@pixerate/editor 0.8.1 → 0.10.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.
- package/dist/agent/index.cjs +512 -0
- package/dist/agent/index.cjs.map +1 -0
- package/dist/agent/index.d.cts +369 -0
- package/dist/agent/index.d.ts +369 -0
- package/dist/agent/index.js +471 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/canvas/index.cjs +797 -0
- package/dist/canvas/index.cjs.map +1 -0
- package/dist/canvas/index.d.cts +187 -0
- package/dist/canvas/index.d.ts +187 -0
- package/dist/canvas/index.js +731 -0
- package/dist/canvas/index.js.map +1 -0
- package/dist/extensions/index.cjs.map +1 -1
- package/dist/extensions/index.d.cts +5 -27
- package/dist/extensions/index.d.ts +5 -27
- package/dist/extensions/index.js.map +1 -1
- package/dist/index.cjs +1274 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +41 -5
- package/dist/index.d.ts +41 -5
- package/dist/index.js +1232 -6
- package/dist/index.js.map +1 -1
- package/dist/mention-Dcevh3ff.d.cts +32 -0
- package/dist/mention-Dcevh3ff.d.ts +32 -0
- package/dist/serializers/index.cjs +194 -4
- package/dist/serializers/index.cjs.map +1 -1
- package/dist/serializers/index.d.cts +89 -2
- package/dist/serializers/index.d.ts +89 -2
- package/dist/serializers/index.js +186 -3
- package/dist/serializers/index.js.map +1 -1
- package/dist/types-lGtRobRV.d.cts +213 -0
- package/dist/types-lGtRobRV.d.ts +213 -0
- package/package.json +13 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/canvas/index.ts","../../src/canvas/layout.ts","../../src/canvas/trajectory.ts","../../src/canvas/displacement.ts","../../src/canvas/clipboard.ts","../../src/canvas/streaming.ts"],"sourcesContent":["export * from './types.js';\nexport * from './layout.js';\nexport * from './trajectory.js';\nexport * from './displacement.js';\nexport * from './clipboard.js';\nexport * from './streaming.js';\n","import dagre from '@dagrejs/dagre';\nimport type {\n\tCanvasEdge,\n\tCanvasLayoutOptions,\n\tCanvasNode,\n\tIncrementalLayoutOptions,\n\tPlaceBesideOptions,\n\tRect,\n\tSide,\n\tXYPosition\n} from './types.js';\n\nexport const DEFAULT_NODE_WIDTH = 200;\nexport const DEFAULT_NODE_HEIGHT = 60;\nexport const DEFAULT_PLACEMENT_GAP = 48;\n\n/**\n * Calculates upper-left flow coordinate for an element to be centered in the viewport.\n */\nexport function getCenteredNodePosition(\n\twidth = 0,\n\theight = 0,\n\tscreenToFlowPosition: (position: XYPosition) => XYPosition,\n\tscreenDimensions?: { width: number; height: number }\n): XYPosition {\n\tconst rect =\n\t\tscreenDimensions ??\n\t\t(typeof document !== 'undefined'\n\t\t\t? { width: document.documentElement.clientWidth, height: document.documentElement.clientHeight }\n\t\t\t: { width: 1920, height: 1080 });\n\n\tconst flowPos = screenToFlowPosition({ x: rect.width / 2, y: rect.height / 2 });\n\treturn {\n\t\tx: flowPos.x - width / 2,\n\t\ty: flowPos.y - height / 2\n\t};\n}\n\n/**\n * Updates positions of nodes so their collective bounding box is centered in the current viewport.\n */\nexport function centerNodes<TNode extends CanvasNode = CanvasNode>(\n\tnodes: TNode[],\n\tscreenToFlowPosition: (position: XYPosition) => XYPosition,\n\tgetNodesBounds: (nodes: TNode[]) => Rect,\n\tscreenDimensions?: { width: number; height: number }\n): TNode[] {\n\tif (nodes.length === 0) {\n\t\treturn [];\n\t}\n\n\tconst bounds = getNodesBounds(nodes);\n\tconst boundingBoxOrigin = { x: bounds.x, y: bounds.y };\n\n\tconst centeredPosition = getCenteredNodePosition(\n\t\tbounds.width,\n\t\tbounds.height,\n\t\tscreenToFlowPosition,\n\t\tscreenDimensions\n\t);\n\n\tconst deltaX = centeredPosition.x - boundingBoxOrigin.x;\n\tconst deltaY = centeredPosition.y - boundingBoxOrigin.y;\n\n\treturn nodes.map((node) => ({\n\t\t...node,\n\t\tposition: {\n\t\t\tx: node.position.x + deltaX,\n\t\t\ty: node.position.y + deltaY\n\t\t}\n\t}));\n}\n\n/**\n * Automatically calculates directed hierarchical layout of nodes and edges using Dagre.\n */\nexport function getLayoutedNodes<\n\tTNode extends CanvasNode = CanvasNode,\n\tTEdge extends CanvasEdge = CanvasEdge\n>(\n\tnodes: TNode[],\n\tedges: TEdge[],\n\tgetNodesBounds?: (nodes: TNode[]) => Rect,\n\toptions: CanvasLayoutOptions = {}\n): TNode[] {\n\tif (nodes.length === 0) return [];\n\n\tconst {\n\t\tdirection = 'LR',\n\t\tranksep = 100,\n\t\tnodesep = 25,\n\t\tdefaultNodeWidth = DEFAULT_NODE_WIDTH,\n\t\tdefaultNodeHeight = DEFAULT_NODE_HEIGHT\n\t} = options;\n\n\tconst dagreGraph = new dagre.graphlib.Graph();\n\tdagreGraph.setDefaultEdgeLabel(() => ({}));\n\tdagreGraph.setGraph({ rankdir: direction, ranksep, nodesep });\n\n\tconst nodeIds = new Set(nodes.map((node) => node.id));\n\n\tnodes.forEach((node) => {\n\t\tconst nodeWidth = node.measured?.width ?? (node as any).width ?? defaultNodeWidth;\n\t\tconst nodeHeight = node.measured?.height ?? (node as any).height ?? defaultNodeHeight;\n\t\tdagreGraph.setNode(node.id, { width: nodeWidth, height: nodeHeight });\n\t});\n\n\tedges.forEach((edge) => {\n\t\tif (nodeIds.has(edge.source) && nodeIds.has(edge.target)) {\n\t\t\tdagreGraph.setEdge(edge.source, edge.target);\n\t\t}\n\t});\n\n\tdagre.layout(dagreGraph);\n\n\treturn nodes.map((node) => {\n\t\tconst nodeWithPosition = dagreGraph.node(node.id);\n\t\tconst nodeWidth = node.measured?.width ?? (node as any).width ?? defaultNodeWidth;\n\t\tconst nodeHeight = node.measured?.height ?? (node as any).height ?? defaultNodeHeight;\n\n\t\treturn {\n\t\t\t...node,\n\t\t\tposition: {\n\t\t\t\tx: nodeWithPosition.x - nodeWidth / 2,\n\t\t\t\ty: nodeWithPosition.y - nodeHeight / 2\n\t\t\t}\n\t\t};\n\t});\n}\n\n/**\n * Heuristic text-based node size estimator when DOM measurement is not available.\n */\nexport function estimateNodeSize(\n\tnode: CanvasNode,\n\tdefaultWidth = DEFAULT_NODE_WIDTH,\n\tdefaultHeight = DEFAULT_NODE_HEIGHT\n): { width: number; height: number } {\n\tconst label = String(node.data?.label ?? node.data?.title ?? node.id ?? '');\n\tconst lines = label.split(/\\n|<br\\s*\\/?>/);\n\tconst longest = Math.max(...lines.map((l) => l.replace(/<[^>]+>/g, '').length), 1);\n\tconst width = Math.min(480, Math.max(defaultWidth, longest * 8 + 48));\n\tconst height = Math.max(defaultHeight, lines.length * 20 + 24);\n\treturn { width, height };\n}\n\n/**\n * Computes bounding rectangle of an array of rectangles.\n */\nexport function boundsOf(rects: Rect[]): Rect | null {\n\tif (!rects.length) return null;\n\tconst minX = Math.min(...rects.map((r) => r.x));\n\tconst minY = Math.min(...rects.map((r) => r.y));\n\tconst maxX = Math.max(...rects.map((r) => r.x + r.width));\n\tconst maxY = Math.max(...rects.map((r) => r.y + r.height));\n\treturn { x: minX, y: minY, width: maxX - minX, height: maxY - minY };\n}\n\n/**\n * Center coordinate of a rectangle.\n */\nexport function centre(r: Rect): XYPosition {\n\treturn { x: r.x + r.width / 2, y: r.y + r.height / 2 };\n}\n\n/**\n * Determines whether two rectangles overlap, including an optional padding distance.\n */\nexport function overlaps(a: Rect, b: Rect, pad = 16): boolean {\n\treturn (\n\t\ta.x < b.x + b.width + pad &&\n\t\ta.x + a.width + pad > b.x &&\n\t\ta.y < b.y + b.height + pad &&\n\t\ta.y + a.height + pad > b.y\n\t);\n}\n\n/**\n * Maps directed layout flow to its natural forward growth side.\n */\nexport function flowSide(direction: 'LR' | 'TB' | 'RL' | 'BT' = 'LR'): Side {\n\tswitch (direction) {\n\t\tcase 'LR':\n\t\t\treturn 'right';\n\t\tcase 'RL':\n\t\t\treturn 'left';\n\t\tcase 'BT':\n\t\t\treturn 'above';\n\t\tcase 'TB':\n\t\tdefault:\n\t\t\treturn 'below';\n\t}\n}\n\n/**\n * Incremental layout blending:\n * Keeps established/manual node positions intact. Runs Dagre on the entire graph,\n * computes the centroid translation offset between auto and stored positions of existing nodes,\n * and places unpositioned/new nodes at (auto + offset).\n */\nexport function ensureLayout<\n\tTNode extends CanvasNode = CanvasNode,\n\tTEdge extends CanvasEdge = CanvasEdge\n>(\n\tnodes: TNode[],\n\tedges: TEdge[],\n\toptions: IncrementalLayoutOptions = {}\n): TNode[] {\n\tif (nodes.length === 0) return [];\n\n\tconst stored = options.storedPositions ?? {};\n\tconst missing = nodes.filter((n) => !stored[n.id]);\n\n\t// Case 1: Every node has an established coordinate -> preserve verbatim\n\tif (missing.length === 0) {\n\t\treturn nodes.map((n) => ({\n\t\t\t...n,\n\t\t\tposition: { ...stored[n.id]! }\n\t\t}));\n\t}\n\n\t// Calculate full dagre auto-layout\n\tconst autoLayouted = getLayoutedNodes(nodes, edges, undefined, options);\n\tconst autoMap = new Map<string, XYPosition>(\n\t\tautoLayouted.map((n) => [n.id, n.position])\n\t);\n\n\t// Case 2: No nodes have stored coordinates -> return auto layout directly\n\tconst both = nodes.filter((n) => stored[n.id] && autoMap.has(n.id));\n\tif (both.length === 0) {\n\t\treturn autoLayouted;\n\t}\n\n\t// Case 3: Blend! Align on centroid translation offset of overlapping nodes\n\tlet dx = 0;\n\tlet dy = 0;\n\tfor (const n of both) {\n\t\tconst s = stored[n.id]!;\n\t\tconst a = autoMap.get(n.id)!;\n\t\tdx += s.x - a.x;\n\t\tdy += s.y - a.y;\n\t}\n\tdx /= both.length;\n\tdy /= both.length;\n\n\treturn nodes.map((node) => {\n\t\tif (stored[node.id]) {\n\t\t\treturn {\n\t\t\t\t...node,\n\t\t\t\tposition: { ...stored[node.id]! }\n\t\t\t};\n\t\t}\n\t\tconst autoPos = autoMap.get(node.id) ?? { x: 0, y: 0 };\n\t\treturn {\n\t\t\t...node,\n\t\t\tposition: {\n\t\t\t\tx: Math.round(autoPos.x + dx),\n\t\t\t\ty: Math.round(autoPos.y + dy)\n\t\t\t}\n\t\t};\n\t});\n}\n\n/**\n * Finds a free top-left coordinate for a node of `size` adjacent to `nearNodeId` (or the cluster),\n * sliding along the perpendicular axis past any intersecting bounding boxes to guarantee non-overlapping placement.\n */\nexport function placeBeside(\n\trects: Record<string, Rect>,\n\tsize: { width: number; height: number },\n\tside: Side,\n\tnearNodeId?: string,\n\toptions: PlaceBesideOptions = {}\n): XYPosition {\n\tconst {\n\t\tgap = DEFAULT_PLACEMENT_GAP,\n\t\tignore = [],\n\t\tmaxAttempts = 32\n\t} = options;\n\n\tconst skip = new Set([nearNodeId, ...ignore].filter(Boolean));\n\tconst obstacles = Object.entries(rects)\n\t\t.filter(([id]) => !skip.has(id))\n\t\t.map(([, r]) => r);\n\n\tconst anchor =\n\t\t(nearNodeId && rects[nearNodeId]) ||\n\t\tboundsOf(Object.values(rects)) ||\n\t\t{ x: 0, y: 0, width: 0, height: 0 };\n\n\tconst anchorCenter = centre(anchor);\n\n\tlet baseX: number;\n\tlet baseY: number;\n\n\tswitch (side) {\n\t\tcase 'right':\n\t\t\tbaseX = anchor.x + anchor.width + gap;\n\t\t\tbaseY = anchorCenter.y - size.height / 2;\n\t\t\tbreak;\n\t\tcase 'left':\n\t\t\tbaseX = anchor.x - gap - size.width;\n\t\t\tbaseY = anchorCenter.y - size.height / 2;\n\t\t\tbreak;\n\t\tcase 'above':\n\t\t\tbaseX = anchorCenter.x - size.width / 2;\n\t\t\tbaseY = anchor.y - gap - size.height;\n\t\t\tbreak;\n\t\tcase 'below':\n\t\tdefault:\n\t\t\tbaseX = anchorCenter.x - size.width / 2;\n\t\t\tbaseY = anchor.y + anchor.height + gap;\n\t\t\tbreak;\n\t}\n\n\t// Slide perpendicular to growth direction, alternating positive and negative steps (+1, -1, +2, -2...)\n\tconst isHorizontal = side === 'right' || side === 'left';\n\tconst step = (isHorizontal ? size.height : size.width) + 20;\n\n\tfor (let i = 0; i < maxAttempts; i++) {\n\t\tconst offset = i === 0 ? 0 : Math.ceil(i / 2) * step * (i % 2 === 1 ? 1 : -1);\n\t\tconst candidateBox: Rect = {\n\t\t\tx: isHorizontal ? baseX : baseX + offset,\n\t\t\ty: isHorizontal ? baseY + offset : baseY,\n\t\t\twidth: size.width,\n\t\t\theight: size.height\n\t\t};\n\n\t\tif (!obstacles.some((obstacle) => overlaps(candidateBox, obstacle, 8))) {\n\t\t\treturn {\n\t\t\t\tx: Math.round(candidateBox.x),\n\t\t\t\ty: Math.round(candidateBox.y)\n\t\t\t};\n\t\t}\n\t}\n\n\treturn {\n\t\tx: Math.round(baseX),\n\t\ty: Math.round(baseY)\n\t};\n}\n","import type {\n\tCanvasNode,\n\tFanOutTrajectoryOptions,\n\tNodeTransition,\n\tTrajectoryFunction,\n\tTrajectoryPoint,\n\tXYPosition\n} from './types.js';\n\n/**\n * Standard cubic ease-out function (pure math, framework-agnostic).\n */\nexport const defaultEasing = (t: number): number => --t * t * t + 1;\n\n/**\n * Standard linear trajectory: straight line interpolation with linear scale & opacity progression.\n */\nexport const linearTrajectory: TrajectoryFunction = (\n\torigin: XYPosition,\n\ttarget: XYPosition,\n\tprogress: number\n): TrajectoryPoint => {\n\treturn {\n\t\tposition: {\n\t\t\tx: origin.x + (target.x - origin.x) * progress,\n\t\t\ty: origin.y + (target.y - origin.y) * progress\n\t\t},\n\t\tscale: progress,\n\t\topacity: Math.min(1, progress * 1.5)\n\t};\n};\n\n/**\n * Linear position trajectory: pure position interpolation without altering scale or opacity.\n */\nexport const linearPositionTrajectory: TrajectoryFunction = (\n\torigin: XYPosition,\n\ttarget: XYPosition,\n\tprogress: number\n): TrajectoryPoint => {\n\treturn {\n\t\tposition: {\n\t\t\tx: origin.x + (target.x - origin.x) * progress,\n\t\t\ty: origin.y + (target.y - origin.y) * progress\n\t\t}\n\t};\n};\n\n/**\n * Creates a fan-out trajectory where nodes arc outward from origin to target.\n */\nexport function createFanOutTrajectory(options: FanOutTrajectoryOptions = {}): TrajectoryFunction {\n\tconst {\n\t\tcurvature = 0.4,\n\t\tstartScale = 0,\n\t\tendScale = 1,\n\t\tstartOpacity = 0,\n\t\tendOpacity = 1\n\t} = options;\n\n\treturn (\n\t\torigin: XYPosition,\n\t\ttarget: XYPosition,\n\t\tprogress: number,\n\t\tindex: number,\n\t\ttotal: number\n\t): TrajectoryPoint => {\n\t\tconst dx = target.x - origin.x;\n\t\tconst dy = target.y - origin.y;\n\n\t\t// Normalized index from -1 (top) to +1 (bottom)\n\t\tconst normIndex = total > 1 ? (index - (total - 1) / 2) / ((total - 1) / 2) : 0;\n\n\t\t// Perpendicular control point offset to create smooth fan arc\n\t\tconst midX = origin.x + dx * 0.4;\n\t\tconst midY = origin.y + dy * 0.1 - normIndex * Math.abs(dx) * 0.15 * curvature;\n\n\t\t// Quadratic Bezier interpolation: B(t) = (1-t)^2 * P0 + 2(1-t)t * P1 + t^2 * P2\n\t\tconst t = progress;\n\t\tconst oneMinusT = 1 - t;\n\n\t\tconst x = oneMinusT * oneMinusT * origin.x + 2 * oneMinusT * t * midX + t * t * target.x;\n\t\tconst y = oneMinusT * oneMinusT * origin.y + 2 * oneMinusT * t * midY + t * t * target.y;\n\n\t\tconst scale = startScale + (endScale - startScale) * progress;\n\t\tconst opacity = startOpacity + (endOpacity - startOpacity) * progress;\n\n\t\treturn {\n\t\t\tposition: { x, y },\n\t\t\tscale,\n\t\t\topacity\n\t\t};\n\t};\n}\n\n/**\n * Creates a custom quadratic Bezier trajectory with a specified control point resolver.\n */\nexport function createBezierTrajectory(\n\tgetControlPoint: (origin: XYPosition, target: XYPosition) => XYPosition\n): TrajectoryFunction {\n\treturn (origin: XYPosition, target: XYPosition, progress: number): TrajectoryPoint => {\n\t\tconst cp = getControlPoint(origin, target);\n\t\tconst t = progress;\n\t\tconst oneMinusT = 1 - t;\n\n\t\tconst x = oneMinusT * oneMinusT * origin.x + 2 * oneMinusT * t * cp.x + t * t * target.x;\n\t\tconst y = oneMinusT * oneMinusT * origin.y + 2 * oneMinusT * t * cp.y + t * t * target.y;\n\n\t\treturn {\n\t\t\tposition: { x, y },\n\t\t\tscale: progress,\n\t\t\topacity: progress\n\t\t};\n\t};\n}\n\n/**\n * Coordinates and animates multiple node transitions simultaneously with zero per-frame array allocations.\n */\nexport function runMultiNodeTransition<TNode extends CanvasNode = CanvasNode>(\n\ttransitions: NodeTransition<TNode>[],\n\toptions: {\n\t\tdefaultDuration?: number;\n\t\tdefaultEasing?: (t: number) => number;\n\t\tonUpdate?: () => void;\n\t\tonComplete?: () => void;\n\t} = {}\n): () => void {\n\tif (transitions.length === 0) {\n\t\toptions.onComplete?.();\n\t\treturn () => {};\n\t}\n\n\tconst { defaultDuration = 400, defaultEasing: easingFunc = defaultEasing, onUpdate, onComplete } = options;\n\n\tlet isCancelled = false;\n\tconst startTime = Date.now();\n\n\tconst items = transitions.map((tr, i) => ({\n\t\t...tr,\n\t\tindex: tr.index ?? i,\n\t\ttotal: tr.total ?? transitions.length,\n\t\tduration: tr.duration ?? defaultDuration,\n\t\teasing: tr.easing ?? easingFunc,\n\t\tdelay: tr.delay ?? 0,\n\t\ttrajectory: tr.trajectory ?? linearTrajectory\n\t}));\n\n\tfunction frame() {\n\t\tif (isCancelled) return;\n\n\t\tconst now = Date.now();\n\t\tlet allCompleted = true;\n\n\t\tfor (let i = 0; i < items.length; i++) {\n\t\t\tconst item = items[i];\n\t\t\tconst elapsed = now - (startTime + item.delay);\n\n\t\t\tif (elapsed < 0) {\n\t\t\t\tallCompleted = false;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Guard zero duration and division by zero (referenced in GOTCHAS.md)\n\t\t\tconst rawProgress = item.duration <= 0 ? 1 : Math.min(elapsed / item.duration, 1);\n\t\t\tconst progress = item.duration <= 0 ? 1 : item.easing(rawProgress);\n\n\t\t\tconst point = item.trajectory(item.from, item.to, progress, item.index, item.total);\n\n\t\t\titem.node.position = { ...point.position };\n\n\t\t\tif (point.scale !== undefined || point.opacity !== undefined) {\n\t\t\t\tif (!item.node.data) {\n\t\t\t\t\titem.node.data = {} as any;\n\t\t\t\t}\n\t\t\t\tif (point.scale !== undefined) {\n\t\t\t\t\t(item.node.data as any).scale = point.scale;\n\t\t\t\t}\n\t\t\t\tif (point.opacity !== undefined) {\n\t\t\t\t\t(item.node.data as any).opacity = point.opacity;\n\t\t\t\t\tconst currentStyle = (item.node.style || '').replace(/opacity:\\s*[^;]+;?/g, '').trim();\n\t\t\t\t\titem.node.style = `${currentStyle ? currentStyle + '; ' : ''}opacity: ${point.opacity};`;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (rawProgress < 1) {\n\t\t\t\tallCompleted = false;\n\t\t\t}\n\t\t}\n\n\t\tonUpdate?.();\n\n\t\tif (!allCompleted) {\n\t\t\tif (typeof requestAnimationFrame !== 'undefined') {\n\t\t\t\trequestAnimationFrame(frame);\n\t\t\t}\n\t\t} else {\n\t\t\tonComplete?.();\n\t\t}\n\t}\n\n\tframe();\n\n\treturn () => {\n\t\tisCancelled = true;\n\t};\n}\n","import dagre from '@dagrejs/dagre';\nimport type {\n\tCanvasEdge,\n\tCanvasNode,\n\tDirectionalDisplacementOptions,\n\tRect,\n\tReflowDisplacementOptions,\n\tXYPosition\n} from './types.js';\n\n/**\n * Calculates a bounding rectangle for a set of nodes if not provided by getNodesBounds.\n */\nexport function computeNodesBoundingBox<TNode extends CanvasNode = CanvasNode>(\n\tnodes: TNode[],\n\tdefaultWidth = 200,\n\tdefaultHeight = 60\n): Rect {\n\tif (nodes.length === 0) {\n\t\treturn { x: 0, y: 0, width: 0, height: 0 };\n\t}\n\n\tlet minX = Infinity;\n\tlet minY = Infinity;\n\tlet maxX = -Infinity;\n\tlet maxY = -Infinity;\n\n\tfor (const node of nodes) {\n\t\tconst width = node.measured?.width ?? (node as any).width ?? defaultWidth;\n\t\tconst height = node.measured?.height ?? (node as any).height ?? defaultHeight;\n\n\t\tminX = Math.min(minX, node.position.x);\n\t\tminY = Math.min(minY, node.position.y);\n\t\tmaxX = Math.max(maxX, node.position.x + width);\n\t\tmaxY = Math.max(maxY, node.position.y + height);\n\t}\n\n\treturn {\n\t\tx: minX,\n\t\ty: minY,\n\t\twidth: maxX - minX,\n\t\theight: maxY - minY\n\t};\n}\n\n/**\n * Pure directional displacement calculation.\n * Shifts downstream or surrounding nodes along an axis to clear space for newly inserted child nodes.\n */\nexport function calculateDirectionalDisplacement<TNode extends CanvasNode = CanvasNode>(params: {\n\texistingNodes: TNode[];\n\toriginNode: TNode;\n\tchildNodes: TNode[];\n\tgetNodesBounds?: (nodes: TNode[]) => Rect;\n\toptions?: DirectionalDisplacementOptions;\n}): Map<string, XYPosition> {\n\tconst {\n\t\texistingNodes,\n\t\toriginNode,\n\t\tchildNodes,\n\t\tgetNodesBounds,\n\t\toptions = {}\n\t} = params;\n\n\tconst {\n\t\tdirection = 'right',\n\t\tgap = 40,\n\t\tspreadSiblingLanes = false,\n\t\tsiblingTolerance = 50,\n\t\tminY\n\t} = options;\n\n\tconst displacedMap = new Map<string, XYPosition>();\n\tif (childNodes.length === 0 || existingNodes.length === 0) {\n\t\treturn displacedMap;\n\t}\n\n\tconst childBounds = getNodesBounds\n\t\t? getNodesBounds(childNodes)\n\t\t: computeNodesBoundingBox(childNodes);\n\n\tconst originWidth = originNode.measured?.width ?? (originNode as any).width ?? 200;\n\tconst originHeight = originNode.measured?.height ?? (originNode as any).height ?? 60;\n\n\t// The delta space required along primary axis\n\tconst deltaPrimary =\n\t\tdirection === 'right' || direction === 'left'\n\t\t\t? childBounds.width + gap\n\t\t\t: childBounds.height + gap;\n\n\t// Vertical displacement parameters: upward and downward row clearance\n\tconst deltaUp = Math.max(0, originNode.position.y - childBounds.y + gap);\n\tconst deltaDown = Math.max(\n\t\t0,\n\t\tchildBounds.y + childBounds.height - (originNode.position.y + originHeight) + gap\n\t);\n\n\t// Both above and below displace equally so the row expands symmetrically\n\tconst equalDelta = Math.max(deltaUp, deltaDown);\n\n\tfor (const node of existingNodes) {\n\t\tif (node.id === originNode.id) continue;\n\n\t\tconst isSiblingRow =\n\t\t\tMath.abs(node.position.y - originNode.position.y) < siblingTolerance;\n\n\t\tswitch (direction) {\n\t\t\tcase 'right': {\n\t\t\t\tif (node.position.x > originNode.position.x) {\n\t\t\t\t\tdisplacedMap.set(node.id, {\n\t\t\t\t\t\tx: node.position.x + deltaPrimary,\n\t\t\t\t\t\ty: node.position.y\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'left': {\n\t\t\t\tif (node.position.x < originNode.position.x) {\n\t\t\t\t\tdisplacedMap.set(node.id, {\n\t\t\t\t\t\tx: node.position.x - deltaPrimary,\n\t\t\t\t\t\ty: node.position.y\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'down': {\n\t\t\t\tif (node.position.y > originNode.position.y) {\n\t\t\t\t\tdisplacedMap.set(node.id, {\n\t\t\t\t\t\tx: node.position.x,\n\t\t\t\t\t\ty: node.position.y + deltaPrimary\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'up': {\n\t\t\t\tif (node.position.y < originNode.position.y) {\n\t\t\t\t\tdisplacedMap.set(node.id, {\n\t\t\t\t\t\tx: node.position.x,\n\t\t\t\t\t\ty: node.position.y - deltaPrimary\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'vertical': {\n\t\t\t\tif (isSiblingRow) break;\n\n\t\t\t\tif (node.position.y < originNode.position.y) {\n\t\t\t\t\tdisplacedMap.set(node.id, {\n\t\t\t\t\t\tx: node.position.x,\n\t\t\t\t\t\ty: node.position.y - equalDelta\n\t\t\t\t\t});\n\t\t\t\t} else if (node.position.y > originNode.position.y) {\n\t\t\t\t\tdisplacedMap.set(node.id, {\n\t\t\t\t\t\tx: node.position.x,\n\t\t\t\t\t\ty: node.position.y + equalDelta\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\t// Sibling lane spreading to avoid overlap among child nodes\n\tif (spreadSiblingLanes && (direction === 'right' || direction === 'left')) {\n\t\tfor (const [nodeId, pos] of displacedMap.entries()) {\n\t\t\tconst node = existingNodes.find((n) => n.id === nodeId);\n\t\t\tif (node && Math.abs(node.position.y - originNode.position.y) < siblingTolerance) {\n\t\t\t\tconst isAbove = node.position.y < originNode.position.y;\n\t\t\t\tdisplacedMap.set(nodeId, {\n\t\t\t\t\tx: pos.x,\n\t\t\t\t\ty: pos.y + (isAbove ? -deltaUp : deltaDown)\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\t// Floor constraint\n\tif (minY !== undefined) {\n\t\tfor (const [nodeId, pos] of displacedMap.entries()) {\n\t\t\tif (pos.y < minY) {\n\t\t\t\tdisplacedMap.set(nodeId, { x: pos.x, y: minY });\n\t\t\t}\n\t\t}\n\t}\n\n\treturn displacedMap;\n}\n\n/**\n * Calculates Dagre reflow displacement preserving the position of an anchor node.\n */\nexport function calculateDagreReflowDisplacement<\n\tTNode extends CanvasNode = CanvasNode,\n\tTEdge extends CanvasEdge = CanvasEdge\n>(params: {\n\tcurrentNodes: TNode[];\n\tcurrentEdges: TEdge[];\n\tfutureNodes: TNode[];\n\tfutureEdges: TEdge[];\n\toptions: ReflowDisplacementOptions;\n\tgetNodesBounds?: (nodes: TNode[]) => Rect;\n}): Map<string, XYPosition> {\n\tconst {\n\t\tcurrentNodes,\n\t\tfutureNodes,\n\t\tfutureEdges,\n\t\toptions\n\t} = params;\n\n\tconst {\n\t\tanchorNodeId,\n\t\tdirection = 'LR',\n\t\tranksep = 100,\n\t\tnodesep = 25,\n\t\tdefaultNodeWidth = 200,\n\t\tdefaultNodeHeight = 60\n\t} = options;\n\n\tconst anchorNode = currentNodes.find((n) => n.id === anchorNodeId);\n\tif (!anchorNode) return new Map();\n\n\tconst g = new dagre.graphlib.Graph();\n\tg.setDefaultEdgeLabel(() => ({}));\n\tg.setGraph({ rankdir: direction, ranksep, nodesep });\n\n\tconst nodeIds = new Set(futureNodes.map((n) => n.id));\n\n\tfutureNodes.forEach((node) => {\n\t\tconst nodeWidth = node.measured?.width ?? (node as any).width ?? defaultNodeWidth;\n\t\tconst nodeHeight = node.measured?.height ?? (node as any).height ?? defaultNodeHeight;\n\t\tg.setNode(node.id, { width: nodeWidth, height: nodeHeight });\n\t});\n\n\tfutureEdges.forEach((edge) => {\n\t\tif (nodeIds.has(edge.source) && nodeIds.has(edge.target)) {\n\t\t\tg.setEdge(edge.source, edge.target);\n\t\t}\n\t});\n\n\tdagre.layout(g);\n\n\tconst anchorLayoutPos = g.node(anchorNodeId);\n\tif (!anchorLayoutPos) return new Map();\n\n\tconst anchorWidth = anchorNode.measured?.width ?? (anchorNode as any).width ?? defaultNodeWidth;\n\tconst anchorHeight = anchorNode.measured?.height ?? (anchorNode as any).height ?? defaultNodeHeight;\n\n\tconst anchorLayoutUpperLeft = {\n\t\tx: anchorLayoutPos.x - anchorWidth / 2,\n\t\ty: anchorLayoutPos.y - anchorHeight / 2\n\t};\n\n\tconst deltaX = anchorNode.position.x - anchorLayoutUpperLeft.x;\n\tconst deltaY = anchorNode.position.y - anchorLayoutUpperLeft.y;\n\n\tconst displacementMap = new Map<string, XYPosition>();\n\n\tcurrentNodes.forEach((node) => {\n\t\tif (node.id === anchorNodeId) return;\n\n\t\tconst layoutNode = g.node(node.id);\n\t\tif (!layoutNode) return;\n\n\t\tconst nodeWidth = node.measured?.width ?? (node as any).width ?? defaultNodeWidth;\n\t\tconst nodeHeight = node.measured?.height ?? (node as any).height ?? defaultNodeHeight;\n\n\t\tconst upperLeftX = layoutNode.x - nodeWidth / 2 + deltaX;\n\t\tconst upperLeftY = layoutNode.y - nodeHeight / 2 + deltaY;\n\n\t\tif (\n\t\t\tMath.abs(upperLeftX - node.position.x) > 1 ||\n\t\t\tMath.abs(upperLeftY - node.position.y) > 1\n\t\t) {\n\t\t\tdisplacementMap.set(node.id, { x: upperLeftX, y: upperLeftY });\n\t\t}\n\t});\n\n\treturn displacementMap;\n}\n","import type {\n\tCanvasClipboardPayload,\n\tCanvasEdge,\n\tCanvasNode,\n\tXYPosition\n} from './types.js';\n\n/**\n * Checks if an event originated from a text input, textarea, contenteditable element, or rich editor.\n */\nexport function isEventFromTextInput(event: Event | { target: EventTarget | null }): boolean {\n\tconst target = (event as any).target as HTMLElement | null;\n\tif (!target) return false;\n\tif (\n\t\ttarget.tagName === 'INPUT' ||\n\t\ttarget.tagName === 'TEXTAREA' ||\n\t\ttarget.tagName === 'SELECT' ||\n\t\ttarget.isContentEditable ||\n\t\ttarget.closest?.('[contenteditable=\"true\"]') ||\n\t\ttarget.closest?.('.ProseMirror')\n\t) {\n\t\treturn true;\n\t}\n\treturn false;\n}\n\n/**\n * Validates that an object conforms to minimal CanvasNode shape.\n */\nexport function isValidCanvasNode(obj: unknown): obj is CanvasNode {\n\treturn (\n\t\ttypeof obj === 'object' &&\n\t\tobj !== null &&\n\t\t'id' in obj &&\n\t\ttypeof (obj as any).id === 'string' &&\n\t\t'position' in obj &&\n\t\ttypeof (obj as any).position === 'object' &&\n\t\t(obj as any).position !== null &&\n\t\t'x' in (obj as any).position &&\n\t\t'y' in (obj as any).position\n\t);\n}\n\n/**\n * Checks if a string is a valid HTTP/HTTPS URL.\n */\nexport function isValidUrl(url: string): boolean {\n\ttry {\n\t\tconst parsed = new URL(url);\n\t\treturn parsed.protocol === 'http:' || parsed.protocol === 'https:';\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/**\n * Serializes nodes and optional edges into clipboard JSON payload.\n */\nexport function serializeCanvasNodes<\n\tTNode extends CanvasNode = CanvasNode,\n\tTEdge extends CanvasEdge = CanvasEdge\n>(nodes: TNode[], edges?: TEdge[]): string {\n\tconst payload: CanvasClipboardPayload<TNode, TEdge> = {\n\t\tversion: 1,\n\t\tnodes,\n\t\tedges\n\t};\n\treturn JSON.stringify(payload);\n}\n\n/**\n * Parses raw JSON string into a CanvasClipboardPayload if valid.\n */\nexport function parseCanvasClipboardData<\n\tTNode extends CanvasNode = CanvasNode,\n\tTEdge extends CanvasEdge = CanvasEdge\n>(raw: string): CanvasClipboardPayload<TNode, TEdge> | null {\n\ttry {\n\t\tconst parsed = JSON.parse(raw);\n\t\tif (\n\t\t\ttypeof parsed === 'object' &&\n\t\t\tparsed !== null &&\n\t\t\tArray.isArray(parsed.nodes) &&\n\t\t\tparsed.nodes.length > 0 &&\n\t\t\tparsed.nodes.every(isValidCanvasNode)\n\t\t) {\n\t\t\treturn parsed as CanvasClipboardPayload<TNode, TEdge>;\n\t\t}\n\t} catch {\n\t\t// Not JSON or invalid payload\n\t}\n\treturn null;\n}\n\n/**\n * Generates unique new IDs for pasted nodes and updates edge references accordingly.\n */\nexport function remapPastedNodes<\n\tTNode extends CanvasNode = CanvasNode,\n\tTEdge extends CanvasEdge = CanvasEdge\n>(\n\tnodes: TNode[],\n\tedges: TEdge[] = [],\n\toffset: XYPosition = { x: 30, y: 30 },\n\tidGenerator: () => string = () => `node-${Math.random().toString(36).substring(2, 9)}`\n): { nodes: TNode[]; edges: TEdge[] } {\n\tconst idMap = new Map<string, string>();\n\n\tconst newNodes = nodes.map((node) => {\n\t\tconst newId = idGenerator();\n\t\tidMap.set(node.id, newId);\n\t\treturn {\n\t\t\t...node,\n\t\t\tid: newId,\n\t\t\tposition: {\n\t\t\t\tx: node.position.x + offset.x,\n\t\t\t\ty: node.position.y + offset.y\n\t\t\t},\n\t\t\tselected: true\n\t\t};\n\t});\n\n\tconst newEdges = edges\n\t\t.filter((e) => idMap.has(e.source) && idMap.has(e.target))\n\t\t.map((edge) => ({\n\t\t\t...edge,\n\t\t\tid: `edge-${Math.random().toString(36).substring(2, 9)}`,\n\t\t\tsource: idMap.get(edge.source)!,\n\t\t\ttarget: idMap.get(edge.target)!,\n\t\t\tselected: false\n\t\t}));\n\n\treturn { nodes: newNodes, edges: newEdges };\n}\n\n/**\n * Repositions nodes so their bounding box origin matches the given target position.\n */\nexport function repositionNodesTo<TNode extends CanvasNode = CanvasNode>(\n\tnodes: TNode[],\n\ttargetOrigin: XYPosition\n): TNode[] {\n\tif (nodes.length === 0) return [];\n\tconst minX = Math.min(...nodes.map((n) => n.position.x));\n\tconst minY = Math.min(...nodes.map((n) => n.position.y));\n\tconst deltaX = targetOrigin.x - minX;\n\tconst deltaY = targetOrigin.y - minY;\n\n\treturn nodes.map((n) => ({\n\t\t...n,\n\t\tposition: {\n\t\t\tx: n.position.x + deltaX,\n\t\t\ty: n.position.y + deltaY\n\t\t}\n\t}));\n}\n","import { ensureLayout } from './layout.js';\nimport { linearPositionTrajectory, runMultiNodeTransition } from './trajectory.js';\nimport type { CanvasEdge, CanvasNode, IncrementalLayoutOptions, NodeTransition, XYPosition } from './types.js';\n\nexport interface StreamingLayoutManagerOptions {\n\tthrottleMs?: number;\n\tglideDurationMs?: number;\n\tlayoutOptions?: IncrementalLayoutOptions;\n\tonLayoutUpdated?: (positions: Map<string, XYPosition>) => void;\n}\n\n/**\n * Manages throttled incremental layout recalculation and smooth tweened node gliding\n * during active streaming (e.g. LLM streaming or graph generation).\n */\nexport class StreamingLayoutManager<\n\tTNode extends CanvasNode = CanvasNode,\n\tTEdge extends CanvasEdge = CanvasEdge\n> {\n\tprivate throttleMs: number;\n\tprivate glideDurationMs: number;\n\tprivate layoutOptions: IncrementalLayoutOptions;\n\tprivate onLayoutUpdated?: (positions: Map<string, XYPosition>) => void;\n\n\tprivate pendingTimer: any = null;\n\tprivate activeTransitionCancel: (() => void) | null = null;\n\tprivate targetPositions = new Map<string, XYPosition>();\n\n\tconstructor(options: StreamingLayoutManagerOptions = {}) {\n\t\tthis.throttleMs = options.throttleMs ?? 200;\n\t\tthis.glideDurationMs = options.glideDurationMs ?? 300;\n\t\tthis.layoutOptions = options.layoutOptions ?? { direction: 'LR' };\n\t\tthis.onLayoutUpdated = options.onLayoutUpdated;\n\t}\n\n\t/**\n\t * Feed incoming nodes and edges into the streaming manager.\n\t * Coalesces rapid streaming bursts and triggers smooth layout gliding.\n\t */\n\tpublic pushStreamUpdate(\n\t\tnodes: TNode[],\n\t\tedges: TEdge[],\n\t\tcurrentPositions: Map<string, XYPosition>\n\t): void {\n\t\tif (this.pendingTimer) {\n\t\t\tclearTimeout(this.pendingTimer);\n\t\t}\n\n\t\tthis.pendingTimer = setTimeout(() => {\n\t\t\tthis.pendingTimer = null;\n\t\t\tthis.recalculateAndGlide(nodes, edges, currentPositions);\n\t\t}, this.throttleMs);\n\t}\n\n\t/**\n\t * Forces immediate calculation and cancels pending throttled timers.\n\t */\n\tpublic flush(\n\t\tnodes: TNode[],\n\t\tedges: TEdge[],\n\t\tcurrentPositions: Map<string, XYPosition>\n\t): void {\n\t\tif (this.pendingTimer) {\n\t\t\tclearTimeout(this.pendingTimer);\n\t\t\tthis.pendingTimer = null;\n\t\t}\n\t\tthis.recalculateAndGlide(nodes, edges, currentPositions);\n\t}\n\n\tprivate recalculateAndGlide(\n\t\tnodes: TNode[],\n\t\tedges: TEdge[],\n\t\tcurrentPositions: Map<string, XYPosition>\n\t): void {\n\t\tif (nodes.length === 0) return;\n\n\t\t// Cancel any currently running RAF glide\n\t\tif (this.activeTransitionCancel) {\n\t\t\tthis.activeTransitionCancel();\n\t\t\tthis.activeTransitionCancel = null;\n\t\t}\n\n\t\t// Incremental layout preserves existing nodes and aligns new nodes\n\t\tconst stored: Record<string, XYPosition> = {};\n\t\tfor (const [id, pos] of currentPositions.entries()) {\n\t\t\tstored[id] = pos;\n\t\t}\n\n\t\tconst layouted = ensureLayout(nodes, edges, {\n\t\t\t...this.layoutOptions,\n\t\t\tstoredPositions: stored\n\t\t});\n\n\t\tconst nextPositions = new Map<string, XYPosition>();\n\t\tconst transitions: NodeTransition<TNode>[] = [];\n\n\t\tfor (const node of layouted) {\n\t\t\tconst target = node.position;\n\t\t\tnextPositions.set(node.id, target);\n\n\t\t\tconst current = currentPositions.get(node.id) ?? target;\n\t\t\tconst distance = Math.hypot(target.x - current.x, target.y - current.y);\n\n\t\t\tif (distance > 2) {\n\t\t\t\ttransitions.push({\n\t\t\t\t\tnode,\n\t\t\t\t\tfrom: current,\n\t\t\t\t\tto: target,\n\t\t\t\t\ttrajectory: linearPositionTrajectory,\n\t\t\t\t\tduration: this.glideDurationMs\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tthis.targetPositions = nextPositions;\n\n\t\tif (transitions.length > 0) {\n\t\t\tthis.activeTransitionCancel = runMultiNodeTransition(transitions, {\n\t\t\t\tonUpdate: () => {\n\t\t\t\t\t// Broadcast updated positions during RAF\n\t\t\t\t\tconst liveMap = new Map<string, XYPosition>(currentPositions);\n\t\t\t\t\tfor (const trans of transitions) {\n\t\t\t\t\t\tliveMap.set(trans.node.id, { ...trans.node.position });\n\t\t\t\t\t}\n\t\t\t\t\tthis.onLayoutUpdated?.(liveMap);\n\t\t\t\t},\n\t\t\t\tonComplete: () => {\n\t\t\t\t\tthis.activeTransitionCancel = null;\n\t\t\t\t\tthis.onLayoutUpdated?.(nextPositions);\n\t\t\t\t}\n\t\t\t});\n\t\t} else {\n\t\t\tthis.onLayoutUpdated?.(nextPositions);\n\t\t}\n\t}\n\n\tpublic destroy(): void {\n\t\tif (this.pendingTimer) {\n\t\t\tclearTimeout(this.pendingTimer);\n\t\t\tthis.pendingTimer = null;\n\t\t}\n\t\tif (this.activeTransitionCancel) {\n\t\t\tthis.activeTransitionCancel();\n\t\t\tthis.activeTransitionCancel = null;\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAkB;AAYX,IAAM,qBAAqB;AAC3B,IAAM,sBAAsB;AAC5B,IAAM,wBAAwB;AAK9B,SAAS,wBACf,QAAQ,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B,oBAAY,KAAK;AAAA,UAChB;AAAA,UACA,MAAM;AAAA,UACN,IAAI;AAAA,UACJ,YAAY;AAAA,UACZ,UAAU,KAAK;AAAA,QAChB,CAAC;AAAA,MACF;AAAA,IACD;AAEA,SAAK,kBAAkB;AAEvB,QAAI,YAAY,SAAS,GAAG;AAC3B,WAAK,yBAAyB,uBAAuB,aAAa;AAAA,QACjE,UAAU,MAAM;AAEf,gBAAM,UAAU,IAAI,IAAwB,gBAAgB;AAC5D,qBAAW,SAAS,aAAa;AAChC,oBAAQ,IAAI,MAAM,KAAK,IAAI,EAAE,GAAG,MAAM,KAAK,SAAS,CAAC;AAAA,UACtD;AACA,eAAK,kBAAkB,OAAO;AAAA,QAC/B;AAAA,QACA,YAAY,MAAM;AACjB,eAAK,yBAAyB;AAC9B,eAAK,kBAAkB,aAAa;AAAA,QACrC;AAAA,MACD,CAAC;AAAA,IACF,OAAO;AACN,WAAK,kBAAkB,aAAa;AAAA,IACrC;AAAA,EACD;AAAA,EAEO,UAAgB;AACtB,QAAI,KAAK,cAAc;AACtB,mBAAa,KAAK,YAAY;AAC9B,WAAK,eAAe;AAAA,IACrB;AACA,QAAI,KAAK,wBAAwB;AAChC,WAAK,uBAAuB;AAC5B,WAAK,yBAAyB;AAAA,IAC/B;AAAA,EACD;AACD;","names":["dagre","import_dagre","dagre"]}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { R as Rect, d as CanvasNode, X as XYPosition, b as CanvasEdge, I as IncrementalLayoutOptions, S as Side, c as CanvasLayoutOptions, P as PlaceBesideOptions, T as TrajectoryFunction, F as FanOutTrajectoryOptions, N as NodeTransition, k as ReflowDisplacementOptions, D as DirectionalDisplacementOptions, C as CanvasClipboardPayload } from '../types-lGtRobRV.cjs';
|
|
2
|
+
export { a as CanvasDockingCallbacks, e as CollapseNodeOptions, f as DisplacementDirection, g as DockStrategy, E as ExplodeNodeOptions, h as ExplosionSnapshot, G as GraphDifferences, i as Point, j as Position, l as TrajectoryPoint } from '../types-lGtRobRV.cjs';
|
|
3
|
+
|
|
4
|
+
declare const DEFAULT_NODE_WIDTH = 200;
|
|
5
|
+
declare const DEFAULT_NODE_HEIGHT = 60;
|
|
6
|
+
declare const DEFAULT_PLACEMENT_GAP = 48;
|
|
7
|
+
/**
|
|
8
|
+
* Calculates upper-left flow coordinate for an element to be centered in the viewport.
|
|
9
|
+
*/
|
|
10
|
+
declare function getCenteredNodePosition(width: number | undefined, height: number | undefined, screenToFlowPosition: (position: XYPosition) => XYPosition, screenDimensions?: {
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
}): XYPosition;
|
|
14
|
+
/**
|
|
15
|
+
* Updates positions of nodes so their collective bounding box is centered in the current viewport.
|
|
16
|
+
*/
|
|
17
|
+
declare function centerNodes<TNode extends CanvasNode = CanvasNode>(nodes: TNode[], screenToFlowPosition: (position: XYPosition) => XYPosition, getNodesBounds: (nodes: TNode[]) => Rect, screenDimensions?: {
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
}): TNode[];
|
|
21
|
+
/**
|
|
22
|
+
* Automatically calculates directed hierarchical layout of nodes and edges using Dagre.
|
|
23
|
+
*/
|
|
24
|
+
declare function getLayoutedNodes<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge>(nodes: TNode[], edges: TEdge[], getNodesBounds?: (nodes: TNode[]) => Rect, options?: CanvasLayoutOptions): TNode[];
|
|
25
|
+
/**
|
|
26
|
+
* Heuristic text-based node size estimator when DOM measurement is not available.
|
|
27
|
+
*/
|
|
28
|
+
declare function estimateNodeSize(node: CanvasNode, defaultWidth?: number, defaultHeight?: number): {
|
|
29
|
+
width: number;
|
|
30
|
+
height: number;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Computes bounding rectangle of an array of rectangles.
|
|
34
|
+
*/
|
|
35
|
+
declare function boundsOf(rects: Rect[]): Rect | null;
|
|
36
|
+
/**
|
|
37
|
+
* Center coordinate of a rectangle.
|
|
38
|
+
*/
|
|
39
|
+
declare function centre(r: Rect): XYPosition;
|
|
40
|
+
/**
|
|
41
|
+
* Determines whether two rectangles overlap, including an optional padding distance.
|
|
42
|
+
*/
|
|
43
|
+
declare function overlaps(a: Rect, b: Rect, pad?: number): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Maps directed layout flow to its natural forward growth side.
|
|
46
|
+
*/
|
|
47
|
+
declare function flowSide(direction?: 'LR' | 'TB' | 'RL' | 'BT'): Side;
|
|
48
|
+
/**
|
|
49
|
+
* Incremental layout blending:
|
|
50
|
+
* Keeps established/manual node positions intact. Runs Dagre on the entire graph,
|
|
51
|
+
* computes the centroid translation offset between auto and stored positions of existing nodes,
|
|
52
|
+
* and places unpositioned/new nodes at (auto + offset).
|
|
53
|
+
*/
|
|
54
|
+
declare function ensureLayout<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge>(nodes: TNode[], edges: TEdge[], options?: IncrementalLayoutOptions): TNode[];
|
|
55
|
+
/**
|
|
56
|
+
* Finds a free top-left coordinate for a node of `size` adjacent to `nearNodeId` (or the cluster),
|
|
57
|
+
* sliding along the perpendicular axis past any intersecting bounding boxes to guarantee non-overlapping placement.
|
|
58
|
+
*/
|
|
59
|
+
declare function placeBeside(rects: Record<string, Rect>, size: {
|
|
60
|
+
width: number;
|
|
61
|
+
height: number;
|
|
62
|
+
}, side: Side, nearNodeId?: string, options?: PlaceBesideOptions): XYPosition;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Standard cubic ease-out function (pure math, framework-agnostic).
|
|
66
|
+
*/
|
|
67
|
+
declare const defaultEasing: (t: number) => number;
|
|
68
|
+
/**
|
|
69
|
+
* Standard linear trajectory: straight line interpolation with linear scale & opacity progression.
|
|
70
|
+
*/
|
|
71
|
+
declare const linearTrajectory: TrajectoryFunction;
|
|
72
|
+
/**
|
|
73
|
+
* Linear position trajectory: pure position interpolation without altering scale or opacity.
|
|
74
|
+
*/
|
|
75
|
+
declare const linearPositionTrajectory: TrajectoryFunction;
|
|
76
|
+
/**
|
|
77
|
+
* Creates a fan-out trajectory where nodes arc outward from origin to target.
|
|
78
|
+
*/
|
|
79
|
+
declare function createFanOutTrajectory(options?: FanOutTrajectoryOptions): TrajectoryFunction;
|
|
80
|
+
/**
|
|
81
|
+
* Creates a custom quadratic Bezier trajectory with a specified control point resolver.
|
|
82
|
+
*/
|
|
83
|
+
declare function createBezierTrajectory(getControlPoint: (origin: XYPosition, target: XYPosition) => XYPosition): TrajectoryFunction;
|
|
84
|
+
/**
|
|
85
|
+
* Coordinates and animates multiple node transitions simultaneously with zero per-frame array allocations.
|
|
86
|
+
*/
|
|
87
|
+
declare function runMultiNodeTransition<TNode extends CanvasNode = CanvasNode>(transitions: NodeTransition<TNode>[], options?: {
|
|
88
|
+
defaultDuration?: number;
|
|
89
|
+
defaultEasing?: (t: number) => number;
|
|
90
|
+
onUpdate?: () => void;
|
|
91
|
+
onComplete?: () => void;
|
|
92
|
+
}): () => void;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Calculates a bounding rectangle for a set of nodes if not provided by getNodesBounds.
|
|
96
|
+
*/
|
|
97
|
+
declare function computeNodesBoundingBox<TNode extends CanvasNode = CanvasNode>(nodes: TNode[], defaultWidth?: number, defaultHeight?: number): Rect;
|
|
98
|
+
/**
|
|
99
|
+
* Pure directional displacement calculation.
|
|
100
|
+
* Shifts downstream or surrounding nodes along an axis to clear space for newly inserted child nodes.
|
|
101
|
+
*/
|
|
102
|
+
declare function calculateDirectionalDisplacement<TNode extends CanvasNode = CanvasNode>(params: {
|
|
103
|
+
existingNodes: TNode[];
|
|
104
|
+
originNode: TNode;
|
|
105
|
+
childNodes: TNode[];
|
|
106
|
+
getNodesBounds?: (nodes: TNode[]) => Rect;
|
|
107
|
+
options?: DirectionalDisplacementOptions;
|
|
108
|
+
}): Map<string, XYPosition>;
|
|
109
|
+
/**
|
|
110
|
+
* Calculates Dagre reflow displacement preserving the position of an anchor node.
|
|
111
|
+
*/
|
|
112
|
+
declare function calculateDagreReflowDisplacement<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge>(params: {
|
|
113
|
+
currentNodes: TNode[];
|
|
114
|
+
currentEdges: TEdge[];
|
|
115
|
+
futureNodes: TNode[];
|
|
116
|
+
futureEdges: TEdge[];
|
|
117
|
+
options: ReflowDisplacementOptions;
|
|
118
|
+
getNodesBounds?: (nodes: TNode[]) => Rect;
|
|
119
|
+
}): Map<string, XYPosition>;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Checks if an event originated from a text input, textarea, contenteditable element, or rich editor.
|
|
123
|
+
*/
|
|
124
|
+
declare function isEventFromTextInput(event: Event | {
|
|
125
|
+
target: EventTarget | null;
|
|
126
|
+
}): boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Validates that an object conforms to minimal CanvasNode shape.
|
|
129
|
+
*/
|
|
130
|
+
declare function isValidCanvasNode(obj: unknown): obj is CanvasNode;
|
|
131
|
+
/**
|
|
132
|
+
* Checks if a string is a valid HTTP/HTTPS URL.
|
|
133
|
+
*/
|
|
134
|
+
declare function isValidUrl(url: string): boolean;
|
|
135
|
+
/**
|
|
136
|
+
* Serializes nodes and optional edges into clipboard JSON payload.
|
|
137
|
+
*/
|
|
138
|
+
declare function serializeCanvasNodes<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge>(nodes: TNode[], edges?: TEdge[]): string;
|
|
139
|
+
/**
|
|
140
|
+
* Parses raw JSON string into a CanvasClipboardPayload if valid.
|
|
141
|
+
*/
|
|
142
|
+
declare function parseCanvasClipboardData<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge>(raw: string): CanvasClipboardPayload<TNode, TEdge> | null;
|
|
143
|
+
/**
|
|
144
|
+
* Generates unique new IDs for pasted nodes and updates edge references accordingly.
|
|
145
|
+
*/
|
|
146
|
+
declare function remapPastedNodes<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge>(nodes: TNode[], edges?: TEdge[], offset?: XYPosition, idGenerator?: () => string): {
|
|
147
|
+
nodes: TNode[];
|
|
148
|
+
edges: TEdge[];
|
|
149
|
+
};
|
|
150
|
+
/**
|
|
151
|
+
* Repositions nodes so their bounding box origin matches the given target position.
|
|
152
|
+
*/
|
|
153
|
+
declare function repositionNodesTo<TNode extends CanvasNode = CanvasNode>(nodes: TNode[], targetOrigin: XYPosition): TNode[];
|
|
154
|
+
|
|
155
|
+
interface StreamingLayoutManagerOptions {
|
|
156
|
+
throttleMs?: number;
|
|
157
|
+
glideDurationMs?: number;
|
|
158
|
+
layoutOptions?: IncrementalLayoutOptions;
|
|
159
|
+
onLayoutUpdated?: (positions: Map<string, XYPosition>) => void;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Manages throttled incremental layout recalculation and smooth tweened node gliding
|
|
163
|
+
* during active streaming (e.g. LLM streaming or graph generation).
|
|
164
|
+
*/
|
|
165
|
+
declare class StreamingLayoutManager<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge> {
|
|
166
|
+
private throttleMs;
|
|
167
|
+
private glideDurationMs;
|
|
168
|
+
private layoutOptions;
|
|
169
|
+
private onLayoutUpdated?;
|
|
170
|
+
private pendingTimer;
|
|
171
|
+
private activeTransitionCancel;
|
|
172
|
+
private targetPositions;
|
|
173
|
+
constructor(options?: StreamingLayoutManagerOptions);
|
|
174
|
+
/**
|
|
175
|
+
* Feed incoming nodes and edges into the streaming manager.
|
|
176
|
+
* Coalesces rapid streaming bursts and triggers smooth layout gliding.
|
|
177
|
+
*/
|
|
178
|
+
pushStreamUpdate(nodes: TNode[], edges: TEdge[], currentPositions: Map<string, XYPosition>): void;
|
|
179
|
+
/**
|
|
180
|
+
* Forces immediate calculation and cancels pending throttled timers.
|
|
181
|
+
*/
|
|
182
|
+
flush(nodes: TNode[], edges: TEdge[], currentPositions: Map<string, XYPosition>): void;
|
|
183
|
+
private recalculateAndGlide;
|
|
184
|
+
destroy(): void;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export { CanvasClipboardPayload, CanvasEdge, CanvasLayoutOptions, CanvasNode, DEFAULT_NODE_HEIGHT, DEFAULT_NODE_WIDTH, DEFAULT_PLACEMENT_GAP, DirectionalDisplacementOptions, FanOutTrajectoryOptions, IncrementalLayoutOptions, NodeTransition, PlaceBesideOptions, Rect, ReflowDisplacementOptions, Side, StreamingLayoutManager, type StreamingLayoutManagerOptions, TrajectoryFunction, XYPosition, boundsOf, calculateDagreReflowDisplacement, calculateDirectionalDisplacement, centerNodes, centre, computeNodesBoundingBox, createBezierTrajectory, createFanOutTrajectory, defaultEasing, ensureLayout, estimateNodeSize, flowSide, getCenteredNodePosition, getLayoutedNodes, isEventFromTextInput, isValidCanvasNode, isValidUrl, linearPositionTrajectory, linearTrajectory, overlaps, parseCanvasClipboardData, placeBeside, remapPastedNodes, repositionNodesTo, runMultiNodeTransition, serializeCanvasNodes };
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { R as Rect, d as CanvasNode, X as XYPosition, b as CanvasEdge, I as IncrementalLayoutOptions, S as Side, c as CanvasLayoutOptions, P as PlaceBesideOptions, T as TrajectoryFunction, F as FanOutTrajectoryOptions, N as NodeTransition, k as ReflowDisplacementOptions, D as DirectionalDisplacementOptions, C as CanvasClipboardPayload } from '../types-lGtRobRV.js';
|
|
2
|
+
export { a as CanvasDockingCallbacks, e as CollapseNodeOptions, f as DisplacementDirection, g as DockStrategy, E as ExplodeNodeOptions, h as ExplosionSnapshot, G as GraphDifferences, i as Point, j as Position, l as TrajectoryPoint } from '../types-lGtRobRV.js';
|
|
3
|
+
|
|
4
|
+
declare const DEFAULT_NODE_WIDTH = 200;
|
|
5
|
+
declare const DEFAULT_NODE_HEIGHT = 60;
|
|
6
|
+
declare const DEFAULT_PLACEMENT_GAP = 48;
|
|
7
|
+
/**
|
|
8
|
+
* Calculates upper-left flow coordinate for an element to be centered in the viewport.
|
|
9
|
+
*/
|
|
10
|
+
declare function getCenteredNodePosition(width: number | undefined, height: number | undefined, screenToFlowPosition: (position: XYPosition) => XYPosition, screenDimensions?: {
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
}): XYPosition;
|
|
14
|
+
/**
|
|
15
|
+
* Updates positions of nodes so their collective bounding box is centered in the current viewport.
|
|
16
|
+
*/
|
|
17
|
+
declare function centerNodes<TNode extends CanvasNode = CanvasNode>(nodes: TNode[], screenToFlowPosition: (position: XYPosition) => XYPosition, getNodesBounds: (nodes: TNode[]) => Rect, screenDimensions?: {
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
}): TNode[];
|
|
21
|
+
/**
|
|
22
|
+
* Automatically calculates directed hierarchical layout of nodes and edges using Dagre.
|
|
23
|
+
*/
|
|
24
|
+
declare function getLayoutedNodes<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge>(nodes: TNode[], edges: TEdge[], getNodesBounds?: (nodes: TNode[]) => Rect, options?: CanvasLayoutOptions): TNode[];
|
|
25
|
+
/**
|
|
26
|
+
* Heuristic text-based node size estimator when DOM measurement is not available.
|
|
27
|
+
*/
|
|
28
|
+
declare function estimateNodeSize(node: CanvasNode, defaultWidth?: number, defaultHeight?: number): {
|
|
29
|
+
width: number;
|
|
30
|
+
height: number;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Computes bounding rectangle of an array of rectangles.
|
|
34
|
+
*/
|
|
35
|
+
declare function boundsOf(rects: Rect[]): Rect | null;
|
|
36
|
+
/**
|
|
37
|
+
* Center coordinate of a rectangle.
|
|
38
|
+
*/
|
|
39
|
+
declare function centre(r: Rect): XYPosition;
|
|
40
|
+
/**
|
|
41
|
+
* Determines whether two rectangles overlap, including an optional padding distance.
|
|
42
|
+
*/
|
|
43
|
+
declare function overlaps(a: Rect, b: Rect, pad?: number): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Maps directed layout flow to its natural forward growth side.
|
|
46
|
+
*/
|
|
47
|
+
declare function flowSide(direction?: 'LR' | 'TB' | 'RL' | 'BT'): Side;
|
|
48
|
+
/**
|
|
49
|
+
* Incremental layout blending:
|
|
50
|
+
* Keeps established/manual node positions intact. Runs Dagre on the entire graph,
|
|
51
|
+
* computes the centroid translation offset between auto and stored positions of existing nodes,
|
|
52
|
+
* and places unpositioned/new nodes at (auto + offset).
|
|
53
|
+
*/
|
|
54
|
+
declare function ensureLayout<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge>(nodes: TNode[], edges: TEdge[], options?: IncrementalLayoutOptions): TNode[];
|
|
55
|
+
/**
|
|
56
|
+
* Finds a free top-left coordinate for a node of `size` adjacent to `nearNodeId` (or the cluster),
|
|
57
|
+
* sliding along the perpendicular axis past any intersecting bounding boxes to guarantee non-overlapping placement.
|
|
58
|
+
*/
|
|
59
|
+
declare function placeBeside(rects: Record<string, Rect>, size: {
|
|
60
|
+
width: number;
|
|
61
|
+
height: number;
|
|
62
|
+
}, side: Side, nearNodeId?: string, options?: PlaceBesideOptions): XYPosition;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Standard cubic ease-out function (pure math, framework-agnostic).
|
|
66
|
+
*/
|
|
67
|
+
declare const defaultEasing: (t: number) => number;
|
|
68
|
+
/**
|
|
69
|
+
* Standard linear trajectory: straight line interpolation with linear scale & opacity progression.
|
|
70
|
+
*/
|
|
71
|
+
declare const linearTrajectory: TrajectoryFunction;
|
|
72
|
+
/**
|
|
73
|
+
* Linear position trajectory: pure position interpolation without altering scale or opacity.
|
|
74
|
+
*/
|
|
75
|
+
declare const linearPositionTrajectory: TrajectoryFunction;
|
|
76
|
+
/**
|
|
77
|
+
* Creates a fan-out trajectory where nodes arc outward from origin to target.
|
|
78
|
+
*/
|
|
79
|
+
declare function createFanOutTrajectory(options?: FanOutTrajectoryOptions): TrajectoryFunction;
|
|
80
|
+
/**
|
|
81
|
+
* Creates a custom quadratic Bezier trajectory with a specified control point resolver.
|
|
82
|
+
*/
|
|
83
|
+
declare function createBezierTrajectory(getControlPoint: (origin: XYPosition, target: XYPosition) => XYPosition): TrajectoryFunction;
|
|
84
|
+
/**
|
|
85
|
+
* Coordinates and animates multiple node transitions simultaneously with zero per-frame array allocations.
|
|
86
|
+
*/
|
|
87
|
+
declare function runMultiNodeTransition<TNode extends CanvasNode = CanvasNode>(transitions: NodeTransition<TNode>[], options?: {
|
|
88
|
+
defaultDuration?: number;
|
|
89
|
+
defaultEasing?: (t: number) => number;
|
|
90
|
+
onUpdate?: () => void;
|
|
91
|
+
onComplete?: () => void;
|
|
92
|
+
}): () => void;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Calculates a bounding rectangle for a set of nodes if not provided by getNodesBounds.
|
|
96
|
+
*/
|
|
97
|
+
declare function computeNodesBoundingBox<TNode extends CanvasNode = CanvasNode>(nodes: TNode[], defaultWidth?: number, defaultHeight?: number): Rect;
|
|
98
|
+
/**
|
|
99
|
+
* Pure directional displacement calculation.
|
|
100
|
+
* Shifts downstream or surrounding nodes along an axis to clear space for newly inserted child nodes.
|
|
101
|
+
*/
|
|
102
|
+
declare function calculateDirectionalDisplacement<TNode extends CanvasNode = CanvasNode>(params: {
|
|
103
|
+
existingNodes: TNode[];
|
|
104
|
+
originNode: TNode;
|
|
105
|
+
childNodes: TNode[];
|
|
106
|
+
getNodesBounds?: (nodes: TNode[]) => Rect;
|
|
107
|
+
options?: DirectionalDisplacementOptions;
|
|
108
|
+
}): Map<string, XYPosition>;
|
|
109
|
+
/**
|
|
110
|
+
* Calculates Dagre reflow displacement preserving the position of an anchor node.
|
|
111
|
+
*/
|
|
112
|
+
declare function calculateDagreReflowDisplacement<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge>(params: {
|
|
113
|
+
currentNodes: TNode[];
|
|
114
|
+
currentEdges: TEdge[];
|
|
115
|
+
futureNodes: TNode[];
|
|
116
|
+
futureEdges: TEdge[];
|
|
117
|
+
options: ReflowDisplacementOptions;
|
|
118
|
+
getNodesBounds?: (nodes: TNode[]) => Rect;
|
|
119
|
+
}): Map<string, XYPosition>;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Checks if an event originated from a text input, textarea, contenteditable element, or rich editor.
|
|
123
|
+
*/
|
|
124
|
+
declare function isEventFromTextInput(event: Event | {
|
|
125
|
+
target: EventTarget | null;
|
|
126
|
+
}): boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Validates that an object conforms to minimal CanvasNode shape.
|
|
129
|
+
*/
|
|
130
|
+
declare function isValidCanvasNode(obj: unknown): obj is CanvasNode;
|
|
131
|
+
/**
|
|
132
|
+
* Checks if a string is a valid HTTP/HTTPS URL.
|
|
133
|
+
*/
|
|
134
|
+
declare function isValidUrl(url: string): boolean;
|
|
135
|
+
/**
|
|
136
|
+
* Serializes nodes and optional edges into clipboard JSON payload.
|
|
137
|
+
*/
|
|
138
|
+
declare function serializeCanvasNodes<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge>(nodes: TNode[], edges?: TEdge[]): string;
|
|
139
|
+
/**
|
|
140
|
+
* Parses raw JSON string into a CanvasClipboardPayload if valid.
|
|
141
|
+
*/
|
|
142
|
+
declare function parseCanvasClipboardData<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge>(raw: string): CanvasClipboardPayload<TNode, TEdge> | null;
|
|
143
|
+
/**
|
|
144
|
+
* Generates unique new IDs for pasted nodes and updates edge references accordingly.
|
|
145
|
+
*/
|
|
146
|
+
declare function remapPastedNodes<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge>(nodes: TNode[], edges?: TEdge[], offset?: XYPosition, idGenerator?: () => string): {
|
|
147
|
+
nodes: TNode[];
|
|
148
|
+
edges: TEdge[];
|
|
149
|
+
};
|
|
150
|
+
/**
|
|
151
|
+
* Repositions nodes so their bounding box origin matches the given target position.
|
|
152
|
+
*/
|
|
153
|
+
declare function repositionNodesTo<TNode extends CanvasNode = CanvasNode>(nodes: TNode[], targetOrigin: XYPosition): TNode[];
|
|
154
|
+
|
|
155
|
+
interface StreamingLayoutManagerOptions {
|
|
156
|
+
throttleMs?: number;
|
|
157
|
+
glideDurationMs?: number;
|
|
158
|
+
layoutOptions?: IncrementalLayoutOptions;
|
|
159
|
+
onLayoutUpdated?: (positions: Map<string, XYPosition>) => void;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Manages throttled incremental layout recalculation and smooth tweened node gliding
|
|
163
|
+
* during active streaming (e.g. LLM streaming or graph generation).
|
|
164
|
+
*/
|
|
165
|
+
declare class StreamingLayoutManager<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge> {
|
|
166
|
+
private throttleMs;
|
|
167
|
+
private glideDurationMs;
|
|
168
|
+
private layoutOptions;
|
|
169
|
+
private onLayoutUpdated?;
|
|
170
|
+
private pendingTimer;
|
|
171
|
+
private activeTransitionCancel;
|
|
172
|
+
private targetPositions;
|
|
173
|
+
constructor(options?: StreamingLayoutManagerOptions);
|
|
174
|
+
/**
|
|
175
|
+
* Feed incoming nodes and edges into the streaming manager.
|
|
176
|
+
* Coalesces rapid streaming bursts and triggers smooth layout gliding.
|
|
177
|
+
*/
|
|
178
|
+
pushStreamUpdate(nodes: TNode[], edges: TEdge[], currentPositions: Map<string, XYPosition>): void;
|
|
179
|
+
/**
|
|
180
|
+
* Forces immediate calculation and cancels pending throttled timers.
|
|
181
|
+
*/
|
|
182
|
+
flush(nodes: TNode[], edges: TEdge[], currentPositions: Map<string, XYPosition>): void;
|
|
183
|
+
private recalculateAndGlide;
|
|
184
|
+
destroy(): void;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export { CanvasClipboardPayload, CanvasEdge, CanvasLayoutOptions, CanvasNode, DEFAULT_NODE_HEIGHT, DEFAULT_NODE_WIDTH, DEFAULT_PLACEMENT_GAP, DirectionalDisplacementOptions, FanOutTrajectoryOptions, IncrementalLayoutOptions, NodeTransition, PlaceBesideOptions, Rect, ReflowDisplacementOptions, Side, StreamingLayoutManager, type StreamingLayoutManagerOptions, TrajectoryFunction, XYPosition, boundsOf, calculateDagreReflowDisplacement, calculateDirectionalDisplacement, centerNodes, centre, computeNodesBoundingBox, createBezierTrajectory, createFanOutTrajectory, defaultEasing, ensureLayout, estimateNodeSize, flowSide, getCenteredNodePosition, getLayoutedNodes, isEventFromTextInput, isValidCanvasNode, isValidUrl, linearPositionTrajectory, linearTrajectory, overlaps, parseCanvasClipboardData, placeBeside, remapPastedNodes, repositionNodesTo, runMultiNodeTransition, serializeCanvasNodes };
|