@php-wasm/universal 3.0.54 → 3.1.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
@@ -1,16 +1,16 @@
1
- var $ = (t) => {
2
- throw TypeError(t);
1
+ var q = (r) => {
2
+ throw TypeError(r);
3
3
  };
4
- var j = (t, e, r) => e.has(t) || $("Cannot " + r);
5
- var u = (t, e, r) => (j(t, e, "read from private field"), r ? r.call(t) : e.get(t)), y = (t, e, r) => e.has(t) ? $("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, r), _ = (t, e, r, s) => (j(t, e, "write to private field"), s ? s.call(t, r) : e.set(t, r), r), m = (t, e, r) => (j(t, e, "access private method"), r);
4
+ var B = (r, e, t) => e.has(r) || q("Cannot " + t);
5
+ var u = (r, e, t) => (B(r, e, "read from private field"), t ? t.call(r) : e.get(r)), y = (r, e, t) => e.has(r) ? q("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(r) : e.set(r, t), g = (r, e, t, s) => (B(r, e, "write to private field"), s ? s.call(r, t) : e.set(r, t), t), m = (r, e, t) => (B(r, e, "access private method"), t);
6
6
  import "@php-wasm/node-polyfills";
7
7
  import { logger } from "@php-wasm/logger";
8
8
  import { dirname, joinPaths, Semaphore, createSpawnHandler, basename, normalizePath, AcquireTimeoutError, splitShellCommand } 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 {
12
- constructor(e, r, s) {
13
- super(r, s), this.name = "ErrnoError", this.errno = e;
12
+ constructor(e, t, s) {
13
+ super(t, s), this.name = "ErrnoError", this.errno = e;
14
14
  }
15
15
  }
16
16
  const FileErrorCodes = {
@@ -92,23 +92,23 @@ const FileErrorCodes = {
92
92
  75: "Cross-device link.",
93
93
  76: "Extension: Capabilities insufficient."
94
94
  };
95
- function getEmscriptenFsError(t) {
96
- const e = typeof t == "object" ? t == null ? void 0 : t.errno : null;
95
+ function getEmscriptenFsError(r) {
96
+ const e = typeof r == "object" ? r == null ? void 0 : r.errno : null;
97
97
  if (e in FileErrorCodes)
98
98
  return FileErrorCodes[e];
99
99
  }
100
- function rethrowFileSystemError(t = "") {
101
- return function(r) {
100
+ function rethrowFileSystemError(r = "") {
101
+ return function(t) {
102
102
  return function(...s) {
103
103
  try {
104
- return r.apply(this, s);
104
+ return t.apply(this, s);
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], c = typeof s[1] == "string" ? s[1] : null, a = c !== null ? t.replaceAll("{path}", c) : t;
108
+ const o = FileErrorCodes[i], a = typeof s[1] == "string" ? s[1] : null, c = a !== null ? r.replaceAll("{path}", a) : r;
109
109
  throw new ErrnoError(
110
110
  i,
111
- `${a}: ${o}`,
111
+ `${c}: ${o}`,
112
112
  {
113
113
  cause: n
114
114
  }
@@ -128,8 +128,8 @@ class FSHelpers {
128
128
  * @param path - The file path to read.
129
129
  * @returns The file contents.
130
130
  */
131
- static readFileAsText(e, r) {
132
- return new TextDecoder().decode(FSHelpers.readFileAsBuffer(e, r));
131
+ static readFileAsText(e, t) {
132
+ return new TextDecoder().decode(FSHelpers.readFileAsBuffer(e, t));
133
133
  }
134
134
  /**
135
135
  * Reads a file from the PHP filesystem and returns it as an array buffer.
@@ -139,8 +139,8 @@ class FSHelpers {
139
139
  * @param path - The file path to read.
140
140
  * @returns The file contents.
141
141
  */
142
- static readFileAsBuffer(e, r) {
143
- return e.readFile(r);
142
+ static readFileAsBuffer(e, t) {
143
+ return e.readFile(t);
144
144
  }
145
145
  /**
146
146
  * Overwrites data in a file in the PHP filesystem.
@@ -150,8 +150,8 @@ class FSHelpers {
150
150
  * @param path - The file path to write to.
151
151
  * @param data - The data to write to the file.
152
152
  */
153
- static writeFile(e, r, s) {
154
- e.writeFile(r, s);
153
+ static writeFile(e, t, s) {
154
+ e.writeFile(t, s);
155
155
  }
156
156
  /**
157
157
  * Removes a file from the PHP filesystem.
@@ -160,8 +160,8 @@ class FSHelpers {
160
160
  * @param FS
161
161
  * @param path - The file path to remove.
162
162
  */
163
- static unlink(e, r) {
164
- e.unlink(r);
163
+ static unlink(e, t) {
164
+ e.unlink(t);
165
165
  }
166
166
  /**
167
167
  * Moves a file or directory in the PHP filesystem to a
@@ -171,14 +171,14 @@ class FSHelpers {
171
171
  * @param fromPath The path to rename.
172
172
  * @param toPath The new path.
173
173
  */
174
- static mv(e, r, s) {
174
+ static mv(e, t, s) {
175
175
  try {
176
- const n = e.lookupPath(r).node.mount, i = FSHelpers.fileExists(e, s) ? e.lookupPath(s).node.mount : e.lookupPath(dirname(s)).node.mount;
177
- n.mountpoint !== i.mountpoint ? (FSHelpers.copyRecursive(e, r, s), FSHelpers.isDir(e, r) ? FSHelpers.rmdir(e, r, { recursive: !0 }) : e.unlink(r)) : e.rename(r, s);
176
+ const n = e.lookupPath(t).node.mount, i = FSHelpers.fileExists(e, s) ? e.lookupPath(s).node.mount : e.lookupPath(dirname(s)).node.mount;
177
+ n.mountpoint !== i.mountpoint ? (FSHelpers.copyRecursive(e, t, s), FSHelpers.isDir(e, t) ? FSHelpers.rmdir(e, t, { recursive: !0 }) : e.unlink(t)) : e.rename(t, s);
178
178
  } catch (n) {
179
179
  const i = getEmscriptenFsError(n);
180
180
  throw i ? new Error(
181
- `Could not move ${r} to ${s}: ${i}`,
181
+ `Could not move ${t} to ${s}: ${i}`,
182
182
  {
183
183
  cause: n
184
184
  }
@@ -192,14 +192,14 @@ class FSHelpers {
192
192
  * @param path The directory path to remove.
193
193
  * @param options Options for the removal.
194
194
  */
195
- static rmdir(e, r, s = { recursive: !0 }) {
196
- const n = e.lookupPath(r, { follow: !1 });
197
- if ((n == null ? void 0 : n.node.mount.mountpoint) === r)
195
+ static rmdir(e, t, s = { recursive: !0 }) {
196
+ const n = e.lookupPath(t, { follow: !1 });
197
+ if ((n == null ? void 0 : n.node.mount.mountpoint) === t)
198
198
  throw new ErrnoError(10);
199
- s != null && s.recursive && FSHelpers.listFiles(e, r).forEach((i) => {
200
- const o = `${r}/${i}`;
199
+ s != null && s.recursive && FSHelpers.listFiles(e, t).forEach((i) => {
200
+ const o = `${t}/${i}`;
201
201
  FSHelpers.isDir(e, o) ? FSHelpers.rmdir(e, o, s) : FSHelpers.unlink(e, o);
202
- }), e.getPath(e.lookupPath(r).node) === e.cwd() && e.chdir(joinPaths(e.cwd(), "..")), e.rmdir(r);
202
+ }), e.getPath(e.lookupPath(t).node) === e.cwd() && e.chdir(joinPaths(e.cwd(), "..")), e.rmdir(t);
203
203
  }
204
204
  /**
205
205
  * Lists the files and directories in the given directory.
@@ -209,20 +209,20 @@ class FSHelpers {
209
209
  * @param options - Options for the listing.
210
210
  * @returns The list of files and directories in the given directory.
211
211
  */
212
- static listFiles(e, r, s = { prependPath: !1 }) {
213
- if (!FSHelpers.fileExists(e, r))
212
+ static listFiles(e, t, s = { prependPath: !1 }) {
213
+ if (!FSHelpers.fileExists(e, t))
214
214
  return [];
215
215
  try {
216
- const n = e.readdir(r).filter(
216
+ const n = e.readdir(t).filter(
217
217
  (i) => i !== "." && i !== ".."
218
218
  );
219
219
  if (s.prependPath) {
220
- const i = r.replace(/\/$/, "");
220
+ const i = t.replace(/\/$/, "");
221
221
  return n.map((o) => `${i}/${o}`);
222
222
  }
223
223
  return n;
224
224
  } catch (n) {
225
- return logger.error(n, { path: r }), [];
225
+ return logger.error(n, { path: t }), [];
226
226
  }
227
227
  }
228
228
  /**
@@ -232,8 +232,8 @@ class FSHelpers {
232
232
  * @param path – The path to check.
233
233
  * @returns True if the path is a directory, false otherwise.
234
234
  */
235
- static isDir(e, r) {
236
- return FSHelpers.fileExists(e, r) ? e.isDir(e.lookupPath(r, { follow: !0 }).node.mode) : !1;
235
+ static isDir(e, t) {
236
+ return FSHelpers.fileExists(e, t) ? e.isDir(e.lookupPath(t, { follow: !0 }).node.mode) : !1;
237
237
  }
238
238
  /**
239
239
  * Checks if a file exists in the PHP filesystem.
@@ -242,8 +242,8 @@ class FSHelpers {
242
242
  * @param path – The path to check.
243
243
  * @returns True if the path is a file, false otherwise.
244
244
  */
245
- static isFile(e, r) {
246
- return FSHelpers.fileExists(e, r) ? e.isFile(e.lookupPath(r, { follow: !0 }).node.mode) : !1;
245
+ static isFile(e, t) {
246
+ return FSHelpers.fileExists(e, t) ? e.isFile(e.lookupPath(t, { follow: !0 }).node.mode) : !1;
247
247
  }
248
248
  /**
249
249
  * Creates a symlink in the PHP filesystem.
@@ -252,8 +252,8 @@ class FSHelpers {
252
252
  * @param target
253
253
  * @param link
254
254
  */
255
- static symlink(e, r, s) {
256
- return e.symlink(r, s);
255
+ static symlink(e, t, s) {
256
+ return e.symlink(t, s);
257
257
  }
258
258
  /**
259
259
  * Checks if a path is a symlink in the PHP filesystem.
@@ -262,8 +262,8 @@ class FSHelpers {
262
262
  * @param path
263
263
  * @returns True if the path is a symlink, false otherwise.
264
264
  */
265
- static isSymlink(e, r) {
266
- return FSHelpers.fileExists(e, r) ? e.isLink(e.lookupPath(r).node.mode) : !1;
265
+ static isSymlink(e, t) {
266
+ return FSHelpers.fileExists(e, t) ? e.isLink(e.lookupPath(t).node.mode) : !1;
267
267
  }
268
268
  /**
269
269
  * Reads the target of a symlink in the PHP filesystem.
@@ -272,8 +272,8 @@ class FSHelpers {
272
272
  * @returns The target of the symlink.
273
273
  * @throws {@link @php-wasm/universal:ErrnoError} – If the path is not a symlink.
274
274
  */
275
- static readlink(e, r) {
276
- return e.readlink(r);
275
+ static readlink(e, t) {
276
+ return e.readlink(t);
277
277
  }
278
278
  /**
279
279
  * Gets the real path of a file in the PHP filesystem.
@@ -282,8 +282,8 @@ class FSHelpers {
282
282
  *
283
283
  * @returns The real path of the file.
284
284
  */
285
- static realpath(e, r) {
286
- return e.lookupPath(r, { follow: !0 }).path;
285
+ static realpath(e, t) {
286
+ return e.lookupPath(t, { follow: !0 }).path;
287
287
  }
288
288
  /**
289
289
  * Checks if a file (or a directory) exists in the PHP filesystem.
@@ -292,9 +292,9 @@ class FSHelpers {
292
292
  * @param path - The file path to check.
293
293
  * @returns True if the file exists, false otherwise.
294
294
  */
295
- static fileExists(e, r) {
295
+ static fileExists(e, t) {
296
296
  try {
297
- return e.lookupPath(r), !0;
297
+ return e.lookupPath(t), !0;
298
298
  } catch {
299
299
  return !1;
300
300
  }
@@ -307,23 +307,23 @@ class FSHelpers {
307
307
  * @param FS
308
308
  * @param path - The directory path to create.
309
309
  */
310
- static mkdir(e, r) {
311
- e.mkdirTree(r);
310
+ static mkdir(e, t) {
311
+ e.mkdirTree(t);
312
312
  }
313
- static copyRecursive(e, r, s) {
314
- const n = e.lookupPath(r).node;
313
+ static copyRecursive(e, t, s) {
314
+ const n = e.lookupPath(t).node;
315
315
  if (e.isDir(n.mode)) {
316
316
  e.mkdirTree(s);
317
- const i = e.readdir(r).filter(
317
+ const i = e.readdir(t).filter(
318
318
  (o) => o !== "." && o !== ".."
319
319
  );
320
320
  for (const o of i)
321
321
  FSHelpers.copyRecursive(
322
322
  e,
323
- joinPaths(r, o),
323
+ joinPaths(t, o),
324
324
  joinPaths(s, o)
325
325
  );
326
- } else e.isLink(n.mode) ? e.symlink(e.readlink(r), s) : e.writeFile(s, e.readFile(r));
326
+ } else e.isLink(n.mode) ? e.symlink(e.readlink(t), s) : e.writeFile(s, e.readFile(t));
327
327
  }
328
328
  }
329
329
  FSHelpers.readFileAsText = rethrowFileSystemError('Could not read "{path}"')(
@@ -366,10 +366,10 @@ const _private = /* @__PURE__ */ new WeakMap();
366
366
  var x;
367
367
  class PHPWorker {
368
368
  /** @inheritDoc */
369
- constructor(e, r) {
369
+ constructor(e, t) {
370
370
  y(this, x);
371
- this.absoluteUrl = "", this.documentRoot = "", this.chroot = null, _(this, x, /* @__PURE__ */ new Map()), this.onMessageListeners = [], _private.set(this, {
372
- monitor: r
371
+ this.absoluteUrl = "", this.documentRoot = "", this.chroot = null, g(this, x, /* @__PURE__ */ new Map()), this.onMessageListeners = [], _private.set(this, {
372
+ monitor: t
373
373
  }), e && this.__internal_setRequestHandler(e);
374
374
  }
375
375
  __internal_setRequestHandler(e) {
@@ -416,16 +416,16 @@ class PHPWorker {
416
416
  * The onDownloadProgress event listener.
417
417
  */
418
418
  async onDownloadProgress(e) {
419
- var r;
420
- return (r = _private.get(this).monitor) == null ? void 0 : r.addEventListener("progress", e);
419
+ var t;
420
+ return (t = _private.get(this).monitor) == null ? void 0 : t.addEventListener("progress", e);
421
421
  }
422
422
  /** @inheritDoc @php-wasm/universal!PHP.mv */
423
- async mv(e, r) {
424
- return _private.get(this).php.mv(e, r);
423
+ async mv(e, t) {
424
+ return _private.get(this).php.mv(e, t);
425
425
  }
426
426
  /** @inheritDoc @php-wasm/universal!PHP.rmdir */
427
- async rmdir(e, r) {
428
- return _private.get(this).php.rmdir(e, r);
427
+ async rmdir(e, t) {
428
+ return _private.get(this).php.rmdir(e, t);
429
429
  }
430
430
  /** @inheritDoc @php-wasm/universal!PHPRequestHandler.request */
431
431
  async request(e) {
@@ -433,19 +433,19 @@ class PHPWorker {
433
433
  }
434
434
  /** @inheritDoc @php-wasm/universal!/PHP.run */
435
435
  async run(e) {
436
- const { php: r, reap: s } = await this.acquirePHPInstance();
436
+ const { php: t, reap: s } = await this.acquirePHPInstance();
437
437
  try {
438
- return await r.run(e);
438
+ return await t.run(e);
439
439
  } finally {
440
440
  s();
441
441
  }
442
442
  }
443
443
  /** @inheritDoc @php-wasm/universal!/PHP.cli */
444
- async cli(e, r) {
444
+ async cli(e, t) {
445
445
  const { php: s, reap: n } = await this.acquirePHPInstance();
446
446
  let i;
447
447
  try {
448
- i = await s.cli(e, r);
448
+ i = await s.cli(e, t);
449
449
  } catch (o) {
450
450
  throw n(), o;
451
451
  }
@@ -463,8 +463,8 @@ class PHPWorker {
463
463
  * @returns A PHP instance with a consistent chroot.
464
464
  */
465
465
  async acquirePHPInstance() {
466
- const { php: e, reap: r } = await _private.get(this).requestHandler.instanceManager.acquirePHPInstance();
467
- return this.chroot !== null && e.chdir(this.chroot), this.registerWorkerListeners(e), { php: e, reap: r };
466
+ const { php: e, reap: t } = await _private.get(this).requestHandler.instanceManager.acquirePHPInstance();
467
+ return this.chroot !== null && e.chdir(this.chroot), this.registerWorkerListeners(e), { php: e, reap: t };
468
468
  }
469
469
  /** @inheritDoc @php-wasm/universal!/PHP.setSapiName */
470
470
  setSapiName(e) {
@@ -487,16 +487,16 @@ class PHPWorker {
487
487
  return _private.get(this).php.readFileAsBuffer(e);
488
488
  }
489
489
  /** @inheritDoc @php-wasm/universal!/PHP.writeFile */
490
- writeFile(e, r) {
491
- return _private.get(this).php.writeFile(e, r);
490
+ writeFile(e, t) {
491
+ return _private.get(this).php.writeFile(e, t);
492
492
  }
493
493
  /** @inheritDoc @php-wasm/universal!/PHP.unlink */
494
494
  unlink(e) {
495
495
  return _private.get(this).php.unlink(e);
496
496
  }
497
497
  /** @inheritDoc @php-wasm/universal!/PHP.listFiles */
498
- listFiles(e, r) {
499
- return _private.get(this).php.listFiles(e, r);
498
+ listFiles(e, t) {
499
+ return _private.get(this).php.listFiles(e, t);
500
500
  }
501
501
  /** @inheritDoc @php-wasm/universal!/PHP.isDir */
502
502
  isDir(e) {
@@ -514,39 +514,39 @@ class PHPWorker {
514
514
  onMessage(e) {
515
515
  return this.onMessageListeners.push(e), async () => {
516
516
  this.onMessageListeners = this.onMessageListeners.filter(
517
- (r) => r !== e
517
+ (t) => t !== e
518
518
  );
519
519
  };
520
520
  }
521
521
  /** @inheritDoc @php-wasm/universal!/PHP.defineConstant */
522
- defineConstant(e, r) {
523
- _private.get(this).php.defineConstant(e, r);
522
+ defineConstant(e, t) {
523
+ _private.get(this).php.defineConstant(e, t);
524
524
  }
525
525
  /** @inheritDoc @php-wasm/universal!/PHP.addEventListener */
526
- addEventListener(e, r) {
527
- u(this, x).has(e) || u(this, x).set(e, /* @__PURE__ */ new Set()), u(this, x).get(e).add(r);
526
+ addEventListener(e, t) {
527
+ u(this, x).has(e) || u(this, x).set(e, /* @__PURE__ */ new Set()), u(this, x).get(e).add(t);
528
528
  }
529
529
  /**
530
530
  * Removes an event listener for a PHP event.
531
531
  * @param eventType - The type of event to remove the listener from.
532
532
  * @param listener - The listener function to be removed.
533
533
  */
534
- removeEventListener(e, r) {
534
+ removeEventListener(e, t) {
535
535
  var s;
536
- (s = u(this, x).get(e)) == null || s.delete(r);
536
+ (s = u(this, x).get(e)) == null || s.delete(t);
537
537
  }
538
538
  dispatchEvent(e) {
539
- const r = u(this, x).get(e.type);
540
- if (r)
541
- for (const s of r)
539
+ const t = u(this, x).get(e.type);
540
+ if (t)
541
+ for (const s of t)
542
542
  s(e);
543
543
  }
544
544
  registerWorkerListeners(e) {
545
- e.addEventListener("*", async (r) => {
546
- this.dispatchEvent(r);
547
- }), e.onMessage(async (r) => {
545
+ e.addEventListener("*", async (t) => {
546
+ this.dispatchEvent(t);
547
+ }), e.onMessage(async (t) => {
548
548
  for (const s of this.onMessageListeners) {
549
- const n = await s(r);
549
+ const n = await s(t);
550
550
  if (n)
551
551
  return n;
552
552
  }
@@ -559,55 +559,55 @@ class PHPWorker {
559
559
  }
560
560
  }
561
561
  x = new WeakMap();
562
- function isExitCode(t) {
563
- return t instanceof Error ? (t == null ? void 0 : t.name) === "ExitStatus" && "status" in t : !1;
562
+ function isExitCode(r) {
563
+ return r instanceof Error ? (r == null ? void 0 : r.name) === "ExitStatus" && "status" in r : !1;
564
564
  }
565
565
  const RuntimeId = Symbol("RuntimeId"), loadedRuntimes = /* @__PURE__ */ new Map();
566
566
  let lastRuntimeId = 0;
567
- async function loadPHPRuntime(t, ...e) {
568
- const r = Object.assign({}, ...e), [s, n, i] = makePromise(), o = t.init(currentJsRuntime, {
569
- onAbort(a) {
570
- i(a), logger.error(a);
567
+ async function loadPHPRuntime(r, ...e) {
568
+ const t = Object.assign({}, ...e), [s, n, i] = makePromise(), o = r.init(currentJsRuntime, {
569
+ onAbort(c) {
570
+ i(c), logger.error(c);
571
571
  },
572
572
  ENV: {},
573
573
  // Emscripten sometimes prepends a '/' to the path, which
574
574
  // breaks vite dev mode. An identity `locateFile` function
575
575
  // fixes it.
576
- locateFile: (a) => a,
577
- ...r,
576
+ locateFile: (c) => c,
577
+ ...t,
578
578
  noInitialRun: !0,
579
579
  onRuntimeInitialized() {
580
- r.onRuntimeInitialized && r.onRuntimeInitialized(o), n();
580
+ t.onRuntimeInitialized && t.onRuntimeInitialized(o), n();
581
581
  }
582
582
  });
583
583
  await s;
584
- const c = ++lastRuntimeId;
585
- return o.FS, o.id = c, o.originalExit = o._exit, o._exit = function(a) {
586
- return o.outboundNetworkProxyServer && (o.outboundNetworkProxyServer.close(), o.outboundNetworkProxyServer.closeAllConnections()), loadedRuntimes.delete(c), o.originalExit(a);
587
- }, o[RuntimeId] = c, loadedRuntimes.set(c, o), c;
584
+ const a = ++lastRuntimeId;
585
+ return o.FS, o.id = a, o.originalExit = o._exit, o._exit = function(c) {
586
+ return o.outboundNetworkProxyServer && (o.outboundNetworkProxyServer.close(), o.outboundNetworkProxyServer.closeAllConnections()), loadedRuntimes.delete(a), o.originalExit(c);
587
+ }, o[RuntimeId] = a, loadedRuntimes.set(a, o), a;
588
588
  }
589
- function popLoadedRuntime(t, {
589
+ function popLoadedRuntime(r, {
590
590
  dangerouslyKeepTheRuntimeInTheMap: e = !1
591
591
  } = {}) {
592
592
  var s;
593
- const r = loadedRuntimes.get(t);
594
- if (!r)
595
- throw new Error(`Runtime with id ${t} not found`);
593
+ const t = loadedRuntimes.get(r);
594
+ if (!t)
595
+ throw new Error(`Runtime with id ${r} not found`);
596
596
  if (e) {
597
597
  if (!((s = process == null ? void 0 : process.env) != null && s.TEST))
598
598
  throw new Error("Cannot pop runtime in non-test environment");
599
- return r;
599
+ return t;
600
600
  }
601
- return loadedRuntimes.delete(t), r;
601
+ return loadedRuntimes.delete(r), t;
602
602
  }
603
603
  const currentJsRuntime = function() {
604
- var t;
605
- return typeof process < "u" && ((t = process.release) == null ? void 0 : t.name) === "node" ? "NODE" : typeof window < "u" ? "WEB" : typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope ? "WORKER" : "NODE";
604
+ var r;
605
+ return typeof process < "u" && ((r = process.release) == null ? void 0 : r.name) === "node" ? "NODE" : typeof window < "u" ? "WEB" : typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope ? "WORKER" : "NODE";
606
606
  }(), makePromise = () => {
607
- const t = [], e = new Promise((r, s) => {
608
- t.push(r, s);
607
+ const r = [], e = new Promise((t, s) => {
608
+ r.push(t, s);
609
609
  });
610
- return t.unshift(e), t;
610
+ return r.unshift(e), r;
611
611
  }, responseTexts = {
612
612
  500: "Internal Server Error",
613
613
  502: "Bad Gateway",
@@ -624,8 +624,8 @@ const currentJsRuntime = function() {
624
624
  200: "OK"
625
625
  };
626
626
  class StreamedPHPResponse {
627
- constructor(e, r, s, n) {
628
- this.parsedHeaders = null, this.cachedStdoutBytes = null, this.cachedStderrText = null, this.headersStream = e, this.stdout = r, this.stderr = s, this.exitCode = n;
627
+ constructor(e, t, s, n) {
628
+ this.parsedHeaders = null, this.cachedStdoutBytes = null, this.cachedStderrText = null, this.headersStream = e, this.stdout = t, this.stderr = s, this.exitCode = n;
629
629
  }
630
630
  /**
631
631
  * True if the response is successful (HTTP status code 200-399),
@@ -660,7 +660,7 @@ class StreamedPHPResponse {
660
660
  */
661
661
  get httpStatusCode() {
662
662
  return this.getParsedHeaders().then((e) => e.httpStatusCode).then((e) => e !== void 0 ? e : this.getParsedHeaders().then(
663
- (r) => r.httpStatusCode,
663
+ (t) => t.httpStatusCode,
664
664
  () => 200
665
665
  )).catch(() => 500);
666
666
  }
@@ -688,62 +688,62 @@ class StreamedPHPResponse {
688
688
  return this.parsedHeaders || (this.parsedHeaders = parseHeadersStream(this.headersStream)), await this.parsedHeaders;
689
689
  }
690
690
  }
691
- async function parseHeadersStream(t) {
692
- const e = await streamToText(t);
693
- let r;
691
+ async function parseHeadersStream(r) {
692
+ const e = await streamToText(r);
693
+ let t;
694
694
  try {
695
- r = JSON.parse(e);
695
+ t = JSON.parse(e);
696
696
  } catch {
697
697
  return { headers: {}, httpStatusCode: 200 };
698
698
  }
699
699
  const s = {};
700
- for (const n of r.headers) {
700
+ for (const n of t.headers) {
701
701
  if (!n.includes(": "))
702
702
  continue;
703
- const i = n.indexOf(": "), o = n.substring(0, i).toLowerCase(), c = n.substring(i + 2);
704
- o in s || (s[o] = []), s[o].push(c);
703
+ const i = n.indexOf(": "), o = n.substring(0, i).toLowerCase(), a = n.substring(i + 2);
704
+ o in s || (s[o] = []), s[o].push(a);
705
705
  }
706
706
  return {
707
707
  headers: s,
708
- httpStatusCode: r.status
708
+ httpStatusCode: t.status
709
709
  };
710
710
  }
711
- async function streamToText(t) {
712
- const e = t.pipeThrough(new TextDecoderStream()).getReader(), r = [];
711
+ async function streamToText(r) {
712
+ const e = r.pipeThrough(new TextDecoderStream()).getReader(), t = [];
713
713
  for (; ; ) {
714
714
  const { done: s, value: n } = await e.read();
715
715
  if (s)
716
- return r.join("");
717
- n && r.push(n);
716
+ return t.join("");
717
+ n && t.push(n);
718
718
  }
719
719
  }
720
- async function streamToBytes(t) {
721
- const e = t.getReader(), r = [];
720
+ async function streamToBytes(r) {
721
+ const e = r.getReader(), t = [];
722
722
  for (; ; ) {
723
723
  const { done: s, value: n } = await e.read();
724
724
  if (s) {
725
- const i = r.reduce(
726
- (a, l) => a + l.byteLength,
725
+ const i = t.reduce(
726
+ (c, l) => c + l.byteLength,
727
727
  0
728
728
  ), o = new Uint8Array(i);
729
- let c = 0;
730
- for (const a of r)
731
- o.set(a, c), c += a.byteLength;
729
+ let a = 0;
730
+ for (const c of t)
731
+ o.set(c, a), a += c.byteLength;
732
732
  return o;
733
733
  }
734
- n && r.push(n);
734
+ n && t.push(n);
735
735
  }
736
736
  }
737
737
  class PHPResponse {
738
- constructor(e, r, s, n = "", i = 0) {
739
- this.httpStatusCode = e, this.headers = r, this.bytes = s, this.exitCode = i, this.errors = n;
738
+ constructor(e, t, s, n = "", i = 0) {
739
+ this.httpStatusCode = e, this.headers = t, this.bytes = s, this.exitCode = i, this.errors = n;
740
740
  }
741
- static forHttpCode(e, r = "") {
741
+ static forHttpCode(e, t = "") {
742
742
  return new PHPResponse(
743
743
  e,
744
744
  {},
745
745
  new TextEncoder().encode(
746
- r || responseTexts[e] || ""
746
+ t || responseTexts[e] || ""
747
747
  )
748
748
  );
749
749
  }
@@ -804,8 +804,8 @@ class ErrorEvent2 extends (_a = Event, _a) {
804
804
  * @param options A dictionary object that allows for setting
805
805
  * attributes via object members of the same name.
806
806
  */
807
- constructor(e, r = {}) {
808
- super(e), this[kError] = r.error === void 0 ? null : r.error, this[kMessage] = r.message === void 0 ? "" : r.message;
807
+ constructor(e, t = {}) {
808
+ super(e), this[kError] = t.error === void 0 ? null : t.error, this[kMessage] = t.message === void 0 ? "" : t.message;
809
809
  }
810
810
  get error() {
811
811
  return this[kError];
@@ -821,17 +821,17 @@ class UnhandledRejectionsTarget extends EventTarget {
821
821
  constructor() {
822
822
  super(...arguments), this.listenersCount = 0;
823
823
  }
824
- addEventListener(e, r, s) {
824
+ addEventListener(e, t, s) {
825
825
  ++this.listenersCount, super.addEventListener(
826
826
  e,
827
- r,
827
+ t,
828
828
  s
829
829
  );
830
830
  }
831
- removeEventListener(e, r, s) {
831
+ removeEventListener(e, t, s) {
832
832
  --this.listenersCount, super.removeEventListener(
833
833
  e,
834
- r,
834
+ t,
835
835
  s
836
836
  );
837
837
  }
@@ -839,29 +839,29 @@ class UnhandledRejectionsTarget extends EventTarget {
839
839
  return this.listenersCount > 0;
840
840
  }
841
841
  }
842
- function improveWASMErrorReporting(t) {
842
+ function improveWASMErrorReporting(r) {
843
843
  const e = new UnhandledRejectionsTarget();
844
- for (const r in t.wasmExports)
845
- if (typeof t.wasmExports[r] == "function") {
846
- const s = t.wasmExports[r];
847
- t.wasmExports[r] = function(...n) {
844
+ for (const t in r.wasmExports)
845
+ if (typeof r.wasmExports[t] == "function") {
846
+ const s = r.wasmExports[t];
847
+ r.wasmExports[t] = function(...n) {
848
848
  var i;
849
849
  try {
850
850
  return s(...n);
851
851
  } catch (o) {
852
852
  if (!(o instanceof Error))
853
853
  throw o;
854
- t.lastAsyncifyStackSource && (o.cause = t.lastAsyncifyStackSource);
855
- const c = clarifyErrorMessage(
854
+ r.lastAsyncifyStackSource && (o.cause = r.lastAsyncifyStackSource);
855
+ const a = clarifyErrorMessage(
856
856
  o,
857
- (i = t.lastAsyncifyStackSource) == null ? void 0 : i.stack
857
+ (i = r.lastAsyncifyStackSource) == null ? void 0 : i.stack
858
858
  );
859
859
  if (e.hasListeners()) {
860
- o.message = c;
861
- const a = new ErrorEvent("error", { error: o });
862
- throw e.dispatchEvent(a), o;
860
+ o.message = a;
861
+ const c = new ErrorEvent("error", { error: o });
862
+ throw e.dispatchEvent(c), o;
863
863
  }
864
- throw (!isExitCode(o) || o.status !== 0) && showCriticalErrorBox(c), o;
864
+ throw (!isExitCode(o) || o.status !== 0) && showCriticalErrorBox(a), o;
865
865
  }
866
866
  };
867
867
  }
@@ -871,10 +871,10 @@ let functionsMaybeMissingFromAsyncify = [];
871
871
  function getFunctionsMaybeMissingFromAsyncify() {
872
872
  return functionsMaybeMissingFromAsyncify;
873
873
  }
874
- function clarifyErrorMessage(t, e) {
875
- if (t.message === "unreachable") {
876
- let r = UNREACHABLE_ERROR;
877
- e || (r += `
874
+ function clarifyErrorMessage(r, e) {
875
+ if (r.message === "unreachable") {
876
+ let t = UNREACHABLE_ERROR;
877
+ e || (t += `
878
878
 
879
879
  This stack trace is lacking. For a better one initialize
880
880
  the PHP runtime with debug: true, e.g. loadNodeRuntime('8.1', { emscriptenOptions: { debug: true } }).
@@ -883,7 +883,7 @@ the PHP runtime with debug: true, e.g. loadNodeRuntime('8.1', { emscriptenOption
883
883
  const s = new Set(
884
884
  extractPHPFunctionsFromStack(e || "")
885
885
  );
886
- let n = t;
886
+ let n = r;
887
887
  do {
888
888
  for (const i of extractPHPFunctionsFromStack(
889
889
  n.stack || ""
@@ -893,12 +893,12 @@ the PHP runtime with debug: true, e.g. loadNodeRuntime('8.1', { emscriptenOption
893
893
  } while (n);
894
894
  functionsMaybeMissingFromAsyncify = Array.from(s);
895
895
  for (const i of s)
896
- r += ` * ${i}
896
+ t += ` * ${i}
897
897
  `;
898
- return r += `Original error message: ${t.message}
899
- `, r;
898
+ return t += `Original error message: ${r.message}
899
+ `, t;
900
900
  }
901
- return t.message;
901
+ return r.message;
902
902
  }
903
903
  const UNREACHABLE_ERROR = `
904
904
  "unreachable" WASM instruction executed.
@@ -926,29 +926,29 @@ CLI option:
926
926
 
927
927
  `, redBg = "\x1B[41m", bold = "\x1B[1m", reset = "\x1B[0m", eol = "\x1B[K";
928
928
  let logged = !1;
929
- function showCriticalErrorBox(t) {
930
- if (!logged && (logged = !0, !(t != null && t.trim().startsWith("Program terminated with exit")))) {
929
+ function showCriticalErrorBox(r) {
930
+ if (!logged && (logged = !0, !(r != null && r.trim().startsWith("Program terminated with exit")))) {
931
931
  logger.log(`${redBg}
932
932
  ${eol}
933
933
  ${bold} WASM ERROR${reset}${redBg}`);
934
- for (const e of t.split(`
934
+ for (const e of r.split(`
935
935
  `))
936
936
  logger.log(`${eol} ${e} `);
937
937
  logger.log(`${reset}`);
938
938
  }
939
939
  }
940
- function extractPHPFunctionsFromStack(t) {
940
+ function extractPHPFunctionsFromStack(r) {
941
941
  try {
942
- const e = t.split(`
943
- `).slice(1).map((r) => {
944
- const s = r.trim().substring(3).split(" ");
942
+ const e = r.split(`
943
+ `).slice(1).map((t) => {
944
+ const s = t.trim().substring(3).split(" ");
945
945
  return {
946
946
  fn: s.length >= 2 ? s[0] : "<unknown>",
947
- isWasm: r.includes("wasm:/")
947
+ isWasm: t.includes("wasm:/")
948
948
  };
949
949
  }).filter(
950
- ({ fn: r, isWasm: s }) => s && !r.startsWith("dynCall_") && !r.startsWith("invoke_")
951
- ).map(({ fn: r }) => r);
950
+ ({ fn: t, isWasm: s }) => s && !t.startsWith("dynCall_") && !t.startsWith("invoke_")
951
+ ).map(({ fn: t }) => t);
952
952
  return Array.from(new Set(e));
953
953
  } catch {
954
954
  return [];
@@ -956,12 +956,12 @@ function extractPHPFunctionsFromStack(t) {
956
956
  }
957
957
  const STRING = "string", NUMBER = "number", __private__dont__use = Symbol("__private__dont__use");
958
958
  class PHPExecutionFailureError extends Error {
959
- constructor(e, r, s) {
960
- super(e), this.response = r, this.source = s;
959
+ constructor(e, t, s) {
960
+ super(e), this.response = t, this.source = s;
961
961
  }
962
962
  }
963
963
  const PHP_INI_PATH = "/internal/shared/php.ini", AUTO_PREPEND_SCRIPT = "/internal/shared/auto_prepend_file.php", OPCACHE_FILE_FOLDER = "/internal/shared/opcache";
964
- var M, H, T, v, F, k, w, h, V, G, J, Y, Q, X, K, Z, q, ee, D, W;
964
+ var M, R, b, S, T, H, w, h, V, G, J, Y, X, Q, K, Z, D, ee, W, j;
965
965
  class PHP {
966
966
  /**
967
967
  * Initializes a PHP runtime.
@@ -970,17 +970,17 @@ class PHP {
970
970
  * @param PHPRuntime - Optional. PHP Runtime ID as initialized by loadPHPRuntime.
971
971
  * @param requestHandlerOptions - Optional. Options for the PHPRequestHandler. If undefined, no request handler will be initialized.
972
972
  */
973
- constructor(t) {
973
+ constructor(r) {
974
974
  y(this, h);
975
975
  y(this, M);
976
- y(this, H, !1);
977
- y(this, T, null);
978
- y(this, v, /* @__PURE__ */ new Map([
976
+ y(this, R, !1);
977
+ y(this, b, null);
978
+ y(this, S, /* @__PURE__ */ new Map([
979
979
  // Listen to all events
980
980
  ["*", /* @__PURE__ */ new Set()]
981
981
  ]));
982
- y(this, F, []);
983
- y(this, k, {});
982
+ y(this, T, []);
983
+ y(this, H, {});
984
984
  y(this, w, {
985
985
  enabled: !1,
986
986
  recreateRuntime: () => 0,
@@ -988,7 +988,7 @@ class PHP {
988
988
  maxRequests: 400,
989
989
  requestsMade: 0
990
990
  });
991
- this.semaphore = new Semaphore({ concurrency: 1 }), t !== void 0 && this.initializeRuntime(t), this.addEventListener("request.error", (e) => {
991
+ this.semaphore = new Semaphore({ concurrency: 1 }), r !== void 0 && this.initializeRuntime(r), this.addEventListener("request.error", (e) => {
992
992
  e.source === "php-wasm" && (u(this, w).needsRotating = !0);
993
993
  });
994
994
  }
@@ -997,26 +997,26 @@ class PHP {
997
997
  * @param eventType - The type of event to listen for.
998
998
  * @param listener - The listener function to be called when the event is triggered.
999
999
  */
1000
- addEventListener(t, e) {
1001
- u(this, v).has(t) || u(this, v).set(t, /* @__PURE__ */ new Set()), u(this, v).get(t).add(e);
1000
+ addEventListener(r, e) {
1001
+ u(this, S).has(r) || u(this, S).set(r, /* @__PURE__ */ new Set()), u(this, S).get(r).add(e);
1002
1002
  }
1003
1003
  /**
1004
1004
  * Removes an event listener for a PHP event.
1005
1005
  * @param eventType - The type of event to remove the listener from.
1006
1006
  * @param listener - The listener function to be removed.
1007
1007
  */
1008
- removeEventListener(t, e) {
1009
- var r;
1010
- (r = u(this, v).get(t)) == null || r.delete(e);
1008
+ removeEventListener(r, e) {
1009
+ var t;
1010
+ (t = u(this, S).get(r)) == null || t.delete(e);
1011
1011
  }
1012
- dispatchEvent(t) {
1012
+ dispatchEvent(r) {
1013
1013
  const e = [
1014
- ...u(this, v).get(t.type) || [],
1015
- ...u(this, v).get("*") || []
1014
+ ...u(this, S).get(r.type) || [],
1015
+ ...u(this, S).get("*") || []
1016
1016
  ];
1017
1017
  if (e)
1018
- for (const r of e)
1019
- r(t);
1018
+ for (const t of e)
1019
+ t(r);
1020
1020
  }
1021
1021
  /**
1022
1022
  * Listens to message sent by the PHP code.
@@ -1057,10 +1057,10 @@ class PHP {
1057
1057
  *
1058
1058
  * @param listener Callback function to handle the message.
1059
1059
  */
1060
- onMessage(t) {
1061
- return u(this, F).push(t), async () => {
1062
- _(this, F, u(this, F).filter(
1063
- (e) => e !== t
1060
+ onMessage(r) {
1061
+ return u(this, T).push(r), async () => {
1062
+ g(this, T, u(this, T).filter(
1063
+ (e) => e !== r
1064
1064
  ));
1065
1065
  };
1066
1066
  }
@@ -1076,17 +1076,17 @@ class PHP {
1076
1076
  return this.requestHandler.documentRoot;
1077
1077
  }
1078
1078
  /** @deprecated Use PHPRequestHandler instead. */
1079
- pathToInternalUrl(t) {
1080
- return this.requestHandler.pathToInternalUrl(t);
1079
+ pathToInternalUrl(r) {
1080
+ return this.requestHandler.pathToInternalUrl(r);
1081
1081
  }
1082
1082
  /** @deprecated Use PHPRequestHandler instead. */
1083
- internalUrlToPath(t) {
1084
- return this.requestHandler.internalUrlToPath(t);
1083
+ internalUrlToPath(r) {
1084
+ return this.requestHandler.internalUrlToPath(r);
1085
1085
  }
1086
- initializeRuntime(t) {
1086
+ initializeRuntime(r) {
1087
1087
  if (this[__private__dont__use])
1088
1088
  throw new Error("PHP runtime already initialized.");
1089
- const e = popLoadedRuntime(t);
1089
+ const e = popLoadedRuntime(r);
1090
1090
  if (!e)
1091
1091
  throw new Error("Invalid PHP runtime id.");
1092
1092
  if (this[__private__dont__use] = e, this[__private__dont__use].ccall(
@@ -1095,7 +1095,7 @@ class PHP {
1095
1095
  ["string"],
1096
1096
  [PHP_INI_PATH]
1097
1097
  ), !this.fileExists(PHP_INI_PATH)) {
1098
- const r = [
1098
+ const t = [
1099
1099
  // OPCache
1100
1100
  "opcache.enable = 1",
1101
1101
  "opcache.enable_cli = 1",
@@ -1130,7 +1130,7 @@ class PHP {
1130
1130
  "output_buffering = 0",
1131
1131
  "max_execution_time = 0",
1132
1132
  "max_input_time = -1",
1133
- ...r
1133
+ ...t
1134
1134
  ].join(`
1135
1135
  `)
1136
1136
  );
@@ -1152,29 +1152,29 @@ class PHP {
1152
1152
  require_once $file;
1153
1153
  }
1154
1154
  `
1155
- ), e.onMessage = async (r) => {
1156
- for (const s of u(this, F)) {
1157
- const n = await s(r);
1155
+ ), e.onMessage = async (t) => {
1156
+ for (const s of u(this, T)) {
1157
+ const n = await s(t);
1158
1158
  if (n)
1159
1159
  return n;
1160
1160
  }
1161
1161
  return "";
1162
- }, _(this, T, improveWASMErrorReporting(e)), this.dispatchEvent({
1162
+ }, g(this, b, improveWASMErrorReporting(e)), this.dispatchEvent({
1163
1163
  type: "runtime.initialized"
1164
1164
  });
1165
1165
  }
1166
1166
  /** @inheritDoc */
1167
- async setSapiName(t) {
1167
+ async setSapiName(r) {
1168
1168
  if (this[__private__dont__use].ccall(
1169
1169
  "wasm_set_sapi_name",
1170
1170
  NUMBER,
1171
1171
  [STRING],
1172
- [t]
1172
+ [r]
1173
1173
  ) !== 0)
1174
1174
  throw new Error(
1175
1175
  "Could not set SAPI name. This can only be done before the PHP WASM module is initialized.Did you already dispatch any requests?"
1176
1176
  );
1177
- _(this, M, t);
1177
+ g(this, M, r);
1178
1178
  }
1179
1179
  /**
1180
1180
  * Changes the current working directory in the PHP filesystem.
@@ -1184,8 +1184,8 @@ class PHP {
1184
1184
  *
1185
1185
  * @param path - The new working directory.
1186
1186
  */
1187
- chdir(t) {
1188
- this[__private__dont__use].FS.chdir(t);
1187
+ chdir(r) {
1188
+ this[__private__dont__use].FS.chdir(r);
1189
1189
  }
1190
1190
  /**
1191
1191
  * Gets the current working directory in the PHP filesystem.
@@ -1200,19 +1200,19 @@ class PHP {
1200
1200
  * @param path - The path to the file or directory.
1201
1201
  * @param mode - The new permissions.
1202
1202
  */
1203
- chmod(t, e) {
1204
- this[__private__dont__use].FS.chmod(t, e);
1203
+ chmod(r, e) {
1204
+ this[__private__dont__use].FS.chmod(r, e);
1205
1205
  }
1206
1206
  /**
1207
1207
  * Do not use. Use new PHPRequestHandler() instead.
1208
1208
  * @deprecated
1209
1209
  */
1210
- async request(t) {
1210
+ async request(r) {
1211
1211
  if (logger.debug(
1212
1212
  "PHP.request() is deprecated. Please use new PHPRequestHandler() instead."
1213
1213
  ), !this.requestHandler)
1214
1214
  throw new Error("No request handler available.");
1215
- return this.requestHandler.request(t);
1215
+ return this.requestHandler.request(r);
1216
1216
  }
1217
1217
  /**
1218
1218
  * Runs PHP code.
@@ -1286,21 +1286,21 @@ class PHP {
1286
1286
  * @deprecated Use stream() instead.
1287
1287
  * @param request - PHP runtime options.
1288
1288
  */
1289
- async run(t) {
1290
- const e = await this.runStream(t), r = await PHPResponse.fromStreamedResponse(e);
1291
- if (r.exitCode !== 0)
1289
+ async run(r) {
1290
+ const e = await this.runStream(r), t = await PHPResponse.fromStreamedResponse(e);
1291
+ if (t.exitCode !== 0)
1292
1292
  throw new PHPExecutionFailureError(
1293
- `PHP.run() failed with exit code ${r.exitCode}.
1293
+ `PHP.run() failed with exit code ${t.exitCode}.
1294
1294
 
1295
1295
  === Stdout ===
1296
- ${r.text}
1296
+ ${t.text}
1297
1297
 
1298
1298
  === Stderr ===
1299
- ${r.errors}`,
1300
- r,
1299
+ ${t.errors}`,
1300
+ t,
1301
1301
  "request"
1302
1302
  );
1303
- return r;
1303
+ return t;
1304
1304
  }
1305
1305
  /**
1306
1306
  * Runs PHP code and returns a StreamedPHPResponse object that can be used to
@@ -1393,11 +1393,11 @@ class PHP {
1393
1393
  * @param request - PHP runtime options.
1394
1394
  * @returns A StreamedPHPResponse object.
1395
1395
  */
1396
- async runStream(t) {
1396
+ async runStream(r) {
1397
1397
  const e = await this.semaphore.acquire();
1398
- let r;
1399
- const s = m(this, h, W).call(this, async () => {
1400
- if (u(this, H) || (await this[__private__dont__use].ccall(
1398
+ let t;
1399
+ const s = m(this, h, j).call(this, async () => {
1400
+ if (u(this, R) || (await this[__private__dont__use].ccall(
1401
1401
  "php_wasm_init",
1402
1402
  null,
1403
1403
  [],
@@ -1405,26 +1405,26 @@ class PHP {
1405
1405
  {
1406
1406
  isAsync: !0
1407
1407
  }
1408
- ), _(this, H, !0)), t.scriptPath && !this.fileExists(t.scriptPath))
1408
+ ), g(this, R, !0)), r.scriptPath && !this.fileExists(r.scriptPath))
1409
1409
  throw new Error(
1410
- `The script path "${t.scriptPath}" does not exist.`
1410
+ `The script path "${r.scriptPath}" does not exist.`
1411
1411
  );
1412
- m(this, h, G).call(this, t.relativeUri || ""), m(this, h, X).call(this, t.method || "GET");
1413
- const i = normalizeHeaders(t.headers || {}), o = i.host || "example.com:443", c = m(this, h, Q).call(this, o, t.protocol || "http");
1414
- if (m(this, h, J).call(this, o), m(this, h, Y).call(this, c), m(this, h, K).call(this, i), t.body && (r = m(this, h, Z).call(this, t.body)), typeof t.code == "string")
1415
- this.writeFile("/internal/eval.php", t.code), m(this, h, q).call(this, "/internal/eval.php");
1416
- else if (typeof t.scriptPath == "string")
1417
- m(this, h, q).call(this, t.scriptPath || "");
1412
+ m(this, h, G).call(this, r.relativeUri || ""), m(this, h, Q).call(this, r.method || "GET");
1413
+ const i = normalizeHeaders(r.headers || {}), o = i.host || "example.com:443", a = m(this, h, X).call(this, o, r.protocol || "http");
1414
+ if (m(this, h, J).call(this, o), m(this, h, Y).call(this, a), m(this, h, K).call(this, i), r.body && (t = m(this, h, Z).call(this, r.body)), typeof r.code == "string")
1415
+ this.writeFile("/internal/eval.php", r.code), m(this, h, D).call(this, "/internal/eval.php");
1416
+ else if (typeof r.scriptPath == "string")
1417
+ m(this, h, D).call(this, r.scriptPath || "");
1418
1418
  else
1419
1419
  throw new TypeError(
1420
1420
  "The request object must have either a `code` or a `scriptPath` property."
1421
1421
  );
1422
- const a = m(this, h, V).call(this, t.$_SERVER, i, c);
1423
- for (const d in a)
1424
- m(this, h, ee).call(this, d, a[d]);
1425
- const l = t.env || {};
1422
+ const c = m(this, h, V).call(this, r.$_SERVER, i, a);
1423
+ for (const d in c)
1424
+ m(this, h, ee).call(this, d, c[d]);
1425
+ const l = r.env || {};
1426
1426
  for (const d in l)
1427
- m(this, h, D).call(this, d, l[d]);
1427
+ m(this, h, W).call(this, d, l[d]);
1428
1428
  return await this[__private__dont__use].ccall(
1429
1429
  "wasm_sapi_handle_request",
1430
1430
  NUMBER,
@@ -1433,9 +1433,9 @@ class PHP {
1433
1433
  { async: !0 }
1434
1434
  );
1435
1435
  }), n = () => {
1436
- if (r)
1436
+ if (t)
1437
1437
  try {
1438
- this[__private__dont__use].free(r);
1438
+ this[__private__dont__use].free(t);
1439
1439
  } catch (i) {
1440
1440
  logger.error(i);
1441
1441
  }
@@ -1460,10 +1460,10 @@ class PHP {
1460
1460
  * @param key - The name of the constant.
1461
1461
  * @param value - The value of the constant.
1462
1462
  */
1463
- defineConstant(t, e) {
1464
- let r = {};
1463
+ defineConstant(r, e) {
1464
+ let t = {};
1465
1465
  try {
1466
- r = JSON.parse(
1466
+ t = JSON.parse(
1467
1467
  this.fileExists("/internal/shared/consts.json") && this.readFileAsText("/internal/shared/consts.json") || "{}"
1468
1468
  );
1469
1469
  } catch {
@@ -1471,8 +1471,8 @@ class PHP {
1471
1471
  this.writeFile(
1472
1472
  "/internal/shared/consts.json",
1473
1473
  JSON.stringify({
1474
- ...r,
1475
- [t]: e
1474
+ ...t,
1475
+ [r]: e
1476
1476
  })
1477
1477
  );
1478
1478
  }
@@ -1483,15 +1483,15 @@ class PHP {
1483
1483
  *
1484
1484
  * @param path - The directory path to create.
1485
1485
  */
1486
- mkdir(t) {
1487
- const e = FSHelpers.mkdir(this[__private__dont__use].FS, t);
1486
+ mkdir(r) {
1487
+ const e = FSHelpers.mkdir(this[__private__dont__use].FS, r);
1488
1488
  return this.dispatchEvent({ type: "filesystem.write" }), e;
1489
1489
  }
1490
1490
  /**
1491
1491
  * @deprecated Use mkdir instead.
1492
1492
  */
1493
- mkdirTree(t) {
1494
- return FSHelpers.mkdir(this[__private__dont__use].FS, t);
1493
+ mkdirTree(r) {
1494
+ return FSHelpers.mkdir(this[__private__dont__use].FS, r);
1495
1495
  }
1496
1496
  /**
1497
1497
  * Reads a file from the PHP filesystem and returns it as a string.
@@ -1500,8 +1500,8 @@ class PHP {
1500
1500
  * @param path - The file path to read.
1501
1501
  * @returns The file contents.
1502
1502
  */
1503
- readFileAsText(t) {
1504
- return FSHelpers.readFileAsText(this[__private__dont__use].FS, t);
1503
+ readFileAsText(r) {
1504
+ return FSHelpers.readFileAsText(this[__private__dont__use].FS, r);
1505
1505
  }
1506
1506
  /**
1507
1507
  * Reads a file from the PHP filesystem and returns it as an array buffer.
@@ -1510,8 +1510,8 @@ class PHP {
1510
1510
  * @param path - The file path to read.
1511
1511
  * @returns The file contents.
1512
1512
  */
1513
- readFileAsBuffer(t) {
1514
- return FSHelpers.readFileAsBuffer(this[__private__dont__use].FS, t);
1513
+ readFileAsBuffer(r) {
1514
+ return FSHelpers.readFileAsBuffer(this[__private__dont__use].FS, r);
1515
1515
  }
1516
1516
  /**
1517
1517
  * Overwrites data in a file in the PHP filesystem.
@@ -1520,13 +1520,13 @@ class PHP {
1520
1520
  * @param path - The file path to write to.
1521
1521
  * @param data - The data to write to the file.
1522
1522
  */
1523
- writeFile(t, e) {
1524
- const r = FSHelpers.writeFile(
1523
+ writeFile(r, e) {
1524
+ const t = FSHelpers.writeFile(
1525
1525
  this[__private__dont__use].FS,
1526
- t,
1526
+ r,
1527
1527
  e
1528
1528
  );
1529
- return this.dispatchEvent({ type: "filesystem.write" }), r;
1529
+ return this.dispatchEvent({ type: "filesystem.write" }), t;
1530
1530
  }
1531
1531
  /**
1532
1532
  * Removes a file from the PHP filesystem.
@@ -1534,8 +1534,8 @@ class PHP {
1534
1534
  * @throws {@link @php-wasm/universal:ErrnoError} – If the file doesn't exist.
1535
1535
  * @param path - The file path to remove.
1536
1536
  */
1537
- unlink(t) {
1538
- const e = FSHelpers.unlink(this[__private__dont__use].FS, t);
1537
+ unlink(r) {
1538
+ const e = FSHelpers.unlink(this[__private__dont__use].FS, r);
1539
1539
  return this.dispatchEvent({ type: "filesystem.write" }), e;
1540
1540
  }
1541
1541
  /**
@@ -1545,13 +1545,13 @@ class PHP {
1545
1545
  * @param oldPath The path to rename.
1546
1546
  * @param newPath The new path.
1547
1547
  */
1548
- mv(t, e) {
1549
- const r = FSHelpers.mv(
1548
+ mv(r, e) {
1549
+ const t = FSHelpers.mv(
1550
1550
  this[__private__dont__use].FS,
1551
- t,
1551
+ r,
1552
1552
  e
1553
1553
  );
1554
- return this.dispatchEvent({ type: "filesystem.write" }), r;
1554
+ return this.dispatchEvent({ type: "filesystem.write" }), t;
1555
1555
  }
1556
1556
  /**
1557
1557
  * Removes a directory from the PHP filesystem.
@@ -1559,13 +1559,13 @@ class PHP {
1559
1559
  * @param path The directory path to remove.
1560
1560
  * @param options Options for the removal.
1561
1561
  */
1562
- rmdir(t, e = { recursive: !0 }) {
1563
- const r = FSHelpers.rmdir(
1562
+ rmdir(r, e = { recursive: !0 }) {
1563
+ const t = FSHelpers.rmdir(
1564
1564
  this[__private__dont__use].FS,
1565
- t,
1565
+ r,
1566
1566
  e
1567
1567
  );
1568
- return this.dispatchEvent({ type: "filesystem.write" }), r;
1568
+ return this.dispatchEvent({ type: "filesystem.write" }), t;
1569
1569
  }
1570
1570
  /**
1571
1571
  * Lists the files and directories in the given directory.
@@ -1574,10 +1574,10 @@ class PHP {
1574
1574
  * @param options - Options for the listing.
1575
1575
  * @returns The list of files and directories in the given directory.
1576
1576
  */
1577
- listFiles(t, e = { prependPath: !1 }) {
1577
+ listFiles(r, e = { prependPath: !1 }) {
1578
1578
  return FSHelpers.listFiles(
1579
1579
  this[__private__dont__use].FS,
1580
- t,
1580
+ r,
1581
1581
  e
1582
1582
  );
1583
1583
  }
@@ -1587,8 +1587,8 @@ class PHP {
1587
1587
  * @param path – The path to check.
1588
1588
  * @returns True if the path is a directory, false otherwise.
1589
1589
  */
1590
- isDir(t) {
1591
- return FSHelpers.isDir(this[__private__dont__use].FS, t);
1590
+ isDir(r) {
1591
+ return FSHelpers.isDir(this[__private__dont__use].FS, r);
1592
1592
  }
1593
1593
  /**
1594
1594
  * Checks if a file exists in the PHP filesystem.
@@ -1596,16 +1596,16 @@ class PHP {
1596
1596
  * @param path – The path to check.
1597
1597
  * @returns True if the path is a file, false otherwise.
1598
1598
  */
1599
- isFile(t) {
1600
- return FSHelpers.isFile(this[__private__dont__use].FS, t);
1599
+ isFile(r) {
1600
+ return FSHelpers.isFile(this[__private__dont__use].FS, r);
1601
1601
  }
1602
1602
  /**
1603
1603
  * Creates a symlink in the PHP filesystem.
1604
1604
  * @param target
1605
1605
  * @param path
1606
1606
  */
1607
- symlink(t, e) {
1608
- return FSHelpers.symlink(this[__private__dont__use].FS, t, e);
1607
+ symlink(r, e) {
1608
+ return FSHelpers.symlink(this[__private__dont__use].FS, r, e);
1609
1609
  }
1610
1610
  /**
1611
1611
  * Checks if a path is a symlink in the PHP filesystem.
@@ -1613,8 +1613,8 @@ class PHP {
1613
1613
  * @param path
1614
1614
  * @returns True if the path is a symlink, false otherwise.
1615
1615
  */
1616
- isSymlink(t) {
1617
- return FSHelpers.isSymlink(this[__private__dont__use].FS, t);
1616
+ isSymlink(r) {
1617
+ return FSHelpers.isSymlink(this[__private__dont__use].FS, r);
1618
1618
  }
1619
1619
  /**
1620
1620
  * Reads the target of a symlink in the PHP filesystem.
@@ -1622,16 +1622,16 @@ class PHP {
1622
1622
  * @param path
1623
1623
  * @returns The target of the symlink.
1624
1624
  */
1625
- readlink(t) {
1626
- return FSHelpers.readlink(this[__private__dont__use].FS, t);
1625
+ readlink(r) {
1626
+ return FSHelpers.readlink(this[__private__dont__use].FS, r);
1627
1627
  }
1628
1628
  /**
1629
1629
  * Resolves the real path of a file in the PHP filesystem.
1630
1630
  * @param path
1631
1631
  * @returns The real path of the file.
1632
1632
  */
1633
- realpath(t) {
1634
- return FSHelpers.realpath(this[__private__dont__use].FS, t);
1633
+ realpath(r) {
1634
+ return FSHelpers.realpath(this[__private__dont__use].FS, r);
1635
1635
  }
1636
1636
  /**
1637
1637
  * Checks if a file (or a directory) exists in the PHP filesystem.
@@ -1639,19 +1639,19 @@ class PHP {
1639
1639
  * @param path - The file path to check.
1640
1640
  * @returns True if the file exists, false otherwise.
1641
1641
  */
1642
- fileExists(t) {
1643
- return FSHelpers.fileExists(this[__private__dont__use].FS, t);
1642
+ fileExists(r) {
1643
+ return FSHelpers.fileExists(this[__private__dont__use].FS, r);
1644
1644
  }
1645
1645
  /**
1646
1646
  * Enables inline PHP runtime rotation after a certain number of requests
1647
1647
  * or an internal crash.
1648
1648
  */
1649
- enableRuntimeRotation(t) {
1650
- _(this, w, {
1649
+ enableRuntimeRotation(r) {
1650
+ g(this, w, {
1651
1651
  ...u(this, w),
1652
1652
  enabled: !0,
1653
- recreateRuntime: t.recreateRuntime,
1654
- maxRequests: t.maxRequests ?? 400
1653
+ recreateRuntime: r.recreateRuntime,
1654
+ maxRequests: r.maxRequests ?? 400
1655
1655
  });
1656
1656
  }
1657
1657
  async rotateRuntime() {
@@ -1669,36 +1669,36 @@ class PHP {
1669
1669
  *
1670
1670
  * @param runtime
1671
1671
  */
1672
- async hotSwapPHPRuntime(t) {
1673
- const e = this[__private__dont__use].FS, r = this.listFiles("/").map((a) => `/${a}`), s = this[__private__dont__use].spawnProcess, n = e.cwd();
1672
+ async hotSwapPHPRuntime(r) {
1673
+ const e = this[__private__dont__use].FS, t = this.listFiles("/").map((c) => `/${c}`), s = this[__private__dont__use].spawnProcess, n = e.cwd();
1674
1674
  e.chdir("/");
1675
- const i = Object.entries(u(this, k)).map(
1676
- ([a, l]) => ({
1675
+ const i = Object.entries(u(this, H)).map(
1676
+ ([c, l]) => ({
1677
1677
  mountHandler: l.mountHandler,
1678
- vfsPath: a
1678
+ vfsPath: c
1679
1679
  })
1680
1680
  ), o = Object.values(
1681
- u(this, k)
1681
+ u(this, H)
1682
1682
  ).reverse();
1683
- for (const a of o)
1684
- await a.unmount();
1683
+ for (const c of o)
1684
+ await c.unmount();
1685
1685
  try {
1686
1686
  this.exit();
1687
1687
  } catch {
1688
1688
  }
1689
- this.initializeRuntime(t), s && (this[__private__dont__use].spawnProcess = s), u(this, M) && this.setSapiName(u(this, M));
1690
- const c = this[__private__dont__use].FS;
1691
- for (const a of r)
1692
- a && a !== "/request" && copyMEMFSNodes(e, c, a);
1693
- for (const { mountHandler: a, vfsPath: l } of i)
1694
- this.mkdir(l), await this.mount(l, a);
1689
+ this.initializeRuntime(r), s && (this[__private__dont__use].spawnProcess = s), u(this, M) && this.setSapiName(u(this, M));
1690
+ const a = this[__private__dont__use].FS;
1691
+ for (const c of t)
1692
+ c && c !== "/request" && copyMEMFSNodes(e, a, c);
1693
+ for (const { mountHandler: c, vfsPath: l } of i)
1694
+ this.mkdir(l), await this.mount(l, c);
1695
1695
  try {
1696
- c.chdir(n);
1697
- } catch (a) {
1696
+ a.chdir(n);
1697
+ } catch (c) {
1698
1698
  throw new Error(
1699
1699
  `Failed to restore CWD to ${n} after PHP runtime rotation.`,
1700
1700
  {
1701
- cause: a
1701
+ cause: c
1702
1702
  }
1703
1703
  );
1704
1704
  }
@@ -1710,18 +1710,18 @@ class PHP {
1710
1710
  * @param mountHandler - The mount handler to use.
1711
1711
  * @return Unmount function to unmount the filesystem.
1712
1712
  */
1713
- async mount(t, e) {
1714
- const r = await e(
1713
+ async mount(r, e) {
1714
+ const t = await e(
1715
1715
  this,
1716
1716
  this[__private__dont__use].FS,
1717
- t
1717
+ r
1718
1718
  ), s = {
1719
1719
  mountHandler: e,
1720
1720
  unmount: async () => {
1721
- await r(), delete u(this, k)[t];
1721
+ await t(), delete u(this, H)[r];
1722
1722
  }
1723
1723
  };
1724
- return u(this, k)[t] = s, () => {
1724
+ return u(this, H)[r] = s, () => {
1725
1725
  s.unmount();
1726
1726
  };
1727
1727
  }
@@ -1738,17 +1738,17 @@ class PHP {
1738
1738
  * @param argv - The arguments to pass to the CLI.
1739
1739
  * @returns The exit code of the CLI session.
1740
1740
  */
1741
- async cli(t, e = {}) {
1742
- if (basename(t[0] ?? "") !== "php")
1743
- return this.subProcess(t, e);
1744
- u(this, H) && (u(this, w).needsRotating = !0);
1745
- const r = await this.semaphore.acquire();
1746
- return await m(this, h, W).call(this, () => {
1741
+ async cli(r, e = {}) {
1742
+ if (basename(r[0] ?? "") !== "php")
1743
+ return this.subProcess(r, e);
1744
+ u(this, R) && (u(this, w).needsRotating = !0);
1745
+ const t = await this.semaphore.acquire();
1746
+ return await m(this, h, j).call(this, () => {
1747
1747
  const s = e.env || {};
1748
1748
  for (const [n, i] of Object.entries(s))
1749
- m(this, h, D).call(this, n, i);
1750
- t = [t[0], "-c", PHP_INI_PATH, ...t.slice(1)];
1751
- for (const n of t)
1749
+ m(this, h, W).call(this, n, i);
1750
+ r = [r[0], "-c", PHP_INI_PATH, ...r.slice(1)];
1751
+ for (const n of r)
1752
1752
  this[__private__dont__use].ccall(
1753
1753
  "wasm_add_cli_arg",
1754
1754
  null,
@@ -1758,7 +1758,7 @@ class PHP {
1758
1758
  return this[__private__dont__use].ccall("run_cli", null, [], [], {
1759
1759
  async: !0
1760
1760
  });
1761
- }).then((s) => (s.exitCode.finally(r), s)).finally(() => {
1761
+ }).then((s) => (s.exitCode.finally(t), s)).finally(() => {
1762
1762
  u(this, w).needsRotating = !0;
1763
1763
  });
1764
1764
  }
@@ -1770,24 +1770,24 @@ class PHP {
1770
1770
  * @param options
1771
1771
  * @returns StreamedPHPResponse.
1772
1772
  */
1773
- async subProcess(t, e = {}) {
1774
- const r = this[__private__dont__use].spawnProcess(
1775
- t[0],
1776
- t.slice(1),
1773
+ async subProcess(r, e = {}) {
1774
+ const t = this[__private__dont__use].spawnProcess(
1775
+ r[0],
1776
+ r.slice(1),
1777
1777
  {
1778
1778
  env: e.env,
1779
1779
  cwd: e.cwd ?? this.cwd()
1780
1780
  }
1781
1781
  ), s = await createInvertedReadableStream();
1782
- r.on("error", (i) => {
1782
+ t.on("error", (i) => {
1783
1783
  s.controller.error(i);
1784
- }), r.stderr.on("data", (i) => {
1784
+ }), t.stderr.on("data", (i) => {
1785
1785
  s.controller.enqueue(i);
1786
1786
  });
1787
1787
  const n = await createInvertedReadableStream();
1788
- return r.stdout.on("data", (i) => {
1788
+ return t.stdout.on("data", (i) => {
1789
1789
  n.controller.enqueue(i);
1790
- }), r.on("exit", () => {
1790
+ }), t.on("exit", () => {
1791
1791
  setTimeout(() => {
1792
1792
  try {
1793
1793
  s.controller.close();
@@ -1809,35 +1809,35 @@ class PHP {
1809
1809
  s.stream,
1810
1810
  // Exit code
1811
1811
  new Promise((i) => {
1812
- r.on("exit", (o) => {
1812
+ t.on("exit", (o) => {
1813
1813
  i(o);
1814
1814
  });
1815
1815
  })
1816
1816
  );
1817
1817
  }
1818
- setSkipShebang(t) {
1818
+ setSkipShebang(r) {
1819
1819
  this[__private__dont__use].ccall(
1820
1820
  "wasm_set_skip_shebang",
1821
1821
  null,
1822
1822
  [NUMBER],
1823
- [t ? 1 : 0]
1823
+ [r ? 1 : 0]
1824
1824
  );
1825
1825
  }
1826
- exit(t = 0) {
1826
+ exit(r = 0) {
1827
1827
  this.dispatchEvent({
1828
1828
  type: "runtime.beforeExit"
1829
1829
  });
1830
1830
  try {
1831
- this[__private__dont__use]._exit(t);
1831
+ this[__private__dont__use]._exit(r);
1832
1832
  } catch {
1833
1833
  }
1834
- _(this, H, !1), _(this, T, null), this[__private__dont__use] && (delete this[__private__dont__use].onMessage, delete this[__private__dont__use]);
1834
+ g(this, R, !1), g(this, b, null), this[__private__dont__use] && (delete this[__private__dont__use].onMessage, delete this[__private__dont__use]);
1835
1835
  }
1836
1836
  [Symbol.dispose]() {
1837
1837
  this.exit(0);
1838
1838
  }
1839
1839
  }
1840
- M = new WeakMap(), H = new WeakMap(), T = new WeakMap(), v = new WeakMap(), F = new WeakMap(), k = new WeakMap(), w = new WeakMap(), h = new WeakSet(), /**
1840
+ M = new WeakMap(), R = new WeakMap(), b = new WeakMap(), S = new WeakMap(), T = new WeakMap(), H = new WeakMap(), w = new WeakMap(), h = new WeakSet(), /**
1841
1841
  * Prepares the $_SERVER entries for the PHP runtime.
1842
1842
  *
1843
1843
  * @param defaults Default entries to include in $_SERVER.
@@ -1846,88 +1846,88 @@ M = new WeakMap(), H = new WeakMap(), T = new WeakMap(), v = new WeakMap(), F =
1846
1846
  * was provided.
1847
1847
  * @returns Computed $_SERVER entries.
1848
1848
  */
1849
- V = function(t, e, r) {
1849
+ V = function(r, e, t) {
1850
1850
  const s = {
1851
- ...t || {}
1851
+ ...r || {}
1852
1852
  };
1853
- s.HTTPS = s.HTTPS || r === 443 ? "on" : "off";
1853
+ s.HTTPS = s.HTTPS || t === 443 ? "on" : "off";
1854
1854
  for (const n in e) {
1855
1855
  let i = "HTTP_";
1856
1856
  ["content-type", "content-length"].includes(n.toLowerCase()) && (i = ""), s[`${i}${n.toUpperCase().replace(/-/g, "_")}`] = e[n];
1857
1857
  }
1858
1858
  return s;
1859
- }, G = function(t) {
1859
+ }, G = function(r) {
1860
1860
  this[__private__dont__use].ccall(
1861
1861
  "wasm_set_request_uri",
1862
1862
  null,
1863
1863
  [STRING],
1864
- [t]
1864
+ [r]
1865
1865
  );
1866
1866
  let e = "";
1867
- t.includes("?") && (e = t.substring(t.indexOf("?") + 1)), this[__private__dont__use].ccall(
1867
+ r.includes("?") && (e = r.substring(r.indexOf("?") + 1)), this[__private__dont__use].ccall(
1868
1868
  "wasm_set_query_string",
1869
1869
  null,
1870
1870
  [STRING],
1871
1871
  [e]
1872
1872
  );
1873
- }, J = function(t) {
1873
+ }, J = function(r) {
1874
1874
  this[__private__dont__use].ccall(
1875
1875
  "wasm_set_request_host",
1876
1876
  null,
1877
1877
  [STRING],
1878
- [t]
1878
+ [r]
1879
1879
  );
1880
- }, Y = function(t) {
1880
+ }, Y = function(r) {
1881
1881
  this[__private__dont__use].ccall(
1882
1882
  "wasm_set_request_port",
1883
1883
  null,
1884
1884
  [NUMBER],
1885
- [t]
1885
+ [r]
1886
1886
  );
1887
- }, Q = function(t, e) {
1888
- let r;
1887
+ }, X = function(r, e) {
1888
+ let t;
1889
1889
  try {
1890
- r = parseInt(new URL(t).port, 10);
1890
+ t = parseInt(new URL(r).port, 10);
1891
1891
  } catch {
1892
1892
  }
1893
- return (!r || isNaN(r) || r === 80) && (r = e === "https" ? 443 : 80), r;
1894
- }, X = function(t) {
1893
+ return (!t || isNaN(t) || t === 80) && (t = e === "https" ? 443 : 80), t;
1894
+ }, Q = function(r) {
1895
1895
  this[__private__dont__use].ccall(
1896
1896
  "wasm_set_request_method",
1897
1897
  null,
1898
1898
  [STRING],
1899
- [t]
1899
+ [r]
1900
1900
  );
1901
- }, K = function(t) {
1902
- t.cookie && this[__private__dont__use].ccall(
1901
+ }, K = function(r) {
1902
+ r.cookie && this[__private__dont__use].ccall(
1903
1903
  "wasm_set_cookies",
1904
1904
  null,
1905
1905
  [STRING],
1906
- [t.cookie]
1907
- ), t["content-type"] && this[__private__dont__use].ccall(
1906
+ [r.cookie]
1907
+ ), r["content-type"] && this[__private__dont__use].ccall(
1908
1908
  "wasm_set_content_type",
1909
1909
  null,
1910
1910
  [STRING],
1911
- [t["content-type"]]
1912
- ), t["content-length"] && this[__private__dont__use].ccall(
1911
+ [r["content-type"]]
1912
+ ), r["content-length"] && this[__private__dont__use].ccall(
1913
1913
  "wasm_set_content_length",
1914
1914
  null,
1915
1915
  [NUMBER],
1916
- [parseInt(t["content-length"], 10)]
1916
+ [parseInt(r["content-length"], 10)]
1917
1917
  );
1918
- }, Z = function(t) {
1919
- let e, r;
1920
- typeof t == "string" ? (logger.warn(
1918
+ }, Z = function(r) {
1919
+ let e, t;
1920
+ typeof r == "string" ? (logger.warn(
1921
1921
  "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"
1922
- ), r = this[__private__dont__use].lengthBytesUTF8(t), e = r + 1) : (r = t.byteLength, e = t.byteLength);
1922
+ ), t = this[__private__dont__use].lengthBytesUTF8(r), e = t + 1) : (t = r.byteLength, e = r.byteLength);
1923
1923
  const s = this[__private__dont__use].malloc(e);
1924
1924
  if (!s)
1925
1925
  throw new Error("Could not allocate memory for the request body.");
1926
- return typeof t == "string" ? this[__private__dont__use].stringToUTF8(
1927
- t,
1926
+ return typeof r == "string" ? this[__private__dont__use].stringToUTF8(
1927
+ r,
1928
1928
  s,
1929
1929
  e + 1
1930
- ) : this[__private__dont__use].HEAPU8.set(t, s), this[__private__dont__use].ccall(
1930
+ ) : this[__private__dont__use].HEAPU8.set(r, s), this[__private__dont__use].ccall(
1931
1931
  "wasm_set_request_body",
1932
1932
  null,
1933
1933
  [NUMBER],
@@ -1936,59 +1936,59 @@ V = function(t, e, r) {
1936
1936
  "wasm_set_content_length",
1937
1937
  null,
1938
1938
  [NUMBER],
1939
- [r]
1939
+ [t]
1940
1940
  ), s;
1941
- }, q = function(t) {
1941
+ }, D = function(r) {
1942
1942
  this[__private__dont__use].ccall(
1943
1943
  "wasm_set_path_translated",
1944
1944
  null,
1945
1945
  [STRING],
1946
- [t]
1946
+ [r]
1947
1947
  );
1948
- }, ee = function(t, e) {
1948
+ }, ee = function(r, e) {
1949
1949
  this[__private__dont__use].ccall(
1950
1950
  "wasm_add_SERVER_entry",
1951
1951
  null,
1952
1952
  [STRING, STRING],
1953
- [t, e]
1953
+ [r, e]
1954
1954
  );
1955
- }, D = function(t, e) {
1955
+ }, W = function(r, e) {
1956
1956
  this[__private__dont__use].ccall(
1957
1957
  "wasm_add_ENV_entry",
1958
1958
  null,
1959
1959
  [STRING, STRING],
1960
- [t, e]
1960
+ [r, e]
1961
1961
  );
1962
- }, W = async function(t) {
1962
+ }, j = async function(r) {
1963
1963
  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);
1964
- const e = this[__private__dont__use], r = await createInvertedReadableStream();
1964
+ const e = this[__private__dont__use], t = await createInvertedReadableStream();
1965
1965
  e.onHeaders = (p) => {
1966
- c || s || r.controller.enqueue(p.slice());
1966
+ a || s || t.controller.enqueue(p.slice());
1967
1967
  };
1968
1968
  let s = !1;
1969
1969
  const n = () => {
1970
- s || (s = !0, r.controller.close());
1970
+ s || (s = !0, t.controller.close());
1971
1971
  }, i = await createInvertedReadableStream();
1972
1972
  e.onStdout = (p) => {
1973
- n(), !c && i.controller.enqueue(p.slice());
1973
+ n(), !a && i.controller.enqueue(p.slice());
1974
1974
  };
1975
1975
  const o = await createInvertedReadableStream();
1976
1976
  e.onStderr = (p) => {
1977
- c || o.controller.enqueue(p.slice());
1977
+ a || o.controller.enqueue(p.slice());
1978
1978
  };
1979
- let c = !1, a;
1979
+ let a = !1, c;
1980
1980
  const d = (async () => {
1981
1981
  var p;
1982
1982
  try {
1983
1983
  return await Promise.race([
1984
- t(),
1985
- new Promise((g, b) => {
1986
- var B;
1987
- a = (z) => {
1988
- isExitCode(z.error) || b(z.error);
1989
- }, (B = u(this, T)) == null || B.addEventListener(
1984
+ r(),
1985
+ new Promise((_, F) => {
1986
+ var z;
1987
+ c = ($) => {
1988
+ isExitCode($.error) || F($.error);
1989
+ }, (z = u(this, b)) == null || z.addEventListener(
1990
1990
  "error",
1991
- a,
1991
+ c,
1992
1992
  { once: !0 }
1993
1993
  );
1994
1994
  })
@@ -1996,18 +1996,18 @@ V = function(t, e, r) {
1996
1996
  } catch (f) {
1997
1997
  if (isExitCode(f))
1998
1998
  return f.status;
1999
- i.controller.error(f), o.controller.error(f), r.controller.error(f), c = !0;
2000
- for (const g in this)
2001
- typeof this[g] == "function" && (this[g] = () => {
1999
+ i.controller.error(f), o.controller.error(f), t.controller.error(f), a = !0;
2000
+ for (const _ in this)
2001
+ typeof this[_] == "function" && (this[_] = () => {
2002
2002
  throw new Error(
2003
2003
  "PHP runtime has crashed – see the earlier error for details."
2004
2004
  );
2005
2005
  });
2006
2006
  throw this.functionsMaybeMissingFromAsyncify = getFunctionsMaybeMissingFromAsyncify(), f;
2007
2007
  } finally {
2008
- c || (i.controller.close(), o.controller.close(), n(), c = !0), (p = u(this, T)) == null || p.removeEventListener(
2008
+ a || (i.controller.close(), o.controller.close(), n(), a = !0), (p = u(this, b)) == null || p.removeEventListener(
2009
2009
  "error",
2010
- a
2010
+ c
2011
2011
  );
2012
2012
  }
2013
2013
  })().then(
@@ -2029,52 +2029,52 @@ V = function(t, e, r) {
2029
2029
  }
2030
2030
  );
2031
2031
  return new StreamedPHPResponse(
2032
- r.stream,
2032
+ t.stream,
2033
2033
  i.stream,
2034
2034
  o.stream,
2035
2035
  d
2036
2036
  );
2037
2037
  };
2038
- function normalizeHeaders(t) {
2038
+ function normalizeHeaders(r) {
2039
2039
  const e = {};
2040
- for (const r in t)
2041
- e[r.toLowerCase()] = t[r];
2040
+ for (const t in r)
2041
+ e[t.toLowerCase()] = r[t];
2042
2042
  return e;
2043
2043
  }
2044
- function copyMEMFSNodes(t, e, r) {
2045
- if (getNodeType(t, r) !== "memfs" || !["memfs", "missing"].includes(getNodeType(e, r)))
2044
+ function copyMEMFSNodes(r, e, t) {
2045
+ if (getNodeType(r, t) !== "memfs" || !["memfs", "missing"].includes(getNodeType(e, t)))
2046
2046
  return;
2047
- const s = t.lookupPath(r);
2048
- if (!t.isDir(s.node.mode)) {
2049
- e.writeFile(r, t.readFile(r));
2047
+ const s = r.lookupPath(t);
2048
+ if (!r.isDir(s.node.mode)) {
2049
+ e.writeFile(t, r.readFile(t));
2050
2050
  return;
2051
2051
  }
2052
- e.mkdirTree(r);
2053
- const n = t.readdir(r).filter((i) => i !== "." && i !== "..");
2052
+ e.mkdirTree(t);
2053
+ const n = r.readdir(t).filter((i) => i !== "." && i !== "..");
2054
2054
  for (const i of n)
2055
- copyMEMFSNodes(t, e, joinPaths(r, i));
2055
+ copyMEMFSNodes(r, e, joinPaths(t, i));
2056
2056
  }
2057
- async function createInvertedReadableStream(t = {}) {
2057
+ async function createInvertedReadableStream(r = {}) {
2058
2058
  let e;
2059
- const r = new Promise(
2059
+ const t = new Promise(
2060
2060
  (i) => {
2061
2061
  e = i;
2062
2062
  }
2063
2063
  ), s = new ReadableStream({
2064
- ...t,
2064
+ ...r,
2065
2065
  start(i) {
2066
- if (e(i), t.start)
2067
- return t.start(i);
2066
+ if (e(i), r.start)
2067
+ return r.start(i);
2068
2068
  }
2069
- }), n = await r;
2069
+ }), n = await t;
2070
2070
  return {
2071
2071
  stream: s,
2072
2072
  controller: n
2073
2073
  };
2074
2074
  }
2075
- const getNodeType = (t, e) => {
2075
+ const getNodeType = (r, e) => {
2076
2076
  try {
2077
- return "contents" in t.lookupPath(e, { follow: !0 }).node ? "memfs" : (
2077
+ return "contents" in r.lookupPath(e, { follow: !0 }).node ? "memfs" : (
2078
2078
  /**
2079
2079
  * Could be NODEFS, PROXYFS, etc.
2080
2080
  */
@@ -2084,38 +2084,38 @@ const getNodeType = (t, e) => {
2084
2084
  return "missing";
2085
2085
  }
2086
2086
  };
2087
- async function getPhpIniEntries(t, e) {
2088
- const r = parse(await t.readFileAsText(PHP_INI_PATH));
2087
+ async function getPhpIniEntries(r, e) {
2088
+ const t = parse(await r.readFileAsText(PHP_INI_PATH));
2089
2089
  if (e === void 0)
2090
- return r;
2090
+ return t;
2091
2091
  const s = {};
2092
2092
  for (const n of e)
2093
- s[n] = r[n];
2093
+ s[n] = t[n];
2094
2094
  return s;
2095
2095
  }
2096
- async function setPhpIniEntries(t, e) {
2097
- const r = parse(await t.readFileAsText(PHP_INI_PATH));
2096
+ async function setPhpIniEntries(r, e) {
2097
+ const t = parse(await r.readFileAsText(PHP_INI_PATH));
2098
2098
  for (const [s, n] of Object.entries(e))
2099
- n == null ? delete r[s] : r[s] = n;
2100
- await t.writeFile(PHP_INI_PATH, stringify(r));
2099
+ n == null ? delete t[s] : t[s] = n;
2100
+ await r.writeFile(PHP_INI_PATH, stringify(t));
2101
2101
  }
2102
- async function withPHPIniValues(t, e, r) {
2103
- const s = await t.readFileAsText(PHP_INI_PATH);
2102
+ async function withPHPIniValues(r, e, t) {
2103
+ const s = await r.readFileAsText(PHP_INI_PATH);
2104
2104
  try {
2105
- return await setPhpIniEntries(t, e), await r();
2105
+ return await setPhpIniEntries(r, e), await t();
2106
2106
  } finally {
2107
- await t.writeFile(PHP_INI_PATH, s);
2107
+ await r.writeFile(PHP_INI_PATH, s);
2108
2108
  }
2109
2109
  }
2110
- async function printDebugDetails(t, e) {
2110
+ async function printDebugDetails(r, e) {
2111
2111
  e && printResponseDebugDetails(
2112
2112
  await PHPResponse.fromStreamedResponse(e)
2113
- ), await prettyPrintFullStackTrace(t);
2113
+ ), await prettyPrintFullStackTrace(r);
2114
2114
  }
2115
- async function prettyPrintFullStackTrace(t) {
2116
- let e = t, r = !0;
2115
+ async function prettyPrintFullStackTrace(r) {
2116
+ let e = r, t = !0;
2117
2117
  for (; e; )
2118
- r || process.stderr.write(`
2118
+ t || process.stderr.write(`
2119
2119
  Caused by:
2120
2120
 
2121
2121
  `), process.stderr.write(e.originalErrorClassName ?? e.name), process.stderr.write(": " + e.message + `
@@ -2128,35 +2128,35 @@ Caused by:
2128
2128
 
2129
2129
  ==== PHP error log ====
2130
2130
 
2131
- `), process.stderr.write(e.phpLogs)), e = e.cause, r = !1;
2131
+ `), process.stderr.write(e.phpLogs)), e = e.cause, t = !1;
2132
2132
  process.stderr.write(`
2133
2133
  `);
2134
2134
  }
2135
- function printResponseDebugDetails(t) {
2135
+ function printResponseDebugDetails(r) {
2136
2136
  process.stderr.write(
2137
2137
  `
2138
- exitCode=${t.exitCode} httpStatusCode=${t.httpStatusCode} `
2138
+ exitCode=${r.exitCode} httpStatusCode=${r.httpStatusCode} `
2139
2139
  );
2140
- const e = t.headers && Object.keys(t.headers).length > 0;
2141
- e || process.stderr.write("responseHeaders=(empty) "), t.text || process.stderr.write("stdout=(empty) "), t.errors || process.stderr.write("stderr=(empty) "), process.stderr.write(`
2140
+ const e = r.headers && Object.keys(r.headers).length > 0;
2141
+ e || process.stderr.write("responseHeaders=(empty) "), r.text || process.stderr.write("stdout=(empty) "), r.errors || process.stderr.write("stderr=(empty) "), process.stderr.write(`
2142
2142
  `), e && process.stderr.write(
2143
2143
  `
2144
2144
  ==== PHP response headers ====
2145
2145
 
2146
2146
  ${JSON.stringify(
2147
- t.headers,
2147
+ r.headers,
2148
2148
  null,
2149
2149
  2
2150
2150
  )}
2151
2151
 
2152
2152
  `
2153
- ), t.text && (process.stderr.write(`
2153
+ ), r.text && (process.stderr.write(`
2154
2154
  ==== PHP stdout ====
2155
2155
 
2156
- `), process.stderr.write(t.text)), t.errors && (process.stderr.write(`
2156
+ `), process.stderr.write(r.text)), r.errors && (process.stderr.write(`
2157
2157
  ==== PHP stderr ====
2158
2158
 
2159
- `), process.stderr.write(t.errors)), process.stderr.write(`
2159
+ `), process.stderr.write(r.errors)), process.stderr.write(`
2160
2160
  `);
2161
2161
  }
2162
2162
  class HttpCookieStore {
@@ -2165,11 +2165,11 @@ class HttpCookieStore {
2165
2165
  }
2166
2166
  rememberCookiesFromResponseHeaders(e) {
2167
2167
  if (e != null && e["set-cookie"])
2168
- for (const r of e["set-cookie"])
2168
+ for (const t of e["set-cookie"])
2169
2169
  try {
2170
- if (!r.includes("="))
2170
+ if (!t.includes("="))
2171
2171
  continue;
2172
- const s = r.indexOf("="), n = r.substring(0, s), i = r.substring(s + 1).split(";")[0];
2172
+ const s = t.indexOf("="), n = t.substring(0, s), i = t.substring(s + 1).split(";")[0];
2173
2173
  this.cookies[n] = i;
2174
2174
  } catch (s) {
2175
2175
  logger.error(s);
@@ -2177,21 +2177,21 @@ class HttpCookieStore {
2177
2177
  }
2178
2178
  getCookieRequestHeader() {
2179
2179
  const e = [];
2180
- for (const r in this.cookies)
2181
- e.push(`${r}=${this.cookies[r]}`);
2180
+ for (const t in this.cookies)
2181
+ e.push(`${t}=${this.cookies[t]}`);
2182
2182
  return e.join("; ");
2183
2183
  }
2184
2184
  }
2185
- function streamReadFileFromPHP(t, e) {
2185
+ function streamReadFileFromPHP(r, e) {
2186
2186
  return new ReadableStream({
2187
- async pull(r) {
2188
- const s = await t.readFileAsBuffer(e);
2189
- r.enqueue(s), r.close();
2187
+ async pull(t) {
2188
+ const s = await r.readFileAsBuffer(e);
2189
+ t.enqueue(s), t.close();
2190
2190
  }
2191
2191
  });
2192
2192
  }
2193
- async function* iteratePhpFiles(t, e, {
2194
- relativePaths: r = !0,
2193
+ async function* iteratePhpFiles(r, e, {
2194
+ relativePaths: t = !0,
2195
2195
  pathPrefix: s,
2196
2196
  exceptPaths: n = []
2197
2197
  } = {}) {
@@ -2201,14 +2201,14 @@ async function* iteratePhpFiles(t, e, {
2201
2201
  const o = i.pop();
2202
2202
  if (!o)
2203
2203
  return;
2204
- const c = await t.listFiles(o);
2205
- for (const a of c) {
2206
- const l = `${o}/${a}`;
2204
+ const a = await r.listFiles(o);
2205
+ for (const c of a) {
2206
+ const l = `${o}/${c}`;
2207
2207
  if (n.includes(l.substring(e.length + 1)))
2208
2208
  continue;
2209
- await t.isDir(l) ? i.push(l) : yield new StreamedFile(
2210
- streamReadFileFromPHP(t, l),
2211
- r ? joinPaths(
2209
+ await r.isDir(l) ? i.push(l) : yield new StreamedFile(
2210
+ streamReadFileFromPHP(r, l),
2211
+ t ? joinPaths(
2212
2212
  s || "",
2213
2213
  l.substring(e.length + 1)
2214
2214
  ) : l
@@ -2216,13 +2216,13 @@ async function* iteratePhpFiles(t, e, {
2216
2216
  }
2217
2217
  }
2218
2218
  }
2219
- function writeFilesStreamToPhp(t, e) {
2219
+ function writeFilesStreamToPhp(r, e) {
2220
2220
  return new WritableStream({
2221
- async write(r) {
2222
- const s = joinPaths(e, r.name);
2223
- r.type === "directory" ? await t.mkdir(s) : (await t.mkdir(dirname(s)), await t.writeFile(
2221
+ async write(t) {
2222
+ const s = joinPaths(e, t.name);
2223
+ t.type === "directory" ? await r.mkdir(s) : (await r.mkdir(dirname(s)), await r.writeFile(
2224
2224
  s,
2225
- new Uint8Array(await r.arrayBuffer())
2225
+ new Uint8Array(await t.arrayBuffer())
2226
2226
  ));
2227
2227
  }
2228
2228
  });
@@ -2300,11 +2300,11 @@ class PHPProcessManager {
2300
2300
  } catch (s) {
2301
2301
  throw s instanceof AcquireTimeoutError ? new MaxPhpInstancesError(this.maxPhpInstances) : s;
2302
2302
  }
2303
- const r = await this.getOrSpawnInstance();
2303
+ const t = await this.getOrSpawnInstance();
2304
2304
  return {
2305
- php: r,
2305
+ php: t,
2306
2306
  reap: () => {
2307
- this.idleInstances.push(r), e();
2307
+ this.idleInstances.push(t), e();
2308
2308
  }
2309
2309
  };
2310
2310
  }
@@ -2322,8 +2322,8 @@ class PHPProcessManager {
2322
2322
  throw new Error(
2323
2323
  "phpFactory must be set before spawning instances."
2324
2324
  );
2325
- const r = await this.phpFactory({ isPrimary: e });
2326
- return this.instances.push(r), this.idleInstances.push(r), r;
2325
+ const t = await this.phpFactory({ isPrimary: e });
2326
+ return this.instances.push(t), this.idleInstances.push(t), t;
2327
2327
  }
2328
2328
  async [Symbol.asyncDispose]() {
2329
2329
  for (const e of this.instances)
@@ -2340,37 +2340,37 @@ const SupportedPHPVersions = [
2340
2340
  "8.0",
2341
2341
  "7.4"
2342
2342
  ], LatestSupportedPHPVersion = SupportedPHPVersions[0], SupportedPHPVersionsList = SupportedPHPVersions, DEFAULT_BASE_URL = "http://example.com";
2343
- function toRelativeUrl(t) {
2344
- return t.origin === "null" ? t.toString() : t.toString().substring(t.origin.length);
2343
+ function toRelativeUrl(r) {
2344
+ return r.origin === "null" ? r.toString() : r.toString().substring(r.origin.length);
2345
2345
  }
2346
- function removePathPrefix(t, e) {
2347
- return !e || !t.startsWith(e) ? t : t.substring(e.length);
2346
+ function removePathPrefix(r, e) {
2347
+ return !e || !r.startsWith(e) ? r : r.substring(e.length);
2348
2348
  }
2349
- function ensurePathPrefix(t, e) {
2350
- return !e || t.startsWith(e) ? t : e + t;
2349
+ function ensurePathPrefix(r, e) {
2350
+ return !e || r.startsWith(e) ? r : e + r;
2351
2351
  }
2352
- async function encodeAsMultipart(t) {
2353
- const e = `----${Math.random().toString(36).slice(2)}`, r = `multipart/form-data; boundary=${e}`, s = new TextEncoder(), n = [];
2354
- for (const [a, l] of Object.entries(t))
2352
+ async function encodeAsMultipart(r) {
2353
+ const e = `----${Math.random().toString(36).slice(2)}`, t = `multipart/form-data; boundary=${e}`, s = new TextEncoder(), n = [];
2354
+ for (const [c, l] of Object.entries(r))
2355
2355
  n.push(`--${e}\r
2356
- `), n.push(`Content-Disposition: form-data; name="${a}"`), l instanceof File && n.push(`; filename="${l.name}"`), n.push(`\r
2356
+ `), n.push(`Content-Disposition: form-data; name="${c}"`), l instanceof File && n.push(`; filename="${l.name}"`), n.push(`\r
2357
2357
  `), l instanceof File && (n.push("Content-Type: application/octet-stream"), n.push(`\r
2358
2358
  `)), n.push(`\r
2359
2359
  `), l instanceof File ? n.push(await fileToUint8Array(l)) : n.push(l), n.push(`\r
2360
2360
  `);
2361
2361
  n.push(`--${e}--\r
2362
2362
  `);
2363
- const i = n.reduce((a, l) => a + l.length, 0), o = new Uint8Array(i);
2364
- let c = 0;
2365
- for (const a of n)
2363
+ const i = n.reduce((c, l) => c + l.length, 0), o = new Uint8Array(i);
2364
+ let a = 0;
2365
+ for (const c of n)
2366
2366
  o.set(
2367
- typeof a == "string" ? s.encode(a) : a,
2368
- c
2369
- ), c += a.length;
2370
- return { bytes: o, contentType: r };
2367
+ typeof c == "string" ? s.encode(c) : c,
2368
+ a
2369
+ ), a += c.length;
2370
+ return { bytes: o, contentType: t };
2371
2371
  }
2372
- function fileToUint8Array(t) {
2373
- return t.arrayBuffer().then((e) => new Uint8Array(e));
2372
+ function fileToUint8Array(r) {
2373
+ return r.arrayBuffer().then((e) => new Uint8Array(e));
2374
2374
  }
2375
2375
  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 = {
2376
2376
  _default,
@@ -2468,7 +2468,7 @@ const _default = "application/octet-stream", asx = "video/x-ms-asf", atom = "app
2468
2468
  xspf,
2469
2469
  zip
2470
2470
  };
2471
- var S, I, O, C, A, E, N, R, L, P, te, U, re, se, ne;
2471
+ var v, C, N, L, I, E, A, k, O, P, te, U, re, se, ne;
2472
2472
  class PHPRequestHandler {
2473
2473
  /**
2474
2474
  * The request handler needs to decide whether to serve a static asset or
@@ -2483,26 +2483,26 @@ class PHPRequestHandler {
2483
2483
  */
2484
2484
  constructor(e) {
2485
2485
  y(this, P);
2486
- y(this, S);
2487
- y(this, I);
2488
- y(this, O);
2486
+ y(this, v);
2489
2487
  y(this, C);
2490
- y(this, A);
2491
- y(this, E);
2492
2488
  y(this, N);
2493
- y(this, R);
2494
2489
  y(this, L);
2490
+ y(this, I);
2491
+ y(this, E);
2492
+ y(this, A);
2493
+ y(this, k);
2494
+ y(this, O);
2495
2495
  const {
2496
- documentRoot: r = "/www/",
2496
+ documentRoot: t = "/www/",
2497
2497
  absoluteUrl: s = typeof location == "object" ? location.href : DEFAULT_BASE_URL,
2498
2498
  rewriteRules: n = [],
2499
2499
  pathAliases: i = [],
2500
2500
  getFileNotFoundAction: o = () => ({ type: "404" })
2501
- } = e, c = (d) => {
2502
- d.isDir(r) || d.mkdir(r), d.chdir(r), d.requestHandler = this;
2501
+ } = e, a = (d) => {
2502
+ d.isDir(t) || d.mkdir(t), d.chdir(t), d.requestHandler = this;
2503
2503
  };
2504
2504
  if (e.php)
2505
- c(e.php), this.instanceManager = new SinglePHPInstanceManager({
2505
+ a(e.php), this.instanceManager = new SinglePHPInstanceManager({
2506
2506
  php: e.php
2507
2507
  });
2508
2508
  else if (e.phpFactory)
@@ -2512,7 +2512,7 @@ class PHPRequestHandler {
2512
2512
  ...d,
2513
2513
  requestHandler: this
2514
2514
  });
2515
- return c(p), p;
2515
+ return a(p), p;
2516
2516
  },
2517
2517
  maxPhpInstances: e.maxPhpInstances
2518
2518
  });
@@ -2520,18 +2520,18 @@ class PHPRequestHandler {
2520
2520
  throw new Error(
2521
2521
  "Either php or phpFactory must be provided in the configuration."
2522
2522
  );
2523
- _(this, R, e.cookieStore === void 0 ? new HttpCookieStore() : e.cookieStore), _(this, S, r);
2524
- const a = new URL(s);
2525
- _(this, O, a.hostname), _(this, C, a.port ? Number(a.port) : a.protocol === "https:" ? 443 : 80), _(this, I, (a.protocol || "").replace(":", ""));
2526
- const l = u(this, C) !== 443 && u(this, C) !== 80;
2527
- _(this, A, [
2528
- u(this, O),
2529
- l ? `:${u(this, C)}` : ""
2530
- ].join("")), _(this, E, a.pathname.replace(/\/+$/, "")), _(this, N, [
2531
- `${u(this, I)}://`,
2532
- u(this, A),
2523
+ g(this, k, e.cookieStore === void 0 ? new HttpCookieStore() : e.cookieStore), g(this, v, t);
2524
+ const c = new URL(s);
2525
+ g(this, N, c.hostname), g(this, L, c.port ? Number(c.port) : c.protocol === "https:" ? 443 : 80), g(this, C, (c.protocol || "").replace(":", ""));
2526
+ const l = u(this, L) !== 443 && u(this, L) !== 80;
2527
+ g(this, I, [
2528
+ u(this, N),
2529
+ l ? `:${u(this, L)}` : ""
2530
+ ].join("")), g(this, E, c.pathname.replace(/\/+$/, "")), g(this, A, [
2531
+ `${u(this, C)}://`,
2532
+ u(this, I),
2533
2533
  u(this, E)
2534
- ].join("")), this.rewriteRules = n, _(this, L, i), this.getFileNotFoundAction = o;
2534
+ ].join("")), this.rewriteRules = n, g(this, O, i), this.getFileNotFoundAction = o;
2535
2535
  }
2536
2536
  async getPrimaryPhp() {
2537
2537
  return await this.instanceManager.getPrimaryPhp();
@@ -2554,21 +2554,21 @@ class PHPRequestHandler {
2554
2554
  * @returns The relative path.
2555
2555
  */
2556
2556
  internalUrlToPath(e) {
2557
- const r = new URL(e, "https://playground.internal");
2558
- return r.pathname.startsWith(u(this, E)) && (r.pathname = r.pathname.slice(u(this, E).length)), toRelativeUrl(r);
2557
+ const t = new URL(e, "https://playground.internal");
2558
+ return t.pathname.startsWith(u(this, E)) && (t.pathname = t.pathname.slice(u(this, E).length)), toRelativeUrl(t);
2559
2559
  }
2560
2560
  /**
2561
2561
  * The absolute URL of this PHPRequestHandler instance.
2562
2562
  */
2563
2563
  get absoluteUrl() {
2564
- return u(this, N);
2564
+ return u(this, A);
2565
2565
  }
2566
2566
  /**
2567
2567
  * The directory in the PHP filesystem where the server will look
2568
2568
  * for the files to serve. Default: `/var/www`.
2569
2569
  */
2570
2570
  get documentRoot() {
2571
- return u(this, S);
2571
+ return u(this, v);
2572
2572
  }
2573
2573
  /**
2574
2574
  * Serves the request – either by serving a static file, or by
@@ -2619,10 +2619,10 @@ class PHPRequestHandler {
2619
2619
  * @param request - PHP Request data.
2620
2620
  */
2621
2621
  async request(e) {
2622
- const r = looksLikeAbsoluteUrl(e.url), s = new URL(
2622
+ const t = looksLikeAbsoluteUrl(e.url), s = new URL(
2623
2623
  // Remove the hash part of the URL as it's not meant for the server.
2624
2624
  e.url.split("#")[0],
2625
- r ? void 0 : DEFAULT_BASE_URL
2625
+ t ? void 0 : DEFAULT_BASE_URL
2626
2626
  ), n = m(this, P, te).call(this, s), i = await this.getPrimaryPhp(), o = removePathPrefix(
2627
2627
  /**
2628
2628
  * URL.pathname returns a URL-encoded path. We need to decode it
@@ -2631,67 +2631,67 @@ class PHPRequestHandler {
2631
2631
  decodeURIComponent(n.pathname),
2632
2632
  u(this, E)
2633
2633
  );
2634
- let c = m(this, P, U).call(this, o);
2635
- if (i.isDir(c)) {
2634
+ let a = m(this, P, U).call(this, o);
2635
+ if (i.isDir(a)) {
2636
2636
  if (!o.endsWith("/"))
2637
2637
  return new PHPResponse(
2638
2638
  301,
2639
2639
  { Location: [`${n.pathname}/`] },
2640
2640
  new Uint8Array(0)
2641
2641
  );
2642
- for (const a of ["index.php", "index.html"]) {
2643
- const l = joinPaths(c, a);
2642
+ for (const c of ["index.php", "index.html"]) {
2643
+ const l = joinPaths(a, c);
2644
2644
  if (i.isFile(l)) {
2645
- c = l, n.pathname = joinPaths(
2645
+ a = l, n.pathname = joinPaths(
2646
2646
  n.pathname,
2647
- a
2647
+ c
2648
2648
  );
2649
2649
  break;
2650
2650
  }
2651
2651
  }
2652
2652
  }
2653
- if (!i.isFile(c)) {
2654
- let a = o;
2655
- for (; a.startsWith("/") && a !== dirname(a); ) {
2656
- a = dirname(a);
2657
- const l = m(this, P, U).call(this, a);
2653
+ if (!i.isFile(a)) {
2654
+ let c = o;
2655
+ for (; c.startsWith("/") && c !== dirname(c); ) {
2656
+ c = dirname(c);
2657
+ const l = m(this, P, U).call(this, c);
2658
2658
  if (i.isFile(l) && // Only run partial path resolution for PHP files.
2659
2659
  l.endsWith(".php")) {
2660
- c = m(this, P, U).call(this, a);
2660
+ a = m(this, P, U).call(this, c);
2661
2661
  break;
2662
2662
  }
2663
2663
  }
2664
2664
  }
2665
- if (!i.isFile(c)) {
2666
- const a = this.getFileNotFoundAction(
2665
+ if (!i.isFile(a)) {
2666
+ const c = this.getFileNotFoundAction(
2667
2667
  n.pathname
2668
2668
  );
2669
- switch (a.type) {
2669
+ switch (c.type) {
2670
2670
  case "response":
2671
- return a.response;
2671
+ return c.response;
2672
2672
  case "internal-redirect":
2673
- c = joinPaths(u(this, S), a.uri);
2673
+ a = joinPaths(u(this, v), c.uri);
2674
2674
  break;
2675
2675
  case "404":
2676
2676
  return PHPResponse.forHttpCode(404);
2677
2677
  default:
2678
2678
  throw new Error(
2679
- `Unsupported file-not-found action type: '${a.type}'`
2679
+ `Unsupported file-not-found action type: '${c.type}'`
2680
2680
  );
2681
2681
  }
2682
2682
  }
2683
- if (i.isFile(c))
2684
- if (c.endsWith(".php")) {
2685
- const a = await m(this, P, se).call(this, e, s, n, c);
2686
- return a.ok() && a.exitCode !== 0 ? new PHPResponse(
2683
+ if (i.isFile(a))
2684
+ if (a.endsWith(".php")) {
2685
+ const c = await m(this, P, se).call(this, e, s, n, a);
2686
+ return c.ok() && c.exitCode !== 0 ? new PHPResponse(
2687
2687
  500,
2688
- a.headers,
2689
- a.bytes,
2690
- a.errors,
2691
- a.exitCode
2692
- ) : a;
2688
+ c.headers,
2689
+ c.bytes,
2690
+ c.errors,
2691
+ c.exitCode
2692
+ ) : c;
2693
2693
  } else
2694
- return m(this, P, re).call(this, i, c);
2694
+ return m(this, P, re).call(this, i, a);
2695
2695
  else
2696
2696
  return PHPResponse.forHttpCode(404);
2697
2697
  }
@@ -2783,37 +2783,37 @@ class PHPRequestHandler {
2783
2783
  * $_GET['param'] | value
2784
2784
  * ```
2785
2785
  */
2786
- prepare_$_SERVER_superglobal(e, r, s) {
2786
+ prepare_$_SERVER_superglobal(e, t, s) {
2787
2787
  const n = {
2788
2788
  REMOTE_ADDR: "127.0.0.1",
2789
- DOCUMENT_ROOT: u(this, S),
2790
- HTTPS: u(this, N).startsWith("https://") ? "on" : ""
2789
+ DOCUMENT_ROOT: u(this, v),
2790
+ HTTPS: u(this, A).startsWith("https://") ? "on" : ""
2791
2791
  };
2792
- return n.REQUEST_URI = e.pathname + e.search, s.startsWith(u(this, S)) && (n.SCRIPT_NAME = s.substring(
2793
- u(this, S).length
2794
- ), n.PHP_SELF = r.pathname, n.REQUEST_URI.startsWith(n.SCRIPT_NAME) && (n.PATH_INFO = n.REQUEST_URI.substring(
2792
+ return n.REQUEST_URI = e.pathname + e.search, s.startsWith(u(this, v)) && (n.SCRIPT_NAME = s.substring(
2793
+ u(this, v).length
2794
+ ), n.PHP_SELF = t.pathname, n.REQUEST_URI.startsWith(n.SCRIPT_NAME) && (n.PATH_INFO = n.REQUEST_URI.substring(
2795
2795
  n.SCRIPT_NAME.length
2796
2796
  ), n.PATH_INFO.includes("?") && (n.PATH_INFO = n.PATH_INFO.substring(
2797
2797
  0,
2798
2798
  n.PATH_INFO.indexOf("?")
2799
- )))), n.QUERY_STRING = r.search.substring(1), n;
2799
+ )))), n.QUERY_STRING = t.search.substring(1), n;
2800
2800
  }
2801
2801
  async [Symbol.asyncDispose]() {
2802
2802
  await this.instanceManager[Symbol.asyncDispose]();
2803
2803
  }
2804
2804
  }
2805
- S = new WeakMap(), I = new WeakMap(), O = new WeakMap(), C = new WeakMap(), A = new WeakMap(), E = new WeakMap(), N = new WeakMap(), R = new WeakMap(), L = new WeakMap(), P = new WeakSet(), /**
2805
+ v = new WeakMap(), C = new WeakMap(), N = new WeakMap(), L = new WeakMap(), I = new WeakMap(), E = new WeakMap(), A = new WeakMap(), k = new WeakMap(), O = new WeakMap(), P = new WeakSet(), /**
2806
2806
  * Apply the rewrite rules to the original request URL.
2807
2807
  *
2808
2808
  * @param originalRequestUrl - The original request URL.
2809
2809
  * @returns The rewritten request URL.
2810
2810
  */
2811
2811
  te = function(e) {
2812
- const r = removePathPrefix(
2812
+ const t = removePathPrefix(
2813
2813
  decodeURIComponent(e.pathname),
2814
2814
  u(this, E)
2815
2815
  ), s = applyRewriteRules(
2816
- r,
2816
+ t,
2817
2817
  this.rewriteRules
2818
2818
  ), n = new URL(
2819
2819
  joinPaths(u(this, E), s),
@@ -2832,20 +2832,20 @@ te = function(e) {
2832
2832
  * @returns The resolved filesystem path
2833
2833
  */
2834
2834
  U = function(e) {
2835
- for (const r of u(this, L))
2836
- if (e === r.urlPrefix || e.startsWith(r.urlPrefix + "/")) {
2837
- const s = e.slice(r.urlPrefix.length);
2838
- return joinPaths(r.fsPath, s);
2835
+ for (const t of u(this, O))
2836
+ if (e === t.urlPrefix || e.startsWith(t.urlPrefix + "/")) {
2837
+ const s = e.slice(t.urlPrefix.length);
2838
+ return joinPaths(t.fsPath, s);
2839
2839
  }
2840
- return joinPaths(u(this, S), e);
2840
+ return joinPaths(u(this, v), e);
2841
2841
  }, /**
2842
2842
  * Serves a static file from the PHP filesystem.
2843
2843
  *
2844
2844
  * @param fsPath - Absolute path of the static file to serve.
2845
2845
  * @returns The response.
2846
2846
  */
2847
- re = function(e, r) {
2848
- const s = e.readFileAsBuffer(r);
2847
+ re = function(e, t) {
2848
+ const s = e.readFileAsBuffer(t);
2849
2849
  return new PHPResponse(
2850
2850
  200,
2851
2851
  {
@@ -2853,13 +2853,13 @@ re = function(e, r) {
2853
2853
  // @TODO: Infer the content-type from the arrayBuffer instead of the
2854
2854
  // file path. The code below won't return the correct mime-type if the
2855
2855
  // extension was tampered with.
2856
- "content-type": [inferMimeType(r)],
2856
+ "content-type": [inferMimeType(t)],
2857
2857
  "accept-ranges": ["bytes"],
2858
2858
  "cache-control": ["public, max-age=0"]
2859
2859
  },
2860
2860
  s
2861
2861
  );
2862
- }, se = async function(e, r, s, n) {
2862
+ }, se = async function(e, t, s, n) {
2863
2863
  let i;
2864
2864
  try {
2865
2865
  i = await this.instanceManager.acquirePHPInstance();
@@ -2867,22 +2867,22 @@ re = function(e, r) {
2867
2867
  return o instanceof MaxPhpInstancesError ? PHPResponse.forHttpCode(502) : PHPResponse.forHttpCode(500);
2868
2868
  }
2869
2869
  try {
2870
- return await m(this, P, ne).call(this, i.php, e, r, s, n);
2870
+ return await m(this, P, ne).call(this, i.php, e, t, s, n);
2871
2871
  } finally {
2872
2872
  i.reap();
2873
2873
  }
2874
- }, ne = async function(e, r, s, n, i) {
2874
+ }, ne = async function(e, t, s, n, i) {
2875
2875
  let o = "GET";
2876
- const c = {
2877
- host: u(this, A),
2878
- ...normalizeHeaders(r.headers || {})
2876
+ const a = {
2877
+ host: u(this, I),
2878
+ ...normalizeHeaders(t.headers || {})
2879
2879
  };
2880
- u(this, R) && (c.cookie = u(this, R).getCookieRequestHeader());
2881
- let a = r.body;
2882
- if (typeof a == "object" && !(a instanceof Uint8Array)) {
2880
+ u(this, k) && (a.cookie = u(this, k).getCookieRequestHeader());
2881
+ let c = t.body;
2882
+ if (typeof c == "object" && !(c instanceof Uint8Array)) {
2883
2883
  o = "POST";
2884
- const { bytes: l, contentType: d } = await encodeAsMultipart(a);
2885
- a = l, c["content-type"] = d;
2884
+ const { bytes: l, contentType: d } = await encodeAsMultipart(c);
2885
+ c = l, a["content-type"] = d;
2886
2886
  }
2887
2887
  try {
2888
2888
  const l = await e.run({
@@ -2890,18 +2890,18 @@ re = function(e, r) {
2890
2890
  toRelativeUrl(new URL(n.toString())),
2891
2891
  u(this, E)
2892
2892
  ),
2893
- protocol: u(this, I),
2894
- method: r.method || o,
2893
+ protocol: u(this, C),
2894
+ method: t.method || o,
2895
2895
  $_SERVER: this.prepare_$_SERVER_superglobal(
2896
2896
  s,
2897
2897
  n,
2898
2898
  i
2899
2899
  ),
2900
- body: a,
2900
+ body: c,
2901
2901
  scriptPath: i,
2902
- headers: c
2902
+ headers: a
2903
2903
  });
2904
- return u(this, R) && u(this, R).rememberCookiesFromResponseHeaders(
2904
+ return u(this, k) && u(this, k).rememberCookiesFromResponseHeaders(
2905
2905
  l.headers
2906
2906
  ), l;
2907
2907
  } catch (l) {
@@ -2911,134 +2911,134 @@ re = function(e, r) {
2911
2911
  throw l;
2912
2912
  }
2913
2913
  };
2914
- function inferMimeType(t) {
2915
- const e = t.split(".").pop();
2914
+ function inferMimeType(r) {
2915
+ const e = r.split(".").pop();
2916
2916
  return mimeTypes[e] || mimeTypes._default;
2917
2917
  }
2918
- function applyRewriteRules(t, e) {
2919
- for (const r of e)
2920
- if (new RegExp(r.match).test(t)) {
2921
- t = t.replace(r.match, r.replacement);
2918
+ function applyRewriteRules(r, e) {
2919
+ for (const t of e)
2920
+ if (new RegExp(t.match).test(r)) {
2921
+ r = r.replace(t.match, t.replacement);
2922
2922
  break;
2923
2923
  }
2924
- return t;
2924
+ return r;
2925
2925
  }
2926
- function looksLikeAbsoluteUrl(t) {
2926
+ function looksLikeAbsoluteUrl(r) {
2927
2927
  try {
2928
- return new URL(t), !0;
2928
+ return new URL(r), !0;
2929
2929
  } catch {
2930
2930
  return !1;
2931
2931
  }
2932
2932
  }
2933
2933
  function rotatePHPRuntime({
2934
- php: t,
2934
+ php: r,
2935
2935
  recreateRuntime: e,
2936
- maxRequests: r = 400
2936
+ maxRequests: t = 400
2937
2937
  }) {
2938
- return t.enableRuntimeRotation({
2938
+ return r.enableRuntimeRotation({
2939
2939
  recreateRuntime: e,
2940
- maxRequests: r
2940
+ maxRequests: t
2941
2941
  });
2942
2942
  }
2943
- async function writeFiles(t, e, r, { rmRoot: s = !1 } = {}) {
2944
- s && await t.isDir(e) && await t.rmdir(e, { recursive: !0 });
2945
- for (const [n, i] of Object.entries(r)) {
2943
+ async function writeFiles(r, e, t, { rmRoot: s = !1 } = {}) {
2944
+ s && await r.isDir(e) && await r.rmdir(e, { recursive: !0 });
2945
+ for (const [n, i] of Object.entries(t)) {
2946
2946
  const o = joinPaths(e, n);
2947
- await t.fileExists(dirname(o)) || await t.mkdir(dirname(o)), i instanceof Uint8Array || typeof i == "string" ? await t.writeFile(o, i) : await writeFiles(t, o, i);
2947
+ 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);
2948
2948
  }
2949
2949
  }
2950
- function ensureProxyFSHasMmapSupport(t) {
2951
- const e = Object.getOwnPropertySymbols(t)[0], r = t[e], s = r.PROXYFS, n = r.FS;
2952
- s.stream_ops.mmap || (s.stream_ops.mmap = function(i, o, c, a, l) {
2950
+ function ensureProxyFSHasMmapSupport(r) {
2951
+ const e = Object.getOwnPropertySymbols(r)[0], t = r[e], s = t.PROXYFS, n = t.FS;
2952
+ s.stream_ops.mmap || (s.stream_ops.mmap = function(i, o, a, c, l) {
2953
2953
  if (!n.isFile(i.node.mode))
2954
2954
  throw new n.ErrnoError(19);
2955
- if (c !== 0)
2955
+ if (a !== 0)
2956
2956
  throw new n.ErrnoError(22);
2957
- const d = r.malloc(o);
2957
+ const d = t.malloc(o);
2958
2958
  if (!d)
2959
2959
  throw new n.ErrnoError(48);
2960
- const p = r.HEAPU8.subarray(d, d + o);
2960
+ const p = t.HEAPU8.subarray(d, d + o);
2961
2961
  let f = 0;
2962
2962
  for (; f < o; ) {
2963
- const g = i.stream_ops.read(
2963
+ const _ = i.stream_ops.read(
2964
2964
  i,
2965
2965
  p,
2966
2966
  f,
2967
2967
  o - f,
2968
2968
  f
2969
2969
  );
2970
- if (g <= 0) break;
2971
- f += g;
2970
+ if (_ <= 0) break;
2971
+ f += _;
2972
2972
  }
2973
2973
  if (f !== o)
2974
- throw r.free(d), new n.ErrnoError(5);
2974
+ throw t.free(d), new n.ErrnoError(5);
2975
2975
  return { ptr: d, allocated: !0 };
2976
- }, s.stream_ops.msync = function(i, o, c, a, l) {
2976
+ }, s.stream_ops.msync = function(i, o, a, c, l) {
2977
2977
  return l & 2 || i.stream_ops.write(
2978
2978
  i,
2979
2979
  o,
2980
- c,
2981
2980
  a,
2982
2981
  c,
2982
+ a,
2983
2983
  !1
2984
2984
  ), 0;
2985
2985
  });
2986
2986
  }
2987
- function proxyFileSystem(t, e, r) {
2987
+ function proxyFileSystem(r, e, t) {
2988
2988
  ensureProxyFSHasMmapSupport(e);
2989
- const s = Object.getOwnPropertySymbols(e)[0], n = Object.getOwnPropertySymbols(t)[0];
2990
- for (const i of r)
2991
- e.fileExists(i) || e.mkdir(i), t.fileExists(i) || t.mkdir(i), e[s].FS.mount(
2989
+ const s = Object.getOwnPropertySymbols(e)[0], n = Object.getOwnPropertySymbols(r)[0];
2990
+ for (const i of t)
2991
+ e.fileExists(i) || e.mkdir(i), r.fileExists(i) || r.mkdir(i), e[s].FS.mount(
2992
2992
  // @ts-ignore
2993
2993
  e[s].PROXYFS,
2994
2994
  {
2995
2995
  root: i,
2996
2996
  // @ts-ignore
2997
- fs: t[n].FS
2997
+ fs: r[n].FS
2998
2998
  },
2999
2999
  i
3000
3000
  );
3001
3001
  }
3002
- function isPathToSharedFS(t, e) {
3002
+ function isPathToSharedFS(r, e) {
3003
3003
  var i;
3004
- const r = Object.getOwnPropertySymbols(t)[0], n = t[r].FS.lookupPath(e, { noent_okay: !0 });
3004
+ const t = Object.getOwnPropertySymbols(r)[0], n = r[t].FS.lookupPath(e, { noent_okay: !0 });
3005
3005
  return ((i = n == null ? void 0 : n.node) == null ? void 0 : i.isSharedFS) ?? !1;
3006
3006
  }
3007
- function sandboxedSpawnHandlerFactory(t) {
3008
- return createSpawnHandler(async function(e, r, s) {
3009
- r.notifySpawn(), (e == null ? void 0 : e[0]) === "/bin/sh" && (e == null ? void 0 : e[1]) === "-c" && typeof e[2] == "string" && (e = splitShellCommand(e[2])), e[0] === "exec" && e.shift(), (e[0].endsWith(".php") || e[0].endsWith(".phar")) && e.unshift("php");
3007
+ function sandboxedSpawnHandlerFactory(r) {
3008
+ return createSpawnHandler(async function(e, t, s) {
3009
+ t.notifySpawn(), (e == null ? void 0 : e[0]) === "/bin/sh" && (e == null ? void 0 : e[1]) === "-c" && typeof e[2] == "string" && (e = splitShellCommand(e[2])), e[0] === "exec" && e.shift(), (e[0].endsWith(".php") || e[0].endsWith(".phar")) && e.unshift("php");
3010
3010
  const n = e[0].split("/").pop();
3011
3011
  if (e[0] === "/usr/bin/env" && e[1] === "stty" && e[2] === "size")
3012
- r.stdout("18 140"), r.exit(0);
3012
+ t.stdout("18 140"), t.exit(0);
3013
3013
  else if (n === "tput" && e[1] === "cols")
3014
- r.stdout("140"), r.exit(0);
3014
+ t.stdout("140"), t.exit(0);
3015
3015
  else if (n === "less") {
3016
- r.on("stdin", (c) => {
3017
- r.stdout(c);
3018
- }), await new Promise((c) => {
3019
- r.childProcess.stdin.on("finish", () => {
3020
- c(!0);
3016
+ t.on("stdin", (a) => {
3017
+ t.stdout(a);
3018
+ }), await new Promise((a) => {
3019
+ t.childProcess.stdin.on("finish", () => {
3020
+ a(!0);
3021
3021
  });
3022
- }), r.exit(0);
3022
+ }), t.exit(0);
3023
3023
  return;
3024
3024
  }
3025
3025
  if (!["php", "ls", "pwd"].includes(n ?? "")) {
3026
- r.exit(127);
3026
+ t.exit(127);
3027
3027
  return;
3028
3028
  }
3029
- if (!t) {
3029
+ if (!r) {
3030
3030
  logger.warn(
3031
3031
  "Tried to spawn a PHP subprocess, but the sandboxed spawn handler was created without a getPHPInstance function."
3032
- ), r.exit(127);
3032
+ ), t.exit(127);
3033
3033
  return;
3034
3034
  }
3035
- const { php: i, reap: o } = await t();
3035
+ const { php: i, reap: o } = await r();
3036
3036
  try {
3037
3037
  s.cwd && await i.chdir(s.cwd);
3038
- const c = await i.cwd();
3038
+ const a = await i.cwd();
3039
3039
  switch (n) {
3040
3040
  case "php": {
3041
- const a = await i.cli(e, {
3041
+ const c = await i.cli(e, {
3042
3042
  env: {
3043
3043
  ...s.env,
3044
3044
  SCRIPT_PATH: e[1],
@@ -3048,82 +3048,82 @@ function sandboxedSpawnHandlerFactory(t) {
3048
3048
  SHELL_PIPE: "0"
3049
3049
  }
3050
3050
  });
3051
- a.stdout.pipeTo(
3051
+ c.stdout.pipeTo(
3052
3052
  new WritableStream({
3053
3053
  write(l) {
3054
- r.stdout(l);
3054
+ t.stdout(l);
3055
3055
  }
3056
3056
  })
3057
- ), a.stderr.pipeTo(
3057
+ ), c.stderr.pipeTo(
3058
3058
  new WritableStream({
3059
3059
  write(l) {
3060
- r.stderr(l);
3060
+ t.stderr(l);
3061
3061
  }
3062
3062
  })
3063
- ), r.exit(await a.exitCode);
3063
+ ), t.exit(await c.exitCode);
3064
3064
  break;
3065
3065
  }
3066
3066
  case "ls": {
3067
- const a = await i.listFiles(e[1] ?? c);
3068
- for (const l of a)
3069
- r.stdout(l + `
3067
+ const c = await i.listFiles(e[1] ?? a);
3068
+ for (const l of c)
3069
+ t.stdout(l + `
3070
3070
  `);
3071
- await new Promise((l) => setTimeout(l, 10)), r.exit(0);
3071
+ await new Promise((l) => setTimeout(l, 10)), t.exit(0);
3072
3072
  break;
3073
3073
  }
3074
3074
  case "pwd": {
3075
- r.stdout(c + `
3076
- `), await new Promise((a) => setTimeout(a, 10)), r.exit(0);
3075
+ t.stdout(a + `
3076
+ `), await new Promise((c) => setTimeout(c, 10)), t.exit(0);
3077
3077
  break;
3078
3078
  }
3079
3079
  }
3080
- } catch (c) {
3081
- throw r.exit(1), c;
3080
+ } catch (a) {
3081
+ throw t.exit(1), a;
3082
3082
  } finally {
3083
3083
  o();
3084
3084
  }
3085
3085
  });
3086
3086
  }
3087
- function exposeSync(t, e, r, s = ["*"]) {
3088
- return expose(t, e, s, r.afterResponseSent);
3087
+ function exposeSync(r, e, t, s = ["*"]) {
3088
+ return expose(r, e, s, t.afterResponseSent);
3089
3089
  }
3090
- function createSyncProxy(t, e = [], r) {
3090
+ function createSyncProxy(r, e = [], t) {
3091
3091
  return new Proxy(() => {
3092
3092
  }, {
3093
3093
  get(s, n) {
3094
3094
  return n === "then" && !e.length ? {
3095
- then: (i, o) => o(createSyncProxy(t, [], r))
3096
- } : createSyncProxy(t, [...e, n], r);
3095
+ then: (i, o) => o(createSyncProxy(r, [], t))
3096
+ } : createSyncProxy(r, [...e, n], t);
3097
3097
  },
3098
3098
  set(s, n, i) {
3099
- const [o, c] = toWireValue(i);
3100
- return r.send(
3101
- t,
3099
+ const [o, a] = toWireValue(i);
3100
+ return t.send(
3101
+ r,
3102
3102
  {
3103
3103
  type: MessageType.SET,
3104
3104
  path: [...e, n].map(String),
3105
3105
  value: o
3106
3106
  },
3107
- c
3107
+ a
3108
3108
  ), !0;
3109
3109
  },
3110
3110
  apply(s, n, i) {
3111
3111
  if (e.at(-1) === "bind")
3112
- return createSyncProxy(t, e.slice(0, -1), r);
3113
- const [c, a] = processArguments(i), l = r.send(
3114
- t,
3112
+ return createSyncProxy(r, e.slice(0, -1), t);
3113
+ const [a, c] = processArguments(i), l = t.send(
3114
+ r,
3115
3115
  {
3116
3116
  type: MessageType.APPLY,
3117
3117
  path: e.map(String),
3118
- argumentList: c
3118
+ argumentList: a
3119
3119
  },
3120
- a
3120
+ c
3121
3121
  );
3122
3122
  return fromWireValue(l);
3123
3123
  },
3124
3124
  construct(s, n) {
3125
- const [i, o] = processArguments(n), c = r.send(
3126
- t,
3125
+ const [i, o] = processArguments(n), a = t.send(
3126
+ r,
3127
3127
  {
3128
3128
  type: MessageType.CONSTRUCT,
3129
3129
  path: e.map(String),
@@ -3131,12 +3131,12 @@ function createSyncProxy(t, e = [], r) {
3131
3131
  },
3132
3132
  o
3133
3133
  );
3134
- return fromWireValue(c);
3134
+ return fromWireValue(a);
3135
3135
  }
3136
3136
  });
3137
3137
  }
3138
- function wrapSync(t, e) {
3139
- return createSyncProxy(t, [], e);
3138
+ function wrapSync(r, e) {
3139
+ return createSyncProxy(r, [], e);
3140
3140
  }
3141
3141
  class NodeSABSyncReceiveMessageTransport {
3142
3142
  static async create() {
@@ -3153,19 +3153,19 @@ class NodeSABSyncReceiveMessageTransport {
3153
3153
  constructor() {
3154
3154
  }
3155
3155
  afterResponseSent(e) {
3156
- const { notifyBuffer: r } = e.data;
3157
- if (r) {
3158
- const s = new Int32Array(r);
3156
+ const { notifyBuffer: t } = e.data;
3157
+ if (t) {
3158
+ const s = new Int32Array(t);
3159
3159
  s[0] = 1, Atomics.notify(s, 0);
3160
3160
  }
3161
3161
  }
3162
- send(e, r, s) {
3162
+ send(e, t, s) {
3163
3163
  var l;
3164
3164
  const n = new SharedArrayBuffer(4), i = new Int32Array(n);
3165
3165
  i[0] = 0;
3166
3166
  const o = generateUUID();
3167
3167
  if (e.postMessage(
3168
- { ...r, id: o, notifyBuffer: n },
3168
+ { ...t, id: o, notifyBuffer: n },
3169
3169
  s
3170
3170
  ), Atomics.wait(i, 0, 0, 5e3) === "timed-out")
3171
3171
  throw new Error("Timeout waiting for response");
@@ -3201,65 +3201,65 @@ const WireValueType = {
3201
3201
  CONSTRUCT: "CONSTRUCT",
3202
3202
  ENDPOINT: "ENDPOINT",
3203
3203
  RELEASE: "RELEASE"
3204
- }, isObject = (t) => typeof t == "object" && t !== null || typeof t == "function", proxyTransferHandler = {
3205
- canHandle: (t) => isObject(t) && t[proxyMarker],
3206
- serialize(t) {
3207
- const { port1: e, port2: r } = new MessageChannel();
3208
- return expose(t, e), [r, [r]];
3204
+ }, isObject = (r) => typeof r == "object" && r !== null || typeof r == "function", proxyTransferHandler = {
3205
+ canHandle: (r) => isObject(r) && r[proxyMarker],
3206
+ serialize(r) {
3207
+ const { port1: e, port2: t } = new MessageChannel();
3208
+ return expose(r, e), [t, [t]];
3209
3209
  },
3210
- deserialize(t) {
3211
- return t.start(), wrap(t);
3210
+ deserialize(r) {
3211
+ return r.start(), wrap(r);
3212
3212
  }
3213
3213
  }, throwTransferHandler$1 = {
3214
- canHandle: (t) => isObject(t) && throwMarker in t,
3215
- serialize({ value: t }) {
3214
+ canHandle: (r) => isObject(r) && throwMarker in r,
3215
+ serialize({ value: r }) {
3216
3216
  let e;
3217
- return t instanceof Error ? e = {
3217
+ return r instanceof Error ? e = {
3218
3218
  isError: !0,
3219
3219
  value: {
3220
- message: t.message,
3221
- name: t.name,
3222
- stack: t.stack
3220
+ message: r.message,
3221
+ name: r.name,
3222
+ stack: r.stack
3223
3223
  }
3224
- } : e = { isError: !1, value: t }, [e, []];
3224
+ } : e = { isError: !1, value: r }, [e, []];
3225
3225
  },
3226
- deserialize(t) {
3227
- throw t.isError ? Object.assign(
3228
- new Error(t.value.message),
3229
- t.value
3230
- ) : t.value;
3226
+ deserialize(r) {
3227
+ throw r.isError ? Object.assign(
3228
+ new Error(r.value.message),
3229
+ r.value
3230
+ ) : r.value;
3231
3231
  }
3232
3232
  }, transferHandlers = /* @__PURE__ */ new Map([
3233
3233
  ["proxy", proxyTransferHandler],
3234
3234
  ["throw", throwTransferHandler$1]
3235
3235
  ]);
3236
- function isAllowedOrigin(t, e) {
3237
- for (const r of t)
3238
- if (e === r || r === "*" || r instanceof RegExp && r.test(e))
3236
+ function isAllowedOrigin(r, e) {
3237
+ for (const t of r)
3238
+ if (e === t || t === "*" || t instanceof RegExp && t.test(e))
3239
3239
  return !0;
3240
3240
  return !1;
3241
3241
  }
3242
- function expose(t, e = globalThis, r = ["*"], s) {
3242
+ function expose(r, e = globalThis, t = ["*"], s) {
3243
3243
  e.addEventListener("message", function n(i) {
3244
3244
  if (!i || !i.data)
3245
3245
  return;
3246
- if (!isAllowedOrigin(r, i.origin)) {
3246
+ if (!isAllowedOrigin(t, i.origin)) {
3247
3247
  console.warn(`Invalid origin '${i.origin}' for comlink proxy`);
3248
3248
  return;
3249
3249
  }
3250
- const { id: o, type: c, path: a } = {
3250
+ const { id: o, type: a, path: c } = {
3251
3251
  path: [],
3252
3252
  ...i.data
3253
3253
  }, l = (i.data.argumentList || []).map(fromWireValue);
3254
3254
  let d;
3255
3255
  try {
3256
- const p = a.slice(0, -1).reduce((g, b) => g[b], t), f = a.reduce((g, b) => g[b], t);
3257
- switch (c) {
3256
+ const p = c.slice(0, -1).reduce((_, F) => _[F], r), f = c.reduce((_, F) => _[F], r);
3257
+ switch (a) {
3258
3258
  case MessageType.GET:
3259
3259
  d = f;
3260
3260
  break;
3261
3261
  case MessageType.SET:
3262
- p[a.slice(-1)[0]] = fromWireValue(
3262
+ p[c.slice(-1)[0]] = fromWireValue(
3263
3263
  i.data.value
3264
3264
  ), d = !0;
3265
3265
  break;
@@ -3268,14 +3268,14 @@ function expose(t, e = globalThis, r = ["*"], s) {
3268
3268
  break;
3269
3269
  case MessageType.CONSTRUCT:
3270
3270
  {
3271
- const g = new f(...l);
3272
- d = proxy(g);
3271
+ const _ = new f(...l);
3272
+ d = proxy(_);
3273
3273
  }
3274
3274
  break;
3275
3275
  case MessageType.ENDPOINT:
3276
3276
  {
3277
- const { port1: g, port2: b } = new MessageChannel();
3278
- expose(t, b), d = transfer(g, [g]);
3277
+ const { port1: _, port2: F } = new MessageChannel();
3278
+ expose(r, F), d = transfer(_, [_]);
3279
3279
  }
3280
3280
  break;
3281
3281
  case MessageType.RELEASE:
@@ -3288,8 +3288,8 @@ function expose(t, e = globalThis, r = ["*"], s) {
3288
3288
  d = { value: p, [throwMarker]: 0 };
3289
3289
  }
3290
3290
  Promise.resolve(d).catch((p) => ({ value: p, [throwMarker]: 0 })).then((p) => {
3291
- const [f, g] = toWireValue(p);
3292
- e.postMessage({ ...f, id: o }, g), c === MessageType.RELEASE && (e.removeEventListener("message", n), closeEndPoint(e), finalizer in t && typeof t[finalizer] == "function" && t[finalizer]());
3291
+ const [f, _] = toWireValue(p);
3292
+ e.postMessage({ ...f, id: o }, _), a === MessageType.RELEASE && (e.removeEventListener("message", n), closeEndPoint(e), finalizer in r && typeof r[finalizer] == "function" && r[finalizer]());
3293
3293
  }).catch(() => {
3294
3294
  const [p, f] = toWireValue({
3295
3295
  value: new TypeError("Unserializable return value"),
@@ -3301,146 +3301,146 @@ function expose(t, e = globalThis, r = ["*"], s) {
3301
3301
  });
3302
3302
  }), e.start && e.start();
3303
3303
  }
3304
- function isMessagePort(t) {
3305
- return t.constructor.name === "MessagePort";
3304
+ function isMessagePort(r) {
3305
+ return r.constructor.name === "MessagePort";
3306
3306
  }
3307
- function closeEndPoint(t) {
3308
- isMessagePort(t) && t.close();
3307
+ function closeEndPoint(r) {
3308
+ isMessagePort(r) && r.close();
3309
3309
  }
3310
- function wrap(t, e) {
3311
- const r = /* @__PURE__ */ new Map();
3312
- return t.addEventListener("message", function(n) {
3310
+ function wrap(r, e) {
3311
+ const t = /* @__PURE__ */ new Map();
3312
+ return r.addEventListener("message", function(n) {
3313
3313
  const { data: i } = n;
3314
3314
  if (!i || !i.id)
3315
3315
  return;
3316
- const o = r.get(i.id);
3316
+ const o = t.get(i.id);
3317
3317
  if (o)
3318
3318
  try {
3319
3319
  o(i);
3320
3320
  } finally {
3321
- r.delete(i.id);
3321
+ t.delete(i.id);
3322
3322
  }
3323
- }), createProxy(t, r, [], e);
3323
+ }), createProxy(r, t, [], e);
3324
3324
  }
3325
- function throwIfProxyReleased(t) {
3326
- if (t)
3325
+ function throwIfProxyReleased(r) {
3326
+ if (r)
3327
3327
  throw new Error("Proxy has been released and is not useable");
3328
3328
  }
3329
- function releaseEndpoint(t) {
3330
- return requestResponseMessage(t, /* @__PURE__ */ new Map(), {
3329
+ function releaseEndpoint(r) {
3330
+ return requestResponseMessage(r, /* @__PURE__ */ new Map(), {
3331
3331
  type: MessageType.RELEASE
3332
3332
  }).then(() => {
3333
- closeEndPoint(t);
3333
+ closeEndPoint(r);
3334
3334
  });
3335
3335
  }
3336
- const proxyCounter = /* @__PURE__ */ new WeakMap(), proxyFinalizers = "FinalizationRegistry" in globalThis && new FinalizationRegistry((t) => {
3337
- const e = (proxyCounter.get(t) || 0) - 1;
3338
- proxyCounter.set(t, e), e === 0 && releaseEndpoint(t);
3336
+ const proxyCounter = /* @__PURE__ */ new WeakMap(), proxyFinalizers = "FinalizationRegistry" in globalThis && new FinalizationRegistry((r) => {
3337
+ const e = (proxyCounter.get(r) || 0) - 1;
3338
+ proxyCounter.set(r, e), e === 0 && releaseEndpoint(r);
3339
3339
  });
3340
- function registerProxy(t, e) {
3341
- const r = (proxyCounter.get(e) || 0) + 1;
3342
- proxyCounter.set(e, r), proxyFinalizers && proxyFinalizers.register(t, e, t);
3340
+ function registerProxy(r, e) {
3341
+ const t = (proxyCounter.get(e) || 0) + 1;
3342
+ proxyCounter.set(e, t), proxyFinalizers && proxyFinalizers.register(r, e, r);
3343
3343
  }
3344
- function unregisterProxy(t) {
3345
- proxyFinalizers && proxyFinalizers.unregister(t);
3344
+ function unregisterProxy(r) {
3345
+ proxyFinalizers && proxyFinalizers.unregister(r);
3346
3346
  }
3347
- function createProxy(t, e, r = [], s = function() {
3347
+ function createProxy(r, e, t = [], s = function() {
3348
3348
  }) {
3349
3349
  let n = !1;
3350
3350
  const i = new Proxy(s, {
3351
- get(o, c) {
3352
- if (throwIfProxyReleased(n), c === releaseProxy)
3351
+ get(o, a) {
3352
+ if (throwIfProxyReleased(n), a === releaseProxy)
3353
3353
  return () => {
3354
- unregisterProxy(i), releaseEndpoint(t), e.clear(), n = !0;
3354
+ unregisterProxy(i), releaseEndpoint(r), e.clear(), n = !0;
3355
3355
  };
3356
- if (c === "then") {
3357
- if (r.length === 0)
3356
+ if (a === "then") {
3357
+ if (t.length === 0)
3358
3358
  return { then: () => i };
3359
- const a = requestResponseMessage(t, e, {
3359
+ const c = requestResponseMessage(r, e, {
3360
3360
  type: MessageType.GET,
3361
- path: r.map((l) => l.toString())
3361
+ path: t.map((l) => l.toString())
3362
3362
  }).then(fromWireValue);
3363
- return a.then.bind(a);
3363
+ return c.then.bind(c);
3364
3364
  }
3365
- return createProxy(t, e, [...r, c]);
3365
+ return createProxy(r, e, [...t, a]);
3366
3366
  },
3367
- set(o, c, a) {
3367
+ set(o, a, c) {
3368
3368
  throwIfProxyReleased(n);
3369
- const [l, d] = toWireValue(a);
3369
+ const [l, d] = toWireValue(c);
3370
3370
  return requestResponseMessage(
3371
- t,
3371
+ r,
3372
3372
  e,
3373
3373
  {
3374
3374
  type: MessageType.SET,
3375
- path: [...r, c].map((p) => p.toString()),
3375
+ path: [...t, a].map((p) => p.toString()),
3376
3376
  value: l
3377
3377
  },
3378
3378
  d
3379
3379
  ).then(fromWireValue);
3380
3380
  },
3381
- apply(o, c, a) {
3381
+ apply(o, a, c) {
3382
3382
  throwIfProxyReleased(n);
3383
- const l = r[r.length - 1];
3383
+ const l = t[t.length - 1];
3384
3384
  if (l === createEndpoint)
3385
- return requestResponseMessage(t, e, {
3385
+ return requestResponseMessage(r, e, {
3386
3386
  type: MessageType.ENDPOINT
3387
3387
  }).then(fromWireValue);
3388
3388
  if (l === "bind")
3389
- return createProxy(t, e, r.slice(0, -1));
3390
- const [d, p] = processArguments(a);
3389
+ return createProxy(r, e, t.slice(0, -1));
3390
+ const [d, p] = processArguments(c);
3391
3391
  return requestResponseMessage(
3392
- t,
3392
+ r,
3393
3393
  e,
3394
3394
  {
3395
3395
  type: MessageType.APPLY,
3396
- path: r.map((f) => f.toString()),
3396
+ path: t.map((f) => f.toString()),
3397
3397
  argumentList: d
3398
3398
  },
3399
3399
  p
3400
3400
  ).then(fromWireValue);
3401
3401
  },
3402
- construct(o, c) {
3402
+ construct(o, a) {
3403
3403
  throwIfProxyReleased(n);
3404
- const [a, l] = processArguments(c);
3404
+ const [c, l] = processArguments(a);
3405
3405
  return requestResponseMessage(
3406
- t,
3406
+ r,
3407
3407
  e,
3408
3408
  {
3409
3409
  type: MessageType.CONSTRUCT,
3410
- path: r.map((d) => d.toString()),
3411
- argumentList: a
3410
+ path: t.map((d) => d.toString()),
3411
+ argumentList: c
3412
3412
  },
3413
3413
  l
3414
3414
  ).then(fromWireValue);
3415
3415
  }
3416
3416
  });
3417
- return registerProxy(i, t), i;
3417
+ return registerProxy(i, r), i;
3418
3418
  }
3419
- function myFlat(t) {
3420
- return Array.prototype.concat.apply([], t);
3419
+ function myFlat(r) {
3420
+ return Array.prototype.concat.apply([], r);
3421
3421
  }
3422
- function processArguments(t) {
3423
- const e = t.map(toWireValue);
3424
- return [e.map((r) => r[0]), myFlat(e.map((r) => r[1]))];
3422
+ function processArguments(r) {
3423
+ const e = r.map(toWireValue);
3424
+ return [e.map((t) => t[0]), myFlat(e.map((t) => t[1]))];
3425
3425
  }
3426
3426
  const transferCache = /* @__PURE__ */ new WeakMap();
3427
- function transfer(t, e) {
3428
- return transferCache.set(t, e), t;
3427
+ function transfer(r, e) {
3428
+ return transferCache.set(r, e), r;
3429
3429
  }
3430
- function proxy(t) {
3431
- return Object.assign(t, { [proxyMarker]: !0 });
3430
+ function proxy(r) {
3431
+ return Object.assign(r, { [proxyMarker]: !0 });
3432
3432
  }
3433
- function windowEndpoint(t, e = globalThis, r = "*") {
3433
+ function windowEndpoint(r, e = globalThis, t = "*") {
3434
3434
  return {
3435
- postMessage: (s, n) => t.postMessage(s, r, n),
3435
+ postMessage: (s, n) => r.postMessage(s, t, n),
3436
3436
  addEventListener: e.addEventListener.bind(e),
3437
3437
  removeEventListener: e.removeEventListener.bind(e)
3438
3438
  };
3439
3439
  }
3440
- function toWireValue(t) {
3441
- for (const [e, r] of transferHandlers)
3442
- if (r.canHandle(t)) {
3443
- const [s, n] = r.serialize(t);
3440
+ function toWireValue(r) {
3441
+ for (const [e, t] of transferHandlers)
3442
+ if (t.canHandle(r)) {
3443
+ const [s, n] = t.serialize(r);
3444
3444
  return [
3445
3445
  {
3446
3446
  type: WireValueType.HANDLER,
@@ -3453,23 +3453,23 @@ function toWireValue(t) {
3453
3453
  return [
3454
3454
  {
3455
3455
  type: WireValueType.RAW,
3456
- value: t
3456
+ value: r
3457
3457
  },
3458
- transferCache.get(t) || []
3458
+ transferCache.get(r) || []
3459
3459
  ];
3460
3460
  }
3461
- function fromWireValue(t) {
3462
- switch (t.type) {
3461
+ function fromWireValue(r) {
3462
+ switch (r.type) {
3463
3463
  case WireValueType.HANDLER:
3464
- return transferHandlers.get(t.name).deserialize(t.value);
3464
+ return transferHandlers.get(r.name).deserialize(r.value);
3465
3465
  case WireValueType.RAW:
3466
- return t.value;
3466
+ return r.value;
3467
3467
  }
3468
3468
  }
3469
- function requestResponseMessage(t, e, r, s) {
3469
+ function requestResponseMessage(r, e, t, s) {
3470
3470
  return new Promise((n) => {
3471
3471
  const i = generateUUID();
3472
- e.set(i, n), t.start && t.start(), t.postMessage({ id: i, ...r }, s);
3472
+ e.set(i, n), r.start && r.start(), r.postMessage({ id: i, ...t }, s);
3473
3473
  });
3474
3474
  }
3475
3475
  function generateUUID() {
@@ -3477,21 +3477,50 @@ function generateUUID() {
3477
3477
  () => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)
3478
3478
  ).join("-");
3479
3479
  }
3480
- function nodeEndpoint(t) {
3480
+ function nodeEndpoint(r) {
3481
3481
  const e = /* @__PURE__ */ new WeakMap();
3482
3482
  return {
3483
- postMessage: t.postMessage.bind(t),
3484
- addEventListener: (r, s) => {
3483
+ postMessage: r.postMessage.bind(r),
3484
+ addEventListener: (t, s) => {
3485
3485
  const n = (i) => {
3486
3486
  "handleEvent" in s ? s.handleEvent({ data: i }) : s({ data: i });
3487
3487
  };
3488
- t.on("message", n), e.set(s, n);
3488
+ r.on("message", n), e.set(s, n);
3489
3489
  },
3490
- removeEventListener: (r, s) => {
3490
+ removeEventListener: (t, s) => {
3491
3491
  const n = e.get(s);
3492
- n && (t.off("message", n), e.delete(s));
3492
+ n && (r.off("message", n), e.delete(s));
3493
+ },
3494
+ start: r.start && r.start.bind(r)
3495
+ };
3496
+ }
3497
+ const proxyByListener = /* @__PURE__ */ new WeakMap();
3498
+ function nodeProcessEndpoint(r) {
3499
+ const e = r || process;
3500
+ if (typeof e.send != "function")
3501
+ throw new Error(
3502
+ "IPC channel is not available. Did you forget to fork the process?"
3503
+ );
3504
+ const t = e;
3505
+ return {
3506
+ postMessage(s, n) {
3507
+ var i;
3508
+ if (n && n.length > 0)
3509
+ throw new Error(
3510
+ "Transferable objects are not supported for nodeProcessEndpoint"
3511
+ );
3512
+ (i = t.send) == null || i.call(t, s);
3493
3513
  },
3494
- start: t.start && t.start.bind(t)
3514
+ addEventListener(s, n) {
3515
+ const i = typeof n == "function" ? (o) => n({ data: o }) : (o) => n.handleEvent({ data: o });
3516
+ proxyByListener.set(n, i), t.addListener(s, i);
3517
+ },
3518
+ removeEventListener(s, n) {
3519
+ const i = proxyByListener.get(n);
3520
+ i && (proxyByListener.delete(n), t.removeListener(s, i));
3521
+ },
3522
+ start() {
3523
+ }
3495
3524
  };
3496
3525
  }
3497
3526
  const list = [
@@ -3510,7 +3539,7 @@ const list = [
3510
3539
  // https://nodejs.org/api/errors.html
3511
3540
  globalThis.AssertionError,
3512
3541
  globalThis.SystemError
3513
- ].filter(Boolean).map((t) => [t.name, t]), errorConstructors = new Map(list);
3542
+ ].filter(Boolean).map((r) => [r.name, r]), errorConstructors = new Map(list);
3514
3543
  class NonError extends Error {
3515
3544
  constructor(e) {
3516
3545
  super(NonError._prepareSuperMessage(e)), this.name = "NonError";
@@ -3548,231 +3577,255 @@ const errorProperties = [
3548
3577
  property: "errors",
3549
3578
  enumerable: !1
3550
3579
  }
3551
- ], toJsonWasCalled = /* @__PURE__ */ new WeakSet(), toJSON = (t) => {
3552
- toJsonWasCalled.add(t);
3553
- const e = t.toJSON();
3554
- return toJsonWasCalled.delete(t), e;
3555
- }, newError = (t) => {
3556
- const e = errorConstructors.get(t) ?? Error;
3580
+ ], toJsonWasCalled = /* @__PURE__ */ new WeakSet(), toJSON = (r) => {
3581
+ toJsonWasCalled.add(r);
3582
+ const e = r.toJSON();
3583
+ return toJsonWasCalled.delete(r), e;
3584
+ }, newError = (r) => {
3585
+ const e = errorConstructors.get(r) ?? Error;
3557
3586
  return e === AggregateError ? new e([]) : new e();
3558
3587
  }, destroyCircular = ({
3559
- from: t,
3588
+ from: r,
3560
3589
  seen: e,
3561
- to: r,
3590
+ to: t,
3562
3591
  forceEnumerable: s,
3563
3592
  maxDepth: n,
3564
3593
  depth: i,
3565
3594
  useToJSON: o,
3566
- serialize: c
3595
+ serialize: a
3567
3596
  }) => {
3568
- if (r || (Array.isArray(t) ? r = [] : !c && isErrorLike(t) ? r = newError(t.name) : r = {}), e.push(t), i >= n)
3569
- return r;
3570
- if (o && typeof t.toJSON == "function" && !toJsonWasCalled.has(t))
3571
- return toJSON(t);
3572
- const a = (l) => destroyCircular({
3597
+ if (t || (Array.isArray(r) ? t = [] : !a && isErrorLike(r) ? t = newError(r.name) : t = {}), e.push(r), i >= n)
3598
+ return t;
3599
+ if (o && typeof r.toJSON == "function" && !toJsonWasCalled.has(r))
3600
+ return toJSON(r);
3601
+ const c = (l) => destroyCircular({
3573
3602
  from: l,
3574
3603
  seen: [...e],
3575
3604
  forceEnumerable: s,
3576
3605
  maxDepth: n,
3577
3606
  depth: i,
3578
3607
  useToJSON: o,
3579
- serialize: c
3608
+ serialize: a
3580
3609
  });
3581
- for (const [l, d] of Object.entries(t)) {
3610
+ for (const [l, d] of Object.entries(r)) {
3582
3611
  if (d && d instanceof Uint8Array && d.constructor.name === "Buffer") {
3583
- r[l] = "[object Buffer]";
3612
+ t[l] = "[object Buffer]";
3584
3613
  continue;
3585
3614
  }
3586
3615
  if (d !== null && typeof d == "object" && typeof d.pipe == "function") {
3587
- r[l] = "[object Stream]";
3616
+ t[l] = "[object Stream]";
3588
3617
  continue;
3589
3618
  }
3590
3619
  if (typeof d != "function") {
3591
3620
  if (!d || typeof d != "object") {
3592
3621
  try {
3593
- r[l] = d;
3622
+ t[l] = d;
3594
3623
  } catch {
3595
3624
  }
3596
3625
  continue;
3597
3626
  }
3598
- if (!e.includes(t[l])) {
3599
- i++, r[l] = a(t[l]);
3627
+ if (!e.includes(r[l])) {
3628
+ i++, t[l] = c(r[l]);
3600
3629
  continue;
3601
3630
  }
3602
- r[l] = "[Circular]";
3631
+ t[l] = "[Circular]";
3603
3632
  }
3604
3633
  }
3605
- if (c || r instanceof Error)
3634
+ if (a || t instanceof Error)
3606
3635
  for (const { property: l, enumerable: d } of errorProperties)
3607
- t[l] !== void 0 && t[l] !== null && Object.defineProperty(r, l, {
3608
- value: isErrorLike(t[l]) || Array.isArray(t[l]) ? a(t[l]) : t[l],
3636
+ r[l] !== void 0 && r[l] !== null && Object.defineProperty(t, l, {
3637
+ value: isErrorLike(r[l]) || Array.isArray(r[l]) ? c(r[l]) : r[l],
3609
3638
  enumerable: s ? !0 : d,
3610
3639
  configurable: !0,
3611
3640
  writable: !0
3612
3641
  });
3613
- return r;
3642
+ return t;
3614
3643
  };
3615
- function serializeError(t, e = {}) {
3616
- const { maxDepth: r = Number.POSITIVE_INFINITY, useToJSON: s = !0 } = e;
3617
- return typeof t == "object" && t !== null ? destroyCircular({
3618
- from: t,
3644
+ function serializeError(r, e = {}) {
3645
+ const { maxDepth: t = Number.POSITIVE_INFINITY, useToJSON: s = !0 } = e;
3646
+ return typeof r == "object" && r !== null ? destroyCircular({
3647
+ from: r,
3619
3648
  seen: [],
3620
3649
  forceEnumerable: !0,
3621
- maxDepth: r,
3650
+ maxDepth: t,
3622
3651
  depth: 0,
3623
3652
  useToJSON: s,
3624
3653
  serialize: !0
3625
- }) : typeof t == "function" ? `[Function: ${t.name || "anonymous"}]` : t;
3654
+ }) : typeof r == "function" ? `[Function: ${r.name || "anonymous"}]` : r;
3626
3655
  }
3627
- function deserializeError(t, e = {}) {
3628
- const { maxDepth: r = Number.POSITIVE_INFINITY } = e;
3629
- return t instanceof Error ? t : isMinimumViableSerializedError(t) ? destroyCircular({
3630
- from: t,
3656
+ function deserializeError(r, e = {}) {
3657
+ const { maxDepth: t = Number.POSITIVE_INFINITY } = e;
3658
+ return r instanceof Error ? r : isMinimumViableSerializedError(r) ? destroyCircular({
3659
+ from: r,
3631
3660
  seen: [],
3632
- to: newError(t.name),
3633
- maxDepth: r,
3661
+ to: newError(r.name),
3662
+ maxDepth: t,
3634
3663
  depth: 0,
3635
3664
  serialize: !1
3636
- }) : new NonError(t);
3665
+ }) : new NonError(r);
3637
3666
  }
3638
- function isErrorLike(t) {
3639
- return !!t && typeof t == "object" && typeof t.name == "string" && typeof t.message == "string" && typeof t.stack == "string";
3667
+ function isErrorLike(r) {
3668
+ return !!r && typeof r == "object" && typeof r.name == "string" && typeof r.message == "string" && typeof r.stack == "string";
3640
3669
  }
3641
- function isMinimumViableSerializedError(t) {
3642
- return !!t && typeof t == "object" && typeof t.message == "string" && !Array.isArray(t);
3670
+ function isMinimumViableSerializedError(r) {
3671
+ return !!r && typeof r == "object" && typeof r.message == "string" && !Array.isArray(r);
3643
3672
  }
3644
- async function consumeAPISync(t) {
3673
+ const releaseApiProxy = releaseProxy;
3674
+ async function consumeAPISync(r) {
3645
3675
  setupTransferHandlers();
3646
3676
  const e = await NodeSABSyncReceiveMessageTransport.create();
3647
- return wrapSync(t, e);
3677
+ return wrapSync(r, e);
3648
3678
  }
3649
- function consumeAPI(t, e = void 0) {
3679
+ function consumeAPI(r, e = void 0) {
3650
3680
  setupTransferHandlers();
3651
- let r;
3652
- typeof process < "u" && typeof process.versions < "u" && typeof process.versions.node < "u" ? r = nodeEndpoint(t) : r = t instanceof Worker ? t : windowEndpoint(t, e);
3653
- const n = wrap(r), i = proxyClone(n);
3681
+ let t;
3682
+ if (typeof process < "u" && typeof process.versions < "u" && typeof process.versions.node < "u")
3683
+ if ("postMessage" in r)
3684
+ t = nodeEndpoint(r);
3685
+ else if ("send" in r && "addListener" in r)
3686
+ t = nodeProcessEndpoint(r);
3687
+ else
3688
+ throw new Error(
3689
+ "consumeAPI: remote does not look like a Worker, MessagePort, or Process"
3690
+ );
3691
+ else
3692
+ t = r instanceof Worker ? r : windowEndpoint(r, e);
3693
+ const n = wrap(t), i = proxyClone(n);
3654
3694
  return new Proxy(i, {
3655
- get: (o, c) => c === "isConnected" ? async () => {
3695
+ get: (o, a) => a === "isConnected" ? async () => {
3656
3696
  for (; ; )
3657
3697
  try {
3658
3698
  await runWithTimeout(n.isConnected(), 200);
3659
3699
  break;
3660
3700
  } catch {
3661
3701
  }
3662
- } : n[c]
3702
+ } : n[a]
3663
3703
  });
3664
3704
  }
3665
- async function runWithTimeout(t, e) {
3666
- return new Promise((r, s) => {
3667
- setTimeout(s, e), t.then(r);
3705
+ async function runWithTimeout(r, e) {
3706
+ return new Promise((t, s) => {
3707
+ setTimeout(s, e), r.then(t);
3668
3708
  });
3669
3709
  }
3670
- function exposeAPI(t, e, r) {
3710
+ function exposeAPI(r, e, t) {
3671
3711
  const { setReady: s, setFailed: n, exposedApi: i } = prepareForExpose(
3672
- t,
3712
+ r,
3673
3713
  e
3674
3714
  );
3675
3715
  let o;
3676
- return r ? o = nodeEndpoint(r) : o = typeof window < "u" ? windowEndpoint(self.parent) : void 0, expose(i, o), [s, n, i];
3716
+ if (t)
3717
+ if ("addEventListener" in t)
3718
+ o = t;
3719
+ else if ("postMessage" in t)
3720
+ o = nodeEndpoint(t);
3721
+ else if ("send" in t && "addListener" in t)
3722
+ o = nodeProcessEndpoint(t);
3723
+ else
3724
+ throw new Error(
3725
+ "exposeAPI: targetWorker does not look like a Worker, MessagePort, or Process"
3726
+ );
3727
+ else
3728
+ o = typeof window < "u" ? windowEndpoint(self.parent) : void 0;
3729
+ return expose(i, o), [s, n, i];
3677
3730
  }
3678
- async function exposeSyncAPI(t, e) {
3679
- const { setReady: r, setFailed: s, exposedApi: n } = prepareForExpose(t), i = await NodeSABSyncReceiveMessageTransport.create(), o = nodeEndpoint(e);
3680
- return exposeSync(n, o, i), [r, s, n];
3731
+ async function exposeSyncAPI(r, e) {
3732
+ const { setReady: t, setFailed: s, exposedApi: n } = prepareForExpose(r), i = await NodeSABSyncReceiveMessageTransport.create(), o = nodeEndpoint(e);
3733
+ return exposeSync(n, o, i), [t, s, n];
3681
3734
  }
3682
- function prepareForExpose(t, e) {
3735
+ function prepareForExpose(r, e) {
3683
3736
  setupTransferHandlers();
3684
- const r = Promise.resolve();
3737
+ const t = Promise.resolve();
3685
3738
  let s, n;
3686
- const i = new Promise((a, l) => {
3687
- s = a, n = l;
3688
- }), o = proxyClone(t), c = new Proxy(o, {
3689
- get: (a, l) => l === "isConnected" ? () => r : l === "isReady" ? () => i : l in a ? a[l] : e == null ? void 0 : e[l]
3739
+ const i = new Promise((c, l) => {
3740
+ s = c, n = l;
3741
+ }), o = proxyClone(r), a = new Proxy(o, {
3742
+ get: (c, l) => l === "isConnected" ? () => t : l === "isReady" ? () => i : l in c ? c[l] : e == null ? void 0 : e[l]
3690
3743
  });
3691
- return { setReady: s, setFailed: n, exposedApi: c };
3744
+ return { setReady: s, setFailed: n, exposedApi: a };
3692
3745
  }
3693
3746
  let isTransferHandlersSetup = !1;
3694
3747
  function setupTransferHandlers() {
3695
3748
  if (isTransferHandlersSetup)
3696
3749
  return;
3697
3750
  isTransferHandlersSetup = !0, transferHandlers.set("EVENT", {
3698
- canHandle: (r) => r instanceof CustomEvent,
3699
- serialize: (r) => [
3751
+ canHandle: (t) => t instanceof CustomEvent,
3752
+ serialize: (t) => [
3700
3753
  {
3701
- detail: r.detail
3754
+ detail: t.detail
3702
3755
  },
3703
3756
  []
3704
3757
  ],
3705
- deserialize: (r) => r
3758
+ deserialize: (t) => t
3706
3759
  }), transferHandlers.set("FUNCTION", {
3707
3760
  // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
3708
- canHandle: (r) => typeof r == "function",
3761
+ canHandle: (t) => typeof t == "function",
3709
3762
  // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
3710
- serialize(r) {
3763
+ serialize(t) {
3711
3764
  const { port1: s, port2: n } = new MessageChannel();
3712
- return expose(r, s), [n, [n]];
3765
+ return expose(t, s), [n, [n]];
3713
3766
  },
3714
- deserialize(r) {
3715
- return r.start(), wrap(r);
3767
+ deserialize(t) {
3768
+ return t.start(), wrap(t);
3716
3769
  }
3717
3770
  }), transferHandlers.set("MESSAGE_PORT", {
3718
- canHandle: (r) => r instanceof MessagePort,
3719
- serialize(r) {
3720
- return [r, [r]];
3771
+ canHandle: (t) => t instanceof MessagePort,
3772
+ serialize(t) {
3773
+ return [t, [t]];
3721
3774
  },
3722
- deserialize(r) {
3723
- return r;
3775
+ deserialize(t) {
3776
+ return t;
3724
3777
  }
3725
3778
  }), transferHandlers.set("PHPResponse", {
3726
- canHandle: (r) => typeof r == "object" && r !== null && "headers" in r && "bytes" in r && "errors" in r && "exitCode" in r && "httpStatusCode" in r,
3727
- serialize(r) {
3728
- const s = r.toRawData(), n = [];
3779
+ canHandle: (t) => typeof t == "object" && t !== null && "headers" in t && "bytes" in t && "errors" in t && "exitCode" in t && "httpStatusCode" in t,
3780
+ serialize(t) {
3781
+ const s = t.toRawData(), n = [];
3729
3782
  return s.bytes.buffer.byteLength > 0 && n.push(s.bytes.buffer), [s, n];
3730
3783
  },
3731
- deserialize(r) {
3732
- return PHPResponse.fromRawData(r);
3784
+ deserialize(t) {
3785
+ return PHPResponse.fromRawData(t);
3733
3786
  }
3734
3787
  });
3735
- const t = transferHandlers.get("throw"), e = t == null ? void 0 : t.serialize;
3736
- t.serialize = ({ value: r }) => {
3737
- const s = e({ value: r });
3738
- return r.response && (s[0].value.response = r.response), r.source && (s[0].value.source = r.source), s;
3788
+ const r = transferHandlers.get("throw"), e = r == null ? void 0 : r.serialize;
3789
+ r.serialize = ({ value: t }) => {
3790
+ const s = e({ value: t });
3791
+ return t.response && (s[0].value.response = t.response), t.source && (s[0].value.source = t.source), s;
3739
3792
  }, transferHandlers.set("StreamedPHPResponse", {
3740
- canHandle: (r) => r instanceof StreamedPHPResponse,
3741
- serialize(r) {
3742
- const s = supportsTransferableStreams(), n = promiseToPort(r.exitCode);
3793
+ canHandle: (t) => t instanceof StreamedPHPResponse,
3794
+ serialize(t) {
3795
+ const s = supportsTransferableStreams(), n = promiseToPort(t.exitCode);
3743
3796
  if (s)
3744
3797
  return [{
3745
3798
  __type: "StreamedPHPResponse",
3746
- headers: r.headersStream,
3747
- stdout: r.stdout,
3748
- stderr: r.stderr,
3799
+ headers: t.headersStream,
3800
+ stdout: t.stdout,
3801
+ stderr: t.stderr,
3749
3802
  exitCodePort: n
3750
3803
  }, [n]];
3751
- const i = streamToPort(r.headersStream), o = streamToPort(r.stdout), c = streamToPort(r.stderr);
3804
+ const i = streamToPort(t.headersStream), o = streamToPort(t.stdout), a = streamToPort(t.stderr);
3752
3805
  return [
3753
3806
  {
3754
3807
  __type: "StreamedPHPResponse",
3755
3808
  headersPort: i,
3756
3809
  stdoutPort: o,
3757
- stderrPort: c,
3810
+ stderrPort: a,
3758
3811
  exitCodePort: n
3759
3812
  },
3760
- [i, o, c, n]
3813
+ [i, o, a, n]
3761
3814
  ];
3762
3815
  },
3763
- deserialize(r) {
3764
- if (r.headers && r.stdout && r.stderr) {
3765
- const c = portToPromise(
3766
- r.exitCodePort
3816
+ deserialize(t) {
3817
+ if (t.headers && t.stdout && t.stderr) {
3818
+ const a = portToPromise(
3819
+ t.exitCodePort
3767
3820
  );
3768
3821
  return new StreamedPHPResponse(
3769
- r.headers,
3770
- r.stdout,
3771
- r.stderr,
3772
- c
3822
+ t.headers,
3823
+ t.stdout,
3824
+ t.stderr,
3825
+ a
3773
3826
  );
3774
3827
  }
3775
- const s = portToStream(r.headersPort), n = portToStream(r.stdoutPort), i = portToStream(r.stderrPort), o = portToPromise(r.exitCodePort);
3828
+ const s = portToStream(t.headersPort), n = portToStream(t.stdoutPort), i = portToStream(t.stderrPort), o = portToPromise(t.exitCodePort);
3776
3829
  return new StreamedPHPResponse(s, n, i, o);
3777
3830
  }
3778
3831
  });
@@ -3780,10 +3833,10 @@ function setupTransferHandlers() {
3780
3833
  function supportsTransferableStreams() {
3781
3834
  try {
3782
3835
  if (typeof ReadableStream > "u") return !1;
3783
- const { port1: t } = new MessageChannel(), e = new ReadableStream();
3784
- t.postMessage(e);
3836
+ const { port1: r } = new MessageChannel(), e = new ReadableStream();
3837
+ r.postMessage(e);
3785
3838
  try {
3786
- t.close();
3839
+ r.close();
3787
3840
  } catch {
3788
3841
  }
3789
3842
  return !0;
@@ -3791,10 +3844,10 @@ function supportsTransferableStreams() {
3791
3844
  return !1;
3792
3845
  }
3793
3846
  }
3794
- function streamToPort(t) {
3795
- const { port1: e, port2: r } = new MessageChannel();
3847
+ function streamToPort(r) {
3848
+ const { port1: e, port2: t } = new MessageChannel();
3796
3849
  return (async () => {
3797
- const s = t.getReader();
3850
+ const s = r.getReader();
3798
3851
  try {
3799
3852
  for (; ; ) {
3800
3853
  const { done: n, value: i } = await s.read();
@@ -3810,10 +3863,10 @@ function streamToPort(t) {
3810
3863
  break;
3811
3864
  }
3812
3865
  if (i) {
3813
- const o = i.byteOffset === 0 && i.byteLength === i.buffer.byteLength ? i : i.slice(), c = o.buffer;
3866
+ const o = i.byteOffset === 0 && i.byteLength === i.buffer.byteLength ? i : i.slice(), a = o.buffer;
3814
3867
  try {
3815
- e.postMessage({ t: "chunk", b: c }, [
3816
- c
3868
+ e.postMessage({ t: "chunk", b: a }, [
3869
+ a
3817
3870
  ]);
3818
3871
  } catch {
3819
3872
  e.postMessage({
@@ -3834,12 +3887,12 @@ function streamToPort(t) {
3834
3887
  } catch {
3835
3888
  }
3836
3889
  }
3837
- })(), r;
3890
+ })(), t;
3838
3891
  }
3839
- function portToStream(t) {
3892
+ function portToStream(r) {
3840
3893
  return new ReadableStream({
3841
3894
  start(e) {
3842
- const r = (n) => {
3895
+ const t = (n) => {
3843
3896
  const i = n.data;
3844
3897
  if (i)
3845
3898
  switch (i.t) {
@@ -3856,34 +3909,34 @@ function portToStream(t) {
3856
3909
  }, s = () => {
3857
3910
  var n;
3858
3911
  try {
3859
- (n = t.removeEventListener) == null || n.call(t, "message", r);
3912
+ (n = r.removeEventListener) == null || n.call(r, "message", t);
3860
3913
  } catch {
3861
3914
  }
3862
3915
  try {
3863
- t.onmessage = null;
3916
+ r.onmessage = null;
3864
3917
  } catch {
3865
3918
  }
3866
3919
  try {
3867
- t.close();
3920
+ r.close();
3868
3921
  } catch {
3869
3922
  }
3870
3923
  };
3871
- t.addEventListener ? t.addEventListener("message", r) : t.on ? t.on(
3924
+ r.addEventListener ? r.addEventListener("message", t) : r.on ? r.on(
3872
3925
  "message",
3873
- (n) => r({ data: n })
3874
- ) : t.onmessage = r, typeof t.start == "function" && t.start();
3926
+ (n) => t({ data: n })
3927
+ ) : r.onmessage = t, typeof r.start == "function" && r.start();
3875
3928
  },
3876
3929
  cancel() {
3877
3930
  try {
3878
- t.close();
3931
+ r.close();
3879
3932
  } catch {
3880
3933
  }
3881
3934
  }
3882
3935
  });
3883
3936
  }
3884
- function promiseToPort(t) {
3885
- const { port1: e, port2: r } = new MessageChannel();
3886
- return t.then((s) => {
3937
+ function promiseToPort(r) {
3938
+ const { port1: e, port2: t } = new MessageChannel();
3939
+ return r.then((s) => {
3887
3940
  try {
3888
3941
  e.postMessage({ t: "resolve", v: s });
3889
3942
  } catch {
@@ -3901,80 +3954,648 @@ function promiseToPort(t) {
3901
3954
  e.close();
3902
3955
  } catch {
3903
3956
  }
3904
- }), r;
3957
+ }), t;
3905
3958
  }
3906
- function portToPromise(t) {
3907
- return new Promise((e, r) => {
3959
+ function portToPromise(r) {
3960
+ return new Promise((e, t) => {
3908
3961
  const s = (i) => {
3909
3962
  const o = i.data;
3910
- o && (o.t === "resolve" ? (n(), e(o.v)) : o.t === "reject" && (n(), r(new Error(o.m || ""))));
3963
+ o && (o.t === "resolve" ? (n(), e(o.v)) : o.t === "reject" && (n(), t(new Error(o.m || ""))));
3911
3964
  }, n = () => {
3912
3965
  var i;
3913
3966
  try {
3914
- (i = t.removeEventListener) == null || i.call(t, "message", s);
3967
+ (i = r.removeEventListener) == null || i.call(r, "message", s);
3915
3968
  } catch {
3916
3969
  }
3917
3970
  try {
3918
- t.onmessage = null;
3971
+ r.onmessage = null;
3919
3972
  } catch {
3920
3973
  }
3921
3974
  try {
3922
- t.close();
3975
+ r.close();
3923
3976
  } catch {
3924
3977
  }
3925
3978
  };
3926
- t.addEventListener ? t.addEventListener("message", s) : t.on ? t.on(
3979
+ r.addEventListener ? r.addEventListener("message", s) : r.on ? r.on(
3927
3980
  "message",
3928
3981
  (i) => s({ data: i })
3929
- ) : t.onmessage = s, typeof t.start == "function" && t.start();
3982
+ ) : r.onmessage = s, typeof r.start == "function" && r.start();
3930
3983
  });
3931
3984
  }
3932
3985
  const throwTransferHandler = transferHandlers.get(
3933
3986
  "throw"
3934
3987
  ), throwTransferHandlerCustom = {
3935
3988
  canHandle: throwTransferHandler.canHandle,
3936
- serialize: ({ value: t }) => {
3989
+ serialize: ({ value: r }) => {
3937
3990
  let e;
3938
- return t instanceof Error ? (e = {
3991
+ return r instanceof Error ? (e = {
3939
3992
  isError: !0,
3940
- value: serializeError(t)
3941
- }, e.value.originalErrorClassName = t.constructor.name) : e = { isError: !1, value: t }, [e, []];
3993
+ value: serializeError(r)
3994
+ }, e.value.originalErrorClassName = r.constructor.name) : e = { isError: !1, value: r }, [e, []];
3942
3995
  },
3943
- deserialize: (t) => {
3944
- if (t.isError) {
3945
- const e = deserializeError(t.value), r = new Error("Comlink method call failed");
3996
+ deserialize: (r) => {
3997
+ if (r.isError) {
3998
+ const e = deserializeError(r.value), t = new Error("Comlink method call failed");
3946
3999
  let s = e;
3947
4000
  for (; s.cause; )
3948
4001
  s = s.cause;
3949
- throw s.cause = r, e;
4002
+ throw s.cause = t, e;
3950
4003
  }
3951
- throw t.value;
4004
+ throw r.value;
3952
4005
  }
3953
4006
  };
3954
4007
  transferHandlers.set("throw", throwTransferHandlerCustom);
3955
- function proxyClone(t) {
3956
- return new Proxy(t, {
3957
- get(e, r) {
3958
- switch (typeof e[r]) {
4008
+ function proxyClone(r) {
4009
+ return new Proxy(r, {
4010
+ get(e, t) {
4011
+ switch (typeof e[t]) {
3959
4012
  case "function":
3960
- return (...s) => e[r](...s);
4013
+ return (...s) => e[t](...s);
3961
4014
  case "object":
3962
- return e[r] === null ? e[r] : proxyClone(e[r]);
4015
+ return e[t] === null ? e[t] : proxyClone(e[t]);
3963
4016
  case "undefined":
3964
4017
  case "number":
3965
4018
  case "string":
3966
- return e[r];
4019
+ return e[t];
3967
4020
  default:
3968
- return proxy(e[r]);
4021
+ return proxy(e[t]);
4022
+ }
4023
+ }
4024
+ });
4025
+ }
4026
+ const MAX_ADDRESSABLE_FILE_OFFSET = BigInt(Number.MAX_SAFE_INTEGER);
4027
+ class IntervalNode {
4028
+ constructor(e) {
4029
+ this.left = null, this.right = null, this.range = e, this.max = e.end;
4030
+ }
4031
+ }
4032
+ class FileLockIntervalTree {
4033
+ constructor() {
4034
+ this.root = null;
4035
+ }
4036
+ isEmpty() {
4037
+ return this.root === null;
4038
+ }
4039
+ /**
4040
+ * Insert a new locked range into the tree
4041
+ */
4042
+ insert(e) {
4043
+ this.root = this.insertNode(this.root, e);
4044
+ }
4045
+ /**
4046
+ * Find all ranges that overlap with the given range
4047
+ */
4048
+ findOverlapping(e) {
4049
+ const t = [];
4050
+ return this.findOverlappingRanges(this.root, e, t), t;
4051
+ }
4052
+ /**
4053
+ * Remove a lock range from the tree
4054
+ */
4055
+ remove(e) {
4056
+ this.root = this.removeNode(this.root, e);
4057
+ }
4058
+ /**
4059
+ * Find all ranges locked by the given process.
4060
+ *
4061
+ * @param pid The process ID to find locks for.
4062
+ * @returns All locked ranges for the given process.
4063
+ */
4064
+ findLocksForProcess(e) {
4065
+ const t = [];
4066
+ return this.findLocksForProcessInNode(this.root, e, t), t;
4067
+ }
4068
+ /**
4069
+ * Find the strictest existing lock type in the range lock tree.
4070
+ *
4071
+ * @returns The strictest existing lock type, or 'unlocked' if no locks exist.
4072
+ */
4073
+ findStrictestExistingLockType() {
4074
+ let e = "unlocked";
4075
+ const t = (s) => {
4076
+ if (s) {
4077
+ if (s.range.type === "exclusive") {
4078
+ e = "exclusive";
4079
+ return;
4080
+ }
4081
+ s.range.type === "shared" && (e = "shared"), t(s.left), t(s.right);
4082
+ }
4083
+ };
4084
+ return t(this.root), e;
4085
+ }
4086
+ insertNode(e, t) {
4087
+ return e ? (t.start < e.range.start ? e.left = this.insertNode(e.left, t) : e.right = this.insertNode(e.right, t), e.max = this.bigintMax(e.max, t.end), e) : new IntervalNode(t);
4088
+ }
4089
+ bigintMax(...e) {
4090
+ return e.reduce((t, s) => s > t ? s : t, e[0]);
4091
+ }
4092
+ findOverlappingRanges(e, t, s) {
4093
+ e && (this.doRangesOverlap(e.range, t) && s.push(e.range), e.left && e.left.max >= t.start && this.findOverlappingRanges(e.left, t, s), e.right && e.range.start <= t.end && this.findOverlappingRanges(e.right, t, s));
4094
+ }
4095
+ doRangesOverlap(e, t) {
4096
+ return e.start < t.end && t.start < e.end;
4097
+ }
4098
+ removeNode(e, t) {
4099
+ if (!e)
4100
+ return null;
4101
+ if (this.areRangesEqual(e.range, t)) {
4102
+ if (!e.left)
4103
+ return e.right;
4104
+ if (!e.right)
4105
+ return e.left;
4106
+ const s = this.findMin(e.right);
4107
+ e.range = s.range, e.right = this.removeNode(e.right, s.range);
4108
+ } else t.start < e.range.start ? e.left = this.removeNode(e.left, t) : e.right = this.removeNode(e.right, t);
4109
+ return e.max = e.range.end, e.left && (e.max = this.bigintMax(e.max, e.left.max)), e.right && (e.max = this.bigintMax(e.max, e.right.max)), e;
4110
+ }
4111
+ findMin(e) {
4112
+ let t = e;
4113
+ for (; t.left; )
4114
+ t = t.left;
4115
+ return t;
4116
+ }
4117
+ areRangesEqual(e, t) {
4118
+ return e.start === t.start && e.end === t.end && e.pid === t.pid && e.fd === t.fd;
4119
+ }
4120
+ findLocksForProcessInNode(e, t, s) {
4121
+ e && (e.range.pid === t && s.push(e.range), this.findLocksForProcessInNode(e.left, t, s), this.findLocksForProcessInNode(e.right, t, s));
4122
+ }
4123
+ }
4124
+ class FileLockManagerInMemory {
4125
+ /**
4126
+ * Create a new FileLockManagerInMemory instance.
4127
+ *
4128
+ * @param nativeFlockSync A synchronous flock() function to lock files via the host OS.
4129
+ */
4130
+ constructor() {
4131
+ this.locks = /* @__PURE__ */ new Map();
4132
+ }
4133
+ /**
4134
+ * Lock the whole file.
4135
+ *
4136
+ * @param path The path to the file to lock. This should be the path
4137
+ * of the file in the native filesystem.
4138
+ * @param op The whole file lock operation to perform.
4139
+ * @returns True if the lock was granted, false otherwise.
4140
+ */
4141
+ lockWholeFile(e, t) {
4142
+ if (this.locks.get(e) === void 0) {
4143
+ if (t.type === "unlock")
4144
+ return !0;
4145
+ this.locks.set(e, new FileLock());
4146
+ }
4147
+ const n = this.locks.get(e).lockWholeFile(t);
4148
+ return this.forgetPathIfUnlocked(e), n;
4149
+ }
4150
+ /**
4151
+ * Lock a byte range.
4152
+ *
4153
+ * @param path The path to the file to lock. This should be the path
4154
+ * of the file in the native filesystem.
4155
+ * @param requestedLock The byte range lock to perform.
4156
+ * @returns True if the lock was granted, false otherwise.
4157
+ */
4158
+ lockFileByteRange(e, t) {
4159
+ if (!this.locks.has(e)) {
4160
+ if (t.type === "unlocked")
4161
+ return !0;
4162
+ this.locks.set(e, new FileLock());
4163
+ }
4164
+ return this.locks.get(e).lockFileByteRange(t);
4165
+ }
4166
+ /**
4167
+ * Find the first conflicting byte range lock.
4168
+ *
4169
+ * @param path The path to the file to find the conflicting lock for.
4170
+ * @param desiredLock The desired byte range lock.
4171
+ * @returns The first conflicting byte range lock, or undefined if no conflicting lock exists.
4172
+ */
4173
+ findFirstConflictingByteRangeLock(e, t) {
4174
+ const s = this.locks.get(e);
4175
+ if (s !== void 0)
4176
+ return s.findFirstConflictingByteRangeLock(t);
4177
+ }
4178
+ /**
4179
+ * Release all locks for the given process.
4180
+ *
4181
+ * @param pid The process ID to release locks for.
4182
+ */
4183
+ releaseLocksForProcess(e) {
4184
+ for (const [t, s] of this.locks.entries())
4185
+ s.releaseLocksForProcess(e), this.forgetPathIfUnlocked(t);
4186
+ }
4187
+ /**
4188
+ * Release all locks for the given process and file descriptor.
4189
+ *
4190
+ * @param pid The process ID to release locks for.
4191
+ * @param fd The file descriptor to release locks for.
4192
+ * @param path The path to the file to release locks for.
4193
+ */
4194
+ releaseLocksOnFdClose(e, t, s) {
4195
+ const n = this.locks.get(s);
4196
+ n && (n.releaseLocksOnFdClose(e, t), this.forgetPathIfUnlocked(s));
4197
+ }
4198
+ /**
4199
+ * Forget the path if it is unlocked.
4200
+ *
4201
+ * @param path The path to the file to forget.
4202
+ */
4203
+ forgetPathIfUnlocked(e) {
4204
+ const t = this.locks.get(e);
4205
+ t && t.isUnlocked() && this.locks.delete(e);
4206
+ }
4207
+ }
4208
+ class FileLock {
4209
+ constructor() {
4210
+ this.rangeLocks = new FileLockIntervalTree(), this.wholeFileLock = { type: "unlocked" };
4211
+ }
4212
+ /**
4213
+ * Lock the whole file.
4214
+ *
4215
+ * This method corresponds to the flock() function.
4216
+ *
4217
+ * @param op The whole file lock operation to perform.
4218
+ * @returns True if the lock was granted, false otherwise.
4219
+ */
4220
+ lockWholeFile(e) {
4221
+ if (e.type === "unlock")
4222
+ return this.wholeFileLock.type === "unlocked" || (this.wholeFileLock.type === "exclusive" && this.wholeFileLock.pid === e.pid && this.wholeFileLock.fd === e.fd ? this.wholeFileLock = { type: "unlocked" } : this.wholeFileLock.type === "shared" && this.wholeFileLock.pidFds.has(e.pid) && this.wholeFileLock.pidFds.get(e.pid).has(e.fd) && (this.wholeFileLock.pidFds.get(e.pid).delete(e.fd), this.wholeFileLock.pidFds.get(e.pid).size === 0 && this.wholeFileLock.pidFds.delete(e.pid), this.wholeFileLock.pidFds.size === 0 && (this.wholeFileLock = { type: "unlocked" }))), !0;
4223
+ if (this.isThereAConflictWithRequestedWholeFileLock(e))
4224
+ return !1;
4225
+ if (e.type === "exclusive")
4226
+ return this.wholeFileLock = {
4227
+ type: "exclusive",
4228
+ pid: e.pid,
4229
+ fd: e.fd
4230
+ }, !0;
4231
+ if (e.type === "shared") {
4232
+ this.wholeFileLock.type !== "shared" && (this.wholeFileLock = {
4233
+ type: "shared",
4234
+ pidFds: /* @__PURE__ */ new Map()
4235
+ });
4236
+ const t = this.wholeFileLock;
4237
+ return t.pidFds.has(e.pid) || t.pidFds.set(e.pid, /* @__PURE__ */ new Set()), t.pidFds.get(e.pid).add(e.fd), !0;
4238
+ }
4239
+ throw new Error(`Unexpected wholeFileLock() op: '${e.type}'`);
4240
+ }
4241
+ /**
4242
+ * Lock a byte range.
4243
+ *
4244
+ * This method corresponds to the fcntl() F_SETLK command.
4245
+ *
4246
+ * @param requestedLock The byte range lock to perform.
4247
+ * @returns True if the lock was granted, false otherwise.
4248
+ */
4249
+ lockFileByteRange(e) {
4250
+ if (e.start === e.end && (e = {
4251
+ ...e,
4252
+ end: MAX_ADDRESSABLE_FILE_OFFSET
4253
+ }), e.type === "unlocked") {
4254
+ const o = this.rangeLocks.findOverlapping(e).filter((a) => a.pid === e.pid);
4255
+ for (const a of o)
4256
+ this.rangeLocks.remove(a), a.start < e.start && this.rangeLocks.insert({
4257
+ ...a,
4258
+ end: e.start
4259
+ }), a.end > e.end && this.rangeLocks.insert({
4260
+ ...a,
4261
+ start: e.end
4262
+ });
4263
+ return !0;
4264
+ }
4265
+ if (this.isThereAConflictWithRequestedRangeLock(e))
4266
+ return !1;
4267
+ const t = this.rangeLocks.findOverlapping(e).filter((o) => o.pid === e.pid);
4268
+ let s = e.start, n = e.end;
4269
+ for (const o of t)
4270
+ this.rangeLocks.remove(o), o.start < s && (s = o.start), o.end > n && (n = o.end);
4271
+ const i = {
4272
+ ...e,
4273
+ start: s,
4274
+ end: n
4275
+ };
4276
+ return this.rangeLocks.insert(i), !0;
4277
+ }
4278
+ /**
4279
+ * Find the first conflicting byte range lock.
4280
+ *
4281
+ * This method corresponds to the fcntl() F_GETLK command.
4282
+ *
4283
+ * @param desiredLock The desired byte range lock.
4284
+ * @returns The first conflicting byte range lock, or undefined if no conflicting lock exists.
4285
+ */
4286
+ findFirstConflictingByteRangeLock(e) {
4287
+ e.start === e.end && (e = {
4288
+ ...e,
4289
+ end: MAX_ADDRESSABLE_FILE_OFFSET
4290
+ });
4291
+ const s = this.rangeLocks.findOverlapping(e).find(
4292
+ (i) => i.pid !== e.pid && (e.type === "exclusive" || i.type === "exclusive")
4293
+ );
4294
+ if (s)
4295
+ return s;
4296
+ if (this.wholeFileLock.type === "unlocked")
4297
+ return;
4298
+ if (this.wholeFileLock.type === "exclusive" || e.type === "exclusive")
4299
+ return {
4300
+ type: this.wholeFileLock.type,
4301
+ start: 0n,
4302
+ end: 0n,
4303
+ pid: -1
4304
+ };
4305
+ }
4306
+ /**
4307
+ * Release all locks for the given process.
4308
+ *
4309
+ * @param pid The process ID to release locks for.
4310
+ */
4311
+ releaseLocksForProcess(e) {
4312
+ for (const t of this.rangeLocks.findLocksForProcess(e))
4313
+ this.lockFileByteRange({
4314
+ ...t,
4315
+ type: "unlocked"
4316
+ });
4317
+ if (this.wholeFileLock.type === "exclusive" && this.wholeFileLock.pid === e)
4318
+ this.lockWholeFile({
4319
+ pid: e,
4320
+ fd: this.wholeFileLock.fd,
4321
+ type: "unlock"
4322
+ });
4323
+ else if (this.wholeFileLock.type === "shared" && this.wholeFileLock.pidFds.has(e))
4324
+ for (const t of this.wholeFileLock.pidFds.get(e))
4325
+ this.lockWholeFile({
4326
+ pid: e,
4327
+ fd: t,
4328
+ type: "unlock"
4329
+ });
4330
+ }
4331
+ /**
4332
+ * Release all locks for the given process and file descriptor.
4333
+ *
4334
+ * @param pid The process ID to release locks for.
4335
+ * @param fd The file descriptor to release locks for.
4336
+ */
4337
+ releaseLocksOnFdClose(e, t) {
4338
+ for (const s of this.rangeLocks.findLocksForProcess(e))
4339
+ this.lockFileByteRange({
4340
+ ...s,
4341
+ type: "unlocked"
4342
+ });
4343
+ this.lockWholeFile({
4344
+ pid: e,
4345
+ fd: t,
4346
+ type: "unlock"
4347
+ });
4348
+ }
4349
+ /**
4350
+ * Check if the file lock is unlocked.
4351
+ *
4352
+ * @returns True if the file lock is unlocked, false otherwise.
4353
+ */
4354
+ isUnlocked() {
4355
+ return this.wholeFileLock.type === "unlocked" && this.rangeLocks.isEmpty();
4356
+ }
4357
+ /**
4358
+ * Check if a lock exists that conflicts with the requested range lock.
4359
+ *
4360
+ * @param requestedLock The desired byte range lock.
4361
+ * @returns True if a conflicting lock exists, false otherwise.
4362
+ */
4363
+ isThereAConflictWithRequestedRangeLock(e) {
4364
+ return this.findFirstConflictingByteRangeLock(e) !== void 0;
4365
+ }
4366
+ /**
4367
+ * Check if a lock exists that conflicts with the requested whole-file lock.
4368
+ *
4369
+ * @param requestedLock The desired whole-file lock.
4370
+ * @returns True if a conflicting lock exists, false otherwise.
4371
+ */
4372
+ isThereAConflictWithRequestedWholeFileLock(e) {
4373
+ return e.type === "exclusive" ? !!(this.wholeFileLock.type === "exclusive" && (this.wholeFileLock.fd !== e.fd || this.wholeFileLock.pid !== e.pid) || this.wholeFileLock.type === "shared" && Array.from(this.wholeFileLock.pidFds).some(
4374
+ ([s]) => s !== e.pid
4375
+ ) || this.rangeLocks.findOverlapping({
4376
+ start: 0n,
4377
+ end: MAX_ADDRESSABLE_FILE_OFFSET
4378
+ }).length > 0) : e.type === "shared" ? this.wholeFileLock.type === "exclusive" && this.wholeFileLock.pid !== e.pid || this.rangeLocks.findOverlapping({
4379
+ start: 0n,
4380
+ end: MAX_ADDRESSABLE_FILE_OFFSET
4381
+ }).filter(
4382
+ (n) => n.type === "exclusive"
4383
+ ).length > 0 : !1;
4384
+ }
4385
+ }
4386
+ class FileLockManagerComposite {
4387
+ constructor({
4388
+ nativeLockManager: e,
4389
+ wasmLockManager: t
4390
+ }) {
4391
+ this.nativeLockManager = e, this.wasmLockManager = t;
4392
+ }
4393
+ lockWholeFile(e, t) {
4394
+ if (t.type !== "unlock") {
4395
+ let s, n;
4396
+ try {
4397
+ if (s = this.nativeLockManager.lockWholeFile(e, t), !s)
4398
+ return !1;
4399
+ n = this.wasmLockManager.lockWholeFile(e, t);
4400
+ } catch (i) {
4401
+ logger.error("Unexpected error in lockWholeFile()", i);
4402
+ } finally {
4403
+ s && !n && this.nativeLockManager.lockWholeFile(e, {
4404
+ ...t,
4405
+ type: "unlock"
4406
+ });
4407
+ }
4408
+ return !!s && !!n;
4409
+ }
4410
+ try {
4411
+ this.wasmLockManager.lockWholeFile(e, t);
4412
+ } catch (s) {
4413
+ logger.error(
4414
+ "Unexpected error unlocking whole file with in-memory lock manager",
4415
+ s
4416
+ );
4417
+ }
4418
+ try {
4419
+ this.nativeLockManager.lockWholeFile(e, t);
4420
+ } catch (s) {
4421
+ logger.error(
4422
+ "Unexpected error unlocking whole file with native lock manager",
4423
+ s
4424
+ );
4425
+ }
4426
+ return !0;
4427
+ }
4428
+ lockFileByteRange(e, t, s) {
4429
+ if (t.type !== "unlocked") {
4430
+ let n, i;
4431
+ try {
4432
+ if (n = this.nativeLockManager.lockFileByteRange(
4433
+ e,
4434
+ t,
4435
+ s
4436
+ ), !n)
4437
+ return !1;
4438
+ i = this.wasmLockManager.lockFileByteRange(
4439
+ e,
4440
+ t,
4441
+ s
4442
+ );
4443
+ } catch (o) {
4444
+ logger.error("Unexpected error in lockFileByteRange()", o);
4445
+ } finally {
4446
+ n && !i && this.nativeLockManager.lockFileByteRange(
4447
+ e,
4448
+ {
4449
+ ...t,
4450
+ type: "unlocked"
4451
+ },
4452
+ !1
4453
+ );
4454
+ }
4455
+ return !!n && !!i;
4456
+ }
4457
+ try {
4458
+ this.wasmLockManager.lockFileByteRange(
4459
+ e,
4460
+ t,
4461
+ s
4462
+ );
4463
+ } catch (n) {
4464
+ logger.error(
4465
+ "Unexpected error unlocking byte range with in-memory lock manager",
4466
+ n
4467
+ );
4468
+ }
4469
+ try {
4470
+ this.nativeLockManager.lockFileByteRange(
4471
+ e,
4472
+ t,
4473
+ s
4474
+ );
4475
+ } catch (n) {
4476
+ logger.error(
4477
+ "Unexpected error unlocking byte range with native lock manager",
4478
+ n
4479
+ );
4480
+ }
4481
+ return !0;
4482
+ }
4483
+ findFirstConflictingByteRangeLock(e, t) {
4484
+ try {
4485
+ const s = this.nativeLockManager.findFirstConflictingByteRangeLock(
4486
+ e,
4487
+ t
4488
+ );
4489
+ return s || this.wasmLockManager.findFirstConflictingByteRangeLock(
4490
+ e,
4491
+ t
4492
+ );
4493
+ } catch (s) {
4494
+ logger.error(
4495
+ "Unexpected error in findFirstConflictingByteRangeLock()",
4496
+ s
4497
+ );
4498
+ return;
4499
+ }
4500
+ }
4501
+ releaseLocksForProcess(e) {
4502
+ try {
4503
+ this.wasmLockManager.releaseLocksForProcess(e);
4504
+ } catch (t) {
4505
+ logger.error(
4506
+ "Unexpected error in wasmLockManager.releaseLocksForProcess()",
4507
+ t
4508
+ );
4509
+ }
4510
+ try {
4511
+ this.nativeLockManager.releaseLocksForProcess(e);
4512
+ } catch (t) {
4513
+ logger.error(
4514
+ "Unexpected error in nativeLockManager.releaseLocksForProcess()",
4515
+ t
4516
+ );
4517
+ }
4518
+ }
4519
+ releaseLocksOnFdClose(e, t, s) {
4520
+ try {
4521
+ this.wasmLockManager.releaseLocksOnFdClose(e, t, s);
4522
+ } catch (n) {
4523
+ logger.error(
4524
+ "Unexpected error in wasmLockManager.releaseLocksOnFdClose()",
4525
+ n
4526
+ );
4527
+ }
4528
+ try {
4529
+ this.nativeLockManager.releaseLocksOnFdClose(e, t, s);
4530
+ } catch (n) {
4531
+ logger.error(
4532
+ "Unexpected error in nativeLockManager.releaseLocksOnFdClose()",
4533
+ n
4534
+ );
4535
+ }
4536
+ }
4537
+ }
4538
+ function createObjectPoolProxy(r) {
4539
+ if (r.length === 0)
4540
+ throw new Error("At least one instance is required");
4541
+ const e = [...r], t = [];
4542
+ function s() {
4543
+ const o = e.shift();
4544
+ return o !== void 0 ? Promise.resolve(o) : new Promise((a) => {
4545
+ t.push(a);
4546
+ });
4547
+ }
4548
+ function n(o) {
4549
+ const a = t.shift();
4550
+ a ? a(o) : e.push(o);
4551
+ }
4552
+ function i(o) {
4553
+ return s().then((a) => {
4554
+ let c;
4555
+ try {
4556
+ c = o(a);
4557
+ } catch (l) {
4558
+ throw n(a), l;
3969
4559
  }
4560
+ return c != null && typeof c.then == "function" ? c.then(
4561
+ (l) => (n(a), l),
4562
+ (l) => {
4563
+ throw n(a), l;
4564
+ }
4565
+ ) : (n(a), c);
4566
+ });
4567
+ }
4568
+ return new Proxy({}, {
4569
+ get(o, a) {
4570
+ if (a in o)
4571
+ return o[a];
4572
+ if (a !== "then")
4573
+ return new Proxy(function() {
4574
+ }, {
4575
+ apply(c, l, d) {
4576
+ return i((p) => p[a](...d));
4577
+ },
4578
+ get(c, l) {
4579
+ if (l === "then")
4580
+ return (d, p) => i((f) => f[a]).then(
4581
+ d,
4582
+ p
4583
+ );
4584
+ }
4585
+ });
3970
4586
  }
3971
4587
  });
3972
4588
  }
3973
4589
  export {
3974
4590
  DEFAULT_BASE_URL,
3975
4591
  FSHelpers,
4592
+ FileLock,
4593
+ FileLockIntervalTree,
4594
+ FileLockManagerComposite,
4595
+ FileLockManagerInMemory,
3976
4596
  HttpCookieStore,
3977
4597
  LatestSupportedPHPVersion,
4598
+ MAX_ADDRESSABLE_FILE_OFFSET,
3978
4599
  PHP,
3979
4600
  PHPExecutionFailureError,
3980
4601
  PHPProcessManager,
@@ -3990,6 +4611,7 @@ export {
3990
4611
  applyRewriteRules,
3991
4612
  consumeAPI,
3992
4613
  consumeAPISync,
4614
+ createObjectPoolProxy,
3993
4615
  ensurePathPrefix,
3994
4616
  exposeAPI,
3995
4617
  exposeSyncAPI,
@@ -4004,6 +4626,7 @@ export {
4004
4626
  printDebugDetails,
4005
4627
  printResponseDebugDetails,
4006
4628
  proxyFileSystem,
4629
+ releaseApiProxy,
4007
4630
  removePathPrefix,
4008
4631
  rotatePHPRuntime,
4009
4632
  sandboxedSpawnHandlerFactory,