@particle-academy/fancy-flow 0.22.0 → 0.24.0

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.
Files changed (39) hide show
  1. package/dist/{chunk-ZB4HHQMR.js → chunk-OWENS2H5.js} +11 -3
  2. package/dist/chunk-OWENS2H5.js.map +1 -0
  3. package/dist/{chunk-YZTBRXBZ.js → chunk-QAA4CA22.js} +8 -4
  4. package/dist/chunk-QAA4CA22.js.map +1 -0
  5. package/dist/{chunk-O7F6SGV4.js → chunk-ZS6DVGB3.js} +17 -5
  6. package/dist/chunk-ZS6DVGB3.js.map +1 -0
  7. package/dist/engine.js +1 -1
  8. package/dist/index.cjs +2409 -525
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.d.cts +15 -5
  11. package/dist/index.d.ts +15 -5
  12. package/dist/index.js +182 -37
  13. package/dist/index.js.map +1 -1
  14. package/dist/layout/index.d.cts +30 -0
  15. package/dist/layout/index.d.ts +30 -0
  16. package/dist/layout.cjs +1693 -0
  17. package/dist/layout.cjs.map +1 -0
  18. package/dist/layout.js +1691 -0
  19. package/dist/layout.js.map +1 -0
  20. package/dist/registry/index.d.cts +2 -2
  21. package/dist/registry/index.d.ts +2 -2
  22. package/dist/registry.cjs +4 -0
  23. package/dist/registry.cjs.map +1 -1
  24. package/dist/registry.js +3 -3
  25. package/dist/runtime/index.d.cts +13 -1
  26. package/dist/runtime/index.d.ts +13 -1
  27. package/dist/runtime.cjs +13 -1
  28. package/dist/runtime.cjs.map +1 -1
  29. package/dist/runtime.js +2 -2
  30. package/dist/styles.css +20 -0
  31. package/dist/styles.css.map +1 -1
  32. package/dist/{types-DneUoivl.d.cts → types-BekE5JTG.d.cts} +7 -0
  33. package/dist/{types-CFEtuRWJ.d.ts → types-DwRpXXNy.d.ts} +7 -0
  34. package/dist/ux.d.cts +1 -1
  35. package/dist/ux.d.ts +1 -1
  36. package/package.json +12 -1
  37. package/dist/chunk-O7F6SGV4.js.map +0 -1
  38. package/dist/chunk-YZTBRXBZ.js.map +0 -1
  39. package/dist/chunk-ZB4HHQMR.js.map +0 -1
package/dist/registry.js CHANGED
@@ -1,10 +1,10 @@
1
- export { ANY_PORT_TYPE, BUILTIN_KINDS, DEFAULT_MAX_DEPTH, RegistryNode, buildNodeTypes, createConnectionValidator, declaredRoutes, defaultPortCompatibility, llmRouterExecutor as llmBranchExecutor, llmRouterExecutor, registerBuiltinKinds, resolveFallbackPort, subflowExecutor, subflowMode, subflowPorts } from './chunk-YZTBRXBZ.js';
2
- import './chunk-ZB4HHQMR.js';
1
+ export { ANY_PORT_TYPE, BUILTIN_KINDS, DEFAULT_MAX_DEPTH, RegistryNode, buildNodeTypes, createConnectionValidator, declaredRoutes, defaultPortCompatibility, llmRouterExecutor as llmBranchExecutor, llmRouterExecutor, registerBuiltinKinds, resolveFallbackPort, subflowExecutor, subflowMode, subflowPorts } from './chunk-QAA4CA22.js';
2
+ import './chunk-OWENS2H5.js';
3
3
  export { LEGACY_PAUSE_PREFIXES, PAUSE_PREFIX, decodePause, encodePause, isPause, pauseForHuman } from './chunk-UEOE6B52.js';
4
+ export { capabilityStatus, getLlmClient, getWorkflowResolver, isResolutionFailure, registerLlmClient, registerWorkflowResolver } from './chunk-USL4FMFU.js';
4
5
  import './chunk-KDHLKBL2.js';
5
6
  export { nodeConfig, resolveNodePorts, resolvePortSpec } from './chunk-TITD5W4Y.js';
