@bian-womp/spark-workbench 0.3.66 → 0.3.68
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/lib/cjs/index.cjs +19 -3
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/cjs/src/misc/hooks.d.ts +2 -1
- package/lib/cjs/src/misc/hooks.d.ts.map +1 -1
- package/lib/esm/index.js +19 -3
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/src/misc/hooks.d.ts +2 -1
- package/lib/esm/src/misc/hooks.d.ts.map +1 -1
- package/package.json +4 -4
package/lib/cjs/index.cjs
CHANGED
|
@@ -2542,7 +2542,7 @@ function layoutNode(args, overrides) {
|
|
|
2542
2542
|
};
|
|
2543
2543
|
}
|
|
2544
2544
|
|
|
2545
|
-
function useWorkbenchBridge(wb) {
|
|
2545
|
+
function useWorkbenchBridge(wb, handlesMap) {
|
|
2546
2546
|
const onConnect = React.useCallback((params) => {
|
|
2547
2547
|
if (!params.source || !params.target)
|
|
2548
2548
|
return;
|
|
@@ -2555,11 +2555,27 @@ function useWorkbenchBridge(wb) {
|
|
|
2555
2555
|
e.target.handle === params.targetHandle);
|
|
2556
2556
|
if (exists)
|
|
2557
2557
|
return;
|
|
2558
|
+
// Check if target input handle is a non-array type (typeId doesn't end with [])
|
|
2559
|
+
// If so, remove any existing connections to that handle before connecting
|
|
2560
|
+
const targetHandles = handlesMap?.[params.target];
|
|
2561
|
+
const targetTypeId = targetHandles
|
|
2562
|
+
? sparkGraph.getInputTypeId(targetHandles.inputs, params.targetHandle)
|
|
2563
|
+
: undefined;
|
|
2564
|
+
const isArrayInput = targetTypeId?.endsWith("[]") ?? false;
|
|
2565
|
+
if (!isArrayInput) {
|
|
2566
|
+
// Find existing edges to this input handle
|
|
2567
|
+
const existingEdges = wb.def.edges.filter((e) => e.target.nodeId === params.target &&
|
|
2568
|
+
e.target.handle === params.targetHandle);
|
|
2569
|
+
// Remove existing edges (without committing yet)
|
|
2570
|
+
for (const edge of existingEdges) {
|
|
2571
|
+
wb.disconnect(edge.id, { commit: false });
|
|
2572
|
+
}
|
|
2573
|
+
}
|
|
2558
2574
|
wb.connect({
|
|
2559
2575
|
source: { nodeId: params.source, handle: params.sourceHandle },
|
|
2560
2576
|
target: { nodeId: params.target, handle: params.targetHandle },
|
|
2561
2577
|
}, { commit: true });
|
|
2562
|
-
}, [wb]);
|
|
2578
|
+
}, [wb, handlesMap]);
|
|
2563
2579
|
const onNodesChange = React.useCallback((changes) => {
|
|
2564
2580
|
const positions = {};
|
|
2565
2581
|
let commit = false;
|
|
@@ -6001,7 +6017,7 @@ const WorkbenchCanvasComponent = React.forwardRef((props, ref) => {
|
|
|
6001
6017
|
}
|
|
6002
6018
|
},
|
|
6003
6019
|
}), []);
|
|
6004
|
-
const { onConnect, onNodesChange, onEdgesChange, onEdgesDelete, onNodesDelete, } = useWorkbenchBridge(wb);
|
|
6020
|
+
const { onConnect, onNodesChange, onEdgesChange, onEdgesDelete, onNodesDelete, } = useWorkbenchBridge(wb, handlesMap);
|
|
6005
6021
|
const ui = React.useMemo(() => wb.getUI(), [wb, uiVersion]);
|
|
6006
6022
|
const { nodeTypes, resolveNodeType } = React.useMemo(() => {
|
|
6007
6023
|
// Build nodeTypes map using UI extension registry
|