@goplasmatic/dataflow-wasm 2.0.4

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 ADDED
@@ -0,0 +1,136 @@
1
+ <div align="center">
2
+ <img src="https://avatars.githubusercontent.com/u/207296579?s=200&v=4" alt="Plasmatic Logo" width="120" height="120">
3
+
4
+ # @goplasmatic/dataflow-wasm
5
+
6
+ **WebAssembly bindings for dataflow-rs workflow engine**
7
+
8
+ [![License: Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
9
+ [![npm](https://img.shields.io/npm/v/@goplasmatic/dataflow-wasm.svg)](https://www.npmjs.com/package/@goplasmatic/dataflow-wasm)
10
+ </div>
11
+
12
+ ---
13
+
14
+ WebAssembly bindings for [dataflow-rs](https://github.com/GoPlasmatic/dataflow-rs), enabling high-performance workflow execution in the browser. Run the same workflow engine that powers your Rust backend directly in JavaScript/TypeScript applications.
15
+
16
+ ## Features
17
+
18
+ - **Browser Execution** - Run dataflow-rs workflows directly in the browser
19
+ - **Full Feature Parity** - Same workflow engine as the native Rust version
20
+ - **TypeScript Support** - Full type definitions included
21
+ - **Execution Tracing** - Debug workflows with step-by-step execution traces
22
+
23
+ ## Installation
24
+
25
+ ```bash
26
+ npm install @goplasmatic/dataflow-wasm
27
+ ```
28
+
29
+ ## Quick Start
30
+
31
+ ```typescript
32
+ import init, { WasmEngine } from '@goplasmatic/dataflow-wasm';
33
+
34
+ // Initialize WASM module
35
+ await init();
36
+
37
+ // Define workflows
38
+ const workflows = [
39
+ {
40
+ id: 'my-workflow',
41
+ name: 'My Workflow',
42
+ tasks: [
43
+ {
44
+ id: 'task-1',
45
+ name: 'Transform Data',
46
+ function: {
47
+ name: 'map',
48
+ input: {
49
+ mappings: [
50
+ { path: 'data.output', logic: { var: 'data.input' } }
51
+ ]
52
+ }
53
+ }
54
+ }
55
+ ]
56
+ }
57
+ ];
58
+
59
+ // Create engine
60
+ const engine = new WasmEngine(workflows);
61
+
62
+ // Process a message
63
+ const message = { data: { input: 'hello' }, metadata: {} };
64
+ const result = await engine.process(message);
65
+ console.log(result); // { data: { input: 'hello', output: 'hello' }, ... }
66
+ ```
67
+
68
+ ## API
69
+
70
+ ### WasmEngine
71
+
72
+ ```typescript
73
+ class WasmEngine {
74
+ constructor(workflows: Workflow[]);
75
+
76
+ // Process a message through all workflows
77
+ process(message: Message): Promise<Message>;
78
+
79
+ // Process with execution trace for debugging
80
+ processWithTrace(message: Message): Promise<ExecutionTrace>;
81
+ }
82
+ ```
83
+
84
+ ### Types
85
+
86
+ ```typescript
87
+ interface Workflow {
88
+ id: string;
89
+ name: string;
90
+ condition?: JsonLogicValue;
91
+ tasks: Task[];
92
+ }
93
+
94
+ interface Task {
95
+ id: string;
96
+ name: string;
97
+ condition?: JsonLogicValue;
98
+ function: FunctionConfig;
99
+ }
100
+
101
+ interface Message {
102
+ data: object;
103
+ metadata: object;
104
+ payload?: object;
105
+ temp_data?: object;
106
+ }
107
+
108
+ interface ExecutionTrace {
109
+ steps: ExecutionStep[];
110
+ initial_message: Message;
111
+ final_message: Message;
112
+ }
113
+ ```
114
+
115
+ ## Building from Source
116
+
117
+ Requirements:
118
+ - Rust 1.70+
119
+ - wasm-pack
120
+
121
+ ```bash
122
+ # Build WASM package
123
+ cd wasm
124
+ wasm-pack build --target web
125
+
126
+ # The output will be in wasm/pkg/
127
+ ```
128
+
129
+ ## Related Packages
130
+
131
+ - [dataflow-rs](https://crates.io/crates/dataflow-rs) - Core Rust workflow engine
132
+ - [@goplasmatic/dataflow-ui](https://www.npmjs.com/package/@goplasmatic/dataflow-ui) - React visualization library
133
+
134
+ ## License
135
+
136
+ This project is licensed under the Apache License, Version 2.0. See the [LICENSE](../LICENSE) file for details.
@@ -0,0 +1,180 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * A WebAssembly-compatible workflow engine.
6
+ *
7
+ * Wraps the dataflow-rs Engine to provide async message processing
8
+ * that returns JavaScript Promises.
9
+ */
10
+ export class WasmEngine {
11
+ free(): void;
12
+ [Symbol.dispose](): void;
13
+ /**
14
+ * Create a new WasmEngine from a JSON array of workflow definitions.
15
+ *
16
+ * # Arguments
17
+ * * `workflows_json` - JSON string containing an array of workflow definitions
18
+ *
19
+ * # Example
20
+ * ```javascript
21
+ * const workflows = JSON.stringify([{
22
+ * id: "workflow1",
23
+ * name: "My Workflow",
24
+ * priority: 1,
25
+ * tasks: [...]
26
+ * }]);
27
+ * const engine = new WasmEngine(workflows);
28
+ * ```
29
+ */
30
+ constructor(workflows_json: string);
31
+ /**
32
+ * Process a payload through the engine's workflows.
33
+ *
34
+ * This is an async operation that returns a Promise.
35
+ *
36
+ * # Arguments
37
+ * * `payload_json` - JSON string of the payload to process
38
+ *
39
+ * # Returns
40
+ * A Promise that resolves to the processed message as a JSON string
41
+ *
42
+ * # Example
43
+ * ```javascript
44
+ * const payload = JSON.stringify({ name: "John", email: "john@example.com" });
45
+ * const result = await engine.process(payload);
46
+ * const processed = JSON.parse(result);
47
+ * console.log(processed.context.data);
48
+ * ```
49
+ */
50
+ process(payload_json: string): Promise<any>;
51
+ /**
52
+ * Process a payload with step-by-step execution tracing.
53
+ *
54
+ * This is an async operation that returns a Promise with the execution trace.
55
+ * The trace contains message snapshots after each step, including which
56
+ * workflows/tasks were executed or skipped.
57
+ *
58
+ * # Arguments
59
+ * * `payload_json` - JSON string of the payload to process
60
+ *
61
+ * # Returns
62
+ * A Promise that resolves to the execution trace as a JSON string
63
+ *
64
+ * # Example
65
+ * ```javascript
66
+ * const payload = JSON.stringify({ name: "John", email: "john@example.com" });
67
+ * const trace = await engine.process_with_trace(payload);
68
+ * const traceData = JSON.parse(trace);
69
+ * console.log(traceData.steps); // Array of execution steps
70
+ * ```
71
+ */
72
+ process_with_trace(payload_json: string): Promise<any>;
73
+ /**
74
+ * Get the number of workflows registered in the engine.
75
+ */
76
+ workflow_count(): number;
77
+ /**
78
+ * Get the list of workflow IDs.
79
+ *
80
+ * # Returns
81
+ * JSON array of workflow IDs as a string
82
+ */
83
+ workflow_ids(): string;
84
+ }
85
+
86
+ /**
87
+ * Create a message JSON string from data and metadata.
88
+ *
89
+ * # Arguments
90
+ * * `data` - JSON string containing the message data (goes to context.data)
91
+ * * `metadata` - JSON string containing the message metadata (goes to context.metadata)
92
+ *
93
+ * # Returns
94
+ * JSON string representing the complete message, or an error message
95
+ *
96
+ * # Example
97
+ * ```javascript
98
+ * const message = create_message('{"name": "John"}', '{"type": "user"}');
99
+ * const result = await engine.process(message);
100
+ * ```
101
+ */
102
+ export function create_message(data: string, metadata: string): string;
103
+
104
+ /**
105
+ * Initialize the WASM module.
106
+ *
107
+ * This is automatically called when the module loads.
108
+ * Sets up the panic hook for better error messages in the browser console.
109
+ */
110
+ export function init(): void;
111
+
112
+ /**
113
+ * Process a payload through a one-off engine (convenience function).
114
+ *
115
+ * Creates an engine with the given workflows and processes a single payload.
116
+ * Use WasmEngine class for better performance when processing multiple payloads.
117
+ *
118
+ * # Arguments
119
+ * * `workflows_json` - JSON string containing an array of workflow definitions
120
+ * * `payload_json` - JSON string of the payload to process
121
+ *
122
+ * # Returns
123
+ * A Promise that resolves to the processed message as a JSON string
124
+ *
125
+ * # Example
126
+ * ```javascript
127
+ * const payload = JSON.stringify({ name: "John", email: "john@example.com" });
128
+ * const result = await process_message(workflowsJson, payload);
129
+ * console.log(JSON.parse(result));
130
+ * ```
131
+ */
132
+ export function process_message(workflows_json: string, payload_json: string): Promise<any>;
133
+
134
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
135
+
136
+ export interface InitOutput {
137
+ readonly memory: WebAssembly.Memory;
138
+ readonly __wbg_wasmengine_free: (a: number, b: number) => void;
139
+ readonly create_message: (a: number, b: number, c: number, d: number) => [number, number, number, number];
140
+ readonly init: () => void;
141
+ readonly process_message: (a: number, b: number, c: number, d: number) => any;
142
+ readonly wasmengine_new: (a: number, b: number) => [number, number, number];
143
+ readonly wasmengine_process: (a: number, b: number, c: number) => any;
144
+ readonly wasmengine_process_with_trace: (a: number, b: number, c: number) => any;
145
+ readonly wasmengine_workflow_count: (a: number) => number;
146
+ readonly wasmengine_workflow_ids: (a: number) => [number, number];
147
+ readonly wasm_bindgen__closure__destroy__h6c21e3ac8818b8da: (a: number, b: number) => void;
148
+ readonly wasm_bindgen__convert__closures_____invoke__h6a4d7bdc6e47fe09: (a: number, b: number, c: any, d: any) => void;
149
+ readonly wasm_bindgen__convert__closures_____invoke__ha914c30c59f13cef: (a: number, b: number, c: any) => void;
150
+ readonly __wbindgen_exn_store: (a: number) => void;
151
+ readonly __externref_table_alloc: () => number;
152
+ readonly __wbindgen_externrefs: WebAssembly.Table;
153
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
154
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
155
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
156
+ readonly __externref_table_dealloc: (a: number) => void;
157
+ readonly __wbindgen_start: () => void;
158
+ }
159
+
160
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
161
+
162
+ /**
163
+ * Instantiates the given `module`, which can either be bytes or
164
+ * a precompiled `WebAssembly.Module`.
165
+ *
166
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
167
+ *
168
+ * @returns {InitOutput}
169
+ */
170
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
171
+
172
+ /**
173
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
174
+ * for everything else, calls `WebAssembly.instantiate` directly.
175
+ *
176
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
177
+ *
178
+ * @returns {Promise<InitOutput>}
179
+ */
180
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
@@ -0,0 +1,608 @@
1
+ /* @ts-self-types="./dataflow_wasm.d.ts" */
2
+
3
+ /**
4
+ * A WebAssembly-compatible workflow engine.
5
+ *
6
+ * Wraps the dataflow-rs Engine to provide async message processing
7
+ * that returns JavaScript Promises.
8
+ */
9
+ export class WasmEngine {
10
+ __destroy_into_raw() {
11
+ const ptr = this.__wbg_ptr;
12
+ this.__wbg_ptr = 0;
13
+ WasmEngineFinalization.unregister(this);
14
+ return ptr;
15
+ }
16
+ free() {
17
+ const ptr = this.__destroy_into_raw();
18
+ wasm.__wbg_wasmengine_free(ptr, 0);
19
+ }
20
+ /**
21
+ * Create a new WasmEngine from a JSON array of workflow definitions.
22
+ *
23
+ * # Arguments
24
+ * * `workflows_json` - JSON string containing an array of workflow definitions
25
+ *
26
+ * # Example
27
+ * ```javascript
28
+ * const workflows = JSON.stringify([{
29
+ * id: "workflow1",
30
+ * name: "My Workflow",
31
+ * priority: 1,
32
+ * tasks: [...]
33
+ * }]);
34
+ * const engine = new WasmEngine(workflows);
35
+ * ```
36
+ * @param {string} workflows_json
37
+ */
38
+ constructor(workflows_json) {
39
+ const ptr0 = passStringToWasm0(workflows_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
40
+ const len0 = WASM_VECTOR_LEN;
41
+ const ret = wasm.wasmengine_new(ptr0, len0);
42
+ if (ret[2]) {
43
+ throw takeFromExternrefTable0(ret[1]);
44
+ }
45
+ this.__wbg_ptr = ret[0] >>> 0;
46
+ WasmEngineFinalization.register(this, this.__wbg_ptr, this);
47
+ return this;
48
+ }
49
+ /**
50
+ * Process a payload through the engine's workflows.
51
+ *
52
+ * This is an async operation that returns a Promise.
53
+ *
54
+ * # Arguments
55
+ * * `payload_json` - JSON string of the payload to process
56
+ *
57
+ * # Returns
58
+ * A Promise that resolves to the processed message as a JSON string
59
+ *
60
+ * # Example
61
+ * ```javascript
62
+ * const payload = JSON.stringify({ name: "John", email: "john@example.com" });
63
+ * const result = await engine.process(payload);
64
+ * const processed = JSON.parse(result);
65
+ * console.log(processed.context.data);
66
+ * ```
67
+ * @param {string} payload_json
68
+ * @returns {Promise<any>}
69
+ */
70
+ process(payload_json) {
71
+ const ptr0 = passStringToWasm0(payload_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
72
+ const len0 = WASM_VECTOR_LEN;
73
+ const ret = wasm.wasmengine_process(this.__wbg_ptr, ptr0, len0);
74
+ return ret;
75
+ }
76
+ /**
77
+ * Process a payload with step-by-step execution tracing.
78
+ *
79
+ * This is an async operation that returns a Promise with the execution trace.
80
+ * The trace contains message snapshots after each step, including which
81
+ * workflows/tasks were executed or skipped.
82
+ *
83
+ * # Arguments
84
+ * * `payload_json` - JSON string of the payload to process
85
+ *
86
+ * # Returns
87
+ * A Promise that resolves to the execution trace as a JSON string
88
+ *
89
+ * # Example
90
+ * ```javascript
91
+ * const payload = JSON.stringify({ name: "John", email: "john@example.com" });
92
+ * const trace = await engine.process_with_trace(payload);
93
+ * const traceData = JSON.parse(trace);
94
+ * console.log(traceData.steps); // Array of execution steps
95
+ * ```
96
+ * @param {string} payload_json
97
+ * @returns {Promise<any>}
98
+ */
99
+ process_with_trace(payload_json) {
100
+ const ptr0 = passStringToWasm0(payload_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
101
+ const len0 = WASM_VECTOR_LEN;
102
+ const ret = wasm.wasmengine_process_with_trace(this.__wbg_ptr, ptr0, len0);
103
+ return ret;
104
+ }
105
+ /**
106
+ * Get the number of workflows registered in the engine.
107
+ * @returns {number}
108
+ */
109
+ workflow_count() {
110
+ const ret = wasm.wasmengine_workflow_count(this.__wbg_ptr);
111
+ return ret >>> 0;
112
+ }
113
+ /**
114
+ * Get the list of workflow IDs.
115
+ *
116
+ * # Returns
117
+ * JSON array of workflow IDs as a string
118
+ * @returns {string}
119
+ */
120
+ workflow_ids() {
121
+ let deferred1_0;
122
+ let deferred1_1;
123
+ try {
124
+ const ret = wasm.wasmengine_workflow_ids(this.__wbg_ptr);
125
+ deferred1_0 = ret[0];
126
+ deferred1_1 = ret[1];
127
+ return getStringFromWasm0(ret[0], ret[1]);
128
+ } finally {
129
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
130
+ }
131
+ }
132
+ }
133
+ if (Symbol.dispose) WasmEngine.prototype[Symbol.dispose] = WasmEngine.prototype.free;
134
+
135
+ /**
136
+ * Create a message JSON string from data and metadata.
137
+ *
138
+ * # Arguments
139
+ * * `data` - JSON string containing the message data (goes to context.data)
140
+ * * `metadata` - JSON string containing the message metadata (goes to context.metadata)
141
+ *
142
+ * # Returns
143
+ * JSON string representing the complete message, or an error message
144
+ *
145
+ * # Example
146
+ * ```javascript
147
+ * const message = create_message('{"name": "John"}', '{"type": "user"}');
148
+ * const result = await engine.process(message);
149
+ * ```
150
+ * @param {string} data
151
+ * @param {string} metadata
152
+ * @returns {string}
153
+ */
154
+ export function create_message(data, metadata) {
155
+ let deferred4_0;
156
+ let deferred4_1;
157
+ try {
158
+ const ptr0 = passStringToWasm0(data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
159
+ const len0 = WASM_VECTOR_LEN;
160
+ const ptr1 = passStringToWasm0(metadata, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
161
+ const len1 = WASM_VECTOR_LEN;
162
+ const ret = wasm.create_message(ptr0, len0, ptr1, len1);
163
+ var ptr3 = ret[0];
164
+ var len3 = ret[1];
165
+ if (ret[3]) {
166
+ ptr3 = 0; len3 = 0;
167
+ throw takeFromExternrefTable0(ret[2]);
168
+ }
169
+ deferred4_0 = ptr3;
170
+ deferred4_1 = len3;
171
+ return getStringFromWasm0(ptr3, len3);
172
+ } finally {
173
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
174
+ }
175
+ }
176
+
177
+ /**
178
+ * Initialize the WASM module.
179
+ *
180
+ * This is automatically called when the module loads.
181
+ * Sets up the panic hook for better error messages in the browser console.
182
+ */
183
+ export function init() {
184
+ wasm.init();
185
+ }
186
+
187
+ /**
188
+ * Process a payload through a one-off engine (convenience function).
189
+ *
190
+ * Creates an engine with the given workflows and processes a single payload.
191
+ * Use WasmEngine class for better performance when processing multiple payloads.
192
+ *
193
+ * # Arguments
194
+ * * `workflows_json` - JSON string containing an array of workflow definitions
195
+ * * `payload_json` - JSON string of the payload to process
196
+ *
197
+ * # Returns
198
+ * A Promise that resolves to the processed message as a JSON string
199
+ *
200
+ * # Example
201
+ * ```javascript
202
+ * const payload = JSON.stringify({ name: "John", email: "john@example.com" });
203
+ * const result = await process_message(workflowsJson, payload);
204
+ * console.log(JSON.parse(result));
205
+ * ```
206
+ * @param {string} workflows_json
207
+ * @param {string} payload_json
208
+ * @returns {Promise<any>}
209
+ */
210
+ export function process_message(workflows_json, payload_json) {
211
+ const ptr0 = passStringToWasm0(workflows_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
212
+ const len0 = WASM_VECTOR_LEN;
213
+ const ptr1 = passStringToWasm0(payload_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
214
+ const len1 = WASM_VECTOR_LEN;
215
+ const ret = wasm.process_message(ptr0, len0, ptr1, len1);
216
+ return ret;
217
+ }
218
+
219
+ function __wbg_get_imports() {
220
+ const import0 = {
221
+ __proto__: null,
222
+ __wbg___wbindgen_is_function_0095a73b8b156f76: function(arg0) {
223
+ const ret = typeof(arg0) === 'function';
224
+ return ret;
225
+ },
226
+ __wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
227
+ const ret = arg0 === undefined;
228
+ return ret;
229
+ },
230
+ __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
231
+ throw new Error(getStringFromWasm0(arg0, arg1));
232
+ },
233
+ __wbg__wbg_cb_unref_d9b87ff7982e3b21: function(arg0) {
234
+ arg0._wbg_cb_unref();
235
+ },
236
+ __wbg_call_389efe28435a9388: function() { return handleError(function (arg0, arg1) {
237
+ const ret = arg0.call(arg1);
238
+ return ret;
239
+ }, arguments); },
240
+ __wbg_call_4708e0c13bdc8e95: function() { return handleError(function (arg0, arg1, arg2) {
241
+ const ret = arg0.call(arg1, arg2);
242
+ return ret;
243
+ }, arguments); },
244
+ __wbg_error_7534b8e9a36f1ab4: function(arg0, arg1) {
245
+ let deferred0_0;
246
+ let deferred0_1;
247
+ try {
248
+ deferred0_0 = arg0;
249
+ deferred0_1 = arg1;
250
+ console.error(getStringFromWasm0(arg0, arg1));
251
+ } finally {
252
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
253
+ }
254
+ },
255
+ __wbg_getRandomValues_9c5c1b115e142bb8: function() { return handleError(function (arg0, arg1) {
256
+ globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
257
+ }, arguments); },
258
+ __wbg_getTime_1e3cd1391c5c3995: function(arg0) {
259
+ const ret = arg0.getTime();
260
+ return ret;
261
+ },
262
+ __wbg_new_0_73afc35eb544e539: function() {
263
+ const ret = new Date();
264
+ return ret;
265
+ },
266
+ __wbg_new_8a6f238a6ece86ea: function() {
267
+ const ret = new Error();
268
+ return ret;
269
+ },
270
+ __wbg_new_b5d9e2fb389fef91: function(arg0, arg1) {
271
+ try {
272
+ var state0 = {a: arg0, b: arg1};
273
+ var cb0 = (arg0, arg1) => {
274
+ const a = state0.a;
275
+ state0.a = 0;
276
+ try {
277
+ return wasm_bindgen__convert__closures_____invoke__h6a4d7bdc6e47fe09(a, state0.b, arg0, arg1);
278
+ } finally {
279
+ state0.a = a;
280
+ }
281
+ };
282
+ const ret = new Promise(cb0);
283
+ return ret;
284
+ } finally {
285
+ state0.a = state0.b = 0;
286
+ }
287
+ },
288
+ __wbg_new_no_args_1c7c842f08d00ebb: function(arg0, arg1) {
289
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
290
+ return ret;
291
+ },
292
+ __wbg_queueMicrotask_0aa0a927f78f5d98: function(arg0) {
293
+ const ret = arg0.queueMicrotask;
294
+ return ret;
295
+ },
296
+ __wbg_queueMicrotask_5bb536982f78a56f: function(arg0) {
297
+ queueMicrotask(arg0);
298
+ },
299
+ __wbg_resolve_002c4b7d9d8f6b64: function(arg0) {
300
+ const ret = Promise.resolve(arg0);
301
+ return ret;
302
+ },
303
+ __wbg_stack_0ed75d68575b0f3c: function(arg0, arg1) {
304
+ const ret = arg1.stack;
305
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
306
+ const len1 = WASM_VECTOR_LEN;
307
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
308
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
309
+ },
310
+ __wbg_static_accessor_GLOBAL_12837167ad935116: function() {
311
+ const ret = typeof global === 'undefined' ? null : global;
312
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
313
+ },
314
+ __wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f: function() {
315
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
316
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
317
+ },
318
+ __wbg_static_accessor_SELF_a621d3dfbb60d0ce: function() {
319
+ const ret = typeof self === 'undefined' ? null : self;
320
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
321
+ },
322
+ __wbg_static_accessor_WINDOW_f8727f0cf888e0bd: function() {
323
+ const ret = typeof window === 'undefined' ? null : window;
324
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
325
+ },
326
+ __wbg_then_b9e7b3b5f1a9e1b5: function(arg0, arg1) {
327
+ const ret = arg0.then(arg1);
328
+ return ret;
329
+ },
330
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
331
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 55, function: Function { arguments: [Externref], shim_idx: 61, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
332
+ const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h6c21e3ac8818b8da, wasm_bindgen__convert__closures_____invoke__ha914c30c59f13cef);
333
+ return ret;
334
+ },
335
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
336
+ // Cast intrinsic for `Ref(String) -> Externref`.
337
+ const ret = getStringFromWasm0(arg0, arg1);
338
+ return ret;
339
+ },
340
+ __wbindgen_init_externref_table: function() {
341
+ const table = wasm.__wbindgen_externrefs;
342
+ const offset = table.grow(4);
343
+ table.set(0, undefined);
344
+ table.set(offset + 0, undefined);
345
+ table.set(offset + 1, null);
346
+ table.set(offset + 2, true);
347
+ table.set(offset + 3, false);
348
+ },
349
+ };
350
+ return {
351
+ __proto__: null,
352
+ "./dataflow_wasm_bg.js": import0,
353
+ };
354
+ }
355
+
356
+ function wasm_bindgen__convert__closures_____invoke__ha914c30c59f13cef(arg0, arg1, arg2) {
357
+ wasm.wasm_bindgen__convert__closures_____invoke__ha914c30c59f13cef(arg0, arg1, arg2);
358
+ }
359
+
360
+ function wasm_bindgen__convert__closures_____invoke__h6a4d7bdc6e47fe09(arg0, arg1, arg2, arg3) {
361
+ wasm.wasm_bindgen__convert__closures_____invoke__h6a4d7bdc6e47fe09(arg0, arg1, arg2, arg3);
362
+ }
363
+
364
+ const WasmEngineFinalization = (typeof FinalizationRegistry === 'undefined')
365
+ ? { register: () => {}, unregister: () => {} }
366
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmengine_free(ptr >>> 0, 1));
367
+
368
+ function addToExternrefTable0(obj) {
369
+ const idx = wasm.__externref_table_alloc();
370
+ wasm.__wbindgen_externrefs.set(idx, obj);
371
+ return idx;
372
+ }
373
+
374
+ const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
375
+ ? { register: () => {}, unregister: () => {} }
376
+ : new FinalizationRegistry(state => state.dtor(state.a, state.b));
377
+
378
+ function getArrayU8FromWasm0(ptr, len) {
379
+ ptr = ptr >>> 0;
380
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
381
+ }
382
+
383
+ let cachedDataViewMemory0 = null;
384
+ function getDataViewMemory0() {
385
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
386
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
387
+ }
388
+ return cachedDataViewMemory0;
389
+ }
390
+
391
+ function getStringFromWasm0(ptr, len) {
392
+ ptr = ptr >>> 0;
393
+ return decodeText(ptr, len);
394
+ }
395
+
396
+ let cachedUint8ArrayMemory0 = null;
397
+ function getUint8ArrayMemory0() {
398
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
399
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
400
+ }
401
+ return cachedUint8ArrayMemory0;
402
+ }
403
+
404
+ function handleError(f, args) {
405
+ try {
406
+ return f.apply(this, args);
407
+ } catch (e) {
408
+ const idx = addToExternrefTable0(e);
409
+ wasm.__wbindgen_exn_store(idx);
410
+ }
411
+ }
412
+
413
+ function isLikeNone(x) {
414
+ return x === undefined || x === null;
415
+ }
416
+
417
+ function makeMutClosure(arg0, arg1, dtor, f) {
418
+ const state = { a: arg0, b: arg1, cnt: 1, dtor };
419
+ const real = (...args) => {
420
+
421
+ // First up with a closure we increment the internal reference
422
+ // count. This ensures that the Rust closure environment won't
423
+ // be deallocated while we're invoking it.
424
+ state.cnt++;
425
+ const a = state.a;
426
+ state.a = 0;
427
+ try {
428
+ return f(a, state.b, ...args);
429
+ } finally {
430
+ state.a = a;
431
+ real._wbg_cb_unref();
432
+ }
433
+ };
434
+ real._wbg_cb_unref = () => {
435
+ if (--state.cnt === 0) {
436
+ state.dtor(state.a, state.b);
437
+ state.a = 0;
438
+ CLOSURE_DTORS.unregister(state);
439
+ }
440
+ };
441
+ CLOSURE_DTORS.register(real, state, state);
442
+ return real;
443
+ }
444
+
445
+ function passStringToWasm0(arg, malloc, realloc) {
446
+ if (realloc === undefined) {
447
+ const buf = cachedTextEncoder.encode(arg);
448
+ const ptr = malloc(buf.length, 1) >>> 0;
449
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
450
+ WASM_VECTOR_LEN = buf.length;
451
+ return ptr;
452
+ }
453
+
454
+ let len = arg.length;
455
+ let ptr = malloc(len, 1) >>> 0;
456
+
457
+ const mem = getUint8ArrayMemory0();
458
+
459
+ let offset = 0;
460
+
461
+ for (; offset < len; offset++) {
462
+ const code = arg.charCodeAt(offset);
463
+ if (code > 0x7F) break;
464
+ mem[ptr + offset] = code;
465
+ }
466
+ if (offset !== len) {
467
+ if (offset !== 0) {
468
+ arg = arg.slice(offset);
469
+ }
470
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
471
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
472
+ const ret = cachedTextEncoder.encodeInto(arg, view);
473
+
474
+ offset += ret.written;
475
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
476
+ }
477
+
478
+ WASM_VECTOR_LEN = offset;
479
+ return ptr;
480
+ }
481
+
482
+ function takeFromExternrefTable0(idx) {
483
+ const value = wasm.__wbindgen_externrefs.get(idx);
484
+ wasm.__externref_table_dealloc(idx);
485
+ return value;
486
+ }
487
+
488
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
489
+ cachedTextDecoder.decode();
490
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
491
+ let numBytesDecoded = 0;
492
+ function decodeText(ptr, len) {
493
+ numBytesDecoded += len;
494
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
495
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
496
+ cachedTextDecoder.decode();
497
+ numBytesDecoded = len;
498
+ }
499
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
500
+ }
501
+
502
+ const cachedTextEncoder = new TextEncoder();
503
+
504
+ if (!('encodeInto' in cachedTextEncoder)) {
505
+ cachedTextEncoder.encodeInto = function (arg, view) {
506
+ const buf = cachedTextEncoder.encode(arg);
507
+ view.set(buf);
508
+ return {
509
+ read: arg.length,
510
+ written: buf.length
511
+ };
512
+ };
513
+ }
514
+
515
+ let WASM_VECTOR_LEN = 0;
516
+
517
+ let wasmModule, wasm;
518
+ function __wbg_finalize_init(instance, module) {
519
+ wasm = instance.exports;
520
+ wasmModule = module;
521
+ cachedDataViewMemory0 = null;
522
+ cachedUint8ArrayMemory0 = null;
523
+ wasm.__wbindgen_start();
524
+ return wasm;
525
+ }
526
+
527
+ async function __wbg_load(module, imports) {
528
+ if (typeof Response === 'function' && module instanceof Response) {
529
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
530
+ try {
531
+ return await WebAssembly.instantiateStreaming(module, imports);
532
+ } catch (e) {
533
+ const validResponse = module.ok && expectedResponseType(module.type);
534
+
535
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
536
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
537
+
538
+ } else { throw e; }
539
+ }
540
+ }
541
+
542
+ const bytes = await module.arrayBuffer();
543
+ return await WebAssembly.instantiate(bytes, imports);
544
+ } else {
545
+ const instance = await WebAssembly.instantiate(module, imports);
546
+
547
+ if (instance instanceof WebAssembly.Instance) {
548
+ return { instance, module };
549
+ } else {
550
+ return instance;
551
+ }
552
+ }
553
+
554
+ function expectedResponseType(type) {
555
+ switch (type) {
556
+ case 'basic': case 'cors': case 'default': return true;
557
+ }
558
+ return false;
559
+ }
560
+ }
561
+
562
+ function initSync(module) {
563
+ if (wasm !== undefined) return wasm;
564
+
565
+
566
+ if (module !== undefined) {
567
+ if (Object.getPrototypeOf(module) === Object.prototype) {
568
+ ({module} = module)
569
+ } else {
570
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
571
+ }
572
+ }
573
+
574
+ const imports = __wbg_get_imports();
575
+ if (!(module instanceof WebAssembly.Module)) {
576
+ module = new WebAssembly.Module(module);
577
+ }
578
+ const instance = new WebAssembly.Instance(module, imports);
579
+ return __wbg_finalize_init(instance, module);
580
+ }
581
+
582
+ async function __wbg_init(module_or_path) {
583
+ if (wasm !== undefined) return wasm;
584
+
585
+
586
+ if (module_or_path !== undefined) {
587
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
588
+ ({module_or_path} = module_or_path)
589
+ } else {
590
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
591
+ }
592
+ }
593
+
594
+ if (module_or_path === undefined) {
595
+ module_or_path = new URL('dataflow_wasm_bg.wasm', import.meta.url);
596
+ }
597
+ const imports = __wbg_get_imports();
598
+
599
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
600
+ module_or_path = fetch(module_or_path);
601
+ }
602
+
603
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
604
+
605
+ return __wbg_finalize_init(instance, module);
606
+ }
607
+
608
+ export { initSync, __wbg_init as default };
Binary file
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@goplasmatic/dataflow-wasm",
3
+ "type": "module",
4
+ "author": "Plasmatic Engineering <shankar@goplasmatic.io>",
5
+ "description": "WebAssembly bindings for dataflow-rs workflow engine",
6
+ "version": "2.0.4",
7
+ "license": "Apache-2.0",
8
+ "homepage": "https://github.com/GoPlasmatic/dataflow-rs",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/GoPlasmatic/dataflow-rs",
12
+ "directory": "wasm"
13
+ },
14
+ "bugs": {
15
+ "url": "https://github.com/GoPlasmatic/dataflow-rs/issues"
16
+ },
17
+ "files": [
18
+ "dataflow_wasm_bg.wasm",
19
+ "dataflow_wasm.js",
20
+ "dataflow_wasm.d.ts",
21
+ "README.md"
22
+ ],
23
+ "main": "dataflow_wasm.js",
24
+ "types": "dataflow_wasm.d.ts",
25
+ "sideEffects": [
26
+ "./snippets/*"
27
+ ],
28
+ "keywords": [
29
+ "workflow",
30
+ "engine",
31
+ "wasm",
32
+ "webassembly",
33
+ "dataflow",
34
+ "rust"
35
+ ]
36
+ }