mirror of
https://github.com/bdnugget/php-wasm.git
synced 2026-11-07 09:07:28 +00:00
Merge conflict & minor tweaks
This commit is contained in:
commit
5627c71ce1
13 files changed
+122
-94
No files matched your search
@@ -0,0 +1,18 @@
|
||||
# php-wasm aka PIB
|
||||
|
||||
Changes
|
||||
|
||||
## 0.0.2 - Gaining Momentum
|
||||
|
||||
* php objects now have persistent memory, may be cleared with `php.refresh();`.
|
||||
* php code may now access Javascript (and thus, the DOM) via the [VRZNO](https://github.com/seanmorris/vrzno) project. The extension is preinstalled with php-wasm.
|
||||
* Building objects is now separated so multiple binaries may be built from the same set of objects.
|
||||
* License changed from MIT to Apache-2.0, which has similar terms, but USERS must hav visibility of the attribution, rather that just DEVELOPERS.
|
||||
* Build dependencies are now expressed in the makefile
|
||||
* Project can be built in its entirety by running `make`.
|
||||
|
||||
|
||||
## 0.0.1 - Humble Beginnings
|
||||
|
||||
* Event-oriented interface added to php object.
|
||||
* Buildscript was slightly improved with a makefile
|
||||
@@ -5,7 +5,7 @@ VRZNO_BRANCH:=master
|
||||
|
||||
.PHONY: configure build hooks build-js build-web-bin build-webview-bin build-node-bin build-shell-bin build-worker-bin clean
|
||||
|
||||
build: configure build-js build-webview-bin build-node-bin build-shell-bin build-worker-bin build-web-bin
|
||||
build: configure build-js build-web-bin
|
||||
@ echo "Done!"
|
||||
|
||||
configure: php-src php-src/ext/vrzno
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
php-wasm aka PIB
|
||||
|
||||
Copyright 2018-2020 Oraoto
|
||||
Copyright 2019-2020 Sean Morris
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -1,10 +1,28 @@
|
||||
# php-wasm aka PIB
|
||||
|
||||
*[PIB](https://github.com/oraoto/pib), except its an NPM module.*
|
||||
# PIB: PHP in Browser (and Node.js) aka php-wasm
|
||||
|
||||
[](https://travis-ci.org/oraoto/pib) 
|
||||
|
||||
v0.0.2 - Gaining Momentum
|
||||
### v0.0.2 - Gaining Momentum
|
||||
|
||||
# In Browser
|
||||
|
||||
**[Run PIB in Browser](https://oraoto.github.io/pib/)**
|
||||
|
||||
Firefox is recommended for better user experience.
|
||||
|
||||
## Examples
|
||||
|
||||
+ [Hello, World](https://oraoto.github.io/pib/?code=%253C%253Fphp%250A%250Aecho%2520%2522Hello%252C%2520World%21%2522%253B)
|
||||
+ [JSON](https://oraoto.github.io/pib/?code=%253C%253Fphp%250A%250A%2524x%2520%253D%2520%255B%250A%2520%2520%2520%2522id%2522%2520%253D%253E%25201%2520%2520%250A%255D%253B%250A%250Avar_dump%28json_decode%28json_encode%28%2524x%29%29%29%253B%250A)
|
||||
+ [Access The DOM](https://oraoto.github.io/pib/?code=%253C%253Fphp%250A%250A%2524oldTitle%2520%253D%2520NULL%253B%250A%2524newTitle%2520%253D%2520%27Changed%2540%27%2520.%2520date%28%27h%253Ai%253As%27%29%253B%250A%250A%252F%252F%2520Grab%2520the%2520current%2520title%250A%2524oldTitle%2520%253D%2520vrzno_eval%28%27document.title%27%29%253B%250A%250A%252F%252F%2520Change%2520the%2520document%2520title%250A%2524newTitle%2520%253D%2520vrzno_eval%28%27document.title%2520%253D%2520%2522%27%2520.%2520%2524newTitle%2520.%2520%27%2522%27%2520%29%253B%250A%250Aprintf%28%250A%2520%2520%2520%2520%27Title%2520changed%2520from%2520%2522%2525s%2522%2520to%2520%2522%2525s%2522.%27%250A%2520%2520%2520%2520%252C%2520%2524oldTitle%250A%2520%2520%2520%2520%252C%2520%2524newTitle%250A%29%253B%250A%250A%250A%252F%252F%2520Show%2520an%2520alert%250Avrzno_run%28%27alert%27%252C%2520%255B%27Hello%252C%2520World%21%27%255D%29%253B)
|
||||
+ [Persistent Data](https://oraoto.github.io/pib/?persistent=1&code=%253C%253Fphp%250A%252F%252F%2520Run%2520this%2520over%2520and%2520over%2520again...%250Aprint%2520%2524x%252B%252B%253B)
|
||||
+ [Closures](https://oraoto.github.io/pib/?code=%253C%253Fphp%250A%250A%2524x%2520%253D%252010%253B%250A%250Afunction%2520run%28callable%2520%2524f%29%2520%257B%250A%2520%2520%2520%2520%2524f%28%29%253B%250A%257D%250A%250Arun%28function%2520%28%29%2520use%2520%28%2526%2524x%29%2520%257B%250A%2520%2520%2520%2520%2524x%2520%253D%25209%253B%250A%257D%29%253B%250A%250Avar_dump%28%2524x%29%253B%250A)
|
||||
+ [PCRE](https://oraoto.github.io/pib/?code=%253C%253Fphp%250A%250Apreg_match%28%27%252F%28foo%29%28bar%29%28baz%29%252F%27%252C%2520%27foobarbaz%27%252C%2520%2524matches%252C%2520PREG_OFFSET_CAPTURE%29%253B%250Aprint_r%28%2524matches%29%253B%250A)
|
||||
+ [Multi catch exception handling](https://oraoto.github.io/pib/?code=%253C%253Fphp%250A%250Atry%2520%257B%250A%2520%2520%2520%2520if%2520%28random_int%280%252C%252010%29%2520%253E%25205%29%2520%257B%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520throw%2520new%2520BadFunctionCallException%28%29%253B%250A%2520%2520%2520%2520%257D%2520else%2520%257B%250A%2520%2520%2520%2520%2520%2520%2520%2520throw%2520new%2520LengthException%28%29%253B%250A%2520%2520%2520%2520%257D%250A%257D%2520catch%2520%28BadFunctionCallException%2520%257C%2520LengthException%2520%2524ex%29%2520%257B%250A%2520%2520%2520%2520var_dump%28%2524ex%29%253B%250A%257D%250A)
|
||||
+ [Scalar type declarations](https://oraoto.github.io/pib/?code=%253C%253Fphp%250A%252F%252Fdeclare%28strict_types%253D1%29%253B%250A%250Afunction%2520sumOfInts%28int%2520...%2524ints%29%250A%257B%250A%2520%2520%2520%2520return%2520array_sum%28%2524ints%29%253B%250A%257D%250A%250Avar_dump%28sumOfInts%282%252C%2520%273%27%252C%25204.1%29%29%253B%250A)
|
||||
+ [File access](https://oraoto.github.io/pib/?code=%253C%253Fphp%250A%250A%2524it%2520%253D%2520new%2520RecursiveIteratorIterator%28new%2520RecursiveDirectoryIterator%28%2522.%2522%29%29%253B%250A%250Aforeach%2520%28%2524it%2520as%2520%2524name%2520%253D%253E%2520%2524entry%29%2520%257B%250A%2520%2520%2520%2520echo%2520%2524name%2520.%2520%2522%253Cbr%252F%253E%2522%253B%250A%257D%250A)
|
||||
+ [Zend/bench.php](https://oraoto.github.io/pib/?code=%253C%253Fphp%250A%250Ainclude%28%2522Zend%252Fbench.php%2522%29%253B%250A)
|
||||
|
||||
|
||||
## Getting started
|
||||
|
||||
@@ -14,7 +32,7 @@ Install with npm:
|
||||
$ npm install php-wasm
|
||||
```
|
||||
|
||||
### Static assets:
|
||||
## Static assets:
|
||||
|
||||
You'll need to add the following `postinstall` script entry to your package.json to ensure the static assets are available to your web application. Make sure to replace `public/` with the path to your public document root if necessary.
|
||||
|
||||
@@ -50,7 +68,6 @@ Then, add an output listener:
|
||||
php.addEventListener('output', (event) => {
|
||||
console.log(event.detail);
|
||||
});
|
||||
|
||||
```
|
||||
|
||||
Be sure to wait until your WASM is fully loaded, then run some PHP:
|
||||
@@ -59,7 +76,6 @@ Be sure to wait until your WASM is fully loaded, then run some PHP:
|
||||
php.addEventListener('ready', () => {
|
||||
php.run('<?php echo "Hello, world!";');
|
||||
});
|
||||
|
||||
```
|
||||
Get the result code of your script with `then()`:
|
||||
|
||||
@@ -69,7 +85,20 @@ php.addEventListener('ready', () => {
|
||||
// retVal contains the return code.
|
||||
});
|
||||
});
|
||||
|
||||
```
|
||||
### Persistent Memory
|
||||
|
||||
So long as `php.refresh()` is not called from Javascript, the instance will maintain its own persistent memory.
|
||||
|
||||
```php
|
||||
<?php
|
||||
// Run this over and over again...
|
||||
print $x++;
|
||||
|
||||
```
|
||||
|
||||
See the example in action [here](https://oraoto.github.io/pib/?persistent=1&code=%253C%253Fphp%250A%252F%252F%2520Run%2520this%2520over%2520and%2520over%2520again...%250Aprint%2520%2524x%252B%252B%253B)
|
||||
|
||||
### Accessing the DOM
|
||||
|
||||
@@ -93,38 +122,12 @@ vrzno_eval('document.title = "' . $newTitle . '"' );
|
||||
|
||||
```
|
||||
|
||||
### Persistent Memory
|
||||
|
||||
So long as `php.refresh()` is not called, the instance will have its own persistent memory.
|
||||
|
||||
```php
|
||||
<?php
|
||||
// Run this over and over again...
|
||||
print $x++;
|
||||
|
||||
```
|
||||
|
||||
See the example in action [here](https://oraoto.github.io/pib/?persistent=1&code=%253C%253Fphp%250A%252F%252F%2520Run%2520this%2520over%2520and%2520over%2520again...%250Aprint%2520%2524x%252B%252B%253B)
|
||||
|
||||
# php-wasm is a fork of oraoto/PIB...
|
||||
|
||||
**[Run PIB](https://oraoto.github.io/pib/)**
|
||||
|
||||
Firefox is recommended for better user experience.
|
||||
|
||||
## Examples
|
||||
|
||||
+ [Hello, World](https://oraoto.github.io/pib/?code=%253C%253Fphp%250A%250Aecho%2520%2522Hello%252C%2520World%21%2522%253B)
|
||||
+ [JSON](https://oraoto.github.io/pib/?code=%253C%253Fphp%250A%250A%2524x%2520%253D%2520%255B%250A%2520%2520%2520%2522id%2522%2520%253D%253E%25201%2520%2520%250A%255D%253B%250A%250Avar_dump%28json_decode%28json_encode%28%2524x%29%29%29%253B%250A)
|
||||
+ [Persistent Data](https://oraoto.github.io/pib/?persistent=1&code=%253C%253Fphp%250A%252F%252F%2520Run%2520this%2520over%2520and%2520over%2520again...%250Aprint%2520%2524x%252B%252B%253B)
|
||||
+ [Access Javascript](https://oraoto.github.io/pib/?code=%253C%253Fphp%250A%250A%2524oldTitle%2520%253D%2520NULL%253B%250A%2524newTitle%2520%253D%2520%27Changed%2540%27%2520.%2520date%28%27h%253Ai%253As%27%29%253B%250A%250A%252F%252F%2520Grab%2520the%2520current%2520title%250A%2524oldTitle%2520%253D%2520vrzno_eval%28%27document.title%27%29%253B%250A%250A%252F%252F%2520Change%2520the%2520document%2520title%250A%2524newTitle%2520%253D%2520vrzno_eval%28%27document.title%2520%253D%2520%2522%27%2520.%2520%2524newTitle%2520.%2520%27%2522%27%2520%29%253B%250A%250Aprintf%28%250A%2520%2520%2520%2520%27Title%2520changed%2520from%2520%2522%2525s%2522%2520to%2520%2522%2525s%2522.%27%250A%2520%2520%2520%2520%252C%2520%2524oldTitle%250A%2520%2520%2520%2520%252C%2520%2524newTitle%250A%29%253B%250A%250A%250A%252F%252F%2520Show%2520an%2520alert%250Avrzno_run%28%27alert%27%252C%2520%255B%27Hello%252C%2520World%21%27%255D%29%253B)
|
||||
+ [Closures](https://oraoto.github.io/pib/?code=%253C%253Fphp%250A%250A%2524x%2520%253D%252010%253B%250A%250Afunction%2520run%28callable%2520%2524f%29%2520%257B%250A%2520%2520%2520%2520%2524f%28%29%253B%250A%257D%250A%250Arun%28function%2520%28%29%2520use%2520%28%2526%2524x%29%2520%257B%250A%2520%2520%2520%2520%2524x%2520%253D%25209%253B%250A%257D%29%253B%250A%250Avar_dump%28%2524x%29%253B%250A)
|
||||
+ [PCRE](https://oraoto.github.io/pib/?code=%253C%253Fphp%250A%250Apreg_match%28%27%252F%28foo%29%28bar%29%28baz%29%252F%27%252C%2520%27foobarbaz%27%252C%2520%2524matches%252C%2520PREG_OFFSET_CAPTURE%29%253B%250Aprint_r%28%2524matches%29%253B%250A)
|
||||
+ [Multi catch exception handling](https://oraoto.github.io/pib/?code=%253C%253Fphp%250A%250Atry%2520%257B%250A%2520%2520%2520%2520if%2520%28random_int%280%252C%252010%29%2520%253E%25205%29%2520%257B%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520throw%2520new%2520BadFunctionCallException%28%29%253B%250A%2520%2520%2520%2520%257D%2520else%2520%257B%250A%2520%2520%2520%2520%2520%2520%2520%2520throw%2520new%2520LengthException%28%29%253B%250A%2520%2520%2520%2520%257D%250A%257D%2520catch%2520%28BadFunctionCallException%2520%257C%2520LengthException%2520%2524ex%29%2520%257B%250A%2520%2520%2520%2520var_dump%28%2524ex%29%253B%250A%257D%250A)
|
||||
+ [Scalar type declarations](https://oraoto.github.io/pib/?code=%253C%253Fphp%250A%252F%252Fdeclare%28strict_types%253D1%29%253B%250A%250Afunction%2520sumOfInts%28int%2520...%2524ints%29%250A%257B%250A%2520%2520%2520%2520return%2520array_sum%28%2524ints%29%253B%250A%257D%250A%250Avar_dump%28sumOfInts%282%252C%2520%273%27%252C%25204.1%29%29%253B%250A)
|
||||
+ [File access](https://oraoto.github.io/pib/?code=%253C%253Fphp%250A%250A%2524it%2520%253D%2520new%2520RecursiveIteratorIterator%28new%2520RecursiveDirectoryIterator%28%2522.%2522%29%29%253B%250A%250Aforeach%2520%28%2524it%2520as%2520%2524name%2520%253D%253E%2520%2524entry%29%2520%257B%250A%2520%2520%2520%2520echo%2520%2524name%2520.%2520%2522%253Cbr%252F%253E%2522%253B%250A%257D%250A)
|
||||
+ [Zend/bench.php](https://oraoto.github.io/pib/?code=%253C%253Fphp%250A%250Ainclude%28%2522Zend%252Fbench.php%2522%29%253B%250A) (**Benchmark, about 5x slower in Firefox than native PHP**)
|
||||
|
||||
## Building From Source
|
||||
|
||||
### Using Docker
|
||||
@@ -142,12 +145,9 @@ Steps:
|
||||
+ Setup emsdk (>= 1.38.11), see [Installation Instructions](https://emscripten.org/docs/getting_started/downloads.html#installation-instructions)
|
||||
+ Run `bash configure.sh`
|
||||
+ Run `bash build-objects.sh`
|
||||
+ Run `bash build.sh` to build the web binaries
|
||||
* Run `ENVIRONMENT=shell bash build.sh` to build the shell binaries (optional)
|
||||
* Run `ENVIRONMENT=node bash build.sh` to build the node binaries (optional)
|
||||
* Run `ENVIRONMENT=worker bash build.sh` to build the worker binaries (optional)
|
||||
* Run `ENVIRONMENT=webview bash build.sh` to build the webview binaries (optional)
|
||||
+ Run `bash build.sh` to build the web binary
|
||||
|
||||
## Acknowledgements
|
||||
# Acknowledgements
|
||||
|
||||
The Web UI is based on [Rust Playground](https://play.rust-lang.org/).
|
||||
- php-wasm and makefile contributed by @seanmorris
|
||||
- The Web UI is based on [Rust Playground](https://play.rust-lang.org/).
|
||||
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euxo pipefail;
|
||||
|
||||
pushd php-src
|
||||
|
||||
emmake make -j8
|
||||
|
||||
EMCC_CORES=8 emcc -O3 \
|
||||
-I . \
|
||||
-I Zend \
|
||||
-I main \
|
||||
-I TSRM/ \
|
||||
../source/pib_eval.c \
|
||||
-o pib_eval.o
|
||||
+3
-20
@@ -33,15 +33,7 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || func
|
||||
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
|
||||
var PhpNode = require('./php-node');
|
||||
|
||||
var PhpShell = require('./php-shell');
|
||||
|
||||
var PhpWeb = require('./php-web');
|
||||
|
||||
var PhpWebView = require('./php-webview');
|
||||
|
||||
var PhpWorker = require('./php-worker');
|
||||
var PhpBinary = require('./php-web');
|
||||
|
||||
var Php = /*#__PURE__*/function (_EventTarget) {
|
||||
_inherits(Php, _EventTarget);
|
||||
@@ -51,8 +43,6 @@ var Php = /*#__PURE__*/function (_EventTarget) {
|
||||
function Php() {
|
||||
var _this;
|
||||
|
||||
var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'web';
|
||||
|
||||
_classCallCheck(this, Php);
|
||||
|
||||
_this = _super.call(this);
|
||||
@@ -65,15 +55,8 @@ var Php = /*#__PURE__*/function (_EventTarget) {
|
||||
|
||||
_this.onready = function () {};
|
||||
|
||||
var binaryClasses = {
|
||||
webview: PhpWebView,
|
||||
worker: PhpWorker,
|
||||
shell: PhpShell,
|
||||
node: PhpNode,
|
||||
web: PhpWeb
|
||||
};
|
||||
var binaryClass = binaryClasses[type];
|
||||
_this.binary = new binaryClass({
|
||||
console.log(PhpBinary);
|
||||
_this.binary = new PhpBinary({
|
||||
postRun: function postRun() {
|
||||
var event = new CustomEvent('ready');
|
||||
|
||||
|
||||
+4
-1
@@ -7,11 +7,14 @@
|
||||
<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$/, '');
|
||||
const path = location.pathname.replace(/index.html$/, '').replace(/\/$/, '') + '/';
|
||||
|
||||
const script = document.createElement('script');
|
||||
script.type = 'text/javascript';
|
||||
script.src = `${path}require1k.js`;
|
||||
|
||||
console.log(script.src);
|
||||
|
||||
console.log(path);
|
||||
|
||||
script.setAttribute('data-main', `./index`);
|
||||
|
||||
+17
-1
@@ -9,7 +9,14 @@ editor.setTheme("ace/theme/github");
|
||||
editor.session.setMode("ace/mode/php");
|
||||
editor.setShowPrintMargin(false);
|
||||
|
||||
const php = new ( require('./Php').Php );
|
||||
console.log(1132);
|
||||
|
||||
const Php = require('./Php').Php;
|
||||
|
||||
console.log(Php);
|
||||
|
||||
const php = new Php();
|
||||
console.log(1132);
|
||||
|
||||
const init = () => {
|
||||
outputArea.write("Click RUN");
|
||||
@@ -36,6 +43,7 @@ const init = () => {
|
||||
if (code.length < 1024)
|
||||
{
|
||||
query.append('code', encodeURIComponent(code));
|
||||
query.append('persist', persistBox.checked ? 1 : 0);
|
||||
history.replaceState({}, document.title, "?" + query.toString());
|
||||
}
|
||||
|
||||
@@ -43,6 +51,7 @@ const init = () => {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
php.addEventListener('ready', (event) => init());
|
||||
|
||||
php.addEventListener('output', (event) => {
|
||||
@@ -62,5 +71,12 @@ else
|
||||
editor.setValue(defaultCode);
|
||||
}
|
||||
|
||||
console.log(query.get('persist'));
|
||||
|
||||
if(query.get('persist'))
|
||||
{
|
||||
persistBox.checked = true;
|
||||
}
|
||||
|
||||
output_area.open();
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ var PHP = (function() {
|
||||
function(PHP) {
|
||||
PHP = PHP || {};
|
||||
|
||||
var Module=typeof PHP!=="undefined"?PHP:{};var readyPromiseResolve,readyPromiseReject;Module["ready"]=new Promise(function(resolve,reject){readyPromiseResolve=resolve;readyPromiseReject=reject});var moduleOverrides={};var key;for(key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var arguments_=[];var thisProgram="./this.program";var quit_=function(status,toThrow){throw toThrow};var ENVIRONMENT_IS_WEB=true;var ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var read_,readAsync,readBinary,setWindowTitle;if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href}else if(document.currentScript){scriptDirectory=document.currentScript.src}if(_scriptDir){scriptDirectory=_scriptDir}if(scriptDirectory.indexOf("blob:")!==0){scriptDirectory=scriptDirectory.substr(0,scriptDirectory.lastIndexOf("/")+1)}else{scriptDirectory=""}{read_=function shell_read(url){var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText};if(ENVIRONMENT_IS_WORKER){readBinary=function readBinary(url){var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=function readAsync(url,onload,onerror){var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=function xhr_onload(){if(xhr.status==200||xhr.status==0&&xhr.response){onload(xhr.response);return}onerror()};xhr.onerror=onerror;xhr.send(null)}}setWindowTitle=function(title){document.title=title}}else{}var out=Module["print"]||console.log.bind(console);var err=Module["printErr"]||console.warn.bind(console);for(key in moduleOverrides){if(moduleOverrides.hasOwnProperty(key)){Module[key]=moduleOverrides[key]}}moduleOverrides=null;if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];if(Module["quit"])quit_=Module["quit"];function dynamicAlloc(size){var ret=HEAP32[DYNAMICTOP_PTR>>2];var end=ret+size+15&-16;HEAP32[DYNAMICTOP_PTR>>2]=end;return ret}function getNativeTypeSize(type){switch(type){case"i1":case"i8":return 1;case"i16":return 2;case"i32":return 4;case"i64":return 8;case"float":return 4;case"double":return 8;default:{if(type[type.length-1]==="*"){return 4}else if(type[0]==="i"){var bits=Number(type.substr(1));assert(bits%8===0,"getNativeTypeSize invalid bits "+bits+", type "+type);return bits/8}else{return 0}}}}var asm2wasmImports={"f64-rem":function(x,y){return x%y},"debugger":function(){}};var functionPointers=new Array(0);var tempRet0=0;var setTempRet0=function(value){tempRet0=value};var getTempRet0=function(){return tempRet0};var wasmBinary;if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];var noExitRuntime;if(Module["noExitRuntime"])noExitRuntime=Module["noExitRuntime"];if(typeof WebAssembly!=="object"){err("no native wasm support detected")}function setValue(ptr,value,type,noSafe){type=type||"i8";if(type.charAt(type.length-1)==="*")type="i32";switch(type){case"i1":HEAP8[ptr>>0]=value;break;case"i8":HEAP8[ptr>>0]=value;break;case"i16":HEAP16[ptr>>1]=value;break;case"i32":HEAP32[ptr>>2]=value;break;case"i64":tempI64=[value>>>0,(tempDouble=value,+Math_abs(tempDouble)>=1?tempDouble>0?(Math_min(+Math_floor(tempDouble/4294967296),4294967295)|0)>>>0:~~+Math_ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[ptr>>2]=tempI64[0],HEAP32[ptr+4>>2]=tempI64[1];break;case"float":HEAPF32[ptr>>2]=value;break;case"double":HEAPF64[ptr>>3]=value;break;default:abort("invalid type for setValue: "+type)}}var wasmMemory;var wasmTable=new WebAssembly.Table({"initial":5295,"maximum":5295,"element":"anyfunc"});var ABORT=false;var EXITSTATUS=0;function assert(condition,text){if(!condition){abort("Assertion failed: "+text)}}function getCFunc(ident){var func=Module["_"+ident];assert(func,"Cannot call unknown function "+ident+", make sure it is exported");return func}function ccall(ident,returnType,argTypes,args,opts){var toC={"string":function(str){var ret=0;if(str!==null&&str!==undefined&&str!==0){var len=(str.length<<2)+1;ret=stackAlloc(len);stringToUTF8(str,ret,len)}return ret},"array":function(arr){var ret=stackAlloc(arr.length);writeArrayToMemory(arr,ret);return ret}};function convertReturnValue(ret){if(returnType==="string")return UTF8ToString(ret);if(returnType==="boolean")return Boolean(ret);return ret}var func=getCFunc(ident);var cArgs=[];var stack=0;if(args){for(var i=0;i<args.length;i++){var converter=toC[argTypes[i]];if(converter){if(stack===0)stack=stackSave();cArgs[i]=converter(args[i])}else{cArgs[i]=args[i]}}}var ret=func.apply(null,cArgs);ret=convertReturnValue(ret);if(stack!==0)stackRestore(stack);return ret}var ALLOC_STACK=1;var ALLOC_NONE=3;function allocate(slab,types,allocator,ptr){var zeroinit,size;if(typeof slab==="numberLine truncated
|
||||
var Module=typeof PHP!=="undefined"?PHP:{};var readyPromiseResolve,readyPromiseReject;Module["ready"]=new Promise(function(resolve,reject){readyPromiseResolve=resolve;readyPromiseReject=reject});if(!Module.expectedDataFileDownloads){Module.expectedDataFileDownloads=0}Module.expectedDataFileDownloads++;(function(){var loadPackage=function(metadata){var PACKAGE_PATH;if(typeof window==="object"){PACKAGE_PATH=window["encodeURIComponent"](window.location.pathname.toString().substring(0,window.location.pathname.toString().lastIndexOf("/"))+"/")}else if(typeof location!=="undefined"){PACKAGE_PATH=encodeURIComponent(location.pathname.toString().substring(0,location.pathname.toString().lastIndexOf("/"))+"/")}else{throw"using preloaded data can only be done on a web page or in a web worker"}var PACKAGE_NAME="../out/php-web.data";var REMOTE_PACKAGE_BASE="php-web.data";if(typeof Module["locateFilePackage"]==="function"&&!Module["locateFile"]){Module["locateFile"]=Module["locateFilePackage"];err("warning: you defined Module.locateFilePackage, that has been renamed to Module.locateFile (using your locateFilePackage for now)")}var REMOTE_PACKAGE_NAME=Module["locateFile"]?Module["locateFile"](REMOTE_PACKAGE_BASE,""):REMOTE_PACKAGE_BASE;var REMOTE_PACKAGE_SIZE=metadata["remote_package_size"];var PACKAGE_UUID=metadata["package_uuid"];function fetchRemotePackage(packageName,packageSize,callback,errback){var xhr=new XMLHttpRequest;xhr.open("GET",packageName,true);xhr.responseType="arraybuffer";xhr.onprogress=function(event){var url=packageName;var size=packageSize;if(event.total)size=event.total;if(event.loaded){if(!xhr.addedTotal){xhr.addedTotal=true;if(!Module.dataFileDownloads)Module.dataFileDownloads={};Module.dataFileDownloads[url]={loaded:event.loaded,total:size}}else{Module.dataFileDownloads[url].loaded=event.loaded}var total=0;var loaded=0;var num=0;for(var download in Module.dataFileDownloads){var data=Module.dataFileDownloads[download];total+=data.total;loaded+=data.loaded;num++}total=Math.ceil(total*Module.expectedDataFileDownloads/num);if(Module["setStatus"])Module["setStatus"]("Downloading data... ("+loaded+"/"+total+")")}else if(!Module.dataFileDownloads){if(Module["setStatus"])Module["setStatus"]("Downloading data...")}};xhr.onerror=function(event){throw new Error("NetworkError for: "+packageName)};xhr.onload=function(event){if(xhr.status==200||xhr.status==304||xhr.status==206||xhr.status==0&&xhr.response){var packageData=xhr.response;callback(packageData)}else{throw new Error(xhr.statusText+" : "+xhr.responseURL)}};xhr.send(null)}function handleError(error){console.error("package error:",error)}var fetchedCallback=null;var fetched=Module["getPreloadedPackage"]?Module["getPreloadedPackage"](REMOTE_PACKAGE_NAME,REMOTE_PACKAGE_SIZE):null;if(!fetched)fetchRemotePackage(REMOTE_PACKAGE_NAME,REMOTE_PACKAGE_SIZE,function(data){if(fetchedCallback){fetchedCallback(data);fetchedCallback=null}else{fetched=data}},handleError);function runWithFS(){function assert(check,msg){if(!check)throw msg+(new Error).stack}Module["FS_createPath"]("/","Zend",true,true);function DataRequest(start,end,audio){this.start=start;this.end=end;this.audio=audio}DataRequest.prototype={requests:{},open:function(mode,name){this.name=name;this.requests[name]=this;Module["addRunDependency"]("fp "+this.name)},send:function(){},onload:function(){var byteArray=this.byteArray.subarray(this.start,this.end);this.finish(byteArray)},finish:function(byteArray){var that=this;Module["FS_createDataFile"](this.name,null,byteArray,true,true,true);Module["removeRunDependency"]("fp "+that.name);this.requests[this.name]=null}};var files=metadata["files"];for(var i=0;i<files.length;++i){new DataRequest(files[i]["start"],files[i]["end"],files[i]["audio"]).open("GET",files[i]["filename"])}function processPackageData(arrayBuffer){assert(arrayBuffer,"Loading data file failed.");assert(arrayBuffer instanceof ArrayBuffer,"bad input to processPackageData");var byteArray=new Uint8Array(arrayBuffer);var ptr=Module["getMemory"](byteArray.length);Module["HEAPU8"].set(byteArray,ptr);DataRequest.prototype.byteArray=Module["HEAPU8"].subarray(ptr,ptr+byteArray.length);var files=metadata["files"];for(var i=0;i<files.length;++i){DataRequest.prototype.requests[files[i].filename].onload()}Module["removeRunDependency"]("datafile_../out/php-web.data")}Module["addRunDependency"]("datafile_../out/php-web.data");if(!Module.preloadResults)Module.preloadResults={};Module.preloadResults[PACKAGE_NAME]={fromCache:false};if(fetched){processPackageData(fetched);fetched=null}else{fetchedCallback=processPackageData}}if(Module["calledRun"]){runWithFS()}else{if(!Module["preRun"])Module["preRun"]=[];Module["preRun"].push(runWithFS)}};loadPackage({"files":[{"filename":"/Zend/bench.php","start":0,"end":7634,"audio":0}],"remote_package_size":7634,"package_uuid":"5b0234a0-3feb-4f8a-997f-82b75051b96c"})})();var moduleOverrides={};var key;for(key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Line truncated
|
||||
|
||||
|
||||
return PHP.ready
|
||||
|
||||
Binary file not shown.
Generated
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "php-wasm",
|
||||
"version": "0.0.1c",
|
||||
"version": "0.0.2",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
"description": "Run PHP right in the browser.",
|
||||
"repository": "https://github.com/seanmorris/pib",
|
||||
"author": "Oraoto <oraoto@outlook.com>",
|
||||
"version": "0.0.1c",
|
||||
"version": "0.0.2",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.8.4",
|
||||
|
||||
+5
-28
@@ -1,6 +1,8 @@
|
||||
const PhpBinary = require('./php-web');
|
||||
|
||||
export class Php extends EventTarget
|
||||
{
|
||||
constructor(type = 'web')
|
||||
constructor()
|
||||
{
|
||||
super();
|
||||
|
||||
@@ -12,34 +14,9 @@ export class Php extends EventTarget
|
||||
this.onoutput = function () {};
|
||||
this.onready = function () {};
|
||||
|
||||
let binaryClass;
|
||||
console.log(PhpBinary);
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case 'webview':
|
||||
binaryClass = require('./php-webview');
|
||||
break;
|
||||
|
||||
case 'worker':
|
||||
binaryClass = require('./php-worker');
|
||||
break;
|
||||
|
||||
case 'shell':
|
||||
binaryClass = require('./php-shell');
|
||||
break;
|
||||
|
||||
case 'node':
|
||||
binaryClass = require('./php-node');
|
||||
break;
|
||||
|
||||
case 'web':
|
||||
binaryClass = require('./php-web');
|
||||
break;
|
||||
}
|
||||
|
||||
binaryClasses[type];
|
||||
|
||||
this.binary = new binaryClass({
|
||||
this.binary = new PhpBinary({
|
||||
|
||||
postRun: () => {
|
||||
const event = new CustomEvent('ready');
|
||||
|
||||
Reference in new issue
Block a user