@php-wasm/web 0.6.8 → 0.6.10
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/index.d.ts +1 -5
- package/index.js +19 -16
- package/kitchen-sink/7_0_33/php_7_0.wasm +0 -0
- package/kitchen-sink/7_1_30/php_7_1.wasm +0 -0
- package/kitchen-sink/7_2_34/php_7_2.wasm +0 -0
- package/kitchen-sink/7_3_33/php_7_3.wasm +0 -0
- package/kitchen-sink/7_4_33/php_7_4.wasm +0 -0
- package/kitchen-sink/8_0_30/php_8_0.wasm +0 -0
- package/kitchen-sink/8_1_23/php_8_1.wasm +0 -0
- package/kitchen-sink/8_2_10/php_8_2.wasm +0 -0
- package/kitchen-sink/8_3_0/php_8_3.wasm +0 -0
- package/kitchen-sink/php_7_0.js +2 -2
- package/kitchen-sink/php_7_1.js +1 -1
- package/kitchen-sink/php_7_2.js +1 -1
- package/kitchen-sink/php_7_3.js +1 -1
- package/kitchen-sink/php_7_4.js +1 -1
- package/kitchen-sink/php_8_0.js +1 -1
- package/kitchen-sink/php_8_1.js +1 -1
- package/kitchen-sink/php_8_2.js +1 -1
- package/kitchen-sink/php_8_3.js +2 -2
- package/light/7_0_33/php_7_0.wasm +0 -0
- package/light/7_1_30/php_7_1.wasm +0 -0
- package/light/7_2_34/php_7_2.wasm +0 -0
- package/light/7_3_33/php_7_3.wasm +0 -0
- package/light/7_4_33/php_7_4.wasm +0 -0
- package/light/8_0_30/php_8_0.wasm +0 -0
- package/light/8_1_23/php_8_1.wasm +0 -0
- package/light/8_2_10/php_8_2.wasm +0 -0
- package/light/8_3_0/php_8_3.wasm +0 -0
- package/light/php_7_0.js +1 -1
- package/light/php_7_1.js +1 -1
- package/light/php_7_2.js +1 -1
- package/light/php_7_3.js +1 -1
- package/light/php_7_4.js +1 -1
- package/light/php_8_0.js +1 -1
- package/light/php_8_1.js +1 -1
- package/light/php_8_2.js +1 -1
- package/light/php_8_3.js +1 -1
- package/package.json +6 -6
package/index.d.ts
CHANGED
|
@@ -82,6 +82,7 @@ export interface PHPRequestEndEvent {
|
|
|
82
82
|
export interface PHPRequestErrorEvent {
|
|
83
83
|
type: "request.error";
|
|
84
84
|
error: Error;
|
|
85
|
+
source?: "request" | "php-wasm";
|
|
85
86
|
}
|
|
86
87
|
/**
|
|
87
88
|
* Represents a PHP runtime initialization event.
|
|
@@ -545,11 +546,6 @@ export interface PHPRunOptions {
|
|
|
545
546
|
* The code snippet to eval instead of a php file.
|
|
546
547
|
*/
|
|
547
548
|
code?: string;
|
|
548
|
-
/**
|
|
549
|
-
* Whether to throw an error if the PHP process exits with a non-zero code
|
|
550
|
-
* or outputs to stderr.
|
|
551
|
-
*/
|
|
552
|
-
throwOnError?: boolean;
|
|
553
549
|
}
|
|
554
550
|
export interface RmDirOptions {
|
|
555
551
|
/**
|
package/index.js
CHANGED
|
@@ -548,7 +548,7 @@ function fileToUint8Array(e) {
|
|
|
548
548
|
}, r.readAsArrayBuffer(e);
|
|
549
549
|
});
|
|
550
550
|
}
|
|
551
|
-
var g, H, N, b, k, y, C, S,
|
|
551
|
+
var g, H, N, b, k, y, C, S, L, Z, O, X, U, ee;
|
|
552
552
|
class PHPRequestHandler {
|
|
553
553
|
/**
|
|
554
554
|
* @param php - The PHP instance.
|
|
@@ -561,7 +561,7 @@ class PHPRequestHandler {
|
|
|
561
561
|
* @param fsPath - Absolute path of the static file to serve.
|
|
562
562
|
* @returns The response.
|
|
563
563
|
*/
|
|
564
|
-
d(this,
|
|
564
|
+
d(this, L);
|
|
565
565
|
/**
|
|
566
566
|
* Runs the requested PHP file with all the request and $_SERVER
|
|
567
567
|
* superglobals populated.
|
|
@@ -569,7 +569,7 @@ class PHPRequestHandler {
|
|
|
569
569
|
* @param request - The request.
|
|
570
570
|
* @returns The response.
|
|
571
571
|
*/
|
|
572
|
-
d(this,
|
|
572
|
+
d(this, O);
|
|
573
573
|
/**
|
|
574
574
|
* Resolve the requested path to the filesystem path of the requested PHP file.
|
|
575
575
|
*
|
|
@@ -630,16 +630,17 @@ class PHPRequestHandler {
|
|
|
630
630
|
/** @inheritDoc */
|
|
631
631
|
async request(t) {
|
|
632
632
|
const r = t.url.startsWith("http://") || t.url.startsWith("https://"), s = new URL(
|
|
633
|
-
|
|
633
|
+
// Remove the hash part of the URL as it's not meant for the server.
|
|
634
|
+
t.url.split("#")[0],
|
|
634
635
|
r ? void 0 : DEFAULT_BASE_URL
|
|
635
636
|
), n = applyRewriteRules(
|
|
636
637
|
removePathPrefix(s.pathname, c(this, y)),
|
|
637
638
|
this.rewriteRules
|
|
638
639
|
), o = `${c(this, g)}${n}`;
|
|
639
|
-
return seemsLikeAPHPRequestHandlerPath(o) ? await f(this,
|
|
640
|
+
return seemsLikeAPHPRequestHandlerPath(o) ? await f(this, O, X).call(this, t, s) : f(this, L, Z).call(this, o);
|
|
640
641
|
}
|
|
641
642
|
}
|
|
642
|
-
g = new WeakMap(), H = new WeakMap(), N = new WeakMap(), b = new WeakMap(), k = new WeakMap(), y = new WeakMap(), C = new WeakMap(), S = new WeakMap(),
|
|
643
|
+
g = new WeakMap(), H = new WeakMap(), N = new WeakMap(), b = new WeakMap(), k = new WeakMap(), y = new WeakMap(), C = new WeakMap(), S = new WeakMap(), L = new WeakSet(), Z = function(t) {
|
|
643
644
|
if (!this.php.fileExists(t))
|
|
644
645
|
return new PHPResponse(
|
|
645
646
|
404,
|
|
@@ -664,7 +665,7 @@ g = new WeakMap(), H = new WeakMap(), N = new WeakMap(), b = new WeakMap(), k =
|
|
|
664
665
|
},
|
|
665
666
|
r
|
|
666
667
|
);
|
|
667
|
-
},
|
|
668
|
+
}, O = new WeakSet(), X = async function(t, r) {
|
|
668
669
|
var n;
|
|
669
670
|
if (c(this, S).running > 0 && ((n = t.headers) == null ? void 0 : n["x-request-issuer"]) === "php")
|
|
670
671
|
return console.warn(
|
|
@@ -923,7 +924,7 @@ var __defProp = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyD
|
|
|
923
924
|
return s && n && __defProp(t, r, n), n;
|
|
924
925
|
};
|
|
925
926
|
const STRING = "string", NUMBER = "number", __private__dont__use = Symbol("__private__dont__use");
|
|
926
|
-
var x, F, A, w, E, v, P, M, W, te,
|
|
927
|
+
var x, F, A, w, E, v, P, M, W, te, q, re, B, se, D, ne, $, ie, z, oe, j, ae, G, le, V, ce, J, ue, Q, de, Y, he;
|
|
927
928
|
class BasePHP {
|
|
928
929
|
/**
|
|
929
930
|
* Initializes a PHP runtime.
|
|
@@ -934,8 +935,8 @@ class BasePHP {
|
|
|
934
935
|
*/
|
|
935
936
|
constructor(e, t) {
|
|
936
937
|
d(this, W);
|
|
937
|
-
d(this, B);
|
|
938
938
|
d(this, q);
|
|
939
|
+
d(this, B);
|
|
939
940
|
d(this, D);
|
|
940
941
|
d(this, $);
|
|
941
942
|
d(this, z);
|
|
@@ -1062,14 +1063,14 @@ class BasePHP {
|
|
|
1062
1063
|
throw new Error(
|
|
1063
1064
|
`The script path "${e.scriptPath}" does not exist.`
|
|
1064
1065
|
);
|
|
1065
|
-
f(this, G, le).call(this, e.scriptPath || ""), f(this,
|
|
1066
|
+
f(this, G, le).call(this, e.scriptPath || ""), f(this, B, se).call(this, e.relativeUri || ""), f(this, $, ie).call(this, e.method || "GET");
|
|
1066
1067
|
const s = normalizeHeaders(e.headers || {}), n = s.host || "example.com:443";
|
|
1067
1068
|
f(this, D, ne).call(this, n, e.protocol || "http"), f(this, z, oe).call(this, s), e.body && (r = f(this, j, ae).call(this, e.body)), typeof e.code == "string" && f(this, Q, de).call(this, " ?>" + e.code), f(this, V, ce).call(this);
|
|
1068
1069
|
const o = e.env || {};
|
|
1069
1070
|
for (const a in o)
|
|
1070
1071
|
f(this, J, ue).call(this, a, o[a]);
|
|
1071
1072
|
const i = await f(this, Y, he).call(this);
|
|
1072
|
-
if (
|
|
1073
|
+
if (i.exitCode !== 0) {
|
|
1073
1074
|
const a = {
|
|
1074
1075
|
stdout: i.text,
|
|
1075
1076
|
stderr: i.errors
|
|
@@ -1078,13 +1079,15 @@ class BasePHP {
|
|
|
1078
1079
|
const l = new Error(
|
|
1079
1080
|
`PHP.run() failed with exit code ${i.exitCode} and the following output: ` + i.errors
|
|
1080
1081
|
);
|
|
1081
|
-
throw l.output = a, console.error(l), l;
|
|
1082
|
+
throw l.output = a, l.source = "request", console.error(l), l;
|
|
1082
1083
|
}
|
|
1083
1084
|
return i;
|
|
1084
1085
|
} catch (s) {
|
|
1085
1086
|
throw this.dispatchEvent({
|
|
1086
1087
|
type: "request.error",
|
|
1087
|
-
error: s
|
|
1088
|
+
error: s,
|
|
1089
|
+
// Distinguish between PHP request and PHP-wasm errors
|
|
1090
|
+
source: s.source ?? "php-wasm"
|
|
1088
1091
|
}), s;
|
|
1089
1092
|
} finally {
|
|
1090
1093
|
try {
|
|
@@ -1234,7 +1237,7 @@ x = new WeakMap(), F = new WeakMap(), A = new WeakMap(), w = new WeakMap(), E =
|
|
|
1234
1237
|
);
|
|
1235
1238
|
}
|
|
1236
1239
|
this[__private__dont__use].ccall("php_wasm_init", null, [], []);
|
|
1237
|
-
},
|
|
1240
|
+
}, q = new WeakSet(), re = function() {
|
|
1238
1241
|
const e = "/internal/headers.json";
|
|
1239
1242
|
if (!this.fileExists(e))
|
|
1240
1243
|
throw new Error(
|
|
@@ -1251,7 +1254,7 @@ x = new WeakMap(), F = new WeakMap(), A = new WeakMap(), w = new WeakMap(), E =
|
|
|
1251
1254
|
headers: r,
|
|
1252
1255
|
httpStatusCode: t.status
|
|
1253
1256
|
};
|
|
1254
|
-
},
|
|
1257
|
+
}, B = new WeakSet(), se = function(e) {
|
|
1255
1258
|
if (this[__private__dont__use].ccall(
|
|
1256
1259
|
"wasm_set_request_uri",
|
|
1257
1260
|
null,
|
|
@@ -1403,7 +1406,7 @@ x = new WeakMap(), F = new WeakMap(), A = new WeakMap(), w = new WeakMap(), E =
|
|
|
1403
1406
|
} finally {
|
|
1404
1407
|
(n = c(this, E)) == null || n.removeEventListener("error", t), h(this, v, {});
|
|
1405
1408
|
}
|
|
1406
|
-
const { headers: r, httpStatusCode: s } = f(this,
|
|
1409
|
+
const { headers: r, httpStatusCode: s } = f(this, q, re).call(this);
|
|
1407
1410
|
return new PHPResponse(
|
|
1408
1411
|
s,
|
|
1409
1412
|
r,
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|