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