@html-graph/html-graph 8.1.0 → 8.2.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 +23 -19
- package/dist/html-graph.js +973 -950
- package/dist/html-graph.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/html-graph.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
var ze = Object.defineProperty;
|
|
2
|
+
var ke = (r, e, t) => e in r ? ze(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
|
+
var o = (r, e, t) => ke(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
var M = /* @__PURE__ */ ((r) => (r.Line = "line", r.NodeCycle = "node-cycle", r.PortCycle = "port-cycle", r))(M || {});
|
|
5
5
|
const He = () => {
|
|
6
6
|
const r = document.createElement("div");
|
|
@@ -13,11 +13,11 @@ const He = () => {
|
|
|
13
13
|
};
|
|
14
14
|
class me {
|
|
15
15
|
constructor(e, t, s) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
o(this, "host", He());
|
|
17
|
+
o(this, "container", Xe());
|
|
18
|
+
o(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
|
|
19
|
+
o(this, "attachedNodeIds", /* @__PURE__ */ new Set());
|
|
20
|
+
o(this, "applyTransform", () => {
|
|
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
|
});
|
|
@@ -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: s, height:
|
|
53
|
+
const t = this.graphStore.getNode(e), { width: s, height: i } = t.element.getBoundingClientRect(), n = this.viewportStore.getViewportMatrix().scale, { payload: a } = t, h = a.centerFn(s, i), 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,24 +60,24 @@ 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 i = this.graphStore.getEdge(e).payload.shape.svg;
|
|
64
|
+
this.edgeIdToElementMap.set(e, i), this.container.appendChild(i);
|
|
65
65
|
}
|
|
66
66
|
renderEdge(e) {
|
|
67
|
-
const t = this.graphStore.getEdge(e), s = this.graphStore.getPort(t.from),
|
|
67
|
+
const t = this.graphStore.getEdge(e), s = this.graphStore.getPort(t.from), i = this.graphStore.getPort(t.to), n = s.element.getBoundingClientRect(), a = i.element.getBoundingClientRect(), h = this.host.getBoundingClientRect(), d = this.viewportStore.getViewportMatrix().scale, c = this.createEdgeRenderPort(
|
|
68
68
|
s,
|
|
69
69
|
n,
|
|
70
70
|
h,
|
|
71
71
|
d
|
|
72
|
-
), g = this.createEdgeRenderPort(
|
|
72
|
+
), g = this.createEdgeRenderPort(i, a, h, d);
|
|
73
73
|
let l = M.Line;
|
|
74
|
-
s.element ===
|
|
74
|
+
s.element === i.element ? l = M.PortCycle : s.nodeId === i.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, s,
|
|
80
|
+
createEdgeRenderPort(e, t, s, i) {
|
|
81
81
|
const n = this.viewportStore.createContentCoords({
|
|
82
82
|
x: t.left - s.left,
|
|
83
83
|
y: t.top - s.top
|
|
@@ -85,57 +85,57 @@ class me {
|
|
|
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 * i,
|
|
89
|
+
height: t.height * i,
|
|
90
90
|
direction: e.payload.direction
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
class Ge {
|
|
95
95
|
constructor(e) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
96
|
+
o(this, "xFrom", 1 / 0);
|
|
97
|
+
o(this, "yFrom", 1 / 0);
|
|
98
|
+
o(this, "xTo", 1 / 0);
|
|
99
|
+
o(this, "yTo", 1 / 0);
|
|
100
100
|
this.graphStore = e;
|
|
101
101
|
}
|
|
102
102
|
setRenderingBox(e) {
|
|
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: s, y:
|
|
107
|
-
return s >= this.xFrom && s <= this.xTo &&
|
|
106
|
+
const t = this.graphStore.getNode(e).payload, { x: s, y: i } = t;
|
|
107
|
+
return s >= this.xFrom && s <= this.xTo && i >= this.yFrom && i <= this.yTo;
|
|
108
108
|
}
|
|
109
109
|
hasEdge(e) {
|
|
110
|
-
const t = this.graphStore.getEdge(e), s = this.graphStore.getPort(t.from).nodeId,
|
|
110
|
+
const t = this.graphStore.getEdge(e), s = this.graphStore.getPort(t.from).nodeId, i = this.graphStore.getPort(t.to).nodeId, n = this.graphStore.getNode(s).payload, a = this.graphStore.getNode(i).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, s,
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
115
|
+
constructor(e, t, s, i) {
|
|
116
|
+
o(this, "attachedNodes", /* @__PURE__ */ new Set());
|
|
117
|
+
o(this, "attachedEdges", /* @__PURE__ */ new Set());
|
|
118
|
+
o(this, "renderingBox");
|
|
119
|
+
o(this, "updateViewport", (e) => {
|
|
120
120
|
this.renderingBox.setRenderingBox(e);
|
|
121
|
-
const t = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(),
|
|
121
|
+
const t = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), i = /* @__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
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), s.delete(g)), this.renderingBox.hasNode(l) || (t.add(l), s.delete(l))), h && !d ?
|
|
127
|
+
h && (this.renderingBox.hasNode(g) || (t.add(g), s.delete(g)), this.renderingBox.hasNode(l) || (t.add(l), s.delete(l))), h && !d ? i.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
|
+
}), i.forEach((a) => {
|
|
135
135
|
this.handleAttachEdge(a);
|
|
136
136
|
});
|
|
137
137
|
});
|
|
138
|
-
this.htmlView = e, this.graphStore = t, this.trigger = s, this.params =
|
|
138
|
+
this.htmlView = e, this.graphStore = t, this.trigger = s, this.params = i, 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), s = this.graphStore.getPort(t.from).nodeId,
|
|
177
|
-
this.attachedNodes.has(s) || this.handleAttachNode(s), this.attachedNodes.has(
|
|
176
|
+
const t = this.graphStore.getEdge(e), s = this.graphStore.getPort(t.from).nodeId, i = this.graphStore.getPort(t.to).nodeId;
|
|
177
|
+
this.attachedNodes.has(s) || this.handleAttachNode(s), this.attachedNodes.has(i) || this.handleAttachNode(i), this.handleAttachEdge(e);
|
|
178
178
|
}
|
|
179
179
|
handleAttachNode(e) {
|
|
180
180
|
this.params.onBeforeNodeAttached(e), this.attachedNodes.add(e), this.htmlView.attachNode(e);
|
|
@@ -189,10 +189,10 @@ class je {
|
|
|
189
189
|
this.htmlView.detachEdge(e), this.attachedEdges.delete(e);
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
|
-
class
|
|
192
|
+
class Ke {
|
|
193
193
|
constructor(e, t) {
|
|
194
|
-
|
|
195
|
-
|
|
194
|
+
o(this, "deferredNodes", /* @__PURE__ */ new Set());
|
|
195
|
+
o(this, "deferredEdges", /* @__PURE__ */ new Set());
|
|
196
196
|
this.htmlView = e, this.graphStore = t;
|
|
197
197
|
}
|
|
198
198
|
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), s = this.graphStore.getPort(t.from),
|
|
240
|
-
return !(this.deferredNodes.has(s.nodeId) || this.deferredNodes.has(
|
|
239
|
+
const t = this.graphStore.getEdge(e), s = this.graphStore.getPort(t.from), i = this.graphStore.getPort(t.to);
|
|
240
|
+
return !(this.deferredNodes.has(s.nodeId) || this.deferredNodes.has(i.nodeId));
|
|
241
241
|
}
|
|
242
242
|
tryAttachEdge(e) {
|
|
243
243
|
this.isEdgeValid(e) && (this.deferredEdges.delete(e), this.htmlView.attachEdge(e));
|
|
@@ -245,7 +245,7 @@ class qe {
|
|
|
245
245
|
}
|
|
246
246
|
class j {
|
|
247
247
|
constructor() {
|
|
248
|
-
|
|
248
|
+
o(this, "callbacks", /* @__PURE__ */ new Set());
|
|
249
249
|
}
|
|
250
250
|
subscribe(e) {
|
|
251
251
|
this.callbacks.add(e);
|
|
@@ -265,7 +265,7 @@ const x = () => {
|
|
|
265
265
|
};
|
|
266
266
|
class X {
|
|
267
267
|
constructor(e) {
|
|
268
|
-
|
|
268
|
+
o(this, "counter", 0);
|
|
269
269
|
this.checkExists = e;
|
|
270
270
|
}
|
|
271
271
|
create(e) {
|
|
@@ -279,74 +279,68 @@ class X {
|
|
|
279
279
|
this.counter = 0;
|
|
280
280
|
}
|
|
281
281
|
}
|
|
282
|
-
class A extends Error {
|
|
283
|
-
constructor() {
|
|
284
|
-
super(...arguments);
|
|
285
|
-
i(this, "name", "CanvasError");
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
282
|
class ve {
|
|
289
|
-
constructor(e, t, s,
|
|
290
|
-
|
|
283
|
+
constructor(e, t, s, i, n, a) {
|
|
284
|
+
o(this, "nodeIdGenerator", new X(
|
|
291
285
|
(e) => this.graphStore.hasNode(e)
|
|
292
286
|
));
|
|
293
|
-
|
|
287
|
+
o(this, "portIdGenerator", new X(
|
|
294
288
|
(e) => this.graphStore.hasPort(e)
|
|
295
289
|
));
|
|
296
|
-
|
|
290
|
+
o(this, "edgeIdGenerator", new X(
|
|
297
291
|
(e) => this.graphStore.hasEdge(e)
|
|
298
292
|
));
|
|
299
|
-
|
|
293
|
+
o(this, "onAfterNodeAdded", (e) => {
|
|
300
294
|
this.htmlView.attachNode(e);
|
|
301
295
|
});
|
|
302
|
-
|
|
296
|
+
o(this, "onAfterNodeUpdated", (e) => {
|
|
303
297
|
this.htmlView.updateNodePosition(e), this.graphStore.getNodeAdjacentEdgeIds(e).forEach((t) => {
|
|
304
298
|
this.htmlView.renderEdge(t);
|
|
305
299
|
});
|
|
306
300
|
});
|
|
307
|
-
|
|
301
|
+
o(this, "onAfterNodePriorityUpdated", (e) => {
|
|
308
302
|
this.htmlView.updateNodePriority(e);
|
|
309
303
|
});
|
|
310
|
-
|
|
304
|
+
o(this, "onBeforeNodeRemoved", (e) => {
|
|
311
305
|
this.graphStore.getNodePortIds(e).forEach((t) => {
|
|
312
306
|
this.unmarkPort(t);
|
|
313
307
|
}), this.htmlView.detachNode(e);
|
|
314
308
|
});
|
|
315
|
-
|
|
309
|
+
o(this, "onAfterPortUpdated", (e) => {
|
|
316
310
|
this.graphStore.getPortAdjacentEdgeIds(e).forEach((t) => {
|
|
317
311
|
this.htmlView.renderEdge(t);
|
|
318
312
|
});
|
|
319
313
|
});
|
|
320
|
-
|
|
314
|
+
o(this, "onBeforePortUnmarked", (e) => {
|
|
321
315
|
this.graphStore.getPortAdjacentEdgeIds(e).forEach((t) => {
|
|
322
316
|
this.removeEdge(t);
|
|
323
317
|
});
|
|
324
318
|
});
|
|
325
|
-
|
|
319
|
+
o(this, "onAfterEdgeAdded", (e) => {
|
|
326
320
|
this.htmlView.attachEdge(e);
|
|
327
321
|
});
|
|
328
|
-
|
|
322
|
+
o(this, "onAfterEdgeShapeUpdated", (e) => {
|
|
329
323
|
this.htmlView.updateEdgeShape(e);
|
|
330
324
|
});
|
|
331
|
-
|
|
325
|
+
o(this, "onAfterEdgeUpdated", (e) => {
|
|
332
326
|
this.htmlView.renderEdge(e);
|
|
333
327
|
});
|
|
334
|
-
|
|
328
|
+
o(this, "onAfterEdgePriorityUpdated", (e) => {
|
|
335
329
|
this.htmlView.updateEdgePriority(e);
|
|
336
330
|
});
|
|
337
|
-
|
|
331
|
+
o(this, "onBeforeEdgeRemoved", (e) => {
|
|
338
332
|
this.htmlView.detachEdge(e);
|
|
339
333
|
});
|
|
340
|
-
|
|
334
|
+
o(this, "onBeforeClear", () => {
|
|
341
335
|
this.nodeIdGenerator.reset(), this.portIdGenerator.reset(), this.edgeIdGenerator.reset(), this.htmlView.clear();
|
|
342
336
|
});
|
|
343
|
-
|
|
344
|
-
|
|
337
|
+
o(this, "onBeforeDestroyEmitter");
|
|
338
|
+
o(this, "destroyed", !1);
|
|
345
339
|
/**
|
|
346
340
|
* emits event just before destruction of canvas
|
|
347
341
|
*/
|
|
348
|
-
|
|
349
|
-
this.graph = e, this.viewport = t, this.graphStore = s, this.viewportStore =
|
|
342
|
+
o(this, "onBeforeDestroy");
|
|
343
|
+
this.graph = e, this.viewport = t, this.graphStore = s, this.viewportStore = i, this.htmlView = n, this.params = a, this.graphStore.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graphStore.onAfterNodeUpdated.subscribe(this.onAfterNodeUpdated), this.graphStore.onAfterNodePriorityUpdated.subscribe(
|
|
350
344
|
this.onAfterNodePriorityUpdated
|
|
351
345
|
), 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
346
|
this.onAfterEdgeShapeUpdated
|
|
@@ -359,12 +353,6 @@ class ve {
|
|
|
359
353
|
*/
|
|
360
354
|
addNode(e) {
|
|
361
355
|
const t = this.nodeIdGenerator.create(e.id);
|
|
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
|
-
"failed to add node with html element already in use by another node"
|
|
367
|
-
);
|
|
368
356
|
if (this.graphStore.addNode({
|
|
369
357
|
id: t,
|
|
370
358
|
element: e.element,
|
|
@@ -386,8 +374,6 @@ class ve {
|
|
|
386
374
|
* updates node parameters
|
|
387
375
|
*/
|
|
388
376
|
updateNode(e, t) {
|
|
389
|
-
if (!this.graphStore.hasNode(e))
|
|
390
|
-
throw new A("failed to update nonexistent node");
|
|
391
377
|
return this.graphStore.updateNode(e, t ?? {}), this;
|
|
392
378
|
}
|
|
393
379
|
/**
|
|
@@ -396,8 +382,6 @@ class ve {
|
|
|
396
382
|
* all the edges adjacent to node get removed
|
|
397
383
|
*/
|
|
398
384
|
removeNode(e) {
|
|
399
|
-
if (!this.graphStore.hasNode(e))
|
|
400
|
-
throw new A("failed to remove nonexistent node");
|
|
401
385
|
return this.graphStore.removeNode(e), this;
|
|
402
386
|
}
|
|
403
387
|
/**
|
|
@@ -405,10 +389,6 @@ class ve {
|
|
|
405
389
|
*/
|
|
406
390
|
markPort(e) {
|
|
407
391
|
const t = this.portIdGenerator.create(e.id);
|
|
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
392
|
return this.graphStore.addPort({
|
|
413
393
|
id: t,
|
|
414
394
|
element: e.element,
|
|
@@ -420,8 +400,6 @@ class ve {
|
|
|
420
400
|
* updates port and edges attached to it
|
|
421
401
|
*/
|
|
422
402
|
updatePort(e, t) {
|
|
423
|
-
if (!this.graphStore.hasPort(e))
|
|
424
|
-
throw new A("failed to update nonexistent port");
|
|
425
403
|
return this.graphStore.updatePort(e, t ?? {}), this;
|
|
426
404
|
}
|
|
427
405
|
/**
|
|
@@ -429,8 +407,6 @@ class ve {
|
|
|
429
407
|
* all the edges adjacent to the port get removed
|
|
430
408
|
*/
|
|
431
409
|
unmarkPort(e) {
|
|
432
|
-
if (!this.graphStore.hasPort(e))
|
|
433
|
-
throw new A("failed to unmark nonexistent port");
|
|
434
410
|
return this.graphStore.removePort(e), this;
|
|
435
411
|
}
|
|
436
412
|
/**
|
|
@@ -438,12 +414,6 @@ class ve {
|
|
|
438
414
|
*/
|
|
439
415
|
addEdge(e) {
|
|
440
416
|
const t = this.edgeIdGenerator.create(e.id);
|
|
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
417
|
return this.graphStore.addEdge({
|
|
448
418
|
id: t,
|
|
449
419
|
from: e.from,
|
|
@@ -456,16 +426,12 @@ class ve {
|
|
|
456
426
|
* updates specified edge
|
|
457
427
|
*/
|
|
458
428
|
updateEdge(e, t) {
|
|
459
|
-
if (!this.graphStore.hasEdge(e))
|
|
460
|
-
throw new A("failed to update nonexistent edge");
|
|
461
429
|
return this.graphStore.updateEdge(e, t ?? {}), this;
|
|
462
430
|
}
|
|
463
431
|
/**
|
|
464
432
|
* removes specified edge
|
|
465
433
|
*/
|
|
466
434
|
removeEdge(e) {
|
|
467
|
-
if (!this.graphStore.hasEdge(e))
|
|
468
|
-
throw new A("failed to remove nonexistent edge");
|
|
469
435
|
return this.graphStore.removeEdge(e), this;
|
|
470
436
|
}
|
|
471
437
|
/**
|
|
@@ -501,10 +467,10 @@ class ve {
|
|
|
501
467
|
), this.graphStore.onBeforeEdgeRemoved.unsubscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.unsubscribe(this.onBeforeClear), this.htmlView.destroy(), this.viewportStore.destroy(), this.destroyed = !0);
|
|
502
468
|
}
|
|
503
469
|
}
|
|
504
|
-
class
|
|
470
|
+
class Qe {
|
|
505
471
|
constructor() {
|
|
506
|
-
|
|
507
|
-
|
|
472
|
+
o(this, "singleToMultiMap", /* @__PURE__ */ new Map());
|
|
473
|
+
o(this, "multiToSingleMap", /* @__PURE__ */ new Map());
|
|
508
474
|
}
|
|
509
475
|
addRecord(e, t) {
|
|
510
476
|
const s = this.singleToMultiMap.get(e);
|
|
@@ -541,42 +507,48 @@ class Ke {
|
|
|
541
507
|
return this.multiToSingleMap.get(e) !== void 0;
|
|
542
508
|
}
|
|
543
509
|
}
|
|
510
|
+
class A extends Error {
|
|
511
|
+
constructor() {
|
|
512
|
+
super(...arguments);
|
|
513
|
+
o(this, "name", "CanvasError");
|
|
514
|
+
}
|
|
515
|
+
}
|
|
544
516
|
class Ae {
|
|
545
517
|
constructor() {
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
518
|
+
o(this, "nodes", /* @__PURE__ */ new Map());
|
|
519
|
+
o(this, "ports", /* @__PURE__ */ new Map());
|
|
520
|
+
o(this, "edges", /* @__PURE__ */ new Map());
|
|
521
|
+
o(this, "nodesElementsMap", /* @__PURE__ */ new Map());
|
|
522
|
+
o(this, "portIncomingEdges", /* @__PURE__ */ new Map());
|
|
523
|
+
o(this, "portOutcomingEdges", /* @__PURE__ */ new Map());
|
|
524
|
+
o(this, "portCycleEdges", /* @__PURE__ */ new Map());
|
|
525
|
+
o(this, "elementPorts", new Qe());
|
|
526
|
+
o(this, "afterNodeAddedEmitter");
|
|
527
|
+
o(this, "onAfterNodeAdded");
|
|
528
|
+
o(this, "afterNodeUpdatedEmitter");
|
|
529
|
+
o(this, "onAfterNodeUpdated");
|
|
530
|
+
o(this, "afterNodePriorityUpdatedEmitter");
|
|
531
|
+
o(this, "onAfterNodePriorityUpdated");
|
|
532
|
+
o(this, "beforeNodeRemovedEmitter");
|
|
533
|
+
o(this, "onBeforeNodeRemoved");
|
|
534
|
+
o(this, "afterPortAddedEmitter");
|
|
535
|
+
o(this, "onAfterPortAdded");
|
|
536
|
+
o(this, "afterPortUpdatedEmitter");
|
|
537
|
+
o(this, "onAfterPortUpdated");
|
|
538
|
+
o(this, "beforePortRemovedEmitter");
|
|
539
|
+
o(this, "onBeforePortRemoved");
|
|
540
|
+
o(this, "afterEdgeAddedEmitter");
|
|
541
|
+
o(this, "onAfterEdgeAdded");
|
|
542
|
+
o(this, "afterEdgeShapeUpdatedEmitter");
|
|
543
|
+
o(this, "onAfterEdgeShapeUpdated");
|
|
544
|
+
o(this, "afterEdgeUpdatedEmitter");
|
|
545
|
+
o(this, "onAfterEdgeUpdated");
|
|
546
|
+
o(this, "afterEdgePriorityUpdatedEmitter");
|
|
547
|
+
o(this, "onAfterEdgePriorityUpdated");
|
|
548
|
+
o(this, "beforeEdgeRemovedEmitter");
|
|
549
|
+
o(this, "onBeforeEdgeRemoved");
|
|
550
|
+
o(this, "beforeClearEmitter");
|
|
551
|
+
o(this, "onBeforeClear");
|
|
580
552
|
[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
553
|
}
|
|
582
554
|
hasNode(e) {
|
|
@@ -589,6 +561,12 @@ class Ae {
|
|
|
589
561
|
return t;
|
|
590
562
|
}
|
|
591
563
|
addNode(e) {
|
|
564
|
+
if (this.hasNode(e.id))
|
|
565
|
+
throw new A("failed to add node with existing id");
|
|
566
|
+
if (this.findNodeIdByElement(e.element) !== void 0)
|
|
567
|
+
throw new A(
|
|
568
|
+
"failed to add node with html element already in use by another node"
|
|
569
|
+
);
|
|
592
570
|
const t = /* @__PURE__ */ new Map(), s = {
|
|
593
571
|
element: e.element,
|
|
594
572
|
payload: {
|
|
@@ -608,10 +586,14 @@ class Ae {
|
|
|
608
586
|
return this.nodesElementsMap.get(e);
|
|
609
587
|
}
|
|
610
588
|
updateNode(e, t) {
|
|
589
|
+
if (!this.hasNode(e))
|
|
590
|
+
throw new A("failed to update nonexistent node");
|
|
611
591
|
const { payload: s } = this.nodes.get(e);
|
|
612
592
|
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);
|
|
613
593
|
}
|
|
614
594
|
removeNode(e) {
|
|
595
|
+
if (!this.hasNode(e))
|
|
596
|
+
throw new A("failed to remove nonexistent node");
|
|
615
597
|
this.beforeNodeRemovedEmitter.emit(e);
|
|
616
598
|
const t = this.nodes.get(e);
|
|
617
599
|
this.nodesElementsMap.delete(t.element), this.nodes.delete(e);
|
|
@@ -626,6 +608,10 @@ class Ae {
|
|
|
626
608
|
return t;
|
|
627
609
|
}
|
|
628
610
|
addPort(e) {
|
|
611
|
+
if (this.hasPort(e.id))
|
|
612
|
+
throw new A("failed to add port with existing id");
|
|
613
|
+
if (!this.hasNode(e.nodeId))
|
|
614
|
+
throw new A("failed to add port to nonexistent node");
|
|
629
615
|
this.ports.set(e.id, {
|
|
630
616
|
element: e.element,
|
|
631
617
|
payload: {
|
|
@@ -635,6 +621,8 @@ class Ae {
|
|
|
635
621
|
}), 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);
|
|
636
622
|
}
|
|
637
623
|
updatePort(e, t) {
|
|
624
|
+
if (!this.hasPort(e))
|
|
625
|
+
throw new A("failed to update nonexistent port");
|
|
638
626
|
const s = this.ports.get(e).payload;
|
|
639
627
|
s.direction = t.direction ?? s.direction, this.afterPortUpdatedEmitter.emit(e);
|
|
640
628
|
}
|
|
@@ -651,6 +639,8 @@ class Ae {
|
|
|
651
639
|
return Array.from(t.ports.keys());
|
|
652
640
|
}
|
|
653
641
|
removePort(e) {
|
|
642
|
+
if (!this.hasPort(e))
|
|
643
|
+
throw new A("failed to remove nonexistent port");
|
|
654
644
|
const t = this.ports.get(e).nodeId;
|
|
655
645
|
this.beforePortRemovedEmitter.emit(e), this.nodes.get(t).ports.delete(e), this.ports.delete(e), this.elementPorts.removeByMulti(e);
|
|
656
646
|
}
|
|
@@ -664,15 +654,23 @@ class Ae {
|
|
|
664
654
|
return t;
|
|
665
655
|
}
|
|
666
656
|
addEdge(e) {
|
|
657
|
+
if (this.hasEdge(e.id))
|
|
658
|
+
throw new A("failed to add edge with existing id");
|
|
659
|
+
if (!this.hasPort(e.from))
|
|
660
|
+
throw new A("failed to add edge from nonexistent port");
|
|
661
|
+
if (!this.hasPort(e.to))
|
|
662
|
+
throw new A("failed to add edge to nonexistent port");
|
|
667
663
|
this.addEdgeInternal(e), this.afterEdgeAddedEmitter.emit(e.id);
|
|
668
664
|
}
|
|
669
665
|
updateEdge(e, t) {
|
|
666
|
+
if (!this.hasEdge(e))
|
|
667
|
+
throw new A("failed to update nonexistent edge");
|
|
670
668
|
if (t.from !== void 0 || t.to !== void 0) {
|
|
671
|
-
const
|
|
669
|
+
const i = this.edges.get(e), n = i.payload;
|
|
672
670
|
this.removeEdgeInternal(e), this.addEdgeInternal({
|
|
673
671
|
id: e,
|
|
674
|
-
from: t.from ??
|
|
675
|
-
to: t.to ??
|
|
672
|
+
from: t.from ?? i.from,
|
|
673
|
+
to: t.to ?? i.to,
|
|
676
674
|
shape: n.shape,
|
|
677
675
|
priority: n.priority
|
|
678
676
|
});
|
|
@@ -684,6 +682,8 @@ class Ae {
|
|
|
684
682
|
return Array.from(this.edges.keys());
|
|
685
683
|
}
|
|
686
684
|
removeEdge(e) {
|
|
685
|
+
if (!this.hasEdge(e))
|
|
686
|
+
throw new A("failed to remove nonexistent edge");
|
|
687
687
|
this.beforeEdgeRemovedEmitter.emit(e), this.removeEdgeInternal(e);
|
|
688
688
|
}
|
|
689
689
|
clear() {
|
|
@@ -716,8 +716,8 @@ class Ae {
|
|
|
716
716
|
}
|
|
717
717
|
getNodeIncomingEdgeIds(e) {
|
|
718
718
|
const t = Array.from(this.getNode(e).ports.keys()), s = [];
|
|
719
|
-
return t.forEach((
|
|
720
|
-
this.getPortIncomingEdgeIds(
|
|
719
|
+
return t.forEach((i) => {
|
|
720
|
+
this.getPortIncomingEdgeIds(i).filter((n) => {
|
|
721
721
|
const a = this.getEdge(n);
|
|
722
722
|
return this.getPort(a.from).nodeId !== e;
|
|
723
723
|
}).forEach((n) => {
|
|
@@ -727,8 +727,8 @@ class Ae {
|
|
|
727
727
|
}
|
|
728
728
|
getNodeOutgoingEdgeIds(e) {
|
|
729
729
|
const t = Array.from(this.getNode(e).ports.keys()), s = [];
|
|
730
|
-
return t.forEach((
|
|
731
|
-
this.getPortOutgoingEdgeIds(
|
|
730
|
+
return t.forEach((i) => {
|
|
731
|
+
this.getPortOutgoingEdgeIds(i).filter((n) => {
|
|
732
732
|
const a = this.getEdge(n);
|
|
733
733
|
return this.getPort(a.to).nodeId !== e;
|
|
734
734
|
}).forEach((n) => {
|
|
@@ -738,10 +738,10 @@ class Ae {
|
|
|
738
738
|
}
|
|
739
739
|
getNodeCycleEdgeIds(e) {
|
|
740
740
|
const t = Array.from(this.getNode(e).ports.keys()), s = [];
|
|
741
|
-
return t.forEach((
|
|
742
|
-
this.getPortCycleEdgeIds(
|
|
741
|
+
return t.forEach((i) => {
|
|
742
|
+
this.getPortCycleEdgeIds(i).forEach((n) => {
|
|
743
743
|
s.push(n);
|
|
744
|
-
}), this.getPortIncomingEdgeIds(
|
|
744
|
+
}), this.getPortIncomingEdgeIds(i).filter((n) => {
|
|
745
745
|
const a = this.getEdge(n);
|
|
746
746
|
return this.getPort(a.to).nodeId === e;
|
|
747
747
|
}).forEach((n) => {
|
|
@@ -751,12 +751,12 @@ class Ae {
|
|
|
751
751
|
}
|
|
752
752
|
getNodeAdjacentEdgeIds(e) {
|
|
753
753
|
const t = Array.from(this.getNode(e).ports.keys()), s = [];
|
|
754
|
-
return t.forEach((
|
|
755
|
-
this.getPortIncomingEdgeIds(
|
|
754
|
+
return t.forEach((i) => {
|
|
755
|
+
this.getPortIncomingEdgeIds(i).forEach((n) => {
|
|
756
756
|
s.push(n);
|
|
757
|
-
}), this.getPortOutgoingEdgeIds(
|
|
757
|
+
}), this.getPortOutgoingEdgeIds(i).forEach((n) => {
|
|
758
758
|
s.push(n);
|
|
759
|
-
}), this.getPortCycleEdgeIds(
|
|
759
|
+
}), this.getPortCycleEdgeIds(i).forEach((n) => {
|
|
760
760
|
s.push(n);
|
|
761
761
|
});
|
|
762
762
|
}), s;
|
|
@@ -772,8 +772,8 @@ class Ae {
|
|
|
772
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);
|
|
773
773
|
}
|
|
774
774
|
removeEdgeInternal(e) {
|
|
775
|
-
const t = this.edges.get(e), s = t.from,
|
|
776
|
-
this.portCycleEdges.get(s).delete(e), this.portCycleEdges.get(
|
|
775
|
+
const t = this.edges.get(e), s = t.from, i = t.to;
|
|
776
|
+
this.portCycleEdges.get(s).delete(e), this.portCycleEdges.get(i).delete(e), this.portIncomingEdges.get(s).delete(e), this.portIncomingEdges.get(i).delete(e), this.portOutcomingEdges.get(s).delete(e), this.portOutcomingEdges.get(i).delete(e), this.edges.delete(e);
|
|
777
777
|
}
|
|
778
778
|
}
|
|
779
779
|
const de = (r) => ({
|
|
@@ -788,17 +788,17 @@ const de = (r) => ({
|
|
|
788
788
|
x: r.scale * e.x + r.x,
|
|
789
789
|
y: r.scale * e.y + r.y
|
|
790
790
|
});
|
|
791
|
-
class
|
|
791
|
+
class Ze {
|
|
792
792
|
constructor(e) {
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
793
|
+
o(this, "viewportMatrix", ce);
|
|
794
|
+
o(this, "contentMatrix", ce);
|
|
795
|
+
o(this, "beforeUpdateEmitter");
|
|
796
|
+
o(this, "onBeforeUpdated");
|
|
797
|
+
o(this, "afterUpdateEmitter");
|
|
798
|
+
o(this, "onAfterUpdated");
|
|
799
|
+
o(this, "afterResizeEmitter");
|
|
800
|
+
o(this, "onAfterResize");
|
|
801
|
+
o(this, "observer", new ResizeObserver(() => {
|
|
802
802
|
this.afterResizeEmitter.emit();
|
|
803
803
|
}));
|
|
804
804
|
this.host = e, [this.afterUpdateEmitter, this.onAfterUpdated] = x(), [this.beforeUpdateEmitter, this.onBeforeUpdated] = x(), [this.afterResizeEmitter, this.onAfterResize] = x(), this.observer.observe(this.host);
|
|
@@ -837,40 +837,40 @@ class Qe {
|
|
|
837
837
|
this.observer.disconnect();
|
|
838
838
|
}
|
|
839
839
|
}
|
|
840
|
-
class
|
|
840
|
+
class K {
|
|
841
841
|
constructor(e) {
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
842
|
+
o(this, "elementToNodeId", /* @__PURE__ */ new Map());
|
|
843
|
+
o(this, "nodesResizeObserver");
|
|
844
|
+
o(this, "onAfterNodeAdded", (e) => {
|
|
845
845
|
const t = this.canvas.graph.getNode(e);
|
|
846
846
|
this.elementToNodeId.set(t.element, e), this.nodesResizeObserver.observe(t.element);
|
|
847
847
|
});
|
|
848
|
-
|
|
848
|
+
o(this, "onBeforeNodeRemoved", (e) => {
|
|
849
849
|
const t = this.canvas.graph.getNode(e);
|
|
850
850
|
this.elementToNodeId.delete(t.element), this.nodesResizeObserver.unobserve(t.element);
|
|
851
851
|
});
|
|
852
|
-
|
|
852
|
+
o(this, "onBeforeClear", () => {
|
|
853
853
|
this.nodesResizeObserver.disconnect(), this.elementToNodeId.clear();
|
|
854
854
|
});
|
|
855
855
|
this.canvas = e, this.nodesResizeObserver = new ResizeObserver((t) => {
|
|
856
856
|
t.forEach((s) => {
|
|
857
|
-
const
|
|
858
|
-
this.handleNodeResize(
|
|
857
|
+
const i = s.target;
|
|
858
|
+
this.handleNodeResize(i);
|
|
859
859
|
});
|
|
860
860
|
}), this.canvas.graph.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.canvas.graph.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.canvas.graph.onBeforeClear.subscribe(this.onBeforeClear);
|
|
861
861
|
}
|
|
862
862
|
static configure(e) {
|
|
863
|
-
new
|
|
863
|
+
new K(e);
|
|
864
864
|
}
|
|
865
865
|
handleNodeResize(e) {
|
|
866
866
|
const t = this.elementToNodeId.get(e);
|
|
867
867
|
this.canvas.updateNode(t);
|
|
868
868
|
}
|
|
869
869
|
}
|
|
870
|
-
const
|
|
871
|
-
const { x: s, y:
|
|
872
|
-
return e >= s && e <= s + n && t >=
|
|
873
|
-
}, Je = (r, e, t) => e >= 0 && e <= r.innerWidth && t >= 0 && t <= r.innerHeight, L = (r, e, t, s) =>
|
|
870
|
+
const qe = (r, e, t) => {
|
|
871
|
+
const { x: s, y: i, width: n, height: a } = r.getBoundingClientRect();
|
|
872
|
+
return e >= s && e <= s + n && t >= i && t <= i + a;
|
|
873
|
+
}, Je = (r, e, t) => e >= 0 && e <= r.innerWidth && t >= 0 && t <= r.innerHeight, L = (r, e, t, s) => qe(e, t, s) && Je(r, t, s), $ = (r, e) => {
|
|
874
874
|
e !== null ? r.style.cursor = e : r.style.removeProperty("cursor");
|
|
875
875
|
}, U = (r) => {
|
|
876
876
|
const e = document.createElement("div");
|
|
@@ -910,8 +910,8 @@ function* Ee(r, e) {
|
|
|
910
910
|
const t = r.elementsFromPoint(e.x, e.y);
|
|
911
911
|
for (const s of t) {
|
|
912
912
|
if (s.shadowRoot !== null) {
|
|
913
|
-
const
|
|
914
|
-
for (const n of
|
|
913
|
+
const i = Ee(s.shadowRoot, e);
|
|
914
|
+
for (const n of i)
|
|
915
915
|
yield n;
|
|
916
916
|
}
|
|
917
917
|
yield s;
|
|
@@ -920,15 +920,15 @@ function* Ee(r, e) {
|
|
|
920
920
|
const xe = (r, e) => {
|
|
921
921
|
const t = Ee(document, e);
|
|
922
922
|
for (const s of t) {
|
|
923
|
-
const
|
|
924
|
-
if (
|
|
925
|
-
return
|
|
926
|
-
if (
|
|
923
|
+
const i = _e(r, s);
|
|
924
|
+
if (i.status === "portFound")
|
|
925
|
+
return i.portId;
|
|
926
|
+
if (i.status === "nodeEncountered")
|
|
927
927
|
return null;
|
|
928
928
|
}
|
|
929
929
|
return null;
|
|
930
930
|
};
|
|
931
|
-
var
|
|
931
|
+
var N = /* @__PURE__ */ ((r) => (r.StaticNodeId = "static", r.DraggingNodeId = "dragging", r.EdgeId = "edge", r))(N || {});
|
|
932
932
|
const Se = (r, e) => ({
|
|
933
933
|
x: r / 2,
|
|
934
934
|
y: e / 2
|
|
@@ -945,9 +945,9 @@ const Se = (r, e) => ({
|
|
|
945
945
|
}, s = {
|
|
946
946
|
x: e.x + e.width / 2,
|
|
947
947
|
y: e.y + e.height / 2
|
|
948
|
-
},
|
|
948
|
+
}, i = 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;
|
|
949
949
|
return {
|
|
950
|
-
x:
|
|
950
|
+
x: i,
|
|
951
951
|
y: n,
|
|
952
952
|
width: a,
|
|
953
953
|
height: h,
|
|
@@ -960,8 +960,8 @@ const Se = (r, e) => ({
|
|
|
960
960
|
});
|
|
961
961
|
class et {
|
|
962
962
|
constructor(e) {
|
|
963
|
-
|
|
964
|
-
|
|
963
|
+
o(this, "path");
|
|
964
|
+
o(this, "midpoint");
|
|
965
965
|
this.params = e;
|
|
966
966
|
const t = this.params.to;
|
|
967
967
|
this.midpoint = { x: t.x / 2, y: t.y / 2 };
|
|
@@ -969,7 +969,7 @@ class et {
|
|
|
969
969
|
{ x: this.params.arrowLength, y: p.y },
|
|
970
970
|
this.params.sourceDirection,
|
|
971
971
|
p
|
|
972
|
-
),
|
|
972
|
+
), i = m(
|
|
973
973
|
{ x: this.params.to.x - this.params.arrowLength, y: this.params.to.y },
|
|
974
974
|
this.params.targetDirection,
|
|
975
975
|
this.params.to
|
|
@@ -977,16 +977,16 @@ class et {
|
|
|
977
977
|
x: s.x + this.params.sourceDirection.x * this.params.curvature,
|
|
978
978
|
y: s.y + this.params.sourceDirection.y * this.params.curvature
|
|
979
979
|
}, a = {
|
|
980
|
-
x:
|
|
981
|
-
y:
|
|
982
|
-
}, h = `M ${s.x} ${s.y} C ${n.x} ${n.y}, ${a.x} ${a.y}, ${
|
|
980
|
+
x: i.x - this.params.targetDirection.x * this.params.curvature,
|
|
981
|
+
y: i.y - this.params.targetDirection.y * this.params.curvature
|
|
982
|
+
}, h = `M ${s.x} ${s.y} C ${n.x} ${n.y}, ${a.x} ${a.y}, ${i.x} ${i.y}`, d = this.params.hasSourceArrow ? "" : `M ${p.x} ${p.y} L ${s.x} ${s.y} `, c = this.params.hasTargetArrow ? "" : ` M ${i.x} ${i.y} L ${this.params.to.x} ${this.params.to.y}`;
|
|
983
983
|
this.path = `${d}${h}${c}`;
|
|
984
984
|
}
|
|
985
985
|
}
|
|
986
986
|
class tt {
|
|
987
987
|
constructor(e) {
|
|
988
|
-
|
|
989
|
-
|
|
988
|
+
o(this, "path");
|
|
989
|
+
o(this, "midpoint");
|
|
990
990
|
this.params = e;
|
|
991
991
|
const t = this.params.hasSourceArrow ? m(
|
|
992
992
|
{ x: this.params.arrowLength, y: p.y },
|
|
@@ -999,15 +999,15 @@ class tt {
|
|
|
999
999
|
},
|
|
1000
1000
|
this.params.targetDirection,
|
|
1001
1001
|
this.params.to
|
|
1002
|
-
) : this.params.to,
|
|
1003
|
-
{ x:
|
|
1002
|
+
) : this.params.to, i = 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: i, y: p.y },
|
|
1004
1004
|
this.params.sourceDirection,
|
|
1005
1005
|
p
|
|
1006
1006
|
), g = {
|
|
1007
1007
|
x: c.x + h,
|
|
1008
1008
|
y: c.y + d
|
|
1009
1009
|
}, l = m(
|
|
1010
|
-
{ x: this.params.to.x -
|
|
1010
|
+
{ x: this.params.to.x - i, y: this.params.to.y },
|
|
1011
1011
|
this.params.targetDirection,
|
|
1012
1012
|
this.params.to
|
|
1013
1013
|
), u = {
|
|
@@ -1016,7 +1016,7 @@ class tt {
|
|
|
1016
1016
|
}, w = {
|
|
1017
1017
|
x: (g.x + u.x) / 2,
|
|
1018
1018
|
y: (g.y + u.y) / 2
|
|
1019
|
-
},
|
|
1019
|
+
}, y = {
|
|
1020
1020
|
x: c.x + this.params.curvature * this.params.sourceDirection.x,
|
|
1021
1021
|
y: c.y + this.params.curvature * this.params.sourceDirection.y
|
|
1022
1022
|
}, E = {
|
|
@@ -1032,42 +1032,42 @@ class tt {
|
|
|
1032
1032
|
this.path = [
|
|
1033
1033
|
`M ${t.x} ${t.y}`,
|
|
1034
1034
|
`L ${c.x} ${c.y}`,
|
|
1035
|
-
`C ${
|
|
1035
|
+
`C ${y.x} ${y.y} ${S.x} ${S.y} ${w.x} ${w.y}`,
|
|
1036
1036
|
`C ${b.x} ${b.y} ${E.x} ${E.y} ${l.x} ${l.y}`,
|
|
1037
1037
|
`L ${s.x} ${s.y}`
|
|
1038
1038
|
].join(" "), this.midpoint = W(w, e.flipX, e.flipY, e.to);
|
|
1039
1039
|
}
|
|
1040
1040
|
}
|
|
1041
|
-
const
|
|
1041
|
+
const Q = Object.freeze({
|
|
1042
1042
|
edgeColor: "--edge-color"
|
|
1043
1043
|
}), Pe = (r) => {
|
|
1044
1044
|
const e = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
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(
|
|
1046
|
-
},
|
|
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(Q.edgeColor, r), e;
|
|
1046
|
+
}, Ne = (r) => {
|
|
1047
1047
|
const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
1048
|
-
return e.setAttribute("stroke", `var(${
|
|
1048
|
+
return e.setAttribute("stroke", `var(${Q.edgeColor})`), e.setAttribute("stroke-width", `${r}`), e.setAttribute("fill", "none"), e;
|
|
1049
1049
|
}, B = () => {
|
|
1050
1050
|
const r = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
1051
|
-
return r.setAttribute("fill", `var(${
|
|
1052
|
-
},
|
|
1051
|
+
return r.setAttribute("fill", `var(${Q.edgeColor})`), r;
|
|
1052
|
+
}, Te = () => {
|
|
1053
1053
|
const r = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
|
1054
1054
|
return r.style.transformOrigin = "50% 50%", r;
|
|
1055
|
-
},
|
|
1055
|
+
}, Ce = (r, e) => {
|
|
1056
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`;
|
|
1057
1057
|
}, D = (r, e) => {
|
|
1058
1058
|
const t = [];
|
|
1059
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) {
|
|
1060
1060
|
const s = r.length - 1;
|
|
1061
|
-
let
|
|
1061
|
+
let i = 0, n = 0, a = 0;
|
|
1062
1062
|
r.forEach((h, d) => {
|
|
1063
1063
|
let c = 0, g = 0, l = 0;
|
|
1064
|
-
const u = d > 0, w = d < s,
|
|
1065
|
-
if (u && (c = -
|
|
1064
|
+
const u = d > 0, w = d < s, y = u && w;
|
|
1065
|
+
if (u && (c = -i, g = -n, l = a), w) {
|
|
1066
1066
|
const V = r[d + 1];
|
|
1067
|
-
|
|
1067
|
+
i = V.x - h.x, n = V.y - h.y, a = Math.sqrt(i * i + n * n);
|
|
1068
1068
|
}
|
|
1069
|
-
const S = a !== 0 ? Math.min((
|
|
1070
|
-
d > 0 && t.push(`L ${R.x} ${R.y}`),
|
|
1069
|
+
const S = a !== 0 ? Math.min((y ? e : 0) / a, d < s - 1 ? 0.5 : 1) : 0, b = y ? { x: h.x + i * S, y: h.y + n * S } : h, P = l !== 0 ? Math.min((y ? e : 0) / l, d > 1 ? 0.5 : 1) : 0, R = y ? { x: h.x + c * P, y: h.y + g * P } : h;
|
|
1070
|
+
d > 0 && t.push(`L ${R.x} ${R.y}`), y && t.push(
|
|
1071
1071
|
`C ${h.x} ${h.y} ${h.x} ${h.y} ${b.x} ${b.y}`
|
|
1072
1072
|
);
|
|
1073
1073
|
});
|
|
@@ -1076,8 +1076,8 @@ const K = Object.freeze({
|
|
|
1076
1076
|
};
|
|
1077
1077
|
class rt {
|
|
1078
1078
|
constructor(e) {
|
|
1079
|
-
|
|
1080
|
-
|
|
1079
|
+
o(this, "path");
|
|
1080
|
+
o(this, "midpoint");
|
|
1081
1081
|
this.params = e;
|
|
1082
1082
|
const t = this.params.to;
|
|
1083
1083
|
this.midpoint = { x: t.x / 2, y: t.y / 2 };
|
|
@@ -1085,7 +1085,7 @@ class rt {
|
|
|
1085
1085
|
{ x: this.params.arrowLength, y: p.y },
|
|
1086
1086
|
this.params.sourceDirection,
|
|
1087
1087
|
p
|
|
1088
|
-
) : p,
|
|
1088
|
+
) : p, i = this.params.hasTargetArrow ? m(
|
|
1089
1089
|
{
|
|
1090
1090
|
x: this.params.to.x - this.params.arrowLength,
|
|
1091
1091
|
y: this.params.to.y
|
|
@@ -1106,17 +1106,17 @@ class rt {
|
|
|
1106
1106
|
}, u = { x: l.x, y: g }, w = {
|
|
1107
1107
|
x: this.params.flipX > 0 ? this.params.to.x - c : this.params.to.x + n,
|
|
1108
1108
|
y: d.y
|
|
1109
|
-
},
|
|
1109
|
+
}, y = { x: w.x, y: g };
|
|
1110
1110
|
this.path = D(
|
|
1111
|
-
[s, h, l, u,
|
|
1111
|
+
[s, h, l, u, y, w, d, i],
|
|
1112
1112
|
this.params.roundness
|
|
1113
1113
|
);
|
|
1114
1114
|
}
|
|
1115
1115
|
}
|
|
1116
1116
|
class st {
|
|
1117
1117
|
constructor(e) {
|
|
1118
|
-
|
|
1119
|
-
|
|
1118
|
+
o(this, "path");
|
|
1119
|
+
o(this, "midpoint");
|
|
1120
1120
|
this.params = e;
|
|
1121
1121
|
const t = this.params.hasSourceArrow ? m(
|
|
1122
1122
|
{ x: this.params.arrowLength, y: p.y },
|
|
@@ -1129,12 +1129,12 @@ class st {
|
|
|
1129
1129
|
},
|
|
1130
1130
|
this.params.targetDirection,
|
|
1131
1131
|
this.params.to
|
|
1132
|
-
) : this.params.to,
|
|
1133
|
-
{ x:
|
|
1132
|
+
) : this.params.to, i = this.params.arrowLength + this.params.arrowOffset, n = m(
|
|
1133
|
+
{ x: i, y: p.y },
|
|
1134
1134
|
this.params.sourceDirection,
|
|
1135
1135
|
p
|
|
1136
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(
|
|
1137
|
-
{ x: this.params.to.x -
|
|
1137
|
+
{ x: this.params.to.x - i, y: this.params.to.y },
|
|
1138
1138
|
this.params.targetDirection,
|
|
1139
1139
|
this.params.to
|
|
1140
1140
|
), u = { x: l.x + d, y: l.y + c }, w = { x: (g.x + u.x) / 2, y: (g.y + u.y) / 2 };
|
|
@@ -1146,8 +1146,8 @@ class st {
|
|
|
1146
1146
|
}
|
|
1147
1147
|
class ot {
|
|
1148
1148
|
constructor(e) {
|
|
1149
|
-
|
|
1150
|
-
|
|
1149
|
+
o(this, "path");
|
|
1150
|
+
o(this, "midpoint");
|
|
1151
1151
|
this.params = e;
|
|
1152
1152
|
const t = this.params.to;
|
|
1153
1153
|
this.midpoint = { x: t.x / 2, y: t.y / 2 };
|
|
@@ -1155,7 +1155,7 @@ class ot {
|
|
|
1155
1155
|
{ x: this.params.arrowLength, y: p.y },
|
|
1156
1156
|
this.params.sourceDirection,
|
|
1157
1157
|
p
|
|
1158
|
-
) : p,
|
|
1158
|
+
) : p, i = this.params.hasTargetArrow ? m(
|
|
1159
1159
|
{
|
|
1160
1160
|
x: this.params.to.x - this.params.arrowLength,
|
|
1161
1161
|
y: this.params.to.y
|
|
@@ -1171,13 +1171,13 @@ class ot {
|
|
|
1171
1171
|
this.params.targetDirection,
|
|
1172
1172
|
this.params.to
|
|
1173
1173
|
);
|
|
1174
|
-
this.path = D([s, a, h,
|
|
1174
|
+
this.path = D([s, a, h, i], this.params.roundness);
|
|
1175
1175
|
}
|
|
1176
1176
|
}
|
|
1177
1177
|
class it {
|
|
1178
1178
|
constructor(e) {
|
|
1179
|
-
|
|
1180
|
-
|
|
1179
|
+
o(this, "path");
|
|
1180
|
+
o(this, "midpoint");
|
|
1181
1181
|
this.params = e;
|
|
1182
1182
|
const t = this.params.to;
|
|
1183
1183
|
this.midpoint = { x: t.x / 2, y: t.y / 2 };
|
|
@@ -1185,7 +1185,7 @@ class it {
|
|
|
1185
1185
|
{ x: this.params.arrowLength, y: p.y },
|
|
1186
1186
|
this.params.sourceDirection,
|
|
1187
1187
|
p
|
|
1188
|
-
) : p,
|
|
1188
|
+
) : p, i = this.params.hasTargetArrow ? m(
|
|
1189
1189
|
{
|
|
1190
1190
|
x: this.params.to.x - this.params.arrowLength,
|
|
1191
1191
|
y: this.params.to.y
|
|
@@ -1206,26 +1206,26 @@ class it {
|
|
|
1206
1206
|
}, u = { x: g, y: l.y }, w = {
|
|
1207
1207
|
x: d.x,
|
|
1208
1208
|
y: this.params.flipY > 0 ? this.params.to.y - c : this.params.to.y + n
|
|
1209
|
-
},
|
|
1209
|
+
}, y = { x: g, y: w.y };
|
|
1210
1210
|
this.path = D(
|
|
1211
|
-
[s, h, l, u,
|
|
1211
|
+
[s, h, l, u, y, w, d, i],
|
|
1212
1212
|
this.params.roundness
|
|
1213
1213
|
);
|
|
1214
1214
|
}
|
|
1215
1215
|
}
|
|
1216
|
-
class
|
|
1216
|
+
class Z {
|
|
1217
1217
|
constructor(e) {
|
|
1218
|
-
|
|
1219
|
-
|
|
1218
|
+
o(this, "path");
|
|
1219
|
+
o(this, "midpoint");
|
|
1220
1220
|
this.params = e;
|
|
1221
|
-
const t = this.params.arrowOffset, s = this.params.side,
|
|
1221
|
+
const t = this.params.arrowOffset, s = this.params.side, i = this.params.arrowLength + t, n = i + 2 * s, h = [
|
|
1222
1222
|
{ x: this.params.arrowLength, y: p.y },
|
|
1223
|
-
{ x:
|
|
1224
|
-
{ x:
|
|
1223
|
+
{ x: i, y: p.y },
|
|
1224
|
+
{ x: i, y: this.params.side },
|
|
1225
1225
|
{ x: n, y: this.params.side },
|
|
1226
1226
|
{ x: n, y: -this.params.side },
|
|
1227
|
-
{ x:
|
|
1228
|
-
{ x:
|
|
1227
|
+
{ x: i, y: -this.params.side },
|
|
1228
|
+
{ x: i, y: p.y },
|
|
1229
1229
|
{ x: this.params.arrowLength, y: p.y }
|
|
1230
1230
|
].map(
|
|
1231
1231
|
(c) => m(c, this.params.sourceDirection, p)
|
|
@@ -1235,16 +1235,16 @@ class Q {
|
|
|
1235
1235
|
}
|
|
1236
1236
|
class nt {
|
|
1237
1237
|
constructor(e) {
|
|
1238
|
-
|
|
1239
|
-
|
|
1238
|
+
o(this, "path");
|
|
1239
|
+
o(this, "midpoint");
|
|
1240
1240
|
this.params = e;
|
|
1241
|
-
const t = this.params.smallRadius, s = this.params.radius,
|
|
1241
|
+
const t = this.params.smallRadius, s = this.params.radius, i = t + s, n = t * s / i, a = Math.sqrt(i * i - t * t), h = a * t / i, d = a + s + this.params.arrowLength, c = this.params.arrowLength + h, l = [
|
|
1242
1242
|
{ x: this.params.arrowLength, y: p.y },
|
|
1243
1243
|
{ x: c, y: n },
|
|
1244
1244
|
{ x: c, y: -n },
|
|
1245
1245
|
{ x: d, y: 0 }
|
|
1246
1246
|
].map(
|
|
1247
|
-
(
|
|
1247
|
+
(y) => m(y, this.params.sourceDirection, p)
|
|
1248
1248
|
), u = [
|
|
1249
1249
|
`M ${l[0].x} ${l[0].y}`,
|
|
1250
1250
|
`A ${t} ${t} 0 0 1 ${l[1].x} ${l[1].y}`,
|
|
@@ -1256,9 +1256,9 @@ class nt {
|
|
|
1256
1256
|
}
|
|
1257
1257
|
class at {
|
|
1258
1258
|
constructor(e) {
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1259
|
+
o(this, "path");
|
|
1260
|
+
o(this, "midpoint");
|
|
1261
|
+
o(this, "diagonalDistance");
|
|
1262
1262
|
this.params = e;
|
|
1263
1263
|
const t = this.params.to;
|
|
1264
1264
|
if (this.midpoint = { x: t.x / 2, y: t.y / 2 }, this.diagonalDistance = Math.sqrt(
|
|
@@ -1269,7 +1269,7 @@ class at {
|
|
|
1269
1269
|
this.path = "";
|
|
1270
1270
|
return;
|
|
1271
1271
|
}
|
|
1272
|
-
const
|
|
1272
|
+
const i = this.createDirectLinePoint({
|
|
1273
1273
|
offset: this.params.sourceOffset,
|
|
1274
1274
|
hasArrow: this.params.hasSourceArrow,
|
|
1275
1275
|
flip: 1,
|
|
@@ -1280,20 +1280,20 @@ class at {
|
|
|
1280
1280
|
flip: -1,
|
|
1281
1281
|
shift: this.params.to
|
|
1282
1282
|
});
|
|
1283
|
-
this.path = `M ${
|
|
1283
|
+
this.path = `M ${i.x} ${i.y} L ${n.x} ${n.y}`;
|
|
1284
1284
|
}
|
|
1285
1285
|
createDirectLinePoint(e) {
|
|
1286
|
-
const t = e.hasArrow ? this.params.arrowLength : 0, s = e.offset + t,
|
|
1286
|
+
const t = e.hasArrow ? this.params.arrowLength : 0, s = e.offset + t, i = e.flip * s / this.diagonalDistance;
|
|
1287
1287
|
return {
|
|
1288
|
-
x: this.params.to.x *
|
|
1289
|
-
y: this.params.to.y *
|
|
1288
|
+
x: this.params.to.x * i + e.shift.x,
|
|
1289
|
+
y: this.params.to.y * i + e.shift.y
|
|
1290
1290
|
};
|
|
1291
1291
|
}
|
|
1292
1292
|
}
|
|
1293
1293
|
class ht {
|
|
1294
1294
|
constructor(e) {
|
|
1295
|
-
|
|
1296
|
-
|
|
1295
|
+
o(this, "path");
|
|
1296
|
+
o(this, "midpoint");
|
|
1297
1297
|
this.params = e;
|
|
1298
1298
|
const t = this.params.hasSourceArrow ? m(
|
|
1299
1299
|
{ x: this.params.arrowLength, y: p.y },
|
|
@@ -1306,12 +1306,12 @@ class ht {
|
|
|
1306
1306
|
},
|
|
1307
1307
|
this.params.targetDirection,
|
|
1308
1308
|
this.params.to
|
|
1309
|
-
) : this.params.to,
|
|
1310
|
-
{ x:
|
|
1309
|
+
) : this.params.to, i = this.params.arrowLength + this.params.arrowOffset, n = m(
|
|
1310
|
+
{ x: i, y: p.y },
|
|
1311
1311
|
this.params.sourceDirection,
|
|
1312
1312
|
p
|
|
1313
1313
|
), a = m(
|
|
1314
|
-
{ x: this.params.to.x -
|
|
1314
|
+
{ x: this.params.to.x - i, y: this.params.to.y },
|
|
1315
1315
|
this.params.targetDirection,
|
|
1316
1316
|
this.params.to
|
|
1317
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 = {
|
|
@@ -1333,8 +1333,8 @@ class ht {
|
|
|
1333
1333
|
}
|
|
1334
1334
|
class dt {
|
|
1335
1335
|
constructor(e) {
|
|
1336
|
-
|
|
1337
|
-
|
|
1336
|
+
o(this, "path");
|
|
1337
|
+
o(this, "midpoint");
|
|
1338
1338
|
this.params = e;
|
|
1339
1339
|
const t = this.params.hasSourceArrow ? m(
|
|
1340
1340
|
{ x: this.params.arrowLength, y: p.y },
|
|
@@ -1347,12 +1347,12 @@ class dt {
|
|
|
1347
1347
|
},
|
|
1348
1348
|
this.params.targetDirection,
|
|
1349
1349
|
this.params.to
|
|
1350
|
-
) : this.params.to,
|
|
1351
|
-
{ x:
|
|
1350
|
+
) : this.params.to, i = this.params.arrowLength + this.params.arrowOffset, n = m(
|
|
1351
|
+
{ x: i, y: p.y },
|
|
1352
1352
|
this.params.sourceDirection,
|
|
1353
1353
|
p
|
|
1354
1354
|
), a = m(
|
|
1355
|
-
{ x: this.params.to.x -
|
|
1355
|
+
{ x: this.params.to.x - i, y: this.params.to.y },
|
|
1356
1356
|
this.params.targetDirection,
|
|
1357
1357
|
this.params.to
|
|
1358
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 = {
|
|
@@ -1372,7 +1372,7 @@ class dt {
|
|
|
1372
1372
|
);
|
|
1373
1373
|
}
|
|
1374
1374
|
}
|
|
1375
|
-
const
|
|
1375
|
+
const f = Object.freeze({
|
|
1376
1376
|
color: "#777777",
|
|
1377
1377
|
width: 1,
|
|
1378
1378
|
arrowLength: 20,
|
|
@@ -1395,24 +1395,24 @@ const y = Object.freeze({
|
|
|
1395
1395
|
interactiveWidth: 10,
|
|
1396
1396
|
preOffset: 0
|
|
1397
1397
|
}), ge = (r, e, t) => ({ x: e * Math.cos(r), y: t * Math.sin(r) });
|
|
1398
|
-
class
|
|
1398
|
+
class z {
|
|
1399
1399
|
constructor(e) {
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
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 =
|
|
1400
|
+
o(this, "svg");
|
|
1401
|
+
o(this, "group", Te());
|
|
1402
|
+
o(this, "line");
|
|
1403
|
+
o(this, "sourceArrow", null);
|
|
1404
|
+
o(this, "targetArrow", null);
|
|
1405
|
+
o(this, "onAfterRender");
|
|
1406
|
+
o(this, "afterRenderEmitter");
|
|
1407
|
+
o(this, "arrowRenderer");
|
|
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 = Ne(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));
|
|
1409
1409
|
}
|
|
1410
1410
|
render(e) {
|
|
1411
|
-
const { x: t, y: s, width:
|
|
1411
|
+
const { x: t, y: s, width: i, height: n, flipX: a, flipY: h } = be(
|
|
1412
1412
|
e.from,
|
|
1413
1413
|
e.to
|
|
1414
1414
|
);
|
|
1415
|
-
|
|
1415
|
+
Ce(this.svg, { x: t, y: s, width: i, height: n }), this.group.style.transform = `scale(${a}, ${h})`;
|
|
1416
1416
|
const d = ge(
|
|
1417
1417
|
e.from.direction,
|
|
1418
1418
|
a,
|
|
@@ -1422,7 +1422,7 @@ class k {
|
|
|
1422
1422
|
a,
|
|
1423
1423
|
h
|
|
1424
1424
|
), g = {
|
|
1425
|
-
x:
|
|
1425
|
+
x: i,
|
|
1426
1426
|
y: n
|
|
1427
1427
|
};
|
|
1428
1428
|
let l = { x: -c.x, y: -c.y }, u;
|
|
@@ -1435,12 +1435,12 @@ class k {
|
|
|
1435
1435
|
h
|
|
1436
1436
|
);
|
|
1437
1437
|
this.line.setAttribute("d", w.path);
|
|
1438
|
-
let
|
|
1439
|
-
this.sourceArrow && (
|
|
1438
|
+
let y = null;
|
|
1439
|
+
this.sourceArrow && (y = this.arrowRenderer({
|
|
1440
1440
|
direction: d,
|
|
1441
1441
|
shift: p,
|
|
1442
1442
|
arrowLength: this.params.arrowLength
|
|
1443
|
-
}), this.sourceArrow.setAttribute("d",
|
|
1443
|
+
}), this.sourceArrow.setAttribute("d", y));
|
|
1444
1444
|
let E = null;
|
|
1445
1445
|
this.targetArrow && (E = this.arrowRenderer({
|
|
1446
1446
|
direction: l,
|
|
@@ -1448,7 +1448,7 @@ class k {
|
|
|
1448
1448
|
arrowLength: this.params.arrowLength
|
|
1449
1449
|
}), this.targetArrow.setAttribute("d", E)), this.afterRenderEmitter.emit({
|
|
1450
1450
|
edgePath: w,
|
|
1451
|
-
sourceArrowPath:
|
|
1451
|
+
sourceArrowPath: y,
|
|
1452
1452
|
targetArrowPath: E
|
|
1453
1453
|
});
|
|
1454
1454
|
}
|
|
@@ -1463,18 +1463,18 @@ const ct = (r) => (e) => {
|
|
|
1463
1463
|
).map((h) => ({
|
|
1464
1464
|
x: h.x + e.shift.x,
|
|
1465
1465
|
y: h.y + e.shift.y
|
|
1466
|
-
})),
|
|
1467
|
-
return `${
|
|
1466
|
+
})), i = `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 `${i} ${n} ${a} Z`;
|
|
1468
1468
|
}, lt = (r) => (e) => {
|
|
1469
|
-
const t = r.radius, s = e.arrowLength,
|
|
1470
|
-
(
|
|
1471
|
-
).map((
|
|
1472
|
-
x:
|
|
1473
|
-
y:
|
|
1474
|
-
})), g = `M ${c[0].x} ${c[0].y}`, l = `A ${
|
|
1469
|
+
const t = r.radius, s = e.arrowLength, i = (s * s + 2 * s * t) / (2 * t), n = i + t, a = s + t - t * (s + t) / n, h = t * i / n, c = [p, { x: a, y: -h }, { x: a, y: h }].map(
|
|
1470
|
+
(y) => m(y, e.direction, p)
|
|
1471
|
+
).map((y) => ({
|
|
1472
|
+
x: y.x + e.shift.x,
|
|
1473
|
+
y: y.y + e.shift.y
|
|
1474
|
+
})), g = `M ${c[0].x} ${c[0].y}`, l = `A ${i} ${i} 0 0 0 ${c[1].x} ${c[1].y}`, u = `A ${t} ${t} 0 0 0 ${c[2].x} ${c[2].y}`, w = `A ${i} ${i} 0 0 0 ${c[0].x} ${c[0].y}`;
|
|
1475
1475
|
return `${g} ${l} ${u} ${w}`;
|
|
1476
1476
|
}, gt = (r) => (e) => {
|
|
1477
|
-
const t = r.smallRadius, s = r.radius,
|
|
1477
|
+
const t = r.smallRadius, s = r.radius, i = m(
|
|
1478
1478
|
{
|
|
1479
1479
|
x: e.arrowLength,
|
|
1480
1480
|
y: 0
|
|
@@ -1487,7 +1487,7 @@ const ct = (r) => (e) => {
|
|
|
1487
1487
|
x: e.arrowLength + r.smallRadius,
|
|
1488
1488
|
y: 0
|
|
1489
1489
|
}
|
|
1490
|
-
), a = [p, { x:
|
|
1490
|
+
), a = [p, { x: i.x, y: -i.y }, i].map(
|
|
1491
1491
|
(l) => m(l, e.direction, p)
|
|
1492
1492
|
).map((l) => ({
|
|
1493
1493
|
x: l.x + e.shift.x,
|
|
@@ -1500,38 +1500,38 @@ const ct = (r) => (e) => {
|
|
|
1500
1500
|
switch (r.type) {
|
|
1501
1501
|
case "triangle":
|
|
1502
1502
|
return ct({
|
|
1503
|
-
radius: r.radius ??
|
|
1503
|
+
radius: r.radius ?? f.polygonArrowRadius
|
|
1504
1504
|
});
|
|
1505
1505
|
case "arc":
|
|
1506
1506
|
return lt({
|
|
1507
|
-
radius: r.radius ??
|
|
1507
|
+
radius: r.radius ?? f.circleArrowRadius
|
|
1508
1508
|
});
|
|
1509
1509
|
default:
|
|
1510
1510
|
return gt({
|
|
1511
|
-
smallRadius: r.smallRadius ??
|
|
1512
|
-
angle: r.angle ??
|
|
1513
|
-
radius: r.radius ??
|
|
1511
|
+
smallRadius: r.smallRadius ?? f.wedgeArrowSmallRadius,
|
|
1512
|
+
angle: r.angle ?? f.wedgeArrowAngle,
|
|
1513
|
+
radius: r.radius ?? f.wedgeArrowRadius
|
|
1514
1514
|
});
|
|
1515
1515
|
}
|
|
1516
1516
|
};
|
|
1517
1517
|
class ut {
|
|
1518
1518
|
constructor(e) {
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1519
|
+
o(this, "svg");
|
|
1520
|
+
o(this, "group");
|
|
1521
|
+
o(this, "line");
|
|
1522
|
+
o(this, "sourceArrow");
|
|
1523
|
+
o(this, "targetArrow");
|
|
1524
|
+
o(this, "onAfterRender");
|
|
1525
|
+
o(this, "arrowLength");
|
|
1526
|
+
o(this, "curvature");
|
|
1527
|
+
o(this, "portCycleRadius");
|
|
1528
|
+
o(this, "portCycleSmallRadius");
|
|
1529
|
+
o(this, "detourDirection");
|
|
1530
|
+
o(this, "detourDistance");
|
|
1531
|
+
o(this, "hasSourceArrow");
|
|
1532
|
+
o(this, "hasTargetArrow");
|
|
1533
|
+
o(this, "pathShape");
|
|
1534
|
+
o(this, "createCyclePath", (e) => new nt({
|
|
1535
1535
|
sourceDirection: e,
|
|
1536
1536
|
radius: this.portCycleRadius,
|
|
1537
1537
|
smallRadius: this.portCycleSmallRadius,
|
|
@@ -1539,11 +1539,11 @@ class ut {
|
|
|
1539
1539
|
hasSourceArrow: this.hasSourceArrow,
|
|
1540
1540
|
hasTargetArrow: this.hasTargetArrow
|
|
1541
1541
|
}));
|
|
1542
|
-
|
|
1542
|
+
o(this, "createDetourPath", (e, t, s, i, n) => new tt({
|
|
1543
1543
|
to: s,
|
|
1544
1544
|
sourceDirection: e,
|
|
1545
1545
|
targetDirection: t,
|
|
1546
|
-
flipX:
|
|
1546
|
+
flipX: i,
|
|
1547
1547
|
flipY: n,
|
|
1548
1548
|
arrowLength: this.arrowLength,
|
|
1549
1549
|
detourDirection: this.detourDirection,
|
|
@@ -1552,7 +1552,7 @@ class ut {
|
|
|
1552
1552
|
hasSourceArrow: this.hasSourceArrow,
|
|
1553
1553
|
hasTargetArrow: this.hasTargetArrow
|
|
1554
1554
|
}));
|
|
1555
|
-
|
|
1555
|
+
o(this, "createLinePath", (e, t, s) => new et({
|
|
1556
1556
|
to: s,
|
|
1557
1557
|
sourceDirection: e,
|
|
1558
1558
|
targetDirection: t,
|
|
@@ -1561,9 +1561,9 @@ class ut {
|
|
|
1561
1561
|
hasSourceArrow: this.hasSourceArrow,
|
|
1562
1562
|
hasTargetArrow: this.hasTargetArrow
|
|
1563
1563
|
}));
|
|
1564
|
-
this.arrowLength = (e == null ? void 0 : e.arrowLength) ??
|
|
1565
|
-
color: (e == null ? void 0 : e.color) ??
|
|
1566
|
-
width: (e == null ? void 0 : e.width) ??
|
|
1564
|
+
this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? f.arrowLength, this.curvature = (e == null ? void 0 : e.curvature) ?? f.curvature, this.portCycleRadius = (e == null ? void 0 : e.cycleRadius) ?? f.cycleRadius, this.portCycleSmallRadius = (e == null ? void 0 : e.smallCycleRadius) ?? f.smallCycleRadius, this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? f.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? f.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? f.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? f.hasTargetArrow, this.pathShape = new z({
|
|
1565
|
+
color: (e == null ? void 0 : e.color) ?? f.color,
|
|
1566
|
+
width: (e == null ? void 0 : e.width) ?? f.width,
|
|
1567
1567
|
arrowRenderer: F((e == null ? void 0 : e.arrowRenderer) ?? {}),
|
|
1568
1568
|
arrowLength: this.arrowLength,
|
|
1569
1569
|
hasSourceArrow: this.hasSourceArrow,
|
|
@@ -1579,21 +1579,21 @@ class ut {
|
|
|
1579
1579
|
}
|
|
1580
1580
|
class pt {
|
|
1581
1581
|
constructor(e) {
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1582
|
+
o(this, "svg");
|
|
1583
|
+
o(this, "group");
|
|
1584
|
+
o(this, "line");
|
|
1585
|
+
o(this, "sourceArrow");
|
|
1586
|
+
o(this, "targetArrow");
|
|
1587
|
+
o(this, "onAfterRender");
|
|
1588
|
+
o(this, "arrowLength");
|
|
1589
|
+
o(this, "arrowOffset");
|
|
1590
|
+
o(this, "roundness");
|
|
1591
|
+
o(this, "cycleSquareSide");
|
|
1592
|
+
o(this, "detourDistance");
|
|
1593
|
+
o(this, "hasSourceArrow");
|
|
1594
|
+
o(this, "hasTargetArrow");
|
|
1595
|
+
o(this, "pathShape");
|
|
1596
|
+
o(this, "createCyclePath", (e) => new Z({
|
|
1597
1597
|
sourceDirection: e,
|
|
1598
1598
|
arrowLength: this.arrowLength,
|
|
1599
1599
|
side: this.cycleSquareSide,
|
|
@@ -1602,11 +1602,11 @@ class pt {
|
|
|
1602
1602
|
hasSourceArrow: this.hasSourceArrow,
|
|
1603
1603
|
hasTargetArrow: this.hasTargetArrow
|
|
1604
1604
|
}));
|
|
1605
|
-
|
|
1605
|
+
o(this, "createDetourPath", (e, t, s, i, n) => new ht({
|
|
1606
1606
|
to: s,
|
|
1607
1607
|
sourceDirection: e,
|
|
1608
1608
|
targetDirection: t,
|
|
1609
|
-
flipX:
|
|
1609
|
+
flipX: i,
|
|
1610
1610
|
flipY: n,
|
|
1611
1611
|
arrowLength: this.arrowLength,
|
|
1612
1612
|
arrowOffset: this.arrowOffset,
|
|
@@ -1615,26 +1615,26 @@ class pt {
|
|
|
1615
1615
|
hasSourceArrow: this.hasSourceArrow,
|
|
1616
1616
|
hasTargetArrow: this.hasTargetArrow
|
|
1617
1617
|
}));
|
|
1618
|
-
|
|
1618
|
+
o(this, "createLinePath", (e, t, s, i) => new rt({
|
|
1619
1619
|
to: s,
|
|
1620
1620
|
sourceDirection: e,
|
|
1621
1621
|
targetDirection: t,
|
|
1622
|
-
flipX:
|
|
1622
|
+
flipX: i,
|
|
1623
1623
|
arrowLength: this.arrowLength,
|
|
1624
1624
|
arrowOffset: this.arrowOffset,
|
|
1625
1625
|
roundness: this.roundness,
|
|
1626
1626
|
hasSourceArrow: this.hasSourceArrow,
|
|
1627
1627
|
hasTargetArrow: this.hasTargetArrow
|
|
1628
1628
|
}));
|
|
1629
|
-
this.arrowLength = (e == null ? void 0 : e.arrowLength) ??
|
|
1630
|
-
const t = (e == null ? void 0 : e.roundness) ??
|
|
1629
|
+
this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? f.arrowLength, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? f.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? f.cycleSquareSide;
|
|
1630
|
+
const t = (e == null ? void 0 : e.roundness) ?? f.roundness;
|
|
1631
1631
|
this.roundness = Math.min(
|
|
1632
1632
|
t,
|
|
1633
1633
|
this.arrowOffset,
|
|
1634
1634
|
this.cycleSquareSide / 2
|
|
1635
|
-
), this.detourDistance = (e == null ? void 0 : e.detourDistance) ??
|
|
1636
|
-
color: (e == null ? void 0 : e.color) ??
|
|
1637
|
-
width: (e == null ? void 0 : e.width) ??
|
|
1635
|
+
), this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? f.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? f.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? f.hasTargetArrow, this.pathShape = new z({
|
|
1636
|
+
color: (e == null ? void 0 : e.color) ?? f.color,
|
|
1637
|
+
width: (e == null ? void 0 : e.width) ?? f.width,
|
|
1638
1638
|
arrowRenderer: F((e == null ? void 0 : e.arrowRenderer) ?? {}),
|
|
1639
1639
|
arrowLength: this.arrowLength,
|
|
1640
1640
|
hasSourceArrow: this.hasSourceArrow,
|
|
@@ -1650,22 +1650,22 @@ class pt {
|
|
|
1650
1650
|
}
|
|
1651
1651
|
class wt {
|
|
1652
1652
|
constructor(e) {
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1653
|
+
o(this, "svg");
|
|
1654
|
+
o(this, "group");
|
|
1655
|
+
o(this, "line");
|
|
1656
|
+
o(this, "sourceArrow");
|
|
1657
|
+
o(this, "targetArrow");
|
|
1658
|
+
o(this, "onAfterRender");
|
|
1659
|
+
o(this, "arrowLength");
|
|
1660
|
+
o(this, "arrowOffset");
|
|
1661
|
+
o(this, "roundness");
|
|
1662
|
+
o(this, "cycleSquareSide");
|
|
1663
|
+
o(this, "detourDirection");
|
|
1664
|
+
o(this, "detourDistance");
|
|
1665
|
+
o(this, "hasSourceArrow");
|
|
1666
|
+
o(this, "hasTargetArrow");
|
|
1667
|
+
o(this, "pathShape");
|
|
1668
|
+
o(this, "createCyclePath", (e) => new Z({
|
|
1669
1669
|
sourceDirection: e,
|
|
1670
1670
|
arrowLength: this.arrowLength,
|
|
1671
1671
|
side: this.cycleSquareSide,
|
|
@@ -1674,11 +1674,11 @@ class wt {
|
|
|
1674
1674
|
hasSourceArrow: this.hasSourceArrow,
|
|
1675
1675
|
hasTargetArrow: this.hasTargetArrow
|
|
1676
1676
|
}));
|
|
1677
|
-
|
|
1677
|
+
o(this, "createDetourPath", (e, t, s, i, n) => new st({
|
|
1678
1678
|
to: s,
|
|
1679
1679
|
sourceDirection: e,
|
|
1680
1680
|
targetDirection: t,
|
|
1681
|
-
flipX:
|
|
1681
|
+
flipX: i,
|
|
1682
1682
|
flipY: n,
|
|
1683
1683
|
arrowLength: this.arrowLength,
|
|
1684
1684
|
arrowOffset: this.arrowOffset,
|
|
@@ -1688,7 +1688,7 @@ class wt {
|
|
|
1688
1688
|
hasSourceArrow: this.hasSourceArrow,
|
|
1689
1689
|
hasTargetArrow: this.hasTargetArrow
|
|
1690
1690
|
}));
|
|
1691
|
-
|
|
1691
|
+
o(this, "createLinePath", (e, t, s) => new ot({
|
|
1692
1692
|
to: s,
|
|
1693
1693
|
sourceDirection: e,
|
|
1694
1694
|
targetDirection: t,
|
|
@@ -1698,15 +1698,15 @@ class wt {
|
|
|
1698
1698
|
hasSourceArrow: this.hasSourceArrow,
|
|
1699
1699
|
hasTargetArrow: this.hasTargetArrow
|
|
1700
1700
|
}));
|
|
1701
|
-
this.arrowLength = (e == null ? void 0 : e.arrowLength) ??
|
|
1702
|
-
const t = (e == null ? void 0 : e.roundness) ??
|
|
1701
|
+
this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? f.arrowLength, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? f.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? f.cycleSquareSide;
|
|
1702
|
+
const t = (e == null ? void 0 : e.roundness) ?? f.roundness;
|
|
1703
1703
|
this.roundness = Math.min(
|
|
1704
1704
|
t,
|
|
1705
1705
|
this.arrowOffset,
|
|
1706
1706
|
this.cycleSquareSide / 2
|
|
1707
|
-
), this.detourDirection = (e == null ? void 0 : e.detourDirection) ??
|
|
1708
|
-
color: (e == null ? void 0 : e.color) ??
|
|
1709
|
-
width: (e == null ? void 0 : e.width) ??
|
|
1707
|
+
), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? f.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? f.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? f.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? f.hasTargetArrow, this.pathShape = new z({
|
|
1708
|
+
color: (e == null ? void 0 : e.color) ?? f.color,
|
|
1709
|
+
width: (e == null ? void 0 : e.width) ?? f.width,
|
|
1710
1710
|
arrowRenderer: F((e == null ? void 0 : e.arrowRenderer) ?? {}),
|
|
1711
1711
|
arrowLength: this.arrowLength,
|
|
1712
1712
|
hasSourceArrow: this.hasSourceArrow,
|
|
@@ -1720,23 +1720,23 @@ class wt {
|
|
|
1720
1720
|
this.pathShape.render(e);
|
|
1721
1721
|
}
|
|
1722
1722
|
}
|
|
1723
|
-
class
|
|
1723
|
+
class yt {
|
|
1724
1724
|
constructor(e) {
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1725
|
+
o(this, "svg");
|
|
1726
|
+
o(this, "group");
|
|
1727
|
+
o(this, "line");
|
|
1728
|
+
o(this, "sourceArrow");
|
|
1729
|
+
o(this, "targetArrow");
|
|
1730
|
+
o(this, "onAfterRender");
|
|
1731
|
+
o(this, "arrowLength");
|
|
1732
|
+
o(this, "arrowOffset");
|
|
1733
|
+
o(this, "roundness");
|
|
1734
|
+
o(this, "cycleSquareSide");
|
|
1735
|
+
o(this, "detourDistance");
|
|
1736
|
+
o(this, "hasSourceArrow");
|
|
1737
|
+
o(this, "hasTargetArrow");
|
|
1738
|
+
o(this, "pathShape");
|
|
1739
|
+
o(this, "createCyclePath", (e) => new Z({
|
|
1740
1740
|
sourceDirection: e,
|
|
1741
1741
|
arrowLength: this.arrowLength,
|
|
1742
1742
|
side: this.cycleSquareSide,
|
|
@@ -1745,11 +1745,11 @@ class ft {
|
|
|
1745
1745
|
hasSourceArrow: this.hasSourceArrow,
|
|
1746
1746
|
hasTargetArrow: this.hasTargetArrow
|
|
1747
1747
|
}));
|
|
1748
|
-
|
|
1748
|
+
o(this, "createDetourPath", (e, t, s, i, n) => new dt({
|
|
1749
1749
|
to: s,
|
|
1750
1750
|
sourceDirection: e,
|
|
1751
1751
|
targetDirection: t,
|
|
1752
|
-
flipX:
|
|
1752
|
+
flipX: i,
|
|
1753
1753
|
flipY: n,
|
|
1754
1754
|
arrowLength: this.arrowLength,
|
|
1755
1755
|
arrowOffset: this.arrowOffset,
|
|
@@ -1758,7 +1758,7 @@ class ft {
|
|
|
1758
1758
|
hasSourceArrow: this.hasSourceArrow,
|
|
1759
1759
|
hasTargetArrow: this.hasTargetArrow
|
|
1760
1760
|
}));
|
|
1761
|
-
|
|
1761
|
+
o(this, "createLinePath", (e, t, s, i, n) => new it({
|
|
1762
1762
|
to: s,
|
|
1763
1763
|
sourceDirection: e,
|
|
1764
1764
|
targetDirection: t,
|
|
@@ -1769,15 +1769,15 @@ class ft {
|
|
|
1769
1769
|
hasSourceArrow: this.hasSourceArrow,
|
|
1770
1770
|
hasTargetArrow: this.hasTargetArrow
|
|
1771
1771
|
}));
|
|
1772
|
-
this.arrowLength = (e == null ? void 0 : e.arrowLength) ??
|
|
1773
|
-
const t = (e == null ? void 0 : e.roundness) ??
|
|
1772
|
+
this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? f.arrowLength, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? f.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? f.cycleSquareSide;
|
|
1773
|
+
const t = (e == null ? void 0 : e.roundness) ?? f.roundness;
|
|
1774
1774
|
this.roundness = Math.min(
|
|
1775
1775
|
t,
|
|
1776
1776
|
this.arrowOffset,
|
|
1777
1777
|
this.cycleSquareSide / 2
|
|
1778
|
-
), this.detourDistance = (e == null ? void 0 : e.detourDistance) ??
|
|
1779
|
-
color: (e == null ? void 0 : e.color) ??
|
|
1780
|
-
width: (e == null ? void 0 : e.width) ??
|
|
1778
|
+
), this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? f.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? f.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? f.hasTargetArrow, this.pathShape = new z({
|
|
1779
|
+
color: (e == null ? void 0 : e.color) ?? f.color,
|
|
1780
|
+
width: (e == null ? void 0 : e.width) ?? f.width,
|
|
1781
1781
|
arrowRenderer: F((e == null ? void 0 : e.arrowRenderer) ?? {}),
|
|
1782
1782
|
arrowLength: this.arrowLength,
|
|
1783
1783
|
hasSourceArrow: this.hasSourceArrow,
|
|
@@ -1793,28 +1793,28 @@ class ft {
|
|
|
1793
1793
|
}
|
|
1794
1794
|
class De {
|
|
1795
1795
|
constructor(e) {
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
[this.afterRenderEmitter, this.onAfterRender] = x(), this.color = (e == null ? void 0 : e.color) ??
|
|
1796
|
+
o(this, "svg");
|
|
1797
|
+
o(this, "group", Te());
|
|
1798
|
+
o(this, "line");
|
|
1799
|
+
o(this, "sourceArrow", null);
|
|
1800
|
+
o(this, "targetArrow", null);
|
|
1801
|
+
o(this, "color");
|
|
1802
|
+
o(this, "width");
|
|
1803
|
+
o(this, "arrowLength");
|
|
1804
|
+
o(this, "sourceOffset");
|
|
1805
|
+
o(this, "targetOffset");
|
|
1806
|
+
o(this, "onAfterRender");
|
|
1807
|
+
o(this, "afterRenderEmitter");
|
|
1808
|
+
o(this, "arrowRenderer");
|
|
1809
|
+
[this.afterRenderEmitter, this.onAfterRender] = x(), this.color = (e == null ? void 0 : e.color) ?? f.color, this.width = (e == null ? void 0 : e.width) ?? f.width, this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? f.arrowLength, this.arrowRenderer = F((e == null ? void 0 : e.arrowRenderer) ?? {}), this.sourceOffset = (e == null ? void 0 : e.sourceOffset) ?? f.preOffset, this.targetOffset = (e == null ? void 0 : e.targetOffset) ?? f.preOffset, this.svg = Pe(this.color), this.svg.appendChild(this.group), this.line = Ne(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));
|
|
1810
1810
|
}
|
|
1811
1811
|
render(e) {
|
|
1812
|
-
const { x: t, y: s, width:
|
|
1812
|
+
const { x: t, y: s, width: i, height: n, flipX: a, flipY: h } = be(
|
|
1813
1813
|
e.from,
|
|
1814
1814
|
e.to
|
|
1815
1815
|
);
|
|
1816
|
-
|
|
1817
|
-
const d = { x:
|
|
1816
|
+
Ce(this.svg, { x: t, y: s, width: i, height: n }), this.group.style.transform = `scale(${a}, ${h})`;
|
|
1817
|
+
const d = { x: i, y: n }, c = new at({
|
|
1818
1818
|
to: d,
|
|
1819
1819
|
sourceOffset: this.sourceOffset,
|
|
1820
1820
|
targetOffset: this.targetOffset,
|
|
@@ -1833,26 +1833,26 @@ class De {
|
|
|
1833
1833
|
y: d.y / u
|
|
1834
1834
|
};
|
|
1835
1835
|
if (this.sourceArrow) {
|
|
1836
|
-
const
|
|
1836
|
+
const y = {
|
|
1837
1837
|
x: w.x * this.sourceOffset,
|
|
1838
1838
|
y: w.y * this.sourceOffset
|
|
1839
1839
|
};
|
|
1840
1840
|
g = this.arrowRenderer({
|
|
1841
1841
|
direction: w,
|
|
1842
|
-
shift:
|
|
1842
|
+
shift: y,
|
|
1843
1843
|
arrowLength: this.arrowLength
|
|
1844
1844
|
}), this.sourceArrow.setAttribute("d", g);
|
|
1845
1845
|
}
|
|
1846
1846
|
if (this.targetArrow) {
|
|
1847
|
-
const
|
|
1847
|
+
const y = {
|
|
1848
1848
|
x: w.x * this.targetOffset,
|
|
1849
1849
|
y: w.y * this.targetOffset
|
|
1850
1850
|
};
|
|
1851
1851
|
l = this.arrowRenderer({
|
|
1852
1852
|
direction: { x: -w.x, y: -w.y },
|
|
1853
1853
|
shift: {
|
|
1854
|
-
x: d.x -
|
|
1855
|
-
y: d.y -
|
|
1854
|
+
x: d.x - y.x,
|
|
1855
|
+
y: d.y - y.y
|
|
1856
1856
|
},
|
|
1857
1857
|
arrowLength: this.arrowLength
|
|
1858
1858
|
}), this.targetArrow.setAttribute("d", l);
|
|
@@ -1865,7 +1865,7 @@ class De {
|
|
|
1865
1865
|
});
|
|
1866
1866
|
}
|
|
1867
1867
|
}
|
|
1868
|
-
const
|
|
1868
|
+
const ft = () => {
|
|
1869
1869
|
const r = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
|
1870
1870
|
return r.style.pointerEvents = "auto", r.style.cursor = "pointer", r;
|
|
1871
1871
|
}, mt = (r) => {
|
|
@@ -1882,40 +1882,40 @@ class vt extends Error {
|
|
|
1882
1882
|
}
|
|
1883
1883
|
class Me {
|
|
1884
1884
|
constructor(e, t) {
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1885
|
+
o(this, "svg");
|
|
1886
|
+
o(this, "group");
|
|
1887
|
+
o(this, "line");
|
|
1888
|
+
o(this, "sourceArrow");
|
|
1889
|
+
o(this, "targetArrow");
|
|
1890
|
+
o(this, "handle", ft());
|
|
1891
|
+
o(this, "onAfterRender");
|
|
1892
|
+
o(this, "interactiveLine");
|
|
1893
|
+
o(this, "interactiveSourceArrow", null);
|
|
1894
|
+
o(this, "interactiveTargetArrow", null);
|
|
1895
1895
|
if (this.baseEdge = e, e instanceof Me)
|
|
1896
1896
|
throw new vt(
|
|
1897
1897
|
"interactive edge can be configured only once"
|
|
1898
1898
|
);
|
|
1899
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;
|
|
1900
|
-
const s = (t == null ? void 0 : t.distance) ??
|
|
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((
|
|
1902
|
-
this.interactiveLine.setAttribute("d",
|
|
1900
|
+
const s = (t == null ? void 0 : t.distance) ?? f.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((i) => {
|
|
1902
|
+
this.interactiveLine.setAttribute("d", i.edgePath.path), this.interactiveSourceArrow && this.interactiveSourceArrow.setAttribute("d", i.sourceArrowPath), this.interactiveTargetArrow && this.interactiveTargetArrow.setAttribute("d", i.targetArrowPath);
|
|
1903
1903
|
});
|
|
1904
1904
|
}
|
|
1905
1905
|
render(e) {
|
|
1906
1906
|
this.baseEdge.render(e);
|
|
1907
1907
|
}
|
|
1908
1908
|
}
|
|
1909
|
-
class
|
|
1909
|
+
class dr {
|
|
1910
1910
|
constructor(e, t) {
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1911
|
+
o(this, "group");
|
|
1912
|
+
o(this, "line");
|
|
1913
|
+
o(this, "sourceArrow");
|
|
1914
|
+
o(this, "targetArrow");
|
|
1915
|
+
o(this, "onAfterRender");
|
|
1916
|
+
o(this, "svg");
|
|
1917
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
|
|
1918
|
+
const i = s.edgePath.midpoint, n = `translate(${i.x}px, ${i.y}px)`;
|
|
1919
1919
|
this.midpointElement.style.setProperty("transform", n);
|
|
1920
1920
|
});
|
|
1921
1921
|
}
|
|
@@ -1925,19 +1925,19 @@ class sr {
|
|
|
1925
1925
|
}
|
|
1926
1926
|
class Le {
|
|
1927
1927
|
constructor(e) {
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1928
|
+
o(this, "onAfterNodeAdded");
|
|
1929
|
+
o(this, "onAfterNodeUpdated");
|
|
1930
|
+
o(this, "onAfterNodePriorityUpdated");
|
|
1931
|
+
o(this, "onBeforeNodeRemoved");
|
|
1932
|
+
o(this, "onAfterPortMarked");
|
|
1933
|
+
o(this, "onAfterPortUpdated");
|
|
1934
|
+
o(this, "onBeforePortUnmarked");
|
|
1935
|
+
o(this, "onAfterEdgeAdded");
|
|
1936
|
+
o(this, "onAfterEdgeShapeUpdated");
|
|
1937
|
+
o(this, "onAfterEdgeUpdated");
|
|
1938
|
+
o(this, "onAfterEdgePriorityUpdated");
|
|
1939
|
+
o(this, "onBeforeEdgeRemoved");
|
|
1940
|
+
o(this, "onBeforeClear");
|
|
1941
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;
|
|
1942
1942
|
}
|
|
1943
1943
|
hasNode(e) {
|
|
@@ -2021,9 +2021,9 @@ class Le {
|
|
|
2021
2021
|
}
|
|
2022
2022
|
class Re {
|
|
2023
2023
|
constructor(e) {
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2024
|
+
o(this, "onBeforeUpdated");
|
|
2025
|
+
o(this, "onAfterUpdated");
|
|
2026
|
+
o(this, "onAfterResize");
|
|
2027
2027
|
this.viewportStore = e, this.onBeforeUpdated = this.viewportStore.onBeforeUpdated, this.onAfterUpdated = this.viewportStore.onAfterUpdated, this.onAfterResize = this.viewportStore.onAfterResize;
|
|
2028
2028
|
}
|
|
2029
2029
|
getViewportMatrix() {
|
|
@@ -2043,7 +2043,7 @@ class Re {
|
|
|
2043
2043
|
}
|
|
2044
2044
|
}
|
|
2045
2045
|
const Ve = (r, e) => {
|
|
2046
|
-
const t = new Ae(), s = new Le(t),
|
|
2046
|
+
const t = new Ae(), s = new Le(t), i = new Re(e), n = new me(t, e, r), a = {
|
|
2047
2047
|
nodes: {
|
|
2048
2048
|
centerFn: Se,
|
|
2049
2049
|
priorityFn: () => 0
|
|
@@ -2058,29 +2058,29 @@ const Ve = (r, e) => {
|
|
|
2058
2058
|
};
|
|
2059
2059
|
return new ve(
|
|
2060
2060
|
s,
|
|
2061
|
-
|
|
2061
|
+
i,
|
|
2062
2062
|
t,
|
|
2063
2063
|
e,
|
|
2064
2064
|
n,
|
|
2065
2065
|
a
|
|
2066
2066
|
);
|
|
2067
2067
|
};
|
|
2068
|
-
class
|
|
2069
|
-
constructor(e, t, s,
|
|
2070
|
-
|
|
2068
|
+
class k {
|
|
2069
|
+
constructor(e, t, s, i) {
|
|
2070
|
+
o(this, "onAfterPortMarked", (e) => {
|
|
2071
2071
|
const t = this.canvas.graph.getPort(e);
|
|
2072
2072
|
this.canvas.graph.findPortIdsByElement(t.element).length === 1 && this.hookPortEvents(t.element);
|
|
2073
2073
|
});
|
|
2074
|
-
|
|
2074
|
+
o(this, "onBeforePortUnmarked", (e) => {
|
|
2075
2075
|
const t = this.canvas.graph.getPort(e);
|
|
2076
2076
|
this.canvas.graph.findPortIdsByElement(t.element).length === 1 && this.unhookPortEvents(t.element);
|
|
2077
2077
|
});
|
|
2078
|
-
|
|
2078
|
+
o(this, "onPortMouseDown", (e) => {
|
|
2079
2079
|
const t = e;
|
|
2080
2080
|
if (!this.params.mouseDownEventVerifier(t))
|
|
2081
2081
|
return;
|
|
2082
|
-
const s = e.currentTarget,
|
|
2083
|
-
this.params.onPortPointerDown(
|
|
2082
|
+
const s = e.currentTarget, i = this.canvas.graph.findPortIdsByElement(s)[0];
|
|
2083
|
+
this.params.onPortPointerDown(i, {
|
|
2084
2084
|
x: t.clientX,
|
|
2085
2085
|
y: t.clientY
|
|
2086
2086
|
}) && (e.stopPropagation(), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
|
|
@@ -2089,7 +2089,7 @@ class z {
|
|
|
2089
2089
|
passive: !0
|
|
2090
2090
|
}));
|
|
2091
2091
|
});
|
|
2092
|
-
|
|
2092
|
+
o(this, "onWindowMouseMove", (e) => {
|
|
2093
2093
|
if (!L(
|
|
2094
2094
|
this.window,
|
|
2095
2095
|
this.element,
|
|
@@ -2101,14 +2101,14 @@ class z {
|
|
|
2101
2101
|
}
|
|
2102
2102
|
this.params.onPointerMove({ x: e.clientX, y: e.clientY });
|
|
2103
2103
|
});
|
|
2104
|
-
|
|
2104
|
+
o(this, "onWindowMouseUp", (e) => {
|
|
2105
2105
|
this.params.mouseUpEventVerifier(e) && (this.params.onPointerUp({ x: e.clientX, y: e.clientY }), this.stopMouseDrag());
|
|
2106
2106
|
});
|
|
2107
|
-
|
|
2107
|
+
o(this, "onPortTouchStart", (e) => {
|
|
2108
2108
|
const t = e;
|
|
2109
2109
|
if (t.touches.length !== 1)
|
|
2110
2110
|
return;
|
|
2111
|
-
const s = t.touches[0],
|
|
2111
|
+
const s = t.touches[0], i = e.currentTarget, n = this.canvas.graph.findPortIdsByElement(i)[0];
|
|
2112
2112
|
this.params.onPortPointerDown(n, {
|
|
2113
2113
|
x: s.clientX,
|
|
2114
2114
|
y: s.clientY
|
|
@@ -2120,7 +2120,7 @@ class z {
|
|
|
2120
2120
|
passive: !0
|
|
2121
2121
|
}));
|
|
2122
2122
|
});
|
|
2123
|
-
|
|
2123
|
+
o(this, "onWindowTouchMove", (e) => {
|
|
2124
2124
|
const t = e.touches[0];
|
|
2125
2125
|
if (!L(
|
|
2126
2126
|
this.window,
|
|
@@ -2133,23 +2133,23 @@ class z {
|
|
|
2133
2133
|
}
|
|
2134
2134
|
this.params.onPointerMove({ x: t.clientX, y: t.clientY });
|
|
2135
2135
|
});
|
|
2136
|
-
|
|
2136
|
+
o(this, "onWindowTouchFinish", (e) => {
|
|
2137
2137
|
const t = e.changedTouches[0];
|
|
2138
2138
|
this.params.onPointerUp({ x: t.clientX, y: t.clientY }), this.stopTouchDrag();
|
|
2139
2139
|
});
|
|
2140
|
-
|
|
2140
|
+
o(this, "onBeforeClear", () => {
|
|
2141
2141
|
this.canvas.graph.getAllPortIds().forEach((e) => {
|
|
2142
2142
|
const t = this.canvas.graph.getPort(e);
|
|
2143
2143
|
this.unhookPortEvents(t.element);
|
|
2144
2144
|
});
|
|
2145
2145
|
});
|
|
2146
|
-
|
|
2146
|
+
o(this, "onBeforeDestroy", () => {
|
|
2147
2147
|
this.params.onStopDrag(), this.removeWindowMouseListeners(), this.removeWindowTouchListeners();
|
|
2148
2148
|
});
|
|
2149
|
-
this.canvas = e, this.element = t, this.window = s, this.params =
|
|
2149
|
+
this.canvas = e, this.element = t, this.window = s, this.params = i, 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);
|
|
2150
2150
|
}
|
|
2151
|
-
static configure(e, t, s,
|
|
2152
|
-
new
|
|
2151
|
+
static configure(e, t, s, i) {
|
|
2152
|
+
new k(e, t, s, i);
|
|
2153
2153
|
}
|
|
2154
2154
|
hookPortEvents(e) {
|
|
2155
2155
|
e.addEventListener("mousedown", this.onPortMouseDown, {
|
|
@@ -2174,12 +2174,39 @@ class z {
|
|
|
2174
2174
|
this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
|
|
2175
2175
|
}
|
|
2176
2176
|
}
|
|
2177
|
-
class
|
|
2178
|
-
constructor(e, t, s
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2177
|
+
class At {
|
|
2178
|
+
constructor(e, t, s) {
|
|
2179
|
+
this.canvas = e, this.layoutAlgorithm = t, this.params = s;
|
|
2180
|
+
}
|
|
2181
|
+
apply() {
|
|
2182
|
+
this.layoutAlgorithm.calculateCoordinates({
|
|
2183
|
+
graph: this.canvas.graph,
|
|
2184
|
+
viewport: this.canvas.viewport
|
|
2185
|
+
}).forEach((t, s) => {
|
|
2186
|
+
this.params.staticNodeResolver(s) || this.canvas.updateNode(s, t);
|
|
2187
|
+
});
|
|
2188
|
+
}
|
|
2189
|
+
}
|
|
2190
|
+
class Et {
|
|
2191
|
+
constructor(e, t, s) {
|
|
2192
|
+
this.canvas = e, this.layoutAlgorithm = t, this.params = s;
|
|
2193
|
+
}
|
|
2194
|
+
apply(e) {
|
|
2195
|
+
this.layoutAlgorithm.calculateNextCoordinates({
|
|
2196
|
+
graph: this.canvas.graph,
|
|
2197
|
+
viewport: this.canvas.viewport,
|
|
2198
|
+
dt: e
|
|
2199
|
+
}).forEach((s, i) => {
|
|
2200
|
+
this.params.staticNodeResolver(i) || this.canvas.updateNode(i, s);
|
|
2201
|
+
});
|
|
2202
|
+
}
|
|
2203
|
+
}
|
|
2204
|
+
class q {
|
|
2205
|
+
constructor(e, t, s, i) {
|
|
2206
|
+
o(this, "grabbedNode", null);
|
|
2207
|
+
o(this, "maxNodePriority", 0);
|
|
2208
|
+
o(this, "graph");
|
|
2209
|
+
o(this, "onAfterNodeAdded", (e) => {
|
|
2183
2210
|
this.updateMaxNodePriority(e);
|
|
2184
2211
|
const { element: t } = this.graph.getNode(e);
|
|
2185
2212
|
t.addEventListener("mousedown", this.onMouseDown, {
|
|
@@ -2188,50 +2215,50 @@ class Z {
|
|
|
2188
2215
|
passive: !0
|
|
2189
2216
|
});
|
|
2190
2217
|
});
|
|
2191
|
-
|
|
2218
|
+
o(this, "onAfterNodeUpdated", (e) => {
|
|
2192
2219
|
this.updateMaxNodePriority(e);
|
|
2193
2220
|
});
|
|
2194
|
-
|
|
2221
|
+
o(this, "onBeforeNodeRemoved", (e) => {
|
|
2195
2222
|
const { element: t } = this.graph.getNode(e);
|
|
2196
2223
|
t.removeEventListener("mousedown", this.onMouseDown), t.removeEventListener("touchstart", this.onTouchStart);
|
|
2197
2224
|
});
|
|
2198
|
-
|
|
2225
|
+
o(this, "onBeforeDestroy", () => {
|
|
2199
2226
|
this.removeMouseDragListeners(), this.removeTouchDragListeners();
|
|
2200
2227
|
});
|
|
2201
|
-
|
|
2228
|
+
o(this, "onBeforeClear", () => {
|
|
2202
2229
|
this.canvas.graph.getAllNodeIds().forEach((e) => {
|
|
2203
2230
|
const { element: t } = this.canvas.graph.getNode(e);
|
|
2204
2231
|
t.removeEventListener("mousedown", this.onMouseDown), t.removeEventListener("touchstart", this.onTouchStart);
|
|
2205
2232
|
}), this.maxNodePriority = 0;
|
|
2206
2233
|
});
|
|
2207
|
-
|
|
2234
|
+
o(this, "onMouseDown", (e) => {
|
|
2208
2235
|
const t = e;
|
|
2209
2236
|
if (!this.params.mouseDownEventVerifier(t))
|
|
2210
2237
|
return;
|
|
2211
|
-
const s = e.currentTarget,
|
|
2212
|
-
if (!this.params.nodeDragVerifier(
|
|
2238
|
+
const s = e.currentTarget, i = this.graph.findNodeIdByElement(s), n = this.graph.getNode(i);
|
|
2239
|
+
if (!this.params.nodeDragVerifier(i))
|
|
2213
2240
|
return;
|
|
2214
|
-
this.params.onNodeDragStarted(
|
|
2241
|
+
this.params.onNodeDragStarted(i), e.stopPropagation();
|
|
2215
2242
|
const h = this.calculateContentPoint({
|
|
2216
2243
|
x: t.clientX,
|
|
2217
2244
|
y: t.clientY
|
|
2218
2245
|
});
|
|
2219
2246
|
this.grabbedNode = {
|
|
2220
|
-
nodeId:
|
|
2247
|
+
nodeId: i,
|
|
2221
2248
|
dx: h.x - n.x,
|
|
2222
2249
|
dy: h.y - n.y
|
|
2223
|
-
}, $(this.element, this.params.dragCursor), this.moveNodeOnTop(
|
|
2250
|
+
}, $(this.element, this.params.dragCursor), this.moveNodeOnTop(i), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
|
|
2224
2251
|
passive: !0
|
|
2225
2252
|
}), this.window.addEventListener("mouseup", this.onWindowMouseUp, {
|
|
2226
2253
|
passive: !0
|
|
2227
2254
|
});
|
|
2228
2255
|
});
|
|
2229
|
-
|
|
2256
|
+
o(this, "onTouchStart", (e) => {
|
|
2230
2257
|
const t = e;
|
|
2231
2258
|
if (t.touches.length !== 1)
|
|
2232
2259
|
return;
|
|
2233
2260
|
e.stopPropagation();
|
|
2234
|
-
const s = t.touches[0],
|
|
2261
|
+
const s = t.touches[0], i = e.currentTarget, n = this.canvas.graph.findNodeIdByElement(i), a = this.graph.getNode(n);
|
|
2235
2262
|
if (!this.params.nodeDragVerifier({
|
|
2236
2263
|
nodeId: n,
|
|
2237
2264
|
element: a.element,
|
|
@@ -2255,7 +2282,7 @@ class Z {
|
|
|
2255
2282
|
passive: !0
|
|
2256
2283
|
});
|
|
2257
2284
|
});
|
|
2258
|
-
|
|
2285
|
+
o(this, "onWindowMouseMove", (e) => {
|
|
2259
2286
|
if (!L(
|
|
2260
2287
|
this.window,
|
|
2261
2288
|
this.element,
|
|
@@ -2270,10 +2297,10 @@ class Z {
|
|
|
2270
2297
|
y: e.clientY
|
|
2271
2298
|
});
|
|
2272
2299
|
});
|
|
2273
|
-
|
|
2300
|
+
o(this, "onWindowMouseUp", (e) => {
|
|
2274
2301
|
this.params.mouseUpEventVerifier(e) && this.cancelMouseDrag();
|
|
2275
2302
|
});
|
|
2276
|
-
|
|
2303
|
+
o(this, "onWindowTouchMove", (e) => {
|
|
2277
2304
|
if (e.touches.length !== 1)
|
|
2278
2305
|
return;
|
|
2279
2306
|
const t = e.touches[0];
|
|
@@ -2291,21 +2318,21 @@ class Z {
|
|
|
2291
2318
|
y: t.clientY
|
|
2292
2319
|
});
|
|
2293
2320
|
});
|
|
2294
|
-
|
|
2321
|
+
o(this, "onWindowTouchFinish", () => {
|
|
2295
2322
|
this.cancelTouchDrag();
|
|
2296
2323
|
});
|
|
2297
|
-
this.canvas = e, this.element = t, this.window = s, this.params =
|
|
2324
|
+
this.canvas = e, this.element = t, this.window = s, this.params = i, 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);
|
|
2298
2325
|
}
|
|
2299
|
-
static configure(e, t, s,
|
|
2300
|
-
new
|
|
2326
|
+
static configure(e, t, s, i) {
|
|
2327
|
+
new q(e, t, s, i);
|
|
2301
2328
|
}
|
|
2302
2329
|
moveNode(e, t) {
|
|
2303
2330
|
if (!this.graph.hasNode(e.nodeId))
|
|
2304
2331
|
return;
|
|
2305
|
-
const s = this.calculateContentPoint(t),
|
|
2332
|
+
const s = this.calculateContentPoint(t), i = {
|
|
2306
2333
|
x: s.x - e.dx,
|
|
2307
2334
|
y: s.y - e.dy
|
|
2308
|
-
}, n = this.adjustNodeCoords(
|
|
2335
|
+
}, n = this.adjustNodeCoords(i);
|
|
2309
2336
|
this.canvas.updateNode(e.nodeId, {
|
|
2310
2337
|
x: n.x,
|
|
2311
2338
|
y: n.y
|
|
@@ -2315,8 +2342,8 @@ class Z {
|
|
|
2315
2342
|
if (this.params.moveOnTop) {
|
|
2316
2343
|
if (this.maxNodePriority++, this.params.moveEdgesOnTop) {
|
|
2317
2344
|
const t = this.maxNodePriority;
|
|
2318
|
-
this.maxNodePriority++, this.graph.getNodeAdjacentEdgeIds(e).forEach((
|
|
2319
|
-
this.canvas.updateEdge(
|
|
2345
|
+
this.maxNodePriority++, this.graph.getNodeAdjacentEdgeIds(e).forEach((i) => {
|
|
2346
|
+
this.canvas.updateEdge(i, { priority: t });
|
|
2320
2347
|
});
|
|
2321
2348
|
}
|
|
2322
2349
|
this.canvas.updateNode(e, { priority: this.maxNodePriority });
|
|
@@ -2366,11 +2393,11 @@ class Z {
|
|
|
2366
2393
|
return e;
|
|
2367
2394
|
}
|
|
2368
2395
|
}
|
|
2369
|
-
const
|
|
2396
|
+
const xt = (r, e, t) => ({
|
|
2370
2397
|
scale: r.scale,
|
|
2371
2398
|
x: r.x + r.scale * e,
|
|
2372
2399
|
y: r.y + r.scale * t
|
|
2373
|
-
}),
|
|
2400
|
+
}), St = (r, e, t, s) => ({
|
|
2374
2401
|
scale: r.scale * e,
|
|
2375
2402
|
x: r.scale * (1 - e) * t + r.x,
|
|
2376
2403
|
y: r.scale * (1 - e) * s + r.y
|
|
@@ -2381,35 +2408,35 @@ const At = (r, e, t) => ({
|
|
|
2381
2408
|
const s = e.reduce(
|
|
2382
2409
|
(h, d) => [h[0] + d[0], h[1] + d[1]],
|
|
2383
2410
|
[0, 0]
|
|
2384
|
-
),
|
|
2411
|
+
), i = [s[0] / t, s[1] / t], a = e.map((h) => [h[0] - i[0], h[1] - i[1]]).reduce(
|
|
2385
2412
|
(h, d) => h + Math.sqrt(d[0] * d[0] + d[1] * d[1]),
|
|
2386
2413
|
0
|
|
2387
2414
|
);
|
|
2388
2415
|
return {
|
|
2389
|
-
x:
|
|
2390
|
-
y:
|
|
2416
|
+
x: i[0],
|
|
2417
|
+
y: i[1],
|
|
2391
2418
|
scale: a / t,
|
|
2392
2419
|
touchesCnt: t,
|
|
2393
2420
|
touches: e
|
|
2394
2421
|
};
|
|
2395
2422
|
};
|
|
2396
2423
|
class H {
|
|
2397
|
-
constructor(e, t, s,
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2424
|
+
constructor(e, t, s, i) {
|
|
2425
|
+
o(this, "viewport");
|
|
2426
|
+
o(this, "prevTouches", null);
|
|
2427
|
+
o(this, "wheelFinishTimer", null);
|
|
2428
|
+
o(this, "transformInProgress", !1);
|
|
2429
|
+
o(this, "onBeforeDestroy", () => {
|
|
2403
2430
|
this.removeMouseDragListeners(), this.removeTouchDragListeners();
|
|
2404
2431
|
});
|
|
2405
|
-
|
|
2432
|
+
o(this, "onMouseDown", (e) => {
|
|
2406
2433
|
this.element === null || !this.params.mouseDownEventVerifier(e) || ($(this.element, this.params.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
|
|
2407
2434
|
passive: !0
|
|
2408
2435
|
}), this.window.addEventListener("mouseup", this.onWindowMouseUp, {
|
|
2409
2436
|
passive: !0
|
|
2410
2437
|
}), this.startRegisteredTransform());
|
|
2411
2438
|
});
|
|
2412
|
-
|
|
2439
|
+
o(this, "onWindowMouseMove", (e) => {
|
|
2413
2440
|
const t = L(
|
|
2414
2441
|
this.window,
|
|
2415
2442
|
this.element,
|
|
@@ -2420,21 +2447,21 @@ class H {
|
|
|
2420
2447
|
this.stopMouseDrag();
|
|
2421
2448
|
return;
|
|
2422
2449
|
}
|
|
2423
|
-
const s = -e.movementX,
|
|
2424
|
-
this.moveViewport(s,
|
|
2450
|
+
const s = -e.movementX, i = -e.movementY;
|
|
2451
|
+
this.moveViewport(s, i);
|
|
2425
2452
|
});
|
|
2426
|
-
|
|
2453
|
+
o(this, "onWindowMouseUp", (e) => {
|
|
2427
2454
|
this.params.mouseUpEventVerifier(e) && this.stopMouseDrag();
|
|
2428
2455
|
});
|
|
2429
|
-
|
|
2456
|
+
o(this, "onWheelScroll", (e) => {
|
|
2430
2457
|
if (!this.params.mouseWheelEventVerifier(e))
|
|
2431
2458
|
return;
|
|
2432
|
-
const { left: t, top: s } = this.element.getBoundingClientRect(),
|
|
2433
|
-
this.wheelFinishTimer === null && this.params.onTransformStarted(), this.scaleViewport(h,
|
|
2459
|
+
const { left: t, top: s } = this.element.getBoundingClientRect(), i = e.clientX - t, n = e.clientY - s, h = 1 / (e.deltaY < 0 ? this.params.wheelSensitivity : 1 / this.params.wheelSensitivity);
|
|
2460
|
+
this.wheelFinishTimer === null && this.params.onTransformStarted(), this.scaleViewport(h, i, n), this.wheelFinishTimer !== null && clearTimeout(this.wheelFinishTimer), this.wheelFinishTimer = setTimeout(() => {
|
|
2434
2461
|
this.transformInProgress || this.params.onTransformFinished(), this.wheelFinishTimer = null;
|
|
2435
2462
|
}, this.params.scaleWheelFinishTimeout);
|
|
2436
2463
|
});
|
|
2437
|
-
|
|
2464
|
+
o(this, "onTouchStart", (e) => {
|
|
2438
2465
|
if (this.prevTouches !== null) {
|
|
2439
2466
|
this.prevTouches = I(e);
|
|
2440
2467
|
return;
|
|
@@ -2447,10 +2474,10 @@ class H {
|
|
|
2447
2474
|
passive: !0
|
|
2448
2475
|
}), this.startRegisteredTransform();
|
|
2449
2476
|
});
|
|
2450
|
-
|
|
2477
|
+
o(this, "onWindowTouchMove", (e) => {
|
|
2451
2478
|
const t = I(e);
|
|
2452
2479
|
if (!t.touches.every(
|
|
2453
|
-
(
|
|
2480
|
+
(i) => L(this.window, this.element, i[0], i[1])
|
|
2454
2481
|
)) {
|
|
2455
2482
|
this.stopTouchDrag();
|
|
2456
2483
|
return;
|
|
@@ -2459,18 +2486,18 @@ class H {
|
|
|
2459
2486
|
-(t.x - this.prevTouches.x),
|
|
2460
2487
|
-(t.y - this.prevTouches.y)
|
|
2461
2488
|
), t.touchesCnt === 2) {
|
|
2462
|
-
const { left:
|
|
2489
|
+
const { left: i, top: n } = this.element.getBoundingClientRect(), a = this.prevTouches.x - i, h = this.prevTouches.y - n, c = 1 / (t.scale / this.prevTouches.scale);
|
|
2463
2490
|
this.scaleViewport(c, a, h);
|
|
2464
2491
|
}
|
|
2465
2492
|
this.prevTouches = t;
|
|
2466
2493
|
});
|
|
2467
|
-
|
|
2494
|
+
o(this, "onWindowTouchFinish", (e) => {
|
|
2468
2495
|
e.touches.length > 0 ? this.prevTouches = I(e) : this.stopTouchDrag();
|
|
2469
2496
|
});
|
|
2470
|
-
|
|
2497
|
+
o(this, "preventWheelScaleListener", (e) => {
|
|
2471
2498
|
e.preventDefault();
|
|
2472
2499
|
});
|
|
2473
|
-
this.canvas = e, this.element = t, this.window = s, this.params =
|
|
2500
|
+
this.canvas = e, this.element = t, this.window = s, this.params = i, this.element.addEventListener("wheel", this.preventWheelScaleListener, {
|
|
2474
2501
|
passive: !1
|
|
2475
2502
|
}), this.viewport = e.viewport, this.handleResize(), this.viewport.onAfterResize.subscribe(() => {
|
|
2476
2503
|
this.handleResize();
|
|
@@ -2482,21 +2509,21 @@ class H {
|
|
|
2482
2509
|
passive: !0
|
|
2483
2510
|
}), e.onBeforeDestroy.subscribe(this.onBeforeDestroy);
|
|
2484
2511
|
}
|
|
2485
|
-
static configure(e, t, s,
|
|
2486
|
-
new H(e, t, s,
|
|
2512
|
+
static configure(e, t, s, i) {
|
|
2513
|
+
new H(e, t, s, i);
|
|
2487
2514
|
}
|
|
2488
2515
|
moveViewport(e, t) {
|
|
2489
|
-
const s = this.viewport.getViewportMatrix(),
|
|
2516
|
+
const s = this.viewport.getViewportMatrix(), i = xt(s, e, t), { width: n, height: a } = this.viewport.getDimensions(), h = this.params.transformPreprocessor({
|
|
2490
2517
|
prevTransform: s,
|
|
2491
|
-
nextTransform:
|
|
2518
|
+
nextTransform: i,
|
|
2492
2519
|
canvasWidth: n,
|
|
2493
2520
|
canvasHeight: a
|
|
2494
2521
|
});
|
|
2495
2522
|
this.performTransform(h);
|
|
2496
2523
|
}
|
|
2497
2524
|
scaleViewport(e, t, s) {
|
|
2498
|
-
const
|
|
2499
|
-
prevTransform:
|
|
2525
|
+
const i = this.canvas.viewport.getViewportMatrix(), n = St(i, e, t, s), { width: a, height: h } = this.viewport.getDimensions(), d = this.params.transformPreprocessor({
|
|
2526
|
+
prevTransform: i,
|
|
2500
2527
|
nextTransform: n,
|
|
2501
2528
|
canvasWidth: a,
|
|
2502
2529
|
canvasHeight: h
|
|
@@ -2525,28 +2552,28 @@ class H {
|
|
|
2525
2552
|
this.transformInProgress = !1, this.params.onTransformFinished();
|
|
2526
2553
|
}
|
|
2527
2554
|
handleResize() {
|
|
2528
|
-
const e = this.viewport.getViewportMatrix(), { width: t, height: s } = this.viewport.getDimensions(),
|
|
2555
|
+
const e = this.viewport.getViewportMatrix(), { width: t, height: s } = this.viewport.getDimensions(), i = this.params.transformPreprocessor({
|
|
2529
2556
|
prevTransform: e,
|
|
2530
2557
|
nextTransform: e,
|
|
2531
2558
|
canvasWidth: t,
|
|
2532
2559
|
canvasHeight: s
|
|
2533
2560
|
});
|
|
2534
|
-
this.params.onResizeTransformStarted(), this.canvas.patchViewportMatrix(
|
|
2561
|
+
this.params.onResizeTransformStarted(), this.canvas.patchViewportMatrix(i), this.params.onResizeTransformFinished();
|
|
2535
2562
|
}
|
|
2536
2563
|
}
|
|
2537
2564
|
class J {
|
|
2538
|
-
constructor(e, t, s,
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2565
|
+
constructor(e, t, s, i, n, a) {
|
|
2566
|
+
o(this, "nodeHorizontal");
|
|
2567
|
+
o(this, "nodeVertical");
|
|
2568
|
+
o(this, "viewport");
|
|
2569
|
+
o(this, "currentScale");
|
|
2570
|
+
o(this, "loadedArea", {
|
|
2544
2571
|
xFrom: 1 / 0,
|
|
2545
2572
|
xTo: 1 / 0,
|
|
2546
2573
|
yFrom: 1 / 0,
|
|
2547
2574
|
yTo: 1 / 0
|
|
2548
2575
|
});
|
|
2549
|
-
|
|
2576
|
+
o(this, "updateLoadedArea", (e) => {
|
|
2550
2577
|
this.loadedArea = {
|
|
2551
2578
|
xFrom: e.x,
|
|
2552
2579
|
xTo: e.x + e.width,
|
|
@@ -2554,31 +2581,31 @@ class J {
|
|
|
2554
2581
|
yTo: e.y + e.height
|
|
2555
2582
|
};
|
|
2556
2583
|
});
|
|
2557
|
-
|
|
2584
|
+
o(this, "onAfterViewportUpdated", () => {
|
|
2558
2585
|
this.userTransformInProgress || this.loadAreaAroundViewport();
|
|
2559
2586
|
});
|
|
2560
|
-
|
|
2587
|
+
o(this, "userTransformInProgress", !1);
|
|
2561
2588
|
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(() => {
|
|
2562
2589
|
this.scheduleLoadAreaAroundViewport();
|
|
2563
2590
|
});
|
|
2564
2591
|
const h = {
|
|
2565
|
-
...
|
|
2592
|
+
...i,
|
|
2566
2593
|
onResizeTransformStarted: () => {
|
|
2567
|
-
this.userTransformInProgress = !0,
|
|
2594
|
+
this.userTransformInProgress = !0, i.onResizeTransformStarted();
|
|
2568
2595
|
},
|
|
2569
2596
|
onResizeTransformFinished: () => {
|
|
2570
|
-
this.userTransformInProgress = !1,
|
|
2597
|
+
this.userTransformInProgress = !1, i.onResizeTransformFinished();
|
|
2571
2598
|
},
|
|
2572
2599
|
onBeforeTransformChange: () => {
|
|
2573
|
-
this.userTransformInProgress = !0,
|
|
2600
|
+
this.userTransformInProgress = !0, i.onBeforeTransformChange();
|
|
2574
2601
|
},
|
|
2575
2602
|
onTransformChange: () => {
|
|
2576
2603
|
this.userTransformInProgress = !1;
|
|
2577
2604
|
const d = this.currentScale;
|
|
2578
|
-
this.currentScale = this.viewport.getViewportMatrix().scale, d !== this.currentScale && this.scheduleEnsureViewportAreaLoaded(),
|
|
2605
|
+
this.currentScale = this.viewport.getViewportMatrix().scale, d !== this.currentScale && this.scheduleEnsureViewportAreaLoaded(), i.onTransformChange();
|
|
2579
2606
|
},
|
|
2580
2607
|
onTransformFinished: () => {
|
|
2581
|
-
this.scheduleLoadAreaAroundViewport(),
|
|
2608
|
+
this.scheduleLoadAreaAroundViewport(), i.onTransformFinished();
|
|
2582
2609
|
}
|
|
2583
2610
|
};
|
|
2584
2611
|
H.configure(
|
|
@@ -2588,12 +2615,12 @@ class J {
|
|
|
2588
2615
|
h
|
|
2589
2616
|
), this.trigger.subscribe(this.updateLoadedArea), this.canvas.viewport.onAfterUpdated.subscribe(this.onAfterViewportUpdated);
|
|
2590
2617
|
}
|
|
2591
|
-
static configure(e, t, s,
|
|
2618
|
+
static configure(e, t, s, i, n, a) {
|
|
2592
2619
|
new J(
|
|
2593
2620
|
e,
|
|
2594
2621
|
t,
|
|
2595
2622
|
s,
|
|
2596
|
-
|
|
2623
|
+
i,
|
|
2597
2624
|
n,
|
|
2598
2625
|
a
|
|
2599
2626
|
);
|
|
@@ -2605,12 +2632,12 @@ class J {
|
|
|
2605
2632
|
}
|
|
2606
2633
|
scheduleEnsureViewportAreaLoaded() {
|
|
2607
2634
|
setTimeout(() => {
|
|
2608
|
-
const { width: e, height: t } = this.viewport.getDimensions(), { scale: s, x:
|
|
2635
|
+
const { width: e, height: t } = this.viewport.getDimensions(), { scale: s, x: i, y: n } = this.viewport.getViewportMatrix(), a = e * s, h = t * s, d = i - this.nodeHorizontal, c = n - this.nodeVertical, g = i + a + this.nodeHorizontal, l = n + h + this.nodeVertical;
|
|
2609
2636
|
this.loadedArea.xFrom < d && this.loadedArea.xTo > g && this.loadedArea.yFrom < c && this.loadedArea.yTo > l || this.loadAreaAroundViewport();
|
|
2610
2637
|
});
|
|
2611
2638
|
}
|
|
2612
2639
|
loadAreaAroundViewport() {
|
|
2613
|
-
const { width: e, height: t } = this.viewport.getDimensions(), { scale: s, x:
|
|
2640
|
+
const { width: e, height: t } = this.viewport.getDimensions(), { scale: s, x: i, y: n } = this.viewport.getViewportMatrix(), a = e * s, h = t * s, d = i - a - this.nodeHorizontal, c = n - h - this.nodeVertical, g = 3 * a + 2 * this.nodeHorizontal, l = 3 * h + 2 * this.nodeVertical;
|
|
2614
2641
|
this.trigger.emit({
|
|
2615
2642
|
x: d,
|
|
2616
2643
|
y: c,
|
|
@@ -2619,13 +2646,13 @@ class J {
|
|
|
2619
2646
|
});
|
|
2620
2647
|
}
|
|
2621
2648
|
}
|
|
2622
|
-
const
|
|
2649
|
+
const bt = () => {
|
|
2623
2650
|
const r = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
2624
2651
|
return r.style.position = "absolute", r.style.inset = "0", r;
|
|
2625
|
-
},
|
|
2652
|
+
}, Pt = () => {
|
|
2626
2653
|
const r = document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
|
2627
2654
|
return r.setAttribute("fill", "url(#pattern)"), r;
|
|
2628
|
-
},
|
|
2655
|
+
}, Nt = () => {
|
|
2629
2656
|
const r = document.createElementNS(
|
|
2630
2657
|
"http://www.w3.org/2000/svg",
|
|
2631
2658
|
"pattern"
|
|
@@ -2634,23 +2661,23 @@ const xt = () => {
|
|
|
2634
2661
|
};
|
|
2635
2662
|
class _ {
|
|
2636
2663
|
constructor(e, t, s) {
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
const e = this.canvas.viewport.getContentMatrix(), t = e.x - this.halfTileWidth * e.scale, s = e.y - this.halfTileHeight * e.scale,
|
|
2649
|
-
this.pattern.setAttribute("patternTransform",
|
|
2664
|
+
o(this, "svg", bt());
|
|
2665
|
+
o(this, "patternRenderingRectangle", Pt());
|
|
2666
|
+
o(this, "pattern", Nt());
|
|
2667
|
+
o(this, "patternContent");
|
|
2668
|
+
o(this, "tileWidth");
|
|
2669
|
+
o(this, "tileHeight");
|
|
2670
|
+
o(this, "halfTileWidth");
|
|
2671
|
+
o(this, "halfTileHeight");
|
|
2672
|
+
o(this, "maxViewportScale");
|
|
2673
|
+
o(this, "visible", !1);
|
|
2674
|
+
o(this, "onAfterTransformUpdated", () => {
|
|
2675
|
+
const e = this.canvas.viewport.getContentMatrix(), t = e.x - this.halfTileWidth * e.scale, s = e.y - this.halfTileHeight * e.scale, i = `matrix(${e.scale}, 0, 0, ${e.scale}, ${t}, ${s})`;
|
|
2676
|
+
this.pattern.setAttribute("patternTransform", i), this.updateVisibility();
|
|
2650
2677
|
});
|
|
2651
2678
|
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;
|
|
2652
|
-
const
|
|
2653
|
-
this.patternContent.setAttribute("transform",
|
|
2679
|
+
const i = `translate(${this.halfTileWidth}, ${this.halfTileHeight})`;
|
|
2680
|
+
this.patternContent.setAttribute("transform", i), this.pattern.appendChild(this.patternContent);
|
|
2654
2681
|
const n = document.createElementNS("http://www.w3.org/2000/svg", "defs");
|
|
2655
2682
|
n.appendChild(this.pattern), this.svg.appendChild(n), this.svg.appendChild(this.patternRenderingRectangle), this.updateDimensions(), this.canvas.viewport.onAfterResize.subscribe(() => {
|
|
2656
2683
|
this.updateDimensions();
|
|
@@ -2666,22 +2693,22 @@ class _ {
|
|
|
2666
2693
|
updateDimensions() {
|
|
2667
2694
|
const { width: e, height: t } = this.canvas.viewport.getDimensions();
|
|
2668
2695
|
this.svg.setAttribute("width", `${e}`), this.svg.setAttribute("height", `${t}`), this.patternRenderingRectangle.setAttribute("width", `${e}`), this.patternRenderingRectangle.setAttribute("height", `${t}`);
|
|
2669
|
-
const s = this.tileWidth / e,
|
|
2670
|
-
this.pattern.setAttribute("width", `${s}`), this.pattern.setAttribute("height", `${
|
|
2696
|
+
const s = this.tileWidth / e, i = this.tileHeight / t;
|
|
2697
|
+
this.pattern.setAttribute("width", `${s}`), this.pattern.setAttribute("height", `${i}`);
|
|
2671
2698
|
}
|
|
2672
2699
|
}
|
|
2673
2700
|
class ee {
|
|
2674
|
-
constructor(e, t, s,
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2701
|
+
constructor(e, t, s, i, n) {
|
|
2702
|
+
o(this, "overlayCanvas");
|
|
2703
|
+
o(this, "staticPortId", null);
|
|
2704
|
+
o(this, "isTargetDragging", !0);
|
|
2705
|
+
o(this, "onEdgeCreated", (e) => {
|
|
2679
2706
|
this.params.onAfterEdgeCreated(e);
|
|
2680
2707
|
});
|
|
2681
|
-
this.canvas = e, this.overlayLayer = t, this.viewportStore = s, this.window =
|
|
2708
|
+
this.canvas = e, this.overlayLayer = t, this.viewportStore = s, this.window = i, this.params = n, this.overlayCanvas = Ve(
|
|
2682
2709
|
this.overlayLayer,
|
|
2683
2710
|
this.viewportStore
|
|
2684
|
-
),
|
|
2711
|
+
), k.configure(
|
|
2685
2712
|
this.canvas,
|
|
2686
2713
|
this.overlayLayer,
|
|
2687
2714
|
this.window,
|
|
@@ -2704,39 +2731,39 @@ class ee {
|
|
|
2704
2731
|
}
|
|
2705
2732
|
);
|
|
2706
2733
|
}
|
|
2707
|
-
static configure(e, t, s,
|
|
2734
|
+
static configure(e, t, s, i, n) {
|
|
2708
2735
|
new ee(
|
|
2709
2736
|
e,
|
|
2710
2737
|
t,
|
|
2711
2738
|
s,
|
|
2712
|
-
|
|
2739
|
+
i,
|
|
2713
2740
|
n
|
|
2714
2741
|
);
|
|
2715
2742
|
}
|
|
2716
2743
|
grabPort(e, t, s) {
|
|
2717
|
-
const
|
|
2744
|
+
const i = this.canvas.graph.getPort(e);
|
|
2718
2745
|
this.staticPortId = e;
|
|
2719
|
-
const n =
|
|
2746
|
+
const n = i.element.getBoundingClientRect(), a = n.x + n.width / 2, h = n.y + n.height / 2, d = this.overlayLayer.getBoundingClientRect(), c = this.canvas.viewport.createContentCoords({
|
|
2720
2747
|
x: a - d.x,
|
|
2721
2748
|
y: h - d.y
|
|
2722
2749
|
}), g = this.canvas.viewport.createContentCoords({
|
|
2723
2750
|
x: t.x - d.x,
|
|
2724
2751
|
y: t.y - d.y
|
|
2725
2752
|
}), l = {
|
|
2726
|
-
overlayNodeId:
|
|
2753
|
+
overlayNodeId: N.StaticNodeId,
|
|
2727
2754
|
portCoords: c,
|
|
2728
|
-
portDirection:
|
|
2755
|
+
portDirection: i.direction
|
|
2729
2756
|
}, u = {
|
|
2730
|
-
overlayNodeId:
|
|
2757
|
+
overlayNodeId: N.DraggingNodeId,
|
|
2731
2758
|
portCoords: g,
|
|
2732
2759
|
portDirection: this.params.dragPortDirection
|
|
2733
2760
|
};
|
|
2734
2761
|
this.isTargetDragging = s === "direct";
|
|
2735
|
-
const [w,
|
|
2736
|
-
this.overlayCanvas.addNode(U(w)), this.overlayCanvas.addNode(U(
|
|
2762
|
+
const [w, y] = this.isTargetDragging ? [l, u] : [u, l];
|
|
2763
|
+
this.overlayCanvas.addNode(U(w)), this.overlayCanvas.addNode(U(y)), this.overlayCanvas.addEdge({
|
|
2737
2764
|
from: w.overlayNodeId,
|
|
2738
|
-
to:
|
|
2739
|
-
shape: this.params.edgeShapeFactory(
|
|
2765
|
+
to: y.overlayNodeId,
|
|
2766
|
+
shape: this.params.edgeShapeFactory(N.EdgeId)
|
|
2740
2767
|
});
|
|
2741
2768
|
}
|
|
2742
2769
|
resetDragState() {
|
|
@@ -2751,7 +2778,7 @@ class ee {
|
|
|
2751
2778
|
});
|
|
2752
2779
|
return;
|
|
2753
2780
|
}
|
|
2754
|
-
const
|
|
2781
|
+
const i = this.isTargetDragging ? s : t, n = this.isTargetDragging ? t : s, a = { from: i, to: n }, h = this.params.connectionPreprocessor(a);
|
|
2755
2782
|
h !== null ? (this.canvas.graph.onAfterEdgeAdded.subscribe(this.onEdgeCreated), this.canvas.addEdge(h), this.canvas.graph.onAfterEdgeAdded.unsubscribe(this.onEdgeCreated)) : this.params.onEdgeCreationPrevented(a);
|
|
2756
2783
|
}
|
|
2757
2784
|
moveDraggingPort(e) {
|
|
@@ -2759,25 +2786,25 @@ class ee {
|
|
|
2759
2786
|
x: e.x - t.x,
|
|
2760
2787
|
y: e.y - t.y
|
|
2761
2788
|
});
|
|
2762
|
-
this.overlayCanvas.updateNode(
|
|
2789
|
+
this.overlayCanvas.updateNode(N.DraggingNodeId, {
|
|
2763
2790
|
x: s.x,
|
|
2764
2791
|
y: s.y
|
|
2765
2792
|
});
|
|
2766
2793
|
}
|
|
2767
2794
|
}
|
|
2768
2795
|
class te {
|
|
2769
|
-
constructor(e, t, s,
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2796
|
+
constructor(e, t, s, i, n) {
|
|
2797
|
+
o(this, "overlayCanvas");
|
|
2798
|
+
o(this, "staticPortId", null);
|
|
2799
|
+
o(this, "isTargetDragging", !0);
|
|
2800
|
+
o(this, "draggingEdgePayload", null);
|
|
2801
|
+
o(this, "onEdgeReattached", (e) => {
|
|
2775
2802
|
this.params.onAfterEdgeReattached(e);
|
|
2776
2803
|
});
|
|
2777
|
-
this.canvas = e, this.overlayLayer = t, this.viewportStore = s, this.window =
|
|
2804
|
+
this.canvas = e, this.overlayLayer = t, this.viewportStore = s, this.window = i, this.params = n, this.overlayCanvas = Ve(
|
|
2778
2805
|
this.overlayLayer,
|
|
2779
2806
|
this.viewportStore
|
|
2780
|
-
),
|
|
2807
|
+
), k.configure(
|
|
2781
2808
|
this.canvas,
|
|
2782
2809
|
this.overlayLayer,
|
|
2783
2810
|
this.window,
|
|
@@ -2797,12 +2824,12 @@ class te {
|
|
|
2797
2824
|
}
|
|
2798
2825
|
);
|
|
2799
2826
|
}
|
|
2800
|
-
static configure(e, t, s,
|
|
2827
|
+
static configure(e, t, s, i, n) {
|
|
2801
2828
|
new te(
|
|
2802
2829
|
e,
|
|
2803
2830
|
t,
|
|
2804
2831
|
s,
|
|
2805
|
-
|
|
2832
|
+
i,
|
|
2806
2833
|
n
|
|
2807
2834
|
);
|
|
2808
2835
|
}
|
|
@@ -2810,7 +2837,7 @@ class te {
|
|
|
2810
2837
|
const s = this.params.draggingEdgeResolver(e);
|
|
2811
2838
|
if (s === null || !this.canvas.graph.hasEdge(s))
|
|
2812
2839
|
return !1;
|
|
2813
|
-
const
|
|
2840
|
+
const i = this.canvas.graph.getEdge(s), n = e === i.from, a = e === i.to, h = n ? i.to : i.from;
|
|
2814
2841
|
this.staticPortId = h, this.isTargetDragging = a;
|
|
2815
2842
|
const d = this.canvas.graph.getPort(e), c = this.canvas.graph.getPort(h), g = c.element.getBoundingClientRect(), l = {
|
|
2816
2843
|
x: g.x + g.width / 2,
|
|
@@ -2818,32 +2845,32 @@ class te {
|
|
|
2818
2845
|
}, u = this.overlayLayer.getBoundingClientRect(), w = this.canvas.viewport.createContentCoords({
|
|
2819
2846
|
x: l.x - u.x,
|
|
2820
2847
|
y: l.y - u.y
|
|
2821
|
-
}),
|
|
2848
|
+
}), y = this.canvas.viewport.createContentCoords({
|
|
2822
2849
|
x: t.x - u.x,
|
|
2823
2850
|
y: t.y - u.y
|
|
2824
2851
|
});
|
|
2825
2852
|
this.draggingEdgePayload = {
|
|
2826
2853
|
id: s,
|
|
2827
|
-
from:
|
|
2828
|
-
to:
|
|
2829
|
-
shape:
|
|
2830
|
-
priority:
|
|
2854
|
+
from: i.from,
|
|
2855
|
+
to: i.to,
|
|
2856
|
+
shape: i.shape,
|
|
2857
|
+
priority: i.priority
|
|
2831
2858
|
}, this.canvas.removeEdge(s);
|
|
2832
2859
|
const E = {
|
|
2833
|
-
overlayNodeId:
|
|
2860
|
+
overlayNodeId: N.StaticNodeId,
|
|
2834
2861
|
portCoords: w,
|
|
2835
2862
|
portDirection: c.direction
|
|
2836
2863
|
}, S = {
|
|
2837
|
-
overlayNodeId:
|
|
2838
|
-
portCoords:
|
|
2864
|
+
overlayNodeId: N.DraggingNodeId,
|
|
2865
|
+
portCoords: y,
|
|
2839
2866
|
portDirection: d.direction
|
|
2840
|
-
}, [b,
|
|
2841
|
-
this.overlayCanvas.addNode(U(b)), this.overlayCanvas.addNode(U(
|
|
2842
|
-
const P = this.params.draggingEdgeShapeFactory !== null ? this.params.draggingEdgeShapeFactory(
|
|
2867
|
+
}, [b, T] = this.isTargetDragging ? [E, S] : [S, E];
|
|
2868
|
+
this.overlayCanvas.addNode(U(b)), this.overlayCanvas.addNode(U(T));
|
|
2869
|
+
const P = this.params.draggingEdgeShapeFactory !== null ? this.params.draggingEdgeShapeFactory(N.EdgeId) : i.shape;
|
|
2843
2870
|
return this.overlayCanvas.addEdge({
|
|
2844
|
-
id:
|
|
2871
|
+
id: N.EdgeId,
|
|
2845
2872
|
from: b.overlayNodeId,
|
|
2846
|
-
to:
|
|
2873
|
+
to: T.overlayNodeId,
|
|
2847
2874
|
shape: P
|
|
2848
2875
|
}), !0;
|
|
2849
2876
|
}
|
|
@@ -2854,15 +2881,15 @@ class te {
|
|
|
2854
2881
|
const t = this.overlayLayer.getBoundingClientRect(), s = {
|
|
2855
2882
|
x: e.x - t.x,
|
|
2856
2883
|
y: e.y - t.y
|
|
2857
|
-
},
|
|
2858
|
-
this.overlayCanvas.updateNode(
|
|
2859
|
-
x:
|
|
2860
|
-
y:
|
|
2884
|
+
}, i = this.canvas.viewport.createContentCoords(s);
|
|
2885
|
+
this.overlayCanvas.updateNode(N.DraggingNodeId, {
|
|
2886
|
+
x: i.x,
|
|
2887
|
+
y: i.y
|
|
2861
2888
|
});
|
|
2862
2889
|
}
|
|
2863
2890
|
tryCreateConnection(e) {
|
|
2864
2891
|
const t = xe(this.canvas.graph, e);
|
|
2865
|
-
if (this.overlayCanvas.removeEdge(
|
|
2892
|
+
if (this.overlayCanvas.removeEdge(N.EdgeId), t === null) {
|
|
2866
2893
|
const d = this.draggingEdgePayload;
|
|
2867
2894
|
this.params.onEdgeReattachInterrupted({
|
|
2868
2895
|
id: d.id,
|
|
@@ -2873,10 +2900,10 @@ class te {
|
|
|
2873
2900
|
});
|
|
2874
2901
|
return;
|
|
2875
2902
|
}
|
|
2876
|
-
const [s,
|
|
2903
|
+
const [s, i] = this.isTargetDragging ? [this.staticPortId, t] : [t, this.staticPortId], n = this.draggingEdgePayload, a = {
|
|
2877
2904
|
id: n.id,
|
|
2878
2905
|
from: s,
|
|
2879
|
-
to:
|
|
2906
|
+
to: i,
|
|
2880
2907
|
shape: n.shape,
|
|
2881
2908
|
priority: n.priority
|
|
2882
2909
|
}, h = this.params.connectionPreprocessor(a);
|
|
@@ -2895,45 +2922,28 @@ class te {
|
|
|
2895
2922
|
}
|
|
2896
2923
|
}
|
|
2897
2924
|
class re {
|
|
2898
|
-
constructor(e, t
|
|
2899
|
-
this.
|
|
2900
|
-
this.
|
|
2925
|
+
constructor(e, t) {
|
|
2926
|
+
this.applier = e, this.trigger = t, this.trigger.subscribe(() => {
|
|
2927
|
+
this.applier.apply();
|
|
2901
2928
|
});
|
|
2902
2929
|
}
|
|
2903
|
-
static configure(e, t
|
|
2904
|
-
new re(
|
|
2905
|
-
e,
|
|
2906
|
-
t,
|
|
2907
|
-
s
|
|
2908
|
-
);
|
|
2909
|
-
}
|
|
2910
|
-
applyLayout() {
|
|
2911
|
-
this.layoutAlgorithm.calculateCoordinates({
|
|
2912
|
-
graph: this.canvas.graph,
|
|
2913
|
-
viewport: this.canvas.viewport
|
|
2914
|
-
}).forEach((t, s) => {
|
|
2915
|
-
this.canvas.updateNode(s, t);
|
|
2916
|
-
});
|
|
2930
|
+
static configure(e, t) {
|
|
2931
|
+
new re(e, t);
|
|
2917
2932
|
}
|
|
2918
2933
|
}
|
|
2919
2934
|
class O {
|
|
2920
2935
|
constructor(e, t, s) {
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
this.applyScheduled = !1, this.
|
|
2924
|
-
graph: this.canvas.graph,
|
|
2925
|
-
viewport: this.canvas.viewport
|
|
2926
|
-
}).forEach((t, s) => {
|
|
2927
|
-
this.canvas.updateNode(s, t);
|
|
2928
|
-
});
|
|
2936
|
+
o(this, "applyScheduled", !1);
|
|
2937
|
+
o(this, "apply", () => {
|
|
2938
|
+
this.applyScheduled = !1, this.applier.apply();
|
|
2929
2939
|
});
|
|
2930
|
-
this.
|
|
2940
|
+
this.graph = e, this.applier = t, this.defererFn = s, this.graph.onAfterNodeAdded.subscribe(() => {
|
|
2931
2941
|
this.scheduleApply();
|
|
2932
|
-
}), this.
|
|
2942
|
+
}), this.graph.onBeforeNodeRemoved.subscribe(() => {
|
|
2933
2943
|
this.scheduleApply();
|
|
2934
|
-
}), this.
|
|
2944
|
+
}), this.graph.onAfterEdgeAdded.subscribe(() => {
|
|
2935
2945
|
this.scheduleApply();
|
|
2936
|
-
}), this.
|
|
2946
|
+
}), this.graph.onBeforeEdgeRemoved.subscribe(() => {
|
|
2937
2947
|
this.scheduleApply();
|
|
2938
2948
|
});
|
|
2939
2949
|
}
|
|
@@ -2948,25 +2958,26 @@ class O {
|
|
|
2948
2958
|
this.applyScheduled || (this.applyScheduled = !0, this.defererFn(this.apply));
|
|
2949
2959
|
}
|
|
2950
2960
|
}
|
|
2951
|
-
class
|
|
2961
|
+
class Tt {
|
|
2952
2962
|
static configure(e, t) {
|
|
2953
|
-
const s = t.applyOn
|
|
2963
|
+
const s = t.applyOn, i = new At(e, t.algorithm, {
|
|
2964
|
+
staticNodeResolver: t.staticNodeResolver
|
|
2965
|
+
});
|
|
2954
2966
|
switch (s.type) {
|
|
2955
2967
|
case "manual": {
|
|
2956
2968
|
re.configure(
|
|
2957
|
-
|
|
2958
|
-
t.algorithm,
|
|
2969
|
+
i,
|
|
2959
2970
|
s.trigger
|
|
2960
2971
|
);
|
|
2961
2972
|
break;
|
|
2962
2973
|
}
|
|
2963
2974
|
case "topologyChangeMacrotask": {
|
|
2964
2975
|
O.configure(
|
|
2965
|
-
e,
|
|
2966
|
-
|
|
2967
|
-
(
|
|
2976
|
+
e.graph,
|
|
2977
|
+
i,
|
|
2978
|
+
(n) => {
|
|
2968
2979
|
setTimeout(() => {
|
|
2969
|
-
|
|
2980
|
+
n();
|
|
2970
2981
|
});
|
|
2971
2982
|
}
|
|
2972
2983
|
);
|
|
@@ -2974,11 +2985,11 @@ class Pt {
|
|
|
2974
2985
|
}
|
|
2975
2986
|
case "topologyChangeMicrotask": {
|
|
2976
2987
|
O.configure(
|
|
2977
|
-
e,
|
|
2978
|
-
|
|
2979
|
-
(
|
|
2988
|
+
e.graph,
|
|
2989
|
+
i,
|
|
2990
|
+
(n) => {
|
|
2980
2991
|
queueMicrotask(() => {
|
|
2981
|
-
|
|
2992
|
+
n();
|
|
2982
2993
|
});
|
|
2983
2994
|
}
|
|
2984
2995
|
);
|
|
@@ -2987,10 +2998,10 @@ class Pt {
|
|
|
2987
2998
|
}
|
|
2988
2999
|
}
|
|
2989
3000
|
}
|
|
2990
|
-
class
|
|
3001
|
+
class Ct {
|
|
2991
3002
|
constructor(e, t) {
|
|
2992
|
-
|
|
2993
|
-
|
|
3003
|
+
o(this, "previousTimeStamp");
|
|
3004
|
+
o(this, "step", (e) => {
|
|
2994
3005
|
if (this.previousTimeStamp === void 0)
|
|
2995
3006
|
this.previousTimeStamp = e;
|
|
2996
3007
|
else {
|
|
@@ -3003,23 +3014,20 @@ class Tt {
|
|
|
3003
3014
|
}
|
|
3004
3015
|
}
|
|
3005
3016
|
class se {
|
|
3006
|
-
constructor(e, t, s
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
dt: e,
|
|
3011
|
-
viewport: this.canvas.viewport
|
|
3012
|
-
}).forEach((s, o) => {
|
|
3013
|
-
this.staticNodes.has(o) || this.canvas.updateNode(o, { x: s.x, y: s.y });
|
|
3014
|
-
});
|
|
3017
|
+
constructor(e, t, s) {
|
|
3018
|
+
o(this, "applier");
|
|
3019
|
+
o(this, "step", (e) => {
|
|
3020
|
+
this.applier.apply(e);
|
|
3015
3021
|
});
|
|
3016
|
-
this.
|
|
3022
|
+
this.win = s, this.applier = new Et(e, t.algorithm, {
|
|
3023
|
+
staticNodeResolver: t.staticNodeResolver
|
|
3024
|
+
}), new Ct(this.win, this.step);
|
|
3017
3025
|
}
|
|
3018
|
-
static configure(e, t, s
|
|
3019
|
-
new se(e, t, s
|
|
3026
|
+
static configure(e, t, s) {
|
|
3027
|
+
new se(e, t, s);
|
|
3020
3028
|
}
|
|
3021
3029
|
}
|
|
3022
|
-
const
|
|
3030
|
+
const Dt = () => {
|
|
3023
3031
|
const r = document.createElement("div");
|
|
3024
3032
|
return r.style.width = "100%", r.style.height = "100%", r.style.position = "relative", r;
|
|
3025
3033
|
}, Y = () => {
|
|
@@ -3029,26 +3037,26 @@ const Ct = () => {
|
|
|
3029
3037
|
const r = Y();
|
|
3030
3038
|
return r.style.pointerEvents = "none", r;
|
|
3031
3039
|
};
|
|
3032
|
-
class
|
|
3040
|
+
class Mt {
|
|
3033
3041
|
constructor(e) {
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3042
|
+
o(this, "background", Y());
|
|
3043
|
+
o(this, "main", Y());
|
|
3044
|
+
o(this, "overlayConnectablePorts", pe());
|
|
3045
|
+
o(this, "overlayDraggableEdges", pe());
|
|
3046
|
+
o(this, "host", Dt());
|
|
3039
3047
|
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);
|
|
3040
3048
|
}
|
|
3041
3049
|
destroy() {
|
|
3042
3050
|
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);
|
|
3043
3051
|
}
|
|
3044
3052
|
}
|
|
3045
|
-
const G = (r) => () => r, we = G(0),
|
|
3053
|
+
const G = (r) => () => r, we = G(0), Lt = () => {
|
|
3046
3054
|
let r = 0;
|
|
3047
3055
|
return () => r++;
|
|
3048
|
-
},
|
|
3056
|
+
}, Rt = (r, e) => {
|
|
3049
3057
|
let t = we, s = we;
|
|
3050
|
-
const
|
|
3051
|
-
return r === "incremental" && (t =
|
|
3058
|
+
const i = Lt();
|
|
3059
|
+
return r === "incremental" && (t = i), e === "incremental" && (s = i), typeof r == "number" && (t = G(r)), typeof e == "number" && (s = G(e)), typeof r == "function" && (t = r), typeof e == "function" && (s = e), {
|
|
3052
3060
|
nodesPriorityFn: t,
|
|
3053
3061
|
edgesPriorityFn: s
|
|
3054
3062
|
};
|
|
@@ -3084,7 +3092,7 @@ const G = (r) => () => r, we = G(0), Dt = () => {
|
|
|
3084
3092
|
detourDistance: r.detourDistance
|
|
3085
3093
|
});
|
|
3086
3094
|
case "vertical":
|
|
3087
|
-
return () => new
|
|
3095
|
+
return () => new yt({
|
|
3088
3096
|
color: r.color,
|
|
3089
3097
|
width: r.width,
|
|
3090
3098
|
arrowLength: r.arrowLength,
|
|
@@ -3122,15 +3130,15 @@ const G = (r) => () => r, we = G(0), Dt = () => {
|
|
|
3122
3130
|
detourDirection: r.detourDirection
|
|
3123
3131
|
});
|
|
3124
3132
|
}
|
|
3125
|
-
},
|
|
3126
|
-
var t, s,
|
|
3127
|
-
const e =
|
|
3133
|
+
}, Vt = (r) => {
|
|
3134
|
+
var t, s, i, n, a;
|
|
3135
|
+
const e = Rt(
|
|
3128
3136
|
(t = r.nodes) == null ? void 0 : t.priority,
|
|
3129
3137
|
(s = r.edges) == null ? void 0 : s.priority
|
|
3130
3138
|
);
|
|
3131
3139
|
return {
|
|
3132
3140
|
nodes: {
|
|
3133
|
-
centerFn: ((
|
|
3141
|
+
centerFn: ((i = r.nodes) == null ? void 0 : i.centerFn) ?? Se,
|
|
3134
3142
|
priorityFn: e.nodesPriorityFn
|
|
3135
3143
|
},
|
|
3136
3144
|
ports: {
|
|
@@ -3141,12 +3149,12 @@ const G = (r) => () => r, we = G(0), Dt = () => {
|
|
|
3141
3149
|
priorityFn: e.edgesPriorityFn
|
|
3142
3150
|
}
|
|
3143
3151
|
};
|
|
3144
|
-
},
|
|
3145
|
-
var w,
|
|
3152
|
+
}, Ft = (r) => {
|
|
3153
|
+
var w, y, E, S, b, T;
|
|
3146
3154
|
const e = ((w = r.events) == null ? void 0 : w.onNodeDragStarted) ?? (() => {
|
|
3147
|
-
}), t = ((
|
|
3148
|
-
}), s = r.nodeDragVerifier ?? (() => !0),
|
|
3149
|
-
}), 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 = (
|
|
3155
|
+
}), t = ((y = r.events) == null ? void 0 : y.onNodeDrag) ?? (() => {
|
|
3156
|
+
}), s = r.nodeDragVerifier ?? (() => !0), i = ((E = r.events) == null ? void 0 : E.onNodeDragFinished) ?? (() => {
|
|
3157
|
+
}), 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 = (T = r.mouse) == null ? void 0 : T.mouseUpEventVerifier, u = l !== void 0 ? l : (P) => P.button === 0;
|
|
3150
3158
|
return {
|
|
3151
3159
|
moveOnTop: n,
|
|
3152
3160
|
moveEdgesOnTop: a,
|
|
@@ -3157,25 +3165,25 @@ const G = (r) => () => r, we = G(0), Dt = () => {
|
|
|
3157
3165
|
onNodeDragStarted: e,
|
|
3158
3166
|
onNodeDrag: t,
|
|
3159
3167
|
nodeDragVerifier: s,
|
|
3160
|
-
onNodeDragFinished:
|
|
3168
|
+
onNodeDragFinished: i
|
|
3161
3169
|
};
|
|
3162
|
-
},
|
|
3163
|
-
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,
|
|
3170
|
+
}, It = (r) => {
|
|
3171
|
+
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, i = r.maxY !== null ? r.maxY : 1 / 0;
|
|
3164
3172
|
return (n) => {
|
|
3165
3173
|
let a = n.nextTransform.x, h = n.nextTransform.y;
|
|
3166
3174
|
a < e && a < n.prevTransform.x && (a = Math.min(n.prevTransform.x, e));
|
|
3167
3175
|
const d = n.canvasWidth * n.prevTransform.scale, c = t - d;
|
|
3168
3176
|
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));
|
|
3169
|
-
const g = n.canvasHeight * n.prevTransform.scale, l =
|
|
3177
|
+
const g = n.canvasHeight * n.prevTransform.scale, l = i - g;
|
|
3170
3178
|
return h > l && h > n.prevTransform.y && (h = Math.max(n.prevTransform.y, l)), { scale: n.nextTransform.scale, x: a, y: h };
|
|
3171
3179
|
};
|
|
3172
|
-
},
|
|
3173
|
-
const e = r.maxContentScale, t = r.minContentScale, s = e !== null ? 1 / e : 0,
|
|
3180
|
+
}, $t = (r) => {
|
|
3181
|
+
const e = r.maxContentScale, t = r.minContentScale, s = e !== null ? 1 / e : 0, i = t !== null ? 1 / t : 1 / 0;
|
|
3174
3182
|
return (n) => {
|
|
3175
3183
|
const a = n.prevTransform, h = n.nextTransform;
|
|
3176
3184
|
let d = h.scale, c = h.x, g = h.y;
|
|
3177
|
-
if (h.scale >
|
|
3178
|
-
d = Math.max(a.scale,
|
|
3185
|
+
if (h.scale > i && h.scale > a.scale) {
|
|
3186
|
+
d = Math.max(a.scale, i), c = a.x, g = a.y;
|
|
3179
3187
|
const l = (d - a.scale) / (h.scale - a.scale);
|
|
3180
3188
|
c = a.x + (h.x - a.x) * l, g = a.y + (h.y - a.y) * l;
|
|
3181
3189
|
}
|
|
@@ -3190,7 +3198,7 @@ const G = (r) => () => r, we = G(0), Dt = () => {
|
|
|
3190
3198
|
y: g
|
|
3191
3199
|
};
|
|
3192
3200
|
};
|
|
3193
|
-
},
|
|
3201
|
+
}, Ut = (r) => (e) => r.reduce(
|
|
3194
3202
|
(t, s) => s({
|
|
3195
3203
|
prevTransform: e.prevTransform,
|
|
3196
3204
|
nextTransform: t,
|
|
@@ -3198,35 +3206,35 @@ const G = (r) => () => r, we = G(0), Dt = () => {
|
|
|
3198
3206
|
canvasHeight: e.canvasHeight
|
|
3199
3207
|
}),
|
|
3200
3208
|
e.nextTransform
|
|
3201
|
-
),
|
|
3209
|
+
), ye = (r) => {
|
|
3202
3210
|
if (typeof r == "function")
|
|
3203
3211
|
return r;
|
|
3204
3212
|
switch (r.type) {
|
|
3205
3213
|
case "scale-limit":
|
|
3206
|
-
return
|
|
3214
|
+
return $t({
|
|
3207
3215
|
minContentScale: r.minContentScale ?? 0,
|
|
3208
3216
|
maxContentScale: r.maxContentScale ?? 1 / 0
|
|
3209
3217
|
});
|
|
3210
3218
|
case "shift-limit":
|
|
3211
|
-
return
|
|
3219
|
+
return It({
|
|
3212
3220
|
minX: r.minX ?? -1 / 0,
|
|
3213
3221
|
maxX: r.maxX ?? 1 / 0,
|
|
3214
3222
|
minY: r.minY ?? -1 / 0,
|
|
3215
3223
|
maxY: r.maxY ?? 1 / 0
|
|
3216
3224
|
});
|
|
3217
3225
|
}
|
|
3218
|
-
},
|
|
3219
|
-
var
|
|
3220
|
-
const e = (
|
|
3221
|
-
let
|
|
3222
|
-
s !== void 0 ? Array.isArray(s) ?
|
|
3226
|
+
}, fe = (r) => {
|
|
3227
|
+
var y, E, S, b, T, P, R, V, ie, ne, ae, he;
|
|
3228
|
+
const e = (y = r == null ? void 0 : r.scale) == null ? void 0 : y.mouseWheelSensitivity, t = e !== void 0 ? e : 1.2, s = r == null ? void 0 : r.transformPreprocessor;
|
|
3229
|
+
let i;
|
|
3230
|
+
s !== void 0 ? Array.isArray(s) ? i = Ut(
|
|
3223
3231
|
s.map(
|
|
3224
|
-
(
|
|
3232
|
+
(C) => ye(C)
|
|
3225
3233
|
)
|
|
3226
|
-
) :
|
|
3234
|
+
) : i = ye(s) : i = (C) => C.nextTransform;
|
|
3227
3235
|
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) ?? (() => {
|
|
3228
3236
|
}), h = ((b = r == null ? void 0 : r.events) == null ? void 0 : b.onTransformChange) ?? (() => {
|
|
3229
|
-
}), d = (
|
|
3237
|
+
}), d = (T = r == null ? void 0 : r.shift) == null ? void 0 : T.mouseDownEventVerifier, c = d !== void 0 ? d : (C) => C.button === 0, g = (P = r == null ? void 0 : r.shift) == null ? void 0 : P.mouseUpEventVerifier, l = g !== void 0 ? g : (C) => C.button === 0, u = (R = r == null ? void 0 : r.scale) == null ? void 0 : R.mouseWheelEventVerifier, w = u !== void 0 ? u : () => !0;
|
|
3230
3238
|
return {
|
|
3231
3239
|
wheelSensitivity: t,
|
|
3232
3240
|
onTransformStarted: ((V = r == null ? void 0 : r.events) == null ? void 0 : V.onTransformStarted) ?? (() => {
|
|
@@ -3235,7 +3243,7 @@ const G = (r) => () => r, we = G(0), Dt = () => {
|
|
|
3235
3243
|
}),
|
|
3236
3244
|
onBeforeTransformChange: a,
|
|
3237
3245
|
onTransformChange: h,
|
|
3238
|
-
transformPreprocessor:
|
|
3246
|
+
transformPreprocessor: i,
|
|
3239
3247
|
shiftCursor: n,
|
|
3240
3248
|
mouseDownEventVerifier: c,
|
|
3241
3249
|
mouseUpEventVerifier: l,
|
|
@@ -3246,32 +3254,32 @@ const G = (r) => () => r, we = G(0), Dt = () => {
|
|
|
3246
3254
|
onResizeTransformFinished: ((he = r == null ? void 0 : r.events) == null ? void 0 : he.onResizeTransformFinished) ?? (() => {
|
|
3247
3255
|
})
|
|
3248
3256
|
};
|
|
3249
|
-
},
|
|
3257
|
+
}, Bt = (r, e) => {
|
|
3250
3258
|
const t = document.createElementNS(
|
|
3251
3259
|
"http://www.w3.org/2000/svg",
|
|
3252
3260
|
"circle"
|
|
3253
3261
|
);
|
|
3254
3262
|
return t.setAttribute("cx", "0"), t.setAttribute("cy", "0"), t.setAttribute("r", `${r}`), t.setAttribute("fill", `${e}`), t;
|
|
3255
|
-
},
|
|
3263
|
+
}, Ot = (r) => r instanceof SVGElement ? r : Bt(
|
|
3256
3264
|
(r == null ? void 0 : r.radius) ?? 1.5,
|
|
3257
3265
|
(r == null ? void 0 : r.color) ?? "#d8d8d8"
|
|
3258
|
-
),
|
|
3259
|
-
const e = r.tileDimensions, t = (e == null ? void 0 : e.width) ?? 25, s = (e == null ? void 0 : e.height) ?? 25,
|
|
3266
|
+
), Wt = (r) => {
|
|
3267
|
+
const e = r.tileDimensions, t = (e == null ? void 0 : e.width) ?? 25, s = (e == null ? void 0 : e.height) ?? 25, i = Ot(r.renderer ?? {});
|
|
3260
3268
|
return {
|
|
3261
3269
|
tileWidth: t,
|
|
3262
3270
|
tileHeight: s,
|
|
3263
|
-
renderer:
|
|
3271
|
+
renderer: i,
|
|
3264
3272
|
maxViewportScale: r.maxViewportScale ?? 10
|
|
3265
3273
|
};
|
|
3266
|
-
},
|
|
3274
|
+
}, zt = (r, e, t) => {
|
|
3267
3275
|
var c, g, l;
|
|
3268
|
-
const s = () => "direct",
|
|
3276
|
+
const s = () => "direct", i = (u) => u, n = (u) => u.button === 0, a = () => {
|
|
3269
3277
|
}, h = () => {
|
|
3270
3278
|
}, d = () => {
|
|
3271
3279
|
};
|
|
3272
3280
|
return {
|
|
3273
3281
|
connectionTypeResolver: r.connectionTypeResolver ?? s,
|
|
3274
|
-
connectionPreprocessor: r.connectionPreprocessor ??
|
|
3282
|
+
connectionPreprocessor: r.connectionPreprocessor ?? i,
|
|
3275
3283
|
mouseDownEventVerifier: r.mouseDownEventVerifier ?? n,
|
|
3276
3284
|
mouseUpEventVerifier: r.mouseUpEventVerifier ?? n,
|
|
3277
3285
|
onAfterEdgeCreated: ((c = r.events) == null ? void 0 : c.onAfterEdgeCreated) ?? a,
|
|
@@ -3280,9 +3288,9 @@ const G = (r) => () => r, we = G(0), Dt = () => {
|
|
|
3280
3288
|
dragPortDirection: r.dragPortDirection ?? t,
|
|
3281
3289
|
edgeShapeFactory: r.edgeShape !== void 0 ? oe(r.edgeShape) : e
|
|
3282
3290
|
};
|
|
3283
|
-
},
|
|
3291
|
+
}, kt = (r, e) => {
|
|
3284
3292
|
var c, g, l;
|
|
3285
|
-
const t = (u) => u, s = (u) => u.button === 0 && u.ctrlKey,
|
|
3293
|
+
const t = (u) => u, s = (u) => u.button === 0 && u.ctrlKey, i = (u) => u.button === 0, n = (u) => {
|
|
3286
3294
|
const w = e.getPortAdjacentEdgeIds(u);
|
|
3287
3295
|
return w.length > 0 ? w[w.length - 1] : null;
|
|
3288
3296
|
}, a = () => {
|
|
@@ -3292,17 +3300,17 @@ const G = (r) => () => r, we = G(0), Dt = () => {
|
|
|
3292
3300
|
return {
|
|
3293
3301
|
connectionPreprocessor: r.connectionPreprocessor ?? t,
|
|
3294
3302
|
mouseDownEventVerifier: r.mouseDownEventVerifier ?? s,
|
|
3295
|
-
mouseUpEventVerifier: r.mouseUpEventVerifier ??
|
|
3303
|
+
mouseUpEventVerifier: r.mouseUpEventVerifier ?? i,
|
|
3296
3304
|
draggingEdgeResolver: r.draggingEdgeResolver ?? n,
|
|
3297
3305
|
draggingEdgeShapeFactory: r.draggingEdgeShape !== void 0 ? oe(r.draggingEdgeShape) : null,
|
|
3298
3306
|
onAfterEdgeReattached: ((c = r.events) == null ? void 0 : c.onAfterEdgeReattached) ?? a,
|
|
3299
3307
|
onEdgeReattachInterrupted: ((g = r.events) == null ? void 0 : g.onEdgeReattachInterrupted) ?? d,
|
|
3300
3308
|
onEdgeReattachPrevented: ((l = r.events) == null ? void 0 : l.onEdgeReattachPrevented) ?? h
|
|
3301
3309
|
};
|
|
3302
|
-
},
|
|
3310
|
+
}, Ht = (r) => ({
|
|
3303
3311
|
nodeVerticalRadius: r.nodeContainingRadius.vertical,
|
|
3304
3312
|
nodeHorizontalRadius: r.nodeContainingRadius.horizontal
|
|
3305
|
-
}),
|
|
3313
|
+
}), Xt = (r) => {
|
|
3306
3314
|
var e, t;
|
|
3307
3315
|
return {
|
|
3308
3316
|
onAfterNodeDetached: ((e = r == null ? void 0 : r.events) == null ? void 0 : e.onAfterNodeDetached) ?? (() => {
|
|
@@ -3311,28 +3319,43 @@ const G = (r) => () => r, we = G(0), Dt = () => {
|
|
|
3311
3319
|
})
|
|
3312
3320
|
};
|
|
3313
3321
|
};
|
|
3314
|
-
class
|
|
3322
|
+
class Yt extends Error {
|
|
3315
3323
|
constructor() {
|
|
3316
3324
|
super(...arguments);
|
|
3317
|
-
|
|
3325
|
+
o(this, "name", "CanvasBuilderError");
|
|
3318
3326
|
}
|
|
3319
3327
|
}
|
|
3328
|
+
const v = Object.freeze({
|
|
3329
|
+
seed: "HTMLGraph is awesome",
|
|
3330
|
+
maxTimeDeltaSec: 0.01,
|
|
3331
|
+
nodeCharge: 1e5,
|
|
3332
|
+
nodeMass: 1,
|
|
3333
|
+
edgeEquilibriumLength: 300,
|
|
3334
|
+
edgeStiffness: 1e3,
|
|
3335
|
+
dtSec: 0.01,
|
|
3336
|
+
maxIterations: 1e3,
|
|
3337
|
+
convergenceVelocity: 10,
|
|
3338
|
+
maxForce: 1e7,
|
|
3339
|
+
nodeForceCoefficient: 1,
|
|
3340
|
+
barnesHutAreaRadiusThreshold: 0.01,
|
|
3341
|
+
barnesHutTheta: 1
|
|
3342
|
+
});
|
|
3320
3343
|
class Fe {
|
|
3321
3344
|
constructor(e, t, s) {
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3345
|
+
o(this, "dt");
|
|
3346
|
+
o(this, "nodeMass");
|
|
3347
|
+
o(this, "edgeEquilibriumLength");
|
|
3348
|
+
o(this, "edgeStiffness");
|
|
3349
|
+
o(this, "nodeForcesApplicationStrategy");
|
|
3350
|
+
o(this, "distanceVectorGenerator");
|
|
3328
3351
|
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;
|
|
3329
3352
|
}
|
|
3330
3353
|
apply() {
|
|
3331
3354
|
let e = 0;
|
|
3332
3355
|
const t = /* @__PURE__ */ new Map();
|
|
3333
|
-
return this.graph.getAllNodeIds().forEach((
|
|
3334
|
-
t.set(
|
|
3335
|
-
}), this.nodeForcesApplicationStrategy.apply(this.currentCoords, t), this.applyEdgeForces(t), this.currentCoords.forEach((
|
|
3356
|
+
return this.graph.getAllNodeIds().forEach((i) => {
|
|
3357
|
+
t.set(i, { x: 0, y: 0 });
|
|
3358
|
+
}), this.nodeForcesApplicationStrategy.apply(this.currentCoords, t), this.applyEdgeForces(t), this.currentCoords.forEach((i, n) => {
|
|
3336
3359
|
const a = t.get(n), h = {
|
|
3337
3360
|
x: a.x / this.nodeMass * this.dt,
|
|
3338
3361
|
y: a.y / this.nodeMass * this.dt
|
|
@@ -3342,26 +3365,26 @@ class Fe {
|
|
|
3342
3365
|
Math.sqrt(h.x * h.x + h.y * h.y)
|
|
3343
3366
|
);
|
|
3344
3367
|
const d = h.x * this.dt, c = h.y * this.dt;
|
|
3345
|
-
|
|
3368
|
+
i.x += d, i.y += c;
|
|
3346
3369
|
}), e;
|
|
3347
3370
|
}
|
|
3348
3371
|
applyEdgeForces(e) {
|
|
3349
3372
|
this.graph.getAllEdgeIds().forEach((t) => {
|
|
3350
|
-
const s = this.graph.getEdge(t),
|
|
3373
|
+
const s = this.graph.getEdge(t), i = this.graph.getPort(s.from), n = this.graph.getPort(s.to), a = this.currentCoords.get(i.nodeId), h = this.currentCoords.get(n.nodeId), d = this.distanceVectorGenerator.create(
|
|
3351
3374
|
a,
|
|
3352
3375
|
h
|
|
3353
|
-
), g = (d.d - this.edgeEquilibriumLength) * this.edgeStiffness, l = d.ex * g, u = d.ey * g, w = e.get(
|
|
3354
|
-
w.x += l, w.y += u,
|
|
3376
|
+
), g = (d.d - this.edgeEquilibriumLength) * this.edgeStiffness, l = d.ex * g, u = d.ey * g, w = e.get(i.nodeId), y = e.get(n.nodeId);
|
|
3377
|
+
w.x += l, w.y += u, y.x -= l, y.y -= u;
|
|
3355
3378
|
});
|
|
3356
3379
|
}
|
|
3357
3380
|
}
|
|
3358
3381
|
class Ie {
|
|
3359
3382
|
constructor(e) {
|
|
3360
|
-
|
|
3383
|
+
o(this, "PI2", 2 * Math.PI);
|
|
3361
3384
|
this.rand = e;
|
|
3362
3385
|
}
|
|
3363
3386
|
create(e, t) {
|
|
3364
|
-
const s = t.x - e.x,
|
|
3387
|
+
const s = t.x - e.x, i = t.y - e.y, n = s * s + i * i;
|
|
3365
3388
|
if (n === 0) {
|
|
3366
3389
|
const c = this.PI2 * this.rand();
|
|
3367
3390
|
return {
|
|
@@ -3370,7 +3393,7 @@ class Ie {
|
|
|
3370
3393
|
d: 0
|
|
3371
3394
|
};
|
|
3372
3395
|
}
|
|
3373
|
-
const a = Math.sqrt(n), h = s / a, d =
|
|
3396
|
+
const a = Math.sqrt(n), h = s / a, d = i / a;
|
|
3374
3397
|
return { ex: h, ey: d, d: a };
|
|
3375
3398
|
}
|
|
3376
3399
|
}
|
|
@@ -3380,18 +3403,18 @@ const $e = (r) => {
|
|
|
3380
3403
|
const e = r.coefficient * (r.sourceCharge * r.targetCharge / (r.distance * r.distance));
|
|
3381
3404
|
return Math.min(e, r.maxForce);
|
|
3382
3405
|
};
|
|
3383
|
-
class
|
|
3406
|
+
class Gt {
|
|
3384
3407
|
constructor(e) {
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3408
|
+
o(this, "nodeCharge");
|
|
3409
|
+
o(this, "distanceVectorGenerator");
|
|
3410
|
+
o(this, "maxForce");
|
|
3388
3411
|
this.nodeCharge = e.nodeCharge, this.distanceVectorGenerator = e.distanceVectorGenerator, this.maxForce = e.maxForce;
|
|
3389
3412
|
}
|
|
3390
3413
|
apply(e, t) {
|
|
3391
|
-
const s = Array.from(t.keys()),
|
|
3392
|
-
for (let n = 0; n <
|
|
3414
|
+
const s = Array.from(t.keys()), i = s.length;
|
|
3415
|
+
for (let n = 0; n < i; n++) {
|
|
3393
3416
|
const a = s[n];
|
|
3394
|
-
for (let h = n + 1; h <
|
|
3417
|
+
for (let h = n + 1; h < i; h++) {
|
|
3395
3418
|
const d = s[h], c = e.get(a), g = e.get(d), l = this.distanceVectorGenerator.create(
|
|
3396
3419
|
c,
|
|
3397
3420
|
g
|
|
@@ -3401,39 +3424,39 @@ class Xt {
|
|
|
3401
3424
|
targetCharge: this.nodeCharge,
|
|
3402
3425
|
distance: l.d,
|
|
3403
3426
|
maxForce: this.maxForce
|
|
3404
|
-
}), w = u * l.ex,
|
|
3405
|
-
E.x -= w, E.y -=
|
|
3427
|
+
}), w = u * l.ex, y = u * l.ey, E = t.get(a), S = t.get(d);
|
|
3428
|
+
E.x -= w, E.y -= y, S.x += w, S.y += y;
|
|
3406
3429
|
}
|
|
3407
3430
|
}
|
|
3408
3431
|
}
|
|
3409
3432
|
}
|
|
3410
|
-
const
|
|
3433
|
+
const jt = (r) => {
|
|
3411
3434
|
if (r.size === 0)
|
|
3412
3435
|
return {
|
|
3413
3436
|
centerX: 0,
|
|
3414
3437
|
centerY: 0,
|
|
3415
3438
|
radius: 0
|
|
3416
3439
|
};
|
|
3417
|
-
let e = 1 / 0, t = -1 / 0, s = 1 / 0,
|
|
3440
|
+
let e = 1 / 0, t = -1 / 0, s = 1 / 0, i = -1 / 0;
|
|
3418
3441
|
r.forEach((d) => {
|
|
3419
|
-
e = Math.min(e, d.x), t = Math.max(t, d.x), s = Math.min(s, d.y),
|
|
3442
|
+
e = Math.min(e, d.x), t = Math.max(t, d.x), s = Math.min(s, d.y), i = Math.max(i, d.y);
|
|
3420
3443
|
});
|
|
3421
|
-
const n = t - e, a =
|
|
3444
|
+
const n = t - e, a = i - s, h = Math.max(n, a);
|
|
3422
3445
|
return {
|
|
3423
3446
|
centerX: (e + t) / 2,
|
|
3424
|
-
centerY: (s +
|
|
3447
|
+
centerY: (s + i) / 2,
|
|
3425
3448
|
radius: h / 2
|
|
3426
3449
|
};
|
|
3427
3450
|
};
|
|
3428
|
-
class
|
|
3451
|
+
class Kt {
|
|
3429
3452
|
constructor(e) {
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3453
|
+
o(this, "root");
|
|
3454
|
+
o(this, "leaves", /* @__PURE__ */ new Map());
|
|
3455
|
+
o(this, "coords");
|
|
3456
|
+
o(this, "areaRadiusThreshold");
|
|
3457
|
+
o(this, "nodeMass");
|
|
3458
|
+
o(this, "nodeCharge");
|
|
3459
|
+
o(this, "sortedParentNodes", []);
|
|
3437
3460
|
this.coords = e.coords, this.areaRadiusThreshold = e.areaRadiusThreshold, this.nodeMass = e.nodeMass, this.nodeCharge = e.nodeCharge, this.root = {
|
|
3438
3461
|
nodeIds: new Set(e.coords.keys()),
|
|
3439
3462
|
box: e.box,
|
|
@@ -3453,16 +3476,16 @@ class Gt {
|
|
|
3453
3476
|
for (; t.length > 0; ) {
|
|
3454
3477
|
const s = [];
|
|
3455
3478
|
for (; t.length > 0; ) {
|
|
3456
|
-
const
|
|
3457
|
-
this.processNode(
|
|
3479
|
+
const i = t.pop();
|
|
3480
|
+
this.processNode(i).forEach((a) => {
|
|
3458
3481
|
s.push(a);
|
|
3459
3482
|
});
|
|
3460
3483
|
}
|
|
3461
3484
|
t = s;
|
|
3462
3485
|
}
|
|
3463
3486
|
this.sortedParentNodes.reverse().forEach((s) => {
|
|
3464
|
-
let
|
|
3465
|
-
s.lb !== null && (a += s.lb.totalMass, h += s.lb.totalCharge,
|
|
3487
|
+
let i = 0, n = 0, a = 0, h = 0;
|
|
3488
|
+
s.lb !== null && (a += s.lb.totalMass, h += s.lb.totalCharge, i += 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, i += 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, i += 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, i += s.rt.chargeCenter.x * s.rt.totalCharge, n += s.rt.chargeCenter.y * s.rt.totalCharge), s.totalMass = a, s.totalCharge = h, s.chargeCenter.x = i / h, s.chargeCenter.y = n / h;
|
|
3466
3489
|
});
|
|
3467
3490
|
}
|
|
3468
3491
|
getRoot() {
|
|
@@ -3474,14 +3497,14 @@ class Gt {
|
|
|
3474
3497
|
processNode(e) {
|
|
3475
3498
|
if (e.nodeIds.size < 2)
|
|
3476
3499
|
return this.setLeaf(e), [];
|
|
3477
|
-
const { centerX: t, centerY: s, radius:
|
|
3478
|
-
if (
|
|
3500
|
+
const { centerX: t, centerY: s, radius: i } = e.box;
|
|
3501
|
+
if (i < this.areaRadiusThreshold)
|
|
3479
3502
|
return this.setLeaf(e), [];
|
|
3480
3503
|
this.sortedParentNodes.push(e);
|
|
3481
|
-
const n = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set(), c =
|
|
3504
|
+
const n = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set(), c = i / 2;
|
|
3482
3505
|
e.nodeIds.forEach((u) => {
|
|
3483
|
-
const { x: w, y
|
|
3484
|
-
w < t ?
|
|
3506
|
+
const { x: w, y } = this.coords.get(u);
|
|
3507
|
+
w < t ? y < s ? d.add(u) : h.add(u) : y < s ? a.add(u) : n.add(u), e.nodeIds.delete(u);
|
|
3485
3508
|
});
|
|
3486
3509
|
const g = {
|
|
3487
3510
|
parent: e,
|
|
@@ -3576,25 +3599,25 @@ class Gt {
|
|
|
3576
3599
|
y: 0
|
|
3577
3600
|
};
|
|
3578
3601
|
let t = 0, s = 0;
|
|
3579
|
-
return e.forEach((
|
|
3580
|
-
const n = this.coords.get(
|
|
3602
|
+
return e.forEach((i) => {
|
|
3603
|
+
const n = this.coords.get(i);
|
|
3581
3604
|
t += n.x, s += n.y;
|
|
3582
3605
|
}), { x: t / e.size, y: s / e.size };
|
|
3583
3606
|
}
|
|
3584
3607
|
}
|
|
3585
|
-
class
|
|
3608
|
+
class Qt {
|
|
3586
3609
|
constructor(e) {
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3610
|
+
o(this, "areaRadiusThreshold");
|
|
3611
|
+
o(this, "nodeMass");
|
|
3612
|
+
o(this, "nodeCharge");
|
|
3613
|
+
o(this, "theta");
|
|
3614
|
+
o(this, "distanceVectorGenerator");
|
|
3615
|
+
o(this, "nodeForceCoefficient");
|
|
3616
|
+
o(this, "maxForce");
|
|
3594
3617
|
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;
|
|
3595
3618
|
}
|
|
3596
3619
|
apply(e, t) {
|
|
3597
|
-
const s =
|
|
3620
|
+
const s = jt(e), i = new Kt({
|
|
3598
3621
|
box: s,
|
|
3599
3622
|
coords: e,
|
|
3600
3623
|
areaRadiusThreshold: this.areaRadiusThreshold,
|
|
@@ -3603,7 +3626,7 @@ class jt {
|
|
|
3603
3626
|
});
|
|
3604
3627
|
e.forEach((n, a) => {
|
|
3605
3628
|
const h = this.calculateForceForNode(
|
|
3606
|
-
|
|
3629
|
+
i.getLeaf(a),
|
|
3607
3630
|
a,
|
|
3608
3631
|
e
|
|
3609
3632
|
), d = t.get(a);
|
|
@@ -3611,14 +3634,14 @@ class jt {
|
|
|
3611
3634
|
});
|
|
3612
3635
|
}
|
|
3613
3636
|
calculateForceForNode(e, t, s) {
|
|
3614
|
-
const
|
|
3637
|
+
const i = s.get(t), n = { x: 0, y: 0 };
|
|
3615
3638
|
e.nodeIds.forEach((h) => {
|
|
3616
3639
|
if (h !== t) {
|
|
3617
3640
|
const d = s.get(h), c = this.calculateNodeRepulsiveForce({
|
|
3618
3641
|
sourceCharge: this.nodeCharge,
|
|
3619
3642
|
targetCharge: this.nodeCharge,
|
|
3620
3643
|
sourceCoords: d,
|
|
3621
|
-
targetCoords:
|
|
3644
|
+
targetCoords: i
|
|
3622
3645
|
});
|
|
3623
3646
|
this.applyForce(n, c);
|
|
3624
3647
|
}
|
|
@@ -3629,49 +3652,49 @@ class jt {
|
|
|
3629
3652
|
if (h !== null) {
|
|
3630
3653
|
const d = this.distanceVectorGenerator.create(
|
|
3631
3654
|
h.chargeCenter,
|
|
3632
|
-
|
|
3655
|
+
i
|
|
3633
3656
|
);
|
|
3634
3657
|
h.box.radius * 2 < d.d * this.theta ? (this.tryApplyFarForce({
|
|
3635
3658
|
totalForce: n,
|
|
3636
|
-
targetCoords:
|
|
3659
|
+
targetCoords: i,
|
|
3637
3660
|
target: h.lb,
|
|
3638
3661
|
current: a
|
|
3639
3662
|
}), this.tryApplyFarForce({
|
|
3640
3663
|
totalForce: n,
|
|
3641
|
-
targetCoords:
|
|
3664
|
+
targetCoords: i,
|
|
3642
3665
|
target: h.rb,
|
|
3643
3666
|
current: a
|
|
3644
3667
|
}), this.tryApplyFarForce({
|
|
3645
3668
|
totalForce: n,
|
|
3646
|
-
targetCoords:
|
|
3669
|
+
targetCoords: i,
|
|
3647
3670
|
target: h.rt,
|
|
3648
3671
|
current: a
|
|
3649
3672
|
}), this.tryApplyFarForce({
|
|
3650
3673
|
totalForce: n,
|
|
3651
|
-
targetCoords:
|
|
3674
|
+
targetCoords: i,
|
|
3652
3675
|
target: h.lt,
|
|
3653
3676
|
current: a
|
|
3654
3677
|
})) : (this.tryApplyNearForce({
|
|
3655
3678
|
totalForce: n,
|
|
3656
|
-
targetCoords:
|
|
3679
|
+
targetCoords: i,
|
|
3657
3680
|
target: h.lb,
|
|
3658
3681
|
current: a,
|
|
3659
3682
|
nodesCoords: s
|
|
3660
3683
|
}), this.tryApplyNearForce({
|
|
3661
3684
|
totalForce: n,
|
|
3662
|
-
targetCoords:
|
|
3685
|
+
targetCoords: i,
|
|
3663
3686
|
target: h.rb,
|
|
3664
3687
|
current: a,
|
|
3665
3688
|
nodesCoords: s
|
|
3666
3689
|
}), this.tryApplyNearForce({
|
|
3667
3690
|
totalForce: n,
|
|
3668
|
-
targetCoords:
|
|
3691
|
+
targetCoords: i,
|
|
3669
3692
|
target: h.rt,
|
|
3670
3693
|
current: a,
|
|
3671
3694
|
nodesCoords: s
|
|
3672
3695
|
}), this.tryApplyNearForce({
|
|
3673
3696
|
totalForce: n,
|
|
3674
|
-
targetCoords:
|
|
3697
|
+
targetCoords: i,
|
|
3675
3698
|
target: h.lt,
|
|
3676
3699
|
current: a,
|
|
3677
3700
|
nodesCoords: s
|
|
@@ -3682,7 +3705,7 @@ class jt {
|
|
|
3682
3705
|
return n;
|
|
3683
3706
|
}
|
|
3684
3707
|
calculateExactForce(e, t, s) {
|
|
3685
|
-
const
|
|
3708
|
+
const i = { x: 0, y: 0 }, n = [e];
|
|
3686
3709
|
for (; n.length > 0; ) {
|
|
3687
3710
|
const a = n.pop();
|
|
3688
3711
|
a.nodeIds.forEach((h) => {
|
|
@@ -3692,10 +3715,10 @@ class jt {
|
|
|
3692
3715
|
sourceCoords: d,
|
|
3693
3716
|
targetCoords: t
|
|
3694
3717
|
});
|
|
3695
|
-
this.applyForce(
|
|
3718
|
+
this.applyForce(i, c);
|
|
3696
3719
|
}), 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);
|
|
3697
3720
|
}
|
|
3698
|
-
return
|
|
3721
|
+
return i;
|
|
3699
3722
|
}
|
|
3700
3723
|
calculateApproximateForce(e, t) {
|
|
3701
3724
|
return this.calculateNodeRepulsiveForce({
|
|
@@ -3744,7 +3767,7 @@ class jt {
|
|
|
3744
3767
|
}
|
|
3745
3768
|
}
|
|
3746
3769
|
}
|
|
3747
|
-
const Ue = (r) => r.theta !== 0 ? new
|
|
3770
|
+
const Ue = (r) => r.theta !== 0 ? new Qt({
|
|
3748
3771
|
nodeCharge: r.nodeCharge,
|
|
3749
3772
|
nodeForceCoefficient: r.nodeForceCoefficient,
|
|
3750
3773
|
distanceVectorGenerator: r.distanceVectorGenerator,
|
|
@@ -3752,7 +3775,7 @@ const Ue = (r) => r.theta !== 0 ? new jt({
|
|
|
3752
3775
|
theta: r.theta,
|
|
3753
3776
|
nodeMass: r.nodeMass,
|
|
3754
3777
|
areaRadiusThreshold: r.areaRadiusThreshold
|
|
3755
|
-
}) : new
|
|
3778
|
+
}) : new Gt({
|
|
3756
3779
|
nodeCharge: r.nodeCharge,
|
|
3757
3780
|
nodeForceCoefficient: r.nodeForceCoefficient,
|
|
3758
3781
|
distanceVectorGenerator: r.distanceVectorGenerator,
|
|
@@ -3760,35 +3783,35 @@ const Ue = (r) => r.theta !== 0 ? new jt({
|
|
|
3760
3783
|
});
|
|
3761
3784
|
class Be {
|
|
3762
3785
|
constructor(e) {
|
|
3763
|
-
|
|
3764
|
-
|
|
3786
|
+
o(this, "rand");
|
|
3787
|
+
o(this, "sparsity");
|
|
3765
3788
|
this.rand = e.rand, this.sparsity = e.sparsity;
|
|
3766
3789
|
}
|
|
3767
3790
|
calculateCoordinates(e) {
|
|
3768
|
-
const { graph: t, viewport: s } = e,
|
|
3791
|
+
const { graph: t, viewport: s } = e, i = /* @__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 = {
|
|
3769
3792
|
x: g.x - l,
|
|
3770
3793
|
y: g.y - l
|
|
3771
3794
|
};
|
|
3772
3795
|
return n.forEach((w) => {
|
|
3773
|
-
const
|
|
3774
|
-
|
|
3775
|
-
x:
|
|
3776
|
-
y:
|
|
3796
|
+
const y = t.getNode(w);
|
|
3797
|
+
i.set(w, {
|
|
3798
|
+
x: y.x ?? u.x + a * this.rand(),
|
|
3799
|
+
y: y.y ?? u.y + a * this.rand()
|
|
3777
3800
|
});
|
|
3778
|
-
}),
|
|
3801
|
+
}), i;
|
|
3779
3802
|
}
|
|
3780
3803
|
}
|
|
3781
|
-
class
|
|
3804
|
+
class Zt {
|
|
3782
3805
|
constructor(e) {
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3806
|
+
o(this, "distanceVectorGenerator");
|
|
3807
|
+
o(this, "nodeForcesApplicationStrategy");
|
|
3808
|
+
o(this, "fillerLayoutAlgorithm");
|
|
3809
|
+
o(this, "maxIterations");
|
|
3810
|
+
o(this, "dtSec");
|
|
3811
|
+
o(this, "nodeMass");
|
|
3812
|
+
o(this, "edgeEquilibriumLength");
|
|
3813
|
+
o(this, "edgeStiffness");
|
|
3814
|
+
o(this, "convergenceVelocity");
|
|
3792
3815
|
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({
|
|
3793
3816
|
distanceVectorGenerator: this.distanceVectorGenerator,
|
|
3794
3817
|
nodeCharge: e.nodeCharge,
|
|
@@ -3803,13 +3826,13 @@ class qt {
|
|
|
3803
3826
|
});
|
|
3804
3827
|
}
|
|
3805
3828
|
calculateCoordinates(e) {
|
|
3806
|
-
const { graph: t, viewport: s } = e,
|
|
3829
|
+
const { graph: t, viewport: s } = e, i = this.fillerLayoutAlgorithm.calculateCoordinates({
|
|
3807
3830
|
graph: t,
|
|
3808
3831
|
viewport: s
|
|
3809
3832
|
});
|
|
3810
3833
|
for (let n = 0; n < this.maxIterations && !(new Fe(
|
|
3811
3834
|
t,
|
|
3812
|
-
|
|
3835
|
+
i,
|
|
3813
3836
|
{
|
|
3814
3837
|
distanceVectorGenerator: this.distanceVectorGenerator,
|
|
3815
3838
|
nodeForcesApplicationStrategy: this.nodeForcesApplicationStrategy,
|
|
@@ -3820,19 +3843,19 @@ class qt {
|
|
|
3820
3843
|
}
|
|
3821
3844
|
).apply() < this.convergenceVelocity); n++)
|
|
3822
3845
|
;
|
|
3823
|
-
return
|
|
3846
|
+
return i;
|
|
3824
3847
|
}
|
|
3825
3848
|
}
|
|
3826
|
-
class
|
|
3849
|
+
class qt {
|
|
3827
3850
|
constructor(e) {
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3851
|
+
o(this, "distanceVectorGenerator");
|
|
3852
|
+
o(this, "nodeForcesApplicationStrategy");
|
|
3853
|
+
o(this, "convergenceVelocity");
|
|
3854
|
+
o(this, "maxTimeDeltaSec");
|
|
3855
|
+
o(this, "nodeMass");
|
|
3856
|
+
o(this, "edgeEquilibriumLength");
|
|
3857
|
+
o(this, "edgeStiffness");
|
|
3858
|
+
o(this, "fillerLayoutAlgorithm");
|
|
3836
3859
|
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({
|
|
3837
3860
|
distanceVectorGenerator: this.distanceVectorGenerator,
|
|
3838
3861
|
nodeCharge: e.nodeCharge,
|
|
@@ -3847,7 +3870,7 @@ class Kt {
|
|
|
3847
3870
|
});
|
|
3848
3871
|
}
|
|
3849
3872
|
calculateNextCoordinates(e) {
|
|
3850
|
-
const { graph: t, viewport: s, dt:
|
|
3873
|
+
const { graph: t, viewport: s, dt: i } = e, n = this.fillerLayoutAlgorithm.calculateCoordinates({
|
|
3851
3874
|
graph: t,
|
|
3852
3875
|
viewport: s
|
|
3853
3876
|
});
|
|
@@ -3857,7 +3880,7 @@ class Kt {
|
|
|
3857
3880
|
{
|
|
3858
3881
|
distanceVectorGenerator: this.distanceVectorGenerator,
|
|
3859
3882
|
nodeForcesApplicationStrategy: this.nodeForcesApplicationStrategy,
|
|
3860
|
-
dtSec: Math.min(
|
|
3883
|
+
dtSec: Math.min(i, this.maxTimeDeltaSec),
|
|
3861
3884
|
nodeMass: this.nodeMass,
|
|
3862
3885
|
edgeEquilibriumLength: this.edgeEquilibriumLength,
|
|
3863
3886
|
edgeStiffness: this.edgeStiffness
|
|
@@ -3869,68 +3892,59 @@ class Kt {
|
|
|
3869
3892
|
}
|
|
3870
3893
|
}
|
|
3871
3894
|
const Oe = (r) => {
|
|
3872
|
-
let e = 1779033703, t = 3144134277, s = 1013904242,
|
|
3895
|
+
let e = 1779033703, t = 3144134277, s = 1013904242, i = 2773480762;
|
|
3873
3896
|
for (let n = 0, a; n < r.length; n++)
|
|
3874
|
-
a = r.charCodeAt(n), e = t ^ Math.imul(e ^ a, 597399067), t = s ^ Math.imul(t ^ a, 2869860233), s =
|
|
3875
|
-
return e = Math.imul(s ^ e >>> 18, 597399067), t = Math.imul(
|
|
3897
|
+
a = r.charCodeAt(n), e = t ^ Math.imul(e ^ a, 597399067), t = s ^ Math.imul(t ^ a, 2869860233), s = i ^ Math.imul(s ^ a, 951274213), i = e ^ Math.imul(i ^ a, 2716044179);
|
|
3898
|
+
return e = Math.imul(s ^ e >>> 18, 597399067), t = Math.imul(i ^ t >>> 22, 2869860233), s = Math.imul(e ^ s >>> 17, 951274213), i = Math.imul(t ^ i >>> 19, 2716044179), e ^= t ^ s ^ i, t ^= e, s ^= e, i ^= e, [e >>> 0, t >>> 0, s >>> 0, i >>> 0];
|
|
3876
3899
|
}, We = (r, e, t, s) => function() {
|
|
3877
3900
|
r |= 0, e |= 0, t |= 0, s |= 0;
|
|
3878
|
-
const
|
|
3879
|
-
return s = s + 1 | 0, r = e ^ e >>> 9, e = t + (t << 3) | 0, t = t << 21 | t >>> 11, t = t +
|
|
3880
|
-
},
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
nodeCharge: 1e5,
|
|
3884
|
-
nodeMass: 1,
|
|
3885
|
-
edgeEquilibriumLength: 300,
|
|
3886
|
-
edgeStiffness: 1e3,
|
|
3887
|
-
dtSec: 0.01,
|
|
3888
|
-
maxIterations: 1e3,
|
|
3889
|
-
convergenceVelocity: 10,
|
|
3890
|
-
maxForce: 1e7,
|
|
3891
|
-
nodeForceCoefficient: 1,
|
|
3892
|
-
barnesHutAreaRadiusThreshold: 0.01,
|
|
3893
|
-
barnesHutTheta: 1
|
|
3894
|
-
}), Qt = (r) => {
|
|
3895
|
-
var e, t, s;
|
|
3896
|
-
switch ((e = r == null ? void 0 : r.algorithm) == null ? void 0 : e.type) {
|
|
3901
|
+
const i = (r + e | 0) + s | 0;
|
|
3902
|
+
return s = s + 1 | 0, r = e ^ e >>> 9, e = t + (t << 3) | 0, t = t << 21 | t >>> 11, t = t + i | 0, (i >>> 0) / 4294967296;
|
|
3903
|
+
}, Jt = (r) => {
|
|
3904
|
+
var e, t;
|
|
3905
|
+
switch (r == null ? void 0 : r.type) {
|
|
3897
3906
|
case "custom":
|
|
3898
|
-
return r.
|
|
3907
|
+
return r.instance;
|
|
3899
3908
|
default: {
|
|
3900
|
-
const
|
|
3901
|
-
return new
|
|
3902
|
-
rand:
|
|
3903
|
-
maxTimeDeltaSec: (
|
|
3904
|
-
nodeCharge: (
|
|
3905
|
-
nodeMass: (
|
|
3906
|
-
edgeEquilibriumLength: (
|
|
3907
|
-
edgeStiffness: (
|
|
3908
|
-
convergenceVelocity: (
|
|
3909
|
-
maxForce: (
|
|
3910
|
-
nodeForceCoefficient: (
|
|
3911
|
-
barnesHutTheta: ((
|
|
3912
|
-
barnesHutAreaRadiusThreshold: ((
|
|
3909
|
+
const s = Oe((r == null ? void 0 : r.seed) ?? v.seed), i = We(s[0], s[1], s[2], s[3]);
|
|
3910
|
+
return new qt({
|
|
3911
|
+
rand: i,
|
|
3912
|
+
maxTimeDeltaSec: (r == null ? void 0 : r.maxTimeDeltaSec) ?? v.maxTimeDeltaSec,
|
|
3913
|
+
nodeCharge: (r == null ? void 0 : r.nodeCharge) ?? v.nodeCharge,
|
|
3914
|
+
nodeMass: (r == null ? void 0 : r.nodeMass) ?? v.nodeMass,
|
|
3915
|
+
edgeEquilibriumLength: (r == null ? void 0 : r.edgeEquilibriumLength) ?? v.edgeEquilibriumLength,
|
|
3916
|
+
edgeStiffness: (r == null ? void 0 : r.edgeStiffness) ?? v.edgeStiffness,
|
|
3917
|
+
convergenceVelocity: (r == null ? void 0 : r.convergenceVelocity) ?? v.convergenceVelocity,
|
|
3918
|
+
maxForce: (r == null ? void 0 : r.maxForce) ?? v.maxForce,
|
|
3919
|
+
nodeForceCoefficient: (r == null ? void 0 : r.nodeForceCoefficient) ?? v.nodeForceCoefficient,
|
|
3920
|
+
barnesHutTheta: ((e = r == null ? void 0 : r.barnesHut) == null ? void 0 : e.theta) ?? v.barnesHutTheta,
|
|
3921
|
+
barnesHutAreaRadiusThreshold: ((t = r == null ? void 0 : r.barnesHut) == null ? void 0 : t.areaRadiusThreshold) ?? v.barnesHutAreaRadiusThreshold
|
|
3913
3922
|
});
|
|
3914
3923
|
}
|
|
3915
3924
|
}
|
|
3916
|
-
},
|
|
3925
|
+
}, _t = {
|
|
3926
|
+
staticNodeResolver: () => !1
|
|
3927
|
+
}, er = (r) => ({
|
|
3928
|
+
algorithm: Jt((r == null ? void 0 : r.algorithm) ?? {}),
|
|
3929
|
+
staticNodeResolver: (r == null ? void 0 : r.staticNodeResolver) ?? _t.staticNodeResolver
|
|
3930
|
+
}), tr = (r) => r instanceof j ? {
|
|
3917
3931
|
type: "manual",
|
|
3918
3932
|
trigger: r
|
|
3919
3933
|
} : (r == null ? void 0 : r.type) === "topologyChangeMacrotask" ? {
|
|
3920
3934
|
type: "topologyChangeMacrotask"
|
|
3921
3935
|
} : {
|
|
3922
3936
|
type: "topologyChangeMicrotask"
|
|
3923
|
-
},
|
|
3937
|
+
}, rr = (r) => {
|
|
3924
3938
|
var e, t;
|
|
3925
3939
|
switch (r == null ? void 0 : r.type) {
|
|
3926
3940
|
case "custom":
|
|
3927
3941
|
return r.instance;
|
|
3928
3942
|
default: {
|
|
3929
|
-
const s = Oe((r == null ? void 0 : r.seed) ?? v.seed),
|
|
3930
|
-
return new
|
|
3943
|
+
const s = Oe((r == null ? void 0 : r.seed) ?? v.seed), i = We(s[0], s[1], s[2], s[3]);
|
|
3944
|
+
return new Zt({
|
|
3931
3945
|
dtSec: (r == null ? void 0 : r.dtSec) ?? v.dtSec,
|
|
3932
3946
|
maxIterations: (r == null ? void 0 : r.maxIterations) ?? v.maxIterations,
|
|
3933
|
-
rand:
|
|
3947
|
+
rand: i,
|
|
3934
3948
|
nodeCharge: (r == null ? void 0 : r.nodeCharge) ?? v.nodeCharge,
|
|
3935
3949
|
nodeMass: (r == null ? void 0 : r.nodeMass) ?? v.nodeMass,
|
|
3936
3950
|
edgeEquilibriumLength: (r == null ? void 0 : r.edgeEquilibriumLength) ?? v.edgeEquilibriumLength,
|
|
@@ -3943,10 +3957,13 @@ const Oe = (r) => {
|
|
|
3943
3957
|
});
|
|
3944
3958
|
}
|
|
3945
3959
|
}
|
|
3946
|
-
},
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3960
|
+
}, sr = {
|
|
3961
|
+
staticNodeResolver: () => !1
|
|
3962
|
+
}, or = (r) => ({
|
|
3963
|
+
algorithm: rr(r == null ? void 0 : r.algorithm),
|
|
3964
|
+
applyOn: tr(r == null ? void 0 : r.applyOn),
|
|
3965
|
+
staticNodeResolver: (r == null ? void 0 : r.staticNodeResolver) ?? sr.staticNodeResolver
|
|
3966
|
+
}), ir = (r, e) => ({
|
|
3950
3967
|
...r,
|
|
3951
3968
|
onNodeDragStarted: (t) => {
|
|
3952
3969
|
e.add(t), r.onNodeDragStarted(t);
|
|
@@ -3954,41 +3971,44 @@ const Oe = (r) => {
|
|
|
3954
3971
|
onNodeDragFinished: (t) => {
|
|
3955
3972
|
e.delete(t), r.onNodeDragFinished(t);
|
|
3956
3973
|
}
|
|
3957
|
-
}),
|
|
3974
|
+
}), nr = (r, e) => {
|
|
3958
3975
|
r.onBeforeNodeRemoved.subscribe((t) => {
|
|
3959
3976
|
e.delete(t);
|
|
3960
3977
|
}), r.onBeforeClear.subscribe(() => {
|
|
3961
3978
|
e.clear();
|
|
3962
3979
|
});
|
|
3963
|
-
}
|
|
3964
|
-
|
|
3980
|
+
}, ar = (r, e) => ({
|
|
3981
|
+
...r,
|
|
3982
|
+
staticNodeResolver: (t) => r.staticNodeResolver(t) || e.has(t)
|
|
3983
|
+
});
|
|
3984
|
+
class cr {
|
|
3965
3985
|
constructor(e) {
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
this.element = e, this.viewportStore = new
|
|
3986
|
+
o(this, "used", !1);
|
|
3987
|
+
o(this, "canvasDefaults", {});
|
|
3988
|
+
o(this, "dragConfig", {});
|
|
3989
|
+
o(this, "transformConfig", {});
|
|
3990
|
+
o(this, "backgroundConfig", {});
|
|
3991
|
+
o(this, "connectablePortsConfig", {});
|
|
3992
|
+
o(this, "draggableEdgesConfig", {});
|
|
3993
|
+
o(this, "virtualScrollConfig");
|
|
3994
|
+
o(this, "layoutConfig", {});
|
|
3995
|
+
o(this, "animatedLayoutConfig", {});
|
|
3996
|
+
o(this, "hasDraggableNodes", !1);
|
|
3997
|
+
o(this, "hasTransformableViewport", !1);
|
|
3998
|
+
o(this, "hasNodeResizeReactiveEdges", !1);
|
|
3999
|
+
o(this, "hasBackground", !1);
|
|
4000
|
+
o(this, "hasUserConnectablePorts", !1);
|
|
4001
|
+
o(this, "hasUserDraggableEdges", !1);
|
|
4002
|
+
o(this, "hasAnimatedLayout", !1);
|
|
4003
|
+
o(this, "hasLayout", !1);
|
|
4004
|
+
o(this, "boxRenderingTrigger", new j());
|
|
4005
|
+
o(this, "graphStore");
|
|
4006
|
+
o(this, "viewportStore");
|
|
4007
|
+
o(this, "graph");
|
|
4008
|
+
o(this, "viewport");
|
|
4009
|
+
o(this, "window", window);
|
|
4010
|
+
o(this, "animationStaticNodes", /* @__PURE__ */ new Set());
|
|
4011
|
+
this.element = e, this.viewportStore = new Ze(this.element), this.viewport = new Re(this.viewportStore), this.graphStore = new Ae(), this.graph = new Le(this.graphStore);
|
|
3992
4012
|
}
|
|
3993
4013
|
/**
|
|
3994
4014
|
* specifies default values for graph entities
|
|
@@ -4056,9 +4076,9 @@ class or {
|
|
|
4056
4076
|
*/
|
|
4057
4077
|
build() {
|
|
4058
4078
|
if (this.used)
|
|
4059
|
-
throw new
|
|
4079
|
+
throw new Yt("CanvasBuilder is a single use object");
|
|
4060
4080
|
this.used = !0;
|
|
4061
|
-
const e = new
|
|
4081
|
+
const e = new Mt(this.element), t = this.createHtmlView(e.main), s = Vt(this.canvasDefaults), i = new ve(
|
|
4062
4082
|
this.graph,
|
|
4063
4083
|
this.viewport,
|
|
4064
4084
|
this.graphStore,
|
|
@@ -4067,29 +4087,29 @@ class or {
|
|
|
4067
4087
|
s
|
|
4068
4088
|
);
|
|
4069
4089
|
if (this.hasBackground && _.configure(
|
|
4070
|
-
|
|
4071
|
-
|
|
4090
|
+
i,
|
|
4091
|
+
Wt(this.backgroundConfig),
|
|
4072
4092
|
e.background
|
|
4073
|
-
), this.hasNodeResizeReactiveEdges &&
|
|
4074
|
-
let a =
|
|
4075
|
-
this.hasAnimatedLayout && (a =
|
|
4093
|
+
), this.hasNodeResizeReactiveEdges && K.configure(i), this.hasDraggableNodes) {
|
|
4094
|
+
let a = Ft(this.dragConfig);
|
|
4095
|
+
this.hasAnimatedLayout && (a = ir(
|
|
4076
4096
|
a,
|
|
4077
4097
|
this.animationStaticNodes
|
|
4078
|
-
)),
|
|
4079
|
-
|
|
4098
|
+
)), q.configure(
|
|
4099
|
+
i,
|
|
4080
4100
|
e.main,
|
|
4081
4101
|
this.window,
|
|
4082
4102
|
a
|
|
4083
4103
|
);
|
|
4084
4104
|
}
|
|
4085
4105
|
if (this.hasUserConnectablePorts) {
|
|
4086
|
-
const a =
|
|
4106
|
+
const a = zt(
|
|
4087
4107
|
this.connectablePortsConfig,
|
|
4088
4108
|
s.edges.shapeFactory,
|
|
4089
4109
|
s.ports.direction
|
|
4090
4110
|
);
|
|
4091
4111
|
ee.configure(
|
|
4092
|
-
|
|
4112
|
+
i,
|
|
4093
4113
|
e.overlayConnectablePorts,
|
|
4094
4114
|
this.viewportStore,
|
|
4095
4115
|
this.window,
|
|
@@ -4097,46 +4117,49 @@ class or {
|
|
|
4097
4117
|
);
|
|
4098
4118
|
}
|
|
4099
4119
|
if (this.hasUserDraggableEdges) {
|
|
4100
|
-
const a =
|
|
4120
|
+
const a = kt(
|
|
4101
4121
|
this.draggableEdgesConfig,
|
|
4102
|
-
|
|
4122
|
+
i.graph
|
|
4103
4123
|
);
|
|
4104
4124
|
te.configure(
|
|
4105
|
-
|
|
4125
|
+
i,
|
|
4106
4126
|
e.overlayDraggableEdges,
|
|
4107
4127
|
this.viewportStore,
|
|
4108
4128
|
this.window,
|
|
4109
4129
|
a
|
|
4110
4130
|
);
|
|
4111
4131
|
}
|
|
4112
|
-
this.virtualScrollConfig !== void 0 ? J.configure(
|
|
4113
|
-
|
|
4132
|
+
if (this.virtualScrollConfig !== void 0 ? J.configure(
|
|
4133
|
+
i,
|
|
4114
4134
|
e.main,
|
|
4115
4135
|
this.window,
|
|
4116
|
-
|
|
4136
|
+
fe(this.transformConfig),
|
|
4117
4137
|
this.boxRenderingTrigger,
|
|
4118
|
-
|
|
4138
|
+
Ht(this.virtualScrollConfig)
|
|
4119
4139
|
) : this.hasTransformableViewport && H.configure(
|
|
4120
|
-
|
|
4140
|
+
i,
|
|
4121
4141
|
e.main,
|
|
4122
4142
|
this.window,
|
|
4123
|
-
|
|
4124
|
-
), this.hasLayout &&
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
), this.hasAnimatedLayout
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4143
|
+
fe(this.transformConfig)
|
|
4144
|
+
), this.hasLayout && Tt.configure(
|
|
4145
|
+
i,
|
|
4146
|
+
or(this.layoutConfig)
|
|
4147
|
+
), this.hasAnimatedLayout) {
|
|
4148
|
+
let a = er(
|
|
4149
|
+
this.animatedLayoutConfig
|
|
4150
|
+
);
|
|
4151
|
+
this.hasDraggableNodes && (nr(
|
|
4152
|
+
i.graph,
|
|
4153
|
+
this.animationStaticNodes
|
|
4154
|
+
), a = ar(
|
|
4155
|
+
a,
|
|
4156
|
+
this.animationStaticNodes
|
|
4157
|
+
)), se.configure(i, a, this.window);
|
|
4158
|
+
}
|
|
4136
4159
|
const n = () => {
|
|
4137
|
-
e.destroy(),
|
|
4160
|
+
e.destroy(), i.onBeforeDestroy.unsubscribe(n);
|
|
4138
4161
|
};
|
|
4139
|
-
return
|
|
4162
|
+
return i.onBeforeDestroy.subscribe(n), i;
|
|
4140
4163
|
}
|
|
4141
4164
|
createHtmlView(e) {
|
|
4142
4165
|
let t = new me(
|
|
@@ -4148,14 +4171,14 @@ class or {
|
|
|
4148
4171
|
t,
|
|
4149
4172
|
this.graphStore,
|
|
4150
4173
|
this.boxRenderingTrigger,
|
|
4151
|
-
|
|
4152
|
-
)), new
|
|
4174
|
+
Xt(this.virtualScrollConfig)
|
|
4175
|
+
)), new Ke(t, this.graphStore);
|
|
4153
4176
|
}
|
|
4154
4177
|
}
|
|
4155
4178
|
export {
|
|
4156
4179
|
ut as BezierEdgeShape,
|
|
4157
|
-
|
|
4158
|
-
|
|
4180
|
+
cr as CanvasBuilder,
|
|
4181
|
+
Yt as CanvasBuilderError,
|
|
4159
4182
|
A as CanvasError,
|
|
4160
4183
|
M as ConnectionCategory,
|
|
4161
4184
|
De as DirectEdgeShape,
|
|
@@ -4163,7 +4186,7 @@ export {
|
|
|
4163
4186
|
pt as HorizontalEdgeShape,
|
|
4164
4187
|
vt as InteractiveEdgeError,
|
|
4165
4188
|
Me as InteractiveEdgeShape,
|
|
4166
|
-
|
|
4189
|
+
dr as MidpointEdgeShape,
|
|
4167
4190
|
wt as StraightEdgeShape,
|
|
4168
|
-
|
|
4191
|
+
yt as VerticalEdgeShape
|
|
4169
4192
|
};
|