@luxonis/depthai-pipeline-lib 1.16.0 → 1.16.1
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.
|
@@ -18,6 +18,20 @@ const PipelineCanvasBody = ({ pipeline, pipelineState: pipelineStateParsed, head
|
|
|
18
18
|
const [shouldFitAndResize, setShouldFitAndResize] = React.useState(false);
|
|
19
19
|
const [openLegend, setOpenLegend] = React.useState(false);
|
|
20
20
|
const pipelineState = React.useMemo(() => pipelineStateParsed, [pipelineStateParsed]);
|
|
21
|
+
const layoutSignature = React.useMemo(() => {
|
|
22
|
+
if (!pipeline) {
|
|
23
|
+
return '';
|
|
24
|
+
}
|
|
25
|
+
const nodeSignature = pipeline.nodes
|
|
26
|
+
.map((node) => `${node.id}:${node.parentId ?? ''}`)
|
|
27
|
+
.sort()
|
|
28
|
+
.join('|');
|
|
29
|
+
const edgeSignature = pipeline.edges
|
|
30
|
+
.map((edge) => `${edge.id}:${edge.source}:${edge.target}:${edge.sourceHandle ?? ''}:${edge.targetHandle ?? ''}:${edge.type ?? ''}`)
|
|
31
|
+
.sort()
|
|
32
|
+
.join('|');
|
|
33
|
+
return `${nodeSignature}__${edgeSignature}`;
|
|
34
|
+
}, [pipeline]);
|
|
21
35
|
// biome-ignore lint/correctness/useExhaustiveDependencies: Intended
|
|
22
36
|
React.useEffect(() => {
|
|
23
37
|
void fitView();
|
|
@@ -25,34 +39,22 @@ const PipelineCanvasBody = ({ pipeline, pipelineState: pipelineStateParsed, head
|
|
|
25
39
|
}, [reactFlowWidth, reactFlowHeight]);
|
|
26
40
|
const [nodes, setNodes, onNodesChange] = useNodesState([]);
|
|
27
41
|
const [edges, setEdges] = useEdgesState([]);
|
|
42
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: Layout should only rerun when graph structure changes
|
|
28
43
|
React.useEffect(() => {
|
|
29
44
|
if (!autoArrangeRef.current) {
|
|
30
45
|
return;
|
|
31
46
|
}
|
|
32
47
|
const layouted = getLayoutedElements(pipeline?.nodes ?? [], pipeline?.edges ?? []);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const adjustedNodes = adjustNodes([...updatedNodes], layouted.edges);
|
|
36
|
-
setNodes([...adjustedNodes]);
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
const adjustedNodes = adjustNodes([...layouted.nodes], layouted.edges);
|
|
40
|
-
setNodes([...adjustedNodes]);
|
|
41
|
-
}
|
|
48
|
+
const adjustedNodes = adjustNodes([...layouted.nodes], layouted.edges);
|
|
49
|
+
setNodes([...adjustedNodes]);
|
|
42
50
|
setEdges([...layouted.edges]);
|
|
43
51
|
setShouldFitAndResize(true);
|
|
44
|
-
}, [
|
|
52
|
+
}, [layoutSignature, setEdges, setNodes]);
|
|
45
53
|
// biome-ignore lint/correctness/useExhaustiveDependencies: Intended
|
|
46
54
|
React.useEffect(() => {
|
|
47
55
|
if (pipelineState && nodes.length > 0) {
|
|
48
56
|
const updatedNodes = updateNodesOnPipelineStateChange(nodes, pipelineState);
|
|
49
57
|
setNodes([...updatedNodes]);
|
|
50
|
-
if (!autoArrangeRef.current) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
setShouldFitAndResize(true);
|
|
55
|
-
}
|
|
56
58
|
}
|
|
57
59
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
58
60
|
}, [pipelineState]);
|