feat: offload parsing elements to worker

* when we're not in ssr environment we use a web worker to parse the elements as this blocks the main thread when there's a good amount of nodes/edges to parse
* when in ssr we don't really care about the main thread blocking so we just parse them like usual
* update vite to latest

Signed-off-by: Braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
Braks
2021-11-20 16:22:31 +01:00
parent d1e59ef322
commit d335944e56
9 changed files with 222 additions and 130 deletions
-19
View File
@@ -54,7 +54,6 @@ const transform = ref({ x: clampedX, y: clampedY, zoom: clampedZoom })
const d3Zoom = ref(zoom<HTMLDivElement, any>().scaleExtent([store.minZoom, store.maxZoom]).translateExtent(store.translateExtent))
const d3Selection = ref()
const { zoomIn, zoomOut, zoomTo, transform: setTransform, fitView } = useZoomPanHelper()
store.transform = [transform.value.x, transform.value.y, transform.value.zoom]
invoke(async () => {
@@ -184,19 +183,6 @@ store.dimensions = {
invoke(async () => {
await until(() => !isNaN(width.value) && width.value > 0 && !isNaN(height.value) && height.value > 0).toBeTruthy()
const instance: FlowInstance = {
fitView: (params = { padding: 0.1 }) => fitView(params),
zoomIn,
zoomOut,
zoomTo,
setTransform,
project: onLoadProject(store),
getElements: onLoadGetElements(store),
toObject: onLoadToObject(store),
}
store.hooks.load.trigger(instance)
store.isReady = true
store.instance = instance
})
watch(
@@ -225,11 +211,6 @@ watch(
v-bind="{
transform,
dimensions: { width, height },
zoomIn,
zoomOut,
zoomTo,
setTransform,
fitView,
}"
/>
</Suspense>