@bian-womp/spark-workbench 0.2.76 → 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 +29 -81
- 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/cjs/src/runtime/IGraphRunner.d.ts +1 -1
- package/lib/cjs/src/runtime/IGraphRunner.d.ts.map +1 -1
- package/lib/cjs/src/runtime/RemoteGraphRunner.d.ts +2 -2
- package/lib/cjs/src/runtime/RemoteGraphRunner.d.ts.map +1 -1
- package/lib/esm/index.js +29 -81
- 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/lib/esm/src/runtime/IGraphRunner.d.ts +1 -1
- package/lib/esm/src/runtime/IGraphRunner.d.ts.map +1 -1
- package/lib/esm/src/runtime/RemoteGraphRunner.d.ts +2 -2
- package/lib/esm/src/runtime/RemoteGraphRunner.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)));
|
|
@@ -1362,7 +1369,7 @@ class RemoteGraphRunner extends AbstractGraphRunner {
|
|
|
1362
1369
|
this.emit("status", { running: true, engine: this.runningKind });
|
|
1363
1370
|
// Re-apply staged inputs using client.setInputs for consistency
|
|
1364
1371
|
for (const [nodeId, map] of Object.entries(this.stagedInputs)) {
|
|
1365
|
-
await
|
|
1372
|
+
await eng.setInputs(nodeId, map).catch(() => {
|
|
1366
1373
|
// Ignore errors during launch - inputs will be set when user calls setInputs
|
|
1367
1374
|
});
|
|
1368
1375
|
}
|
|
@@ -1408,7 +1415,7 @@ class RemoteGraphRunner extends AbstractGraphRunner {
|
|
|
1408
1415
|
this.emit("status", { running: true, engine: this.runningKind });
|
|
1409
1416
|
// Re-apply staged inputs using client.setInputs for consistency
|
|
1410
1417
|
for (const [nodeId, map] of Object.entries(currentInputs)) {
|
|
1411
|
-
await
|
|
1418
|
+
await eng.setInputs(nodeId, map).catch(() => {
|
|
1412
1419
|
// Ignore errors during engine switch - inputs will be set when user calls setInputs
|
|
1413
1420
|
});
|
|
1414
1421
|
}
|
|
@@ -1437,10 +1444,9 @@ class RemoteGraphRunner extends AbstractGraphRunner {
|
|
|
1437
1444
|
this.stagedInputs[nodeId][handle] = value;
|
|
1438
1445
|
}
|
|
1439
1446
|
}
|
|
1440
|
-
// Use transport.request instead of transport.send for consistency
|
|
1441
|
-
const client = await this.ensureClient();
|
|
1442
1447
|
try {
|
|
1443
|
-
await
|
|
1448
|
+
const client = await this.ensureClient();
|
|
1449
|
+
await client.getEngine()?.setInputs(nodeId, inputs, options);
|
|
1444
1450
|
}
|
|
1445
1451
|
catch (err) {
|
|
1446
1452
|
// Emit synthetic events if connection fails
|
|
@@ -1452,36 +1458,15 @@ class RemoteGraphRunner extends AbstractGraphRunner {
|
|
|
1452
1458
|
}
|
|
1453
1459
|
async copyOutputs(fromNodeId, toNodeId, options) {
|
|
1454
1460
|
const client = await this.ensureClient();
|
|
1455
|
-
await client.copyOutputs(fromNodeId, toNodeId, options);
|
|
1461
|
+
await client.getEngine()?.copyOutputs(fromNodeId, toNodeId, options);
|
|
1456
1462
|
}
|
|
1457
|
-
async
|
|
1463
|
+
async triggerExternal(nodeId, event, options) {
|
|
1458
1464
|
const client = await this.ensureClient();
|
|
1459
|
-
|
|
1460
|
-
if (transport && transport.send) {
|
|
1461
|
-
transport.send({
|
|
1462
|
-
seq: Date.now(),
|
|
1463
|
-
ts: Date.now(),
|
|
1464
|
-
message: {
|
|
1465
|
-
type: "SetViewport",
|
|
1466
|
-
payload: { viewport },
|
|
1467
|
-
},
|
|
1468
|
-
});
|
|
1469
|
-
}
|
|
1465
|
+
await client.getEngine()?.triggerExternal(nodeId, event, options);
|
|
1470
1466
|
}
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
this.engine.triggerExternal(nodeId, event, options);
|
|
1475
|
-
}
|
|
1476
|
-
else {
|
|
1477
|
-
this.ensureClient()
|
|
1478
|
-
.then((client) => {
|
|
1479
|
-
client.getEngine().triggerExternal(nodeId, event, options);
|
|
1480
|
-
})
|
|
1481
|
-
.catch(() => {
|
|
1482
|
-
// Silently fail if connection not available
|
|
1483
|
-
});
|
|
1484
|
-
}
|
|
1467
|
+
async setViewport(viewport) {
|
|
1468
|
+
const client = await this.ensureClient();
|
|
1469
|
+
await client.setViewport(viewport);
|
|
1485
1470
|
}
|
|
1486
1471
|
async coerce(from, to, value) {
|
|
1487
1472
|
const client = await this.ensureClient();
|
|
@@ -2554,7 +2539,7 @@ async function upload(parsed, wb, runner) {
|
|
|
2554
2539
|
runner.build(wb.export());
|
|
2555
2540
|
if (inputs && typeof inputs === "object") {
|
|
2556
2541
|
for (const [nodeId, map] of Object.entries(inputs)) {
|
|
2557
|
-
runner.setInputs(nodeId, map);
|
|
2542
|
+
runner.setInputs(nodeId, map, { dry: true });
|
|
2558
2543
|
}
|
|
2559
2544
|
}
|
|
2560
2545
|
}
|
|
@@ -2850,10 +2835,6 @@ function WorkbenchProvider({ wb, runner, registry, setRegistry, overrides, uiVer
|
|
|
2850
2835
|
[handle]: now,
|
|
2851
2836
|
},
|
|
2852
2837
|
}));
|
|
2853
|
-
setNodeStatus((s) => ({
|
|
2854
|
-
...s,
|
|
2855
|
-
[nodeId]: { ...s[nodeId], invalidated: true },
|
|
2856
|
-
}));
|
|
2857
2838
|
// Clear validation errors for this input when a valid value is set
|
|
2858
2839
|
setInputValidationErrors((prev) => prev.filter((err) => !(err.nodeId === nodeId && err.handle === handle)));
|
|
2859
2840
|
}
|
|
@@ -2959,30 +2940,6 @@ function WorkbenchProvider({ wb, runner, registry, setRegistry, overrides, uiVer
|
|
|
2959
2940
|
// If resolvedHandles are included in the event, use them directly (more efficient)
|
|
2960
2941
|
if (e?.resolvedHandles && Object.keys(e.resolvedHandles).length > 0) {
|
|
2961
2942
|
applyResolvedHandles(e.resolvedHandles);
|
|
2962
|
-
// Mark nodes whose handles changed as invalid
|
|
2963
|
-
const affectedNodeIds = Object.keys(e.resolvedHandles);
|
|
2964
|
-
if (affectedNodeIds.length > 0) {
|
|
2965
|
-
setNodeStatus((prev) => {
|
|
2966
|
-
const next = { ...prev };
|
|
2967
|
-
for (const id of affectedNodeIds) {
|
|
2968
|
-
const cur = next[id] ?? (next[id] = { activeRuns: 0, activeRunIds: [] });
|
|
2969
|
-
next[id] = { ...cur, invalidated: true };
|
|
2970
|
-
}
|
|
2971
|
-
return next;
|
|
2972
|
-
});
|
|
2973
|
-
}
|
|
2974
|
-
}
|
|
2975
|
-
// For broader invalidations (e.g. registry-changed, graph-updated), mark all nodes invalid
|
|
2976
|
-
if (e?.reason === "registry-changed" || e?.reason === "graph-updated") {
|
|
2977
|
-
setNodeStatus((prev) => {
|
|
2978
|
-
const next = { ...prev };
|
|
2979
|
-
for (const n of def.nodes) {
|
|
2980
|
-
const cur = next[n.nodeId] ??
|
|
2981
|
-
(next[n.nodeId] = { activeRuns: 0, activeRunIds: [] });
|
|
2982
|
-
next[n.nodeId] = { ...cur, invalidated: true };
|
|
2983
|
-
}
|
|
2984
|
-
return next;
|
|
2985
|
-
});
|
|
2986
2943
|
}
|
|
2987
2944
|
return add("runner", "invalidate")(e);
|
|
2988
2945
|
});
|
|
@@ -3015,7 +2972,6 @@ function WorkbenchProvider({ wb, runner, registry, setRegistry, overrides, uiVer
|
|
|
3015
2972
|
? [...currentRunIds, runId]
|
|
3016
2973
|
: currentRunIds,
|
|
3017
2974
|
progress: 0,
|
|
3018
|
-
invalidated: false,
|
|
3019
2975
|
},
|
|
3020
2976
|
};
|
|
3021
2977
|
});
|
|
@@ -3118,16 +3074,6 @@ function WorkbenchProvider({ wb, runner, registry, setRegistry, overrides, uiVer
|
|
|
3118
3074
|
const offWbGraphUiChangedForLog = wb.on("graphUiChanged", add("workbench", "graphUiChanged"));
|
|
3119
3075
|
const offWbValidationChanged = wb.on("validationChanged", add("workbench", "validationChanged"));
|
|
3120
3076
|
// Ensure newly added nodes start as invalidated until first evaluation
|
|
3121
|
-
const offWbAddNode = wb.on("graphChanged", (e) => {
|
|
3122
|
-
const change = e.change;
|
|
3123
|
-
if (change?.type === "addNode" && typeof change.nodeId === "string") {
|
|
3124
|
-
const id = change.nodeId;
|
|
3125
|
-
setNodeStatus((s) => ({
|
|
3126
|
-
...s,
|
|
3127
|
-
[id]: { ...s[id], invalidated: true },
|
|
3128
|
-
}));
|
|
3129
|
-
}
|
|
3130
|
-
});
|
|
3131
3077
|
const offWbGraphChangedForUpdate = wb.on("graphChanged", async (event) => {
|
|
3132
3078
|
// Build detailed reason from change type
|
|
3133
3079
|
let reason = "graph-changed";
|
|
@@ -3152,6 +3098,10 @@ function WorkbenchProvider({ wb, runner, registry, setRegistry, overrides, uiVer
|
|
|
3152
3098
|
reason = "update-edge-type";
|
|
3153
3099
|
}
|
|
3154
3100
|
}
|
|
3101
|
+
if (event.change?.type === "setInputs") {
|
|
3102
|
+
const { nodeId, inputs } = event.change;
|
|
3103
|
+
await runner.setInputs(nodeId, inputs, { dry: event.dry });
|
|
3104
|
+
}
|
|
3155
3105
|
if (!runner.isRunning()) {
|
|
3156
3106
|
if (event.commit) {
|
|
3157
3107
|
await saveUiRuntimeMetadata();
|
|
@@ -3159,9 +3109,8 @@ function WorkbenchProvider({ wb, runner, registry, setRegistry, overrides, uiVer
|
|
|
3159
3109
|
console.error("[WorkbenchContext] Error committing:", err);
|
|
3160
3110
|
return undefined;
|
|
3161
3111
|
});
|
|
3162
|
-
if (history)
|
|
3112
|
+
if (history)
|
|
3163
3113
|
wb.setHistory(history);
|
|
3164
|
-
}
|
|
3165
3114
|
}
|
|
3166
3115
|
return;
|
|
3167
3116
|
}
|
|
@@ -3184,7 +3133,7 @@ function WorkbenchProvider({ wb, runner, registry, setRegistry, overrides, uiVer
|
|
|
3184
3133
|
}
|
|
3185
3134
|
}
|
|
3186
3135
|
}
|
|
3187
|
-
else {
|
|
3136
|
+
else if (event.change?.type !== "setInputs") {
|
|
3188
3137
|
await runner.update(event.def, { dry: event.dry });
|
|
3189
3138
|
}
|
|
3190
3139
|
if (event.commit) {
|
|
@@ -3317,7 +3266,6 @@ function WorkbenchProvider({ wb, runner, registry, setRegistry, overrides, uiVer
|
|
|
3317
3266
|
offWbGraphUiChanged();
|
|
3318
3267
|
offWbValidationChanged();
|
|
3319
3268
|
offWbError();
|
|
3320
|
-
offWbAddNode();
|
|
3321
3269
|
offWbGraphChangedForUpdate();
|
|
3322
3270
|
offWbdSetValidation();
|
|
3323
3271
|
offWbSelectionChanged();
|
|
@@ -5289,7 +5237,7 @@ function WorkbenchStudioCanvas({ setRegistry, autoScroll, onAutoScrollChange, ex
|
|
|
5289
5237
|
catch { }
|
|
5290
5238
|
if (inputs) {
|
|
5291
5239
|
for (const [nodeId, map] of Object.entries(inputs)) {
|
|
5292
|
-
runner.setInputs(nodeId, map);
|
|
5240
|
+
runner.setInputs(nodeId, map, { dry: true });
|
|
5293
5241
|
}
|
|
5294
5242
|
}
|
|
5295
5243
|
};
|
|
@@ -5355,7 +5303,7 @@ function WorkbenchStudioCanvas({ setRegistry, autoScroll, onAutoScrollChange, ex
|
|
|
5355
5303
|
// Set initial inputs if provided
|
|
5356
5304
|
if (inputs) {
|
|
5357
5305
|
for (const [nodeId, map] of Object.entries(inputs)) {
|
|
5358
|
-
runner.setInputs(nodeId, map);
|
|
5306
|
+
runner.setInputs(nodeId, map, { dry: true });
|
|
5359
5307
|
}
|
|
5360
5308
|
}
|
|
5361
5309
|
runAutoLayout();
|
|
@@ -5455,7 +5403,7 @@ function WorkbenchStudioCanvas({ setRegistry, autoScroll, onAutoScrollChange, ex
|
|
|
5455
5403
|
return;
|
|
5456
5404
|
// If raw is undefined, pass it through to delete the input value
|
|
5457
5405
|
if (raw === undefined) {
|
|
5458
|
-
|
|
5406
|
+
wb.setInputs(selectedNodeId, { [handle]: undefined }, { commit: true });
|
|
5459
5407
|
return;
|
|
5460
5408
|
}
|
|
5461
5409
|
const typeId = sparkGraph.getInputTypeId(effectiveHandles.inputs, handle);
|
|
@@ -5534,8 +5482,8 @@ function WorkbenchStudioCanvas({ setRegistry, autoScroll, onAutoScrollChange, ex
|
|
|
5534
5482
|
value = raw;
|
|
5535
5483
|
}
|
|
5536
5484
|
}
|
|
5537
|
-
|
|
5538
|
-
}, [selectedNodeId, def.edges, effectiveHandles,
|
|
5485
|
+
wb.setInputs(selectedNodeId, { [handle]: value }, { commit: true });
|
|
5486
|
+
}, [selectedNodeId, def.edges, effectiveHandles, wb]);
|
|
5539
5487
|
const setInput = React.useMemo(() => {
|
|
5540
5488
|
if (overrides?.setInput) {
|
|
5541
5489
|
return overrides.setInput(baseSetInput, {
|