@wp-playground/cli 3.0.44 → 3.0.46

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,14 +1,14 @@
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";
1
+ import { logger as y, LogSeverity as j, errorLogPath as re } from "@php-wasm/logger";
2
+ import { PHPResponse as z, consumeAPI as U, SupportedPHPVersions as oe, printDebugDetails as ve, exposeAPI as Pe, exposeSyncAPI as Se } from "@php-wasm/universal";
3
+ import { resolveRemoteBlueprint as xe, resolveRuntimeConfiguration as se, compileBlueprintV1 as ke, isBlueprintBundle as Ie, runBlueprintV1Steps as $e } from "@wp-playground/blueprints";
4
+ import { zipDirectory as Ee, RecommendedPHPVersion as F } from "@wp-playground/common";
5
+ import c, { existsSync as Z, rmdirSync as Te, mkdirSync as G, readdirSync as Be } from "fs";
6
+ import { MessageChannel as Me, Worker as ie } from "worker_threads";
7
7
  import { createNodeFsMountHandler as Ce, FileLockManagerForNode as Le } from "@php-wasm/node";
8
- import p, { basename as A, join as de } from "path";
8
+ import p, { basename as A, join as ce } from "path";
9
9
  import We from "express";
10
- import N, { cpus as Me } from "os";
11
- import { jspi as De } from "wasm-feature-detect";
10
+ import N, { cpus as De } from "os";
11
+ import { jspi as Q } from "wasm-feature-detect";
12
12
  import Re from "yargs";
13
13
  import { NodeJsFilesystem as Ae, OverlayFilesystem as Ue, InMemoryFilesystem as Fe, ZipFilesystem as Oe } from "@wp-playground/storage";
14
14
  import { EmscriptenDownloadMonitor as Ne, ProgressTracker as _e } from "@php-wasm/progress";
@@ -29,10 +29,10 @@ function q(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, n] = s;
33
- if (!X(o))
32
+ const [o, i] = s;
33
+ if (!Z(o))
34
34
  throw new Error(`Host path does not exist: ${o}`);
35
- t.push({ hostPath: o, vfsPath: n });
35
+ t.push({ hostPath: o, vfsPath: i });
36
36
  }
37
37
  return t;
38
38
  }
