@statelyai/flow 0.14.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/README.md +2 -1
  2. package/dist/esm/index.d.ts +5 -2
  3. package/dist/esm/index.d.ts.map +1 -0
  4. package/dist/esm/index.js +19 -14
  5. package/dist/esm/index.js.map +1 -0
  6. package/dist/esm/layout/dagre.d.ts +2 -1
  7. package/dist/esm/layout/dagre.d.ts.map +1 -0
  8. package/dist/esm/layout/dagre.js +2 -0
  9. package/dist/esm/layout/dagre.js.map +1 -0
  10. package/dist/esm/layout/elk.d.ts +2 -1
  11. package/dist/esm/layout/elk.d.ts.map +1 -0
  12. package/dist/esm/layout/elk.js +2 -0
  13. package/dist/esm/layout/elk.js.map +1 -0
  14. package/dist/esm/layout/stately.d.ts +2 -1
  15. package/dist/esm/layout/stately.d.ts.map +1 -0
  16. package/dist/esm/layout/stately.js +2 -0
  17. package/dist/esm/layout/stately.js.map +1 -0
  18. package/dist/esm/shared.d.ts +2 -1
  19. package/dist/esm/shared.d.ts.map +1 -0
  20. package/dist/esm/shared.js +2 -0
  21. package/dist/esm/shared.js.map +1 -0
  22. package/package.json +4 -3
  23. package/src/__fixtures__/nested.ts +106 -0
  24. package/src/appearances.test.ts +428 -0
  25. package/src/appearances.ts +144 -0
  26. package/src/authoritative-route.ts +14 -0
  27. package/src/changeSet.test.ts +132 -0
  28. package/src/changeSet.ts +337 -0
  29. package/src/config.ts +41 -0
  30. package/src/configure.test.ts +212 -0
  31. package/src/connection-lifetime.ts +1 -0
  32. package/src/connectionPreview.test.ts +102 -0
  33. package/src/connectionPreview.ts +82 -0
  34. package/src/content.ts +203 -0
  35. package/src/createFlow.fit-frame.test.ts +256 -0
  36. package/src/createFlow.modern.test.ts +743 -0
  37. package/src/createFlow.test.ts +632 -0
  38. package/src/createFlow.ts +3463 -0
  39. package/src/createFlow.view.test.ts +212 -0
  40. package/src/createFlow.viewport-controls.test.ts +221 -0
  41. package/src/edge-geometry.ts +318 -0
  42. package/src/engine.cache.test.ts +728 -0
  43. package/src/engine.hierarchy.test.ts +1023 -0
  44. package/src/engine.test.ts +1965 -0
  45. package/src/engine.ts +3385 -0
  46. package/src/entity-changes.test.ts +309 -0
  47. package/src/entity-changes.ts +395 -0
  48. package/src/examples/flow-based-math.test.ts +25 -0
  49. package/src/examples/flow-based-math.ts +210 -0
  50. package/src/external-edit.test.ts +337 -0
  51. package/src/external-edit.ts +358 -0
  52. package/src/factories.test.ts +104 -0
  53. package/src/factories.ts +70 -0
  54. package/src/geometry.ts +13 -0
  55. package/src/graph-index.test.ts +56 -0
  56. package/src/graph-index.ts +194 -0
  57. package/src/hierarchy.test.ts +175 -0
  58. package/src/hierarchy.ts +330 -0
  59. package/src/highlights.test.ts +130 -0
  60. package/src/index.ts +469 -0
  61. package/src/input/index.ts +615 -0
  62. package/src/input/input.test.ts +2577 -0
  63. package/src/input/keymap.ts +111 -0
  64. package/src/input/modes.ts +1715 -0
  65. package/src/input/reparent.test.ts +214 -0
  66. package/src/layout/dagre.ts +138 -0
  67. package/src/layout/elk.ts +1382 -0
  68. package/src/layout/index.ts +12 -0
  69. package/src/layout/layout.test.ts +1248 -0
  70. package/src/layout/shared.ts +260 -0
  71. package/src/layout/stately-globals.d.ts +9 -0
  72. package/src/layout/stately.test.ts +246 -0
  73. package/src/layout/stately.ts +528 -0
  74. package/src/layout-animation.test.ts +223 -0
  75. package/src/layout-contract.test.ts +414 -0
  76. package/src/marker.test.ts +23 -0
  77. package/src/marker.ts +23 -0
  78. package/src/measurement-anchor.test.ts +232 -0
  79. package/src/minimap.test.ts +96 -0
  80. package/src/minimap.ts +137 -0
  81. package/src/nested-fixture.test.ts +178 -0
  82. package/src/port-measurement.test.ts +27 -0
  83. package/src/port-measurements.test.ts +187 -0
  84. package/src/profile.ts +124 -0
  85. package/src/projections.test.ts +103 -0
  86. package/src/projections.ts +295 -0
  87. package/src/render-invalidation.test.ts +62 -0
  88. package/src/render-invalidation.ts +55 -0
  89. package/src/renderer-geometry.test.ts +356 -0
  90. package/src/renderer-transactions.test.ts +234 -0
  91. package/src/routing/avoid.ts +417 -0
  92. package/src/routing/index.test.ts +361 -0
  93. package/src/routing/index.ts +366 -0
  94. package/src/routing/readTracking.test.ts +103 -0
  95. package/src/routing/readTracking.ts +233 -0
  96. package/src/selection-commands.test.ts +355 -0
  97. package/src/serialize.test.ts +167 -0
  98. package/src/serialize.ts +254 -0
  99. package/src/shapes/index.test.ts +45 -0
  100. package/src/shapes/index.ts +142 -0
  101. package/src/snap.test.ts +123 -0
  102. package/src/snap.ts +395 -0
  103. package/src/spatial.test.ts +676 -0
  104. package/src/spatial.ts +457 -0
  105. package/src/store/index.ts +4121 -0
  106. package/src/store.test.ts +2903 -0
  107. package/src/toolbar.test.ts +31 -0
  108. package/src/toolbar.ts +62 -0
  109. package/src/types.test.ts +15 -0
  110. package/src/types.ts +487 -0
  111. package/src/validation.ts +558 -0
  112. package/src/view.ts +172 -0
  113. package/src/viewport/animate.ts +285 -0
  114. package/src/viewport/index.ts +296 -0
  115. package/src/viewport.test.ts +569 -0
@@ -3,4 +3,5 @@ import { n as FlowLayoutFactory, r as FlowLayoutOptions } from "../shared.js";
3
3
  type DagreLayoutOptions<TNodeData = any, TEdgeData = any, TLabelData = any> = FlowLayoutOptions<TNodeData, TEdgeData, TLabelData>;
4
4
  declare const dagreLayout: FlowLayoutFactory;
5
5
  //#endregion
6
- export { DagreLayoutOptions, dagreLayout };
6
+ export { DagreLayoutOptions, dagreLayout };
7
+ //# sourceMappingURL=dagre.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dagre.d.ts","names":[],"sources":["../../../src/layout/dagre.ts"],"mappings":";;KAYY,mBAAmB,iBAAiB,iBAAiB,oBAC/D,kBAAkB,WAAW,WAAW;cAE7B,aAAa"}
@@ -104,3 +104,5 @@ function dagreEdgeLabelPositions(graph, g) {
104
104
  }
105
105
  //#endregion
106
106
  export { dagreLayout };
107
+
108
+ //# sourceMappingURL=dagre.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dagre.js","names":[],"sources":["../../../src/layout/dagre.ts"],"sourcesContent":["import * as dagre from '@dagrejs/dagre';\nimport type { FlowGraph, FlowNode, LayoutResult, Rect } from '@statelyai/flow';\nimport {\n boundsOf,\n edgeLabelPositionsFromNodePositions,\n layoutRunContext,\n rankDirection,\n throwIfAborted,\n type FlowLayoutFactory,\n type FlowLayoutOptions,\n} from './shared';\n\nexport type DagreLayoutOptions<TNodeData = any, TEdgeData = any, TLabelData = any> =\n FlowLayoutOptions<TNodeData, TEdgeData, TLabelData>;\n\nexport const dagreLayout: FlowLayoutFactory = (options = {}) => {\n return async (graph, runOptions = {}) => {\n throwIfAborted(runOptions);\n if (options.scope || runOptions.scope) {\n throw new Error('dagreLayout does not support scope/incremental layout.');\n }\n const mutableGraph = graph as FlowGraph;\n const context = layoutRunContext(mutableGraph, options, runOptions, 'dagre');\n if (graph.nodes.some((node) => node.parentId)) {\n const message = 'dagreLayout flattens parentId hierarchy; use elkLayout for compound layout.';\n options.onWarning?.(message);\n context.diagnostics.push({\n severity: 'warning',\n code: 'flattened-hierarchy',\n message,\n });\n }\n\n const g = new dagre.graphlib.Graph({ multigraph: true });\n g.setGraph({\n rankdir: rankDirection(options.direction ?? graph.direction),\n nodesep: options.nodeSpacing ?? 60,\n ranksep: options.rankSpacing ?? 90,\n ...options.graph,\n });\n g.setDefaultEdgeLabel(() => ({}));\n\n for (const node of graph.nodes) {\n const bounds = boundsOf(node, options.getBounds as (node: FlowNode) => any);\n g.setNode(node.id, {\n width: bounds.width,\n height: bounds.height,\n ...options.node,\n });\n }\n\n for (const edge of graph.edges) {\n g.setEdge(edge.sourceId, edge.targetId, {\n width: edge.label?.width ?? 0,\n height: edge.label?.height ?? 0,\n ...options.edge,\n }, edge.id);\n }\n\n dagre.layout(g);\n throwIfAborted(runOptions);\n\n const positions = new Map<string, { x: number; y: number }>();\n const nodeSizes = new Map<string, { width: number; height: number }>();\n const nodeBounds = new Map<string, Rect>();\n for (const node of graph.nodes) {\n if (context.fixedIds.has(node.id)) continue;\n const laidOut = g.node(node.id);\n if (!laidOut) continue;\n const position = {\n x: laidOut.x - laidOut.width / 2,\n y: laidOut.y - laidOut.height / 2,\n };\n const size = { width: laidOut.width, height: laidOut.height };\n positions.set(node.id, position);\n nodeSizes.set(node.id, size);\n nodeBounds.set(node.id, { ...position, ...size });\n }\n\n const edgeLabelPositions = dagreEdgeLabelPositions(mutableGraph, g) ??\n edgeLabelPositionsFromNodePositions(\n mutableGraph,\n positions,\n options.getBounds as ((node: FlowNode) => Rect) | undefined,\n nodeBounds,\n options.direction ?? graph.direction,\n );\n const edgeLabelBounds = new Map<string, Rect>();\n for (const edge of graph.edges) {\n if (!edge.label || context.fixedIds.has(edge.id)) continue;\n const position = edgeLabelPositions?.get(edge.id);\n if (!position) continue;\n edgeLabelBounds.set(edge.id, {\n ...position,\n width: edge.label.width,\n height: edge.label.height,\n });\n }\n\n return {\n positions,\n nodeSizes,\n nodeBounds,\n ...(edgeLabelPositions\n ? {\n edgeLabelPositions: new Map(\n [...edgeLabelPositions].filter(\n ([id]) => !context.fixedIds.has(id),\n ),\n ),\n }\n : {}),\n ...(edgeLabelBounds.size > 0 ? { edgeLabelBounds } : {}),\n ...(context.diagnostics.length > 0\n ? { diagnostics: context.diagnostics }\n : {}),\n source: context.source,\n metadata: context.metadata,\n } satisfies LayoutResult;\n };\n};\n\nfunction dagreEdgeLabelPositions(\n graph: FlowGraph,\n g: dagre.graphlib.Graph,\n): Map<string, { x: number; y: number }> | undefined {\n const labels = new Map<string, { x: number; y: number }>();\n for (const edge of graph.edges) {\n if (!edge.label) continue;\n const laidOut = g.edge({ v: edge.sourceId, w: edge.targetId, name: edge.id });\n if (!laidOut || typeof laidOut.x !== 'number' || typeof laidOut.y !== 'number') continue;\n labels.set(edge.id, {\n x: laidOut.x - edge.label.width / 2,\n y: laidOut.y - edge.label.height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AAEA,SAAS,wBACP,OACA,GACmD;CACnD,MAAM,yBAAS,IAAI,IAAsC;CACzD,KAAK,MAAM,QAAQ,MAAM,OAAO;EAC9B,IAAI,CAAC,KAAK,OAAO;EACjB,MAAM,UAAU,EAAE,KAAK;GAAE,GAAG,KAAK;GAAU,GAAG,KAAK;GAAU,MAAM,KAAK;EAAG,CAAC;EAC5E,IAAI,CAAC,WAAW,OAAO,QAAQ,MAAM,YAAY,OAAO,QAAQ,MAAM,UAAU;EAChF,OAAO,IAAI,KAAK,IAAI;GAClB,GAAG,QAAQ,IAAI,KAAK,MAAM,QAAQ;GAClC,GAAG,QAAQ,IAAI,KAAK,MAAM,SAAS;EACrC,CAAC;CACH;CACA,OAAO,OAAO,OAAO,IAAI,SAAS,KAAA;AACpC"}
@@ -6,4 +6,5 @@ type ElkLayoutOptions<TNodeData = any, TEdgeData = any, TLabelData = any> = Flow
6
6
  declare const elkLayout: FlowLayoutFactory;
7
7
  declare function toElkGraph(graph: FlowGraph, options: FlowLayoutOptions): ElkNode;
8
8
  //#endregion
