@capsulescodes/browser-php 0.5.12 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -117,9 +117,10 @@ npm run composer
117
117
 
118
118
  The scripts can be configured with environment variables
119
119
 
120
- - `BROWSER_PHP_VERSION` : The PHP version you need | default : `8.2`
120
+ - `BROWSER_PHP_VERSION` : The PHP version you need | default : `8.3`
121
+ - `BROWSER_PHP_CLI` : The CLI output mode | default : `xterm`
121
122
 
122
- - `BROWSER_PHP_COMPOSER_VERSION` : The Composer executable version | default : `2.7.7`
123
+ - `BROWSER_PHP_COMPOSER_VERSION` : The Composer executable version | default : `2.8.9`
123
124
  - `BROWSER_PHP_COMPOSER_PATH` : The Composer executable path | default : `vendor/bin`
124
125
  - `BROWSER_PHP_COMPOSER_NAME` : The Composer executable name | default : `composer`
125
126
 
package/bin/cli.js CHANGED
@@ -1,13 +1,21 @@
1
1
  #!/usr/bin/env node
2
- import { PHP as i } from "@php-wasm/universal";
2
+ import { PHP as p } from "@php-wasm/universal";
3
3
  import { loadNodeRuntime as n, createNodeFsMountHandler as c } from "@php-wasm/node";
4
- import r from "../dist/env.js";
5
- const o = new i(await n(r.php.version));
6
- o.mkdir(process.cwd());
7
- o.mount(process.cwd(), c(process.cwd()));
8
- o.chdir(process.cwd());
9
- let e = process.argv.slice(2);
10
- e.includes("--disable-functions") && (e.splice(e.indexOf("--disable-functions"), 1), e = ["-d", "disable_functions=proc_open,popen", ...e]);
11
- o.cli(["php", ...e]).catch((s) => {
12
- throw s;
13
- }).finally(() => process.exit(0));
4
+ import s from "../dist/env.js";
5
+ const r = new p(await n(s.php.version, { emscriptenOptions: { ENV: { TERM: s.php.cli } } }));
6
+ r.mkdir(process.cwd());
7
+ r.mount(process.cwd(), c(process.cwd()));
8
+ r.chdir(process.cwd());
9
+ let d = process.argv.slice(2);
10
+ const t = await r.cli(["php", ...d]);
11
+ t.stderr.pipeTo(new WritableStream({ write(e) {
12
+ process.stderr.write(e);
13
+ } }));
14
+ t.stdout.pipeTo(new WritableStream({ write(e) {
15
+ process.stdout.write(e);
16
+ } }));
17
+ t.exitCode.finally(() => setTimeout(() => process.exit(0), 100));
18
+ const a = process.stderr.write;
19
+ process.stderr.write = function(e, i, o) {
20
+ return typeof e == "string" && (e.includes("Program terminated with exit(0)") || e.includes("ErrorEvent")) ? !0 : a.call(process.stderr, e, i, o);
21
+ };