logic-mesh 0.1.1 → 0.1.2

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 CHANGED
@@ -1,64 +1,107 @@
1
- [![GitHub CI](https://github.com/rracariu/logic-mesh/actions/workflows/main.yml/badge.svg)](https://github.com/rracariu/logic-mesh/actions/workflows/main.yml)
2
- [![License](https://img.shields.io/badge/License-BSD_3--Clause-blue.svg)](https://github.com/rracariu/logic-mesh/blob/master/LICENSE)
3
- [![crates.io](https://img.shields.io/crates/v/logic-mesh.svg)](https://crates.io/crates/logic-mesh)
4
-
5
1
  # Logic Mesh
6
2
  A logic engine that is fully async, dynamic, and reactive written in Rust.
3
+ The engine is compiled to WebAssembly and can be used in the browser, or in a Node.js environment.
7
4
 
8
- ## Possible applications
9
- Logic Mesh started as a hardware control engine, but the scope expanded to anything that requires a reactive and dynamic evaluation engine.
10
- It is designed to be used in a variety of applications, from hardware controls, games to web servers. It is designed to be fast, efficient, and easy to use.
11
-
12
- The included WASM support allows it to be used in web applications, with the option to use the same codebase for both the frontend and backend.
5
+ ## Applications
6
+ - Low code editors
7
+ - Interactive visualizations
13
8
 
14
9
  ## Features
15
10
  - Fully async and reactive
16
- - WASM support
17
- - Uses Tokio for async runtime
18
- - The API is simple enough to be used in a variety of applications
19
- - A low code editor is included as an example of how Logic Mesh can be used
20
- - A growing library of built-in blocks
21
11
  - Extensible with custom blocks, either in Rust or JavaScript when running in a WASM environment
22
12
 
23
13
  ## UI Editor
24
- There is a sample low code editor that is built on top of Logic Mesh, which can be found [here](https://rracariu.github.io/logic-mesh/). It serves as an example of how Logic Mesh can be used, and as
25
- a simple way to experiment with the Logic Mesh engine.
14
+ There is a sample low code editor that is built on top of Logic Mesh, which can be found [here](https://rracariu.github.io/logic-mesh/). It serves as an example of how Logic Mesh can be used, and as a simple way to experiment with the Logic Mesh engine.
26
15
 
27
16
  ## Examples
28
17
 
29
- The following examples are written in Rust.
18
+ ### List all registered blocks
19
+ ```ts
20
+ import { initEngine } from 'logic-mesh';
21
+
22
+ // Initialize the engine
23
+ const engine = initEngine();
24
+
25
+ // List all registered blocks
26
+ const blocks = engine.listBlocks();
27
+ ```
28
+
29
+ ### Add block and wire them together
30
+ ```ts
31
+ import { initEngine } from 'logic-mesh';
32
+
33
+ // Initialize the engine
34
+ const engine = initEngine();
35
+
36
+ // Get a command instance for the engine
37
+ const command = engine.engineCommand();
38
+
39
+ // Add a SineWave block
40
+ const sineWaveId = await command.addBlock('SineWave')
41
+ // Add a StrLen block
42
+ const strLenId = await command.addBlock('StrLen')
30
43
 
31
- ```rust
32
- // Init a Add block
33
- let mut add1 = Add::new();
34
- // Init a SineWave block
35
- let mut sine1 = SineWave::new();
44
+ // Connect the blocks, sineWave -> strLen (sineWave's out port to strLen's in port)
45
+ command.createLink(sineWaveId, strLenId, 'out', 'in')
36
46
 
37
- // Se the amplitude and frequency of the sine wave
38
- sine1.amplitude.val = Some(3.into());
39
- sine1.freq.val = Some(200.into());
40
- // Connect the output of the sine wave to the first input of the add block
41
- connect_output(&mut sine1.out, add1.inputs_mut()[0]).expect("Connected");
47
+ // Start the engine (this is async)
48
+ engine.run()
49
+ ```
50
+
51
+ ### Watch for block changes
52
+ ```ts
53
+ import { initEngine } from 'logic-mesh';
54
+
55
+ // Initialize the engine
56
+ const engine = initEngine();
57
+
58
+ // Get a command instance for the engine
59
+ const command = engine.engineCommand();
60
+
61
+ // Add a SineWave block
62
+ const sineWave = await command.addBlock('SineWave')
63
+
64
+ // Create a new command instance for the watcher
65
+ const watchCommand = engine.engineCommand()
66
+ // Register a callback that will be called when the block changes
67
+ watchCommand.createWatch((notification) => {
68
+ console.log('Block changed', JSON.stringify(notification))
69
+ })
70
+
71
+ engine.run()
72
+ ```
42
73
 
43
- // Init another SineWave block
44
- let mut sine2 = SineWave::new();
45
- sine2.amplitude.val = Some(7.into());
46
- sine2.freq.val = Some(400.into());
74
+ ### Add a custom JavaScript block
75
+ ```ts
76
+ import { initEngine, JsBlock } from 'logic-mesh';
47
77
 
48
- // Connect the output of the sine wave to the second input of the add block
49
- sine2
50
- .connect_output("out", add1.inputs_mut()[1])
51
- .expect("Connected");
78
+ // Initialize the engine
79
+ const engine = initEngine();
52
80
 
53
- // Init a single threaded engine
54
- let mut engine = SingleThreadedEngine::new();
81
+ /**
82
+ * Defines a block that is implemented in JS
83
+ */
84
+ const JsAddBlock = {
85
+ // The block description
86
+ desc: {
87
+ name: 'AddBlock',
88
+ dis: 'JS Add block',
89
+ lib: 'examples',
90
+ ver: '0.0.1',
91
+ category: 'Docs',
92
+ doc: 'Adds two numbers',
93
+ implementation: 'external',
94
+ inputs: [{ name: 'in1', kind: 'Number' }, { name: 'in2', kind: 'Number' }],
95
+ outputs: [{ name: 'out', kind: 'Number' }],
96
+ } satisfies BlockDesc,
97
+ // The block implementation
98
+ function: async (inputs: unknown[]) => {
99
+ return (inputs[0] as number) + (inputs[1] as number)
100
+ },
101
+ } satisfies JsBlock
55
102
 
56
- // Schedule the blocks to be run
57
- engine.schedule(add1);
58
- engine.schedule(sine1);
59
- engine.schedule(sine2);
103
+ engine.registerBlock(JsAddBlock.desc, JsAddBlock.function)
60
104
 
61
- // Run the engine
62
- engine.run().await;
105
+ engine.run()
63
106
  ```
64
107
 
package/index.d.ts ADDED
@@ -0,0 +1,133 @@
1
+ export { BlocksEngine, initEngine, EngineCommand } from './logic_mesh'
2
+
3
+ /**
4
+ * The kind of the block pin.
5
+ */
6
+ export type Kind =
7
+ | 'null'
8
+ | 'remove'
9
+ | 'marker'
10
+ | 'na'
11
+ | 'bool'
12
+ | 'number'
13
+ | 'str'
14
+ | 'uri'
15
+ | 'ref'
16
+ | 'symbol'
17
+ | 'date'
18
+ | 'time'
19
+ | 'dateTime'
20
+ | 'coord'
21
+ | 'xstr'
22
+ | 'list'
23
+ | 'dict'
24
+ | 'grid'
25
+
26
+ /**
27
+ * A block that is implemented in JS
28
+ */
29
+ export type JsBlock = {
30
+ /**
31
+ * The block description
32
+ */
33
+ desc: BlockDesc
34
+ /**
35
+ * The block function
36
+ * @param inputs The block inputs that have been set
37
+ * @returns The block outputs that have to be set
38
+ */
39
+ function: (inputs: unknown[]) => Promise<unknown[]>
40
+ }
41
+
42
+ /**
43
+ * A block pin.
44
+ *
45
+ * Pins are the inputs and outputs of a block.
46
+ */
47
+ export interface BlockPin {
48
+ /**
49
+ * The pin name
50
+ */
51
+ name: string
52
+ /**
53
+ * The pin kind
54
+ * Must be a valid haystack type kind.
55
+ * See https://project-haystack.org/doc/docHaystack/Kinds
56
+ */
57
+ kind: Kind
58
+ /**
59
+ * The pin value
60
+ * Value is a Haystack value encoded as JSON.
61
+ */
62
+ value?: unknown
63
+ }
64
+
65
+ /**
66
+ * Describe a block that is available in block library.
67
+ */
68
+ export interface BlockDesc {
69
+ /**
70
+ * The block name
71
+ */
72
+ name: string
73
+ /**
74
+ * The block display name
75
+ */
76
+ dis: string
77
+ /**
78
+ * The block library name
79
+ */
80
+ lib: string
81
+ /**
82
+ * The block library version
83
+ */
84
+ ver: string
85
+ /**
86
+ * The block category
87
+ */
88
+ category: string
89
+ /**
90
+ * The block documentation
91
+ */
92
+ doc: string
93
+ /**
94
+ * The block implementation
95
+ */
96
+ implementation: 'native' | 'external'
97
+ /**
98
+ * The block inputs
99
+ */
100
+ inputs: BlockPin[]
101
+ /**
102
+ * The block outputs
103
+ */
104
+ outputs: BlockPin[]
105
+ }
106
+
107
+ /**
108
+ * Notification on a block change
109
+ */
110
+ export interface BlockNotification {
111
+ /**
112
+ * The block id
113
+ */
114
+ id: string
115
+
116
+ /**
117
+ * The changes
118
+ */
119
+ changes: {
120
+ /**
121
+ * The block pin name
122
+ */
123
+ name: string
124
+ /**
125
+ * The block pin source
126
+ */
127
+ source: string
128
+ /**
129
+ * The value that was changed on this pin
130
+ */
131
+ value: {}
132
+ }[]
133
+ }
package/index.js ADDED
@@ -0,0 +1 @@
1
+ export { BlocksEngine, EngineCommand, initEngine } from "./logic_mesh.js";
package/logic_mesh.d.ts CHANGED
@@ -27,6 +27,22 @@ export class BlocksEngine {
27
27
  */
28
28
  listBlocks(): Array<any>;
29
29
  /**
30
+ * Register a new JS block in the registry
31
+ * The block is described by a JsBlockDesc object
32
+ *
33
+ * # Arguments
34
+ * * `desc` - The description of the block
35
+ * * `func` - The function that implements the block
36
+ *
37
+ * # Returns
38
+ * The name of the block
39
+ *
40
+ * @param {any} desc
41
+ * @param {Function} func
42
+ * @returns {string}
43
+ */
44
+ registerBlock(desc: any, func: Function): string;
45
+ /**
30
46
  * @returns {EngineCommand}
31
47
  */
32
48
  engineCommand(): EngineCommand;
@@ -47,9 +63,9 @@ export class EngineCommand {
47
63
  * Adds a block instance to the engine
48
64
  * to be immediately scheduled for execution
49
65
  * @param {string} block_name
50
- * @returns {Promise<string | undefined>}
66
+ * @returns {Promise<string>}
51
67
  */
52
- addBlock(block_name: string): Promise<string | undefined>;
68
+ addBlock(block_name: string): Promise<string>;
53
69
  /**
54
70
  * Removes a block instance from the engine
55
71
  * to be immediately unscheduled for execution
@@ -61,9 +77,9 @@ export class EngineCommand {
61
77
  * # Returns
62
78
  * The UUID of the removed block
63
79
  * @param {string} block_uuid
64
- * @returns {Promise<string | undefined>}
80
+ * @returns {Promise<string>}
65
81
  */
66
- removeBlock(block_uuid: string): Promise<string | undefined>;
82
+ removeBlock(block_uuid: string): Promise<string>;
67
83
  /**
68
84
  * Creates a link between two blocks
69
85
  *
@@ -99,6 +115,22 @@ export class EngineCommand {
99
115
  */
100
116
  removeLink(link_uuid: string): Promise<boolean>;
101
117
  /**
118
+ * Writes the given block out with a value
119
+ *
120
+ * # Arguments
121
+ * * `block_uuid` - The UUID of the block to write to
122
+ * * `output_name` - The name of the output to write to
123
+ * * `value` - The value to write
124
+ *
125
+ * # Returns
126
+ * The block data
127
+ * @param {string} block_uuid
128
+ * @param {string} output_name
129
+ * @param {any} value
130
+ * @returns {Promise<any>}
131
+ */
132
+ writeBlockOutput(block_uuid: string, output_name: string, value: any): Promise<any>;
133
+ /**
102
134
  * Get the current running engine program.
103
135
  * The program contains the scheduled blocks, their properties, and their links.
104
136
  * @returns {Promise<any>}
package/logic_mesh_bg.js CHANGED
@@ -24,11 +24,38 @@ function takeObject(idx) {
24
24
  return ret;
25
25
  }
26
26
 
27
- const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
27
+ function isLikeNone(x) {
28
+ return x === undefined || x === null;
29
+ }
28
30
 
29
- let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
31
+ let cachedFloat64Memory0 = null;
30
32
 
31
- cachedTextDecoder.decode();
33
+ function getFloat64Memory0() {
34
+ if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) {
35
+ cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer);
36
+ }
37
+ return cachedFloat64Memory0;
38
+ }
39
+
40
+ let cachedInt32Memory0 = null;
41
+
42
+ function getInt32Memory0() {
43
+ if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
44
+ cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
45
+ }
46
+ return cachedInt32Memory0;
47
+ }
48
+
49
+ function addHeapObject(obj) {
50
+ if (heap_next === heap.length) heap.push(heap.length + 1);
51
+ const idx = heap_next;
52
+ heap_next = heap[idx];
53
+
54
+ heap[idx] = obj;
55
+ return idx;
56
+ }
57
+
58
+ let WASM_VECTOR_LEN = 0;
32
59
 
33
60
  let cachedUint8Memory0 = null;
34
61
 
@@ -39,18 +66,79 @@ function getUint8Memory0() {
39
66
  return cachedUint8Memory0;
40
67
  }
41
68
 
69
+ const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder;
70
+
71
+ let cachedTextEncoder = new lTextEncoder('utf-8');
72
+
73
+ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
74
+ ? function (arg, view) {
75
+ return cachedTextEncoder.encodeInto(arg, view);
76
+ }
77
+ : function (arg, view) {
78
+ const buf = cachedTextEncoder.encode(arg);
79
+ view.set(buf);
80
+ return {
81
+ read: arg.length,
82
+ written: buf.length
83
+ };
84
+ });
85
+
86
+ function passStringToWasm0(arg, malloc, realloc) {
87
+
88
+ if (realloc === undefined) {
89
+ const buf = cachedTextEncoder.encode(arg);
90
+ const ptr = malloc(buf.length, 1) >>> 0;
91
+ getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
92
+ WASM_VECTOR_LEN = buf.length;
93
+ return ptr;
94
+ }
95
+
96
+ let len = arg.length;
97
+ let ptr = malloc(len, 1) >>> 0;
98
+
99
+ const mem = getUint8Memory0();
100
+
101
+ let offset = 0;
102
+
103
+ for (; offset < len; offset++) {
104
+ const code = arg.charCodeAt(offset);
105
+ if (code > 0x7F) break;
106
+ mem[ptr + offset] = code;
107
+ }
108
+
109
+ if (offset !== len) {
110
+ if (offset !== 0) {
111
+ arg = arg.slice(offset);
112
+ }
113
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
114
+ const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
115
+ const ret = encodeString(arg, view);
116
+
117
+ offset += ret.written;
118
+ }
119
+
120
+ WASM_VECTOR_LEN = offset;
121
+ return ptr;
122
+ }
123
+
124
+ const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
125
+
126
+ let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
127
+
128
+ cachedTextDecoder.decode();
129
+
42
130
  function getStringFromWasm0(ptr, len) {
43
131
  ptr = ptr >>> 0;
44
132
  return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
45
133
  }
46
134
 
47
- function addHeapObject(obj) {
48
- if (heap_next === heap.length) heap.push(heap.length + 1);
49
- const idx = heap_next;
50
- heap_next = heap[idx];
135
+ let cachedBigInt64Memory0 = null;
51
136
 
52
- heap[idx] = obj;
53
- return idx;
137
+ function getBigInt64Memory0() {
138
+ if (cachedBigInt64Memory0 === null || cachedBigInt64Memory0.byteLength === 0) {
139
+ cachedBigInt64Memory0 = new BigInt64Array(wasm.memory.buffer);
140
+ }
141
+ return cachedBigInt64Memory0;
54
142
  }
55
143
 
56
144
  function debugString(val) {
@@ -118,72 +206,6 @@ function debugString(val) {
118
206
  return className;
119
207
  }
120
208
 
121
- let WASM_VECTOR_LEN = 0;
122
-
123
- const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder;
124
-
125
- let cachedTextEncoder = new lTextEncoder('utf-8');
126
-
127
- const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
128
- ? function (arg, view) {
129
- return cachedTextEncoder.encodeInto(arg, view);
130
- }
131
- : function (arg, view) {
132
- const buf = cachedTextEncoder.encode(arg);
133
- view.set(buf);
134
- return {
135
- read: arg.length,
136
- written: buf.length
137
- };
138
- });
139
-
140
- function passStringToWasm0(arg, malloc, realloc) {
141
-
142
- if (realloc === undefined) {
143
- const buf = cachedTextEncoder.encode(arg);
144
- const ptr = malloc(buf.length, 1) >>> 0;
145
- getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
146
- WASM_VECTOR_LEN = buf.length;
147
- return ptr;
148
- }
149
-
150
- let len = arg.length;
151
- let ptr = malloc(len, 1) >>> 0;
152
-
153
- const mem = getUint8Memory0();
154
-
155
- let offset = 0;
156
-
157
- for (; offset < len; offset++) {
158
- const code = arg.charCodeAt(offset);
159
- if (code > 0x7F) break;
160
- mem[ptr + offset] = code;
161
- }
162
-
163
- if (offset !== len) {
164
- if (offset !== 0) {
165
- arg = arg.slice(offset);
166
- }
167
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
168
- const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
169
- const ret = encodeString(arg, view);
170
-
171
- offset += ret.written;
172
- }
173
-
174
- WASM_VECTOR_LEN = offset;
175
- return ptr;
176
- }
177
-
178
- let cachedInt32Memory0 = null;
179
-
180
- function getInt32Memory0() {
181
- if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
182
- cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
183
- }
184
- return cachedInt32Memory0;
185
- }
186
-
187
209
  function makeMutClosure(arg0, arg1, dtor, f) {
188
210
  const state = { a: arg0, b: arg1, cnt: 1, dtor };
189
211
  const real = (...args) => {
@@ -208,7 +230,7 @@ function makeMutClosure(arg0, arg1, dtor, f) {
208
230
 
209
231
  return real;
210
232
  }
211
- function __wbg_adapter_30(arg0, arg1, arg2) {
233
+ function __wbg_adapter_50(arg0, arg1, arg2) {
212
234
  wasm.__wbindgen_export_3(arg0, arg1, addHeapObject(arg2));
213
235
  }
214
236
 
@@ -239,7 +261,7 @@ function handleError(f, args) {
239
261
  wasm.__wbindgen_export_5(addHeapObject(e));
240
262
  }
241
263
  }
242
- function __wbg_adapter_97(arg0, arg1, arg2, arg3) {
264
+ function __wbg_adapter_145(arg0, arg1, arg2, arg3) {
243
265
  wasm.__wbindgen_export_6(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
244
266
  }
245
267
 
@@ -285,6 +307,45 @@ export class BlocksEngine {
285
307
  return takeObject(ret);
286
308
  }
287
309
  /**
310
+ * Register a new JS block in the registry
311
+ * The block is described by a JsBlockDesc object
312
+ *
313
+ * # Arguments
314
+ * * `desc` - The description of the block
315
+ * * `func` - The function that implements the block
316
+ *
317
+ * # Returns
318
+ * The name of the block
319
+ *
320
+ * @param {any} desc
321
+ * @param {Function} func
322
+ * @returns {string}
323
+ */
324
+ registerBlock(desc, func) {
325
+ let deferred2_0;
326
+ let deferred2_1;
327
+ try {
328
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
329
+ wasm.blocksengine_registerBlock(retptr, this.__wbg_ptr, addHeapObject(desc), addHeapObject(func));
330
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
331
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
332
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
333
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
334
+ var ptr1 = r0;
335
+ var len1 = r1;
336
+ if (r3) {
337
+ ptr1 = 0; len1 = 0;
338
+ throw takeObject(r2);
339
+ }
340
+ deferred2_0 = ptr1;
341
+ deferred2_1 = len1;
342
+ return getStringFromWasm0(ptr1, len1);
343
+ } finally {
344
+ wasm.__wbindgen_add_to_stack_pointer(16);
345
+ wasm.__wbindgen_export_4(deferred2_0, deferred2_1, 1);
346
+ }
347
+ }
348
+ /**
288
349
  * @returns {EngineCommand}
289
350
  */
290
351
  engineCommand() {
@@ -330,7 +391,7 @@ export class EngineCommand {
330
391
  * Adds a block instance to the engine
331
392
  * to be immediately scheduled for execution
332
393
  * @param {string} block_name
333
- * @returns {Promise<string | undefined>}
394
+ * @returns {Promise<string>}
334
395
  */
335
396
  addBlock(block_name) {
336
397
  const ptr0 = passStringToWasm0(block_name, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
@@ -349,7 +410,7 @@ export class EngineCommand {
349
410
  * # Returns
350
411
  * The UUID of the removed block
351
412
  * @param {string} block_uuid
352
- * @returns {Promise<string | undefined>}
413
+ * @returns {Promise<string>}
353
414
  */
354
415
  removeBlock(block_uuid) {
355
416
  const ptr0 = passStringToWasm0(block_uuid, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
@@ -408,6 +469,29 @@ export class EngineCommand {
408
469
  return takeObject(ret);
409
470
  }
410
471
  /**
472
+ * Writes the given block out with a value
473
+ *
474
+ * # Arguments
475
+ * * `block_uuid` - The UUID of the block to write to
476
+ * * `output_name` - The name of the output to write to
477
+ * * `value` - The value to write
478
+ *
479
+ * # Returns
480
+ * The block data
481
+ * @param {string} block_uuid
482
+ * @param {string} output_name
483
+ * @param {any} value
484
+ * @returns {Promise<any>}
485
+ */
486
+ writeBlockOutput(block_uuid, output_name, value) {
487
+ const ptr0 = passStringToWasm0(block_uuid, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
488
+ const len0 = WASM_VECTOR_LEN;
489
+ const ptr1 = passStringToWasm0(output_name, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
490
+ const len1 = WASM_VECTOR_LEN;
491
+ const ret = wasm.enginecommand_writeBlockOutput(this.__wbg_ptr, ptr0, len0, ptr1, len1, addHeapObject(value));
492
+ return takeObject(ret);
493
+ }
494
+ /**
411
495
  * Get the current running engine program.
412
496
  * The program contains the scheduled blocks, their properties, and their links.
413
497
  * @returns {Promise<any>}
@@ -442,6 +526,69 @@ export function __wbindgen_object_drop_ref(arg0) {
442
526
  takeObject(arg0);
443
527
  };
444
528
 
529
+ export function __wbindgen_is_array(arg0) {
530
+ const ret = Array.isArray(getObject(arg0));
531
+ return ret;
532
+ };
533
+
534
+ export function __wbindgen_is_undefined(arg0) {
535
+ const ret = getObject(arg0) === undefined;
536
+ return ret;
537
+ };
538
+
539
+ export function __wbindgen_in(arg0, arg1) {
540
+ const ret = getObject(arg0) in getObject(arg1);
541
+ return ret;
542
+ };
543
+
544
+ export function __wbindgen_boolean_get(arg0) {
545
+ const v = getObject(arg0);
546
+ const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2;
547
+ return ret;
548
+ };
549
+
550
+ export function __wbindgen_is_bigint(arg0) {
551
+ const ret = typeof(getObject(arg0)) === 'bigint';
552
+ return ret;
553
+ };
554
+
555
+ export function __wbindgen_number_get(arg0, arg1) {
556
+ const obj = getObject(arg1);
557
+ const ret = typeof(obj) === 'number' ? obj : undefined;
558
+ getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
559
+ getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
560
+ };
561
+
562
+ export function __wbindgen_bigint_from_i64(arg0) {
563
+ const ret = arg0;
564
+ return addHeapObject(ret);
565
+ };
566
+
567
+ export function __wbindgen_jsval_eq(arg0, arg1) {
568
+ const ret = getObject(arg0) === getObject(arg1);
569
+ return ret;
570
+ };
571
+
572
+ export function __wbindgen_string_get(arg0, arg1) {
573
+ const obj = getObject(arg1);
574
+ const ret = typeof(obj) === 'string' ? obj : undefined;
575
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
576
+ var len1 = WASM_VECTOR_LEN;
577
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
578
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
579
+ };
580
+
581
+ export function __wbindgen_is_object(arg0) {
582
+ const val = getObject(arg0);
583
+ const ret = typeof(val) === 'object' && val !== null;
584
+ return ret;
585
+ };
586
+
587
+ export function __wbindgen_bigint_from_u64(arg0) {
588
+ const ret = BigInt.asUintN(64, arg0);
589
+ return addHeapObject(ret);
590
+ };
591
+
445
592
  export function __wbindgen_error_new(arg0, arg1) {
446
593
  const ret = new Error(getStringFromWasm0(arg0, arg1));
447
594
  return addHeapObject(ret);
@@ -457,19 +604,26 @@ export function __wbindgen_object_clone_ref(arg0) {
457
604
  return addHeapObject(ret);
458
605
  };
459
606
 
460
- export function __wbindgen_is_object(arg0) {
461
- const val = getObject(arg0);
462
- const ret = typeof(val) === 'object' && val !== null;
607
+ export function __wbindgen_jsval_loose_eq(arg0, arg1) {
608
+ const ret = getObject(arg0) == getObject(arg1);
463
609
  return ret;
464
610
  };
465
611
 
612
+ export function __wbg_String_88810dfeb4021902(arg0, arg1) {
613
+ const ret = String(getObject(arg1));
614
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
615
+ const len1 = WASM_VECTOR_LEN;
616
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
617
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
618
+ };
619
+
466
620
  export function __wbindgen_number_new(arg0) {
467
621
  const ret = arg0;
468
622
  return addHeapObject(ret);
469
623
  };
470
624
 
471
- export function __wbindgen_bigint_from_i64(arg0) {
472
- const ret = arg0;
625
+ export function __wbg_getwithrefkey_5e6d9547403deab8(arg0, arg1) {
626
+ const ret = getObject(arg0)[getObject(arg1)];
473
627
  return addHeapObject(ret);
474
628
  };
475
629
 
@@ -583,6 +737,16 @@ export function __wbg_getRandomValues_37fa2ca9e4e07fab() { return handleError(fu
583
737
  getObject(arg0).getRandomValues(getObject(arg1));
584
738
  }, arguments) };
585
739
 
740
+ export function __wbg_get_44be0491f933a435(arg0, arg1) {
741
+ const ret = getObject(arg0)[arg1 >>> 0];
742
+ return addHeapObject(ret);
743
+ };
744
+
745
+ export function __wbg_length_fff51ee6522a1a18(arg0) {
746
+ const ret = getObject(arg0).length;
747
+ return ret;
748
+ };
749
+
586
750
  export function __wbg_new_898a68150f225f2e() {
587
751
  const ret = new Array();
588
752
  return addHeapObject(ret);
@@ -603,6 +767,36 @@ export function __wbg_new_56693dbed0c32988() {
603
767
  return addHeapObject(ret);
604
768
  };
605
769
 
770
+ export function __wbg_next_526fc47e980da008(arg0) {
771
+ const ret = getObject(arg0).next;
772
+ return addHeapObject(ret);
773
+ };
774
+
775
+ export function __wbg_next_ddb3312ca1c4e32a() { return handleError(function (arg0) {
776
+ const ret = getObject(arg0).next();
777
+ return addHeapObject(ret);
778
+ }, arguments) };
779
+
780
+ export function __wbg_done_5c1f01fb660d73b5(arg0) {
781
+ const ret = getObject(arg0).done;
782
+ return ret;
783
+ };
784
+
785
+ export function __wbg_value_1695675138684bd5(arg0) {
786
+ const ret = getObject(arg0).value;
787
+ return addHeapObject(ret);
788
+ };
789
+
790
+ export function __wbg_iterator_97f0c81209c6c35a() {
791
+ const ret = Symbol.iterator;
792
+ return addHeapObject(ret);
793
+ };
794
+
795
+ export function __wbg_get_97b561fb56f034b5() { return handleError(function (arg0, arg1) {
796
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
797
+ return addHeapObject(ret);
798
+ }, arguments) };
799
+
606
800
  export function __wbg_call_cb65541d95d71282() { return handleError(function (arg0, arg1) {
607
801
  const ret = getObject(arg0).call(getObject(arg1));
608
802
  return addHeapObject(ret);
@@ -633,20 +827,31 @@ export function __wbg_global_651f05c6a0944d1c() { return handleError(function ()
633
827
  return addHeapObject(ret);
634
828
  }, arguments) };
635
829
 
636
- export function __wbindgen_is_undefined(arg0) {
637
- const ret = getObject(arg0) === undefined;
638
- return ret;
639
- };
640
-
641
830
  export function __wbg_set_502d29070ea18557(arg0, arg1, arg2) {
642
831
  getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
643
832
  };
644
833
 
834
+ export function __wbg_isArray_4c24b343cb13cfb1(arg0) {
835
+ const ret = Array.isArray(getObject(arg0));
836
+ return ret;
837
+ };
838
+
645
839
  export function __wbg_push_ca1c26067ef907ac(arg0, arg1) {
646
840
  const ret = getObject(arg0).push(getObject(arg1));
647
841
  return ret;
648
842
  };
649
843
 
844
+ export function __wbg_instanceof_ArrayBuffer_39ac22089b74fddb(arg0) {
845
+ let result;
846
+ try {
847
+ result = getObject(arg0) instanceof ArrayBuffer;
848
+ } catch {
849
+ result = false;
850
+ }
851
+ const ret = result;
852
+ return ret;
853
+ };
854
+
650
855
  export function __wbg_call_01734de55d61e11d() { return handleError(function (arg0, arg1, arg2) {
651
856
  const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
652
857
  return addHeapObject(ret);
@@ -657,6 +862,16 @@ export function __wbg_set_bedc3d02d0f05eb0(arg0, arg1, arg2) {
657
862
  return addHeapObject(ret);
658
863
  };
659
864
 
865
+ export function __wbg_isSafeInteger_bb8e18dd21c97288(arg0) {
866
+ const ret = Number.isSafeInteger(getObject(arg0));
867
+ return ret;
868
+ };
869
+
870
+ export function __wbg_entries_e51f29c7bba0c054(arg0) {
871
+ const ret = Object.entries(getObject(arg0));
872
+ return addHeapObject(ret);
873
+ };
874
+
660
875
  export function __wbg_new_43f1b47c28813cbd(arg0, arg1) {
661
876
  try {
662
877
  var state0 = {a: arg0, b: arg1};
@@ -664,7 +879,7 @@ export function __wbg_new_43f1b47c28813cbd(arg0, arg1) {
664
879
  const a = state0.a;
665
880
  state0.a = 0;
666
881
  try {
667
- return __wbg_adapter_97(a, state0.b, arg0, arg1);
882
+ return __wbg_adapter_145(a, state0.b, arg0, arg1);
668
883
  } finally {
669
884
  state0.a = a;
670
885
  }
@@ -710,6 +925,22 @@ export function __wbg_set_5cf90238115182c3(arg0, arg1, arg2) {
710
925
  getObject(arg0).set(getObject(arg1), arg2 >>> 0);
711
926
  };
712
927
 
928
+ export function __wbg_length_72e2208bbc0efc61(arg0) {
929
+ const ret = getObject(arg0).length;
930
+ return ret;
931
+ };
932
+
933
+ export function __wbg_instanceof_Uint8Array_d8d9cb2b8e8ac1d4(arg0) {
934
+ let result;
935
+ try {
936
+ result = getObject(arg0) instanceof Uint8Array;
937
+ } catch {
938
+ result = false;
939
+ }
940
+ const ret = result;
941
+ return ret;
942
+ };
943
+
713
944
  export function __wbg_newwithlength_e5d69174d6984cd7(arg0) {
714
945
  const ret = new Uint8Array(arg0 >>> 0);
715
946
  return addHeapObject(ret);
@@ -720,6 +951,13 @@ export function __wbg_subarray_13db269f57aa838d(arg0, arg1, arg2) {
720
951
  return addHeapObject(ret);
721
952
  };
722
953
 
954
+ export function __wbindgen_bigint_get_as_i64(arg0, arg1) {
955
+ const v = getObject(arg1);
956
+ const ret = typeof(v) === 'bigint' ? v : undefined;
957
+ getBigInt64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? BigInt(0) : ret;
958
+ getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
959
+ };
960
+
723
961
  export function __wbindgen_debug_string(arg0, arg1) {
724
962
  const ret = debugString(getObject(arg1));
725
963
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
@@ -737,8 +975,8 @@ export function __wbindgen_memory() {
737
975
  return addHeapObject(ret);
738
976
  };
739
977
 
740
- export function __wbindgen_closure_wrapper1887(arg0, arg1, arg2) {
741
- const ret = makeMutClosure(arg0, arg1, 598, __wbg_adapter_30);
978
+ export function __wbindgen_closure_wrapper2525(arg0, arg1, arg2) {
979
+ const ret = makeMutClosure(arg0, arg1, 889, __wbg_adapter_50);
742
980
  return addHeapObject(ret);
743
981
  };
744
982
 
Binary file
package/package.json CHANGED
@@ -1,32 +1,35 @@
1
1
  {
2
- "name": "logic-mesh",
3
- "collaborators": [
4
- "Radu Racariu <radu.racariu@gmail.com>"
5
- ],
6
- "description": "Control logic engine using event based and reactive blocks written in Rust.",
7
- "version": "0.1.1",
8
- "license": "BSD-3-Clause",
9
- "repository": {
10
- "type": "git",
11
- "url": "https://github.com/rracariu/logic-mesh"
12
- },
13
- "files": [
14
- "logic_mesh_bg.wasm",
15
- "logic_mesh.js",
16
- "logic_mesh_bg.js",
17
- "logic_mesh.d.ts"
18
- ],
19
- "module": "logic_mesh.js",
20
- "types": "logic_mesh.d.ts",
21
- "sideEffects": [
22
- "./logic_mesh.js",
23
- "./snippets/*"
24
- ],
25
- "keywords": [
26
- "logic",
27
- "control",
28
- "reactive",
29
- "wasm",
30
- "low-code"
31
- ]
32
- }
2
+ "name": "logic-mesh",
3
+ "collaborators": [
4
+ "Radu Racariu <radu.racariu@gmail.com>"
5
+ ],
6
+ "description": "Control logic engine using event based and reactive blocks written in Rust.",
7
+ "version": "0.1.2",
8
+ "license": "BSD-3-Clause",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/rracariu/logic-mesh"
12
+ },
13
+ "files": [
14
+ "index.js",
15
+ "index.d.ts",
16
+ "logic_mesh_bg.wasm",
17
+ "logic_mesh.js",
18
+ "logic_mesh_bg.js",
19
+ "logic_mesh.d.ts"
20
+ ],
21
+ "module": "index.js",
22
+ "types": "index.d.ts",
23
+ "sideEffects": [
24
+ "./index.js",
25
+ "./logic_mesh.js",
26
+ "./snippets/*"
27
+ ],
28
+ "keywords": [
29
+ "logic",
30
+ "control",
31
+ "reactive",
32
+ "wasm",
33
+ "low-code"
34
+ ]
35
+ }
package/LICENSE DELETED
@@ -1,11 +0,0 @@
1
- Copyright 2023 Radu Racariu
2
-
3
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4
-
5
- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6
-
7
- 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8
-
9
- 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10
-
11
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.