@html-graph/html-graph 7.8.0 → 8.0.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 +39 -56
- package/dist/html-graph.js +786 -778
- 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));
|
|
@@ -259,7 +259,7 @@ class j {
|
|
|
259
259
|
});
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
|
-
const
|
|
262
|
+
const x = () => {
|
|
263
263
|
const r = new j();
|
|
264
264
|
return [r, r];
|
|
265
265
|
};
|
|
@@ -279,29 +279,29 @@ class X {
|
|
|
279
279
|
this.counter = 0;
|
|
280
280
|
}
|
|
281
281
|
}
|
|
282
|
-
class
|
|
282
|
+
class A extends Error {
|
|
283
283
|
constructor() {
|
|
284
284
|
super(...arguments);
|
|
285
285
|
i(this, "name", "CanvasError");
|
|
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((t) => {
|
|
304
|
+
this.htmlView.renderEdge(t);
|
|
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((t) => {
|
|
317
|
+
this.htmlView.renderEdge(t);
|
|
318
318
|
});
|
|
319
319
|
});
|
|
320
320
|
i(this, "onBeforePortUnmarked", (e) => {
|
|
@@ -346,23 +346,23 @@ 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
|
|
353
353
|
), this.graphStore.onAfterEdgeUpdated.subscribe(this.onAfterEdgeUpdated), this.graphStore.onAfterEdgePriorityUpdated.subscribe(
|
|
354
354
|
this.onAfterEdgePriorityUpdated
|
|
355
|
-
), this.graphStore.onBeforeEdgeRemoved.subscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.subscribe(this.onBeforeClear), [this.onBeforeDestroyEmitter, this.onBeforeDestroy] =
|
|
355
|
+
), this.graphStore.onBeforeEdgeRemoved.subscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.subscribe(this.onBeforeClear), [this.onBeforeDestroyEmitter, this.onBeforeDestroy] = x();
|
|
356
356
|
}
|
|
357
357
|
/**
|
|
358
358
|
* adds new node
|
|
359
359
|
*/
|
|
360
360
|
addNode(e) {
|
|
361
361
|
const t = this.nodeIdGenerator.create(e.id);
|
|
362
|
-
if (this.graphStore.
|
|
363
|
-
throw new
|
|
364
|
-
if (this.graphStore.
|
|
365
|
-
throw new
|
|
362
|
+
if (this.graphStore.hasNode(t))
|
|
363
|
+
throw new A("failed to add node with existing id");
|
|
364
|
+
if (this.graphStore.findNodeIdByElement(e.element) !== void 0)
|
|
365
|
+
throw new A(
|
|
366
366
|
"failed to add node with html element already in use by another node"
|
|
367
367
|
);
|
|
368
368
|
if (this.graphStore.addNode({
|
|
@@ -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,8 +386,8 @@ class ve {
|
|
|
386
386
|
* updates node parameters
|
|
387
387
|
*/
|
|
388
388
|
updateNode(e, t) {
|
|
389
|
-
if (this.graphStore.
|
|
390
|
-
throw new
|
|
389
|
+
if (!this.graphStore.hasNode(e))
|
|
390
|
+
throw new A("failed to update nonexistent node");
|
|
391
391
|
return this.graphStore.updateNode(e, t ?? {}), this;
|
|
392
392
|
}
|
|
393
393
|
/**
|
|
@@ -396,8 +396,8 @@ class ve {
|
|
|
396
396
|
* all the edges adjacent to node get removed
|
|
397
397
|
*/
|
|
398
398
|
removeNode(e) {
|
|
399
|
-
if (this.graphStore.
|
|
400
|
-
throw new
|
|
399
|
+
if (!this.graphStore.hasNode(e))
|
|
400
|
+
throw new A("failed to remove nonexistent node");
|
|
401
401
|
return this.graphStore.removeNode(e), this;
|
|
402
402
|
}
|
|
403
403
|
/**
|
|
@@ -405,10 +405,10 @@ class ve {
|
|
|
405
405
|
*/
|
|
406
406
|
markPort(e) {
|
|
407
407
|
const t = this.portIdGenerator.create(e.id);
|
|
408
|
-
if (this.graphStore.
|
|
409
|
-
throw new
|
|
410
|
-
if (this.graphStore.
|
|
411
|
-
throw new
|
|
408
|
+
if (this.graphStore.hasPort(t))
|
|
409
|
+
throw new A("failed to add port with existing id");
|
|
410
|
+
if (!this.graphStore.hasNode(e.nodeId))
|
|
411
|
+
throw new A("failed to mark port for nonexistent node");
|
|
412
412
|
return this.graphStore.addPort({
|
|
413
413
|
id: t,
|
|
414
414
|
element: e.element,
|
|
@@ -420,8 +420,8 @@ class ve {
|
|
|
420
420
|
* updates port and edges attached to it
|
|
421
421
|
*/
|
|
422
422
|
updatePort(e, t) {
|
|
423
|
-
if (this.graphStore.
|
|
424
|
-
throw new
|
|
423
|
+
if (!this.graphStore.hasPort(e))
|
|
424
|
+
throw new A("failed to update nonexistent port");
|
|
425
425
|
return this.graphStore.updatePort(e, t ?? {}), this;
|
|
426
426
|
}
|
|
427
427
|
/**
|
|
@@ -429,8 +429,8 @@ class ve {
|
|
|
429
429
|
* all the edges adjacent to the port get removed
|
|
430
430
|
*/
|
|
431
431
|
unmarkPort(e) {
|
|
432
|
-
if (this.graphStore.
|
|
433
|
-
throw new
|
|
432
|
+
if (!this.graphStore.hasPort(e))
|
|
433
|
+
throw new A("failed to unmark nonexistent port");
|
|
434
434
|
return this.graphStore.removePort(e), this;
|
|
435
435
|
}
|
|
436
436
|
/**
|
|
@@ -438,12 +438,12 @@ class ve {
|
|
|
438
438
|
*/
|
|
439
439
|
addEdge(e) {
|
|
440
440
|
const t = this.edgeIdGenerator.create(e.id);
|
|
441
|
-
if (this.graphStore.
|
|
442
|
-
throw new
|
|
443
|
-
if (this.graphStore.
|
|
444
|
-
throw new
|
|
445
|
-
if (this.graphStore.
|
|
446
|
-
throw new
|
|
441
|
+
if (this.graphStore.hasEdge(t))
|
|
442
|
+
throw new A("failed to add edge with existing id");
|
|
443
|
+
if (!this.graphStore.hasPort(e.from))
|
|
444
|
+
throw new A("failed to add edge from nonexistent port");
|
|
445
|
+
if (!this.graphStore.hasPort(e.to))
|
|
446
|
+
throw new A("failed to add edge to nonexistent port");
|
|
447
447
|
return this.graphStore.addEdge({
|
|
448
448
|
id: t,
|
|
449
449
|
from: e.from,
|
|
@@ -456,16 +456,16 @@ class ve {
|
|
|
456
456
|
* updates specified edge
|
|
457
457
|
*/
|
|
458
458
|
updateEdge(e, t) {
|
|
459
|
-
if (this.graphStore.
|
|
460
|
-
throw new
|
|
459
|
+
if (!this.graphStore.hasEdge(e))
|
|
460
|
+
throw new A("failed to update nonexistent edge");
|
|
461
461
|
return this.graphStore.updateEdge(e, t ?? {}), this;
|
|
462
462
|
}
|
|
463
463
|
/**
|
|
464
464
|
* removes specified edge
|
|
465
465
|
*/
|
|
466
466
|
removeEdge(e) {
|
|
467
|
-
if (this.graphStore.
|
|
468
|
-
throw new
|
|
467
|
+
if (!this.graphStore.hasEdge(e))
|
|
468
|
+
throw new A("failed to remove nonexistent edge");
|
|
469
469
|
return this.graphStore.removeEdge(e), this;
|
|
470
470
|
}
|
|
471
471
|
/**
|
|
@@ -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) {
|
|
@@ -577,10 +577,19 @@ class Ae {
|
|
|
577
577
|
i(this, "onBeforeEdgeRemoved");
|
|
578
578
|
i(this, "beforeClearEmitter");
|
|
579
579
|
i(this, "onBeforeClear");
|
|
580
|
-
[this.afterNodeAddedEmitter, this.onAfterNodeAdded] =
|
|
580
|
+
[this.afterNodeAddedEmitter, this.onAfterNodeAdded] = x(), [this.afterNodeUpdatedEmitter, this.onAfterNodeUpdated] = x(), [this.afterNodePriorityUpdatedEmitter, this.onAfterNodePriorityUpdated] = x(), [this.beforeNodeRemovedEmitter, this.onBeforeNodeRemoved] = x(), [this.afterPortAddedEmitter, this.onAfterPortAdded] = x(), [this.afterPortUpdatedEmitter, this.onAfterPortUpdated] = x(), [this.beforePortRemovedEmitter, this.onBeforePortRemoved] = x(), [this.afterEdgeAddedEmitter, this.onAfterEdgeAdded] = x(), [this.afterEdgeShapeUpdatedEmitter, this.onAfterEdgeShapeUpdated] = x(), [this.afterEdgeUpdatedEmitter, this.onAfterEdgeUpdated] = x(), [this.afterEdgePriorityUpdatedEmitter, this.onAfterEdgePriorityUpdated] = x(), [this.beforeEdgeRemovedEmitter, this.onBeforeEdgeRemoved] = x(), [this.beforeClearEmitter, this.onBeforeClear] = x();
|
|
581
|
+
}
|
|
582
|
+
hasNode(e) {
|
|
583
|
+
return this.nodes.has(e);
|
|
584
|
+
}
|
|
585
|
+
getNode(e) {
|
|
586
|
+
const t = this.nodes.get(e);
|
|
587
|
+
if (t === void 0)
|
|
588
|
+
throw new A("failed to access nonexistent node");
|
|
589
|
+
return t;
|
|
581
590
|
}
|
|
582
591
|
addNode(e) {
|
|
583
|
-
const t = /* @__PURE__ */ new Map(),
|
|
592
|
+
const t = /* @__PURE__ */ new Map(), s = {
|
|
584
593
|
element: e.element,
|
|
585
594
|
payload: {
|
|
586
595
|
x: e.x,
|
|
@@ -590,26 +599,32 @@ class Ae {
|
|
|
590
599
|
},
|
|
591
600
|
ports: t
|
|
592
601
|
};
|
|
593
|
-
this.nodes.set(e.id,
|
|
602
|
+
this.nodes.set(e.id, s), this.nodesElementsMap.set(e.element, e.id), this.afterNodeAddedEmitter.emit(e.id);
|
|
594
603
|
}
|
|
595
604
|
getAllNodeIds() {
|
|
596
605
|
return Array.from(this.nodes.keys());
|
|
597
606
|
}
|
|
598
|
-
|
|
599
|
-
return this.nodes.get(e);
|
|
600
|
-
}
|
|
601
|
-
getElementNodeId(e) {
|
|
607
|
+
findNodeIdByElement(e) {
|
|
602
608
|
return this.nodesElementsMap.get(e);
|
|
603
609
|
}
|
|
604
610
|
updateNode(e, t) {
|
|
605
|
-
const
|
|
606
|
-
|
|
611
|
+
const { payload: s } = this.nodes.get(e);
|
|
612
|
+
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
613
|
}
|
|
608
614
|
removeNode(e) {
|
|
609
615
|
this.beforeNodeRemovedEmitter.emit(e);
|
|
610
616
|
const t = this.nodes.get(e);
|
|
611
617
|
this.nodesElementsMap.delete(t.element), this.nodes.delete(e);
|
|
612
618
|
}
|
|
619
|
+
hasPort(e) {
|
|
620
|
+
return this.ports.has(e);
|
|
621
|
+
}
|
|
622
|
+
getPort(e) {
|
|
623
|
+
const t = this.ports.get(e);
|
|
624
|
+
if (t === void 0)
|
|
625
|
+
throw new A("failed to access nonexistent port");
|
|
626
|
+
return t;
|
|
627
|
+
}
|
|
613
628
|
addPort(e) {
|
|
614
629
|
this.ports.set(e.id, {
|
|
615
630
|
element: e.element,
|
|
@@ -619,51 +634,55 @@ class Ae {
|
|
|
619
634
|
nodeId: e.nodeId
|
|
620
635
|
}), 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
636
|
}
|
|
622
|
-
getPort(e) {
|
|
623
|
-
return this.ports.get(e);
|
|
624
|
-
}
|
|
625
637
|
updatePort(e, t) {
|
|
626
|
-
const
|
|
627
|
-
|
|
638
|
+
const s = this.ports.get(e).payload;
|
|
639
|
+
s.direction = t.direction ?? s.direction, this.afterPortUpdatedEmitter.emit(e);
|
|
628
640
|
}
|
|
629
641
|
getAllPortIds() {
|
|
630
642
|
return Array.from(this.ports.keys());
|
|
631
643
|
}
|
|
632
|
-
|
|
644
|
+
findPortIdsByElement(e) {
|
|
633
645
|
return this.elementPorts.getMultiBySingle(e);
|
|
634
646
|
}
|
|
635
647
|
getNodePortIds(e) {
|
|
636
648
|
const t = this.nodes.get(e);
|
|
637
|
-
if (t
|
|
638
|
-
|
|
649
|
+
if (t === void 0)
|
|
650
|
+
throw new A("failed to access port ids of nonexistent node");
|
|
651
|
+
return Array.from(t.ports.keys());
|
|
639
652
|
}
|
|
640
653
|
removePort(e) {
|
|
641
654
|
const t = this.ports.get(e).nodeId;
|
|
642
655
|
this.beforePortRemovedEmitter.emit(e), this.nodes.get(t).ports.delete(e), this.ports.delete(e), this.elementPorts.removeByMulti(e);
|
|
643
656
|
}
|
|
657
|
+
hasEdge(e) {
|
|
658
|
+
return this.edges.has(e);
|
|
659
|
+
}
|
|
660
|
+
getEdge(e) {
|
|
661
|
+
const t = this.edges.get(e);
|
|
662
|
+
if (t === void 0)
|
|
663
|
+
throw new A("failed to access nonexistent edge");
|
|
664
|
+
return t;
|
|
665
|
+
}
|
|
644
666
|
addEdge(e) {
|
|
645
667
|
this.addEdgeInternal(e), this.afterEdgeAddedEmitter.emit(e.id);
|
|
646
668
|
}
|
|
647
669
|
updateEdge(e, t) {
|
|
648
670
|
if (t.from !== void 0 || t.to !== void 0) {
|
|
649
|
-
const
|
|
671
|
+
const o = this.edges.get(e), n = o.payload;
|
|
650
672
|
this.removeEdgeInternal(e), this.addEdgeInternal({
|
|
651
673
|
id: e,
|
|
652
|
-
from: t.from ??
|
|
653
|
-
to: t.to ??
|
|
674
|
+
from: t.from ?? o.from,
|
|
675
|
+
to: t.to ?? o.to,
|
|
654
676
|
shape: n.shape,
|
|
655
677
|
priority: n.priority
|
|
656
678
|
});
|
|
657
679
|
}
|
|
658
|
-
const
|
|
659
|
-
t.shape !== void 0 && (
|
|
680
|
+
const s = this.edges.get(e);
|
|
681
|
+
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
682
|
}
|
|
661
683
|
getAllEdgeIds() {
|
|
662
684
|
return Array.from(this.edges.keys());
|
|
663
685
|
}
|
|
664
|
-
getEdge(e) {
|
|
665
|
-
return this.edges.get(e);
|
|
666
|
-
}
|
|
667
686
|
removeEdge(e) {
|
|
668
687
|
this.beforeEdgeRemovedEmitter.emit(e), this.removeEdgeInternal(e);
|
|
669
688
|
}
|
|
@@ -671,13 +690,22 @@ class Ae {
|
|
|
671
690
|
this.beforeClearEmitter.emit(), this.portIncomingEdges.clear(), this.portOutcomingEdges.clear(), this.portCycleEdges.clear(), this.elementPorts.clear(), this.nodesElementsMap.clear(), this.edges.clear(), this.ports.clear(), this.nodes.clear();
|
|
672
691
|
}
|
|
673
692
|
getPortIncomingEdgeIds(e) {
|
|
674
|
-
|
|
693
|
+
const t = this.portIncomingEdges.get(e);
|
|
694
|
+
if (t === void 0)
|
|
695
|
+
throw new A("failed to access edges for nonexistent port");
|
|
696
|
+
return Array.from(t);
|
|
675
697
|
}
|
|
676
698
|
getPortOutgoingEdgeIds(e) {
|
|
677
|
-
|
|
699
|
+
const t = this.portOutcomingEdges.get(e);
|
|
700
|
+
if (t === void 0)
|
|
701
|
+
throw new A("failed to access edges for nonexistent port");
|
|
702
|
+
return Array.from(t);
|
|
678
703
|
}
|
|
679
704
|
getPortCycleEdgeIds(e) {
|
|
680
|
-
|
|
705
|
+
const t = this.portCycleEdges.get(e);
|
|
706
|
+
if (t === void 0)
|
|
707
|
+
throw new A("failed to access edges for nonexistent port");
|
|
708
|
+
return Array.from(t);
|
|
681
709
|
}
|
|
682
710
|
getPortAdjacentEdgeIds(e) {
|
|
683
711
|
return [
|
|
@@ -687,51 +715,51 @@ class Ae {
|
|
|
687
715
|
];
|
|
688
716
|
}
|
|
689
717
|
getNodeIncomingEdgeIds(e) {
|
|
690
|
-
const t = Array.from(this.
|
|
691
|
-
return t.forEach((
|
|
692
|
-
this.getPortIncomingEdgeIds(
|
|
718
|
+
const t = Array.from(this.getNode(e).ports.keys()), s = [];
|
|
719
|
+
return t.forEach((o) => {
|
|
720
|
+
this.getPortIncomingEdgeIds(o).filter((n) => {
|
|
693
721
|
const a = this.getEdge(n);
|
|
694
722
|
return this.getPort(a.from).nodeId !== e;
|
|
695
723
|
}).forEach((n) => {
|
|
696
|
-
|
|
724
|
+
s.push(n);
|
|
697
725
|
});
|
|
698
|
-
}),
|
|
726
|
+
}), s;
|
|
699
727
|
}
|
|
700
728
|
getNodeOutgoingEdgeIds(e) {
|
|
701
|
-
const t = Array.from(this.
|
|
702
|
-
return t.forEach((
|
|
703
|
-
this.getPortOutgoingEdgeIds(
|
|
729
|
+
const t = Array.from(this.getNode(e).ports.keys()), s = [];
|
|
730
|
+
return t.forEach((o) => {
|
|
731
|
+
this.getPortOutgoingEdgeIds(o).filter((n) => {
|
|
704
732
|
const a = this.getEdge(n);
|
|
705
733
|
return this.getPort(a.to).nodeId !== e;
|
|
706
734
|
}).forEach((n) => {
|
|
707
|
-
|
|
735
|
+
s.push(n);
|
|
708
736
|
});
|
|
709
|
-
}),
|
|
737
|
+
}), s;
|
|
710
738
|
}
|
|
711
739
|
getNodeCycleEdgeIds(e) {
|
|
712
|
-
const t = Array.from(this.
|
|
713
|
-
return t.forEach((
|
|
714
|
-
this.getPortCycleEdgeIds(
|
|
715
|
-
|
|
716
|
-
}), this.getPortIncomingEdgeIds(
|
|
740
|
+
const t = Array.from(this.getNode(e).ports.keys()), s = [];
|
|
741
|
+
return t.forEach((o) => {
|
|
742
|
+
this.getPortCycleEdgeIds(o).forEach((n) => {
|
|
743
|
+
s.push(n);
|
|
744
|
+
}), this.getPortIncomingEdgeIds(o).filter((n) => {
|
|
717
745
|
const a = this.getEdge(n);
|
|
718
746
|
return this.getPort(a.to).nodeId === e;
|
|
719
747
|
}).forEach((n) => {
|
|
720
|
-
|
|
748
|
+
s.push(n);
|
|
721
749
|
});
|
|
722
|
-
}),
|
|
750
|
+
}), s;
|
|
723
751
|
}
|
|
724
752
|
getNodeAdjacentEdgeIds(e) {
|
|
725
|
-
const t = Array.from(this.
|
|
726
|
-
return t.forEach((
|
|
727
|
-
this.getPortIncomingEdgeIds(
|
|
728
|
-
|
|
729
|
-
}), this.getPortOutgoingEdgeIds(
|
|
730
|
-
|
|
731
|
-
}), this.getPortCycleEdgeIds(
|
|
732
|
-
|
|
753
|
+
const t = Array.from(this.getNode(e).ports.keys()), s = [];
|
|
754
|
+
return t.forEach((o) => {
|
|
755
|
+
this.getPortIncomingEdgeIds(o).forEach((n) => {
|
|
756
|
+
s.push(n);
|
|
757
|
+
}), this.getPortOutgoingEdgeIds(o).forEach((n) => {
|
|
758
|
+
s.push(n);
|
|
759
|
+
}), this.getPortCycleEdgeIds(o).forEach((n) => {
|
|
760
|
+
s.push(n);
|
|
733
761
|
});
|
|
734
|
-
}),
|
|
762
|
+
}), s;
|
|
735
763
|
}
|
|
736
764
|
addEdgeInternal(e) {
|
|
737
765
|
this.edges.set(e.id, {
|
|
@@ -744,8 +772,8 @@ class Ae {
|
|
|
744
772
|
}), 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
773
|
}
|
|
746
774
|
removeEdgeInternal(e) {
|
|
747
|
-
const t = this.edges.get(e),
|
|
748
|
-
this.portCycleEdges.get(
|
|
775
|
+
const t = this.edges.get(e), s = t.from, o = t.to;
|
|
776
|
+
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
777
|
}
|
|
750
778
|
}
|
|
751
779
|
const de = (r) => ({
|
|
@@ -773,7 +801,7 @@ class Qe {
|
|
|
773
801
|
i(this, "observer", new ResizeObserver(() => {
|
|
774
802
|
this.afterResizeEmitter.emit();
|
|
775
803
|
}));
|
|
776
|
-
this.host = e, [this.afterUpdateEmitter, this.onAfterUpdated] =
|
|
804
|
+
this.host = e, [this.afterUpdateEmitter, this.onAfterUpdated] = x(), [this.beforeUpdateEmitter, this.onBeforeUpdated] = x(), [this.afterResizeEmitter, this.onAfterResize] = x(), this.observer.observe(this.host);
|
|
777
805
|
}
|
|
778
806
|
getViewportMatrix() {
|
|
779
807
|
return this.viewportMatrix;
|
|
@@ -825,9 +853,9 @@ class q {
|
|
|
825
853
|
this.nodesResizeObserver.disconnect(), this.elementToNodeId.clear();
|
|
826
854
|
});
|
|
827
855
|
this.canvas = e, this.nodesResizeObserver = new ResizeObserver((t) => {
|
|
828
|
-
t.forEach((
|
|
829
|
-
const
|
|
830
|
-
this.handleNodeResize(
|
|
856
|
+
t.forEach((s) => {
|
|
857
|
+
const o = s.target;
|
|
858
|
+
this.handleNodeResize(o);
|
|
831
859
|
});
|
|
832
860
|
}), this.canvas.graph.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.canvas.graph.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.canvas.graph.onBeforeClear.subscribe(this.onBeforeClear);
|
|
833
861
|
}
|
|
@@ -840,9 +868,9 @@ class q {
|
|
|
840
868
|
}
|
|
841
869
|
}
|
|
842
870
|
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,
|
|
871
|
+
const { x: s, y: o, width: n, height: a } = r.getBoundingClientRect();
|
|
872
|
+
return e >= s && e <= s + n && t >= o && t <= o + a;
|
|
873
|
+
}, 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
874
|
e !== null ? r.style.cursor = e : r.style.removeProperty("cursor");
|
|
847
875
|
}, U = (r) => {
|
|
848
876
|
const e = document.createElement("div");
|
|
@@ -862,13 +890,13 @@ const Ze = (r, e, t) => {
|
|
|
862
890
|
}, _e = (r, e) => {
|
|
863
891
|
let t = e;
|
|
864
892
|
for (; t !== null; ) {
|
|
865
|
-
const
|
|
866
|
-
if (
|
|
893
|
+
const s = r.findPortIdsByElement(t)[0] ?? null;
|
|
894
|
+
if (s !== null)
|
|
867
895
|
return {
|
|
868
896
|
status: "portFound",
|
|
869
|
-
portId:
|
|
897
|
+
portId: s
|
|
870
898
|
};
|
|
871
|
-
if (r.
|
|
899
|
+
if (r.findNodeIdByElement(t) !== void 0)
|
|
872
900
|
return {
|
|
873
901
|
status: "nodeEncountered"
|
|
874
902
|
};
|
|
@@ -880,27 +908,27 @@ const Ze = (r, e, t) => {
|
|
|
880
908
|
};
|
|
881
909
|
function* Ee(r, e) {
|
|
882
910
|
const t = r.elementsFromPoint(e.x, e.y);
|
|
883
|
-
for (const
|
|
884
|
-
if (
|
|
885
|
-
const
|
|
886
|
-
for (const n of
|
|
911
|
+
for (const s of t) {
|
|
912
|
+
if (s.shadowRoot !== null) {
|
|
913
|
+
const o = Ee(s.shadowRoot, e);
|
|
914
|
+
for (const n of o)
|
|
887
915
|
yield n;
|
|
888
916
|
}
|
|
889
|
-
yield
|
|
917
|
+
yield s;
|
|
890
918
|
}
|
|
891
919
|
}
|
|
892
920
|
const xe = (r, e) => {
|
|
893
921
|
const t = Ee(document, e);
|
|
894
|
-
for (const
|
|
895
|
-
const
|
|
896
|
-
if (
|
|
897
|
-
return
|
|
898
|
-
if (
|
|
922
|
+
for (const s of t) {
|
|
923
|
+
const o = _e(r, s);
|
|
924
|
+
if (o.status === "portFound")
|
|
925
|
+
return o.portId;
|
|
926
|
+
if (o.status === "nodeEncountered")
|
|
899
927
|
return null;
|
|
900
928
|
}
|
|
901
929
|
return null;
|
|
902
930
|
};
|
|
903
|
-
var
|
|
931
|
+
var T = /* @__PURE__ */ ((r) => (r.StaticNodeId = "static", r.DraggingNodeId = "dragging", r.EdgeId = "edge", r))(T || {});
|
|
904
932
|
const Se = (r, e) => ({
|
|
905
933
|
x: r / 2,
|
|
906
934
|
y: e / 2
|
|
@@ -914,21 +942,21 @@ const Se = (r, e) => ({
|
|
|
914
942
|
const t = {
|
|
915
943
|
x: r.x + r.width / 2,
|
|
916
944
|
y: r.y + r.height / 2
|
|
917
|
-
},
|
|
945
|
+
}, s = {
|
|
918
946
|
x: e.x + e.width / 2,
|
|
919
947
|
y: e.y + e.height / 2
|
|
920
|
-
},
|
|
948
|
+
}, 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
949
|
return {
|
|
922
|
-
x:
|
|
950
|
+
x: o,
|
|
923
951
|
y: n,
|
|
924
952
|
width: a,
|
|
925
953
|
height: h,
|
|
926
954
|
flipX: d,
|
|
927
955
|
flipY: c
|
|
928
956
|
};
|
|
929
|
-
}, W = (r, e, t,
|
|
930
|
-
x: e * r.x + (1 - e) / 2 *
|
|
931
|
-
y: t * r.y + (1 - t) / 2 *
|
|
957
|
+
}, W = (r, e, t, s) => ({
|
|
958
|
+
x: e * r.x + (1 - e) / 2 * s.x,
|
|
959
|
+
y: t * r.y + (1 - t) / 2 * s.y
|
|
932
960
|
});
|
|
933
961
|
class et {
|
|
934
962
|
constructor(e) {
|
|
@@ -937,21 +965,21 @@ class et {
|
|
|
937
965
|
this.params = e;
|
|
938
966
|
const t = this.params.to;
|
|
939
967
|
this.midpoint = { x: t.x / 2, y: t.y / 2 };
|
|
940
|
-
const
|
|
968
|
+
const s = m(
|
|
941
969
|
{ x: this.params.arrowLength, y: p.y },
|
|
942
970
|
this.params.sourceDirection,
|
|
943
971
|
p
|
|
944
|
-
),
|
|
972
|
+
), o = m(
|
|
945
973
|
{ x: this.params.to.x - this.params.arrowLength, y: this.params.to.y },
|
|
946
974
|
this.params.targetDirection,
|
|
947
975
|
this.params.to
|
|
948
976
|
), n = {
|
|
949
|
-
x:
|
|
950
|
-
y:
|
|
977
|
+
x: s.x + this.params.sourceDirection.x * this.params.curvature,
|
|
978
|
+
y: s.y + this.params.sourceDirection.y * this.params.curvature
|
|
951
979
|
}, a = {
|
|
952
|
-
x:
|
|
953
|
-
y:
|
|
954
|
-
}, h = `M ${
|
|
980
|
+
x: o.x - this.params.targetDirection.x * this.params.curvature,
|
|
981
|
+
y: o.y - this.params.targetDirection.y * this.params.curvature
|
|
982
|
+
}, 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
983
|
this.path = `${d}${h}${c}`;
|
|
956
984
|
}
|
|
957
985
|
}
|
|
@@ -964,22 +992,22 @@ class tt {
|
|
|
964
992
|
{ x: this.params.arrowLength, y: p.y },
|
|
965
993
|
this.params.sourceDirection,
|
|
966
994
|
p
|
|
967
|
-
) : p,
|
|
995
|
+
) : p, s = this.params.hasTargetArrow ? m(
|
|
968
996
|
{
|
|
969
997
|
x: this.params.to.x - this.params.arrowLength,
|
|
970
998
|
y: this.params.to.y
|
|
971
999
|
},
|
|
972
1000
|
this.params.targetDirection,
|
|
973
1001
|
this.params.to
|
|
974
|
-
) : this.params.to,
|
|
975
|
-
{ x:
|
|
1002
|
+
) : 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(
|
|
1003
|
+
{ x: o, y: p.y },
|
|
976
1004
|
this.params.sourceDirection,
|
|
977
1005
|
p
|
|
978
1006
|
), g = {
|
|
979
1007
|
x: c.x + h,
|
|
980
1008
|
y: c.y + d
|
|
981
1009
|
}, l = m(
|
|
982
|
-
{ x: this.params.to.x -
|
|
1010
|
+
{ x: this.params.to.x - o, y: this.params.to.y },
|
|
983
1011
|
this.params.targetDirection,
|
|
984
1012
|
this.params.to
|
|
985
1013
|
), u = {
|
|
@@ -988,25 +1016,25 @@ class tt {
|
|
|
988
1016
|
}, w = {
|
|
989
1017
|
x: (g.x + u.x) / 2,
|
|
990
1018
|
y: (g.y + u.y) / 2
|
|
991
|
-
},
|
|
1019
|
+
}, f = {
|
|
992
1020
|
x: c.x + this.params.curvature * this.params.sourceDirection.x,
|
|
993
1021
|
y: c.y + this.params.curvature * this.params.sourceDirection.y
|
|
994
|
-
},
|
|
1022
|
+
}, E = {
|
|
995
1023
|
x: l.x - this.params.curvature * this.params.targetDirection.x,
|
|
996
1024
|
y: l.y - this.params.curvature * this.params.targetDirection.y
|
|
997
|
-
},
|
|
1025
|
+
}, S = {
|
|
998
1026
|
x: c.x + h,
|
|
999
1027
|
y: c.y + d
|
|
1000
|
-
},
|
|
1028
|
+
}, b = {
|
|
1001
1029
|
x: l.x + h,
|
|
1002
1030
|
y: l.y + d
|
|
1003
1031
|
};
|
|
1004
1032
|
this.path = [
|
|
1005
1033
|
`M ${t.x} ${t.y}`,
|
|
1006
1034
|
`L ${c.x} ${c.y}`,
|
|
1007
|
-
`C ${
|
|
1008
|
-
`C ${
|
|
1009
|
-
`L ${
|
|
1035
|
+
`C ${f.x} ${f.y} ${S.x} ${S.y} ${w.x} ${w.y}`,
|
|
1036
|
+
`C ${b.x} ${b.y} ${E.x} ${E.y} ${l.x} ${l.y}`,
|
|
1037
|
+
`L ${s.x} ${s.y}`
|
|
1010
1038
|
].join(" "), this.midpoint = W(w, e.flipX, e.flipY, e.to);
|
|
1011
1039
|
}
|
|
1012
1040
|
}
|
|
@@ -1015,32 +1043,32 @@ const K = Object.freeze({
|
|
|
1015
1043
|
}), Pe = (r) => {
|
|
1016
1044
|
const e = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
1017
1045
|
return e.style.pointerEvents = "none", e.style.position = "absolute", e.style.top = "0", e.style.left = "0", e.style.overflow = "visible", e.style.setProperty(K.edgeColor, r), e;
|
|
1018
|
-
},
|
|
1046
|
+
}, Te = (r) => {
|
|
1019
1047
|
const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
1020
1048
|
return e.setAttribute("stroke", `var(${K.edgeColor})`), e.setAttribute("stroke-width", `${r}`), e.setAttribute("fill", "none"), e;
|
|
1021
1049
|
}, B = () => {
|
|
1022
1050
|
const r = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
1023
1051
|
return r.setAttribute("fill", `var(${K.edgeColor})`), r;
|
|
1024
|
-
},
|
|
1052
|
+
}, Ce = () => {
|
|
1025
1053
|
const r = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
|
1026
1054
|
return r.style.transformOrigin = "50% 50%", r;
|
|
1027
|
-
},
|
|
1055
|
+
}, Ne = (r, e) => {
|
|
1028
1056
|
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
|
-
},
|
|
1057
|
+
}, D = (r, e) => {
|
|
1030
1058
|
const t = [];
|
|
1031
1059
|
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
|
|
1060
|
+
const s = r.length - 1;
|
|
1061
|
+
let o = 0, n = 0, a = 0;
|
|
1034
1062
|
r.forEach((h, d) => {
|
|
1035
1063
|
let c = 0, g = 0, l = 0;
|
|
1036
|
-
const u = d > 0, w = d <
|
|
1037
|
-
if (u && (c = -
|
|
1064
|
+
const u = d > 0, w = d < s, f = u && w;
|
|
1065
|
+
if (u && (c = -o, g = -n, l = a), w) {
|
|
1038
1066
|
const V = r[d + 1];
|
|
1039
|
-
|
|
1067
|
+
o = V.x - h.x, n = V.y - h.y, a = Math.sqrt(o * o + n * n);
|
|
1040
1068
|
}
|
|
1041
|
-
const
|
|
1042
|
-
d > 0 && t.push(`L ${R.x} ${R.y}`),
|
|
1043
|
-
`C ${h.x} ${h.y} ${h.x} ${h.y} ${
|
|
1069
|
+
const S = a !== 0 ? Math.min((f ? e : 0) / a, d < s - 1 ? 0.5 : 1) : 0, b = f ? { x: h.x + o * S, y: h.y + n * S } : h, P = l !== 0 ? Math.min((f ? e : 0) / l, d > 1 ? 0.5 : 1) : 0, R = f ? { x: h.x + c * P, y: h.y + g * P } : h;
|
|
1070
|
+
d > 0 && t.push(`L ${R.x} ${R.y}`), f && t.push(
|
|
1071
|
+
`C ${h.x} ${h.y} ${h.x} ${h.y} ${b.x} ${b.y}`
|
|
1044
1072
|
);
|
|
1045
1073
|
});
|
|
1046
1074
|
}
|
|
@@ -1053,11 +1081,11 @@ class rt {
|
|
|
1053
1081
|
this.params = e;
|
|
1054
1082
|
const t = this.params.to;
|
|
1055
1083
|
this.midpoint = { x: t.x / 2, y: t.y / 2 };
|
|
1056
|
-
const
|
|
1084
|
+
const s = this.params.hasSourceArrow ? m(
|
|
1057
1085
|
{ x: this.params.arrowLength, y: p.y },
|
|
1058
1086
|
this.params.sourceDirection,
|
|
1059
1087
|
p
|
|
1060
|
-
) : p,
|
|
1088
|
+
) : p, o = this.params.hasTargetArrow ? m(
|
|
1061
1089
|
{
|
|
1062
1090
|
x: this.params.to.x - this.params.arrowLength,
|
|
1063
1091
|
y: this.params.to.y
|
|
@@ -1078,14 +1106,14 @@ class rt {
|
|
|
1078
1106
|
}, u = { x: l.x, y: g }, w = {
|
|
1079
1107
|
x: this.params.flipX > 0 ? this.params.to.x - c : this.params.to.x + n,
|
|
1080
1108
|
y: d.y
|
|
1081
|
-
},
|
|
1082
|
-
this.path =
|
|
1083
|
-
[
|
|
1109
|
+
}, f = { x: w.x, y: g };
|
|
1110
|
+
this.path = D(
|
|
1111
|
+
[s, h, l, u, f, w, d, o],
|
|
1084
1112
|
this.params.roundness
|
|
1085
1113
|
);
|
|
1086
1114
|
}
|
|
1087
1115
|
}
|
|
1088
|
-
class
|
|
1116
|
+
class st {
|
|
1089
1117
|
constructor(e) {
|
|
1090
1118
|
i(this, "path");
|
|
1091
1119
|
i(this, "midpoint");
|
|
@@ -1094,40 +1122,40 @@ class ot {
|
|
|
1094
1122
|
{ x: this.params.arrowLength, y: p.y },
|
|
1095
1123
|
this.params.sourceDirection,
|
|
1096
1124
|
p
|
|
1097
|
-
) : p,
|
|
1125
|
+
) : p, s = this.params.hasTargetArrow ? m(
|
|
1098
1126
|
{
|
|
1099
1127
|
x: this.params.to.x - this.params.arrowLength,
|
|
1100
1128
|
y: this.params.to.y
|
|
1101
1129
|
},
|
|
1102
1130
|
this.params.targetDirection,
|
|
1103
1131
|
this.params.to
|
|
1104
|
-
) : this.params.to,
|
|
1105
|
-
{ x:
|
|
1132
|
+
) : this.params.to, o = this.params.arrowLength + this.params.arrowOffset, n = m(
|
|
1133
|
+
{ x: o, y: p.y },
|
|
1106
1134
|
this.params.sourceDirection,
|
|
1107
1135
|
p
|
|
1108
1136
|
), 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 -
|
|
1137
|
+
{ x: this.params.to.x - o, y: this.params.to.y },
|
|
1110
1138
|
this.params.targetDirection,
|
|
1111
1139
|
this.params.to
|
|
1112
1140
|
), 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,
|
|
1141
|
+
this.midpoint = W(w, e.flipX, e.flipY, e.to), this.path = D(
|
|
1142
|
+
[t, n, g, u, l, s],
|
|
1115
1143
|
this.params.roundness
|
|
1116
1144
|
);
|
|
1117
1145
|
}
|
|
1118
1146
|
}
|
|
1119
|
-
class
|
|
1147
|
+
class ot {
|
|
1120
1148
|
constructor(e) {
|
|
1121
1149
|
i(this, "path");
|
|
1122
1150
|
i(this, "midpoint");
|
|
1123
1151
|
this.params = e;
|
|
1124
1152
|
const t = this.params.to;
|
|
1125
1153
|
this.midpoint = { x: t.x / 2, y: t.y / 2 };
|
|
1126
|
-
const
|
|
1154
|
+
const s = this.params.hasSourceArrow ? m(
|
|
1127
1155
|
{ x: this.params.arrowLength, y: p.y },
|
|
1128
1156
|
this.params.sourceDirection,
|
|
1129
1157
|
p
|
|
1130
|
-
) : p,
|
|
1158
|
+
) : p, o = this.params.hasTargetArrow ? m(
|
|
1131
1159
|
{
|
|
1132
1160
|
x: this.params.to.x - this.params.arrowLength,
|
|
1133
1161
|
y: this.params.to.y
|
|
@@ -1143,7 +1171,7 @@ class st {
|
|
|
1143
1171
|
this.params.targetDirection,
|
|
1144
1172
|
this.params.to
|
|
1145
1173
|
);
|
|
1146
|
-
this.path =
|
|
1174
|
+
this.path = D([s, a, h, o], this.params.roundness);
|
|
1147
1175
|
}
|
|
1148
1176
|
}
|
|
1149
1177
|
class it {
|
|
@@ -1153,11 +1181,11 @@ class it {
|
|
|
1153
1181
|
this.params = e;
|
|
1154
1182
|
const t = this.params.to;
|
|
1155
1183
|
this.midpoint = { x: t.x / 2, y: t.y / 2 };
|
|
1156
|
-
const
|
|
1184
|
+
const s = this.params.hasSourceArrow ? m(
|
|
1157
1185
|
{ x: this.params.arrowLength, y: p.y },
|
|
1158
1186
|
this.params.sourceDirection,
|
|
1159
1187
|
p
|
|
1160
|
-
) : p,
|
|
1188
|
+
) : p, o = this.params.hasTargetArrow ? m(
|
|
1161
1189
|
{
|
|
1162
1190
|
x: this.params.to.x - this.params.arrowLength,
|
|
1163
1191
|
y: this.params.to.y
|
|
@@ -1178,9 +1206,9 @@ class it {
|
|
|
1178
1206
|
}, u = { x: g, y: l.y }, w = {
|
|
1179
1207
|
x: d.x,
|
|
1180
1208
|
y: this.params.flipY > 0 ? this.params.to.y - c : this.params.to.y + n
|
|
1181
|
-
},
|
|
1182
|
-
this.path =
|
|
1183
|
-
[
|
|
1209
|
+
}, f = { x: g, y: w.y };
|
|
1210
|
+
this.path = D(
|
|
1211
|
+
[s, h, l, u, f, w, d, o],
|
|
1184
1212
|
this.params.roundness
|
|
1185
1213
|
);
|
|
1186
1214
|
}
|
|
@@ -1190,19 +1218,19 @@ class Q {
|
|
|
1190
1218
|
i(this, "path");
|
|
1191
1219
|
i(this, "midpoint");
|
|
1192
1220
|
this.params = e;
|
|
1193
|
-
const t = this.params.arrowOffset,
|
|
1221
|
+
const t = this.params.arrowOffset, s = this.params.side, o = this.params.arrowLength + t, n = o + 2 * s, h = [
|
|
1194
1222
|
{ x: this.params.arrowLength, y: p.y },
|
|
1195
|
-
{ x:
|
|
1196
|
-
{ x:
|
|
1223
|
+
{ x: o, y: p.y },
|
|
1224
|
+
{ x: o, y: this.params.side },
|
|
1197
1225
|
{ x: n, y: this.params.side },
|
|
1198
1226
|
{ x: n, y: -this.params.side },
|
|
1199
|
-
{ x:
|
|
1200
|
-
{ x:
|
|
1227
|
+
{ x: o, y: -this.params.side },
|
|
1228
|
+
{ x: o, y: p.y },
|
|
1201
1229
|
{ x: this.params.arrowLength, y: p.y }
|
|
1202
1230
|
].map(
|
|
1203
1231
|
(c) => m(c, this.params.sourceDirection, p)
|
|
1204
1232
|
), d = `M ${p.x} ${p.y} L ${h[0].x} ${h[0].y} `;
|
|
1205
|
-
this.path = `${this.params.hasSourceArrow || this.params.hasTargetArrow ? "" : d}${
|
|
1233
|
+
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
1234
|
}
|
|
1207
1235
|
}
|
|
1208
1236
|
class nt {
|
|
@@ -1210,17 +1238,17 @@ class nt {
|
|
|
1210
1238
|
i(this, "path");
|
|
1211
1239
|
i(this, "midpoint");
|
|
1212
1240
|
this.params = e;
|
|
1213
|
-
const t = this.params.smallRadius,
|
|
1241
|
+
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
1242
|
{ x: this.params.arrowLength, y: p.y },
|
|
1215
1243
|
{ x: c, y: n },
|
|
1216
1244
|
{ x: c, y: -n },
|
|
1217
1245
|
{ x: d, y: 0 }
|
|
1218
1246
|
].map(
|
|
1219
|
-
(
|
|
1247
|
+
(f) => m(f, this.params.sourceDirection, p)
|
|
1220
1248
|
), u = [
|
|
1221
1249
|
`M ${l[0].x} ${l[0].y}`,
|
|
1222
1250
|
`A ${t} ${t} 0 0 1 ${l[1].x} ${l[1].y}`,
|
|
1223
|
-
`A ${
|
|
1251
|
+
`A ${s} ${s} 0 1 0 ${l[2].x} ${l[2].y}`,
|
|
1224
1252
|
`A ${t} ${t} 0 0 1 ${l[0].x} ${l[0].y}`
|
|
1225
1253
|
].join(" "), w = `M 0 0 L ${l[0].x} ${l[0].y} `;
|
|
1226
1254
|
this.path = `${this.params.hasSourceArrow || this.params.hasTargetArrow ? "" : w}${u}`, this.midpoint = l[3];
|
|
@@ -1241,7 +1269,7 @@ class at {
|
|
|
1241
1269
|
this.path = "";
|
|
1242
1270
|
return;
|
|
1243
1271
|
}
|
|
1244
|
-
const
|
|
1272
|
+
const o = this.createDirectLinePoint({
|
|
1245
1273
|
offset: this.params.sourceOffset,
|
|
1246
1274
|
hasArrow: this.params.hasSourceArrow,
|
|
1247
1275
|
flip: 1,
|
|
@@ -1252,13 +1280,13 @@ class at {
|
|
|
1252
1280
|
flip: -1,
|
|
1253
1281
|
shift: this.params.to
|
|
1254
1282
|
});
|
|
1255
|
-
this.path = `M ${
|
|
1283
|
+
this.path = `M ${o.x} ${o.y} L ${n.x} ${n.y}`;
|
|
1256
1284
|
}
|
|
1257
1285
|
createDirectLinePoint(e) {
|
|
1258
|
-
const t = e.hasArrow ? this.params.arrowLength : 0,
|
|
1286
|
+
const t = e.hasArrow ? this.params.arrowLength : 0, s = e.offset + t, o = e.flip * s / this.diagonalDistance;
|
|
1259
1287
|
return {
|
|
1260
|
-
x: this.params.to.x *
|
|
1261
|
-
y: this.params.to.y *
|
|
1288
|
+
x: this.params.to.x * o + e.shift.x,
|
|
1289
|
+
y: this.params.to.y * o + e.shift.y
|
|
1262
1290
|
};
|
|
1263
1291
|
}
|
|
1264
1292
|
}
|
|
@@ -1271,33 +1299,33 @@ class ht {
|
|
|
1271
1299
|
{ x: this.params.arrowLength, y: p.y },
|
|
1272
1300
|
this.params.sourceDirection,
|
|
1273
1301
|
p
|
|
1274
|
-
) : p,
|
|
1302
|
+
) : p, s = this.params.hasTargetArrow ? m(
|
|
1275
1303
|
{
|
|
1276
1304
|
x: this.params.to.x - this.params.arrowLength,
|
|
1277
1305
|
y: this.params.to.y
|
|
1278
1306
|
},
|
|
1279
1307
|
this.params.targetDirection,
|
|
1280
1308
|
this.params.to
|
|
1281
|
-
) : this.params.to,
|
|
1282
|
-
{ x:
|
|
1309
|
+
) : this.params.to, o = this.params.arrowLength + this.params.arrowOffset, n = m(
|
|
1310
|
+
{ x: o, y: p.y },
|
|
1283
1311
|
this.params.sourceDirection,
|
|
1284
1312
|
p
|
|
1285
1313
|
), a = m(
|
|
1286
|
-
{ x: this.params.to.x -
|
|
1314
|
+
{ x: this.params.to.x - o, y: this.params.to.y },
|
|
1287
1315
|
this.params.targetDirection,
|
|
1288
1316
|
this.params.to
|
|
1289
1317
|
), 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
1318
|
x: (n.x + a.x) / 2,
|
|
1291
1319
|
y: g
|
|
1292
1320
|
};
|
|
1293
|
-
this.midpoint = W(l, e.flipX, e.flipY, e.to), this.path =
|
|
1321
|
+
this.midpoint = W(l, e.flipX, e.flipY, e.to), this.path = D(
|
|
1294
1322
|
[
|
|
1295
1323
|
t,
|
|
1296
1324
|
n,
|
|
1297
1325
|
{ x: n.x, y: g },
|
|
1298
1326
|
{ x: a.x, y: g },
|
|
1299
1327
|
a,
|
|
1300
|
-
|
|
1328
|
+
s
|
|
1301
1329
|
],
|
|
1302
1330
|
this.params.roundness
|
|
1303
1331
|
);
|
|
@@ -1312,39 +1340,39 @@ class dt {
|
|
|
1312
1340
|
{ x: this.params.arrowLength, y: p.y },
|
|
1313
1341
|
this.params.sourceDirection,
|
|
1314
1342
|
p
|
|
1315
|
-
) : p,
|
|
1343
|
+
) : p, s = this.params.hasTargetArrow ? m(
|
|
1316
1344
|
{
|
|
1317
1345
|
x: this.params.to.x - this.params.arrowLength,
|
|
1318
1346
|
y: this.params.to.y
|
|
1319
1347
|
},
|
|
1320
1348
|
this.params.targetDirection,
|
|
1321
1349
|
this.params.to
|
|
1322
|
-
) : this.params.to,
|
|
1323
|
-
{ x:
|
|
1350
|
+
) : this.params.to, o = this.params.arrowLength + this.params.arrowOffset, n = m(
|
|
1351
|
+
{ x: o, y: p.y },
|
|
1324
1352
|
this.params.sourceDirection,
|
|
1325
1353
|
p
|
|
1326
1354
|
), a = m(
|
|
1327
|
-
{ x: this.params.to.x -
|
|
1355
|
+
{ x: this.params.to.x - o, y: this.params.to.y },
|
|
1328
1356
|
this.params.targetDirection,
|
|
1329
1357
|
this.params.to
|
|
1330
1358
|
), 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
1359
|
x: g,
|
|
1332
1360
|
y: (n.y + a.y) / 2
|
|
1333
1361
|
};
|
|
1334
|
-
this.midpoint = W(l, e.flipX, e.flipY, e.to), this.path =
|
|
1362
|
+
this.midpoint = W(l, e.flipX, e.flipY, e.to), this.path = D(
|
|
1335
1363
|
[
|
|
1336
1364
|
t,
|
|
1337
1365
|
n,
|
|
1338
1366
|
{ x: g, y: n.y },
|
|
1339
1367
|
{ x: g, y: a.y },
|
|
1340
1368
|
a,
|
|
1341
|
-
|
|
1369
|
+
s
|
|
1342
1370
|
],
|
|
1343
1371
|
this.params.roundness
|
|
1344
1372
|
);
|
|
1345
1373
|
}
|
|
1346
1374
|
}
|
|
1347
|
-
const
|
|
1375
|
+
const y = Object.freeze({
|
|
1348
1376
|
color: "#777777",
|
|
1349
1377
|
width: 1,
|
|
1350
1378
|
arrowLength: 20,
|
|
@@ -1370,21 +1398,21 @@ const f = Object.freeze({
|
|
|
1370
1398
|
class k {
|
|
1371
1399
|
constructor(e) {
|
|
1372
1400
|
i(this, "svg");
|
|
1373
|
-
i(this, "group",
|
|
1401
|
+
i(this, "group", Ce());
|
|
1374
1402
|
i(this, "line");
|
|
1375
1403
|
i(this, "sourceArrow", null);
|
|
1376
1404
|
i(this, "targetArrow", null);
|
|
1377
1405
|
i(this, "onAfterRender");
|
|
1378
1406
|
i(this, "afterRenderEmitter");
|
|
1379
1407
|
i(this, "arrowRenderer");
|
|
1380
|
-
this.params = e, [this.afterRenderEmitter, this.onAfterRender] =
|
|
1408
|
+
this.params = e, [this.afterRenderEmitter, this.onAfterRender] = x(), this.arrowRenderer = this.params.arrowRenderer, this.svg = Pe(e.color), this.svg.appendChild(this.group), this.line = Te(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
1409
|
}
|
|
1382
1410
|
render(e) {
|
|
1383
|
-
const { x: t, y:
|
|
1411
|
+
const { x: t, y: s, width: o, height: n, flipX: a, flipY: h } = be(
|
|
1384
1412
|
e.from,
|
|
1385
1413
|
e.to
|
|
1386
1414
|
);
|
|
1387
|
-
|
|
1415
|
+
Ne(this.svg, { x: t, y: s, width: o, height: n }), this.group.style.transform = `scale(${a}, ${h})`;
|
|
1388
1416
|
const d = ge(
|
|
1389
1417
|
e.from.direction,
|
|
1390
1418
|
a,
|
|
@@ -1394,7 +1422,7 @@ class k {
|
|
|
1394
1422
|
a,
|
|
1395
1423
|
h
|
|
1396
1424
|
), g = {
|
|
1397
|
-
x:
|
|
1425
|
+
x: o,
|
|
1398
1426
|
y: n
|
|
1399
1427
|
};
|
|
1400
1428
|
let l = { x: -c.x, y: -c.y }, u;
|
|
@@ -1407,26 +1435,26 @@ class k {
|
|
|
1407
1435
|
h
|
|
1408
1436
|
);
|
|
1409
1437
|
this.line.setAttribute("d", w.path);
|
|
1410
|
-
let
|
|
1411
|
-
this.sourceArrow && (
|
|
1438
|
+
let f = null;
|
|
1439
|
+
this.sourceArrow && (f = this.arrowRenderer({
|
|
1412
1440
|
direction: d,
|
|
1413
1441
|
shift: p,
|
|
1414
1442
|
arrowLength: this.params.arrowLength
|
|
1415
|
-
}), this.sourceArrow.setAttribute("d",
|
|
1416
|
-
let
|
|
1417
|
-
this.targetArrow && (
|
|
1443
|
+
}), this.sourceArrow.setAttribute("d", f));
|
|
1444
|
+
let E = null;
|
|
1445
|
+
this.targetArrow && (E = this.arrowRenderer({
|
|
1418
1446
|
direction: l,
|
|
1419
1447
|
shift: g,
|
|
1420
1448
|
arrowLength: this.params.arrowLength
|
|
1421
|
-
}), this.targetArrow.setAttribute("d",
|
|
1449
|
+
}), this.targetArrow.setAttribute("d", E)), this.afterRenderEmitter.emit({
|
|
1422
1450
|
edgePath: w,
|
|
1423
|
-
sourceArrowPath:
|
|
1424
|
-
targetArrowPath:
|
|
1451
|
+
sourceArrowPath: f,
|
|
1452
|
+
targetArrowPath: E
|
|
1425
1453
|
});
|
|
1426
1454
|
}
|
|
1427
1455
|
}
|
|
1428
1456
|
const ct = (r) => (e) => {
|
|
1429
|
-
const
|
|
1457
|
+
const s = [
|
|
1430
1458
|
p,
|
|
1431
1459
|
{ x: e.arrowLength, y: r.radius },
|
|
1432
1460
|
{ x: e.arrowLength, y: -r.radius }
|
|
@@ -1435,18 +1463,18 @@ const ct = (r) => (e) => {
|
|
|
1435
1463
|
).map((h) => ({
|
|
1436
1464
|
x: h.x + e.shift.x,
|
|
1437
1465
|
y: h.y + e.shift.y
|
|
1438
|
-
})),
|
|
1439
|
-
return `${
|
|
1466
|
+
})), o = `M ${s[0].x} ${s[0].y}`, n = `L ${s[1].x} ${s[1].y}`, a = `L ${s[2].x} ${s[2].y}`;
|
|
1467
|
+
return `${o} ${n} ${a} Z`;
|
|
1440
1468
|
}, lt = (r) => (e) => {
|
|
1441
|
-
const t = r.radius,
|
|
1442
|
-
(
|
|
1443
|
-
).map((
|
|
1444
|
-
x:
|
|
1445
|
-
y:
|
|
1446
|
-
})), g = `M ${c[0].x} ${c[0].y}`, l = `A ${
|
|
1469
|
+
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(
|
|
1470
|
+
(f) => m(f, e.direction, p)
|
|
1471
|
+
).map((f) => ({
|
|
1472
|
+
x: f.x + e.shift.x,
|
|
1473
|
+
y: f.y + e.shift.y
|
|
1474
|
+
})), 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
1475
|
return `${g} ${l} ${u} ${w}`;
|
|
1448
1476
|
}, gt = (r) => (e) => {
|
|
1449
|
-
const t = r.smallRadius,
|
|
1477
|
+
const t = r.smallRadius, s = r.radius, o = m(
|
|
1450
1478
|
{
|
|
1451
1479
|
x: e.arrowLength,
|
|
1452
1480
|
y: 0
|
|
@@ -1459,12 +1487,12 @@ const ct = (r) => (e) => {
|
|
|
1459
1487
|
x: e.arrowLength + r.smallRadius,
|
|
1460
1488
|
y: 0
|
|
1461
1489
|
}
|
|
1462
|
-
), a = [p, { x:
|
|
1490
|
+
), a = [p, { x: o.x, y: -o.y }, o].map(
|
|
1463
1491
|
(l) => m(l, e.direction, p)
|
|
1464
1492
|
).map((l) => ({
|
|
1465
1493
|
x: l.x + e.shift.x,
|
|
1466
1494
|
y: l.y + e.shift.y
|
|
1467
|
-
})), h = `M ${a[0].x} ${a[0].y}`, d = `A ${
|
|
1495
|
+
})), 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
1496
|
return `${h} ${d} ${c} ${g}`;
|
|
1469
1497
|
}, F = (r) => {
|
|
1470
1498
|
if (typeof r == "function")
|
|
@@ -1472,17 +1500,17 @@ const ct = (r) => (e) => {
|
|
|
1472
1500
|
switch (r.type) {
|
|
1473
1501
|
case "triangle":
|
|
1474
1502
|
return ct({
|
|
1475
|
-
radius: r.radius ??
|
|
1503
|
+
radius: r.radius ?? y.polygonArrowRadius
|
|
1476
1504
|
});
|
|
1477
1505
|
case "arc":
|
|
1478
1506
|
return lt({
|
|
1479
|
-
radius: r.radius ??
|
|
1507
|
+
radius: r.radius ?? y.circleArrowRadius
|
|
1480
1508
|
});
|
|
1481
1509
|
default:
|
|
1482
1510
|
return gt({
|
|
1483
|
-
smallRadius: r.smallRadius ??
|
|
1484
|
-
angle: r.angle ??
|
|
1485
|
-
radius: r.radius ??
|
|
1511
|
+
smallRadius: r.smallRadius ?? y.wedgeArrowSmallRadius,
|
|
1512
|
+
angle: r.angle ?? y.wedgeArrowAngle,
|
|
1513
|
+
radius: r.radius ?? y.wedgeArrowRadius
|
|
1486
1514
|
});
|
|
1487
1515
|
}
|
|
1488
1516
|
};
|
|
@@ -1511,11 +1539,11 @@ class ut {
|
|
|
1511
1539
|
hasSourceArrow: this.hasSourceArrow,
|
|
1512
1540
|
hasTargetArrow: this.hasTargetArrow
|
|
1513
1541
|
}));
|
|
1514
|
-
i(this, "createDetourPath", (e, t,
|
|
1515
|
-
to:
|
|
1542
|
+
i(this, "createDetourPath", (e, t, s, o, n) => new tt({
|
|
1543
|
+
to: s,
|
|
1516
1544
|
sourceDirection: e,
|
|
1517
1545
|
targetDirection: t,
|
|
1518
|
-
flipX:
|
|
1546
|
+
flipX: o,
|
|
1519
1547
|
flipY: n,
|
|
1520
1548
|
arrowLength: this.arrowLength,
|
|
1521
1549
|
detourDirection: this.detourDirection,
|
|
@@ -1524,8 +1552,8 @@ class ut {
|
|
|
1524
1552
|
hasSourceArrow: this.hasSourceArrow,
|
|
1525
1553
|
hasTargetArrow: this.hasTargetArrow
|
|
1526
1554
|
}));
|
|
1527
|
-
i(this, "createLinePath", (e, t,
|
|
1528
|
-
to:
|
|
1555
|
+
i(this, "createLinePath", (e, t, s) => new et({
|
|
1556
|
+
to: s,
|
|
1529
1557
|
sourceDirection: e,
|
|
1530
1558
|
targetDirection: t,
|
|
1531
1559
|
arrowLength: this.arrowLength,
|
|
@@ -1533,9 +1561,9 @@ class ut {
|
|
|
1533
1561
|
hasSourceArrow: this.hasSourceArrow,
|
|
1534
1562
|
hasTargetArrow: this.hasTargetArrow
|
|
1535
1563
|
}));
|
|
1536
|
-
this.arrowLength = (e == null ? void 0 : e.arrowLength) ??
|
|
1537
|
-
color: (e == null ? void 0 : e.color) ??
|
|
1538
|
-
width: (e == null ? void 0 : e.width) ??
|
|
1564
|
+
this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? y.arrowLength, this.curvature = (e == null ? void 0 : e.curvature) ?? y.curvature, this.portCycleRadius = (e == null ? void 0 : e.cycleRadius) ?? y.cycleRadius, this.portCycleSmallRadius = (e == null ? void 0 : e.smallCycleRadius) ?? y.smallCycleRadius, this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? y.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? y.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? y.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? y.hasTargetArrow, this.pathShape = new k({
|
|
1565
|
+
color: (e == null ? void 0 : e.color) ?? y.color,
|
|
1566
|
+
width: (e == null ? void 0 : e.width) ?? y.width,
|
|
1539
1567
|
arrowRenderer: F((e == null ? void 0 : e.arrowRenderer) ?? {}),
|
|
1540
1568
|
arrowLength: this.arrowLength,
|
|
1541
1569
|
hasSourceArrow: this.hasSourceArrow,
|
|
@@ -1574,11 +1602,11 @@ class pt {
|
|
|
1574
1602
|
hasSourceArrow: this.hasSourceArrow,
|
|
1575
1603
|
hasTargetArrow: this.hasTargetArrow
|
|
1576
1604
|
}));
|
|
1577
|
-
i(this, "createDetourPath", (e, t,
|
|
1578
|
-
to:
|
|
1605
|
+
i(this, "createDetourPath", (e, t, s, o, n) => new ht({
|
|
1606
|
+
to: s,
|
|
1579
1607
|
sourceDirection: e,
|
|
1580
1608
|
targetDirection: t,
|
|
1581
|
-
flipX:
|
|
1609
|
+
flipX: o,
|
|
1582
1610
|
flipY: n,
|
|
1583
1611
|
arrowLength: this.arrowLength,
|
|
1584
1612
|
arrowOffset: this.arrowOffset,
|
|
@@ -1587,26 +1615,26 @@ class pt {
|
|
|
1587
1615
|
hasSourceArrow: this.hasSourceArrow,
|
|
1588
1616
|
hasTargetArrow: this.hasTargetArrow
|
|
1589
1617
|
}));
|
|
1590
|
-
i(this, "createLinePath", (e, t,
|
|
1591
|
-
to:
|
|
1618
|
+
i(this, "createLinePath", (e, t, s, o) => new rt({
|
|
1619
|
+
to: s,
|
|
1592
1620
|
sourceDirection: e,
|
|
1593
1621
|
targetDirection: t,
|
|
1594
|
-
flipX:
|
|
1622
|
+
flipX: o,
|
|
1595
1623
|
arrowLength: this.arrowLength,
|
|
1596
1624
|
arrowOffset: this.arrowOffset,
|
|
1597
1625
|
roundness: this.roundness,
|
|
1598
1626
|
hasSourceArrow: this.hasSourceArrow,
|
|
1599
1627
|
hasTargetArrow: this.hasTargetArrow
|
|
1600
1628
|
}));
|
|
1601
|
-
this.arrowLength = (e == null ? void 0 : e.arrowLength) ??
|
|
1602
|
-
const t = (e == null ? void 0 : e.roundness) ??
|
|
1629
|
+
this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? y.arrowLength, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? y.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? y.cycleSquareSide;
|
|
1630
|
+
const t = (e == null ? void 0 : e.roundness) ?? y.roundness;
|
|
1603
1631
|
this.roundness = Math.min(
|
|
1604
1632
|
t,
|
|
1605
1633
|
this.arrowOffset,
|
|
1606
1634
|
this.cycleSquareSide / 2
|
|
1607
|
-
), this.detourDistance = (e == null ? void 0 : e.detourDistance) ??
|
|
1608
|
-
color: (e == null ? void 0 : e.color) ??
|
|
1609
|
-
width: (e == null ? void 0 : e.width) ??
|
|
1635
|
+
), this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? y.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? y.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? y.hasTargetArrow, this.pathShape = new k({
|
|
1636
|
+
color: (e == null ? void 0 : e.color) ?? y.color,
|
|
1637
|
+
width: (e == null ? void 0 : e.width) ?? y.width,
|
|
1610
1638
|
arrowRenderer: F((e == null ? void 0 : e.arrowRenderer) ?? {}),
|
|
1611
1639
|
arrowLength: this.arrowLength,
|
|
1612
1640
|
hasSourceArrow: this.hasSourceArrow,
|
|
@@ -1646,11 +1674,11 @@ class wt {
|
|
|
1646
1674
|
hasSourceArrow: this.hasSourceArrow,
|
|
1647
1675
|
hasTargetArrow: this.hasTargetArrow
|
|
1648
1676
|
}));
|
|
1649
|
-
i(this, "createDetourPath", (e, t,
|
|
1650
|
-
to:
|
|
1677
|
+
i(this, "createDetourPath", (e, t, s, o, n) => new st({
|
|
1678
|
+
to: s,
|
|
1651
1679
|
sourceDirection: e,
|
|
1652
1680
|
targetDirection: t,
|
|
1653
|
-
flipX:
|
|
1681
|
+
flipX: o,
|
|
1654
1682
|
flipY: n,
|
|
1655
1683
|
arrowLength: this.arrowLength,
|
|
1656
1684
|
arrowOffset: this.arrowOffset,
|
|
@@ -1660,8 +1688,8 @@ class wt {
|
|
|
1660
1688
|
hasSourceArrow: this.hasSourceArrow,
|
|
1661
1689
|
hasTargetArrow: this.hasTargetArrow
|
|
1662
1690
|
}));
|
|
1663
|
-
i(this, "createLinePath", (e, t,
|
|
1664
|
-
to:
|
|
1691
|
+
i(this, "createLinePath", (e, t, s) => new ot({
|
|
1692
|
+
to: s,
|
|
1665
1693
|
sourceDirection: e,
|
|
1666
1694
|
targetDirection: t,
|
|
1667
1695
|
arrowLength: this.arrowLength,
|
|
@@ -1670,15 +1698,15 @@ class wt {
|
|
|
1670
1698
|
hasSourceArrow: this.hasSourceArrow,
|
|
1671
1699
|
hasTargetArrow: this.hasTargetArrow
|
|
1672
1700
|
}));
|
|
1673
|
-
this.arrowLength = (e == null ? void 0 : e.arrowLength) ??
|
|
1674
|
-
const t = (e == null ? void 0 : e.roundness) ??
|
|
1701
|
+
this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? y.arrowLength, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? y.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? y.cycleSquareSide;
|
|
1702
|
+
const t = (e == null ? void 0 : e.roundness) ?? y.roundness;
|
|
1675
1703
|
this.roundness = Math.min(
|
|
1676
1704
|
t,
|
|
1677
1705
|
this.arrowOffset,
|
|
1678
1706
|
this.cycleSquareSide / 2
|
|
1679
|
-
), this.detourDirection = (e == null ? void 0 : e.detourDirection) ??
|
|
1680
|
-
color: (e == null ? void 0 : e.color) ??
|
|
1681
|
-
width: (e == null ? void 0 : e.width) ??
|
|
1707
|
+
), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? y.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? y.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? y.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? y.hasTargetArrow, this.pathShape = new k({
|
|
1708
|
+
color: (e == null ? void 0 : e.color) ?? y.color,
|
|
1709
|
+
width: (e == null ? void 0 : e.width) ?? y.width,
|
|
1682
1710
|
arrowRenderer: F((e == null ? void 0 : e.arrowRenderer) ?? {}),
|
|
1683
1711
|
arrowLength: this.arrowLength,
|
|
1684
1712
|
hasSourceArrow: this.hasSourceArrow,
|
|
@@ -1717,11 +1745,11 @@ class ft {
|
|
|
1717
1745
|
hasSourceArrow: this.hasSourceArrow,
|
|
1718
1746
|
hasTargetArrow: this.hasTargetArrow
|
|
1719
1747
|
}));
|
|
1720
|
-
i(this, "createDetourPath", (e, t,
|
|
1721
|
-
to:
|
|
1748
|
+
i(this, "createDetourPath", (e, t, s, o, n) => new dt({
|
|
1749
|
+
to: s,
|
|
1722
1750
|
sourceDirection: e,
|
|
1723
1751
|
targetDirection: t,
|
|
1724
|
-
flipX:
|
|
1752
|
+
flipX: o,
|
|
1725
1753
|
flipY: n,
|
|
1726
1754
|
arrowLength: this.arrowLength,
|
|
1727
1755
|
arrowOffset: this.arrowOffset,
|
|
@@ -1730,8 +1758,8 @@ class ft {
|
|
|
1730
1758
|
hasSourceArrow: this.hasSourceArrow,
|
|
1731
1759
|
hasTargetArrow: this.hasTargetArrow
|
|
1732
1760
|
}));
|
|
1733
|
-
i(this, "createLinePath", (e, t,
|
|
1734
|
-
to:
|
|
1761
|
+
i(this, "createLinePath", (e, t, s, o, n) => new it({
|
|
1762
|
+
to: s,
|
|
1735
1763
|
sourceDirection: e,
|
|
1736
1764
|
targetDirection: t,
|
|
1737
1765
|
flipY: n,
|
|
@@ -1741,15 +1769,15 @@ class ft {
|
|
|
1741
1769
|
hasSourceArrow: this.hasSourceArrow,
|
|
1742
1770
|
hasTargetArrow: this.hasTargetArrow
|
|
1743
1771
|
}));
|
|
1744
|
-
this.arrowLength = (e == null ? void 0 : e.arrowLength) ??
|
|
1745
|
-
const t = (e == null ? void 0 : e.roundness) ??
|
|
1772
|
+
this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? y.arrowLength, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? y.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? y.cycleSquareSide;
|
|
1773
|
+
const t = (e == null ? void 0 : e.roundness) ?? y.roundness;
|
|
1746
1774
|
this.roundness = Math.min(
|
|
1747
1775
|
t,
|
|
1748
1776
|
this.arrowOffset,
|
|
1749
1777
|
this.cycleSquareSide / 2
|
|
1750
|
-
), this.detourDistance = (e == null ? void 0 : e.detourDistance) ??
|
|
1751
|
-
color: (e == null ? void 0 : e.color) ??
|
|
1752
|
-
width: (e == null ? void 0 : e.width) ??
|
|
1778
|
+
), this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? y.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? y.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? y.hasTargetArrow, this.pathShape = new k({
|
|
1779
|
+
color: (e == null ? void 0 : e.color) ?? y.color,
|
|
1780
|
+
width: (e == null ? void 0 : e.width) ?? y.width,
|
|
1753
1781
|
arrowRenderer: F((e == null ? void 0 : e.arrowRenderer) ?? {}),
|
|
1754
1782
|
arrowLength: this.arrowLength,
|
|
1755
1783
|
hasSourceArrow: this.hasSourceArrow,
|
|
@@ -1763,10 +1791,10 @@ class ft {
|
|
|
1763
1791
|
this.pathShape.render(e);
|
|
1764
1792
|
}
|
|
1765
1793
|
}
|
|
1766
|
-
class
|
|
1794
|
+
class De {
|
|
1767
1795
|
constructor(e) {
|
|
1768
1796
|
i(this, "svg");
|
|
1769
|
-
i(this, "group",
|
|
1797
|
+
i(this, "group", Ce());
|
|
1770
1798
|
i(this, "line");
|
|
1771
1799
|
i(this, "sourceArrow", null);
|
|
1772
1800
|
i(this, "targetArrow", null);
|
|
@@ -1778,15 +1806,15 @@ class Ne {
|
|
|
1778
1806
|
i(this, "onAfterRender");
|
|
1779
1807
|
i(this, "afterRenderEmitter");
|
|
1780
1808
|
i(this, "arrowRenderer");
|
|
1781
|
-
[this.afterRenderEmitter, this.onAfterRender] =
|
|
1809
|
+
[this.afterRenderEmitter, this.onAfterRender] = x(), this.color = (e == null ? void 0 : e.color) ?? y.color, this.width = (e == null ? void 0 : e.width) ?? y.width, this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? y.arrowLength, this.arrowRenderer = F((e == null ? void 0 : e.arrowRenderer) ?? {}), this.sourceOffset = (e == null ? void 0 : e.sourceOffset) ?? y.preOffset, this.targetOffset = (e == null ? void 0 : e.targetOffset) ?? y.preOffset, this.svg = Pe(this.color), this.svg.appendChild(this.group), this.line = Te(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
1810
|
}
|
|
1783
1811
|
render(e) {
|
|
1784
|
-
const { x: t, y:
|
|
1812
|
+
const { x: t, y: s, width: o, height: n, flipX: a, flipY: h } = be(
|
|
1785
1813
|
e.from,
|
|
1786
1814
|
e.to
|
|
1787
1815
|
);
|
|
1788
|
-
|
|
1789
|
-
const d = { x:
|
|
1816
|
+
Ne(this.svg, { x: t, y: s, width: o, height: n }), this.group.style.transform = `scale(${a}, ${h})`;
|
|
1817
|
+
const d = { x: o, y: n }, c = new at({
|
|
1790
1818
|
to: d,
|
|
1791
1819
|
sourceOffset: this.sourceOffset,
|
|
1792
1820
|
targetOffset: this.targetOffset,
|
|
@@ -1805,26 +1833,26 @@ class Ne {
|
|
|
1805
1833
|
y: d.y / u
|
|
1806
1834
|
};
|
|
1807
1835
|
if (this.sourceArrow) {
|
|
1808
|
-
const
|
|
1836
|
+
const f = {
|
|
1809
1837
|
x: w.x * this.sourceOffset,
|
|
1810
1838
|
y: w.y * this.sourceOffset
|
|
1811
1839
|
};
|
|
1812
1840
|
g = this.arrowRenderer({
|
|
1813
1841
|
direction: w,
|
|
1814
|
-
shift:
|
|
1842
|
+
shift: f,
|
|
1815
1843
|
arrowLength: this.arrowLength
|
|
1816
1844
|
}), this.sourceArrow.setAttribute("d", g);
|
|
1817
1845
|
}
|
|
1818
1846
|
if (this.targetArrow) {
|
|
1819
|
-
const
|
|
1847
|
+
const f = {
|
|
1820
1848
|
x: w.x * this.targetOffset,
|
|
1821
1849
|
y: w.y * this.targetOffset
|
|
1822
1850
|
};
|
|
1823
1851
|
l = this.arrowRenderer({
|
|
1824
1852
|
direction: { x: -w.x, y: -w.y },
|
|
1825
1853
|
shift: {
|
|
1826
|
-
x: d.x -
|
|
1827
|
-
y: d.y -
|
|
1854
|
+
x: d.x - f.x,
|
|
1855
|
+
y: d.y - f.y
|
|
1828
1856
|
},
|
|
1829
1857
|
arrowLength: this.arrowLength
|
|
1830
1858
|
}), this.targetArrow.setAttribute("d", l);
|
|
@@ -1869,16 +1897,16 @@ class Me {
|
|
|
1869
1897
|
"interactive edge can be configured only once"
|
|
1870
1898
|
);
|
|
1871
1899
|
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",
|
|
1900
|
+
const s = (t == null ? void 0 : t.distance) ?? y.interactiveWidth;
|
|
1901
|
+
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) => {
|
|
1902
|
+
this.interactiveLine.setAttribute("d", o.edgePath.path), this.interactiveSourceArrow && this.interactiveSourceArrow.setAttribute("d", o.sourceArrowPath), this.interactiveTargetArrow && this.interactiveTargetArrow.setAttribute("d", o.targetArrowPath);
|
|
1875
1903
|
});
|
|
1876
1904
|
}
|
|
1877
1905
|
render(e) {
|
|
1878
1906
|
this.baseEdge.render(e);
|
|
1879
1907
|
}
|
|
1880
1908
|
}
|
|
1881
|
-
class
|
|
1909
|
+
class sr {
|
|
1882
1910
|
constructor(e, t) {
|
|
1883
1911
|
i(this, "group");
|
|
1884
1912
|
i(this, "line");
|
|
@@ -1886,8 +1914,8 @@ class or {
|
|
|
1886
1914
|
i(this, "targetArrow");
|
|
1887
1915
|
i(this, "onAfterRender");
|
|
1888
1916
|
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
|
|
1917
|
+
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) => {
|
|
1918
|
+
const o = s.edgePath.midpoint, n = `translate(${o.x}px, ${o.y}px)`;
|
|
1891
1919
|
this.midpointElement.style.setProperty("transform", n);
|
|
1892
1920
|
});
|
|
1893
1921
|
}
|
|
@@ -1912,28 +1940,31 @@ class Le {
|
|
|
1912
1940
|
i(this, "onBeforeClear");
|
|
1913
1941
|
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
1942
|
}
|
|
1943
|
+
hasNode(e) {
|
|
1944
|
+
return this.graphStore.hasNode(e);
|
|
1945
|
+
}
|
|
1915
1946
|
getNode(e) {
|
|
1916
|
-
const t = this.graphStore.getNode(e);
|
|
1917
|
-
if (t === void 0)
|
|
1918
|
-
return null;
|
|
1919
|
-
const o = t.payload;
|
|
1947
|
+
const t = this.graphStore.getNode(e), { payload: s } = t;
|
|
1920
1948
|
return {
|
|
1921
1949
|
element: t.element,
|
|
1922
|
-
x:
|
|
1923
|
-
y:
|
|
1924
|
-
centerFn:
|
|
1925
|
-
priority:
|
|
1950
|
+
x: s.x,
|
|
1951
|
+
y: s.y,
|
|
1952
|
+
centerFn: s.centerFn,
|
|
1953
|
+
priority: s.priority
|
|
1926
1954
|
};
|
|
1927
1955
|
}
|
|
1928
|
-
|
|
1929
|
-
return this.graphStore.
|
|
1956
|
+
findNodeIdByElement(e) {
|
|
1957
|
+
return this.graphStore.findNodeIdByElement(e);
|
|
1930
1958
|
}
|
|
1931
1959
|
getAllNodeIds() {
|
|
1932
1960
|
return this.graphStore.getAllNodeIds();
|
|
1933
1961
|
}
|
|
1962
|
+
hasPort(e) {
|
|
1963
|
+
return this.graphStore.hasPort(e);
|
|
1964
|
+
}
|
|
1934
1965
|
getPort(e) {
|
|
1935
1966
|
const t = this.graphStore.getPort(e);
|
|
1936
|
-
return
|
|
1967
|
+
return {
|
|
1937
1968
|
element: t.element,
|
|
1938
1969
|
direction: t.payload.direction,
|
|
1939
1970
|
nodeId: t.nodeId
|
|
@@ -1943,49 +1974,49 @@ class Le {
|
|
|
1943
1974
|
return this.graphStore.getAllPortIds();
|
|
1944
1975
|
}
|
|
1945
1976
|
getNodePortIds(e) {
|
|
1946
|
-
return this.graphStore.getNodePortIds(e)
|
|
1977
|
+
return this.graphStore.getNodePortIds(e);
|
|
1947
1978
|
}
|
|
1948
|
-
|
|
1949
|
-
return
|
|
1979
|
+
findPortIdsByElement(e) {
|
|
1980
|
+
return this.graphStore.findPortIdsByElement(e);
|
|
1950
1981
|
}
|
|
1951
1982
|
getAllEdgeIds() {
|
|
1952
1983
|
return this.graphStore.getAllEdgeIds();
|
|
1953
1984
|
}
|
|
1985
|
+
hasEdge(e) {
|
|
1986
|
+
return this.graphStore.hasEdge(e);
|
|
1987
|
+
}
|
|
1954
1988
|
getEdge(e) {
|
|
1955
|
-
const t = this.graphStore.getEdge(e);
|
|
1956
|
-
if (t === void 0)
|
|
1957
|
-
return null;
|
|
1958
|
-
const o = t.payload;
|
|
1989
|
+
const t = this.graphStore.getEdge(e), { payload: s } = t;
|
|
1959
1990
|
return {
|
|
1960
1991
|
from: t.from,
|
|
1961
1992
|
to: t.to,
|
|
1962
|
-
priority:
|
|
1963
|
-
shape:
|
|
1993
|
+
priority: s.priority,
|
|
1994
|
+
shape: s.shape
|
|
1964
1995
|
};
|
|
1965
1996
|
}
|
|
1966
1997
|
getPortIncomingEdgeIds(e) {
|
|
1967
|
-
return this.graphStore.
|
|
1998
|
+
return this.graphStore.getPortIncomingEdgeIds(e);
|
|
1968
1999
|
}
|
|
1969
2000
|
getPortOutgoingEdgeIds(e) {
|
|
1970
|
-
return this.graphStore.
|
|
2001
|
+
return this.graphStore.getPortOutgoingEdgeIds(e);
|
|
1971
2002
|
}
|
|
1972
2003
|
getPortCycleEdgeIds(e) {
|
|
1973
|
-
return this.graphStore.
|
|
2004
|
+
return this.graphStore.getPortCycleEdgeIds(e);
|
|
1974
2005
|
}
|
|
1975
2006
|
getPortAdjacentEdgeIds(e) {
|
|
1976
|
-
return this.graphStore.
|
|
2007
|
+
return this.graphStore.getPortAdjacentEdgeIds(e);
|
|
1977
2008
|
}
|
|
1978
2009
|
getNodeIncomingEdgeIds(e) {
|
|
1979
|
-
return this.graphStore.
|
|
2010
|
+
return this.graphStore.getNodeIncomingEdgeIds(e);
|
|
1980
2011
|
}
|
|
1981
2012
|
getNodeOutgoingEdgeIds(e) {
|
|
1982
|
-
return this.graphStore.
|
|
2013
|
+
return this.graphStore.getNodeOutgoingEdgeIds(e);
|
|
1983
2014
|
}
|
|
1984
2015
|
getNodeCycleEdgeIds(e) {
|
|
1985
|
-
return this.graphStore.
|
|
2016
|
+
return this.graphStore.getNodeCycleEdgeIds(e);
|
|
1986
2017
|
}
|
|
1987
2018
|
getNodeAdjacentEdgeIds(e) {
|
|
1988
|
-
return this.graphStore.
|
|
2019
|
+
return this.graphStore.getNodeAdjacentEdgeIds(e);
|
|
1989
2020
|
}
|
|
1990
2021
|
}
|
|
1991
2022
|
class Re {
|
|
@@ -2012,13 +2043,13 @@ class Re {
|
|
|
2012
2043
|
}
|
|
2013
2044
|
}
|
|
2014
2045
|
const Ve = (r, e) => {
|
|
2015
|
-
const t = new Ae(),
|
|
2046
|
+
const t = new Ae(), s = new Le(t), o = new Re(e), n = new me(t, e, r), a = {
|
|
2016
2047
|
nodes: {
|
|
2017
2048
|
centerFn: Se,
|
|
2018
2049
|
priorityFn: () => 0
|
|
2019
2050
|
},
|
|
2020
2051
|
edges: {
|
|
2021
|
-
shapeFactory: () => new
|
|
2052
|
+
shapeFactory: () => new De(),
|
|
2022
2053
|
priorityFn: () => 0
|
|
2023
2054
|
},
|
|
2024
2055
|
ports: {
|
|
@@ -2026,8 +2057,8 @@ const Ve = (r, e) => {
|
|
|
2026
2057
|
}
|
|
2027
2058
|
};
|
|
2028
2059
|
return new ve(
|
|
2029
|
-
o,
|
|
2030
2060
|
s,
|
|
2061
|
+
o,
|
|
2031
2062
|
t,
|
|
2032
2063
|
e,
|
|
2033
2064
|
n,
|
|
@@ -2035,20 +2066,20 @@ const Ve = (r, e) => {
|
|
|
2035
2066
|
);
|
|
2036
2067
|
};
|
|
2037
2068
|
class z {
|
|
2038
|
-
constructor(e, t,
|
|
2069
|
+
constructor(e, t, s, o) {
|
|
2039
2070
|
i(this, "onAfterPortMarked", (e) => {
|
|
2040
2071
|
const t = this.canvas.graph.getPort(e);
|
|
2041
|
-
this.canvas.graph.
|
|
2072
|
+
this.canvas.graph.findPortIdsByElement(t.element).length === 1 && this.hookPortEvents(t.element);
|
|
2042
2073
|
});
|
|
2043
2074
|
i(this, "onBeforePortUnmarked", (e) => {
|
|
2044
2075
|
const t = this.canvas.graph.getPort(e);
|
|
2045
|
-
this.canvas.graph.
|
|
2076
|
+
this.canvas.graph.findPortIdsByElement(t.element).length === 1 && this.unhookPortEvents(t.element);
|
|
2046
2077
|
});
|
|
2047
2078
|
i(this, "onPortMouseDown", (e) => {
|
|
2048
2079
|
if (!this.params.mouseDownEventVerifier(e))
|
|
2049
2080
|
return;
|
|
2050
|
-
const t = e.currentTarget,
|
|
2051
|
-
this.params.onPortPointerDown(
|
|
2081
|
+
const t = e.currentTarget, s = this.canvas.graph.findPortIdsByElement(t)[0];
|
|
2082
|
+
this.params.onPortPointerDown(s, {
|
|
2052
2083
|
x: e.clientX,
|
|
2053
2084
|
y: e.clientY
|
|
2054
2085
|
}) && (e.stopPropagation(), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
|
|
@@ -2075,8 +2106,8 @@ class z {
|
|
|
2075
2106
|
i(this, "onPortTouchStart", (e) => {
|
|
2076
2107
|
if (e.touches.length !== 1)
|
|
2077
2108
|
return;
|
|
2078
|
-
const t = e.touches[0],
|
|
2079
|
-
this.params.onPortPointerDown(
|
|
2109
|
+
const t = e.touches[0], s = e.currentTarget, o = this.canvas.graph.findPortIdsByElement(s)[0];
|
|
2110
|
+
this.params.onPortPointerDown(o, {
|
|
2080
2111
|
x: t.clientX,
|
|
2081
2112
|
y: t.clientY
|
|
2082
2113
|
}) && (e.stopPropagation(), this.window.addEventListener("touchmove", this.onWindowTouchMove, {
|
|
@@ -2113,10 +2144,10 @@ class z {
|
|
|
2113
2144
|
i(this, "onBeforeDestroy", () => {
|
|
2114
2145
|
this.params.onStopDrag(), this.removeWindowMouseListeners(), this.removeWindowTouchListeners();
|
|
2115
2146
|
});
|
|
2116
|
-
this.canvas = e, this.element = t, this.window =
|
|
2147
|
+
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
2148
|
}
|
|
2118
|
-
static configure(e, t,
|
|
2119
|
-
new z(e, t,
|
|
2149
|
+
static configure(e, t, s, o) {
|
|
2150
|
+
new z(e, t, s, o);
|
|
2120
2151
|
}
|
|
2121
2152
|
hookPortEvents(e) {
|
|
2122
2153
|
e.addEventListener("mousedown", this.onPortMouseDown, {
|
|
@@ -2142,7 +2173,7 @@ class z {
|
|
|
2142
2173
|
}
|
|
2143
2174
|
}
|
|
2144
2175
|
class Z {
|
|
2145
|
-
constructor(e, t,
|
|
2176
|
+
constructor(e, t, s, o) {
|
|
2146
2177
|
i(this, "grabbedNode", null);
|
|
2147
2178
|
i(this, "maxNodePriority", 0);
|
|
2148
2179
|
i(this, "graph");
|
|
@@ -2174,19 +2205,19 @@ class Z {
|
|
|
2174
2205
|
i(this, "onMouseDown", (e) => {
|
|
2175
2206
|
if (!this.params.mouseDownEventVerifier(e))
|
|
2176
2207
|
return;
|
|
2177
|
-
const t = e.currentTarget,
|
|
2178
|
-
if (!this.params.nodeDragVerifier(
|
|
2208
|
+
const t = e.currentTarget, s = this.graph.findNodeIdByElement(t), o = this.graph.getNode(s);
|
|
2209
|
+
if (!this.params.nodeDragVerifier(s))
|
|
2179
2210
|
return;
|
|
2180
|
-
this.params.onNodeDragStarted(
|
|
2211
|
+
this.params.onNodeDragStarted(s), e.stopPropagation();
|
|
2181
2212
|
const a = this.calculateContentPoint({
|
|
2182
2213
|
x: e.clientX,
|
|
2183
2214
|
y: e.clientY
|
|
2184
2215
|
});
|
|
2185
2216
|
this.grabbedNode = {
|
|
2186
|
-
nodeId:
|
|
2187
|
-
dx: a.x -
|
|
2188
|
-
dy: a.y -
|
|
2189
|
-
}, $(this.element, this.params.dragCursor), this.moveNodeOnTop(
|
|
2217
|
+
nodeId: s,
|
|
2218
|
+
dx: a.x - o.x,
|
|
2219
|
+
dy: a.y - o.y
|
|
2220
|
+
}, $(this.element, this.params.dragCursor), this.moveNodeOnTop(s), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
|
|
2190
2221
|
passive: !0
|
|
2191
2222
|
}), this.window.addEventListener("mouseup", this.onWindowMouseUp, {
|
|
2192
2223
|
passive: !0
|
|
@@ -2196,9 +2227,9 @@ class Z {
|
|
|
2196
2227
|
if (e.touches.length !== 1)
|
|
2197
2228
|
return;
|
|
2198
2229
|
e.stopPropagation();
|
|
2199
|
-
const t = e.touches[0],
|
|
2230
|
+
const t = e.touches[0], s = e.currentTarget, o = this.canvas.graph.findNodeIdByElement(s), n = this.graph.getNode(o);
|
|
2200
2231
|
if (!this.params.nodeDragVerifier({
|
|
2201
|
-
nodeId:
|
|
2232
|
+
nodeId: o,
|
|
2202
2233
|
element: n.element,
|
|
2203
2234
|
x: n.x,
|
|
2204
2235
|
y: n.y
|
|
@@ -2209,10 +2240,10 @@ class Z {
|
|
|
2209
2240
|
y: t.clientY
|
|
2210
2241
|
});
|
|
2211
2242
|
this.grabbedNode = {
|
|
2212
|
-
nodeId:
|
|
2243
|
+
nodeId: o,
|
|
2213
2244
|
dx: h.x - n.x,
|
|
2214
2245
|
dy: h.y - n.y
|
|
2215
|
-
}, this.moveNodeOnTop(
|
|
2246
|
+
}, this.moveNodeOnTop(o), this.window.addEventListener("touchmove", this.onWindowTouchMove, {
|
|
2216
2247
|
passive: !0
|
|
2217
2248
|
}), this.window.addEventListener("touchend", this.onWindowTouchFinish, {
|
|
2218
2249
|
passive: !0
|
|
@@ -2259,44 +2290,44 @@ class Z {
|
|
|
2259
2290
|
i(this, "onWindowTouchFinish", () => {
|
|
2260
2291
|
this.cancelTouchDrag();
|
|
2261
2292
|
});
|
|
2262
|
-
this.canvas = e, this.element = t, this.window =
|
|
2293
|
+
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
2294
|
}
|
|
2264
|
-
static configure(e, t,
|
|
2265
|
-
new Z(e, t,
|
|
2295
|
+
static configure(e, t, s, o) {
|
|
2296
|
+
new Z(e, t, s, o);
|
|
2266
2297
|
}
|
|
2267
2298
|
moveNode(e, t) {
|
|
2268
|
-
if (this.graph.
|
|
2299
|
+
if (!this.graph.hasNode(e.nodeId))
|
|
2269
2300
|
return;
|
|
2270
|
-
const s = this.calculateContentPoint(t),
|
|
2301
|
+
const s = this.calculateContentPoint(t), o = {
|
|
2271
2302
|
x: s.x - e.dx,
|
|
2272
2303
|
y: s.y - e.dy
|
|
2273
|
-
},
|
|
2304
|
+
}, n = this.adjustNodeCoords(o);
|
|
2274
2305
|
this.canvas.updateNode(e.nodeId, {
|
|
2275
|
-
x:
|
|
2276
|
-
y:
|
|
2306
|
+
x: n.x,
|
|
2307
|
+
y: n.y
|
|
2277
2308
|
}), this.params.onNodeDrag(e.nodeId);
|
|
2278
2309
|
}
|
|
2279
2310
|
moveNodeOnTop(e) {
|
|
2280
2311
|
if (this.params.moveOnTop) {
|
|
2281
2312
|
if (this.maxNodePriority++, this.params.moveEdgesOnTop) {
|
|
2282
2313
|
const t = this.maxNodePriority;
|
|
2283
|
-
this.maxNodePriority++, this.graph.getNodeAdjacentEdgeIds(e).forEach((
|
|
2284
|
-
this.canvas.updateEdge(
|
|
2314
|
+
this.maxNodePriority++, this.graph.getNodeAdjacentEdgeIds(e).forEach((o) => {
|
|
2315
|
+
this.canvas.updateEdge(o, { priority: t });
|
|
2285
2316
|
});
|
|
2286
2317
|
}
|
|
2287
2318
|
this.canvas.updateNode(e, { priority: this.maxNodePriority });
|
|
2288
2319
|
}
|
|
2289
2320
|
}
|
|
2290
2321
|
cancelMouseDrag() {
|
|
2291
|
-
this.grabbedNode !== null && this.graph.
|
|
2322
|
+
this.grabbedNode !== null && this.graph.hasNode(this.grabbedNode.nodeId) && this.params.onNodeDragFinished(this.grabbedNode.nodeId), this.grabbedNode = null, $(this.element, null), this.removeMouseDragListeners();
|
|
2292
2323
|
}
|
|
2293
2324
|
removeMouseDragListeners() {
|
|
2294
2325
|
this.window.removeEventListener("mouseup", this.onWindowMouseUp), this.window.removeEventListener("mousemove", this.onWindowMouseMove);
|
|
2295
2326
|
}
|
|
2296
2327
|
cancelTouchDrag() {
|
|
2297
|
-
if (this.grabbedNode !== null) {
|
|
2328
|
+
if (this.grabbedNode !== null && this.graph.hasNode(this.grabbedNode.nodeId)) {
|
|
2298
2329
|
const e = this.graph.getNode(this.grabbedNode.nodeId);
|
|
2299
|
-
|
|
2330
|
+
this.params.onNodeDragFinished({
|
|
2300
2331
|
nodeId: this.grabbedNode.nodeId,
|
|
2301
2332
|
element: e.element,
|
|
2302
2333
|
x: e.x,
|
|
@@ -2322,10 +2353,10 @@ class Z {
|
|
|
2322
2353
|
adjustNodeCoords(e) {
|
|
2323
2354
|
const t = this.params.gridSize;
|
|
2324
2355
|
if (t !== null) {
|
|
2325
|
-
const
|
|
2356
|
+
const s = t / 2;
|
|
2326
2357
|
return {
|
|
2327
|
-
x: Math.floor((e.x +
|
|
2328
|
-
y: Math.floor((e.y +
|
|
2358
|
+
x: Math.floor((e.x + s) / t) * t,
|
|
2359
|
+
y: Math.floor((e.y + s) / t) * t
|
|
2329
2360
|
};
|
|
2330
2361
|
}
|
|
2331
2362
|
return e;
|
|
@@ -2335,31 +2366,31 @@ const At = (r, e, t) => ({
|
|
|
2335
2366
|
scale: r.scale,
|
|
2336
2367
|
x: r.x + r.scale * e,
|
|
2337
2368
|
y: r.y + r.scale * t
|
|
2338
|
-
}), Et = (r, e, t,
|
|
2369
|
+
}), Et = (r, e, t, s) => ({
|
|
2339
2370
|
scale: r.scale * e,
|
|
2340
2371
|
x: r.scale * (1 - e) * t + r.x,
|
|
2341
|
-
y: r.scale * (1 - e) *
|
|
2372
|
+
y: r.scale * (1 - e) * s + r.y
|
|
2342
2373
|
}), I = (r) => {
|
|
2343
2374
|
const e = [], t = r.touches.length;
|
|
2344
2375
|
for (let h = 0; h < t; h++)
|
|
2345
2376
|
e.push([r.touches[h].clientX, r.touches[h].clientY]);
|
|
2346
|
-
const
|
|
2377
|
+
const s = e.reduce(
|
|
2347
2378
|
(h, d) => [h[0] + d[0], h[1] + d[1]],
|
|
2348
2379
|
[0, 0]
|
|
2349
|
-
),
|
|
2380
|
+
), o = [s[0] / t, s[1] / t], a = e.map((h) => [h[0] - o[0], h[1] - o[1]]).reduce(
|
|
2350
2381
|
(h, d) => h + Math.sqrt(d[0] * d[0] + d[1] * d[1]),
|
|
2351
2382
|
0
|
|
2352
2383
|
);
|
|
2353
2384
|
return {
|
|
2354
|
-
x:
|
|
2355
|
-
y:
|
|
2385
|
+
x: o[0],
|
|
2386
|
+
y: o[1],
|
|
2356
2387
|
scale: a / t,
|
|
2357
2388
|
touchesCnt: t,
|
|
2358
2389
|
touches: e
|
|
2359
2390
|
};
|
|
2360
2391
|
};
|
|
2361
2392
|
class H {
|
|
2362
|
-
constructor(e, t,
|
|
2393
|
+
constructor(e, t, s, o) {
|
|
2363
2394
|
i(this, "viewport");
|
|
2364
2395
|
i(this, "prevTouches", null);
|
|
2365
2396
|
i(this, "wheelFinishTimer", null);
|
|
@@ -2385,8 +2416,8 @@ class H {
|
|
|
2385
2416
|
this.stopMouseDrag();
|
|
2386
2417
|
return;
|
|
2387
2418
|
}
|
|
2388
|
-
const
|
|
2389
|
-
this.moveViewport(
|
|
2419
|
+
const s = -e.movementX, o = -e.movementY;
|
|
2420
|
+
this.moveViewport(s, o);
|
|
2390
2421
|
});
|
|
2391
2422
|
i(this, "onWindowMouseUp", (e) => {
|
|
2392
2423
|
this.params.mouseUpEventVerifier(e) && this.stopMouseDrag();
|
|
@@ -2394,8 +2425,8 @@ class H {
|
|
|
2394
2425
|
i(this, "onWheelScroll", (e) => {
|
|
2395
2426
|
if (!this.params.mouseWheelEventVerifier(e))
|
|
2396
2427
|
return;
|
|
2397
|
-
const { left: t, top:
|
|
2398
|
-
this.wheelFinishTimer === null && this.params.onTransformStarted(), this.scaleViewport(h,
|
|
2428
|
+
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);
|
|
2429
|
+
this.wheelFinishTimer === null && this.params.onTransformStarted(), this.scaleViewport(h, o, n), this.wheelFinishTimer !== null && clearTimeout(this.wheelFinishTimer), this.wheelFinishTimer = setTimeout(() => {
|
|
2399
2430
|
this.transformInProgress || this.params.onTransformFinished(), this.wheelFinishTimer = null;
|
|
2400
2431
|
}, this.params.scaleWheelFinishTimeout);
|
|
2401
2432
|
});
|
|
@@ -2415,7 +2446,7 @@ class H {
|
|
|
2415
2446
|
i(this, "onWindowTouchMove", (e) => {
|
|
2416
2447
|
const t = I(e);
|
|
2417
2448
|
if (!t.touches.every(
|
|
2418
|
-
(
|
|
2449
|
+
(o) => L(this.window, this.element, o[0], o[1])
|
|
2419
2450
|
)) {
|
|
2420
2451
|
this.stopTouchDrag();
|
|
2421
2452
|
return;
|
|
@@ -2424,7 +2455,7 @@ class H {
|
|
|
2424
2455
|
-(t.x - this.prevTouches.x),
|
|
2425
2456
|
-(t.y - this.prevTouches.y)
|
|
2426
2457
|
), t.touchesCnt === 2) {
|
|
2427
|
-
const { left:
|
|
2458
|
+
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
2459
|
this.scaleViewport(c, a, h);
|
|
2429
2460
|
}
|
|
2430
2461
|
this.prevTouches = t;
|
|
@@ -2435,7 +2466,7 @@ class H {
|
|
|
2435
2466
|
i(this, "preventWheelScaleListener", (e) => {
|
|
2436
2467
|
e.preventDefault();
|
|
2437
2468
|
});
|
|
2438
|
-
this.canvas = e, this.element = t, this.window =
|
|
2469
|
+
this.canvas = e, this.element = t, this.window = s, this.params = o, this.element.addEventListener("wheel", this.preventWheelScaleListener, {
|
|
2439
2470
|
passive: !1
|
|
2440
2471
|
}), this.viewport = e.viewport, this.handleResize(), this.viewport.onAfterResize.subscribe(() => {
|
|
2441
2472
|
this.handleResize();
|
|
@@ -2447,21 +2478,21 @@ class H {
|
|
|
2447
2478
|
passive: !0
|
|
2448
2479
|
}), e.onBeforeDestroy.subscribe(this.onBeforeDestroy);
|
|
2449
2480
|
}
|
|
2450
|
-
static configure(e, t,
|
|
2451
|
-
new H(e, t,
|
|
2481
|
+
static configure(e, t, s, o) {
|
|
2482
|
+
new H(e, t, s, o);
|
|
2452
2483
|
}
|
|
2453
2484
|
moveViewport(e, t) {
|
|
2454
|
-
const
|
|
2455
|
-
prevTransform:
|
|
2456
|
-
nextTransform:
|
|
2485
|
+
const s = this.viewport.getViewportMatrix(), o = At(s, e, t), { width: n, height: a } = this.viewport.getDimensions(), h = this.params.transformPreprocessor({
|
|
2486
|
+
prevTransform: s,
|
|
2487
|
+
nextTransform: o,
|
|
2457
2488
|
canvasWidth: n,
|
|
2458
2489
|
canvasHeight: a
|
|
2459
2490
|
});
|
|
2460
2491
|
this.performTransform(h);
|
|
2461
2492
|
}
|
|
2462
|
-
scaleViewport(e, t,
|
|
2463
|
-
const
|
|
2464
|
-
prevTransform:
|
|
2493
|
+
scaleViewport(e, t, s) {
|
|
2494
|
+
const o = this.canvas.viewport.getViewportMatrix(), n = Et(o, e, t, s), { width: a, height: h } = this.viewport.getDimensions(), d = this.params.transformPreprocessor({
|
|
2495
|
+
prevTransform: o,
|
|
2465
2496
|
nextTransform: n,
|
|
2466
2497
|
canvasWidth: a,
|
|
2467
2498
|
canvasHeight: h
|
|
@@ -2490,17 +2521,17 @@ class H {
|
|
|
2490
2521
|
this.transformInProgress = !1, this.params.onTransformFinished();
|
|
2491
2522
|
}
|
|
2492
2523
|
handleResize() {
|
|
2493
|
-
const e = this.viewport.getViewportMatrix(), { width: t, height:
|
|
2524
|
+
const e = this.viewport.getViewportMatrix(), { width: t, height: s } = this.viewport.getDimensions(), o = this.params.transformPreprocessor({
|
|
2494
2525
|
prevTransform: e,
|
|
2495
2526
|
nextTransform: e,
|
|
2496
2527
|
canvasWidth: t,
|
|
2497
|
-
canvasHeight:
|
|
2528
|
+
canvasHeight: s
|
|
2498
2529
|
});
|
|
2499
|
-
this.params.onResizeTransformStarted(), this.canvas.patchViewportMatrix(
|
|
2530
|
+
this.params.onResizeTransformStarted(), this.canvas.patchViewportMatrix(o), this.params.onResizeTransformFinished();
|
|
2500
2531
|
}
|
|
2501
2532
|
}
|
|
2502
2533
|
class J {
|
|
2503
|
-
constructor(e, t,
|
|
2534
|
+
constructor(e, t, s, o, n, a) {
|
|
2504
2535
|
i(this, "nodeHorizontal");
|
|
2505
2536
|
i(this, "nodeVertical");
|
|
2506
2537
|
i(this, "viewport");
|
|
@@ -2523,27 +2554,27 @@ class J {
|
|
|
2523
2554
|
this.userTransformInProgress || this.loadAreaAroundViewport();
|
|
2524
2555
|
});
|
|
2525
2556
|
i(this, "userTransformInProgress", !1);
|
|
2526
|
-
this.canvas = e, this.element = t, this.window =
|
|
2557
|
+
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
2558
|
this.scheduleLoadAreaAroundViewport();
|
|
2528
2559
|
});
|
|
2529
2560
|
const h = {
|
|
2530
|
-
...
|
|
2561
|
+
...o,
|
|
2531
2562
|
onResizeTransformStarted: () => {
|
|
2532
|
-
this.userTransformInProgress = !0,
|
|
2563
|
+
this.userTransformInProgress = !0, o.onResizeTransformStarted();
|
|
2533
2564
|
},
|
|
2534
2565
|
onResizeTransformFinished: () => {
|
|
2535
|
-
this.userTransformInProgress = !1,
|
|
2566
|
+
this.userTransformInProgress = !1, o.onResizeTransformFinished();
|
|
2536
2567
|
},
|
|
2537
2568
|
onBeforeTransformChange: () => {
|
|
2538
|
-
this.userTransformInProgress = !0,
|
|
2569
|
+
this.userTransformInProgress = !0, o.onBeforeTransformChange();
|
|
2539
2570
|
},
|
|
2540
2571
|
onTransformChange: () => {
|
|
2541
2572
|
this.userTransformInProgress = !1;
|
|
2542
2573
|
const d = this.currentScale;
|
|
2543
|
-
this.currentScale = this.viewport.getViewportMatrix().scale, d !== this.currentScale && this.scheduleEnsureViewportAreaLoaded(),
|
|
2574
|
+
this.currentScale = this.viewport.getViewportMatrix().scale, d !== this.currentScale && this.scheduleEnsureViewportAreaLoaded(), o.onTransformChange();
|
|
2544
2575
|
},
|
|
2545
2576
|
onTransformFinished: () => {
|
|
2546
|
-
this.scheduleLoadAreaAroundViewport(),
|
|
2577
|
+
this.scheduleLoadAreaAroundViewport(), o.onTransformFinished();
|
|
2547
2578
|
}
|
|
2548
2579
|
};
|
|
2549
2580
|
H.configure(
|
|
@@ -2553,12 +2584,12 @@ class J {
|
|
|
2553
2584
|
h
|
|
2554
2585
|
), this.trigger.subscribe(this.updateLoadedArea), this.canvas.viewport.onAfterUpdated.subscribe(this.onAfterViewportUpdated);
|
|
2555
2586
|
}
|
|
2556
|
-
static configure(e, t,
|
|
2587
|
+
static configure(e, t, s, o, n, a) {
|
|
2557
2588
|
new J(
|
|
2558
2589
|
e,
|
|
2559
2590
|
t,
|
|
2560
|
-
o,
|
|
2561
2591
|
s,
|
|
2592
|
+
o,
|
|
2562
2593
|
n,
|
|
2563
2594
|
a
|
|
2564
2595
|
);
|
|
@@ -2570,12 +2601,12 @@ class J {
|
|
|
2570
2601
|
}
|
|
2571
2602
|
scheduleEnsureViewportAreaLoaded() {
|
|
2572
2603
|
setTimeout(() => {
|
|
2573
|
-
const { width: e, height: t } = this.viewport.getDimensions(), { scale:
|
|
2604
|
+
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
2605
|
this.loadedArea.xFrom < d && this.loadedArea.xTo > g && this.loadedArea.yFrom < c && this.loadedArea.yTo > l || this.loadAreaAroundViewport();
|
|
2575
2606
|
});
|
|
2576
2607
|
}
|
|
2577
2608
|
loadAreaAroundViewport() {
|
|
2578
|
-
const { width: e, height: t } = this.viewport.getDimensions(), { scale:
|
|
2609
|
+
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
2610
|
this.trigger.emit({
|
|
2580
2611
|
x: d,
|
|
2581
2612
|
y: c,
|
|
@@ -2598,7 +2629,7 @@ const xt = () => {
|
|
|
2598
2629
|
return r.setAttribute("id", "pattern"), r;
|
|
2599
2630
|
};
|
|
2600
2631
|
class _ {
|
|
2601
|
-
constructor(e, t,
|
|
2632
|
+
constructor(e, t, s) {
|
|
2602
2633
|
i(this, "svg", xt());
|
|
2603
2634
|
i(this, "patternRenderingRectangle", St());
|
|
2604
2635
|
i(this, "pattern", bt());
|
|
@@ -2610,19 +2641,19 @@ class _ {
|
|
|
2610
2641
|
i(this, "maxViewportScale");
|
|
2611
2642
|
i(this, "visible", !1);
|
|
2612
2643
|
i(this, "onAfterTransformUpdated", () => {
|
|
2613
|
-
const e = this.canvas.viewport.getContentMatrix(), t = e.x - this.halfTileWidth * e.scale,
|
|
2614
|
-
this.pattern.setAttribute("patternTransform",
|
|
2644
|
+
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})`;
|
|
2645
|
+
this.pattern.setAttribute("patternTransform", o), this.updateVisibility();
|
|
2615
2646
|
});
|
|
2616
|
-
this.canvas = e, this.backgroundHost =
|
|
2617
|
-
const
|
|
2618
|
-
this.patternContent.setAttribute("transform",
|
|
2647
|
+
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;
|
|
2648
|
+
const o = `translate(${this.halfTileWidth}, ${this.halfTileHeight})`;
|
|
2649
|
+
this.patternContent.setAttribute("transform", o), this.pattern.appendChild(this.patternContent);
|
|
2619
2650
|
const n = document.createElementNS("http://www.w3.org/2000/svg", "defs");
|
|
2620
2651
|
n.appendChild(this.pattern), this.svg.appendChild(n), this.svg.appendChild(this.patternRenderingRectangle), this.updateDimensions(), this.canvas.viewport.onAfterResize.subscribe(() => {
|
|
2621
2652
|
this.updateDimensions();
|
|
2622
2653
|
}), this.canvas.viewport.onAfterUpdated.subscribe(this.onAfterTransformUpdated), this.onAfterTransformUpdated();
|
|
2623
2654
|
}
|
|
2624
|
-
static configure(e, t,
|
|
2625
|
-
new _(e, t,
|
|
2655
|
+
static configure(e, t, s) {
|
|
2656
|
+
new _(e, t, s);
|
|
2626
2657
|
}
|
|
2627
2658
|
updateVisibility() {
|
|
2628
2659
|
const t = this.canvas.viewport.getViewportMatrix().scale > this.maxViewportScale;
|
|
@@ -2631,19 +2662,19 @@ class _ {
|
|
|
2631
2662
|
updateDimensions() {
|
|
2632
2663
|
const { width: e, height: t } = this.canvas.viewport.getDimensions();
|
|
2633
2664
|
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", `${
|
|
2665
|
+
const s = this.tileWidth / e, o = this.tileHeight / t;
|
|
2666
|
+
this.pattern.setAttribute("width", `${s}`), this.pattern.setAttribute("height", `${o}`);
|
|
2636
2667
|
}
|
|
2637
2668
|
}
|
|
2638
2669
|
class ee {
|
|
2639
|
-
constructor(e, t,
|
|
2670
|
+
constructor(e, t, s, o, n) {
|
|
2640
2671
|
i(this, "overlayCanvas");
|
|
2641
2672
|
i(this, "staticPortId", null);
|
|
2642
2673
|
i(this, "isTargetDragging", !0);
|
|
2643
2674
|
i(this, "onEdgeCreated", (e) => {
|
|
2644
2675
|
this.params.onAfterEdgeCreated(e);
|
|
2645
2676
|
});
|
|
2646
|
-
this.canvas = e, this.overlayLayer = t, this.viewportStore =
|
|
2677
|
+
this.canvas = e, this.overlayLayer = t, this.viewportStore = s, this.window = o, this.params = n, this.overlayCanvas = Ve(
|
|
2647
2678
|
this.overlayLayer,
|
|
2648
2679
|
this.viewportStore
|
|
2649
2680
|
), z.configure(
|
|
@@ -2669,69 +2700,69 @@ class ee {
|
|
|
2669
2700
|
}
|
|
2670
2701
|
);
|
|
2671
2702
|
}
|
|
2672
|
-
static configure(e, t,
|
|
2703
|
+
static configure(e, t, s, o, n) {
|
|
2673
2704
|
new ee(
|
|
2674
2705
|
e,
|
|
2675
2706
|
t,
|
|
2676
|
-
o,
|
|
2677
2707
|
s,
|
|
2708
|
+
o,
|
|
2678
2709
|
n
|
|
2679
2710
|
);
|
|
2680
2711
|
}
|
|
2681
|
-
grabPort(e, t,
|
|
2682
|
-
const
|
|
2712
|
+
grabPort(e, t, s) {
|
|
2713
|
+
const o = this.canvas.graph.getPort(e);
|
|
2683
2714
|
this.staticPortId = e;
|
|
2684
|
-
const n =
|
|
2715
|
+
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
2716
|
x: a - d.x,
|
|
2686
2717
|
y: h - d.y
|
|
2687
2718
|
}), g = this.canvas.viewport.createContentCoords({
|
|
2688
2719
|
x: t.x - d.x,
|
|
2689
2720
|
y: t.y - d.y
|
|
2690
2721
|
}), l = {
|
|
2691
|
-
overlayNodeId:
|
|
2722
|
+
overlayNodeId: T.StaticNodeId,
|
|
2692
2723
|
portCoords: c,
|
|
2693
|
-
portDirection:
|
|
2724
|
+
portDirection: o.direction
|
|
2694
2725
|
}, u = {
|
|
2695
|
-
overlayNodeId:
|
|
2726
|
+
overlayNodeId: T.DraggingNodeId,
|
|
2696
2727
|
portCoords: g,
|
|
2697
2728
|
portDirection: this.params.dragPortDirection
|
|
2698
2729
|
};
|
|
2699
|
-
this.isTargetDragging =
|
|
2700
|
-
const [w,
|
|
2701
|
-
this.overlayCanvas.addNode(U(w)), this.overlayCanvas.addNode(U(
|
|
2730
|
+
this.isTargetDragging = s === "direct";
|
|
2731
|
+
const [w, f] = this.isTargetDragging ? [l, u] : [u, l];
|
|
2732
|
+
this.overlayCanvas.addNode(U(w)), this.overlayCanvas.addNode(U(f)), this.overlayCanvas.addEdge({
|
|
2702
2733
|
from: w.overlayNodeId,
|
|
2703
|
-
to:
|
|
2704
|
-
shape: this.params.edgeShapeFactory(
|
|
2734
|
+
to: f.overlayNodeId,
|
|
2735
|
+
shape: this.params.edgeShapeFactory(T.EdgeId)
|
|
2705
2736
|
});
|
|
2706
2737
|
}
|
|
2707
2738
|
resetDragState() {
|
|
2708
2739
|
this.staticPortId = null, this.isTargetDragging = !0, this.overlayCanvas.clear();
|
|
2709
2740
|
}
|
|
2710
2741
|
tryCreateConnection(e) {
|
|
2711
|
-
const t = xe(this.canvas.graph, e),
|
|
2742
|
+
const t = xe(this.canvas.graph, e), s = this.staticPortId;
|
|
2712
2743
|
if (t === null) {
|
|
2713
2744
|
this.params.onEdgeCreationInterrupted({
|
|
2714
|
-
staticPortId:
|
|
2745
|
+
staticPortId: s,
|
|
2715
2746
|
isDirect: this.isTargetDragging
|
|
2716
2747
|
});
|
|
2717
2748
|
return;
|
|
2718
2749
|
}
|
|
2719
|
-
const
|
|
2750
|
+
const o = this.isTargetDragging ? s : t, n = this.isTargetDragging ? t : s, a = { from: o, to: n }, h = this.params.connectionPreprocessor(a);
|
|
2720
2751
|
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
2752
|
}
|
|
2722
2753
|
moveDraggingPort(e) {
|
|
2723
|
-
const t = this.overlayLayer.getBoundingClientRect(),
|
|
2754
|
+
const t = this.overlayLayer.getBoundingClientRect(), s = this.canvas.viewport.createContentCoords({
|
|
2724
2755
|
x: e.x - t.x,
|
|
2725
2756
|
y: e.y - t.y
|
|
2726
2757
|
});
|
|
2727
|
-
this.overlayCanvas.updateNode(
|
|
2728
|
-
x:
|
|
2729
|
-
y:
|
|
2758
|
+
this.overlayCanvas.updateNode(T.DraggingNodeId, {
|
|
2759
|
+
x: s.x,
|
|
2760
|
+
y: s.y
|
|
2730
2761
|
});
|
|
2731
2762
|
}
|
|
2732
2763
|
}
|
|
2733
2764
|
class te {
|
|
2734
|
-
constructor(e, t,
|
|
2765
|
+
constructor(e, t, s, o, n) {
|
|
2735
2766
|
i(this, "overlayCanvas");
|
|
2736
2767
|
i(this, "staticPortId", null);
|
|
2737
2768
|
i(this, "isTargetDragging", !0);
|
|
@@ -2739,7 +2770,7 @@ class te {
|
|
|
2739
2770
|
i(this, "onEdgeReattached", (e) => {
|
|
2740
2771
|
this.params.onAfterEdgeReattached(e);
|
|
2741
2772
|
});
|
|
2742
|
-
this.canvas = e, this.overlayLayer = t, this.viewportStore =
|
|
2773
|
+
this.canvas = e, this.overlayLayer = t, this.viewportStore = s, this.window = o, this.params = n, this.overlayCanvas = Ve(
|
|
2743
2774
|
this.overlayLayer,
|
|
2744
2775
|
this.viewportStore
|
|
2745
2776
|
), z.configure(
|
|
@@ -2762,23 +2793,20 @@ class te {
|
|
|
2762
2793
|
}
|
|
2763
2794
|
);
|
|
2764
2795
|
}
|
|
2765
|
-
static configure(e, t,
|
|
2796
|
+
static configure(e, t, s, o, n) {
|
|
2766
2797
|
new te(
|
|
2767
2798
|
e,
|
|
2768
2799
|
t,
|
|
2769
|
-
o,
|
|
2770
2800
|
s,
|
|
2801
|
+
o,
|
|
2771
2802
|
n
|
|
2772
2803
|
);
|
|
2773
2804
|
}
|
|
2774
2805
|
tryStartEdgeDragging(e, t) {
|
|
2775
|
-
const
|
|
2776
|
-
if (
|
|
2806
|
+
const s = this.params.draggingEdgeResolver(e);
|
|
2807
|
+
if (s === null || !this.canvas.graph.hasEdge(s))
|
|
2777
2808
|
return !1;
|
|
2778
|
-
const
|
|
2779
|
-
if (s === null)
|
|
2780
|
-
return !1;
|
|
2781
|
-
const n = e === s.from, a = e === s.to, h = n ? s.to : s.from;
|
|
2809
|
+
const o = this.canvas.graph.getEdge(s), n = e === o.from, a = e === o.to, h = n ? o.to : o.from;
|
|
2782
2810
|
this.staticPortId = h, this.isTargetDragging = a;
|
|
2783
2811
|
const d = this.canvas.graph.getPort(e), c = this.canvas.graph.getPort(h), g = c.element.getBoundingClientRect(), l = {
|
|
2784
2812
|
x: g.x + g.width / 2,
|
|
@@ -2786,32 +2814,32 @@ class te {
|
|
|
2786
2814
|
}, u = this.overlayLayer.getBoundingClientRect(), w = this.canvas.viewport.createContentCoords({
|
|
2787
2815
|
x: l.x - u.x,
|
|
2788
2816
|
y: l.y - u.y
|
|
2789
|
-
}),
|
|
2817
|
+
}), f = this.canvas.viewport.createContentCoords({
|
|
2790
2818
|
x: t.x - u.x,
|
|
2791
2819
|
y: t.y - u.y
|
|
2792
2820
|
});
|
|
2793
2821
|
this.draggingEdgePayload = {
|
|
2794
|
-
id:
|
|
2795
|
-
from:
|
|
2796
|
-
to:
|
|
2797
|
-
shape:
|
|
2798
|
-
priority:
|
|
2799
|
-
}, this.canvas.removeEdge(
|
|
2800
|
-
const
|
|
2801
|
-
overlayNodeId:
|
|
2822
|
+
id: s,
|
|
2823
|
+
from: o.from,
|
|
2824
|
+
to: o.to,
|
|
2825
|
+
shape: o.shape,
|
|
2826
|
+
priority: o.priority
|
|
2827
|
+
}, this.canvas.removeEdge(s);
|
|
2828
|
+
const E = {
|
|
2829
|
+
overlayNodeId: T.StaticNodeId,
|
|
2802
2830
|
portCoords: w,
|
|
2803
2831
|
portDirection: c.direction
|
|
2804
|
-
},
|
|
2805
|
-
overlayNodeId:
|
|
2806
|
-
portCoords:
|
|
2832
|
+
}, S = {
|
|
2833
|
+
overlayNodeId: T.DraggingNodeId,
|
|
2834
|
+
portCoords: f,
|
|
2807
2835
|
portDirection: d.direction
|
|
2808
|
-
}, [
|
|
2809
|
-
this.overlayCanvas.addNode(U(
|
|
2810
|
-
const P = this.params.draggingEdgeShapeFactory !== null ? this.params.draggingEdgeShapeFactory(
|
|
2836
|
+
}, [b, C] = this.isTargetDragging ? [E, S] : [S, E];
|
|
2837
|
+
this.overlayCanvas.addNode(U(b)), this.overlayCanvas.addNode(U(C));
|
|
2838
|
+
const P = this.params.draggingEdgeShapeFactory !== null ? this.params.draggingEdgeShapeFactory(T.EdgeId) : o.shape;
|
|
2811
2839
|
return this.overlayCanvas.addEdge({
|
|
2812
|
-
id:
|
|
2813
|
-
from:
|
|
2814
|
-
to:
|
|
2840
|
+
id: T.EdgeId,
|
|
2841
|
+
from: b.overlayNodeId,
|
|
2842
|
+
to: C.overlayNodeId,
|
|
2815
2843
|
shape: P
|
|
2816
2844
|
}), !0;
|
|
2817
2845
|
}
|
|
@@ -2819,18 +2847,18 @@ class te {
|
|
|
2819
2847
|
this.draggingEdgePayload = null, this.staticPortId = null, this.isTargetDragging = !0, this.overlayCanvas.clear();
|
|
2820
2848
|
}
|
|
2821
2849
|
moveDraggingPort(e) {
|
|
2822
|
-
const t = this.overlayLayer.getBoundingClientRect(),
|
|
2850
|
+
const t = this.overlayLayer.getBoundingClientRect(), s = {
|
|
2823
2851
|
x: e.x - t.x,
|
|
2824
2852
|
y: e.y - t.y
|
|
2825
|
-
},
|
|
2826
|
-
this.overlayCanvas.updateNode(
|
|
2827
|
-
x:
|
|
2828
|
-
y:
|
|
2853
|
+
}, o = this.canvas.viewport.createContentCoords(s);
|
|
2854
|
+
this.overlayCanvas.updateNode(T.DraggingNodeId, {
|
|
2855
|
+
x: o.x,
|
|
2856
|
+
y: o.y
|
|
2829
2857
|
});
|
|
2830
2858
|
}
|
|
2831
2859
|
tryCreateConnection(e) {
|
|
2832
2860
|
const t = xe(this.canvas.graph, e);
|
|
2833
|
-
if (this.overlayCanvas.removeEdge(
|
|
2861
|
+
if (this.overlayCanvas.removeEdge(T.EdgeId), t === null) {
|
|
2834
2862
|
const d = this.draggingEdgePayload;
|
|
2835
2863
|
this.params.onEdgeReattachInterrupted({
|
|
2836
2864
|
id: d.id,
|
|
@@ -2841,10 +2869,10 @@ class te {
|
|
|
2841
2869
|
});
|
|
2842
2870
|
return;
|
|
2843
2871
|
}
|
|
2844
|
-
const [
|
|
2872
|
+
const [s, o] = this.isTargetDragging ? [this.staticPortId, t] : [t, this.staticPortId], n = this.draggingEdgePayload, a = {
|
|
2845
2873
|
id: n.id,
|
|
2846
|
-
from:
|
|
2847
|
-
to:
|
|
2874
|
+
from: s,
|
|
2875
|
+
to: o,
|
|
2848
2876
|
shape: n.shape,
|
|
2849
2877
|
priority: n.priority
|
|
2850
2878
|
}, h = this.params.connectionPreprocessor(a);
|
|
@@ -2863,39 +2891,39 @@ class te {
|
|
|
2863
2891
|
}
|
|
2864
2892
|
}
|
|
2865
2893
|
class re {
|
|
2866
|
-
constructor(e, t,
|
|
2867
|
-
this.canvas = e, this.layoutAlgorithm = t, this.trigger =
|
|
2894
|
+
constructor(e, t, s) {
|
|
2895
|
+
this.canvas = e, this.layoutAlgorithm = t, this.trigger = s, this.trigger.subscribe(() => {
|
|
2868
2896
|
this.applyLayout();
|
|
2869
2897
|
});
|
|
2870
2898
|
}
|
|
2871
|
-
static configure(e, t,
|
|
2899
|
+
static configure(e, t, s) {
|
|
2872
2900
|
new re(
|
|
2873
2901
|
e,
|
|
2874
2902
|
t,
|
|
2875
|
-
|
|
2903
|
+
s
|
|
2876
2904
|
);
|
|
2877
2905
|
}
|
|
2878
2906
|
applyLayout() {
|
|
2879
|
-
this.layoutAlgorithm.calculateCoordinates(
|
|
2880
|
-
this.canvas.graph,
|
|
2881
|
-
this.canvas.viewport
|
|
2882
|
-
).forEach((t,
|
|
2883
|
-
this.canvas.updateNode(
|
|
2907
|
+
this.layoutAlgorithm.calculateCoordinates({
|
|
2908
|
+
graph: this.canvas.graph,
|
|
2909
|
+
viewport: this.canvas.viewport
|
|
2910
|
+
}).forEach((t, s) => {
|
|
2911
|
+
this.canvas.updateNode(s, t);
|
|
2884
2912
|
});
|
|
2885
2913
|
}
|
|
2886
2914
|
}
|
|
2887
2915
|
class O {
|
|
2888
|
-
constructor(e, t,
|
|
2916
|
+
constructor(e, t, s) {
|
|
2889
2917
|
i(this, "applyScheduled", !1);
|
|
2890
2918
|
i(this, "apply", () => {
|
|
2891
|
-
this.applyScheduled = !1, this.layoutAlgorithm.calculateCoordinates(
|
|
2892
|
-
this.canvas.graph,
|
|
2893
|
-
this.canvas.viewport
|
|
2894
|
-
).forEach((t,
|
|
2895
|
-
this.canvas.updateNode(
|
|
2919
|
+
this.applyScheduled = !1, this.layoutAlgorithm.calculateCoordinates({
|
|
2920
|
+
graph: this.canvas.graph,
|
|
2921
|
+
viewport: this.canvas.viewport
|
|
2922
|
+
}).forEach((t, s) => {
|
|
2923
|
+
this.canvas.updateNode(s, t);
|
|
2896
2924
|
});
|
|
2897
2925
|
});
|
|
2898
|
-
this.canvas = e, this.layoutAlgorithm = t, this.defererFn =
|
|
2926
|
+
this.canvas = e, this.layoutAlgorithm = t, this.defererFn = s, this.canvas.graph.onAfterNodeAdded.subscribe(() => {
|
|
2899
2927
|
this.scheduleApply();
|
|
2900
2928
|
}), this.canvas.graph.onBeforeNodeRemoved.subscribe(() => {
|
|
2901
2929
|
this.scheduleApply();
|
|
@@ -2905,11 +2933,11 @@ class O {
|
|
|
2905
2933
|
this.scheduleApply();
|
|
2906
2934
|
});
|
|
2907
2935
|
}
|
|
2908
|
-
static configure(e, t,
|
|
2936
|
+
static configure(e, t, s) {
|
|
2909
2937
|
new O(
|
|
2910
2938
|
e,
|
|
2911
2939
|
t,
|
|
2912
|
-
|
|
2940
|
+
s
|
|
2913
2941
|
);
|
|
2914
2942
|
}
|
|
2915
2943
|
scheduleApply() {
|
|
@@ -2918,13 +2946,13 @@ class O {
|
|
|
2918
2946
|
}
|
|
2919
2947
|
class Pt {
|
|
2920
2948
|
static configure(e, t) {
|
|
2921
|
-
const
|
|
2922
|
-
switch (
|
|
2949
|
+
const s = t.applyOn;
|
|
2950
|
+
switch (s.type) {
|
|
2923
2951
|
case "manual": {
|
|
2924
2952
|
re.configure(
|
|
2925
2953
|
e,
|
|
2926
2954
|
t.algorithm,
|
|
2927
|
-
|
|
2955
|
+
s.trigger
|
|
2928
2956
|
);
|
|
2929
2957
|
break;
|
|
2930
2958
|
}
|
|
@@ -2932,9 +2960,9 @@ class Pt {
|
|
|
2932
2960
|
O.configure(
|
|
2933
2961
|
e,
|
|
2934
2962
|
t.algorithm,
|
|
2935
|
-
(
|
|
2963
|
+
(o) => {
|
|
2936
2964
|
setTimeout(() => {
|
|
2937
|
-
|
|
2965
|
+
o();
|
|
2938
2966
|
});
|
|
2939
2967
|
}
|
|
2940
2968
|
);
|
|
@@ -2944,9 +2972,9 @@ class Pt {
|
|
|
2944
2972
|
O.configure(
|
|
2945
2973
|
e,
|
|
2946
2974
|
t.algorithm,
|
|
2947
|
-
(
|
|
2975
|
+
(o) => {
|
|
2948
2976
|
queueMicrotask(() => {
|
|
2949
|
-
|
|
2977
|
+
o();
|
|
2950
2978
|
});
|
|
2951
2979
|
}
|
|
2952
2980
|
);
|
|
@@ -2955,7 +2983,7 @@ class Pt {
|
|
|
2955
2983
|
}
|
|
2956
2984
|
}
|
|
2957
2985
|
}
|
|
2958
|
-
class
|
|
2986
|
+
class Tt {
|
|
2959
2987
|
constructor(e, t) {
|
|
2960
2988
|
i(this, "previousTimeStamp");
|
|
2961
2989
|
i(this, "step", (e) => {
|
|
@@ -2970,24 +2998,24 @@ class Ct {
|
|
|
2970
2998
|
this.win = e, this.callback = t, this.win.requestAnimationFrame(this.step);
|
|
2971
2999
|
}
|
|
2972
3000
|
}
|
|
2973
|
-
class
|
|
2974
|
-
constructor(e, t,
|
|
3001
|
+
class se {
|
|
3002
|
+
constructor(e, t, s, o) {
|
|
2975
3003
|
i(this, "step", (e) => {
|
|
2976
|
-
this.algorithm.calculateNextCoordinates(
|
|
2977
|
-
this.canvas.graph,
|
|
2978
|
-
e,
|
|
2979
|
-
this.canvas.viewport
|
|
2980
|
-
).forEach((
|
|
2981
|
-
this.staticNodes.has(
|
|
3004
|
+
this.algorithm.calculateNextCoordinates({
|
|
3005
|
+
graph: this.canvas.graph,
|
|
3006
|
+
dt: e,
|
|
3007
|
+
viewport: this.canvas.viewport
|
|
3008
|
+
}).forEach((s, o) => {
|
|
3009
|
+
this.staticNodes.has(o) || this.canvas.updateNode(o, { x: s.x, y: s.y });
|
|
2982
3010
|
});
|
|
2983
3011
|
});
|
|
2984
|
-
this.canvas = e, this.algorithm = t, this.staticNodes =
|
|
3012
|
+
this.canvas = e, this.algorithm = t, this.staticNodes = s, this.win = o, new Tt(this.win, this.step);
|
|
2985
3013
|
}
|
|
2986
|
-
static configure(e, t,
|
|
2987
|
-
new
|
|
3014
|
+
static configure(e, t, s, o) {
|
|
3015
|
+
new se(e, t, s, o);
|
|
2988
3016
|
}
|
|
2989
3017
|
}
|
|
2990
|
-
const
|
|
3018
|
+
const Ct = () => {
|
|
2991
3019
|
const r = document.createElement("div");
|
|
2992
3020
|
return r.style.width = "100%", r.style.height = "100%", r.style.position = "relative", r;
|
|
2993
3021
|
}, Y = () => {
|
|
@@ -2997,30 +3025,30 @@ const Tt = () => {
|
|
|
2997
3025
|
const r = Y();
|
|
2998
3026
|
return r.style.pointerEvents = "none", r;
|
|
2999
3027
|
};
|
|
3000
|
-
class
|
|
3028
|
+
class Nt {
|
|
3001
3029
|
constructor(e) {
|
|
3002
3030
|
i(this, "background", Y());
|
|
3003
3031
|
i(this, "main", Y());
|
|
3004
3032
|
i(this, "overlayConnectablePorts", pe());
|
|
3005
3033
|
i(this, "overlayDraggableEdges", pe());
|
|
3006
|
-
i(this, "host",
|
|
3034
|
+
i(this, "host", Ct());
|
|
3007
3035
|
this.element = e, this.element.appendChild(this.host), this.host.appendChild(this.background), this.host.appendChild(this.main), this.host.appendChild(this.overlayConnectablePorts), this.host.appendChild(this.overlayDraggableEdges);
|
|
3008
3036
|
}
|
|
3009
3037
|
destroy() {
|
|
3010
3038
|
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
3039
|
}
|
|
3012
3040
|
}
|
|
3013
|
-
const G = (r) => () => r, we = G(0),
|
|
3041
|
+
const G = (r) => () => r, we = G(0), Dt = () => {
|
|
3014
3042
|
let r = 0;
|
|
3015
3043
|
return () => r++;
|
|
3016
3044
|
}, Mt = (r, e) => {
|
|
3017
|
-
let t = we,
|
|
3018
|
-
const
|
|
3019
|
-
return r === "incremental" && (t =
|
|
3045
|
+
let t = we, s = we;
|
|
3046
|
+
const o = Dt();
|
|
3047
|
+
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
3048
|
nodesPriorityFn: t,
|
|
3021
|
-
edgesPriorityFn:
|
|
3049
|
+
edgesPriorityFn: s
|
|
3022
3050
|
};
|
|
3023
|
-
},
|
|
3051
|
+
}, oe = (r) => {
|
|
3024
3052
|
if (typeof r == "function")
|
|
3025
3053
|
return r;
|
|
3026
3054
|
switch (r.type) {
|
|
@@ -3065,7 +3093,7 @@ const G = (r) => () => r, we = G(0), Nt = () => {
|
|
|
3065
3093
|
detourDistance: r.detourDistance
|
|
3066
3094
|
});
|
|
3067
3095
|
case "direct":
|
|
3068
|
-
return () => new
|
|
3096
|
+
return () => new De({
|
|
3069
3097
|
color: r.color,
|
|
3070
3098
|
width: r.width,
|
|
3071
3099
|
arrowLength: r.arrowLength,
|
|
@@ -3091,30 +3119,30 @@ const G = (r) => () => r, we = G(0), Nt = () => {
|
|
|
3091
3119
|
});
|
|
3092
3120
|
}
|
|
3093
3121
|
}, Lt = (r) => {
|
|
3094
|
-
var t,
|
|
3122
|
+
var t, s, o, n, a;
|
|
3095
3123
|
const e = Mt(
|
|
3096
3124
|
(t = r.nodes) == null ? void 0 : t.priority,
|
|
3097
|
-
(
|
|
3125
|
+
(s = r.edges) == null ? void 0 : s.priority
|
|
3098
3126
|
);
|
|
3099
3127
|
return {
|
|
3100
3128
|
nodes: {
|
|
3101
|
-
centerFn: ((
|
|
3129
|
+
centerFn: ((o = r.nodes) == null ? void 0 : o.centerFn) ?? Se,
|
|
3102
3130
|
priorityFn: e.nodesPriorityFn
|
|
3103
3131
|
},
|
|
3104
3132
|
ports: {
|
|
3105
3133
|
direction: ((n = r.ports) == null ? void 0 : n.direction) ?? 0
|
|
3106
3134
|
},
|
|
3107
3135
|
edges: {
|
|
3108
|
-
shapeFactory:
|
|
3136
|
+
shapeFactory: oe(((a = r.edges) == null ? void 0 : a.shape) ?? {}),
|
|
3109
3137
|
priorityFn: e.edgesPriorityFn
|
|
3110
3138
|
}
|
|
3111
3139
|
};
|
|
3112
3140
|
}, Rt = (r) => {
|
|
3113
|
-
var w,
|
|
3141
|
+
var w, f, E, S, b, C;
|
|
3114
3142
|
const e = ((w = r.events) == null ? void 0 : w.onNodeDragStarted) ?? (() => {
|
|
3115
|
-
}), t = ((
|
|
3116
|
-
}),
|
|
3117
|
-
}), n = r.moveOnTop !== !1, a = r.moveEdgesOnTop !== !1 && n, h = (
|
|
3143
|
+
}), t = ((f = r.events) == null ? void 0 : f.onNodeDrag) ?? (() => {
|
|
3144
|
+
}), s = r.nodeDragVerifier ?? (() => !0), o = ((E = r.events) == null ? void 0 : E.onNodeDragFinished) ?? (() => {
|
|
3145
|
+
}), n = r.moveOnTop !== !1, a = r.moveEdgesOnTop !== !1 && n, h = (S = r.mouse) == null ? void 0 : S.dragCursor, d = h !== void 0 ? h : "grab", c = (b = r.mouse) == null ? void 0 : b.mouseDownEventVerifier, g = c !== void 0 ? c : (P) => P.button === 0, l = (C = r.mouse) == null ? void 0 : C.mouseUpEventVerifier, u = l !== void 0 ? l : (P) => P.button === 0;
|
|
3118
3146
|
return {
|
|
3119
3147
|
moveOnTop: n,
|
|
3120
3148
|
moveEdgesOnTop: a,
|
|
@@ -3124,31 +3152,31 @@ const G = (r) => () => r, we = G(0), Nt = () => {
|
|
|
3124
3152
|
mouseUpEventVerifier: u,
|
|
3125
3153
|
onNodeDragStarted: e,
|
|
3126
3154
|
onNodeDrag: t,
|
|
3127
|
-
nodeDragVerifier:
|
|
3128
|
-
onNodeDragFinished:
|
|
3155
|
+
nodeDragVerifier: s,
|
|
3156
|
+
onNodeDragFinished: o
|
|
3129
3157
|
};
|
|
3130
3158
|
}, Vt = (r) => {
|
|
3131
|
-
const e = r.minX !== null ? r.minX : -1 / 0, t = r.maxX !== null ? r.maxX : 1 / 0,
|
|
3159
|
+
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
3160
|
return (n) => {
|
|
3133
3161
|
let a = n.nextTransform.x, h = n.nextTransform.y;
|
|
3134
3162
|
a < e && a < n.prevTransform.x && (a = Math.min(n.prevTransform.x, e));
|
|
3135
3163
|
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 =
|
|
3164
|
+
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));
|
|
3165
|
+
const g = n.canvasHeight * n.prevTransform.scale, l = o - g;
|
|
3138
3166
|
return h > l && h > n.prevTransform.y && (h = Math.max(n.prevTransform.y, l)), { scale: n.nextTransform.scale, x: a, y: h };
|
|
3139
3167
|
};
|
|
3140
3168
|
}, Ft = (r) => {
|
|
3141
|
-
const e = r.maxContentScale, t = r.minContentScale,
|
|
3169
|
+
const e = r.maxContentScale, t = r.minContentScale, s = e !== null ? 1 / e : 0, o = t !== null ? 1 / t : 1 / 0;
|
|
3142
3170
|
return (n) => {
|
|
3143
3171
|
const a = n.prevTransform, h = n.nextTransform;
|
|
3144
3172
|
let d = h.scale, c = h.x, g = h.y;
|
|
3145
|
-
if (h.scale >
|
|
3146
|
-
d = Math.max(a.scale,
|
|
3173
|
+
if (h.scale > o && h.scale > a.scale) {
|
|
3174
|
+
d = Math.max(a.scale, o), c = a.x, g = a.y;
|
|
3147
3175
|
const l = (d - a.scale) / (h.scale - a.scale);
|
|
3148
3176
|
c = a.x + (h.x - a.x) * l, g = a.y + (h.y - a.y) * l;
|
|
3149
3177
|
}
|
|
3150
|
-
if (h.scale <
|
|
3151
|
-
d = Math.min(a.scale,
|
|
3178
|
+
if (h.scale < s && h.scale < a.scale) {
|
|
3179
|
+
d = Math.min(a.scale, s), c = a.x, g = a.y;
|
|
3152
3180
|
const l = (d - a.scale) / (h.scale - a.scale);
|
|
3153
3181
|
c = a.x + (h.x - a.x) * l, g = a.y + (h.y - a.y) * l;
|
|
3154
3182
|
}
|
|
@@ -3159,7 +3187,7 @@ const G = (r) => () => r, we = G(0), Nt = () => {
|
|
|
3159
3187
|
};
|
|
3160
3188
|
};
|
|
3161
3189
|
}, It = (r) => (e) => r.reduce(
|
|
3162
|
-
(t,
|
|
3190
|
+
(t, s) => s({
|
|
3163
3191
|
prevTransform: e.prevTransform,
|
|
3164
3192
|
nextTransform: t,
|
|
3165
3193
|
canvasWidth: e.canvasWidth,
|
|
@@ -3184,17 +3212,17 @@ const G = (r) => () => r, we = G(0), Nt = () => {
|
|
|
3184
3212
|
});
|
|
3185
3213
|
}
|
|
3186
3214
|
}, ye = (r) => {
|
|
3187
|
-
var
|
|
3188
|
-
const e = (
|
|
3189
|
-
let
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
(
|
|
3215
|
+
var f, E, S, b, C, P, R, V, ie, ne, ae, he;
|
|
3216
|
+
const e = (f = r == null ? void 0 : r.scale) == null ? void 0 : f.mouseWheelSensitivity, t = e !== void 0 ? e : 1.2, s = r == null ? void 0 : r.transformPreprocessor;
|
|
3217
|
+
let o;
|
|
3218
|
+
s !== void 0 ? Array.isArray(s) ? o = It(
|
|
3219
|
+
s.map(
|
|
3220
|
+
(N) => fe(N)
|
|
3193
3221
|
)
|
|
3194
|
-
) :
|
|
3195
|
-
const n = ((
|
|
3196
|
-
}), h = ((
|
|
3197
|
-
}), d = (
|
|
3222
|
+
) : o = fe(s) : o = (N) => N.nextTransform;
|
|
3223
|
+
const n = ((E = r == null ? void 0 : r.shift) == null ? void 0 : E.cursor) !== void 0 ? r.shift.cursor : "grab", a = ((S = r == null ? void 0 : r.events) == null ? void 0 : S.onBeforeTransformChange) ?? (() => {
|
|
3224
|
+
}), h = ((b = r == null ? void 0 : r.events) == null ? void 0 : b.onTransformChange) ?? (() => {
|
|
3225
|
+
}), d = (C = r == null ? void 0 : r.shift) == null ? void 0 : C.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
3226
|
return {
|
|
3199
3227
|
wheelSensitivity: t,
|
|
3200
3228
|
onTransformStarted: ((V = r == null ? void 0 : r.events) == null ? void 0 : V.onTransformStarted) ?? (() => {
|
|
@@ -3203,7 +3231,7 @@ const G = (r) => () => r, we = G(0), Nt = () => {
|
|
|
3203
3231
|
}),
|
|
3204
3232
|
onBeforeTransformChange: a,
|
|
3205
3233
|
onTransformChange: h,
|
|
3206
|
-
transformPreprocessor:
|
|
3234
|
+
transformPreprocessor: o,
|
|
3207
3235
|
shiftCursor: n,
|
|
3208
3236
|
mouseDownEventVerifier: c,
|
|
3209
3237
|
mouseUpEventVerifier: l,
|
|
@@ -3224,33 +3252,33 @@ const G = (r) => () => r, we = G(0), Nt = () => {
|
|
|
3224
3252
|
(r == null ? void 0 : r.radius) ?? 1.5,
|
|
3225
3253
|
(r == null ? void 0 : r.color) ?? "#d8d8d8"
|
|
3226
3254
|
), Bt = (r) => {
|
|
3227
|
-
const e = r.tileDimensions, t = (e == null ? void 0 : e.width) ?? 25,
|
|
3255
|
+
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
3256
|
return {
|
|
3229
3257
|
tileWidth: t,
|
|
3230
|
-
tileHeight:
|
|
3231
|
-
renderer:
|
|
3258
|
+
tileHeight: s,
|
|
3259
|
+
renderer: o,
|
|
3232
3260
|
maxViewportScale: r.maxViewportScale ?? 10
|
|
3233
3261
|
};
|
|
3234
3262
|
}, Ot = (r, e, t) => {
|
|
3235
3263
|
var c, g, l;
|
|
3236
|
-
const
|
|
3264
|
+
const s = () => "direct", o = (u) => u, n = (u) => u.button === 0, a = () => {
|
|
3237
3265
|
}, h = () => {
|
|
3238
3266
|
}, d = () => {
|
|
3239
3267
|
};
|
|
3240
3268
|
return {
|
|
3241
|
-
connectionTypeResolver: r.connectionTypeResolver ??
|
|
3242
|
-
connectionPreprocessor: r.connectionPreprocessor ??
|
|
3269
|
+
connectionTypeResolver: r.connectionTypeResolver ?? s,
|
|
3270
|
+
connectionPreprocessor: r.connectionPreprocessor ?? o,
|
|
3243
3271
|
mouseDownEventVerifier: r.mouseDownEventVerifier ?? n,
|
|
3244
3272
|
mouseUpEventVerifier: r.mouseUpEventVerifier ?? n,
|
|
3245
3273
|
onAfterEdgeCreated: ((c = r.events) == null ? void 0 : c.onAfterEdgeCreated) ?? a,
|
|
3246
3274
|
onEdgeCreationInterrupted: ((g = r.events) == null ? void 0 : g.onEdgeCreationInterrupted) ?? d,
|
|
3247
3275
|
onEdgeCreationPrevented: ((l = r.events) == null ? void 0 : l.onEdgeCreationPrevented) ?? h,
|
|
3248
3276
|
dragPortDirection: r.dragPortDirection ?? t,
|
|
3249
|
-
edgeShapeFactory: r.edgeShape !== void 0 ?
|
|
3277
|
+
edgeShapeFactory: r.edgeShape !== void 0 ? oe(r.edgeShape) : e
|
|
3250
3278
|
};
|
|
3251
3279
|
}, Wt = (r, e) => {
|
|
3252
3280
|
var c, g, l;
|
|
3253
|
-
const t = (u) => u,
|
|
3281
|
+
const t = (u) => u, s = (u) => u.button === 0 && u.ctrlKey, o = (u) => u.button === 0, n = (u) => {
|
|
3254
3282
|
const w = e.getPortAdjacentEdgeIds(u);
|
|
3255
3283
|
return w.length > 0 ? w[w.length - 1] : null;
|
|
3256
3284
|
}, a = () => {
|
|
@@ -3259,10 +3287,10 @@ const G = (r) => () => r, we = G(0), Nt = () => {
|
|
|
3259
3287
|
};
|
|
3260
3288
|
return {
|
|
3261
3289
|
connectionPreprocessor: r.connectionPreprocessor ?? t,
|
|
3262
|
-
mouseDownEventVerifier: r.mouseDownEventVerifier ??
|
|
3263
|
-
mouseUpEventVerifier: r.mouseUpEventVerifier ??
|
|
3290
|
+
mouseDownEventVerifier: r.mouseDownEventVerifier ?? s,
|
|
3291
|
+
mouseUpEventVerifier: r.mouseUpEventVerifier ?? o,
|
|
3264
3292
|
draggingEdgeResolver: r.draggingEdgeResolver ?? n,
|
|
3265
|
-
draggingEdgeShapeFactory: r.draggingEdgeShape !== void 0 ?
|
|
3293
|
+
draggingEdgeShapeFactory: r.draggingEdgeShape !== void 0 ? oe(r.draggingEdgeShape) : null,
|
|
3266
3294
|
onAfterEdgeReattached: ((c = r.events) == null ? void 0 : c.onAfterEdgeReattached) ?? a,
|
|
3267
3295
|
onEdgeReattachInterrupted: ((g = r.events) == null ? void 0 : g.onEdgeReattachInterrupted) ?? d,
|
|
3268
3296
|
onEdgeReattachPrevented: ((l = r.events) == null ? void 0 : l.onEdgeReattachPrevented) ?? h
|
|
@@ -3286,40 +3314,40 @@ class Ht extends Error {
|
|
|
3286
3314
|
}
|
|
3287
3315
|
}
|
|
3288
3316
|
class Fe {
|
|
3289
|
-
constructor(e, t,
|
|
3317
|
+
constructor(e, t, s) {
|
|
3290
3318
|
i(this, "dt");
|
|
3291
3319
|
i(this, "nodeMass");
|
|
3292
3320
|
i(this, "edgeEquilibriumLength");
|
|
3293
3321
|
i(this, "edgeStiffness");
|
|
3294
3322
|
i(this, "nodeForcesApplicationStrategy");
|
|
3295
3323
|
i(this, "distanceVectorGenerator");
|
|
3296
|
-
this.graph = e, this.currentCoords = t, this.dt =
|
|
3324
|
+
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
3325
|
}
|
|
3298
3326
|
apply() {
|
|
3299
|
-
let e = 0
|
|
3300
|
-
const
|
|
3301
|
-
return this.graph.getAllNodeIds().forEach((
|
|
3302
|
-
|
|
3303
|
-
}), this.nodeForcesApplicationStrategy.apply(this.currentCoords,
|
|
3304
|
-
const
|
|
3305
|
-
x:
|
|
3306
|
-
y:
|
|
3327
|
+
let e = 0;
|
|
3328
|
+
const t = /* @__PURE__ */ new Map();
|
|
3329
|
+
return this.graph.getAllNodeIds().forEach((o) => {
|
|
3330
|
+
t.set(o, { x: 0, y: 0 });
|
|
3331
|
+
}), this.nodeForcesApplicationStrategy.apply(this.currentCoords, t), this.applyEdgeForces(t), this.currentCoords.forEach((o, n) => {
|
|
3332
|
+
const a = t.get(n), h = {
|
|
3333
|
+
x: a.x / this.nodeMass * this.dt,
|
|
3334
|
+
y: a.y / this.nodeMass * this.dt
|
|
3307
3335
|
};
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
Math.sqrt(
|
|
3336
|
+
e = Math.max(
|
|
3337
|
+
e,
|
|
3338
|
+
Math.sqrt(h.x * h.x + h.y * h.y)
|
|
3311
3339
|
);
|
|
3312
|
-
const
|
|
3313
|
-
|
|
3314
|
-
}),
|
|
3340
|
+
const d = h.x * this.dt, c = h.y * this.dt;
|
|
3341
|
+
o.x += d, o.y += c;
|
|
3342
|
+
}), e;
|
|
3315
3343
|
}
|
|
3316
3344
|
applyEdgeForces(e) {
|
|
3317
3345
|
this.graph.getAllEdgeIds().forEach((t) => {
|
|
3318
|
-
const
|
|
3346
|
+
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
3347
|
a,
|
|
3320
3348
|
h
|
|
3321
|
-
), g = (d.d - this.edgeEquilibriumLength) * this.edgeStiffness, l = d.ex * g, u = d.ey * g, w = e.get(
|
|
3322
|
-
w.x += l, w.y += u,
|
|
3349
|
+
), g = (d.d - this.edgeEquilibriumLength) * this.edgeStiffness, l = d.ex * g, u = d.ey * g, w = e.get(o.nodeId), f = e.get(n.nodeId);
|
|
3350
|
+
w.x += l, w.y += u, f.x -= l, f.y -= u;
|
|
3323
3351
|
});
|
|
3324
3352
|
}
|
|
3325
3353
|
}
|
|
@@ -3329,7 +3357,7 @@ class Ie {
|
|
|
3329
3357
|
this.rand = e;
|
|
3330
3358
|
}
|
|
3331
3359
|
create(e, t) {
|
|
3332
|
-
const
|
|
3360
|
+
const s = t.x - e.x, o = t.y - e.y, n = s * s + o * o;
|
|
3333
3361
|
if (n === 0) {
|
|
3334
3362
|
const c = this.PI2 * this.rand();
|
|
3335
3363
|
return {
|
|
@@ -3338,7 +3366,7 @@ class Ie {
|
|
|
3338
3366
|
d: 0
|
|
3339
3367
|
};
|
|
3340
3368
|
}
|
|
3341
|
-
const a = Math.sqrt(n), h =
|
|
3369
|
+
const a = Math.sqrt(n), h = s / a, d = o / a;
|
|
3342
3370
|
return { ex: h, ey: d, d: a };
|
|
3343
3371
|
}
|
|
3344
3372
|
}
|
|
@@ -3350,31 +3378,27 @@ const $e = (r) => {
|
|
|
3350
3378
|
};
|
|
3351
3379
|
class Xt {
|
|
3352
3380
|
constructor(e) {
|
|
3353
|
-
i(this, "effectiveDistance");
|
|
3354
3381
|
i(this, "nodeCharge");
|
|
3355
3382
|
i(this, "distanceVectorGenerator");
|
|
3356
3383
|
i(this, "maxForce");
|
|
3357
|
-
this.
|
|
3384
|
+
this.nodeCharge = e.nodeCharge, this.distanceVectorGenerator = e.distanceVectorGenerator, this.maxForce = e.maxForce;
|
|
3358
3385
|
}
|
|
3359
3386
|
apply(e, t) {
|
|
3360
|
-
const
|
|
3361
|
-
for (let n = 0; n <
|
|
3362
|
-
const a =
|
|
3363
|
-
for (let h = n + 1; h <
|
|
3364
|
-
const d =
|
|
3387
|
+
const s = Array.from(t.keys()), o = s.length;
|
|
3388
|
+
for (let n = 0; n < o; n++) {
|
|
3389
|
+
const a = s[n];
|
|
3390
|
+
for (let h = n + 1; h < o; h++) {
|
|
3391
|
+
const d = s[h], c = e.get(a), g = e.get(d), l = this.distanceVectorGenerator.create(
|
|
3365
3392
|
c,
|
|
3366
3393
|
g
|
|
3367
|
-
)
|
|
3368
|
-
if (l.d > this.effectiveDistance)
|
|
3369
|
-
continue;
|
|
3370
|
-
const u = $e({
|
|
3394
|
+
), u = $e({
|
|
3371
3395
|
coefficient: 1,
|
|
3372
3396
|
sourceCharge: this.nodeCharge,
|
|
3373
3397
|
targetCharge: this.nodeCharge,
|
|
3374
3398
|
distance: l.d,
|
|
3375
3399
|
maxForce: this.maxForce
|
|
3376
|
-
}), w = u * l.ex,
|
|
3377
|
-
|
|
3400
|
+
}), w = u * l.ex, f = u * l.ey, E = t.get(a), S = t.get(d);
|
|
3401
|
+
E.x -= w, E.y -= f, S.x += w, S.y += f;
|
|
3378
3402
|
}
|
|
3379
3403
|
}
|
|
3380
3404
|
}
|
|
@@ -3386,14 +3410,14 @@ const Yt = (r) => {
|
|
|
3386
3410
|
centerY: 0,
|
|
3387
3411
|
radius: 0
|
|
3388
3412
|
};
|
|
3389
|
-
let e = 1 / 0, t = -1 / 0,
|
|
3413
|
+
let e = 1 / 0, t = -1 / 0, s = 1 / 0, o = -1 / 0;
|
|
3390
3414
|
r.forEach((d) => {
|
|
3391
|
-
e = Math.min(e, d.x), t = Math.max(t, d.x),
|
|
3415
|
+
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
3416
|
});
|
|
3393
|
-
const n = t - e, a =
|
|
3417
|
+
const n = t - e, a = o - s, h = Math.max(n, a);
|
|
3394
3418
|
return {
|
|
3395
3419
|
centerX: (e + t) / 2,
|
|
3396
|
-
centerY: (
|
|
3420
|
+
centerY: (s + o) / 2,
|
|
3397
3421
|
radius: h / 2
|
|
3398
3422
|
};
|
|
3399
3423
|
};
|
|
@@ -3423,18 +3447,18 @@ class Gt {
|
|
|
3423
3447
|
};
|
|
3424
3448
|
let t = [this.root];
|
|
3425
3449
|
for (; t.length > 0; ) {
|
|
3426
|
-
const
|
|
3450
|
+
const s = [];
|
|
3427
3451
|
for (; t.length > 0; ) {
|
|
3428
|
-
const
|
|
3429
|
-
this.processNode(
|
|
3430
|
-
|
|
3452
|
+
const o = t.pop();
|
|
3453
|
+
this.processNode(o).forEach((a) => {
|
|
3454
|
+
s.push(a);
|
|
3431
3455
|
});
|
|
3432
3456
|
}
|
|
3433
|
-
t =
|
|
3457
|
+
t = s;
|
|
3434
3458
|
}
|
|
3435
|
-
this.sortedParentNodes.reverse().forEach((
|
|
3436
|
-
let
|
|
3437
|
-
|
|
3459
|
+
this.sortedParentNodes.reverse().forEach((s) => {
|
|
3460
|
+
let o = 0, n = 0, a = 0, h = 0;
|
|
3461
|
+
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
3462
|
});
|
|
3439
3463
|
}
|
|
3440
3464
|
getRoot() {
|
|
@@ -3446,14 +3470,14 @@ class Gt {
|
|
|
3446
3470
|
processNode(e) {
|
|
3447
3471
|
if (e.nodeIds.size < 2)
|
|
3448
3472
|
return this.setLeaf(e), [];
|
|
3449
|
-
const { centerX: t, centerY:
|
|
3450
|
-
if (
|
|
3473
|
+
const { centerX: t, centerY: s, radius: o } = e.box;
|
|
3474
|
+
if (o < this.areaRadiusThreshold)
|
|
3451
3475
|
return this.setLeaf(e), [];
|
|
3452
3476
|
this.sortedParentNodes.push(e);
|
|
3453
|
-
const n = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set(), c =
|
|
3477
|
+
const n = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set(), c = o / 2;
|
|
3454
3478
|
e.nodeIds.forEach((u) => {
|
|
3455
|
-
const { x: w, y } = this.coords.get(u);
|
|
3456
|
-
w < t ?
|
|
3479
|
+
const { x: w, y: f } = this.coords.get(u);
|
|
3480
|
+
w < t ? f < s ? d.add(u) : h.add(u) : f < s ? a.add(u) : n.add(u), e.nodeIds.delete(u);
|
|
3457
3481
|
});
|
|
3458
3482
|
const g = {
|
|
3459
3483
|
parent: e,
|
|
@@ -3473,7 +3497,7 @@ class Gt {
|
|
|
3473
3497
|
},
|
|
3474
3498
|
box: {
|
|
3475
3499
|
centerX: t + c,
|
|
3476
|
-
centerY:
|
|
3500
|
+
centerY: s + c,
|
|
3477
3501
|
radius: c
|
|
3478
3502
|
},
|
|
3479
3503
|
...g
|
|
@@ -3491,7 +3515,7 @@ class Gt {
|
|
|
3491
3515
|
},
|
|
3492
3516
|
box: {
|
|
3493
3517
|
centerX: t + c,
|
|
3494
|
-
centerY:
|
|
3518
|
+
centerY: s - c,
|
|
3495
3519
|
radius: c
|
|
3496
3520
|
},
|
|
3497
3521
|
...g
|
|
@@ -3509,7 +3533,7 @@ class Gt {
|
|
|
3509
3533
|
},
|
|
3510
3534
|
box: {
|
|
3511
3535
|
centerX: t - c,
|
|
3512
|
-
centerY:
|
|
3536
|
+
centerY: s + c,
|
|
3513
3537
|
radius: c
|
|
3514
3538
|
},
|
|
3515
3539
|
...g
|
|
@@ -3527,7 +3551,7 @@ class Gt {
|
|
|
3527
3551
|
},
|
|
3528
3552
|
box: {
|
|
3529
3553
|
centerX: t - c,
|
|
3530
|
-
centerY:
|
|
3554
|
+
centerY: s - c,
|
|
3531
3555
|
radius: c
|
|
3532
3556
|
},
|
|
3533
3557
|
...g
|
|
@@ -3547,11 +3571,11 @@ class Gt {
|
|
|
3547
3571
|
x: 0,
|
|
3548
3572
|
y: 0
|
|
3549
3573
|
};
|
|
3550
|
-
let t = 0,
|
|
3551
|
-
return e.forEach((
|
|
3552
|
-
const n = this.coords.get(
|
|
3553
|
-
t += n.x,
|
|
3554
|
-
}), { x: t / e.size, y:
|
|
3574
|
+
let t = 0, s = 0;
|
|
3575
|
+
return e.forEach((o) => {
|
|
3576
|
+
const n = this.coords.get(o);
|
|
3577
|
+
t += n.x, s += n.y;
|
|
3578
|
+
}), { x: t / e.size, y: s / e.size };
|
|
3555
3579
|
}
|
|
3556
3580
|
}
|
|
3557
3581
|
class jt {
|
|
@@ -3566,8 +3590,8 @@ class jt {
|
|
|
3566
3590
|
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
3591
|
}
|
|
3568
3592
|
apply(e, t) {
|
|
3569
|
-
const
|
|
3570
|
-
box:
|
|
3593
|
+
const s = Yt(e), o = new Gt({
|
|
3594
|
+
box: s,
|
|
3571
3595
|
coords: e,
|
|
3572
3596
|
areaRadiusThreshold: this.areaRadiusThreshold,
|
|
3573
3597
|
nodeMass: this.nodeMass,
|
|
@@ -3575,22 +3599,22 @@ class jt {
|
|
|
3575
3599
|
});
|
|
3576
3600
|
e.forEach((n, a) => {
|
|
3577
3601
|
const h = this.calculateForceForNode(
|
|
3578
|
-
|
|
3602
|
+
o.getLeaf(a),
|
|
3579
3603
|
a,
|
|
3580
3604
|
e
|
|
3581
3605
|
), d = t.get(a);
|
|
3582
3606
|
this.applyForce(d, h);
|
|
3583
3607
|
});
|
|
3584
3608
|
}
|
|
3585
|
-
calculateForceForNode(e, t,
|
|
3586
|
-
const
|
|
3609
|
+
calculateForceForNode(e, t, s) {
|
|
3610
|
+
const o = s.get(t), n = { x: 0, y: 0 };
|
|
3587
3611
|
e.nodeIds.forEach((h) => {
|
|
3588
3612
|
if (h !== t) {
|
|
3589
|
-
const d =
|
|
3613
|
+
const d = s.get(h), c = this.calculateNodeRepulsiveForce({
|
|
3590
3614
|
sourceCharge: this.nodeCharge,
|
|
3591
3615
|
targetCharge: this.nodeCharge,
|
|
3592
3616
|
sourceCoords: d,
|
|
3593
|
-
targetCoords:
|
|
3617
|
+
targetCoords: o
|
|
3594
3618
|
});
|
|
3595
3619
|
this.applyForce(n, c);
|
|
3596
3620
|
}
|
|
@@ -3601,73 +3625,73 @@ class jt {
|
|
|
3601
3625
|
if (h !== null) {
|
|
3602
3626
|
const d = this.distanceVectorGenerator.create(
|
|
3603
3627
|
h.chargeCenter,
|
|
3604
|
-
|
|
3628
|
+
o
|
|
3605
3629
|
);
|
|
3606
3630
|
h.box.radius * 2 < d.d * this.theta ? (this.tryApplyFarForce({
|
|
3607
3631
|
totalForce: n,
|
|
3608
|
-
targetCoords:
|
|
3632
|
+
targetCoords: o,
|
|
3609
3633
|
target: h.lb,
|
|
3610
3634
|
current: a
|
|
3611
3635
|
}), this.tryApplyFarForce({
|
|
3612
3636
|
totalForce: n,
|
|
3613
|
-
targetCoords:
|
|
3637
|
+
targetCoords: o,
|
|
3614
3638
|
target: h.rb,
|
|
3615
3639
|
current: a
|
|
3616
3640
|
}), this.tryApplyFarForce({
|
|
3617
3641
|
totalForce: n,
|
|
3618
|
-
targetCoords:
|
|
3642
|
+
targetCoords: o,
|
|
3619
3643
|
target: h.rt,
|
|
3620
3644
|
current: a
|
|
3621
3645
|
}), this.tryApplyFarForce({
|
|
3622
3646
|
totalForce: n,
|
|
3623
|
-
targetCoords:
|
|
3647
|
+
targetCoords: o,
|
|
3624
3648
|
target: h.lt,
|
|
3625
3649
|
current: a
|
|
3626
3650
|
})) : (this.tryApplyNearForce({
|
|
3627
3651
|
totalForce: n,
|
|
3628
|
-
targetCoords:
|
|
3652
|
+
targetCoords: o,
|
|
3629
3653
|
target: h.lb,
|
|
3630
3654
|
current: a,
|
|
3631
|
-
nodesCoords:
|
|
3655
|
+
nodesCoords: s
|
|
3632
3656
|
}), this.tryApplyNearForce({
|
|
3633
3657
|
totalForce: n,
|
|
3634
|
-
targetCoords:
|
|
3658
|
+
targetCoords: o,
|
|
3635
3659
|
target: h.rb,
|
|
3636
3660
|
current: a,
|
|
3637
|
-
nodesCoords:
|
|
3661
|
+
nodesCoords: s
|
|
3638
3662
|
}), this.tryApplyNearForce({
|
|
3639
3663
|
totalForce: n,
|
|
3640
|
-
targetCoords:
|
|
3664
|
+
targetCoords: o,
|
|
3641
3665
|
target: h.rt,
|
|
3642
3666
|
current: a,
|
|
3643
|
-
nodesCoords:
|
|
3667
|
+
nodesCoords: s
|
|
3644
3668
|
}), this.tryApplyNearForce({
|
|
3645
3669
|
totalForce: n,
|
|
3646
|
-
targetCoords:
|
|
3670
|
+
targetCoords: o,
|
|
3647
3671
|
target: h.lt,
|
|
3648
3672
|
current: a,
|
|
3649
|
-
nodesCoords:
|
|
3673
|
+
nodesCoords: s
|
|
3650
3674
|
}));
|
|
3651
3675
|
}
|
|
3652
3676
|
a = a.parent;
|
|
3653
3677
|
}
|
|
3654
3678
|
return n;
|
|
3655
3679
|
}
|
|
3656
|
-
calculateExactForce(e, t,
|
|
3657
|
-
const
|
|
3680
|
+
calculateExactForce(e, t, s) {
|
|
3681
|
+
const o = { x: 0, y: 0 }, n = [e];
|
|
3658
3682
|
for (; n.length > 0; ) {
|
|
3659
3683
|
const a = n.pop();
|
|
3660
3684
|
a.nodeIds.forEach((h) => {
|
|
3661
|
-
const d =
|
|
3685
|
+
const d = s.get(h), c = this.calculateNodeRepulsiveForce({
|
|
3662
3686
|
sourceCharge: this.nodeCharge,
|
|
3663
3687
|
targetCharge: this.nodeCharge,
|
|
3664
3688
|
sourceCoords: d,
|
|
3665
3689
|
targetCoords: t
|
|
3666
3690
|
});
|
|
3667
|
-
this.applyForce(
|
|
3691
|
+
this.applyForce(o, c);
|
|
3668
3692
|
}), 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
3693
|
}
|
|
3670
|
-
return
|
|
3694
|
+
return o;
|
|
3671
3695
|
}
|
|
3672
3696
|
calculateApproximateForce(e, t) {
|
|
3673
3697
|
return this.calculateNodeRepulsiveForce({
|
|
@@ -3681,7 +3705,7 @@ class jt {
|
|
|
3681
3705
|
const t = this.distanceVectorGenerator.create(
|
|
3682
3706
|
e.sourceCoords,
|
|
3683
3707
|
e.targetCoords
|
|
3684
|
-
),
|
|
3708
|
+
), s = $e({
|
|
3685
3709
|
coefficient: this.nodeForceCoefficient,
|
|
3686
3710
|
sourceCharge: e.sourceCharge,
|
|
3687
3711
|
targetCharge: e.targetCharge,
|
|
@@ -3689,8 +3713,8 @@ class jt {
|
|
|
3689
3713
|
maxForce: this.maxForce
|
|
3690
3714
|
});
|
|
3691
3715
|
return {
|
|
3692
|
-
x:
|
|
3693
|
-
y:
|
|
3716
|
+
x: s * t.ex,
|
|
3717
|
+
y: s * t.ey
|
|
3694
3718
|
};
|
|
3695
3719
|
}
|
|
3696
3720
|
applyForce(e, t) {
|
|
@@ -3728,7 +3752,6 @@ const Ue = (r) => r.theta !== 0 ? new jt({
|
|
|
3728
3752
|
nodeCharge: r.nodeCharge,
|
|
3729
3753
|
nodeForceCoefficient: r.nodeForceCoefficient,
|
|
3730
3754
|
distanceVectorGenerator: r.distanceVectorGenerator,
|
|
3731
|
-
effectiveDistance: r.effectiveDistance,
|
|
3732
3755
|
maxForce: r.maxForce
|
|
3733
3756
|
});
|
|
3734
3757
|
class Be {
|
|
@@ -3737,16 +3760,16 @@ class Be {
|
|
|
3737
3760
|
i(this, "sparsity");
|
|
3738
3761
|
this.rand = e.rand, this.sparsity = e.sparsity;
|
|
3739
3762
|
}
|
|
3740
|
-
calculateCoordinates(e
|
|
3741
|
-
const o = /* @__PURE__ */ new Map(),
|
|
3742
|
-
x:
|
|
3743
|
-
y:
|
|
3763
|
+
calculateCoordinates(e) {
|
|
3764
|
+
const { graph: t, viewport: s } = e, o = /* @__PURE__ */ new Map(), n = t.getAllNodeIds(), a = Math.sqrt(n.length) * this.sparsity, { width: h, height: d } = s.getDimensions(), c = { x: h / 2, y: d / 2 }, g = s.createContentCoords(c), l = a / 2, u = {
|
|
3765
|
+
x: g.x - l,
|
|
3766
|
+
y: g.y - l
|
|
3744
3767
|
};
|
|
3745
|
-
return
|
|
3746
|
-
const
|
|
3747
|
-
o.set(
|
|
3748
|
-
x:
|
|
3749
|
-
y:
|
|
3768
|
+
return n.forEach((w) => {
|
|
3769
|
+
const f = t.getNode(w);
|
|
3770
|
+
o.set(w, {
|
|
3771
|
+
x: f.x ?? u.x + a * this.rand(),
|
|
3772
|
+
y: f.y ?? u.y + a * this.rand()
|
|
3750
3773
|
});
|
|
3751
3774
|
}), o;
|
|
3752
3775
|
}
|
|
@@ -3761,12 +3784,10 @@ class qt {
|
|
|
3761
3784
|
i(this, "nodeMass");
|
|
3762
3785
|
i(this, "edgeEquilibriumLength");
|
|
3763
3786
|
i(this, "edgeStiffness");
|
|
3764
|
-
i(this, "convergenceDelta");
|
|
3765
3787
|
i(this, "convergenceVelocity");
|
|
3766
|
-
this.maxIterations = e.maxIterations, this.dtSec = e.dtSec, this.nodeMass = e.nodeMass, this.edgeEquilibriumLength = e.edgeEquilibriumLength, this.edgeStiffness = e.edgeStiffness, this.
|
|
3788
|
+
this.maxIterations = e.maxIterations, this.dtSec = e.dtSec, this.nodeMass = e.nodeMass, this.edgeEquilibriumLength = e.edgeEquilibriumLength, this.edgeStiffness = e.edgeStiffness, this.convergenceVelocity = e.convergenceVelocity, this.distanceVectorGenerator = new Ie(e.rand), this.nodeForcesApplicationStrategy = Ue({
|
|
3767
3789
|
distanceVectorGenerator: this.distanceVectorGenerator,
|
|
3768
3790
|
nodeCharge: e.nodeCharge,
|
|
3769
|
-
effectiveDistance: e.effectiveDistance,
|
|
3770
3791
|
maxForce: e.maxForce,
|
|
3771
3792
|
nodeForceCoefficient: e.nodeForceCoefficient,
|
|
3772
3793
|
theta: e.barnesHutTheta,
|
|
@@ -3777,27 +3798,24 @@ class qt {
|
|
|
3777
3798
|
sparsity: e.edgeEquilibriumLength
|
|
3778
3799
|
});
|
|
3779
3800
|
}
|
|
3780
|
-
calculateCoordinates(e
|
|
3781
|
-
const o = this.fillerLayoutAlgorithm.calculateCoordinates(
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
);
|
|
3785
|
-
for (let
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
if (a < this.convergenceDelta || h < this.convergenceVelocity)
|
|
3799
|
-
break;
|
|
3800
|
-
}
|
|
3801
|
+
calculateCoordinates(e) {
|
|
3802
|
+
const { graph: t, viewport: s } = e, o = this.fillerLayoutAlgorithm.calculateCoordinates({
|
|
3803
|
+
graph: t,
|
|
3804
|
+
viewport: s
|
|
3805
|
+
});
|
|
3806
|
+
for (let n = 0; n < this.maxIterations && !(new Fe(
|
|
3807
|
+
t,
|
|
3808
|
+
o,
|
|
3809
|
+
{
|
|
3810
|
+
distanceVectorGenerator: this.distanceVectorGenerator,
|
|
3811
|
+
nodeForcesApplicationStrategy: this.nodeForcesApplicationStrategy,
|
|
3812
|
+
dtSec: this.dtSec,
|
|
3813
|
+
nodeMass: this.nodeMass,
|
|
3814
|
+
edgeEquilibriumLength: this.edgeEquilibriumLength,
|
|
3815
|
+
edgeStiffness: this.edgeStiffness
|
|
3816
|
+
}
|
|
3817
|
+
).apply() < this.convergenceVelocity); n++)
|
|
3818
|
+
;
|
|
3801
3819
|
return o;
|
|
3802
3820
|
}
|
|
3803
3821
|
}
|
|
@@ -3805,17 +3823,15 @@ class Kt {
|
|
|
3805
3823
|
constructor(e) {
|
|
3806
3824
|
i(this, "distanceVectorGenerator");
|
|
3807
3825
|
i(this, "nodeForcesApplicationStrategy");
|
|
3808
|
-
i(this, "convergenceDelta");
|
|
3809
3826
|
i(this, "convergenceVelocity");
|
|
3810
3827
|
i(this, "maxTimeDeltaSec");
|
|
3811
3828
|
i(this, "nodeMass");
|
|
3812
3829
|
i(this, "edgeEquilibriumLength");
|
|
3813
3830
|
i(this, "edgeStiffness");
|
|
3814
3831
|
i(this, "fillerLayoutAlgorithm");
|
|
3815
|
-
this.
|
|
3832
|
+
this.convergenceVelocity = e.convergenceVelocity, this.maxTimeDeltaSec = e.maxTimeDeltaSec, this.nodeMass = e.nodeMass, this.edgeEquilibriumLength = e.edgeEquilibriumLength, this.edgeStiffness = e.edgeStiffness, this.distanceVectorGenerator = new Ie(e.rand), this.nodeForcesApplicationStrategy = Ue({
|
|
3816
3833
|
distanceVectorGenerator: this.distanceVectorGenerator,
|
|
3817
3834
|
nodeCharge: e.nodeCharge,
|
|
3818
|
-
effectiveDistance: e.effectiveDistance,
|
|
3819
3835
|
maxForce: e.maxForce,
|
|
3820
3836
|
nodeForceCoefficient: e.nodeForceCoefficient,
|
|
3821
3837
|
theta: e.barnesHutTheta,
|
|
@@ -3826,37 +3842,37 @@ class Kt {
|
|
|
3826
3842
|
sparsity: e.edgeEquilibriumLength
|
|
3827
3843
|
});
|
|
3828
3844
|
}
|
|
3829
|
-
calculateNextCoordinates(e
|
|
3830
|
-
const s = this.fillerLayoutAlgorithm.calculateCoordinates(
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
)
|
|
3834
|
-
|
|
3835
|
-
|
|
3845
|
+
calculateNextCoordinates(e) {
|
|
3846
|
+
const { graph: t, viewport: s, dt: o } = e, n = this.fillerLayoutAlgorithm.calculateCoordinates({
|
|
3847
|
+
graph: t,
|
|
3848
|
+
viewport: s
|
|
3849
|
+
});
|
|
3850
|
+
return new Fe(
|
|
3851
|
+
t,
|
|
3852
|
+
n,
|
|
3836
3853
|
{
|
|
3837
3854
|
distanceVectorGenerator: this.distanceVectorGenerator,
|
|
3838
3855
|
nodeForcesApplicationStrategy: this.nodeForcesApplicationStrategy,
|
|
3839
|
-
dtSec: Math.min(
|
|
3856
|
+
dtSec: Math.min(o, this.maxTimeDeltaSec),
|
|
3840
3857
|
nodeMass: this.nodeMass,
|
|
3841
3858
|
edgeEquilibriumLength: this.edgeEquilibriumLength,
|
|
3842
3859
|
edgeStiffness: this.edgeStiffness
|
|
3843
3860
|
}
|
|
3844
|
-
)
|
|
3845
|
-
|
|
3846
|
-
const g = e.getNode(c);
|
|
3861
|
+
).apply() < this.convergenceVelocity && !t.getAllNodeIds().some((c) => {
|
|
3862
|
+
const g = t.getNode(c);
|
|
3847
3863
|
return g.x === null || g.y === null;
|
|
3848
|
-
}) ? /* @__PURE__ */ new Map() :
|
|
3864
|
+
}) ? /* @__PURE__ */ new Map() : n;
|
|
3849
3865
|
}
|
|
3850
3866
|
}
|
|
3851
3867
|
const Oe = (r) => {
|
|
3852
|
-
let e = 1779033703, t = 3144134277,
|
|
3868
|
+
let e = 1779033703, t = 3144134277, s = 1013904242, o = 2773480762;
|
|
3853
3869
|
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
|
|
3870
|
+
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);
|
|
3871
|
+
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];
|
|
3872
|
+
}, We = (r, e, t, s) => function() {
|
|
3873
|
+
r |= 0, e |= 0, t |= 0, s |= 0;
|
|
3874
|
+
const o = (r + e | 0) + s | 0;
|
|
3875
|
+
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
3876
|
}, v = Object.freeze({
|
|
3861
3877
|
seed: "HTMLGraph is awesome",
|
|
3862
3878
|
maxTimeDeltaSec: 0.01,
|
|
@@ -3864,36 +3880,32 @@ const Oe = (r) => {
|
|
|
3864
3880
|
nodeMass: 1,
|
|
3865
3881
|
edgeEquilibriumLength: 300,
|
|
3866
3882
|
edgeStiffness: 1e3,
|
|
3867
|
-
effectiveDistance: 1e3,
|
|
3868
3883
|
dtSec: 0.01,
|
|
3869
3884
|
maxIterations: 1e3,
|
|
3870
|
-
convergenceDelta: 0,
|
|
3871
3885
|
convergenceVelocity: 10,
|
|
3872
3886
|
maxForce: 1e7,
|
|
3873
3887
|
nodeForceCoefficient: 1,
|
|
3874
3888
|
barnesHutAreaRadiusThreshold: 0.01,
|
|
3875
3889
|
barnesHutTheta: 1
|
|
3876
3890
|
}), Qt = (r) => {
|
|
3877
|
-
var e, t,
|
|
3891
|
+
var e, t, s;
|
|
3878
3892
|
switch ((e = r == null ? void 0 : r.algorithm) == null ? void 0 : e.type) {
|
|
3879
3893
|
case "custom":
|
|
3880
3894
|
return r.algorithm.instance;
|
|
3881
3895
|
default: {
|
|
3882
|
-
const
|
|
3896
|
+
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
3897
|
return new Kt({
|
|
3884
3898
|
rand: a,
|
|
3885
|
-
maxTimeDeltaSec: (
|
|
3886
|
-
nodeCharge: (
|
|
3887
|
-
nodeMass: (
|
|
3888
|
-
edgeEquilibriumLength: (
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
barnesHutTheta: ((t = s == null ? void 0 : s.barnesHut) == null ? void 0 : t.theta) ?? v.barnesHutTheta,
|
|
3896
|
-
barnesHutAreaRadiusThreshold: ((o = s == null ? void 0 : s.barnesHut) == null ? void 0 : o.areaRadiusThreshold) ?? v.barnesHutAreaRadiusThreshold
|
|
3899
|
+
maxTimeDeltaSec: (o == null ? void 0 : o.maxTimeDeltaSec) ?? v.maxTimeDeltaSec,
|
|
3900
|
+
nodeCharge: (o == null ? void 0 : o.nodeCharge) ?? v.nodeCharge,
|
|
3901
|
+
nodeMass: (o == null ? void 0 : o.nodeMass) ?? v.nodeMass,
|
|
3902
|
+
edgeEquilibriumLength: (o == null ? void 0 : o.edgeEquilibriumLength) ?? v.edgeEquilibriumLength,
|
|
3903
|
+
edgeStiffness: (o == null ? void 0 : o.edgeStiffness) ?? v.edgeStiffness,
|
|
3904
|
+
convergenceVelocity: (o == null ? void 0 : o.convergenceVelocity) ?? v.convergenceVelocity,
|
|
3905
|
+
maxForce: (o == null ? void 0 : o.maxForce) ?? v.maxForce,
|
|
3906
|
+
nodeForceCoefficient: (o == null ? void 0 : o.nodeForceCoefficient) ?? v.nodeForceCoefficient,
|
|
3907
|
+
barnesHutTheta: ((t = o == null ? void 0 : o.barnesHut) == null ? void 0 : t.theta) ?? v.barnesHutTheta,
|
|
3908
|
+
barnesHutAreaRadiusThreshold: ((s = o == null ? void 0 : o.barnesHut) == null ? void 0 : s.areaRadiusThreshold) ?? v.barnesHutAreaRadiusThreshold
|
|
3897
3909
|
});
|
|
3898
3910
|
}
|
|
3899
3911
|
}
|
|
@@ -3902,8 +3914,6 @@ const Oe = (r) => {
|
|
|
3902
3914
|
trigger: r
|
|
3903
3915
|
} : (r == null ? void 0 : r.type) === "topologyChangeMacrotask" ? {
|
|
3904
3916
|
type: "topologyChangeMacrotask"
|
|
3905
|
-
} : (r == null ? void 0 : r.type) === "topologyChangeTimeout" ? {
|
|
3906
|
-
type: "topologyChangeMacrotask"
|
|
3907
3917
|
} : {
|
|
3908
3918
|
type: "topologyChangeMicrotask"
|
|
3909
3919
|
}, Jt = (r) => {
|
|
@@ -3912,17 +3922,15 @@ const Oe = (r) => {
|
|
|
3912
3922
|
case "custom":
|
|
3913
3923
|
return r.instance;
|
|
3914
3924
|
default: {
|
|
3915
|
-
const
|
|
3925
|
+
const s = Oe((r == null ? void 0 : r.seed) ?? v.seed), o = We(s[0], s[1], s[2], s[3]);
|
|
3916
3926
|
return new qt({
|
|
3917
3927
|
dtSec: (r == null ? void 0 : r.dtSec) ?? v.dtSec,
|
|
3918
3928
|
maxIterations: (r == null ? void 0 : r.maxIterations) ?? v.maxIterations,
|
|
3919
|
-
rand:
|
|
3929
|
+
rand: o,
|
|
3920
3930
|
nodeCharge: (r == null ? void 0 : r.nodeCharge) ?? v.nodeCharge,
|
|
3921
3931
|
nodeMass: (r == null ? void 0 : r.nodeMass) ?? v.nodeMass,
|
|
3922
3932
|
edgeEquilibriumLength: (r == null ? void 0 : r.edgeEquilibriumLength) ?? v.edgeEquilibriumLength,
|
|
3923
3933
|
edgeStiffness: (r == null ? void 0 : r.edgeStiffness) ?? v.edgeStiffness,
|
|
3924
|
-
effectiveDistance: (r == null ? void 0 : r.effectiveDistance) ?? v.effectiveDistance,
|
|
3925
|
-
convergenceDelta: (r == null ? void 0 : r.convergenceDelta) ?? v.convergenceDelta,
|
|
3926
3934
|
convergenceVelocity: (r == null ? void 0 : r.convergenceVelocity) ?? v.convergenceVelocity,
|
|
3927
3935
|
maxForce: (r == null ? void 0 : r.maxForce) ?? v.maxForce,
|
|
3928
3936
|
nodeForceCoefficient: (r == null ? void 0 : r.nodeForceCoefficient) ?? v.nodeForceCoefficient,
|
|
@@ -3949,7 +3957,7 @@ const Oe = (r) => {
|
|
|
3949
3957
|
e.clear();
|
|
3950
3958
|
});
|
|
3951
3959
|
};
|
|
3952
|
-
class
|
|
3960
|
+
class or {
|
|
3953
3961
|
constructor(e) {
|
|
3954
3962
|
i(this, "used", !1);
|
|
3955
3963
|
i(this, "canvasDefaults", {});
|
|
@@ -4046,25 +4054,25 @@ class sr {
|
|
|
4046
4054
|
if (this.used)
|
|
4047
4055
|
throw new Ht("CanvasBuilder is a single use object");
|
|
4048
4056
|
this.used = !0;
|
|
4049
|
-
const e = new
|
|
4057
|
+
const e = new Nt(this.element), t = this.createHtmlView(e.main), s = Lt(this.canvasDefaults), o = new ve(
|
|
4050
4058
|
this.graph,
|
|
4051
4059
|
this.viewport,
|
|
4052
4060
|
this.graphStore,
|
|
4053
4061
|
this.viewportStore,
|
|
4054
4062
|
t,
|
|
4055
|
-
|
|
4063
|
+
s
|
|
4056
4064
|
);
|
|
4057
4065
|
if (this.hasBackground && _.configure(
|
|
4058
|
-
|
|
4066
|
+
o,
|
|
4059
4067
|
Bt(this.backgroundConfig),
|
|
4060
4068
|
e.background
|
|
4061
|
-
), this.hasNodeResizeReactiveEdges && q.configure(
|
|
4069
|
+
), this.hasNodeResizeReactiveEdges && q.configure(o), this.hasDraggableNodes) {
|
|
4062
4070
|
let a = Rt(this.dragConfig);
|
|
4063
4071
|
this.hasAnimatedLayout && (a = er(
|
|
4064
4072
|
a,
|
|
4065
4073
|
this.animationStaticNodes
|
|
4066
4074
|
)), Z.configure(
|
|
4067
|
-
|
|
4075
|
+
o,
|
|
4068
4076
|
e.main,
|
|
4069
4077
|
this.window,
|
|
4070
4078
|
a
|
|
@@ -4073,11 +4081,11 @@ class sr {
|
|
|
4073
4081
|
if (this.hasUserConnectablePorts) {
|
|
4074
4082
|
const a = Ot(
|
|
4075
4083
|
this.connectablePortsConfig,
|
|
4076
|
-
|
|
4077
|
-
|
|
4084
|
+
s.edges.shapeFactory,
|
|
4085
|
+
s.ports.direction
|
|
4078
4086
|
);
|
|
4079
4087
|
ee.configure(
|
|
4080
|
-
|
|
4088
|
+
o,
|
|
4081
4089
|
e.overlayConnectablePorts,
|
|
4082
4090
|
this.viewportStore,
|
|
4083
4091
|
this.window,
|
|
@@ -4087,10 +4095,10 @@ class sr {
|
|
|
4087
4095
|
if (this.hasUserDraggableEdges) {
|
|
4088
4096
|
const a = Wt(
|
|
4089
4097
|
this.draggableEdgesConfig,
|
|
4090
|
-
|
|
4098
|
+
o.graph
|
|
4091
4099
|
);
|
|
4092
4100
|
te.configure(
|
|
4093
|
-
|
|
4101
|
+
o,
|
|
4094
4102
|
e.overlayDraggableEdges,
|
|
4095
4103
|
this.viewportStore,
|
|
4096
4104
|
this.window,
|
|
@@ -4098,33 +4106,33 @@ class sr {
|
|
|
4098
4106
|
);
|
|
4099
4107
|
}
|
|
4100
4108
|
this.virtualScrollConfig !== void 0 ? J.configure(
|
|
4101
|
-
|
|
4109
|
+
o,
|
|
4102
4110
|
e.main,
|
|
4103
4111
|
this.window,
|
|
4104
4112
|
ye(this.transformConfig),
|
|
4105
4113
|
this.boxRenderingTrigger,
|
|
4106
4114
|
kt(this.virtualScrollConfig)
|
|
4107
4115
|
) : this.hasTransformableViewport && H.configure(
|
|
4108
|
-
|
|
4116
|
+
o,
|
|
4109
4117
|
e.main,
|
|
4110
4118
|
this.window,
|
|
4111
4119
|
ye(this.transformConfig)
|
|
4112
4120
|
), this.hasLayout && Pt.configure(
|
|
4113
|
-
|
|
4121
|
+
o,
|
|
4114
4122
|
_t(this.layoutConfig)
|
|
4115
4123
|
), this.hasAnimatedLayout && (tr(
|
|
4116
|
-
|
|
4124
|
+
o.graph,
|
|
4117
4125
|
this.animationStaticNodes
|
|
4118
|
-
),
|
|
4119
|
-
|
|
4126
|
+
), se.configure(
|
|
4127
|
+
o,
|
|
4120
4128
|
Qt(this.animatedLayoutConfig),
|
|
4121
4129
|
this.animationStaticNodes,
|
|
4122
4130
|
this.window
|
|
4123
4131
|
));
|
|
4124
4132
|
const n = () => {
|
|
4125
|
-
e.destroy(),
|
|
4133
|
+
e.destroy(), o.onBeforeDestroy.unsubscribe(n);
|
|
4126
4134
|
};
|
|
4127
|
-
return
|
|
4135
|
+
return o.onBeforeDestroy.subscribe(n), o;
|
|
4128
4136
|
}
|
|
4129
4137
|
createHtmlView(e) {
|
|
4130
4138
|
let t = new me(
|
|
@@ -4142,16 +4150,16 @@ class sr {
|
|
|
4142
4150
|
}
|
|
4143
4151
|
export {
|
|
4144
4152
|
ut as BezierEdgeShape,
|
|
4145
|
-
|
|
4153
|
+
or as CanvasBuilder,
|
|
4146
4154
|
Ht as CanvasBuilderError,
|
|
4147
|
-
|
|
4155
|
+
A as CanvasError,
|
|
4148
4156
|
M as ConnectionCategory,
|
|
4149
|
-
|
|
4157
|
+
De as DirectEdgeShape,
|
|
4150
4158
|
j as EventSubject,
|
|
4151
4159
|
pt as HorizontalEdgeShape,
|
|
4152
4160
|
vt as InteractiveEdgeError,
|
|
4153
4161
|
Me as InteractiveEdgeShape,
|
|
4154
|
-
|
|
4162
|
+
sr as MidpointEdgeShape,
|
|
4155
4163
|
wt as StraightEdgeShape,
|
|
4156
4164
|
ft as VerticalEdgeShape
|
|
4157
4165
|
};
|