@bian-womp/spark-workbench 0.2.80 → 0.2.81
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 +46 -1
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/cjs/src/index.d.ts +2 -0
- package/lib/cjs/src/index.d.ts.map +1 -1
- package/lib/cjs/src/misc/load.d.ts.map +1 -1
- package/lib/cjs/src/misc/merge-utils.d.ts +7 -0
- package/lib/cjs/src/misc/merge-utils.d.ts.map +1 -0
- package/lib/cjs/src/misc/types.d.ts +14 -0
- package/lib/cjs/src/misc/types.d.ts.map +1 -0
- package/lib/esm/index.js +46 -2
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/src/index.d.ts +2 -0
- package/lib/esm/src/index.d.ts.map +1 -1
- package/lib/esm/src/misc/load.d.ts.map +1 -1
- package/lib/esm/src/misc/merge-utils.d.ts +7 -0
- package/lib/esm/src/misc/merge-utils.d.ts.map +1 -0
- package/lib/esm/src/misc/types.d.ts +14 -0
- package/lib/esm/src/misc/types.d.ts.map +1 -0
- package/package.json +4 -4
package/lib/cjs/index.cjs
CHANGED
|
@@ -2772,6 +2772,50 @@ async function upload(parsed, wb, runner) {
|
|
|
2772
2772
|
}
|
|
2773
2773
|
}
|
|
2774
2774
|
|
|
2775
|
+
/**
|
|
2776
|
+
* Merge UI state from source into target, remapping node IDs using nodeIdMap.
|
|
2777
|
+
* Preserves target state and adds/updates source state with remapped IDs.
|
|
2778
|
+
*/
|
|
2779
|
+
function mergeUIState(targetUI, sourceUI, nodeIdMap) {
|
|
2780
|
+
const result = {
|
|
2781
|
+
...targetUI,
|
|
2782
|
+
};
|
|
2783
|
+
if (!sourceUI)
|
|
2784
|
+
return result;
|
|
2785
|
+
// Merge positions (already handled by mergeSnapshotData, but included for completeness)
|
|
2786
|
+
if (sourceUI.positions) {
|
|
2787
|
+
result.positions = {
|
|
2788
|
+
...(targetUI?.positions || {}),
|
|
2789
|
+
...Object.fromEntries(Object.entries(sourceUI.positions).map(([oldId, pos]) => [
|
|
2790
|
+
nodeIdMap[oldId] || oldId,
|
|
2791
|
+
pos,
|
|
2792
|
+
])),
|
|
2793
|
+
};
|
|
2794
|
+
}
|
|
2795
|
+
// Merge selection: remap node IDs and edge IDs
|
|
2796
|
+
if (sourceUI.selection) {
|
|
2797
|
+
const remappedNodes = (sourceUI.selection.nodes || [])
|
|
2798
|
+
.map((id) => nodeIdMap[id] || id)
|
|
2799
|
+
.filter((id) => id); // Filter out invalid mappings
|
|
2800
|
+
const remappedEdges = sourceUI.selection.edges || []; // Edge IDs don't need remapping typically
|
|
2801
|
+
result.selection = {
|
|
2802
|
+
nodes: [...(targetUI?.selection?.nodes || []), ...remappedNodes],
|
|
2803
|
+
edges: [...(targetUI?.selection?.edges || []), ...remappedEdges],
|
|
2804
|
+
};
|
|
2805
|
+
}
|
|
2806
|
+
// Merge nodeNames: remap node IDs
|
|
2807
|
+
if (sourceUI.nodeNames) {
|
|
2808
|
+
result.nodeNames = {
|
|
2809
|
+
...(targetUI?.nodeNames || {}),
|
|
2810
|
+
...Object.fromEntries(Object.entries(sourceUI.nodeNames).map(([oldId, name]) => [
|
|
2811
|
+
nodeIdMap[oldId] || oldId,
|
|
2812
|
+
name,
|
|
2813
|
+
])),
|
|
2814
|
+
};
|
|
2815
|
+
}
|
|
2816
|
+
return result;
|
|
2817
|
+
}
|
|
2818
|
+
|
|
2775
2819
|
const WorkbenchContext = React.createContext(null);
|
|
2776
2820
|
function useWorkbenchContext() {
|
|
2777
2821
|
const ctx = React.useContext(WorkbenchContext);
|
|
@@ -4293,7 +4337,7 @@ function DefaultNodeHeader({ id, typeId, title, validation, right, showId, onInv
|
|
|
4293
4337
|
const [editValue, setEditValue] = React.useState("");
|
|
4294
4338
|
const inputRef = React.useRef(null);
|
|
4295
4339
|
// Use getNodeDisplayName if typeId is provided, otherwise use title prop
|
|
4296
|
-
const displayName = typeId ? ctx.getNodeDisplayName(id) :
|
|
4340
|
+
const displayName = typeId ? ctx.getNodeDisplayName(id) : title ?? id;
|
|
4297
4341
|
const effectiveTypeId = typeId ?? title ?? id;
|
|
4298
4342
|
// Get the default display name (without custom name) for comparison
|
|
4299
4343
|
const getDefaultDisplayName = React.useCallback(() => {
|
|
@@ -5871,6 +5915,7 @@ exports.getHandleLayoutY = getHandleLayoutY;
|
|
|
5871
5915
|
exports.getNodeBorderClassNames = getNodeBorderClassNames;
|
|
5872
5916
|
exports.isValidViewport = isValidViewport;
|
|
5873
5917
|
exports.layoutNode = layoutNode;
|
|
5918
|
+
exports.mergeUIState = mergeUIState;
|
|
5874
5919
|
exports.preformatValueForDisplay = preformatValueForDisplay;
|
|
5875
5920
|
exports.prettyHandle = prettyHandle;
|
|
5876
5921
|
exports.resolveOutputDisplay = resolveOutputDisplay;
|