6
7
  export { categoryAccent, defaultConfigFor, getNodeKind, kindIds, listNodeKinds, onNodeKindsChanged, registerNodeKind, resolveKindId, validateConfig } from './chunk-YXRLIV7A.js';
7
8
  export { RichInputPreview, getRichInputAdapter, isRichInputEnabled, onRichInputAdapterChanged, registerRichInputAdapter } from './chunk-F5RPRB7A.js';
8
- export { capabilityStatus, getLlmClient, getWorkflowResolver, isResolutionFailure, registerLlmClient, registerWorkflowResolver } from './chunk-USL4FMFU.js';
9
9
  //# sourceMappingURL=registry.js.map
10
10
  //# sourceMappingURL=registry.js.map
@@ -16,6 +16,8 @@ type UseFlowRunReturn = {
16
16
  statuses: Record<string, NodeRunStatus>;
17
17
  /** Per-node status text (e.g. error message). */
18
18
  statusText: Record<string, string | undefined>;
19
+ /** Latest computed output value per node (for reactive kinds). */
20
+ outputs: Record<string, unknown>;
19
21
  /** Live event log (capped to last N). */
20
22
  feed: FlowRunFeedEntry[];
21
23
  /** Whether a run is currently in progress. */
@@ -39,6 +41,16 @@ type UseFlowRunOptions = {
39
41
  * the per-node status badge renders.
40
42
  */
41
43
  declare function useFlowRun({ maxFeed }?: UseFlowRunOptions): UseFlowRunReturn;
44
+ /**
45
+ * Write each reactive kind's latest run output into its `data.output`, so its
46
+ * card can render the computed value live. Non-reactive kinds are returned
47
+ * untouched. Pair with `applyStatusesToNodes` before rendering.
48
+ */
49
+ declare function applyOutputsToNodes<TNode extends {
50
+ id: string;
51
+ type?: string;
52
+ data: any;
53
+ }>(nodes: TNode[], outputs: Record<string, unknown>): TNode[];
42
54
  /** Merge runtime statuses into nodes for rendering. */
43
55
  declare function applyStatusesToNodes<TNode extends {
44
56
  id: string;
@@ -122,4 +134,4 @@ type HistoryController = {
122
134
  };
123
135
  declare function createHistory(limit?: number): HistoryController;
124
136
 
125
- export { type FlowRunFeedEntry, type HistoryController, RunOptions, RunResult, type UseFlowHistoryReturn, type UseFlowRunOptions, type UseFlowRunReturn, type UseFlowStateReturn, applyStatusesToNodes, createHistory, useFlowHistory, useFlowRun, useFlowState };
137
+ export { type FlowRunFeedEntry, type HistoryController, RunOptions, RunResult, type UseFlowHistoryReturn, type UseFlowRunOptions, type UseFlowRunReturn, type UseFlowStateReturn, applyOutputsToNodes, applyStatusesToNodes, createHistory, useFlowHistory, useFlowRun, useFlowState };
@@ -16,6 +16,8 @@ type UseFlowRunReturn = {
16
16
  statuses: Record<string, NodeRunStatus>;
17
17
  /** Per-node status text (e.g. error message). */
18
18
  statusText: Record<string, string | undefined>;
19
+ /** Latest computed output value per node (for reactive kinds). */
20
+ outputs: Record<string, unknown>;
19
21
  /** Live event log (capped to last N). */
20
22
  feed: FlowRunFeedEntry[];
21
23
  /** Whether a run is currently in progress. */
@@ -39,6 +41,16 @@ type UseFlowRunOptions = {
39
41
  * the per-node status badge renders.
40
42
  */
41
43
  declare function useFlowRun({ maxFeed }?: UseFlowRunOptions): UseFlowRunReturn;
44
+ /**
45
+ * Write each reactive kind's latest run output into its `data.output`, so its
46
+ * card can render the computed value live. Non-reactive kinds are returned
47
+ * untouched. Pair with `applyStatusesToNodes` before rendering.
48
+ */
49
+ declare function applyOutputsToNodes<TNode extends {
50
+ id: string;
51
+ type?: string;
52
+ data: any;
53
+ }>(nodes: TNode[], outputs: Record<string, unknown>): TNode[];
42
54
  /** Merge runtime statuses into nodes for rendering. */
43
55
  declare function applyStatusesToNodes<TNode extends {
44
56
  id: string;
@@ -122,4 +134,4 @@ type HistoryController = {
122
134
  };
123
135
  declare function createHistory(limit?: number): HistoryController;
124
136
 
125
- export { type FlowRunFeedEntry, type HistoryController, RunOptions, RunResult, type UseFlowHistoryReturn, type UseFlowRunOptions, type UseFlowRunReturn, type UseFlowStateReturn, applyStatusesToNodes, createHistory, useFlowHistory, useFlowRun, useFlowState };
137
+ export { type FlowRunFeedEntry, type HistoryController, RunOptions, RunResult, type UseFlowHistoryReturn, type UseFlowRunOptions, type UseFlowRunReturn, type UseFlowStateReturn, applyOutputsToNodes, applyStatusesToNodes, createHistory, useFlowHistory, useFlowRun, useFlowState };
package/dist/runtime.cjs CHANGED
@@ -198,6 +198,7 @@ function activatedPorts(node, result) {
198
198
  function useFlowRun({ maxFeed = 200 } = {}) {
199
199
  const [statuses, setStatuses] = ReactExports.useState({});
200
200
  const [statusText, setStatusText] = ReactExports.useState({});
201
+ const [outputs, setOutputs] = ReactExports.useState({});
201
202
  const [feed, setFeed] = ReactExports.useState([]);
202
203
  const [running, setRunning] = ReactExports.useState(false);
203
204
  const [lastResult, setLastResult] = ReactExports.useState(null);
@@ -211,6 +212,7 @@ function useFlowRun({ maxFeed = 200 } = {}) {
211
212
  appendFeed({ level: "status", text: `${e.nodeId} \u2192 ${e.status}${e.text ? ` (${e.text})` : ""}`, nodeId: e.nodeId });
212
213
  break;
213
214
  case "node-output":
215
+ setOutputs((o) => ({ ...o, [e.nodeId]: e.value }));
214
216
  appendFeed({ level: "info", text: `${e.nodeId}.${e.portId} = ${preview(e.value)}`, nodeId: e.nodeId, detail: e.value });
215
217
  break;
216
218
  case "log":
@@ -247,6 +249,7 @@ function useFlowRun({ maxFeed = 200 } = {}) {
247
249
  for (const n of graph.nodes) idleStatuses[n.id] = "idle";
248
250
  setStatuses(idleStatuses);
249
251
  setStatusText({});
252
+ setOutputs({});
250
253
  setRunning(true);
251
254
  try {
252
255
  const result = await runFlow(graph, executors, handleEvent, { ...options, signal: controller.signal });
@@ -263,10 +266,18 @@ function useFlowRun({ maxFeed = 200 } = {}) {
263
266
  const reset = ReactExports.useCallback(() => {
264
267
  setStatuses({});
265
268
  setStatusText({});
269
+ setOutputs({});
266
270
  setFeed([]);
267
271
  setLastResult(null);
268
272
  }, []);
269
- return { statuses, statusText, feed, running, lastResult, run, cancel, reset };
273
+ return { statuses, statusText, outputs, feed, running, lastResult, run, cancel, reset };
274
+ }
275
+ function applyOutputsToNodes(nodes, outputs) {
276
+ return nodes.map((n) => {
277
+ const kind = getNodeKind(n.data?.kind ?? n.type ?? "");
278
+ if (!kind?.reactive || !(n.id in outputs)) return n;
279
+ return { ...n, data: { ...n.data, output: outputs[n.id] } };
280
+ });
270
281
  }
271
282
  function applyStatusesToNodes(nodes, statuses, statusText) {
272
283
  return nodes.map((n) => ({
@@ -9313,6 +9324,7 @@ function useFlowHistory(flow) {
9313
9324
  };
9314
9325
  }
9315
9326
 
9327
+ exports.applyOutputsToNodes = applyOutputsToNodes;
9316
9328
  exports.applyStatusesToNodes = applyStatusesToNodes;
9317
9329
  exports.createHistory = createHistory;
9318
9330
  exports.runFlow = runFlow;