Giter Site home page Giter Site logo

haukex / webperl Goto Github PK

View Code? Open in Web Editor NEW
269.0 21.0 18.0 6.15 MB

Run Perl in the browser with WebPerl!

Home Page: https://webperl.zero-g.net

License: Other

Perl 27.13% Shell 2.90% CSS 1.34% JavaScript 18.69% HTML 49.94%
perl perl5 web javascript webapp webapplication web-application webapp-framework web-application-framework dom-manipulation

webperl's Introduction

WebPerl

Welcome to WebPerl! Please see the documentation on the main site:

http://webperl.zero-g.net: Using, Building, Notes

As well as the GitHub Wiki.

You can also check out all of the documentation into subdirectories of this project, for example:

$ git clone --branch gh-pages https://github.com/haukex/webperl.git pages
$ git clone https://github.com/haukex/webperl.wiki.git wiki

Author, Copyright, and License

WebPerl - http://webperl.zero-g.net

Copyright (c) 2018 Hauke Daempfling ([email protected]) at the Leibniz Institute of Freshwater Ecology and Inland Fisheries (IGB), Berlin, Germany, http://www.igb-berlin.de

This program is free software; you can redistribute it and/or modify it under the same terms as Perl 5 itself: either the GNU General Public License as published by the Free Software Foundation (either version 1, or, at your option, any later version), or the "Artistic License" which comes with Perl 5.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the licenses for details.

You should have received a copy of the licenses along with this program. If not, see http://perldoc.perl.org/index-licence.html.

webperl's People

Contributors

haukex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

webperl's Issues

Opening the demo HTMLs locally via file:// doesn't work

Loading failed for the <script> with source “file:///tmp/webperl_prebuilt_v0.01-beta/mini_ide/null/tmp/webperl_prebuilt_v0.01-beta/emperl.js”.

I think probably the baseurl resolution in webperl.js is failing for file:// URLs.

Until I fix this, the workaround is to use a web server like plackup webperl.psgi.

missing module Digest::MD5

This is a pretty amazing project! For fun I wanted to see how much of https://github.com/AlDanial/cloc I could run in the browser. I changed webperl_demo.html to

<script type="text/perl">
use Digest::MD5;
print "Hello, Perl World!\n";
</script>

and got the error

Can't locate Digest/MD5.pm in @INC (you may need to install the Digest::MD5 module) (@INC contains: /opt/perl/lib/site_perl/5.28.0/wasm /opt/perl/lib/site_perl/5.28.0 /opt/perl/lib/5.28.0/wasm /opt/perl/lib/5.28.0) at /tmp/scripts.pl line 13.
BEGIN failed--compilation aborted at /tmp/scripts.pl line 13.
exit(2) called, but NO_EXIT_RUNTIME is set, so halting execution but not exiting the runtime or preventing further async execution (build with NO_EXIT_RUNTIME=0, if you want a true shutdown)

I realize you can't possibly include all of CPAN's modules in your wasm collection, but perhaps you could add some of the more popular ones?

Here, have a cpanfile

Here, have a cpanfile:

requires 'Archive::Tar';
requires 'Archive::Zip';
requires 'Carp';
requires 'Cpanel::JSON::XS';
requires 'ExtUtils::MakeMaker';
requires 'File::Copy::Recursive';
requires 'File::Replace';
requires 'File::Temp';
requires 'FindBin';
requires 'Getopt::Long';
requires 'HTTP::Tiny';
requires 'Hash::Util';
requires 'IO::Socket::SSL';
requires 'IPC::Run3::Shell';
requires 'Net::SSLeay';
requires 'Path::Class';
requires 'Pod::Strip';
requires 'URI';
requires 'Time::HiRes';
requires 'Graph';
requires 'Memoize';
requires 'Memoize::Storable';
requires 'Devel::GlobalDestruction';
requires 'MetaCPAN::Client';
requires 'Module::CoreList';
requires 'IO::Select';
requires 'Socket';
requires 'Term::ANSIColor';
requires 'Module::Load::Conditional';
requires 'Plack';
requires 'Plack::App::Directory';
requires 'Plack::Builder';
requires 'Plack::MIME';
requires 'IPC::Open2';

For some odd reason I couldn't get github to play with me.:


> git push --set-upstream origin cpanfile
> ERROR: Permission to haukex/webperl.git denied to davehodg.
> fatal: Could not read from remote repository.
> 
> Please make sure you have the correct access rights
> and the repository exists.
> 

Perl v5.38 Support?

Howdy @haukex, I hope this message reaches you well my friend!

There has been a bit of discussion about WebPerl online today, and it's been a while, so I figured I'd open an issue just to see how your Perl projects have been coming along lately?

Oh yeah, and it would be great to have Perl v5.38 support at some point... :-)

Unexpected termination in JS.do console

Describe the bug
Running a simple, valid program in the JS.do example website may lead to a valid script terminating.

