@wp-playground/cli 3.0.43 → 3.0.44

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,26 +1,26 @@
1
- import { logger as g, LogSeverity as j, errorLogPath as ee } from "@php-wasm/logger";
2
- import { PHPResponse as Y, consumeAPI as F, SupportedPHPVersions as te, printDebugDetails as ye, exposeAPI as be, exposeSyncAPI as ve } from "@php-wasm/universal";
3
- import { resolveRemoteBlueprint as Pe, resolveRuntimeConfiguration as re, compileBlueprintV1 as Se, isBlueprintBundle as xe, runBlueprintV1Steps as ke } from "@wp-playground/blueprints";
4
- import { zipDirectory as Ie, RecommendedPHPVersion as U } from "@wp-playground/common";
5
- import p, { existsSync as X, rmdirSync as $e, mkdirSync as z, readdirSync as Te } from "fs";
6
- import { MessageChannel as Be, Worker as oe } from "worker_threads";
7
- import { createNodeFsMountHandler as Ee, FileLockManagerForNode as Le } from "@php-wasm/node";
8
- import h, { basename as A, join as ue } from "path";
1
+ import { logger as y, LogSeverity as j, errorLogPath as te } from "@php-wasm/logger";
2
+ import { PHPResponse as z, consumeAPI as U, SupportedPHPVersions as re, printDebugDetails as be, exposeAPI as ve, exposeSyncAPI as Pe } from "@php-wasm/universal";
3
+ import { resolveRemoteBlueprint as Se, resolveRuntimeConfiguration as oe, compileBlueprintV1 as xe, isBlueprintBundle as ke, runBlueprintV1Steps as Ie } from "@wp-playground/blueprints";
4
+ import { zipDirectory as $e, RecommendedPHPVersion as F } from "@wp-playground/common";
5
+ import c, { existsSync as X, rmdirSync as Ee, mkdirSync as G, readdirSync as Te } from "fs";
6
+ import { MessageChannel as Be, Worker as se } from "worker_threads";
7
+ import { createNodeFsMountHandler as Ce, FileLockManagerForNode as Le } from "@php-wasm/node";
8
+ import p, { basename as A, join as de } from "path";
9
9
  import We from "express";
10
- import O, { cpus as Ce } from "os";
11
- import { jspi as Me } from "wasm-feature-detect";
10
+ import N, { cpus as Me } from "os";
11
+ import { jspi as De } from "wasm-feature-detect";
12
12
  import Re from "yargs";
13
- import { NodeJsFilesystem as De, OverlayFilesystem as Ae, InMemoryFilesystem as Fe, ZipFilesystem as Ue } from "@wp-playground/storage";
14
- import { EmscriptenDownloadMonitor as Oe, ProgressTracker as He } from "@php-wasm/progress";
15
- import { resolveWordPressRelease as Ve } from "@wp-playground/wordpress";
13
+ import { NodeJsFilesystem as Ae, OverlayFilesystem as Ue, InMemoryFilesystem as Fe, ZipFilesystem as Oe } from "@wp-playground/storage";
14
+ import { EmscriptenDownloadMonitor as Ne, ProgressTracker as _e } from "@php-wasm/progress";
15
+ import { resolveWordPressRelease as He } from "@wp-playground/wordpress";
16
16
  import B from "fs-extra";
17
- import { startBridge as Ne } from "@php-wasm/xdebug-bridge";
17
+ import { startBridge as Ve } from "@php-wasm/xdebug-bridge";
18
18
  import { exec as je } from "child_process";
