@php-wasm/web 0.9.14 → 0.9.16

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 (2) hide show
  1. package/index.js +225 -1040
  2. package/package.json +7 -7
package/index.js CHANGED
@@ -1,776 +1,99 @@
1
- import "/home/runner/work/wordpress-playground/wordpress-playground/node_modules/ini/lib/ini.js";
2
- import * as m from "/home/runner/work/wordpress-playground/wordpress-playground/node_modules/comlink/dist/esm/comlink.mjs";
3
- const F = function() {
4
- var r;
5
- return typeof process < "u" && ((r = process.release) == null ? void 0 : r.name) === "node" ? "NODE" : typeof window < "u" ? "WEB" : (
6
- // @ts-ignore
7
- typeof WorkerGlobalScope < "u" && // @ts-ignore
8
- self instanceof WorkerGlobalScope ? "WORKER" : "NODE"
9
- );
10
- }();
11
- if (F === "NODE") {
12
- let r = function(t) {
13
- return new Promise(function(n, o) {
14
- t.onload = t.onerror = function(i) {
15
- t.onload = t.onerror = null, i.type === "load" ? n(t.result) : o(new Error("Failed to read the blob/file"));
16
- };
17
- });
18
- }, e = function() {
19
- const t = new Uint8Array([1, 2, 3, 4]), o = new File([t], "test").stream();
20
- try {
21
- return o.getReader({ mode: "byob" }), !0;
22
- } catch {
23
- return !1;
24
- }
25
- };
26
- if (typeof File > "u") {
27
- class t extends Blob {
28
- constructor(o, i, s) {
29
- super(o);
30
- let a;
31
- s != null && s.lastModified && (a = /* @__PURE__ */ new Date()), (!a || isNaN(a.getFullYear())) && (a = /* @__PURE__ */ new Date()), this.lastModifiedDate = a, this.lastModified = a.getMilliseconds(), this.name = i || "";
32
- }
33
- }
34
- global.File = t;
35
- }
36
- typeof Blob.prototype.arrayBuffer > "u" && (Blob.prototype.arrayBuffer = function() {
37
- const n = new FileReader();
38
- return n.readAsArrayBuffer(this), r(n);
39
- }), typeof Blob.prototype.text > "u" && (Blob.prototype.text = function() {
40
- const n = new FileReader();
41
- return n.readAsText(this), r(n);
42
- }), (typeof Blob.prototype.stream > "u" || !e()) && (Blob.prototype.stream = function() {
43
- let t = 0;
44
- const n = this;
45
- return new ReadableStream({
46
- type: "bytes",
47
- // 0.5 MB seems like a reasonable chunk size, let's adjust
48
- // this if needed.
49
- autoAllocateChunkSize: 512 * 1024,
50
- async pull(o) {
51
- const i = o.byobRequest.view, a = await n.slice(
52
- t,
53
- t + i.byteLength
54
- ).arrayBuffer(), c = new Uint8Array(a);
55
- new Uint8Array(i.buffer).set(c);
56
- const l = c.byteLength;
57
- o.byobRequest.respond(l), t += l, t >= n.size && o.close();
58
- }
59
- });
60
- });
61
- }
62
- if (F === "NODE" && typeof CustomEvent > "u") {
63
- class r extends Event {
64
- constructor(t, n = {}) {
65
- super(t, n), this.detail = n.detail;
66
- }
67
- initCustomEvent() {
68
- }
69
- }
70
- globalThis.CustomEvent = r;
71
- }
72
- const k = {
73
- 0: "No error occurred. System call completed successfully.",
74
- 1: "Argument list too long.",
75
- 2: "Permission denied.",
76
- 3: "Address in use.",
77
- 4: "Address not available.",
78
- 5: "Address family not supported.",
79
- 6: "Resource unavailable, or operation would block.",
80
- 7: "Connection already in progress.",
81
- 8: "Bad file descriptor.",
82
- 9: "Bad message.",
83
- 10: "Device or resource busy.",
84
- 11: "Operation canceled.",
85
- 12: "No child processes.",
86
- 13: "Connection aborted.",
87
- 14: "Connection refused.",
88
- 15: "Connection reset.",
89
- 16: "Resource deadlock would occur.",
90
- 17: "Destination address required.",
91
- 18: "Mathematics argument out of domain of function.",
92
- 19: "Reserved.",
93
- 20: "File exists.",
94
- 21: "Bad address.",
95
- 22: "File too large.",
96
- 23: "Host is unreachable.",
97
- 24: "Identifier removed.",
98
- 25: "Illegal byte sequence.",
99
- 26: "Operation in progress.",
100
- 27: "Interrupted function.",
101
- 28: "Invalid argument.",
102
- 29: "I/O error.",
103
- 30: "Socket is connected.",
104
- 31: "There is a directory under that path.",
105
- 32: "Too many levels of symbolic links.",
106
- 33: "File descriptor value too large.",
107
- 34: "Too many links.",
108
- 35: "Message too large.",
109
- 36: "Reserved.",
110
- 37: "Filename too long.",
111
- 38: "Network is down.",
112
- 39: "Connection aborted by network.",
113
- 40: "Network unreachable.",
114
- 41: "Too many files open in system.",
115
- 42: "No buffer space available.",
116
- 43: "No such device.",
117
- 44: "There is no such file or directory OR the parent directory does not exist.",
118
- 45: "Executable file format error.",
119
- 46: "No locks available.",
120
- 47: "Reserved.",
121
- 48: "Not enough space.",
122
- 49: "No message of the desired type.",
123
- 50: "Protocol not available.",
124
- 51: "No space left on device.",
125
- 52: "Function not supported.",
126
- 53: "The socket is not connected.",
127
- 54: "Not a directory or a symbolic link to a directory.",
128
- 55: "Directory not empty.",
129
- 56: "State not recoverable.",
130
- 57: "Not a socket.",
131
- 58: "Not supported, or operation not supported on socket.",
132
- 59: "Inappropriate I/O control operation.",
133
- 60: "No such device or address.",
134
- 61: "Value too large to be stored in data type.",
135
- 62: "Previous owner died.",
136
- 63: "Operation not permitted.",
137
- 64: "Broken pipe.",
138
- 65: "Protocol error.",
139
- 66: "Protocol not supported.",
140
- 67: "Protocol wrong type for socket.",
141
- 68: "Result too large.",
142
- 69: "Read-only file system.",
143
- 70: "Invalid seek.",
144
- 71: "No such process.",
145
- 72: "Reserved.",
146
- 73: "Connection timed out.",
147
- 74: "Text file busy.",
148
- 75: "Cross-device link.",
149
- 76: "Extension: Capabilities insufficient."
150
- };
151
- function j(r) {
152
- const e = typeof r == "object" ? r == null ? void 0 : r.errno : null;
153
- if (e in k)
154
- return k[e];
155
- }
156
- function y(r = "") {
157
- return function(t, n, o) {
158
- const i = o.value;
159
- o.value = function(...s) {
160
- try {
161
- return i.apply(this, s);
162
- } catch (a) {
163
- const c = typeof a == "object" ? a == null ? void 0 : a.errno : null;
164
- if (c in k) {
165
- const l = k[c], u = typeof s[1] == "string" ? s[1] : null, d = u !== null ? r.replaceAll("{path}", u) : r;
166
- throw new Error(`${d}: ${l}`, {
167
- cause: a
168
- });
169
- }
170
- throw a;
171
- }
172
- };
173
- };
174
- }
175
- const J = "playground-log", D = (r, ...e) => {
176
- E.dispatchEvent(
177
- new CustomEvent(J, {
178
- detail: {
179
- log: r,
180
- args: e
181
- }
182
- })
183
- );
184
- }, _ = (r, ...e) => {
185
- switch (typeof r.message == "string" ? r.message = R(r.message) : r.message.message && typeof r.message.message == "string" && (r.message.message = R(r.message.message)), r.severity) {
186
- case "Debug":
187
- console.debug(r.message, ...e);
188
- break;
189
- case "Info":
190
- console.info(r.message, ...e);
191
- break;
192
- case "Warn":
193
- console.warn(r.message, ...e);
194
- break;
195
- case "Error":
196
- console.error(r.message, ...e);
197
- break;
198
- case "Fatal":
199
- console.error(r.message, ...e);
200
- break;
201
- default:
202
- console.log(r.message, ...e);
203
- }
204
- }, G = (r) => r instanceof Error ? [r.message, r.stack].join(`
205
- `) : JSON.stringify(r, null, 2), M = [], O = (r) => {
206
- M.push(r);
207
- }, P = (r) => {
208
- if (r.raw === !0)
209
- O(r.message);
210
- else {
211
- const e = K(
212
- typeof r.message == "object" ? G(r.message) : r.message,
213
- r.severity ?? "Info",
214
- r.prefix ?? "JavaScript"
215
- );
216
- O(e);
217
- }
218
- };
219
- class U extends EventTarget {
220
- // constructor
221
- constructor(e = []) {
222
- super(), this.handlers = e, this.fatalErrorEvent = "playground-fatal-error";
223
- }
224
- /**
225
- * Get all logs.
226
- * @returns string[]
227
- */
228
- getLogs() {
229
- return this.handlers.includes(P) ? [...M] : (this.error(`Logs aren't stored because the logToMemory handler isn't registered.
230
- If you're using a custom logger instance, make sure to register logToMemory handler.
231
- `), []);
232
- }
233
- /**
234
- * Log message with severity.
235
- *
236
- * @param message any
237
- * @param severity LogSeverity
238
- * @param raw boolean
239
- * @param args any
240
- */
241
- logMessage(e, ...t) {
242
- for (const n of this.handlers)
243
- n(e, ...t);
244
- }
245
- /**
246
- * Log message
247
- *
248
- * @param message any
249
- * @param args any
250
- */
251
- log(e, ...t) {
252
- this.logMessage(
253
- {
254
- message: e,
255
- severity: void 0,
256
- prefix: "JavaScript",
257
- raw: !1
258
- },
259
- ...t
260
- );
261
- }
262
- /**
263
- * Log debug message
264
- *
265
- * @param message any
266
- * @param args any
267
- */
268
- debug(e, ...t) {
269
- this.logMessage(
270
- {
271
- message: e,
272
- severity: "Debug",
273
- prefix: "JavaScript",
274
- raw: !1
275
- },
276
- ...t
277
- );
278
- }
279
- /**
280
- * Log info message
281
- *
282
- * @param message any
283
- * @param args any
284
- */
285
- info(e, ...t) {
286
- this.logMessage(
287
- {
288
- message: e,
289
- severity: "Info",
290
- prefix: "JavaScript",
291
- raw: !1
292
- },
293
- ...t
294
- );
295
- }
296
- /**
297
- * Log warning message
298
- *
299
- * @param message any
300
- * @param args any
301
- */
302
- warn(e, ...t) {
303
- this.logMessage(
304
- {
305
- message: e,
306
- severity: "Warn",
307
- prefix: "JavaScript",
308
- raw: !1
309
- },
310
- ...t
311
- );
312
- }
313
- /**
314
- * Log error message
315
- *
316
- * @param message any
317
- * @param args any
318
- */
319
- error(e, ...t) {
320
- this.logMessage(
321
- {
322
- message: e,
323
- severity: "Error",
324
- prefix: "JavaScript",
325
- raw: !1
326
- },
327
- ...t
328
- );
329
- }
330
- }
331
- const V = () => {
332
- try {
333
- if (process.env.NODE_ENV === "test")
334
- return [P, D];
335
- } catch {
336
- }
337
- return [P, _, D];
338
- }, E = new U(V()), R = (r) => r.replace(/\t/g, ""), K = (r, e, t) => {
339
- const n = /* @__PURE__ */ new Date(), o = new Intl.DateTimeFormat("en-GB", {
340
- year: "numeric",
341
- month: "short",
342
- day: "2-digit",
343
- timeZone: "UTC"
344
- }).format(n).replace(/ /g, "-"), i = new Intl.DateTimeFormat("en-GB", {
345
- hour: "2-digit",
346
- minute: "2-digit",
347
- second: "2-digit",
348
- hour12: !1,
349
- timeZone: "UTC",
350
- timeZoneName: "short"
351
- }).format(n), s = o + " " + i;
352
- return r = R(r), `[${s}] ${t} ${e}: ${r}`;
353
- }, L = Symbol("SleepFinished");
354
- function Z(r) {
355
- return new Promise((e) => {
356
- setTimeout(() => e(L), r);
357
- });
358
- }
359
- class Q extends Error {
360
- constructor() {
361
- super("Acquiring lock timed out");
362
- }
363
- }
364
- class Y {
365
- constructor({ concurrency: e, timeout: t }) {
366
- this._running = 0, this.concurrency = e, this.timeout = t, this.queue = [];
367
- }
368
- get remaining() {
369
- return this.concurrency - this.running;
370
- }
371
- get running() {
372
- return this._running;
373
- }
374
- async acquire() {
375
- for (; ; )
376
- if (this._running >= this.concurrency) {
377
- const e = new Promise((t) => {
378
- this.queue.push(t);
379
- });
380
- this.timeout !== void 0 ? await Promise.race([e, Z(this.timeout)]).then(
381
- (t) => {
382
- if (t === L)
383
- throw new Q();
384
- }
385
- ) : await e;
386
- } else {
387
- this._running++;
388
- let e = !1;
389
- return () => {
390
- e || (e = !0, this._running--, this.queue.length > 0 && this.queue.shift()());
391
- };
392
- }
393
- }
394
- async run(e) {
395
- const t = await this.acquire();
396
- try {
397
- return await e();
398
- } finally {
399
- t();
400
- }
401
- }
402
- }
403
- class H extends Error {
404
- constructor(e, t) {
405
- super(e), this.userFriendlyMessage = t, this.userFriendlyMessage || (this.userFriendlyMessage = e);
406
- }
407
- }
408
- function g(...r) {
409
- let e = r.join("/");
410
- const t = e[0] === "/", n = e.substring(e.length - 1) === "/";
411
- return e = C(e), !e && !t && (e = "."), e && n && (e += "/"), e;
412
- }
413
- function X(r) {
414
- if (r === "/")
415
- return "/";
416
- r = C(r);
417
- const e = r.lastIndexOf("/");
418
- return e === -1 ? "" : e === 0 ? "/" : r.substr(0, e);
419
- }
420
- function ee(r) {
421
- if (r === "/")
422
- return "/";
423
- r = C(r);
424
- const e = r.lastIndexOf("/");
425
- return e === -1 ? r : r.substr(e + 1);
426
- }
427
- function C(r) {
428
- const e = r[0] === "/";
429
- return r = te(
430
- r.split("/").filter((t) => !!t),
431
- !e
432
- ).join("/"), (e ? "/" : "") + r.replace(/\/$/, "");
433
- }
434
- function te(r, e) {
435
- let t = 0;
436
- for (let n = r.length - 1; n >= 0; n--) {
437
- const o = r[n];
438
- o === "." ? r.splice(n, 1) : o === ".." ? (r.splice(n, 1), t++) : t && (r.splice(n, 1), t--);
439
- }
440
- if (e)
441
- for (; t; t--)
442
- r.unshift("..");
443
- return r;
444
- }
445
- var re = Object.defineProperty, ne = Object.getOwnPropertyDescriptor, h = (r, e, t, n) => {
446
- for (var o = n > 1 ? void 0 : n ? ne(e, t) : e, i = r.length - 1, s; i >= 0; i--)
447
- (s = r[i]) && (o = (n ? s(e, t, o) : s(o)) || o);
448
- return n && o && re(e, t, o), o;
449
- };
450
- const p = class f {
451
- static readFileAsText(e, t) {
452
- return new TextDecoder().decode(f.readFileAsBuffer(e, t));
453
- }
454
- static readFileAsBuffer(e, t) {
455
- return e.readFile(t);
456
- }
457
- static writeFile(e, t, n) {
458
- e.writeFile(t, n);
459
- }
460
- static unlink(e, t) {
461
- e.unlink(t);
462
- }
463
- /**
464
- * Moves a file or directory in the PHP filesystem to a
465
- * new location.
466
- *
467
- * @param oldPath The path to rename.
468
- * @param newPath The new path.
469
- */
470
- static mv(e, t, n) {
471
- try {
472
- const o = e.lookupPath(t).node.mount, i = f.fileExists(e, n) ? e.lookupPath(n).node.mount : e.lookupPath(X(n)).node.mount;
473
- o.mountpoint !== i.mountpoint ? (f.copyRecursive(e, t, n), f.rmdir(e, t, { recursive: !0 })) : e.rename(t, n);
474
- } catch (o) {
475
- const i = j(o);
476
- throw i ? new Error(
477
- `Could not move ${t} to ${n}: ${i}`,
478
- {
479
- cause: o
480
- }
481
- ) : o;
482
- }
483
- }
484
- static rmdir(e, t, n = { recursive: !0 }) {
485
- n != null && n.recursive && f.listFiles(e, t).forEach((o) => {
486
- const i = `${t}/${o}`;
487
- f.isDir(e, i) ? f.rmdir(e, i, n) : f.unlink(e, i);
488
- }), e.rmdir(t);
489
- }
490
- static listFiles(e, t, n = { prependPath: !1 }) {
491
- if (!f.fileExists(e, t))
492
- return [];
493
- try {
494
- const o = e.readdir(t).filter(
495
- (i) => i !== "." && i !== ".."
496
- );
497
- if (n.prependPath) {
498
- const i = t.replace(/\/$/, "");
499
- return o.map((s) => `${i}/${s}`);
500
- }
501
- return o;
502
- } catch (o) {
503
- return E.error(o, { path: t }), [];
504
- }
505
- }
506
- static isDir(e, t) {
507
- return f.fileExists(e, t) ? e.isDir(e.lookupPath(t).node.mode) : !1;
508
- }
509
- static fileExists(e, t) {
510
- try {
511
- return e.lookupPath(t), !0;
512
- } catch {
513
- return !1;
514
- }
515
- }
516
- static mkdir(e, t) {
517
- e.mkdirTree(t);
518
- }
519
- static copyRecursive(e, t, n) {
520
- const o = e.lookupPath(t).node;
521
- if (e.isDir(o.mode)) {
522
- e.mkdirTree(n);
523
- const i = e.readdir(t).filter(
524
- (s) => s !== "." && s !== ".."
525
- );
526
- for (const s of i)
527
- f.copyRecursive(
528
- e,
529
- g(t, s),
530
- g(n, s)
531
- );
532
- } else
533
- e.writeFile(n, e.readFile(t));
534
- }
535
- };
536
- h([
537
- y('Could not read "{path}"')
538
- ], p, "readFileAsText", 1);
539
- h([
540
- y('Could not read "{path}"')
541
- ], p, "readFileAsBuffer", 1);
542
- h([
543
- y('Could not write to "{path}"')
544
- ], p, "writeFile", 1);
545
- h([
546
- y('Could not unlink "{path}"')
547
- ], p, "unlink", 1);
548
- h([
549
- y('Could not remove directory "{path}"')
550
- ], p, "rmdir", 1);
551
- h([
552
- y('Could not list files in "{path}"')
553
- ], p, "listFiles", 1);
554
- h([
555
- y('Could not stat "{path}"')
556
- ], p, "isDir", 1);
557
- h([
558
- y('Could not stat "{path}"')
559
- ], p, "fileExists", 1);
560
- h([
561
- y('Could not create directory "{path}"')
562
- ], p, "mkdir", 1);
563
- h([
564
- y('Could not copy files from "{path}"')
565
- ], p, "copyRecursive", 1);
566
- let v = p;
567
- const oe = {
568
- 500: "Internal Server Error",
569
- 502: "Bad Gateway",
570
- 404: "Not Found",
571
- 403: "Forbidden",
572
- 401: "Unauthorized",
573
- 400: "Bad Request",
574
- 301: "Moved Permanently",
575
- 302: "Found",
576
- 307: "Temporary Redirect",
577
- 308: "Permanent Redirect",
578
- 204: "No Content",
579
- 201: "Created",
580
- 200: "OK"
581
- };
582
- class T {
583
- constructor(e, t, n, o = "", i = 0) {
584
- this.httpStatusCode = e, this.headers = t, this.bytes = n, this.exitCode = i, this.errors = o;
585
- }
586
- static forHttpCode(e, t = "") {
587
- return new T(
588
- e,
589
- {},
590
- new TextEncoder().encode(
591
- t || oe[e] || ""
592
- )
593
- );
594
- }
595
- static fromRawData(e) {
596
- return new T(
597
- e.httpStatusCode,
598
- e.headers,
599
- e.bytes,
600
- e.errors,
601
- e.exitCode
602
- );
603
- }
604
- toRawData() {
605
- return {
606
- headers: this.headers,
607
- bytes: this.bytes,
608
- errors: this.errors,
609
- exitCode: this.exitCode,
610
- httpStatusCode: this.httpStatusCode
611
- };
612
- }
613
- /**
614
- * Response body as JSON.
615
- */
616
- get json() {
617
- return JSON.parse(this.text);
618
- }
619
- /**
620
- * Response body as text.
621
- */
622
- get text() {
623
- return new TextDecoder().decode(this.bytes);
624
- }
625
- }
626
- const ie = Symbol("RuntimeId"), N = /* @__PURE__ */ new Map();
627
- let se = 0;
628
- async function ae(r, e = {}) {
629
- const [t, n, o] = ue(), i = r.init(ce, {
630
- onAbort(a) {
631
- o(a), E.error(a);
632
- },
633
- ENV: {},
634
- // Emscripten sometimes prepends a '/' to the path, which
635
- // breaks vite dev mode. An identity `locateFile` function
636
- // fixes it.
637
- locateFile: (a) => a,
638
- ...e,
639
- noInitialRun: !0,
640
- onRuntimeInitialized() {
641
- e.onRuntimeInitialized && e.onRuntimeInitialized(), n();
642
- }
643
- });
644
- await t;
645
- const s = ++se;
646
- return i.id = s, i.originalExit = i._exit, i._exit = function(a) {
647
- return N.delete(s), i.originalExit(a);
648
- }, i[ie] = s, N.set(s, i), s;
649
- }
650
- const ce = function() {
651
- var r;
652
- 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";
653
- }(), ue = () => {
654
- const r = [], e = new Promise((t, n) => {
655
- r.push(t, n);
656
- });
657
- return r.unshift(e), r;
658
- }, w = Symbol("__private__dont__use");
659
- ReadableStream.prototype[Symbol.asyncIterator] || (ReadableStream.prototype[Symbol.asyncIterator] = async function* () {
660
- const r = this.getReader();
661
- try {
662
- for (; ; ) {
663
- const { done: e, value: t } = await r.read();
664
- if (e)
665
- return;
666
- yield t;
667
- }
668
- } finally {
669
- r.releaseLock();
670
- }
671
- }, ReadableStream.prototype.iterate = // @ts-ignore
672
- ReadableStream.prototype[Symbol.asyncIterator]);
673
- const le = [
674
- "8.3",
675
- "8.2",
676
- "8.1",
677
- "8.0",
678
- "7.4",
679
- "7.3",
680
- "7.2",
681
- "7.1",
682
- "7.0"
683
- ], de = le[0];
684
- function Re(r, e = void 0) {
685
- B();
686
- const t = r instanceof Worker ? r : m.windowEndpoint(r, e), n = m.wrap(t), o = x(n);
687
- return new Proxy(o, {
1
+ import { PHPResponse as C, LatestSupportedPHPVersion as O, loadPHPRuntime as R, FSHelpers as w, __private__dont__use as y } from "@php-wasm/universal";
2
+ import * as d from "comlink";
3
+ import { PhpWasmError as g, Semaphore as v, joinPaths as T } from "@php-wasm/util";
4
+ import { responseTo as L } from "@php-wasm/web-service-worker";
5
+ import { logger as p } from "@php-wasm/logger";
6
+ import { journalFSEvents as S } from "@php-wasm/fs-journal";
7
+ function B(r, t = void 0) {
8
+ W();
9
+ const e = r instanceof Worker ? r : d.windowEndpoint(r, t), a = d.wrap(e), n = h(a);
10
+ return new Proxy(n, {
688
11
  get: (i, s) => s === "isConnected" ? async () => {
689
12
  for (; ; )
690
13
  try {
691
- await fe(n.isConnected(), 200);
14
+ await z(a.isConnected(), 200);
692
15
  break;
693
16
  } catch {
694
17
  }
695
- } : n[s]
18
+ } : a[s]
696
19
  });
697
20
  }
698
- async function fe(r, e) {
699
- return new Promise((t, n) => {
700
- setTimeout(n, e), r.then(t);
21
+ async function z(r, t) {
22
+ return new Promise((e, a) => {
23
+ setTimeout(a, t), r.then(e);
701
24
  });
702
25
  }
703
- function Ce(r, e) {
704
- B();
705
- const t = Promise.resolve();
706
- let n, o;
707
- const i = new Promise((c, l) => {
708
- n = c, o = l;
709
- }), s = x(r), a = new Proxy(s, {
710
- get: (c, l) => l === "isConnected" ? () => t : l === "isReady" ? () => i : l in c ? c[l] : e == null ? void 0 : e[l]
26
+ function Q(r, t) {
27
+ W();
28
+ const e = Promise.resolve();
29
+ let a, n;
30
+ const i = new Promise((o, u) => {
31
+ a = o, n = u;
32
+ }), s = h(r), c = new Proxy(s, {
33
+ get: (o, u) => u === "isConnected" ? () => e : u === "isReady" ? () => i : u in o ? o[u] : t == null ? void 0 : t[u]
711
34
  });
712
- return m.expose(
713
- a,
714
- typeof window < "u" ? m.windowEndpoint(self.parent) : void 0
715
- ), [n, o, a];
716
- }
717
- let W = !1;
718
- function B() {
719
- if (W)
35
+ return d.expose(
36
+ c,
37
+ typeof window < "u" ? d.windowEndpoint(self.parent) : void 0
38
+ ), [a, n, c];
39
+ }
40
+ let P = !1;
41
+ function W() {
42
+ if (P)
720
43
  return;
721
- W = !0, m.transferHandlers.set("EVENT", {
722
- canHandle: (t) => t instanceof CustomEvent,
723
- serialize: (t) => [
44
+ P = !0, d.transferHandlers.set("EVENT", {
45
+ canHandle: (e) => e instanceof CustomEvent,
46
+ serialize: (e) => [
724
47
  {
725
- detail: t.detail
48
+ detail: e.detail
726
49
  },
727
50
  []
728
51
  ],
729
- deserialize: (t) => t
730
- }), m.transferHandlers.set("FUNCTION", {
731
- canHandle: (t) => typeof t == "function",
732
- serialize(t) {
733
- const { port1: n, port2: o } = new MessageChannel();
734
- return m.expose(t, n), [o, [o]];
52
+ deserialize: (e) => e
53
+ }), d.transferHandlers.set("FUNCTION", {
54
+ canHandle: (e) => typeof e == "function",
55
+ serialize(e) {
56
+ const { port1: a, port2: n } = new MessageChannel();
57
+ return d.expose(e, a), [n, [n]];
735
58
  },
736
- deserialize(t) {
737
- return t.start(), m.wrap(t);
59
+ deserialize(e) {
60
+ return e.start(), d.wrap(e);
738
61
  }
739
- }), m.transferHandlers.set("PHPResponse", {
740
- canHandle: (t) => typeof t == "object" && t !== null && "headers" in t && "bytes" in t && "errors" in t && "exitCode" in t && "httpStatusCode" in t,
741
- serialize(t) {
742
- return [t.toRawData(), []];
62
+ }), d.transferHandlers.set("PHPResponse", {
63
+ canHandle: (e) => typeof e == "object" && e !== null && "headers" in e && "bytes" in e && "errors" in e && "exitCode" in e && "httpStatusCode" in e,
64
+ serialize(e) {
65
+ return [e.toRawData(), []];
743
66
  },
744
- deserialize(t) {
745
- return T.fromRawData(t);
67
+ deserialize(e) {
68
+ return C.fromRawData(e);
746
69
  }
747
70
  });
748
- const r = m.transferHandlers.get("throw"), e = r == null ? void 0 : r.serialize;
749
- r.serialize = ({ value: t }) => {
750
- const n = e({ value: t });
751
- return t.response && (n[0].value.response = t.response), t.source && (n[0].value.source = t.source), n;
71
+ const r = d.transferHandlers.get("throw"), t = r == null ? void 0 : r.serialize;
72
+ r.serialize = ({ value: e }) => {
73
+ const a = t({ value: e });
74
+ return e.response && (a[0].value.response = e.response), e.source && (a[0].value.source = e.source), a;
752
75
  };
753
76
  }
754
- function x(r) {
77
+ function h(r) {
755
78
  return new Proxy(r, {
756
- get(e, t) {
757
- switch (typeof e[t]) {
79
+ get(t, e) {
80
+ switch (typeof t[e]) {
758
81
  case "function":
759
- return (...n) => e[t](...n);
82
+ return (...a) => t[e](...a);
760
83
  case "object":
761
- return e[t] === null ? e[t] : x(e[t]);
84
+ return t[e] === null ? t[e] : h(t[e]);
762
85
  case "undefined":
763
86
  case "number":
764
87
  case "string":
765
- return e[t];
88
+ return t[e];
766
89
  default:
767
- return m.proxy(e[t]);
90
+ return d.proxy(t[e]);
768
91
  }
769
92
  }
770
93
  });
771
94
  }
772
- async function me(r = de, e = "light") {
773
- if (e === "kitchen-sink")
95
+ async function D(r = O, t = "light") {
96
+ if (t === "kitchen-sink")
774
97
  switch (r) {
775
98
  case "8.3":
776
99
  return await import("./kitchen-sink/php_8_3.js");
@@ -814,7 +137,7 @@ async function me(r = de, e = "light") {
814
137
  }
815
138
  throw new Error(`Unsupported PHP version ${r}`);
816
139
  }
817
- const pe = () => ({
140
+ const M = () => ({
818
141
  websocket: {
819
142
  decorator: (r) => class extends r {
820
143
  constructor() {
@@ -829,310 +152,172 @@ const pe = () => ({
829
152
  }
830
153
  }
831
154
  });
832
- async function De(r, e = {}) {
833
- var o;
834
- const t = e.loadAllExtensions ? "kitchen-sink" : "light", n = await me(r, t);
835
- return (o = e.onPhpLoaderModuleLoaded) == null || o.call(e, n), await ae(n, {
836
- ...e.emscriptenOptions || {},
837
- ...pe()
155
+ async function G(r, t = {}) {
156
+ var n;
157
+ const e = t.loadAllExtensions ? "kitchen-sink" : "light", a = await D(r, e);
158
+ return (n = t.onPhpLoaderModuleLoaded) == null || n.call(t, a), await R(a, {
159
+ ...t.emscriptenOptions || {},
160
+ ...M()
838
161
  });
839
162
  }
840
- function ye(r, e) {
841
- return {
842
- type: "response",
843
- requestId: r,
844
- response: e
845
- };
846
- }
847
- async function Oe(r, e, t) {
848
- const n = navigator.serviceWorker;
849
- if (!n)
850
- throw window.isSecureContext ? new H(
163
+ async function K(r, t, e) {
164
+ const a = navigator.serviceWorker;
165
+ if (!a)
166
+ throw window.isSecureContext ? new g(
851
167
  "Service workers are not supported in your browser."
852
- ) : new H(
168
+ ) : new g(
853
169
  "WordPress Playground uses service workers and may only work on HTTPS and http://localhost/ sites, but the current site is neither."
854
170
  );
855
- await (await n.register(t, {
171
+ await (await a.register(e, {
856
172
  type: "module",
857
173
  // Always bypass HTTP cache when fetching the new Service Worker script:
858
174
  updateViaCache: "none"
859
175
  })).update(), navigator.serviceWorker.addEventListener(
860
176
  "message",
861
177
  async function(s) {
862
- if (e && s.data.scope !== e)
178
+ if (t && s.data.scope !== t)
863
179
  return;
864
- const a = s.data.args || [], c = s.data.method, l = await r[c](...a);
865
- s.source.postMessage(ye(s.data.requestId, l));
180
+ const c = s.data.args || [], o = s.data.method, u = await r[o](...c);
181
+ s.source.postMessage(L(s.data.requestId, u));
866
182
  }
867
- ), n.startMessages();
868
- }
869
- function He(r, e) {
870
- window.addEventListener("message", (t) => {
871
- t.source === r.contentWindow && (e && t.origin !== e || typeof t.data != "object" || t.data.type !== "relay" || window.parent.postMessage(t.data, "*"));
872
- }), window.addEventListener("message", (t) => {
873
- var n;
874
- t.source === window.parent && (typeof t.data != "object" || t.data.type !== "relay" || (n = r == null ? void 0 : r.contentWindow) == null || n.postMessage(t.data));
183
+ ), a.startMessages();
184
+ }
185
+ function X(r, t) {
186
+ window.addEventListener("message", (e) => {
187
+ e.source === r.contentWindow && (t && e.origin !== t || typeof e.data != "object" || e.data.type !== "relay" || window.parent.postMessage(e.data, "*"));
188
+ }), window.addEventListener("message", (e) => {
189
+ var a;
190
+ e.source === window.parent && (typeof e.data != "object" || e.data.type !== "relay" || (a = r == null ? void 0 : r.contentWindow) == null || a.postMessage(e.data));
875
191
  });
876
192
  }
877
- async function Ne(r, e = {}) {
878
- r = he(r, e);
879
- const t = new Worker(r, { type: "module" });
880
- return new Promise((n, o) => {
881
- t.onerror = (s) => {
882
- const a = new Error(
193
+ async function Y(r, t = {}) {
194
+ r = A(r, t);
195
+ const e = new Worker(r, { type: "module" });
196
+ return new Promise((a, n) => {
197
+ e.onerror = (s) => {
198
+ const c = new Error(
883
199
  `WebWorker failed to load at ${r}. ${s.message ? `Original error: ${s.message}` : ""}`
884
200
  );
885
- a.filename = s.filename, o(a);
201
+ c.filename = s.filename, n(c);
886
202
  };
887
203
  function i(s) {
888
- s.data === "worker-script-started" && (n(t), t.removeEventListener("message", i));
204
+ s.data === "worker-script-started" && (a(e), e.removeEventListener("message", i));
889
205
  }
890
- t.addEventListener("message", i);
206
+ e.addEventListener("message", i);
891
207
  });
892
208
  }
893
- function he(r, e) {
894
- if (!Object.entries(e).length)
209
+ function A(r, t) {
210
+ if (!Object.entries(t).length)
895
211
  return r + "";
896
- const t = new URL(r);
897
- for (const [n, o] of Object.entries(e))
898
- if (Array.isArray(o))
899
- for (const i of o)
900
- t.searchParams.append(n, i);
212
+ const e = new URL(r);
213
+ for (const [a, n] of Object.entries(t))
214
+ if (Array.isArray(n))
215
+ for (const i of n)
216
+ e.searchParams.append(a, i);
901
217
  else
902
- t.searchParams.set(n, o);
903
- return t.toString();
904
- }
905
- function we(r, e, t = () => {
906
- }) {
907
- function n() {
908
- e = be(e);
909
- const i = r[w].FS, s = ge(i, (u) => {
910
- if (u.path.startsWith(e))
911
- t(u);
912
- else if (u.operation === "RENAME" && u.toPath.startsWith(e))
913
- for (const d of $(
914
- r,
915
- u.path,
916
- u.toPath
917
- ))
918
- t(d);
919
- }), a = {};
920
- for (const [u] of Object.entries(s))
921
- a[u] = i[u];
922
- function c() {
923
- for (const [u, d] of Object.entries(s))
924
- i[u] = function(...b) {
925
- return d(...b), a[u].apply(this, b);
926
- };
927
- }
928
- function l() {
929
- for (const [u, d] of Object.entries(a))
930
- r[w].FS[u] = d;
931
- }
932
- r[w].journal = {
933
- bind: c,
934
- unbind: l
935
- }, c();
936
- }
937
- r.addEventListener("runtime.initialized", n), r[w] && n();
938
- function o() {
939
- r[w].journal.unbind(), delete r[w].journal;
940
- }
941
- return r.addEventListener("runtime.beforedestroy", o), function() {
942
- return r.removeEventListener("runtime.initialized", n), r.removeEventListener("runtime.beforedestroy", o), r[w].journal.unbind();
943
- };
944
- }
945
- const ge = (r, e = () => {
946
- }) => ({
947
- write(t) {
948
- e({
949
- operation: "WRITE",
950
- path: t.path,
951
- nodeType: "file"
952
- });
953
- },
954
- truncate(t) {
955
- let n;
956
- typeof t == "string" ? n = r.lookupPath(t, {
957
- follow: !0
958
- }).node : n = t, e({
959
- operation: "WRITE",
960
- path: r.getPath(n),
961
- nodeType: "file"
962
- });
963
- },
964
- unlink(t) {
965
- e({
966
- operation: "DELETE",
967
- path: t,
968
- nodeType: "file"
969
- });
970
- },
971
- mknod(t, n) {
972
- r.isFile(n) && e({
973
- operation: "CREATE",
974
- path: t,
975
- nodeType: "file"
976
- });
977
- },
978
- mkdir(t) {
979
- e({
980
- operation: "CREATE",
981
- path: t,
982
- nodeType: "directory"
983
- });
984
- },
985
- rmdir(t) {
986
- e({
987
- operation: "DELETE",
988
- path: t,
989
- nodeType: "directory"
990
- });
991
- },
992
- rename(t, n) {
993
- try {
994
- const o = r.lookupPath(t, {
995
- follow: !0
996
- }), i = r.lookupPath(n, {
997
- parent: !0
998
- }).path;
999
- e({
1000
- operation: "RENAME",
1001
- nodeType: r.isDir(o.node.mode) ? "directory" : "file",
1002
- path: o.path,
1003
- toPath: g(i, ee(n))
1004
- });
1005
- } catch {
1006
- }
1007
- }
1008
- });
1009
- function* $(r, e, t) {
1010
- if (r.isDir(e)) {
1011
- yield {
1012
- operation: "CREATE",
1013
- path: t,
1014
- nodeType: "directory"
1015
- };
1016
- for (const n of r.listFiles(e))
1017
- yield* $(
1018
- r,
1019
- g(e, n),
1020
- g(t, n)
1021
- );
1022
- } else
1023
- yield {
1024
- operation: "CREATE",
1025
- path: t,
1026
- nodeType: "file"
1027
- }, yield {
1028
- operation: "WRITE",
1029
- nodeType: "file",
1030
- path: t
1031
- };
218
+ e.searchParams.set(a, n);
219
+ return e.toString();
1032
220
  }
1033
- function be(r) {
1034
- return r.replace(/\/$/, "").replace(/\/\/+/g, "/");
1035
- }
1036
- function We(r, e = { initialSync: {} }) {
1037
- return e = {
1038
- ...e,
221
+ function Z(r, t = { initialSync: {} }) {
222
+ return t = {
223
+ ...t,
1039
224
  initialSync: {
1040
- ...e.initialSync,
1041
- direction: e.initialSync.direction ?? "opfs-to-memfs"
225
+ ...t.initialSync,
226
+ direction: t.initialSync.direction ?? "opfs-to-memfs"
1042
227
  }
1043
- }, async function(t, n, o) {
1044
- return e.initialSync.direction === "opfs-to-memfs" ? (v.fileExists(n, o) && v.rmdir(n, o), v.mkdir(n, o), await Ee(n, r, o)) : await z(
1045
- n,
228
+ }, async function(e, a, n) {
229
+ return t.initialSync.direction === "opfs-to-memfs" ? (w.fileExists(a, n) && w.rmdir(a, n), w.mkdir(a, n), await I(a, r, n)) : await b(
230
+ a,
1046
231
  r,
1047
- o,
1048
- e.initialSync.onProgress
1049
- ), ke(t, r, o);
232
+ n,
233
+ t.initialSync.onProgress
234
+ ), $(e, r, n);
1050
235
  };
1051
236
  }
1052
- async function Ee(r, e, t) {
1053
- v.mkdir(r, t);
1054
- const n = new Y({
237
+ async function I(r, t, e) {
238
+ w.mkdir(r, e);
239
+ const a = new v({
1055
240
  concurrency: 40
1056
- }), o = [], i = [
1057
- [e, t]
241
+ }), n = [], i = [
242
+ [t, e]
1058
243
  ];
1059
244
  for (; i.length > 0; ) {
1060
- const [s, a] = i.pop();
1061
- for await (const c of s.values()) {
1062
- const l = n.run(async () => {
1063
- const u = g(
1064
- a,
1065
- c.name
245
+ const [s, c] = i.pop();
246
+ for await (const o of s.values()) {
247
+ const u = a.run(async () => {
248
+ const l = T(
249
+ c,
250
+ o.name
1066
251
  );
1067
- if (c.kind === "directory") {
252
+ if (o.kind === "directory") {
1068
253
  try {
1069
- r.mkdir(u);
1070
- } catch (d) {
1071
- if ((d == null ? void 0 : d.errno) !== 20)
1072
- throw E.error(d), d;
254
+ r.mkdir(l);
255
+ } catch (f) {
256
+ if ((f == null ? void 0 : f.errno) !== 20)
257
+ throw p.error(f), f;
1073
258
  }
1074
- i.push([c, u]);
1075
- } else if (c.kind === "file") {
1076
- const d = await c.getFile(), b = new Uint8Array(await d.arrayBuffer());
259
+ i.push([o, l]);
260
+ } else if (o.kind === "file") {
261
+ const f = await o.getFile(), m = new Uint8Array(await f.arrayBuffer());
1077
262
  r.createDataFile(
1078
- a,
1079
- c.name,
1080
- b,
263
+ c,
264
+ o.name,
265
+ m,
1081
266
  !0,
1082
267
  !0,
1083
268
  !0
1084
269
  );
1085
270
  }
1086
- o.splice(o.indexOf(l), 1);
271
+ n.splice(n.indexOf(u), 1);
1087
272
  });
1088
- o.push(l);
273
+ n.push(u);
1089
274
  }
1090
- for (; i.length === 0 && o.length > 0; )
1091
- await Promise.any(o);
275
+ for (; i.length === 0 && n.length > 0; )
276
+ await Promise.any(n);
1092
277
  }
1093
278
  }
1094
- async function z(r, e, t, n) {
1095
- r.mkdirTree(t);
1096
- const o = [];
1097
- async function i(c, l) {
279
+ async function b(r, t, e, a) {
280
+ r.mkdirTree(e);
281
+ const n = [];
282
+ async function i(o, u) {
1098
283
  await Promise.all(
1099
- r.readdir(c).filter(
1100
- (u) => u !== "." && u !== ".."
1101
- ).map(async (u) => {
1102
- const d = g(c, u);
1103
- if (!ve(r, d)) {
1104
- o.push([l, d, u]);
284
+ r.readdir(o).filter(
285
+ (l) => l !== "." && l !== ".."
286
+ ).map(async (l) => {
287
+ const f = T(o, l);
288
+ if (!_(r, f)) {
289
+ n.push([u, f, l]);
1105
290
  return;
1106
291
  }
1107
- const b = await l.getDirectoryHandle(u, {
292
+ const m = await u.getDirectoryHandle(l, {
1108
293
  create: !0
1109
294
  });
1110
- return await i(d, b);
295
+ return await i(f, m);
1111
296
  })
1112
297
  );
1113
298
  }
1114
- await i(t, e);
299
+ await i(e, t);
1115
300
  let s = 0;
1116
- const a = o.map(
1117
- ([c, l, u]) => q(c, u, r, l).then(() => {
1118
- n == null || n({ files: ++s, total: o.length });
301
+ const c = n.map(
302
+ ([o, u, l]) => x(o, l, r, u).then(() => {
303
+ a == null || a({ files: ++s, total: n.length });
1119
304
  })
1120
305
  );
1121
- await Promise.all(a);
306
+ await Promise.all(c);
1122
307
  }
1123
- function ve(r, e) {
1124
- return r.isDir(r.lookupPath(e, { follow: !0 }).node.mode);
308
+ function _(r, t) {
309
+ return r.isDir(r.lookupPath(t, { follow: !0 }).node.mode);
1125
310
  }
1126
- async function q(r, e, t, n) {
1127
- let o;
311
+ async function x(r, t, e, a) {
312
+ let n;
1128
313
  try {
1129
- o = t.readFile(n, {
314
+ n = e.readFile(a, {
1130
315
  encoding: "binary"
1131
316
  });
1132
317
  } catch {
1133
318
  return;
1134
319
  }
1135
- const i = await r.getFileHandle(e, { create: !0 }), s = i.createWritable !== void 0 ? (
320
+ const i = await r.getFileHandle(t, { create: !0 }), s = i.createWritable !== void 0 ? (
1136
321
  // Google Chrome, Firefox, probably more browsers
1137
322
  await i.createWritable()
1138
323
  ) : (
@@ -1140,113 +325,113 @@ async function q(r, e, t, n) {
1140
325
  await i.createSyncAccessHandle()
1141
326
  );
1142
327
  try {
1143
- await s.truncate(0), await s.write(o);
328
+ await s.truncate(0), await s.write(n);
1144
329
  } finally {
1145
330
  await s.close();
1146
331
  }
1147
332
  }
1148
- function ke(r, e, t) {
1149
- const n = [], o = we(r, t, (a) => {
1150
- n.push(a);
1151
- }), i = new Te(r, e, t);
333
+ function $(r, t, e) {
334
+ const a = [], n = S(r, e, (c) => {
335
+ a.push(c);
336
+ }), i = new j(r, t, e);
1152
337
  async function s() {
1153
- const a = await r.semaphore.acquire();
338
+ const c = await r.semaphore.acquire();
1154
339
  try {
1155
- for (; n.length; )
1156
- await i.processEntry(n.shift());
340
+ for (; a.length; )
341
+ await i.processEntry(a.shift());
1157
342
  } finally {
1158
- a();
343
+ c();
1159
344
  }
1160
345
  }
1161
346
  return r.addEventListener("request.end", s), function() {
1162
- o(), r.removeEventListener("request.end", s);
347
+ n(), r.removeEventListener("request.end", s);
1163
348
  };
1164
349
  }
1165
- class Te {
1166
- constructor(e, t, n) {
1167
- this.php = e, this.opfs = t, this.memfsRoot = I(n);
350
+ class j {
351
+ constructor(t, e, a) {
352
+ this.php = t, this.opfs = e, this.memfsRoot = E(a);
1168
353
  }
1169
- toOpfsPath(e) {
1170
- return I(e.substring(this.memfsRoot.length));
354
+ toOpfsPath(t) {
355
+ return E(t.substring(this.memfsRoot.length));
1171
356
  }
1172
- async processEntry(e) {
1173
- if (!e.path.startsWith(this.memfsRoot) || e.path === this.memfsRoot)
357
+ async processEntry(t) {
358
+ if (!t.path.startsWith(this.memfsRoot) || t.path === this.memfsRoot)
1174
359
  return;
1175
- const t = this.toOpfsPath(e.path), n = await A(this.opfs, t), o = S(t);
1176
- if (o)
360
+ const e = this.toOpfsPath(t.path), a = await H(this.opfs, e), n = k(e);
361
+ if (n)
1177
362
  try {
1178
- if (e.operation === "DELETE")
363
+ if (t.operation === "DELETE")
1179
364
  try {
1180
- await n.removeEntry(o, {
365
+ await a.removeEntry(n, {
1181
366
  recursive: !0
1182
367
  });
1183
368
  } catch {
1184
369
  }
1185
- else if (e.operation === "CREATE")
1186
- e.nodeType === "directory" ? await n.getDirectoryHandle(o, {
370
+ else if (t.operation === "CREATE")
371
+ t.nodeType === "directory" ? await a.getDirectoryHandle(n, {
1187
372
  create: !0
1188
- }) : await n.getFileHandle(o, {
373
+ }) : await a.getFileHandle(n, {
1189
374
  create: !0
1190
375
  });
1191
- else if (e.operation === "WRITE")
1192
- await q(
376
+ else if (t.operation === "WRITE")
377
+ await x(
378
+ a,
1193
379
  n,
1194
- o,
1195
- this.php[w].FS,
1196
- e.path
380
+ this.php[y].FS,
381
+ t.path
1197
382
  );
1198
- else if (e.operation === "RENAME" && e.toPath.startsWith(this.memfsRoot)) {
1199
- const i = this.toOpfsPath(e.toPath), s = await A(
383
+ else if (t.operation === "RENAME" && t.toPath.startsWith(this.memfsRoot)) {
384
+ const i = this.toOpfsPath(t.toPath), s = await H(
1200
385
  this.opfs,
1201
386
  i
1202
- ), a = S(i);
1203
- if (e.nodeType === "directory") {
1204
- const c = await s.getDirectoryHandle(
1205
- o,
387
+ ), c = k(i);
388
+ if (t.nodeType === "directory") {
389
+ const o = await s.getDirectoryHandle(
390
+ n,
1206
391
  {
1207
392
  create: !0
1208
393
  }
1209
394
  );
1210
- await z(
1211
- this.php[w].FS,
1212
- c,
1213
- e.toPath
1214
- ), await n.removeEntry(o, {
395
+ await b(
396
+ this.php[y].FS,
397
+ o,
398
+ t.toPath
399
+ ), await a.removeEntry(n, {
1215
400
  recursive: !0
1216
401
  });
1217
402
  } else
1218
- (await n.getFileHandle(o)).move(s, a);
403
+ (await a.getFileHandle(n)).move(s, c);
1219
404
  }
1220
405
  } catch (i) {
1221
- throw E.log({ entry: e, name: o }), E.error(i), i;
406
+ throw p.log({ entry: t, name: n }), p.error(i), i;
1222
407
  }
1223
408
  }
1224
409
  }
1225
- function I(r) {
410
+ function E(r) {
1226
411
  return r.replace(/\/$/, "").replace(/\/\/+/g, "/");
1227
412
  }
1228
- function S(r) {
413
+ function k(r) {
1229
414
  return r.substring(r.lastIndexOf("/") + 1);
1230
415
  }
1231
- async function A(r, e) {
1232
- const t = e.replace(/^\/+|\/+$/g, "").replace(/\/+/, "/");
1233
- if (!t)
416
+ async function H(r, t) {
417
+ const e = t.replace(/^\/+|\/+$/g, "").replace(/\/+/, "/");
418
+ if (!e)
1234
419
  return r;
1235
- const n = t.split("/");
1236
- let o = r;
1237
- for (let i = 0; i < n.length - 1; i++) {
1238
- const s = n[i];
1239
- o = await o.getDirectoryHandle(s, { create: !0 });
420
+ const a = e.split("/");
421
+ let n = r;
422
+ for (let i = 0; i < a.length - 1; i++) {
423
+ const s = a[i];
424
+ n = await n.getDirectoryHandle(s, { create: !0 });
1240
425
  }
1241
- return o;
426
+ return n;
1242
427
  }
1243
428
  export {
1244
- Re as consumeAPI,
1245
- We as createDirectoryHandleMountHandler,
1246
- Ce as exposeAPI,
1247
- me as getPHPLoaderModule,
1248
- De as loadWebRuntime,
1249
- Oe as registerServiceWorker,
1250
- He as setupPostMessageRelay,
1251
- Ne as spawnPHPWorkerThread
429
+ B as consumeAPI,
430
+ Z as createDirectoryHandleMountHandler,
431
+ Q as exposeAPI,
432
+ D as getPHPLoaderModule,
433
+ G as loadWebRuntime,
434
+ K as registerServiceWorker,
435
+ X as setupPostMessageRelay,
436
+ Y as spawnPHPWorkerThread
1252
437
  };