@theclearsky/react-blender-nodes 0.0.11 → 0.0.13

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.
@@ -0,0 +1,514 @@
1
+ const i = [
2
+ "string",
3
+ "number",
4
+ "boolean",
5
+ "complex",
6
+ "noEquivalent",
7
+ "inferFromConnection"
8
+ ], L = {
9
+ [i[0]]: i[0],
10
+ [i[1]]: i[1],
11
+ [i[2]]: i[2],
12
+ [i[3]]: i[3],
13
+ [i[4]]: i[4],
14
+ [i[5]]: i[5]
15
+ };
16
+ function O(t) {
17
+ return t in L;
18
+ }
19
+ function U(t) {
20
+ return t;
21
+ }
22
+ function k(t, e) {
23
+ return t in e;
24
+ }
25
+ function q(t) {
26
+ return t;
27
+ }
28
+ function A(t) {
29
+ return t;
30
+ }
31
+ function M(t) {
32
+ return t;
33
+ }
34
+ function R(t) {
35
+ return t;
36
+ }
37
+ const m = {
38
+ locationInContextMenu: ["Standard Nodes"],
39
+ priorityInContextMenu: 200
40
+ }, B = {
41
+ locationInContextMenu: ["Group Nodes"],
42
+ priorityInContextMenu: 100
43
+ }, u = [
44
+ "groupInfer",
45
+ "loopInfer",
46
+ "switchInfer",
47
+ "condition",
48
+ "bindLoopNodes",
49
+ "bindSwitchNodes"
50
+ ], n = {
51
+ [u[0]]: u[0],
52
+ [u[1]]: u[1],
53
+ [u[2]]: u[2],
54
+ [u[3]]: u[3],
55
+ [u[4]]: u[4],
56
+ [u[5]]: u[5]
57
+ }, s = [
58
+ "groupInput",
59
+ "groupOutput",
60
+ "loopStart",
61
+ "loopEnd",
62
+ "loopStop",
63
+ "switchStart",
64
+ "switchEnd"
65
+ ], r = {
66
+ [s[0]]: s[0],
67
+ [s[1]]: s[1],
68
+ [s[2]]: s[2],
69
+ [s[3]]: s[3],
70
+ [s[4]]: s[4],
71
+ [s[5]]: s[5],
72
+ [s[6]]: s[6]
73
+ }, W = {
74
+ [n.groupInfer]: {
75
+ name: "Group Infer",
76
+ underlyingType: "inferFromConnection",
77
+ color: "#333333"
78
+ },
79
+ [n.loopInfer]: {
80
+ name: "Loop Infer",
81
+ underlyingType: "inferFromConnection",
82
+ color: "#333333"
83
+ },
84
+ [n.condition]: {
85
+ name: "Condition",
86
+ underlyingType: "boolean",
87
+ color: "#cca6d6",
88
+ allowInput: !0
89
+ },
90
+ [n.bindLoopNodes]: {
91
+ name: "Bind Loop Nodes",
92
+ underlyingType: "noEquivalent",
93
+ color: "#8c52d1",
94
+ maxConnections: 1
95
+ },
96
+ [n.switchInfer]: {
97
+ name: "Switch Infer",
98
+ underlyingType: "inferFromConnection",
99
+ color: "#333333"
100
+ },
101
+ [n.bindSwitchNodes]: {
102
+ name: "Bind Switch Nodes",
103
+ underlyingType: "noEquivalent",
104
+ color: "#8c52d1",
105
+ maxConnections: 1
106
+ }
107
+ }, G = {
108
+ [r.groupInput]: {
109
+ name: "Group Input",
110
+ headerColor: "#1d1d1d",
111
+ ...m,
112
+ inputs: [],
113
+ outputs: [
114
+ {
115
+ name: "",
116
+ dataType: n.groupInfer
117
+ }
118
+ ]
119
+ },
120
+ [r.groupOutput]: {
121
+ name: "Group Output",
122
+ headerColor: "#1d1d1d",
123
+ ...m,
124
+ inputs: [
125
+ {
126
+ name: "",
127
+ dataType: n.groupInfer
128
+ }
129
+ ],
130
+ outputs: []
131
+ },
132
+ [r.loopStart]: {
133
+ name: "Loop Start",
134
+ headerColor: "#1d1d1d",
135
+ ...m,
136
+ inputs: [
137
+ {
138
+ name: "",
139
+ dataType: n.loopInfer
140
+ }
141
+ ],
142
+ outputs: [
143
+ {
144
+ name: "Bind Loop Nodes",
145
+ dataType: n.bindLoopNodes
146
+ },
147
+ {
148
+ name: "",
149
+ dataType: n.loopInfer
150
+ }
151
+ ]
152
+ },
153
+ [r.loopStop]: {
154
+ name: "Loop Stop",
155
+ headerColor: "#1d1d1d",
156
+ ...m,
157
+ inputs: [
158
+ {
159
+ name: "Bind Loop Nodes",
160
+ dataType: n.bindLoopNodes
161
+ },
162
+ {
163
+ name: "Continue If Condition Is True",
164
+ dataType: n.condition
165
+ },
166
+ {
167
+ name: "",
168
+ dataType: n.loopInfer
169
+ }
170
+ ],
171
+ outputs: [
172
+ {
173
+ name: "Bind Loop Nodes",
174
+ dataType: n.bindLoopNodes
175
+ },
176
+ {
177
+ name: "",
178
+ dataType: n.loopInfer
179
+ }
180
+ ]
181
+ },
182
+ [r.loopEnd]: {
183
+ name: "Loop End",
184
+ headerColor: "#1d1d1d",
185
+ ...m,
186
+ inputs: [
187
+ {
188
+ name: "Bind Loop Nodes",
189
+ dataType: n.bindLoopNodes
190
+ },
191
+ {
192
+ name: "",
193
+ dataType: n.loopInfer
194
+ }
195
+ ],
196
+ outputs: [
197
+ {
198
+ name: "",
199
+ dataType: n.loopInfer
200
+ }
201
+ ]
202
+ },
203
+ [r.switchStart]: {
204
+ name: "Switch Start",
205
+ headerColor: "#1d1d1d",
206
+ ...m,
207
+ inputs: [
208
+ {
209
+ name: "",
210
+ dataType: n.switchInfer
211
+ },
212
+ {
213
+ name: "Condition",
214
+ dataType: n.condition
215
+ }
216
+ ],
217
+ outputs: [
218
+ {
219
+ name: "Bind Switch Nodes",
220
+ dataType: n.bindSwitchNodes
221
+ },
222
+ {
223
+ name: "",
224
+ dataType: n.switchInfer
225
+ },
226
+ {
227
+ name: "",
228
+ dataType: n.switchInfer
229
+ }
230
+ ]
231
+ },
232
+ [r.switchEnd]: {
233
+ name: "Switch End",
234
+ headerColor: "#1d1d1d",
235
+ ...m,
236
+ inputs: [
237
+ {
238
+ name: "Bind Switch Nodes",
239
+ dataType: n.bindSwitchNodes
240
+ },
241
+ {
242
+ name: "",
243
+ dataType: n.switchInfer
244
+ },
245
+ {
246
+ name: "",
247
+ dataType: n.switchInfer
248
+ }
249
+ ],
250
+ outputs: [
251
+ {
252
+ name: "",
253
+ dataType: n.switchInfer
254
+ }
255
+ ]
256
+ }
257
+ }, F = {
258
+ [r.groupInput]: !0,
259
+ [r.groupOutput]: !0,
260
+ [r.loopStart]: !0,
261
+ [r.loopStop]: !0,
262
+ [r.loopEnd]: !0,
263
+ [r.switchStart]: !0,
264
+ [r.switchEnd]: !0
265
+ }, V = {
266
+ // A graph may declare its own I/O via ONE root-level Graph Input + ONE Graph
267
+ // Output (maxInRoot: 1) — these become the compiled program's parameters and
268
+ // return. Inside a group exactly one of each is still required (the group's
269
+ // boundary). See `.claude/plans/root-io-editors.md`.
270
+ [r.groupInput]: {
271
+ maxInRoot: 1,
272
+ minInRoot: 0,
273
+ minWithinANodeGroup: 1,
274
+ maxWithinANodeGroup: 1
275
+ },
276
+ [r.groupOutput]: {
277
+ maxInRoot: 1,
278
+ minInRoot: 0,
279
+ minWithinANodeGroup: 1,
280
+ maxWithinANodeGroup: 1
281
+ }
282
+ }, $ = 0, j = 1, _ = 1, P = 2, z = 1, J = 2, K = 0, Y = 0, Q = 1, X = 2, Z = 1, ee = 1, ne = 0;
283
+ function N(t, e) {
284
+ return process.env.NODE_ENV !== "production" && ((t.includes(":") || t.includes(">")) && console.warn(
285
+ `react-blender-nodes: Node ID "${t}" contains reserved characters (: or >). This may cause data corruption in the runner.`
286
+ ), (e.includes(":") || e.includes(">")) && console.warn(
287
+ `react-blender-nodes: Handle ID "${e}" contains reserved characters (: or >). This may cause data corruption in the runner.`
288
+ )), `${t}:${e}`;
289
+ }
290
+ function E(t) {
291
+ const e = [];
292
+ if (!t) return e;
293
+ for (const o of t)
294
+ if ("inputs" in o)
295
+ for (const a of o.inputs)
296
+ e.push(a);
297
+ else
298
+ e.push(o);
299
+ return e;
300
+ }
301
+ class C {
302
+ store;
303
+ prefix;
304
+ parent;
305
+ constructor(e = "", o = null) {
306
+ this.store = /* @__PURE__ */ new Map(), this.prefix = e, this.parent = o;
307
+ }
308
+ /**
309
+ * Store a value for an output handle.
310
+ */
311
+ set(e, o, a) {
312
+ this.store.set(this.prefix + N(e, o), a);
313
+ }
314
+ /**
315
+ * Get a value from a specific output handle.
316
+ * Falls back to parent scope if not found locally.
317
+ */
318
+ get(e, o) {
319
+ const a = this.prefix + N(e, o);
320
+ if (this.store.has(a))
321
+ return this.store.get(a);
322
+ if (this.parent)
323
+ return this.parent.get(e, o);
324
+ }
325
+ /**
326
+ * Check if a value exists for the given handle.
327
+ */
328
+ has(e, o) {
329
+ const a = this.prefix + N(e, o);
330
+ return this.store.has(a) ? !0 : this.parent ? this.parent.has(e, o) : !1;
331
+ }
332
+ /**
333
+ * Resolve all input values for a node based on the inputResolutionMap.
334
+ *
335
+ * Returns a Map keyed by handle **name** (as required by the
336
+ * FunctionImplementation contract).
337
+ *
338
+ * Fan-in: multiple edges into one handle → connections array has N entries.
339
+ * No edges + allowInput → isDefault=true, defaultValue from the UI.
340
+ */
341
+ resolveInputs(e, o, a, c) {
342
+ const p = /* @__PURE__ */ new Map(), l = E(o.inputs);
343
+ for (const d of l) {
344
+ if (!d.id || !d.name) continue;
345
+ const I = d.id, f = d.name, T = d.inferredDataType?.dataTypeUniqueId ?? d.dataType?.dataTypeUniqueId ?? "", g = N(e, I), y = a.get(g);
346
+ if (y && y.length > 0) {
347
+ const x = [];
348
+ for (const h of y) {
349
+ const w = c.get(h.sourceNodeId), S = (w?.data.outputs ?? []).find(
350
+ (b) => b.id === h.sourceHandleId
351
+ );
352
+ x.push({
353
+ value: this.get(h.sourceNodeId, h.sourceHandleId),
354
+ sourceNodeId: h.sourceNodeId,
355
+ sourceNodeName: w?.typeOfNode?.name ?? "",
356
+ sourceNodeCustomName: w?.data.customName,
357
+ sourceNodeTypeId: w?.data.nodeTypeUniqueId ?? "",
358
+ sourceHandleId: h.sourceHandleId,
359
+ sourceHandleName: S?.name ?? "",
360
+ sourceDataTypeId: S?.inferredDataType?.dataTypeUniqueId ?? S?.dataType?.dataTypeUniqueId ?? "",
361
+ edgeId: h.edgeId
362
+ });
363
+ }
364
+ p.set(f, {
365
+ connections: x,
366
+ handleId: I,
367
+ handleName: f,
368
+ dataTypeId: T,
369
+ isDefault: !1
370
+ });
371
+ } else d.allowInput && d.value !== void 0 ? p.set(f, {
372
+ connections: [],
373
+ handleId: I,
374
+ handleName: f,
375
+ dataTypeId: T,
376
+ isDefault: !0,
377
+ defaultValue: d.value
378
+ }) : p.set(f, {
379
+ connections: [],
380
+ handleId: I,
381
+ handleName: f,
382
+ dataTypeId: T,
383
+ isDefault: !0,
384
+ defaultValue: void 0
385
+ });
386
+ }
387
+ return p;
388
+ }
389
+ /**
390
+ * Build output handle info for a node.
391
+ *
392
+ * Returns a Map keyed by handle **name** (as required by the
393
+ * FunctionImplementation contract).
394
+ */
395
+ buildOutputInfo(e, o, a) {
396
+ const c = /* @__PURE__ */ new Map(), p = o.outputs;
397
+ if (!p) return c;
398
+ for (const l of p) {
399
+ if (!l.id || !l.name) continue;
400
+ const d = l.id, I = l.name, f = l.inferredDataType?.dataTypeUniqueId ?? l.dataType?.dataTypeUniqueId ?? "", T = N(e, d), g = a.get(T) ?? [];
401
+ c.set(I, {
402
+ handleId: d,
403
+ handleName: I,
404
+ dataTypeId: f,
405
+ connections: g.map((y) => ({
406
+ targetNodeId: y.targetNodeId,
407
+ targetHandleId: y.targetHandleId,
408
+ edgeId: y.edgeId
409
+ }))
410
+ });
411
+ }
412
+ return c;
413
+ }
414
+ /**
415
+ * Snapshot the entire store for recording in ExecutionRecord.
416
+ */
417
+ snapshot() {
418
+ return new Map(this.store);
419
+ }
420
+ /**
421
+ * Create a scoped store for group execution.
422
+ * The scoped store prefixes all IDs with "groupNodeId>" and
423
+ * falls back to the parent store for reads.
424
+ *
425
+ * **Important:** The `prefix` (typically a groupNodeId) must NOT contain
426
+ * `>` or `:` characters. `>` is the scope separator and `:` is the
427
+ * handle separator used by {@link qualifiedId}. Using these characters
428
+ * will cause key collisions and data corruption.
429
+ */
430
+ createScope(e) {
431
+ return process.env.NODE_ENV !== "production" && (e.includes(">") || e.includes(":")) && console.warn(
432
+ `react-blender-nodes: Scope prefix "${e}" contains reserved characters (> or :). This may cause data corruption in the runner.`
433
+ ), new C(`${e}>`, this);
434
+ }
435
+ /**
436
+ * Clear all values with the given prefix (for loop iteration reset).
437
+ */
438
+ clearScope(e) {
439
+ const o = `${e}>`;
440
+ for (const a of this.store.keys())
441
+ a.startsWith(o) && this.store.delete(a);
442
+ }
443
+ }
444
+ const D = /* @__PURE__ */ new Set([
445
+ n.bindLoopNodes,
446
+ n.loopInfer,
447
+ n.bindSwitchNodes,
448
+ n.switchInfer,
449
+ n.condition
450
+ ]);
451
+ function H(t) {
452
+ return t.inferredDataType?.dataTypeUniqueId ?? t.dataType?.dataTypeUniqueId;
453
+ }
454
+ function te(t) {
455
+ return t.filter((e) => {
456
+ const o = H(e);
457
+ return e.id && o && !D.has(o);
458
+ }).map((e) => e.id);
459
+ }
460
+ function oe(t) {
461
+ return t.find(
462
+ (e) => H(e) === n.condition
463
+ )?.id;
464
+ }
465
+ function ae(t, e, o = "text/plain") {
466
+ if (typeof document > "u" || typeof URL > "u" || typeof URL.createObjectURL != "function")
467
+ return;
468
+ const a = new Blob([e], { type: o }), c = URL.createObjectURL(a), p = document.createElement("a");
469
+ p.href = c, p.download = t, p.click(), URL.revokeObjectURL(c);
470
+ }
471
+ function re(t, e) {
472
+ const o = t.get(e);
473
+ return o && o.connections.length > 0 ? o.connections.map((a) => a.value) : [o ? o.defaultValue : void 0];
474
+ }
475
+ export {
476
+ V as A,
477
+ u as B,
478
+ s as C,
479
+ $ as D,
480
+ j as E,
481
+ _ as F,
482
+ P as G,
483
+ z as H,
484
+ J as I,
485
+ K as J,
486
+ re as K,
487
+ C as V,
488
+ Q as a,
489
+ X as b,
490
+ Z as c,
491
+ ee as d,
492
+ ne as e,
493
+ n as f,
494
+ B as g,
495
+ E as h,
496
+ te as i,
497
+ oe as j,
498
+ ae as k,
499
+ Y as l,
500
+ O as m,
501
+ U as n,
502
+ q as o,
503
+ A as p,
504
+ N as q,
505
+ M as r,
506
+ r as s,
507
+ R as t,
508
+ L as u,
509
+ k as v,
510
+ m as w,
511
+ W as x,
512
+ G as y,
513
+ F as z
514
+ };