@bian-womp/spark-workbench 0.2.77 → 0.2.78
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 -49
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/cjs/src/core/InMemoryWorkbench.d.ts +5 -0
- package/lib/cjs/src/core/InMemoryWorkbench.d.ts.map +1 -1
- package/lib/cjs/src/core/contracts.d.ts +4 -0
- package/lib/cjs/src/core/contracts.d.ts.map +1 -1
- package/lib/cjs/src/misc/context/WorkbenchContext.provider.d.ts.map +1 -1
- package/lib/cjs/src/misc/load.d.ts.map +1 -1
- package/lib/esm/index.js +19 -49
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/src/core/InMemoryWorkbench.d.ts +5 -0
- package/lib/esm/src/core/InMemoryWorkbench.d.ts.map +1 -1
- package/lib/esm/src/core/contracts.d.ts +4 -0
- package/lib/esm/src/core/contracts.d.ts.map +1 -1
- package/lib/esm/src/misc/context/WorkbenchContext.provider.d.ts.map +1 -1
- package/lib/esm/src/misc/load.d.ts.map +1 -1
- package/package.json +4 -4
package/lib/cjs/index.cjs
CHANGED
|
@@ -193,6 +193,13 @@ class InMemoryWorkbench extends AbstractWorkbench {
|
|
|
193
193
|
}
|
|
194
194
|
return { ok: issues.every((i) => i.level !== "error"), issues };
|
|
195
195
|
}
|
|
196
|
+
setInputs(nodeId, inputs, options) {
|
|
197
|
+
this.emit("graphChanged", {
|
|
198
|
+
def: this.def,
|
|
199
|
+
change: { type: "setInputs", nodeId, inputs },
|
|
200
|
+
...options,
|
|
201
|
+
});
|
|
202
|
+
}
|
|
196
203
|
addNode(node, options) {
|
|
197
204
|
const id = node.nodeId ??
|
|
198
205
|
this.genId("n", new Set(this.def.nodes.map((n) => n.nodeId)));
|
|
@@ -2532,7 +2539,7 @@ async function upload(parsed, wb, runner) {
|
|
|
2532
2539
|
runner.build(wb.export());
|
|
2533
2540
|
if (inputs && typeof inputs === "object") {
|
|
2534
2541
|
for (const [nodeId, map] of Object.entries(inputs)) {
|
|
2535
|
-
runner.setInputs(nodeId, map);
|
|
2542
|
+
runner.setInputs(nodeId, map, { dry: true });
|
|
2536
2543
|
}
|
|
2537
2544
|
}
|
|
2538
2545
|
}
|
|
@@ -2828,10 +2835,6 @@ function WorkbenchProvider({ wb, runner, registry, setRegistry, overrides, uiVer
|
|
|
2828
2835
|
[handle]: now,
|
|
2829
2836
|
},
|
|
2830
2837
|
}));
|
|
2831
|
-
setNodeStatus((s) => ({
|
|
2832
|
-
...s,
|
|
2833
|
-
[nodeId]: { ...s[nodeId], invalidated: true },
|
|
2834
|
-
}));
|
|
2835
2838
|
// Clear validation errors for this input when a valid value is set
|
|
2836
2839
|
setInputValidationErrors((prev) => prev.filter((err) => !(err.nodeId === nodeId && err.handle === handle)));
|
|
2837
2840
|
}
|
|
@@ -2937,30 +2940,6 @@ function WorkbenchProvider({ wb, runner, registry, setRegistry, overrides, uiVer
|
|
|
2937
2940
|
// If resolvedHandles are included in the event, use them directly (more efficient)
|
|
2938
2941
|
if (e?.resolvedHandles && Object.keys(e.resolvedHandles).length > 0) {
|
|
2939
2942
|
applyResolvedHandles(e.resolvedHandles);
|
|
2940
|
-
// Mark nodes whose handles changed as invalid
|
|
2941
|
-
const affectedNodeIds = Object.keys(e.resolvedHandles);
|
|
2942
|
-
if (affectedNodeIds.length > 0) {
|
|
2943
|
-
setNodeStatus((prev) => {
|
|
2944
|
-
const next = { ...prev };
|
|
2945
|
-
for (const id of affectedNodeIds) {
|
|
2946
|
-
const cur = next[id] ?? (next[id] = { activeRuns: 0, activeRunIds: [] });
|
|
2947
|
-
next[id] = { ...cur, invalidated: true };
|
|
2948
|
-
}
|
|
2949
|
-
return next;
|
|
2950
|
-
});
|
|
2951
|
-
}
|
|
2952
|
-
}
|
|
2953
|
-
// For broader invalidations (e.g. registry-changed, graph-updated), mark all nodes invalid
|
|
2954
|
-
if (e?.reason === "registry-changed" || e?.reason === "graph-updated") {
|
|
2955
|
-
setNodeStatus((prev) => {
|
|
2956
|
-
const next = { ...prev };
|
|
2957
|
-
for (const n of def.nodes) {
|
|
2958
|
-
const cur = next[n.nodeId] ??
|
|
2959
|
-
(next[n.nodeId] = { activeRuns: 0, activeRunIds: [] });
|
|
2960
|
-
next[n.nodeId] = { ...cur, invalidated: true };
|
|
2961
|
-
}
|
|
2962
|
-
return next;
|
|
2963
|
-
});
|
|
2964
2943
|
}
|
|
2965
2944
|
return add("runner", "invalidate")(e);
|
|
2966
2945
|
});
|
|
@@ -2993,7 +2972,6 @@ function WorkbenchProvider({ wb, runner, registry, setRegistry, overrides, uiVer
|
|
|
2993
2972
|
? [...currentRunIds, runId]
|
|
2994
2973
|
: currentRunIds,
|
|
2995
2974
|
progress: 0,
|
|
2996
|
-
invalidated: false,
|
|
2997
2975
|
},
|
|
2998
2976
|
};
|
|
2999
2977
|
});
|
|
@@ -3096,16 +3074,6 @@ function WorkbenchProvider({ wb, runner, registry, setRegistry, overrides, uiVer
|
|
|
3096
3074
|
const offWbGraphUiChangedForLog = wb.on("graphUiChanged", add("workbench", "graphUiChanged"));
|
|
3097
3075
|
const offWbValidationChanged = wb.on("validationChanged", add("workbench", "validationChanged"));
|
|
3098
3076
|
// Ensure newly added nodes start as invalidated until first evaluation
|
|
3099
|
-
const offWbAddNode = wb.on("graphChanged", (e) => {
|
|
3100
|
-
const change = e.change;
|
|
3101
|
-
if (change?.type === "addNode" && typeof change.nodeId === "string") {
|
|
3102
|
-
const id = change.nodeId;
|
|
3103
|
-
setNodeStatus((s) => ({
|
|
3104
|
-
...s,
|
|
3105
|
-
[id]: { ...s[id], invalidated: true },
|
|
3106
|
-
}));
|
|
3107
|
-
}
|
|
3108
|
-
});
|
|
3109
3077
|
const offWbGraphChangedForUpdate = wb.on("graphChanged", async (event) => {
|
|
3110
3078
|
// Build detailed reason from change type
|
|
3111
3079
|
let reason = "graph-changed";
|
|
@@ -3130,6 +3098,10 @@ function WorkbenchProvider({ wb, runner, registry, setRegistry, overrides, uiVer
|
|
|
3130
3098
|
reason = "update-edge-type";
|
|
3131
3099
|
}
|
|
3132
3100
|
}
|
|
3101
|
+
if (event.change?.type === "setInputs") {
|
|
3102
|
+
const { nodeId, inputs } = event.change;
|
|
3103
|
+
await runner.setInputs(nodeId, inputs, { dry: event.dry });
|
|
3104
|
+
}
|
|
3133
3105
|
if (!runner.isRunning()) {
|
|
3134
3106
|
if (event.commit) {
|
|
3135
3107
|
await saveUiRuntimeMetadata();
|
|
@@ -3137,9 +3109,8 @@ function WorkbenchProvider({ wb, runner, registry, setRegistry, overrides, uiVer
|
|
|
3137
3109
|
console.error("[WorkbenchContext] Error committing:", err);
|
|
3138
3110
|
return undefined;
|
|
3139
3111
|
});
|
|
3140
|
-
if (history)
|
|
3112
|
+
if (history)
|
|
3141
3113
|
wb.setHistory(history);
|
|
3142
|
-
}
|
|
3143
3114
|
}
|
|
3144
3115
|
return;
|
|
3145
3116
|
}
|
|
@@ -3162,7 +3133,7 @@ function WorkbenchProvider({ wb, runner, registry, setRegistry, overrides, uiVer
|
|
|
3162
3133
|
}
|
|
3163
3134
|
}
|
|
3164
3135
|
}
|
|
3165
|
-
else {
|
|
3136
|
+
else if (event.change?.type !== "setInputs") {
|
|
3166
3137
|
await runner.update(event.def, { dry: event.dry });
|
|
3167
3138
|
}
|
|
3168
3139
|
if (event.commit) {
|
|
@@ -3295,7 +3266,6 @@ function WorkbenchProvider({ wb, runner, registry, setRegistry, overrides, uiVer
|
|
|
3295
3266
|
offWbGraphUiChanged();
|
|
3296
3267
|
offWbValidationChanged();
|
|
3297
3268
|
offWbError();
|
|
3298
|
-
offWbAddNode();
|
|
3299
3269
|
offWbGraphChangedForUpdate();
|
|
3300
3270
|
offWbdSetValidation();
|
|
3301
3271
|
offWbSelectionChanged();
|
|
@@ -5267,7 +5237,7 @@ function WorkbenchStudioCanvas({ setRegistry, autoScroll, onAutoScrollChange, ex
|
|
|
5267
5237
|
catch { }
|
|
5268
5238
|
if (inputs) {
|
|
5269
5239
|
for (const [nodeId, map] of Object.entries(inputs)) {
|
|
5270
|
-
runner.setInputs(nodeId, map);
|
|
5240
|
+
runner.setInputs(nodeId, map, { dry: true });
|
|
5271
5241
|
}
|
|
5272
5242
|
}
|
|
5273
5243
|
};
|
|
@@ -5333,7 +5303,7 @@ function WorkbenchStudioCanvas({ setRegistry, autoScroll, onAutoScrollChange, ex
|
|
|
5333
5303
|
// Set initial inputs if provided
|
|
5334
5304
|
if (inputs) {
|
|
5335
5305
|
for (const [nodeId, map] of Object.entries(inputs)) {
|
|
5336
|
-
runner.setInputs(nodeId, map);
|
|
5306
|
+
runner.setInputs(nodeId, map, { dry: true });
|
|
5337
5307
|
}
|
|
5338
5308
|
}
|
|
5339
5309
|
runAutoLayout();
|
|
@@ -5433,7 +5403,7 @@ function WorkbenchStudioCanvas({ setRegistry, autoScroll, onAutoScrollChange, ex
|
|
|
5433
5403
|
return;
|
|
5434
5404
|
// If raw is undefined, pass it through to delete the input value
|
|
5435
5405
|
if (raw === undefined) {
|
|
5436
|
-
|
|
5406
|
+
wb.setInputs(selectedNodeId, { [handle]: undefined }, { commit: true });
|
|
5437
5407
|
return;
|
|
5438
5408
|
}
|
|
5439
5409
|
const typeId = sparkGraph.getInputTypeId(effectiveHandles.inputs, handle);
|
|
@@ -5512,8 +5482,8 @@ function WorkbenchStudioCanvas({ setRegistry, autoScroll, onAutoScrollChange, ex
|
|
|
5512
5482
|
value = raw;
|
|
5513
5483
|
}
|
|
5514
5484
|
}
|
|
5515
|
-
|
|
5516
|
-
}, [selectedNodeId, def.edges, effectiveHandles,
|
|
5485
|
+
wb.setInputs(selectedNodeId, { [handle]: value }, { commit: true });
|
|
5486
|
+
}, [selectedNodeId, def.edges, effectiveHandles, wb]);
|
|
5517
5487
|
const setInput = React.useMemo(() => {
|
|
5518
5488
|
if (overrides?.setInput) {
|
|
5519
5489
|
return overrides.setInput(baseSetInput, {
|