@php-wasm/web 0.2.0 → 0.3.1

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.
Files changed (42) hide show
  1. package/README.md +35 -0
  2. package/index.d.ts +11 -8
  3. package/index.js +231 -202
  4. package/kitchen-sink/php_5_6.js +85 -0
  5. package/kitchen-sink/php_5_6.wasm +0 -0
  6. package/kitchen-sink/php_7_0.js +85 -0
  7. package/kitchen-sink/php_7_0.wasm +0 -0
  8. package/kitchen-sink/php_7_1.js +85 -0
  9. package/kitchen-sink/php_7_1.wasm +0 -0
  10. package/kitchen-sink/php_7_2.js +85 -0
  11. package/kitchen-sink/php_7_2.wasm +0 -0
  12. package/kitchen-sink/php_7_3.js +85 -0
  13. package/kitchen-sink/php_7_3.wasm +0 -0
  14. package/kitchen-sink/php_7_4.js +85 -0
  15. package/kitchen-sink/php_7_4.wasm +0 -0
  16. package/kitchen-sink/php_8_0.js +85 -0
  17. package/kitchen-sink/php_8_0.wasm +0 -0
  18. package/kitchen-sink/php_8_1.js +85 -0
  19. package/kitchen-sink/php_8_1.wasm +0 -0
  20. package/kitchen-sink/php_8_2.js +85 -0
  21. package/kitchen-sink/php_8_2.wasm +0 -0
  22. package/lib/worker-thread/spawn-php-worker-thread.d.ts +1 -1
  23. package/package.json +2 -2
  24. package/lib/worker-thread/parse-startup-options.d.ts +0 -1
  25. /package/{php_5_6.js → light/php_5_6.js} +0 -0
  26. /package/{php_5_6.wasm → light/php_5_6.wasm} +0 -0
  27. /package/{php_7_0.js → light/php_7_0.js} +0 -0
  28. /package/{php_7_0.wasm → light/php_7_0.wasm} +0 -0
  29. /package/{php_7_1.js → light/php_7_1.js} +0 -0
  30. /package/{php_7_1.wasm → light/php_7_1.wasm} +0 -0
  31. /package/{php_7_2.js → light/php_7_2.js} +0 -0
  32. /package/{php_7_2.wasm → light/php_7_2.wasm} +0 -0
  33. /package/{php_7_3.js → light/php_7_3.js} +0 -0
  34. /package/{php_7_3.wasm → light/php_7_3.wasm} +0 -0
  35. /package/{php_7_4.js → light/php_7_4.js} +0 -0
  36. /package/{php_7_4.wasm → light/php_7_4.wasm} +0 -0
  37. /package/{php_8_0.js → light/php_8_0.js} +0 -0
  38. /package/{php_8_0.wasm → light/php_8_0.wasm} +0 -0
  39. /package/{php_8_1.js → light/php_8_1.js} +0 -0
  40. /package/{php_8_1.wasm → light/php_8_1.wasm} +0 -0
  41. /package/{php_8_2.js → light/php_8_2.js} +0 -0
  42. /package/{php_8_2.wasm → light/php_8_2.wasm} +0 -0
