Skip to content

[CLI] Extract Blueprints v1-specific parts into BlueprintsV1Handler #2366

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/php-wasm/universal/src/lib/php-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,17 @@ export class PHPWorker implements LimitedPHPApi, AsyncDisposable {
_private.get(this)!.php!.removeEventListener(eventType, listener);
}

/**
* @internal
* @deprecated
* Do not use this method directly in the code consuming
* the web API. It will change or even be removed without
* a warning.
*/
protected __internal_getRequestHandler(): PHPRequestHandler {
return _private.get(this)!.requestHandler!;
}

async [Symbol.asyncDispose]() {
await _private.get(this)!.requestHandler?.[Symbol.asyncDispose]();
}
Expand Down
15 changes: 10 additions & 5 deletions packages/playground/cli/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { parseOptionsAndRunCLI } from './run-cli';

// Do not await this as top-level await is not supported in all environments.
parseOptionsAndRunCLI().catch(() => {
// process.exit(1); is here and not in parseOptionsAndRunCLI()
// so that we can unit test the failure modes with try/catch.
process.exit(1);
});
parseOptionsAndRunCLI().then(
() => {
process.exit(0);
},
(e) => {
// eslint-disable-next-line no-console
console.error(e);
process.exit(1);
}
);
8 changes: 4 additions & 4 deletions packages/playground/cli/src/load-balancer.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import type { PHPRequest, PHPResponse, RemoteAPI } from '@php-wasm/universal';
import type { PlaygroundCliWorker } from './worker-thread';
import type { PlaygroundCliBlueprintV1Worker } from './worker-thread';

// TODO: Let's merge worker management into PHPProcessManager
// when we can have multiple workers in both CLI and web.
// ¡ATTENTION!:Please don't expand upon this as an independent abstraction.

// TODO: Could we just spawn a worker using the factory function to PHPProcessManager?
type WorkerLoad = {
worker: RemoteAPI<PlaygroundCliWorker>;
worker: RemoteAPI<PlaygroundCliBlueprintV1Worker>;
activeRequests: Set<Promise<PHPResponse>>;
};
export class LoadBalancer {
Expand All @@ -19,12 +19,12 @@ export class LoadBalancer {
// Playground CLI initialization, as of 2025-06-11, requires that
// an initial worker is booted alone and initialized via Blueprint
// before additional workers are created based on the initialized worker.
initialWorker: RemoteAPI<PlaygroundCliWorker>
initialWorker: RemoteAPI<PlaygroundCliBlueprintV1Worker>
) {
this.addWorker(initialWorker);
}

addWorker(worker: RemoteAPI<PlaygroundCliWorker>) {
addWorker(worker: RemoteAPI<PlaygroundCliBlueprintV1Worker>) {
this.workerLoads.push({
worker,
activeRequests: new Set(),
Expand Down
2 changes: 1 addition & 1 deletion packages/playground/cli/src/mounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export function expandAutoMounts(args: RunCLIArgs): RunCLIArgs {
// newArgs.mode = 'mount-only';
}

return newArgs as RunCLIArgs;
return newArgs;
}

export function containsFullWordPressInstallation(path: string): boolean {
Expand Down
Loading
Loading