/** * Imports required for the Playground Client. */ import type { ProgressReceiver } from '@php-wasm/progress'; import type { MessageListener, UniversalPHP } from '@php-wasm/universal'; import type { RemoteAPI, SyncProgressCallback } from '@php-wasm/web'; import type { ProgressBarOptions } from './progress-bar'; import type { WebMCPToolDescriptor } from './webmcp-frame-bridge'; import type { PlaygroundWorkerEndpoint, MountDescriptor, WorkerBootOptions } from './playground-worker-endpoint'; export type { BootProgressEvent } from './playground-worker-endpoint'; export type { WebMCPToolDescriptor } from './webmcp-frame-bridge'; export interface WebClientMixin extends ProgressReceiver { /** * Sets the progress bar options. * @param options The progress bar options. */ setProgress(options: ProgressBarOptions): Promise; /** * Sets the loaded state. */ setLoaded(): Promise; /** * Sets the navigation event listener. * @param fn The function to be called when a navigation event occurs. */ onNavigation(fn: (url: string) => void): Promise; /** * Navigates to the requested path. * @param requestedPath The requested path. */ goTo(requestedPath: string): Promise; /** * Gets the current URL. */ getCurrentURL(): Promise; /** * Renders the site's front page in a disposable 1024×768 browsing context * and returns a compact 320×240 image. * * This method does not persist the image or synchronize it with OPFS. * Callers own the result's lifecycle and must discard it if the site changes * while the asynchronous capture is running. * * DOM cloning and canvas rendering run in the captured document's event * loop. A worker handles supported resource fetches, while explicit task * yields keep that document responsive during cloning. */ captureSiteThumbnail(): Promise; /** * Sets the iframe sandbox flags. * @param flags The iframe sandbox flags. */ setIframeSandboxFlags(flags: string[]): Promise; /** * Subscribes to the WebMCP tools a plugin registers with * `document.modelContext` inside the WordPress document. * * The callback receives the complete tool list every time it changes, and * once with the current list when it subscribes. A navigation to a page * that registers no tools reports an empty list. */ onWebMCPToolsChanged(fn: (tools: WebMCPToolDescriptor[]) => void): Promise<() => void>; /** * Runs one of those tools inside the WordPress document and returns its * JSON-serializable result. * * @param name The tool name as announced by `onWebMCPToolsChanged`. * @param args The tool input. * @param callId An optional identifier used to cancel this call. Use a fresh ID * for each invocation; an already-pending ID is rejected. */ callWebMCPTool(name: string, args: Record, callId?: string): Promise; /** Signals cancellation to a pending tool inside the WordPress document. */ cancelWebMCPTool(callId: string): Promise; /** * The onDownloadProgress event listener. */ onDownloadProgress: PlaygroundWorkerEndpoint['onDownloadProgress']; journalFSEvents: PlaygroundWorkerEndpoint['journalFSEvents']; replayFSJournal: PlaygroundWorkerEndpoint['replayFSJournal']; addEventListener: PlaygroundWorkerEndpoint['addEventListener']; removeEventListener: PlaygroundWorkerEndpoint['removeEventListener']; backfillStaticFilesRemovedFromMinifiedBuild: PlaygroundWorkerEndpoint['backfillStaticFilesRemovedFromMinifiedBuild']; hasCachedStaticFilesRemovedFromMinifiedBuild: PlaygroundWorkerEndpoint['hasCachedStaticFilesRemovedFromMinifiedBuild']; /** @inheritDoc @php-wasm/universal!UniversalPHP.onMessage */ onMessage(listener: MessageListener): Promise<() => Promise>; mountOpfs(options: MountDescriptor, onProgress?: SyncProgressCallback): Promise; flushOpfs(mountpoint: string): Promise; /** * Flushes and detaches an OPFS mount. * * On success, clears its tracking. If the final flush fails, keeps the mount * registered for retry and rejects with the original persistence error. * Other unmount failures clear tracking because the mount did not guarantee * that it remained live. */ unmountOpfs(mountpoint: string): Promise; boot(options: WorkerBootOptions): Promise; /** * Retires the shared runtime for all connected tabs. Stops accepting new work, * drains active operations, flushes and unmounts OPFS, and disposes PHP before * confirming shutdown. Rejects if retirement fails. Dedicated runtimes ignore this call. */ shutdownSharedRuntime(): Promise; /** * Whether this connection owns initial Blueprint execution. Always true for a * dedicated runtime. Used by the client startup handlers, not application code. * @internal */ shouldRunStartupBlueprint(): Promise; /** * Signals that the initializing connection has finished its startup Blueprint, * allowing waiting tabs to attach. Only that connection may complete initialization. * Used by the client startup handlers, including after Blueprint errors so recovery * tools remain available. Dedicated runtimes ignore this call. * @internal */ finishSharedRuntimeInitialization(): Promise; } export type SiteThumbnail = { /** The encoded image's MIME type. */ mime: string; /** The base64 payload without a data URL prefix. */ data: string; }; /** * The Playground Client interface. */ export interface PlaygroundClient extends RemoteAPI { } export declare const assertion: UniversalPHP;