@ankhzet/graph 0.4.1 → 0.5.1
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/CHANGELOG.md +12 -0
- package/dist/index.d.ts +42 -10
- package/dist/index.js +300 -305
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/GraphCanvas.tsx +8 -1
- package/src/ManagedGraph.tsx +9 -5
- package/src/graph/nodes/index.ts +1 -1
- package/src/graph/nodes/layout/LayeredLayout.ts +32 -61
- package/src/graph/nodes/layout/Layout.ts +1 -1
- package/src/graph/nodes/layout/Layouter.ts +10 -10
- package/src/index.ts +1 -0
- package/src/utils.ts +0 -4
package/dist/index.js
CHANGED
|
@@ -13,22 +13,53 @@ var S = Object.defineProperty, C = Object.getOwnPropertyDescriptor, w = Object.g
|
|
|
13
13
|
enumerable: !0
|
|
14
14
|
});
|
|
15
15
|
return t || S(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
16
|
-
},
|
|
16
|
+
}, D = (e, t, n, r) => {
|
|
17
17
|
if (t && typeof t == "object" || typeof t == "function") for (var i = w(t), a = 0, o = i.length, s; a < o; a++) s = i[a], !T.call(e, s) && s !== n && S(e, s, {
|
|
18
18
|
get: ((e) => t[e]).bind(null, s),
|
|
19
19
|
enumerable: !(r = C(t, s)) || r.enumerable
|
|
20
20
|
});
|
|
21
21
|
return e;
|
|
22
|
-
},
|
|
22
|
+
}, O = (e, t, n) => (D(e, t, "default"), n && D(n, t, "default")), ee = 16, te = 8, ne = 16, re = 32, ie = class {
|
|
23
|
+
grid;
|
|
24
|
+
gridSize;
|
|
25
|
+
sizes;
|
|
26
|
+
constructor({ grid: e = 16, port: t = 8, lane: n = 16, space: r = 32 } = {}) {
|
|
27
|
+
this.grid = e, this.gridSize = {
|
|
28
|
+
x: e,
|
|
29
|
+
y: e
|
|
30
|
+
}, this.sizes = {
|
|
31
|
+
grid: this.gridSize,
|
|
32
|
+
port: t,
|
|
33
|
+
lane: n,
|
|
34
|
+
space: r
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
snap(e) {
|
|
38
|
+
let t = e < 0 ? -1 : 1;
|
|
39
|
+
return t * (Math.round(t * e / this.grid + .5) - .5) * this.grid;
|
|
40
|
+
}
|
|
41
|
+
toGraph({ x: e, y: t }) {
|
|
42
|
+
return {
|
|
43
|
+
x: (e - .5) * this.grid,
|
|
44
|
+
y: (t - .5) * this.grid
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
toData({ x: e, y: t }) {
|
|
48
|
+
return {
|
|
49
|
+
x: ~~(this.snap(e) / this.grid + .5),
|
|
50
|
+
y: ~~(this.snap(t) / this.grid + .5)
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}, ae = ({ description: { item: e } }) => e.isolator ? e.title : null, k = (e, t, n = 1) => ({
|
|
23
54
|
x: ~~(e.x + t.x * n),
|
|
24
55
|
y: ~~(e.y + t.y * n)
|
|
25
|
-
}),
|
|
56
|
+
}), A = (e, t) => (n) => n.node === e && n.port === t, oe = (e) => (t) => t.node === e, se = (e, t, n) => {
|
|
26
57
|
if (n) for (let r of n) {
|
|
27
|
-
let n = t.nodes.findIndex(
|
|
58
|
+
let n = t.nodes.findIndex(A(r.node, r.port));
|
|
28
59
|
n >= 0 !== e && (e ? t.nodes.push(r) : t.nodes.splice(n, 1));
|
|
29
60
|
}
|
|
30
61
|
else e || (t.nodes = []);
|
|
31
|
-
},
|
|
62
|
+
}, ce = (e, t, n, r, i, a, o, s) => {
|
|
32
63
|
if (e === n && t === r || i === o && a === s) return !1;
|
|
33
64
|
let c = (s - a) * (n - e) - (o - i) * (r - t);
|
|
34
65
|
if (c === 0) return !1;
|
|
@@ -37,7 +68,7 @@ var S = Object.defineProperty, C = Object.getOwnPropertyDescriptor, w = Object.g
|
|
|
37
68
|
x: e + l * (n - e),
|
|
38
69
|
y: t + l * (r - t)
|
|
39
70
|
};
|
|
40
|
-
},
|
|
71
|
+
}, j = class {
|
|
41
72
|
joints = /* @__PURE__ */ new Map();
|
|
42
73
|
parentId;
|
|
43
74
|
constructor(e, t) {
|
|
@@ -64,16 +95,16 @@ var S = Object.defineProperty, C = Object.getOwnPropertyDescriptor, w = Object.g
|
|
|
64
95
|
return !!this.getPort(e, t);
|
|
65
96
|
}
|
|
66
97
|
hasAtPort(e, t, n) {
|
|
67
|
-
return !!this.joints.get(e)?.nodes.some(
|
|
98
|
+
return !!this.joints.get(e)?.nodes.some(A(t, n));
|
|
68
99
|
}
|
|
69
100
|
getPort(e, t) {
|
|
70
|
-
let n = this.find(t === void 0 ? (t) => t.nodes.some(
|
|
101
|
+
let n = this.find(t === void 0 ? (t) => t.nodes.some(oe(e)) : (n) => n.nodes.some(A(e, t)));
|
|
71
102
|
if (n) return n.port;
|
|
72
103
|
}
|
|
73
104
|
connect({ port: e, target: t, connect: n }) {
|
|
74
105
|
let r = this.joints.get(e);
|
|
75
106
|
if (!r) throw Error(`Node ${this.parentId} does not have joint "${e}"`);
|
|
76
|
-
return
|
|
107
|
+
return se(n, r, t), r;
|
|
77
108
|
}
|
|
78
109
|
getNodes(e) {
|
|
79
110
|
return this.joints.get(e)?.nodes;
|
|
@@ -86,7 +117,7 @@ var S = Object.defineProperty, C = Object.getOwnPropertyDescriptor, w = Object.g
|
|
|
86
117
|
get count() {
|
|
87
118
|
return this.joints.size;
|
|
88
119
|
}
|
|
89
|
-
},
|
|
120
|
+
}, le = Symbol("E_CONNECT"), M = Symbol("E_MOVE"), N = class extends e {
|
|
90
121
|
id;
|
|
91
122
|
description;
|
|
92
123
|
inputs;
|
|
@@ -97,7 +128,7 @@ var S = Object.defineProperty, C = Object.getOwnPropertyDescriptor, w = Object.g
|
|
|
97
128
|
y: 0
|
|
98
129
|
};
|
|
99
130
|
constructor({ id: e, coordinator: t, inputs: n = [], outputs: r = [], ...i }) {
|
|
100
|
-
super(), this.id = e, this.coordinator = t, this.description = i, this.inputs = new
|
|
131
|
+
super(), this.id = e, this.coordinator = t, this.description = i, this.inputs = new j(e, n), this.outputs = new j(e, r);
|
|
101
132
|
}
|
|
102
133
|
get title() {
|
|
103
134
|
return this.description.title;
|
|
@@ -154,7 +185,7 @@ var S = Object.defineProperty, C = Object.getOwnPropertyDescriptor, w = Object.g
|
|
|
154
185
|
nodes: a
|
|
155
186
|
});
|
|
156
187
|
}
|
|
157
|
-
this.dispatchEvent(
|
|
188
|
+
this.dispatchEvent(le, {
|
|
158
189
|
connect: t,
|
|
159
190
|
input: e,
|
|
160
191
|
source: i,
|
|
@@ -165,12 +196,12 @@ var S = Object.defineProperty, C = Object.getOwnPropertyDescriptor, w = Object.g
|
|
|
165
196
|
return this.position = e;
|
|
166
197
|
}
|
|
167
198
|
onConnect(e) {
|
|
168
|
-
return this.handleEvent(
|
|
199
|
+
return this.handleEvent(le, e);
|
|
169
200
|
}
|
|
170
201
|
onMove(e) {
|
|
171
202
|
return this.handleEvent(M, e);
|
|
172
203
|
}
|
|
173
|
-
},
|
|
204
|
+
}, P = class {
|
|
174
205
|
_barriers = {};
|
|
175
206
|
_isBarrier;
|
|
176
207
|
map;
|
|
@@ -231,32 +262,22 @@ var S = Object.defineProperty, C = Object.getOwnPropertyDescriptor, w = Object.g
|
|
|
231
262
|
y: (i.y - r.y) / 2
|
|
232
263
|
};
|
|
233
264
|
}
|
|
234
|
-
},
|
|
265
|
+
}, ue = class extends P {
|
|
235
266
|
layers = [];
|
|
236
|
-
|
|
267
|
+
#e = null;
|
|
237
268
|
get center() {
|
|
238
|
-
return this
|
|
269
|
+
return this.#e ??= this.getCenter((e) => e.position);
|
|
239
270
|
}
|
|
240
271
|
spread(e, t) {
|
|
241
|
-
let n = [], r =
|
|
242
|
-
|
|
243
|
-
let t = this.map[i], a = this.shift(t, this.findLayer(t), e, n);
|
|
244
|
-
r = Math.max(r, a);
|
|
245
|
-
}
|
|
246
|
-
return r;
|
|
272
|
+
let n = [], r = this.get(t).map((t) => this.shift(t, this.findLayer(t), e, n));
|
|
273
|
+
return Math.max(...r);
|
|
247
274
|
}
|
|
248
275
|
findMax(e) {
|
|
249
|
-
let t = this.findLayers(this.get(e.inputs.ids))
|
|
250
|
-
|
|
251
|
-
let t = +e;
|
|
252
|
-
t > n && (n = t);
|
|
253
|
-
}
|
|
254
|
-
return n || 0;
|
|
276
|
+
let t = this.findLayers(this.get(e.inputs.ids));
|
|
277
|
+
return Math.max(0, ...Object.values(t));
|
|
255
278
|
}
|
|
256
279
|
dependants({ id: e }) {
|
|
257
|
-
|
|
258
|
-
for (let n of this.nodes) n.id !== e && n.inputs.has(e) && t.push(n);
|
|
259
|
-
return t;
|
|
280
|
+
return this.nodes.filter((t) => t.id !== e && t.inputs.has(e));
|
|
260
281
|
}
|
|
261
282
|
get(e) {
|
|
262
283
|
return e.map((e) => this.map[e]).filter(n);
|
|
@@ -265,19 +286,17 @@ var S = Object.defineProperty, C = Object.getOwnPropertyDescriptor, w = Object.g
|
|
|
265
286
|
return this.layers[t] ? delete this.layers[t][e.id] : !1;
|
|
266
287
|
}
|
|
267
288
|
put(e, t) {
|
|
268
|
-
|
|
269
|
-
n[e.id] = e;
|
|
289
|
+
(this.layers[t] ??= {})[e.id] = e;
|
|
270
290
|
}
|
|
271
291
|
findLayer(e) {
|
|
272
|
-
|
|
273
|
-
return 0;
|
|
292
|
+
return Math.max(0, this.layers.findIndex((t) => t[e.id]));
|
|
274
293
|
}
|
|
275
294
|
findLayers(e) {
|
|
276
295
|
let t = {};
|
|
277
|
-
for (let n
|
|
278
|
-
let
|
|
279
|
-
for (let
|
|
280
|
-
e = e.filter((e) => i.
|
|
296
|
+
for (let [n, r] of this.layers.entries()) {
|
|
297
|
+
let i = e.filter((e) => r[e.id]).map((e) => e.id);
|
|
298
|
+
for (let e of i) t[e] = n;
|
|
299
|
+
e = e.filter((e) => !i.includes(e.id));
|
|
281
300
|
}
|
|
282
301
|
return t;
|
|
283
302
|
}
|
|
@@ -304,7 +323,7 @@ var S = Object.defineProperty, C = Object.getOwnPropertyDescriptor, w = Object.g
|
|
|
304
323
|
if (n && !1 === t(n)) break;
|
|
305
324
|
}
|
|
306
325
|
}
|
|
307
|
-
},
|
|
326
|
+
}, de = class extends P {
|
|
308
327
|
cache = {};
|
|
309
328
|
hash = null;
|
|
310
329
|
get center() {
|
|
@@ -337,7 +356,7 @@ var S = Object.defineProperty, C = Object.getOwnPropertyDescriptor, w = Object.g
|
|
|
337
356
|
}
|
|
338
357
|
return this.hash = null, a;
|
|
339
358
|
}
|
|
340
|
-
},
|
|
359
|
+
}, fe = class {
|
|
341
360
|
sort(e) {
|
|
342
361
|
let t = {}, n = {}, r = [];
|
|
343
362
|
for (let i of e) {
|
|
@@ -389,7 +408,7 @@ var S = Object.defineProperty, C = Object.getOwnPropertyDescriptor, w = Object.g
|
|
|
389
408
|
leafs: r
|
|
390
409
|
};
|
|
391
410
|
}
|
|
392
|
-
},
|
|
411
|
+
}, pe = class {
|
|
393
412
|
sort(e, t, n) {
|
|
394
413
|
let r = n.pop();
|
|
395
414
|
for (let e of r);
|
|
@@ -402,19 +421,21 @@ var S = Object.defineProperty, C = Object.getOwnPropertyDescriptor, w = Object.g
|
|
|
402
421
|
}
|
|
403
422
|
return n;
|
|
404
423
|
}
|
|
405
|
-
},
|
|
424
|
+
}, me = class {
|
|
406
425
|
isBarrier;
|
|
407
426
|
klass;
|
|
408
427
|
constructor(e, t) {
|
|
409
428
|
this.klass = e, this.isBarrier = t;
|
|
410
429
|
}
|
|
411
430
|
layout(e, t) {
|
|
412
|
-
|
|
431
|
+
let n = new this.klass(e, this.isBarrier), r = n.getSubGraphs(t), i = 0;
|
|
432
|
+
for (let e of r) i += n.spread(i, e);
|
|
433
|
+
return n;
|
|
413
434
|
}
|
|
414
|
-
getSubGraphs(e) {
|
|
415
|
-
return new this.klass(e, this.isBarrier).getSubGraphs();
|
|
435
|
+
getSubGraphs(e, t) {
|
|
436
|
+
return new this.klass(e, this.isBarrier).getSubGraphs(t);
|
|
416
437
|
}
|
|
417
|
-
},
|
|
438
|
+
}, F = Symbol("changed"), I = class extends e {
|
|
418
439
|
all;
|
|
419
440
|
map = {};
|
|
420
441
|
constructor(e = []) {
|
|
@@ -422,7 +443,7 @@ var S = Object.defineProperty, C = Object.getOwnPropertyDescriptor, w = Object.g
|
|
|
422
443
|
}
|
|
423
444
|
clear() {
|
|
424
445
|
let e = this.all;
|
|
425
|
-
this.all = [], this.map = {}, this.dispatchEvent(
|
|
446
|
+
this.all = [], this.map = {}, this.dispatchEvent(F, {
|
|
426
447
|
diff: e,
|
|
427
448
|
added: !1
|
|
428
449
|
});
|
|
@@ -439,22 +460,22 @@ var S = Object.defineProperty, C = Object.getOwnPropertyDescriptor, w = Object.g
|
|
|
439
460
|
add(e) {
|
|
440
461
|
let t = Array.isArray(e) ? e : [e], n = [];
|
|
441
462
|
for (let e of t) this.all.includes(e) || (n.push(e), this.map[e.id] = e);
|
|
442
|
-
return n.length && (this.all = this.all.concat(n), this.dispatchEvent(
|
|
463
|
+
return n.length && (this.all = this.all.concat(n), this.dispatchEvent(F)), e;
|
|
443
464
|
}
|
|
444
465
|
remove(e) {
|
|
445
466
|
Array.isArray(e) || (e = [e]);
|
|
446
467
|
let t = this.all.filter((t) => !e.includes(t.id));
|
|
447
468
|
if (t.length !== this.all.length) {
|
|
448
469
|
for (let t of e) delete this.map[t];
|
|
449
|
-
this.all = t, this.dispatchEvent(
|
|
470
|
+
this.all = t, this.dispatchEvent(F);
|
|
450
471
|
}
|
|
451
472
|
return this;
|
|
452
473
|
}
|
|
453
474
|
onChange(e) {
|
|
454
|
-
return this.handleEvent(
|
|
475
|
+
return this.handleEvent(F, e);
|
|
455
476
|
}
|
|
456
|
-
},
|
|
457
|
-
function
|
|
477
|
+
}, L = (e, t) => e === t ? !0 : e.length === t.length ? e.every((e, n) => e.id === t[n]?.id) : !1;
|
|
478
|
+
function he(e) {
|
|
458
479
|
let [[t, n]] = l(() => {
|
|
459
480
|
let t = e();
|
|
460
481
|
return [t, [
|
|
@@ -462,7 +483,7 @@ function L(e) {
|
|
|
462
483
|
() => t.all,
|
|
463
484
|
() => t.all,
|
|
464
485
|
(e) => e,
|
|
465
|
-
|
|
486
|
+
L
|
|
466
487
|
]];
|
|
467
488
|
});
|
|
468
489
|
return o(() => () => {
|
|
@@ -471,7 +492,7 @@ function L(e) {
|
|
|
471
492
|
}
|
|
472
493
|
//#endregion
|
|
473
494
|
//#region src/graph/useDraggable.tsx
|
|
474
|
-
var
|
|
495
|
+
var ge = (e) => {
|
|
475
496
|
let t = e.position, [n, r] = l(() => ({
|
|
476
497
|
x: t.x,
|
|
477
498
|
y: t.y
|
|
@@ -505,24 +526,24 @@ var R = (e) => {
|
|
|
505
526
|
e.onDrag(t), r(t);
|
|
506
527
|
})
|
|
507
528
|
};
|
|
508
|
-
},
|
|
509
|
-
import * as
|
|
510
|
-
|
|
511
|
-
import * as
|
|
512
|
-
|
|
513
|
-
import * as
|
|
514
|
-
|
|
515
|
-
import * as
|
|
516
|
-
|
|
517
|
-
import * as
|
|
518
|
-
|
|
519
|
-
import * as
|
|
520
|
-
|
|
521
|
-
import * as
|
|
522
|
-
|
|
529
|
+
}, R = /* @__PURE__ */ E({});
|
|
530
|
+
import * as _e from "@pixi/core";
|
|
531
|
+
O(R, _e);
|
|
532
|
+
import * as ve from "@pixi/display";
|
|
533
|
+
O(R, ve);
|
|
534
|
+
import * as ye from "@pixi/sprite";
|
|
535
|
+
O(R, ye);
|
|
536
|
+
import * as be from "@pixi/graphics";
|
|
537
|
+
O(R, be);
|
|
538
|
+
import * as xe from "@pixi/text";
|
|
539
|
+
O(R, xe);
|
|
540
|
+
import * as Se from "@pixi/text-bitmap";
|
|
541
|
+
O(R, Se);
|
|
542
|
+
import * as Ce from "@pixi/events";
|
|
543
|
+
O(R, Ce);
|
|
523
544
|
//#endregion
|
|
524
545
|
//#region src/graph/render/Batch.ts
|
|
525
|
-
var
|
|
546
|
+
var z = class extends e {
|
|
526
547
|
counter;
|
|
527
548
|
constructor() {
|
|
528
549
|
super(), this.counter = 0;
|
|
@@ -543,12 +564,12 @@ var _e = class extends e {
|
|
|
543
564
|
and(e) {
|
|
544
565
|
return this.handleEvent(".", e);
|
|
545
566
|
}
|
|
546
|
-
},
|
|
567
|
+
}, we = [
|
|
547
568
|
[0, -1],
|
|
548
569
|
[-1, 0],
|
|
549
570
|
[0, 1],
|
|
550
571
|
[1, 0]
|
|
551
|
-
],
|
|
572
|
+
], Te = Math.PI * 2, Ee = Math.PI / 2, De = class extends R.Graphics {
|
|
552
573
|
sizeX;
|
|
553
574
|
sizeY;
|
|
554
575
|
lineSize;
|
|
@@ -560,10 +581,10 @@ var _e = class extends e {
|
|
|
560
581
|
#n;
|
|
561
582
|
#r;
|
|
562
583
|
constructor(e, { lineSize: t, sizeX: n, sizeY: r, radius: i, color: a }) {
|
|
563
|
-
super(), this.lineSize = t, this.color = a, this.sizeX = n, this.sizeY = r, this.#t = new
|
|
584
|
+
super(), this.lineSize = t, this.color = a, this.sizeX = n, this.sizeY = r, this.#t = new R.Graphics().lineStyle({
|
|
564
585
|
width: t,
|
|
565
586
|
color: a
|
|
566
|
-
}).drawRoundedRect(0, 0, n, r, i), this.#e = new
|
|
587
|
+
}).drawRoundedRect(0, 0, n, r, i), this.#e = new R.Graphics(), this.#e.position.set(n / 2, r / 2), this.#t.mask = this.#e, this.addChild(e), this.addChild(this.#t), this.addChild(this.#e), this.progress = 0;
|
|
567
588
|
let o = this.sizeX / 2, s = this.sizeY / 2, c = -o + this.lineSize, l = -s + this.lineSize, u = +o - this.lineSize, d = +s - this.lineSize, f = [
|
|
568
589
|
[
|
|
569
590
|
c,
|
|
@@ -615,11 +636,11 @@ var _e = class extends e {
|
|
|
615
636
|
}
|
|
616
637
|
update(e) {
|
|
617
638
|
this.progress = e;
|
|
618
|
-
let t = e *
|
|
639
|
+
let t = e * Te % Te, n = Math.cos(t - Ee) * this.sizeX * 2, r = Math.sin(t - Ee) * this.sizeY * 2, i, a = null, o = 0;
|
|
619
640
|
for (let e = 0; e < this.#r.segments.length; e++) {
|
|
620
|
-
let t = this.#r.segments[e], s =
|
|
641
|
+
let t = this.#r.segments[e], s = ce(0, 0, n, r, t[0], t[1], t[2], t[3]);
|
|
621
642
|
if (s) {
|
|
622
|
-
a = s, o = e === 0 ? s.x > 0 ? 0 : 4 : 4 - e, i =
|
|
643
|
+
a = s, o = e === 0 ? s.x > 0 ? 0 : 4 : 4 - e, i = we[e];
|
|
623
644
|
break;
|
|
624
645
|
}
|
|
625
646
|
}
|
|
@@ -629,7 +650,7 @@ var _e = class extends e {
|
|
|
629
650
|
this.#e.lineTo(a.x + i[0] * this.lineSize * 2, a.y + i[1] * this.lineSize * 2).lineTo(a.x, a.y).lineTo(0, 0).endFill();
|
|
630
651
|
}
|
|
631
652
|
}
|
|
632
|
-
}, B = class extends
|
|
653
|
+
}, B = class extends R.Graphics {
|
|
633
654
|
from;
|
|
634
655
|
to;
|
|
635
656
|
angled = !1;
|
|
@@ -637,7 +658,7 @@ var _e = class extends e {
|
|
|
637
658
|
#e;
|
|
638
659
|
#t = 2;
|
|
639
660
|
constructor(e, t, n, r, i = 2) {
|
|
640
|
-
super(), this.#e = i, this.from = new
|
|
661
|
+
super(), this.#e = i, this.from = new R.ObservablePoint(() => this.update(), 0, e, t), this.to = new R.ObservablePoint(() => this.update(), 0, n, r), this.eventMode = "none";
|
|
641
662
|
}
|
|
642
663
|
moveFromPoint(e) {
|
|
643
664
|
let t = this.from.x !== e.x || this.from.y !== e.y;
|
|
@@ -657,11 +678,11 @@ var _e = class extends e {
|
|
|
657
678
|
let { x: e, y: t } = this.from, { x: n, y: r } = this.to, i = n - e, a = r - t, o = i / 2, s = a / 2;
|
|
658
679
|
return this.clear(), this.lineStyle(this.#t, this.color, this.alpha), this.x = n - o, this.y = r - s, this.angled ? (this.moveTo(-o, -s), this.lineTo(0, -s), this.lineTo(0, s), this.lineTo(o, s)) : (this.moveTo(-o, -s), this.lineTo(o, s)), this.#e && (this.beginFill(this.color, this.alpha), this.drawCircle(-o, -s, this.#e / 2), this.drawCircle(o, s, this.#e / 2), this.endFill()), this;
|
|
659
680
|
}
|
|
660
|
-
},
|
|
681
|
+
}, Oe = class extends R.Graphics {
|
|
661
682
|
from;
|
|
662
683
|
to;
|
|
663
684
|
constructor(e, t) {
|
|
664
|
-
super(), this.from = new
|
|
685
|
+
super(), this.from = new R.Point(e, t), this.to = {};
|
|
665
686
|
for (let e of Object.values(this.to)) this.addChild(e);
|
|
666
687
|
}
|
|
667
688
|
addTarget(e, t) {
|
|
@@ -683,26 +704,26 @@ var _e = class extends e {
|
|
|
683
704
|
}
|
|
684
705
|
return t;
|
|
685
706
|
}
|
|
686
|
-
},
|
|
707
|
+
}, ke = {
|
|
687
708
|
0: 6710886,
|
|
688
709
|
2: 16737894,
|
|
689
710
|
1: 6750054
|
|
690
|
-
},
|
|
711
|
+
}, Ae = {
|
|
691
712
|
0: 6710886,
|
|
692
713
|
2: 11167334,
|
|
693
714
|
1: 16724787
|
|
694
|
-
},
|
|
715
|
+
}, je = (e, t, n) => {
|
|
695
716
|
let { point: { parent: r, input: i } } = e;
|
|
696
717
|
if (t.hover) {
|
|
697
718
|
let a = r === t.point.parent || i === t.point.input ? 2 : 1;
|
|
698
719
|
if (a && n) {
|
|
699
|
-
let n = e.point.nodes.some(
|
|
720
|
+
let n = e.point.nodes.some(A(t.point.parent, t.point.port)), r = t.point.nodes.some(A(e.point.parent, e.point.port));
|
|
700
721
|
return n && r ? 1 : 0;
|
|
701
722
|
}
|
|
702
723
|
return a;
|
|
703
724
|
}
|
|
704
725
|
return 0;
|
|
705
|
-
},
|
|
726
|
+
}, Me = (e, t) => e.parent === t.parent && e.port === t.port, Ne = class extends R.Graphics {
|
|
706
727
|
line1;
|
|
707
728
|
line2;
|
|
708
729
|
line12;
|
|
@@ -727,14 +748,14 @@ var _e = class extends e {
|
|
|
727
748
|
setPosition(e) {
|
|
728
749
|
return this.x = e.x, this.y = e.y, this;
|
|
729
750
|
}
|
|
730
|
-
},
|
|
751
|
+
}, Pe = class extends Oe {
|
|
731
752
|
start;
|
|
732
753
|
finish;
|
|
733
754
|
viable;
|
|
734
755
|
#e;
|
|
735
756
|
#t;
|
|
736
757
|
constructor(e) {
|
|
737
|
-
super(e.pos.x, e.pos.y), this.start = e, this.viable = 0, this.#e = this.addTarget(0, 0), this.#t = new
|
|
758
|
+
super(e.pos.x, e.pos.y), this.start = e, this.viable = 0, this.#e = this.addTarget(0, 0), this.#t = new Ne(10, 16724787).hide(), this.addChild(this.#t);
|
|
738
759
|
}
|
|
739
760
|
get isRemoving() {
|
|
740
761
|
return this.start.remove || !!this.finish?.remove;
|
|
@@ -747,18 +768,18 @@ var _e = class extends e {
|
|
|
747
768
|
x: t + a / 2,
|
|
748
769
|
y: n + o / 2
|
|
749
770
|
};
|
|
750
|
-
this.#t.setColor(
|
|
771
|
+
this.#t.setColor(Ae[this.viable]).setPosition(e).setAngle(s).show(), this.viable === 0 && (this.#e.visible = !1, this.#t.hide());
|
|
751
772
|
} else this.#t.hide();
|
|
752
|
-
this.#e.setColor(this.isRemoving ?
|
|
773
|
+
this.#e.setColor(this.isRemoving ? Ae[this.viable] : ke[this.viable]).moveToPoint(e);
|
|
753
774
|
}
|
|
754
775
|
flail(e) {
|
|
755
776
|
this.finish || this.setLine(e);
|
|
756
777
|
}
|
|
757
778
|
hoverPort(e) {
|
|
758
|
-
this.viable =
|
|
779
|
+
this.viable = je(this.start, e, this.isRemoving), this.finish = this.viable === 1 ? e : void 0, this.setLine(e.pos);
|
|
759
780
|
}
|
|
760
781
|
connect({ point: e }) {
|
|
761
|
-
if (this.finish &&
|
|
782
|
+
if (this.finish && Me(this.finish.point, e)) {
|
|
762
783
|
let { start: { remove: e, point: t }, finish: { remove: n, point: r } } = this, i = t.input ? t : r, a = t.input ? r : t;
|
|
763
784
|
return {
|
|
764
785
|
connect: !(e || n),
|
|
@@ -768,8 +789,8 @@ var _e = class extends e {
|
|
|
768
789
|
}
|
|
769
790
|
return !1;
|
|
770
791
|
}
|
|
771
|
-
}, V = class extends
|
|
772
|
-
static makeFont = (e, t, n) => typeof document < "u" &&
|
|
792
|
+
}, V = class extends R.Container {
|
|
793
|
+
static makeFont = (e, t, n) => typeof document < "u" && R.BitmapFont.from(e, t, {
|
|
773
794
|
chars: [
|
|
774
795
|
["a", "z"],
|
|
775
796
|
["A", "Z"],
|
|
@@ -787,7 +808,7 @@ var _e = class extends e {
|
|
|
787
808
|
fontName: e
|
|
788
809
|
}));
|
|
789
810
|
constructor(e, t) {
|
|
790
|
-
super(), this.#e = this.addChild(new
|
|
811
|
+
super(), this.#e = this.addChild(new R.BitmapText(String(e), t));
|
|
791
812
|
}
|
|
792
813
|
set text(e) {
|
|
793
814
|
this.#e.text = String(e);
|
|
@@ -798,7 +819,7 @@ var _e = class extends e {
|
|
|
798
819
|
set tint(e) {
|
|
799
820
|
this.#e.tint = e;
|
|
800
821
|
}
|
|
801
|
-
}, H = Symbol.for("E_PORT_CLICK"), U = Symbol.for("E_PORT_HOVER"),
|
|
822
|
+
}, H = Symbol.for("E_PORT_CLICK"), U = Symbol.for("E_PORT_HOVER"), Fe = class t extends R.Graphics {
|
|
802
823
|
connectorPoint;
|
|
803
824
|
hasBothLanes;
|
|
804
825
|
static port = V.factory("nodePort", {
|
|
@@ -847,12 +868,12 @@ var _e = class extends e {
|
|
|
847
868
|
x: n.x,
|
|
848
869
|
y: n.y
|
|
849
870
|
};
|
|
850
|
-
},
|
|
851
|
-
function
|
|
871
|
+
}, Ie = (e) => e.__drag_root ? e : e.parent && Ie(e.parent);
|
|
872
|
+
function Le(e) {
|
|
852
873
|
return function(t) {
|
|
853
874
|
if (e.dispatchEvent(G, !0), t.buttons & 2) return;
|
|
854
875
|
let n = this._drag_meta = {
|
|
855
|
-
root:
|
|
876
|
+
root: Ie(this.parent) || (() => {
|
|
856
877
|
throw Error("Can't find scene root");
|
|
857
878
|
})(),
|
|
858
879
|
emitter: e,
|
|
@@ -860,8 +881,8 @@ function je(e) {
|
|
|
860
881
|
anchor: this.position.clone(),
|
|
861
882
|
lastPosition: K(t),
|
|
862
883
|
newPosition: K(t),
|
|
863
|
-
onDragEnd:
|
|
864
|
-
onDragMove:
|
|
884
|
+
onDragEnd: ze(this),
|
|
885
|
+
onDragMove: Re(this)
|
|
865
886
|
};
|
|
866
887
|
n.root.addEventListener("pointerup", n.onDragEnd, {
|
|
867
888
|
capture: !0,
|
|
@@ -875,18 +896,18 @@ function je(e) {
|
|
|
875
896
|
});
|
|
876
897
|
};
|
|
877
898
|
}
|
|
878
|
-
var
|
|
899
|
+
var Re = (e) => (t) => {
|
|
879
900
|
if (!e._drag_meta?.dragging) return;
|
|
880
901
|
let { newPosition: n, lastPosition: r, anchor: i, emitter: a } = e._drag_meta;
|
|
881
902
|
K(t, n), n.x -= r.x, n.y -= r.y, a.dispatchEvent(W, {
|
|
882
903
|
x: i.x + n.x,
|
|
883
904
|
y: i.y + n.y
|
|
884
905
|
});
|
|
885
|
-
},
|
|
906
|
+
}, ze = (e) => () => {
|
|
886
907
|
if (!e._drag_meta) return;
|
|
887
908
|
let { root: t, emitter: n, onDragEnd: r, onDragMove: i } = e._drag_meta;
|
|
888
909
|
t.removeEventListener("pointerup", r), t.removeEventListener("pointerupoutside", r), t.removeEventListener("pointermove", i), n.dispatchEvent(G, !1), delete e._drag_meta;
|
|
889
|
-
}, q = Symbol.for("E_NODE_CONTEXT"), J = Symbol.for("E_CONNECTORS_UPDATE"),
|
|
910
|
+
}, q = Symbol.for("E_NODE_CONTEXT"), J = Symbol.for("E_CONNECTORS_UPDATE"), Be = class t extends e {
|
|
890
911
|
static label = V.factory("nodeLabel", {
|
|
891
912
|
fontSize: 24,
|
|
892
913
|
align: "center",
|
|
@@ -897,7 +918,7 @@ var Me = (e) => (t) => {
|
|
|
897
918
|
#e;
|
|
898
919
|
#t;
|
|
899
920
|
#n;
|
|
900
|
-
#r =
|
|
921
|
+
#r = Le(this);
|
|
901
922
|
data;
|
|
902
923
|
find;
|
|
903
924
|
ports = /* @__PURE__ */ new Map();
|
|
@@ -934,12 +955,12 @@ var Me = (e) => (t) => {
|
|
|
934
955
|
#i({ connect: e, input: t, source: { port: n }, target: r }) {
|
|
935
956
|
let i = this.connectors.find((e) => e.port === n && e.input === t);
|
|
936
957
|
if (!i) return;
|
|
937
|
-
|
|
958
|
+
se(e, i, r);
|
|
938
959
|
let a = this.ports.get(n);
|
|
939
960
|
a && a.setActive(!!i.nodes.length);
|
|
940
961
|
}
|
|
941
962
|
connectedAt(e, t, n) {
|
|
942
|
-
return this.connectors.find(({ nodes: r, connector: i }) => n !== !i && r.length && r.some(
|
|
963
|
+
return this.connectors.find(({ nodes: r, connector: i }) => n !== !i && r.length && r.some(A(e, t)));
|
|
943
964
|
}
|
|
944
965
|
get connectors() {
|
|
945
966
|
if (this.#n) return this.#n;
|
|
@@ -950,7 +971,7 @@ var Me = (e) => (t) => {
|
|
|
950
971
|
let n = {
|
|
951
972
|
x: 16 / 2,
|
|
952
973
|
y: t * 16 + 16 / 2
|
|
953
|
-
}, r =
|
|
974
|
+
}, r = k(this.data.position, n);
|
|
954
975
|
this.#n.push({
|
|
955
976
|
parent: this.data.id,
|
|
956
977
|
port: e.port,
|
|
@@ -959,7 +980,7 @@ var Me = (e) => (t) => {
|
|
|
959
980
|
input: !0,
|
|
960
981
|
x: n.x,
|
|
961
982
|
y: n.y,
|
|
962
|
-
connector: new
|
|
983
|
+
connector: new Oe(r.x, r.y)
|
|
963
984
|
}), t++;
|
|
964
985
|
}
|
|
965
986
|
for (let t of this.data.outputs) this.#n.push({
|
|
@@ -977,11 +998,11 @@ var Me = (e) => (t) => {
|
|
|
977
998
|
let t = /* @__PURE__ */ new Map(), n = [];
|
|
978
999
|
for (let r of this.connectors) {
|
|
979
1000
|
let { connector: i, nodes: a, port: o } = r, s = `${this.id}-${o}`;
|
|
980
|
-
if (i) if (i.move(
|
|
1001
|
+
if (i) if (i.move(k(this.renderable, r)), a.length) {
|
|
981
1002
|
let e = 0;
|
|
982
1003
|
for (let { node: t, port: n } of a) {
|
|
983
1004
|
let r = this.find(t), a = r?.connectedAt(this.id, o);
|
|
984
|
-
r && a ? (i.moveTargetTo(t, n,
|
|
1005
|
+
r && a ? (i.moveTargetTo(t, n, k(r.renderable, a)), e++) : i.removeTarget(t, n);
|
|
985
1006
|
}
|
|
986
1007
|
e && t.set(s, i);
|
|
987
1008
|
} else n.push(s);
|
|
@@ -1026,7 +1047,7 @@ var Me = (e) => (t) => {
|
|
|
1026
1047
|
return o.eventMode = "static", o.addEventListener("pointerdown", (e) => this.handleClick(e)), o.x = this.data.position.x, o.y = this.data.position.y, this.#t = o;
|
|
1027
1048
|
}
|
|
1028
1049
|
makeRoundRect({ stroke: e, fill: t, x: n = 0, y: r = 0, width: i, height: a, thickness: o = 1, radius: s = 4 }) {
|
|
1029
|
-
let c = new
|
|
1050
|
+
let c = new R.Graphics();
|
|
1030
1051
|
return c.lineStyle(o, e), c.beginFill(t), c.drawRoundedRect(0, 0, i, a, s), c.endFill(), c.x = n, c.y = r, c;
|
|
1031
1052
|
}
|
|
1032
1053
|
makeLane(e) {
|
|
@@ -1038,7 +1059,7 @@ var Me = (e) => (t) => {
|
|
|
1038
1059
|
}, e));
|
|
1039
1060
|
}
|
|
1040
1061
|
makePort(e, t) {
|
|
1041
|
-
let { port: n, x: r, y: i } = e, a = new
|
|
1062
|
+
let { port: n, x: r, y: i } = e, a = new Fe(e, t);
|
|
1042
1063
|
return this.ports.set(n, a), a.onClick((t) => {
|
|
1043
1064
|
if (t.buttons & 2) return this.dispatchEvent(q, {
|
|
1044
1065
|
event: t,
|
|
@@ -1103,13 +1124,13 @@ var Me = (e) => (t) => {
|
|
|
1103
1124
|
}
|
|
1104
1125
|
this.placeConnectors();
|
|
1105
1126
|
}
|
|
1106
|
-
},
|
|
1127
|
+
}, Ve = {
|
|
1107
1128
|
x: 0,
|
|
1108
1129
|
y: 0
|
|
1109
|
-
},
|
|
1130
|
+
}, He = (e, t) => e.cell.x === t.cell.x && e.cell.y === t.cell.y && e.count.x === t.count.x && e.count.y === t.count.y && e.size.width === t.size.width && e.size.height === t.size.height, Y = (e, t, n) => e > t ? e < n ? e : n : t, X = (e, t, n, r, i) => Y(e - t / 2, n + i, r - t - i), Ue = (e) => {
|
|
1110
1131
|
let t = Math.ceil(e);
|
|
1111
1132
|
return t % 2 ? t + 1 : t;
|
|
1112
|
-
},
|
|
1133
|
+
}, We = class e extends R.Graphics {
|
|
1113
1134
|
static text = V.factory("GridBoundary", {
|
|
1114
1135
|
fontSize: 24,
|
|
1115
1136
|
fill: 16777215,
|
|
@@ -1124,10 +1145,10 @@ var Me = (e) => (t) => {
|
|
|
1124
1145
|
#n;
|
|
1125
1146
|
#r;
|
|
1126
1147
|
#i;
|
|
1127
|
-
#a = new
|
|
1148
|
+
#a = new R.Rectangle(0, 0, 0, 0);
|
|
1128
1149
|
#o = {
|
|
1129
|
-
cell:
|
|
1130
|
-
count:
|
|
1150
|
+
cell: Ve,
|
|
1151
|
+
count: Ve,
|
|
1131
1152
|
size: {
|
|
1132
1153
|
width: 0,
|
|
1133
1154
|
height: 0
|
|
@@ -1136,13 +1157,13 @@ var Me = (e) => (t) => {
|
|
|
1136
1157
|
#s;
|
|
1137
1158
|
#c;
|
|
1138
1159
|
constructor(t, n, r = 5) {
|
|
1139
|
-
super(), this.cellSize = t, this.colors = n, this.#e = r, this.#s = this.addChild(new
|
|
1160
|
+
super(), this.cellSize = t, this.colors = n, this.#e = r, this.#s = this.addChild(new R.Container()), this.#c = this.addChild(new R.Container()), this.#n = e.text("", { fontSize: 12 }), this.#t = e.text("", { fontSize: 12 }), this.#i = e.text("", { fontSize: 12 }), this.#r = e.text("", { fontSize: 12 });
|
|
1140
1161
|
}
|
|
1141
1162
|
get lods() {
|
|
1142
1163
|
return this.colors.length;
|
|
1143
1164
|
}
|
|
1144
1165
|
snapSize({ width: e, height: t }, n) {
|
|
1145
|
-
let { x: r, y: i } = this.cellSize, a = n ? 2 ** (n - 1) * this.#e : 1, o = a * r, s = a * i, c =
|
|
1166
|
+
let { x: r, y: i } = this.cellSize, a = n ? 2 ** (n - 1) * this.#e : 1, o = a * r, s = a * i, c = Ue(e / o), l = Ue(t / s);
|
|
1146
1167
|
return {
|
|
1147
1168
|
cell: {
|
|
1148
1169
|
x: o,
|
|
@@ -1164,24 +1185,24 @@ var Me = (e) => (t) => {
|
|
|
1164
1185
|
viewport(e) {
|
|
1165
1186
|
this.makeRullers(e);
|
|
1166
1187
|
let t = this.toMaxSnap(this.#a), n = this.toMaxSnap(e);
|
|
1167
|
-
this.#s.x = (e.left + e.width) % n.cell.x, this.#s.y = (e.top + e.height) % n.cell.y, !
|
|
1188
|
+
this.#s.x = (e.left + e.width) % n.cell.x, this.#s.y = (e.top + e.height) % n.cell.y, !He(t, n) && (this.#a.copyFrom(e), this.#o = n, this.update());
|
|
1168
1189
|
}
|
|
1169
1190
|
makeRullers(e) {
|
|
1170
1191
|
this.#c.removeChildren();
|
|
1171
|
-
let t = this.#c.addChild(new
|
|
1192
|
+
let t = this.#c.addChild(new R.Graphics()), { left: n, top: r, width: i, height: a } = e, o = n + i, s = r + a, c = Y(o, 1, i - 1), l = Y(s, 1, a - 1);
|
|
1172
1193
|
t.lineStyle(2, 16711680, 1), t.moveTo(0, l), t.lineTo(i, l), t.moveTo(c, 0), t.lineTo(c, a), this.#c.addChild(this.#n, this.#t, this.#i, this.#r), this.#n.text = ~~(-(i + n) / this.cellSize.x), this.#i.text = ~~(-(a + r) / this.cellSize.y), this.#t.text = ~~(-n / this.cellSize.x), this.#r.text = ~~(-r / this.cellSize.y);
|
|
1173
1194
|
let u = this.#n.height, d = this.#n.width, f = this.#t.width, p = this.#i.width, m = this.#r.width, h = X(l, u, 0, a, 2), g = X(c, p, d + 5, i - f - 5, 2), _ = X(c, m, d + 5, i - f - 5, 2);
|
|
1174
1195
|
this.#n.x = 2, this.#n.y = h, this.#t.x = i - f - 2, this.#t.y = h, this.#i.x = g, this.#i.y = 2, this.#r.x = _, this.#r.y = a - u - 2;
|
|
1175
1196
|
}
|
|
1176
1197
|
makeLOD(e) {
|
|
1177
|
-
let t = this.colors[e], { cell: { x: n, y: r }, count: { x: i, y: a }, size: { width: o, height: s } } = this.snapSize(this.#o.size, e), c = new
|
|
1198
|
+
let t = this.colors[e], { cell: { x: n, y: r }, count: { x: i, y: a }, size: { width: o, height: s } } = this.snapSize(this.#o.size, e), c = new R.Graphics();
|
|
1178
1199
|
c.lineStyle(.25 * (e + 1), t, 1);
|
|
1179
1200
|
for (let e = 0; e < i; e++) c.moveTo(n * e, 0), c.lineTo(n * e, s);
|
|
1180
1201
|
for (let e = 0; e < a; e++) c.moveTo(0, r * e), c.lineTo(o, r * e);
|
|
1181
1202
|
return c;
|
|
1182
1203
|
}
|
|
1183
1204
|
makeGrid() {
|
|
1184
|
-
let e = new
|
|
1205
|
+
let e = new R.Container();
|
|
1185
1206
|
for (let t of this.colors.keys()) e.addChild(this.makeLOD(t));
|
|
1186
1207
|
return e;
|
|
1187
1208
|
}
|
|
@@ -1193,7 +1214,7 @@ var Me = (e) => (t) => {
|
|
|
1193
1214
|
i.x = n * e, i.y = r * t, this.#s.addChild(i);
|
|
1194
1215
|
}
|
|
1195
1216
|
}
|
|
1196
|
-
},
|
|
1217
|
+
}, Ge = 24, Z = 12, Ke = class e extends R.Container {
|
|
1197
1218
|
static label = V.factory("menuItem", {
|
|
1198
1219
|
fontSize: 24,
|
|
1199
1220
|
align: "center",
|
|
@@ -1204,13 +1225,13 @@ var Me = (e) => (t) => {
|
|
|
1204
1225
|
#n;
|
|
1205
1226
|
#r;
|
|
1206
1227
|
#i = 0;
|
|
1207
|
-
#a =
|
|
1228
|
+
#a = Ge;
|
|
1208
1229
|
#o = !1;
|
|
1209
1230
|
#s = !1;
|
|
1210
1231
|
#c = !1;
|
|
1211
1232
|
index;
|
|
1212
1233
|
constructor(t, n, r) {
|
|
1213
|
-
super(), this.index = t, this.#n = n, this.#s = !!n.separator, this.#r = !!n.group, this.#c = !!n.disabled || this.#r, this.#e = this.addChild(new
|
|
1234
|
+
super(), this.index = t, this.#n = n, this.#s = !!n.separator, this.#r = !!n.group, this.#c = !!n.disabled || this.#r, this.#e = this.addChild(new R.Graphics()), this.#t = this.addChild(e.label(this.label, { fontSize: 12 })), this.eventMode = "static", this.addEventListener("pointerdown", (e) => {
|
|
1214
1235
|
this.#c || (e.stopPropagation(), e.preventDefault(), r());
|
|
1215
1236
|
});
|
|
1216
1237
|
}
|
|
@@ -1251,7 +1272,7 @@ var Me = (e) => (t) => {
|
|
|
1251
1272
|
let e = this.width, t = this.height, n = this.#e;
|
|
1252
1273
|
this.separator ? (n.lineStyle(1, 1638, 1), n.moveTo(Z, 1), n.lineTo(e - Z, 1)) : this.#r ? (n.lineStyle(0, 0, 1), n.beginFill(3355443), n.drawRect(-1, 1, e + 2, t - 2), n.endFill()) : this.hover ? (n.lineStyle(0, 0, 1), n.beginFill(4473924), n.drawRoundedRect(0, 0, e, t, 4), n.endFill()) : n.clear(), this.#t.text = this.#n.label, this.#t.x = Z, this.#t.y = (t - this.#t.height) / 2, this.#t.alpha = this.#c && !this.#r ? .3 : 1, this.#t.tint = this.#r || this.hover ? 16777215 : 0;
|
|
1253
1274
|
}
|
|
1254
|
-
},
|
|
1275
|
+
}, qe = Symbol.for("E_ITEM_SELECT"), Je = Symbol.for("E_CLOSE_MENU"), Ye = new R.Point(), Xe = class extends R.Container {
|
|
1255
1276
|
#e;
|
|
1256
1277
|
#t;
|
|
1257
1278
|
#n;
|
|
@@ -1259,8 +1280,8 @@ var Me = (e) => (t) => {
|
|
|
1259
1280
|
#i;
|
|
1260
1281
|
#a = -1;
|
|
1261
1282
|
constructor(t) {
|
|
1262
|
-
super(), this.#i = new e(), this.#n = this.addChild(new
|
|
1263
|
-
this.hoverIndex = this.getItemAtY(e.getLocalPosition(this,
|
|
1283
|
+
super(), this.#i = new e(), this.#n = this.addChild(new R.Graphics()), this.#e = this.addChild(new R.Graphics()), this.#t = this.addChild(new R.Container()), this.#r = t.items.map((e, t) => this.#t.addChild(new Ke(t, e, () => this.handleSelect(e)))), this.#t.mask = this.#n, this.eventMode = "static", this.addEventListener("pointermove", (e) => {
|
|
1284
|
+
this.hoverIndex = this.getItemAtY(e.getLocalPosition(this, Ye).y);
|
|
1264
1285
|
}), this.addEventListener("pointerleave", () => {
|
|
1265
1286
|
this.hoverIndex = -1;
|
|
1266
1287
|
}), this.update();
|
|
@@ -1282,16 +1303,16 @@ var Me = (e) => (t) => {
|
|
|
1282
1303
|
n && (n.hover = t);
|
|
1283
1304
|
}
|
|
1284
1305
|
handleSelect(e) {
|
|
1285
|
-
this.#i.dispatchEvent(
|
|
1306
|
+
this.#i.dispatchEvent(qe, e);
|
|
1286
1307
|
}
|
|
1287
1308
|
close() {
|
|
1288
|
-
this.visible = !1, this.#i.dispatchEvent(
|
|
1309
|
+
this.visible = !1, this.#i.dispatchEvent(Je);
|
|
1289
1310
|
}
|
|
1290
1311
|
onSelect(e) {
|
|
1291
|
-
return this.#i.handleEvent(
|
|
1312
|
+
return this.#i.handleEvent(qe, e);
|
|
1292
1313
|
}
|
|
1293
1314
|
onClose(e) {
|
|
1294
|
-
return this.#i.handleEvent(
|
|
1315
|
+
return this.#i.handleEvent(Je, e);
|
|
1295
1316
|
}
|
|
1296
1317
|
get width() {
|
|
1297
1318
|
return Math.max(...this.#r.map((e) => e.labelWidth));
|
|
@@ -1307,7 +1328,7 @@ var Me = (e) => (t) => {
|
|
|
1307
1328
|
let i = 0;
|
|
1308
1329
|
for (let t of this.#r) t.y = i, t.resize(e), i += t.height;
|
|
1309
1330
|
}
|
|
1310
|
-
},
|
|
1331
|
+
}, Ze = class {
|
|
1311
1332
|
ticker;
|
|
1312
1333
|
nodes = /* @__PURE__ */ new Map();
|
|
1313
1334
|
connectors = /* @__PURE__ */ new Map();
|
|
@@ -1331,7 +1352,7 @@ var Me = (e) => (t) => {
|
|
|
1331
1352
|
#e = t(() => this.ticker.speed = .05, 1e3);
|
|
1332
1353
|
#t = (e) => this.nodes.get(e);
|
|
1333
1354
|
constructor({ maxFPS: e, grid: t, gui: n = [] }) {
|
|
1334
|
-
this.ticker = new
|
|
1355
|
+
this.ticker = new R.Ticker(), this.world = new R.Container(), this.root = new R.Container(), this.overlay = new R.Container(), this.grid = new We(t.cellSize, t.colors), this.world.sortableChildren = !0, this.ticker.maxFPS = e, this.world.__drag_root = !0, this.gui = n, this.root.addChild(this.grid), this.root.addChild(this.world), this.root.addChild(this.overlay), this.root.addChild(...n), this.ticker.add(this.render.bind(this)), this.world.eventMode = "static", this.world.hitArea = { contains: () => !0 }, this.world.addEventListener("pointermove", (e) => {
|
|
1335
1356
|
this.handlePointerMove(this.fromGlobal(e.global));
|
|
1336
1357
|
}), this.world.addEventListener("pointerdown", (e) => {
|
|
1337
1358
|
this.handlePointerDown(this.fromGlobal(e.global), e);
|
|
@@ -1343,7 +1364,7 @@ var Me = (e) => (t) => {
|
|
|
1343
1364
|
get renderer() {
|
|
1344
1365
|
if (!this._renderer) {
|
|
1345
1366
|
let { viewport: e } = this.options;
|
|
1346
|
-
this._renderer = (0,
|
|
1367
|
+
this._renderer = (0, R.autoDetectRenderer)({
|
|
1347
1368
|
width: e.width,
|
|
1348
1369
|
height: e.height,
|
|
1349
1370
|
antialias: e.antialias,
|
|
@@ -1379,13 +1400,13 @@ var Me = (e) => (t) => {
|
|
|
1379
1400
|
};
|
|
1380
1401
|
}
|
|
1381
1402
|
fromGlobal(e) {
|
|
1382
|
-
return
|
|
1403
|
+
return k(e, this.world.transform.position, -1);
|
|
1383
1404
|
}
|
|
1384
1405
|
fromLocal(e) {
|
|
1385
|
-
return
|
|
1406
|
+
return k(k(e, this.world.transform.position, -2), this.center);
|
|
1386
1407
|
}
|
|
1387
1408
|
offsetPos(e, t = 1) {
|
|
1388
|
-
return
|
|
1409
|
+
return k(e, this.center, t);
|
|
1389
1410
|
}
|
|
1390
1411
|
translate(e) {
|
|
1391
1412
|
this.world.transform.position.copyFrom(this.offsetPos(e)), this.overlay.transform.position.copyFrom(this.offsetPos(e)), this.updateViewport();
|
|
@@ -1397,7 +1418,7 @@ var Me = (e) => (t) => {
|
|
|
1397
1418
|
this.closeMenu();
|
|
1398
1419
|
let r = e.getMenu(t, n);
|
|
1399
1420
|
if (r) {
|
|
1400
|
-
let t = this.overlay.addChild(Object.assign(new
|
|
1421
|
+
let t = this.overlay.addChild(Object.assign(new Xe(r), n));
|
|
1401
1422
|
return t.onSelect((t) => {
|
|
1402
1423
|
!1 !== e.handleMenu(t.data) && this.closeMenu();
|
|
1403
1424
|
}), t.onClose(() => {
|
|
@@ -1407,7 +1428,7 @@ var Me = (e) => (t) => {
|
|
|
1407
1428
|
}
|
|
1408
1429
|
addNode(e) {
|
|
1409
1430
|
if (this.#t(e.id)) return;
|
|
1410
|
-
let t = new
|
|
1431
|
+
let t = new Be(e, this.#t);
|
|
1411
1432
|
t.onMove((t) => {
|
|
1412
1433
|
this._pending || this.moveNodeTo(e.id, t);
|
|
1413
1434
|
}), t.onCapture((t) => {
|
|
@@ -1424,7 +1445,7 @@ var Me = (e) => (t) => {
|
|
|
1424
1445
|
t && (this.connectNodes(t), this.pending = null);
|
|
1425
1446
|
return;
|
|
1426
1447
|
}
|
|
1427
|
-
this.pending = new
|
|
1448
|
+
this.pending = new Pe(e);
|
|
1428
1449
|
}
|
|
1429
1450
|
}), t.onPortHover((e) => this.pending?.hoverPort(e)), t.onConnectorsUpdate(({ add: e, remove: t }) => {
|
|
1430
1451
|
if (e) for (let { uid: t, connector: n } of e) this.addConnector(t, n);
|
|
@@ -1526,7 +1547,7 @@ var Me = (e) => (t) => {
|
|
|
1526
1547
|
}
|
|
1527
1548
|
updateViewport() {
|
|
1528
1549
|
let { width: e, height: t, translation: { x: n, y: r } } = this;
|
|
1529
|
-
e && t && this.grid.viewport(new
|
|
1550
|
+
e && t && this.grid.viewport(new R.Rectangle(n - e / 2, r - t / 2, e, t));
|
|
1530
1551
|
}
|
|
1531
1552
|
render() {
|
|
1532
1553
|
this.renderer?.render(this.root);
|
|
@@ -1534,7 +1555,7 @@ var Me = (e) => (t) => {
|
|
|
1534
1555
|
update() {
|
|
1535
1556
|
this.ticker.update();
|
|
1536
1557
|
}
|
|
1537
|
-
},
|
|
1558
|
+
}, Qe = "\nPort:\n LMB - start connecting\n LMB + (Meta | Ctrl) - start disconnecting\nCanvas:\n LMB + Shift - drag while connecting/disconnecting", Q = class e extends R.Container {
|
|
1538
1559
|
static text = V.factory("GUIText", {
|
|
1539
1560
|
fontSize: 16,
|
|
1540
1561
|
align: "left",
|
|
@@ -1549,7 +1570,7 @@ var Me = (e) => (t) => {
|
|
|
1549
1570
|
] });
|
|
1550
1571
|
static makeText = (e) => this.text(e, { fontSize: 8 });
|
|
1551
1572
|
#e;
|
|
1552
|
-
#t = new
|
|
1573
|
+
#t = new R.Text("ℹ️", {
|
|
1553
1574
|
fontSize: 8,
|
|
1554
1575
|
lineHeight: 14
|
|
1555
1576
|
});
|
|
@@ -1557,7 +1578,7 @@ var Me = (e) => (t) => {
|
|
|
1557
1578
|
#r = !1;
|
|
1558
1579
|
#i = "";
|
|
1559
1580
|
#a;
|
|
1560
|
-
constructor(e, t =
|
|
1581
|
+
constructor(e, t = Qe) {
|
|
1561
1582
|
super(), this.#a = t, this.addChild(this.#t), this.addChild(this.#n), this.#t.eventMode = "static", this.#t.addEventListener("pointerdown", () => this.legend = !this.legend), this.#n.x = 8, this.#n.y = 8, this.#e = e;
|
|
1562
1583
|
}
|
|
1563
1584
|
getMenu(e, t) {
|
|
@@ -1581,7 +1602,7 @@ var Me = (e) => (t) => {
|
|
|
1581
1602
|
set legend(e) {
|
|
1582
1603
|
this.#r = e, this.#n.text = this.#i + (this.#r ? this.#a : "");
|
|
1583
1604
|
}
|
|
1584
|
-
},
|
|
1605
|
+
}, $e = class extends R.Container {
|
|
1585
1606
|
first;
|
|
1586
1607
|
constructor(e, ...t) {
|
|
1587
1608
|
super(), this.first = e, this.addChild(e, ...t);
|
|
@@ -1589,7 +1610,7 @@ var Me = (e) => (t) => {
|
|
|
1589
1610
|
hotSwap(...e) {
|
|
1590
1611
|
this.removeChildren(), this.addChild(this.first, ...e);
|
|
1591
1612
|
}
|
|
1592
|
-
},
|
|
1613
|
+
}, et = class extends R.Graphics {
|
|
1593
1614
|
#e;
|
|
1594
1615
|
#t;
|
|
1595
1616
|
constructor(e) {
|
|
@@ -1608,27 +1629,27 @@ var Me = (e) => (t) => {
|
|
|
1608
1629
|
}
|
|
1609
1630
|
}
|
|
1610
1631
|
};
|
|
1611
|
-
|
|
1612
|
-
Batch: () =>
|
|
1632
|
+
O(/* @__PURE__ */ E({
|
|
1633
|
+
Batch: () => z,
|
|
1613
1634
|
E_CONNECTORS_UPDATE: () => J,
|
|
1614
1635
|
E_NODE_CONTEXT: () => q,
|
|
1615
1636
|
LANE_HEIGHT: () => 16,
|
|
1616
1637
|
LANE_WIDTH: () => 16,
|
|
1617
1638
|
PIXIGUI: () => Q,
|
|
1618
|
-
PIXINode: () =>
|
|
1619
|
-
PIXIOutlined: () =>
|
|
1620
|
-
PIXIRenderer: () =>
|
|
1621
|
-
PIXIStacked: () =>
|
|
1639
|
+
PIXINode: () => Be,
|
|
1640
|
+
PIXIOutlined: () => et,
|
|
1641
|
+
PIXIRenderer: () => Ze,
|
|
1642
|
+
PIXIStacked: () => $e,
|
|
1622
1643
|
PORT_SIZE: () => 8,
|
|
1623
|
-
RectSpinner: () =>
|
|
1624
|
-
}),
|
|
1644
|
+
RectSpinner: () => De
|
|
1645
|
+
}), R);
|
|
1625
1646
|
//#endregion
|
|
1626
1647
|
//#region src/graph/GraphAdapter.ts
|
|
1627
|
-
var
|
|
1648
|
+
var tt = class extends z {
|
|
1628
1649
|
renderer;
|
|
1629
1650
|
nodes = [];
|
|
1630
1651
|
constructor(e) {
|
|
1631
|
-
super(), this.renderer = new
|
|
1652
|
+
super(), this.renderer = new Ze(e), this.and(() => this.renderer.render());
|
|
1632
1653
|
}
|
|
1633
1654
|
[Symbol.iterator]() {
|
|
1634
1655
|
return this.nodes[Symbol.iterator]();
|
|
@@ -1691,7 +1712,7 @@ var Ye = class extends _e {
|
|
|
1691
1712
|
};
|
|
1692
1713
|
//#endregion
|
|
1693
1714
|
//#region src/graph/NodeGroups.tsx
|
|
1694
|
-
function
|
|
1715
|
+
function nt(e, t) {
|
|
1695
1716
|
let n = [];
|
|
1696
1717
|
for (let r of e) {
|
|
1697
1718
|
let e = t(r);
|
|
@@ -1707,23 +1728,23 @@ function Xe(e, t) {
|
|
|
1707
1728
|
getAll: () => [r]
|
|
1708
1729
|
};
|
|
1709
1730
|
}
|
|
1710
|
-
var
|
|
1731
|
+
var rt = (e, t) => {
|
|
1711
1732
|
let n = e.length;
|
|
1712
1733
|
if (n !== t.length) return !1;
|
|
1713
1734
|
for (let r = 0; r < n; r++) if (e[r] !== t[r]) return !1;
|
|
1714
1735
|
return !0;
|
|
1715
|
-
},
|
|
1736
|
+
}, it = (e) => {
|
|
1716
1737
|
let t = e.map(String);
|
|
1717
1738
|
return (e) => t.includes(String(e.value));
|
|
1718
|
-
},
|
|
1719
|
-
let { groups: c, getAll: u } = s(() =>
|
|
1720
|
-
let t = c.filter(
|
|
1739
|
+
}, at = (e, t) => e.every((e) => t.some((t) => t.value === e.value)) && rt(e.flatMap(ot), t.flatMap(ot)), $ = (e) => e.value, ot = (e) => e.ids, st = v(function({ items: e, resolver: t, onSelect: n, children: r, ...a }) {
|
|
1740
|
+
let { groups: c, getAll: u } = s(() => nt(e, t), [e, t]), [d, f] = l(u), p = s(() => d.map((e) => String(e.value)), [d]), h = m(({ target: { selectedOptions: e } }) => {
|
|
1741
|
+
let t = c.filter(it(Array.from(e, $)));
|
|
1721
1742
|
t && f(t);
|
|
1722
1743
|
});
|
|
1723
1744
|
return i(() => void n(d), [d, n]), o(() => {
|
|
1724
|
-
let e = c.filter(
|
|
1745
|
+
let e = c.filter(it(d.map($)));
|
|
1725
1746
|
if (e) {
|
|
1726
|
-
if (
|
|
1747
|
+
if (at(e, d)) return;
|
|
1727
1748
|
f(e);
|
|
1728
1749
|
} else f(u);
|
|
1729
1750
|
}, [
|
|
@@ -1741,8 +1762,8 @@ var Ze = (e, t) => {
|
|
|
1741
1762
|
children: t
|
|
1742
1763
|
}, String(e)))]
|
|
1743
1764
|
});
|
|
1744
|
-
}),
|
|
1745
|
-
let [o, s] = h(), { bind: c, reset: l } =
|
|
1765
|
+
}), ct = v(({ ref: e, handlers: t, onResize: n, ...r }) => {
|
|
1766
|
+
let [o, s] = h(), { bind: c, reset: l } = ge(t);
|
|
1746
1767
|
return a(e, () => ({
|
|
1747
1768
|
reset: l,
|
|
1748
1769
|
get element() {
|
|
@@ -1755,31 +1776,19 @@ var Ze = (e, t) => {
|
|
|
1755
1776
|
});
|
|
1756
1777
|
}, [o, n]), /* @__PURE__ */ y("div", {
|
|
1757
1778
|
ref: s,
|
|
1758
|
-
style:
|
|
1779
|
+
style: lt.root,
|
|
1759
1780
|
children: /* @__PURE__ */ y("div", {
|
|
1760
|
-
style:
|
|
1781
|
+
style: lt.root,
|
|
1761
1782
|
...c,
|
|
1762
1783
|
...r
|
|
1763
1784
|
})
|
|
1764
1785
|
});
|
|
1765
|
-
}),
|
|
1786
|
+
}), lt = u.of({ root: {
|
|
1766
1787
|
flex: 1,
|
|
1767
1788
|
display: "flex",
|
|
1768
1789
|
minWidth: 0,
|
|
1769
1790
|
minHeight: 0
|
|
1770
|
-
} }),
|
|
1771
|
-
resolver: at,
|
|
1772
|
-
onSelect: m((t) => e(t.ids)),
|
|
1773
|
-
...t
|
|
1774
|
-
})), at = (e) => {
|
|
1775
|
-
if (!e.item.isolator) return;
|
|
1776
|
-
let t = [e.id];
|
|
1777
|
-
return {
|
|
1778
|
-
value: e.id,
|
|
1779
|
-
label: e.title,
|
|
1780
|
-
ids: t
|
|
1781
|
-
};
|
|
1782
|
-
}, ot = (e, t, { onEdit: n, onConnect: r, onMove: i, onAddPort: a, onDisconnectPort: o, onDeletePort: s, onDelete: c, onSelect: l, onContextMenu: u } = {}) => ({
|
|
1791
|
+
} }), ut = (e, t, { onEdit: n, onConnect: r, onMove: i, onAddPort: a, onDisconnectPort: o, onDeletePort: s, onDelete: c, onSelect: l, onContextMenu: u } = {}) => ({
|
|
1783
1792
|
canvas: {
|
|
1784
1793
|
onSelectNode: (t, n) => l?.(t?.item || null, e.toData(n)),
|
|
1785
1794
|
onContextMenu: (t, n) => u?.(t?.item || null, e.toData(n))
|
|
@@ -1809,11 +1818,23 @@ var Ze = (e, t) => {
|
|
|
1809
1818
|
onDeletePort: async (e, t) => s?.(e.item, t),
|
|
1810
1819
|
onDelete: async (e) => c?.(e.item)
|
|
1811
1820
|
}
|
|
1812
|
-
}),
|
|
1821
|
+
}), dt = v(({ onSelect: e, ...t }) => /* @__PURE__ */ y(st, {
|
|
1822
|
+
resolver: ft,
|
|
1823
|
+
onSelect: m((t) => e(t.ids)),
|
|
1824
|
+
...t
|
|
1825
|
+
})), ft = (e) => {
|
|
1826
|
+
if (!e.item.isolator) return;
|
|
1827
|
+
let t = [e.id];
|
|
1828
|
+
return {
|
|
1829
|
+
value: e.id,
|
|
1830
|
+
label: e.title,
|
|
1831
|
+
ids: t
|
|
1832
|
+
};
|
|
1833
|
+
}, pt = {
|
|
1813
1834
|
x: 0,
|
|
1814
1835
|
y: 0
|
|
1815
|
-
},
|
|
1816
|
-
let
|
|
1836
|
+
}, mt = v(function({ innerRef: e, nodes: t, subset: n, coordinator: r, layouter: l, menu: u, onSelectNode: d, onContextMenu: f, ...p }) {
|
|
1837
|
+
let h = c(pt), g = c(null), _ = s(() => new Q(u), [u]), v = s(() => new tt({
|
|
1817
1838
|
maxFPS: 120,
|
|
1818
1839
|
grid: {
|
|
1819
1840
|
cellSize: r.gridSize,
|
|
@@ -1824,49 +1845,53 @@ var Ze = (e, t) => {
|
|
|
1824
1845
|
10066329
|
|
1825
1846
|
]
|
|
1826
1847
|
},
|
|
1827
|
-
gui: [
|
|
1848
|
+
gui: [_]
|
|
1828
1849
|
}), [r]);
|
|
1829
1850
|
a(e, () => ({
|
|
1830
|
-
graph:
|
|
1851
|
+
graph: v,
|
|
1831
1852
|
get element() {
|
|
1832
|
-
return
|
|
1853
|
+
return g.current?.element;
|
|
1833
1854
|
}
|
|
1834
1855
|
}));
|
|
1835
|
-
let
|
|
1836
|
-
let { x: e, y: t } = r.toData(
|
|
1837
|
-
|
|
1838
|
-
}), x = m((e) => {
|
|
1839
|
-
p.current = _.fromLocal(e), b();
|
|
1856
|
+
let b = m(({ width: e, height: t }) => v.resize(e, t)), x = m(() => {
|
|
1857
|
+
let { x: e, y: t } = r.toData(v.translation), { x: n, y: i } = r.toData(h.current);
|
|
1858
|
+
_.text = `Pos: ${-(e - 1)} x ${-(t - 1)}\nCursor: ${~~(n - 1)} x ${~~(i - 1)}`;
|
|
1840
1859
|
}), S = m((e) => {
|
|
1841
|
-
|
|
1842
|
-
}), C = m((e
|
|
1843
|
-
|
|
1844
|
-
}), w = m((e) => {
|
|
1845
|
-
|
|
1860
|
+
h.current = v.fromLocal(e), x();
|
|
1861
|
+
}), C = m((e) => {
|
|
1862
|
+
h.current = v.fromLocal(e), v.releaseNode(), x();
|
|
1863
|
+
}), w = m((e, t) => {
|
|
1864
|
+
if (S(e), v.capturing && !t?.shiftKey && d(null, r.toData(h.current)), !1 === d(v.capturing || null, r.toData(h.current))) return v.releaseNode(), !1;
|
|
1846
1865
|
}), T = m((e) => {
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1866
|
+
v.capturing || (v.translate(e), x());
|
|
1867
|
+
}), E = m((e) => {
|
|
1868
|
+
if (!1 === w(e)) return !1;
|
|
1869
|
+
if (!1 === f(v.capturing || null, r.toData(h.current))) return v.releaseNode(), !1;
|
|
1870
|
+
}), D = s(() => ({
|
|
1850
1871
|
get position() {
|
|
1851
|
-
return
|
|
1872
|
+
return v.translation;
|
|
1852
1873
|
},
|
|
1853
|
-
onDrag:
|
|
1854
|
-
onPointer:
|
|
1855
|
-
onClick:
|
|
1856
|
-
onUp:
|
|
1857
|
-
onContext:
|
|
1858
|
-
}), [
|
|
1874
|
+
onDrag: T,
|
|
1875
|
+
onPointer: S,
|
|
1876
|
+
onClick: w,
|
|
1877
|
+
onUp: C,
|
|
1878
|
+
onContext: E
|
|
1879
|
+
}), [v]);
|
|
1859
1880
|
return i(() => {
|
|
1860
|
-
if (!
|
|
1881
|
+
if (!g.current) return;
|
|
1861
1882
|
let e = n || t.map(({ id: e }) => e);
|
|
1862
|
-
|
|
1863
|
-
for (let t of
|
|
1864
|
-
for (let n of t) e.includes(n.id) && (
|
|
1865
|
-
|
|
1883
|
+
v.batch(() => {
|
|
1884
|
+
for (let t of v) e.includes(t.id) || v.removeNode(t);
|
|
1885
|
+
for (let n of t) e.includes(n.id) && (v.addNode(n), v.moveNodeTo(n, n.position));
|
|
1886
|
+
l && l.layout(t, n), v.layout();
|
|
1866
1887
|
});
|
|
1867
|
-
}, [
|
|
1868
|
-
|
|
1869
|
-
|
|
1888
|
+
}, [
|
|
1889
|
+
n,
|
|
1890
|
+
t,
|
|
1891
|
+
l
|
|
1892
|
+
]), o(() => {
|
|
1893
|
+
let e = g.current?.element;
|
|
1894
|
+
if (e) return v.mount(e, { viewport: {
|
|
1870
1895
|
width: e.clientWidth,
|
|
1871
1896
|
height: e.clientHeight,
|
|
1872
1897
|
resolution: window.devicePixelRatio,
|
|
@@ -1874,15 +1899,15 @@ var Ze = (e, t) => {
|
|
|
1874
1899
|
antialias: !0,
|
|
1875
1900
|
transparent: !1
|
|
1876
1901
|
} });
|
|
1877
|
-
}, [
|
|
1878
|
-
ref:
|
|
1879
|
-
handlers:
|
|
1880
|
-
onResize:
|
|
1881
|
-
...
|
|
1902
|
+
}, [v]), /* @__PURE__ */ y(ct, {
|
|
1903
|
+
ref: g,
|
|
1904
|
+
handlers: D,
|
|
1905
|
+
onResize: b,
|
|
1906
|
+
...p
|
|
1882
1907
|
});
|
|
1883
|
-
}),
|
|
1908
|
+
}), ht = (e, { onEdit: t, onMove: n, onConnect: r, onDelete: i, onAddPort: a, onDisconnectPort: o, onDeletePort: s }) => {
|
|
1884
1909
|
e.onConnect(r), e.onMove((t) => n(e, t)), e.onEditAction(() => t(e)), e.onDeleteAction(() => i(e)), e.onAddPortAction((t) => a(e, t)), e.onDisconnectPortAction(({ port: t }) => o(e, t)), e.onDeletePortAction(({ port: t }) => s(e, t));
|
|
1885
|
-
},
|
|
1910
|
+
}, gt = (e, t, { added: n, removed: r }) => {
|
|
1886
1911
|
if (n.length) {
|
|
1887
1912
|
let r = n.reduce((e, t) => (e[t.id] = t, e), {}), i = (t) => r[t] || e.find((e) => e.id === t);
|
|
1888
1913
|
for (let e of n) {
|
|
@@ -1906,11 +1931,11 @@ var Ze = (e, t) => {
|
|
|
1906
1931
|
}
|
|
1907
1932
|
}
|
|
1908
1933
|
}
|
|
1909
|
-
if (t) for (let e of n)
|
|
1934
|
+
if (t) for (let e of n) ht(e, t);
|
|
1910
1935
|
e.add(n);
|
|
1911
1936
|
}
|
|
1912
1937
|
if (r.length) for (let t of r) e.remove(t);
|
|
1913
|
-
},
|
|
1938
|
+
}, _t = () => [{
|
|
1914
1939
|
label: "Add node",
|
|
1915
1940
|
items: [{
|
|
1916
1941
|
label: "+ Call",
|
|
@@ -1965,13 +1990,13 @@ var Ze = (e, t) => {
|
|
|
1965
1990
|
}
|
|
1966
1991
|
}
|
|
1967
1992
|
]
|
|
1968
|
-
}],
|
|
1993
|
+
}], vt = (e, t) => ({
|
|
1969
1994
|
getMenu(t, n) {
|
|
1970
1995
|
let r = {
|
|
1971
1996
|
action: "add",
|
|
1972
1997
|
...e.toData(n)
|
|
1973
1998
|
};
|
|
1974
|
-
return { items:
|
|
1999
|
+
return { items: _t().map(({ label: e, items: t }) => [{
|
|
1975
2000
|
label: e,
|
|
1976
2001
|
group: !0
|
|
1977
2002
|
}, ...t.map(({ label: e, data: t, ...n }) => ({
|
|
@@ -1990,7 +2015,7 @@ var Ze = (e, t) => {
|
|
|
1990
2015
|
return;
|
|
1991
2016
|
}
|
|
1992
2017
|
}
|
|
1993
|
-
}),
|
|
2018
|
+
}), yt = (e, t) => {
|
|
1994
2019
|
let n = c([]);
|
|
1995
2020
|
p(() => {
|
|
1996
2021
|
let i = t?.filter((e) => !n.current.some(r(e.id))), a = n.current.filter((e) => !t?.some(r(e.id)));
|
|
@@ -1998,8 +2023,8 @@ var Ze = (e, t) => {
|
|
|
1998
2023
|
if (i) for (let { id: t } of i) e.find(r(t))?.setSelected(!0);
|
|
1999
2024
|
n.current = t || [];
|
|
2000
2025
|
}, [t, e]);
|
|
2001
|
-
},
|
|
2002
|
-
let o =
|
|
2026
|
+
}, bt = (e) => e.startsWith("channel_"), xt = (e) => bt(e) ? e.slice(8) : "", St = (e) => ({ id: t, name: n, input: r, to: i, port: a }) => {
|
|
2027
|
+
let o = xt(n);
|
|
2003
2028
|
o && (n = `${r ? "> " : ""}@${o}${r ? "" : " >"}`);
|
|
2004
2029
|
let s = [];
|
|
2005
2030
|
if (i) {
|
|
@@ -2014,11 +2039,11 @@ var Ze = (e, t) => {
|
|
|
2014
2039
|
name: n,
|
|
2015
2040
|
nodes: s
|
|
2016
2041
|
};
|
|
2017
|
-
},
|
|
2042
|
+
}, Ct = /* @__PURE__ */ function(e) {
|
|
2018
2043
|
return e[e.Idle = 1] = "Idle", e[e.Processing = 2] = "Processing", e[e.Done = 4] = "Done", e[e.Error = 8] = "Error", e[e.Selected = 16] = "Selected", e;
|
|
2019
|
-
}({}),
|
|
2044
|
+
}({}), wt = /* @__PURE__ */ function(e) {
|
|
2020
2045
|
return e[e.EDIT_NODE = 1] = "EDIT_NODE", e[e.ADD_PORT = 2] = "ADD_PORT", e[e.DISCONNECT_PORT = 3] = "DISCONNECT_PORT", e[e.DELETE_PORT = 4] = "DELETE_PORT", e[e.DELETE_NODE = 5] = "DELETE_NODE", e;
|
|
2021
|
-
}({}),
|
|
2046
|
+
}({}), Tt = class extends N {
|
|
2022
2047
|
#e;
|
|
2023
2048
|
#t;
|
|
2024
2049
|
constructor({ finder: e, item: t, coordinator: n, toTitle: r }) {
|
|
@@ -2029,8 +2054,8 @@ var Ze = (e, t) => {
|
|
|
2029
2054
|
progress: 0,
|
|
2030
2055
|
id: t.id,
|
|
2031
2056
|
title: r(t),
|
|
2032
|
-
inputs: t.ports.filter(({ input: e }) => !!e).map(
|
|
2033
|
-
outputs: t.ports.filter(({ input: e }) => !e).map(
|
|
2057
|
+
inputs: t.ports.filter(({ input: e }) => !!e).map(St(e)),
|
|
2058
|
+
outputs: t.ports.filter(({ input: e }) => !e).map(St(e))
|
|
2034
2059
|
}), this.position = this.coordinator.toGraph(t);
|
|
2035
2060
|
}
|
|
2036
2061
|
dispose() {
|
|
@@ -2151,13 +2176,13 @@ var Ze = (e, t) => {
|
|
|
2151
2176
|
}
|
|
2152
2177
|
render(e) {
|
|
2153
2178
|
let t = e.width - 1, n = e.height - 1;
|
|
2154
|
-
return this.#t ? this.#t.hotSwap(e) : this.#t = new
|
|
2179
|
+
return this.#t ? this.#t.hotSwap(e) : this.#t = new $e(new et({
|
|
2155
2180
|
width: t,
|
|
2156
2181
|
height: n,
|
|
2157
2182
|
color: 3407871,
|
|
2158
2183
|
lineSize: 1,
|
|
2159
2184
|
radius: 6
|
|
2160
|
-
}), e), this.#t.first.active = this.isSelected, this.#e ? this.#e.hotSwap(this.#t) : this.#e = new
|
|
2185
|
+
}), e), this.#t.first.active = this.isSelected, this.#e ? this.#e.hotSwap(this.#t) : this.#e = new De(this.#t, {
|
|
2161
2186
|
sizeX: t,
|
|
2162
2187
|
sizeY: n,
|
|
2163
2188
|
color: 3355647,
|
|
@@ -2165,15 +2190,15 @@ var Ze = (e, t) => {
|
|
|
2165
2190
|
radius: 6
|
|
2166
2191
|
}), this.#e.setActive(this.isInProgress), this.#e;
|
|
2167
2192
|
}
|
|
2168
|
-
},
|
|
2193
|
+
}, Et = ({ coordinator: e, sync: t, onUpdate: n, store: r, toTitle: i }) => {
|
|
2169
2194
|
let a = c(t), o = s(() => ({
|
|
2170
2195
|
subscribe: (e) => r.onChange(e),
|
|
2171
2196
|
getSnapshot: () => r.get(),
|
|
2172
2197
|
selector: (e) => e.sort((e, t) => e.id.localeCompare(t.id)),
|
|
2173
|
-
is:
|
|
2198
|
+
is: L
|
|
2174
2199
|
}), [r]), l = _(o.subscribe, o.getSnapshot, o.getSnapshot, o.selector, o.is), u = g(l), d = m((e) => l.find((t) => t.id === e));
|
|
2175
2200
|
a.current = t, p(() => {
|
|
2176
|
-
let t = (t) => new
|
|
2201
|
+
let t = (t) => new Tt({
|
|
2177
2202
|
finder: d,
|
|
2178
2203
|
item: t,
|
|
2179
2204
|
coordinator: e,
|
|
@@ -2190,90 +2215,60 @@ var Ze = (e, t) => {
|
|
|
2190
2215
|
removed: []
|
|
2191
2216
|
});
|
|
2192
2217
|
}, [l, i]), p(() => x(() => l, n), []);
|
|
2193
|
-
},
|
|
2194
|
-
|
|
2195
|
-
gridSize;
|
|
2196
|
-
sizes;
|
|
2197
|
-
constructor({ grid: e = 16, port: t = 8, lane: n = 16, space: r = 32 } = {}) {
|
|
2198
|
-
this.grid = e, this.gridSize = {
|
|
2199
|
-
x: e,
|
|
2200
|
-
y: e
|
|
2201
|
-
}, this.sizes = {
|
|
2202
|
-
grid: this.gridSize,
|
|
2203
|
-
port: t,
|
|
2204
|
-
lane: n,
|
|
2205
|
-
space: r
|
|
2206
|
-
};
|
|
2207
|
-
}
|
|
2208
|
-
snap(e) {
|
|
2209
|
-
let t = e < 0 ? -1 : 1;
|
|
2210
|
-
return t * (Math.round(t * e / this.grid + .5) - .5) * this.grid;
|
|
2211
|
-
}
|
|
2212
|
-
toGraph({ x: e, y: t }) {
|
|
2213
|
-
return {
|
|
2214
|
-
x: (e - .5) * this.grid,
|
|
2215
|
-
y: (t - .5) * this.grid
|
|
2216
|
-
};
|
|
2217
|
-
}
|
|
2218
|
-
toData({ x: e, y: t }) {
|
|
2219
|
-
return {
|
|
2220
|
-
x: ~~(this.snap(e) / this.grid + .5),
|
|
2221
|
-
y: ~~(this.snap(t) / this.grid + .5)
|
|
2222
|
-
};
|
|
2223
|
-
}
|
|
2224
|
-
}, St = v(({ innerRef: e, graph: t, selected: n, sizes: r, handlers: i, children: o, onExport: u, ...f }) => {
|
|
2225
|
-
let p = c(null), h = s(() => new xt(r), [r]), g = ft(h, i?.onCreate), [_, v] = L(() => new F()), [x, S] = l(), { canvas: C, loader: w } = ot(h, _, i), T = m(() => u?.(t));
|
|
2218
|
+
}, Dt = v(({ innerRef: e, graph: t, layouter: n, selected: r, sizes: i, handlers: o, children: u, onExport: f, ...p }) => {
|
|
2219
|
+
let h = c(null), g = s(() => new ie(i), [i]), _ = vt(g, o?.onCreate), [v, x] = he(() => new I()), [S, C] = l(), { canvas: w, loader: T } = ut(g, v, o), E = m(() => f?.(t));
|
|
2226
2220
|
return a(e, () => ({
|
|
2227
2221
|
get graph() {
|
|
2228
|
-
return
|
|
2222
|
+
return h.current?.graph;
|
|
2229
2223
|
},
|
|
2230
2224
|
get element() {
|
|
2231
|
-
return
|
|
2225
|
+
return h.current?.element;
|
|
2232
2226
|
}
|
|
2233
|
-
})),
|
|
2227
|
+
})), Et({
|
|
2234
2228
|
store: s(() => {
|
|
2235
|
-
let e = new
|
|
2229
|
+
let e = new I(t.items);
|
|
2236
2230
|
return {
|
|
2237
2231
|
items: e,
|
|
2238
2232
|
get: () => e.all,
|
|
2239
2233
|
onChange: (t) => e.onChange(t)
|
|
2240
2234
|
};
|
|
2241
2235
|
}, [t.items]),
|
|
2242
|
-
coordinator:
|
|
2236
|
+
coordinator: g,
|
|
2243
2237
|
toTitle: (e) => e.title,
|
|
2244
|
-
sync: (e) =>
|
|
2238
|
+
sync: (e) => gt(v, T, e),
|
|
2245
2239
|
onUpdate: () => e?.current?.graph.layout()
|
|
2246
|
-
}),
|
|
2240
|
+
}), yt(x, r), /* @__PURE__ */ b("div", {
|
|
2247
2241
|
onContextMenu: d,
|
|
2248
|
-
style:
|
|
2249
|
-
...
|
|
2242
|
+
style: Ot.root,
|
|
2243
|
+
...p,
|
|
2250
2244
|
children: [/* @__PURE__ */ b("div", {
|
|
2251
|
-
style:
|
|
2245
|
+
style: Ot.selector,
|
|
2252
2246
|
children: [
|
|
2253
|
-
|
|
2254
|
-
/* @__PURE__ */ y(
|
|
2255
|
-
items:
|
|
2256
|
-
onSelect:
|
|
2247
|
+
u,
|
|
2248
|
+
/* @__PURE__ */ y(dt, {
|
|
2249
|
+
items: x,
|
|
2250
|
+
onSelect: C
|
|
2257
2251
|
}),
|
|
2258
2252
|
/* @__PURE__ */ y("button", {
|
|
2259
|
-
onClick: () =>
|
|
2253
|
+
onClick: () => C(void 0),
|
|
2260
2254
|
children: "Update"
|
|
2261
2255
|
}),
|
|
2262
|
-
|
|
2263
|
-
onClick:
|
|
2256
|
+
f && /* @__PURE__ */ y("button", {
|
|
2257
|
+
onClick: E,
|
|
2264
2258
|
children: "Export"
|
|
2265
2259
|
})
|
|
2266
2260
|
]
|
|
2267
|
-
}), /* @__PURE__ */ y(
|
|
2268
|
-
innerRef:
|
|
2269
|
-
coordinator:
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2261
|
+
}), /* @__PURE__ */ y(mt, {
|
|
2262
|
+
innerRef: h,
|
|
2263
|
+
coordinator: g,
|
|
2264
|
+
layouter: n,
|
|
2265
|
+
nodes: x,
|
|
2266
|
+
subset: S,
|
|
2267
|
+
menu: _,
|
|
2268
|
+
...w
|
|
2274
2269
|
})]
|
|
2275
2270
|
});
|
|
2276
|
-
}),
|
|
2271
|
+
}), Ot = u.of({
|
|
2277
2272
|
root: {
|
|
2278
2273
|
flex: 1,
|
|
2279
2274
|
display: "flex",
|
|
@@ -2287,6 +2282,6 @@ var Ze = (e, t) => {
|
|
|
2287
2282
|
}
|
|
2288
2283
|
});
|
|
2289
2284
|
//#endregion
|
|
2290
|
-
export {
|
|
2285
|
+
export { de as ClusteredLayout, ie as Coordinates, pe as EdgesSort, ee as GRID_SIZE, tt as GraphAdapter, mt as GraphCanvas, N as GraphNode, j as GraphNodeJoints, ne as LANE_SIZE, ue as LayeredLayout, me as Layouter, Dt as ManagedGraph, Tt as ManagedGraphNode, wt as MenuActions, st as NodeGroups, Ct as NodeStatus, P as NodesGraph, fe as NodesSort, Q as PIXIGUI, te as PORT_SIZE, re as SPACE_SIZE, I as Store, ct as Viewport, xt as getChannelName, ae as groupResolver, bt as isChannelName, L as isEqualIdentifiables, ge as useDraggable, he as useStore };
|
|
2291
2286
|
|
|
2292
2287
|
//# sourceMappingURL=index.js.map
|