Correcting styling on docs, and eval bug in pib_eval.c
No files matched your search
@@ -49,7 +49,7 @@ third_party/sqlite3.33-src/sqlite3.c:
|
||||
@ mv sqlite-amalgamation-3330000 third_party/sqlite3.33-src
|
||||
@ rm sqlite-amalgamation-3330000.zip*
|
||||
@ git apply --no-index patch/sqlite3-wasm.patch
|
||||
@ cp third_party/sqlite3.33-src/sqlite3.* third_party/php7.4-src/
|
||||
@ cp third_party/sqlite3.33-src/sqlite3.* source/
|
||||
|
||||
third_party/php7.4-src/ext/vrzno/README.md:
|
||||
git clone https://github.com/seanmorris/vrzno.git third_party/php7.4-src/ext/vrzno \
|
||||
@@ -71,8 +71,7 @@ third_party/libxml2:
|
||||
|
||||
########### Build the objects. ###########
|
||||
|
||||
lib/libphp7.a: third_party/php7.4-src/patched third_party/php7.4-src/ext/vrzno/README.md third_party/php7.4-src/**.c third_party/php7.4-src/**.h
|
||||
@ ${DOCKER_RUN_IN_PHP} rm -rf configure
|
||||
lib/libphp7.a: third_party/php7.4-src/patched third_party/php7.4-src/ext/vrzno/README.md
|
||||
@ ${DOCKER_RUN_IN_PHP} ./buildconf --force | ${TIMER}
|
||||
@ ${DOCKER_RUN_IN_PHP} emconfigure ./configure \
|
||||
--enable-embed=static \
|
||||
@@ -96,7 +95,7 @@ lib/libphp7.a: third_party/php7.4-src/patched third_party/php7.4-src/ext/vrzno/R
|
||||
--disable-mbregex \
|
||||
--enable-tokenizer \
|
||||
--enable-vrzno | ${TIMER}
|
||||
@ cp third_party/php7.4-src/.libs/* lib
|
||||
@ cp -v third_party/php7.4-src/.libs/* lib
|
||||
|
||||
lib/pib_eval.o: source/pib_eval.c lib/libphp7.a
|
||||
@ ${DOCKER_RUN_IN_PHP} emmake make -j8
|
||||
@@ -120,7 +119,7 @@ FINAL_BUILD=${DOCKER_RUN_IN_PHP} emcc ${OPTIMIZE} \
|
||||
-o ../../build/php-${ENVIRONMENT}${RELEASE_SUFFUX}.js \
|
||||
--llvm-lto 2 \
|
||||
--preload-file ${PRELOAD_ASSETS} \
|
||||
-s EXPORTED_FUNCTIONS='["_pib_init", "_pib_destroy", "_pib_eval" "_pib_refresh", "_main", "_php_embed_init", "_php_embed_shutdown", "_php_embed_shutdown", "_zend_eval_string", "_exec_callback", "_del_callback"]' \
|
||||
-s EXPORTED_FUNCTIONS='["_pib_init", "_pib_destroy", "_pib_run", "_pib_exec" "_pib_refresh", "_main", "_php_embed_init", "_php_embed_shutdown", "_php_embed_shutdown", "_zend_eval_string", "_exec_callback", "_del_callback"]' \
|
||||
-s EXTRA_EXPORTED_RUNTIME_METHODS='["ccall", "UTF8ToString", "lengthBytesUTF8"]' \
|
||||
-s ENVIRONMENT=${ENVIRONMENT} \
|
||||
-s ERROR_ON_UNDEFINED_SYMBOLS=0 \
|
||||
@@ -135,11 +134,14 @@ php-web.wasm: ENVIRONMENT=web
|
||||
php-web.wasm: lib/libphp7.a lib/pib_eval.o source/**.c source/**.h
|
||||
@ ${FINAL_BUILD}
|
||||
cp -v build/php-${ENVIRONMENT}${RELEASE_SUFFUX}.* ./
|
||||
cp -v build/php-${ENVIRONMENT}${RELEASE_SUFFUX}.* ./source_docs/source/assets
|
||||
cp -v build/php-${ENVIRONMENT}${RELEASE_SUFFUX}.* ./source_docs/docs
|
||||
|
||||
php-worker.wasm: ENVIRONMENT=worker
|
||||
php-worker.wasm: lib/libphp7.a lib/pib_eval.o source/**.c source/**.h
|
||||
@ ${FINAL_BUILD}
|
||||
cp -v build/php-${ENVIRONMENT}${RELEASE_SUFFUX}.* ./
|
||||
cp -v build/php-${ENVIRONMENT}${RELEASE_SUFFUX}.* ./source_docs/docs
|
||||
|
||||
php-node.wasm: ENVIRONMENT=node
|
||||
php-node.wasm: lib/libphp7.a lib/pib_eval.o source/**.c source/**.h
|
||||
@@ -156,6 +158,7 @@ php-webview.wasm: lib/libphp7.a lib/pib_eval.o source/**.c source/**.h
|
||||
@ ${FINAL_BUILD}
|
||||
cp -v build/php-${ENVIRONMENT}${RELEASE_SUFFUX}.* ./
|
||||
|
||||
|
||||
########### Clerical stuff. ###########
|
||||
|
||||
clean:
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
!.gitignore
|
||||
node_modules
|
||||
@@ -0,0 +1,20 @@
|
||||
module.exports = {
|
||||
files: {
|
||||
javascripts: {joinTo: 'app.js'}
|
||||
, stylesheets: {joinTo: 'app.css'}
|
||||
}
|
||||
, plugins: {
|
||||
babel: {
|
||||
presets: ['@babel/preset-env']
|
||||
, plugins: ["@babel/plugin-proposal-class-properties"]
|
||||
}
|
||||
, raw: {
|
||||
pattern: /\.tmp\.(.+)$/,
|
||||
wrapper: content => `module.exports = ${JSON.stringify(content)}`
|
||||
}
|
||||
}
|
||||
, paths: {
|
||||
public: 'docs'
|
||||
, watched: ['source/', 'build/']
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
../docs
|
||||
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"name": "php-wasm-doc",
|
||||
"version": "0.0.0",
|
||||
"description": "Demo for php-wasm.",
|
||||
"main": "index.js",
|
||||
"author": "Sean Morris",
|
||||
"license": "Apache-2.0",
|
||||
"scripts": {
|
||||
"postinstall": "cp -rfv node_modules/php-wasm/php-web.* docs/"
|
||||
},
|
||||
"dependencies": {
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.8.4",
|
||||
"@babel/core": "^7.8.7",
|
||||
"@babel/preset-env": "^7.0.0",
|
||||
"auto-reload-brunch": "^2.7.1",
|
||||
"babel-brunch": "^7.0.1",
|
||||
"babel-minify": "^0.5.1",
|
||||
"babel-preset-es2015": "^6.24.1",
|
||||
"brunch": "^3.0.0",
|
||||
"clean-css-brunch": "^3.0.0",
|
||||
"raw-brunch": "^1.0.2",
|
||||
"uglify-js-brunch": "^2.10.0",
|
||||
"php-wasm": "^0.0.3"
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 210 B |
|
After Width: | Height: | Size: 213 B |
|
After Width: | Height: | Size: 214 B |
|
After Width: | Height: | Size: 2.2 KiB |
@@ -0,0 +1,99 @@
|
||||
<!DOCTYPE html>
|
||||
<head>
|
||||
<style>@import url('/app.css')</style>
|
||||
<script src="/app.js"></script>
|
||||
<script>require('source/initialize');</script>
|
||||
<script src="//ajaxorg.github.io/ace-builds/src-min/ace.js" type="text/javascript" charset="utf-8"></script>
|
||||
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class = "row header toolbar">
|
||||
<div class = "cols">
|
||||
<div class = "row start">
|
||||
<a target = "_blank" href = "https://github.com/oraoto">
|
||||
<img class = "round" src = "/oraoto-icon.png" />
|
||||
</a>
|
||||
<a target = "_blank" href = "https://github.com/seanmorris">
|
||||
<img class = "round" src = "/sean-icon.png" />
|
||||
</a>
|
||||
<h1>php-wasm</h1>
|
||||
</div>
|
||||
</div>
|
||||
<div class = "row rows">
|
||||
<label>
|
||||
<span>Persist Memory</span>
|
||||
<input type = "checkbox" id = "persist" />
|
||||
</label>
|
||||
<label>
|
||||
<span>Single Expression</span>
|
||||
<input type = "checkbox" id = "single-expression" />
|
||||
</label>
|
||||
</div>
|
||||
<button data-run>execute</button>
|
||||
<!-- <button data-run>tokenize</button> -->
|
||||
</div>
|
||||
|
||||
<div class = "row body">
|
||||
<div class = "panel">
|
||||
<div class = "input">
|
||||
<div class = "cols">
|
||||
<label tabindex="-1">
|
||||
Input PHP Code
|
||||
</label>
|
||||
<!-- <button>open file</button> -->
|
||||
|
||||
</div>
|
||||
<textarea></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class = "panel">
|
||||
<div id = "ret">
|
||||
<label tabindex="-1">return</label>
|
||||
<div class = "stdret output liquid">
|
||||
<div class = "column">
|
||||
<div class = "scroller"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label tabindex="-1">stdout</label>
|
||||
<div class = "stdout output liquid">
|
||||
<div class = "column">
|
||||
<div class = "scroller"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label tabindex="-1">stderr</label>
|
||||
<div class = "stderr output liquid">
|
||||
<div class = "column">
|
||||
<div class = "scroller"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class = "row status toolbar">
|
||||
<div>
|
||||
<div class = "row start" data-status>
|
||||
php-wasm
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
<!--
|
||||
|
||||
-->
|
||||
|
||||
<!-- <body>
|
||||
|
||||
|
||||
<div class = "row footer">foot</div>
|
||||
</body>
|
||||
-->
|
||||
|
After Width: | Height: | Size: 14 KiB |
@@ -0,0 +1,422 @@
|
||||
<?php
|
||||
if (function_exists("date_default_timezone_set")) {
|
||||
date_default_timezone_set("UTC");
|
||||
}
|
||||
|
||||
function simple() {
|
||||
$a = 0;
|
||||
for ($i = 0; $i < 1000000; $i++)
|
||||
$a++;
|
||||
|
||||
$thisisanotherlongname = 0;
|
||||
for ($thisisalongname = 0; $thisisalongname < 1000000; $thisisalongname++)
|
||||
$thisisanotherlongname++;
|
||||
}
|
||||
|
||||
/****/
|
||||
|
||||
function simplecall() {
|
||||
for ($i = 0; $i < 1000000; $i++)
|
||||
strlen("hallo");
|
||||
}
|
||||
|
||||
/****/
|
||||
|
||||
function hallo($a) {
|
||||
}
|
||||
|
||||
function simpleucall() {
|
||||
for ($i = 0; $i < 1000000; $i++)
|
||||
hallo("hallo");
|
||||
}
|
||||
|
||||
/****/
|
||||
|
||||
function simpleudcall() {
|
||||
for ($i = 0; $i < 1000000; $i++)
|
||||
hallo2("hallo");
|
||||
}
|
||||
|
||||
function hallo2($a) {
|
||||
}
|
||||
|
||||
/****/
|
||||
|
||||
function mandel() {
|
||||
$w1=50;
|
||||
$h1=150;
|
||||
$recen=-.45;
|
||||
$imcen=0.0;
|
||||
$r=0.7;
|
||||
$s=0; $rec=0; $imc=0; $re=0; $im=0; $re2=0; $im2=0;
|
||||
$x=0; $y=0; $w2=0; $h2=0; $color=0;
|
||||
$s=2*$r/$w1;
|
||||
$w2=40;
|
||||
$h2=12;
|
||||
for ($y=0 ; $y<=$w1; $y=$y+1) {
|
||||
$imc=$s*($y-$h2)+$imcen;
|
||||
for ($x=0 ; $x<=$h1; $x=$x+1) {
|
||||
$rec=$s*($x-$w2)+$recen;
|
||||
$re=$rec;
|
||||
$im=$imc;
|
||||
$color=1000;
|
||||
$re2=$re*$re;
|
||||
$im2=$im*$im;
|
||||
while( ((($re2+$im2)<1000000) && $color>0)) {
|
||||
$im=$re*$im*2+$imc;
|
||||
$re=$re2-$im2+$rec;
|
||||
$re2=$re*$re;
|
||||
$im2=$im*$im;
|
||||
$color=$color-1;
|
||||
}
|
||||
if ( $color==0 ) {
|
||||
print "_";
|
||||
} else {
|
||||
print "#";
|
||||
}
|
||||
}
|
||||
print "<br>";
|
||||
flush();
|
||||
}
|
||||
}
|
||||
|
||||
/****/
|
||||
|
||||
function mandel2() {
|
||||
$b = " .:,;!/>)|&IH%*#";
|
||||
//float r, i, z, Z, t, c, C;
|
||||
for ($y=30; printf("\n"), $C = $y*0.1 - 1.5, $y--;){
|
||||
for ($x=0; $c = $x*0.04 - 2, $z=0, $Z=0, $x++ < 75;){
|
||||
for ($r=$c, $i=$C, $k=0; $t = $z*$z - $Z*$Z + $r, $Z = 2*$z*$Z + $i, $z=$t, $k<5000; $k++)
|
||||
if ($z*$z + $Z*$Z > 500000) break;
|
||||
echo $b[$k%16];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/****/
|
||||
|
||||
function Ack($m, $n){
|
||||
if($m == 0) return $n+1;
|
||||
if($n == 0) return Ack($m-1, 1);
|
||||
return Ack($m - 1, Ack($m, ($n - 1)));
|
||||
}
|
||||
|
||||
function ackermann($n) {
|
||||
$r = Ack(3,$n);
|
||||
print "Ack(3,$n): $r\n";
|
||||
}
|
||||
|
||||
/****/
|
||||
|
||||
function ary($n) {
|
||||
for ($i=0; $i<$n; $i++) {
|
||||
$X[$i] = $i;
|
||||
}
|
||||
for ($i=$n-1; $i>=0; $i--) {
|
||||
$Y[$i] = $X[$i];
|
||||
}
|
||||
$last = $n-1;
|
||||
print "$Y[$last]\n";
|
||||
}
|
||||
|
||||
/****/
|
||||
|
||||
function ary2($n) {
|
||||
for ($i=0; $i<$n;) {
|
||||
$X[$i] = $i; ++$i;
|
||||
$X[$i] = $i; ++$i;
|
||||
$X[$i] = $i; ++$i;
|
||||
$X[$i] = $i; ++$i;
|
||||
$X[$i] = $i; ++$i;
|
||||
|
||||
$X[$i] = $i; ++$i;
|
||||
$X[$i] = $i; ++$i;
|
||||
$X[$i] = $i; ++$i;
|
||||
$X[$i] = $i; ++$i;
|
||||
$X[$i] = $i; ++$i;
|
||||
}
|
||||
for ($i=$n-1; $i>=0;) {
|
||||
$Y[$i] = $X[$i]; --$i;
|
||||
$Y[$i] = $X[$i]; --$i;
|
||||
$Y[$i] = $X[$i]; --$i;
|
||||
$Y[$i] = $X[$i]; --$i;
|
||||
$Y[$i] = $X[$i]; --$i;
|
||||
|
||||
$Y[$i] = $X[$i]; --$i;
|
||||
$Y[$i] = $X[$i]; --$i;
|
||||
$Y[$i] = $X[$i]; --$i;
|
||||
$Y[$i] = $X[$i]; --$i;
|
||||
$Y[$i] = $X[$i]; --$i;
|
||||
}
|
||||
$last = $n-1;
|
||||
print "$Y[$last]\n";
|
||||
}
|
||||
|
||||
/****/
|
||||
|
||||
function ary3($n) {
|
||||
for ($i=0; $i<$n; $i++) {
|
||||
$X[$i] = $i + 1;
|
||||
$Y[$i] = 0;
|
||||
}
|
||||
for ($k=0; $k<1000; $k++) {
|
||||
for ($i=$n-1; $i>=0; $i--) {
|
||||
$Y[$i] += $X[$i];
|
||||
}
|
||||
}
|
||||
$last = $n-1;
|
||||
print "$Y[0] $Y[$last]\n";
|
||||
}
|
||||
|
||||
/****/
|
||||
|
||||
function fibo_r($n){
|
||||
return(($n < 2) ? 1 : fibo_r($n - 2) + fibo_r($n - 1));
|
||||
}
|
||||
|
||||
function fibo($n) {
|
||||
$r = fibo_r($n);
|
||||
print "$r\n";
|
||||
}
|
||||
|
||||
/****/
|
||||
|
||||
function hash1($n) {
|
||||
for ($i = 1; $i <= $n; $i++) {
|
||||
$X[dechex($i)] = $i;
|
||||
}
|
||||
$c = 0;
|
||||
for ($i = $n; $i > 0; $i--) {
|
||||
if ($X[dechex($i)]) { $c++; }
|
||||
}
|
||||
print "$c\n";
|
||||
}
|
||||
|
||||
/****/
|
||||
|
||||
function hash2($n) {
|
||||
for ($i = 0; $i < $n; $i++) {
|
||||
$hash1["foo_$i"] = $i;
|
||||
$hash2["foo_$i"] = 0;
|
||||
}
|
||||
for ($i = $n; $i > 0; $i--) {
|
||||
foreach($hash1 as $key => $value) $hash2[$key] += $value;
|
||||
}
|
||||
$first = "foo_0";
|
||||
$last = "foo_".($n-1);
|
||||
print "$hash1[$first] $hash1[$last] $hash2[$first] $hash2[$last]\n";
|
||||
}
|
||||
|
||||
/****/
|
||||
|
||||
function gen_random ($n) {
|
||||
global $LAST;
|
||||
return( ($n * ($LAST = ($LAST * IA + IC) % IM)) / IM );
|
||||
}
|
||||
|
||||
function heapsort_r($n, &$ra) {
|
||||
$l = ($n >> 1) + 1;
|
||||
$ir = $n;
|
||||
|
||||
while (1) {
|
||||
if ($l > 1) {
|
||||
$rra = $ra[--$l];
|
||||
} else {
|
||||
$rra = $ra[$ir];
|
||||
$ra[$ir] = $ra[1];
|
||||
if (--$ir == 1) {
|
||||
$ra[1] = $rra;
|
||||
return;
|
||||
}
|
||||
}
|
||||
$i = $l;
|
||||
$j = $l << 1;
|
||||
while ($j <= $ir) {
|
||||
if (($j < $ir) && ($ra[$j] < $ra[$j+1])) {
|
||||
$j++;
|
||||
}
|
||||
if ($rra < $ra[$j]) {
|
||||
$ra[$i] = $ra[$j];
|
||||
$j += ($i = $j);
|
||||
} else {
|
||||
$j = $ir + 1;
|
||||
}
|
||||
}
|
||||
$ra[$i] = $rra;
|
||||
}
|
||||
}
|
||||
|
||||
function heapsort($N) {
|
||||
global $LAST;
|
||||
|
||||
define("IM", 139968);
|
||||
define("IA", 3877);
|
||||
define("IC", 29573);
|
||||
|
||||
$LAST = 42;
|
||||
for ($i=1; $i<=$N; $i++) {
|
||||
$ary[$i] = gen_random(1);
|
||||
}
|
||||
heapsort_r($N, $ary);
|
||||
printf("%.10f\n", $ary[$N]);
|
||||
}
|
||||
|
||||
/****/
|
||||
|
||||
function mkmatrix ($rows, $cols) {
|
||||
$count = 1;
|
||||
$mx = array();
|
||||
for ($i=0; $i<$rows; $i++) {
|
||||
for ($j=0; $j<$cols; $j++) {
|
||||
$mx[$i][$j] = $count++;
|
||||
}
|
||||
}
|
||||
return($mx);
|
||||
}
|
||||
|
||||
function mmult ($rows, $cols, $m1, $m2) {
|
||||
$m3 = array();
|
||||
for ($i=0; $i<$rows; $i++) {
|
||||
for ($j=0; $j<$cols; $j++) {
|
||||
$x = 0;
|
||||
for ($k=0; $k<$cols; $k++) {
|
||||
$x += $m1[$i][$k] * $m2[$k][$j];
|
||||
}
|
||||
$m3[$i][$j] = $x;
|
||||
}
|
||||
}
|
||||
return($m3);
|
||||
}
|
||||
|
||||
function matrix($n) {
|
||||
$SIZE = 30;
|
||||
$m1 = mkmatrix($SIZE, $SIZE);
|
||||
$m2 = mkmatrix($SIZE, $SIZE);
|
||||
while ($n--) {
|
||||
$mm = mmult($SIZE, $SIZE, $m1, $m2);
|
||||
}
|
||||
print "{$mm[0][0]} {$mm[2][3]} {$mm[3][2]} {$mm[4][4]}\n";
|
||||
}
|
||||
|
||||
/****/
|
||||
|
||||
function nestedloop($n) {
|
||||
$x = 0;
|
||||
for ($a=0; $a<$n; $a++)
|
||||
for ($b=0; $b<$n; $b++)
|
||||
for ($c=0; $c<$n; $c++)
|
||||
for ($d=0; $d<$n; $d++)
|
||||
for ($e=0; $e<$n; $e++)
|
||||
for ($f=0; $f<$n; $f++)
|
||||
$x++;
|
||||
print "$x\n";
|
||||
}
|
||||
|
||||
/****/
|
||||
|
||||
function sieve($n) {
|
||||
$count = 0;
|
||||
while ($n-- > 0) {
|
||||
$count = 0;
|
||||
$flags = range (0,8192);
|
||||
for ($i=2; $i<8193; $i++) {
|
||||
if ($flags[$i] > 0) {
|
||||
for ($k=$i+$i; $k <= 8192; $k+=$i) {
|
||||
$flags[$k] = 0;
|
||||
}
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
print "Count: $count\n";
|
||||
}
|
||||
|
||||
/****/
|
||||
|
||||
function strcat($n) {
|
||||
$str = "";
|
||||
while ($n-- > 0) {
|
||||
$str .= "hello\n";
|
||||
}
|
||||
$len = strlen($str);
|
||||
print "$len\n";
|
||||
}
|
||||
|
||||
/*****/
|
||||
|
||||
function gethrtime()
|
||||
{
|
||||
$hrtime = hrtime();
|
||||
return (($hrtime[0]*1000000000 + $hrtime[1]) / 1000000000);
|
||||
}
|
||||
|
||||
function start_test()
|
||||
{
|
||||
ob_start();
|
||||
return gethrtime();
|
||||
}
|
||||
|
||||
function end_test($start, $name)
|
||||
{
|
||||
global $total;
|
||||
$end = gethrtime();
|
||||
ob_end_clean();
|
||||
$total += $end-$start;
|
||||
$num = number_format($end-$start,3);
|
||||
$pad = str_repeat(" ", 24-strlen($name)-strlen($num));
|
||||
|
||||
echo $name.$pad.$num."\n";
|
||||
ob_start();
|
||||
return gethrtime();
|
||||
}
|
||||
|
||||
function total()
|
||||
{
|
||||
global $total;
|
||||
$pad = str_repeat("-", 24);
|
||||
echo $pad."\n";
|
||||
$num = number_format($total,3);
|
||||
$pad = str_repeat(" ", 24-strlen("Total")-strlen($num));
|
||||
echo "Total".$pad.$num."\n";
|
||||
}
|
||||
|
||||
$t0 = $t = start_test();
|
||||
simple();
|
||||
$t = end_test($t, "simple");
|
||||
simplecall();
|
||||
$t = end_test($t, "simplecall");
|
||||
simpleucall();
|
||||
$t = end_test($t, "simpleucall");
|
||||
simpleudcall();
|
||||
$t = end_test($t, "simpleudcall");
|
||||
mandel();
|
||||
$t = end_test($t, "mandel");
|
||||
mandel2();
|
||||
$t = end_test($t, "mandel2");
|
||||
ackermann(7);
|
||||
$t = end_test($t, "ackermann(7)");
|
||||
ary(50000);
|
||||
$t = end_test($t, "ary(50000)");
|
||||
ary2(50000);
|
||||
$t = end_test($t, "ary2(50000)");
|
||||
ary3(2000);
|
||||
$t = end_test($t, "ary3(2000)");
|
||||
fibo(30);
|
||||
$t = end_test($t, "fibo(30)");
|
||||
hash1(50000);
|
||||
$t = end_test($t, "hash1(50000)");
|
||||
hash2(500);
|
||||
$t = end_test($t, "hash2(500)");
|
||||
heapsort(20000);
|
||||
$t = end_test($t, "heapsort(20000)");
|
||||
matrix(20);
|
||||
$t = end_test($t, "matrix(20)");
|
||||
nestedloop(12);
|
||||
$t = end_test($t, "nestedloop(12)");
|
||||
sieve(30);
|
||||
$t = end_test($t, "sieve(30)");
|
||||
strcat(200000);
|
||||
$t = end_test($t, "strcat(200000)");
|
||||
total();
|
||||
?>
|
||||
|
After Width: | Height: | Size: 716 B |
@@ -0,0 +1,156 @@
|
||||
"use strict";
|
||||
|
||||
const PHP = require('php-wasm/PhpWeb').PhpWeb;
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
|
||||
const input = document.querySelector('.input textarea');
|
||||
const stdret = document.querySelector('.stdret > * > *');
|
||||
const stdout = document.querySelector('.stdout > * > *');
|
||||
const stderr = document.querySelector('.stderr > * > *');
|
||||
const run = document.querySelector('[data-run]');
|
||||
const status = document.querySelector('[data-status]');
|
||||
const editor = ace.edit(input);
|
||||
const ret = document.querySelector('#ret');
|
||||
|
||||
const persistBox = document.getElementById('persist');
|
||||
const singleBox = document.getElementById('single-expression');
|
||||
|
||||
editor.session.setMode("ace/mode/php");
|
||||
editor.setTheme('ace/theme/monokai')
|
||||
|
||||
status.innerText = 'php-wasm loading...';
|
||||
const php = new PHP;
|
||||
|
||||
const query = new URLSearchParams(location.search);
|
||||
|
||||
php.addEventListener('ready', (event) => {
|
||||
status.innerText = 'php-wasm ready!';
|
||||
|
||||
run.addEventListener('click', () => {
|
||||
|
||||
status.innerText = 'Executing...';
|
||||
|
||||
while(stdout.firstChild)
|
||||
{
|
||||
stdout.firstChild.remove();
|
||||
}
|
||||
|
||||
while(stderr.firstChild)
|
||||
{
|
||||
stderr.firstChild.remove();
|
||||
}
|
||||
|
||||
while(stdret.firstChild)
|
||||
{
|
||||
stdret.firstChild.remove();
|
||||
}
|
||||
|
||||
let code = editor.session.getValue();
|
||||
|
||||
if(code.length < 1024)
|
||||
{
|
||||
query.set('code', encodeURIComponent(code));
|
||||
query.set('persist', persistBox.checked ? 1 : 0);
|
||||
history.replaceState({}, document.title, "?" + query.toString());
|
||||
}
|
||||
|
||||
// const runCode = code.replace(/^<\?php/, '');
|
||||
|
||||
console.log(code);
|
||||
|
||||
const func = singleBox.checked
|
||||
? 'exec'
|
||||
: 'run';
|
||||
|
||||
if(singleBox.checked)
|
||||
{
|
||||
code = code.replace(/^\s*<\?php/, '');
|
||||
code = code.replace(/\?>\s*/, '');
|
||||
}
|
||||
|
||||
console.log(func);
|
||||
|
||||
php[func](code).then(ret=>{
|
||||
|
||||
console.log(ret);
|
||||
|
||||
status.innerText = 'php-wasm ready!';
|
||||
|
||||
const row = document.createElement('div');
|
||||
|
||||
row.innerText = ret;
|
||||
row.setAttribute('tabindex', -1);
|
||||
|
||||
row.classList.add('row');
|
||||
|
||||
stdret.append(row);
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
php.addEventListener('output', (event) => {
|
||||
|
||||
console.log('output', event);
|
||||
|
||||
const row = document.createElement('div');
|
||||
|
||||
row.innerText = event.detail.join("\n");
|
||||
row.setAttribute('tabindex', -1);
|
||||
|
||||
row.classList.add('row');
|
||||
|
||||
stdout.append(row);
|
||||
});
|
||||
|
||||
php.addEventListener('error', (event) => {
|
||||
|
||||
console.log('error', event);
|
||||
|
||||
const row = document.createElement('div');
|
||||
|
||||
row.innerText = event.detail.join("\n");
|
||||
row.setAttribute('tabindex', -1);
|
||||
|
||||
row.classList.add('row');
|
||||
|
||||
stderr.append(row);
|
||||
});
|
||||
|
||||
ret.style.display = 'none';
|
||||
|
||||
singleBox.addEventListener('input', event=>{
|
||||
|
||||
if(event.target.checked)
|
||||
{
|
||||
ret.style.display = 'flex';
|
||||
}
|
||||
else
|
||||
{
|
||||
ret.style.display = 'none';
|
||||
}
|
||||
|
||||
console.log(ret, event.target.checked)
|
||||
|
||||
})
|
||||
|
||||
if(query.has('code'))
|
||||
{
|
||||
editor.setValue(decodeURIComponent(query.get('code')));
|
||||
editor.selection.moveCursorFileStart();
|
||||
}
|
||||
else
|
||||
{
|
||||
editor.setValue(`
|
||||
<?php
|
||||
fwrite( fopen('php://stdout', 'w'), "This is STDOUT\\n" );
|
||||
fwrite( fopen('php://stderr', 'w'), "This is STDOUT\\n" );
|
||||
`);
|
||||
|
||||
editor.selection.moveCursorFileEnd();
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
@@ -0,0 +1,220 @@
|
||||
@font-face {
|
||||
src: url('fsex302-webfont.woff') format('woff');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
font-family: 'fixedsys';
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'fixedsys';
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
height: 100vh;
|
||||
padding: 0px;
|
||||
margin: 0px;
|
||||
background-color: #aaa;
|
||||
}
|
||||
|
||||
.output {
|
||||
|
||||
}
|
||||
|
||||
.output .scroller {
|
||||
background-color: #bbb;
|
||||
}
|
||||
|
||||
.output .row {
|
||||
background-color: #FFF;
|
||||
padding: 0.5em 0.5em;
|
||||
border-bottom: 1px white solid;
|
||||
}
|
||||
|
||||
.row.toolbar {
|
||||
margin: 0.5em;
|
||||
padding: 0.5em 0em;
|
||||
border: 2px solid;
|
||||
border-image: url(/border-inset.png) 2 2 2 2;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.row.toolbar > div{
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
padding: 0em 0.5em;
|
||||
flex: 1;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.row.toolbar > div .start{
|
||||
align-items: center;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.row.toolbar button {
|
||||
user-select: none;
|
||||
padding: 0.75em;
|
||||
font-weight: bold;
|
||||
border: 2px solid;
|
||||
align-self: center;
|
||||
margin-right: 0.5em;
|
||||
}
|
||||
|
||||
button {
|
||||
border-image: url(/border.png) 2 2 2 2;
|
||||
}
|
||||
|
||||
*:focus {
|
||||
outline-style: dotted;
|
||||
outline-color: black;
|
||||
}
|
||||
|
||||
.row:focus {
|
||||
background-color: #000082;
|
||||
border-bottom: 1px #000082 solid;
|
||||
color: #FFF;
|
||||
}
|
||||
|
||||
.row.toolbar.header{
|
||||
background-color: #BBB;
|
||||
}
|
||||
|
||||
.row.toolbar.status {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.row.toolbar.status > div {
|
||||
padding: 0.25em;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0em;
|
||||
margin: 0.25em;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
body > div {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.row.body {
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
div.column {
|
||||
position: relative;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
div.column .scroller {
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
left: 0px;
|
||||
bottom: 0px;
|
||||
right: 0px;
|
||||
overflow-y: auto;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
div.panel {
|
||||
font-family: 'fixedsys';
|
||||
display: flex;
|
||||
position: relative;
|
||||
background-color: #aaa;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
padding: 0.5em;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
div.panel div.input {
|
||||
background-color: #272822;
|
||||
}
|
||||
|
||||
div.panel > div {
|
||||
user-select: none;
|
||||
background-color: white;
|
||||
border: 2px solid;
|
||||
border-image: url(/border-inset.png) 2 2 2 2;
|
||||
flex-direction: column;
|
||||
display: flex;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.liquid{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
button,
|
||||
.panel label {
|
||||
border: 2px solid;
|
||||
border-image: url(/border.png) 2 2 2 2 !important;
|
||||
background-color: #c3c3c3;
|
||||
padding: 0.25em;
|
||||
}
|
||||
|
||||
.panel label, .panel .cols button {
|
||||
margin-top: -1px;
|
||||
}
|
||||
|
||||
label[tabindex]:active,
|
||||
button:active {
|
||||
border: 2px solid;
|
||||
border-image: url(/border-inset.png) 2 2 2 2 !important;
|
||||
}
|
||||
|
||||
.header label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.header label p {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
pre {
|
||||
flex: 1;
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
|
||||
.round {
|
||||
border-radius: 50%;
|
||||
height: 49px;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.credit{
|
||||
padding-right: 0.5em;
|
||||
padding-left: 0.5em;
|
||||
}
|
||||
|
||||
.column .row {
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
.cols {
|
||||
display: flex;
|
||||
flex-direction: row !important;
|
||||
}
|
||||
|
||||
.rows {
|
||||
display: flex;
|
||||
flex-direction: column !important;
|
||||
}
|
||||
|
||||
.cols label {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
label {
|
||||
user-select: none;
|
||||
}
|
||||
@@ -1,216 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.Php = void 0;
|
||||
|
||||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
||||
|
||||
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
||||
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
||||
|
||||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
||||
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
|
||||
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
|
||||
|
||||
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
||||
|
||||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
||||
|
||||
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
|
||||
|
||||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
||||
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
|
||||
var PhpBinary = require('./php-web');
|
||||
|
||||
var Php = /*#__PURE__*/function (_EventTarget) {
|
||||
_inherits(Php, _EventTarget);
|
||||
|
||||
var _super = _createSuper(Php);
|
||||
|
||||
function Php() {
|
||||
var _this;
|
||||
|
||||
_classCallCheck(this, Php);
|
||||
|
||||
_this = _super.call(this);
|
||||
var FLAGS = {};
|
||||
_this.returnValue = -1;
|
||||
|
||||
_this.onerror = function () {};
|
||||
|
||||
_this.onoutput = function () {};
|
||||
|
||||
_this.onready = function () {};
|
||||
|
||||
_this.binary = new PhpBinary({
|
||||
postRun: function postRun() {
|
||||
var event = new CustomEvent('ready');
|
||||
|
||||
_this.dispatchEvent(event);
|
||||
|
||||
_this.onready(event);
|
||||
},
|
||||
print: function print() {
|
||||
for (var _len = arguments.length, chunks = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
chunks[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
var event = new CustomEvent('output', {
|
||||
detail: chunks.map(function (c) {
|
||||
return c + "\n";
|
||||
})
|
||||
});
|
||||
|
||||
_this.dispatchEvent(event);
|
||||
|
||||
_this.onoutput(event);
|
||||
},
|
||||
printErr: function printErr() {
|
||||
for (var _len2 = arguments.length, chunks = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
||||
chunks[_key2] = arguments[_key2];
|
||||
}
|
||||
|
||||
var event = new CustomEvent('error', {
|
||||
detail: chunks.map(function (c) {
|
||||
return c + "\n";
|
||||
})
|
||||
});
|
||||
|
||||
_this.onerror(event);
|
||||
|
||||
_this.dispatchEvent(event);
|
||||
}
|
||||
}).then(function (php) {
|
||||
var retVal = php.ccall('pib_init', 'number', ["string"], []);
|
||||
return php;
|
||||
})["catch"](function (error) {
|
||||
return console.log(error);
|
||||
});
|
||||
return _this;
|
||||
}
|
||||
|
||||
_createClass(Php, [{
|
||||
key: "run",
|
||||
value: function run(phpCode) {
|
||||
return this.binary.then(function (php) {
|
||||
var retVal = php.ccall('pib_eval', 'number', ["string"], ["?>".concat(phpCode)]);
|
||||
php.ccall('pib_eval', 'number', ["string"], ["fwrite(fopen('php://stdout', 'w'), PHP_EOL);"]);
|
||||
return retVal;
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "refresh",
|
||||
value: function refresh() {
|
||||
return this.binary.then(function (php) {
|
||||
return php.ccall('pib_refresh', 'number', [], []);
|
||||
})["catch"](function (error) {
|
||||
return console.log(error);
|
||||
});
|
||||
}
|
||||
}]);
|
||||
|
||||
return Php;
|
||||
}( /*#__PURE__*/_wrapNativeSuper(EventTarget));
|
||||
|
||||
exports.Php = Php;
|
||||
|
||||
if (window && document) {
|
||||
var php = new Php();
|
||||
|
||||
var runScriptTag = function runScriptTag(element) {
|
||||
var src = element.getAttribute('src');
|
||||
|
||||
if (src) {
|
||||
fetch(src).then(function (r) {
|
||||
return r.text();
|
||||
}).then(function (r) {
|
||||
console.log(r);
|
||||
php.run(r);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
var inlineCode = element.innerText.trim();
|
||||
console.log(inlineCode);
|
||||
|
||||
if (inlineCode) {// php.run(inlineCode);
|
||||
}
|
||||
};
|
||||
|
||||
php.addEventListener('ready', function () {
|
||||
var phpSelector = 'script[type="text/php"]';
|
||||
var htmlNode = document.body.parentElement;
|
||||
var observer = new MutationObserver(function (mutations, observer) {
|
||||
var _iterator = _createForOfIteratorHelper(mutations),
|
||||
_step;
|
||||
|
||||
try {
|
||||
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
||||
var mutation = _step.value;
|
||||
|
||||
var _iterator2 = _createForOfIteratorHelper(mutation.addedNodes),
|
||||
_step2;
|
||||
|
||||
try {
|
||||
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
||||
var addedNode = _step2.value;
|
||||
|
||||
if (!addedNode.matches || !addedNode.matches(phpSelector)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
runScriptTag(addedNode);
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator2.e(err);
|
||||
} finally {
|
||||
_iterator2.f();
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator.e(err);
|
||||
} finally {
|
||||
_iterator.f();
|
||||
}
|
||||
});
|
||||
observer.observe(htmlNode, {
|
||||
childList: true,
|
||||
subtree: true
|
||||
});
|
||||
var phpNodes = document.querySelectorAll(phpSelector);
|
||||
|
||||
var _iterator3 = _createForOfIteratorHelper(phpNodes),
|
||||
_step3;
|
||||
|
||||
try {
|
||||
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
||||
var phpNode = _step3.value;
|
||||
var code = phpNode.innerText.trim();
|
||||
runScriptTag(phpNode);
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator3.e(err);
|
||||
} finally {
|
||||
_iterator3.f();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1,132 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.PhpBase = void 0;
|
||||
|
||||
var _UniqueIndex = require("./UniqueIndex");
|
||||
|
||||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
||||
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
||||
|
||||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
||||
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
|
||||
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
|
||||
|
||||
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
||||
|
||||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
||||
|
||||
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
|
||||
|
||||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
||||
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
|
||||
var PhpBase = /*#__PURE__*/function (_EventTarget) {
|
||||
_inherits(PhpBase, _EventTarget);
|
||||
|
||||
var _super = _createSuper(PhpBase);
|
||||
|
||||
function PhpBase(PhpBinary) {
|
||||
var _this;
|
||||
|
||||
_classCallCheck(this, PhpBase);
|
||||
|
||||
_this = _super.call(this);
|
||||
var FLAGS = {};
|
||||
_this.returnValue = -1;
|
||||
|
||||
_this.onerror = function () {};
|
||||
|
||||
_this.onoutput = function () {};
|
||||
|
||||
_this.onready = function () {};
|
||||
|
||||
var callbacks = new _UniqueIndex.UniqueIndex();
|
||||
var targets = new _UniqueIndex.UniqueIndex();
|
||||
_this.binary = new PhpBinary({
|
||||
callbacks: callbacks,
|
||||
targets: targets,
|
||||
postRun: function postRun() {
|
||||
var event = new CustomEvent('ready');
|
||||
|
||||
_this.dispatchEvent(event);
|
||||
|
||||
_this.onready(event);
|
||||
},
|
||||
print: function print() {
|
||||
for (var _len = arguments.length, chunks = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
chunks[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
var event = new CustomEvent('output', {
|
||||
detail: chunks.map(function (c) {
|
||||
return c + "\n";
|
||||
})
|
||||
});
|
||||
|
||||
_this.dispatchEvent(event);
|
||||
|
||||
_this.onoutput(event);
|
||||
},
|
||||
printErr: function printErr() {
|
||||
for (var _len2 = arguments.length, chunks = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
||||
chunks[_key2] = arguments[_key2];
|
||||
}
|
||||
|
||||
var event = new CustomEvent('error', {
|
||||
detail: chunks.map(function (c) {
|
||||
return c + "\n";
|
||||
})
|
||||
});
|
||||
|
||||
_this.onerror(event);
|
||||
|
||||
_this.dispatchEvent(event);
|
||||
}
|
||||
}).then(function (php) {
|
||||
var retVal = php.ccall('pib_init', 'number', ['string'], []);
|
||||
return php;
|
||||
})["catch"](function (error) {
|
||||
return console.log(error);
|
||||
});
|
||||
return _this;
|
||||
}
|
||||
|
||||
_createClass(PhpBase, [{
|
||||
key: "run",
|
||||
value: function run(phpCode) {
|
||||
return this.binary.then(function (php) {
|
||||
return php.ccall('pib_eval', 'string', ['string'], [phpCode]);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "refresh",
|
||||
value: function refresh() {
|
||||
var call = this.binary.then(function (php) {
|
||||
return php.ccall('pib_refresh', 'number', [], []);
|
||||
});
|
||||
call["catch"](function (error) {
|
||||
return console.log(error);
|
||||
});
|
||||
return call;
|
||||
}
|
||||
}]);
|
||||
|
||||
return PhpBase;
|
||||
}( /*#__PURE__*/_wrapNativeSuper(EventTarget));
|
||||
|
||||
exports.PhpBase = PhpBase;
|
||||
@@ -1,134 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.PhpWeb = void 0;
|
||||
|
||||
var _PhpBase2 = require("./PhpBase");
|
||||
|
||||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
||||
|
||||
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
||||
|
||||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
||||
|
||||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
||||
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
|
||||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
||||
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
|
||||
var PhpBinary = require('./php-web');
|
||||
|
||||
var PhpWeb = /*#__PURE__*/function (_PhpBase) {
|
||||
_inherits(PhpWeb, _PhpBase);
|
||||
|
||||
var _super = _createSuper(PhpWeb);
|
||||
|
||||
function PhpWeb() {
|
||||
_classCallCheck(this, PhpWeb);
|
||||
|
||||
return _super.call(this, PhpBinary);
|
||||
}
|
||||
|
||||
return PhpWeb;
|
||||
}(_PhpBase2.PhpBase);
|
||||
|
||||
exports.PhpWeb = PhpWeb;
|
||||
|
||||
if (window && document) {
|
||||
var php = new PhpWeb();
|
||||
|
||||
var runScriptTag = function runScriptTag(element) {
|
||||
var src = element.getAttribute('src');
|
||||
|
||||
if (src) {
|
||||
fetch(src).then(function (r) {
|
||||
return r.text();
|
||||
}).then(function (r) {
|
||||
php.run(r).then(function (exit) {
|
||||
return console.log(exit);
|
||||
});
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
var inlineCode = element.innerText.trim();
|
||||
console.log(inlineCode);
|
||||
|
||||
if (inlineCode) {
|
||||
php.run(inlineCode);
|
||||
}
|
||||
};
|
||||
|
||||
php.addEventListener('ready', function () {
|
||||
var phpSelector = 'script[type="text/php"]';
|
||||
var htmlNode = document.body.parentElement;
|
||||
var observer = new MutationObserver(function (mutations, observer) {
|
||||
var _iterator = _createForOfIteratorHelper(mutations),
|
||||
_step;
|
||||
|
||||
try {
|
||||
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
||||
var mutation = _step.value;
|
||||
|
||||
var _iterator2 = _createForOfIteratorHelper(mutation.addedNodes),
|
||||
_step2;
|
||||
|
||||
try {
|
||||
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
||||
var addedNode = _step2.value;
|
||||
|
||||
if (!addedNode.matches || !addedNode.matches(phpSelector)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
runScriptTag(addedNode);
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator2.e(err);
|
||||
} finally {
|
||||
_iterator2.f();
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator.e(err);
|
||||
} finally {
|
||||
_iterator.f();
|
||||
}
|
||||
});
|
||||
observer.observe(htmlNode, {
|
||||
childList: true,
|
||||
subtree: true
|
||||
});
|
||||
var phpNodes = document.querySelectorAll(phpSelector);
|
||||
|
||||
var _iterator3 = _createForOfIteratorHelper(phpNodes),
|
||||
_step3;
|
||||
|
||||
try {
|
||||
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
||||
var phpNode = _step3.value;
|
||||
var code = phpNode.innerText.trim();
|
||||
runScriptTag(phpNode);
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator3.e(err);
|
||||
} finally {
|
||||
_iterator3.f();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.PhpWebview = void 0;
|
||||
|
||||
var _PhpBase2 = require("./PhpBase");
|
||||
|
||||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
||||
|
||||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
||||
|
||||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
||||
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
|
||||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
||||
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
|
||||
var PhpBinary = require('./php-webview');
|
||||
|
||||
var PhpWebview = /*#__PURE__*/function (_PhpBase) {
|
||||
_inherits(PhpWebview, _PhpBase);
|
||||
|
||||
var _super = _createSuper(PhpWebview);
|
||||
|
||||
function PhpWebview() {
|
||||
_classCallCheck(this, PhpWebview);
|
||||
|
||||
return _super.call(this, PhpBinary);
|
||||
}
|
||||
|
||||
return PhpWebview;
|
||||
}(_PhpBase2.PhpBase);
|
||||
|
||||
exports.PhpWebview = PhpWebview;
|
||||
@@ -1,64 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.UniqueIndex = void 0;
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
var UniqueIndex = function UniqueIndex() {
|
||||
_classCallCheck(this, UniqueIndex);
|
||||
|
||||
var map = new Map();
|
||||
var set = new WeakMap();
|
||||
var index = 0;
|
||||
Object.defineProperty(this, 'add', {
|
||||
configurable: false,
|
||||
writable: false,
|
||||
value: function value(callback) {
|
||||
var existing = set.has(callback);
|
||||
|
||||
if (existing) {
|
||||
return existing;
|
||||
}
|
||||
|
||||
var newIndex = ++index;
|
||||
set.set(callback, newIndex);
|
||||
map.set(newIndex, callback);
|
||||
return newIndex;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(this, 'has', {
|
||||
configurable: false,
|
||||
writable: false,
|
||||
value: function value(callback) {
|
||||
if (set.has(callback)) {
|
||||
return set.get(callback);
|
||||
}
|
||||
}
|
||||
});
|
||||
Object.defineProperty(this, 'get', {
|
||||
configurable: false,
|
||||
writable: false,
|
||||
value: function value(index) {
|
||||
if (map.has(index)) {
|
||||
return map.get(index);
|
||||
}
|
||||
}
|
||||
});
|
||||
Object.defineProperty(this, 'remove', {
|
||||
configurable: false,
|
||||
writable: false,
|
||||
value: function value(index) {
|
||||
var callback = map.get(index);
|
||||
|
||||
if (callback) {
|
||||
set["delete"](callback);
|
||||
map["delete"](index);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
exports.UniqueIndex = UniqueIndex;
|
||||
@@ -1,17 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.ZVal = void 0;
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
var ZVal = function ZVal(wrappedValue) {
|
||||
_classCallCheck(this, ZVal);
|
||||
|
||||
this.wrapped = wrappedValue;
|
||||
this.refCount = 1;
|
||||
};
|
||||
|
||||
exports.ZVal = ZVal;
|
||||
@@ -0,0 +1,223 @@
|
||||
@font-face {
|
||||
src: url('fsex302-webfont.woff') format('woff');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
font-family: 'fixedsys';
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'fixedsys';
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
height: 100vh;
|
||||
padding: 0px;
|
||||
margin: 0px;
|
||||
background-color: #aaa;
|
||||
}
|
||||
|
||||
.output {
|
||||
|
||||
}
|
||||
|
||||
.output .scroller {
|
||||
background-color: #bbb;
|
||||
}
|
||||
|
||||
.output .row {
|
||||
background-color: #FFF;
|
||||
padding: 0.5em 0.5em;
|
||||
border-bottom: 1px white solid;
|
||||
}
|
||||
|
||||
.row.toolbar {
|
||||
margin: 0.5em;
|
||||
padding: 0.5em 0em;
|
||||
border: 2px solid;
|
||||
border-image: url(/border-inset.png) 2 2 2 2;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.row.toolbar > div{
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
padding: 0em 0.5em;
|
||||
flex: 1;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.row.toolbar > div .start{
|
||||
align-items: center;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.row.toolbar button {
|
||||
user-select: none;
|
||||
padding: 0.75em;
|
||||
font-weight: bold;
|
||||
border: 2px solid;
|
||||
align-self: center;
|
||||
margin-right: 0.5em;
|
||||
}
|
||||
|
||||
button {
|
||||
border-image: url(/border.png) 2 2 2 2;
|
||||
}
|
||||
|
||||
*:focus {
|
||||
outline-style: dotted;
|
||||
outline-color: black;
|
||||
}
|
||||
|
||||
.row:focus {
|
||||
background-color: #000082;
|
||||
border-bottom: 1px #000082 solid;
|
||||
color: #FFF;
|
||||
}
|
||||
|
||||
.row.toolbar.header{
|
||||
background-color: #BBB;
|
||||
}
|
||||
|
||||
.row.toolbar.status {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.row.toolbar.status > div {
|
||||
padding: 0.25em;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0em;
|
||||
margin: 0.25em;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
body > div {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.row.body {
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
div.column {
|
||||
position: relative;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
div.column .scroller {
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
left: 0px;
|
||||
bottom: 0px;
|
||||
right: 0px;
|
||||
overflow-y: auto;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
div.panel {
|
||||
font-family: 'fixedsys';
|
||||
display: flex;
|
||||
position: relative;
|
||||
background-color: #aaa;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
padding: 0.5em;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
div.panel div.input {
|
||||
background-color: #272822;
|
||||
}
|
||||
|
||||
div.panel > div {
|
||||
user-select: none;
|
||||
background-color: white;
|
||||
border: 2px solid;
|
||||
border-image: url(/border-inset.png) 2 2 2 2;
|
||||
flex-direction: column;
|
||||
display: flex;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.liquid{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
button,
|
||||
.panel label {
|
||||
border: 2px solid;
|
||||
border-image: url(/border.png) 2 2 2 2 !important;
|
||||
background-color: #c3c3c3;
|
||||
padding: 0.25em;
|
||||
}
|
||||
|
||||
.panel label, .panel .cols button {
|
||||
margin-top: -1px;
|
||||
}
|
||||
|
||||
label[tabindex]:active,
|
||||
button:active {
|
||||
border: 2px solid;
|
||||
border-image: url(/border-inset.png) 2 2 2 2 !important;
|
||||
}
|
||||
|
||||
.header label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.header label p {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
pre {
|
||||
flex: 1;
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
|
||||
.round {
|
||||
border-radius: 50%;
|
||||
height: 49px;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.credit{
|
||||
padding-right: 0.5em;
|
||||
padding-left: 0.5em;
|
||||
}
|
||||
|
||||
.column .row {
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
.cols {
|
||||
display: flex;
|
||||
flex-direction: row !important;
|
||||
}
|
||||
|
||||
.rows {
|
||||
display: flex;
|
||||
flex-direction: column !important;
|
||||
}
|
||||
|
||||
.cols label {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
label {
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
|
||||
/*# sourceMappingURL=app.css.map*/
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["source/styles.css"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"docs/app.css","sourcesContent":["@font-face {\n src: url('fsex302-webfont.woff') format('woff');\n font-weight: normal;\n font-style: normal;\n\tfont-family: 'fixedsys';\n}\n\nbody {\n\tfont-family: 'fixedsys';\n\tdisplay: flex;\n\tflex-direction: column;\n\talign-items: stretch;\n\theight: 100vh;\n\tpadding: 0px;\n\tmargin: 0px;\n\tbackground-color: #aaa;\n}\n\n.output {\n\n}\n\n.output .scroller {\n\tbackground-color: #bbb;\n}\n\n.output .row {\n\tbackground-color: #FFF;\n\tpadding: 0.5em 0.5em;\n\tborder-bottom: 1px white solid;\n}\n\n.row.toolbar {\n\tmargin: 0.5em;\n\tpadding: 0.5em 0em;\n\tborder: 2px solid;\n\tborder-image: url(/border-inset.png) 2 2 2 2;\n\talign-items: center;\n}\n\n.row.toolbar > div{\n\tdisplay: flex;\n\tjustify-content: flex-end;\n\tpadding: 0em 0.5em;\n\tflex: 1;\n\tflex-direction: row;\n}\n\n.row.toolbar > div .start{\n\talign-items: center;\n\tflex: 1;\n}\n\n.row.toolbar button {\n\tuser-select: none;\n\tpadding: 0.75em;\n\tfont-weight: bold;\n\tborder: 2px solid;\n\talign-self: center;\n\tmargin-right: 0.5em;\n}\n\nbutton {\n\tborder-image: url(/border.png) 2 2 2 2;\n}\n\n*:focus {\n\toutline-style: dotted;\n\toutline-color: black;\n}\n\n.row:focus {\n\tbackground-color: #000082;\n\tborder-bottom: 1px #000082 solid;\n\tcolor: #FFF;\n}\n\n.row.toolbar.header{\n\tbackground-color: #BBB;\n}\n\n.row.toolbar.status {\n\tpadding: 0;\n}\n\n.row.toolbar.status > div {\n\tpadding: 0.25em;\n}\n\nh1 {\n\tmargin: 0em;\n\tmargin: 0.25em;\n\twhite-space: nowrap;\n}\n\n.row {\n\tdisplay: flex;\n\tflex-direction: row;\n}\n\nbody > div {\n\tdisplay: flex;\n\tflex-direction: row;\n}\n\n.row.body {\n\tflex-grow: 1;\n}\n\ndiv.column {\n\tposition: relative;\n\tflex: 1;\n}\n\ndiv.column .scroller {\n\tposition: absolute;\n\ttop: 0px;\n\tleft: 0px;\n\tbottom: 0px;\n\tright: 0px;\n\toverflow-y: auto;\n\toverflow-x: auto;\n}\n\ndiv.panel {\n font-family: 'fixedsys';\n\tdisplay: flex;\n\tposition: relative;\n\tbackground-color: #aaa;\n\tflex-direction: column;\n\tbox-sizing: border-box;\n\tpadding: 0.5em;\n\tflex: 1;\n}\n\ndiv.panel div.input {\n\tbackground-color: #272822;\n}\n\ndiv.panel > div {\n\tuser-select: none;\n\tbackground-color: white;\n\tborder: 2px solid;\n\tborder-image: url(/border-inset.png) 2 2 2 2;\n\tflex-direction: column;\n\tdisplay: flex;\n\tflex: 1;\n}\n\n.liquid{\n\tdisplay: flex;\n\tflex-direction: column;\n\tflex: 1;\n}\n\nbutton,\n.panel label {\n\tborder: 2px solid;\n\tborder-image: url(/border.png) 2 2 2 2 !important;\n\tbackground-color: #c3c3c3;\n\tpadding: 0.25em;\n}\n\n.panel label, .panel .cols button {\n\tmargin-top: -1px;\n}\n\nlabel[tabindex]:active,\nbutton:active {\n\tborder: 2px solid;\n\tborder-image: url(/border-inset.png) 2 2 2 2 !important;\n}\n\n.header label {\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: flex-end;\n}\n\n.header label p {\n\ttext-align: right;\n}\n\npre {\n\tflex: 1;\n\tmargin-bottom: 0px;\n}\n\n.round {\n\tborder-radius: 50%;\n\theight: 49px;\n\tmargin-right: 5px;\n}\n\n.credit{\n\tpadding-right: 0.5em;\n\tpadding-left: 0.5em;\n}\n\n.column .row {\n\twhite-space: pre;\n}\n\n.cols {\n\tdisplay: flex;\n\tflex-direction: row !important;\n}\n\n.rows {\n\tdisplay: flex;\n\tflex-direction: column !important;\n}\n\n.cols label {\n\tflex: 1;\n}\n\nlabel {\n\tuser-select: none;\n}\n"]}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["node_modules/php-wasm/PhpBase.js","node_modules/php-wasm/PhpWeb.js","node_modules/php-wasm/UniqueIndex.js","node_modules/php-wasm/php-web.js","node_modules/process/browser.js","source/initialize.js","node_modules/auto-reload-brunch/vendor/auto-reload.js"],"names":["PHP","require","PhpWeb","document","addEventListener","input","querySelector","stdret","stdout","stderr","run","status","editor","ace","edit","ret","persistBox","getElementById","singleBox","session","setMode","setTheme","innerText","php","query","URLSearchParams","location","search","event","firstChild","remove","code","getValue","length","set","encodeURIComponent","checked","history","replaceState","title","toString","console","log","func","replace","then","row","createElement","setAttribute","classList","add","append","detail","join","style","display","target","has","setValue","decodeURIComponent","get","selection","moveCursorFileStart","moveCursorFileEnd","WebSocket","window","MozWebSocket","br","brunch","ar","disabled","_ar","cacheBuster","url","date","Math","round","Date","now","indexOf","browser","navigator","userAgent","toLowerCase","forceRepaint","reloaders","page","reload","stylesheet","slice","call","querySelectorAll","filter","link","val","getAttribute","href","forEach","setTimeout","body","offsetHeight","javascript","scripts","textScripts","map","script","text","srcScripts","src","loaded","all","onLoad","eval","newScript","async","onload","head","appendChild","port","host","server","hostname","connect","connection","onmessage","message","data","reloader","onerror","readyState","close","onclose"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACvJA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AC3IA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACrEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AALine truncated
|
||||
|
After Width: | Height: | Size: 210 B |
|
After Width: | Height: | Size: 213 B |
|
After Width: | Height: | Size: 214 B |
@@ -1,29 +0,0 @@
|
||||
# Numerous always-ignore extensions
|
||||
*.diff
|
||||
*.err
|
||||
*.orig
|
||||
*.log
|
||||
*.rej
|
||||
*.swo
|
||||
*.swp
|
||||
*.vi
|
||||
*~
|
||||
*.sass-cache
|
||||
|
||||
# OS or Editor folders
|
||||
.DS_Store
|
||||
.cache
|
||||
.project
|
||||
.settings
|
||||
.tmproj
|
||||
nbproject
|
||||
Thumbs.db
|
||||
|
||||
# NPM packages folder.
|
||||
node_modules/
|
||||
|
||||
# Brunch folder for temporary files.
|
||||
tmp/
|
||||
|
||||
# Brunch output folder.
|
||||
public/
|
||||
@@ -1,216 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.Php = void 0;
|
||||
|
||||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
||||
|
||||
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
||||
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
||||
|
||||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
||||
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
|
||||
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
|
||||
|
||||
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
||||
|
||||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
||||
|
||||
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
|
||||
|
||||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
||||
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
|
||||
var PhpBinary = require('./php-web');
|
||||
|
||||
var Php = /*#__PURE__*/function (_EventTarget) {
|
||||
_inherits(Php, _EventTarget);
|
||||
|
||||
var _super = _createSuper(Php);
|
||||
|
||||
function Php() {
|
||||
var _this;
|
||||
|
||||
_classCallCheck(this, Php);
|
||||
|
||||
_this = _super.call(this);
|
||||
var FLAGS = {};
|
||||
_this.returnValue = -1;
|
||||
|
||||
_this.onerror = function () {};
|
||||
|
||||
_this.onoutput = function () {};
|
||||
|
||||
_this.onready = function () {};
|
||||
|
||||
_this.binary = new PhpBinary({
|
||||
postRun: function postRun() {
|
||||
var event = new CustomEvent('ready');
|
||||
|
||||
_this.dispatchEvent(event);
|
||||
|
||||
_this.onready(event);
|
||||
},
|
||||
print: function print() {
|
||||
for (var _len = arguments.length, chunks = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
chunks[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
var event = new CustomEvent('output', {
|
||||
detail: chunks.map(function (c) {
|
||||
return c + "\n";
|
||||
})
|
||||
});
|
||||
|
||||
_this.dispatchEvent(event);
|
||||
|
||||
_this.onoutput(event);
|
||||
},
|
||||
printErr: function printErr() {
|
||||
for (var _len2 = arguments.length, chunks = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
||||
chunks[_key2] = arguments[_key2];
|
||||
}
|
||||
|
||||
var event = new CustomEvent('error', {
|
||||
detail: chunks.map(function (c) {
|
||||
return c + "\n";
|
||||
})
|
||||
});
|
||||
|
||||
_this.onerror(event);
|
||||
|
||||
_this.dispatchEvent(event);
|
||||
}
|
||||
}).then(function (php) {
|
||||
var retVal = php.ccall('pib_init', 'number', ["string"], []);
|
||||
return php;
|
||||
})["catch"](function (error) {
|
||||
return console.log(error);
|
||||
});
|
||||
return _this;
|
||||
}
|
||||
|
||||
_createClass(Php, [{
|
||||
key: "run",
|
||||
value: function run(phpCode) {
|
||||
return this.binary.then(function (php) {
|
||||
var retVal = php.ccall('pib_eval', 'number', ["string"], ["?>".concat(phpCode)]);
|
||||
php.ccall('pib_eval', 'number', ["string"], ["fwrite(fopen('php://stdout', 'w'), PHP_EOL);"]);
|
||||
return retVal;
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "refresh",
|
||||
value: function refresh() {
|
||||
return this.binary.then(function (php) {
|
||||
return php.ccall('pib_refresh', 'number', [], []);
|
||||
})["catch"](function (error) {
|
||||
return console.log(error);
|
||||
});
|
||||
}
|
||||
}]);
|
||||
|
||||
return Php;
|
||||
}( /*#__PURE__*/_wrapNativeSuper(EventTarget));
|
||||
|
||||
exports.Php = Php;
|
||||
|
||||
if (window && document) {
|
||||
var php = new Php();
|
||||
|
||||
var runScriptTag = function runScriptTag(element) {
|
||||
var src = element.getAttribute('src');
|
||||
|
||||
if (src) {
|
||||
fetch(src).then(function (r) {
|
||||
return r.text();
|
||||
}).then(function (r) {
|
||||
console.log(r);
|
||||
php.run(r);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
var inlineCode = element.innerText.trim();
|
||||
console.log(inlineCode);
|
||||
|
||||
if (inlineCode) {// php.run(inlineCode);
|
||||
}
|
||||
};
|
||||
|
||||
php.addEventListener('ready', function () {
|
||||
var phpSelector = 'script[type="text/php"]';
|
||||
var htmlNode = document.body.parentElement;
|
||||
var observer = new MutationObserver(function (mutations, observer) {
|
||||
var _iterator = _createForOfIteratorHelper(mutations),
|
||||
_step;
|
||||
|
||||
try {
|
||||
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
||||
var mutation = _step.value;
|
||||
|
||||
var _iterator2 = _createForOfIteratorHelper(mutation.addedNodes),
|
||||
_step2;
|
||||
|
||||
try {
|
||||
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
||||
var addedNode = _step2.value;
|
||||
|
||||
if (!addedNode.matches || !addedNode.matches(phpSelector)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
runScriptTag(addedNode);
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator2.e(err);
|
||||
} finally {
|
||||
_iterator2.f();
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator.e(err);
|
||||
} finally {
|
||||
_iterator.f();
|
||||
}
|
||||
});
|
||||
observer.observe(htmlNode, {
|
||||
childList: true,
|
||||
subtree: true
|
||||
});
|
||||
var phpNodes = document.querySelectorAll(phpSelector);
|
||||
|
||||
var _iterator3 = _createForOfIteratorHelper(phpNodes),
|
||||
_step3;
|
||||
|
||||
try {
|
||||
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
||||
var phpNode = _step3.value;
|
||||
var code = phpNode.innerText.trim();
|
||||
runScriptTag(phpNode);
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator3.e(err);
|
||||
} finally {
|
||||
_iterator3.f();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1,132 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.PhpBase = void 0;
|
||||
|
||||
var _UniqueIndex = require("./UniqueIndex");
|
||||
|
||||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
||||
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
||||
|
||||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
||||
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
|
||||
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
|
||||
|
||||
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
||||
|
||||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
||||
|
||||
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
|
||||
|
||||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
||||
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
|
||||
var PhpBase = /*#__PURE__*/function (_EventTarget) {
|
||||
_inherits(PhpBase, _EventTarget);
|
||||
|
||||
var _super = _createSuper(PhpBase);
|
||||
|
||||
function PhpBase(PhpBinary) {
|
||||
var _this;
|
||||
|
||||
_classCallCheck(this, PhpBase);
|
||||
|
||||
_this = _super.call(this);
|
||||
var FLAGS = {};
|
||||
_this.returnValue = -1;
|
||||
|
||||
_this.onerror = function () {};
|
||||
|
||||
_this.onoutput = function () {};
|
||||
|
||||
_this.onready = function () {};
|
||||
|
||||
var callbacks = new _UniqueIndex.UniqueIndex();
|
||||
var targets = new _UniqueIndex.UniqueIndex();
|
||||
_this.binary = new PhpBinary({
|
||||
callbacks: callbacks,
|
||||
targets: targets,
|
||||
postRun: function postRun() {
|
||||
var event = new CustomEvent('ready');
|
||||
|
||||
_this.dispatchEvent(event);
|
||||
|
||||
_this.onready(event);
|
||||
},
|
||||
print: function print() {
|
||||
for (var _len = arguments.length, chunks = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
chunks[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
var event = new CustomEvent('output', {
|
||||
detail: chunks.map(function (c) {
|
||||
return c + "\n";
|
||||
})
|
||||
});
|
||||
|
||||
_this.dispatchEvent(event);
|
||||
|
||||
_this.onoutput(event);
|
||||
},
|
||||
printErr: function printErr() {
|
||||
for (var _len2 = arguments.length, chunks = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
||||
chunks[_key2] = arguments[_key2];
|
||||
}
|
||||
|
||||
var event = new CustomEvent('error', {
|
||||
detail: chunks.map(function (c) {
|
||||
return c + "\n";
|
||||
})
|
||||
});
|
||||
|
||||
_this.onerror(event);
|
||||
|
||||
_this.dispatchEvent(event);
|
||||
}
|
||||
}).then(function (php) {
|
||||
var retVal = php.ccall('pib_init', 'number', ["string"], []);
|
||||
return php;
|
||||
})["catch"](function (error) {
|
||||
return console.log(error);
|
||||
});
|
||||
return _this;
|
||||
}
|
||||
|
||||
_createClass(PhpBase, [{
|
||||
key: "run",
|
||||
value: function run(phpCode) {
|
||||
return this.binary.then(function (php) {
|
||||
var retVal = php.ccall('pib_eval', 'number', ["string"], ["?>".concat(phpCode)]);
|
||||
php.ccall('pib_eval', 'number', ["string"], ["fwrite(fopen('php://stdout', 'w'), PHP_EOL);"]);
|
||||
return retVal;
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "refresh",
|
||||
value: function refresh() {
|
||||
return this.binary.then(function (php) {
|
||||
return php.ccall('pib_refresh', 'number', [], []);
|
||||
})["catch"](function (error) {
|
||||
return console.log(error);
|
||||
});
|
||||
}
|
||||
}]);
|
||||
|
||||
return PhpBase;
|
||||
}( /*#__PURE__*/_wrapNativeSuper(EventTarget));
|
||||
|
||||
exports.PhpBase = PhpBase;
|
||||
@@ -1,44 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.PhpWorker = void 0;
|
||||
|
||||
var _PhpBase2 = require("./PhpBase");
|
||||
|
||||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
||||
|
||||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
||||
|
||||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
||||
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
|
||||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
||||
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
|
||||
var PhpBinary = require('./php-worker');
|
||||
|
||||
var PhpWorker = /*#__PURE__*/function (_PhpBase) {
|
||||
_inherits(PhpWorker, _PhpBase);
|
||||
|
||||
var _super = _createSuper(PhpWorker);
|
||||
|
||||
function PhpWorker() {
|
||||
_classCallCheck(this, PhpWorker);
|
||||
|
||||
return _super.call(this, PhpBinary);
|
||||
}
|
||||
|
||||
return PhpWorker;
|
||||
}(_PhpBase2.PhpBase);
|
||||
|
||||
exports.PhpWorker = PhpWorker;
|
||||
@@ -1,16 +0,0 @@
|
||||
# Brunch app
|
||||
|
||||
This is a HTML5 application, built with [Brunch](http://brunch.io).
|
||||
|
||||
## Getting started
|
||||
* Install (if you don't have them):
|
||||
* [Node.js](http://nodejs.org): `brew install node` on OS X
|
||||
* [Brunch](http://brunch.io): `npm install -g brunch`
|
||||
* Brunch plugins and app dependencies: `npm install`
|
||||
* Run:
|
||||
* `npm start` — watches the project with continuous rebuild. This will also launch HTTP server with [pushState](https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Manipulating_the_browser_history).
|
||||
* `npm run build` — builds minified project for production
|
||||
* Learn:
|
||||
* `public/` dir is fully auto-generated and served by HTTP server. Write your code in `app/` dir.
|
||||
* Place static files you want to be copied from `app/assets/` to `public/`.
|
||||
* [Brunch site](http://brunch.io), [Getting started guide](https://github.com/brunch/brunch-guide#readme)
|
||||
@@ -1,67 +0,0 @@
|
||||
<!doctype html>
|
||||
<html lang="en-us">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>PIB: PHP in Browser</title>
|
||||
<script src="//ajaxorg.github.io/ace-builds/src-min/ace.js" type="text/javascript" charset="utf-8"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
navigator.serviceWorker.register('/worker.js').then(reg => {
|
||||
reg.update();
|
||||
});
|
||||
|
||||
const path = location.pathname.replace(/index.html$/, '');
|
||||
|
||||
if(!path.match(/\/$/))
|
||||
{
|
||||
window.location = path + '/' + (location.search||'');
|
||||
}
|
||||
else
|
||||
{
|
||||
const script = document.createElement('script');
|
||||
script.type = 'text/javascript';
|
||||
script.src = `${path}require1k.js`;
|
||||
|
||||
console.log(script.src);
|
||||
script.setAttribute('data-main', `./index`);
|
||||
document.head.append(script);
|
||||
|
||||
const style = document.createElement('style');
|
||||
style.type = 'text/css';
|
||||
style.innerText = `@import url('${path}style.css')`;
|
||||
document.head.append(style);
|
||||
|
||||
const favicon = document.createElement('link');
|
||||
|
||||
favicon.setAttribute('rel', 'icon');
|
||||
favicon.setAttribute('href', `${path}favicon.ico`);
|
||||
favicon.setAttribute('type', 'image/x-icon');
|
||||
|
||||
document.head.append(favicon);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="playground">
|
||||
<div class="playground-header">
|
||||
<button id="run" disabled>Loading...</button>
|
||||
<label>
|
||||
<input id = "persist" type = "checkbox" >
|
||||
Persist
|
||||
</label>
|
||||
</div>
|
||||
<div class="playground-split-vertical">
|
||||
<div class="playground-editor">
|
||||
<div id="editor"></div>
|
||||
</div>
|
||||
<iframe allow="midi; geolocation; microphone; camera; encrypted-media;" sandbox="allow-forms allow-scripts allow-same-origin allow-modals allow-popups"
|
||||
id="output"></iframe>
|
||||
</div>
|
||||
</div>
|
||||
<a href="https://github.com/seanmorris/php-wasm"><img style="z-index: 1;position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub"></a>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,83 +0,0 @@
|
||||
const inputArea = document.getElementById('input');
|
||||
const runButton = document.getElementById('run');
|
||||
const persistBox = document.getElementById('persist');
|
||||
const outputArea = document.getElementById('output').contentDocument;
|
||||
const defaultCode = '<?php phpinfo();';
|
||||
const editor = ace.edit("editor");
|
||||
|
||||
editor.setTheme("ace/theme/github");
|
||||
editor.session.setMode("ace/mode/php");
|
||||
editor.setShowPrintMargin(false);
|
||||
|
||||
const Php = require('./Php').Php;
|
||||
|
||||
const php = new Php();
|
||||
|
||||
const init = () => {
|
||||
outputArea.open();
|
||||
outputArea.write("Click RUN");
|
||||
outputArea.close();
|
||||
|
||||
runButton.disabled = false
|
||||
runButton.textContent = "Run"
|
||||
runButton.addEventListener('click', () => {
|
||||
|
||||
outputArea.open();
|
||||
|
||||
var code = editor.getValue();
|
||||
var query = new URLSearchParams();
|
||||
|
||||
php.run(code).then(exitCode => {
|
||||
|
||||
const style = document.createElement('style');
|
||||
|
||||
style.textContent = "body{ white-space:pre; }";
|
||||
|
||||
if(outputArea.head)
|
||||
{
|
||||
outputArea.head.append(style);
|
||||
}
|
||||
|
||||
|
||||
if(exitCode || !persistBox.checked)
|
||||
{
|
||||
php.refresh();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
if (code.length < 1024)
|
||||
{
|
||||
query.append('code', encodeURIComponent(code));
|
||||
query.append('persist', persistBox.checked ? 1 : 0);
|
||||
history.replaceState({}, document.title, "?" + query.toString());
|
||||
}
|
||||
|
||||
outputArea.close();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
php.addEventListener('ready', (event) => init());
|
||||
|
||||
php.addEventListener('output', (event) => {
|
||||
outputArea.write(event.detail.join("\n"));
|
||||
});
|
||||
|
||||
const query = new URLSearchParams(document.location.search);
|
||||
|
||||
if(query.has('code'))
|
||||
{
|
||||
editor.setValue(decodeURIComponent(query.get('code')));
|
||||
}
|
||||
else
|
||||
{
|
||||
editor.setValue(defaultCode);
|
||||
}
|
||||
|
||||
if(query.get('persist'))
|
||||
{
|
||||
persistBox.checked = true;
|
||||
}
|
||||
|
||||
outputArea.open();
|
||||
@@ -1,19 +0,0 @@
|
||||
{
|
||||
"name": "brunch-app",
|
||||
"description": "Brunch.io application",
|
||||
"private": true,
|
||||
"author": "Brunch",
|
||||
"version": "0.0.1",
|
||||
"repository": "",
|
||||
"scripts": {
|
||||
"start": "brunch watch --server",
|
||||
"build": "brunch build --production"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"auto-reload-brunch": "^2",
|
||||
"brunch": "^3",
|
||||
"clean-css-brunch": "^3",
|
||||
"terser-brunch": "^4"
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
//http://stuk.github.io/require1k/
|
||||
R=function(e,n,v1){function t(e,o,u,a){if(e.g)return o(e.e,e);var c=e.g=e.l,f=new XMLHttpRequest;f.onload=function(i,l){function s(){l--||o(n,e)}200==f.status||e.t?(i=[],(e.t=e.t||f.response).replace(/(?:^|[^\w\$_.])require\s*\(\s*["']([^"']*)["']\s*\)/g,function(e,n){i.push(n)}),l=i.length,i.map(function(o){t(r(e.l,o),s,"."!=o[0]?c+"/../":n,o)}),s()):u?t(e.n=r(u+="../",a),o,u,a):(e.e=f,o(f,e))},e.t?f.onload():(f.open("GET",c,!0),f.send())}function r(e,n,t){if(e.e)throw e.e;return n?(f.href=e,i.href="."!=n[0]?"./node_modules/"+n:n,t=i.href+".js",f.href="",u[t]=u[t]||{l:t}):e.n?r(e.n):(e[c]||(e.f||a("(function(require,"+c+",module){"+e.t+"\n})//# sourceURL="+e.l))(function(n){return r(r(e.l,n))},e[c]={},e),e[c])}function o(e,n){t(e.call?{l:"",t:""+e,f:e}:r("",e),function(t,o){try{e=r(o)}catch(u){t=u}n&&n(t,e)})}var u={},a=eval,c="createElement",f=e[c]("base"),i=e[c]("a");return e.head.appendChild(f),c=e.querySelector("script[data-main]"),c&&o(c.dataset.main),c="exports",o}(document);
|
||||
@@ -1,79 +0,0 @@
|
||||
body {
|
||||
background-color: #E1E1DB;
|
||||
padding: 0 1em;
|
||||
margin: 0;
|
||||
font-family: "Open Sans", sans-serif;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.playground {
|
||||
display: flex;
|
||||
height: 100vh;
|
||||
flex-direction: column;
|
||||
padding-bottom: 1em;
|
||||
box-sizing: inherit;
|
||||
}
|
||||
|
||||
.playground-header {
|
||||
display: flex;
|
||||
font-size: 12px;
|
||||
padding: 1.25em 0;
|
||||
}
|
||||
|
||||
.playground-split-vertical {
|
||||
flex-direction: row;
|
||||
display: flex;
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
.playground-editor {
|
||||
flex: 1 1 auto;
|
||||
position: relative;
|
||||
border: 4px solid #bbb;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
#output {
|
||||
flex: 1 1 auto;
|
||||
position: relative;
|
||||
margin-left: 0.5em;
|
||||
background: #f9ffff;
|
||||
border: 1px solid #bbb;
|
||||
border-right: none;
|
||||
}
|
||||
|
||||
#editor {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
}
|
||||
|
||||
#run {
|
||||
height: 3em;
|
||||
padding: 0 1.25em;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
text-transform: uppercase;
|
||||
text-decoration: none;
|
||||
font-weight: 700;
|
||||
white-space: nowrap;
|
||||
background: #a42;
|
||||
color: #fff;
|
||||
border-color: #88361b;
|
||||
border-top-right-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
border-top-left-radius: 4px;
|
||||
border-bottom-left-radius: 4px;
|
||||
cursor: pointer;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #dedede;
|
||||
}
|
||||
|
||||
label {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
// self.importScripts('./php-worker.js', './PhpBase.js', './PhpWorker.js');
|
||||
|
||||
// const PhpWorker = require('./PhpWorker').PhpWorker;
|
||||
// const php = new PhpWorker;
|
||||
|
||||
self.addEventListener('install', event => {
|
||||
console.log('SW installed',event);
|
||||
console.dir(event);
|
||||
// event.waitUntil(php);
|
||||
});
|
||||
|
||||
self.addEventListener('activate', event => {
|
||||
console.log('SW activated',event);
|
||||
console.dir(event);
|
||||
});
|
||||
|
||||
self.addEventListener('fetch', event => {
|
||||
console.log('SW fetched!',event);
|
||||
console.dir(event);
|
||||
});
|
||||
@@ -1,65 +1,99 @@
|
||||
<!doctype html>
|
||||
<html lang="en-us">
|
||||
|
||||
<!DOCTYPE html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>PIB: PHP in Browser</title>
|
||||
<script src="//ajaxorg.github.io/ace-builds/src-min/ace.js" type="text/javascript" charset="utf-8"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
// Allow the page to be served from any direcotry...
|
||||
|
||||
const path = location.pathname.replace(/index.html$/, '');
|
||||
|
||||
if(!path.match(/\/$/))
|
||||
{
|
||||
window.location = path + '/' + (location.search||'');
|
||||
}
|
||||
else
|
||||
{
|
||||
const script = document.createElement('script');
|
||||
script.type = 'text/javascript';
|
||||
script.src = `${path}require1k.js`;
|
||||
|
||||
console.log(script.src);
|
||||
script.setAttribute('data-main', `./index`);
|
||||
document.head.append(script);
|
||||
|
||||
const style = document.createElement('style');
|
||||
style.type = 'text/css';
|
||||
style.innerText = `@import url('${path}style.css')`;
|
||||
document.head.append(style);
|
||||
|
||||
const favicon = document.createElement('link');
|
||||
|
||||
favicon.setAttribute('rel', 'icon');
|
||||
favicon.setAttribute('href', `${path}favicon.ico`);
|
||||
favicon.setAttribute('type', 'image/x-icon');
|
||||
|
||||
document.head.append(favicon);
|
||||
}
|
||||
</script>
|
||||
<style>@import url('/app.css')</style>
|
||||
<script src="/app.js"></script>
|
||||
<script>require('source/initialize');</script>
|
||||
<script src="//ajaxorg.github.io/ace-builds/src-min/ace.js" type="text/javascript" charset="utf-8"></script>
|
||||
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class = "row header toolbar">
|
||||
<div class = "cols">
|
||||
<div class = "row start">
|
||||
<a target = "_blank" href = "https://github.com/oraoto">
|
||||
<img class = "round" src = "/oraoto-icon.png" />
|
||||
</a>
|
||||
<a target = "_blank" href = "https://github.com/seanmorris">
|
||||
<img class = "round" src = "/sean-icon.png" />
|
||||
</a>
|
||||
<h1>php-wasm</h1>
|
||||
</div>
|
||||
</div>
|
||||
<div class = "row rows">
|
||||
<label>
|
||||
<span>Persist Memory</span>
|
||||
<input type = "checkbox" id = "persist" />
|
||||
</label>
|
||||
<label>
|
||||
<span>Single Expression</span>
|
||||
<input type = "checkbox" id = "single-expression" />
|
||||
</label>
|
||||
</div>
|
||||
<button data-run>execute</button>
|
||||
<!-- <button data-run>tokenize</button> -->
|
||||
</div>
|
||||
|
||||
<div class = "row body">
|
||||
<div class = "panel">
|
||||
<div class = "input">
|
||||
<div class = "cols">
|
||||
<label tabindex="-1">
|
||||
Input PHP Code
|
||||
</label>
|
||||
<!-- <button>open file</button> -->
|
||||
|
||||
<div class="playground">
|
||||
<div class="playground-header">
|
||||
<button id="run" disabled>Loading...</button>
|
||||
<label>
|
||||
<input id = "persist" type = "checkbox" >
|
||||
Persist
|
||||
</label>
|
||||
</div>
|
||||
<textarea></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="playground-split-vertical">
|
||||
<div class="playground-editor">
|
||||
<div id="editor"></div>
|
||||
|
||||
<div class = "panel">
|
||||
<div id = "ret">
|
||||
<label tabindex="-1">return</label>
|
||||
<div class = "stdret output liquid">
|
||||
<div class = "column">
|
||||
<div class = "scroller"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label tabindex="-1">stdout</label>
|
||||
<div class = "stdout output liquid">
|
||||
<div class = "column">
|
||||
<div class = "scroller"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label tabindex="-1">stderr</label>
|
||||
<div class = "stderr output liquid">
|
||||
<div class = "column">
|
||||
<div class = "scroller"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<iframe allow="midi; geolocation; microphone; camera; encrypted-media;" sandbox="allow-forms allow-scripts allow-same-origin allow-modals allow-popups"
|
||||
id="output"></iframe>
|
||||
</div>
|
||||
</div>
|
||||
<a href="https://github.com/seanmorris/php-wasm"><img style="z-index: 1;position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub"></a>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
<div class = "row status toolbar">
|
||||
<div>
|
||||
<div class = "row start" data-status>
|
||||
php-wasm
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
<!--
|
||||
|
||||
-->
|
||||
|
||||
<!-- <body>
|
||||
|
||||
|
||||
<div class = "row footer">foot</div>
|
||||
</body>
|
||||
-->
|
||||
@@ -1,85 +0,0 @@
|
||||
const inputArea = document.getElementById('input');
|
||||
const runButton = document.getElementById('run');
|
||||
const persistBox = document.getElementById('persist');
|
||||
const outputArea = document.getElementById('output').contentDocument;
|
||||
const defaultCode = '<?php phpinfo();';
|
||||
const editor = ace.edit("editor");
|
||||
|
||||
editor.setTheme("ace/theme/github");
|
||||
editor.session.setMode("ace/mode/php");
|
||||
editor.setShowPrintMargin(false);
|
||||
|
||||
const Php = require('./PhpWeb').PhpWeb;
|
||||
|
||||
const php = new Php();
|
||||
|
||||
const init = () => {
|
||||
outputArea.open();
|
||||
outputArea.write("Click RUN");
|
||||
outputArea.close();
|
||||
|
||||
runButton.disabled = false
|
||||
runButton.textContent = "Run"
|
||||
runButton.addEventListener('click', () => {
|
||||
|
||||
outputArea.open();
|
||||
|
||||
var code = editor.getValue();
|
||||
var query = new URLSearchParams();
|
||||
|
||||
php.run(code.replace(/^<\?php/, '')).then(returnValue => {
|
||||
|
||||
console.log(returnValue);
|
||||
|
||||
const style = document.createElement('style');
|
||||
|
||||
style.textContent = "body{ white-space:pre; }";
|
||||
|
||||
if(outputArea.head)
|
||||
{
|
||||
outputArea.head.append(style);
|
||||
}
|
||||
|
||||
if(!persistBox.checked)
|
||||
{
|
||||
php.refresh();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
if (code.length < 1024)
|
||||
{
|
||||
query.append('code', encodeURIComponent(code));
|
||||
query.append('persist', persistBox.checked ? 1 : 0);
|
||||
history.replaceState({}, document.title, "?" + query.toString());
|
||||
}
|
||||
|
||||
outputArea.close();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
php.addEventListener('ready', (event) => init());
|
||||
|
||||
php.addEventListener('output', (event) => {
|
||||
console.log(event.detail);
|
||||
outputArea.write(event.detail.join("\n"));
|
||||
});
|
||||
|
||||
const query = new URLSearchParams(document.location.search);
|
||||
|
||||
if(query.has('code'))
|
||||
{
|
||||
editor.setValue(decodeURIComponent(query.get('code')));
|
||||
}
|
||||
else
|
||||
{
|
||||
editor.setValue(defaultCode);
|
||||
}
|
||||
|
||||
if(query.get('persist'))
|
||||
{
|
||||
persistBox.checked = true;
|
||||
}
|
||||
|
||||
outputArea.open();
|
||||
|
After Width: | Height: | Size: 14 KiB |
@@ -206,7 +206,7 @@ Module['ready'] = new Promise(function(resolve, reject) {
|
||||
}
|
||||
|
||||
}
|
||||
loadPackage({"files": [{"filename": "/Zend/bench.php", "start": 0, "end": 7634, "audio": 0}], "remote_package_size": 7634, "package_uuid": "d7eb3392-4e35-4997-a136-272beeec94d0"});
|
||||
loadPackage({"files": [{"filename": "/Zend/bench.php", "start": 0, "end": 7634, "audio": 0}], "remote_package_size": 7634, "package_uuid": "99ccbb5f-82c1-47cd-89dc-e914c3820f10"});
|
||||
|
||||
})();
|
||||
|
||||
@@ -1358,11 +1358,11 @@ function updateGlobalBufferAndViews(buf) {
|
||||
}
|
||||
|
||||
var STATIC_BASE = 1024,
|
||||
STACK_BASE = 2285200,
|
||||
STACK_BASE = 2285232,
|
||||
STACKTOP = STACK_BASE,
|
||||
STACK_MAX = 7528080,
|
||||
DYNAMIC_BASE = 7528080,
|
||||
DYNAMICTOP_PTR = 2285008;
|
||||
STACK_MAX = 7528112,
|
||||
DYNAMIC_BASE = 7528112,
|
||||
DYNAMICTOP_PTR = 2285040;
|
||||
|
||||
|
||||
|
||||
@@ -1836,7 +1836,7 @@ function _emscripten_asm_const_iiii(code, a0, a1, a2) {
|
||||
|
||||
|
||||
|
||||
// STATICTOP = STATIC_BASE + 2284176;
|
||||
// STATICTOP = STATIC_BASE + 2284208;
|
||||
/* global initializers */ __ATINIT__.push({ func: function() { ___emscripten_environ_constructor() } });
|
||||
|
||||
|
||||
@@ -1847,7 +1847,7 @@ function _emscripten_asm_const_iiii(code, a0, a1, a2) {
|
||||
|
||||
|
||||
/* no memory initializer */
|
||||
var tempDoublePtr = 2285184;
|
||||
var tempDoublePtr = 2285216;
|
||||
|
||||
function copyTempFloat(ptr) { // functions, because inlining this code increases code size too much
|
||||
HEAP8[tempDoublePtr] = HEAP8[ptr];
|
||||
@@ -6556,7 +6556,7 @@ function copyTempDouble(ptr) {
|
||||
}
|
||||
|
||||
|
||||
var ___tm_formatted=2285104;
|
||||
var ___tm_formatted=2285136;
|
||||
|
||||
|
||||
function _tzset() {
|
||||
@@ -6881,7 +6881,7 @@ function copyTempDouble(ptr) {
|
||||
}
|
||||
|
||||
|
||||
var ___tm_timezone=(stringToUTF8("GMT", 2285088, 4), 2285088);function _gmtime_r(time, tmPtr) {
|
||||
var ___tm_timezone=(stringToUTF8("GMT", 2285120, 4), 2285120);function _gmtime_r(time, tmPtr) {
|
||||
var date = new Date(HEAP32[((time)>>2)]*1000);
|
||||
HEAP32[((tmPtr)>>2)]=date.getUTCSeconds();
|
||||
HEAP32[(((tmPtr)+(4))>>2)]=date.getUTCMinutes();
|
||||
@@ -8291,8 +8291,8 @@ var _pib_destroy = Module["_pib_destroy"] = function() {
|
||||
};
|
||||
|
||||
/** @type {function(...*):?} */
|
||||
var _pib_eval = Module["_pib_eval"] = function() {
|
||||
return (_pib_eval = Module["_pib_eval"] = Module["asm"]["_pib_eval"]).apply(null, arguments);
|
||||
var _pib_exec = Module["_pib_exec"] = function() {
|
||||
return (_pib_exec = Module["_pib_exec"] = Module["asm"]["_pib_exec"]).apply(null, arguments);
|
||||
};
|
||||
|
||||
/** @type {function(...*):?} */
|
||||
@@ -8305,6 +8305,11 @@ var _pib_refresh = Module["_pib_refresh"] = function() {
|
||||
return (_pib_refresh = Module["_pib_refresh"] = Module["asm"]["_pib_refresh"]).apply(null, arguments);
|
||||
};
|
||||
|
||||
/** @type {function(...*):?} */
|
||||
var _pib_run = Module["_pib_run"] = function() {
|
||||
return (_pib_run = Module["_pib_run"] = Module["asm"]["_pib_run"]).apply(null, arguments);
|
||||
};
|
||||
|
||||
/** @type {function(...*):?} */
|
||||
var _realloc = Module["_realloc"] = function() {
|
||||
return (_realloc = Module["_realloc"] = Module["asm"]["_realloc"]).apply(null, arguments);
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
//http://stuk.github.io/require1k/
|
||||
R=function(e,n,v1){function t(e,o,u,a){if(e.g)return o(e.e,e);var c=e.g=e.l,f=new XMLHttpRequest;f.onload=function(i,l){function s(){l--||o(n,e)}200==f.status||e.t?(i=[],(e.t=e.t||f.response).replace(/(?:^|[^\w\$_.])require\s*\(\s*["']([^"']*)["']\s*\)/g,function(e,n){i.push(n)}),l=i.length,i.map(function(o){t(r(e.l,o),s,"."!=o[0]?c+"/../":n,o)}),s()):u?t(e.n=r(u+="../",a),o,u,a):(e.e=f,o(f,e))},e.t?f.onload():(f.open("GET",c,!0),f.send())}function r(e,n,t){if(e.e)throw e.e;return n?(f.href=e,i.href="."!=n[0]?"./node_modules/"+n:n,t=i.href+".js",f.href="",u[t]=u[t]||{l:t}):e.n?r(e.n):(e[c]||(e.f||a("(function(require,"+c+",module){"+e.t+"\n})//# sourceURL="+e.l))(function(n){return r(r(e.l,n))},e[c]={},e),e[c])}function o(e,n){t(e.call?{l:"",t:""+e,f:e}:r("",e),function(t,o){try{e=r(o)}catch(u){t=u}n&&n(t,e)})}var u={},a=eval,c="createElement",f=e[c]("base"),i=e[c]("a");return e.head.appendChild(f),c=e.querySelector("script[data-main]"),c&&o(c.dataset.main),c="exports",o}(document);
|
||||
|
After Width: | Height: | Size: 716 B |
@@ -1,79 +0,0 @@
|
||||
body {
|
||||
background-color: #E1E1DB;
|
||||
padding: 0 1em;
|
||||
margin: 0;
|
||||
font-family: "Open Sans", sans-serif;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.playground {
|
||||
display: flex;
|
||||
height: 100vh;
|
||||
flex-direction: column;
|
||||
padding-bottom: 1em;
|
||||
box-sizing: inherit;
|
||||
}
|
||||
|
||||
.playground-header {
|
||||
display: flex;
|
||||
font-size: 12px;
|
||||
padding: 1.25em 0;
|
||||
}
|
||||
|
||||
.playground-split-vertical {
|
||||
flex-direction: row;
|
||||
display: flex;
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
.playground-editor {
|
||||
flex: 1 1 auto;
|
||||
position: relative;
|
||||
border: 4px solid #bbb;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
#output {
|
||||
flex: 1 1 auto;
|
||||
position: relative;
|
||||
margin-left: 0.5em;
|
||||
background: #f9ffff;
|
||||
border: 1px solid #bbb;
|
||||
border-right: none;
|
||||
}
|
||||
|
||||
#editor {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
}
|
||||
|
||||
#run {
|
||||
height: 3em;
|
||||
padding: 0 1.25em;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
text-transform: uppercase;
|
||||
text-decoration: none;
|
||||
font-weight: 700;
|
||||
white-space: nowrap;
|
||||
background: #a42;
|
||||
color: #fff;
|
||||
border-color: #88361b;
|
||||
border-top-right-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
border-top-left-radius: 4px;
|
||||
border-bottom-left-radius: 4px;
|
||||
cursor: pointer;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #dedede;
|
||||
}
|
||||
|
||||
label {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
|
||||
}
|
||||
@@ -9,22 +9,10 @@ RUN set -euxo pipefail;\
|
||||
apt-get update; \
|
||||
emsdk install latest; \
|
||||
apt-get --no-install-recommends -y install \
|
||||
libcurl4-openssl-dev \
|
||||
build-essential \
|
||||
libargon2-0-dev \
|
||||
libreadline-dev \
|
||||
libsqlite3-dev \
|
||||
automake-1.15 \
|
||||
libsodium-dev \
|
||||
libonig-dev \
|
||||
libyaml-dev \
|
||||
libxml2-dev \
|
||||
libssl-dev \
|
||||
libgmp-dev \
|
||||
autoconf \
|
||||
valgrind \
|
||||
libtool \
|
||||
php-dev \
|
||||
pkgconf \
|
||||
bison \
|
||||
flex \
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "php-wasm",
|
||||
"version": "0.0.2",
|
||||
"version": "0.0.3",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
sqlite3.c
|
||||
sqlite3.h
|
||||
@@ -1,5 +1,8 @@
|
||||
import { UniqueIndex } from './UniqueIndex';
|
||||
|
||||
const STR = 'string';
|
||||
const NUM = 'number';
|
||||
|
||||
export class PhpBase extends EventTarget
|
||||
{
|
||||
constructor(PhpBinary)
|
||||
@@ -28,12 +31,14 @@ export class PhpBase extends EventTarget
|
||||
},
|
||||
|
||||
print: (...chunks) =>{
|
||||
console.log(chunks);
|
||||
const event = new CustomEvent('output', {detail: chunks.map(c=>c+"\n")});
|
||||
this.dispatchEvent(event);
|
||||
this.onoutput(event);
|
||||
},
|
||||
|
||||
printErr: (...chunks) => {
|
||||
console.log(chunks);
|
||||
const event = new CustomEvent('error', {detail: chunks.map(c=>c+"\n")});
|
||||
this.onerror(event);
|
||||
this.dispatchEvent(event);
|
||||
@@ -43,8 +48,8 @@ export class PhpBase extends EventTarget
|
||||
|
||||
const retVal = php.ccall(
|
||||
'pib_init'
|
||||
, 'number'
|
||||
, ['string']
|
||||
, NUM
|
||||
, [STR]
|
||||
, []
|
||||
);
|
||||
|
||||
@@ -55,10 +60,22 @@ export class PhpBase extends EventTarget
|
||||
|
||||
run(phpCode)
|
||||
{
|
||||
console.log('Run script', phpCode);
|
||||
return this.binary.then(php => php.ccall(
|
||||
'pib_eval'
|
||||
, 'string'
|
||||
, ['string']
|
||||
'pib_run'
|
||||
, NUM
|
||||
, [STR]
|
||||
, [`?>${phpCode}`]
|
||||
));
|
||||
}
|
||||
|
||||
exec(phpCode)
|
||||
{
|
||||
console.log('Exec expression', phpCode);
|
||||
return this.binary.then(php => php.ccall(
|
||||
'pib_exec'
|
||||
, STR
|
||||
, [STR]
|
||||
, [phpCode]
|
||||
));
|
||||
}
|
||||
@@ -67,7 +84,7 @@ export class PhpBase extends EventTarget
|
||||
{
|
||||
const call = this.binary.then(php => php.ccall(
|
||||
'pib_refresh'
|
||||
, 'number'
|
||||
, NUM
|
||||
, []
|
||||
, []
|
||||
));
|
||||
|
||||
@@ -18,15 +18,24 @@ int EMSCRIPTEN_KEEPALIVE pib_init()
|
||||
return php_embed_init(0, NULL);
|
||||
}
|
||||
|
||||
char *EMSCRIPTEN_KEEPALIVE pib_eval(char *code)
|
||||
void pib_finally()
|
||||
{
|
||||
char *retVal = "";
|
||||
fflush(stdout);
|
||||
fprintf(stdout, "\n");
|
||||
|
||||
fflush(stderr);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
char *EMSCRIPTEN_KEEPALIVE pib_exec(char *code)
|
||||
{
|
||||
char *retVal = NULL;
|
||||
|
||||
zend_try
|
||||
{
|
||||
zval retZv;
|
||||
|
||||
zend_eval_string(code, &retZv, "php-wasm");
|
||||
zend_eval_string(code, &retZv, "php-wasm evaluate expression");
|
||||
|
||||
convert_to_string(&retZv);
|
||||
|
||||
@@ -34,14 +43,42 @@ char *EMSCRIPTEN_KEEPALIVE pib_eval(char *code)
|
||||
}
|
||||
zend_catch
|
||||
{
|
||||
retVal = "";
|
||||
}
|
||||
|
||||
zend_end_try();
|
||||
|
||||
pib_finally();
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
int EMSCRIPTEN_KEEPALIVE pib_run(char *code)
|
||||
{
|
||||
int retVal = 255; // Unknown error.
|
||||
|
||||
zend_try
|
||||
{
|
||||
retVal = zend_eval_string(code, NULL, "php-wasm run script");
|
||||
}
|
||||
zend_catch
|
||||
{
|
||||
retVal = 1; // Code died.
|
||||
}
|
||||
|
||||
zend_end_try();
|
||||
|
||||
pib_finally();
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
char *pib_tokenize(char *code)
|
||||
{
|
||||
// tokenize_parse(zval zend_string)
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
void EMSCRIPTEN_KEEPALIVE pib_destroy()
|
||||
{
|
||||
return php_embed_shutdown();
|
||||
|
||||