@bian-womp/spark-workbench 0.2.61 → 0.2.62
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 +42 -26
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/cjs/src/core/InMemoryWorkbench.d.ts.map +1 -1
- package/lib/cjs/src/misc/WorkbenchCanvas.d.ts.map +1 -1
- package/lib/cjs/src/misc/WorkbenchStudio.d.ts.map +1 -1
- package/lib/cjs/src/misc/context/ContextMenuHandlers.d.ts +0 -1
- package/lib/cjs/src/misc/context/ContextMenuHandlers.d.ts.map +1 -1
- package/lib/cjs/src/misc/context/ContextMenuHelpers.d.ts.map +1 -1
- package/lib/cjs/src/misc/context/WorkbenchContext.d.ts +1 -0
- package/lib/cjs/src/misc/context/WorkbenchContext.d.ts.map +1 -1
- package/lib/cjs/src/runtime/AbstractGraphRunner.d.ts +10 -3
- package/lib/cjs/src/runtime/AbstractGraphRunner.d.ts.map +1 -1
- package/lib/cjs/src/runtime/IGraphRunner.d.ts +10 -3
- package/lib/cjs/src/runtime/IGraphRunner.d.ts.map +1 -1
- package/lib/cjs/src/runtime/LocalGraphRunner.d.ts +4 -1
- package/lib/cjs/src/runtime/LocalGraphRunner.d.ts.map +1 -1
- package/lib/cjs/src/runtime/RemoteGraphRunner.d.ts +7 -2
- package/lib/cjs/src/runtime/RemoteGraphRunner.d.ts.map +1 -1
- package/lib/esm/index.js +42 -26
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/src/core/InMemoryWorkbench.d.ts.map +1 -1
- package/lib/esm/src/misc/WorkbenchCanvas.d.ts.map +1 -1
- package/lib/esm/src/misc/WorkbenchStudio.d.ts.map +1 -1
- package/lib/esm/src/misc/context/ContextMenuHandlers.d.ts +0 -1
- package/lib/esm/src/misc/context/ContextMenuHandlers.d.ts.map +1 -1
- package/lib/esm/src/misc/context/ContextMenuHelpers.d.ts.map +1 -1
- package/lib/esm/src/misc/context/WorkbenchContext.d.ts +1 -0
- package/lib/esm/src/misc/context/WorkbenchContext.d.ts.map +1 -1
- package/lib/esm/src/runtime/AbstractGraphRunner.d.ts +10 -3
- package/lib/esm/src/runtime/AbstractGraphRunner.d.ts.map +1 -1
- package/lib/esm/src/runtime/IGraphRunner.d.ts +10 -3
- package/lib/esm/src/runtime/IGraphRunner.d.ts.map +1 -1
- package/lib/esm/src/runtime/LocalGraphRunner.d.ts +4 -1
- package/lib/esm/src/runtime/LocalGraphRunner.d.ts.map +1 -1
- package/lib/esm/src/runtime/RemoteGraphRunner.d.ts +7 -2
- package/lib/esm/src/runtime/RemoteGraphRunner.d.ts.map +1 -1
- package/package.json +4 -4
package/lib/cjs/index.cjs
CHANGED
|
@@ -197,7 +197,6 @@ class InMemoryWorkbench extends AbstractWorkbench {
|
|
|
197
197
|
nodeId: id,
|
|
198
198
|
typeId: node.typeId,
|
|
199
199
|
params: node.params,
|
|
200
|
-
initialInputs: node.initialInputs,
|
|
201
200
|
resolvedHandles: node.resolvedHandles,
|
|
202
201
|
});
|
|
203
202
|
if (node.position)
|
|
@@ -427,11 +426,11 @@ class AbstractGraphRunner {
|
|
|
427
426
|
this.stop();
|
|
428
427
|
}
|
|
429
428
|
}
|
|
430
|
-
triggerExternal(nodeId, event) {
|
|
429
|
+
triggerExternal(nodeId, event, options) {
|
|
431
430
|
this.engine?.triggerExternal(nodeId, event);
|
|
432
431
|
}
|
|
433
432
|
// Batch update multiple inputs on a node and trigger a single run
|
|
434
|
-
setInputs(nodeId, inputs) {
|
|
433
|
+
setInputs(nodeId, inputs, options) {
|
|
435
434
|
if (!inputs)
|
|
436
435
|
return;
|
|
437
436
|
if (!this.stagedInputs[nodeId])
|
|
@@ -496,10 +495,8 @@ class AbstractGraphRunner {
|
|
|
496
495
|
const out = {};
|
|
497
496
|
for (const n of def.nodes) {
|
|
498
497
|
const dynDefaults = n.resolvedHandles?.inputDefaults ?? {};
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
if (Object.keys(merged).length > 0) {
|
|
502
|
-
out[n.nodeId] = merged;
|
|
498
|
+
if (Object.keys(dynDefaults).length > 0) {
|
|
499
|
+
out[n.nodeId] = dynDefaults;
|
|
503
500
|
}
|
|
504
501
|
}
|
|
505
502
|
return out;
|
|
@@ -543,13 +540,22 @@ class LocalGraphRunner extends AbstractGraphRunner {
|
|
|
543
540
|
this.setEnvironment = (env, opts) => {
|
|
544
541
|
if (!this.runtime)
|
|
545
542
|
return;
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
543
|
+
const wasPaused = this.runtime.isPaused();
|
|
544
|
+
if (opts?.dry && !wasPaused)
|
|
545
|
+
this.runtime.pause();
|
|
546
|
+
try {
|
|
547
|
+
if (opts?.merge) {
|
|
548
|
+
const current = this.runtime.getEnvironment();
|
|
549
|
+
const next = { ...(current || {}), ...(env || {}) };
|
|
550
|
+
this.runtime.setEnvironment(next);
|
|
551
|
+
}
|
|
552
|
+
else {
|
|
553
|
+
this.runtime.setEnvironment(env);
|
|
554
|
+
}
|
|
550
555
|
}
|
|
551
|
-
|
|
552
|
-
|
|
556
|
+
finally {
|
|
557
|
+
if (opts?.dry && !wasPaused)
|
|
558
|
+
this.runtime.resume();
|
|
553
559
|
}
|
|
554
560
|
};
|
|
555
561
|
this.getEnvironment = () => {
|
|
@@ -567,14 +573,20 @@ class LocalGraphRunner extends AbstractGraphRunner {
|
|
|
567
573
|
// Signal UI that freshly built graph should be considered invalidated
|
|
568
574
|
this.emit("invalidate", { reason: "graph-built" });
|
|
569
575
|
}
|
|
570
|
-
update(def) {
|
|
576
|
+
update(def, options) {
|
|
571
577
|
if (!this.runtime)
|
|
572
578
|
return;
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
579
|
+
const wasPaused = this.runtime.isPaused();
|
|
580
|
+
if (!wasPaused)
|
|
581
|
+
this.runtime.pause();
|
|
582
|
+
try {
|
|
583
|
+
this.runtime.update(def, this.registry);
|
|
584
|
+
this.emit("invalidate", { reason: "graph-updated" });
|
|
585
|
+
}
|
|
586
|
+
finally {
|
|
587
|
+
if (!wasPaused)
|
|
588
|
+
this.runtime.resume();
|
|
589
|
+
}
|
|
578
590
|
}
|
|
579
591
|
launch(def, opts) {
|
|
580
592
|
super.launch(def, opts);
|
|
@@ -689,7 +701,7 @@ class LocalGraphRunner extends AbstractGraphRunner {
|
|
|
689
701
|
return { def, environment, inputs, outputs };
|
|
690
702
|
}
|
|
691
703
|
async applySnapshotFull(payload, options) {
|
|
692
|
-
if (payload.def && options?.skipBuild
|
|
704
|
+
if (payload.def && !options?.skipBuild) {
|
|
693
705
|
this.build(payload.def);
|
|
694
706
|
}
|
|
695
707
|
this.setEnvironment?.(payload.environment || {}, { merge: false });
|
|
@@ -1002,11 +1014,11 @@ class RemoteGraphRunner extends AbstractGraphRunner {
|
|
|
1002
1014
|
});
|
|
1003
1015
|
}
|
|
1004
1016
|
build(def) { }
|
|
1005
|
-
update(def) {
|
|
1017
|
+
update(def, options) {
|
|
1006
1018
|
// Remote: forward update; ignore errors (fire-and-forget)
|
|
1007
1019
|
this.ensureClient().then(async (client) => {
|
|
1008
1020
|
try {
|
|
1009
|
-
await client.update(def);
|
|
1021
|
+
await client.update(def, options);
|
|
1010
1022
|
this.emit("invalidate", { reason: "graph-updated" });
|
|
1011
1023
|
this.lastDef = def;
|
|
1012
1024
|
}
|
|
@@ -1132,7 +1144,7 @@ class RemoteGraphRunner extends AbstractGraphRunner {
|
|
|
1132
1144
|
const client = await this.ensureClient();
|
|
1133
1145
|
await client.flush();
|
|
1134
1146
|
}
|
|
1135
|
-
triggerExternal(nodeId, event) {
|
|
1147
|
+
triggerExternal(nodeId, event, options) {
|
|
1136
1148
|
this.ensureClient().then(async (client) => {
|
|
1137
1149
|
try {
|
|
1138
1150
|
await client.getEngine().triggerExternal(nodeId, event);
|
|
@@ -3539,7 +3551,6 @@ function createNodeContextMenuHandlers(nodeId, wb, runner, registry, outputsMap,
|
|
|
3539
3551
|
typeId: n.typeId,
|
|
3540
3552
|
params: n.params,
|
|
3541
3553
|
position: { x: pos.x + 24, y: pos.y + 24 },
|
|
3542
|
-
initialInputs: n.initialInputs,
|
|
3543
3554
|
resolvedHandles: n.resolvedHandles,
|
|
3544
3555
|
});
|
|
3545
3556
|
await runner.whenIdle();
|
|
@@ -3865,7 +3876,6 @@ const WorkbenchCanvas = React.forwardRef(({ showValues, toString, toElement, get
|
|
|
3865
3876
|
const addNodeAt = React.useCallback(async (typeId, opts) => {
|
|
3866
3877
|
const nodeId = wb.addNode({
|
|
3867
3878
|
typeId,
|
|
3868
|
-
initialInputs: opts.initialInputs,
|
|
3869
3879
|
position: opts.position,
|
|
3870
3880
|
});
|
|
3871
3881
|
if (opts.inputs) {
|
|
@@ -4117,7 +4127,7 @@ function WorkbenchStudioCanvas({ setRegistry, autoScroll, onAutoScrollChange, ex
|
|
|
4117
4127
|
const ex = examples.find((e) => e.id === key) ?? examples[0];
|
|
4118
4128
|
if (!ex)
|
|
4119
4129
|
return;
|
|
4120
|
-
const { registry: r, def } = await ex.load();
|
|
4130
|
+
const { registry: r, def, inputs } = await ex.load();
|
|
4121
4131
|
// Keep registry consistent with backend:
|
|
4122
4132
|
// - For local backend, allow example to provide its own registry
|
|
4123
4133
|
// - For remote backend, registry is automatically managed by RemoteGraphRunner
|
|
@@ -4130,6 +4140,12 @@ function WorkbenchStudioCanvas({ setRegistry, autoScroll, onAutoScrollChange, ex
|
|
|
4130
4140
|
await wb.load(def);
|
|
4131
4141
|
// Build a local runtime so seeded defaults are visible pre-run
|
|
4132
4142
|
runner.build(wb.export());
|
|
4143
|
+
// Set initial inputs if provided
|
|
4144
|
+
if (inputs) {
|
|
4145
|
+
for (const [nodeId, map] of Object.entries(inputs)) {
|
|
4146
|
+
runner.setInputs(nodeId, map);
|
|
4147
|
+
}
|
|
4148
|
+
}
|
|
4133
4149
|
runAutoLayout();
|
|
4134
4150
|
setExampleState(key);
|
|
4135
4151
|
onExampleChange?.(key);
|