import type { RemoteAPI } from '@php-wasm/universal'; import type { PlaygroundWorkerEndpoint } from './playground-worker-endpoint'; /** * Connect WordPress HTTP requests on a separate origin to this app-origin PHP worker. * * For example, remote.html on playground.wordpress.net runs PHP, but the visible * WordPress iframe loads wpsandbox.wordpress.net/scope:site-a/. The WordPress * service worker cannot message remote.html directly: it can only reach windows * on its own origin. This function creates a hidden WordPress-origin iframe as * a sibling of the visible WordPress iframe. Requests take this path: * * WordPress page -> WordPress service worker -> hidden iframe * -> remote.html (this listener) -> the supplied PHP worker. * * Only messages from that exact hidden iframe, at the configured WordPress origin, * with the supplied scope reach PHP. The HTTP URL must also use that origin and * scope. The connection exposes two operations: HTTP requests and the directory * name for shared WordPress assets. It does not forward the full PHP API, file * handles, mount options, or requests for a different scope. Response status and * headers return as message data; body chunks travel through a MessagePort. * * Call after PHP has booted. Resolves when the bridge reports its service worker * is ready, not when a WordPress page has loaded. On success, the hidden iframe * and listener remain for the lifetime of remote.html. If no ready message arrives * within 30 seconds, both are removed and the promise rejects. * * Production URLs name this app's /releases//wordpress-bridge.html. Development * and portable builds use /wordpress-bridge-.html instead. A worker * can generate its own release's bridge HTML and its matching build-version alias. * Requests naming another release or build reach HTTP, so an older worker cannot * substitute HTML that names its own script. The unversioned compatibility alias * also uses worker-generated HTML. The bridge registers the WordPress worker and * waits for activation before reporting ready. * * After connection, reject app-service-worker HTTP requests for this scope with * 404. Returning this site's HTML there would let its scripts run on the app * origin with app storage access, bypassing the sandbox origin entirely. * The rejection listener lasts with remote.html and survives worker restarts. * * The scope selects a PHP instance; it does not prove which WordPress page made * the HTTP request. Pages sharing the WordPress origin can still request another * running site's known scope. This connection also does not prevent WordPress * from embedding a fresh app/API document and connecting to that separate API. * * @param client The already-booted PHP worker that will serve this site's requests. * @param scope The site's URL routing scope, as supplied in its PHP boot options. */ export declare function connectWordPressOrigin(client: RemoteAPI, scope: string): Promise;