@php-wasm/universal 3.1.2 → 3.1.4
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.cjs +6 -6
- package/index.cjs.map +1 -1
- package/index.js +149 -89
- package/index.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/php.d.ts +10 -2
- package/lib/process-id-allocator.d.ts +9 -0
- package/package.json +7 -7
package/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
var G = (r) => {
|
|
2
2
|
throw TypeError(r);
|
|
3
3
|
};
|
|
4
|
-
var
|
|
5
|
-
var u = (r, e, t) => (
|
|
4
|
+
var D = (r, e, t) => e.has(r) || G("Cannot " + t);
|
|
5
|
+
var u = (r, e, t) => (D(r, e, "read from private field"), t ? t.call(r) : e.get(r)), y = (r, e, t) => e.has(r) ? G("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(r) : e.set(r, t), g = (r, e, t, s) => (D(r, e, "write to private field"), s ? s.call(r, t) : e.set(r, t), t), m = (r, e, t) => (D(r, e, "access private method"), t);
|
|
6
6
|
import "@php-wasm/node-polyfills";
|
|
7
7
|
import { logger } from "@php-wasm/logger";
|
|
8
8
|
import { dirname, joinPaths, Semaphore, createSpawnHandler, basename, normalizePath, AcquireTimeoutError, splitShellCommand } from "@php-wasm/util";
|
|
@@ -311,19 +311,31 @@ class FSHelpers {
|
|
|
311
311
|
e.mkdirTree(t);
|
|
312
312
|
}
|
|
313
313
|
static copyRecursive(e, t, s) {
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
e.
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
e,
|
|
323
|
-
joinPaths(t, o),
|
|
324
|
-
joinPaths(s, o)
|
|
314
|
+
try {
|
|
315
|
+
const n = e.lookupPath(t).node;
|
|
316
|
+
if (e.isDir(n.mode)) {
|
|
317
|
+
if (t === s || s.startsWith(`${t}/`))
|
|
318
|
+
throw new ErrnoError(28);
|
|
319
|
+
e.mkdirTree(s);
|
|
320
|
+
const i = e.readdir(t).filter(
|
|
321
|
+
(o) => o !== "." && o !== ".."
|
|
325
322
|
);
|
|
326
|
-
|
|
323
|
+
for (const o of i)
|
|
324
|
+
FSHelpers.copyRecursive(
|
|
325
|
+
e,
|
|
326
|
+
joinPaths(t, o),
|
|
327
|
+
joinPaths(s, o)
|
|
328
|
+
);
|
|
329
|
+
} else e.isLink(n.mode) ? e.symlink(e.readlink(t), s) : e.writeFile(s, e.readFile(t));
|
|
330
|
+
} catch (n) {
|
|
331
|
+
const i = getEmscriptenFsError(n);
|
|
332
|
+
throw i ? new Error(
|
|
333
|
+
`Could not copy ${t} to ${s}: ${i}`,
|
|
334
|
+
{
|
|
335
|
+
cause: n
|
|
336
|
+
}
|
|
337
|
+
) : n;
|
|
338
|
+
}
|
|
327
339
|
}
|
|
328
340
|
}
|
|
329
341
|
FSHelpers.readFileAsText = rethrowFileSystemError('Could not read "{path}"')(
|
|
@@ -359,9 +371,6 @@ FSHelpers.fileExists = rethrowFileSystemError('Could not stat "{path}"')(
|
|
|
359
371
|
FSHelpers.mkdir = rethrowFileSystemError('Could not create directory "{path}"')(
|
|
360
372
|
FSHelpers.mkdir
|
|
361
373
|
);
|
|
362
|
-
FSHelpers.copyRecursive = rethrowFileSystemError(
|
|
363
|
-
'Could not copy files from "{path}"'
|
|
364
|
-
)(FSHelpers.copyRecursive);
|
|
365
374
|
const _private = /* @__PURE__ */ new WeakMap();
|
|
366
375
|
var x;
|
|
367
376
|
class PHPWorker {
|
|
@@ -637,7 +646,7 @@ const currentJsRuntime = function() {
|
|
|
637
646
|
200: "OK"
|
|
638
647
|
};
|
|
639
648
|
var C;
|
|
640
|
-
const
|
|
649
|
+
const j = class j {
|
|
641
650
|
constructor(e, t, s, n) {
|
|
642
651
|
/**
|
|
643
652
|
* Response headers stream (internal).
|
|
@@ -651,30 +660,43 @@ const D = class D {
|
|
|
651
660
|
*/
|
|
652
661
|
static fromPHPResponse(e) {
|
|
653
662
|
const t = new ReadableStream({
|
|
654
|
-
start(
|
|
655
|
-
|
|
663
|
+
start(c) {
|
|
664
|
+
c.enqueue(e.bytes), c.close();
|
|
665
|
+
}
|
|
666
|
+
}), s = [];
|
|
667
|
+
for (const [c, l] of Object.entries(e.headers))
|
|
668
|
+
for (const d of l)
|
|
669
|
+
s.push(`${c}: ${d}`);
|
|
670
|
+
const n = JSON.stringify({
|
|
671
|
+
status: e.httpStatusCode,
|
|
672
|
+
headers: s
|
|
673
|
+
}), i = new ReadableStream({
|
|
674
|
+
start(c) {
|
|
675
|
+
c.enqueue(new TextEncoder().encode(n)), c.close();
|
|
656
676
|
}
|
|
657
|
-
}),
|
|
658
|
-
start(
|
|
659
|
-
|
|
677
|
+
}), o = new ReadableStream({
|
|
678
|
+
start(c) {
|
|
679
|
+
e.errors.length > 0 && c.enqueue(
|
|
680
|
+
new TextEncoder().encode(e.errors)
|
|
681
|
+
), c.close();
|
|
660
682
|
}
|
|
661
|
-
}),
|
|
662
|
-
|
|
683
|
+
}), a = new j(
|
|
684
|
+
i,
|
|
663
685
|
t,
|
|
664
|
-
|
|
686
|
+
o,
|
|
665
687
|
Promise.resolve(e.exitCode)
|
|
666
688
|
);
|
|
667
|
-
return
|
|
689
|
+
return a.parsedHeaders = Promise.resolve({
|
|
668
690
|
headers: e.headers,
|
|
669
691
|
httpStatusCode: e.httpStatusCode
|
|
670
|
-
}),
|
|
692
|
+
}), a;
|
|
671
693
|
}
|
|
672
694
|
/**
|
|
673
695
|
* Creates a StreamedPHPResponse for a given HTTP status code.
|
|
674
696
|
* Shorthand for `StreamedPHPResponse.fromPHPResponse(PHPResponse.forHttpCode(...))`.
|
|
675
697
|
*/
|
|
676
698
|
static forHttpCode(e, t = "") {
|
|
677
|
-
return
|
|
699
|
+
return j.fromPHPResponse(
|
|
678
700
|
PHPResponse.forHttpCode(e, t)
|
|
679
701
|
);
|
|
680
702
|
}
|
|
@@ -747,7 +769,7 @@ const D = class D {
|
|
|
747
769
|
}
|
|
748
770
|
};
|
|
749
771
|
C = new WeakMap();
|
|
750
|
-
let StreamedPHPResponse =
|
|
772
|
+
let StreamedPHPResponse = j;
|
|
751
773
|
async function parseHeadersStream(r) {
|
|
752
774
|
const e = await streamToText(r);
|
|
753
775
|
let t;
|
|
@@ -1021,7 +1043,7 @@ class PHPExecutionFailureError extends Error {
|
|
|
1021
1043
|
}
|
|
1022
1044
|
}
|
|
1023
1045
|
const PHP_INI_PATH = "/internal/shared/php.ini", AUTO_PREPEND_SCRIPT = "/internal/shared/auto_prepend_file.php", OPCACHE_FILE_FOLDER = "/internal/shared/opcache";
|
|
1024
|
-
var M, R, b, S, H, T, w,
|
|
1046
|
+
var M, R, b, S, H, T, w, p, J, Y, X, Q, K, Z, ee, te, W, re, q, $;
|
|
1025
1047
|
class PHP {
|
|
1026
1048
|
/**
|
|
1027
1049
|
* Initializes a PHP runtime.
|
|
@@ -1031,7 +1053,7 @@ class PHP {
|
|
|
1031
1053
|
* @param requestHandlerOptions - Optional. Options for the PHPRequestHandler. If undefined, no request handler will be initialized.
|
|
1032
1054
|
*/
|
|
1033
1055
|
constructor(r) {
|
|
1034
|
-
y(this,
|
|
1056
|
+
y(this, p);
|
|
1035
1057
|
y(this, M);
|
|
1036
1058
|
y(this, R, !1);
|
|
1037
1059
|
y(this, b, null);
|
|
@@ -1456,7 +1478,7 @@ class PHP {
|
|
|
1456
1478
|
async runStream(r) {
|
|
1457
1479
|
const e = await this.semaphore.acquire();
|
|
1458
1480
|
let t;
|
|
1459
|
-
const s = m(this,
|
|
1481
|
+
const s = m(this, p, $).call(this, async () => {
|
|
1460
1482
|
if (u(this, R) || (await this[__private__dont__use].ccall(
|
|
1461
1483
|
"php_wasm_init",
|
|
1462
1484
|
null,
|
|
@@ -1469,22 +1491,22 @@ class PHP {
|
|
|
1469
1491
|
throw new Error(
|
|
1470
1492
|
`The script path "${r.scriptPath}" does not exist.`
|
|
1471
1493
|
);
|
|
1472
|
-
m(this,
|
|
1473
|
-
const i = normalizeHeaders(r.headers || {}), o = i.host || "example.com:443", a = m(this,
|
|
1474
|
-
if (m(this,
|
|
1475
|
-
this.writeFile("/internal/eval.php", r.code), m(this,
|
|
1494
|
+
m(this, p, Y).call(this, r.relativeUri || ""), m(this, p, Z).call(this, r.method || "GET");
|
|
1495
|
+
const i = normalizeHeaders(r.headers || {}), o = i.host || "example.com:443", a = m(this, p, K).call(this, o, r.protocol || "http");
|
|
1496
|
+
if (m(this, p, X).call(this, o), m(this, p, Q).call(this, a), m(this, p, ee).call(this, i), r.body && (t = m(this, p, te).call(this, r.body)), typeof r.code == "string")
|
|
1497
|
+
this.writeFile("/internal/eval.php", r.code), m(this, p, W).call(this, "/internal/eval.php");
|
|
1476
1498
|
else if (typeof r.scriptPath == "string")
|
|
1477
|
-
m(this,
|
|
1499
|
+
m(this, p, W).call(this, r.scriptPath || "");
|
|
1478
1500
|
else
|
|
1479
1501
|
throw new TypeError(
|
|
1480
1502
|
"The request object must have either a `code` or a `scriptPath` property."
|
|
1481
1503
|
);
|
|
1482
|
-
const c = m(this,
|
|
1504
|
+
const c = m(this, p, J).call(this, r.$_SERVER, i, a);
|
|
1483
1505
|
for (const d in c)
|
|
1484
|
-
m(this,
|
|
1506
|
+
m(this, p, re).call(this, d, c[d]);
|
|
1485
1507
|
const l = r.env || {};
|
|
1486
1508
|
for (const d in l)
|
|
1487
|
-
m(this,
|
|
1509
|
+
m(this, p, q).call(this, d, l[d]);
|
|
1488
1510
|
return await this[__private__dont__use].ccall(
|
|
1489
1511
|
"wasm_sapi_handle_request",
|
|
1490
1512
|
NUMBER,
|
|
@@ -1602,8 +1624,8 @@ class PHP {
|
|
|
1602
1624
|
* Moves a file or directory in the PHP filesystem to a
|
|
1603
1625
|
* new location.
|
|
1604
1626
|
*
|
|
1605
|
-
* @param
|
|
1606
|
-
* @param
|
|
1627
|
+
* @param fromPath The path to rename.
|
|
1628
|
+
* @param toPath The new path.
|
|
1607
1629
|
*/
|
|
1608
1630
|
mv(r, e) {
|
|
1609
1631
|
const t = FSHelpers.mv(
|
|
@@ -1613,6 +1635,21 @@ class PHP {
|
|
|
1613
1635
|
);
|
|
1614
1636
|
return this.dispatchEvent({ type: "filesystem.write" }), t;
|
|
1615
1637
|
}
|
|
1638
|
+
/**
|
|
1639
|
+
* Copies a file or directory in the PHP filesystem to a
|
|
1640
|
+
* new location.
|
|
1641
|
+
*
|
|
1642
|
+
* @param fromPath The source path.
|
|
1643
|
+
* @param toPath The target path.
|
|
1644
|
+
*/
|
|
1645
|
+
cp(r, e) {
|
|
1646
|
+
const t = FSHelpers.copyRecursive(
|
|
1647
|
+
this[__private__dont__use].FS,
|
|
1648
|
+
r,
|
|
1649
|
+
e
|
|
1650
|
+
);
|
|
1651
|
+
return this.dispatchEvent({ type: "filesystem.write" }), t;
|
|
1652
|
+
}
|
|
1616
1653
|
/**
|
|
1617
1654
|
* Removes a directory from the PHP filesystem.
|
|
1618
1655
|
*
|
|
@@ -1803,10 +1840,10 @@ class PHP {
|
|
|
1803
1840
|
return this.subProcess(r, e);
|
|
1804
1841
|
u(this, R) && (u(this, w).needsRotating = !0);
|
|
1805
1842
|
const t = await this.semaphore.acquire();
|
|
1806
|
-
return await m(this,
|
|
1843
|
+
return await m(this, p, $).call(this, () => {
|
|
1807
1844
|
const s = e.env || {};
|
|
1808
1845
|
for (const [n, i] of Object.entries(s))
|
|
1809
|
-
m(this,
|
|
1846
|
+
m(this, p, q).call(this, n, i);
|
|
1810
1847
|
r = [r[0], "-c", PHP_INI_PATH, ...r.slice(1)];
|
|
1811
1848
|
for (const n of r)
|
|
1812
1849
|
this[__private__dont__use].ccall(
|
|
@@ -1897,7 +1934,7 @@ class PHP {
|
|
|
1897
1934
|
this.exit(0);
|
|
1898
1935
|
}
|
|
1899
1936
|
}
|
|
1900
|
-
M = new WeakMap(), R = new WeakMap(), b = new WeakMap(), S = new WeakMap(), H = new WeakMap(), T = new WeakMap(), w = new WeakMap(),
|
|
1937
|
+
M = new WeakMap(), R = new WeakMap(), b = new WeakMap(), S = new WeakMap(), H = new WeakMap(), T = new WeakMap(), w = new WeakMap(), p = new WeakSet(), /**
|
|
1901
1938
|
* Prepares the $_SERVER entries for the PHP runtime.
|
|
1902
1939
|
*
|
|
1903
1940
|
* @param defaults Default entries to include in $_SERVER.
|
|
@@ -1998,7 +2035,7 @@ J = function(r, e, t) {
|
|
|
1998
2035
|
[NUMBER],
|
|
1999
2036
|
[t]
|
|
2000
2037
|
), s;
|
|
2001
|
-
},
|
|
2038
|
+
}, W = function(r) {
|
|
2002
2039
|
this[__private__dont__use].ccall(
|
|
2003
2040
|
"wasm_set_path_translated",
|
|
2004
2041
|
null,
|
|
@@ -2019,34 +2056,34 @@ J = function(r, e, t) {
|
|
|
2019
2056
|
[STRING, STRING],
|
|
2020
2057
|
[r, e]
|
|
2021
2058
|
);
|
|
2022
|
-
},
|
|
2059
|
+
}, $ = async function(r) {
|
|
2023
2060
|
u(this, w).enabled && u(this, w).needsRotating && await this.rotateRuntime(), ++u(this, w).requestsMade, u(this, w).requestsMade >= u(this, w).maxRequests && (u(this, w).needsRotating = !0);
|
|
2024
2061
|
const e = this[__private__dont__use], t = await createInvertedReadableStream();
|
|
2025
|
-
e.onHeaders = (
|
|
2026
|
-
a || s || t.controller.enqueue(
|
|
2062
|
+
e.onHeaders = (h) => {
|
|
2063
|
+
a || s || t.controller.enqueue(h.slice());
|
|
2027
2064
|
};
|
|
2028
2065
|
let s = !1;
|
|
2029
2066
|
const n = () => {
|
|
2030
2067
|
s || (s = !0, t.controller.close());
|
|
2031
2068
|
}, i = await createInvertedReadableStream();
|
|
2032
|
-
e.onStdout = (
|
|
2033
|
-
n(), !a && i.controller.enqueue(
|
|
2069
|
+
e.onStdout = (h) => {
|
|
2070
|
+
n(), !a && i.controller.enqueue(h.slice());
|
|
2034
2071
|
};
|
|
2035
2072
|
const o = await createInvertedReadableStream();
|
|
2036
|
-
e.onStderr = (
|
|
2037
|
-
a || o.controller.enqueue(
|
|
2073
|
+
e.onStderr = (h) => {
|
|
2074
|
+
a || o.controller.enqueue(h.slice());
|
|
2038
2075
|
};
|
|
2039
2076
|
let a = !1, c;
|
|
2040
2077
|
const d = (async () => {
|
|
2041
|
-
var
|
|
2078
|
+
var h;
|
|
2042
2079
|
try {
|
|
2043
2080
|
return await Promise.race([
|
|
2044
2081
|
r(),
|
|
2045
2082
|
new Promise((_, F) => {
|
|
2046
|
-
var
|
|
2083
|
+
var z;
|
|
2047
2084
|
c = (V) => {
|
|
2048
2085
|
isExitCode(V.error) || F(V.error);
|
|
2049
|
-
}, (
|
|
2086
|
+
}, (z = u(this, b)) == null || z.addEventListener(
|
|
2050
2087
|
"error",
|
|
2051
2088
|
c,
|
|
2052
2089
|
{ once: !0 }
|
|
@@ -2065,27 +2102,27 @@ J = function(r, e, t) {
|
|
|
2065
2102
|
});
|
|
2066
2103
|
throw this.functionsMaybeMissingFromAsyncify = getFunctionsMaybeMissingFromAsyncify(), f;
|
|
2067
2104
|
} finally {
|
|
2068
|
-
a || (i.controller.close(), o.controller.close(), n(), a = !0), (
|
|
2105
|
+
a || (i.controller.close(), o.controller.close(), n(), a = !0), (h = u(this, b)) == null || h.removeEventListener(
|
|
2069
2106
|
"error",
|
|
2070
2107
|
c
|
|
2071
2108
|
);
|
|
2072
2109
|
}
|
|
2073
2110
|
})().then(
|
|
2074
|
-
(
|
|
2111
|
+
(h) => (h !== 0 && this.dispatchEvent({
|
|
2075
2112
|
type: "request.error",
|
|
2076
2113
|
error: new Error(
|
|
2077
|
-
`PHP.run() failed with exit code ${
|
|
2114
|
+
`PHP.run() failed with exit code ${h}.`
|
|
2078
2115
|
),
|
|
2079
2116
|
// Distinguish between PHP request and PHP-wasm errors
|
|
2080
2117
|
source: "php-wasm"
|
|
2081
|
-
}),
|
|
2082
|
-
(
|
|
2083
|
-
const f =
|
|
2118
|
+
}), h),
|
|
2119
|
+
(h) => {
|
|
2120
|
+
const f = h.source ?? "php-wasm";
|
|
2084
2121
|
throw this.dispatchEvent({
|
|
2085
2122
|
type: "request.error",
|
|
2086
|
-
error:
|
|
2123
|
+
error: h,
|
|
2087
2124
|
source: f
|
|
2088
|
-
}),
|
|
2125
|
+
}), h;
|
|
2089
2126
|
}
|
|
2090
2127
|
);
|
|
2091
2128
|
return new StreamedPHPResponse(
|
|
@@ -2432,7 +2469,7 @@ async function encodeAsMultipart(r) {
|
|
|
2432
2469
|
function fileToUint8Array(r) {
|
|
2433
2470
|
return r.arrayBuffer().then((e) => new Uint8Array(e));
|
|
2434
2471
|
}
|
|
2435
|
-
const _default = "application/octet-stream", asx = "video/x-ms-asf", atom = "application/atom+xml", avi = "video/x-msvideo", avif = "image/avif", bin = "application/octet-stream", bmp = "image/x-ms-bmp", cco = "application/x-cocoa", css = "text/css", data = "application/octet-stream", deb = "application/octet-stream", der = "application/x-x509-ca-cert", dmg = "application/octet-stream", doc = "application/msword", docx = "application/vnd.openxmlformats-officedocument.wordprocessingml.document", eot = "application/vnd.ms-fontobject", flv = "video/x-flv", gif = "image/gif", gz = "application/gzip", hqx = "application/mac-binhex40", htc = "text/x-component", html = "text/html", ico = "image/x-icon", iso = "application/octet-stream", jad = "text/vnd.sun.j2me.app-descriptor", jar = "application/java-archive", jardiff = "application/x-java-archive-diff", jng = "image/x-jng", jnlp = "application/x-java-jnlp-file", jpg = "image/jpeg", jpeg = "image/jpeg", js = "application/javascript", json = "application/json", kml = "application/vnd.google-earth.kml+xml", kmz = "application/vnd.google-earth.kmz", m3u8 = "application/vnd.apple.mpegurl", m4a = "audio/x-m4a", m4v = "video/x-m4v", md = "text/plain", mid = "audio/midi", mml = "text/mathml", mng = "video/x-mng", mov = "video/quicktime", mp3 = "audio/mpeg", mp4 = "video/mp4", mpeg = "video/mpeg", msi = "application/octet-stream", odg = "application/vnd.oasis.opendocument.graphics", odp = "application/vnd.oasis.opendocument.presentation", ods = "application/vnd.oasis.opendocument.spreadsheet", odt = "application/vnd.oasis.opendocument.text", ogg = "audio/ogg", otf = "font/otf", pdf = "application/pdf", pl = "application/x-perl", png = "image/png", ppt = "application/vnd.ms-powerpoint", pptx = "application/vnd.openxmlformats-officedocument.presentationml.presentation", prc = "application/x-pilot", ps = "application/postscript", ra = "audio/x-realaudio", rar = "application/x-rar-compressed", rpm = "application/x-redhat-package-manager", rss = "application/rss+xml", rtf = "application/rtf", run = "application/x-makeself", sea = "application/x-sea", sit = "application/x-stuffit", svg = "image/svg+xml", swf = "application/x-shockwave-flash", tcl = "application/x-tcl", tar = "application/x-tar", tif = "image/tiff", ts = "video/mp2t", ttf = "font/ttf", txt = "text/plain", wasm = "application/wasm", wbmp = "image/vnd.wap.wbmp", webm = "video/webm", webp = "image/webp", wml = "text/vnd.wap.wml", wmlc = "application/vnd.wap.wmlc", wmv = "video/x-ms-wmv", woff = "font/woff", woff2 = "font/woff2", xhtml = "application/xhtml+xml", xls = "application/vnd.ms-excel", xlsx = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", xml = "text/xml", xpi = "application/x-xpinstall", xspf = "application/xspf+xml", zip = "application/zip", mimeTypes = {
|
|
2472
|
+
const _default = "application/octet-stream", asx = "video/x-ms-asf", atom = "application/atom+xml", avi = "video/x-msvideo", avif = "image/avif", bin = "application/octet-stream", bmp = "image/x-ms-bmp", cco = "application/x-cocoa", cjs = "application/javascript", css = "text/css", data = "application/octet-stream", deb = "application/octet-stream", der = "application/x-x509-ca-cert", dmg = "application/octet-stream", doc = "application/msword", docx = "application/vnd.openxmlformats-officedocument.wordprocessingml.document", eot = "application/vnd.ms-fontobject", flv = "video/x-flv", gif = "image/gif", gz = "application/gzip", hqx = "application/mac-binhex40", htc = "text/x-component", html = "text/html", ico = "image/x-icon", iso = "application/octet-stream", jad = "text/vnd.sun.j2me.app-descriptor", jar = "application/java-archive", jardiff = "application/x-java-archive-diff", jng = "image/x-jng", jnlp = "application/x-java-jnlp-file", jpg = "image/jpeg", jpeg = "image/jpeg", js = "application/javascript", json = "application/json", kml = "application/vnd.google-earth.kml+xml", kmz = "application/vnd.google-earth.kmz", m3u8 = "application/vnd.apple.mpegurl", m4a = "audio/x-m4a", m4v = "video/x-m4v", md = "text/plain", mid = "audio/midi", mjs = "application/javascript", mml = "text/mathml", mng = "video/x-mng", mov = "video/quicktime", mp3 = "audio/mpeg", mp4 = "video/mp4", mpeg = "video/mpeg", msi = "application/octet-stream", odg = "application/vnd.oasis.opendocument.graphics", odp = "application/vnd.oasis.opendocument.presentation", ods = "application/vnd.oasis.opendocument.spreadsheet", odt = "application/vnd.oasis.opendocument.text", ogg = "audio/ogg", otf = "font/otf", pdf = "application/pdf", pl = "application/x-perl", png = "image/png", ppt = "application/vnd.ms-powerpoint", pptx = "application/vnd.openxmlformats-officedocument.presentationml.presentation", prc = "application/x-pilot", ps = "application/postscript", ra = "audio/x-realaudio", rar = "application/x-rar-compressed", rpm = "application/x-redhat-package-manager", rss = "application/rss+xml", rtf = "application/rtf", run = "application/x-makeself", sea = "application/x-sea", sit = "application/x-stuffit", svg = "image/svg+xml", swf = "application/x-shockwave-flash", tcl = "application/x-tcl", tar = "application/x-tar", tif = "image/tiff", ts = "video/mp2t", ttf = "font/ttf", txt = "text/plain", wasm = "application/wasm", wbmp = "image/vnd.wap.wbmp", webm = "video/webm", webp = "image/webp", wml = "text/vnd.wap.wml", wmlc = "application/vnd.wap.wmlc", wmv = "video/x-ms-wmv", woff = "font/woff", woff2 = "font/woff2", xhtml = "application/xhtml+xml", xls = "application/vnd.ms-excel", xlsx = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", xml = "text/xml", xpi = "application/x-xpinstall", xspf = "application/xspf+xml", zip = "application/zip", mimeTypes = {
|
|
2436
2473
|
_default,
|
|
2437
2474
|
"3gpp": "video/3gpp",
|
|
2438
2475
|
"7z": "application/x-7z-compressed",
|
|
@@ -2443,6 +2480,7 @@ const _default = "application/octet-stream", asx = "video/x-ms-asf", atom = "app
|
|
|
2443
2480
|
bin,
|
|
2444
2481
|
bmp,
|
|
2445
2482
|
cco,
|
|
2483
|
+
cjs,
|
|
2446
2484
|
css,
|
|
2447
2485
|
data,
|
|
2448
2486
|
deb,
|
|
@@ -2475,6 +2513,7 @@ const _default = "application/octet-stream", asx = "video/x-ms-asf", atom = "app
|
|
|
2475
2513
|
m4v,
|
|
2476
2514
|
md,
|
|
2477
2515
|
mid,
|
|
2516
|
+
mjs,
|
|
2478
2517
|
mml,
|
|
2479
2518
|
mng,
|
|
2480
2519
|
mov,
|
|
@@ -2568,11 +2607,11 @@ class PHPRequestHandler {
|
|
|
2568
2607
|
else if (e.phpFactory)
|
|
2569
2608
|
this.instanceManager = new PHPProcessManager({
|
|
2570
2609
|
phpFactory: async (d) => {
|
|
2571
|
-
const
|
|
2610
|
+
const h = await e.phpFactory({
|
|
2572
2611
|
...d,
|
|
2573
2612
|
requestHandler: this
|
|
2574
2613
|
});
|
|
2575
|
-
return a(
|
|
2614
|
+
return a(h), h;
|
|
2576
2615
|
},
|
|
2577
2616
|
maxPhpInstances: e.maxPhpInstances
|
|
2578
2617
|
});
|
|
@@ -2959,8 +2998,8 @@ ne = function(e, t) {
|
|
|
2959
2998
|
let c = t.body;
|
|
2960
2999
|
if (typeof c == "object" && !(c instanceof Uint8Array)) {
|
|
2961
3000
|
o = "POST";
|
|
2962
|
-
const { bytes: d, contentType:
|
|
2963
|
-
c = d, a["content-type"] =
|
|
3001
|
+
const { bytes: d, contentType: h } = await encodeAsMultipart(c);
|
|
3002
|
+
c = d, a["content-type"] = h;
|
|
2964
3003
|
}
|
|
2965
3004
|
const l = await e.runStream({
|
|
2966
3005
|
relativeUri: ensurePathPrefix(
|
|
@@ -2980,8 +3019,8 @@ ne = function(e, t) {
|
|
|
2980
3019
|
});
|
|
2981
3020
|
if (u(this, k)) {
|
|
2982
3021
|
const d = u(this, k);
|
|
2983
|
-
l.headers.then((
|
|
2984
|
-
d.rememberCookiesFromResponseHeaders(
|
|
3022
|
+
l.headers.then((h) => {
|
|
3023
|
+
d.rememberCookiesFromResponseHeaders(h);
|
|
2985
3024
|
});
|
|
2986
3025
|
}
|
|
2987
3026
|
return l;
|
|
@@ -3032,12 +3071,12 @@ function ensureProxyFSHasMmapSupport(r) {
|
|
|
3032
3071
|
const d = t.malloc(o);
|
|
3033
3072
|
if (!d)
|
|
3034
3073
|
throw new n.ErrnoError(48);
|
|
3035
|
-
const
|
|
3074
|
+
const h = t.HEAPU8.subarray(d, d + o);
|
|
3036
3075
|
let f = 0;
|
|
3037
3076
|
for (; f < o; ) {
|
|
3038
3077
|
const _ = i.stream_ops.read(
|
|
3039
3078
|
i,
|
|
3040
|
-
|
|
3079
|
+
h,
|
|
3041
3080
|
f,
|
|
3042
3081
|
o - f,
|
|
3043
3082
|
f
|
|
@@ -3328,18 +3367,18 @@ function expose(r, e = globalThis, t = ["*"], s) {
|
|
|
3328
3367
|
}, l = (i.data.argumentList || []).map(fromWireValue);
|
|
3329
3368
|
let d;
|
|
3330
3369
|
try {
|
|
3331
|
-
const
|
|
3370
|
+
const h = c.slice(0, -1).reduce((_, F) => _[F], r), f = c.reduce((_, F) => _[F], r);
|
|
3332
3371
|
switch (a) {
|
|
3333
3372
|
case MessageType.GET:
|
|
3334
3373
|
d = f;
|
|
3335
3374
|
break;
|
|
3336
3375
|
case MessageType.SET:
|
|
3337
|
-
|
|
3376
|
+
h[c.slice(-1)[0]] = fromWireValue(
|
|
3338
3377
|
i.data.value
|
|
3339
3378
|
), d = !0;
|
|
3340
3379
|
break;
|
|
3341
3380
|
case MessageType.APPLY:
|
|
3342
|
-
d = f.apply(
|
|
3381
|
+
d = f.apply(h, l);
|
|
3343
3382
|
break;
|
|
3344
3383
|
case MessageType.CONSTRUCT:
|
|
3345
3384
|
{
|
|
@@ -3359,18 +3398,18 @@ function expose(r, e = globalThis, t = ["*"], s) {
|
|
|
3359
3398
|
default:
|
|
3360
3399
|
return;
|
|
3361
3400
|
}
|
|
3362
|
-
} catch (
|
|
3363
|
-
d = { value:
|
|
3401
|
+
} catch (h) {
|
|
3402
|
+
d = { value: h, [throwMarker]: 0 };
|
|
3364
3403
|
}
|
|
3365
|
-
Promise.resolve(d).catch((
|
|
3366
|
-
const [f, _] = toWireValue(
|
|
3404
|
+
Promise.resolve(d).catch((h) => ({ value: h, [throwMarker]: 0 })).then((h) => {
|
|
3405
|
+
const [f, _] = toWireValue(h);
|
|
3367
3406
|
e.postMessage({ ...f, id: o }, _), a === MessageType.RELEASE && (e.removeEventListener("message", n), closeEndPoint(e), finalizer in r && typeof r[finalizer] == "function" && r[finalizer]());
|
|
3368
3407
|
}).catch(() => {
|
|
3369
|
-
const [
|
|
3408
|
+
const [h, f] = toWireValue({
|
|
3370
3409
|
value: new TypeError("Unserializable return value"),
|
|
3371
3410
|
[throwMarker]: 0
|
|
3372
3411
|
});
|
|
3373
|
-
e.postMessage({ ...
|
|
3412
|
+
e.postMessage({ ...h, id: o }, f);
|
|
3374
3413
|
}).finally(() => {
|
|
3375
3414
|
s == null || s(i);
|
|
3376
3415
|
});
|
|
@@ -3447,7 +3486,7 @@ function createProxy(r, e, t = [], s = function() {
|
|
|
3447
3486
|
e,
|
|
3448
3487
|
{
|
|
3449
3488
|
type: MessageType.SET,
|
|
3450
|
-
path: [...t, a].map((
|
|
3489
|
+
path: [...t, a].map((h) => h.toString()),
|
|
3451
3490
|
value: l
|
|
3452
3491
|
},
|
|
3453
3492
|
d
|
|
@@ -3462,7 +3501,7 @@ function createProxy(r, e, t = [], s = function() {
|
|
|
3462
3501
|
}).then(fromWireValue);
|
|
3463
3502
|
if (l === "bind")
|
|
3464
3503
|
return createProxy(r, e, t.slice(0, -1));
|
|
3465
|
-
const [d,
|
|
3504
|
+
const [d, h] = processArguments(c);
|
|
3466
3505
|
return requestResponseMessage(
|
|
3467
3506
|
r,
|
|
3468
3507
|
e,
|
|
@@ -3471,7 +3510,7 @@ function createProxy(r, e, t = [], s = function() {
|
|
|
3471
3510
|
path: t.map((f) => f.toString()),
|
|
3472
3511
|
argumentList: d
|
|
3473
3512
|
},
|
|
3474
|
-
|
|
3513
|
+
h
|
|
3475
3514
|
).then(fromWireValue);
|
|
3476
3515
|
},
|
|
3477
3516
|
construct(o, a) {
|
|
@@ -4656,19 +4695,39 @@ function createObjectPoolProxy(r) {
|
|
|
4656
4695
|
return new Proxy(function() {
|
|
4657
4696
|
}, {
|
|
4658
4697
|
apply(c, l, d) {
|
|
4659
|
-
return i((
|
|
4698
|
+
return i((h) => h[a](...d));
|
|
4660
4699
|
},
|
|
4661
4700
|
get(c, l) {
|
|
4662
4701
|
if (l === "then")
|
|
4663
|
-
return (d,
|
|
4702
|
+
return (d, h) => i((f) => f[a]).then(
|
|
4664
4703
|
d,
|
|
4665
|
-
|
|
4704
|
+
h
|
|
4666
4705
|
);
|
|
4667
4706
|
}
|
|
4668
4707
|
});
|
|
4669
4708
|
}
|
|
4670
4709
|
});
|
|
4671
4710
|
}
|
|
4711
|
+
const maxValueForSigned32BitInteger = 2 ** 31 - 1;
|
|
4712
|
+
class ProcessIdAllocator {
|
|
4713
|
+
constructor(e = 1, t = maxValueForSigned32BitInteger) {
|
|
4714
|
+
this.claimed = /* @__PURE__ */ new Set(), this.initialId = e, this.maxId = t, this.nextId = e;
|
|
4715
|
+
}
|
|
4716
|
+
claim() {
|
|
4717
|
+
const e = this.maxId - this.initialId + 1;
|
|
4718
|
+
for (let t = 0; t < e; t++)
|
|
4719
|
+
if (this.claimed.has(this.nextId))
|
|
4720
|
+
this.nextId++, this.nextId > this.maxId && (this.nextId = this.initialId);
|
|
4721
|
+
else
|
|
4722
|
+
return this.claimed.add(this.nextId), this.nextId;
|
|
4723
|
+
throw new Error(
|
|
4724
|
+
`Unable to find free process ID after ${e} tries.`
|
|
4725
|
+
);
|
|
4726
|
+
}
|
|
4727
|
+
release(e) {
|
|
4728
|
+
return this.claimed.has(e) ? (this.claimed.delete(e), !0) : !1;
|
|
4729
|
+
}
|
|
4730
|
+
}
|
|
4672
4731
|
export {
|
|
4673
4732
|
DEFAULT_BASE_URL,
|
|
4674
4733
|
FSHelpers,
|
|
@@ -4685,6 +4744,7 @@ export {
|
|
|
4685
4744
|
PHPRequestHandler,
|
|
4686
4745
|
PHPResponse,
|
|
4687
4746
|
PHPWorker,
|
|
4747
|
+
ProcessIdAllocator,
|
|
4688
4748
|
SinglePHPInstanceManager,
|
|
4689
4749
|
StreamedPHPResponse,
|
|
4690
4750
|
SupportedPHPVersions,
|