9
- export { ElkLayoutOptions, elkLayout, toElkGraph };
9
+ export { ElkLayoutOptions, elkLayout, toElkGraph };
10
+ //# sourceMappingURL=elk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"elk.d.ts","names":[],"sources":["../../../src/layout/elk.ts"],"mappings":";;;;KA8BY,iBAAiB,iBAAiB,iBAAiB,oBAC7D,kBAAkB,WAAW,WAAW;cAE7B,WAAW;iBA6yBR,WACd,OAAO,WACP,SAAS,oBACR"}
@@ -850,3 +850,5 @@ function elkDirection(direction) {
850
850
  }
851
851
  //#endregion
852
852
  export { elkLayout, toElkGraph };
853
+
854
+ //# sourceMappingURL=elk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"elk.js","names":[],"sources":["../../../src/layout/elk.ts"],"sourcesContent":["import ELK from 'elkjs/lib/elk.bundled.js';\nimport type { ElkExtendedEdge, ElkNode } from 'elkjs/lib/elk-api';\nimport type {\n FlowEdge,\n FlowGraph,\n FlowNode,\n GroupContentSide,\n GroupInsets,\n GroupLayout,\n LayoutResult,\n Point,\n Rect,\n Size,\n} from '@statelyai/flow';\nimport {\n deriveGroupGeometry,\n isGroup,\n resolveGroupPadding,\n} from '@statelyai/flow';\nimport {\n boundsOf,\n edgeLabelPositionsFromNodePositions,\n graphForLayoutScope,\n layoutRunContext,\n mergedLayoutScope,\n throwIfAborted,\n type FlowLayoutFactory,\n type FlowLayoutOptions,\n} from './shared';\n\nexport type ElkLayoutOptions<TNodeData = any, TEdgeData = any, TLabelData = any> =\n FlowLayoutOptions<TNodeData, TEdgeData, TLabelData>;\n\nexport const elkLayout: FlowLayoutFactory = (options = {}) => {\n const elk = new ELK();\n return async (graph, runOptions = {}) => {\n throwIfAborted(runOptions);\n const mutableGraph = graph as FlowGraph;\n const scope = mergedLayoutScope(mutableGraph, options.scope, runOptions);\n const layoutGraph = graphForLayoutScope(mutableGraph, scope);\n const context = layoutRunContext(mutableGraph, options, runOptions, 'elk');\n const result = await elk.layout(\n toElkGraph(layoutGraph, { ...options, scope }),\n );\n throwIfAborted(runOptions);\n const positions = new Map<string, Point>();\n const nodeSizes = new Map<string, Size>();\n const nodeBounds = new Map<string, Rect>();\n const edgeLabelBounds = new Map<string, Rect>();\n const edgeRoutes = new Map<string, { waypoints: Point[] }>();\n collectElkGeometry(result, {\n positions,\n nodeSizes,\n nodeBounds,\n edgeLabelBounds,\n edgeRoutes,\n fixedIds: context.fixedIds,\n });\n await restoreExplicitCompoundDirections(\n elk,\n layoutGraph,\n positions,\n nodeSizes,\n nodeBounds,\n edgeLabelBounds,\n edgeRoutes,\n context.fixedIds,\n options,\n );\n throwIfAborted(runOptions);\n const edgeLabelPositions = new Map(\n [...edgeLabelBounds].map(([id, bounds]) => [\n id,\n { x: bounds.x, y: bounds.y },\n ]),\n );\n const fallbackLabels = edgeLabelPositionsFromNodePositions(\n layoutGraph,\n positions,\n options.getBounds as ((node: FlowNode) => Rect) | undefined,\n nodeBounds,\n options.direction ?? layoutGraph.direction,\n );\n const nodesById = new Map(layoutGraph.nodes.map((node) => [node.id, node]));\n const edgesById = new Map(\n layoutGraph.edges.map((edge) => [edge.id, edge]),\n );\n const hasHierarchy = layoutGraph.nodes.some((node) => node.parentId);\n for (const [id, position] of fallbackLabels ?? []) {\n const edge = edgesById.get(id);\n const containerId = edge\n ? elkEdgeContainerId(edge, nodesById)\n : undefined;\n const containerOrigin = containerId\n ? nodeBounds.get(containerId)\n : { x: 0, y: 0 };\n const reported = edgeLabelBounds.get(id);\n const reportedAtContainerOrigin =\n !!reported &&\n !!containerOrigin &&\n Math.abs(reported.x - containerOrigin.x) <= 0.5 &&\n Math.abs(reported.y - containerOrigin.y) <= 0.5;\n const overlapsEndpoint =\n !!edge &&\n !!reported &&\n [nodeBounds.get(edge.sourceId), nodeBounds.get(edge.targetId)].some(\n (bounds) => bounds && rectsOverlap(reported, bounds),\n );\n const invalidHierarchyPlacement =\n hasHierarchy &&\n edge?.sourceId !== edge?.targetId &&\n (reportedAtContainerOrigin || overlapsEndpoint);\n if (\n (!edgeLabelPositions.has(id) || invalidHierarchyPlacement) &&\n !context.fixedIds.has(id)\n ) {\n edgeLabelPositions.set(id, position);\n const bounds = edgeLabelBounds.get(id);\n const label = edge?.label;\n if (bounds || label) {\n edgeLabelBounds.set(id, {\n ...position,\n width: bounds?.width ?? label!.width,\n height: bounds?.height ?? label!.height,\n });\n }\n }\n }\n if (hasHierarchy) {\n centerCompoundEdgeLabels(\n layoutGraph,\n edgeLabelPositions,\n edgeLabelBounds,\n nodeBounds,\n nodesById,\n context.fixedIds,\n );\n centerAncestorDescendantEdgeLabels(\n layoutGraph,\n edgeLabelPositions,\n edgeLabelBounds,\n nodeBounds,\n nodesById,\n context.fixedIds,\n options,\n );\n for (let pass = 0; pass < 12; pass++) {\n const labelsMoved = avoidEdgeLabelOverlaps(\n layoutGraph,\n edgeLabelPositions,\n edgeLabelBounds,\n nodeBounds,\n nodesById,\n context.fixedIds,\n options.direction ?? layoutGraph.direction,\n );\n const groupsMoved = reconcileDerivedGroupBounds(\n layoutGraph,\n positions,\n nodeSizes,\n nodeBounds,\n edgeLabelPositions,\n edgeLabelBounds,\n edgeRoutes,\n context.fixedIds,\n options,\n );\n if (!labelsMoved && !groupsMoved) break;\n }\n }\n const missingNodes = layoutGraph.nodes\n .map((node) => node.id)\n .filter((id) => !context.fixedIds.has(id) && !positions.has(id))\n .sort();\n if (missingNodes.length > 0) {\n const message = `ELK omitted node geometry: ${missingNodes.join(', ')}`;\n context.diagnostics.push({ severity: 'warning', code: 'missing-node', message });\n options.onWarning?.(message);\n }\n return {\n positions,\n nodeSizes,\n nodeBounds,\n ...(edgeLabelPositions.size > 0 ? { edgeLabelPositions } : {}),\n ...(edgeLabelBounds.size > 0 ? { edgeLabelBounds } : {}),\n ...(edgeRoutes.size > 0 ? { edgeRoutes } : {}),\n ...(context.diagnostics.length > 0\n ? { diagnostics: context.diagnostics }\n : {}),\n source: context.source,\n metadata: context.metadata,\n } satisfies LayoutResult;\n };\n};\n\nasync function restoreExplicitCompoundDirections(\n elk: InstanceType<typeof ELK>,\n graph: FlowGraph,\n positions: Map<string, Point>,\n nodeSizes: Map<string, Size>,\n nodeBounds: Map<string, Rect>,\n edgeLabelBounds: Map<string, Rect>,\n edgeRoutes: Map<string, { waypoints: Point[] }>,\n fixedIds: ReadonlySet<string>,\n options: FlowLayoutOptions,\n): Promise<void> {\n const nodesById = new Map(graph.nodes.map((node) => [node.id, node]));\n const childrenByParent = new Map<string, FlowNode[]>();\n for (const node of graph.nodes) {\n if (!node.parentId) continue;\n const children = childrenByParent.get(node.parentId) ?? [];\n children.push(node);\n childrenByParent.set(node.parentId, children);\n }\n const depthOf = (node: FlowNode) => {\n let depth = 0;\n let marker = node.parentId ? nodesById.get(node.parentId) : undefined;\n while (marker) {\n depth++;\n marker = marker.parentId ? nodesById.get(marker.parentId) : undefined;\n }\n return depth;\n };\n const descendantsOf = (id: string) => {\n const descendants = new Set<string>([id]);\n const pending = [id];\n while (pending.length > 0) {\n for (const child of childrenByParent.get(pending.pop()!) ?? []) {\n descendants.add(child.id);\n pending.push(child.id);\n }\n }\n return descendants;\n };\n const directChildOf = (id: string, groupId: string): string | undefined => {\n let marker = nodesById.get(id);\n while (marker?.parentId && marker.parentId !== groupId) {\n marker = nodesById.get(marker.parentId);\n }\n return marker?.parentId === groupId ? marker.id : undefined;\n };\n const groups = graph.nodes\n .filter(\n (node) =>\n node.group?.direction &&\n node.group.direction !==\n (options.direction ?? graph.direction ?? 'down') &&\n (childrenByParent.get(node.id)?.length ?? 0) > 1,\n )\n .sort((a, b) => depthOf(b) - depthOf(a));\n\n for (const group of groups) {\n const children = childrenByParent.get(group.id)!;\n const childDescendants = new Map(\n children.map((child) => [child.id, descendantsOf(child.id)]),\n );\n if (\n [...childDescendants.values()].some((ids) =>\n [...ids].some((id) => fixedIds.has(id)),\n )\n ) {\n continue;\n }\n const currentChildren = children.flatMap((child) => {\n const bounds = nodeBounds.get(child.id);\n return bounds ? [{ child, bounds }] : [];\n });\n if (currentChildren.length < 2) continue;\n const centers = currentChildren.map(({ bounds }) => ({\n x: bounds.x + bounds.width / 2,\n y: bounds.y + bounds.height / 2,\n }));\n const dx =\n Math.max(...centers.map((center) => center.x)) -\n Math.min(...centers.map((center) => center.x));\n const dy =\n Math.max(...centers.map((center) => center.y)) -\n Math.min(...centers.map((center) => center.y));\n const alreadyDirected =\n ((group.group!.direction === 'right' ||\n group.group!.direction === 'left') &&\n dx >= dy) ||\n ((group.group!.direction === 'down' ||\n group.group!.direction === 'up') &&\n dy >= dx);\n if (alreadyDirected) continue;\n\n const localEdges: ElkExtendedEdge[] = [];\n for (const edge of graph.edges) {\n const sourceId = directChildOf(edge.sourceId, group.id);\n const targetId = edge.targetId\n ? directChildOf(edge.targetId, group.id)\n : undefined;\n if (!sourceId || !targetId || sourceId === targetId) continue;\n localEdges.push({\n id: `direction:${edge.id}`,\n sources: [sourceId],\n targets: [targetId],\n labels: edge.label\n ? [\n {\n id: `direction:${edge.id}:label`,\n width: edge.label.width,\n height: edge.label.height,\n },\n ]\n : undefined,\n });\n }\n const direction = group.group!.direction!;\n const localLayoutOptions: Record<string, string> = {\n 'elk.algorithm': 'layered',\n 'elk.direction': elkDirection(direction),\n 'elk.spacing.nodeNode': String(options.nodeSpacing ?? 60),\n };\n applyCompoundLayeredOptions(\n localLayoutOptions,\n localEdges,\n direction,\n options,\n );\n // A compound's local rerun must retain its configured cycle orientation.\n const nestedNodeOptions = options.node?.layoutOptions;\n const cycleBreakingStrategy =\n options.node?.['elk.layered.cycleBreaking.strategy'] ??\n (nestedNodeOptions && typeof nestedNodeOptions === 'object'\n ? (nestedNodeOptions as Record<string, unknown>)['elk.layered.cycleBreaking.strategy']\n : undefined) ??\n options.graph?.['elk.layered.cycleBreaking.strategy'];\n if (cycleBreakingStrategy !== undefined) {\n localLayoutOptions['elk.layered.cycleBreaking.strategy'] = String(cycleBreakingStrategy);\n }\n const localResult = await elk.layout({\n id: `direction:${group.id}`,\n layoutOptions: localLayoutOptions,\n children: currentChildren.map(({ child, bounds }) => ({\n id: child.id,\n width: bounds.width,\n height: bounds.height,\n })),\n edges: localEdges,\n });\n const laidOutChildren: ElkNode[] = localResult.children ?? [];\n const currentX = Math.min(...currentChildren.map(({ bounds }) => bounds.x));\n const currentY = Math.min(...currentChildren.map(({ bounds }) => bounds.y));\n const localX = Math.min(...laidOutChildren.map((child) => child.x ?? 0));\n const localY = Math.min(...laidOutChildren.map((child) => child.y ?? 0));\n if (group.group?.type === 'fixed') {\n const groupBounds = nodeBounds.get(group.id);\n const candidateBounds = laidOutChildren.reduce<Rect | null>(\n (bounds, child) =>\n unionRect(bounds, {\n x: currentX + (child.x ?? 0) - localX,\n y: currentY + (child.y ?? 0) - localY,\n width: child.width ?? 0,\n height: child.height ?? 0,\n }),\n null,\n );\n if (\n !groupBounds ||\n !candidateBounds ||\n candidateBounds.x < groupBounds.x ||\n candidateBounds.y < groupBounds.y ||\n candidateBounds.x + candidateBounds.width >\n groupBounds.x + groupBounds.width ||\n candidateBounds.y + candidateBounds.height >\n groupBounds.y + groupBounds.height\n ) {\n continue;\n }\n }\n const movedIds = new Set<string>();\n\n for (const laidOut of laidOutChildren) {\n const current = nodeBounds.get(laidOut.id);\n if (!current) continue;\n const dx = currentX + (laidOut.x ?? 0) - localX - current.x;\n const dy = currentY + (laidOut.y ?? 0) - localY - current.y;\n if (dx === 0 && dy === 0) continue;\n const descendants = childDescendants.get(laidOut.id)!;\n for (const id of descendants) {\n movedIds.add(id);\n const position = positions.get(id);\n if (position) positions.set(id, { x: position.x + dx, y: position.y + dy });\n const bounds = nodeBounds.get(id);\n if (bounds) nodeBounds.set(id, { ...bounds, x: bounds.x + dx, y: bounds.y + dy });\n }\n }\n for (const edge of graph.edges) {\n if (movedIds.has(edge.sourceId) || movedIds.has(edge.targetId)) {\n edgeLabelBounds.delete(edge.id);\n edgeRoutes.set(edge.id, { waypoints: [] });\n }\n }\n\n if (group.group?.type === 'derived') {\n let content: Rect | null = null;\n for (const child of children) {\n const bounds = nodeBounds.get(child.id);\n if (bounds) content = unionRect(content, bounds);\n }\n const stored = boundsOf(\n group,\n options.getBounds as ((node: FlowNode) => Rect) | undefined,\n );\n const derived = deriveGroupGeometry(\n { width: stored.width, height: stored.height },\n content,\n group.group,\n nodeBounds.get(group.id),\n ).bounds;\n positions.set(group.id, { x: derived.x, y: derived.y });\n nodeBounds.set(group.id, derived);\n nodeSizes.set(group.id, { width: derived.width, height: derived.height });\n }\n }\n}\n\nfunction rectsOverlap(a: Rect, b: Rect): boolean {\n return (\n a.x < b.x + b.width &&\n a.x + a.width > b.x &&\n a.y < b.y + b.height &&\n a.y + a.height > b.y\n );\n}\n\nfunction centerCompoundEdgeLabels(\n graph: FlowGraph,\n positions: Map<string, Point>,\n boundsById: Map<string, Rect>,\n nodeBounds: ReadonlyMap<string, Rect>,\n nodesById: ReadonlyMap<string, FlowNode>,\n fixedIds: ReadonlySet<string>,\n): void {\n for (const edge of graph.edges) {\n if (fixedIds.has(edge.id) || edge.sourceId === edge.targetId) continue;\n const sourceNode = nodesById.get(edge.sourceId);\n const targetNode = nodesById.get(edge.targetId);\n if (\n !sourceNode?.parentId ||\n sourceNode.parentId !== targetNode?.parentId\n ) {\n continue;\n }\n const parent = nodesById.get(sourceNode.parentId);\n const direction = parent?.group?.direction ?? graph.direction ?? 'down';\n const source = nodeBounds.get(edge.sourceId);\n const target = nodeBounds.get(edge.targetId);\n const label = boundsById.get(edge.id);\n if (!source || !target || !label) continue;\n\n const horizontal = direction === 'left' || direction === 'right';\n const sourceBeforeTarget = horizontal\n ? source.x + source.width / 2 < target.x + target.width / 2\n : source.y + source.height / 2 < target.y + target.height / 2;\n const before = sourceBeforeTarget ? source : target;\n const after = sourceBeforeTarget ? target : source;\n const available = horizontal\n ? after.x - (before.x + before.width)\n : after.y - (before.y + before.height);\n const labelSize = horizontal ? label.width : label.height;\n if (available < labelSize + 48) continue;\n\n const position = horizontal\n ? {\n x: before.x + before.width + (available - label.width) / 2,\n y:\n (source.y + source.height / 2 +\n target.y +\n target.height / 2) /\n 2 -\n label.height / 2,\n }\n : {\n x:\n (source.x + source.width / 2 +\n target.x +\n target.width / 2) /\n 2 -\n label.width / 2,\n y: before.y + before.height + (available - label.height) / 2,\n };\n positions.set(edge.id, position);\n boundsById.set(edge.id, { ...label, ...position });\n }\n}\n\nfunction centerAncestorDescendantEdgeLabels(\n graph: FlowGraph,\n positions: Map<string, Point>,\n boundsById: Map<string, Rect>,\n nodeBounds: ReadonlyMap<string, Rect>,\n nodesById: ReadonlyMap<string, FlowNode>,\n fixedIds: ReadonlySet<string>,\n options: FlowLayoutOptions,\n): void {\n for (const edge of graph.edges) {\n if (fixedIds.has(edge.id) || edge.sourceId === edge.targetId) continue;\n const relation = ancestorEndpoint(edge, nodesById);\n const label = boundsById.get(edge.id);\n const ancestorBounds = relation\n ? nodeBounds.get(relation.ancestor.id)\n : undefined;\n const descendantBounds = relation\n ? nodeBounds.get(relation.descendant.id)\n : undefined;\n if (!relation || !label || !ancestorBounds || !descendantBounds) continue;\n\n const content = groupContentBounds(\n relation.ancestor,\n ancestorBounds,\n options.getBounds as ((node: FlowNode) => Rect) | undefined,\n );\n const side = relation.ancestor.group?.content ?? 'top';\n const vertical = side === 'top' || side === 'bottom';\n const before =\n side === 'top' || side === 'left' ? content : descendantBounds;\n const after =\n side === 'top' || side === 'left' ? descendantBounds : content;\n const available = vertical\n ? after.y - (before.y + before.height)\n : after.x - (before.x + before.width);\n const labelSize = vertical ? label.height : label.width;\n if (available < labelSize + 24) continue;\n\n const position = vertical\n ? {\n x:\n descendantBounds.x +\n descendantBounds.width / 2 -\n label.width / 2,\n y: before.y + before.height + (available - label.height) / 2,\n }\n : {\n x: before.x + before.width + (available - label.width) / 2,\n y:\n descendantBounds.y +\n descendantBounds.height / 2 -\n label.height / 2,\n };\n positions.set(edge.id, position);\n boundsById.set(edge.id, { ...label, ...position });\n }\n}\n\nfunction avoidEdgeLabelOverlaps(\n graph: FlowGraph,\n positions: Map<string, Point>,\n boundsById: Map<string, Rect>,\n nodeBounds: ReadonlyMap<string, Rect>,\n nodesById: ReadonlyMap<string, FlowNode>,\n fixedIds: ReadonlySet<string>,\n direction = graph.direction ?? 'down',\n): boolean {\n const settledLabels: Rect[] = [];\n let moved = false;\n\n for (const edge of graph.edges) {\n const bounds = boundsById.get(edge.id);\n if (!bounds || fixedIds.has(edge.id)) continue;\n\n const ignoredNodeIds = new Set<string>();\n const containerId = semanticEdgeOwnerId(edge, nodesById);\n if (edge.sourceId === edge.targetId) {\n ignoredNodeIds.add(edge.sourceId);\n }\n if (containerId) {\n let container = nodesById.get(containerId);\n while (container) {\n ignoredNodeIds.add(container.id);\n container = container.parentId\n ? nodesById.get(container.parentId)\n : undefined;\n }\n }\n\n const obstacles = [\n ...[...nodeBounds].flatMap(([id, rect]) =>\n ignoredNodeIds.has(id) ? [] : [rect],\n ),\n ...settledLabels,\n ];\n const ancestor = ancestorEndpoint(edge, nodesById)?.ancestor;\n const contentSide = ancestor?.group?.content;\n const labelDirection =\n contentSide === 'top' || contentSide === 'bottom'\n ? 'down'\n : contentSide === 'left' || contentSide === 'right'\n ? 'right'\n : direction;\n const position = nearestClearLabelPosition(\n bounds,\n obstacles,\n labelDirection,\n );\n if (position.x !== bounds.x || position.y !== bounds.y) moved = true;\n const placed = { ...bounds, ...position };\n positions.set(edge.id, position);\n boundsById.set(edge.id, placed);\n settledLabels.push(placed);\n }\n return moved;\n}\n\nfunction nearestClearLabelPosition(\n label: Rect,\n obstacles: readonly Rect[],\n direction: string,\n): Point {\n const gap = 12;\n const origin = { x: label.x, y: label.y };\n const horizontal = direction === 'left' || direction === 'right';\n const score = (point: Point) => {\n const dx = point.x - origin.x;\n const dy = point.y - origin.y;\n return horizontal ? dx * dx * 2 + dy * dy : dx * dx + dy * dy * 2;\n };\n const candidates: Point[] = [origin];\n const visited = new Set<string>();\n\n for (let attempts = 0; candidates.length > 0 && attempts < 1_000; attempts++) {\n candidates.sort((a, b) => score(a) - score(b));\n const candidate = candidates.shift()!;\n const key = `${candidate.x.toFixed(3)},${candidate.y.toFixed(3)}`;\n if (visited.has(key)) continue;\n visited.add(key);\n\n const candidateBounds = { ...label, ...candidate };\n const overlapping = obstacles.filter((obstacle) =>\n rectsOverlap(candidateBounds, obstacle),\n );\n if (overlapping.length === 0) return candidate;\n\n for (const obstacle of overlapping) {\n candidates.push(\n { x: obstacle.x - label.width - gap, y: candidate.y },\n { x: obstacle.x + obstacle.width + gap, y: candidate.y },\n { x: candidate.x, y: obstacle.y - label.height - gap },\n { x: candidate.x, y: obstacle.y + obstacle.height + gap },\n );\n }\n }\n\n return origin;\n}\n\nfunction reconcileDerivedGroupBounds(\n graph: FlowGraph,\n positions: Map<string, Point>,\n nodeSizes: Map<string, Size>,\n nodeBounds: Map<string, Rect>,\n edgeLabelPositions: Map<string, Point>,\n edgeLabelBounds: Map<string, Rect>,\n edgeRoutes: Map<string, { waypoints: Point[] }>,\n fixedIds: ReadonlySet<string>,\n options: FlowLayoutOptions,\n): boolean {\n const nodesById = new Map(graph.nodes.map((node) => [node.id, node]));\n const childrenByParent = new Map<string | undefined, string[]>();\n for (const node of graph.nodes) {\n const parentId = node.parentId ?? undefined;\n const children = childrenByParent.get(parentId) ?? [];\n children.push(node.id);\n childrenByParent.set(parentId, children);\n }\n const edgesByOwner = new Map<string, FlowEdge[]>();\n for (const edge of graph.edges) {\n const ownerId = semanticEdgeOwnerId(edge, nodesById);\n if (!ownerId) continue;\n const edges = edgesByOwner.get(ownerId) ?? [];\n edges.push(edge);\n edgesByOwner.set(ownerId, edges);\n }\n\n const effectiveBounds = (id: string, cache: Map<string, Rect>): Rect => {\n const cached = cache.get(id);\n if (cached) return cached;\n const node = nodesById.get(id)!;\n const base = nodeBounds.get(id) ?? boundsOf(node, options.getBounds as (node: FlowNode) => Rect);\n if (node.group?.type !== 'derived') {\n cache.set(id, base);\n return base;\n }\n\n let content: Rect | null = null;\n for (const childId of childrenByParent.get(id) ?? []) {\n content = unionRect(content, effectiveBounds(childId, cache));\n }\n for (const edge of edgesByOwner.get(id) ?? []) {\n if (edge.sourceId === id && edge.targetId === id) continue;\n const label = edgeLabelBounds.get(edge.id);\n if (label) content = unionRect(content, label);\n }\n const stored = boundsOf(node, options.getBounds as (node: FlowNode) => Rect);\n const derived = deriveGroupGeometry(\n { width: stored.width, height: stored.height },\n content,\n node.group,\n base,\n ).bounds;\n cache.set(id, derived);\n return derived;\n };\n\n const descendantsOf = (id: string): Set<string> => {\n const descendants = new Set<string>([id]);\n const pending = [id];\n while (pending.length > 0) {\n for (const childId of childrenByParent.get(pending.pop()!) ?? []) {\n descendants.add(childId);\n pending.push(childId);\n }\n }\n return descendants;\n };\n\n const shiftSubtree = (id: string, dx: number, dy: number): void => {\n const descendants = descendantsOf(id);\n for (const nodeId of descendants) {\n const position = positions.get(nodeId);\n if (position) positions.set(nodeId, { x: position.x + dx, y: position.y + dy });\n const bounds = nodeBounds.get(nodeId);\n if (bounds) nodeBounds.set(nodeId, { ...bounds, x: bounds.x + dx, y: bounds.y + dy });\n }\n for (const edge of graph.edges) {\n const ownerId = semanticEdgeOwnerId(edge, nodesById);\n if (ownerId && descendants.has(ownerId)) {\n const position = edgeLabelPositions.get(edge.id);\n if (position) {\n edgeLabelPositions.set(edge.id, {\n x: position.x + dx,\n y: position.y + dy,\n });\n }\n const bounds = edgeLabelBounds.get(edge.id);\n if (bounds) {\n edgeLabelBounds.set(edge.id, {\n ...bounds,\n x: bounds.x + dx,\n y: bounds.y + dy,\n });\n }\n const route = edgeRoutes.get(edge.id);\n if (route) {\n edgeRoutes.set(edge.id, {\n waypoints: route.waypoints.map((point) => ({\n x: point.x + dx,\n y: point.y + dy,\n })),\n });\n }\n } else if (\n descendants.has(edge.sourceId) ||\n descendants.has(edge.targetId)\n ) {\n edgeRoutes.set(edge.id, { waypoints: [] });\n }\n }\n };\n\n const direction = options.direction ?? graph.direction ?? 'down';\n const horizontal = direction === 'left' || direction === 'right';\n const reverse = direction === 'left' || direction === 'up';\n let cache = new Map<string, Rect>();\n let changed = false;\n const gap = options.nodeSpacing ?? 60;\n\n const depthOf = (parentId: string | undefined): number => {\n let depth = 0;\n let marker = parentId ? nodesById.get(parentId) : undefined;\n while (marker) {\n depth++;\n marker = marker.parentId ? nodesById.get(marker.parentId) : undefined;\n }\n return depth;\n };\n const containers = [...childrenByParent.keys()].sort(\n (a, b) => depthOf(b) - depthOf(a),\n );\n\n for (const containerId of containers) {\n const ordered = [...(childrenByParent.get(containerId) ?? [])].sort(\n (a, b) => {\n const aBounds = effectiveBounds(a, cache);\n const bBounds = effectiveBounds(b, cache);\n const delta = horizontal\n ? aBounds.x - bBounds.x\n : aBounds.y - bBounds.y;\n return reverse ? -delta : delta;\n },\n );\n for (let i = 0; i < ordered.length; i++) {\n for (let j = i + 1; j < ordered.length; j++) {\n const first = effectiveBounds(ordered[i]!, cache);\n const second = effectiveBounds(ordered[j]!, cache);\n if (!rectsOverlap(first, second)) continue;\n if ([...descendantsOf(ordered[j]!)].some((id) => fixedIds.has(id))) {\n continue;\n }\n const delta = horizontal\n ? reverse\n ? first.x - gap - (second.x + second.width)\n : first.x + first.width + gap - second.x\n : reverse\n ? first.y - gap - (second.y + second.height)\n : first.y + first.height + gap - second.y;\n shiftSubtree(\n ordered[j]!,\n horizontal ? delta : 0,\n horizontal ? 0 : delta,\n );\n cache = new Map();\n changed = true;\n }\n }\n }\n\n cache = new Map();\n for (const node of graph.nodes) {\n if (node.group?.type !== 'derived' || fixedIds.has(node.id)) continue;\n const bounds = effectiveBounds(node.id, cache);\n positions.set(node.id, { x: bounds.x, y: bounds.y });\n nodeBounds.set(node.id, bounds);\n nodeSizes.set(node.id, { width: bounds.width, height: bounds.height });\n }\n return changed;\n}\n\nfunction unionRect(a: Rect | null, b: Rect): Rect {\n if (!a) return { ...b };\n const x = Math.min(a.x, b.x);\n const y = Math.min(a.y, b.y);\n const right = Math.max(a.x + a.width, b.x + b.width);\n const bottom = Math.max(a.y + a.height, b.y + b.height);\n return { x, y, width: right - x, height: bottom - y };\n}\n\nconst SIDE_TO_ELK: Record<string, string> = {\n top: 'NORTH',\n bottom: 'SOUTH',\n left: 'WEST',\n right: 'EAST',\n};\n\nexport function toElkGraph(\n graph: FlowGraph,\n options: FlowLayoutOptions,\n): ElkNode {\n const childIdsByParent = new Map<string | undefined, string[]>();\n for (const node of graph.nodes) {\n const parentId = node.parentId ?? undefined;\n const siblings = childIdsByParent.get(parentId) ?? [];\n siblings.push(node.id);\n childIdsByParent.set(parentId, siblings);\n }\n const nodesById = new Map(graph.nodes.map((node) => [node.id, node]));\n const ancestorLabelClearance = new Map<string, number>();\n for (const edge of graph.edges) {\n if (!edge.label) continue;\n const ancestor = ancestorEndpoint(edge, nodesById)?.ancestor;\n if (!ancestor?.group) continue;\n const side = ancestor.group.content ?? 'top';\n const extent =\n (side === 'top' || side === 'bottom'\n ? edge.label.height\n : edge.label.width) + 24;\n ancestorLabelClearance.set(\n ancestor.id,\n Math.max(ancestorLabelClearance.get(ancestor.id) ?? 0, extent),\n );\n }\n\n // Assign each edge to the Lowest Common Ancestor (LCA) of its source &\n // target and nest it in THAT container's ELK subtree (not root), so ELK\n // routes intra-group edges INSIDE the group. Edges crossing group\n // boundaries — or with no common group — live at the root.\n const edgesByContainer = new Map<string | undefined, ElkExtendedEdge[]>();\n for (const edge of graph.edges) {\n const containerId = elkEdgeContainerId(edge, nodesById);\n const bucket = edgesByContainer.get(containerId) ?? [];\n bucket.push(toElkEdge(edge, options));\n edgesByContainer.set(containerId, bucket);\n }\n const rootEdges = edgesByContainer.get(undefined) ?? [];\n const hasRootHierarchyEdge = hasRootHierarchyEdges(graph, nodesById);\n const rootDirection = options.direction ?? graph.direction;\n const graphOptions = stringOptions(options.graph);\n const configuredRootRankSpacing = finiteNumberOption(\n graphOptions['elk.layered.spacing.nodeNodeBetweenLayers'] ??\n options.rankSpacing,\n 90,\n );\n const hasDerivedGroup = graph.nodes.some(\n (node) => node.group?.type === 'derived',\n );\n\n return {\n id: 'root',\n layoutOptions: {\n 'elk.algorithm': 'layered',\n 'elk.direction': elkDirection(rootDirection),\n 'elk.spacing.nodeNode': String(options.nodeSpacing ?? 60),\n 'elk.layered.spacing.nodeNodeBetweenLayers': String(options.rankSpacing ?? 90),\n ...(options.scope ? { 'elk.interactive': 'true' } : {}),\n ...graphOptions,\n ...(hasRootHierarchyEdge\n ? { 'elk.hierarchyHandling': 'INCLUDE_CHILDREN' }\n : {}),\n ...(hasDerivedGroup\n ? {\n 'elk.layered.spacing.nodeNodeBetweenLayers': String(\n labelAwareRankSpacing(\n rootEdges,\n rootDirection === 'left' || rootDirection === 'right',\n configuredRootRankSpacing,\n ),\n ),\n }\n : {}),\n },\n children: (childIdsByParent.get(undefined) ?? []).map((id) =>\n toElkNode(\n nodesById.get(id)!,\n childIdsByParent,\n nodesById,\n edgesByContainer,\n ancestorLabelClearance,\n options,\n ),\n ),\n edges: rootEdges,\n };\n}\n\nfunction hasRootHierarchyEdges(\n graph: FlowGraph,\n nodesById: ReadonlyMap<string, FlowNode>,\n): boolean {\n return graph.edges.some((edge) => {\n if (elkEdgeContainerId(edge, nodesById) !== undefined) return false;\n return ancestorEndpoint(edge, nodesById) !== undefined;\n });\n}\n\nfunction toElkEdge(edge: FlowEdge, options: FlowLayoutOptions): ElkExtendedEdge {\n const labelLayoutOptions = stringOptions(options.label);\n return {\n id: edge.id,\n sources: [edge.sourcePort ? `${edge.sourceId}:${edge.sourcePort}` : edge.sourceId],\n targets: [edge.targetPort ? `${edge.targetId}:${edge.targetPort}` : edge.targetId],\n labels: edge.label\n ? [\n {\n id: `${edge.id}:label`,\n width: edge.label.width,\n height: edge.label.height,\n ...(Object.keys(labelLayoutOptions).length > 0\n ? { layoutOptions: labelLayoutOptions }\n : {}),\n },\n ]\n : undefined,\n ...options.edge,\n } as ElkExtendedEdge;\n}\n\n/**\n * The semantic owner whose derived bounds include the edge label: the Lowest\n * Common Ancestor of its source & target (undefined = root). Walk the source's\n * ancestor chain (including the source itself) into a set, then walk the\n * target's chain up until it hits a member of that set. An edge whose\n * endpoints are both children of group G resolves to G; a cross-boundary edge\n * resolves to the shared ancestor (often root/undefined).\n */\nfunction semanticEdgeOwnerId(\n edge: FlowEdge,\n nodesById: ReadonlyMap<string, FlowNode>,\n): string | undefined {\n const source = nodesById.get(edge.sourceId);\n const target = edge.targetId ? nodesById.get(edge.targetId) : undefined;\n if (!source) return undefined;\n if (!target || source === target) return source.parentId ?? undefined;\n\n const ancestors = new Set<string>([source.id]);\n let marker: FlowNode | undefined = source.parentId\n ? nodesById.get(source.parentId)\n : undefined;\n while (marker) {\n ancestors.add(marker.id);\n marker = marker.parentId ? nodesById.get(marker.parentId) : undefined;\n }\n marker = target;\n while (marker) {\n if (ancestors.has(marker.id)) return marker.id;\n marker = marker.parentId ? nodesById.get(marker.parentId) : undefined;\n }\n return undefined;\n}\n\nfunction ancestorEndpoint(\n edge: FlowEdge,\n nodesById: ReadonlyMap<string, FlowNode>,\n): { ancestor: FlowNode; descendant: FlowNode } | undefined {\n const source = nodesById.get(edge.sourceId);\n const target = edge.targetId ? nodesById.get(edge.targetId) : undefined;\n if (!source || !target) return undefined;\n\n const isAncestor = (ancestor: FlowNode, descendant: FlowNode) => {\n let marker = descendant.parentId\n ? nodesById.get(descendant.parentId)\n : undefined;\n while (marker) {\n if (marker.id === ancestor.id) return true;\n marker = marker.parentId ? nodesById.get(marker.parentId) : undefined;\n }\n return false;\n };\n\n if (source.group && isAncestor(source, target)) {\n return { ancestor: source, descendant: target };\n }\n if (target.group && isAncestor(target, source)) {\n return { ancestor: target, descendant: source };\n }\n return undefined;\n}\n\nfunction groupContentBounds(\n node: FlowNode,\n bounds: Rect,\n getBounds?: (node: FlowNode) => Rect,\n): Rect {\n const side = node.group?.content ?? 'top';\n const size =\n node.group?.type === 'fixed'\n ? (node.group.contentSize ?? { width: 0, height: 0 })\n : boundsOf(node, getBounds);\n if (side === 'top' || side === 'bottom') {\n const height = Math.min(size.height, bounds.height);\n return {\n x: bounds.x,\n y: side === 'top' ? bounds.y : bounds.y + bounds.height - height,\n width: bounds.width,\n height,\n };\n }\n const width = Math.min(size.width, bounds.width);\n return {\n x: side === 'left' ? bounds.x : bounds.x + bounds.width - width,\n y: bounds.y,\n width,\n height: bounds.height,\n };\n}\n\nfunction elkEdgeContainerId(\n edge: FlowEdge,\n nodesById: ReadonlyMap<string, FlowNode>,\n): string | undefined {\n const source = nodesById.get(edge.sourceId);\n const target = edge.targetId ? nodesById.get(edge.targetId) : undefined;\n // Self-edge or dangling target: nest in the source's parent group.\n if (!source) return undefined;\n if (!target || source === target) return source.parentId ?? undefined;\n\n const isAncestorOf = (ancestor: FlowNode, descendant: FlowNode): boolean => {\n let marker = descendant.parentId\n ? nodesById.get(descendant.parentId)\n : undefined;\n while (marker) {\n if (marker.id === ancestor.id) return true;\n marker = marker.parentId ? nodesById.get(marker.parentId) : undefined;\n }\n return false;\n };\n\n // A container cannot also be an endpoint of an edge nested inside itself.\n // Keep ancestor-descendant edges on the ancestor's parent canvas for ELK;\n // semantic ownership still belongs to the ancestor.\n if (isAncestorOf(source, target)) return source.parentId ?? undefined;\n if (isAncestorOf(target, source)) return target.parentId ?? undefined;\n\n // Source's ancestor chain, including the source itself.\n const ancestors = new Set<string>([source.id]);\n let marker: FlowNode | undefined = source.parentId\n ? nodesById.get(source.parentId)\n : undefined;\n while (marker) {\n ancestors.add(marker.id);\n marker = marker.parentId ? nodesById.get(marker.parentId) : undefined;\n }\n\n // First target-chain node (including target itself) that's a source\n // ancestor is the LCA — the deepest node containing both endpoints. When\n // both endpoints are children of group G, this is G, so the edge nests in\n // G. A cross-boundary edge resolves to a higher shared node (often root).\n marker = target;\n while (marker) {\n if (ancestors.has(marker.id)) return marker.id;\n marker = marker.parentId ? nodesById.get(marker.parentId) : undefined;\n }\n return undefined;\n}\n\nfunction toElkNode(\n node: FlowNode,\n childIdsByParent: Map<string | undefined, string[]>,\n nodesById: Map<string, FlowNode>,\n edgesByContainer: Map<string | undefined, ElkExtendedEdge[]>,\n ancestorLabelClearance: ReadonlyMap<string, number>,\n options: FlowLayoutOptions,\n): ElkNode {\n const bounds = boundsOf(node, options.getBounds as (node: FlowNode) => any);\n const children = (childIdsByParent.get(node.id) ?? []).map((id) =>\n toElkNode(\n nodesById.get(id)!,\n childIdsByParent,\n nodesById,\n edgesByContainer,\n ancestorLabelClearance,\n options,\n ),\n );\n const ports = (node.ports ?? []).map((port) => ({\n id: `${node.id}:${port.name}`,\n x: port.x,\n y: port.y,\n width: port.width,\n height: port.height,\n layoutOptions: {\n 'elk.port.side': SIDE_TO_ELK[(port as { side?: string }).side ?? 'right'] ?? 'EAST',\n },\n }));\n\n // Edges whose LCA is this node nest here so ELK routes them within it.\n const nestedEdges = edgesByContainer.get(node.id);\n const isCompound = children.length > 0 && isGroup(node);\n const configuredNode = { ...(options.node ?? {}) };\n const configuredLayoutOptions =\n configuredNode.layoutOptions &&\n typeof configuredNode.layoutOptions === 'object' &&\n !Array.isArray(configuredNode.layoutOptions)\n ? stringOptions(configuredNode.layoutOptions as Record<string, unknown>)\n : {};\n delete configuredNode.layoutOptions;\n for (const [key, value] of Object.entries(configuredNode)) {\n if (!key.startsWith('elk.')) continue;\n configuredLayoutOptions[key] = String(value);\n delete configuredNode[key];\n }\n const layoutOptions: Record<string, string> = configuredLayoutOptions;\n if (ports.length > 0) layoutOptions['elk.portConstraints'] = 'FIXED_SIDE';\n if (isCompound) {\n // Lay out this compound's descendants as one graph so it's sized to\n // contain them and its intra-group edges route INSIDE it. Set on the\n // compound (not root): setting it on root would force the root direction\n // onto every descendant.\n layoutOptions['elk.hierarchyHandling'] = 'INCLUDE_CHILDREN';\n // Let ELK size the compound around its children (a fixed authored\n // width/height would fight the child union and clip them), and reserve\n // the content block (header) side via padding so children never overlap\n // it.\n layoutOptions['elk.padding'] = elkPadding(\n groupInsets(\n node.group!,\n { width: bounds.width, height: bounds.height },\n ancestorLabelClearance.get(node.id),\n ),\n );\n layoutOptions['elk.nodeSize.constraints'] = 'NODE_LABELS PORTS MINIMUM_SIZE';\n layoutOptions['elk.nodeSize.minimum'] = `(${bounds.width},${bounds.height})`;\n const contentSide = node.group?.content ?? 'top';\n layoutOptions['elk.contentAlignment'] =\n contentSide === 'top' || contentSide === 'bottom'\n ? 'H_CENTER'\n : 'V_CENTER';\n const direction = node.group?.direction ?? options.direction ?? 'down';\n layoutOptions['elk.direction'] = elkDirection(direction);\n applyCompoundLayeredOptions(\n layoutOptions,\n nestedEdges ?? [],\n direction,\n options,\n );\n }\n\n const elkNode: ElkNode = {\n id: node.id,\n x: node.x,\n y: node.y,\n ports,\n children: children.length > 0 ? children : undefined,\n edges: nestedEdges && nestedEdges.length > 0 ? nestedEdges : undefined,\n ...configuredNode,\n layoutOptions:\n Object.keys(layoutOptions).length > 0 ? layoutOptions : undefined,\n };\n // Compounds are sized by ELK from their children; a fixed authored size\n // fights the child union and clips them. The width/height keys must be\n // OMITTED entirely (not set to undefined) — elkjs crashes on present-but-\n // undefined size keys.\n if (!isCompound) {\n elkNode.width = bounds.width;\n elkNode.height = bounds.height;\n }\n return elkNode;\n}\n\n/**\n * A compound is an independent layered graph. Root graph options are not\n * inherited reliably by that nested graph, so propagate the readability\n * options that matter there and reserve enough rank space for native labels.\n */\nfunction applyCompoundLayeredOptions(\n layoutOptions: Record<string, string>,\n edges: readonly ElkExtendedEdge[],\n direction: string,\n options: FlowLayoutOptions,\n): void {\n const graphOptions = stringOptions(options.graph);\n const propagatedOptions = [\n 'elk.spacing.edgeNode',\n 'elk.layered.spacing.edgeNodeBetweenLayers',\n 'elk.layered.nodePlacement.favorStraightEdges',\n 'elk.layered.nodePlacement.bk.edgeStraightening',\n 'elk.layered.feedbackEdges',\n 'elk.layered.unnecessaryBendpoints',\n ] as const;\n\n for (const key of propagatedOptions) {\n if (layoutOptions[key] === undefined && graphOptions[key] !== undefined) {\n layoutOptions[key] = graphOptions[key];\n }\n }\n\n layoutOptions['elk.layered.nodePlacement.favorStraightEdges'] ??= 'true';\n layoutOptions['elk.layered.nodePlacement.bk.edgeStraightening'] ??=\n 'IMPROVE_STRAIGHTNESS';\n\n const horizontal = direction === 'left' || direction === 'right';\n const spacingKey = 'elk.layered.spacing.nodeNodeBetweenLayers';\n const configuredSpacing = finiteNumberOption(\n layoutOptions[spacingKey] ??\n graphOptions[spacingKey] ??\n options.rankSpacing,\n 20,\n );\n // Keep a native edge label between ranks, with enough clearance that the\n // source -> event -> target chain remains readable instead of doglegging.\n layoutOptions[spacingKey] = String(\n labelAwareRankSpacing(edges, horizontal, configuredSpacing),\n );\n}\n\nfunction labelAwareRankSpacing(\n edges: readonly ElkExtendedEdge[],\n horizontal: boolean,\n configuredSpacing: number,\n): number {\n const largestLabel = Math.max(\n 0,\n ...edges.flatMap((edge) =>\n (edge.labels ?? []).map((label) =>\n horizontal ? label.width ?? 0 : label.height ?? 0,\n ),\n ),\n );\n return Math.max(configuredSpacing, largestLabel + 48);\n}\n\nfunction finiteNumberOption(value: unknown, fallback: number): number {\n const parsed = Number(value);\n return Number.isFinite(parsed) ? parsed : fallback;\n}\n\n/**\n * The inset ELK must leave inside a compound so children clear the group's\n * content block (header) and honor its padding. The content block occupies\n * one side at `contentSize` (fixed groups) or the node's own size (derived\n * groups); every side also carries the group's padding.\n */\nfunction groupInsets(\n group: NonNullable<FlowNode['group']>,\n bounds: Size,\n contentClearance = 0,\n): GroupInsets {\n const padding = resolveGroupPadding((group as GroupLayout).padding);\n const side: GroupContentSide = (group as GroupLayout).content ?? 'top';\n const contentSize: Size =\n group.type === 'fixed'\n ? group.contentSize ?? { width: 0, height: 0 }\n : bounds;\n const insets: GroupInsets = { ...padding };\n if (side === 'top')\n insets.top = contentSize.height + Math.max(padding.top, contentClearance);\n else if (side === 'bottom')\n insets.bottom =\n contentSize.height + Math.max(padding.bottom, contentClearance);\n else if (side === 'left')\n insets.left = contentSize.width + Math.max(padding.left, contentClearance);\n else\n insets.right =\n contentSize.width + Math.max(padding.right, contentClearance);\n return insets;\n}\n\nfunction elkPadding(insets: GroupInsets): string {\n return `[top=${insets.top},left=${insets.left},bottom=${insets.bottom},right=${insets.right}]`;\n}\n\nfunction collectElkGeometry(\n node: ElkNode,\n output: {\n positions: Map<string, Point>;\n nodeSizes: Map<string, Size>;\n nodeBounds: Map<string, Rect>;\n edgeLabelBounds: Map<string, Rect>;\n edgeRoutes: Map<string, { waypoints: Point[] }>;\n fixedIds: ReadonlySet<string>;\n },\n offsetX = 0,\n offsetY = 0,\n): void {\n const x = offsetX + (node.x ?? 0);\n const y = offsetY + (node.y ?? 0);\n if (\n node.id !== 'root' &&\n !output.fixedIds.has(node.id) &&\n Number.isFinite(x) &&\n Number.isFinite(y) &&\n Number.isFinite(node.width) &&\n Number.isFinite(node.height)\n ) {\n const size = { width: node.width!, height: node.height! };\n output.positions.set(node.id, { x, y });\n output.nodeSizes.set(node.id, size);\n output.nodeBounds.set(node.id, { x, y, ...size });\n }\n for (const edge of node.edges ?? []) {\n if (output.fixedIds.has(edge.id)) continue;\n const label = edge.labels?.[0];\n if (\n label &&\n Number.isFinite(label.x) &&\n Number.isFinite(label.y) &&\n Number.isFinite(label.width) &&\n Number.isFinite(label.height)\n ) {\n output.edgeLabelBounds.set(edge.id, {\n x: x + label.x!,\n y: y + label.y!,\n width: label.width!,\n height: label.height!,\n });\n }\n const sections = edge.sections ?? [];\n if (sections.length === 1) {\n output.edgeRoutes.set(edge.id, {\n waypoints: (sections[0]!.bendPoints ?? []).map((point) => ({\n x: x + point.x,\n y: y + point.y,\n })),\n });\n }\n }\n for (const child of node.children ?? []) {\n collectElkGeometry(child, output, x, y);\n }\n}\n\nfunction stringOptions(options: Record<string, unknown> | undefined): Record<string, string> {\n if (!options) return {};\n return Object.fromEntries(\n Object.entries(options).map(([key, value]) => [key, String(value)]),\n );\n}\n\nfunction elkDirection(direction: string | undefined): string {\n return (direction ?? 'down').toUpperCase();\n}\n"],"mappings":";;;;AAiCA,MAAa,aAAgC,UAAU,CAAC,MAAM;CAC5D,MAAM,MAAM,IAAI,IAAI;CACpB,OAAO,OAAO,OAAO,aAAa,CAAC,MAAM;EACvC,eAAe,UAAU;EACzB,MAAM,eAAe;EACrB,MAAM,QAAQ,kBAAkB,cAAc,QAAQ,OAAO,UAAU;EACvE,MAAM,cAAc,oBAAoB,cAAc,KAAK;EAC3D,MAAM,UAAU,iBAAiB,cAAc,SAAS,YAAY,KAAK;EACzE,MAAM,SAAS,MAAM,IAAI,OACvB,WAAW,aAAa;GAAE,GAAG;GAAS;EAAM,CAAC,CAC/C;EACA,eAAe,UAAU;EACzB,MAAM,4BAAY,IAAI,IAAmB;EACzC,MAAM,4BAAY,IAAI,IAAkB;EACxC,MAAM,6BAAa,IAAI,IAAkB;EACzC,MAAM,kCAAkB,IAAI,IAAkB;EAC9C,MAAM,6BAAa,IAAI,IAAoC;EAC3D,mBAAmB,QAAQ;GACzB;GACA;GACA;GACA;GACA;GACA,UAAU,QAAQ;EACpB,CAAC;EACD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AY,CAAC;EACnC,IAAI,SAAS,WAAW,GACtB,OAAO,WAAW,IAAI,KAAK,IAAI,EAC7B,YAAY,SAAS,EAAE,CAAE,cAAc,CAAC,EAAA,CAAG,KAAK,WAAW;GACzD,GAAG,IAAI,MAAM;GACb,GAAG,IAAI,MAAM;EACf,EAAE,EACJ,CAAC;CAEL;CACA,KAAK,MAAM,SAAS,KAAK,YAAY,CAAC,GACpC,mBAAmB,OAAO,QAAQ,GAAG,CAAC;AAE1C;AAEA,SAAS,cAAc,SAAsE;CAC3F,IAAI,CAAC,SAAS,OAAO,CAAC;CACtB,OAAO,OAAO,YACZ,OAAO,QAAQ,OAAO,CAAC,CAAC,KAAK,CAAC,KAAK,WAAW,CAAC,KAAK,OAAO,KAAK,CAAC,CAAC,CACpE;AACF;AAEA,SAAS,aAAa,WAAuC;CAC3D,QAAQ,aAAa,OAAA,CAAQ,YAAY;AAC3C"}
@@ -5,4 +5,5 @@ type StatelyLayoutOptions<TNodeData = any, TEdgeData = any, TLabelData = any> =
5
5
  /** Graph-native layered layout powered by `@statelyai/layout`. */
