@uipath/apollo-react 4.18.0 → 4.18.2
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/canvas/components/AddNodePanel/AddNodeManager.helpers.cjs +60 -4
- package/dist/canvas/components/AddNodePanel/AddNodeManager.helpers.d.ts.map +1 -1
- package/dist/canvas/components/AddNodePanel/AddNodeManager.helpers.js +61 -5
- package/dist/canvas/components/AddNodePanel/createAddNodePreview.cjs +19 -0
- package/dist/canvas/components/AddNodePanel/createAddNodePreview.d.ts.map +1 -1
- package/dist/canvas/components/AddNodePanel/createAddNodePreview.js +19 -0
- package/dist/canvas/components/LoopNode/LoopNode.cjs +13 -13
- package/dist/canvas/components/LoopNode/LoopNode.d.ts.map +1 -1
- package/dist/canvas/components/LoopNode/LoopNode.js +13 -13
- package/dist/canvas/components/LoopNode/LoopNodePreview.cjs +3 -1
- package/dist/canvas/components/LoopNode/LoopNodePreview.d.ts.map +1 -1
- package/dist/canvas/components/LoopNode/LoopNodePreview.js +3 -1
- package/dist/canvas/storybook-utils/manifests/node-definitions.d.ts.map +1 -1
- package/dist/canvas/storybook-utils/mocks/nodes.d.ts +6 -6
- package/dist/canvas/storybook-utils/mocks/nodes.d.ts.map +1 -1
- package/dist/canvas/utils/NodeUtils.cjs +15 -3
- package/dist/canvas/utils/NodeUtils.d.ts +5 -1
- package/dist/canvas/utils/NodeUtils.d.ts.map +1 -1
- package/dist/canvas/utils/NodeUtils.js +15 -3
- package/dist/canvas/utils/container.cjs +73 -42
- package/dist/canvas/utils/container.d.ts +17 -4
- package/dist/canvas/utils/container.d.ts.map +1 -1
- package/dist/canvas/utils/container.js +69 -41
- package/dist/canvas/utils/createPreviewGraph.cjs +14 -2
- package/dist/canvas/utils/createPreviewGraph.d.ts +2 -0
- package/dist/canvas/utils/createPreviewGraph.d.ts.map +1 -1
- package/dist/canvas/utils/createPreviewGraph.js +14 -2
- package/dist/canvas/utils/createPreviewNode.cjs +8 -5
- package/dist/canvas/utils/createPreviewNode.d.ts +21 -7
- package/dist/canvas/utils/createPreviewNode.d.ts.map +1 -1
- package/dist/canvas/utils/createPreviewNode.js +8 -5
- package/package.json +3 -3
|
@@ -25,12 +25,13 @@ var __webpack_exports__ = {};
|
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
27
|
CONTAINER_SEQUENCE_GAP_PX: ()=>CONTAINER_SEQUENCE_GAP_PX,
|
|
28
|
-
|
|
28
|
+
collectLinearDownstreamSiblings: ()=>collectLinearDownstreamSiblings,
|
|
29
29
|
DEFAULT_CONTAINER_HEIGHT: ()=>DEFAULT_CONTAINER_HEIGHT,
|
|
30
30
|
getContainerSafeArea: ()=>container_getContainerSafeArea,
|
|
31
|
+
DEFAULT_CONTAINER_WIDTH: ()=>DEFAULT_CONTAINER_WIDTH,
|
|
31
32
|
isContainerNodeManifest: ()=>isContainerNodeManifest,
|
|
32
|
-
placeContainerNode: ()=>placeContainerNode,
|
|
33
33
|
DEFAULT_CONTAINER_MIN_HEIGHT: ()=>DEFAULT_CONTAINER_MIN_HEIGHT,
|
|
34
|
+
placeContainerNode: ()=>placeContainerNode,
|
|
34
35
|
getContainerNodeForEdge: ()=>getContainerNodeForEdge,
|
|
35
36
|
resolveContainerPreview: ()=>resolveContainerPreview,
|
|
36
37
|
getContainerFitGeometry: ()=>container_getContainerFitGeometry,
|
|
@@ -204,10 +205,12 @@ function clampTopToSafeArea(top, safeArea, nodeSize) {
|
|
|
204
205
|
function rangesOverlap(startA, endA, startB, endB) {
|
|
205
206
|
return startA < endB && endA > startB;
|
|
206
207
|
}
|
|
207
|
-
function
|
|
208
|
+
function centerOnContainerRail(containerSize, safeArea, nodeSize) {
|
|
209
|
+
const railY = (0, external_NodeUtils_cjs_namespaceObject.snapToGrid)(containerSize.height / 2 - nodeSize.height / 2);
|
|
210
|
+
const maxY = safeArea.y + Math.max(0, safeArea.height - nodeSize.height);
|
|
208
211
|
return {
|
|
209
212
|
x: Math.max(safeArea.x, (0, external_NodeUtils_cjs_namespaceObject.snapToGrid)(safeArea.x + (safeArea.width - nodeSize.width) / 2)),
|
|
210
|
-
y:
|
|
213
|
+
y: (0, external_NodeUtils_cjs_namespaceObject.clamp)(railY, safeArea.y, maxY)
|
|
211
214
|
};
|
|
212
215
|
}
|
|
213
216
|
function getLocalNodePosition(node, containerNode, nodes) {
|
|
@@ -273,43 +276,54 @@ function getSingleOutgoingEdge(sourceNodeId, sourceHandleId, edges) {
|
|
|
273
276
|
function isPreviewGraphEdge(edge) {
|
|
274
277
|
return edge.source === external_constants_cjs_namespaceObject.PREVIEW_NODE_ID || edge.target === external_constants_cjs_namespaceObject.PREVIEW_NODE_ID;
|
|
275
278
|
}
|
|
276
|
-
function
|
|
277
|
-
const
|
|
278
|
-
|
|
279
|
-
if (
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
279
|
+
function bucketInScopeEdgesBySource({ edges, nodesById, parentId, isSequenceEdge }) {
|
|
280
|
+
const bySource = new Map();
|
|
281
|
+
for (const edge of edges){
|
|
282
|
+
if (isPreviewGraphEdge(edge)) continue;
|
|
283
|
+
if (isSequenceEdge && !isSequenceEdge(edge)) continue;
|
|
284
|
+
const targetIsParent = void 0 !== parentId && edge.target === parentId;
|
|
285
|
+
const targetIsSibling = nodesById.get(edge.target)?.parentId === parentId;
|
|
286
|
+
if (!targetIsParent && !targetIsSibling) continue;
|
|
287
|
+
const bucket = bySource.get(edge.source);
|
|
288
|
+
if (bucket) bucket.push(edge);
|
|
289
|
+
else bySource.set(edge.source, [
|
|
290
|
+
edge
|
|
291
|
+
]);
|
|
292
|
+
}
|
|
293
|
+
return bySource;
|
|
284
294
|
}
|
|
285
|
-
function
|
|
286
|
-
if (!
|
|
295
|
+
function collectLinearDownstreamSiblings({ startNodeId, parentId, nodes, edges, isSequenceEdge, getNextNodeId }) {
|
|
296
|
+
if (!startNodeId || startNodeId === parentId) return [];
|
|
287
297
|
const nodesById = new Map(nodes.map((node)=>[
|
|
288
298
|
node.id,
|
|
289
299
|
node
|
|
290
300
|
]));
|
|
301
|
+
const inScopeEdgesBySource = bucketInScopeEdgesBySource({
|
|
302
|
+
edges,
|
|
303
|
+
nodesById,
|
|
304
|
+
parentId,
|
|
305
|
+
isSequenceEdge
|
|
306
|
+
});
|
|
291
307
|
const collectedIds = [];
|
|
292
308
|
const visitedIds = new Set();
|
|
293
|
-
let currentNodeId =
|
|
309
|
+
let currentNodeId = startNodeId;
|
|
294
310
|
while(!visitedIds.has(currentNodeId)){
|
|
295
311
|
const currentNode = nodesById.get(currentNodeId);
|
|
296
|
-
if (!currentNode || currentNode.parentId !==
|
|
312
|
+
if (!currentNode || currentNode.parentId !== parentId) break;
|
|
297
313
|
collectedIds.push(currentNodeId);
|
|
298
314
|
visitedIds.add(currentNodeId);
|
|
299
|
-
|
|
315
|
+
let next = getNextNodeId ? getNextNodeId({
|
|
300
316
|
nodeId: currentNodeId,
|
|
301
317
|
edges,
|
|
302
318
|
nodesById,
|
|
303
|
-
|
|
304
|
-
})
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
if (!nextNodeId || nextNodeId === containerId) break;
|
|
312
|
-
currentNodeId = nextNodeId;
|
|
319
|
+
parentId
|
|
320
|
+
}) : void 0;
|
|
321
|
+
if (void 0 === next) {
|
|
322
|
+
const outgoing = inScopeEdgesBySource.get(currentNodeId) ?? [];
|
|
323
|
+
next = 1 === outgoing.length ? outgoing[0].target : null;
|
|
324
|
+
}
|
|
325
|
+
if (!next || next === parentId) break;
|
|
326
|
+
currentNodeId = next;
|
|
313
327
|
}
|
|
314
328
|
return collectedIds;
|
|
315
329
|
}
|
|
@@ -491,26 +505,37 @@ function pushSiblingsAfterContainerGrowth({ nodes, changes, getNodeDimensions, g
|
|
|
491
505
|
let nextNodes = nodes;
|
|
492
506
|
for (const change of sortContainerSizeChanges(changes, nextNodes)){
|
|
493
507
|
const widthDelta = change.nextSize.width - change.previousSize.width;
|
|
494
|
-
|
|
508
|
+
const heightDelta = change.nextSize.height - change.previousSize.height;
|
|
509
|
+
if (widthDelta <= 0 && heightDelta <= 0) continue;
|
|
495
510
|
const containerNode = nextNodes.find((node)=>node.id === change.containerId);
|
|
496
511
|
const oldRight = containerNode.position.x + change.previousSize.width;
|
|
497
512
|
const newRight = containerNode.position.x + change.nextSize.width;
|
|
513
|
+
const oldBottom = containerNode.position.y + change.previousSize.height;
|
|
514
|
+
const newBottom = containerNode.position.y + change.nextSize.height;
|
|
515
|
+
const containerLeft = containerNode.position.x;
|
|
516
|
+
const containerRight = containerNode.position.x + Math.max(change.previousSize.width, change.nextSize.width);
|
|
498
517
|
const containerTop = containerNode.position.y;
|
|
499
518
|
const containerBottom = containerNode.position.y + Math.max(change.previousSize.height, change.nextSize.height);
|
|
500
519
|
nextNodes = nextNodes.map((node)=>{
|
|
501
520
|
if (node.id === containerNode.id || node.parentId !== containerNode.parentId) return node;
|
|
502
521
|
const nodeSize = getNodeDimensions(node);
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
if (
|
|
506
|
-
|
|
507
|
-
|
|
522
|
+
let nextX = node.position.x;
|
|
523
|
+
let nextY = node.position.y;
|
|
524
|
+
if (widthDelta > 0 && node.position.x >= oldRight) {
|
|
525
|
+
const verticallyOverlaps = rangesOverlap(node.position.y, node.position.y + nodeSize.height, containerTop, containerBottom);
|
|
526
|
+
if (verticallyOverlaps) nextX = Math.max(node.position.x + widthDelta, (0, external_NodeUtils_cjs_namespaceObject.snapUpToGrid)(newRight + gap));
|
|
527
|
+
}
|
|
528
|
+
if (heightDelta > 0 && node.position.y >= oldBottom) {
|
|
529
|
+
const horizontallyOverlaps = rangesOverlap(node.position.x, node.position.x + nodeSize.width, containerLeft, containerRight);
|
|
530
|
+
if (horizontallyOverlaps) nextY = Math.max(node.position.y + heightDelta, (0, external_NodeUtils_cjs_namespaceObject.snapUpToGrid)(newBottom + gap));
|
|
531
|
+
}
|
|
532
|
+
if (nextX === node.position.x && nextY === node.position.y) return node;
|
|
508
533
|
shifted = true;
|
|
509
534
|
return {
|
|
510
535
|
...node,
|
|
511
536
|
position: {
|
|
512
|
-
|
|
513
|
-
|
|
537
|
+
x: nextX,
|
|
538
|
+
y: nextY
|
|
514
539
|
}
|
|
515
540
|
};
|
|
516
541
|
});
|
|
@@ -542,11 +567,11 @@ function fitContainersAndPushSiblings({ nodes, containerIds, getContainerFitGeom
|
|
|
542
567
|
}
|
|
543
568
|
return nextNodes;
|
|
544
569
|
}
|
|
545
|
-
function getContainerPlacement(
|
|
570
|
+
function getContainerPlacement(previewNode) {
|
|
546
571
|
const placement = previewNode.data?.[PLACEMENT_DATA_KEY];
|
|
547
572
|
if (!placement) return null;
|
|
548
573
|
if (previewNode.parentId && placement.containerId !== previewNode.parentId) return null;
|
|
549
|
-
return
|
|
574
|
+
return placement;
|
|
550
575
|
}
|
|
551
576
|
function placeContainerNode({ nodes, insertedNode, placement, safeArea, getContainerFitGeometry: resolveContainerFitGeometry = container_getContainerFitGeometry, getNodeDimensions: resolveNodeDimensions = container_getNodeDimensions, gap = CONTAINER_SEQUENCE_GAP_PX, downstreamNodeIds, edges }) {
|
|
552
577
|
const containerNode = nodes.find((node)=>node.id === placement.containerId);
|
|
@@ -558,7 +583,7 @@ function placeContainerNode({ nodes, insertedNode, placement, safeArea, getConta
|
|
|
558
583
|
const resolvedSafeArea = getSafeArea(containerNode, safeArea);
|
|
559
584
|
const positionedNode = 'first-child' === placement.mode ? {
|
|
560
585
|
...insertedNode,
|
|
561
|
-
position:
|
|
586
|
+
position: centerOnContainerRail(resolveNodeDimensions(containerNode), resolvedSafeArea, insertedSize)
|
|
562
587
|
} : {
|
|
563
588
|
...insertedNode,
|
|
564
589
|
position: getInsertedPosition({
|
|
@@ -577,14 +602,18 @@ function placeContainerNode({ nodes, insertedNode, placement, safeArea, getConta
|
|
|
577
602
|
const fallbackTargetIds = placement.targetNodeId && placement.targetNodeId !== placement.containerId ? [
|
|
578
603
|
placement.targetNodeId
|
|
579
604
|
] : [];
|
|
580
|
-
const idsToShift = new Set(downstreamNodeIds ?? (edges ?
|
|
581
|
-
|
|
582
|
-
|
|
605
|
+
const idsToShift = new Set(downstreamNodeIds ?? (edges ? collectLinearDownstreamSiblings({
|
|
606
|
+
startNodeId: placement.targetNodeId,
|
|
607
|
+
parentId: placement.containerId,
|
|
583
608
|
nodes,
|
|
584
609
|
edges
|
|
585
610
|
}) : fallbackTargetIds));
|
|
611
|
+
if (placement.sourceNodeId) idsToShift.delete(placement.sourceNodeId);
|
|
612
|
+
const sourceNode = placement.sourceNodeId ? nodesById.get(placement.sourceNodeId) : void 0;
|
|
613
|
+
const sourceIsContainer = placement.sourceNodeId === placement.containerId;
|
|
614
|
+
const isBackEdge = !sourceIsContainer && void 0 !== sourceNode && void 0 !== targetNode && sourceNode.position.x >= targetNode.position.x;
|
|
586
615
|
const requiredTargetLeft = positionedNode.position.x + insertedSize.width + gap;
|
|
587
|
-
const downstreamShift = targetNode && targetNode.position.x < requiredTargetLeft ? (0, external_NodeUtils_cjs_namespaceObject.snapUpToGrid)(requiredTargetLeft - targetNode.position.x) : 0;
|
|
616
|
+
const downstreamShift = !isBackEdge && targetNode && targetNode.position.x < requiredTargetLeft ? (0, external_NodeUtils_cjs_namespaceObject.snapUpToGrid)(requiredTargetLeft - targetNode.position.x) : 0;
|
|
588
617
|
const positionedNodes = nodes.map((node)=>{
|
|
589
618
|
if (node.id === insertedNode.id) return positionedNode;
|
|
590
619
|
if (downstreamShift > 0 && idsToShift.has(node.id)) return {
|
|
@@ -612,6 +641,7 @@ exports.DEFAULT_CONTAINER_HEIGHT = __webpack_exports__.DEFAULT_CONTAINER_HEIGHT;
|
|
|
612
641
|
exports.DEFAULT_CONTAINER_MIN_HEIGHT = __webpack_exports__.DEFAULT_CONTAINER_MIN_HEIGHT;
|
|
613
642
|
exports.DEFAULT_CONTAINER_MIN_WIDTH = __webpack_exports__.DEFAULT_CONTAINER_MIN_WIDTH;
|
|
614
643
|
exports.DEFAULT_CONTAINER_WIDTH = __webpack_exports__.DEFAULT_CONTAINER_WIDTH;
|
|
644
|
+
exports.collectLinearDownstreamSiblings = __webpack_exports__.collectLinearDownstreamSiblings;
|
|
615
645
|
exports.ensureContainersFitChildren = __webpack_exports__.ensureContainersFitChildren;
|
|
616
646
|
exports.getContainerFitGeometry = __webpack_exports__.getContainerFitGeometry;
|
|
617
647
|
exports.getContainerNodeForEdge = __webpack_exports__.getContainerNodeForEdge;
|
|
@@ -628,6 +658,7 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
|
628
658
|
"DEFAULT_CONTAINER_MIN_HEIGHT",
|
|
629
659
|
"DEFAULT_CONTAINER_MIN_WIDTH",
|
|
630
660
|
"DEFAULT_CONTAINER_WIDTH",
|
|
661
|
+
"collectLinearDownstreamSiblings",
|
|
631
662
|
"ensureContainersFitChildren",
|
|
632
663
|
"getContainerFitGeometry",
|
|
633
664
|
"getContainerNodeForEdge",
|
|
@@ -59,6 +59,14 @@ interface ContainerPreviewOptions {
|
|
|
59
59
|
avoidSiblings?: boolean;
|
|
60
60
|
getNodeDimensions?: (node: Node) => NodeDimensions;
|
|
61
61
|
}
|
|
62
|
+
type SequenceEdgePredicate = (edge: Edge) => boolean;
|
|
63
|
+
interface NextNodeContext {
|
|
64
|
+
nodeId: string;
|
|
65
|
+
edges: Edge[];
|
|
66
|
+
nodesById: Map<string, Node>;
|
|
67
|
+
parentId: string | undefined;
|
|
68
|
+
}
|
|
69
|
+
type NextNodeResolver = (context: NextNodeContext) => string | null | undefined;
|
|
62
70
|
export declare const DEFAULT_CONTAINER_WIDTH: number;
|
|
63
71
|
export declare const DEFAULT_CONTAINER_HEIGHT: number;
|
|
64
72
|
export declare const DEFAULT_CONTAINER_MIN_WIDTH: number;
|
|
@@ -77,11 +85,16 @@ export declare function ensureContainersFitChildren(nodes: Node[], { containerId
|
|
|
77
85
|
includeAncestors?: boolean;
|
|
78
86
|
}): EnsureContainersFitChildrenResult;
|
|
79
87
|
export declare function getContainerNodeForEdge(sourceNode: Node, targetNode: Node, nodes: Node[]): Node | null;
|
|
88
|
+
export declare function collectLinearDownstreamSiblings({ startNodeId, parentId, nodes, edges, isSequenceEdge, getNextNodeId, }: {
|
|
89
|
+
startNodeId: string | undefined;
|
|
90
|
+
parentId: string | undefined;
|
|
91
|
+
nodes: Node[];
|
|
92
|
+
edges: Edge[];
|
|
93
|
+
isSequenceEdge?: SequenceEdgePredicate;
|
|
94
|
+
getNextNodeId?: NextNodeResolver;
|
|
95
|
+
}): string[];
|
|
80
96
|
export declare function resolveContainerPreview({ source, sourceHandleType, reactFlowInstance, ...options }: ContainerPreviewContext & ContainerPreviewOptions): PreviewGraphOverrides | null;
|
|
81
|
-
export declare function getContainerPlacement(
|
|
82
|
-
previewNode: Pick<Node, 'data' | 'parentId'>;
|
|
83
|
-
isContainerId?: (containerId: string) => boolean;
|
|
84
|
-
}): ContainerPlacement | null;
|
|
97
|
+
export declare function getContainerPlacement(previewNode: Pick<Node, 'data' | 'parentId'>): ContainerPlacement | null;
|
|
85
98
|
export declare function placeContainerNode({ nodes, insertedNode, placement, safeArea, getContainerFitGeometry: resolveContainerFitGeometry, getNodeDimensions: resolveNodeDimensions, gap, downstreamNodeIds, edges, }: {
|
|
86
99
|
nodes: Node[];
|
|
87
100
|
insertedNode: Node;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../../src/canvas/utils/container.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACJ,IAAI,EACJ,iBAAiB,EAElB,MAAM,0CAA0C,CAAC;AAOlD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAanF,MAAM,WAAW,cAAc;IAC7B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T,QAAQ,EACR,uBAAuB,EAAE,2BAAqD,EAC9E,iBAAiB,EAAE,qBAAyC,EAC5D,GAA+B,EAC/B,iBAAiB,EACjB,KAAK,GACN,EAAE;IACD,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,YAAY,EAAE,IAAI,CAAC;IACnB,SAAS,EAAE,kBAAkB,CAAC;IAC9B,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B,uBAAuB,CAAC,EAAE,CAAC,aAAa,EAAE,IAAI,KAAK,oBAAoB,GAAG,IAAI,GAAG,SAAS,CAAC;IAC3F,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,cAAc,CAAC;IACnD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,iBAAiB,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IACrC,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;CAChB,GAAG,IAAI,EAAE,CA8FT"}
|
|
@@ -162,10 +162,12 @@ function clampTopToSafeArea(top, safeArea, nodeSize) {
|
|
|
162
162
|
function rangesOverlap(startA, endA, startB, endB) {
|
|
163
163
|
return startA < endB && endA > startB;
|
|
164
164
|
}
|
|
165
|
-
function
|
|
165
|
+
function centerOnContainerRail(containerSize, safeArea, nodeSize) {
|
|
166
|
+
const railY = snapToGrid(containerSize.height / 2 - nodeSize.height / 2);
|
|
167
|
+
const maxY = safeArea.y + Math.max(0, safeArea.height - nodeSize.height);
|
|
166
168
|
return {
|
|
167
169
|
x: Math.max(safeArea.x, snapToGrid(safeArea.x + (safeArea.width - nodeSize.width) / 2)),
|
|
168
|
-
y:
|
|
170
|
+
y: clamp(railY, safeArea.y, maxY)
|
|
169
171
|
};
|
|
170
172
|
}
|
|
171
173
|
function getLocalNodePosition(node, containerNode, nodes) {
|
|
@@ -231,43 +233,54 @@ function getSingleOutgoingEdge(sourceNodeId, sourceHandleId, edges) {
|
|
|
231
233
|
function isPreviewGraphEdge(edge) {
|
|
232
234
|
return edge.source === PREVIEW_NODE_ID || edge.target === PREVIEW_NODE_ID;
|
|
233
235
|
}
|
|
234
|
-
function
|
|
235
|
-
const
|
|
236
|
-
|
|
237
|
-
if (
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
236
|
+
function bucketInScopeEdgesBySource({ edges, nodesById, parentId, isSequenceEdge }) {
|
|
237
|
+
const bySource = new Map();
|
|
238
|
+
for (const edge of edges){
|
|
239
|
+
if (isPreviewGraphEdge(edge)) continue;
|
|
240
|
+
if (isSequenceEdge && !isSequenceEdge(edge)) continue;
|
|
241
|
+
const targetIsParent = void 0 !== parentId && edge.target === parentId;
|
|
242
|
+
const targetIsSibling = nodesById.get(edge.target)?.parentId === parentId;
|
|
243
|
+
if (!targetIsParent && !targetIsSibling) continue;
|
|
244
|
+
const bucket = bySource.get(edge.source);
|
|
245
|
+
if (bucket) bucket.push(edge);
|
|
246
|
+
else bySource.set(edge.source, [
|
|
247
|
+
edge
|
|
248
|
+
]);
|
|
249
|
+
}
|
|
250
|
+
return bySource;
|
|
242
251
|
}
|
|
243
|
-
function
|
|
244
|
-
if (!
|
|
252
|
+
function collectLinearDownstreamSiblings({ startNodeId, parentId, nodes, edges, isSequenceEdge, getNextNodeId }) {
|
|
253
|
+
if (!startNodeId || startNodeId === parentId) return [];
|
|
245
254
|
const nodesById = new Map(nodes.map((node)=>[
|
|
246
255
|
node.id,
|
|
247
256
|
node
|
|
248
257
|
]));
|
|
258
|
+
const inScopeEdgesBySource = bucketInScopeEdgesBySource({
|
|
259
|
+
edges,
|
|
260
|
+
nodesById,
|
|
261
|
+
parentId,
|
|
262
|
+
isSequenceEdge
|
|
263
|
+
});
|
|
249
264
|
const collectedIds = [];
|
|
250
265
|
const visitedIds = new Set();
|
|
251
|
-
let currentNodeId =
|
|
266
|
+
let currentNodeId = startNodeId;
|
|
252
267
|
while(!visitedIds.has(currentNodeId)){
|
|
253
268
|
const currentNode = nodesById.get(currentNodeId);
|
|
254
|
-
if (!currentNode || currentNode.parentId !==
|
|
269
|
+
if (!currentNode || currentNode.parentId !== parentId) break;
|
|
255
270
|
collectedIds.push(currentNodeId);
|
|
256
271
|
visitedIds.add(currentNodeId);
|
|
257
|
-
|
|
272
|
+
let next = getNextNodeId ? getNextNodeId({
|
|
258
273
|
nodeId: currentNodeId,
|
|
259
274
|
edges,
|
|
260
275
|
nodesById,
|
|
261
|
-
|
|
262
|
-
})
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
if (!nextNodeId || nextNodeId === containerId) break;
|
|
270
|
-
currentNodeId = nextNodeId;
|
|
276
|
+
parentId
|
|
277
|
+
}) : void 0;
|
|
278
|
+
if (void 0 === next) {
|
|
279
|
+
const outgoing = inScopeEdgesBySource.get(currentNodeId) ?? [];
|
|
280
|
+
next = 1 === outgoing.length ? outgoing[0].target : null;
|
|
281
|
+
}
|
|
282
|
+
if (!next || next === parentId) break;
|
|
283
|
+
currentNodeId = next;
|
|
271
284
|
}
|
|
272
285
|
return collectedIds;
|
|
273
286
|
}
|
|
@@ -449,26 +462,37 @@ function pushSiblingsAfterContainerGrowth({ nodes, changes, getNodeDimensions, g
|
|
|
449
462
|
let nextNodes = nodes;
|
|
450
463
|
for (const change of sortContainerSizeChanges(changes, nextNodes)){
|
|
451
464
|
const widthDelta = change.nextSize.width - change.previousSize.width;
|
|
452
|
-
|
|
465
|
+
const heightDelta = change.nextSize.height - change.previousSize.height;
|
|
466
|
+
if (widthDelta <= 0 && heightDelta <= 0) continue;
|
|
453
467
|
const containerNode = nextNodes.find((node)=>node.id === change.containerId);
|
|
454
468
|
const oldRight = containerNode.position.x + change.previousSize.width;
|
|
455
469
|
const newRight = containerNode.position.x + change.nextSize.width;
|
|
470
|
+
const oldBottom = containerNode.position.y + change.previousSize.height;
|
|
471
|
+
const newBottom = containerNode.position.y + change.nextSize.height;
|
|
472
|
+
const containerLeft = containerNode.position.x;
|
|
473
|
+
const containerRight = containerNode.position.x + Math.max(change.previousSize.width, change.nextSize.width);
|
|
456
474
|
const containerTop = containerNode.position.y;
|
|
457
475
|
const containerBottom = containerNode.position.y + Math.max(change.previousSize.height, change.nextSize.height);
|
|
458
476
|
nextNodes = nextNodes.map((node)=>{
|
|
459
477
|
if (node.id === containerNode.id || node.parentId !== containerNode.parentId) return node;
|
|
460
478
|
const nodeSize = getNodeDimensions(node);
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
if (
|
|
464
|
-
|
|
465
|
-
|
|
479
|
+
let nextX = node.position.x;
|
|
480
|
+
let nextY = node.position.y;
|
|
481
|
+
if (widthDelta > 0 && node.position.x >= oldRight) {
|
|
482
|
+
const verticallyOverlaps = rangesOverlap(node.position.y, node.position.y + nodeSize.height, containerTop, containerBottom);
|
|
483
|
+
if (verticallyOverlaps) nextX = Math.max(node.position.x + widthDelta, snapUpToGrid(newRight + gap));
|
|
484
|
+
}
|
|
485
|
+
if (heightDelta > 0 && node.position.y >= oldBottom) {
|
|
486
|
+
const horizontallyOverlaps = rangesOverlap(node.position.x, node.position.x + nodeSize.width, containerLeft, containerRight);
|
|
487
|
+
if (horizontallyOverlaps) nextY = Math.max(node.position.y + heightDelta, snapUpToGrid(newBottom + gap));
|
|
488
|
+
}
|
|
489
|
+
if (nextX === node.position.x && nextY === node.position.y) return node;
|
|
466
490
|
shifted = true;
|
|
467
491
|
return {
|
|
468
492
|
...node,
|
|
469
493
|
position: {
|
|
470
|
-
|
|
471
|
-
|
|
494
|
+
x: nextX,
|
|
495
|
+
y: nextY
|
|
472
496
|
}
|
|
473
497
|
};
|
|
474
498
|
});
|
|
@@ -500,11 +524,11 @@ function fitContainersAndPushSiblings({ nodes, containerIds, getContainerFitGeom
|
|
|
500
524
|
}
|
|
501
525
|
return nextNodes;
|
|
502
526
|
}
|
|
503
|
-
function getContainerPlacement(
|
|
527
|
+
function getContainerPlacement(previewNode) {
|
|
504
528
|
const placement = previewNode.data?.[PLACEMENT_DATA_KEY];
|
|
505
529
|
if (!placement) return null;
|
|
506
530
|
if (previewNode.parentId && placement.containerId !== previewNode.parentId) return null;
|
|
507
|
-
return
|
|
531
|
+
return placement;
|
|
508
532
|
}
|
|
509
533
|
function placeContainerNode({ nodes, insertedNode, placement, safeArea, getContainerFitGeometry: resolveContainerFitGeometry = container_getContainerFitGeometry, getNodeDimensions: resolveNodeDimensions = container_getNodeDimensions, gap = CONTAINER_SEQUENCE_GAP_PX, downstreamNodeIds, edges }) {
|
|
510
534
|
const containerNode = nodes.find((node)=>node.id === placement.containerId);
|
|
@@ -516,7 +540,7 @@ function placeContainerNode({ nodes, insertedNode, placement, safeArea, getConta
|
|
|
516
540
|
const resolvedSafeArea = getSafeArea(containerNode, safeArea);
|
|
517
541
|
const positionedNode = 'first-child' === placement.mode ? {
|
|
518
542
|
...insertedNode,
|
|
519
|
-
position:
|
|
543
|
+
position: centerOnContainerRail(resolveNodeDimensions(containerNode), resolvedSafeArea, insertedSize)
|
|
520
544
|
} : {
|
|
521
545
|
...insertedNode,
|
|
522
546
|
position: getInsertedPosition({
|
|
@@ -535,14 +559,18 @@ function placeContainerNode({ nodes, insertedNode, placement, safeArea, getConta
|
|
|
535
559
|
const fallbackTargetIds = placement.targetNodeId && placement.targetNodeId !== placement.containerId ? [
|
|
536
560
|
placement.targetNodeId
|
|
537
561
|
] : [];
|
|
538
|
-
const idsToShift = new Set(downstreamNodeIds ?? (edges ?
|
|
539
|
-
|
|
540
|
-
|
|
562
|
+
const idsToShift = new Set(downstreamNodeIds ?? (edges ? collectLinearDownstreamSiblings({
|
|
563
|
+
startNodeId: placement.targetNodeId,
|
|
564
|
+
parentId: placement.containerId,
|
|
541
565
|
nodes,
|
|
542
566
|
edges
|
|
543
567
|
}) : fallbackTargetIds));
|
|
568
|
+
if (placement.sourceNodeId) idsToShift.delete(placement.sourceNodeId);
|
|
569
|
+
const sourceNode = placement.sourceNodeId ? nodesById.get(placement.sourceNodeId) : void 0;
|
|
570
|
+
const sourceIsContainer = placement.sourceNodeId === placement.containerId;
|
|
571
|
+
const isBackEdge = !sourceIsContainer && void 0 !== sourceNode && void 0 !== targetNode && sourceNode.position.x >= targetNode.position.x;
|
|
544
572
|
const requiredTargetLeft = positionedNode.position.x + insertedSize.width + gap;
|
|
545
|
-
const downstreamShift = targetNode && targetNode.position.x < requiredTargetLeft ? snapUpToGrid(requiredTargetLeft - targetNode.position.x) : 0;
|
|
573
|
+
const downstreamShift = !isBackEdge && targetNode && targetNode.position.x < requiredTargetLeft ? snapUpToGrid(requiredTargetLeft - targetNode.position.x) : 0;
|
|
546
574
|
const positionedNodes = nodes.map((node)=>{
|
|
547
575
|
if (node.id === insertedNode.id) return positionedNode;
|
|
548
576
|
if (downstreamShift > 0 && idsToShift.has(node.id)) return {
|
|
@@ -564,4 +592,4 @@ function placeContainerNode({ nodes, insertedNode, placement, safeArea, getConta
|
|
|
564
592
|
gap
|
|
565
593
|
});
|
|
566
594
|
}
|
|
567
|
-
export { CONTAINER_FRAME_INSET_PX, CONTAINER_SEQUENCE_GAP_PX, DEFAULT_CONTAINER_HEIGHT, DEFAULT_CONTAINER_MIN_HEIGHT, DEFAULT_CONTAINER_MIN_WIDTH, DEFAULT_CONTAINER_WIDTH, ensureContainersFitChildren, container_getContainerFitGeometry as getContainerFitGeometry, getContainerNodeForEdge, getContainerPlacement, container_getContainerSafeArea as getContainerSafeArea, container_getNodeDimensions as getNodeDimensions, isContainerNodeManifest, placeContainerNode, resolveContainerPreview };
|
|
595
|
+
export { CONTAINER_FRAME_INSET_PX, CONTAINER_SEQUENCE_GAP_PX, DEFAULT_CONTAINER_HEIGHT, DEFAULT_CONTAINER_MIN_HEIGHT, DEFAULT_CONTAINER_MIN_WIDTH, DEFAULT_CONTAINER_WIDTH, collectLinearDownstreamSiblings, ensureContainersFitChildren, container_getContainerFitGeometry as getContainerFitGeometry, getContainerNodeForEdge, getContainerPlacement, container_getContainerSafeArea as getContainerSafeArea, container_getNodeDimensions as getNodeDimensions, isContainerNodeManifest, placeContainerNode, resolveContainerPreview };
|
|
@@ -52,8 +52,20 @@ function reparentPreviewNodeToContainer(previewNode, containerId, reactFlowInsta
|
|
|
52
52
|
extent: 'parent'
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
|
-
function createPreviewNodeForGraph({ source, reactFlowInstance, position, data, sourceHandleType, previewNodeSize, handlePosition, ignoredNodeTypes, positionMode }) {
|
|
56
|
-
return (0, external_createPreviewNode_cjs_namespaceObject.createPreviewNode)(
|
|
55
|
+
function createPreviewNodeForGraph({ source, reactFlowInstance, position, data, sourceHandleType, previewNodeSize, handlePosition, ignoredNodeTypes, positionMode, sourceBoundaryOf }) {
|
|
56
|
+
return (0, external_createPreviewNode_cjs_namespaceObject.createPreviewNode)({
|
|
57
|
+
sourceNodeId: source.nodeId,
|
|
58
|
+
sourceHandleId: source.handleId ?? external_constants_cjs_namespaceObject.DEFAULT_SOURCE_HANDLE_ID,
|
|
59
|
+
reactFlowInstance,
|
|
60
|
+
position,
|
|
61
|
+
data,
|
|
62
|
+
sourceHandleType,
|
|
63
|
+
previewNodeSize,
|
|
64
|
+
handlePosition,
|
|
65
|
+
ignoredNodeTypes,
|
|
66
|
+
positionMode,
|
|
67
|
+
sourceBoundaryOf
|
|
68
|
+
});
|
|
57
69
|
}
|
|
58
70
|
function createTrailingPreviewEdge({ target, trailingEdgeId, trailingEdgeStyle = external_createPreviewNode_cjs_namespaceObject.PREVIEW_EDGE_STYLE }) {
|
|
59
71
|
if (!target) return null;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Edge, Node, Position, ReactFlowInstance } from '../xyflow/react.ts';
|
|
2
2
|
import type { CSSProperties } from 'react';
|
|
3
3
|
import { type PreviewNodePositionMode } from './createPreviewNode';
|
|
4
|
+
import { type HandleBoundaryResolver } from './NodeUtils';
|
|
4
5
|
export interface PreviewGraph {
|
|
5
6
|
node: Node;
|
|
6
7
|
edges: Edge[];
|
|
@@ -29,6 +30,7 @@ export interface CreatePreviewGraphOptions {
|
|
|
29
30
|
containerId?: string;
|
|
30
31
|
trailingEdgeId?: string;
|
|
31
32
|
trailingEdgeStyle?: CSSProperties;
|
|
33
|
+
sourceBoundaryOf?: HandleBoundaryResolver;
|
|
32
34
|
}
|
|
33
35
|
export type PreviewGraphOverrides = Partial<Pick<CreatePreviewGraphOptions, 'containerId' | 'data' | 'position' | 'positionMode' | 'target' | 'trailingEdgeId' | 'trailingEdgeStyle'>>;
|
|
34
36
|
export declare function reparentPreviewNodeToContainer(previewNode: Node, containerId: string, reactFlowInstance: ReactFlowInstance): Node | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createPreviewGraph.d.ts","sourceRoot":"","sources":["../../../src/canvas/utils/createPreviewGraph.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,iBAAiB,EAClB,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,EAIL,KAAK,uBAAuB,EAC7B,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"createPreviewGraph.d.ts","sourceRoot":"","sources":["../../../src/canvas/utils/createPreviewGraph.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,iBAAiB,EAClB,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,EAIL,KAAK,uBAAuB,EAC7B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAuB,KAAK,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAG/E,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,IAAI,CAAC;IACX,KAAK,EAAE,IAAI,EAAE,CAAC;CACf;AAGD,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,M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AA4B,CAC1C,OAAO,EAAE,YAAY,EACrB,iBAAiB,EAAE,iBAAiB,GACnC,IAAI,CAgBN"}
|
|
@@ -21,8 +21,20 @@ function reparentPreviewNodeToContainer(previewNode, containerId, reactFlowInsta
|
|
|
21
21
|
extent: 'parent'
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
-
function createPreviewNodeForGraph({ source, reactFlowInstance, position, data, sourceHandleType, previewNodeSize, handlePosition, ignoredNodeTypes, positionMode }) {
|
|
25
|
-
return createPreviewNode(
|
|
24
|
+
function createPreviewNodeForGraph({ source, reactFlowInstance, position, data, sourceHandleType, previewNodeSize, handlePosition, ignoredNodeTypes, positionMode, sourceBoundaryOf }) {
|
|
25
|
+
return createPreviewNode({
|
|
26
|
+
sourceNodeId: source.nodeId,
|
|
27
|
+
sourceHandleId: source.handleId ?? DEFAULT_SOURCE_HANDLE_ID,
|
|
28
|
+
reactFlowInstance,
|
|
29
|
+
position,
|
|
30
|
+
data,
|
|
31
|
+
sourceHandleType,
|
|
32
|
+
previewNodeSize,
|
|
33
|
+
handlePosition,
|
|
34
|
+
ignoredNodeTypes,
|
|
35
|
+
positionMode,
|
|
36
|
+
sourceBoundaryOf
|
|
37
|
+
});
|
|
26
38
|
}
|
|
27
39
|
function createTrailingPreviewEdge({ target, trailingEdgeId, trailingEdgeStyle = PREVIEW_EDGE_STYLE }) {
|
|
28
40
|
if (!target) return null;
|
|
@@ -160,10 +160,11 @@ function calculateAutoPosition(sourceNode, handlePosition, previewNodeSize, exis
|
|
|
160
160
|
};
|
|
161
161
|
return (0, external_NodeUtils_cjs_namespaceObject.getNonOverlappingPositionForDirection)(nodesWithAbsolutePositions, initialPosition, previewNodeSize, direction, offset, ignoredNodeTypes, overflowDirection);
|
|
162
162
|
}
|
|
163
|
-
function createPreviewNode(
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
163
|
+
function createPreviewNode(options) {
|
|
164
|
+
const { sourceNodeId, sourceHandleId, reactFlowInstance, position, data, sourceHandleType = 'source', previewNodeSize = {
|
|
165
|
+
width: external_constants_cjs_namespaceObject.DEFAULT_NODE_SIZE,
|
|
166
|
+
height: external_constants_cjs_namespaceObject.DEFAULT_NODE_SIZE
|
|
167
|
+
}, handlePosition = react_cjs_namespaceObject.Position.Right, ignoredNodeTypes = [], positionMode = 'drop', sourceBoundaryOf } = options;
|
|
167
168
|
const sourceNode = reactFlowInstance.getNode(sourceNodeId);
|
|
168
169
|
if (!sourceNode) {
|
|
169
170
|
console.warn(`Source node ${sourceNodeId} not found`);
|
|
@@ -172,7 +173,9 @@ function createPreviewNode(sourceNodeId, sourceHandleId, reactFlowInstance, posi
|
|
|
172
173
|
const treatPreviewAsSource = 'target' === sourceHandleType;
|
|
173
174
|
const existingNodes = reactFlowInstance.getNodes().filter((n)=>n.id !== external_constants_cjs_namespaceObject.PREVIEW_NODE_ID);
|
|
174
175
|
const internalNode = void 0 === position ? reactFlowInstance.getInternalNode(sourceNodeId) : void 0;
|
|
175
|
-
const handle = internalNode ? (0, external_NodeUtils_cjs_namespaceObject.resolveHandleContext)(internalNode, sourceHandleId, handlePosition
|
|
176
|
+
const handle = internalNode ? (0, external_NodeUtils_cjs_namespaceObject.resolveHandleContext)(internalNode, sourceHandleId, handlePosition, {
|
|
177
|
+
boundaryOf: sourceBoundaryOf
|
|
178
|
+
}) : void 0;
|
|
176
179
|
const nodePosition = position ? 'center' === positionMode ? calculateCenteredPosition(position, previewNodeSize) : calculatePositionFromDrop(position, handlePosition, previewNodeSize) : calculateAutoPosition(sourceNode, handlePosition, previewNodeSize, existingNodes, void 0, ignoredNodeTypes, handle);
|
|
177
180
|
const handleFacingSource = getOppositePosition(handlePosition);
|
|
178
181
|
const finalData = {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type Edge, type Node, Position, type ReactFlowInstance } from '../xyflow/react.ts';
|
|
2
|
+
import { type HandleBoundaryResolver } from './NodeUtils';
|
|
2
3
|
export type PreviewNodePositionMode = 'drop' | 'center';
|
|
3
4
|
export declare const PREVIEW_EDGE_STYLE: Edge['style'];
|
|
4
5
|
export declare function isPreviewEdge(edge: {
|
|
@@ -7,13 +8,26 @@ export declare function isPreviewEdge(edge: {
|
|
|
7
8
|
target?: string;
|
|
8
9
|
}): boolean;
|
|
9
10
|
export declare function getOppositePosition(position: Position): Position;
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
export interface CreatePreviewNodeOptions {
|
|
12
|
+
sourceNodeId: string;
|
|
13
|
+
sourceHandleId: string;
|
|
14
|
+
reactFlowInstance: ReactFlowInstance;
|
|
15
|
+
position?: {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
};
|
|
19
|
+
data?: Record<string, unknown>;
|
|
20
|
+
sourceHandleType?: 'source' | 'target';
|
|
21
|
+
previewNodeSize?: {
|
|
22
|
+
width: number;
|
|
23
|
+
height: number;
|
|
24
|
+
};
|
|
25
|
+
handlePosition?: Position;
|
|
26
|
+
ignoredNodeTypes?: string[];
|
|
27
|
+
positionMode?: PreviewNodePositionMode;
|
|
28
|
+
sourceBoundaryOf?: HandleBoundaryResolver;
|
|
29
|
+
}
|
|
30
|
+
export declare function createPreviewNode(options: CreatePreviewNodeOptions): {
|
|
17
31
|
node: Node;
|
|
18
32
|
edge: Edge;
|
|
19
33
|
} | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createPreviewNode.d.ts","sourceRoot":"","sources":["../../../src/canvas/utils/createPreviewNode.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,IAAI,EACT,KAAK,IAAI,EACT,QAAQ,EACR,KAAK,iBAAiB,EACvB,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"createPreviewNode.d.ts","sourceRoot":"","sources":["../../../src/canvas/utils/createPreviewNode.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,IAAI,EACT,KA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