@wp-playground/client 0.1.40 → 0.1.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -5,14 +5,14 @@ function L(t) {
5
5
  const e = t.split(".").shift().replace("-", " ");
6
6
  return e.charAt(0).toUpperCase() + e.slice(1).toLowerCase();
7
7
  }
8
- async function E(t, e, r) {
8
+ async function P(t, e, r) {
9
9
  let s = "";
10
10
  await t.fileExists(e) && (s = await t.readFileAsText(e)), await t.writeFile(e, r(s));
11
11
  }
12
- async function Ce(t) {
12
+ async function ke(t) {
13
13
  return new Uint8Array(await t.arrayBuffer());
14
14
  }
15
- const ke = async (t, { plugin: e }, r) => {
15
+ const G = "/vfs-blueprints", J = "/vfs-blueprints/wp-config-consts.php", Oe = async (t, { plugin: e }, r) => {
16
16
  r?.tracker.setCaption(`Activating ${e}`);
17
17
  const i = x(
18
18
  await t.request({
@@ -24,20 +24,20 @@ const ke = async (t, { plugin: e }, r) => {
24
24
  await t.request({
25
25
  url: "/wp-admin/" + i
26
26
  });
27
- }, Fe = async (t, e) => {
28
- const r = new Oe(
27
+ }, Ae = async (t, e) => {
28
+ const r = new Le(
29
29
  t,
30
30
  e.siteUrl,
31
31
  e.wordpressPath || "/wordpress"
32
32
  );
33
33
  e.patchSqlitePlugin !== !1 && await r.patchSqlitePlugin(), e.addPhpInfo !== !1 && await r.addPhpInfo(), e.patchSiteUrl !== !1 && await r.patchSiteUrl(), e.disableSiteHealth !== !1 && await r.disableSiteHealth(), e.disableWpNewBlogNotification !== !1 && await r.disableWpNewBlogNotification();
34
34
  };
35
- class Oe {
35
+ class Le {
36
36
  constructor(e, r, s) {
37
37
  this.php = e, this.scopedSiteUrl = r, this.wordpressPath = s;
38
38
  }
39
39
  async patchSqlitePlugin() {
40
- await E(
40
+ await P(
41
41
  this.php,
42
42
  `${this.wordpressPath}/wp-content/plugins/sqlite-database-integration/wp-includes/sqlite/class-wp-sqlite-translator.php`,
43
43
  (e) => e.replace(
@@ -53,7 +53,7 @@ class Oe {
53
53
  );
54
54
  }
55
55
  async patchSiteUrl() {
56
- await E(
56
+ await P(
57
57
  this.php,
58
58
  `${this.wordpressPath}/wp-config.php`,
59
59
  (e) => `<?php
@@ -65,7 +65,7 @@ class Oe {
65
65
  );
66
66
  }
67
67
  async disableSiteHealth() {
68
- await E(
68
+ await P(
69
69
  this.php,
70
70
  `${this.wordpressPath}/wp-includes/default-filters.php`,
71
71
  (e) => e.replace(
@@ -75,7 +75,7 @@ class Oe {
75
75
  );
76
76
  }
77
77
  async disableWpNewBlogNotification() {
78
- await E(
78
+ await P(
79
79
  this.php,
80
80
  `${this.wordpressPath}/wp-config.php`,
81
81
  // The original version of this function crashes WASM PHP, let's define an empty one instead.
@@ -83,33 +83,33 @@ class Oe {
83
83
  );
84
84
  }
85
85
  }
86
- const Ae = async (t, { code: e }) => await t.run({ code: e }), Le = async (t, { options: e }) => await t.run(e), Ue = async (t, { key: e, value: r }) => {
86
+ const Ue = async (t, { code: e }) => await t.run({ code: e }), He = async (t, { options: e }) => await t.run(e), Ie = async (t, { key: e, value: r }) => {
87
87
  await t.setPhpIniEntry(e, r);
88
- }, He = async (t, { request: e }) => await t.request(e), Ie = async (t, { fromPath: e, toPath: r }) => {
88
+ }, Ne = async (t, { request: e }) => await t.request(e), Me = async (t, { fromPath: e, toPath: r }) => {
89
89
  await t.writeFile(
90
90
  r,
91
91
  await t.readFileAsBuffer(e)
92
92
  );
93
- }, Ne = async (t, { fromPath: e, toPath: r }) => {
93
+ }, We = async (t, { fromPath: e, toPath: r }) => {
94
94
  await t.mv(e, r);
95
- }, Me = async (t, { path: e }) => {
95
+ }, De = async (t, { path: e }) => {
96
96
  await t.mkdir(e);
97
- }, We = async (t, { path: e }) => {
97
+ }, ze = async (t, { path: e }) => {
98
98
  await t.unlink(e);
99
- }, De = async (t, { path: e }) => {
99
+ }, qe = async (t, { path: e }) => {
100
100
  await t.rmdir(e);
101
- }, ze = async (t, { path: e, data: r }) => {
102
- r instanceof File && (r = await Ce(r)), await t.writeFile(e, r);
103
- }, he = async (t, { consts: e }) => {
101
+ }, je = async (t, { path: e, data: r }) => {
102
+ r instanceof File && (r = await ke(r)), await t.writeFile(e, r);
103
+ }, pe = async (t, { consts: e }) => {
104
104
  const r = await t.documentRoot;
105
- await E(
105
+ await P(
106
106
  t,
107
107
  `${r}/playground-consts.json`,
108
108
  (s) => JSON.stringify({
109
109
  ...JSON.parse(s || "{}"),
110
110
  ...e
111
111
  })
112
- ), await E(
112
+ ), await P(
113
113
  t,
114
114
  `${r}/wp-config.php`,
115
115
  (s) => s.includes("playground-consts.json") ? s : `<?php
@@ -121,13 +121,13 @@ const Ae = async (t, { code: e }) => await t.run({ code: e }), Le = async (t, {
121
121
  }
122
122
  ?>${s}`
123
123
  );
124
- }, qe = async (t, { siteUrl: e }) => await he(t, {
124
+ }, Be = async (t, { siteUrl: e }) => await pe(t, {
125
125
  consts: {
126
126
  WP_HOME: e,
127
127
  WP_SITEURL: e
128
128
  }
129
129
  });
130
- class de {
130
+ class fe {
131
131
  constructor({ concurrency: e }) {
132
132
  this._running = 0, this.concurrency = e, this.queue = [];
133
133
  }
@@ -152,7 +152,7 @@ class de {
152
152
  }
153
153
  }
154
154
  }
155
- const je = Symbol("literal");
155
+ const Ve = Symbol("literal");
156
156
  function v(t) {
157
157
  if (typeof t == "string")
158
158
  return t.startsWith("$") ? t : JSON.stringify(t);
@@ -163,7 +163,7 @@ function v(t) {
163
163
  if (t === null)
164
164
  return "null";
165
165
  if (typeof t == "object")
166
- return je in t ? t.toString() : `array(${Object.entries(t).map(([r, s]) => `${JSON.stringify(r)} => ${v(s)}`).join(", ")})`;
166
+ return Ve in t ? t.toString() : `array(${Object.entries(t).map(([r, s]) => `${JSON.stringify(r)} => ${v(s)}`).join(", ")})`;
167
167
  if (typeof t == "function")
168
168
  return t();
169
169
  throw new Error(`Unsupported value: ${t}`);
@@ -174,7 +174,7 @@ function W(t) {
174
174
  e[r] = v(t[r]);
175
175
  return e;
176
176
  }
177
- const G = `<?php
177
+ const Y = `<?php
178
178
 
179
179
  function zipDir($dir, $output, $additionalFiles = array())
180
180
  {
@@ -237,28 +237,28 @@ function delTree($dir)
237
237
  return rmdir($dir);
238
238
  }
239
239
  `;
240
- async function Be(t) {
240
+ async function Ge(t) {
241
241
  const e = "wordpress-playground.zip", r = `/${e}`, s = W({
242
242
  zipPath: r,
243
243
  documentRoot: await t.documentRoot
244
244
  });
245
- await fe(
245
+ await ge(
246
246
  t,
247
247
  `zipDir(${s.documentRoot}, ${s.zipPath});`
248
248
  );
249
249
  const n = await t.readFileAsBuffer(r);
250
250
  return t.unlink(r), new File([n], e);
251
251
  }
252
- const Ve = async (t, { fullSiteZip: e }) => {
252
+ const Je = async (t, { fullSiteZip: e }) => {
253
253
  const r = "/import.zip";
254
254
  await t.writeFile(
255
255
  r,
256
256
  new Uint8Array(await e.arrayBuffer())
257
257
  );
258
258
  const s = await t.absoluteUrl, n = await t.documentRoot;
259
- await t.rmdir(n), await pe(t, { zipPath: r, extractToPath: "/" });
259
+ await t.rmdir(n), await me(t, { zipPath: r, extractToPath: "/" });
260
260
  const i = W({ absoluteUrl: s });
261
- await Ye(
261
+ await Qe(
262
262
  t,
263
263
  `${n}/wp-config.php`,
264
264
  (o) => `<?php
@@ -268,30 +268,30 @@ const Ve = async (t, { fullSiteZip: e }) => {
268
268
  }
269
269
  ?>${o}`
270
270
  );
271
- }, pe = async (t, { zipPath: e, extractToPath: r }) => {
271
+ }, me = async (t, { zipPath: e, extractToPath: r }) => {
272
272
  const s = W({
273
273
  zipPath: e,
274
274
  extractToPath: r
275
275
  });
276
- await fe(
276
+ await ge(
277
277
  t,
278
278
  `unzip(${s.zipPath}, ${s.extractToPath});`
279
279
  );
280
- }, Ge = async (t, { file: e }) => {
280
+ }, Ye = async (t, { file: e }) => {
281
281
  const r = await t.request({
282
282
  url: "/wp-admin/admin.php?import=wordpress"
283
- }), s = J(r).getElementById("import-upload-form")?.getAttribute("action"), n = await t.request({
283
+ }), s = K(r).getElementById("import-upload-form")?.getAttribute("action"), n = await t.request({
284
284
  url: `/wp-admin/${s}`,
285
285
  method: "POST",
286
286
  files: { import: e }
287
- }), i = J(n).querySelector(
287
+ }), i = K(n).querySelector(
288
288
  "#wpbody-content form"
289
289
  );
290
290
  if (!i)
291
291
  throw console.log(n.text), new Error(
292
292
  "Could not find an importer form in response. See the response text above for details."
293
293
  );
294
- const o = Je(i);
294
+ const o = Ke(i);
295
295
  o.fetch_attachments = "1";
296
296
  for (const a in o)
297
297
  if (a.startsWith("user_map[")) {
@@ -304,27 +304,27 @@ const Ve = async (t, { fullSiteZip: e }) => {
304
304
  formData: o
305
305
  });
306
306
  };
307
- function J(t) {
307
+ function K(t) {
308
308
  return new DOMParser().parseFromString(t.text, "text/html");
309
309
  }
310
- function Je(t) {
310
+ function Ke(t) {
311
311
  return Object.fromEntries(new FormData(t).entries());
312
312
  }
313
- async function Ye(t, e, r) {
313
+ async function Qe(t, e, r) {
314
314
  await t.writeFile(
315
315
  e,
316
316
  r(await t.readFileAsText(e))
317
317
  );
318
318
  }
319
- async function fe(t, e) {
319
+ async function ge(t, e) {
320
320
  const r = await t.run({
321
- code: G + e
321
+ code: Y + e
322
322
  });
323
323
  if (r.exitCode !== 0)
324
- throw console.log(G + e), console.log(e + ""), console.log(r.errors), r.errors;
324
+ throw console.log(Y + e), console.log(e + ""), console.log(r.errors), r.errors;
325
325
  return r;
326
326
  }
327
- const Ke = async (t, { pluginZipFile: e, options: r = {} }, s) => {
327
+ const Xe = async (t, { pluginZipFile: e, options: r = {} }, s) => {
328
328
  s?.tracker.setCaption(
329
329
  `Installing the ${L(e?.name)} plugin`
330
330
  );
@@ -352,14 +352,14 @@ const Ke = async (t, { pluginZipFile: e, options: r = {} }, s) => {
352
352
  }
353
353
  await t.isDir(
354
354
  "/wordpress/wp-content/plugins/gutenberg"
355
- ) && !await t.fileExists("/wordpress/.gutenberg-patched") && (await t.writeFile("/wordpress/.gutenberg-patched", "1"), await Y(
355
+ ) && !await t.fileExists("/wordpress/.gutenberg-patched") && (await t.writeFile("/wordpress/.gutenberg-patched", "1"), await Q(
356
356
  t,
357
357
  "/wordpress/wp-content/plugins/gutenberg/build/block-editor/index.js",
358
358
  (d) => d.replace(
359
359
  /srcDoc:("[^"]+"|[^,]+)/g,
360
360
  'src:"/wp-includes/empty.html"'
361
361
  )
362
- ), await Y(
362
+ ), await Q(
363
363
  t,
364
364
  "/wordpress/wp-content/plugins/gutenberg/build/block-editor/index.min.js",
365
365
  (d) => d.replace(
@@ -373,13 +373,13 @@ const Ke = async (t, { pluginZipFile: e, options: r = {} }, s) => {
373
373
  ), console.error(n);
374
374
  }
375
375
  };
376
- async function Y(t, e, r) {
376
+ async function Q(t, e, r) {
377
377
  return await t.writeFile(
378
378
  e,
379
379
  r(await t.readFileAsText(e))
380
380
  );
381
381
  }
382
- const Qe = async (t, { themeZipFile: e, options: r = {} }, s) => {
382
+ const Ze = async (t, { themeZipFile: e, options: r = {} }, s) => {
383
383
  s?.tracker.setCaption(
384
384
  `Installing the ${L(e.name)} theme`
385
385
  );
@@ -413,12 +413,12 @@ const Qe = async (t, { themeZipFile: e, options: r = {} }, s) => {
413
413
  console.error('The "activate" button was not found.');
414
414
  return;
415
415
  }
416
- const xe = y.attributes.getNamedItem("href").value, Te = new URL(
417
- xe,
416
+ const Ce = y.attributes.getNamedItem("href").value, Fe = new URL(
417
+ Ce,
418
418
  await t.pathToInternalUrl("/wp-admin/")
419
419
  ).toString();
420
420
  await t.request({
421
- url: Te
421
+ url: Fe
422
422
  });
423
423
  }
424
424
  } catch (n) {
@@ -426,7 +426,7 @@ const Qe = async (t, { themeZipFile: e, options: r = {} }, s) => {
426
426
  `Proceeding without the ${e.name} theme. Could not install it in wp-admin. The original error was: ${n}`
427
427
  ), console.error(n);
428
428
  }
429
- }, Xe = async (t, { username: e = "admin", password: r = "password" } = {}, s) => {
429
+ }, et = async (t, { username: e = "admin", password: r = "password" } = {}, s) => {
430
430
  s?.tracker.setCaption(s?.initialCaption || "Logging in"), await t.request({
431
431
  url: "/wp-login.php"
432
432
  }), await t.request({
@@ -438,7 +438,7 @@ const Qe = async (t, { themeZipFile: e, options: r = {} }, s) => {
438
438
  rememberme: "forever"
439
439
  }
440
440
  });
441
- }, Ze = async (t, { options: e }) => {
441
+ }, tt = async (t, { options: e }) => {
442
442
  await t.request({
443
443
  url: "/wp-admin/install.php?step=2",
444
444
  method: "POST",
@@ -455,7 +455,7 @@ const Qe = async (t, { themeZipFile: e, options: r = {} }, s) => {
455
455
  admin_email: "admin@localhost.com"
456
456
  }
457
457
  });
458
- }, et = async (t, { options: e }) => {
458
+ }, rt = async (t, { options: e }) => {
459
459
  const r = `<?php
460
460
  include 'wordpress/wp-load.php';
461
461
  $site_options = ${v(e)};
@@ -466,8 +466,8 @@ const Qe = async (t, { themeZipFile: e, options: r = {} }, s) => {
466
466
  `, s = await t.run({
467
467
  code: r
468
468
  });
469
- return me(s), { code: r, result: s };
470
- }, tt = async (t, { meta: e, userId: r }) => {
469
+ return we(s), { code: r, result: s };
470
+ }, st = async (t, { meta: e, userId: r }) => {
471
471
  const s = `<?php
472
472
  include 'wordpress/wp-load.php';
473
473
  $meta = ${v(e)};
@@ -478,41 +478,60 @@ const Qe = async (t, { themeZipFile: e, options: r = {} }, s) => {
478
478
  `, n = await t.run({
479
479
  code: s
480
480
  });
481
- return me(n), { code: s, result: n };
481
+ return we(n), { code: s, result: n };
482
482
  };
483
- async function me(t) {
483
+ async function we(t) {
484
484
  if (t.text !== "Success")
485
485
  throw console.log(t), new Error(`Failed to run code: ${t.text} ${t.errors}`);
486
486
  }
487
- const rt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
487
+ const nt = async (t, { consts: e }) => {
488
+ t.mkdir(G);
489
+ const r = `${G}/playground-consts.json`;
490
+ return await P(
491
+ t,
492
+ r,
493
+ (s) => JSON.stringify({
494
+ ...JSON.parse(s || "{}"),
495
+ ...e
496
+ })
497
+ ), await P(t, J, (s) => s.includes("playground-consts.json") ? s : `<?php
498
+ $consts = json_decode(file_get_contents('${r}'), true);
499
+ foreach ($consts as $const => $value) {
500
+ if (!defined($const)) {
501
+ define($const, $value);
502
+ }
503
+ }
504
+ ?>${s}`), J;
505
+ }, it = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
488
506
  __proto__: null,
489
- activatePlugin: ke,
490
- applyWordPressPatches: Fe,
491
- cp: Ie,
492
- defineSiteUrl: qe,
493
- defineWpConfigConsts: he,
494
- importFile: Ge,
495
- installPlugin: Ke,
496
- installTheme: Qe,
497
- login: Xe,
498
- mkdir: Me,
499
- mv: Ne,
500
- replaceSite: Ve,
501
- request: He,
502
- rm: We,
503
- rmdir: De,
504
- runPHP: Ae,
505
- runPHPWithOptions: Le,
506
- runWpInstallationWizard: Ze,
507
- setPhpIniEntry: Ue,
508
- setSiteOptions: et,
509
- unzip: pe,
510
- updateUserMeta: tt,
511
- writeFile: ze,
512
- zipEntireSite: Be
513
- }, Symbol.toStringTag, { value: "Module" })), st = 5 * 1024 * 1024;
514
- function nt(t, e) {
515
- const r = t.headers.get("content-length") || "", s = parseInt(r, 10) || st;
507
+ activatePlugin: Oe,
508
+ applyWordPressPatches: Ae,
509
+ cp: Me,
510
+ defineSiteUrl: Be,
511
+ defineVirtualWpConfigConsts: nt,
512
+ defineWpConfigConsts: pe,
513
+ importFile: Ye,
514
+ installPlugin: Xe,
515
+ installTheme: Ze,
516
+ login: et,
517
+ mkdir: De,
518
+ mv: We,
519
+ replaceSite: Je,
520
+ request: Ne,
521
+ rm: ze,
522
+ rmdir: qe,
523
+ runPHP: Ue,
524
+ runPHPWithOptions: He,
525
+ runWpInstallationWizard: tt,
526
+ setPhpIniEntry: Ie,
527
+ setSiteOptions: rt,
528
+ unzip: me,
529
+ updateUserMeta: st,
530
+ writeFile: je,
531
+ zipEntireSite: Ge
532
+ }, Symbol.toStringTag, { value: "Module" })), ot = 5 * 1024 * 1024;
533
+ function at(t, e) {
534
+ const r = t.headers.get("content-length") || "", s = parseInt(r, 10) || ot;
516
535
  function n(i, o) {
517
536
  e(
518
537
  new CustomEvent("progress", {
@@ -720,6 +739,151 @@ class U extends EventTarget {
720
739
  this.dispatchEvent(new CustomEvent("done"));
721
740
  }
722
741
  }
742
+ const X = Symbol("error"), Z = Symbol("message");
743
+ class D extends Event {
744
+ /**
745
+ * Create a new `ErrorEvent`.
746
+ *
747
+ * @param type The name of the event
748
+ * @param options A dictionary object that allows for setting
749
+ * attributes via object members of the same name.
750
+ */
751
+ constructor(e, r = {}) {
752
+ super(e), this[X] = r.error === void 0 ? null : r.error, this[Z] = r.message === void 0 ? "" : r.message;
753
+ }
754
+ get error() {
755
+ return this[X];
756
+ }
757
+ get message() {
758
+ return this[Z];
759
+ }
760
+ }
761
+ Object.defineProperty(D.prototype, "error", { enumerable: !0 });
762
+ Object.defineProperty(D.prototype, "message", { enumerable: !0 });
763
+ const ct = typeof globalThis.ErrorEvent == "function" ? globalThis.ErrorEvent : D;
764
+ class lt extends EventTarget {
765
+ constructor() {
766
+ super(...arguments), this.listenersCount = 0;
767
+ }
768
+ addEventListener(e, r) {
769
+ ++this.listenersCount, super.addEventListener(e, r);
770
+ }
771
+ removeEventListener(e, r) {
772
+ --this.listenersCount, super.removeEventListener(e, r);
773
+ }
774
+ hasListeners() {
775
+ return this.listenersCount > 0;
776
+ }
777
+ }
778
+ function ut(t) {
779
+ t.asm = {
780
+ ...t.asm
781
+ };
782
+ const e = new lt();
783
+ for (const r in t.asm)
784
+ if (typeof t.asm[r] == "function") {
785
+ const s = t.asm[r];
786
+ t.asm[r] = function(...n) {
787
+ try {
788
+ return s(...n);
789
+ } catch (i) {
790
+ if (!(i instanceof Error))
791
+ throw i;
792
+ if ("exitCode" in i && i?.exitCode === 0)
793
+ return;
794
+ const o = dt(
795
+ i,
796
+ t.lastAsyncifyStackSource?.stack
797
+ );
798
+ if (t.lastAsyncifyStackSource && (i.cause = t.lastAsyncifyStackSource), !e.hasListeners())
799
+ throw mt(o), i;
800
+ e.dispatchEvent(
801
+ new ct("error", {
802
+ error: i,
803
+ message: o
804
+ })
805
+ );
806
+ }
807
+ };
808
+ }
809
+ return e;
810
+ }
811
+ let N = [];
812
+ function ht() {
813
+ return N;
814
+ }
815
+ function dt(t, e) {
816
+ if (t.message === "unreachable") {
817
+ let r = pt;
818
+ e || (r += `
819
+
820
+ This stack trace is lacking. For a better one initialize
821
+ the PHP runtime with { debug: true }, e.g. PHPNode.load('8.1', { debug: true }).
822
+
823
+ `), N = gt(
824
+ e || t.stack || ""
825
+ );
826
+ for (const s of N)
827
+ r += ` * ${s}
828
+ `;
829
+ return r;
830
+ }
831
+ return t.message;
832
+ }
833
+ const pt = `
834
+ "unreachable" WASM instruction executed.
835
+
836
+ The typical reason is a PHP function missing from the ASYNCIFY_ONLY
837
+ list when building PHP.wasm.
838
+
839
+ You will need to file a new issue in the WordPress Playground repository
840
+ and paste this error message there:
841
+
842
+ https://github.com/WordPress/wordpress-playground/issues/new
843
+
844
+ If you're a core developer, the typical fix is to:
845
+
846
+ * Isolate a minimal reproduction of the error
847
+ * Add a reproduction of the error to php-asyncify.spec.ts in the WordPress Playground repository
848
+ * Run 'npm run fix-asyncify'
849
+ * Commit the changes, push to the repo, release updated NPM packages
850
+
851
+ Below is a list of all the PHP functions found in the stack trace to
852
+ help with the minimal reproduction. If they're all already listed in
853
+ the Dockerfile, you'll need to trigger this error again with long stack
854
+ traces enabled. In node.js, you can do it using the --stack-trace-limit=100
855
+ CLI option:
856
+
857
+ `, ee = "\x1B[41m", ft = "\x1B[1m", te = "\x1B[0m", re = "\x1B[K";
858
+ let se = !1;
859
+ function mt(t) {
860
+ if (!se) {
861
+ se = !0, console.log(`${ee}
862
+ ${re}
863
+ ${ft} WASM ERROR${te}${ee}`);
864
+ for (const e of t.split(`
865
+ `))
866
+ console.log(`${re} ${e} `);
867
+ console.log(`${te}`);
868
+ }
869
+ }
870
+ function gt(t) {
871
+ try {
872
+ const e = t.split(`
873
+ `).slice(1).map((r) => {
874
+ const s = r.trim().substring(3).split(" ");
875
+ return {
876
+ fn: s.length >= 2 ? s[0] : "<unknown>",
877
+ isWasm: r.includes("wasm://")
878
+ };
879
+ }).filter(
880
+ ({ fn: r, isWasm: s }) => s && !r.startsWith("dynCall_") && !r.startsWith("invoke_")
881
+ ).map(({ fn: r }) => r);
882
+ return Array.from(new Set(e));
883
+ } catch {
884
+ return [];
885
+ }
886
+ }
723
887
  class S {
724
888
  constructor(e, r, s, n = "", i = 0) {
725
889
  this.httpStatusCode = e, this.headers = r, this.bytes = s, this.exitCode = i, this.errors = n;
@@ -755,7 +919,7 @@ class S {
755
919
  return new TextDecoder().decode(this.bytes);
756
920
  }
757
921
  }
758
- const D = [
922
+ const z = [
759
923
  "8.2",
760
924
  "8.1",
761
925
  "8.0",
@@ -765,8 +929,8 @@ const D = [
765
929
  "7.1",
766
930
  "7.0",
767
931
  "5.6"
768
- ], it = D[0], rr = D;
769
- class ot {
932
+ ], wt = z[0], ir = z;
933
+ class yt {
770
934
  #e;
771
935
  #t;
772
936
  /**
@@ -799,10 +963,10 @@ class ot {
799
963
  ...e,
800
964
  headers: {
801
965
  ...e.headers,
802
- cookie: this.#n()
966
+ cookie: this.#r()
803
967
  }
804
968
  });
805
- if (s.headers["set-cookie"] && this.#r(s.headers["set-cookie"]), this.#t.handleRedirects && s.headers.location && r < this.#t.maxRedirects) {
969
+ if (s.headers["set-cookie"] && this.#s(s.headers["set-cookie"]), this.#t.handleRedirects && s.headers.location && r < this.#t.maxRedirects) {
806
970
  const n = new URL(
807
971
  s.headers.location[0],
808
972
  this.requestHandler.absoluteUrl
@@ -834,7 +998,7 @@ class ot {
834
998
  get documentRoot() {
835
999
  return this.requestHandler.documentRoot;
836
1000
  }
837
- #r(e) {
1001
+ #s(e) {
838
1002
  for (const r of e)
839
1003
  try {
840
1004
  if (!r.includes("="))
@@ -845,30 +1009,30 @@ class ot {
845
1009
  console.error(s);
846
1010
  }
847
1011
  }
848
- #n() {
1012
+ #r() {
849
1013
  const e = [];
850
1014
  for (const r in this.#e)
851
1015
  e.push(`${r}=${this.#e[r]}`);
852
1016
  return e.join("; ");
853
1017
  }
854
1018
  }
855
- const at = "http://example.com";
856
- function K(t) {
1019
+ const Pt = "http://example.com";
1020
+ function ne(t) {
857
1021
  return t.toString().substring(t.origin.length);
858
1022
  }
859
- function Q(t, e) {
1023
+ function ie(t, e) {
860
1024
  return !e || !t.startsWith(e) ? t : t.substring(e.length);
861
1025
  }
862
- function ct(t, e) {
1026
+ function bt(t, e) {
863
1027
  return !e || t.startsWith(e) ? t : e + t;
864
1028
  }
865
- class lt {
1029
+ class _t {
866
1030
  #e;
867
1031
  #t;
1032
+ #s;
868
1033
  #r;
869
- #n;
870
1034
  #i;
871
- #s;
1035
+ #n;
872
1036
  #o;
873
1037
  #a;
874
1038
  #c;
@@ -877,7 +1041,7 @@ class lt {
877
1041
  * @param config - Request Handler configuration.
878
1042
  */
879
1043
  constructor(e, r = {}) {
880
- this.#a = new de({ concurrency: 1 });
1044
+ this.#a = new fe({ concurrency: 1 });
881
1045
  const {
882
1046
  documentRoot: s = "/www/",
883
1047
  absoluteUrl: n = typeof location == "object" ? location?.href : "",
@@ -885,15 +1049,15 @@ class lt {
885
1049
  } = r;
886
1050
  this.php = e, this.#e = s, this.#c = i;
887
1051
  const o = new URL(n);
888
- this.#r = o.hostname, this.#n = o.port ? Number(o.port) : o.protocol === "https:" ? 443 : 80, this.#t = (o.protocol || "").replace(":", "");
889
- const a = this.#n !== 443 && this.#n !== 80;
1052
+ this.#s = o.hostname, this.#r = o.port ? Number(o.port) : o.protocol === "https:" ? 443 : 80, this.#t = (o.protocol || "").replace(":", "");
1053
+ const a = this.#r !== 443 && this.#r !== 80;
890
1054
  this.#i = [
891
- this.#r,
892
- a ? `:${this.#n}` : ""
893
- ].join(""), this.#s = o.pathname.replace(/\/+$/, ""), this.#o = [
1055
+ this.#s,
1056
+ a ? `:${this.#r}` : ""
1057
+ ].join(""), this.#n = o.pathname.replace(/\/+$/, ""), this.#o = [
894
1058
  `${this.#t}://`,
895
1059
  this.#i,
896
- this.#s
1060
+ this.#n
897
1061
  ].join("");
898
1062
  }
899
1063
  /** @inheritDoc */
@@ -903,7 +1067,7 @@ class lt {
903
1067
  /** @inheritDoc */
904
1068
  internalUrlToPath(e) {
905
1069
  const r = new URL(e);
906
- return r.pathname.startsWith(this.#s) && (r.pathname = r.pathname.slice(this.#s.length)), K(r);
1070
+ return r.pathname.startsWith(this.#n) && (r.pathname = r.pathname.slice(this.#n.length)), ne(r);
907
1071
  }
908
1072
  get isRequestRunning() {
909
1073
  return this.#a.running > 0;
@@ -920,10 +1084,10 @@ class lt {
920
1084
  async request(e) {
921
1085
  const r = e.url.startsWith("http://") || e.url.startsWith("https://"), s = new URL(
922
1086
  e.url,
923
- r ? void 0 : at
924
- ), n = Q(
1087
+ r ? void 0 : Pt
1088
+ ), n = ie(
925
1089
  s.pathname,
926
- this.#s
1090
+ this.#n
927
1091
  );
928
1092
  return this.#c(n) ? this.#l(n) : await this.#u(e, s);
929
1093
  }
@@ -949,7 +1113,7 @@ class lt {
949
1113
  // @TODO: Infer the content-type from the arrayBuffer instead of the file path.
950
1114
  // The code below won't return the correct mime-type if the extension
951
1115
  // was tampered with.
952
- "content-type": [ht(r)],
1116
+ "content-type": [Et(r)],
953
1117
  "accept-ranges": ["bytes"],
954
1118
  "cache-control": ["public, max-age=0"]
955
1119
  },
@@ -973,7 +1137,7 @@ class lt {
973
1137
  let n = "GET";
974
1138
  const i = {
975
1139
  host: this.#i,
976
- ...ge(e.headers || {})
1140
+ ...ye(e.headers || {})
977
1141
  }, o = [];
978
1142
  if (e.files && Object.keys(e.files).length) {
979
1143
  n = "POST";
@@ -986,7 +1150,7 @@ class lt {
986
1150
  data: new Uint8Array(await l.arrayBuffer())
987
1151
  });
988
1152
  }
989
- i["content-type"]?.startsWith("multipart/form-data") && (e.formData = ut(
1153
+ i["content-type"]?.startsWith("multipart/form-data") && (e.formData = $t(
990
1154
  e.body || ""
991
1155
  ), i["content-type"] = "application/x-www-form-urlencoded", delete e.body);
992
1156
  }
@@ -994,9 +1158,9 @@ class lt {
994
1158
  return e.formData !== void 0 ? (n = "POST", i["content-type"] = i["content-type"] || "application/x-www-form-urlencoded", a = new URLSearchParams(
995
1159
  e.formData
996
1160
  ).toString()) : a = e.body, await this.php.run({
997
- relativeUri: ct(
998
- K(r),
999
- this.#s
1161
+ relativeUri: bt(
1162
+ ne(r),
1163
+ this.#n
1000
1164
  ),
1001
1165
  protocol: this.#t,
1002
1166
  method: e.method || n,
@@ -1018,13 +1182,13 @@ class lt {
1018
1182
  * @returns The resolved filesystem path.
1019
1183
  */
1020
1184
  #h(e) {
1021
- let r = Q(e, this.#s);
1185
+ let r = ie(e, this.#n);
1022
1186
  r.includes(".php") ? r = r.split(".php")[0] + ".php" : (r.endsWith("/") || (r += "/"), r.endsWith("index.php") || (r += "index.php"));
1023
1187
  const s = `${this.#e}${r}`;
1024
1188
  return this.php.fileExists(s) ? s : `${this.#e}/index.php`;
1025
1189
  }
1026
1190
  }
1027
- function ut(t) {
1191
+ function $t(t) {
1028
1192
  const e = {}, r = t.match(/--(.*)\r\n/);
1029
1193
  if (!r)
1030
1194
  return e;
@@ -1039,7 +1203,7 @@ function ut(t) {
1039
1203
  }
1040
1204
  }), e;
1041
1205
  }
1042
- function ht(t) {
1206
+ function Et(t) {
1043
1207
  switch (t.split(".").pop()) {
1044
1208
  case "css":
1045
1209
  return "text/css";
@@ -1079,7 +1243,7 @@ function ht(t) {
1079
1243
  return "application-octet-stream";
1080
1244
  }
1081
1245
  }
1082
- const X = {
1246
+ const oe = {
1083
1247
  0: "No error occurred. System call completed successfully.",
1084
1248
  1: "Argument list too long.",
1085
1249
  2: "Permission denied.",
@@ -1166,8 +1330,8 @@ function m(t = "") {
1166
1330
  return i.apply(this, o);
1167
1331
  } catch (a) {
1168
1332
  const c = typeof a == "object" ? a?.errno : null;
1169
- if (c in X) {
1170
- const l = X[c], u = typeof o[0] == "string" ? o[0] : null, d = u !== null ? t.replaceAll("{path}", u) : t;
1333
+ if (c in oe) {
1334
+ const l = oe[c], u = typeof o[0] == "string" ? o[0] : null, d = u !== null ? t.replaceAll("{path}", u) : t;
1171
1335
  throw new Error(`${d}: ${l}`, {
1172
1336
  cause: a
1173
1337
  });
@@ -1177,164 +1341,19 @@ function m(t = "") {
1177
1341
  };
1178
1342
  };
1179
1343
  }
1180
- const dt = [];
1181
- function pt(t) {
1182
- return dt[t];
1344
+ const vt = [];
1345
+ function St(t) {
1346
+ return vt[t];
1183
1347
  }
1184
1348
  (function() {
1185
1349
  return typeof process < "u" && process.release?.name === "node" ? "NODE" : typeof window < "u" ? "WEB" : typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope ? "WORKER" : "NODE";
1186
1350
  })();
1187
- const Z = Symbol("error"), ee = Symbol("message");
1188
- class z extends Event {
1189
- /**
1190
- * Create a new `ErrorEvent`.
1191
- *
1192
- * @param type The name of the event
1193
- * @param options A dictionary object that allows for setting
1194
- * attributes via object members of the same name.
1195
- */
1196
- constructor(e, r = {}) {
1197
- super(e), this[Z] = r.error === void 0 ? null : r.error, this[ee] = r.message === void 0 ? "" : r.message;
1198
- }
1199
- get error() {
1200
- return this[Z];
1201
- }
1202
- get message() {
1203
- return this[ee];
1204
- }
1205
- }
1206
- Object.defineProperty(z.prototype, "error", { enumerable: !0 });
1207
- Object.defineProperty(z.prototype, "message", { enumerable: !0 });
1208
- const ft = typeof globalThis.ErrorEvent == "function" ? globalThis.ErrorEvent : z;
1209
- class mt extends EventTarget {
1210
- constructor() {
1211
- super(...arguments), this.listenersCount = 0;
1212
- }
1213
- addEventListener(e, r) {
1214
- ++this.listenersCount, super.addEventListener(e, r);
1215
- }
1216
- removeEventListener(e, r) {
1217
- --this.listenersCount, super.removeEventListener(e, r);
1218
- }
1219
- hasListeners() {
1220
- return this.listenersCount > 0;
1221
- }
1222
- }
1223
- function gt(t) {
1224
- t.asm = {
1225
- ...t.asm
1226
- };
1227
- const e = new mt();
1228
- for (const r in t.asm)
1229
- if (typeof t.asm[r] == "function") {
1230
- const s = t.asm[r];
1231
- t.asm[r] = function(...n) {
1232
- try {
1233
- return s(...n);
1234
- } catch (i) {
1235
- if (!(i instanceof Error))
1236
- throw i;
1237
- if ("exitCode" in i && i?.exitCode === 0)
1238
- return;
1239
- const o = yt(
1240
- i,
1241
- t.lastAsyncifyStackSource?.stack
1242
- );
1243
- if (t.lastAsyncifyStackSource && (i.cause = t.lastAsyncifyStackSource), !e.hasListeners())
1244
- throw _t(o), i;
1245
- e.dispatchEvent(
1246
- new ft("error", {
1247
- error: i,
1248
- message: o
1249
- })
1250
- );
1251
- }
1252
- };
1253
- }
1254
- return e;
1255
- }
1256
- let N = [];
1257
- function wt() {
1258
- return N;
1259
- }
1260
- function yt(t, e) {
1261
- if (t.message === "unreachable") {
1262
- let r = Pt;
1263
- e || (r += `
1264
-
1265
- This stack trace is lacking. For a better one initialize
1266
- the PHP runtime with { debug: true }, e.g. PHPNode.load('8.1', { debug: true }).
1267
-
1268
- `), N = $t(
1269
- e || t.stack || ""
1270
- );
1271
- for (const s of N)
1272
- r += ` * ${s}
1273
- `;
1274
- return r;
1275
- }
1276
- return t.message;
1277
- }
1278
- const Pt = `
1279
- "unreachable" WASM instruction executed.
1280
-
1281
- The typical reason is a PHP function missing from the ASYNCIFY_ONLY
1282
- list when building PHP.wasm.
1283
-
1284
- You will need to file a new issue in the WordPress Playground repository
1285
- and paste this error message there:
1286
-
1287
- https://github.com/WordPress/wordpress-playground/issues/new
1288
-
1289
- If you're a core developer, the typical fix is to:
1290
-
1291
- * Isolate a minimal reproduction of the error
1292
- * Add a reproduction of the error to php-asyncify.spec.ts in the WordPress Playground repository
1293
- * Run 'npm run fix-asyncify'
1294
- * Commit the changes, push to the repo, release updated NPM packages
1295
-
1296
- Below is a list of all the PHP functions found in the stack trace to
1297
- help with the minimal reproduction. If they're all already listed in
1298
- the Dockerfile, you'll need to trigger this error again with long stack
1299
- traces enabled. In node.js, you can do it using the --stack-trace-limit=100
1300
- CLI option:
1301
-
1302
- `, te = "\x1B[41m", bt = "\x1B[1m", re = "\x1B[0m", se = "\x1B[K";
1303
- let ne = !1;
1304
- function _t(t) {
1305
- if (!ne) {
1306
- ne = !0, console.log(`${te}
1307
- ${se}
1308
- ${bt} WASM ERROR${re}${te}`);
1309
- for (const e of t.split(`
1310
- `))
1311
- console.log(`${se} ${e} `);
1312
- console.log(`${re}`);
1313
- }
1314
- }
1315
- function $t(t) {
1316
- try {
1317
- const e = t.split(`
1318
- `).slice(1).map((r) => {
1319
- const s = r.trim().substring(3).split(" ");
1320
- return {
1321
- fn: s.length >= 2 ? s[0] : "<unknown>",
1322
- isWasm: r.includes("wasm://")
1323
- };
1324
- }).filter(
1325
- ({ fn: r, isWasm: s }) => s && !r.startsWith("dynCall_") && !r.startsWith("invoke_")
1326
- ).map(({ fn: r }) => r);
1327
- return Array.from(new Set(e));
1328
- } catch {
1329
- return [];
1330
- }
1331
- }
1332
- var Et = Object.defineProperty, vt = Object.getOwnPropertyDescriptor, g = (t, e, r, s) => {
1333
- for (var n = s > 1 ? void 0 : s ? vt(e, r) : e, i = t.length - 1, o; i >= 0; i--)
1351
+ var Rt = Object.defineProperty, xt = Object.getOwnPropertyDescriptor, g = (t, e, r, s) => {
1352
+ for (var n = s > 1 ? void 0 : s ? xt(e, r) : e, i = t.length - 1, o; i >= 0; i--)
1334
1353
  (o = t[i]) && (n = (s ? o(e, r, n) : o(n)) || n);
1335
- return s && n && Et(e, r, n), n;
1354
+ return s && n && Rt(e, r, n), n;
1336
1355
  };
1337
- const f = "string", _ = "number", h = Symbol("__private__dont__use");
1356
+ const f = "string", $ = "number", h = Symbol("__private__dont__use");
1338
1357
  class w {
1339
1358
  /**
1340
1359
  * Initializes a PHP runtime.
@@ -1344,12 +1363,13 @@ class w {
1344
1363
  * @param serverOptions - Optional. Options for the PHPRequestHandler. If undefined, no request handler will be initialized.
1345
1364
  */
1346
1365
  constructor(e, r) {
1347
- this.#e = [], this.#t = !1, this.#r = null, e !== void 0 && this.initializeRuntime(e), r && (this.requestHandler = new ot(
1348
- new lt(this, r)
1366
+ this.#e = [], this.#t = !1, this.#s = null, this.#r = {}, e !== void 0 && this.initializeRuntime(e), r && (this.requestHandler = new yt(
1367
+ new _t(this, r)
1349
1368
  ));
1350
1369
  }
1351
1370
  #e;
1352
1371
  #t;
1372
+ #s;
1353
1373
  #r;
1354
1374
  /** @inheritDoc */
1355
1375
  get absoluteUrl() {
@@ -1372,10 +1392,10 @@ class w {
1372
1392
  initializeRuntime(e) {
1373
1393
  if (this[h])
1374
1394
  throw new Error("PHP runtime already initialized.");
1375
- const r = pt(e);
1395
+ const r = St(e);
1376
1396
  if (!r)
1377
1397
  throw new Error("Invalid PHP runtime id.");
1378
- this[h] = r, this.#r = gt(r);
1398
+ this[h] = r, this.#s = ut(r);
1379
1399
  }
1380
1400
  /** @inheritDoc */
1381
1401
  setPhpIniPath(e) {
@@ -1406,17 +1426,17 @@ class w {
1406
1426
  }
1407
1427
  /** @inheritDoc */
1408
1428
  async run(e) {
1409
- this.#t || (this.#n(), this.#t = !0), this.#u(e.scriptPath || ""), this.#s(e.relativeUri || ""), this.#a(e.method || "GET");
1429
+ this.#t || (this.#i(), this.#t = !0), this.#h(e.scriptPath || ""), this.#o(e.relativeUri || ""), this.#c(e.method || "GET");
1410
1430
  const { host: r, ...s } = {
1411
1431
  host: "example.com:443",
1412
- ...ge(e.headers || {})
1432
+ ...ye(e.headers || {})
1413
1433
  };
1414
- if (this.#o(r, e.protocol || "http"), this.#c(s), e.body && this.#l(e.body), e.fileInfos)
1434
+ if (this.#a(r, e.protocol || "http"), this.#l(s), e.body && this.#u(e.body), e.fileInfos)
1415
1435
  for (const n of e.fileInfos)
1416
- this.#h(n);
1417
- return e.code && this.#d(" ?>" + e.code), await this.#p();
1436
+ this.#p(n);
1437
+ return e.code && this.#f(" ?>" + e.code), this.#d(), await this.#m();
1418
1438
  }
1419
- #n() {
1439
+ #i() {
1420
1440
  if (this.#e.length > 0) {
1421
1441
  const e = this.#e.map(([r, s]) => `${r}=${s}`).join(`
1422
1442
  `) + `
@@ -1431,7 +1451,7 @@ class w {
1431
1451
  }
1432
1452
  this[h].ccall("php_wasm_init", null, [], []);
1433
1453
  }
1434
- #i() {
1454
+ #n() {
1435
1455
  const e = "/tmp/headers.json";
1436
1456
  if (!this.fileExists(e))
1437
1457
  throw new Error(
@@ -1449,7 +1469,7 @@ class w {
1449
1469
  httpStatusCode: r.status
1450
1470
  };
1451
1471
  }
1452
- #s(e) {
1472
+ #o(e) {
1453
1473
  if (this[h].ccall(
1454
1474
  "wasm_set_request_uri",
1455
1475
  null,
@@ -1465,7 +1485,7 @@ class w {
1465
1485
  );
1466
1486
  }
1467
1487
  }
1468
- #o(e, r) {
1488
+ #a(e, r) {
1469
1489
  this[h].ccall(
1470
1490
  "wasm_set_request_host",
1471
1491
  null,
@@ -1480,11 +1500,11 @@ class w {
1480
1500
  (!s || isNaN(s) || s === 80) && (s = r === "https" ? 443 : 80), this[h].ccall(
1481
1501
  "wasm_set_request_port",
1482
1502
  null,
1483
- [_],
1503
+ [$],
1484
1504
  [s]
1485
1505
  ), (r === "https" || !r && s === 443) && this.addServerGlobalEntry("HTTPS", "on");
1486
1506
  }
1487
- #a(e) {
1507
+ #c(e) {
1488
1508
  this[h].ccall(
1489
1509
  "wasm_set_request_method",
1490
1510
  null,
@@ -1492,7 +1512,7 @@ class w {
1492
1512
  [e]
1493
1513
  );
1494
1514
  }
1495
- #c(e) {
1515
+ #l(e) {
1496
1516
  e.cookie && this[h].ccall(
1497
1517
  "wasm_set_cookies",
1498
1518
  null,
@@ -1506,7 +1526,7 @@ class w {
1506
1526
  ), e["content-length"] && this[h].ccall(
1507
1527
  "wasm_set_content_length",
1508
1528
  null,
1509
- [_],
1529
+ [$],
1510
1530
  [parseInt(e["content-length"], 10)]
1511
1531
  );
1512
1532
  for (const r in e)
@@ -1515,7 +1535,7 @@ class w {
1515
1535
  e[r]
1516
1536
  );
1517
1537
  }
1518
- #l(e) {
1538
+ #u(e) {
1519
1539
  this[h].ccall(
1520
1540
  "wasm_set_request_body",
1521
1541
  null,
@@ -1524,11 +1544,11 @@ class w {
1524
1544
  ), this[h].ccall(
1525
1545
  "wasm_set_content_length",
1526
1546
  null,
1527
- [_],
1547
+ [$],
1528
1548
  [new TextEncoder().encode(e).length]
1529
1549
  );
1530
1550
  }
1531
- #u(e) {
1551
+ #h(e) {
1532
1552
  this[h].ccall(
1533
1553
  "wasm_set_path_translated",
1534
1554
  null,
@@ -1537,12 +1557,16 @@ class w {
1537
1557
  );
1538
1558
  }
1539
1559
  addServerGlobalEntry(e, r) {
1540
- this[h].ccall(
1541
- "wasm_add_SERVER_entry",
1542
- null,
1543
- [f, f],
1544
- [e, r]
1545
- );
1560
+ this.#r[e] = r;
1561
+ }
1562
+ #d() {
1563
+ for (const e in this.#r)
1564
+ this[h].ccall(
1565
+ "wasm_add_SERVER_entry",
1566
+ null,
1567
+ [f, f],
1568
+ [e, this.#r[e]]
1569
+ );
1546
1570
  }
1547
1571
  /**
1548
1572
  * Adds file information to $_FILES superglobal in PHP.
@@ -1553,18 +1577,18 @@ class w {
1553
1577
  *
1554
1578
  * @param fileInfo - File details
1555
1579
  */
1556
- #h(e) {
1580
+ #p(e) {
1557
1581
  const { key: r, name: s, type: n, data: i } = e, o = `/tmp/${Math.random().toFixed(20)}`;
1558
1582
  this.writeFile(o, i);
1559
1583
  const a = 0;
1560
1584
  this[h].ccall(
1561
1585
  "wasm_add_uploaded_file",
1562
1586
  null,
1563
- [f, f, f, f, _, _],
1587
+ [f, f, f, f, $, $],
1564
1588
  [r, s, n, o, a, i.byteLength]
1565
1589
  );
1566
1590
  }
1567
- #d(e) {
1591
+ #f(e) {
1568
1592
  this[h].ccall(
1569
1593
  "wasm_set_php_code",
1570
1594
  null,
@@ -1572,14 +1596,14 @@ class w {
1572
1596
  [e]
1573
1597
  );
1574
1598
  }
1575
- async #p() {
1599
+ async #m() {
1576
1600
  let e, r;
1577
1601
  try {
1578
1602
  e = await new Promise(async (i, o) => {
1579
1603
  r = (a) => {
1580
1604
  const c = new Error("Rethrown");
1581
1605
  c.cause = a.error, c.betterMessage = a.message, o(c);
1582
- }, this.#r?.addEventListener(
1606
+ }, this.#s?.addEventListener(
1583
1607
  "error",
1584
1608
  r
1585
1609
  );
@@ -1593,7 +1617,7 @@ class w {
1593
1617
  */
1594
1618
  await await this[h].ccall(
1595
1619
  "wasm_sapi_handle_request",
1596
- _,
1620
+ $,
1597
1621
  [],
1598
1622
  []
1599
1623
  )
@@ -1609,13 +1633,13 @@ class w {
1609
1633
  "PHP runtime has crashed – see the earlier error for details."
1610
1634
  );
1611
1635
  });
1612
- this.functionsMaybeMissingFromAsyncify = wt();
1636
+ this.functionsMaybeMissingFromAsyncify = ht();
1613
1637
  const o = i, a = "betterMessage" in o ? o.betterMessage : o.message, c = new Error(a);
1614
1638
  throw c.cause = o, c;
1615
1639
  } finally {
1616
- this.#r?.removeEventListener("error", r);
1640
+ this.#s?.removeEventListener("error", r), this.#r = {};
1617
1641
  }
1618
- const { headers: s, httpStatusCode: n } = this.#i();
1642
+ const { headers: s, httpStatusCode: n } = this.#n();
1619
1643
  return new S(
1620
1644
  n,
1621
1645
  s,
@@ -1708,23 +1732,23 @@ g([
1708
1732
  g([
1709
1733
  m('Could not stat "{path}"')
1710
1734
  ], w.prototype, "fileExists", 1);
1711
- function ge(t) {
1735
+ function ye(t) {
1712
1736
  const e = {};
1713
1737
  for (const r in t)
1714
1738
  e[r.toLowerCase()] = t[r];
1715
1739
  return e;
1716
1740
  }
1717
- const St = [
1741
+ const Tt = [
1718
1742
  "vfs",
1719
1743
  "literal",
1720
1744
  "wordpress.org/themes",
1721
1745
  "wordpress.org/plugins",
1722
1746
  "url"
1723
1747
  ];
1724
- function Rt(t) {
1725
- return t && typeof t == "object" && typeof t.resource == "string" && St.includes(t.resource);
1748
+ function Ct(t) {
1749
+ return t && typeof t == "object" && typeof t.resource == "string" && Tt.includes(t.resource);
1726
1750
  }
1727
- class b {
1751
+ class _ {
1728
1752
  /**
1729
1753
  * Creates a new Resource based on the given file reference
1730
1754
  *
@@ -1736,24 +1760,24 @@ class b {
1736
1760
  let n;
1737
1761
  switch (e.resource) {
1738
1762
  case "vfs":
1739
- n = new xt(e, s);
1763
+ n = new Ft(e, s);
1740
1764
  break;
1741
1765
  case "literal":
1742
- n = new Tt(e, s);
1766
+ n = new kt(e, s);
1743
1767
  break;
1744
1768
  case "wordpress.org/themes":
1745
- n = new Ft(e, s);
1769
+ n = new Lt(e, s);
1746
1770
  break;
1747
1771
  case "wordpress.org/plugins":
1748
- n = new Ot(e, s);
1772
+ n = new Ut(e, s);
1749
1773
  break;
1750
1774
  case "url":
1751
- n = new kt(e, s);
1775
+ n = new At(e, s);
1752
1776
  break;
1753
1777
  default:
1754
1778
  throw new Error(`Invalid resource: ${e}`);
1755
1779
  }
1756
- return n = new At(n), r && (n = new Lt(n, r)), n;
1780
+ return n = new Ht(n), r && (n = new It(n, r)), n;
1757
1781
  }
1758
1782
  setPlayground(e) {
1759
1783
  this.playground = e;
@@ -1763,7 +1787,7 @@ class b {
1763
1787
  return !1;
1764
1788
  }
1765
1789
  }
1766
- class xt extends b {
1790
+ class Ft extends _ {
1767
1791
  /**
1768
1792
  * Creates a new instance of `VFSResource`.
1769
1793
  * @param playground The playground client.
@@ -1785,7 +1809,7 @@ class xt extends b {
1785
1809
  return this.resource.path;
1786
1810
  }
1787
1811
  }
1788
- class Tt extends b {
1812
+ class kt extends _ {
1789
1813
  /**
1790
1814
  * Creates a new instance of `LiteralResource`.
1791
1815
  * @param resource The literal reference.
@@ -1803,7 +1827,7 @@ class Tt extends b {
1803
1827
  return this.resource.name;
1804
1828
  }
1805
1829
  }
1806
- class q extends b {
1830
+ class q extends _ {
1807
1831
  /**
1808
1832
  * Creates a new instance of `FetchResource`.
1809
1833
  * @param progress The progress tracker.
@@ -1816,9 +1840,9 @@ class q extends b {
1816
1840
  this.progress?.setCaption(this.caption);
1817
1841
  const e = this.getURL();
1818
1842
  let r = await fetch(e);
1819
- if (r = await nt(
1843
+ if (r = await at(
1820
1844
  r,
1821
- this.progress?.loadingListener ?? Ct
1845
+ this.progress?.loadingListener ?? Ot
1822
1846
  ), r.status !== 200)
1823
1847
  throw new Error(`Could not download "${e}"`);
1824
1848
  return new File([await r.blob()], this.name);
@@ -1843,9 +1867,9 @@ class q extends b {
1843
1867
  return !0;
1844
1868
  }
1845
1869
  }
1846
- const Ct = () => {
1870
+ const Ot = () => {
1847
1871
  };
1848
- class kt extends q {
1872
+ class At extends q {
1849
1873
  /**
1850
1874
  * Creates a new instance of `UrlResource`.
1851
1875
  * @param resource The URL reference.
@@ -1864,10 +1888,10 @@ class kt extends q {
1864
1888
  }
1865
1889
  }
1866
1890
  let j = "https://playground.wordpress.net/plugin-proxy";
1867
- function sr(t) {
1891
+ function or(t) {
1868
1892
  j = t;
1869
1893
  }
1870
- class Ft extends q {
1894
+ class Lt extends q {
1871
1895
  constructor(e, r) {
1872
1896
  super(r), this.resource = e;
1873
1897
  }
@@ -1875,11 +1899,11 @@ class Ft extends q {
1875
1899
  return L(this.resource.slug);
1876
1900
  }
1877
1901
  getURL() {
1878
- const e = we(this.resource.slug);
1902
+ const e = Pe(this.resource.slug);
1879
1903
  return `${j}?theme=` + e;
1880
1904
  }
1881
1905
  }
1882
- class Ot extends q {
1906
+ class Ut extends q {
1883
1907
  constructor(e, r) {
1884
1908
  super(r), this.resource = e;
1885
1909
  }
@@ -1889,14 +1913,14 @@ class Ot extends q {
1889
1913
  }
1890
1914
  /** @inheritDoc */
1891
1915
  getURL() {
1892
- const e = we(this.resource.slug);
1916
+ const e = Pe(this.resource.slug);
1893
1917
  return `${j}?plugin=` + e;
1894
1918
  }
1895
1919
  }
1896
- function we(t) {
1920
+ function Pe(t) {
1897
1921
  return !t || t.endsWith(".zip") ? t : t + ".latest-stable.zip";
1898
1922
  }
1899
- class ye extends b {
1923
+ class be extends _ {
1900
1924
  constructor(e) {
1901
1925
  super(), this.resource = e;
1902
1926
  }
@@ -1925,13 +1949,13 @@ class ye extends b {
1925
1949
  return this.resource.isAsync;
1926
1950
  }
1927
1951
  }
1928
- class At extends ye {
1952
+ class Ht extends be {
1929
1953
  /** @inheritDoc */
1930
1954
  async resolve() {
1931
1955
  return this.promise || (this.promise = super.resolve()), this.promise;
1932
1956
  }
1933
1957
  }
1934
- class Lt extends ye {
1958
+ class It extends be {
1935
1959
  constructor(e, r) {
1936
1960
  super(e), this.semaphore = r;
1937
1961
  }
@@ -1940,18 +1964,18 @@ class Lt extends ye {
1940
1964
  return this.isAsync ? this.semaphore.run(() => super.resolve()) : super.resolve();
1941
1965
  }
1942
1966
  }
1943
- const Ut = ["6.2", "6.1", "6.0", "5.9"];
1944
- function Ht(t, {
1967
+ const Nt = ["6.2", "6.1", "6.0", "5.9"];
1968
+ function Mt(t, {
1945
1969
  progress: e = new U(),
1946
- semaphore: r = new de({ concurrency: 3 }),
1970
+ semaphore: r = new fe({ concurrency: 3 }),
1947
1971
  onStepCompleted: s = () => {
1948
1972
  }
1949
1973
  } = {}) {
1950
- const n = (t.steps || []).filter(It), i = n.reduce(
1974
+ const n = (t.steps || []).filter(Wt), i = n.reduce(
1951
1975
  (a, c) => a + (c.progress?.weight || 1),
1952
1976
  0
1953
1977
  ), o = n.map(
1954
- (a) => Nt(a, {
1978
+ (a) => Dt(a, {
1955
1979
  semaphore: r,
1956
1980
  rootProgressTracker: e,
1957
1981
  totalProgressWeight: i
@@ -1959,14 +1983,14 @@ function Ht(t, {
1959
1983
  );
1960
1984
  return {
1961
1985
  versions: {
1962
- php: ie(
1986
+ php: ae(
1963
1987
  t.preferredVersions?.php,
1964
- D,
1965
- it
1988
+ z,
1989
+ wt
1966
1990
  ),
1967
- wp: ie(
1991
+ wp: ae(
1968
1992
  t.preferredVersions?.wp,
1969
- Ut,
1993
+ Nt,
1970
1994
  "6.2"
1971
1995
  )
1972
1996
  },
@@ -1991,13 +2015,13 @@ function Ht(t, {
1991
2015
  }
1992
2016
  };
1993
2017
  }
1994
- function ie(t, e, r) {
2018
+ function ae(t, e, r) {
1995
2019
  return t && e.includes(t) ? t : r;
1996
2020
  }
1997
- function It(t) {
2021
+ function Wt(t) {
1998
2022
  return !!(typeof t == "object" && t);
1999
2023
  }
2000
- function Nt(t, {
2024
+ function Dt(t, {
2001
2025
  semaphore: e,
2002
2026
  rootProgressTracker: r,
2003
2027
  totalProgressWeight: s
@@ -2007,15 +2031,15 @@ function Nt(t, {
2007
2031
  ), i = {};
2008
2032
  for (const u of Object.keys(t)) {
2009
2033
  let d = t[u];
2010
- Rt(d) && (d = b.create(d, {
2034
+ Ct(d) && (d = _.create(d, {
2011
2035
  semaphore: e
2012
2036
  })), i[u] = d;
2013
2037
  }
2014
2038
  const o = async (u) => {
2015
2039
  try {
2016
- return n.fillSlowly(), await rt[t.step](
2040
+ return n.fillSlowly(), await it[t.step](
2017
2041
  u,
2018
- await Mt(i),
2042
+ await zt(i),
2019
2043
  {
2020
2044
  tracker: n,
2021
2045
  initialCaption: t.progress?.caption
@@ -2024,30 +2048,30 @@ function Nt(t, {
2024
2048
  } finally {
2025
2049
  n.finish();
2026
2050
  }
2027
- }, a = oe(i), c = oe(i).filter(
2051
+ }, a = ce(i), c = ce(i).filter(
2028
2052
  (u) => u.isAsync
2029
2053
  ), l = 1 / (c.length + 1);
2030
2054
  for (const u of c)
2031
2055
  u.progress = n.stage(l);
2032
2056
  return { run: o, step: t, resources: a };
2033
2057
  }
2034
- function oe(t) {
2058
+ function ce(t) {
2035
2059
  const e = [];
2036
2060
  for (const r in t) {
2037
2061
  const s = t[r];
2038
- s instanceof b && e.push(s);
2062
+ s instanceof _ && e.push(s);
2039
2063
  }
2040
2064
  return e;
2041
2065
  }
2042
- async function Mt(t) {
2066
+ async function zt(t) {
2043
2067
  const e = {};
2044
2068
  for (const r in t) {
2045
2069
  const s = t[r];
2046
- s instanceof b ? e[r] = await s.resolve() : e[r] = s;
2070
+ s instanceof _ ? e[r] = await s.resolve() : e[r] = s;
2047
2071
  }
2048
2072
  return e;
2049
2073
  }
2050
- async function Wt(t, e) {
2074
+ async function qt(t, e) {
2051
2075
  await t.run(e);
2052
2076
  }
2053
2077
  /**
@@ -2055,8 +2079,8 @@ async function Wt(t, e) {
2055
2079
  * Copyright 2019 Google LLC
2056
2080
  * SPDX-License-Identifier: Apache-2.0
2057
2081
  */
2058
- const Pe = Symbol("Comlink.proxy"), Dt = Symbol("Comlink.endpoint"), zt = Symbol("Comlink.releaseProxy"), I = Symbol("Comlink.finalizer"), C = Symbol("Comlink.thrown"), be = (t) => typeof t == "object" && t !== null || typeof t == "function", qt = {
2059
- canHandle: (t) => be(t) && t[Pe],
2082
+ const _e = Symbol("Comlink.proxy"), jt = Symbol("Comlink.endpoint"), Bt = Symbol("Comlink.releaseProxy"), I = Symbol("Comlink.finalizer"), C = Symbol("Comlink.thrown"), $e = (t) => typeof t == "object" && t !== null || typeof t == "function", Vt = {
2083
+ canHandle: (t) => $e(t) && t[_e],
2060
2084
  serialize(t) {
2061
2085
  const { port1: e, port2: r } = new MessageChannel();
2062
2086
  return B(t, e), [r, [r]];
@@ -2064,8 +2088,8 @@ const Pe = Symbol("Comlink.proxy"), Dt = Symbol("Comlink.endpoint"), zt = Symbol
2064
2088
  deserialize(t) {
2065
2089
  return t.start(), V(t);
2066
2090
  }
2067
- }, jt = {
2068
- canHandle: (t) => be(t) && C in t,
2091
+ }, Gt = {
2092
+ canHandle: (t) => $e(t) && C in t,
2069
2093
  serialize({ value: t }) {
2070
2094
  let e;
2071
2095
  return t instanceof Error ? e = {
@@ -2081,10 +2105,10 @@ const Pe = Symbol("Comlink.proxy"), Dt = Symbol("Comlink.endpoint"), zt = Symbol
2081
2105
  throw t.isError ? Object.assign(new Error(t.value.message), t.value) : t.value;
2082
2106
  }
2083
2107
  }, R = /* @__PURE__ */ new Map([
2084
- ["proxy", qt],
2085
- ["throw", jt]
2108
+ ["proxy", Vt],
2109
+ ["throw", Gt]
2086
2110
  ]);
2087
- function Bt(t, e) {
2111
+ function Jt(t, e) {
2088
2112
  for (const r of t)
2089
2113
  if (e === r || r === "*" || r instanceof RegExp && r.test(e))
2090
2114
  return !0;
@@ -2094,11 +2118,11 @@ function B(t, e = globalThis, r = ["*"]) {
2094
2118
  e.addEventListener("message", function s(n) {
2095
2119
  if (!n || !n.data)
2096
2120
  return;
2097
- if (!Bt(r, n.origin)) {
2121
+ if (!Jt(r, n.origin)) {
2098
2122
  console.warn(`Invalid origin '${n.origin}' for comlink proxy`);
2099
2123
  return;
2100
2124
  }
2101
- const { id: i, type: o, path: a } = Object.assign({ path: [] }, n.data), c = (n.data.argumentList || []).map(P);
2125
+ const { id: i, type: o, path: a } = Object.assign({ path: [] }, n.data), c = (n.data.argumentList || []).map(b);
2102
2126
  let l;
2103
2127
  try {
2104
2128
  const u = a.slice(0, -1).reduce((p, y) => p[y], t), d = a.reduce((p, y) => p[y], t);
@@ -2107,7 +2131,7 @@ function B(t, e = globalThis, r = ["*"]) {
2107
2131
  l = d;
2108
2132
  break;
2109
2133
  case "SET":
2110
- u[a.slice(-1)[0]] = P(n.data.value), l = !0;
2134
+ u[a.slice(-1)[0]] = b(n.data.value), l = !0;
2111
2135
  break;
2112
2136
  case "APPLY":
2113
2137
  l = d.apply(u, c);
@@ -2115,13 +2139,13 @@ function B(t, e = globalThis, r = ["*"]) {
2115
2139
  case "CONSTRUCT":
2116
2140
  {
2117
2141
  const p = new d(...c);
2118
- l = ve(p);
2142
+ l = Re(p);
2119
2143
  }
2120
2144
  break;
2121
2145
  case "ENDPOINT":
2122
2146
  {
2123
2147
  const { port1: p, port2: y } = new MessageChannel();
2124
- B(t, y), l = Kt(p, [p]);
2148
+ B(t, y), l = Zt(p, [p]);
2125
2149
  }
2126
2150
  break;
2127
2151
  case "RELEASE":
@@ -2135,7 +2159,7 @@ function B(t, e = globalThis, r = ["*"]) {
2135
2159
  }
2136
2160
  Promise.resolve(l).catch((u) => ({ value: u, [C]: 0 })).then((u) => {
2137
2161
  const [d, p] = A(u);
2138
- e.postMessage(Object.assign(Object.assign({}, d), { id: i }), p), o === "RELEASE" && (e.removeEventListener("message", s), _e(e), I in t && typeof t[I] == "function" && t[I]());
2162
+ e.postMessage(Object.assign(Object.assign({}, d), { id: i }), p), o === "RELEASE" && (e.removeEventListener("message", s), Ee(e), I in t && typeof t[I] == "function" && t[I]());
2139
2163
  }).catch((u) => {
2140
2164
  const [d, p] = A({
2141
2165
  value: new TypeError("Unserializable return value"),
@@ -2145,11 +2169,11 @@ function B(t, e = globalThis, r = ["*"]) {
2145
2169
  });
2146
2170
  }), e.start && e.start();
2147
2171
  }
2148
- function Vt(t) {
2172
+ function Yt(t) {
2149
2173
  return t.constructor.name === "MessagePort";
2150
2174
  }
2151
- function _e(t) {
2152
- Vt(t) && t.close();
2175
+ function Ee(t) {
2176
+ Yt(t) && t.close();
2153
2177
  }
2154
2178
  function V(t, e) {
2155
2179
  return M(t, [], e);
@@ -2158,22 +2182,22 @@ function T(t) {
2158
2182
  if (t)
2159
2183
  throw new Error("Proxy has been released and is not useable");
2160
2184
  }
2161
- function $e(t) {
2162
- return $(t, {
2185
+ function ve(t) {
2186
+ return E(t, {
2163
2187
  type: "RELEASE"
2164
2188
  }).then(() => {
2165
- _e(t);
2189
+ Ee(t);
2166
2190
  });
2167
2191
  }
2168
- const F = /* @__PURE__ */ new WeakMap(), O = "FinalizationRegistry" in globalThis && new FinalizationRegistry((t) => {
2169
- const e = (F.get(t) || 0) - 1;
2170
- F.set(t, e), e === 0 && $e(t);
2192
+ const k = /* @__PURE__ */ new WeakMap(), O = "FinalizationRegistry" in globalThis && new FinalizationRegistry((t) => {
2193
+ const e = (k.get(t) || 0) - 1;
2194
+ k.set(t, e), e === 0 && ve(t);
2171
2195
  });
2172
- function Gt(t, e) {
2173
- const r = (F.get(e) || 0) + 1;
2174
- F.set(e, r), O && O.register(t, e, t);
2196
+ function Kt(t, e) {
2197
+ const r = (k.get(e) || 0) + 1;
2198
+ k.set(e, r), O && O.register(t, e, t);
2175
2199
  }
2176
- function Jt(t) {
2200
+ function Qt(t) {
2177
2201
  O && O.unregister(t);
2178
2202
  }
2179
2203
  function M(t, e = [], r = function() {
@@ -2181,17 +2205,17 @@ function M(t, e = [], r = function() {
2181
2205
  let s = !1;
2182
2206
  const n = new Proxy(r, {
2183
2207
  get(i, o) {
2184
- if (T(s), o === zt)
2208
+ if (T(s), o === Bt)
2185
2209
  return () => {
2186
- Jt(n), $e(t), s = !0;
2210
+ Qt(n), ve(t), s = !0;
2187
2211
  };
2188
2212
  if (o === "then") {
2189
2213
  if (e.length === 0)
2190
2214
  return { then: () => n };
2191
- const a = $(t, {
2215
+ const a = E(t, {
2192
2216
  type: "GET",
2193
2217
  path: e.map((c) => c.toString())
2194
- }).then(P);
2218
+ }).then(b);
2195
2219
  return a.then.bind(a);
2196
2220
  }
2197
2221
  return M(t, [...e, o]);
@@ -2199,55 +2223,55 @@ function M(t, e = [], r = function() {
2199
2223
  set(i, o, a) {
2200
2224
  T(s);
2201
2225
  const [c, l] = A(a);
2202
- return $(t, {
2226
+ return E(t, {
2203
2227
  type: "SET",
2204
2228
  path: [...e, o].map((u) => u.toString()),
2205
2229
  value: c
2206
- }, l).then(P);
2230
+ }, l).then(b);
2207
2231
  },
2208
2232
  apply(i, o, a) {
2209
2233
  T(s);
2210
2234
  const c = e[e.length - 1];
2211
- if (c === Dt)
2212
- return $(t, {
2235
+ if (c === jt)
2236
+ return E(t, {
2213
2237
  type: "ENDPOINT"
2214
- }).then(P);
2238
+ }).then(b);
2215
2239
  if (c === "bind")
2216
2240
  return M(t, e.slice(0, -1));
2217
- const [l, u] = ae(a);
2218
- return $(t, {
2241
+ const [l, u] = le(a);
2242
+ return E(t, {
2219
2243
  type: "APPLY",
2220
2244
  path: e.map((d) => d.toString()),
2221
2245
  argumentList: l
2222
- }, u).then(P);
2246
+ }, u).then(b);
2223
2247
  },
2224
2248
  construct(i, o) {
2225
2249
  T(s);
2226
- const [a, c] = ae(o);
2227
- return $(t, {
2250
+ const [a, c] = le(o);
2251
+ return E(t, {
2228
2252
  type: "CONSTRUCT",
2229
2253
  path: e.map((l) => l.toString()),
2230
2254
  argumentList: a
2231
- }, c).then(P);
2255
+ }, c).then(b);
2232
2256
  }
2233
2257
  });
2234
- return Gt(n, t), n;
2258
+ return Kt(n, t), n;
2235
2259
  }
2236
- function Yt(t) {
2260
+ function Xt(t) {
2237
2261
  return Array.prototype.concat.apply([], t);
2238
2262
  }
2239
- function ae(t) {
2263
+ function le(t) {
2240
2264
  const e = t.map(A);
2241
- return [e.map((r) => r[0]), Yt(e.map((r) => r[1]))];
2265
+ return [e.map((r) => r[0]), Xt(e.map((r) => r[1]))];
2242
2266
  }
2243
- const Ee = /* @__PURE__ */ new WeakMap();
2244
- function Kt(t, e) {
2245
- return Ee.set(t, e), t;
2267
+ const Se = /* @__PURE__ */ new WeakMap();
2268
+ function Zt(t, e) {
2269
+ return Se.set(t, e), t;
2246
2270
  }
2247
- function ve(t) {
2248
- return Object.assign(t, { [Pe]: !0 });
2271
+ function Re(t) {
2272
+ return Object.assign(t, { [_e]: !0 });
2249
2273
  }
2250
- function Qt(t, e = globalThis, r = "*") {
2274
+ function er(t, e = globalThis, r = "*") {
2251
2275
  return {
2252
2276
  postMessage: (s, n) => t.postMessage(s, r, n),
2253
2277
  addEventListener: e.addEventListener.bind(e),
@@ -2272,10 +2296,10 @@ function A(t) {
2272
2296
  type: "RAW",
2273
2297
  value: t
2274
2298
  },
2275
- Ee.get(t) || []
2299
+ Se.get(t) || []
2276
2300
  ];
2277
2301
  }
2278
- function P(t) {
2302
+ function b(t) {
2279
2303
  switch (t.type) {
2280
2304
  case "HANDLER":
2281
2305
  return R.get(t.name).deserialize(t.value);
@@ -2283,27 +2307,27 @@ function P(t) {
2283
2307
  return t.value;
2284
2308
  }
2285
2309
  }
2286
- function $(t, e, r) {
2310
+ function E(t, e, r) {
2287
2311
  return new Promise((s) => {
2288
- const n = Xt();
2312
+ const n = tr();
2289
2313
  t.addEventListener("message", function i(o) {
2290
2314
  !o.data || !o.data.id || o.data.id !== n || (t.removeEventListener("message", i), s(o.data));
2291
2315
  }), t.start && t.start(), t.postMessage(Object.assign({ id: n }, e), r);
2292
2316
  });
2293
2317
  }
2294
- function Xt() {
2318
+ function tr() {
2295
2319
  return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
2296
2320
  }
2297
- function Se(t) {
2298
- Zt();
2299
- const e = t instanceof Worker ? t : Qt(t), r = V(e), s = Re(r);
2321
+ function xe(t) {
2322
+ rr();
2323
+ const e = t instanceof Worker ? t : er(t), r = V(e), s = Te(r);
2300
2324
  return new Proxy(s, {
2301
2325
  get: (n, i) => i === "isConnected" ? () => r.isConnected() : r[i]
2302
2326
  });
2303
2327
  }
2304
- let ce = !1;
2305
- function Zt() {
2306
- ce || (ce = !0, R.set("EVENT", {
2328
+ let ue = !1;
2329
+ function rr() {
2330
+ ue || (ue = !0, R.set("EVENT", {
2307
2331
  canHandle: (t) => t instanceof CustomEvent,
2308
2332
  serialize: (t) => [
2309
2333
  {
@@ -2332,20 +2356,20 @@ function Zt() {
2332
2356
  }
2333
2357
  }));
2334
2358
  }
2335
- function Re(t) {
2359
+ function Te(t) {
2336
2360
  return new Proxy(t, {
2337
2361
  get(e, r) {
2338
2362
  switch (typeof e[r]) {
2339
2363
  case "function":
2340
2364
  return (...s) => e[r](...s);
2341
2365
  case "object":
2342
- return e[r] === null ? e[r] : Re(e[r]);
2366
+ return e[r] === null ? e[r] : Te(e[r]);
2343
2367
  case "undefined":
2344
2368
  case "number":
2345
2369
  case "string":
2346
2370
  return e[r];
2347
2371
  default:
2348
- return ve(e[r]);
2372
+ return Re(e[r]);
2349
2373
  }
2350
2374
  }
2351
2375
  });
@@ -2353,7 +2377,7 @@ function Re(t) {
2353
2377
  (function() {
2354
2378
  return typeof navigator < "u" && navigator?.userAgent?.toLowerCase().indexOf("firefox") > -1 ? "iframe" : "webworker";
2355
2379
  })();
2356
- async function er({
2380
+ async function sr({
2357
2381
  iframe: t,
2358
2382
  blueprint: e,
2359
2383
  remoteUrl: r,
@@ -2361,94 +2385,95 @@ async function er({
2361
2385
  disableProgressBar: n,
2362
2386
  onBlueprintStepCompleted: i
2363
2387
  }) {
2364
- if (tr(r), r = ue(r, {
2388
+ if (nr(r), r = de(r, {
2365
2389
  progressbar: !n
2366
2390
  }), s.setCaption("Preparing WordPress"), !e)
2367
- return le(t, r, s);
2368
- const o = Ht(e, {
2391
+ return he(t, r, s);
2392
+ const o = Mt(e, {
2369
2393
  progress: s.stage(0.5),
2370
2394
  onStepCompleted: i
2371
- }), a = await le(
2395
+ }), a = await he(
2372
2396
  t,
2373
- ue(r, {
2397
+ de(r, {
2374
2398
  php: o.versions.php,
2375
2399
  wp: o.versions.wp
2376
2400
  }),
2377
2401
  s
2378
2402
  );
2379
- return await Wt(o, a), s.finish(), a;
2403
+ return await qt(o, a), s.finish(), a;
2380
2404
  }
2381
- async function le(t, e, r) {
2405
+ async function he(t, e, r) {
2382
2406
  await new Promise((i) => {
2383
2407
  t.src = e, t.addEventListener("load", i, !1);
2384
2408
  });
2385
- const s = Se(
2409
+ const s = xe(
2386
2410
  t.contentWindow
2387
2411
  );
2388
2412
  await s.isConnected(), r.pipe(s);
2389
2413
  const n = r.stage();
2390
2414
  return await s.onDownloadProgress(n.loadingListener), await s.isReady(), n.finish(), s;
2391
2415
  }
2392
- const k = "https://playground.wordpress.net";
2393
- function tr(t) {
2394
- const e = new URL(t, k);
2395
- if ((e.origin === k || e.hostname === "localhost") && e.pathname !== "/remote.html")
2416
+ const F = "https://playground.wordpress.net";
2417
+ function nr(t) {
2418
+ const e = new URL(t, F);
2419
+ if ((e.origin === F || e.hostname === "localhost") && e.pathname !== "/remote.html")
2396
2420
  throw new Error(
2397
- `Invalid remote URL: ${e}. Expected origin to be ${k}/remote.html.`
2421
+ `Invalid remote URL: ${e}. Expected origin to be ${F}/remote.html.`
2398
2422
  );
2399
2423
  }
2400
- function ue(t, e) {
2401
- const r = new URL(t, k), s = new URLSearchParams(r.search);
2424
+ function de(t, e) {
2425
+ const r = new URL(t, F), s = new URLSearchParams(r.search);
2402
2426
  for (const [n, i] of Object.entries(e))
2403
2427
  i != null && i !== !1 && s.set(n, i.toString());
2404
2428
  return r.search = s.toString(), r.toString();
2405
2429
  }
2406
- async function nr(t, e) {
2430
+ async function ar(t, e) {
2407
2431
  if (console.warn(
2408
2432
  "`connectPlayground` is deprecated and will be removed. Use `startPlayground` instead."
2409
2433
  ), e?.loadRemote)
2410
- return er({
2434
+ return sr({
2411
2435
  iframe: t,
2412
2436
  remoteUrl: e.loadRemote
2413
2437
  });
2414
- const r = Se(
2438
+ const r = xe(
2415
2439
  t.contentWindow
2416
2440
  );
2417
2441
  return await r.isConnected(), r;
2418
2442
  }
2419
2443
  export {
2420
- it as LatestSupportedPHPVersion,
2421
- D as SupportedPHPVersions,
2422
- rr as SupportedPHPVersionsList,
2423
- ke as activatePlugin,
2424
- Fe as applyWordPressPatches,
2425
- Ht as compileBlueprint,
2426
- nr as connectPlayground,
2427
- Ie as cp,
2428
- qe as defineSiteUrl,
2429
- he as defineWpConfigConsts,
2430
- Ge as importFile,
2431
- Ke as installPlugin,
2432
- Qe as installTheme,
2433
- Xe as login,
2434
- Me as mkdir,
2435
- Ne as mv,
2444
+ wt as LatestSupportedPHPVersion,
2445
+ z as SupportedPHPVersions,
2446
+ ir as SupportedPHPVersionsList,
2447
+ Oe as activatePlugin,
2448
+ Ae as applyWordPressPatches,
2449
+ Mt as compileBlueprint,
2450
+ ar as connectPlayground,
2451
+ Me as cp,
2452
+ Be as defineSiteUrl,
2453
+ nt as defineVirtualWpConfigConsts,
2454
+ pe as defineWpConfigConsts,
2455
+ Ye as importFile,
2456
+ Xe as installPlugin,
2457
+ Ze as installTheme,
2458
+ et as login,
2459
+ De as mkdir,
2460
+ We as mv,
2436
2461
  v as phpVar,
2437
2462
  W as phpVars,
2438
- Ve as replaceSite,
2439
- He as request,
2440
- We as rm,
2441
- De as rmdir,
2442
- Wt as runBlueprintSteps,
2443
- Ae as runPHP,
2444
- Le as runPHPWithOptions,
2445
- Ze as runWpInstallationWizard,
2446
- Ue as setPhpIniEntry,
2447
- sr as setPluginProxyURL,
2448
- et as setSiteOptions,
2449
- er as startPlaygroundWeb,
2450
- pe as unzip,
2451
- tt as updateUserMeta,
2452
- ze as writeFile,
2453
- Be as zipEntireSite
2463
+ Je as replaceSite,
2464
+ Ne as request,
2465
+ ze as rm,
2466
+ qe as rmdir,
2467
+ qt as runBlueprintSteps,
2468
+ Ue as runPHP,
2469
+ He as runPHPWithOptions,
2470
+ tt as runWpInstallationWizard,
2471
+ Ie as setPhpIniEntry,
2472
+ or as setPluginProxyURL,
2473
+ rt as setSiteOptions,
2474
+ sr as startPlaygroundWeb,
2475
+ me as unzip,
2476
+ st as updateUserMeta,
2477
+ je as writeFile,
2478
+ Ge as zipEntireSite
2454
2479
  };