diff --git a/packages/php-wasm/web/src/lib/api.ts b/packages/php-wasm/web/src/lib/api.ts index 7875db0ec5..9748a837cc 100644 --- a/packages/php-wasm/web/src/lib/api.ts +++ b/packages/php-wasm/web/src/lib/api.ts @@ -16,7 +16,8 @@ export type WithAPIState = { export type RemoteAPI = Comlink.Remote & WithAPIState; export function consumeAPI( - remote: Worker | Window + remote: Worker | Window, + context: undefined | EventTarget = undefined ): RemoteAPI { setupTransferHandlers(); @@ -32,7 +33,7 @@ export function consumeAPI( * * @TODO: Remove this workaround. */ - const api = Comlink.wrap(endpoint); + const api = Comlink.wrap(endpoint, context); const methods = proxyClone(api); return new Proxy(methods, { get: (target, prop) => { diff --git a/packages/playground/client/src/index.ts b/packages/playground/client/src/index.ts index e5fc712f1f..c4cc41aa09 100644 --- a/packages/playground/client/src/index.ts +++ b/packages/playground/client/src/index.ts @@ -143,7 +143,8 @@ async function doStartPlaygroundWeb( // Connect the Comlink client and wait until the // playground is ready. const playground = consumeAPI( - iframe.contentWindow! + iframe.contentWindow!, + iframe.ownerDocument!.defaultView! ) as PlaygroundClient; await playground.isConnected(); progressTracker.pipe(playground); @@ -208,7 +209,8 @@ export async function connectPlayground( }); } const client = consumeAPI( - iframe.contentWindow! + iframe.contentWindow!, + iframe.ownerDocument!.defaultView! ) as PlaygroundClient; await client.isConnected(); return client;