diff --git a/src/main.ts b/src/main.ts index 83951c0..5a2297d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,8 +1,10 @@ import { createApp } from "vue"; import * as VueRouter from "vue-router"; import { createPinia } from "pinia"; + import { wasmInterop } from "./wasmInterop"; import { initializeNativeAdapter } from "./native"; +import "./utils/comlinkVueTransferHandler"; import "splitpanes/dist/splitpanes.css"; import "@baklavajs/themes/dist/syrup-dark.css"; diff --git a/src/stage/visualization/visualization.worker.ts b/src/stage/visualization/visualization.worker.ts index 9cbe406..e9e0c44 100644 --- a/src/stage/visualization/visualization.worker.ts +++ b/src/stage/visualization/visualization.worker.ts @@ -1,4 +1,5 @@ import * as Comlink from "comlink"; +import "../../utils/comlinkVueTransferHandler"; import { StageRenderer } from "./stageRenderer"; console.log("Stage visualization worker started"); diff --git a/src/utils/comlinkVueTransferHandler.ts b/src/utils/comlinkVueTransferHandler.ts new file mode 100644 index 0000000..4d34c0c --- /dev/null +++ b/src/utils/comlinkVueTransferHandler.ts @@ -0,0 +1,11 @@ +import { isReactive } from "vue"; +import * as Comlink from "comlink"; + +const vueReactiveTransferHandler: Comlink.TransferHandler = { + canHandle: ((x: any) => { + return isReactive(x) || (x && typeof x === "object" && Object.values(x).some((v) => isReactive(v))); + }) as (x: any) => x is any, + serialize: (x) => [JSON.parse(JSON.stringify(x)), []], + deserialize: (x) => x, +}; +Comlink.transferHandlers.set("VueReactiveValue", vueReactiveTransferHandler);