@goplasmatic/dataflow-ui 2.0.4 → 2.0.6
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/README.md +46 -3
- package/dist/index.cjs +547 -77
- package/dist/index.d.ts +44 -1
- package/dist/index.js +547 -77
- package/package.json +5 -3
package/dist/index.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1
4
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
5
|
import require$$0, { createContext, useState, useEffect, useContext, forwardRef, createElement, useReducer, useRef, useCallback, memo, useMemo, useLayoutEffect, Component } from "react";
|
|
3
6
|
import { createPortal } from "react-dom";
|
|
@@ -241,6 +244,21 @@ const FileJson = createLucideIcon("FileJson", [
|
|
|
241
244
|
{ d: "M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1", key: "mpwhp6" }
|
|
242
245
|
]
|
|
243
246
|
]);
|
|
247
|
+
/**
|
|
248
|
+
* @license lucide-react v0.462.0 - ISC
|
|
249
|
+
*
|
|
250
|
+
* This source code is licensed under the ISC license.
|
|
251
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
252
|
+
*/
|
|
253
|
+
const Folder = createLucideIcon("Folder", [
|
|
254
|
+
[
|
|
255
|
+
"path",
|
|
256
|
+
{
|
|
257
|
+
d: "M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",
|
|
258
|
+
key: "1kt360"
|
|
259
|
+
}
|
|
260
|
+
]
|
|
261
|
+
]);
|
|
244
262
|
/**
|
|
245
263
|
* @license lucide-react v0.462.0 - ISC
|
|
246
264
|
*
|
|
@@ -626,7 +644,8 @@ const DebuggerContext = createContext(null);
|
|
|
626
644
|
function DebuggerProvider({
|
|
627
645
|
children: children2,
|
|
628
646
|
initialPayload,
|
|
629
|
-
autoActivate = false
|
|
647
|
+
autoActivate = false,
|
|
648
|
+
engineFactory
|
|
630
649
|
}) {
|
|
631
650
|
const [state, dispatch2] = useReducer(debuggerReducer, {
|
|
632
651
|
...initialState,
|
|
@@ -634,6 +653,9 @@ function DebuggerProvider({
|
|
|
634
653
|
isActive: autoActivate
|
|
635
654
|
});
|
|
636
655
|
const playbackTimerRef = useRef(null);
|
|
656
|
+
const engineRef = useRef(null);
|
|
657
|
+
const lastWorkflowsJsonRef = useRef(null);
|
|
658
|
+
const isEngineReady = Boolean(engineFactory);
|
|
637
659
|
const activate = useCallback(() => dispatch2({ type: "ACTIVATE" }), []);
|
|
638
660
|
const deactivate = useCallback(() => dispatch2({ type: "DEACTIVATE" }), []);
|
|
639
661
|
const setInputPayload = useCallback(
|
|
@@ -657,6 +679,38 @@ function DebuggerProvider({
|
|
|
657
679
|
const stepBackward = useCallback(() => dispatch2({ type: "STEP_BACKWARD" }), []);
|
|
658
680
|
const goToStep = useCallback((index2) => dispatch2({ type: "GO_TO_STEP", index: index2 }), []);
|
|
659
681
|
const setSpeed = useCallback((speed) => dispatch2({ type: "SET_SPEED", speed }), []);
|
|
682
|
+
const runExecution = useCallback(
|
|
683
|
+
async (workflows, payload) => {
|
|
684
|
+
var _a;
|
|
685
|
+
if (workflows.length === 0 || !engineFactory) {
|
|
686
|
+
return null;
|
|
687
|
+
}
|
|
688
|
+
try {
|
|
689
|
+
const workflowsJson = JSON.stringify(workflows);
|
|
690
|
+
if (lastWorkflowsJsonRef.current !== workflowsJson || !engineRef.current) {
|
|
691
|
+
if ((_a = engineRef.current) == null ? void 0 : _a.dispose) {
|
|
692
|
+
engineRef.current.dispose();
|
|
693
|
+
}
|
|
694
|
+
engineRef.current = engineFactory(workflows);
|
|
695
|
+
lastWorkflowsJsonRef.current = workflowsJson;
|
|
696
|
+
}
|
|
697
|
+
return await engineRef.current.processWithTrace(payload);
|
|
698
|
+
} catch (error) {
|
|
699
|
+
console.error("Execution error:", error);
|
|
700
|
+
throw error;
|
|
701
|
+
}
|
|
702
|
+
},
|
|
703
|
+
[engineFactory]
|
|
704
|
+
);
|
|
705
|
+
useEffect(() => {
|
|
706
|
+
return () => {
|
|
707
|
+
var _a;
|
|
708
|
+
if ((_a = engineRef.current) == null ? void 0 : _a.dispose) {
|
|
709
|
+
engineRef.current.dispose();
|
|
710
|
+
engineRef.current = null;
|
|
711
|
+
}
|
|
712
|
+
};
|
|
713
|
+
}, []);
|
|
660
714
|
useEffect(() => {
|
|
661
715
|
if (state.playbackState === "playing") {
|
|
662
716
|
playbackTimerRef.current = window.setInterval(() => {
|
|
@@ -699,6 +753,7 @@ function DebuggerProvider({
|
|
|
699
753
|
stepBackward,
|
|
700
754
|
goToStep,
|
|
701
755
|
setSpeed,
|
|
756
|
+
runExecution,
|
|
702
757
|
currentStep,
|
|
703
758
|
currentMessage,
|
|
704
759
|
currentChanges,
|
|
@@ -706,7 +761,8 @@ function DebuggerProvider({
|
|
|
706
761
|
isAtEnd,
|
|
707
762
|
hasTrace,
|
|
708
763
|
progress,
|
|
709
|
-
totalSteps
|
|
764
|
+
totalSteps,
|
|
765
|
+
isEngineReady
|
|
710
766
|
};
|
|
711
767
|
return /* @__PURE__ */ jsx(DebuggerContext.Provider, { value, children: children2 });
|
|
712
768
|
}
|
|
@@ -9607,9 +9663,9 @@ function ResizeControl({ nodeId, position, variant = ResizeControlVariant.Handle
|
|
|
9607
9663
|
}, children: children2 });
|
|
9608
9664
|
}
|
|
9609
9665
|
memo(ResizeControl);
|
|
9610
|
-
var
|
|
9611
|
-
var
|
|
9612
|
-
var
|
|
9666
|
+
var __defProp2 = Object.defineProperty;
|
|
9667
|
+
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9668
|
+
var __publicField2 = (obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
9613
9669
|
let CATEGORY_COLORS, DataLogicEditor, OPERATORS, applyTreeLayout, jsonLogicToNodes;
|
|
9614
9670
|
(async () => {
|
|
9615
9671
|
const BRANCH_COLORS = {
|
|
@@ -13343,23 +13399,23 @@ let CATEGORY_COLORS, DataLogicEditor, OPERATORS, applyTreeLayout, jsonLogicToNod
|
|
|
13343
13399
|
var EDGE_KEY_DELIM = "";
|
|
13344
13400
|
class Graph {
|
|
13345
13401
|
constructor(opts) {
|
|
13346
|
-
|
|
13347
|
-
|
|
13348
|
-
|
|
13349
|
-
|
|
13350
|
-
|
|
13351
|
-
|
|
13352
|
-
|
|
13353
|
-
|
|
13354
|
-
|
|
13355
|
-
|
|
13356
|
-
|
|
13357
|
-
|
|
13358
|
-
|
|
13359
|
-
|
|
13360
|
-
|
|
13361
|
-
|
|
13362
|
-
|
|
13402
|
+
__publicField2(this, "_isDirected", true);
|
|
13403
|
+
__publicField2(this, "_isMultigraph", false);
|
|
13404
|
+
__publicField2(this, "_isCompound", false);
|
|
13405
|
+
__publicField2(this, "_label");
|
|
13406
|
+
__publicField2(this, "_defaultNodeLabelFn", () => void 0);
|
|
13407
|
+
__publicField2(this, "_defaultEdgeLabelFn", () => void 0);
|
|
13408
|
+
__publicField2(this, "_nodes", {});
|
|
13409
|
+
__publicField2(this, "_in", {});
|
|
13410
|
+
__publicField2(this, "_preds", {});
|
|
13411
|
+
__publicField2(this, "_out", {});
|
|
13412
|
+
__publicField2(this, "_sucs", {});
|
|
13413
|
+
__publicField2(this, "_edgeObjs", {});
|
|
13414
|
+
__publicField2(this, "_edgeLabels", {});
|
|
13415
|
+
__publicField2(this, "_nodeCount", 0);
|
|
13416
|
+
__publicField2(this, "_edgeCount", 0);
|
|
13417
|
+
__publicField2(this, "_parent");
|
|
13418
|
+
__publicField2(this, "_children");
|
|
13363
13419
|
if (opts) {
|
|
13364
13420
|
this._isDirected = Object.hasOwn(opts, "directed") ? opts.directed : true;
|
|
13365
13421
|
this._isMultigraph = Object.hasOwn(opts, "multigraph") ? opts.multigraph : false;
|
|
@@ -13891,8 +13947,8 @@ let CATEGORY_COLORS, DataLogicEditor, OPERATORS, applyTreeLayout, jsonLogicToNod
|
|
|
13891
13947
|
hasRequiredPriorityQueue = 1;
|
|
13892
13948
|
class PriorityQueue {
|
|
13893
13949
|
constructor() {
|
|
13894
|
-
|
|
13895
|
-
|
|
13950
|
+
__publicField2(this, "_arr", []);
|
|
13951
|
+
__publicField2(this, "_keyIndices", {});
|
|
13896
13952
|
}
|
|
13897
13953
|
size() {
|
|
13898
13954
|
return this._arr.length;
|
|
@@ -17572,13 +17628,13 @@ let CATEGORY_COLORS, DataLogicEditor, OPERATORS, applyTreeLayout, jsonLogicToNod
|
|
|
17572
17628
|
try {
|
|
17573
17629
|
setLoading(true);
|
|
17574
17630
|
setError(null);
|
|
17575
|
-
const
|
|
17576
|
-
await
|
|
17631
|
+
const wasm2 = await import("./datalogic_wasm-4utZNR2J-DW6r1ZIK.js");
|
|
17632
|
+
await wasm2.default();
|
|
17577
17633
|
if (!cancelled) {
|
|
17578
17634
|
moduleRef.current = {
|
|
17579
|
-
evaluate:
|
|
17580
|
-
evaluate_with_trace:
|
|
17581
|
-
CompiledRule:
|
|
17635
|
+
evaluate: wasm2.evaluate,
|
|
17636
|
+
evaluate_with_trace: wasm2.evaluate_with_trace,
|
|
17637
|
+
CompiledRule: wasm2.CompiledRule
|
|
17582
17638
|
};
|
|
17583
17639
|
setReady(true);
|
|
17584
17640
|
setLoading(false);
|
|
@@ -19852,31 +19908,38 @@ function TreeNode({
|
|
|
19852
19908
|
};
|
|
19853
19909
|
const debugStateClass = debugState ? `df-tree-node-${debugState}` : "";
|
|
19854
19910
|
const currentClass = isCurrent ? "df-tree-node-current-step" : "";
|
|
19855
|
-
return /* @__PURE__ */ jsxs(
|
|
19856
|
-
|
|
19857
|
-
|
|
19858
|
-
{
|
|
19859
|
-
|
|
19860
|
-
|
|
19861
|
-
|
|
19862
|
-
|
|
19863
|
-
|
|
19864
|
-
"
|
|
19865
|
-
{
|
|
19866
|
-
|
|
19867
|
-
|
|
19868
|
-
|
|
19869
|
-
|
|
19870
|
-
|
|
19871
|
-
|
|
19872
|
-
|
|
19873
|
-
|
|
19874
|
-
|
|
19875
|
-
|
|
19876
|
-
|
|
19877
|
-
|
|
19878
|
-
|
|
19879
|
-
|
|
19911
|
+
return /* @__PURE__ */ jsxs(
|
|
19912
|
+
"div",
|
|
19913
|
+
{
|
|
19914
|
+
className: `df-tree-node ${debugStateClass} ${currentClass}`,
|
|
19915
|
+
"data-current-step": isCurrent ? "true" : void 0,
|
|
19916
|
+
children: [
|
|
19917
|
+
/* @__PURE__ */ jsxs(
|
|
19918
|
+
"div",
|
|
19919
|
+
{
|
|
19920
|
+
className: `df-tree-node-content ${isSelected ? "df-tree-node-selected" : ""}`,
|
|
19921
|
+
style: { paddingLeft: `${level * 16 + 8}px` },
|
|
19922
|
+
onClick: handleClick,
|
|
19923
|
+
children: [
|
|
19924
|
+
/* @__PURE__ */ jsx(
|
|
19925
|
+
"span",
|
|
19926
|
+
{
|
|
19927
|
+
className: "df-tree-toggle",
|
|
19928
|
+
onClick: hasChildren ? handleToggle : void 0,
|
|
19929
|
+
style: { visibility: hasChildren ? "visible" : "hidden" },
|
|
19930
|
+
children: isExpanded ? /* @__PURE__ */ jsx(ChevronDown, { size: 14 }) : /* @__PURE__ */ jsx(ChevronRight, { size: 14 })
|
|
19931
|
+
}
|
|
19932
|
+
),
|
|
19933
|
+
icon && /* @__PURE__ */ jsx("span", { className: "df-tree-icon", style: iconColor ? { color: iconColor } : void 0, children: icon }),
|
|
19934
|
+
/* @__PURE__ */ jsx("span", { className: "df-tree-label", children: label }),
|
|
19935
|
+
debugState && /* @__PURE__ */ jsx("span", { className: "df-tree-debug-indicator", children: /* @__PURE__ */ jsx(DebugStateIcon, { state: debugState, conditionResult }) })
|
|
19936
|
+
]
|
|
19937
|
+
}
|
|
19938
|
+
),
|
|
19939
|
+
isExpanded && hasChildren && /* @__PURE__ */ jsx("div", { className: "df-tree-children", children: children2 })
|
|
19940
|
+
]
|
|
19941
|
+
}
|
|
19942
|
+
);
|
|
19880
19943
|
}
|
|
19881
19944
|
const TREE_COLORS = {
|
|
19882
19945
|
workflow: "#0078d4",
|
|
@@ -19889,8 +19952,10 @@ const TREE_COLORS = {
|
|
|
19889
19952
|
// VSCode teal/green
|
|
19890
19953
|
validation: "#ce9178",
|
|
19891
19954
|
// VSCode orange
|
|
19892
|
-
tasks: "#9d9d9d"
|
|
19955
|
+
tasks: "#9d9d9d",
|
|
19893
19956
|
// VSCode gray
|
|
19957
|
+
folder: "#dcb67a"
|
|
19958
|
+
// VSCode folder yellow/gold
|
|
19894
19959
|
};
|
|
19895
19960
|
function TaskNode({
|
|
19896
19961
|
task,
|
|
@@ -20089,20 +20154,177 @@ function WorkflowNode({
|
|
|
20089
20154
|
}
|
|
20090
20155
|
);
|
|
20091
20156
|
}
|
|
20157
|
+
function FolderNode({
|
|
20158
|
+
folder,
|
|
20159
|
+
level,
|
|
20160
|
+
selection: selection2,
|
|
20161
|
+
onSelect,
|
|
20162
|
+
expandedNodes,
|
|
20163
|
+
toggleNode,
|
|
20164
|
+
debugMode = false
|
|
20165
|
+
}) {
|
|
20166
|
+
const folderId = `folder-${folder.fullPath}`;
|
|
20167
|
+
const isExpanded = expandedNodes.has(folderId);
|
|
20168
|
+
const hasChildren = folder.folders.size > 0 || folder.workflows.length > 0;
|
|
20169
|
+
const sortedFolders = Array.from(folder.folders.values()).sort(
|
|
20170
|
+
(a, b) => a.name.localeCompare(b.name)
|
|
20171
|
+
);
|
|
20172
|
+
return /* @__PURE__ */ jsxs(
|
|
20173
|
+
TreeNode,
|
|
20174
|
+
{
|
|
20175
|
+
label: `${folder.name} (${folder.totalWorkflowCount})`,
|
|
20176
|
+
icon: /* @__PURE__ */ jsx(Folder, { size: 14 }),
|
|
20177
|
+
iconColor: TREE_COLORS.folder,
|
|
20178
|
+
isExpanded,
|
|
20179
|
+
hasChildren,
|
|
20180
|
+
level,
|
|
20181
|
+
onToggle: () => toggleNode(folderId),
|
|
20182
|
+
onClick: () => toggleNode(folderId),
|
|
20183
|
+
children: [
|
|
20184
|
+
sortedFolders.map((childFolder) => /* @__PURE__ */ jsx(
|
|
20185
|
+
FolderNode,
|
|
20186
|
+
{
|
|
20187
|
+
folder: childFolder,
|
|
20188
|
+
level: level + 1,
|
|
20189
|
+
selection: selection2,
|
|
20190
|
+
onSelect,
|
|
20191
|
+
expandedNodes,
|
|
20192
|
+
toggleNode,
|
|
20193
|
+
debugMode
|
|
20194
|
+
},
|
|
20195
|
+
childFolder.fullPath
|
|
20196
|
+
)),
|
|
20197
|
+
folder.workflows.map((workflow) => /* @__PURE__ */ jsx(
|
|
20198
|
+
WorkflowNode,
|
|
20199
|
+
{
|
|
20200
|
+
workflow,
|
|
20201
|
+
level: level + 1,
|
|
20202
|
+
selection: selection2,
|
|
20203
|
+
onSelect,
|
|
20204
|
+
expandedNodes,
|
|
20205
|
+
toggleNode,
|
|
20206
|
+
debugMode
|
|
20207
|
+
},
|
|
20208
|
+
workflow.id
|
|
20209
|
+
))
|
|
20210
|
+
]
|
|
20211
|
+
}
|
|
20212
|
+
);
|
|
20213
|
+
}
|
|
20214
|
+
function parsePath(path) {
|
|
20215
|
+
if (!path) return [];
|
|
20216
|
+
const trimmed = path.replace(/^\/+|\/+$/g, "");
|
|
20217
|
+
if (!trimmed) return [];
|
|
20218
|
+
return trimmed.split("/").filter((segment) => segment.length > 0);
|
|
20219
|
+
}
|
|
20220
|
+
function createFolderNode(name, fullPath) {
|
|
20221
|
+
return {
|
|
20222
|
+
name,
|
|
20223
|
+
fullPath,
|
|
20224
|
+
folders: /* @__PURE__ */ new Map(),
|
|
20225
|
+
workflows: [],
|
|
20226
|
+
totalWorkflowCount: 0
|
|
20227
|
+
};
|
|
20228
|
+
}
|
|
20229
|
+
function calculateTotalCount(node) {
|
|
20230
|
+
let count = node.workflows.length;
|
|
20231
|
+
for (const child of node.folders.values()) {
|
|
20232
|
+
count += calculateTotalCount(child);
|
|
20233
|
+
}
|
|
20234
|
+
node.totalWorkflowCount = count;
|
|
20235
|
+
return count;
|
|
20236
|
+
}
|
|
20237
|
+
function buildFolderTree(workflows) {
|
|
20238
|
+
const tree = {
|
|
20239
|
+
folders: /* @__PURE__ */ new Map(),
|
|
20240
|
+
workflows: []
|
|
20241
|
+
};
|
|
20242
|
+
const sortedWorkflows = [...workflows].sort((a, b) => (a.priority ?? 0) - (b.priority ?? 0));
|
|
20243
|
+
for (const workflow of sortedWorkflows) {
|
|
20244
|
+
const segments = parsePath(workflow.path);
|
|
20245
|
+
if (segments.length === 0) {
|
|
20246
|
+
tree.workflows.push(workflow);
|
|
20247
|
+
} else {
|
|
20248
|
+
let currentLevel = tree.folders;
|
|
20249
|
+
let currentPath = "";
|
|
20250
|
+
for (let i = 0; i < segments.length; i++) {
|
|
20251
|
+
const segment = segments[i];
|
|
20252
|
+
currentPath = currentPath ? `${currentPath}/${segment}` : segment;
|
|
20253
|
+
if (!currentLevel.has(segment)) {
|
|
20254
|
+
currentLevel.set(segment, createFolderNode(segment, currentPath));
|
|
20255
|
+
}
|
|
20256
|
+
const folder = currentLevel.get(segment);
|
|
20257
|
+
if (i === segments.length - 1) {
|
|
20258
|
+
folder.workflows.push(workflow);
|
|
20259
|
+
} else {
|
|
20260
|
+
currentLevel = folder.folders;
|
|
20261
|
+
}
|
|
20262
|
+
}
|
|
20263
|
+
}
|
|
20264
|
+
}
|
|
20265
|
+
for (const folder of tree.folders.values()) {
|
|
20266
|
+
calculateTotalCount(folder);
|
|
20267
|
+
}
|
|
20268
|
+
return tree;
|
|
20269
|
+
}
|
|
20270
|
+
function getFirstLevelFolderIds(tree) {
|
|
20271
|
+
return Array.from(tree.folders.keys()).map((name) => `folder-${name}`);
|
|
20272
|
+
}
|
|
20273
|
+
function getParentFolderIds(path) {
|
|
20274
|
+
const segments = parsePath(path);
|
|
20275
|
+
if (segments.length === 0) return [];
|
|
20276
|
+
const ids = [];
|
|
20277
|
+
let currentPath = "";
|
|
20278
|
+
for (const segment of segments) {
|
|
20279
|
+
currentPath = currentPath ? `${currentPath}/${segment}` : segment;
|
|
20280
|
+
ids.push(`folder-${currentPath}`);
|
|
20281
|
+
}
|
|
20282
|
+
return ids;
|
|
20283
|
+
}
|
|
20092
20284
|
function TreeView({ workflows, selection: selection2, onSelect, debugMode = false }) {
|
|
20093
20285
|
const debuggerContext = useDebugger();
|
|
20094
20286
|
const effectiveDebugContext = debugMode ? debuggerContext : null;
|
|
20287
|
+
const folderTree = useMemo(() => buildFolderTree(workflows), [workflows]);
|
|
20288
|
+
const sortedRootFolders = useMemo(() => {
|
|
20289
|
+
return Array.from(folderTree.folders.values()).sort(
|
|
20290
|
+
(a, b) => a.name.localeCompare(b.name)
|
|
20291
|
+
);
|
|
20292
|
+
}, [folderTree]);
|
|
20293
|
+
const rootWorkflows = folderTree.workflows;
|
|
20095
20294
|
const [expandedNodes, setExpandedNodes] = useState(() => {
|
|
20096
20295
|
const initial = /* @__PURE__ */ new Set(["workflows-root"]);
|
|
20097
|
-
|
|
20098
|
-
initial.add(`workflow-${workflows[0].id}`);
|
|
20099
|
-
}
|
|
20296
|
+
getFirstLevelFolderIds(folderTree).forEach((id2) => initial.add(id2));
|
|
20100
20297
|
return initial;
|
|
20101
20298
|
});
|
|
20102
|
-
|
|
20103
|
-
|
|
20104
|
-
|
|
20299
|
+
useEffect(() => {
|
|
20300
|
+
setExpandedNodes((prev) => {
|
|
20301
|
+
const next = new Set(prev);
|
|
20302
|
+
next.add("workflows-root");
|
|
20303
|
+
getFirstLevelFolderIds(folderTree).forEach((id2) => next.add(id2));
|
|
20304
|
+
return next;
|
|
20305
|
+
});
|
|
20306
|
+
}, [folderTree]);
|
|
20307
|
+
useEffect(() => {
|
|
20308
|
+
const allWorkflows = [...folderTree.workflows];
|
|
20309
|
+
function collectWorkflows(folders) {
|
|
20310
|
+
for (const folder of folders.values()) {
|
|
20311
|
+
allWorkflows.push(...folder.workflows);
|
|
20312
|
+
collectWorkflows(folder.folders);
|
|
20313
|
+
}
|
|
20314
|
+
}
|
|
20315
|
+
collectWorkflows(folderTree.folders);
|
|
20316
|
+
if (allWorkflows.length > 0) {
|
|
20317
|
+
allWorkflows.sort((a, b) => (a.priority ?? 0) - (b.priority ?? 0));
|
|
20318
|
+
setExpandedNodes((prev) => {
|
|
20319
|
+
const next = new Set(prev);
|
|
20320
|
+
next.add(`workflow-${allWorkflows[0].id}`);
|
|
20321
|
+
getParentFolderIds(allWorkflows[0].path).forEach((id2) => next.add(id2));
|
|
20322
|
+
return next;
|
|
20323
|
+
});
|
|
20324
|
+
}
|
|
20325
|
+
}, [folderTree]);
|
|
20105
20326
|
const lastSelectedRef = useRef(null);
|
|
20327
|
+
const treeContainerRef = useRef(null);
|
|
20106
20328
|
useEffect(() => {
|
|
20107
20329
|
var _a, _b;
|
|
20108
20330
|
if (!debugMode || !(effectiveDebugContext == null ? void 0 : effectiveDebugContext.currentStep) || effectiveDebugContext.state.currentStepIndex < 0) {
|
|
@@ -20112,9 +20334,13 @@ function TreeView({ workflows, selection: selection2, onSelect, debugMode = fals
|
|
|
20112
20334
|
if (((_a = lastSelectedRef.current) == null ? void 0 : _a.workflowId) === workflow_id && ((_b = lastSelectedRef.current) == null ? void 0 : _b.taskId) === task_id) {
|
|
20113
20335
|
return;
|
|
20114
20336
|
}
|
|
20337
|
+
const workflow = workflows.find((w) => w.id === workflow_id);
|
|
20115
20338
|
setExpandedNodes((prev) => {
|
|
20116
20339
|
const next = new Set(prev);
|
|
20117
20340
|
next.add("workflows-root");
|
|
20341
|
+
if (workflow == null ? void 0 : workflow.path) {
|
|
20342
|
+
getParentFolderIds(workflow.path).forEach((id2) => next.add(id2));
|
|
20343
|
+
}
|
|
20118
20344
|
next.add(`workflow-${workflow_id}`);
|
|
20119
20345
|
next.add(`tasks-${workflow_id}`);
|
|
20120
20346
|
if (task_id) {
|
|
@@ -20123,7 +20349,6 @@ function TreeView({ workflows, selection: selection2, onSelect, debugMode = fals
|
|
|
20123
20349
|
return next;
|
|
20124
20350
|
});
|
|
20125
20351
|
if (task_id) {
|
|
20126
|
-
const workflow = workflows.find((w) => w.id === workflow_id);
|
|
20127
20352
|
const task = workflow == null ? void 0 : workflow.tasks.find((t) => t.id === task_id);
|
|
20128
20353
|
if (workflow && task) {
|
|
20129
20354
|
lastSelectedRef.current = { workflowId: workflow_id, taskId: task_id };
|
|
@@ -20132,6 +20357,16 @@ function TreeView({ workflows, selection: selection2, onSelect, debugMode = fals
|
|
|
20132
20357
|
} else {
|
|
20133
20358
|
lastSelectedRef.current = { workflowId: workflow_id };
|
|
20134
20359
|
}
|
|
20360
|
+
setTimeout(() => {
|
|
20361
|
+
var _a2;
|
|
20362
|
+
const currentStepElement = (_a2 = treeContainerRef.current) == null ? void 0 : _a2.querySelector('[data-current-step="true"]');
|
|
20363
|
+
if (currentStepElement) {
|
|
20364
|
+
currentStepElement.scrollIntoView({
|
|
20365
|
+
behavior: "smooth",
|
|
20366
|
+
block: "nearest"
|
|
20367
|
+
});
|
|
20368
|
+
}
|
|
20369
|
+
}, 50);
|
|
20135
20370
|
}, [debugMode, effectiveDebugContext == null ? void 0 : effectiveDebugContext.currentStep, effectiveDebugContext == null ? void 0 : effectiveDebugContext.state.currentStepIndex, workflows, onSelect]);
|
|
20136
20371
|
const toggleNode = (id2) => {
|
|
20137
20372
|
setExpandedNodes((prev) => {
|
|
@@ -20145,30 +20380,46 @@ function TreeView({ workflows, selection: selection2, onSelect, debugMode = fals
|
|
|
20145
20380
|
});
|
|
20146
20381
|
};
|
|
20147
20382
|
const isRootExpanded = expandedNodes.has("workflows-root");
|
|
20148
|
-
|
|
20383
|
+
const totalWorkflowCount = workflows.length;
|
|
20384
|
+
return /* @__PURE__ */ jsx("div", { ref: treeContainerRef, className: `df-tree-view ${debugMode ? "df-tree-view-debug" : ""}`, children: /* @__PURE__ */ jsxs(
|
|
20149
20385
|
TreeNode,
|
|
20150
20386
|
{
|
|
20151
20387
|
label: "Workflows",
|
|
20152
20388
|
icon: /* @__PURE__ */ jsx(Layers, { size: 14 }),
|
|
20153
20389
|
iconColor: TREE_COLORS.workflow,
|
|
20154
20390
|
isExpanded: isRootExpanded,
|
|
20155
|
-
hasChildren:
|
|
20391
|
+
hasChildren: totalWorkflowCount > 0,
|
|
20156
20392
|
level: 0,
|
|
20157
20393
|
onToggle: () => toggleNode("workflows-root"),
|
|
20158
20394
|
onClick: () => toggleNode("workflows-root"),
|
|
20159
|
-
children:
|
|
20160
|
-
|
|
20161
|
-
|
|
20162
|
-
|
|
20163
|
-
|
|
20164
|
-
|
|
20165
|
-
|
|
20166
|
-
|
|
20167
|
-
|
|
20168
|
-
|
|
20169
|
-
|
|
20170
|
-
|
|
20171
|
-
|
|
20395
|
+
children: [
|
|
20396
|
+
sortedRootFolders.map((folder) => /* @__PURE__ */ jsx(
|
|
20397
|
+
FolderNode,
|
|
20398
|
+
{
|
|
20399
|
+
folder,
|
|
20400
|
+
level: 1,
|
|
20401
|
+
selection: selection2,
|
|
20402
|
+
onSelect,
|
|
20403
|
+
expandedNodes,
|
|
20404
|
+
toggleNode,
|
|
20405
|
+
debugMode
|
|
20406
|
+
},
|
|
20407
|
+
folder.fullPath
|
|
20408
|
+
)),
|
|
20409
|
+
rootWorkflows.map((workflow) => /* @__PURE__ */ jsx(
|
|
20410
|
+
WorkflowNode,
|
|
20411
|
+
{
|
|
20412
|
+
workflow,
|
|
20413
|
+
level: 1,
|
|
20414
|
+
selection: selection2,
|
|
20415
|
+
onSelect,
|
|
20416
|
+
expandedNodes,
|
|
20417
|
+
toggleNode,
|
|
20418
|
+
debugMode
|
|
20419
|
+
},
|
|
20420
|
+
workflow.id
|
|
20421
|
+
))
|
|
20422
|
+
]
|
|
20172
20423
|
}
|
|
20173
20424
|
) });
|
|
20174
20425
|
}
|
|
@@ -22021,6 +22272,223 @@ function DebugStateBadge({
|
|
|
22021
22272
|
conditionResult !== void 0 && /* @__PURE__ */ jsx("span", { className: `df-debug-badge-condition ${conditionResult ? "df-debug-badge-condition-pass" : "df-debug-badge-condition-fail"}`, children: conditionResult ? /* @__PURE__ */ jsx(Check, { size: iconSize }) : /* @__PURE__ */ jsx(X, { size: iconSize }) })
|
|
22022
22273
|
] });
|
|
22023
22274
|
}
|
|
22275
|
+
class WasmEngine {
|
|
22276
|
+
__destroy_into_raw() {
|
|
22277
|
+
const ptr = this.__wbg_ptr;
|
|
22278
|
+
this.__wbg_ptr = 0;
|
|
22279
|
+
WasmEngineFinalization.unregister(this);
|
|
22280
|
+
return ptr;
|
|
22281
|
+
}
|
|
22282
|
+
free() {
|
|
22283
|
+
const ptr = this.__destroy_into_raw();
|
|
22284
|
+
wasm.__wbg_wasmengine_free(ptr, 0);
|
|
22285
|
+
}
|
|
22286
|
+
/**
|
|
22287
|
+
* Create a new WasmEngine from a JSON array of workflow definitions.
|
|
22288
|
+
*
|
|
22289
|
+
* # Arguments
|
|
22290
|
+
* * `workflows_json` - JSON string containing an array of workflow definitions
|
|
22291
|
+
*
|
|
22292
|
+
* # Example
|
|
22293
|
+
* ```javascript
|
|
22294
|
+
* const workflows = JSON.stringify([{
|
|
22295
|
+
* id: "workflow1",
|
|
22296
|
+
* name: "My Workflow",
|
|
22297
|
+
* priority: 1,
|
|
22298
|
+
* tasks: [...]
|
|
22299
|
+
* }]);
|
|
22300
|
+
* const engine = new WasmEngine(workflows);
|
|
22301
|
+
* ```
|
|
22302
|
+
* @param {string} workflows_json
|
|
22303
|
+
*/
|
|
22304
|
+
constructor(workflows_json) {
|
|
22305
|
+
const ptr0 = passStringToWasm0(workflows_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
22306
|
+
const len0 = WASM_VECTOR_LEN;
|
|
22307
|
+
const ret = wasm.wasmengine_new(ptr0, len0);
|
|
22308
|
+
if (ret[2]) {
|
|
22309
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
22310
|
+
}
|
|
22311
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
22312
|
+
WasmEngineFinalization.register(this, this.__wbg_ptr, this);
|
|
22313
|
+
return this;
|
|
22314
|
+
}
|
|
22315
|
+
/**
|
|
22316
|
+
* Process a payload through the engine's workflows.
|
|
22317
|
+
*
|
|
22318
|
+
* This is an async operation that returns a Promise.
|
|
22319
|
+
*
|
|
22320
|
+
* # Arguments
|
|
22321
|
+
* * `payload_json` - JSON string of the payload to process
|
|
22322
|
+
*
|
|
22323
|
+
* # Returns
|
|
22324
|
+
* A Promise that resolves to the processed message as a JSON string
|
|
22325
|
+
*
|
|
22326
|
+
* # Example
|
|
22327
|
+
* ```javascript
|
|
22328
|
+
* const payload = JSON.stringify({ name: "John", email: "john@example.com" });
|
|
22329
|
+
* const result = await engine.process(payload);
|
|
22330
|
+
* const processed = JSON.parse(result);
|
|
22331
|
+
* console.log(processed.context.data);
|
|
22332
|
+
* ```
|
|
22333
|
+
* @param {string} payload_json
|
|
22334
|
+
* @returns {Promise<any>}
|
|
22335
|
+
*/
|
|
22336
|
+
process(payload_json) {
|
|
22337
|
+
const ptr0 = passStringToWasm0(payload_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
22338
|
+
const len0 = WASM_VECTOR_LEN;
|
|
22339
|
+
const ret = wasm.wasmengine_process(this.__wbg_ptr, ptr0, len0);
|
|
22340
|
+
return ret;
|
|
22341
|
+
}
|
|
22342
|
+
/**
|
|
22343
|
+
* Process a payload with step-by-step execution tracing.
|
|
22344
|
+
*
|
|
22345
|
+
* This is an async operation that returns a Promise with the execution trace.
|
|
22346
|
+
* The trace contains message snapshots after each step, including which
|
|
22347
|
+
* workflows/tasks were executed or skipped.
|
|
22348
|
+
*
|
|
22349
|
+
* # Arguments
|
|
22350
|
+
* * `payload_json` - JSON string of the payload to process
|
|
22351
|
+
*
|
|
22352
|
+
* # Returns
|
|
22353
|
+
* A Promise that resolves to the execution trace as a JSON string
|
|
22354
|
+
*
|
|
22355
|
+
* # Example
|
|
22356
|
+
* ```javascript
|
|
22357
|
+
* const payload = JSON.stringify({ name: "John", email: "john@example.com" });
|
|
22358
|
+
* const trace = await engine.process_with_trace(payload);
|
|
22359
|
+
* const traceData = JSON.parse(trace);
|
|
22360
|
+
* console.log(traceData.steps); // Array of execution steps
|
|
22361
|
+
* ```
|
|
22362
|
+
* @param {string} payload_json
|
|
22363
|
+
* @returns {Promise<any>}
|
|
22364
|
+
*/
|
|
22365
|
+
process_with_trace(payload_json) {
|
|
22366
|
+
const ptr0 = passStringToWasm0(payload_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
22367
|
+
const len0 = WASM_VECTOR_LEN;
|
|
22368
|
+
const ret = wasm.wasmengine_process_with_trace(this.__wbg_ptr, ptr0, len0);
|
|
22369
|
+
return ret;
|
|
22370
|
+
}
|
|
22371
|
+
/**
|
|
22372
|
+
* Get the number of workflows registered in the engine.
|
|
22373
|
+
* @returns {number}
|
|
22374
|
+
*/
|
|
22375
|
+
workflow_count() {
|
|
22376
|
+
const ret = wasm.wasmengine_workflow_count(this.__wbg_ptr);
|
|
22377
|
+
return ret >>> 0;
|
|
22378
|
+
}
|
|
22379
|
+
/**
|
|
22380
|
+
* Get the list of workflow IDs.
|
|
22381
|
+
*
|
|
22382
|
+
* # Returns
|
|
22383
|
+
* JSON array of workflow IDs as a string
|
|
22384
|
+
* @returns {string}
|
|
22385
|
+
*/
|
|
22386
|
+
workflow_ids() {
|
|
22387
|
+
let deferred1_0;
|
|
22388
|
+
let deferred1_1;
|
|
22389
|
+
try {
|
|
22390
|
+
const ret = wasm.wasmengine_workflow_ids(this.__wbg_ptr);
|
|
22391
|
+
deferred1_0 = ret[0];
|
|
22392
|
+
deferred1_1 = ret[1];
|
|
22393
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
22394
|
+
} finally {
|
|
22395
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
22396
|
+
}
|
|
22397
|
+
}
|
|
22398
|
+
}
|
|
22399
|
+
if (Symbol.dispose) WasmEngine.prototype[Symbol.dispose] = WasmEngine.prototype.free;
|
|
22400
|
+
const WasmEngineFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
|
|
22401
|
+
}, unregister: () => {
|
|
22402
|
+
} } : new FinalizationRegistry((ptr) => wasm.__wbg_wasmengine_free(ptr >>> 0, 1));
|
|
22403
|
+
typeof FinalizationRegistry === "undefined" ? {} : new FinalizationRegistry((state) => state.dtor(state.a, state.b));
|
|
22404
|
+
function getStringFromWasm0(ptr, len) {
|
|
22405
|
+
ptr = ptr >>> 0;
|
|
22406
|
+
return decodeText(ptr, len);
|
|
22407
|
+
}
|
|
22408
|
+
let cachedUint8ArrayMemory0 = null;
|
|
22409
|
+
function getUint8ArrayMemory0() {
|
|
22410
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
22411
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
22412
|
+
}
|
|
22413
|
+
return cachedUint8ArrayMemory0;
|
|
22414
|
+
}
|
|
22415
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
22416
|
+
if (realloc === void 0) {
|
|
22417
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
22418
|
+
const ptr2 = malloc(buf.length, 1) >>> 0;
|
|
22419
|
+
getUint8ArrayMemory0().subarray(ptr2, ptr2 + buf.length).set(buf);
|
|
22420
|
+
WASM_VECTOR_LEN = buf.length;
|
|
22421
|
+
return ptr2;
|
|
22422
|
+
}
|
|
22423
|
+
let len = arg.length;
|
|
22424
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
22425
|
+
const mem = getUint8ArrayMemory0();
|
|
22426
|
+
let offset = 0;
|
|
22427
|
+
for (; offset < len; offset++) {
|
|
22428
|
+
const code = arg.charCodeAt(offset);
|
|
22429
|
+
if (code > 127) break;
|
|
22430
|
+
mem[ptr + offset] = code;
|
|
22431
|
+
}
|
|
22432
|
+
if (offset !== len) {
|
|
22433
|
+
if (offset !== 0) {
|
|
22434
|
+
arg = arg.slice(offset);
|
|
22435
|
+
}
|
|
22436
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
22437
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
22438
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
22439
|
+
offset += ret.written;
|
|
22440
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
22441
|
+
}
|
|
22442
|
+
WASM_VECTOR_LEN = offset;
|
|
22443
|
+
return ptr;
|
|
22444
|
+
}
|
|
22445
|
+
function takeFromExternrefTable0(idx) {
|
|
22446
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
22447
|
+
wasm.__externref_table_dealloc(idx);
|
|
22448
|
+
return value;
|
|
22449
|
+
}
|
|
22450
|
+
let cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true });
|
|
22451
|
+
cachedTextDecoder.decode();
|
|
22452
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
22453
|
+
let numBytesDecoded = 0;
|
|
22454
|
+
function decodeText(ptr, len) {
|
|
22455
|
+
numBytesDecoded += len;
|
|
22456
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
22457
|
+
cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true });
|
|
22458
|
+
cachedTextDecoder.decode();
|
|
22459
|
+
numBytesDecoded = len;
|
|
22460
|
+
}
|
|
22461
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
22462
|
+
}
|
|
22463
|
+
const cachedTextEncoder = new TextEncoder();
|
|
22464
|
+
if (!("encodeInto" in cachedTextEncoder)) {
|
|
22465
|
+
cachedTextEncoder.encodeInto = function(arg, view) {
|
|
22466
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
22467
|
+
view.set(buf);
|
|
22468
|
+
return {
|
|
22469
|
+
read: arg.length,
|
|
22470
|
+
written: buf.length
|
|
22471
|
+
};
|
|
22472
|
+
};
|
|
22473
|
+
}
|
|
22474
|
+
let WASM_VECTOR_LEN = 0;
|
|
22475
|
+
let wasm;
|
|
22476
|
+
class WasmEngineAdapter {
|
|
22477
|
+
constructor(workflows) {
|
|
22478
|
+
__publicField(this, "engine");
|
|
22479
|
+
const workflowsJson = JSON.stringify(workflows);
|
|
22480
|
+
this.engine = new WasmEngine(workflowsJson);
|
|
22481
|
+
}
|
|
22482
|
+
async processWithTrace(payload) {
|
|
22483
|
+
const payloadJson = JSON.stringify(payload);
|
|
22484
|
+
const traceJson = await this.engine.process_with_trace(payloadJson);
|
|
22485
|
+
return JSON.parse(traceJson);
|
|
22486
|
+
}
|
|
22487
|
+
dispose() {
|
|
22488
|
+
this.engine.free();
|
|
22489
|
+
}
|
|
22490
|
+
}
|
|
22491
|
+
const defaultEngineFactory = (workflows) => new WasmEngineAdapter(workflows);
|
|
22024
22492
|
export {
|
|
22025
22493
|
ConditionBadge,
|
|
22026
22494
|
DebugInfoBubble,
|
|
@@ -22037,11 +22505,13 @@ export {
|
|
|
22037
22505
|
TaskRow,
|
|
22038
22506
|
ThemeProvider,
|
|
22039
22507
|
TreeView,
|
|
22508
|
+
WasmEngineAdapter,
|
|
22040
22509
|
WorkflowCard,
|
|
22041
22510
|
WorkflowFlowView,
|
|
22042
22511
|
WorkflowVisualizer,
|
|
22043
22512
|
cloneMessage,
|
|
22044
22513
|
createEmptyMessage,
|
|
22514
|
+
defaultEngineFactory,
|
|
22045
22515
|
getChangesAtStep,
|
|
22046
22516
|
getFunctionDisplayInfo,
|
|
22047
22517
|
getMessageAtStep,
|