@html-graph/html-graph 7.8.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 +33 -5
- package/dist/html-graph.js +619 -575
- package/dist/html-graph.umd.cjs +1 -1
- package/package.json +2 -1
package/dist/html-graph.js
CHANGED
|
@@ -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,8 +236,8 @@ 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));
|
|
@@ -286,22 +286,22 @@ class b extends Error {
|
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
288
|
class ve {
|
|
289
|
-
constructor(e, t,
|
|
289
|
+
constructor(e, t, s, o, n, a) {
|
|
290
290
|
i(this, "nodeIdGenerator", new X(
|
|
291
|
-
(e) => this.graphStore.
|
|
291
|
+
(e) => this.graphStore.hasNode(e)
|
|
292
292
|
));
|
|
293
293
|
i(this, "portIdGenerator", new X(
|
|
294
|
-
(e) => this.graphStore.
|
|
294
|
+
(e) => this.graphStore.hasPort(e)
|
|
295
295
|
));
|
|
296
296
|
i(this, "edgeIdGenerator", new X(
|
|
297
|
-
(e) => this.graphStore.
|
|
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) => ({
|
|
@@ -825,9 +846,9 @@ class q {
|
|
|
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
|
}
|
|
@@ -840,9 +861,9 @@ class q {
|
|
|
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,22 +901,22 @@ 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;
|
|
@@ -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
|
-
}, W = (r, e, t,
|
|
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,7 +1027,7 @@ 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 ${
|
|
1030
|
+
`L ${s.x} ${s.y}`
|
|
1010
1031
|
].join(" "), this.midpoint = W(w, e.flipX, e.flipY, e.to);
|
|
1011
1032
|
}
|
|
1012
1033
|
}
|
|
@@ -1024,21 +1045,21 @@ const K = Object.freeze({
|
|
|
1024
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 = W(w, e.flipX, e.flipY, e.to), this.path =
|
|
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,8 +1200,8 @@ 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
|
}
|
|
@@ -1190,19 +1211,19 @@ class Q {
|
|
|
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 = W(l, e.flipX, e.flipY, e.to), this.path =
|
|
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 = W(l, e.flipX, e.flipY, e.to), this.path =
|
|
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
|
);
|
|
@@ -1380,11 +1401,11 @@ class k {
|
|
|
1380
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 k {
|
|
|
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 k {
|
|
|
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,
|
|
@@ -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,
|
|
@@ -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,
|
|
@@ -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,
|
|
@@ -1763,7 +1784,7 @@ 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
1790
|
i(this, "group", Te());
|
|
@@ -1781,12 +1802,12 @@ class Ne {
|
|
|
1781
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, {
|
|
@@ -2142,7 +2186,7 @@ class z {
|
|
|
2142
2186
|
}
|
|
2143
2187
|
}
|
|
2144
2188
|
class Z {
|
|
2145
|
-
constructor(e, t,
|
|
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 Z {
|
|
|
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 Z {
|
|
|
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 Z {
|
|
|
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 Z {
|
|
|
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 Z(e, t,
|
|
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 Z {
|
|
|
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 Z {
|
|
|
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
2405
|
class H {
|
|
2362
|
-
constructor(e, t,
|
|
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 H {
|
|
|
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 H {
|
|
|
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 H {
|
|
|
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 H {
|
|
|
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 H {
|
|
|
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 H {
|
|
|
2447
2491
|
passive: !0
|
|
2448
2492
|
}), e.onBeforeDestroy.subscribe(this.onBeforeDestroy);
|
|
2449
2493
|
}
|
|
2450
|
-
static configure(e, t,
|
|
2451
|
-
new H(e, t,
|
|
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 H {
|
|
|
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
2546
|
class J {
|
|
2503
|
-
constructor(e, t,
|
|
2547
|
+
constructor(e, t, s, o, n, a) {
|
|
2504
2548
|
i(this, "nodeHorizontal");
|
|
2505
2549
|
i(this, "nodeVertical");
|
|
2506
2550
|
i(this, "viewport");
|
|
@@ -2523,27 +2567,27 @@ class J {
|
|
|
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(
|
|
@@ -2553,12 +2597,12 @@ class J {
|
|
|
2553
2597
|
h
|
|
2554
2598
|
), this.trigger.subscribe(this.updateLoadedArea), this.canvas.viewport.onAfterUpdated.subscribe(this.onAfterViewportUpdated);
|
|
2555
2599
|
}
|
|
2556
|
-
static configure(e, t,
|
|
2600
|
+
static configure(e, t, s, o, n, a) {
|
|
2557
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 J {
|
|
|
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,
|
|
@@ -2598,7 +2642,7 @@ const xt = () => {
|
|
|
2598
2642
|
return r.setAttribute("id", "pattern"), r;
|
|
2599
2643
|
};
|
|
2600
2644
|
class _ {
|
|
2601
|
-
constructor(e, t,
|
|
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 _ {
|
|
|
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 _(e, t,
|
|
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 _ {
|
|
|
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
2682
|
class ee {
|
|
2639
|
-
constructor(e, t,
|
|
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,19 +2713,19 @@ class ee {
|
|
|
2669
2713
|
}
|
|
2670
2714
|
);
|
|
2671
2715
|
}
|
|
2672
|
-
static configure(e, t,
|
|
2716
|
+
static configure(e, t, s, o, n) {
|
|
2673
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({
|
|
@@ -2690,13 +2734,13 @@ class ee {
|
|
|
2690
2734
|
}), l = {
|
|
2691
2735
|
overlayNodeId: C.StaticNodeId,
|
|
2692
2736
|
portCoords: c,
|
|
2693
|
-
portDirection:
|
|
2737
|
+
portDirection: o.direction
|
|
2694
2738
|
}, u = {
|
|
2695
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,
|
|
@@ -2708,30 +2752,30 @@ class ee {
|
|
|
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
2771
|
this.overlayCanvas.updateNode(C.DraggingNodeId, {
|
|
2728
|
-
x:
|
|
2729
|
-
y:
|
|
2772
|
+
x: s.x,
|
|
2773
|
+
y: s.y
|
|
2730
2774
|
});
|
|
2731
2775
|
}
|
|
2732
2776
|
}
|
|
2733
2777
|
class te {
|
|
2734
|
-
constructor(e, t,
|
|
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 te {
|
|
|
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 te {
|
|
|
2762
2806
|
}
|
|
2763
2807
|
);
|
|
2764
2808
|
}
|
|
2765
|
-
static configure(e, t,
|
|
2809
|
+
static configure(e, t, s, o, n) {
|
|
2766
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,12 +2835,12 @@ class te {
|
|
|
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
2845
|
overlayNodeId: C.StaticNodeId,
|
|
2802
2846
|
portCoords: w,
|
|
@@ -2807,7 +2851,7 @@ class te {
|
|
|
2807
2851
|
portDirection: d.direction
|
|
2808
2852
|
}, [S, T] = this.isTargetDragging ? [A, x] : [x, A];
|
|
2809
2853
|
this.overlayCanvas.addNode(U(S)), this.overlayCanvas.addNode(U(T));
|
|
2810
|
-
const P = this.params.draggingEdgeShapeFactory !== null ? this.params.draggingEdgeShapeFactory(C.EdgeId) :
|
|
2854
|
+
const P = this.params.draggingEdgeShapeFactory !== null ? this.params.draggingEdgeShapeFactory(C.EdgeId) : o.shape;
|
|
2811
2855
|
return this.overlayCanvas.addEdge({
|
|
2812
2856
|
id: C.EdgeId,
|
|
2813
2857
|
from: S.overlayNodeId,
|
|
@@ -2819,13 +2863,13 @@ class te {
|
|
|
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
|
-
},
|
|
2869
|
+
}, o = this.canvas.viewport.createContentCoords(s);
|
|
2826
2870
|
this.overlayCanvas.updateNode(C.DraggingNodeId, {
|
|
2827
|
-
x:
|
|
2828
|
-
y:
|
|
2871
|
+
x: o.x,
|
|
2872
|
+
y: o.y
|
|
2829
2873
|
});
|
|
2830
2874
|
}
|
|
2831
2875
|
tryCreateConnection(e) {
|
|
@@ -2841,10 +2885,10 @@ class te {
|
|
|
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);
|
|
@@ -2863,39 +2907,39 @@ class te {
|
|
|
2863
2907
|
}
|
|
2864
2908
|
}
|
|
2865
2909
|
class re {
|
|
2866
|
-
constructor(e, t,
|
|
2867
|
-
this.canvas = e, this.layoutAlgorithm = t, this.trigger =
|
|
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,
|
|
2915
|
+
static configure(e, t, s) {
|
|
2872
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
2931
|
class O {
|
|
2888
|
-
constructor(e, t,
|
|
2932
|
+
constructor(e, t, s) {
|
|
2889
2933
|
i(this, "applyScheduled", !1);
|
|
2890
2934
|
i(this, "apply", () => {
|
|
2891
2935
|
this.applyScheduled = !1, this.layoutAlgorithm.calculateCoordinates(
|
|
2892
2936
|
this.canvas.graph,
|
|
2893
2937
|
this.canvas.viewport
|
|
2894
|
-
).forEach((t,
|
|
2895
|
-
this.canvas.updateNode(
|
|
2938
|
+
).forEach((t, s) => {
|
|
2939
|
+
this.canvas.updateNode(s, t);
|
|
2896
2940
|
});
|
|
2897
2941
|
});
|
|
2898
|
-
this.canvas = e, this.layoutAlgorithm = t, this.defererFn =
|
|
2942
|
+
this.canvas = e, this.layoutAlgorithm = t, this.defererFn = s, this.canvas.graph.onAfterNodeAdded.subscribe(() => {
|
|
2899
2943
|
this.scheduleApply();
|
|
2900
2944
|
}), this.canvas.graph.onBeforeNodeRemoved.subscribe(() => {
|
|
2901
2945
|
this.scheduleApply();
|
|
@@ -2905,11 +2949,11 @@ class O {
|
|
|
2905
2949
|
this.scheduleApply();
|
|
2906
2950
|
});
|
|
2907
2951
|
}
|
|
2908
|
-
static configure(e, t,
|
|
2952
|
+
static configure(e, t, s) {
|
|
2909
2953
|
new O(
|
|
2910
2954
|
e,
|
|
2911
2955
|
t,
|
|
2912
|
-
|
|
2956
|
+
s
|
|
2913
2957
|
);
|
|
2914
2958
|
}
|
|
2915
2959
|
scheduleApply() {
|
|
@@ -2918,13 +2962,13 @@ class O {
|
|
|
2918
2962
|
}
|
|
2919
2963
|
class Pt {
|
|
2920
2964
|
static configure(e, t) {
|
|
2921
|
-
const
|
|
2922
|
-
switch (
|
|
2965
|
+
const s = t.applyOn;
|
|
2966
|
+
switch (s.type) {
|
|
2923
2967
|
case "manual": {
|
|
2924
2968
|
re.configure(
|
|
2925
2969
|
e,
|
|
2926
2970
|
t.algorithm,
|
|
2927
|
-
|
|
2971
|
+
s.trigger
|
|
2928
2972
|
);
|
|
2929
2973
|
break;
|
|
2930
2974
|
}
|
|
@@ -2932,9 +2976,9 @@ class Pt {
|
|
|
2932
2976
|
O.configure(
|
|
2933
2977
|
e,
|
|
2934
2978
|
t.algorithm,
|
|
2935
|
-
(
|
|
2979
|
+
(o) => {
|
|
2936
2980
|
setTimeout(() => {
|
|
2937
|
-
|
|
2981
|
+
o();
|
|
2938
2982
|
});
|
|
2939
2983
|
}
|
|
2940
2984
|
);
|
|
@@ -2944,9 +2988,9 @@ class Pt {
|
|
|
2944
2988
|
O.configure(
|
|
2945
2989
|
e,
|
|
2946
2990
|
t.algorithm,
|
|
2947
|
-
(
|
|
2991
|
+
(o) => {
|
|
2948
2992
|
queueMicrotask(() => {
|
|
2949
|
-
|
|
2993
|
+
o();
|
|
2950
2994
|
});
|
|
2951
2995
|
}
|
|
2952
2996
|
);
|
|
@@ -2970,21 +3014,21 @@ class Ct {
|
|
|
2970
3014
|
this.win = e, this.callback = t, this.win.requestAnimationFrame(this.step);
|
|
2971
3015
|
}
|
|
2972
3016
|
}
|
|
2973
|
-
class
|
|
2974
|
-
constructor(e, t,
|
|
3017
|
+
class se {
|
|
3018
|
+
constructor(e, t, s, o) {
|
|
2975
3019
|
i(this, "step", (e) => {
|
|
2976
3020
|
this.algorithm.calculateNextCoordinates(
|
|
2977
3021
|
this.canvas.graph,
|
|
2978
3022
|
e,
|
|
2979
3023
|
this.canvas.viewport
|
|
2980
|
-
).forEach((
|
|
2981
|
-
this.staticNodes.has(
|
|
3024
|
+
).forEach((s, o) => {
|
|
3025
|
+
this.staticNodes.has(o) || this.canvas.updateNode(o, { x: s.x, y: s.y });
|
|
2982
3026
|
});
|
|
2983
3027
|
});
|
|
2984
|
-
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);
|
|
2985
3029
|
}
|
|
2986
|
-
static configure(e, t,
|
|
2987
|
-
new
|
|
3030
|
+
static configure(e, t, s, o) {
|
|
3031
|
+
new se(e, t, s, o);
|
|
2988
3032
|
}
|
|
2989
3033
|
}
|
|
2990
3034
|
const Tt = () => {
|
|
@@ -2997,7 +3041,7 @@ const Tt = () => {
|
|
|
2997
3041
|
const r = Y();
|
|
2998
3042
|
return r.style.pointerEvents = "none", r;
|
|
2999
3043
|
};
|
|
3000
|
-
class
|
|
3044
|
+
class Nt {
|
|
3001
3045
|
constructor(e) {
|
|
3002
3046
|
i(this, "background", Y());
|
|
3003
3047
|
i(this, "main", Y());
|
|
@@ -3010,17 +3054,17 @@ class Dt {
|
|
|
3010
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);
|
|
3011
3055
|
}
|
|
3012
3056
|
}
|
|
3013
|
-
const G = (r) => () => r, we = G(0),
|
|
3057
|
+
const G = (r) => () => r, we = G(0), Dt = () => {
|
|
3014
3058
|
let r = 0;
|
|
3015
3059
|
return () => r++;
|
|
3016
3060
|
}, Mt = (r, e) => {
|
|
3017
|
-
let t = we,
|
|
3018
|
-
const
|
|
3019
|
-
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), {
|
|
3020
3064
|
nodesPriorityFn: t,
|
|
3021
|
-
edgesPriorityFn:
|
|
3065
|
+
edgesPriorityFn: s
|
|
3022
3066
|
};
|
|
3023
|
-
},
|
|
3067
|
+
}, oe = (r) => {
|
|
3024
3068
|
if (typeof r == "function")
|
|
3025
3069
|
return r;
|
|
3026
3070
|
switch (r.type) {
|
|
@@ -3065,7 +3109,7 @@ const G = (r) => () => r, we = G(0), Nt = () => {
|
|
|
3065
3109
|
detourDistance: r.detourDistance
|
|
3066
3110
|
});
|
|
3067
3111
|
case "direct":
|
|
3068
|
-
return () => new
|
|
3112
|
+
return () => new De({
|
|
3069
3113
|
color: r.color,
|
|
3070
3114
|
width: r.width,
|
|
3071
3115
|
arrowLength: r.arrowLength,
|
|
@@ -3091,21 +3135,21 @@ const G = (r) => () => r, we = G(0), Nt = () => {
|
|
|
3091
3135
|
});
|
|
3092
3136
|
}
|
|
3093
3137
|
}, Lt = (r) => {
|
|
3094
|
-
var t,
|
|
3138
|
+
var t, s, o, n, a;
|
|
3095
3139
|
const e = Mt(
|
|
3096
3140
|
(t = r.nodes) == null ? void 0 : t.priority,
|
|
3097
|
-
(
|
|
3141
|
+
(s = r.edges) == null ? void 0 : s.priority
|
|
3098
3142
|
);
|
|
3099
3143
|
return {
|
|
3100
3144
|
nodes: {
|
|
3101
|
-
centerFn: ((
|
|
3145
|
+
centerFn: ((o = r.nodes) == null ? void 0 : o.centerFn) ?? Se,
|
|
3102
3146
|
priorityFn: e.nodesPriorityFn
|
|
3103
3147
|
},
|
|
3104
3148
|
ports: {
|
|
3105
3149
|
direction: ((n = r.ports) == null ? void 0 : n.direction) ?? 0
|
|
3106
3150
|
},
|
|
3107
3151
|
edges: {
|
|
3108
|
-
shapeFactory:
|
|
3152
|
+
shapeFactory: oe(((a = r.edges) == null ? void 0 : a.shape) ?? {}),
|
|
3109
3153
|
priorityFn: e.edgesPriorityFn
|
|
3110
3154
|
}
|
|
3111
3155
|
};
|
|
@@ -3113,7 +3157,7 @@ const G = (r) => () => r, we = G(0), Nt = () => {
|
|
|
3113
3157
|
var w, y, A, x, S, T;
|
|
3114
3158
|
const e = ((w = r.events) == null ? void 0 : w.onNodeDragStarted) ?? (() => {
|
|
3115
3159
|
}), t = ((y = r.events) == null ? void 0 : y.onNodeDrag) ?? (() => {
|
|
3116
|
-
}),
|
|
3160
|
+
}), s = r.nodeDragVerifier ?? (() => !0), o = ((A = r.events) == null ? void 0 : A.onNodeDragFinished) ?? (() => {
|
|
3117
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;
|
|
3118
3162
|
return {
|
|
3119
3163
|
moveOnTop: n,
|
|
@@ -3124,31 +3168,31 @@ const G = (r) => () => r, we = G(0), Nt = () => {
|
|
|
3124
3168
|
mouseUpEventVerifier: u,
|
|
3125
3169
|
onNodeDragStarted: e,
|
|
3126
3170
|
onNodeDrag: t,
|
|
3127
|
-
nodeDragVerifier:
|
|
3128
|
-
onNodeDragFinished:
|
|
3171
|
+
nodeDragVerifier: s,
|
|
3172
|
+
onNodeDragFinished: o
|
|
3129
3173
|
};
|
|
3130
3174
|
}, Vt = (r) => {
|
|
3131
|
-
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;
|
|
3132
3176
|
return (n) => {
|
|
3133
3177
|
let a = n.nextTransform.x, h = n.nextTransform.y;
|
|
3134
3178
|
a < e && a < n.prevTransform.x && (a = Math.min(n.prevTransform.x, e));
|
|
3135
3179
|
const d = n.canvasWidth * n.prevTransform.scale, c = t - d;
|
|
3136
|
-
a > c && a > n.prevTransform.x && (a = Math.max(n.prevTransform.x, c)), h <
|
|
3137
|
-
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;
|
|
3138
3182
|
return h > l && h > n.prevTransform.y && (h = Math.max(n.prevTransform.y, l)), { scale: n.nextTransform.scale, x: a, y: h };
|
|
3139
3183
|
};
|
|
3140
3184
|
}, Ft = (r) => {
|
|
3141
|
-
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;
|
|
3142
3186
|
return (n) => {
|
|
3143
3187
|
const a = n.prevTransform, h = n.nextTransform;
|
|
3144
3188
|
let d = h.scale, c = h.x, g = h.y;
|
|
3145
|
-
if (h.scale >
|
|
3146
|
-
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;
|
|
3147
3191
|
const l = (d - a.scale) / (h.scale - a.scale);
|
|
3148
3192
|
c = a.x + (h.x - a.x) * l, g = a.y + (h.y - a.y) * l;
|
|
3149
3193
|
}
|
|
3150
|
-
if (h.scale <
|
|
3151
|
-
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;
|
|
3152
3196
|
const l = (d - a.scale) / (h.scale - a.scale);
|
|
3153
3197
|
c = a.x + (h.x - a.x) * l, g = a.y + (h.y - a.y) * l;
|
|
3154
3198
|
}
|
|
@@ -3159,7 +3203,7 @@ const G = (r) => () => r, we = G(0), Nt = () => {
|
|
|
3159
3203
|
};
|
|
3160
3204
|
};
|
|
3161
3205
|
}, It = (r) => (e) => r.reduce(
|
|
3162
|
-
(t,
|
|
3206
|
+
(t, s) => s({
|
|
3163
3207
|
prevTransform: e.prevTransform,
|
|
3164
3208
|
nextTransform: t,
|
|
3165
3209
|
canvasWidth: e.canvasWidth,
|
|
@@ -3185,16 +3229,16 @@ const G = (r) => () => r, we = G(0), Nt = () => {
|
|
|
3185
3229
|
}
|
|
3186
3230
|
}, ye = (r) => {
|
|
3187
3231
|
var y, A, x, S, T, P, R, V, ie, ne, ae, he;
|
|
3188
|
-
const e = (y = r == null ? void 0 : r.scale) == null ? void 0 : y.mouseWheelSensitivity, t = e !== void 0 ? e : 1.2,
|
|
3189
|
-
let
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
(
|
|
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)
|
|
3193
3237
|
)
|
|
3194
|
-
) :
|
|
3238
|
+
) : o = fe(s) : o = (N) => N.nextTransform;
|
|
3195
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) ?? (() => {
|
|
3196
3240
|
}), h = ((S = r == null ? void 0 : r.events) == null ? void 0 : S.onTransformChange) ?? (() => {
|
|
3197
|
-
}), d = (T = r == null ? void 0 : r.shift) == null ? void 0 : T.mouseDownEventVerifier, c = d !== void 0 ? 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;
|
|
3198
3242
|
return {
|
|
3199
3243
|
wheelSensitivity: t,
|
|
3200
3244
|
onTransformStarted: ((V = r == null ? void 0 : r.events) == null ? void 0 : V.onTransformStarted) ?? (() => {
|
|
@@ -3203,7 +3247,7 @@ const G = (r) => () => r, we = G(0), Nt = () => {
|
|
|
3203
3247
|
}),
|
|
3204
3248
|
onBeforeTransformChange: a,
|
|
3205
3249
|
onTransformChange: h,
|
|
3206
|
-
transformPreprocessor:
|
|
3250
|
+
transformPreprocessor: o,
|
|
3207
3251
|
shiftCursor: n,
|
|
3208
3252
|
mouseDownEventVerifier: c,
|
|
3209
3253
|
mouseUpEventVerifier: l,
|
|
@@ -3224,33 +3268,33 @@ const G = (r) => () => r, we = G(0), Nt = () => {
|
|
|
3224
3268
|
(r == null ? void 0 : r.radius) ?? 1.5,
|
|
3225
3269
|
(r == null ? void 0 : r.color) ?? "#d8d8d8"
|
|
3226
3270
|
), Bt = (r) => {
|
|
3227
|
-
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 ?? {});
|
|
3228
3272
|
return {
|
|
3229
3273
|
tileWidth: t,
|
|
3230
|
-
tileHeight:
|
|
3231
|
-
renderer:
|
|
3274
|
+
tileHeight: s,
|
|
3275
|
+
renderer: o,
|
|
3232
3276
|
maxViewportScale: r.maxViewportScale ?? 10
|
|
3233
3277
|
};
|
|
3234
3278
|
}, Ot = (r, e, t) => {
|
|
3235
3279
|
var c, g, l;
|
|
3236
|
-
const
|
|
3280
|
+
const s = () => "direct", o = (u) => u, n = (u) => u.button === 0, a = () => {
|
|
3237
3281
|
}, h = () => {
|
|
3238
3282
|
}, d = () => {
|
|
3239
3283
|
};
|
|
3240
3284
|
return {
|
|
3241
|
-
connectionTypeResolver: r.connectionTypeResolver ??
|
|
3242
|
-
connectionPreprocessor: r.connectionPreprocessor ??
|
|
3285
|
+
connectionTypeResolver: r.connectionTypeResolver ?? s,
|
|
3286
|
+
connectionPreprocessor: r.connectionPreprocessor ?? o,
|
|
3243
3287
|
mouseDownEventVerifier: r.mouseDownEventVerifier ?? n,
|
|
3244
3288
|
mouseUpEventVerifier: r.mouseUpEventVerifier ?? n,
|
|
3245
3289
|
onAfterEdgeCreated: ((c = r.events) == null ? void 0 : c.onAfterEdgeCreated) ?? a,
|
|
3246
3290
|
onEdgeCreationInterrupted: ((g = r.events) == null ? void 0 : g.onEdgeCreationInterrupted) ?? d,
|
|
3247
3291
|
onEdgeCreationPrevented: ((l = r.events) == null ? void 0 : l.onEdgeCreationPrevented) ?? h,
|
|
3248
3292
|
dragPortDirection: r.dragPortDirection ?? t,
|
|
3249
|
-
edgeShapeFactory: r.edgeShape !== void 0 ?
|
|
3293
|
+
edgeShapeFactory: r.edgeShape !== void 0 ? oe(r.edgeShape) : e
|
|
3250
3294
|
};
|
|
3251
3295
|
}, Wt = (r, e) => {
|
|
3252
3296
|
var c, g, l;
|
|
3253
|
-
const t = (u) => u,
|
|
3297
|
+
const t = (u) => u, s = (u) => u.button === 0 && u.ctrlKey, o = (u) => u.button === 0, n = (u) => {
|
|
3254
3298
|
const w = e.getPortAdjacentEdgeIds(u);
|
|
3255
3299
|
return w.length > 0 ? w[w.length - 1] : null;
|
|
3256
3300
|
}, a = () => {
|
|
@@ -3259,10 +3303,10 @@ const G = (r) => () => r, we = G(0), Nt = () => {
|
|
|
3259
3303
|
};
|
|
3260
3304
|
return {
|
|
3261
3305
|
connectionPreprocessor: r.connectionPreprocessor ?? t,
|
|
3262
|
-
mouseDownEventVerifier: r.mouseDownEventVerifier ??
|
|
3263
|
-
mouseUpEventVerifier: r.mouseUpEventVerifier ??
|
|
3306
|
+
mouseDownEventVerifier: r.mouseDownEventVerifier ?? s,
|
|
3307
|
+
mouseUpEventVerifier: r.mouseUpEventVerifier ?? o,
|
|
3264
3308
|
draggingEdgeResolver: r.draggingEdgeResolver ?? n,
|
|
3265
|
-
draggingEdgeShapeFactory: r.draggingEdgeShape !== void 0 ?
|
|
3309
|
+
draggingEdgeShapeFactory: r.draggingEdgeShape !== void 0 ? oe(r.draggingEdgeShape) : null,
|
|
3266
3310
|
onAfterEdgeReattached: ((c = r.events) == null ? void 0 : c.onAfterEdgeReattached) ?? a,
|
|
3267
3311
|
onEdgeReattachInterrupted: ((g = r.events) == null ? void 0 : g.onEdgeReattachInterrupted) ?? d,
|
|
3268
3312
|
onEdgeReattachPrevented: ((l = r.events) == null ? void 0 : l.onEdgeReattachPrevented) ?? h
|
|
@@ -3286,22 +3330,22 @@ class Ht extends Error {
|
|
|
3286
3330
|
}
|
|
3287
3331
|
}
|
|
3288
3332
|
class Fe {
|
|
3289
|
-
constructor(e, t,
|
|
3333
|
+
constructor(e, t, s) {
|
|
3290
3334
|
i(this, "dt");
|
|
3291
3335
|
i(this, "nodeMass");
|
|
3292
3336
|
i(this, "edgeEquilibriumLength");
|
|
3293
3337
|
i(this, "edgeStiffness");
|
|
3294
3338
|
i(this, "nodeForcesApplicationStrategy");
|
|
3295
3339
|
i(this, "distanceVectorGenerator");
|
|
3296
|
-
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;
|
|
3297
3341
|
}
|
|
3298
3342
|
apply() {
|
|
3299
3343
|
let e = 0, t = 0;
|
|
3300
|
-
const
|
|
3344
|
+
const s = /* @__PURE__ */ new Map();
|
|
3301
3345
|
return this.graph.getAllNodeIds().forEach((n) => {
|
|
3302
|
-
|
|
3303
|
-
}), this.nodeForcesApplicationStrategy.apply(this.currentCoords,
|
|
3304
|
-
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 = {
|
|
3305
3349
|
x: h.x / this.nodeMass * this.dt,
|
|
3306
3350
|
y: h.y / this.nodeMass * this.dt
|
|
3307
3351
|
};
|
|
@@ -3315,10 +3359,10 @@ class Fe {
|
|
|
3315
3359
|
}
|
|
3316
3360
|
applyEdgeForces(e) {
|
|
3317
3361
|
this.graph.getAllEdgeIds().forEach((t) => {
|
|
3318
|
-
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(
|
|
3319
3363
|
a,
|
|
3320
3364
|
h
|
|
3321
|
-
), 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);
|
|
3322
3366
|
w.x += l, w.y += u, y.x -= l, y.y -= u;
|
|
3323
3367
|
});
|
|
3324
3368
|
}
|
|
@@ -3329,7 +3373,7 @@ class Ie {
|
|
|
3329
3373
|
this.rand = e;
|
|
3330
3374
|
}
|
|
3331
3375
|
create(e, t) {
|
|
3332
|
-
const
|
|
3376
|
+
const s = t.x - e.x, o = t.y - e.y, n = s * s + o * o;
|
|
3333
3377
|
if (n === 0) {
|
|
3334
3378
|
const c = this.PI2 * this.rand();
|
|
3335
3379
|
return {
|
|
@@ -3338,7 +3382,7 @@ class Ie {
|
|
|
3338
3382
|
d: 0
|
|
3339
3383
|
};
|
|
3340
3384
|
}
|
|
3341
|
-
const a = Math.sqrt(n), h =
|
|
3385
|
+
const a = Math.sqrt(n), h = s / a, d = o / a;
|
|
3342
3386
|
return { ex: h, ey: d, d: a };
|
|
3343
3387
|
}
|
|
3344
3388
|
}
|
|
@@ -3357,11 +3401,11 @@ class Xt {
|
|
|
3357
3401
|
this.effectiveDistance = e.effectiveDistance, this.nodeCharge = e.nodeCharge, this.distanceVectorGenerator = e.distanceVectorGenerator, this.maxForce = e.maxForce;
|
|
3358
3402
|
}
|
|
3359
3403
|
apply(e, t) {
|
|
3360
|
-
const
|
|
3361
|
-
for (let n = 0; n <
|
|
3362
|
-
const a =
|
|
3363
|
-
for (let h = n + 1; h <
|
|
3364
|
-
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(
|
|
3365
3409
|
c,
|
|
3366
3410
|
g
|
|
3367
3411
|
);
|
|
@@ -3386,14 +3430,14 @@ const Yt = (r) => {
|
|
|
3386
3430
|
centerY: 0,
|
|
3387
3431
|
radius: 0
|
|
3388
3432
|
};
|
|
3389
|
-
let e = 1 / 0, t = -1 / 0,
|
|
3433
|
+
let e = 1 / 0, t = -1 / 0, s = 1 / 0, o = -1 / 0;
|
|
3390
3434
|
r.forEach((d) => {
|
|
3391
|
-
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);
|
|
3392
3436
|
});
|
|
3393
|
-
const n = t - e, a =
|
|
3437
|
+
const n = t - e, a = o - s, h = Math.max(n, a);
|
|
3394
3438
|
return {
|
|
3395
3439
|
centerX: (e + t) / 2,
|
|
3396
|
-
centerY: (
|
|
3440
|
+
centerY: (s + o) / 2,
|
|
3397
3441
|
radius: h / 2
|
|
3398
3442
|
};
|
|
3399
3443
|
};
|
|
@@ -3423,18 +3467,18 @@ class Gt {
|
|
|
3423
3467
|
};
|
|
3424
3468
|
let t = [this.root];
|
|
3425
3469
|
for (; t.length > 0; ) {
|
|
3426
|
-
const
|
|
3470
|
+
const s = [];
|
|
3427
3471
|
for (; t.length > 0; ) {
|
|
3428
|
-
const
|
|
3429
|
-
this.processNode(
|
|
3430
|
-
|
|
3472
|
+
const o = t.pop();
|
|
3473
|
+
this.processNode(o).forEach((a) => {
|
|
3474
|
+
s.push(a);
|
|
3431
3475
|
});
|
|
3432
3476
|
}
|
|
3433
|
-
t =
|
|
3477
|
+
t = s;
|
|
3434
3478
|
}
|
|
3435
|
-
this.sortedParentNodes.reverse().forEach((
|
|
3436
|
-
let
|
|
3437
|
-
|
|
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;
|
|
3438
3482
|
});
|
|
3439
3483
|
}
|
|
3440
3484
|
getRoot() {
|
|
@@ -3446,14 +3490,14 @@ class Gt {
|
|
|
3446
3490
|
processNode(e) {
|
|
3447
3491
|
if (e.nodeIds.size < 2)
|
|
3448
3492
|
return this.setLeaf(e), [];
|
|
3449
|
-
const { centerX: t, centerY:
|
|
3450
|
-
if (
|
|
3493
|
+
const { centerX: t, centerY: s, radius: o } = e.box;
|
|
3494
|
+
if (o < this.areaRadiusThreshold)
|
|
3451
3495
|
return this.setLeaf(e), [];
|
|
3452
3496
|
this.sortedParentNodes.push(e);
|
|
3453
|
-
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;
|
|
3454
3498
|
e.nodeIds.forEach((u) => {
|
|
3455
3499
|
const { x: w, y } = this.coords.get(u);
|
|
3456
|
-
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);
|
|
3457
3501
|
});
|
|
3458
3502
|
const g = {
|
|
3459
3503
|
parent: e,
|
|
@@ -3473,7 +3517,7 @@ class Gt {
|
|
|
3473
3517
|
},
|
|
3474
3518
|
box: {
|
|
3475
3519
|
centerX: t + c,
|
|
3476
|
-
centerY:
|
|
3520
|
+
centerY: s + c,
|
|
3477
3521
|
radius: c
|
|
3478
3522
|
},
|
|
3479
3523
|
...g
|
|
@@ -3491,7 +3535,7 @@ class Gt {
|
|
|
3491
3535
|
},
|
|
3492
3536
|
box: {
|
|
3493
3537
|
centerX: t + c,
|
|
3494
|
-
centerY:
|
|
3538
|
+
centerY: s - c,
|
|
3495
3539
|
radius: c
|
|
3496
3540
|
},
|
|
3497
3541
|
...g
|
|
@@ -3509,7 +3553,7 @@ class Gt {
|
|
|
3509
3553
|
},
|
|
3510
3554
|
box: {
|
|
3511
3555
|
centerX: t - c,
|
|
3512
|
-
centerY:
|
|
3556
|
+
centerY: s + c,
|
|
3513
3557
|
radius: c
|
|
3514
3558
|
},
|
|
3515
3559
|
...g
|
|
@@ -3527,7 +3571,7 @@ class Gt {
|
|
|
3527
3571
|
},
|
|
3528
3572
|
box: {
|
|
3529
3573
|
centerX: t - c,
|
|
3530
|
-
centerY:
|
|
3574
|
+
centerY: s - c,
|
|
3531
3575
|
radius: c
|
|
3532
3576
|
},
|
|
3533
3577
|
...g
|
|
@@ -3547,11 +3591,11 @@ class Gt {
|
|
|
3547
3591
|
x: 0,
|
|
3548
3592
|
y: 0
|
|
3549
3593
|
};
|
|
3550
|
-
let t = 0,
|
|
3551
|
-
return e.forEach((
|
|
3552
|
-
const n = this.coords.get(
|
|
3553
|
-
t += n.x,
|
|
3554
|
-
}), { 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 };
|
|
3555
3599
|
}
|
|
3556
3600
|
}
|
|
3557
3601
|
class jt {
|
|
@@ -3566,8 +3610,8 @@ class jt {
|
|
|
3566
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;
|
|
3567
3611
|
}
|
|
3568
3612
|
apply(e, t) {
|
|
3569
|
-
const
|
|
3570
|
-
box:
|
|
3613
|
+
const s = Yt(e), o = new Gt({
|
|
3614
|
+
box: s,
|
|
3571
3615
|
coords: e,
|
|
3572
3616
|
areaRadiusThreshold: this.areaRadiusThreshold,
|
|
3573
3617
|
nodeMass: this.nodeMass,
|
|
@@ -3575,22 +3619,22 @@ class jt {
|
|
|
3575
3619
|
});
|
|
3576
3620
|
e.forEach((n, a) => {
|
|
3577
3621
|
const h = this.calculateForceForNode(
|
|
3578
|
-
|
|
3622
|
+
o.getLeaf(a),
|
|
3579
3623
|
a,
|
|
3580
3624
|
e
|
|
3581
3625
|
), d = t.get(a);
|
|
3582
3626
|
this.applyForce(d, h);
|
|
3583
3627
|
});
|
|
3584
3628
|
}
|
|
3585
|
-
calculateForceForNode(e, t,
|
|
3586
|
-
const
|
|
3629
|
+
calculateForceForNode(e, t, s) {
|
|
3630
|
+
const o = s.get(t), n = { x: 0, y: 0 };
|
|
3587
3631
|
e.nodeIds.forEach((h) => {
|
|
3588
3632
|
if (h !== t) {
|
|
3589
|
-
const d =
|
|
3633
|
+
const d = s.get(h), c = this.calculateNodeRepulsiveForce({
|
|
3590
3634
|
sourceCharge: this.nodeCharge,
|
|
3591
3635
|
targetCharge: this.nodeCharge,
|
|
3592
3636
|
sourceCoords: d,
|
|
3593
|
-
targetCoords:
|
|
3637
|
+
targetCoords: o
|
|
3594
3638
|
});
|
|
3595
3639
|
this.applyForce(n, c);
|
|
3596
3640
|
}
|
|
@@ -3601,73 +3645,73 @@ class jt {
|
|
|
3601
3645
|
if (h !== null) {
|
|
3602
3646
|
const d = this.distanceVectorGenerator.create(
|
|
3603
3647
|
h.chargeCenter,
|
|
3604
|
-
|
|
3648
|
+
o
|
|
3605
3649
|
);
|
|
3606
3650
|
h.box.radius * 2 < d.d * this.theta ? (this.tryApplyFarForce({
|
|
3607
3651
|
totalForce: n,
|
|
3608
|
-
targetCoords:
|
|
3652
|
+
targetCoords: o,
|
|
3609
3653
|
target: h.lb,
|
|
3610
3654
|
current: a
|
|
3611
3655
|
}), this.tryApplyFarForce({
|
|
3612
3656
|
totalForce: n,
|
|
3613
|
-
targetCoords:
|
|
3657
|
+
targetCoords: o,
|
|
3614
3658
|
target: h.rb,
|
|
3615
3659
|
current: a
|
|
3616
3660
|
}), this.tryApplyFarForce({
|
|
3617
3661
|
totalForce: n,
|
|
3618
|
-
targetCoords:
|
|
3662
|
+
targetCoords: o,
|
|
3619
3663
|
target: h.rt,
|
|
3620
3664
|
current: a
|
|
3621
3665
|
}), this.tryApplyFarForce({
|
|
3622
3666
|
totalForce: n,
|
|
3623
|
-
targetCoords:
|
|
3667
|
+
targetCoords: o,
|
|
3624
3668
|
target: h.lt,
|
|
3625
3669
|
current: a
|
|
3626
3670
|
})) : (this.tryApplyNearForce({
|
|
3627
3671
|
totalForce: n,
|
|
3628
|
-
targetCoords:
|
|
3672
|
+
targetCoords: o,
|
|
3629
3673
|
target: h.lb,
|
|
3630
3674
|
current: a,
|
|
3631
|
-
nodesCoords:
|
|
3675
|
+
nodesCoords: s
|
|
3632
3676
|
}), this.tryApplyNearForce({
|
|
3633
3677
|
totalForce: n,
|
|
3634
|
-
targetCoords:
|
|
3678
|
+
targetCoords: o,
|
|
3635
3679
|
target: h.rb,
|
|
3636
3680
|
current: a,
|
|
3637
|
-
nodesCoords:
|
|
3681
|
+
nodesCoords: s
|
|
3638
3682
|
}), this.tryApplyNearForce({
|
|
3639
3683
|
totalForce: n,
|
|
3640
|
-
targetCoords:
|
|
3684
|
+
targetCoords: o,
|
|
3641
3685
|
target: h.rt,
|
|
3642
3686
|
current: a,
|
|
3643
|
-
nodesCoords:
|
|
3687
|
+
nodesCoords: s
|
|
3644
3688
|
}), this.tryApplyNearForce({
|
|
3645
3689
|
totalForce: n,
|
|
3646
|
-
targetCoords:
|
|
3690
|
+
targetCoords: o,
|
|
3647
3691
|
target: h.lt,
|
|
3648
3692
|
current: a,
|
|
3649
|
-
nodesCoords:
|
|
3693
|
+
nodesCoords: s
|
|
3650
3694
|
}));
|
|
3651
3695
|
}
|
|
3652
3696
|
a = a.parent;
|
|
3653
3697
|
}
|
|
3654
3698
|
return n;
|
|
3655
3699
|
}
|
|
3656
|
-
calculateExactForce(e, t,
|
|
3657
|
-
const
|
|
3700
|
+
calculateExactForce(e, t, s) {
|
|
3701
|
+
const o = { x: 0, y: 0 }, n = [e];
|
|
3658
3702
|
for (; n.length > 0; ) {
|
|
3659
3703
|
const a = n.pop();
|
|
3660
3704
|
a.nodeIds.forEach((h) => {
|
|
3661
|
-
const d =
|
|
3705
|
+
const d = s.get(h), c = this.calculateNodeRepulsiveForce({
|
|
3662
3706
|
sourceCharge: this.nodeCharge,
|
|
3663
3707
|
targetCharge: this.nodeCharge,
|
|
3664
3708
|
sourceCoords: d,
|
|
3665
3709
|
targetCoords: t
|
|
3666
3710
|
});
|
|
3667
|
-
this.applyForce(
|
|
3711
|
+
this.applyForce(o, c);
|
|
3668
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);
|
|
3669
3713
|
}
|
|
3670
|
-
return
|
|
3714
|
+
return o;
|
|
3671
3715
|
}
|
|
3672
3716
|
calculateApproximateForce(e, t) {
|
|
3673
3717
|
return this.calculateNodeRepulsiveForce({
|
|
@@ -3681,7 +3725,7 @@ class jt {
|
|
|
3681
3725
|
const t = this.distanceVectorGenerator.create(
|
|
3682
3726
|
e.sourceCoords,
|
|
3683
3727
|
e.targetCoords
|
|
3684
|
-
),
|
|
3728
|
+
), s = $e({
|
|
3685
3729
|
coefficient: this.nodeForceCoefficient,
|
|
3686
3730
|
sourceCharge: e.sourceCharge,
|
|
3687
3731
|
targetCharge: e.targetCharge,
|
|
@@ -3689,8 +3733,8 @@ class jt {
|
|
|
3689
3733
|
maxForce: this.maxForce
|
|
3690
3734
|
});
|
|
3691
3735
|
return {
|
|
3692
|
-
x:
|
|
3693
|
-
y:
|
|
3736
|
+
x: s * t.ex,
|
|
3737
|
+
y: s * t.ey
|
|
3694
3738
|
};
|
|
3695
3739
|
}
|
|
3696
3740
|
applyForce(e, t) {
|
|
@@ -3738,17 +3782,17 @@ class Be {
|
|
|
3738
3782
|
this.rand = e.rand, this.sparsity = e.sparsity;
|
|
3739
3783
|
}
|
|
3740
3784
|
calculateCoordinates(e, t) {
|
|
3741
|
-
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 = {
|
|
3742
3786
|
x: c.x - g,
|
|
3743
3787
|
y: c.y - g
|
|
3744
3788
|
};
|
|
3745
|
-
return
|
|
3789
|
+
return o.forEach((u) => {
|
|
3746
3790
|
const w = e.getNode(u);
|
|
3747
|
-
|
|
3791
|
+
s.set(u, {
|
|
3748
3792
|
x: w.x ?? l.x + n * this.rand(),
|
|
3749
3793
|
y: w.y ?? l.y + n * this.rand()
|
|
3750
3794
|
});
|
|
3751
|
-
}),
|
|
3795
|
+
}), s;
|
|
3752
3796
|
}
|
|
3753
3797
|
}
|
|
3754
3798
|
class qt {
|
|
@@ -3778,14 +3822,14 @@ class qt {
|
|
|
3778
3822
|
});
|
|
3779
3823
|
}
|
|
3780
3824
|
calculateCoordinates(e, t) {
|
|
3781
|
-
const
|
|
3825
|
+
const s = this.fillerLayoutAlgorithm.calculateCoordinates(
|
|
3782
3826
|
e,
|
|
3783
3827
|
t
|
|
3784
3828
|
);
|
|
3785
|
-
for (let
|
|
3829
|
+
for (let o = 0; o < this.maxIterations; o++) {
|
|
3786
3830
|
const n = new Fe(
|
|
3787
3831
|
e,
|
|
3788
|
-
|
|
3832
|
+
s,
|
|
3789
3833
|
{
|
|
3790
3834
|
distanceVectorGenerator: this.distanceVectorGenerator,
|
|
3791
3835
|
nodeForcesApplicationStrategy: this.nodeForcesApplicationStrategy,
|
|
@@ -3798,7 +3842,7 @@ class qt {
|
|
|
3798
3842
|
if (a < this.convergenceDelta || h < this.convergenceVelocity)
|
|
3799
3843
|
break;
|
|
3800
3844
|
}
|
|
3801
|
-
return
|
|
3845
|
+
return s;
|
|
3802
3846
|
}
|
|
3803
3847
|
}
|
|
3804
3848
|
class Kt {
|
|
@@ -3826,13 +3870,13 @@ class Kt {
|
|
|
3826
3870
|
sparsity: e.edgeEquilibriumLength
|
|
3827
3871
|
});
|
|
3828
3872
|
}
|
|
3829
|
-
calculateNextCoordinates(e, t,
|
|
3830
|
-
const
|
|
3873
|
+
calculateNextCoordinates(e, t, s) {
|
|
3874
|
+
const o = this.fillerLayoutAlgorithm.calculateCoordinates(
|
|
3831
3875
|
e,
|
|
3832
|
-
|
|
3876
|
+
s
|
|
3833
3877
|
), n = new Fe(
|
|
3834
3878
|
e,
|
|
3835
|
-
|
|
3879
|
+
o,
|
|
3836
3880
|
{
|
|
3837
3881
|
distanceVectorGenerator: this.distanceVectorGenerator,
|
|
3838
3882
|
nodeForcesApplicationStrategy: this.nodeForcesApplicationStrategy,
|
|
@@ -3845,18 +3889,18 @@ class Kt {
|
|
|
3845
3889
|
return (a < this.convergenceDelta || h < this.convergenceVelocity) && !e.getAllNodeIds().some((c) => {
|
|
3846
3890
|
const g = e.getNode(c);
|
|
3847
3891
|
return g.x === null || g.y === null;
|
|
3848
|
-
}) ? /* @__PURE__ */ new Map() :
|
|
3892
|
+
}) ? /* @__PURE__ */ new Map() : o;
|
|
3849
3893
|
}
|
|
3850
3894
|
}
|
|
3851
3895
|
const Oe = (r) => {
|
|
3852
|
-
let e = 1779033703, t = 3144134277,
|
|
3896
|
+
let e = 1779033703, t = 3144134277, s = 1013904242, o = 2773480762;
|
|
3853
3897
|
for (let n = 0, a; n < r.length; n++)
|
|
3854
|
-
a = r.charCodeAt(n), e = t ^ Math.imul(e ^ a, 597399067), t =
|
|
3855
|
-
return e = Math.imul(
|
|
3856
|
-
}, We = (r, e, t,
|
|
3857
|
-
r |= 0, e |= 0, t |= 0,
|
|
3858
|
-
const
|
|
3859
|
-
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;
|
|
3860
3904
|
}, v = Object.freeze({
|
|
3861
3905
|
seed: "HTMLGraph is awesome",
|
|
3862
3906
|
maxTimeDeltaSec: 0.01,
|
|
@@ -3874,26 +3918,26 @@ const Oe = (r) => {
|
|
|
3874
3918
|
barnesHutAreaRadiusThreshold: 0.01,
|
|
3875
3919
|
barnesHutTheta: 1
|
|
3876
3920
|
}), Qt = (r) => {
|
|
3877
|
-
var e, t,
|
|
3921
|
+
var e, t, s;
|
|
3878
3922
|
switch ((e = r == null ? void 0 : r.algorithm) == null ? void 0 : e.type) {
|
|
3879
3923
|
case "custom":
|
|
3880
3924
|
return r.algorithm.instance;
|
|
3881
3925
|
default: {
|
|
3882
|
-
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]);
|
|
3883
3927
|
return new Kt({
|
|
3884
3928
|
rand: a,
|
|
3885
|
-
maxTimeDeltaSec: (
|
|
3886
|
-
nodeCharge: (
|
|
3887
|
-
nodeMass: (
|
|
3888
|
-
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,
|
|
3889
3933
|
effectiveDistance: v.effectiveDistance,
|
|
3890
|
-
edgeStiffness: (
|
|
3891
|
-
convergenceDelta: (
|
|
3892
|
-
convergenceVelocity: (
|
|
3893
|
-
maxForce: (
|
|
3894
|
-
nodeForceCoefficient: (
|
|
3895
|
-
barnesHutTheta: ((t =
|
|
3896
|
-
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
|
|
3897
3941
|
});
|
|
3898
3942
|
}
|
|
3899
3943
|
}
|
|
@@ -3912,11 +3956,11 @@ const Oe = (r) => {
|
|
|
3912
3956
|
case "custom":
|
|
3913
3957
|
return r.instance;
|
|
3914
3958
|
default: {
|
|
3915
|
-
const
|
|
3959
|
+
const s = Oe((r == null ? void 0 : r.seed) ?? v.seed), o = We(s[0], s[1], s[2], s[3]);
|
|
3916
3960
|
return new qt({
|
|
3917
3961
|
dtSec: (r == null ? void 0 : r.dtSec) ?? v.dtSec,
|
|
3918
3962
|
maxIterations: (r == null ? void 0 : r.maxIterations) ?? v.maxIterations,
|
|
3919
|
-
rand:
|
|
3963
|
+
rand: o,
|
|
3920
3964
|
nodeCharge: (r == null ? void 0 : r.nodeCharge) ?? v.nodeCharge,
|
|
3921
3965
|
nodeMass: (r == null ? void 0 : r.nodeMass) ?? v.nodeMass,
|
|
3922
3966
|
edgeEquilibriumLength: (r == null ? void 0 : r.edgeEquilibriumLength) ?? v.edgeEquilibriumLength,
|
|
@@ -3949,7 +3993,7 @@ const Oe = (r) => {
|
|
|
3949
3993
|
e.clear();
|
|
3950
3994
|
});
|
|
3951
3995
|
};
|
|
3952
|
-
class
|
|
3996
|
+
class or {
|
|
3953
3997
|
constructor(e) {
|
|
3954
3998
|
i(this, "used", !1);
|
|
3955
3999
|
i(this, "canvasDefaults", {});
|
|
@@ -4046,25 +4090,25 @@ class sr {
|
|
|
4046
4090
|
if (this.used)
|
|
4047
4091
|
throw new Ht("CanvasBuilder is a single use object");
|
|
4048
4092
|
this.used = !0;
|
|
4049
|
-
const e = new
|
|
4093
|
+
const e = new Nt(this.element), t = this.createHtmlView(e.main), s = Lt(this.canvasDefaults), o = new ve(
|
|
4050
4094
|
this.graph,
|
|
4051
4095
|
this.viewport,
|
|
4052
4096
|
this.graphStore,
|
|
4053
4097
|
this.viewportStore,
|
|
4054
4098
|
t,
|
|
4055
|
-
|
|
4099
|
+
s
|
|
4056
4100
|
);
|
|
4057
4101
|
if (this.hasBackground && _.configure(
|
|
4058
|
-
|
|
4102
|
+
o,
|
|
4059
4103
|
Bt(this.backgroundConfig),
|
|
4060
4104
|
e.background
|
|
4061
|
-
), this.hasNodeResizeReactiveEdges && q.configure(
|
|
4105
|
+
), this.hasNodeResizeReactiveEdges && q.configure(o), this.hasDraggableNodes) {
|
|
4062
4106
|
let a = Rt(this.dragConfig);
|
|
4063
4107
|
this.hasAnimatedLayout && (a = er(
|
|
4064
4108
|
a,
|
|
4065
4109
|
this.animationStaticNodes
|
|
4066
4110
|
)), Z.configure(
|
|
4067
|
-
|
|
4111
|
+
o,
|
|
4068
4112
|
e.main,
|
|
4069
4113
|
this.window,
|
|
4070
4114
|
a
|
|
@@ -4073,11 +4117,11 @@ class sr {
|
|
|
4073
4117
|
if (this.hasUserConnectablePorts) {
|
|
4074
4118
|
const a = Ot(
|
|
4075
4119
|
this.connectablePortsConfig,
|
|
4076
|
-
|
|
4077
|
-
|
|
4120
|
+
s.edges.shapeFactory,
|
|
4121
|
+
s.ports.direction
|
|
4078
4122
|
);
|
|
4079
4123
|
ee.configure(
|
|
4080
|
-
|
|
4124
|
+
o,
|
|
4081
4125
|
e.overlayConnectablePorts,
|
|
4082
4126
|
this.viewportStore,
|
|
4083
4127
|
this.window,
|
|
@@ -4087,10 +4131,10 @@ class sr {
|
|
|
4087
4131
|
if (this.hasUserDraggableEdges) {
|
|
4088
4132
|
const a = Wt(
|
|
4089
4133
|
this.draggableEdgesConfig,
|
|
4090
|
-
|
|
4134
|
+
o.graph
|
|
4091
4135
|
);
|
|
4092
4136
|
te.configure(
|
|
4093
|
-
|
|
4137
|
+
o,
|
|
4094
4138
|
e.overlayDraggableEdges,
|
|
4095
4139
|
this.viewportStore,
|
|
4096
4140
|
this.window,
|
|
@@ -4098,33 +4142,33 @@ class sr {
|
|
|
4098
4142
|
);
|
|
4099
4143
|
}
|
|
4100
4144
|
this.virtualScrollConfig !== void 0 ? J.configure(
|
|
4101
|
-
|
|
4145
|
+
o,
|
|
4102
4146
|
e.main,
|
|
4103
4147
|
this.window,
|
|
4104
4148
|
ye(this.transformConfig),
|
|
4105
4149
|
this.boxRenderingTrigger,
|
|
4106
4150
|
kt(this.virtualScrollConfig)
|
|
4107
4151
|
) : this.hasTransformableViewport && H.configure(
|
|
4108
|
-
|
|
4152
|
+
o,
|
|
4109
4153
|
e.main,
|
|
4110
4154
|
this.window,
|
|
4111
4155
|
ye(this.transformConfig)
|
|
4112
4156
|
), this.hasLayout && Pt.configure(
|
|
4113
|
-
|
|
4157
|
+
o,
|
|
4114
4158
|
_t(this.layoutConfig)
|
|
4115
4159
|
), this.hasAnimatedLayout && (tr(
|
|
4116
|
-
|
|
4160
|
+
o.graph,
|
|
4117
4161
|
this.animationStaticNodes
|
|
4118
|
-
),
|
|
4119
|
-
|
|
4162
|
+
), se.configure(
|
|
4163
|
+
o,
|
|
4120
4164
|
Qt(this.animatedLayoutConfig),
|
|
4121
4165
|
this.animationStaticNodes,
|
|
4122
4166
|
this.window
|
|
4123
4167
|
));
|
|
4124
4168
|
const n = () => {
|
|
4125
|
-
e.destroy(),
|
|
4169
|
+
e.destroy(), o.onBeforeDestroy.unsubscribe(n);
|
|
4126
4170
|
};
|
|
4127
|
-
return
|
|
4171
|
+
return o.onBeforeDestroy.subscribe(n), o;
|
|
4128
4172
|
}
|
|
4129
4173
|
createHtmlView(e) {
|
|
4130
4174
|
let t = new me(
|
|
@@ -4142,16 +4186,16 @@ class sr {
|
|
|
4142
4186
|
}
|
|
4143
4187
|
export {
|
|
4144
4188
|
ut as BezierEdgeShape,
|
|
4145
|
-
|
|
4189
|
+
or as CanvasBuilder,
|
|
4146
4190
|
Ht as CanvasBuilderError,
|
|
4147
4191
|
b as CanvasError,
|
|
4148
4192
|
M as ConnectionCategory,
|
|
4149
|
-
|
|
4193
|
+
De as DirectEdgeShape,
|
|
4150
4194
|
j as EventSubject,
|
|
4151
4195
|
pt as HorizontalEdgeShape,
|
|
4152
4196
|
vt as InteractiveEdgeError,
|
|
4153
4197
|
Me as InteractiveEdgeShape,
|
|
4154
|
-
|
|
4198
|
+
sr as MidpointEdgeShape,
|
|
4155
4199
|
wt as StraightEdgeShape,
|
|
4156
4200
|
ft as VerticalEdgeShape
|
|
4157
4201
|
};
|