@php-wasm/universal 3.1.39 → 3.1.41

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
@@ -371,12 +371,12 @@ FSHelpers.mkdir = rethrowFileSystemError('Could not create directory "{path}"')(
371
371
  FSHelpers.mkdir
372
372
  );
373
373
  const _private = /* @__PURE__ */ new WeakMap();
374
- var j;
374
+ var U;
375
375
  class PHPWorker {
376
376
  /** @inheritDoc */
377
377
  constructor(e, t) {
378
- E(this, j);
379
- this.absoluteUrl = "", this.documentRoot = "", this.chroot = null, x(this, j, /* @__PURE__ */ new Map()), this.onMessageListeners = [], _private.set(this, {
378
+ E(this, U);
379
+ this.absoluteUrl = "", this.documentRoot = "", this.chroot = null, x(this, U, /* @__PURE__ */ new Map()), this.onMessageListeners = [], _private.set(this, {
380
380
  monitor: t
381
381
  }), e && this.__internal_setRequestHandler(e);
382
382
  }
@@ -551,7 +551,7 @@ class PHPWorker {
551
551
  }
552
552
  /** @inheritDoc @php-wasm/universal!/PHP.addEventListener */
553
553
  addEventListener(e, t) {
554
- p(this, j).has(e) || p(this, j).set(e, /* @__PURE__ */ new Set()), p(this, j).get(e).add(t);
554
+ p(this, U).has(e) || p(this, U).set(e, /* @__PURE__ */ new Set()), p(this, U).get(e).add(t);
555
555
  }
556
556
  /**
557
557
  * Removes an event listener for a PHP event.
@@ -560,10 +560,10 @@ class PHPWorker {
560
560
  */
561
561
  removeEventListener(e, t) {
562
562
  var s;
563
- (s = p(this, j).get(e)) == null || s.delete(t);
563
+ (s = p(this, U).get(e)) == null || s.delete(t);
564
564
  }
565
565
  dispatchEvent(e) {
566
- const t = p(this, j).get(e.type);
566
+ const t = p(this, U).get(e.type);
567
567
  if (t)
568
568
  for (const s of t)
569
569
  s(e);
@@ -595,7 +595,7 @@ class PHPWorker {
595
595
  throw new Error("PHPWorker is not connected to a request handler.");
596
596
  }
597
597
  }
598
- j = new WeakMap();
598
+ U = new WeakMap();
599
599
  function isExitCode(r) {
600
600
  return r instanceof Error ? (r == null ? void 0 : r.name) === "ExitStatus" && "status" in r : !1;
601
601
  }
@@ -1069,7 +1069,7 @@ class PHPExecutionFailureError extends Error {
1069
1069
  }
1070
1070
  }
1071
1071
  const PHP_INI_PATH = "/internal/shared/php.ini", AUTO_PREPEND_SCRIPT = "/internal/shared/auto_prepend_file.php", OPCACHE_FILE_FOLDER = "/internal/shared/opcache";
1072
- var J, V, z, D, G, X, F, g, Pe, we, _e, ve, Ee, xe, Se, Fe, fe, ke, he, me;
1072
+ var Y, V, z, D, G, J, k, g, Pe, we, _e, ve, Ee, xe, Se, ke, fe, Fe, he, me;
1073
1073
  class PHP {
1074
1074
  /**
1075
1075
  * Initializes a PHP runtime.
@@ -1080,7 +1080,7 @@ class PHP {
1080
1080
  */
1081
1081
  constructor(r) {
1082
1082
  E(this, g);
1083
- E(this, J);
1083
+ E(this, Y);
1084
1084
  E(this, V, !1);
1085
1085
  E(this, z, null);
1086
1086
  E(this, D, /* @__PURE__ */ new Map([
@@ -1088,8 +1088,8 @@ class PHP {
1088
1088
  ["*", /* @__PURE__ */ new Set()]
1089
1089
  ]));
1090
1090
  E(this, G, []);
1091
- E(this, X, {});
1092
- E(this, F, {
1091
+ E(this, J, {});
1092
+ E(this, k, {
1093
1093
  enabled: !1,
1094
1094
  recreateRuntime: () => 0,
1095
1095
  needsRotating: !1,
@@ -1097,7 +1097,7 @@ class PHP {
1097
1097
  requestsMade: 0
1098
1098
  });
1099
1099
  this.semaphore = new Semaphore({ concurrency: 1 }), r !== void 0 && this.initializeRuntime(r), this.addEventListener("request.error", (e) => {
1100
- e.source === "php-wasm" && (p(this, F).needsRotating = !0);
1100
+ e.source === "php-wasm" && (p(this, k).needsRotating = !0);
1101
1101
  });
1102
1102
  }
1103
1103
  /**
@@ -1282,7 +1282,7 @@ class PHP {
1282
1282
  throw new Error(
1283
1283
  "Could not set SAPI name. This can only be done before the PHP WASM module is initialized.Did you already dispatch any requests?"
1284
1284
  );
1285
- x(this, J, r);
1285
+ x(this, Y, r);
1286
1286
  }
1287
1287
  /**
1288
1288
  * Changes the current working directory in the PHP filesystem.
@@ -1519,7 +1519,7 @@ class PHP {
1519
1519
  );
1520
1520
  _(this, g, we).call(this, r.relativeUri || ""), _(this, g, xe).call(this, r.method || "GET");
1521
1521
  const o = normalizeHeaders(r.headers || {}), i = o.host || "example.com:443", a = _(this, g, Ee).call(this, i, r.protocol || "http");
1522
- if (_(this, g, _e).call(this, i), _(this, g, ve).call(this, a), _(this, g, Se).call(this, o), r.body && (t = _(this, g, Fe).call(this, r.body)), typeof r.code == "string")
1522
+ if (_(this, g, _e).call(this, i), _(this, g, ve).call(this, a), _(this, g, Se).call(this, o), r.body && (t = _(this, g, ke).call(this, r.body)), typeof r.code == "string")
1523
1523
  this.writeFile("/internal/eval.php", r.code), _(this, g, fe).call(this, "/internal/eval.php");
1524
1524
  else if (typeof r.scriptPath == "string")
1525
1525
  _(this, g, fe).call(this, r.scriptPath || "");
@@ -1529,7 +1529,7 @@ class PHP {
1529
1529
  );
1530
1530
  const c = _(this, g, Pe).call(this, r.$_SERVER, o, a);
1531
1531
  for (const d in c)
1532
- _(this, g, ke).call(this, d, c[d]);
1532
+ _(this, g, Fe).call(this, d, c[d]);
1533
1533
  const l = r.env || {};
1534
1534
  for (const d in l)
1535
1535
  _(this, g, he).call(this, d, l[d]);
@@ -1770,21 +1770,21 @@ class PHP {
1770
1770
  * or an internal crash.
1771
1771
  */
1772
1772
  enableRuntimeRotation(r) {
1773
- x(this, F, {
1774
- ...p(this, F),
1773
+ x(this, k, {
1774
+ ...p(this, k),
1775
1775
  enabled: !0,
1776
1776
  recreateRuntime: r.recreateRuntime,
1777
1777
  maxRequests: r.maxRequests ?? 400
1778
1778
  });
1779
1779
  }
1780
1780
  async rotateRuntime() {
1781
- if (!p(this, F).enabled)
1781
+ if (!p(this, k).enabled)
1782
1782
  throw new Error(
1783
1783
  "Runtime rotation is not enabled. Call enableRuntimeRotation() first."
1784
1784
  );
1785
1785
  await this.hotSwapPHPRuntime(
1786
- await p(this, F).recreateRuntime()
1787
- ), p(this, F).requestsMade = 0, p(this, F).needsRotating = !1;
1786
+ await p(this, k).recreateRuntime()
1787
+ ), p(this, k).requestsMade = 0, p(this, k).needsRotating = !1;
1788
1788
  }
1789
1789
  /**
1790
1790
  * Hot-swaps the PHP runtime for a new one without
@@ -1795,13 +1795,14 @@ class PHP {
1795
1795
  async hotSwapPHPRuntime(r) {
1796
1796
  const e = this[__private__dont__use].FS, t = this.listFiles("/").map((c) => `/${c}`), s = this[__private__dont__use].spawnProcess, n = e.cwd();
1797
1797
  e.chdir("/");
1798
- const o = Object.entries(p(this, X)).map(
1798
+ const o = Object.entries(p(this, J)).map(
1799
1799
  ([c, l]) => ({
1800
1800
  mountHandler: l.mountHandler,
1801
+ mountPointSnapshot: snapshotMountPoint(e, c),
1801
1802
  vfsPath: c
1802
1803
  })
1803
1804
  ), i = Object.values(
1804
- p(this, X)
1805
+ p(this, J)
1805
1806
  ).reverse();
1806
1807
  for (const c of i)
1807
1808
  await c.unmount();
@@ -1809,12 +1810,30 @@ class PHP {
1809
1810
  this.exit();
1810
1811
  } catch {
1811
1812
  }
1812
- this.initializeRuntime(r), s && (this[__private__dont__use].spawnProcess = s), p(this, J) && this.setSapiName(p(this, J));
1813
+ this.initializeRuntime(r), s && (this[__private__dont__use].spawnProcess = s), p(this, Y) && this.setSapiName(p(this, Y));
1813
1814
  const a = this[__private__dont__use].FS;
1814
1815
  for (const c of t)
1815
1816
  c && c !== "/request" && copyMEMFSNodes(e, a, c);
1816
- for (const { mountHandler: c, vfsPath: l } of o)
1817
- this.mkdir(l), await this.mount(l, c);
1817
+ for (const {
1818
+ mountHandler: c,
1819
+ mountPointSnapshot: l,
1820
+ vfsPath: d
1821
+ } of o)
1822
+ try {
1823
+ await this.mount(d, c);
1824
+ } catch (u) {
1825
+ if (isMissingMountSourceError(u)) {
1826
+ restoreMountPointSnapshot(
1827
+ a,
1828
+ d,
1829
+ l
1830
+ );
1831
+ continue;
1832
+ }
1833
+ if (!isMissingMountTargetPathError(u))
1834
+ throw u;
1835
+ this.mkdir(d), await this.mount(d, c);
1836
+ }
1818
1837
  try {
1819
1838
  a.chdir(n);
1820
1839
  } catch (c) {
@@ -1844,11 +1863,11 @@ class PHP {
1844
1863
  try {
1845
1864
  await t();
1846
1865
  } finally {
1847
- delete p(this, X)[r];
1866
+ delete p(this, J)[r];
1848
1867
  }
1849
1868
  }
1850
1869
  };
1851
- return p(this, X)[r] = s, () => s.unmount();
1870
+ return p(this, J)[r] = s, () => s.unmount();
1852
1871
  }
1853
1872
  /**
1854
1873
  * Starts a PHP CLI session with given arguments.
@@ -1866,7 +1885,7 @@ class PHP {
1866
1885
  async cli(r, e = {}) {
1867
1886
  if (basename(r[0] ?? "") !== "php")
1868
1887
  return this.subProcess(r, e);
1869
- p(this, V) && (p(this, F).needsRotating = !0);
1888
+ p(this, V) && (p(this, k).needsRotating = !0);
1870
1889
  const t = await this.semaphore.acquire();
1871
1890
  return await _(this, g, me).call(this, () => {
1872
1891
  const s = e.env || {};
@@ -1884,7 +1903,7 @@ class PHP {
1884
1903
  async: !0
1885
1904
  });
1886
1905
  }).then((s) => (s.exitCode.finally(t), s)).finally(() => {
1887
- p(this, F).needsRotating = !0;
1906
+ p(this, k).needsRotating = !0;
1888
1907
  });
1889
1908
  }
1890
1909
  /**
@@ -1972,7 +1991,7 @@ class PHP {
1972
1991
  this.exit(0);
1973
1992
  }
1974
1993
  }
1975
- J = new WeakMap(), V = new WeakMap(), z = new WeakMap(), D = new WeakMap(), G = new WeakMap(), X = new WeakMap(), F = new WeakMap(), g = new WeakSet(), /**
1994
+ Y = new WeakMap(), V = new WeakMap(), z = new WeakMap(), D = new WeakMap(), G = new WeakMap(), J = new WeakMap(), k = new WeakMap(), g = new WeakSet(), /**
1976
1995
  * Prepares the $_SERVER entries for the PHP runtime.
1977
1996
  *
1978
1997
  * @param defaults Default entries to include in $_SERVER.
@@ -2050,7 +2069,7 @@ Pe = function(r, e, t) {
2050
2069
  [NUMBER],
2051
2070
  [parseInt(r["content-length"], 10)]
2052
2071
  );
2053
- }, Fe = function(r) {
2072
+ }, ke = function(r) {
2054
2073
  let e, t;
2055
2074
  typeof r == "string" ? (logger.warn(
2056
2075
  "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"
@@ -2080,7 +2099,7 @@ Pe = function(r, e, t) {
2080
2099
  [STRING],
2081
2100
  [r]
2082
2101
  );
2083
- }, ke = function(r, e) {
2102
+ }, Fe = function(r, e) {
2084
2103
  this[__private__dont__use].ccall(
2085
2104
  "wasm_add_SERVER_entry",
2086
2105
  null,
@@ -2095,7 +2114,7 @@ Pe = function(r, e, t) {
2095
2114
  [r, e]
2096
2115
  );
2097
2116
  }, me = async function(r) {
2098
- p(this, F).enabled && p(this, F).needsRotating && await this.rotateRuntime(), ++p(this, F).requestsMade, p(this, F).requestsMade >= p(this, F).maxRequests && (p(this, F).needsRotating = !0);
2117
+ p(this, k).enabled && p(this, k).needsRotating && await this.rotateRuntime(), ++p(this, k).requestsMade, p(this, k).requestsMade >= p(this, k).maxRequests && (p(this, k).needsRotating = !0);
2099
2118
  const e = this[__private__dont__use], t = await createInvertedReadableStream();
2100
2119
  e.onHeaders = (u) => {
2101
2120
  a || s || t.controller.enqueue(u.slice());
@@ -2194,6 +2213,29 @@ function copyMEMFSNodes(r, e, t) {
2194
2213
  for (const o of n)
2195
2214
  copyMEMFSNodes(r, e, joinPaths(t, o));
2196
2215
  }
2216
+ function snapshotMountPoint(r, e) {
2217
+ try {
2218
+ const t = r.lookupPath(e, { follow: !1 });
2219
+ return r.isLink(t.node.mode) ? { kind: "symlink", target: r.readlink(e) } : r.isDir(t.node.mode) ? { kind: "directory" } : { kind: "file" };
2220
+ } catch {
2221
+ return;
2222
+ }
2223
+ }
2224
+ function restoreMountPointSnapshot(r, e, t) {
2225
+ if (!(!t || getNodeType(r, e) !== "missing")) {
2226
+ if (t.kind === "directory") {
2227
+ r.mkdirTree(e);
2228
+ return;
2229
+ }
2230
+ r.mkdirTree(dirname(e)), t.kind === "symlink" ? r.symlink(t.target, e) : r.writeFile(e, new Uint8Array());
2231
+ }
2232
+ }
2233
+ function isMissingMountSourceError(r) {
2234
+ return r.phpWasmMountSourceMissing === !0;
2235
+ }
2236
+ function isMissingMountTargetPathError(r) {
2237
+ return r.errno === 44;
2238
+ }
2197
2239
  async function createInvertedReadableStream(r = {}) {
2198
2240
  let e;
2199
2241
  const t = new Promise(
@@ -2284,6 +2326,34 @@ Caused by:
2284
2326
  process.stderr.write(`
2285
2327
  `);
2286
2328
  }
2329
+ function describeError(r, e = /* @__PURE__ */ new WeakSet(), t = 0, s = {}) {
2330
+ return t > 10 ? "[Max error cause depth exceeded]" : r instanceof Error ? r.message ? r.message : describeErrorObject(r, e, t, {
2331
+ ...s,
2332
+ suppressGenericErrorName: !0
2333
+ }) : r && typeof r == "object" ? describeErrorObject(r, e, t, s) : String(r);
2334
+ }
2335
+ function describeErrorObject(r, e, t, s = {}) {
2336
+ if (e.has(r))
2337
+ return "[Circular error cause]";
2338
+ e.add(r);
2339
+ const n = [];
2340
+ if (r.name && !(s.suppressGenericErrorName && r.name === "Error") && n.push(String(r.name)), r.message && n.push(String(r.message)), r.errno !== void 0 && n.push(`errno: ${r.errno}`), r.code !== void 0 && n.push(`code: ${r.code}`), r.cause && n.push(
2341
+ `caused by: ${describeError(
2342
+ r.cause,
2343
+ e,
2344
+ t + 1,
2345
+ s
2346
+ )}`
2347
+ ), n.length > 0)
2348
+ return n.join(" — ");
2349
+ if (typeof r.stack == "string")
2350
+ return r.stack;
2351
+ try {
2352
+ return JSON.stringify(r);
2353
+ } catch {
2354
+ return String(r);
2355
+ }
2356
+ }
2287
2357
  function printResponseDebugDetails(r) {
2288
2358
  process.stderr.write(
2289
2359
  `
@@ -2662,7 +2732,7 @@ const _default = "application/octet-stream", asx = "video/x-ms-asf", atom = "app
2662
2732
  xspf,
2663
2733
  zip
2664
2734
  };
2665
- var A, Q, re, Y, K, M, Z, $, se, b, Re, oe, be, He, Te;
2735
+ var A, Q, re, X, K, I, Z, $, se, R, be, oe, Re, He, Te;
2666
2736
  class PHPRequestHandler {
2667
2737
  /**
2668
2738
  * The request handler needs to decide whether to serve a static asset or
@@ -2676,13 +2746,13 @@ class PHPRequestHandler {
2676
2746
  * @param config - Request Handler configuration.
2677
2747
  */
2678
2748
  constructor(e) {
2679
- E(this, b);
2749
+ E(this, R);
2680
2750
  E(this, A);
2681
2751
  E(this, Q);
2682
2752
  E(this, re);
2683
- E(this, Y);
2753
+ E(this, X);
2684
2754
  E(this, K);
2685
- E(this, M);
2755
+ E(this, I);
2686
2756
  E(this, Z);
2687
2757
  E(this, $);
2688
2758
  E(this, se);
@@ -2716,15 +2786,15 @@ class PHPRequestHandler {
2716
2786
  );
2717
2787
  x(this, $, e.cookieStore === void 0 ? new HttpCookieStore() : e.cookieStore), x(this, A, t);
2718
2788
  const c = new URL(s);
2719
- x(this, re, c.hostname), x(this, Y, c.port ? Number(c.port) : c.protocol === "https:" ? 443 : 80), x(this, Q, (c.protocol || "").replace(":", ""));
2720
- const l = p(this, Y) !== 443 && p(this, Y) !== 80;
2789
+ x(this, re, c.hostname), x(this, X, c.port ? Number(c.port) : c.protocol === "https:" ? 443 : 80), x(this, Q, (c.protocol || "").replace(":", ""));
2790
+ const l = p(this, X) !== 443 && p(this, X) !== 80;
2721
2791
  x(this, K, [
2722
2792
  p(this, re),
2723
- l ? `:${p(this, Y)}` : ""
2724
- ].join("")), x(this, M, c.pathname.replace(/\/+$/, "")), x(this, Z, [
2793
+ l ? `:${p(this, X)}` : ""
2794
+ ].join("")), x(this, I, c.pathname.replace(/\/+$/, "")), x(this, Z, [
2725
2795
  `${p(this, Q)}://`,
2726
2796
  p(this, K),
2727
- p(this, M)
2797
+ p(this, I)
2728
2798
  ].join("")), this.rewriteRules = n, x(this, se, o), this.getFileNotFoundAction = i;
2729
2799
  }
2730
2800
  async getPrimaryPhp() {
@@ -2749,7 +2819,7 @@ class PHPRequestHandler {
2749
2819
  */
2750
2820
  internalUrlToPath(e) {
2751
2821
  const t = new URL(e, "https://playground.internal");
2752
- return t.pathname.startsWith(p(this, M)) && (t.pathname = t.pathname.slice(p(this, M).length)), toRelativeUrl(t);
2822
+ return t.pathname.startsWith(p(this, I)) && (t.pathname = t.pathname.slice(p(this, I).length)), toRelativeUrl(t);
2753
2823
  }
2754
2824
  /**
2755
2825
  * The absolute URL of this PHPRequestHandler instance.
@@ -2838,15 +2908,15 @@ class PHPRequestHandler {
2838
2908
  // Remove the hash part of the URL as it's not meant for the server.
2839
2909
  e.url.split("#")[0],
2840
2910
  t ? void 0 : DEFAULT_BASE_URL
2841
- ), n = _(this, b, Re).call(this, s), o = await this.getPrimaryPhp(), i = removePathPrefix(
2911
+ ), n = _(this, R, be).call(this, s), o = await this.getPrimaryPhp(), i = removePathPrefix(
2842
2912
  /**
2843
2913
  * URL.pathname returns a URL-encoded path. We need to decode it
2844
2914
  * before using it as a filesystem path.
2845
2915
  */
2846
2916
  decodeURIComponent(n.pathname),
2847
- p(this, M)
2917
+ p(this, I)
2848
2918
  );
2849
- let a = _(this, b, oe).call(this, i);
2919
+ let a = _(this, R, oe).call(this, i);
2850
2920
  if (o.isDir(a)) {
2851
2921
  if (!i.endsWith("/"))
2852
2922
  return StreamedPHPResponse.fromPHPResponse(
@@ -2871,10 +2941,10 @@ class PHPRequestHandler {
2871
2941
  let c = i;
2872
2942
  for (; c.startsWith("/") && c !== dirname(c); ) {
2873
2943
  c = dirname(c);
2874
- const l = _(this, b, oe).call(this, c);
2944
+ const l = _(this, R, oe).call(this, c);
2875
2945
  if (o.isFile(l) && // Only run partial path resolution for PHP files.
2876
2946
  l.endsWith(".php")) {
2877
- a = _(this, b, oe).call(this, c);
2947
+ a = _(this, R, oe).call(this, c);
2878
2948
  break;
2879
2949
  }
2880
2950
  }
@@ -2899,8 +2969,8 @@ class PHPRequestHandler {
2899
2969
  );
2900
2970
  }
2901
2971
  }
2902
- return o.isFile(a) ? a.endsWith(".php") ? await _(this, b, He).call(this, e, s, n, a) : StreamedPHPResponse.fromPHPResponse(
2903
- _(this, b, be).call(this, o, a)
2972
+ return o.isFile(a) ? a.endsWith(".php") ? await _(this, R, He).call(this, e, s, n, a) : StreamedPHPResponse.fromPHPResponse(
2973
+ _(this, R, Re).call(this, o, a)
2904
2974
  ) : StreamedPHPResponse.forHttpCode(404);
2905
2975
  }
2906
2976
  /**
@@ -3010,21 +3080,21 @@ class PHPRequestHandler {
3010
3080
  await this.instanceManager[Symbol.asyncDispose]();
3011
3081
  }
3012
3082
  }
3013
- A = new WeakMap(), Q = new WeakMap(), re = new WeakMap(), Y = new WeakMap(), K = new WeakMap(), M = new WeakMap(), Z = new WeakMap(), $ = new WeakMap(), se = new WeakMap(), b = new WeakSet(), /**
3083
+ A = new WeakMap(), Q = new WeakMap(), re = new WeakMap(), X = new WeakMap(), K = new WeakMap(), I = new WeakMap(), Z = new WeakMap(), $ = new WeakMap(), se = new WeakMap(), R = new WeakSet(), /**
3014
3084
  * Apply the rewrite rules to the original request URL.
3015
3085
  *
3016
3086
  * @param originalRequestUrl - The original request URL.
3017
3087
  * @returns The rewritten request URL.
3018
3088
  */
3019
- Re = function(e) {
3089
+ be = function(e) {
3020
3090
  const t = removePathPrefix(
3021
3091
  decodeURIComponent(e.pathname),
3022
- p(this, M)
3092
+ p(this, I)
3023
3093
  ), s = applyRewriteRules(
3024
3094
  t,
3025
3095
  this.rewriteRules
3026
3096
  ), n = new URL(
3027
- joinPaths(p(this, M), s),
3097
+ joinPaths(p(this, I), s),
3028
3098
  e.toString()
3029
3099
  );
3030
3100
  for (const [o, i] of e.searchParams.entries())
@@ -3052,7 +3122,7 @@ oe = function(e) {
3052
3122
  * @param fsPath - Absolute path of the static file to serve.
3053
3123
  * @returns The response.
3054
3124
  */
3055
- be = function(e, t) {
3125
+ Re = function(e, t) {
3056
3126
  const s = e.readFileAsBuffer(t);
3057
3127
  return new PHPResponse(
3058
3128
  200,
@@ -3076,7 +3146,7 @@ be = function(e, t) {
3076
3146
  }
3077
3147
  let i;
3078
3148
  try {
3079
- i = await _(this, b, Te).call(this, o.php, e, t, s, n);
3149
+ i = await _(this, R, Te).call(this, o.php, e, t, s, n);
3080
3150
  } catch (a) {
3081
3151
  throw o.reap(), a;
3082
3152
  }
@@ -3099,7 +3169,7 @@ be = function(e, t) {
3099
3169
  const l = await e.runStream({
3100
3170
  relativeUri: ensurePathPrefix(
3101
3171
  toRelativeUrl(new URL(n.toString())),
3102
- p(this, M)
3172
+ p(this, I)
3103
3173
  ),
3104
3174
  protocol: p(this, Q),
3105
3175
  method: t.method || i,
@@ -3290,15 +3360,15 @@ function validate11(r, { instancePath: e = "", parentData: t, parentDataProperty
3290
3360
  let o = null, i = 0;
3291
3361
  if (i === 0)
3292
3362
  if (r && typeof r == "object" && !Array.isArray(r)) {
3293
- let L;
3294
- if (r.name === void 0 && (L = "name") || r.artifacts === void 0 && (L = "artifacts"))
3363
+ let M;
3364
+ if (r.name === void 0 && (M = "name") || r.artifacts === void 0 && (M = "artifacts"))
3295
3365
  return validate11.errors = [
3296
3366
  {
3297
3367
  instancePath: e,
3298
3368
  schemaPath: "#/required",
3299
3369
  keyword: "required",
3300
- params: { missingProperty: L },
3301
- message: "must have required property '" + L + "'"
3370
+ params: { missingProperty: M },
3371
+ message: "must have required property '" + M + "'"
3302
3372
  }
3303
3373
  ], !1;
3304
3374
  {
@@ -3349,7 +3419,7 @@ function validate11(r, { instancePath: e = "", parentData: t, parentDataProperty
3349
3419
  if (a) {
3350
3420
  if (r.mode !== void 0) {
3351
3421
  let f = r.mode;
3352
- const R = i;
3422
+ const b = i;
3353
3423
  if (typeof f != "string")
3354
3424
  return validate11.errors = [
3355
3425
  {
@@ -3372,7 +3442,7 @@ function validate11(r, { instancePath: e = "", parentData: t, parentDataProperty
3372
3442
  message: "must be equal to constant"
3373
3443
  }
3374
3444
  ], !1;
3375
- var a = R === i;
3445
+ var a = b === i;
3376
3446
  } else
3377
3447
  var a = !0;
3378
3448
  if (a) {
@@ -3392,15 +3462,15 @@ function validate11(r, { instancePath: e = "", parentData: t, parentDataProperty
3392
3462
  if (a) {
3393
3463
  if (r.iniEntries !== void 0) {
3394
3464
  let f = r.iniEntries;
3395
- const R = i;
3396
- if (i === R)
3465
+ const b = i;
3466
+ if (i === b)
3397
3467
  if (f && typeof f == "object" && !Array.isArray(f))
3398
- for (const U in f) {
3468
+ for (const j in f) {
3399
3469
  const m = i;
3400
- if (typeof f[U] != "string")
3470
+ if (typeof f[j] != "string")
3401
3471
  return validate11.errors = [
3402
3472
  {
3403
- instancePath: e + "/iniEntries/" + U.replace(
3473
+ instancePath: e + "/iniEntries/" + j.replace(
3404
3474
  /~/g,
3405
3475
  "~0"
3406
3476
  ).replace(
@@ -3431,21 +3501,21 @@ function validate11(r, { instancePath: e = "", parentData: t, parentDataProperty
3431
3501
  message: "must be object"
3432
3502
  }
3433
3503
  ], !1;
3434
- var a = R === i;
3504
+ var a = b === i;
3435
3505
  } else
3436
3506
  var a = !0;
3437
3507
  if (a) {
3438
3508
  if (r.env !== void 0) {
3439
3509
  let f = r.env;
3440
- const R = i;
3441
- if (i === R)
3510
+ const b = i;
3511
+ if (i === b)
3442
3512
  if (f && typeof f == "object" && !Array.isArray(f))
3443
- for (const U in f) {
3513
+ for (const j in f) {
3444
3514
  const m = i;
3445
- if (typeof f[U] != "string")
3515
+ if (typeof f[j] != "string")
3446
3516
  return validate11.errors = [
3447
3517
  {
3448
- instancePath: e + "/env/" + U.replace(
3518
+ instancePath: e + "/env/" + j.replace(
3449
3519
  /~/g,
3450
3520
  "~0"
3451
3521
  ).replace(
@@ -3476,7 +3546,7 @@ function validate11(r, { instancePath: e = "", parentData: t, parentDataProperty
3476
3546
  message: "must be object"
3477
3547
  }
3478
3548
  ], !1;
3479
- var a = R === i;
3549
+ var a = b === i;
3480
3550
  } else
3481
3551
  var a = !0;
3482
3552
  if (a) {
@@ -3500,29 +3570,29 @@ function validate11(r, { instancePath: e = "", parentData: t, parentDataProperty
3500
3570
  if (a) {
3501
3571
  if (r.artifacts !== void 0) {
3502
3572
  let f = r.artifacts;
3503
- const R = i;
3504
- if (i === R)
3573
+ const b = i;
3574
+ if (i === b)
3505
3575
  if (Array.isArray(f)) {
3506
3576
  var d = !0;
3507
- const U = f.length;
3508
- for (let m = 0; m < U; m++) {
3577
+ const j = f.length;
3578
+ for (let m = 0; m < j; m++) {
3509
3579
  let w = f[m];
3510
- const q = i;
3511
- if (i === q)
3580
+ const W = i;
3581
+ if (i === W)
3512
3582
  if (w && typeof w == "object" && !Array.isArray(
3513
3583
  w
3514
3584
  )) {
3515
- let W;
3516
- if (w.phpVersion === void 0 && (W = "phpVersion") || w.sourcePath === void 0 && (W = "sourcePath"))
3585
+ let q;
3586
+ if (w.phpVersion === void 0 && (q = "phpVersion") || w.sourcePath === void 0 && (q = "sourcePath"))
3517
3587
  return validate11.errors = [
3518
3588
  {
3519
3589
  instancePath: e + "/artifacts/" + m,
3520
3590
  schemaPath: "#/properties/artifacts/items/required",
3521
3591
  keyword: "required",
3522
3592
  params: {
3523
- missingProperty: W
3593
+ missingProperty: q
3524
3594
  },
3525
- message: "must have required property '" + W + "'"
3595
+ message: "must have required property '" + q + "'"
3526
3596
  }
3527
3597
  ], !1;
3528
3598
  {
@@ -3625,16 +3695,16 @@ function validate11(r, { instancePath: e = "", parentData: t, parentDataProperty
3625
3695
  v
3626
3696
  )) {
3627
3697
  var P = !0;
3628
- const Ie = v.length;
3629
- for (let C = 0; C < Ie; C++) {
3630
- let I = v[C];
3698
+ const Le = v.length;
3699
+ for (let C = 0; C < Le; C++) {
3700
+ let L = v[C];
3631
3701
  const ye = i;
3632
3702
  if (i === ye)
3633
- if (I && typeof I == "object" && !Array.isArray(
3634
- I
3703
+ if (L && typeof L == "object" && !Array.isArray(
3704
+ L
3635
3705
  )) {
3636
3706
  let ue;
3637
- if (I.vfsPath === void 0 && (ue = "vfsPath"))
3707
+ if (L.vfsPath === void 0 && (ue = "vfsPath"))
3638
3708
  return validate11.errors = [
3639
3709
  {
3640
3710
  instancePath: e + "/artifacts/" + m + "/extraFiles/nodes/" + C,
@@ -3647,8 +3717,8 @@ function validate11(r, { instancePath: e = "", parentData: t, parentDataProperty
3647
3717
  }
3648
3718
  ], !1;
3649
3719
  {
3650
- const Me = i;
3651
- for (const T in I)
3720
+ const Ie = i;
3721
+ for (const T in L)
3652
3722
  if (!(T === "vfsPath" || T === "type" || T === "sourcePath"))
3653
3723
  return validate11.errors = [
3654
3724
  {
@@ -3661,10 +3731,10 @@ function validate11(r, { instancePath: e = "", parentData: t, parentDataProperty
3661
3731
  message: "must NOT have additional properties"
3662
3732
  }
3663
3733
  ], !1;
3664
- if (Me === i) {
3665
- if (I.vfsPath !== void 0) {
3734
+ if (Ie === i) {
3735
+ if (L.vfsPath !== void 0) {
3666
3736
  const T = i;
3667
- if (typeof I.vfsPath != "string")
3737
+ if (typeof L.vfsPath != "string")
3668
3738
  return validate11.errors = [
3669
3739
  {
3670
3740
  instancePath: e + "/artifacts/" + m + "/extraFiles/nodes/" + C + "/vfsPath",
@@ -3680,8 +3750,8 @@ function validate11(r, { instancePath: e = "", parentData: t, parentDataProperty
3680
3750
  } else
3681
3751
  var S = !0;
3682
3752
  if (S) {
3683
- if (I.type !== void 0) {
3684
- let T = I.type;
3753
+ if (L.type !== void 0) {
3754
+ let T = L.type;
3685
3755
  const Ce = i;
3686
3756
  if (typeof T != "string")
3687
3757
  return validate11.errors = [
@@ -3711,9 +3781,9 @@ function validate11(r, { instancePath: e = "", parentData: t, parentDataProperty
3711
3781
  } else
3712
3782
  var S = !0;
3713
3783
  if (S)
3714
- if (I.sourcePath !== void 0) {
3784
+ if (L.sourcePath !== void 0) {
3715
3785
  const T = i;
3716
- if (typeof I.sourcePath != "string")
3786
+ if (typeof L.sourcePath != "string")
3717
3787
  return validate11.errors = [
3718
3788
  {
3719
3789
  instancePath: e + "/artifacts/" + m + "/extraFiles/nodes/" + C + "/sourcePath",
@@ -3793,7 +3863,7 @@ function validate11(r, { instancePath: e = "", parentData: t, parentDataProperty
3793
3863
  message: "must be object"
3794
3864
  }
3795
3865
  ], !1;
3796
- var d = q === i;
3866
+ var d = W === i;
3797
3867
  if (!d)
3798
3868
  break;
3799
3869
  }
@@ -3809,13 +3879,13 @@ function validate11(r, { instancePath: e = "", parentData: t, parentDataProperty
3809
3879
  message: "must be array"
3810
3880
  }
3811
3881
  ], !1;
3812
- var a = R === i;
3882
+ var a = b === i;
3813
3883
  } else
3814
3884
  var a = !0;
3815
3885
  if (a)
3816
3886
  if (r.extraFiles !== void 0) {
3817
3887
  let f = r.extraFiles;
3818
- const R = i;
3888
+ const b = i;
3819
3889
  if (i === i)
3820
3890
  if (f && typeof f == "object" && !Array.isArray(
3821
3891
  f
@@ -3855,14 +3925,14 @@ function validate11(r, { instancePath: e = "", parentData: t, parentDataProperty
3855
3925
  if (N)
3856
3926
  if (f.nodes !== void 0) {
3857
3927
  let w = f.nodes;
3858
- const q = i;
3859
- if (i === q)
3928
+ const W = i;
3929
+ if (i === W)
3860
3930
  if (Array.isArray(
3861
3931
  w
3862
3932
  )) {
3863
3933
  var B = !0;
3864
- const W = w.length;
3865
- for (let H = 0; H < W; H++) {
3934
+ const q = w.length;
3935
+ for (let H = 0; H < q; H++) {
3866
3936
  let y = w[H];
3867
3937
  const ne = i;
3868
3938
  if (i === ne)
@@ -3912,10 +3982,10 @@ function validate11(r, { instancePath: e = "", parentData: t, parentDataProperty
3912
3982
  message: "must be string"
3913
3983
  }
3914
3984
  ], !1;
3915
- var k = v === i;
3985
+ var F = v === i;
3916
3986
  } else
3917
- var k = !0;
3918
- if (k) {
3987
+ var F = !0;
3988
+ if (F) {
3919
3989
  if (y.type !== void 0) {
3920
3990
  let v = y.type;
3921
3991
  const ie = i;
@@ -3943,10 +4013,10 @@ function validate11(r, { instancePath: e = "", parentData: t, parentDataProperty
3943
4013
  message: "must be equal to one of the allowed values"
3944
4014
  }
3945
4015
  ], !1;
3946
- var k = ie === i;
4016
+ var F = ie === i;
3947
4017
  } else
3948
- var k = !0;
3949
- if (k)
4018
+ var F = !0;
4019
+ if (F)
3950
4020
  if (y.sourcePath !== void 0) {
3951
4021
  const v = i;
3952
4022
  if (typeof y.sourcePath != "string")
@@ -3961,9 +4031,9 @@ function validate11(r, { instancePath: e = "", parentData: t, parentDataProperty
3961
4031
  message: "must be string"
3962
4032
  }
3963
4033
  ], !1;
3964
- var k = v === i;
4034
+ var F = v === i;
3965
4035
  } else
3966
- var k = !0;
4036
+ var F = !0;
3967
4037
  }
3968
4038
  }
3969
4039
  }
@@ -3995,7 +4065,7 @@ function validate11(r, { instancePath: e = "", parentData: t, parentDataProperty
3995
4065
  message: "must be array"
3996
4066
  }
3997
4067
  ], !1;
3998
- var N = q === i;
4068
+ var N = W === i;
3999
4069
  } else
4000
4070
  var N = !0;
4001
4071
  }
@@ -4011,7 +4081,7 @@ function validate11(r, { instancePath: e = "", parentData: t, parentDataProperty
4011
4081
  message: "must be object"
4012
4082
  }
4013
4083
  ], !1;
4014
- var a = R === i;
4084
+ var a = b === i;
4015
4085
  } else
4016
4086
  var a = !0;
4017
4087
  }
@@ -4057,9 +4127,9 @@ async function resolvePHPExtension(r) {
4057
4127
  );
4058
4128
  n = toUint8Array(t.bytes);
4059
4129
  } else if (t.format === "url") {
4060
- let k;
4130
+ let F;
4061
4131
  try {
4062
- k = new URL(String(t.url));
4132
+ F = new URL(String(t.url));
4063
4133
  } catch {
4064
4134
  throw new Error(
4065
4135
  `source.url must be an absolute URL when loading a PHP extension from a direct URL. Received: ${String(
@@ -4067,21 +4137,21 @@ async function resolvePHPExtension(r) {
4067
4137
  )}`
4068
4138
  );
4069
4139
  }
4070
- if (s || (s = t.name), !s && k.pathname.endsWith(".so") && (s = basename(k.pathname).slice(0, -3)), !s)
4140
+ if (s || (s = t.name), !s && F.pathname.endsWith(".so") && (s = basename(F.pathname).slice(0, -3)), !s)
4071
4141
  throw new Error(
4072
4142
  "name is required when loading an extension from a direct URL."
4073
4143
  );
4074
- n = await fetchBytes(e, k);
4144
+ n = await fetchBytes(e, F);
4075
4145
  } else {
4076
- let k, L;
4077
- if ("manifest" in t ? (k = t.manifest, t.baseUrl && (L = new URL(String(t.baseUrl)))) : (L = new URL(String(t.manifestUrl)), k = await (await e(L)).json()), !validate10(k))
4146
+ let F, M;
4147
+ if ("manifest" in t ? (F = t.manifest, t.baseUrl && (M = new URL(String(t.baseUrl)))) : (M = new URL(String(t.manifestUrl)), F = await (await e(M)).json()), !validate10(F))
4078
4148
  throw new Error(
4079
4149
  `Invalid PHP extension manifest: ${JSON.stringify(
4080
4150
  validate10.errors
4081
4151
  )}`
4082
4152
  );
4083
- const O = k;
4084
- if (!L)
4153
+ const O = F;
4154
+ if (!M)
4085
4155
  throw new Error(
4086
4156
  "Manifest artifacts require a manifest URL or baseUrl so relative files can be resolved."
4087
4157
  );
@@ -4093,29 +4163,29 @@ async function resolvePHPExtension(r) {
4093
4163
  `No extension artifact found for PHP ${r.phpVersion}.`
4094
4164
  );
4095
4165
  s ?? (s = O.name), a = O.loadWithIniDirective, c = O.iniEntries, l = O.env, d = O.extensionDir;
4096
- const R = new Semaphore({
4166
+ const b = new Semaphore({
4097
4167
  concurrency: MAX_EXTENSION_SIDECAR_FILE_REQUESTS
4098
4168
  }), ce = [];
4099
4169
  for (const m of [O.extraFiles, f.extraFiles])
4100
4170
  for (const w of (m == null ? void 0 : m.nodes) ?? []) {
4101
- const q = joinPaths(m.vfsRoot ?? "", w.vfsPath);
4171
+ const W = joinPaths(m.vfsRoot ?? "", w.vfsPath);
4102
4172
  if (w.type === "directory") {
4103
- i.push(q);
4173
+ i.push(W);
4104
4174
  continue;
4105
4175
  }
4106
4176
  if (!w.sourcePath) continue;
4107
- const Le = new URL(w.sourcePath, L);
4177
+ const Me = new URL(w.sourcePath, M);
4108
4178
  ce.push(
4109
- R.run(() => fetchBytes(e, Le)).then((W) => {
4110
- o[q] = W;
4179
+ b.run(() => fetchBytes(e, Me)).then((q) => {
4180
+ o[W] = q;
4111
4181
  })
4112
4182
  );
4113
4183
  }
4114
- const [U] = await Promise.all([
4115
- fetchBytes(e, new URL(f.sourcePath, L)),
4184
+ const [j] = await Promise.all([
4185
+ fetchBytes(e, new URL(f.sourcePath, M)),
4116
4186
  ...ce
4117
4187
  ]);
4118
- n = U;
4188
+ n = j;
4119
4189
  }
4120
4190
  const u = normalizePath(
4121
4191
  r.extensionDir ?? d ?? PHP_EXTENSIONS_DIR
@@ -5971,6 +6041,7 @@ export {
5971
6041
  consumeAPISync,
5972
6042
  createLegacyPhpIniPreRunStep,
5973
6043
  createObjectPoolProxy,
6044
+ describeError,
5974
6045
  ensurePathPrefix,
5975
6046
  exposeAPI,
5976
6047
  exposeSyncAPI,