@bian-womp/spark-graph 0.2.45 → 0.2.46
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 +15 -57
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/cjs/src/core/categories.d.ts +2 -2
- package/lib/cjs/src/core/categories.d.ts.map +1 -1
- package/lib/cjs/src/core/types.d.ts +3 -4
- package/lib/cjs/src/core/types.d.ts.map +1 -1
- package/lib/cjs/src/plugins/compute.d.ts +1 -1
- package/lib/cjs/src/plugins/compute.d.ts.map +1 -1
- package/lib/cjs/src/runtime/GraphRuntime.d.ts.map +1 -1
- package/lib/esm/index.js +15 -57
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/src/core/categories.d.ts +2 -2
- package/lib/esm/src/core/categories.d.ts.map +1 -1
- package/lib/esm/src/core/types.d.ts +3 -4
- package/lib/esm/src/core/types.d.ts.map +1 -1
- package/lib/esm/src/plugins/compute.d.ts +1 -1
- package/lib/esm/src/plugins/compute.d.ts.map +1 -1
- package/lib/esm/src/runtime/GraphRuntime.d.ts.map +1 -1
- package/package.json +2 -2
package/lib/cjs/index.cjs
CHANGED
|
@@ -683,6 +683,9 @@ class GraphRuntime {
|
|
|
683
683
|
}
|
|
684
684
|
const ctx = {
|
|
685
685
|
state: node.state,
|
|
686
|
+
environment: this.environment,
|
|
687
|
+
runId,
|
|
688
|
+
abortSignal: controller.signal,
|
|
686
689
|
setState: (next) => Object.assign(node.state, next),
|
|
687
690
|
emit: (handle, value) => {
|
|
688
691
|
const m = policy.asyncConcurrency ?? "switch";
|
|
@@ -691,11 +694,11 @@ class GraphRuntime {
|
|
|
691
694
|
this.propagate(nodeId, handle, value);
|
|
692
695
|
},
|
|
693
696
|
invalidateDownstream: () => this.invalidateDownstream(nodeId),
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
697
|
+
scheduleInputsChanged: () => {
|
|
698
|
+
if (this.allInboundHaveValue(nodeId)) {
|
|
699
|
+
this.scheduleInputsChanged(nodeId);
|
|
700
|
+
}
|
|
701
|
+
},
|
|
699
702
|
reportProgress: (p) => {
|
|
700
703
|
node.stats.progress = Math.max(0, Math.min(1, Number(p) || 0));
|
|
701
704
|
this.emit("stats", {
|
|
@@ -1150,27 +1153,11 @@ class GraphRuntime {
|
|
|
1150
1153
|
launch(invalidate = false) {
|
|
1151
1154
|
// call onActivated for nodes that implement it
|
|
1152
1155
|
for (const node of this.nodes.values()) {
|
|
1153
|
-
const ctrl = new AbortController();
|
|
1154
|
-
const effectiveInputs = this.getEffectiveInputs(node.nodeId);
|
|
1155
|
-
const ctx = {
|
|
1156
|
-
state: node.state,
|
|
1157
|
-
setState: (next) => Object.assign(node.state, next),
|
|
1158
|
-
emit: (handle, value) => this.propagate(node.nodeId, handle, value),
|
|
1159
|
-
invalidateDownstream: () => this.invalidateDownstream(node.nodeId),
|
|
1160
|
-
getInput: (handle) => effectiveInputs[handle],
|
|
1161
|
-
environment: this.environment,
|
|
1162
|
-
runId: `${node.nodeId}:activation`,
|
|
1163
|
-
abortSignal: ctrl.signal,
|
|
1164
|
-
createAbortController: () => new AbortController(),
|
|
1165
|
-
reportProgress: (p) => {
|
|
1166
|
-
node.stats.progress = Math.max(0, Math.min(1, Number(p) || 0));
|
|
1167
|
-
},
|
|
1168
|
-
};
|
|
1169
1156
|
node.lifecycle?.init?.(node.params ?? {}, {
|
|
1170
1157
|
state: node.state,
|
|
1171
1158
|
setState: (next) => Object.assign(node.state, next),
|
|
1172
1159
|
});
|
|
1173
|
-
node.runtime.onActivated?.(
|
|
1160
|
+
node.runtime.onActivated?.();
|
|
1174
1161
|
}
|
|
1175
1162
|
if (invalidate) {
|
|
1176
1163
|
// After activation, schedule nodes that have all inbound inputs present
|
|
@@ -1184,22 +1171,6 @@ class GraphRuntime {
|
|
|
1184
1171
|
const node = this.nodes.get(nodeId);
|
|
1185
1172
|
if (!node)
|
|
1186
1173
|
return;
|
|
1187
|
-
const ctrl = new AbortController();
|
|
1188
|
-
const effectiveInputs = this.getEffectiveInputs(nodeId);
|
|
1189
|
-
const ctx = {
|
|
1190
|
-
state: node.state,
|
|
1191
|
-
setState: (next) => Object.assign(node.state, next),
|
|
1192
|
-
emit: (handle, value) => this.propagate(nodeId, handle, value),
|
|
1193
|
-
invalidateDownstream: () => this.invalidateDownstream(nodeId),
|
|
1194
|
-
getInput: (handle) => effectiveInputs[handle],
|
|
1195
|
-
environment: this.environment,
|
|
1196
|
-
runId: `${nodeId}:external`,
|
|
1197
|
-
abortSignal: ctrl.signal,
|
|
1198
|
-
createAbortController: () => new AbortController(),
|
|
1199
|
-
reportProgress: (p) => {
|
|
1200
|
-
node.stats.progress = Math.max(0, Math.min(1, Number(p) || 0));
|
|
1201
|
-
},
|
|
1202
|
-
};
|
|
1203
1174
|
// Built-in support: invalidate event reruns or re-emits without per-node wiring
|
|
1204
1175
|
if (event &&
|
|
1205
1176
|
typeof event === "object" &&
|
|
@@ -1210,7 +1181,7 @@ class GraphRuntime {
|
|
|
1210
1181
|
this.invalidateDownstream(nodeId);
|
|
1211
1182
|
}
|
|
1212
1183
|
else {
|
|
1213
|
-
node.runtime.onExternalEvent?.(event,
|
|
1184
|
+
node.runtime.onExternalEvent?.(event, node.state);
|
|
1214
1185
|
}
|
|
1215
1186
|
}
|
|
1216
1187
|
dispose() {
|
|
@@ -1428,24 +1399,11 @@ class GraphRuntime {
|
|
|
1428
1399
|
};
|
|
1429
1400
|
this.nodes.set(n.nodeId, rn);
|
|
1430
1401
|
// Activate new node
|
|
1431
|
-
const ctrl = new AbortController();
|
|
1432
|
-
const effectiveInputs = this.getEffectiveInputs(rn.nodeId);
|
|
1433
|
-
const ctx = {
|
|
1434
|
-
state: rn.state,
|
|
1435
|
-
setState: (next) => Object.assign(rn.state, next),
|
|
1436
|
-
emit: (handle, value) => this.propagate(rn.nodeId, handle, value),
|
|
1437
|
-
invalidateDownstream: () => this.invalidateDownstream(rn.nodeId),
|
|
1438
|
-
getInput: (handle) => effectiveInputs[handle],
|
|
1439
|
-
environment: this.environment,
|
|
1440
|
-
runId: `${rn.nodeId}:activation`,
|
|
1441
|
-
abortSignal: ctrl.signal,
|
|
1442
|
-
createAbortController: () => new AbortController(),
|
|
1443
|
-
};
|
|
1444
1402
|
rn.lifecycle?.init?.(rn.params ?? {}, {
|
|
1445
1403
|
state: rn.state,
|
|
1446
1404
|
setState: (next) => Object.assign(rn.state, next),
|
|
1447
1405
|
});
|
|
1448
|
-
rn.runtime.onActivated?.(
|
|
1406
|
+
rn.runtime.onActivated?.();
|
|
1449
1407
|
}
|
|
1450
1408
|
else {
|
|
1451
1409
|
// update params/policy and initialInputs
|
|
@@ -2088,13 +2046,13 @@ const ComputeCategory = {
|
|
|
2088
2046
|
ctx.emit(h, v);
|
|
2089
2047
|
}
|
|
2090
2048
|
},
|
|
2091
|
-
onExternalEvent(event,
|
|
2049
|
+
onExternalEvent(event, state) {
|
|
2092
2050
|
try {
|
|
2093
2051
|
const e = event;
|
|
2094
|
-
// Preferred: call a function on
|
|
2052
|
+
// Preferred: call a function on state keyed by e.action
|
|
2095
2053
|
const action = e?.action;
|
|
2096
|
-
if (action && typeof
|
|
2097
|
-
const fn =
|
|
2054
|
+
if (action && typeof state?.[action] === "function") {
|
|
2055
|
+
const fn = state[action];
|
|
2098
2056
|
// Normalize args: prefer explicit args array, else wrap single value;
|
|
2099
2057
|
let args = [];
|
|
2100
2058
|
if (Array.isArray(e?.args))
|