@php-wasm/web 0.1.61 → 0.3.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/.htaccess +0 -4
- package/README.md +4 -0
- package/index.d.ts +15 -19
- package/index.js +393 -371
- package/kitchen-sink/php_5_6.js +85 -0
- package/kitchen-sink/php_5_6.wasm +0 -0
- package/kitchen-sink/php_7_0.js +85 -0
- package/kitchen-sink/php_7_0.wasm +0 -0
- package/kitchen-sink/php_7_1.js +85 -0
- package/kitchen-sink/php_7_1.wasm +0 -0
- package/kitchen-sink/php_7_2.js +85 -0
- package/kitchen-sink/php_7_2.wasm +0 -0
- package/kitchen-sink/php_7_3.js +85 -0
- package/kitchen-sink/php_7_3.wasm +0 -0
- package/kitchen-sink/php_7_4.js +85 -0
- package/kitchen-sink/php_7_4.wasm +0 -0
- package/kitchen-sink/php_8_0.js +85 -0
- package/kitchen-sink/php_8_0.wasm +0 -0
- package/kitchen-sink/php_8_1.js +85 -0
- package/kitchen-sink/php_8_1.wasm +0 -0
- package/kitchen-sink/php_8_2.js +85 -0
- package/kitchen-sink/php_8_2.wasm +0 -0
- package/lib/worker-thread/spawn-php-worker-thread.d.ts +1 -9
- package/{php_5_6.js → light/php_5_6.js} +15 -1
- package/{php_5_6.wasm → light/php_5_6.wasm} +0 -0
- package/{php_7_0.js → light/php_7_0.js} +15 -1
- package/{php_7_0.wasm → light/php_7_0.wasm} +0 -0
- package/{php_7_1.js → light/php_7_1.js} +15 -1
- package/{php_7_1.wasm → light/php_7_1.wasm} +0 -0
- package/{php_7_2.js → light/php_7_2.js} +15 -1
- package/{php_7_2.wasm → light/php_7_2.wasm} +0 -0
- package/{php_7_3.js → light/php_7_3.js} +15 -1
- package/{php_7_3.wasm → light/php_7_3.wasm} +0 -0
- package/{php_7_4.js → light/php_7_4.js} +16 -2
- package/{php_7_4.wasm → light/php_7_4.wasm} +0 -0
- package/{php_8_0.js → light/php_8_0.js} +16 -2
- package/{php_8_0.wasm → light/php_8_0.wasm} +0 -0
- package/{php_8_1.js → light/php_8_1.js} +16 -2
- package/{php_8_1.wasm → light/php_8_1.wasm} +0 -0
- package/{php_8_2.js → light/php_8_2.js} +15 -1
- package/{php_8_2.wasm → light/php_8_2.wasm} +0 -0
- package/package.json +6 -2
- package/lib/worker-thread/parse-startup-options.d.ts +0 -1
package/index.js
CHANGED
|
@@ -19,8 +19,11 @@ class I extends Event {
|
|
|
19
19
|
}
|
|
20
20
|
Object.defineProperty(I.prototype, "error", { enumerable: !0 });
|
|
21
21
|
Object.defineProperty(I.prototype, "message", { enumerable: !0 });
|
|
22
|
-
const
|
|
23
|
-
|
|
22
|
+
const oe = typeof globalThis.ErrorEvent == "function" ? globalThis.ErrorEvent : I;
|
|
23
|
+
function ae(t) {
|
|
24
|
+
return t instanceof Error ? "exitCode" in t && t?.exitCode === 0 || t?.name === "ExitStatus" && "status" in t && t.status === 0 : !1;
|
|
25
|
+
}
|
|
26
|
+
class ce extends EventTarget {
|
|
24
27
|
constructor() {
|
|
25
28
|
super(...arguments), this.listenersCount = 0;
|
|
26
29
|
}
|
|
@@ -34,62 +37,62 @@ class oe extends EventTarget {
|
|
|
34
37
|
return this.listenersCount > 0;
|
|
35
38
|
}
|
|
36
39
|
}
|
|
37
|
-
function
|
|
40
|
+
function le(t) {
|
|
38
41
|
t.asm = {
|
|
39
42
|
...t.asm
|
|
40
43
|
};
|
|
41
|
-
const e = new
|
|
44
|
+
const e = new ce();
|
|
42
45
|
for (const r in t.asm)
|
|
43
46
|
if (typeof t.asm[r] == "function") {
|
|
44
47
|
const n = t.asm[r];
|
|
45
48
|
t.asm[r] = function(...s) {
|
|
46
49
|
try {
|
|
47
50
|
return n(...s);
|
|
48
|
-
} catch (
|
|
49
|
-
if (!(
|
|
50
|
-
throw
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const i = le(
|
|
54
|
-
o,
|
|
51
|
+
} catch (i) {
|
|
52
|
+
if (!(i instanceof Error))
|
|
53
|
+
throw i;
|
|
54
|
+
const o = he(
|
|
55
|
+
i,
|
|
55
56
|
t.lastAsyncifyStackSource?.stack
|
|
56
57
|
);
|
|
57
|
-
if (t.lastAsyncifyStackSource && (
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
58
|
+
if (t.lastAsyncifyStackSource && (i.cause = t.lastAsyncifyStackSource), e.hasListeners()) {
|
|
59
|
+
e.dispatchEvent(
|
|
60
|
+
new oe("error", {
|
|
61
|
+
error: i,
|
|
62
|
+
message: o
|
|
63
|
+
})
|
|
64
|
+
);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
throw ae(i) || pe(o), i;
|
|
65
68
|
}
|
|
66
69
|
};
|
|
67
70
|
}
|
|
68
71
|
return e;
|
|
69
72
|
}
|
|
70
|
-
let
|
|
71
|
-
function
|
|
72
|
-
return
|
|
73
|
+
let A = [];
|
|
74
|
+
function ue() {
|
|
75
|
+
return A;
|
|
73
76
|
}
|
|
74
|
-
function
|
|
77
|
+
function he(t, e) {
|
|
75
78
|
if (t.message === "unreachable") {
|
|
76
|
-
let r =
|
|
79
|
+
let r = de;
|
|
77
80
|
e || (r += `
|
|
78
81
|
|
|
79
82
|
This stack trace is lacking. For a better one initialize
|
|
80
83
|
the PHP runtime with { debug: true }, e.g. PHPNode.load('8.1', { debug: true }).
|
|
81
84
|
|
|
82
|
-
`),
|
|
85
|
+
`), A = me(
|
|
83
86
|
e || t.stack || ""
|
|
84
87
|
);
|
|
85
|
-
for (const n of
|
|
88
|
+
for (const n of A)
|
|
86
89
|
r += ` * ${n}
|
|
87
90
|
`;
|
|
88
91
|
return r;
|
|
89
92
|
}
|
|
90
93
|
return t.message;
|
|
91
94
|
}
|
|
92
|
-
const
|
|
95
|
+
const de = `
|
|
93
96
|
"unreachable" WASM instruction executed.
|
|
94
97
|
|
|
95
98
|
The typical reason is a PHP function missing from the ASYNCIFY_ONLY
|
|
@@ -113,20 +116,20 @@ the Dockerfile, you'll need to trigger this error again with long stack
|
|
|
113
116
|
traces enabled. In node.js, you can do it using the --stack-trace-limit=100
|
|
114
117
|
CLI option:
|
|
115
118
|
|
|
116
|
-
`, D = "\x1B[41m",
|
|
119
|
+
`, D = "\x1B[41m", fe = "\x1B[1m", q = "\x1B[0m", z = "\x1B[K";
|
|
117
120
|
let B = !1;
|
|
118
|
-
function
|
|
121
|
+
function pe(t) {
|
|
119
122
|
if (!B) {
|
|
120
123
|
B = !0, console.log(`${D}
|
|
121
124
|
${z}
|
|
122
|
-
${
|
|
125
|
+
${fe} WASM ERROR${q}${D}`);
|
|
123
126
|
for (const e of t.split(`
|
|
124
127
|
`))
|
|
125
128
|
console.log(`${z} ${e} `);
|
|
126
129
|
console.log(`${q}`);
|
|
127
130
|
}
|
|
128
131
|
}
|
|
129
|
-
function
|
|
132
|
+
function me(t) {
|
|
130
133
|
try {
|
|
131
134
|
const e = t.split(`
|
|
132
135
|
`).slice(1).map((r) => {
|
|
@@ -144,8 +147,8 @@ function fe(t) {
|
|
|
144
147
|
}
|
|
145
148
|
}
|
|
146
149
|
class b {
|
|
147
|
-
constructor(e, r, n, s = "",
|
|
148
|
-
this.httpStatusCode = e, this.headers = r, this.bytes = n, this.exitCode =
|
|
150
|
+
constructor(e, r, n, s = "", i = 0) {
|
|
151
|
+
this.httpStatusCode = e, this.headers = r, this.bytes = n, this.exitCode = i, this.errors = s;
|
|
149
152
|
}
|
|
150
153
|
static fromRawData(e) {
|
|
151
154
|
return new b(
|
|
@@ -178,7 +181,7 @@ class b {
|
|
|
178
181
|
return new TextDecoder().decode(this.bytes);
|
|
179
182
|
}
|
|
180
183
|
}
|
|
181
|
-
const
|
|
184
|
+
const ge = [
|
|
182
185
|
"8.2",
|
|
183
186
|
"8.1",
|
|
184
187
|
"8.0",
|
|
@@ -188,8 +191,8 @@ const pe = [
|
|
|
188
191
|
"7.1",
|
|
189
192
|
"7.0",
|
|
190
193
|
"5.6"
|
|
191
|
-
],
|
|
192
|
-
class
|
|
194
|
+
], ye = ge[0];
|
|
195
|
+
class we {
|
|
193
196
|
#e;
|
|
194
197
|
#t;
|
|
195
198
|
/**
|
|
@@ -262,8 +265,8 @@ class ge {
|
|
|
262
265
|
try {
|
|
263
266
|
if (!r.includes("="))
|
|
264
267
|
continue;
|
|
265
|
-
const n = r.indexOf("="), s = r.substring(0, n),
|
|
266
|
-
this.#e[s] =
|
|
268
|
+
const n = r.indexOf("="), s = r.substring(0, n), i = r.substring(n + 1).split(";")[0];
|
|
269
|
+
this.#e[s] = i;
|
|
267
270
|
} catch (n) {
|
|
268
271
|
console.error(n);
|
|
269
272
|
}
|
|
@@ -275,7 +278,7 @@ class ge {
|
|
|
275
278
|
return e.join("; ");
|
|
276
279
|
}
|
|
277
280
|
}
|
|
278
|
-
class
|
|
281
|
+
class Pe {
|
|
279
282
|
constructor({ concurrency: e }) {
|
|
280
283
|
this._running = 0, this.concurrency = e, this.queue = [];
|
|
281
284
|
}
|
|
@@ -303,17 +306,17 @@ class ye {
|
|
|
303
306
|
}
|
|
304
307
|
}
|
|
305
308
|
}
|
|
306
|
-
const
|
|
309
|
+
const be = "http://example.com";
|
|
307
310
|
function j(t) {
|
|
308
311
|
return t.toString().substring(t.origin.length);
|
|
309
312
|
}
|
|
310
313
|
function G(t, e) {
|
|
311
314
|
return !e || !t.startsWith(e) ? t : t.substring(e.length);
|
|
312
315
|
}
|
|
313
|
-
function
|
|
316
|
+
function Ee(t, e) {
|
|
314
317
|
return !e || t.startsWith(e) ? t : e + t;
|
|
315
318
|
}
|
|
316
|
-
class
|
|
319
|
+
class ke {
|
|
317
320
|
#e;
|
|
318
321
|
#t;
|
|
319
322
|
#n;
|
|
@@ -322,25 +325,23 @@ class be {
|
|
|
322
325
|
#s;
|
|
323
326
|
#o;
|
|
324
327
|
#a;
|
|
325
|
-
#c;
|
|
326
328
|
/**
|
|
327
329
|
* @param php - The PHP instance.
|
|
328
330
|
* @param config - Request Handler configuration.
|
|
329
331
|
*/
|
|
330
332
|
constructor(e, r = {}) {
|
|
331
|
-
this.#a = new
|
|
333
|
+
this.#a = new Pe({ concurrency: 1 });
|
|
332
334
|
const {
|
|
333
335
|
documentRoot: n = "/www/",
|
|
334
|
-
absoluteUrl: s = typeof location == "object" ? location?.href : ""
|
|
335
|
-
isStaticFilePath: o = () => !1
|
|
336
|
+
absoluteUrl: s = typeof location == "object" ? location?.href : ""
|
|
336
337
|
} = r;
|
|
337
|
-
this.php = e, this.#e = n
|
|
338
|
+
this.php = e, this.#e = n;
|
|
338
339
|
const i = new URL(s);
|
|
339
340
|
this.#n = i.hostname, this.#r = i.port ? Number(i.port) : i.protocol === "https:" ? 443 : 80, this.#t = (i.protocol || "").replace(":", "");
|
|
340
|
-
const
|
|
341
|
+
const o = this.#r !== 443 && this.#r !== 80;
|
|
341
342
|
this.#i = [
|
|
342
343
|
this.#n,
|
|
343
|
-
|
|
344
|
+
o ? `:${this.#r}` : ""
|
|
344
345
|
].join(""), this.#s = i.pathname.replace(/\/+$/, ""), this.#o = [
|
|
345
346
|
`${this.#t}://`,
|
|
346
347
|
this.#i,
|
|
@@ -371,40 +372,43 @@ class be {
|
|
|
371
372
|
async request(e) {
|
|
372
373
|
const r = e.url.startsWith("http://") || e.url.startsWith("https://"), n = new URL(
|
|
373
374
|
e.url,
|
|
374
|
-
r ? void 0 :
|
|
375
|
+
r ? void 0 : be
|
|
375
376
|
), s = G(
|
|
376
377
|
n.pathname,
|
|
377
378
|
this.#s
|
|
378
|
-
)
|
|
379
|
-
return
|
|
379
|
+
), i = `${this.#e}${s}`;
|
|
380
|
+
return xe(i) ? await this.#l(e, n) : this.#c(i);
|
|
380
381
|
}
|
|
381
382
|
/**
|
|
382
383
|
* Serves a static file from the PHP filesystem.
|
|
383
384
|
*
|
|
384
|
-
* @param
|
|
385
|
+
* @param fsPath - Absolute path of the static file to serve.
|
|
385
386
|
* @returns The response.
|
|
386
387
|
*/
|
|
387
|
-
#
|
|
388
|
-
|
|
389
|
-
if (!this.php.fileExists(r))
|
|
388
|
+
#c(e) {
|
|
389
|
+
if (!this.php.fileExists(e))
|
|
390
390
|
return new b(
|
|
391
391
|
404,
|
|
392
|
-
|
|
392
|
+
// Let the service worker know that no static file was found
|
|
393
|
+
// and that it's okay to issue a real fetch() to the server.
|
|
394
|
+
{
|
|
395
|
+
"x-file-type": ["static"]
|
|
396
|
+
},
|
|
393
397
|
new TextEncoder().encode("404 File not found")
|
|
394
398
|
);
|
|
395
|
-
const
|
|
399
|
+
const r = this.php.readFileAsBuffer(e);
|
|
396
400
|
return new b(
|
|
397
401
|
200,
|
|
398
402
|
{
|
|
399
|
-
"content-length": [`${
|
|
403
|
+
"content-length": [`${r.byteLength}`],
|
|
400
404
|
// @TODO: Infer the content-type from the arrayBuffer instead of the file path.
|
|
401
405
|
// The code below won't return the correct mime-type if the extension
|
|
402
406
|
// was tampered with.
|
|
403
|
-
"content-type": [ve(
|
|
407
|
+
"content-type": [ve(e)],
|
|
404
408
|
"accept-ranges": ["bytes"],
|
|
405
409
|
"cache-control": ["public, max-age=0"]
|
|
406
410
|
},
|
|
407
|
-
|
|
411
|
+
r
|
|
408
412
|
);
|
|
409
413
|
}
|
|
410
414
|
/**
|
|
@@ -414,7 +418,7 @@ class be {
|
|
|
414
418
|
* @param request - The request.
|
|
415
419
|
* @returns The response.
|
|
416
420
|
*/
|
|
417
|
-
async #
|
|
421
|
+
async #l(e, r) {
|
|
418
422
|
const n = await this.#a.acquire();
|
|
419
423
|
try {
|
|
420
424
|
this.php.addServerGlobalEntry("DOCUMENT_ROOT", this.#e), this.php.addServerGlobalEntry(
|
|
@@ -422,32 +426,32 @@ class be {
|
|
|
422
426
|
this.#o.startsWith("https://") ? "on" : ""
|
|
423
427
|
);
|
|
424
428
|
let s = "GET";
|
|
425
|
-
const
|
|
429
|
+
const i = {
|
|
426
430
|
host: this.#i,
|
|
427
|
-
...
|
|
428
|
-
},
|
|
431
|
+
...Q(e.headers || {})
|
|
432
|
+
}, o = [];
|
|
429
433
|
if (e.files && Object.keys(e.files).length) {
|
|
430
434
|
s = "POST";
|
|
431
|
-
for (const
|
|
432
|
-
const h = e.files[
|
|
433
|
-
|
|
434
|
-
key:
|
|
435
|
+
for (const a in e.files) {
|
|
436
|
+
const h = e.files[a];
|
|
437
|
+
o.push({
|
|
438
|
+
key: a,
|
|
435
439
|
name: h.name,
|
|
436
440
|
type: h.type,
|
|
437
441
|
data: new Uint8Array(await h.arrayBuffer())
|
|
438
442
|
});
|
|
439
443
|
}
|
|
440
|
-
|
|
444
|
+
i["content-type"]?.startsWith("multipart/form-data") && (e.formData = Re(
|
|
441
445
|
e.body || ""
|
|
442
|
-
),
|
|
446
|
+
), i["content-type"] = "application/x-www-form-urlencoded", delete e.body);
|
|
443
447
|
}
|
|
444
|
-
let a;
|
|
445
|
-
e.formData !== void 0 ? (s = "POST", o["content-type"] = o["content-type"] || "application/x-www-form-urlencoded", a = new URLSearchParams(
|
|
446
|
-
e.formData
|
|
447
|
-
).toString()) : a = e.body;
|
|
448
448
|
let c;
|
|
449
|
+
e.formData !== void 0 ? (s = "POST", i["content-type"] = i["content-type"] || "application/x-www-form-urlencoded", c = new URLSearchParams(
|
|
450
|
+
e.formData
|
|
451
|
+
).toString()) : c = e.body;
|
|
452
|
+
let l;
|
|
449
453
|
try {
|
|
450
|
-
|
|
454
|
+
l = this.#u(r.pathname);
|
|
451
455
|
} catch {
|
|
452
456
|
return new b(
|
|
453
457
|
404,
|
|
@@ -456,16 +460,16 @@ class be {
|
|
|
456
460
|
);
|
|
457
461
|
}
|
|
458
462
|
return await this.php.run({
|
|
459
|
-
relativeUri:
|
|
463
|
+
relativeUri: Ee(
|
|
460
464
|
j(r),
|
|
461
465
|
this.#s
|
|
462
466
|
),
|
|
463
467
|
protocol: this.#t,
|
|
464
468
|
method: e.method || s,
|
|
465
|
-
body:
|
|
466
|
-
fileInfos:
|
|
467
|
-
scriptPath:
|
|
468
|
-
headers:
|
|
469
|
+
body: c,
|
|
470
|
+
fileInfos: o,
|
|
471
|
+
scriptPath: l,
|
|
472
|
+
headers: i
|
|
469
473
|
});
|
|
470
474
|
} finally {
|
|
471
475
|
n();
|
|
@@ -480,7 +484,7 @@ class be {
|
|
|
480
484
|
* @throws {Error} If the requested path doesn't exist.
|
|
481
485
|
* @returns The resolved filesystem path.
|
|
482
486
|
*/
|
|
483
|
-
#
|
|
487
|
+
#u(e) {
|
|
484
488
|
let r = G(e, this.#s);
|
|
485
489
|
r.includes(".php") ? r = r.split(".php")[0] + ".php" : (r.endsWith("/") || (r += "/"), r.endsWith("index.php") || (r += "index.php"));
|
|
486
490
|
const n = `${this.#e}${r}`;
|
|
@@ -491,18 +495,18 @@ class be {
|
|
|
491
495
|
return `${this.#e}/index.php`;
|
|
492
496
|
}
|
|
493
497
|
}
|
|
494
|
-
function
|
|
498
|
+
function Re(t) {
|
|
495
499
|
const e = {}, r = t.match(/--(.*)\r\n/);
|
|
496
500
|
if (!r)
|
|
497
501
|
return e;
|
|
498
502
|
const n = r[1], s = t.split(`--${n}`);
|
|
499
|
-
return s.shift(), s.pop(), s.forEach((
|
|
500
|
-
const
|
|
503
|
+
return s.shift(), s.pop(), s.forEach((i) => {
|
|
504
|
+
const o = i.indexOf(`\r
|
|
501
505
|
\r
|
|
502
|
-
`),
|
|
503
|
-
if (
|
|
504
|
-
const h =
|
|
505
|
-
e[h] =
|
|
506
|
+
`), c = i.substring(0, o).trim(), l = i.substring(o + 4).trim(), a = c.match(/name="([^"]+)"/);
|
|
507
|
+
if (a) {
|
|
508
|
+
const h = a[1];
|
|
509
|
+
e[h] = l;
|
|
506
510
|
}
|
|
507
511
|
}), e;
|
|
508
512
|
}
|
|
@@ -546,6 +550,15 @@ function ve(t) {
|
|
|
546
550
|
return "application-octet-stream";
|
|
547
551
|
}
|
|
548
552
|
}
|
|
553
|
+
function xe(t) {
|
|
554
|
+
return Se(t) || Te(t);
|
|
555
|
+
}
|
|
556
|
+
function Se(t) {
|
|
557
|
+
return t.endsWith(".php") || t.includes(".php/");
|
|
558
|
+
}
|
|
559
|
+
function Te(t) {
|
|
560
|
+
return !t.split("/").pop().includes(".");
|
|
561
|
+
}
|
|
549
562
|
const V = {
|
|
550
563
|
0: "No error occurred. System call completed successfully.",
|
|
551
564
|
1: "Argument list too long.",
|
|
@@ -627,62 +640,64 @@ const V = {
|
|
|
627
640
|
};
|
|
628
641
|
function y(t = "") {
|
|
629
642
|
return function(r, n, s) {
|
|
630
|
-
const
|
|
631
|
-
s.value = function(...
|
|
643
|
+
const i = s.value;
|
|
644
|
+
s.value = function(...o) {
|
|
632
645
|
try {
|
|
633
|
-
return
|
|
634
|
-
} catch (
|
|
635
|
-
const
|
|
636
|
-
if (
|
|
637
|
-
const
|
|
638
|
-
throw new Error(`${g}: ${
|
|
639
|
-
cause:
|
|
646
|
+
return i.apply(this, o);
|
|
647
|
+
} catch (c) {
|
|
648
|
+
const l = typeof c == "object" ? c?.errno : null;
|
|
649
|
+
if (l in V) {
|
|
650
|
+
const a = V[l], h = typeof o[0] == "string" ? o[0] : null, g = h !== null ? t.replaceAll("{path}", h) : t;
|
|
651
|
+
throw new Error(`${g}: ${a}`, {
|
|
652
|
+
cause: c
|
|
640
653
|
});
|
|
641
654
|
}
|
|
642
|
-
throw
|
|
655
|
+
throw c;
|
|
643
656
|
}
|
|
644
657
|
};
|
|
645
658
|
};
|
|
646
659
|
}
|
|
647
|
-
async function
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
}), i = new Promise((c) => {
|
|
652
|
-
n = c;
|
|
653
|
-
}), a = t.init(Se, {
|
|
654
|
-
onAbort(c) {
|
|
655
|
-
console.error("WASM aborted: "), console.error(c);
|
|
660
|
+
async function _e(t, e = {}, r = []) {
|
|
661
|
+
const [n, s, i] = Y(), [o, c] = Y(), l = t.init(He, {
|
|
662
|
+
onAbort(a) {
|
|
663
|
+
i(a), c(), console.error(a);
|
|
656
664
|
},
|
|
657
665
|
ENV: {},
|
|
658
666
|
// Emscripten sometimes prepends a '/' to the path, which
|
|
659
667
|
// breaks vite dev mode. An identity `locateFile` function
|
|
660
668
|
// fixes it.
|
|
661
|
-
locateFile: (
|
|
669
|
+
locateFile: (a) => a,
|
|
662
670
|
...e,
|
|
663
671
|
noInitialRun: !0,
|
|
664
672
|
onRuntimeInitialized() {
|
|
665
|
-
e.onRuntimeInitialized && e.onRuntimeInitialized(),
|
|
673
|
+
e.onRuntimeInitialized && e.onRuntimeInitialized(), s();
|
|
666
674
|
},
|
|
667
|
-
monitorRunDependencies(
|
|
668
|
-
|
|
675
|
+
monitorRunDependencies(a) {
|
|
676
|
+
a === 0 && (delete l.monitorRunDependencies, c());
|
|
669
677
|
}
|
|
670
678
|
});
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
679
|
+
return await Promise.all(
|
|
680
|
+
r.map(
|
|
681
|
+
({ default: a }) => a(l)
|
|
682
|
+
)
|
|
683
|
+
), r.length || c(), await o, await n, M.push(l), M.length - 1;
|
|
674
684
|
}
|
|
675
|
-
const
|
|
676
|
-
function
|
|
677
|
-
return
|
|
685
|
+
const M = [];
|
|
686
|
+
function Ce(t) {
|
|
687
|
+
return M[t];
|
|
678
688
|
}
|
|
679
|
-
const
|
|
689
|
+
const He = function() {
|
|
680
690
|
return typeof process < "u" && process.release?.name === "node" ? "NODE" : typeof window < "u" ? "WEB" : typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope ? "WORKER" : "NODE";
|
|
681
|
-
}()
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
return
|
|
691
|
+
}(), Y = () => {
|
|
692
|
+
const t = [], e = new Promise((r, n) => {
|
|
693
|
+
t.push(r, n);
|
|
694
|
+
});
|
|
695
|
+
return t.unshift(e), t;
|
|
696
|
+
};
|
|
697
|
+
var Fe = Object.defineProperty, Ae = Object.getOwnPropertyDescriptor, w = (t, e, r, n) => {
|
|
698
|
+
for (var s = n > 1 ? void 0 : n ? Ae(e, r) : e, i = t.length - 1, o; i >= 0; i--)
|
|
699
|
+
(o = t[i]) && (s = (n ? o(e, r, s) : o(s)) || s);
|
|
700
|
+
return n && s && Fe(e, r, s), s;
|
|
686
701
|
};
|
|
687
702
|
const f = "string", E = "number", u = Symbol("__private__dont__use");
|
|
688
703
|
class m {
|
|
@@ -694,8 +709,8 @@ class m {
|
|
|
694
709
|
* @param serverOptions - Optional. Options for the PHPRequestHandler. If undefined, no request handler will be initialized.
|
|
695
710
|
*/
|
|
696
711
|
constructor(e, r) {
|
|
697
|
-
this.#e = [], this.#t = !1, this.#n = null, this.#r = {}, this.#i = [], e !== void 0 && this.initializeRuntime(e), r && (this.requestHandler = new
|
|
698
|
-
new
|
|
712
|
+
this.#e = [], this.#t = !1, this.#n = null, this.#r = {}, this.#i = [], e !== void 0 && this.initializeRuntime(e), r && (this.requestHandler = new we(
|
|
713
|
+
new ke(this, r)
|
|
699
714
|
));
|
|
700
715
|
}
|
|
701
716
|
#e;
|
|
@@ -728,13 +743,13 @@ class m {
|
|
|
728
743
|
initializeRuntime(e) {
|
|
729
744
|
if (this[u])
|
|
730
745
|
throw new Error("PHP runtime already initialized.");
|
|
731
|
-
const r =
|
|
746
|
+
const r = Ce(e);
|
|
732
747
|
if (!r)
|
|
733
748
|
throw new Error("Invalid PHP runtime id.");
|
|
734
749
|
this[u] = r, r.onMessage = (n) => {
|
|
735
750
|
for (const s of this.#i)
|
|
736
751
|
s(n);
|
|
737
|
-
}, this.#n =
|
|
752
|
+
}, this.#n = le(r);
|
|
738
753
|
}
|
|
739
754
|
/** @inheritDoc */
|
|
740
755
|
setPhpIniPath(e) {
|
|
@@ -768,7 +783,7 @@ class m {
|
|
|
768
783
|
this.#t || (this.#s(), this.#t = !0), this.#d(e.scriptPath || ""), this.#a(e.relativeUri || ""), this.#l(e.method || "GET");
|
|
769
784
|
const { host: r, ...n } = {
|
|
770
785
|
host: "example.com:443",
|
|
771
|
-
...
|
|
786
|
+
...Q(e.headers || {})
|
|
772
787
|
};
|
|
773
788
|
if (this.#c(r, e.protocol || "http"), this.#u(n), e.body && this.#h(e.body), e.fileInfos)
|
|
774
789
|
for (const s of e.fileInfos)
|
|
@@ -800,8 +815,8 @@ class m {
|
|
|
800
815
|
for (const s of r.headers) {
|
|
801
816
|
if (!s.includes(": "))
|
|
802
817
|
continue;
|
|
803
|
-
const
|
|
804
|
-
|
|
818
|
+
const i = s.indexOf(": "), o = s.substring(0, i).toLowerCase(), c = s.substring(i + 2);
|
|
819
|
+
o in n || (n[o] = []), n[o].push(c);
|
|
805
820
|
}
|
|
806
821
|
return {
|
|
807
822
|
headers: n,
|
|
@@ -919,14 +934,14 @@ class m {
|
|
|
919
934
|
* @param fileInfo - File details
|
|
920
935
|
*/
|
|
921
936
|
#p(e) {
|
|
922
|
-
const { key: r, name: n, type: s, data:
|
|
923
|
-
this.writeFile(
|
|
924
|
-
const
|
|
937
|
+
const { key: r, name: n, type: s, data: i } = e, o = `/tmp/${Math.random().toFixed(20)}`;
|
|
938
|
+
this.writeFile(o, i);
|
|
939
|
+
const c = 0;
|
|
925
940
|
this[u].ccall(
|
|
926
941
|
"wasm_add_uploaded_file",
|
|
927
942
|
null,
|
|
928
943
|
[f, f, f, f, E, E],
|
|
929
|
-
[r, n, s,
|
|
944
|
+
[r, n, s, o, c, i.byteLength]
|
|
930
945
|
);
|
|
931
946
|
}
|
|
932
947
|
#m(e) {
|
|
@@ -940,32 +955,32 @@ class m {
|
|
|
940
955
|
async #g() {
|
|
941
956
|
let e, r;
|
|
942
957
|
try {
|
|
943
|
-
e = await new Promise((
|
|
944
|
-
r = (
|
|
945
|
-
const
|
|
946
|
-
|
|
958
|
+
e = await new Promise((i, o) => {
|
|
959
|
+
r = (l) => {
|
|
960
|
+
const a = new Error("Rethrown");
|
|
961
|
+
a.cause = l.error, a.betterMessage = l.message, o(a);
|
|
947
962
|
}, this.#n?.addEventListener(
|
|
948
963
|
"error",
|
|
949
964
|
r
|
|
950
965
|
);
|
|
951
|
-
const
|
|
966
|
+
const c = this[u].ccall(
|
|
952
967
|
"wasm_sapi_handle_request",
|
|
953
968
|
E,
|
|
954
969
|
[],
|
|
955
970
|
[]
|
|
956
971
|
);
|
|
957
|
-
return
|
|
972
|
+
return c instanceof Promise ? c.then(i, o) : i(c);
|
|
958
973
|
});
|
|
959
|
-
} catch (
|
|
960
|
-
for (const
|
|
961
|
-
typeof this[
|
|
974
|
+
} catch (i) {
|
|
975
|
+
for (const a in this)
|
|
976
|
+
typeof this[a] == "function" && (this[a] = () => {
|
|
962
977
|
throw new Error(
|
|
963
978
|
"PHP runtime has crashed – see the earlier error for details."
|
|
964
979
|
);
|
|
965
980
|
});
|
|
966
|
-
this.functionsMaybeMissingFromAsyncify =
|
|
967
|
-
const
|
|
968
|
-
throw
|
|
981
|
+
this.functionsMaybeMissingFromAsyncify = ue();
|
|
982
|
+
const o = i, c = "betterMessage" in o ? o.betterMessage : o.message, l = new Error(c);
|
|
983
|
+
throw l.cause = o, l;
|
|
969
984
|
} finally {
|
|
970
985
|
this.#n?.removeEventListener("error", r), this.#r = {};
|
|
971
986
|
}
|
|
@@ -1014,7 +1029,7 @@ class m {
|
|
|
1014
1029
|
);
|
|
1015
1030
|
if (r.prependPath) {
|
|
1016
1031
|
const s = e.replace(/\/$/, "");
|
|
1017
|
-
return n.map((
|
|
1032
|
+
return n.map((i) => `${s}/${i}`);
|
|
1018
1033
|
}
|
|
1019
1034
|
return n;
|
|
1020
1035
|
} catch (n) {
|
|
@@ -1067,7 +1082,7 @@ w([
|
|
|
1067
1082
|
w([
|
|
1068
1083
|
y('Could not stat "{path}"')
|
|
1069
1084
|
], m.prototype, "fileExists", 1);
|
|
1070
|
-
function
|
|
1085
|
+
function Q(t) {
|
|
1071
1086
|
const e = {};
|
|
1072
1087
|
for (const r in t)
|
|
1073
1088
|
e[r.toLowerCase()] = t[r];
|
|
@@ -1078,17 +1093,17 @@ function K(t) {
|
|
|
1078
1093
|
* Copyright 2019 Google LLC
|
|
1079
1094
|
* SPDX-License-Identifier: Apache-2.0
|
|
1080
1095
|
*/
|
|
1081
|
-
const
|
|
1082
|
-
canHandle: (t) =>
|
|
1096
|
+
const X = Symbol("Comlink.proxy"), Me = Symbol("Comlink.endpoint"), Le = Symbol("Comlink.releaseProxy"), F = Symbol("Comlink.finalizer"), S = Symbol("Comlink.thrown"), Z = (t) => typeof t == "object" && t !== null || typeof t == "function", Oe = {
|
|
1097
|
+
canHandle: (t) => Z(t) && t[X],
|
|
1083
1098
|
serialize(t) {
|
|
1084
1099
|
const { port1: e, port2: r } = new MessageChannel();
|
|
1085
|
-
return
|
|
1100
|
+
return H(t, e), [r, [r]];
|
|
1086
1101
|
},
|
|
1087
1102
|
deserialize(t) {
|
|
1088
1103
|
return t.start(), U(t);
|
|
1089
1104
|
}
|
|
1090
|
-
},
|
|
1091
|
-
canHandle: (t) =>
|
|
1105
|
+
}, Ie = {
|
|
1106
|
+
canHandle: (t) => Z(t) && S in t,
|
|
1092
1107
|
serialize({ value: t }) {
|
|
1093
1108
|
let e;
|
|
1094
1109
|
return t instanceof Error ? e = {
|
|
@@ -1103,174 +1118,174 @@ const Q = Symbol("Comlink.proxy"), _e = Symbol("Comlink.endpoint"), Ce = Symbol(
|
|
|
1103
1118
|
deserialize(t) {
|
|
1104
1119
|
throw t.isError ? Object.assign(new Error(t.value.message), t.value) : t.value;
|
|
1105
1120
|
}
|
|
1106
|
-
},
|
|
1107
|
-
["proxy",
|
|
1108
|
-
["throw",
|
|
1121
|
+
}, v = /* @__PURE__ */ new Map([
|
|
1122
|
+
["proxy", Oe],
|
|
1123
|
+
["throw", Ie]
|
|
1109
1124
|
]);
|
|
1110
|
-
function
|
|
1125
|
+
function Ue(t, e) {
|
|
1111
1126
|
for (const r of t)
|
|
1112
1127
|
if (e === r || r === "*" || r instanceof RegExp && r.test(e))
|
|
1113
1128
|
return !0;
|
|
1114
1129
|
return !1;
|
|
1115
1130
|
}
|
|
1116
|
-
function
|
|
1131
|
+
function H(t, e = globalThis, r = ["*"]) {
|
|
1117
1132
|
e.addEventListener("message", function n(s) {
|
|
1118
1133
|
if (!s || !s.data)
|
|
1119
1134
|
return;
|
|
1120
|
-
if (!
|
|
1135
|
+
if (!Ue(r, s.origin)) {
|
|
1121
1136
|
console.warn(`Invalid origin '${s.origin}' for comlink proxy`);
|
|
1122
1137
|
return;
|
|
1123
1138
|
}
|
|
1124
|
-
const { id:
|
|
1125
|
-
let
|
|
1139
|
+
const { id: i, type: o, path: c } = Object.assign({ path: [] }, s.data), l = (s.data.argumentList || []).map(P);
|
|
1140
|
+
let a;
|
|
1126
1141
|
try {
|
|
1127
|
-
const h =
|
|
1128
|
-
switch (
|
|
1142
|
+
const h = c.slice(0, -1).reduce((p, R) => p[R], t), g = c.reduce((p, R) => p[R], t);
|
|
1143
|
+
switch (o) {
|
|
1129
1144
|
case "GET":
|
|
1130
|
-
|
|
1145
|
+
a = g;
|
|
1131
1146
|
break;
|
|
1132
1147
|
case "SET":
|
|
1133
|
-
h[
|
|
1148
|
+
h[c.slice(-1)[0]] = P(s.data.value), a = !0;
|
|
1134
1149
|
break;
|
|
1135
1150
|
case "APPLY":
|
|
1136
|
-
|
|
1151
|
+
a = g.apply(h, l);
|
|
1137
1152
|
break;
|
|
1138
1153
|
case "CONSTRUCT":
|
|
1139
1154
|
{
|
|
1140
|
-
const p = new g(...
|
|
1141
|
-
|
|
1155
|
+
const p = new g(...l);
|
|
1156
|
+
a = ne(p);
|
|
1142
1157
|
}
|
|
1143
1158
|
break;
|
|
1144
1159
|
case "ENDPOINT":
|
|
1145
1160
|
{
|
|
1146
1161
|
const { port1: p, port2: R } = new MessageChannel();
|
|
1147
|
-
|
|
1162
|
+
H(t, R), a = qe(p, [p]);
|
|
1148
1163
|
}
|
|
1149
1164
|
break;
|
|
1150
1165
|
case "RELEASE":
|
|
1151
|
-
|
|
1166
|
+
a = void 0;
|
|
1152
1167
|
break;
|
|
1153
1168
|
default:
|
|
1154
1169
|
return;
|
|
1155
1170
|
}
|
|
1156
1171
|
} catch (h) {
|
|
1157
|
-
|
|
1172
|
+
a = { value: h, [S]: 0 };
|
|
1158
1173
|
}
|
|
1159
|
-
Promise.resolve(
|
|
1174
|
+
Promise.resolve(a).catch((h) => ({ value: h, [S]: 0 })).then((h) => {
|
|
1160
1175
|
const [g, p] = C(h);
|
|
1161
|
-
e.postMessage(Object.assign(Object.assign({}, g), { id:
|
|
1176
|
+
e.postMessage(Object.assign(Object.assign({}, g), { id: i }), p), o === "RELEASE" && (e.removeEventListener("message", n), ee(e), F in t && typeof t[F] == "function" && t[F]());
|
|
1162
1177
|
}).catch((h) => {
|
|
1163
1178
|
const [g, p] = C({
|
|
1164
1179
|
value: new TypeError("Unserializable return value"),
|
|
1165
|
-
[
|
|
1180
|
+
[S]: 0
|
|
1166
1181
|
});
|
|
1167
|
-
e.postMessage(Object.assign(Object.assign({}, g), { id:
|
|
1182
|
+
e.postMessage(Object.assign(Object.assign({}, g), { id: i }), p);
|
|
1168
1183
|
});
|
|
1169
1184
|
}), e.start && e.start();
|
|
1170
1185
|
}
|
|
1171
|
-
function
|
|
1186
|
+
function Ne(t) {
|
|
1172
1187
|
return t.constructor.name === "MessagePort";
|
|
1173
1188
|
}
|
|
1174
|
-
function
|
|
1175
|
-
|
|
1189
|
+
function ee(t) {
|
|
1190
|
+
Ne(t) && t.close();
|
|
1176
1191
|
}
|
|
1177
1192
|
function U(t, e) {
|
|
1178
|
-
return
|
|
1193
|
+
return L(t, [], e);
|
|
1179
1194
|
}
|
|
1180
|
-
function
|
|
1195
|
+
function x(t) {
|
|
1181
1196
|
if (t)
|
|
1182
1197
|
throw new Error("Proxy has been released and is not useable");
|
|
1183
1198
|
}
|
|
1184
|
-
function
|
|
1185
|
-
return
|
|
1199
|
+
function te(t) {
|
|
1200
|
+
return k(t, {
|
|
1186
1201
|
type: "RELEASE"
|
|
1187
1202
|
}).then(() => {
|
|
1188
|
-
|
|
1203
|
+
ee(t);
|
|
1189
1204
|
});
|
|
1190
1205
|
}
|
|
1191
1206
|
const T = /* @__PURE__ */ new WeakMap(), _ = "FinalizationRegistry" in globalThis && new FinalizationRegistry((t) => {
|
|
1192
1207
|
const e = (T.get(t) || 0) - 1;
|
|
1193
|
-
T.set(t, e), e === 0 &&
|
|
1208
|
+
T.set(t, e), e === 0 && te(t);
|
|
1194
1209
|
});
|
|
1195
|
-
function
|
|
1210
|
+
function We(t, e) {
|
|
1196
1211
|
const r = (T.get(e) || 0) + 1;
|
|
1197
1212
|
T.set(e, r), _ && _.register(t, e, t);
|
|
1198
1213
|
}
|
|
1199
|
-
function
|
|
1214
|
+
function $e(t) {
|
|
1200
1215
|
_ && _.unregister(t);
|
|
1201
1216
|
}
|
|
1202
|
-
function
|
|
1217
|
+
function L(t, e = [], r = function() {
|
|
1203
1218
|
}) {
|
|
1204
1219
|
let n = !1;
|
|
1205
1220
|
const s = new Proxy(r, {
|
|
1206
|
-
get(
|
|
1207
|
-
if (
|
|
1221
|
+
get(i, o) {
|
|
1222
|
+
if (x(n), o === Le)
|
|
1208
1223
|
return () => {
|
|
1209
|
-
|
|
1224
|
+
$e(s), te(t), n = !0;
|
|
1210
1225
|
};
|
|
1211
|
-
if (
|
|
1226
|
+
if (o === "then") {
|
|
1212
1227
|
if (e.length === 0)
|
|
1213
1228
|
return { then: () => s };
|
|
1214
|
-
const
|
|
1229
|
+
const c = k(t, {
|
|
1215
1230
|
type: "GET",
|
|
1216
|
-
path: e.map((
|
|
1231
|
+
path: e.map((l) => l.toString())
|
|
1217
1232
|
}).then(P);
|
|
1218
|
-
return
|
|
1233
|
+
return c.then.bind(c);
|
|
1219
1234
|
}
|
|
1220
|
-
return
|
|
1235
|
+
return L(t, [...e, o]);
|
|
1221
1236
|
},
|
|
1222
|
-
set(
|
|
1223
|
-
|
|
1224
|
-
const [
|
|
1225
|
-
return
|
|
1237
|
+
set(i, o, c) {
|
|
1238
|
+
x(n);
|
|
1239
|
+
const [l, a] = C(c);
|
|
1240
|
+
return k(t, {
|
|
1226
1241
|
type: "SET",
|
|
1227
|
-
path: [...e,
|
|
1228
|
-
value:
|
|
1229
|
-
},
|
|
1242
|
+
path: [...e, o].map((h) => h.toString()),
|
|
1243
|
+
value: l
|
|
1244
|
+
}, a).then(P);
|
|
1230
1245
|
},
|
|
1231
|
-
apply(
|
|
1232
|
-
|
|
1233
|
-
const
|
|
1234
|
-
if (
|
|
1235
|
-
return
|
|
1246
|
+
apply(i, o, c) {
|
|
1247
|
+
x(n);
|
|
1248
|
+
const l = e[e.length - 1];
|
|
1249
|
+
if (l === Me)
|
|
1250
|
+
return k(t, {
|
|
1236
1251
|
type: "ENDPOINT"
|
|
1237
1252
|
}).then(P);
|
|
1238
|
-
if (
|
|
1239
|
-
return
|
|
1240
|
-
const [
|
|
1241
|
-
return
|
|
1253
|
+
if (l === "bind")
|
|
1254
|
+
return L(t, e.slice(0, -1));
|
|
1255
|
+
const [a, h] = J(c);
|
|
1256
|
+
return k(t, {
|
|
1242
1257
|
type: "APPLY",
|
|
1243
1258
|
path: e.map((g) => g.toString()),
|
|
1244
|
-
argumentList:
|
|
1259
|
+
argumentList: a
|
|
1245
1260
|
}, h).then(P);
|
|
1246
1261
|
},
|
|
1247
|
-
construct(
|
|
1248
|
-
|
|
1249
|
-
const [
|
|
1250
|
-
return
|
|
1262
|
+
construct(i, o) {
|
|
1263
|
+
x(n);
|
|
1264
|
+
const [c, l] = J(o);
|
|
1265
|
+
return k(t, {
|
|
1251
1266
|
type: "CONSTRUCT",
|
|
1252
|
-
path: e.map((
|
|
1253
|
-
argumentList:
|
|
1254
|
-
},
|
|
1267
|
+
path: e.map((a) => a.toString()),
|
|
1268
|
+
argumentList: c
|
|
1269
|
+
}, l).then(P);
|
|
1255
1270
|
}
|
|
1256
1271
|
});
|
|
1257
|
-
return
|
|
1272
|
+
return We(s, t), s;
|
|
1258
1273
|
}
|
|
1259
|
-
function
|
|
1274
|
+
function De(t) {
|
|
1260
1275
|
return Array.prototype.concat.apply([], t);
|
|
1261
1276
|
}
|
|
1262
|
-
function
|
|
1277
|
+
function J(t) {
|
|
1263
1278
|
const e = t.map(C);
|
|
1264
|
-
return [e.map((r) => r[0]),
|
|
1279
|
+
return [e.map((r) => r[0]), De(e.map((r) => r[1]))];
|
|
1265
1280
|
}
|
|
1266
|
-
const
|
|
1267
|
-
function
|
|
1268
|
-
return
|
|
1281
|
+
const re = /* @__PURE__ */ new WeakMap();
|
|
1282
|
+
function qe(t, e) {
|
|
1283
|
+
return re.set(t, e), t;
|
|
1269
1284
|
}
|
|
1270
|
-
function
|
|
1271
|
-
return Object.assign(t, { [
|
|
1285
|
+
function ne(t) {
|
|
1286
|
+
return Object.assign(t, { [X]: !0 });
|
|
1272
1287
|
}
|
|
1273
|
-
function
|
|
1288
|
+
function se(t, e = globalThis, r = "*") {
|
|
1274
1289
|
return {
|
|
1275
1290
|
postMessage: (n, s) => t.postMessage(n, r, s),
|
|
1276
1291
|
addEventListener: e.addEventListener.bind(e),
|
|
@@ -1278,7 +1293,7 @@ function ne(t, e = globalThis, r = "*") {
|
|
|
1278
1293
|
};
|
|
1279
1294
|
}
|
|
1280
1295
|
function C(t) {
|
|
1281
|
-
for (const [e, r] of
|
|
1296
|
+
for (const [e, r] of v)
|
|
1282
1297
|
if (r.canHandle(t)) {
|
|
1283
1298
|
const [n, s] = r.serialize(t);
|
|
1284
1299
|
return [
|
|
@@ -1295,64 +1310,64 @@ function C(t) {
|
|
|
1295
1310
|
type: "RAW",
|
|
1296
1311
|
value: t
|
|
1297
1312
|
},
|
|
1298
|
-
|
|
1313
|
+
re.get(t) || []
|
|
1299
1314
|
];
|
|
1300
1315
|
}
|
|
1301
1316
|
function P(t) {
|
|
1302
1317
|
switch (t.type) {
|
|
1303
1318
|
case "HANDLER":
|
|
1304
|
-
return
|
|
1319
|
+
return v.get(t.name).deserialize(t.value);
|
|
1305
1320
|
case "RAW":
|
|
1306
1321
|
return t.value;
|
|
1307
1322
|
}
|
|
1308
1323
|
}
|
|
1309
|
-
function
|
|
1324
|
+
function k(t, e, r) {
|
|
1310
1325
|
return new Promise((n) => {
|
|
1311
|
-
const s =
|
|
1312
|
-
t.addEventListener("message", function o
|
|
1313
|
-
!
|
|
1326
|
+
const s = ze();
|
|
1327
|
+
t.addEventListener("message", function i(o) {
|
|
1328
|
+
!o.data || !o.data.id || o.data.id !== s || (t.removeEventListener("message", i), n(o.data));
|
|
1314
1329
|
}), t.start && t.start(), t.postMessage(Object.assign({ id: s }, e), r);
|
|
1315
1330
|
});
|
|
1316
1331
|
}
|
|
1317
|
-
function
|
|
1332
|
+
function ze() {
|
|
1318
1333
|
return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
|
|
1319
1334
|
}
|
|
1320
|
-
function
|
|
1321
|
-
|
|
1322
|
-
const e = t instanceof Worker ? t :
|
|
1335
|
+
function Je(t) {
|
|
1336
|
+
ie();
|
|
1337
|
+
const e = t instanceof Worker ? t : se(t), r = U(e), n = N(r);
|
|
1323
1338
|
return new Proxy(n, {
|
|
1324
|
-
get: (s,
|
|
1325
|
-
for (let
|
|
1339
|
+
get: (s, i) => i === "isConnected" ? async () => {
|
|
1340
|
+
for (let o = 0; o < 10; o++)
|
|
1326
1341
|
try {
|
|
1327
|
-
await
|
|
1342
|
+
await Be(r.isConnected(), 200);
|
|
1328
1343
|
break;
|
|
1329
1344
|
} catch {
|
|
1330
1345
|
}
|
|
1331
|
-
} : r[
|
|
1346
|
+
} : r[i]
|
|
1332
1347
|
});
|
|
1333
1348
|
}
|
|
1334
|
-
async function
|
|
1349
|
+
async function Be(t, e) {
|
|
1335
1350
|
return new Promise((r, n) => {
|
|
1336
1351
|
setTimeout(n, e), t.then(r);
|
|
1337
1352
|
});
|
|
1338
1353
|
}
|
|
1339
|
-
function
|
|
1340
|
-
|
|
1354
|
+
function Ke(t, e) {
|
|
1355
|
+
ie();
|
|
1341
1356
|
const r = Promise.resolve();
|
|
1342
|
-
let n;
|
|
1343
|
-
const
|
|
1344
|
-
n = a;
|
|
1345
|
-
}), o = N(t),
|
|
1346
|
-
get: (
|
|
1357
|
+
let n, s;
|
|
1358
|
+
const i = new Promise((l, a) => {
|
|
1359
|
+
n = l, s = a;
|
|
1360
|
+
}), o = N(t), c = new Proxy(o, {
|
|
1361
|
+
get: (l, a) => a === "isConnected" ? () => r : a === "isReady" ? () => i : a in l ? l[a] : e?.[a]
|
|
1347
1362
|
});
|
|
1348
|
-
return
|
|
1349
|
-
|
|
1350
|
-
typeof window < "u" ?
|
|
1351
|
-
), [n,
|
|
1363
|
+
return H(
|
|
1364
|
+
c,
|
|
1365
|
+
typeof window < "u" ? se(self.parent) : void 0
|
|
1366
|
+
), [n, s, c];
|
|
1352
1367
|
}
|
|
1353
|
-
let
|
|
1354
|
-
function
|
|
1355
|
-
|
|
1368
|
+
let K = !1;
|
|
1369
|
+
function ie() {
|
|
1370
|
+
K || (K = !0, v.set("EVENT", {
|
|
1356
1371
|
canHandle: (t) => t instanceof CustomEvent,
|
|
1357
1372
|
serialize: (t) => [
|
|
1358
1373
|
{
|
|
@@ -1361,17 +1376,17 @@ function se() {
|
|
|
1361
1376
|
[]
|
|
1362
1377
|
],
|
|
1363
1378
|
deserialize: (t) => t
|
|
1364
|
-
}),
|
|
1379
|
+
}), v.set("FUNCTION", {
|
|
1365
1380
|
canHandle: (t) => typeof t == "function",
|
|
1366
1381
|
serialize(t) {
|
|
1367
1382
|
console.debug("[Comlink][Performance] Proxying a function");
|
|
1368
1383
|
const { port1: e, port2: r } = new MessageChannel();
|
|
1369
|
-
return
|
|
1384
|
+
return H(t, e), [r, [r]];
|
|
1370
1385
|
},
|
|
1371
1386
|
deserialize(t) {
|
|
1372
1387
|
return t.start(), U(t);
|
|
1373
1388
|
}
|
|
1374
|
-
}),
|
|
1389
|
+
}), v.set("PHPResponse", {
|
|
1375
1390
|
canHandle: (t) => typeof t == "object" && t !== null && "headers" in t && "bytes" in t && "errors" in t && "exitCode" in t && "httpStatusCode" in t,
|
|
1376
1391
|
serialize(t) {
|
|
1377
1392
|
return [t.toRawData(), []];
|
|
@@ -1394,35 +1409,72 @@ function N(t) {
|
|
|
1394
1409
|
case "string":
|
|
1395
1410
|
return e[r];
|
|
1396
1411
|
default:
|
|
1397
|
-
return
|
|
1412
|
+
return ne(e[r]);
|
|
1398
1413
|
}
|
|
1399
1414
|
}
|
|
1400
1415
|
});
|
|
1401
1416
|
}
|
|
1402
|
-
async function
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1417
|
+
async function je(t = ye, e = "light") {
|
|
1418
|
+
if (e === "kitchen-sink")
|
|
1419
|
+
switch (t) {
|
|
1420
|
+
case "8.2":
|
|
1421
|
+
return await import("./php_8_2.js");
|
|
1422
|
+
case "8.1":
|
|
1423
|
+
return await import("./php_8_1.js");
|
|
1424
|
+
case "8.0":
|
|
1425
|
+
return await import("./php_8_0.js");
|
|
1426
|
+
case "7.4":
|
|
1427
|
+
return await import("./php_7_4.js");
|
|
1428
|
+
case "7.3":
|
|
1429
|
+
return await import("./php_7_3.js");
|
|
1430
|
+
case "7.2":
|
|
1431
|
+
return await import("./php_7_2.js");
|
|
1432
|
+
case "7.1":
|
|
1433
|
+
return await import("./php_7_1.js");
|
|
1434
|
+
case "7.0":
|
|
1435
|
+
return await import("./php_7_0.js");
|
|
1436
|
+
case "5.6":
|
|
1437
|
+
return await import("./php_5_6.js");
|
|
1438
|
+
}
|
|
1439
|
+
else
|
|
1440
|
+
switch (t) {
|
|
1441
|
+
case "8.2":
|
|
1442
|
+
return await import("./php_8_2.js");
|
|
1443
|
+
case "8.1":
|
|
1444
|
+
return await import("./php_8_1.js");
|
|
1445
|
+
case "8.0":
|
|
1446
|
+
return await import("./php_8_0.js");
|
|
1447
|
+
case "7.4":
|
|
1448
|
+
return await import("./php_7_4.js");
|
|
1449
|
+
case "7.3":
|
|
1450
|
+
return await import("./php_7_3.js");
|
|
1451
|
+
case "7.2":
|
|
1452
|
+
return await import("./php_7_2.js");
|
|
1453
|
+
case "7.1":
|
|
1454
|
+
return await import("./php_7_1.js");
|
|
1455
|
+
case "7.0":
|
|
1456
|
+
return await import("./php_7_0.js");
|
|
1457
|
+
case "5.6":
|
|
1458
|
+
return await import("./php_5_6.js");
|
|
1459
|
+
}
|
|
1423
1460
|
throw new Error(`Unsupported PHP version ${t}`);
|
|
1424
1461
|
}
|
|
1425
|
-
|
|
1462
|
+
const Ge = () => ({
|
|
1463
|
+
websocket: {
|
|
1464
|
+
decorator: (t) => class extends t {
|
|
1465
|
+
constructor() {
|
|
1466
|
+
try {
|
|
1467
|
+
super();
|
|
1468
|
+
} catch {
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
send() {
|
|
1472
|
+
return null;
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
});
|
|
1477
|
+
class O extends m {
|
|
1426
1478
|
/**
|
|
1427
1479
|
* Creates a new PHP instance.
|
|
1428
1480
|
*
|
|
@@ -1436,7 +1488,7 @@ class L extends m {
|
|
|
1436
1488
|
* @returns A new PHP instance
|
|
1437
1489
|
*/
|
|
1438
1490
|
static async load(e, r = {}) {
|
|
1439
|
-
return await
|
|
1491
|
+
return await O.loadSync(e, r).phpReady;
|
|
1440
1492
|
}
|
|
1441
1493
|
/**
|
|
1442
1494
|
* Does what load() does, but synchronously returns
|
|
@@ -1446,21 +1498,22 @@ class L extends m {
|
|
|
1446
1498
|
* @see load
|
|
1447
1499
|
*/
|
|
1448
1500
|
static loadSync(e, r = {}) {
|
|
1449
|
-
const n = new
|
|
1450
|
-
const
|
|
1451
|
-
|
|
1501
|
+
const n = new O(void 0, r.requestHandler), s = r.loadAllExtensions ? "kitchen-sink" : "light", o = (async () => {
|
|
1502
|
+
const c = await Promise.all([
|
|
1503
|
+
je(e, s),
|
|
1452
1504
|
...r.dataModules || []
|
|
1453
|
-
]), [
|
|
1454
|
-
r.downloadMonitor?.setModules(
|
|
1455
|
-
const
|
|
1456
|
-
|
|
1505
|
+
]), [l, ...a] = c;
|
|
1506
|
+
r.downloadMonitor?.setModules(c);
|
|
1507
|
+
const h = await _e(
|
|
1508
|
+
l,
|
|
1457
1509
|
{
|
|
1458
1510
|
...r.emscriptenOptions || {},
|
|
1459
|
-
...r.downloadMonitor?.getEmscriptenOptions() || {}
|
|
1511
|
+
...r.downloadMonitor?.getEmscriptenOptions() || {},
|
|
1512
|
+
...Ge()
|
|
1460
1513
|
},
|
|
1461
|
-
|
|
1514
|
+
a
|
|
1462
1515
|
);
|
|
1463
|
-
n.initializeRuntime(
|
|
1516
|
+
n.initializeRuntime(h);
|
|
1464
1517
|
})();
|
|
1465
1518
|
return {
|
|
1466
1519
|
php: n,
|
|
@@ -1469,7 +1522,7 @@ class L extends m {
|
|
|
1469
1522
|
}
|
|
1470
1523
|
}
|
|
1471
1524
|
const d = /* @__PURE__ */ new WeakMap();
|
|
1472
|
-
class
|
|
1525
|
+
class Xe {
|
|
1473
1526
|
/** @inheritDoc */
|
|
1474
1527
|
constructor(e, r) {
|
|
1475
1528
|
d.set(this, {
|
|
@@ -1560,96 +1613,65 @@ class Ve {
|
|
|
1560
1613
|
d.get(this).php.onMessage(e);
|
|
1561
1614
|
}
|
|
1562
1615
|
}
|
|
1563
|
-
function
|
|
1616
|
+
function Ve(t, e) {
|
|
1564
1617
|
return {
|
|
1565
1618
|
type: "response",
|
|
1566
1619
|
requestId: t,
|
|
1567
1620
|
response: e
|
|
1568
1621
|
};
|
|
1569
1622
|
}
|
|
1570
|
-
async function
|
|
1571
|
-
const
|
|
1572
|
-
if (!
|
|
1623
|
+
async function Ze(t, e, r) {
|
|
1624
|
+
const n = navigator.serviceWorker;
|
|
1625
|
+
if (!n)
|
|
1573
1626
|
throw new Error("Service workers are not supported in this browser.");
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
`[window] Reloading the currently registered Service Worker (expected version: ${n}, registered version: ${i})`
|
|
1580
|
-
);
|
|
1581
|
-
for (const a of o) {
|
|
1582
|
-
let c = !1;
|
|
1583
|
-
try {
|
|
1584
|
-
await a.update();
|
|
1585
|
-
} catch {
|
|
1586
|
-
c = !0;
|
|
1587
|
-
}
|
|
1588
|
-
const l = a.waiting || a.installing;
|
|
1589
|
-
l && !c && (i !== null ? l.postMessage("skip-waiting") : c = !0), c && (await a.unregister(), window.location.reload());
|
|
1590
|
-
}
|
|
1591
|
-
}
|
|
1592
|
-
} else
|
|
1593
|
-
console.debug(
|
|
1594
|
-
`[window] Creating a Service Worker registration (version: ${n})`
|
|
1595
|
-
), await s.register(r, {
|
|
1596
|
-
type: "module"
|
|
1597
|
-
});
|
|
1598
|
-
navigator.serviceWorker.addEventListener(
|
|
1627
|
+
console.debug("[window][sw] Registering a Service Worker"), await (await n.register(r, {
|
|
1628
|
+
type: "module",
|
|
1629
|
+
// Always bypass HTTP cache when fetching the new Service Worker script:
|
|
1630
|
+
updateViaCache: "none"
|
|
1631
|
+
})).update(), navigator.serviceWorker.addEventListener(
|
|
1599
1632
|
"message",
|
|
1600
|
-
async function(
|
|
1601
|
-
if (console.debug("Message from ServiceWorker",
|
|
1633
|
+
async function(o) {
|
|
1634
|
+
if (console.debug("[window][sw] Message from ServiceWorker", o), e && o.data.scope !== e)
|
|
1602
1635
|
return;
|
|
1603
|
-
const c =
|
|
1604
|
-
|
|
1636
|
+
const c = o.data.args || [], l = o.data.method, a = await t[l](...c);
|
|
1637
|
+
o.source.postMessage(Ve(o.data.requestId, a));
|
|
1605
1638
|
}
|
|
1606
|
-
),
|
|
1607
|
-
}
|
|
1608
|
-
async function qe() {
|
|
1609
|
-
try {
|
|
1610
|
-
return (await (await fetch("/version")).json()).version;
|
|
1611
|
-
} catch {
|
|
1612
|
-
return null;
|
|
1613
|
-
}
|
|
1639
|
+
), n.startMessages();
|
|
1614
1640
|
}
|
|
1615
|
-
function
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1641
|
+
async function et(t, e = {}) {
|
|
1642
|
+
t = Ye(t, e);
|
|
1643
|
+
const r = new Worker(t, { type: "module" });
|
|
1644
|
+
return new Promise((n, s) => {
|
|
1645
|
+
r.onerror = (o) => {
|
|
1646
|
+
const c = new Error(
|
|
1647
|
+
`WebWorker failed to load at ${t}. ${o.message ? `Original error: ${o.message}` : ""}`
|
|
1648
|
+
);
|
|
1649
|
+
c.filename = o.filename, s(c);
|
|
1650
|
+
};
|
|
1651
|
+
function i(o) {
|
|
1652
|
+
o.data === "worker-script-started" && (n(r), r.removeEventListener("message", i));
|
|
1653
|
+
}
|
|
1654
|
+
r.addEventListener("message", i);
|
|
1655
|
+
});
|
|
1630
1656
|
}
|
|
1631
|
-
function
|
|
1657
|
+
function Ye(t, e) {
|
|
1632
1658
|
if (!Object.entries(e).length)
|
|
1633
1659
|
return t + "";
|
|
1634
1660
|
const r = new URL(t);
|
|
1635
1661
|
for (const [n, s] of Object.entries(e))
|
|
1636
|
-
|
|
1662
|
+
if (Array.isArray(s))
|
|
1663
|
+
for (const i of s)
|
|
1664
|
+
r.searchParams.append(n, i);
|
|
1665
|
+
else
|
|
1666
|
+
r.searchParams.set(n, s);
|
|
1637
1667
|
return r.toString();
|
|
1638
1668
|
}
|
|
1639
|
-
async function Be(t) {
|
|
1640
|
-
const e = document.createElement("iframe"), r = "/" + t.split("/").slice(-1)[0];
|
|
1641
|
-
return e.src = r, e.style.display = "none", document.body.appendChild(e), await new Promise((n) => {
|
|
1642
|
-
e.addEventListener("load", n);
|
|
1643
|
-
}), e;
|
|
1644
|
-
}
|
|
1645
1669
|
export {
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
Ye as registerServiceWorker,
|
|
1654
|
-
Qe as spawnPHPWorkerThread
|
|
1670
|
+
O as WebPHP,
|
|
1671
|
+
Xe as WebPHPEndpoint,
|
|
1672
|
+
Je as consumeAPI,
|
|
1673
|
+
Ke as exposeAPI,
|
|
1674
|
+
je as getPHPLoaderModule,
|
|
1675
|
+
Ze as registerServiceWorker,
|
|
1676
|
+
et as spawnPHPWorkerThread
|
|
1655
1677
|
};
|