@html-graph/html-graph 7.7.0 → 7.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/html-graph.d.ts +41 -5
- package/dist/html-graph.js +730 -666
- package/dist/html-graph.umd.cjs +1 -1
- package/package.json +2 -1
package/dist/html-graph.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var i = (r, e, t) =>
|
|
1
|
+
var ke = Object.defineProperty;
|
|
2
|
+
var ze = (r, e, t) => e in r ? ke(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
|
+
var i = (r, e, t) => ze(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
var M = /* @__PURE__ */ ((r) => (r.Line = "line", r.NodeCycle = "node-cycle", r.PortCycle = "port-cycle", r))(M || {});
|
|
5
5
|
const He = () => {
|
|
6
6
|
const r = document.createElement("div");
|
|
@@ -12,7 +12,7 @@ const He = () => {
|
|
|
12
12
|
r.style.position = "absolute", r.style.top = "0", r.style.left = "0", r.style.visibility = "hidden";
|
|
13
13
|
};
|
|
14
14
|
class me {
|
|
15
|
-
constructor(e, t,
|
|
15
|
+
constructor(e, t, s) {
|
|
16
16
|
i(this, "host", He());
|
|
17
17
|
i(this, "container", Xe());
|
|
18
18
|
i(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
|
|
@@ -21,7 +21,7 @@ class me {
|
|
|
21
21
|
const e = this.viewportStore.getContentMatrix();
|
|
22
22
|
this.container.style.transform = `matrix(${e.scale}, 0, 0, ${e.scale}, ${e.x}, ${e.y})`;
|
|
23
23
|
});
|
|
24
|
-
this.graphStore = e, this.viewportStore = t, this.element =
|
|
24
|
+
this.graphStore = e, this.viewportStore = t, this.element = s, this.element.appendChild(this.host), this.host.appendChild(this.container), this.viewportStore.onAfterUpdated.subscribe(this.applyTransform);
|
|
25
25
|
}
|
|
26
26
|
attachNode(e) {
|
|
27
27
|
const t = this.graphStore.getNode(e);
|
|
@@ -50,7 +50,7 @@ class me {
|
|
|
50
50
|
this.viewportStore.onAfterUpdated.unsubscribe(this.applyTransform), this.element.removeChild(this.host), this.host.removeChild(this.container);
|
|
51
51
|
}
|
|
52
52
|
updateNodePosition(e) {
|
|
53
|
-
const t = this.graphStore.getNode(e), { width:
|
|
53
|
+
const t = this.graphStore.getNode(e), { width: s, height: o } = t.element.getBoundingClientRect(), n = this.viewportStore.getViewportMatrix().scale, { payload: a } = t, h = a.centerFn(s, o), d = a.x - n * h.x, c = a.y - n * h.y;
|
|
54
54
|
t.element.style.transform = `translate(${d}px, ${c}px)`;
|
|
55
55
|
}
|
|
56
56
|
updateNodePriority(e) {
|
|
@@ -60,33 +60,33 @@ class me {
|
|
|
60
60
|
updateEdgeShape(e) {
|
|
61
61
|
const t = this.edgeIdToElementMap.get(e);
|
|
62
62
|
this.container.removeChild(t);
|
|
63
|
-
const
|
|
64
|
-
this.edgeIdToElementMap.set(e,
|
|
63
|
+
const o = this.graphStore.getEdge(e).payload.shape.svg;
|
|
64
|
+
this.edgeIdToElementMap.set(e, o), this.container.appendChild(o);
|
|
65
65
|
}
|
|
66
66
|
renderEdge(e) {
|
|
67
|
-
const t = this.graphStore.getEdge(e),
|
|
68
|
-
|
|
67
|
+
const t = this.graphStore.getEdge(e), s = this.graphStore.getPort(t.from), o = this.graphStore.getPort(t.to), n = s.element.getBoundingClientRect(), a = o.element.getBoundingClientRect(), h = this.host.getBoundingClientRect(), d = this.viewportStore.getViewportMatrix().scale, c = this.createEdgeRenderPort(
|
|
68
|
+
s,
|
|
69
69
|
n,
|
|
70
70
|
h,
|
|
71
71
|
d
|
|
72
|
-
), g = this.createEdgeRenderPort(
|
|
72
|
+
), g = this.createEdgeRenderPort(o, a, h, d);
|
|
73
73
|
let l = M.Line;
|
|
74
|
-
|
|
74
|
+
s.element === o.element ? l = M.PortCycle : s.nodeId === o.nodeId && (l = M.NodeCycle), t.payload.shape.render({ from: c, to: g, category: l });
|
|
75
75
|
}
|
|
76
76
|
updateEdgePriority(e) {
|
|
77
77
|
const t = this.graphStore.getEdge(e);
|
|
78
78
|
t.payload.shape.svg.style.zIndex = `${t.payload.priority}`;
|
|
79
79
|
}
|
|
80
|
-
createEdgeRenderPort(e, t,
|
|
80
|
+
createEdgeRenderPort(e, t, s, o) {
|
|
81
81
|
const n = this.viewportStore.createContentCoords({
|
|
82
|
-
x: t.left -
|
|
83
|
-
y: t.top -
|
|
82
|
+
x: t.left - s.left,
|
|
83
|
+
y: t.top - s.top
|
|
84
84
|
});
|
|
85
85
|
return {
|
|
86
86
|
x: n.x,
|
|
87
87
|
y: n.y,
|
|
88
|
-
width: t.width *
|
|
89
|
-
height: t.height *
|
|
88
|
+
width: t.width * o,
|
|
89
|
+
height: t.height * o,
|
|
90
90
|
direction: e.payload.direction
|
|
91
91
|
};
|
|
92
92
|
}
|
|
@@ -103,39 +103,39 @@ class Ge {
|
|
|
103
103
|
this.xFrom = e.x, this.xTo = e.x + e.width, this.yFrom = e.y, this.yTo = e.y + e.height;
|
|
104
104
|
}
|
|
105
105
|
hasNode(e) {
|
|
106
|
-
const t = this.graphStore.getNode(e).payload, { x:
|
|
107
|
-
return
|
|
106
|
+
const t = this.graphStore.getNode(e).payload, { x: s, y: o } = t;
|
|
107
|
+
return s >= this.xFrom && s <= this.xTo && o >= this.yFrom && o <= this.yTo;
|
|
108
108
|
}
|
|
109
109
|
hasEdge(e) {
|
|
110
|
-
const t = this.graphStore.getEdge(e),
|
|
110
|
+
const t = this.graphStore.getEdge(e), s = this.graphStore.getPort(t.from).nodeId, o = this.graphStore.getPort(t.to).nodeId, n = this.graphStore.getNode(s).payload, a = this.graphStore.getNode(o).payload, h = Math.min(n.x, a.x), d = Math.max(n.x, a.x), c = Math.min(n.y, a.y), g = Math.max(n.y, a.y);
|
|
111
111
|
return h <= this.xTo && d >= this.xFrom && c <= this.yTo && g >= this.yFrom;
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
class je {
|
|
115
|
-
constructor(e, t,
|
|
115
|
+
constructor(e, t, s, o) {
|
|
116
116
|
i(this, "attachedNodes", /* @__PURE__ */ new Set());
|
|
117
117
|
i(this, "attachedEdges", /* @__PURE__ */ new Set());
|
|
118
118
|
i(this, "renderingBox");
|
|
119
119
|
i(this, "updateViewport", (e) => {
|
|
120
120
|
this.renderingBox.setRenderingBox(e);
|
|
121
|
-
const t = /* @__PURE__ */ new Set(),
|
|
121
|
+
const t = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
|
|
122
122
|
this.graphStore.getAllNodeIds().forEach((a) => {
|
|
123
123
|
const h = this.renderingBox.hasNode(a), d = this.attachedNodes.has(a);
|
|
124
|
-
h && !d ? t.add(a) : !h && d &&
|
|
124
|
+
h && !d ? t.add(a) : !h && d && s.add(a);
|
|
125
125
|
}), this.graphStore.getAllEdgeIds().forEach((a) => {
|
|
126
126
|
const h = this.renderingBox.hasEdge(a), d = this.attachedEdges.has(a), c = this.graphStore.getEdge(a), g = this.graphStore.getPort(c.from).nodeId, l = this.graphStore.getPort(c.to).nodeId;
|
|
127
|
-
h && (this.renderingBox.hasNode(g) || (t.add(g),
|
|
127
|
+
h && (this.renderingBox.hasNode(g) || (t.add(g), s.delete(g)), this.renderingBox.hasNode(l) || (t.add(l), s.delete(l))), h && !d ? o.add(a) : !h && d && n.add(a);
|
|
128
128
|
}), n.forEach((a) => {
|
|
129
129
|
this.handleDetachEdge(a);
|
|
130
|
-
}),
|
|
130
|
+
}), s.forEach((a) => {
|
|
131
131
|
this.handleDetachNode(a);
|
|
132
132
|
}), t.forEach((a) => {
|
|
133
133
|
this.attachedNodes.has(a) || this.handleAttachNode(a);
|
|
134
|
-
}),
|
|
134
|
+
}), o.forEach((a) => {
|
|
135
135
|
this.handleAttachEdge(a);
|
|
136
136
|
});
|
|
137
137
|
});
|
|
138
|
-
this.htmlView = e, this.graphStore = t, this.trigger =
|
|
138
|
+
this.htmlView = e, this.graphStore = t, this.trigger = s, this.params = o, this.renderingBox = new Ge(this.graphStore), this.trigger.subscribe(this.updateViewport);
|
|
139
139
|
}
|
|
140
140
|
attachNode(e) {
|
|
141
141
|
this.renderingBox.hasNode(e) && this.handleAttachNode(e);
|
|
@@ -173,8 +173,8 @@ class je {
|
|
|
173
173
|
this.clear(), this.htmlView.destroy(), this.trigger.unsubscribe(this.updateViewport);
|
|
174
174
|
}
|
|
175
175
|
attachEdgeEntities(e) {
|
|
176
|
-
const t = this.graphStore.getEdge(e),
|
|
177
|
-
this.attachedNodes.has(
|
|
176
|
+
const t = this.graphStore.getEdge(e), s = this.graphStore.getPort(t.from).nodeId, o = this.graphStore.getPort(t.to).nodeId;
|
|
177
|
+
this.attachedNodes.has(s) || this.handleAttachNode(s), this.attachedNodes.has(o) || this.handleAttachNode(o), this.handleAttachEdge(e);
|
|
178
178
|
}
|
|
179
179
|
handleAttachNode(e) {
|
|
180
180
|
this.params.onBeforeNodeAttached(e), this.attachedNodes.add(e), this.htmlView.attachNode(e);
|
|
@@ -236,14 +236,14 @@ class qe {
|
|
|
236
236
|
this.isNodeValid(e) && (this.deferredNodes.delete(e), this.htmlView.attachNode(e));
|
|
237
237
|
}
|
|
238
238
|
isEdgeValid(e) {
|
|
239
|
-
const t = this.graphStore.getEdge(e),
|
|
240
|
-
return !(this.deferredNodes.has(
|
|
239
|
+
const t = this.graphStore.getEdge(e), s = this.graphStore.getPort(t.from), o = this.graphStore.getPort(t.to);
|
|
240
|
+
return !(this.deferredNodes.has(s.nodeId) || this.deferredNodes.has(o.nodeId));
|
|
241
241
|
}
|
|
242
242
|
tryAttachEdge(e) {
|
|
243
243
|
this.isEdgeValid(e) && (this.deferredEdges.delete(e), this.htmlView.attachEdge(e));
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
|
-
class
|
|
246
|
+
class j {
|
|
247
247
|
constructor() {
|
|
248
248
|
i(this, "callbacks", /* @__PURE__ */ new Set());
|
|
249
249
|
}
|
|
@@ -260,10 +260,10 @@ class G {
|
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
262
|
const E = () => {
|
|
263
|
-
const r = new
|
|
263
|
+
const r = new j();
|
|
264
264
|
return [r, r];
|
|
265
265
|
};
|
|
266
|
-
class
|
|
266
|
+
class X {
|
|
267
267
|
constructor(e) {
|
|
268
268
|
i(this, "counter", 0);
|
|
269
269
|
this.checkExists = e;
|
|
@@ -286,22 +286,22 @@ class b extends Error {
|
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
288
|
class ve {
|
|
289
|
-
constructor(e, t,
|
|
290
|
-
i(this, "nodeIdGenerator", new
|
|
291
|
-
(e) => this.graphStore.
|
|
289
|
+
constructor(e, t, s, o, n, a) {
|
|
290
|
+
i(this, "nodeIdGenerator", new X(
|
|
291
|
+
(e) => this.graphStore.hasNode(e)
|
|
292
292
|
));
|
|
293
|
-
i(this, "portIdGenerator", new
|
|
294
|
-
(e) => this.graphStore.
|
|
293
|
+
i(this, "portIdGenerator", new X(
|
|
294
|
+
(e) => this.graphStore.hasPort(e)
|
|
295
295
|
));
|
|
296
|
-
i(this, "edgeIdGenerator", new
|
|
297
|
-
(e) => this.graphStore.
|
|
296
|
+
i(this, "edgeIdGenerator", new X(
|
|
297
|
+
(e) => this.graphStore.hasEdge(e)
|
|
298
298
|
));
|
|
299
299
|
i(this, "onAfterNodeAdded", (e) => {
|
|
300
300
|
this.htmlView.attachNode(e);
|
|
301
301
|
});
|
|
302
302
|
i(this, "onAfterNodeUpdated", (e) => {
|
|
303
|
-
this.htmlView.updateNodePosition(e), this.graphStore.getNodeAdjacentEdgeIds(e).forEach((
|
|
304
|
-
this.htmlView.renderEdge(
|
|
303
|
+
this.htmlView.updateNodePosition(e), this.graphStore.getNodeAdjacentEdgeIds(e).forEach((s) => {
|
|
304
|
+
this.htmlView.renderEdge(s);
|
|
305
305
|
});
|
|
306
306
|
});
|
|
307
307
|
i(this, "onAfterNodePriorityUpdated", (e) => {
|
|
@@ -313,8 +313,8 @@ class ve {
|
|
|
313
313
|
}), this.htmlView.detachNode(e);
|
|
314
314
|
});
|
|
315
315
|
i(this, "onAfterPortUpdated", (e) => {
|
|
316
|
-
this.graphStore.getPortAdjacentEdgeIds(e).forEach((
|
|
317
|
-
this.htmlView.renderEdge(
|
|
316
|
+
this.graphStore.getPortAdjacentEdgeIds(e).forEach((s) => {
|
|
317
|
+
this.htmlView.renderEdge(s);
|
|
318
318
|
});
|
|
319
319
|
});
|
|
320
320
|
i(this, "onBeforePortUnmarked", (e) => {
|
|
@@ -346,7 +346,7 @@ class ve {
|
|
|
346
346
|
* emits event just before destruction of canvas
|
|
347
347
|
*/
|
|
348
348
|
i(this, "onBeforeDestroy");
|
|
349
|
-
this.graph = e, this.viewport = t, this.graphStore =
|
|
349
|
+
this.graph = e, this.viewport = t, this.graphStore = s, this.viewportStore = o, this.htmlView = n, this.params = a, this.graphStore.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graphStore.onAfterNodeUpdated.subscribe(this.onAfterNodeUpdated), this.graphStore.onAfterNodePriorityUpdated.subscribe(
|
|
350
350
|
this.onAfterNodePriorityUpdated
|
|
351
351
|
), this.graphStore.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.graphStore.onAfterPortUpdated.subscribe(this.onAfterPortUpdated), this.graphStore.onBeforePortRemoved.subscribe(this.onBeforePortUnmarked), this.graphStore.onAfterEdgeAdded.subscribe(this.onAfterEdgeAdded), this.graphStore.onAfterEdgeShapeUpdated.subscribe(
|
|
352
352
|
this.onAfterEdgeShapeUpdated
|
|
@@ -359,9 +359,9 @@ class ve {
|
|
|
359
359
|
*/
|
|
360
360
|
addNode(e) {
|
|
361
361
|
const t = this.nodeIdGenerator.create(e.id);
|
|
362
|
-
if (this.graphStore.
|
|
362
|
+
if (this.graphStore.hasNode(t))
|
|
363
363
|
throw new b("failed to add node with existing id");
|
|
364
|
-
if (this.graphStore.
|
|
364
|
+
if (this.graphStore.findNodeIdByElement(e.element) !== void 0)
|
|
365
365
|
throw new b(
|
|
366
366
|
"failed to add node with html element already in use by another node"
|
|
367
367
|
);
|
|
@@ -373,12 +373,12 @@ class ve {
|
|
|
373
373
|
centerFn: e.centerFn ?? this.params.nodes.centerFn,
|
|
374
374
|
priority: e.priority ?? this.params.nodes.priorityFn()
|
|
375
375
|
}), e.ports !== void 0)
|
|
376
|
-
for (const
|
|
376
|
+
for (const s of e.ports)
|
|
377
377
|
this.markPort({
|
|
378
|
-
id:
|
|
379
|
-
element:
|
|
378
|
+
id: s.id,
|
|
379
|
+
element: s.element,
|
|
380
380
|
nodeId: t,
|
|
381
|
-
direction:
|
|
381
|
+
direction: s.direction
|
|
382
382
|
});
|
|
383
383
|
return this;
|
|
384
384
|
}
|
|
@@ -386,7 +386,7 @@ class ve {
|
|
|
386
386
|
* updates node parameters
|
|
387
387
|
*/
|
|
388
388
|
updateNode(e, t) {
|
|
389
|
-
if (this.graphStore.
|
|
389
|
+
if (!this.graphStore.hasNode(e))
|
|
390
390
|
throw new b("failed to update nonexistent node");
|
|
391
391
|
return this.graphStore.updateNode(e, t ?? {}), this;
|
|
392
392
|
}
|
|
@@ -396,7 +396,7 @@ class ve {
|
|
|
396
396
|
* all the edges adjacent to node get removed
|
|
397
397
|
*/
|
|
398
398
|
removeNode(e) {
|
|
399
|
-
if (this.graphStore.
|
|
399
|
+
if (!this.graphStore.hasNode(e))
|
|
400
400
|
throw new b("failed to remove nonexistent node");
|
|
401
401
|
return this.graphStore.removeNode(e), this;
|
|
402
402
|
}
|
|
@@ -405,9 +405,9 @@ class ve {
|
|
|
405
405
|
*/
|
|
406
406
|
markPort(e) {
|
|
407
407
|
const t = this.portIdGenerator.create(e.id);
|
|
408
|
-
if (this.graphStore.
|
|
408
|
+
if (this.graphStore.hasPort(t))
|
|
409
409
|
throw new b("failed to add port with existing id");
|
|
410
|
-
if (this.graphStore.
|
|
410
|
+
if (!this.graphStore.hasNode(e.nodeId))
|
|
411
411
|
throw new b("failed to mark port for nonexistent node");
|
|
412
412
|
return this.graphStore.addPort({
|
|
413
413
|
id: t,
|
|
@@ -420,7 +420,7 @@ class ve {
|
|
|
420
420
|
* updates port and edges attached to it
|
|
421
421
|
*/
|
|
422
422
|
updatePort(e, t) {
|
|
423
|
-
if (this.graphStore.
|
|
423
|
+
if (!this.graphStore.hasPort(e))
|
|
424
424
|
throw new b("failed to update nonexistent port");
|
|
425
425
|
return this.graphStore.updatePort(e, t ?? {}), this;
|
|
426
426
|
}
|
|
@@ -429,7 +429,7 @@ class ve {
|
|
|
429
429
|
* all the edges adjacent to the port get removed
|
|
430
430
|
*/
|
|
431
431
|
unmarkPort(e) {
|
|
432
|
-
if (this.graphStore.
|
|
432
|
+
if (!this.graphStore.hasPort(e))
|
|
433
433
|
throw new b("failed to unmark nonexistent port");
|
|
434
434
|
return this.graphStore.removePort(e), this;
|
|
435
435
|
}
|
|
@@ -438,11 +438,11 @@ class ve {
|
|
|
438
438
|
*/
|
|
439
439
|
addEdge(e) {
|
|
440
440
|
const t = this.edgeIdGenerator.create(e.id);
|
|
441
|
-
if (this.graphStore.
|
|
441
|
+
if (this.graphStore.hasEdge(t))
|
|
442
442
|
throw new b("failed to add edge with existing id");
|
|
443
|
-
if (this.graphStore.
|
|
443
|
+
if (!this.graphStore.hasPort(e.from))
|
|
444
444
|
throw new b("failed to add edge from nonexistent port");
|
|
445
|
-
if (this.graphStore.
|
|
445
|
+
if (!this.graphStore.hasPort(e.to))
|
|
446
446
|
throw new b("failed to add edge to nonexistent port");
|
|
447
447
|
return this.graphStore.addEdge({
|
|
448
448
|
id: t,
|
|
@@ -456,7 +456,7 @@ class ve {
|
|
|
456
456
|
* updates specified edge
|
|
457
457
|
*/
|
|
458
458
|
updateEdge(e, t) {
|
|
459
|
-
if (this.graphStore.
|
|
459
|
+
if (!this.graphStore.hasEdge(e))
|
|
460
460
|
throw new b("failed to update nonexistent edge");
|
|
461
461
|
return this.graphStore.updateEdge(e, t ?? {}), this;
|
|
462
462
|
}
|
|
@@ -464,7 +464,7 @@ class ve {
|
|
|
464
464
|
* removes specified edge
|
|
465
465
|
*/
|
|
466
466
|
removeEdge(e) {
|
|
467
|
-
if (this.graphStore.
|
|
467
|
+
if (!this.graphStore.hasEdge(e))
|
|
468
468
|
throw new b("failed to remove nonexistent edge");
|
|
469
469
|
return this.graphStore.removeEdge(e), this;
|
|
470
470
|
}
|
|
@@ -507,31 +507,31 @@ class Ke {
|
|
|
507
507
|
i(this, "multiToSingleMap", /* @__PURE__ */ new Map());
|
|
508
508
|
}
|
|
509
509
|
addRecord(e, t) {
|
|
510
|
-
const
|
|
511
|
-
|
|
510
|
+
const s = this.singleToMultiMap.get(e);
|
|
511
|
+
s === void 0 ? this.singleToMultiMap.set(e, /* @__PURE__ */ new Set([t])) : s.add(t), this.multiToSingleMap.set(t, e);
|
|
512
512
|
}
|
|
513
513
|
getMultiBySingle(e) {
|
|
514
514
|
const t = this.singleToMultiMap.get(e) ?? /* @__PURE__ */ new Set();
|
|
515
515
|
return Array.from(t.values());
|
|
516
516
|
}
|
|
517
517
|
removeByMulti(e) {
|
|
518
|
-
const t = this.multiToSingleMap.get(e),
|
|
519
|
-
|
|
518
|
+
const t = this.multiToSingleMap.get(e), s = this.singleToMultiMap.get(t);
|
|
519
|
+
s.delete(e), s.size === 0 && this.singleToMultiMap.delete(t), this.multiToSingleMap.delete(e);
|
|
520
520
|
}
|
|
521
521
|
getByMulti(e) {
|
|
522
522
|
return this.multiToSingleMap.get(e);
|
|
523
523
|
}
|
|
524
524
|
removeBySingle(e) {
|
|
525
|
-
this.singleToMultiMap.get(e).forEach((
|
|
526
|
-
this.multiToSingleMap.delete(
|
|
525
|
+
this.singleToMultiMap.get(e).forEach((s) => {
|
|
526
|
+
this.multiToSingleMap.delete(s);
|
|
527
527
|
}), this.singleToMultiMap.delete(e);
|
|
528
528
|
}
|
|
529
529
|
clear() {
|
|
530
530
|
this.singleToMultiMap.clear(), this.multiToSingleMap.clear();
|
|
531
531
|
}
|
|
532
532
|
forEachSingle(e) {
|
|
533
|
-
this.singleToMultiMap.forEach((t,
|
|
534
|
-
e(
|
|
533
|
+
this.singleToMultiMap.forEach((t, s) => {
|
|
534
|
+
e(s);
|
|
535
535
|
});
|
|
536
536
|
}
|
|
537
537
|
hasSingle(e) {
|
|
@@ -579,8 +579,18 @@ class Ae {
|
|
|
579
579
|
i(this, "onBeforeClear");
|
|
580
580
|
[this.afterNodeAddedEmitter, this.onAfterNodeAdded] = E(), [this.afterNodeUpdatedEmitter, this.onAfterNodeUpdated] = E(), [this.afterNodePriorityUpdatedEmitter, this.onAfterNodePriorityUpdated] = E(), [this.beforeNodeRemovedEmitter, this.onBeforeNodeRemoved] = E(), [this.afterPortAddedEmitter, this.onAfterPortAdded] = E(), [this.afterPortUpdatedEmitter, this.onAfterPortUpdated] = E(), [this.beforePortRemovedEmitter, this.onBeforePortRemoved] = E(), [this.afterEdgeAddedEmitter, this.onAfterEdgeAdded] = E(), [this.afterEdgeShapeUpdatedEmitter, this.onAfterEdgeShapeUpdated] = E(), [this.afterEdgeUpdatedEmitter, this.onAfterEdgeUpdated] = E(), [this.afterEdgePriorityUpdatedEmitter, this.onAfterEdgePriorityUpdated] = E(), [this.beforeEdgeRemovedEmitter, this.onBeforeEdgeRemoved] = E(), [this.beforeClearEmitter, this.onBeforeClear] = E();
|
|
581
581
|
}
|
|
582
|
+
hasNode(e) {
|
|
583
|
+
return this.nodes.has(e);
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* TODO: v8
|
|
587
|
+
* throw error when node does not exist
|
|
588
|
+
*/
|
|
589
|
+
getNode(e) {
|
|
590
|
+
return this.nodes.get(e);
|
|
591
|
+
}
|
|
582
592
|
addNode(e) {
|
|
583
|
-
const t = /* @__PURE__ */ new Map(),
|
|
593
|
+
const t = /* @__PURE__ */ new Map(), s = {
|
|
584
594
|
element: e.element,
|
|
585
595
|
payload: {
|
|
586
596
|
x: e.x,
|
|
@@ -590,26 +600,33 @@ class Ae {
|
|
|
590
600
|
},
|
|
591
601
|
ports: t
|
|
592
602
|
};
|
|
593
|
-
this.nodes.set(e.id,
|
|
603
|
+
this.nodes.set(e.id, s), this.nodesElementsMap.set(e.element, e.id), this.afterNodeAddedEmitter.emit(e.id);
|
|
594
604
|
}
|
|
595
605
|
getAllNodeIds() {
|
|
596
606
|
return Array.from(this.nodes.keys());
|
|
597
607
|
}
|
|
598
|
-
|
|
599
|
-
return this.nodes.get(e);
|
|
600
|
-
}
|
|
601
|
-
getElementNodeId(e) {
|
|
608
|
+
findNodeIdByElement(e) {
|
|
602
609
|
return this.nodesElementsMap.get(e);
|
|
603
610
|
}
|
|
604
611
|
updateNode(e, t) {
|
|
605
|
-
const
|
|
606
|
-
|
|
612
|
+
const s = this.nodes.get(e).payload;
|
|
613
|
+
s.x = t.x ?? s.x, s.y = t.y ?? s.y, s.centerFn = t.centerFn ?? s.centerFn, t.priority !== void 0 && (s.priority = t.priority, this.afterNodePriorityUpdatedEmitter.emit(e)), this.afterNodeUpdatedEmitter.emit(e);
|
|
607
614
|
}
|
|
608
615
|
removeNode(e) {
|
|
609
616
|
this.beforeNodeRemovedEmitter.emit(e);
|
|
610
617
|
const t = this.nodes.get(e);
|
|
611
618
|
this.nodesElementsMap.delete(t.element), this.nodes.delete(e);
|
|
612
619
|
}
|
|
620
|
+
hasPort(e) {
|
|
621
|
+
return this.ports.has(e);
|
|
622
|
+
}
|
|
623
|
+
/**
|
|
624
|
+
* TODO: v8
|
|
625
|
+
* throw error when port does not exist
|
|
626
|
+
*/
|
|
627
|
+
getPort(e) {
|
|
628
|
+
return this.ports.get(e);
|
|
629
|
+
}
|
|
613
630
|
addPort(e) {
|
|
614
631
|
this.ports.set(e.id, {
|
|
615
632
|
element: e.element,
|
|
@@ -619,17 +636,14 @@ class Ae {
|
|
|
619
636
|
nodeId: e.nodeId
|
|
620
637
|
}), this.elementPorts.addRecord(e.element, e.id), this.portCycleEdges.set(e.id, /* @__PURE__ */ new Set()), this.portIncomingEdges.set(e.id, /* @__PURE__ */ new Set()), this.portOutcomingEdges.set(e.id, /* @__PURE__ */ new Set()), this.nodes.get(e.nodeId).ports.set(e.id, e.element), this.afterPortAddedEmitter.emit(e.id);
|
|
621
638
|
}
|
|
622
|
-
getPort(e) {
|
|
623
|
-
return this.ports.get(e);
|
|
624
|
-
}
|
|
625
639
|
updatePort(e, t) {
|
|
626
|
-
const
|
|
627
|
-
|
|
640
|
+
const s = this.ports.get(e).payload;
|
|
641
|
+
s.direction = t.direction ?? s.direction, this.afterPortUpdatedEmitter.emit(e);
|
|
628
642
|
}
|
|
629
643
|
getAllPortIds() {
|
|
630
644
|
return Array.from(this.ports.keys());
|
|
631
645
|
}
|
|
632
|
-
|
|
646
|
+
findPortIdsByElement(e) {
|
|
633
647
|
return this.elementPorts.getMultiBySingle(e);
|
|
634
648
|
}
|
|
635
649
|
getNodePortIds(e) {
|
|
@@ -641,29 +655,36 @@ class Ae {
|
|
|
641
655
|
const t = this.ports.get(e).nodeId;
|
|
642
656
|
this.beforePortRemovedEmitter.emit(e), this.nodes.get(t).ports.delete(e), this.ports.delete(e), this.elementPorts.removeByMulti(e);
|
|
643
657
|
}
|
|
658
|
+
hasEdge(e) {
|
|
659
|
+
return this.edges.has(e);
|
|
660
|
+
}
|
|
661
|
+
/**
|
|
662
|
+
* TODO: v8
|
|
663
|
+
* throw error when edge does not exist
|
|
664
|
+
*/
|
|
665
|
+
getEdge(e) {
|
|
666
|
+
return this.edges.get(e);
|
|
667
|
+
}
|
|
644
668
|
addEdge(e) {
|
|
645
669
|
this.addEdgeInternal(e), this.afterEdgeAddedEmitter.emit(e.id);
|
|
646
670
|
}
|
|
647
671
|
updateEdge(e, t) {
|
|
648
672
|
if (t.from !== void 0 || t.to !== void 0) {
|
|
649
|
-
const
|
|
673
|
+
const o = this.edges.get(e), n = o.payload;
|
|
650
674
|
this.removeEdgeInternal(e), this.addEdgeInternal({
|
|
651
675
|
id: e,
|
|
652
|
-
from: t.from ??
|
|
653
|
-
to: t.to ??
|
|
676
|
+
from: t.from ?? o.from,
|
|
677
|
+
to: t.to ?? o.to,
|
|
654
678
|
shape: n.shape,
|
|
655
679
|
priority: n.priority
|
|
656
680
|
});
|
|
657
681
|
}
|
|
658
|
-
const
|
|
659
|
-
t.shape !== void 0 && (
|
|
682
|
+
const s = this.edges.get(e);
|
|
683
|
+
t.shape !== void 0 && (s.payload.shape = t.shape, this.afterEdgeShapeUpdatedEmitter.emit(e)), t.priority !== void 0 && (s.payload.priority = t.priority, this.afterEdgePriorityUpdatedEmitter.emit(e)), this.afterEdgeUpdatedEmitter.emit(e);
|
|
660
684
|
}
|
|
661
685
|
getAllEdgeIds() {
|
|
662
686
|
return Array.from(this.edges.keys());
|
|
663
687
|
}
|
|
664
|
-
getEdge(e) {
|
|
665
|
-
return this.edges.get(e);
|
|
666
|
-
}
|
|
667
688
|
removeEdge(e) {
|
|
668
689
|
this.beforeEdgeRemovedEmitter.emit(e), this.removeEdgeInternal(e);
|
|
669
690
|
}
|
|
@@ -687,51 +708,51 @@ class Ae {
|
|
|
687
708
|
];
|
|
688
709
|
}
|
|
689
710
|
getNodeIncomingEdgeIds(e) {
|
|
690
|
-
const t = Array.from(this.nodes.get(e).ports.keys()),
|
|
691
|
-
return t.forEach((
|
|
692
|
-
this.getPortIncomingEdgeIds(
|
|
711
|
+
const t = Array.from(this.nodes.get(e).ports.keys()), s = [];
|
|
712
|
+
return t.forEach((o) => {
|
|
713
|
+
this.getPortIncomingEdgeIds(o).filter((n) => {
|
|
693
714
|
const a = this.getEdge(n);
|
|
694
715
|
return this.getPort(a.from).nodeId !== e;
|
|
695
716
|
}).forEach((n) => {
|
|
696
|
-
|
|
717
|
+
s.push(n);
|
|
697
718
|
});
|
|
698
|
-
}),
|
|
719
|
+
}), s;
|
|
699
720
|
}
|
|
700
721
|
getNodeOutgoingEdgeIds(e) {
|
|
701
|
-
const t = Array.from(this.nodes.get(e).ports.keys()),
|
|
702
|
-
return t.forEach((
|
|
703
|
-
this.getPortOutgoingEdgeIds(
|
|
722
|
+
const t = Array.from(this.nodes.get(e).ports.keys()), s = [];
|
|
723
|
+
return t.forEach((o) => {
|
|
724
|
+
this.getPortOutgoingEdgeIds(o).filter((n) => {
|
|
704
725
|
const a = this.getEdge(n);
|
|
705
726
|
return this.getPort(a.to).nodeId !== e;
|
|
706
727
|
}).forEach((n) => {
|
|
707
|
-
|
|
728
|
+
s.push(n);
|
|
708
729
|
});
|
|
709
|
-
}),
|
|
730
|
+
}), s;
|
|
710
731
|
}
|
|
711
732
|
getNodeCycleEdgeIds(e) {
|
|
712
|
-
const t = Array.from(this.nodes.get(e).ports.keys()),
|
|
713
|
-
return t.forEach((
|
|
714
|
-
this.getPortCycleEdgeIds(
|
|
715
|
-
|
|
716
|
-
}), this.getPortIncomingEdgeIds(
|
|
733
|
+
const t = Array.from(this.nodes.get(e).ports.keys()), s = [];
|
|
734
|
+
return t.forEach((o) => {
|
|
735
|
+
this.getPortCycleEdgeIds(o).forEach((n) => {
|
|
736
|
+
s.push(n);
|
|
737
|
+
}), this.getPortIncomingEdgeIds(o).filter((n) => {
|
|
717
738
|
const a = this.getEdge(n);
|
|
718
739
|
return this.getPort(a.to).nodeId === e;
|
|
719
740
|
}).forEach((n) => {
|
|
720
|
-
|
|
741
|
+
s.push(n);
|
|
721
742
|
});
|
|
722
|
-
}),
|
|
743
|
+
}), s;
|
|
723
744
|
}
|
|
724
745
|
getNodeAdjacentEdgeIds(e) {
|
|
725
|
-
const t = Array.from(this.nodes.get(e).ports.keys()),
|
|
726
|
-
return t.forEach((
|
|
727
|
-
this.getPortIncomingEdgeIds(
|
|
728
|
-
|
|
729
|
-
}), this.getPortOutgoingEdgeIds(
|
|
730
|
-
|
|
731
|
-
}), this.getPortCycleEdgeIds(
|
|
732
|
-
|
|
746
|
+
const t = Array.from(this.nodes.get(e).ports.keys()), s = [];
|
|
747
|
+
return t.forEach((o) => {
|
|
748
|
+
this.getPortIncomingEdgeIds(o).forEach((n) => {
|
|
749
|
+
s.push(n);
|
|
750
|
+
}), this.getPortOutgoingEdgeIds(o).forEach((n) => {
|
|
751
|
+
s.push(n);
|
|
752
|
+
}), this.getPortCycleEdgeIds(o).forEach((n) => {
|
|
753
|
+
s.push(n);
|
|
733
754
|
});
|
|
734
|
-
}),
|
|
755
|
+
}), s;
|
|
735
756
|
}
|
|
736
757
|
addEdgeInternal(e) {
|
|
737
758
|
this.edges.set(e.id, {
|
|
@@ -744,8 +765,8 @@ class Ae {
|
|
|
744
765
|
}), e.from !== e.to ? (this.portOutcomingEdges.get(e.from).add(e.id), this.portIncomingEdges.get(e.to).add(e.id)) : this.portCycleEdges.get(e.from).add(e.id);
|
|
745
766
|
}
|
|
746
767
|
removeEdgeInternal(e) {
|
|
747
|
-
const t = this.edges.get(e),
|
|
748
|
-
this.portCycleEdges.get(
|
|
768
|
+
const t = this.edges.get(e), s = t.from, o = t.to;
|
|
769
|
+
this.portCycleEdges.get(s).delete(e), this.portCycleEdges.get(o).delete(e), this.portIncomingEdges.get(s).delete(e), this.portIncomingEdges.get(o).delete(e), this.portOutcomingEdges.get(s).delete(e), this.portOutcomingEdges.get(o).delete(e), this.edges.delete(e);
|
|
749
770
|
}
|
|
750
771
|
}
|
|
751
772
|
const de = (r) => ({
|
|
@@ -809,7 +830,7 @@ class Qe {
|
|
|
809
830
|
this.observer.disconnect();
|
|
810
831
|
}
|
|
811
832
|
}
|
|
812
|
-
class
|
|
833
|
+
class q {
|
|
813
834
|
constructor(e) {
|
|
814
835
|
i(this, "elementToNodeId", /* @__PURE__ */ new Map());
|
|
815
836
|
i(this, "nodesResizeObserver");
|
|
@@ -825,14 +846,14 @@ class j {
|
|
|
825
846
|
this.nodesResizeObserver.disconnect(), this.elementToNodeId.clear();
|
|
826
847
|
});
|
|
827
848
|
this.canvas = e, this.nodesResizeObserver = new ResizeObserver((t) => {
|
|
828
|
-
t.forEach((
|
|
829
|
-
const
|
|
830
|
-
this.handleNodeResize(
|
|
849
|
+
t.forEach((s) => {
|
|
850
|
+
const o = s.target;
|
|
851
|
+
this.handleNodeResize(o);
|
|
831
852
|
});
|
|
832
853
|
}), this.canvas.graph.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.canvas.graph.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.canvas.graph.onBeforeClear.subscribe(this.onBeforeClear);
|
|
833
854
|
}
|
|
834
855
|
static configure(e) {
|
|
835
|
-
new
|
|
856
|
+
new q(e);
|
|
836
857
|
}
|
|
837
858
|
handleNodeResize(e) {
|
|
838
859
|
const t = this.elementToNodeId.get(e);
|
|
@@ -840,9 +861,9 @@ class j {
|
|
|
840
861
|
}
|
|
841
862
|
}
|
|
842
863
|
const Ze = (r, e, t) => {
|
|
843
|
-
const { x:
|
|
844
|
-
return e >=
|
|
845
|
-
}, Je = (r, e, t) => e >= 0 && e <= r.innerWidth && t >= 0 && t <= r.innerHeight, L = (r, e, t,
|
|
864
|
+
const { x: s, y: o, width: n, height: a } = r.getBoundingClientRect();
|
|
865
|
+
return e >= s && e <= s + n && t >= o && t <= o + a;
|
|
866
|
+
}, Je = (r, e, t) => e >= 0 && e <= r.innerWidth && t >= 0 && t <= r.innerHeight, L = (r, e, t, s) => Ze(e, t, s) && Je(r, t, s), $ = (r, e) => {
|
|
846
867
|
e !== null ? r.style.cursor = e : r.style.removeProperty("cursor");
|
|
847
868
|
}, U = (r) => {
|
|
848
869
|
const e = document.createElement("div");
|
|
@@ -862,13 +883,13 @@ const Ze = (r, e, t) => {
|
|
|
862
883
|
}, _e = (r, e) => {
|
|
863
884
|
let t = e;
|
|
864
885
|
for (; t !== null; ) {
|
|
865
|
-
const
|
|
866
|
-
if (
|
|
886
|
+
const s = r.findPortIdsByElement(t)[0] ?? null;
|
|
887
|
+
if (s !== null)
|
|
867
888
|
return {
|
|
868
889
|
status: "portFound",
|
|
869
|
-
portId:
|
|
890
|
+
portId: s
|
|
870
891
|
};
|
|
871
|
-
if (r.
|
|
892
|
+
if (r.findNodeIdByElement(t) !== null)
|
|
872
893
|
return {
|
|
873
894
|
status: "nodeEncountered"
|
|
874
895
|
};
|
|
@@ -880,27 +901,27 @@ const Ze = (r, e, t) => {
|
|
|
880
901
|
};
|
|
881
902
|
function* Ee(r, e) {
|
|
882
903
|
const t = r.elementsFromPoint(e.x, e.y);
|
|
883
|
-
for (const
|
|
884
|
-
if (
|
|
885
|
-
const
|
|
886
|
-
for (const n of
|
|
904
|
+
for (const s of t) {
|
|
905
|
+
if (s.shadowRoot !== null) {
|
|
906
|
+
const o = Ee(s.shadowRoot, e);
|
|
907
|
+
for (const n of o)
|
|
887
908
|
yield n;
|
|
888
909
|
}
|
|
889
|
-
yield
|
|
910
|
+
yield s;
|
|
890
911
|
}
|
|
891
912
|
}
|
|
892
913
|
const xe = (r, e) => {
|
|
893
914
|
const t = Ee(document, e);
|
|
894
|
-
for (const
|
|
895
|
-
const
|
|
896
|
-
if (
|
|
897
|
-
return
|
|
898
|
-
if (
|
|
915
|
+
for (const s of t) {
|
|
916
|
+
const o = _e(r, s);
|
|
917
|
+
if (o.status === "portFound")
|
|
918
|
+
return o.portId;
|
|
919
|
+
if (o.status === "nodeEncountered")
|
|
899
920
|
return null;
|
|
900
921
|
}
|
|
901
922
|
return null;
|
|
902
923
|
};
|
|
903
|
-
var
|
|
924
|
+
var C = /* @__PURE__ */ ((r) => (r.StaticNodeId = "static", r.DraggingNodeId = "dragging", r.EdgeId = "edge", r))(C || {});
|
|
904
925
|
const Se = (r, e) => ({
|
|
905
926
|
x: r / 2,
|
|
906
927
|
y: e / 2
|
|
@@ -914,21 +935,21 @@ const Se = (r, e) => ({
|
|
|
914
935
|
const t = {
|
|
915
936
|
x: r.x + r.width / 2,
|
|
916
937
|
y: r.y + r.height / 2
|
|
917
|
-
},
|
|
938
|
+
}, s = {
|
|
918
939
|
x: e.x + e.width / 2,
|
|
919
940
|
y: e.y + e.height / 2
|
|
920
|
-
},
|
|
941
|
+
}, o = Math.min(t.x, s.x), n = Math.min(t.y, s.y), a = Math.abs(s.x - t.x), h = Math.abs(s.y - t.y), d = t.x <= s.x ? 1 : -1, c = t.y <= s.y ? 1 : -1;
|
|
921
942
|
return {
|
|
922
|
-
x:
|
|
943
|
+
x: o,
|
|
923
944
|
y: n,
|
|
924
945
|
width: a,
|
|
925
946
|
height: h,
|
|
926
947
|
flipX: d,
|
|
927
948
|
flipY: c
|
|
928
949
|
};
|
|
929
|
-
},
|
|
930
|
-
x: e * r.x + (1 - e) / 2 *
|
|
931
|
-
y: t * r.y + (1 - t) / 2 *
|
|
950
|
+
}, W = (r, e, t, s) => ({
|
|
951
|
+
x: e * r.x + (1 - e) / 2 * s.x,
|
|
952
|
+
y: t * r.y + (1 - t) / 2 * s.y
|
|
932
953
|
});
|
|
933
954
|
class et {
|
|
934
955
|
constructor(e) {
|
|
@@ -937,21 +958,21 @@ class et {
|
|
|
937
958
|
this.params = e;
|
|
938
959
|
const t = this.params.to;
|
|
939
960
|
this.midpoint = { x: t.x / 2, y: t.y / 2 };
|
|
940
|
-
const
|
|
961
|
+
const s = m(
|
|
941
962
|
{ x: this.params.arrowLength, y: p.y },
|
|
942
963
|
this.params.sourceDirection,
|
|
943
964
|
p
|
|
944
|
-
),
|
|
965
|
+
), o = m(
|
|
945
966
|
{ x: this.params.to.x - this.params.arrowLength, y: this.params.to.y },
|
|
946
967
|
this.params.targetDirection,
|
|
947
968
|
this.params.to
|
|
948
969
|
), n = {
|
|
949
|
-
x:
|
|
950
|
-
y:
|
|
970
|
+
x: s.x + this.params.sourceDirection.x * this.params.curvature,
|
|
971
|
+
y: s.y + this.params.sourceDirection.y * this.params.curvature
|
|
951
972
|
}, a = {
|
|
952
|
-
x:
|
|
953
|
-
y:
|
|
954
|
-
}, h = `M ${
|
|
973
|
+
x: o.x - this.params.targetDirection.x * this.params.curvature,
|
|
974
|
+
y: o.y - this.params.targetDirection.y * this.params.curvature
|
|
975
|
+
}, h = `M ${s.x} ${s.y} C ${n.x} ${n.y}, ${a.x} ${a.y}, ${o.x} ${o.y}`, d = this.params.hasSourceArrow ? "" : `M ${p.x} ${p.y} L ${s.x} ${s.y} `, c = this.params.hasTargetArrow ? "" : ` M ${o.x} ${o.y} L ${this.params.to.x} ${this.params.to.y}`;
|
|
955
976
|
this.path = `${d}${h}${c}`;
|
|
956
977
|
}
|
|
957
978
|
}
|
|
@@ -964,22 +985,22 @@ class tt {
|
|
|
964
985
|
{ x: this.params.arrowLength, y: p.y },
|
|
965
986
|
this.params.sourceDirection,
|
|
966
987
|
p
|
|
967
|
-
) : p,
|
|
988
|
+
) : p, s = this.params.hasTargetArrow ? m(
|
|
968
989
|
{
|
|
969
990
|
x: this.params.to.x - this.params.arrowLength,
|
|
970
991
|
y: this.params.to.y
|
|
971
992
|
},
|
|
972
993
|
this.params.targetDirection,
|
|
973
994
|
this.params.to
|
|
974
|
-
) : this.params.to,
|
|
975
|
-
{ x:
|
|
995
|
+
) : this.params.to, o = this.params.arrowLength, n = Math.cos(this.params.detourDirection) * this.params.detourDistance, a = Math.sin(this.params.detourDirection) * this.params.detourDistance, h = n * this.params.flipX, d = a * this.params.flipY, c = m(
|
|
996
|
+
{ x: o, y: p.y },
|
|
976
997
|
this.params.sourceDirection,
|
|
977
998
|
p
|
|
978
999
|
), g = {
|
|
979
1000
|
x: c.x + h,
|
|
980
1001
|
y: c.y + d
|
|
981
1002
|
}, l = m(
|
|
982
|
-
{ x: this.params.to.x -
|
|
1003
|
+
{ x: this.params.to.x - o, y: this.params.to.y },
|
|
983
1004
|
this.params.targetDirection,
|
|
984
1005
|
this.params.to
|
|
985
1006
|
), u = {
|
|
@@ -1006,39 +1027,39 @@ class tt {
|
|
|
1006
1027
|
`L ${c.x} ${c.y}`,
|
|
1007
1028
|
`C ${y.x} ${y.y} ${x.x} ${x.y} ${w.x} ${w.y}`,
|
|
1008
1029
|
`C ${S.x} ${S.y} ${A.x} ${A.y} ${l.x} ${l.y}`,
|
|
1009
|
-
`L ${
|
|
1010
|
-
].join(" "), this.midpoint =
|
|
1030
|
+
`L ${s.x} ${s.y}`
|
|
1031
|
+
].join(" "), this.midpoint = W(w, e.flipX, e.flipY, e.to);
|
|
1011
1032
|
}
|
|
1012
1033
|
}
|
|
1013
|
-
const
|
|
1034
|
+
const K = Object.freeze({
|
|
1014
1035
|
edgeColor: "--edge-color"
|
|
1015
1036
|
}), Pe = (r) => {
|
|
1016
1037
|
const e = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
1017
|
-
return e.style.pointerEvents = "none", e.style.position = "absolute", e.style.top = "0", e.style.left = "0", e.style.overflow = "visible", e.style.setProperty(
|
|
1018
|
-
},
|
|
1038
|
+
return e.style.pointerEvents = "none", e.style.position = "absolute", e.style.top = "0", e.style.left = "0", e.style.overflow = "visible", e.style.setProperty(K.edgeColor, r), e;
|
|
1039
|
+
}, Ce = (r) => {
|
|
1019
1040
|
const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
1020
|
-
return e.setAttribute("stroke", `var(${
|
|
1041
|
+
return e.setAttribute("stroke", `var(${K.edgeColor})`), e.setAttribute("stroke-width", `${r}`), e.setAttribute("fill", "none"), e;
|
|
1021
1042
|
}, B = () => {
|
|
1022
1043
|
const r = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
1023
|
-
return r.setAttribute("fill", `var(${
|
|
1024
|
-
},
|
|
1044
|
+
return r.setAttribute("fill", `var(${K.edgeColor})`), r;
|
|
1045
|
+
}, Te = () => {
|
|
1025
1046
|
const r = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
|
1026
1047
|
return r.style.transformOrigin = "50% 50%", r;
|
|
1027
|
-
},
|
|
1048
|
+
}, Ne = (r, e) => {
|
|
1028
1049
|
r.style.transform = `translate(${e.x}px, ${e.y}px)`, r.style.width = `${Math.max(e.width, 1)}px`, r.style.height = `${Math.max(e.height, 1)}px`;
|
|
1029
|
-
},
|
|
1050
|
+
}, D = (r, e) => {
|
|
1030
1051
|
const t = [];
|
|
1031
1052
|
if (r.length > 0 && t.push(`M ${r[0].x} ${r[0].y}`), r.length === 2 && t.push(`L ${r[1].x} ${r[1].y}`), r.length > 2) {
|
|
1032
|
-
const
|
|
1033
|
-
let
|
|
1053
|
+
const s = r.length - 1;
|
|
1054
|
+
let o = 0, n = 0, a = 0;
|
|
1034
1055
|
r.forEach((h, d) => {
|
|
1035
1056
|
let c = 0, g = 0, l = 0;
|
|
1036
|
-
const u = d > 0, w = d <
|
|
1037
|
-
if (u && (c = -
|
|
1057
|
+
const u = d > 0, w = d < s, y = u && w;
|
|
1058
|
+
if (u && (c = -o, g = -n, l = a), w) {
|
|
1038
1059
|
const V = r[d + 1];
|
|
1039
|
-
|
|
1060
|
+
o = V.x - h.x, n = V.y - h.y, a = Math.sqrt(o * o + n * n);
|
|
1040
1061
|
}
|
|
1041
|
-
const x = a !== 0 ? Math.min((y ? e : 0) / a, d <
|
|
1062
|
+
const x = a !== 0 ? Math.min((y ? e : 0) / a, d < s - 1 ? 0.5 : 1) : 0, S = y ? { x: h.x + o * x, y: h.y + n * x } : h, P = l !== 0 ? Math.min((y ? e : 0) / l, d > 1 ? 0.5 : 1) : 0, R = y ? { x: h.x + c * P, y: h.y + g * P } : h;
|
|
1042
1063
|
d > 0 && t.push(`L ${R.x} ${R.y}`), y && t.push(
|
|
1043
1064
|
`C ${h.x} ${h.y} ${h.x} ${h.y} ${S.x} ${S.y}`
|
|
1044
1065
|
);
|
|
@@ -1053,11 +1074,11 @@ class rt {
|
|
|
1053
1074
|
this.params = e;
|
|
1054
1075
|
const t = this.params.to;
|
|
1055
1076
|
this.midpoint = { x: t.x / 2, y: t.y / 2 };
|
|
1056
|
-
const
|
|
1077
|
+
const s = this.params.hasSourceArrow ? m(
|
|
1057
1078
|
{ x: this.params.arrowLength, y: p.y },
|
|
1058
1079
|
this.params.sourceDirection,
|
|
1059
1080
|
p
|
|
1060
|
-
) : p,
|
|
1081
|
+
) : p, o = this.params.hasTargetArrow ? m(
|
|
1061
1082
|
{
|
|
1062
1083
|
x: this.params.to.x - this.params.arrowLength,
|
|
1063
1084
|
y: this.params.to.y
|
|
@@ -1079,13 +1100,13 @@ class rt {
|
|
|
1079
1100
|
x: this.params.flipX > 0 ? this.params.to.x - c : this.params.to.x + n,
|
|
1080
1101
|
y: d.y
|
|
1081
1102
|
}, y = { x: w.x, y: g };
|
|
1082
|
-
this.path =
|
|
1083
|
-
[
|
|
1103
|
+
this.path = D(
|
|
1104
|
+
[s, h, l, u, y, w, d, o],
|
|
1084
1105
|
this.params.roundness
|
|
1085
1106
|
);
|
|
1086
1107
|
}
|
|
1087
1108
|
}
|
|
1088
|
-
class
|
|
1109
|
+
class st {
|
|
1089
1110
|
constructor(e) {
|
|
1090
1111
|
i(this, "path");
|
|
1091
1112
|
i(this, "midpoint");
|
|
@@ -1094,40 +1115,40 @@ class ot {
|
|
|
1094
1115
|
{ x: this.params.arrowLength, y: p.y },
|
|
1095
1116
|
this.params.sourceDirection,
|
|
1096
1117
|
p
|
|
1097
|
-
) : p,
|
|
1118
|
+
) : p, s = this.params.hasTargetArrow ? m(
|
|
1098
1119
|
{
|
|
1099
1120
|
x: this.params.to.x - this.params.arrowLength,
|
|
1100
1121
|
y: this.params.to.y
|
|
1101
1122
|
},
|
|
1102
1123
|
this.params.targetDirection,
|
|
1103
1124
|
this.params.to
|
|
1104
|
-
) : this.params.to,
|
|
1105
|
-
{ x:
|
|
1125
|
+
) : this.params.to, o = this.params.arrowLength + this.params.arrowOffset, n = m(
|
|
1126
|
+
{ x: o, y: p.y },
|
|
1106
1127
|
this.params.sourceDirection,
|
|
1107
1128
|
p
|
|
1108
1129
|
), a = Math.cos(this.params.detourDirection) * this.params.detourDistance, h = Math.sin(this.params.detourDirection) * this.params.detourDistance, d = a * this.params.flipX, c = h * this.params.flipY, g = { x: n.x + d, y: n.y + c }, l = m(
|
|
1109
|
-
{ x: this.params.to.x -
|
|
1130
|
+
{ x: this.params.to.x - o, y: this.params.to.y },
|
|
1110
1131
|
this.params.targetDirection,
|
|
1111
1132
|
this.params.to
|
|
1112
1133
|
), u = { x: l.x + d, y: l.y + c }, w = { x: (g.x + u.x) / 2, y: (g.y + u.y) / 2 };
|
|
1113
|
-
this.midpoint =
|
|
1114
|
-
[t, n, g, u, l,
|
|
1134
|
+
this.midpoint = W(w, e.flipX, e.flipY, e.to), this.path = D(
|
|
1135
|
+
[t, n, g, u, l, s],
|
|
1115
1136
|
this.params.roundness
|
|
1116
1137
|
);
|
|
1117
1138
|
}
|
|
1118
1139
|
}
|
|
1119
|
-
class
|
|
1140
|
+
class ot {
|
|
1120
1141
|
constructor(e) {
|
|
1121
1142
|
i(this, "path");
|
|
1122
1143
|
i(this, "midpoint");
|
|
1123
1144
|
this.params = e;
|
|
1124
1145
|
const t = this.params.to;
|
|
1125
1146
|
this.midpoint = { x: t.x / 2, y: t.y / 2 };
|
|
1126
|
-
const
|
|
1147
|
+
const s = this.params.hasSourceArrow ? m(
|
|
1127
1148
|
{ x: this.params.arrowLength, y: p.y },
|
|
1128
1149
|
this.params.sourceDirection,
|
|
1129
1150
|
p
|
|
1130
|
-
) : p,
|
|
1151
|
+
) : p, o = this.params.hasTargetArrow ? m(
|
|
1131
1152
|
{
|
|
1132
1153
|
x: this.params.to.x - this.params.arrowLength,
|
|
1133
1154
|
y: this.params.to.y
|
|
@@ -1143,7 +1164,7 @@ class st {
|
|
|
1143
1164
|
this.params.targetDirection,
|
|
1144
1165
|
this.params.to
|
|
1145
1166
|
);
|
|
1146
|
-
this.path =
|
|
1167
|
+
this.path = D([s, a, h, o], this.params.roundness);
|
|
1147
1168
|
}
|
|
1148
1169
|
}
|
|
1149
1170
|
class it {
|
|
@@ -1153,11 +1174,11 @@ class it {
|
|
|
1153
1174
|
this.params = e;
|
|
1154
1175
|
const t = this.params.to;
|
|
1155
1176
|
this.midpoint = { x: t.x / 2, y: t.y / 2 };
|
|
1156
|
-
const
|
|
1177
|
+
const s = this.params.hasSourceArrow ? m(
|
|
1157
1178
|
{ x: this.params.arrowLength, y: p.y },
|
|
1158
1179
|
this.params.sourceDirection,
|
|
1159
1180
|
p
|
|
1160
|
-
) : p,
|
|
1181
|
+
) : p, o = this.params.hasTargetArrow ? m(
|
|
1161
1182
|
{
|
|
1162
1183
|
x: this.params.to.x - this.params.arrowLength,
|
|
1163
1184
|
y: this.params.to.y
|
|
@@ -1179,30 +1200,30 @@ class it {
|
|
|
1179
1200
|
x: d.x,
|
|
1180
1201
|
y: this.params.flipY > 0 ? this.params.to.y - c : this.params.to.y + n
|
|
1181
1202
|
}, y = { x: g, y: w.y };
|
|
1182
|
-
this.path =
|
|
1183
|
-
[
|
|
1203
|
+
this.path = D(
|
|
1204
|
+
[s, h, l, u, y, w, d, o],
|
|
1184
1205
|
this.params.roundness
|
|
1185
1206
|
);
|
|
1186
1207
|
}
|
|
1187
1208
|
}
|
|
1188
|
-
class
|
|
1209
|
+
class Q {
|
|
1189
1210
|
constructor(e) {
|
|
1190
1211
|
i(this, "path");
|
|
1191
1212
|
i(this, "midpoint");
|
|
1192
1213
|
this.params = e;
|
|
1193
|
-
const t = this.params.arrowOffset,
|
|
1214
|
+
const t = this.params.arrowOffset, s = this.params.side, o = this.params.arrowLength + t, n = o + 2 * s, h = [
|
|
1194
1215
|
{ x: this.params.arrowLength, y: p.y },
|
|
1195
|
-
{ x:
|
|
1196
|
-
{ x:
|
|
1216
|
+
{ x: o, y: p.y },
|
|
1217
|
+
{ x: o, y: this.params.side },
|
|
1197
1218
|
{ x: n, y: this.params.side },
|
|
1198
1219
|
{ x: n, y: -this.params.side },
|
|
1199
|
-
{ x:
|
|
1200
|
-
{ x:
|
|
1220
|
+
{ x: o, y: -this.params.side },
|
|
1221
|
+
{ x: o, y: p.y },
|
|
1201
1222
|
{ x: this.params.arrowLength, y: p.y }
|
|
1202
1223
|
].map(
|
|
1203
1224
|
(c) => m(c, this.params.sourceDirection, p)
|
|
1204
1225
|
), d = `M ${p.x} ${p.y} L ${h[0].x} ${h[0].y} `;
|
|
1205
|
-
this.path = `${this.params.hasSourceArrow || this.params.hasTargetArrow ? "" : d}${
|
|
1226
|
+
this.path = `${this.params.hasSourceArrow || this.params.hasTargetArrow ? "" : d}${D(h, this.params.roundness)}`, this.midpoint = { x: (h[3].x + h[4].x) / 2, y: (h[3].y + h[4].y) / 2 };
|
|
1206
1227
|
}
|
|
1207
1228
|
}
|
|
1208
1229
|
class nt {
|
|
@@ -1210,7 +1231,7 @@ class nt {
|
|
|
1210
1231
|
i(this, "path");
|
|
1211
1232
|
i(this, "midpoint");
|
|
1212
1233
|
this.params = e;
|
|
1213
|
-
const t = this.params.smallRadius,
|
|
1234
|
+
const t = this.params.smallRadius, s = this.params.radius, o = t + s, n = t * s / o, a = Math.sqrt(o * o - t * t), h = a * t / o, d = a + s + this.params.arrowLength, c = this.params.arrowLength + h, l = [
|
|
1214
1235
|
{ x: this.params.arrowLength, y: p.y },
|
|
1215
1236
|
{ x: c, y: n },
|
|
1216
1237
|
{ x: c, y: -n },
|
|
@@ -1220,7 +1241,7 @@ class nt {
|
|
|
1220
1241
|
), u = [
|
|
1221
1242
|
`M ${l[0].x} ${l[0].y}`,
|
|
1222
1243
|
`A ${t} ${t} 0 0 1 ${l[1].x} ${l[1].y}`,
|
|
1223
|
-
`A ${
|
|
1244
|
+
`A ${s} ${s} 0 1 0 ${l[2].x} ${l[2].y}`,
|
|
1224
1245
|
`A ${t} ${t} 0 0 1 ${l[0].x} ${l[0].y}`
|
|
1225
1246
|
].join(" "), w = `M 0 0 L ${l[0].x} ${l[0].y} `;
|
|
1226
1247
|
this.path = `${this.params.hasSourceArrow || this.params.hasTargetArrow ? "" : w}${u}`, this.midpoint = l[3];
|
|
@@ -1241,7 +1262,7 @@ class at {
|
|
|
1241
1262
|
this.path = "";
|
|
1242
1263
|
return;
|
|
1243
1264
|
}
|
|
1244
|
-
const
|
|
1265
|
+
const o = this.createDirectLinePoint({
|
|
1245
1266
|
offset: this.params.sourceOffset,
|
|
1246
1267
|
hasArrow: this.params.hasSourceArrow,
|
|
1247
1268
|
flip: 1,
|
|
@@ -1252,13 +1273,13 @@ class at {
|
|
|
1252
1273
|
flip: -1,
|
|
1253
1274
|
shift: this.params.to
|
|
1254
1275
|
});
|
|
1255
|
-
this.path = `M ${
|
|
1276
|
+
this.path = `M ${o.x} ${o.y} L ${n.x} ${n.y}`;
|
|
1256
1277
|
}
|
|
1257
1278
|
createDirectLinePoint(e) {
|
|
1258
|
-
const t = e.hasArrow ? this.params.arrowLength : 0,
|
|
1279
|
+
const t = e.hasArrow ? this.params.arrowLength : 0, s = e.offset + t, o = e.flip * s / this.diagonalDistance;
|
|
1259
1280
|
return {
|
|
1260
|
-
x: this.params.to.x *
|
|
1261
|
-
y: this.params.to.y *
|
|
1281
|
+
x: this.params.to.x * o + e.shift.x,
|
|
1282
|
+
y: this.params.to.y * o + e.shift.y
|
|
1262
1283
|
};
|
|
1263
1284
|
}
|
|
1264
1285
|
}
|
|
@@ -1271,33 +1292,33 @@ class ht {
|
|
|
1271
1292
|
{ x: this.params.arrowLength, y: p.y },
|
|
1272
1293
|
this.params.sourceDirection,
|
|
1273
1294
|
p
|
|
1274
|
-
) : p,
|
|
1295
|
+
) : p, s = this.params.hasTargetArrow ? m(
|
|
1275
1296
|
{
|
|
1276
1297
|
x: this.params.to.x - this.params.arrowLength,
|
|
1277
1298
|
y: this.params.to.y
|
|
1278
1299
|
},
|
|
1279
1300
|
this.params.targetDirection,
|
|
1280
1301
|
this.params.to
|
|
1281
|
-
) : this.params.to,
|
|
1282
|
-
{ x:
|
|
1302
|
+
) : this.params.to, o = this.params.arrowLength + this.params.arrowOffset, n = m(
|
|
1303
|
+
{ x: o, y: p.y },
|
|
1283
1304
|
this.params.sourceDirection,
|
|
1284
1305
|
p
|
|
1285
1306
|
), a = m(
|
|
1286
|
-
{ x: this.params.to.x -
|
|
1307
|
+
{ x: this.params.to.x - o, y: this.params.to.y },
|
|
1287
1308
|
this.params.targetDirection,
|
|
1288
1309
|
this.params.to
|
|
1289
1310
|
), h = this.params.detourDistance > 0 ? 1 : -1, d = this.params.to.y / 2, c = d + Math.abs(this.params.detourDistance), g = d + c * this.params.flipY * h, l = {
|
|
1290
1311
|
x: (n.x + a.x) / 2,
|
|
1291
1312
|
y: g
|
|
1292
1313
|
};
|
|
1293
|
-
this.midpoint =
|
|
1314
|
+
this.midpoint = W(l, e.flipX, e.flipY, e.to), this.path = D(
|
|
1294
1315
|
[
|
|
1295
1316
|
t,
|
|
1296
1317
|
n,
|
|
1297
1318
|
{ x: n.x, y: g },
|
|
1298
1319
|
{ x: a.x, y: g },
|
|
1299
1320
|
a,
|
|
1300
|
-
|
|
1321
|
+
s
|
|
1301
1322
|
],
|
|
1302
1323
|
this.params.roundness
|
|
1303
1324
|
);
|
|
@@ -1312,33 +1333,33 @@ class dt {
|
|
|
1312
1333
|
{ x: this.params.arrowLength, y: p.y },
|
|
1313
1334
|
this.params.sourceDirection,
|
|
1314
1335
|
p
|
|
1315
|
-
) : p,
|
|
1336
|
+
) : p, s = this.params.hasTargetArrow ? m(
|
|
1316
1337
|
{
|
|
1317
1338
|
x: this.params.to.x - this.params.arrowLength,
|
|
1318
1339
|
y: this.params.to.y
|
|
1319
1340
|
},
|
|
1320
1341
|
this.params.targetDirection,
|
|
1321
1342
|
this.params.to
|
|
1322
|
-
) : this.params.to,
|
|
1323
|
-
{ x:
|
|
1343
|
+
) : this.params.to, o = this.params.arrowLength + this.params.arrowOffset, n = m(
|
|
1344
|
+
{ x: o, y: p.y },
|
|
1324
1345
|
this.params.sourceDirection,
|
|
1325
1346
|
p
|
|
1326
1347
|
), a = m(
|
|
1327
|
-
{ x: this.params.to.x -
|
|
1348
|
+
{ x: this.params.to.x - o, y: this.params.to.y },
|
|
1328
1349
|
this.params.targetDirection,
|
|
1329
1350
|
this.params.to
|
|
1330
1351
|
), h = this.params.detourDistance > 0 ? 1 : -1, d = this.params.to.x / 2, c = d + Math.abs(this.params.detourDistance), g = d + c * this.params.flipX * h, l = {
|
|
1331
1352
|
x: g,
|
|
1332
1353
|
y: (n.y + a.y) / 2
|
|
1333
1354
|
};
|
|
1334
|
-
this.midpoint =
|
|
1355
|
+
this.midpoint = W(l, e.flipX, e.flipY, e.to), this.path = D(
|
|
1335
1356
|
[
|
|
1336
1357
|
t,
|
|
1337
1358
|
n,
|
|
1338
1359
|
{ x: g, y: n.y },
|
|
1339
1360
|
{ x: g, y: a.y },
|
|
1340
1361
|
a,
|
|
1341
|
-
|
|
1362
|
+
s
|
|
1342
1363
|
],
|
|
1343
1364
|
this.params.roundness
|
|
1344
1365
|
);
|
|
@@ -1367,24 +1388,24 @@ const f = Object.freeze({
|
|
|
1367
1388
|
interactiveWidth: 10,
|
|
1368
1389
|
preOffset: 0
|
|
1369
1390
|
}), ge = (r, e, t) => ({ x: e * Math.cos(r), y: t * Math.sin(r) });
|
|
1370
|
-
class
|
|
1391
|
+
class k {
|
|
1371
1392
|
constructor(e) {
|
|
1372
1393
|
i(this, "svg");
|
|
1373
|
-
i(this, "group",
|
|
1394
|
+
i(this, "group", Te());
|
|
1374
1395
|
i(this, "line");
|
|
1375
1396
|
i(this, "sourceArrow", null);
|
|
1376
1397
|
i(this, "targetArrow", null);
|
|
1377
1398
|
i(this, "onAfterRender");
|
|
1378
1399
|
i(this, "afterRenderEmitter");
|
|
1379
1400
|
i(this, "arrowRenderer");
|
|
1380
|
-
this.params = e, [this.afterRenderEmitter, this.onAfterRender] = E(), this.arrowRenderer = this.params.arrowRenderer, this.svg = Pe(e.color), this.svg.appendChild(this.group), this.line =
|
|
1401
|
+
this.params = e, [this.afterRenderEmitter, this.onAfterRender] = E(), this.arrowRenderer = this.params.arrowRenderer, this.svg = Pe(e.color), this.svg.appendChild(this.group), this.line = Ce(e.width), this.group.appendChild(this.line), e.hasSourceArrow && (this.sourceArrow = B(), this.group.appendChild(this.sourceArrow)), e.hasTargetArrow && (this.targetArrow = B(), this.group.appendChild(this.targetArrow));
|
|
1381
1402
|
}
|
|
1382
1403
|
render(e) {
|
|
1383
|
-
const { x: t, y:
|
|
1404
|
+
const { x: t, y: s, width: o, height: n, flipX: a, flipY: h } = be(
|
|
1384
1405
|
e.from,
|
|
1385
1406
|
e.to
|
|
1386
1407
|
);
|
|
1387
|
-
|
|
1408
|
+
Ne(this.svg, { x: t, y: s, width: o, height: n }), this.group.style.transform = `scale(${a}, ${h})`;
|
|
1388
1409
|
const d = ge(
|
|
1389
1410
|
e.from.direction,
|
|
1390
1411
|
a,
|
|
@@ -1394,7 +1415,7 @@ class W {
|
|
|
1394
1415
|
a,
|
|
1395
1416
|
h
|
|
1396
1417
|
), g = {
|
|
1397
|
-
x:
|
|
1418
|
+
x: o,
|
|
1398
1419
|
y: n
|
|
1399
1420
|
};
|
|
1400
1421
|
let l = { x: -c.x, y: -c.y }, u;
|
|
@@ -1426,7 +1447,7 @@ class W {
|
|
|
1426
1447
|
}
|
|
1427
1448
|
}
|
|
1428
1449
|
const ct = (r) => (e) => {
|
|
1429
|
-
const
|
|
1450
|
+
const s = [
|
|
1430
1451
|
p,
|
|
1431
1452
|
{ x: e.arrowLength, y: r.radius },
|
|
1432
1453
|
{ x: e.arrowLength, y: -r.radius }
|
|
@@ -1435,18 +1456,18 @@ const ct = (r) => (e) => {
|
|
|
1435
1456
|
).map((h) => ({
|
|
1436
1457
|
x: h.x + e.shift.x,
|
|
1437
1458
|
y: h.y + e.shift.y
|
|
1438
|
-
})),
|
|
1439
|
-
return `${
|
|
1459
|
+
})), o = `M ${s[0].x} ${s[0].y}`, n = `L ${s[1].x} ${s[1].y}`, a = `L ${s[2].x} ${s[2].y}`;
|
|
1460
|
+
return `${o} ${n} ${a} Z`;
|
|
1440
1461
|
}, lt = (r) => (e) => {
|
|
1441
|
-
const t = r.radius,
|
|
1462
|
+
const t = r.radius, s = e.arrowLength, o = (s * s + 2 * s * t) / (2 * t), n = o + t, a = s + t - t * (s + t) / n, h = t * o / n, c = [p, { x: a, y: -h }, { x: a, y: h }].map(
|
|
1442
1463
|
(y) => m(y, e.direction, p)
|
|
1443
1464
|
).map((y) => ({
|
|
1444
1465
|
x: y.x + e.shift.x,
|
|
1445
1466
|
y: y.y + e.shift.y
|
|
1446
|
-
})), g = `M ${c[0].x} ${c[0].y}`, l = `A ${
|
|
1467
|
+
})), g = `M ${c[0].x} ${c[0].y}`, l = `A ${o} ${o} 0 0 0 ${c[1].x} ${c[1].y}`, u = `A ${t} ${t} 0 0 0 ${c[2].x} ${c[2].y}`, w = `A ${o} ${o} 0 0 0 ${c[0].x} ${c[0].y}`;
|
|
1447
1468
|
return `${g} ${l} ${u} ${w}`;
|
|
1448
1469
|
}, gt = (r) => (e) => {
|
|
1449
|
-
const t = r.smallRadius,
|
|
1470
|
+
const t = r.smallRadius, s = r.radius, o = m(
|
|
1450
1471
|
{
|
|
1451
1472
|
x: e.arrowLength,
|
|
1452
1473
|
y: 0
|
|
@@ -1459,12 +1480,12 @@ const ct = (r) => (e) => {
|
|
|
1459
1480
|
x: e.arrowLength + r.smallRadius,
|
|
1460
1481
|
y: 0
|
|
1461
1482
|
}
|
|
1462
|
-
), a = [p, { x:
|
|
1483
|
+
), a = [p, { x: o.x, y: -o.y }, o].map(
|
|
1463
1484
|
(l) => m(l, e.direction, p)
|
|
1464
1485
|
).map((l) => ({
|
|
1465
1486
|
x: l.x + e.shift.x,
|
|
1466
1487
|
y: l.y + e.shift.y
|
|
1467
|
-
})), h = `M ${a[0].x} ${a[0].y}`, d = `A ${
|
|
1488
|
+
})), h = `M ${a[0].x} ${a[0].y}`, d = `A ${s} ${s} 0 0 1 ${a[1].x} ${a[1].y}`, c = `A ${t} ${t} 0 0 1 ${a[2].x} ${a[2].y}`, g = `A ${s} ${s} 0 0 1 ${a[0].x} ${a[0].y}`;
|
|
1468
1489
|
return `${h} ${d} ${c} ${g}`;
|
|
1469
1490
|
}, F = (r) => {
|
|
1470
1491
|
if (typeof r == "function")
|
|
@@ -1511,11 +1532,11 @@ class ut {
|
|
|
1511
1532
|
hasSourceArrow: this.hasSourceArrow,
|
|
1512
1533
|
hasTargetArrow: this.hasTargetArrow
|
|
1513
1534
|
}));
|
|
1514
|
-
i(this, "createDetourPath", (e, t,
|
|
1515
|
-
to:
|
|
1535
|
+
i(this, "createDetourPath", (e, t, s, o, n) => new tt({
|
|
1536
|
+
to: s,
|
|
1516
1537
|
sourceDirection: e,
|
|
1517
1538
|
targetDirection: t,
|
|
1518
|
-
flipX:
|
|
1539
|
+
flipX: o,
|
|
1519
1540
|
flipY: n,
|
|
1520
1541
|
arrowLength: this.arrowLength,
|
|
1521
1542
|
detourDirection: this.detourDirection,
|
|
@@ -1524,8 +1545,8 @@ class ut {
|
|
|
1524
1545
|
hasSourceArrow: this.hasSourceArrow,
|
|
1525
1546
|
hasTargetArrow: this.hasTargetArrow
|
|
1526
1547
|
}));
|
|
1527
|
-
i(this, "createLinePath", (e, t,
|
|
1528
|
-
to:
|
|
1548
|
+
i(this, "createLinePath", (e, t, s) => new et({
|
|
1549
|
+
to: s,
|
|
1529
1550
|
sourceDirection: e,
|
|
1530
1551
|
targetDirection: t,
|
|
1531
1552
|
arrowLength: this.arrowLength,
|
|
@@ -1533,7 +1554,7 @@ class ut {
|
|
|
1533
1554
|
hasSourceArrow: this.hasSourceArrow,
|
|
1534
1555
|
hasTargetArrow: this.hasTargetArrow
|
|
1535
1556
|
}));
|
|
1536
|
-
this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? f.arrowLength, this.curvature = (e == null ? void 0 : e.curvature) ?? f.curvature, this.portCycleRadius = (e == null ? void 0 : e.cycleRadius) ?? f.cycleRadius, this.portCycleSmallRadius = (e == null ? void 0 : e.smallCycleRadius) ?? f.smallCycleRadius, this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? f.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? f.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? f.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? f.hasTargetArrow, this.pathShape = new
|
|
1557
|
+
this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? f.arrowLength, this.curvature = (e == null ? void 0 : e.curvature) ?? f.curvature, this.portCycleRadius = (e == null ? void 0 : e.cycleRadius) ?? f.cycleRadius, this.portCycleSmallRadius = (e == null ? void 0 : e.smallCycleRadius) ?? f.smallCycleRadius, this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? f.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? f.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? f.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? f.hasTargetArrow, this.pathShape = new k({
|
|
1537
1558
|
color: (e == null ? void 0 : e.color) ?? f.color,
|
|
1538
1559
|
width: (e == null ? void 0 : e.width) ?? f.width,
|
|
1539
1560
|
arrowRenderer: F((e == null ? void 0 : e.arrowRenderer) ?? {}),
|
|
@@ -1565,7 +1586,7 @@ class pt {
|
|
|
1565
1586
|
i(this, "hasSourceArrow");
|
|
1566
1587
|
i(this, "hasTargetArrow");
|
|
1567
1588
|
i(this, "pathShape");
|
|
1568
|
-
i(this, "createCyclePath", (e) => new
|
|
1589
|
+
i(this, "createCyclePath", (e) => new Q({
|
|
1569
1590
|
sourceDirection: e,
|
|
1570
1591
|
arrowLength: this.arrowLength,
|
|
1571
1592
|
side: this.cycleSquareSide,
|
|
@@ -1574,11 +1595,11 @@ class pt {
|
|
|
1574
1595
|
hasSourceArrow: this.hasSourceArrow,
|
|
1575
1596
|
hasTargetArrow: this.hasTargetArrow
|
|
1576
1597
|
}));
|
|
1577
|
-
i(this, "createDetourPath", (e, t,
|
|
1578
|
-
to:
|
|
1598
|
+
i(this, "createDetourPath", (e, t, s, o, n) => new ht({
|
|
1599
|
+
to: s,
|
|
1579
1600
|
sourceDirection: e,
|
|
1580
1601
|
targetDirection: t,
|
|
1581
|
-
flipX:
|
|
1602
|
+
flipX: o,
|
|
1582
1603
|
flipY: n,
|
|
1583
1604
|
arrowLength: this.arrowLength,
|
|
1584
1605
|
arrowOffset: this.arrowOffset,
|
|
@@ -1587,11 +1608,11 @@ class pt {
|
|
|
1587
1608
|
hasSourceArrow: this.hasSourceArrow,
|
|
1588
1609
|
hasTargetArrow: this.hasTargetArrow
|
|
1589
1610
|
}));
|
|
1590
|
-
i(this, "createLinePath", (e, t,
|
|
1591
|
-
to:
|
|
1611
|
+
i(this, "createLinePath", (e, t, s, o) => new rt({
|
|
1612
|
+
to: s,
|
|
1592
1613
|
sourceDirection: e,
|
|
1593
1614
|
targetDirection: t,
|
|
1594
|
-
flipX:
|
|
1615
|
+
flipX: o,
|
|
1595
1616
|
arrowLength: this.arrowLength,
|
|
1596
1617
|
arrowOffset: this.arrowOffset,
|
|
1597
1618
|
roundness: this.roundness,
|
|
@@ -1604,7 +1625,7 @@ class pt {
|
|
|
1604
1625
|
t,
|
|
1605
1626
|
this.arrowOffset,
|
|
1606
1627
|
this.cycleSquareSide / 2
|
|
1607
|
-
), this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? f.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? f.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? f.hasTargetArrow, this.pathShape = new
|
|
1628
|
+
), this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? f.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? f.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? f.hasTargetArrow, this.pathShape = new k({
|
|
1608
1629
|
color: (e == null ? void 0 : e.color) ?? f.color,
|
|
1609
1630
|
width: (e == null ? void 0 : e.width) ?? f.width,
|
|
1610
1631
|
arrowRenderer: F((e == null ? void 0 : e.arrowRenderer) ?? {}),
|
|
@@ -1637,7 +1658,7 @@ class wt {
|
|
|
1637
1658
|
i(this, "hasSourceArrow");
|
|
1638
1659
|
i(this, "hasTargetArrow");
|
|
1639
1660
|
i(this, "pathShape");
|
|
1640
|
-
i(this, "createCyclePath", (e) => new
|
|
1661
|
+
i(this, "createCyclePath", (e) => new Q({
|
|
1641
1662
|
sourceDirection: e,
|
|
1642
1663
|
arrowLength: this.arrowLength,
|
|
1643
1664
|
side: this.cycleSquareSide,
|
|
@@ -1646,11 +1667,11 @@ class wt {
|
|
|
1646
1667
|
hasSourceArrow: this.hasSourceArrow,
|
|
1647
1668
|
hasTargetArrow: this.hasTargetArrow
|
|
1648
1669
|
}));
|
|
1649
|
-
i(this, "createDetourPath", (e, t,
|
|
1650
|
-
to:
|
|
1670
|
+
i(this, "createDetourPath", (e, t, s, o, n) => new st({
|
|
1671
|
+
to: s,
|
|
1651
1672
|
sourceDirection: e,
|
|
1652
1673
|
targetDirection: t,
|
|
1653
|
-
flipX:
|
|
1674
|
+
flipX: o,
|
|
1654
1675
|
flipY: n,
|
|
1655
1676
|
arrowLength: this.arrowLength,
|
|
1656
1677
|
arrowOffset: this.arrowOffset,
|
|
@@ -1660,8 +1681,8 @@ class wt {
|
|
|
1660
1681
|
hasSourceArrow: this.hasSourceArrow,
|
|
1661
1682
|
hasTargetArrow: this.hasTargetArrow
|
|
1662
1683
|
}));
|
|
1663
|
-
i(this, "createLinePath", (e, t,
|
|
1664
|
-
to:
|
|
1684
|
+
i(this, "createLinePath", (e, t, s) => new ot({
|
|
1685
|
+
to: s,
|
|
1665
1686
|
sourceDirection: e,
|
|
1666
1687
|
targetDirection: t,
|
|
1667
1688
|
arrowLength: this.arrowLength,
|
|
@@ -1676,7 +1697,7 @@ class wt {
|
|
|
1676
1697
|
t,
|
|
1677
1698
|
this.arrowOffset,
|
|
1678
1699
|
this.cycleSquareSide / 2
|
|
1679
|
-
), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? f.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? f.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? f.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? f.hasTargetArrow, this.pathShape = new
|
|
1700
|
+
), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? f.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? f.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? f.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? f.hasTargetArrow, this.pathShape = new k({
|
|
1680
1701
|
color: (e == null ? void 0 : e.color) ?? f.color,
|
|
1681
1702
|
width: (e == null ? void 0 : e.width) ?? f.width,
|
|
1682
1703
|
arrowRenderer: F((e == null ? void 0 : e.arrowRenderer) ?? {}),
|
|
@@ -1708,7 +1729,7 @@ class ft {
|
|
|
1708
1729
|
i(this, "hasSourceArrow");
|
|
1709
1730
|
i(this, "hasTargetArrow");
|
|
1710
1731
|
i(this, "pathShape");
|
|
1711
|
-
i(this, "createCyclePath", (e) => new
|
|
1732
|
+
i(this, "createCyclePath", (e) => new Q({
|
|
1712
1733
|
sourceDirection: e,
|
|
1713
1734
|
arrowLength: this.arrowLength,
|
|
1714
1735
|
side: this.cycleSquareSide,
|
|
@@ -1717,11 +1738,11 @@ class ft {
|
|
|
1717
1738
|
hasSourceArrow: this.hasSourceArrow,
|
|
1718
1739
|
hasTargetArrow: this.hasTargetArrow
|
|
1719
1740
|
}));
|
|
1720
|
-
i(this, "createDetourPath", (e, t,
|
|
1721
|
-
to:
|
|
1741
|
+
i(this, "createDetourPath", (e, t, s, o, n) => new dt({
|
|
1742
|
+
to: s,
|
|
1722
1743
|
sourceDirection: e,
|
|
1723
1744
|
targetDirection: t,
|
|
1724
|
-
flipX:
|
|
1745
|
+
flipX: o,
|
|
1725
1746
|
flipY: n,
|
|
1726
1747
|
arrowLength: this.arrowLength,
|
|
1727
1748
|
arrowOffset: this.arrowOffset,
|
|
@@ -1730,8 +1751,8 @@ class ft {
|
|
|
1730
1751
|
hasSourceArrow: this.hasSourceArrow,
|
|
1731
1752
|
hasTargetArrow: this.hasTargetArrow
|
|
1732
1753
|
}));
|
|
1733
|
-
i(this, "createLinePath", (e, t,
|
|
1734
|
-
to:
|
|
1754
|
+
i(this, "createLinePath", (e, t, s, o, n) => new it({
|
|
1755
|
+
to: s,
|
|
1735
1756
|
sourceDirection: e,
|
|
1736
1757
|
targetDirection: t,
|
|
1737
1758
|
flipY: n,
|
|
@@ -1747,7 +1768,7 @@ class ft {
|
|
|
1747
1768
|
t,
|
|
1748
1769
|
this.arrowOffset,
|
|
1749
1770
|
this.cycleSquareSide / 2
|
|
1750
|
-
), this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? f.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? f.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? f.hasTargetArrow, this.pathShape = new
|
|
1771
|
+
), this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? f.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? f.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? f.hasTargetArrow, this.pathShape = new k({
|
|
1751
1772
|
color: (e == null ? void 0 : e.color) ?? f.color,
|
|
1752
1773
|
width: (e == null ? void 0 : e.width) ?? f.width,
|
|
1753
1774
|
arrowRenderer: F((e == null ? void 0 : e.arrowRenderer) ?? {}),
|
|
@@ -1763,10 +1784,10 @@ class ft {
|
|
|
1763
1784
|
this.pathShape.render(e);
|
|
1764
1785
|
}
|
|
1765
1786
|
}
|
|
1766
|
-
class
|
|
1787
|
+
class De {
|
|
1767
1788
|
constructor(e) {
|
|
1768
1789
|
i(this, "svg");
|
|
1769
|
-
i(this, "group",
|
|
1790
|
+
i(this, "group", Te());
|
|
1770
1791
|
i(this, "line");
|
|
1771
1792
|
i(this, "sourceArrow", null);
|
|
1772
1793
|
i(this, "targetArrow", null);
|
|
@@ -1778,15 +1799,15 @@ class Ne {
|
|
|
1778
1799
|
i(this, "onAfterRender");
|
|
1779
1800
|
i(this, "afterRenderEmitter");
|
|
1780
1801
|
i(this, "arrowRenderer");
|
|
1781
|
-
[this.afterRenderEmitter, this.onAfterRender] = E(), this.color = (e == null ? void 0 : e.color) ?? f.color, this.width = (e == null ? void 0 : e.width) ?? f.width, this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? f.arrowLength, this.arrowRenderer = F((e == null ? void 0 : e.arrowRenderer) ?? {}), this.sourceOffset = (e == null ? void 0 : e.sourceOffset) ?? f.preOffset, this.targetOffset = (e == null ? void 0 : e.targetOffset) ?? f.preOffset, this.svg = Pe(this.color), this.svg.appendChild(this.group), this.line =
|
|
1802
|
+
[this.afterRenderEmitter, this.onAfterRender] = E(), this.color = (e == null ? void 0 : e.color) ?? f.color, this.width = (e == null ? void 0 : e.width) ?? f.width, this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? f.arrowLength, this.arrowRenderer = F((e == null ? void 0 : e.arrowRenderer) ?? {}), this.sourceOffset = (e == null ? void 0 : e.sourceOffset) ?? f.preOffset, this.targetOffset = (e == null ? void 0 : e.targetOffset) ?? f.preOffset, this.svg = Pe(this.color), this.svg.appendChild(this.group), this.line = Ce(this.width), this.group.appendChild(this.line), e != null && e.hasSourceArrow && (this.sourceArrow = B(), this.group.appendChild(this.sourceArrow)), e != null && e.hasTargetArrow && (this.targetArrow = B(), this.group.appendChild(this.targetArrow));
|
|
1782
1803
|
}
|
|
1783
1804
|
render(e) {
|
|
1784
|
-
const { x: t, y:
|
|
1805
|
+
const { x: t, y: s, width: o, height: n, flipX: a, flipY: h } = be(
|
|
1785
1806
|
e.from,
|
|
1786
1807
|
e.to
|
|
1787
1808
|
);
|
|
1788
|
-
|
|
1789
|
-
const d = { x:
|
|
1809
|
+
Ne(this.svg, { x: t, y: s, width: o, height: n }), this.group.style.transform = `scale(${a}, ${h})`;
|
|
1810
|
+
const d = { x: o, y: n }, c = new at({
|
|
1790
1811
|
to: d,
|
|
1791
1812
|
sourceOffset: this.sourceOffset,
|
|
1792
1813
|
targetOffset: this.targetOffset,
|
|
@@ -1869,16 +1890,16 @@ class Me {
|
|
|
1869
1890
|
"interactive edge can be configured only once"
|
|
1870
1891
|
);
|
|
1871
1892
|
this.svg = this.baseEdge.svg, this.group = this.baseEdge.group, this.line = this.baseEdge.line, this.sourceArrow = this.baseEdge.sourceArrow, this.targetArrow = this.baseEdge.targetArrow, this.onAfterRender = this.baseEdge.onAfterRender;
|
|
1872
|
-
const
|
|
1873
|
-
this.interactiveLine = mt(
|
|
1874
|
-
this.interactiveLine.setAttribute("d",
|
|
1893
|
+
const s = (t == null ? void 0 : t.distance) ?? f.interactiveWidth;
|
|
1894
|
+
this.interactiveLine = mt(s), this.handle.appendChild(this.interactiveLine), this.sourceArrow && (this.interactiveSourceArrow = ue(s), this.handle.appendChild(this.interactiveSourceArrow)), this.targetArrow && (this.interactiveTargetArrow = ue(s), this.handle.appendChild(this.interactiveTargetArrow)), this.group.appendChild(this.handle), this.baseEdge.onAfterRender.subscribe((o) => {
|
|
1895
|
+
this.interactiveLine.setAttribute("d", o.edgePath.path), this.interactiveSourceArrow && this.interactiveSourceArrow.setAttribute("d", o.sourceArrowPath), this.interactiveTargetArrow && this.interactiveTargetArrow.setAttribute("d", o.targetArrowPath);
|
|
1875
1896
|
});
|
|
1876
1897
|
}
|
|
1877
1898
|
render(e) {
|
|
1878
1899
|
this.baseEdge.render(e);
|
|
1879
1900
|
}
|
|
1880
1901
|
}
|
|
1881
|
-
class
|
|
1902
|
+
class sr {
|
|
1882
1903
|
constructor(e, t) {
|
|
1883
1904
|
i(this, "group");
|
|
1884
1905
|
i(this, "line");
|
|
@@ -1886,8 +1907,8 @@ class or {
|
|
|
1886
1907
|
i(this, "targetArrow");
|
|
1887
1908
|
i(this, "onAfterRender");
|
|
1888
1909
|
i(this, "svg");
|
|
1889
|
-
this.baseShape = e, this.midpointElement = t, this.svg = this.baseShape.svg, this.group = this.baseShape.group, this.line = this.baseShape.line, this.sourceArrow = this.baseShape.sourceArrow, this.targetArrow = this.baseShape.targetArrow, this.onAfterRender = this.baseShape.onAfterRender, this.svg.append(this.midpointElement), this.baseShape.onAfterRender.subscribe((
|
|
1890
|
-
const
|
|
1910
|
+
this.baseShape = e, this.midpointElement = t, this.svg = this.baseShape.svg, this.group = this.baseShape.group, this.line = this.baseShape.line, this.sourceArrow = this.baseShape.sourceArrow, this.targetArrow = this.baseShape.targetArrow, this.onAfterRender = this.baseShape.onAfterRender, this.svg.append(this.midpointElement), this.baseShape.onAfterRender.subscribe((s) => {
|
|
1911
|
+
const o = s.edgePath.midpoint, n = `translate(${o.x}px, ${o.y}px)`;
|
|
1891
1912
|
this.midpointElement.style.setProperty("transform", n);
|
|
1892
1913
|
});
|
|
1893
1914
|
}
|
|
@@ -1912,25 +1933,38 @@ class Le {
|
|
|
1912
1933
|
i(this, "onBeforeClear");
|
|
1913
1934
|
this.graphStore = e, this.onAfterNodeAdded = this.graphStore.onAfterNodeAdded, this.onAfterNodeUpdated = this.graphStore.onAfterNodeUpdated, this.onAfterNodePriorityUpdated = this.graphStore.onAfterNodePriorityUpdated, this.onBeforeNodeRemoved = this.graphStore.onBeforeNodeRemoved, this.onAfterPortMarked = this.graphStore.onAfterPortAdded, this.onAfterPortUpdated = this.graphStore.onAfterPortUpdated, this.onBeforePortUnmarked = this.graphStore.onBeforePortRemoved, this.onAfterEdgeAdded = this.graphStore.onAfterEdgeAdded, this.onAfterEdgeShapeUpdated = this.graphStore.onAfterEdgeShapeUpdated, this.onAfterEdgeUpdated = this.graphStore.onAfterEdgeUpdated, this.onAfterEdgePriorityUpdated = this.graphStore.onAfterEdgePriorityUpdated, this.onBeforeEdgeRemoved = this.graphStore.onBeforeEdgeRemoved, this.onBeforeClear = this.graphStore.onBeforeClear;
|
|
1914
1935
|
}
|
|
1936
|
+
hasNode(e) {
|
|
1937
|
+
return this.graphStore.hasNode(e);
|
|
1938
|
+
}
|
|
1915
1939
|
getNode(e) {
|
|
1916
1940
|
const t = this.graphStore.getNode(e);
|
|
1917
1941
|
if (t === void 0)
|
|
1918
1942
|
return null;
|
|
1919
|
-
const
|
|
1943
|
+
const s = t.payload;
|
|
1920
1944
|
return {
|
|
1921
1945
|
element: t.element,
|
|
1922
|
-
x:
|
|
1923
|
-
y:
|
|
1924
|
-
centerFn:
|
|
1925
|
-
priority:
|
|
1946
|
+
x: s.x,
|
|
1947
|
+
y: s.y,
|
|
1948
|
+
centerFn: s.centerFn,
|
|
1949
|
+
priority: s.priority
|
|
1926
1950
|
};
|
|
1927
1951
|
}
|
|
1952
|
+
findNodeIdByElement(e) {
|
|
1953
|
+
return this.graphStore.findNodeIdByElement(e) ?? null;
|
|
1954
|
+
}
|
|
1955
|
+
/**
|
|
1956
|
+
* @deprecated
|
|
1957
|
+
* use findNodeIdByElement instead
|
|
1958
|
+
*/
|
|
1928
1959
|
getElementNodeId(e) {
|
|
1929
|
-
return this.graphStore.
|
|
1960
|
+
return this.graphStore.findNodeIdByElement(e) ?? null;
|
|
1930
1961
|
}
|
|
1931
1962
|
getAllNodeIds() {
|
|
1932
1963
|
return this.graphStore.getAllNodeIds();
|
|
1933
1964
|
}
|
|
1965
|
+
hasPort(e) {
|
|
1966
|
+
return this.graphStore.hasPort(e);
|
|
1967
|
+
}
|
|
1934
1968
|
getPort(e) {
|
|
1935
1969
|
const t = this.graphStore.getPort(e);
|
|
1936
1970
|
return t === void 0 ? null : {
|
|
@@ -1945,47 +1979,57 @@ class Le {
|
|
|
1945
1979
|
getNodePortIds(e) {
|
|
1946
1980
|
return this.graphStore.getNodePortIds(e) ?? null;
|
|
1947
1981
|
}
|
|
1982
|
+
/**
|
|
1983
|
+
* @deprecated
|
|
1984
|
+
* use findPortIdsByElement instead
|
|
1985
|
+
*/
|
|
1948
1986
|
getElementPortIds(e) {
|
|
1949
|
-
return
|
|
1987
|
+
return this.graphStore.findPortIdsByElement(e);
|
|
1988
|
+
}
|
|
1989
|
+
findPortIdsByElement(e) {
|
|
1990
|
+
return this.graphStore.findPortIdsByElement(e);
|
|
1950
1991
|
}
|
|
1951
1992
|
getAllEdgeIds() {
|
|
1952
1993
|
return this.graphStore.getAllEdgeIds();
|
|
1953
1994
|
}
|
|
1995
|
+
hasEdge(e) {
|
|
1996
|
+
return this.graphStore.hasEdge(e);
|
|
1997
|
+
}
|
|
1954
1998
|
getEdge(e) {
|
|
1955
1999
|
const t = this.graphStore.getEdge(e);
|
|
1956
2000
|
if (t === void 0)
|
|
1957
2001
|
return null;
|
|
1958
|
-
const
|
|
2002
|
+
const s = t.payload;
|
|
1959
2003
|
return {
|
|
1960
2004
|
from: t.from,
|
|
1961
2005
|
to: t.to,
|
|
1962
|
-
priority:
|
|
1963
|
-
shape:
|
|
2006
|
+
priority: s.priority,
|
|
2007
|
+
shape: s.shape
|
|
1964
2008
|
};
|
|
1965
2009
|
}
|
|
1966
2010
|
getPortIncomingEdgeIds(e) {
|
|
1967
|
-
return this.graphStore.
|
|
2011
|
+
return this.graphStore.hasPort(e) ? this.graphStore.getPortIncomingEdgeIds(e) : null;
|
|
1968
2012
|
}
|
|
1969
2013
|
getPortOutgoingEdgeIds(e) {
|
|
1970
|
-
return this.graphStore.
|
|
2014
|
+
return this.graphStore.hasPort(e) ? this.graphStore.getPortOutgoingEdgeIds(e) : null;
|
|
1971
2015
|
}
|
|
1972
2016
|
getPortCycleEdgeIds(e) {
|
|
1973
|
-
return this.graphStore.
|
|
2017
|
+
return this.graphStore.hasPort(e) ? this.graphStore.getPortCycleEdgeIds(e) : null;
|
|
1974
2018
|
}
|
|
1975
2019
|
getPortAdjacentEdgeIds(e) {
|
|
1976
|
-
return this.graphStore.
|
|
2020
|
+
return this.graphStore.hasPort(e) ? this.graphStore.getPortAdjacentEdgeIds(e) : null;
|
|
1977
2021
|
}
|
|
1978
2022
|
getNodeIncomingEdgeIds(e) {
|
|
1979
|
-
return this.graphStore.
|
|
2023
|
+
return this.graphStore.hasNode(e) ? this.graphStore.getNodeIncomingEdgeIds(e) : null;
|
|
1980
2024
|
}
|
|
1981
2025
|
getNodeOutgoingEdgeIds(e) {
|
|
1982
|
-
return this.graphStore.
|
|
2026
|
+
return this.graphStore.hasNode(e) ? this.graphStore.getNodeOutgoingEdgeIds(e) : null;
|
|
1983
2027
|
}
|
|
1984
2028
|
getNodeCycleEdgeIds(e) {
|
|
1985
|
-
return this.graphStore.
|
|
2029
|
+
return this.graphStore.hasNode(e) ? this.graphStore.getNodeCycleEdgeIds(e) : null;
|
|
1986
2030
|
}
|
|
1987
2031
|
getNodeAdjacentEdgeIds(e) {
|
|
1988
|
-
return this.graphStore.
|
|
2032
|
+
return this.graphStore.hasNode(e) ? this.graphStore.getNodeAdjacentEdgeIds(e) : null;
|
|
1989
2033
|
}
|
|
1990
2034
|
}
|
|
1991
2035
|
class Re {
|
|
@@ -2012,13 +2056,13 @@ class Re {
|
|
|
2012
2056
|
}
|
|
2013
2057
|
}
|
|
2014
2058
|
const Ve = (r, e) => {
|
|
2015
|
-
const t = new Ae(),
|
|
2059
|
+
const t = new Ae(), s = new Le(t), o = new Re(e), n = new me(t, e, r), a = {
|
|
2016
2060
|
nodes: {
|
|
2017
2061
|
centerFn: Se,
|
|
2018
2062
|
priorityFn: () => 0
|
|
2019
2063
|
},
|
|
2020
2064
|
edges: {
|
|
2021
|
-
shapeFactory: () => new
|
|
2065
|
+
shapeFactory: () => new De(),
|
|
2022
2066
|
priorityFn: () => 0
|
|
2023
2067
|
},
|
|
2024
2068
|
ports: {
|
|
@@ -2026,8 +2070,8 @@ const Ve = (r, e) => {
|
|
|
2026
2070
|
}
|
|
2027
2071
|
};
|
|
2028
2072
|
return new ve(
|
|
2029
|
-
o,
|
|
2030
2073
|
s,
|
|
2074
|
+
o,
|
|
2031
2075
|
t,
|
|
2032
2076
|
e,
|
|
2033
2077
|
n,
|
|
@@ -2035,7 +2079,7 @@ const Ve = (r, e) => {
|
|
|
2035
2079
|
);
|
|
2036
2080
|
};
|
|
2037
2081
|
class z {
|
|
2038
|
-
constructor(e, t,
|
|
2082
|
+
constructor(e, t, s, o) {
|
|
2039
2083
|
i(this, "onAfterPortMarked", (e) => {
|
|
2040
2084
|
const t = this.canvas.graph.getPort(e);
|
|
2041
2085
|
this.canvas.graph.getElementPortIds(t.element).length === 1 && this.hookPortEvents(t.element);
|
|
@@ -2047,8 +2091,8 @@ class z {
|
|
|
2047
2091
|
i(this, "onPortMouseDown", (e) => {
|
|
2048
2092
|
if (!this.params.mouseDownEventVerifier(e))
|
|
2049
2093
|
return;
|
|
2050
|
-
const t = e.currentTarget,
|
|
2051
|
-
this.params.onPortPointerDown(
|
|
2094
|
+
const t = e.currentTarget, s = this.canvas.graph.getElementPortIds(t)[0];
|
|
2095
|
+
this.params.onPortPointerDown(s, {
|
|
2052
2096
|
x: e.clientX,
|
|
2053
2097
|
y: e.clientY
|
|
2054
2098
|
}) && (e.stopPropagation(), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
|
|
@@ -2075,8 +2119,8 @@ class z {
|
|
|
2075
2119
|
i(this, "onPortTouchStart", (e) => {
|
|
2076
2120
|
if (e.touches.length !== 1)
|
|
2077
2121
|
return;
|
|
2078
|
-
const t = e.touches[0],
|
|
2079
|
-
this.params.onPortPointerDown(
|
|
2122
|
+
const t = e.touches[0], s = e.currentTarget, o = this.canvas.graph.getElementPortIds(s)[0];
|
|
2123
|
+
this.params.onPortPointerDown(o, {
|
|
2080
2124
|
x: t.clientX,
|
|
2081
2125
|
y: t.clientY
|
|
2082
2126
|
}) && (e.stopPropagation(), this.window.addEventListener("touchmove", this.onWindowTouchMove, {
|
|
@@ -2113,10 +2157,10 @@ class z {
|
|
|
2113
2157
|
i(this, "onBeforeDestroy", () => {
|
|
2114
2158
|
this.params.onStopDrag(), this.removeWindowMouseListeners(), this.removeWindowTouchListeners();
|
|
2115
2159
|
});
|
|
2116
|
-
this.canvas = e, this.element = t, this.window =
|
|
2160
|
+
this.canvas = e, this.element = t, this.window = s, this.params = o, this.canvas.graph.onAfterPortMarked.subscribe(this.onAfterPortMarked), this.canvas.graph.onBeforePortUnmarked.subscribe(this.onBeforePortUnmarked), this.canvas.graph.onBeforeClear.subscribe(this.onBeforeClear), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
|
|
2117
2161
|
}
|
|
2118
|
-
static configure(e, t,
|
|
2119
|
-
new z(e, t,
|
|
2162
|
+
static configure(e, t, s, o) {
|
|
2163
|
+
new z(e, t, s, o);
|
|
2120
2164
|
}
|
|
2121
2165
|
hookPortEvents(e) {
|
|
2122
2166
|
e.addEventListener("mousedown", this.onPortMouseDown, {
|
|
@@ -2141,8 +2185,8 @@ class z {
|
|
|
2141
2185
|
this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
|
|
2142
2186
|
}
|
|
2143
2187
|
}
|
|
2144
|
-
class
|
|
2145
|
-
constructor(e, t,
|
|
2188
|
+
class Z {
|
|
2189
|
+
constructor(e, t, s, o) {
|
|
2146
2190
|
i(this, "grabbedNode", null);
|
|
2147
2191
|
i(this, "maxNodePriority", 0);
|
|
2148
2192
|
i(this, "graph");
|
|
@@ -2174,19 +2218,19 @@ class Q {
|
|
|
2174
2218
|
i(this, "onMouseDown", (e) => {
|
|
2175
2219
|
if (!this.params.mouseDownEventVerifier(e))
|
|
2176
2220
|
return;
|
|
2177
|
-
const t = e.currentTarget,
|
|
2178
|
-
if (!this.params.nodeDragVerifier(
|
|
2221
|
+
const t = e.currentTarget, s = this.graph.findNodeIdByElement(t), o = this.graph.getNode(s);
|
|
2222
|
+
if (!this.params.nodeDragVerifier(s))
|
|
2179
2223
|
return;
|
|
2180
|
-
this.params.onNodeDragStarted(
|
|
2224
|
+
this.params.onNodeDragStarted(s), e.stopPropagation();
|
|
2181
2225
|
const a = this.calculateContentPoint({
|
|
2182
2226
|
x: e.clientX,
|
|
2183
2227
|
y: e.clientY
|
|
2184
2228
|
});
|
|
2185
2229
|
this.grabbedNode = {
|
|
2186
|
-
nodeId:
|
|
2187
|
-
dx: a.x -
|
|
2188
|
-
dy: a.y -
|
|
2189
|
-
}, $(this.element, this.params.dragCursor), this.moveNodeOnTop(
|
|
2230
|
+
nodeId: s,
|
|
2231
|
+
dx: a.x - o.x,
|
|
2232
|
+
dy: a.y - o.y
|
|
2233
|
+
}, $(this.element, this.params.dragCursor), this.moveNodeOnTop(s), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
|
|
2190
2234
|
passive: !0
|
|
2191
2235
|
}), this.window.addEventListener("mouseup", this.onWindowMouseUp, {
|
|
2192
2236
|
passive: !0
|
|
@@ -2196,9 +2240,9 @@ class Q {
|
|
|
2196
2240
|
if (e.touches.length !== 1)
|
|
2197
2241
|
return;
|
|
2198
2242
|
e.stopPropagation();
|
|
2199
|
-
const t = e.touches[0],
|
|
2243
|
+
const t = e.touches[0], s = e.currentTarget, o = this.canvas.graph.findNodeIdByElement(s), n = this.graph.getNode(o);
|
|
2200
2244
|
if (!this.params.nodeDragVerifier({
|
|
2201
|
-
nodeId:
|
|
2245
|
+
nodeId: o,
|
|
2202
2246
|
element: n.element,
|
|
2203
2247
|
x: n.x,
|
|
2204
2248
|
y: n.y
|
|
@@ -2209,10 +2253,10 @@ class Q {
|
|
|
2209
2253
|
y: t.clientY
|
|
2210
2254
|
});
|
|
2211
2255
|
this.grabbedNode = {
|
|
2212
|
-
nodeId:
|
|
2256
|
+
nodeId: o,
|
|
2213
2257
|
dx: h.x - n.x,
|
|
2214
2258
|
dy: h.y - n.y
|
|
2215
|
-
}, this.moveNodeOnTop(
|
|
2259
|
+
}, this.moveNodeOnTop(o), this.window.addEventListener("touchmove", this.onWindowTouchMove, {
|
|
2216
2260
|
passive: !0
|
|
2217
2261
|
}), this.window.addEventListener("touchend", this.onWindowTouchFinish, {
|
|
2218
2262
|
passive: !0
|
|
@@ -2259,17 +2303,17 @@ class Q {
|
|
|
2259
2303
|
i(this, "onWindowTouchFinish", () => {
|
|
2260
2304
|
this.cancelTouchDrag();
|
|
2261
2305
|
});
|
|
2262
|
-
this.canvas = e, this.element = t, this.window =
|
|
2306
|
+
this.canvas = e, this.element = t, this.window = s, this.params = o, this.graph = e.graph, this.graph.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graph.onAfterNodeUpdated.subscribe(this.onAfterNodeUpdated), this.graph.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.graph.onBeforeClear.subscribe(this.onBeforeClear), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
|
|
2263
2307
|
}
|
|
2264
|
-
static configure(e, t,
|
|
2265
|
-
new
|
|
2308
|
+
static configure(e, t, s, o) {
|
|
2309
|
+
new Z(e, t, s, o);
|
|
2266
2310
|
}
|
|
2267
2311
|
moveNode(e, t) {
|
|
2268
2312
|
if (this.graph.getNode(e.nodeId) === null)
|
|
2269
2313
|
return;
|
|
2270
|
-
const
|
|
2271
|
-
x:
|
|
2272
|
-
y:
|
|
2314
|
+
const o = this.calculateContentPoint(t), n = {
|
|
2315
|
+
x: o.x - e.dx,
|
|
2316
|
+
y: o.y - e.dy
|
|
2273
2317
|
}, a = this.adjustNodeCoords(n);
|
|
2274
2318
|
this.canvas.updateNode(e.nodeId, {
|
|
2275
2319
|
x: a.x,
|
|
@@ -2280,8 +2324,8 @@ class Q {
|
|
|
2280
2324
|
if (this.params.moveOnTop) {
|
|
2281
2325
|
if (this.maxNodePriority++, this.params.moveEdgesOnTop) {
|
|
2282
2326
|
const t = this.maxNodePriority;
|
|
2283
|
-
this.maxNodePriority++, this.graph.getNodeAdjacentEdgeIds(e).forEach((
|
|
2284
|
-
this.canvas.updateEdge(
|
|
2327
|
+
this.maxNodePriority++, this.graph.getNodeAdjacentEdgeIds(e).forEach((o) => {
|
|
2328
|
+
this.canvas.updateEdge(o, { priority: t });
|
|
2285
2329
|
});
|
|
2286
2330
|
}
|
|
2287
2331
|
this.canvas.updateNode(e, { priority: this.maxNodePriority });
|
|
@@ -2322,10 +2366,10 @@ class Q {
|
|
|
2322
2366
|
adjustNodeCoords(e) {
|
|
2323
2367
|
const t = this.params.gridSize;
|
|
2324
2368
|
if (t !== null) {
|
|
2325
|
-
const
|
|
2369
|
+
const s = t / 2;
|
|
2326
2370
|
return {
|
|
2327
|
-
x: Math.floor((e.x +
|
|
2328
|
-
y: Math.floor((e.y +
|
|
2371
|
+
x: Math.floor((e.x + s) / t) * t,
|
|
2372
|
+
y: Math.floor((e.y + s) / t) * t
|
|
2329
2373
|
};
|
|
2330
2374
|
}
|
|
2331
2375
|
return e;
|
|
@@ -2335,31 +2379,31 @@ const At = (r, e, t) => ({
|
|
|
2335
2379
|
scale: r.scale,
|
|
2336
2380
|
x: r.x + r.scale * e,
|
|
2337
2381
|
y: r.y + r.scale * t
|
|
2338
|
-
}), Et = (r, e, t,
|
|
2382
|
+
}), Et = (r, e, t, s) => ({
|
|
2339
2383
|
scale: r.scale * e,
|
|
2340
2384
|
x: r.scale * (1 - e) * t + r.x,
|
|
2341
|
-
y: r.scale * (1 - e) *
|
|
2385
|
+
y: r.scale * (1 - e) * s + r.y
|
|
2342
2386
|
}), I = (r) => {
|
|
2343
2387
|
const e = [], t = r.touches.length;
|
|
2344
2388
|
for (let h = 0; h < t; h++)
|
|
2345
2389
|
e.push([r.touches[h].clientX, r.touches[h].clientY]);
|
|
2346
|
-
const
|
|
2390
|
+
const s = e.reduce(
|
|
2347
2391
|
(h, d) => [h[0] + d[0], h[1] + d[1]],
|
|
2348
2392
|
[0, 0]
|
|
2349
|
-
),
|
|
2393
|
+
), o = [s[0] / t, s[1] / t], a = e.map((h) => [h[0] - o[0], h[1] - o[1]]).reduce(
|
|
2350
2394
|
(h, d) => h + Math.sqrt(d[0] * d[0] + d[1] * d[1]),
|
|
2351
2395
|
0
|
|
2352
2396
|
);
|
|
2353
2397
|
return {
|
|
2354
|
-
x:
|
|
2355
|
-
y:
|
|
2398
|
+
x: o[0],
|
|
2399
|
+
y: o[1],
|
|
2356
2400
|
scale: a / t,
|
|
2357
2401
|
touchesCnt: t,
|
|
2358
2402
|
touches: e
|
|
2359
2403
|
};
|
|
2360
2404
|
};
|
|
2361
|
-
class
|
|
2362
|
-
constructor(e, t,
|
|
2405
|
+
class H {
|
|
2406
|
+
constructor(e, t, s, o) {
|
|
2363
2407
|
i(this, "viewport");
|
|
2364
2408
|
i(this, "prevTouches", null);
|
|
2365
2409
|
i(this, "wheelFinishTimer", null);
|
|
@@ -2385,8 +2429,8 @@ class k {
|
|
|
2385
2429
|
this.stopMouseDrag();
|
|
2386
2430
|
return;
|
|
2387
2431
|
}
|
|
2388
|
-
const
|
|
2389
|
-
this.moveViewport(
|
|
2432
|
+
const s = -e.movementX, o = -e.movementY;
|
|
2433
|
+
this.moveViewport(s, o);
|
|
2390
2434
|
});
|
|
2391
2435
|
i(this, "onWindowMouseUp", (e) => {
|
|
2392
2436
|
this.params.mouseUpEventVerifier(e) && this.stopMouseDrag();
|
|
@@ -2394,8 +2438,8 @@ class k {
|
|
|
2394
2438
|
i(this, "onWheelScroll", (e) => {
|
|
2395
2439
|
if (!this.params.mouseWheelEventVerifier(e))
|
|
2396
2440
|
return;
|
|
2397
|
-
const { left: t, top:
|
|
2398
|
-
this.wheelFinishTimer === null && this.params.onTransformStarted(), this.scaleViewport(h,
|
|
2441
|
+
const { left: t, top: s } = this.element.getBoundingClientRect(), o = e.clientX - t, n = e.clientY - s, h = 1 / (e.deltaY < 0 ? this.params.wheelSensitivity : 1 / this.params.wheelSensitivity);
|
|
2442
|
+
this.wheelFinishTimer === null && this.params.onTransformStarted(), this.scaleViewport(h, o, n), this.wheelFinishTimer !== null && clearTimeout(this.wheelFinishTimer), this.wheelFinishTimer = setTimeout(() => {
|
|
2399
2443
|
this.transformInProgress || this.params.onTransformFinished(), this.wheelFinishTimer = null;
|
|
2400
2444
|
}, this.params.scaleWheelFinishTimeout);
|
|
2401
2445
|
});
|
|
@@ -2415,7 +2459,7 @@ class k {
|
|
|
2415
2459
|
i(this, "onWindowTouchMove", (e) => {
|
|
2416
2460
|
const t = I(e);
|
|
2417
2461
|
if (!t.touches.every(
|
|
2418
|
-
(
|
|
2462
|
+
(o) => L(this.window, this.element, o[0], o[1])
|
|
2419
2463
|
)) {
|
|
2420
2464
|
this.stopTouchDrag();
|
|
2421
2465
|
return;
|
|
@@ -2424,7 +2468,7 @@ class k {
|
|
|
2424
2468
|
-(t.x - this.prevTouches.x),
|
|
2425
2469
|
-(t.y - this.prevTouches.y)
|
|
2426
2470
|
), t.touchesCnt === 2) {
|
|
2427
|
-
const { left:
|
|
2471
|
+
const { left: o, top: n } = this.element.getBoundingClientRect(), a = this.prevTouches.x - o, h = this.prevTouches.y - n, c = 1 / (t.scale / this.prevTouches.scale);
|
|
2428
2472
|
this.scaleViewport(c, a, h);
|
|
2429
2473
|
}
|
|
2430
2474
|
this.prevTouches = t;
|
|
@@ -2435,7 +2479,7 @@ class k {
|
|
|
2435
2479
|
i(this, "preventWheelScaleListener", (e) => {
|
|
2436
2480
|
e.preventDefault();
|
|
2437
2481
|
});
|
|
2438
|
-
this.canvas = e, this.element = t, this.window =
|
|
2482
|
+
this.canvas = e, this.element = t, this.window = s, this.params = o, this.element.addEventListener("wheel", this.preventWheelScaleListener, {
|
|
2439
2483
|
passive: !1
|
|
2440
2484
|
}), this.viewport = e.viewport, this.handleResize(), this.viewport.onAfterResize.subscribe(() => {
|
|
2441
2485
|
this.handleResize();
|
|
@@ -2447,21 +2491,21 @@ class k {
|
|
|
2447
2491
|
passive: !0
|
|
2448
2492
|
}), e.onBeforeDestroy.subscribe(this.onBeforeDestroy);
|
|
2449
2493
|
}
|
|
2450
|
-
static configure(e, t,
|
|
2451
|
-
new
|
|
2494
|
+
static configure(e, t, s, o) {
|
|
2495
|
+
new H(e, t, s, o);
|
|
2452
2496
|
}
|
|
2453
2497
|
moveViewport(e, t) {
|
|
2454
|
-
const
|
|
2455
|
-
prevTransform:
|
|
2456
|
-
nextTransform:
|
|
2498
|
+
const s = this.viewport.getViewportMatrix(), o = At(s, e, t), { width: n, height: a } = this.viewport.getDimensions(), h = this.params.transformPreprocessor({
|
|
2499
|
+
prevTransform: s,
|
|
2500
|
+
nextTransform: o,
|
|
2457
2501
|
canvasWidth: n,
|
|
2458
2502
|
canvasHeight: a
|
|
2459
2503
|
});
|
|
2460
2504
|
this.performTransform(h);
|
|
2461
2505
|
}
|
|
2462
|
-
scaleViewport(e, t,
|
|
2463
|
-
const
|
|
2464
|
-
prevTransform:
|
|
2506
|
+
scaleViewport(e, t, s) {
|
|
2507
|
+
const o = this.canvas.viewport.getViewportMatrix(), n = Et(o, e, t, s), { width: a, height: h } = this.viewport.getDimensions(), d = this.params.transformPreprocessor({
|
|
2508
|
+
prevTransform: o,
|
|
2465
2509
|
nextTransform: n,
|
|
2466
2510
|
canvasWidth: a,
|
|
2467
2511
|
canvasHeight: h
|
|
@@ -2490,17 +2534,17 @@ class k {
|
|
|
2490
2534
|
this.transformInProgress = !1, this.params.onTransformFinished();
|
|
2491
2535
|
}
|
|
2492
2536
|
handleResize() {
|
|
2493
|
-
const e = this.viewport.getViewportMatrix(), { width: t, height:
|
|
2537
|
+
const e = this.viewport.getViewportMatrix(), { width: t, height: s } = this.viewport.getDimensions(), o = this.params.transformPreprocessor({
|
|
2494
2538
|
prevTransform: e,
|
|
2495
2539
|
nextTransform: e,
|
|
2496
2540
|
canvasWidth: t,
|
|
2497
|
-
canvasHeight:
|
|
2541
|
+
canvasHeight: s
|
|
2498
2542
|
});
|
|
2499
|
-
this.params.onResizeTransformStarted(), this.canvas.patchViewportMatrix(
|
|
2543
|
+
this.params.onResizeTransformStarted(), this.canvas.patchViewportMatrix(o), this.params.onResizeTransformFinished();
|
|
2500
2544
|
}
|
|
2501
2545
|
}
|
|
2502
|
-
class
|
|
2503
|
-
constructor(e, t,
|
|
2546
|
+
class J {
|
|
2547
|
+
constructor(e, t, s, o, n, a) {
|
|
2504
2548
|
i(this, "nodeHorizontal");
|
|
2505
2549
|
i(this, "nodeVertical");
|
|
2506
2550
|
i(this, "viewport");
|
|
@@ -2523,42 +2567,42 @@ class Z {
|
|
|
2523
2567
|
this.userTransformInProgress || this.loadAreaAroundViewport();
|
|
2524
2568
|
});
|
|
2525
2569
|
i(this, "userTransformInProgress", !1);
|
|
2526
|
-
this.canvas = e, this.element = t, this.window =
|
|
2570
|
+
this.canvas = e, this.element = t, this.window = s, this.trigger = n, this.params = a, this.nodeHorizontal = this.params.nodeVerticalRadius, this.nodeVertical = this.params.nodeHorizontalRadius, this.viewport = e.viewport, this.currentScale = this.viewport.getViewportMatrix().scale, this.scheduleLoadAreaAroundViewport(), this.viewport.onAfterResize.subscribe(() => {
|
|
2527
2571
|
this.scheduleLoadAreaAroundViewport();
|
|
2528
2572
|
});
|
|
2529
2573
|
const h = {
|
|
2530
|
-
...
|
|
2574
|
+
...o,
|
|
2531
2575
|
onResizeTransformStarted: () => {
|
|
2532
|
-
this.userTransformInProgress = !0,
|
|
2576
|
+
this.userTransformInProgress = !0, o.onResizeTransformStarted();
|
|
2533
2577
|
},
|
|
2534
2578
|
onResizeTransformFinished: () => {
|
|
2535
|
-
this.userTransformInProgress = !1,
|
|
2579
|
+
this.userTransformInProgress = !1, o.onResizeTransformFinished();
|
|
2536
2580
|
},
|
|
2537
2581
|
onBeforeTransformChange: () => {
|
|
2538
|
-
this.userTransformInProgress = !0,
|
|
2582
|
+
this.userTransformInProgress = !0, o.onBeforeTransformChange();
|
|
2539
2583
|
},
|
|
2540
2584
|
onTransformChange: () => {
|
|
2541
2585
|
this.userTransformInProgress = !1;
|
|
2542
2586
|
const d = this.currentScale;
|
|
2543
|
-
this.currentScale = this.viewport.getViewportMatrix().scale, d !== this.currentScale && this.scheduleEnsureViewportAreaLoaded(),
|
|
2587
|
+
this.currentScale = this.viewport.getViewportMatrix().scale, d !== this.currentScale && this.scheduleEnsureViewportAreaLoaded(), o.onTransformChange();
|
|
2544
2588
|
},
|
|
2545
2589
|
onTransformFinished: () => {
|
|
2546
|
-
this.scheduleLoadAreaAroundViewport(),
|
|
2590
|
+
this.scheduleLoadAreaAroundViewport(), o.onTransformFinished();
|
|
2547
2591
|
}
|
|
2548
2592
|
};
|
|
2549
|
-
|
|
2593
|
+
H.configure(
|
|
2550
2594
|
e,
|
|
2551
2595
|
this.element,
|
|
2552
2596
|
this.window,
|
|
2553
2597
|
h
|
|
2554
2598
|
), this.trigger.subscribe(this.updateLoadedArea), this.canvas.viewport.onAfterUpdated.subscribe(this.onAfterViewportUpdated);
|
|
2555
2599
|
}
|
|
2556
|
-
static configure(e, t,
|
|
2557
|
-
new
|
|
2600
|
+
static configure(e, t, s, o, n, a) {
|
|
2601
|
+
new J(
|
|
2558
2602
|
e,
|
|
2559
2603
|
t,
|
|
2560
|
-
o,
|
|
2561
2604
|
s,
|
|
2605
|
+
o,
|
|
2562
2606
|
n,
|
|
2563
2607
|
a
|
|
2564
2608
|
);
|
|
@@ -2570,12 +2614,12 @@ class Z {
|
|
|
2570
2614
|
}
|
|
2571
2615
|
scheduleEnsureViewportAreaLoaded() {
|
|
2572
2616
|
setTimeout(() => {
|
|
2573
|
-
const { width: e, height: t } = this.viewport.getDimensions(), { scale:
|
|
2617
|
+
const { width: e, height: t } = this.viewport.getDimensions(), { scale: s, x: o, y: n } = this.viewport.getViewportMatrix(), a = e * s, h = t * s, d = o - this.nodeHorizontal, c = n - this.nodeVertical, g = o + a + this.nodeHorizontal, l = n + h + this.nodeVertical;
|
|
2574
2618
|
this.loadedArea.xFrom < d && this.loadedArea.xTo > g && this.loadedArea.yFrom < c && this.loadedArea.yTo > l || this.loadAreaAroundViewport();
|
|
2575
2619
|
});
|
|
2576
2620
|
}
|
|
2577
2621
|
loadAreaAroundViewport() {
|
|
2578
|
-
const { width: e, height: t } = this.viewport.getDimensions(), { scale:
|
|
2622
|
+
const { width: e, height: t } = this.viewport.getDimensions(), { scale: s, x: o, y: n } = this.viewport.getViewportMatrix(), a = e * s, h = t * s, d = o - a - this.nodeHorizontal, c = n - h - this.nodeVertical, g = 3 * a + 2 * this.nodeHorizontal, l = 3 * h + 2 * this.nodeVertical;
|
|
2579
2623
|
this.trigger.emit({
|
|
2580
2624
|
x: d,
|
|
2581
2625
|
y: c,
|
|
@@ -2597,8 +2641,8 @@ const xt = () => {
|
|
|
2597
2641
|
);
|
|
2598
2642
|
return r.setAttribute("id", "pattern"), r;
|
|
2599
2643
|
};
|
|
2600
|
-
class
|
|
2601
|
-
constructor(e, t,
|
|
2644
|
+
class _ {
|
|
2645
|
+
constructor(e, t, s) {
|
|
2602
2646
|
i(this, "svg", xt());
|
|
2603
2647
|
i(this, "patternRenderingRectangle", St());
|
|
2604
2648
|
i(this, "pattern", bt());
|
|
@@ -2610,19 +2654,19 @@ class J {
|
|
|
2610
2654
|
i(this, "maxViewportScale");
|
|
2611
2655
|
i(this, "visible", !1);
|
|
2612
2656
|
i(this, "onAfterTransformUpdated", () => {
|
|
2613
|
-
const e = this.canvas.viewport.getContentMatrix(), t = e.x - this.halfTileWidth * e.scale,
|
|
2614
|
-
this.pattern.setAttribute("patternTransform",
|
|
2657
|
+
const e = this.canvas.viewport.getContentMatrix(), t = e.x - this.halfTileWidth * e.scale, s = e.y - this.halfTileHeight * e.scale, o = `matrix(${e.scale}, 0, 0, ${e.scale}, ${t}, ${s})`;
|
|
2658
|
+
this.pattern.setAttribute("patternTransform", o), this.updateVisibility();
|
|
2615
2659
|
});
|
|
2616
|
-
this.canvas = e, this.backgroundHost =
|
|
2617
|
-
const
|
|
2618
|
-
this.patternContent.setAttribute("transform",
|
|
2660
|
+
this.canvas = e, this.backgroundHost = s, this.tileWidth = t.tileWidth, this.tileHeight = t.tileHeight, this.halfTileWidth = this.tileWidth / 2, this.halfTileHeight = this.tileHeight / 2, this.patternContent = t.renderer, this.maxViewportScale = t.maxViewportScale;
|
|
2661
|
+
const o = `translate(${this.halfTileWidth}, ${this.halfTileHeight})`;
|
|
2662
|
+
this.patternContent.setAttribute("transform", o), this.pattern.appendChild(this.patternContent);
|
|
2619
2663
|
const n = document.createElementNS("http://www.w3.org/2000/svg", "defs");
|
|
2620
2664
|
n.appendChild(this.pattern), this.svg.appendChild(n), this.svg.appendChild(this.patternRenderingRectangle), this.updateDimensions(), this.canvas.viewport.onAfterResize.subscribe(() => {
|
|
2621
2665
|
this.updateDimensions();
|
|
2622
2666
|
}), this.canvas.viewport.onAfterUpdated.subscribe(this.onAfterTransformUpdated), this.onAfterTransformUpdated();
|
|
2623
2667
|
}
|
|
2624
|
-
static configure(e, t,
|
|
2625
|
-
new
|
|
2668
|
+
static configure(e, t, s) {
|
|
2669
|
+
new _(e, t, s);
|
|
2626
2670
|
}
|
|
2627
2671
|
updateVisibility() {
|
|
2628
2672
|
const t = this.canvas.viewport.getViewportMatrix().scale > this.maxViewportScale;
|
|
@@ -2631,19 +2675,19 @@ class J {
|
|
|
2631
2675
|
updateDimensions() {
|
|
2632
2676
|
const { width: e, height: t } = this.canvas.viewport.getDimensions();
|
|
2633
2677
|
this.svg.setAttribute("width", `${e}`), this.svg.setAttribute("height", `${t}`), this.patternRenderingRectangle.setAttribute("width", `${e}`), this.patternRenderingRectangle.setAttribute("height", `${t}`);
|
|
2634
|
-
const
|
|
2635
|
-
this.pattern.setAttribute("width", `${
|
|
2678
|
+
const s = this.tileWidth / e, o = this.tileHeight / t;
|
|
2679
|
+
this.pattern.setAttribute("width", `${s}`), this.pattern.setAttribute("height", `${o}`);
|
|
2636
2680
|
}
|
|
2637
2681
|
}
|
|
2638
|
-
class
|
|
2639
|
-
constructor(e, t,
|
|
2682
|
+
class ee {
|
|
2683
|
+
constructor(e, t, s, o, n) {
|
|
2640
2684
|
i(this, "overlayCanvas");
|
|
2641
2685
|
i(this, "staticPortId", null);
|
|
2642
2686
|
i(this, "isTargetDragging", !0);
|
|
2643
2687
|
i(this, "onEdgeCreated", (e) => {
|
|
2644
2688
|
this.params.onAfterEdgeCreated(e);
|
|
2645
2689
|
});
|
|
2646
|
-
this.canvas = e, this.overlayLayer = t, this.viewportStore =
|
|
2690
|
+
this.canvas = e, this.overlayLayer = t, this.viewportStore = s, this.window = o, this.params = n, this.overlayCanvas = Ve(
|
|
2647
2691
|
this.overlayLayer,
|
|
2648
2692
|
this.viewportStore
|
|
2649
2693
|
), z.configure(
|
|
@@ -2669,69 +2713,69 @@ class _ {
|
|
|
2669
2713
|
}
|
|
2670
2714
|
);
|
|
2671
2715
|
}
|
|
2672
|
-
static configure(e, t,
|
|
2673
|
-
new
|
|
2716
|
+
static configure(e, t, s, o, n) {
|
|
2717
|
+
new ee(
|
|
2674
2718
|
e,
|
|
2675
2719
|
t,
|
|
2676
|
-
o,
|
|
2677
2720
|
s,
|
|
2721
|
+
o,
|
|
2678
2722
|
n
|
|
2679
2723
|
);
|
|
2680
2724
|
}
|
|
2681
|
-
grabPort(e, t,
|
|
2682
|
-
const
|
|
2725
|
+
grabPort(e, t, s) {
|
|
2726
|
+
const o = this.canvas.graph.getPort(e);
|
|
2683
2727
|
this.staticPortId = e;
|
|
2684
|
-
const n =
|
|
2728
|
+
const n = o.element.getBoundingClientRect(), a = n.x + n.width / 2, h = n.y + n.height / 2, d = this.overlayLayer.getBoundingClientRect(), c = this.canvas.viewport.createContentCoords({
|
|
2685
2729
|
x: a - d.x,
|
|
2686
2730
|
y: h - d.y
|
|
2687
2731
|
}), g = this.canvas.viewport.createContentCoords({
|
|
2688
2732
|
x: t.x - d.x,
|
|
2689
2733
|
y: t.y - d.y
|
|
2690
2734
|
}), l = {
|
|
2691
|
-
overlayNodeId:
|
|
2735
|
+
overlayNodeId: C.StaticNodeId,
|
|
2692
2736
|
portCoords: c,
|
|
2693
|
-
portDirection:
|
|
2737
|
+
portDirection: o.direction
|
|
2694
2738
|
}, u = {
|
|
2695
|
-
overlayNodeId:
|
|
2739
|
+
overlayNodeId: C.DraggingNodeId,
|
|
2696
2740
|
portCoords: g,
|
|
2697
2741
|
portDirection: this.params.dragPortDirection
|
|
2698
2742
|
};
|
|
2699
|
-
this.isTargetDragging =
|
|
2743
|
+
this.isTargetDragging = s === "direct";
|
|
2700
2744
|
const [w, y] = this.isTargetDragging ? [l, u] : [u, l];
|
|
2701
2745
|
this.overlayCanvas.addNode(U(w)), this.overlayCanvas.addNode(U(y)), this.overlayCanvas.addEdge({
|
|
2702
2746
|
from: w.overlayNodeId,
|
|
2703
2747
|
to: y.overlayNodeId,
|
|
2704
|
-
shape: this.params.edgeShapeFactory(
|
|
2748
|
+
shape: this.params.edgeShapeFactory(C.EdgeId)
|
|
2705
2749
|
});
|
|
2706
2750
|
}
|
|
2707
2751
|
resetDragState() {
|
|
2708
2752
|
this.staticPortId = null, this.isTargetDragging = !0, this.overlayCanvas.clear();
|
|
2709
2753
|
}
|
|
2710
2754
|
tryCreateConnection(e) {
|
|
2711
|
-
const t = xe(this.canvas.graph, e),
|
|
2755
|
+
const t = xe(this.canvas.graph, e), s = this.staticPortId;
|
|
2712
2756
|
if (t === null) {
|
|
2713
2757
|
this.params.onEdgeCreationInterrupted({
|
|
2714
|
-
staticPortId:
|
|
2758
|
+
staticPortId: s,
|
|
2715
2759
|
isDirect: this.isTargetDragging
|
|
2716
2760
|
});
|
|
2717
2761
|
return;
|
|
2718
2762
|
}
|
|
2719
|
-
const
|
|
2763
|
+
const o = this.isTargetDragging ? s : t, n = this.isTargetDragging ? t : s, a = { from: o, to: n }, h = this.params.connectionPreprocessor(a);
|
|
2720
2764
|
h !== null ? (this.canvas.graph.onAfterEdgeAdded.subscribe(this.onEdgeCreated), this.canvas.addEdge(h), this.canvas.graph.onAfterEdgeAdded.unsubscribe(this.onEdgeCreated)) : this.params.onEdgeCreationPrevented(a);
|
|
2721
2765
|
}
|
|
2722
2766
|
moveDraggingPort(e) {
|
|
2723
|
-
const t = this.overlayLayer.getBoundingClientRect(),
|
|
2767
|
+
const t = this.overlayLayer.getBoundingClientRect(), s = this.canvas.viewport.createContentCoords({
|
|
2724
2768
|
x: e.x - t.x,
|
|
2725
2769
|
y: e.y - t.y
|
|
2726
2770
|
});
|
|
2727
|
-
this.overlayCanvas.updateNode(
|
|
2728
|
-
x:
|
|
2729
|
-
y:
|
|
2771
|
+
this.overlayCanvas.updateNode(C.DraggingNodeId, {
|
|
2772
|
+
x: s.x,
|
|
2773
|
+
y: s.y
|
|
2730
2774
|
});
|
|
2731
2775
|
}
|
|
2732
2776
|
}
|
|
2733
|
-
class
|
|
2734
|
-
constructor(e, t,
|
|
2777
|
+
class te {
|
|
2778
|
+
constructor(e, t, s, o, n) {
|
|
2735
2779
|
i(this, "overlayCanvas");
|
|
2736
2780
|
i(this, "staticPortId", null);
|
|
2737
2781
|
i(this, "isTargetDragging", !0);
|
|
@@ -2739,7 +2783,7 @@ class ee {
|
|
|
2739
2783
|
i(this, "onEdgeReattached", (e) => {
|
|
2740
2784
|
this.params.onAfterEdgeReattached(e);
|
|
2741
2785
|
});
|
|
2742
|
-
this.canvas = e, this.overlayLayer = t, this.viewportStore =
|
|
2786
|
+
this.canvas = e, this.overlayLayer = t, this.viewportStore = s, this.window = o, this.params = n, this.overlayCanvas = Ve(
|
|
2743
2787
|
this.overlayLayer,
|
|
2744
2788
|
this.viewportStore
|
|
2745
2789
|
), z.configure(
|
|
@@ -2762,23 +2806,23 @@ class ee {
|
|
|
2762
2806
|
}
|
|
2763
2807
|
);
|
|
2764
2808
|
}
|
|
2765
|
-
static configure(e, t,
|
|
2766
|
-
new
|
|
2809
|
+
static configure(e, t, s, o, n) {
|
|
2810
|
+
new te(
|
|
2767
2811
|
e,
|
|
2768
2812
|
t,
|
|
2769
|
-
o,
|
|
2770
2813
|
s,
|
|
2814
|
+
o,
|
|
2771
2815
|
n
|
|
2772
2816
|
);
|
|
2773
2817
|
}
|
|
2774
2818
|
tryStartEdgeDragging(e, t) {
|
|
2775
|
-
const
|
|
2776
|
-
if (o === null)
|
|
2777
|
-
return !1;
|
|
2778
|
-
const s = this.canvas.graph.getEdge(o);
|
|
2819
|
+
const s = this.params.draggingEdgeResolver(e);
|
|
2779
2820
|
if (s === null)
|
|
2780
2821
|
return !1;
|
|
2781
|
-
const
|
|
2822
|
+
const o = this.canvas.graph.getEdge(s);
|
|
2823
|
+
if (o === null)
|
|
2824
|
+
return !1;
|
|
2825
|
+
const n = e === o.from, a = e === o.to, h = n ? o.to : o.from;
|
|
2782
2826
|
this.staticPortId = h, this.isTargetDragging = a;
|
|
2783
2827
|
const d = this.canvas.graph.getPort(e), c = this.canvas.graph.getPort(h), g = c.element.getBoundingClientRect(), l = {
|
|
2784
2828
|
x: g.x + g.width / 2,
|
|
@@ -2791,27 +2835,27 @@ class ee {
|
|
|
2791
2835
|
y: t.y - u.y
|
|
2792
2836
|
});
|
|
2793
2837
|
this.draggingEdgePayload = {
|
|
2794
|
-
id:
|
|
2795
|
-
from:
|
|
2796
|
-
to:
|
|
2797
|
-
shape:
|
|
2798
|
-
priority:
|
|
2799
|
-
}, this.canvas.removeEdge(
|
|
2838
|
+
id: s,
|
|
2839
|
+
from: o.from,
|
|
2840
|
+
to: o.to,
|
|
2841
|
+
shape: o.shape,
|
|
2842
|
+
priority: o.priority
|
|
2843
|
+
}, this.canvas.removeEdge(s);
|
|
2800
2844
|
const A = {
|
|
2801
|
-
overlayNodeId:
|
|
2845
|
+
overlayNodeId: C.StaticNodeId,
|
|
2802
2846
|
portCoords: w,
|
|
2803
2847
|
portDirection: c.direction
|
|
2804
2848
|
}, x = {
|
|
2805
|
-
overlayNodeId:
|
|
2849
|
+
overlayNodeId: C.DraggingNodeId,
|
|
2806
2850
|
portCoords: y,
|
|
2807
2851
|
portDirection: d.direction
|
|
2808
|
-
}, [S,
|
|
2809
|
-
this.overlayCanvas.addNode(U(S)), this.overlayCanvas.addNode(U(
|
|
2810
|
-
const P = this.params.draggingEdgeShapeFactory !== null ? this.params.draggingEdgeShapeFactory(
|
|
2852
|
+
}, [S, T] = this.isTargetDragging ? [A, x] : [x, A];
|
|
2853
|
+
this.overlayCanvas.addNode(U(S)), this.overlayCanvas.addNode(U(T));
|
|
2854
|
+
const P = this.params.draggingEdgeShapeFactory !== null ? this.params.draggingEdgeShapeFactory(C.EdgeId) : o.shape;
|
|
2811
2855
|
return this.overlayCanvas.addEdge({
|
|
2812
|
-
id:
|
|
2856
|
+
id: C.EdgeId,
|
|
2813
2857
|
from: S.overlayNodeId,
|
|
2814
|
-
to:
|
|
2858
|
+
to: T.overlayNodeId,
|
|
2815
2859
|
shape: P
|
|
2816
2860
|
}), !0;
|
|
2817
2861
|
}
|
|
@@ -2819,18 +2863,18 @@ class ee {
|
|
|
2819
2863
|
this.draggingEdgePayload = null, this.staticPortId = null, this.isTargetDragging = !0, this.overlayCanvas.clear();
|
|
2820
2864
|
}
|
|
2821
2865
|
moveDraggingPort(e) {
|
|
2822
|
-
const t = this.overlayLayer.getBoundingClientRect(),
|
|
2866
|
+
const t = this.overlayLayer.getBoundingClientRect(), s = {
|
|
2823
2867
|
x: e.x - t.x,
|
|
2824
2868
|
y: e.y - t.y
|
|
2825
|
-
},
|
|
2826
|
-
this.overlayCanvas.updateNode(
|
|
2827
|
-
x:
|
|
2828
|
-
y:
|
|
2869
|
+
}, o = this.canvas.viewport.createContentCoords(s);
|
|
2870
|
+
this.overlayCanvas.updateNode(C.DraggingNodeId, {
|
|
2871
|
+
x: o.x,
|
|
2872
|
+
y: o.y
|
|
2829
2873
|
});
|
|
2830
2874
|
}
|
|
2831
2875
|
tryCreateConnection(e) {
|
|
2832
2876
|
const t = xe(this.canvas.graph, e);
|
|
2833
|
-
if (this.overlayCanvas.removeEdge(
|
|
2877
|
+
if (this.overlayCanvas.removeEdge(C.EdgeId), t === null) {
|
|
2834
2878
|
const d = this.draggingEdgePayload;
|
|
2835
2879
|
this.params.onEdgeReattachInterrupted({
|
|
2836
2880
|
id: d.id,
|
|
@@ -2841,10 +2885,10 @@ class ee {
|
|
|
2841
2885
|
});
|
|
2842
2886
|
return;
|
|
2843
2887
|
}
|
|
2844
|
-
const [
|
|
2888
|
+
const [s, o] = this.isTargetDragging ? [this.staticPortId, t] : [t, this.staticPortId], n = this.draggingEdgePayload, a = {
|
|
2845
2889
|
id: n.id,
|
|
2846
|
-
from:
|
|
2847
|
-
to:
|
|
2890
|
+
from: s,
|
|
2891
|
+
to: o,
|
|
2848
2892
|
shape: n.shape,
|
|
2849
2893
|
priority: n.priority
|
|
2850
2894
|
}, h = this.params.connectionPreprocessor(a);
|
|
@@ -2862,32 +2906,40 @@ class ee {
|
|
|
2862
2906
|
}
|
|
2863
2907
|
}
|
|
2864
2908
|
}
|
|
2865
|
-
class
|
|
2866
|
-
constructor(e, t,
|
|
2867
|
-
this.canvas = e, this.layoutAlgorithm = t, this.trigger =
|
|
2909
|
+
class re {
|
|
2910
|
+
constructor(e, t, s) {
|
|
2911
|
+
this.canvas = e, this.layoutAlgorithm = t, this.trigger = s, this.trigger.subscribe(() => {
|
|
2868
2912
|
this.applyLayout();
|
|
2869
2913
|
});
|
|
2870
2914
|
}
|
|
2871
|
-
static configure(e, t,
|
|
2872
|
-
new
|
|
2915
|
+
static configure(e, t, s) {
|
|
2916
|
+
new re(
|
|
2873
2917
|
e,
|
|
2874
2918
|
t,
|
|
2875
|
-
|
|
2919
|
+
s
|
|
2876
2920
|
);
|
|
2877
2921
|
}
|
|
2878
2922
|
applyLayout() {
|
|
2879
2923
|
this.layoutAlgorithm.calculateCoordinates(
|
|
2880
2924
|
this.canvas.graph,
|
|
2881
2925
|
this.canvas.viewport
|
|
2882
|
-
).forEach((t,
|
|
2883
|
-
this.canvas.updateNode(
|
|
2926
|
+
).forEach((t, s) => {
|
|
2927
|
+
this.canvas.updateNode(s, t);
|
|
2884
2928
|
});
|
|
2885
2929
|
}
|
|
2886
2930
|
}
|
|
2887
|
-
class
|
|
2888
|
-
constructor(e, t) {
|
|
2931
|
+
class O {
|
|
2932
|
+
constructor(e, t, s) {
|
|
2889
2933
|
i(this, "applyScheduled", !1);
|
|
2890
|
-
this
|
|
2934
|
+
i(this, "apply", () => {
|
|
2935
|
+
this.applyScheduled = !1, this.layoutAlgorithm.calculateCoordinates(
|
|
2936
|
+
this.canvas.graph,
|
|
2937
|
+
this.canvas.viewport
|
|
2938
|
+
).forEach((t, s) => {
|
|
2939
|
+
this.canvas.updateNode(s, t);
|
|
2940
|
+
});
|
|
2941
|
+
});
|
|
2942
|
+
this.canvas = e, this.layoutAlgorithm = t, this.defererFn = s, this.canvas.graph.onAfterNodeAdded.subscribe(() => {
|
|
2891
2943
|
this.scheduleApply();
|
|
2892
2944
|
}), this.canvas.graph.onBeforeNodeRemoved.subscribe(() => {
|
|
2893
2945
|
this.scheduleApply();
|
|
@@ -2897,49 +2949,57 @@ class re {
|
|
|
2897
2949
|
this.scheduleApply();
|
|
2898
2950
|
});
|
|
2899
2951
|
}
|
|
2900
|
-
static configure(e, t) {
|
|
2901
|
-
new
|
|
2952
|
+
static configure(e, t, s) {
|
|
2953
|
+
new O(
|
|
2902
2954
|
e,
|
|
2903
|
-
t
|
|
2955
|
+
t,
|
|
2956
|
+
s
|
|
2904
2957
|
);
|
|
2905
2958
|
}
|
|
2906
2959
|
scheduleApply() {
|
|
2907
|
-
this.applyScheduled || (this.applyScheduled = !0,
|
|
2908
|
-
this.applyScheduled = !1, this.applyLayout();
|
|
2909
|
-
}));
|
|
2910
|
-
}
|
|
2911
|
-
applyLayout() {
|
|
2912
|
-
this.layoutAlgorithm.calculateCoordinates(
|
|
2913
|
-
this.canvas.graph,
|
|
2914
|
-
this.canvas.viewport
|
|
2915
|
-
).forEach((t, o) => {
|
|
2916
|
-
this.canvas.updateNode(o, t);
|
|
2917
|
-
});
|
|
2960
|
+
this.applyScheduled || (this.applyScheduled = !0, this.defererFn(this.apply));
|
|
2918
2961
|
}
|
|
2919
2962
|
}
|
|
2920
2963
|
class Pt {
|
|
2921
2964
|
static configure(e, t) {
|
|
2922
|
-
const
|
|
2923
|
-
switch (
|
|
2965
|
+
const s = t.applyOn;
|
|
2966
|
+
switch (s.type) {
|
|
2924
2967
|
case "manual": {
|
|
2925
|
-
|
|
2968
|
+
re.configure(
|
|
2926
2969
|
e,
|
|
2927
2970
|
t.algorithm,
|
|
2928
|
-
|
|
2971
|
+
s.trigger
|
|
2929
2972
|
);
|
|
2930
2973
|
break;
|
|
2931
2974
|
}
|
|
2932
|
-
case "
|
|
2933
|
-
|
|
2975
|
+
case "topologyChangeMacrotask": {
|
|
2976
|
+
O.configure(
|
|
2977
|
+
e,
|
|
2978
|
+
t.algorithm,
|
|
2979
|
+
(o) => {
|
|
2980
|
+
setTimeout(() => {
|
|
2981
|
+
o();
|
|
2982
|
+
});
|
|
2983
|
+
}
|
|
2984
|
+
);
|
|
2985
|
+
break;
|
|
2986
|
+
}
|
|
2987
|
+
case "topologyChangeMicrotask": {
|
|
2988
|
+
O.configure(
|
|
2934
2989
|
e,
|
|
2935
|
-
t.algorithm
|
|
2990
|
+
t.algorithm,
|
|
2991
|
+
(o) => {
|
|
2992
|
+
queueMicrotask(() => {
|
|
2993
|
+
o();
|
|
2994
|
+
});
|
|
2995
|
+
}
|
|
2936
2996
|
);
|
|
2937
2997
|
break;
|
|
2938
2998
|
}
|
|
2939
2999
|
}
|
|
2940
3000
|
}
|
|
2941
3001
|
}
|
|
2942
|
-
class
|
|
3002
|
+
class Ct {
|
|
2943
3003
|
constructor(e, t) {
|
|
2944
3004
|
i(this, "previousTimeStamp");
|
|
2945
3005
|
i(this, "step", (e) => {
|
|
@@ -2954,57 +3014,57 @@ class Tt {
|
|
|
2954
3014
|
this.win = e, this.callback = t, this.win.requestAnimationFrame(this.step);
|
|
2955
3015
|
}
|
|
2956
3016
|
}
|
|
2957
|
-
class
|
|
2958
|
-
constructor(e, t,
|
|
3017
|
+
class se {
|
|
3018
|
+
constructor(e, t, s, o) {
|
|
2959
3019
|
i(this, "step", (e) => {
|
|
2960
3020
|
this.algorithm.calculateNextCoordinates(
|
|
2961
3021
|
this.canvas.graph,
|
|
2962
3022
|
e,
|
|
2963
3023
|
this.canvas.viewport
|
|
2964
|
-
).forEach((
|
|
2965
|
-
this.staticNodes.has(
|
|
3024
|
+
).forEach((s, o) => {
|
|
3025
|
+
this.staticNodes.has(o) || this.canvas.updateNode(o, { x: s.x, y: s.y });
|
|
2966
3026
|
});
|
|
2967
3027
|
});
|
|
2968
|
-
this.canvas = e, this.algorithm = t, this.staticNodes =
|
|
3028
|
+
this.canvas = e, this.algorithm = t, this.staticNodes = s, this.win = o, new Ct(this.win, this.step);
|
|
2969
3029
|
}
|
|
2970
|
-
static configure(e, t,
|
|
2971
|
-
new
|
|
3030
|
+
static configure(e, t, s, o) {
|
|
3031
|
+
new se(e, t, s, o);
|
|
2972
3032
|
}
|
|
2973
3033
|
}
|
|
2974
|
-
const
|
|
3034
|
+
const Tt = () => {
|
|
2975
3035
|
const r = document.createElement("div");
|
|
2976
3036
|
return r.style.width = "100%", r.style.height = "100%", r.style.position = "relative", r;
|
|
2977
|
-
},
|
|
3037
|
+
}, Y = () => {
|
|
2978
3038
|
const r = document.createElement("div");
|
|
2979
3039
|
return r.style.position = "absolute", r.style.inset = "0", r;
|
|
2980
3040
|
}, pe = () => {
|
|
2981
|
-
const r =
|
|
3041
|
+
const r = Y();
|
|
2982
3042
|
return r.style.pointerEvents = "none", r;
|
|
2983
3043
|
};
|
|
2984
|
-
class
|
|
3044
|
+
class Nt {
|
|
2985
3045
|
constructor(e) {
|
|
2986
|
-
i(this, "background",
|
|
2987
|
-
i(this, "main",
|
|
3046
|
+
i(this, "background", Y());
|
|
3047
|
+
i(this, "main", Y());
|
|
2988
3048
|
i(this, "overlayConnectablePorts", pe());
|
|
2989
3049
|
i(this, "overlayDraggableEdges", pe());
|
|
2990
|
-
i(this, "host",
|
|
3050
|
+
i(this, "host", Tt());
|
|
2991
3051
|
this.element = e, this.element.appendChild(this.host), this.host.appendChild(this.background), this.host.appendChild(this.main), this.host.appendChild(this.overlayConnectablePorts), this.host.appendChild(this.overlayDraggableEdges);
|
|
2992
3052
|
}
|
|
2993
3053
|
destroy() {
|
|
2994
3054
|
this.host.removeChild(this.background), this.host.removeChild(this.main), this.host.removeChild(this.overlayConnectablePorts), this.host.removeChild(this.overlayDraggableEdges), this.element.removeChild(this.host);
|
|
2995
3055
|
}
|
|
2996
3056
|
}
|
|
2997
|
-
const
|
|
3057
|
+
const G = (r) => () => r, we = G(0), Dt = () => {
|
|
2998
3058
|
let r = 0;
|
|
2999
3059
|
return () => r++;
|
|
3000
3060
|
}, Mt = (r, e) => {
|
|
3001
|
-
let t = we,
|
|
3002
|
-
const
|
|
3003
|
-
return r === "incremental" && (t =
|
|
3061
|
+
let t = we, s = we;
|
|
3062
|
+
const o = Dt();
|
|
3063
|
+
return r === "incremental" && (t = o), e === "incremental" && (s = o), typeof r == "number" && (t = G(r)), typeof e == "number" && (s = G(e)), typeof r == "function" && (t = r), typeof e == "function" && (s = e), {
|
|
3004
3064
|
nodesPriorityFn: t,
|
|
3005
|
-
edgesPriorityFn:
|
|
3065
|
+
edgesPriorityFn: s
|
|
3006
3066
|
};
|
|
3007
|
-
},
|
|
3067
|
+
}, oe = (r) => {
|
|
3008
3068
|
if (typeof r == "function")
|
|
3009
3069
|
return r;
|
|
3010
3070
|
switch (r.type) {
|
|
@@ -3049,7 +3109,7 @@ const Y = (r) => () => r, we = Y(0), Nt = () => {
|
|
|
3049
3109
|
detourDistance: r.detourDistance
|
|
3050
3110
|
});
|
|
3051
3111
|
case "direct":
|
|
3052
|
-
return () => new
|
|
3112
|
+
return () => new De({
|
|
3053
3113
|
color: r.color,
|
|
3054
3114
|
width: r.width,
|
|
3055
3115
|
arrowLength: r.arrowLength,
|
|
@@ -3075,30 +3135,30 @@ const Y = (r) => () => r, we = Y(0), Nt = () => {
|
|
|
3075
3135
|
});
|
|
3076
3136
|
}
|
|
3077
3137
|
}, Lt = (r) => {
|
|
3078
|
-
var t,
|
|
3138
|
+
var t, s, o, n, a;
|
|
3079
3139
|
const e = Mt(
|
|
3080
3140
|
(t = r.nodes) == null ? void 0 : t.priority,
|
|
3081
|
-
(
|
|
3141
|
+
(s = r.edges) == null ? void 0 : s.priority
|
|
3082
3142
|
);
|
|
3083
3143
|
return {
|
|
3084
3144
|
nodes: {
|
|
3085
|
-
centerFn: ((
|
|
3145
|
+
centerFn: ((o = r.nodes) == null ? void 0 : o.centerFn) ?? Se,
|
|
3086
3146
|
priorityFn: e.nodesPriorityFn
|
|
3087
3147
|
},
|
|
3088
3148
|
ports: {
|
|
3089
3149
|
direction: ((n = r.ports) == null ? void 0 : n.direction) ?? 0
|
|
3090
3150
|
},
|
|
3091
3151
|
edges: {
|
|
3092
|
-
shapeFactory:
|
|
3152
|
+
shapeFactory: oe(((a = r.edges) == null ? void 0 : a.shape) ?? {}),
|
|
3093
3153
|
priorityFn: e.edgesPriorityFn
|
|
3094
3154
|
}
|
|
3095
3155
|
};
|
|
3096
3156
|
}, Rt = (r) => {
|
|
3097
|
-
var w, y, A, x, S,
|
|
3157
|
+
var w, y, A, x, S, T;
|
|
3098
3158
|
const e = ((w = r.events) == null ? void 0 : w.onNodeDragStarted) ?? (() => {
|
|
3099
3159
|
}), t = ((y = r.events) == null ? void 0 : y.onNodeDrag) ?? (() => {
|
|
3100
|
-
}),
|
|
3101
|
-
}), n = r.moveOnTop !== !1, a = r.moveEdgesOnTop !== !1 && n, h = (x = r.mouse) == null ? void 0 : x.dragCursor, d = h !== void 0 ? h : "grab", c = (S = r.mouse) == null ? void 0 : S.mouseDownEventVerifier, g = c !== void 0 ? c : (P) => P.button === 0, l = (
|
|
3160
|
+
}), s = r.nodeDragVerifier ?? (() => !0), o = ((A = r.events) == null ? void 0 : A.onNodeDragFinished) ?? (() => {
|
|
3161
|
+
}), n = r.moveOnTop !== !1, a = r.moveEdgesOnTop !== !1 && n, h = (x = r.mouse) == null ? void 0 : x.dragCursor, d = h !== void 0 ? h : "grab", c = (S = r.mouse) == null ? void 0 : S.mouseDownEventVerifier, g = c !== void 0 ? c : (P) => P.button === 0, l = (T = r.mouse) == null ? void 0 : T.mouseUpEventVerifier, u = l !== void 0 ? l : (P) => P.button === 0;
|
|
3102
3162
|
return {
|
|
3103
3163
|
moveOnTop: n,
|
|
3104
3164
|
moveEdgesOnTop: a,
|
|
@@ -3108,31 +3168,31 @@ const Y = (r) => () => r, we = Y(0), Nt = () => {
|
|
|
3108
3168
|
mouseUpEventVerifier: u,
|
|
3109
3169
|
onNodeDragStarted: e,
|
|
3110
3170
|
onNodeDrag: t,
|
|
3111
|
-
nodeDragVerifier:
|
|
3112
|
-
onNodeDragFinished:
|
|
3171
|
+
nodeDragVerifier: s,
|
|
3172
|
+
onNodeDragFinished: o
|
|
3113
3173
|
};
|
|
3114
3174
|
}, Vt = (r) => {
|
|
3115
|
-
const e = r.minX !== null ? r.minX : -1 / 0, t = r.maxX !== null ? r.maxX : 1 / 0,
|
|
3175
|
+
const e = r.minX !== null ? r.minX : -1 / 0, t = r.maxX !== null ? r.maxX : 1 / 0, s = r.minY !== null ? r.minY : -1 / 0, o = r.maxY !== null ? r.maxY : 1 / 0;
|
|
3116
3176
|
return (n) => {
|
|
3117
3177
|
let a = n.nextTransform.x, h = n.nextTransform.y;
|
|
3118
3178
|
a < e && a < n.prevTransform.x && (a = Math.min(n.prevTransform.x, e));
|
|
3119
3179
|
const d = n.canvasWidth * n.prevTransform.scale, c = t - d;
|
|
3120
|
-
a > c && a > n.prevTransform.x && (a = Math.max(n.prevTransform.x, c)), h <
|
|
3121
|
-
const g = n.canvasHeight * n.prevTransform.scale, l =
|
|
3180
|
+
a > c && a > n.prevTransform.x && (a = Math.max(n.prevTransform.x, c)), h < s && h < n.prevTransform.y && (h = Math.min(n.prevTransform.y, s));
|
|
3181
|
+
const g = n.canvasHeight * n.prevTransform.scale, l = o - g;
|
|
3122
3182
|
return h > l && h > n.prevTransform.y && (h = Math.max(n.prevTransform.y, l)), { scale: n.nextTransform.scale, x: a, y: h };
|
|
3123
3183
|
};
|
|
3124
3184
|
}, Ft = (r) => {
|
|
3125
|
-
const e = r.maxContentScale, t = r.minContentScale,
|
|
3185
|
+
const e = r.maxContentScale, t = r.minContentScale, s = e !== null ? 1 / e : 0, o = t !== null ? 1 / t : 1 / 0;
|
|
3126
3186
|
return (n) => {
|
|
3127
3187
|
const a = n.prevTransform, h = n.nextTransform;
|
|
3128
3188
|
let d = h.scale, c = h.x, g = h.y;
|
|
3129
|
-
if (h.scale >
|
|
3130
|
-
d = Math.max(a.scale,
|
|
3189
|
+
if (h.scale > o && h.scale > a.scale) {
|
|
3190
|
+
d = Math.max(a.scale, o), c = a.x, g = a.y;
|
|
3131
3191
|
const l = (d - a.scale) / (h.scale - a.scale);
|
|
3132
3192
|
c = a.x + (h.x - a.x) * l, g = a.y + (h.y - a.y) * l;
|
|
3133
3193
|
}
|
|
3134
|
-
if (h.scale <
|
|
3135
|
-
d = Math.min(a.scale,
|
|
3194
|
+
if (h.scale < s && h.scale < a.scale) {
|
|
3195
|
+
d = Math.min(a.scale, s), c = a.x, g = a.y;
|
|
3136
3196
|
const l = (d - a.scale) / (h.scale - a.scale);
|
|
3137
3197
|
c = a.x + (h.x - a.x) * l, g = a.y + (h.y - a.y) * l;
|
|
3138
3198
|
}
|
|
@@ -3143,7 +3203,7 @@ const Y = (r) => () => r, we = Y(0), Nt = () => {
|
|
|
3143
3203
|
};
|
|
3144
3204
|
};
|
|
3145
3205
|
}, It = (r) => (e) => r.reduce(
|
|
3146
|
-
(t,
|
|
3206
|
+
(t, s) => s({
|
|
3147
3207
|
prevTransform: e.prevTransform,
|
|
3148
3208
|
nextTransform: t,
|
|
3149
3209
|
canvasWidth: e.canvasWidth,
|
|
@@ -3168,17 +3228,17 @@ const Y = (r) => () => r, we = Y(0), Nt = () => {
|
|
|
3168
3228
|
});
|
|
3169
3229
|
}
|
|
3170
3230
|
}, ye = (r) => {
|
|
3171
|
-
var y, A, x, S,
|
|
3172
|
-
const e = (y = r == null ? void 0 : r.scale) == null ? void 0 : y.mouseWheelSensitivity, t = e !== void 0 ? e : 1.2,
|
|
3173
|
-
let
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
(
|
|
3231
|
+
var y, A, x, S, T, P, R, V, ie, ne, ae, he;
|
|
3232
|
+
const e = (y = r == null ? void 0 : r.scale) == null ? void 0 : y.mouseWheelSensitivity, t = e !== void 0 ? e : 1.2, s = r == null ? void 0 : r.transformPreprocessor;
|
|
3233
|
+
let o;
|
|
3234
|
+
s !== void 0 ? Array.isArray(s) ? o = It(
|
|
3235
|
+
s.map(
|
|
3236
|
+
(N) => fe(N)
|
|
3177
3237
|
)
|
|
3178
|
-
) :
|
|
3238
|
+
) : o = fe(s) : o = (N) => N.nextTransform;
|
|
3179
3239
|
const n = ((A = r == null ? void 0 : r.shift) == null ? void 0 : A.cursor) !== void 0 ? r.shift.cursor : "grab", a = ((x = r == null ? void 0 : r.events) == null ? void 0 : x.onBeforeTransformChange) ?? (() => {
|
|
3180
3240
|
}), h = ((S = r == null ? void 0 : r.events) == null ? void 0 : S.onTransformChange) ?? (() => {
|
|
3181
|
-
}), d = (
|
|
3241
|
+
}), d = (T = r == null ? void 0 : r.shift) == null ? void 0 : T.mouseDownEventVerifier, c = d !== void 0 ? d : (N) => N.button === 0, g = (P = r == null ? void 0 : r.shift) == null ? void 0 : P.mouseUpEventVerifier, l = g !== void 0 ? g : (N) => N.button === 0, u = (R = r == null ? void 0 : r.scale) == null ? void 0 : R.mouseWheelEventVerifier, w = u !== void 0 ? u : () => !0;
|
|
3182
3242
|
return {
|
|
3183
3243
|
wheelSensitivity: t,
|
|
3184
3244
|
onTransformStarted: ((V = r == null ? void 0 : r.events) == null ? void 0 : V.onTransformStarted) ?? (() => {
|
|
@@ -3187,7 +3247,7 @@ const Y = (r) => () => r, we = Y(0), Nt = () => {
|
|
|
3187
3247
|
}),
|
|
3188
3248
|
onBeforeTransformChange: a,
|
|
3189
3249
|
onTransformChange: h,
|
|
3190
|
-
transformPreprocessor:
|
|
3250
|
+
transformPreprocessor: o,
|
|
3191
3251
|
shiftCursor: n,
|
|
3192
3252
|
mouseDownEventVerifier: c,
|
|
3193
3253
|
mouseUpEventVerifier: l,
|
|
@@ -3208,33 +3268,33 @@ const Y = (r) => () => r, we = Y(0), Nt = () => {
|
|
|
3208
3268
|
(r == null ? void 0 : r.radius) ?? 1.5,
|
|
3209
3269
|
(r == null ? void 0 : r.color) ?? "#d8d8d8"
|
|
3210
3270
|
), Bt = (r) => {
|
|
3211
|
-
const e = r.tileDimensions, t = (e == null ? void 0 : e.width) ?? 25,
|
|
3271
|
+
const e = r.tileDimensions, t = (e == null ? void 0 : e.width) ?? 25, s = (e == null ? void 0 : e.height) ?? 25, o = Ut(r.renderer ?? {});
|
|
3212
3272
|
return {
|
|
3213
3273
|
tileWidth: t,
|
|
3214
|
-
tileHeight:
|
|
3215
|
-
renderer:
|
|
3274
|
+
tileHeight: s,
|
|
3275
|
+
renderer: o,
|
|
3216
3276
|
maxViewportScale: r.maxViewportScale ?? 10
|
|
3217
3277
|
};
|
|
3218
3278
|
}, Ot = (r, e, t) => {
|
|
3219
3279
|
var c, g, l;
|
|
3220
|
-
const
|
|
3280
|
+
const s = () => "direct", o = (u) => u, n = (u) => u.button === 0, a = () => {
|
|
3221
3281
|
}, h = () => {
|
|
3222
3282
|
}, d = () => {
|
|
3223
3283
|
};
|
|
3224
3284
|
return {
|
|
3225
|
-
connectionTypeResolver: r.connectionTypeResolver ??
|
|
3226
|
-
connectionPreprocessor: r.connectionPreprocessor ??
|
|
3285
|
+
connectionTypeResolver: r.connectionTypeResolver ?? s,
|
|
3286
|
+
connectionPreprocessor: r.connectionPreprocessor ?? o,
|
|
3227
3287
|
mouseDownEventVerifier: r.mouseDownEventVerifier ?? n,
|
|
3228
3288
|
mouseUpEventVerifier: r.mouseUpEventVerifier ?? n,
|
|
3229
3289
|
onAfterEdgeCreated: ((c = r.events) == null ? void 0 : c.onAfterEdgeCreated) ?? a,
|
|
3230
3290
|
onEdgeCreationInterrupted: ((g = r.events) == null ? void 0 : g.onEdgeCreationInterrupted) ?? d,
|
|
3231
3291
|
onEdgeCreationPrevented: ((l = r.events) == null ? void 0 : l.onEdgeCreationPrevented) ?? h,
|
|
3232
3292
|
dragPortDirection: r.dragPortDirection ?? t,
|
|
3233
|
-
edgeShapeFactory: r.edgeShape !== void 0 ?
|
|
3293
|
+
edgeShapeFactory: r.edgeShape !== void 0 ? oe(r.edgeShape) : e
|
|
3234
3294
|
};
|
|
3235
3295
|
}, Wt = (r, e) => {
|
|
3236
3296
|
var c, g, l;
|
|
3237
|
-
const t = (u) => u,
|
|
3297
|
+
const t = (u) => u, s = (u) => u.button === 0 && u.ctrlKey, o = (u) => u.button === 0, n = (u) => {
|
|
3238
3298
|
const w = e.getPortAdjacentEdgeIds(u);
|
|
3239
3299
|
return w.length > 0 ? w[w.length - 1] : null;
|
|
3240
3300
|
}, a = () => {
|
|
@@ -3243,18 +3303,18 @@ const Y = (r) => () => r, we = Y(0), Nt = () => {
|
|
|
3243
3303
|
};
|
|
3244
3304
|
return {
|
|
3245
3305
|
connectionPreprocessor: r.connectionPreprocessor ?? t,
|
|
3246
|
-
mouseDownEventVerifier: r.mouseDownEventVerifier ??
|
|
3247
|
-
mouseUpEventVerifier: r.mouseUpEventVerifier ??
|
|
3306
|
+
mouseDownEventVerifier: r.mouseDownEventVerifier ?? s,
|
|
3307
|
+
mouseUpEventVerifier: r.mouseUpEventVerifier ?? o,
|
|
3248
3308
|
draggingEdgeResolver: r.draggingEdgeResolver ?? n,
|
|
3249
|
-
draggingEdgeShapeFactory: r.draggingEdgeShape !== void 0 ?
|
|
3309
|
+
draggingEdgeShapeFactory: r.draggingEdgeShape !== void 0 ? oe(r.draggingEdgeShape) : null,
|
|
3250
3310
|
onAfterEdgeReattached: ((c = r.events) == null ? void 0 : c.onAfterEdgeReattached) ?? a,
|
|
3251
3311
|
onEdgeReattachInterrupted: ((g = r.events) == null ? void 0 : g.onEdgeReattachInterrupted) ?? d,
|
|
3252
3312
|
onEdgeReattachPrevented: ((l = r.events) == null ? void 0 : l.onEdgeReattachPrevented) ?? h
|
|
3253
3313
|
};
|
|
3254
|
-
},
|
|
3314
|
+
}, kt = (r) => ({
|
|
3255
3315
|
nodeVerticalRadius: r.nodeContainingRadius.vertical,
|
|
3256
3316
|
nodeHorizontalRadius: r.nodeContainingRadius.horizontal
|
|
3257
|
-
}),
|
|
3317
|
+
}), zt = (r) => {
|
|
3258
3318
|
var e, t;
|
|
3259
3319
|
return {
|
|
3260
3320
|
onAfterNodeDetached: ((e = r == null ? void 0 : r.events) == null ? void 0 : e.onAfterNodeDetached) ?? (() => {
|
|
@@ -3270,22 +3330,22 @@ class Ht extends Error {
|
|
|
3270
3330
|
}
|
|
3271
3331
|
}
|
|
3272
3332
|
class Fe {
|
|
3273
|
-
constructor(e, t,
|
|
3333
|
+
constructor(e, t, s) {
|
|
3274
3334
|
i(this, "dt");
|
|
3275
3335
|
i(this, "nodeMass");
|
|
3276
3336
|
i(this, "edgeEquilibriumLength");
|
|
3277
3337
|
i(this, "edgeStiffness");
|
|
3278
3338
|
i(this, "nodeForcesApplicationStrategy");
|
|
3279
3339
|
i(this, "distanceVectorGenerator");
|
|
3280
|
-
this.graph = e, this.currentCoords = t, this.dt =
|
|
3340
|
+
this.graph = e, this.currentCoords = t, this.dt = s.dtSec, this.nodeMass = s.nodeMass, this.edgeEquilibriumLength = s.edgeEquilibriumLength, this.edgeStiffness = s.edgeStiffness, this.distanceVectorGenerator = s.distanceVectorGenerator, this.nodeForcesApplicationStrategy = s.nodeForcesApplicationStrategy;
|
|
3281
3341
|
}
|
|
3282
3342
|
apply() {
|
|
3283
3343
|
let e = 0, t = 0;
|
|
3284
|
-
const
|
|
3344
|
+
const s = /* @__PURE__ */ new Map();
|
|
3285
3345
|
return this.graph.getAllNodeIds().forEach((n) => {
|
|
3286
|
-
|
|
3287
|
-
}), this.nodeForcesApplicationStrategy.apply(this.currentCoords,
|
|
3288
|
-
const h =
|
|
3346
|
+
s.set(n, { x: 0, y: 0 });
|
|
3347
|
+
}), this.nodeForcesApplicationStrategy.apply(this.currentCoords, s), this.applyEdgeForces(s), this.currentCoords.forEach((n, a) => {
|
|
3348
|
+
const h = s.get(a), d = {
|
|
3289
3349
|
x: h.x / this.nodeMass * this.dt,
|
|
3290
3350
|
y: h.y / this.nodeMass * this.dt
|
|
3291
3351
|
};
|
|
@@ -3299,10 +3359,10 @@ class Fe {
|
|
|
3299
3359
|
}
|
|
3300
3360
|
applyEdgeForces(e) {
|
|
3301
3361
|
this.graph.getAllEdgeIds().forEach((t) => {
|
|
3302
|
-
const
|
|
3362
|
+
const s = this.graph.getEdge(t), o = this.graph.getPort(s.from), n = this.graph.getPort(s.to), a = this.currentCoords.get(o.nodeId), h = this.currentCoords.get(n.nodeId), d = this.distanceVectorGenerator.create(
|
|
3303
3363
|
a,
|
|
3304
3364
|
h
|
|
3305
|
-
), g = (d.d - this.edgeEquilibriumLength) * this.edgeStiffness, l = d.ex * g, u = d.ey * g, w = e.get(
|
|
3365
|
+
), g = (d.d - this.edgeEquilibriumLength) * this.edgeStiffness, l = d.ex * g, u = d.ey * g, w = e.get(o.nodeId), y = e.get(n.nodeId);
|
|
3306
3366
|
w.x += l, w.y += u, y.x -= l, y.y -= u;
|
|
3307
3367
|
});
|
|
3308
3368
|
}
|
|
@@ -3313,7 +3373,7 @@ class Ie {
|
|
|
3313
3373
|
this.rand = e;
|
|
3314
3374
|
}
|
|
3315
3375
|
create(e, t) {
|
|
3316
|
-
const
|
|
3376
|
+
const s = t.x - e.x, o = t.y - e.y, n = s * s + o * o;
|
|
3317
3377
|
if (n === 0) {
|
|
3318
3378
|
const c = this.PI2 * this.rand();
|
|
3319
3379
|
return {
|
|
@@ -3322,7 +3382,7 @@ class Ie {
|
|
|
3322
3382
|
d: 0
|
|
3323
3383
|
};
|
|
3324
3384
|
}
|
|
3325
|
-
const a = Math.sqrt(n), h =
|
|
3385
|
+
const a = Math.sqrt(n), h = s / a, d = o / a;
|
|
3326
3386
|
return { ex: h, ey: d, d: a };
|
|
3327
3387
|
}
|
|
3328
3388
|
}
|
|
@@ -3341,11 +3401,11 @@ class Xt {
|
|
|
3341
3401
|
this.effectiveDistance = e.effectiveDistance, this.nodeCharge = e.nodeCharge, this.distanceVectorGenerator = e.distanceVectorGenerator, this.maxForce = e.maxForce;
|
|
3342
3402
|
}
|
|
3343
3403
|
apply(e, t) {
|
|
3344
|
-
const
|
|
3345
|
-
for (let n = 0; n <
|
|
3346
|
-
const a =
|
|
3347
|
-
for (let h = n + 1; h <
|
|
3348
|
-
const d =
|
|
3404
|
+
const s = Array.from(t.keys()), o = s.length;
|
|
3405
|
+
for (let n = 0; n < o; n++) {
|
|
3406
|
+
const a = s[n];
|
|
3407
|
+
for (let h = n + 1; h < o; h++) {
|
|
3408
|
+
const d = s[h], c = e.get(a), g = e.get(d), l = this.distanceVectorGenerator.create(
|
|
3349
3409
|
c,
|
|
3350
3410
|
g
|
|
3351
3411
|
);
|
|
@@ -3370,14 +3430,14 @@ const Yt = (r) => {
|
|
|
3370
3430
|
centerY: 0,
|
|
3371
3431
|
radius: 0
|
|
3372
3432
|
};
|
|
3373
|
-
let e = 1 / 0, t = -1 / 0,
|
|
3433
|
+
let e = 1 / 0, t = -1 / 0, s = 1 / 0, o = -1 / 0;
|
|
3374
3434
|
r.forEach((d) => {
|
|
3375
|
-
e = Math.min(e, d.x), t = Math.max(t, d.x),
|
|
3435
|
+
e = Math.min(e, d.x), t = Math.max(t, d.x), s = Math.min(s, d.y), o = Math.max(o, d.y);
|
|
3376
3436
|
});
|
|
3377
|
-
const n = t - e, a =
|
|
3437
|
+
const n = t - e, a = o - s, h = Math.max(n, a);
|
|
3378
3438
|
return {
|
|
3379
3439
|
centerX: (e + t) / 2,
|
|
3380
|
-
centerY: (
|
|
3440
|
+
centerY: (s + o) / 2,
|
|
3381
3441
|
radius: h / 2
|
|
3382
3442
|
};
|
|
3383
3443
|
};
|
|
@@ -3407,18 +3467,18 @@ class Gt {
|
|
|
3407
3467
|
};
|
|
3408
3468
|
let t = [this.root];
|
|
3409
3469
|
for (; t.length > 0; ) {
|
|
3410
|
-
const
|
|
3470
|
+
const s = [];
|
|
3411
3471
|
for (; t.length > 0; ) {
|
|
3412
|
-
const
|
|
3413
|
-
this.processNode(
|
|
3414
|
-
|
|
3472
|
+
const o = t.pop();
|
|
3473
|
+
this.processNode(o).forEach((a) => {
|
|
3474
|
+
s.push(a);
|
|
3415
3475
|
});
|
|
3416
3476
|
}
|
|
3417
|
-
t =
|
|
3477
|
+
t = s;
|
|
3418
3478
|
}
|
|
3419
|
-
this.sortedParentNodes.reverse().forEach((
|
|
3420
|
-
let
|
|
3421
|
-
|
|
3479
|
+
this.sortedParentNodes.reverse().forEach((s) => {
|
|
3480
|
+
let o = 0, n = 0, a = 0, h = 0;
|
|
3481
|
+
s.lb !== null && (a += s.lb.totalMass, h += s.lb.totalCharge, o += s.lb.chargeCenter.x * s.lb.totalCharge, n += s.lb.chargeCenter.y * s.lb.totalCharge), s.lt !== null && (a += s.lt.totalMass, h += s.lt.totalCharge, o += s.lt.chargeCenter.x * s.lt.totalCharge, n += s.lt.chargeCenter.y * s.lt.totalCharge), s.rb !== null && (a += s.rb.totalMass, h += s.rb.totalCharge, o += s.rb.chargeCenter.x * s.rb.totalCharge, n += s.rb.chargeCenter.y * s.rb.totalCharge), s.rt !== null && (a += s.rt.totalMass, h += s.rt.totalCharge, o += s.rt.chargeCenter.x * s.rt.totalCharge, n += s.rt.chargeCenter.y * s.rt.totalCharge), s.totalMass = a, s.totalCharge = h, s.chargeCenter.x = o / h, s.chargeCenter.y = n / h;
|
|
3422
3482
|
});
|
|
3423
3483
|
}
|
|
3424
3484
|
getRoot() {
|
|
@@ -3430,14 +3490,14 @@ class Gt {
|
|
|
3430
3490
|
processNode(e) {
|
|
3431
3491
|
if (e.nodeIds.size < 2)
|
|
3432
3492
|
return this.setLeaf(e), [];
|
|
3433
|
-
const { centerX: t, centerY:
|
|
3434
|
-
if (
|
|
3493
|
+
const { centerX: t, centerY: s, radius: o } = e.box;
|
|
3494
|
+
if (o < this.areaRadiusThreshold)
|
|
3435
3495
|
return this.setLeaf(e), [];
|
|
3436
3496
|
this.sortedParentNodes.push(e);
|
|
3437
|
-
const n = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set(), c =
|
|
3497
|
+
const n = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set(), c = o / 2;
|
|
3438
3498
|
e.nodeIds.forEach((u) => {
|
|
3439
3499
|
const { x: w, y } = this.coords.get(u);
|
|
3440
|
-
w < t ? y <
|
|
3500
|
+
w < t ? y < s ? d.add(u) : h.add(u) : y < s ? a.add(u) : n.add(u), e.nodeIds.delete(u);
|
|
3441
3501
|
});
|
|
3442
3502
|
const g = {
|
|
3443
3503
|
parent: e,
|
|
@@ -3457,7 +3517,7 @@ class Gt {
|
|
|
3457
3517
|
},
|
|
3458
3518
|
box: {
|
|
3459
3519
|
centerX: t + c,
|
|
3460
|
-
centerY:
|
|
3520
|
+
centerY: s + c,
|
|
3461
3521
|
radius: c
|
|
3462
3522
|
},
|
|
3463
3523
|
...g
|
|
@@ -3475,7 +3535,7 @@ class Gt {
|
|
|
3475
3535
|
},
|
|
3476
3536
|
box: {
|
|
3477
3537
|
centerX: t + c,
|
|
3478
|
-
centerY:
|
|
3538
|
+
centerY: s - c,
|
|
3479
3539
|
radius: c
|
|
3480
3540
|
},
|
|
3481
3541
|
...g
|
|
@@ -3493,7 +3553,7 @@ class Gt {
|
|
|
3493
3553
|
},
|
|
3494
3554
|
box: {
|
|
3495
3555
|
centerX: t - c,
|
|
3496
|
-
centerY:
|
|
3556
|
+
centerY: s + c,
|
|
3497
3557
|
radius: c
|
|
3498
3558
|
},
|
|
3499
3559
|
...g
|
|
@@ -3511,7 +3571,7 @@ class Gt {
|
|
|
3511
3571
|
},
|
|
3512
3572
|
box: {
|
|
3513
3573
|
centerX: t - c,
|
|
3514
|
-
centerY:
|
|
3574
|
+
centerY: s - c,
|
|
3515
3575
|
radius: c
|
|
3516
3576
|
},
|
|
3517
3577
|
...g
|
|
@@ -3531,11 +3591,11 @@ class Gt {
|
|
|
3531
3591
|
x: 0,
|
|
3532
3592
|
y: 0
|
|
3533
3593
|
};
|
|
3534
|
-
let t = 0,
|
|
3535
|
-
return e.forEach((
|
|
3536
|
-
const n = this.coords.get(
|
|
3537
|
-
t += n.x,
|
|
3538
|
-
}), { x: t / e.size, y:
|
|
3594
|
+
let t = 0, s = 0;
|
|
3595
|
+
return e.forEach((o) => {
|
|
3596
|
+
const n = this.coords.get(o);
|
|
3597
|
+
t += n.x, s += n.y;
|
|
3598
|
+
}), { x: t / e.size, y: s / e.size };
|
|
3539
3599
|
}
|
|
3540
3600
|
}
|
|
3541
3601
|
class jt {
|
|
@@ -3550,8 +3610,8 @@ class jt {
|
|
|
3550
3610
|
this.areaRadiusThreshold = e.areaRadiusThreshold, this.nodeMass = e.nodeMass, this.nodeCharge = e.nodeCharge, this.theta = e.theta, this.distanceVectorGenerator = e.distanceVectorGenerator, this.nodeForceCoefficient = e.nodeForceCoefficient, this.maxForce = e.maxForce;
|
|
3551
3611
|
}
|
|
3552
3612
|
apply(e, t) {
|
|
3553
|
-
const
|
|
3554
|
-
box:
|
|
3613
|
+
const s = Yt(e), o = new Gt({
|
|
3614
|
+
box: s,
|
|
3555
3615
|
coords: e,
|
|
3556
3616
|
areaRadiusThreshold: this.areaRadiusThreshold,
|
|
3557
3617
|
nodeMass: this.nodeMass,
|
|
@@ -3559,22 +3619,22 @@ class jt {
|
|
|
3559
3619
|
});
|
|
3560
3620
|
e.forEach((n, a) => {
|
|
3561
3621
|
const h = this.calculateForceForNode(
|
|
3562
|
-
|
|
3622
|
+
o.getLeaf(a),
|
|
3563
3623
|
a,
|
|
3564
3624
|
e
|
|
3565
3625
|
), d = t.get(a);
|
|
3566
3626
|
this.applyForce(d, h);
|
|
3567
3627
|
});
|
|
3568
3628
|
}
|
|
3569
|
-
calculateForceForNode(e, t,
|
|
3570
|
-
const
|
|
3629
|
+
calculateForceForNode(e, t, s) {
|
|
3630
|
+
const o = s.get(t), n = { x: 0, y: 0 };
|
|
3571
3631
|
e.nodeIds.forEach((h) => {
|
|
3572
3632
|
if (h !== t) {
|
|
3573
|
-
const d =
|
|
3633
|
+
const d = s.get(h), c = this.calculateNodeRepulsiveForce({
|
|
3574
3634
|
sourceCharge: this.nodeCharge,
|
|
3575
3635
|
targetCharge: this.nodeCharge,
|
|
3576
3636
|
sourceCoords: d,
|
|
3577
|
-
targetCoords:
|
|
3637
|
+
targetCoords: o
|
|
3578
3638
|
});
|
|
3579
3639
|
this.applyForce(n, c);
|
|
3580
3640
|
}
|
|
@@ -3585,73 +3645,73 @@ class jt {
|
|
|
3585
3645
|
if (h !== null) {
|
|
3586
3646
|
const d = this.distanceVectorGenerator.create(
|
|
3587
3647
|
h.chargeCenter,
|
|
3588
|
-
|
|
3648
|
+
o
|
|
3589
3649
|
);
|
|
3590
3650
|
h.box.radius * 2 < d.d * this.theta ? (this.tryApplyFarForce({
|
|
3591
3651
|
totalForce: n,
|
|
3592
|
-
targetCoords:
|
|
3652
|
+
targetCoords: o,
|
|
3593
3653
|
target: h.lb,
|
|
3594
3654
|
current: a
|
|
3595
3655
|
}), this.tryApplyFarForce({
|
|
3596
3656
|
totalForce: n,
|
|
3597
|
-
targetCoords:
|
|
3657
|
+
targetCoords: o,
|
|
3598
3658
|
target: h.rb,
|
|
3599
3659
|
current: a
|
|
3600
3660
|
}), this.tryApplyFarForce({
|
|
3601
3661
|
totalForce: n,
|
|
3602
|
-
targetCoords:
|
|
3662
|
+
targetCoords: o,
|
|
3603
3663
|
target: h.rt,
|
|
3604
3664
|
current: a
|
|
3605
3665
|
}), this.tryApplyFarForce({
|
|
3606
3666
|
totalForce: n,
|
|
3607
|
-
targetCoords:
|
|
3667
|
+
targetCoords: o,
|
|
3608
3668
|
target: h.lt,
|
|
3609
3669
|
current: a
|
|
3610
3670
|
})) : (this.tryApplyNearForce({
|
|
3611
3671
|
totalForce: n,
|
|
3612
|
-
targetCoords:
|
|
3672
|
+
targetCoords: o,
|
|
3613
3673
|
target: h.lb,
|
|
3614
3674
|
current: a,
|
|
3615
|
-
nodesCoords:
|
|
3675
|
+
nodesCoords: s
|
|
3616
3676
|
}), this.tryApplyNearForce({
|
|
3617
3677
|
totalForce: n,
|
|
3618
|
-
targetCoords:
|
|
3678
|
+
targetCoords: o,
|
|
3619
3679
|
target: h.rb,
|
|
3620
3680
|
current: a,
|
|
3621
|
-
nodesCoords:
|
|
3681
|
+
nodesCoords: s
|
|
3622
3682
|
}), this.tryApplyNearForce({
|
|
3623
3683
|
totalForce: n,
|
|
3624
|
-
targetCoords:
|
|
3684
|
+
targetCoords: o,
|
|
3625
3685
|
target: h.rt,
|
|
3626
3686
|
current: a,
|
|
3627
|
-
nodesCoords:
|
|
3687
|
+
nodesCoords: s
|
|
3628
3688
|
}), this.tryApplyNearForce({
|
|
3629
3689
|
totalForce: n,
|
|
3630
|
-
targetCoords:
|
|
3690
|
+
targetCoords: o,
|
|
3631
3691
|
target: h.lt,
|
|
3632
3692
|
current: a,
|
|
3633
|
-
nodesCoords:
|
|
3693
|
+
nodesCoords: s
|
|
3634
3694
|
}));
|
|
3635
3695
|
}
|
|
3636
3696
|
a = a.parent;
|
|
3637
3697
|
}
|
|
3638
3698
|
return n;
|
|
3639
3699
|
}
|
|
3640
|
-
calculateExactForce(e, t,
|
|
3641
|
-
const
|
|
3700
|
+
calculateExactForce(e, t, s) {
|
|
3701
|
+
const o = { x: 0, y: 0 }, n = [e];
|
|
3642
3702
|
for (; n.length > 0; ) {
|
|
3643
3703
|
const a = n.pop();
|
|
3644
3704
|
a.nodeIds.forEach((h) => {
|
|
3645
|
-
const d =
|
|
3705
|
+
const d = s.get(h), c = this.calculateNodeRepulsiveForce({
|
|
3646
3706
|
sourceCharge: this.nodeCharge,
|
|
3647
3707
|
targetCharge: this.nodeCharge,
|
|
3648
3708
|
sourceCoords: d,
|
|
3649
3709
|
targetCoords: t
|
|
3650
3710
|
});
|
|
3651
|
-
this.applyForce(
|
|
3711
|
+
this.applyForce(o, c);
|
|
3652
3712
|
}), a.lb !== null && n.push(a.lb), a.rb !== null && n.push(a.rb), a.lt !== null && n.push(a.lt), a.rt !== null && n.push(a.rt);
|
|
3653
3713
|
}
|
|
3654
|
-
return
|
|
3714
|
+
return o;
|
|
3655
3715
|
}
|
|
3656
3716
|
calculateApproximateForce(e, t) {
|
|
3657
3717
|
return this.calculateNodeRepulsiveForce({
|
|
@@ -3665,7 +3725,7 @@ class jt {
|
|
|
3665
3725
|
const t = this.distanceVectorGenerator.create(
|
|
3666
3726
|
e.sourceCoords,
|
|
3667
3727
|
e.targetCoords
|
|
3668
|
-
),
|
|
3728
|
+
), s = $e({
|
|
3669
3729
|
coefficient: this.nodeForceCoefficient,
|
|
3670
3730
|
sourceCharge: e.sourceCharge,
|
|
3671
3731
|
targetCharge: e.targetCharge,
|
|
@@ -3673,8 +3733,8 @@ class jt {
|
|
|
3673
3733
|
maxForce: this.maxForce
|
|
3674
3734
|
});
|
|
3675
3735
|
return {
|
|
3676
|
-
x:
|
|
3677
|
-
y:
|
|
3736
|
+
x: s * t.ex,
|
|
3737
|
+
y: s * t.ey
|
|
3678
3738
|
};
|
|
3679
3739
|
}
|
|
3680
3740
|
applyForce(e, t) {
|
|
@@ -3722,17 +3782,17 @@ class Be {
|
|
|
3722
3782
|
this.rand = e.rand, this.sparsity = e.sparsity;
|
|
3723
3783
|
}
|
|
3724
3784
|
calculateCoordinates(e, t) {
|
|
3725
|
-
const
|
|
3785
|
+
const s = /* @__PURE__ */ new Map(), o = e.getAllNodeIds(), n = Math.sqrt(o.length) * this.sparsity, { width: a, height: h } = t.getDimensions(), d = { x: a / 2, y: h / 2 }, c = t.createContentCoords(d), g = n / 2, l = {
|
|
3726
3786
|
x: c.x - g,
|
|
3727
3787
|
y: c.y - g
|
|
3728
3788
|
};
|
|
3729
|
-
return
|
|
3789
|
+
return o.forEach((u) => {
|
|
3730
3790
|
const w = e.getNode(u);
|
|
3731
|
-
|
|
3791
|
+
s.set(u, {
|
|
3732
3792
|
x: w.x ?? l.x + n * this.rand(),
|
|
3733
3793
|
y: w.y ?? l.y + n * this.rand()
|
|
3734
3794
|
});
|
|
3735
|
-
}),
|
|
3795
|
+
}), s;
|
|
3736
3796
|
}
|
|
3737
3797
|
}
|
|
3738
3798
|
class qt {
|
|
@@ -3762,14 +3822,14 @@ class qt {
|
|
|
3762
3822
|
});
|
|
3763
3823
|
}
|
|
3764
3824
|
calculateCoordinates(e, t) {
|
|
3765
|
-
const
|
|
3825
|
+
const s = this.fillerLayoutAlgorithm.calculateCoordinates(
|
|
3766
3826
|
e,
|
|
3767
3827
|
t
|
|
3768
3828
|
);
|
|
3769
|
-
for (let
|
|
3829
|
+
for (let o = 0; o < this.maxIterations; o++) {
|
|
3770
3830
|
const n = new Fe(
|
|
3771
3831
|
e,
|
|
3772
|
-
|
|
3832
|
+
s,
|
|
3773
3833
|
{
|
|
3774
3834
|
distanceVectorGenerator: this.distanceVectorGenerator,
|
|
3775
3835
|
nodeForcesApplicationStrategy: this.nodeForcesApplicationStrategy,
|
|
@@ -3782,7 +3842,7 @@ class qt {
|
|
|
3782
3842
|
if (a < this.convergenceDelta || h < this.convergenceVelocity)
|
|
3783
3843
|
break;
|
|
3784
3844
|
}
|
|
3785
|
-
return
|
|
3845
|
+
return s;
|
|
3786
3846
|
}
|
|
3787
3847
|
}
|
|
3788
3848
|
class Kt {
|
|
@@ -3810,13 +3870,13 @@ class Kt {
|
|
|
3810
3870
|
sparsity: e.edgeEquilibriumLength
|
|
3811
3871
|
});
|
|
3812
3872
|
}
|
|
3813
|
-
calculateNextCoordinates(e, t,
|
|
3814
|
-
const
|
|
3873
|
+
calculateNextCoordinates(e, t, s) {
|
|
3874
|
+
const o = this.fillerLayoutAlgorithm.calculateCoordinates(
|
|
3815
3875
|
e,
|
|
3816
|
-
|
|
3876
|
+
s
|
|
3817
3877
|
), n = new Fe(
|
|
3818
3878
|
e,
|
|
3819
|
-
|
|
3879
|
+
o,
|
|
3820
3880
|
{
|
|
3821
3881
|
distanceVectorGenerator: this.distanceVectorGenerator,
|
|
3822
3882
|
nodeForcesApplicationStrategy: this.nodeForcesApplicationStrategy,
|
|
@@ -3829,18 +3889,18 @@ class Kt {
|
|
|
3829
3889
|
return (a < this.convergenceDelta || h < this.convergenceVelocity) && !e.getAllNodeIds().some((c) => {
|
|
3830
3890
|
const g = e.getNode(c);
|
|
3831
3891
|
return g.x === null || g.y === null;
|
|
3832
|
-
}) ? /* @__PURE__ */ new Map() :
|
|
3892
|
+
}) ? /* @__PURE__ */ new Map() : o;
|
|
3833
3893
|
}
|
|
3834
3894
|
}
|
|
3835
3895
|
const Oe = (r) => {
|
|
3836
|
-
let e = 1779033703, t = 3144134277,
|
|
3896
|
+
let e = 1779033703, t = 3144134277, s = 1013904242, o = 2773480762;
|
|
3837
3897
|
for (let n = 0, a; n < r.length; n++)
|
|
3838
|
-
a = r.charCodeAt(n), e = t ^ Math.imul(e ^ a, 597399067), t =
|
|
3839
|
-
return e = Math.imul(
|
|
3840
|
-
}, We = (r, e, t,
|
|
3841
|
-
r |= 0, e |= 0, t |= 0,
|
|
3842
|
-
const
|
|
3843
|
-
return
|
|
3898
|
+
a = r.charCodeAt(n), e = t ^ Math.imul(e ^ a, 597399067), t = s ^ Math.imul(t ^ a, 2869860233), s = o ^ Math.imul(s ^ a, 951274213), o = e ^ Math.imul(o ^ a, 2716044179);
|
|
3899
|
+
return e = Math.imul(s ^ e >>> 18, 597399067), t = Math.imul(o ^ t >>> 22, 2869860233), s = Math.imul(e ^ s >>> 17, 951274213), o = Math.imul(t ^ o >>> 19, 2716044179), e ^= t ^ s ^ o, t ^= e, s ^= e, o ^= e, [e >>> 0, t >>> 0, s >>> 0, o >>> 0];
|
|
3900
|
+
}, We = (r, e, t, s) => function() {
|
|
3901
|
+
r |= 0, e |= 0, t |= 0, s |= 0;
|
|
3902
|
+
const o = (r + e | 0) + s | 0;
|
|
3903
|
+
return s = s + 1 | 0, r = e ^ e >>> 9, e = t + (t << 3) | 0, t = t << 21 | t >>> 11, t = t + o | 0, (o >>> 0) / 4294967296;
|
|
3844
3904
|
}, v = Object.freeze({
|
|
3845
3905
|
seed: "HTMLGraph is awesome",
|
|
3846
3906
|
maxTimeDeltaSec: 0.01,
|
|
@@ -3858,45 +3918,49 @@ const Oe = (r) => {
|
|
|
3858
3918
|
barnesHutAreaRadiusThreshold: 0.01,
|
|
3859
3919
|
barnesHutTheta: 1
|
|
3860
3920
|
}), Qt = (r) => {
|
|
3861
|
-
var e, t,
|
|
3921
|
+
var e, t, s;
|
|
3862
3922
|
switch ((e = r == null ? void 0 : r.algorithm) == null ? void 0 : e.type) {
|
|
3863
3923
|
case "custom":
|
|
3864
3924
|
return r.algorithm.instance;
|
|
3865
3925
|
default: {
|
|
3866
|
-
const
|
|
3926
|
+
const o = r == null ? void 0 : r.algorithm, n = Oe((o == null ? void 0 : o.seed) ?? v.seed), a = We(n[0], n[1], n[2], n[3]);
|
|
3867
3927
|
return new Kt({
|
|
3868
3928
|
rand: a,
|
|
3869
|
-
maxTimeDeltaSec: (
|
|
3870
|
-
nodeCharge: (
|
|
3871
|
-
nodeMass: (
|
|
3872
|
-
edgeEquilibriumLength: (
|
|
3929
|
+
maxTimeDeltaSec: (o == null ? void 0 : o.maxTimeDeltaSec) ?? v.maxTimeDeltaSec,
|
|
3930
|
+
nodeCharge: (o == null ? void 0 : o.nodeCharge) ?? v.nodeCharge,
|
|
3931
|
+
nodeMass: (o == null ? void 0 : o.nodeMass) ?? v.nodeMass,
|
|
3932
|
+
edgeEquilibriumLength: (o == null ? void 0 : o.edgeEquilibriumLength) ?? v.edgeEquilibriumLength,
|
|
3873
3933
|
effectiveDistance: v.effectiveDistance,
|
|
3874
|
-
edgeStiffness: (
|
|
3875
|
-
convergenceDelta: (
|
|
3876
|
-
convergenceVelocity: (
|
|
3877
|
-
maxForce: (
|
|
3878
|
-
nodeForceCoefficient: (
|
|
3879
|
-
barnesHutTheta: ((t =
|
|
3880
|
-
barnesHutAreaRadiusThreshold: ((
|
|
3934
|
+
edgeStiffness: (o == null ? void 0 : o.edgeStiffness) ?? v.edgeStiffness,
|
|
3935
|
+
convergenceDelta: (o == null ? void 0 : o.convergenceDelta) ?? v.convergenceDelta,
|
|
3936
|
+
convergenceVelocity: (o == null ? void 0 : o.convergenceVelocity) ?? v.convergenceVelocity,
|
|
3937
|
+
maxForce: (o == null ? void 0 : o.maxForce) ?? v.maxForce,
|
|
3938
|
+
nodeForceCoefficient: (o == null ? void 0 : o.nodeForceCoefficient) ?? v.nodeForceCoefficient,
|
|
3939
|
+
barnesHutTheta: ((t = o == null ? void 0 : o.barnesHut) == null ? void 0 : t.theta) ?? v.barnesHutTheta,
|
|
3940
|
+
barnesHutAreaRadiusThreshold: ((s = o == null ? void 0 : o.barnesHut) == null ? void 0 : s.areaRadiusThreshold) ?? v.barnesHutAreaRadiusThreshold
|
|
3881
3941
|
});
|
|
3882
3942
|
}
|
|
3883
3943
|
}
|
|
3884
|
-
}, Zt = (r) => r instanceof
|
|
3944
|
+
}, Zt = (r) => r instanceof j ? {
|
|
3885
3945
|
type: "manual",
|
|
3886
3946
|
trigger: r
|
|
3947
|
+
} : (r == null ? void 0 : r.type) === "topologyChangeMacrotask" ? {
|
|
3948
|
+
type: "topologyChangeMacrotask"
|
|
3949
|
+
} : (r == null ? void 0 : r.type) === "topologyChangeTimeout" ? {
|
|
3950
|
+
type: "topologyChangeMacrotask"
|
|
3887
3951
|
} : {
|
|
3888
|
-
type: "
|
|
3952
|
+
type: "topologyChangeMicrotask"
|
|
3889
3953
|
}, Jt = (r) => {
|
|
3890
3954
|
var e, t;
|
|
3891
3955
|
switch (r == null ? void 0 : r.type) {
|
|
3892
3956
|
case "custom":
|
|
3893
3957
|
return r.instance;
|
|
3894
3958
|
default: {
|
|
3895
|
-
const
|
|
3959
|
+
const s = Oe((r == null ? void 0 : r.seed) ?? v.seed), o = We(s[0], s[1], s[2], s[3]);
|
|
3896
3960
|
return new qt({
|
|
3897
3961
|
dtSec: (r == null ? void 0 : r.dtSec) ?? v.dtSec,
|
|
3898
3962
|
maxIterations: (r == null ? void 0 : r.maxIterations) ?? v.maxIterations,
|
|
3899
|
-
rand:
|
|
3963
|
+
rand: o,
|
|
3900
3964
|
nodeCharge: (r == null ? void 0 : r.nodeCharge) ?? v.nodeCharge,
|
|
3901
3965
|
nodeMass: (r == null ? void 0 : r.nodeMass) ?? v.nodeMass,
|
|
3902
3966
|
edgeEquilibriumLength: (r == null ? void 0 : r.edgeEquilibriumLength) ?? v.edgeEquilibriumLength,
|
|
@@ -3929,7 +3993,7 @@ const Oe = (r) => {
|
|
|
3929
3993
|
e.clear();
|
|
3930
3994
|
});
|
|
3931
3995
|
};
|
|
3932
|
-
class
|
|
3996
|
+
class or {
|
|
3933
3997
|
constructor(e) {
|
|
3934
3998
|
i(this, "used", !1);
|
|
3935
3999
|
i(this, "canvasDefaults", {});
|
|
@@ -3949,7 +4013,7 @@ class sr {
|
|
|
3949
4013
|
i(this, "hasUserDraggableEdges", !1);
|
|
3950
4014
|
i(this, "hasAnimatedLayout", !1);
|
|
3951
4015
|
i(this, "hasLayout", !1);
|
|
3952
|
-
i(this, "boxRenderingTrigger", new
|
|
4016
|
+
i(this, "boxRenderingTrigger", new j());
|
|
3953
4017
|
i(this, "graphStore");
|
|
3954
4018
|
i(this, "viewportStore");
|
|
3955
4019
|
i(this, "graph");
|
|
@@ -4026,25 +4090,25 @@ class sr {
|
|
|
4026
4090
|
if (this.used)
|
|
4027
4091
|
throw new Ht("CanvasBuilder is a single use object");
|
|
4028
4092
|
this.used = !0;
|
|
4029
|
-
const e = new
|
|
4093
|
+
const e = new Nt(this.element), t = this.createHtmlView(e.main), s = Lt(this.canvasDefaults), o = new ve(
|
|
4030
4094
|
this.graph,
|
|
4031
4095
|
this.viewport,
|
|
4032
4096
|
this.graphStore,
|
|
4033
4097
|
this.viewportStore,
|
|
4034
4098
|
t,
|
|
4035
|
-
|
|
4099
|
+
s
|
|
4036
4100
|
);
|
|
4037
|
-
if (this.hasBackground &&
|
|
4038
|
-
|
|
4101
|
+
if (this.hasBackground && _.configure(
|
|
4102
|
+
o,
|
|
4039
4103
|
Bt(this.backgroundConfig),
|
|
4040
4104
|
e.background
|
|
4041
|
-
), this.hasNodeResizeReactiveEdges &&
|
|
4105
|
+
), this.hasNodeResizeReactiveEdges && q.configure(o), this.hasDraggableNodes) {
|
|
4042
4106
|
let a = Rt(this.dragConfig);
|
|
4043
4107
|
this.hasAnimatedLayout && (a = er(
|
|
4044
4108
|
a,
|
|
4045
4109
|
this.animationStaticNodes
|
|
4046
|
-
)),
|
|
4047
|
-
|
|
4110
|
+
)), Z.configure(
|
|
4111
|
+
o,
|
|
4048
4112
|
e.main,
|
|
4049
4113
|
this.window,
|
|
4050
4114
|
a
|
|
@@ -4053,11 +4117,11 @@ class sr {
|
|
|
4053
4117
|
if (this.hasUserConnectablePorts) {
|
|
4054
4118
|
const a = Ot(
|
|
4055
4119
|
this.connectablePortsConfig,
|
|
4056
|
-
|
|
4057
|
-
|
|
4120
|
+
s.edges.shapeFactory,
|
|
4121
|
+
s.ports.direction
|
|
4058
4122
|
);
|
|
4059
|
-
|
|
4060
|
-
|
|
4123
|
+
ee.configure(
|
|
4124
|
+
o,
|
|
4061
4125
|
e.overlayConnectablePorts,
|
|
4062
4126
|
this.viewportStore,
|
|
4063
4127
|
this.window,
|
|
@@ -4067,44 +4131,44 @@ class sr {
|
|
|
4067
4131
|
if (this.hasUserDraggableEdges) {
|
|
4068
4132
|
const a = Wt(
|
|
4069
4133
|
this.draggableEdgesConfig,
|
|
4070
|
-
|
|
4134
|
+
o.graph
|
|
4071
4135
|
);
|
|
4072
|
-
|
|
4073
|
-
|
|
4136
|
+
te.configure(
|
|
4137
|
+
o,
|
|
4074
4138
|
e.overlayDraggableEdges,
|
|
4075
4139
|
this.viewportStore,
|
|
4076
4140
|
this.window,
|
|
4077
4141
|
a
|
|
4078
4142
|
);
|
|
4079
4143
|
}
|
|
4080
|
-
this.virtualScrollConfig !== void 0 ?
|
|
4081
|
-
|
|
4144
|
+
this.virtualScrollConfig !== void 0 ? J.configure(
|
|
4145
|
+
o,
|
|
4082
4146
|
e.main,
|
|
4083
4147
|
this.window,
|
|
4084
4148
|
ye(this.transformConfig),
|
|
4085
4149
|
this.boxRenderingTrigger,
|
|
4086
|
-
|
|
4087
|
-
) : this.hasTransformableViewport &&
|
|
4088
|
-
|
|
4150
|
+
kt(this.virtualScrollConfig)
|
|
4151
|
+
) : this.hasTransformableViewport && H.configure(
|
|
4152
|
+
o,
|
|
4089
4153
|
e.main,
|
|
4090
4154
|
this.window,
|
|
4091
4155
|
ye(this.transformConfig)
|
|
4092
4156
|
), this.hasLayout && Pt.configure(
|
|
4093
|
-
|
|
4157
|
+
o,
|
|
4094
4158
|
_t(this.layoutConfig)
|
|
4095
4159
|
), this.hasAnimatedLayout && (tr(
|
|
4096
|
-
|
|
4160
|
+
o.graph,
|
|
4097
4161
|
this.animationStaticNodes
|
|
4098
|
-
),
|
|
4099
|
-
|
|
4162
|
+
), se.configure(
|
|
4163
|
+
o,
|
|
4100
4164
|
Qt(this.animatedLayoutConfig),
|
|
4101
4165
|
this.animationStaticNodes,
|
|
4102
4166
|
this.window
|
|
4103
4167
|
));
|
|
4104
4168
|
const n = () => {
|
|
4105
|
-
e.destroy(),
|
|
4169
|
+
e.destroy(), o.onBeforeDestroy.unsubscribe(n);
|
|
4106
4170
|
};
|
|
4107
|
-
return
|
|
4171
|
+
return o.onBeforeDestroy.subscribe(n), o;
|
|
4108
4172
|
}
|
|
4109
4173
|
createHtmlView(e) {
|
|
4110
4174
|
let t = new me(
|
|
@@ -4116,22 +4180,22 @@ class sr {
|
|
|
4116
4180
|
t,
|
|
4117
4181
|
this.graphStore,
|
|
4118
4182
|
this.boxRenderingTrigger,
|
|
4119
|
-
|
|
4183
|
+
zt(this.virtualScrollConfig)
|
|
4120
4184
|
)), new qe(t, this.graphStore);
|
|
4121
4185
|
}
|
|
4122
4186
|
}
|
|
4123
4187
|
export {
|
|
4124
4188
|
ut as BezierEdgeShape,
|
|
4125
|
-
|
|
4189
|
+
or as CanvasBuilder,
|
|
4126
4190
|
Ht as CanvasBuilderError,
|
|
4127
4191
|
b as CanvasError,
|
|
4128
4192
|
M as ConnectionCategory,
|
|
4129
|
-
|
|
4130
|
-
|
|
4193
|
+
De as DirectEdgeShape,
|
|
4194
|
+
j as EventSubject,
|
|
4131
4195
|
pt as HorizontalEdgeShape,
|
|
4132
4196
|
vt as InteractiveEdgeError,
|
|
4133
4197
|
Me as InteractiveEdgeShape,
|
|
4134
|
-
|
|
4198
|
+
sr as MidpointEdgeShape,
|
|
4135
4199
|
wt as StraightEdgeShape,
|
|
4136
4200
|
ft as VerticalEdgeShape
|
|
4137
4201
|
};
|