@php-wasm/universal 3.0.6 → 3.0.8

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
@@ -2,10 +2,10 @@ var z = (t) => {
2
2
  throw TypeError(t);
3
3
  };
4
4
  var O = (t, e, r) => e.has(t) || z("Cannot " + r);
5
- var u = (t, e, r) => (O(t, e, "read from private field"), r ? r.call(t) : e.get(t)), m = (t, e, r) => e.has(t) ? z("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, r), g = (t, e, r, s) => (O(t, e, "write to private field"), s ? s.call(t, r) : e.set(t, r), r), y = (t, e, r) => (O(t, e, "access private method"), r);
5
+ var u = (t, e, r) => (O(t, e, "read from private field"), r ? r.call(t) : e.get(t)), m = (t, e, r) => e.has(t) ? z("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, r), w = (t, e, r, s) => (O(t, e, "write to private field"), s ? s.call(t, r) : e.set(t, r), r), y = (t, e, r) => (O(t, e, "access private method"), r);
6
6
  import "@php-wasm/node-polyfills";
7
7
  import { logger } from "@php-wasm/logger";
8
- import { dirname, joinPaths, Semaphore, createSpawnHandler, normalizePath, AcquireTimeoutError } from "@php-wasm/util";
8
+ import { dirname, joinPaths, Semaphore, createSpawnHandler, basename, normalizePath, AcquireTimeoutError } from "@php-wasm/util";
9
9
  import { parse, stringify } from "ini";
10
10
  import { StreamedFile } from "@php-wasm/stream-compression";
11
11
  class ErrnoError extends Error {
@@ -368,12 +368,12 @@ class PHPWorker {
368
368
  /** @inheritDoc */
369
369
  constructor(e, r) {
370
370
  m(this, P);
371
- this.absoluteUrl = "", this.documentRoot = "", g(this, P, /* @__PURE__ */ new Map()), this.onMessageListeners = [], _private.set(this, {
371
+ this.absoluteUrl = "", this.documentRoot = "", this.chroot = null, w(this, P, /* @__PURE__ */ new Map()), this.onMessageListeners = [], _private.set(this, {
372
372
  monitor: r
373
373
  }), e && this.__internal_setRequestHandler(e);
374
374
  }
375
375
  __internal_setRequestHandler(e) {
376
- this.absoluteUrl = e.absoluteUrl, this.documentRoot = e.documentRoot, _private.set(this, {
376
+ this.absoluteUrl = e.absoluteUrl, this.documentRoot = e.documentRoot, this.chroot = this.documentRoot, _private.set(this, {
377
377
  ..._private.get(this),
378
378
  requestHandler: e
379
379
  });
@@ -433,7 +433,7 @@ class PHPWorker {
433
433
  }
434
434
  /** @inheritDoc @php-wasm/universal!/PHP.run */
435
435
  async run(e) {
436
- const { php: r, reap: s } = await _private.get(this).requestHandler.processManager.acquirePHPInstance();
436
+ const { php: r, reap: s } = await this.acquirePHPInstance();
437
437
  try {
438
438
  return await r.run(e);
439
439
  } finally {
@@ -442,16 +442,29 @@ class PHPWorker {
442
442
  }
443
443
  /** @inheritDoc @php-wasm/universal!/PHP.cli */
444
444
  async cli(e, r) {
445
- const { php: s, reap: n } = await _private.get(this).requestHandler.processManager.acquirePHPInstance();
445
+ const { php: s, reap: n } = await this.acquirePHPInstance();
446
+ let i;
446
447
  try {
447
- return await s.cli(e, r);
448
- } finally {
449
- n();
448
+ i = await s.cli(e, r);
449
+ } catch (o) {
450
+ throw n(), o;
450
451
  }
452
+ return i.finished.finally(n), i;
451
453
  }
452
454
  /** @inheritDoc @php-wasm/universal!/PHP.chdir */
453
455
  chdir(e) {
454
- return _private.get(this).php.chdir(e);
456
+ return this.chroot = e, _private.get(this).php.chdir(e);
457
+ }
458
+ /** @inheritDoc @php-wasm/universal!/PHP.chdir */
459
+ cwd() {
460
+ return _private.get(this).php.cwd();
461
+ }
462
+ /**
463
+ * @returns A PHP instance with a consistent chroot.
464
+ */
465
+ async acquirePHPInstance() {
466
+ const { php: e, reap: r } = await _private.get(this).requestHandler.processManager.acquirePHPInstance();
467
+ return this.chroot !== null && e.chdir(this.chroot), this.registerWorkerListeners(e), { php: e, reap: r };
455
468
  }
456
469
  /** @inheritDoc @php-wasm/universal!/PHP.setSapiName */
457
470
  setSapiName(e) {
@@ -937,7 +950,7 @@ class PHPExecutionFailureError extends Error {
937
950
  }
938
951
  }
939
952
  const PHP_INI_PATH = "/internal/shared/php.ini", AUTO_PREPEND_SCRIPT = "/internal/shared/auto_prepend_file.php", OPCACHE_FILE_FOLDER = "/internal/shared/opcache";
940
- var C, b, T, E, F, M, _, h, B, $, V, G, J, Y, K, X, U, Q, j, q;
953
+ var C, H, T, E, F, M, _, h, B, $, V, G, J, Y, K, X, U, Q, q, D;
941
954
  class PHP {
942
955
  /**
943
956
  * Initializes a PHP runtime.
@@ -949,7 +962,7 @@ class PHP {
949
962
  constructor(t) {
950
963
  m(this, h);
951
964
  m(this, C);
952
- m(this, b, !1);
965
+ m(this, H, !1);
953
966
  m(this, T, null);
954
967
  m(this, E, /* @__PURE__ */ new Map([
955
968
  // Listen to all events
@@ -1035,7 +1048,7 @@ class PHP {
1035
1048
  */
1036
1049
  onMessage(t) {
1037
1050
  return u(this, F).push(t), async () => {
1038
- g(this, F, u(this, F).filter(
1051
+ w(this, F, u(this, F).filter(
1039
1052
  (e) => e !== t
1040
1053
  ));
1041
1054
  };
@@ -1135,7 +1148,7 @@ class PHP {
1135
1148
  return n;
1136
1149
  }
1137
1150
  return "";
1138
- }, g(this, T, improveWASMErrorReporting(e)), this.dispatchEvent({
1151
+ }, w(this, T, improveWASMErrorReporting(e)), this.dispatchEvent({
1139
1152
  type: "runtime.initialized"
1140
1153
  });
1141
1154
  }
@@ -1150,7 +1163,7 @@ class PHP {
1150
1163
  throw new Error(
1151
1164
  "Could not set SAPI name. This can only be done before the PHP WASM module is initialized.Did you already dispatch any requests?"
1152
1165
  );
1153
- g(this, C, t);
1166
+ w(this, C, t);
1154
1167
  }
1155
1168
  /**
1156
1169
  * Changes the current working directory in the PHP filesystem.
@@ -1163,6 +1176,14 @@ class PHP {
1163
1176
  chdir(t) {
1164
1177
  this[__private__dont__use].FS.chdir(t);
1165
1178
  }
1179
+ /**
1180
+ * Gets the current working directory in the PHP filesystem.
1181
+ *
1182
+ * @returns The current working directory.
1183
+ */
1184
+ cwd() {
1185
+ return this[__private__dont__use].FS.cwd();
1186
+ }
1166
1187
  /**
1167
1188
  * Changes the permissions of a file or directory.
1168
1189
  * @param path - The path to the file or directory.
@@ -1366,8 +1387,8 @@ class PHP {
1366
1387
  async runStream(t) {
1367
1388
  const e = await this.semaphore.acquire();
1368
1389
  let r;
1369
- const s = y(this, h, q).call(this, async () => {
1370
- if (u(this, b) || (await this[__private__dont__use].ccall(
1390
+ const s = y(this, h, D).call(this, async () => {
1391
+ if (u(this, H) || (await this[__private__dont__use].ccall(
1371
1392
  "php_wasm_init",
1372
1393
  null,
1373
1394
  [],
@@ -1375,7 +1396,7 @@ class PHP {
1375
1396
  {
1376
1397
  isAsync: !0
1377
1398
  }
1378
- ), g(this, b, !0)), t.scriptPath && !this.fileExists(t.scriptPath))
1399
+ ), w(this, H, !0)), t.scriptPath && !this.fileExists(t.scriptPath))
1379
1400
  throw new Error(
1380
1401
  `The script path "${t.scriptPath}" does not exist.`
1381
1402
  );
@@ -1394,7 +1415,7 @@ class PHP {
1394
1415
  y(this, h, Q).call(this, d, c[d]);
1395
1416
  const l = t.env || {};
1396
1417
  for (const d in l)
1397
- y(this, h, j).call(this, d, l[d]);
1418
+ y(this, h, q).call(this, d, l[d]);
1398
1419
  return await this[__private__dont__use].ccall(
1399
1420
  "wasm_sapi_handle_request",
1400
1421
  NUMBER,
@@ -1600,12 +1621,11 @@ class PHP {
1600
1621
  * or an internal crash.
1601
1622
  */
1602
1623
  enableRuntimeRotation(t) {
1603
- g(this, _, {
1624
+ w(this, _, {
1604
1625
  ...u(this, _),
1605
1626
  enabled: !0,
1606
1627
  recreateRuntime: t.recreateRuntime,
1607
- maxRequests: t.maxRequests ?? 400,
1608
- cwd: t.cwd
1628
+ maxRequests: t.maxRequests ?? 400
1609
1629
  });
1610
1630
  }
1611
1631
  async rotateRuntime() {
@@ -1624,19 +1644,31 @@ class PHP {
1624
1644
  * @param runtime
1625
1645
  */
1626
1646
  async hotSwapPHPRuntime(t) {
1627
- const e = this[__private__dont__use].FS, r = this.listFiles("/").map((o) => `/${o}`), s = this[__private__dont__use].spawnProcess, n = [];
1628
- for (const [o, a] of Object.entries(u(this, M)))
1629
- n.push({ mountHandler: a.mountHandler, vfsPath: o }), await a.unmount();
1647
+ const e = this[__private__dont__use].FS, r = this.listFiles("/").map((a) => `/${a}`), s = this[__private__dont__use].spawnProcess, n = e.cwd();
1648
+ e.chdir("/");
1649
+ const i = [];
1650
+ for (const [a, c] of Object.entries(u(this, M)))
1651
+ i.push({ mountHandler: c.mountHandler, vfsPath: a }), await c.unmount();
1630
1652
  try {
1631
1653
  this.exit();
1632
1654
  } catch {
1633
1655
  }
1634
1656
  this.initializeRuntime(t), s && (this[__private__dont__use].spawnProcess = s), u(this, C) && this.setSapiName(u(this, C));
1635
- const i = this[__private__dont__use].FS;
1636
- for (const o of r)
1637
- o && o !== "/request" && copyMEMFSNodes(e, i, o);
1638
- for (const { mountHandler: o, vfsPath: a } of n)
1639
- this.mkdir(a), await this.mount(a, o);
1657
+ const o = this[__private__dont__use].FS;
1658
+ for (const a of r)
1659
+ a && a !== "/request" && copyMEMFSNodes(e, o, a);
1660
+ for (const { mountHandler: a, vfsPath: c } of i)
1661
+ this.mkdir(c), await this.mount(c, a);
1662
+ try {
1663
+ o.chdir(n);
1664
+ } catch (a) {
1665
+ throw new Error(
1666
+ `Failed to restore CWD to ${n} after PHP runtime rotation.`,
1667
+ {
1668
+ cause: a
1669
+ }
1670
+ );
1671
+ }
1640
1672
  }
1641
1673
  /**
1642
1674
  * Mounts a filesystem to a given path in the PHP filesystem.
@@ -1674,12 +1706,14 @@ class PHP {
1674
1706
  * @returns The exit code of the CLI session.
1675
1707
  */
1676
1708
  async cli(t, e = {}) {
1677
- u(this, b) && (u(this, _).needsRotating = !0);
1709
+ if (basename(t[0] ?? "") !== "php")
1710
+ return this.subProcess(t, e);
1711
+ u(this, H) && (u(this, _).needsRotating = !0);
1678
1712
  const r = await this.semaphore.acquire();
1679
- return await y(this, h, q).call(this, () => {
1713
+ return await y(this, h, D).call(this, () => {
1680
1714
  const s = e.env || {};
1681
1715
  for (const [n, i] of Object.entries(s))
1682
- y(this, h, j).call(this, n, i);
1716
+ y(this, h, q).call(this, n, i);
1683
1717
  t = [t[0], "-c", PHP_INI_PATH, ...t.slice(1)];
1684
1718
  for (const n of t)
1685
1719
  this[__private__dont__use].ccall(
@@ -1695,6 +1729,59 @@ class PHP {
1695
1729
  u(this, _).needsRotating = !0;
1696
1730
  });
1697
1731
  }
1732
+ /**
1733
+ * Runs an arbitrary CLI command using the spawn handler associated
1734
+ * with this PHP instance.
1735
+ *
1736
+ * @param argv
1737
+ * @param options
1738
+ * @returns StreamedPHPResponse.
1739
+ */
1740
+ async subProcess(t, e = {}) {
1741
+ const r = this[__private__dont__use].spawnProcess(
1742
+ t[0],
1743
+ t.slice(1),
1744
+ {
1745
+ env: e.env,
1746
+ cwd: e.cwd ?? this.cwd()
1747
+ }
1748
+ ), s = await createInvertedReadableStream();
1749
+ r.on("error", (i) => {
1750
+ s.controller.error(i);
1751
+ }), r.stderr.on("data", (i) => {
1752
+ s.controller.enqueue(i);
1753
+ });
1754
+ const n = await createInvertedReadableStream();
1755
+ return r.stdout.on("data", (i) => {
1756
+ n.controller.enqueue(i);
1757
+ }), r.on("exit", () => {
1758
+ setTimeout(() => {
1759
+ try {
1760
+ s.controller.close();
1761
+ } catch {
1762
+ }
1763
+ try {
1764
+ n.controller.close();
1765
+ } catch {
1766
+ }
1767
+ }, 0);
1768
+ }), new StreamedPHPResponse(
1769
+ // Headers stream
1770
+ new ReadableStream({
1771
+ start(i) {
1772
+ i.close();
1773
+ }
1774
+ }),
1775
+ n.stream,
1776
+ s.stream,
1777
+ // Exit code
1778
+ new Promise((i) => {
1779
+ r.on("exit", (o) => {
1780
+ i(o);
1781
+ });
1782
+ })
1783
+ );
1784
+ }
1698
1785
  setSkipShebang(t) {
1699
1786
  this[__private__dont__use].ccall(
1700
1787
  "wasm_set_skip_shebang",
@@ -1711,13 +1798,13 @@ class PHP {
1711
1798
  this[__private__dont__use]._exit(t);
1712
1799
  } catch {
1713
1800
  }
1714
- g(this, b, !1), g(this, T, null), this[__private__dont__use] && (delete this[__private__dont__use].onMessage, delete this[__private__dont__use]);
1801
+ w(this, H, !1), w(this, T, null), this[__private__dont__use] && (delete this[__private__dont__use].onMessage, delete this[__private__dont__use]);
1715
1802
  }
1716
1803
  [Symbol.dispose]() {
1717
1804
  this.exit(0);
1718
1805
  }
1719
1806
  }
1720
- C = new WeakMap(), b = new WeakMap(), T = new WeakMap(), E = new WeakMap(), F = new WeakMap(), M = new WeakMap(), _ = new WeakMap(), h = new WeakSet(), /**
1807
+ C = new WeakMap(), H = new WeakMap(), T = new WeakMap(), E = new WeakMap(), F = new WeakMap(), M = new WeakMap(), _ = new WeakMap(), h = new WeakSet(), /**
1721
1808
  * Prepares the $_SERVER entries for the PHP runtime.
1722
1809
  *
1723
1810
  * @param defaults Default entries to include in $_SERVER.
@@ -1832,14 +1919,14 @@ B = function(t, e, r) {
1832
1919
  [STRING, STRING],
1833
1920
  [t, e]
1834
1921
  );
1835
- }, j = function(t, e) {
1922
+ }, q = function(t, e) {
1836
1923
  this[__private__dont__use].ccall(
1837
1924
  "wasm_add_ENV_entry",
1838
1925
  null,
1839
1926
  [STRING, STRING],
1840
1927
  [t, e]
1841
1928
  );
1842
- }, q = async function(t) {
1929
+ }, D = async function(t) {
1843
1930
  u(this, _).enabled && u(this, _).needsRotating && await this.rotateRuntime(), ++u(this, _).requestsMade, u(this, _).requestsMade >= u(this, _).maxRequests && (u(this, _).needsRotating = !0);
1844
1931
  const e = this[__private__dont__use], r = await createInvertedReadableStream();
1845
1932
  e.onHeaders = (p) => {
@@ -1862,11 +1949,11 @@ B = function(t, e, r) {
1862
1949
  try {
1863
1950
  return await Promise.race([
1864
1951
  t(),
1865
- new Promise((w, H) => {
1866
- var D;
1952
+ new Promise((g, b) => {
1953
+ var j;
1867
1954
  c = (W) => {
1868
- isExitCode(W.error) || H(W.error);
1869
- }, (D = u(this, T)) == null || D.addEventListener(
1955
+ isExitCode(W.error) || b(W.error);
1956
+ }, (j = u(this, T)) == null || j.addEventListener(
1870
1957
  "error",
1871
1958
  c,
1872
1959
  { once: !0 }
@@ -1877,8 +1964,8 @@ B = function(t, e, r) {
1877
1964
  if (isExitCode(f))
1878
1965
  return f.status;
1879
1966
  i.controller.error(f), o.controller.error(f), r.controller.error(f), a = !0;
1880
- for (const w in this)
1881
- typeof this[w] == "function" && (this[w] = () => {
1967
+ for (const g in this)
1968
+ typeof this[g] == "function" && (this[g] = () => {
1882
1969
  throw new Error(
1883
1970
  "PHP runtime has crashed – see the earlier error for details."
1884
1971
  );
@@ -2407,14 +2494,14 @@ class PHPRequestHandler {
2407
2494
  return l.isDir(r) || l.mkdir(r), l.chdir(r), l.requestHandler = this, l;
2408
2495
  },
2409
2496
  maxPhpInstances: e.maxPhpInstances
2410
- }), g(this, v, e.cookieStore === void 0 ? new HttpCookieStore() : e.cookieStore), g(this, S, r);
2497
+ }), w(this, v, e.cookieStore === void 0 ? new HttpCookieStore() : e.cookieStore), w(this, S, r);
2411
2498
  const o = new URL(s);
2412
- g(this, L, o.hostname), g(this, k, o.port ? Number(o.port) : o.protocol === "https:" ? 443 : 80), g(this, I, (o.protocol || "").replace(":", ""));
2499
+ w(this, L, o.hostname), w(this, k, o.port ? Number(o.port) : o.protocol === "https:" ? 443 : 80), w(this, I, (o.protocol || "").replace(":", ""));
2413
2500
  const a = u(this, k) !== 443 && u(this, k) !== 80;
2414
- g(this, A, [
2501
+ w(this, A, [
2415
2502
  u(this, L),
2416
2503
  a ? `:${u(this, k)}` : ""
2417
- ].join("")), g(this, x, o.pathname.replace(/\/+$/, "")), g(this, N, [
2504
+ ].join("")), w(this, x, o.pathname.replace(/\/+$/, "")), w(this, N, [
2418
2505
  `${u(this, I)}://`,
2419
2506
  u(this, A),
2420
2507
  u(this, x)
@@ -2661,14 +2748,12 @@ function applyRewriteRules(t, e) {
2661
2748
  }
2662
2749
  function rotatePHPRuntime({
2663
2750
  php: t,
2664
- cwd: e,
2665
- recreateRuntime: r,
2666
- maxRequests: s = 400
2751
+ recreateRuntime: e,
2752
+ maxRequests: r = 400
2667
2753
  }) {
2668
2754
  return t.enableRuntimeRotation({
2669
- recreateRuntime: r,
2670
- maxRequests: s,
2671
- cwd: e
2755
+ recreateRuntime: e,
2756
+ maxRequests: r
2672
2757
  });
2673
2758
  }
2674
2759
  async function writeFiles(t, e, r, { rmRoot: s = !1 } = {}) {
@@ -2706,50 +2791,71 @@ function sandboxedSpawnHandlerFactory(t) {
2706
2791
  else if (n === "tput" && e[1] === "cols")
2707
2792
  r.stdout("140"), r.exit(0);
2708
2793
  else if (n === "less") {
2709
- r.on("stdin", (i) => {
2710
- r.stdout(i);
2711
- }), await new Promise((i) => {
2794
+ r.on("stdin", (a) => {
2795
+ r.stdout(a);
2796
+ }), await new Promise((a) => {
2712
2797
  r.childProcess.stdin.on("finish", () => {
2713
- i(!0);
2798
+ a(!0);
2714
2799
  });
2715
2800
  }), r.exit(0);
2716
2801
  return;
2717
- } else if (n === "php") {
2718
- const { php: i, reap: o } = await t.acquirePHPInstance({
2719
- considerPrimary: !1
2720
- });
2721
- i.chdir(s.cwd);
2722
- try {
2723
- const a = await i.cli(e, {
2724
- env: {
2725
- ...s.env,
2726
- SCRIPT_PATH: e[1],
2727
- // Set SHELL_PIPE to 0 to ensure WP-CLI formats
2728
- // the output as ASCII tables.
2729
- // @see https://github.com/wp-cli/wp-cli/issues/1102
2730
- SHELL_PIPE: "0"
2731
- }
2732
- });
2733
- a.stdout.pipeTo(
2734
- new WritableStream({
2735
- write(c) {
2736
- r.stdout(c);
2737
- }
2738
- })
2739
- ), a.stderr.pipeTo(
2740
- new WritableStream({
2741
- write(c) {
2742
- r.stderr(c);
2802
+ }
2803
+ if (!["php", "ls", "pwd"].includes(n ?? "")) {
2804
+ r.exit(127);
2805
+ return;
2806
+ }
2807
+ const { php: i, reap: o } = await t.acquirePHPInstance({
2808
+ considerPrimary: !1
2809
+ });
2810
+ try {
2811
+ s.cwd && i.chdir(s.cwd);
2812
+ const a = i.cwd();
2813
+ switch (n) {
2814
+ case "php": {
2815
+ const c = await i.cli(e, {
2816
+ env: {
2817
+ ...s.env,
2818
+ SCRIPT_PATH: e[1],
2819
+ // Set SHELL_PIPE to 0 to ensure WP-CLI formats
2820
+ // the output as ASCII tables.
2821
+ // @see https://github.com/wp-cli/wp-cli/issues/1102
2822
+ SHELL_PIPE: "0"
2743
2823
  }
2744
- })
2745
- ), r.exit(await a.exitCode);
2746
- } catch (a) {
2747
- throw r.exit(1), a;
2748
- } finally {
2749
- o();
2824
+ });
2825
+ c.stdout.pipeTo(
2826
+ new WritableStream({
2827
+ write(l) {
2828
+ r.stdout(l);
2829
+ }
2830
+ })
2831
+ ), c.stderr.pipeTo(
2832
+ new WritableStream({
2833
+ write(l) {
2834
+ r.stderr(l);
2835
+ }
2836
+ })
2837
+ ), r.exit(await c.exitCode);
2838
+ break;
2839
+ }
2840
+ case "ls": {
2841
+ const c = i.listFiles(e[1] ?? a);
2842
+ for (const l of c)
2843
+ r.stdout(l + `
2844
+ `);
2845
+ await new Promise((l) => setTimeout(l, 10)), r.exit(0);
2846
+ break;
2847
+ }
2848
+ case "pwd": {
2849
+ r.stdout(a + `
2850
+ `), await new Promise((c) => setTimeout(c, 10)), r.exit(0);
2851
+ break;
2852
+ }
2750
2853
  }
2751
- } else
2752
- r.exit(1);
2854
+ } catch (a) {
2855
+ throw r.exit(1), a;
2856
+ } finally {
2857
+ o();
2858
+ }
2753
2859
  });
2754
2860
  }
2755
2861
  function exposeSync(t, e, r, s = ["*"]) {
@@ -2921,7 +3027,7 @@ function expose(t, e = globalThis, r = ["*"], s) {
2921
3027
  }, l = (i.data.argumentList || []).map(fromWireValue);
2922
3028
  let d;
2923
3029
  try {
2924
- const p = c.slice(0, -1).reduce((w, H) => w[H], t), f = c.reduce((w, H) => w[H], t);
3030
+ const p = c.slice(0, -1).reduce((g, b) => g[b], t), f = c.reduce((g, b) => g[b], t);
2925
3031
  switch (a) {
2926
3032
  case MessageType.GET:
2927
3033
  d = f;
@@ -2936,14 +3042,14 @@ function expose(t, e = globalThis, r = ["*"], s) {
2936
3042
  break;
2937
3043
  case MessageType.CONSTRUCT:
2938
3044
  {
2939
- const w = new f(...l);
2940
- d = proxy(w);
3045
+ const g = new f(...l);
3046
+ d = proxy(g);
2941
3047
  }
2942
3048
  break;
2943
3049
  case MessageType.ENDPOINT:
2944
3050
  {
2945
- const { port1: w, port2: H } = new MessageChannel();
2946
- expose(t, H), d = transfer(w, [w]);
3051
+ const { port1: g, port2: b } = new MessageChannel();
3052
+ expose(t, b), d = transfer(g, [g]);
2947
3053
  }
2948
3054
  break;
2949
3055
  case MessageType.RELEASE:
@@ -2956,8 +3062,8 @@ function expose(t, e = globalThis, r = ["*"], s) {
2956
3062
  d = { value: p, [throwMarker]: 0 };
2957
3063
  }
2958
3064
  Promise.resolve(d).catch((p) => ({ value: p, [throwMarker]: 0 })).then((p) => {
2959
- const [f, w] = toWireValue(p);
2960
- e.postMessage({ ...f, id: o }, w), a === MessageType.RELEASE && (e.removeEventListener("message", n), closeEndPoint(e), finalizer in t && typeof t[finalizer] == "function" && t[finalizer]());
3065
+ const [f, g] = toWireValue(p);
3066
+ e.postMessage({ ...f, id: o }, g), a === MessageType.RELEASE && (e.removeEventListener("message", n), closeEndPoint(e), finalizer in t && typeof t[finalizer] == "function" && t[finalizer]());
2961
3067
  }).catch(() => {
2962
3068
  const [p, f] = toWireValue({
2963
3069
  value: new TypeError("Unserializable return value"),