@php-wasm/universal 0.9.13 → 0.9.15

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.
Files changed (3) hide show
  1. package/index.cjs +11 -16
  2. package/index.js +275 -914
  3. package/package.json +2 -2
package/index.js CHANGED
@@ -1,82 +1,18 @@
1
- var Y = (t, e, r) => {
1
+ var V = (t, e, r) => {
2
2
  if (!e.has(t))
3
3
  throw TypeError("Cannot " + r);
4
4
  };
5
- var u = (t, e, r) => (Y(t, e, "read from private field"), r ? r.call(t) : e.get(t)), p = (t, e, r) => {
5
+ var c = (t, e, r) => (V(t, e, "read from private field"), r ? r.call(t) : e.get(t)), u = (t, e, r) => {
6
6
  if (e.has(t))
7
7
  throw TypeError("Cannot add the same private member more than once");
8
8
  e instanceof WeakSet ? e.add(t) : e.set(t, r);
9
- }, f = (t, e, r, s) => (Y(t, e, "write to private field"), s ? s.call(t, r) : e.set(t, r), r);
10
- var h = (t, e, r) => (Y(t, e, "access private method"), r);
11
- const currentJsRuntime$1 = function() {
12
- var t;
13
- return typeof process < "u" && ((t = process.release) == null ? void 0 : t.name) === "node" ? "NODE" : typeof window < "u" ? "WEB" : (
14
- // @ts-ignore
15
- typeof WorkerGlobalScope < "u" && // @ts-ignore
16
- self instanceof WorkerGlobalScope ? "WORKER" : "NODE"
17
- );
18
- }();
19
- if (currentJsRuntime$1 === "NODE") {
20
- let t = function(r) {
21
- return new Promise(function(s, n) {
22
- r.onload = r.onerror = function(i) {
23
- r.onload = r.onerror = null, i.type === "load" ? s(r.result) : n(new Error("Failed to read the blob/file"));
24
- };
25
- });
26
- }, e = function() {
27
- const r = new Uint8Array([1, 2, 3, 4]), n = new File([r], "test").stream();
28
- try {
29
- return n.getReader({ mode: "byob" }), !0;
30
- } catch {
31
- return !1;
32
- }
33
- };
34
- if (typeof File > "u") {
35
- class r extends Blob {
36
- constructor(n, i, o) {
37
- super(n);
38
- let l;
39
- o != null && o.lastModified && (l = /* @__PURE__ */ new Date()), (!l || isNaN(l.getFullYear())) && (l = /* @__PURE__ */ new Date()), this.lastModifiedDate = l, this.lastModified = l.getMilliseconds(), this.name = i || "";
40
- }
41
- }
42
- global.File = r;
43
- }
44
- typeof Blob.prototype.arrayBuffer > "u" && (Blob.prototype.arrayBuffer = function() {
45
- const s = new FileReader();
46
- return s.readAsArrayBuffer(this), t(s);
47
- }), typeof Blob.prototype.text > "u" && (Blob.prototype.text = function() {
48
- const s = new FileReader();
49
- return s.readAsText(this), t(s);
50
- }), (typeof Blob.prototype.stream > "u" || !e()) && (Blob.prototype.stream = function() {
51
- let r = 0;
52
- const s = this;
53
- return new ReadableStream({
54
- type: "bytes",
55
- // 0.5 MB seems like a reasonable chunk size, let's adjust
56
- // this if needed.
57
- autoAllocateChunkSize: 512 * 1024,
58
- async pull(n) {
59
- const i = n.byobRequest.view, l = await s.slice(
60
- r,
61
- r + i.byteLength
62
- ).arrayBuffer(), c = new Uint8Array(l);
63
- new Uint8Array(i.buffer).set(c);
64
- const a = c.byteLength;
65
- n.byobRequest.respond(a), r += a, r >= s.size && n.close();
66
- }
67
- });
68
- });
69
- }
70
- if (currentJsRuntime$1 === "NODE" && typeof CustomEvent > "u") {
71
- class t extends Event {
72
- constructor(r, s = {}) {
73
- super(r, s), this.detail = s.detail;
74
- }
75
- initCustomEvent() {
76
- }
77
- }
78
- globalThis.CustomEvent = t;
79
- }
9
+ }, h = (t, e, r, s) => (V(t, e, "write to private field"), s ? s.call(t, r) : e.set(t, r), r);
10
+ var d = (t, e, r) => (V(t, e, "access private method"), r);
11
+ import "@php-wasm/node-polyfills";
12
+ import { logger } from "@php-wasm/logger";
13
+ import { dirname, joinPaths, Semaphore, createSpawnHandler, normalizePath, AcquireTimeoutError } from "@php-wasm/util";
14
+ import { parse, stringify } from "/home/runner/work/wordpress-playground/wordpress-playground/node_modules/ini/lib/ini.js";
15
+ import { StreamedFile } from "@php-wasm/stream-compression";
80
16
  const FileErrorCodes = {
81
17
  0: "No error occurred. System call completed successfully.",
82
18
  1: "Argument list too long.",
@@ -162,375 +98,32 @@ function getEmscriptenFsError(t) {
162
98
  return FileErrorCodes[e];
163
99
  }
164
100
  function rethrowFileSystemError(t = "") {
165
- return function(r, s, n) {
166
- const i = n.value;
167
- n.value = function(...o) {
101
+ return function(r, s, i) {
102
+ const n = i.value;
103
+ i.value = function(...o) {
168
104
  try {
169
- return i.apply(this, o);
170
- } catch (l) {
171
- const c = typeof l == "object" ? l == null ? void 0 : l.errno : null;
172
- if (c in FileErrorCodes) {
173
- const a = FileErrorCodes[c], d = typeof o[1] == "string" ? o[1] : null, m = d !== null ? t.replaceAll("{path}", d) : t;
174
- throw new Error(`${m}: ${a}`, {
175
- cause: l
105
+ return n.apply(this, o);
106
+ } catch (p) {
107
+ const l = typeof p == "object" ? p == null ? void 0 : p.errno : null;
108
+ if (l in FileErrorCodes) {
109
+ const a = FileErrorCodes[l], y = typeof o[1] == "string" ? o[1] : null, de = y !== null ? t.replaceAll("{path}", y) : t;
110
+ throw new Error(`${de}: ${a}`, {
111
+ cause: p
176
112
  });
177
113
  }
178
- throw l;
114
+ throw p;
179
115
  }
180
116
  };
181
117
  };
182
118
  }
183
- const logEventType = "playground-log", logEvent = (t, ...e) => {
184
- logger.dispatchEvent(
185
- new CustomEvent(logEventType, {
186
- detail: {
187
- log: t,
188
- args: e
189
- }
190
- })
191
- );
192
- }, logToConsole = (t, ...e) => {
193
- switch (typeof t.message == "string" ? t.message = prepareLogMessage(t.message) : t.message.message && typeof t.message.message == "string" && (t.message.message = prepareLogMessage(t.message.message)), t.severity) {
194
- case "Debug":
195
- console.debug(t.message, ...e);
196
- break;
197
- case "Info":
198
- console.info(t.message, ...e);
199
- break;
200
- case "Warn":
201
- console.warn(t.message, ...e);
202
- break;
203
- case "Error":
204
- console.error(t.message, ...e);
205
- break;
206
- case "Fatal":
207
- console.error(t.message, ...e);
208
- break;
209
- default:
210
- console.log(t.message, ...e);
211
- }
212
- }, prepareLogMessage$1 = (t) => t instanceof Error ? [t.message, t.stack].join(`
213
- `) : JSON.stringify(t, null, 2), logs = [], addToLogArray = (t) => {
214
- logs.push(t);
215
- }, logToMemory = (t) => {
216
- if (t.raw === !0)
217
- addToLogArray(t.message);
218
- else {
219
- const e = formatLogEntry(
220
- typeof t.message == "object" ? prepareLogMessage$1(t.message) : t.message,
221
- t.severity ?? "Info",
222
- t.prefix ?? "JavaScript"
223
- );
224
- addToLogArray(e);
225
- }
226
- };
227
- class Logger extends EventTarget {
228
- // constructor
229
- constructor(e = []) {
230
- super(), this.handlers = e, this.fatalErrorEvent = "playground-fatal-error";
231
- }
232
- /**
233
- * Get all logs.
234
- * @returns string[]
235
- */
236
- getLogs() {
237
- return this.handlers.includes(logToMemory) ? [...logs] : (this.error(`Logs aren't stored because the logToMemory handler isn't registered.
238
- If you're using a custom logger instance, make sure to register logToMemory handler.
239
- `), []);
240
- }
241
- /**
242
- * Log message with severity.
243
- *
244
- * @param message any
245
- * @param severity LogSeverity
246
- * @param raw boolean
247
- * @param args any
248
- */
249
- logMessage(e, ...r) {
250
- for (const s of this.handlers)
251
- s(e, ...r);
252
- }
253
- /**
254
- * Log message
255
- *
256
- * @param message any
257
- * @param args any
258
- */
259
- log(e, ...r) {
260
- this.logMessage(
261
- {
262
- message: e,
263
- severity: void 0,
264
- prefix: "JavaScript",
265
- raw: !1
266
- },
267
- ...r
268
- );
269
- }
270
- /**
271
- * Log debug message
272
- *
273
- * @param message any
274
- * @param args any
275
- */
276
- debug(e, ...r) {
277
- this.logMessage(
278
- {
279
- message: e,
280
- severity: "Debug",
281
- prefix: "JavaScript",
282
- raw: !1
283
- },
284
- ...r
285
- );
286
- }
287
- /**
288
- * Log info message
289
- *
290
- * @param message any
291
- * @param args any
292
- */
293
- info(e, ...r) {
294
- this.logMessage(
295
- {
296
- message: e,
297
- severity: "Info",
298
- prefix: "JavaScript",
299
- raw: !1
300
- },
301
- ...r
302
- );
303
- }
304
- /**
305
- * Log warning message
306
- *
307
- * @param message any
308
- * @param args any
309
- */
310
- warn(e, ...r) {
311
- this.logMessage(
312
- {
313
- message: e,
314
- severity: "Warn",
315
- prefix: "JavaScript",
316
- raw: !1
317
- },
318
- ...r
319
- );
320
- }
321
- /**
322
- * Log error message
323
- *
324
- * @param message any
325
- * @param args any
326
- */
327
- error(e, ...r) {
328
- this.logMessage(
329
- {
330
- message: e,
331
- severity: "Error",
332
- prefix: "JavaScript",
333
- raw: !1
334
- },
335
- ...r
336
- );
337
- }
338
- }
339
- const getDefaultHandlers = () => {
340
- try {
341
- if (process.env.NODE_ENV === "test")
342
- return [logToMemory, logEvent];
343
- } catch {
344
- }
345
- return [logToMemory, logToConsole, logEvent];
346
- }, logger = new Logger(getDefaultHandlers()), prepareLogMessage = (t) => t.replace(/\t/g, ""), formatLogEntry = (t, e, r) => {
347
- const s = /* @__PURE__ */ new Date(), n = new Intl.DateTimeFormat("en-GB", {
348
- year: "numeric",
349
- month: "short",
350
- day: "2-digit",
351
- timeZone: "UTC"
352
- }).format(s).replace(/ /g, "-"), i = new Intl.DateTimeFormat("en-GB", {
353
- hour: "2-digit",
354
- minute: "2-digit",
355
- second: "2-digit",
356
- hour12: !1,
357
- timeZone: "UTC",
358
- timeZoneName: "short"
359
- }).format(s), o = n + " " + i;
360
- return t = prepareLogMessage(t), `[${o}] ${r} ${e}: ${t}`;
361
- }, SleepFinished = Symbol("SleepFinished");
362
- function sleep(t) {
363
- return new Promise((e) => {
364
- setTimeout(() => e(SleepFinished), t);
365
- });
366
- }
367
- class AcquireTimeoutError extends Error {
368
- constructor() {
369
- super("Acquiring lock timed out");
370
- }
371
- }
372
- class Semaphore {
373
- constructor({ concurrency: e, timeout: r }) {
374
- this._running = 0, this.concurrency = e, this.timeout = r, this.queue = [];
375
- }
376
- get remaining() {
377
- return this.concurrency - this.running;
378
- }
379
- get running() {
380
- return this._running;
381
- }
382
- async acquire() {
383
- for (; ; )
384
- if (this._running >= this.concurrency) {
385
- const e = new Promise((r) => {
386
- this.queue.push(r);
387
- });
388
- this.timeout !== void 0 ? await Promise.race([e, sleep(this.timeout)]).then(
389
- (r) => {
390
- if (r === SleepFinished)
391
- throw new AcquireTimeoutError();
392
- }
393
- ) : await e;
394
- } else {
395
- this._running++;
396
- let e = !1;
397
- return () => {
398
- e || (e = !0, this._running--, this.queue.length > 0 && this.queue.shift()());
399
- };
400
- }
401
- }
402
- async run(e) {
403
- const r = await this.acquire();
404
- try {
405
- return await e();
406
- } finally {
407
- r();
408
- }
409
- }
410
- }
411
- function joinPaths(...t) {
412
- let e = t.join("/");
413
- const r = e[0] === "/", s = e.substring(e.length - 1) === "/";
414
- return e = normalizePath(e), !e && !r && (e = "."), e && s && (e += "/"), e;
415
- }
416
- function dirname(t) {
417
- if (t === "/")
418
- return "/";
419
- t = normalizePath(t);
420
- const e = t.lastIndexOf("/");
421
- return e === -1 ? "" : e === 0 ? "/" : t.substr(0, e);
422
- }
423
- function normalizePath(t) {
424
- const e = t[0] === "/";
425
- return t = normalizePathsArray(
426
- t.split("/").filter((r) => !!r),
427
- !e
428
- ).join("/"), (e ? "/" : "") + t.replace(/\/$/, "");
429
- }
430
- function normalizePathsArray(t, e) {
431
- let r = 0;
432
- for (let s = t.length - 1; s >= 0; s--) {
433
- const n = t[s];
434
- n === "." ? t.splice(s, 1) : n === ".." ? (t.splice(s, 1), r++) : r && (t.splice(s, 1), r--);
435
- }
436
- if (e)
437
- for (; r; r--)
438
- t.unshift("..");
439
- return t;
440
- }
441
- function splitShellCommand(t) {
442
- let s = 0, n = "";
443
- const i = [];
444
- let o = "";
445
- for (let l = 0; l < t.length; l++) {
446
- const c = t[l];
447
- c === "\\" ? ((t[l + 1] === '"' || t[l + 1] === "'") && l++, o += t[l]) : s === 0 ? c === '"' || c === "'" ? (s = 1, n = c) : c.match(/\s/) ? (o.trim().length && i.push(o.trim()), o = c) : i.length && !o ? o = i.pop() + c : o += c : s === 1 && (c === n ? (s = 0, n = "") : o += c);
448
- }
449
- return o && i.push(o.trim()), i;
450
- }
451
- function createSpawnHandler(t) {
452
- return function(e, r = [], s = {}) {
453
- const n = new ChildProcess(), i = new ProcessApi(n);
454
- return setTimeout(async () => {
455
- let o = [];
456
- if (r.length)
457
- o = [e, ...r];
458
- else if (typeof e == "string")
459
- o = splitShellCommand(e);
460
- else if (Array.isArray(e))
461
- o = e;
462
- else
463
- throw new Error("Invalid command ", e);
464
- try {
465
- await t(o, i, s);
466
- } catch (l) {
467
- n.emit("error", l), typeof l == "object" && l !== null && "message" in l && typeof l.message == "string" && i.stderr(l.message), i.exit(1);
468
- }
469
- n.emit("spawn", !0);
470
- }), n;
471
- };
472
- }
473
- class EventEmitter {
474
- constructor() {
475
- this.listeners = {};
476
- }
477
- emit(e, r) {
478
- this.listeners[e] && this.listeners[e].forEach(function(s) {
479
- s(r);
480
- });
481
- }
482
- on(e, r) {
483
- this.listeners[e] || (this.listeners[e] = []), this.listeners[e].push(r);
484
- }
485
- }
486
- class ProcessApi extends EventEmitter {
487
- constructor(e) {
488
- super(), this.childProcess = e, this.exited = !1, this.stdinData = [], e.on("stdin", (r) => {
489
- this.stdinData ? this.stdinData.push(r.slice()) : this.emit("stdin", r);
490
- });
491
- }
492
- stdout(e) {
493
- typeof e == "string" && (e = new TextEncoder().encode(e)), this.childProcess.stdout.emit("data", e);
494
- }
495
- stdoutEnd() {
496
- this.childProcess.stdout.emit("end", {});
497
- }
498
- stderr(e) {
499
- typeof e == "string" && (e = new TextEncoder().encode(e)), this.childProcess.stderr.emit("data", e);
500
- }
501
- stderrEnd() {
502
- this.childProcess.stderr.emit("end", {});
503
- }
504
- exit(e) {
505
- this.exited || (this.exited = !0, this.childProcess.emit("exit", e));
506
- }
507
- flushStdin() {
508
- if (this.stdinData)
509
- for (let e = 0; e < this.stdinData.length; e++)
510
- this.emit("stdin", this.stdinData[e]);
511
- this.stdinData = null;
512
- }
513
- }
514
- let lastPid = 9743;
515
- class ChildProcess extends EventEmitter {
516
- constructor(e = lastPid++) {
517
- super(), this.pid = e, this.stdout = new EventEmitter(), this.stderr = new EventEmitter();
518
- const r = this;
519
- this.stdin = {
520
- write: (s) => {
521
- r.emit("stdin", s);
522
- }
523
- };
524
- }
525
- }
526
119
  var __defProp = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __decorateClass = (t, e, r, s) => {
527
- for (var n = s > 1 ? void 0 : s ? __getOwnPropDesc(e, r) : e, i = t.length - 1, o; i >= 0; i--)
528
- (o = t[i]) && (n = (s ? o(e, r, n) : o(n)) || n);
529
- return s && n && __defProp(e, r, n), n;
120
+ for (var i = s > 1 ? void 0 : s ? __getOwnPropDesc(e, r) : e, n = t.length - 1, o; n >= 0; n--)
121
+ (o = t[n]) && (i = (s ? o(e, r, i) : o(i)) || i);
122
+ return s && i && __defProp(e, r, i), i;
530
123
  };
531
- const _FSHelpers = class g {
124
+ const _FSHelpers = class m {
532
125
  static readFileAsText(e, r) {
533
- return new TextDecoder().decode(g.readFileAsBuffer(e, r));
126
+ return new TextDecoder().decode(m.readFileAsBuffer(e, r));
534
127
  }
535
128
  static readFileAsBuffer(e, r) {
536
129
  return e.readFile(r);
@@ -550,42 +143,42 @@ const _FSHelpers = class g {
550
143
  */
551
144
  static mv(e, r, s) {
552
145
  try {
553
- const n = e.lookupPath(r).node.mount, i = g.fileExists(e, s) ? e.lookupPath(s).node.mount : e.lookupPath(dirname(s)).node.mount;
554
- n.mountpoint !== i.mountpoint ? (g.copyRecursive(e, r, s), g.rmdir(e, r, { recursive: !0 })) : e.rename(r, s);
555
- } catch (n) {
556
- const i = getEmscriptenFsError(n);
557
- throw i ? new Error(
558
- `Could not move ${r} to ${s}: ${i}`,
146
+ const i = e.lookupPath(r).node.mount, n = m.fileExists(e, s) ? e.lookupPath(s).node.mount : e.lookupPath(dirname(s)).node.mount;
147
+ i.mountpoint !== n.mountpoint ? (m.copyRecursive(e, r, s), m.rmdir(e, r, { recursive: !0 })) : e.rename(r, s);
148
+ } catch (i) {
149
+ const n = getEmscriptenFsError(i);
150
+ throw n ? new Error(
151
+ `Could not move ${r} to ${s}: ${n}`,
559
152
  {
560
- cause: n
153
+ cause: i
561
154
  }
562
- ) : n;
155
+ ) : i;
563
156
  }
564
157
  }
565
158
  static rmdir(e, r, s = { recursive: !0 }) {
566
- s != null && s.recursive && g.listFiles(e, r).forEach((n) => {
567
- const i = `${r}/${n}`;
568
- g.isDir(e, i) ? g.rmdir(e, i, s) : g.unlink(e, i);
159
+ s != null && s.recursive && m.listFiles(e, r).forEach((i) => {
160
+ const n = `${r}/${i}`;
161
+ m.isDir(e, n) ? m.rmdir(e, n, s) : m.unlink(e, n);
569
162
  }), e.rmdir(r);
570
163
  }
571
164
  static listFiles(e, r, s = { prependPath: !1 }) {
572
- if (!g.fileExists(e, r))
165
+ if (!m.fileExists(e, r))
573
166
  return [];
574
167
  try {
575
- const n = e.readdir(r).filter(
576
- (i) => i !== "." && i !== ".."
168
+ const i = e.readdir(r).filter(
169
+ (n) => n !== "." && n !== ".."
577
170
  );
578
171
  if (s.prependPath) {
579
- const i = r.replace(/\/$/, "");
580
- return n.map((o) => `${i}/${o}`);
172
+ const n = r.replace(/\/$/, "");
173
+ return i.map((o) => `${n}/${o}`);
581
174
  }
582
- return n;
583
- } catch (n) {
584
- return logger.error(n, { path: r }), [];
175
+ return i;
176
+ } catch (i) {
177
+ return logger.error(i, { path: r }), [];
585
178
  }
586
179
  }
587
180
  static isDir(e, r) {
588
- return g.fileExists(e, r) ? e.isDir(e.lookupPath(r).node.mode) : !1;
181
+ return m.fileExists(e, r) ? e.isDir(e.lookupPath(r).node.mode) : !1;
589
182
  }
590
183
  static fileExists(e, r) {
591
184
  try {
@@ -598,14 +191,14 @@ const _FSHelpers = class g {
598
191
  e.mkdirTree(r);
599
192
  }
600
193
  static copyRecursive(e, r, s) {
601
- const n = e.lookupPath(r).node;
602
- if (e.isDir(n.mode)) {
194
+ const i = e.lookupPath(r).node;
195
+ if (e.isDir(i.mode)) {
603
196
  e.mkdirTree(s);
604
- const i = e.readdir(r).filter(
197
+ const n = e.readdir(r).filter(
605
198
  (o) => o !== "." && o !== ".."
606
199
  );
607
- for (const o of i)
608
- g.copyRecursive(
200
+ for (const o of n)
201
+ m.copyRecursive(
609
202
  e,
610
203
  joinPaths(r, o),
611
204
  joinPaths(s, o)
@@ -788,8 +381,8 @@ const responseTexts = {
788
381
  200: "OK"
789
382
  };
790
383
  class PHPResponse {
791
- constructor(e, r, s, n = "", i = 0) {
792
- this.httpStatusCode = e, this.headers = r, this.bytes = s, this.exitCode = i, this.errors = n;
384
+ constructor(e, r, s, i = "", n = 0) {
385
+ this.httpStatusCode = e, this.headers = r, this.bytes = s, this.exitCode = n, this.errors = i;
793
386
  }
794
387
  static forHttpCode(e, r = "") {
795
388
  return new PHPResponse(
@@ -834,15 +427,15 @@ class PHPResponse {
834
427
  const RuntimeId = Symbol("RuntimeId"), loadedRuntimes = /* @__PURE__ */ new Map();
835
428
  let lastRuntimeId = 0;
836
429
  async function loadPHPRuntime(t, e = {}) {
837
- const [r, s, n] = makePromise(), i = t.init(currentJsRuntime, {
838
- onAbort(l) {
839
- n(l), logger.error(l);
430
+ const [r, s, i] = makePromise(), n = t.init(currentJsRuntime, {
431
+ onAbort(p) {
432
+ i(p), logger.error(p);
840
433
  },
841
434
  ENV: {},
842
435
  // Emscripten sometimes prepends a '/' to the path, which
843
436
  // breaks vite dev mode. An identity `locateFile` function
844
437
  // fixes it.
845
- locateFile: (l) => l,
438
+ locateFile: (p) => p,
846
439
  ...e,
847
440
  noInitialRun: !0,
848
441
  onRuntimeInitialized() {
@@ -851,9 +444,9 @@ async function loadPHPRuntime(t, e = {}) {
851
444
  });
852
445
  await r;
853
446
  const o = ++lastRuntimeId;
854
- return i.id = o, i.originalExit = i._exit, i._exit = function(l) {
855
- return loadedRuntimes.delete(o), i.originalExit(l);
856
- }, i[RuntimeId] = o, loadedRuntimes.set(o, i), o;
447
+ return n.id = o, n.originalExit = n._exit, n._exit = function(p) {
448
+ return loadedRuntimes.delete(o), n.originalExit(p);
449
+ }, n[RuntimeId] = o, loadedRuntimes.set(o, n), o;
857
450
  }
858
451
  function getLoadedRuntime(t) {
859
452
  return loadedRuntimes.get(t);
@@ -910,27 +503,27 @@ function improveWASMErrorReporting(t) {
910
503
  for (const r in t.wasmExports)
911
504
  if (typeof t.wasmExports[r] == "function") {
912
505
  const s = t.wasmExports[r];
913
- t.wasmExports[r] = function(...n) {
914
- var i;
506
+ t.wasmExports[r] = function(...i) {
507
+ var n;
915
508
  try {
916
- return s(...n);
509
+ return s(...i);
917
510
  } catch (o) {
918
511
  if (!(o instanceof Error))
919
512
  throw o;
920
- const l = clarifyErrorMessage(
513
+ const p = clarifyErrorMessage(
921
514
  o,
922
- (i = t.lastAsyncifyStackSource) == null ? void 0 : i.stack
515
+ (n = t.lastAsyncifyStackSource) == null ? void 0 : n.stack
923
516
  );
924
517
  if (t.lastAsyncifyStackSource && (o.cause = t.lastAsyncifyStackSource), e.hasListeners()) {
925
518
  e.dispatchEvent(
926
519
  new ErrorEvent("error", {
927
520
  error: o,
928
- message: l
521
+ message: p
929
522
  })
930
523
  );
931
524
  return;
932
525
  }
933
- throw isExitCodeZero(o) || showCriticalErrorBox(l), o;
526
+ throw isExitCodeZero(o) || showCriticalErrorBox(p), o;
934
527
  }
935
528
  };
936
529
  }
@@ -1019,7 +612,7 @@ class PHPExecutionFailureError extends Error {
1019
612
  }
1020
613
  }
1021
614
  const PHP_INI_PATH = "/internal/shared/php.ini", AUTO_PREPEND_SCRIPT = "/internal/shared/auto_prepend_file.php";
1022
- var S, E, x, v, R, M, ee, N, te, U, re, O, se, L, ne, D, ie, j, oe, $, ae, B, le, q, ce, I, K, z, ue, W, pe, G, de;
615
+ var x, P, w, g, E, k, Y, I, Z, C, K, A, X, N, Q, M, ee, j, te, U, re, L, se, $, ie, b, J, q, ne, B, oe, O, ae;
1023
616
  class PHP {
1024
617
  /**
1025
618
  * Initializes a PHP runtime.
@@ -1038,26 +631,26 @@ class PHP {
1038
631
  * was provided.
1039
632
  * @returns Computed $_SERVER entries.
1040
633
  */
1041
- p(this, M);
1042
- p(this, N);
1043
- p(this, U);
1044
- p(this, O);
1045
- p(this, L);
1046
- p(this, D);
1047
- p(this, j);
1048
- p(this, $);
1049
- p(this, B);
1050
- p(this, q);
1051
- p(this, I);
1052
- p(this, z);
1053
- p(this, W);
1054
- p(this, G);
1055
- p(this, S, void 0);
1056
- p(this, E, void 0);
1057
- p(this, x, void 0);
1058
- p(this, v, void 0);
1059
- p(this, R, void 0);
1060
- f(this, E, !1), f(this, x, null), f(this, v, /* @__PURE__ */ new Map()), f(this, R, []), this.semaphore = new Semaphore({ concurrency: 1 }), t !== void 0 && this.initializeRuntime(t);
634
+ u(this, k);
635
+ u(this, I);
636
+ u(this, C);
637
+ u(this, A);
638
+ u(this, N);
639
+ u(this, M);
640
+ u(this, j);
641
+ u(this, U);
642
+ u(this, L);
643
+ u(this, $);
644
+ u(this, b);
645
+ u(this, q);
646
+ u(this, B);
647
+ u(this, O);
648
+ u(this, x, void 0);
649
+ u(this, P, void 0);
650
+ u(this, w, void 0);
651
+ u(this, g, void 0);
652
+ u(this, E, void 0);
653
+ h(this, P, !1), h(this, w, null), h(this, g, /* @__PURE__ */ new Map()), h(this, E, []), this.semaphore = new Semaphore({ concurrency: 1 }), t !== void 0 && this.initializeRuntime(t);
1061
654
  }
1062
655
  /**
1063
656
  * Adds an event listener for a PHP event.
@@ -1065,7 +658,7 @@ class PHP {
1065
658
  * @param listener - The listener function to be called when the event is triggered.
1066
659
  */
1067
660
  addEventListener(t, e) {
1068
- u(this, v).has(t) || u(this, v).set(t, /* @__PURE__ */ new Set()), u(this, v).get(t).add(e);
661
+ c(this, g).has(t) || c(this, g).set(t, /* @__PURE__ */ new Set()), c(this, g).get(t).add(e);
1069
662
  }
1070
663
  /**
1071
664
  * Removes an event listener for a PHP event.
@@ -1074,10 +667,10 @@ class PHP {
1074
667
  */
1075
668
  removeEventListener(t, e) {
1076
669
  var r;
1077
- (r = u(this, v).get(t)) == null || r.delete(e);
670
+ (r = c(this, g).get(t)) == null || r.delete(e);
1078
671
  }
1079
672
  dispatchEvent(t) {
1080
- const e = u(this, v).get(t.type);
673
+ const e = c(this, g).get(t.type);
1081
674
  if (e)
1082
675
  for (const r of e)
1083
676
  r(t);
@@ -1122,7 +715,7 @@ class PHP {
1122
715
  * @param listener Callback function to handle the message.
1123
716
  */
1124
717
  onMessage(t) {
1125
- u(this, R).push(t);
718
+ c(this, E).push(t);
1126
719
  }
1127
720
  async setSpawnHandler(handler) {
1128
721
  typeof handler == "string" && (handler = createSpawnHandler(eval(handler))), this[__private__dont__use].spawnProcess = handler;
@@ -1196,13 +789,13 @@ class PHP {
1196
789
  }
1197
790
  `
1198
791
  ), e.onMessage = async (r) => {
1199
- for (const s of u(this, R)) {
1200
- const n = await s(r);
1201
- if (n)
1202
- return n;
792
+ for (const s of c(this, E)) {
793
+ const i = await s(r);
794
+ if (i)
795
+ return i;
1203
796
  }
1204
797
  return "";
1205
- }, f(this, x, improveWASMErrorReporting(e)), this.dispatchEvent({
798
+ }, h(this, w, improveWASMErrorReporting(e)), this.dispatchEvent({
1206
799
  type: "runtime.initialized"
1207
800
  });
1208
801
  }
@@ -1217,7 +810,7 @@ class PHP {
1217
810
  throw new Error(
1218
811
  "Could not set SAPI name. This can only be done before the PHP WASM module is initialized.Did you already dispatch any requests?"
1219
812
  );
1220
- f(this, S, t);
813
+ h(this, x, t);
1221
814
  }
1222
815
  /**
1223
816
  * Changes the current working directory in the PHP filesystem.
@@ -1314,30 +907,30 @@ class PHP {
1314
907
  const e = await this.semaphore.acquire();
1315
908
  let r;
1316
909
  try {
1317
- if (u(this, E) || (h(this, N, te).call(this), f(this, E, !0)), t.scriptPath && !this.fileExists(t.scriptPath))
910
+ if (c(this, P) || (d(this, I, Z).call(this), h(this, P, !0)), t.scriptPath && !this.fileExists(t.scriptPath))
1318
911
  throw new Error(
1319
912
  `The script path "${t.scriptPath}" does not exist.`
1320
913
  );
1321
- h(this, O, se).call(this, t.relativeUri || ""), h(this, $, ae).call(this, t.method || "GET");
1322
- const s = normalizeHeaders(t.headers || {}), n = s.host || "example.com:443", i = h(this, j, oe).call(this, n, t.protocol || "http");
1323
- h(this, L, ne).call(this, n), h(this, D, ie).call(this, i), h(this, B, le).call(this, s), t.body && (r = h(this, q, ce).call(this, t.body)), typeof t.code == "string" ? (this.writeFile("/internal/eval.php", t.code), h(this, I, K).call(this, "/internal/eval.php")) : h(this, I, K).call(this, t.scriptPath || "");
1324
- const o = h(this, M, ee).call(this, t.$_SERVER, s, i);
914
+ d(this, A, X).call(this, t.relativeUri || ""), d(this, U, re).call(this, t.method || "GET");
915
+ const s = normalizeHeaders(t.headers || {}), i = s.host || "example.com:443", n = d(this, j, te).call(this, i, t.protocol || "http");
916
+ d(this, N, Q).call(this, i), d(this, M, ee).call(this, n), d(this, L, se).call(this, s), t.body && (r = d(this, $, ie).call(this, t.body)), typeof t.code == "string" ? (this.writeFile("/internal/eval.php", t.code), d(this, b, J).call(this, "/internal/eval.php")) : d(this, b, J).call(this, t.scriptPath || "");
917
+ const o = d(this, k, Y).call(this, t.$_SERVER, s, n);
1325
918
  for (const a in o)
1326
- h(this, z, ue).call(this, a, o[a]);
1327
- const l = t.env || {};
1328
- for (const a in l)
1329
- h(this, W, pe).call(this, a, l[a]);
1330
- const c = await h(this, G, de).call(this);
1331
- if (c.exitCode !== 0) {
1332
- logger.warn("PHP.run() output was:", c.text);
919
+ d(this, q, ne).call(this, a, o[a]);
920
+ const p = t.env || {};
921
+ for (const a in p)
922
+ d(this, B, oe).call(this, a, p[a]);
923
+ const l = await d(this, O, ae).call(this);
924
+ if (l.exitCode !== 0) {
925
+ logger.warn("PHP.run() output was:", l.text);
1333
926
  const a = new PHPExecutionFailureError(
1334
- `PHP.run() failed with exit code ${c.exitCode} and the following output: ` + c.errors,
1335
- c,
927
+ `PHP.run() failed with exit code ${l.exitCode} and the following output: ` + l.errors,
928
+ l,
1336
929
  "request"
1337
930
  );
1338
931
  throw logger.error(a), a;
1339
932
  }
1340
- return c;
933
+ return l;
1341
934
  } catch (s) {
1342
935
  throw this.dispatchEvent({
1343
936
  type: "request.error",
@@ -1498,7 +1091,7 @@ class PHP {
1498
1091
  this.exit();
1499
1092
  } catch {
1500
1093
  }
1501
- this.initializeRuntime(t), u(this, S) && this.setSapiName(u(this, S)), e && copyFS(r, this[__private__dont__use].FS, e);
1094
+ this.initializeRuntime(t), c(this, x) && this.setSapiName(c(this, x)), e && copyFS(r, this[__private__dont__use].FS, e);
1502
1095
  }
1503
1096
  /**
1504
1097
  * Mounts a filesystem to a given path in the PHP filesystem.
@@ -1567,25 +1160,25 @@ class PHP {
1567
1160
  this[__private__dont__use]._exit(t);
1568
1161
  } catch {
1569
1162
  }
1570
- f(this, E, !1), f(this, x, null), delete this[__private__dont__use].onMessage, delete this[__private__dont__use];
1163
+ h(this, P, !1), h(this, w, null), delete this[__private__dont__use].onMessage, delete this[__private__dont__use];
1571
1164
  }
1572
1165
  [Symbol.dispose]() {
1573
- u(this, E) && this.exit(0);
1166
+ c(this, P) && this.exit(0);
1574
1167
  }
1575
1168
  }
1576
- S = new WeakMap(), E = new WeakMap(), x = new WeakMap(), v = new WeakMap(), R = new WeakMap(), M = new WeakSet(), ee = function(t, e, r) {
1169
+ x = new WeakMap(), P = new WeakMap(), w = new WeakMap(), g = new WeakMap(), E = new WeakMap(), k = new WeakSet(), Y = function(t, e, r) {
1577
1170
  const s = {
1578
1171
  ...t || {}
1579
1172
  };
1580
1173
  s.HTTPS = s.HTTPS || r === 443 ? "on" : "off";
1581
- for (const n in e) {
1582
- let i = "HTTP_";
1583
- ["content-type", "content-length"].includes(n.toLowerCase()) && (i = ""), s[`${i}${n.toUpperCase().replace(/-/g, "_")}`] = e[n];
1174
+ for (const i in e) {
1175
+ let n = "HTTP_";
1176
+ ["content-type", "content-length"].includes(i.toLowerCase()) && (n = ""), s[`${n}${i.toUpperCase().replace(/-/g, "_")}`] = e[i];
1584
1177
  }
1585
1178
  return s;
1586
- }, N = new WeakSet(), te = function() {
1179
+ }, I = new WeakSet(), Z = function() {
1587
1180
  this[__private__dont__use].ccall("php_wasm_init", null, [], []);
1588
- }, U = new WeakSet(), re = function() {
1181
+ }, C = new WeakSet(), K = function() {
1589
1182
  const t = "/internal/headers.json";
1590
1183
  if (!this.fileExists(t))
1591
1184
  throw new Error(
@@ -1595,14 +1188,14 @@ S = new WeakMap(), E = new WeakMap(), x = new WeakMap(), v = new WeakMap(), R =
1595
1188
  for (const s of e.headers) {
1596
1189
  if (!s.includes(": "))
1597
1190
  continue;
1598
- const n = s.indexOf(": "), i = s.substring(0, n).toLowerCase(), o = s.substring(n + 2);
1599
- i in r || (r[i] = []), r[i].push(o);
1191
+ const i = s.indexOf(": "), n = s.substring(0, i).toLowerCase(), o = s.substring(i + 2);
1192
+ n in r || (r[n] = []), r[n].push(o);
1600
1193
  }
1601
1194
  return {
1602
1195
  headers: r,
1603
1196
  httpStatusCode: e.status
1604
1197
  };
1605
- }, O = new WeakSet(), se = function(t) {
1198
+ }, A = new WeakSet(), X = function(t) {
1606
1199
  if (this[__private__dont__use].ccall(
1607
1200
  "wasm_set_request_uri",
1608
1201
  null,
@@ -1617,35 +1210,35 @@ S = new WeakMap(), E = new WeakMap(), x = new WeakMap(), v = new WeakMap(), R =
1617
1210
  [e]
1618
1211
  );
1619
1212
  }
1620
- }, L = new WeakSet(), ne = function(t) {
1213
+ }, N = new WeakSet(), Q = function(t) {
1621
1214
  this[__private__dont__use].ccall(
1622
1215
  "wasm_set_request_host",
1623
1216
  null,
1624
1217
  [STRING],
1625
1218
  [t]
1626
1219
  );
1627
- }, D = new WeakSet(), ie = function(t) {
1220
+ }, M = new WeakSet(), ee = function(t) {
1628
1221
  this[__private__dont__use].ccall(
1629
1222
  "wasm_set_request_port",
1630
1223
  null,
1631
1224
  [NUMBER],
1632
1225
  [t]
1633
1226
  );
1634
- }, j = new WeakSet(), oe = function(t, e) {
1227
+ }, j = new WeakSet(), te = function(t, e) {
1635
1228
  let r;
1636
1229
  try {
1637
1230
  r = parseInt(new URL(t).port, 10);
1638
1231
  } catch {
1639
1232
  }
1640
1233
  return (!r || isNaN(r) || r === 80) && (r = e === "https" ? 443 : 80), r;
1641
- }, $ = new WeakSet(), ae = function(t) {
1234
+ }, U = new WeakSet(), re = function(t) {
1642
1235
  this[__private__dont__use].ccall(
1643
1236
  "wasm_set_request_method",
1644
1237
  null,
1645
1238
  [STRING],
1646
1239
  [t]
1647
1240
  );
1648
- }, B = new WeakSet(), le = function(t) {
1241
+ }, L = new WeakSet(), se = function(t) {
1649
1242
  t.cookie && this[__private__dont__use].ccall(
1650
1243
  "wasm_set_cookies",
1651
1244
  null,
@@ -1662,7 +1255,7 @@ S = new WeakMap(), E = new WeakMap(), x = new WeakMap(), v = new WeakMap(), R =
1662
1255
  [NUMBER],
1663
1256
  [parseInt(t["content-length"], 10)]
1664
1257
  );
1665
- }, q = new WeakSet(), ce = function(t) {
1258
+ }, $ = new WeakSet(), ie = function(t) {
1666
1259
  let e, r;
1667
1260
  typeof t == "string" ? (logger.warn(
1668
1261
  "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"
@@ -1685,51 +1278,51 @@ S = new WeakMap(), E = new WeakMap(), x = new WeakMap(), v = new WeakMap(), R =
1685
1278
  [NUMBER],
1686
1279
  [r]
1687
1280
  ), s;
1688
- }, I = new WeakSet(), K = function(t) {
1281
+ }, b = new WeakSet(), J = function(t) {
1689
1282
  this[__private__dont__use].ccall(
1690
1283
  "wasm_set_path_translated",
1691
1284
  null,
1692
1285
  [STRING],
1693
1286
  [t]
1694
1287
  );
1695
- }, z = new WeakSet(), ue = function(t, e) {
1288
+ }, q = new WeakSet(), ne = function(t, e) {
1696
1289
  this[__private__dont__use].ccall(
1697
1290
  "wasm_add_SERVER_entry",
1698
1291
  null,
1699
1292
  [STRING, STRING],
1700
1293
  [t, e]
1701
1294
  );
1702
- }, W = new WeakSet(), pe = function(t, e) {
1295
+ }, B = new WeakSet(), oe = function(t, e) {
1703
1296
  this[__private__dont__use].ccall(
1704
1297
  "wasm_add_ENV_entry",
1705
1298
  null,
1706
1299
  [STRING, STRING],
1707
1300
  [t, e]
1708
1301
  );
1709
- }, G = new WeakSet(), de = async function() {
1710
- var n;
1302
+ }, O = new WeakSet(), ae = async function() {
1303
+ var i;
1711
1304
  let t, e;
1712
1305
  try {
1713
- t = await new Promise((i, o) => {
1714
- var c;
1306
+ t = await new Promise((n, o) => {
1307
+ var l;
1715
1308
  e = (a) => {
1716
1309
  logger.error(a), logger.error(a.error);
1717
- const d = new Error("Rethrown");
1718
- d.cause = a.error, d.betterMessage = a.message, o(d);
1719
- }, (c = u(this, x)) == null || c.addEventListener(
1310
+ const y = new Error("Rethrown");
1311
+ y.cause = a.error, y.betterMessage = a.message, o(y);
1312
+ }, (l = c(this, w)) == null || l.addEventListener(
1720
1313
  "error",
1721
1314
  e
1722
1315
  );
1723
- const l = this[__private__dont__use].ccall(
1316
+ const p = this[__private__dont__use].ccall(
1724
1317
  "wasm_sapi_handle_request",
1725
1318
  NUMBER,
1726
1319
  [],
1727
1320
  [],
1728
1321
  { async: !0 }
1729
1322
  );
1730
- return l instanceof Promise ? l.then(i, o) : i(l);
1323
+ return p instanceof Promise ? p.then(n, o) : n(p);
1731
1324
  });
1732
- } catch (i) {
1325
+ } catch (n) {
1733
1326
  for (const a in this)
1734
1327
  typeof this[a] == "function" && (this[a] = () => {
1735
1328
  throw new Error(
@@ -1737,12 +1330,12 @@ S = new WeakMap(), E = new WeakMap(), x = new WeakMap(), v = new WeakMap(), R =
1737
1330
  );
1738
1331
  });
1739
1332
  this.functionsMaybeMissingFromAsyncify = getFunctionsMaybeMissingFromAsyncify();
1740
- const o = i, l = "betterMessage" in o ? o.betterMessage : o.message, c = new Error(l);
1741
- throw c.cause = o, logger.error(c), c;
1333
+ const o = n, p = "betterMessage" in o ? o.betterMessage : o.message, l = new Error(p);
1334
+ throw l.cause = o, logger.error(l), l;
1742
1335
  } finally {
1743
- (n = u(this, x)) == null || n.removeEventListener("error", e);
1336
+ (i = c(this, w)) == null || i.removeEventListener("error", e);
1744
1337
  }
1745
- const { headers: r, httpStatusCode: s } = h(this, U, re).call(this);
1338
+ const { headers: r, httpStatusCode: s } = d(this, C, K).call(this);
1746
1339
  return new PHPResponse(
1747
1340
  t === 0 ? s : 500,
1748
1341
  r,
@@ -1771,137 +1364,24 @@ function copyFS(t, e, r) {
1771
1364
  return;
1772
1365
  }
1773
1366
  e.mkdirTree(r);
1774
- const n = t.readdir(r).filter((i) => i !== "." && i !== "..");
1775
- for (const i of n)
1776
- copyFS(t, e, joinPaths(r, i));
1777
- }
1778
- const { hasOwnProperty } = Object.prototype, encode = (t, e = {}) => {
1779
- typeof e == "string" && (e = { section: e }), e.align = e.align === !0, e.newline = e.newline === !0, e.sort = e.sort === !0, e.whitespace = e.whitespace === !0 || e.align === !0, e.platform = e.platform || typeof process < "u" && process.platform, e.bracketedArray = e.bracketedArray !== !1;
1780
- const r = e.platform === "win32" ? `\r
1781
- ` : `
1782
- `, s = e.whitespace ? " = " : "=", n = [], i = e.sort ? Object.keys(t).sort() : Object.keys(t);
1783
- let o = 0;
1784
- e.align && (o = safe(
1785
- i.filter((a) => t[a] === null || Array.isArray(t[a]) || typeof t[a] != "object").map((a) => Array.isArray(t[a]) ? `${a}[]` : a).concat([""]).reduce((a, d) => safe(a).length >= safe(d).length ? a : d)
1786
- ).length);
1787
- let l = "";
1788
- const c = e.bracketedArray ? "[]" : "";
1789
- for (const a of i) {
1790
- const d = t[a];
1791
- if (d && Array.isArray(d))
1792
- for (const m of d)
1793
- l += safe(`${a}${c}`).padEnd(o, " ") + s + safe(m) + r;
1794
- else
1795
- d && typeof d == "object" ? n.push(a) : l += safe(a).padEnd(o, " ") + s + safe(d) + r;
1796
- }
1797
- e.section && l.length && (l = "[" + safe(e.section) + "]" + (e.newline ? r + r : r) + l);
1798
- for (const a of n) {
1799
- const d = splitSections(a, ".").join("\\."), m = (e.section ? e.section + "." : "") + d, y = encode(t[a], {
1800
- ...e,
1801
- section: m
1802
- });
1803
- l.length && y.length && (l += r), l += y;
1804
- }
1805
- return l;
1806
- };
1807
- function splitSections(t, e) {
1808
- var r = 0, s = 0, n = 0, i = [];
1809
- do
1810
- if (n = t.indexOf(e, r), n !== -1) {
1811
- if (r = n + e.length, n > 0 && t[n - 1] === "\\")
1812
- continue;
1813
- i.push(t.slice(s, n)), s = n + e.length;
1814
- }
1815
- while (n !== -1);
1816
- return i.push(t.slice(s)), i;
1367
+ const i = t.readdir(r).filter((n) => n !== "." && n !== "..");
1368
+ for (const n of i)
1369
+ copyFS(t, e, joinPaths(r, n));
1817
1370
  }
1818
- const decode = (t, e = {}) => {
1819
- e.bracketedArray = e.bracketedArray !== !1;
1820
- const r = /* @__PURE__ */ Object.create(null);
1821
- let s = r, n = null;
1822
- const i = /^\[([^\]]*)\]\s*$|^([^=]+)(=(.*))?$/i, o = t.split(/[\r\n]+/g), l = {};
1823
- for (const a of o) {
1824
- if (!a || a.match(/^\s*[;#]/) || a.match(/^\s*$/))
1825
- continue;
1826
- const d = a.match(i);
1827
- if (!d)
1828
- continue;
1829
- if (d[1] !== void 0) {
1830
- if (n = unsafe(d[1]), n === "__proto__") {
1831
- s = /* @__PURE__ */ Object.create(null);
1832
- continue;
1833
- }
1834
- s = r[n] = r[n] || /* @__PURE__ */ Object.create(null);
1835
- continue;
1836
- }
1837
- const m = unsafe(d[2]);
1838
- let y;
1839
- e.bracketedArray ? y = m.length > 2 && m.slice(-2) === "[]" : (l[m] = ((l == null ? void 0 : l[m]) || 0) + 1, y = l[m] > 1);
1840
- const _ = y ? m.slice(0, -2) : m;
1841
- if (_ === "__proto__")
1842
- continue;
1843
- const A = d[3] ? unsafe(d[4]) : !0, X = A === "true" || A === "false" || A === "null" ? JSON.parse(A) : A;
1844
- y && (hasOwnProperty.call(s, _) ? Array.isArray(s[_]) || (s[_] = [s[_]]) : s[_] = []), Array.isArray(s[_]) ? s[_].push(X) : s[_] = X;
1845
- }
1846
- const c = [];
1847
- for (const a of Object.keys(r)) {
1848
- if (!hasOwnProperty.call(r, a) || typeof r[a] != "object" || Array.isArray(r[a]))
1849
- continue;
1850
- const d = splitSections(a, ".");
1851
- s = r;
1852
- const m = d.pop(), y = m.replace(/\\\./g, ".");
1853
- for (const _ of d)
1854
- _ !== "__proto__" && ((!hasOwnProperty.call(s, _) || typeof s[_] != "object") && (s[_] = /* @__PURE__ */ Object.create(null)), s = s[_]);
1855
- s === r && y === m || (s[y] = r[a], c.push(a));
1856
- }
1857
- for (const a of c)
1858
- delete r[a];
1859
- return r;
1860
- }, isQuoted = (t) => t.startsWith('"') && t.endsWith('"') || t.startsWith("'") && t.endsWith("'"), safe = (t) => typeof t != "string" || t.match(/[=\r\n]/) || t.match(/^\[/) || t.length > 1 && isQuoted(t) || t !== t.trim() ? JSON.stringify(t) : t.split(";").join("\\;").split("#").join("\\#"), unsafe = (t) => {
1861
- if (t = (t || "").trim(), isQuoted(t)) {
1862
- t.charAt(0) === "'" && (t = t.slice(1, -1));
1863
- try {
1864
- t = JSON.parse(t);
1865
- } catch {
1866
- }
1867
- } else {
1868
- let e = !1, r = "";
1869
- for (let s = 0, n = t.length; s < n; s++) {
1870
- const i = t.charAt(s);
1871
- if (e)
1872
- "\\;#".indexOf(i) !== -1 ? r += i : r += "\\" + i, e = !1;
1873
- else {
1874
- if (";#".indexOf(i) !== -1)
1875
- break;
1876
- i === "\\" ? e = !0 : r += i;
1877
- }
1878
- }
1879
- return e && (r += "\\"), r.trim();
1880
- }
1881
- return t;
1882
- };
1883
- var ini = {
1884
- parse: decode,
1885
- decode,
1886
- stringify: encode,
1887
- encode,
1888
- safe,
1889
- unsafe
1890
- };
1891
1371
  async function getPhpIniEntries(t, e) {
1892
- const r = ini.parse(await t.readFileAsText(PHP_INI_PATH));
1372
+ const r = parse(await t.readFileAsText(PHP_INI_PATH));
1893
1373
  if (e === void 0)
1894
1374
  return r;
1895
1375
  const s = {};
1896
- for (const n of e)
1897
- s[n] = r[n];
1376
+ for (const i of e)
1377
+ s[i] = r[i];
1898
1378
  return s;
1899
1379
  }
1900
1380
  async function setPhpIniEntries(t, e) {
1901
- const r = ini.parse(await t.readFileAsText(PHP_INI_PATH));
1902
- for (const [s, n] of Object.entries(e))
1903
- n == null ? delete r[s] : r[s] = n;
1904
- await t.writeFile(PHP_INI_PATH, ini.stringify(r));
1381
+ const r = parse(await t.readFileAsText(PHP_INI_PATH));
1382
+ for (const [s, i] of Object.entries(e))
1383
+ i == null ? delete r[s] : r[s] = i;
1384
+ await t.writeFile(PHP_INI_PATH, stringify(r));
1905
1385
  }
1906
1386
  async function withPHPIniValues(t, e, r) {
1907
1387
  const s = await t.readFileAsText(PHP_INI_PATH);
@@ -1921,8 +1401,8 @@ class HttpCookieStore {
1921
1401
  try {
1922
1402
  if (!r.includes("="))
1923
1403
  continue;
1924
- const s = r.indexOf("="), n = r.substring(0, s), i = r.substring(s + 1).split(";")[0];
1925
- this.cookies[n] = i;
1404
+ const s = r.indexOf("="), i = r.substring(0, s), n = r.substring(s + 1).split(";")[0];
1405
+ this.cookies[i] = n;
1926
1406
  } catch (s) {
1927
1407
  logger.error(s);
1928
1408
  }
@@ -1934,125 +1414,6 @@ class HttpCookieStore {
1934
1414
  return e.join("; ");
1935
1415
  }
1936
1416
  }
1937
- function concatUint8Array(...t) {
1938
- const e = new Uint8Array(
1939
- t.reduce((s, n) => s + n.length, 0)
1940
- );
1941
- let r = 0;
1942
- for (const s of t)
1943
- e.set(s, r), r += s.length;
1944
- return e;
1945
- }
1946
- function concatBytes(t) {
1947
- if (t === void 0) {
1948
- let e = new Uint8Array();
1949
- return new TransformStream({
1950
- transform(r) {
1951
- e = concatUint8Array(e, r);
1952
- },
1953
- flush(r) {
1954
- r.enqueue(e);
1955
- }
1956
- });
1957
- } else {
1958
- const e = new ArrayBuffer(t || 0);
1959
- let r = 0;
1960
- return new TransformStream({
1961
- transform(s) {
1962
- new Uint8Array(e).set(s, r), r += s.byteLength;
1963
- },
1964
- flush(s) {
1965
- s.enqueue(new Uint8Array(e));
1966
- }
1967
- });
1968
- }
1969
- }
1970
- function limitBytes(t, e) {
1971
- if (e === 0)
1972
- return new ReadableStream({
1973
- start(n) {
1974
- n.close();
1975
- }
1976
- });
1977
- const r = t.getReader({ mode: "byob" });
1978
- let s = 0;
1979
- return new ReadableStream({
1980
- async pull(n) {
1981
- const { value: i, done: o } = await r.read(
1982
- new Uint8Array(e - s)
1983
- );
1984
- if (o) {
1985
- r.releaseLock(), n.close();
1986
- return;
1987
- }
1988
- s += i.length, n.enqueue(i), s >= e && (r.releaseLock(), n.close());
1989
- },
1990
- cancel() {
1991
- r.cancel();
1992
- }
1993
- });
1994
- }
1995
- async function collectBytes(t, e) {
1996
- return e !== void 0 && (t = limitBytes(t, e)), await t.pipeThrough(concatBytes(e)).getReader().read().then(({ value: r }) => r);
1997
- }
1998
- class StreamedFile extends File {
1999
- /**
2000
- * Creates a new StreamedFile instance.
2001
- *
2002
- * @param readableStream The readable stream containing the file data.
2003
- * @param name The name of the file.
2004
- * @param type The MIME type of the file.
2005
- */
2006
- constructor(e, r, s) {
2007
- super([], r, { type: s }), this.readableStream = e;
2008
- }
2009
- /**
2010
- * Overrides the slice() method of the File class.
2011
- *
2012
- * @returns A Blob representing a portion of the file.
2013
- */
2014
- slice() {
2015
- throw new Error("slice() is not possible on a StreamedFile");
2016
- }
2017
- /**
2018
- * Returns the readable stream associated with the file.
2019
- *
2020
- * @returns The readable stream.
2021
- */
2022
- stream() {
2023
- return this.readableStream;
2024
- }
2025
- /**
2026
- * Loads the file data into memory and then returns it as a string.
2027
- *
2028
- * @returns File data as text.
2029
- */
2030
- async text() {
2031
- return new TextDecoder().decode(await this.arrayBuffer());
2032
- }
2033
- /**
2034
- * Loads the file data into memory and then returns it as an ArrayBuffer.
2035
- *
2036
- * @returns File data as an ArrayBuffer.
2037
- */
2038
- async arrayBuffer() {
2039
- return await collectBytes(this.stream());
2040
- }
2041
- }
2042
- ReadableStream.prototype[Symbol.asyncIterator] || (ReadableStream.prototype[Symbol.asyncIterator] = async function* () {
2043
- const t = this.getReader();
2044
- try {
2045
- for (; ; ) {
2046
- const { done: e, value: r } = await t.read();
2047
- if (e)
2048
- return;
2049
- yield r;
2050
- }
2051
- } finally {
2052
- t.releaseLock();
2053
- }
2054
- }, ReadableStream.prototype.iterate = // @ts-ignore
2055
- ReadableStream.prototype[Symbol.asyncIterator]);
2056
1417
  function streamReadFileFromPHP(t, e) {
2057
1418
  return new ReadableStream({
2058
1419
  async pull(r) {
@@ -2064,20 +1425,20 @@ function streamReadFileFromPHP(t, e) {
2064
1425
  async function* iteratePhpFiles(t, e, {
2065
1426
  relativePaths: r = !0,
2066
1427
  pathPrefix: s,
2067
- exceptPaths: n = []
1428
+ exceptPaths: i = []
2068
1429
  } = {}) {
2069
1430
  e = normalizePath(e);
2070
- const i = [e];
2071
- for (; i.length; ) {
2072
- const o = i.pop();
1431
+ const n = [e];
1432
+ for (; n.length; ) {
1433
+ const o = n.pop();
2073
1434
  if (!o)
2074
1435
  return;
2075
- const l = await t.listFiles(o);
2076
- for (const c of l) {
2077
- const a = `${o}/${c}`;
2078
- if (n.includes(a.substring(e.length + 1)))
1436
+ const p = await t.listFiles(o);
1437
+ for (const l of p) {
1438
+ const a = `${o}/${l}`;
1439
+ if (i.includes(a.substring(e.length + 1)))
2079
1440
  continue;
2080
- await t.isDir(a) ? i.push(a) : yield new StreamedFile(
1441
+ await t.isDir(a) ? n.push(a) : yield new StreamedFile(
2081
1442
  streamReadFileFromPHP(t, a),
2082
1443
  r ? joinPaths(
2083
1444
  s || "",
@@ -2168,15 +1529,15 @@ class PHPProcessManager {
2168
1529
  this.allInstances.push(r);
2169
1530
  const s = () => {
2170
1531
  this.allInstances = this.allInstances.filter(
2171
- (n) => n !== r
1532
+ (i) => i !== r
2172
1533
  );
2173
1534
  };
2174
- return r.catch((n) => {
2175
- throw s(), n;
2176
- }).then((n) => ({
2177
- ...n,
1535
+ return r.catch((i) => {
1536
+ throw s(), i;
1537
+ }).then((i) => ({
1538
+ ...i,
2178
1539
  reap: () => {
2179
- s(), n.reap();
1540
+ s(), i.reap();
2180
1541
  }
2181
1542
  }));
2182
1543
  }
@@ -2239,23 +1600,23 @@ function ensurePathPrefix(t, e) {
2239
1600
  return !e || t.startsWith(e) ? t : e + t;
2240
1601
  }
2241
1602
  async function encodeAsMultipart(t) {
2242
- const e = `----${Math.random().toString(36).slice(2)}`, r = `multipart/form-data; boundary=${e}`, s = new TextEncoder(), n = [];
2243
- for (const [c, a] of Object.entries(t))
2244
- n.push(`--${e}\r
2245
- `), n.push(`Content-Disposition: form-data; name="${c}"`), a instanceof File && n.push(`; filename="${a.name}"`), n.push(`\r
2246
- `), a instanceof File && (n.push("Content-Type: application/octet-stream"), n.push(`\r
2247
- `)), n.push(`\r
2248
- `), a instanceof File ? n.push(await fileToUint8Array(a)) : n.push(a), n.push(`\r
1603
+ const e = `----${Math.random().toString(36).slice(2)}`, r = `multipart/form-data; boundary=${e}`, s = new TextEncoder(), i = [];
1604
+ for (const [l, a] of Object.entries(t))
1605
+ i.push(`--${e}\r
1606
+ `), i.push(`Content-Disposition: form-data; name="${l}"`), a instanceof File && i.push(`; filename="${a.name}"`), i.push(`\r
1607
+ `), a instanceof File && (i.push("Content-Type: application/octet-stream"), i.push(`\r
1608
+ `)), i.push(`\r
1609
+ `), a instanceof File ? i.push(await fileToUint8Array(a)) : i.push(a), i.push(`\r
2249
1610
  `);
2250
- n.push(`--${e}--\r
1611
+ i.push(`--${e}--\r
2251
1612
  `);
2252
- const i = n.reduce((c, a) => c + a.length, 0), o = new Uint8Array(i);
2253
- let l = 0;
2254
- for (const c of n)
1613
+ const n = i.reduce((l, a) => l + a.length, 0), o = new Uint8Array(n);
1614
+ let p = 0;
1615
+ for (const l of i)
2255
1616
  o.set(
2256
- typeof c == "string" ? s.encode(c) : c,
2257
- l
2258
- ), l += c.length;
1617
+ typeof l == "string" ? s.encode(l) : l,
1618
+ p
1619
+ ), p += l.length;
2259
1620
  return { bytes: o, contentType: r };
2260
1621
  }
2261
1622
  function fileToUint8Array(t) {
@@ -2362,7 +1723,7 @@ const _default = "application/octet-stream", asx = "video/x-ms-asf", atom = "app
2362
1723
  xspf,
2363
1724
  zip
2364
1725
  };
2365
- var w, F, C, b, H, P, T, k, V, he, J, fe, Q, me, Z, _e;
1726
+ var f, R, T, v, S, _, H, F, D, le, z, ce, W, pe, G, ue;
2366
1727
  class PHPRequestHandler {
2367
1728
  /**
2368
1729
  * The request handler needs to decide whether to serve a static asset or
@@ -2382,11 +1743,11 @@ class PHPRequestHandler {
2382
1743
  * @param fsPath - Absolute path of the static file to serve.
2383
1744
  * @returns The response.
2384
1745
  */
2385
- p(this, V);
1746
+ u(this, D);
2386
1747
  /**
2387
1748
  * Spawns a new PHP instance and dispatches a request to it.
2388
1749
  */
2389
- p(this, J);
1750
+ u(this, z);
2390
1751
  /**
2391
1752
  * Runs the requested PHP file with all the request and $_SERVER
2392
1753
  * superglobals populated.
@@ -2394,7 +1755,7 @@ class PHPRequestHandler {
2394
1755
  * @param request - The request.
2395
1756
  * @returns The response.
2396
1757
  */
2397
- p(this, Q);
1758
+ u(this, W);
2398
1759
  /**
2399
1760
  * Resolve the requested path to the filesystem path of the requested PHP file.
2400
1761
  *
@@ -2404,41 +1765,41 @@ class PHPRequestHandler {
2404
1765
  * @throws {Error} If the requested path doesn't exist.
2405
1766
  * @returns The resolved filesystem path.
2406
1767
  */
2407
- p(this, Z);
2408
- p(this, w, void 0);
2409
- p(this, F, void 0);
2410
- p(this, C, void 0);
2411
- p(this, b, void 0);
2412
- p(this, H, void 0);
2413
- p(this, P, void 0);
2414
- p(this, T, void 0);
2415
- p(this, k, void 0);
1768
+ u(this, G);
1769
+ u(this, f, void 0);
1770
+ u(this, R, void 0);
1771
+ u(this, T, void 0);
1772
+ u(this, v, void 0);
1773
+ u(this, S, void 0);
1774
+ u(this, _, void 0);
1775
+ u(this, H, void 0);
1776
+ u(this, F, void 0);
2416
1777
  const {
2417
1778
  documentRoot: r = "/www/",
2418
1779
  absoluteUrl: s = typeof location == "object" ? location == null ? void 0 : location.href : "",
2419
- rewriteRules: n = []
1780
+ rewriteRules: i = []
2420
1781
  } = e;
2421
1782
  "processManager" in e ? this.processManager = e.processManager : this.processManager = new PHPProcessManager({
2422
- phpFactory: async (l) => {
2423
- const c = await e.phpFactory({
2424
- ...l,
1783
+ phpFactory: async (p) => {
1784
+ const l = await e.phpFactory({
1785
+ ...p,
2425
1786
  requestHandler: this
2426
1787
  });
2427
- return c.requestHandler = this, c;
1788
+ return l.requestHandler = this, l;
2428
1789
  },
2429
1790
  maxPhpInstances: e.maxPhpInstances
2430
- }), f(this, k, new HttpCookieStore()), f(this, w, r);
2431
- const i = new URL(s);
2432
- f(this, C, i.hostname), f(this, b, i.port ? Number(i.port) : i.protocol === "https:" ? 443 : 80), f(this, F, (i.protocol || "").replace(":", ""));
2433
- const o = u(this, b) !== 443 && u(this, b) !== 80;
2434
- f(this, H, [
2435
- u(this, C),
2436
- o ? `:${u(this, b)}` : ""
2437
- ].join("")), f(this, P, i.pathname.replace(/\/+$/, "")), f(this, T, [
2438
- `${u(this, F)}://`,
2439
- u(this, H),
2440
- u(this, P)
2441
- ].join("")), this.rewriteRules = n;
1791
+ }), h(this, F, new HttpCookieStore()), h(this, f, r);
1792
+ const n = new URL(s);
1793
+ h(this, T, n.hostname), h(this, v, n.port ? Number(n.port) : n.protocol === "https:" ? 443 : 80), h(this, R, (n.protocol || "").replace(":", ""));
1794
+ const o = c(this, v) !== 443 && c(this, v) !== 80;
1795
+ h(this, S, [
1796
+ c(this, T),
1797
+ o ? `:${c(this, v)}` : ""
1798
+ ].join("")), h(this, _, n.pathname.replace(/\/+$/, "")), h(this, H, [
1799
+ `${c(this, R)}://`,
1800
+ c(this, S),
1801
+ c(this, _)
1802
+ ].join("")), this.rewriteRules = i;
2442
1803
  }
2443
1804
  async getPrimaryPhp() {
2444
1805
  return await this.processManager.getPrimaryPhp();
@@ -2462,20 +1823,20 @@ class PHPRequestHandler {
2462
1823
  */
2463
1824
  internalUrlToPath(e) {
2464
1825
  const r = new URL(e);
2465
- return r.pathname.startsWith(u(this, P)) && (r.pathname = r.pathname.slice(u(this, P).length)), toRelativeUrl(r);
1826
+ return r.pathname.startsWith(c(this, _)) && (r.pathname = r.pathname.slice(c(this, _).length)), toRelativeUrl(r);
2466
1827
  }
2467
1828
  /**
2468
1829
  * The absolute URL of this PHPRequestHandler instance.
2469
1830
  */
2470
1831
  get absoluteUrl() {
2471
- return u(this, T);
1832
+ return c(this, H);
2472
1833
  }
2473
1834
  /**
2474
1835
  * The directory in the PHP filesystem where the server will look
2475
1836
  * for the files to serve. Default: `/var/www`.
2476
1837
  */
2477
1838
  get documentRoot() {
2478
- return u(this, w);
1839
+ return c(this, f);
2479
1840
  }
2480
1841
  /**
2481
1842
  * Serves the request – either by serving a static file, or by
@@ -2530,17 +1891,17 @@ class PHPRequestHandler {
2530
1891
  // Remove the hash part of the URL as it's not meant for the server.
2531
1892
  e.url.split("#")[0],
2532
1893
  r ? void 0 : DEFAULT_BASE_URL
2533
- ), n = applyRewriteRules(
1894
+ ), i = applyRewriteRules(
2534
1895
  removePathPrefix(
2535
1896
  decodeURIComponent(s.pathname),
2536
- u(this, P)
1897
+ c(this, _)
2537
1898
  ),
2538
1899
  this.rewriteRules
2539
- ), i = joinPaths(u(this, w), n);
2540
- return seemsLikeAPHPRequestHandlerPath(i) ? h(this, J, fe).call(this, e, s) : h(this, V, he).call(this, await this.processManager.getPrimaryPhp(), i);
1900
+ ), n = joinPaths(c(this, f), i);
1901
+ return seemsLikeAPHPRequestHandlerPath(n) ? d(this, z, ce).call(this, e, s) : d(this, D, le).call(this, await this.processManager.getPrimaryPhp(), n);
2541
1902
  }
2542
1903
  }
2543
- w = new WeakMap(), F = new WeakMap(), C = new WeakMap(), b = new WeakMap(), H = new WeakMap(), P = new WeakMap(), T = new WeakMap(), k = new WeakMap(), V = new WeakSet(), he = function(e, r) {
1904
+ f = new WeakMap(), R = new WeakMap(), T = new WeakMap(), v = new WeakMap(), S = new WeakMap(), _ = new WeakMap(), H = new WeakMap(), F = new WeakMap(), D = new WeakSet(), le = function(e, r) {
2544
1905
  if (!e.fileExists(r))
2545
1906
  return new PHPResponse(
2546
1907
  404,
@@ -2565,70 +1926,70 @@ w = new WeakMap(), F = new WeakMap(), C = new WeakMap(), b = new WeakMap(), H =
2565
1926
  },
2566
1927
  s
2567
1928
  );
2568
- }, J = new WeakSet(), fe = async function(e, r) {
1929
+ }, z = new WeakSet(), ce = async function(e, r) {
2569
1930
  let s;
2570
1931
  try {
2571
1932
  s = await this.processManager.acquirePHPInstance();
2572
- } catch (n) {
2573
- return n instanceof MaxPhpInstancesError ? PHPResponse.forHttpCode(502) : PHPResponse.forHttpCode(500);
1933
+ } catch (i) {
1934
+ return i instanceof MaxPhpInstancesError ? PHPResponse.forHttpCode(502) : PHPResponse.forHttpCode(500);
2574
1935
  }
2575
1936
  try {
2576
- return await h(this, Q, me).call(this, s.php, e, r);
1937
+ return await d(this, W, pe).call(this, s.php, e, r);
2577
1938
  } finally {
2578
1939
  s.reap();
2579
1940
  }
2580
- }, Q = new WeakSet(), me = async function(e, r, s) {
2581
- let n = "GET";
2582
- const i = {
2583
- host: u(this, H),
1941
+ }, W = new WeakSet(), pe = async function(e, r, s) {
1942
+ let i = "GET";
1943
+ const n = {
1944
+ host: c(this, S),
2584
1945
  ...normalizeHeaders(r.headers || {}),
2585
- cookie: u(this, k).getCookieRequestHeader()
1946
+ cookie: c(this, F).getCookieRequestHeader()
2586
1947
  };
2587
1948
  let o = r.body;
2588
1949
  if (typeof o == "object" && !(o instanceof Uint8Array)) {
2589
- n = "POST";
2590
- const { bytes: c, contentType: a } = await encodeAsMultipart(o);
2591
- o = c, i["content-type"] = a;
1950
+ i = "POST";
1951
+ const { bytes: l, contentType: a } = await encodeAsMultipart(o);
1952
+ o = l, n["content-type"] = a;
2592
1953
  }
2593
- let l;
1954
+ let p;
2594
1955
  try {
2595
- l = h(this, Z, _e).call(this, e, decodeURIComponent(s.pathname));
1956
+ p = d(this, G, ue).call(this, e, decodeURIComponent(s.pathname));
2596
1957
  } catch {
2597
1958
  return PHPResponse.forHttpCode(404);
2598
1959
  }
2599
1960
  try {
2600
- const c = await e.run({
1961
+ const l = await e.run({
2601
1962
  relativeUri: ensurePathPrefix(
2602
1963
  toRelativeUrl(s),
2603
- u(this, P)
1964
+ c(this, _)
2604
1965
  ),
2605
- protocol: u(this, F),
2606
- method: r.method || n,
1966
+ protocol: c(this, R),
1967
+ method: r.method || i,
2607
1968
  $_SERVER: {
2608
1969
  REMOTE_ADDR: "127.0.0.1",
2609
- DOCUMENT_ROOT: u(this, w),
2610
- HTTPS: u(this, T).startsWith("https://") ? "on" : ""
1970
+ DOCUMENT_ROOT: c(this, f),
1971
+ HTTPS: c(this, H).startsWith("https://") ? "on" : ""
2611
1972
  },
2612
1973
  body: o,
2613
- scriptPath: l,
2614
- headers: i
1974
+ scriptPath: p,
1975
+ headers: n
2615
1976
  });
2616
- return u(this, k).rememberCookiesFromResponseHeaders(
2617
- c.headers
2618
- ), c;
2619
- } catch (c) {
2620
- const a = c;
1977
+ return c(this, F).rememberCookiesFromResponseHeaders(
1978
+ l.headers
1979
+ ), l;
1980
+ } catch (l) {
1981
+ const a = l;
2621
1982
  if (a != null && a.response)
2622
1983
  return a.response;
2623
- throw c;
2624
- }
2625
- }, Z = new WeakSet(), _e = function(e, r) {
2626
- let s = removePathPrefix(r, u(this, P));
2627
- s = applyRewriteRules(s, this.rewriteRules), s.includes(".php") ? s = s.split(".php")[0] + ".php" : e.isDir(`${u(this, w)}${s}`) ? (s.endsWith("/") || (s = `${s}/`), s = `${s}index.php`) : s = "/index.php";
2628
- let n = `${u(this, w)}${s}`;
2629
- if (e.fileExists(n) || (n = `${u(this, w)}/index.php`), e.fileExists(n))
2630
- return n;
2631
- throw new Error(`File not found: ${n}`);
1984
+ throw l;
1985
+ }
1986
+ }, G = new WeakSet(), ue = function(e, r) {
1987
+ let s = removePathPrefix(r, c(this, _));
1988
+ s = applyRewriteRules(s, this.rewriteRules), s.includes(".php") ? s = s.split(".php")[0] + ".php" : e.isDir(`${c(this, f)}${s}`) ? (s.endsWith("/") || (s = `${s}/`), s = `${s}index.php`) : s = "/index.php";
1989
+ let i = `${c(this, f)}${s}`;
1990
+ if (e.fileExists(i) || (i = `${c(this, f)}/index.php`), e.fileExists(i))
1991
+ return i;
1992
+ throw new Error(`File not found: ${i}`);
2632
1993
  };
2633
1994
  function inferMimeType(t) {
2634
1995
  const e = t.split(".").pop();
@@ -2663,11 +2024,11 @@ function rotatePHPRuntime({
2663
2024
  */
2664
2025
  maxRequests: s = 400
2665
2026
  }) {
2666
- let n = 0;
2667
- async function i() {
2668
- if (++n < s)
2027
+ let i = 0;
2028
+ async function n() {
2029
+ if (++i < s)
2669
2030
  return;
2670
- n = 0;
2031
+ i = 0;
2671
2032
  const o = await t.semaphore.acquire();
2672
2033
  try {
2673
2034
  t.hotSwapPHPRuntime(await r(), e);
@@ -2675,29 +2036,29 @@ function rotatePHPRuntime({
2675
2036
  o();
2676
2037
  }
2677
2038
  }
2678
- return t.addEventListener("request.end", i), function() {
2679
- t.removeEventListener("request.end", i);
2039
+ return t.addEventListener("request.end", n), function() {
2040
+ t.removeEventListener("request.end", n);
2680
2041
  };
2681
2042
  }
2682
2043
  async function writeFiles(t, e, r, { rmRoot: s = !1 } = {}) {
2683
2044
  s && await t.isDir(e) && await t.rmdir(e, { recursive: !0 });
2684
- for (const [n, i] of Object.entries(r)) {
2685
- const o = joinPaths(e, n);
2686
- 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);
2045
+ for (const [i, n] of Object.entries(r)) {
2046
+ const o = joinPaths(e, i);
2047
+ await t.fileExists(dirname(o)) || await t.mkdir(dirname(o)), n instanceof Uint8Array || typeof n == "string" ? await t.writeFile(o, n) : await writeFiles(t, o, n);
2687
2048
  }
2688
2049
  }
2689
2050
  function proxyFileSystem(t, e, r) {
2690
2051
  const s = Object.getOwnPropertySymbols(t)[0];
2691
- for (const n of r)
2692
- e.fileExists(n) || e.mkdir(n), t.fileExists(n) || t.mkdir(n), e[s].FS.mount(
2052
+ for (const i of r)
2053
+ e.fileExists(i) || e.mkdir(i), t.fileExists(i) || t.mkdir(i), e[s].FS.mount(
2693
2054
  // @ts-ignore
2694
2055
  e[s].PROXYFS,
2695
2056
  {
2696
- root: n,
2057
+ root: i,
2697
2058
  // @ts-ignore
2698
2059
  fs: t[s].FS
2699
2060
  },
2700
- n
2061
+ i
2701
2062
  );
2702
2063
  }
2703
2064
  export {