@wp-playground/cli 3.1.3 → 3.1.5

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.
@@ -1,40 +1,40 @@
1
- import { logger as P, LogSeverity as F, errorLogPath as Z } from "@php-wasm/logger";
2
- import { consumeAPI as ue, ProcessIdAllocator as xe, SupportedPHPVersions as R, printDebugDetails as $e, HttpCookieStore as Ee, FileLockManagerInMemory as Te, StreamedPHPResponse as J, createObjectPoolProxy as Ie, exposeAPI as ke, PHPResponse as Me, exposeSyncAPI as Be } from "@php-wasm/universal";
3
- import { resolveRemoteBlueprint as Ae, resolveRuntimeConfiguration as K, compileBlueprintV1 as de, isBlueprintBundle as Ce, runBlueprintV1Steps as ee } from "@wp-playground/blueprints";
1
+ import { logger as P, LogSeverity as _, errorLogPath as Z } from "@php-wasm/logger";
2
+ import { consumeAPI as ue, ProcessIdAllocator as xe, SupportedPHPVersions as R, printDebugDetails as Ee, HttpCookieStore as $e, FileLockManagerInMemory as Te, StreamedPHPResponse as J, createObjectPoolProxy as Ie, exposeAPI as ke, PHPResponse as Me, exposeSyncAPI as Ae } from "@php-wasm/universal";
3
+ import { resolveRemoteBlueprint as Be, resolveRuntimeConfiguration as K, compileBlueprintV1 as de, isBlueprintBundle as Ce, runBlueprintV1Steps as ee } from "@wp-playground/blueprints";
4
4
  import { zipDirectory as De, RecommendedPHPVersion as M } from "@wp-playground/common";
5
- import c, { existsSync as Y, rmdirSync as Re, mkdirSync as j, readdirSync as We } from "fs";
6
- import { MessageChannel as pe, Worker as te } from "worker_threads";
5
+ import p, { existsSync as Y, rmdirSync as Re, mkdirSync as j, readdirSync as We } from "fs";
6
+ import { MessageChannel as ce, Worker as te } from "worker_threads";
7
7
  import { createNodeFsMountHandler as Le } from "@php-wasm/node";
8
- import d, { basename as D, join as ce } from "path";
8
+ import d, { basename as D, join as pe } from "path";
9
9
  import { exec as me } from "child_process";
10
10
  import { promisify as Ue } from "util";
11
11
  import fe from "express";
12
12
  import { Readable as He } from "stream";
13
- import { pipeline as Fe } from "stream/promises";
14
- import Ne from "yargs";
15
- import { NodeJsFilesystem as Oe, OverlayFilesystem as _e, InMemoryFilesystem as je, ZipFilesystem as Ve } from "@wp-playground/storage";
13
+ import { pipeline as _e } from "stream/promises";
14
+ import Fe from "yargs";
15
+ import { NodeJsFilesystem as Ne, OverlayFilesystem as Oe, InMemoryFilesystem as je, ZipFilesystem as Ve } from "@wp-playground/storage";
16
16
  import { EmscriptenDownloadMonitor as Ye, ProgressTracker as qe } from "@php-wasm/progress";
17
17
  import { resolveWordPressRelease as ze } from "@wp-playground/wordpress";
18
- import $ from "fs-extra";
18
+ import E from "fs-extra";
19
19
  import { createRequire as Ge } from "module";
20
20
  import q from "os";
21
21
  import { startBridge as Qe } from "@php-wasm/xdebug-bridge";
22
22
  import { dir as Xe, setGracefulCleanup as Ze } from "tmp-promise";
23
23
  import Je from "ps-man";
24
- import { removeTempDirSymlink as Ke, createTempDirSymlink as oe, makeXdebugConfig as et, clearXdebugIDEConfig as tt, addXdebugIDEConfig as ot } from "@php-wasm/cli-util";
25
- import { createHash as rt } from "crypto";
26
- import { PHPMYADMIN_INSTALL_PATH as re, getPhpMyAdminInstallSteps as st, PHPMYADMIN_ENTRY_PATH as it } from "@wp-playground/tools";
24
+ import { removeTempDirSymlink as Ke, createTempDirSymlink as re, makeXdebugConfig as et, clearXdebugIDEConfig as tt, addXdebugIDEConfig as rt } from "@php-wasm/cli-util";
25
+ import { createHash as ot } from "crypto";
26
+ import { PHPMYADMIN_INSTALL_PATH as oe, getPhpMyAdminInstallSteps as st, PHPMYADMIN_ENTRY_PATH as it } from "@wp-playground/tools";
27
27
  import { jspi as se } from "wasm-feature-detect";