6
6
  declare const statelyLayout: <TNodeData = any, TEdgeData = any, TLabelData = any>(options?: StatelyLayoutOptions<TNodeData, TEdgeData, TLabelData>) => FlowLayoutAlgorithm<TNodeData, TEdgeData, TLabelData>;
7
7
  //#endregion
8
- export { StatelyLayoutOptions, statelyLayout };
8
+ export { StatelyLayoutOptions, statelyLayout };
9
+ //# sourceMappingURL=stately.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stately.d.ts","names":[],"sources":["../../../src/layout/stately.ts"],"mappings":";;;KA8BY,qBACV,iBACA,iBACA,oBACE,KAAK,mCACP,KACE,kBAAkB,WAAW,WAAW;;cAK/B,gBACX,iBACA,iBACA,kBAEA,UAAS,qBAAqB,WAAW,WAAW,gBACnD,oBAAoB,WAAW,WAAW"}
@@ -423,3 +423,5 @@ function fromStatelyGraph(graph, input, rootOffsets, fixedIds, getBounds, labelE
423
423
  }
424
424
  //#endregion
425
425
  export { statelyLayout };
426
+
427
+ //# sourceMappingURL=stately.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stately.js","names":[],"sources":["../../../src/layout/stately.ts"],"sourcesContent":["import {\n getLayeredLayout,\n type LayeredLayoutOptions,\n} from '@statelyai/layout/layered';\nimport { getLayout } from '@statelyai/layout';\nimport { getLCA, type GraphEdge, type VisualGraph } from '@statelyai/graph';\nimport type {\n EdgeRouting,\n FlowGraph,\n FlowNode,\n LayoutResult,\n Point,\n Rect,\n} from '@statelyai/flow';\nimport {\n deriveGroupGeometry,\n fixedGroupGeometry,\n isGroup,\n resolveGroupPadding,\n} from '@statelyai/flow';\nimport {\n boundsOf,\n graphForLayoutScope,\n layoutRunContext,\n mergedLayoutScope,\n throwIfAborted,\n type FlowLayoutAlgorithm,\n type FlowLayoutOptions,\n} from './shared';\n\nexport type StatelyLayoutOptions<\n TNodeData = any,\n TEdgeData = any,\n TLabelData = any,\n> = Omit<LayeredLayoutOptions, 'measure'> &\n Pick<\n FlowLayoutOptions<TNodeData, TEdgeData, TLabelData>,\n 'getBounds' | 'scope' | 'source' | 'metadata' | '_types'\n >;\n\n/** Graph-native layered layout powered by `@statelyai/layout`. */\nexport const statelyLayout = <\n TNodeData = any,\n TEdgeData = any,\n TLabelData = any,\n>(\n options: StatelyLayoutOptions<TNodeData, TEdgeData, TLabelData> = {},\n): FlowLayoutAlgorithm<TNodeData, TEdgeData, TLabelData> => {\n return async (graph, runOptions = {}) => {\n throwIfAborted(runOptions);\n const mutableGraph = graph as FlowGraph<\n TNodeData,\n TEdgeData,\n TLabelData\n >;\n const scope = mergedLayoutScope(mutableGraph, options.scope, runOptions);\n const layoutGraph = graphForLayoutScope(mutableGraph, scope);\n const context = layoutRunContext(\n mutableGraph,\n options,\n runOptions,\n 'stately',\n );\n const input = toStatelyGraph(layoutGraph, options.getBounds);\n const native = await getLayout({\n graph: input,\n algorithm: 'layered',\n options: nativeOptions(options),\n ...(runOptions.signal\n ? { signal: runOptions.signal as unknown as AbortSignal }\n : {}),\n });\n context.diagnostics.push(...native.diagnostics.map((entry) => ({ ...entry })));\n const output = applyFlowGroupContracts(\n native.graph,\n layoutGraph,\n nativeOptions(options),\n options.getBounds,\n );\n throwIfAborted(runOptions);\n return fromStatelyGraph(\n output,\n layoutGraph,\n promotedRootOffsets(layoutGraph, mutableGraph, options.getBounds),\n context.fixedIds,\n options.getBounds,\n new Set(layoutGraph.edges.filter((edge) => edge.label).map((edge) => edge.id)),\n {\n source: context.source,\n metadata: {\n ...context.metadata,\n algorithm: 'layered',\n },\n diagnostics: context.diagnostics,\n },\n );\n };\n};\n\nfunction nativeOptions(\n options: StatelyLayoutOptions,\n): LayeredLayoutOptions {\n const {\n getBounds: _getBounds,\n scope: _scope,\n source: _source,\n metadata: _metadata,\n _types,\n ...native\n } = options;\n void _types;\n return native;\n}\n\nfunction promotedRootOffsets(\n scoped: FlowGraph,\n full: FlowGraph,\n getBounds: ((node: FlowNode) => Rect) | undefined,\n): ReadonlyMap<string, Point> {\n if (scoped === full) return new Map();\n const scopedById = new Map(scoped.nodes.map((node) => [node.id, node]));\n const fullById = new Map(full.nodes.map((node) => [node.id, node]));\n return new Map(\n scoped.nodes.flatMap((node) => {\n const original = fullById.get(node.id);\n if (!original?.parentId || scopedById.has(original.parentId)) return [];\n const parent = fullById.get(original.parentId);\n return parent ? [[node.id, boundsOf(parent, getBounds)] as const] : [];\n }),\n );\n}\n\nfunction applyFlowGroupContracts(\n output: VisualGraph,\n input: FlowGraph,\n options: LayeredLayoutOptions,\n getBounds: ((node: FlowNode) => Rect) | undefined,\n): VisualGraph {\n const nodes = output.nodes.map((node) => ({ ...node }));\n const edges = output.edges.map((edge) => ({ ...edge }));\n const nodeById = new Map(nodes.map((node) => [node.id, node]));\n const inputById = new Map(input.nodes.map((node) => [node.id, node]));\n const edgeById = new Map(edges.map((edge) => [edge.id, edge]));\n const depth = (id: string): number => {\n let value = 0;\n let parentId = nodeById.get(id)?.parentId;\n const seen = new Set<string>();\n while (parentId && !seen.has(parentId)) {\n seen.add(parentId);\n value++;\n parentId = nodeById.get(parentId)?.parentId;\n }\n return value;\n };\n\n const layoutSiblings = (\n parentId: string | undefined,\n direction: FlowGraph['direction'],\n padding: LayeredLayoutOptions['padding'] = 0,\n ): void => {\n const siblings = nodes.filter(\n (node) => (node.parentId ?? undefined) === parentId,\n );\n if (siblings.length === 0) return;\n const siblingIds = new Set(siblings.map((node) => node.id));\n const owner = (id: string): string | undefined => {\n let node = nodeById.get(id);\n const seen = new Set<string>();\n while (node && !seen.has(node.id)) {\n seen.add(node.id);\n if (siblingIds.has(node.id)) return node.id;\n node = node.parentId ? nodeById.get(node.parentId) : undefined;\n }\n return undefined;\n };\n const siblingEdges = edges.flatMap((edge) => {\n const sourceId = owner(edge.sourceId);\n const targetId = owner(edge.targetId);\n if (!sourceId || !targetId || sourceId === targetId) return [];\n if (sourceId === edge.sourceId && targetId === edge.targetId) return [edge];\n return [\n {\n ...edge,\n id: `__flow_layout_proxy__${edge.id}`,\n sourceId,\n targetId,\n x: 0,\n y: 0,\n width: 0,\n height: 0,\n points: undefined,\n },\n ];\n });\n const laidOut = getLayeredLayout(\n {\n ...output,\n direction,\n nodes: siblings.map((node) => ({ ...node, parentId: undefined })),\n edges: siblingEdges,\n },\n { ...options, direction, padding },\n );\n for (const node of laidOut.nodes) {\n Object.assign(nodeById.get(node.id)!, node, { parentId });\n }\n for (const edge of laidOut.edges) {\n if (edgeById.has(edge.id)) edgeById.set(edge.id, edge);\n }\n };\n\n const groups = input.nodes\n .filter(isGroup)\n .sort((left, right) => depth(right.id) - depth(left.id));\n for (const group of groups) {\n const node = nodeById.get(group.id);\n if (!node) continue;\n const children = nodes.filter((child) => child.parentId === group.id);\n if (children.length === 0) continue;\n layoutSiblings(group.id, group.group!.direction ?? input.direction);\n const union = boundsUnion(children);\n const original = boundsOf(inputById.get(group.id)!, getBounds);\n const contentSize =\n group.group!.type === 'fixed'\n ? (group.group!.contentSize ?? { width: 0, height: 0 })\n : { width: original.width, height: original.height };\n const normalizedUnion = { ...union, x: 0, y: 0 };\n const geometry =\n group.group!.type === 'fixed'\n ? fixedGroupGeometry(\n { x: 0, y: 0, width: original.width, height: original.height },\n contentSize,\n group.group!,\n )\n : deriveGroupGeometry(contentSize, normalizedUnion, group.group!);\n const derivedPadding =\n group.group!.type === 'derived'\n ? resolveGroupPadding(group.group!.padding)\n : { top: 0, left: 0 };\n const target = {\n x: geometry.childArea.x - geometry.bounds.x + derivedPadding.left,\n y: geometry.childArea.y - geometry.bounds.y + derivedPadding.top,\n };\n const dx = target.x - union.x;\n const dy = target.y - union.y;\n shiftChildrenAndOwnedEdges(children, edgeById, dx, dy);\n node.width = geometry.bounds.width;\n node.height = geometry.bounds.height;\n }\n\n layoutSiblings(\n undefined,\n options.direction ?? input.direction,\n options.padding,\n );\n routeCrossBoundaryEdges(\n { ...output, nodes, edges: edges.map((edge) => edgeById.get(edge.id) ?? edge) },\n options.direction ?? input.direction ?? 'down',\n );\n return {\n ...output,\n nodes,\n edges: edges.map((edge) => edgeById.get(edge.id) ?? edge),\n };\n}\n\nfunction routeCrossBoundaryEdges(\n graph: VisualGraph,\n direction: NonNullable<FlowGraph['direction']>,\n): void {\n const nodes = new Map(graph.nodes.map((node) => [node.id, node]));\n const absolute = (id: string): Point => {\n const node = nodes.get(id);\n if (!node) return { x: 0, y: 0 };\n const parent = node.parentId ? absolute(node.parentId) : { x: 0, y: 0 };\n return { x: parent.x + node.x, y: parent.y + node.y };\n };\n const horizontal = direction === 'left' || direction === 'right';\n const reverse = direction === 'left' || direction === 'up';\n for (const edge of graph.edges) {\n const sourceNode = nodes.get(edge.sourceId);\n const targetNode = nodes.get(edge.targetId);\n if (!sourceNode || !targetNode || sourceNode.parentId === targetNode.parentId) {\n continue;\n }\n const source = { ...absolute(sourceNode.id), width: sourceNode.width, height: sourceNode.height };\n const target = { ...absolute(targetNode.id), width: targetNode.width, height: targetNode.height };\n const start = horizontal\n ? {\n x: reverse ? source.x : source.x + source.width,\n y: source.y + source.height / 2,\n }\n : {\n x: source.x + source.width / 2,\n y: reverse ? source.y : source.y + source.height,\n };\n const end = horizontal\n ? {\n x: reverse ? target.x + target.width : target.x,\n y: target.y + target.height / 2,\n }\n : {\n x: target.x + target.width / 2,\n y: reverse ? target.y + target.height : target.y,\n };\n const track = horizontal\n ? { x: (start.x + end.x) / 2, y: 0 }\n : { x: 0, y: (start.y + end.y) / 2 };\n const container = getLCA(graph, edge.sourceId, edge.targetId);\n const origin = container ? absolute(container.id) : { x: 0, y: 0 };\n const points = horizontal\n ? [start, { x: track.x, y: start.y }, { x: track.x, y: end.y }, end]\n : [start, { x: start.x, y: track.y }, { x: end.x, y: track.y }, end];\n edge.points = points.map((point) => ({\n x: point.x - origin.x,\n y: point.y - origin.y,\n }));\n edge.routing = 'orthogonal';\n edge.x = (start.x + end.x) / 2 - origin.x - edge.width / 2;\n edge.y = (start.y + end.y) / 2 - origin.y - edge.height / 2;\n }\n}\n\nfunction boundsUnion(nodes: readonly { x: number; y: number; width: number; height: number }[]): Rect {\n const left = Math.min(...nodes.map((node) => node.x));\n const top = Math.min(...nodes.map((node) => node.y));\n const right = Math.max(...nodes.map((node) => node.x + node.width));\n const bottom = Math.max(...nodes.map((node) => node.y + node.height));\n return { x: left, y: top, width: right - left, height: bottom - top };\n}\n\nfunction shiftChildrenAndOwnedEdges(\n children: readonly { id: string; x: number; y: number }[],\n edges: Map<string, GraphEdge & Rect>,\n dx: number,\n dy: number,\n): void {\n const ids = new Set(children.map((node) => node.id));\n for (const child of children) {\n child.x += dx;\n child.y += dy;\n }\n for (const edge of edges.values()) {\n if (!ids.has(edge.sourceId) || !ids.has(edge.targetId)) continue;\n edge.x += dx;\n edge.y += dy;\n if (edge.points) {\n edge.points = edge.points.map((point) => ({\n x: point.x + dx,\n y: point.y + dy,\n }));\n }\n }\n}\n\nfunction toStatelyGraph<TNodeData, TEdgeData, TLabelData>(\n graph: FlowGraph<TNodeData, TEdgeData, TLabelData>,\n getBounds?: (node: FlowNode<TNodeData>) => Rect,\n): VisualGraph<TNodeData, TEdgeData> {\n const boundsById = new Map(\n graph.nodes.map((node) => [node.id, boundsOf(node, getBounds)]),\n );\n return {\n ...graph,\n id: graph.id ?? 'flow',\n mode: graph.mode ?? 'directed',\n data: graph.data ?? {},\n direction: graph.direction ?? 'down',\n nodes: graph.nodes.map((node) => {\n const bounds = boundsById.get(node.id)!;\n const parent = node.parentId ? boundsById.get(node.parentId) : undefined;\n return {\n ...node,\n ...bounds,\n x: bounds.x - (parent?.x ?? 0),\n y: bounds.y - (parent?.y ?? 0),\n };\n }),\n edges: graph.edges.map((edge) => {\n const container = getLCA(graph as VisualGraph, edge.sourceId, edge.targetId);\n const origin = container\n ? boundsById.get(container.id) ?? { x: 0, y: 0 }\n : { x: 0, y: 0 };\n return {\n ...edge,\n x: (edge.label?.x ?? edge.x ?? 0) - origin.x,\n y: (edge.label?.y ?? edge.y ?? 0) - origin.y,\n width: edge.label?.width ?? edge.width ?? 0,\n height: edge.label?.height ?? edge.height ?? 0,\n ...(edge.points\n ? {\n points: edge.points.map((point) => ({\n x: point.x - origin.x,\n y: point.y - origin.y,\n })),\n }\n : {}),\n };\n }) as (GraphEdge<TEdgeData> & Rect)[],\n };\n}\n\nfunction fromStatelyGraph(\n graph: VisualGraph,\n input: FlowGraph,\n rootOffsets: ReadonlyMap<string, Point>,\n fixedIds: ReadonlySet<string>,\n getBounds: ((node: FlowNode) => Rect) | undefined,\n labelEdgeIds: ReadonlySet<string>,\n details: {\n source: string;\n metadata: Readonly<Record<string, unknown>>;\n diagnostics: LayoutResult['diagnostics'];\n },\n): LayoutResult {\n const nodesById = new Map(graph.nodes.map((node) => [node.id, node]));\n const inputNodesById = new Map(input.nodes.map((node) => [node.id, node]));\n const absolutePositions = new Map<string, Point>();\n const absolutePosition = (id: string, visiting = new Set<string>()): Point => {\n const cached = absolutePositions.get(id);\n if (cached) return cached;\n const node = nodesById.get(id);\n if (!node || visiting.has(id)) return { x: 0, y: 0 };\n if (fixedIds.has(id)) {\n const fixed = inputNodesById.get(id);\n if (fixed) {\n const position = boundsOf(fixed, getBounds);\n absolutePositions.set(id, position);\n return position;\n }\n }\n visiting.add(id);\n const parent = node.parentId\n ? absolutePosition(node.parentId, visiting)\n : (rootOffsets.get(node.id) ?? { x: 0, y: 0 });\n const position = { x: parent.x + node.x, y: parent.y + node.y };\n absolutePositions.set(id, position);\n return position;\n };\n const rootAncestorId = (id: string): string => {\n let node = nodesById.get(id);\n const seen = new Set<string>();\n while (node?.parentId && !seen.has(node.id)) {\n seen.add(node.id);\n node = nodesById.get(node.parentId);\n }\n return node?.id ?? id;\n };\n const rootOffsetOf = (id: string): Point =>\n rootOffsets.get(rootAncestorId(id)) ?? { x: 0, y: 0 };\n const positions = new Map<string, Point>();\n const nodeSizes = new Map<string, { width: number; height: number }>();\n const nodeBounds = new Map<string, Rect>();\n for (const node of graph.nodes) {\n if (fixedIds.has(node.id)) continue;\n const position = absolutePosition(node.id);\n const size = { width: node.width, height: node.height };\n positions.set(node.id, position);\n nodeSizes.set(node.id, size);\n nodeBounds.set(node.id, { ...position, ...size });\n }\n\n const edgeLabelBounds = new Map<string, Rect>();\n const edgeRoutes = new Map<\n string,\n { points: Point[]; routing?: EdgeRouting }\n >();\n for (const edge of graph.edges) {\n if (fixedIds.has(edge.id)) continue;\n if (fixedIds.has(edge.sourceId) || fixedIds.has(edge.targetId)) continue;\n const container = getLCA(graph, edge.sourceId, edge.targetId);\n const sourceOffset = rootOffsetOf(edge.sourceId);\n const targetOffset = rootOffsetOf(edge.targetId);\n if (\n !container &&\n (sourceOffset.x !== targetOffset.x || sourceOffset.y !== targetOffset.y)\n ) {\n continue;\n }\n const origin = container ? absolutePosition(container.id) : sourceOffset;\n if (\n labelEdgeIds.has(edge.id) &&\n Number.isFinite(edge.x) &&\n Number.isFinite(edge.y) &&\n Number.isFinite(edge.width) &&\n Number.isFinite(edge.height)\n ) {\n edgeLabelBounds.set(edge.id, {\n x: origin.x + edge.x,\n y: origin.y + edge.y,\n width: edge.width,\n height: edge.height,\n });\n }\n if (edge.points && edge.points.length >= 2) {\n edgeRoutes.set(edge.id, {\n points: edge.points.map((point) => ({\n x: origin.x + point.x,\n y: origin.y + point.y,\n })),\n ...(edge.routing ? { routing: edge.routing } : {}),\n });\n }\n }\n\n return {\n positions,\n nodeSizes,\n nodeBounds,\n ...(edgeLabelBounds.size > 0\n ? {\n edgeLabelBounds,\n edgeLabelPositions: new Map(\n [...edgeLabelBounds].map(([id, bounds]) => [\n id,\n { x: bounds.x, y: bounds.y },\n ]),\n ),\n }\n : {}),\n ...(edgeRoutes.size > 0 ? { edgeRoutes } : {}),\n ...(details.diagnostics?.length\n ? { diagnostics: details.diagnostics }\n : {}),\n source: details.source,\n metadata: details.metadata,\n };\n}\n"],"mappings":";;;;;;;AAyCA,MAAa,iBAKX,UAAkE,CAAC,MACT;CAC1D,OAAO,OAAO,OAAO,aAAa,CAAC,MAAM;EACvC,eAAe,UAAU;EACzB,MAAM,eAAe;EAMrB,MAAM,cAAc,oBAAoB,cAD1B,kBAAkB,cAAc,QAAQ,OAAO,UACH,CAAC;EAC3D,MAAM,UAAU,iBACd,cACA,SACA,YACA,SACF;EAEA,MAAM,SAAS,MAAM,UAAU;GAC7B,OAFY,eAAe,aAAa,QAAQ,SAErC;GACX,WAAW;GACX,SAAS,cAAc,OAAO;GAC9B,GAAI,WAAW,SACX,EAAE,QAAQ,WAAW,OAAiC,IACtD,CAAC;EACP,CAAC;EACD,QAAQ,YAAY,KAAK,GAAG,OAAO,YAAY,KAAK,WAAW,EAAE,GAAG,MAAM,EAAE,CAAC;EAC7E,MAAM,SAAS,wBACb,OAAO,OACP,aACA,cAAc,OAAO,GACrB,QAAQ,SACV;EACA,eAAe,UAAU;EACzB,OAAO,iBACL,QACA,aACA,oBAAoB,aAAa,cAAc,QAAQ,SAAS,GAChE,QAAQ,UACR,QAAQ,WACR,IAAI,IAAI,YAAY,MAAM,QAAQ,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AAI;GACtB,QAAQ,KAAK,OAAO,KAAK,WAAW;IAClC,GAAG,OAAO,IAAI,MAAM;IACpB,GAAG,OAAO,IAAI,MAAM;GACtB,EAAE;GACF,GAAI,KAAK,UAAU,EAAE,SAAS,KAAK,QAAQ,IAAI,CAAC;EAClD,CAAC;CAEL;CAEA,OAAO;EACL;EACA;EACA;EACA,GAAI,gBAAgB,OAAO,IACvB;GACE;GACA,oBAAoB,IAAI,IACtB,CAAC,GAAG,eAAe,CAAC,CAAC,KAAK,CAAC,IAAI,YAAY,CACzC,IACA;IAAE,GAAG,OAAO;IAAG,GAAG,OAAO;GAAE,CAC7B,CAAC,CACH;EACF,IACA,CAAC;EACL,GAAI,WAAW,OAAO,IAAI,EAAE,WAAW,IAAI,CAAC;EAC5C,GAAI,QAAQ,aAAa,SACrB,EAAE,aAAa,QAAQ,YAAY,IACnC,CAAC;EACL,QAAQ,QAAQ;EAChB,UAAU,QAAQ;CACpB;AACF"}
@@ -25,4 +25,5 @@ type FlowLayoutOptions<TNodeData = any, TEdgeData = any, TLabelData = any> = {
25
25
  type FlowLayoutFactory<TNodeData = any, TEdgeData = any, TLabelData = any> = (options?: FlowLayoutOptions<TNodeData, TEdgeData, TLabelData>) => FlowLayoutAlgorithm<TNodeData, TEdgeData, TLabelData>;
26
26
  type FlowLayoutAlgorithm<TNodeData = any, TEdgeData = any, TLabelData = any> = (graph: Readonly<FlowGraph<TNodeData, TEdgeData, TLabelData>>, options?: LayoutRunOptions) => Promise<LayoutResult | LayoutPositions>;
27
27
  //#endregion
28
- export { FlowLayoutScope as i, FlowLayoutFactory as n, FlowLayoutOptions as r, FlowLayoutAlgorithm as t };
28
+ export { FlowLayoutScope as i, FlowLayoutFactory as n, FlowLayoutOptions as r, FlowLayoutAlgorithm as t };
29
+ //# sourceMappingURL=shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.d.ts","names":[],"sources":["../../src/layout/shared.ts"],"mappings":";;KAcY;EACV;;KAGU,kBAAkB,iBAAiB,iBAAiB;EAC9D,aAAa,MAAM,SAAS,eAAe;EAC3C,QAAQ;EACR,aAAa;EACb;EACA;EACA;EACA,QAAQ;EACR,OAAO;EACP,OAAO;EACP,QAAQ;EACR;EACA,WAAW,SAAS;EACpB;IACE,OAAO;IACP,OAAO;IACP,QAAQ;;;KAIA,kBACV,iBACA,iBACA,qBAEA,UAAU,kBAAkB,WAAW,WAAW,gBAC/C,oBAAoB,WAAW,WAAW;KAEnC,oBACV,iBACA,iBACA,qBAEA,OAAO,SAAS,UAAU,WAAW,WAAW,cAChD,UAAU,qBACP,QAAQ,eAAe"}
@@ -113,3 +113,5 @@ function rankDirection(direction) {
113
113
  }
114
114
  //#endregion
115
115
  export { mergedLayoutScope as a, layoutRunContext as i, edgeLabelPositionsFromNodePositions as n, rankDirection as o, graphForLayoutScope as r, throwIfAborted as s, boundsOf as t };
116
+
117
+ //# sourceMappingURL=shared.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.js","names":[],"sources":["../../src/layout/shared.ts"],"sourcesContent":["import {\n deriveFlowView,\n resolvedBounds,\n type FlowEdge,\n type FlowGraph,\n type FlowNode,\n type LayoutDiagnostic,\n type LayoutPositions,\n type LayoutResult,\n type LayoutRunOptions,\n type Point,\n type Rect,\n} from '@statelyai/flow';\n\nexport type FlowLayoutScope = {\n ids: string[];\n};\n\nexport type FlowLayoutOptions<TNodeData = any, TEdgeData = any, TLabelData = any> = {\n getBounds?: (node: FlowNode<TNodeData>) => Rect;\n scope?: FlowLayoutScope;\n onWarning?: (message: string) => void;\n nodeSpacing?: number;\n rankSpacing?: number;\n direction?: 'down' | 'right' | 'up' | 'left';\n graph?: Record<string, unknown>;\n node?: Record<string, unknown>;\n edge?: Record<string, unknown>;\n label?: Record<string, unknown>;\n source?: string;\n metadata?: Readonly<Record<string, unknown>>;\n _types?: {\n node?: TNodeData;\n edge?: TEdgeData;\n label?: TLabelData;\n };\n};\n\nexport type FlowLayoutFactory<\n TNodeData = any,\n TEdgeData = any,\n TLabelData = any,\n> = (\n options?: FlowLayoutOptions<TNodeData, TEdgeData, TLabelData>,\n) => FlowLayoutAlgorithm<TNodeData, TEdgeData, TLabelData>;\n\nexport type FlowLayoutAlgorithm<\n TNodeData = any,\n TEdgeData = any,\n TLabelData = any,\n> = (\n graph: Readonly<FlowGraph<TNodeData, TEdgeData, TLabelData>>,\n options?: LayoutRunOptions,\n) => Promise<LayoutResult | LayoutPositions>;\n\nexport function boundsOf<TNodeData>(\n node: FlowNode<TNodeData>,\n getBounds?: (node: FlowNode<TNodeData>) => Rect,\n): Rect {\n const bounds = getBounds?.(node) ?? resolvedBounds(node);\n if (\n !Number.isFinite(bounds.x) ||\n !Number.isFinite(bounds.y) ||\n !Number.isFinite(bounds.width) ||\n !Number.isFinite(bounds.height) ||\n bounds.width < 0 ||\n bounds.height < 0\n ) {\n throw new TypeError(\n `Layout bounds for node \"${node.id}\" must be finite with non-negative size.`,\n );\n }\n return bounds;\n}\n\n/**\n * Build the induced graph used by a scoped layout. Out-of-scope nodes never\n * reach the engine; scoped nodes with an excluded parent become roots.\n */\nexport function graphForLayoutScope<TNodeData, TEdgeData, TLabelData>(\n graph: FlowGraph<TNodeData, TEdgeData, TLabelData>,\n scope?: FlowLayoutScope,\n): FlowGraph<TNodeData, TEdgeData, TLabelData> {\n if (!scope) return graph;\n const ids = new Set(scope.ids);\n const knownIds = new Set(graph.nodes.map((node) => node.id));\n const unknownIds = [...ids].filter((id) => !knownIds.has(id)).sort();\n if (unknownIds.length > 0) {\n throw new TypeError(\n `Layout scope contains unknown node ids: ${unknownIds.join(', ')}`,\n );\n }\n return {\n ...graph,\n nodes: graph.nodes\n .filter((node) => ids.has(node.id))\n .map((node) =>\n node.parentId && !ids.has(node.parentId)\n ? { ...node, parentId: undefined }\n : node,\n ),\n edges: graph.edges.filter(\n (edge) => ids.has(edge.sourceId) && ids.has(edge.targetId),\n ),\n };\n}\n\nexport function mergedLayoutScope(\n graph: FlowGraph,\n factoryScope: FlowLayoutScope | undefined,\n runOptions: LayoutRunOptions,\n): FlowLayoutScope | undefined {\n if (!factoryScope && !runOptions.scope) return undefined;\n const knownIds = new Set(graph.nodes.map((node) => node.id));\n if (\n runOptions.scope?.parentId &&\n !knownIds.has(runOptions.scope.parentId)\n ) {\n throw new TypeError(\n `Layout scope contains unknown parent id: ${runOptions.scope.parentId}`,\n );\n }\n const unknownFactoryIds = (factoryScope?.ids ?? [])\n .filter((id) => !knownIds.has(id))\n .sort();\n if (unknownFactoryIds.length > 0) {\n throw new TypeError(\n `Layout scope contains unknown node ids: ${unknownFactoryIds.join(', ')}`,\n );\n }\n const factoryIds = factoryScope ? new Set(factoryScope.ids) : null;\n const structuralIds = runOptions.scope\n ? new Set(\n deriveFlowView(graph, runOptions.scope, {\n nodes: graph.nodes,\n edges: graph.edges,\n }).nodes.map((node) => node.id),\n )\n : null;\n return {\n ids: graph.nodes\n .map((node) => node.id)\n .filter(\n (id) =>\n (!factoryIds || factoryIds.has(id)) &&\n (!structuralIds || structuralIds.has(id)),\n ),\n };\n}\n\nexport function layoutRunContext(\n graph: FlowGraph,\n factoryOptions: FlowLayoutOptions,\n runOptions: LayoutRunOptions,\n adapter: 'stately' | 'elk' | 'dagre',\n): {\n fixedIds: ReadonlySet<string>;\n source: string;\n metadata: Readonly<Record<string, unknown>>;\n diagnostics: LayoutDiagnostic[];\n} {\n const knownIds = new Set([\n ...graph.nodes.map((node) => node.id),\n ...graph.edges.map((edge) => edge.id),\n ]);\n const fixedIds = new Set([\n ...(runOptions.fixedEntityIds ?? []),\n ...(runOptions.pinnedEntityIds ?? []),\n ]);\n const unknown = [...fixedIds].filter((id) => !knownIds.has(id)).sort();\n if (unknown.length > 0) {\n throw new TypeError(`Layout fixed/pinned ids are unknown: ${unknown.join(', ')}`);\n }\n return {\n fixedIds,\n source: runOptions.source ?? factoryOptions.source ?? adapter,\n metadata: {\n ...(runOptions.previousResult?.metadata ?? {}),\n ...(factoryOptions.metadata ?? {}),\n ...(runOptions.metadata ?? {}),\n adapter,\n },\n diagnostics: [],\n };\n}\n\nexport function throwIfAborted(options: LayoutRunOptions): void {\n if (!options.signal?.aborted) return;\n const error = new Error('Layout aborted.');\n error.name = 'AbortError';\n throw error;\n}\n\nexport function edgeLabelPositionsFromNodePositions<\n TEdgeData,\n TLabelData,\n>(\n graph: FlowGraph<any, TEdgeData, TLabelData>,\n positions: Map<string, Point>,\n getBounds?: (node: FlowNode) => Rect,\n laidOutBounds?: ReadonlyMap<string, Rect>,\n direction = graph.direction ?? 'down',\n): Map<string, Point> | undefined {\n const labels = new Map<string, Point>();\n const nodes = new Map(graph.nodes.map((node) => [node.id, node]));\n for (const edge of graph.edges as FlowEdge<TEdgeData, TLabelData>[]) {\n if (!edge.label) continue;\n const source = nodes.get(edge.sourceId);\n const target = nodes.get(edge.targetId);\n if (!source || !target) continue;\n const sourceBounds = laidOutBounds?.get(source.id) ?? boundsOf(source, getBounds);\n const targetBounds = laidOutBounds?.get(target.id) ?? boundsOf(target, getBounds);\n const sourcePosition = positions.get(source.id) ?? sourceBounds;\n const targetPosition = positions.get(target.id) ?? targetBounds;\n const sourceRect = { ...sourceBounds, ...sourcePosition };\n const targetRect = { ...targetBounds, ...targetPosition };\n const horizontal = direction === 'left' || direction === 'right';\n const sourceCenter = {\n x: sourceRect.x + sourceRect.width / 2,\n y: sourceRect.y + sourceRect.height / 2,\n };\n const targetCenter = {\n x: targetRect.x + targetRect.width / 2,\n y: targetRect.y + targetRect.height / 2,\n };\n const gapCenter = horizontal\n ? {\n x:\n direction === 'left'\n ? (targetRect.x + targetRect.width + sourceRect.x) / 2\n : (sourceRect.x + sourceRect.width + targetRect.x) / 2,\n y: (sourceCenter.y + targetCenter.y) / 2,\n }\n : {\n x: (sourceCenter.x + targetCenter.x) / 2,\n y:\n direction === 'up'\n ? (targetRect.y + targetRect.height + sourceRect.y) / 2\n : (sourceRect.y + sourceRect.height + targetRect.y) / 2,\n };\n labels.set(edge.id, {\n x: gapCenter.x - edge.label.width / 2,\n y: gapCenter.y - edge.label.height / 2,\n });\n }\n return labels.size > 0 ? labels : undefined;\n}\n\nexport function rankDirection(direction: string | undefined): 'TB' | 'LR' | 'BT' | 'RL' {\n switch (direction) {\n case 'right':\n return 'LR';\n case 'up':\n return 'BT';\n case 'left':\n return 'RL';\n default:\n return 'TB';\n }\n}\n"],"mappings":";;AAuDA,SAAgB,SACd,MACA,WACM;CACN,MAAM,SAAS,YAAY,IAAI,KAAK,eAAe,IAAI;CACvD,IACE,CAAC,OAAO,SAAS,OAAO,CAAC,KACzB,CAAC,OAAO,SAAS,OAAO,CAAC,KACzB,CAAC,OAAO,SAAS,OAAO,KAAK,KAC7B,CAAC,OAAO,SAAS,OAAO,MAAM,KAC9B,OAAO,QAAQ,KACf,OAAO,SAAS,GAEhB,MAAM,IAAI,UACR,2BAA2B,KAAK,GAAG,yCACrC;CAEF,OAAO;AACT;;;;;AAMA,SAAgB,oBACd,OACA,OAC6C;CAC7C,IAAI,CAAC,OAAO,OAAO;CACnB,MAAM,MAAM,IAAI,IAAI,MAAM,GAAG;CAC7B,MAAM,WAAW,IAAI,IAAI,MAAM,MAAM,KAAK,SAAS,KAAK,EAAE,CAAC;CAC3D,MAAM,aAAa,CAAC,GAAG,GAAG,CAAC,CAAC,QAAQ,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK;CACnE,IAAI,WAAW,SAAS,GACtB,MAAM,IAAI,UACR,2CAA2C,WAAW,KAAK,IAAI,GACjE;CAEF,OAAO;EACL,GAAG;EACH,OAAO,MAAM,MACV,QAAQ,SAAS,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC,CAClC,KAAK,SACJ,KAAK,YAAY,CAAC,IAAI,IAAI,KAAK,QAAQ,IACnC;GAAE,GAAG;GAAM,UAAU,KAAA;EAAU,IAC/B,IACN;EACF,OAAO,MAAM,MAAM,QAChB,SAAS,IAAI,IAAI,KAAK,QAAQ,KAAK,IAAI,IAAI,KAAK,QAAQ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D,MAAM,eAAe;GACnB,GAAG,WAAW,IAAI,WAAW,QAAQ;GACrC,GAAG,WAAW,IAAI,WAAW,SAAS;EACxC;EACA,MAAM,eAAe;GACnB,GAAG,WAAW,IAAI,WAAW,QAAQ;GACrC,GAAG,WAAW,IAAI,WAAW,SAAS;EACxC;EACA,MAAM,YAAY,aACd;GACE,GACE,cAAc,UACT,WAAW,IAAI,WAAW,QAAQ,WAAW,KAAK,KAClD,WAAW,IAAI,WAAW,QAAQ,WAAW,KAAK;GACzD,IAAI,aAAa,IAAI,aAAa,KAAK;EACzC,IACA;GACE,IAAI,aAAa,IAAI,aAAa,KAAK;GACvC,GACE,cAAc,QACT,WAAW,IAAI,WAAW,SAAS,WAAW,KAAK,KACnD,WAAW,IAAI,WAAW,SAAS,WAAW,KAAK;EAC5D;EACJ,OAAO,IAAI,KAAK,IAAI;GAClB,GAAG,UAAU,IAAI,KAAK,MAAM,QAAQ;GACpC,GAAG,UAAU,IAAI,KAAK,MAAM,SAAS;EACvC,CAAC;CACH;CACA,OAAO,OAAO,OAAO,IAAI,SAAS,KAAA;AACpC;AAEA,SAAgB,cAAc,WAA0D;CACtF,QAAQ,WAAR;EACE,KAAK,SACH,OAAO;EACT,KAAK,MACH,OAAO;EACT,KAAK,QACH,OAAO;EACT,SACE,OAAO;CACX;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@statelyai/flow",
3
- "version": "0.14.0",
3
+ "version": "0.15.0",
4
4
  "description": "Framework-agnostic flow visualization engine. Builds on @statelyai/graph.",
5
5
  "type": "module",
6
6
  "sideEffects": true,
@@ -14,7 +14,8 @@
14
14
  ],
