@wp-playground/cli 3.0.54 → 3.1.0

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,7 +1,8 @@
1
1
  /// <reference types="node" />
2
+ import { type Pooled } from '@php-wasm/universal';
2
3
  import type { PlaygroundCliBlueprintV1Worker } from './worker-thread-v1';
3
4
  import type { MessagePort as NodeMessagePort } from 'worker_threads';
4
- import { type RunCLIArgs, type SpawnedWorker, type WorkerType } from '../run-cli';
5
+ import { type PlaygroundCliWorker, type RunCLIArgs, type SpawnedWorker, type WorkerType } from '../run-cli';
5
6
  import type { CLIOutput } from '../cli-output';
6
7
  /**
7
8
  * Boots Playground CLI workers using Blueprint version 1.
@@ -11,20 +12,17 @@ import type { CLIOutput } from '../cli-output';
11
12
  */
12
13
  export declare class BlueprintsV1Handler {
13
14
  private siteUrl;
14
- private processIdSpaceLength;
15
15
  private args;
16
16
  private cliOutput;
17
17
  constructor(args: RunCLIArgs, options: {
18
18
  siteUrl: string;
19
- processIdSpaceLength: number;
20
19
  cliOutput: CLIOutput;
21
20
  });
22
21
  getWorkerType(): WorkerType;
23
- bootAndSetUpInitialPlayground(phpPort: NodeMessagePort, fileLockManagerPort: NodeMessagePort, nativeInternalDirPath: string): Promise<import("@php-wasm/universal").RemoteAPI<PlaygroundCliBlueprintV1Worker>>;
24
- bootPlayground({ worker, fileLockManagerPort, firstProcessId, nativeInternalDirPath, }: {
22
+ bootWordPress(playground: Pooled<PlaygroundCliWorker>, workerPostInstallMountsPort: NodeMessagePort): Promise<Pooled<PlaygroundCliWorker>>;
23
+ bootRequestHandler({ worker, fileLockManagerPort, nativeInternalDirPath, }: {
25
24
  worker: SpawnedWorker;
26
25
  fileLockManagerPort: NodeMessagePort;
27
- firstProcessId: number;
28
26
  nativeInternalDirPath: string;
29
27
  }): Promise<import("@php-wasm/universal").RemoteAPI<PlaygroundCliBlueprintV1Worker>>;
30
28
  compileInputBlueprint(additionalBlueprintSteps: any[]): Promise<import("@wp-playground/blueprints").CompiledBlueprintV1>;
@@ -1,61 +1,32 @@
1
1
  /// <reference types="node" />
2
- import type { FileLockManager } from '@php-wasm/node';
2
+ import type { FileLockManager } from '@php-wasm/universal';
3
3
  import { EmscriptenDownloadMonitor } from '@php-wasm/progress';
4
- import type { PathAlias, RemoteAPI, SupportedPHPVersion } from '@php-wasm/universal';
4
+ import type { PathAlias, SupportedPHPVersion } from '@php-wasm/universal';
5
5
  import { PHPWorker } from '@php-wasm/universal';
6
6
  import { type WordPressInstallMode } from '@wp-playground/wordpress';
7
7
  import { type MessagePort } from 'worker_threads';
8
8
  import type { Mount } from '@php-wasm/cli-util';
9
- export type WorkerBootOptions = {
10
- phpVersion: SupportedPHPVersion;
9
+ export type WorkerBootWordPressOptions = {
11
10
  siteUrl: string;
12
- mountsBeforeWpInstall: Array<Mount>;
13
- mountsAfterWpInstall: Array<Mount>;
14
- firstProcessId: number;
15
- processIdSpaceLength: number;
16
- followSymlinks: boolean;
17
- trace: boolean;
18
- /**
19
- * When true, Playground will not send cookies to the client but will manage
20
- * them internally. This can be useful in environments that can't store cookies,
21
- * e.g. VS Code WebView.
22
- *
23
- * Default: false.
24
- */
25
- internalCookieStore?: boolean;
26
- withIntl?: boolean;
27
- withRedis?: boolean;
28
- withMemcached?: boolean;
29
- withXdebug?: boolean;
30
- nativeInternalDirPath: string;
31
- /**
32
- * PHP constants to define via php.defineConstant().
33
- * Process-specific, set for each PHP instance.
34
- */
35
- constants?: Record<string, string | number | boolean | null>;
36
- /**
37
- * Path aliases that map URL prefixes to filesystem paths outside
38
- * the document root. Similar to Nginx's `alias` directive.
39
- */
40
- pathAliases?: PathAlias[];
41
- };
42
- export type PrimaryWorkerBootOptions = WorkerBootOptions & {
43
- wordpressInstallMode: WordPressInstallMode;
44
11
  wpVersion?: string;
12
+ wordpressInstallMode: WordPressInstallMode;
45
13
  wordPressZip?: ArrayBuffer;
46
14
  sqliteIntegrationPluginZip?: ArrayBuffer;
47
15
  dataSqlPath?: string;
16
+ /**
17
+ * PHP constants to define via php.defineConstant().
18
+ */
19
+ constants?: Record<string, string | number | boolean>;
48
20
  };
49
21
  interface WorkerBootRequestHandlerOptions {
50
22
  siteUrl: string;
51
- followSymlinks: boolean;
52
23
  phpVersion: SupportedPHPVersion;
53
- firstProcessId: number;
54
- processIdSpaceLength: number;
24
+ processId: number;
55
25
  trace: boolean;
56
26
  nativeInternalDirPath: string;
57
27
  mountsBeforeWpInstall: Array<Mount>;
58
28
  mountsAfterWpInstall: Array<Mount>;
29
+ followSymlinks: boolean;
59
30
  withIntl?: boolean;
60
31
  withRedis?: boolean;
61
32
  withMemcached?: boolean;
@@ -63,8 +34,9 @@ interface WorkerBootRequestHandlerOptions {
63
34
  pathAliases?: PathAlias[];
64
35
  }
65
36
  export declare class PlaygroundCliBlueprintV1Worker extends PHPWorker {
66
- booted: boolean;
67
- fileLockManager: RemoteAPI<FileLockManager> | FileLockManager | undefined;
37
+ bootedRequestHandler: boolean;
38
+ bootedWordPress: boolean;
39
+ fileLockManager: FileLockManager | undefined;
68
40
  constructor(monitor: EmscriptenDownloadMonitor);
69
41
  /**
70
42
  * Call this method before boot() to use file locking.
@@ -76,10 +48,9 @@ export declare class PlaygroundCliBlueprintV1Worker extends PHPWorker {
76
48
  * @see phpwasm-emscripten-library-file-locking-for-node.js
77
49
  */
78
50
  useFileLockManager(port: MessagePort): Promise<void>;
79
- bootAndSetUpInitialWorker(options: PrimaryWorkerBootOptions): Promise<void>;
80
- hello(): Promise<string>;
81
- bootWorker(args: WorkerBootOptions): Promise<void>;
51
+ bootWordPress(options: WorkerBootWordPressOptions, workerPostInstallMountsPort: MessagePort): Promise<void>;
82
52
  bootRequestHandler(options: WorkerBootRequestHandlerOptions): Promise<void>;
53
+ mountAfterWordPressInstall(mounts: Array<Mount>): Promise<void>;
83
54
  dispose(): Promise<void>;
84
55
  }
85
56
  export {};
@@ -1,8 +1,9 @@
1
1
  /// <reference types="node" />
2
- import type { RemoteAPI } from '@php-wasm/universal';
2
+ import type { Pooled } from '@php-wasm/universal';
3
+ import { type RemoteAPI } from '@php-wasm/universal';
3
4
  import type { PlaygroundCliBlueprintV2Worker } from './worker-thread-v2';
4
5
  import type { MessagePort as NodeMessagePort } from 'worker_threads';
5
- import { type RunCLIArgs, type SpawnedWorker, type WorkerType } from '../run-cli';
6
+ import { type PlaygroundCliWorker, type RunCLIArgs, type SpawnedWorker, type WorkerType } from '../run-cli';
6
7
  import type { CLIOutput } from '../cli-output';
7
8
  /**
8
9
  * Boots Playground CLI workers using Blueprint version 2.
@@ -13,20 +14,17 @@ import type { CLIOutput } from '../cli-output';
13
14
  export declare class BlueprintsV2Handler {
14
15
  private phpVersion;
15
16
  private siteUrl;
16
- private processIdSpaceLength;
17
17
  private args;
18
18
  private cliOutput;
19
19
  constructor(args: RunCLIArgs, options: {
20
20
  siteUrl: string;
21
- processIdSpaceLength: number;
22
21
  cliOutput: CLIOutput;
23
22
  });
24
23
  getWorkerType(): WorkerType;
25
- bootAndSetUpInitialPlayground(phpPort: NodeMessagePort, fileLockManagerPort: NodeMessagePort, nativeInternalDirPath: string): Promise<RemoteAPI<PlaygroundCliBlueprintV2Worker>>;
26
- bootPlayground({ worker, fileLockManagerPort, firstProcessId, nativeInternalDirPath, }: {
24
+ bootWordPress(playground: Pooled<PlaygroundCliWorker>, workerPostInstallMountsPort: NodeMessagePort): Promise<Pooled<PlaygroundCliWorker>>;
25
+ bootRequestHandler({ worker, fileLockManagerPort, nativeInternalDirPath, }: {
27
26
  worker: SpawnedWorker;
28
27
  fileLockManagerPort: NodeMessagePort;
29
- firstProcessId: number;
30
28
  nativeInternalDirPath: string;
31
29
  }): Promise<RemoteAPI<PlaygroundCliBlueprintV2Worker>>;
32
30
  }
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
- import type { FileLockManager } from '@php-wasm/node';
2
+ import type { FileLockManager } from '@php-wasm/universal';
3
3
  import { EmscriptenDownloadMonitor } from '@php-wasm/progress';
4
- import type { PathAlias, PHP, FileTree, RemoteAPI, SupportedPHPVersion, SpawnHandler } from '@php-wasm/universal';
4
+ import type { PathAlias, PHP, FileTree, SupportedPHPVersion, SpawnHandler } from '@php-wasm/universal';
5
5
  import { PHPWorker } from '@php-wasm/universal';
6
6
  import { type BlueprintV1Declaration } from '@wp-playground/blueprints';
7
7
  import { type ParsedBlueprintV2String, type RawBlueprintV2Data } from '@wp-playground/blueprints';
@@ -9,21 +9,9 @@ import { type MessagePort } from 'worker_threads';
9
9
  import { type RunCLIArgs } from '../run-cli';
10
10
  import type { PhpIniOptions, PHPInstanceCreatedHook } from '@wp-playground/wordpress';
11
11
  import type { Mount } from '@php-wasm/cli-util';
12
- export type PrimaryWorkerBootArgs = Omit<RunCLIArgs, 'mount-before-install' | 'mount'> & {
13
- phpVersion: SupportedPHPVersion;
12
+ export type WorkerWordPressBootArgs = Omit<RunCLIArgs, 'mount-before-install' | 'mount'> & {
14
13
  siteUrl: string;
15
- firstProcessId: number;
16
- processIdSpaceLength: number;
17
- trace: boolean;
18
14
  blueprint: RawBlueprintV2Data | ParsedBlueprintV2String | BlueprintV1Declaration;
19
- nativeInternalDirPath: string;
20
- mountsBeforeWpInstall?: Array<Mount>;
21
- mountsAfterWpInstall?: Array<Mount>;
22
- /**
23
- * PHP constants to define via php.defineConstant().
24
- * Process-specific, set for each PHP instance.
25
- */
26
- constants?: Record<string, string | number | boolean | null>;
27
15
  };
28
16
  type WorkerRunBlueprintArgs = Omit<RunCLIArgs, 'mount-before-install' | 'mount'> & {
29
17
  siteUrl: string;
@@ -37,8 +25,7 @@ export type SecondaryWorkerBootArgs = {
37
25
  phpIniEntries?: PhpIniOptions;
38
26
  constants?: Record<string, string | number | boolean | null>;
39
27
  createFiles?: FileTree;
40
- firstProcessId: number;
41
- processIdSpaceLength: number;
28
+ processId: number;
42
29
  trace: boolean;
43
30
  nativeInternalDirPath: string;
44
31
  withIntl?: boolean;
@@ -57,7 +44,7 @@ export declare class PlaygroundCliBlueprintV2Worker extends PHPWorker {
57
44
  booted: boolean;
58
45
  blueprintTargetResolved: boolean;
59
46
  phpInstancesThatNeedMountsAfterTargetResolved: Set<PHP>;
60
- fileLockManager: RemoteAPI<FileLockManager> | FileLockManager | undefined;
47
+ fileLockManager: FileLockManager | undefined;
61
48
  constructor(monitor: EmscriptenDownloadMonitor);
62
49
  /**
63
50
  * Call this method before boot() to use file locking.
@@ -69,10 +56,12 @@ export declare class PlaygroundCliBlueprintV2Worker extends PHPWorker {
69
56
  * @see phpwasm-emscripten-library-file-locking-for-node.js
70
57
  */
71
58
  useFileLockManager(port: MessagePort): Promise<void>;
72
- bootAndSetUpInitialWorker(args: PrimaryWorkerBootArgs): Promise<void>;
59
+ bootWordPress(args: WorkerWordPressBootArgs, workerPostInstallMountsPort: MessagePort): Promise<void>;
73
60
  bootWorker(args: SecondaryWorkerBootArgs): Promise<void>;
74
- runBlueprintV2(args: WorkerRunBlueprintArgs): Promise<void>;
75
- bootRequestHandler({ siteUrl, allow, phpVersion, createFiles, constants, phpIniEntries, firstProcessId, processIdSpaceLength, trace, nativeInternalDirPath, withIntl, withRedis, withMemcached, withXdebug, pathAliases, onPHPInstanceCreated, spawnHandler, }: WorkerBootRequestHandlerOptions): Promise<void>;
61
+ runBlueprintV2(args: WorkerRunBlueprintArgs, workerPostInstallMountsPort: MessagePort): Promise<void>;
62
+ bootRequestHandler({ siteUrl, allow, phpVersion, processId, createFiles, constants, phpIniEntries, trace, nativeInternalDirPath, withIntl, withRedis, withMemcached, withXdebug, pathAliases, onPHPInstanceCreated, spawnHandler, }: WorkerBootRequestHandlerOptions): Promise<void>;
63
+ mountAfterWordPressInstall(mounts: Array<Mount>): Promise<void>;
64
+ applyPostInstallMountsToAllWorkers(postInstallMountsPort: MessagePort): Promise<void>;
76
65
  dispose(): Promise<void>;
77
66
  }
78
67
  export {};
package/cli.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";const s=require("./run-cli-DHqpmO6s.cjs"),r=process.argv.slice(2);s.parseOptionsAndRunCLI(r);
1
+ "use strict";const s=require("./run-cli-CIkDrr7x.cjs"),r=process.argv.slice(2);s.parseOptionsAndRunCLI(r);
2
2
  //# sourceMappingURL=cli.cjs.map
package/cli.js CHANGED
@@ -1,4 +1,4 @@
1
- import { p as s } from "./run-cli-Cxpf7CoX.js";
1
+ import { p as s } from "./run-cli-BzYAH0YF.js";
2
2
  const r = process.argv.slice(2);
3
3
  s(r);
4
4
  //# sourceMappingURL=cli.js.map
package/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./run-cli-DHqpmO6s.cjs");exports.LogVerbosity=e.LogVerbosity;exports.internalsKeyForTesting=e.internalsKeyForTesting;exports.mergeDefinedConstants=e.mergeDefinedConstants;exports.parseOptionsAndRunCLI=e.parseOptionsAndRunCLI;exports.runCLI=e.runCLI;exports.spawnWorkerThread=e.spawnWorkerThread;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./run-cli-CIkDrr7x.cjs");exports.LogVerbosity=e.LogVerbosity;exports.internalsKeyForTesting=e.internalsKeyForTesting;exports.mergeDefinedConstants=e.mergeDefinedConstants;exports.parseOptionsAndRunCLI=e.parseOptionsAndRunCLI;exports.runCLI=e.runCLI;exports.spawnWorkerThread=e.spawnWorkerThread;
2
2
  //# sourceMappingURL=index.cjs.map
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { L as r, i as a, m as n, p as o, r as t, s as i } from "./run-cli-Cxpf7CoX.js";
1
+ import { L as r, i as a, m as n, p as o, r as t, s as i } from "./run-cli-BzYAH0YF.js";
2
2
  export {
3
3
  r as LogVerbosity,
4
4
  a as internalsKeyForTesting,
@@ -1,16 +1,23 @@
1
- import type { PHPRequest, PHPResponse, RemoteAPI } from '@php-wasm/universal';
2
- import type { PlaygroundCliBlueprintV1Worker as PlaygroundCliWorkerV1 } from './blueprints-v1/worker-thread-v1';
3
- import type { PlaygroundCliBlueprintV2Worker as PlaygroundCliWorkerV2 } from './blueprints-v2/worker-thread-v2';
4
- type PlaygroundCliWorker = PlaygroundCliWorkerV1 | PlaygroundCliWorkerV2;
5
- type WorkerLoad = {
6
- worker: RemoteAPI<PlaygroundCliWorker>;
7
- activeRequests: Set<Promise<PHPResponse>>;
1
+ import type { PHPRequest, PHPResponse } from '@php-wasm/universal';
2
+ export interface LoadBalancerWorker {
3
+ request(request: PHPRequest): Promise<PHPResponse>;
4
+ }
5
+ type InProgressRequest = {
6
+ request: PHPRequest;
7
+ promisedResponse: Promise<PHPResponse>;
8
+ };
9
+ type QueuedRequest = {
10
+ request: PHPRequest;
11
+ resolve: (response: PHPResponse | PromiseLike<PHPResponse>) => void;
12
+ reject: (reason?: any) => void;
8
13
  };
9
14
  export declare class LoadBalancer {
10
- workerLoads: WorkerLoad[];
11
- constructor(initialWorker: RemoteAPI<PlaygroundCliWorker>);
12
- addWorker(worker: RemoteAPI<PlaygroundCliWorker>): void;
13
- removeWorker(worker: RemoteAPI<PlaygroundCliWorker>): Promise<void>;
15
+ workers: LoadBalancerWorker[];
16
+ freeWorkers: LoadBalancerWorker[];
17
+ busyWorkers: Map<LoadBalancerWorker, InProgressRequest>;
18
+ queuedRequests: QueuedRequest[];
19
+ constructor(workers: LoadBalancerWorker[]);
14
20
  handleRequest(request: PHPRequest): Promise<PHPResponse>;
21
+ private dispatchQueuedRequests;
15
22
  }
16
23
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wp-playground/cli",
3
- "version": "3.0.54",
3
+ "version": "3.1.0",
4
4
  "description": "WordPress Playground CLI",
5
5
  "repository": {
6
6
  "type": "git",
@@ -34,7 +34,7 @@
34
34
  "bin": {
35
35
  "wp-playground-cli": "wp-playground.js"
36
36
  },
37
- "gitHead": "e449793042bf2c66f8fdd4212ef266801ae3f605",
37
+ "gitHead": "be66d7e27ea9a8f09c2cc15e4470a6e28def5c58",
38
38
  "dependencies": {
39
39
  "@zip.js/zip.js": "2.7.57",
40
40
  "ajv": "8.12.0",
@@ -44,6 +44,7 @@
44
44
  "diff3": "0.0.4",
45
45
  "express": "4.22.0",
46
46
  "fast-xml-parser": "^5.3.4",
47
+ "fs-ext-extra-prebuilt": "2.2.7",
47
48
  "fs-extra": "11.1.1",
48
49
  "ignore": "5.3.2",
49
50
  "ini": "4.1.2",
@@ -54,7 +55,6 @@
54
55
  "pify": "2.3.0",
55
56
  "ps-man": "1.1.8",
56
57
  "readable-stream": "3.6.2",
57
- "selfsigned": "5.5.0",
58
58
  "sha.js": "2.4.12",
59
59
  "simple-get": "4.0.1",
60
60
  "tmp-promise": "3.0.3",
@@ -62,18 +62,18 @@
62
62
  "ws": "8.18.3",
63
63
  "xml2js": "0.6.2",
64
64
  "yargs": "17.7.2",
65
- "@php-wasm/logger": "3.0.54",
66
- "@php-wasm/progress": "3.0.54",
67
- "@php-wasm/universal": "3.0.54",
68
- "@wp-playground/blueprints": "3.0.54",
69
- "@wp-playground/common": "3.0.54",
70
- "@wp-playground/wordpress": "3.0.54",
71
- "@php-wasm/node": "3.0.54",
72
- "@php-wasm/util": "3.0.54",
73
- "@php-wasm/cli-util": "3.0.54",
74
- "@wp-playground/storage": "3.0.54",
75
- "@php-wasm/xdebug-bridge": "3.0.54",
76
- "@wp-playground/tools": "3.0.54"
65
+ "@php-wasm/logger": "3.1.0",
66
+ "@php-wasm/progress": "3.1.0",
67
+ "@php-wasm/universal": "3.1.0",
68
+ "@wp-playground/blueprints": "3.1.0",
69
+ "@wp-playground/common": "3.1.0",
70
+ "@wp-playground/wordpress": "3.1.0",
71
+ "@php-wasm/node": "3.1.0",
72
+ "@php-wasm/util": "3.1.0",
73
+ "@php-wasm/cli-util": "3.1.0",
74
+ "@wp-playground/storage": "3.1.0",
75
+ "@php-wasm/xdebug-bridge": "3.1.0",
76
+ "@wp-playground/tools": "3.1.0"
77
77
  },
78
78
  "packageManager": "npm@10.9.2",
79
79
  "overrides": {
@@ -87,8 +87,5 @@
87
87
  "form-data": "^4.0.4",
88
88
  "lodash": "^4.17.23",
89
89
  "glob": "^9.3.0"
90
- },
91
- "optionalDependencies": {
92
- "fs-ext": "2.1.1"
93
90
  }
94
91
  }
@@ -0,0 +1,9 @@
1
+ export declare class ProcessIdAllocator {
2
+ private initialId;
3
+ private maxId;
4
+ private nextId;
5
+ private claimed;
6
+ constructor(initialId?: number, maxId?: number);
7
+ claim(): number;
8
+ release(id: number): boolean;
9
+ }