@wp-playground/cli 1.2.1 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/run-cli.d.ts CHANGED
@@ -22,6 +22,7 @@ export interface RunCLIArgs {
22
22
  followSymlinks?: boolean;
23
23
  experimentalMultiWorker?: number;
24
24
  experimentalTrace?: boolean;
25
+ internalCookieStore?: boolean;
25
26
  }
26
27
  export interface RunCLIServer extends AsyncDisposable {
27
28
  playground: RemoteAPI<PlaygroundCliWorker>;
@@ -1,22 +1,22 @@
1
- import { exposeAPI as k, PHPWorker as S, consumeAPI as _ } from "@php-wasm/universal";
2
- import { loadNodeRuntime as N, createNodeFsMountHandler as W } from "@php-wasm/node";
3
- import { EmscriptenDownloadMonitor as v } from "@php-wasm/progress";
4
- import { bootWordPress as x } from "@wp-playground/wordpress";
5
- import { parentPort as f } from "worker_threads";
6
- import { rootCertificates as E } from "tls";
7
- function I(r, ...o) {
8
- let e = "", n = 0;
1
+ import { loadNodeRuntime as k, createNodeFsMountHandler as S } from "@php-wasm/node";
2
+ import { EmscriptenDownloadMonitor as M } from "@php-wasm/progress";
3
+ import { exposeAPI as _, PHPWorker as W, consumeAPI as v, consumeAPISync as I } from "@php-wasm/universal";
4
+ import { bootWordPress as N } from "@wp-playground/wordpress";
5
+ import { rootCertificates as x } from "tls";
6
+ import { MessageChannel as A, parentPort as E } from "worker_threads";
7
+ function F(r, ...o) {
8
+ let e = "", s = 0;
9
9
  for (let i = 0; i < r.length; i++)
10
10
  if (r[i] === "%" && i + 1 < r.length) {
11
11
  i++;
12
12
  const a = r[i];
13
13
  switch (a) {
14
14
  case "s": {
15
- const t = o[n++];
16
- let s;
15
+ const t = o[s++];
16
+ let n;
17
17
  if (typeof t == "object")
18
18
  try {
19
- s = JSON.stringify(
19
+ n = JSON.stringify(
20
20
  t,
21
21
  // Represent bigint values as strings in JSON.stringify().
22
22
  (u, c) => typeof c == "bigint" ? `0x${c.toString(16)}` : c,
@@ -25,22 +25,22 @@ function I(r, ...o) {
25
25
  } catch {
26
26
  }
27
27
  else
28
- s = String(t);
29
- e += s;
28
+ n = String(t);
29
+ e += n;
30
30
  break;
31
31
  }
32
32
  case "d": {
33
- const t = o[n++];
33
+ const t = o[s++];
34
34
  typeof t == "bigint" ? e += t.toString() : e += Math.floor(Number(t));
35
35
  break;
36
36
  }
37
37
  case "f": {
38
- const t = o[n++];
38
+ const t = o[s++];
39
39
  e += Number(t);
40
40
  break;
41
41
  }
42
42
  case "x": {
43
- const t = o[n++];
43
+ const t = o[s++];
44
44
  typeof t == "bigint" ? e += t.toString(16) : e += Math.floor(Number(t)).toString(16);
45
45
  break;
46
46
  }
@@ -55,56 +55,69 @@ function I(r, ...o) {
55
55
  e += r[i];
56
56
  return e;
57
57
  }
58
- function P(r, o) {
58
+ const L = () => (async () => "Suspending" in WebAssembly)();
59
+ function g(r, o) {
59
60
  for (const e of o)
60
- r.mkdir(e.vfsPath), r.mount(e.vfsPath, W(e.hostPath));
61
+ r.mkdir(e.vfsPath), r.mount(e.vfsPath, S(e.hostPath));
61
62
  }
62
63
  function D(r, o, ...e) {
63
64
  console.log(
64
65
  performance.now().toFixed(6).padStart(15, "0"),
65
66
  r.toString().padStart(16, "0"),
66
- I(o, ...e)
67
+ F(o, ...e)
67
68
  );
68
69
  }
69
- class F extends S {
70
+ class H extends W {
70
71
  constructor(o) {
71
72
  super(void 0, o), this.booted = !1;
72
73
  }
74
+ /**
75
+ * Call this method before boot() to use file locking.
76
+ *
77
+ * This method is separate from boot() to simplify the related Comlink.transferHandlers
78
+ * setup – if an argument is a MessagePort, we're transferring it, not copying it.
79
+ *
80
+ * @see comlink-sync.ts
81
+ * @see phpwasm-emscripten-library-file-locking-for-node.js
82
+ */
83
+ async useFileLockManager(o) {
84
+ await L() ? this.fileLockManager = v(o) : this.fileLockManager = await I(o);
85
+ }
73
86
  async boot({
74
87
  absoluteUrl: o,
75
88
  mountsBeforeWpInstall: e,
76
- mountsAfterWpInstall: n,
89
+ mountsAfterWpInstall: s,
77
90
  phpVersion: i = "8.0",
78
91
  wordPressZip: a,
79
92
  sqliteIntegrationPluginZip: t,
80
- firstProcessId: s,
93
+ firstProcessId: n,
81
94
  processIdSpaceLength: u,
82
95
  dataSqlPath: c,
83
- followSymlinks: g,
84
- trace: y
96
+ followSymlinks: b,
97
+ trace: P,
98
+ internalCookieStore: y
85
99
  }) {
86
100
  if (this.booted)
87
101
  throw new Error("Playground already booted");
88
102
  this.booted = !0;
89
- let l = s;
90
- const w = s + u - 1, m = _(f);
91
- await m.isConnected();
103
+ let l = n;
104
+ const w = n + u - 1;
92
105
  try {
93
- const d = {
106
+ const p = {
94
107
  WP_DEBUG: !0,
95
108
  WP_DEBUG_LOG: !0,
96
109
  WP_DEBUG_DISPLAY: !1
97
- }, h = await x({
110
+ }, h = await N({
98
111
  siteUrl: o,
99
112
  createPhpRuntime: async () => {
100
- const p = l;
101
- return l < w ? l++ : l = s, await N(i, {
113
+ const d = l;
114
+ return l < w ? l++ : l = n, await k(i, {
102
115
  emscriptenOptions: {
103
- fileLockManager: m,
104
- processId: p,
105
- trace: y ? D : void 0
116
+ fileLockManager: this.fileLockManager,
117
+ processId: d,
118
+ trace: P ? D : void 0
106
119
  },
107
- followSymlinks: g
120
+ followSymlinks: b
108
121
  });
109
122
  },
110
123
  wordPressZip: a !== void 0 ? new File([a], "wordpress.zip") : void 0,
@@ -114,28 +127,28 @@ class F extends S {
114
127
  ) : void 0,
115
128
  sapiName: "cli",
116
129
  createFiles: {
117
- "/internal/shared/ca-bundle.crt": E.join(`
130
+ "/internal/shared/ca-bundle.crt": x.join(`
118
131
  `)
119
132
  },
120
- constants: d,
133
+ constants: p,
121
134
  phpIniEntries: {
122
135
  "openssl.cafile": "/internal/shared/ca-bundle.crt",
123
136
  allow_url_fopen: "1",
124
137
  disable_functions: ""
125
138
  },
126
139
  hooks: {
127
- async beforeWordPressFiles(p) {
128
- P(p, e);
140
+ async beforeWordPressFiles(d) {
141
+ g(d, e);
129
142
  }
130
143
  },
131
- cookieStore: !1,
144
+ cookieStore: y ? void 0 : !1,
132
145
  dataSqlPath: c
133
146
  });
134
147
  this.__internal_setRequestHandler(h);
135
- const b = await h.getPrimaryPhp();
136
- await this.setPrimaryPHP(b), P(b, n), M();
137
- } catch (d) {
138
- throw A(d), d;
148
+ const m = await h.getPrimaryPhp();
149
+ await this.setPrimaryPHP(m), g(m, s), R();
150
+ } catch (p) {
151
+ throw C(p), p;
139
152
  }
140
153
  }
141
154
  // Provide a named disposal method that can be invoked via comlink.
@@ -143,10 +156,16 @@ class F extends S {
143
156
  await this[Symbol.asyncDispose]();
144
157
  }
145
158
  }
146
- const [M, A] = k(
147
- new F(new v()),
159
+ const f = new A(), [R, C] = _(
160
+ new H(new M()),
148
161
  void 0,
149
- f
162
+ f.port1
163
+ );
164
+ E.postMessage(
165
+ {
166
+ command: "worker-script-initialized",
167
+ phpPort: f.port2
168
+ },
169
+ [f.port2]
150
170
  );
151
- f.postMessage("worker-script-initialized");
152
- //# sourceMappingURL=worker-thread-BQ8BezvJ.js.map
171
+ //# sourceMappingURL=worker-thread-CQBM_bGk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker-thread-CQBM_bGk.js","sources":["packages/php-wasm/util/src/lib/sprintf.ts","node_modules/wasm-feature-detect/dist/esm/index.js","packages/playground/cli/src/worker-thread.ts"],"sourcesContent":["/**\n * Formats a string like sprintf().\n *\n * This function:\n * - Supports basic format specifiers: %s, %d, %f, %x, %%\n * - Supports bigint values\n *\n * The purpose of this function is for use in optional php-wasm tracing.\n * If we use printf-style formatting for trace messages, we let the trace\n * function decide whether to format and do not have to pay for formatting\n * unless tracing is enabled.\n */\nexport function sprintf(format: string, ...args: any[]): string {\n\tlet result = '';\n\tlet argIndex = 0;\n\n\tfor (let i = 0; i < format.length; i++) {\n\t\tif (format[i] === '%' && i + 1 < format.length) {\n\t\t\ti++;\n\t\t\tconst specifier = format[i];\n\n\t\t\tswitch (specifier) {\n\t\t\t\tcase 's': {\n\t\t\t\t\tconst arg = args[argIndex++];\n\t\t\t\t\tlet str;\n\t\t\t\t\tif (typeof arg === 'object') {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t// If an object doesn't provide its own toString(),\n\t\t\t\t\t\t\t// try to represent it as JSON.\n\t\t\t\t\t\t\tstr = JSON.stringify(\n\t\t\t\t\t\t\t\targ,\n\t\t\t\t\t\t\t\t// Represent bigint values as strings in JSON.stringify().\n\t\t\t\t\t\t\t\t(key, value) => {\n\t\t\t\t\t\t\t\t\tif (typeof value === 'bigint') {\n\t\t\t\t\t\t\t\t\t\treturn `0x${value.toString(16)}`;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn value;\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t2\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t// Ignore error and use default representation.\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tstr = String(arg);\n\t\t\t\t\t}\n\n\t\t\t\t\tresult += str;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase 'd': {\n\t\t\t\t\tconst arg = args[argIndex++];\n\t\t\t\t\tif (typeof arg === 'bigint') {\n\t\t\t\t\t\tresult += arg.toString();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresult += Math.floor(Number(arg));\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase 'f': {\n\t\t\t\t\tconst arg = args[argIndex++];\n\t\t\t\t\tif (typeof arg === 'bigint') {\n\t\t\t\t\t\tresult += Number(arg);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresult += Number(arg);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase 'x': {\n\t\t\t\t\tconst arg = args[argIndex++];\n\t\t\t\t\tif (typeof arg === 'bigint') {\n\t\t\t\t\t\tresult += arg.toString(16);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresult += Math.floor(Number(arg)).toString(16);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase '%': {\n\t\t\t\t\tresult += '%';\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tresult += '%' + specifier;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tresult += format[i];\n\t\t}\n\t}\n\n\treturn result;\n}\n","export const bigInt=()=>(async e=>{try{return(await WebAssembly.instantiate(e)).instance.exports.b(BigInt(0))===BigInt(0)}catch(e){return!1}})(new Uint8Array([0,97,115,109,1,0,0,0,1,6,1,96,1,126,1,126,3,2,1,0,7,5,1,1,98,0,0,10,6,1,4,0,32,0,11])),bulkMemory=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,3,1,0,1,10,14,1,12,0,65,0,65,0,65,0,252,10,0,0,11])),exceptions=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,8,1,6,0,6,64,25,11,11])),exceptionsFinal=()=>(async()=>{try{return new WebAssembly.Module(Uint8Array.from(atob(\"AGFzbQEAAAABBAFgAAADAgEAChABDgACaR9AAQMAAAsACxoL\"),(e=>e.codePointAt(0)))),!0}catch(e){return!1}})(),extendedConst=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,5,3,1,0,1,11,9,1,0,65,1,65,2,106,11,0])),gc=()=>(async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,95,1,120,0])))(),jsStringBuiltins=()=>(async()=>{try{return await WebAssembly.instantiate(Uint8Array.from(atob(\"AGFzbQEAAAABBgFgAW8BfwIXAQ53YXNtOmpzLXN0cmluZwR0ZXN0AAA=\"),(e=>e.codePointAt(0))),{},{builtins:[\"js-string\"]}),!0}catch(e){return!1}})(),jspi=()=>(async()=>\"Suspending\"in WebAssembly)(),memory64=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,5,3,1,4,1])),multiMemory=()=>(async()=>{try{return new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,5,5,2,0,0,0,0])),!0}catch(e){return!1}})(),multiValue=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,6,1,96,0,2,127,127,3,2,1,0,10,8,1,6,0,65,0,65,0,11])),mutableGlobals=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,2,8,1,1,97,1,98,3,127,1,6,6,1,127,1,65,0,11,7,5,1,1,97,3,1])),referenceTypes=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,7,1,5,0,208,112,26,11])),relaxedSimd=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,15,1,13,0,65,1,253,15,65,2,253,15,253,128,2,11])),saturatedFloatToInt=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,12,1,10,0,67,0,0,0,0,252,0,26,11])),signExtensions=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,8,1,6,0,65,0,192,26,11])),simd=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11])),streamingCompilation=()=>(async()=>\"compileStreaming\"in WebAssembly)(),tailCall=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,6,1,4,0,18,0,11])),threads=()=>(async e=>{try{return\"undefined\"!=typeof MessageChannel&&(new MessageChannel).port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(e)}catch(e){return!1}})(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11])),typeReflection=()=>(async()=>\"Function\"in WebAssembly)(),typedFunctionReferences=()=>(async()=>{try{return new WebAssembly.Module(Uint8Array.from(atob(\"AGFzbQEAAAABEANgAX8Bf2ABZAABf2AAAX8DBAMBAAIJBQEDAAEBChwDCwBBCkEqIAAUAGoLBwAgAEEBagsGANIBEAAL\"),(e=>e.codePointAt(0)))),!0}catch(e){return!1}})();\n","import type { FileLockManager } from '@php-wasm/node';\nimport { createNodeFsMountHandler, loadNodeRuntime } from '@php-wasm/node';\nimport { EmscriptenDownloadMonitor } from '@php-wasm/progress';\nimport type { PHP, RemoteAPI, SupportedPHPVersion } from '@php-wasm/universal';\nimport {\n\tPHPWorker,\n\tconsumeAPI,\n\tconsumeAPISync,\n\texposeAPI,\n} from '@php-wasm/universal';\nimport { sprintf } from '@php-wasm/util';\nimport { bootWordPress } from '@wp-playground/wordpress';\nimport { rootCertificates } from 'tls';\nimport { jspi } from 'wasm-feature-detect';\nimport { MessageChannel, type MessagePort, parentPort } from 'worker_threads';\n\nexport interface Mount {\n\thostPath: string;\n\tvfsPath: string;\n}\n\nexport type PrimaryWorkerBootOptions = {\n\twpVersion?: string;\n\tphpVersion?: SupportedPHPVersion;\n\tabsoluteUrl: string;\n\tmountsBeforeWpInstall: Array<Mount>;\n\tmountsAfterWpInstall: Array<Mount>;\n\twordPressZip?: ArrayBuffer;\n\tsqliteIntegrationPluginZip?: ArrayBuffer;\n\tfirstProcessId: number;\n\tprocessIdSpaceLength: number;\n\tdataSqlPath?: string;\n\tfollowSymlinks: boolean;\n\ttrace: boolean;\n\t/**\n\t * When true, Playground will not send cookies to the client but will manage\n\t * them internally. This can be useful in environments that can't store cookies,\n\t * e.g. VS Code WebView.\n\t *\n\t * Default: false.\n\t */\n\tinternalCookieStore?: boolean;\n};\n\nfunction mountResources(php: PHP, mounts: Mount[]) {\n\tfor (const mount of mounts) {\n\t\tphp.mkdir(mount.vfsPath);\n\t\tphp.mount(mount.vfsPath, createNodeFsMountHandler(mount.hostPath));\n\t}\n}\n\n/**\n * Print trace messages from PHP-WASM.\n *\n * @param {number} processId - The process ID.\n * @param {string} format - The format string.\n * @param {...any} args - The arguments.\n */\nfunction tracePhpWasm(processId: number, format: string, ...args: any[]) {\n\t// eslint-disable-next-line no-console\n\tconsole.log(\n\t\tperformance.now().toFixed(6).padStart(15, '0'),\n\t\tprocessId.toString().padStart(16, '0'),\n\t\tsprintf(format, ...args)\n\t);\n}\n\nexport class PlaygroundCliWorker extends PHPWorker {\n\tbooted = false;\n\tfileLockManager: RemoteAPI<FileLockManager> | FileLockManager | undefined;\n\n\tconstructor(monitor: EmscriptenDownloadMonitor) {\n\t\tsuper(undefined, monitor);\n\t}\n\n\t/**\n\t * Call this method before boot() to use file locking.\n\t *\n\t * This method is separate from boot() to simplify the related Comlink.transferHandlers\n\t * setup – if an argument is a MessagePort, we're transferring it, not copying it.\n\t *\n\t * @see comlink-sync.ts\n\t * @see phpwasm-emscripten-library-file-locking-for-node.js\n\t */\n\tasync useFileLockManager(port: MessagePort) {\n\t\tif (await jspi()) {\n\t\t\t/**\n\t\t\t * If JSPI is available, php.js supports both synchronous and asynchronous locking syscalls.\n\t\t\t * Web browsers, however, only support asynchronous message passing so let's use the\n\t\t\t * asynchronous API. Every method call will return a promise.\n\t\t\t *\n\t\t\t * @see comlink-sync.ts\n\t\t\t * @see phpwasm-emscripten-library-file-locking-for-node.js\n\t\t\t */\n\t\t\tthis.fileLockManager = consumeAPI<FileLockManager>(port);\n\t\t} else {\n\t\t\t/**\n\t\t\t * If JSPI is not available, php.js only supports synchronous locking syscalls.\n\t\t\t * Let's use the synchronous API. Every method call will block this thread\n\t\t\t * until the result is available.\n\t\t\t *\n\t\t\t * @see comlink-sync.ts\n\t\t\t * @see phpwasm-emscripten-library-file-locking-for-node.js\n\t\t\t */\n\t\t\tthis.fileLockManager = await consumeAPISync<FileLockManager>(port);\n\t\t}\n\t}\n\n\tasync boot({\n\t\tabsoluteUrl,\n\t\tmountsBeforeWpInstall,\n\t\tmountsAfterWpInstall,\n\t\tphpVersion = '8.0',\n\t\twordPressZip,\n\t\tsqliteIntegrationPluginZip,\n\t\tfirstProcessId,\n\t\tprocessIdSpaceLength,\n\t\tdataSqlPath,\n\t\tfollowSymlinks,\n\t\ttrace,\n\t\tinternalCookieStore,\n\t}: PrimaryWorkerBootOptions) {\n\t\tif (this.booted) {\n\t\t\tthrow new Error('Playground already booted');\n\t\t}\n\t\tthis.booted = true;\n\n\t\tlet nextProcessId = firstProcessId;\n\t\tconst lastProcessId = firstProcessId + processIdSpaceLength - 1;\n\n\t\ttry {\n\t\t\tconst constants: Record<string, string | number | boolean | null> =\n\t\t\t\t{\n\t\t\t\t\tWP_DEBUG: true,\n\t\t\t\t\tWP_DEBUG_LOG: true,\n\t\t\t\t\tWP_DEBUG_DISPLAY: false,\n\t\t\t\t};\n\n\t\t\tconst requestHandler = await bootWordPress({\n\t\t\t\tsiteUrl: absoluteUrl,\n\t\t\t\tcreatePhpRuntime: async () => {\n\t\t\t\t\tconst processId = nextProcessId;\n\n\t\t\t\t\tif (nextProcessId < lastProcessId) {\n\t\t\t\t\t\tnextProcessId++;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// We've reached the end of the process ID space. Start over.\n\t\t\t\t\t\tnextProcessId = firstProcessId;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn await loadNodeRuntime(phpVersion, {\n\t\t\t\t\t\temscriptenOptions: {\n\t\t\t\t\t\t\tfileLockManager: this.fileLockManager!,\n\t\t\t\t\t\t\tprocessId,\n\t\t\t\t\t\t\ttrace: trace ? tracePhpWasm : undefined,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tfollowSymlinks,\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\twordPressZip:\n\t\t\t\t\twordPressZip !== undefined\n\t\t\t\t\t\t? new File([wordPressZip], 'wordpress.zip')\n\t\t\t\t\t\t: undefined,\n\t\t\t\tsqliteIntegrationPluginZip:\n\t\t\t\t\tsqliteIntegrationPluginZip !== undefined\n\t\t\t\t\t\t? new File(\n\t\t\t\t\t\t\t\t[sqliteIntegrationPluginZip],\n\t\t\t\t\t\t\t\t'sqlite-integration-plugin.zip'\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: undefined,\n\t\t\t\tsapiName: 'cli',\n\t\t\t\tcreateFiles: {\n\t\t\t\t\t'/internal/shared/ca-bundle.crt':\n\t\t\t\t\t\trootCertificates.join('\\n'),\n\t\t\t\t},\n\t\t\t\tconstants,\n\t\t\t\tphpIniEntries: {\n\t\t\t\t\t'openssl.cafile': '/internal/shared/ca-bundle.crt',\n\t\t\t\t\tallow_url_fopen: '1',\n\t\t\t\t\tdisable_functions: '',\n\t\t\t\t},\n\t\t\t\thooks: {\n\t\t\t\t\tasync beforeWordPressFiles(php) {\n\t\t\t\t\t\tmountResources(php, mountsBeforeWpInstall);\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tcookieStore: internalCookieStore ? undefined : false,\n\t\t\t\tdataSqlPath,\n\t\t\t});\n\t\t\tthis.__internal_setRequestHandler(requestHandler);\n\n\t\t\tconst primaryPhp = await requestHandler.getPrimaryPhp();\n\t\t\tawait this.setPrimaryPHP(primaryPhp);\n\n\t\t\tmountResources(primaryPhp, mountsAfterWpInstall);\n\n\t\t\tsetApiReady();\n\t\t} catch (e) {\n\t\t\tsetAPIError(e as Error);\n\t\t\tthrow e;\n\t\t}\n\t}\n\n\t// Provide a named disposal method that can be invoked via comlink.\n\tasync dispose() {\n\t\tawait this[Symbol.asyncDispose]();\n\t}\n}\n\nconst phpChannel = new MessageChannel();\n\nconst [setApiReady, setAPIError] = exposeAPI(\n\tnew PlaygroundCliWorker(new EmscriptenDownloadMonitor()),\n\tundefined,\n\tphpChannel.port1\n);\n\nparentPort!.postMessage(\n\t{\n\t\tcommand: 'worker-script-initialized',\n\t\tphpPort: phpChannel.port2,\n\t},\n\t[phpChannel.port2 as any]\n);\n"],"names":["sprintf","format","args","result","argIndex","specifier","arg","str","key","value","jspi","mountResources","php","mounts","mount","createNodeFsMountHandler","tracePhpWasm","processId","PlaygroundCliWorker","PHPWorker","monitor","port","consumeAPI","consumeAPISync","absoluteUrl","mountsBeforeWpInstall","mountsAfterWpInstall","phpVersion","wordPressZip","sqliteIntegrationPluginZip","firstProcessId","processIdSpaceLength","dataSqlPath","followSymlinks","trace","internalCookieStore","nextProcessId","lastProcessId","constants","requestHandler","bootWordPress","loadNodeRuntime","rootCertificates","primaryPhp","setApiReady","e","setAPIError","phpChannel","MessageChannel","exposeAPI","EmscriptenDownloadMonitor","parentPort"],"mappings":";;;;;;AAYgB,SAAAA,EAAQC,MAAmBC,GAAqB;AAC/D,MAAIC,IAAS,IACTC,IAAW;AAEf,WAAS,IAAI,GAAG,IAAIH,EAAO,QAAQ;AAClC,QAAIA,EAAO,CAAC,MAAM,OAAO,IAAI,IAAIA,EAAO,QAAQ;AAC/C;AACM,YAAAI,IAAYJ,EAAO,CAAC;AAE1B,cAAQI,GAAW;AAAA,QAClB,KAAK,KAAK;AACH,gBAAAC,IAAMJ,EAAKE,GAAU;AACvB,cAAAG;AACA,cAAA,OAAOD,KAAQ;AACd,gBAAA;AAGH,cAAAC,IAAM,KAAK;AAAA,gBACVD;AAAA;AAAA,gBAEA,CAACE,GAAKC,MACD,OAAOA,KAAU,WACb,KAAKA,EAAM,SAAS,EAAE,CAAC,KAExBA;AAAA,gBAER;AAAA,cACD;AAAA,YAAA,QACO;AAAA,YAAA;AAAA;AAIR,YAAAF,IAAM,OAAOD,CAAG;AAGP,UAAAH,KAAAI;AACV;AAAA,QAAA;AAAA,QAED,KAAK,KAAK;AACH,gBAAAD,IAAMJ,EAAKE,GAAU;AACvB,UAAA,OAAOE,KAAQ,WAClBH,KAAUG,EAAI,SAAS,IAEvBH,KAAU,KAAK,MAAM,OAAOG,CAAG,CAAC;AAEjC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qBAAqB1B,GAAK;AAC/B,YAAAD,EAAeC,GAAKa,CAAqB;AAAA,UAAA;AAAA,QAE3C;AAAA,QACA,aAAaU,IAAsB,SAAY;AAAA,QAC/C,aAAAH;AAAA,MAAA,CACA;AACD,WAAK,6BAA6BO,CAAc;AAE1C,YAAAI,IAAa,MAAMJ,EAAe,cAAc;AAChD,YAAA,KAAK,cAAcI,CAAU,GAEnChC,EAAegC,GAAYjB,CAAoB,GAEnCkB,EAAA;AAAA,aACJC,GAAG;AACX,YAAAC,EAAYD,CAAU,GAChBA;AAAA,IAAA;AAAA,EACP;AAAA;AAAA,EAID,MAAM,UAAU;AACT,UAAA,KAAK,OAAO,YAAY,EAAE;AAAA,EAAA;AAElC;AAEA,MAAME,IAAa,IAAIC,EAAe,GAEhC,CAACJ,GAAaE,CAAW,IAAIG;AAAA,EAClC,IAAI/B,EAAoB,IAAIgC,GAA2B;AAAA,EACvD;AAAA,EACAH,EAAW;AACZ;AAEAI,EAAY;AAAA,EACX;AAAA,IACC,SAAS;AAAA,IACT,SAASJ,EAAW;AAAA,EACrB;AAAA,EACA,CAACA,EAAW,KAAY;AACzB;","x_google_ignoreList":[1]}
package/worker-thread.cjs CHANGED
@@ -1,3 +1,3 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@php-wasm/universal"),w=require("@php-wasm/node"),k=require("@php-wasm/progress"),W=require("@wp-playground/wordpress"),S=require("@php-wasm/util"),c=require("worker_threads"),E=require("tls");function h(o,e){for(const t of e)o.mkdir(t.vfsPath),o.mount(t.vfsPath,w.createNodeFsMountHandler(t.hostPath))}function D(o,e,...t){console.log(performance.now().toFixed(6).padStart(15,"0"),o.toString().padStart(16,"0"),S.sprintf(e,...t))}class f extends a.PHPWorker{constructor(e){super(void 0,e),this.booted=!1}async boot({absoluteUrl:e,mountsBeforeWpInstall:t,mountsAfterWpInstall:m,phpVersion:y="8.0",wordPressZip:l,sqliteIntegrationPluginZip:d,firstProcessId:n,processIdSpaceLength:b,dataSqlPath:g,followSymlinks:_,trace:v}){if(this.booted)throw new Error("Playground already booted");this.booted=!0;let r=n;const q=n+b-1,u=a.consumeAPI(c.parentPort);await u.isConnected();try{const s={WP_DEBUG:!0,WP_DEBUG_LOG:!0,WP_DEBUG_DISPLAY:!1},p=await W.bootWordPress({siteUrl:e,createPhpRuntime:async()=>{const i=r;return r<q?r++:r=n,await w.loadNodeRuntime(y,{emscriptenOptions:{fileLockManager:u,processId:i,trace:v?D:void 0},followSymlinks:_})},wordPressZip:l!==void 0?new File([l],"wordpress.zip"):void 0,sqliteIntegrationPluginZip:d!==void 0?new File([d],"sqlite-integration-plugin.zip"):void 0,sapiName:"cli",createFiles:{"/internal/shared/ca-bundle.crt":E.rootCertificates.join(`
2
- `)},constants:s,phpIniEntries:{"openssl.cafile":"/internal/shared/ca-bundle.crt",allow_url_fopen:"1",disable_functions:""},hooks:{async beforeWordPressFiles(i){h(i,t)}},cookieStore:!1,dataSqlPath:g});this.__internal_setRequestHandler(p);const P=await p.getPrimaryPhp();await this.setPrimaryPHP(P),h(P,m),F()}catch(s){throw I(s),s}}async dispose(){await this[Symbol.asyncDispose]()}}const[F,I]=a.exposeAPI(new f(new k.EmscriptenDownloadMonitor),void 0,c.parentPort);c.parentPort.postMessage("worker-script-initialized");exports.PlaygroundCliWorker=f;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("@php-wasm/node"),M=require("@php-wasm/progress"),n=require("@php-wasm/universal"),S=require("@php-wasm/util"),W=require("@wp-playground/wordpress"),E=require("tls"),F=require("./index-CyPmrjJv.cjs"),f=require("worker_threads");function P(o,e){for(const t of e)o.mkdir(t.vfsPath),o.mount(t.vfsPath,h.createNodeFsMountHandler(t.hostPath))}function I(o,e,...t){console.log(performance.now().toFixed(6).padStart(15,"0"),o.toString().padStart(16,"0"),S.sprintf(e,...t))}class w extends n.PHPWorker{constructor(e){super(void 0,e),this.booted=!1}async useFileLockManager(e){await F.jspi()?this.fileLockManager=n.consumeAPI(e):this.fileLockManager=await n.consumeAPISync(e)}async boot({absoluteUrl:e,mountsBeforeWpInstall:t,mountsAfterWpInstall:m,phpVersion:y="8.0",wordPressZip:l,sqliteIntegrationPluginZip:d,firstProcessId:i,processIdSpaceLength:g,dataSqlPath:b,followSymlinks:k,trace:v,internalCookieStore:_}){if(this.booted)throw new Error("Playground already booted");this.booted=!0;let r=i;const q=i+g-1;try{const s={WP_DEBUG:!0,WP_DEBUG_LOG:!0,WP_DEBUG_DISPLAY:!1},u=await W.bootWordPress({siteUrl:e,createPhpRuntime:async()=>{const a=r;return r<q?r++:r=i,await h.loadNodeRuntime(y,{emscriptenOptions:{fileLockManager:this.fileLockManager,processId:a,trace:v?I:void 0},followSymlinks:k})},wordPressZip:l!==void 0?new File([l],"wordpress.zip"):void 0,sqliteIntegrationPluginZip:d!==void 0?new File([d],"sqlite-integration-plugin.zip"):void 0,sapiName:"cli",createFiles:{"/internal/shared/ca-bundle.crt":E.rootCertificates.join(`
2
+ `)},constants:s,phpIniEntries:{"openssl.cafile":"/internal/shared/ca-bundle.crt",allow_url_fopen:"1",disable_functions:""},hooks:{async beforeWordPressFiles(a){P(a,t)}},cookieStore:_?void 0:!1,dataSqlPath:b});this.__internal_setRequestHandler(u);const p=await u.getPrimaryPhp();await this.setPrimaryPHP(p),P(p,m),L()}catch(s){throw A(s),s}}async dispose(){await this[Symbol.asyncDispose]()}}const c=new f.MessageChannel,[L,A]=n.exposeAPI(new w(new M.EmscriptenDownloadMonitor),void 0,c.port1);f.parentPort.postMessage({command:"worker-script-initialized",phpPort:c.port2},[c.port2]);exports.PlaygroundCliWorker=w;
3
3
  //# sourceMappingURL=worker-thread.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"worker-thread.cjs","sources":["../../../../packages/playground/cli/src/worker-thread.ts"],"sourcesContent":["import type { PHP, SupportedPHPVersion } from '@php-wasm/universal';\nimport { PHPWorker, consumeAPI, exposeAPI } from '@php-wasm/universal';\nimport type { FileLockManager } from '@php-wasm/node';\nimport { createNodeFsMountHandler, loadNodeRuntime } from '@php-wasm/node';\nimport { EmscriptenDownloadMonitor } from '@php-wasm/progress';\nimport { bootWordPress } from '@wp-playground/wordpress';\nimport { sprintf } from '@php-wasm/util';\nimport { parentPort } from 'worker_threads';\nimport { rootCertificates } from 'tls';\n\nexport interface Mount {\n\thostPath: string;\n\tvfsPath: string;\n}\n\nexport type PrimaryWorkerBootOptions = {\n\twpVersion?: string;\n\tphpVersion?: SupportedPHPVersion;\n\tabsoluteUrl: string;\n\tmountsBeforeWpInstall: Array<Mount>;\n\tmountsAfterWpInstall: Array<Mount>;\n\twordPressZip?: ArrayBuffer;\n\tsqliteIntegrationPluginZip?: ArrayBuffer;\n\tfirstProcessId: number;\n\tprocessIdSpaceLength: number;\n\tdataSqlPath?: string;\n\tfollowSymlinks: boolean;\n\ttrace: boolean;\n};\n\nfunction mountResources(php: PHP, mounts: Mount[]) {\n\tfor (const mount of mounts) {\n\t\tphp.mkdir(mount.vfsPath);\n\t\tphp.mount(mount.vfsPath, createNodeFsMountHandler(mount.hostPath));\n\t}\n}\n\n/**\n * Print trace messages from PHP-WASM.\n *\n * @param {number} processId - The process ID.\n * @param {string} format - The format string.\n * @param {...any} args - The arguments.\n */\nfunction tracePhpWasm(processId: number, format: string, ...args: any[]) {\n\t// eslint-disable-next-line no-console\n\tconsole.log(\n\t\tperformance.now().toFixed(6).padStart(15, '0'),\n\t\tprocessId.toString().padStart(16, '0'),\n\t\tsprintf(format, ...args)\n\t);\n}\n\nexport class PlaygroundCliWorker extends PHPWorker {\n\tbooted = false;\n\n\tconstructor(monitor: EmscriptenDownloadMonitor) {\n\t\tsuper(undefined, monitor);\n\t}\n\n\tasync boot({\n\t\tabsoluteUrl,\n\t\tmountsBeforeWpInstall,\n\t\tmountsAfterWpInstall,\n\t\tphpVersion = '8.0',\n\t\twordPressZip,\n\t\tsqliteIntegrationPluginZip,\n\t\tfirstProcessId,\n\t\tprocessIdSpaceLength,\n\t\tdataSqlPath,\n\t\tfollowSymlinks,\n\t\ttrace,\n\t}: PrimaryWorkerBootOptions) {\n\t\tif (this.booted) {\n\t\t\tthrow new Error('Playground already booted');\n\t\t}\n\t\tthis.booted = true;\n\n\t\tlet nextProcessId = firstProcessId;\n\t\tconst lastProcessId = firstProcessId + processIdSpaceLength - 1;\n\t\tconst fileLockManager = consumeAPI<FileLockManager>(parentPort!);\n\t\tawait fileLockManager.isConnected();\n\n\t\ttry {\n\t\t\tconst constants: Record<string, string | number | boolean | null> =\n\t\t\t\t{\n\t\t\t\t\tWP_DEBUG: true,\n\t\t\t\t\tWP_DEBUG_LOG: true,\n\t\t\t\t\tWP_DEBUG_DISPLAY: false,\n\t\t\t\t};\n\n\t\t\tconst requestHandler = await bootWordPress({\n\t\t\t\tsiteUrl: absoluteUrl,\n\t\t\t\tcreatePhpRuntime: async () => {\n\t\t\t\t\tconst processId = nextProcessId;\n\n\t\t\t\t\tif (nextProcessId < lastProcessId) {\n\t\t\t\t\t\tnextProcessId++;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// We've reached the end of the process ID space. Start over.\n\t\t\t\t\t\tnextProcessId = firstProcessId;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn await loadNodeRuntime(phpVersion, {\n\t\t\t\t\t\temscriptenOptions: {\n\t\t\t\t\t\t\tfileLockManager,\n\t\t\t\t\t\t\tprocessId,\n\t\t\t\t\t\t\ttrace: trace ? tracePhpWasm : undefined,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tfollowSymlinks,\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\twordPressZip:\n\t\t\t\t\twordPressZip !== undefined\n\t\t\t\t\t\t? new File([wordPressZip], 'wordpress.zip')\n\t\t\t\t\t\t: undefined,\n\t\t\t\tsqliteIntegrationPluginZip:\n\t\t\t\t\tsqliteIntegrationPluginZip !== undefined\n\t\t\t\t\t\t? new File(\n\t\t\t\t\t\t\t\t[sqliteIntegrationPluginZip],\n\t\t\t\t\t\t\t\t'sqlite-integration-plugin.zip'\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: undefined,\n\t\t\t\tsapiName: 'cli',\n\t\t\t\tcreateFiles: {\n\t\t\t\t\t'/internal/shared/ca-bundle.crt':\n\t\t\t\t\t\trootCertificates.join('\\n'),\n\t\t\t\t},\n\t\t\t\tconstants,\n\t\t\t\tphpIniEntries: {\n\t\t\t\t\t'openssl.cafile': '/internal/shared/ca-bundle.crt',\n\t\t\t\t\tallow_url_fopen: '1',\n\t\t\t\t\tdisable_functions: '',\n\t\t\t\t},\n\t\t\t\thooks: {\n\t\t\t\t\tasync beforeWordPressFiles(php) {\n\t\t\t\t\t\tmountResources(php, mountsBeforeWpInstall);\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tcookieStore: false,\n\t\t\t\tdataSqlPath,\n\t\t\t});\n\t\t\tthis.__internal_setRequestHandler(requestHandler);\n\n\t\t\tconst primaryPhp = await requestHandler.getPrimaryPhp();\n\t\t\tawait this.setPrimaryPHP(primaryPhp);\n\n\t\t\tmountResources(primaryPhp, mountsAfterWpInstall);\n\n\t\t\tsetApiReady();\n\t\t} catch (e) {\n\t\t\tsetAPIError(e as Error);\n\t\t\tthrow e;\n\t\t}\n\t}\n\n\t// Provide a named disposal method that can be invoked via comlink.\n\tasync dispose() {\n\t\tawait this[Symbol.asyncDispose]();\n\t}\n}\n\nconst [setApiReady, setAPIError] = exposeAPI(\n\tnew PlaygroundCliWorker(new EmscriptenDownloadMonitor()),\n\tundefined,\n\tparentPort!\n);\n\n// Confirm that the worker script has initialized.\nparentPort!.postMessage('worker-script-initialized');\n"],"names":["mountResources","php","mounts","mount","createNodeFsMountHandler","tracePhpWasm","processId","format","args","sprintf","PlaygroundCliWorker","PHPWorker","monitor","absoluteUrl","mountsBeforeWpInstall","mountsAfterWpInstall","phpVersion","wordPressZip","sqliteIntegrationPluginZip","firstProcessId","processIdSpaceLength","dataSqlPath","followSymlinks","trace","nextProcessId","lastProcessId","fileLockManager","consumeAPI","parentPort","constants","requestHandler","bootWordPress","loadNodeRuntime","rootCertificates","primaryPhp","setApiReady","e","setAPIError","exposeAPI","EmscriptenDownloadMonitor"],"mappings":"kSA8BA,SAASA,EAAeC,EAAUC,EAAiB,CAClD,UAAWC,KAASD,EACfD,EAAA,MAAME,EAAM,OAAO,EACvBF,EAAI,MAAME,EAAM,QAASC,EAAAA,yBAAyBD,EAAM,QAAQ,CAAC,CAEnE,CASA,SAASE,EAAaC,EAAmBC,KAAmBC,EAAa,CAEhE,QAAA,IACP,YAAY,MAAM,QAAQ,CAAC,EAAE,SAAS,GAAI,GAAG,EAC7CF,EAAU,SAAW,EAAA,SAAS,GAAI,GAAG,EACrCG,EAAA,QAAQF,EAAQ,GAAGC,CAAI,CACxB,CACD,CAEO,MAAME,UAA4BC,EAAAA,SAAU,CAGlD,YAAYC,EAAoC,CAC/C,MAAM,OAAWA,CAAO,EAHhB,KAAA,OAAA,EAAA,CAMT,MAAM,KAAK,CACV,YAAAC,EACA,sBAAAC,EACA,qBAAAC,EACA,WAAAC,EAAa,MACb,aAAAC,EACA,2BAAAC,EACA,eAAAC,EACA,qBAAAC,EACA,YAAAC,EACA,eAAAC,EACA,MAAAC,CAAA,EAC4B,CAC5B,GAAI,KAAK,OACF,MAAA,IAAI,MAAM,2BAA2B,EAE5C,KAAK,OAAS,GAEd,IAAIC,EAAgBL,EACd,MAAAM,EAAgBN,EAAiBC,EAAuB,EACxDM,EAAkBC,aAA4BC,YAAW,EAC/D,MAAMF,EAAgB,YAAY,EAE9B,GAAA,CACH,MAAMG,EACL,CACC,SAAU,GACV,aAAc,GACd,iBAAkB,EACnB,EAEKC,EAAiB,MAAMC,gBAAc,CAC1C,QAASlB,EACT,iBAAkB,SAAY,CAC7B,MAAMP,EAAYkB,EAElB,OAAIA,EAAgBC,EACnBD,IAGgBA,EAAAL,EAGV,MAAMa,kBAAgBhB,EAAY,CACxC,kBAAmB,CAClB,gBAAAU,EACA,UAAApB,EACA,MAAOiB,EAAQlB,EAAe,MAC/B,EACA,eAAAiB,CAAA,CACA,CACF,EACA,aACCL,IAAiB,OACd,IAAI,KAAK,CAACA,CAAY,EAAG,eAAe,EACxC,OACJ,2BACCC,IAA+B,OAC5B,IAAI,KACJ,CAACA,CAA0B,EAC3B,+BAEA,EAAA,OACJ,SAAU,MACV,YAAa,CACZ,iCACCe,EAAAA,iBAAiB,KAAK;AAAA,CAAI,CAC5B,EACA,UAAAJ,EACA,cAAe,CACd,iBAAkB,iCAClB,gBAAiB,IACjB,kBAAmB,EACpB,EACA,MAAO,CACN,MAAM,qBAAqB5B,EAAK,CAC/BD,EAAeC,EAAKa,CAAqB,CAAA,CAE3C,EACA,YAAa,GACb,YAAAO,CAAA,CACA,EACD,KAAK,6BAA6BS,CAAc,EAE1C,MAAAI,EAAa,MAAMJ,EAAe,cAAc,EAChD,MAAA,KAAK,cAAcI,CAAU,EAEnClC,EAAekC,EAAYnB,CAAoB,EAEnCoB,EAAA,QACJC,EAAG,CACX,MAAAC,EAAYD,CAAU,EAChBA,CAAA,CACP,CAID,MAAM,SAAU,CACT,MAAA,KAAK,OAAO,YAAY,EAAE,CAAA,CAElC,CAEA,KAAM,CAACD,EAAaE,CAAW,EAAIC,EAAA,UAClC,IAAI5B,EAAoB,IAAI6B,EAAAA,yBAA2B,EACvD,OACAX,EAAAA,UACD,EAGAA,EAAAA,WAAY,YAAY,2BAA2B"}
1
+ {"version":3,"file":"worker-thread.cjs","sources":["../../../../packages/playground/cli/src/worker-thread.ts"],"sourcesContent":["import type { FileLockManager } from '@php-wasm/node';\nimport { createNodeFsMountHandler, loadNodeRuntime } from '@php-wasm/node';\nimport { EmscriptenDownloadMonitor } from '@php-wasm/progress';\nimport type { PHP, RemoteAPI, SupportedPHPVersion } from '@php-wasm/universal';\nimport {\n\tPHPWorker,\n\tconsumeAPI,\n\tconsumeAPISync,\n\texposeAPI,\n} from '@php-wasm/universal';\nimport { sprintf } from '@php-wasm/util';\nimport { bootWordPress } from '@wp-playground/wordpress';\nimport { rootCertificates } from 'tls';\nimport { jspi } from 'wasm-feature-detect';\nimport { MessageChannel, type MessagePort, parentPort } from 'worker_threads';\n\nexport interface Mount {\n\thostPath: string;\n\tvfsPath: string;\n}\n\nexport type PrimaryWorkerBootOptions = {\n\twpVersion?: string;\n\tphpVersion?: SupportedPHPVersion;\n\tabsoluteUrl: string;\n\tmountsBeforeWpInstall: Array<Mount>;\n\tmountsAfterWpInstall: Array<Mount>;\n\twordPressZip?: ArrayBuffer;\n\tsqliteIntegrationPluginZip?: ArrayBuffer;\n\tfirstProcessId: number;\n\tprocessIdSpaceLength: number;\n\tdataSqlPath?: string;\n\tfollowSymlinks: boolean;\n\ttrace: boolean;\n\t/**\n\t * When true, Playground will not send cookies to the client but will manage\n\t * them internally. This can be useful in environments that can't store cookies,\n\t * e.g. VS Code WebView.\n\t *\n\t * Default: false.\n\t */\n\tinternalCookieStore?: boolean;\n};\n\nfunction mountResources(php: PHP, mounts: Mount[]) {\n\tfor (const mount of mounts) {\n\t\tphp.mkdir(mount.vfsPath);\n\t\tphp.mount(mount.vfsPath, createNodeFsMountHandler(mount.hostPath));\n\t}\n}\n\n/**\n * Print trace messages from PHP-WASM.\n *\n * @param {number} processId - The process ID.\n * @param {string} format - The format string.\n * @param {...any} args - The arguments.\n */\nfunction tracePhpWasm(processId: number, format: string, ...args: any[]) {\n\t// eslint-disable-next-line no-console\n\tconsole.log(\n\t\tperformance.now().toFixed(6).padStart(15, '0'),\n\t\tprocessId.toString().padStart(16, '0'),\n\t\tsprintf(format, ...args)\n\t);\n}\n\nexport class PlaygroundCliWorker extends PHPWorker {\n\tbooted = false;\n\tfileLockManager: RemoteAPI<FileLockManager> | FileLockManager | undefined;\n\n\tconstructor(monitor: EmscriptenDownloadMonitor) {\n\t\tsuper(undefined, monitor);\n\t}\n\n\t/**\n\t * Call this method before boot() to use file locking.\n\t *\n\t * This method is separate from boot() to simplify the related Comlink.transferHandlers\n\t * setup – if an argument is a MessagePort, we're transferring it, not copying it.\n\t *\n\t * @see comlink-sync.ts\n\t * @see phpwasm-emscripten-library-file-locking-for-node.js\n\t */\n\tasync useFileLockManager(port: MessagePort) {\n\t\tif (await jspi()) {\n\t\t\t/**\n\t\t\t * If JSPI is available, php.js supports both synchronous and asynchronous locking syscalls.\n\t\t\t * Web browsers, however, only support asynchronous message passing so let's use the\n\t\t\t * asynchronous API. Every method call will return a promise.\n\t\t\t *\n\t\t\t * @see comlink-sync.ts\n\t\t\t * @see phpwasm-emscripten-library-file-locking-for-node.js\n\t\t\t */\n\t\t\tthis.fileLockManager = consumeAPI<FileLockManager>(port);\n\t\t} else {\n\t\t\t/**\n\t\t\t * If JSPI is not available, php.js only supports synchronous locking syscalls.\n\t\t\t * Let's use the synchronous API. Every method call will block this thread\n\t\t\t * until the result is available.\n\t\t\t *\n\t\t\t * @see comlink-sync.ts\n\t\t\t * @see phpwasm-emscripten-library-file-locking-for-node.js\n\t\t\t */\n\t\t\tthis.fileLockManager = await consumeAPISync<FileLockManager>(port);\n\t\t}\n\t}\n\n\tasync boot({\n\t\tabsoluteUrl,\n\t\tmountsBeforeWpInstall,\n\t\tmountsAfterWpInstall,\n\t\tphpVersion = '8.0',\n\t\twordPressZip,\n\t\tsqliteIntegrationPluginZip,\n\t\tfirstProcessId,\n\t\tprocessIdSpaceLength,\n\t\tdataSqlPath,\n\t\tfollowSymlinks,\n\t\ttrace,\n\t\tinternalCookieStore,\n\t}: PrimaryWorkerBootOptions) {\n\t\tif (this.booted) {\n\t\t\tthrow new Error('Playground already booted');\n\t\t}\n\t\tthis.booted = true;\n\n\t\tlet nextProcessId = firstProcessId;\n\t\tconst lastProcessId = firstProcessId + processIdSpaceLength - 1;\n\n\t\ttry {\n\t\t\tconst constants: Record<string, string | number | boolean | null> =\n\t\t\t\t{\n\t\t\t\t\tWP_DEBUG: true,\n\t\t\t\t\tWP_DEBUG_LOG: true,\n\t\t\t\t\tWP_DEBUG_DISPLAY: false,\n\t\t\t\t};\n\n\t\t\tconst requestHandler = await bootWordPress({\n\t\t\t\tsiteUrl: absoluteUrl,\n\t\t\t\tcreatePhpRuntime: async () => {\n\t\t\t\t\tconst processId = nextProcessId;\n\n\t\t\t\t\tif (nextProcessId < lastProcessId) {\n\t\t\t\t\t\tnextProcessId++;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// We've reached the end of the process ID space. Start over.\n\t\t\t\t\t\tnextProcessId = firstProcessId;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn await loadNodeRuntime(phpVersion, {\n\t\t\t\t\t\temscriptenOptions: {\n\t\t\t\t\t\t\tfileLockManager: this.fileLockManager!,\n\t\t\t\t\t\t\tprocessId,\n\t\t\t\t\t\t\ttrace: trace ? tracePhpWasm : undefined,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tfollowSymlinks,\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\twordPressZip:\n\t\t\t\t\twordPressZip !== undefined\n\t\t\t\t\t\t? new File([wordPressZip], 'wordpress.zip')\n\t\t\t\t\t\t: undefined,\n\t\t\t\tsqliteIntegrationPluginZip:\n\t\t\t\t\tsqliteIntegrationPluginZip !== undefined\n\t\t\t\t\t\t? new File(\n\t\t\t\t\t\t\t\t[sqliteIntegrationPluginZip],\n\t\t\t\t\t\t\t\t'sqlite-integration-plugin.zip'\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: undefined,\n\t\t\t\tsapiName: 'cli',\n\t\t\t\tcreateFiles: {\n\t\t\t\t\t'/internal/shared/ca-bundle.crt':\n\t\t\t\t\t\trootCertificates.join('\\n'),\n\t\t\t\t},\n\t\t\t\tconstants,\n\t\t\t\tphpIniEntries: {\n\t\t\t\t\t'openssl.cafile': '/internal/shared/ca-bundle.crt',\n\t\t\t\t\tallow_url_fopen: '1',\n\t\t\t\t\tdisable_functions: '',\n\t\t\t\t},\n\t\t\t\thooks: {\n\t\t\t\t\tasync beforeWordPressFiles(php) {\n\t\t\t\t\t\tmountResources(php, mountsBeforeWpInstall);\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tcookieStore: internalCookieStore ? undefined : false,\n\t\t\t\tdataSqlPath,\n\t\t\t});\n\t\t\tthis.__internal_setRequestHandler(requestHandler);\n\n\t\t\tconst primaryPhp = await requestHandler.getPrimaryPhp();\n\t\t\tawait this.setPrimaryPHP(primaryPhp);\n\n\t\t\tmountResources(primaryPhp, mountsAfterWpInstall);\n\n\t\t\tsetApiReady();\n\t\t} catch (e) {\n\t\t\tsetAPIError(e as Error);\n\t\t\tthrow e;\n\t\t}\n\t}\n\n\t// Provide a named disposal method that can be invoked via comlink.\n\tasync dispose() {\n\t\tawait this[Symbol.asyncDispose]();\n\t}\n}\n\nconst phpChannel = new MessageChannel();\n\nconst [setApiReady, setAPIError] = exposeAPI(\n\tnew PlaygroundCliWorker(new EmscriptenDownloadMonitor()),\n\tundefined,\n\tphpChannel.port1\n);\n\nparentPort!.postMessage(\n\t{\n\t\tcommand: 'worker-script-initialized',\n\t\tphpPort: phpChannel.port2,\n\t},\n\t[phpChannel.port2 as any]\n);\n"],"names":["mountResources","php","mounts","mount","createNodeFsMountHandler","tracePhpWasm","processId","format","args","sprintf","PlaygroundCliWorker","PHPWorker","monitor","port","jspi","consumeAPI","consumeAPISync","absoluteUrl","mountsBeforeWpInstall","mountsAfterWpInstall","phpVersion","wordPressZip","sqliteIntegrationPluginZip","firstProcessId","processIdSpaceLength","dataSqlPath","followSymlinks","trace","internalCookieStore","nextProcessId","lastProcessId","constants","requestHandler","bootWordPress","loadNodeRuntime","rootCertificates","primaryPhp","setApiReady","e","setAPIError","phpChannel","MessageChannel","exposeAPI","EmscriptenDownloadMonitor","parentPort"],"mappings":"oUA4CA,SAASA,EAAeC,EAAUC,EAAiB,CAClD,UAAWC,KAASD,EACfD,EAAA,MAAME,EAAM,OAAO,EACvBF,EAAI,MAAME,EAAM,QAASC,EAAAA,yBAAyBD,EAAM,QAAQ,CAAC,CAEnE,CASA,SAASE,EAAaC,EAAmBC,KAAm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a,CACZ,iCACCa,EAAAA,iBAAiB,KAAK;AAAA,CAAI,CAC5B,EACA,UAAAJ,EACA,cAAe,CACd,iBAAkB,iCAClB,gBAAiB,IACjB,kBAAmB,EACpB,EACA,MAAO,CACN,MAAM,qBAAqB9B,EAAK,CAC/BD,EAAeC,EAAKiB,CAAqB,CAAA,CAE3C,EACA,YAAaU,EAAsB,OAAY,GAC/C,YAAAH,CAAA,CACA,EACD,KAAK,6BAA6BO,CAAc,EAE1C,MAAAI,EAAa,MAAMJ,EAAe,cAAc,EAChD,MAAA,KAAK,cAAcI,CAAU,EAEnCpC,EAAeoC,EAAYjB,CAAoB,EAEnCkB,EAAA,QACJC,EAAG,CACX,MAAAC,EAAYD,CAAU,EAChBA,CAAA,CACP,CAID,MAAM,SAAU,CACT,MAAA,KAAK,OAAO,YAAY,EAAE,CAAA,CAElC,CAEA,MAAME,EAAa,IAAIC,EAAAA,eAEjB,CAACJ,EAAaE,CAAW,EAAIG,EAAA,UAClC,IAAIhC,EAAoB,IAAIiC,EAAAA,yBAA2B,EACvD,OACAH,EAAW,KACZ,EAEAI,EAAAA,WAAY,YACX,CACC,QAAS,4BACT,QAASJ,EAAW,KACrB,EACA,CAACA,EAAW,KAAY,CACzB"}
@@ -1,6 +1,9 @@
1
- import type { SupportedPHPVersion } from '@php-wasm/universal';
2
- import { PHPWorker } from '@php-wasm/universal';
1
+ /// <reference types="node" />
2
+ import type { FileLockManager } from '@php-wasm/node';
3
3
  import { EmscriptenDownloadMonitor } from '@php-wasm/progress';
4
+ import type { RemoteAPI, SupportedPHPVersion } from '@php-wasm/universal';
5
+ import { PHPWorker } from '@php-wasm/universal';
6
+ import { type MessagePort } from 'worker_threads';
4
7
  export interface Mount {
5
8
  hostPath: string;
6
9
  vfsPath: string;
@@ -18,10 +21,29 @@ export type PrimaryWorkerBootOptions = {
18
21
  dataSqlPath?: string;
19
22
  followSymlinks: boolean;
20
23
  trace: boolean;
24
+ /**
25
+ * When true, Playground will not send cookies to the client but will manage
26
+ * them internally. This can be useful in environments that can't store cookies,
27
+ * e.g. VS Code WebView.
28
+ *
29
+ * Default: false.
30
+ */
31
+ internalCookieStore?: boolean;
21
32
  };
22
33
  export declare class PlaygroundCliWorker extends PHPWorker {
23
34
  booted: boolean;
35
+ fileLockManager: RemoteAPI<FileLockManager> | FileLockManager | undefined;
24
36
  constructor(monitor: EmscriptenDownloadMonitor);
25
- boot({ absoluteUrl, mountsBeforeWpInstall, mountsAfterWpInstall, phpVersion, wordPressZip, sqliteIntegrationPluginZip, firstProcessId, processIdSpaceLength, dataSqlPath, followSymlinks, trace, }: PrimaryWorkerBootOptions): Promise<void>;
37
+ /**
38
+ * Call this method before boot() to use file locking.
39
+ *
40
+ * This method is separate from boot() to simplify the related Comlink.transferHandlers
41
+ * setup – if an argument is a MessagePort, we're transferring it, not copying it.
42
+ *
43
+ * @see comlink-sync.ts
44
+ * @see phpwasm-emscripten-library-file-locking-for-node.js
45
+ */
46
+ useFileLockManager(port: MessagePort): Promise<void>;
47
+ boot({ absoluteUrl, mountsBeforeWpInstall, mountsAfterWpInstall, phpVersion, wordPressZip, sqliteIntegrationPluginZip, firstProcessId, processIdSpaceLength, dataSqlPath, followSymlinks, trace, internalCookieStore, }: PrimaryWorkerBootOptions): Promise<void>;
26
48
  dispose(): Promise<void>;
27
49
  }
package/worker-thread.js CHANGED
@@ -1,60 +1,73 @@
1
- import { exposeAPI as g, PHPWorker as v, consumeAPI as W } from "@php-wasm/universal";
2
- import { loadNodeRuntime as k, createNodeFsMountHandler as E } from "@php-wasm/node";
3
- import { EmscriptenDownloadMonitor as D } from "@php-wasm/progress";
4
- import { bootWordPress as F } from "@wp-playground/wordpress";
1
+ import { loadNodeRuntime as k, createNodeFsMountHandler as _ } from "@php-wasm/node";
2
+ import { EmscriptenDownloadMonitor as v } from "@php-wasm/progress";
3
+ import { exposeAPI as M, PHPWorker as W, consumeAPI as E, consumeAPISync as F } from "@php-wasm/universal";
5
4
  import { sprintf as I } from "@php-wasm/util";
6
- import { parentPort as a } from "worker_threads";
5
+ import { bootWordPress as L } from "@wp-playground/wordpress";
7
6
  import { rootCertificates as S } from "tls";
8
- function u(t, e) {
7
+ import { j as A } from "./index-CddYZc1x.js";
8
+ import { MessageChannel as D, parentPort as x } from "worker_threads";
9
+ function m(t, e) {
9
10
  for (const o of e)
10
- t.mkdir(o.vfsPath), t.mount(o.vfsPath, E(o.hostPath));
11
+ t.mkdir(o.vfsPath), t.mount(o.vfsPath, _(o.hostPath));
11
12
  }
12
- function x(t, e, ...o) {
13
+ function H(t, e, ...o) {
13
14
  console.log(
14
15
  performance.now().toFixed(6).padStart(15, "0"),
15
16
  t.toString().padStart(16, "0"),
16
17
  I(e, ...o)
17
18
  );
18
19
  }
19
- class A extends v {
20
+ class R extends W {
20
21
  constructor(e) {
21
22
  super(void 0, e), this.booted = !1;
22
23
  }
24
+ /**
25
+ * Call this method before boot() to use file locking.
26
+ *
27
+ * This method is separate from boot() to simplify the related Comlink.transferHandlers
28
+ * setup – if an argument is a MessagePort, we're transferring it, not copying it.
29
+ *
30
+ * @see comlink-sync.ts
31
+ * @see phpwasm-emscripten-library-file-locking-for-node.js
32
+ */
33
+ async useFileLockManager(e) {
34
+ await A() ? this.fileLockManager = E(e) : this.fileLockManager = await F(e);
35
+ }
23
36
  async boot({
24
37
  absoluteUrl: e,
25
38
  mountsBeforeWpInstall: o,
26
- mountsAfterWpInstall: P,
27
- phpVersion: f = "8.0",
39
+ mountsAfterWpInstall: f,
40
+ phpVersion: h = "8.0",
28
41
  wordPressZip: c,
29
42
  sqliteIntegrationPluginZip: l,
30
43
  firstProcessId: i,
31
- processIdSpaceLength: h,
32
- dataSqlPath: w,
33
- followSymlinks: y,
34
- trace: b
44
+ processIdSpaceLength: u,
45
+ dataSqlPath: P,
46
+ followSymlinks: w,
47
+ trace: y,
48
+ internalCookieStore: g
35
49
  }) {
36
50
  if (this.booted)
37
51
  throw new Error("Playground already booted");
38
52
  this.booted = !0;
39
53
  let r = i;
40
- const _ = i + h - 1, d = W(a);
41
- await d.isConnected();
54
+ const b = i + u - 1;
42
55
  try {
43
56
  const s = {
44
57
  WP_DEBUG: !0,
45
58
  WP_DEBUG_LOG: !0,
46
59
  WP_DEBUG_DISPLAY: !1
47
- }, p = await F({
60
+ }, p = await L({
48
61
  siteUrl: e,
49
62
  createPhpRuntime: async () => {
50
- const n = r;
51
- return r < _ ? r++ : r = i, await k(f, {
63
+ const a = r;
64
+ return r < b ? r++ : r = i, await k(h, {
52
65
  emscriptenOptions: {
53
- fileLockManager: d,
54
- processId: n,
55
- trace: b ? x : void 0
66
+ fileLockManager: this.fileLockManager,
67
+ processId: a,
68
+ trace: y ? H : void 0
56
69
  },
57
- followSymlinks: y
70
+ followSymlinks: w
58
71
  });
59
72
  },
60
73
  wordPressZip: c !== void 0 ? new File([c], "wordpress.zip") : void 0,
@@ -74,18 +87,18 @@ class A extends v {
74
87
  disable_functions: ""
75
88
  },
76
89
  hooks: {
77
- async beforeWordPressFiles(n) {
78
- u(n, o);
90
+ async beforeWordPressFiles(a) {
91
+ m(a, o);
79
92
  }
80
93
  },
81
- cookieStore: !1,
82
- dataSqlPath: w
94
+ cookieStore: g ? void 0 : !1,
95
+ dataSqlPath: P
83
96
  });
84
97
  this.__internal_setRequestHandler(p);
85
- const m = await p.getPrimaryPhp();
86
- await this.setPrimaryPHP(m), u(m, P), H();
98
+ const d = await p.getPrimaryPhp();
99
+ await this.setPrimaryPHP(d), m(d, f), C();
87
100
  } catch (s) {
88
- throw R(s), s;
101
+ throw G(s), s;
89
102
  }
90
103
  }
91
104
  // Provide a named disposal method that can be invoked via comlink.
@@ -93,13 +106,19 @@ class A extends v {
93
106
  await this[Symbol.asyncDispose]();
94
107
  }
95
108
  }
96
- const [H, R] = g(
97
- new A(new D()),
109
+ const n = new D(), [C, G] = M(
110
+ new R(new v()),
98
111
  void 0,
99
- a
112
+ n.port1
113
+ );
114
+ x.postMessage(
115
+ {
116
+ command: "worker-script-initialized",
117
+ phpPort: n.port2
118
+ },
119
+ [n.port2]
100
120
  );
101
- a.postMessage("worker-script-initialized");
102
121
  export {
103
- A as PlaygroundCliWorker
122
+ R as PlaygroundCliWorker
104
123
  };
105
124
  //# sourceMappingURL=worker-thread.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"worker-thread.js","sources":["../../../../packages/playground/cli/src/worker-thread.ts"],"sourcesContent":["import type { PHP, SupportedPHPVersion } from '@php-wasm/universal';\nimport { PHPWorker, consumeAPI, exposeAPI } from '@php-wasm/universal';\nimport type { FileLockManager } from '@php-wasm/node';\nimport { createNodeFsMountHandler, loadNodeRuntime } from '@php-wasm/node';\nimport { EmscriptenDownloadMonitor } from '@php-wasm/progress';\nimport { bootWordPress } from '@wp-playground/wordpress';\nimport { sprintf } from '@php-wasm/util';\nimport { parentPort } from 'worker_threads';\nimport { rootCertificates } from 'tls';\n\nexport interface Mount {\n\thostPath: string;\n\tvfsPath: string;\n}\n\nexport type PrimaryWorkerBootOptions = {\n\twpVersion?: string;\n\tphpVersion?: SupportedPHPVersion;\n\tabsoluteUrl: string;\n\tmountsBeforeWpInstall: Array<Mount>;\n\tmountsAfterWpInstall: Array<Mount>;\n\twordPressZip?: ArrayBuffer;\n\tsqliteIntegrationPluginZip?: ArrayBuffer;\n\tfirstProcessId: number;\n\tprocessIdSpaceLength: number;\n\tdataSqlPath?: string;\n\tfollowSymlinks: boolean;\n\ttrace: boolean;\n};\n\nfunction mountResources(php: PHP, mounts: Mount[]) {\n\tfor (const mount of mounts) {\n\t\tphp.mkdir(mount.vfsPath);\n\t\tphp.mount(mount.vfsPath, createNodeFsMountHandler(mount.hostPath));\n\t}\n}\n\n/**\n * Print trace messages from PHP-WASM.\n *\n * @param {number} processId - The process ID.\n * @param {string} format - The format string.\n * @param {...any} args - The arguments.\n */\nfunction tracePhpWasm(processId: number, format: string, ...args: any[]) {\n\t// eslint-disable-next-line no-console\n\tconsole.log(\n\t\tperformance.now().toFixed(6).padStart(15, '0'),\n\t\tprocessId.toString().padStart(16, '0'),\n\t\tsprintf(format, ...args)\n\t);\n}\n\nexport class PlaygroundCliWorker extends PHPWorker {\n\tbooted = false;\n\n\tconstructor(monitor: EmscriptenDownloadMonitor) {\n\t\tsuper(undefined, monitor);\n\t}\n\n\tasync boot({\n\t\tabsoluteUrl,\n\t\tmountsBeforeWpInstall,\n\t\tmountsAfterWpInstall,\n\t\tphpVersion = '8.0',\n\t\twordPressZip,\n\t\tsqliteIntegrationPluginZip,\n\t\tfirstProcessId,\n\t\tprocessIdSpaceLength,\n\t\tdataSqlPath,\n\t\tfollowSymlinks,\n\t\ttrace,\n\t}: PrimaryWorkerBootOptions) {\n\t\tif (this.booted) {\n\t\t\tthrow new Error('Playground already booted');\n\t\t}\n\t\tthis.booted = true;\n\n\t\tlet nextProcessId = firstProcessId;\n\t\tconst lastProcessId = firstProcessId + processIdSpaceLength - 1;\n\t\tconst fileLockManager = consumeAPI<FileLockManager>(parentPort!);\n\t\tawait fileLockManager.isConnected();\n\n\t\ttry {\n\t\t\tconst constants: Record<string, string | number | boolean | null> =\n\t\t\t\t{\n\t\t\t\t\tWP_DEBUG: true,\n\t\t\t\t\tWP_DEBUG_LOG: true,\n\t\t\t\t\tWP_DEBUG_DISPLAY: false,\n\t\t\t\t};\n\n\t\t\tconst requestHandler = await bootWordPress({\n\t\t\t\tsiteUrl: absoluteUrl,\n\t\t\t\tcreatePhpRuntime: async () => {\n\t\t\t\t\tconst processId = nextProcessId;\n\n\t\t\t\t\tif (nextProcessId < lastProcessId) {\n\t\t\t\t\t\tnextProcessId++;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// We've reached the end of the process ID space. Start over.\n\t\t\t\t\t\tnextProcessId = firstProcessId;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn await loadNodeRuntime(phpVersion, {\n\t\t\t\t\t\temscriptenOptions: {\n\t\t\t\t\t\t\tfileLockManager,\n\t\t\t\t\t\t\tprocessId,\n\t\t\t\t\t\t\ttrace: trace ? tracePhpWasm : undefined,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tfollowSymlinks,\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\twordPressZip:\n\t\t\t\t\twordPressZip !== undefined\n\t\t\t\t\t\t? new File([wordPressZip], 'wordpress.zip')\n\t\t\t\t\t\t: undefined,\n\t\t\t\tsqliteIntegrationPluginZip:\n\t\t\t\t\tsqliteIntegrationPluginZip !== undefined\n\t\t\t\t\t\t? new File(\n\t\t\t\t\t\t\t\t[sqliteIntegrationPluginZip],\n\t\t\t\t\t\t\t\t'sqlite-integration-plugin.zip'\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: undefined,\n\t\t\t\tsapiName: 'cli',\n\t\t\t\tcreateFiles: {\n\t\t\t\t\t'/internal/shared/ca-bundle.crt':\n\t\t\t\t\t\trootCertificates.join('\\n'),\n\t\t\t\t},\n\t\t\t\tconstants,\n\t\t\t\tphpIniEntries: {\n\t\t\t\t\t'openssl.cafile': '/internal/shared/ca-bundle.crt',\n\t\t\t\t\tallow_url_fopen: '1',\n\t\t\t\t\tdisable_functions: '',\n\t\t\t\t},\n\t\t\t\thooks: {\n\t\t\t\t\tasync beforeWordPressFiles(php) {\n\t\t\t\t\t\tmountResources(php, mountsBeforeWpInstall);\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tcookieStore: false,\n\t\t\t\tdataSqlPath,\n\t\t\t});\n\t\t\tthis.__internal_setRequestHandler(requestHandler);\n\n\t\t\tconst primaryPhp = await requestHandler.getPrimaryPhp();\n\t\t\tawait this.setPrimaryPHP(primaryPhp);\n\n\t\t\tmountResources(primaryPhp, mountsAfterWpInstall);\n\n\t\t\tsetApiReady();\n\t\t} catch (e) {\n\t\t\tsetAPIError(e as Error);\n\t\t\tthrow e;\n\t\t}\n\t}\n\n\t// Provide a named disposal method that can be invoked via comlink.\n\tasync dispose() {\n\t\tawait this[Symbol.asyncDispose]();\n\t}\n}\n\nconst [setApiReady, setAPIError] = exposeAPI(\n\tnew PlaygroundCliWorker(new EmscriptenDownloadMonitor()),\n\tundefined,\n\tparentPort!\n);\n\n// Confirm that the worker script has initialized.\nparentPort!.postMessage('worker-script-initialized');\n"],"names":["mountResources","php","mounts","mount","createNodeFsMountHandler","tracePhpWasm","processId","format","args","sprintf","PlaygroundCliWorker","PHPWorker","monitor","absoluteUrl","mountsBeforeWpInstall","mountsAfterWpInstall","phpVersion","wordPressZip","sqliteIntegrationPluginZip","firstProcessId","processIdSpaceLength","dataSqlPath","followSymlinks","trace","nextProcessId","lastProcessId","fileLockManager","consumeAPI","parentPort","constants","requestHandler","bootWordPress","loadNodeRuntime","rootCertificates","primaryPhp","setApiReady","e","setAPIError","exposeAPI","EmscriptenDownloadMonitor"],"mappings":";;;;;;;AA8BA,SAASA,EAAeC,GAAUC,GAAiB;AAClD,aAAWC,KAASD;AACf,IAAAD,EAAA,MAAME,EAAM,OAAO,GACvBF,EAAI,MAAME,EAAM,SAASC,EAAyBD,EAAM,QAAQ,CAAC;AAEnE;AASA,SAASE,EAAaC,GAAmBC,MAAmBC,GAAa;AAEhE,UAAA;AAAA,IACP,YAAY,MAAM,QAAQ,CAAC,EAAE,SAAS,IAAI,GAAG;AAAA,IAC7CF,EAAU,SAAW,EAAA,SAAS,IAAI,GAAG;AAAA,IACrCG,EAAQF,GAAQ,GAAGC,CAAI;AAAA,EACxB;AACD;AAEO,MAAME,UAA4BC,EAAU;AAAA,EAGlD,YAAYC,GAAoC;AAC/C,UAAM,QAAWA,CAAO,GAHhB,KAAA,SAAA;AAAA,EAAA;AAAA,EAMT,MAAM,KAAK;AAAA,IACV,aAAAC;AAAA,IACA,uBAAAC;AAAA,IACA,sBAAAC;AAAA,IACA,YAAAC,IAAa;AAAA,IACb,cAAAC;AAAA,IACA,4BAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,sBAAAC;AAAA,IACA,aAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,OAAAC;AAAA,EAAA,GAC4B;AAC5B,QAAI,KAAK;AACF,YAAA,IA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oB,GAEnCoB,EAAA;AAAA,aACJC,GAAG;AACX,YAAAC,EAAYD,CAAU,GAChBA;AAAA,IAAA;AAAA,EACP;AAAA;AAAA,EAID,MAAM,UAAU;AACT,UAAA,KAAK,OAAO,YAAY,EAAE;AAAA,EAAA;AAElC;AAEA,MAAM,CAACD,GAAaE,CAAW,IAAIC;AAAA,EAClC,IAAI5B,EAAoB,IAAI6B,GAA2B;AAAA,EACvD;AAAA,EACAX;AACD;AAGAA,EAAY,YAAY,2BAA2B;"}
1
+ {"version":3,"file":"worker-thread.js","sources":["../../../../packages/playground/cli/src/worker-thread.ts"],"sourcesContent":["import type { FileLockManager } from '@php-wasm/node';\nimport { createNodeFsMountHandler, loadNodeRuntime } from '@php-wasm/node';\nimport { EmscriptenDownloadMonitor } from '@php-wasm/progress';\nimport type { PHP, RemoteAPI, SupportedPHPVersion } from '@php-wasm/universal';\nimport {\n\tPHPWorker,\n\tconsumeAPI,\n\tconsumeAPISync,\n\texposeAPI,\n} from '@php-wasm/universal';\nimport { sprintf } from '@php-wasm/util';\nimport { bootWordPress } from '@wp-playground/wordpress';\nimport { rootCertificates } from 'tls';\nimport { jspi } from 'wasm-feature-detect';\nimport { MessageChannel, type MessagePort, parentPort } from 'worker_threads';\n\nexport interface Mount {\n\thostPath: string;\n\tvfsPath: string;\n}\n\nexport type PrimaryWorkerBootOptions = {\n\twpVersion?: string;\n\tphpVersion?: SupportedPHPVersion;\n\tabsoluteUrl: string;\n\tmountsBeforeWpInstall: Array<Mount>;\n\tmountsAfterWpInstall: Array<Mount>;\n\twordPressZip?: ArrayBuffer;\n\tsqliteIntegrationPluginZip?: ArrayBuffer;\n\tfirstProcessId: number;\n\tprocessIdSpaceLength: number;\n\tdataSqlPath?: string;\n\tfollowSymlinks: boolean;\n\ttrace: boolean;\n\t/**\n\t * When true, Playground will not send cookies to the client but will manage\n\t * them internally. This can be useful in environments that can't store cookies,\n\t * e.g. VS Code WebView.\n\t *\n\t * Default: false.\n\t */\n\tinternalCookieStore?: boolean;\n};\n\nfunction mountResources(php: PHP, mounts: Mount[]) {\n\tfor (const mount of mounts) {\n\t\tphp.mkdir(mount.vfsPath);\n\t\tphp.mount(mount.vfsPath, createNodeFsMountHandler(mount.hostPath));\n\t}\n}\n\n/**\n * Print trace messages from PHP-WASM.\n *\n * @param {number} processId - The process ID.\n * @param {string} format - The format string.\n * @param {...any} args - The arguments.\n */\nfunction tracePhpWasm(processId: number, format: string, ...args: any[]) {\n\t// eslint-disable-next-line no-console\n\tconsole.log(\n\t\tperformance.now().toFixed(6).padStart(15, '0'),\n\t\tprocessId.toString().padStart(16, '0'),\n\t\tsprintf(format, ...args)\n\t);\n}\n\nexport class PlaygroundCliWorker extends PHPWorker {\n\tbooted = false;\n\tfileLockManager: RemoteAPI<FileLockManager> | FileLockManager | undefined;\n\n\tconstructor(monitor: EmscriptenDownloadMonitor) {\n\t\tsuper(undefined, monitor);\n\t}\n\n\t/**\n\t * Call this method before boot() to use file locking.\n\t *\n\t * This method is separate from boot() to simplify the related Comlink.transferHandlers\n\t * setup – if an argument is a MessagePort, we're transferring it, not copying it.\n\t *\n\t * @see comlink-sync.ts\n\t * @see phpwasm-emscripten-library-file-locking-for-node.js\n\t */\n\tasync useFileLockManager(port: MessagePort) {\n\t\tif (await jspi()) {\n\t\t\t/**\n\t\t\t * If JSPI is available, php.js supports both synchronous and asynchronous locking syscalls.\n\t\t\t * Web browsers, however, only support asynchronous message passing so let's use the\n\t\t\t * asynchronous API. Every method call will return a promise.\n\t\t\t *\n\t\t\t * @see comlink-sync.ts\n\t\t\t * @see phpwasm-emscripten-library-file-locking-for-node.js\n\t\t\t */\n\t\t\tthis.fileLockManager = consumeAPI<FileLockManager>(port);\n\t\t} else {\n\t\t\t/**\n\t\t\t * If JSPI is not available, php.js only supports synchronous locking syscalls.\n\t\t\t * Let's use the synchronous API. Every method call will block this thread\n\t\t\t * until the result is available.\n\t\t\t *\n\t\t\t * @see comlink-sync.ts\n\t\t\t * @see phpwasm-emscripten-library-file-locking-for-node.js\n\t\t\t */\n\t\t\tthis.fileLockManager = await consumeAPISync<FileLockManager>(port);\n\t\t}\n\t}\n\n\tasync boot({\n\t\tabsoluteUrl,\n\t\tmountsBeforeWpInstall,\n\t\tmountsAfterWpInstall,\n\t\tphpVersion = '8.0',\n\t\twordPressZip,\n\t\tsqliteIntegrationPluginZip,\n\t\tfirstProcessId,\n\t\tprocessIdSpaceLength,\n\t\tdataSqlPath,\n\t\tfollowSymlinks,\n\t\ttrace,\n\t\tinternalCookieStore,\n\t}: PrimaryWorkerBootOptions) {\n\t\tif (this.booted) {\n\t\t\tthrow new Error('Playground already booted');\n\t\t}\n\t\tthis.booted = true;\n\n\t\tlet nextProcessId = firstProcessId;\n\t\tconst lastProcessId = firstProcessId + processIdSpaceLength - 1;\n\n\t\ttry {\n\t\t\tconst constants: Record<string, string | number | boolean | null> =\n\t\t\t\t{\n\t\t\t\t\tWP_DEBUG: true,\n\t\t\t\t\tWP_DEBUG_LOG: true,\n\t\t\t\t\tWP_DEBUG_DISPLAY: false,\n\t\t\t\t};\n\n\t\t\tconst requestHandler = await bootWordPress({\n\t\t\t\tsiteUrl: absoluteUrl,\n\t\t\t\tcreatePhpRuntime: async () => {\n\t\t\t\t\tconst processId = nextProcessId;\n\n\t\t\t\t\tif (nextProcessId < lastProcessId) {\n\t\t\t\t\t\tnextProcessId++;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// We've reached the end of the process ID space. Start over.\n\t\t\t\t\t\tnextProcessId = firstProcessId;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn await loadNodeRuntime(phpVersion, {\n\t\t\t\t\t\temscriptenOptions: {\n\t\t\t\t\t\t\tfileLockManager: this.fileLockManager!,\n\t\t\t\t\t\t\tprocessId,\n\t\t\t\t\t\t\ttrace: trace ? tracePhpWasm : undefined,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tfollowSymlinks,\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\twordPressZip:\n\t\t\t\t\twordPressZip !== undefined\n\t\t\t\t\t\t? new File([wordPressZip], 'wordpress.zip')\n\t\t\t\t\t\t: undefined,\n\t\t\t\tsqliteIntegrationPluginZip:\n\t\t\t\t\tsqliteIntegrationPluginZip !== undefined\n\t\t\t\t\t\t? new File(\n\t\t\t\t\t\t\t\t[sqliteIntegrationPluginZip],\n\t\t\t\t\t\t\t\t'sqlite-integration-plugin.zip'\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: undefined,\n\t\t\t\tsapiName: 'cli',\n\t\t\t\tcreateFiles: {\n\t\t\t\t\t'/internal/shared/ca-bundle.crt':\n\t\t\t\t\t\trootCertificates.join('\\n'),\n\t\t\t\t},\n\t\t\t\tconstants,\n\t\t\t\tphpIniEntries: {\n\t\t\t\t\t'openssl.cafile': '/internal/shared/ca-bundle.crt',\n\t\t\t\t\tallow_url_fopen: '1',\n\t\t\t\t\tdisable_functions: '',\n\t\t\t\t},\n\t\t\t\thooks: {\n\t\t\t\t\tasync beforeWordPressFiles(php) {\n\t\t\t\t\t\tmountResources(php, mountsBeforeWpInstall);\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tcookieStore: internalCookieStore ? undefined : false,\n\t\t\t\tdataSqlPath,\n\t\t\t});\n\t\t\tthis.__internal_setRequestHandler(requestHandler);\n\n\t\t\tconst primaryPhp = await requestHandler.getPrimaryPhp();\n\t\t\tawait this.setPrimaryPHP(primaryPhp);\n\n\t\t\tmountResources(primaryPhp, mountsAfterWpInstall);\n\n\t\t\tsetApiReady();\n\t\t} catch (e) {\n\t\t\tsetAPIError(e as Error);\n\t\t\tthrow e;\n\t\t}\n\t}\n\n\t// Provide a named disposal method that can be invoked via comlink.\n\tasync dispose() {\n\t\tawait this[Symbol.asyncDispose]();\n\t}\n}\n\nconst phpChannel = new MessageChannel();\n\nconst [setApiReady, setAPIError] = exposeAPI(\n\tnew PlaygroundCliWorker(new EmscriptenDownloadMonitor()),\n\tundefined,\n\tphpChannel.port1\n);\n\nparentPort!.postMessage(\n\t{\n\t\tcommand: 'worker-script-initialized',\n\t\tphpPort: phpChannel.port2,\n\t},\n\t[phpChannel.port2 as any]\n);\n"],"names":["mountResources","php","mounts","mount","createNodeFsMountHandler","tracePhpWasm","processId","format","args","sprintf","PlaygroundCliWorker","PHPWorker","monitor","port","jspi","consumeAPI","consumeAPISync","absoluteUrl","mountsBeforeWpInstall","mountsAfterWpInstall","phpVersion","wordPressZip","sqliteIntegrationPluginZip","firstProcessId","processIdSpaceLength","dataSqlPath","followSymlinks","trace","internalCookieStore","nextProcessId","lastProcessId","constants","requestHandler","bootWordPress","loadNodeRuntime","rootCertificates","primaryPhp","setApiReady","e","setAPIError","phpChannel","MessageChannel","exposeAPI","EmscriptenDownloadMonitor","parentPort"],"mappings":";;;;;;;;AA4CA,SAASA,EAAeC,GAAUC,GAAiB;AAClD,aAAWC,KAASD;AACf,IAAAD,EAAA,MAAME,EAAM,OAAO,GACvBF,EAAI,MAAME,EAAM,SAASC,EAAyBD,EAAM,QAAQ,CAAC;AAEnE;AASA,SAASE,EAAaC,GAAmBC,MAAmBC,GAAa;AAEhE,UAAA;AAAA,IACP,YAAY,MAAM,QAAQ,CAAC,EAAE,SAAS,IAAI,GAAG;AAAA,IAC7CF,EAAU,SAAW,EAAA,SAAS,IAAI,GAAG;AAAA,IACrCG,EAAQF,GAAQ,GAAGC,CAAI;AAAA,EACxB;AACD;AAEO,MAAME,UAA4BC,EAAU;AAAA,EAIlD,YAAYC,GAAoC;AAC/C,UAAM,QAAWA,CAAO,GAJhB,KAAA,SAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBT,MAAM,mBAAmBC,GAAmB;AACvC,IAAA,MAAMC,MASJ,KAAA,kBAAkBC,EAA4BF,CAAI,IAUlD,KAAA,kBAAkB,MAAMG,EAAgCH,CAAI;AAAA,EAClE;AAAA,EAGD,MAAM,KAAK;AAAA,IACV,aAAAI;AAAA,IACA,uBA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