@bian-womp/spark-workbench 0.1.20 → 0.1.21

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
@@ -819,7 +819,10 @@ function useQueryParamString(key, defaultValue) {
819
819
 
820
820
  function resolveOutputDisplay(raw, declared) {
821
821
  if (sparkGraph.isTypedOutput(raw)) {
822
- return { typeId: String(raw.__spark_type), value: raw.__spark_value };
822
+ return {
823
+ typeId: sparkGraph.getTypedOutputTypeId(raw),
824
+ value: sparkGraph.getTypedOutputValue(raw),
825
+ };
823
826
  }
824
827
  let typeId = undefined;
825
828
  if (Array.isArray(declared)) {
@@ -841,7 +844,7 @@ function preformatValueForDisplay(typeId, value, registry) {
841
844
  return "";
842
845
  // Unwrap typed outputs
843
846
  if (sparkGraph.isTypedOutput(value)) {
844
- return preformatValueForDisplay(String(value.__spark_type), value.__spark_value, registry);
847
+ return preformatValueForDisplay(sparkGraph.getTypedOutputTypeId(value), sparkGraph.getTypedOutputValue(value), registry);
845
848
  }
846
849
  // Enums
847
850
  if (typeId && typeId.includes("enum:") && registry) {
@@ -885,7 +888,7 @@ function summarizeDeep(value) {
885
888
  }
886
889
  // Typed output wrapper
887
890
  if (sparkGraph.isTypedOutput(value)) {
888
- return summarizeDeep(value.__spark_value);
891
+ return summarizeDeep(sparkGraph.getTypedOutputValue(value));
889
892
  }
890
893
  // Arrays
891
894
  if (Array.isArray(value)) {
@@ -1078,6 +1081,21 @@ function WorkbenchProvider({ wb, runner, registry, setRegistry, children, }) {
1078
1081
  const def = wb.export();
1079
1082
  const inputsMap = React.useMemo(() => runner.getInputs(def), [runner, def, valuesTick]);
1080
1083
  const outputsMap = React.useMemo(() => runner.getOutputs(def), [runner, def, valuesTick]);
1084
+ const outputTypesMap = React.useMemo(() => {
1085
+ const out = {};
1086
+ // Local: runtimeTypeId is not stored; derive from typed wrapper in outputsMap
1087
+ for (const n of def.nodes) {
1088
+ const handles = Object.keys(registry.nodes.get(n.typeId)?.outputs ?? {});
1089
+ const cur = {};
1090
+ for (const h of handles) {
1091
+ const v = outputsMap[n.nodeId]?.[h];
1092
+ cur[h] = sparkGraph.getTypedOutputTypeId(v);
1093
+ }
1094
+ if (Object.keys(cur).length > 0)
1095
+ out[n.nodeId] = cur;
1096
+ }
1097
+ return out;
1098
+ }, [def, outputsMap, registry]);
1081
1099
  // Initialize nodes as invalidated by default until first successful run
1082
1100
  React.useEffect(() => {
1083
1101
  setNodeStatus((prev) => {
@@ -1425,6 +1443,7 @@ function WorkbenchProvider({ wb, runner, registry, setRegistry, children, }) {
1425
1443
  valuesTick,
1426
1444
  inputsMap,
1427
1445
  outputsMap,
1446
+ outputTypesMap,
1428
1447
  validationByNode,
1429
1448
  validationByEdge,
1430
1449
  validationGlobal,
@@ -1521,7 +1540,7 @@ function Inspector({ debug, autoScroll, hideWorkbench, onAutoScrollChange, onHid
1521
1540
  return String(value ?? "");
1522
1541
  }
1523
1542
  };
1524
- const { registry, def, selectedNodeId, selectedEdgeId, inputsMap, outputsMap, nodeStatus, validationByNode, validationByEdge, validationGlobal, valuesTick, } = useWorkbenchContext();
1543
+ const { registry, def, selectedNodeId, selectedEdgeId, inputsMap, outputsMap, outputTypesMap, nodeStatus, validationByNode, validationByEdge, validationGlobal, valuesTick, } = useWorkbenchContext();
1525
1544
  const nodeValidationIssues = validationByNode.issues;
1526
1545
  const edgeValidationIssues = validationByEdge.issues;
1527
1546
  const nodeValidationHandles = validationByNode;
@@ -1644,7 +1663,7 @@ function Inspector({ debug, autoScroll, hideWorkbench, onAutoScrollChange, onHid
1644
1663
  if (e.key === "Escape")
1645
1664
  revert();
1646
1665
  }, ...commonProps }))] }, h));
1647
- }))] }), jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("div", { className: "font-semibold mb-1", children: "Outputs" }), outputHandles.length === 0 ? (jsxRuntime.jsx("div", { className: "text-gray-500", children: "No outputs" })) : (outputHandles.map((h) => (jsxRuntime.jsxs("div", { className: "flex items-center gap-2 mb-1", children: [jsxRuntime.jsx("label", { className: "w-20", children: h }), jsxRuntime.jsx("div", { className: "flex-1", children: (() => {
1666
+ }))] }), jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("div", { className: "font-semibold mb-1", children: "Outputs" }), outputHandles.length === 0 ? (jsxRuntime.jsx("div", { className: "text-gray-500", children: "No outputs" })) : (outputHandles.map((h) => (jsxRuntime.jsxs("div", { className: "flex items-center gap-2 mb-1", children: [jsxRuntime.jsxs("label", { className: "w-20 flex flex-col", children: [jsxRuntime.jsx("span", { children: h }), jsxRuntime.jsx("span", { className: "text-gray-500 text-[11px]", children: outputTypesMap[selectedNodeId]?.[h] ?? "" })] }), jsxRuntime.jsx("div", { className: "flex-1", children: (() => {
1648
1667
  const { typeId, value } = resolveOutputDisplay(nodeOutputs[h], selectedDesc?.outputs?.[h]);
1649
1668
  return toElement(typeId, value);
1650
1669
  })() }), (() => {
@@ -2308,7 +2327,7 @@ function WorkbenchStudioCanvas({ setRegistry, autoScroll, onAutoScrollChange, ex
2308
2327
  return "";
2309
2328
  // Normalize typed wrapper
2310
2329
  if (sparkGraph.isTypedOutput(value)) {
2311
- return baseToString(String(value.__spark_type), value.__spark_value);
2330
+ return baseToString(sparkGraph.getTypedOutputTypeId(value), sparkGraph.getTypedOutputValue(value));
2312
2331
  }
2313
2332
  const pre = preformatValueForDisplay(typeId, value, registry);
2314
2333
  if (pre !== undefined)