nodi-modular 0.0.8 → 0.0.9

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/index.d.ts CHANGED
@@ -1,12 +1,37 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  export function do_nothing_just_tell_wasm_bindgen_to_generate_types(): void;
4
- export interface NodeConnectionInterop {
5
- outputNodeId: string;
6
- outputIndex: number;
7
- inputNodeId: string;
8
- inputIndex: number;
9
- inputConnectionIndex: number | undefined;
4
+ export type GeometryInteropVec = GeometryInterop[];
5
+
6
+ export type NodeConnectionInteropVec = NodeConnectionInterop[];
7
+
8
+ export type NodePropertyInteropVec = NodePropertyInterop[];
9
+
10
+ export type NodeInteropVec = NodeInterop[];
11
+
12
+ export type EdgeInteropVec = EdgeInterop[];
13
+
14
+ export interface IndicesInteropHandle {
15
+ count: number;
16
+ indices: number;
17
+ }
18
+
19
+ export interface EdgeInterop {
20
+ source: EdgeUnitInterop<OutputId>;
21
+ destination: EdgeUnitInterop<InputId>;
22
+ empty: boolean;
23
+ }
24
+
25
+ export interface EdgeUnitInterop<IO> {
26
+ node: NodeId;
27
+ io: IO;
28
+ }
29
+
30
+ export interface GeometrySpreadsheet {
31
+ points: Point3<number>[];
32
+ curves: CurveProxy[];
33
+ surfaces: SurfaceProxy[];
34
+ meshes: MeshInterop[];
10
35
  }
11
36
 
12
37
  /**
@@ -16,13 +41,79 @@ export interface EvaluationInterop {
16
41
  /**
17
42
  * Processed nodes in the latest evaluation
18
43
  */
19
- processedNodes: NodeId[];
44
+ processedNodes: GraphNodeSet[];
20
45
  /**
21
46
  * Geometry identifiers in the latest evaluation
22
47
  */
23
48
  geometryIdentifiers: GeometryIdentifier[];
24
49
  }
25
50
 
51
+
52
+ /// Manually added types due to limitations in the `wasm-bindgen` & `tsify` crates.
53
+ export type ID<T = any> = string;
54
+ export type NodeId = ID;
55
+ export type InputId = ID;
56
+ export type OutputId = ID;
57
+ export type SubGraphId = ID;
58
+ export type SubGraphInstanceId = ID;
59
+
60
+ export type IndexMap<K, V> = Map<K, V>;
61
+
62
+ export type U1 = 1;
63
+ export type U2 = 2;
64
+ export type U3 = 3;
65
+
66
+ /// Define vector & point types with FixedLengthArray
67
+ type BuildTuple<L extends number, T, R extends any[] = []> = R['length'] extends L ? R : BuildTuple<L, T, [T, ...R]>;
68
+ type FixedLengthArray<T, L extends number> = BuildTuple<L, T>;
69
+ export type OPoint<T, D extends number> = FixedLengthArray<T, D>;
70
+ export type OVector<T, D extends number> = FixedLengthArray<T, D>;
71
+ export type Point<T, D extends number> = OPoint<T, D>;
72
+ export type SVector<T, D extends number> = OVector<T, D>;
73
+ export type Point2<T = number> = Point<T, 2>;
74
+ export type Vector2<T = number> = SVector<T, 2>;
75
+ export type Point3<T = number> = Point<T, 3>;
76
+ export type Vector3<T = number> = SVector<T, 3>;
77
+ export type Point4<T = number> = Point<T, 4>;
78
+ export type Vector4<T = number> = SVector<T, 4>;
79
+ export type Transform3<T = number> = FixedLengthArray<T, 16>;
80
+
81
+
82
+ export interface DataTreeInterop {
83
+ branches: IndexMap<string, string[]>;
84
+ }
85
+
86
+ export interface DataTreeFormatInterop {
87
+ outputs: IndexMap<string, string>;
88
+ }
89
+
90
+ /**
91
+ * Interop struct for transform
92
+ * Represents a 4x4 matrix as a 16-element array
93
+ */
94
+ export type TransformInterop = number[];
95
+
96
+ export interface MeshInteropHandle {
97
+ count: number;
98
+ vertices: number;
99
+ normals: number;
100
+ indices: IndicesInteropHandle | undefined;
101
+ transform: TransformInterop | undefined;
102
+ }
103
+
104
+ /**
105
+ * Vector display handle for wasm interop
106
+ * stride = 6 (3 for point, 3 for vector)
107
+ */
108
+ export interface VectorDisplayHandle {
109
+ count: number;
110
+ vertices: number;
111
+ }
112
+
113
+ export type DisplayProxyHandle = { variant: "Vector"; data: VectorDisplayHandle };
114
+
115
+ export type GeometryInteropHandleProxy = { variant: "Mesh"; data: MeshInteropHandle } | { variant: "Curve"; data: CurveInteropHandle } | { variant: "Group"; data: GroupInteropHandle };
116
+
26
117
  export type NodeSectionInterop = { type: "section"; content: NodeFolderInterop } | { type: "item"; content: NodeItemInterop };
