From fd3a550a19ce6613a67c2f8a31abeb87971e8a8e Mon Sep 17 00:00:00 2001 From: newcat Date: Sun, 3 Mar 2024 09:07:55 +0100 Subject: [PATCH] Fix visualization parameters not being updated --- src/main.ts | 2 ++ src/stage/visualization/visualization.worker.ts | 1 + src/utils/comlinkVueTransferHandler.ts | 11 +++++++++++ 3 files changed, 14 insertions(+) create mode 100644 src/utils/comlinkVueTransferHandler.ts 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);