@php-wasm/universal 1.2.3 → 2.0.1

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
@@ -105,10 +105,10 @@ function rethrowFileSystemError(t = "") {
105
105
  } catch (n) {
106
106
  const i = typeof n == "object" ? n == null ? void 0 : n.errno : null;
107
107
  if (i in FileErrorCodes) {
108
- const o = FileErrorCodes[i], a = typeof s[1] == "string" ? s[1] : null, l = a !== null ? t.replaceAll("{path}", a) : t;
108
+ const o = FileErrorCodes[i], a = typeof s[1] == "string" ? s[1] : null, c = a !== null ? t.replaceAll("{path}", a) : t;
109
109
  throw new ErrnoError(
110
110
  i,
111
- `${l}: ${o}`,
111
+ `${c}: ${o}`,
112
112
  {
113
113
  cause: n
114
114
  }
@@ -386,6 +386,16 @@ class PHPWorker {
386
386
  __internal_getPHP() {
387
387
  return _private.get(this).php;
388
388
  }
389
+ /**
390
+ * @internal
391
+ * @deprecated
392
+ * Do not use this method directly in the code consuming
393
+ * the web API. It will change or even be removed without
394
+ * a warning.
395
+ */
396
+ __internal_getRequestHandler() {
397
+ return _private.get(this).requestHandler;
398
+ }
389
399
  async setPrimaryPHP(e) {
390
400
  _private.set(this, {
391
401
  ..._private.get(this),
@@ -660,14 +670,14 @@ const RuntimeId = Symbol("RuntimeId"), loadedRuntimes = /* @__PURE__ */ new Map(
660
670
  let lastRuntimeId = 0;
661
671
  async function loadPHPRuntime(t, ...e) {
662
672
  const r = Object.assign({}, ...e), [s, n, i] = makePromise(), o = t.init(currentJsRuntime, {
663
- onAbort(l) {
664
- i(l), logger.error(l);
673
+ onAbort(c) {
674
+ i(c), logger.error(c);
665
675
  },
666
676
  ENV: {},
667
677
  // Emscripten sometimes prepends a '/' to the path, which
668
678
  // breaks vite dev mode. An identity `locateFile` function
669
679
  // fixes it.
670
- locateFile: (l) => l,
680
+ locateFile: (c) => c,
671
681
  ...r,
672
682
  noInitialRun: !0,
673
683
  onRuntimeInitialized() {
@@ -676,8 +686,8 @@ async function loadPHPRuntime(t, ...e) {
676
686
  });
677
687
  await s;
678
688
  const a = ++lastRuntimeId;
679
- return o.FS, o.id = a, o.originalExit = o._exit, o._exit = function(l) {
680
- return o.outboundNetworkProxyServer && (o.outboundNetworkProxyServer.close(), o.outboundNetworkProxyServer.closeAllConnections()), loadedRuntimes.delete(a), o.originalExit(l);
689
+ return o.FS, o.id = a, o.originalExit = o._exit, o._exit = function(c) {
690
+ return o.outboundNetworkProxyServer && (o.outboundNetworkProxyServer.close(), o.outboundNetworkProxyServer.closeAllConnections()), loadedRuntimes.delete(a), o.originalExit(c);
681
691
  }, o[RuntimeId] = a, loadedRuntimes.set(a, o), a;
682
692
  }
683
693
  function getLoadedRuntime(t) {
@@ -759,8 +769,8 @@ function improveWASMErrorReporting(t) {
759
769
  );
760
770
  if (e.hasListeners()) {
761
771
  o.message = a;
762
- const l = new ErrorEvent("error", { error: o });
763
- throw e.dispatchEvent(l), o;
772
+ const c = new ErrorEvent("error", { error: o });
773
+ throw e.dispatchEvent(c), o;
764
774
  }
765
775
  throw (!isExitCode(o) || o.status !== 0) && showCriticalErrorBox(a), o;
766
776
  }
@@ -861,8 +871,8 @@ class PHPExecutionFailureError extends Error {
861
871
  super(e), this.response = r, this.source = s;
862
872
  }
863
873
  }
864
- const PHP_INI_PATH = "/internal/shared/php.ini", AUTO_PREPEND_SCRIPT = "/internal/shared/auto_prepend_file.php";
865
- var k, E, x, g, v, T, d, z, W, B, $, V, G, J, Y, K, L, X, U, O;
874
+ const PHP_INI_PATH = "/internal/shared/php.ini", AUTO_PREPEND_SCRIPT = "/internal/shared/auto_prepend_file.php", OPCACHE_FILE_FOLDER = "/internal/shared/opcache";
875
+ var k, E, x, g, v, T, d, z, W, B, $, V, G, J, Y, K, L, X, O, U;
866
876
  class PHP {
867
877
  /**
868
878
  * Initializes a PHP runtime.
@@ -975,35 +985,53 @@ class PHP {
975
985
  const e = getLoadedRuntime(t);
976
986
  if (!e)
977
987
  throw new Error("Invalid PHP runtime id.");
978
- this[__private__dont__use] = e, this[__private__dont__use].ccall(
988
+ if (this[__private__dont__use] = e, this[__private__dont__use].ccall(
979
989
  "wasm_set_phpini_path",
980
990
  null,
981
991
  ["string"],
982
992
  [PHP_INI_PATH]
983
- ), this.fileExists(PHP_INI_PATH) || this.writeFile(
984
- PHP_INI_PATH,
985
- [
986
- "auto_prepend_file=" + AUTO_PREPEND_SCRIPT,
987
- "memory_limit=256M",
988
- "ignore_repeated_errors = 1",
989
- "error_reporting = E_ALL",
990
- "display_errors = 1",
991
- "html_errors = 1",
992
- "display_startup_errors = On",
993
- "log_errors = 1",
994
- "always_populate_raw_post_data = -1",
995
- "upload_max_filesize = 2000M",
996
- "post_max_size = 2000M",
997
- "allow_url_fopen = On",
998
- "allow_url_include = Off",
999
- "session.save_path = /home/web_user",
1000
- "implicit_flush = 1",
1001
- "output_buffering = 0",
1002
- "max_execution_time = 0",
1003
- "max_input_time = -1"
1004
- ].join(`
993
+ ), !this.fileExists(PHP_INI_PATH)) {
994
+ const r = [
995
+ // OPCache
996
+ "opcache.enable = 1",
997
+ "opcache.enable_cli = 1",
998
+ "opcache.jit = 0",
999
+ "opcache.interned_strings_buffer = 8",
1000
+ "opcache.max_accelerated_files = 1000",
1001
+ "opcache.memory_consumption = 64",
1002
+ "opcache.max_wasted_percentage = 5",
1003
+ "opcache.file_cache = " + OPCACHE_FILE_FOLDER,
1004
+ // Always enable the file cache.
1005
+ "opcache.file_cache_only = 1",
1006
+ "opcache.file_cache_consistency_checks = 1"
1007
+ ];
1008
+ this.fileExists(OPCACHE_FILE_FOLDER) || this.mkdir(OPCACHE_FILE_FOLDER), this.writeFile(
1009
+ PHP_INI_PATH,
1010
+ [
1011
+ "auto_prepend_file=" + AUTO_PREPEND_SCRIPT,
1012
+ "memory_limit=256M",
1013
+ "ignore_repeated_errors = 1",
1014
+ "error_reporting = E_ALL",
1015
+ "display_errors = 1",
1016
+ "html_errors = 1",
1017
+ "display_startup_errors = On",
1018
+ "log_errors = 1",
1019
+ "always_populate_raw_post_data = -1",
1020
+ "upload_max_filesize = 2000M",
1021
+ "post_max_size = 2000M",
1022
+ "allow_url_fopen = On",
1023
+ "allow_url_include = Off",
1024
+ "session.save_path = /home/web_user",
1025
+ "implicit_flush = 1",
1026
+ "output_buffering = 0",
1027
+ "max_execution_time = 0",
1028
+ "max_input_time = -1",
1029
+ ...r
1030
+ ].join(`
1005
1031
  `)
1006
- ), this.fileExists(AUTO_PREPEND_SCRIPT) || this.writeFile(
1032
+ );
1033
+ }
1034
+ this.fileExists(AUTO_PREPEND_SCRIPT) || this.writeFile(
1007
1035
  AUTO_PREPEND_SCRIPT,
1008
1036
  `<?php
1009
1037
  // Define constants set via defineConstant() calls
@@ -1263,7 +1291,7 @@ class PHP {
1263
1291
  this.runStreamCalled = !0;
1264
1292
  const e = await this.semaphore.acquire();
1265
1293
  let r;
1266
- const s = m(this, d, O).call(this, async () => {
1294
+ const s = m(this, d, U).call(this, async () => {
1267
1295
  if (u(this, E) || (await m(this, d, W).call(this), f(this, E, !0)), t.scriptPath && !this.fileExists(t.scriptPath))
1268
1296
  throw new Error(
1269
1297
  `The script path "${t.scriptPath}" does not exist.`
@@ -1279,11 +1307,11 @@ class PHP {
1279
1307
  "The request object must have either a `code` or a `scriptPath` property."
1280
1308
  );
1281
1309
  const a = m(this, d, z).call(this, t.$_SERVER, n, o);
1282
- for (const c in a)
1283
- m(this, d, X).call(this, c, a[c]);
1284
- const l = t.env || {};
1285
- for (const c in l)
1286
- m(this, d, U).call(this, c, l[c]);
1310
+ for (const l in a)
1311
+ m(this, d, X).call(this, l, a[l]);
1312
+ const c = t.env || {};
1313
+ for (const l in c)
1314
+ m(this, d, O).call(this, l, c[l]);
1287
1315
  return await this[__private__dont__use].ccall(
1288
1316
  "wasm_sapi_handle_request",
1289
1317
  NUMBER,
@@ -1546,7 +1574,7 @@ class PHP {
1546
1574
  this.cliCalled = !0;
1547
1575
  const r = await this.semaphore.acquire(), s = e.env || {};
1548
1576
  for (const [n, i] of Object.entries(s))
1549
- m(this, d, U).call(this, n, i);
1577
+ m(this, d, O).call(this, n, i);
1550
1578
  t = [t[0], "-c", PHP_INI_PATH, ...t.slice(1)];
1551
1579
  for (const n of t)
1552
1580
  this[__private__dont__use].ccall(
@@ -1555,7 +1583,7 @@ class PHP {
1555
1583
  [STRING],
1556
1584
  [n]
1557
1585
  );
1558
- return await m(this, d, O).call(this, () => this[__private__dont__use].ccall("run_cli", null, [], [], {
1586
+ return await m(this, d, U).call(this, () => this[__private__dont__use].ccall("run_cli", null, [], [], {
1559
1587
  async: !0
1560
1588
  })).then((n) => (n.exitCode.finally(r), n));
1561
1589
  }
@@ -1700,14 +1728,14 @@ z = function(t, e, r) {
1700
1728
  [STRING, STRING],
1701
1729
  [t, e]
1702
1730
  );
1703
- }, U = function(t, e) {
1731
+ }, O = function(t, e) {
1704
1732
  this[__private__dont__use].ccall(
1705
1733
  "wasm_add_ENV_entry",
1706
1734
  null,
1707
1735
  [STRING, STRING],
1708
1736
  [t, e]
1709
1737
  );
1710
- }, O = async function(t) {
1738
+ }, U = async function(t) {
1711
1739
  const e = this[__private__dont__use], r = await createInvertedReadableStream();
1712
1740
  e.onHeaders = (h) => {
1713
1741
  a || s || r.controller.enqueue(h.slice());
@@ -1723,7 +1751,7 @@ z = function(t, e, r) {
1723
1751
  e.onStderr = (h) => {
1724
1752
  a || o.controller.enqueue(h.slice());
1725
1753
  };
1726
- let a = !1, l;
1754
+ let a = !1, c;
1727
1755
  const p = (async () => {
1728
1756
  var h;
1729
1757
  try {
@@ -1731,11 +1759,11 @@ z = function(t, e, r) {
1731
1759
  t(),
1732
1760
  new Promise((w, b) => {
1733
1761
  var j;
1734
- l = (D) => {
1762
+ c = (D) => {
1735
1763
  isExitCode(D.error) || b(D.error);
1736
1764
  }, (j = u(this, x)) == null || j.addEventListener(
1737
1765
  "error",
1738
- l,
1766
+ c,
1739
1767
  { once: !0 }
1740
1768
  );
1741
1769
  })
@@ -1754,7 +1782,7 @@ z = function(t, e, r) {
1754
1782
  } finally {
1755
1783
  a || (i.controller.close(), o.controller.close(), n(), a = !0), (h = u(this, x)) == null || h.removeEventListener(
1756
1784
  "error",
1757
- l
1785
+ c
1758
1786
  );
1759
1787
  }
1760
1788
  })();
@@ -1925,16 +1953,16 @@ async function* iteratePhpFiles(t, e, {
1925
1953
  if (!o)
1926
1954
  return;
1927
1955
  const a = await t.listFiles(o);
1928
- for (const l of a) {
1929
- const c = `${o}/${l}`;
1930
- if (n.includes(c.substring(e.length + 1)))
1956
+ for (const c of a) {
1957
+ const l = `${o}/${c}`;
1958
+ if (n.includes(l.substring(e.length + 1)))
1931
1959
  continue;
1932
- await t.isDir(c) ? i.push(c) : yield new StreamedFile(
1933
- streamReadFileFromPHP(t, c),
1960
+ await t.isDir(l) ? i.push(l) : yield new StreamedFile(
1961
+ streamReadFileFromPHP(t, l),
1934
1962
  r ? joinPaths(
1935
1963
  s || "",
1936
- c.substring(e.length + 1)
1937
- ) : c
1964
+ l.substring(e.length + 1)
1965
+ ) : l
1938
1966
  );
1939
1967
  }
1940
1968
  }
@@ -2095,22 +2123,22 @@ function ensurePathPrefix(t, e) {
2095
2123
  }
2096
2124
  async function encodeAsMultipart(t) {
2097
2125
  const e = `----${Math.random().toString(36).slice(2)}`, r = `multipart/form-data; boundary=${e}`, s = new TextEncoder(), n = [];
2098
- for (const [l, c] of Object.entries(t))
2126
+ for (const [c, l] of Object.entries(t))
2099
2127
  n.push(`--${e}\r
2100
- `), n.push(`Content-Disposition: form-data; name="${l}"`), c instanceof File && n.push(`; filename="${c.name}"`), n.push(`\r
2101
- `), c instanceof File && (n.push("Content-Type: application/octet-stream"), n.push(`\r
2128
+ `), n.push(`Content-Disposition: form-data; name="${c}"`), l instanceof File && n.push(`; filename="${l.name}"`), n.push(`\r
2129
+ `), l instanceof File && (n.push("Content-Type: application/octet-stream"), n.push(`\r
2102
2130
  `)), n.push(`\r
2103
- `), c instanceof File ? n.push(await fileToUint8Array(c)) : n.push(c), n.push(`\r
2131
+ `), l instanceof File ? n.push(await fileToUint8Array(l)) : n.push(l), n.push(`\r
2104
2132
  `);
2105
2133
  n.push(`--${e}--\r
2106
2134
  `);
2107
- const i = n.reduce((l, c) => l + c.length, 0), o = new Uint8Array(i);
2135
+ const i = n.reduce((c, l) => c + l.length, 0), o = new Uint8Array(i);
2108
2136
  let a = 0;
2109
- for (const l of n)
2137
+ for (const c of n)
2110
2138
  o.set(
2111
- typeof l == "string" ? s.encode(l) : l,
2139
+ typeof c == "string" ? s.encode(c) : c,
2112
2140
  a
2113
- ), a += l.length;
2141
+ ), a += c.length;
2114
2142
  return { bytes: o, contentType: r };
2115
2143
  }
2116
2144
  function fileToUint8Array(t) {
@@ -2212,7 +2240,7 @@ const _default = "application/octet-stream", asx = "video/x-ms-asf", atom = "app
2212
2240
  xspf,
2213
2241
  zip
2214
2242
  };
2215
- var S, C, A, F, I, P, M, R, H, Q, Z, ee;
2243
+ var S, C, M, F, I, P, A, R, H, Q, Z, ee;
2216
2244
  class PHPRequestHandler {
2217
2245
  /**
2218
2246
  * The request handler needs to decide whether to serve a static asset or
@@ -2229,11 +2257,11 @@ class PHPRequestHandler {
2229
2257
  _(this, H);
2230
2258
  _(this, S);
2231
2259
  _(this, C);
2232
- _(this, A);
2260
+ _(this, M);
2233
2261
  _(this, F);
2234
2262
  _(this, I);
2235
2263
  _(this, P);
2236
- _(this, M);
2264
+ _(this, A);
2237
2265
  _(this, R);
2238
2266
  const {
2239
2267
  documentRoot: r = "/www/",
@@ -2242,22 +2270,22 @@ class PHPRequestHandler {
2242
2270
  getFileNotFoundAction: i = () => ({ type: "404" })
2243
2271
  } = e;
2244
2272
  "processManager" in e ? this.processManager = e.processManager : this.processManager = new PHPProcessManager({
2245
- phpFactory: async (l) => {
2246
- const c = await e.phpFactory({
2247
- ...l,
2273
+ phpFactory: async (c) => {
2274
+ const l = await e.phpFactory({
2275
+ ...c,
2248
2276
  requestHandler: this
2249
2277
  });
2250
- return c.isDir(r) || c.mkdir(r), c.chdir(r), c.requestHandler = this, c;
2278
+ return l.isDir(r) || l.mkdir(r), l.chdir(r), l.requestHandler = this, l;
2251
2279
  },
2252
2280
  maxPhpInstances: e.maxPhpInstances
2253
2281
  }), f(this, R, e.cookieStore === void 0 ? new HttpCookieStore() : e.cookieStore), f(this, S, r);
2254
2282
  const o = new URL(s);
2255
- f(this, A, o.hostname), f(this, F, o.port ? Number(o.port) : o.protocol === "https:" ? 443 : 80), f(this, C, (o.protocol || "").replace(":", ""));
2283
+ f(this, M, o.hostname), f(this, F, o.port ? Number(o.port) : o.protocol === "https:" ? 443 : 80), f(this, C, (o.protocol || "").replace(":", ""));
2256
2284
  const a = u(this, F) !== 443 && u(this, F) !== 80;
2257
2285
  f(this, I, [
2258
- u(this, A),
2286
+ u(this, M),
2259
2287
  a ? `:${u(this, F)}` : ""
2260
- ].join("")), f(this, P, o.pathname.replace(/\/+$/, "")), f(this, M, [
2288
+ ].join("")), f(this, P, o.pathname.replace(/\/+$/, "")), f(this, A, [
2261
2289
  `${u(this, C)}://`,
2262
2290
  u(this, I),
2263
2291
  u(this, P)
@@ -2291,7 +2319,7 @@ class PHPRequestHandler {
2291
2319
  * The absolute URL of this PHPRequestHandler instance.
2292
2320
  */
2293
2321
  get absoluteUrl() {
2294
- return u(this, M);
2322
+ return u(this, A);
2295
2323
  }
2296
2324
  /**
2297
2325
  * The directory in the PHP filesystem where the server will look
@@ -2369,9 +2397,9 @@ class PHPRequestHandler {
2369
2397
  new Uint8Array(0)
2370
2398
  );
2371
2399
  for (const a of ["index.php", "index.html"]) {
2372
- const l = joinPaths(o, a);
2373
- if (i.isFile(l)) {
2374
- o = l;
2400
+ const c = joinPaths(o, a);
2401
+ if (i.isFile(c)) {
2402
+ o = c;
2375
2403
  break;
2376
2404
  }
2377
2405
  }
@@ -2411,7 +2439,7 @@ class PHPRequestHandler {
2411
2439
  await this.processManager[Symbol.asyncDispose]();
2412
2440
  }
2413
2441
  }
2414
- S = new WeakMap(), C = new WeakMap(), A = new WeakMap(), F = new WeakMap(), I = new WeakMap(), P = new WeakMap(), M = new WeakMap(), R = new WeakMap(), H = new WeakSet(), /**
2442
+ S = new WeakMap(), C = new WeakMap(), M = new WeakMap(), F = new WeakMap(), I = new WeakMap(), P = new WeakMap(), A = new WeakMap(), R = new WeakMap(), H = new WeakSet(), /**
2415
2443
  * Serves a static file from the PHP filesystem.
2416
2444
  *
2417
2445
  * @param fsPath - Absolute path of the static file to serve.
@@ -2456,8 +2484,8 @@ Q = function(e, r) {
2456
2484
  let o = r.body;
2457
2485
  if (typeof o == "object" && !(o instanceof Uint8Array)) {
2458
2486
  n = "POST";
2459
- const { bytes: a, contentType: l } = await encodeAsMultipart(o);
2460
- o = a, i["content-type"] = l;
2487
+ const { bytes: a, contentType: c } = await encodeAsMultipart(o);
2488
+ o = a, i["content-type"] = c;
2461
2489
  }
2462
2490
  try {
2463
2491
  const a = await e.run({
@@ -2470,7 +2498,7 @@ Q = function(e, r) {
2470
2498
  $_SERVER: {
2471
2499
  REMOTE_ADDR: "127.0.0.1",
2472
2500
  DOCUMENT_ROOT: u(this, S),
2473
- HTTPS: u(this, M).startsWith("https://") ? "on" : ""
2501
+ HTTPS: u(this, A).startsWith("https://") ? "on" : ""
2474
2502
  },
2475
2503
  body: o,
2476
2504
  scriptPath: s,
@@ -2480,9 +2508,9 @@ Q = function(e, r) {
2480
2508
  a.headers
2481
2509
  ), a;
2482
2510
  } catch (a) {
2483
- const l = a;
2484
- if (l != null && l.response)
2485
- return l.response;
2511
+ const c = a;
2512
+ if (c != null && c.response)
2513
+ return c.response;
2486
2514
  throw a;
2487
2515
  }
2488
2516
  };
@@ -2512,18 +2540,18 @@ function rotatePHPRuntime({
2512
2540
  }) {
2513
2541
  let n = 0;
2514
2542
  async function i() {
2515
- const l = await t.semaphore.acquire();
2543
+ const c = await t.semaphore.acquire();
2516
2544
  try {
2517
2545
  await t.hotSwapPHPRuntime(await r(), e), n = 0;
2518
2546
  } finally {
2519
- l();
2547
+ c();
2520
2548
  }
2521
2549
  }
2522
2550
  async function o() {
2523
2551
  ++n < s || await i();
2524
2552
  }
2525
- async function a(l) {
2526
- l.type === "request.error" && l.source === "php-wasm" && await i();
2553
+ async function a(c) {
2554
+ c.type === "request.error" && c.source === "php-wasm" && await i();
2527
2555
  }
2528
2556
  return t.addEventListener("request.error", a), t.addEventListener("request.end", o), function() {
2529
2557
  t.removeEventListener("request.error", a), t.removeEventListener("request.end", o);
@@ -2580,14 +2608,14 @@ function sandboxedSpawnHandlerFactory(t) {
2580
2608
  });
2581
2609
  a.stdout.pipeTo(
2582
2610
  new WritableStream({
2583
- write(l) {
2584
- r.stdout(l);
2611
+ write(c) {
2612
+ r.stdout(c);
2585
2613
  }
2586
2614
  })
2587
2615
  ), a.stderr.pipeTo(
2588
2616
  new WritableStream({
2589
- write(l) {
2590
- r.stderr(l);
2617
+ write(c) {
2618
+ r.stderr(c);
2591
2619
  }
2592
2620
  })
2593
2621
  ), r.exit(await a.exitCode);
@@ -2626,16 +2654,16 @@ function createSyncProxy(t, e = [], r) {
2626
2654
  apply(s, n, i) {
2627
2655
  if (e.at(-1) === "bind")
2628
2656
  return createSyncProxy(t, e.slice(0, -1), r);
2629
- const [a, l] = processArguments(i), c = r.send(
2657
+ const [a, c] = processArguments(i), l = r.send(
2630
2658
  t,
2631
2659
  {
2632
2660
  type: MessageType.APPLY,
2633
2661
  path: e.map(String),
2634
2662
  argumentList: a
2635
2663
  },
2636
- l
2664
+ c
2637
2665
  );
2638
- return fromWireValue(c);
2666
+ return fromWireValue(l);
2639
2667
  },
2640
2668
  construct(s, n) {
2641
2669
  const [i, o] = processArguments(n), a = r.send(
@@ -2676,7 +2704,7 @@ class NodeSABSyncReceiveMessageTransport {
2676
2704
  }
2677
2705
  }
2678
2706
  send(e, r, s) {
2679
- var c;
2707
+ var l;
2680
2708
  const n = new SharedArrayBuffer(4), i = new Int32Array(n);
2681
2709
  i[0] = 0;
2682
2710
  const o = generateUUID();
@@ -2687,7 +2715,7 @@ class NodeSABSyncReceiveMessageTransport {
2687
2715
  throw new Error("Timeout waiting for response");
2688
2716
  for (; ; ) {
2689
2717
  const p = NodeSABSyncReceiveMessageTransport.receiveMessageOnPort(e);
2690
- if (((c = p.message) == null ? void 0 : c.id) === o)
2718
+ if (((l = p.message) == null ? void 0 : l.id) === o)
2691
2719
  return p.message;
2692
2720
  if (!p)
2693
2721
  throw new Error("No response received");
@@ -2763,28 +2791,28 @@ function expose(t, e = globalThis, r = ["*"], s) {
2763
2791
  console.warn(`Invalid origin '${i.origin}' for comlink proxy`);
2764
2792
  return;
2765
2793
  }
2766
- const { id: o, type: a, path: l } = {
2794
+ const { id: o, type: a, path: c } = {
2767
2795
  path: [],
2768
2796
  ...i.data
2769
- }, c = (i.data.argumentList || []).map(fromWireValue);
2797
+ }, l = (i.data.argumentList || []).map(fromWireValue);
2770
2798
  let p;
2771
2799
  try {
2772
- const h = l.slice(0, -1).reduce((w, b) => w[b], t), y = l.reduce((w, b) => w[b], t);
2800
+ const h = c.slice(0, -1).reduce((w, b) => w[b], t), y = c.reduce((w, b) => w[b], t);
2773
2801
  switch (a) {
2774
2802
  case MessageType.GET:
2775
2803
  p = y;
2776
2804
  break;
2777
2805
  case MessageType.SET:
2778
- h[l.slice(-1)[0]] = fromWireValue(
2806
+ h[c.slice(-1)[0]] = fromWireValue(
2779
2807
  i.data.value
2780
2808
  ), p = !0;
2781
2809
  break;
2782
2810
  case MessageType.APPLY:
2783
- p = y.apply(h, c);
2811
+ p = y.apply(h, l);
2784
2812
  break;
2785
2813
  case MessageType.CONSTRUCT:
2786
2814
  {
2787
- const w = new y(...c);
2815
+ const w = new y(...l);
2788
2816
  p = proxy(w);
2789
2817
  }
2790
2818
  break;
@@ -2872,38 +2900,38 @@ function createProxy(t, e, r = [], s = function() {
2872
2900
  if (a === "then") {
2873
2901
  if (r.length === 0)
2874
2902
  return { then: () => i };
2875
- const l = requestResponseMessage(t, e, {
2903
+ const c = requestResponseMessage(t, e, {
2876
2904
  type: MessageType.GET,
2877
- path: r.map((c) => c.toString())
2905
+ path: r.map((l) => l.toString())
2878
2906
  }).then(fromWireValue);
2879
- return l.then.bind(l);
2907
+ return c.then.bind(c);
2880
2908
  }
2881
2909
  return createProxy(t, e, [...r, a]);
2882
2910
  },
2883
- set(o, a, l) {
2911
+ set(o, a, c) {
2884
2912
  throwIfProxyReleased(n);
2885
- const [c, p] = toWireValue(l);
2913
+ const [l, p] = toWireValue(c);
2886
2914
  return requestResponseMessage(
2887
2915
  t,
2888
2916
  e,
2889
2917
  {
2890
2918
  type: MessageType.SET,
2891
2919
  path: [...r, a].map((h) => h.toString()),
2892
- value: c
2920
+ value: l
2893
2921
  },
2894
2922
  p
2895
2923
  ).then(fromWireValue);
2896
2924
  },
2897
- apply(o, a, l) {
2925
+ apply(o, a, c) {
2898
2926
  throwIfProxyReleased(n);
2899
- const c = r[r.length - 1];
2900
- if (c === createEndpoint)
2927
+ const l = r[r.length - 1];
2928
+ if (l === createEndpoint)
2901
2929
  return requestResponseMessage(t, e, {
2902
2930
  type: MessageType.ENDPOINT
2903
2931
  }).then(fromWireValue);
2904
- if (c === "bind")
2932
+ if (l === "bind")
2905
2933
  return createProxy(t, e, r.slice(0, -1));
2906
- const [p, h] = processArguments(l);
2934
+ const [p, h] = processArguments(c);
2907
2935
  return requestResponseMessage(
2908
2936
  t,
2909
2937
  e,
@@ -2917,16 +2945,16 @@ function createProxy(t, e, r = [], s = function() {
2917
2945
  },
2918
2946
  construct(o, a) {
2919
2947
  throwIfProxyReleased(n);
2920
- const [l, c] = processArguments(a);
2948
+ const [c, l] = processArguments(a);
2921
2949
  return requestResponseMessage(
2922
2950
  t,
2923
2951
  e,
2924
2952
  {
2925
2953
  type: MessageType.CONSTRUCT,
2926
2954
  path: r.map((p) => p.toString()),
2927
- argumentList: l
2955
+ argumentList: c
2928
2956
  },
2929
- c
2957
+ l
2930
2958
  ).then(fromWireValue);
2931
2959
  }
2932
2960
  });
@@ -3085,8 +3113,8 @@ const errorProperties = [
3085
3113
  return r;
3086
3114
  if (o && typeof t.toJSON == "function" && !toJsonWasCalled.has(t))
3087
3115
  return toJSON(t);
3088
- const l = (c) => destroyCircular({
3089
- from: c,
3116
+ const c = (l) => destroyCircular({
3117
+ from: l,
3090
3118
  seen: [...e],
3091
3119
  forceEnumerable: s,
3092
3120
  maxDepth: n,
@@ -3094,34 +3122,34 @@ const errorProperties = [
3094
3122
  useToJSON: o,
3095
3123
  serialize: a
3096
3124
  });
3097
- for (const [c, p] of Object.entries(t)) {
3125
+ for (const [l, p] of Object.entries(t)) {
3098
3126
  if (p && p instanceof Uint8Array && p.constructor.name === "Buffer") {
3099
- r[c] = "[object Buffer]";
3127
+ r[l] = "[object Buffer]";
3100
3128
  continue;
3101
3129
  }
3102
3130
  if (p !== null && typeof p == "object" && typeof p.pipe == "function") {
3103
- r[c] = "[object Stream]";
3131
+ r[l] = "[object Stream]";
3104
3132
  continue;
3105
3133
  }
3106
3134
  if (typeof p != "function") {
3107
3135
  if (!p || typeof p != "object") {
3108
3136
  try {
3109
- r[c] = p;
3137
+ r[l] = p;
3110
3138
  } catch {
3111
3139
  }
3112
3140
  continue;
3113
3141
  }
3114
- if (!e.includes(t[c])) {
3115
- i++, r[c] = l(t[c]);
3142
+ if (!e.includes(t[l])) {
3143
+ i++, r[l] = c(t[l]);
3116
3144
  continue;
3117
3145
  }
3118
- r[c] = "[Circular]";
3146
+ r[l] = "[Circular]";
3119
3147
  }
3120
3148
  }
3121
3149
  if (a || r instanceof Error)
3122
- for (const { property: c, enumerable: p } of errorProperties)
3123
- t[c] !== void 0 && t[c] !== null && Object.defineProperty(r, c, {
3124
- value: isErrorLike(t[c]) || Array.isArray(t[c]) ? l(t[c]) : t[c],
3150
+ for (const { property: l, enumerable: p } of errorProperties)
3151
+ t[l] !== void 0 && t[l] !== null && Object.defineProperty(r, l, {
3152
+ value: isErrorLike(t[l]) || Array.isArray(t[l]) ? c(t[l]) : t[l],
3125
3153
  enumerable: s ? !0 : p,
3126
3154
  configurable: !0,
3127
3155
  writable: !0
@@ -3199,10 +3227,10 @@ function prepareForExpose(t, e) {
3199
3227
  setupTransferHandlers();
3200
3228
  const r = Promise.resolve();
3201
3229
  let s, n;
3202
- const i = new Promise((l, c) => {
3203
- s = l, n = c;
3230
+ const i = new Promise((c, l) => {
3231
+ s = c, n = l;
3204
3232
  }), o = proxyClone(t), a = new Proxy(o, {
3205
- get: (l, c) => c === "isConnected" ? () => r : c === "isReady" ? () => i : c in l ? l[c] : e == null ? void 0 : e[c]
3233
+ get: (c, l) => l === "isConnected" ? () => r : l === "isReady" ? () => i : l in c ? c[l] : e == null ? void 0 : e[l]
3206
3234
  });
3207
3235
  return { setReady: s, setFailed: n, exposedApi: a };
3208
3236
  }