@goplasmatic/dataflow-ui 2.0.5 → 2.0.7
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 +43 -2
- package/dist/index.cjs +289 -29
- package/dist/index.d.ts +42 -1
- package/dist/index.js +289 -29
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -91,11 +91,11 @@ interface WorkflowVisualizerProps {
|
|
|
91
91
|
Enable step-by-step execution visualization:
|
|
92
92
|
|
|
93
93
|
```tsx
|
|
94
|
-
import { WorkflowVisualizer, DebuggerProvider, DebuggerControls } from '@goplasmatic/dataflow-ui';
|
|
94
|
+
import { WorkflowVisualizer, DebuggerProvider, DebuggerControls, defaultEngineFactory } from '@goplasmatic/dataflow-ui';
|
|
95
95
|
|
|
96
96
|
function DebugView() {
|
|
97
97
|
return (
|
|
98
|
-
<DebuggerProvider>
|
|
98
|
+
<DebuggerProvider engineFactory={defaultEngineFactory}>
|
|
99
99
|
<WorkflowVisualizer workflows={workflows} debugMode={true} />
|
|
100
100
|
<DebuggerControls />
|
|
101
101
|
</DebuggerProvider>
|
|
@@ -103,6 +103,41 @@ function DebugView() {
|
|
|
103
103
|
}
|
|
104
104
|
```
|
|
105
105
|
|
|
106
|
+
### Custom WASM Engine
|
|
107
|
+
|
|
108
|
+
Use a custom WASM engine with plugins or custom functions:
|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
import { WorkflowVisualizer, DebuggerProvider, DataflowEngine } from '@goplasmatic/dataflow-ui';
|
|
112
|
+
import { MyCustomWasmEngine } from './my-custom-wasm';
|
|
113
|
+
|
|
114
|
+
// Implement the DataflowEngine interface
|
|
115
|
+
class MyEngineAdapter implements DataflowEngine {
|
|
116
|
+
private engine: MyCustomWasmEngine;
|
|
117
|
+
|
|
118
|
+
constructor(workflows: Workflow[]) {
|
|
119
|
+
this.engine = new MyCustomWasmEngine(JSON.stringify(workflows));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
async processWithTrace(payload: Record<string, unknown>) {
|
|
123
|
+
const result = await this.engine.process_with_trace(JSON.stringify(payload));
|
|
124
|
+
return JSON.parse(result);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
dispose() {
|
|
128
|
+
this.engine.free();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function CustomDebugView() {
|
|
133
|
+
return (
|
|
134
|
+
<DebuggerProvider engineFactory={(workflows) => new MyEngineAdapter(workflows)}>
|
|
135
|
+
<WorkflowVisualizer workflows={workflows} debugMode={true} />
|
|
136
|
+
</DebuggerProvider>
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
106
141
|
## Exports
|
|
107
142
|
|
|
108
143
|
### Components
|
|
@@ -116,6 +151,12 @@ function DebugView() {
|
|
|
116
151
|
- `useDebugger` - Access debugger state and controls
|
|
117
152
|
- `useTaskDebugState` - Get debug state for a specific task
|
|
118
153
|
|
|
154
|
+
### Engine
|
|
155
|
+
- `WasmEngineAdapter` - Default WASM engine adapter
|
|
156
|
+
- `defaultEngineFactory` - Factory function for default engine
|
|
157
|
+
- `DataflowEngine` - Interface for custom engines
|
|
158
|
+
- `EngineFactory` - Type for engine factory functions
|
|
159
|
+
|
|
119
160
|
### Types
|
|
120
161
|
All TypeScript types are exported for workflow definitions, tasks, messages, and execution traces.
|
|
121
162
|
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2
5
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
6
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
7
|
const require$$0 = require("react");
|
|
@@ -643,7 +646,8 @@ const DebuggerContext = require$$0.createContext(null);
|
|
|
643
646
|
function DebuggerProvider({
|
|
644
647
|
children: children2,
|
|
645
648
|
initialPayload,
|
|
646
|
-
autoActivate = false
|
|
649
|
+
autoActivate = false,
|
|
650
|
+
engineFactory
|
|
647
651
|
}) {
|
|
648
652
|
const [state, dispatch2] = require$$0.useReducer(debuggerReducer, {
|
|
649
653
|
...initialState,
|
|
@@ -651,6 +655,9 @@ function DebuggerProvider({
|
|
|
651
655
|
isActive: autoActivate
|
|
652
656
|
});
|
|
653
657
|
const playbackTimerRef = require$$0.useRef(null);
|
|
658
|
+
const engineRef = require$$0.useRef(null);
|
|
659
|
+
const lastWorkflowsJsonRef = require$$0.useRef(null);
|
|
660
|
+
const isEngineReady = Boolean(engineFactory);
|
|
654
661
|
const activate = require$$0.useCallback(() => dispatch2({ type: "ACTIVATE" }), []);
|
|
655
662
|
const deactivate = require$$0.useCallback(() => dispatch2({ type: "DEACTIVATE" }), []);
|
|
656
663
|
const setInputPayload = require$$0.useCallback(
|
|
@@ -674,6 +681,38 @@ function DebuggerProvider({
|
|
|
674
681
|
const stepBackward = require$$0.useCallback(() => dispatch2({ type: "STEP_BACKWARD" }), []);
|
|
675
682
|
const goToStep = require$$0.useCallback((index2) => dispatch2({ type: "GO_TO_STEP", index: index2 }), []);
|
|
676
683
|
const setSpeed = require$$0.useCallback((speed) => dispatch2({ type: "SET_SPEED", speed }), []);
|
|
684
|
+
const runExecution = require$$0.useCallback(
|
|
685
|
+
async (workflows, payload) => {
|
|
686
|
+
var _a;
|
|
687
|
+
if (workflows.length === 0 || !engineFactory) {
|
|
688
|
+
return null;
|
|
689
|
+
}
|
|
690
|
+
try {
|
|
691
|
+
const workflowsJson = JSON.stringify(workflows);
|
|
692
|
+
if (lastWorkflowsJsonRef.current !== workflowsJson || !engineRef.current) {
|
|
693
|
+
if ((_a = engineRef.current) == null ? void 0 : _a.dispose) {
|
|
694
|
+
engineRef.current.dispose();
|
|
695
|
+
}
|
|
696
|
+
engineRef.current = engineFactory(workflows);
|
|
697
|
+
lastWorkflowsJsonRef.current = workflowsJson;
|
|
698
|
+
}
|
|
699
|
+
return await engineRef.current.processWithTrace(payload);
|
|
700
|
+
} catch (error) {
|
|
701
|
+
console.error("Execution error:", error);
|
|
702
|
+
throw error;
|
|
703
|
+
}
|
|
704
|
+
},
|
|
705
|
+
[engineFactory]
|
|
706
|
+
);
|
|
707
|
+
require$$0.useEffect(() => {
|
|
708
|
+
return () => {
|
|
709
|
+
var _a;
|
|
710
|
+
if ((_a = engineRef.current) == null ? void 0 : _a.dispose) {
|
|
711
|
+
engineRef.current.dispose();
|
|
712
|
+
engineRef.current = null;
|
|
713
|
+
}
|
|
714
|
+
};
|
|
715
|
+
}, []);
|
|
677
716
|
require$$0.useEffect(() => {
|
|
678
717
|
if (state.playbackState === "playing") {
|
|
679
718
|
playbackTimerRef.current = window.setInterval(() => {
|
|
@@ -716,6 +755,7 @@ function DebuggerProvider({
|
|
|
716
755
|
stepBackward,
|
|
717
756
|
goToStep,
|
|
718
757
|
setSpeed,
|
|
758
|
+
runExecution,
|
|
719
759
|
currentStep,
|
|
720
760
|
currentMessage,
|
|
721
761
|
currentChanges,
|
|
@@ -723,7 +763,8 @@ function DebuggerProvider({
|
|
|
723
763
|
isAtEnd,
|
|
724
764
|
hasTrace,
|
|
725
765
|
progress,
|
|
726
|
-
totalSteps
|
|
766
|
+
totalSteps,
|
|
767
|
+
isEngineReady
|
|
727
768
|
};
|
|
728
769
|
return /* @__PURE__ */ jsxRuntime.jsx(DebuggerContext.Provider, { value, children: children2 });
|
|
729
770
|
}
|
|
@@ -9624,9 +9665,9 @@ function ResizeControl({ nodeId, position, variant = ResizeControlVariant.Handle
|
|
|
9624
9665
|
}, children: children2 });
|
|
9625
9666
|
}
|
|
9626
9667
|
require$$0.memo(ResizeControl);
|
|
9627
|
-
var
|
|
9628
|
-
var
|
|
9629
|
-
var
|
|
9668
|
+
var __defProp2 = Object.defineProperty;
|
|
9669
|
+
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9670
|
+
var __publicField2 = (obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
9630
9671
|
let CATEGORY_COLORS, DataLogicEditor, OPERATORS, applyTreeLayout, jsonLogicToNodes;
|
|
9631
9672
|
(async () => {
|
|
9632
9673
|
const BRANCH_COLORS = {
|
|
@@ -13360,23 +13401,23 @@ let CATEGORY_COLORS, DataLogicEditor, OPERATORS, applyTreeLayout, jsonLogicToNod
|
|
|
13360
13401
|
var EDGE_KEY_DELIM = "";
|
|
13361
13402
|
class Graph {
|
|
13362
13403
|
constructor(opts) {
|
|
13363
|
-
|
|
13364
|
-
|
|
13365
|
-
|
|
13366
|
-
|
|
13367
|
-
|
|
13368
|
-
|
|
13369
|
-
|
|
13370
|
-
|
|
13371
|
-
|
|
13372
|
-
|
|
13373
|
-
|
|
13374
|
-
|
|
13375
|
-
|
|
13376
|
-
|
|
13377
|
-
|
|
13378
|
-
|
|
13379
|
-
|
|
13404
|
+
__publicField2(this, "_isDirected", true);
|
|
13405
|
+
__publicField2(this, "_isMultigraph", false);
|
|
13406
|
+
__publicField2(this, "_isCompound", false);
|
|
13407
|
+
__publicField2(this, "_label");
|
|
13408
|
+
__publicField2(this, "_defaultNodeLabelFn", () => void 0);
|
|
13409
|
+
__publicField2(this, "_defaultEdgeLabelFn", () => void 0);
|
|
13410
|
+
__publicField2(this, "_nodes", {});
|
|
13411
|
+
__publicField2(this, "_in", {});
|
|
13412
|
+
__publicField2(this, "_preds", {});
|
|
13413
|
+
__publicField2(this, "_out", {});
|
|
13414
|
+
__publicField2(this, "_sucs", {});
|
|
13415
|
+
__publicField2(this, "_edgeObjs", {});
|
|
13416
|
+
__publicField2(this, "_edgeLabels", {});
|
|
13417
|
+
__publicField2(this, "_nodeCount", 0);
|
|
13418
|
+
__publicField2(this, "_edgeCount", 0);
|
|
13419
|
+
__publicField2(this, "_parent");
|
|
13420
|
+
__publicField2(this, "_children");
|
|
13380
13421
|
if (opts) {
|
|
13381
13422
|
this._isDirected = Object.hasOwn(opts, "directed") ? opts.directed : true;
|
|
13382
13423
|
this._isMultigraph = Object.hasOwn(opts, "multigraph") ? opts.multigraph : false;
|
|
@@ -13908,8 +13949,8 @@ let CATEGORY_COLORS, DataLogicEditor, OPERATORS, applyTreeLayout, jsonLogicToNod
|
|
|
13908
13949
|
hasRequiredPriorityQueue = 1;
|
|
13909
13950
|
class PriorityQueue {
|
|
13910
13951
|
constructor() {
|
|
13911
|
-
|
|
13912
|
-
|
|
13952
|
+
__publicField2(this, "_arr", []);
|
|
13953
|
+
__publicField2(this, "_keyIndices", {});
|
|
13913
13954
|
}
|
|
13914
13955
|
size() {
|
|
13915
13956
|
return this._arr.length;
|
|
@@ -17589,13 +17630,13 @@ let CATEGORY_COLORS, DataLogicEditor, OPERATORS, applyTreeLayout, jsonLogicToNod
|
|
|
17589
17630
|
try {
|
|
17590
17631
|
setLoading(true);
|
|
17591
17632
|
setError(null);
|
|
17592
|
-
const
|
|
17593
|
-
await
|
|
17633
|
+
const wasm2 = await Promise.resolve().then(() => require("./datalogic_wasm-4utZNR2J-B5BvlAcC.cjs"));
|
|
17634
|
+
await wasm2.default();
|
|
17594
17635
|
if (!cancelled) {
|
|
17595
17636
|
moduleRef.current = {
|
|
17596
|
-
evaluate:
|
|
17597
|
-
evaluate_with_trace:
|
|
17598
|
-
CompiledRule:
|
|
17637
|
+
evaluate: wasm2.evaluate,
|
|
17638
|
+
evaluate_with_trace: wasm2.evaluate_with_trace,
|
|
17639
|
+
CompiledRule: wasm2.CompiledRule
|
|
17599
17640
|
};
|
|
17600
17641
|
setReady(true);
|
|
17601
17642
|
setLoading(false);
|
|
@@ -22233,6 +22274,223 @@ function DebugStateBadge({
|
|
|
22233
22274
|
conditionResult !== void 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: `df-debug-badge-condition ${conditionResult ? "df-debug-badge-condition-pass" : "df-debug-badge-condition-fail"}`, children: conditionResult ? /* @__PURE__ */ jsxRuntime.jsx(Check, { size: iconSize }) : /* @__PURE__ */ jsxRuntime.jsx(X, { size: iconSize }) })
|
|
22234
22275
|
] });
|
|
22235
22276
|
}
|
|
22277
|
+
class WasmEngine {
|
|
22278
|
+
__destroy_into_raw() {
|
|
22279
|
+
const ptr = this.__wbg_ptr;
|
|
22280
|
+
this.__wbg_ptr = 0;
|
|
22281
|
+
WasmEngineFinalization.unregister(this);
|
|
22282
|
+
return ptr;
|
|
22283
|
+
}
|
|
22284
|
+
free() {
|
|
22285
|
+
const ptr = this.__destroy_into_raw();
|
|
22286
|
+
wasm.__wbg_wasmengine_free(ptr, 0);
|
|
22287
|
+
}
|
|
22288
|
+
/**
|
|
22289
|
+
* Create a new WasmEngine from a JSON array of workflow definitions.
|
|
22290
|
+
*
|
|
22291
|
+
* # Arguments
|
|
22292
|
+
* * `workflows_json` - JSON string containing an array of workflow definitions
|
|
22293
|
+
*
|
|
22294
|
+
* # Example
|
|
22295
|
+
* ```javascript
|
|
22296
|
+
* const workflows = JSON.stringify([{
|
|
22297
|
+
* id: "workflow1",
|
|
22298
|
+
* name: "My Workflow",
|
|
22299
|
+
* priority: 1,
|
|
22300
|
+
* tasks: [...]
|
|
22301
|
+
* }]);
|
|
22302
|
+
* const engine = new WasmEngine(workflows);
|
|
22303
|
+
* ```
|
|
22304
|
+
* @param {string} workflows_json
|
|
22305
|
+
*/
|
|
22306
|
+
constructor(workflows_json) {
|
|
22307
|
+
const ptr0 = passStringToWasm0(workflows_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
22308
|
+
const len0 = WASM_VECTOR_LEN;
|
|
22309
|
+
const ret = wasm.wasmengine_new(ptr0, len0);
|
|
22310
|
+
if (ret[2]) {
|
|
22311
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
22312
|
+
}
|
|
22313
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
22314
|
+
WasmEngineFinalization.register(this, this.__wbg_ptr, this);
|
|
22315
|
+
return this;
|
|
22316
|
+
}
|
|
22317
|
+
/**
|
|
22318
|
+
* Process a payload through the engine's workflows.
|
|
22319
|
+
*
|
|
22320
|
+
* This is an async operation that returns a Promise.
|
|
22321
|
+
*
|
|
22322
|
+
* # Arguments
|
|
22323
|
+
* * `payload_json` - JSON string of the payload to process
|
|
22324
|
+
*
|
|
22325
|
+
* # Returns
|
|
22326
|
+
* A Promise that resolves to the processed message as a JSON string
|
|
22327
|
+
*
|
|
22328
|
+
* # Example
|
|
22329
|
+
* ```javascript
|
|
22330
|
+
* const payload = JSON.stringify({ name: "John", email: "john@example.com" });
|
|
22331
|
+
* const result = await engine.process(payload);
|
|
22332
|
+
* const processed = JSON.parse(result);
|
|
22333
|
+
* console.log(processed.context.data);
|
|
22334
|
+
* ```
|
|
22335
|
+
* @param {string} payload_json
|
|
22336
|
+
* @returns {Promise<any>}
|
|
22337
|
+
*/
|
|
22338
|
+
process(payload_json) {
|
|
22339
|
+
const ptr0 = passStringToWasm0(payload_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
22340
|
+
const len0 = WASM_VECTOR_LEN;
|
|
22341
|
+
const ret = wasm.wasmengine_process(this.__wbg_ptr, ptr0, len0);
|
|
22342
|
+
return ret;
|
|
22343
|
+
}
|
|
22344
|
+
/**
|
|
22345
|
+
* Process a payload with step-by-step execution tracing.
|
|
22346
|
+
*
|
|
22347
|
+
* This is an async operation that returns a Promise with the execution trace.
|
|
22348
|
+
* The trace contains message snapshots after each step, including which
|
|
22349
|
+
* workflows/tasks were executed or skipped.
|
|
22350
|
+
*
|
|
22351
|
+
* # Arguments
|
|
22352
|
+
* * `payload_json` - JSON string of the payload to process
|
|
22353
|
+
*
|
|
22354
|
+
* # Returns
|
|
22355
|
+
* A Promise that resolves to the execution trace as a JSON string
|
|
22356
|
+
*
|
|
22357
|
+
* # Example
|
|
22358
|
+
* ```javascript
|
|
22359
|
+
* const payload = JSON.stringify({ name: "John", email: "john@example.com" });
|
|
22360
|
+
* const trace = await engine.process_with_trace(payload);
|
|
22361
|
+
* const traceData = JSON.parse(trace);
|
|
22362
|
+
* console.log(traceData.steps); // Array of execution steps
|
|
22363
|
+
* ```
|
|
22364
|
+
* @param {string} payload_json
|
|
22365
|
+
* @returns {Promise<any>}
|
|
22366
|
+
*/
|
|
22367
|
+
process_with_trace(payload_json) {
|
|
22368
|
+
const ptr0 = passStringToWasm0(payload_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
22369
|
+
const len0 = WASM_VECTOR_LEN;
|
|
22370
|
+
const ret = wasm.wasmengine_process_with_trace(this.__wbg_ptr, ptr0, len0);
|
|
22371
|
+
return ret;
|
|
22372
|
+
}
|
|
22373
|
+
/**
|
|
22374
|
+
* Get the number of workflows registered in the engine.
|
|
22375
|
+
* @returns {number}
|
|
22376
|
+
*/
|
|
22377
|
+
workflow_count() {
|
|
22378
|
+
const ret = wasm.wasmengine_workflow_count(this.__wbg_ptr);
|
|
22379
|
+
return ret >>> 0;
|
|
22380
|
+
}
|
|
22381
|
+
/**
|
|
22382
|
+
* Get the list of workflow IDs.
|
|
22383
|
+
*
|
|
22384
|
+
* # Returns
|
|
22385
|
+
* JSON array of workflow IDs as a string
|
|
22386
|
+
* @returns {string}
|
|
22387
|
+
*/
|
|
22388
|
+
workflow_ids() {
|
|
22389
|
+
let deferred1_0;
|
|
22390
|
+
let deferred1_1;
|
|
22391
|
+
try {
|
|
22392
|
+
const ret = wasm.wasmengine_workflow_ids(this.__wbg_ptr);
|
|
22393
|
+
deferred1_0 = ret[0];
|
|
22394
|
+
deferred1_1 = ret[1];
|
|
22395
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
22396
|
+
} finally {
|
|
22397
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
22398
|
+
}
|
|
22399
|
+
}
|
|
22400
|
+
}
|
|
22401
|
+
if (Symbol.dispose) WasmEngine.prototype[Symbol.dispose] = WasmEngine.prototype.free;
|
|
22402
|
+
const WasmEngineFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
|
|
22403
|
+
}, unregister: () => {
|
|
22404
|
+
} } : new FinalizationRegistry((ptr) => wasm.__wbg_wasmengine_free(ptr >>> 0, 1));
|
|
22405
|
+
typeof FinalizationRegistry === "undefined" ? {} : new FinalizationRegistry((state) => state.dtor(state.a, state.b));
|
|
22406
|
+
function getStringFromWasm0(ptr, len) {
|
|
22407
|
+
ptr = ptr >>> 0;
|
|
22408
|
+
return decodeText(ptr, len);
|
|
22409
|
+
}
|
|
22410
|
+
let cachedUint8ArrayMemory0 = null;
|
|
22411
|
+
function getUint8ArrayMemory0() {
|
|
22412
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
22413
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
22414
|
+
}
|
|
22415
|
+
return cachedUint8ArrayMemory0;
|
|
22416
|
+
}
|
|
22417
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
22418
|
+
if (realloc === void 0) {
|
|
22419
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
22420
|
+
const ptr2 = malloc(buf.length, 1) >>> 0;
|
|
22421
|
+
getUint8ArrayMemory0().subarray(ptr2, ptr2 + buf.length).set(buf);
|
|
22422
|
+
WASM_VECTOR_LEN = buf.length;
|
|
22423
|
+
return ptr2;
|
|
22424
|
+
}
|
|
22425
|
+
let len = arg.length;
|
|
22426
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
22427
|
+
const mem = getUint8ArrayMemory0();
|
|
22428
|
+
let offset = 0;
|
|
22429
|
+
for (; offset < len; offset++) {
|
|
22430
|
+
const code = arg.charCodeAt(offset);
|
|
22431
|
+
if (code > 127) break;
|
|
22432
|
+
mem[ptr + offset] = code;
|
|
22433
|
+
}
|
|
22434
|
+
if (offset !== len) {
|
|
22435
|
+
if (offset !== 0) {
|
|
22436
|
+
arg = arg.slice(offset);
|
|
22437
|
+
}
|
|
22438
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
22439
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
22440
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
22441
|
+
offset += ret.written;
|
|
22442
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
22443
|
+
}
|
|
22444
|
+
WASM_VECTOR_LEN = offset;
|
|
22445
|
+
return ptr;
|
|
22446
|
+
}
|
|
22447
|
+
function takeFromExternrefTable0(idx) {
|
|
22448
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
22449
|
+
wasm.__externref_table_dealloc(idx);
|
|
22450
|
+
return value;
|
|
22451
|
+
}
|
|
22452
|
+
let cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true });
|
|
22453
|
+
cachedTextDecoder.decode();
|
|
22454
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
22455
|
+
let numBytesDecoded = 0;
|
|
22456
|
+
function decodeText(ptr, len) {
|
|
22457
|
+
numBytesDecoded += len;
|
|
22458
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
22459
|
+
cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true });
|
|
22460
|
+
cachedTextDecoder.decode();
|
|
22461
|
+
numBytesDecoded = len;
|
|
22462
|
+
}
|
|
22463
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
22464
|
+
}
|
|
22465
|
+
const cachedTextEncoder = new TextEncoder();
|
|
22466
|
+
if (!("encodeInto" in cachedTextEncoder)) {
|
|
22467
|
+
cachedTextEncoder.encodeInto = function(arg, view) {
|
|
22468
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
22469
|
+
view.set(buf);
|
|
22470
|
+
return {
|
|
22471
|
+
read: arg.length,
|
|
22472
|
+
written: buf.length
|
|
22473
|
+
};
|
|
22474
|
+
};
|
|
22475
|
+
}
|
|
22476
|
+
let WASM_VECTOR_LEN = 0;
|
|
22477
|
+
let wasm;
|
|
22478
|
+
class WasmEngineAdapter {
|
|
22479
|
+
constructor(workflows) {
|
|
22480
|
+
__publicField(this, "engine");
|
|
22481
|
+
const workflowsJson = JSON.stringify(workflows);
|
|
22482
|
+
this.engine = new WasmEngine(workflowsJson);
|
|
22483
|
+
}
|
|
22484
|
+
async processWithTrace(payload) {
|
|
22485
|
+
const payloadJson = JSON.stringify(payload);
|
|
22486
|
+
const traceJson = await this.engine.process_with_trace(payloadJson);
|
|
22487
|
+
return JSON.parse(traceJson);
|
|
22488
|
+
}
|
|
22489
|
+
dispose() {
|
|
22490
|
+
this.engine.free();
|
|
22491
|
+
}
|
|
22492
|
+
}
|
|
22493
|
+
const defaultEngineFactory = (workflows) => new WasmEngineAdapter(workflows);
|
|
22236
22494
|
exports.ConditionBadge = ConditionBadge;
|
|
22237
22495
|
exports.DebugInfoBubble = DebugInfoBubble;
|
|
22238
22496
|
exports.DebugStateBadge = DebugStateBadge;
|
|
@@ -22248,11 +22506,13 @@ exports.SearchInput = SearchInput;
|
|
|
22248
22506
|
exports.TaskRow = TaskRow;
|
|
22249
22507
|
exports.ThemeProvider = ThemeProvider;
|
|
22250
22508
|
exports.TreeView = TreeView;
|
|
22509
|
+
exports.WasmEngineAdapter = WasmEngineAdapter;
|
|
22251
22510
|
exports.WorkflowCard = WorkflowCard;
|
|
22252
22511
|
exports.WorkflowFlowView = WorkflowFlowView;
|
|
22253
22512
|
exports.WorkflowVisualizer = WorkflowVisualizer;
|
|
22254
22513
|
exports.cloneMessage = cloneMessage;
|
|
22255
22514
|
exports.createEmptyMessage = createEmptyMessage;
|
|
22515
|
+
exports.defaultEngineFactory = defaultEngineFactory;
|
|
22256
22516
|
exports.getChangesAtStep = getChangesAtStep;
|
|
22257
22517
|
exports.getFunctionDisplayInfo = getFunctionDisplayInfo;
|
|
22258
22518
|
exports.getMessageAtStep = getMessageAtStep;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Component } from 'react';
|
|
2
|
+
import { defaultEngineFactory } from './engines';
|
|
2
3
|
import { ErrorInfo as ErrorInfo_2 } from 'react';
|
|
3
4
|
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
4
5
|
import { LucideIcon } from 'lucide-react';
|
|
5
6
|
import { ReactNode } from 'react';
|
|
6
7
|
import { ReactPortal } from 'react';
|
|
8
|
+
import { WasmEngineAdapter } from './engines';
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
11
|
* Audit trail entry for tracking changes (matches Rust AuditTrail)
|
|
@@ -68,6 +70,25 @@ export declare interface ConditionResult {
|
|
|
68
70
|
*/
|
|
69
71
|
export declare function createEmptyMessage(): Message;
|
|
70
72
|
|
|
73
|
+
/**
|
|
74
|
+
* Interface for custom dataflow engines
|
|
75
|
+
*
|
|
76
|
+
* Implement this interface to provide a custom WASM engine for executing
|
|
77
|
+
* workflows with custom functions or plugins.
|
|
78
|
+
*/
|
|
79
|
+
export declare interface DataflowEngine {
|
|
80
|
+
/**
|
|
81
|
+
* Process a payload through the engine and return an execution trace
|
|
82
|
+
* for step-by-step debugging.
|
|
83
|
+
*/
|
|
84
|
+
processWithTrace(payload: Record<string, unknown>): Promise<ExecutionTrace>;
|
|
85
|
+
/**
|
|
86
|
+
* Optional cleanup method called when the engine is no longer needed.
|
|
87
|
+
* Use this to free WASM memory.
|
|
88
|
+
*/
|
|
89
|
+
dispose?(): void;
|
|
90
|
+
}
|
|
91
|
+
|
|
71
92
|
/**
|
|
72
93
|
* Actions for the debugger reducer
|
|
73
94
|
*/
|
|
@@ -126,6 +147,7 @@ declare interface DebuggerContextValue {
|
|
|
126
147
|
stepBackward: () => void;
|
|
127
148
|
goToStep: (index: number) => void;
|
|
128
149
|
setSpeed: (speed: number) => void;
|
|
150
|
+
runExecution: (workflows: Workflow[], payload: Record<string, unknown>) => Promise<ExecutionTrace | null>;
|
|
129
151
|
currentStep: ExecutionStep | null;
|
|
130
152
|
currentMessage: Message | null;
|
|
131
153
|
currentChanges: Change[];
|
|
@@ -134,6 +156,7 @@ declare interface DebuggerContextValue {
|
|
|
134
156
|
hasTrace: boolean;
|
|
135
157
|
progress: number;
|
|
136
158
|
totalSteps: number;
|
|
159
|
+
isEngineReady: boolean;
|
|
137
160
|
}
|
|
138
161
|
|
|
139
162
|
/**
|
|
@@ -151,7 +174,7 @@ declare interface DebuggerControlsProps {
|
|
|
151
174
|
/**
|
|
152
175
|
* Provider component for debugger state
|
|
153
176
|
*/
|
|
154
|
-
export declare function DebuggerProvider({ children, initialPayload, autoActivate, }: DebuggerProviderProps): JSX_2.Element;
|
|
177
|
+
export declare function DebuggerProvider({ children, initialPayload, autoActivate, engineFactory, }: DebuggerProviderProps): JSX_2.Element;
|
|
155
178
|
|
|
156
179
|
declare interface DebuggerProviderProps {
|
|
157
180
|
children: ReactNode;
|
|
@@ -159,6 +182,12 @@ declare interface DebuggerProviderProps {
|
|
|
159
182
|
initialPayload?: Record<string, unknown>;
|
|
160
183
|
/** Auto-start in debug mode */
|
|
161
184
|
autoActivate?: boolean;
|
|
185
|
+
/**
|
|
186
|
+
* Factory function to create engine instances when workflows change.
|
|
187
|
+
* Called whenever workflows are updated to create a fresh engine.
|
|
188
|
+
* Use this for custom WASM engines with plugins.
|
|
189
|
+
*/
|
|
190
|
+
engineFactory?: EngineFactory;
|
|
162
191
|
}
|
|
163
192
|
|
|
164
193
|
/**
|
|
@@ -215,6 +244,16 @@ declare interface DebugStateBadgeProps {
|
|
|
215
244
|
size?: 'sm' | 'md';
|
|
216
245
|
}
|
|
217
246
|
|
|
247
|
+
export { defaultEngineFactory }
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Factory function type for creating engine instances.
|
|
251
|
+
*
|
|
252
|
+
* Called when workflows change to create a new engine instance
|
|
253
|
+
* configured with the current workflows.
|
|
254
|
+
*/
|
|
255
|
+
export declare type EngineFactory = (workflows: Workflow[]) => DataflowEngine;
|
|
256
|
+
|
|
218
257
|
/**
|
|
219
258
|
* Error boundary component to catch and display errors in child components
|
|
220
259
|
*/
|
|
@@ -658,6 +697,8 @@ export declare interface ValidationRule {
|
|
|
658
697
|
message: string;
|
|
659
698
|
}
|
|
660
699
|
|
|
700
|
+
export { WasmEngineAdapter }
|
|
701
|
+
|
|
661
702
|
/**
|
|
662
703
|
* Workflow definition
|
|
663
704
|
*/
|
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";
|
|
@@ -641,7 +644,8 @@ const DebuggerContext = createContext(null);
|
|
|
641
644
|
function DebuggerProvider({
|
|
642
645
|
children: children2,
|
|
643
646
|
initialPayload,
|
|
644
|
-
autoActivate = false
|
|
647
|
+
autoActivate = false,
|
|
648
|
+
engineFactory
|
|
645
649
|
}) {
|
|
646
650
|
const [state, dispatch2] = useReducer(debuggerReducer, {
|
|
647
651
|
...initialState,
|
|
@@ -649,6 +653,9 @@ function DebuggerProvider({
|
|
|
649
653
|
isActive: autoActivate
|
|
650
654
|
});
|
|
651
655
|
const playbackTimerRef = useRef(null);
|
|
656
|
+
const engineRef = useRef(null);
|
|
657
|
+
const lastWorkflowsJsonRef = useRef(null);
|
|
658
|
+
const isEngineReady = Boolean(engineFactory);
|
|
652
659
|
const activate = useCallback(() => dispatch2({ type: "ACTIVATE" }), []);
|
|
653
660
|
const deactivate = useCallback(() => dispatch2({ type: "DEACTIVATE" }), []);
|
|
654
661
|
const setInputPayload = useCallback(
|
|
@@ -672,6 +679,38 @@ function DebuggerProvider({
|
|
|
672
679
|
const stepBackward = useCallback(() => dispatch2({ type: "STEP_BACKWARD" }), []);
|
|
673
680
|
const goToStep = useCallback((index2) => dispatch2({ type: "GO_TO_STEP", index: index2 }), []);
|
|
674
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
|
+
}, []);
|
|
675
714
|
useEffect(() => {
|
|
676
715
|
if (state.playbackState === "playing") {
|
|
677
716
|
playbackTimerRef.current = window.setInterval(() => {
|
|
@@ -714,6 +753,7 @@ function DebuggerProvider({
|
|
|
714
753
|
stepBackward,
|
|
715
754
|
goToStep,
|
|
716
755
|
setSpeed,
|
|
756
|
+
runExecution,
|
|
717
757
|
currentStep,
|
|
718
758
|
currentMessage,
|
|
719
759
|
currentChanges,
|
|
@@ -721,7 +761,8 @@ function DebuggerProvider({
|
|
|
721
761
|
isAtEnd,
|
|
722
762
|
hasTrace,
|
|
723
763
|
progress,
|
|
724
|
-
totalSteps
|
|
764
|
+
totalSteps,
|
|
765
|
+
isEngineReady
|
|
725
766
|
};
|
|
726
767
|
return /* @__PURE__ */ jsx(DebuggerContext.Provider, { value, children: children2 });
|
|
727
768
|
}
|
|
@@ -9622,9 +9663,9 @@ function ResizeControl({ nodeId, position, variant = ResizeControlVariant.Handle
|
|
|
9622
9663
|
}, children: children2 });
|
|
9623
9664
|
}
|
|
9624
9665
|
memo(ResizeControl);
|
|
9625
|
-
var
|
|
9626
|
-
var
|
|
9627
|
-
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);
|
|
9628
9669
|
let CATEGORY_COLORS, DataLogicEditor, OPERATORS, applyTreeLayout, jsonLogicToNodes;
|
|
9629
9670
|
(async () => {
|
|
9630
9671
|
const BRANCH_COLORS = {
|
|
@@ -13358,23 +13399,23 @@ let CATEGORY_COLORS, DataLogicEditor, OPERATORS, applyTreeLayout, jsonLogicToNod
|
|
|
13358
13399
|
var EDGE_KEY_DELIM = "";
|
|
13359
13400
|
class Graph {
|
|
13360
13401
|
constructor(opts) {
|
|
13361
|
-
|
|
13362
|
-
|
|
13363
|
-
|
|
13364
|
-
|
|
13365
|
-
|
|
13366
|
-
|
|
13367
|
-
|
|
13368
|
-
|
|
13369
|
-
|
|
13370
|
-
|
|
13371
|
-
|
|
13372
|
-
|
|
13373
|
-
|
|
13374
|
-
|
|
13375
|
-
|
|
13376
|
-
|
|
13377
|
-
|
|
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");
|
|
13378
13419
|
if (opts) {
|
|
13379
13420
|
this._isDirected = Object.hasOwn(opts, "directed") ? opts.directed : true;
|
|
13380
13421
|
this._isMultigraph = Object.hasOwn(opts, "multigraph") ? opts.multigraph : false;
|
|
@@ -13906,8 +13947,8 @@ let CATEGORY_COLORS, DataLogicEditor, OPERATORS, applyTreeLayout, jsonLogicToNod
|
|
|
13906
13947
|
hasRequiredPriorityQueue = 1;
|
|
13907
13948
|
class PriorityQueue {
|
|
13908
13949
|
constructor() {
|
|
13909
|
-
|
|
13910
|
-
|
|
13950
|
+
__publicField2(this, "_arr", []);
|
|
13951
|
+
__publicField2(this, "_keyIndices", {});
|
|
13911
13952
|
}
|
|
13912
13953
|
size() {
|
|
13913
13954
|
return this._arr.length;
|
|
@@ -17587,13 +17628,13 @@ let CATEGORY_COLORS, DataLogicEditor, OPERATORS, applyTreeLayout, jsonLogicToNod
|
|
|
17587
17628
|
try {
|
|
17588
17629
|
setLoading(true);
|
|
17589
17630
|
setError(null);
|
|
17590
|
-
const
|
|
17591
|
-
await
|
|
17631
|
+
const wasm2 = await import("./datalogic_wasm-4utZNR2J-DW6r1ZIK.js");
|
|
17632
|
+
await wasm2.default();
|
|
17592
17633
|
if (!cancelled) {
|
|
17593
17634
|
moduleRef.current = {
|
|
17594
|
-
evaluate:
|
|
17595
|
-
evaluate_with_trace:
|
|
17596
|
-
CompiledRule:
|
|
17635
|
+
evaluate: wasm2.evaluate,
|
|
17636
|
+
evaluate_with_trace: wasm2.evaluate_with_trace,
|
|
17637
|
+
CompiledRule: wasm2.CompiledRule
|
|
17597
17638
|
};
|
|
17598
17639
|
setReady(true);
|
|
17599
17640
|
setLoading(false);
|
|
@@ -22231,6 +22272,223 @@ function DebugStateBadge({
|
|
|
22231
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 }) })
|
|
22232
22273
|
] });
|
|
22233
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);
|
|
22234
22492
|
export {
|
|
22235
22493
|
ConditionBadge,
|
|
22236
22494
|
DebugInfoBubble,
|
|
@@ -22247,11 +22505,13 @@ export {
|
|
|
22247
22505
|
TaskRow,
|
|
22248
22506
|
ThemeProvider,
|
|
22249
22507
|
TreeView,
|
|
22508
|
+
WasmEngineAdapter,
|
|
22250
22509
|
WorkflowCard,
|
|
22251
22510
|
WorkflowFlowView,
|
|
22252
22511
|
WorkflowVisualizer,
|
|
22253
22512
|
cloneMessage,
|
|
22254
22513
|
createEmptyMessage,
|
|
22514
|
+
defaultEngineFactory,
|
|
22255
22515
|
getChangesAtStep,
|
|
22256
22516
|
getFunctionDisplayInfo,
|
|
22257
22517
|
getMessageAtStep,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goplasmatic/dataflow-ui",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "React visualization library for dataflow-rs workflow engine",
|
|
6
6
|
"author": "Plasmatic Engineering <shankar@goplasmatic.io>",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"react-dom": "^18.0.0 || ^19.0.0"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@goplasmatic/dataflow-wasm": "^2.0.
|
|
55
|
+
"@goplasmatic/dataflow-wasm": "^2.0.7",
|
|
56
56
|
"@goplasmatic/datalogic-ui": "^4.0.11",
|
|
57
57
|
"@monaco-editor/react": "^4.7.0",
|
|
58
58
|
"@xyflow/react": "^12.0.0",
|