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