Error message is:
Operation """": no method found, argument in overloaded package WebPerl::JSObject. exit(255) called, but NO_EXIT_RUNTIME is set, so halting execution but not exiting the runtime or preventing further async execution (build with NO_EXIT_RUNTIME=0, if you want a true shutdown)

To Reproduce

  1. Open https://js.do/perl/
  2. Paste and run this program:
use v5.28;
use WebPerl 'js';
use strict;
use warnings;

my $doc = js("document");
say $doc->{location}{href};

my $p = $doc->createElement('p');
$p->{innerText} = "I am perldom";
$p->{style}{cssText} = 'background: green; border: 3px red solid;';

my $container = $doc->{body}->querySelector('div.container');
$container->appendChild( $p );
#1
  1. Note that the code runs and then show an error message.
  2. Uncomment the last line, so that '1' is now a statement
  3. Click run, the code will work without errors.

Expected behavior vs. actual behavior

This code should run identically with or without the trailing constant.

Versions

  • Device: desktop
  • OS: OSX 10.14.4 (18E226)
  • Browser and version: Safari Version 12.1 (14607.1.40.1.4)
  • WebPerl: whatever is hosted on js.do

Additional context
Add any other context about the problem here. If applicable, add screenshots to help explain your problem.

Don't get past "Perl loading".

perl 5.24, freshly brewed. The only error from the .psgi is:

127.0.0.1 - - [23/Oct/2018:10:44:59 +0100] "GET /emperl.js HTTP/1.1" 404 9 "http://localhost:5000/democode/perlrunner.html" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:62.0) Gecko/20100101 Firefox/62.0"

Which isn't in the pack I got from git. I see:

screen shot 2018-10-23 at 10 46 44

In the build directory I get:

./build.pl 
Please run '. emperl_config.sh' to set up the environment variables.
DAVIDs-MBP:build daveh$ . emperl_config.sh
-bash: /Users/daveh/emsdk/emsdk_env.sh: No such file or directory

Perl -> JS Interpretation Suggestion

Hello,

As someone who is very interested in this project, I wanted to know what would be the simplest way of going about running Perl in the browser. I see that in order to do this, we will likely have to work with the binary data that comes with each file. However, why not have the Perl script saved or "read" as a text file, then JavaScript receives the data and runs functions based on what was written (with Python as a medium)? It seems possible because the file can be interpreted line by line instead of doing a bunch of str.replace()s. We can use JavaScript's object to translate each Perl method while keeping note of brackets.

One reason for me suggesting this is because, looking through the scripts, this seems to be geared more towards the server-side of things, when users may have to test Perl on the client-side of their programs. Plus, it seems a lot simpler than having to go through an entire build process of procedures.

P.S.: It would really be helpful if you could include which files are useable and which files are to be worked on for/by users in the README.

Restructure to look like other dists

Can we structure things to look like other dists?

A lib/ directory for modules
html/ for HTML
js/ for JavaScript
css/ for CSS.
.psgi in the root or a bin/ directory
t/ for tests. We do have tests, right?
Maybe we could work in some Selenium tests?

Use ExtUtils::MakeMaker to tie everything together. Perhaps in the hope we might one day install things. And run tests.

pending-author.t is not happy

Describe the bug
I was trying to compile webperl, so that I can add some additional modules (although I haven't got that far yet), and the compile failed because my "git" name is not in the "authors" file.

To Reproduce
I was following the instructions on the website, and ./build/build.pl was going along gangbusters, and then it failed:

	t/porting/pending-author ....................................... Ricky Morse  <[email protected]> not found in AUTHORS
	FAILED at test 1

...

	Failed 1 test out of 2467, 99.96% okay.
		porting/pending-author.t
	### Since not all tests were successful, you may want to run some of
	### them individually and examine any diagnostic messages they produce.
	### See the INSTALL document's section on "make test".
	### You have a good chance to get more information by running
	###   ./perl harness
	### in the 't' directory since most (>=80%) of the tests succeeded.
	### You may have to set your dynamic library search path,
	### DYLD_LIBRARY_PATH, to point to the build directory:
	###   setenv DYLD_LIBRARY_PATH `pwd`; cd t; ./perl harness
	###   DYLD_LIBRARY_PATH=`pwd`; export DYLD_LIBRARY_PATH; cd t; ./perl harness
	###   export DYLD_LIBRARY_PATH=`pwd`; cd t; ./perl harness
	### for csh-style shells, like tcsh; or for traditional/modern
	### Bourne-style shells, like bash, ksh, and zsh, respectively.
	Elapsed: 620 sec
	u=4.62  s=2.83  cu=334.57  cs=45.55  scripts=2467  tests=1158999
	make: *** [test] Error 1
	Command "make" failed: exit status 2 at ./build/build.pl line 206.

Expected behavior vs. actual behavior
I had hoped it would compile.

Versions

  • Device: compiling on Mac OS X 10.13.6
  • Perl: 5.28, it seems
  • Emscripten: 1.38.21-64bit

webperl waits for process to finish

Describe the bug

Perl.makeOutputTextarea()

Won't work with loop because it waits for finished execution

To Reproduce

Include emperl.* in the folder as well as webperl.js and this index.html:

<!DOCTYPE html>
<html>
    <head>
        <script src="./webperl.js"></script>
        <script type="text/perl" src="./main.pl">
        </script>
        <script>
            window.addEventListener("load", function () {document.body.appendChild(Perl.makeOutputTextarea());});
        </script>
    </head>
    <body></body>
</html>

And this main.pl:

while(1){
  print "1"
}

Expected behavior vs. actual behavior

I would expect the created textarea to update continuously but instead the tab freeze.

Restart without reload

The demo pages go to great lengths to work around the fact that WebPerl can only be run once.

The comment in perlrunner.html says

Of course, at some point I should investigate how difficult it really is to re-start an Emscripten program...

What's the status of this? Are there any references or hints from Emscripten devs about that? It would be really nice to be able to run WebPerl multiple times directly without IFrame work-arounds.

Patch for library.js needs small adjustment for emscripten 1.39.16

Describe the bug
The emscript_38.xx patches can't be applied for emscripten 39.16. The original file changed a bit.

A small patch for build.pl

--- build.pl.orig	2020-05-18 17:45:33.704724349 +0200
+++ build.pl	2020-05-18 17:45:14.232537643 +0200
@@ -97,6 +97,8 @@
 	my $patchf;
 	if ( $libraryjs=~/\b\Q___setErrNo(ERRNO_CODES.\E(EAGAIN|ENOTSUP)\b/ )
 		{ $patchf = 'emscripten_1.38.10_eagain.patch' }
+	elsif ( $libraryjs=~/no shell available\s+setErrNo\Q({{{ cDefine('EAGAIN') }}})\E/ )
+		{ $patchf = 'emscripten_1.39.16_eagain.patch' }
 	elsif ( $libraryjs=~/\b\QcDefine('EAGAIN')\E/ ) # note that this appears in 1.38.1* versions too
 		{ $patchf = 'emscripten_1.38.28_eagain.patch' }
 	else { die "Could not figure out which library.js patch to use" }

And the patch for library.js

--- library.js.orig     2020-05-18 17:14:18.682328912 +0200
+++ library.js  2020-05-18 17:14:48.366639562 +0200
@@ -271,7 +271,7 @@
     // pid_t fork(void);
     // http://pubs.opengroup.org/onlinepubs/000095399/functions/fork.html
     // We don't support multiple processes.
-    setErrNo({{{ cDefine('EAGAIN') }}});
+    setErrNo({{{ cDefine('ENOTSUP') }}});
     return -1;
   },
   vfork: 'fork',
@@ -696,7 +696,7 @@
     // http://pubs.opengroup.org/onlinepubs/000095399/functions/system.html
     // Can't call external programs.
     if (!command) return 0; // no shell available
-    setErrNo({{{ cDefine('EAGAIN') }}});
+    setErrNo({{{ cDefine('ENOTSUP') }}});
     return -1;
   },

Fatal error in patchlevel.h

Hi! I was able to get past the bug in pending-author.t by editing it to be skipped. However, now I get the following:

	[...]
	$ cd /Users/rem16/git/webperl
	# Rebuilding /Users/rem16/git/webperl/work/outputperl/opt/perl...
	mkdir /Users/rem16/git/webperl/work/outputperl
	mkdir /Users/rem16/git/webperl/work/outputperl/opt
	mkdir /Users/rem16/git/webperl/work/outputperl/opt/perl
	$ cd /Users/rem16/git/webperl/emperl5
	$ emmake make perl
	/Users/rem16/git/emsdk/emscripten/1.38.21/emcc     perl.c   -o perl
	In file included from perl.c:38:
	./patchlevel.h:132:10: fatal error: 'git_version.h' file not found
	#include "git_version.h"
			 ^~~~~~~~~~~~~~~
	1 error generated.
	shared:ERROR: compiler frontend failed to generate LLVM bitcode, halting
	make: *** [perl] Error 1
	Command "emmake" failed: exit status 2 at build/build.pl line 320.
	$ cd /Users/rem16/git/webperl

This is after something like 15-20 minutes of compiling.

I'm on a Mac, running macOS 10.13.6.

Please edit 'emperl_config.sh' to point it to the correct location of 'emsdk_env.sh'

Probably a school boy error on my part, but I get the error:

Please edit 'emperl_config.sh' to point it to the correct location of 'emsdk_env.sh'

However, I have set 'emperl_config.sh' to point it to the correct location. As I can manually run it, which gives the following output:

Setting environment variables:
EMSDK = /home/dev/emsdk
EM_CACHE = /home/dev/emsdk/upstream/emscripten/cache

It seems that the environment variable EMSCRIPTEN isn't being set?

I am new to emscripten, I followed the steps to create a basic example which worked so I assume my emscripten environment is set up correctly?

My environment:

Clean Ubuntu: Ubuntu 18.04.4 LTS
Perl: v5.26.1
webperl: Latest from git
emscripten: Latest.

Is master branch working?

hi, I'm trying to automate the build process via docker and encountered various problems, some of them were solved

I would like to clarify whether I am using the correct branch? working master or v0.9-beta? Thank you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.