19
- import { dir as _e, setGracefulCleanup as qe } from "tmp-promise";
20
- import Ye from "ps-man";
21
- import { removeTempDirSymlink as ze, createTempDirSymlink as Qe, clearXdebugIDEConfig as Xe, addXdebugIDEConfig as Ze } from "@php-wasm/cli-util";
22
- import { createHash as Ge } from "crypto";
23
- function _(e) {
19
+ import { dir as qe, setGracefulCleanup as Ye } from "tmp-promise";
20
+ import ze from "ps-man";
21
+ import { removeTempDirSymlink as Ge, createTempDirSymlink as Qe, clearXdebugIDEConfig as Xe, addXdebugIDEConfig as Ze } from "@php-wasm/cli-util";
22
+ import { createHash as Je } from "crypto";
23
+ function q(e) {
24
24
  const t = [];
25
25
  for (const r of e) {
26
26
  const s = r.split(":");
@@ -29,14 +29,14 @@ function _(e) {
29
29
  Expected format: /host/path:/vfs/path.
30
30
  If your path contains a colon, e.g. C:\\myplugin, use the --mount-dir option instead.
31
31
  Example: --mount-dir C:\\my-plugin /wordpress/wp-content/plugins/my-plugin`);
32
- const [o, i] = s;
32
+ const [o, n] = s;
33
33
  if (!X(o))
34
34
  throw new Error(`Host path does not exist: ${o}`);
35
- t.push({ hostPath: o, vfsPath: i });
35
+ t.push({ hostPath: o, vfsPath: n });
36
36
  }
37
37
  return t;
38
38
  }
39
- function se(e) {
39
+ function ne(e) {
40
40
  if (e.length % 2 !== 0)
41
41
  throw new Error("Invalid mount format. Expected: /host/path /vfs/path");
42
42
  const t = [];
@@ -45,17 +45,17 @@ function se(e) {
45
45
  if (!X(s))
46
46
  throw new Error(`Host path does not exist: ${s}`);
47
47
  t.push({
48
- hostPath: h.resolve(process.cwd(), s),
48
+ hostPath: p.resolve(process.cwd(), s),
49
49
  vfsPath: o
50
50
  });
51
51
  }
52
52
  return t;
53
53
  }
54
- async function Gt(e, t) {
54
+ async function rr(e, t) {
55
55
  for (const r of t)
56
56
  await e.mount(
57
57
  r.vfsPath,
58
- Ee(r.hostPath)
58
+ Ce(r.hostPath)
59
59
  );
60
60
  }
61
61
  const ie = {
@@ -77,7 +77,7 @@ const ie = {
77
77
  `
78
78
  }
79
79
  };
80
- function de(e) {
80
+ function ce(e) {
81
81
  const t = e.autoMount, r = [...e.mount || []], s = [...e["mount-before-install"] || []], o = {
82
82
  ...e,
83
83
  mount: r,
@@ -86,110 +86,183 @@ function de(e) {
86
86
  ...e["additional-blueprint-steps"] || []
87
87
  ]
88
88
  };
89
- if (tt(t)) {
90
- const n = `/wordpress/wp-content/plugins/${A(t)}`;
89
+ if (rt(t)) {
90
+ const i = `/wordpress/wp-content/plugins/${A(t)}`;
91
91
  r.push({
92
92
  hostPath: t,
93
- vfsPath: n,
93
+ vfsPath: i,
94
94
  autoMounted: !0
95
95
  }), o["additional-blueprint-steps"].push({
96
96
  step: "activatePlugin",
97
97
  pluginPath: `/wordpress/wp-content/plugins/${A(t)}`
98
98
  });
99
- } else if (et(t)) {
100
- const i = A(t), n = `/wordpress/wp-content/themes/${i}`;
99
+ } else if (tt(t)) {
100
+ const n = A(t), i = `/wordpress/wp-content/themes/${n}`;
101
101
  r.push({
102
102
  hostPath: t,
103
- vfsPath: n,
103
+ vfsPath: i,
104
104
  autoMounted: !0
105
105
  }), o["additional-blueprint-steps"].push(
106
106
  e["experimental-blueprints-v2-runner"] ? {
107
107
  step: "activateTheme",
108
- themeDirectoryName: i
108
+ themeDirectoryName: n
109
109
  } : {
110
110
  step: "activateTheme",
111
- themeFolderName: i
111
+ themeFolderName: n
112
112
  }
113
113
  );
114
- } else if (Ke(t)) {
115
- const i = p.readdirSync(t);
116
- for (const n of i)
117
- n !== "index.php" && r.push({
118
- hostPath: `${t}/${n}`,
119
- vfsPath: `/wordpress/wp-content/${n}`,
114
+ } else if (et(t)) {
115
+ const n = c.readdirSync(t);
116
+ for (const i of n)
117
+ i !== "index.php" && r.push({
118
+ hostPath: `${t}/${i}`,
119
+ vfsPath: `/wordpress/wp-content/${i}`,
120
120
  autoMounted: !0
121
121
  });
122
122
  o["additional-blueprint-steps"].push(ie);
123
- } else Je(t) && (s.push({
123
+ } else Ke(t) && (s.push({
124
124
  hostPath: t,
125
125
  vfsPath: "/wordpress",
126
126
  autoMounted: !0
127
127
  }), o.mode = "apply-to-existing-site", o["additional-blueprint-steps"].push(ie), o.wordpressInstallMode || (o.wordpressInstallMode = "install-from-existing-files-if-needed"));
128
128
  return o;
129
129
  }
130
- function Je(e) {
131
- const t = p.readdirSync(e);
130
+ function Ke(e) {
131
+ const t = c.readdirSync(e);
132
132
  return t.includes("wp-admin") && t.includes("wp-includes") && t.includes("wp-content");
133
133
  }
134
- function Ke(e) {
135
- const t = p.readdirSync(e);
134
+ function et(e) {
135
+ const t = c.readdirSync(e);
136
136
  return t.includes("themes") || t.includes("plugins") || t.includes("mu-plugins") || t.includes("uploads");
137
137
  }
138
- function et(e) {
139
- if (!p.readdirSync(e).includes("style.css"))
138
+ function tt(e) {
139
+ if (!c.readdirSync(e).includes("style.css"))
140
140
  return !1;
141
- const r = p.readFileSync(ue(e, "style.css"), "utf8");
141
+ const r = c.readFileSync(de(e, "style.css"), "utf8");
142
142
  return !!/^(?:[ \t]*<\?php)?[ \t/*#@]*Theme Name:(.*)$/im.exec(r);
143
143
  }
144
- function tt(e) {
145
- const t = p.readdirSync(e), r = /^(?:[ \t]*<\?php)?[ \t/*#@]*Plugin Name:(.*)$/im;
144
+ function rt(e) {
145
+ const t = c.readdirSync(e), r = /^(?:[ \t]*<\?php)?[ \t/*#@]*Plugin Name:(.*)$/im;
146
146
  return !!t.filter((o) => o.endsWith(".php")).find((o) => {
147
- const i = p.readFileSync(ue(e, o), "utf8");
148
- return !!r.exec(i);
147
+ const n = c.readFileSync(de(e, o), "utf8");
148
+ return !!r.exec(n);
149
149
  });
150
150
  }
151
- async function rt(e) {
152
- const t = We(), r = await new Promise((i, n) => {
151
+ function ot(e) {
152
+ if (e.length % 2 !== 0)
153
+ throw new Error(
154
+ "Invalid constant definition format. Expected pairs of NAME value"
155
+ );
156
+ const t = {};
157
+ for (let r = 0; r < e.length; r += 2) {
158
+ const s = e[r], o = e[r + 1];
159
+ if (!s || !s.trim())
160
+ throw new Error("Constant name cannot be empty");
161
+ t[s.trim()] = o;
162
+ }
163
+ return t;
164
+ }
165
+ function st(e) {
166
+ if (e.length % 2 !== 0)
167
+ throw new Error(
168
+ "Invalid boolean constant definition format. Expected pairs of NAME value"
169
+ );
170
+ const t = {};
171
+ for (let r = 0; r < e.length; r += 2) {
172
+ const s = e[r], o = e[r + 1].trim().toLowerCase();
173
+ if (!s || !s.trim())
174
+ throw new Error("Constant name cannot be empty");
175
+ if (o === "true" || o === "1")
176
+ t[s.trim()] = !0;
177
+ else if (o === "false" || o === "0")
178
+ t[s.trim()] = !1;
179
+ else
180
+ throw new Error(
181
+ `Invalid boolean value for constant "${s}": "${o}". Must be "true", "false", "1", or "0".`
182
+ );
183
+ }
184
+ return t;
185
+ }
186
+ function nt(e) {
187
+ if (e.length % 2 !== 0)
188
+ throw new Error(
189
+ "Invalid number constant definition format. Expected pairs of NAME value"
190
+ );
191
+ const t = {};
192
+ for (let r = 0; r < e.length; r += 2) {
193
+ const s = e[r], o = e[r + 1].trim();
194
+ if (!s || !s.trim())
195
+ throw new Error("Constant name cannot be empty");
196
+ const n = Number(o);
197
+ if (isNaN(n))
198
+ throw new Error(
199
+ `Invalid number value for constant "${s}": "${o}". Must be a valid number.`
200
+ );
201
+ t[s.trim()] = n;
202
+ }
203
+ return t;
204
+ }
205
+ function it(e = {}, t = {}, r = {}) {
206
+ const s = {}, o = /* @__PURE__ */ new Set(), n = (i, l) => {
207
+ for (const u in i) {
208
+ if (o.has(u))
209
+ throw new Error(
210
+ `Constant "${u}" is defined multiple times across different --define-${l} flags`
211
+ );
212
+ o.add(u), s[u] = i[u];
213
+ }
214
+ };
215
+ return n(e, "string"), n(t, "bool"), n(r, "number"), s;
216
+ }
217
+ function O(e) {
218
+ return it(
219
+ e.define,
220
+ e["define-bool"],
221
+ e["define-number"]
222
+ );
223
+ }
224
+ async function at(e) {
225
+ const t = We(), r = await new Promise((n, i) => {
153
226
  const l = t.listen(e.port, () => {
154
227
  const u = l.address();
155
- u === null || typeof u == "string" ? n(new Error("Server address is not available")) : i(l);
228
+ u === null || typeof u == "string" ? i(new Error("Server address is not available")) : n(l);
156
229
  });
157
230
  });
158
- t.use("/", async (i, n) => {
231
+ t.use("/", async (n, i) => {
159
232
  let l;
160
233
  try {
161
234
  l = await e.handleRequest({
162
- url: i.url,
163
- headers: st(i),
164
- method: i.method,
165
- body: await ot(i)
235
+ url: n.url,
236
+ headers: ut(n),
237
+ method: n.method,
238
+ body: await lt(n)
166
239
  });
167
240
  } catch (u) {
168
- g.error(u), l = Y.forHttpCode(500);
241
+ y.error(u), l = z.forHttpCode(500);
169
242
  }
170
- n.statusCode = l.httpStatusCode;
243
+ i.statusCode = l.httpStatusCode;
171
244
  for (const u in l.headers)
172
- n.setHeader(u, l.headers[u]);
173
- n.end(l.bytes);
245
+ i.setHeader(u, l.headers[u]);
246
+ i.end(l.bytes);
174
247
  });
175
248
  const o = r.address().port;
176
249
  return await e.onBind(r, o);
177
250
  }
178
- const ot = async (e) => await new Promise((t) => {
251
+ const lt = async (e) => await new Promise((t) => {
179
252
  const r = [];
180
253
  e.on("data", (s) => {
181
254
  r.push(s);
182
255
  }), e.on("end", () => {
183
256
  t(new Uint8Array(Buffer.concat(r)));
184
257
  });
185
- }), st = (e) => {
258
+ }), ut = (e) => {
186
259
  const t = {};
187
260
  if (e.rawHeaders && e.rawHeaders.length)
188
261
  for (let r = 0; r < e.rawHeaders.length; r += 2)
189
262
  t[e.rawHeaders[r].toLowerCase()] = e.rawHeaders[r + 1];
190
263
  return t;
191
264
  };
192
- class it {
265
+ class dt {
193
266
  constructor(t) {
194
267
  this.workerLoads = [], this.addWorker(t);
195
268
  }
@@ -211,8 +284,8 @@ class it {
211
284
  async handleRequest(t) {
212
285
  let r = this.workerLoads[0];
213
286
  for (let o = 1; o < this.workerLoads.length; o++) {
214
- const i = this.workerLoads[o];
215
- i.activeRequests.size < r.activeRequests.size && (r = i);
287
+ const n = this.workerLoads[o];
288
+ n.activeRequests.size < r.activeRequests.size && (r = n);
216
289
  }
217
290
  const s = r.worker.request(t);
218
291
  return r.activeRequests.add(s), s.url = t.url, s.finally(() => {
@@ -220,44 +293,44 @@ class it {
220
293
  });
221
294
  }
222
295
  }
223
- function nt(e) {
296
+ function ct(e) {
224
297
  return /^latest$|^trunk$|^nightly$|^(?:(\d+)\.(\d+)(?:\.(\d+))?)((?:-beta(?:\d+)?)|(?:-RC(?:\d+)?))?$/.test(e);
225
298
  }
226
- async function at({
299
+ async function pt({
227
300
  sourceString: e,
228
301
  blueprintMayReadAdjacentFiles: t
229
302
  }) {
230
303
  if (!e)
231
304
  return;
232
305
  if (e.startsWith("http://") || e.startsWith("https://"))
233
- return await Pe(e);
234
- let r = h.resolve(process.cwd(), e);
235
- if (!p.existsSync(r))
306
+ return await Se(e);
307
+ let r = p.resolve(process.cwd(), e);
308
+ if (!c.existsSync(r))
236
309
  throw new Error(`Blueprint file does not exist: ${r}`);
237
- const s = p.statSync(r);
238
- if (s.isDirectory() && (r = h.join(r, "blueprint.json")), !s.isFile() && s.isSymbolicLink())
310
+ const s = c.statSync(r);
311
+ if (s.isDirectory() && (r = p.join(r, "blueprint.json")), !s.isFile() && s.isSymbolicLink())
239
312
  throw new Error(
240
313
  `Blueprint path is neither a file nor a directory: ${r}`
241
314
  );
242
- const o = h.extname(r);
315
+ const o = p.extname(r);
243
316
  switch (o) {
244
317
  case ".zip":
245
- return Ue.fromArrayBuffer(
246
- p.readFileSync(r).buffer
318
+ return Oe.fromArrayBuffer(
319
+ c.readFileSync(r).buffer
247
320
  );
248
321
  case ".json": {
249
- const i = p.readFileSync(r, "utf-8");
322
+ const n = c.readFileSync(r, "utf-8");
250
323
  try {
251
- JSON.parse(i);
324
+ JSON.parse(n);
252
325
  } catch {
253
326
  throw new Error(
254
327
  `Blueprint file at ${r} is not a valid JSON file`
255
328
  );
256
329
  }
257
- const n = h.dirname(r), l = new De(n);
258
- return new Ae([
330
+ const i = p.dirname(r), l = new Ae(i);
331
+ return new Ue([
259
332
  new Fe({
260
- "blueprint.json": i
333
+ "blueprint.json": n
261
334
  }),
262
335
  /**
263
336
  * Wrap the NodeJS filesystem to prevent access to local files
@@ -282,7 +355,7 @@ You can allow this Blueprint to read files from the same parent directory by exp
282
355
  );
283
356
  }
284
357
  }
285
- class lt {
358
+ class mt {
286
359
  constructor(t, r) {
287
360
  this.args = t, this.siteUrl = r.siteUrl, this.processIdSpaceLength = r.processIdSpaceLength, this.phpVersion = t.php, this.cliOutput = r.cliOutput;
288
361
  }
@@ -290,9 +363,9 @@ class lt {
290
363
  return "v2";
291
364
  }
292
365
  async bootAndSetUpInitialPlayground(t, r, s) {
293
- const o = F(t);
366
+ const o = U(t);
294
367
  await o.useFileLockManager(r);
295
- const i = {
368
+ const n = {
296
369
  ...this.args,
297
370
  phpVersion: this.phpVersion,
298
371
  siteUrl: this.siteUrl,
@@ -309,9 +382,10 @@ class lt {
309
382
  xdebug: void 0,
310
383
  nativeInternalDirPath: s,
311
384
  mountsBeforeWpInstall: this.args["mount-before-install"] || [],
312
- mountsAfterWpInstall: this.args.mount || []
385
+ mountsAfterWpInstall: this.args.mount || [],
386
+ constants: O(this.args)
313
387
  };
314
- return await o.bootAndSetUpInitialWorker(i), o;
388
+ return await o.bootAndSetUpInitialWorker(n), o;
315
389
  }
316
390
  async bootPlayground({
317
391
  worker: t,
@@ -319,9 +393,9 @@ class lt {
319
393
  firstProcessId: s,
320
394
  nativeInternalDirPath: o
321
395
  }) {
322
- const i = F(t.phpPort);
323
- await i.useFileLockManager(r);
324
- const n = {
396
+ const n = U(t.phpPort);
397
+ await n.useFileLockManager(r);
398
+ const i = {
325
399
  ...this.args,
326
400
  phpVersion: this.phpVersion,
327
401
  siteUrl: this.siteUrl,
@@ -332,13 +406,14 @@ class lt {
332
406
  withXdebug: !!this.args.xdebug,
333
407
  nativeInternalDirPath: o,
334
408
  mountsBeforeWpInstall: this.args["mount-before-install"] || [],
335
- mountsAfterWpInstall: this.args.mount || []
409
+ mountsAfterWpInstall: this.args.mount || [],
410
+ constants: O(this.args)
336
411
  };
337
- return await i.bootWorker(n), i;
412
+ return await n.bootWorker(i), n;
338
413
  }
339
414
  }
340
- const Q = h.join(O.homedir(), ".wordpress-playground");
341
- async function ut(e) {
415
+ const Q = p.join(N.homedir(), ".wordpress-playground");
416
+ async function ht(e) {
342
417
  return await pe(
343
418
  "https://github.com/WordPress/sqlite-database-integration/archive/refs/heads/develop.zip",
344
419
  "sqlite.zip",
@@ -346,28 +421,28 @@ async function ut(e) {
346
421
  );
347
422
  }
348
423
  async function pe(e, t, r) {
349
- const s = h.join(Q, t);
350
- return B.existsSync(s) || (B.ensureDirSync(Q), await dt(e, s, r)), ce(s);
424
+ const s = p.join(Q, t);
425
+ return B.existsSync(s) || (B.ensureDirSync(Q), await ft(e, s, r)), me(s);
351
426
  }
352
- async function dt(e, t, r) {
353
- const o = (await r.monitorFetch(fetch(e))).body.getReader(), i = `${t}.partial`, n = B.createWriteStream(i);
427
+ async function ft(e, t, r) {
428
+ const o = (await r.monitorFetch(fetch(e))).body.getReader(), n = `${t}.partial`, i = B.createWriteStream(n);
354
429
  for (; ; ) {
355
430
  const { done: l, value: u } = await o.read();
356
- if (u && n.write(u), l)
431
+ if (u && i.write(u), l)
357
432
  break;
358
433
  }
359
- n.close(), n.closed || await new Promise((l, u) => {
360
- n.on("finish", () => {
361
- B.renameSync(i, t), l(null);
362
- }), n.on("error", (b) => {
363
- B.removeSync(i), u(b);
434
+ i.close(), i.closed || await new Promise((l, u) => {
435
+ i.on("finish", () => {
436
+ B.renameSync(n, t), l(null);
437
+ }), i.on("error", (v) => {
438
+ B.removeSync(n), u(v);
364
439
  });
365
440
  });
366
441
  }
367
- function ce(e, t) {
442
+ function me(e, t) {
368
443
  return new File([B.readFileSync(e)], A(e));
369
444
  }
370
- class pt {
445
+ class wt {
371
446
  constructor(t, r) {
372
447
  this.args = t, this.siteUrl = r.siteUrl, this.processIdSpaceLength = r.processIdSpaceLength, this.cliOutput = r.cliOutput;
373
448
  }
@@ -375,51 +450,51 @@ class pt {
375
450
  return "v1";
376
451
  }
377
452
  async bootAndSetUpInitialPlayground(t, r, s) {
378
- let o, i, n;
379
- const l = new Oe();
453
+ let o, n, i;
454
+ const l = new Ne();
380
455
  if (this.args.wordpressInstallMode === "download-and-install") {
381
- let E = !1;
382
- l.addEventListener("progress", (k) => {
383
- if (E)
456
+ let k = !1;
457
+ l.addEventListener("progress", (I) => {
458
+ if (k)
384
459
  return;
385
- const { loaded: W, total: Z } = k.detail, C = Math.floor(
386
- Math.min(100, 100 * W / Z)
460
+ const { loaded: L, total: Z } = I.detail, W = Math.floor(
461
+ Math.min(100, 100 * L / Z)
387
462
  );
388
- E = C === 100, this.cliOutput.updateProgress(
463
+ k = W === 100, this.cliOutput.updateProgress(
389
464
  "Downloading WordPress",
390
- C
465
+ W
391
466
  );
392
- }), o = await Ve(this.args.wp), n = h.join(
467
+ }), o = await He(this.args.wp), i = p.join(
393
468
  Q,
394
469
  `prebuilt-wp-content-for-wp-${o.version}.zip`
395
- ), i = p.existsSync(n) ? ce(n) : await pe(
470
+ ), n = c.existsSync(i) ? me(i) : await pe(
396
471
  o.releaseUrl,
397
472
  `${o.version}.zip`,
398
473
  l
399
- ), g.debug(
474
+ ), y.debug(
400
475
  `Resolved WordPress release URL: ${o?.releaseUrl}`
401
476
  );
402
477
  }
403
478
  let u;
404
- this.args.skipSqliteSetup ? (g.debug("Skipping SQLite integration plugin setup..."), u = void 0) : (this.cliOutput.updateProgress("Preparing SQLite database"), u = await ut(l));
405
- const b = this.args.followSymlinks === !0, v = this.args.experimentalTrace === !0, a = this.args["mount-before-install"] || [], f = this.args.mount || [], c = F(t);
406
- await c.isConnected(), this.cliOutput.updateProgress("Booting WordPress");
407
- const S = await re(
479
+ this.args.skipSqliteSetup ? (y.debug("Skipping SQLite integration plugin setup..."), u = void 0) : (this.cliOutput.updateProgress("Preparing SQLite database"), u = await ht(l));
480
+ const v = this.args.followSymlinks === !0, P = this.args.experimentalTrace === !0, w = this.args["mount-before-install"] || [], a = this.args.mount || [], g = U(t);
481
+ await g.isConnected(), this.cliOutput.updateProgress("Booting WordPress");
482
+ const h = await oe(
408
483
  this.getEffectiveBlueprint()
409
484
  );
410
- return await c.useFileLockManager(r), await c.bootAndSetUpInitialWorker({
411
- phpVersion: S.phpVersion,
412
- wpVersion: S.wpVersion,
485
+ return await g.useFileLockManager(r), await g.bootAndSetUpInitialWorker({
486
+ phpVersion: h.phpVersion,
487
+ wpVersion: h.wpVersion,
413
488
  siteUrl: this.siteUrl,
414
- mountsBeforeWpInstall: a,
415
- mountsAfterWpInstall: f,
489
+ mountsBeforeWpInstall: w,
490
+ mountsAfterWpInstall: a,
416
491
  wordpressInstallMode: this.args.wordpressInstallMode || "download-and-install",
417
- wordPressZip: i && await i.arrayBuffer(),
492
+ wordPressZip: n && await n.arrayBuffer(),
418
493
  sqliteIntegrationPluginZip: await u?.arrayBuffer(),
419
494
  firstProcessId: 0,
420
495
  processIdSpaceLength: this.processIdSpaceLength,
421
- followSymlinks: b,
422
- trace: v,
496
+ followSymlinks: v,
497
+ trace: P,
423
498
  internalCookieStore: this.args.internalCookieStore,
424
499
  withIntl: this.args.intl,
425
500
  // We do not enable Xdebug by default for the initial worker
@@ -427,11 +502,12 @@ class pt {
427
502
  // until Playground has fully booted.
428
503
  // TODO: Consider supporting Xdebug for the initial worker via a dedicated flag.
429
504
  withXdebug: !1,
430
- nativeInternalDirPath: s
431
- }), n && !this.args["mount-before-install"] && !p.existsSync(n) && (this.cliOutput.updateProgress("Caching WordPress for next boot"), p.writeFileSync(
432
- n,
433
- await Ie(c, "/wordpress")
434
- )), c;
505
+ nativeInternalDirPath: s,
506
+ constants: O(this.args)
507
+ }), i && !this.args["mount-before-install"] && !c.existsSync(i) && (this.cliOutput.updateProgress("Caching WordPress for next boot"), c.writeFileSync(
508
+ i,
509
+ await $e(g, "/wordpress")
510
+ )), g;
435
511
  }
436
512
  async bootPlayground({
437
513
  worker: t,
@@ -439,15 +515,15 @@ class pt {
439
515
  firstProcessId: s,
440
516
  nativeInternalDirPath: o
441
517
  }) {
442
- const i = F(
518
+ const n = U(
443
519
  t.phpPort
444
520
  );
445
- await i.isConnected();
446
- const n = await re(
521
+ await n.isConnected();
522
+ const i = await oe(
447
523
  this.getEffectiveBlueprint()
448
524
  );
449
- return await i.useFileLockManager(r), await i.bootWorker({
450
- phpVersion: n.phpVersion,
525
+ return await n.useFileLockManager(r), await n.bootWorker({
526
+ phpVersion: i.phpVersion,
451
527
  siteUrl: this.siteUrl,
452
528
  mountsBeforeWpInstall: this.args["mount-before-install"] || [],
453
529
  mountsAfterWpInstall: this.args.mount || [],
@@ -460,38 +536,39 @@ class pt {
460
536
  internalCookieStore: this.args.internalCookieStore,
461
537
  withIntl: this.args.intl,
462
538
  withXdebug: !!this.args.xdebug,
463
- nativeInternalDirPath: o
464
- }), await i.isReady(), i;
539
+ nativeInternalDirPath: o,
540
+ constants: O(this.args)
541
+ }), await n.isReady(), n;
465
542
  }
466
543
  async compileInputBlueprint(t) {
467
- const r = this.getEffectiveBlueprint(), s = new He();
468
- let o = "", i = !1;
469
- return s.addEventListener("progress", (n) => {
470
- if (i)
544
+ const r = this.getEffectiveBlueprint(), s = new _e();
545
+ let o = "", n = !1;
546
+ return s.addEventListener("progress", (i) => {
547
+ if (n)
471
548
  return;
472
- i = n.detail.progress === 100;
473
- const l = Math.floor(n.detail.progress);
474
- o = n.detail.caption || o || "Running Blueprint", this.cliOutput.updateProgress(o.trim(), l);
475
- }), await Se(r, {
549
+ n = i.detail.progress === 100;
550
+ const l = Math.floor(i.detail.progress);
551
+ o = i.detail.caption || o || "Running Blueprint", this.cliOutput.updateProgress(o.trim(), l);
552
+ }), await xe(r, {
476
553
  progress: s,
477
554
  additionalSteps: t
478
555
  });
479
556
  }
480
557
  getEffectiveBlueprint() {
481
558
  const t = this.args.blueprint;
482
- return xe(t) ? t : {
559
+ return ke(t) ? t : {
483
560
  login: this.args.login,
484
561
  ...t || {},
485
562
  preferredVersions: {
486
- php: this.args.php ?? t?.preferredVersions?.php ?? U,
563
+ php: this.args.php ?? t?.preferredVersions?.php ?? F,
487
564
  wp: this.args.wp ?? t?.preferredVersions?.wp ?? "latest",
488
565
  ...t?.preferredVersions || {}
489
566
  }
490
567
  };
491
568
  }
492
569
  }
493
- async function ct(e, t = !0) {
494
- const s = `${h.basename(process.argv0)}${e}${process.pid}-`, o = await _e({
570
+ async function gt(e, t = !0) {
571
+ const s = `${p.basename(process.argv0)}${e}${process.pid}-`, o = await qe({
495
572
  prefix: s,
496
573
  /*
497
574
  * Allow recursive cleanup on process exit.
@@ -503,83 +580,83 @@ async function ct(e, t = !0) {
503
580
  */
504
581
  unsafeCleanup: !0
505
582
  });
506
- return t && qe(), o;
583
+ return t && Ye(), o;
507
584
  }
508
- async function ht(e, t, r) {
509
- const o = (await mt(
585
+ async function yt(e, t, r) {
586
+ const o = (await bt(
510
587
  e,
511
588
  t,
512
589
  r
513
590
  )).map(
514
- (i) => new Promise((n) => {
515
- p.rm(i, { recursive: !0 }, (l) => {
516
- l ? g.warn(
517
- `Failed to delete stale Playground temp dir: ${i}`,
591
+ (n) => new Promise((i) => {
592
+ c.rm(n, { recursive: !0 }, (l) => {
593
+ l ? y.warn(
594
+ `Failed to delete stale Playground temp dir: ${n}`,
518
595
  l
519
- ) : g.info(
520
- `Deleted stale Playground temp dir: ${i}`
521
- ), n();
596
+ ) : y.info(
597
+ `Deleted stale Playground temp dir: ${n}`
598
+ ), i();
522
599
  });
523
600
  })
524
601
  );
525
602
  await Promise.all(o);
526
603
  }
527
- async function mt(e, t, r) {
604
+ async function bt(e, t, r) {
528
605
  try {
529
- const s = p.readdirSync(r).map((i) => h.join(r, i)), o = [];
530
- for (const i of s)
531
- await ft(
606
+ const s = c.readdirSync(r).map((n) => p.join(r, n)), o = [];
607
+ for (const n of s)
608
+ await vt(
532
609
  e,
533
610
  t,
534
- i
535
- ) && o.push(i);
611
+ n
612
+ ) && o.push(n);
536
613
  return o;
537
614
  } catch (s) {
538
- return g.warn(`Failed to find stale Playground temp dirs: ${s}`), [];
615
+ return y.warn(`Failed to find stale Playground temp dirs: ${s}`), [];
539
616
  }
540
617
  }
541
- async function ft(e, t, r) {
542
- if (!p.lstatSync(r).isDirectory())
618
+ async function vt(e, t, r) {
619
+ if (!c.lstatSync(r).isDirectory())
543
620
  return !1;
544
- const o = h.basename(r);
621
+ const o = p.basename(r);
545
622
  if (!o.includes(e))
546
623
  return !1;
547
- const i = o.match(
624
+ const n = o.match(
548
625
  new RegExp(`^(.+)${e}(\\d+)-`)
549
626
  );
550
- if (!i)
627
+ if (!n)
551
628
  return !1;
552
- const n = {
553
- executableName: i[1],
554
- pid: i[2]
629
+ const i = {
630
+ executableName: n[1],
631
+ pid: n[2]
555
632
  };
556
- if (await wt(n.pid, n.executableName))
633
+ if (await Pt(i.pid, i.executableName))
557
634
  return !1;
558
635
  const l = Date.now() - t;
559
- return p.statSync(r).mtime.getTime() < l;
636
+ return c.statSync(r).mtime.getTime() < l;
560
637
  }
561
- async function wt(e, t) {
638
+ async function Pt(e, t) {
562
639
  const [r] = await new Promise(
563
640
  (s, o) => {
564
- Ye.list(
641
+ ze.list(
565
642
  {
566
643
  pid: e,
567
644
  name: t,
568
645
  // Remove path from executable name in the results.
569
646
  clean: !0
570
647
  },
571
- (i, n) => {
572
- i ? o(i) : s(n);
648
+ (n, i) => {
649
+ n ? o(n) : s(i);
573
650
  }
574
651
  );
575
652
  }
576
653
  );
577
654
  return !!r && r.pid === e && r.command === t;
578
655
  }
579
- function gt(e) {
656
+ function St(e) {
580
657
  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;
581
658
  }
582
- class yt {
659
+ class xt {
583
660
  constructor(t) {
584
661
  this.lastProgressLine = "", this.progressActive = !1, this.verbosity = t.verbosity, this.writeStream = t.writeStream || process.stdout;
585
662
  }
@@ -593,7 +670,7 @@ class yt {
593
670
  * This prevents progress spam in logs - users only see the final outcome.
594
671
  */
595
672
  get shouldRender() {
596
- return gt(this.writeStream);
673
+ return St(this.writeStream);
597
674
  }
598
675
  get isQuiet() {
599
676
  return this.verbosity === "quiet";
@@ -647,9 +724,9 @@ ${t}
647
724
  const s = [];
648
725
  if (t.intl && s.push("intl"), t.xdebug && s.push(this.yellow("xdebug")), s.length > 0 && r.push(`${this.dim("Extensions")} ${s.join(", ")}`), t.mounts.length > 0)
649
726
  for (const o of t.mounts) {
650
- const i = o.autoMounted ? ` ${this.dim("(auto-mount)")}` : "";
727
+ const n = o.autoMounted ? ` ${this.dim("(auto-mount)")}` : "";
651
728
  r.push(
652
- `${this.dim("Mount")} ${o.hostPath} ${this.dim("→")} ${o.vfsPath}${i}`
729
+ `${this.dim("Mount")} ${o.hostPath} ${this.dim("→")} ${o.vfsPath}${n}`
653
730
  );
654
731
  }
655
732
  t.blueprint && r.push(`${this.dim("Blueprint")} ${t.blueprint}`), this.writeStream.write(r.join(`
@@ -737,7 +814,7 @@ const he = {
737
814
  Normal: { name: "normal", severity: j.Info },
738
815
  Debug: { name: "debug", severity: j.Debug }
739
816
  };
740
- async function Jt(e) {
817
+ async function or(e) {
741
818
  try {
742
819
  const t = {
743
820
  "site-url": {
@@ -747,41 +824,62 @@ async function Jt(e) {
747
824
  php: {
748
825
  describe: "PHP version to use.",
749
826
  type: "string",
750
- default: U,
751
- choices: te
827
+ default: F,
828
+ choices: re
752
829
  },
753
830
  wp: {
754
831
  describe: "WordPress version to use.",
755
832
  type: "string",
756
833
  default: "latest"
757
834
  },
835
+ define: {
836
+ describe: 'Define PHP string constants (can be used multiple times). Format: NAME value. These constants are set via php.defineConstant() and only exist for the current request. Examples: --define API_KEY secret --define CON=ST "va=lu=e"',
837
+ type: "string",
838
+ nargs: 2,
839
+ array: !0,
840
+ coerce: ot
841
+ },
842
+ "define-bool": {
843
+ describe: 'Define PHP boolean constants (can be used multiple times). Format: NAME value. Value must be "true", "false", "1", or "0". Examples: --define-bool WP_DEBUG true --define-bool MY_FEATURE false',
844
+ type: "string",
845
+ nargs: 2,
846
+ array: !0,
847
+ coerce: st
848
+ },
849
+ "define-number": {
850
+ describe: "Define PHP number constants (can be used multiple times). Format: NAME value. Examples: --define-number LIMIT 100 --define-number RATE 45.67",
851
+ type: "string",
852
+ nargs: 2,
853
+ array: !0,
854
+ coerce: nt
855
+ },
758
856
  // @TODO: Support read-only mounts, e.g. via WORKERFS, a custom
759
857
  // ReadOnlyNODEFS, or by copying the files into MEMFS
760
858
  mount: {
761
859
  describe: "Mount a directory to the PHP runtime (can be used multiple times). Format: /host/path:/vfs/path",
762
860
  type: "array",
763
861
  string: !0,
764
- coerce: _
862
+ coerce: q
765
863
  },
766
864
  "mount-before-install": {
767
865
  describe: "Mount a directory to the PHP runtime before WordPress installation (can be used multiple times). Format: /host/path:/vfs/path",
768
866
  type: "array",
769
867
  string: !0,
770
- coerce: _
868
+ coerce: q
771
869
  },
772
870
  "mount-dir": {
773
871
  describe: 'Mount a directory to the PHP runtime (can be used multiple times). Format: "/host/path" "/vfs/path"',
774
872
  type: "array",
775
873
  nargs: 2,
776
874
  array: !0,
777
- coerce: se
875
+ coerce: ne
778
876
  },
779
877
  "mount-dir-before-install": {
780
878
  describe: 'Mount a directory before WordPress installation (can be used multiple times). Format: "/host/path" "/vfs/path"',
781
879
  type: "string",
782
880
  nargs: 2,
783
881
  array: !0,
784
- coerce: se
882
+ coerce: ne
785
883
  },
786
884
  login: {
787
885
  describe: "Should log the user in",
@@ -904,7 +1002,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
904
1002
  "experimental-multi-worker": {
905
1003
  describe: "Enable experimental multi-worker support which requires a /wordpress directory backed by a real filesystem. Pass a positive number to specify the number of workers to use. Otherwise, default to the number of CPUs minus 1.",
906
1004
  type: "number",
907
- coerce: (a) => a ?? Ce().length - 1
1005
+ coerce: (a) => a ?? Me().length - 1
908
1006
  },
909
1007
  "experimental-devtools": {
910
1008
  describe: "Enable experimental browser development tools.",
@@ -919,8 +1017,8 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
919
1017
  php: {
920
1018
  describe: "PHP version to use.",
921
1019
  type: "string",
922
- default: U,
923
- choices: te
1020
+ default: F,
1021
+ choices: re
924
1022
  },
925
1023
  wp: {
926
1024
  describe: "WordPress version to use.",
@@ -966,7 +1064,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
966
1064
  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.",
967
1065
  type: "array",
968
1066
  string: !0,
969
- coerce: _
1067
+ coerce: q
970
1068
  },
971
1069
  reset: {
972
1070
  describe: "Deletes the stored site directory and starts a new site from scratch.",
@@ -977,14 +1075,18 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
977
1075
  describe: "Disable automatic project type detection. Use --mount to manually specify mounts instead.",
978
1076
  type: "boolean",
979
1077
  default: !1
980
- }
1078
+ },
1079
+ // Define constants
1080
+ define: t.define,
1081
+ "define-bool": t["define-bool"],
1082
+ "define-number": t["define-number"]
981
1083
  }, o = {
982
1084
  outfile: {
983
1085
  describe: "When building, write to this output file.",
984
1086
  type: "string",
985
1087
  default: "wordpress.zip"
986
1088
  }
987
- }, i = Re(e).usage("Usage: wp-playground <command> [options]").command(
1089
+ }, n = Re(e).usage("Usage: wp-playground <command> [options]").command(
988
1090
  "start",
989
1091
  "Start a local WordPress server with automatic project detection (recommended)",
990
1092
  (a) => a.usage(
@@ -1022,13 +1124,13 @@ Examples:
1022
1124
  ).demandCommand(1, "Please specify a command").strictCommands().conflicts(
1023
1125
  "experimental-unsafe-ide-integration",
1024
1126
  "experimental-devtools"
1025
- ).showHelpOnFail(!1).fail((a, f, c) => {
1026
- if (f)
1027
- throw f;
1028
- a && a.includes("Please specify a command") && (c.showHelp(), console.error(`
1127
+ ).showHelpOnFail(!1).fail((a, g, h) => {
1128
+ if (g)
1129
+ throw g;
1130
+ a && a.includes("Please specify a command") && (h.showHelp(), console.error(`
1029
1131
  ` + a), process.exit(1)), console.error(a), process.exit(1);
1030
1132
  }).strictOptions().check(async (a) => {
1031
- if (a["skip-wordpress-install"] === !0 && (a["wordpress-install-mode"] = "do-not-attempt-installing", a.wordpressInstallMode = "do-not-attempt-installing"), a.wp !== void 0 && typeof a.wp == "string" && !nt(a.wp))
1133
+ if (a["skip-wordpress-install"] === !0 && (a["wordpress-install-mode"] = "do-not-attempt-installing", a.wordpressInstallMode = "do-not-attempt-installing"), a.wp !== void 0 && typeof a.wp == "string" && !ct(a.wp))
1032
1134
  try {
1033
1135
  new URL(a.wp);
1034
1136
  } catch {
@@ -1036,25 +1138,25 @@ Examples:
1036
1138
  'Unrecognized WordPress version. Please use "latest", a URL, or a numeric version such as "6.2", "6.0.1", "6.2-beta1", or "6.2-RC1"'
1037
1139
  );
1038
1140
  }
1039
- const f = a["site-url"];
1040
- if (typeof f == "string" && f.trim() !== "")
1141
+ const g = a["site-url"];
1142
+ if (typeof g == "string" && g.trim() !== "")
1041
1143
  try {
1042
- new URL(f);
1144
+ new URL(g);
1043
1145
  } catch {
1044
1146
  throw new Error(
1045
- `Invalid site-url "${f}". Please provide a valid URL (e.g., http://localhost:8080 or https://example.com)`
1147
+ `Invalid site-url "${g}". Please provide a valid URL (e.g., http://localhost:8080 or https://example.com)`
1046
1148
  );
1047
1149
  }
1048
1150
  if (a["auto-mount"]) {
1049
- let c = !1;
1151
+ let h = !1;
1050
1152
  try {
1051
- c = p.statSync(
1153
+ h = c.statSync(
1052
1154
  a["auto-mount"]
1053
1155
  ).isDirectory();
1054
1156
  } catch {
1055
- c = !1;
1157
+ h = !1;
1056
1158
  }
1057
- if (!c)
1159
+ if (!h)
1058
1160
  throw new Error(
1059
1161
  `The specified --auto-mount path is not a directory: '${a["auto-mount"]}'.`
1060
1162
  );
@@ -1085,44 +1187,47 @@ Examples:
1085
1187
  );
1086
1188
  } else
1087
1189
  a["wordpress-install-mode"] === "do-not-attempt-installing" ? a.mode = "apply-to-existing-site" : a.mode = "create-new-site";
1088
- const c = a.allow || [];
1089
- a.followSymlinks === !0 && c.push("follow-symlinks"), a["blueprint-may-read-adjacent-files"] === !0 && c.push("read-local-fs"), a.allow = c;
1190
+ const h = a.allow || [];
1191
+ a.followSymlinks === !0 && h.push("follow-symlinks"), a["blueprint-may-read-adjacent-files"] === !0 && h.push("read-local-fs"), a.allow = h;
1090
1192
  } else if (a.mode !== void 0)
1091
1193
  throw new Error(
1092
1194
  "The --mode option requires the --experimentalBlueprintsV2Runner flag."
1093
1195
  );
1094
1196
  return !0;
1095
1197
  });
1096
- i.wrap(i.terminalWidth());
1097
- const n = await i.argv, l = n._[0];
1198
+ n.wrap(n.terminalWidth());
1199
+ const i = await n.argv, l = i._[0];
1098
1200
  ["start", "run-blueprint", "server", "build-snapshot"].includes(
1099
1201
  l
1100
- ) || (i.showHelp(), process.exit(1));
1101
- const u = {
1102
- ...n,
1202
+ ) || (n.showHelp(), process.exit(1));
1203
+ const u = i.define || {};
1204
+ !("WP_DEBUG" in u) && !("WP_DEBUG_LOG" in u) && !("WP_DEBUG_DISPLAY" in u) && (u.WP_DEBUG = "true", u.WP_DEBUG_LOG = "true", u.WP_DEBUG_DISPLAY = "true");
1205
+ const v = {
1206
+ ...i,
1207
+ define: u,
1103
1208
  command: l,
1104
1209
  mount: [
1105
- ...n.mount || [],
1106
- ...n["mount-dir"] || []
1210
+ ...i.mount || [],
1211
+ ...i["mount-dir"] || []
1107
1212
  ],
1108
1213
  "mount-before-install": [
1109
- ...n["mount-before-install"] || [],
1110
- ...n["mount-dir-before-install"] || []
1214
+ ...i["mount-before-install"] || [],
1215
+ ...i["mount-dir-before-install"] || []
1111
1216
  ]
1112
- }, b = await St(u);
1113
- b === void 0 && process.exit(0);
1114
- const v = /* @__PURE__ */ (() => {
1217
+ }, P = await Et(v);
1218
+ P === void 0 && process.exit(0);
1219
+ const w = /* @__PURE__ */ (() => {
1115
1220
  let a;
1116
1221
  return async () => {
1117
- a !== void 0 && (a = b[Symbol.asyncDispose]()), await a, process.exit(0);
1222
+ a !== void 0 && (a = P[Symbol.asyncDispose]()), await a, process.exit(0);
1118
1223
  };
1119
1224
  })();
1120
- process.on("SIGINT", v), process.on("SIGTERM", v);
1225
+ process.on("SIGINT", w), process.on("SIGTERM", w);
1121
1226
  } catch (t) {
1122
1227
  if (console.error(t), !(t instanceof Error))
1123
1228
  throw t;
1124
1229
  if (process.argv.includes("--debug"))
1125
- ye(t);
1230
+ be(t);
1126
1231
  else {
1127
1232
  const s = [];
1128
1233
  let o = t;
@@ -1136,27 +1241,27 @@ Examples:
1136
1241
  process.exit(1);
1137
1242
  }
1138
1243
  }
1139
- function ne(e, t) {
1244
+ function ae(e, t) {
1140
1245
  return e.find(
1141
1246
  (r) => r.vfsPath.replace(/\/$/, "") === t.replace(/\/$/, "")
1142
1247
  );
1143
1248
  }
1144
- const bt = Symbol("playground-cli-testing"), T = (e) => process.stdout.isTTY ? "\x1B[1m" + e + "\x1B[0m" : e, vt = (e) => process.stdout.isTTY ? "\x1B[31m" + e + "\x1B[0m" : e, Pt = (e) => process.stdout.isTTY ? `\x1B[2m${e}\x1B[0m` : e, q = (e) => process.stdout.isTTY ? `\x1B[3m${e}\x1B[0m` : e, ae = (e) => process.stdout.isTTY ? `\x1B[33m${e}\x1B[0m` : e;
1145
- async function St(e) {
1249
+ const kt = Symbol("playground-cli-testing"), T = (e) => process.stdout.isTTY ? "\x1B[1m" + e + "\x1B[0m" : e, It = (e) => process.stdout.isTTY ? "\x1B[31m" + e + "\x1B[0m" : e, $t = (e) => process.stdout.isTTY ? `\x1B[2m${e}\x1B[0m` : e, Y = (e) => process.stdout.isTTY ? `\x1B[3m${e}\x1B[0m` : e, le = (e) => process.stdout.isTTY ? `\x1B[33m${e}\x1B[0m` : e;
1250
+ async function Et(e) {
1146
1251
  let t, r;
1147
1252
  const s = /* @__PURE__ */ new Map();
1148
- if (e.command === "start" && (e = xt(e)), e.autoMount !== void 0 && (e.autoMount === "" && (e = { ...e, autoMount: process.cwd() }), e = de(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) {
1149
- const a = Object.values(he).find(
1150
- (f) => f.name === e.verbosity
1253
+ if (e.command === "start" && (e = Tt(e)), e.autoMount !== void 0 && (e.autoMount === "" && (e = { ...e, autoMount: process.cwd() }), e = ce(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) {
1254
+ const w = Object.values(he).find(
1255
+ (a) => a.name === e.verbosity
1151
1256
  ).severity;
1152
- g.setSeverityFilterLevel(a);
1257
+ y.setSeverityFilterLevel(w);
1153
1258
  }
1154
1259
  e.intl || (e.intl = !0);
1155
- const o = new yt({
1260
+ const o = new xt({
1156
1261
  verbosity: e.verbosity || "normal"
1157
1262
  });
1158
1263
  e.command === "server" && (o.printBanner(), o.printConfig({
1159
- phpVersion: e.php || U,
1264
+ phpVersion: e.php || F,
1160
1265
  wpVersion: e.wp || "latest",
1161
1266
  port: e.port || 9400,
1162
1267
  xdebug: !!e.xdebug,
@@ -1167,42 +1272,42 @@ async function St(e) {
1167
1272
  ],
1168
1273
  blueprint: typeof e.blueprint == "string" ? e.blueprint : void 0
1169
1274
  }));
1170
- const i = e.command === "server" ? e.port ?? 9400 : 0, n = O.platform() === "win32" ? (
1275
+ const n = e.command === "server" ? e.port ?? 9400 : 0, i = N.platform() === "win32" ? (
1171
1276
  // @TODO: Enable fs-ext here when it works with Windows.
1172
1277
  void 0
1173
- ) : await import("fs-ext").then((a) => a.flockSync).catch(() => {
1174
- g.debug(
1278
+ ) : await import("fs-ext").then((w) => w.flockSync).catch(() => {
1279
+ y.debug(
1175
1280
  "The fs-ext package is not installed. Internal file locking will not be integrated with host OS file locking."
1176
1281
  );
1177
- }), l = new Le(n);
1178
- let u = !1, b = !0;
1179
- const v = await rt({
1180
- port: i,
1181
- onBind: async (a, f) => {
1182
- const c = "127.0.0.1", S = `http://${c}:${f}`, E = e["site-url"] || S, k = e.command === "server" ? e.experimentalMultiWorker ?? 1 : 1, W = e.command === "server" ? (
1282
+ }), l = new Le(i);
1283
+ let u = !1, v = !0;
1284
+ const P = await at({
1285
+ port: n,
1286
+ onBind: async (w, a) => {
1287
+ const g = "127.0.0.1", h = `http://${g}:${a}`, k = e["site-url"] || h, I = e.command === "server" ? e.experimentalMultiWorker ?? 1 : 1, L = e.command === "server" ? (
1183
1288
  // Account for the initial worker which is discarded by the server after setup.
1184
- k + 1
1185
- ) : k, C = 2 ** 31 - 1, L = Math.floor(
1186
- C / W
1187
- ), G = "-playground-cli-site-", I = await ct(G);
1188
- g.debug(`Native temp dir for VFS root: ${I.path}`);
1189
- const M = "WP Playground CLI - Listen for Xdebug", J = ".playground-xdebug-root", K = h.join(process.cwd(), J);
1190
- if (await ze(K), e.xdebug && e.experimentalUnsafeIdeIntegration) {
1289
+ I + 1
1290
+ ) : I, W = 2 ** 31 - 1, C = Math.floor(
1291
+ W / L
1292
+ ), J = "-playground-cli-site-", $ = await gt(J);
1293
+ y.debug(`Native temp dir for VFS root: ${$.path}`);
1294
+ const M = "WP Playground CLI - Listen for Xdebug", K = ".playground-xdebug-root", ee = p.join(process.cwd(), K);
1295
+ if (await Ge(ee), e.xdebug && e.experimentalUnsafeIdeIntegration) {
1191
1296
  await Qe(
1192
- I.path,
1193
- K,
1297
+ $.path,
1298
+ ee,
1194
1299
  process.platform
1195
1300
  );
1196
1301
  const d = {
1197
- hostPath: h.join(".", h.sep, J),
1302
+ hostPath: p.join(".", p.sep, K),
1198
1303
  vfsPath: "/"
1199
1304
  };
1200
1305
  try {
1201
1306
  await Xe(M, process.cwd());
1202
- const w = typeof e.xdebug == "object" ? e.xdebug : void 0, P = await Ze({
1307
+ const f = typeof e.xdebug == "object" ? e.xdebug : void 0, S = await Ze({
1203
1308
  name: M,
1204
- host: c,
1205
- port: f,
1309
+ host: g,
1310
+ port: a,
1206
1311
  ides: e.experimentalUnsafeIdeIntegration,
1207
1312
  cwd: process.cwd(),
1208
1313
  mounts: [
@@ -1210,19 +1315,19 @@ async function St(e) {
1210
1315
  ...e["mount-before-install"] || [],
1211
1316
  ...e.mount || []
1212
1317
  ],
1213
- ideKey: w?.ideKey
1214
- }), m = e.experimentalUnsafeIdeIntegration, y = m.includes("vscode"), x = m.includes("phpstorm"), D = Object.values(P);
1215
- console.log(""), D.length > 0 ? (console.log(T("Xdebug configured successfully")), console.log(
1216
- ae("Updated IDE config: ") + D.join(" ")
1318
+ ideKey: f?.ideKey
1319
+ }), m = e.experimentalUnsafeIdeIntegration, b = m.includes("vscode"), x = m.includes("phpstorm"), R = Object.values(S);
1320
+ console.log(""), R.length > 0 ? (console.log(T("Xdebug configured successfully")), console.log(
1321
+ le("Updated IDE config: ") + R.join(" ")
1217
1322
  ), console.log(
1218
- ae("Playground source root: ") + ".playground-xdebug-root" + q(
1219
- Pt(
1323
+ le("Playground source root: ") + ".playground-xdebug-root" + Y(
1324
+ $t(
1220
1325
  " – you can set breakpoints and preview Playground's VFS structure in there."
1221
1326
  )
1222
1327
  )
1223
1328
  )) : (console.log(T("Xdebug configuration failed.")), console.log(
1224
1329
  "No IDE-specific project settings directory was found in the current working directory."
1225
- )), console.log(""), y && P.vscode && (console.log(T("VS Code / Cursor instructions:")), console.log(
1330
+ )), console.log(""), b && S.vscode && (console.log(T("VS Code / Cursor instructions:")), console.log(
1226
1331
  " 1. Ensure you have installed an IDE extension for PHP Debugging"
1227
1332
  ), console.log(
1228
1333
  ` (The ${T("PHP Debug")} extension by ${T(
@@ -1231,15 +1336,15 @@ async function St(e) {
1231
1336
  ), console.log(
1232
1337
  " 2. Open the Run and Debug panel on the left sidebar"
1233
1338
  ), console.log(
1234
- ` 3. Select "${q(
1339
+ ` 3. Select "${Y(
1235
1340
  M
1236
1341
  )}" from the dropdown`
1237
1342
  ), console.log(' 3. Click "start debugging"'), console.log(
1238
1343
  " 5. Set a breakpoint. For example, in .playground-xdebug-root/wordpress/index.php"
1239
1344
  ), console.log(
1240
1345
  " 6. Visit Playground in your browser to hit the breakpoint"
1241
- ), x && console.log("")), x && P.phpstorm && (console.log(T("PhpStorm instructions:")), console.log(
1242
- ` 1. Choose "${q(
1346
+ ), x && console.log("")), x && S.phpstorm && (console.log(T("PhpStorm instructions:")), console.log(
1347
+ ` 1. Choose "${Y(
1243
1348
  M
1244
1349
  )}" debug configuration in the toolbar`
1245
1350
  ), console.log(" 2. Click the debug button (bug icon)`"), console.log(
@@ -1247,21 +1352,21 @@ async function St(e) {
1247
1352
  ), console.log(
1248
1353
  " 4. Visit Playground in your browser to hit the breakpoint"
1249
1354
  )), console.log("");
1250
- } catch (w) {
1355
+ } catch (f) {
1251
1356
  throw new Error("Could not configure Xdebug", {
1252
- cause: w
1357
+ cause: f
1253
1358
  });
1254
1359
  }
1255
1360
  }
1256
- const me = h.dirname(I.path), fe = 2 * 24 * 60 * 60 * 1e3;
1257
- ht(
1258
- G,
1259
- fe,
1260
- me
1361
+ const fe = p.dirname($.path), we = 2 * 24 * 60 * 60 * 1e3;
1362
+ yt(
1363
+ J,
1364
+ we,
1365
+ fe
1261
1366
  );
1262
- const H = h.join(I.path, "internal");
1263
- z(H);
1264
- const we = [
1367
+ const _ = p.join($.path, "internal");
1368
+ G(_);
1369
+ const ge = [
1265
1370
  "wordpress",
1266
1371
  // Note: These dirs are from Emscripten's "default dirs" list:
1267
1372
  // https://github.com/emscripten-core/emscripten/blob/f431ec220e472e1f8d3db6b52fe23fb377facf30/src/lib/libfs.js#L1400-L1402
@@ -1272,14 +1377,14 @@ async function St(e) {
1272
1377
  "tmp",
1273
1378
  "home"
1274
1379
  ];
1275
- for (const d of we) {
1276
- const w = (m) => m.vfsPath === `/${d}`;
1277
- if (!(e["mount-before-install"]?.some(w) || e.mount?.some(w))) {
1278
- const m = h.join(
1279
- I.path,
1380
+ for (const d of ge) {
1381
+ const f = (m) => m.vfsPath === `/${d}`;
1382
+ if (!(e["mount-before-install"]?.some(f) || e.mount?.some(f))) {
1383
+ const m = p.join(
1384
+ $.path,
1280
1385
  d
1281
1386
  );
1282
- z(m), e["mount-before-install"] === void 0 && (e["mount-before-install"] = []), e["mount-before-install"].unshift({
1387
+ G(m), e["mount-before-install"] === void 0 && (e["mount-before-install"] = []), e["mount-before-install"].unshift({
1283
1388
  vfsPath: `/${d}`,
1284
1389
  hostPath: m
1285
1390
  });
@@ -1287,144 +1392,144 @@ async function St(e) {
1287
1392
  }
1288
1393
  if (e["mount-before-install"])
1289
1394
  for (const d of e["mount-before-install"])
1290
- g.debug(
1395
+ y.debug(
1291
1396
  `Mount before WP install: ${d.vfsPath} -> ${d.hostPath}`
1292
1397
  );
1293
1398
  if (e.mount)
1294
1399
  for (const d of e.mount)
1295
- g.debug(
1400
+ y.debug(
1296
1401
  `Mount after WP install: ${d.vfsPath} -> ${d.hostPath}`
1297
1402
  );
1298
- let $;
1299
- e["experimental-blueprints-v2-runner"] ? $ = new lt(e, {
1300
- siteUrl: E,
1301
- processIdSpaceLength: L,
1403
+ let E;
1404
+ e["experimental-blueprints-v2-runner"] ? E = new mt(e, {
1405
+ siteUrl: k,
1406
+ processIdSpaceLength: C,
1302
1407
  cliOutput: o
1303
- }) : ($ = new pt(e, {
1304
- siteUrl: E,
1305
- processIdSpaceLength: L,
1408
+ }) : (E = new wt(e, {
1409
+ siteUrl: k,
1410
+ processIdSpaceLength: C,
1306
1411
  cliOutput: o
1307
- }), typeof e.blueprint == "string" && (e.blueprint = await at({
1412
+ }), typeof e.blueprint == "string" && (e.blueprint = await pt({
1308
1413
  sourceString: e.blueprint,
1309
1414
  blueprintMayReadAdjacentFiles: e["blueprint-may-read-adjacent-files"] === !0
1310
1415
  })));
1311
- let V = !1;
1312
- const R = async function() {
1313
- V || (V = !0, await Promise.all(
1416
+ let H = !1;
1417
+ const D = async function() {
1418
+ H || (H = !0, await Promise.all(
1314
1419
  [...s].map(
1315
- async ([w, P]) => {
1316
- await P.dispose(), await w.terminate();
1420
+ async ([f, S]) => {
1421
+ await S.dispose(), await f.terminate();
1317
1422
  }
1318
1423
  )
1319
- ), a && await new Promise((w) => a.close(w)), await I.cleanup());
1320
- }, ge = kt(
1321
- W,
1322
- $.getWorkerType(),
1323
- ({ exitCode: d, workerIndex: w }) => {
1324
- V || d === 0 && g.error(
1325
- `Worker ${w} exited with code ${d}
1424
+ ), w && await new Promise((f) => w.close(f)), await $.cleanup());
1425
+ }, ye = Bt(
1426
+ L,
1427
+ E.getWorkerType(),
1428
+ ({ exitCode: d, workerIndex: f }) => {
1429
+ H || d === 0 && y.error(
1430
+ `Worker ${f} exited with code ${d}
1326
1431
  `
1327
1432
  );
1328
1433
  }
1329
1434
  );
1330
1435
  o.startProgress("Starting...");
1331
1436
  try {
1332
- const d = await ge, w = await le(l);
1437
+ const d = await ye, f = await ue(l);
1333
1438
  {
1334
- const m = d.shift(), y = await $.bootAndSetUpInitialPlayground(
1439
+ const m = d.shift(), b = await E.bootAndSetUpInitialPlayground(
1335
1440
  m.phpPort,
1336
- w,
1337
- H
1441
+ f,
1442
+ _
1338
1443
  );
1339
1444
  if (s.set(
1340
1445
  m.worker,
1341
- y
1342
- ), await y.isReady(), u = !0, t = new it(y), !e["experimental-blueprints-v2-runner"]) {
1343
- const x = await $.compileInputBlueprint(
1446
+ b
1447
+ ), await b.isReady(), u = !0, t = new dt(b), !e["experimental-blueprints-v2-runner"]) {
1448
+ const x = await E.compileInputBlueprint(
1344
1449
  e["additional-blueprint-steps"] || []
1345
1450
  );
1346
- x && await ke(
1451
+ x && await Ie(
1347
1452
  x,
1348
- y
1453
+ b
1349
1454
  );
1350
1455
  }
1351
1456
  if (e.command === "build-snapshot") {
1352
- await Tt(r, e.outfile), o.printStatus(`Exported to ${e.outfile}`), await R();
1457
+ await Wt(r, e.outfile), o.printStatus(`Exported to ${e.outfile}`), await D();
1353
1458
  return;
1354
1459
  } else if (e.command === "run-blueprint") {
1355
- o.finishProgress("Done"), await R();
1460
+ o.finishProgress("Done"), await D();
1356
1461
  return;
1357
1462
  }
1358
- await t.removeWorker(y), await y.dispose(), await m.worker.terminate(), s.delete(m.worker);
1463
+ await t.removeWorker(b), await b.dispose(), await m.worker.terminate(), s.delete(m.worker);
1359
1464
  }
1360
- const P = L;
1465
+ const S = C;
1361
1466
  return [r] = await Promise.all(
1362
- d.map(async (m, y) => {
1363
- const x = P + y * L, D = await le(l), N = await $.bootPlayground({
1467
+ d.map(async (m, b) => {
1468
+ const x = S + b * C, R = await ue(l), V = await E.bootPlayground({
1364
1469
  worker: m,
1365
- fileLockManagerPort: D,
1470
+ fileLockManagerPort: R,
1366
1471
  firstProcessId: x,
1367
- nativeInternalDirPath: H
1472
+ nativeInternalDirPath: _
1368
1473
  });
1369
1474
  return s.set(
1370
1475
  m.worker,
1371
- N
1372
- ), t.addWorker(N), N;
1476
+ V
1477
+ ), t.addWorker(V), V;
1373
1478
  })
1374
- ), o.finishProgress(), o.printReady(S, k), e.xdebug && e.experimentalDevtools && (await Ne({
1479
+ ), o.finishProgress(), o.printReady(h, I), e.xdebug && e.experimentalDevtools && (await Ve({
1375
1480
  phpInstance: r,
1376
1481
  phpRoot: "/wordpress"
1377
1482
  })).start(), {
1378
1483
  playground: r,
1379
- server: a,
1380
- serverUrl: S,
1381
- [Symbol.asyncDispose]: R,
1382
- [bt]: {
1383
- workerThreadCount: k,
1384
- getWorkerNumberFromProcessId: (m) => Math.floor(m / L)
1484
+ server: w,
1485
+ serverUrl: h,
1486
+ [Symbol.asyncDispose]: D,
1487
+ [kt]: {
1488
+ workerThreadCount: I,
1489
+ getWorkerNumberFromProcessId: (m) => Math.floor(m / C)
1385
1490
  }
1386
1491
  };
1387
1492
  } catch (d) {
1388
1493
  if (e.verbosity !== "debug")
1389
1494
  throw d;
1390
- let w = "";
1391
- throw await r?.fileExists(ee) && (w = await r.readFileAsText(ee)), await R(), new Error(w, { cause: d });
1495
+ let f = "";
1496
+ throw await r?.fileExists(te) && (f = await r.readFileAsText(te)), await D(), new Error(f, { cause: d });
1392
1497
  }
1393
1498
  },
1394
- async handleRequest(a) {
1499
+ async handleRequest(w) {
1395
1500
  if (!u)
1396
- return Y.forHttpCode(
1501
+ return z.forHttpCode(
1397
1502
  502,
1398
1503
  "WordPress is not ready yet"
1399
1504
  );
1400
- if (b) {
1401
- b = !1;
1402
- const f = {
1505
+ if (v) {
1506
+ v = !1;
1507
+ const a = {
1403
1508
  "Content-Type": ["text/plain"],
1404
1509
  "Content-Length": ["0"],
1405
- Location: [a.url]
1510
+ Location: [w.url]
1406
1511
  };
1407
- return a.headers?.cookie?.includes(
1512
+ return w.headers?.cookie?.includes(
1408
1513
  "playground_auto_login_already_happened"
1409
- ) && (f["Set-Cookie"] = [
1514
+ ) && (a["Set-Cookie"] = [
1410
1515
  "playground_auto_login_already_happened=1; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=/"
1411
- ]), new Y(302, f, new Uint8Array());
1516
+ ]), new z(302, a, new Uint8Array());
1412
1517
  }
1413
- return await t.handleRequest(a);
1518
+ return await t.handleRequest(w);
1414
1519
  }
1415
1520
  });
1416
- return v && e.command === "start" && !e.skipBrowser && $t(v.serverUrl), v;
1521
+ return P && e.command === "start" && !e.skipBrowser && Lt(P.serverUrl), P;
1417
1522
  }
1418
- function xt(e) {
1523
+ function Tt(e) {
1419
1524
  let t = { ...e, command: "server" };
1420
- e.noAutoMount || (t.autoMount = h.resolve(process.cwd(), t.path ?? ""), t = de(t), delete t.autoMount);
1421
- const r = ne(
1525
+ e.noAutoMount || (t.autoMount = p.resolve(process.cwd(), t.path ?? ""), t = ce(t), delete t.autoMount);
1526
+ const r = ae(
1422
1527
  t["mount-before-install"] || [],
1423
1528
  "/wordpress"
1424
- ) || ne(t.mount || [], "/wordpress");
1529
+ ) || ae(t.mount || [], "/wordpress");
1425
1530
  if (r)
1426
1531
  console.log("Site files stored at:", r?.hostPath), e.reset && (console.log(""), console.log(
1427
- vt(
1532
+ It(
1428
1533
  "This site is not managed by Playground CLI and cannot be reset."
1429
1534
  )
1430
1535
  ), console.log(
@@ -1433,15 +1538,15 @@ function xt(e) {
1433
1538
  "You may still remove the site's directory manually if you wish."
1434
1539
  ), process.exit(1));
1435
1540
  else {
1436
- const s = t.autoMount || process.cwd(), o = Ge("sha256").update(s).digest("hex"), i = O.homedir(), n = h.join(
1437
- i,
1541
+ const s = t.autoMount || process.cwd(), o = Je("sha256").update(s).digest("hex"), n = N.homedir(), i = p.join(
1542
+ n,
1438
1543
  ".wordpress-playground/sites",
1439
1544
  o
1440
1545
  );
1441
- console.log("Site files stored at:", n), X(n) && e.reset && (console.log("Resetting site..."), $e(n, { recursive: !0 })), z(n, { recursive: !0 }), t["mount-before-install"] = [
1546
+ console.log("Site files stored at:", i), X(i) && e.reset && (console.log("Resetting site..."), Ee(i, { recursive: !0 })), G(i, { recursive: !0 }), t["mount-before-install"] = [
1442
1547
  ...t["mount-before-install"] || [],
1443
- { vfsPath: "/wordpress", hostPath: n }
1444
- ], t.wordpressInstallMode = Te(n).length === 0 ? (
1548
+ { vfsPath: "/wordpress", hostPath: i }
1549
+ ], t.wordpressInstallMode = Te(i).length === 0 ? (
1445
1550
  // Only download WordPress on the first run when the site directory is still
1446
1551
  // empty.
1447
1552
  "download-and-install"
@@ -1452,45 +1557,45 @@ function xt(e) {
1452
1557
  }
1453
1558
  return t;
1454
1559
  }
1455
- async function kt(e, t, r) {
1560
+ async function Bt(e, t, r) {
1456
1561
  const s = [];
1457
1562
  for (let o = 0; o < e; o++) {
1458
- const n = It(t, { onExit: (l) => {
1563
+ const i = Ct(t, { onExit: (l) => {
1459
1564
  r({
1460
1565
  exitCode: l,
1461
1566
  workerIndex: o
1462
1567
  });
1463
1568
  } });
1464
- s.push(n);
1569
+ s.push(i);
1465
1570
  }
1466
1571
  return Promise.all(s);
1467
1572
  }
1468
- function It(e, { onExit: t } = {}) {
1573
+ function Ct(e, { onExit: t } = {}) {
1469
1574
  let r;
1470
- return e === "v1" ? r = new oe(new URL("./worker-thread-v1.js", import.meta.url)) : r = new oe(new URL("./worker-thread-v2.js", import.meta.url)), new Promise((s, o) => {
1471
- r.once("message", function(n) {
1472
- n.command === "worker-script-initialized" && s({ worker: r, phpPort: n.phpPort });
1473
- }), r.once("error", function(n) {
1474
- console.error(n);
1575
+ return e === "v1" ? r = new se(new URL("./worker-thread-v1.js", import.meta.url)) : r = new se(new URL("./worker-thread-v2.js", import.meta.url)), new Promise((s, o) => {
1576
+ r.once("message", function(i) {
1577
+ i.command === "worker-script-initialized" && s({ worker: r, phpPort: i.phpPort });
1578
+ }), r.once("error", function(i) {
1579
+ console.error(i);
1475
1580
  const l = new Error(
1476
- `Worker failed to load worker. ${n.message ? `Original error: ${n.message}` : ""}`
1581
+ `Worker failed to load worker. ${i.message ? `Original error: ${i.message}` : ""}`
1477
1582
  );
1478
1583
  o(l);
1479
1584
  });
1480
- let i = !1;
1585
+ let n = !1;
1481
1586
  r.once("spawn", () => {
1482
- i = !0;
1483
- }), r.once("exit", (n) => {
1484
- i || o(new Error(`Worker exited before spawning: ${n}`)), t?.(n);
1587
+ n = !0;
1588
+ }), r.once("exit", (i) => {
1589
+ n || o(new Error(`Worker exited before spawning: ${i}`)), t?.(i);
1485
1590
  });
1486
1591
  });
1487
1592
  }
1488
- async function le(e) {
1593
+ async function ue(e) {
1489
1594
  const { port1: t, port2: r } = new Be();
1490
- return await Me() ? be(e, null, t) : await ve(e, t), r;
1595
+ return await De() ? ve(e, null, t) : await Pe(e, t), r;
1491
1596
  }
1492
- function $t(e) {
1493
- const t = O.platform();
1597
+ function Lt(e) {
1598
+ const t = N.platform();
1494
1599
  let r;
1495
1600
  switch (t) {
1496
1601
  case "darwin":
@@ -1504,10 +1609,10 @@ function $t(e) {
1504
1609
  break;
1505
1610
  }
1506
1611
  je(r, (s) => {
1507
- s && g.debug(`Could not open browser: ${s.message}`);
1612
+ s && y.debug(`Could not open browser: ${s.message}`);
1508
1613
  });
1509
1614
  }
1510
- async function Tt(e, t) {
1615
+ async function Wt(e, t) {
1511
1616
  await e.run({
1512
1617
  code: `<?php
1513
1618
  $zip = new ZipArchive();
@@ -1529,15 +1634,16 @@ async function Tt(e, t) {
1529
1634
  `
1530
1635
  });
1531
1636
  const r = await e.readFileAsBuffer("/tmp/build.zip");
1532
- p.writeFileSync(t, r);
1637
+ c.writeFileSync(t, r);
1533
1638
  }
1534
1639
  export {
1535
1640
  he as L,
1536
- gt as a,
1537
- bt as i,
1538
- Gt as m,
1539
- Jt as p,
1540
- St as r,
1541
- It as s
1641
+ rr as a,
1642
+ St as b,
1643
+ kt as i,
1644
+ O as m,
1645
+ or as p,
1646
+ Et as r,
1647
+ Ct as s
1542
1648
  };
1543
- //# sourceMappingURL=run-cli-NcKUE5gJ.js.map
1649
+ //# sourceMappingURL=run-cli-DOpShCrT.js.map