@php-wasm/web 0.9.13 → 0.9.14

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 +542 -784
  2. package/package.json +7 -7
package/index.js CHANGED
@@ -1,73 +1,75 @@
1
- const K = function() {
2
- var e;
3
- return typeof process < "u" && ((e = process.release) == null ? void 0 : e.name) === "node" ? "NODE" : typeof window < "u" ? "WEB" : (
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" : (
4
6
  // @ts-ignore
5
7
  typeof WorkerGlobalScope < "u" && // @ts-ignore
6
8
  self instanceof WorkerGlobalScope ? "WORKER" : "NODE"
7
9
  );
8
10
  }();
9
- if (K === "NODE") {
10
- let e = function(r) {
11
- return new Promise(function(n, s) {
12
- r.onload = r.onerror = function(o) {
13
- r.onload = r.onerror = null, o.type === "load" ? n(r.result) : s(new Error("Failed to read the blob/file"));
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"));
14
16
  };
15
17
  });
16
- }, t = function() {
17
- const r = new Uint8Array([1, 2, 3, 4]), s = new File([r], "test").stream();
18
+ }, e = function() {
19
+ const t = new Uint8Array([1, 2, 3, 4]), o = new File([t], "test").stream();
18
20
  try {
19
- return s.getReader({ mode: "byob" }), !0;
21
+ return o.getReader({ mode: "byob" }), !0;
20
22
  } catch {
21
23
  return !1;
22
24
  }
23
25
  };
24
26
  if (typeof File > "u") {
25
- class r extends Blob {
26
- constructor(s, o, i) {
27
- super(s);
27
+ class t extends Blob {
28
+ constructor(o, i, s) {
29
+ super(o);
28
30
  let a;
29
- i != null && i.lastModified && (a = /* @__PURE__ */ new Date()), (!a || isNaN(a.getFullYear())) && (a = /* @__PURE__ */ new Date()), this.lastModifiedDate = a, this.lastModified = a.getMilliseconds(), this.name = o || "";
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 || "";
30
32
  }
31
33
  }
32
- global.File = r;
34
+ global.File = t;
33
35
  }
34
36
  typeof Blob.prototype.arrayBuffer > "u" && (Blob.prototype.arrayBuffer = function() {
35
37
  const n = new FileReader();
36
- return n.readAsArrayBuffer(this), e(n);
38
+ return n.readAsArrayBuffer(this), r(n);
37
39
  }), typeof Blob.prototype.text > "u" && (Blob.prototype.text = function() {
38
40
  const n = new FileReader();
39
- return n.readAsText(this), e(n);
40
- }), (typeof Blob.prototype.stream > "u" || !t()) && (Blob.prototype.stream = function() {
41
- let r = 0;
41
+ return n.readAsText(this), r(n);
42
+ }), (typeof Blob.prototype.stream > "u" || !e()) && (Blob.prototype.stream = function() {
43
+ let t = 0;
42
44
  const n = this;
43
45
  return new ReadableStream({
44
46
  type: "bytes",
45
47
  // 0.5 MB seems like a reasonable chunk size, let's adjust
46
48
  // this if needed.
47
49
  autoAllocateChunkSize: 512 * 1024,
48
- async pull(s) {
49
- const o = s.byobRequest.view, a = await n.slice(
50
- r,
51
- r + o.byteLength
52
- ).arrayBuffer(), u = new Uint8Array(a);
53
- new Uint8Array(o.buffer).set(u);
54
- const l = u.byteLength;
55
- s.byobRequest.respond(l), r += l, r >= n.size && s.close();
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();
56
58
  }
57
59
  });
58
60
  });
59
61
  }
60
- if (K === "NODE" && typeof CustomEvent > "u") {
61
- class e extends Event {
62
- constructor(r, n = {}) {
63
- super(r, n), this.detail = n.detail;
62
+ if (F === "NODE" && typeof CustomEvent > "u") {
63
+ class r extends Event {
64
+ constructor(t, n = {}) {
65
+ super(t, n), this.detail = n.detail;
64
66
  }
65
67
  initCustomEvent() {
66
68
  }
67
69
  }
68
- globalThis.CustomEvent = e;
70
+ globalThis.CustomEvent = r;
69
71
  }
70
- const x = {
72
+ const k = {
71
73
  0: "No error occurred. System call completed successfully.",
72
74
  1: "Argument list too long.",
73
75
  2: "Permission denied.",
@@ -146,21 +148,21 @@ const x = {
146
148
  75: "Cross-device link.",
147
149
  76: "Extension: Capabilities insufficient."
148
150
  };
149
- function ue(e) {
150
- const t = typeof e == "object" ? e == null ? void 0 : e.errno : null;
151
- if (t in x)
152
- return x[t];
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];
153
155
  }
154
- function y(e = "") {
155
- return function(r, n, s) {
156
- const o = s.value;
157
- s.value = function(...i) {
156
+ function y(r = "") {
157
+ return function(t, n, o) {
158
+ const i = o.value;
159
+ o.value = function(...s) {
158
160
  try {
159
- return o.apply(this, i);
161
+ return i.apply(this, s);
160
162
  } catch (a) {
161
- const u = typeof a == "object" ? a == null ? void 0 : a.errno : null;
162
- if (u in x) {
163
- const l = x[u], c = typeof i[1] == "string" ? i[1] : null, d = c !== null ? e.replaceAll("{path}", c) : e;
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;
164
166
  throw new Error(`${d}: ${l}`, {
165
167
  cause: a
166
168
  });
@@ -170,61 +172,61 @@ function y(e = "") {
170
172
  };
171
173
  };
172
174
  }
173
- const le = "playground-log", B = (e, ...t) => {
174
- v.dispatchEvent(
175
- new CustomEvent(le, {
175
+ const J = "playground-log", D = (r, ...e) => {
176
+ E.dispatchEvent(
177
+ new CustomEvent(J, {
176
178
  detail: {
177
- log: e,
178
- args: t
179
+ log: r,
180
+ args: e
179
181
  }
180
182
  })
181
183
  );
182
- }, de = (e, ...t) => {
183
- switch (typeof e.message == "string" ? e.message = W(e.message) : e.message.message && typeof e.message.message == "string" && (e.message.message = W(e.message.message)), e.severity) {
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) {
184
186
  case "Debug":
185
- console.debug(e.message, ...t);
187
+ console.debug(r.message, ...e);
186
188
  break;
187
189
  case "Info":
188
- console.info(e.message, ...t);
190
+ console.info(r.message, ...e);
189
191
  break;
190
192
  case "Warn":
191
- console.warn(e.message, ...t);
193
+ console.warn(r.message, ...e);
192
194
  break;
193
195
  case "Error":
194
- console.error(e.message, ...t);
196
+ console.error(r.message, ...e);
195
197
  break;
196
198
  case "Fatal":
197
- console.error(e.message, ...t);
199
+ console.error(r.message, ...e);
198
200
  break;
199
201
  default:
200
- console.log(e.message, ...t);
202
+ console.log(r.message, ...e);
201
203
  }
202
- }, fe = (e) => e instanceof Error ? [e.message, e.stack].join(`
203
- `) : JSON.stringify(e, null, 2), Y = [], $ = (e) => {
204
- Y.push(e);
205
- }, N = (e) => {
206
- if (e.raw === !0)
207
- $(e.message);
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);
208
210
  else {
209
- const t = ye(
210
- typeof e.message == "object" ? fe(e.message) : e.message,
211
- e.severity ?? "Info",
212
- e.prefix ?? "JavaScript"
211
+ const e = K(
212
+ typeof r.message == "object" ? G(r.message) : r.message,
213
+ r.severity ?? "Info",
214
+ r.prefix ?? "JavaScript"
213
215
  );
214
- $(t);
216
+ O(e);
215
217
  }
216
218
  };
217
- class me extends EventTarget {
219
+ class U extends EventTarget {
218
220
  // constructor
219
- constructor(t = []) {
220
- super(), this.handlers = t, this.fatalErrorEvent = "playground-fatal-error";
221
+ constructor(e = []) {
222
+ super(), this.handlers = e, this.fatalErrorEvent = "playground-fatal-error";
221
223
  }
222
224
  /**
223
225
  * Get all logs.
224
226
  * @returns string[]
225
227
  */
226
228
  getLogs() {
227
- return this.handlers.includes(N) ? [...Y] : (this.error(`Logs aren't stored because the logToMemory handler isn't registered.
229
+ return this.handlers.includes(P) ? [...M] : (this.error(`Logs aren't stored because the logToMemory handler isn't registered.
228
230
  If you're using a custom logger instance, make sure to register logToMemory handler.
229
231
  `), []);
230
232
  }
@@ -236,9 +238,9 @@ class me extends EventTarget {
236
238
  * @param raw boolean
237
239
  * @param args any
238
240
  */
239
- logMessage(t, ...r) {
241
+ logMessage(e, ...t) {
240
242
  for (const n of this.handlers)
241
- n(t, ...r);
243
+ n(e, ...t);
242
244
  }
243
245
  /**
244
246
  * Log message
@@ -246,15 +248,15 @@ class me extends EventTarget {
246
248
  * @param message any
247
249
  * @param args any
248
250
  */
249
- log(t, ...r) {
251
+ log(e, ...t) {
250
252
  this.logMessage(
251
253
  {
252
- message: t,
254
+ message: e,
253
255
  severity: void 0,
254
256
  prefix: "JavaScript",
255
257
  raw: !1
256
258
  },
257
- ...r
259
+ ...t
258
260
  );
259
261
  }
260
262
  /**
@@ -263,15 +265,15 @@ class me extends EventTarget {
263
265
  * @param message any
264
266
  * @param args any
265
267
  */
266
- debug(t, ...r) {
268
+ debug(e, ...t) {
267
269
  this.logMessage(
268
270
  {
269
- message: t,
271
+ message: e,
270
272
  severity: "Debug",
271
273
  prefix: "JavaScript",
272
274
  raw: !1
273
275
  },
274
- ...r
276
+ ...t
275
277
  );
276
278
  }
277
279
  /**
@@ -280,15 +282,15 @@ class me extends EventTarget {
280
282
  * @param message any
281
283
  * @param args any
282
284
  */
283
- info(t, ...r) {
285
+ info(e, ...t) {
284
286
  this.logMessage(
285
287
  {
286
- message: t,
288
+ message: e,
287
289
  severity: "Info",
288
290
  prefix: "JavaScript",
289
291
  raw: !1
290
292
  },
291
- ...r
293
+ ...t
292
294
  );
293
295
  }
294
296
  /**
@@ -297,15 +299,15 @@ class me extends EventTarget {
297
299
  * @param message any
298
300
  * @param args any
299
301
  */
300
- warn(t, ...r) {
302
+ warn(e, ...t) {
301
303
  this.logMessage(
302
304
  {
303
- message: t,
305
+ message: e,
304
306
  severity: "Warn",
305
307
  prefix: "JavaScript",
306
308
  raw: !1
307
309
  },
308
- ...r
310
+ ...t
309
311
  );
310
312
  }
311
313
  /**
@@ -314,54 +316,54 @@ class me extends EventTarget {
314
316
  * @param message any
315
317
  * @param args any
316
318
  */
317
- error(t, ...r) {
319
+ error(e, ...t) {
318
320
  this.logMessage(
319
321
  {
320
- message: t,
322
+ message: e,
321
323
  severity: "Error",
322
324
  prefix: "JavaScript",
323
325
  raw: !1
324
326
  },
325
- ...r
327
+ ...t
326
328
  );
327
329
  }
328
330
  }
329
- const pe = () => {
331
+ const V = () => {
330
332
  try {
331
333
  if (process.env.NODE_ENV === "test")
332
- return [N, B];
334
+ return [P, D];
333
335
  } catch {
334
336
  }
335
- return [N, de, B];
336
- }, v = new me(pe()), W = (e) => e.replace(/\t/g, ""), ye = (e, t, r) => {
337
- const n = /* @__PURE__ */ new Date(), s = new Intl.DateTimeFormat("en-GB", {
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", {
338
340
  year: "numeric",
339
341
  month: "short",
340
342
  day: "2-digit",
341
343
  timeZone: "UTC"
342
- }).format(n).replace(/ /g, "-"), o = new Intl.DateTimeFormat("en-GB", {
344
+ }).format(n).replace(/ /g, "-"), i = new Intl.DateTimeFormat("en-GB", {
343
345
  hour: "2-digit",
344
346
  minute: "2-digit",
345
347
  second: "2-digit",
346
348
  hour12: !1,
347
349
  timeZone: "UTC",
348
350
  timeZoneName: "short"
349
- }).format(n), i = s + " " + o;
350
- return e = W(e), `[${i}] ${r} ${t}: ${e}`;
351
- }, Z = Symbol("SleepFinished");
352
- function he(e) {
353
- return new Promise((t) => {
354
- setTimeout(() => t(Z), e);
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);
355
357
  });
356
358
  }
357
- class we extends Error {
359
+ class Q extends Error {
358
360
  constructor() {
359
361
  super("Acquiring lock timed out");
360
362
  }
361
363
  }
362
- class ge {
363
- constructor({ concurrency: t, timeout: r }) {
364
- this._running = 0, this.concurrency = t, this.timeout = r, this.queue = [];
364
+ class Y {
365
+ constructor({ concurrency: e, timeout: t }) {
366
+ this._running = 0, this.concurrency = e, this.timeout = t, this.queue = [];
365
367
  }
366
368
  get remaining() {
367
369
  return this.concurrency - this.running;
@@ -372,91 +374,91 @@ class ge {
372
374
  async acquire() {
373
375
  for (; ; )
374
376
  if (this._running >= this.concurrency) {
375
- const t = new Promise((r) => {
376
- this.queue.push(r);
377
+ const e = new Promise((t) => {
378
+ this.queue.push(t);
377
379
  });
378
- this.timeout !== void 0 ? await Promise.race([t, he(this.timeout)]).then(
379
- (r) => {
380
- if (r === Z)
381
- throw new we();
380
+ this.timeout !== void 0 ? await Promise.race([e, Z(this.timeout)]).then(
381
+ (t) => {
382
+ if (t === L)
383
+ throw new Q();
382
384
  }
383
- ) : await t;
385
+ ) : await e;
384
386
  } else {
385
387
  this._running++;
386
- let t = !1;
388
+ let e = !1;
387
389
  return () => {
388
- t || (t = !0, this._running--, this.queue.length > 0 && this.queue.shift()());
390
+ e || (e = !0, this._running--, this.queue.length > 0 && this.queue.shift()());
389
391
  };
390
392
  }
391
393
  }
392
- async run(t) {
393
- const r = await this.acquire();
394
+ async run(e) {
395
+ const t = await this.acquire();
394
396
  try {
395
- return await t();
397
+ return await e();
396
398
  } finally {
397
- r();
399
+ t();
398
400
  }
399
401
  }
400
402
  }
401
- class j extends Error {
402
- constructor(t, r) {
403
- super(t), this.userFriendlyMessage = r, this.userFriendlyMessage || (this.userFriendlyMessage = t);
403
+ class H extends Error {
404
+ constructor(e, t) {
405
+ super(e), this.userFriendlyMessage = t, this.userFriendlyMessage || (this.userFriendlyMessage = e);
404
406
  }
405
407
  }
406
- function b(...e) {
407
- let t = e.join("/");
408
- const r = t[0] === "/", n = t.substring(t.length - 1) === "/";
409
- return t = H(t), !t && !r && (t = "."), t && n && (t += "/"), t;
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;
410
412
  }
411
- function be(e) {
412
- if (e === "/")
413
+ function X(r) {
414
+ if (r === "/")
413
415
  return "/";
414
- e = H(e);
415
- const t = e.lastIndexOf("/");
416
- return t === -1 ? "" : t === 0 ? "/" : e.substr(0, t);
416
+ r = C(r);
417
+ const e = r.lastIndexOf("/");
418
+ return e === -1 ? "" : e === 0 ? "/" : r.substr(0, e);
417
419
  }
418
- function Ee(e) {
419
- if (e === "/")
420
+ function ee(r) {
421
+ if (r === "/")
420
422
  return "/";
421
- e = H(e);
422
- const t = e.lastIndexOf("/");
423
- return t === -1 ? e : e.substr(t + 1);
423
+ r = C(r);
424
+ const e = r.lastIndexOf("/");
425
+ return e === -1 ? r : r.substr(e + 1);
424
426
  }
425
- function H(e) {
426
- const t = e[0] === "/";
427
- return e = ke(
428
- e.split("/").filter((r) => !!r),
429
- !t
430
- ).join("/"), (t ? "/" : "") + e.replace(/\/$/, "");
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(/\/$/, "");
431
433
  }
432
- function ke(e, t) {
433
- let r = 0;
434
- for (let n = e.length - 1; n >= 0; n--) {
435
- const s = e[n];
436
- s === "." ? e.splice(n, 1) : s === ".." ? (e.splice(n, 1), r++) : r && (e.splice(n, 1), r--);
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--);
437
439
  }
438
- if (t)
439
- for (; r; r--)
440
- e.unshift("..");
441
- return e;
440
+ if (e)
441
+ for (; t; t--)
442
+ r.unshift("..");
443
+ return r;
442
444
  }
443
- var ve = Object.defineProperty, Pe = Object.getOwnPropertyDescriptor, h = (e, t, r, n) => {
444
- for (var s = n > 1 ? void 0 : n ? Pe(t, r) : t, o = e.length - 1, i; o >= 0; o--)
445
- (i = e[o]) && (s = (n ? i(t, r, s) : i(s)) || s);
446
- return n && s && ve(t, r, s), s;
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;
447
449
  };
448
- const p = class m {
449
- static readFileAsText(t, r) {
450
- return new TextDecoder().decode(m.readFileAsBuffer(t, r));
450
+ const p = class f {
451
+ static readFileAsText(e, t) {
452
+ return new TextDecoder().decode(f.readFileAsBuffer(e, t));
451
453
  }
452
- static readFileAsBuffer(t, r) {
453
- return t.readFile(r);
454
+ static readFileAsBuffer(e, t) {
455
+ return e.readFile(t);
454
456
  }
455
- static writeFile(t, r, n) {
456
- t.writeFile(r, n);
457
+ static writeFile(e, t, n) {
458
+ e.writeFile(t, n);
457
459
  }
458
- static unlink(t, r) {
459
- t.unlink(r);
460
+ static unlink(e, t) {
461
+ e.unlink(t);
460
462
  }
461
463
  /**
462
464
  * Moves a file or directory in the PHP filesystem to a
@@ -465,70 +467,70 @@ const p = class m {
465
467
  * @param oldPath The path to rename.
466
468
  * @param newPath The new path.
467
469
  */
468
- static mv(t, r, n) {
470
+ static mv(e, t, n) {
469
471
  try {
470
- const s = t.lookupPath(r).node.mount, o = m.fileExists(t, n) ? t.lookupPath(n).node.mount : t.lookupPath(be(n)).node.mount;
471
- s.mountpoint !== o.mountpoint ? (m.copyRecursive(t, r, n), m.rmdir(t, r, { recursive: !0 })) : t.rename(r, n);
472
- } catch (s) {
473
- const o = ue(s);
474
- throw o ? new Error(
475
- `Could not move ${r} to ${n}: ${o}`,
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}`,
476
478
  {
477
- cause: s
479
+ cause: o
478
480
  }
479
- ) : s;
481
+ ) : o;
480
482
  }
481
483
  }
482
- static rmdir(t, r, n = { recursive: !0 }) {
483
- n != null && n.recursive && m.listFiles(t, r).forEach((s) => {
484
- const o = `${r}/${s}`;
485
- m.isDir(t, o) ? m.rmdir(t, o, n) : m.unlink(t, o);
486
- }), t.rmdir(r);
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);
487
489
  }
488
- static listFiles(t, r, n = { prependPath: !1 }) {
489
- if (!m.fileExists(t, r))
490
+ static listFiles(e, t, n = { prependPath: !1 }) {
491
+ if (!f.fileExists(e, t))
490
492
  return [];
491
493
  try {
492
- const s = t.readdir(r).filter(
493
- (o) => o !== "." && o !== ".."
494
+ const o = e.readdir(t).filter(
495
+ (i) => i !== "." && i !== ".."
494
496
  );
495
497
  if (n.prependPath) {
496
- const o = r.replace(/\/$/, "");
497
- return s.map((i) => `${o}/${i}`);
498
+ const i = t.replace(/\/$/, "");
499
+ return o.map((s) => `${i}/${s}`);
498
500
  }
499
- return s;
500
- } catch (s) {
501
- return v.error(s, { path: r }), [];
501
+ return o;
502
+ } catch (o) {
503
+ return E.error(o, { path: t }), [];
502
504
  }
503
505
  }
504
- static isDir(t, r) {
505
- return m.fileExists(t, r) ? t.isDir(t.lookupPath(r).node.mode) : !1;
506
+ static isDir(e, t) {
507
+ return f.fileExists(e, t) ? e.isDir(e.lookupPath(t).node.mode) : !1;
506
508
  }
507
- static fileExists(t, r) {
509
+ static fileExists(e, t) {
508
510
  try {
509
- return t.lookupPath(r), !0;
511
+ return e.lookupPath(t), !0;
510
512
  } catch {
511
513
  return !1;
512
514
  }
513
515
  }
514
- static mkdir(t, r) {
515
- t.mkdirTree(r);
516
+ static mkdir(e, t) {
517
+ e.mkdirTree(t);
516
518
  }
517
- static copyRecursive(t, r, n) {
518
- const s = t.lookupPath(r).node;
519
- if (t.isDir(s.mode)) {
520
- t.mkdirTree(n);
521
- const o = t.readdir(r).filter(
522
- (i) => i !== "." && i !== ".."
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 !== ".."
523
525
  );
524
- for (const i of o)
525
- m.copyRecursive(
526
- t,
527
- b(r, i),
528
- b(n, i)
526
+ for (const s of i)
527
+ f.copyRecursive(
528
+ e,
529
+ g(t, s),
530
+ g(n, s)
529
531
  );
530
532
  } else
531
- t.writeFile(n, t.readFile(r));
533
+ e.writeFile(n, e.readFile(t));
532
534
  }
533
535
  };
534
536
  h([
@@ -561,8 +563,8 @@ h([
561
563
  h([
562
564
  y('Could not copy files from "{path}"')
563
565
  ], p, "copyRecursive", 1);
564
- let R = p;
565
- const Te = {
566
+ let v = p;
567
+ const oe = {
566
568
  500: "Internal Server Error",
567
569
  502: "Bad Gateway",
568
570
  404: "Not Found",
@@ -577,26 +579,26 @@ const Te = {
577
579
  201: "Created",
578
580
  200: "OK"
579
581
  };
580
- class O {
581
- constructor(t, r, n, s = "", o = 0) {
582
- this.httpStatusCode = t, this.headers = r, this.bytes = n, this.exitCode = o, this.errors = s;
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;
583
585
  }
584
- static forHttpCode(t, r = "") {
585
- return new O(
586
- t,
586
+ static forHttpCode(e, t = "") {
587
+ return new T(
588
+ e,
587
589
  {},
588
590
  new TextEncoder().encode(
589
- r || Te[t] || ""
591
+ t || oe[e] || ""
590
592
  )
591
593
  );
592
594
  }
593
- static fromRawData(t) {
594
- return new O(
595
- t.httpStatusCode,
596
- t.headers,
597
- t.bytes,
598
- t.errors,
599
- t.exitCode
595
+ static fromRawData(e) {
596
+ return new T(
597
+ e.httpStatusCode,
598
+ e.headers,
599
+ e.bytes,
600
+ e.errors,
601
+ e.exitCode
600
602
  );
601
603
  }
602
604
  toRawData() {
@@ -621,54 +623,54 @@ class O {
621
623
  return new TextDecoder().decode(this.bytes);
622
624
  }
623
625
  }
624
- const Re = Symbol("RuntimeId"), _ = /* @__PURE__ */ new Map();
625
- let Ce = 0;
626
- async function xe(e, t = {}) {
627
- const [r, n, s] = Se(), o = e.init(Oe, {
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, {
628
630
  onAbort(a) {
629
- s(a), v.error(a);
631
+ o(a), E.error(a);
630
632
  },
631
633
  ENV: {},
632
634
  // Emscripten sometimes prepends a '/' to the path, which
633
635
  // breaks vite dev mode. An identity `locateFile` function
634
636
  // fixes it.
635
637
  locateFile: (a) => a,
636
- ...t,
638
+ ...e,
637
639
  noInitialRun: !0,
638
640
  onRuntimeInitialized() {
639
- t.onRuntimeInitialized && t.onRuntimeInitialized(), n();
641
+ e.onRuntimeInitialized && e.onRuntimeInitialized(), n();
640
642
  }
641
643
  });
642
- await r;
643
- const i = ++Ce;
644
- return o.id = i, o.originalExit = o._exit, o._exit = function(a) {
645
- return _.delete(i), o.originalExit(a);
646
- }, o[Re] = i, _.set(i, o), i;
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;
647
649
  }
648
- const Oe = function() {
649
- var e;
650
- return typeof process < "u" && ((e = process.release) == null ? void 0 : e.name) === "node" ? "NODE" : typeof window < "u" ? "WEB" : typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope ? "WORKER" : "NODE";
651
- }(), Se = () => {
652
- const e = [], t = new Promise((r, n) => {
653
- e.push(r, n);
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);
654
656
  });
655
- return e.unshift(t), e;
657
+ return r.unshift(e), r;
656
658
  }, w = Symbol("__private__dont__use");
657
659
  ReadableStream.prototype[Symbol.asyncIterator] || (ReadableStream.prototype[Symbol.asyncIterator] = async function* () {
658
- const e = this.getReader();
660
+ const r = this.getReader();
659
661
  try {
660
662
  for (; ; ) {
661
- const { done: t, value: r } = await e.read();
662
- if (t)
663
+ const { done: e, value: t } = await r.read();
664
+ if (e)
663
665
  return;
664
- yield r;
666
+ yield t;
665
667
  }
666
668
  } finally {
667
- e.releaseLock();
669
+ r.releaseLock();
668
670
  }
669
671
  }, ReadableStream.prototype.iterate = // @ts-ignore
670
672
  ReadableStream.prototype[Symbol.asyncIterator]);
671
- const De = [
673
+ const le = [
672
674
  "8.3",
673
675
  "8.2",
674
676
  "8.1",
@@ -678,342 +680,98 @@ const De = [
678
680
  "7.2",
679
681
  "7.1",
680
682
  "7.0"
681
- ], Ae = De[0];
682
- /**
683
- * @license
684
- * Copyright 2019 Google LLC
685
- * SPDX-License-Identifier: Apache-2.0
686
- */
687
- const Q = Symbol("Comlink.proxy"), Me = Symbol("Comlink.endpoint"), Le = Symbol("Comlink.releaseProxy"), L = Symbol("Comlink.finalizer"), C = Symbol("Comlink.thrown"), X = (e) => typeof e == "object" && e !== null || typeof e == "function", Ne = {
688
- canHandle: (e) => X(e) && e[Q],
689
- serialize(e) {
690
- const { port1: t, port2: r } = new MessageChannel();
691
- return M(e, t), [r, [r]];
692
- },
693
- deserialize(e) {
694
- return e.start(), F(e);
695
- }
696
- }, We = {
697
- canHandle: (e) => X(e) && C in e,
698
- serialize({ value: e }) {
699
- let t;
700
- return e instanceof Error ? t = {
701
- isError: !0,
702
- value: {
703
- message: e.message,
704
- name: e.name,
705
- stack: e.stack
706
- }
707
- } : t = { isError: !1, value: e }, [t, []];
708
- },
709
- deserialize(e) {
710
- throw e.isError ? Object.assign(new Error(e.value.message), e.value) : e.value;
711
- }
712
- }, k = /* @__PURE__ */ new Map([
713
- ["proxy", Ne],
714
- ["throw", We]
715
- ]);
716
- function Ie(e, t) {
717
- for (const r of e)
718
- if (t === r || r === "*" || r instanceof RegExp && r.test(t))
719
- return !0;
720
- return !1;
721
- }
722
- function M(e, t = globalThis, r = ["*"]) {
723
- t.addEventListener("message", function n(s) {
724
- if (!s || !s.data)
725
- return;
726
- if (!Ie(r, s.origin)) {
727
- console.warn(`Invalid origin '${s.origin}' for comlink proxy`);
728
- return;
729
- }
730
- const { id: o, type: i, path: a } = Object.assign({ path: [] }, s.data), u = (s.data.argumentList || []).map(g);
731
- let l;
732
- try {
733
- const c = a.slice(0, -1).reduce((f, P) => f[P], e), d = a.reduce((f, P) => f[P], e);
734
- switch (i) {
735
- case "GET":
736
- l = d;
737
- break;
738
- case "SET":
739
- c[a.slice(-1)[0]] = g(s.data.value), l = !0;
740
- break;
741
- case "APPLY":
742
- l = d.apply(c, u);
743
- break;
744
- case "CONSTRUCT":
745
- {
746
- const f = new d(...u);
747
- l = ne(f);
748
- }
749
- break;
750
- case "ENDPOINT":
751
- {
752
- const { port1: f, port2: P } = new MessageChannel();
753
- M(e, P), l = $e(f, [f]);
754
- }
755
- break;
756
- case "RELEASE":
757
- l = void 0;
758
- break;
759
- default:
760
- return;
761
- }
762
- } catch (c) {
763
- l = { value: c, [C]: 0 };
764
- }
765
- Promise.resolve(l).catch((c) => ({ value: c, [C]: 0 })).then((c) => {
766
- const [d, f] = A(c);
767
- t.postMessage(Object.assign(Object.assign({}, d), { id: o }), f), i === "RELEASE" && (t.removeEventListener("message", n), ee(t), L in e && typeof e[L] == "function" && e[L]());
768
- }).catch((c) => {
769
- const [d, f] = A({
770
- value: new TypeError("Unserializable return value"),
771
- [C]: 0
772
- });
773
- t.postMessage(Object.assign(Object.assign({}, d), { id: o }), f);
774
- });
775
- }), t.start && t.start();
776
- }
777
- function He(e) {
778
- return e.constructor.name === "MessagePort";
779
- }
780
- function ee(e) {
781
- He(e) && e.close();
782
- }
783
- function F(e, t) {
784
- return I(e, [], t);
785
- }
786
- function T(e) {
787
- if (e)
788
- throw new Error("Proxy has been released and is not useable");
789
- }
790
- function te(e) {
791
- return E(e, {
792
- type: "RELEASE"
793
- }).then(() => {
794
- ee(e);
795
- });
796
- }
797
- const S = /* @__PURE__ */ new WeakMap(), D = "FinalizationRegistry" in globalThis && new FinalizationRegistry((e) => {
798
- const t = (S.get(e) || 0) - 1;
799
- S.set(e, t), t === 0 && te(e);
800
- });
801
- function Fe(e, t) {
802
- const r = (S.get(t) || 0) + 1;
803
- S.set(t, r), D && D.register(e, t, e);
804
- }
805
- function ze(e) {
806
- D && D.unregister(e);
807
- }
808
- function I(e, t = [], r = function() {
809
- }) {
810
- let n = !1;
811
- const s = new Proxy(r, {
812
- get(o, i) {
813
- if (T(n), i === Le)
814
- return () => {
815
- ze(s), te(e), n = !0;
816
- };
817
- if (i === "then") {
818
- if (t.length === 0)
819
- return { then: () => s };
820
- const a = E(e, {
821
- type: "GET",
822
- path: t.map((u) => u.toString())
823
- }).then(g);
824
- return a.then.bind(a);
825
- }
826
- return I(e, [...t, i]);
827
- },
828
- set(o, i, a) {
829
- T(n);
830
- const [u, l] = A(a);
831
- return E(e, {
832
- type: "SET",
833
- path: [...t, i].map((c) => c.toString()),
834
- value: u
835
- }, l).then(g);
836
- },
837
- apply(o, i, a) {
838
- T(n);
839
- const u = t[t.length - 1];
840
- if (u === Me)
841
- return E(e, {
842
- type: "ENDPOINT"
843
- }).then(g);
844
- if (u === "bind")
845
- return I(e, t.slice(0, -1));
846
- const [l, c] = q(a);
847
- return E(e, {
848
- type: "APPLY",
849
- path: t.map((d) => d.toString()),
850
- argumentList: l
851
- }, c).then(g);
852
- },
853
- construct(o, i) {
854
- T(n);
855
- const [a, u] = q(i);
856
- return E(e, {
857
- type: "CONSTRUCT",
858
- path: t.map((l) => l.toString()),
859
- argumentList: a
860
- }, u).then(g);
861
- }
862
- });
863
- return Fe(s, e), s;
864
- }
865
- function Be(e) {
866
- return Array.prototype.concat.apply([], e);
867
- }
868
- function q(e) {
869
- const t = e.map(A);
870
- return [t.map((r) => r[0]), Be(t.map((r) => r[1]))];
871
- }
872
- const re = /* @__PURE__ */ new WeakMap();
873
- function $e(e, t) {
874
- return re.set(e, t), e;
875
- }
876
- function ne(e) {
877
- return Object.assign(e, { [Q]: !0 });
878
- }
879
- function se(e, t = globalThis, r = "*") {
880
- return {
881
- postMessage: (n, s) => e.postMessage(n, r, s),
882
- addEventListener: t.addEventListener.bind(t),
883
- removeEventListener: t.removeEventListener.bind(t)
884
- };
885
- }
886
- function A(e) {
887
- for (const [t, r] of k)
888
- if (r.canHandle(e)) {
889
- const [n, s] = r.serialize(e);
890
- return [
891
- {
892
- type: "HANDLER",
893
- name: t,
894
- value: n
895
- },
896
- s
897
- ];
898
- }
899
- return [
900
- {
901
- type: "RAW",
902
- value: e
903
- },
904
- re.get(e) || []
905
- ];
906
- }
907
- function g(e) {
908
- switch (e.type) {
909
- case "HANDLER":
910
- return k.get(e.name).deserialize(e.value);
911
- case "RAW":
912
- return e.value;
913
- }
914
- }
915
- function E(e, t, r) {
916
- return new Promise((n) => {
917
- const s = je();
918
- e.addEventListener("message", function o(i) {
919
- !i.data || !i.data.id || i.data.id !== s || (e.removeEventListener("message", o), n(i.data));
920
- }), e.start && e.start(), e.postMessage(Object.assign({ id: s }, t), r);
921
- });
922
- }
923
- function je() {
924
- return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
925
- }
926
- function tt(e, t = void 0) {
927
- oe();
928
- const r = e instanceof Worker ? e : se(e, t), n = F(r), s = z(n);
929
- return new Proxy(s, {
930
- get: (o, i) => i === "isConnected" ? async () => {
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, {
688
+ get: (i, s) => s === "isConnected" ? async () => {
931
689
  for (; ; )
932
690
  try {
933
- await _e(n.isConnected(), 200);
691
+ await fe(n.isConnected(), 200);
934
692
  break;
935
693
  } catch {
936
694
  }
937
- } : n[i]
695
+ } : n[s]
938
696
  });
939
697
  }
940
- async function _e(e, t) {
941
- return new Promise((r, n) => {
942
- setTimeout(n, t), e.then(r);
698
+ async function fe(r, e) {
699
+ return new Promise((t, n) => {
700
+ setTimeout(n, e), r.then(t);
943
701
  });
944
702
  }
945
- function rt(e, t) {
946
- oe();
947
- const r = Promise.resolve();
948
- let n, s;
949
- const o = new Promise((u, l) => {
950
- n = u, s = l;
951
- }), i = z(e), a = new Proxy(i, {
952
- get: (u, l) => l === "isConnected" ? () => r : l === "isReady" ? () => o : l in u ? u[l] : t == null ? void 0 : t[l]
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]
953
711
  });
954
- return M(
712
+ return m.expose(
955
713
  a,
956
- typeof window < "u" ? se(self.parent) : void 0
957
- ), [n, s, a];
714
+ typeof window < "u" ? m.windowEndpoint(self.parent) : void 0
715
+ ), [n, o, a];
958
716
  }
959
- let J = !1;
960
- function oe() {
961
- if (J)
717
+ let W = !1;
718
+ function B() {
719
+ if (W)
962
720
  return;
963
- J = !0, k.set("EVENT", {
964
- canHandle: (r) => r instanceof CustomEvent,
965
- serialize: (r) => [
721
+ W = !0, m.transferHandlers.set("EVENT", {
722
+ canHandle: (t) => t instanceof CustomEvent,
723
+ serialize: (t) => [
966
724
  {
967
- detail: r.detail
725
+ detail: t.detail
968
726
  },
969
727
  []
970
728
  ],
971
- deserialize: (r) => r
972
- }), k.set("FUNCTION", {
973
- canHandle: (r) => typeof r == "function",
974
- serialize(r) {
975
- const { port1: n, port2: s } = new MessageChannel();
976
- return M(r, n), [s, [s]];
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]];
977
735
  },
978
- deserialize(r) {
979
- return r.start(), F(r);
736
+ deserialize(t) {
737
+ return t.start(), m.wrap(t);
980
738
  }
981
- }), k.set("PHPResponse", {
982
- canHandle: (r) => typeof r == "object" && r !== null && "headers" in r && "bytes" in r && "errors" in r && "exitCode" in r && "httpStatusCode" in r,
983
- serialize(r) {
984
- return [r.toRawData(), []];
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(), []];
985
743
  },
986
- deserialize(r) {
987
- return O.fromRawData(r);
744
+ deserialize(t) {
745
+ return T.fromRawData(t);
988
746
  }
989
747
  });
990
- const e = k.get("throw"), t = e == null ? void 0 : e.serialize;
991
- e.serialize = ({ value: r }) => {
992
- const n = t({ value: r });
993
- return r.response && (n[0].value.response = r.response), r.source && (n[0].value.source = r.source), n;
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;
994
752
  };
995
753
  }
996
- function z(e) {
997
- return new Proxy(e, {
998
- get(t, r) {
999
- switch (typeof t[r]) {
754
+ function x(r) {
755
+ return new Proxy(r, {
756
+ get(e, t) {
757
+ switch (typeof e[t]) {
1000
758
  case "function":
1001
- return (...n) => t[r](...n);
759
+ return (...n) => e[t](...n);
1002
760
  case "object":
1003
- return t[r] === null ? t[r] : z(t[r]);
761
+ return e[t] === null ? e[t] : x(e[t]);
1004
762
  case "undefined":
1005
763
  case "number":
1006
764
  case "string":
1007
- return t[r];
765
+ return e[t];
1008
766
  default:
1009
- return ne(t[r]);
767
+ return m.proxy(e[t]);
1010
768
  }
1011
769
  }
1012
770
  });
1013
771
  }
1014
- async function qe(e = Ae, t = "light") {
1015
- if (t === "kitchen-sink")
1016
- switch (e) {
772
+ async function me(r = de, e = "light") {
773
+ if (e === "kitchen-sink")
774
+ switch (r) {
1017
775
  case "8.3":
1018
776
  return await import("./kitchen-sink/php_8_3.js");
1019
777
  case "8.2":
@@ -1034,7 +792,7 @@ async function qe(e = Ae, t = "light") {
1034
792
  return await import("./kitchen-sink/php_7_0.js");
1035
793
  }
1036
794
  else
1037
- switch (e) {
795
+ switch (r) {
1038
796
  case "8.3":
1039
797
  return await import("./light/php_8_3.js");
1040
798
  case "8.2":
@@ -1054,11 +812,11 @@ async function qe(e = Ae, t = "light") {
1054
812
  case "7.0":
1055
813
  return await import("./light/php_7_0.js");
1056
814
  }
1057
- throw new Error(`Unsupported PHP version ${e}`);
815
+ throw new Error(`Unsupported PHP version ${r}`);
1058
816
  }
1059
- const Je = () => ({
817
+ const pe = () => ({
1060
818
  websocket: {
1061
- decorator: (e) => class extends e {
819
+ decorator: (r) => class extends r {
1062
820
  constructor() {
1063
821
  try {
1064
822
  super();
@@ -1071,424 +829,424 @@ const Je = () => ({
1071
829
  }
1072
830
  }
1073
831
  });
1074
- async function st(e, t = {}) {
1075
- var s;
1076
- const r = t.loadAllExtensions ? "kitchen-sink" : "light", n = await qe(e, r);
1077
- return (s = t.onPhpLoaderModuleLoaded) == null || s.call(t, n), await xe(n, {
1078
- ...t.emscriptenOptions || {},
1079
- ...Je()
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()
1080
838
  });
1081
839
  }
1082
- function Ve(e, t) {
840
+ function ye(r, e) {
1083
841
  return {
1084
842
  type: "response",
1085
- requestId: e,
1086
- response: t
843
+ requestId: r,
844
+ response: e
1087
845
  };
1088
846
  }
1089
- async function ot(e, t, r) {
847
+ async function Oe(r, e, t) {
1090
848
  const n = navigator.serviceWorker;
1091
849
  if (!n)
1092
- throw window.isSecureContext ? new j(
850
+ throw window.isSecureContext ? new H(
1093
851
  "Service workers are not supported in your browser."
1094
- ) : new j(
852
+ ) : new H(
1095
853
  "WordPress Playground uses service workers and may only work on HTTPS and http://localhost/ sites, but the current site is neither."
1096
854
  );
1097
- await (await n.register(r, {
855
+ await (await n.register(t, {
1098
856
  type: "module",
1099
857
  // Always bypass HTTP cache when fetching the new Service Worker script:
1100
858
  updateViaCache: "none"
1101
859
  })).update(), navigator.serviceWorker.addEventListener(
1102
860
  "message",
1103
- async function(i) {
1104
- if (t && i.data.scope !== t)
861
+ async function(s) {
862
+ if (e && s.data.scope !== e)
1105
863
  return;
1106
- const a = i.data.args || [], u = i.data.method, l = await e[u](...a);
1107
- i.source.postMessage(Ve(i.data.requestId, l));
864
+ const a = s.data.args || [], c = s.data.method, l = await r[c](...a);
865
+ s.source.postMessage(ye(s.data.requestId, l));
1108
866
  }
1109
867
  ), n.startMessages();
1110
868
  }
1111
- function it(e, t) {
1112
- window.addEventListener("message", (r) => {
1113
- r.source === e.contentWindow && (t && r.origin !== t || typeof r.data != "object" || r.data.type !== "relay" || window.parent.postMessage(r.data, "*"));
1114
- }), window.addEventListener("message", (r) => {
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) => {
1115
873
  var n;
1116
- r.source === window.parent && (typeof r.data != "object" || r.data.type !== "relay" || (n = e == null ? void 0 : e.contentWindow) == null || n.postMessage(r.data));
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));
1117
875
  });
1118
876
  }
1119
- async function at(e, t = {}) {
1120
- e = Ue(e, t);
1121
- const r = new Worker(e, { type: "module" });
1122
- return new Promise((n, s) => {
1123
- r.onerror = (i) => {
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) => {
1124
882
  const a = new Error(
1125
- `WebWorker failed to load at ${e}. ${i.message ? `Original error: ${i.message}` : ""}`
883
+ `WebWorker failed to load at ${r}. ${s.message ? `Original error: ${s.message}` : ""}`
1126
884
  );
1127
- a.filename = i.filename, s(a);
885
+ a.filename = s.filename, o(a);
1128
886
  };
1129
- function o(i) {
1130
- i.data === "worker-script-started" && (n(r), r.removeEventListener("message", o));
887
+ function i(s) {
888
+ s.data === "worker-script-started" && (n(t), t.removeEventListener("message", i));
1131
889
  }
1132
- r.addEventListener("message", o);
890
+ t.addEventListener("message", i);
1133
891
  });
1134
892
  }
1135
- function Ue(e, t) {
1136
- if (!Object.entries(t).length)
1137
- return e + "";
1138
- const r = new URL(e);
1139
- for (const [n, s] of Object.entries(t))
1140
- if (Array.isArray(s))
1141
- for (const o of s)
1142
- r.searchParams.append(n, o);
893
+ function he(r, e) {
894
+ if (!Object.entries(e).length)
895
+ 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);
1143
901
  else
1144
- r.searchParams.set(n, s);
1145
- return r.toString();
902
+ t.searchParams.set(n, o);
903
+ return t.toString();
1146
904
  }
1147
- function Ge(e, t, r = () => {
905
+ function we(r, e, t = () => {
1148
906
  }) {
1149
907
  function n() {
1150
- t = Ye(t);
1151
- const o = e[w].FS, i = Ke(o, (c) => {
1152
- if (c.path.startsWith(t))
1153
- r(c);
1154
- else if (c.operation === "RENAME" && c.toPath.startsWith(t))
1155
- for (const d of ie(
1156
- e,
1157
- c.path,
1158
- c.toPath
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
1159
917
  ))
1160
- r(d);
918
+ t(d);
1161
919
  }), a = {};
1162
- for (const [c] of Object.entries(i))
1163
- a[c] = o[c];
1164
- function u() {
1165
- for (const [c, d] of Object.entries(i))
1166
- o[c] = function(...f) {
1167
- return d(...f), a[c].apply(this, f);
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);
1168
926
  };
1169
927
  }
1170
928
  function l() {
1171
- for (const [c, d] of Object.entries(a))
1172
- e[w].FS[c] = d;
929
+ for (const [u, d] of Object.entries(a))
930
+ r[w].FS[u] = d;
1173
931
  }
1174
- e[w].journal = {
1175
- bind: u,
932
+ r[w].journal = {
933
+ bind: c,
1176
934
  unbind: l
1177
- }, u();
935
+ }, c();
1178
936
  }
1179
- e.addEventListener("runtime.initialized", n), e[w] && n();
1180
- function s() {
1181
- e[w].journal.unbind(), delete e[w].journal;
937
+ r.addEventListener("runtime.initialized", n), r[w] && n();
938
+ function o() {
939
+ r[w].journal.unbind(), delete r[w].journal;
1182
940
  }
1183
- return e.addEventListener("runtime.beforedestroy", s), function() {
1184
- return e.removeEventListener("runtime.initialized", n), e.removeEventListener("runtime.beforedestroy", s), e[w].journal.unbind();
941
+ return r.addEventListener("runtime.beforedestroy", o), function() {
942
+ return r.removeEventListener("runtime.initialized", n), r.removeEventListener("runtime.beforedestroy", o), r[w].journal.unbind();
1185
943
  };
1186
944
  }
1187
- const Ke = (e, t = () => {
945
+ const ge = (r, e = () => {
1188
946
  }) => ({
1189
- write(r) {
1190
- t({
947
+ write(t) {
948
+ e({
1191
949
  operation: "WRITE",
1192
- path: r.path,
950
+ path: t.path,
1193
951
  nodeType: "file"
1194
952
  });
1195
953
  },
1196
- truncate(r) {
954
+ truncate(t) {
1197
955
  let n;
1198
- typeof r == "string" ? n = e.lookupPath(r, {
956
+ typeof t == "string" ? n = r.lookupPath(t, {
1199
957
  follow: !0
1200
- }).node : n = r, t({
958
+ }).node : n = t, e({
1201
959
  operation: "WRITE",
1202
- path: e.getPath(n),
960
+ path: r.getPath(n),
1203
961
  nodeType: "file"
1204
962
  });
1205
963
  },
1206
- unlink(r) {
1207
- t({
964
+ unlink(t) {
965
+ e({
1208
966
  operation: "DELETE",
1209
- path: r,
967
+ path: t,
1210
968
  nodeType: "file"
1211
969
  });
1212
970
  },
1213
- mknod(r, n) {
1214
- e.isFile(n) && t({
971
+ mknod(t, n) {
972
+ r.isFile(n) && e({
1215
973
  operation: "CREATE",
1216
- path: r,
974
+ path: t,
1217
975
  nodeType: "file"
1218
976
  });
1219
977
  },
1220
- mkdir(r) {
1221
- t({
978
+ mkdir(t) {
979
+ e({
1222
980
  operation: "CREATE",
1223
- path: r,
981
+ path: t,
1224
982
  nodeType: "directory"
1225
983
  });
1226
984
  },
1227
- rmdir(r) {
1228
- t({
985
+ rmdir(t) {
986
+ e({
1229
987
  operation: "DELETE",
1230
- path: r,
988
+ path: t,
1231
989
  nodeType: "directory"
1232
990
  });
1233
991
  },
1234
- rename(r, n) {
992
+ rename(t, n) {
1235
993
  try {
1236
- const s = e.lookupPath(r, {
994
+ const o = r.lookupPath(t, {
1237
995
  follow: !0
1238
- }), o = e.lookupPath(n, {
996
+ }), i = r.lookupPath(n, {
1239
997
  parent: !0
1240
998
  }).path;
1241
- t({
999
+ e({
1242
1000
  operation: "RENAME",
1243
- nodeType: e.isDir(s.node.mode) ? "directory" : "file",
1244
- path: s.path,
1245
- toPath: b(o, Ee(n))
1001
+ nodeType: r.isDir(o.node.mode) ? "directory" : "file",
1002
+ path: o.path,
1003
+ toPath: g(i, ee(n))
1246
1004
  });
1247
1005
  } catch {
1248
1006
  }
1249
1007
  }
1250
1008
  });
1251
- function* ie(e, t, r) {
1252
- if (e.isDir(t)) {
1009
+ function* $(r, e, t) {
1010
+ if (r.isDir(e)) {
1253
1011
  yield {
1254
1012
  operation: "CREATE",
1255
- path: r,
1013
+ path: t,
1256
1014
  nodeType: "directory"
1257
1015
  };
1258
- for (const n of e.listFiles(t))
1259
- yield* ie(
1260
- e,
1261
- b(t, n),
1262
- b(r, n)
1016
+ for (const n of r.listFiles(e))
1017
+ yield* $(
1018
+ r,
1019
+ g(e, n),
1020
+ g(t, n)
1263
1021
  );
1264
1022
  } else
1265
1023
  yield {
1266
1024
  operation: "CREATE",
1267
- path: r,
1025
+ path: t,
1268
1026
  nodeType: "file"
1269
1027
  }, yield {
1270
1028
  operation: "WRITE",
1271
1029
  nodeType: "file",
1272
- path: r
1030
+ path: t
1273
1031
  };
1274
1032
  }
1275
- function Ye(e) {
1276
- return e.replace(/\/$/, "").replace(/\/\/+/g, "/");
1033
+ function be(r) {
1034
+ return r.replace(/\/$/, "").replace(/\/\/+/g, "/");
1277
1035
  }
1278
- function ct(e, t = { initialSync: {} }) {
1279
- return t = {
1280
- ...t,
1036
+ function We(r, e = { initialSync: {} }) {
1037
+ return e = {
1038
+ ...e,
1281
1039
  initialSync: {
1282
- ...t.initialSync,
1283
- direction: t.initialSync.direction ?? "opfs-to-memfs"
1040
+ ...e.initialSync,
1041
+ direction: e.initialSync.direction ?? "opfs-to-memfs"
1284
1042
  }
1285
- }, async function(r, n, s) {
1286
- return t.initialSync.direction === "opfs-to-memfs" ? (R.fileExists(n, s) && R.rmdir(n, s), R.mkdir(n, s), await Ze(n, e, s)) : await ae(
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(
1287
1045
  n,
1288
- e,
1289
- s,
1290
- t.initialSync.onProgress
1291
- ), Xe(r, e, s);
1046
+ r,
1047
+ o,
1048
+ e.initialSync.onProgress
1049
+ ), ke(t, r, o);
1292
1050
  };
1293
1051
  }
1294
- async function Ze(e, t, r) {
1295
- R.mkdir(e, r);
1296
- const n = new ge({
1052
+ async function Ee(r, e, t) {
1053
+ v.mkdir(r, t);
1054
+ const n = new Y({
1297
1055
  concurrency: 40
1298
- }), s = [], o = [
1299
- [t, r]
1056
+ }), o = [], i = [
1057
+ [e, t]
1300
1058
  ];
1301
- for (; o.length > 0; ) {
1302
- const [i, a] = o.pop();
1303
- for await (const u of i.values()) {
1059
+ for (; i.length > 0; ) {
1060
+ const [s, a] = i.pop();
1061
+ for await (const c of s.values()) {
1304
1062
  const l = n.run(async () => {
1305
- const c = b(
1063
+ const u = g(
1306
1064
  a,
1307
- u.name
1065
+ c.name
1308
1066
  );
1309
- if (u.kind === "directory") {
1067
+ if (c.kind === "directory") {
1310
1068
  try {
1311
- e.mkdir(c);
1069
+ r.mkdir(u);
1312
1070
  } catch (d) {
1313
1071
  if ((d == null ? void 0 : d.errno) !== 20)
1314
- throw v.error(d), d;
1072
+ throw E.error(d), d;
1315
1073
  }
1316
- o.push([u, c]);
1317
- } else if (u.kind === "file") {
1318
- const d = await u.getFile(), f = new Uint8Array(await d.arrayBuffer());
1319
- e.createDataFile(
1074
+ i.push([c, u]);
1075
+ } else if (c.kind === "file") {
1076
+ const d = await c.getFile(), b = new Uint8Array(await d.arrayBuffer());
1077
+ r.createDataFile(
1320
1078
  a,
1321
- u.name,
1322
- f,
1079
+ c.name,
1080
+ b,
1323
1081
  !0,
1324
1082
  !0,
1325
1083
  !0
1326
1084
  );
1327
1085
  }
1328
- s.splice(s.indexOf(l), 1);
1086
+ o.splice(o.indexOf(l), 1);
1329
1087
  });
1330
- s.push(l);
1088
+ o.push(l);
1331
1089
  }
1332
- for (; o.length === 0 && s.length > 0; )
1333
- await Promise.any(s);
1090
+ for (; i.length === 0 && o.length > 0; )
1091
+ await Promise.any(o);
1334
1092
  }
1335
1093
  }
1336
- async function ae(e, t, r, n) {
1337
- e.mkdirTree(r);
1338
- const s = [];
1339
- async function o(u, l) {
1094
+ async function z(r, e, t, n) {
1095
+ r.mkdirTree(t);
1096
+ const o = [];
1097
+ async function i(c, l) {
1340
1098
  await Promise.all(
1341
- e.readdir(u).filter(
1342
- (c) => c !== "." && c !== ".."
1343
- ).map(async (c) => {
1344
- const d = b(u, c);
1345
- if (!Qe(e, d)) {
1346
- s.push([l, d, c]);
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]);
1347
1105
  return;
1348
1106
  }
1349
- const f = await l.getDirectoryHandle(c, {
1107
+ const b = await l.getDirectoryHandle(u, {
1350
1108
  create: !0
1351
1109
  });
1352
- return await o(d, f);
1110
+ return await i(d, b);
1353
1111
  })
1354
1112
  );
1355
1113
  }
1356
- await o(r, t);
1357
- let i = 0;
1358
- const a = s.map(
1359
- ([u, l, c]) => ce(u, c, e, l).then(() => {
1360
- n == null || n({ files: ++i, total: s.length });
1114
+ await i(t, e);
1115
+ 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 });
1361
1119
  })
1362
1120
  );
1363
1121
  await Promise.all(a);
1364
1122
  }
1365
- function Qe(e, t) {
1366
- return e.isDir(e.lookupPath(t, { follow: !0 }).node.mode);
1123
+ function ve(r, e) {
1124
+ return r.isDir(r.lookupPath(e, { follow: !0 }).node.mode);
1367
1125
  }
1368
- async function ce(e, t, r, n) {
1369
- let s;
1126
+ async function q(r, e, t, n) {
1127
+ let o;
1370
1128
  try {
1371
- s = r.readFile(n, {
1129
+ o = t.readFile(n, {
1372
1130
  encoding: "binary"
1373
1131
  });
1374
1132
  } catch {
1375
1133
  return;
1376
1134
  }
1377
- const o = await e.getFileHandle(t, { create: !0 }), i = o.createWritable !== void 0 ? (
1135
+ const i = await r.getFileHandle(e, { create: !0 }), s = i.createWritable !== void 0 ? (
1378
1136
  // Google Chrome, Firefox, probably more browsers
1379
- await o.createWritable()
1137
+ await i.createWritable()
1380
1138
  ) : (
1381
1139
  // Safari
1382
- await o.createSyncAccessHandle()
1140
+ await i.createSyncAccessHandle()
1383
1141
  );
1384
1142
  try {
1385
- await i.truncate(0), await i.write(s);
1143
+ await s.truncate(0), await s.write(o);
1386
1144
  } finally {
1387
- await i.close();
1145
+ await s.close();
1388
1146
  }
1389
1147
  }
1390
- function Xe(e, t, r) {
1391
- const n = [], s = Ge(e, r, (a) => {
1148
+ function ke(r, e, t) {
1149
+ const n = [], o = we(r, t, (a) => {
1392
1150
  n.push(a);
1393
- }), o = new et(e, t, r);
1394
- async function i() {
1395
- const a = await e.semaphore.acquire();
1151
+ }), i = new Te(r, e, t);
1152
+ async function s() {
1153
+ const a = await r.semaphore.acquire();
1396
1154
  try {
1397
1155
  for (; n.length; )
1398
- await o.processEntry(n.shift());
1156
+ await i.processEntry(n.shift());
1399
1157
  } finally {
1400
1158
  a();
1401
1159
  }
1402
1160
  }
1403
- return e.addEventListener("request.end", i), function() {
1404
- s(), e.removeEventListener("request.end", i);
1161
+ return r.addEventListener("request.end", s), function() {
1162
+ o(), r.removeEventListener("request.end", s);
1405
1163
  };
1406
1164
  }
1407
- class et {
1408
- constructor(t, r, n) {
1409
- this.php = t, this.opfs = r, this.memfsRoot = V(n);
1165
+ class Te {
1166
+ constructor(e, t, n) {
1167
+ this.php = e, this.opfs = t, this.memfsRoot = I(n);
1410
1168
  }
1411
- toOpfsPath(t) {
1412
- return V(t.substring(this.memfsRoot.length));
1169
+ toOpfsPath(e) {
1170
+ return I(e.substring(this.memfsRoot.length));
1413
1171
  }
1414
- async processEntry(t) {
1415
- if (!t.path.startsWith(this.memfsRoot) || t.path === this.memfsRoot)
1172
+ async processEntry(e) {
1173
+ if (!e.path.startsWith(this.memfsRoot) || e.path === this.memfsRoot)
1416
1174
  return;
1417
- const r = this.toOpfsPath(t.path), n = await G(this.opfs, r), s = U(r);
1418
- if (s)
1175
+ const t = this.toOpfsPath(e.path), n = await A(this.opfs, t), o = S(t);
1176
+ if (o)
1419
1177
  try {
1420
- if (t.operation === "DELETE")
1178
+ if (e.operation === "DELETE")
1421
1179
  try {
1422
- await n.removeEntry(s, {
1180
+ await n.removeEntry(o, {
1423
1181
  recursive: !0
1424
1182
  });
1425
1183
  } catch {
1426
1184
  }
1427
- else if (t.operation === "CREATE")
1428
- t.nodeType === "directory" ? await n.getDirectoryHandle(s, {
1185
+ else if (e.operation === "CREATE")
1186
+ e.nodeType === "directory" ? await n.getDirectoryHandle(o, {
1429
1187
  create: !0
1430
- }) : await n.getFileHandle(s, {
1188
+ }) : await n.getFileHandle(o, {
1431
1189
  create: !0
1432
1190
  });
1433
- else if (t.operation === "WRITE")
1434
- await ce(
1191
+ else if (e.operation === "WRITE")
1192
+ await q(
1435
1193
  n,
1436
- s,
1194
+ o,
1437
1195
  this.php[w].FS,
1438
- t.path
1196
+ e.path
1439
1197
  );
1440
- else if (t.operation === "RENAME" && t.toPath.startsWith(this.memfsRoot)) {
1441
- const o = this.toOpfsPath(t.toPath), i = await G(
1198
+ else if (e.operation === "RENAME" && e.toPath.startsWith(this.memfsRoot)) {
1199
+ const i = this.toOpfsPath(e.toPath), s = await A(
1442
1200
  this.opfs,
1443
- o
1444
- ), a = U(o);
1445
- if (t.nodeType === "directory") {
1446
- const u = await i.getDirectoryHandle(
1447
- s,
1201
+ i
1202
+ ), a = S(i);
1203
+ if (e.nodeType === "directory") {
1204
+ const c = await s.getDirectoryHandle(
1205
+ o,
1448
1206
  {
1449
1207
  create: !0
1450
1208
  }
1451
1209
  );
1452
- await ae(
1210
+ await z(
1453
1211
  this.php[w].FS,
1454
- u,
1455
- t.toPath
1456
- ), await n.removeEntry(s, {
1212
+ c,
1213
+ e.toPath
1214
+ ), await n.removeEntry(o, {
1457
1215
  recursive: !0
1458
1216
  });
1459
1217
  } else
1460
- (await n.getFileHandle(s)).move(i, a);
1218
+ (await n.getFileHandle(o)).move(s, a);
1461
1219
  }
1462
- } catch (o) {
1463
- throw v.log({ entry: t, name: s }), v.error(o), o;
1220
+ } catch (i) {
1221
+ throw E.log({ entry: e, name: o }), E.error(i), i;
1464
1222
  }
1465
1223
  }
1466
1224
  }
1467
- function V(e) {
1468
- return e.replace(/\/$/, "").replace(/\/\/+/g, "/");
1225
+ function I(r) {
1226
+ return r.replace(/\/$/, "").replace(/\/\/+/g, "/");
1469
1227
  }
1470
- function U(e) {
1471
- return e.substring(e.lastIndexOf("/") + 1);
1228
+ function S(r) {
1229
+ return r.substring(r.lastIndexOf("/") + 1);
1472
1230
  }
1473
- async function G(e, t) {
1474
- const r = t.replace(/^\/+|\/+$/g, "").replace(/\/+/, "/");
1475
- if (!r)
1476
- return e;
1477
- const n = r.split("/");
1478
- let s = e;
1479
- for (let o = 0; o < n.length - 1; o++) {
1480
- const i = n[o];
1481
- s = await s.getDirectoryHandle(i, { create: !0 });
1231
+ async function A(r, e) {
1232
+ const t = e.replace(/^\/+|\/+$/g, "").replace(/\/+/, "/");
1233
+ if (!t)
1234
+ 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 });
1482
1240
  }
1483
- return s;
1241
+ return o;
1484
1242
  }
1485
1243
  export {
1486
- tt as consumeAPI,
1487
- ct as createDirectoryHandleMountHandler,
1488
- rt as exposeAPI,
1489
- qe as getPHPLoaderModule,
1490
- st as loadWebRuntime,
1491
- ot as registerServiceWorker,
1492
- it as setupPostMessageRelay,
1493
- at as spawnPHPWorkerThread
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
1494
1252
  };