@php-wasm/web 0.1.61 → 0.2.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/index.d.ts +5 -12
- package/index.js +276 -283
- package/lib/worker-thread/spawn-php-worker-thread.d.ts +1 -9
- package/package.json +6 -2
- package/php_5_6.js +15 -1
- package/php_5_6.wasm +0 -0
- package/php_7_0.js +15 -1
- package/php_7_0.wasm +0 -0
- package/php_7_1.js +15 -1
- package/php_7_1.wasm +0 -0
- package/php_7_2.js +15 -1
- package/php_7_2.wasm +0 -0
- package/php_7_3.js +15 -1
- package/php_7_3.wasm +0 -0
- package/php_7_4.js +16 -2
- package/php_7_4.wasm +0 -0
- package/php_8_0.js +16 -2
- package/php_8_0.wasm +0 -0
- package/php_8_1.js +16 -2
- package/php_8_1.wasm +0 -0
- package/php_8_2.js +15 -1
- package/php_8_2.wasm +0 -0
- package/README.md +0 -31
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,11 +37,11 @@ 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];
|
|
@@ -48,48 +51,48 @@ function ae(t) {
|
|
|
48
51
|
} catch (o) {
|
|
49
52
|
if (!(o instanceof Error))
|
|
50
53
|
throw o;
|
|
51
|
-
|
|
52
|
-
return;
|
|
53
|
-
const i = le(
|
|
54
|
+
const i = he(
|
|
54
55
|
o,
|
|
55
56
|
t.lastAsyncifyStackSource?.stack
|
|
56
57
|
);
|
|
57
|
-
if (t.lastAsyncifyStackSource && (o.cause = t.lastAsyncifyStackSource),
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
58
|
+
if (t.lastAsyncifyStackSource && (o.cause = t.lastAsyncifyStackSource), e.hasListeners()) {
|
|
59
|
+
e.dispatchEvent(
|
|
60
|
+
new oe("error", {
|
|
61
|
+
error: o,
|
|
62
|
+
message: i
|
|
63
|
+
})
|
|
64
|
+
);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
throw ae(o) || pe(i), o;
|
|
65
68
|
}
|
|
66
69
|
};
|
|
67
70
|
}
|
|
68
71
|
return e;
|
|
69
72
|
}
|
|
70
|
-
let
|
|
71
|
-
function
|
|
72
|
-
return
|
|
73
|
+
let O = [];
|
|
74
|
+
function ue() {
|
|
75
|
+
return O;
|
|
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
|
+
`), O = me(
|
|
83
86
|
e || t.stack || ""
|
|
84
87
|
);
|
|
85
|
-
for (const n of
|
|
88
|
+
for (const n of O)
|
|
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) => {
|
|
@@ -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
|
/**
|
|
@@ -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 Re {
|
|
317
320
|
#e;
|
|
318
321
|
#t;
|
|
319
322
|
#n;
|
|
@@ -328,7 +331,7 @@ class be {
|
|
|
328
331
|
* @param config - Request Handler configuration.
|
|
329
332
|
*/
|
|
330
333
|
constructor(e, r = {}) {
|
|
331
|
-
this.#a = new
|
|
334
|
+
this.#a = new Pe({ concurrency: 1 });
|
|
332
335
|
const {
|
|
333
336
|
documentRoot: n = "/www/",
|
|
334
337
|
absoluteUrl: s = typeof location == "object" ? location?.href : "",
|
|
@@ -337,10 +340,10 @@ class be {
|
|
|
337
340
|
this.php = e, this.#e = n, this.#c = o;
|
|
338
341
|
const i = new URL(s);
|
|
339
342
|
this.#n = i.hostname, this.#r = i.port ? Number(i.port) : i.protocol === "https:" ? 443 : 80, this.#t = (i.protocol || "").replace(":", "");
|
|
340
|
-
const
|
|
343
|
+
const c = this.#r !== 443 && this.#r !== 80;
|
|
341
344
|
this.#i = [
|
|
342
345
|
this.#n,
|
|
343
|
-
|
|
346
|
+
c ? `:${this.#r}` : ""
|
|
344
347
|
].join(""), this.#s = i.pathname.replace(/\/+$/, ""), this.#o = [
|
|
345
348
|
`${this.#t}://`,
|
|
346
349
|
this.#i,
|
|
@@ -371,7 +374,7 @@ class be {
|
|
|
371
374
|
async request(e) {
|
|
372
375
|
const r = e.url.startsWith("http://") || e.url.startsWith("https://"), n = new URL(
|
|
373
376
|
e.url,
|
|
374
|
-
r ? void 0 :
|
|
377
|
+
r ? void 0 : be
|
|
375
378
|
), s = G(
|
|
376
379
|
n.pathname,
|
|
377
380
|
this.#s
|
|
@@ -424,30 +427,30 @@ class be {
|
|
|
424
427
|
let s = "GET";
|
|
425
428
|
const o = {
|
|
426
429
|
host: this.#i,
|
|
427
|
-
...
|
|
430
|
+
...Q(e.headers || {})
|
|
428
431
|
}, i = [];
|
|
429
432
|
if (e.files && Object.keys(e.files).length) {
|
|
430
433
|
s = "POST";
|
|
431
|
-
for (const
|
|
432
|
-
const h = e.files[
|
|
434
|
+
for (const a in e.files) {
|
|
435
|
+
const h = e.files[a];
|
|
433
436
|
i.push({
|
|
434
|
-
key:
|
|
437
|
+
key: a,
|
|
435
438
|
name: h.name,
|
|
436
439
|
type: h.type,
|
|
437
440
|
data: new Uint8Array(await h.arrayBuffer())
|
|
438
441
|
});
|
|
439
442
|
}
|
|
440
|
-
o["content-type"]?.startsWith("multipart/form-data") && (e.formData =
|
|
443
|
+
o["content-type"]?.startsWith("multipart/form-data") && (e.formData = ke(
|
|
441
444
|
e.body || ""
|
|
442
445
|
), o["content-type"] = "application/x-www-form-urlencoded", delete e.body);
|
|
443
446
|
}
|
|
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
447
|
let c;
|
|
448
|
+
e.formData !== void 0 ? (s = "POST", o["content-type"] = o["content-type"] || "application/x-www-form-urlencoded", c = new URLSearchParams(
|
|
449
|
+
e.formData
|
|
450
|
+
).toString()) : c = e.body;
|
|
451
|
+
let l;
|
|
449
452
|
try {
|
|
450
|
-
|
|
453
|
+
l = this.#h(r.pathname);
|
|
451
454
|
} catch {
|
|
452
455
|
return new b(
|
|
453
456
|
404,
|
|
@@ -456,15 +459,15 @@ class be {
|
|
|
456
459
|
);
|
|
457
460
|
}
|
|
458
461
|
return await this.php.run({
|
|
459
|
-
relativeUri:
|
|
462
|
+
relativeUri: Ee(
|
|
460
463
|
j(r),
|
|
461
464
|
this.#s
|
|
462
465
|
),
|
|
463
466
|
protocol: this.#t,
|
|
464
467
|
method: e.method || s,
|
|
465
|
-
body:
|
|
468
|
+
body: c,
|
|
466
469
|
fileInfos: i,
|
|
467
|
-
scriptPath:
|
|
470
|
+
scriptPath: l,
|
|
468
471
|
headers: o
|
|
469
472
|
});
|
|
470
473
|
} finally {
|
|
@@ -491,7 +494,7 @@ class be {
|
|
|
491
494
|
return `${this.#e}/index.php`;
|
|
492
495
|
}
|
|
493
496
|
}
|
|
494
|
-
function
|
|
497
|
+
function ke(t) {
|
|
495
498
|
const e = {}, r = t.match(/--(.*)\r\n/);
|
|
496
499
|
if (!r)
|
|
497
500
|
return e;
|
|
@@ -499,10 +502,10 @@ function Ee(t) {
|
|
|
499
502
|
return s.shift(), s.pop(), s.forEach((o) => {
|
|
500
503
|
const i = o.indexOf(`\r
|
|
501
504
|
\r
|
|
502
|
-
`),
|
|
503
|
-
if (
|
|
504
|
-
const h =
|
|
505
|
-
e[h] =
|
|
505
|
+
`), c = o.substring(0, i).trim(), l = o.substring(i + 4).trim(), a = c.match(/name="([^"]+)"/);
|
|
506
|
+
if (a) {
|
|
507
|
+
const h = a[1];
|
|
508
|
+
e[h] = l;
|
|
506
509
|
}
|
|
507
510
|
}), e;
|
|
508
511
|
}
|
|
@@ -631,58 +634,60 @@ function y(t = "") {
|
|
|
631
634
|
s.value = function(...i) {
|
|
632
635
|
try {
|
|
633
636
|
return o.apply(this, i);
|
|
634
|
-
} catch (
|
|
635
|
-
const
|
|
636
|
-
if (
|
|
637
|
-
const
|
|
638
|
-
throw new Error(`${g}: ${
|
|
639
|
-
cause:
|
|
637
|
+
} catch (c) {
|
|
638
|
+
const l = typeof c == "object" ? c?.errno : null;
|
|
639
|
+
if (l in V) {
|
|
640
|
+
const a = V[l], h = typeof i[0] == "string" ? i[0] : null, g = h !== null ? t.replaceAll("{path}", h) : t;
|
|
641
|
+
throw new Error(`${g}: ${a}`, {
|
|
642
|
+
cause: c
|
|
640
643
|
});
|
|
641
644
|
}
|
|
642
|
-
throw
|
|
645
|
+
throw c;
|
|
643
646
|
}
|
|
644
647
|
};
|
|
645
648
|
};
|
|
646
649
|
}
|
|
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);
|
|
650
|
+
async function xe(t, e = {}, r = []) {
|
|
651
|
+
const [n, s, o] = Y(), [i, c] = Y(), l = t.init(Te, {
|
|
652
|
+
onAbort(a) {
|
|
653
|
+
o(a), c(), console.error(a);
|
|
656
654
|
},
|
|
657
655
|
ENV: {},
|
|
658
656
|
// Emscripten sometimes prepends a '/' to the path, which
|
|
659
657
|
// breaks vite dev mode. An identity `locateFile` function
|
|
660
658
|
// fixes it.
|
|
661
|
-
locateFile: (
|
|
659
|
+
locateFile: (a) => a,
|
|
662
660
|
...e,
|
|
663
661
|
noInitialRun: !0,
|
|
664
662
|
onRuntimeInitialized() {
|
|
665
|
-
e.onRuntimeInitialized && e.onRuntimeInitialized(),
|
|
663
|
+
e.onRuntimeInitialized && e.onRuntimeInitialized(), s();
|
|
666
664
|
},
|
|
667
|
-
monitorRunDependencies(
|
|
668
|
-
|
|
665
|
+
monitorRunDependencies(a) {
|
|
666
|
+
a === 0 && (delete l.monitorRunDependencies, c());
|
|
669
667
|
}
|
|
670
668
|
});
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
669
|
+
return await Promise.all(
|
|
670
|
+
r.map(
|
|
671
|
+
({ default: a }) => a(l)
|
|
672
|
+
)
|
|
673
|
+
), r.length || c(), await i, await n, M.push(l), M.length - 1;
|
|
674
674
|
}
|
|
675
|
-
const
|
|
676
|
-
function
|
|
677
|
-
return
|
|
675
|
+
const M = [];
|
|
676
|
+
function Se(t) {
|
|
677
|
+
return M[t];
|
|
678
678
|
}
|
|
679
|
-
const
|
|
679
|
+
const Te = function() {
|
|
680
680
|
return typeof process < "u" && process.release?.name === "node" ? "NODE" : typeof window < "u" ? "WEB" : typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope ? "WORKER" : "NODE";
|
|
681
|
-
}()
|
|
682
|
-
|
|
683
|
-
|
|
681
|
+
}(), Y = () => {
|
|
682
|
+
const t = [], e = new Promise((r, n) => {
|
|
683
|
+
t.push(r, n);
|
|
684
|
+
});
|
|
685
|
+
return t.unshift(e), t;
|
|
686
|
+
};
|
|
687
|
+
var _e = Object.defineProperty, Ce = Object.getOwnPropertyDescriptor, w = (t, e, r, n) => {
|
|
688
|
+
for (var s = n > 1 ? void 0 : n ? Ce(e, r) : e, o = t.length - 1, i; o >= 0; o--)
|
|
684
689
|
(i = t[o]) && (s = (n ? i(e, r, s) : i(s)) || s);
|
|
685
|
-
return n && s &&
|
|
690
|
+
return n && s && _e(e, r, s), s;
|
|
686
691
|
};
|
|
687
692
|
const f = "string", E = "number", u = Symbol("__private__dont__use");
|
|
688
693
|
class m {
|
|
@@ -694,8 +699,8 @@ class m {
|
|
|
694
699
|
* @param serverOptions - Optional. Options for the PHPRequestHandler. If undefined, no request handler will be initialized.
|
|
695
700
|
*/
|
|
696
701
|
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
|
|
702
|
+
this.#e = [], this.#t = !1, this.#n = null, this.#r = {}, this.#i = [], e !== void 0 && this.initializeRuntime(e), r && (this.requestHandler = new we(
|
|
703
|
+
new Re(this, r)
|
|
699
704
|
));
|
|
700
705
|
}
|
|
701
706
|
#e;
|
|
@@ -728,13 +733,13 @@ class m {
|
|
|
728
733
|
initializeRuntime(e) {
|
|
729
734
|
if (this[u])
|
|
730
735
|
throw new Error("PHP runtime already initialized.");
|
|
731
|
-
const r =
|
|
736
|
+
const r = Se(e);
|
|
732
737
|
if (!r)
|
|
733
738
|
throw new Error("Invalid PHP runtime id.");
|
|
734
739
|
this[u] = r, r.onMessage = (n) => {
|
|
735
740
|
for (const s of this.#i)
|
|
736
741
|
s(n);
|
|
737
|
-
}, this.#n =
|
|
742
|
+
}, this.#n = le(r);
|
|
738
743
|
}
|
|
739
744
|
/** @inheritDoc */
|
|
740
745
|
setPhpIniPath(e) {
|
|
@@ -768,7 +773,7 @@ class m {
|
|
|
768
773
|
this.#t || (this.#s(), this.#t = !0), this.#d(e.scriptPath || ""), this.#a(e.relativeUri || ""), this.#l(e.method || "GET");
|
|
769
774
|
const { host: r, ...n } = {
|
|
770
775
|
host: "example.com:443",
|
|
771
|
-
...
|
|
776
|
+
...Q(e.headers || {})
|
|
772
777
|
};
|
|
773
778
|
if (this.#c(r, e.protocol || "http"), this.#u(n), e.body && this.#h(e.body), e.fileInfos)
|
|
774
779
|
for (const s of e.fileInfos)
|
|
@@ -800,8 +805,8 @@ class m {
|
|
|
800
805
|
for (const s of r.headers) {
|
|
801
806
|
if (!s.includes(": "))
|
|
802
807
|
continue;
|
|
803
|
-
const o = s.indexOf(": "), i = s.substring(0, o).toLowerCase(),
|
|
804
|
-
i in n || (n[i] = []), n[i].push(
|
|
808
|
+
const o = s.indexOf(": "), i = s.substring(0, o).toLowerCase(), c = s.substring(o + 2);
|
|
809
|
+
i in n || (n[i] = []), n[i].push(c);
|
|
805
810
|
}
|
|
806
811
|
return {
|
|
807
812
|
headers: n,
|
|
@@ -921,12 +926,12 @@ class m {
|
|
|
921
926
|
#p(e) {
|
|
922
927
|
const { key: r, name: n, type: s, data: o } = e, i = `/tmp/${Math.random().toFixed(20)}`;
|
|
923
928
|
this.writeFile(i, o);
|
|
924
|
-
const
|
|
929
|
+
const c = 0;
|
|
925
930
|
this[u].ccall(
|
|
926
931
|
"wasm_add_uploaded_file",
|
|
927
932
|
null,
|
|
928
933
|
[f, f, f, f, E, E],
|
|
929
|
-
[r, n, s, i,
|
|
934
|
+
[r, n, s, i, c, o.byteLength]
|
|
930
935
|
);
|
|
931
936
|
}
|
|
932
937
|
#m(e) {
|
|
@@ -941,31 +946,31 @@ class m {
|
|
|
941
946
|
let e, r;
|
|
942
947
|
try {
|
|
943
948
|
e = await new Promise((o, i) => {
|
|
944
|
-
r = (
|
|
945
|
-
const
|
|
946
|
-
|
|
949
|
+
r = (l) => {
|
|
950
|
+
const a = new Error("Rethrown");
|
|
951
|
+
a.cause = l.error, a.betterMessage = l.message, i(a);
|
|
947
952
|
}, this.#n?.addEventListener(
|
|
948
953
|
"error",
|
|
949
954
|
r
|
|
950
955
|
);
|
|
951
|
-
const
|
|
956
|
+
const c = this[u].ccall(
|
|
952
957
|
"wasm_sapi_handle_request",
|
|
953
958
|
E,
|
|
954
959
|
[],
|
|
955
960
|
[]
|
|
956
961
|
);
|
|
957
|
-
return
|
|
962
|
+
return c instanceof Promise ? c.then(o, i) : o(c);
|
|
958
963
|
});
|
|
959
964
|
} catch (o) {
|
|
960
|
-
for (const
|
|
961
|
-
typeof this[
|
|
965
|
+
for (const a in this)
|
|
966
|
+
typeof this[a] == "function" && (this[a] = () => {
|
|
962
967
|
throw new Error(
|
|
963
968
|
"PHP runtime has crashed – see the earlier error for details."
|
|
964
969
|
);
|
|
965
970
|
});
|
|
966
|
-
this.functionsMaybeMissingFromAsyncify =
|
|
967
|
-
const i = o,
|
|
968
|
-
throw
|
|
971
|
+
this.functionsMaybeMissingFromAsyncify = ue();
|
|
972
|
+
const i = o, c = "betterMessage" in i ? i.betterMessage : i.message, l = new Error(c);
|
|
973
|
+
throw l.cause = i, l;
|
|
969
974
|
} finally {
|
|
970
975
|
this.#n?.removeEventListener("error", r), this.#r = {};
|
|
971
976
|
}
|
|
@@ -1067,7 +1072,7 @@ w([
|
|
|
1067
1072
|
w([
|
|
1068
1073
|
y('Could not stat "{path}"')
|
|
1069
1074
|
], m.prototype, "fileExists", 1);
|
|
1070
|
-
function
|
|
1075
|
+
function Q(t) {
|
|
1071
1076
|
const e = {};
|
|
1072
1077
|
for (const r in t)
|
|
1073
1078
|
e[r.toLowerCase()] = t[r];
|
|
@@ -1078,8 +1083,8 @@ function K(t) {
|
|
|
1078
1083
|
* Copyright 2019 Google LLC
|
|
1079
1084
|
* SPDX-License-Identifier: Apache-2.0
|
|
1080
1085
|
*/
|
|
1081
|
-
const
|
|
1082
|
-
canHandle: (t) =>
|
|
1086
|
+
const X = Symbol("Comlink.proxy"), Fe = Symbol("Comlink.endpoint"), He = Symbol("Comlink.releaseProxy"), H = Symbol("Comlink.finalizer"), S = Symbol("Comlink.thrown"), Z = (t) => typeof t == "object" && t !== null || typeof t == "function", Oe = {
|
|
1087
|
+
canHandle: (t) => Z(t) && t[X],
|
|
1083
1088
|
serialize(t) {
|
|
1084
1089
|
const { port1: e, port2: r } = new MessageChannel();
|
|
1085
1090
|
return F(t, e), [r, [r]];
|
|
@@ -1087,8 +1092,8 @@ const Q = Symbol("Comlink.proxy"), _e = Symbol("Comlink.endpoint"), Ce = Symbol(
|
|
|
1087
1092
|
deserialize(t) {
|
|
1088
1093
|
return t.start(), U(t);
|
|
1089
1094
|
}
|
|
1090
|
-
},
|
|
1091
|
-
canHandle: (t) =>
|
|
1095
|
+
}, Me = {
|
|
1096
|
+
canHandle: (t) => Z(t) && S in t,
|
|
1092
1097
|
serialize({ value: t }) {
|
|
1093
1098
|
let e;
|
|
1094
1099
|
return t instanceof Error ? e = {
|
|
@@ -1103,11 +1108,11 @@ const Q = Symbol("Comlink.proxy"), _e = Symbol("Comlink.endpoint"), Ce = Symbol(
|
|
|
1103
1108
|
deserialize(t) {
|
|
1104
1109
|
throw t.isError ? Object.assign(new Error(t.value.message), t.value) : t.value;
|
|
1105
1110
|
}
|
|
1106
|
-
},
|
|
1107
|
-
["proxy",
|
|
1108
|
-
["throw",
|
|
1111
|
+
}, v = /* @__PURE__ */ new Map([
|
|
1112
|
+
["proxy", Oe],
|
|
1113
|
+
["throw", Me]
|
|
1109
1114
|
]);
|
|
1110
|
-
function
|
|
1115
|
+
function Ae(t, e) {
|
|
1111
1116
|
for (const r of t)
|
|
1112
1117
|
if (e === r || r === "*" || r instanceof RegExp && r.test(e))
|
|
1113
1118
|
return !0;
|
|
@@ -1117,160 +1122,160 @@ function F(t, e = globalThis, r = ["*"]) {
|
|
|
1117
1122
|
e.addEventListener("message", function n(s) {
|
|
1118
1123
|
if (!s || !s.data)
|
|
1119
1124
|
return;
|
|
1120
|
-
if (!
|
|
1125
|
+
if (!Ae(r, s.origin)) {
|
|
1121
1126
|
console.warn(`Invalid origin '${s.origin}' for comlink proxy`);
|
|
1122
1127
|
return;
|
|
1123
1128
|
}
|
|
1124
|
-
const { id: o, type: i, path:
|
|
1125
|
-
let
|
|
1129
|
+
const { id: o, type: i, path: c } = Object.assign({ path: [] }, s.data), l = (s.data.argumentList || []).map(P);
|
|
1130
|
+
let a;
|
|
1126
1131
|
try {
|
|
1127
|
-
const h =
|
|
1132
|
+
const h = c.slice(0, -1).reduce((p, k) => p[k], t), g = c.reduce((p, k) => p[k], t);
|
|
1128
1133
|
switch (i) {
|
|
1129
1134
|
case "GET":
|
|
1130
|
-
|
|
1135
|
+
a = g;
|
|
1131
1136
|
break;
|
|
1132
1137
|
case "SET":
|
|
1133
|
-
h[
|
|
1138
|
+
h[c.slice(-1)[0]] = P(s.data.value), a = !0;
|
|
1134
1139
|
break;
|
|
1135
1140
|
case "APPLY":
|
|
1136
|
-
|
|
1141
|
+
a = g.apply(h, l);
|
|
1137
1142
|
break;
|
|
1138
1143
|
case "CONSTRUCT":
|
|
1139
1144
|
{
|
|
1140
|
-
const p = new g(...
|
|
1141
|
-
|
|
1145
|
+
const p = new g(...l);
|
|
1146
|
+
a = ne(p);
|
|
1142
1147
|
}
|
|
1143
1148
|
break;
|
|
1144
1149
|
case "ENDPOINT":
|
|
1145
1150
|
{
|
|
1146
|
-
const { port1: p, port2:
|
|
1147
|
-
F(t,
|
|
1151
|
+
const { port1: p, port2: k } = new MessageChannel();
|
|
1152
|
+
F(t, k), a = We(p, [p]);
|
|
1148
1153
|
}
|
|
1149
1154
|
break;
|
|
1150
1155
|
case "RELEASE":
|
|
1151
|
-
|
|
1156
|
+
a = void 0;
|
|
1152
1157
|
break;
|
|
1153
1158
|
default:
|
|
1154
1159
|
return;
|
|
1155
1160
|
}
|
|
1156
1161
|
} catch (h) {
|
|
1157
|
-
|
|
1162
|
+
a = { value: h, [S]: 0 };
|
|
1158
1163
|
}
|
|
1159
|
-
Promise.resolve(
|
|
1164
|
+
Promise.resolve(a).catch((h) => ({ value: h, [S]: 0 })).then((h) => {
|
|
1160
1165
|
const [g, p] = C(h);
|
|
1161
|
-
e.postMessage(Object.assign(Object.assign({}, g), { id: o }), p), i === "RELEASE" && (e.removeEventListener("message", n),
|
|
1166
|
+
e.postMessage(Object.assign(Object.assign({}, g), { id: o }), p), i === "RELEASE" && (e.removeEventListener("message", n), ee(e), H in t && typeof t[H] == "function" && t[H]());
|
|
1162
1167
|
}).catch((h) => {
|
|
1163
1168
|
const [g, p] = C({
|
|
1164
1169
|
value: new TypeError("Unserializable return value"),
|
|
1165
|
-
[
|
|
1170
|
+
[S]: 0
|
|
1166
1171
|
});
|
|
1167
1172
|
e.postMessage(Object.assign(Object.assign({}, g), { id: o }), p);
|
|
1168
1173
|
});
|
|
1169
1174
|
}), e.start && e.start();
|
|
1170
1175
|
}
|
|
1171
|
-
function
|
|
1176
|
+
function Le(t) {
|
|
1172
1177
|
return t.constructor.name === "MessagePort";
|
|
1173
1178
|
}
|
|
1174
|
-
function
|
|
1175
|
-
|
|
1179
|
+
function ee(t) {
|
|
1180
|
+
Le(t) && t.close();
|
|
1176
1181
|
}
|
|
1177
1182
|
function U(t, e) {
|
|
1178
|
-
return
|
|
1183
|
+
return A(t, [], e);
|
|
1179
1184
|
}
|
|
1180
|
-
function
|
|
1185
|
+
function x(t) {
|
|
1181
1186
|
if (t)
|
|
1182
1187
|
throw new Error("Proxy has been released and is not useable");
|
|
1183
1188
|
}
|
|
1184
|
-
function
|
|
1185
|
-
return
|
|
1189
|
+
function te(t) {
|
|
1190
|
+
return R(t, {
|
|
1186
1191
|
type: "RELEASE"
|
|
1187
1192
|
}).then(() => {
|
|
1188
|
-
|
|
1193
|
+
ee(t);
|
|
1189
1194
|
});
|
|
1190
1195
|
}
|
|
1191
1196
|
const T = /* @__PURE__ */ new WeakMap(), _ = "FinalizationRegistry" in globalThis && new FinalizationRegistry((t) => {
|
|
1192
1197
|
const e = (T.get(t) || 0) - 1;
|
|
1193
|
-
T.set(t, e), e === 0 &&
|
|
1198
|
+
T.set(t, e), e === 0 && te(t);
|
|
1194
1199
|
});
|
|
1195
|
-
function
|
|
1200
|
+
function Ie(t, e) {
|
|
1196
1201
|
const r = (T.get(e) || 0) + 1;
|
|
1197
1202
|
T.set(e, r), _ && _.register(t, e, t);
|
|
1198
1203
|
}
|
|
1199
|
-
function
|
|
1204
|
+
function Ue(t) {
|
|
1200
1205
|
_ && _.unregister(t);
|
|
1201
1206
|
}
|
|
1202
|
-
function
|
|
1207
|
+
function A(t, e = [], r = function() {
|
|
1203
1208
|
}) {
|
|
1204
1209
|
let n = !1;
|
|
1205
1210
|
const s = new Proxy(r, {
|
|
1206
1211
|
get(o, i) {
|
|
1207
|
-
if (
|
|
1212
|
+
if (x(n), i === He)
|
|
1208
1213
|
return () => {
|
|
1209
|
-
|
|
1214
|
+
Ue(s), te(t), n = !0;
|
|
1210
1215
|
};
|
|
1211
1216
|
if (i === "then") {
|
|
1212
1217
|
if (e.length === 0)
|
|
1213
1218
|
return { then: () => s };
|
|
1214
|
-
const
|
|
1219
|
+
const c = R(t, {
|
|
1215
1220
|
type: "GET",
|
|
1216
|
-
path: e.map((
|
|
1221
|
+
path: e.map((l) => l.toString())
|
|
1217
1222
|
}).then(P);
|
|
1218
|
-
return
|
|
1223
|
+
return c.then.bind(c);
|
|
1219
1224
|
}
|
|
1220
|
-
return
|
|
1225
|
+
return A(t, [...e, i]);
|
|
1221
1226
|
},
|
|
1222
|
-
set(o, i,
|
|
1223
|
-
|
|
1224
|
-
const [
|
|
1225
|
-
return
|
|
1227
|
+
set(o, i, c) {
|
|
1228
|
+
x(n);
|
|
1229
|
+
const [l, a] = C(c);
|
|
1230
|
+
return R(t, {
|
|
1226
1231
|
type: "SET",
|
|
1227
1232
|
path: [...e, i].map((h) => h.toString()),
|
|
1228
|
-
value:
|
|
1229
|
-
},
|
|
1233
|
+
value: l
|
|
1234
|
+
}, a).then(P);
|
|
1230
1235
|
},
|
|
1231
|
-
apply(o, i,
|
|
1232
|
-
|
|
1233
|
-
const
|
|
1234
|
-
if (
|
|
1235
|
-
return
|
|
1236
|
+
apply(o, i, c) {
|
|
1237
|
+
x(n);
|
|
1238
|
+
const l = e[e.length - 1];
|
|
1239
|
+
if (l === Fe)
|
|
1240
|
+
return R(t, {
|
|
1236
1241
|
type: "ENDPOINT"
|
|
1237
1242
|
}).then(P);
|
|
1238
|
-
if (
|
|
1239
|
-
return
|
|
1240
|
-
const [
|
|
1241
|
-
return
|
|
1243
|
+
if (l === "bind")
|
|
1244
|
+
return A(t, e.slice(0, -1));
|
|
1245
|
+
const [a, h] = J(c);
|
|
1246
|
+
return R(t, {
|
|
1242
1247
|
type: "APPLY",
|
|
1243
1248
|
path: e.map((g) => g.toString()),
|
|
1244
|
-
argumentList:
|
|
1249
|
+
argumentList: a
|
|
1245
1250
|
}, h).then(P);
|
|
1246
1251
|
},
|
|
1247
1252
|
construct(o, i) {
|
|
1248
|
-
|
|
1249
|
-
const [
|
|
1250
|
-
return
|
|
1253
|
+
x(n);
|
|
1254
|
+
const [c, l] = J(i);
|
|
1255
|
+
return R(t, {
|
|
1251
1256
|
type: "CONSTRUCT",
|
|
1252
|
-
path: e.map((
|
|
1253
|
-
argumentList:
|
|
1254
|
-
},
|
|
1257
|
+
path: e.map((a) => a.toString()),
|
|
1258
|
+
argumentList: c
|
|
1259
|
+
}, l).then(P);
|
|
1255
1260
|
}
|
|
1256
1261
|
});
|
|
1257
|
-
return
|
|
1262
|
+
return Ie(s, t), s;
|
|
1258
1263
|
}
|
|
1259
|
-
function
|
|
1264
|
+
function Ne(t) {
|
|
1260
1265
|
return Array.prototype.concat.apply([], t);
|
|
1261
1266
|
}
|
|
1262
|
-
function
|
|
1267
|
+
function J(t) {
|
|
1263
1268
|
const e = t.map(C);
|
|
1264
|
-
return [e.map((r) => r[0]),
|
|
1269
|
+
return [e.map((r) => r[0]), Ne(e.map((r) => r[1]))];
|
|
1265
1270
|
}
|
|
1266
|
-
const
|
|
1267
|
-
function
|
|
1268
|
-
return
|
|
1271
|
+
const re = /* @__PURE__ */ new WeakMap();
|
|
1272
|
+
function We(t, e) {
|
|
1273
|
+
return re.set(t, e), t;
|
|
1269
1274
|
}
|
|
1270
|
-
function
|
|
1271
|
-
return Object.assign(t, { [
|
|
1275
|
+
function ne(t) {
|
|
1276
|
+
return Object.assign(t, { [X]: !0 });
|
|
1272
1277
|
}
|
|
1273
|
-
function
|
|
1278
|
+
function se(t, e = globalThis, r = "*") {
|
|
1274
1279
|
return {
|
|
1275
1280
|
postMessage: (n, s) => t.postMessage(n, r, s),
|
|
1276
1281
|
addEventListener: e.addEventListener.bind(e),
|
|
@@ -1278,7 +1283,7 @@ function ne(t, e = globalThis, r = "*") {
|
|
|
1278
1283
|
};
|
|
1279
1284
|
}
|
|
1280
1285
|
function C(t) {
|
|
1281
|
-
for (const [e, r] of
|
|
1286
|
+
for (const [e, r] of v)
|
|
1282
1287
|
if (r.canHandle(t)) {
|
|
1283
1288
|
const [n, s] = r.serialize(t);
|
|
1284
1289
|
return [
|
|
@@ -1295,64 +1300,64 @@ function C(t) {
|
|
|
1295
1300
|
type: "RAW",
|
|
1296
1301
|
value: t
|
|
1297
1302
|
},
|
|
1298
|
-
|
|
1303
|
+
re.get(t) || []
|
|
1299
1304
|
];
|
|
1300
1305
|
}
|
|
1301
1306
|
function P(t) {
|
|
1302
1307
|
switch (t.type) {
|
|
1303
1308
|
case "HANDLER":
|
|
1304
|
-
return
|
|
1309
|
+
return v.get(t.name).deserialize(t.value);
|
|
1305
1310
|
case "RAW":
|
|
1306
1311
|
return t.value;
|
|
1307
1312
|
}
|
|
1308
1313
|
}
|
|
1309
|
-
function
|
|
1314
|
+
function R(t, e, r) {
|
|
1310
1315
|
return new Promise((n) => {
|
|
1311
|
-
const s =
|
|
1316
|
+
const s = $e();
|
|
1312
1317
|
t.addEventListener("message", function o(i) {
|
|
1313
1318
|
!i.data || !i.data.id || i.data.id !== s || (t.removeEventListener("message", o), n(i.data));
|
|
1314
1319
|
}), t.start && t.start(), t.postMessage(Object.assign({ id: s }, e), r);
|
|
1315
1320
|
});
|
|
1316
1321
|
}
|
|
1317
|
-
function
|
|
1322
|
+
function $e() {
|
|
1318
1323
|
return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
|
|
1319
1324
|
}
|
|
1320
|
-
function
|
|
1321
|
-
|
|
1322
|
-
const e = t instanceof Worker ? t :
|
|
1325
|
+
function Ge(t) {
|
|
1326
|
+
ie();
|
|
1327
|
+
const e = t instanceof Worker ? t : se(t), r = U(e), n = N(r);
|
|
1323
1328
|
return new Proxy(n, {
|
|
1324
1329
|
get: (s, o) => o === "isConnected" ? async () => {
|
|
1325
1330
|
for (let i = 0; i < 10; i++)
|
|
1326
1331
|
try {
|
|
1327
|
-
await
|
|
1332
|
+
await De(r.isConnected(), 200);
|
|
1328
1333
|
break;
|
|
1329
1334
|
} catch {
|
|
1330
1335
|
}
|
|
1331
1336
|
} : r[o]
|
|
1332
1337
|
});
|
|
1333
1338
|
}
|
|
1334
|
-
async function
|
|
1339
|
+
async function De(t, e) {
|
|
1335
1340
|
return new Promise((r, n) => {
|
|
1336
1341
|
setTimeout(n, e), t.then(r);
|
|
1337
1342
|
});
|
|
1338
1343
|
}
|
|
1339
|
-
function
|
|
1340
|
-
|
|
1344
|
+
function Ve(t, e) {
|
|
1345
|
+
ie();
|
|
1341
1346
|
const r = Promise.resolve();
|
|
1342
|
-
let n;
|
|
1343
|
-
const
|
|
1344
|
-
n = a;
|
|
1345
|
-
}),
|
|
1346
|
-
get: (
|
|
1347
|
+
let n, s;
|
|
1348
|
+
const o = new Promise((l, a) => {
|
|
1349
|
+
n = l, s = a;
|
|
1350
|
+
}), i = N(t), c = new Proxy(i, {
|
|
1351
|
+
get: (l, a) => a === "isConnected" ? () => r : a === "isReady" ? () => o : a in l ? l[a] : e?.[a]
|
|
1347
1352
|
});
|
|
1348
1353
|
return F(
|
|
1349
|
-
|
|
1350
|
-
typeof window < "u" ?
|
|
1351
|
-
), [n,
|
|
1354
|
+
c,
|
|
1355
|
+
typeof window < "u" ? se(self.parent) : void 0
|
|
1356
|
+
), [n, s, c];
|
|
1352
1357
|
}
|
|
1353
|
-
let
|
|
1354
|
-
function
|
|
1355
|
-
|
|
1358
|
+
let K = !1;
|
|
1359
|
+
function ie() {
|
|
1360
|
+
K || (K = !0, v.set("EVENT", {
|
|
1356
1361
|
canHandle: (t) => t instanceof CustomEvent,
|
|
1357
1362
|
serialize: (t) => [
|
|
1358
1363
|
{
|
|
@@ -1361,7 +1366,7 @@ function se() {
|
|
|
1361
1366
|
[]
|
|
1362
1367
|
],
|
|
1363
1368
|
deserialize: (t) => t
|
|
1364
|
-
}),
|
|
1369
|
+
}), v.set("FUNCTION", {
|
|
1365
1370
|
canHandle: (t) => typeof t == "function",
|
|
1366
1371
|
serialize(t) {
|
|
1367
1372
|
console.debug("[Comlink][Performance] Proxying a function");
|
|
@@ -1371,7 +1376,7 @@ function se() {
|
|
|
1371
1376
|
deserialize(t) {
|
|
1372
1377
|
return t.start(), U(t);
|
|
1373
1378
|
}
|
|
1374
|
-
}),
|
|
1379
|
+
}), v.set("PHPResponse", {
|
|
1375
1380
|
canHandle: (t) => typeof t == "object" && t !== null && "headers" in t && "bytes" in t && "errors" in t && "exitCode" in t && "httpStatusCode" in t,
|
|
1376
1381
|
serialize(t) {
|
|
1377
1382
|
return [t.toRawData(), []];
|
|
@@ -1394,12 +1399,12 @@ function N(t) {
|
|
|
1394
1399
|
case "string":
|
|
1395
1400
|
return e[r];
|
|
1396
1401
|
default:
|
|
1397
|
-
return
|
|
1402
|
+
return ne(e[r]);
|
|
1398
1403
|
}
|
|
1399
1404
|
}
|
|
1400
1405
|
});
|
|
1401
1406
|
}
|
|
1402
|
-
async function
|
|
1407
|
+
async function qe(t = ye) {
|
|
1403
1408
|
switch (t) {
|
|
1404
1409
|
case "8.2":
|
|
1405
1410
|
return await import("./php_8_2.js");
|
|
@@ -1422,6 +1427,21 @@ async function $e(t = me) {
|
|
|
1422
1427
|
}
|
|
1423
1428
|
throw new Error(`Unsupported PHP version ${t}`);
|
|
1424
1429
|
}
|
|
1430
|
+
const ze = () => ({
|
|
1431
|
+
websocket: {
|
|
1432
|
+
decorator: (t) => class extends t {
|
|
1433
|
+
constructor() {
|
|
1434
|
+
try {
|
|
1435
|
+
super();
|
|
1436
|
+
} catch {
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1439
|
+
send() {
|
|
1440
|
+
return null;
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
});
|
|
1425
1445
|
class L extends m {
|
|
1426
1446
|
/**
|
|
1427
1447
|
* Creates a new PHP instance.
|
|
@@ -1448,19 +1468,20 @@ class L extends m {
|
|
|
1448
1468
|
static loadSync(e, r = {}) {
|
|
1449
1469
|
const n = new L(void 0, r.requestHandler), o = (async () => {
|
|
1450
1470
|
const i = await Promise.all([
|
|
1451
|
-
|
|
1471
|
+
qe(e),
|
|
1452
1472
|
...r.dataModules || []
|
|
1453
|
-
]), [
|
|
1473
|
+
]), [c, ...l] = i;
|
|
1454
1474
|
r.downloadMonitor?.setModules(i);
|
|
1455
|
-
const
|
|
1456
|
-
|
|
1475
|
+
const a = await xe(
|
|
1476
|
+
c,
|
|
1457
1477
|
{
|
|
1458
1478
|
...r.emscriptenOptions || {},
|
|
1459
|
-
...r.downloadMonitor?.getEmscriptenOptions() || {}
|
|
1479
|
+
...r.downloadMonitor?.getEmscriptenOptions() || {},
|
|
1480
|
+
...ze()
|
|
1460
1481
|
},
|
|
1461
|
-
|
|
1482
|
+
l
|
|
1462
1483
|
);
|
|
1463
|
-
n.initializeRuntime(
|
|
1484
|
+
n.initializeRuntime(a);
|
|
1464
1485
|
})();
|
|
1465
1486
|
return {
|
|
1466
1487
|
php: n,
|
|
@@ -1469,7 +1490,7 @@ class L extends m {
|
|
|
1469
1490
|
}
|
|
1470
1491
|
}
|
|
1471
1492
|
const d = /* @__PURE__ */ new WeakMap();
|
|
1472
|
-
class
|
|
1493
|
+
class Je {
|
|
1473
1494
|
/** @inheritDoc */
|
|
1474
1495
|
constructor(e, r) {
|
|
1475
1496
|
d.set(this, {
|
|
@@ -1560,75 +1581,54 @@ class Ve {
|
|
|
1560
1581
|
d.get(this).php.onMessage(e);
|
|
1561
1582
|
}
|
|
1562
1583
|
}
|
|
1563
|
-
function
|
|
1584
|
+
function Be(t, e) {
|
|
1564
1585
|
return {
|
|
1565
1586
|
type: "response",
|
|
1566
1587
|
requestId: t,
|
|
1567
1588
|
response: e
|
|
1568
1589
|
};
|
|
1569
1590
|
}
|
|
1570
|
-
async function
|
|
1571
|
-
const
|
|
1572
|
-
if (!
|
|
1591
|
+
async function Ke(t, e, r) {
|
|
1592
|
+
const n = navigator.serviceWorker;
|
|
1593
|
+
if (!n)
|
|
1573
1594
|
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(
|
|
1595
|
+
console.debug("[window][sw] Registering a Service Worker"), await (await n.register(r, {
|
|
1596
|
+
type: "module",
|
|
1597
|
+
// Always bypass HTTP cache when fetching the new Service Worker script:
|
|
1598
|
+
updateViaCache: "none"
|
|
1599
|
+
})).update(), navigator.serviceWorker.addEventListener(
|
|
1599
1600
|
"message",
|
|
1600
|
-
async function(
|
|
1601
|
-
if (console.debug("Message from ServiceWorker",
|
|
1601
|
+
async function(i) {
|
|
1602
|
+
if (console.debug("[window][sw] Message from ServiceWorker", i), e && i.data.scope !== e)
|
|
1602
1603
|
return;
|
|
1603
|
-
const c =
|
|
1604
|
-
|
|
1604
|
+
const c = i.data.args || [], l = i.data.method, a = await t[l](...c);
|
|
1605
|
+
i.source.postMessage(Be(i.data.requestId, a));
|
|
1605
1606
|
}
|
|
1606
|
-
),
|
|
1607
|
-
}
|
|
1608
|
-
async function qe() {
|
|
1609
|
-
try {
|
|
1610
|
-
return (await (await fetch("/version")).json()).version;
|
|
1611
|
-
} catch {
|
|
1612
|
-
return null;
|
|
1613
|
-
}
|
|
1607
|
+
), n.startMessages();
|
|
1614
1608
|
}
|
|
1615
|
-
function
|
|
1609
|
+
function Qe() {
|
|
1616
1610
|
const t = {};
|
|
1617
1611
|
return typeof self?.location?.href < "u" && new URL(self.location.href).searchParams.forEach((r, n) => {
|
|
1618
1612
|
t[n] = r;
|
|
1619
1613
|
}), t;
|
|
1620
1614
|
}
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
}
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1615
|
+
async function Xe(t, e = {}) {
|
|
1616
|
+
t = je(t, e);
|
|
1617
|
+
const r = new Worker(t, { type: "module" });
|
|
1618
|
+
return new Promise((n, s) => {
|
|
1619
|
+
r.onerror = (i) => {
|
|
1620
|
+
const c = new Error(
|
|
1621
|
+
`WebWorker failed to load at ${t}. ${i.message ? `Original error: ${i.message}` : ""}`
|
|
1622
|
+
);
|
|
1623
|
+
c.filename = i.filename, s(c);
|
|
1624
|
+
};
|
|
1625
|
+
function o(i) {
|
|
1626
|
+
i.data === "worker-script-started" && (n(r), r.removeEventListener("message", o));
|
|
1627
|
+
}
|
|
1628
|
+
r.addEventListener("message", o);
|
|
1629
|
+
});
|
|
1630
1630
|
}
|
|
1631
|
-
function
|
|
1631
|
+
function je(t, e) {
|
|
1632
1632
|
if (!Object.entries(e).length)
|
|
1633
1633
|
return t + "";
|
|
1634
1634
|
const r = new URL(t);
|
|
@@ -1636,20 +1636,13 @@ function ze(t, e) {
|
|
|
1636
1636
|
r.searchParams.set(n, s);
|
|
1637
1637
|
return r.toString();
|
|
1638
1638
|
}
|
|
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
1639
|
export {
|
|
1646
1640
|
L as WebPHP,
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
Ke as
|
|
1653
|
-
|
|
1654
|
-
Qe as spawnPHPWorkerThread
|
|
1641
|
+
Je as WebPHPEndpoint,
|
|
1642
|
+
Ge as consumeAPI,
|
|
1643
|
+
Ve as exposeAPI,
|
|
1644
|
+
qe as getPHPLoaderModule,
|
|
1645
|
+
Qe as parseWorkerStartupOptions,
|
|
1646
|
+
Ke as registerServiceWorker,
|
|
1647
|
+
Xe as spawnPHPWorkerThread
|
|
1655
1648
|
};
|