@php-wasm/universal 3.1.20 → 3.1.21

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 J = (r) => {
1
+ var Y = (r) => {
2
2
  throw TypeError(r);
3
3
  };
4
- var W = (r, e, t) => e.has(r) || J("Cannot " + t);
5
- var u = (r, e, t) => (W(r, e, "read from private field"), t ? t.call(r) : e.get(r)), y = (r, e, t) => e.has(r) ? J("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(r) : e.set(r, t), g = (r, e, t, s) => (W(r, e, "write to private field"), s ? s.call(r, t) : e.set(r, t), t), m = (r, e, t) => (W(r, e, "access private method"), t);
4
+ var W = (r, e, t) => e.has(r) || Y("Cannot " + t);
5
+ var u = (r, e, t) => (W(r, e, "read from private field"), t ? t.call(r) : e.get(r)), y = (r, e, t) => e.has(r) ? Y("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(r) : e.set(r, t), g = (r, e, t, s) => (W(r, e, "write to private field"), s ? s.call(r, t) : e.set(r, t), t), m = (r, e, t) => (W(r, e, "access private method"), t);
6
6
  import { logger } from "@php-wasm/logger";
7
7
  import { dirname, joinPaths, Semaphore, createSpawnHandler, basename, normalizePath, AcquireTimeoutError, splitShellCommand } from "@php-wasm/util";
8
8
  import { parse, stringify } from "ini";
@@ -1051,7 +1051,7 @@ class PHPExecutionFailureError extends Error {
1051
1051
  }
1052
1052
  }
1053
1053
  const PHP_INI_PATH = "/internal/shared/php.ini", AUTO_PREPEND_SCRIPT = "/internal/shared/auto_prepend_file.php", OPCACHE_FILE_FOLDER = "/internal/shared/opcache";
1054
- var C, R, b, x, T, H, w, p, Y, X, Q, K, Z, ee, te, re, $, se, q, z;
1054
+ var C, R, b, x, H, T, _, h, J, X, Q, K, Z, ee, te, re, $, se, q, z;
1055
1055
  class PHP {
1056
1056
  /**
1057
1057
  * Initializes a PHP runtime.
@@ -1061,7 +1061,7 @@ class PHP {
1061
1061
  * @param requestHandlerOptions - Optional. Options for the PHPRequestHandler. If undefined, no request handler will be initialized.
1062
1062
  */
1063
1063
  constructor(r) {
1064
- y(this, p);
1064
+ y(this, h);
1065
1065
  y(this, C);
1066
1066
  y(this, R, !1);
1067
1067
  y(this, b, null);
@@ -1069,9 +1069,9 @@ class PHP {
1069
1069
  // Listen to all events
1070
1070
  ["*", /* @__PURE__ */ new Set()]
1071
1071
  ]));
1072
- y(this, T, []);
1073
- y(this, H, {});
1074
- y(this, w, {
1072
+ y(this, H, []);
1073
+ y(this, T, {});
1074
+ y(this, _, {
1075
1075
  enabled: !1,
1076
1076
  recreateRuntime: () => 0,
1077
1077
  needsRotating: !1,
@@ -1079,7 +1079,7 @@ class PHP {
1079
1079
  requestsMade: 0
1080
1080
  });
1081
1081
  this.semaphore = new Semaphore({ concurrency: 1 }), r !== void 0 && this.initializeRuntime(r), this.addEventListener("request.error", (e) => {
1082
- e.source === "php-wasm" && (u(this, w).needsRotating = !0);
1082
+ e.source === "php-wasm" && (u(this, _).needsRotating = !0);
1083
1083
  });
1084
1084
  }
1085
1085
  /**
@@ -1148,8 +1148,8 @@ class PHP {
1148
1148
  * @param listener Callback function to handle the message.
1149
1149
  */
1150
1150
  onMessage(r) {
1151
- return u(this, T).push(r), async () => {
1152
- g(this, T, u(this, T).filter(
1151
+ return u(this, H).push(r), async () => {
1152
+ g(this, H, u(this, H).filter(
1153
1153
  (e) => e !== r
1154
1154
  ));
1155
1155
  };
@@ -1243,7 +1243,7 @@ class PHP {
1243
1243
  }
1244
1244
  `
1245
1245
  ), e.onMessage = async (t) => {
1246
- for (const s of u(this, T)) {
1246
+ for (const s of u(this, H)) {
1247
1247
  const n = await s(t);
1248
1248
  if (n)
1249
1249
  return n;
@@ -1486,7 +1486,7 @@ class PHP {
1486
1486
  async runStream(r) {
1487
1487
  const e = await this.semaphore.acquire();
1488
1488
  let t;
1489
- const s = m(this, p, z).call(this, async () => {
1489
+ const s = m(this, h, z).call(this, async () => {
1490
1490
  if (u(this, R) || (await this[__private__dont__use].ccall(
1491
1491
  "php_wasm_init",
1492
1492
  null,
@@ -1499,22 +1499,22 @@ class PHP {
1499
1499
  throw new Error(
1500
1500
  `The script path "${r.scriptPath}" does not exist.`
1501
1501
  );
1502
- m(this, p, X).call(this, r.relativeUri || ""), m(this, p, ee).call(this, r.method || "GET");
1503
- const i = normalizeHeaders(r.headers || {}), o = i.host || "example.com:443", a = m(this, p, Z).call(this, o, r.protocol || "http");
1504
- if (m(this, p, Q).call(this, o), m(this, p, K).call(this, a), m(this, p, te).call(this, i), r.body && (t = m(this, p, re).call(this, r.body)), typeof r.code == "string")
1505
- this.writeFile("/internal/eval.php", r.code), m(this, p, $).call(this, "/internal/eval.php");
1502
+ m(this, h, X).call(this, r.relativeUri || ""), m(this, h, ee).call(this, r.method || "GET");
1503
+ const i = normalizeHeaders(r.headers || {}), o = i.host || "example.com:443", a = m(this, h, Z).call(this, o, r.protocol || "http");
1504
+ if (m(this, h, Q).call(this, o), m(this, h, K).call(this, a), m(this, h, te).call(this, i), r.body && (t = m(this, h, re).call(this, r.body)), typeof r.code == "string")
1505
+ this.writeFile("/internal/eval.php", r.code), m(this, h, $).call(this, "/internal/eval.php");
1506
1506
  else if (typeof r.scriptPath == "string")
1507
- m(this, p, $).call(this, r.scriptPath || "");
1507
+ m(this, h, $).call(this, r.scriptPath || "");
1508
1508
  else
1509
1509
  throw new TypeError(
1510
1510
  "The request object must have either a `code` or a `scriptPath` property."
1511
1511
  );
1512
- const c = m(this, p, Y).call(this, r.$_SERVER, i, a);
1512
+ const c = m(this, h, J).call(this, r.$_SERVER, i, a);
1513
1513
  for (const d in c)
1514
- m(this, p, se).call(this, d, c[d]);
1514
+ m(this, h, se).call(this, d, c[d]);
1515
1515
  const l = r.env || {};
1516
1516
  for (const d in l)
1517
- m(this, p, q).call(this, d, l[d]);
1517
+ m(this, h, q).call(this, d, l[d]);
1518
1518
  return await this[__private__dont__use].ccall(
1519
1519
  "wasm_sapi_handle_request",
1520
1520
  NUMBER,
@@ -1752,21 +1752,21 @@ class PHP {
1752
1752
  * or an internal crash.
1753
1753
  */
1754
1754
  enableRuntimeRotation(r) {
1755
- g(this, w, {
1756
- ...u(this, w),
1755
+ g(this, _, {
1756
+ ...u(this, _),
1757
1757
  enabled: !0,
1758
1758
  recreateRuntime: r.recreateRuntime,
1759
1759
  maxRequests: r.maxRequests ?? 400
1760
1760
  });
1761
1761
  }
1762
1762
  async rotateRuntime() {
1763
- if (!u(this, w).enabled)
1763
+ if (!u(this, _).enabled)
1764
1764
  throw new Error(
1765
1765
  "Runtime rotation is not enabled. Call enableRuntimeRotation() first."
1766
1766
  );
1767
1767
  await this.hotSwapPHPRuntime(
1768
- await u(this, w).recreateRuntime()
1769
- ), u(this, w).requestsMade = 0, u(this, w).needsRotating = !1;
1768
+ await u(this, _).recreateRuntime()
1769
+ ), u(this, _).requestsMade = 0, u(this, _).needsRotating = !1;
1770
1770
  }
1771
1771
  /**
1772
1772
  * Hot-swaps the PHP runtime for a new one without
@@ -1777,13 +1777,13 @@ class PHP {
1777
1777
  async hotSwapPHPRuntime(r) {
1778
1778
  const e = this[__private__dont__use].FS, t = this.listFiles("/").map((c) => `/${c}`), s = this[__private__dont__use].spawnProcess, n = e.cwd();
1779
1779
  e.chdir("/");
1780
- const i = Object.entries(u(this, H)).map(
1780
+ const i = Object.entries(u(this, T)).map(
1781
1781
  ([c, l]) => ({
1782
1782
  mountHandler: l.mountHandler,
1783
1783
  vfsPath: c
1784
1784
  })
1785
1785
  ), o = Object.values(
1786
- u(this, H)
1786
+ u(this, T)
1787
1787
  ).reverse();
1788
1788
  for (const c of o)
1789
1789
  await c.unmount();
@@ -1823,12 +1823,14 @@ class PHP {
1823
1823
  ), s = {
1824
1824
  mountHandler: e,
1825
1825
  unmount: async () => {
1826
- await t(), delete u(this, H)[r];
1826
+ try {
1827
+ await t();
1828
+ } finally {
1829
+ delete u(this, T)[r];
1830
+ }
1827
1831
  }
1828
1832
  };
1829
- return u(this, H)[r] = s, () => {
1830
- s.unmount();
1831
- };
1833
+ return u(this, T)[r] = s, () => s.unmount();
1832
1834
  }
1833
1835
  /**
1834
1836
  * Starts a PHP CLI session with given arguments.
@@ -1846,12 +1848,12 @@ class PHP {
1846
1848
  async cli(r, e = {}) {
1847
1849
  if (basename(r[0] ?? "") !== "php")
1848
1850
  return this.subProcess(r, e);
1849
- u(this, R) && (u(this, w).needsRotating = !0);
1851
+ u(this, R) && (u(this, _).needsRotating = !0);
1850
1852
  const t = await this.semaphore.acquire();
1851
- return await m(this, p, z).call(this, () => {
1853
+ return await m(this, h, z).call(this, () => {
1852
1854
  const s = e.env || {};
1853
1855
  for (const [n, i] of Object.entries(s))
1854
- m(this, p, q).call(this, n, i);
1856
+ m(this, h, q).call(this, n, i);
1855
1857
  r = [r[0], "-c", PHP_INI_PATH, ...r.slice(1)];
1856
1858
  for (const n of r)
1857
1859
  this[__private__dont__use].ccall(
@@ -1864,7 +1866,7 @@ class PHP {
1864
1866
  async: !0
1865
1867
  });
1866
1868
  }).then((s) => (s.exitCode.finally(t), s)).finally(() => {
1867
- u(this, w).needsRotating = !0;
1869
+ u(this, _).needsRotating = !0;
1868
1870
  });
1869
1871
  }
1870
1872
  /**
@@ -1952,7 +1954,7 @@ class PHP {
1952
1954
  this.exit(0);
1953
1955
  }
1954
1956
  }
1955
- C = new WeakMap(), R = new WeakMap(), b = new WeakMap(), x = new WeakMap(), T = new WeakMap(), H = new WeakMap(), w = new WeakMap(), p = new WeakSet(), /**
1957
+ C = new WeakMap(), R = new WeakMap(), b = new WeakMap(), x = new WeakMap(), H = new WeakMap(), T = new WeakMap(), _ = new WeakMap(), h = new WeakSet(), /**
1956
1958
  * Prepares the $_SERVER entries for the PHP runtime.
1957
1959
  *
1958
1960
  * @param defaults Default entries to include in $_SERVER.
@@ -1961,7 +1963,7 @@ C = new WeakMap(), R = new WeakMap(), b = new WeakMap(), x = new WeakMap(), T =
1961
1963
  * was provided.
1962
1964
  * @returns Computed $_SERVER entries.
1963
1965
  */
1964
- Y = function(r, e, t) {
1966
+ J = function(r, e, t) {
1965
1967
  const s = {
1966
1968
  ...r || {}
1967
1969
  };
@@ -2075,29 +2077,29 @@ Y = function(r, e, t) {
2075
2077
  [r, e]
2076
2078
  );
2077
2079
  }, z = async function(r) {
2078
- 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);
2080
+ u(this, _).enabled && u(this, _).needsRotating && await this.rotateRuntime(), ++u(this, _).requestsMade, u(this, _).requestsMade >= u(this, _).maxRequests && (u(this, _).needsRotating = !0);
2079
2081
  const e = this[__private__dont__use], t = await createInvertedReadableStream();
2080
- e.onHeaders = (h) => {
2081
- a || s || t.controller.enqueue(h.slice());
2082
+ e.onHeaders = (p) => {
2083
+ a || s || t.controller.enqueue(p.slice());
2082
2084
  };
2083
2085
  let s = !1;
2084
2086
  const n = () => {
2085
2087
  s || (s = !0, t.controller.close());
2086
2088
  }, i = await createInvertedReadableStream();
2087
- e.onStdout = (h) => {
2088
- n(), !a && i.controller.enqueue(h.slice());
2089
+ e.onStdout = (p) => {
2090
+ n(), !a && i.controller.enqueue(p.slice());
2089
2091
  };
2090
2092
  const o = await createInvertedReadableStream();
2091
- e.onStderr = (h) => {
2092
- a || o.controller.enqueue(h.slice());
2093
+ e.onStderr = (p) => {
2094
+ a || o.controller.enqueue(p.slice());
2093
2095
  };
2094
2096
  let a = !1, c;
2095
2097
  const d = (async () => {
2096
- var h;
2098
+ var p;
2097
2099
  try {
2098
2100
  return await Promise.race([
2099
2101
  r(),
2100
- new Promise((_, F) => {
2102
+ new Promise((w, F) => {
2101
2103
  var V;
2102
2104
  c = (G) => {
2103
2105
  isExitCode(G.error) || F(G.error);
@@ -2112,35 +2114,35 @@ Y = function(r, e, t) {
2112
2114
  if (isExitCode(f))
2113
2115
  return f.status;
2114
2116
  safeStreamError$1(i.controller, f), safeStreamError$1(o.controller, f), safeStreamError$1(t.controller, f), a = !0;
2115
- for (const _ in this)
2116
- typeof this[_] == "function" && (this[_] = () => {
2117
+ for (const w in this)
2118
+ typeof this[w] == "function" && (this[w] = () => {
2117
2119
  throw new Error(
2118
2120
  "PHP runtime has crashed – see the earlier error for details."
2119
2121
  );
2120
2122
  });
2121
2123
  throw this.functionsMaybeMissingFromAsyncify = getFunctionsMaybeMissingFromAsyncify(), f;
2122
2124
  } finally {
2123
- a || (safeStreamClose$1(i.controller), safeStreamClose$1(o.controller), n(), a = !0), (h = u(this, b)) == null || h.removeEventListener(
2125
+ a || (safeStreamClose$1(i.controller), safeStreamClose$1(o.controller), n(), a = !0), (p = u(this, b)) == null || p.removeEventListener(
2124
2126
  "error",
2125
2127
  c
2126
2128
  );
2127
2129
  }
2128
2130
  })().then(
2129
- (h) => (h !== 0 && this.dispatchEvent({
2131
+ (p) => (p !== 0 && this.dispatchEvent({
2130
2132
  type: "request.error",
2131
2133
  error: new Error(
2132
- `PHP.run() failed with exit code ${h}.`
2134
+ `PHP.run() failed with exit code ${p}.`
2133
2135
  ),
2134
2136
  // Distinguish between PHP request and PHP-wasm errors
2135
2137
  source: "php-wasm"
2136
- }), h),
2137
- (h) => {
2138
- const f = h.source ?? "php-wasm";
2138
+ }), p),
2139
+ (p) => {
2140
+ const f = p.source ?? "php-wasm";
2139
2141
  throw this.dispatchEvent({
2140
2142
  type: "request.error",
2141
- error: h,
2143
+ error: p,
2142
2144
  source: f
2143
- }), h;
2145
+ }), p;
2144
2146
  }
2145
2147
  );
2146
2148
  return new StreamedPHPResponse(
@@ -2159,7 +2161,12 @@ function normalizeHeaders(r) {
2159
2161
  function copyMEMFSNodes(r, e, t) {
2160
2162
  if (getNodeType(r, t) !== "memfs" || !["memfs", "missing"].includes(getNodeType(e, t)))
2161
2163
  return;
2162
- const s = r.lookupPath(t);
2164
+ const s = r.lookupPath(t, { follow: !1 });
2165
+ if (r.isLink(s.node.mode)) {
2166
+ const i = r.readlink(t);
2167
+ e.symlink(i, t);
2168
+ return;
2169
+ }
2163
2170
  if (!r.isDir(s.node.mode)) {
2164
2171
  e.writeFile(t, r.readFile(t));
2165
2172
  return;
@@ -2466,7 +2473,43 @@ const SupportedPHPVersions = [
2466
2473
  "8.1",
2467
2474
  "8.0",
2468
2475
  "7.4"
2469
- ], LatestSupportedPHPVersion = SupportedPHPVersions[0], SupportedPHPVersionsList = SupportedPHPVersions, DEFAULT_BASE_URL = "http://example.com";
2476
+ ], LatestSupportedPHPVersion = SupportedPHPVersions[0], SupportedPHPVersionsList = SupportedPHPVersions, LegacyPHPVersions = ["5.2"];
2477
+ function isLegacyPHPVersion(r) {
2478
+ return LegacyPHPVersions.includes(r ?? "");
2479
+ }
2480
+ const AllPHPVersions = [
2481
+ ...SupportedPHPVersions,
2482
+ ...LegacyPHPVersions
2483
+ ], LEGACY_PHP_INI_PATH = "/internal/shared/php.ini", LEGACY_PHP_INI_CONTENT = [
2484
+ "auto_prepend_file=/internal/shared/auto_prepend_file.php",
2485
+ "memory_limit=256M",
2486
+ "ignore_repeated_errors = 1",
2487
+ "error_reporting = E_ALL",
2488
+ "display_errors = 1",
2489
+ "html_errors = 1",
2490
+ "display_startup_errors = On",
2491
+ "log_errors = 1",
2492
+ "always_populate_raw_post_data = -1",
2493
+ "upload_max_filesize = 2000M",
2494
+ "post_max_size = 2000M",
2495
+ "allow_url_fopen = On",
2496
+ "allow_url_include = Off",
2497
+ "session.save_path = /home/web_user",
2498
+ "implicit_flush = 1",
2499
+ "output_buffering = 0",
2500
+ "max_execution_time = 0",
2501
+ "max_input_time = -1",
2502
+ "disable_functions = ini_get_all",
2503
+ "opcache.enable = 0",
2504
+ "opcache.enable_cli = 0"
2505
+ ].join(`
2506
+ `);
2507
+ function createLegacyPhpIniPreRunStep() {
2508
+ return (r) => {
2509
+ r.FS.mkdirTree("/internal/shared"), r.FS.writeFile(LEGACY_PHP_INI_PATH, LEGACY_PHP_INI_CONTENT);
2510
+ };
2511
+ }
2512
+ const DEFAULT_BASE_URL = "http://example.com";
2470
2513
  function toRelativeUrl(r) {
2471
2514
  return r.origin === "null" ? r.toString() : r.toString().substring(r.origin.length);
2472
2515
  }
@@ -2597,7 +2640,7 @@ const _default = "application/octet-stream", asx = "video/x-ms-asf", atom = "app
2597
2640
  xspf,
2598
2641
  zip
2599
2642
  };
2600
- var S, M, U, L, I, E, A, k, B, P, ne, j, ie, oe, ae;
2643
+ var S, I, U, L, M, E, A, k, j, P, ne, B, ie, oe, ae;
2601
2644
  class PHPRequestHandler {
2602
2645
  /**
2603
2646
  * The request handler needs to decide whether to serve a static asset or
@@ -2613,14 +2656,14 @@ class PHPRequestHandler {
2613
2656
  constructor(e) {
2614
2657
  y(this, P);
2615
2658
  y(this, S);
2616
- y(this, M);
2659
+ y(this, I);
2617
2660
  y(this, U);
2618
2661
  y(this, L);
2619
- y(this, I);
2662
+ y(this, M);
2620
2663
  y(this, E);
2621
2664
  y(this, A);
2622
2665
  y(this, k);
2623
- y(this, B);
2666
+ y(this, j);
2624
2667
  const {
2625
2668
  documentRoot: t = "/www/",
2626
2669
  absoluteUrl: s = typeof location == "object" ? location.href : DEFAULT_BASE_URL,
@@ -2637,11 +2680,11 @@ class PHPRequestHandler {
2637
2680
  else if (e.phpFactory)
2638
2681
  this.instanceManager = new PHPProcessManager({
2639
2682
  phpFactory: async (d) => {
2640
- const h = await e.phpFactory({
2683
+ const p = await e.phpFactory({
2641
2684
  ...d,
2642
2685
  requestHandler: this
2643
2686
  });
2644
- return a(h), h;
2687
+ return a(p), p;
2645
2688
  },
2646
2689
  maxPhpInstances: e.maxPhpInstances
2647
2690
  });
@@ -2651,16 +2694,16 @@ class PHPRequestHandler {
2651
2694
  );
2652
2695
  g(this, k, e.cookieStore === void 0 ? new HttpCookieStore() : e.cookieStore), g(this, S, t);
2653
2696
  const c = new URL(s);
2654
- g(this, U, c.hostname), g(this, L, c.port ? Number(c.port) : c.protocol === "https:" ? 443 : 80), g(this, M, (c.protocol || "").replace(":", ""));
2697
+ g(this, U, c.hostname), g(this, L, c.port ? Number(c.port) : c.protocol === "https:" ? 443 : 80), g(this, I, (c.protocol || "").replace(":", ""));
2655
2698
  const l = u(this, L) !== 443 && u(this, L) !== 80;
2656
- g(this, I, [
2699
+ g(this, M, [
2657
2700
  u(this, U),
2658
2701
  l ? `:${u(this, L)}` : ""
2659
2702
  ].join("")), g(this, E, c.pathname.replace(/\/+$/, "")), g(this, A, [
2660
- `${u(this, M)}://`,
2661
- u(this, I),
2703
+ `${u(this, I)}://`,
2704
+ u(this, M),
2662
2705
  u(this, E)
2663
- ].join("")), this.rewriteRules = n, g(this, B, i), this.getFileNotFoundAction = o;
2706
+ ].join("")), this.rewriteRules = n, g(this, j, i), this.getFileNotFoundAction = o;
2664
2707
  }
2665
2708
  async getPrimaryPhp() {
2666
2709
  return await this.instanceManager.getPrimaryPhp();
@@ -2781,7 +2824,7 @@ class PHPRequestHandler {
2781
2824
  decodeURIComponent(n.pathname),
2782
2825
  u(this, E)
2783
2826
  );
2784
- let a = m(this, P, j).call(this, o);
2827
+ let a = m(this, P, B).call(this, o);
2785
2828
  if (i.isDir(a)) {
2786
2829
  if (!o.endsWith("/"))
2787
2830
  return StreamedPHPResponse.fromPHPResponse(
@@ -2806,10 +2849,10 @@ class PHPRequestHandler {
2806
2849
  let c = o;
2807
2850
  for (; c.startsWith("/") && c !== dirname(c); ) {
2808
2851
  c = dirname(c);
2809
- const l = m(this, P, j).call(this, c);
2852
+ const l = m(this, P, B).call(this, c);
2810
2853
  if (i.isFile(l) && // Only run partial path resolution for PHP files.
2811
2854
  l.endsWith(".php")) {
2812
- a = m(this, P, j).call(this, c);
2855
+ a = m(this, P, B).call(this, c);
2813
2856
  break;
2814
2857
  }
2815
2858
  }
@@ -2945,7 +2988,7 @@ class PHPRequestHandler {
2945
2988
  await this.instanceManager[Symbol.asyncDispose]();
2946
2989
  }
2947
2990
  }
2948
- S = new WeakMap(), M = new WeakMap(), U = new WeakMap(), L = new WeakMap(), I = new WeakMap(), E = new WeakMap(), A = new WeakMap(), k = new WeakMap(), B = new WeakMap(), P = new WeakSet(), /**
2991
+ S = new WeakMap(), I = new WeakMap(), U = new WeakMap(), L = new WeakMap(), M = new WeakMap(), E = new WeakMap(), A = new WeakMap(), k = new WeakMap(), j = new WeakMap(), P = new WeakSet(), /**
2949
2992
  * Apply the rewrite rules to the original request URL.
2950
2993
  *
2951
2994
  * @param originalRequestUrl - The original request URL.
@@ -2974,8 +3017,8 @@ ne = function(e) {
2974
3017
  * @param urlPath - The URL path to resolve (e.g., '/phpmyadmin/index.php')
2975
3018
  * @returns The resolved filesystem path
2976
3019
  */
2977
- j = function(e) {
2978
- for (const t of u(this, B))
3020
+ B = function(e) {
3021
+ for (const t of u(this, j))
2979
3022
  if (e === t.urlPrefix || e.startsWith(t.urlPrefix + "/")) {
2980
3023
  const s = e.slice(t.urlPrefix.length);
2981
3024
  return joinPaths(t.fsPath, s);
@@ -3021,22 +3064,22 @@ ie = function(e, t) {
3021
3064
  }, ae = async function(e, t, s, n, i) {
3022
3065
  let o = "GET";
3023
3066
  const a = {
3024
- host: u(this, I),
3067
+ host: u(this, M),
3025
3068
  ...normalizeHeaders(t.headers || {})
3026
3069
  };
3027
3070
  u(this, k) && (a.cookie = u(this, k).getCookieRequestHeader());
3028
3071
  let c = t.body;
3029
3072
  if (typeof c == "object" && !(c instanceof Uint8Array)) {
3030
3073
  o = "POST";
3031
- const { bytes: d, contentType: h } = await encodeAsMultipart(c);
3032
- c = d, a["content-type"] = h;
3074
+ const { bytes: d, contentType: p } = await encodeAsMultipart(c);
3075
+ c = d, a["content-type"] = p;
3033
3076
  }
3034
3077
  const l = await e.runStream({
3035
3078
  relativeUri: ensurePathPrefix(
3036
3079
  toRelativeUrl(new URL(n.toString())),
3037
3080
  u(this, E)
3038
3081
  ),
3039
- protocol: u(this, M),
3082
+ protocol: u(this, I),
3040
3083
  method: t.method || o,
3041
3084
  $_SERVER: this.prepare_$_SERVER_superglobal(
3042
3085
  s,
@@ -3091,6 +3134,11 @@ async function writeFiles(r, e, t, { rmRoot: s = !1 } = {}) {
3091
3134
  await r.fileExists(dirname(o)) || await r.mkdir(dirname(o)), i instanceof Uint8Array || typeof i == "string" ? await r.writeFile(o, i) : await writeFiles(r, o, i);
3092
3135
  }
3093
3136
  }
3137
+ function isLegacyPhpInstance(r) {
3138
+ var n;
3139
+ const e = Object.getOwnPropertySymbols(r)[0], t = r[e], s = (n = t == null ? void 0 : t.phpVersion) == null ? void 0 : n.major;
3140
+ return typeof s == "number" && s < 7;
3141
+ }
3094
3142
  function ensureProxyFSHasMmapSupport(r) {
3095
3143
  const e = Object.getOwnPropertySymbols(r)[0], t = r[e], s = t.PROXYFS, n = t.FS;
3096
3144
  s.stream_ops.mmap || (s.stream_ops.mmap = function(i, o, a, c, l) {
@@ -3101,18 +3149,18 @@ function ensureProxyFSHasMmapSupport(r) {
3101
3149
  const d = t.malloc(o);
3102
3150
  if (!d)
3103
3151
  throw new n.ErrnoError(48);
3104
- const h = t.HEAPU8.subarray(d, d + o);
3152
+ const p = t.HEAPU8.subarray(d, d + o);
3105
3153
  let f = 0;
3106
3154
  for (; f < o; ) {
3107
- const _ = i.stream_ops.read(
3155
+ const w = i.stream_ops.read(
3108
3156
  i,
3109
- h,
3157
+ p,
3110
3158
  f,
3111
3159
  o - f,
3112
3160
  f
3113
3161
  );
3114
- if (_ <= 0) break;
3115
- f += _;
3162
+ if (w <= 0) break;
3163
+ f += w;
3116
3164
  }
3117
3165
  if (f !== o)
3118
3166
  throw t.free(d), new n.ErrnoError(5);
@@ -3129,23 +3177,23 @@ function ensureProxyFSHasMmapSupport(r) {
3129
3177
  });
3130
3178
  }
3131
3179
  async function proxyFileSystem(r, e, t) {
3132
- const s = Object.getOwnPropertySymbols(r)[0];
3133
- for (const n of t)
3134
- r.fileExists(n) || r.mkdir(n), e.mkdir(n), await e.mount(n, (i) => {
3135
- ensureProxyFSHasMmapSupport(i);
3136
- const o = Object.getOwnPropertySymbols(i)[0];
3137
- return i[o].FS.mount(
3180
+ const s = isLegacyPhpInstance(e), n = Object.getOwnPropertySymbols(r)[0];
3181
+ for (const i of t)
3182
+ r.fileExists(i) || r.mkdir(i), e.mkdir(i), await e.mount(i, (o) => {
3183
+ s || ensureProxyFSHasMmapSupport(o);
3184
+ const a = Object.getOwnPropertySymbols(o)[0];
3185
+ return o[a].FS.mount(
3138
3186
  // @ts-ignore
3139
- i[o].PROXYFS,
3187
+ o[a].PROXYFS,
3140
3188
  {
3141
- root: n,
3189
+ root: i,
3142
3190
  // @ts-ignore
3143
- fs: r[s].FS
3191
+ fs: r[n].FS
3144
3192
  },
3145
- n
3193
+ i
3146
3194
  ), () => {
3147
3195
  try {
3148
- i[o].FS.unmount(n);
3196
+ o[a].FS.unmount(i);
3149
3197
  } catch {
3150
3198
  }
3151
3199
  };
@@ -3407,29 +3455,29 @@ function expose(r, e = globalThis, t = ["*"], s) {
3407
3455
  }, l = (i.data.argumentList || []).map(fromWireValue);
3408
3456
  let d;
3409
3457
  try {
3410
- const h = c.slice(0, -1).reduce((_, F) => _[F], r), f = c.reduce((_, F) => _[F], r);
3458
+ const p = c.slice(0, -1).reduce((w, F) => w[F], r), f = c.reduce((w, F) => w[F], r);
3411
3459
  switch (a) {
3412
3460
  case MessageType.GET:
3413
3461
  d = f;
3414
3462
  break;
3415
3463
  case MessageType.SET:
3416
- h[c.slice(-1)[0]] = fromWireValue(
3464
+ p[c.slice(-1)[0]] = fromWireValue(
3417
3465
  i.data.value
3418
3466
  ), d = !0;
3419
3467
  break;
3420
3468
  case MessageType.APPLY:
3421
- d = f.apply(h, l);
3469
+ d = f.apply(p, l);
3422
3470
  break;
3423
3471
  case MessageType.CONSTRUCT:
3424
3472
  {
3425
- const _ = new f(...l);
3426
- d = proxy(_);
3473
+ const w = new f(...l);
3474
+ d = proxy(w);
3427
3475
  }
3428
3476
  break;
3429
3477
  case MessageType.ENDPOINT:
3430
3478
  {
3431
- const { port1: _, port2: F } = new MessageChannel();
3432
- expose(r, F), d = transfer(_, [_]);
3479
+ const { port1: w, port2: F } = new MessageChannel();
3480
+ expose(r, F), d = transfer(w, [w]);
3433
3481
  }
3434
3482
  break;
3435
3483
  case MessageType.RELEASE:
@@ -3438,18 +3486,18 @@ function expose(r, e = globalThis, t = ["*"], s) {
3438
3486
  default:
3439
3487
  return;
3440
3488
  }
3441
- } catch (h) {
3442
- d = { value: h, [throwMarker]: 0 };
3489
+ } catch (p) {
3490
+ d = { value: p, [throwMarker]: 0 };
3443
3491
  }
3444
- Promise.resolve(d).catch((h) => ({ value: h, [throwMarker]: 0 })).then((h) => {
3445
- const [f, _] = toWireValue(h);
3446
- e.postMessage({ ...f, id: o }, _), a === MessageType.RELEASE && (e.removeEventListener("message", n), closeEndPoint(e), finalizer in r && typeof r[finalizer] == "function" && r[finalizer]());
3492
+ Promise.resolve(d).catch((p) => ({ value: p, [throwMarker]: 0 })).then((p) => {
3493
+ const [f, w] = toWireValue(p);
3494
+ e.postMessage({ ...f, id: o }, w), a === MessageType.RELEASE && (e.removeEventListener("message", n), closeEndPoint(e), finalizer in r && typeof r[finalizer] == "function" && r[finalizer]());
3447
3495
  }).catch(() => {
3448
- const [h, f] = toWireValue({
3496
+ const [p, f] = toWireValue({
3449
3497
  value: new TypeError("Unserializable return value"),
3450
3498
  [throwMarker]: 0
3451
3499
  });
3452
- e.postMessage({ ...h, id: o }, f);
3500
+ e.postMessage({ ...p, id: o }, f);
3453
3501
  }).finally(() => {
3454
3502
  s == null || s(i);
3455
3503
  });
@@ -3526,7 +3574,7 @@ function createProxy(r, e, t = [], s = function() {
3526
3574
  e,
3527
3575
  {
3528
3576
  type: MessageType.SET,
3529
- path: [...t, a].map((h) => h.toString()),
3577
+ path: [...t, a].map((p) => p.toString()),
3530
3578
  value: l
3531
3579
  },
3532
3580
  d
@@ -3541,7 +3589,7 @@ function createProxy(r, e, t = [], s = function() {
3541
3589
  }).then(fromWireValue);
3542
3590
  if (l === "bind")
3543
3591
  return createProxy(r, e, t.slice(0, -1));
3544
- const [d, h] = processArguments(c);
3592
+ const [d, p] = processArguments(c);
3545
3593
  return requestResponseMessage(
3546
3594
  r,
3547
3595
  e,
@@ -3550,7 +3598,7 @@ function createProxy(r, e, t = [], s = function() {
3550
3598
  path: t.map((f) => f.toString()),
3551
3599
  argumentList: d
3552
3600
  },
3553
- h
3601
+ p
3554
3602
  ).then(fromWireValue);
3555
3603
  },
3556
3604
  construct(o, a) {
@@ -4756,13 +4804,13 @@ function createObjectPoolProxy(r) {
4756
4804
  return new Proxy(function() {
4757
4805
  }, {
4758
4806
  apply(c, l, d) {
4759
- return i((h) => h[a](...d));
4807
+ return i((p) => p[a](...d));
4760
4808
  },
4761
4809
  get(c, l) {
4762
4810
  if (l === "then")
4763
- return (d, h) => i((f) => f[a]).then(
4811
+ return (d, p) => i((f) => f[a]).then(
4764
4812
  d,
4765
- h
4813
+ p
4766
4814
  );
4767
4815
  }
4768
4816
  });
@@ -4790,6 +4838,7 @@ class ProcessIdAllocator {
4790
4838
  }
4791
4839
  }
4792
4840
  export {
4841
+ AllPHPVersions,
4793
4842
  DEFAULT_BASE_URL,
4794
4843
  FSHelpers,
4795
4844
  FileLock,
@@ -4797,7 +4846,10 @@ export {
4797
4846
  FileLockManagerComposite,
4798
4847
  FileLockManagerInMemory,
4799
4848
  HttpCookieStore,
4849
+ LEGACY_PHP_INI_CONTENT,
4850
+ LEGACY_PHP_INI_PATH,
4800
4851
  LatestSupportedPHPVersion,
4852
+ LegacyPHPVersions,
4801
4853
  MAX_ADDRESSABLE_FILE_OFFSET,
4802
4854
  PHP,
4803
4855
  PHPExecutionFailureError,
@@ -4815,6 +4867,7 @@ export {
4815
4867
  applyRewriteRules,
4816
4868
  consumeAPI,
4817
4869
  consumeAPISync,
4870
+ createLegacyPhpIniPreRunStep,
4818
4871
  createObjectPoolProxy,
4819
4872
  ensurePathPrefix,
4820
4873
  exposeAPI,
@@ -4822,6 +4875,7 @@ export {
4822
4875
  getPhpIniEntries,
4823
4876
  inferMimeType,
4824
4877
  isExitCode,
4878
+ isLegacyPHPVersion,
4825
4879
  isPathToSharedFS,
4826
4880
  iteratePhpFiles as iterateFiles,
4827
4881
  loadPHPRuntime,