@php-wasm/universal 3.0.46 → 3.0.52

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
@@ -1,8 +1,8 @@
1
- var B = (t) => {
1
+ var $ = (t) => {
2
2
  throw TypeError(t);
3
3
  };
4
- var O = (t, e, r) => e.has(t) || B("Cannot " + r);
5
- var u = (t, e, r) => (O(t, e, "read from private field"), r ? r.call(t) : e.get(t)), y = (t, e, r) => e.has(t) ? B("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, r), P = (t, e, r, s) => (O(t, e, "write to private field"), s ? s.call(t, r) : e.set(t, r), r), m = (t, e, r) => (O(t, e, "access private method"), r);
4
+ var j = (t, e, r) => e.has(t) || $("Cannot " + r);
5
+ var u = (t, e, r) => (j(t, e, "read from private field"), r ? r.call(t) : e.get(t)), y = (t, e, r) => e.has(t) ? $("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, r), _ = (t, e, r, s) => (j(t, e, "write to private field"), s ? s.call(t, r) : e.set(t, r), r), m = (t, e, r) => (j(t, e, "access private method"), r);
6
6
  import "@php-wasm/node-polyfills";
7
7
  import { logger } from "@php-wasm/logger";
8
8
  import { dirname, joinPaths, Semaphore, createSpawnHandler, basename, normalizePath, AcquireTimeoutError, splitShellCommand } from "@php-wasm/util";
@@ -105,10 +105,10 @@ function rethrowFileSystemError(t = "") {
105
105
  } catch (n) {
106
106
  const i = typeof n == "object" ? n == null ? void 0 : n.errno : null;
107
107
  if (i in FileErrorCodes) {
108
- const o = FileErrorCodes[i], a = typeof s[1] == "string" ? s[1] : null, c = a !== null ? t.replaceAll("{path}", a) : t;
108
+ const o = FileErrorCodes[i], c = typeof s[1] == "string" ? s[1] : null, a = c !== null ? t.replaceAll("{path}", c) : t;
109
109
  throw new ErrnoError(
110
110
  i,
111
- `${c}: ${o}`,
111
+ `${a}: ${o}`,
112
112
  {
113
113
  cause: n
114
114
  }
@@ -368,7 +368,7 @@ class PHPWorker {
368
368
  /** @inheritDoc */
369
369
  constructor(e, r) {
370
370
  y(this, x);
371
- this.absoluteUrl = "", this.documentRoot = "", this.chroot = null, P(this, x, /* @__PURE__ */ new Map()), this.onMessageListeners = [], _private.set(this, {
371
+ this.absoluteUrl = "", this.documentRoot = "", this.chroot = null, _(this, x, /* @__PURE__ */ new Map()), this.onMessageListeners = [], _private.set(this, {
372
372
  monitor: r
373
373
  }), e && this.__internal_setRequestHandler(e);
374
374
  }
@@ -566,14 +566,14 @@ const RuntimeId = Symbol("RuntimeId"), loadedRuntimes = /* @__PURE__ */ new Map(
566
566
  let lastRuntimeId = 0;
567
567
  async function loadPHPRuntime(t, ...e) {
568
568
  const r = Object.assign({}, ...e), [s, n, i] = makePromise(), o = t.init(currentJsRuntime, {
569
- onAbort(c) {
570
- i(c), logger.error(c);
569
+ onAbort(a) {
570
+ i(a), logger.error(a);
571
571
  },
572
572
  ENV: {},
573
573
  // Emscripten sometimes prepends a '/' to the path, which
574
574
  // breaks vite dev mode. An identity `locateFile` function
575
575
  // fixes it.
576
- locateFile: (c) => c,
576
+ locateFile: (a) => a,
577
577
  ...r,
578
578
  noInitialRun: !0,
579
579
  onRuntimeInitialized() {
@@ -581,10 +581,10 @@ async function loadPHPRuntime(t, ...e) {
581
581
  }
582
582
  });
583
583
  await s;
584
- const a = ++lastRuntimeId;
585
- return o.FS, o.id = a, o.originalExit = o._exit, o._exit = function(c) {
586
- return o.outboundNetworkProxyServer && (o.outboundNetworkProxyServer.close(), o.outboundNetworkProxyServer.closeAllConnections()), loadedRuntimes.delete(a), o.originalExit(c);
587
- }, o[RuntimeId] = a, loadedRuntimes.set(a, o), a;
584
+ const c = ++lastRuntimeId;
585
+ return o.FS, o.id = c, o.originalExit = o._exit, o._exit = function(a) {
586
+ return o.outboundNetworkProxyServer && (o.outboundNetworkProxyServer.close(), o.outboundNetworkProxyServer.closeAllConnections()), loadedRuntimes.delete(c), o.originalExit(a);
587
+ }, o[RuntimeId] = c, loadedRuntimes.set(c, o), c;
588
588
  }
589
589
  function popLoadedRuntime(t, {
590
590
  dangerouslyKeepTheRuntimeInTheMap: e = !1
@@ -700,8 +700,8 @@ async function parseHeadersStream(t) {
700
700
  for (const n of r.headers) {
701
701
  if (!n.includes(": "))
702
702
  continue;
703
- const i = n.indexOf(": "), o = n.substring(0, i).toLowerCase(), a = n.substring(i + 2);
704
- o in s || (s[o] = []), s[o].push(a);
703
+ const i = n.indexOf(": "), o = n.substring(0, i).toLowerCase(), c = n.substring(i + 2);
704
+ o in s || (s[o] = []), s[o].push(c);
705
705
  }
706
706
  return {
707
707
  headers: s,
@@ -723,12 +723,12 @@ async function streamToBytes(t) {
723
723
  const { done: s, value: n } = await e.read();
724
724
  if (s) {
725
725
  const i = r.reduce(
726
- (c, l) => c + l.byteLength,
726
+ (a, l) => a + l.byteLength,
727
727
  0
728
728
  ), o = new Uint8Array(i);
729
- let a = 0;
730
- for (const c of r)
731
- o.set(c, a), a += c.byteLength;
729
+ let c = 0;
730
+ for (const a of r)
731
+ o.set(a, c), c += a.byteLength;
732
732
  return o;
733
733
  }
734
734
  n && r.push(n);
@@ -852,16 +852,16 @@ function improveWASMErrorReporting(t) {
852
852
  if (!(o instanceof Error))
853
853
  throw o;
854
854
  t.lastAsyncifyStackSource && (o.cause = t.lastAsyncifyStackSource);
855
- const a = clarifyErrorMessage(
855
+ const c = clarifyErrorMessage(
856
856
  o,
857
857
  (i = t.lastAsyncifyStackSource) == null ? void 0 : i.stack
858
858
  );
859
859
  if (e.hasListeners()) {
860
- o.message = a;
861
- const c = new ErrorEvent("error", { error: o });
862
- throw e.dispatchEvent(c), o;
860
+ o.message = c;
861
+ const a = new ErrorEvent("error", { error: o });
862
+ throw e.dispatchEvent(a), o;
863
863
  }
864
- throw (!isExitCode(o) || o.status !== 0) && showCriticalErrorBox(a), o;
864
+ throw (!isExitCode(o) || o.status !== 0) && showCriticalErrorBox(c), o;
865
865
  }
866
866
  };
867
867
  }
@@ -961,7 +961,7 @@ class PHPExecutionFailureError extends Error {
961
961
  }
962
962
  }
963
963
  const PHP_INI_PATH = "/internal/shared/php.ini", AUTO_PREPEND_SCRIPT = "/internal/shared/auto_prepend_file.php", OPCACHE_FILE_FOLDER = "/internal/shared/opcache";
964
- var M, H, T, v, F, k, _, h, z, $, V, G, J, Y, Q, X, U, K, j, q;
964
+ var M, H, T, v, F, k, w, h, V, G, J, Y, Q, X, K, Z, q, ee, D, W;
965
965
  class PHP {
966
966
  /**
967
967
  * Initializes a PHP runtime.
@@ -981,7 +981,7 @@ class PHP {
981
981
  ]));
982
982
  y(this, F, []);
983
983
  y(this, k, {});
984
- y(this, _, {
984
+ y(this, w, {
985
985
  enabled: !1,
986
986
  recreateRuntime: () => 0,
987
987
  needsRotating: !1,
@@ -989,7 +989,7 @@ class PHP {
989
989
  requestsMade: 0
990
990
  });
991
991
  this.semaphore = new Semaphore({ concurrency: 1 }), t !== void 0 && this.initializeRuntime(t), this.addEventListener("request.error", (e) => {
992
- e.source === "php-wasm" && (u(this, _).needsRotating = !0);
992
+ e.source === "php-wasm" && (u(this, w).needsRotating = !0);
993
993
  });
994
994
  }
995
995
  /**
@@ -1059,7 +1059,7 @@ class PHP {
1059
1059
  */
1060
1060
  onMessage(t) {
1061
1061
  return u(this, F).push(t), async () => {
1062
- P(this, F, u(this, F).filter(
1062
+ _(this, F, u(this, F).filter(
1063
1063
  (e) => e !== t
1064
1064
  ));
1065
1065
  };
@@ -1159,7 +1159,7 @@ class PHP {
1159
1159
  return n;
1160
1160
  }
1161
1161
  return "";
1162
- }, P(this, T, improveWASMErrorReporting(e)), this.dispatchEvent({
1162
+ }, _(this, T, improveWASMErrorReporting(e)), this.dispatchEvent({
1163
1163
  type: "runtime.initialized"
1164
1164
  });
1165
1165
  }
@@ -1174,7 +1174,7 @@ class PHP {
1174
1174
  throw new Error(
1175
1175
  "Could not set SAPI name. This can only be done before the PHP WASM module is initialized.Did you already dispatch any requests?"
1176
1176
  );
1177
- P(this, M, t);
1177
+ _(this, M, t);
1178
1178
  }
1179
1179
  /**
1180
1180
  * Changes the current working directory in the PHP filesystem.
@@ -1396,7 +1396,7 @@ class PHP {
1396
1396
  async runStream(t) {
1397
1397
  const e = await this.semaphore.acquire();
1398
1398
  let r;
1399
- const s = m(this, h, q).call(this, async () => {
1399
+ const s = m(this, h, W).call(this, async () => {
1400
1400
  if (u(this, H) || (await this[__private__dont__use].ccall(
1401
1401
  "php_wasm_init",
1402
1402
  null,
@@ -1405,26 +1405,26 @@ class PHP {
1405
1405
  {
1406
1406
  isAsync: !0
1407
1407
  }
1408
- ), P(this, H, !0)), t.scriptPath && !this.fileExists(t.scriptPath))
1408
+ ), _(this, H, !0)), t.scriptPath && !this.fileExists(t.scriptPath))
1409
1409
  throw new Error(
1410
1410
  `The script path "${t.scriptPath}" does not exist.`
1411
1411
  );
1412
- m(this, h, $).call(this, t.relativeUri || ""), m(this, h, Y).call(this, t.method || "GET");
1413
- const i = normalizeHeaders(t.headers || {}), o = i.host || "example.com:443", a = m(this, h, J).call(this, o, t.protocol || "http");
1414
- if (m(this, h, V).call(this, o), m(this, h, G).call(this, a), m(this, h, Q).call(this, i), t.body && (r = m(this, h, X).call(this, t.body)), typeof t.code == "string")
1415
- this.writeFile("/internal/eval.php", t.code), m(this, h, U).call(this, "/internal/eval.php");
1412
+ m(this, h, G).call(this, t.relativeUri || ""), m(this, h, X).call(this, t.method || "GET");
1413
+ const i = normalizeHeaders(t.headers || {}), o = i.host || "example.com:443", c = m(this, h, Q).call(this, o, t.protocol || "http");
1414
+ if (m(this, h, J).call(this, o), m(this, h, Y).call(this, c), m(this, h, K).call(this, i), t.body && (r = m(this, h, Z).call(this, t.body)), typeof t.code == "string")
1415
+ this.writeFile("/internal/eval.php", t.code), m(this, h, q).call(this, "/internal/eval.php");
1416
1416
  else if (typeof t.scriptPath == "string")
1417
- m(this, h, U).call(this, t.scriptPath || "");
1417
+ m(this, h, q).call(this, t.scriptPath || "");
1418
1418
  else
1419
1419
  throw new TypeError(
1420
1420
  "The request object must have either a `code` or a `scriptPath` property."
1421
1421
  );
1422
- const c = m(this, h, z).call(this, t.$_SERVER, i, a);
1423
- for (const p in c)
1424
- m(this, h, K).call(this, p, c[p]);
1422
+ const a = m(this, h, V).call(this, t.$_SERVER, i, c);
1423
+ for (const d in a)
1424
+ m(this, h, ee).call(this, d, a[d]);
1425
1425
  const l = t.env || {};
1426
- for (const p in l)
1427
- m(this, h, j).call(this, p, l[p]);
1426
+ for (const d in l)
1427
+ m(this, h, D).call(this, d, l[d]);
1428
1428
  return await this[__private__dont__use].ccall(
1429
1429
  "wasm_sapi_handle_request",
1430
1430
  NUMBER,
@@ -1647,21 +1647,21 @@ class PHP {
1647
1647
  * or an internal crash.
1648
1648
  */
1649
1649
  enableRuntimeRotation(t) {
1650
- P(this, _, {
1651
- ...u(this, _),
1650
+ _(this, w, {
1651
+ ...u(this, w),
1652
1652
  enabled: !0,
1653
1653
  recreateRuntime: t.recreateRuntime,
1654
1654
  maxRequests: t.maxRequests ?? 400
1655
1655
  });
1656
1656
  }
1657
1657
  async rotateRuntime() {
1658
- if (!u(this, _).enabled)
1658
+ if (!u(this, w).enabled)
1659
1659
  throw new Error(
1660
1660
  "Runtime rotation is not enabled. Call enableRuntimeRotation() first."
1661
1661
  );
1662
1662
  await this.hotSwapPHPRuntime(
1663
- await u(this, _).recreateRuntime()
1664
- ), u(this, _).requestsMade = 0, u(this, _).needsRotating = !1;
1663
+ await u(this, w).recreateRuntime()
1664
+ ), u(this, w).requestsMade = 0, u(this, w).needsRotating = !1;
1665
1665
  }
1666
1666
  /**
1667
1667
  * Hot-swaps the PHP runtime for a new one without
@@ -1670,35 +1670,35 @@ class PHP {
1670
1670
  * @param runtime
1671
1671
  */
1672
1672
  async hotSwapPHPRuntime(t) {
1673
- const e = this[__private__dont__use].FS, r = this.listFiles("/").map((c) => `/${c}`), s = this[__private__dont__use].spawnProcess, n = e.cwd();
1673
+ const e = this[__private__dont__use].FS, r = this.listFiles("/").map((a) => `/${a}`), s = this[__private__dont__use].spawnProcess, n = e.cwd();
1674
1674
  e.chdir("/");
1675
1675
  const i = Object.entries(u(this, k)).map(
1676
- ([c, l]) => ({
1676
+ ([a, l]) => ({
1677
1677
  mountHandler: l.mountHandler,
1678
- vfsPath: c
1678
+ vfsPath: a
1679
1679
  })
1680
1680
  ), o = Object.values(
1681
1681
  u(this, k)
1682
1682
  ).reverse();
1683
- for (const c of o)
1684
- await c.unmount();
1683
+ for (const a of o)
1684
+ await a.unmount();
1685
1685
  try {
1686
1686
  this.exit();
1687
1687
  } catch {
1688
1688
  }
1689
1689
  this.initializeRuntime(t), s && (this[__private__dont__use].spawnProcess = s), u(this, M) && this.setSapiName(u(this, M));
1690
- const a = this[__private__dont__use].FS;
1691
- for (const c of r)
1692
- c && c !== "/request" && copyMEMFSNodes(e, a, c);
1693
- for (const { mountHandler: c, vfsPath: l } of i)
1694
- this.mkdir(l), await this.mount(l, c);
1690
+ const c = this[__private__dont__use].FS;
1691
+ for (const a of r)
1692
+ a && a !== "/request" && copyMEMFSNodes(e, c, a);
1693
+ for (const { mountHandler: a, vfsPath: l } of i)
1694
+ this.mkdir(l), await this.mount(l, a);
1695
1695
  try {
1696
- a.chdir(n);
1697
- } catch (c) {
1696
+ c.chdir(n);
1697
+ } catch (a) {
1698
1698
  throw new Error(
1699
1699
  `Failed to restore CWD to ${n} after PHP runtime rotation.`,
1700
1700
  {
1701
- cause: c
1701
+ cause: a
1702
1702
  }
1703
1703
  );
1704
1704
  }
@@ -1741,12 +1741,12 @@ class PHP {
1741
1741
  async cli(t, e = {}) {
1742
1742
  if (basename(t[0] ?? "") !== "php")
1743
1743
  return this.subProcess(t, e);
1744
- u(this, H) && (u(this, _).needsRotating = !0);
1744
+ u(this, H) && (u(this, w).needsRotating = !0);
1745
1745
  const r = await this.semaphore.acquire();
1746
- return await m(this, h, q).call(this, () => {
1746
+ return await m(this, h, W).call(this, () => {
1747
1747
  const s = e.env || {};
1748
1748
  for (const [n, i] of Object.entries(s))
1749
- m(this, h, j).call(this, n, i);
1749
+ m(this, h, D).call(this, n, i);
1750
1750
  t = [t[0], "-c", PHP_INI_PATH, ...t.slice(1)];
1751
1751
  for (const n of t)
1752
1752
  this[__private__dont__use].ccall(
@@ -1759,7 +1759,7 @@ class PHP {
1759
1759
  async: !0
1760
1760
  });
1761
1761
  }).then((s) => (s.exitCode.finally(r), s)).finally(() => {
1762
- u(this, _).needsRotating = !0;
1762
+ u(this, w).needsRotating = !0;
1763
1763
  });
1764
1764
  }
1765
1765
  /**
@@ -1831,13 +1831,13 @@ class PHP {
1831
1831
  this[__private__dont__use]._exit(t);
1832
1832
  } catch {
1833
1833
  }
1834
- P(this, H, !1), P(this, T, null), this[__private__dont__use] && (delete this[__private__dont__use].onMessage, delete this[__private__dont__use]);
1834
+ _(this, H, !1), _(this, T, null), this[__private__dont__use] && (delete this[__private__dont__use].onMessage, delete this[__private__dont__use]);
1835
1835
  }
1836
1836
  [Symbol.dispose]() {
1837
1837
  this.exit(0);
1838
1838
  }
1839
1839
  }
1840
- M = new WeakMap(), H = new WeakMap(), T = new WeakMap(), v = new WeakMap(), F = new WeakMap(), k = new WeakMap(), _ = new WeakMap(), h = new WeakSet(), /**
1840
+ M = new WeakMap(), H = new WeakMap(), T = new WeakMap(), v = new WeakMap(), F = new WeakMap(), k = new WeakMap(), w = new WeakMap(), h = new WeakSet(), /**
1841
1841
  * Prepares the $_SERVER entries for the PHP runtime.
1842
1842
  *
1843
1843
  * @param defaults Default entries to include in $_SERVER.
@@ -1846,7 +1846,7 @@ M = new WeakMap(), H = new WeakMap(), T = new WeakMap(), v = new WeakMap(), F =
1846
1846
  * was provided.
1847
1847
  * @returns Computed $_SERVER entries.
1848
1848
  */
1849
- z = function(t, e, r) {
1849
+ V = function(t, e, r) {
1850
1850
  const s = {
1851
1851
  ...t || {}
1852
1852
  };
@@ -1856,7 +1856,7 @@ z = function(t, e, r) {
1856
1856
  ["content-type", "content-length"].includes(n.toLowerCase()) && (i = ""), s[`${i}${n.toUpperCase().replace(/-/g, "_")}`] = e[n];
1857
1857
  }
1858
1858
  return s;
1859
- }, $ = function(t) {
1859
+ }, G = function(t) {
1860
1860
  this[__private__dont__use].ccall(
1861
1861
  "wasm_set_request_uri",
1862
1862
  null,
@@ -1870,35 +1870,35 @@ z = function(t, e, r) {
1870
1870
  [STRING],
1871
1871
  [e]
1872
1872
  );
1873
- }, V = function(t) {
1873
+ }, J = function(t) {
1874
1874
  this[__private__dont__use].ccall(
1875
1875
  "wasm_set_request_host",
1876
1876
  null,
1877
1877
  [STRING],
1878
1878
  [t]
1879
1879
  );
1880
- }, G = function(t) {
1880
+ }, Y = function(t) {
1881
1881
  this[__private__dont__use].ccall(
1882
1882
  "wasm_set_request_port",
1883
1883
  null,
1884
1884
  [NUMBER],
1885
1885
  [t]
1886
1886
  );
1887
- }, J = function(t, e) {
1887
+ }, Q = function(t, e) {
1888
1888
  let r;
1889
1889
  try {
1890
1890
  r = parseInt(new URL(t).port, 10);
1891
1891
  } catch {
1892
1892
  }
1893
1893
  return (!r || isNaN(r) || r === 80) && (r = e === "https" ? 443 : 80), r;
1894
- }, Y = function(t) {
1894
+ }, X = function(t) {
1895
1895
  this[__private__dont__use].ccall(
1896
1896
  "wasm_set_request_method",
1897
1897
  null,
1898
1898
  [STRING],
1899
1899
  [t]
1900
1900
  );
1901
- }, Q = function(t) {
1901
+ }, K = function(t) {
1902
1902
  t.cookie && this[__private__dont__use].ccall(
1903
1903
  "wasm_set_cookies",
1904
1904
  null,
@@ -1915,7 +1915,7 @@ z = function(t, e, r) {
1915
1915
  [NUMBER],
1916
1916
  [parseInt(t["content-length"], 10)]
1917
1917
  );
1918
- }, X = function(t) {
1918
+ }, Z = function(t) {
1919
1919
  let e, r;
1920
1920
  typeof t == "string" ? (logger.warn(
1921
1921
  "Passing a string as the request body is deprecated. Please use a Uint8Array instead. See https://github.com/WordPress/wordpress-playground/issues/997 for more details"
@@ -1938,57 +1938,57 @@ z = function(t, e, r) {
1938
1938
  [NUMBER],
1939
1939
  [r]
1940
1940
  ), s;
1941
- }, U = function(t) {
1941
+ }, q = function(t) {
1942
1942
  this[__private__dont__use].ccall(
1943
1943
  "wasm_set_path_translated",
1944
1944
  null,
1945
1945
  [STRING],
1946
1946
  [t]
1947
1947
  );
1948
- }, K = function(t, e) {
1948
+ }, ee = function(t, e) {
1949
1949
  this[__private__dont__use].ccall(
1950
1950
  "wasm_add_SERVER_entry",
1951
1951
  null,
1952
1952
  [STRING, STRING],
1953
1953
  [t, e]
1954
1954
  );
1955
- }, j = function(t, e) {
1955
+ }, D = function(t, e) {
1956
1956
  this[__private__dont__use].ccall(
1957
1957
  "wasm_add_ENV_entry",
1958
1958
  null,
1959
1959
  [STRING, STRING],
1960
1960
  [t, e]
1961
1961
  );
1962
- }, q = async function(t) {
1963
- u(this, _).enabled && u(this, _).needsRotating && await this.rotateRuntime(), ++u(this, _).requestsMade, u(this, _).requestsMade >= u(this, _).maxRequests && (u(this, _).needsRotating = !0);
1962
+ }, W = async function(t) {
1963
+ u(this, w).enabled && u(this, w).needsRotating && await this.rotateRuntime(), ++u(this, w).requestsMade, u(this, w).requestsMade >= u(this, w).maxRequests && (u(this, w).needsRotating = !0);
1964
1964
  const e = this[__private__dont__use], r = await createInvertedReadableStream();
1965
- e.onHeaders = (d) => {
1966
- a || s || r.controller.enqueue(d.slice());
1965
+ e.onHeaders = (p) => {
1966
+ c || s || r.controller.enqueue(p.slice());
1967
1967
  };
1968
1968
  let s = !1;
1969
1969
  const n = () => {
1970
1970
  s || (s = !0, r.controller.close());
1971
1971
  }, i = await createInvertedReadableStream();
1972
- e.onStdout = (d) => {
1973
- n(), !a && i.controller.enqueue(d.slice());
1972
+ e.onStdout = (p) => {
1973
+ n(), !c && i.controller.enqueue(p.slice());
1974
1974
  };
1975
1975
  const o = await createInvertedReadableStream();
1976
- e.onStderr = (d) => {
1977
- a || o.controller.enqueue(d.slice());
1976
+ e.onStderr = (p) => {
1977
+ c || o.controller.enqueue(p.slice());
1978
1978
  };
1979
- let a = !1, c;
1980
- const p = (async () => {
1981
- var d;
1979
+ let c = !1, a;
1980
+ const d = (async () => {
1981
+ var p;
1982
1982
  try {
1983
1983
  return await Promise.race([
1984
1984
  t(),
1985
- new Promise((w, b) => {
1986
- var D;
1987
- c = (W) => {
1988
- isExitCode(W.error) || b(W.error);
1989
- }, (D = u(this, T)) == null || D.addEventListener(
1985
+ new Promise((g, b) => {
1986
+ var B;
1987
+ a = (z) => {
1988
+ isExitCode(z.error) || b(z.error);
1989
+ }, (B = u(this, T)) == null || B.addEventListener(
1990
1990
  "error",
1991
- c,
1991
+ a,
1992
1992
  { once: !0 }
1993
1993
  );
1994
1994
  })
@@ -1996,43 +1996,43 @@ z = function(t, e, r) {
1996
1996
  } catch (f) {
1997
1997
  if (isExitCode(f))
1998
1998
  return f.status;
1999
- i.controller.error(f), o.controller.error(f), r.controller.error(f), a = !0;
2000
- for (const w in this)
2001
- typeof this[w] == "function" && (this[w] = () => {
1999
+ i.controller.error(f), o.controller.error(f), r.controller.error(f), c = !0;
2000
+ for (const g in this)
2001
+ typeof this[g] == "function" && (this[g] = () => {
2002
2002
  throw new Error(
2003
2003
  "PHP runtime has crashed – see the earlier error for details."
2004
2004
  );
2005
2005
  });
2006
2006
  throw this.functionsMaybeMissingFromAsyncify = getFunctionsMaybeMissingFromAsyncify(), f;
2007
2007
  } finally {
2008
- a || (i.controller.close(), o.controller.close(), n(), a = !0), (d = u(this, T)) == null || d.removeEventListener(
2008
+ c || (i.controller.close(), o.controller.close(), n(), c = !0), (p = u(this, T)) == null || p.removeEventListener(
2009
2009
  "error",
2010
- c
2010
+ a
2011
2011
  );
2012
2012
  }
2013
2013
  })().then(
2014
- (d) => (d !== 0 && this.dispatchEvent({
2014
+ (p) => (p !== 0 && this.dispatchEvent({
2015
2015
  type: "request.error",
2016
2016
  error: new Error(
2017
- `PHP.run() failed with exit code ${d}.`
2017
+ `PHP.run() failed with exit code ${p}.`
2018
2018
  ),
2019
2019
  // Distinguish between PHP request and PHP-wasm errors
2020
2020
  source: "php-wasm"
2021
- }), d),
2022
- (d) => {
2023
- const f = d.source ?? "php-wasm";
2021
+ }), p),
2022
+ (p) => {
2023
+ const f = p.source ?? "php-wasm";
2024
2024
  throw this.dispatchEvent({
2025
2025
  type: "request.error",
2026
- error: d,
2026
+ error: p,
2027
2027
  source: f
2028
- }), d;
2028
+ }), p;
2029
2029
  }
2030
2030
  );
2031
2031
  return new StreamedPHPResponse(
2032
2032
  r.stream,
2033
2033
  i.stream,
2034
2034
  o.stream,
2035
- p
2035
+ d
2036
2036
  );
2037
2037
  };
2038
2038
  function normalizeHeaders(t) {
@@ -2201,9 +2201,9 @@ async function* iteratePhpFiles(t, e, {
2201
2201
  const o = i.pop();
2202
2202
  if (!o)
2203
2203
  return;
2204
- const a = await t.listFiles(o);
2205
- for (const c of a) {
2206
- const l = `${o}/${c}`;
2204
+ const c = await t.listFiles(o);
2205
+ for (const a of c) {
2206
+ const l = `${o}/${a}`;
2207
2207
  if (n.includes(l.substring(e.length + 1)))
2208
2208
  continue;
2209
2209
  await t.isDir(l) ? i.push(l) : yield new StreamedFile(
@@ -2264,119 +2264,71 @@ class MaxPhpInstancesError extends Error {
2264
2264
  }
2265
2265
  class PHPProcessManager {
2266
2266
  constructor(e) {
2267
- this.primaryIdle = !0, this.nextInstance = null, this.allInstances = [], this.maxPhpInstances = (e == null ? void 0 : e.maxPhpInstances) ?? 5, this.phpFactory = e == null ? void 0 : e.phpFactory, this.primaryPhp = e == null ? void 0 : e.primaryPhp, this.semaphore = new Semaphore({
2267
+ this.instances = [], this.idleInstances = [], this.maxPhpInstances = (e == null ? void 0 : e.maxPhpInstances) ?? 2, this.phpFactory = e == null ? void 0 : e.phpFactory, this.semaphore = new Semaphore({
2268
2268
  concurrency: this.maxPhpInstances,
2269
- /**
2270
- * Wait up to 5 seconds for resources to become available
2271
- * before assuming that all the PHP instances are deadlocked.
2272
- */
2273
- timeout: (e == null ? void 0 : e.timeout) || 5e3
2269
+ timeout: (e == null ? void 0 : e.timeout) || 3e4
2274
2270
  });
2275
2271
  }
2276
2272
  /**
2277
- * Get the primary PHP instance.
2278
- *
2279
- * If the primary PHP instance is not set, it will be spawned
2280
- * using the provided phpFactory.
2281
- *
2282
- * @throws {Error} when called twice before the first call is resolved.
2273
+ * Get the primary PHP instance (the first one spawned).
2274
+ * If no instance exists yet, one will be spawned and marked as idle.
2283
2275
  */
2284
2276
  async getPrimaryPhp() {
2285
- if (!this.phpFactory && !this.primaryPhp)
2286
- throw new Error(
2287
- "phpFactory or primaryPhp must be set before calling getPrimaryPhp()."
2288
- );
2289
- return this.primaryPhp || (this.primaryPhpPromise || (this.primaryPhpPromise = this.spawn({ isPrimary: !0 })), this.primaryPhp = (await this.primaryPhpPromise).php, this.primaryPhpPromise = void 0), this.primaryPhp;
2290
- }
2291
- /**
2292
- * Get a PHP instance.
2293
- *
2294
- * It could be either the primary PHP instance, an idle disposable PHP
2295
- * instance, or a newly spawned PHP instance – depending on the resource
2296
- * availability.
2297
- *
2298
- * @param considerPrimary - Whether to consider the primary PHP instance.
2299
- * It matters because PHP.cli() sets the SAPI to CLI and
2300
- * kills the entire process after it finishes running,
2301
- * making the primary PHP instance non-reusable for
2302
- * subsequent .run() calls. This is fine for one-off
2303
- * child PHP instances, but not for the primary PHP
2304
- * that's meant to continue working for the entire duration
2305
- * of the ProcessManager lifetime. Therefore, we don't
2306
- * consider the primary PHP instance by default unless
2307
- * the caller explicitly requests it.
2308
- *
2309
- * @throws {MaxPhpInstancesError} when the maximum number of PHP instances is reached
2310
- * and the waiting timeout is exceeded.
2311
- */
2312
- async acquirePHPInstance({
2313
- considerPrimary: e = !1
2314
- } = {}) {
2315
- if (this.primaryPhp || await this.getPrimaryPhp(), this.primaryIdle && e)
2316
- return this.primaryIdle = !1, {
2317
- php: await this.getPrimaryPhp(),
2318
- reap: () => {
2319
- this.primaryIdle = !0;
2320
- }
2321
- };
2322
- const r = this.nextInstance || this.spawn({ isPrimary: !1 });
2323
- return this.semaphore.remaining > 0 ? this.nextInstance = this.spawn({ isPrimary: !1 }) : this.nextInstance = null, await r;
2277
+ if (this.instances.length > 0)
2278
+ return this.instances[0];
2279
+ this.primaryPhpPromise || (this.primaryPhpPromise = this.spawnInstance(!0));
2280
+ try {
2281
+ return await this.primaryPhpPromise;
2282
+ } finally {
2283
+ this.primaryPhpPromise = void 0;
2284
+ }
2324
2285
  }
2325
2286
  /**
2326
- * Initiated spawning of a new PHP instance.
2327
- * This function is synchronous on purpose – it needs to synchronously
2328
- * add the spawn promise to the allInstances array without waiting
2329
- * for PHP to spawn.
2287
+ * Acquire a PHP instance for processing a request.
2288
+ *
2289
+ * Returns an idle instance from the pool, or spawns a new one if
2290
+ * the pool isn't at capacity. If all instances are busy, waits
2291
+ * until one becomes available.
2292
+ *
2293
+ * @throws {MaxPhpInstancesError} when the timeout is reached waiting
2294
+ * for an available instance.
2330
2295
  */
2331
- spawn(e) {
2332
- if (e.isPrimary && this.allInstances.length > 0)
2333
- throw new Error(
2334
- "Requested spawning a primary PHP instance when another primary instance already started spawning."
2335
- );
2336
- const r = this.doSpawn(e);
2337
- this.allInstances.push(r);
2338
- const s = () => {
2339
- this.allInstances = this.allInstances.filter(
2340
- (n) => n !== r
2341
- );
2342
- };
2343
- return r.catch((n) => {
2344
- throw s(), n;
2345
- }).then((n) => ({
2346
- ...n,
2296
+ async acquirePHPInstance() {
2297
+ let e;
2298
+ try {
2299
+ e = await this.semaphore.acquire();
2300
+ } catch (s) {
2301
+ throw s instanceof AcquireTimeoutError ? new MaxPhpInstancesError(this.maxPhpInstances) : s;
2302
+ }
2303
+ const r = await this.getOrSpawnInstance();
2304
+ return {
2305
+ php: r,
2347
2306
  reap: () => {
2348
- s(), n.reap();
2307
+ this.idleInstances.push(r), e();
2349
2308
  }
2350
- }));
2309
+ };
2351
2310
  }
2352
2311
  /**
2353
- * Actually acquires the lock and spawns a new PHP instance.
2312
+ * Get an idle instance or spawn a new one.
2354
2313
  */
2355
- async doSpawn(e) {
2356
- let r;
2357
- try {
2358
- r = await this.semaphore.acquire();
2359
- } catch (s) {
2360
- throw s instanceof AcquireTimeoutError ? new MaxPhpInstancesError(this.maxPhpInstances) : s;
2361
- }
2362
- try {
2363
- const s = await this.phpFactory(e);
2364
- return {
2365
- php: s,
2366
- reap() {
2367
- s.exit(), r();
2368
- }
2369
- };
2370
- } catch (s) {
2371
- throw r(), s;
2372
- }
2314
+ async getOrSpawnInstance() {
2315
+ return this.instances.length === 0 && await this.getPrimaryPhp(), this.idleInstances.length === 0 && await this.spawnInstance(!1), this.idleInstances.pop();
2316
+ }
2317
+ /**
2318
+ * Spawn a new PHP instance.
2319
+ */
2320
+ async spawnInstance(e) {
2321
+ if (!this.phpFactory)
2322
+ throw new Error(
2323
+ "phpFactory must be set before spawning instances."
2324
+ );
2325
+ const r = await this.phpFactory({ isPrimary: e });
2326
+ return this.instances.push(r), this.idleInstances.push(r), r;
2373
2327
  }
2374
2328
  async [Symbol.asyncDispose]() {
2375
- this.primaryPhp && this.primaryPhp.exit(), await Promise.all(
2376
- this.allInstances.map(
2377
- (e) => e.then(({ reap: r }) => r())
2378
- )
2379
- );
2329
+ for (const e of this.instances)
2330
+ e.exit();
2331
+ this.instances = [], this.idleInstances = [];
2380
2332
  }
2381
2333
  }
2382
2334
  const SupportedPHPVersions = [
@@ -2399,22 +2351,22 @@ function ensurePathPrefix(t, e) {
2399
2351
  }
2400
2352
  async function encodeAsMultipart(t) {
2401
2353
  const e = `----${Math.random().toString(36).slice(2)}`, r = `multipart/form-data; boundary=${e}`, s = new TextEncoder(), n = [];
2402
- for (const [c, l] of Object.entries(t))
2354
+ for (const [a, l] of Object.entries(t))
2403
2355
  n.push(`--${e}\r
2404
- `), n.push(`Content-Disposition: form-data; name="${c}"`), l instanceof File && n.push(`; filename="${l.name}"`), n.push(`\r
2356
+ `), n.push(`Content-Disposition: form-data; name="${a}"`), l instanceof File && n.push(`; filename="${l.name}"`), n.push(`\r
2405
2357
  `), l instanceof File && (n.push("Content-Type: application/octet-stream"), n.push(`\r
2406
2358
  `)), n.push(`\r
2407
2359
  `), l instanceof File ? n.push(await fileToUint8Array(l)) : n.push(l), n.push(`\r
2408
2360
  `);
2409
2361
  n.push(`--${e}--\r
2410
2362
  `);
2411
- const i = n.reduce((c, l) => c + l.length, 0), o = new Uint8Array(i);
2412
- let a = 0;
2413
- for (const c of n)
2363
+ const i = n.reduce((a, l) => a + l.length, 0), o = new Uint8Array(i);
2364
+ let c = 0;
2365
+ for (const a of n)
2414
2366
  o.set(
2415
- typeof c == "string" ? s.encode(c) : c,
2416
- a
2417
- ), a += c.length;
2367
+ typeof a == "string" ? s.encode(a) : a,
2368
+ c
2369
+ ), c += a.length;
2418
2370
  return { bytes: o, contentType: r };
2419
2371
  }
2420
2372
  function fileToUint8Array(t) {
@@ -2516,7 +2468,7 @@ const _default = "application/octet-stream", asx = "video/x-ms-asf", atom = "app
2516
2468
  xspf,
2517
2469
  zip
2518
2470
  };
2519
- var g, I, L, C, A, E, N, R, S, Z, ee, te, re;
2471
+ var S, I, O, C, A, E, N, R, L, P, te, U, re, se, ne;
2520
2472
  class PHPRequestHandler {
2521
2473
  /**
2522
2474
  * The request handler needs to decide whether to serve a static asset or
@@ -2530,35 +2482,37 @@ class PHPRequestHandler {
2530
2482
  * @param config - Request Handler configuration.
2531
2483
  */
2532
2484
  constructor(e) {
2485
+ y(this, P);
2533
2486
  y(this, S);
2534
- y(this, g);
2535
2487
  y(this, I);
2536
- y(this, L);
2488
+ y(this, O);
2537
2489
  y(this, C);
2538
2490
  y(this, A);
2539
2491
  y(this, E);
2540
2492
  y(this, N);
2541
2493
  y(this, R);
2494
+ y(this, L);
2542
2495
  const {
2543
2496
  documentRoot: r = "/www/",
2544
2497
  absoluteUrl: s = typeof location == "object" ? location.href : DEFAULT_BASE_URL,
2545
2498
  rewriteRules: n = [],
2546
- getFileNotFoundAction: i = () => ({ type: "404" })
2547
- } = e, o = (l) => {
2548
- l.isDir(r) || l.mkdir(r), l.chdir(r), l.requestHandler = this;
2499
+ pathAliases: i = [],
2500
+ getFileNotFoundAction: o = () => ({ type: "404" })
2501
+ } = e, c = (d) => {
2502
+ d.isDir(r) || d.mkdir(r), d.chdir(r), d.requestHandler = this;
2549
2503
  };
2550
2504
  if (e.php)
2551
- o(e.php), this.instanceManager = new SinglePHPInstanceManager({
2505
+ c(e.php), this.instanceManager = new SinglePHPInstanceManager({
2552
2506
  php: e.php
2553
2507
  });
2554
2508
  else if (e.phpFactory)
2555
2509
  this.instanceManager = new PHPProcessManager({
2556
- phpFactory: async (l) => {
2510
+ phpFactory: async (d) => {
2557
2511
  const p = await e.phpFactory({
2558
- ...l,
2512
+ ...d,
2559
2513
  requestHandler: this
2560
2514
  });
2561
- return o(p), p;
2515
+ return c(p), p;
2562
2516
  },
2563
2517
  maxPhpInstances: e.maxPhpInstances
2564
2518
  });
@@ -2566,18 +2520,18 @@ class PHPRequestHandler {
2566
2520
  throw new Error(
2567
2521
  "Either php or phpFactory must be provided in the configuration."
2568
2522
  );
2569
- P(this, R, e.cookieStore === void 0 ? new HttpCookieStore() : e.cookieStore), P(this, g, r);
2523
+ _(this, R, e.cookieStore === void 0 ? new HttpCookieStore() : e.cookieStore), _(this, S, r);
2570
2524
  const a = new URL(s);
2571
- P(this, L, a.hostname), P(this, C, a.port ? Number(a.port) : a.protocol === "https:" ? 443 : 80), P(this, I, (a.protocol || "").replace(":", ""));
2572
- const c = u(this, C) !== 443 && u(this, C) !== 80;
2573
- P(this, A, [
2574
- u(this, L),
2575
- c ? `:${u(this, C)}` : ""
2576
- ].join("")), P(this, E, a.pathname.replace(/\/+$/, "")), P(this, N, [
2525
+ _(this, O, a.hostname), _(this, C, a.port ? Number(a.port) : a.protocol === "https:" ? 443 : 80), _(this, I, (a.protocol || "").replace(":", ""));
2526
+ const l = u(this, C) !== 443 && u(this, C) !== 80;
2527
+ _(this, A, [
2528
+ u(this, O),
2529
+ l ? `:${u(this, C)}` : ""
2530
+ ].join("")), _(this, E, a.pathname.replace(/\/+$/, "")), _(this, N, [
2577
2531
  `${u(this, I)}://`,
2578
2532
  u(this, A),
2579
2533
  u(this, E)
2580
- ].join("")), this.rewriteRules = n, this.getFileNotFoundAction = i;
2534
+ ].join("")), this.rewriteRules = n, _(this, L, i), this.getFileNotFoundAction = o;
2581
2535
  }
2582
2536
  async getPrimaryPhp() {
2583
2537
  return await this.instanceManager.getPrimaryPhp();
@@ -2614,7 +2568,7 @@ class PHPRequestHandler {
2614
2568
  * for the files to serve. Default: `/var/www`.
2615
2569
  */
2616
2570
  get documentRoot() {
2617
- return u(this, g);
2571
+ return u(this, S);
2618
2572
  }
2619
2573
  /**
2620
2574
  * Serves the request – either by serving a static file, or by
@@ -2669,23 +2623,16 @@ class PHPRequestHandler {
2669
2623
  // Remove the hash part of the URL as it's not meant for the server.
2670
2624
  e.url.split("#")[0],
2671
2625
  r ? void 0 : DEFAULT_BASE_URL
2672
- ), n = m(this, S, Z).call(this, s), i = await this.getPrimaryPhp();
2673
- let o = joinPaths(
2674
- u(this, g),
2626
+ ), n = m(this, P, te).call(this, s), i = await this.getPrimaryPhp(), o = removePathPrefix(
2675
2627
  /**
2676
- * Turn a URL such as `https://playground/scope:my-site/wp-admin/index.php`
2677
- * into a site-relative path, such as `/wp-admin/index.php`.
2628
+ * URL.pathname returns a URL-encoded path. We need to decode it
2629
+ * before using it as a filesystem path.
2678
2630
  */
2679
- removePathPrefix(
2680
- /**
2681
- * URL.pathname returns a URL-encoded path. We need to decode it
2682
- * before using it as a filesystem path.
2683
- */
2684
- decodeURIComponent(n.pathname),
2685
- u(this, E)
2686
- )
2631
+ decodeURIComponent(n.pathname),
2632
+ u(this, E)
2687
2633
  );
2688
- if (i.isDir(o)) {
2634
+ let c = m(this, P, U).call(this, o);
2635
+ if (i.isDir(c)) {
2689
2636
  if (!o.endsWith("/"))
2690
2637
  return new PHPResponse(
2691
2638
  301,
@@ -2693,9 +2640,9 @@ class PHPRequestHandler {
2693
2640
  new Uint8Array(0)
2694
2641
  );
2695
2642
  for (const a of ["index.php", "index.html"]) {
2696
- const c = joinPaths(o, a);
2697
- if (i.isFile(c)) {
2698
- o = c, n.pathname = joinPaths(
2643
+ const l = joinPaths(c, a);
2644
+ if (i.isFile(l)) {
2645
+ c = l, n.pathname = joinPaths(
2699
2646
  n.pathname,
2700
2647
  a
2701
2648
  );
@@ -2703,19 +2650,19 @@ class PHPRequestHandler {
2703
2650
  }
2704
2651
  }
2705
2652
  }
2706
- if (!i.isFile(o)) {
2707
- let a = n.pathname;
2653
+ if (!i.isFile(c)) {
2654
+ let a = o;
2708
2655
  for (; a.startsWith("/") && a !== dirname(a); ) {
2709
2656
  a = dirname(a);
2710
- const c = joinPaths(u(this, g), a);
2711
- if (i.isFile(c) && // Only run partial path resolution for PHP files.
2712
- c.endsWith(".php")) {
2713
- o = joinPaths(u(this, g), a);
2657
+ const l = m(this, P, U).call(this, a);
2658
+ if (i.isFile(l) && // Only run partial path resolution for PHP files.
2659
+ l.endsWith(".php")) {
2660
+ c = m(this, P, U).call(this, a);
2714
2661
  break;
2715
2662
  }
2716
2663
  }
2717
2664
  }
2718
- if (!i.isFile(o)) {
2665
+ if (!i.isFile(c)) {
2719
2666
  const a = this.getFileNotFoundAction(
2720
2667
  n.pathname
2721
2668
  );
@@ -2723,7 +2670,7 @@ class PHPRequestHandler {
2723
2670
  case "response":
2724
2671
  return a.response;
2725
2672
  case "internal-redirect":
2726
- o = joinPaths(u(this, g), a.uri);
2673
+ c = joinPaths(u(this, S), a.uri);
2727
2674
  break;
2728
2675
  case "404":
2729
2676
  return PHPResponse.forHttpCode(404);
@@ -2733,9 +2680,9 @@ class PHPRequestHandler {
2733
2680
  );
2734
2681
  }
2735
2682
  }
2736
- if (i.isFile(o))
2737
- if (o.endsWith(".php")) {
2738
- const a = await m(this, S, te).call(this, e, s, n, o);
2683
+ if (i.isFile(c))
2684
+ if (c.endsWith(".php")) {
2685
+ const a = await m(this, P, se).call(this, e, s, n, c);
2739
2686
  return a.ok() && a.exitCode !== 0 ? new PHPResponse(
2740
2687
  500,
2741
2688
  a.headers,
@@ -2744,7 +2691,7 @@ class PHPRequestHandler {
2744
2691
  a.exitCode
2745
2692
  ) : a;
2746
2693
  } else
2747
- return m(this, S, ee).call(this, i, o);
2694
+ return m(this, P, re).call(this, i, c);
2748
2695
  else
2749
2696
  return PHPResponse.forHttpCode(404);
2750
2697
  }
@@ -2839,11 +2786,11 @@ class PHPRequestHandler {
2839
2786
  prepare_$_SERVER_superglobal(e, r, s) {
2840
2787
  const n = {
2841
2788
  REMOTE_ADDR: "127.0.0.1",
2842
- DOCUMENT_ROOT: u(this, g),
2789
+ DOCUMENT_ROOT: u(this, S),
2843
2790
  HTTPS: u(this, N).startsWith("https://") ? "on" : ""
2844
2791
  };
2845
- return n.REQUEST_URI = e.pathname + e.search, s.startsWith(u(this, g)) && (n.SCRIPT_NAME = s.substring(
2846
- u(this, g).length
2792
+ return n.REQUEST_URI = e.pathname + e.search, s.startsWith(u(this, S)) && (n.SCRIPT_NAME = s.substring(
2793
+ u(this, S).length
2847
2794
  ), n.PHP_SELF = r.pathname, n.REQUEST_URI.startsWith(n.SCRIPT_NAME) && (n.PATH_INFO = n.REQUEST_URI.substring(
2848
2795
  n.SCRIPT_NAME.length
2849
2796
  ), n.PATH_INFO.includes("?") && (n.PATH_INFO = n.PATH_INFO.substring(
@@ -2855,13 +2802,13 @@ class PHPRequestHandler {
2855
2802
  await this.instanceManager[Symbol.asyncDispose]();
2856
2803
  }
2857
2804
  }
2858
- g = new WeakMap(), I = new WeakMap(), L = new WeakMap(), C = new WeakMap(), A = new WeakMap(), E = new WeakMap(), N = new WeakMap(), R = new WeakMap(), S = new WeakSet(), /**
2805
+ S = new WeakMap(), I = new WeakMap(), O = new WeakMap(), C = new WeakMap(), A = new WeakMap(), E = new WeakMap(), N = new WeakMap(), R = new WeakMap(), L = new WeakMap(), P = new WeakSet(), /**
2859
2806
  * Apply the rewrite rules to the original request URL.
2860
2807
  *
2861
2808
  * @param originalRequestUrl - The original request URL.
2862
2809
  * @returns The rewritten request URL.
2863
2810
  */
2864
- Z = function(e) {
2811
+ te = function(e) {
2865
2812
  const r = removePathPrefix(
2866
2813
  decodeURIComponent(e.pathname),
2867
2814
  u(this, E)
@@ -2875,13 +2822,29 @@ Z = function(e) {
2875
2822
  for (const [i, o] of e.searchParams.entries())
2876
2823
  n.searchParams.append(i, o);
2877
2824
  return n;
2825
+ }, /**
2826
+ * Resolves a URL path to a filesystem path, checking path aliases first.
2827
+ *
2828
+ * If the URL path matches a configured alias prefix, the alias's
2829
+ * filesystem path is used instead of the document root.
2830
+ *
2831
+ * @param urlPath - The URL path to resolve (e.g., '/phpmyadmin/index.php')
2832
+ * @returns The resolved filesystem path
2833
+ */
2834
+ U = function(e) {
2835
+ for (const r of u(this, L))
2836
+ if (e === r.urlPrefix || e.startsWith(r.urlPrefix + "/")) {
2837
+ const s = e.slice(r.urlPrefix.length);
2838
+ return joinPaths(r.fsPath, s);
2839
+ }
2840
+ return joinPaths(u(this, S), e);
2878
2841
  }, /**
2879
2842
  * Serves a static file from the PHP filesystem.
2880
2843
  *
2881
2844
  * @param fsPath - Absolute path of the static file to serve.
2882
2845
  * @returns The response.
2883
2846
  */
2884
- ee = function(e, r) {
2847
+ re = function(e, r) {
2885
2848
  const s = e.readFileAsBuffer(r);
2886
2849
  return new PHPResponse(
2887
2850
  200,
@@ -2896,32 +2859,30 @@ ee = function(e, r) {
2896
2859
  },
2897
2860
  s
2898
2861
  );
2899
- }, te = async function(e, r, s, n) {
2862
+ }, se = async function(e, r, s, n) {
2900
2863
  let i;
2901
2864
  try {
2902
- i = await this.instanceManager.acquirePHPInstance({
2903
- considerPrimary: !0
2904
- });
2865
+ i = await this.instanceManager.acquirePHPInstance();
2905
2866
  } catch (o) {
2906
2867
  return o instanceof MaxPhpInstancesError ? PHPResponse.forHttpCode(502) : PHPResponse.forHttpCode(500);
2907
2868
  }
2908
2869
  try {
2909
- return await m(this, S, re).call(this, i.php, e, r, s, n);
2870
+ return await m(this, P, ne).call(this, i.php, e, r, s, n);
2910
2871
  } finally {
2911
2872
  i.reap();
2912
2873
  }
2913
- }, re = async function(e, r, s, n, i) {
2874
+ }, ne = async function(e, r, s, n, i) {
2914
2875
  let o = "GET";
2915
- const a = {
2876
+ const c = {
2916
2877
  host: u(this, A),
2917
2878
  ...normalizeHeaders(r.headers || {})
2918
2879
  };
2919
- u(this, R) && (a.cookie = u(this, R).getCookieRequestHeader());
2920
- let c = r.body;
2921
- if (typeof c == "object" && !(c instanceof Uint8Array)) {
2880
+ u(this, R) && (c.cookie = u(this, R).getCookieRequestHeader());
2881
+ let a = r.body;
2882
+ if (typeof a == "object" && !(a instanceof Uint8Array)) {
2922
2883
  o = "POST";
2923
- const { bytes: l, contentType: p } = await encodeAsMultipart(c);
2924
- c = l, a["content-type"] = p;
2884
+ const { bytes: l, contentType: d } = await encodeAsMultipart(a);
2885
+ a = l, c["content-type"] = d;
2925
2886
  }
2926
2887
  try {
2927
2888
  const l = await e.run({
@@ -2936,17 +2897,17 @@ ee = function(e, r) {
2936
2897
  n,
2937
2898
  i
2938
2899
  ),
2939
- body: c,
2900
+ body: a,
2940
2901
  scriptPath: i,
2941
- headers: a
2902
+ headers: c
2942
2903
  });
2943
2904
  return u(this, R) && u(this, R).rememberCookiesFromResponseHeaders(
2944
2905
  l.headers
2945
2906
  ), l;
2946
2907
  } catch (l) {
2947
- const p = l;
2948
- if (p != null && p.response)
2949
- return p.response;
2908
+ const d = l;
2909
+ if (d != null && d.response)
2910
+ return d.response;
2950
2911
  throw l;
2951
2912
  }
2952
2913
  };
@@ -2988,37 +2949,37 @@ async function writeFiles(t, e, r, { rmRoot: s = !1 } = {}) {
2988
2949
  }
2989
2950
  function ensureProxyFSHasMmapSupport(t) {
2990
2951
  const e = Object.getOwnPropertySymbols(t)[0], r = t[e], s = r.PROXYFS, n = r.FS;
2991
- s.stream_ops.mmap || (s.stream_ops.mmap = function(i, o, a, c, l) {
2952
+ s.stream_ops.mmap || (s.stream_ops.mmap = function(i, o, c, a, l) {
2992
2953
  if (!n.isFile(i.node.mode))
2993
2954
  throw new n.ErrnoError(19);
2994
- if (a !== 0)
2955
+ if (c !== 0)
2995
2956
  throw new n.ErrnoError(22);
2996
- const p = r.malloc(o);
2997
- if (!p)
2957
+ const d = r.malloc(o);
2958
+ if (!d)
2998
2959
  throw new n.ErrnoError(48);
2999
- const d = r.HEAPU8.subarray(p, p + o);
2960
+ const p = r.HEAPU8.subarray(d, d + o);
3000
2961
  let f = 0;
3001
2962
  for (; f < o; ) {
3002
- const w = i.stream_ops.read(
2963
+ const g = i.stream_ops.read(
3003
2964
  i,
3004
- d,
2965
+ p,
3005
2966
  f,
3006
2967
  o - f,
3007
2968
  f
3008
2969
  );
3009
- if (w <= 0) break;
3010
- f += w;
2970
+ if (g <= 0) break;
2971
+ f += g;
3011
2972
  }
3012
2973
  if (f !== o)
3013
- throw r.free(p), new n.ErrnoError(5);
3014
- return { ptr: p, allocated: !0 };
3015
- }, s.stream_ops.msync = function(i, o, a, c, l) {
2974
+ throw r.free(d), new n.ErrnoError(5);
2975
+ return { ptr: d, allocated: !0 };
2976
+ }, s.stream_ops.msync = function(i, o, c, a, l) {
3016
2977
  return l & 2 || i.stream_ops.write(
3017
2978
  i,
3018
2979
  o,
3019
- a,
3020
2980
  c,
3021
2981
  a,
2982
+ c,
3022
2983
  !1
3023
2984
  ), 0;
3024
2985
  });
@@ -3052,11 +3013,11 @@ function sandboxedSpawnHandlerFactory(t) {
3052
3013
  else if (n === "tput" && e[1] === "cols")
3053
3014
  r.stdout("140"), r.exit(0);
3054
3015
  else if (n === "less") {
3055
- r.on("stdin", (a) => {
3056
- r.stdout(a);
3057
- }), await new Promise((a) => {
3016
+ r.on("stdin", (c) => {
3017
+ r.stdout(c);
3018
+ }), await new Promise((c) => {
3058
3019
  r.childProcess.stdin.on("finish", () => {
3059
- a(!0);
3020
+ c(!0);
3060
3021
  });
3061
3022
  }), r.exit(0);
3062
3023
  return;
@@ -3074,10 +3035,10 @@ function sandboxedSpawnHandlerFactory(t) {
3074
3035
  const { php: i, reap: o } = await t();
3075
3036
  try {
3076
3037
  s.cwd && await i.chdir(s.cwd);
3077
- const a = await i.cwd();
3038
+ const c = await i.cwd();
3078
3039
  switch (n) {
3079
3040
  case "php": {
3080
- const c = await i.cli(e, {
3041
+ const a = await i.cli(e, {
3081
3042
  env: {
3082
3043
  ...s.env,
3083
3044
  SCRIPT_PATH: e[1],
@@ -3087,37 +3048,37 @@ function sandboxedSpawnHandlerFactory(t) {
3087
3048
  SHELL_PIPE: "0"
3088
3049
  }
3089
3050
  });
3090
- c.stdout.pipeTo(
3051
+ a.stdout.pipeTo(
3091
3052
  new WritableStream({
3092
3053
  write(l) {
3093
3054
  r.stdout(l);
3094
3055
  }
3095
3056
  })
3096
- ), c.stderr.pipeTo(
3057
+ ), a.stderr.pipeTo(
3097
3058
  new WritableStream({
3098
3059
  write(l) {
3099
3060
  r.stderr(l);
3100
3061
  }
3101
3062
  })
3102
- ), r.exit(await c.exitCode);
3063
+ ), r.exit(await a.exitCode);
3103
3064
  break;
3104
3065
  }
3105
3066
  case "ls": {
3106
- const c = await i.listFiles(e[1] ?? a);
3107
- for (const l of c)
3067
+ const a = await i.listFiles(e[1] ?? c);
3068
+ for (const l of a)
3108
3069
  r.stdout(l + `
3109
3070
  `);
3110
3071
  await new Promise((l) => setTimeout(l, 10)), r.exit(0);
3111
3072
  break;
3112
3073
  }
3113
3074
  case "pwd": {
3114
- r.stdout(a + `
3115
- `), await new Promise((c) => setTimeout(c, 10)), r.exit(0);
3075
+ r.stdout(c + `
3076
+ `), await new Promise((a) => setTimeout(a, 10)), r.exit(0);
3116
3077
  break;
3117
3078
  }
3118
3079
  }
3119
- } catch (a) {
3120
- throw r.exit(1), a;
3080
+ } catch (c) {
3081
+ throw r.exit(1), c;
3121
3082
  } finally {
3122
3083
  o();
3123
3084
  }
@@ -3135,7 +3096,7 @@ function createSyncProxy(t, e = [], r) {
3135
3096
  } : createSyncProxy(t, [...e, n], r);
3136
3097
  },
3137
3098
  set(s, n, i) {
3138
- const [o, a] = toWireValue(i);
3099
+ const [o, c] = toWireValue(i);
3139
3100
  return r.send(
3140
3101
  t,
3141
3102
  {
@@ -3143,25 +3104,25 @@ function createSyncProxy(t, e = [], r) {
3143
3104
  path: [...e, n].map(String),
3144
3105
  value: o
3145
3106
  },
3146
- a
3107
+ c
3147
3108
  ), !0;
3148
3109
  },
3149
3110
  apply(s, n, i) {
3150
3111
  if (e.at(-1) === "bind")
3151
3112
  return createSyncProxy(t, e.slice(0, -1), r);
3152
- const [a, c] = processArguments(i), l = r.send(
3113
+ const [c, a] = processArguments(i), l = r.send(
3153
3114
  t,
3154
3115
  {
3155
3116
  type: MessageType.APPLY,
3156
3117
  path: e.map(String),
3157
- argumentList: a
3118
+ argumentList: c
3158
3119
  },
3159
- c
3120
+ a
3160
3121
  );
3161
3122
  return fromWireValue(l);
3162
3123
  },
3163
3124
  construct(s, n) {
3164
- const [i, o] = processArguments(n), a = r.send(
3125
+ const [i, o] = processArguments(n), c = r.send(
3165
3126
  t,
3166
3127
  {
3167
3128
  type: MessageType.CONSTRUCT,
@@ -3170,7 +3131,7 @@ function createSyncProxy(t, e = [], r) {
3170
3131
  },
3171
3132
  o
3172
3133
  );
3173
- return fromWireValue(a);
3134
+ return fromWireValue(c);
3174
3135
  }
3175
3136
  });
3176
3137
  }
@@ -3209,10 +3170,10 @@ class NodeSABSyncReceiveMessageTransport {
3209
3170
  ), Atomics.wait(i, 0, 0, 5e3) === "timed-out")
3210
3171
  throw new Error("Timeout waiting for response");
3211
3172
  for (; ; ) {
3212
- const p = NodeSABSyncReceiveMessageTransport.receiveMessageOnPort(e);
3213
- if (((l = p.message) == null ? void 0 : l.id) === o)
3214
- return p.message;
3215
- if (!p)
3173
+ const d = NodeSABSyncReceiveMessageTransport.receiveMessageOnPort(e);
3174
+ if (((l = d.message) == null ? void 0 : l.id) === o)
3175
+ return d.message;
3176
+ if (!d)
3216
3177
  throw new Error("No response received");
3217
3178
  }
3218
3179
  }
@@ -3286,55 +3247,55 @@ function expose(t, e = globalThis, r = ["*"], s) {
3286
3247
  console.warn(`Invalid origin '${i.origin}' for comlink proxy`);
3287
3248
  return;
3288
3249
  }
3289
- const { id: o, type: a, path: c } = {
3250
+ const { id: o, type: c, path: a } = {
3290
3251
  path: [],
3291
3252
  ...i.data
3292
3253
  }, l = (i.data.argumentList || []).map(fromWireValue);
3293
- let p;
3254
+ let d;
3294
3255
  try {
3295
- const d = c.slice(0, -1).reduce((w, b) => w[b], t), f = c.reduce((w, b) => w[b], t);
3296
- switch (a) {
3256
+ const p = a.slice(0, -1).reduce((g, b) => g[b], t), f = a.reduce((g, b) => g[b], t);
3257
+ switch (c) {
3297
3258
  case MessageType.GET:
3298
- p = f;
3259
+ d = f;
3299
3260
  break;
3300
3261
  case MessageType.SET:
3301
- d[c.slice(-1)[0]] = fromWireValue(
3262
+ p[a.slice(-1)[0]] = fromWireValue(
3302
3263
  i.data.value
3303
- ), p = !0;
3264
+ ), d = !0;
3304
3265
  break;
3305
3266
  case MessageType.APPLY:
3306
- p = f.apply(d, l);
3267
+ d = f.apply(p, l);
3307
3268
  break;
3308
3269
  case MessageType.CONSTRUCT:
3309
3270
  {
3310
- const w = new f(...l);
3311
- p = proxy(w);
3271
+ const g = new f(...l);
3272
+ d = proxy(g);
3312
3273
  }
3313
3274
  break;
3314
3275
  case MessageType.ENDPOINT:
3315
3276
  {
3316
- const { port1: w, port2: b } = new MessageChannel();
3317
- expose(t, b), p = transfer(w, [w]);
3277
+ const { port1: g, port2: b } = new MessageChannel();
3278
+ expose(t, b), d = transfer(g, [g]);
3318
3279
  }
3319
3280
  break;
3320
3281
  case MessageType.RELEASE:
3321
- p = void 0;
3282
+ d = void 0;
3322
3283
  break;
3323
3284
  default:
3324
3285
  return;
3325
3286
  }
3326
- } catch (d) {
3327
- p = { value: d, [throwMarker]: 0 };
3287
+ } catch (p) {
3288
+ d = { value: p, [throwMarker]: 0 };
3328
3289
  }
3329
- Promise.resolve(p).catch((d) => ({ value: d, [throwMarker]: 0 })).then((d) => {
3330
- const [f, w] = toWireValue(d);
3331
- e.postMessage({ ...f, id: o }, w), a === MessageType.RELEASE && (e.removeEventListener("message", n), closeEndPoint(e), finalizer in t && typeof t[finalizer] == "function" && t[finalizer]());
3290
+ Promise.resolve(d).catch((p) => ({ value: p, [throwMarker]: 0 })).then((p) => {
3291
+ const [f, g] = toWireValue(p);
3292
+ e.postMessage({ ...f, id: o }, g), c === MessageType.RELEASE && (e.removeEventListener("message", n), closeEndPoint(e), finalizer in t && typeof t[finalizer] == "function" && t[finalizer]());
3332
3293
  }).catch(() => {
3333
- const [d, f] = toWireValue({
3294
+ const [p, f] = toWireValue({
3334
3295
  value: new TypeError("Unserializable return value"),
3335
3296
  [throwMarker]: 0
3336
3297
  });
3337
- e.postMessage({ ...d, id: o }, f);
3298
+ e.postMessage({ ...p, id: o }, f);
3338
3299
  }).finally(() => {
3339
3300
  s == null || s(i);
3340
3301
  });
@@ -3387,37 +3348,37 @@ function createProxy(t, e, r = [], s = function() {
3387
3348
  }) {
3388
3349
  let n = !1;
3389
3350
  const i = new Proxy(s, {
3390
- get(o, a) {
3391
- if (throwIfProxyReleased(n), a === releaseProxy)
3351
+ get(o, c) {
3352
+ if (throwIfProxyReleased(n), c === releaseProxy)
3392
3353
  return () => {
3393
3354
  unregisterProxy(i), releaseEndpoint(t), e.clear(), n = !0;
3394
3355
  };
3395
- if (a === "then") {
3356
+ if (c === "then") {
3396
3357
  if (r.length === 0)
3397
3358
  return { then: () => i };
3398
- const c = requestResponseMessage(t, e, {
3359
+ const a = requestResponseMessage(t, e, {
3399
3360
  type: MessageType.GET,
3400
3361
  path: r.map((l) => l.toString())
3401
3362
  }).then(fromWireValue);
3402
- return c.then.bind(c);
3363
+ return a.then.bind(a);
3403
3364
  }
3404
- return createProxy(t, e, [...r, a]);
3365
+ return createProxy(t, e, [...r, c]);
3405
3366
  },
3406
- set(o, a, c) {
3367
+ set(o, c, a) {
3407
3368
  throwIfProxyReleased(n);
3408
- const [l, p] = toWireValue(c);
3369
+ const [l, d] = toWireValue(a);
3409
3370
  return requestResponseMessage(
3410
3371
  t,
3411
3372
  e,
3412
3373
  {
3413
3374
  type: MessageType.SET,
3414
- path: [...r, a].map((d) => d.toString()),
3375
+ path: [...r, c].map((p) => p.toString()),
3415
3376
  value: l
3416
3377
  },
3417
- p
3378
+ d
3418
3379
  ).then(fromWireValue);
3419
3380
  },
3420
- apply(o, a, c) {
3381
+ apply(o, c, a) {
3421
3382
  throwIfProxyReleased(n);
3422
3383
  const l = r[r.length - 1];
3423
3384
  if (l === createEndpoint)
@@ -3426,28 +3387,28 @@ function createProxy(t, e, r = [], s = function() {
3426
3387
  }).then(fromWireValue);
3427
3388
  if (l === "bind")
3428
3389
  return createProxy(t, e, r.slice(0, -1));
3429
- const [p, d] = processArguments(c);
3390
+ const [d, p] = processArguments(a);
3430
3391
  return requestResponseMessage(
3431
3392
  t,
3432
3393
  e,
3433
3394
  {
3434
3395
  type: MessageType.APPLY,
3435
3396
  path: r.map((f) => f.toString()),
3436
- argumentList: p
3397
+ argumentList: d
3437
3398
  },
3438
- d
3399
+ p
3439
3400
  ).then(fromWireValue);
3440
3401
  },
3441
- construct(o, a) {
3402
+ construct(o, c) {
3442
3403
  throwIfProxyReleased(n);
3443
- const [c, l] = processArguments(a);
3404
+ const [a, l] = processArguments(c);
3444
3405
  return requestResponseMessage(
3445
3406
  t,
3446
3407
  e,
3447
3408
  {
3448
3409
  type: MessageType.CONSTRUCT,
3449
- path: r.map((p) => p.toString()),
3450
- argumentList: c
3410
+ path: r.map((d) => d.toString()),
3411
+ argumentList: a
3451
3412
  },
3452
3413
  l
3453
3414
  ).then(fromWireValue);
@@ -3602,50 +3563,50 @@ const errorProperties = [
3602
3563
  maxDepth: n,
3603
3564
  depth: i,
3604
3565
  useToJSON: o,
3605
- serialize: a
3566
+ serialize: c
3606
3567
  }) => {
3607
- if (r || (Array.isArray(t) ? r = [] : !a && isErrorLike(t) ? r = newError(t.name) : r = {}), e.push(t), i >= n)
3568
+ if (r || (Array.isArray(t) ? r = [] : !c && isErrorLike(t) ? r = newError(t.name) : r = {}), e.push(t), i >= n)
3608
3569
  return r;
3609
3570
  if (o && typeof t.toJSON == "function" && !toJsonWasCalled.has(t))
3610
3571
  return toJSON(t);
3611
- const c = (l) => destroyCircular({
3572
+ const a = (l) => destroyCircular({
3612
3573
  from: l,
3613
3574
  seen: [...e],
3614
3575
  forceEnumerable: s,
3615
3576
  maxDepth: n,
3616
3577
  depth: i,
3617
3578
  useToJSON: o,
3618
- serialize: a
3579
+ serialize: c
3619
3580
  });
3620
- for (const [l, p] of Object.entries(t)) {
3621
- if (p && p instanceof Uint8Array && p.constructor.name === "Buffer") {
3581
+ for (const [l, d] of Object.entries(t)) {
3582
+ if (d && d instanceof Uint8Array && d.constructor.name === "Buffer") {
3622
3583
  r[l] = "[object Buffer]";
3623
3584
  continue;
3624
3585
  }
3625
- if (p !== null && typeof p == "object" && typeof p.pipe == "function") {
3586
+ if (d !== null && typeof d == "object" && typeof d.pipe == "function") {
3626
3587
  r[l] = "[object Stream]";
3627
3588
  continue;
3628
3589
  }
3629
- if (typeof p != "function") {
3630
- if (!p || typeof p != "object") {
3590
+ if (typeof d != "function") {
3591
+ if (!d || typeof d != "object") {
3631
3592
  try {
3632
- r[l] = p;
3593
+ r[l] = d;
3633
3594
  } catch {
3634
3595
  }
3635
3596
  continue;
3636
3597
  }
3637
3598
  if (!e.includes(t[l])) {
3638
- i++, r[l] = c(t[l]);
3599
+ i++, r[l] = a(t[l]);
3639
3600
  continue;
3640
3601
  }
3641
3602
  r[l] = "[Circular]";
3642
3603
  }
3643
3604
  }
3644
- if (a || r instanceof Error)
3645
- for (const { property: l, enumerable: p } of errorProperties)
3605
+ if (c || r instanceof Error)
3606
+ for (const { property: l, enumerable: d } of errorProperties)
3646
3607
  t[l] !== void 0 && t[l] !== null && Object.defineProperty(r, l, {
3647
- value: isErrorLike(t[l]) || Array.isArray(t[l]) ? c(t[l]) : t[l],
3648
- enumerable: s ? !0 : p,
3608
+ value: isErrorLike(t[l]) || Array.isArray(t[l]) ? a(t[l]) : t[l],
3609
+ enumerable: s ? !0 : d,
3649
3610
  configurable: !0,
3650
3611
  writable: !0
3651
3612
  });
@@ -3688,17 +3649,17 @@ async function consumeAPISync(t) {
3688
3649
  function consumeAPI(t, e = void 0) {
3689
3650
  setupTransferHandlers();
3690
3651
  let r;
3691
- import.meta.url.startsWith("file://") ? r = nodeEndpoint(t) : r = t instanceof Worker ? t : windowEndpoint(t, e);
3652
+ typeof process < "u" && typeof process.versions < "u" && typeof process.versions.node < "u" ? r = nodeEndpoint(t) : r = t instanceof Worker ? t : windowEndpoint(t, e);
3692
3653
  const n = wrap(r), i = proxyClone(n);
3693
3654
  return new Proxy(i, {
3694
- get: (o, a) => a === "isConnected" ? async () => {
3655
+ get: (o, c) => c === "isConnected" ? async () => {
3695
3656
  for (; ; )
3696
3657
  try {
3697
3658
  await runWithTimeout(n.isConnected(), 200);
3698
3659
  break;
3699
3660
  } catch {
3700
3661
  }
3701
- } : n[a]
3662
+ } : n[c]
3702
3663
  });
3703
3664
  }
3704
3665
  async function runWithTimeout(t, e) {
@@ -3722,12 +3683,12 @@ function prepareForExpose(t, e) {
3722
3683
  setupTransferHandlers();
3723
3684
  const r = Promise.resolve();
3724
3685
  let s, n;
3725
- const i = new Promise((c, l) => {
3726
- s = c, n = l;
3727
- }), o = proxyClone(t), a = new Proxy(o, {
3728
- get: (c, l) => l === "isConnected" ? () => r : l === "isReady" ? () => i : l in c ? c[l] : e == null ? void 0 : e[l]
3686
+ const i = new Promise((a, l) => {
3687
+ s = a, n = l;
3688
+ }), o = proxyClone(t), c = new Proxy(o, {
3689
+ get: (a, l) => l === "isConnected" ? () => r : l === "isReady" ? () => i : l in a ? a[l] : e == null ? void 0 : e[l]
3729
3690
  });
3730
- return { setReady: s, setFailed: n, exposedApi: a };
3691
+ return { setReady: s, setFailed: n, exposedApi: c };
3731
3692
  }
3732
3693
  let isTransferHandlersSetup = !1;
3733
3694
  function setupTransferHandlers() {
@@ -3787,28 +3748,28 @@ function setupTransferHandlers() {
3787
3748
  stderr: r.stderr,
3788
3749
  exitCodePort: n
3789
3750
  }, [n]];
3790
- const i = streamToPort(r.headersStream), o = streamToPort(r.stdout), a = streamToPort(r.stderr);
3751
+ const i = streamToPort(r.headersStream), o = streamToPort(r.stdout), c = streamToPort(r.stderr);
3791
3752
  return [
3792
3753
  {
3793
3754
  __type: "StreamedPHPResponse",
3794
3755
  headersPort: i,
3795
3756
  stdoutPort: o,
3796
- stderrPort: a,
3757
+ stderrPort: c,
3797
3758
  exitCodePort: n
3798
3759
  },
3799
- [i, o, a, n]
3760
+ [i, o, c, n]
3800
3761
  ];
3801
3762
  },
3802
3763
  deserialize(r) {
3803
3764
  if (r.headers && r.stdout && r.stderr) {
3804
- const a = portToPromise(
3765
+ const c = portToPromise(
3805
3766
  r.exitCodePort
3806
3767
  );
3807
3768
  return new StreamedPHPResponse(
3808
3769
  r.headers,
3809
3770
  r.stdout,
3810
3771
  r.stderr,
3811
- a
3772
+ c
3812
3773
  );
3813
3774
  }
3814
3775
  const s = portToStream(r.headersPort), n = portToStream(r.stdoutPort), i = portToStream(r.stderrPort), o = portToPromise(r.exitCodePort);
@@ -3849,10 +3810,10 @@ function streamToPort(t) {
3849
3810
  break;
3850
3811
  }
3851
3812
  if (i) {
3852
- const o = i.byteOffset === 0 && i.byteLength === i.buffer.byteLength ? i : i.slice(), a = o.buffer;
3813
+ const o = i.byteOffset === 0 && i.byteLength === i.buffer.byteLength ? i : i.slice(), c = o.buffer;
3853
3814
  try {
3854
- e.postMessage({ t: "chunk", b: a }, [
3855
- a
3815
+ e.postMessage({ t: "chunk", b: c }, [
3816
+ c
3856
3817
  ]);
3857
3818
  } catch {
3858
3819
  e.postMessage({