@bian-womp/spark-graph 0.2.10 → 0.2.11
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 +54 -0
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/cjs/src/builder/Registry.d.ts +1 -1
- package/lib/cjs/src/builder/Registry.d.ts.map +1 -1
- package/lib/cjs/src/core/types.d.ts +1 -1
- package/lib/cjs/src/core/types.d.ts.map +1 -1
- package/lib/cjs/src/examples/run.d.ts.map +1 -1
- package/lib/cjs/src/examples/snapshot.d.ts +4 -0
- package/lib/cjs/src/examples/snapshot.d.ts.map +1 -0
- package/lib/cjs/src/runtime/GraphRuntime.d.ts +6 -0
- package/lib/cjs/src/runtime/GraphRuntime.d.ts.map +1 -1
- package/lib/esm/index.js +54 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/src/builder/Registry.d.ts +1 -1
- package/lib/esm/src/builder/Registry.d.ts.map +1 -1
- package/lib/esm/src/core/types.d.ts +1 -1
- package/lib/esm/src/core/types.d.ts.map +1 -1
- package/lib/esm/src/examples/run.d.ts.map +1 -1
- package/lib/esm/src/examples/snapshot.d.ts +4 -0
- package/lib/esm/src/examples/snapshot.d.ts.map +1 -0
- package/lib/esm/src/runtime/GraphRuntime.d.ts +6 -0
- package/lib/esm/src/runtime/GraphRuntime.d.ts.map +1 -1
- package/package.json +2 -2
package/lib/cjs/index.cjs
CHANGED
|
@@ -1054,6 +1054,60 @@ class GraphRuntime {
|
|
|
1054
1054
|
__unsafe_scheduleInputsChanged(nodeId) {
|
|
1055
1055
|
this.scheduleInputsChanged(nodeId);
|
|
1056
1056
|
}
|
|
1057
|
+
// Hydrate inputs/outputs without triggering computation; optionally re-emit outputs downstream
|
|
1058
|
+
hydrate(payload, opts) {
|
|
1059
|
+
const prevPaused = this.paused;
|
|
1060
|
+
this.paused = true;
|
|
1061
|
+
try {
|
|
1062
|
+
const ins = payload?.inputs || {};
|
|
1063
|
+
for (const [nodeId, map] of Object.entries(ins)) {
|
|
1064
|
+
const node = this.nodes.get(nodeId);
|
|
1065
|
+
if (!node)
|
|
1066
|
+
continue;
|
|
1067
|
+
for (const [h, v] of Object.entries(map || {})) {
|
|
1068
|
+
node.inputs[h] =
|
|
1069
|
+
typeof structuredClone === "function"
|
|
1070
|
+
? structuredClone(v)
|
|
1071
|
+
: JSON.parse(JSON.stringify(v));
|
|
1072
|
+
// emit input value event
|
|
1073
|
+
this.emit("value", {
|
|
1074
|
+
nodeId,
|
|
1075
|
+
handle: h,
|
|
1076
|
+
value: node.inputs[h],
|
|
1077
|
+
io: "input",
|
|
1078
|
+
runtimeTypeId: getTypedOutputTypeId(node.inputs[h]),
|
|
1079
|
+
});
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
const outs = payload?.outputs || {};
|
|
1083
|
+
for (const [nodeId, map] of Object.entries(outs)) {
|
|
1084
|
+
const node = this.nodes.get(nodeId);
|
|
1085
|
+
if (!node)
|
|
1086
|
+
continue;
|
|
1087
|
+
for (const [h, v] of Object.entries(map || {})) {
|
|
1088
|
+
node.outputs[h] =
|
|
1089
|
+
typeof structuredClone === "function"
|
|
1090
|
+
? structuredClone(v)
|
|
1091
|
+
: JSON.parse(JSON.stringify(v));
|
|
1092
|
+
// emit output value event
|
|
1093
|
+
this.emit("value", {
|
|
1094
|
+
nodeId,
|
|
1095
|
+
handle: h,
|
|
1096
|
+
value: node.outputs[h],
|
|
1097
|
+
io: "output",
|
|
1098
|
+
runtimeTypeId: getTypedOutputTypeId(node.outputs[h]),
|
|
1099
|
+
});
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
if (opts?.reemit) {
|
|
1103
|
+
for (const nodeId of this.nodes.keys())
|
|
1104
|
+
this.reemitNodeOutputs(nodeId);
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
finally {
|
|
1108
|
+
this.paused = prevPaused;
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1057
1111
|
// Incrementally update nodes/edges to match new definition without full rebuild
|
|
1058
1112
|
update(def, registry) {
|
|
1059
1113
|
// Handle node additions and removals
|