package/index.js CHANGED
@@ -48,31 +48,31 @@ function le(t) {
48
48
  t.asm[r] = function(...s) {
49
49
  try {
50
50
  return n(...s);
51
- } catch (o) {
52
- if (!(o instanceof Error))
53
- throw o;
54
- const i = he(
55
- o,
51
+ } catch (i) {
52
+ if (!(i instanceof Error))
53
+ throw i;
54
+ const o = he(
55
+ i,
56
56
  t.lastAsyncifyStackSource?.stack
57
57
  );
58
- if (t.lastAsyncifyStackSource && (o.cause = t.lastAsyncifyStackSource), e.hasListeners()) {
58
+ if (t.lastAsyncifyStackSource && (i.cause = t.lastAsyncifyStackSource), e.hasListeners()) {
59
59
  e.dispatchEvent(
60
60
  new oe("error", {
61
- error: o,
62
- message: i
61
+ error: i,
62
+ message: o
63
63
  })
64
64
  );
65
65
  return;
66
66
  }
67
- throw ae(o) || pe(i), o;
67
+ throw ae(i) || pe(o), i;
68
68
  }
69
69
  };
70
70
  }
71
71
  return e;
72
72
  }
73
- let O = [];
73
+ let A = [];
74
74
  function ue() {
75
- return O;
75
+ return A;
76
76
  }
77
77
  function he(t, e) {
78
78
  if (t.message === "unreachable") {
@@ -82,10 +82,10 @@ function he(t, e) {
82
82
  This stack trace is lacking. For a better one initialize
83
83
  the PHP runtime with { debug: true }, e.g. PHPNode.load('8.1', { debug: true }).
84
84
 
85
- `), O = me(
85
+ `), A = me(
86
86
  e || t.stack || ""
87
87
  );
88
- for (const n of O)
88
+ for (const n of A)
89
89
  r += ` * ${n}
90
90
  `;
91
91
  return r;
@@ -147,8 +147,8 @@ function me(t) {
147
147
  }
148
148
  }
149
149
  class b {
150
- constructor(e, r, n, s = "", o = 0) {
151
- this.httpStatusCode = e, this.headers = r, this.bytes = n, this.exitCode = o, this.errors = s;
150
+ constructor(e, r, n, s = "", i = 0) {
151
+ this.httpStatusCode = e, this.headers = r, this.bytes = n, this.exitCode = i, this.errors = s;
152
152
  }
153
153
  static fromRawData(e) {
154
154
  return new b(
@@ -265,8 +265,8 @@ class we {
265
265
  try {
266
266
  if (!r.includes("="))
267
267
  continue;
268
- const n = r.indexOf("="), s = r.substring(0, n), o = r.substring(n + 1).split(";")[0];
269
- this.#e[s] = o;
268
+ const n = r.indexOf("="), s = r.substring(0, n), i = r.substring(n + 1).split(";")[0];
269
+ this.#e[s] = i;
270
270
  } catch (n) {
271
271
  console.error(n);
272
272
  }
@@ -316,7 +316,7 @@ function G(t, e) {
316
316
  function Ee(t, e) {
317
317
  return !e || t.startsWith(e) ? t : e + t;
318
318
  }
319
- class Re {
319
+ class ke {
320
320
  #e;
321
321
  #t;
322
322
  #n;
@@ -325,7 +325,6 @@ class Re {
325
325
  #s;
326
326
  #o;
327
327
  #a;
328
- #c;
329
328
  /**
330
329
  * @param php - The PHP instance.
331
330
  * @param config - Request Handler configuration.
@@ -334,16 +333,15 @@ class Re {
334
333
  this.#a = new Pe({ concurrency: 1 });
335
334
  const {
336
335
  documentRoot: n = "/www/",
337
- absoluteUrl: s = typeof location == "object" ? location?.href : "",
338
- isStaticFilePath: o = () => !1
336
+ absoluteUrl: s = typeof location == "object" ? location?.href : ""
339
337
  } = r;
340
- this.php = e, this.#e = n, this.#c = o;
338
+ this.php = e, this.#e = n;
341
339
  const i = new URL(s);
342
340
  this.#n = i.hostname, this.#r = i.port ? Number(i.port) : i.protocol === "https:" ? 443 : 80, this.#t = (i.protocol || "").replace(":", "");
343
- const c = this.#r !== 443 && this.#r !== 80;
341
+ const o = this.#r !== 443 && this.#r !== 80;
344
342
  this.#i = [
345
343
  this.#n,
346
- c ? `:${this.#r}` : ""
344
+ o ? `:${this.#r}` : ""
347
345
  ].join(""), this.#s = i.pathname.replace(/\/+$/, ""), this.#o = [
348
346
  `${this.#t}://`,
349
347
  this.#i,
@@ -378,36 +376,39 @@ class Re {
378
376
  ), s = G(
379
377
  n.pathname,
380
378
  this.#s
381
- );
382
- return this.#c(s) ? this.#l(s) : await this.#u(e, n);
379
+ ), i = `${this.#e}${s}`;
380
+ return xe(i) ? await this.#l(e, n) : this.#c(i);
383
381
  }
384
382
  /**
385
383
  * Serves a static file from the PHP filesystem.
386
384
  *
387
- * @param path - The requested static file path.
385
+ * @param fsPath - Absolute path of the static file to serve.
388
386
  * @returns The response.
389
387
  */
390
- #l(e) {
391
- const r = `${this.#e}${e}`;
392
- if (!this.php.fileExists(r))
388
+ #c(e) {
389
+ if (!this.php.fileExists(e))
393
390
  return new b(
394
391
  404,
395
- {},
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
+ },
396
397
  new TextEncoder().encode("404 File not found")
397
398
  );
398
- const n = this.php.readFileAsBuffer(r);
399
+ const r = this.php.readFileAsBuffer(e);
399
400
  return new b(
400
401
  200,
401
402
  {
402
- "content-length": [`${n.byteLength}`],
403
+ "content-length": [`${r.byteLength}`],
403
404
  // @TODO: Infer the content-type from the arrayBuffer instead of the file path.
404
405
  // The code below won't return the correct mime-type if the extension
405
406
  // was tampered with.
406
- "content-type": [ve(r)],
407
+ "content-type": [ve(e)],
407
408
  "accept-ranges": ["bytes"],
408
409
  "cache-control": ["public, max-age=0"]
409
410
  },
410
- n
411
+ r
411
412
  );
412
413
  }
413
414
  /**
@@ -417,7 +418,7 @@ class Re {
417
418
  * @param request - The request.
418
419
  * @returns The response.
419
420
  */
420
- async #u(e, r) {
421
+ async #l(e, r) {
421
422
  const n = await this.#a.acquire();
422
423
  try {
423
424
  this.php.addServerGlobalEntry("DOCUMENT_ROOT", this.#e), this.php.addServerGlobalEntry(
@@ -425,32 +426,32 @@ class Re {
425
426
  this.#o.startsWith("https://") ? "on" : ""
426
427
  );
427
428
  let s = "GET";
428
- const o = {
429
+ const i = {
429
430
  host: this.#i,
430
431
  ...Q(e.headers || {})
431
- }, i = [];
432
+ }, o = [];
432
433
  if (e.files && Object.keys(e.files).length) {
433
434
  s = "POST";
434
435
  for (const a in e.files) {
435
436
  const h = e.files[a];
436
- i.push({
437
+ o.push({
437
438
  key: a,
438
439
  name: h.name,
439
440
  type: h.type,
440
441
  data: new Uint8Array(await h.arrayBuffer())
441
442
  });
442
443
  }
443
- o["content-type"]?.startsWith("multipart/form-data") && (e.formData = ke(
444
+ i["content-type"]?.startsWith("multipart/form-data") && (e.formData = Re(
444
445
  e.body || ""
445
- ), o["content-type"] = "application/x-www-form-urlencoded", delete e.body);
446
+ ), i["content-type"] = "application/x-www-form-urlencoded", delete e.body);
446
447
  }
447
448
  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 !== void 0 ? (s = "POST", i["content-type"] = i["content-type"] || "application/x-www-form-urlencoded", c = new URLSearchParams(
449
450
  e.formData
450
451
  ).toString()) : c = e.body;
451
452
  let l;
452
453
  try {
453
- l = this.#h(r.pathname);
454
+ l = this.#u(r.pathname);
454
455
  } catch {
455
456
  return new b(
456
457
  404,
@@ -466,9 +467,9 @@ class Re {
466
467
  protocol: this.#t,
467
468
  method: e.method || s,
468
469
  body: c,
469
- fileInfos: i,
470
+ fileInfos: o,
470
471
  scriptPath: l,
471
- headers: o
472
+ headers: i
472
473
  });
473
474
  } finally {
474
475
  n();
@@ -483,7 +484,7 @@ class Re {
483
484
  * @throws {Error} If the requested path doesn't exist.
484
485
  * @returns The resolved filesystem path.
485
486
  */
486
- #h(e) {
487
+ #u(e) {
487
488
  let r = G(e, this.#s);
488
489
  r.includes(".php") ? r = r.split(".php")[0] + ".php" : (r.endsWith("/") || (r += "/"), r.endsWith("index.php") || (r += "index.php"));
489
490
  const n = `${this.#e}${r}`;
@@ -494,15 +495,15 @@ class Re {
494
495
  return `${this.#e}/index.php`;
495
496
  }
496
497
  }
497
- function ke(t) {
498
+ function Re(t) {
498
499
  const e = {}, r = t.match(/--(.*)\r\n/);
499
500
  if (!r)
500
501
  return e;
501
502
  const n = r[1], s = t.split(`--${n}`);
502
- return s.shift(), s.pop(), s.forEach((o) => {
503
- const i = o.indexOf(`\r
503
+ return s.shift(), s.pop(), s.forEach((i) => {
504
+ const o = i.indexOf(`\r
504
505
  \r
505
- `), c = o.substring(0, i).trim(), l = o.substring(i + 4).trim(), a = c.match(/name="([^"]+)"/);
506
+ `), c = i.substring(0, o).trim(), l = i.substring(o + 4).trim(), a = c.match(/name="([^"]+)"/);
506
507
  if (a) {
507
508
  const h = a[1];
508
509
  e[h] = l;
@@ -549,6 +550,15 @@ function ve(t) {
549
550
  return "application-octet-stream";
550
551
  }
551
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
+ }
552
562
  const V = {
553
563
  0: "No error occurred. System call completed successfully.",
554
564
  1: "Argument list too long.",
@@ -630,14 +640,14 @@ const V = {
630
640
  };
631
641
  function y(t = "") {
632
642
  return function(r, n, s) {
633
- const o = s.value;
634
- s.value = function(...i) {
643
+ const i = s.value;
644
+ s.value = function(...o) {
635
645
  try {
636
- return o.apply(this, i);
646
+ return i.apply(this, o);
637
647
  } catch (c) {
638
648
  const l = typeof c == "object" ? c?.errno : null;
639
649
  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;
650
+ const a = V[l], h = typeof o[0] == "string" ? o[0] : null, g = h !== null ? t.replaceAll("{path}", h) : t;
641
651
  throw new Error(`${g}: ${a}`, {
642
652
  cause: c
643
653
  });
@@ -647,10 +657,10 @@ function y(t = "") {
647
657
  };
648
658
  };
649
659
  }
650
- async function xe(t, e = {}, r = []) {
651
- const [n, s, o] = Y(), [i, c] = Y(), l = t.init(Te, {
660
+ async function _e(t, e = {}, r = []) {
661
+ const [n, s, i] = Y(), [o, c] = Y(), l = t.init(He, {
652
662
  onAbort(a) {
653
- o(a), c(), console.error(a);
663
+ i(a), c(), console.error(a);
654
664
  },
655
665
  ENV: {},
656
666
  // Emscripten sometimes prepends a '/' to the path, which
@@ -670,13 +680,13 @@ async function xe(t, e = {}, r = []) {
670
680
  r.map(
671
681
  ({ default: a }) => a(l)
672
682
  )
673
- ), r.length || c(), await i, await n, M.push(l), M.length - 1;
683
+ ), r.length || c(), await o, await n, M.push(l), M.length - 1;
674
684
  }
675
685
  const M = [];
676
- function Se(t) {
686
+ function Ce(t) {
677
687
  return M[t];
678
688
  }
679
- const Te = function() {
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
691
  }(), Y = () => {
682
692
  const t = [], e = new Promise((r, n) => {
@@ -684,10 +694,10 @@ const Te = function() {
684
694
  });
685
695
  return t.unshift(e), t;
686
696
  };
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--)
689
- (i = t[o]) && (s = (n ? i(e, r, s) : i(s)) || s);
690
- return n && s && _e(e, r, s), s;
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;
691
701
  };
692
702
  const f = "string", E = "number", u = Symbol("__private__dont__use");
693
703
  class m {
@@ -700,7 +710,7 @@ class m {
700
710
  */
701
711
  constructor(e, r) {
702
712
  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)
713
+ new ke(this, r)
704
714
  ));
705
715
  }
706
716
  #e;
@@ -733,7 +743,7 @@ class m {
733
743
  initializeRuntime(e) {
734
744
  if (this[u])
735
745
  throw new Error("PHP runtime already initialized.");
736
- const r = Se(e);
746
+ const r = Ce(e);
737
747
  if (!r)
738
748
  throw new Error("Invalid PHP runtime id.");
739
749
  this[u] = r, r.onMessage = (n) => {
@@ -805,8 +815,8 @@ class m {
805
815
  for (const s of r.headers) {
806
816
  if (!s.includes(": "))
807
817
  continue;
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);
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);
810
820
  }
811
821
  return {
812
822
  headers: n,
@@ -924,14 +934,14 @@ class m {
924
934
  * @param fileInfo - File details
925
935
  */
926
936
  #p(e) {
927
- const { key: r, name: n, type: s, data: o } = e, i = `/tmp/${Math.random().toFixed(20)}`;
928
- this.writeFile(i, o);
937
+ const { key: r, name: n, type: s, data: i } = e, o = `/tmp/${Math.random().toFixed(20)}`;
938
+ this.writeFile(o, i);
929
939
  const c = 0;
930
940
  this[u].ccall(
931
941
  "wasm_add_uploaded_file",
932
942
  null,
933
943
  [f, f, f, f, E, E],
934
- [r, n, s, i, c, o.byteLength]
944
+ [r, n, s, o, c, i.byteLength]
935
945
  );
936
946
  }
937
947
  #m(e) {
@@ -945,10 +955,10 @@ class m {
945
955
  async #g() {
946
956
  let e, r;
947
957
  try {
948
- e = await new Promise((o, i) => {
958
+ e = await new Promise((i, o) => {
949
959
  r = (l) => {
950
960
  const a = new Error("Rethrown");
951
- a.cause = l.error, a.betterMessage = l.message, i(a);
961
+ a.cause = l.error, a.betterMessage = l.message, o(a);
952
962
  }, this.#n?.addEventListener(
953
963
  "error",
954
964
  r
@@ -959,9 +969,9 @@ class m {
959
969
  [],
960
970
  []
961
971
  );
962
- return c instanceof Promise ? c.then(o, i) : o(c);
972
+ return c instanceof Promise ? c.then(i, o) : i(c);
963
973
  });
964
- } catch (o) {
974
+ } catch (i) {
965
975
  for (const a in this)
966
976
  typeof this[a] == "function" && (this[a] = () => {
967
977
  throw new Error(
@@ -969,8 +979,8 @@ class m {
969
979
  );
970
980
  });
971
981
  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;
982
+ const o = i, c = "betterMessage" in o ? o.betterMessage : o.message, l = new Error(c);
983
+ throw l.cause = o, l;
974
984
  } finally {
975
985
  this.#n?.removeEventListener("error", r), this.#r = {};
976
986
  }
@@ -1019,7 +1029,7 @@ class m {
1019
1029
  );
1020
1030
  if (r.prependPath) {
1021
1031
  const s = e.replace(/\/$/, "");
1022
- return n.map((o) => `${s}/${o}`);
1032
+ return n.map((i) => `${s}/${i}`);
1023
1033
  }
1024
1034
  return n;
1025
1035
  } catch (n) {
@@ -1083,16 +1093,16 @@ function Q(t) {
1083
1093
  * Copyright 2019 Google LLC
1084
1094
  * SPDX-License-Identifier: Apache-2.0
1085
1095
  */
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 = {
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 = {
1087
1097
  canHandle: (t) => Z(t) && t[X],
1088
1098
  serialize(t) {
1089
1099
  const { port1: e, port2: r } = new MessageChannel();
1090
- return F(t, e), [r, [r]];
1100
+ return H(t, e), [r, [r]];
1091
1101
  },
1092
1102
  deserialize(t) {
1093
1103
  return t.start(), U(t);
1094
1104
  }
1095
- }, Me = {
1105
+ }, Ie = {
1096
1106
  canHandle: (t) => Z(t) && S in t,
1097
1107
  serialize({ value: t }) {
1098
1108
  let e;
@@ -1110,27 +1120,27 @@ const X = Symbol("Comlink.proxy"), Fe = Symbol("Comlink.endpoint"), He = Symbol(
1110
1120
  }
1111
1121
  }, v = /* @__PURE__ */ new Map([
1112
1122
  ["proxy", Oe],
1113
- ["throw", Me]
1123
+ ["throw", Ie]
1114
1124
  ]);
1115
- function Ae(t, e) {
1125
+ function Ue(t, e) {
1116
1126
  for (const r of t)
1117
1127
  if (e === r || r === "*" || r instanceof RegExp && r.test(e))
1118
1128
  return !0;
1119
1129
  return !1;
1120
1130
  }
1121
- function F(t, e = globalThis, r = ["*"]) {
1131
+ function H(t, e = globalThis, r = ["*"]) {
1122
1132
  e.addEventListener("message", function n(s) {
1123
1133
  if (!s || !s.data)
1124
1134
  return;
1125
- if (!Ae(r, s.origin)) {
1135
+ if (!Ue(r, s.origin)) {
1126
1136
  console.warn(`Invalid origin '${s.origin}' for comlink proxy`);
1127
1137
  return;
1128
1138
  }
1129
- const { id: o, type: i, path: c } = Object.assign({ path: [] }, s.data), l = (s.data.argumentList || []).map(P);
1139
+ const { id: i, type: o, path: c } = Object.assign({ path: [] }, s.data), l = (s.data.argumentList || []).map(P);
1130
1140
  let a;
1131
1141
  try {
1132
- const h = c.slice(0, -1).reduce((p, k) => p[k], t), g = c.reduce((p, k) => p[k], t);
1133
- switch (i) {
1142
+ const h = c.slice(0, -1).reduce((p, R) => p[R], t), g = c.reduce((p, R) => p[R], t);
1143
+ switch (o) {
1134
1144
  case "GET":
1135
1145
  a = g;
1136
1146
  break;
@@ -1148,8 +1158,8 @@ function F(t, e = globalThis, r = ["*"]) {
1148
1158
  break;
1149
1159
  case "ENDPOINT":
1150
1160
  {
1151
- const { port1: p, port2: k } = new MessageChannel();
1152
- F(t, k), a = We(p, [p]);
1161
+ const { port1: p, port2: R } = new MessageChannel();
1162
+ H(t, R), a = qe(p, [p]);
1153
1163
  }
1154
1164
  break;
1155
1165
  case "RELEASE":
@@ -1163,31 +1173,31 @@ function F(t, e = globalThis, r = ["*"]) {
1163
1173
  }
1164
1174
  Promise.resolve(a).catch((h) => ({ value: h, [S]: 0 })).then((h) => {
1165
1175
  const [g, p] = C(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]());
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]());
1167
1177
  }).catch((h) => {
1168
1178
  const [g, p] = C({
1169
1179
  value: new TypeError("Unserializable return value"),
1170
1180
  [S]: 0
1171
1181
  });
1172
- e.postMessage(Object.assign(Object.assign({}, g), { id: o }), p);
1182
+ e.postMessage(Object.assign(Object.assign({}, g), { id: i }), p);
1173
1183
  });
1174
1184
  }), e.start && e.start();
1175
1185
  }
1176
- function Le(t) {
1186
+ function Ne(t) {
1177
1187
  return t.constructor.name === "MessagePort";
1178
1188
  }
1179
1189
  function ee(t) {
1180
- Le(t) && t.close();
1190
+ Ne(t) && t.close();
1181
1191
  }
1182
1192
  function U(t, e) {
1183
- return A(t, [], e);
1193
+ return L(t, [], e);
1184
1194
  }
1185
1195
  function x(t) {
1186
1196
  if (t)
1187
1197
  throw new Error("Proxy has been released and is not useable");
1188
1198
  }
1189
1199
  function te(t) {
1190
- return R(t, {
1200
+ return k(t, {
1191
1201
  type: "RELEASE"
1192
1202
  }).then(() => {
1193
1203
  ee(t);
@@ -1197,79 +1207,79 @@ const T = /* @__PURE__ */ new WeakMap(), _ = "FinalizationRegistry" in globalThi
1197
1207
  const e = (T.get(t) || 0) - 1;
1198
1208
  T.set(t, e), e === 0 && te(t);
1199
1209
  });
1200
- function Ie(t, e) {
1210
+ function We(t, e) {
1201
1211
  const r = (T.get(e) || 0) + 1;
1202
1212
  T.set(e, r), _ && _.register(t, e, t);
1203
1213
  }
1204
- function Ue(t) {
1214
+ function $e(t) {
1205
1215
  _ && _.unregister(t);
1206
1216
  }
1207
- function A(t, e = [], r = function() {
1217
+ function L(t, e = [], r = function() {
1208
1218
  }) {
1209
1219
  let n = !1;
1210
1220
  const s = new Proxy(r, {
1211
- get(o, i) {
1212
- if (x(n), i === He)
1221
+ get(i, o) {
1222
+ if (x(n), o === Le)
1213
1223
  return () => {
1214
- Ue(s), te(t), n = !0;
1224
+ $e(s), te(t), n = !0;
1215
1225
  };
1216
- if (i === "then") {
1226
+ if (o === "then") {
1217
1227
  if (e.length === 0)
1218
1228
  return { then: () => s };
1219
- const c = R(t, {
1229
+ const c = k(t, {
1220
1230
  type: "GET",
1221
1231
  path: e.map((l) => l.toString())
1222
1232
  }).then(P);
1223
1233
  return c.then.bind(c);
1224
1234
  }
1225
- return A(t, [...e, i]);
1235
+ return L(t, [...e, o]);
1226
1236
  },
1227
- set(o, i, c) {
1237
+ set(i, o, c) {
1228
1238
  x(n);
1229
1239
  const [l, a] = C(c);
1230
- return R(t, {
1240
+ return k(t, {
1231
1241
  type: "SET",
1232
- path: [...e, i].map((h) => h.toString()),
1242
+ path: [...e, o].map((h) => h.toString()),
1233
1243
  value: l
1234
1244
  }, a).then(P);
1235
1245
  },
1236
- apply(o, i, c) {
1246
+ apply(i, o, c) {
1237
1247
  x(n);
1238
1248
  const l = e[e.length - 1];
1239
- if (l === Fe)
1240
- return R(t, {
1249
+ if (l === Me)
1250
+ return k(t, {
1241
1251
  type: "ENDPOINT"
1242
1252
  }).then(P);
1243
1253
  if (l === "bind")
1244
- return A(t, e.slice(0, -1));
1254
+ return L(t, e.slice(0, -1));
1245
1255
  const [a, h] = J(c);
1246
- return R(t, {
1256
+ return k(t, {
1247
1257
  type: "APPLY",
1248
1258
  path: e.map((g) => g.toString()),
1249
1259
  argumentList: a
1250
1260
  }, h).then(P);
1251
1261
  },
1252
- construct(o, i) {
1262
+ construct(i, o) {
1253
1263
  x(n);
1254
- const [c, l] = J(i);
1255
- return R(t, {
1264
+ const [c, l] = J(o);
1265
+ return k(t, {
1256
1266
  type: "CONSTRUCT",
1257
1267
  path: e.map((a) => a.toString()),
1258
1268
  argumentList: c
1259
1269
  }, l).then(P);
1260
1270
  }
1261
1271
  });
1262
- return Ie(s, t), s;
1272
+ return We(s, t), s;
1263
1273
  }
1264
- function Ne(t) {
1274
+ function De(t) {
1265
1275
  return Array.prototype.concat.apply([], t);
1266
1276
  }
1267
1277
  function J(t) {
1268
1278
  const e = t.map(C);
1269
- return [e.map((r) => r[0]), Ne(e.map((r) => r[1]))];
1279
+ return [e.map((r) => r[0]), De(e.map((r) => r[1]))];
1270
1280
  }
1271
1281
  const re = /* @__PURE__ */ new WeakMap();
1272
- function We(t, e) {
1282
+ function qe(t, e) {
1273
1283
  return re.set(t, e), t;
1274
1284
  }
1275
1285
  function ne(t) {
@@ -1311,46 +1321,46 @@ function P(t) {
1311
1321
  return t.value;
1312
1322
  }
1313
1323
  }
1314
- function R(t, e, r) {
1324
+ function k(t, e, r) {
1315
1325
  return new Promise((n) => {
1316
- const s = $e();
1317
- t.addEventListener("message", function o(i) {
1318
- !i.data || !i.data.id || i.data.id !== s || (t.removeEventListener("message", o), n(i.data));
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));
1319
1329
  }), t.start && t.start(), t.postMessage(Object.assign({ id: s }, e), r);
1320
1330
  });
1321
1331
  }
1322
- function $e() {
1332
+ function ze() {
1323
1333
  return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
1324
1334
  }
1325
- function Ge(t) {
1335
+ function Je(t) {
1326
1336
  ie();
1327
1337
  const e = t instanceof Worker ? t : se(t), r = U(e), n = N(r);
1328
1338
  return new Proxy(n, {
1329
- get: (s, o) => o === "isConnected" ? async () => {
1330
- for (let i = 0; i < 10; i++)
1339
+ get: (s, i) => i === "isConnected" ? async () => {
1340
+ for (let o = 0; o < 10; o++)
1331
1341
  try {
1332
- await De(r.isConnected(), 200);
1342
+ await Be(r.isConnected(), 200);
1333
1343
  break;
1334
1344
  } catch {
1335
1345
  }
1336
- } : r[o]
1346
+ } : r[i]
1337
1347
  });
1338
1348
  }
1339
- async function De(t, e) {
1349
+ async function Be(t, e) {
1340
1350
  return new Promise((r, n) => {
1341
1351
  setTimeout(n, e), t.then(r);
1342
1352
  });
1343
1353
  }
1344
- function Ve(t, e) {
1354
+ function Ke(t, e) {
1345
1355
  ie();
1346
1356
  const r = Promise.resolve();
1347
1357
  let n, s;
1348
- const o = new Promise((l, a) => {
1358
+ const i = new Promise((l, a) => {
1349
1359
  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]
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]
1352
1362
  });
1353
- return F(
1363
+ return H(
1354
1364
  c,
1355
1365
  typeof window < "u" ? se(self.parent) : void 0
1356
1366
  ), [n, s, c];
@@ -1371,7 +1381,7 @@ function ie() {
1371
1381
  serialize(t) {
1372
1382
  console.debug("[Comlink][Performance] Proxying a function");
1373
1383
  const { port1: e, port2: r } = new MessageChannel();
1374
- return F(t, e), [r, [r]];
1384
+ return H(t, e), [r, [r]];
1375
1385
  },
1376
1386
  deserialize(t) {
1377
1387
  return t.start(), U(t);
@@ -1404,30 +1414,52 @@ function N(t) {
1404
1414
  }
1405
1415
  });
1406
1416
  }
1407
- async function qe(t = ye) {
1408
- switch (t) {
1409
- case "8.2":
1410
- return await import("./php_8_2.js");
1411
- case "8.1":
1412
- return await import("./php_8_1.js");
1413
- case "8.0":
1414
- return await import("./php_8_0.js");
1415
- case "7.4":
1416
- return await import("./php_7_4.js");
1417
- case "7.3":
1418
- return await import("./php_7_3.js");
1419
- case "7.2":
1420
- return await import("./php_7_2.js");
1421
- case "7.1":
1422
- return await import("./php_7_1.js");
1423
- case "7.0":
1424
- return await import("./php_7_0.js");
1425
- case "5.6":
1426
- return await import("./php_5_6.js");
1427
- }
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
+ }
1428
1460
  throw new Error(`Unsupported PHP version ${t}`);
1429
1461
  }
1430
- const ze = () => ({
1462
+ const Ge = () => ({
1431
1463
  websocket: {
1432
1464
  decorator: (t) => class extends t {
1433
1465
  constructor() {
@@ -1442,7 +1474,7 @@ const ze = () => ({
1442
1474
  }
1443
1475
  }
1444
1476
  });
1445
- class L extends m {
1477
+ class O extends m {
1446
1478
  /**
1447
1479
  * Creates a new PHP instance.
1448
1480
  *
@@ -1456,7 +1488,7 @@ class L extends m {
1456
1488
  * @returns A new PHP instance
1457
1489
  */
1458
1490
  static async load(e, r = {}) {
1459
- return await L.loadSync(e, r).phpReady;
1491
+ return await O.loadSync(e, r).phpReady;
1460
1492
  }
1461
1493
  /**
1462
1494
  * Does what load() does, but synchronously returns
@@ -1466,22 +1498,22 @@ class L extends m {
1466
1498
  * @see load
1467
1499
  */
1468
1500
  static loadSync(e, r = {}) {
1469
- const n = new L(void 0, r.requestHandler), o = (async () => {
1470
- const i = await Promise.all([
1471
- qe(e),
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),
1472
1504
  ...r.dataModules || []
1473
- ]), [c, ...l] = i;
1474
- r.downloadMonitor?.setModules(i);
1475
- const a = await xe(
1476
- c,
1505
+ ]), [l, ...a] = c;
1506
+ r.downloadMonitor?.setModules(c);
1507
+ const h = await _e(
1508
+ l,
1477
1509
  {
1478
1510
  ...r.emscriptenOptions || {},
1479
1511
  ...r.downloadMonitor?.getEmscriptenOptions() || {},
1480
- ...ze()
1512
+ ...Ge()
1481
1513
  },
1482
- l
1514
+ a
1483
1515
  );
1484
- n.initializeRuntime(a);
1516
+ n.initializeRuntime(h);
1485
1517
  })();
1486
1518
  return {
1487
1519
  php: n,
@@ -1490,7 +1522,7 @@ class L extends m {
1490
1522
  }
1491
1523
  }
1492
1524
  const d = /* @__PURE__ */ new WeakMap();
1493
- class Je {
1525
+ class Xe {
1494
1526
  /** @inheritDoc */
1495
1527
  constructor(e, r) {
1496
1528
  d.set(this, {
@@ -1581,14 +1613,14 @@ class Je {
1581
1613
  d.get(this).php.onMessage(e);
1582
1614
  }
1583
1615
  }
1584
- function Be(t, e) {
1616
+ function Ve(t, e) {
1585
1617
  return {
1586
1618
  type: "response",
1587
1619
  requestId: t,
1588
1620
  response: e
1589
1621
  };
1590
1622
  }
1591
- async function Ke(t, e, r) {
1623
+ async function Ze(t, e, r) {
1592
1624
  const n = navigator.serviceWorker;
1593
1625
  if (!n)
1594
1626
  throw new Error("Service workers are not supported in this browser.");
@@ -1598,51 +1630,48 @@ async function Ke(t, e, r) {
1598
1630
  updateViaCache: "none"
1599
1631
  })).update(), navigator.serviceWorker.addEventListener(
1600
1632
  "message",
1601
- async function(i) {
1602
- if (console.debug("[window][sw] Message from ServiceWorker", i), e && i.data.scope !== e)
1633
+ async function(o) {
1634
+ if (console.debug("[window][sw] Message from ServiceWorker", o), e && o.data.scope !== e)
1603
1635
  return;
1604
- const c = i.data.args || [], l = i.data.method, a = await t[l](...c);
1605
- i.source.postMessage(Be(i.data.requestId, a));
1636
+ const c = o.data.args || [], l = o.data.method, a = await t[l](...c);
1637
+ o.source.postMessage(Ve(o.data.requestId, a));
1606
1638
  }
1607
1639
  ), n.startMessages();
1608
1640
  }
1609
- function Qe() {
1610
- const t = {};
1611
- return typeof self?.location?.href < "u" && new URL(self.location.href).searchParams.forEach((r, n) => {
1612
- t[n] = r;
1613
- }), t;
1614
- }
1615
- async function Xe(t, e = {}) {
1616
- t = je(t, e);
1641
+ async function et(t, e = {}) {
1642
+ t = Ye(t, e);
1617
1643
  const r = new Worker(t, { type: "module" });
1618
1644
  return new Promise((n, s) => {
1619
- r.onerror = (i) => {
1645
+ r.onerror = (o) => {
1620
1646
  const c = new Error(
1621
- `WebWorker failed to load at ${t}. ${i.message ? `Original error: ${i.message}` : ""}`
1647
+ `WebWorker failed to load at ${t}. ${o.message ? `Original error: ${o.message}` : ""}`
1622
1648
  );
1623
- c.filename = i.filename, s(c);
1649
+ c.filename = o.filename, s(c);
1624
1650
  };
1625
- function o(i) {
1626
- i.data === "worker-script-started" && (n(r), r.removeEventListener("message", o));
1651
+ function i(o) {
1652
+ o.data === "worker-script-started" && (n(r), r.removeEventListener("message", i));
1627
1653
  }
1628
- r.addEventListener("message", o);
1654
+ r.addEventListener("message", i);
1629
1655
  });
1630
1656
  }
1631
- function je(t, e) {
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
- r.searchParams.set(n, s);
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
1669
  export {
1640
- L as WebPHP,
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
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
1648
1677
  };