@php-wasm/web 0.1.60 → 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/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 ie = typeof globalThis.ErrorEvent == "function" ? globalThis.ErrorEvent : I;
23
- class oe extends EventTarget {
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 ae(t) {
40
+ function le(t) {
38
41
  t.asm = {
39
42
  ...t.asm
40
43
  };
41
- const e = new oe();
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
- if ("exitCode" in o && o?.exitCode === 0)
52
- return;
53
- const i = ce(
54
+ const i = he(
54
55
  o,
55
56
  t.lastAsyncifyStackSource?.stack
56
57
  );
57
- if (t.lastAsyncifyStackSource && (o.cause = t.lastAsyncifyStackSource), !e.hasListeners())
58
- throw de(i), o;
59
- e.dispatchEvent(
60
- new ie("error", {
61
- error: o,
62
- message: i
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 A = [];
71
- function le() {
72
- return A;
73
+ let O = [];
74
+ function ue() {
75
+ return O;
73
76
  }
74
- function ce(t, e) {
77
+ function he(t, e) {
75
78
  if (t.message === "unreachable") {
76
- let r = ue;
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
- `), A = fe(
85
+ `), O = me(
83
86
  e || t.stack || ""
84
87
  );
85
- for (const n of A)
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 ue = `
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", he = "\x1B[1m", q = "\x1B[0m", z = "\x1B[K";
119
+ `, D = "\x1B[41m", fe = "\x1B[1m", q = "\x1B[0m", z = "\x1B[K";
117
120
  let B = !1;
118
- function de(t) {
121
+ function pe(t) {
119
122
  if (!B) {
120
123
  B = !0, console.log(`${D}
121
124
  ${z}
122
- ${he} WASM ERROR${q}${D}`);
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 fe(t) {
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 pe = [
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
- ], me = pe[0];
192
- class ge {
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 ye {
281
+ class Pe {
279
282
  constructor({ concurrency: e }) {
280
283
  this._running = 0, this.concurrency = e, this.queue = [];
281
284
  }
@@ -286,10 +289,13 @@ class ye {
286
289
  for (; ; )
287
290
  if (this._running >= this.concurrency)
288
291
  await new Promise((e) => this.queue.push(e));
289
- else
290
- return this._running++, () => {
291
- this._running--, this.queue.length > 0 && this.queue.shift()();
292
+ else {
293
+ this._running++;
294
+ let e = !1;
295
+ return () => {
296
+ e || (e = !0, this._running--, this.queue.length > 0 && this.queue.shift()());
292
297
  };
298
+ }
293
299
  }
294
300
  async run(e) {
295
301
  const r = await this.acquire();
@@ -300,17 +306,17 @@ class ye {
300
306
  }
301
307
  }
302
308
  }
303
- const we = "http://example.com";
309
+ const be = "http://example.com";
304
310
  function j(t) {
305
311
  return t.toString().substring(t.origin.length);
306
312
  }
307
313
  function G(t, e) {
308
314
  return !e || !t.startsWith(e) ? t : t.substring(e.length);
309
315
  }
310
- function Pe(t, e) {
316
+ function Ee(t, e) {
311
317
  return !e || t.startsWith(e) ? t : e + t;
312
318
  }
313
- class be {
319
+ class Re {
314
320
  #e;
315
321
  #t;
316
322
  #n;
@@ -319,25 +325,25 @@ class be {
319
325
  #s;
320
326
  #o;
321
327
  #a;
322
- #l;
328
+ #c;
323
329
  /**
324
330
  * @param php - The PHP instance.
325
331
  * @param config - Request Handler configuration.
326
332
  */
327
333
  constructor(e, r = {}) {
328
- this.#a = new ye({ concurrency: 1 });
334
+ this.#a = new Pe({ concurrency: 1 });
329
335
  const {
330
336
  documentRoot: n = "/www/",
331
337
  absoluteUrl: s = typeof location == "object" ? location?.href : "",
332
338
  isStaticFilePath: o = () => !1
333
339
  } = r;
334
- this.php = e, this.#e = n, this.#l = o;
340
+ this.php = e, this.#e = n, this.#c = o;
335
341
  const i = new URL(s);
336
342
  this.#n = i.hostname, this.#r = i.port ? Number(i.port) : i.protocol === "https:" ? 443 : 80, this.#t = (i.protocol || "").replace(":", "");
337
- const a = this.#r !== 443 && this.#r !== 80;
343
+ const c = this.#r !== 443 && this.#r !== 80;
338
344
  this.#i = [
339
345
  this.#n,
340
- a ? `:${this.#r}` : ""
346
+ c ? `:${this.#r}` : ""
341
347
  ].join(""), this.#s = i.pathname.replace(/\/+$/, ""), this.#o = [
342
348
  `${this.#t}://`,
343
349
  this.#i,
@@ -368,12 +374,12 @@ class be {
368
374
  async request(e) {
369
375
  const r = e.url.startsWith("http://") || e.url.startsWith("https://"), n = new URL(
370
376
  e.url,
371
- r ? void 0 : we
377
+ r ? void 0 : be
372
378
  ), s = G(
373
379
  n.pathname,
374
380
  this.#s
375
381
  );
376
- return this.#l(s) ? this.#c(s) : await this.#u(e, n);
382
+ return this.#c(s) ? this.#l(s) : await this.#u(e, n);
377
383
  }
378
384
  /**
379
385
  * Serves a static file from the PHP filesystem.
@@ -381,7 +387,7 @@ class be {
381
387
  * @param path - The requested static file path.
382
388
  * @returns The response.
383
389
  */
384
- #c(e) {
390
+ #l(e) {
385
391
  const r = `${this.#e}${e}`;
386
392
  if (!this.php.fileExists(r))
387
393
  return new b(
@@ -421,27 +427,27 @@ class be {
421
427
  let s = "GET";
422
428
  const o = {
423
429
  host: this.#i,
424
- ...K(e.headers || {})
430
+ ...Q(e.headers || {})
425
431
  }, i = [];
426
432
  if (e.files && Object.keys(e.files).length) {
427
433
  s = "POST";
428
- for (const c in e.files) {
429
- const h = e.files[c];
434
+ for (const a in e.files) {
435
+ const h = e.files[a];
430
436
  i.push({
431
- key: c,
437
+ key: a,
432
438
  name: h.name,
433
439
  type: h.type,
434
440
  data: new Uint8Array(await h.arrayBuffer())
435
441
  });
436
442
  }
437
- o["content-type"]?.startsWith("multipart/form-data") && (e.formData = Ee(
443
+ o["content-type"]?.startsWith("multipart/form-data") && (e.formData = ke(
438
444
  e.body || ""
439
445
  ), o["content-type"] = "application/x-www-form-urlencoded", delete e.body);
440
446
  }
441
- let a;
442
- e.formData !== void 0 ? (s = "POST", o["content-type"] = o["content-type"] || "application/x-www-form-urlencoded", a = new URLSearchParams(
447
+ let c;
448
+ e.formData !== void 0 ? (s = "POST", o["content-type"] = o["content-type"] || "application/x-www-form-urlencoded", c = new URLSearchParams(
443
449
  e.formData
444
- ).toString()) : a = e.body;
450
+ ).toString()) : c = e.body;
445
451
  let l;
446
452
  try {
447
453
  l = this.#h(r.pathname);
@@ -453,13 +459,13 @@ class be {
453
459
  );
454
460
  }
455
461
  return await this.php.run({
456
- relativeUri: Pe(
462
+ relativeUri: Ee(
457
463
  j(r),
458
464
  this.#s
459
465
  ),
460
466
  protocol: this.#t,
461
467
  method: e.method || s,
462
- body: a,
468
+ body: c,
463
469
  fileInfos: i,
464
470
  scriptPath: l,
465
471
  headers: o
@@ -488,7 +494,7 @@ class be {
488
494
  return `${this.#e}/index.php`;
489
495
  }
490
496
  }
491
- function Ee(t) {
497
+ function ke(t) {
492
498
  const e = {}, r = t.match(/--(.*)\r\n/);
493
499
  if (!r)
494
500
  return e;
@@ -496,9 +502,9 @@ function Ee(t) {
496
502
  return s.shift(), s.pop(), s.forEach((o) => {
497
503
  const i = o.indexOf(`\r
498
504
  \r
499
- `), a = o.substring(0, i).trim(), l = o.substring(i + 4).trim(), c = a.match(/name="([^"]+)"/);
500
- if (c) {
501
- const h = c[1];
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];
502
508
  e[h] = l;
503
509
  }
504
510
  }), e;
@@ -628,58 +634,60 @@ function y(t = "") {
628
634
  s.value = function(...i) {
629
635
  try {
630
636
  return o.apply(this, i);
631
- } catch (a) {
632
- const l = typeof a == "object" ? a?.errno : null;
637
+ } catch (c) {
638
+ const l = typeof c == "object" ? c?.errno : null;
633
639
  if (l in V) {
634
- const c = V[l], h = typeof i[0] == "string" ? i[0] : null, g = h !== null ? t.replaceAll("{path}", h) : t;
635
- throw new Error(`${g}: ${c}`, {
636
- cause: a
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
637
643
  });
638
644
  }
639
- throw a;
645
+ throw c;
640
646
  }
641
647
  };
642
648
  };
643
649
  }
644
- async function Re(t, e = {}, r = []) {
645
- let n, s;
646
- const o = new Promise((l) => {
647
- s = l;
648
- }), i = new Promise((l) => {
649
- n = l;
650
- }), a = t.init(ke, {
651
- onAbort(l) {
652
- console.error("WASM aborted: "), console.error(l);
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);
653
654
  },
654
655
  ENV: {},
655
656
  // Emscripten sometimes prepends a '/' to the path, which
656
657
  // breaks vite dev mode. An identity `locateFile` function
657
658
  // fixes it.
658
- locateFile: (l) => l,
659
+ locateFile: (a) => a,
659
660
  ...e,
660
661
  noInitialRun: !0,
661
662
  onRuntimeInitialized() {
662
- e.onRuntimeInitialized && e.onRuntimeInitialized(), n();
663
+ e.onRuntimeInitialized && e.onRuntimeInitialized(), s();
663
664
  },
664
- monitorRunDependencies(l) {
665
- l === 0 && (delete a.monitorRunDependencies, s());
665
+ monitorRunDependencies(a) {
666
+ a === 0 && (delete l.monitorRunDependencies, c());
666
667
  }
667
668
  });
668
- for (const { default: l } of r)
669
- l(a);
670
- return r.length || s(), await o, await i, M.push(a), M.length - 1;
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;
671
674
  }
672
675
  const M = [];
673
676
  function Se(t) {
674
677
  return M[t];
675
678
  }
676
- const ke = function() {
679
+ const Te = function() {
677
680
  return typeof process < "u" && process.release?.name === "node" ? "NODE" : typeof window < "u" ? "WEB" : typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope ? "WORKER" : "NODE";
678
- }();
679
- var xe = Object.defineProperty, Te = Object.getOwnPropertyDescriptor, w = (t, e, r, n) => {
680
- for (var s = n > 1 ? void 0 : n ? Te(e, r) : e, o = t.length - 1, i; o >= 0; o--)
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--)
681
689
  (i = t[o]) && (s = (n ? i(e, r, s) : i(s)) || s);
682
- return n && s && xe(e, r, s), s;
690
+ return n && s && _e(e, r, s), s;
683
691
  };
684
692
  const f = "string", E = "number", u = Symbol("__private__dont__use");
685
693
  class m {
@@ -691,14 +699,19 @@ class m {
691
699
  * @param serverOptions - Optional. Options for the PHPRequestHandler. If undefined, no request handler will be initialized.
692
700
  */
693
701
  constructor(e, r) {
694
- this.#e = [], this.#t = !1, this.#n = null, this.#r = {}, e !== void 0 && this.initializeRuntime(e), r && (this.requestHandler = new ge(
695
- new be(this, r)
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)
696
704
  ));
697
705
  }
698
706
  #e;
699
707
  #t;
700
708
  #n;
701
709
  #r;
710
+ #i;
711
+ /** @inheritDoc */
712
+ async onMessage(e) {
713
+ this.#i.push(e);
714
+ }
702
715
  /** @inheritDoc */
703
716
  get absoluteUrl() {
704
717
  return this.requestHandler.requestHandler.absoluteUrl;
@@ -723,7 +736,10 @@ class m {
723
736
  const r = Se(e);
724
737
  if (!r)
725
738
  throw new Error("Invalid PHP runtime id.");
726
- this[u] = r, this.#n = ae(r);
739
+ this[u] = r, r.onMessage = (n) => {
740
+ for (const s of this.#i)
741
+ s(n);
742
+ }, this.#n = le(r);
727
743
  }
728
744
  /** @inheritDoc */
729
745
  setPhpIniPath(e) {
@@ -754,17 +770,17 @@ class m {
754
770
  }
755
771
  /** @inheritDoc */
756
772
  async run(e) {
757
- this.#t || (this.#i(), this.#t = !0), this.#h(e.scriptPath || ""), this.#o(e.relativeUri || ""), this.#l(e.method || "GET");
773
+ this.#t || (this.#s(), this.#t = !0), this.#d(e.scriptPath || ""), this.#a(e.relativeUri || ""), this.#l(e.method || "GET");
758
774
  const { host: r, ...n } = {
759
775
  host: "example.com:443",
760
- ...K(e.headers || {})
776
+ ...Q(e.headers || {})
761
777
  };
762
- if (this.#a(r, e.protocol || "http"), this.#c(n), e.body && this.#u(e.body), e.fileInfos)
778
+ if (this.#c(r, e.protocol || "http"), this.#u(n), e.body && this.#h(e.body), e.fileInfos)
763
779
  for (const s of e.fileInfos)
764
- this.#f(s);
765
- return e.code && this.#p(" ?>" + e.code), this.#d(), await this.#m();
780
+ this.#p(s);
781
+ return e.code && this.#m(" ?>" + e.code), this.#f(), await this.#g();
766
782
  }
767
- #i() {
783
+ #s() {
768
784
  if (this.#e.length > 0) {
769
785
  const e = this.#e.map(([r, n]) => `${r}=${n}`).join(`
770
786
  `) + `
@@ -779,7 +795,7 @@ class m {
779
795
  }
780
796
  this[u].ccall("php_wasm_init", null, [], []);
781
797
  }
782
- #s() {
798
+ #o() {
783
799
  const e = "/tmp/headers.json";
784
800
  if (!this.fileExists(e))
785
801
  throw new Error(
@@ -789,15 +805,15 @@ class m {
789
805
  for (const s of r.headers) {
790
806
  if (!s.includes(": "))
791
807
  continue;
792
- const o = s.indexOf(": "), i = s.substring(0, o).toLowerCase(), a = s.substring(o + 2);
793
- i in n || (n[i] = []), n[i].push(a);
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);
794
810
  }
795
811
  return {
796
812
  headers: n,
797
813
  httpStatusCode: r.status
798
814
  };
799
815
  }
800
- #o(e) {
816
+ #a(e) {
801
817
  if (this[u].ccall(
802
818
  "wasm_set_request_uri",
803
819
  null,
@@ -813,7 +829,7 @@ class m {
813
829
  );
814
830
  }
815
831
  }
816
- #a(e, r) {
832
+ #c(e, r) {
817
833
  this[u].ccall(
818
834
  "wasm_set_request_host",
819
835
  null,
@@ -840,7 +856,7 @@ class m {
840
856
  [e]
841
857
  );
842
858
  }
843
- #c(e) {
859
+ #u(e) {
844
860
  e.cookie && this[u].ccall(
845
861
  "wasm_set_cookies",
846
862
  null,
@@ -865,7 +881,7 @@ class m {
865
881
  );
866
882
  }
867
883
  }
868
- #u(e) {
884
+ #h(e) {
869
885
  this[u].ccall(
870
886
  "wasm_set_request_body",
871
887
  null,
@@ -878,7 +894,7 @@ class m {
878
894
  [new TextEncoder().encode(e).length]
879
895
  );
880
896
  }
881
- #h(e) {
897
+ #d(e) {
882
898
  this[u].ccall(
883
899
  "wasm_set_path_translated",
884
900
  null,
@@ -889,7 +905,7 @@ class m {
889
905
  addServerGlobalEntry(e, r) {
890
906
  this.#r[e] = r;
891
907
  }
892
- #d() {
908
+ #f() {
893
909
  for (const e in this.#r)
894
910
  this[u].ccall(
895
911
  "wasm_add_SERVER_entry",
@@ -907,18 +923,18 @@ class m {
907
923
  *
908
924
  * @param fileInfo - File details
909
925
  */
910
- #f(e) {
926
+ #p(e) {
911
927
  const { key: r, name: n, type: s, data: o } = e, i = `/tmp/${Math.random().toFixed(20)}`;
912
928
  this.writeFile(i, o);
913
- const a = 0;
929
+ const c = 0;
914
930
  this[u].ccall(
915
931
  "wasm_add_uploaded_file",
916
932
  null,
917
933
  [f, f, f, f, E, E],
918
- [r, n, s, i, a, o.byteLength]
934
+ [r, n, s, i, c, o.byteLength]
919
935
  );
920
936
  }
921
- #p(e) {
937
+ #m(e) {
922
938
  this[u].ccall(
923
939
  "wasm_set_php_code",
924
940
  null,
@@ -926,39 +942,39 @@ class m {
926
942
  [e]
927
943
  );
928
944
  }
929
- async #m() {
945
+ async #g() {
930
946
  let e, r;
931
947
  try {
932
948
  e = await new Promise((o, i) => {
933
949
  r = (l) => {
934
- const c = new Error("Rethrown");
935
- c.cause = l.error, c.betterMessage = l.message, i(c);
950
+ const a = new Error("Rethrown");
951
+ a.cause = l.error, a.betterMessage = l.message, i(a);
936
952
  }, this.#n?.addEventListener(
937
953
  "error",
938
954
  r
939
955
  );
940
- const a = this[u].ccall(
956
+ const c = this[u].ccall(
941
957
  "wasm_sapi_handle_request",
942
958
  E,
943
959
  [],
944
960
  []
945
961
  );
946
- return a instanceof Promise ? a.then(o, i) : o(a);
962
+ return c instanceof Promise ? c.then(o, i) : o(c);
947
963
  });
948
964
  } catch (o) {
949
- for (const c in this)
950
- typeof this[c] == "function" && (this[c] = () => {
965
+ for (const a in this)
966
+ typeof this[a] == "function" && (this[a] = () => {
951
967
  throw new Error(
952
968
  "PHP runtime has crashed – see the earlier error for details."
953
969
  );
954
970
  });
955
- this.functionsMaybeMissingFromAsyncify = le();
956
- const i = o, a = "betterMessage" in i ? i.betterMessage : i.message, l = new Error(a);
971
+ this.functionsMaybeMissingFromAsyncify = ue();
972
+ const i = o, c = "betterMessage" in i ? i.betterMessage : i.message, l = new Error(c);
957
973
  throw l.cause = i, l;
958
974
  } finally {
959
975
  this.#n?.removeEventListener("error", r), this.#r = {};
960
976
  }
961
- const { headers: n, httpStatusCode: s } = this.#s();
977
+ const { headers: n, httpStatusCode: s } = this.#o();
962
978
  return new b(
963
979
  s,
964
980
  n,
@@ -1056,7 +1072,7 @@ w([
1056
1072
  w([
1057
1073
  y('Could not stat "{path}"')
1058
1074
  ], m.prototype, "fileExists", 1);
1059
- function K(t) {
1075
+ function Q(t) {
1060
1076
  const e = {};
1061
1077
  for (const r in t)
1062
1078
  e[r.toLowerCase()] = t[r];
@@ -1067,8 +1083,8 @@ function K(t) {
1067
1083
  * Copyright 2019 Google LLC
1068
1084
  * SPDX-License-Identifier: Apache-2.0
1069
1085
  */
1070
- const Q = Symbol("Comlink.proxy"), _e = Symbol("Comlink.endpoint"), Ce = Symbol("Comlink.releaseProxy"), H = Symbol("Comlink.finalizer"), x = Symbol("Comlink.thrown"), X = (t) => typeof t == "object" && t !== null || typeof t == "function", Fe = {
1071
- canHandle: (t) => X(t) && t[Q],
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],
1072
1088
  serialize(t) {
1073
1089
  const { port1: e, port2: r } = new MessageChannel();
1074
1090
  return F(t, e), [r, [r]];
@@ -1076,8 +1092,8 @@ const Q = Symbol("Comlink.proxy"), _e = Symbol("Comlink.endpoint"), Ce = Symbol(
1076
1092
  deserialize(t) {
1077
1093
  return t.start(), U(t);
1078
1094
  }
1079
- }, He = {
1080
- canHandle: (t) => X(t) && x in t,
1095
+ }, Me = {
1096
+ canHandle: (t) => Z(t) && S in t,
1081
1097
  serialize({ value: t }) {
1082
1098
  let e;
1083
1099
  return t instanceof Error ? e = {
@@ -1092,9 +1108,9 @@ const Q = Symbol("Comlink.proxy"), _e = Symbol("Comlink.endpoint"), Ce = Symbol(
1092
1108
  deserialize(t) {
1093
1109
  throw t.isError ? Object.assign(new Error(t.value.message), t.value) : t.value;
1094
1110
  }
1095
- }, S = /* @__PURE__ */ new Map([
1096
- ["proxy", Fe],
1097
- ["throw", He]
1111
+ }, v = /* @__PURE__ */ new Map([
1112
+ ["proxy", Oe],
1113
+ ["throw", Me]
1098
1114
  ]);
1099
1115
  function Ae(t, e) {
1100
1116
  for (const r of t)
@@ -1110,156 +1126,156 @@ function F(t, e = globalThis, r = ["*"]) {
1110
1126
  console.warn(`Invalid origin '${s.origin}' for comlink proxy`);
1111
1127
  return;
1112
1128
  }
1113
- const { id: o, type: i, path: a } = Object.assign({ path: [] }, s.data), l = (s.data.argumentList || []).map(P);
1114
- let c;
1129
+ const { id: o, type: i, path: c } = Object.assign({ path: [] }, s.data), l = (s.data.argumentList || []).map(P);
1130
+ let a;
1115
1131
  try {
1116
- const h = a.slice(0, -1).reduce((p, R) => p[R], t), g = a.reduce((p, R) => p[R], t);
1132
+ const h = c.slice(0, -1).reduce((p, k) => p[k], t), g = c.reduce((p, k) => p[k], t);
1117
1133
  switch (i) {
1118
1134
  case "GET":
1119
- c = g;
1135
+ a = g;
1120
1136
  break;
1121
1137
  case "SET":
1122
- h[a.slice(-1)[0]] = P(s.data.value), c = !0;
1138
+ h[c.slice(-1)[0]] = P(s.data.value), a = !0;
1123
1139
  break;
1124
1140
  case "APPLY":
1125
- c = g.apply(h, l);
1141
+ a = g.apply(h, l);
1126
1142
  break;
1127
1143
  case "CONSTRUCT":
1128
1144
  {
1129
1145
  const p = new g(...l);
1130
- c = re(p);
1146
+ a = ne(p);
1131
1147
  }
1132
1148
  break;
1133
1149
  case "ENDPOINT":
1134
1150
  {
1135
- const { port1: p, port2: R } = new MessageChannel();
1136
- F(t, R), c = Ue(p, [p]);
1151
+ const { port1: p, port2: k } = new MessageChannel();
1152
+ F(t, k), a = We(p, [p]);
1137
1153
  }
1138
1154
  break;
1139
1155
  case "RELEASE":
1140
- c = void 0;
1156
+ a = void 0;
1141
1157
  break;
1142
1158
  default:
1143
1159
  return;
1144
1160
  }
1145
1161
  } catch (h) {
1146
- c = { value: h, [x]: 0 };
1162
+ a = { value: h, [S]: 0 };
1147
1163
  }
1148
- Promise.resolve(c).catch((h) => ({ value: h, [x]: 0 })).then((h) => {
1164
+ Promise.resolve(a).catch((h) => ({ value: h, [S]: 0 })).then((h) => {
1149
1165
  const [g, p] = C(h);
1150
- e.postMessage(Object.assign(Object.assign({}, g), { id: o }), p), i === "RELEASE" && (e.removeEventListener("message", n), Z(e), H in t && typeof t[H] == "function" && t[H]());
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]());
1151
1167
  }).catch((h) => {
1152
1168
  const [g, p] = C({
1153
1169
  value: new TypeError("Unserializable return value"),
1154
- [x]: 0
1170
+ [S]: 0
1155
1171
  });
1156
1172
  e.postMessage(Object.assign(Object.assign({}, g), { id: o }), p);
1157
1173
  });
1158
1174
  }), e.start && e.start();
1159
1175
  }
1160
- function Me(t) {
1176
+ function Le(t) {
1161
1177
  return t.constructor.name === "MessagePort";
1162
1178
  }
1163
- function Z(t) {
1164
- Me(t) && t.close();
1179
+ function ee(t) {
1180
+ Le(t) && t.close();
1165
1181
  }
1166
1182
  function U(t, e) {
1167
- return O(t, [], e);
1183
+ return A(t, [], e);
1168
1184
  }
1169
- function k(t) {
1185
+ function x(t) {
1170
1186
  if (t)
1171
1187
  throw new Error("Proxy has been released and is not useable");
1172
1188
  }
1173
- function ee(t) {
1174
- return v(t, {
1189
+ function te(t) {
1190
+ return R(t, {
1175
1191
  type: "RELEASE"
1176
1192
  }).then(() => {
1177
- Z(t);
1193
+ ee(t);
1178
1194
  });
1179
1195
  }
1180
1196
  const T = /* @__PURE__ */ new WeakMap(), _ = "FinalizationRegistry" in globalThis && new FinalizationRegistry((t) => {
1181
1197
  const e = (T.get(t) || 0) - 1;
1182
- T.set(t, e), e === 0 && ee(t);
1198
+ T.set(t, e), e === 0 && te(t);
1183
1199
  });
1184
- function Oe(t, e) {
1200
+ function Ie(t, e) {
1185
1201
  const r = (T.get(e) || 0) + 1;
1186
1202
  T.set(e, r), _ && _.register(t, e, t);
1187
1203
  }
1188
- function Le(t) {
1204
+ function Ue(t) {
1189
1205
  _ && _.unregister(t);
1190
1206
  }
1191
- function O(t, e = [], r = function() {
1207
+ function A(t, e = [], r = function() {
1192
1208
  }) {
1193
1209
  let n = !1;
1194
1210
  const s = new Proxy(r, {
1195
1211
  get(o, i) {
1196
- if (k(n), i === Ce)
1212
+ if (x(n), i === He)
1197
1213
  return () => {
1198
- Le(s), ee(t), n = !0;
1214
+ Ue(s), te(t), n = !0;
1199
1215
  };
1200
1216
  if (i === "then") {
1201
1217
  if (e.length === 0)
1202
1218
  return { then: () => s };
1203
- const a = v(t, {
1219
+ const c = R(t, {
1204
1220
  type: "GET",
1205
1221
  path: e.map((l) => l.toString())
1206
1222
  }).then(P);
1207
- return a.then.bind(a);
1223
+ return c.then.bind(c);
1208
1224
  }
1209
- return O(t, [...e, i]);
1225
+ return A(t, [...e, i]);
1210
1226
  },
1211
- set(o, i, a) {
1212
- k(n);
1213
- const [l, c] = C(a);
1214
- return v(t, {
1227
+ set(o, i, c) {
1228
+ x(n);
1229
+ const [l, a] = C(c);
1230
+ return R(t, {
1215
1231
  type: "SET",
1216
1232
  path: [...e, i].map((h) => h.toString()),
1217
1233
  value: l
1218
- }, c).then(P);
1234
+ }, a).then(P);
1219
1235
  },
1220
- apply(o, i, a) {
1221
- k(n);
1236
+ apply(o, i, c) {
1237
+ x(n);
1222
1238
  const l = e[e.length - 1];
1223
- if (l === _e)
1224
- return v(t, {
1239
+ if (l === Fe)
1240
+ return R(t, {
1225
1241
  type: "ENDPOINT"
1226
1242
  }).then(P);
1227
1243
  if (l === "bind")
1228
- return O(t, e.slice(0, -1));
1229
- const [c, h] = Y(a);
1230
- return v(t, {
1244
+ return A(t, e.slice(0, -1));
1245
+ const [a, h] = J(c);
1246
+ return R(t, {
1231
1247
  type: "APPLY",
1232
1248
  path: e.map((g) => g.toString()),
1233
- argumentList: c
1249
+ argumentList: a
1234
1250
  }, h).then(P);
1235
1251
  },
1236
1252
  construct(o, i) {
1237
- k(n);
1238
- const [a, l] = Y(i);
1239
- return v(t, {
1253
+ x(n);
1254
+ const [c, l] = J(i);
1255
+ return R(t, {
1240
1256
  type: "CONSTRUCT",
1241
- path: e.map((c) => c.toString()),
1242
- argumentList: a
1257
+ path: e.map((a) => a.toString()),
1258
+ argumentList: c
1243
1259
  }, l).then(P);
1244
1260
  }
1245
1261
  });
1246
- return Oe(s, t), s;
1262
+ return Ie(s, t), s;
1247
1263
  }
1248
- function Ie(t) {
1264
+ function Ne(t) {
1249
1265
  return Array.prototype.concat.apply([], t);
1250
1266
  }
1251
- function Y(t) {
1267
+ function J(t) {
1252
1268
  const e = t.map(C);
1253
- return [e.map((r) => r[0]), Ie(e.map((r) => r[1]))];
1269
+ return [e.map((r) => r[0]), Ne(e.map((r) => r[1]))];
1254
1270
  }
1255
- const te = /* @__PURE__ */ new WeakMap();
1256
- function Ue(t, e) {
1257
- return te.set(t, e), t;
1271
+ const re = /* @__PURE__ */ new WeakMap();
1272
+ function We(t, e) {
1273
+ return re.set(t, e), t;
1258
1274
  }
1259
- function re(t) {
1260
- return Object.assign(t, { [Q]: !0 });
1275
+ function ne(t) {
1276
+ return Object.assign(t, { [X]: !0 });
1261
1277
  }
1262
- function ne(t, e = globalThis, r = "*") {
1278
+ function se(t, e = globalThis, r = "*") {
1263
1279
  return {
1264
1280
  postMessage: (n, s) => t.postMessage(n, r, s),
1265
1281
  addEventListener: e.addEventListener.bind(e),
@@ -1267,7 +1283,7 @@ function ne(t, e = globalThis, r = "*") {
1267
1283
  };
1268
1284
  }
1269
1285
  function C(t) {
1270
- for (const [e, r] of S)
1286
+ for (const [e, r] of v)
1271
1287
  if (r.canHandle(t)) {
1272
1288
  const [n, s] = r.serialize(t);
1273
1289
  return [
@@ -1284,52 +1300,64 @@ function C(t) {
1284
1300
  type: "RAW",
1285
1301
  value: t
1286
1302
  },
1287
- te.get(t) || []
1303
+ re.get(t) || []
1288
1304
  ];
1289
1305
  }
1290
1306
  function P(t) {
1291
1307
  switch (t.type) {
1292
1308
  case "HANDLER":
1293
- return S.get(t.name).deserialize(t.value);
1309
+ return v.get(t.name).deserialize(t.value);
1294
1310
  case "RAW":
1295
1311
  return t.value;
1296
1312
  }
1297
1313
  }
1298
- function v(t, e, r) {
1314
+ function R(t, e, r) {
1299
1315
  return new Promise((n) => {
1300
- const s = Ne();
1316
+ const s = $e();
1301
1317
  t.addEventListener("message", function o(i) {
1302
1318
  !i.data || !i.data.id || i.data.id !== s || (t.removeEventListener("message", o), n(i.data));
1303
1319
  }), t.start && t.start(), t.postMessage(Object.assign({ id: s }, e), r);
1304
1320
  });
1305
1321
  }
1306
- function Ne() {
1322
+ function $e() {
1307
1323
  return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
1308
1324
  }
1309
- function Be(t) {
1310
- se();
1311
- const e = t instanceof Worker ? t : ne(t), r = U(e), n = N(r);
1325
+ function Ge(t) {
1326
+ ie();
1327
+ const e = t instanceof Worker ? t : se(t), r = U(e), n = N(r);
1312
1328
  return new Proxy(n, {
1313
- get: (s, o) => o === "isConnected" ? () => r.isConnected() : r[o]
1329
+ get: (s, o) => o === "isConnected" ? async () => {
1330
+ for (let i = 0; i < 10; i++)
1331
+ try {
1332
+ await De(r.isConnected(), 200);
1333
+ break;
1334
+ } catch {
1335
+ }
1336
+ } : r[o]
1314
1337
  });
1315
1338
  }
1316
- function je(t, e) {
1317
- se();
1339
+ async function De(t, e) {
1340
+ return new Promise((r, n) => {
1341
+ setTimeout(n, e), t.then(r);
1342
+ });
1343
+ }
1344
+ function Ve(t, e) {
1345
+ ie();
1318
1346
  const r = Promise.resolve();
1319
- let n;
1320
- const s = new Promise((a) => {
1321
- n = a;
1322
- }), o = N(t), i = new Proxy(o, {
1323
- get: (a, l) => l === "isConnected" ? () => r : l === "isReady" ? () => s : l in a ? a[l] : e?.[l]
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]
1324
1352
  });
1325
1353
  return F(
1326
- i,
1327
- typeof window < "u" ? ne(self.parent) : void 0
1328
- ), [n, i];
1354
+ c,
1355
+ typeof window < "u" ? se(self.parent) : void 0
1356
+ ), [n, s, c];
1329
1357
  }
1330
- let J = !1;
1331
- function se() {
1332
- J || (J = !0, S.set("EVENT", {
1358
+ let K = !1;
1359
+ function ie() {
1360
+ K || (K = !0, v.set("EVENT", {
1333
1361
  canHandle: (t) => t instanceof CustomEvent,
1334
1362
  serialize: (t) => [
1335
1363
  {
@@ -1338,7 +1366,7 @@ function se() {
1338
1366
  []
1339
1367
  ],
1340
1368
  deserialize: (t) => t
1341
- }), S.set("FUNCTION", {
1369
+ }), v.set("FUNCTION", {
1342
1370
  canHandle: (t) => typeof t == "function",
1343
1371
  serialize(t) {
1344
1372
  console.debug("[Comlink][Performance] Proxying a function");
@@ -1348,7 +1376,7 @@ function se() {
1348
1376
  deserialize(t) {
1349
1377
  return t.start(), U(t);
1350
1378
  }
1351
- }), S.set("PHPResponse", {
1379
+ }), v.set("PHPResponse", {
1352
1380
  canHandle: (t) => typeof t == "object" && t !== null && "headers" in t && "bytes" in t && "errors" in t && "exitCode" in t && "httpStatusCode" in t,
1353
1381
  serialize(t) {
1354
1382
  return [t.toRawData(), []];
@@ -1371,12 +1399,12 @@ function N(t) {
1371
1399
  case "string":
1372
1400
  return e[r];
1373
1401
  default:
1374
- return re(e[r]);
1402
+ return ne(e[r]);
1375
1403
  }
1376
1404
  }
1377
1405
  });
1378
1406
  }
1379
- async function We(t = me) {
1407
+ async function qe(t = ye) {
1380
1408
  switch (t) {
1381
1409
  case "8.2":
1382
1410
  return await import("./php_8_2.js");
@@ -1399,6 +1427,21 @@ async function We(t = me) {
1399
1427
  }
1400
1428
  throw new Error(`Unsupported PHP version ${t}`);
1401
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
+ });
1402
1445
  class L extends m {
1403
1446
  /**
1404
1447
  * Creates a new PHP instance.
@@ -1425,29 +1468,29 @@ class L extends m {
1425
1468
  static loadSync(e, r = {}) {
1426
1469
  const n = new L(void 0, r.requestHandler), o = (async () => {
1427
1470
  const i = await Promise.all([
1428
- We(e),
1471
+ qe(e),
1429
1472
  ...r.dataModules || []
1430
- ]), [a, ...l] = i;
1473
+ ]), [c, ...l] = i;
1431
1474
  r.downloadMonitor?.setModules(i);
1432
- const c = await Re(
1433
- a,
1475
+ const a = await xe(
1476
+ c,
1434
1477
  {
1435
1478
  ...r.emscriptenOptions || {},
1436
- ...r.downloadMonitor?.getEmscriptenOptions() || {}
1479
+ ...r.downloadMonitor?.getEmscriptenOptions() || {},
1480
+ ...ze()
1437
1481
  },
1438
1482
  l
1439
1483
  );
1440
- return n.initializeRuntime(c), { dataModules: l };
1484
+ n.initializeRuntime(a);
1441
1485
  })();
1442
1486
  return {
1443
1487
  php: n,
1444
- phpReady: o.then(() => n),
1445
- dataModules: o.then((i) => i.dataModules)
1488
+ phpReady: o.then(() => n)
1446
1489
  };
1447
1490
  }
1448
1491
  }
1449
1492
  const d = /* @__PURE__ */ new WeakMap();
1450
- class Ge {
1493
+ class Je {
1451
1494
  /** @inheritDoc */
1452
1495
  constructor(e, r) {
1453
1496
  d.set(this, {
@@ -1533,76 +1576,59 @@ class Ge {
1533
1576
  fileExists(e) {
1534
1577
  return d.get(this).php.fileExists(e);
1535
1578
  }
1579
+ /** @inheritDoc @php-wasm/web!WebPHP.onMessage */
1580
+ onMessage(e) {
1581
+ d.get(this).php.onMessage(e);
1582
+ }
1536
1583
  }
1537
- function $e(t, e) {
1584
+ function Be(t, e) {
1538
1585
  return {
1539
1586
  type: "response",
1540
1587
  requestId: t,
1541
1588
  response: e
1542
1589
  };
1543
1590
  }
1544
- async function Ve(t, e, r, n) {
1545
- const s = navigator.serviceWorker;
1546
- if (!s)
1591
+ async function Ke(t, e, r) {
1592
+ const n = navigator.serviceWorker;
1593
+ if (!n)
1547
1594
  throw new Error("Service workers are not supported in this browser.");
1548
- const o = await s.getRegistrations();
1549
- if (o.length > 0) {
1550
- const i = await De();
1551
- if (n !== i) {
1552
- console.debug(
1553
- `[window] Reloading the currently registered Service Worker (expected version: ${n}, registered version: ${i})`
1554
- );
1555
- for (const a of o) {
1556
- let l = !1;
1557
- try {
1558
- await a.update();
1559
- } catch {
1560
- l = !0;
1561
- }
1562
- const c = a.waiting || a.installing;
1563
- c && !l && (i !== null ? c.postMessage("skip-waiting") : l = !0), l && (await a.unregister(), window.location.reload());
1564
- }
1565
- }
1566
- } else
1567
- console.debug(
1568
- `[window] Creating a Service Worker registration (version: ${n})`
1569
- ), await s.register(r, {
1570
- type: "module"
1571
- });
1572
- 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(
1573
1600
  "message",
1574
- async function(a) {
1575
- if (console.debug("Message from ServiceWorker", a), e && a.data.scope !== e)
1601
+ async function(i) {
1602
+ if (console.debug("[window][sw] Message from ServiceWorker", i), e && i.data.scope !== e)
1576
1603
  return;
1577
- const l = a.data.args || [], c = a.data.method, h = await t[c](...l);
1578
- a.source.postMessage($e(a.data.requestId, h));
1604
+ const c = i.data.args || [], l = i.data.method, a = await t[l](...c);
1605
+ i.source.postMessage(Be(i.data.requestId, a));
1579
1606
  }
1580
- ), s.startMessages();
1581
- }
1582
- async function De() {
1583
- try {
1584
- return (await (await fetch("/version")).json()).version;
1585
- } catch {
1586
- return null;
1587
- }
1607
+ ), n.startMessages();
1588
1608
  }
1589
- function Ye() {
1609
+ function Qe() {
1590
1610
  const t = {};
1591
1611
  return typeof self?.location?.href < "u" && new URL(self.location.href).searchParams.forEach((r, n) => {
1592
1612
  t[n] = r;
1593
1613
  }), t;
1594
1614
  }
1595
- const Je = function() {
1596
- return typeof navigator < "u" && navigator?.userAgent?.toLowerCase().indexOf("firefox") > -1 ? "iframe" : "webworker";
1597
- }();
1598
- async function Ke(t, e = "webworker", r = {}) {
1599
- if (t = qe(t, r), e === "webworker")
1600
- return new Worker(t, { type: "module" });
1601
- if (e === "iframe")
1602
- return (await ze(t)).contentWindow;
1603
- throw new Error(`Unknown backendName: ${e}`);
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
+ });
1604
1630
  }
1605
- function qe(t, e) {
1631
+ function je(t, e) {
1606
1632
  if (!Object.entries(e).length)
1607
1633
  return t + "";
1608
1634
  const r = new URL(t);
@@ -1610,20 +1636,13 @@ function qe(t, e) {
1610
1636
  r.searchParams.set(n, s);
1611
1637
  return r.toString();
1612
1638
  }
1613
- async function ze(t) {
1614
- const e = document.createElement("iframe"), r = "/" + t.split("/").slice(-1)[0];
1615
- return e.src = r, e.style.display = "none", document.body.appendChild(e), await new Promise((n) => {
1616
- e.addEventListener("load", n);
1617
- }), e;
1618
- }
1619
1639
  export {
1620
1640
  L as WebPHP,
1621
- Ge as WebPHPEndpoint,
1622
- Be as consumeAPI,
1623
- je as exposeAPI,
1624
- We as getPHPLoaderModule,
1625
- Ye as parseWorkerStartupOptions,
1626
- Je as recommendedWorkerBackend,
1627
- Ve as registerServiceWorker,
1628
- Ke 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
1629
1648
  };