File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed
rust/cubesql/cubesql/egraph-debug-template Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change 2323 "@types/react-dom" : " 18.0.11" ,
2424 "prettier" : " 3.3.3" ,
2525 "react-scripts" : " 5.0.1" ,
26- "typescript" : " 4.9.5"
26+ "typescript" : " 4.9.5" ,
27+ "web-worker" : " 1.3.0"
2728 },
2829 "eslintConfig" : {
2930 "extends" : [
Original file line number Diff line number Diff line change 11import { createRoot } from 'react-dom/client' ;
2- import ELK from 'elkjs/lib/elk.bundled.js ' ;
2+ import ELK from 'elkjs' ;
33import type { ElkNode , LayoutOptions } from 'elkjs' ;
44import { useCallback , useState , useEffect , useMemo } from 'react' ;
55import ReactFlow , {
@@ -97,6 +97,18 @@ const initialNodes = data.combos
9797 . concat ( data . nodes . map ( toRegularNode ) ) ;
9898const initialEdges = data . edges . map ( toEdge ) ;
9999
100+ const elk = new ELK ( {
101+ workerFactory : function ( _url ) {
102+ // TODO something is broken with bundling and web-worker
103+ return new Worker (
104+ new URL (
105+ '../node_modules/elkjs/lib/elk-worker.min.js' ,
106+ import . meta. url ,
107+ ) ,
108+ ) ;
109+ } ,
110+ } ) ;
111+
100112async function layout (
101113 options : LayoutOptions ,
102114 nodes : Array < Node > ,
@@ -200,7 +212,8 @@ async function layout(
200212 } ) ;
201213 }
202214
203- const elk = new ELK ( ) ;
215+ // TODO add throbber while waiting for layout
216+ // TODO add queue to be able to cancel request before sending it to worker
204217 const { children } = await elk . layout ( graph ) ;
205218
206219 if ( abortSignal . aborted ) {
You can’t perform that action at this time.
0 commit comments