27
118
 
28
119
  export interface NodeItemInterop {
@@ -36,11 +127,72 @@ export interface NodeMapInterop {
36
127
  folder: NodeFolderInterop;
37
128
  }
38
129
 
39
- export interface GeometrySpreadsheet {
40
- points: Point3<number>[];
41
- curves: CurveProxy[];
42
- surfaces: SurfaceProxy[];
43
- meshes: MeshInterop[];
130
+ export interface GroupInteropHandle {
131
+ objects: GeometryInteropHandleProxy[];
132
+ }
133
+
134
+ export interface NodeCreationSetting {
135
+ id: NodeId;
136
+ variant: string;
137
+ name?: string;
138
+ label?: string;
139
+ inputs?: number;
140
+ outputs?: number;
141
+ properties: NodePropertyInterop[];
142
+ enabled?: boolean;
143
+ visible?: boolean;
144
+ }
145
+
146
+ /**
147
+ * Interop struct for node property
148
+ */
149
+ export interface NodePropertyInterop {
150
+ /**
151
+ * Property name
152
+ */
153
+ name: string;
154
+ /**
155
+ * Property value
156
+ */
157
+ value: NodePropertyValue;
158
+ /**
159
+ * Whether the node has input connection and the property change is disabled
160
+ */
161
+ connected?: boolean;
162
+ /**
163
+ * Whether the property is disabled in node\' inspector
164
+ */
165
+ disabled?: boolean;
166
+ }
167
+
168
+ /**
169
+ * Options for adaptive tessellation to create geometry interoperability
170
+ */
171
+ export interface AdaptiveTessellationOptions {
172
+ /**
173
+ * Whether to enable adaptive tessellation
174
+ */
175
+ enabled: boolean;
176
+ /**
177
+ * Tolerance for the normal vector: if the L2 norm of the normal vectors is below this value, the edge is considered flat
178
+ */
179
+ normTolerance: number;
180
+ /**
181
+ * Minimum number of divisions in u direction
182
+ */
183
+ minDivsU: number;
184
+ /**
185
+ * Minimum number of divisions in v direction
186
+ */
187
+ minDivsV: number;
188
+ /**
189
+ * Minimum depth for division
190
+ */
191
+ minDepth: number;
192
+ /**
193
+ * Maximum depth for division
194
+ */
195
+ maxDepth: number;
44
196
  }
45
197
 
46
198
  /**
@@ -108,13 +260,20 @@ export interface NodeMetaInterop {
108
260
  hasGeometry: boolean;
109
261
  }
110
262
 
111
- /**
112
- * Interop struct for transform
113
- * Represents a 4x4 matrix as a 16-element array
114
- */
115
- export type TransformInterop = number[];
263
+ export interface NodeConnectionInterop {
264
+ outputNodeId: string;
265
+ outputIndex: number;
266
+ inputNodeId: string;
267
+ inputIndex: number;
268
+ inputConnectionIndex: number | undefined;
269
+ }
116
270
 
117
- export type GeometryInteropHandleProxy = { variant: "Mesh"; data: MeshInteropHandle } | { variant: "Curve"; data: CurveInteropHandle } | { variant: "Group"; data: GroupInteropHandle };
271
+ export interface IOInterop {
272
+ id: string;
273
+ name: string;
274
+ accessType: AccessTypes;
275
+ connections: string[];
276
+ }
118
277
 
119
278
  /**
120
279
  * Geometry identifier
@@ -123,7 +282,7 @@ export interface GeometryIdentifier {
123
282
  /**
124
283
  * Parent node ID
125
284
  */
126
- nodeId?: NodeId;
285
+ graphNodeSet?: GraphNodeSet;
127
286
  /**
128
287
  * Output ID that the geometry is belonged to
129
288
  */
@@ -138,155 +297,6 @@ export interface GeometryIdentifier {
138
297
  transform: TransformInterop;
139
298
  }
140
299
 
141
- export interface IOInterop {
142
- id: string;
143
- name: string;
144
- accessType: string;
145
- connections: string[];
146
- }
147
-
148
- export interface GroupInteropHandle {
149
- objects: GeometryInteropHandleProxy[];
150
- }
151
-
152
- /**
153
- * Interop struct for node property
154
- */
155
- export interface NodePropertyInterop {
156
- /**
157
- * Property name
158
- */
159
- name: string;
160
- /**
161
- * Property value
162
- */
163
- value: NodePropertyValue;
164
- /**
165
- * Whether the node has input connection and the property change is disabled
166
- */
167
- connected?: boolean;
168
- /**
169
- * Whether the property is disabled in node\' inspector
170
- */
171
- disabled?: boolean;
172
- }
173
-
174
- /**
175
- * Options for adaptive tessellation to create geometry interoperability
176
- */
177
- export interface AdaptiveTessellationOptions {
178
- /**
179
- * Whether to enable adaptive tessellation
180
- */
181
- enabled: boolean;
182
- /**
183
- * Tolerance for the normal vector: if the L2 norm of the normal vectors is below this value, the edge is considered flat
184
- */
185
- normTolerance: number;
186
- /**
187
- * Minimum number of divisions in u direction
188
- */
189
- minDivsU: number;
190
- /**
191
- * Minimum number of divisions in v direction
192
- */
193
- minDivsV: number;
194
- /**
195
- * Minimum depth for division
196
- */
197
- minDepth: number;
198
- /**
199
- * Maximum depth for division
200
- */
201
- maxDepth: number;
202
- }
203
-
204
- export type GeometryInteropVec = GeometryInterop[];
205
-
206
- export type NodeConnectionInteropVec = NodeConnectionInterop[];
207
-
208
- export type NodePropertyInteropVec = NodePropertyInterop[];
209
-
210
- export type NodeInteropVec = NodeInterop[];
211
-
212
- export type EdgeInteropVec = EdgeInterop[];
213
-
214
- export interface NodeCreationSetting {
215
- id: NodeId;
216
- variant: string;
217
- name?: string;
218
- label?: string;
219
- inputs?: number;
220
- outputs?: number;
221
- properties: NodePropertyInterop[];
222
- enabled?: boolean;
223
- visible?: boolean;
224
- }
225
-
226
- export interface IndicesInteropHandle {
227
- count: number;
228
- indices: number;
229
- }
230
-
231
- export interface DataTreeInterop {
232
- branches: IndexMap<string, string[]>;
233
- }
234
-
235
- export interface DataTreeFormatInterop {
236
- outputs: IndexMap<string, string>;
237
- }
238
-
239
- /**
240
- * Vector display handle for wasm interop
241
- * stride = 6 (3 for point, 3 for vector)
242
- */
243
- export interface VectorDisplayHandle {
244
- count: number;
245
- vertices: number;
246
- }
247
-
248
- export type DisplayProxyHandle = { variant: "Vector"; data: VectorDisplayHandle };
249
-
250
-
251
- /// Manually added types due to limitations in the `wasm-bindgen` & `tsify` crates.
252
- export type ID<T = any> = string;
253
- export type NodeId = ID;
254
- export type InputId = ID;
255
- export type OutputId = ID;
256
-
257
- export type IndexMap<K, V> = Map<K, V>;
258
-
259
- export type U1 = 1;
260
- export type U2 = 2;
261
- export type U3 = 3;
262
-
263
- /// Define vector & point types with FixedLengthArray
264
- type BuildTuple<L extends number, T, R extends any[] = []> = R['length'] extends L ? R : BuildTuple<L, T, [T, ...R]>;
265
- type FixedLengthArray<T, L extends number> = BuildTuple<L, T>;
266
- export type OPoint<T, D extends number> = FixedLengthArray<T, D>;
267
- export type OVector<T, D extends number> = FixedLengthArray<T, D>;
268
- export type Point<T, D extends number> = OPoint<T, D>;
269
- export type SVector<T, D extends number> = OVector<T, D>;
270
- export type Point2<T = number> = Point<T, 2>;
271
- export type Vector2<T = number> = SVector<T, 2>;
272
- export type Point3<T = number> = Point<T, 3>;
273
- export type Vector3<T = number> = SVector<T, 3>;
274
- export type Point4<T = number> = Point<T, 4>;
275
- export type Vector4<T = number> = SVector<T, 4>;
276
- export type Transform3<T = number> = FixedLengthArray<T, 16>;
277
-
278
-
279
- export interface EdgeInterop {
280
- source: EdgeUnitInterop<OutputId>;
281
- destination: EdgeUnitInterop<InputId>;
282
- empty: boolean;
283
- }
284
-
285
- export interface EdgeUnitInterop<IO> {
286
- node: NodeId;
287
- io: IO;
288
- }
289
-
290
300
  /**
291
301
  * Curve interop handle for wasm interop
292
302
  * stride = 3 (x, y, z)
@@ -297,14 +307,6 @@ export interface CurveInteropHandle {
297
307
  transform: TransformInterop | undefined;
298
308
  }
299
309
 
300
- export interface MeshInteropHandle {
301
- count: number;
302
- vertices: number;
303
- normals: number;
304
- indices: IndicesInteropHandle | undefined;
305
- transform: TransformInterop | undefined;
306
- }
307
-
308
310
  export interface NodePropertyCategoryValue {
309
311
  candidates: Map<string, number>;
310
312
  selected: number;
@@ -319,6 +321,18 @@ export interface NodePropertyRangeValue {
319
321
 
320
322
  export type NodePropertyValue = { type: "Number"; content: number } | { type: "Range"; content: NodePropertyRangeValue } | { type: "Range2d"; content: [NodePropertyRangeValue, NodePropertyRangeValue] } | { type: "String"; content: string } | { type: "Bool"; content: boolean } | { type: "NumberVector"; content: number[] } | { type: "Category"; content: NodePropertyCategoryValue } | { type: "Vector2d"; content: [number, number] } | { type: "Vector3d"; content: [number, number, number] } | { type: "Point2d"; content: [number, number] } | { type: "Point3d"; content: [number, number, number] } | { type: "Points2d"; content: [number, number][] } | { type: "Buffer"; content: number[] };
321
323
 
324
+ /**
325
+ * A set of node id and instance id
326
+ */
327
+ export interface GraphNodeSet {
328
+ subGraphIdSet: SubGraphIdSet | undefined;
329
+ nodeId: NodeId;
330
+ }
331
+
332
+ export type AccessTypes = "Item" | "List" | "Tree";
333
+
334
+ export type GraphMappingTypes = "None" | "Bezier" | "Linear" | "Sine";
335
+
322
336
  /**
323
337
  * Defines the dynamics of an IO parameter.
324
338
  */
@@ -327,6 +341,7 @@ export interface IOVariables {
327
341
  maxCount: number;
328
342
  defaultCount: number;
329
343
  offset: number;
344
+ editable: boolean;
330
345
  }
331
346
 
332
347
  /**
@@ -337,22 +352,36 @@ export interface Graph<T, U> {
337
352
  * Nodes in the graph
338
353
  */
339
354
  nodes: IndexMap<NodeId, Node<T, U>>;
355
+ /**
356
+ * nested graphs
357
+ */
358
+ sub_graphs?: IndexMap<SubGraphId, SubGraph<T, U>>;
340
359
  }
341
360
 
342
- export interface Node<T> {
343
- id: NodeId;
344
- name: string;
345
- label: string | undefined;
346
- input: InputIOManager;
347
- output: OutputIOManager;
348
- entity: T;
349
- enabled: boolean;
350
- visible: boolean;
351
- }
361
+ export type GraphVariant = "Root" | { SubGraph: SubGraphId };
352
362
 
353
- export type OutputIOManager = IOManager<OutputId, InputId>;
363
+ export interface Prune<T, U> {
364
+ connectedComponents: ConnectedComponents<T, U>[];
365
+ bypass: Connection[] | undefined;
366
+ }
354
367
 
355
- export type InputIOManager = IOManager<InputId, OutputId>;
368
+ /**
369
+ * A sub graph is a graph that is a part of a larger graph
370
+ */
371
+ export interface SubGraph<T, U> {
372
+ /**
373
+ * The id of the sub graph
374
+ */
375
+ id: SubGraphId;
376
+ /**
377
+ * The graph of the sub graph
378
+ */
379
+ graph: Graph<T, U>;
380
+ /**
381
+ * The instances of the sub graph
382
+ */
383
+ instances: SubGraphInstanceId[];
384
+ }
356
385
 
357
386
  export interface Connection {
358
387
  source: NodeParameter<OutputId>;
@@ -365,25 +394,38 @@ export interface NodeParameter<T> {
365
394
  parameterIndex: number;
366
395
  }
367
396
 
368
- export interface IOManager<T, U> {
369
- parameters: IOParameter<T, U>[];
397
+ export interface ConnectedComponentNode {
398
+ sources: NodeId[];
399
+ destinations: NodeId[];
370
400
  }
371
401
 
372
- export interface Prune<T, U> {
373
- connectedComponents: SubGraph<T, U>[];
374
- bypass: Connection[] | undefined;
402
+ export interface ConnectedComponents<T, U> {
403
+ nodes: IndexMap<NodeId, ConnectedComponentNode<T, U>>;
375
404
  }
376
405
 
377
- export interface SubGraphNode {
378
- sources: NodeId[];
379
- destinations: NodeId[];
406
+ export interface SubGraphIdSet {
407
+ subGraphId: SubGraphId;
408
+ instanceId: SubGraphInstanceId;
380
409
  }
381
410
 
382
- export interface SubGraph<T, U> {
383
- nodes: IndexMap<NodeId, SubGraphNode<T, U>>;
411
+ export interface Node<T> {
412
+ id: NodeId;
413
+ name: string;
414
+ label: string | undefined;
415
+ input: InputIOManager;
416
+ output: OutputIOManager;
417
+ entity: T;
418
+ enabled: boolean;
419
+ visible: boolean;
384
420
  }
385
421
 
386
- export type GraphMappingTypes = "None" | "Bezier" | "Linear" | "Sine";
422
+ export type OutputIOManager = IOManager<OutputId, InputId>;
423
+
424
+ export type InputIOManager = IOManager<InputId, OutputId>;
425
+
426
+ export interface IOManager<T, U> {
427
+ parameters: IOParameter<T, U>[];
428
+ }
387
429
 
388
430
 
389
431
  export type Triangle3D = {
@@ -714,7 +756,7 @@ export class Modular {
714
756
  /**
715
757
  * Change a node property with node id and property
716
758
  */
717
- changeNodeProperty(node_id: string, prop: NodePropertyInterop): boolean;
759
+ changeNodeProperty(node_id: string, prop: NodePropertyInterop, graph_id?: string | null): boolean;
718
760
  /**
719
761
  * Find a geometry by its identifier
720
762
  */
@@ -740,7 +782,7 @@ export interface InitOutput {
740
782
  readonly modular_clearGraph: (a: number) => void;
741
783
  readonly modular_evaluate: (a: number) => any;
742
784
  readonly modular_getNodes: (a: number) => [number, number];
743
- readonly modular_changeNodeProperty: (a: number, b: number, c: number, d: any) => number;
785
+ readonly modular_changeNodeProperty: (a: number, b: number, c: number, d: any, e: number, f: number) => number;
744
786
  readonly modular_findGeometryById: (a: number, b: any) => any;
745
787
  readonly modular_findGeometryInteropById: (a: number, b: any) => any;
746
788
  readonly modular_updateTessellationOptions: (a: number, b: number) => void;
@@ -754,8 +796,8 @@ export interface InitOutput {
754
796
  readonly __externref_table_dealloc: (a: number) => void;
755
797
  readonly __externref_drop_slice: (a: number, b: number) => void;
756
798
  readonly __wbindgen_free: (a: number, b: number, c: number) => void;
757
- readonly closure765_externref_shim: (a: number, b: number, c: any) => void;
758
- readonly closure3426_externref_shim: (a: number, b: number, c: any, d: any) => void;
799
+ readonly closure774_externref_shim: (a: number, b: number, c: any) => void;
800
+ readonly closure3434_externref_shim: (a: number, b: number, c: any, d: any) => void;
759
801
  readonly __wbindgen_start: () => void;
760
802
  }
761
803
 
package/index.js CHANGED
@@ -220,11 +220,11 @@ export function do_nothing_just_tell_wasm_bindgen_to_generate_types() {
220
220
  }
221
221
 
222
222
  function __wbg_adapter_52(arg0, arg1, arg2) {
223
- wasm.closure765_externref_shim(arg0, arg1, arg2);
223
+ wasm.closure774_externref_shim(arg0, arg1, arg2);
224
224
  }
225
225
 
226
226
  function __wbg_adapter_142(arg0, arg1, arg2, arg3) {
227
- wasm.closure3426_externref_shim(arg0, arg1, arg2, arg3);
227
+ wasm.closure3434_externref_shim(arg0, arg1, arg2, arg3);
228
228
  }
229
229
 
230
230
  const ModularFinalization = (typeof FinalizationRegistry === 'undefined')
@@ -310,12 +310,15 @@ export class Modular {
310
310
  * Change a node property with node id and property
311
311
  * @param {string} node_id
312
312
  * @param {NodePropertyInterop} prop
313
+ * @param {string | null} [graph_id]
313
314
  * @returns {boolean}
314
315
  */
315
- changeNodeProperty(node_id, prop) {
316
+ changeNodeProperty(node_id, prop, graph_id) {
316
317
  const ptr0 = passStringToWasm0(node_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
317
318
  const len0 = WASM_VECTOR_LEN;
318
- const ret = wasm.modular_changeNodeProperty(this.__wbg_ptr, ptr0, len0, prop);
319
+ var ptr1 = isLikeNone(graph_id) ? 0 : passStringToWasm0(graph_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
320
+ var len1 = WASM_VECTOR_LEN;
321
+ const ret = wasm.modular_changeNodeProperty(this.__wbg_ptr, ptr0, len0, prop, ptr1, len1);
319
322
  return ret !== 0;
320
323
  }
321
324
  /**
@@ -660,8 +663,8 @@ function __wbg_get_imports() {
660
663
  const ret = false;
661
664
  return ret;
662
665
  };
663
- imports.wbg.__wbindgen_closure_wrapper3236 = function(arg0, arg1, arg2) {
664
- const ret = makeMutClosure(arg0, arg1, 766, __wbg_adapter_52);
666
+ imports.wbg.__wbindgen_closure_wrapper3355 = function(arg0, arg1, arg2) {
667
+ const ret = makeMutClosure(arg0, arg1, 775, __wbg_adapter_52);
665
668
  return ret;
666
669
  };
667
670
  imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
package/index_bg.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "Masatatsu Nakamura <masatatsu.nakamura@gmail.com"
6
6
  ],
7
7
  "description": "Modular is a module project designed to import node graphs created in Nodi in JSON format, enabling the extraction of geometric data generated based on the node graph structure.",
8
- "version": "0.0.8",
8
+ "version": "0.0.9",
9
9
  "license": "MIT",
10
10
  "repository": {
11
11
  "type": "git",