@php-wasm/universal 1.0.20 → 1.0.22

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,13 +1,13 @@
1
- var G = (t, e, r) => {
1
+ var V = (t, e, r) => {
2
2
  if (!e.has(t))
3
3
  throw TypeError("Cannot " + r);
4
4
  };
5
- var p = (t, e, r) => (G(t, e, "read from private field"), r ? r.call(t) : e.get(t)), u = (t, e, r) => {
5
+ var c = (t, e, r) => (V(t, e, "read from private field"), r ? r.call(t) : e.get(t)), u = (t, e, r) => {
6
6
  if (e.has(t))
7
7
  throw TypeError("Cannot add the same private member more than once");
8
8
  e instanceof WeakSet ? e.add(t) : e.set(t, r);
9
- }, d = (t, e, r, s) => (G(t, e, "write to private field"), s ? s.call(t, r) : e.set(t, r), r);
10
- var h = (t, e, r) => (G(t, e, "access private method"), r);
9
+ }, d = (t, e, r, s) => (V(t, e, "write to private field"), s ? s.call(t, r) : e.set(t, r), r);
10
+ var h = (t, e, r) => (V(t, e, "access private method"), r);
11
11
  import "@php-wasm/node-polyfills";
12
12
  import { logger } from "@php-wasm/logger";
13
13
  import { dirname, joinPaths, Semaphore, createSpawnHandler, normalizePath, AcquireTimeoutError } from "@php-wasm/util";
@@ -106,8 +106,8 @@ function rethrowFileSystemError(t = "") {
106
106
  } catch (a) {
107
107
  const l = typeof a == "object" ? a == null ? void 0 : a.errno : null;
108
108
  if (l in FileErrorCodes) {
109
- const c = FileErrorCodes[l], v = typeof o[1] == "string" ? o[1] : null, pe = v !== null ? t.replaceAll("{path}", v) : t;
110
- throw new Error(`${pe}: ${c}`, {
109
+ const p = FileErrorCodes[l], v = typeof o[1] == "string" ? o[1] : null, ue = v !== null ? t.replaceAll("{path}", v) : t;
110
+ throw new Error(`${ue}: ${p}`, {
111
111
  cause: a
112
112
  });
113
113
  }
@@ -659,7 +659,7 @@ class PHPExecutionFailureError extends Error {
659
659
  }
660
660
  }
661
661
  const PHP_INI_PATH = "/internal/shared/php.ini", AUTO_PREPEND_SCRIPT = "/internal/shared/auto_prepend_file.php";
662
- var E, g, w, _, y, T, J, I, Y, C, Z, A, K, N, X, M, Q, j, ee, U, te, L, re, q, se, b, V, $, ie, O, ne, B, oe;
662
+ var R, g, w, _, y, x, I, Y, C, Z, A, K, N, X, j, Q, M, ee, U, te, L, re, q, se, $, ie, k, J, O, ne, B, oe, D, ae;
663
663
  class PHP {
664
664
  /**
665
665
  * Initializes a PHP runtime.
@@ -678,26 +678,27 @@ class PHP {
678
678
  * was provided.
679
679
  * @returns Computed $_SERVER entries.
680
680
  */
681
- u(this, T);
682
681
  u(this, I);
683
682
  u(this, C);
684
683
  u(this, A);
685
684
  u(this, N);
686
- u(this, M);
687
685
  u(this, j);
686
+ u(this, M);
688
687
  u(this, U);
689
688
  u(this, L);
690
689
  u(this, q);
691
- u(this, b);
692
690
  u(this, $);
691
+ u(this, k);
693
692
  u(this, O);
694
693
  u(this, B);
695
- u(this, E, void 0);
694
+ u(this, D);
695
+ u(this, R, void 0);
696
696
  u(this, g, void 0);
697
697
  u(this, w, void 0);
698
698
  u(this, _, void 0);
699
699
  u(this, y, void 0);
700
- d(this, g, !1), d(this, w, null), d(this, _, /* @__PURE__ */ new Map()), d(this, y, []), this.semaphore = new Semaphore({ concurrency: 1 }), t !== void 0 && this.initializeRuntime(t);
700
+ u(this, x, void 0);
701
+ d(this, g, !1), d(this, w, null), d(this, _, /* @__PURE__ */ new Map()), d(this, y, []), d(this, x, {}), this.semaphore = new Semaphore({ concurrency: 1 }), t !== void 0 && this.initializeRuntime(t);
701
702
  }
702
703
  /**
703
704
  * Adds an event listener for a PHP event.
@@ -705,7 +706,7 @@ class PHP {
705
706
  * @param listener - The listener function to be called when the event is triggered.
706
707
  */
707
708
  addEventListener(t, e) {
708
- p(this, _).has(t) || p(this, _).set(t, /* @__PURE__ */ new Set()), p(this, _).get(t).add(e);
709
+ c(this, _).has(t) || c(this, _).set(t, /* @__PURE__ */ new Set()), c(this, _).get(t).add(e);
709
710
  }
710
711
  /**
711
712
  * Removes an event listener for a PHP event.
@@ -714,10 +715,10 @@ class PHP {
714
715
  */
715
716
  removeEventListener(t, e) {
716
717
  var r;
717
- (r = p(this, _).get(t)) == null || r.delete(e);
718
+ (r = c(this, _).get(t)) == null || r.delete(e);
718
719
  }
719
720
  dispatchEvent(t) {
720
- const e = p(this, _).get(t.type);
721
+ const e = c(this, _).get(t.type);
721
722
  if (e)
722
723
  for (const r of e)
723
724
  r(t);
@@ -762,8 +763,8 @@ class PHP {
762
763
  * @param listener Callback function to handle the message.
763
764
  */
764
765
  onMessage(t) {
765
- return p(this, y).push(t), async () => {
766
- d(this, y, p(this, y).filter(
766
+ return c(this, y).push(t), async () => {
767
+ d(this, y, c(this, y).filter(
767
768
  (e) => e !== t
768
769
  ));
769
770
  };
@@ -839,7 +840,7 @@ class PHP {
839
840
  }
840
841
  `
841
842
  ), e.onMessage = async (r) => {
842
- for (const s of p(this, y)) {
843
+ for (const s of c(this, y)) {
843
844
  const i = await s(r);
844
845
  if (i)
845
846
  return i;
@@ -860,7 +861,7 @@ class PHP {
860
861
  throw new Error(
861
862
  "Could not set SAPI name. This can only be done before the PHP WASM module is initialized.Did you already dispatch any requests?"
862
863
  );
863
- d(this, E, t);
864
+ d(this, R, t);
864
865
  }
865
866
  /**
866
867
  * Changes the current working directory in the PHP filesystem.
@@ -957,35 +958,35 @@ class PHP {
957
958
  const e = await this.semaphore.acquire();
958
959
  let r;
959
960
  try {
960
- if (p(this, g) || (h(this, I, Y).call(this), d(this, g, !0)), t.scriptPath && !this.fileExists(t.scriptPath))
961
+ if (c(this, g) || (h(this, C, Z).call(this), d(this, g, !0)), t.scriptPath && !this.fileExists(t.scriptPath))
961
962
  throw new Error(
962
963
  `The script path "${t.scriptPath}" does not exist.`
963
964
  );
964
- h(this, A, K).call(this, t.relativeUri || ""), h(this, U, te).call(this, t.method || "GET");
965
- const s = normalizeHeaders(t.headers || {}), i = s.host || "example.com:443", n = h(this, j, ee).call(this, i, t.protocol || "http");
966
- if (h(this, N, X).call(this, i), h(this, M, Q).call(this, n), h(this, L, re).call(this, s), t.body && (r = h(this, q, se).call(this, t.body)), typeof t.code == "string")
967
- this.writeFile("/internal/eval.php", t.code), h(this, b, V).call(this, "/internal/eval.php");
965
+ h(this, N, X).call(this, t.relativeUri || ""), h(this, L, re).call(this, t.method || "GET");
966
+ const s = normalizeHeaders(t.headers || {}), i = s.host || "example.com:443", n = h(this, U, te).call(this, i, t.protocol || "http");
967
+ if (h(this, j, Q).call(this, i), h(this, M, ee).call(this, n), h(this, q, se).call(this, s), t.body && (r = h(this, $, ie).call(this, t.body)), typeof t.code == "string")
968
+ this.writeFile("/internal/eval.php", t.code), h(this, k, J).call(this, "/internal/eval.php");
968
969
  else if (typeof t.scriptPath == "string")
969
- h(this, b, V).call(this, t.scriptPath || "");
970
+ h(this, k, J).call(this, t.scriptPath || "");
970
971
  else
971
972
  throw new TypeError(
972
973
  "The request object must have either a `code` or a `scriptPath` property."
973
974
  );
974
- const o = h(this, T, J).call(this, t.$_SERVER, s, n);
975
- for (const c in o)
976
- h(this, $, ie).call(this, c, o[c]);
975
+ const o = h(this, I, Y).call(this, t.$_SERVER, s, n);
976
+ for (const p in o)
977
+ h(this, O, ne).call(this, p, o[p]);
977
978
  const a = t.env || {};
978
- for (const c in a)
979
- h(this, O, ne).call(this, c, a[c]);
980
- const l = await h(this, B, oe).call(this);
979
+ for (const p in a)
980
+ h(this, B, oe).call(this, p, a[p]);
981
+ const l = await h(this, D, ae).call(this);
981
982
  if (l.exitCode !== 0) {
982
983
  logger.warn("PHP.run() output was:", l.text);
983
- const c = new PHPExecutionFailureError(
984
+ const p = new PHPExecutionFailureError(
984
985
  `PHP.run() failed with exit code ${l.exitCode} and the following output: ` + l.errors,
985
986
  l,
986
987
  "request"
987
988
  );
988
- throw logger.error(c), c;
989
+ throw logger.error(p), p;
989
990
  }
990
991
  return l;
991
992
  } catch (s) {
@@ -1185,13 +1186,17 @@ class PHP {
1185
1186
  * is fully decoupled from the request handler and
1186
1187
  * accepts a constructor-level cwd argument.
1187
1188
  */
1188
- hotSwapPHPRuntime(t, e) {
1189
- const r = this[__private__dont__use].FS;
1189
+ async hotSwapPHPRuntime(t, e) {
1190
+ const r = this[__private__dont__use].FS, s = [];
1191
+ for (const [i, n] of Object.entries(c(this, x)))
1192
+ s.push({ mountHandler: n.mountHandler, vfsPath: i }), await n.unmount();
1190
1193
  try {
1191
1194
  this.exit();
1192
1195
  } catch {
1193
1196
  }
1194
- this.initializeRuntime(t), p(this, E) && this.setSapiName(p(this, E)), e && copyFS(r, this[__private__dont__use].FS, e);
1197
+ this.initializeRuntime(t), c(this, R) && this.setSapiName(c(this, R)), copyFS(r, this[__private__dont__use].FS, "/internal"), e && copyFS(r, this[__private__dont__use].FS, e);
1198
+ for (const { mountHandler: i, vfsPath: n } of s)
1199
+ this.mkdir(n), await this.mount(n, i);
1195
1200
  }
1196
1201
  /**
1197
1202
  * Mounts a filesystem to a given path in the PHP filesystem.
@@ -1201,11 +1206,19 @@ class PHP {
1201
1206
  * @return Unmount function to unmount the filesystem.
1202
1207
  */
1203
1208
  async mount(t, e) {
1204
- return await e(
1209
+ const r = await e(
1205
1210
  this,
1206
1211
  this[__private__dont__use].FS,
1207
1212
  t
1208
- );
1213
+ ), s = {
1214
+ mountHandler: e,
1215
+ unmount: async () => {
1216
+ await r(), delete c(this, x)[t];
1217
+ }
1218
+ };
1219
+ return c(this, x)[t] = s, () => {
1220
+ s.unmount();
1221
+ };
1209
1222
  }
1210
1223
  /**
1211
1224
  * Starts a PHP CLI session with given arguments.
@@ -1263,10 +1276,10 @@ class PHP {
1263
1276
  d(this, g, !1), d(this, w, null), delete this[__private__dont__use].onMessage, delete this[__private__dont__use];
1264
1277
  }
1265
1278
  [Symbol.dispose]() {
1266
- p(this, g) && this.exit(0);
1279
+ c(this, g) && this.exit(0);
1267
1280
  }
1268
1281
  }
1269
- E = new WeakMap(), g = new WeakMap(), w = new WeakMap(), _ = new WeakMap(), y = new WeakMap(), T = new WeakSet(), J = function(t, e, r) {
1282
+ R = new WeakMap(), g = new WeakMap(), w = new WeakMap(), _ = new WeakMap(), y = new WeakMap(), x = new WeakMap(), I = new WeakSet(), Y = function(t, e, r) {
1270
1283
  const s = {
1271
1284
  ...t || {}
1272
1285
  };
@@ -1276,9 +1289,9 @@ E = new WeakMap(), g = new WeakMap(), w = new WeakMap(), _ = new WeakMap(), y =
1276
1289
  ["content-type", "content-length"].includes(i.toLowerCase()) && (n = ""), s[`${n}${i.toUpperCase().replace(/-/g, "_")}`] = e[i];
1277
1290
  }
1278
1291
  return s;
1279
- }, I = new WeakSet(), Y = function() {
1280
- this[__private__dont__use].ccall("php_wasm_init", null, [], []);
1281
1292
  }, C = new WeakSet(), Z = function() {
1293
+ this[__private__dont__use].ccall("php_wasm_init", null, [], []);
1294
+ }, A = new WeakSet(), K = function() {
1282
1295
  const t = "/internal/headers.json";
1283
1296
  if (!this.fileExists(t))
1284
1297
  throw new Error(
@@ -1295,7 +1308,7 @@ E = new WeakMap(), g = new WeakMap(), w = new WeakMap(), _ = new WeakMap(), y =
1295
1308
  headers: r,
1296
1309
  httpStatusCode: e.status
1297
1310
  };
1298
- }, A = new WeakSet(), K = function(t) {
1311
+ }, N = new WeakSet(), X = function(t) {
1299
1312
  if (this[__private__dont__use].ccall(
1300
1313
  "wasm_set_request_uri",
1301
1314
  null,
@@ -1310,35 +1323,35 @@ E = new WeakMap(), g = new WeakMap(), w = new WeakMap(), _ = new WeakMap(), y =
1310
1323
  [e]
1311
1324
  );
1312
1325
  }
1313
- }, N = new WeakSet(), X = function(t) {
1326
+ }, j = new WeakSet(), Q = function(t) {
1314
1327
  this[__private__dont__use].ccall(
1315
1328
  "wasm_set_request_host",
1316
1329
  null,
1317
1330
  [STRING],
1318
1331
  [t]
1319
1332
  );
1320
- }, M = new WeakSet(), Q = function(t) {
1333
+ }, M = new WeakSet(), ee = function(t) {
1321
1334
  this[__private__dont__use].ccall(
1322
1335
  "wasm_set_request_port",
1323
1336
  null,
1324
1337
  [NUMBER],
1325
1338
  [t]
1326
1339
  );
1327
- }, j = new WeakSet(), ee = function(t, e) {
1340
+ }, U = new WeakSet(), te = function(t, e) {
1328
1341
  let r;
1329
1342
  try {
1330
1343
  r = parseInt(new URL(t).port, 10);
1331
1344
  } catch {
1332
1345
  }
1333
1346
  return (!r || isNaN(r) || r === 80) && (r = e === "https" ? 443 : 80), r;
1334
- }, U = new WeakSet(), te = function(t) {
1347
+ }, L = new WeakSet(), re = function(t) {
1335
1348
  this[__private__dont__use].ccall(
1336
1349
  "wasm_set_request_method",
1337
1350
  null,
1338
1351
  [STRING],
1339
1352
  [t]
1340
1353
  );
1341
- }, L = new WeakSet(), re = function(t) {
1354
+ }, q = new WeakSet(), se = function(t) {
1342
1355
  t.cookie && this[__private__dont__use].ccall(
1343
1356
  "wasm_set_cookies",
1344
1357
  null,
@@ -1355,7 +1368,7 @@ E = new WeakMap(), g = new WeakMap(), w = new WeakMap(), _ = new WeakMap(), y =
1355
1368
  [NUMBER],
1356
1369
  [parseInt(t["content-length"], 10)]
1357
1370
  );
1358
- }, q = new WeakSet(), se = function(t) {
1371
+ }, $ = new WeakSet(), ie = function(t) {
1359
1372
  let e, r;
1360
1373
  typeof t == "string" ? (logger.warn(
1361
1374
  "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"
@@ -1378,38 +1391,38 @@ E = new WeakMap(), g = new WeakMap(), w = new WeakMap(), _ = new WeakMap(), y =
1378
1391
  [NUMBER],
1379
1392
  [r]
1380
1393
  ), s;
1381
- }, b = new WeakSet(), V = function(t) {
1394
+ }, k = new WeakSet(), J = function(t) {
1382
1395
  this[__private__dont__use].ccall(
1383
1396
  "wasm_set_path_translated",
1384
1397
  null,
1385
1398
  [STRING],
1386
1399
  [t]
1387
1400
  );
1388
- }, $ = new WeakSet(), ie = function(t, e) {
1401
+ }, O = new WeakSet(), ne = function(t, e) {
1389
1402
  this[__private__dont__use].ccall(
1390
1403
  "wasm_add_SERVER_entry",
1391
1404
  null,
1392
1405
  [STRING, STRING],
1393
1406
  [t, e]
1394
1407
  );
1395
- }, O = new WeakSet(), ne = function(t, e) {
1408
+ }, B = new WeakSet(), oe = function(t, e) {
1396
1409
  this[__private__dont__use].ccall(
1397
1410
  "wasm_add_ENV_entry",
1398
1411
  null,
1399
1412
  [STRING, STRING],
1400
1413
  [t, e]
1401
1414
  );
1402
- }, B = new WeakSet(), oe = async function() {
1415
+ }, D = new WeakSet(), ae = async function() {
1403
1416
  var i;
1404
1417
  let t, e;
1405
1418
  try {
1406
1419
  t = await new Promise((n, o) => {
1407
1420
  var l;
1408
- e = (c) => {
1409
- logger.error(c), logger.error(c.error);
1421
+ e = (p) => {
1422
+ logger.error(p), logger.error(p.error);
1410
1423
  const v = new Error("Rethrown");
1411
- v.cause = c.error, v.betterMessage = c.message, o(v);
1412
- }, (l = p(this, w)) == null || l.addEventListener(
1424
+ v.cause = p.error, v.betterMessage = p.message, o(v);
1425
+ }, (l = c(this, w)) == null || l.addEventListener(
1413
1426
  "error",
1414
1427
  e
1415
1428
  );
@@ -1423,8 +1436,8 @@ E = new WeakMap(), g = new WeakMap(), w = new WeakMap(), _ = new WeakMap(), y =
1423
1436
  return a instanceof Promise ? a.then(n, o) : n(a);
1424
1437
  });
1425
1438
  } catch (n) {
1426
- for (const c in this)
1427
- typeof this[c] == "function" && (this[c] = () => {
1439
+ for (const p in this)
1440
+ typeof this[p] == "function" && (this[p] = () => {
1428
1441
  throw new Error(
1429
1442
  "PHP runtime has crashed – see the earlier error for details."
1430
1443
  );
@@ -1433,9 +1446,9 @@ E = new WeakMap(), g = new WeakMap(), w = new WeakMap(), _ = new WeakMap(), y =
1433
1446
  const o = n, a = "betterMessage" in o ? o.betterMessage : o.message, l = new Error(a);
1434
1447
  throw l.cause = o, logger.error(l), l;
1435
1448
  } finally {
1436
- (i = p(this, w)) == null || i.removeEventListener("error", e);
1449
+ (i = c(this, w)) == null || i.removeEventListener("error", e);
1437
1450
  }
1438
- const { headers: r, httpStatusCode: s } = h(this, C, Z).call(this);
1451
+ const { headers: r, httpStatusCode: s } = h(this, A, K).call(this);
1439
1452
  return new PHPResponse(
1440
1453
  t === 0 ? s : 500,
1441
1454
  r,
@@ -1535,15 +1548,15 @@ async function* iteratePhpFiles(t, e, {
1535
1548
  return;
1536
1549
  const a = await t.listFiles(o);
1537
1550
  for (const l of a) {
1538
- const c = `${o}/${l}`;
1539
- if (i.includes(c.substring(e.length + 1)))
1551
+ const p = `${o}/${l}`;
1552
+ if (i.includes(p.substring(e.length + 1)))
1540
1553
  continue;
1541
- await t.isDir(c) ? n.push(c) : yield new StreamedFile(
1542
- streamReadFileFromPHP(t, c),
1554
+ await t.isDir(p) ? n.push(p) : yield new StreamedFile(
1555
+ streamReadFileFromPHP(t, p),
1543
1556
  r ? joinPaths(
1544
1557
  s || "",
1545
- c.substring(e.length + 1)
1546
- ) : c
1558
+ p.substring(e.length + 1)
1559
+ ) : p
1547
1560
  );
1548
1561
  }
1549
1562
  }
@@ -1673,6 +1686,7 @@ class PHPProcessManager {
1673
1686
  }
1674
1687
  }
1675
1688
  const SupportedPHPVersions = [
1689
+ "8.4",
1676
1690
  "8.3",
1677
1691
  "8.2",
1678
1692
  "8.1",
@@ -1694,16 +1708,16 @@ function ensurePathPrefix(t, e) {
1694
1708
  }
1695
1709
  async function encodeAsMultipart(t) {
1696
1710
  const e = `----${Math.random().toString(36).slice(2)}`, r = `multipart/form-data; boundary=${e}`, s = new TextEncoder(), i = [];
1697
- for (const [l, c] of Object.entries(t))
1711
+ for (const [l, p] of Object.entries(t))
1698
1712
  i.push(`--${e}\r
1699
- `), i.push(`Content-Disposition: form-data; name="${l}"`), c instanceof File && i.push(`; filename="${c.name}"`), i.push(`\r
1700
- `), c instanceof File && (i.push("Content-Type: application/octet-stream"), i.push(`\r
1713
+ `), i.push(`Content-Disposition: form-data; name="${l}"`), p instanceof File && i.push(`; filename="${p.name}"`), i.push(`\r
1714
+ `), p instanceof File && (i.push("Content-Type: application/octet-stream"), i.push(`\r
1701
1715
  `)), i.push(`\r
1702
- `), c instanceof File ? i.push(await fileToUint8Array(c)) : i.push(c), i.push(`\r
1716
+ `), p instanceof File ? i.push(await fileToUint8Array(p)) : i.push(p), i.push(`\r
1703
1717
  `);
1704
1718
  i.push(`--${e}--\r
1705
1719
  `);
1706
- const n = i.reduce((l, c) => l + c.length, 0), o = new Uint8Array(n);
1720
+ const n = i.reduce((l, p) => l + p.length, 0), o = new Uint8Array(n);
1707
1721
  let a = 0;
1708
1722
  for (const l of i)
1709
1723
  o.set(
@@ -1713,12 +1727,7 @@ async function encodeAsMultipart(t) {
1713
1727
  return { bytes: o, contentType: r };
1714
1728
  }
1715
1729
  function fileToUint8Array(t) {
1716
- return new Promise((e) => {
1717
- const r = new FileReader();
1718
- r.onload = () => {
1719
- e(new Uint8Array(r.result));
1720
- }, r.readAsArrayBuffer(t);
1721
- });
1730
+ return t.arrayBuffer().then((e) => new Uint8Array(e));
1722
1731
  }
1723
1732
  const _default = "application/octet-stream", asx = "video/x-ms-asf", atom = "application/atom+xml", avi = "video/x-msvideo", avif = "image/avif", bin = "application/octet-stream", bmp = "image/x-ms-bmp", cco = "application/x-cocoa", css = "text/css", data = "application/octet-stream", deb = "application/octet-stream", der = "application/x-x509-ca-cert", dmg = "application/octet-stream", doc = "application/msword", docx = "application/vnd.openxmlformats-officedocument.wordprocessingml.document", eot = "application/vnd.ms-fontobject", flv = "video/x-flv", gif = "image/gif", gz = "application/gzip", hqx = "application/mac-binhex40", htc = "text/x-component", html = "text/html", ico = "image/x-icon", iso = "application/octet-stream", jad = "text/vnd.sun.j2me.app-descriptor", jar = "application/java-archive", jardiff = "application/x-java-archive-diff", jng = "image/x-jng", jnlp = "application/x-java-jnlp-file", jpg = "image/jpeg", jpeg = "image/jpeg", js = "application/javascript", json = "application/json", kml = "application/vnd.google-earth.kml+xml", kmz = "application/vnd.google-earth.kmz", m3u8 = "application/vnd.apple.mpegurl", m4a = "audio/x-m4a", m4v = "video/x-m4v", md = "text/plain", mid = "audio/midi", mml = "text/mathml", mng = "video/x-mng", mov = "video/quicktime", mp3 = "audio/mpeg", mp4 = "video/mp4", mpeg = "video/mpeg", msi = "application/octet-stream", odg = "application/vnd.oasis.opendocument.graphics", odp = "application/vnd.oasis.opendocument.presentation", ods = "application/vnd.oasis.opendocument.spreadsheet", odt = "application/vnd.oasis.opendocument.text", ogg = "audio/ogg", otf = "font/otf", pdf = "application/pdf", pl = "application/x-perl", png = "image/png", ppt = "application/vnd.ms-powerpoint", pptx = "application/vnd.openxmlformats-officedocument.presentationml.presentation", prc = "application/x-pilot", ps = "application/postscript", ra = "audio/x-realaudio", rar = "application/x-rar-compressed", rpm = "application/x-redhat-package-manager", rss = "application/rss+xml", rtf = "application/rtf", run = "application/x-makeself", sea = "application/x-sea", sit = "application/x-stuffit", svg = "image/svg+xml", swf = "application/x-shockwave-flash", tcl = "application/x-tcl", tar = "application/x-tar", tif = "image/tiff", ts = "video/mp2t", ttf = "font/ttf", txt = "text/plain", wasm = "application/wasm", wbmp = "image/vnd.wap.wbmp", webm = "video/webm", webp = "image/webp", wml = "text/vnd.wap.wml", wmlc = "application/vnd.wap.wmlc", wmv = "video/x-ms-wmv", woff = "font/woff", woff2 = "font/woff2", xhtml = "application/xhtml+xml", xls = "application/vnd.ms-excel", xlsx = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", xml = "text/xml", xpi = "application/x-xpinstall", xspf = "application/xspf+xml", zip = "application/zip", mimeTypes = {
1724
1733
  _default,
@@ -1816,7 +1825,7 @@ const _default = "application/octet-stream", asx = "video/x-ms-asf", atom = "app
1816
1825
  xspf,
1817
1826
  zip
1818
1827
  };
1819
- var P, R, k, x, F, f, S, H, D, ae, z, le, W, ce;
1828
+ var P, F, T, E, S, f, H, b, z, le, W, ce, G, pe;
1820
1829
  class PHPRequestHandler {
1821
1830
  /**
1822
1831
  * The request handler needs to decide whether to serve a static asset or
@@ -1836,11 +1845,11 @@ class PHPRequestHandler {
1836
1845
  * @param fsPath - Absolute path of the static file to serve.
1837
1846
  * @returns The response.
1838
1847
  */
1839
- u(this, D);
1848
+ u(this, z);
1840
1849
  /**
1841
1850
  * Spawns a new PHP instance and dispatches a request to it.
1842
1851
  */
1843
- u(this, z);
1852
+ u(this, W);
1844
1853
  /**
1845
1854
  * Runs the requested PHP file with all the request and $_SERVER
1846
1855
  * superglobals populated.
@@ -1848,15 +1857,15 @@ class PHPRequestHandler {
1848
1857
  * @param request - The request.
1849
1858
  * @returns The response.
1850
1859
  */
1851
- u(this, W);
1860
+ u(this, G);
1852
1861
  u(this, P, void 0);
1853
- u(this, R, void 0);
1854
- u(this, k, void 0);
1855
- u(this, x, void 0);
1856
1862
  u(this, F, void 0);
1857
- u(this, f, void 0);
1863
+ u(this, T, void 0);
1864
+ u(this, E, void 0);
1858
1865
  u(this, S, void 0);
1866
+ u(this, f, void 0);
1859
1867
  u(this, H, void 0);
1868
+ u(this, b, void 0);
1860
1869
  const {
1861
1870
  documentRoot: r = "/www/",
1862
1871
  absoluteUrl: s = typeof location == "object" ? location == null ? void 0 : location.href : "",
@@ -1865,24 +1874,24 @@ class PHPRequestHandler {
1865
1874
  } = e;
1866
1875
  "processManager" in e ? this.processManager = e.processManager : this.processManager = new PHPProcessManager({
1867
1876
  phpFactory: async (l) => {
1868
- const c = await e.phpFactory({
1877
+ const p = await e.phpFactory({
1869
1878
  ...l,
1870
1879
  requestHandler: this
1871
1880
  });
1872
- return c.requestHandler = this, c;
1881
+ return p.requestHandler = this, p;
1873
1882
  },
1874
1883
  maxPhpInstances: e.maxPhpInstances
1875
- }), d(this, H, new HttpCookieStore()), d(this, P, r);
1884
+ }), d(this, b, new HttpCookieStore()), d(this, P, r);
1876
1885
  const o = new URL(s);
1877
- d(this, k, o.hostname), d(this, x, o.port ? Number(o.port) : o.protocol === "https:" ? 443 : 80), d(this, R, (o.protocol || "").replace(":", ""));
1878
- const a = p(this, x) !== 443 && p(this, x) !== 80;
1879
- d(this, F, [
1880
- p(this, k),
1881
- a ? `:${p(this, x)}` : ""
1882
- ].join("")), d(this, f, o.pathname.replace(/\/+$/, "")), d(this, S, [
1883
- `${p(this, R)}://`,
1884
- p(this, F),
1885
- p(this, f)
1886
+ d(this, T, o.hostname), d(this, E, o.port ? Number(o.port) : o.protocol === "https:" ? 443 : 80), d(this, F, (o.protocol || "").replace(":", ""));
1887
+ const a = c(this, E) !== 443 && c(this, E) !== 80;
1888
+ d(this, S, [
1889
+ c(this, T),
1890
+ a ? `:${c(this, E)}` : ""
1891
+ ].join("")), d(this, f, o.pathname.replace(/\/+$/, "")), d(this, H, [
1892
+ `${c(this, F)}://`,
1893
+ c(this, S),
1894
+ c(this, f)
1886
1895
  ].join("")), this.rewriteRules = i, this.getFileNotFoundAction = n;
1887
1896
  }
1888
1897
  async getPrimaryPhp() {
@@ -1907,20 +1916,20 @@ class PHPRequestHandler {
1907
1916
  */
1908
1917
  internalUrlToPath(e) {
1909
1918
  const r = new URL(e);
1910
- return r.pathname.startsWith(p(this, f)) && (r.pathname = r.pathname.slice(p(this, f).length)), toRelativeUrl(r);
1919
+ return r.pathname.startsWith(c(this, f)) && (r.pathname = r.pathname.slice(c(this, f).length)), toRelativeUrl(r);
1911
1920
  }
1912
1921
  /**
1913
1922
  * The absolute URL of this PHPRequestHandler instance.
1914
1923
  */
1915
1924
  get absoluteUrl() {
1916
- return p(this, S);
1925
+ return c(this, H);
1917
1926
  }
1918
1927
  /**
1919
1928
  * The directory in the PHP filesystem where the server will look
1920
1929
  * for the files to serve. Default: `/var/www`.
1921
1930
  */
1922
1931
  get documentRoot() {
1923
- return p(this, P);
1932
+ return c(this, P);
1924
1933
  }
1925
1934
  /**
1926
1935
  * Serves the request – either by serving a static file, or by
@@ -1978,11 +1987,11 @@ class PHPRequestHandler {
1978
1987
  ), i = applyRewriteRules(
1979
1988
  removePathPrefix(
1980
1989
  decodeURIComponent(s.pathname),
1981
- p(this, f)
1990
+ c(this, f)
1982
1991
  ),
1983
1992
  this.rewriteRules
1984
1993
  ), n = await this.getPrimaryPhp();
1985
- let o = joinPaths(p(this, P), i);
1994
+ let o = joinPaths(c(this, P), i);
1986
1995
  if (n.isDir(o)) {
1987
1996
  if (!o.endsWith("/"))
1988
1997
  return new PHPResponse(
@@ -2006,7 +2015,7 @@ class PHPRequestHandler {
2006
2015
  case "response":
2007
2016
  return a.response;
2008
2017
  case "internal-redirect":
2009
- o = joinPaths(p(this, P), a.uri);
2018
+ o = joinPaths(c(this, P), a.uri);
2010
2019
  break;
2011
2020
  case "404":
2012
2021
  return PHPResponse.forHttpCode(404);
@@ -2023,14 +2032,14 @@ class PHPRequestHandler {
2023
2032
  // Pass along URL with the #fragment filtered out
2024
2033
  url: s.toString()
2025
2034
  };
2026
- return h(this, z, le).call(this, a, o);
2035
+ return h(this, W, ce).call(this, a, o);
2027
2036
  } else
2028
- return h(this, D, ae).call(this, n, o);
2037
+ return h(this, z, le).call(this, n, o);
2029
2038
  else
2030
2039
  return PHPResponse.forHttpCode(404);
2031
2040
  }
2032
2041
  }
2033
- P = new WeakMap(), R = new WeakMap(), k = new WeakMap(), x = new WeakMap(), F = new WeakMap(), f = new WeakMap(), S = new WeakMap(), H = new WeakMap(), D = new WeakSet(), ae = function(e, r) {
2042
+ P = new WeakMap(), F = new WeakMap(), T = new WeakMap(), E = new WeakMap(), S = new WeakMap(), f = new WeakMap(), H = new WeakMap(), b = new WeakMap(), z = new WeakSet(), le = function(e, r) {
2034
2043
  const s = e.readFileAsBuffer(r);
2035
2044
  return new PHPResponse(
2036
2045
  200,
@@ -2045,7 +2054,7 @@ P = new WeakMap(), R = new WeakMap(), k = new WeakMap(), x = new WeakMap(), F =
2045
2054
  },
2046
2055
  s
2047
2056
  );
2048
- }, z = new WeakSet(), le = async function(e, r) {
2057
+ }, W = new WeakSet(), ce = async function(e, r) {
2049
2058
  let s;
2050
2059
  try {
2051
2060
  s = await this.processManager.acquirePHPInstance();
@@ -2053,16 +2062,16 @@ P = new WeakMap(), R = new WeakMap(), k = new WeakMap(), x = new WeakMap(), F =
2053
2062
  return i instanceof MaxPhpInstancesError ? PHPResponse.forHttpCode(502) : PHPResponse.forHttpCode(500);
2054
2063
  }
2055
2064
  try {
2056
- return await h(this, W, ce).call(this, s.php, e, r);
2065
+ return await h(this, G, pe).call(this, s.php, e, r);
2057
2066
  } finally {
2058
2067
  s.reap();
2059
2068
  }
2060
- }, W = new WeakSet(), ce = async function(e, r, s) {
2069
+ }, G = new WeakSet(), pe = async function(e, r, s) {
2061
2070
  let i = "GET";
2062
2071
  const n = {
2063
- host: p(this, F),
2072
+ host: c(this, S),
2064
2073
  ...normalizeHeaders(r.headers || {}),
2065
- cookie: p(this, H).getCookieRequestHeader()
2074
+ cookie: c(this, b).getCookieRequestHeader()
2066
2075
  };
2067
2076
  let o = r.body;
2068
2077
  if (typeof o == "object" && !(o instanceof Uint8Array)) {
@@ -2074,20 +2083,20 @@ P = new WeakMap(), R = new WeakMap(), k = new WeakMap(), x = new WeakMap(), F =
2074
2083
  const a = await e.run({
2075
2084
  relativeUri: ensurePathPrefix(
2076
2085
  toRelativeUrl(new URL(r.url)),
2077
- p(this, f)
2086
+ c(this, f)
2078
2087
  ),
2079
- protocol: p(this, R),
2088
+ protocol: c(this, F),
2080
2089
  method: r.method || i,
2081
2090
  $_SERVER: {
2082
2091
  REMOTE_ADDR: "127.0.0.1",
2083
- DOCUMENT_ROOT: p(this, P),
2084
- HTTPS: p(this, S).startsWith("https://") ? "on" : ""
2092
+ DOCUMENT_ROOT: c(this, P),
2093
+ HTTPS: c(this, H).startsWith("https://") ? "on" : ""
2085
2094
  },
2086
2095
  body: o,
2087
2096
  scriptPath: s,
2088
2097
  headers: n
2089
2098
  });
2090
- return p(this, H).rememberCookiesFromResponseHeaders(
2099
+ return c(this, b).rememberCookiesFromResponseHeaders(
2091
2100
  a.headers
2092
2101
  ), a;
2093
2102
  } catch (a) {
@@ -2125,7 +2134,7 @@ function rotatePHPRuntime({
2125
2134
  async function n() {
2126
2135
  const l = await t.semaphore.acquire();
2127
2136
  try {
2128
- t.hotSwapPHPRuntime(await r(), e), i = 0;
2137
+ await t.hotSwapPHPRuntime(await r(), e), i = 0;
2129
2138
  } finally {
2130
2139
  l();
2131
2140
  }