@php-wasm/universal 3.1.22 → 3.1.25
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 +6 -5
- package/index.cjs +7 -7
- package/index.cjs.map +1 -1
- package/index.js +118 -113
- package/index.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/load-extension.d.ts +1 -13
- package/package.json +6 -6
package/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var
|
|
1
|
+
var J = (r) => {
|
|
2
2
|
throw TypeError(r);
|
|
3
3
|
};
|
|
4
|
-
var q = (r, e, t) => e.has(r) ||
|
|
5
|
-
var
|
|
4
|
+
var q = (r, e, t) => e.has(r) || J("Cannot " + t);
|
|
5
|
+
var d = (r, e, t) => (q(r, e, "read from private field"), t ? t.call(r) : e.get(r)), y = (r, e, t) => e.has(r) ? J("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(r) : e.set(r, t), w = (r, e, t, s) => (q(r, e, "write to private field"), s ? s.call(r, t) : e.set(r, t), t), m = (r, e, t) => (q(r, e, "access private method"), t);
|
|
6
6
|
import { logger } from "@php-wasm/logger";
|
|
7
7
|
import { dirname, joinPaths, Semaphore, createSpawnHandler, basename, normalizePath, AcquireTimeoutError, splitShellCommand } from "@php-wasm/util";
|
|
8
8
|
import { parse, stringify } from "ini";
|
|
@@ -551,7 +551,7 @@ class PHPWorker {
|
|
|
551
551
|
}
|
|
552
552
|
/** @inheritDoc @php-wasm/universal!/PHP.addEventListener */
|
|
553
553
|
addEventListener(e, t) {
|
|
554
|
-
|
|
554
|
+
d(this, v).has(e) || d(this, v).set(e, /* @__PURE__ */ new Set()), d(this, v).get(e).add(t);
|
|
555
555
|
}
|
|
556
556
|
/**
|
|
557
557
|
* Removes an event listener for a PHP event.
|
|
@@ -560,10 +560,10 @@ class PHPWorker {
|
|
|
560
560
|
*/
|
|
561
561
|
removeEventListener(e, t) {
|
|
562
562
|
var s;
|
|
563
|
-
(s =
|
|
563
|
+
(s = d(this, v).get(e)) == null || s.delete(t);
|
|
564
564
|
}
|
|
565
565
|
dispatchEvent(e) {
|
|
566
|
-
const t =
|
|
566
|
+
const t = d(this, v).get(e.type);
|
|
567
567
|
if (t)
|
|
568
568
|
for (const s of t)
|
|
569
569
|
s(e);
|
|
@@ -729,7 +729,7 @@ const W = class W {
|
|
|
729
729
|
* For parsed headers, use the `headers` property instead.
|
|
730
730
|
*/
|
|
731
731
|
getHeadersStream() {
|
|
732
|
-
return
|
|
732
|
+
return d(this, O);
|
|
733
733
|
}
|
|
734
734
|
/**
|
|
735
735
|
* True if the response is successful (HTTP status code 200-399),
|
|
@@ -790,7 +790,7 @@ const W = class W {
|
|
|
790
790
|
}
|
|
791
791
|
async getParsedHeaders() {
|
|
792
792
|
return this.cachedParsedHeaders || (this.cachedParsedHeaders = parseHeadersStream(
|
|
793
|
-
|
|
793
|
+
d(this, U)
|
|
794
794
|
)), await this.cachedParsedHeaders;
|
|
795
795
|
}
|
|
796
796
|
};
|
|
@@ -1069,7 +1069,7 @@ class PHPExecutionFailureError extends Error {
|
|
|
1069
1069
|
}
|
|
1070
1070
|
}
|
|
1071
1071
|
const PHP_INI_PATH = "/internal/shared/php.ini", AUTO_PREPEND_SCRIPT = "/internal/shared/auto_prepend_file.php", OPCACHE_FILE_FOLDER = "/internal/shared/opcache";
|
|
1072
|
-
var I, R, H, F, b, T, _, f,
|
|
1072
|
+
var I, R, H, F, b, T, _, f, Y, X, Q, K, Z, ee, te, re, z, se, V, G;
|
|
1073
1073
|
class PHP {
|
|
1074
1074
|
/**
|
|
1075
1075
|
* Initializes a PHP runtime.
|
|
@@ -1097,7 +1097,7 @@ class PHP {
|
|
|
1097
1097
|
requestsMade: 0
|
|
1098
1098
|
});
|
|
1099
1099
|
this.semaphore = new Semaphore({ concurrency: 1 }), r !== void 0 && this.initializeRuntime(r), this.addEventListener("request.error", (e) => {
|
|
1100
|
-
e.source === "php-wasm" && (
|
|
1100
|
+
e.source === "php-wasm" && (d(this, _).needsRotating = !0);
|
|
1101
1101
|
});
|
|
1102
1102
|
}
|
|
1103
1103
|
/**
|
|
@@ -1106,7 +1106,7 @@ class PHP {
|
|
|
1106
1106
|
* @param listener - The listener function to be called when the event is triggered.
|
|
1107
1107
|
*/
|
|
1108
1108
|
addEventListener(r, e) {
|
|
1109
|
-
|
|
1109
|
+
d(this, F).has(r) || d(this, F).set(r, /* @__PURE__ */ new Set()), d(this, F).get(r).add(e);
|
|
1110
1110
|
}
|
|
1111
1111
|
/**
|
|
1112
1112
|
* Removes an event listener for a PHP event.
|
|
@@ -1115,12 +1115,12 @@ class PHP {
|
|
|
1115
1115
|
*/
|
|
1116
1116
|
removeEventListener(r, e) {
|
|
1117
1117
|
var t;
|
|
1118
|
-
(t =
|
|
1118
|
+
(t = d(this, F).get(r)) == null || t.delete(e);
|
|
1119
1119
|
}
|
|
1120
1120
|
dispatchEvent(r) {
|
|
1121
1121
|
const e = [
|
|
1122
|
-
...
|
|
1123
|
-
...
|
|
1122
|
+
...d(this, F).get(r.type) || [],
|
|
1123
|
+
...d(this, F).get("*") || []
|
|
1124
1124
|
];
|
|
1125
1125
|
if (e)
|
|
1126
1126
|
for (const t of e)
|
|
@@ -1166,8 +1166,8 @@ class PHP {
|
|
|
1166
1166
|
* @param listener Callback function to handle the message.
|
|
1167
1167
|
*/
|
|
1168
1168
|
onMessage(r) {
|
|
1169
|
-
return
|
|
1170
|
-
w(this, b,
|
|
1169
|
+
return d(this, b).push(r), async () => {
|
|
1170
|
+
w(this, b, d(this, b).filter(
|
|
1171
1171
|
(e) => e !== r
|
|
1172
1172
|
));
|
|
1173
1173
|
};
|
|
@@ -1261,7 +1261,7 @@ class PHP {
|
|
|
1261
1261
|
}
|
|
1262
1262
|
`
|
|
1263
1263
|
), e.onMessage = async (t) => {
|
|
1264
|
-
for (const s of
|
|
1264
|
+
for (const s of d(this, b)) {
|
|
1265
1265
|
const n = await s(t);
|
|
1266
1266
|
if (n)
|
|
1267
1267
|
return n;
|
|
@@ -1505,7 +1505,7 @@ class PHP {
|
|
|
1505
1505
|
const e = await this.semaphore.acquire();
|
|
1506
1506
|
let t;
|
|
1507
1507
|
const s = m(this, f, G).call(this, async () => {
|
|
1508
|
-
if (
|
|
1508
|
+
if (d(this, R) || (await this[__private__dont__use].ccall(
|
|
1509
1509
|
"php_wasm_init",
|
|
1510
1510
|
null,
|
|
1511
1511
|
[],
|
|
@@ -1527,7 +1527,7 @@ class PHP {
|
|
|
1527
1527
|
throw new TypeError(
|
|
1528
1528
|
"The request object must have either a `code` or a `scriptPath` property."
|
|
1529
1529
|
);
|
|
1530
|
-
const c = m(this, f,
|
|
1530
|
+
const c = m(this, f, Y).call(this, r.$_SERVER, i, a);
|
|
1531
1531
|
for (const u in c)
|
|
1532
1532
|
m(this, f, se).call(this, u, c[u]);
|
|
1533
1533
|
const l = r.env || {};
|
|
@@ -1771,20 +1771,20 @@ class PHP {
|
|
|
1771
1771
|
*/
|
|
1772
1772
|
enableRuntimeRotation(r) {
|
|
1773
1773
|
w(this, _, {
|
|
1774
|
-
...
|
|
1774
|
+
...d(this, _),
|
|
1775
1775
|
enabled: !0,
|
|
1776
1776
|
recreateRuntime: r.recreateRuntime,
|
|
1777
1777
|
maxRequests: r.maxRequests ?? 400
|
|
1778
1778
|
});
|
|
1779
1779
|
}
|
|
1780
1780
|
async rotateRuntime() {
|
|
1781
|
-
if (!
|
|
1781
|
+
if (!d(this, _).enabled)
|
|
1782
1782
|
throw new Error(
|
|
1783
1783
|
"Runtime rotation is not enabled. Call enableRuntimeRotation() first."
|
|
1784
1784
|
);
|
|
1785
1785
|
await this.hotSwapPHPRuntime(
|
|
1786
|
-
await
|
|
1787
|
-
),
|
|
1786
|
+
await d(this, _).recreateRuntime()
|
|
1787
|
+
), d(this, _).requestsMade = 0, d(this, _).needsRotating = !1;
|
|
1788
1788
|
}
|
|
1789
1789
|
/**
|
|
1790
1790
|
* Hot-swaps the PHP runtime for a new one without
|
|
@@ -1795,13 +1795,13 @@ class PHP {
|
|
|
1795
1795
|
async hotSwapPHPRuntime(r) {
|
|
1796
1796
|
const e = this[__private__dont__use].FS, t = this.listFiles("/").map((c) => `/${c}`), s = this[__private__dont__use].spawnProcess, n = e.cwd();
|
|
1797
1797
|
e.chdir("/");
|
|
1798
|
-
const i = Object.entries(
|
|
1798
|
+
const i = Object.entries(d(this, T)).map(
|
|
1799
1799
|
([c, l]) => ({
|
|
1800
1800
|
mountHandler: l.mountHandler,
|
|
1801
1801
|
vfsPath: c
|
|
1802
1802
|
})
|
|
1803
1803
|
), o = Object.values(
|
|
1804
|
-
|
|
1804
|
+
d(this, T)
|
|
1805
1805
|
).reverse();
|
|
1806
1806
|
for (const c of o)
|
|
1807
1807
|
await c.unmount();
|
|
@@ -1809,7 +1809,7 @@ class PHP {
|
|
|
1809
1809
|
this.exit();
|
|
1810
1810
|
} catch {
|
|
1811
1811
|
}
|
|
1812
|
-
this.initializeRuntime(r), s && (this[__private__dont__use].spawnProcess = s),
|
|
1812
|
+
this.initializeRuntime(r), s && (this[__private__dont__use].spawnProcess = s), d(this, I) && this.setSapiName(d(this, I));
|
|
1813
1813
|
const a = this[__private__dont__use].FS;
|
|
1814
1814
|
for (const c of t)
|
|
1815
1815
|
c && c !== "/request" && copyMEMFSNodes(e, a, c);
|
|
@@ -1844,11 +1844,11 @@ class PHP {
|
|
|
1844
1844
|
try {
|
|
1845
1845
|
await t();
|
|
1846
1846
|
} finally {
|
|
1847
|
-
delete
|
|
1847
|
+
delete d(this, T)[r];
|
|
1848
1848
|
}
|
|
1849
1849
|
}
|
|
1850
1850
|
};
|
|
1851
|
-
return
|
|
1851
|
+
return d(this, T)[r] = s, () => s.unmount();
|
|
1852
1852
|
}
|
|
1853
1853
|
/**
|
|
1854
1854
|
* Starts a PHP CLI session with given arguments.
|
|
@@ -1866,7 +1866,7 @@ class PHP {
|
|
|
1866
1866
|
async cli(r, e = {}) {
|
|
1867
1867
|
if (basename(r[0] ?? "") !== "php")
|
|
1868
1868
|
return this.subProcess(r, e);
|
|
1869
|
-
|
|
1869
|
+
d(this, R) && (d(this, _).needsRotating = !0);
|
|
1870
1870
|
const t = await this.semaphore.acquire();
|
|
1871
1871
|
return await m(this, f, G).call(this, () => {
|
|
1872
1872
|
const s = e.env || {};
|
|
@@ -1884,7 +1884,7 @@ class PHP {
|
|
|
1884
1884
|
async: !0
|
|
1885
1885
|
});
|
|
1886
1886
|
}).then((s) => (s.exitCode.finally(t), s)).finally(() => {
|
|
1887
|
-
|
|
1887
|
+
d(this, _).needsRotating = !0;
|
|
1888
1888
|
});
|
|
1889
1889
|
}
|
|
1890
1890
|
/**
|
|
@@ -1981,7 +1981,7 @@ I = new WeakMap(), R = new WeakMap(), H = new WeakMap(), F = new WeakMap(), b =
|
|
|
1981
1981
|
* was provided.
|
|
1982
1982
|
* @returns Computed $_SERVER entries.
|
|
1983
1983
|
*/
|
|
1984
|
-
|
|
1984
|
+
Y = function(r, e, t) {
|
|
1985
1985
|
const s = {
|
|
1986
1986
|
...r || {}
|
|
1987
1987
|
};
|
|
@@ -2095,25 +2095,25 @@ J = function(r, e, t) {
|
|
|
2095
2095
|
[r, e]
|
|
2096
2096
|
);
|
|
2097
2097
|
}, G = async function(r) {
|
|
2098
|
-
|
|
2098
|
+
d(this, _).enabled && d(this, _).needsRotating && await this.rotateRuntime(), ++d(this, _).requestsMade, d(this, _).requestsMade >= d(this, _).maxRequests && (d(this, _).needsRotating = !0);
|
|
2099
2099
|
const e = this[__private__dont__use], t = await createInvertedReadableStream();
|
|
2100
|
-
e.onHeaders = (
|
|
2101
|
-
a || s || t.controller.enqueue(
|
|
2100
|
+
e.onHeaders = (h) => {
|
|
2101
|
+
a || s || t.controller.enqueue(h.slice());
|
|
2102
2102
|
};
|
|
2103
2103
|
let s = !1;
|
|
2104
2104
|
const n = () => {
|
|
2105
2105
|
s || (s = !0, t.controller.close());
|
|
2106
2106
|
}, i = await createInvertedReadableStream();
|
|
2107
|
-
e.onStdout = (
|
|
2108
|
-
n(), !a && i.controller.enqueue(
|
|
2107
|
+
e.onStdout = (h) => {
|
|
2108
|
+
n(), !a && i.controller.enqueue(h.slice());
|
|
2109
2109
|
};
|
|
2110
2110
|
const o = await createInvertedReadableStream();
|
|
2111
|
-
e.onStderr = (
|
|
2112
|
-
a || o.controller.enqueue(
|
|
2111
|
+
e.onStderr = (h) => {
|
|
2112
|
+
a || o.controller.enqueue(h.slice());
|
|
2113
2113
|
};
|
|
2114
2114
|
let a = !1, c;
|
|
2115
2115
|
const u = (async () => {
|
|
2116
|
-
var
|
|
2116
|
+
var h;
|
|
2117
2117
|
try {
|
|
2118
2118
|
return await Promise.race([
|
|
2119
2119
|
r(),
|
|
@@ -2121,7 +2121,7 @@ J = function(r, e, t) {
|
|
|
2121
2121
|
var $;
|
|
2122
2122
|
c = (N) => {
|
|
2123
2123
|
isExitCode(N.error) || S(N.error);
|
|
2124
|
-
}, ($ =
|
|
2124
|
+
}, ($ = d(this, H)) == null || $.addEventListener(
|
|
2125
2125
|
"error",
|
|
2126
2126
|
c,
|
|
2127
2127
|
{ once: !0 }
|
|
@@ -2140,27 +2140,27 @@ J = function(r, e, t) {
|
|
|
2140
2140
|
});
|
|
2141
2141
|
throw this.functionsMaybeMissingFromAsyncify = getFunctionsMaybeMissingFromAsyncify(), p;
|
|
2142
2142
|
} finally {
|
|
2143
|
-
a || (safeStreamClose$1(i.controller), safeStreamClose$1(o.controller), n(), a = !0), (
|
|
2143
|
+
a || (safeStreamClose$1(i.controller), safeStreamClose$1(o.controller), n(), a = !0), (h = d(this, H)) == null || h.removeEventListener(
|
|
2144
2144
|
"error",
|
|
2145
2145
|
c
|
|
2146
2146
|
);
|
|
2147
2147
|
}
|
|
2148
2148
|
})().then(
|
|
2149
|
-
(
|
|
2149
|
+
(h) => (h !== 0 && this.dispatchEvent({
|
|
2150
2150
|
type: "request.error",
|
|
2151
2151
|
error: new Error(
|
|
2152
|
-
`PHP.run() failed with exit code ${
|
|
2152
|
+
`PHP.run() failed with exit code ${h}.`
|
|
2153
2153
|
),
|
|
2154
2154
|
// Distinguish between PHP request and PHP-wasm errors
|
|
2155
2155
|
source: "php-wasm"
|
|
2156
|
-
}),
|
|
2157
|
-
(
|
|
2158
|
-
const p =
|
|
2156
|
+
}), h),
|
|
2157
|
+
(h) => {
|
|
2158
|
+
const p = h.source ?? "php-wasm";
|
|
2159
2159
|
throw this.dispatchEvent({
|
|
2160
2160
|
type: "request.error",
|
|
2161
|
-
error:
|
|
2161
|
+
error: h,
|
|
2162
2162
|
source: p
|
|
2163
|
-
}),
|
|
2163
|
+
}), h;
|
|
2164
2164
|
}
|
|
2165
2165
|
);
|
|
2166
2166
|
return new StreamedPHPResponse(
|
|
@@ -2698,11 +2698,11 @@ class PHPRequestHandler {
|
|
|
2698
2698
|
else if (e.phpFactory)
|
|
2699
2699
|
this.instanceManager = new PHPProcessManager({
|
|
2700
2700
|
phpFactory: async (u) => {
|
|
2701
|
-
const
|
|
2701
|
+
const h = await e.phpFactory({
|
|
2702
2702
|
...u,
|
|
2703
2703
|
requestHandler: this
|
|
2704
2704
|
});
|
|
2705
|
-
return a(
|
|
2705
|
+
return a(h), h;
|
|
2706
2706
|
},
|
|
2707
2707
|
maxPhpInstances: e.maxPhpInstances
|
|
2708
2708
|
});
|
|
@@ -2713,14 +2713,14 @@ class PHPRequestHandler {
|
|
|
2713
2713
|
w(this, k, e.cookieStore === void 0 ? new HttpCookieStore() : e.cookieStore), w(this, x, t);
|
|
2714
2714
|
const c = new URL(s);
|
|
2715
2715
|
w(this, j, c.hostname), w(this, L, c.port ? Number(c.port) : c.protocol === "https:" ? 443 : 80), w(this, C, (c.protocol || "").replace(":", ""));
|
|
2716
|
-
const l =
|
|
2716
|
+
const l = d(this, L) !== 443 && d(this, L) !== 80;
|
|
2717
2717
|
w(this, M, [
|
|
2718
|
-
|
|
2719
|
-
l ? `:${
|
|
2718
|
+
d(this, j),
|
|
2719
|
+
l ? `:${d(this, L)}` : ""
|
|
2720
2720
|
].join("")), w(this, E, c.pathname.replace(/\/+$/, "")), w(this, A, [
|
|
2721
|
-
`${
|
|
2722
|
-
|
|
2723
|
-
|
|
2721
|
+
`${d(this, C)}://`,
|
|
2722
|
+
d(this, M),
|
|
2723
|
+
d(this, E)
|
|
2724
2724
|
].join("")), this.rewriteRules = n, w(this, D, i), this.getFileNotFoundAction = o;
|
|
2725
2725
|
}
|
|
2726
2726
|
async getPrimaryPhp() {
|
|
@@ -2745,20 +2745,20 @@ class PHPRequestHandler {
|
|
|
2745
2745
|
*/
|
|
2746
2746
|
internalUrlToPath(e) {
|
|
2747
2747
|
const t = new URL(e, "https://playground.internal");
|
|
2748
|
-
return t.pathname.startsWith(
|
|
2748
|
+
return t.pathname.startsWith(d(this, E)) && (t.pathname = t.pathname.slice(d(this, E).length)), toRelativeUrl(t);
|
|
2749
2749
|
}
|
|
2750
2750
|
/**
|
|
2751
2751
|
* The absolute URL of this PHPRequestHandler instance.
|
|
2752
2752
|
*/
|
|
2753
2753
|
get absoluteUrl() {
|
|
2754
|
-
return
|
|
2754
|
+
return d(this, A);
|
|
2755
2755
|
}
|
|
2756
2756
|
/**
|
|
2757
2757
|
* The directory in the PHP filesystem where the server will look
|
|
2758
2758
|
* for the files to serve. Default: `/var/www`.
|
|
2759
2759
|
*/
|
|
2760
2760
|
get documentRoot() {
|
|
2761
|
-
return
|
|
2761
|
+
return d(this, x);
|
|
2762
2762
|
}
|
|
2763
2763
|
/**
|
|
2764
2764
|
* Serves the request – either by serving a static file, or by
|
|
@@ -2840,7 +2840,7 @@ class PHPRequestHandler {
|
|
|
2840
2840
|
* before using it as a filesystem path.
|
|
2841
2841
|
*/
|
|
2842
2842
|
decodeURIComponent(n.pathname),
|
|
2843
|
-
|
|
2843
|
+
d(this, E)
|
|
2844
2844
|
);
|
|
2845
2845
|
let a = m(this, P, B).call(this, o);
|
|
2846
2846
|
if (i.isDir(a)) {
|
|
@@ -2885,7 +2885,7 @@ class PHPRequestHandler {
|
|
|
2885
2885
|
c.response
|
|
2886
2886
|
);
|
|
2887
2887
|
case "internal-redirect":
|
|
2888
|
-
a = joinPaths(
|
|
2888
|
+
a = joinPaths(d(this, x), c.uri);
|
|
2889
2889
|
break;
|
|
2890
2890
|
case "404":
|
|
2891
2891
|
return StreamedPHPResponse.forHttpCode(404);
|
|
@@ -2990,11 +2990,11 @@ class PHPRequestHandler {
|
|
|
2990
2990
|
prepare_$_SERVER_superglobal(e, t, s) {
|
|
2991
2991
|
const n = {
|
|
2992
2992
|
REMOTE_ADDR: "127.0.0.1",
|
|
2993
|
-
DOCUMENT_ROOT:
|
|
2994
|
-
HTTPS:
|
|
2993
|
+
DOCUMENT_ROOT: d(this, x),
|
|
2994
|
+
HTTPS: d(this, A).startsWith("https://") ? "on" : ""
|
|
2995
2995
|
};
|
|
2996
|
-
return n.REQUEST_URI = e.pathname + e.search, s.startsWith(
|
|
2997
|
-
|
|
2996
|
+
return n.REQUEST_URI = e.pathname + e.search, s.startsWith(d(this, x)) && (n.SCRIPT_NAME = s.substring(
|
|
2997
|
+
d(this, x).length
|
|
2998
2998
|
), n.PHP_SELF = t.pathname, n.REQUEST_URI.startsWith(n.SCRIPT_NAME) && (n.PATH_INFO = n.REQUEST_URI.substring(
|
|
2999
2999
|
n.SCRIPT_NAME.length
|
|
3000
3000
|
), n.PATH_INFO.includes("?") && (n.PATH_INFO = n.PATH_INFO.substring(
|
|
@@ -3015,12 +3015,12 @@ x = new WeakMap(), C = new WeakMap(), j = new WeakMap(), L = new WeakMap(), M =
|
|
|
3015
3015
|
ne = function(e) {
|
|
3016
3016
|
const t = removePathPrefix(
|
|
3017
3017
|
decodeURIComponent(e.pathname),
|
|
3018
|
-
|
|
3018
|
+
d(this, E)
|
|
3019
3019
|
), s = applyRewriteRules(
|
|
3020
3020
|
t,
|
|
3021
3021
|
this.rewriteRules
|
|
3022
3022
|
), n = new URL(
|
|
3023
|
-
joinPaths(
|
|
3023
|
+
joinPaths(d(this, E), s),
|
|
3024
3024
|
e.toString()
|
|
3025
3025
|
);
|
|
3026
3026
|
for (const [i, o] of e.searchParams.entries())
|
|
@@ -3036,12 +3036,12 @@ ne = function(e) {
|
|
|
3036
3036
|
* @returns The resolved filesystem path
|
|
3037
3037
|
*/
|
|
3038
3038
|
B = function(e) {
|
|
3039
|
-
for (const t of
|
|
3039
|
+
for (const t of d(this, D))
|
|
3040
3040
|
if (e === t.urlPrefix || e.startsWith(t.urlPrefix + "/")) {
|
|
3041
3041
|
const s = e.slice(t.urlPrefix.length);
|
|
3042
3042
|
return joinPaths(t.fsPath, s);
|
|
3043
3043
|
}
|
|
3044
|
-
return joinPaths(
|
|
3044
|
+
return joinPaths(d(this, x), e);
|
|
3045
3045
|
}, /**
|
|
3046
3046
|
* Serves a static file from the PHP filesystem.
|
|
3047
3047
|
*
|
|
@@ -3082,22 +3082,22 @@ ie = function(e, t) {
|
|
|
3082
3082
|
}, ae = async function(e, t, s, n, i) {
|
|
3083
3083
|
let o = "GET";
|
|
3084
3084
|
const a = {
|
|
3085
|
-
host:
|
|
3085
|
+
host: d(this, M),
|
|
3086
3086
|
...normalizeHeaders(t.headers || {})
|
|
3087
3087
|
};
|
|
3088
|
-
|
|
3088
|
+
d(this, k) && (a.cookie = d(this, k).getCookieRequestHeader());
|
|
3089
3089
|
let c = t.body;
|
|
3090
3090
|
if (typeof c == "object" && !(c instanceof Uint8Array)) {
|
|
3091
3091
|
o = "POST";
|
|
3092
|
-
const { bytes: u, contentType:
|
|
3093
|
-
c = u, a["content-type"] =
|
|
3092
|
+
const { bytes: u, contentType: h } = await encodeAsMultipart(c);
|
|
3093
|
+
c = u, a["content-type"] = h;
|
|
3094
3094
|
}
|
|
3095
3095
|
const l = await e.runStream({
|
|
3096
3096
|
relativeUri: ensurePathPrefix(
|
|
3097
3097
|
toRelativeUrl(new URL(n.toString())),
|
|
3098
|
-
|
|
3098
|
+
d(this, E)
|
|
3099
3099
|
),
|
|
3100
|
-
protocol:
|
|
3100
|
+
protocol: d(this, C),
|
|
3101
3101
|
method: t.method || o,
|
|
3102
3102
|
$_SERVER: this.prepare_$_SERVER_superglobal(
|
|
3103
3103
|
s,
|
|
@@ -3108,9 +3108,9 @@ ie = function(e, t) {
|
|
|
3108
3108
|
scriptPath: i,
|
|
3109
3109
|
headers: a
|
|
3110
3110
|
});
|
|
3111
|
-
if (
|
|
3111
|
+
if (d(this, k)) {
|
|
3112
3112
|
const u = await l.headers;
|
|
3113
|
-
|
|
3113
|
+
d(this, k).rememberCookiesFromResponseHeaders(
|
|
3114
3114
|
u
|
|
3115
3115
|
);
|
|
3116
3116
|
}
|
|
@@ -3229,17 +3229,17 @@ function installPHPExtensionFilesSync(r, e) {
|
|
|
3229
3229
|
async function resolvePHPExtensionSource(r, e) {
|
|
3230
3230
|
const t = r.source;
|
|
3231
3231
|
if (t.format === "so") {
|
|
3232
|
-
const
|
|
3233
|
-
if (!
|
|
3232
|
+
const h = r.name ?? t.name;
|
|
3233
|
+
if (!h)
|
|
3234
3234
|
throw new Error(
|
|
3235
3235
|
"name is required when loading an extension from direct bytes."
|
|
3236
3236
|
);
|
|
3237
|
-
return t.sha256 && await assertSha256(t.bytes, t.sha256,
|
|
3237
|
+
return t.sha256 && await assertSha256(t.bytes, t.sha256, h), { name: h, soBytes: toUint8Array(t.bytes) };
|
|
3238
3238
|
}
|
|
3239
3239
|
if (t.format === "url") {
|
|
3240
|
-
let
|
|
3240
|
+
let h;
|
|
3241
3241
|
try {
|
|
3242
|
-
|
|
3242
|
+
h = new URL(String(t.url));
|
|
3243
3243
|
} catch {
|
|
3244
3244
|
throw new Error(
|
|
3245
3245
|
`source.url must be an absolute URL when loading a PHP extension from a direct URL. Received: ${String(
|
|
@@ -3248,7 +3248,7 @@ async function resolvePHPExtensionSource(r, e) {
|
|
|
3248
3248
|
);
|
|
3249
3249
|
}
|
|
3250
3250
|
const p = r.name ?? t.name ?? (() => {
|
|
3251
|
-
const N =
|
|
3251
|
+
const N = h.pathname.split("/").pop() ?? "";
|
|
3252
3252
|
return N.endsWith(".so") ? N.slice(0, -3) : void 0;
|
|
3253
3253
|
})();
|
|
3254
3254
|
if (!p)
|
|
@@ -3259,13 +3259,13 @@ async function resolvePHPExtensionSource(r, e) {
|
|
|
3259
3259
|
throw new Error(
|
|
3260
3260
|
"resolvePHPExtension() requires a fetch implementation."
|
|
3261
3261
|
);
|
|
3262
|
-
const g = await e(
|
|
3262
|
+
const g = await e(h);
|
|
3263
3263
|
if (!g.ok)
|
|
3264
3264
|
throw new Error(
|
|
3265
|
-
`Failed to fetch ${String(
|
|
3265
|
+
`Failed to fetch ${String(h)}: ${g.status}`
|
|
3266
3266
|
);
|
|
3267
3267
|
const S = new Uint8Array(await g.arrayBuffer());
|
|
3268
|
-
return t.sha256 && await assertSha256(S, t.sha256, String(
|
|
3268
|
+
return t.sha256 && await assertSha256(S, t.sha256, String(h)), { name: p, soBytes: S };
|
|
3269
3269
|
}
|
|
3270
3270
|
const s = "manifestUrl" in t ? new URL(String(t.manifestUrl)) : void 0;
|
|
3271
3271
|
let n;
|
|
@@ -3276,12 +3276,12 @@ async function resolvePHPExtensionSource(r, e) {
|
|
|
3276
3276
|
throw new Error(
|
|
3277
3277
|
"resolvePHPExtension() requires a fetch implementation."
|
|
3278
3278
|
);
|
|
3279
|
-
const
|
|
3280
|
-
if (!
|
|
3279
|
+
const h = await e(s);
|
|
3280
|
+
if (!h.ok)
|
|
3281
3281
|
throw new Error(
|
|
3282
|
-
`Failed to fetch ${String(s)}: ${
|
|
3282
|
+
`Failed to fetch ${String(s)}: ${h.status}`
|
|
3283
3283
|
);
|
|
3284
|
-
n = await
|
|
3284
|
+
n = await h.json();
|
|
3285
3285
|
}
|
|
3286
3286
|
if (!n || typeof n != "object")
|
|
3287
3287
|
throw new Error("Extension manifest must be an object.");
|
|
@@ -3290,15 +3290,20 @@ async function resolvePHPExtensionSource(r, e) {
|
|
|
3290
3290
|
throw new Error("Extension manifest must include a name.");
|
|
3291
3291
|
if (!Array.isArray(i.artifacts))
|
|
3292
3292
|
throw new Error("Extension manifest must include an artifacts array.");
|
|
3293
|
-
for (const
|
|
3294
|
-
if (!
|
|
3293
|
+
for (const h of i.artifacts) {
|
|
3294
|
+
if (!h || typeof h.phpVersion != "string" || typeof h.file != "string")
|
|
3295
3295
|
throw new Error("Extension manifest contains an invalid artifact.");
|
|
3296
|
+
if ("asyncMode" in h)
|
|
3297
|
+
throw new Error(
|
|
3298
|
+
"Extension manifests do not use asyncMode. External PHP extensions require JSPI."
|
|
3299
|
+
);
|
|
3300
|
+
}
|
|
3296
3301
|
const o = "baseUrl" in t && t.baseUrl ? new URL(String(t.baseUrl)) : s, a = i.artifacts.find(
|
|
3297
|
-
(
|
|
3302
|
+
(h) => h.phpVersion === r.phpVersion
|
|
3298
3303
|
);
|
|
3299
3304
|
if (!a)
|
|
3300
3305
|
throw new Error(
|
|
3301
|
-
`No extension artifact found for PHP ${r.phpVersion}
|
|
3306
|
+
`No extension artifact found for PHP ${r.phpVersion}.`
|
|
3302
3307
|
);
|
|
3303
3308
|
if (!o)
|
|
3304
3309
|
throw new Error(
|
|
@@ -3356,12 +3361,12 @@ function ensureProxyFSHasMmapSupport(r) {
|
|
|
3356
3361
|
const u = t.malloc(o);
|
|
3357
3362
|
if (!u)
|
|
3358
3363
|
throw new n.ErrnoError(48);
|
|
3359
|
-
const
|
|
3364
|
+
const h = t.HEAPU8.subarray(u, u + o);
|
|
3360
3365
|
let p = 0;
|
|
3361
3366
|
for (; p < o; ) {
|
|
3362
3367
|
const g = i.stream_ops.read(
|
|
3363
3368
|
i,
|
|
3364
|
-
|
|
3369
|
+
h,
|
|
3365
3370
|
p,
|
|
3366
3371
|
o - p,
|
|
3367
3372
|
p
|
|
@@ -3662,18 +3667,18 @@ function expose(r, e = globalThis, t = ["*"], s) {
|
|
|
3662
3667
|
}, l = (i.data.argumentList || []).map(fromWireValue);
|
|
3663
3668
|
let u;
|
|
3664
3669
|
try {
|
|
3665
|
-
const
|
|
3670
|
+
const h = c.slice(0, -1).reduce((g, S) => g[S], r), p = c.reduce((g, S) => g[S], r);
|
|
3666
3671
|
switch (a) {
|
|
3667
3672
|
case MessageType.GET:
|
|
3668
3673
|
u = p;
|
|
3669
3674
|
break;
|
|
3670
3675
|
case MessageType.SET:
|
|
3671
|
-
|
|
3676
|
+
h[c.slice(-1)[0]] = fromWireValue(
|
|
3672
3677
|
i.data.value
|
|
3673
3678
|
), u = !0;
|
|
3674
3679
|
break;
|
|
3675
3680
|
case MessageType.APPLY:
|
|
3676
|
-
u = p.apply(
|
|
3681
|
+
u = p.apply(h, l);
|
|
3677
3682
|
break;
|
|
3678
3683
|
case MessageType.CONSTRUCT:
|
|
3679
3684
|
{
|
|
@@ -3693,18 +3698,18 @@ function expose(r, e = globalThis, t = ["*"], s) {
|
|
|
3693
3698
|
default:
|
|
3694
3699
|
return;
|
|
3695
3700
|
}
|
|
3696
|
-
} catch (
|
|
3697
|
-
u = { value:
|
|
3701
|
+
} catch (h) {
|
|
3702
|
+
u = { value: h, [throwMarker]: 0 };
|
|
3698
3703
|
}
|
|
3699
|
-
Promise.resolve(u).catch((
|
|
3700
|
-
const [p, g] = toWireValue(
|
|
3704
|
+
Promise.resolve(u).catch((h) => ({ value: h, [throwMarker]: 0 })).then((h) => {
|
|
3705
|
+
const [p, g] = toWireValue(h);
|
|
3701
3706
|
e.postMessage({ ...p, id: o }, g), a === MessageType.RELEASE && (e.removeEventListener("message", n), closeEndPoint(e), finalizer in r && typeof r[finalizer] == "function" && r[finalizer]());
|
|
3702
3707
|
}).catch(() => {
|
|
3703
|
-
const [
|
|
3708
|
+
const [h, p] = toWireValue({
|
|
3704
3709
|
value: new TypeError("Unserializable return value"),
|
|
3705
3710
|
[throwMarker]: 0
|
|
3706
3711
|
});
|
|
3707
|
-
e.postMessage({ ...
|
|
3712
|
+
e.postMessage({ ...h, id: o }, p);
|
|
3708
3713
|
}).finally(() => {
|
|
3709
3714
|
s == null || s(i);
|
|
3710
3715
|
});
|
|
@@ -3781,7 +3786,7 @@ function createProxy(r, e, t = [], s = function() {
|
|
|
3781
3786
|
e,
|
|
3782
3787
|
{
|
|
3783
3788
|
type: MessageType.SET,
|
|
3784
|
-
path: [...t, a].map((
|
|
3789
|
+
path: [...t, a].map((h) => h.toString()),
|
|
3785
3790
|
value: l
|
|
3786
3791
|
},
|
|
3787
3792
|
u
|
|
@@ -3796,7 +3801,7 @@ function createProxy(r, e, t = [], s = function() {
|
|
|
3796
3801
|
}).then(fromWireValue);
|
|
3797
3802
|
if (l === "bind")
|
|
3798
3803
|
return createProxy(r, e, t.slice(0, -1));
|
|
3799
|
-
const [u,
|
|
3804
|
+
const [u, h] = processArguments(c);
|
|
3800
3805
|
return requestResponseMessage(
|
|
3801
3806
|
r,
|
|
3802
3807
|
e,
|
|
@@ -3805,7 +3810,7 @@ function createProxy(r, e, t = [], s = function() {
|
|
|
3805
3810
|
path: t.map((p) => p.toString()),
|
|
3806
3811
|
argumentList: u
|
|
3807
3812
|
},
|
|
3808
|
-
|
|
3813
|
+
h
|
|
3809
3814
|
).then(fromWireValue);
|
|
3810
3815
|
},
|
|
3811
3816
|
construct(o, a) {
|
|
@@ -4990,8 +4995,8 @@ function createObjectPoolProxy(r) {
|
|
|
4990
4995
|
function i(o) {
|
|
4991
4996
|
return s().then((a) => {
|
|
4992
4997
|
const c = (u) => {
|
|
4993
|
-
const
|
|
4994
|
-
return
|
|
4998
|
+
const h = u == null ? void 0 : u.finished;
|
|
4999
|
+
return h && typeof h.then == "function" ? Promise.resolve(h).then(
|
|
4995
5000
|
() => n(a),
|
|
4996
5001
|
() => n(a)
|
|
4997
5002
|
) : n(a), u;
|
|
@@ -5018,13 +5023,13 @@ function createObjectPoolProxy(r) {
|
|
|
5018
5023
|
return new Proxy(function() {
|
|
5019
5024
|
}, {
|
|
5020
5025
|
apply(c, l, u) {
|
|
5021
|
-
return i((
|
|
5026
|
+
return i((h) => h[a](...u));
|
|
5022
5027
|
},
|
|
5023
5028
|
get(c, l) {
|
|
5024
5029
|
if (l === "then")
|
|
5025
|
-
return (u,
|
|
5030
|
+
return (u, h) => i((p) => p[a]).then(
|
|
5026
5031
|
u,
|
|
5027
|
-
|
|
5032
|
+
h
|
|
5028
5033
|
);
|
|
5029
5034
|
}
|
|
5030
5035
|
});
|