@wp-playground/blueprints 0.1.60 → 0.1.61

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,16 +1,16 @@
1
- const J = async (s, { pluginPath: e, pluginName: t }, r) => {
2
- r?.tracker.setCaption(`Activating ${t || e}`);
1
+ const Z = async (r, { pluginPath: e, pluginName: t }, s) => {
2
+ s?.tracker.setCaption(`Activating ${t || e}`);
3
3
  const i = [
4
- `${await s.documentRoot}/wp-load.php`,
5
- `${await s.documentRoot}/wp-admin/includes/plugin.php`
4
+ `${await r.documentRoot}/wp-load.php`,
5
+ `${await r.documentRoot}/wp-admin/includes/plugin.php`
6
6
  ];
7
7
  if (!i.every(
8
- (a) => s.fileExists(a)
8
+ (a) => r.fileExists(a)
9
9
  ))
10
10
  throw new Error(
11
11
  `Required WordPress files do not exist: ${i.join(", ")}`
12
12
  );
13
- if ((await s.run({
13
+ if ((await r.run({
14
14
  code: `<?php
15
15
  define( 'WP_ADMIN', true );
16
16
  ${i.map((a) => `require_once( '${a}' );`).join(`
@@ -32,33 +32,33 @@ echo 'NO_ENTRY_FILE';
32
32
  `
33
33
  })).text.endsWith("NO_ENTRY_FILE"))
34
34
  throw new Error("Could not find plugin entry file.");
35
- }, K = async (s, { themeFolderName: e }, t) => {
35
+ }, Q = async (r, { themeFolderName: e }, t) => {
36
36
  t?.tracker.setCaption(`Activating ${e}`);
37
- const r = `${await s.documentRoot}/wp-load.php`;
38
- if (!s.fileExists(r))
37
+ const s = `${await r.documentRoot}/wp-load.php`;
38
+ if (!r.fileExists(s))
39
39
  throw new Error(
40
- `Required WordPress file does not exist: ${r}`
40
+ `Required WordPress file does not exist: ${s}`
41
41
  );
42
- await s.run({
42
+ await r.run({
43
43
  code: `<?php
44
44
  define( 'WP_ADMIN', true );
45
- require_once( '${r}' );
45
+ require_once( '${s}' );
46
46
  switch_theme( '${e}' );
47
47
  `
48
48
  });
49
49
  };
50
- function b(s) {
51
- const e = s.split(".").shift().replace(/-/g, " ");
50
+ function v(r) {
51
+ const e = r.split(".").shift().replace(/-/g, " ");
52
52
  return e.charAt(0).toUpperCase() + e.slice(1).toLowerCase();
53
53
  }
54
- async function P(s, e, t) {
55
- let r = "";
56
- await s.fileExists(e) && (r = await s.readFileAsText(e)), await s.writeFile(e, t(r));
54
+ async function b(r, e, t) {
55
+ let s = "";
56
+ await r.fileExists(e) && (s = await r.readFileAsText(e)), await r.writeFile(e, t(s));
57
57
  }
58
- async function ae(s) {
59
- return new Uint8Array(await s.arrayBuffer());
58
+ async function ce(r) {
59
+ return new Uint8Array(await r.arrayBuffer());
60
60
  }
61
- class ce extends File {
61
+ class le extends File {
62
62
  constructor(e, t) {
63
63
  super(e, t), this.buffers = e;
64
64
  }
@@ -66,27 +66,34 @@ class ce extends File {
66
66
  return this.buffers[0];
67
67
  }
68
68
  }
69
- const R = File.prototype.arrayBuffer instanceof Function ? File : ce, le = async (s, e) => {
70
- const t = new he(
71
- s,
72
- e.siteUrl,
73
- e.wordpressPath || "/wordpress"
69
+ const T = File.prototype.arrayBuffer instanceof Function ? File : le, O = "/vfs-blueprints", x = async (r, { consts: e, virtualize: t = !1 }) => {
70
+ const s = await r.documentRoot, i = t ? O : s, n = `${i}/playground-consts.json`, o = `${i}/wp-config.php`;
71
+ return t && (r.mkdir(O), r.setPhpIniEntry("auto_prepend_file", o)), await b(
72
+ r,
73
+ n,
74
+ (a) => JSON.stringify({
75
+ ...JSON.parse(a || "{}"),
76
+ ...e
77
+ })
78
+ ), await b(r, o, (a) => a.includes("playground-consts.json") ? a : `<?php
79
+ $consts = json_decode(file_get_contents('${n}'), true);
80
+ foreach ($consts as $const => $value) {
81
+ if (!defined($const)) {
82
+ define($const, $value);
83
+ }
84
+ }
85
+ ?>${a}`), o;
86
+ }, he = async (r, e) => {
87
+ const t = new ue(
88
+ r,
89
+ e.wordpressPath || "/wordpress",
90
+ e.siteUrl
74
91
  );
75
- e.patchSqlitePlugin !== !1 && await t.patchSqlitePlugin(), e.addPhpInfo !== !1 && await t.addPhpInfo(), e.patchSiteUrl !== !1 && await t.patchSiteUrl(), e.disableSiteHealth !== !1 && await t.disableSiteHealth(), e.disableWpNewBlogNotification !== !1 && await t.disableWpNewBlogNotification();
92
+ e.addPhpInfo === !0 && await t.addPhpInfo(), e.siteUrl && await t.patchSiteUrl(), e.patchSecrets === !0 && await t.patchSecrets(), e.disableSiteHealth === !0 && await t.disableSiteHealth(), e.disableWpNewBlogNotification === !0 && await t.disableWpNewBlogNotification();
76
93
  };
77
- class he {
78
- constructor(e, t, r) {
79
- this.php = e, this.scopedSiteUrl = t, this.wordpressPath = r;
80
- }
81
- async patchSqlitePlugin() {
82
- await P(
83
- this.php,
84
- `${this.wordpressPath}/wp-content/plugins/sqlite-database-integration/wp-includes/sqlite/class-wp-sqlite-translator.php`,
85
- (e) => e.replace(
86
- "if ( false === strtotime( $value ) )",
87
- 'if ( $value === "0000-00-00 00:00:00" || false === strtotime( $value ) )'
88
- )
89
- );
94
+ class ue {
95
+ constructor(e, t, s) {
96
+ this.php = e, this.scopedSiteUrl = s, this.wordpressPath = t;
90
97
  }
91
98
  async addPhpInfo() {
92
99
  await this.php.writeFile(
@@ -95,19 +102,32 @@ class he {
95
102
  );
96
103
  }
97
104
  async patchSiteUrl() {
98
- await P(
105
+ await x(this.php, {
106
+ consts: {
107
+ WP_HOME: this.scopedSiteUrl,
108
+ WP_SITEURL: this.scopedSiteUrl
109
+ },
110
+ virtualize: !0
111
+ });
112
+ }
113
+ async patchSecrets() {
114
+ await b(
99
115
  this.php,
100
116
  `${this.wordpressPath}/wp-config.php`,
101
117
  (e) => `<?php
102
- if(!defined('WP_HOME')) {
103
- define('WP_HOME', "${this.scopedSiteUrl}");
104
- define('WP_SITEURL', "${this.scopedSiteUrl}");
105
- }
106
- ?>${e}`
118
+ define('AUTH_KEY', '${g(40)}');
119
+ define('SECURE_AUTH_KEY', '${g(40)}');
120
+ define('LOGGED_IN_KEY', '${g(40)}');
121
+ define('NONCE_KEY', '${g(40)}');
122
+ define('AUTH_SALT', '${g(40)}');
123
+ define('SECURE_AUTH_SALT', '${g(40)}');
124
+ define('LOGGED_IN_SALT', '${g(40)}');
125
+ define('NONCE_SALT', '${g(40)}');
126
+ ?>${e.replaceAll("', 'put your unique phrase here'", "__', ''")}`
107
127
  );
108
128
  }
109
129
  async disableSiteHealth() {
110
- await P(
130
+ await b(
111
131
  this.php,
112
132
  `${this.wordpressPath}/wp-includes/default-filters.php`,
113
133
  (e) => e.replace(
@@ -117,7 +137,7 @@ class he {
117
137
  );
118
138
  }
119
139
  async disableWpNewBlogNotification() {
120
- await P(
140
+ await b(
121
141
  this.php,
122
142
  `${this.wordpressPath}/wp-config.php`,
123
143
  // The original version of this function crashes WASM PHP, let's define an empty one instead.
@@ -125,47 +145,37 @@ class he {
125
145
  );
126
146
  }
127
147
  }
128
- const ue = async (s, { code: e }) => await s.run({ code: e }), pe = async (s, { options: e }) => await s.run(e), de = async (s, { key: e, value: t }) => {
129
- await s.setPhpIniEntry(e, t);
130
- }, fe = async (s, { request: e }) => await s.request(e), me = async (s, { fromPath: e, toPath: t }) => {
131
- await s.writeFile(
148
+ function g(r) {
149
+ const e = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()_+=-[]/.,<>?";
150
+ let t = "";
151
+ for (let s = r; s > 0; --s)
152
+ t += e[Math.floor(Math.random() * e.length)];
153
+ return t;
154
+ }
155
+ const pe = async (r, { code: e }) => await r.run({ code: e }), de = async (r, { options: e }) => await r.run(e), fe = async (r, { key: e, value: t }) => {
156
+ await r.setPhpIniEntry(e, t);
157
+ }, me = async (r, { request: e }) => await r.request(e), we = async (r, { fromPath: e, toPath: t }) => {
158
+ await r.writeFile(
132
159
  t,
133
- await s.readFileAsBuffer(e)
160
+ await r.readFileAsBuffer(e)
134
161
  );
135
- }, we = async (s, { fromPath: e, toPath: t }) => {
136
- await s.mv(e, t);
137
- }, ge = async (s, { path: e }) => {
138
- await s.mkdir(e);
139
- }, ye = async (s, { path: e }) => {
140
- await s.unlink(e);
141
- }, Pe = async (s, { path: e }) => {
142
- await s.rmdir(e);
143
- }, Z = async (s, { path: e, data: t }) => {
144
- t instanceof File && (t = await ae(t)), await s.writeFile(e, t);
145
- }, N = "/vfs-blueprints", Q = async (s, { consts: e, virtualize: t = !1 }) => {
146
- const r = await s.documentRoot, i = t ? N : r, n = `${i}/playground-consts.json`, o = `${i}/wp-config.php`;
147
- return t && (s.mkdir(N), s.setPhpIniEntry("auto_prepend_file", o)), await P(
148
- s,
149
- n,
150
- (a) => JSON.stringify({
151
- ...JSON.parse(a || "{}"),
152
- ...e
153
- })
154
- ), await P(s, o, (a) => a.includes("playground-consts.json") ? a : `<?php
155
- $consts = json_decode(file_get_contents('${n}'), true);
156
- foreach ($consts as $const => $value) {
157
- if (!defined($const)) {
158
- define($const, $value);
159
- }
160
- }
161
- ?>${a}`), o;
162
- }, _e = async (s, { siteUrl: e }) => await Q(s, {
162
+ }, ge = async (r, { fromPath: e, toPath: t }) => {
163
+ await r.mv(e, t);
164
+ }, ye = async (r, { path: e }) => {
165
+ await r.mkdir(e);
166
+ }, _e = async (r, { path: e }) => {
167
+ await r.unlink(e);
168
+ }, Pe = async (r, { path: e }) => {
169
+ await r.rmdir(e);
170
+ }, X = async (r, { path: e, data: t }) => {
171
+ t instanceof File && (t = await ce(t)), await r.writeFile(e, t);
172
+ }, $e = async (r, { siteUrl: e }) => await x(r, {
163
173
  consts: {
164
174
  WP_HOME: e,
165
175
  WP_SITEURL: e
166
176
  }
167
177
  });
168
- class X {
178
+ class ee {
169
179
  constructor({ concurrency: e }) {
170
180
  this._running = 0, this.concurrency = e, this.queue = [];
171
181
  }
@@ -176,10 +186,13 @@ class X {
176
186
  for (; ; )
177
187
  if (this._running >= this.concurrency)
178
188
  await new Promise((e) => this.queue.push(e));
179
- else
180
- return this._running++, () => {
181
- this._running--, this.queue.length > 0 && this.queue.shift()();
189
+ else {
190
+ this._running++;
191
+ let e = !1;
192
+ return () => {
193
+ e || (e = !0, this._running--, this.queue.length > 0 && this.queue.shift()());
182
194
  };
195
+ }
183
196
  }
184
197
  async run(e) {
185
198
  const t = await this.acquire();
@@ -190,29 +203,29 @@ class X {
190
203
  }
191
204
  }
192
205
  }
193
- const $e = Symbol("literal");
194
- function $(s) {
195
- if (typeof s == "string")
196
- return s.startsWith("$") ? s : JSON.stringify(s);
197
- if (typeof s == "number")
198
- return s.toString();
199
- if (Array.isArray(s))
200
- return `array(${s.map($).join(", ")})`;
201
- if (s === null)
206
+ const be = Symbol("literal");
207
+ function $(r) {
208
+ if (typeof r == "string")
209
+ return r.startsWith("$") ? r : JSON.stringify(r);
210
+ if (typeof r == "number")
211
+ return r.toString();
212
+ if (Array.isArray(r))
213
+ return `array(${r.map($).join(", ")})`;
214
+ if (r === null)
202
215
  return "null";
203
- if (typeof s == "object")
204
- return $e in s ? s.toString() : `array(${Object.entries(s).map(([t, r]) => `${JSON.stringify(t)} => ${$(r)}`).join(", ")})`;
205
- if (typeof s == "function")
206
- return s();
207
- throw new Error(`Unsupported value: ${s}`);
216
+ if (typeof r == "object")
217
+ return be in r ? r.toString() : `array(${Object.entries(r).map(([t, s]) => `${JSON.stringify(t)} => ${$(s)}`).join(", ")})`;
218
+ if (typeof r == "function")
219
+ return r();
220
+ throw new Error(`Unsupported value: ${r}`);
208
221
  }
209
- function x(s) {
222
+ function F(r) {
210
223
  const e = {};
211
- for (const t in s)
212
- e[t] = $(s[t]);
224
+ for (const t in r)
225
+ e[t] = $(r[t]);
213
226
  return e;
214
227
  }
215
- const O = `<?php
228
+ const H = `<?php
216
229
 
217
230
  function zipDir($dir, $output, $additionalFiles = array())
218
231
  {
@@ -275,29 +288,29 @@ function delTree($dir)
275
288
  return rmdir($dir);
276
289
  }
277
290
  `;
278
- async function be(s) {
279
- const e = "wordpress-playground.zip", t = `/${e}`, r = x({
291
+ async function ve(r) {
292
+ const e = "wordpress-playground.zip", t = `/${e}`, s = F({
280
293
  zipPath: t,
281
- documentRoot: await s.documentRoot
294
+ documentRoot: await r.documentRoot
282
295
  });
283
- await ee(
284
- s,
285
- `zipDir(${r.documentRoot}, ${r.zipPath});`
296
+ await te(
297
+ r,
298
+ `zipDir(${s.documentRoot}, ${s.zipPath});`
286
299
  );
287
- const i = await s.readFileAsBuffer(t);
288
- return s.unlink(t), new File([i], e);
300
+ const i = await r.readFileAsBuffer(t);
301
+ return r.unlink(t), new File([i], e);
289
302
  }
290
- const ve = async (s, { fullSiteZip: e }) => {
303
+ const Ee = async (r, { fullSiteZip: e }) => {
291
304
  const t = "/import.zip";
292
- await s.writeFile(
305
+ await r.writeFile(
293
306
  t,
294
307
  new Uint8Array(await e.arrayBuffer())
295
308
  );
296
- const r = await s.absoluteUrl, i = await s.documentRoot;
297
- await s.rmdir(i), await F(s, { zipPath: t, extractToPath: "/" });
298
- const n = x({ absoluteUrl: r });
299
- await Re(
300
- s,
309
+ const s = await r.absoluteUrl, i = await r.documentRoot;
310
+ await r.rmdir(i), await C(r, { zipPath: t, extractToPath: "/" });
311
+ const n = F({ absoluteUrl: s });
312
+ await Te(
313
+ r,
301
314
  `${i}/wp-config.php`,
302
315
  (o) => `<?php
303
316
  if(!defined('WP_HOME')) {
@@ -306,122 +319,122 @@ const ve = async (s, { fullSiteZip: e }) => {
306
319
  }
307
320
  ?>${o}`
308
321
  );
309
- }, F = async (s, { zipPath: e, extractToPath: t }) => {
310
- const r = x({
322
+ }, C = async (r, { zipPath: e, extractToPath: t }) => {
323
+ const s = F({
311
324
  zipPath: e,
312
325
  extractToPath: t
313
326
  });
314
- await ee(
315
- s,
316
- `unzip(${r.zipPath}, ${r.extractToPath});`
327
+ await te(
328
+ r,
329
+ `unzip(${s.zipPath}, ${s.extractToPath});`
317
330
  );
318
- }, Ee = async (s, { file: e }) => {
319
- const t = await s.request({
331
+ }, Se = async (r, { file: e }) => {
332
+ const t = await r.request({
320
333
  url: "/wp-admin/admin.php?import=wordpress"
321
- }), r = L(t).getElementById("import-upload-form")?.getAttribute("action"), i = await s.request({
322
- url: `/wp-admin/${r}`,
334
+ }), s = I(t).getElementById("import-upload-form")?.getAttribute("action"), i = await r.request({
335
+ url: `/wp-admin/${s}`,
323
336
  method: "POST",
324
337
  files: { import: e }
325
- }), n = L(i).querySelector(
338
+ }), n = I(i).querySelector(
326
339
  "#wpbody-content form"
327
340
  );
328
341
  if (!n)
329
342
  throw console.log(i.text), new Error(
330
343
  "Could not find an importer form in response. See the response text above for details."
331
344
  );
332
- const o = Se(n);
345
+ const o = Re(n);
333
346
  o.fetch_attachments = "1";
334
347
  for (const a in o)
335
348
  if (a.startsWith("user_map[")) {
336
349
  const l = "user_new[" + a.slice(9, -1) + "]";
337
350
  o[l] = "1";
338
351
  }
339
- await s.request({
352
+ await r.request({
340
353
  url: n.action,
341
354
  method: "POST",
342
355
  formData: o
343
356
  });
344
357
  };
345
- function L(s) {
346
- return new DOMParser().parseFromString(s.text, "text/html");
358
+ function I(r) {
359
+ return new DOMParser().parseFromString(r.text, "text/html");
347
360
  }
348
- function Se(s) {
349
- return Object.fromEntries(new FormData(s).entries());
361
+ function Re(r) {
362
+ return Object.fromEntries(new FormData(r).entries());
350
363
  }
351
- async function Re(s, e, t) {
352
- await s.writeFile(
364
+ async function Te(r, e, t) {
365
+ await r.writeFile(
353
366
  e,
354
- t(await s.readFileAsText(e))
367
+ t(await r.readFileAsText(e))
355
368
  );
356
369
  }
357
- async function ee(s, e) {
358
- const t = await s.run({
359
- code: O + e
370
+ async function te(r, e) {
371
+ const t = await r.run({
372
+ code: H + e
360
373
  });
361
374
  if (t.exitCode !== 0)
362
- throw console.log(O + e), console.log(e + ""), console.log(t.errors), t.errors;
375
+ throw console.log(H + e), console.log(e + ""), console.log(t.errors), t.errors;
363
376
  return t;
364
377
  }
365
- async function te(s, { targetPath: e, zipFile: t }) {
366
- const r = t.name, i = r.replace(/\.zip$/, ""), n = `/tmp/assets/${i}`, o = `/tmp/${r}`, a = () => s.rmdir(n, {
378
+ async function re(r, { targetPath: e, zipFile: t }) {
379
+ const s = t.name, i = s.replace(/\.zip$/, ""), n = `/tmp/assets/${i}`, o = `/tmp/${s}`, a = () => r.rmdir(n, {
367
380
  recursive: !0
368
381
  });
369
- await s.fileExists(n) && await a(), await Z(s, {
382
+ await r.fileExists(n) && await a(), await X(r, {
370
383
  path: o,
371
384
  data: t
372
385
  });
373
- const l = () => Promise.all([a, () => s.unlink(o)]);
386
+ const l = () => Promise.all([a, () => r.unlink(o)]);
374
387
  try {
375
- await F(s, {
388
+ await C(r, {
376
389
  zipPath: o,
377
390
  extractToPath: n
378
391
  });
379
- const c = await s.listFiles(n, {
392
+ const c = await r.listFiles(n, {
380
393
  prependPath: !0
381
- }), u = c.length === 1 && await s.isDir(c[0]);
382
- let d, v = "";
383
- u ? (v = c[0], d = c[0].split("/").pop()) : (v = n, d = i);
384
- const U = `${e}/${d}`;
385
- return await s.mv(v, U), await l(), {
386
- assetFolderPath: U,
394
+ }), u = c.length === 1 && await r.isDir(c[0]);
395
+ let d, E = "";
396
+ u ? (E = c[0], d = c[0].split("/").pop()) : (E = n, d = i);
397
+ const L = `${e}/${d}`;
398
+ return await r.mv(E, L), await l(), {
399
+ assetFolderPath: L,
387
400
  assetFolderName: d
388
401
  };
389
402
  } catch (c) {
390
403
  throw await l(), c;
391
404
  }
392
405
  }
393
- const xe = async (s, { pluginZipFile: e, options: t = {} }, r) => {
394
- const i = e.name.split("/").pop() || "plugin.zip", n = b(i);
395
- r?.tracker.setCaption(`Installing the ${n} plugin`);
406
+ const xe = async (r, { pluginZipFile: e, options: t = {} }, s) => {
407
+ const i = e.name.split("/").pop() || "plugin.zip", n = v(i);
408
+ s?.tracker.setCaption(`Installing the ${n} plugin`);
396
409
  try {
397
- const { assetFolderPath: o } = await te(s, {
410
+ const { assetFolderPath: o } = await re(r, {
398
411
  zipFile: e,
399
- targetPath: `${await s.documentRoot}/wp-content/plugins`
412
+ targetPath: `${await r.documentRoot}/wp-content/plugins`
400
413
  });
401
- ("activate" in t ? t.activate : !0) && await J(
402
- s,
414
+ ("activate" in t ? t.activate : !0) && await Z(
415
+ r,
403
416
  {
404
417
  pluginPath: o,
405
418
  pluginName: n
406
419
  },
407
- r
408
- ), await Fe(s);
420
+ s
421
+ ), await Fe(r);
409
422
  } catch (o) {
410
423
  console.error(
411
424
  `Proceeding without the ${n} plugin. Could not install it in wp-admin. The original error was: ${o}`
412
425
  ), console.error(o);
413
426
  }
414
427
  };
415
- async function Fe(s) {
416
- await s.isDir("/wordpress/wp-content/plugins/gutenberg") && !await s.fileExists("/wordpress/.gutenberg-patched") && (await s.writeFile("/wordpress/.gutenberg-patched", "1"), await H(
417
- s,
428
+ async function Fe(r) {
429
+ await r.isDir("/wordpress/wp-content/plugins/gutenberg") && !await r.fileExists("/wordpress/.gutenberg-patched") && (await r.writeFile("/wordpress/.gutenberg-patched", "1"), await W(
430
+ r,
418
431
  "/wordpress/wp-content/plugins/gutenberg/build/block-editor/index.js",
419
432
  (e) => e.replace(
420
433
  /srcDoc:("[^"]+"|[^,]+)/g,
421
434
  'src:"/wp-includes/empty.html"'
422
435
  )
423
- ), await H(
424
- s,
436
+ ), await W(
437
+ r,
425
438
  "/wordpress/wp-content/plugins/gutenberg/build/block-editor/index.min.js",
426
439
  (e) => e.replace(
427
440
  /srcDoc:("[^"]+"|[^,]+)/g,
@@ -429,36 +442,36 @@ async function Fe(s) {
429
442
  )
430
443
  ));
431
444
  }
432
- async function H(s, e, t) {
433
- return await s.writeFile(
445
+ async function W(r, e, t) {
446
+ return await r.writeFile(
434
447
  e,
435
- t(await s.readFileAsText(e))
448
+ t(await r.readFileAsText(e))
436
449
  );
437
450
  }
438
- const Te = async (s, { themeZipFile: e, options: t = {} }, r) => {
439
- const i = b(e.name);
440
- r?.tracker.setCaption(`Installing the ${i} theme`);
451
+ const Ce = async (r, { themeZipFile: e, options: t = {} }, s) => {
452
+ const i = v(e.name);
453
+ s?.tracker.setCaption(`Installing the ${i} theme`);
441
454
  try {
442
- const { assetFolderName: n } = await te(s, {
455
+ const { assetFolderName: n } = await re(r, {
443
456
  zipFile: e,
444
- targetPath: `${await s.documentRoot}/wp-content/themes`
457
+ targetPath: `${await r.documentRoot}/wp-content/themes`
445
458
  });
446
- ("activate" in t ? t.activate : !0) && await K(
447
- s,
459
+ ("activate" in t ? t.activate : !0) && await Q(
460
+ r,
448
461
  {
449
462
  themeFolderName: n
450
463
  },
451
- r
464
+ s
452
465
  );
453
466
  } catch (n) {
454
467
  console.error(
455
468
  `Proceeding without the ${i} theme. Could not install it in wp-admin. The original error was: ${n}`
456
469
  ), console.error(n);
457
470
  }
458
- }, ke = async (s, { username: e = "admin", password: t = "password" } = {}, r) => {
459
- r?.tracker.setCaption(r?.initialCaption || "Logging in"), await s.request({
471
+ }, ke = async (r, { username: e = "admin", password: t = "password" } = {}, s) => {
472
+ s?.tracker.setCaption(s?.initialCaption || "Logging in"), await r.request({
460
473
  url: "/wp-login.php"
461
- }), await s.request({
474
+ }), await r.request({
462
475
  url: "/wp-login.php",
463
476
  method: "POST",
464
477
  formData: {
@@ -467,8 +480,8 @@ const Te = async (s, { themeZipFile: e, options: t = {} }, r) => {
467
480
  rememberme: "forever"
468
481
  }
469
482
  });
470
- }, Ce = async (s, { options: e }) => {
471
- await s.request({
483
+ }, Ae = async (r, { options: e }) => {
484
+ await r.request({
472
485
  url: "/wp-admin/install.php?step=2",
473
486
  method: "POST",
474
487
  formData: {
@@ -484,7 +497,7 @@ const Te = async (s, { themeZipFile: e, options: t = {} }, r) => {
484
497
  admin_email: "admin@localhost.com"
485
498
  }
486
499
  });
487
- }, Ae = async (s, { options: e }) => {
500
+ }, Ue = async (r, { options: e }) => {
488
501
  const t = `<?php
489
502
  include 'wordpress/wp-load.php';
490
503
  $site_options = ${$(e)};
@@ -492,57 +505,57 @@ const Te = async (s, { themeZipFile: e, options: t = {} }, r) => {
492
505
  update_option($name, $value);
493
506
  }
494
507
  echo "Success";
495
- `, r = await s.run({
508
+ `, s = await r.run({
496
509
  code: t
497
510
  });
498
- return se(r), { code: t, result: r };
499
- }, Ue = async (s, { meta: e, userId: t }) => {
500
- const r = `<?php
511
+ return se(s), { code: t, result: s };
512
+ }, Ne = async (r, { meta: e, userId: t }) => {
513
+ const s = `<?php
501
514
  include 'wordpress/wp-load.php';
502
515
  $meta = ${$(e)};
503
516
  foreach($meta as $name => $value) {
504
517
  update_user_meta(${$(t)}, $name, $value);
505
518
  }
506
519
  echo "Success";
507
- `, i = await s.run({
508
- code: r
520
+ `, i = await r.run({
521
+ code: s
509
522
  });
510
- return se(i), { code: r, result: i };
523
+ return se(i), { code: s, result: i };
511
524
  };
512
- async function se(s) {
513
- if (s.text !== "Success")
514
- throw console.log(s), new Error(`Failed to run code: ${s.text} ${s.errors}`);
525
+ async function se(r) {
526
+ if (r.text !== "Success")
527
+ throw console.log(r), new Error(`Failed to run code: ${r.text} ${r.errors}`);
515
528
  }
516
- const Ne = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
529
+ const Le = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
517
530
  __proto__: null,
518
- activatePlugin: J,
519
- activateTheme: K,
520
- applyWordPressPatches: le,
521
- cp: me,
522
- defineSiteUrl: _e,
523
- defineWpConfigConsts: Q,
524
- importFile: Ee,
531
+ activatePlugin: Z,
532
+ activateTheme: Q,
533
+ applyWordPressPatches: he,
534
+ cp: we,
535
+ defineSiteUrl: $e,
536
+ defineWpConfigConsts: x,
537
+ importFile: Se,
525
538
  installPlugin: xe,
526
- installTheme: Te,
539
+ installTheme: Ce,
527
540
  login: ke,
528
- mkdir: ge,
529
- mv: we,
530
- replaceSite: ve,
531
- request: fe,
532
- rm: ye,
541
+ mkdir: ye,
542
+ mv: ge,
543
+ replaceSite: Ee,
544
+ request: me,
545
+ rm: _e,
533
546
  rmdir: Pe,
534
- runPHP: ue,
535
- runPHPWithOptions: pe,
536
- runWpInstallationWizard: Ce,
537
- setPhpIniEntry: de,
538
- setSiteOptions: Ae,
539
- unzip: F,
540
- updateUserMeta: Ue,
541
- writeFile: Z,
542
- zipEntireSite: be
547
+ runPHP: pe,
548
+ runPHPWithOptions: de,
549
+ runWpInstallationWizard: Ae,
550
+ setPhpIniEntry: fe,
551
+ setSiteOptions: Ue,
552
+ unzip: C,
553
+ updateUserMeta: Ne,
554
+ writeFile: X,
555
+ zipEntireSite: ve
543
556
  }, Symbol.toStringTag, { value: "Module" })), Oe = 5 * 1024 * 1024;
544
- function Le(s, e) {
545
- const t = s.headers.get("content-length") || "", r = parseInt(t, 10) || Oe;
557
+ function He(r, e) {
558
+ const t = r.headers.get("content-length") || "", s = parseInt(t, 10) || Oe;
546
559
  function i(n, o) {
547
560
  e(
548
561
  new CustomEvent("progress", {
@@ -556,11 +569,11 @@ function Le(s, e) {
556
569
  return new Response(
557
570
  new ReadableStream({
558
571
  async start(n) {
559
- if (!s.body) {
572
+ if (!r.body) {
560
573
  n.close();
561
574
  return;
562
575
  }
563
- const o = s.body.getReader();
576
+ const o = r.body.getReader();
564
577
  let a = 0;
565
578
  for (; ; )
566
579
  try {
@@ -569,7 +582,7 @@ function Le(s, e) {
569
582
  i(a, a), n.close();
570
583
  break;
571
584
  } else
572
- i(a, r), n.enqueue(c);
585
+ i(a, s), n.enqueue(c);
573
586
  } catch (l) {
574
587
  console.error({ e: l }), n.error(l);
575
588
  break;
@@ -577,20 +590,20 @@ function Le(s, e) {
577
590
  }
578
591
  }),
579
592
  {
580
- status: s.status,
581
- statusText: s.statusText,
582
- headers: s.headers
593
+ status: r.status,
594
+ statusText: r.statusText,
595
+ headers: r.headers
583
596
  }
584
597
  );
585
598
  }
586
- const E = 1e-5;
587
- class T extends EventTarget {
599
+ const S = 1e-5;
600
+ class k extends EventTarget {
588
601
  constructor({
589
602
  weight: e = 1,
590
603
  caption: t = "",
591
- fillTime: r = 4
604
+ fillTime: s = 4
592
605
  } = {}) {
593
- super(), this._selfWeight = 1, this._selfDone = !1, this._selfProgress = 0, this._selfCaption = "", this._isFilling = !1, this._subTrackers = [], this._weight = e, this._selfCaption = t, this._fillTime = r;
606
+ super(), this._selfWeight = 1, this._selfDone = !1, this._selfProgress = 0, this._selfCaption = "", this._isFilling = !1, this._subTrackers = [], this._weight = e, this._selfCaption = t, this._fillTime = s;
594
607
  }
595
608
  /**
596
609
  * Creates a new sub-tracker with a specific weight.
@@ -628,19 +641,19 @@ class T extends EventTarget {
628
641
  * ```
629
642
  */
630
643
  stage(e, t = "") {
631
- if (e || (e = this._selfWeight), this._selfWeight - e < -E)
644
+ if (e || (e = this._selfWeight), this._selfWeight - e < -S)
632
645
  throw new Error(
633
646
  `Cannot add a stage with weight ${e} as the total weight of registered stages would exceed 1.`
634
647
  );
635
648
  this._selfWeight -= e;
636
- const r = new T({
649
+ const s = new k({
637
650
  caption: t,
638
651
  weight: e,
639
652
  fillTime: this._fillTime
640
653
  });
641
- return this._subTrackers.push(r), r.addEventListener("progress", () => this.notifyProgress()), r.addEventListener("done", () => {
654
+ return this._subTrackers.push(s), s.addEventListener("progress", () => this.notifyProgress()), s.addEventListener("done", () => {
642
655
  this.done && this.notifyDone();
643
- }), r;
656
+ }), s;
644
657
  }
645
658
  /**
646
659
  * Fills the progress bar slowly over time, simulating progress.
@@ -664,13 +677,13 @@ class T extends EventTarget {
664
677
  if (this._isFilling)
665
678
  return;
666
679
  this._isFilling = !0;
667
- const t = 100, r = this._fillTime / t;
680
+ const t = 100, s = this._fillTime / t;
668
681
  this._fillInterval = setInterval(() => {
669
682
  this.set(this._selfProgress + 1), e && this._selfProgress >= 99 && clearInterval(this._fillInterval);
670
- }, r);
683
+ }, s);
671
684
  }
672
685
  set(e) {
673
- this._selfProgress = Math.min(e, 100), this.notifyProgress(), this._selfProgress + E >= 100 && this.finish();
686
+ this._selfProgress = Math.min(e, 100), this.notifyProgress(), this._selfProgress + S >= 100 && this.finish();
674
687
  }
675
688
  finish() {
676
689
  this._fillInterval && clearInterval(this._fillInterval), this._selfDone = !0, this._selfProgress = 100, this._isFilling = !1, this._fillInterval = void 0, this.notifyProgress(), this.notifyDone();
@@ -688,13 +701,13 @@ class T extends EventTarget {
688
701
  this._selfCaption = e, this.notifyProgress();
689
702
  }
690
703
  get done() {
691
- return this.progress + E >= 100;
704
+ return this.progress + S >= 100;
692
705
  }
693
706
  get progress() {
694
707
  if (this._selfDone)
695
708
  return 100;
696
709
  const e = this._subTrackers.reduce(
697
- (t, r) => t + r.progress * r.weight,
710
+ (t, s) => t + s.progress * s.weight,
698
711
  this._selfProgress * this._selfWeight
699
712
  );
700
713
  return Math.round(e * 1e4) / 1e4;
@@ -750,8 +763,8 @@ class T extends EventTarget {
750
763
  this.dispatchEvent(new CustomEvent("done"));
751
764
  }
752
765
  }
753
- const I = Symbol("error"), W = Symbol("message");
754
- class k extends Event {
766
+ const D = Symbol("error"), M = Symbol("message");
767
+ class A extends Event {
755
768
  /**
756
769
  * Create a new `ErrorEvent`.
757
770
  *
@@ -760,19 +773,19 @@ class k extends Event {
760
773
  * attributes via object members of the same name.
761
774
  */
762
775
  constructor(e, t = {}) {
763
- super(e), this[I] = t.error === void 0 ? null : t.error, this[W] = t.message === void 0 ? "" : t.message;
776
+ super(e), this[D] = t.error === void 0 ? null : t.error, this[M] = t.message === void 0 ? "" : t.message;
764
777
  }
765
778
  get error() {
766
- return this[I];
779
+ return this[D];
767
780
  }
768
781
  get message() {
769
- return this[W];
782
+ return this[M];
770
783
  }
771
784
  }
772
- Object.defineProperty(k.prototype, "error", { enumerable: !0 });
773
- Object.defineProperty(k.prototype, "message", { enumerable: !0 });
774
- const He = typeof globalThis.ErrorEvent == "function" ? globalThis.ErrorEvent : k;
775
- class Ie extends EventTarget {
785
+ Object.defineProperty(A.prototype, "error", { enumerable: !0 });
786
+ Object.defineProperty(A.prototype, "message", { enumerable: !0 });
787
+ const Ie = typeof globalThis.ErrorEvent == "function" ? globalThis.ErrorEvent : A;
788
+ class We extends EventTarget {
776
789
  constructor() {
777
790
  super(...arguments), this.listenersCount = 0;
778
791
  }
@@ -786,30 +799,30 @@ class Ie extends EventTarget {
786
799
  return this.listenersCount > 0;
787
800
  }
788
801
  }
789
- function We(s) {
790
- s.asm = {
791
- ...s.asm
802
+ function De(r) {
803
+ r.asm = {
804
+ ...r.asm
792
805
  };
793
- const e = new Ie();
794
- for (const t in s.asm)
795
- if (typeof s.asm[t] == "function") {
796
- const r = s.asm[t];
797
- s.asm[t] = function(...i) {
806
+ const e = new We();
807
+ for (const t in r.asm)
808
+ if (typeof r.asm[t] == "function") {
809
+ const s = r.asm[t];
810
+ r.asm[t] = function(...i) {
798
811
  try {
799
- return r(...i);
812
+ return s(...i);
800
813
  } catch (n) {
801
814
  if (!(n instanceof Error))
802
815
  throw n;
803
816
  if ("exitCode" in n && n?.exitCode === 0)
804
817
  return;
805
- const o = qe(
818
+ const o = ze(
806
819
  n,
807
- s.lastAsyncifyStackSource?.stack
820
+ r.lastAsyncifyStackSource?.stack
808
821
  );
809
- if (s.lastAsyncifyStackSource && (n.cause = s.lastAsyncifyStackSource), !e.hasListeners())
810
- throw Be(o), n;
822
+ if (r.lastAsyncifyStackSource && (n.cause = r.lastAsyncifyStackSource), !e.hasListeners())
823
+ throw je(o), n;
811
824
  e.dispatchEvent(
812
- new He("error", {
825
+ new Ie("error", {
813
826
  error: n,
814
827
  message: o
815
828
  })
@@ -819,29 +832,29 @@ function We(s) {
819
832
  }
820
833
  return e;
821
834
  }
822
- let S = [];
823
- function De() {
824
- return S;
835
+ let R = [];
836
+ function Me() {
837
+ return R;
825
838
  }
826
- function qe(s, e) {
827
- if (s.message === "unreachable") {
828
- let t = ze;
839
+ function ze(r, e) {
840
+ if (r.message === "unreachable") {
841
+ let t = qe;
829
842
  e || (t += `
830
843
 
831
844
  This stack trace is lacking. For a better one initialize
832
845
  the PHP runtime with { debug: true }, e.g. PHPNode.load('8.1', { debug: true }).
833
846
 
834
- `), S = je(
835
- e || s.stack || ""
847
+ `), R = Ge(
848
+ e || r.stack || ""
836
849
  );
837
- for (const r of S)
838
- t += ` * ${r}
850
+ for (const s of R)
851
+ t += ` * ${s}
839
852
  `;
840
853
  return t;
841
854
  }
842
- return s.message;
855
+ return r.message;
843
856
  }
844
- const ze = `
857
+ const qe = `
845
858
  "unreachable" WASM instruction executed.
846
859
 
847
860
  The typical reason is a PHP function missing from the ASYNCIFY_ONLY
@@ -865,42 +878,42 @@ the Dockerfile, you'll need to trigger this error again with long stack
865
878
  traces enabled. In node.js, you can do it using the --stack-trace-limit=100
866
879
  CLI option:
867
880
 
868
- `, D = "\x1B[41m", Me = "\x1B[1m", q = "\x1B[0m", z = "\x1B[K";
869
- let M = !1;
870
- function Be(s) {
871
- if (!M) {
872
- M = !0, console.log(`${D}
873
- ${z}
874
- ${Me} WASM ERROR${q}${D}`);
875
- for (const e of s.split(`
881
+ `, z = "\x1B[41m", Be = "\x1B[1m", q = "\x1B[0m", B = "\x1B[K";
882
+ let j = !1;
883
+ function je(r) {
884
+ if (!j) {
885
+ j = !0, console.log(`${z}
886
+ ${B}
887
+ ${Be} WASM ERROR${q}${z}`);
888
+ for (const e of r.split(`
876
889
  `))
877
- console.log(`${z} ${e} `);
890
+ console.log(`${B} ${e} `);
878
891
  console.log(`${q}`);
879
892
  }
880
893
  }
881
- function je(s) {
894
+ function Ge(r) {
882
895
  try {
883
- const e = s.split(`
896
+ const e = r.split(`
884
897
  `).slice(1).map((t) => {
885
- const r = t.trim().substring(3).split(" ");
898
+ const s = t.trim().substring(3).split(" ");
886
899
  return {
887
- fn: r.length >= 2 ? r[0] : "<unknown>",
900
+ fn: s.length >= 2 ? s[0] : "<unknown>",
888
901
  isWasm: t.includes("wasm://")
889
902
  };
890
903
  }).filter(
891
- ({ fn: t, isWasm: r }) => r && !t.startsWith("dynCall_") && !t.startsWith("invoke_")
904
+ ({ fn: t, isWasm: s }) => s && !t.startsWith("dynCall_") && !t.startsWith("invoke_")
892
905
  ).map(({ fn: t }) => t);
893
906
  return Array.from(new Set(e));
894
907
  } catch {
895
908
  return [];
896
909
  }
897
910
  }
898
- class _ {
899
- constructor(e, t, r, i = "", n = 0) {
900
- this.httpStatusCode = e, this.headers = t, this.bytes = r, this.exitCode = n, this.errors = i;
911
+ class P {
912
+ constructor(e, t, s, i = "", n = 0) {
913
+ this.httpStatusCode = e, this.headers = t, this.bytes = s, this.exitCode = n, this.errors = i;
901
914
  }
902
915
  static fromRawData(e) {
903
- return new _(
916
+ return new P(
904
917
  e.httpStatusCode,
905
918
  e.headers,
906
919
  e.bytes,
@@ -930,7 +943,7 @@ class _ {
930
943
  return new TextDecoder().decode(this.bytes);
931
944
  }
932
945
  }
933
- const re = [
946
+ const ie = [
934
947
  "8.2",
935
948
  "8.1",
936
949
  "8.0",
@@ -940,8 +953,8 @@ const re = [
940
953
  "7.1",
941
954
  "7.0",
942
955
  "5.6"
943
- ], Ge = re[0];
944
- class Ve {
956
+ ], Ve = ie[0];
957
+ class Ye {
945
958
  #e;
946
959
  #t;
947
960
  /**
@@ -970,16 +983,16 @@ class Ve {
970
983
  * @returns PHPRequestHandler response.
971
984
  */
972
985
  async request(e, t = 0) {
973
- const r = await this.requestHandler.request({
986
+ const s = await this.requestHandler.request({
974
987
  ...e,
975
988
  headers: {
976
989
  ...e.headers,
977
- cookie: this.#s()
990
+ cookie: this.#r()
978
991
  }
979
992
  });
980
- if (r.headers["set-cookie"] && this.#r(r.headers["set-cookie"]), this.#t.handleRedirects && r.headers.location && t < this.#t.maxRedirects) {
993
+ if (s.headers["set-cookie"] && this.#s(s.headers["set-cookie"]), this.#t.handleRedirects && s.headers.location && t < this.#t.maxRedirects) {
981
994
  const i = new URL(
982
- r.headers.location[0],
995
+ s.headers.location[0],
983
996
  this.requestHandler.absoluteUrl
984
997
  );
985
998
  return this.request(
@@ -991,7 +1004,7 @@ class Ve {
991
1004
  t + 1
992
1005
  );
993
1006
  }
994
- return r;
1007
+ return s;
995
1008
  }
996
1009
  /** @inheritDoc */
997
1010
  pathToInternalUrl(e) {
@@ -1009,39 +1022,39 @@ class Ve {
1009
1022
  get documentRoot() {
1010
1023
  return this.requestHandler.documentRoot;
1011
1024
  }
1012
- #r(e) {
1025
+ #s(e) {
1013
1026
  for (const t of e)
1014
1027
  try {
1015
1028
  if (!t.includes("="))
1016
1029
  continue;
1017
- const r = t.indexOf("="), i = t.substring(0, r), n = t.substring(r + 1).split(";")[0];
1030
+ const s = t.indexOf("="), i = t.substring(0, s), n = t.substring(s + 1).split(";")[0];
1018
1031
  this.#e[i] = n;
1019
- } catch (r) {
1020
- console.error(r);
1032
+ } catch (s) {
1033
+ console.error(s);
1021
1034
  }
1022
1035
  }
1023
- #s() {
1036
+ #r() {
1024
1037
  const e = [];
1025
1038
  for (const t in this.#e)
1026
1039
  e.push(`${t}=${this.#e[t]}`);
1027
1040
  return e.join("; ");
1028
1041
  }
1029
1042
  }
1030
- const Ye = "http://example.com";
1031
- function B(s) {
1032
- return s.toString().substring(s.origin.length);
1043
+ const Ke = "http://example.com";
1044
+ function G(r) {
1045
+ return r.toString().substring(r.origin.length);
1033
1046
  }
1034
- function j(s, e) {
1035
- return !e || !s.startsWith(e) ? s : s.substring(e.length);
1047
+ function V(r, e) {
1048
+ return !e || !r.startsWith(e) ? r : r.substring(e.length);
1036
1049
  }
1037
- function Je(s, e) {
1038
- return !e || s.startsWith(e) ? s : e + s;
1050
+ function Je(r, e) {
1051
+ return !e || r.startsWith(e) ? r : e + r;
1039
1052
  }
1040
- class Ke {
1053
+ class Ze {
1041
1054
  #e;
1042
1055
  #t;
1043
- #r;
1044
1056
  #s;
1057
+ #r;
1045
1058
  #n;
1046
1059
  #i;
1047
1060
  #o;
@@ -1052,19 +1065,19 @@ class Ke {
1052
1065
  * @param config - Request Handler configuration.
1053
1066
  */
1054
1067
  constructor(e, t = {}) {
1055
- this.#a = new X({ concurrency: 1 });
1068
+ this.#a = new ee({ concurrency: 1 });
1056
1069
  const {
1057
- documentRoot: r = "/www/",
1070
+ documentRoot: s = "/www/",
1058
1071
  absoluteUrl: i = typeof location == "object" ? location?.href : "",
1059
1072
  isStaticFilePath: n = () => !1
1060
1073
  } = t;
1061
- this.php = e, this.#e = r, this.#c = n;
1074
+ this.php = e, this.#e = s, this.#c = n;
1062
1075
  const o = new URL(i);
1063
- this.#r = o.hostname, this.#s = o.port ? Number(o.port) : o.protocol === "https:" ? 443 : 80, this.#t = (o.protocol || "").replace(":", "");
1064
- const a = this.#s !== 443 && this.#s !== 80;
1076
+ this.#s = o.hostname, this.#r = o.port ? Number(o.port) : o.protocol === "https:" ? 443 : 80, this.#t = (o.protocol || "").replace(":", "");
1077
+ const a = this.#r !== 443 && this.#r !== 80;
1065
1078
  this.#n = [
1066
- this.#r,
1067
- a ? `:${this.#s}` : ""
1079
+ this.#s,
1080
+ a ? `:${this.#r}` : ""
1068
1081
  ].join(""), this.#i = o.pathname.replace(/\/+$/, ""), this.#o = [
1069
1082
  `${this.#t}://`,
1070
1083
  this.#n,
@@ -1078,7 +1091,7 @@ class Ke {
1078
1091
  /** @inheritDoc */
1079
1092
  internalUrlToPath(e) {
1080
1093
  const t = new URL(e);
1081
- return t.pathname.startsWith(this.#i) && (t.pathname = t.pathname.slice(this.#i.length)), B(t);
1094
+ return t.pathname.startsWith(this.#i) && (t.pathname = t.pathname.slice(this.#i.length)), G(t);
1082
1095
  }
1083
1096
  get isRequestRunning() {
1084
1097
  return this.#a.running > 0;
@@ -1093,14 +1106,14 @@ class Ke {
1093
1106
  }
1094
1107
  /** @inheritDoc */
1095
1108
  async request(e) {
1096
- const t = e.url.startsWith("http://") || e.url.startsWith("https://"), r = new URL(
1109
+ const t = e.url.startsWith("http://") || e.url.startsWith("https://"), s = new URL(
1097
1110
  e.url,
1098
- t ? void 0 : Ye
1099
- ), i = j(
1100
- r.pathname,
1111
+ t ? void 0 : Ke
1112
+ ), i = V(
1113
+ s.pathname,
1101
1114
  this.#i
1102
1115
  );
1103
- return this.#c(i) ? this.#l(i) : await this.#h(e, r);
1116
+ return this.#c(i) ? this.#l(i) : await this.#h(e, s);
1104
1117
  }
1105
1118
  /**
1106
1119
  * Serves a static file from the PHP filesystem.
@@ -1111,24 +1124,24 @@ class Ke {
1111
1124
  #l(e) {
1112
1125
  const t = `${this.#e}${e}`;
1113
1126
  if (!this.php.fileExists(t))
1114
- return new _(
1127
+ return new P(
1115
1128
  404,
1116
1129
  {},
1117
1130
  new TextEncoder().encode("404 File not found")
1118
1131
  );
1119
- const r = this.php.readFileAsBuffer(t);
1120
- return new _(
1132
+ const s = this.php.readFileAsBuffer(t);
1133
+ return new P(
1121
1134
  200,
1122
1135
  {
1123
- "content-length": [`${r.byteLength}`],
1136
+ "content-length": [`${s.byteLength}`],
1124
1137
  // @TODO: Infer the content-type from the arrayBuffer instead of the file path.
1125
1138
  // The code below won't return the correct mime-type if the extension
1126
1139
  // was tampered with.
1127
- "content-type": [Qe(t)],
1140
+ "content-type": [Xe(t)],
1128
1141
  "accept-ranges": ["bytes"],
1129
1142
  "cache-control": ["public, max-age=0"]
1130
1143
  },
1131
- r
1144
+ s
1132
1145
  );
1133
1146
  }
1134
1147
  /**
@@ -1139,7 +1152,7 @@ class Ke {
1139
1152
  * @returns The response.
1140
1153
  */
1141
1154
  async #h(e, t) {
1142
- const r = await this.#a.acquire();
1155
+ const s = await this.#a.acquire();
1143
1156
  try {
1144
1157
  this.php.addServerGlobalEntry("DOCUMENT_ROOT", this.#e), this.php.addServerGlobalEntry(
1145
1158
  "HTTPS",
@@ -1148,7 +1161,7 @@ class Ke {
1148
1161
  let i = "GET";
1149
1162
  const n = {
1150
1163
  host: this.#n,
1151
- ...ie(e.headers || {})
1164
+ ...ne(e.headers || {})
1152
1165
  }, o = [];
1153
1166
  if (e.files && Object.keys(e.files).length) {
1154
1167
  i = "POST";
@@ -1161,7 +1174,7 @@ class Ke {
1161
1174
  data: new Uint8Array(await u.arrayBuffer())
1162
1175
  });
1163
1176
  }
1164
- n["content-type"]?.startsWith("multipart/form-data") && (e.formData = Ze(
1177
+ n["content-type"]?.startsWith("multipart/form-data") && (e.formData = Qe(
1165
1178
  e.body || ""
1166
1179
  ), n["content-type"] = "application/x-www-form-urlencoded", delete e.body);
1167
1180
  }
@@ -1173,7 +1186,7 @@ class Ke {
1173
1186
  try {
1174
1187
  l = this.#u(t.pathname);
1175
1188
  } catch {
1176
- return new _(
1189
+ return new P(
1177
1190
  404,
1178
1191
  {},
1179
1192
  new TextEncoder().encode("404 File not found")
@@ -1181,7 +1194,7 @@ class Ke {
1181
1194
  }
1182
1195
  return await this.php.run({
1183
1196
  relativeUri: Je(
1184
- B(t),
1197
+ G(t),
1185
1198
  this.#i
1186
1199
  ),
1187
1200
  protocol: this.#t,
@@ -1192,7 +1205,7 @@ class Ke {
1192
1205
  headers: n
1193
1206
  });
1194
1207
  } finally {
1195
- r();
1208
+ s();
1196
1209
  }
1197
1210
  }
1198
1211
  /**
@@ -1205,21 +1218,21 @@ class Ke {
1205
1218
  * @returns The resolved filesystem path.
1206
1219
  */
1207
1220
  #u(e) {
1208
- let t = j(e, this.#i);
1221
+ let t = V(e, this.#i);
1209
1222
  t.includes(".php") ? t = t.split(".php")[0] + ".php" : (t.endsWith("/") || (t += "/"), t.endsWith("index.php") || (t += "index.php"));
1210
- const r = `${this.#e}${t}`;
1211
- if (this.php.fileExists(r))
1212
- return r;
1223
+ const s = `${this.#e}${t}`;
1224
+ if (this.php.fileExists(s))
1225
+ return s;
1213
1226
  if (!this.php.fileExists(`${this.#e}/index.php`))
1214
- throw new Error(`File not found: ${r}`);
1227
+ throw new Error(`File not found: ${s}`);
1215
1228
  return `${this.#e}/index.php`;
1216
1229
  }
1217
1230
  }
1218
- function Ze(s) {
1219
- const e = {}, t = s.match(/--(.*)\r\n/);
1231
+ function Qe(r) {
1232
+ const e = {}, t = r.match(/--(.*)\r\n/);
1220
1233
  if (!t)
1221
1234
  return e;
1222
- const r = t[1], i = s.split(`--${r}`);
1235
+ const s = t[1], i = r.split(`--${s}`);
1223
1236
  return i.shift(), i.pop(), i.forEach((n) => {
1224
1237
  const o = n.indexOf(`\r
1225
1238
  \r
@@ -1230,8 +1243,8 @@ function Ze(s) {
1230
1243
  }
1231
1244
  }), e;
1232
1245
  }
1233
- function Qe(s) {
1234
- switch (s.split(".").pop()) {
1246
+ function Xe(r) {
1247
+ switch (r.split(".").pop()) {
1235
1248
  case "css":
1236
1249
  return "text/css";
1237
1250
  case "js":
@@ -1270,7 +1283,7 @@ function Qe(s) {
1270
1283
  return "application-octet-stream";
1271
1284
  }
1272
1285
  }
1273
- const G = {
1286
+ const Y = {
1274
1287
  0: "No error occurred. System call completed successfully.",
1275
1288
  1: "Argument list too long.",
1276
1289
  2: "Permission denied.",
@@ -1349,16 +1362,16 @@ const G = {
1349
1362
  75: "Cross-device link.",
1350
1363
  76: "Extension: Capabilities insufficient."
1351
1364
  };
1352
- function f(s = "") {
1353
- return function(t, r, i) {
1365
+ function f(r = "") {
1366
+ return function(t, s, i) {
1354
1367
  const n = i.value;
1355
1368
  i.value = function(...o) {
1356
1369
  try {
1357
1370
  return n.apply(this, o);
1358
1371
  } catch (a) {
1359
1372
  const l = typeof a == "object" ? a?.errno : null;
1360
- if (l in G) {
1361
- const c = G[l], u = typeof o[0] == "string" ? o[0] : null, d = u !== null ? s.replaceAll("{path}", u) : s;
1373
+ if (l in Y) {
1374
+ const c = Y[l], u = typeof o[0] == "string" ? o[0] : null, d = u !== null ? r.replaceAll("{path}", u) : r;
1362
1375
  throw new Error(`${d}: ${c}`, {
1363
1376
  cause: a
1364
1377
  });
@@ -1368,19 +1381,19 @@ function f(s = "") {
1368
1381
  };
1369
1382
  };
1370
1383
  }
1371
- const Xe = [];
1372
- function et(s) {
1373
- return Xe[s];
1384
+ const et = [];
1385
+ function tt(r) {
1386
+ return et[r];
1374
1387
  }
1375
1388
  (function() {
1376
1389
  return typeof process < "u" && process.release?.name === "node" ? "NODE" : typeof window < "u" ? "WEB" : typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope ? "WORKER" : "NODE";
1377
1390
  })();
1378
- var tt = Object.defineProperty, st = Object.getOwnPropertyDescriptor, m = (s, e, t, r) => {
1379
- for (var i = r > 1 ? void 0 : r ? st(e, t) : e, n = s.length - 1, o; n >= 0; n--)
1380
- (o = s[n]) && (i = (r ? o(e, t, i) : o(i)) || i);
1381
- return r && i && tt(e, t, i), i;
1391
+ var rt = Object.defineProperty, st = Object.getOwnPropertyDescriptor, m = (r, e, t, s) => {
1392
+ for (var i = s > 1 ? void 0 : s ? st(e, t) : e, n = r.length - 1, o; n >= 0; n--)
1393
+ (o = r[n]) && (i = (s ? o(e, t, i) : o(i)) || i);
1394
+ return s && i && rt(e, t, i), i;
1382
1395
  };
1383
- const p = "string", y = "number", h = Symbol("__private__dont__use");
1396
+ const p = "string", _ = "number", h = Symbol("__private__dont__use");
1384
1397
  class w {
1385
1398
  /**
1386
1399
  * Initializes a PHP runtime.
@@ -1390,14 +1403,19 @@ class w {
1390
1403
  * @param serverOptions - Optional. Options for the PHPRequestHandler. If undefined, no request handler will be initialized.
1391
1404
  */
1392
1405
  constructor(e, t) {
1393
- this.#e = [], this.#t = !1, this.#r = null, this.#s = {}, e !== void 0 && this.initializeRuntime(e), t && (this.requestHandler = new Ve(
1394
- new Ke(this, t)
1406
+ this.#e = [], this.#t = !1, this.#s = null, this.#r = {}, this.#n = [], e !== void 0 && this.initializeRuntime(e), t && (this.requestHandler = new Ye(
1407
+ new Ze(this, t)
1395
1408
  ));
1396
1409
  }
1397
1410
  #e;
1398
1411
  #t;
1399
- #r;
1400
1412
  #s;
1413
+ #r;
1414
+ #n;
1415
+ /** @inheritDoc */
1416
+ async onMessage(e) {
1417
+ this.#n.push(e);
1418
+ }
1401
1419
  /** @inheritDoc */
1402
1420
  get absoluteUrl() {
1403
1421
  return this.requestHandler.requestHandler.absoluteUrl;
@@ -1419,10 +1437,13 @@ class w {
1419
1437
  initializeRuntime(e) {
1420
1438
  if (this[h])
1421
1439
  throw new Error("PHP runtime already initialized.");
1422
- const t = et(e);
1440
+ const t = tt(e);
1423
1441
  if (!t)
1424
1442
  throw new Error("Invalid PHP runtime id.");
1425
- this[h] = t, this.#r = We(t);
1443
+ this[h] = t, t.onMessage = (s) => {
1444
+ for (const i of this.#n)
1445
+ i(s);
1446
+ }, this.#s = De(t);
1426
1447
  }
1427
1448
  /** @inheritDoc */
1428
1449
  setPhpIniPath(e) {
@@ -1453,19 +1474,19 @@ class w {
1453
1474
  }
1454
1475
  /** @inheritDoc */
1455
1476
  async run(e) {
1456
- this.#t || (this.#n(), this.#t = !0), this.#u(e.scriptPath || ""), this.#o(e.relativeUri || ""), this.#c(e.method || "GET");
1457
- const { host: t, ...r } = {
1477
+ this.#t || (this.#i(), this.#t = !0), this.#p(e.scriptPath || ""), this.#a(e.relativeUri || ""), this.#l(e.method || "GET");
1478
+ const { host: t, ...s } = {
1458
1479
  host: "example.com:443",
1459
- ...ie(e.headers || {})
1480
+ ...ne(e.headers || {})
1460
1481
  };
1461
- if (this.#a(t, e.protocol || "http"), this.#l(r), e.body && this.#h(e.body), e.fileInfos)
1482
+ if (this.#c(t, e.protocol || "http"), this.#h(s), e.body && this.#u(e.body), e.fileInfos)
1462
1483
  for (const i of e.fileInfos)
1463
- this.#d(i);
1464
- return e.code && this.#f(" ?>" + e.code), this.#p(), await this.#m();
1484
+ this.#f(i);
1485
+ return e.code && this.#m(" ?>" + e.code), this.#d(), await this.#w();
1465
1486
  }
1466
- #n() {
1487
+ #i() {
1467
1488
  if (this.#e.length > 0) {
1468
- const e = this.#e.map(([t, r]) => `${t}=${r}`).join(`
1489
+ const e = this.#e.map(([t, s]) => `${t}=${s}`).join(`
1469
1490
  `) + `
1470
1491
 
1471
1492
  `;
@@ -1478,25 +1499,25 @@ class w {
1478
1499
  }
1479
1500
  this[h].ccall("php_wasm_init", null, [], []);
1480
1501
  }
1481
- #i() {
1502
+ #o() {
1482
1503
  const e = "/tmp/headers.json";
1483
1504
  if (!this.fileExists(e))
1484
1505
  throw new Error(
1485
1506
  "SAPI Error: Could not find response headers file."
1486
1507
  );
1487
- const t = JSON.parse(this.readFileAsText(e)), r = {};
1508
+ const t = JSON.parse(this.readFileAsText(e)), s = {};
1488
1509
  for (const i of t.headers) {
1489
1510
  if (!i.includes(": "))
1490
1511
  continue;
1491
1512
  const n = i.indexOf(": "), o = i.substring(0, n).toLowerCase(), a = i.substring(n + 2);
1492
- o in r || (r[o] = []), r[o].push(a);
1513
+ o in s || (s[o] = []), s[o].push(a);
1493
1514
  }
1494
1515
  return {
1495
- headers: r,
1516
+ headers: s,
1496
1517
  httpStatusCode: t.status
1497
1518
  };
1498
1519
  }
1499
- #o(e) {
1520
+ #a(e) {
1500
1521
  if (this[h].ccall(
1501
1522
  "wasm_set_request_uri",
1502
1523
  null,
@@ -1512,26 +1533,26 @@ class w {
1512
1533
  );
1513
1534
  }
1514
1535
  }
1515
- #a(e, t) {
1536
+ #c(e, t) {
1516
1537
  this[h].ccall(
1517
1538
  "wasm_set_request_host",
1518
1539
  null,
1519
1540
  [p],
1520
1541
  [e]
1521
1542
  );
1522
- let r;
1543
+ let s;
1523
1544
  try {
1524
- r = parseInt(new URL(e).port, 10);
1545
+ s = parseInt(new URL(e).port, 10);
1525
1546
  } catch {
1526
1547
  }
1527
- (!r || isNaN(r) || r === 80) && (r = t === "https" ? 443 : 80), this[h].ccall(
1548
+ (!s || isNaN(s) || s === 80) && (s = t === "https" ? 443 : 80), this[h].ccall(
1528
1549
  "wasm_set_request_port",
1529
1550
  null,
1530
- [y],
1531
- [r]
1532
- ), (t === "https" || !t && r === 443) && this.addServerGlobalEntry("HTTPS", "on");
1551
+ [_],
1552
+ [s]
1553
+ ), (t === "https" || !t && s === 443) && this.addServerGlobalEntry("HTTPS", "on");
1533
1554
  }
1534
- #c(e) {
1555
+ #l(e) {
1535
1556
  this[h].ccall(
1536
1557
  "wasm_set_request_method",
1537
1558
  null,
@@ -1539,7 +1560,7 @@ class w {
1539
1560
  [e]
1540
1561
  );
1541
1562
  }
1542
- #l(e) {
1563
+ #h(e) {
1543
1564
  e.cookie && this[h].ccall(
1544
1565
  "wasm_set_cookies",
1545
1566
  null,
@@ -1553,18 +1574,18 @@ class w {
1553
1574
  ), e["content-length"] && this[h].ccall(
1554
1575
  "wasm_set_content_length",
1555
1576
  null,
1556
- [y],
1577
+ [_],
1557
1578
  [parseInt(e["content-length"], 10)]
1558
1579
  );
1559
1580
  for (const t in e) {
1560
- let r = "HTTP_";
1561
- ["content-type", "content-length"].includes(t.toLowerCase()) && (r = ""), this.addServerGlobalEntry(
1562
- `${r}${t.toUpperCase().replace(/-/g, "_")}`,
1581
+ let s = "HTTP_";
1582
+ ["content-type", "content-length"].includes(t.toLowerCase()) && (s = ""), this.addServerGlobalEntry(
1583
+ `${s}${t.toUpperCase().replace(/-/g, "_")}`,
1563
1584
  e[t]
1564
1585
  );
1565
1586
  }
1566
1587
  }
1567
- #h(e) {
1588
+ #u(e) {
1568
1589
  this[h].ccall(
1569
1590
  "wasm_set_request_body",
1570
1591
  null,
@@ -1573,11 +1594,11 @@ class w {
1573
1594
  ), this[h].ccall(
1574
1595
  "wasm_set_content_length",
1575
1596
  null,
1576
- [y],
1597
+ [_],
1577
1598
  [new TextEncoder().encode(e).length]
1578
1599
  );
1579
1600
  }
1580
- #u(e) {
1601
+ #p(e) {
1581
1602
  this[h].ccall(
1582
1603
  "wasm_set_path_translated",
1583
1604
  null,
@@ -1586,15 +1607,15 @@ class w {
1586
1607
  );
1587
1608
  }
1588
1609
  addServerGlobalEntry(e, t) {
1589
- this.#s[e] = t;
1610
+ this.#r[e] = t;
1590
1611
  }
1591
- #p() {
1592
- for (const e in this.#s)
1612
+ #d() {
1613
+ for (const e in this.#r)
1593
1614
  this[h].ccall(
1594
1615
  "wasm_add_SERVER_entry",
1595
1616
  null,
1596
1617
  [p, p],
1597
- [e, this.#s[e]]
1618
+ [e, this.#r[e]]
1598
1619
  );
1599
1620
  }
1600
1621
  /**
@@ -1606,18 +1627,18 @@ class w {
1606
1627
  *
1607
1628
  * @param fileInfo - File details
1608
1629
  */
1609
- #d(e) {
1610
- const { key: t, name: r, type: i, data: n } = e, o = `/tmp/${Math.random().toFixed(20)}`;
1630
+ #f(e) {
1631
+ const { key: t, name: s, type: i, data: n } = e, o = `/tmp/${Math.random().toFixed(20)}`;
1611
1632
  this.writeFile(o, n);
1612
1633
  const a = 0;
1613
1634
  this[h].ccall(
1614
1635
  "wasm_add_uploaded_file",
1615
1636
  null,
1616
- [p, p, p, p, y, y],
1617
- [t, r, i, o, a, n.byteLength]
1637
+ [p, p, p, p, _, _],
1638
+ [t, s, i, o, a, n.byteLength]
1618
1639
  );
1619
1640
  }
1620
- #f(e) {
1641
+ #m(e) {
1621
1642
  this[h].ccall(
1622
1643
  "wasm_set_php_code",
1623
1644
  null,
@@ -1625,20 +1646,20 @@ class w {
1625
1646
  [e]
1626
1647
  );
1627
1648
  }
1628
- async #m() {
1649
+ async #w() {
1629
1650
  let e, t;
1630
1651
  try {
1631
1652
  e = await new Promise((n, o) => {
1632
1653
  t = (l) => {
1633
1654
  const c = new Error("Rethrown");
1634
1655
  c.cause = l.error, c.betterMessage = l.message, o(c);
1635
- }, this.#r?.addEventListener(
1656
+ }, this.#s?.addEventListener(
1636
1657
  "error",
1637
1658
  t
1638
1659
  );
1639
1660
  const a = this[h].ccall(
1640
1661
  "wasm_sapi_handle_request",
1641
- y,
1662
+ _,
1642
1663
  [],
1643
1664
  []
1644
1665
  );
@@ -1651,16 +1672,16 @@ class w {
1651
1672
  "PHP runtime has crashed – see the earlier error for details."
1652
1673
  );
1653
1674
  });
1654
- this.functionsMaybeMissingFromAsyncify = De();
1675
+ this.functionsMaybeMissingFromAsyncify = Me();
1655
1676
  const o = n, a = "betterMessage" in o ? o.betterMessage : o.message, l = new Error(a);
1656
1677
  throw l.cause = o, l;
1657
1678
  } finally {
1658
- this.#r?.removeEventListener("error", t), this.#s = {};
1679
+ this.#s?.removeEventListener("error", t), this.#r = {};
1659
1680
  }
1660
- const { headers: r, httpStatusCode: i } = this.#i();
1661
- return new _(
1681
+ const { headers: s, httpStatusCode: i } = this.#o();
1682
+ return new P(
1662
1683
  i,
1663
- r,
1684
+ s,
1664
1685
  this.readFileAsBuffer("/tmp/stdout"),
1665
1686
  this.readFileAsText("/tmp/stderr"),
1666
1687
  e
@@ -1688,8 +1709,8 @@ class w {
1688
1709
  this[h].FS.rename(e, t);
1689
1710
  }
1690
1711
  rmdir(e, t = { recursive: !0 }) {
1691
- t?.recursive && this.listFiles(e).forEach((r) => {
1692
- const i = `${e}/${r}`;
1712
+ t?.recursive && this.listFiles(e).forEach((s) => {
1713
+ const i = `${e}/${s}`;
1693
1714
  this.isDir(i) ? this.rmdir(i, t) : this.unlink(i);
1694
1715
  }), this[h].FS.rmdir(e);
1695
1716
  }
@@ -1697,16 +1718,16 @@ class w {
1697
1718
  if (!this.fileExists(e))
1698
1719
  return [];
1699
1720
  try {
1700
- const r = this[h].FS.readdir(e).filter(
1721
+ const s = this[h].FS.readdir(e).filter(
1701
1722
  (i) => i !== "." && i !== ".."
1702
1723
  );
1703
1724
  if (t.prependPath) {
1704
1725
  const i = e.replace(/\/$/, "");
1705
- return r.map((n) => `${i}/${n}`);
1726
+ return s.map((n) => `${i}/${n}`);
1706
1727
  }
1707
- return r;
1708
- } catch (r) {
1709
- return console.error(r, { path: e }), [];
1728
+ return s;
1729
+ } catch (s) {
1730
+ return console.error(s, { path: e }), [];
1710
1731
  }
1711
1732
  }
1712
1733
  isDir(e) {
@@ -1755,23 +1776,23 @@ m([
1755
1776
  m([
1756
1777
  f('Could not stat "{path}"')
1757
1778
  ], w.prototype, "fileExists", 1);
1758
- function ie(s) {
1779
+ function ne(r) {
1759
1780
  const e = {};
1760
- for (const t in s)
1761
- e[t.toLowerCase()] = s[t];
1781
+ for (const t in r)
1782
+ e[t.toLowerCase()] = r[t];
1762
1783
  return e;
1763
1784
  }
1764
- const rt = [
1785
+ const it = [
1765
1786
  "vfs",
1766
1787
  "literal",
1767
1788
  "wordpress.org/themes",
1768
1789
  "wordpress.org/plugins",
1769
1790
  "url"
1770
1791
  ];
1771
- function it(s) {
1772
- return s && typeof s == "object" && typeof s.resource == "string" && rt.includes(s.resource);
1792
+ function nt(r) {
1793
+ return r && typeof r == "object" && typeof r.resource == "string" && it.includes(r.resource);
1773
1794
  }
1774
- class g {
1795
+ class y {
1775
1796
  /**
1776
1797
  * Creates a new Resource based on the given file reference
1777
1798
  *
@@ -1779,28 +1800,28 @@ class g {
1779
1800
  * @param options Additional options for the Resource
1780
1801
  * @returns A new Resource instance
1781
1802
  */
1782
- static create(e, { semaphore: t, progress: r }) {
1803
+ static create(e, { semaphore: t, progress: s }) {
1783
1804
  let i;
1784
1805
  switch (e.resource) {
1785
1806
  case "vfs":
1786
- i = new nt(e, r);
1807
+ i = new ot(e, s);
1787
1808
  break;
1788
1809
  case "literal":
1789
- i = new ot(e, r);
1810
+ i = new at(e, s);
1790
1811
  break;
1791
1812
  case "wordpress.org/themes":
1792
- i = new lt(e, r);
1813
+ i = new ht(e, s);
1793
1814
  break;
1794
1815
  case "wordpress.org/plugins":
1795
- i = new ht(e, r);
1816
+ i = new ut(e, s);
1796
1817
  break;
1797
1818
  case "url":
1798
- i = new ct(e, r);
1819
+ i = new lt(e, s);
1799
1820
  break;
1800
1821
  default:
1801
1822
  throw new Error(`Invalid resource: ${e}`);
1802
1823
  }
1803
- return i = new ut(i), t && (i = new pt(i, t)), i;
1824
+ return i = new pt(i), t && (i = new dt(i, t)), i;
1804
1825
  }
1805
1826
  setPlayground(e) {
1806
1827
  this.playground = e;
@@ -1810,7 +1831,7 @@ class g {
1810
1831
  return !1;
1811
1832
  }
1812
1833
  }
1813
- class nt extends g {
1834
+ class ot extends y {
1814
1835
  /**
1815
1836
  * Creates a new instance of `VFSResource`.
1816
1837
  * @param playground The playground client.
@@ -1825,14 +1846,14 @@ class nt extends g {
1825
1846
  const e = await this.playground.readFileAsBuffer(
1826
1847
  this.resource.path
1827
1848
  );
1828
- return this.progress?.set(100), new R([e], this.name);
1849
+ return this.progress?.set(100), new T([e], this.name);
1829
1850
  }
1830
1851
  /** @inheritDoc */
1831
1852
  get name() {
1832
1853
  return this.resource.path.split("/").pop() || "";
1833
1854
  }
1834
1855
  }
1835
- class ot extends g {
1856
+ class at extends y {
1836
1857
  /**
1837
1858
  * Creates a new instance of `LiteralResource`.
1838
1859
  * @param resource The literal reference.
@@ -1843,14 +1864,14 @@ class ot extends g {
1843
1864
  }
1844
1865
  /** @inheritDoc */
1845
1866
  async resolve() {
1846
- return this.progress?.set(100), new R([this.resource.contents], this.resource.name);
1867
+ return this.progress?.set(100), new T([this.resource.contents], this.resource.name);
1847
1868
  }
1848
1869
  /** @inheritDoc */
1849
1870
  get name() {
1850
1871
  return this.resource.name;
1851
1872
  }
1852
1873
  }
1853
- class C extends g {
1874
+ class U extends y {
1854
1875
  /**
1855
1876
  * Creates a new instance of `FetchResource`.
1856
1877
  * @param progress The progress tracker.
@@ -1863,12 +1884,12 @@ class C extends g {
1863
1884
  this.progress?.setCaption(this.caption);
1864
1885
  const e = this.getURL();
1865
1886
  let t = await fetch(e);
1866
- if (t = await Le(
1887
+ if (t = await He(
1867
1888
  t,
1868
- this.progress?.loadingListener ?? at
1889
+ this.progress?.loadingListener ?? ct
1869
1890
  ), t.status !== 200)
1870
1891
  throw new Error(`Could not download "${e}"`);
1871
- return new R([await t.blob()], this.name);
1892
+ return new T([await t.blob()], this.name);
1872
1893
  }
1873
1894
  /**
1874
1895
  * Gets the caption for the progress tracker.
@@ -1890,9 +1911,9 @@ class C extends g {
1890
1911
  return !0;
1891
1912
  }
1892
1913
  }
1893
- const at = () => {
1914
+ const ct = () => {
1894
1915
  };
1895
- class ct extends C {
1916
+ class lt extends U {
1896
1917
  /**
1897
1918
  * Creates a new instance of `UrlResource`.
1898
1919
  * @param resource The URL reference.
@@ -1910,40 +1931,40 @@ class ct extends C {
1910
1931
  return this.resource.caption ?? super.caption;
1911
1932
  }
1912
1933
  }
1913
- let A = "https://playground.wordpress.net/plugin-proxy";
1914
- function gt(s) {
1915
- A = s;
1934
+ let N = "https://playground.wordpress.net/plugin-proxy";
1935
+ function yt(r) {
1936
+ N = r;
1916
1937
  }
1917
- class lt extends C {
1938
+ class ht extends U {
1918
1939
  constructor(e, t) {
1919
1940
  super(t), this.resource = e;
1920
1941
  }
1921
1942
  get name() {
1922
- return b(this.resource.slug);
1943
+ return v(this.resource.slug);
1923
1944
  }
1924
1945
  getURL() {
1925
- const e = ne(this.resource.slug);
1926
- return `${A}?theme=` + e;
1946
+ const e = oe(this.resource.slug);
1947
+ return `${N}?theme=` + e;
1927
1948
  }
1928
1949
  }
1929
- class ht extends C {
1950
+ class ut extends U {
1930
1951
  constructor(e, t) {
1931
1952
  super(t), this.resource = e;
1932
1953
  }
1933
1954
  /** @inheritDoc */
1934
1955
  get name() {
1935
- return b(this.resource.slug);
1956
+ return v(this.resource.slug);
1936
1957
  }
1937
1958
  /** @inheritDoc */
1938
1959
  getURL() {
1939
- const e = ne(this.resource.slug);
1940
- return `${A}?plugin=` + e;
1960
+ const e = oe(this.resource.slug);
1961
+ return `${N}?plugin=` + e;
1941
1962
  }
1942
1963
  }
1943
- function ne(s) {
1944
- return !s || s.endsWith(".zip") ? s : s + ".latest-stable.zip";
1964
+ function oe(r) {
1965
+ return !r || r.endsWith(".zip") ? r : r + ".latest-stable.zip";
1945
1966
  }
1946
- class oe extends g {
1967
+ class ae extends y {
1947
1968
  constructor(e) {
1948
1969
  super(), this.resource = e;
1949
1970
  }
@@ -1972,13 +1993,13 @@ class oe extends g {
1972
1993
  return this.resource.isAsync;
1973
1994
  }
1974
1995
  }
1975
- class ut extends oe {
1996
+ class pt extends ae {
1976
1997
  /** @inheritDoc */
1977
1998
  async resolve() {
1978
1999
  return this.promise || (this.promise = super.resolve()), this.promise;
1979
2000
  }
1980
2001
  }
1981
- class pt extends oe {
2002
+ class dt extends ae {
1982
2003
  constructor(e, t) {
1983
2004
  super(e), this.semaphore = t;
1984
2005
  }
@@ -1987,18 +2008,18 @@ class pt extends oe {
1987
2008
  return this.isAsync ? this.semaphore.run(() => super.resolve()) : super.resolve();
1988
2009
  }
1989
2010
  }
1990
- const dt = ["6.2", "6.1", "6.0", "5.9"];
1991
- function yt(s, {
1992
- progress: e = new T(),
1993
- semaphore: t = new X({ concurrency: 3 }),
1994
- onStepCompleted: r = () => {
2011
+ const ft = ["6.2", "6.1", "6.0", "5.9"];
2012
+ function _t(r, {
2013
+ progress: e = new k(),
2014
+ semaphore: t = new ee({ concurrency: 3 }),
2015
+ onStepCompleted: s = () => {
1995
2016
  }
1996
2017
  } = {}) {
1997
- const i = (s.steps || []).filter(ft), n = i.reduce(
2018
+ const i = (r.steps || []).filter(mt), n = i.reduce(
1998
2019
  (a, l) => a + (l.progress?.weight || 1),
1999
2020
  0
2000
2021
  ), o = i.map(
2001
- (a) => mt(a, {
2022
+ (a) => wt(a, {
2002
2023
  semaphore: t,
2003
2024
  rootProgressTracker: e,
2004
2025
  totalProgressWeight: n
@@ -2006,14 +2027,14 @@ function yt(s, {
2006
2027
  );
2007
2028
  return {
2008
2029
  versions: {
2009
- php: V(
2010
- s.preferredVersions?.php,
2011
- re,
2012
- Ge
2030
+ php: K(
2031
+ r.preferredVersions?.php,
2032
+ ie,
2033
+ Ve
2013
2034
  ),
2014
- wp: V(
2015
- s.preferredVersions?.wp,
2016
- dt,
2035
+ wp: K(
2036
+ r.preferredVersions?.wp,
2037
+ ft,
2017
2038
  "6.2"
2018
2039
  )
2019
2040
  },
@@ -2024,11 +2045,11 @@ function yt(s, {
2024
2045
  c.setPlayground(a), c.isAsync && c.resolve();
2025
2046
  for (const { run: l, step: c } of o) {
2026
2047
  const u = await l(a);
2027
- r(u, c);
2048
+ s(u, c);
2028
2049
  }
2029
2050
  try {
2030
2051
  await a.goTo(
2031
- s.landingPage || "/"
2052
+ r.landingPage || "/"
2032
2053
  );
2033
2054
  } catch {
2034
2055
  }
@@ -2038,92 +2059,92 @@ function yt(s, {
2038
2059
  }
2039
2060
  };
2040
2061
  }
2041
- function V(s, e, t) {
2042
- return s && e.includes(s) ? s : t;
2062
+ function K(r, e, t) {
2063
+ return r && e.includes(r) ? r : t;
2043
2064
  }
2044
- function ft(s) {
2045
- return !!(typeof s == "object" && s);
2065
+ function mt(r) {
2066
+ return !!(typeof r == "object" && r);
2046
2067
  }
2047
- function mt(s, {
2068
+ function wt(r, {
2048
2069
  semaphore: e,
2049
2070
  rootProgressTracker: t,
2050
- totalProgressWeight: r
2071
+ totalProgressWeight: s
2051
2072
  }) {
2052
2073
  const i = t.stage(
2053
- (s.progress?.weight || 1) / r
2074
+ (r.progress?.weight || 1) / s
2054
2075
  ), n = {};
2055
- for (const u of Object.keys(s)) {
2056
- let d = s[u];
2057
- it(d) && (d = g.create(d, {
2076
+ for (const u of Object.keys(r)) {
2077
+ let d = r[u];
2078
+ nt(d) && (d = y.create(d, {
2058
2079
  semaphore: e
2059
2080
  })), n[u] = d;
2060
2081
  }
2061
2082
  const o = async (u) => {
2062
2083
  try {
2063
- return i.fillSlowly(), await Ne[s.step](
2084
+ return i.fillSlowly(), await Le[r.step](
2064
2085
  u,
2065
- await wt(n),
2086
+ await gt(n),
2066
2087
  {
2067
2088
  tracker: i,
2068
- initialCaption: s.progress?.caption
2089
+ initialCaption: r.progress?.caption
2069
2090
  }
2070
2091
  );
2071
2092
  } finally {
2072
2093
  i.finish();
2073
2094
  }
2074
- }, a = Y(n), l = Y(n).filter(
2095
+ }, a = J(n), l = J(n).filter(
2075
2096
  (u) => u.isAsync
2076
2097
  ), c = 1 / (l.length + 1);
2077
2098
  for (const u of l)
2078
2099
  u.progress = i.stage(c);
2079
- return { run: o, step: s, resources: a };
2100
+ return { run: o, step: r, resources: a };
2080
2101
  }
2081
- function Y(s) {
2102
+ function J(r) {
2082
2103
  const e = [];
2083
- for (const t in s) {
2084
- const r = s[t];
2085
- r instanceof g && e.push(r);
2104
+ for (const t in r) {
2105
+ const s = r[t];
2106
+ s instanceof y && e.push(s);
2086
2107
  }
2087
2108
  return e;
2088
2109
  }
2089
- async function wt(s) {
2110
+ async function gt(r) {
2090
2111
  const e = {};
2091
- for (const t in s) {
2092
- const r = s[t];
2093
- r instanceof g ? e[t] = await r.resolve() : e[t] = r;
2112
+ for (const t in r) {
2113
+ const s = r[t];
2114
+ s instanceof y ? e[t] = await s.resolve() : e[t] = s;
2094
2115
  }
2095
2116
  return e;
2096
2117
  }
2097
- async function Pt(s, e) {
2098
- await s.run(e);
2118
+ async function Pt(r, e) {
2119
+ await r.run(e);
2099
2120
  }
2100
2121
  export {
2101
- J as activatePlugin,
2102
- K as activateTheme,
2103
- le as applyWordPressPatches,
2104
- yt as compileBlueprint,
2105
- me as cp,
2106
- _e as defineSiteUrl,
2107
- Q as defineWpConfigConsts,
2108
- Ee as importFile,
2122
+ Z as activatePlugin,
2123
+ Q as activateTheme,
2124
+ he as applyWordPressPatches,
2125
+ _t as compileBlueprint,
2126
+ we as cp,
2127
+ $e as defineSiteUrl,
2128
+ x as defineWpConfigConsts,
2129
+ Se as importFile,
2109
2130
  xe as installPlugin,
2110
- Te as installTheme,
2131
+ Ce as installTheme,
2111
2132
  ke as login,
2112
- ge as mkdir,
2113
- we as mv,
2114
- ve as replaceSite,
2115
- fe as request,
2116
- ye as rm,
2133
+ ye as mkdir,
2134
+ ge as mv,
2135
+ Ee as replaceSite,
2136
+ me as request,
2137
+ _e as rm,
2117
2138
  Pe as rmdir,
2118
2139
  Pt as runBlueprintSteps,
2119
- ue as runPHP,
2120
- pe as runPHPWithOptions,
2121
- Ce as runWpInstallationWizard,
2122
- de as setPhpIniEntry,
2123
- gt as setPluginProxyURL,
2124
- Ae as setSiteOptions,
2125
- F as unzip,
2126
- Ue as updateUserMeta,
2127
- Z as writeFile,
2128
- be as zipEntireSite
2140
+ pe as runPHP,
2141
+ de as runPHPWithOptions,
2142
+ Ae as runWpInstallationWizard,
2143
+ fe as setPhpIniEntry,
2144
+ yt as setPluginProxyURL,
2145
+ Ue as setSiteOptions,
2146
+ C as unzip,
2147
+ Ne as updateUserMeta,
2148
+ X as writeFile,
2149
+ ve as zipEntireSite
2129
2150
  };