@@ -42,7 +42,7 @@ function ne(e) {
42
42
  const t = [];
43
43
  for (let r = 0; r < e.length; r += 2) {
44
44
  const s = e[r], o = e[r + 1];
45
- if (!X(s))
45
+ if (!Z(s))
46
46
  throw new Error(`Host path does not exist: ${s}`);
47
47
  t.push({
48
48
  hostPath: p.resolve(process.cwd(), s),
@@ -58,7 +58,7 @@ async function rr(e, t) {
58
58
  Ce(r.hostPath)
59
59
  );
60
60
  }
61
- const ie = {
61
+ const ae = {
62
62
  step: "runPHP",
63
63
  code: {
64
64
  filename: "activate-theme.php",
@@ -77,7 +77,7 @@ const ie = {
77
77
  `
78
78
  }
79
79
  };
80
- function ce(e) {
80
+ function pe(e) {
81
81
  const t = e.autoMount, r = [...e.mount || []], s = [...e["mount-before-install"] || []], o = {
82
82
  ...e,
83
83
  mount: r,
@@ -87,44 +87,44 @@ function ce(e) {
87
87
  ]
88
88
  };
89
89
  if (rt(t)) {
90
- const i = `/wordpress/wp-content/plugins/${A(t)}`;
90
+ const n = `/wordpress/wp-content/plugins/${A(t)}`;
91
91
  r.push({
92
92
  hostPath: t,
93
- vfsPath: i,
93
+ vfsPath: n,
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
99
  } else if (tt(t)) {
100
- const n = A(t), i = `/wordpress/wp-content/themes/${n}`;
100
+ const i = A(t), n = `/wordpress/wp-content/themes/${i}`;
101
101
  r.push({
102
102
  hostPath: t,
103
- vfsPath: i,
103
+ vfsPath: n,
104
104
  autoMounted: !0
105
105
  }), o["additional-blueprint-steps"].push(
106
106
  e["experimental-blueprints-v2-runner"] ? {
107
107
  step: "activateTheme",
108
- themeDirectoryName: n
108
+ themeDirectoryName: i
109
109
  } : {
110
110
  step: "activateTheme",
111
- themeFolderName: n
111
+ themeFolderName: i
112
112
  }
113
113
  );
114
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}`,
115
+ const i = c.readdirSync(t);
116
+ for (const n of i)
117
+ n !== "index.php" && r.push({
118
+ hostPath: `${t}/${n}`,
119
+ vfsPath: `/wordpress/wp-content/${n}`,
120
120
  autoMounted: !0
121
121
  });
122
- o["additional-blueprint-steps"].push(ie);
122
+ o["additional-blueprint-steps"].push(ae);
123
123
  } else Ke(t) && (s.push({
124
124
  hostPath: t,
125
125
  vfsPath: "/wordpress",
126
126
  autoMounted: !0
127
- }), o.mode = "apply-to-existing-site", o["additional-blueprint-steps"].push(ie), o.wordpressInstallMode || (o.wordpressInstallMode = "install-from-existing-files-if-needed"));
127
+ }), o.mode = "apply-to-existing-site", o["additional-blueprint-steps"].push(ae), o.wordpressInstallMode || (o.wordpressInstallMode = "install-from-existing-files-if-needed"));
128
128
  return o;
129
129
  }
130
130
  function Ke(e) {
@@ -138,14 +138,14 @@ function et(e) {
138
138
  function tt(e) {
139
139
  if (!c.readdirSync(e).includes("style.css"))
140
140
  return !1;
141
- const r = c.readFileSync(de(e, "style.css"), "utf8");
141
+ const r = c.readFileSync(ce(e, "style.css"), "utf8");
142
142
  return !!/^(?:[ \t]*<\?php)?[ \t/*#@]*Theme Name:(.*)$/im.exec(r);
143
143
  }
144
144
  function rt(e) {
145
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 n = c.readFileSync(de(e, o), "utf8");
148
- return !!r.exec(n);
147
+ const i = c.readFileSync(ce(e, o), "utf8");
148
+ return !!r.exec(i);
149
149
  });
150
150
  }
151
151
  function ot(e) {
@@ -183,7 +183,7 @@ function st(e) {
183
183
  }
184
184
  return t;
185
185
  }
186
- function nt(e) {
186
+ function it(e) {
187
187
  if (e.length % 2 !== 0)
188
188
  throw new Error(
189
189
  "Invalid number constant definition format. Expected pairs of NAME value"
@@ -193,57 +193,57 @@ function nt(e) {
193
193
  const s = e[r], o = e[r + 1].trim();
194
194
  if (!s || !s.trim())
195
195
  throw new Error("Constant name cannot be empty");
196
- const n = Number(o);
197
- if (isNaN(n))
196
+ const i = Number(o);
197
+ if (isNaN(i))
198
198
  throw new Error(
199
199
  `Invalid number value for constant "${s}": "${o}". Must be a valid number.`
200
200
  );
201
- t[s.trim()] = n;
201
+ t[s.trim()] = i;
202
202
  }
203
203
  return t;
204
204
  }
205
- function it(e = {}, t = {}, r = {}) {
206
- const s = {}, o = /* @__PURE__ */ new Set(), n = (i, l) => {
207
- for (const u in i) {
205
+ function nt(e = {}, t = {}, r = {}) {
206
+ const s = {}, o = /* @__PURE__ */ new Set(), i = (n, l) => {
207
+ for (const u in n) {
208
208
  if (o.has(u))
209
209
  throw new Error(
210
210
  `Constant "${u}" is defined multiple times across different --define-${l} flags`
211
211
  );
212
- o.add(u), s[u] = i[u];
212
+ o.add(u), s[u] = n[u];
213
213
  }
214
214
  };
215
- return n(e, "string"), n(t, "bool"), n(r, "number"), s;
215
+ return i(e, "string"), i(t, "bool"), i(r, "number"), s;
216
216
  }
217
217
  function O(e) {
218
- return it(
218
+ return nt(
219
219
  e.define,
220
220
  e["define-bool"],
221
221
  e["define-number"]
222
222
  );
223
223
  }
224
224
  async function at(e) {
225
- const t = We(), r = await new Promise((n, i) => {
225
+ const t = We(), r = await new Promise((i, n) => {
226
226
  const l = t.listen(e.port, () => {
227
227
  const u = l.address();
228
- u === null || typeof u == "string" ? i(new Error("Server address is not available")) : n(l);
228
+ u === null || typeof u == "string" ? n(new Error("Server address is not available")) : i(l);
229
229
  });
230
230
  });
231
- t.use("/", async (n, i) => {
231
+ t.use("/", async (i, n) => {
232
232
  let l;
233
233
  try {
234
234
  l = await e.handleRequest({
235
- url: n.url,
236
- headers: ut(n),
237
- method: n.method,
238
- body: await lt(n)
235
+ url: i.url,
236
+ headers: ut(i),
237
+ method: i.method,
238
+ body: await lt(i)
239
239
  });
240
240
  } catch (u) {
241
241
  y.error(u), l = z.forHttpCode(500);
242
242
  }
243
- i.statusCode = l.httpStatusCode;
243
+ n.statusCode = l.httpStatusCode;
244
244
  for (const u in l.headers)
245
- i.setHeader(u, l.headers[u]);
246
- i.end(l.bytes);
245
+ n.setHeader(u, l.headers[u]);
246
+ n.end(l.bytes);
247
247
  });
248
248
  const o = r.address().port;
249
249
  return await e.onBind(r, o);
@@ -284,8 +284,8 @@ class dt {
284
284
  async handleRequest(t) {
285
285
  let r = this.workerLoads[0];
286
286
  for (let o = 1; o < this.workerLoads.length; o++) {
287
- const n = this.workerLoads[o];
288
- n.activeRequests.size < r.activeRequests.size && (r = n);
287
+ const i = this.workerLoads[o];
288
+ i.activeRequests.size < r.activeRequests.size && (r = i);
289
289
  }
290
290
  const s = r.worker.request(t);
291
291
  return r.activeRequests.add(s), s.url = t.url, s.finally(() => {
@@ -303,7 +303,7 @@ async function pt({
303
303
  if (!e)
304
304
  return;
305
305
  if (e.startsWith("http://") || e.startsWith("https://"))
306
- return await Se(e);
306
+ return await xe(e);
307
307
  let r = p.resolve(process.cwd(), e);
308
308
  if (!c.existsSync(r))
309
309
  throw new Error(`Blueprint file does not exist: ${r}`);
@@ -319,18 +319,18 @@ async function pt({
319
319
  c.readFileSync(r).buffer
320
320
  );
321
321
  case ".json": {
322
- const n = c.readFileSync(r, "utf-8");
322
+ const i = c.readFileSync(r, "utf-8");
323
323
  try {
324
- JSON.parse(n);
324
+ JSON.parse(i);
325
325
  } catch {
326
326
  throw new Error(
327
327
  `Blueprint file at ${r} is not a valid JSON file`
328
328
  );
329
329
  }
330
- const i = p.dirname(r), l = new Ae(i);
330
+ const n = p.dirname(r), l = new Ae(n);
331
331
  return new Ue([
332
332
  new Fe({
333
- "blueprint.json": n
333
+ "blueprint.json": i
334
334
  }),
335
335
  /**
336
336
  * Wrap the NodeJS filesystem to prevent access to local files
@@ -365,7 +365,7 @@ class mt {
365
365
  async bootAndSetUpInitialPlayground(t, r, s) {
366
366
  const o = U(t);
367
367
  await o.useFileLockManager(r);
368
- const n = {
368
+ const i = {
369
369
  ...this.args,
370
370
  phpVersion: this.phpVersion,
371
371
  siteUrl: this.siteUrl,
@@ -374,6 +374,8 @@ class mt {
374
374
  trace: this.args.verbosity === "debug",
375
375
  blueprint: this.args.blueprint,
376
376
  withIntl: this.args.intl,
377
+ withRedis: this.args.redis,
378
+ withMemcached: this.args.memcached,
377
379
  // We do not enable Xdebug by default for the initial worker
378
380
  // because we do not imagine users expect to hit breakpoints
379
381
  // until Playground has fully booted.
@@ -385,7 +387,7 @@ class mt {
385
387
  mountsAfterWpInstall: this.args.mount || [],
386
388
  constants: O(this.args)
387
389
  };
388
- return await o.bootAndSetUpInitialWorker(n), o;
390
+ return await o.bootAndSetUpInitialWorker(i), o;
389
391
  }
390
392
  async bootPlayground({
391
393
  worker: t,
@@ -393,9 +395,9 @@ class mt {
393
395
  firstProcessId: s,
394
396
  nativeInternalDirPath: o
395
397
  }) {
396
- const n = U(t.phpPort);
397
- await n.useFileLockManager(r);
398
- const i = {
398
+ const i = U(t.phpPort);
399
+ await i.useFileLockManager(r);
400
+ const n = {
399
401
  ...this.args,
400
402
  phpVersion: this.phpVersion,
401
403
  siteUrl: this.siteUrl,
@@ -403,43 +405,45 @@ class mt {
403
405
  processIdSpaceLength: this.processIdSpaceLength,
404
406
  trace: this.args.verbosity === "debug",
405
407
  withIntl: this.args.intl,
408
+ withRedis: this.args.redis,
409
+ withMemcached: this.args.memcached,
406
410
  withXdebug: !!this.args.xdebug,
407
411
  nativeInternalDirPath: o,
408
412
  mountsBeforeWpInstall: this.args["mount-before-install"] || [],
409
413
  mountsAfterWpInstall: this.args.mount || [],
410
414
  constants: O(this.args)
411
415
  };
412
- return await n.bootWorker(i), n;
416
+ return await i.bootWorker(n), i;
413
417
  }
414
418
  }
415
- const Q = p.join(N.homedir(), ".wordpress-playground");
419
+ const X = p.join(N.homedir(), ".wordpress-playground");
416
420
  async function ht(e) {
417
- return await pe(
421
+ return await me(
418
422
  "https://github.com/WordPress/sqlite-database-integration/archive/refs/heads/develop.zip",
419
423
  "sqlite.zip",
420
424
  e
421
425
  );
422
426
  }
423
- async function pe(e, t, r) {
424
- const s = p.join(Q, t);
425
- return B.existsSync(s) || (B.ensureDirSync(Q), await ft(e, s, r)), me(s);
427
+ async function me(e, t, r) {
428
+ const s = p.join(X, t);
429
+ return B.existsSync(s) || (B.ensureDirSync(X), await ft(e, s, r)), he(s);
426
430
  }
427
431
  async function ft(e, t, r) {
428
- const o = (await r.monitorFetch(fetch(e))).body.getReader(), n = `${t}.partial`, i = B.createWriteStream(n);
432
+ const o = (await r.monitorFetch(fetch(e))).body.getReader(), i = `${t}.partial`, n = B.createWriteStream(i);
429
433
  for (; ; ) {
430
434
  const { done: l, value: u } = await o.read();
431
- if (u && i.write(u), l)
435
+ if (u && n.write(u), l)
432
436
  break;
433
437
  }
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);
438
+ n.close(), n.closed || await new Promise((l, u) => {
439
+ n.on("finish", () => {
440
+ B.renameSync(i, t), l(null);
441
+ }), n.on("error", (v) => {
442
+ B.removeSync(i), u(v);
439
443
  });
440
444
  });
441
445
  }
442
- function me(e, t) {
446
+ function he(e, t) {
443
447
  return new File([B.readFileSync(e)], A(e));
444
448
  }
445
449
  class wt {
@@ -450,24 +454,24 @@ class wt {
450
454
  return "v1";
451
455
  }
452
456
  async bootAndSetUpInitialPlayground(t, r, s) {
453
- let o, n, i;
457
+ let o, i, n;
454
458
  const l = new Ne();
455
459
  if (this.args.wordpressInstallMode === "download-and-install") {
456
460
  let k = !1;
457
461
  l.addEventListener("progress", (I) => {
458
462
  if (k)
459
463
  return;
460
- const { loaded: L, total: Z } = I.detail, W = Math.floor(
461
- Math.min(100, 100 * L / Z)
464
+ const { loaded: C, total: J } = I.detail, L = Math.floor(
465
+ Math.min(100, 100 * C / J)
462
466
  );
463
- k = W === 100, this.cliOutput.updateProgress(
467
+ k = L === 100, this.cliOutput.updateProgress(
464
468
  "Downloading WordPress",
465
- W
469
+ L
466
470
  );
467
- }), o = await He(this.args.wp), i = p.join(
468
- Q,
471
+ }), o = await He(this.args.wp), n = p.join(
472
+ X,
469
473
  `prebuilt-wp-content-for-wp-${o.version}.zip`
470
- ), n = c.existsSync(i) ? me(i) : await pe(
474
+ ), i = c.existsSync(n) ? he(n) : await me(
471
475
  o.releaseUrl,
472
476
  `${o.version}.zip`,
473
477
  l
@@ -479,7 +483,7 @@ class wt {
479
483
  this.args.skipSqliteSetup ? (y.debug("Skipping SQLite integration plugin setup..."), u = void 0) : (this.cliOutput.updateProgress("Preparing SQLite database"), u = await ht(l));
480
484
  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
485
  await g.isConnected(), this.cliOutput.updateProgress("Booting WordPress");
482
- const h = await oe(
486
+ const h = await se(
483
487
  this.getEffectiveBlueprint()
484
488
  );
485
489
  return await g.useFileLockManager(r), await g.bootAndSetUpInitialWorker({
@@ -489,7 +493,7 @@ class wt {
489
493
  mountsBeforeWpInstall: w,
490
494
  mountsAfterWpInstall: a,
491
495
  wordpressInstallMode: this.args.wordpressInstallMode || "download-and-install",
492
- wordPressZip: n && await n.arrayBuffer(),
496
+ wordPressZip: i && await i.arrayBuffer(),
493
497
  sqliteIntegrationPluginZip: await u?.arrayBuffer(),
494
498
  firstProcessId: 0,
495
499
  processIdSpaceLength: this.processIdSpaceLength,
@@ -497,6 +501,8 @@ class wt {
497
501
  trace: P,
498
502
  internalCookieStore: this.args.internalCookieStore,
499
503
  withIntl: this.args.intl,
504
+ withRedis: this.args.redis,
505
+ withMemcached: this.args.memcached,
500
506
  // We do not enable Xdebug by default for the initial worker
501
507
  // because we do not imagine users expect to hit breakpoints
502
508
  // until Playground has fully booted.
@@ -504,9 +510,9 @@ class wt {
504
510
  withXdebug: !1,
505
511
  nativeInternalDirPath: s,
506
512
  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")
513
+ }), n && !this.args["mount-before-install"] && !c.existsSync(n) && (this.cliOutput.updateProgress("Caching WordPress for next boot"), c.writeFileSync(
514
+ n,
515
+ await Ee(g, "/wordpress")
510
516
  )), g;
511
517
  }
512
518
  async bootPlayground({
@@ -515,15 +521,15 @@ class wt {
515
521
  firstProcessId: s,
516
522
  nativeInternalDirPath: o
517
523
  }) {
518
- const n = U(
524
+ const i = U(
519
525
  t.phpPort
520
526
  );
521
- await n.isConnected();
522
- const i = await oe(
527
+ await i.isConnected();
528
+ const n = await se(
523
529
  this.getEffectiveBlueprint()
524
530
  );
525
- return await n.useFileLockManager(r), await n.bootWorker({
526
- phpVersion: i.phpVersion,
531
+ return await i.useFileLockManager(r), await i.bootWorker({
532
+ phpVersion: n.phpVersion,
527
533
  siteUrl: this.siteUrl,
528
534
  mountsBeforeWpInstall: this.args["mount-before-install"] || [],
529
535
  mountsAfterWpInstall: this.args.mount || [],
@@ -535,28 +541,30 @@ class wt {
535
541
  // will have a separate cookie store.
536
542
  internalCookieStore: this.args.internalCookieStore,
537
543
  withIntl: this.args.intl,
544
+ withRedis: this.args.redis,
545
+ withMemcached: this.args.memcached,
538
546
  withXdebug: !!this.args.xdebug,
539
547
  nativeInternalDirPath: o,
540
548
  constants: O(this.args)
541
- }), await n.isReady(), n;
549
+ }), await i.isReady(), i;
542
550
  }
543
551
  async compileInputBlueprint(t) {
544
552
  const r = this.getEffectiveBlueprint(), s = new _e();
545
- let o = "", n = !1;
546
- return s.addEventListener("progress", (i) => {
547
- if (n)
553
+ let o = "", i = !1;
554
+ return s.addEventListener("progress", (n) => {
555
+ if (i)
548
556
  return;
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, {
557
+ i = n.detail.progress === 100;
558
+ const l = Math.floor(n.detail.progress);
559
+ o = n.detail.caption || o || "Running Blueprint", this.cliOutput.updateProgress(o.trim(), l);
560
+ }), await ke(r, {
553
561
  progress: s,
554
562
  additionalSteps: t
555
563
  });
556
564
  }
557
565
  getEffectiveBlueprint() {
558
566
  const t = this.args.blueprint;
559
- return ke(t) ? t : {
567
+ return Ie(t) ? t : {
560
568
  login: this.args.login,
561
569
  ...t || {},
562
570
  preferredVersions: {
@@ -588,14 +596,14 @@ async function yt(e, t, r) {
588
596
  t,
589
597
  r
590
598
  )).map(
591
- (n) => new Promise((i) => {
592
- c.rm(n, { recursive: !0 }, (l) => {
599
+ (i) => new Promise((n) => {
600
+ c.rm(i, { recursive: !0 }, (l) => {
593
601
  l ? y.warn(
594
- `Failed to delete stale Playground temp dir: ${n}`,
602
+ `Failed to delete stale Playground temp dir: ${i}`,
595
603
  l
596
604
  ) : y.info(
597
- `Deleted stale Playground temp dir: ${n}`
598
- ), i();
605
+ `Deleted stale Playground temp dir: ${i}`
606
+ ), n();
599
607
  });
600
608
  })
601
609
  );
@@ -603,13 +611,13 @@ async function yt(e, t, r) {
603
611
  }
604
612
  async function bt(e, t, r) {
605
613
  try {
606
- const s = c.readdirSync(r).map((n) => p.join(r, n)), o = [];
607
- for (const n of s)
614
+ const s = c.readdirSync(r).map((i) => p.join(r, i)), o = [];
615
+ for (const i of s)
608
616
  await vt(
609
617
  e,
610
618
  t,
611
- n
612
- ) && o.push(n);
619
+ i
620
+ ) && o.push(i);
613
621
  return o;
614
622
  } catch (s) {
615
623
  return y.warn(`Failed to find stale Playground temp dirs: ${s}`), [];
@@ -621,16 +629,16 @@ async function vt(e, t, r) {
621
629
  const o = p.basename(r);
622
630
  if (!o.includes(e))
623
631
  return !1;
624
- const n = o.match(
632
+ const i = o.match(
625
633
  new RegExp(`^(.+)${e}(\\d+)-`)
626
634
  );
627
- if (!n)
635
+ if (!i)
628
636
  return !1;
629
- const i = {
630
- executableName: n[1],
631
- pid: n[2]
637
+ const n = {
638
+ executableName: i[1],
639
+ pid: i[2]
632
640
  };
633
- if (await Pt(i.pid, i.executableName))
641
+ if (await Pt(n.pid, n.executableName))
634
642
  return !1;
635
643
  const l = Date.now() - t;
636
644
  return c.statSync(r).mtime.getTime() < l;
@@ -645,8 +653,8 @@ async function Pt(e, t) {
645
653
  // Remove path from executable name in the results.
646
654
  clean: !0
647
655
  },
648
- (n, i) => {
649
- n ? o(n) : s(i);
656
+ (i, n) => {
657
+ i ? o(i) : s(n);
650
658
  }
651
659
  );
652
660
  }
@@ -722,11 +730,11 @@ ${t}
722
730
  `${this.dim("PHP")} ${this.cyan(t.phpVersion)} ${this.dim("WordPress")} ${this.cyan(t.wpVersion)}`
723
731
  );
724
732
  const s = [];
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)
733
+ if (t.intl && s.push("intl"), t.redis && s.push("redis"), t.memcached && s.push("memcached"), t.xdebug && s.push(this.yellow("xdebug")), s.length > 0 && r.push(`${this.dim("Extensions")} ${s.join(", ")}`), t.mounts.length > 0)
726
734
  for (const o of t.mounts) {
727
- const n = o.autoMounted ? ` ${this.dim("(auto-mount)")}` : "";
735
+ const i = o.autoMounted ? ` ${this.dim("(auto-mount)")}` : "";
728
736
  r.push(
729
- `${this.dim("Mount")} ${o.hostPath} ${this.dim("→")} ${o.vfsPath}${n}`
737
+ `${this.dim("Mount")} ${o.hostPath} ${this.dim("→")} ${o.vfsPath}${i}`
730
738
  );
731
739
  }
732
740
  t.blueprint && r.push(`${this.dim("Blueprint")} ${t.blueprint}`), this.writeStream.write(r.join(`
@@ -809,7 +817,7 @@ ${this.green("Ready!")} WordPress is running on ${this.bold(t)} ${this.dim(`(${r
809
817
  `);
810
818
  }
811
819
  }
812
- const he = {
820
+ const fe = {
813
821
  Quiet: { name: "quiet", severity: j.Fatal },
814
822
  Normal: { name: "normal", severity: j.Info },
815
823
  Debug: { name: "debug", severity: j.Debug }
@@ -825,7 +833,7 @@ async function or(e) {
825
833
  describe: "PHP version to use.",
826
834
  type: "string",
827
835
  default: F,
828
- choices: re
836
+ choices: oe
829
837
  },
830
838
  wp: {
831
839
  describe: "WordPress version to use.",
@@ -851,7 +859,7 @@ async function or(e) {
851
859
  type: "string",
852
860
  nargs: 2,
853
861
  array: !0,
854
- coerce: nt
862
+ coerce: it
855
863
  },
856
864
  // @TODO: Support read-only mounts, e.g. via WORKERFS, a custom
857
865
  // ReadOnlyNODEFS, or by copying the files into MEMFS
@@ -926,7 +934,7 @@ async function or(e) {
926
934
  verbosity: {
927
935
  describe: "Output logs and progress messages.",
928
936
  type: "string",
929
- choices: Object.values(he).map(
937
+ choices: Object.values(fe).map(
930
938
  (a) => a.name
931
939
  ),
932
940
  default: "normal"
@@ -965,6 +973,16 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
965
973
  type: "boolean",
966
974
  default: !0
967
975
  },
976
+ redis: {
977
+ describe: "Enable Redis (requires JSPI support).",
978
+ type: "boolean"
979
+ // No default - will be determined at runtime based on JSPI availability
980
+ },
981
+ memcached: {
982
+ describe: "Enable Memcached.",
983
+ type: "boolean"
984
+ // No default - will be determined at runtime based on JSPI availability
985
+ },
968
986
  xdebug: {
969
987
  describe: "Enable Xdebug.",
970
988
  type: "boolean",
@@ -1002,7 +1020,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
1002
1020
  "experimental-multi-worker": {
1003
1021
  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.",
1004
1022
  type: "number",
1005
- coerce: (a) => a ?? Me().length - 1
1023
+ coerce: (a) => a ?? De().length - 1
1006
1024
  },
1007
1025
  "experimental-devtools": {
1008
1026
  describe: "Enable experimental browser development tools.",
@@ -1018,7 +1036,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
1018
1036
  describe: "PHP version to use.",
1019
1037
  type: "string",
1020
1038
  default: F,
1021
- choices: re
1039
+ choices: oe
1022
1040
  },
1023
1041
  wp: {
1024
1042
  describe: "WordPress version to use.",
@@ -1086,7 +1104,7 @@ Warning: Following symlinks will expose files outside mounted directories to Pla
1086
1104
  type: "string",
1087
1105
  default: "wordpress.zip"
1088
1106
  }
1089
- }, n = Re(e).usage("Usage: wp-playground <command> [options]").command(
1107
+ }, i = Re(e).usage("Usage: wp-playground <command> [options]").command(
1090
1108
  "start",
1091
1109
  "Start a local WordPress server with automatic project detection (recommended)",
1092
1110
  (a) => a.usage(
@@ -1195,24 +1213,24 @@ Examples:
1195
1213
  );
1196
1214
  return !0;
1197
1215
  });
1198
- n.wrap(n.terminalWidth());
1199
- const i = await n.argv, l = i._[0];
1216
+ i.wrap(i.terminalWidth());
1217
+ const n = await i.argv, l = n._[0];
1200
1218
  ["start", "run-blueprint", "server", "build-snapshot"].includes(
1201
1219
  l
1202
- ) || (n.showHelp(), process.exit(1));
1203
- const u = i.define || {};
1220
+ ) || (i.showHelp(), process.exit(1));
1221
+ const u = n.define || {};
1204
1222
  !("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
1223
  const v = {
1206
- ...i,
1224
+ ...n,
1207
1225
  define: u,
1208
1226
  command: l,
1209
1227
  mount: [
1210
- ...i.mount || [],
1211
- ...i["mount-dir"] || []
1228
+ ...n.mount || [],
1229
+ ...n["mount-dir"] || []
1212
1230
  ],
1213
1231
  "mount-before-install": [
1214
- ...i["mount-before-install"] || [],
1215
- ...i["mount-dir-before-install"] || []
1232
+ ...n["mount-before-install"] || [],
1233
+ ...n["mount-dir-before-install"] || []
1216
1234
  ]
1217
1235
  }, P = await Et(v);
1218
1236
  P === void 0 && process.exit(0);
@@ -1227,7 +1245,7 @@ Examples:
1227
1245
  if (console.error(t), !(t instanceof Error))
1228
1246
  throw t;
1229
1247
  if (process.argv.includes("--debug"))
1230
- be(t);
1248
+ ve(t);
1231
1249
  else {
1232
1250
  const s = [];
1233
1251
  let o = t;
@@ -1241,22 +1259,22 @@ Examples:
1241
1259
  process.exit(1);
1242
1260
  }
1243
1261
  }
1244
- function ae(e, t) {
1262
+ function le(e, t) {
1245
1263
  return e.find(
1246
1264
  (r) => r.vfsPath.replace(/\/$/, "") === t.replace(/\/$/, "")
1247
1265
  );
1248
1266
  }
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;
1267
+ 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, ue = (e) => process.stdout.isTTY ? `\x1B[33m${e}\x1B[0m` : e;
1250
1268
  async function Et(e) {
1251
1269
  let t, r;
1252
1270
  const s = /* @__PURE__ */ new Map();
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(
1271
+ if (e.command === "start" && (e = Tt(e)), e.autoMount !== void 0 && (e.autoMount === "" && (e = { ...e, autoMount: process.cwd() }), e = pe(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) {
1272
+ const w = Object.values(fe).find(
1255
1273
  (a) => a.name === e.verbosity
1256
1274
  ).severity;
1257
1275
  y.setSeverityFilterLevel(w);
1258
1276
  }
1259
- e.intl || (e.intl = !0);
1277
+ e.intl || (e.intl = !0), e.redis === void 0 && (e.redis = await Q()), e.memcached === void 0 && (e.memcached = await Q());
1260
1278
  const o = new xt({
1261
1279
  verbosity: e.verbosity || "normal"
1262
1280
  });
@@ -1266,46 +1284,48 @@ async function Et(e) {
1266
1284
  port: e.port || 9400,
1267
1285
  xdebug: !!e.xdebug,
1268
1286
  intl: !!e.intl,
1287
+ redis: !!e.redis,
1288
+ memcached: !!e.memcached,
1269
1289
  mounts: [
1270
1290
  ...e.mount || [],
1271
1291
  ...e["mount-before-install"] || []
1272
1292
  ],
1273
1293
  blueprint: typeof e.blueprint == "string" ? e.blueprint : void 0
1274
1294
  }));
1275
- const n = e.command === "server" ? e.port ?? 9400 : 0, i = N.platform() === "win32" ? (
1295
+ const i = e.command === "server" ? e.port ?? 9400 : 0, n = N.platform() === "win32" ? (
1276
1296
  // @TODO: Enable fs-ext here when it works with Windows.
1277
1297
  void 0
1278
1298
  ) : await import("fs-ext").then((w) => w.flockSync).catch(() => {
1279
1299
  y.debug(
1280
1300
  "The fs-ext package is not installed. Internal file locking will not be integrated with host OS file locking."
1281
1301
  );
1282
- }), l = new Le(i);
1302
+ }), l = new Le(n);
1283
1303
  let u = !1, v = !0;
1284
1304
  const P = await at({
1285
- port: n,
1305
+ port: i,
1286
1306
  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" ? (
1307
+ const g = "127.0.0.1", h = `http://${g}:${a}`, k = e["site-url"] || h, I = e.command === "server" ? e.experimentalMultiWorker ?? 1 : 1, C = e.command === "server" ? (
1288
1308
  // Account for the initial worker which is discarded by the server after setup.
1289
1309
  I + 1
1290
- ) : I, W = 2 ** 31 - 1, C = Math.floor(
1291
- W / L
1292
- ), J = "-playground-cli-site-", $ = await gt(J);
1310
+ ) : I, L = 2 ** 31 - 1, M = Math.floor(
1311
+ L / C
1312
+ ), K = "-playground-cli-site-", $ = await gt(K);
1293
1313
  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) {
1314
+ const W = "WP Playground CLI - Listen for Xdebug", ee = ".playground-xdebug-root", te = p.join(process.cwd(), ee);
1315
+ if (await Ge(te), e.xdebug && e.experimentalUnsafeIdeIntegration) {
1296
1316
  await Qe(
1297
1317
  $.path,
1298
- ee,
1318
+ te,
1299
1319
  process.platform
1300
1320
  );
1301
1321
  const d = {
1302
- hostPath: p.join(".", p.sep, K),
1322
+ hostPath: p.join(".", p.sep, ee),
1303
1323
  vfsPath: "/"
1304
1324
  };
1305
1325
  try {
1306
- await Xe(M, process.cwd());
1326
+ await Xe(W, process.cwd());
1307
1327
  const f = typeof e.xdebug == "object" ? e.xdebug : void 0, S = await Ze({
1308
- name: M,
1328
+ name: W,
1309
1329
  host: g,
1310
1330
  port: a,
1311
1331
  ides: e.experimentalUnsafeIdeIntegration,
@@ -1318,9 +1338,9 @@ async function Et(e) {
1318
1338
  ideKey: f?.ideKey
1319
1339
  }), m = e.experimentalUnsafeIdeIntegration, b = m.includes("vscode"), x = m.includes("phpstorm"), R = Object.values(S);
1320
1340
  console.log(""), R.length > 0 ? (console.log(T("Xdebug configured successfully")), console.log(
1321
- le("Updated IDE config: ") + R.join(" ")
1341
+ ue("Updated IDE config: ") + R.join(" ")
1322
1342
  ), console.log(
1323
- le("Playground source root: ") + ".playground-xdebug-root" + Y(
1343
+ ue("Playground source root: ") + ".playground-xdebug-root" + Y(
1324
1344
  $t(
1325
1345
  " – you can set breakpoints and preview Playground's VFS structure in there."
1326
1346
  )
@@ -1337,7 +1357,7 @@ async function Et(e) {
1337
1357
  " 2. Open the Run and Debug panel on the left sidebar"
1338
1358
  ), console.log(
1339
1359
  ` 3. Select "${Y(
1340
- M
1360
+ W
1341
1361
  )}" from the dropdown`
1342
1362
  ), console.log(' 3. Click "start debugging"'), console.log(
1343
1363
  " 5. Set a breakpoint. For example, in .playground-xdebug-root/wordpress/index.php"
@@ -1345,7 +1365,7 @@ async function Et(e) {
1345
1365
  " 6. Visit Playground in your browser to hit the breakpoint"
1346
1366
  ), x && console.log("")), x && S.phpstorm && (console.log(T("PhpStorm instructions:")), console.log(
1347
1367
  ` 1. Choose "${Y(
1348
- M
1368
+ W
1349
1369
  )}" debug configuration in the toolbar`
1350
1370
  ), console.log(" 2. Click the debug button (bug icon)`"), console.log(
1351
1371
  " 3. Set a breakpoint. For example, in .playground-xdebug-root/wordpress/index.php"
@@ -1358,15 +1378,15 @@ async function Et(e) {
1358
1378
  });
1359
1379
  }
1360
1380
  }
1361
- const fe = p.dirname($.path), we = 2 * 24 * 60 * 60 * 1e3;
1381
+ const we = p.dirname($.path), ge = 2 * 24 * 60 * 60 * 1e3;
1362
1382
  yt(
1363
- J,
1364
- we,
1365
- fe
1383
+ K,
1384
+ ge,
1385
+ we
1366
1386
  );
1367
1387
  const _ = p.join($.path, "internal");
1368
1388
  G(_);
1369
- const ge = [
1389
+ const ye = [
1370
1390
  "wordpress",
1371
1391
  // Note: These dirs are from Emscripten's "default dirs" list:
1372
1392
  // https://github.com/emscripten-core/emscripten/blob/f431ec220e472e1f8d3db6b52fe23fb377facf30/src/lib/libfs.js#L1400-L1402
@@ -1377,7 +1397,7 @@ async function Et(e) {
1377
1397
  "tmp",
1378
1398
  "home"
1379
1399
  ];
1380
- for (const d of ge) {
1400
+ for (const d of ye) {
1381
1401
  const f = (m) => m.vfsPath === `/${d}`;
1382
1402
  if (!(e["mount-before-install"]?.some(f) || e.mount?.some(f))) {
1383
1403
  const m = p.join(
@@ -1403,11 +1423,11 @@ async function Et(e) {
1403
1423
  let E;
1404
1424
  e["experimental-blueprints-v2-runner"] ? E = new mt(e, {
1405
1425
  siteUrl: k,
1406
- processIdSpaceLength: C,
1426
+ processIdSpaceLength: M,
1407
1427
  cliOutput: o
1408
1428
  }) : (E = new wt(e, {
1409
1429
  siteUrl: k,
1410
- processIdSpaceLength: C,
1430
+ processIdSpaceLength: M,
1411
1431
  cliOutput: o
1412
1432
  }), typeof e.blueprint == "string" && (e.blueprint = await pt({
1413
1433
  sourceString: e.blueprint,
@@ -1422,8 +1442,8 @@ async function Et(e) {
1422
1442
  }
1423
1443
  )
1424
1444
  ), w && await new Promise((f) => w.close(f)), await $.cleanup());
1425
- }, ye = Bt(
1426
- L,
1445
+ }, be = Bt(
1446
+ C,
1427
1447
  E.getWorkerType(),
1428
1448
  ({ exitCode: d, workerIndex: f }) => {
1429
1449
  H || d === 0 && y.error(
@@ -1434,7 +1454,7 @@ async function Et(e) {
1434
1454
  );
1435
1455
  o.startProgress("Starting...");
1436
1456
  try {
1437
- const d = await ye, f = await ue(l);
1457
+ const d = await be, f = await de(l);
1438
1458
  {
1439
1459
  const m = d.shift(), b = await E.bootAndSetUpInitialPlayground(
1440
1460
  m.phpPort,
@@ -1448,13 +1468,13 @@ async function Et(e) {
1448
1468
  const x = await E.compileInputBlueprint(
1449
1469
  e["additional-blueprint-steps"] || []
1450
1470
  );
1451
- x && await Ie(
1471
+ x && await $e(
1452
1472
  x,
1453
1473
  b
1454
1474
  );
1455
1475
  }
1456
1476
  if (e.command === "build-snapshot") {
1457
- await Wt(r, e.outfile), o.printStatus(`Exported to ${e.outfile}`), await D();
1477
+ await Lt(r, e.outfile), o.printStatus(`Exported to ${e.outfile}`), await D();
1458
1478
  return;
1459
1479
  } else if (e.command === "run-blueprint") {
1460
1480
  o.finishProgress("Done"), await D();
@@ -1462,10 +1482,10 @@ async function Et(e) {
1462
1482
  }
1463
1483
  await t.removeWorker(b), await b.dispose(), await m.worker.terminate(), s.delete(m.worker);
1464
1484
  }
1465
- const S = C;
1485
+ const S = M;
1466
1486
  return [r] = await Promise.all(
1467
1487
  d.map(async (m, b) => {
1468
- const x = S + b * C, R = await ue(l), V = await E.bootPlayground({
1488
+ const x = S + b * M, R = await de(l), V = await E.bootPlayground({
1469
1489
  worker: m,
1470
1490
  fileLockManagerPort: R,
1471
1491
  firstProcessId: x,
@@ -1486,14 +1506,14 @@ async function Et(e) {
1486
1506
  [Symbol.asyncDispose]: D,
1487
1507
  [kt]: {
1488
1508
  workerThreadCount: I,
1489
- getWorkerNumberFromProcessId: (m) => Math.floor(m / C)
1509
+ getWorkerNumberFromProcessId: (m) => Math.floor(m / M)
1490
1510
  }
1491
1511
  };
1492
1512
  } catch (d) {
1493
1513
  if (e.verbosity !== "debug")
1494
1514
  throw d;
1495
1515
  let f = "";
1496
- throw await r?.fileExists(te) && (f = await r.readFileAsText(te)), await D(), new Error(f, { cause: d });
1516
+ throw await r?.fileExists(re) && (f = await r.readFileAsText(re)), await D(), new Error(f, { cause: d });
1497
1517
  }
1498
1518
  },
1499
1519
  async handleRequest(w) {
@@ -1518,15 +1538,15 @@ async function Et(e) {
1518
1538
  return await t.handleRequest(w);
1519
1539
  }
1520
1540
  });
1521
- return P && e.command === "start" && !e.skipBrowser && Lt(P.serverUrl), P;
1541
+ return P && e.command === "start" && !e.skipBrowser && Ct(P.serverUrl), P;
1522
1542
  }
1523
1543
  function Tt(e) {
1524
1544
  let t = { ...e, command: "server" };
1525
- e.noAutoMount || (t.autoMount = p.resolve(process.cwd(), t.path ?? ""), t = ce(t), delete t.autoMount);
1526
- const r = ae(
1545
+ e.noAutoMount || (t.autoMount = p.resolve(process.cwd(), t.path ?? ""), t = pe(t), delete t.autoMount);
1546
+ const r = le(
1527
1547
  t["mount-before-install"] || [],
1528
1548
  "/wordpress"
1529
- ) || ae(t.mount || [], "/wordpress");
1549
+ ) || le(t.mount || [], "/wordpress");
1530
1550
  if (r)
1531
1551
  console.log("Site files stored at:", r?.hostPath), e.reset && (console.log(""), console.log(
1532
1552
  It(
@@ -1538,15 +1558,15 @@ function Tt(e) {
1538
1558
  "You may still remove the site's directory manually if you wish."
1539
1559
  ), process.exit(1));
1540
1560
  else {
1541
- const s = t.autoMount || process.cwd(), o = Je("sha256").update(s).digest("hex"), n = N.homedir(), i = p.join(
1542
- n,
1561
+ const s = t.autoMount || process.cwd(), o = Je("sha256").update(s).digest("hex"), i = N.homedir(), n = p.join(
1562
+ i,
1543
1563
  ".wordpress-playground/sites",
1544
1564
  o
1545
1565
  );
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"] = [
1566
+ console.log("Site files stored at:", n), Z(n) && e.reset && (console.log("Resetting site..."), Te(n, { recursive: !0 })), G(n, { recursive: !0 }), t["mount-before-install"] = [
1547
1567
  ...t["mount-before-install"] || [],
1548
- { vfsPath: "/wordpress", hostPath: i }
1549
- ], t.wordpressInstallMode = Te(i).length === 0 ? (
1568
+ { vfsPath: "/wordpress", hostPath: n }
1569
+ ], t.wordpressInstallMode = Be(n).length === 0 ? (
1550
1570
  // Only download WordPress on the first run when the site directory is still
1551
1571
  // empty.
1552
1572
  "download-and-install"
@@ -1560,41 +1580,41 @@ function Tt(e) {
1560
1580
  async function Bt(e, t, r) {
1561
1581
  const s = [];
1562
1582
  for (let o = 0; o < e; o++) {
1563
- const i = Ct(t, { onExit: (l) => {
1583
+ const n = Mt(t, { onExit: (l) => {
1564
1584
  r({
1565
1585
  exitCode: l,
1566
1586
  workerIndex: o
1567
1587
  });
1568
1588
  } });
1569
- s.push(i);
1589
+ s.push(n);
1570
1590
  }
1571
1591
  return Promise.all(s);
1572
1592
  }
1573
- function Ct(e, { onExit: t } = {}) {
1593
+ function Mt(e, { onExit: t } = {}) {
1574
1594
  let r;
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);
1595
+ return e === "v1" ? r = new ie(new URL("./worker-thread-v1.js", import.meta.url)) : r = new ie(new URL("./worker-thread-v2.js", import.meta.url)), new Promise((s, o) => {
1596
+ r.once("message", function(n) {
1597
+ n.command === "worker-script-initialized" && s({ worker: r, phpPort: n.phpPort });
1598
+ }), r.once("error", function(n) {
1599
+ console.error(n);
1580
1600
  const l = new Error(
1581
- `Worker failed to load worker. ${i.message ? `Original error: ${i.message}` : ""}`
1601
+ `Worker failed to load worker. ${n.message ? `Original error: ${n.message}` : ""}`
1582
1602
  );
1583
1603
  o(l);
1584
1604
  });
1585
- let n = !1;
1605
+ let i = !1;
1586
1606
  r.once("spawn", () => {
1587
- n = !0;
1588
- }), r.once("exit", (i) => {
1589
- n || o(new Error(`Worker exited before spawning: ${i}`)), t?.(i);
1607
+ i = !0;
1608
+ }), r.once("exit", (n) => {
1609
+ i || o(new Error(`Worker exited before spawning: ${n}`)), t?.(n);
1590
1610
  });
1591
1611
  });
1592
1612
  }
1593
- async function ue(e) {
1594
- const { port1: t, port2: r } = new Be();
1595
- return await De() ? ve(e, null, t) : await Pe(e, t), r;
1613
+ async function de(e) {
1614
+ const { port1: t, port2: r } = new Me();
1615
+ return await Q() ? Pe(e, null, t) : await Se(e, t), r;
1596
1616
  }
1597
- function Lt(e) {
1617
+ function Ct(e) {
1598
1618
  const t = N.platform();
1599
1619
  let r;
1600
1620
  switch (t) {
@@ -1612,7 +1632,7 @@ function Lt(e) {
1612
1632
  s && y.debug(`Could not open browser: ${s.message}`);
1613
1633
  });
1614
1634
  }
1615
- async function Wt(e, t) {
1635
+ async function Lt(e, t) {
1616
1636
  await e.run({
1617
1637
  code: `<?php
1618
1638
  $zip = new ZipArchive();
@@ -1637,13 +1657,13 @@ async function Wt(e, t) {
1637
1657
  c.writeFileSync(t, r);
1638
1658
  }
1639
1659
  export {
1640
- he as L,
1660
+ fe as L,
1641
1661
  rr as a,
1642
1662
  St as b,
1643
1663
  kt as i,
1644
1664
  O as m,
1645
1665
  or as p,
1646
1666
  Et as r,
1647
- Ct as s
1667
+ Mt as s
1648
1668
  };
1649
- //# sourceMappingURL=run-cli-DOpShCrT.js.map
1669
+ //# sourceMappingURL=run-cli-BK0MGgcU.js.map