diff --git a/src/web_worker_kernel.ts b/src/web_worker_kernel.ts index e11e2ce..bdacd9e 100644 --- a/src/web_worker_kernel.ts +++ b/src/web_worker_kernel.ts @@ -2,7 +2,10 @@ // Copyright (c) JupyterLite Contributors // Distributed under the terms of the Modified BSD License. -import coincident from 'coincident'; +// @ts-expect-error - no types available +import coincident from 'coincident/main'; + +const { Worker: CoincidentWorker } = coincident(); import { ISignal, Signal } from '@lumino/signaling'; import { PromiseDelegate } from '@lumino/coreutils'; @@ -48,14 +51,17 @@ export class WebWorkerKernel implements IKernel { this._kernelspec = kernelspec; this._contentsManager = contentsManager; this._sendMessage = sendMessage; - this._worker = new Worker(new URL('./worker.js', import.meta.url), { - type: 'module' - }); + const worker = new CoincidentWorker( + new URL('./worker.js', import.meta.url), + { + type: 'module' + } + ); + this._worker = worker; + this._remote = worker.proxy; this._worker.onmessage = this._processWorkerMessage.bind(this); - this._remote = coincident(this._worker) as IXeusKernel; - this.setupFilesystemAPIs(); this._remote.initialize(this._kernelspec, PageConfig.getBaseUrl()); diff --git a/src/worker.ts b/src/worker.ts index 7180b15..96469de 100644 --- a/src/worker.ts +++ b/src/worker.ts @@ -2,7 +2,8 @@ // Copyright (c) JupyterLite Contributors // Distributed under the terms of the Modified BSD License. -import coincident from 'coincident'; +// @ts-expect-error - no types available +import coincident from 'coincident/worker'; import { ContentsAPI, @@ -19,7 +20,7 @@ declare function createXeusModule(options: any): any; globalThis.Module = {}; -const workerAPI = coincident(self) as typeof globalThis; +const { proxy: workerAPI } = await coincident(); /** * An Emscripten-compatible synchronous Contents API using shared array buffers.