1
1
import { useStore } from '@nanostores/react' ;
2
2
import type { NodeChange } from '@xyflow/react' ;
3
3
import { useAppDispatch , useAppSelector } from 'app/store/storeHooks' ;
4
- import type { ELK as ELKType , ElkExtendedEdge , ElkNode } from 'elkjs' ;
5
- import * as ElkModule from 'elkjs/lib/elk.bundled.js' ;
4
+ import type { ElkExtendedEdge , ElkNode } from 'elkjs/lib/elk.bundled.js ' ;
5
+ import ELK from 'elkjs/lib/elk.bundled.js' ;
6
6
import { $templates , nodesChanged } from 'features/nodes/store/nodesSlice' ;
7
7
import { selectEdges , selectNodes } from 'features/nodes/store/selectors' ;
8
8
import {
@@ -17,13 +17,7 @@ import type { AnyNode } from 'features/nodes/types/invocation';
17
17
import { isInvocationNode } from 'features/nodes/types/invocation' ;
18
18
import { useCallback } from 'react' ;
19
19
20
- // This is a workaround for a common issue with how ELKjs is packaged. The bundled script doesn't have a
21
- // clean ES module export, so we import the module namespace and then extract the constructor, which may
22
- // be on the `default` property or be the module itself.
23
- const ElkConstructor = ( ( ElkModule as unknown as { default : unknown } ) . default ?? ElkModule ) as new (
24
- options ?: Record < string , unknown >
25
- ) => ELKType ;
26
- const elk : ELKType = new ElkConstructor ( ) ;
20
+ const elk = new ELK ( ) ;
27
21
28
22
// These are estimates for node dimensions, used as a fallback when the node has not yet been rendered.
29
23
const ESTIMATED_NODE_HEADER_HEIGHT = 40 ;
0 commit comments