@bian-womp/spark-graph 0.2.61 → 0.2.63
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 +5 -39
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/cjs/src/examples/simple.d.ts.map +1 -1
- package/lib/cjs/src/misc/utils/merge.d.ts.map +1 -1
- package/lib/cjs/src/runtime/GraphRuntime.d.ts +1 -0
- package/lib/cjs/src/runtime/GraphRuntime.d.ts.map +1 -1
- package/lib/esm/index.js +5 -39
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/src/examples/simple.d.ts.map +1 -1
- package/lib/esm/src/misc/utils/merge.d.ts.map +1 -1
- package/lib/esm/src/runtime/GraphRuntime.d.ts +1 -0
- package/lib/esm/src/runtime/GraphRuntime.d.ts.map +1 -1
- package/package.json +2 -2
package/lib/cjs/index.cjs
CHANGED
|
@@ -494,7 +494,6 @@ class GraphRuntime {
|
|
|
494
494
|
queued: 0,
|
|
495
495
|
progress: 0,
|
|
496
496
|
},
|
|
497
|
-
initialInputs: n.initialInputs ?? {},
|
|
498
497
|
};
|
|
499
498
|
gr.nodes.set(n.nodeId, rn);
|
|
500
499
|
}
|
|
@@ -878,16 +877,14 @@ class GraphRuntime {
|
|
|
878
877
|
const resolved = this.resolvedByNode.get(nodeId);
|
|
879
878
|
const regDefaults = desc.inputDefaults ?? {};
|
|
880
879
|
const dynDefaults = resolved?.inputDefaults ?? {};
|
|
881
|
-
const graphDefaults = node.initialInputs ?? {};
|
|
882
880
|
// Identify which handles are dynamically resolved (not in registry statics)
|
|
883
881
|
// Dynamic handles are metadata-only and should not receive defaults in execution
|
|
884
882
|
const staticHandles = new Set(Object.keys(desc.inputs ?? {}));
|
|
885
883
|
const dynamicHandles = new Set(Object.keys(resolved?.inputs ?? {}).filter((h) => !staticHandles.has(h)));
|
|
886
|
-
// Precedence:
|
|
884
|
+
// Precedence: dynamic > registry
|
|
887
885
|
const mergedDefaults = {
|
|
888
886
|
...regDefaults,
|
|
889
887
|
...dynDefaults,
|
|
890
|
-
...graphDefaults,
|
|
891
888
|
};
|
|
892
889
|
// Start with real inputs only (no defaults)
|
|
893
890
|
const effective = { ...node.inputs };
|
|
@@ -1296,20 +1293,10 @@ class GraphRuntime {
|
|
|
1296
1293
|
getGraphDef() {
|
|
1297
1294
|
const nodes = Array.from(this.nodes.values()).map((n) => {
|
|
1298
1295
|
const resolved = this.resolvedByNode.get(n.nodeId);
|
|
1299
|
-
// Collect user-provided inputs (inputs without inbound edges)
|
|
1300
|
-
const initialInputs = {};
|
|
1301
|
-
for (const [handle, value] of Object.entries(n.inputs)) {
|
|
1302
|
-
const hasInbound = this.edges.some((e) => e.target.nodeId === n.nodeId && e.target.handle === handle);
|
|
1303
|
-
if (!hasInbound && value !== undefined) {
|
|
1304
|
-
// Clone to avoid shared references
|
|
1305
|
-
initialInputs[handle] = structuredClone(value);
|
|
1306
|
-
}
|
|
1307
|
-
}
|
|
1308
1296
|
return {
|
|
1309
1297
|
nodeId: n.nodeId,
|
|
1310
1298
|
typeId: n.typeId,
|
|
1311
1299
|
params: n.params ? { ...n.params } : undefined,
|
|
1312
|
-
initialInputs: Object.keys(initialInputs).length > 0 ? initialInputs : undefined,
|
|
1313
1300
|
resolvedHandles: resolved ? { ...resolved } : undefined,
|
|
1314
1301
|
};
|
|
1315
1302
|
});
|
|
@@ -1346,6 +1333,9 @@ class GraphRuntime {
|
|
|
1346
1333
|
pause() {
|
|
1347
1334
|
this.paused = true;
|
|
1348
1335
|
}
|
|
1336
|
+
isPaused() {
|
|
1337
|
+
return this.paused;
|
|
1338
|
+
}
|
|
1349
1339
|
resume() {
|
|
1350
1340
|
this.paused = false;
|
|
1351
1341
|
}
|
|
@@ -1463,7 +1453,6 @@ class GraphRuntime {
|
|
|
1463
1453
|
queued: 0,
|
|
1464
1454
|
progress: 0,
|
|
1465
1455
|
},
|
|
1466
|
-
initialInputs: n.initialInputs ?? {},
|
|
1467
1456
|
};
|
|
1468
1457
|
this.nodes.set(n.nodeId, rn);
|
|
1469
1458
|
// Activate new node
|
|
@@ -1478,9 +1467,8 @@ class GraphRuntime {
|
|
|
1478
1467
|
rn.runtime.onActivated?.();
|
|
1479
1468
|
}
|
|
1480
1469
|
else {
|
|
1481
|
-
// update params/policy
|
|
1470
|
+
// update params/policy
|
|
1482
1471
|
existing.params = n.params;
|
|
1483
|
-
existing.initialInputs = n.initialInputs ?? {};
|
|
1484
1472
|
if (!existing.stats) {
|
|
1485
1473
|
existing.stats = {
|
|
1486
1474
|
runs: 0,
|
|
@@ -3392,8 +3380,6 @@ function makeBasicGraphDefinition() {
|
|
|
3392
3380
|
{
|
|
3393
3381
|
nodeId: "n2",
|
|
3394
3382
|
typeId: "base.math",
|
|
3395
|
-
// Graph-level defaults override registry if provided
|
|
3396
|
-
initialInputs: { Operation: 2, B: [10] }, // Multiply by 10
|
|
3397
3383
|
},
|
|
3398
3384
|
// Transitivity demo nodes
|
|
3399
3385
|
{ nodeId: "n3", typeId: "base.compare" },
|
|
@@ -3762,26 +3748,6 @@ function mergeGraphDefinitions(target, source, converter) {
|
|
|
3762
3748
|
};
|
|
3763
3749
|
if (converter) {
|
|
3764
3750
|
const nodeTypeId = transformedNode.typeId;
|
|
3765
|
-
if (transformedNode.initialInputs) {
|
|
3766
|
-
const transformedInitialInputs = {};
|
|
3767
|
-
for (const [handleId, value] of Object.entries(transformedNode.initialInputs)) {
|
|
3768
|
-
const handleDataType = transformedNode.resolvedHandles?.inputs?.[handleId]
|
|
3769
|
-
? typeof transformedNode.resolvedHandles.inputs[handleId] ===
|
|
3770
|
-
"string"
|
|
3771
|
-
? transformedNode.resolvedHandles.inputs[handleId]
|
|
3772
|
-
: transformedNode.resolvedHandles.inputs[handleId]?.typeId
|
|
3773
|
-
: undefined;
|
|
3774
|
-
transformedInitialInputs[handleId] = converter({
|
|
3775
|
-
nodeId: newId,
|
|
3776
|
-
handleId,
|
|
3777
|
-
value,
|
|
3778
|
-
type: "initialInput",
|
|
3779
|
-
nodeTypeId,
|
|
3780
|
-
handleDataType,
|
|
3781
|
-
});
|
|
3782
|
-
}
|
|
3783
|
-
transformedNode.initialInputs = transformedInitialInputs;
|
|
3784
|
-
}
|
|
3785
3751
|
if (transformedNode.resolvedHandles?.inputDefaults) {
|
|
3786
3752
|
const transformedInputDefaults = {};
|
|
3787
3753
|
for (const [handleId, value] of Object.entries(transformedNode.resolvedHandles.inputDefaults)) {
|