@bian-womp/spark-workbench 0.1.12 → 0.1.13

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 CHANGED
@@ -399,9 +399,7 @@ class GraphRunner {
399
399
  this.runningKind = opts.engine;
400
400
  this.emit("status", { running: true, engine: this.runningKind });
401
401
  for (const [nodeId, map] of Object.entries(this.stagedInputs)) {
402
- for (const [handle, value] of Object.entries(map)) {
403
- this.engine.setInput(nodeId, handle, value);
404
- }
402
+ this.engine.setInputs(nodeId, map);
405
403
  }
406
404
  return;
407
405
  }
@@ -429,9 +427,7 @@ class GraphRunner {
429
427
  this.runningKind = "push";
430
428
  this.emit("status", { running: true, engine: this.runningKind });
431
429
  for (const [nodeId, map] of Object.entries(this.stagedInputs)) {
432
- for (const [handle, value] of Object.entries(map)) {
433
- this.engine.setInput(nodeId, handle, value);
434
- }
430
+ this.engine.setInputs(nodeId, map);
435
431
  }
436
432
  });
437
433
  }
@@ -998,7 +994,7 @@ function WorkbenchProvider({ wb, runner, registry, setRegistry, children, }) {
998
994
  const nodeId = e?.nodeId;
999
995
  setNodeStatus((s) => ({
1000
996
  ...s,
1001
- [nodeId]: { ...(s[nodeId] ?? {}), invalidated: true },
997
+ [nodeId]: { ...s[nodeId], invalidated: true },
1002
998
  }));
1003
999
  }
1004
1000
  return add("runner", "value")(e);
@@ -1010,7 +1006,7 @@ function WorkbenchProvider({ wb, runner, registry, setRegistry, children, }) {
1010
1006
  const edgeId = edgeError.edgeId;
1011
1007
  setEdgeStatus((s) => ({
1012
1008
  ...s,
1013
- [edgeId]: { ...(s[edgeId] ?? {}), lastError: edgeError.err },
1009
+ [edgeId]: { ...s[edgeId], lastError: edgeError.err },
1014
1010
  }));
1015
1011
  }
1016
1012
  else if (nodeError.nodeId) {
@@ -1018,7 +1014,7 @@ function WorkbenchProvider({ wb, runner, registry, setRegistry, children, }) {
1018
1014
  setNodeStatus((s) => ({
1019
1015
  ...s,
1020
1016
  [nodeId]: {
1021
- ...(s[nodeId] ?? {}),
1017
+ ...s[nodeId],
1022
1018
  lastError: nodeError.err,
1023
1019
  },
1024
1020
  }));
@@ -1030,7 +1026,7 @@ function WorkbenchProvider({ wb, runner, registry, setRegistry, children, }) {
1030
1026
  setNodeStatus((s) => {
1031
1027
  const next = {};
1032
1028
  for (const n of wb.export().nodes) {
1033
- next[n.nodeId] = { ...(s[n.nodeId] ?? {}), invalidated: true };
1029
+ next[n.nodeId] = { ...s[n.nodeId], invalidated: true };
1034
1030
  }
1035
1031
  return next;
1036
1032
  });
@@ -1043,12 +1039,12 @@ function WorkbenchProvider({ wb, runner, registry, setRegistry, children, }) {
1043
1039
  if (s.kind === "node-start") {
1044
1040
  const id = s.nodeId;
1045
1041
  setNodeStatus((prev) => {
1046
- const active = Math.max(1, (prev[id]?.activeRuns ?? 0) + 1);
1042
+ const current = prev[id]?.activeRuns ?? 0;
1047
1043
  return {
1048
1044
  ...prev,
1049
1045
  [id]: {
1050
- ...(prev[id] ?? {}),
1051
- activeRuns: active,
1046
+ ...prev[id],
1047
+ activeRuns: current + 1,
1052
1048
  progress: 0,
1053
1049
  invalidated: false,
1054
1050
  },
@@ -1060,7 +1056,7 @@ function WorkbenchProvider({ wb, runner, registry, setRegistry, children, }) {
1060
1056
  setNodeStatus((prev) => ({
1061
1057
  ...prev,
1062
1058
  [id]: {
1063
- ...(prev[id] ?? {}),
1059
+ ...prev[id],
1064
1060
  progress: Number(s.progress) || 0,
1065
1061
  },
1066
1062
  }));
@@ -1068,13 +1064,12 @@ function WorkbenchProvider({ wb, runner, registry, setRegistry, children, }) {
1068
1064
  else if (s.kind === "node-done") {
1069
1065
  const id = s.nodeId;
1070
1066
  setNodeStatus((prev) => {
1071
- const current = prev[id]?.activeRuns ?? 1;
1072
- const nextActive = Math.max(0, current - 1);
1067
+ const current = prev[id]?.activeRuns ?? 0;
1073
1068
  return {
1074
1069
  ...prev,
1075
1070
  [id]: {
1076
- ...(prev[id] ?? {}),
1077
- activeRuns: nextActive,
1071
+ ...prev[id],
1072
+ activeRuns: current - 1,
1078
1073
  },
1079
1074
  };
1080
1075
  });
@@ -1082,22 +1077,20 @@ function WorkbenchProvider({ wb, runner, registry, setRegistry, children, }) {
1082
1077
  else if (s.kind === "edge-start") {
1083
1078
  const id = s.edgeId;
1084
1079
  setEdgeStatus((prev) => {
1085
- const current = prev[id]?.activeRuns ?? 1;
1086
- const nextActive = Math.max(0, current + 1);
1080
+ const current = prev[id]?.activeRuns ?? 0;
1087
1081
  return {
1088
1082
  ...prev,
1089
- [id]: { ...(prev[id] ?? {}), activeRuns: nextActive },
1083
+ [id]: { ...prev[id], activeRuns: current + 1 },
1090
1084
  };
1091
1085
  });
1092
1086
  }
1093
1087
  else if (s.kind === "edge-done") {
1094
1088
  const id = s.edgeId;
1095
1089
  setEdgeStatus((prev) => {
1096
- const current = prev[id]?.activeRuns ?? 1;
1097
- const nextActive = Math.max(0, current - 1);
1090
+ const current = prev[id]?.activeRuns ?? 0;
1098
1091
  return {
1099
1092
  ...prev,
1100
- [id]: { ...(prev[id] ?? {}), activeRuns: nextActive },
1093
+ [id]: { ...prev[id], activeRuns: current - 1 },
1101
1094
  };
1102
1095
  });
1103
1096
  }
@@ -1111,7 +1104,7 @@ function WorkbenchProvider({ wb, runner, registry, setRegistry, children, }) {
1111
1104
  const id = change.nodeId;
1112
1105
  setNodeStatus((s) => ({
1113
1106
  ...s,
1114
- [id]: { ...(s[id] ?? {}), invalidated: true },
1107
+ [id]: { ...s[id], invalidated: true },
1115
1108
  }));
1116
1109
  }
1117
1110
  });
@@ -1463,7 +1456,7 @@ const DefaultNode = React.memo(function DefaultNode({ id, data, selected, isConn
1463
1456
  const { typeId, showValues, inputValues, outputValues, toString } = data;
1464
1457
  const inputEntries = data.inputHandles ?? [];
1465
1458
  const outputEntries = data.outputHandles ?? [];
1466
- const status = data.status ?? {};
1459
+ const status = data.status ?? { activeRuns: 0 };
1467
1460
  const validation = data.validation ?? {
1468
1461
  inputs: [],
1469
1462
  outputs: [],