15
15
  "license": "MIT",
16
16
  "files": [
17
- "dist"
17
+ "dist",
18
+ "src"
18
19
  ],
19
20
  "source": "src/index.ts",
20
21
  "main": "dist/esm/index.js",
@@ -53,7 +54,7 @@
53
54
  }
54
55
  },
55
56
  "dependencies": {
56
- "@xstate/store": "^4.2.2",
57
+ "@xstate/store": "5.0.0-alpha.8",
57
58
  "immer": "^10.0.0"
58
59
  },
59
60
  "peerDependencies": {
@@ -0,0 +1,106 @@
1
+ import { createFlowStore } from '../store';
2
+ import { createFlowEngine } from '../engine';
3
+ import { createNode, createEdge, createGraph } from '../factories';
4
+ import type { FlowEdge, FlowNode } from '../types';
5
+
6
+ /**
7
+ * Nested statechart fixture — the REFRAME phase-3 gate: 3 hierarchy levels,
8
+ * 200 nodes (8 top derived groups × 4 mid derived groups × 5 leaves), with
9
+ * labeled edges at every containment level (leaf chains owned by mid groups,
10
+ * mid-to-mid owned by top groups, cross-top edges owned by the root).
11
+ */
12
+ export function makeNestedFixture(): {
13
+ nodes: FlowNode[];
14
+ edges: FlowEdge[];
15
+ } {
16
+ const nodes: FlowNode[] = [];
17
+ const edges: FlowEdge[] = [];
18
+ const group = (id: string, parentId?: string): FlowNode => ({
19
+ ...createNode({
20
+ id,
21
+ width: 140,
22
+ height: 36,
23
+ data: { label: id },
24
+ group: { type: 'derived', padding: 16 },
25
+ }),
26
+ ...(parentId ? { parentId } : {}),
27
+ });
28
+
29
+ for (let t = 0; t < 8; t++) {
30
+ const top = `top${t}`;
31
+ nodes.push(group(top));
32
+ for (let m = 0; m < 4; m++) {
33
+ const mid = `${top}.mid${m}`;
34
+ nodes.push(group(mid, top));
35
+ const originX = t * 1400 + m * 330;
36
+ const originY = Math.floor(t / 4) * 1200 + 200;
37
+ for (let l = 0; l < 5; l++) {
38
+ const leaf = `${mid}.leaf${l}`;
39
+ nodes.push({
40
+ ...createNode({
41
+ id: leaf,
42
+ x: originX + (l % 2) * 140,
43
+ y: originY + Math.floor(l / 2) * 110,
44
+ width: 110,
45
+ height: 44,
46
+ data: { label: `leaf${l}` },
47
+ }),
48
+ parentId: mid,
49
+ });
50
+ if (l > 0) {
51
+ // owned by the mid group
52
+ edges.push(
53
+ createEdge({
54
+ id: `${mid}.e${l}`,
55
+ sourceId: `${mid}.leaf${l - 1}`,
56
+ targetId: leaf,
57
+ label: {
58
+ x: originX + 40,
59
+ y: originY + Math.floor(l / 2) * 110 + 60,
60
+ width: 60,
61
+ height: 18,
62
+ },
63
+ }),
64
+ );
65
+ }
66
+ }
67
+ if (m > 0) {
68
+ // owned by the top group
69
+ edges.push(
70
+ createEdge({
71
+ id: `${top}.m${m}`,
72
+ sourceId: `${top}.mid${m - 1}.leaf0`,
73
+ targetId: `${mid}.leaf0`,
74
+ label: {
75
+ x: originX - 100,
76
+ y: originY - 60,
77
+ width: 70,
78
+ height: 18,
79
+ },
80
+ }),
81
+ );
82
+ }
83
+ }
84
+ if (t > 0) {
85
+ // owned by the root
86
+ edges.push(
87
+ createEdge({
88
+ id: `cross${t}`,
89
+ sourceId: `top${t - 1}.mid0.leaf0`,
90
+ targetId: `top${t}.mid0.leaf0`,
91
+ }),
92
+ );
93
+ }
94
+ }
95
+ return { nodes, edges };
96
+ }
97
+
98
+ export function makeNestedDraggingFlow() {
99
+ const { nodes, edges } = makeNestedFixture();
100
+ const store = createFlowStore(createGraph({ nodes, edges }));
101
+ const engine = createFlowEngine(store);
102
+ store.trigger.updateViewportSize({ width: 1600, height: 1000 });
103
+ store.trigger.select({ ids: ['top3.mid2.leaf4'] });
104
+ store.trigger.dragStart({ id: 'top3.mid2.leaf4' });
105
+ return { store, engine };
106
+ }