logic-mesh 0.1.9 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
@@ -0,0 +1,37 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const __wbg_blocksengine_free: (a: number, b: number) => void;
5
+ export const __wbg_enginecommand_free: (a: number, b: number) => void;
6
+ export const blocksengine_engineCommand: (a: number) => number;
7
+ export const blocksengine_listBlocks: (a: number) => number;
8
+ export const blocksengine_new: (a: number, b: bigint) => number;
9
+ export const blocksengine_registerBlock: (a: number, b: number, c: number, d: number) => void;
10
+ export const blocksengine_run: (a: number) => number;
11
+ export const enginecommand_addBlock: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
12
+ export const enginecommand_createLink: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => number;
13
+ export const enginecommand_createWatch: (a: number, b: number) => number;
14
+ export const enginecommand_evalBlock: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
15
+ export const enginecommand_getProgram: (a: number) => number;
16
+ export const enginecommand_inspectBlock: (a: number, b: number, c: number) => number;
17
+ export const enginecommand_loadProgram: (a: number, b: number) => number;
18
+ export const enginecommand_pauseExecution: (a: number) => number;
19
+ export const enginecommand_removeBlock: (a: number, b: number, c: number) => number;
20
+ export const enginecommand_removeLink: (a: number, b: number, c: number) => number;
21
+ export const enginecommand_resetEngine: (a: number) => number;
22
+ export const enginecommand_resumeExecution: (a: number) => number;
23
+ export const enginecommand_stopEngine: (a: number) => number;
24
+ export const enginecommand_writeBlockInput: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
25
+ export const enginecommand_writeBlockOutput: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
26
+ export const initEngine: (a: number) => number;
27
+ export const start: () => void;
28
+ export const init_panic_hook: () => void;
29
+ export const __wasm_bindgen_func_elem_11016: (a: number, b: number, c: number, d: number) => void;
30
+ export const __wasm_bindgen_func_elem_11010: (a: number, b: number, c: number, d: number) => void;
31
+ export const __wbindgen_export: (a: number, b: number) => number;
32
+ export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
33
+ export const __wbindgen_export3: (a: number) => void;
34
+ export const __wbindgen_export4: (a: number, b: number, c: number) => void;
35
+ export const __wbindgen_export5: (a: number, b: number) => void;
36
+ export const __wbindgen_add_to_stack_pointer: (a: number) => number;
37
+ export const __wbindgen_start: () => void;
package/package.json CHANGED
@@ -4,29 +4,43 @@
4
4
  "Radu Racariu <radu.racariu@gmail.com>"
5
5
  ],
6
6
  "description": "Control logic engine using event based and reactive blocks written in Rust.",
7
- "version": "0.1.9",
7
+ "version": "0.9.0",
8
8
  "license": "BSD-3-Clause",
9
9
  "repository": {
10
10
  "type": "git",
11
11
  "url": "https://github.com/rracariu/logic-mesh"
12
12
  },
13
+ "scripts": {
14
+ "build": "wasm-pack build --release --out-dir web/packages/logic-mesh/pkg ../../.. && npm run build:prepare && tsc",
15
+ "build:dev": "wasm-pack build --dev --out-dir web/packages/logic-mesh/pkg ../../.. && npm run build:prepare && tsc",
16
+ "build:prepare": "mkdir -p dist && mv ./pkg/*.js ./pkg/*.ts ./pkg/*.wasm ./dist/ && npm version $(node -p \"require('./pkg/package.json').version\") --allow-same-version && rm -rf ./pkg",
17
+ "test": "vitest run",
18
+ "test:watch": "vitest"
19
+ },
13
20
  "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"
21
+ "dist/"
20
22
  ],
21
- "module": "index.js",
22
- "types": "index.d.ts",
23
+ "module": "dist/index.js",
24
+ "types": "./dist/index.d.ts",
25
+ "exports": {
26
+ ".": {
27
+ "types": "./dist/index.d.ts",
28
+ "import": "./dist/index.js"
29
+ }
30
+ },
23
31
  "sideEffects": [
24
- "./index.js",
25
- "./logic_mesh.js",
26
- "./snippets/*"
32
+ "./dist/index.js",
33
+ "./dist/logic_mesh.js"
27
34
  ],