28
- function N(e) {
28
+ function F(e) {
29
29
  const t = [];
30
- for (const o of e) {
31
- const r = o.split(":");
32
- if (r.length !== 2)
33
- throw new Error(`Invalid mount format: ${o}.
30
+ for (const r of e) {
31
+ const o = r.split(":");
32
+ if (o.length !== 2)
33
+ throw new Error(`Invalid mount format: ${r}.
34
34
  Expected format: /host/path:/vfs/path.
35
35
  If your path contains a colon, e.g. C:\\myplugin, use the --mount-dir option instead.
36
36
  Example: --mount-dir C:\\my-plugin /wordpress/wp-content/plugins/my-plugin`);
37
- const [s, i] = r;
37
+ const [s, i] = o;
38
38
  if (!Y(s))
39
39
  throw new Error(`Host path does not exist: ${s}`);
40
40
  t.push({ hostPath: s, vfsPath: i });
@@ -45,22 +45,22 @@ function ie(e) {
45
45
  if (e.length % 2 !== 0)
46
46
  throw new Error("Invalid mount format. Expected: /host/path /vfs/path");
47
47
  const t = [];
48
- for (let o = 0; o < e.length; o += 2) {
49
- const r = e[o], s = e[o + 1];
50
- if (!Y(r))
51
- throw new Error(`Host path does not exist: ${r}`);
48
+ for (let r = 0; r < e.length; r += 2) {
49
+ const o = e[r], s = e[r + 1];
50
+ if (!Y(o))
51
+ throw new Error(`Host path does not exist: ${o}`);
52
52
  t.push({
53
- hostPath: d.resolve(process.cwd(), r),
53
+ hostPath: d.resolve(process.cwd(), o),
54
54
  vfsPath: s
55
55
  });
56
56
  }
57
57
  return t;
58
58
  }
59
- async function yo(e, t) {
60
- for (const o of t)
59
+ async function wr(e, t) {
60
+ for (const r of t)
61
61
  await e.mount(
62
- o.vfsPath,
63
- Le(o.hostPath)
62
+ r.vfsPath,
63
+ Le(r.hostPath)
64
64
  );
65
65
  }
66
66
  const ne = {
@@ -83,17 +83,17 @@ const ne = {
83
83
  }
84
84
  };
85
85
  function he(e) {
86
- const t = e.autoMount, o = [...e.mount || []], r = [...e["mount-before-install"] || []], s = {
86
+ const t = e.autoMount, r = [...e.mount || []], o = [...e["mount-before-install"] || []], s = {
87
87
  ...e,
88
- mount: o,
89
- "mount-before-install": r,
88
+ mount: r,
89
+ "mount-before-install": o,
90
90
  "additional-blueprint-steps": [
91
91
  ...e["additional-blueprint-steps"] || []
92
92
  ]
93
93
  };
94
94
  if (ut(t)) {
95
95
  const n = `/wordpress/wp-content/plugins/${D(t)}`;
96
- o.push({
96
+ r.push({
97
97
  hostPath: t,
98
98
  vfsPath: n,
99
99
  autoMounted: !0
@@ -103,7 +103,7 @@ function he(e) {
103
103
  });
104
104
  } else if (lt(t)) {
105
105
  const i = D(t), n = `/wordpress/wp-content/themes/${i}`;
106
- o.push({
106
+ r.push({
107
107
  hostPath: t,
108
108
  vfsPath: n,
109
109
  autoMounted: !0
@@ -117,15 +117,15 @@ function he(e) {
117
117
  }
118
118
  );
119
119
  } else if (at(t)) {
120
- const i = c.readdirSync(t);
120
+ const i = p.readdirSync(t);
121
121
  for (const n of i)
122
- n !== "index.php" && o.push({
122
+ n !== "index.php" && r.push({
123
123
  hostPath: `${t}/${n}`,
124
124
  vfsPath: `/wordpress/wp-content/${n}`,
125
125
  autoMounted: !0
126
126
  });
127
127
  s["additional-blueprint-steps"].push(ne);
128
- } else nt(t) && (r.push({
128
+ } else nt(t) && (o.push({
129
129
  hostPath: t,
130
130
  vfsPath: "/wordpress",
131
131
  autoMounted: !0
@@ -133,24 +133,24 @@ function he(e) {
133
133
  return s;
134
134
  }
135
135
  function nt(e) {
136
- const t = c.readdirSync(e);
136
+ const t = p.readdirSync(e);
137
137
  return t.includes("wp-admin") && t.includes("wp-includes") && t.includes("wp-content");
138
138
  }
139
139
  function at(e) {
140
- const t = c.readdirSync(e);
140
+ const t = p.readdirSync(e);
141
141
  return t.includes("themes") || t.includes("plugins") || t.includes("mu-plugins") || t.includes("uploads");
142
142
  }
143
143
  function lt(e) {
144
- if (!c.readdirSync(e).includes("style.css"))
144
+ if (!p.readdirSync(e).includes("style.css"))
145
145
  return !1;
146
- const o = c.readFileSync(ce(e, "style.css"), "utf8");
147
- return !!/^(?:[ \t]*<\?php)?[ \t/*#@]*Theme Name:(.*)$/im.exec(o);
146
+ const r = p.readFileSync(pe(e, "style.css"), "utf8");
147
+ return !!/^(?:[ \t]*<\?php)?[ \t/*#@]*Theme Name:(.*)$/im.exec(r);
148
148
  }
149
149
  function ut(e) {
150
- const t = c.readdirSync(e), o = /^(?:[ \t]*<\?php)?[ \t/*#@]*Plugin Name:(.*)$/im;
150
+ const t = p.readdirSync(e), r = /^(?:[ \t]*<\?php)?[ \t/*#@]*Plugin Name:(.*)$/im;
151
151
  return !!t.filter((s) => s.endsWith(".php")).find((s) => {
152
- const i = c.readFileSync(ce(e, s), "utf8");
153
- return !!o.exec(i);
152
+ const i = p.readFileSync(pe(e, s), "utf8");
153
+ return !!r.exec(i);
154
154
  });
155
155
  }
156
156
  function dt(e) {
@@ -159,65 +159,65 @@ function dt(e) {
159
159
  "Invalid constant definition format. Expected pairs of NAME value"
160
160
  );
161
161
  const t = {};
162
- for (let o = 0; o < e.length; o += 2) {
163
- const r = e[o], s = e[o + 1];
164
- if (!r || !r.trim())
162
+ for (let r = 0; r < e.length; r += 2) {
163
+ const o = e[r], s = e[r + 1];
164
+ if (!o || !o.trim())
165
165
  throw new Error("Constant name cannot be empty");
166
- t[r.trim()] = s;
166
+ t[o.trim()] = s;
167
167
  }
168
168
  return t;
169
169
  }
170
- function pt(e) {
170
+ function ct(e) {
171
171
  if (e.length % 2 !== 0)
172
172
  throw new Error(
173
173
  "Invalid boolean constant definition format. Expected pairs of NAME value"
174
174
  );
175
175
  const t = {};
176
- for (let o = 0; o < e.length; o += 2) {
177
- const r = e[o], s = e[o + 1].trim().toLowerCase();
178
- if (!r || !r.trim())
176
+ for (let r = 0; r < e.length; r += 2) {
177
+ const o = e[r], s = e[r + 1].trim().toLowerCase();
178
+ if (!o || !o.trim())
179
179
  throw new Error("Constant name cannot be empty");
180
180
  if (s === "true" || s === "1")
181
- t[r.trim()] = !0;
181
+ t[o.trim()] = !0;
182
182
  else if (s === "false" || s === "0")
183
- t[r.trim()] = !1;
183
+ t[o.trim()] = !1;
184
184
  else
185
185
  throw new Error(
186
- `Invalid boolean value for constant "${r}": "${s}". Must be "true", "false", "1", or "0".`
186
+ `Invalid boolean value for constant "${o}": "${s}". Must be "true", "false", "1", or "0".`
187
187
  );
188
188
  }
189
189
  return t;
190
190
  }
191
- function ct(e) {
191
+ function pt(e) {
192
192
  if (e.length % 2 !== 0)
193
193
  throw new Error(
194
194
  "Invalid number constant definition format. Expected pairs of NAME value"
195
195
  );
196
196
  const t = {};
197
- for (let o = 0; o < e.length; o += 2) {
198
- const r = e[o], s = e[o + 1].trim();
199
- if (!r || !r.trim())
197
+ for (let r = 0; r < e.length; r += 2) {
198
+ const o = e[r], s = e[r + 1].trim();
199
+ if (!o || !o.trim())
200
200
  throw new Error("Constant name cannot be empty");
201
201
  const i = Number(s);
202
202
  if (isNaN(i))
203
203
  throw new Error(
204
- `Invalid number value for constant "${r}": "${s}". Must be a valid number.`
204
+ `Invalid number value for constant "${o}": "${s}". Must be a valid number.`
205
205
  );
206
- t[r.trim()] = i;
206
+ t[o.trim()] = i;
207
207
  }
208
208
  return t;
209
209
  }
210
- function mt(e = {}, t = {}, o = {}) {
211
- const r = {}, s = /* @__PURE__ */ new Set(), i = (n, l) => {
210
+ function mt(e = {}, t = {}, r = {}) {
211
+ const o = {}, s = /* @__PURE__ */ new Set(), i = (n, l) => {
212
212
  for (const u in n) {
213
213
  if (s.has(u))
214
214
  throw new Error(
215
215
  `Constant "${u}" is defined multiple times across different --define-${l} flags`
216
216
  );
217
- s.add(u), r[u] = n[u];
217
+ s.add(u), o[u] = n[u];
218
218
  }
219
219
  };
220
- return i(e, "string"), i(t, "bool"), i(o, "number"), r;
220
+ return i(e, "string"), i(t, "bool"), i(r, "number"), o;
221
221
  }
222
222
  function we(e) {
223
223
  return mt(
@@ -230,15 +230,15 @@ const ft = Ue(me);
230
230
  function ht(e) {
231
231
  return new Promise((t) => {
232
232
  if (e === 0) return t(!1);
233
- const o = fe().listen(e);
234
- o.once("listening", () => o.close(() => t(!1))), o.once(
233
+ const r = fe().listen(e);
234
+ r.once("listening", () => r.close(() => t(!1))), r.once(
235
235
  "error",
236
- (r) => t(r.code === "EADDRINUSE")
236
+ (o) => t(o.code === "EADDRINUSE")
237
237
  );
238
238
  });
239
239
  }
240
240
  async function wt(e) {
241
- const t = fe(), o = await new Promise((n, l) => {
241
+ const t = fe(), r = await new Promise((n, l) => {
242
242
  const u = t.listen(e.port, () => {
243
243
  const w = u.address();
244
244
  w === null || typeof w == "string" ? l(new Error("Server address is not available")) : n(u);
@@ -257,34 +257,40 @@ async function wt(e) {
257
257
  P.error(u), l.headersSent || (l.statusCode = 500, l.end("Internal Server Error"));
258
258
  }
259
259
  });
260
- const s = o.address().port, i = process.env.CODESPACE_NAME;
261
- return i && gt(s, i), await e.onBind(o, s);
260
+ const s = r.address().port, i = process.env.CODESPACE_NAME;
261
+ return i && gt(s, i), await e.onBind(r, s);
262
262
  }
263
263
  async function yt(e, t) {
264
- const [o, r] = await Promise.all([
264
+ const [r, o] = await Promise.all([
265
265
  e.headers,
266
266
  e.httpStatusCode
267
267
  ]);
268
- t.statusCode = r;
269
- for (const i in o)
270
- t.setHeader(i, o[i]);
268
+ t.statusCode = o;
269
+ for (const i in r)
270
+ t.setHeader(i, r[i]);
271
271
  const s = He.fromWeb(e.stdout);
272
- await Fe(s, t);
272
+ try {
273
+ await _e(s, t);
274
+ } catch (i) {
275
+ if (i instanceof Error && "code" in i && i.code === "ERR_STREAM_PREMATURE_CLOSE")
276
+ return;
277
+ throw i;
278
+ }
273
279
  }
274
280
  const bt = async (e) => await new Promise((t) => {
275
- const o = [];
276
- e.on("data", (r) => {
277
- o.push(r);
281
+ const r = [];
282
+ e.on("data", (o) => {
283
+ r.push(o);
278
284
  }), e.on("end", () => {
279
- t(new Uint8Array(Buffer.concat(o)));
285
+ t(new Uint8Array(Buffer.concat(r)));
280
286
  });
281
287
  });
282
288
  async function gt(e, t) {
283
289
  P.log(`Publishing port ${e}...`);
284
- const o = `gh codespace ports visibility ${e}:public -c ${t}`;
285
- for (let r = 0; r < 10; r++)
290
+ const r = `gh codespace ports visibility ${e}:public -c ${t}`;
291
+ for (let o = 0; o < 10; o++)
286
292
  try {
287
- await ft(o);
293
+ await ft(r);
288
294
  return;
289
295
  } catch {
290
296
  await new Promise((s) => setTimeout(s, 2e3));
@@ -293,8 +299,8 @@ async function gt(e, t) {
293
299
  const Pt = (e) => {
294
300
  const t = {};
295
301
  if (e.rawHeaders && e.rawHeaders.length)
296
- for (let o = 0; o < e.rawHeaders.length; o += 2)
297
- t[e.rawHeaders[o].toLowerCase()] = e.rawHeaders[o + 1];
302
+ for (let r = 0; r < e.rawHeaders.length; r += 2)
303
+ t[e.rawHeaders[r].toLowerCase()] = e.rawHeaders[r + 1];
298
304
  return t;
299
305
  };
300
306
  function vt(e) {
@@ -307,32 +313,32 @@ async function St({
307
313
  if (!e)
308
314
  return;
309
315
  if (e.startsWith("http://") || e.startsWith("https://"))
310
- return await Ae(e);
311
- let o = d.resolve(process.cwd(), e);
312
- if (!c.existsSync(o))
313
- throw new Error(`Blueprint file does not exist: ${o}`);
314
- const r = c.statSync(o);
315
- if (r.isDirectory() && (o = d.join(o, "blueprint.json")), !r.isFile() && r.isSymbolicLink())
316
+ return await Be(e);
317
+ let r = d.resolve(process.cwd(), e);
318
+ if (!p.existsSync(r))
319
+ throw new Error(`Blueprint file does not exist: ${r}`);
320
+ const o = p.statSync(r);
321
+ if (o.isDirectory() && (r = d.join(r, "blueprint.json")), !o.isFile() && o.isSymbolicLink())
316
322
  throw new Error(
317
- `Blueprint path is neither a file nor a directory: ${o}`
323
+ `Blueprint path is neither a file nor a directory: ${r}`
318
324
  );
319
- const s = d.extname(o);
325
+ const s = d.extname(r);
320
326
  switch (s) {
321
327
  case ".zip":
322
328
  return Ve.fromArrayBuffer(
323
- c.readFileSync(o).buffer
329
+ p.readFileSync(r).buffer
324
330
  );
325
331
  case ".json": {
326
- const i = c.readFileSync(o, "utf-8");
332
+ const i = p.readFileSync(r, "utf-8");
327
333
  try {
328
334
  JSON.parse(i);
329
335
  } catch {
330
336
  throw new Error(
331
- `Blueprint file at ${o} is not a valid JSON file`
337
+ `Blueprint file at ${r} is not a valid JSON file`
332
338
  );
333
339
  }
334
- const n = d.dirname(o), l = new Oe(n);
335
- return new _e([
340
+ const n = d.dirname(r), l = new Ne(n);
341
+ return new Oe([
336
342
  new je({
337
343
  "blueprint.json": i
338
344
  }),
@@ -360,28 +366,28 @@ You can allow this Blueprint to read files from the same parent directory by exp
360
366
  }
361
367
  }
362
368
  class xt {
363
- constructor(t, o) {
364
- this.args = t, this.siteUrl = o.siteUrl, this.phpVersion = t.php, this.cliOutput = o.cliOutput;
369
+ constructor(t, r) {
370
+ this.args = t, this.siteUrl = r.siteUrl, this.phpVersion = t.php, this.cliOutput = r.cliOutput;
365
371
  }
366
372
  getWorkerType() {
367
373
  return "v2";
368
374
  }
369
- async bootWordPress(t, o) {
370
- const r = {
375
+ async bootWordPress(t, r) {
376
+ const o = {
371
377
  command: this.args.command,
372
378
  siteUrl: this.siteUrl,
373
379
  blueprint: this.args.blueprint,
374
- workerPostInstallMountsPort: o
380
+ workerPostInstallMountsPort: r
375
381
  };
376
- return await t.bootWordPress(r, o), t;
382
+ return await t.bootWordPress(o, r), t;
377
383
  }
378
384
  async bootRequestHandler({
379
385
  worker: t,
380
- fileLockManagerPort: o,
381
- nativeInternalDirPath: r
386
+ fileLockManagerPort: r,
387
+ nativeInternalDirPath: o
382
388
  }) {
383
389
  const s = ue(t.phpPort);
384
- await s.useFileLockManager(o);
390
+ await s.useFileLockManager(r);
385
391
  const i = {
386
392
  ...this.args,
387
393
  phpVersion: this.phpVersion,
@@ -392,7 +398,7 @@ class xt {
392
398
  withRedis: this.args.redis,
393
399
  withMemcached: this.args.memcached,
394
400
  withXdebug: !!this.args.xdebug,
395
- nativeInternalDirPath: r,
401
+ nativeInternalDirPath: o,
396
402
  mountsBeforeWpInstall: this.args["mount-before-install"] || [],
397
403
  mountsAfterWpInstall: this.args.mount || [],
398
404
  constants: we(this.args)
@@ -401,28 +407,28 @@ class xt {
401
407
  }
402
408
  }
403
409
  const V = d.join(q.homedir(), ".wordpress-playground");
404
- async function $t() {
410
+ async function Et() {
405
411
  const e = typeof __dirname < "u" ? __dirname : import.meta.dirname;
406
412
  let t = d.join(e, "sqlite-database-integration.zip");
407
- if (!$.existsSync(t)) {
408
- const o = Ge(import.meta.url), r = d.dirname(
409
- o.resolve("@wp-playground/wordpress-builds/package.json")
413
+ if (!E.existsSync(t)) {
414
+ const r = Ge(import.meta.url), o = d.dirname(
415
+ r.resolve("@wp-playground/wordpress-builds/package.json")
410
416
  );
411
417
  t = d.join(
412
- r,
418
+ o,
413
419
  "src",
414
420
  "sqlite-database-integration",
415
421
  "sqlite-database-integration-trunk.zip"
416
422
  );
417
423
  }
418
- return new File([await $.readFile(t)], d.basename(t));
424
+ return new File([await E.readFile(t)], d.basename(t));
419
425
  }
420
- async function Et(e, t, o) {
421
- const r = d.join(V, t);
422
- return $.existsSync(r) || ($.ensureDirSync(V), await Tt(e, r, o)), ye(r);
426
+ async function $t(e, t, r) {
427
+ const o = d.join(V, t);
428
+ return E.existsSync(o) || (E.ensureDirSync(V), await Tt(e, o, r)), ye(o);
423
429
  }
424
- async function Tt(e, t, o) {
425
- const s = (await o.monitorFetch(fetch(e))).body.getReader(), i = `${t}.partial`, n = $.createWriteStream(i);
430
+ async function Tt(e, t, r) {
431
+ const s = (await r.monitorFetch(fetch(e))).body.getReader(), i = `${t}.partial`, n = E.createWriteStream(i);
426
432
  for (; ; ) {
427
433
  const { done: l, value: u } = await s.read();
428
434
  if (u && n.write(u), l)
@@ -430,50 +436,50 @@ async function Tt(e, t, o) {
430
436
  }
431
437
  n.close(), n.closed || await new Promise((l, u) => {
432
438
  n.on("finish", () => {
433
- $.renameSync(i, t), l(null);
439
+ E.renameSync(i, t), l(null);
434
440
  }), n.on("error", (w) => {
435
- $.removeSync(i), u(w);
441
+ E.removeSync(i), u(w);
436
442
  });
437
443
  });
438
444
  }
439
445
  function ye(e, t) {
440
- return new File([$.readFileSync(e)], D(e));
446
+ return new File([E.readFileSync(e)], D(e));
441
447
  }
442
448
  class It {
443
- constructor(t, o) {
444
- this.args = t, this.siteUrl = o.siteUrl, this.cliOutput = o.cliOutput;
449
+ constructor(t, r) {
450
+ this.args = t, this.siteUrl = r.siteUrl, this.cliOutput = r.cliOutput;
445
451
  }
446
452
  getWorkerType() {
447
453
  return "v1";
448
454
  }
449
- async bootWordPress(t, o) {
450
- let r, s, i;
455
+ async bootWordPress(t, r) {
456
+ let o, s, i;
451
457
  const n = new Ye();
452
458
  if (this.args.wordpressInstallMode === "download-and-install") {
453
459
  let w = !1;
454
460
  n.addEventListener("progress", (S) => {
455
461
  if (w)
456
462
  return;
457
- const { loaded: p, total: a } = S.detail, m = Math.floor(
458
- Math.min(100, 100 * p / a)
463
+ const { loaded: c, total: a } = S.detail, m = Math.floor(
464
+ Math.min(100, 100 * c / a)
459
465
  );
460
466
  w = m === 100, this.cliOutput.updateProgress(
461
467
  "Downloading WordPress",
462
468
  m
463
469
  );
464
- }), r = await ze(this.args.wp), i = d.join(
470
+ }), o = await ze(this.args.wp), i = d.join(
465
471
  V,
466
- `prebuilt-wp-content-for-wp-${r.version}.zip`
467
- ), s = c.existsSync(i) ? ye(i) : await Et(
468
- r.releaseUrl,
469
- `${r.version}.zip`,
472
+ `prebuilt-wp-content-for-wp-${o.version}.zip`
473
+ ), s = p.existsSync(i) ? ye(i) : await $t(
474
+ o.releaseUrl,
475
+ `${o.version}.zip`,
470
476
  n
471
477
  ), P.debug(
472
- `Resolved WordPress release URL: ${r?.releaseUrl}`
478
+ `Resolved WordPress release URL: ${o?.releaseUrl}`
473
479
  );
474
480
  }
475
481
  let l;
476
- this.args.skipSqliteSetup ? (P.debug("Skipping SQLite integration plugin setup..."), l = void 0) : (this.cliOutput.updateProgress("Preparing SQLite database"), l = await $t()), this.cliOutput.updateProgress("Booting WordPress");
482
+ this.args.skipSqliteSetup ? (P.debug("Skipping SQLite integration plugin setup..."), l = void 0) : (this.cliOutput.updateProgress("Preparing SQLite database"), l = await Et()), this.cliOutput.updateProgress("Booting WordPress");
477
483
  const u = await K(
478
484
  this.getEffectiveBlueprint()
479
485
  );
@@ -486,8 +492,8 @@ class It {
486
492
  sqliteIntegrationPluginZip: await l?.arrayBuffer(),
487
493
  constants: we(this.args)
488
494
  },
489
- o
490
- ), i && !this.args["mount-before-install"] && !c.existsSync(i) && (this.cliOutput.updateProgress("Caching WordPress for next boot"), c.writeFileSync(
495
+ r
496
+ ), i && !this.args["mount-before-install"] && !p.existsSync(i) && (this.cliOutput.updateProgress("Caching WordPress for next boot"), p.writeFileSync(
491
497
  i,
492
498
  // Comlink proxy is not assignable to UniversalPHP but
493
499
  // proxies all method calls transparently at runtime.
@@ -499,8 +505,8 @@ class It {
499
505
  }
500
506
  async bootRequestHandler({
501
507
  worker: t,
502
- fileLockManagerPort: o,
503
- nativeInternalDirPath: r
508
+ fileLockManagerPort: r,
509
+ nativeInternalDirPath: o
504
510
  }) {
505
511
  const s = ue(
506
512
  t.phpPort
@@ -509,7 +515,7 @@ class It {
509
515
  const i = await K(
510
516
  this.getEffectiveBlueprint()
511
517
  );
512
- return await s.useFileLockManager(o), await s.bootRequestHandler({
518
+ return await s.useFileLockManager(r), await s.bootRequestHandler({
513
519
  phpVersion: i.phpVersion,
514
520
  siteUrl: this.siteUrl,
515
521
  mountsBeforeWpInstall: this.args["mount-before-install"] || [],
@@ -521,21 +527,21 @@ class It {
521
527
  withRedis: this.args.redis,
522
528
  withMemcached: this.args.memcached,
523
529
  withXdebug: !!this.args.xdebug,
524
- nativeInternalDirPath: r,
530
+ nativeInternalDirPath: o,
525
531
  pathAliases: this.args.pathAliases
526
532
  }), await s.isReady(), s;
527
533
  }
528
534
  async compileInputBlueprint(t) {
529
- const o = this.getEffectiveBlueprint(), r = new qe();
535
+ const r = this.getEffectiveBlueprint(), o = new qe();
530
536
  let s = "", i = !1;
531
- return r.addEventListener("progress", (n) => {
537
+ return o.addEventListener("progress", (n) => {
532
538
  if (i)
533
539
  return;
534
540
  i = n.detail.progress === 100;
535
541
  const l = Math.floor(n.detail.progress);
536
542
  s = n.detail.caption || s || "Running Blueprint", this.cliOutput.updateProgress(s.trim(), l);
537
- }), await de(o, {
538
- progress: r,
543
+ }), await de(r, {
544
+ progress: o,
539
545
  additionalSteps: t
540
546
  });
541
547
  }
@@ -553,8 +559,8 @@ class It {
553
559
  }
554
560
  }
555
561
  async function kt(e, t = !0) {
556
- const r = `${d.basename(process.argv0)}${e}${process.pid}-`, s = await Xe({
557
- prefix: r,
562
+ const o = `${d.basename(process.argv0)}${e}${process.pid}-`, s = await Xe({
563
+ prefix: o,
558
564
  /*
559
565
  * Allow recursive cleanup on process exit.
560
566
  *
@@ -567,14 +573,14 @@ async function kt(e, t = !0) {
567
573
  });
568
574
  return t && Ze(), s;
569
575
  }
570
- async function Mt(e, t, o) {
571
- const s = (await Bt(
576
+ async function Mt(e, t, r) {
577
+ const s = (await At(
572
578
  e,
573
579
  t,
574
- o
580
+ r
575
581
  )).map(
576
582
  (i) => new Promise((n) => {
577
- c.rm(i, { recursive: !0 }, (l) => {
583
+ p.rm(i, { recursive: !0 }, (l) => {
578
584
  l ? P.warn(
579
585
  `Failed to delete stale Playground temp dir: ${i}`,
580
586
  l
@@ -586,24 +592,24 @@ async function Mt(e, t, o) {
586
592
  );
587
593
  await Promise.all(s);
588
594
  }
589
- async function Bt(e, t, o) {
595
+ async function At(e, t, r) {
590
596
  try {
591
- const r = c.readdirSync(o).map((i) => d.join(o, i)), s = [];
592
- for (const i of r)
593
- await At(
597
+ const o = p.readdirSync(r).map((i) => d.join(r, i)), s = [];
598
+ for (const i of o)
599
+ await Bt(
594
600
  e,
595
601
  t,
596
602
  i
597
603
  ) && s.push(i);
598
604
  return s;
599
- } catch (r) {
600
- return P.warn(`Failed to find stale Playground temp dirs: ${r}`), [];
605
+ } catch (o) {
606
+ return P.warn(`Failed to find stale Playground temp dirs: ${o}`), [];
601
607
  }
602
608
  }
603
- async function At(e, t, o) {
604
- if (!c.lstatSync(o).isDirectory())
609
+ async function Bt(e, t, r) {
610
+ if (!p.lstatSync(r).isDirectory())
605
611
  return !1;
606
- const s = d.basename(o);
612
+ const s = d.basename(r);
607
613
  if (!s.includes(e))
608
614
  return !1;
609
615
  const i = s.match(
@@ -618,11 +624,11 @@ async function At(e, t, o) {
618
624
  if (await Ct(n.pid, n.executableName))
619
625
  return !1;
620
626
  const l = Date.now() - t;
621
- return c.statSync(o).mtime.getTime() < l;
627
+ return p.statSync(r).mtime.getTime() < l;
622
628
  }
623
629
  async function Ct(e, t) {
624
- const [o] = await new Promise(
625
- (r, s) => {
630
+ const [r] = await new Promise(
631
+ (o, s) => {
626
632
  Je.list(
627
633
  {
628
634
  pid: e,
@@ -631,12 +637,12 @@ async function Ct(e, t) {
631
637
  clean: !0
632
638
  },
633
639
  (i, n) => {
634
- i ? s(i) : r(n);
640
+ i ? s(i) : o(n);
635
641
  }
636
642
  );
637
643
  }
638
644
  );
639
- return !!o && o.pid === e && o.command === t;
645
+ return !!r && r.pid === e && r.command === t;
640
646
  }
641
647
  function Dt(e) {
642
648
  return process.env.CI === "true" || process.env.CI === "1" || process.env.GITHUB_ACTIONS === "true" || process.env.GITHUB_ACTIONS === "1" || (process.env.TERM || "").toLowerCase() === "dumb" ? !1 : e ? !!e.isTTY : process.stdout.isTTY;
@@ -702,19 +708,19 @@ ${t}
702
708
  */
703
709
  printConfig(t) {
704
710
  if (this.isQuiet) return;
705
- const o = [];
706
- o.push(
711
+ const r = [];
712
+ r.push(
707
713
  `${this.dim("PHP")} ${this.cyan(t.phpVersion)} ${this.dim("WordPress")} ${this.cyan(t.wpVersion)}`
708
714
  );
709
- const r = [];
710
- if (t.intl && r.push("intl"), t.redis && r.push("redis"), t.memcached && r.push("memcached"), t.xdebug && r.push(this.yellow("xdebug")), r.length > 0 && o.push(`${this.dim("Extensions")} ${r.join(", ")}`), t.mounts.length > 0)
715
+ const o = [];
716
+ if (t.intl && o.push("intl"), t.redis && o.push("redis"), t.memcached && o.push("memcached"), t.xdebug && o.push(this.yellow("xdebug")), o.length > 0 && r.push(`${this.dim("Extensions")} ${o.join(", ")}`), t.mounts.length > 0)
711
717
  for (const s of t.mounts) {
712
718
  const i = s.autoMounted ? ` ${this.dim("(auto-mount)")}` : "";
713
- o.push(
719
+ r.push(
714
720
  `${this.dim("Mount")} ${s.hostPath} ${this.dim("→")} ${s.vfsPath}${i}`
715
721
  );
716
722
  }
717
- t.blueprint && o.push(`${this.dim("Blueprint")} ${t.blueprint}`), this.writeStream.write(o.join(`
723
+ t.blueprint && r.push(`${this.dim("Blueprint")} ${t.blueprint}`), this.writeStream.write(r.join(`
718
724
  `) + `
719
725
 
720
726
  `);
@@ -735,11 +741,11 @@ ${t}
735
741
  * Identical messages are skipped to prevent flickering. When piped,
736
742
  * this method does nothing (early return via shouldRender check).
737
743
  */
738
- updateProgress(t, o) {
744
+ updateProgress(t, r) {
739
745
  if (this.isQuiet || !this.shouldRender) return;
740
746
  this.progressActive || (this.progressActive = !0);
741
- let r = `${t}`;
742
- o !== void 0 && (r = `${t} ${this.dim(`${o}%`)}`), r !== this.lastProgressLine && (this.lastProgressLine = r, this.isTTY ? (this.writeStream.cursorTo(0), this.writeStream.write(r), this.writeStream.clearLine(1)) : this.writeStream.write(`${r}
747
+ let o = `${t}`;
748
+ r !== void 0 && (o = `${t} ${this.dim(`${r}%`)}`), o !== this.lastProgressLine && (this.lastProgressLine = o, this.isTTY ? (this.writeStream.cursorTo(0), this.writeStream.write(o), this.writeStream.clearLine(1)) : this.writeStream.write(`${o}
743
749
  `));
744
750
  }
745
751
  /**
@@ -779,12 +785,12 @@ ${t}
779
785
  * Note: The exact wording "WordPress is running on" is checked by
780
786
  * CI tests, so changes to this string will break test assertions.
781
787
  */
782
- printReady(t, o) {
788
+ printReady(t, r) {
783
789
  if (this.isQuiet) return;
784
- const r = o === 1 ? "worker" : "workers";
790
+ const o = r === 1 ? "worker" : "workers";
785
791
  this.writeStream.write(
786
792
  `
787
- ${this.green("Ready!")} WordPress is running on ${this.bold(t)} ${this.dim(`(${o} ${r})`)}
793
+ ${this.green("Ready!")} WordPress is running on ${this.bold(t)} ${this.dim(`(${r} ${o})`)}
788
794
 
789
795
  `
790
796
  );
@@ -805,11 +811,11 @@ ${this.green("Ready!")} WordPress is running on ${this.bold(t)} ${this.dim(`(${o
805
811
  }
806
812
  }
807
813
  const be = {
808
- Quiet: { name: "quiet", severity: F.Fatal },
809
- Normal: { name: "normal", severity: F.Info },
810
- Debug: { name: "debug", severity: F.Debug }
814
+ Quiet: { name: "quiet", severity: _.Fatal },
815
+ Normal: { name: "normal", severity: _.Info },
816
+ Debug: { name: "debug", severity: _.Debug }
811
817
  };
812
- async function bo(e) {
818
+ async function yr(e) {
813
819
  try {
814
820
  const t = {
815
821
  "site-url": {
@@ -839,14 +845,14 @@ async function bo(e) {
839
845
  type: "string",
840
846
  nargs: 2,
841
847
  array: !0,
842
- coerce: pt
848
+ coerce: ct
843
849
  },
844
850
  "define-number": {
845
851
  describe: "Define PHP number constants (can be used multiple times). Format: NAME value. Examples: --define-number LIMIT 100 --define-number RATE 45.67",
846
852
  type: "string",
847
853
  nargs: 2,
848
854
  array: !0,
849
- coerce: ct
855
+ coerce: pt
850
856
  },
851
857
  // @TODO: Support read-only mounts, e.g. via WORKERFS, a custom
852
858
  // ReadOnlyNODEFS, or by copying the files into MEMFS
@@ -854,13 +860,13 @@ async function bo(e) {
854
860
  describe: "Mount a directory to the PHP runtime (can be used multiple times). Format: /host/path:/vfs/path",
855
861
  type: "array",
856
862
  string: !0,
857
- coerce: N
863
+ coerce: F
858
864
  },
859
865
  "mount-before-install": {
860
866
  describe: "Mount a directory to the PHP runtime before WordPress installation (can be used multiple times). Format: /host/path:/vfs/path",
861
867
  type: "array",
862
868
  string: !0,
863
- coerce: N
869
+ coerce: F
864
870
  },
865
871
  "mount-dir": {
866
872
  describe: 'Mount a directory to the PHP runtime (can be used multiple times). Format: "/host/path" "/vfs/path"',
@@ -1003,7 +1009,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
1003
1009
  type: "string",
1004
1010
  coerce: (a) => a === "" ? "/phpmyadmin" : a
1005
1011
  }
1006
- }, o = {
1012
+ }, r = {
1007
1013
  port: {
1008
1014
  describe: "Port to listen on when serving. Defaults to 9400 when available.",
1009
1015
  type: "number"
@@ -1017,7 +1023,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
1017
1023
  describe: "Enable experimental browser development tools.",
1018
1024
  type: "boolean"
1019
1025
  }
1020
- }, r = {
1026
+ }, o = {
1021
1027
  path: {
1022
1028
  describe: "Path to the project directory. Playground will auto-detect if this is a plugin, theme, wp-content, or WordPress directory.",
1023
1029
  type: "string",
@@ -1072,7 +1078,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
1072
1078
  describe: "Mount a directory to the PHP runtime (can be used multiple times). Format: /host/path:/vfs/path. Use this for additional mounts beyond auto-detection.",
1073
1079
  type: "array",
1074
1080
  string: !0,
1075
- coerce: N
1081
+ coerce: F
1076
1082
  },
1077
1083
  reset: {
1078
1084
  describe: "Deletes the stored site directory and starts a new site from scratch.",
@@ -1096,7 +1102,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
1096
1102
  type: "string",
1097
1103
  default: "wordpress.zip"
1098
1104
  }
1099
- }, i = Ne(e).usage("Usage: wp-playground <command> [options]").command(
1105
+ }, i = Fe(e).usage("Usage: wp-playground <command> [options]").command(
1100
1106
  "start",
1101
1107
  "Start a local WordPress server with automatic project detection (recommended)",
1102
1108
  (a) => a.usage(
@@ -1112,13 +1118,13 @@ Examples:
1112
1118
  wp-playground start --wp=6.7 --php=8.3 # Use specific versions
1113
1119
  wp-playground start --skip-browser # Skip opening browser
1114
1120
  wp-playground start --no-auto-mount # Disable auto-detection`
1115
- ).options(r)
1121
+ ).options(o)
1116
1122
  ).command(
1117
1123
  "server",
1118
1124
  "Start a local WordPress server (advanced, low-level)",
1119
1125
  (a) => a.options({
1120
1126
  ...t,
1121
- ...o
1127
+ ...r
1122
1128
  })
1123
1129
  ).command(
1124
1130
  "run-blueprint",
@@ -1160,7 +1166,7 @@ Examples:
1160
1166
  if (a["auto-mount"]) {
1161
1167
  let y = !1;
1162
1168
  try {
1163
- y = c.statSync(
1169
+ y = p.statSync(
1164
1170
  a["auto-mount"]
1165
1171
  ).isDirectory();
1166
1172
  } catch {
@@ -1202,15 +1208,15 @@ Examples:
1202
1208
  ]
1203
1209
  }, S = await Lt(w);
1204
1210
  S === void 0 && process.exit(0);
1205
- const p = /* @__PURE__ */ (() => {
1211
+ const c = /* @__PURE__ */ (() => {
1206
1212
  let a;
1207
1213
  return async () => {
1208
1214
  a === void 0 && (a = S[Symbol.asyncDispose]()), await a, process.exit(0);
1209
1215
  };
1210
1216
  })();
1211
- return process.on("SIGINT", p), process.on("SIGTERM", p), {
1217
+ return process.on("SIGINT", c), process.on("SIGTERM", c), {
1212
1218
  [Symbol.asyncDispose]: async () => {
1213
- process.off("SIGINT", p), process.off("SIGTERM", p), await S[Symbol.asyncDispose]();
1219
+ process.off("SIGINT", c), process.off("SIGTERM", c), await S[Symbol.asyncDispose]();
1214
1220
  },
1215
1221
  [ge]: { cliServer: S }
1216
1222
  };
@@ -1218,15 +1224,15 @@ Examples:
1218
1224
  if (console.error(t), !(t instanceof Error))
1219
1225
  throw t;
1220
1226
  if (process.argv.includes("--debug"))
1221
- $e(t);
1227
+ Ee(t);
1222
1228
  else {
1223
- const r = [];
1229
+ const o = [];
1224
1230
  let s = t;
1225
1231
  do
1226
- r.push(s.message), s = s.cause;
1232
+ o.push(s.message), s = s.cause;
1227
1233
  while (s instanceof Error);
1228
1234
  console.error(
1229
- "\x1B[1m" + r.join(" caused by: ") + "\x1B[0m"
1235
+ "\x1B[1m" + o.join(" caused by: ") + "\x1B[0m"
1230
1236
  );
1231
1237
  }
1232
1238
  process.exit(1);
@@ -1234,18 +1240,18 @@ Examples:
1234
1240
  }
1235
1241
  function ae(e, t) {
1236
1242
  return e.find(
1237
- (o) => o.vfsPath.replace(/\/$/, "") === t.replace(/\/$/, "")
1243
+ (r) => r.vfsPath.replace(/\/$/, "") === t.replace(/\/$/, "")
1238
1244
  );
1239
1245
  }
1240
- const ge = Symbol("playground-cli-testing"), I = (e) => process.stdout.isTTY ? "\x1B[1m" + e + "\x1B[0m" : e, Wt = (e) => process.stdout.isTTY ? "\x1B[31m" + e + "\x1B[0m" : e, le = (e) => process.stdout.isTTY ? `\x1B[2m${e}\x1B[0m` : e, C = (e) => process.stdout.isTTY ? `\x1B[3m${e}\x1B[0m` : e, O = (e) => process.stdout.isTTY ? `\x1B[33m${e}\x1B[0m` : e;
1246
+ const ge = Symbol("playground-cli-testing"), I = (e) => process.stdout.isTTY ? "\x1B[1m" + e + "\x1B[0m" : e, Wt = (e) => process.stdout.isTTY ? "\x1B[31m" + e + "\x1B[0m" : e, le = (e) => process.stdout.isTTY ? `\x1B[2m${e}\x1B[0m` : e, C = (e) => process.stdout.isTTY ? `\x1B[3m${e}\x1B[0m` : e, N = (e) => process.stdout.isTTY ? `\x1B[33m${e}\x1B[0m` : e;
1241
1247
  async function Lt(e) {
1242
1248
  let t;
1243
- const o = e.internalCookieStore ? new Ee() : void 0, r = [], s = /* @__PURE__ */ new Map();
1249
+ const r = e.internalCookieStore ? new $e() : void 0, o = [], s = /* @__PURE__ */ new Map();
1244
1250
  if (e.command === "start" && (e = Ut(e)), e.autoMount !== void 0 && (e.autoMount === "" && (e = { ...e, autoMount: process.cwd() }), e = he(e)), e.wordpressInstallMode === void 0 && (e.wordpressInstallMode = "download-and-install"), e.quiet && (e.verbosity = "quiet", delete e.quiet), e.debug && (e.verbosity = "debug", delete e.debug), e.verbosity) {
1245
- const p = Object.values(be).find(
1251
+ const c = Object.values(be).find(
1246
1252
  (a) => a.name === e.verbosity
1247
1253
  ).severity;
1248
- P.setSeverityFilterLevel(p);
1254
+ P.setSeverityFilterLevel(c);
1249
1255
  }
1250
1256
  if (e.intl || (e.intl = !0), e.redis === void 0 && (e.redis = await se()), e.memcached === void 0 && (e.memcached = await se()), e.phpmyadmin) {
1251
1257
  if (e.phpmyadmin === !0 && (e.phpmyadmin = "/phpmyadmin"), e.skipSqliteSetup)
@@ -1255,7 +1261,7 @@ async function Lt(e) {
1255
1261
  e.pathAliases = [
1256
1262
  {
1257
1263
  urlPrefix: e.phpmyadmin,
1258
- fsPath: re
1264
+ fsPath: oe
1259
1265
  }
1260
1266
  ];
1261
1267
  }
@@ -1280,10 +1286,10 @@ async function Lt(e) {
1280
1286
  let u = !1, w = !0;
1281
1287
  const S = await wt({
1282
1288
  port: e.port ? e.port : await ht(n) ? 0 : n,
1283
- onBind: async (p, a) => {
1284
- const m = "127.0.0.1", y = `http://${m}:${a}`, W = e["site-url"] || y, L = 6, z = "-playground-cli-site-", E = await kt(z);
1285
- P.debug(`Native temp dir for VFS root: ${E.path}`);
1286
- const B = "WP Playground CLI - Listen for Xdebug", G = ".playground-xdebug-root", U = d.join(process.cwd(), G);
1289
+ onBind: async (c, a) => {
1290
+ const m = "127.0.0.1", y = `http://${m}:${a}`, W = e["site-url"] || y, L = 6, z = "-playground-cli-site-", $ = await kt(z);
1291
+ P.debug(`Native temp dir for VFS root: ${$.path}`);
1292
+ const A = "WP Playground CLI - Listen for Xdebug", G = ".playground-xdebug-root", U = d.join(process.cwd(), G);
1287
1293
  if (await Ke(U), e.xdebug) {
1288
1294
  const f = {
1289
1295
  hostPath: d.join(".", d.sep, G),
@@ -1292,8 +1298,8 @@ async function Lt(e) {
1292
1298
  if (R.indexOf(
1293
1299
  e.php || M
1294
1300
  ) <= R.indexOf("8.5"))
1295
- await oe(
1296
- E.path,
1301
+ await re(
1302
+ $.path,
1297
1303
  U,
1298
1304
  process.platform
1299
1305
  ), e.xdebug = et({
@@ -1311,25 +1317,25 @@ async function Lt(e) {
1311
1317
  "/proc/"
1312
1318
  ]
1313
1319
  }), console.log(I("Xdebug configured successfully")), console.log(
1314
- O("Playground source root: ") + ".playground-xdebug-root" + C(
1320
+ N("Playground source root: ") + ".playground-xdebug-root" + C(
1315
1321
  le(
1316
1322
  " – you can set breakpoints and preview Playground's VFS structure in there."
1317
1323
  )
1318
1324
  )
1319
1325
  );
1320
1326
  else if (e.experimentalUnsafeIdeIntegration) {
1321
- await oe(
1322
- E.path,
1327
+ await re(
1328
+ $.path,
1323
1329
  U,
1324
1330
  process.platform
1325
1331
  );
1326
1332
  try {
1327
1333
  await tt(
1328
- B,
1334
+ A,
1329
1335
  process.cwd()
1330
1336
  );
1331
- const h = typeof e.xdebug == "object" ? e.xdebug : {}, b = await ot({
1332
- name: B,
1337
+ const h = typeof e.xdebug == "object" ? e.xdebug : {}, b = await rt({
1338
+ name: A,
1333
1339
  host: m,
1334
1340
  port: a,
1335
1341
  ides: e.experimentalUnsafeIdeIntegration,
@@ -1344,9 +1350,9 @@ async function Lt(e) {
1344
1350
  console.log(""), X.length > 0 ? (console.log(
1345
1351
  I("Xdebug configured successfully")
1346
1352
  ), console.log(
1347
- O("Updated IDE config: ") + X.join(" ")
1353
+ N("Updated IDE config: ") + X.join(" ")
1348
1354
  ), console.log(
1349
- O("Playground source root: ") + ".playground-xdebug-root" + C(
1355
+ N("Playground source root: ") + ".playground-xdebug-root" + C(
1350
1356
  le(
1351
1357
  " – you can set breakpoints and preview Playground's VFS structure in there."
1352
1358
  )
@@ -1367,7 +1373,7 @@ async function Lt(e) {
1367
1373
  " 2. Open the Run and Debug panel on the left sidebar"
1368
1374
  ), console.log(
1369
1375
  ` 3. Select "${C(
1370
- B
1376
+ A
1371
1377
  )}" from the dropdown`
1372
1378
  ), console.log(' 3. Click "start debugging"'), console.log(
1373
1379
  " 5. Set a breakpoint. For example, in .playground-xdebug-root/wordpress/index.php"
@@ -1375,7 +1381,7 @@ async function Lt(e) {
1375
1381
  " 6. Visit Playground in your browser to hit the breakpoint"
1376
1382
  ), T && console.log("")), T && b.phpstorm && (console.log(I("PhpStorm instructions:")), console.log(
1377
1383
  ` 1. Choose "${C(
1378
- B
1384
+ A
1379
1385
  )}" debug configuration in the toolbar`
1380
1386
  ), console.log(
1381
1387
  " 2. Click the debug button (bug icon)`"
@@ -1391,13 +1397,13 @@ async function Lt(e) {
1391
1397
  }
1392
1398
  }
1393
1399
  }
1394
- const Pe = d.dirname(E.path), ve = 2 * 24 * 60 * 60 * 1e3;
1400
+ const Pe = d.dirname($.path), ve = 2 * 24 * 60 * 60 * 1e3;
1395
1401
  Mt(
1396
1402
  z,
1397
1403
  ve,
1398
1404
  Pe
1399
1405
  );
1400
- const Q = d.join(E.path, "internal");
1406
+ const Q = d.join($.path, "internal");
1401
1407
  j(Q);
1402
1408
  const Se = [
1403
1409
  "wordpress",
@@ -1415,7 +1421,7 @@ async function Lt(e) {
1415
1421
  const g = (b) => b.vfsPath === `/${f}`;
1416
1422
  if (!(e["mount-before-install"]?.some(g) || e.mount?.some(g))) {
1417
1423
  const b = d.join(
1418
- E.path,
1424
+ $.path,
1419
1425
  f
1420
1426
  );
1421
1427
  j(b), e["mount-before-install"] === void 0 && (e["mount-before-install"] = []), e["mount-before-install"].unshift({
@@ -1446,14 +1452,14 @@ async function Lt(e) {
1446
1452
  blueprintMayReadAdjacentFiles: e["blueprint-may-read-adjacent-files"] === !0
1447
1453
  })));
1448
1454
  let H = !1;
1449
- const A = async function() {
1455
+ const B = async function() {
1450
1456
  H || (H = !0, await Promise.all(
1451
- r.map(async (g) => {
1457
+ o.map(async (g) => {
1452
1458
  await s.get(g)?.dispose(), await g.worker.terminate();
1453
1459
  })
1454
- ), p && await new Promise((g) => {
1455
- p.close(g), p.closeAllConnections();
1456
- }), await E.cleanup());
1460
+ ), c && await new Promise((g) => {
1461
+ c.close(g), c.closeAllConnections();
1462
+ }), await $.cleanup());
1457
1463
  };
1458
1464
  try {
1459
1465
  const f = [], g = k.getWorkerType();
@@ -1467,8 +1473,8 @@ async function Lt(e) {
1467
1473
  }
1468
1474
  }).then(
1469
1475
  async (v) => {
1470
- r.push(v);
1471
- const x = await Ft(l), T = await k.bootRequestHandler({
1476
+ o.push(v);
1477
+ const x = await _t(l), T = await k.bootRequestHandler({
1472
1478
  worker: v,
1473
1479
  fileLockManagerPort: x,
1474
1480
  nativeInternalDirPath: Q
@@ -1482,12 +1488,12 @@ async function Lt(e) {
1482
1488
  f.push(b), h === 0 && await b;
1483
1489
  }
1484
1490
  await Promise.all(f), t = Ie(
1485
- r.map(
1491
+ o.map(
1486
1492
  (h) => s.get(h)
1487
1493
  )
1488
1494
  );
1489
1495
  {
1490
- const h = new pe(), b = h.port1, v = h.port2;
1496
+ const h = new ce(), b = h.port1, v = h.port2;
1491
1497
  if (await ke(
1492
1498
  {
1493
1499
  applyPostInstallMountsToAllWorkers: async () => {
@@ -1517,16 +1523,16 @@ async function Lt(e) {
1517
1523
  );
1518
1524
  }
1519
1525
  if (e.phpmyadmin && !await t.fileExists(
1520
- `${re}/index.php`
1526
+ `${oe}/index.php`
1521
1527
  )) {
1522
1528
  const x = await st(), T = await de({ steps: x });
1523
1529
  await ee(T, t);
1524
1530
  }
1525
1531
  if (e.command === "build-snapshot") {
1526
- await Ot(t, e.outfile), i.printStatus(`Exported to ${e.outfile}`), await A();
1532
+ await Nt(t, e.outfile), i.printStatus(`Exported to ${e.outfile}`), await B();
1527
1533
  return;
1528
1534
  } else if (e.command === "run-blueprint") {
1529
- i.finishProgress("Done"), await A();
1535
+ i.finishProgress("Done"), await B();
1530
1536
  return;
1531
1537
  }
1532
1538
  }
@@ -1544,9 +1550,9 @@ async function Lt(e) {
1544
1550
  phpRoot: "/wordpress"
1545
1551
  })).start(), {
1546
1552
  playground: t,
1547
- server: p,
1553
+ server: c,
1548
1554
  serverUrl: y,
1549
- [Symbol.asyncDispose]: A,
1555
+ [Symbol.asyncDispose]: B,
1550
1556
  [ge]: {
1551
1557
  workerThreadCount: L
1552
1558
  }
@@ -1555,10 +1561,10 @@ async function Lt(e) {
1555
1561
  if (e.verbosity !== "debug")
1556
1562
  throw f;
1557
1563
  let g = "";
1558
- throw await t?.fileExists(Z) && (g = await t.readFileAsText(Z)), await A(), new Error(g, { cause: f });
1564
+ throw await t?.fileExists(Z) && (g = await t.readFileAsText(Z)), await B(), new Error(g, { cause: f });
1559
1565
  }
1560
1566
  },
1561
- async handleRequest(p) {
1567
+ async handleRequest(c) {
1562
1568
  if (!u)
1563
1569
  return J.forHttpCode(
1564
1570
  502,
@@ -1569,9 +1575,9 @@ async function Lt(e) {
1569
1575
  const m = {
1570
1576
  "Content-Type": ["text/plain"],
1571
1577
  "Content-Length": ["0"],
1572
- Location: [p.url]
1578
+ Location: [c.url]
1573
1579
  };
1574
- return p.headers?.cookie?.includes(
1580
+ return c.headers?.cookie?.includes(
1575
1581
  "playground_auto_login_already_happened"
1576
1582
  ) && (m["Set-Cookie"] = [
1577
1583
  "playground_auto_login_already_happened=1; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=/"
@@ -1579,39 +1585,39 @@ async function Lt(e) {
1579
1585
  new Me(302, m, new Uint8Array())
1580
1586
  );
1581
1587
  }
1582
- o && (p = {
1583
- ...p,
1588
+ r && (c = {
1589
+ ...c,
1584
1590
  headers: {
1585
- ...p.headers,
1591
+ ...c.headers,
1586
1592
  // While we have an internal cookie store, we
1587
1593
  // completely replace the incoming request's Cookie
1588
1594
  // header with the cookies from our store. This avoids
1589
1595
  // getting into a strange state where both browser and
1590
1596
  // server are managing cookies.
1591
- cookie: o.getCookieRequestHeader()
1597
+ cookie: r.getCookieRequestHeader()
1592
1598
  }
1593
1599
  });
1594
- const a = await t.requestStreamed(p);
1595
- if (o) {
1600
+ const a = await t.requestStreamed(c);
1601
+ if (r) {
1596
1602
  const m = await a.headers;
1597
- o.rememberCookiesFromResponseHeaders(m), delete m["set-cookie"];
1603
+ r.rememberCookiesFromResponseHeaders(m), delete m["set-cookie"];
1598
1604
  }
1599
1605
  return a;
1600
1606
  }
1601
- }).catch((p) => {
1602
- i.printError(p.message), process.exit(1);
1607
+ }).catch((c) => {
1608
+ i.printError(c.message), process.exit(1);
1603
1609
  });
1604
- return S && e.command === "start" && !e.skipBrowser && Nt(S.serverUrl), S;
1610
+ return S && e.command === "start" && !e.skipBrowser && Ft(S.serverUrl), S;
1605
1611
  }
1606
1612
  function Ut(e) {
1607
1613
  let t = { ...e, command: "server" };
1608
1614
  e.noAutoMount || (t.autoMount = d.resolve(process.cwd(), t.path ?? ""), t = he(t), delete t.autoMount);
1609
- const o = ae(
1615
+ const r = ae(
1610
1616
  t["mount-before-install"] || [],
1611
1617
  "/wordpress"
1612
1618
  ) || ae(t.mount || [], "/wordpress");
1613
- if (o)
1614
- console.log("Site files stored at:", o?.hostPath), e.reset && (console.log(""), console.log(
1619
+ if (r)
1620
+ console.log("Site files stored at:", r?.hostPath), e.reset && (console.log(""), console.log(
1615
1621
  Wt(
1616
1622
  "This site is not managed by Playground CLI and cannot be reset."
1617
1623
  )
@@ -1621,7 +1627,7 @@ function Ut(e) {
1621
1627
  "You may still remove the site's directory manually if you wish."
1622
1628
  ), process.exit(1));
1623
1629
  else {
1624
- const r = t.autoMount || process.cwd(), s = rt("sha256").update(r).digest("hex"), i = q.homedir(), n = d.join(
1630
+ const o = t.autoMount || process.cwd(), s = ot("sha256").update(o).digest("hex"), i = q.homedir(), n = d.join(
1625
1631
  i,
1626
1632
  ".wordpress-playground/sites",
1627
1633
  s
@@ -1640,55 +1646,55 @@ function Ut(e) {
1640
1646
  }
1641
1647
  return t;
1642
1648
  }
1643
- const _ = new xe();
1649
+ const O = new xe();
1644
1650
  function Ht(e, { onExit: t } = {}) {
1645
- let o;
1646
- return e === "v1" ? o = new te(new URL("./worker-thread-v1.js", import.meta.url)) : o = new te(new URL("./worker-thread-v2.js", import.meta.url)), new Promise((r, s) => {
1647
- const i = _.claim();
1648
- o.once("message", function(l) {
1649
- l.command === "worker-script-initialized" && r({
1651
+ let r;
1652
+ return e === "v1" ? r = new te(new URL("./worker-thread-v1.js", import.meta.url)) : r = new te(new URL("./worker-thread-v2.js", import.meta.url)), new Promise((o, s) => {
1653
+ const i = O.claim();
1654
+ r.once("message", function(l) {
1655
+ l.command === "worker-script-initialized" && o({
1650
1656
  processId: i,
1651
- worker: o,
1657
+ worker: r,
1652
1658
  phpPort: l.phpPort
1653
1659
  });
1654
- }), o.once("error", function(l) {
1655
- _.release(i), console.error(l);
1660
+ }), r.once("error", function(l) {
1661
+ O.release(i), console.error(l);
1656
1662
  const u = new Error(
1657
1663
  `Worker failed to load worker. ${l.message ? `Original error: ${l.message}` : ""}`
1658
1664
  );
1659
1665
  s(u);
1660
1666
  });
1661
1667
  let n = !1;
1662
- o.once("spawn", () => {
1668
+ r.once("spawn", () => {
1663
1669
  n = !0;
1664
- }), o.once("exit", (l) => {
1665
- _.release(i), n || s(new Error(`Worker exited before spawning: ${l}`)), t?.(l);
1670
+ }), r.once("exit", (l) => {
1671
+ O.release(i), n || s(new Error(`Worker exited before spawning: ${l}`)), t?.(l);
1666
1672
  });
1667
1673
  });
1668
1674
  }
1669
- async function Ft(e) {
1670
- const { port1: t, port2: o } = new pe();
1671
- return await Be(e, t), o;
1675
+ async function _t(e) {
1676
+ const { port1: t, port2: r } = new ce();
1677
+ return await Ae(e, t), r;
1672
1678
  }
1673
- function Nt(e) {
1679
+ function Ft(e) {
1674
1680
  const t = q.platform();
1675
- let o;
1681
+ let r;
1676
1682
  switch (t) {
1677
1683
  case "darwin":
1678
- o = `open "${e}"`;
1684
+ r = `open "${e}"`;
1679
1685
  break;
1680
1686
  case "win32":
1681
- o = `start "" "${e}"`;
1687
+ r = `start "" "${e}"`;
1682
1688
  break;
1683
1689
  default:
1684
- o = `xdg-open "${e}"`;
1690
+ r = `xdg-open "${e}"`;
1685
1691
  break;
1686
1692
  }
1687
- me(o, (r) => {
1688
- r && P.debug(`Could not open browser: ${r.message}`);
1693
+ me(r, (o) => {
1694
+ o && P.debug(`Could not open browser: ${o.message}`);
1689
1695
  });
1690
1696
  }
1691
- async function Ot(e, t) {
1697
+ async function Nt(e, t) {
1692
1698
  await e.run({
1693
1699
  code: `<?php
1694
1700
  $zip = new ZipArchive();
@@ -1709,17 +1715,17 @@ async function Ot(e, t) {
1709
1715
 
1710
1716
  `
1711
1717
  });
1712
- const o = await e.readFileAsBuffer("/tmp/build.zip");
1713
- c.writeFileSync(t, o);
1718
+ const r = await e.readFileAsBuffer("/tmp/build.zip");
1719
+ p.writeFileSync(t, r);
1714
1720
  }
1715
1721
  export {
1716
1722
  be as L,
1717
- yo as a,
1723
+ wr as a,
1718
1724
  Dt as b,
1719
1725
  ge as i,
1720
1726
  we as m,
1721
- bo as p,
1727
+ yr as p,
1722
1728
  Lt as r,
1723
1729
  Ht as s
1724
1730
  };
1725
- //# sourceMappingURL=run-cli-Cv4FHhj_.js.map
1731
+ //# sourceMappingURL=run-cli-DEBbpuwb.js.map