35
+ "dependencies": {
36
+ "zod": "^4.4.3"
37
+ },
38
+ "devDependencies": {
39
+ "typescript": "^6.0.3",
40
+ "vitest": "^4.1.6"
41
+ },
28
42
  "keywords": [
29
- "logic",
43
+ "dataflow",
30
44
  "control",
31
45
  "reactive",
32
46
  "wasm",
package/index.d.ts DELETED
@@ -1,239 +0,0 @@
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
- /**
36
- * An optional block factory function that returns a function that is called when the block is executed.
37
- *
38
- * The execute function is called with the block inputs and should return the block outputs.
39
- * The order of the inputs and outputs is the same as the order of the pins in the block description.
40
- * Returning `undefined` will not change the output value.
41
- *
42
- * @returns The execute function that is called when the block is executed.
43
- */
44
- executor?: () => (inputs: unknown[]) => Promise<unknown[] | undefined>
45
- }
46
-
47
- /**
48
- * A block pin.
49
- *
50
- * Pins are the inputs and outputs of a block.
51
- */
52
- export interface BlockPin {
53
- /**
54
- * The pin name
55
- */
56
- name: string
57
-
58
- /**
59
- * The pin kind
60
- * Must be a valid haystack type kind.
61
- * See https://project-haystack.org/doc/docHaystack/Kinds
62
- */
63
- kind: Kind
64
-
65
- /**
66
- * The pin value
67
- * Value is a Haystack value encoded as JSON.
68
- */
69
- value?: unknown
70
-
71
- /**
72
- * True if the pin is connected to another pin.
73
- */
74
- isConnected?: boolean
75
- }
76
-
77
- /**
78
- * Describe a block that is available in block library.
79
- */
80
- export interface BlockDesc {
81
- /**
82
- * The block name
83
- */
84
- name: string
85
-
86
- /**
87
- * The block display name
88
- */
89
- dis: string
90
-
91
- /**
92
- * The block library name
93
- */
94
- lib: string
95
-
96
- /**
97
- * The block library version
98
- */
99
- ver: string
100
-
101
- /**
102
- * The block category
103
- */
104
- category: string
105
-
106
- /**
107
- * The block documentation
108
- */
109
- doc: string
110
-
111
- /**
112
- * The block implementation
113
- */
114
- implementation: 'native' | 'external'
115
-
116
- /**
117
- * The block inputs
118
- */
119
- inputs: BlockPin[]
120
-
121
- /**
122
- * The block outputs
123
- */
124
- outputs: BlockPin[]
125
-
126
- /**
127
- * The block run condition.
128
- *
129
- * If not set, the block will be executed when any of its inputs change.
130
- * Otherwise, the block will execute regularly according to the run condition.
131
- *
132
- * Default: 'change'
133
- */
134
- runCondition?: 'change' | 'always'
135
- }
136
-
137
- /**
138
- * Notification on a block change
139
- */
140
- export interface BlockNotification {
141
- /**
142
- * The block id
143
- */
144
- id: string
145
-
146
- /**
147
- * The changes
148
- */
149
- changes: {
150
- /**
151
- * The block pin name
152
- */
153
- name: string
154
- /**
155
- * The block pin source
156
- */
157
- source: string
158
- /**
159
- * The value that was changed on this pin
160
- */
161
- value: {}
162
- }[]
163
- }
164
-
165
- export interface LinkData {
166
- /**
167
- * The link id
168
- */
169
- id?: string
170
-
171
- /**
172
- * The link source block pin name
173
- */
174
- sourceBlockPinName: string
175
-
176
- /**
177
- * The link source block uuid
178
- */
179
- sourceBlockUuid: string
180
-
181
- /**
182
- * The link target block pin name
183
- */
184
- targetBlockPinName: string
185
-
186
- /**
187
- * The link target block uuid
188
- */
189
- targetBlockUuid: string
190
- }
191
-
192
- /**
193
- * Describes a program that would be loaded in the engine.
194
- *
195
- * The program is a set of blocks and links between them.
196
- * The program and the blocks have meta data that would be used in the editor
197
- * for example to position the blocks.
198
- */
199
- export interface Program {
200
- /**
201
- * The program name
202
- */
203
- name: string
204
-
205
- /**
206
- * Optional program description
207
- */
208
- description?: string
209
-
210
- /**
211
- * Blocks used in the program
212
- */
213
- blocks: {
214
- [blockUuid: string]: {
215
- name: string
216
- lib: string
217
-
218
- positions: {
219
- x: number
220
- y: number
221
- }
222
-
223
- inputs?: {
224
- [pinName: string]: { value?: unknown; isConnected?: boolean }
225
- }
226
-
227
- outputs?: {
228
- [pinName: string]: { value?: unknown; isConnected?: boolean }
229
- }
230
- }
231
- }
232
-
233
- /**
234
- * Links between blocks
235
- */
236
- links: {
237
- [linkUuid: string]: LinkData
238
- }
239
- }
package/index.js DELETED
@@ -1 +0,0 @@
1
- export { BlocksEngine, EngineCommand, initEngine } from "./logic_mesh.js";
package/logic_mesh.d.ts DELETED
@@ -1,211 +0,0 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
- /**
4
- * @param {number | undefined} [sleep_duration]
5
- * @returns {BlocksEngine}
6
- */
7
- export function initEngine(sleep_duration?: number): BlocksEngine;
8
- /**
9
- */
10
- export function start(): void;
11
- /**
12
- */
13
- export function init_panic_hook(): void;
14
- /**
15
- * Controls the execution or the blocks.
16
- * Loads programs and enables inspection and debugging
17
- * of the blocks and their inputs and outputs.
18
- */
19
- export class BlocksEngine {
20
- free(): void;
21
- /**
22
- * Create a new instance of an engine
23
- * @param {bigint | undefined} [sleep_duration]
24
- */
25
- constructor(sleep_duration?: bigint);
26
- /**
27
- * Lists all available blocks
28
- * @returns {Array<any>}
29
- */
30
- listBlocks(): Array<any>;
31
- /**
32
- * Register a new JS block in the registry
33
- * The block is described by a JsBlockDesc object
34
- *
35
- * # Arguments
36
- * * `desc` - The description of the block
37
- * * `func` - Optional function that implements the block
38
- * logic. If not provided, the block would do nothing.
39
- *
40
- * # Returns
41
- * The name of the block
42
- *
43
- * @param {any} desc
44
- * @param {Function | undefined} [func]
45
- * @returns {string}
46
- */
47
- registerBlock(desc: any, func?: Function): string;
48
- /**
49
- * @returns {EngineCommand}
50
- */
51
- engineCommand(): EngineCommand;
52
- /**
53
- * Runs the engine asynchronously
54
- * After this is called, the engine instance can't be used directly
55
- * Instead use the command object to communicate with the engine.
56
- * @returns {Promise<void>}
57
- */
58
- run(): Promise<void>;
59
- }
60
- /**
61
- * Commands a running instance of a Block Engine.
62
- */
63
- export class EngineCommand {
64
- free(): void;
65
- /**
66
- * Adds a block instance to the engine
67
- * to be immediately scheduled for execution
68
- * @param {string} block_name
69
- * @param {string | undefined} [block_uuid]
70
- * @param {string | undefined} [lib]
71
- * @returns {Promise<string>}
72
- */
73
- addBlock(block_name: string, block_uuid?: string, lib?: string): Promise<string>;
74
- /**
75
- * Removes a block instance from the engine
76
- * to be immediately unscheduled for execution
77
- * and removed from the engine together with all its links.
78
- *
79
- * # Arguments
80
- * * `block_uuid` - The UUID of the block to be removed
81
- *
82
- * # Returns
83
- * The UUID of the removed block
84
- * @param {string} block_uuid
85
- * @returns {Promise<string>}
86
- */
87
- removeBlock(block_uuid: string): Promise<string>;
88
- /**
89
- * Creates a link between two blocks
90
- *
91
- * # Arguments
92
- * * `source_block_uuid` - The UUID of the source block
93
- * * `target_block_uuid` - The UUID of the target block
94
- * * `source_block_pin_name` - The name of the output pin of the source block
95
- * * `target_block_input_name` - The name of the input pin of the target block
96
- *
97
- * # Returns
98
- * A `LinkData` object with the following properties:
99
- * * `source_block_uuid` - The UUID of the source block
100
- * * `target_block_uuid` - The UUID of the target block
101
- * * `source_block_pin_name` - The name of the output pin of the source block
102
- * * `target_block_input_name` - The name of the input pin of the target block
103
- * @param {string} source_block_uuid
104
- * @param {string} target_block_uuid
105
- * @param {string} source_block_pin_name
106
- * @param {string} target_block_pin_name
107
- * @returns {Promise<any>}
108
- */
109
- createLink(source_block_uuid: string, target_block_uuid: string, source_block_pin_name: string, target_block_pin_name: string): Promise<any>;
110
- /**
111
- * Removes a link between two blocks
112
- *
113
- * # Arguments
114
- * * `link_uuid` - The UUID of the link to be removed
115
- *
116
- * # Returns
117
- * True if the link was removed, false otherwise
118
- * @param {string} link_uuid
119
- * @returns {Promise<boolean>}
120
- */
121
- removeLink(link_uuid: string): Promise<boolean>;
122
- /**
123
- * Writes the given block out with a value
124
- *
125
- * # Arguments
126
- * * `block_uuid` - The UUID of the block to write to
127
- * * `output_name` - The name of the output to write to
128
- * * `value` - The value to write
129
- *
130
- * # Returns
131
- * The block data
132
- * @param {string} block_uuid
133
- * @param {string} output_name
134
- * @param {any} value
135
- * @returns {Promise<any>}
136
- */
137
- writeBlockOutput(block_uuid: string, output_name: string, value: any): Promise<any>;
138
- /**
139
- * Writes the given block input with a value
140
- *
141
- * # Arguments
142
- * * `block_uuid` - The UUID of the block to write to
143
- * * `input_name` - The name of the input to write to
144
- * * `value` - The value to write
145
- *
146
- * # Returns
147
- * The previous value of the input
148
- * @param {string} block_uuid
149
- * @param {string} input_name
150
- * @param {any} value
151
- * @returns {Promise<any>}
152
- */
153
- writeBlockInput(block_uuid: string, input_name: string, value: any): Promise<any>;
154
- /**
155
- * Get the current running engine program.
156
- * The program contains the scheduled blocks, their properties, and their links.
157
- * @returns {Promise<any>}
158
- */
159
- getProgram(): Promise<any>;
160
- /**
161
- * Inspects the current state of a block
162
- * @param {string} block_uuid
163
- * @returns {Promise<any>}
164
- */
165
- inspectBlock(block_uuid: string): Promise<any>;
166
- /**
167
- * Evaluates a block by name
168
- * This will create a block instance and execute it.
169
- *
170
- * # Arguments
171
- * * `block_name` - The name of the block to evaluate
172
- * * `inputs` - The input values to the block
173
- * * `lib` - Optional, the library to load the block from, defaults to "core"
174
- *
175
- * # Returns
176
- * A list of values representing the outputs of the block
177
- * @param {string} block_name
178
- * @param {any[]} inputs
179
- * @param {string | undefined} [lib]
180
- * @returns {Promise<any>}
181
- */
182
- evalBlock(block_name: string, inputs: any[], lib?: string): Promise<any>;
183
- /**
184
- * Creates a watch on block changes
185
- * @param {Function} callback
186
- * @returns {Promise<void>}
187
- */
188
- createWatch(callback: Function): Promise<void>;
189
- /**
190
- * Pauses the execution of the engine
191
- * If the engine is already paused, this does nothing
192
- * @returns {Promise<void>}
193
- */
194
- pauseExecution(): Promise<void>;
195
- /**
196
- * Resumes the execution of the engine
197
- * If the engine is not paused, this does nothing
198
- * @returns {Promise<void>}
199
- */
200
- resumeExecution(): Promise<void>;
201
- /**
202
- * Resets the engine state, clears all blocks and links
203
- * @returns {Promise<void>}
204
- */
205
- resetEngine(): Promise<void>;
206
- /**
207
- * Stop the engine's execution
208
- * @returns {Promise<void>}
209
- */
210
- stopEngine(): Promise<void>;
211
- }