@html-graph/html-graph 3.12.0 → 3.14.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/README.md +1 -1
- package/dist/html-graph.d.ts +64 -23
- package/dist/html-graph.js +1947 -1771
- package/dist/html-graph.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/html-graph.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var o = (r, e, t) =>
|
|
4
|
-
const
|
|
1
|
+
var Ne = Object.defineProperty;
|
|
2
|
+
var Me = (r, e, t) => e in r ? Ne(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
|
+
var o = (r, e, t) => Me(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
const Le = () => {
|
|
5
5
|
const r = document.createElement("div");
|
|
6
6
|
return r.style.position = "absolute", r.style.top = "0", r.style.left = "0", r.style.width = "0", r.style.height = "0", r;
|
|
7
|
-
},
|
|
7
|
+
}, Re = () => {
|
|
8
8
|
const r = document.createElement("div");
|
|
9
9
|
return r.style.width = "100%", r.style.height = "100%", r.style.position = "relative", r.style.overflow = "hidden", r;
|
|
10
|
-
},
|
|
10
|
+
}, Ce = (r) => {
|
|
11
11
|
r.style.position = "absolute", r.style.top = "0", r.style.left = "0", r.style.visibility = "hidden";
|
|
12
|
-
},
|
|
12
|
+
}, T = (r, e) => ({
|
|
13
13
|
x: r.scale * e.x + r.x,
|
|
14
14
|
y: r.scale * e.y + r.y
|
|
15
15
|
});
|
|
16
|
-
class
|
|
16
|
+
class ue {
|
|
17
17
|
constructor(e, t, s) {
|
|
18
|
-
o(this, "host",
|
|
19
|
-
o(this, "container",
|
|
18
|
+
o(this, "host", Re());
|
|
19
|
+
o(this, "container", Le());
|
|
20
20
|
o(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
|
|
21
21
|
o(this, "applyTransform", () => {
|
|
22
22
|
const e = this.viewportStore.getContentMatrix();
|
|
@@ -26,7 +26,7 @@ class ne {
|
|
|
26
26
|
}
|
|
27
27
|
attachNode(e) {
|
|
28
28
|
const t = this.graphStore.getNode(e);
|
|
29
|
-
|
|
29
|
+
Ce(t.element), this.container.appendChild(t.element), this.updateNodePosition(e), this.updateNodePriority(e), t.element.style.visibility = "visible";
|
|
30
30
|
}
|
|
31
31
|
detachNode(e) {
|
|
32
32
|
const t = this.graphStore.getNode(e);
|
|
@@ -71,14 +71,14 @@ class ne {
|
|
|
71
71
|
n,
|
|
72
72
|
a,
|
|
73
73
|
d
|
|
74
|
-
),
|
|
74
|
+
), l = this.createEdgeRenderPort(
|
|
75
75
|
t.to,
|
|
76
76
|
i,
|
|
77
77
|
h,
|
|
78
78
|
a,
|
|
79
79
|
d
|
|
80
80
|
);
|
|
81
|
-
t.shape.render({ from: c, to:
|
|
81
|
+
t.shape.render({ from: c, to: l });
|
|
82
82
|
}
|
|
83
83
|
updateEdgePriority(e) {
|
|
84
84
|
const t = this.graphStore.getEdge(e);
|
|
@@ -88,7 +88,7 @@ class ne {
|
|
|
88
88
|
const h = {
|
|
89
89
|
x: s.left - i.left,
|
|
90
90
|
y: s.top - i.top
|
|
91
|
-
}, a =
|
|
91
|
+
}, a = T(n, h);
|
|
92
92
|
return {
|
|
93
93
|
x: a.x,
|
|
94
94
|
y: a.y,
|
|
@@ -100,7 +100,7 @@ class ne {
|
|
|
100
100
|
};
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
class
|
|
103
|
+
class Ie {
|
|
104
104
|
constructor(e) {
|
|
105
105
|
o(this, "xFrom", 1 / 0);
|
|
106
106
|
o(this, "yFrom", 1 / 0);
|
|
@@ -116,11 +116,11 @@ class be {
|
|
|
116
116
|
return t.x >= this.xFrom && t.x <= this.xTo && t.y >= this.yFrom && t.y <= this.yTo;
|
|
117
117
|
}
|
|
118
118
|
hasEdge(e) {
|
|
119
|
-
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), h = this.graphStore.getNode(i), a = Math.min(n.x, h.x), d = Math.max(n.x, h.x), c = Math.min(n.y, h.y),
|
|
120
|
-
return a <= this.xTo && d >= this.xFrom && c <= this.yTo &&
|
|
119
|
+
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), h = this.graphStore.getNode(i), a = Math.min(n.x, h.x), d = Math.max(n.x, h.x), c = Math.min(n.y, h.y), l = Math.max(n.y, h.y);
|
|
120
|
+
return a <= this.xTo && d >= this.xFrom && c <= this.yTo && l >= this.yFrom;
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
|
-
class
|
|
123
|
+
class Ue {
|
|
124
124
|
constructor(e, t, s) {
|
|
125
125
|
o(this, "attachedNodes", /* @__PURE__ */ new Set());
|
|
126
126
|
o(this, "attachedEdges", /* @__PURE__ */ new Set());
|
|
@@ -132,8 +132,8 @@ class Te {
|
|
|
132
132
|
const a = this.renderingBox.hasNode(h), d = this.attachedNodes.has(h);
|
|
133
133
|
a && !d ? t.add(h) : !a && d && s.add(h);
|
|
134
134
|
}), this.graphStore.getAllEdgeIds().forEach((h) => {
|
|
135
|
-
const a = this.renderingBox.hasEdge(h), d = this.attachedEdges.has(h), c = this.graphStore.getEdge(h),
|
|
136
|
-
a && (this.renderingBox.hasNode(
|
|
135
|
+
const a = this.renderingBox.hasEdge(h), d = this.attachedEdges.has(h), c = this.graphStore.getEdge(h), l = this.graphStore.getPort(c.from).nodeId, g = this.graphStore.getPort(c.to).nodeId;
|
|
136
|
+
a && (this.renderingBox.hasNode(l) || (t.add(l), s.delete(l)), this.renderingBox.hasNode(g) || (t.add(g), s.delete(g))), a && !d ? i.add(h) : !a && d && n.add(h);
|
|
137
137
|
}), n.forEach((h) => {
|
|
138
138
|
this.handleDetachEdge(h);
|
|
139
139
|
}), s.forEach((h) => {
|
|
@@ -144,7 +144,7 @@ class Te {
|
|
|
144
144
|
this.handleAttachEdge(h);
|
|
145
145
|
});
|
|
146
146
|
});
|
|
147
|
-
this.htmlView = e, this.graphStore = t, this.trigger = s, this.renderingBox = new
|
|
147
|
+
this.htmlView = e, this.graphStore = t, this.trigger = s, this.renderingBox = new Ie(this.graphStore), this.trigger.subscribe(this.updateViewport);
|
|
148
148
|
}
|
|
149
149
|
attachNode(e) {
|
|
150
150
|
this.renderingBox.hasNode(e) && this.handleAttachNode(e);
|
|
@@ -198,7 +198,7 @@ class Te {
|
|
|
198
198
|
this.htmlView.detachEdge(e), this.attachedEdges.delete(e);
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
|
-
class
|
|
201
|
+
class pe {
|
|
202
202
|
constructor() {
|
|
203
203
|
o(this, "callbacks", /* @__PURE__ */ new Set());
|
|
204
204
|
}
|
|
@@ -214,11 +214,11 @@ class he {
|
|
|
214
214
|
});
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
-
const
|
|
218
|
-
const r = new
|
|
217
|
+
const A = () => {
|
|
218
|
+
const r = new pe();
|
|
219
219
|
return [r, r];
|
|
220
220
|
};
|
|
221
|
-
class
|
|
221
|
+
class Ve {
|
|
222
222
|
constructor(e) {
|
|
223
223
|
o(this, "onBeforeUpdated");
|
|
224
224
|
o(this, "onAfterUpdated");
|
|
@@ -231,7 +231,7 @@ class Pe {
|
|
|
231
231
|
return { ...this.viewportStore.getContentMatrix() };
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
|
-
class
|
|
234
|
+
class Be {
|
|
235
235
|
constructor(e) {
|
|
236
236
|
o(this, "onAfterNodeAdded");
|
|
237
237
|
o(this, "onAfterNodeUpdated");
|
|
@@ -261,7 +261,6 @@ class De {
|
|
|
261
261
|
getElementNodeId(e) {
|
|
262
262
|
return this.graphStore.getElementNodeId(e) ?? null;
|
|
263
263
|
}
|
|
264
|
-
// TODO: use Set in v4
|
|
265
264
|
getAllNodeIds() {
|
|
266
265
|
return this.graphStore.getAllNodeIds();
|
|
267
266
|
}
|
|
@@ -273,60 +272,74 @@ class De {
|
|
|
273
272
|
nodeId: t.nodeId
|
|
274
273
|
};
|
|
275
274
|
}
|
|
276
|
-
// TODO: use Set in v4
|
|
277
275
|
getAllPortIds() {
|
|
278
276
|
return this.graphStore.getAllPortIds();
|
|
279
277
|
}
|
|
280
|
-
// TODO: use Set in v4
|
|
281
278
|
getNodePortIds(e) {
|
|
282
279
|
return this.graphStore.getNodePortIds(e) ?? null;
|
|
283
280
|
}
|
|
284
|
-
|
|
281
|
+
getElementPortIds(e) {
|
|
282
|
+
return [...this.graphStore.getElementPortIds(e)];
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* @deprecated
|
|
286
|
+
* use getElementPortIds instead
|
|
287
|
+
*/
|
|
285
288
|
getElementPortsIds(e) {
|
|
286
|
-
return
|
|
289
|
+
return this.getElementPortIds(e);
|
|
287
290
|
}
|
|
288
|
-
// TODO: use Set in v4
|
|
289
291
|
getAllEdgeIds() {
|
|
290
292
|
return this.graphStore.getAllEdgeIds();
|
|
291
293
|
}
|
|
292
294
|
getEdge(e) {
|
|
293
295
|
const t = this.graphStore.getEdge(e);
|
|
294
|
-
return t === void 0 ? null : {
|
|
296
|
+
return t === void 0 ? null : {
|
|
297
|
+
from: t.from,
|
|
298
|
+
to: t.to,
|
|
299
|
+
priority: t.priority,
|
|
300
|
+
shape: t.shape
|
|
301
|
+
};
|
|
295
302
|
}
|
|
296
|
-
// TODO: use Set in v4
|
|
297
303
|
getPortIncomingEdgeIds(e) {
|
|
298
304
|
return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortIncomingEdgeIds(e);
|
|
299
305
|
}
|
|
300
|
-
|
|
306
|
+
getPortOutgoingEdgeIds(e) {
|
|
307
|
+
return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortOutgoingEdgeIds(e);
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* @deprecated
|
|
311
|
+
* use getPortOutgoingEdgeIds instead
|
|
312
|
+
*/
|
|
301
313
|
getPortOutcomingEdgeIds(e) {
|
|
302
|
-
return this.
|
|
314
|
+
return this.getPortOutgoingEdgeIds(e);
|
|
303
315
|
}
|
|
304
|
-
// TODO: use Set in v4
|
|
305
316
|
getPortCycleEdgeIds(e) {
|
|
306
317
|
return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortCycleEdgeIds(e);
|
|
307
318
|
}
|
|
308
|
-
// TODO: use Set in v4
|
|
309
319
|
getPortAdjacentEdgeIds(e) {
|
|
310
320
|
return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortAdjacentEdgeIds(e);
|
|
311
321
|
}
|
|
312
|
-
// TODO: use Set in v4
|
|
313
322
|
getNodeIncomingEdgeIds(e) {
|
|
314
323
|
return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeIncomingEdgeIds(e);
|
|
315
324
|
}
|
|
316
|
-
|
|
325
|
+
getNodeOutgoingEdgeIds(e) {
|
|
326
|
+
return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeOutgoingEdgeIds(e);
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* @deprecated
|
|
330
|
+
* use getNodeOutgoingEdgeIds instead
|
|
331
|
+
*/
|
|
317
332
|
getNodeOutcomingEdgeIds(e) {
|
|
318
|
-
return this.
|
|
333
|
+
return this.getNodeOutgoingEdgeIds(e);
|
|
319
334
|
}
|
|
320
|
-
// TODO: use Set in v4
|
|
321
335
|
getNodeCycleEdgeIds(e) {
|
|
322
336
|
return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeCycleEdgeIds(e);
|
|
323
337
|
}
|
|
324
|
-
// TODO: use Set in v4
|
|
325
338
|
getNodeAdjacentEdgeIds(e) {
|
|
326
339
|
return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeAdjacentEdgeIds(e);
|
|
327
340
|
}
|
|
328
341
|
}
|
|
329
|
-
class
|
|
342
|
+
class O {
|
|
330
343
|
constructor(e) {
|
|
331
344
|
o(this, "counter", 0);
|
|
332
345
|
this.checkExists = e;
|
|
@@ -348,7 +361,7 @@ class S extends Error {
|
|
|
348
361
|
o(this, "name", "HtmlGraphError");
|
|
349
362
|
}
|
|
350
363
|
}
|
|
351
|
-
class
|
|
364
|
+
class we {
|
|
352
365
|
constructor(e, t, s, i, n) {
|
|
353
366
|
/**
|
|
354
367
|
* provides api for accessing model of rendered graph
|
|
@@ -358,13 +371,13 @@ class ae {
|
|
|
358
371
|
* provides api for accessing viewport state
|
|
359
372
|
*/
|
|
360
373
|
o(this, "viewport");
|
|
361
|
-
o(this, "nodeIdGenerator", new
|
|
374
|
+
o(this, "nodeIdGenerator", new O(
|
|
362
375
|
(e) => this.graph.getNode(e) !== null
|
|
363
376
|
));
|
|
364
|
-
o(this, "portIdGenerator", new
|
|
377
|
+
o(this, "portIdGenerator", new O(
|
|
365
378
|
(e) => this.graph.getPort(e) !== null
|
|
366
379
|
));
|
|
367
|
-
o(this, "edgeIdGenerator", new
|
|
380
|
+
o(this, "edgeIdGenerator", new O(
|
|
368
381
|
(e) => this.graph.getEdge(e) !== null
|
|
369
382
|
));
|
|
370
383
|
o(this, "onAfterNodeAdded", (e) => {
|
|
@@ -416,13 +429,13 @@ class ae {
|
|
|
416
429
|
* emits event just before destruction of canvas
|
|
417
430
|
*/
|
|
418
431
|
o(this, "onBeforeDestroy");
|
|
419
|
-
this.element = e, this.graphStore = t, this.viewportStore = s, this.htmlView = i, this.
|
|
432
|
+
this.element = e, this.graphStore = t, this.viewportStore = s, this.htmlView = i, this.params = n, this.graph = new Be(this.graphStore), this.viewport = new Ve(this.viewportStore), this.graphStore.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graphStore.onAfterNodeUpdated.subscribe(this.onAfterNodeUpdated), this.graphStore.onAfterNodePriorityUpdated.subscribe(
|
|
420
433
|
this.onAfterNodePriorityUpdated
|
|
421
434
|
), 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(
|
|
422
435
|
this.onAfterEdgeShapeUpdated
|
|
423
436
|
), this.graphStore.onAfterEdgeUpdated.subscribe(this.onAfterEdgeUpdated), this.graphStore.onAfterEdgePriorityUpdated.subscribe(
|
|
424
437
|
this.onAfterEdgePriorityUpdated
|
|
425
|
-
), this.graphStore.onBeforeEdgeRemoved.subscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.subscribe(this.onBeforeClear), [this.onBeforeDestroyEmitter, this.onBeforeDestroy] =
|
|
438
|
+
), this.graphStore.onBeforeEdgeRemoved.subscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.subscribe(this.onBeforeClear), [this.onBeforeDestroyEmitter, this.onBeforeDestroy] = A();
|
|
426
439
|
}
|
|
427
440
|
/**
|
|
428
441
|
* adds new node
|
|
@@ -440,8 +453,8 @@ class ae {
|
|
|
440
453
|
element: e.element,
|
|
441
454
|
x: e.x,
|
|
442
455
|
y: e.y,
|
|
443
|
-
centerFn: e.centerFn ?? this.
|
|
444
|
-
priority: e.priority ?? this.
|
|
456
|
+
centerFn: e.centerFn ?? this.params.nodes.centerFn,
|
|
457
|
+
priority: e.priority ?? this.params.nodes.priorityFn()
|
|
445
458
|
}), e.ports !== void 0)
|
|
446
459
|
for (const s of e.ports)
|
|
447
460
|
this.markPort({
|
|
@@ -483,7 +496,7 @@ class ae {
|
|
|
483
496
|
id: t,
|
|
484
497
|
element: e.element,
|
|
485
498
|
nodeId: e.nodeId,
|
|
486
|
-
direction: e.direction ?? this.
|
|
499
|
+
direction: e.direction ?? this.params.ports.direction
|
|
487
500
|
}), this;
|
|
488
501
|
}
|
|
489
502
|
/**
|
|
@@ -518,8 +531,8 @@ class ae {
|
|
|
518
531
|
id: t,
|
|
519
532
|
from: e.from,
|
|
520
533
|
to: e.to,
|
|
521
|
-
shape: e.shape ?? this.
|
|
522
|
-
priority: e.priority ?? this.
|
|
534
|
+
shape: e.shape ?? this.params.edges.shapeFactory(t),
|
|
535
|
+
priority: e.priority ?? this.params.edges.priorityFn()
|
|
523
536
|
}), this;
|
|
524
537
|
}
|
|
525
538
|
/**
|
|
@@ -571,7 +584,7 @@ class ae {
|
|
|
571
584
|
), this.graphStore.onBeforeEdgeRemoved.unsubscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.unsubscribe(this.onBeforeClear), this.htmlView.destroy();
|
|
572
585
|
}
|
|
573
586
|
}
|
|
574
|
-
class
|
|
587
|
+
class We {
|
|
575
588
|
constructor() {
|
|
576
589
|
o(this, "singleToMultiMap", /* @__PURE__ */ new Map());
|
|
577
590
|
o(this, "multiToSingleMap", /* @__PURE__ */ new Map());
|
|
@@ -611,7 +624,7 @@ class Ne {
|
|
|
611
624
|
return this.multiToSingleMap.get(e) !== void 0;
|
|
612
625
|
}
|
|
613
626
|
}
|
|
614
|
-
class
|
|
627
|
+
class fe {
|
|
615
628
|
constructor() {
|
|
616
629
|
o(this, "nodes", /* @__PURE__ */ new Map());
|
|
617
630
|
o(this, "ports", /* @__PURE__ */ new Map());
|
|
@@ -620,7 +633,7 @@ class de {
|
|
|
620
633
|
o(this, "incomingEdges", /* @__PURE__ */ new Map());
|
|
621
634
|
o(this, "outcomingEdges", /* @__PURE__ */ new Map());
|
|
622
635
|
o(this, "cycleEdges", /* @__PURE__ */ new Map());
|
|
623
|
-
o(this, "elementPorts", new
|
|
636
|
+
o(this, "elementPorts", new We());
|
|
624
637
|
o(this, "afterNodeAddedEmitter");
|
|
625
638
|
o(this, "onAfterNodeAdded");
|
|
626
639
|
o(this, "afterNodeUpdatedEmitter");
|
|
@@ -647,7 +660,7 @@ class de {
|
|
|
647
660
|
o(this, "onBeforeEdgeRemoved");
|
|
648
661
|
o(this, "beforeClearEmitter");
|
|
649
662
|
o(this, "onBeforeClear");
|
|
650
|
-
[this.afterNodeAddedEmitter, this.onAfterNodeAdded] =
|
|
663
|
+
[this.afterNodeAddedEmitter, this.onAfterNodeAdded] = A(), [this.afterNodeUpdatedEmitter, this.onAfterNodeUpdated] = A(), [this.afterNodePriorityUpdatedEmitter, this.onAfterNodePriorityUpdated] = A(), [this.beforeNodeRemovedEmitter, this.onBeforeNodeRemoved] = A(), [this.afterPortAddedEmitter, this.onAfterPortAdded] = A(), [this.afterPortUpdatedEmitter, this.onAfterPortUpdated] = A(), [this.beforePortRemovedEmitter, this.onBeforePortRemoved] = A(), [this.afterEdgeAddedEmitter, this.onAfterEdgeAdded] = A(), [this.afterEdgeShapeUpdatedEmitter, this.onAfterEdgeShapeUpdated] = A(), [this.afterEdgeUpdatedEmitter, this.onAfterEdgeUpdated] = A(), [this.afterEdgePriorityUpdatedEmitter, this.onAfterEdgePriorityUpdated] = A(), [this.beforeEdgeRemovedEmitter, this.onBeforeEdgeRemoved] = A(), [this.beforeClearEmitter, this.onBeforeClear] = A();
|
|
651
664
|
}
|
|
652
665
|
addNode(e) {
|
|
653
666
|
const t = /* @__PURE__ */ new Map(), s = {
|
|
@@ -695,7 +708,7 @@ class de {
|
|
|
695
708
|
getAllPortIds() {
|
|
696
709
|
return Array.from(this.ports.keys());
|
|
697
710
|
}
|
|
698
|
-
|
|
711
|
+
getElementPortIds(e) {
|
|
699
712
|
return this.elementPorts.getMultiBySingle(e);
|
|
700
713
|
}
|
|
701
714
|
getNodePortIds(e) {
|
|
@@ -739,7 +752,7 @@ class de {
|
|
|
739
752
|
getPortIncomingEdgeIds(e) {
|
|
740
753
|
return Array.from(this.incomingEdges.get(e));
|
|
741
754
|
}
|
|
742
|
-
|
|
755
|
+
getPortOutgoingEdgeIds(e) {
|
|
743
756
|
return Array.from(this.outcomingEdges.get(e));
|
|
744
757
|
}
|
|
745
758
|
getPortCycleEdgeIds(e) {
|
|
@@ -748,7 +761,7 @@ class de {
|
|
|
748
761
|
getPortAdjacentEdgeIds(e) {
|
|
749
762
|
return [
|
|
750
763
|
...this.getPortIncomingEdgeIds(e),
|
|
751
|
-
...this.
|
|
764
|
+
...this.getPortOutgoingEdgeIds(e),
|
|
752
765
|
...this.getPortCycleEdgeIds(e)
|
|
753
766
|
];
|
|
754
767
|
}
|
|
@@ -759,11 +772,11 @@ class de {
|
|
|
759
772
|
s = [...s, ...this.getPortIncomingEdgeIds(i)];
|
|
760
773
|
}), s;
|
|
761
774
|
}
|
|
762
|
-
|
|
775
|
+
getNodeOutgoingEdgeIds(e) {
|
|
763
776
|
const t = Array.from(this.nodes.get(e).ports.keys());
|
|
764
777
|
let s = [];
|
|
765
778
|
return t.forEach((i) => {
|
|
766
|
-
s = [...s, ...this.
|
|
779
|
+
s = [...s, ...this.getPortOutgoingEdgeIds(i)];
|
|
767
780
|
}), s;
|
|
768
781
|
}
|
|
769
782
|
getNodeCycleEdgeIds(e) {
|
|
@@ -776,7 +789,7 @@ class de {
|
|
|
776
789
|
getNodeAdjacentEdgeIds(e) {
|
|
777
790
|
return [
|
|
778
791
|
...this.getNodeIncomingEdgeIds(e),
|
|
779
|
-
...this.
|
|
792
|
+
...this.getNodeOutgoingEdgeIds(e),
|
|
780
793
|
...this.getNodeCycleEdgeIds(e)
|
|
781
794
|
];
|
|
782
795
|
}
|
|
@@ -793,24 +806,24 @@ class de {
|
|
|
793
806
|
this.cycleEdges.get(s).delete(e), this.cycleEdges.get(i).delete(e), this.incomingEdges.get(s).delete(e), this.incomingEdges.get(i).delete(e), this.outcomingEdges.get(s).delete(e), this.outcomingEdges.get(i).delete(e), this.edges.delete(e);
|
|
794
807
|
}
|
|
795
808
|
}
|
|
796
|
-
const
|
|
809
|
+
const se = (r) => ({
|
|
797
810
|
scale: 1 / r.scale,
|
|
798
811
|
x: -r.x / r.scale,
|
|
799
812
|
y: -r.y / r.scale
|
|
800
|
-
}),
|
|
813
|
+
}), ie = {
|
|
801
814
|
scale: 1,
|
|
802
815
|
x: 0,
|
|
803
816
|
y: 0
|
|
804
817
|
};
|
|
805
|
-
class
|
|
818
|
+
class $e {
|
|
806
819
|
constructor() {
|
|
807
|
-
o(this, "viewportMatrix",
|
|
808
|
-
o(this, "contentMatrix",
|
|
820
|
+
o(this, "viewportMatrix", ie);
|
|
821
|
+
o(this, "contentMatrix", ie);
|
|
809
822
|
o(this, "afterUpdateEmitter");
|
|
810
823
|
o(this, "onAfterUpdated");
|
|
811
824
|
o(this, "beforeUpdateEmitter");
|
|
812
825
|
o(this, "onBeforeUpdated");
|
|
813
|
-
[this.afterUpdateEmitter, this.onAfterUpdated] =
|
|
826
|
+
[this.afterUpdateEmitter, this.onAfterUpdated] = A(), [this.beforeUpdateEmitter, this.onBeforeUpdated] = A();
|
|
814
827
|
}
|
|
815
828
|
getViewportMatrix() {
|
|
816
829
|
return this.viewportMatrix;
|
|
@@ -823,17 +836,17 @@ class Me {
|
|
|
823
836
|
scale: e.scale ?? this.viewportMatrix.scale,
|
|
824
837
|
x: e.x ?? this.viewportMatrix.x,
|
|
825
838
|
y: e.y ?? this.viewportMatrix.y
|
|
826
|
-
}, this.contentMatrix =
|
|
839
|
+
}, this.contentMatrix = se(this.viewportMatrix), this.afterUpdateEmitter.emit();
|
|
827
840
|
}
|
|
828
841
|
patchContentMatrix(e) {
|
|
829
842
|
this.beforeUpdateEmitter.emit(), this.contentMatrix = {
|
|
830
843
|
scale: e.scale ?? this.contentMatrix.scale,
|
|
831
844
|
x: e.x ?? this.contentMatrix.x,
|
|
832
845
|
y: e.y ?? this.contentMatrix.y
|
|
833
|
-
}, this.viewportMatrix =
|
|
846
|
+
}, this.viewportMatrix = se(this.contentMatrix), this.afterUpdateEmitter.emit();
|
|
834
847
|
}
|
|
835
848
|
}
|
|
836
|
-
class
|
|
849
|
+
class Y {
|
|
837
850
|
constructor(e) {
|
|
838
851
|
o(this, "elementToNodeId", /* @__PURE__ */ new Map());
|
|
839
852
|
o(this, "nodesResizeObserver");
|
|
@@ -859,1757 +872,1761 @@ class k {
|
|
|
859
872
|
}), this.canvas.graph.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.canvas.graph.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.canvas.graph.onBeforeClear.subscribe(this.onBeforeClear), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
|
|
860
873
|
}
|
|
861
874
|
static configure(e) {
|
|
862
|
-
new
|
|
875
|
+
new Y(e);
|
|
863
876
|
}
|
|
864
877
|
handleNodeResize(e) {
|
|
865
878
|
const t = this.elementToNodeId.get(e);
|
|
866
879
|
this.canvas.updateNode(t);
|
|
867
880
|
}
|
|
868
881
|
}
|
|
869
|
-
const
|
|
870
|
-
var p, f, v, A, m, x;
|
|
871
|
-
const e = ((p = r == null ? void 0 : r.events) == null ? void 0 : p.onNodeDrag) ?? (() => {
|
|
872
|
-
}), t = ((f = r == null ? void 0 : r.events) == null ? void 0 : f.onBeforeNodeDrag) ?? (() => !0), s = ((v = r == null ? void 0 : r.events) == null ? void 0 : v.onNodeDragFinished) ?? (() => {
|
|
873
|
-
}), i = (r == null ? void 0 : r.moveOnTop) !== !1, n = (r == null ? void 0 : r.moveEdgesOnTop) !== !1 && i, h = (A = r == null ? void 0 : r.mouse) == null ? void 0 : A.dragCursor, a = h !== void 0 ? h : "grab", d = (m = r == null ? void 0 : r.mouse) == null ? void 0 : m.mouseDownEventVerifier, c = d !== void 0 ? d : (b) => b.button === 0, g = (x = r == null ? void 0 : r.mouse) == null ? void 0 : x.mouseUpEventVerifier;
|
|
874
|
-
return {
|
|
875
|
-
moveOnTop: i,
|
|
876
|
-
moveEdgesOnTop: n,
|
|
877
|
-
dragCursor: a,
|
|
878
|
-
mouseDownEventVerifier: c,
|
|
879
|
-
mouseUpEventVerifier: g !== void 0 ? g : (b) => b.button === 0,
|
|
880
|
-
onNodeDrag: e,
|
|
881
|
-
onBeforeNodeDrag: t,
|
|
882
|
-
onNodeDragFinished: s
|
|
883
|
-
};
|
|
884
|
-
}, Re = (r, e, t) => {
|
|
882
|
+
const Fe = (r, e, t) => {
|
|
885
883
|
const { x: s, y: i, width: n, height: h } = r.getBoundingClientRect();
|
|
886
884
|
return e >= s && e <= s + n && t >= i && t <= i + h;
|
|
887
|
-
},
|
|
885
|
+
}, Oe = (r, e, t) => e >= 0 && e <= r.innerWidth && t >= 0 && t <= r.innerHeight, L = (r, e, t, s) => Fe(e, t, s) && Oe(r, t, s), U = (r, e) => {
|
|
888
886
|
e !== null ? r.style.cursor = e : r.style.removeProperty("cursor");
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
}), t.element.addEventListener("touchstart", this.onTouchStart, {
|
|
902
|
-
passive: !0
|
|
903
|
-
});
|
|
904
|
-
});
|
|
905
|
-
o(this, "onAfterNodeUpdated", (e) => {
|
|
906
|
-
this.updateMaxNodePriority(e);
|
|
907
|
-
});
|
|
908
|
-
o(this, "onBeforeNodeRemoved", (e) => {
|
|
909
|
-
const t = this.graph.getNode(e);
|
|
910
|
-
t.element.removeEventListener("mousedown", this.onMouseDown), t.element.removeEventListener("touchstart", this.onTouchStart);
|
|
911
|
-
});
|
|
912
|
-
o(this, "onBeforeDestroy", () => {
|
|
913
|
-
this.graph.onAfterNodeAdded.unsubscribe(this.onAfterNodeAdded), this.graph.onAfterNodeUpdated.unsubscribe(this.onAfterNodeUpdated), this.graph.onBeforeNodeRemoved.unsubscribe(this.onBeforeNodeRemoved), this.graph.onBeforeClear.unsubscribe(this.onBeforeClear), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy), this.removeMouseDragListeners(), this.removeTouchDragListeners();
|
|
914
|
-
});
|
|
915
|
-
o(this, "onBeforeClear", () => {
|
|
916
|
-
this.canvas.graph.getAllNodeIds().forEach((e) => {
|
|
917
|
-
const t = this.canvas.graph.getNode(e);
|
|
918
|
-
t.element.removeEventListener("mousedown", this.onMouseDown), t.element.removeEventListener("touchstart", this.onTouchStart);
|
|
919
|
-
}), this.maxNodePriority = 0;
|
|
920
|
-
});
|
|
921
|
-
o(this, "onMouseDown", (e) => {
|
|
922
|
-
if (!this.config.mouseDownEventVerifier(e))
|
|
923
|
-
return;
|
|
924
|
-
const t = e.currentTarget, s = this.graph.getElementNodeId(t), i = this.graph.getNode(s);
|
|
925
|
-
this.config.onBeforeNodeDrag({
|
|
926
|
-
nodeId: s,
|
|
927
|
-
element: i.element,
|
|
928
|
-
x: i.x,
|
|
929
|
-
y: i.y
|
|
930
|
-
}) && (e.stopImmediatePropagation(), this.grabbedNodeId = s, B(this.element, this.config.dragCursor), this.moveNodeOnTop(s), this.window.addEventListener("mouseup", this.onWindowMouseUp, {
|
|
931
|
-
passive: !0
|
|
932
|
-
}), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
|
|
933
|
-
passive: !0
|
|
934
|
-
}));
|
|
935
|
-
});
|
|
936
|
-
o(this, "onTouchStart", (e) => {
|
|
937
|
-
if (e.touches.length !== 1)
|
|
938
|
-
return;
|
|
939
|
-
e.stopImmediatePropagation(), this.previousTouchCoordinates = {
|
|
940
|
-
x: e.touches[0].clientX,
|
|
941
|
-
y: e.touches[0].clientY
|
|
942
|
-
};
|
|
943
|
-
const t = e.currentTarget, s = this.canvas.graph.getElementNodeId(t), i = this.graph.getNode(s);
|
|
944
|
-
this.config.onBeforeNodeDrag({
|
|
945
|
-
nodeId: s,
|
|
946
|
-
element: i.element,
|
|
947
|
-
x: i.x,
|
|
948
|
-
y: i.y
|
|
949
|
-
}) && (this.grabbedNodeId = s, this.moveNodeOnTop(s), this.window.addEventListener("touchmove", this.onWindowTouchMove, {
|
|
950
|
-
passive: !0
|
|
951
|
-
}), this.window.addEventListener("touchend", this.onWindowTouchFinish, {
|
|
952
|
-
passive: !0
|
|
953
|
-
}), this.window.addEventListener("touchcancel", this.onWindowTouchFinish, {
|
|
954
|
-
passive: !0
|
|
955
|
-
}));
|
|
956
|
-
});
|
|
957
|
-
o(this, "onWindowMouseMove", (e) => {
|
|
958
|
-
if (!N(
|
|
959
|
-
this.window,
|
|
960
|
-
this.element,
|
|
961
|
-
e.clientX,
|
|
962
|
-
e.clientY
|
|
963
|
-
)) {
|
|
964
|
-
this.cancelMouseDrag();
|
|
965
|
-
return;
|
|
966
|
-
}
|
|
967
|
-
this.grabbedNodeId !== null && this.dragNode(this.grabbedNodeId, e.movementX, e.movementY);
|
|
968
|
-
});
|
|
969
|
-
o(this, "onWindowMouseUp", (e) => {
|
|
970
|
-
this.config.mouseUpEventVerifier(e) && this.cancelMouseDrag();
|
|
971
|
-
});
|
|
972
|
-
o(this, "onWindowTouchMove", (e) => {
|
|
973
|
-
if (e.touches.length !== 1)
|
|
974
|
-
return;
|
|
975
|
-
const t = e.touches[0];
|
|
976
|
-
if (!N(
|
|
977
|
-
this.window,
|
|
978
|
-
this.element,
|
|
979
|
-
t.clientX,
|
|
980
|
-
t.clientY
|
|
981
|
-
)) {
|
|
982
|
-
this.cancelTouchDrag();
|
|
983
|
-
return;
|
|
984
|
-
}
|
|
985
|
-
if (this.grabbedNodeId !== null && this.previousTouchCoordinates !== null) {
|
|
986
|
-
const i = t.clientX - this.previousTouchCoordinates.x, n = t.clientY - this.previousTouchCoordinates.y;
|
|
987
|
-
this.dragNode(this.grabbedNodeId, i, n), this.previousTouchCoordinates = {
|
|
988
|
-
x: e.touches[0].clientX,
|
|
989
|
-
y: e.touches[0].clientY
|
|
990
|
-
};
|
|
887
|
+
}, V = (r) => {
|
|
888
|
+
const e = document.createElement("div");
|
|
889
|
+
return {
|
|
890
|
+
id: r.overlayId,
|
|
891
|
+
element: e,
|
|
892
|
+
x: r.portCoords.x,
|
|
893
|
+
y: r.portCoords.y,
|
|
894
|
+
ports: [
|
|
895
|
+
{
|
|
896
|
+
id: r.overlayId,
|
|
897
|
+
element: e,
|
|
898
|
+
direction: r.portDirection
|
|
991
899
|
}
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
900
|
+
]
|
|
901
|
+
};
|
|
902
|
+
}, ke = (r, e) => {
|
|
903
|
+
let t = e, s = null;
|
|
904
|
+
for (; t !== null && (s = r.getElementPortIds(t)[0] ?? null, s === null); )
|
|
905
|
+
t = t.parentElement;
|
|
906
|
+
return s;
|
|
907
|
+
}, ve = (r, e) => {
|
|
908
|
+
const t = document.elementsFromPoint(e.x, e.y);
|
|
909
|
+
for (const s of t) {
|
|
910
|
+
const i = ke(r, s);
|
|
911
|
+
if (i !== null)
|
|
912
|
+
return i;
|
|
913
|
+
}
|
|
914
|
+
return null;
|
|
915
|
+
};
|
|
916
|
+
var b = /* @__PURE__ */ ((r) => (r.Static = "static", r.Dragging = "dragging", r.Edge = "edge", r))(b || {});
|
|
917
|
+
const me = (r, e) => ({
|
|
918
|
+
x: r / 2,
|
|
919
|
+
y: e / 2
|
|
920
|
+
}), m = (r, e, t) => ({
|
|
921
|
+
x: e.x * r.x - e.y * r.y + ((1 - e.x) * t.x + e.y * t.y),
|
|
922
|
+
y: e.y * r.x + e.x * r.y + ((1 - e.x) * t.y - e.y * t.x)
|
|
923
|
+
}), w = {
|
|
924
|
+
x: 0,
|
|
925
|
+
y: 0
|
|
926
|
+
};
|
|
927
|
+
class ze {
|
|
928
|
+
constructor(e) {
|
|
929
|
+
o(this, "path");
|
|
930
|
+
o(this, "midpoint");
|
|
931
|
+
this.params = e;
|
|
932
|
+
const t = this.params.to;
|
|
933
|
+
this.midpoint = { x: t.x / 2, y: t.y / 2 };
|
|
934
|
+
const s = m(
|
|
935
|
+
{ x: this.params.arrowLength, y: w.y },
|
|
936
|
+
this.params.sourceDirection,
|
|
937
|
+
w
|
|
938
|
+
), i = m(
|
|
939
|
+
{ x: this.params.to.x - this.params.arrowLength, y: this.params.to.y },
|
|
940
|
+
this.params.targetDirection,
|
|
941
|
+
this.params.to
|
|
942
|
+
), n = {
|
|
943
|
+
x: s.x + this.params.sourceDirection.x * this.params.curvature,
|
|
944
|
+
y: s.y + this.params.sourceDirection.y * this.params.curvature
|
|
945
|
+
}, h = {
|
|
946
|
+
x: i.x - this.params.targetDirection.x * this.params.curvature,
|
|
947
|
+
y: i.y - this.params.targetDirection.y * this.params.curvature
|
|
948
|
+
}, a = `M ${s.x} ${s.y} C ${n.x} ${n.y}, ${h.x} ${h.y}, ${i.x} ${i.y}`, d = this.params.hasSourceArrow ? "" : `M ${w.x} ${w.y} L ${s.x} ${s.y} `, c = this.params.hasTargetArrow ? "" : ` M ${i.x} ${i.y} L ${this.params.to.x} ${this.params.to.y}`;
|
|
949
|
+
this.path = `${d}${a}${c}`;
|
|
1001
950
|
}
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
951
|
+
}
|
|
952
|
+
const ye = (r, e, t, s) => ({
|
|
953
|
+
x: e * r.x + (1 - e) / 2 * s.x,
|
|
954
|
+
y: t * r.y + (1 - t) / 2 * s.y
|
|
955
|
+
});
|
|
956
|
+
class Xe {
|
|
957
|
+
constructor(e) {
|
|
958
|
+
o(this, "path");
|
|
959
|
+
o(this, "midpoint");
|
|
960
|
+
this.params = e;
|
|
961
|
+
const t = this.params.hasSourceArrow ? m(
|
|
962
|
+
{ x: this.params.arrowLength, y: w.y },
|
|
963
|
+
this.params.sourceDirection,
|
|
964
|
+
w
|
|
965
|
+
) : w, s = this.params.hasTargetArrow ? m(
|
|
966
|
+
{
|
|
967
|
+
x: this.params.to.x - this.params.arrowLength,
|
|
968
|
+
y: this.params.to.y
|
|
969
|
+
},
|
|
970
|
+
this.params.targetDirection,
|
|
971
|
+
this.params.to
|
|
972
|
+
) : this.params.to, i = this.params.arrowLength, n = Math.cos(this.params.detourDirection) * this.params.detourDistance, h = Math.sin(this.params.detourDirection) * this.params.detourDistance, a = n * this.params.flipX, d = h * this.params.flipY, c = m(
|
|
973
|
+
{ x: i, y: w.y },
|
|
974
|
+
this.params.sourceDirection,
|
|
975
|
+
w
|
|
976
|
+
), l = {
|
|
977
|
+
x: c.x + a,
|
|
978
|
+
y: c.y + d
|
|
979
|
+
}, g = m(
|
|
980
|
+
{ x: this.params.to.x - i, y: this.params.to.y },
|
|
981
|
+
this.params.targetDirection,
|
|
982
|
+
this.params.to
|
|
983
|
+
), p = {
|
|
984
|
+
x: g.x + a,
|
|
985
|
+
y: g.y + d
|
|
986
|
+
}, f = {
|
|
987
|
+
x: (l.x + p.x) / 2,
|
|
988
|
+
y: (l.y + p.y) / 2
|
|
989
|
+
}, v = {
|
|
990
|
+
x: c.x + this.params.curvature * this.params.sourceDirection.x,
|
|
991
|
+
y: c.y + this.params.curvature * this.params.sourceDirection.y
|
|
992
|
+
}, y = {
|
|
993
|
+
x: g.x - this.params.curvature * this.params.targetDirection.x,
|
|
994
|
+
y: g.y - this.params.curvature * this.params.targetDirection.y
|
|
995
|
+
}, E = {
|
|
996
|
+
x: c.x + a,
|
|
997
|
+
y: c.y + d
|
|
998
|
+
}, x = {
|
|
999
|
+
x: g.x + a,
|
|
1000
|
+
y: g.y + d
|
|
1001
|
+
};
|
|
1002
|
+
this.path = [
|
|
1003
|
+
`M ${t.x} ${t.y}`,
|
|
1004
|
+
`L ${c.x} ${c.y}`,
|
|
1005
|
+
`C ${v.x} ${v.y} ${E.x} ${E.y} ${f.x} ${f.y}`,
|
|
1006
|
+
`C ${x.x} ${x.y} ${y.x} ${y.y} ${g.x} ${g.y}`,
|
|
1007
|
+
`L ${s.x} ${s.y}`
|
|
1008
|
+
].join(" "), this.midpoint = ye(f, e.flipX, e.flipY, e.to);
|
|
1019
1009
|
}
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1010
|
+
}
|
|
1011
|
+
const C = (r, e) => {
|
|
1012
|
+
const t = [];
|
|
1013
|
+
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) {
|
|
1014
|
+
const s = r.length - 1;
|
|
1015
|
+
let i = 0, n = 0, h = 0;
|
|
1016
|
+
r.forEach((a, d) => {
|
|
1017
|
+
let c = 0, l = 0, g = 0;
|
|
1018
|
+
const p = d > 0, f = d < s, v = p && f;
|
|
1019
|
+
if (p && (c = -i, l = -n, g = h), f) {
|
|
1020
|
+
const R = r[d + 1];
|
|
1021
|
+
i = R.x - a.x, n = R.y - a.y, h = Math.sqrt(i * i + n * n);
|
|
1027
1022
|
}
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
e !== null && this.config.onNodeDragFinished({
|
|
1034
|
-
nodeId: this.grabbedNodeId,
|
|
1035
|
-
element: e.element,
|
|
1036
|
-
x: e.x,
|
|
1037
|
-
y: e.y
|
|
1038
|
-
}), this.grabbedNodeId = null, B(this.element, null), this.removeMouseDragListeners();
|
|
1039
|
-
}
|
|
1040
|
-
removeMouseDragListeners() {
|
|
1041
|
-
this.window.removeEventListener("mouseup", this.onWindowMouseUp), this.window.removeEventListener("mousemove", this.onWindowMouseMove);
|
|
1023
|
+
const E = h !== 0 ? Math.min((v ? e : 0) / h, d < s - 1 ? 0.5 : 1) : 0, x = v ? { x: a.x + i * E, y: a.y + n * E } : a, D = g !== 0 ? Math.min((v ? e : 0) / g, d > 1 ? 0.5 : 1) : 0, N = v ? { x: a.x + c * D, y: a.y + l * D } : a;
|
|
1024
|
+
d > 0 && t.push(`L ${N.x} ${N.y}`), v && t.push(
|
|
1025
|
+
`C ${a.x} ${a.y} ${a.x} ${a.y} ${x.x} ${x.y}`
|
|
1026
|
+
);
|
|
1027
|
+
});
|
|
1042
1028
|
}
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1029
|
+
return t.join(" ");
|
|
1030
|
+
};
|
|
1031
|
+
class Ye {
|
|
1032
|
+
constructor(e) {
|
|
1033
|
+
o(this, "path");
|
|
1034
|
+
o(this, "midpoint");
|
|
1035
|
+
this.params = e;
|
|
1036
|
+
const t = this.params.to;
|
|
1037
|
+
this.midpoint = { x: t.x / 2, y: t.y / 2 };
|
|
1038
|
+
const s = this.params.hasSourceArrow ? m(
|
|
1039
|
+
{ x: this.params.arrowLength, y: w.y },
|
|
1040
|
+
this.params.sourceDirection,
|
|
1041
|
+
w
|
|
1042
|
+
) : w, i = this.params.hasTargetArrow ? m(
|
|
1043
|
+
{
|
|
1044
|
+
x: this.params.to.x - this.params.arrowLength,
|
|
1045
|
+
y: this.params.to.y
|
|
1046
|
+
},
|
|
1047
|
+
this.params.targetDirection,
|
|
1048
|
+
this.params.to
|
|
1049
|
+
) : this.params.to, n = this.params.arrowLength + this.params.arrowOffset, h = n - this.params.roundness, a = m(
|
|
1050
|
+
{ x: h, y: w.y },
|
|
1051
|
+
this.params.sourceDirection,
|
|
1052
|
+
w
|
|
1053
|
+
), d = m(
|
|
1054
|
+
{ x: this.params.to.x - h, y: this.params.to.y },
|
|
1055
|
+
this.params.targetDirection,
|
|
1056
|
+
this.params.to
|
|
1057
|
+
), c = Math.max((a.x + d.x) / 2, n), l = this.params.to.y / 2, g = {
|
|
1058
|
+
x: this.params.flipX > 0 ? c : -n,
|
|
1059
|
+
y: a.y
|
|
1060
|
+
}, p = { x: g.x, y: l }, f = {
|
|
1061
|
+
x: this.params.flipX > 0 ? this.params.to.x - c : this.params.to.x + n,
|
|
1062
|
+
y: d.y
|
|
1063
|
+
}, v = { x: f.x, y: l };
|
|
1064
|
+
this.path = C(
|
|
1065
|
+
[s, a, g, p, v, f, d, i],
|
|
1066
|
+
this.params.roundness
|
|
1067
|
+
);
|
|
1052
1068
|
}
|
|
1053
|
-
|
|
1054
|
-
|
|
1069
|
+
}
|
|
1070
|
+
class H {
|
|
1071
|
+
constructor(e) {
|
|
1072
|
+
o(this, "path");
|
|
1073
|
+
o(this, "midpoint");
|
|
1074
|
+
this.params = e;
|
|
1075
|
+
const t = this.params.hasSourceArrow ? m(
|
|
1076
|
+
{ x: this.params.arrowLength, y: w.y },
|
|
1077
|
+
this.params.sourceDirection,
|
|
1078
|
+
w
|
|
1079
|
+
) : w, s = this.params.hasTargetArrow ? m(
|
|
1080
|
+
{
|
|
1081
|
+
x: this.params.to.x - this.params.arrowLength,
|
|
1082
|
+
y: this.params.to.y
|
|
1083
|
+
},
|
|
1084
|
+
this.params.targetDirection,
|
|
1085
|
+
this.params.to
|
|
1086
|
+
) : this.params.to, i = this.params.arrowLength + this.params.arrowOffset, n = m(
|
|
1087
|
+
{ x: i, y: w.y },
|
|
1088
|
+
this.params.sourceDirection,
|
|
1089
|
+
w
|
|
1090
|
+
), h = Math.cos(this.params.detourDirection) * this.params.detourDistance, a = Math.sin(this.params.detourDirection) * this.params.detourDistance, d = h * this.params.flipX, c = a * this.params.flipY, l = { x: n.x + d, y: n.y + c }, g = m(
|
|
1091
|
+
{ x: this.params.to.x - i, y: this.params.to.y },
|
|
1092
|
+
this.params.targetDirection,
|
|
1093
|
+
this.params.to
|
|
1094
|
+
), p = { x: g.x + d, y: g.y + c }, f = { x: (l.x + p.x) / 2, y: (l.y + p.y) / 2 };
|
|
1095
|
+
this.midpoint = ye(f, e.flipX, e.flipY, e.to), this.path = C(
|
|
1096
|
+
[t, n, l, p, g, s],
|
|
1097
|
+
this.params.roundness
|
|
1098
|
+
);
|
|
1055
1099
|
}
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1100
|
+
}
|
|
1101
|
+
class He {
|
|
1102
|
+
constructor(e) {
|
|
1103
|
+
o(this, "path");
|
|
1104
|
+
o(this, "midpoint");
|
|
1105
|
+
this.params = e;
|
|
1106
|
+
const t = this.params.to;
|
|
1107
|
+
this.midpoint = { x: t.x / 2, y: t.y / 2 };
|
|
1108
|
+
const s = this.params.hasSourceArrow ? m(
|
|
1109
|
+
{ x: this.params.arrowLength, y: w.y },
|
|
1110
|
+
this.params.sourceDirection,
|
|
1111
|
+
w
|
|
1112
|
+
) : w, i = this.params.hasTargetArrow ? m(
|
|
1113
|
+
{
|
|
1114
|
+
x: this.params.to.x - this.params.arrowLength,
|
|
1115
|
+
y: this.params.to.y
|
|
1116
|
+
},
|
|
1117
|
+
this.params.targetDirection,
|
|
1118
|
+
this.params.to
|
|
1119
|
+
) : this.params.to, n = this.params.arrowLength + this.params.arrowOffset, h = m(
|
|
1120
|
+
{ x: n, y: w.y },
|
|
1121
|
+
this.params.sourceDirection,
|
|
1122
|
+
w
|
|
1123
|
+
), a = m(
|
|
1124
|
+
{ x: this.params.to.x - n, y: this.params.to.y },
|
|
1125
|
+
this.params.targetDirection,
|
|
1126
|
+
this.params.to
|
|
1127
|
+
);
|
|
1128
|
+
this.path = C([s, h, a, i], this.params.roundness);
|
|
1059
1129
|
}
|
|
1060
1130
|
}
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
const
|
|
1067
|
-
|
|
1068
|
-
const
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1131
|
+
class je {
|
|
1132
|
+
constructor(e) {
|
|
1133
|
+
o(this, "path");
|
|
1134
|
+
o(this, "midpoint");
|
|
1135
|
+
this.params = e;
|
|
1136
|
+
const t = this.params.to;
|
|
1137
|
+
this.midpoint = { x: t.x / 2, y: t.y / 2 };
|
|
1138
|
+
const s = this.params.hasSourceArrow ? m(
|
|
1139
|
+
{ x: this.params.arrowLength, y: w.y },
|
|
1140
|
+
this.params.sourceDirection,
|
|
1141
|
+
w
|
|
1142
|
+
) : w, i = this.params.hasTargetArrow ? m(
|
|
1143
|
+
{
|
|
1144
|
+
x: this.params.to.x - this.params.arrowLength,
|
|
1145
|
+
y: this.params.to.y
|
|
1146
|
+
},
|
|
1147
|
+
this.params.targetDirection,
|
|
1148
|
+
this.params.to
|
|
1149
|
+
) : this.params.to, n = this.params.arrowLength + this.params.arrowOffset, h = n - this.params.roundness, a = m(
|
|
1150
|
+
{ x: h, y: w.y },
|
|
1151
|
+
this.params.sourceDirection,
|
|
1152
|
+
w
|
|
1153
|
+
), d = m(
|
|
1154
|
+
{ x: this.params.to.x - h, y: this.params.to.y },
|
|
1155
|
+
this.params.targetDirection,
|
|
1156
|
+
this.params.to
|
|
1157
|
+
), c = Math.max((a.y + d.y) / 2, n), l = this.params.to.x / 2, g = {
|
|
1158
|
+
x: a.x,
|
|
1159
|
+
y: this.params.flipY > 0 ? c : -n
|
|
1160
|
+
}, p = { x: l, y: g.y }, f = {
|
|
1161
|
+
x: d.x,
|
|
1162
|
+
y: this.params.flipY > 0 ? this.params.to.y - c : this.params.to.y + n
|
|
1163
|
+
}, v = { x: l, y: f.y };
|
|
1164
|
+
this.path = C(
|
|
1165
|
+
[s, a, g, p, v, f, d, i],
|
|
1166
|
+
this.params.roundness
|
|
1167
|
+
);
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
class j {
|
|
1171
|
+
constructor(e) {
|
|
1172
|
+
o(this, "path");
|
|
1173
|
+
o(this, "midpoint");
|
|
1174
|
+
this.params = e;
|
|
1175
|
+
const t = this.params.arrowOffset, s = this.params.side, i = this.params.arrowLength + t, n = i + 2 * s, a = [
|
|
1176
|
+
{ x: this.params.arrowLength, y: w.y },
|
|
1177
|
+
{ x: i, y: w.y },
|
|
1178
|
+
{ x: i, y: this.params.side },
|
|
1179
|
+
{ x: n, y: this.params.side },
|
|
1180
|
+
{ x: n, y: -this.params.side },
|
|
1181
|
+
{ x: i, y: -this.params.side },
|
|
1182
|
+
{ x: i, y: w.y },
|
|
1183
|
+
{ x: this.params.arrowLength, y: w.y }
|
|
1184
|
+
].map(
|
|
1185
|
+
(c) => m(c, this.params.sourceDirection, w)
|
|
1186
|
+
), d = `M ${w.x} ${w.y} L ${a[0].x} ${a[0].y} `;
|
|
1187
|
+
this.path = `${this.params.hasSourceArrow || this.params.hasTargetArrow ? "" : d}${C(a, this.params.roundness)}`, this.midpoint = { x: (a[3].x + a[4].x) / 2, y: (a[3].y + a[4].y) / 2 };
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
class Ge {
|
|
1191
|
+
constructor(e) {
|
|
1192
|
+
o(this, "path");
|
|
1193
|
+
o(this, "midpoint");
|
|
1194
|
+
this.params = e;
|
|
1195
|
+
const t = this.params.smallRadius, s = this.params.radius, i = t + s, n = t * s / i, h = Math.sqrt(i * i - t * t), a = h * t / i, d = h + s + this.params.arrowLength, c = this.params.arrowLength + a, g = [
|
|
1196
|
+
{ x: this.params.arrowLength, y: w.y },
|
|
1197
|
+
{ x: c, y: n },
|
|
1198
|
+
{ x: c, y: -n },
|
|
1199
|
+
{ x: d, y: 0 }
|
|
1200
|
+
].map(
|
|
1201
|
+
(v) => m(v, this.params.sourceDirection, w)
|
|
1202
|
+
), p = [
|
|
1203
|
+
`M ${g[0].x} ${g[0].y}`,
|
|
1204
|
+
`A ${t} ${t} 0 0 1 ${g[1].x} ${g[1].y}`,
|
|
1205
|
+
`A ${s} ${s} 0 1 0 ${g[2].x} ${g[2].y}`,
|
|
1206
|
+
`A ${t} ${t} 0 0 1 ${g[0].x} ${g[0].y}`
|
|
1207
|
+
].join(" "), f = `M 0 0 L ${g[0].x} ${g[0].y} `;
|
|
1208
|
+
this.path = `${this.params.hasSourceArrow || this.params.hasTargetArrow ? "" : f}${p}`, this.midpoint = g[3];
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
class Ke {
|
|
1212
|
+
constructor(e) {
|
|
1213
|
+
o(this, "path");
|
|
1214
|
+
o(this, "midpoint");
|
|
1215
|
+
o(this, "diagonalDistance");
|
|
1216
|
+
this.params = e;
|
|
1217
|
+
const t = this.params.to;
|
|
1218
|
+
if (this.midpoint = { x: t.x / 2, y: t.y / 2 }, this.diagonalDistance = Math.sqrt(
|
|
1219
|
+
this.params.to.x * this.params.to.x + this.params.to.y * this.params.to.y
|
|
1220
|
+
), Math.sqrt(
|
|
1221
|
+
this.params.to.x * this.params.to.x + this.params.to.y * this.params.to.y
|
|
1222
|
+
) === 0) {
|
|
1223
|
+
this.path = "";
|
|
1224
|
+
return;
|
|
1085
1225
|
}
|
|
1226
|
+
const i = this.createDirectLinePoint({
|
|
1227
|
+
offset: this.params.sourceOffset,
|
|
1228
|
+
hasArrow: this.params.hasSourceArrow,
|
|
1229
|
+
flip: 1,
|
|
1230
|
+
shift: w
|
|
1231
|
+
}), n = this.createDirectLinePoint({
|
|
1232
|
+
offset: this.params.targetOffset,
|
|
1233
|
+
hasArrow: this.params.hasTargetArrow,
|
|
1234
|
+
flip: -1,
|
|
1235
|
+
shift: this.params.to
|
|
1236
|
+
});
|
|
1237
|
+
this.path = `M ${i.x} ${i.y} L ${n.x} ${n.y}`;
|
|
1238
|
+
}
|
|
1239
|
+
createDirectLinePoint(e) {
|
|
1240
|
+
const t = e.hasArrow ? this.params.arrowLength : 0, s = e.offset + t, i = e.flip * s / this.diagonalDistance;
|
|
1086
1241
|
return {
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
y: g
|
|
1242
|
+
x: this.params.to.x * i + e.shift.x,
|
|
1243
|
+
y: this.params.to.y * i + e.shift.y
|
|
1090
1244
|
};
|
|
1091
|
-
};
|
|
1092
|
-
}, Ue = (r) => (e) => r.reduce(
|
|
1093
|
-
(t, s) => s({
|
|
1094
|
-
prevTransform: e.prevTransform,
|
|
1095
|
-
nextTransform: t,
|
|
1096
|
-
canvasWidth: e.canvasWidth,
|
|
1097
|
-
canvasHeight: e.canvasHeight
|
|
1098
|
-
}),
|
|
1099
|
-
e.nextTransform
|
|
1100
|
-
), te = (r) => {
|
|
1101
|
-
if (typeof r == "function")
|
|
1102
|
-
return r;
|
|
1103
|
-
switch (r.type) {
|
|
1104
|
-
case "scale-limit":
|
|
1105
|
-
return Ve({
|
|
1106
|
-
minContentScale: r.minContentScale ?? 0,
|
|
1107
|
-
maxContentScale: r.maxContentScale ?? 1 / 0
|
|
1108
|
-
});
|
|
1109
|
-
case "shift-limit":
|
|
1110
|
-
return Be({
|
|
1111
|
-
minX: r.minX ?? -1 / 0,
|
|
1112
|
-
maxX: r.maxX ?? 1 / 0,
|
|
1113
|
-
minY: r.minY ?? -1 / 0,
|
|
1114
|
-
maxY: r.maxY ?? 1 / 0
|
|
1115
|
-
});
|
|
1116
1245
|
}
|
|
1117
|
-
}
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
const
|
|
1127
|
-
|
|
1128
|
-
|
|
1246
|
+
}
|
|
1247
|
+
const Ee = (r, e) => {
|
|
1248
|
+
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`;
|
|
1249
|
+
}, G = Object.freeze({
|
|
1250
|
+
edgeColor: "--edge-color"
|
|
1251
|
+
}), Ae = (r) => {
|
|
1252
|
+
const e = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
1253
|
+
return e.style.pointerEvents = "none", e.style.position = "absolute", e.style.top = "0", e.style.left = "0", e.style.overflow = "visible", e.style.setProperty(G.edgeColor, r), e;
|
|
1254
|
+
}, B = () => {
|
|
1255
|
+
const r = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
1256
|
+
return r.setAttribute("fill", `var(${G.edgeColor})`), r;
|
|
1257
|
+
}, xe = () => {
|
|
1258
|
+
const r = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
|
1259
|
+
return r.style.transformOrigin = "50% 50%", r;
|
|
1260
|
+
}, Se = (r) => {
|
|
1261
|
+
const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
1262
|
+
return e.setAttribute("stroke", `var(${G.edgeColor})`), e.setAttribute("stroke-width", `${r}`), e.setAttribute("fill", "none"), e;
|
|
1263
|
+
}, be = (r, e) => {
|
|
1264
|
+
const t = {
|
|
1265
|
+
x: r.x + r.width / 2,
|
|
1266
|
+
y: r.y + r.height / 2
|
|
1267
|
+
}, s = {
|
|
1268
|
+
x: e.x + e.width / 2,
|
|
1269
|
+
y: e.y + e.height / 2
|
|
1270
|
+
}, i = Math.min(t.x, s.x), n = Math.min(t.y, s.y), h = Math.abs(s.x - t.x), a = Math.abs(s.y - t.y), d = t.x <= s.x ? 1 : -1, c = t.y <= s.y ? 1 : -1;
|
|
1129
1271
|
return {
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
onTransformChange: a,
|
|
1137
|
-
transformPreprocessor: i,
|
|
1138
|
-
shiftCursor: n,
|
|
1139
|
-
mouseDownEventVerifier: c,
|
|
1140
|
-
mouseUpEventVerifier: l,
|
|
1141
|
-
mouseWheelEventVerifier: f,
|
|
1142
|
-
scaleWheelFinishTimeout: ((K = r == null ? void 0 : r.scale) == null ? void 0 : K.wheelFinishTimeout) ?? 500,
|
|
1143
|
-
onResizeTransformStarted: ((Q = r == null ? void 0 : r.events) == null ? void 0 : Q.onResizeTransformStarted) ?? (() => {
|
|
1144
|
-
}),
|
|
1145
|
-
onResizeTransformFinished: ((_ = r == null ? void 0 : r.events) == null ? void 0 : _.onResizeTransformFinished) ?? (() => {
|
|
1146
|
-
})
|
|
1272
|
+
x: i,
|
|
1273
|
+
y: n,
|
|
1274
|
+
width: h,
|
|
1275
|
+
height: a,
|
|
1276
|
+
flipX: d,
|
|
1277
|
+
flipY: c
|
|
1147
1278
|
};
|
|
1148
|
-
},
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
o(this, "
|
|
1178
|
-
o(this, "
|
|
1179
|
-
o(this, "
|
|
1180
|
-
o(this, "
|
|
1181
|
-
o(this, "
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
})
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
this.window,
|
|
1194
|
-
this.element,
|
|
1195
|
-
e.clientX,
|
|
1196
|
-
e.clientY
|
|
1197
|
-
);
|
|
1198
|
-
if (this.element === null || !t) {
|
|
1199
|
-
this.stopMouseDrag();
|
|
1200
|
-
return;
|
|
1201
|
-
}
|
|
1202
|
-
const s = -e.movementX, i = -e.movementY;
|
|
1203
|
-
this.moveViewport(s, i);
|
|
1204
|
-
});
|
|
1205
|
-
o(this, "onWindowMouseUp", (e) => {
|
|
1206
|
-
this.element === null || !this.config.mouseUpEventVerifier(e) || this.stopMouseDrag();
|
|
1207
|
-
});
|
|
1208
|
-
o(this, "onWheelScroll", (e) => {
|
|
1209
|
-
if (!this.config.mouseWheelEventVerifier(e))
|
|
1210
|
-
return;
|
|
1211
|
-
const { left: t, top: s } = this.element.getBoundingClientRect(), i = e.clientX - t, n = e.clientY - s, a = 1 / (e.deltaY < 0 ? this.config.wheelSensitivity : 1 / this.config.wheelSensitivity);
|
|
1212
|
-
this.wheelFinishTimer === null && this.config.onTransformStarted(), this.scaleViewport(a, i, n), this.wheelFinishTimer !== null && clearTimeout(this.wheelFinishTimer), this.wheelFinishTimer = setTimeout(() => {
|
|
1213
|
-
this.transformInProgress || this.config.onTransformFinished(), this.wheelFinishTimer = null;
|
|
1214
|
-
}, this.config.scaleWheelFinishTimeout);
|
|
1215
|
-
});
|
|
1216
|
-
o(this, "onTouchStart", (e) => {
|
|
1217
|
-
if (this.prevTouches !== null) {
|
|
1218
|
-
this.prevTouches = I(e);
|
|
1219
|
-
return;
|
|
1220
|
-
}
|
|
1221
|
-
this.prevTouches = I(e), this.window.addEventListener("touchmove", this.onWindowTouchMove, {
|
|
1222
|
-
passive: !0
|
|
1223
|
-
}), this.window.addEventListener("touchend", this.onWindowTouchFinish, {
|
|
1224
|
-
passive: !0
|
|
1225
|
-
}), this.window.addEventListener("touchcancel", this.onWindowTouchFinish, {
|
|
1226
|
-
passive: !0
|
|
1227
|
-
}), this.startRegisteredTransform();
|
|
1228
|
-
});
|
|
1229
|
-
o(this, "onWindowTouchMove", (e) => {
|
|
1230
|
-
const t = I(e);
|
|
1231
|
-
if (!t.touches.every(
|
|
1232
|
-
(i) => N(this.window, this.element, i[0], i[1])
|
|
1233
|
-
)) {
|
|
1234
|
-
this.stopTouchDrag();
|
|
1235
|
-
return;
|
|
1236
|
-
}
|
|
1237
|
-
if ((t.touchesCnt === 1 || t.touchesCnt === 2) && this.moveViewport(
|
|
1238
|
-
-(t.x - this.prevTouches.x),
|
|
1239
|
-
-(t.y - this.prevTouches.y)
|
|
1240
|
-
), t.touchesCnt === 2) {
|
|
1241
|
-
const { left: i, top: n } = this.element.getBoundingClientRect(), h = this.prevTouches.x - i, a = this.prevTouches.y - n, c = 1 / (t.scale / this.prevTouches.scale);
|
|
1242
|
-
this.scaleViewport(c, h, a);
|
|
1243
|
-
}
|
|
1244
|
-
this.prevTouches = t;
|
|
1245
|
-
});
|
|
1246
|
-
o(this, "onWindowTouchFinish", (e) => {
|
|
1247
|
-
e.touches.length > 0 ? this.prevTouches = I(e) : this.stopTouchDrag();
|
|
1248
|
-
});
|
|
1249
|
-
o(this, "observer", new ResizeObserver(() => {
|
|
1250
|
-
const e = this.viewport.getViewportMatrix(), { width: t, height: s } = this.element.getBoundingClientRect(), i = this.config.transformPreprocessor({
|
|
1251
|
-
prevTransform: e,
|
|
1252
|
-
nextTransform: e,
|
|
1253
|
-
canvasWidth: t,
|
|
1254
|
-
canvasHeight: s
|
|
1255
|
-
});
|
|
1256
|
-
this.config.onResizeTransformStarted(), this.canvas.patchViewportMatrix(i), this.config.onResizeTransformFinished();
|
|
1257
|
-
}));
|
|
1258
|
-
o(this, "config");
|
|
1259
|
-
o(this, "preventWheelScaleListener", (e) => {
|
|
1260
|
-
e.preventDefault();
|
|
1261
|
-
});
|
|
1262
|
-
this.canvas = e, this.element = t, this.window = s, this.element.addEventListener("wheel", this.preventWheelScaleListener, {
|
|
1263
|
-
passive: !1
|
|
1264
|
-
}), this.config = Ce(i), this.viewport = e.viewport, this.observer.observe(this.element), this.element.addEventListener("mousedown", this.onMouseDown, {
|
|
1265
|
-
passive: !0
|
|
1266
|
-
}), this.element.addEventListener("wheel", this.onWheelScroll, {
|
|
1267
|
-
passive: !0
|
|
1268
|
-
}), this.element.addEventListener("touchstart", this.onTouchStart, {
|
|
1269
|
-
passive: !0
|
|
1270
|
-
}), e.onBeforeDestroy.subscribe(this.onBeforeDestroy);
|
|
1271
|
-
}
|
|
1272
|
-
static configure(e, t, s, i) {
|
|
1273
|
-
new U(
|
|
1274
|
-
e,
|
|
1275
|
-
t,
|
|
1276
|
-
s,
|
|
1277
|
-
i
|
|
1278
|
-
);
|
|
1279
|
-
}
|
|
1280
|
-
moveViewport(e, t) {
|
|
1281
|
-
const s = this.viewport.getViewportMatrix(), i = We(s, e, t), { width: n, height: h } = this.element.getBoundingClientRect(), a = this.config.transformPreprocessor({
|
|
1282
|
-
prevTransform: s,
|
|
1283
|
-
nextTransform: i,
|
|
1284
|
-
canvasWidth: n,
|
|
1285
|
-
canvasHeight: h
|
|
1286
|
-
});
|
|
1287
|
-
this.performTransform(a);
|
|
1288
|
-
}
|
|
1289
|
-
scaleViewport(e, t, s) {
|
|
1290
|
-
const i = this.canvas.viewport.getViewportMatrix(), n = $e(i, e, t, s), { width: h, height: a } = this.element.getBoundingClientRect(), d = this.config.transformPreprocessor({
|
|
1291
|
-
prevTransform: i,
|
|
1292
|
-
nextTransform: n,
|
|
1293
|
-
canvasWidth: h,
|
|
1294
|
-
canvasHeight: a
|
|
1295
|
-
});
|
|
1296
|
-
this.performTransform(d);
|
|
1297
|
-
}
|
|
1298
|
-
stopMouseDrag() {
|
|
1299
|
-
B(this.element, null), this.removeMouseDragListeners(), this.finishRegisteredTransform();
|
|
1300
|
-
}
|
|
1301
|
-
removeMouseDragListeners() {
|
|
1302
|
-
this.window.removeEventListener("mousemove", this.onWindowMouseMove), this.window.removeEventListener("mouseup", this.onWindowMouseUp);
|
|
1303
|
-
}
|
|
1304
|
-
stopTouchDrag() {
|
|
1305
|
-
this.prevTouches = null, this.removeTouchDragListeners(), this.finishRegisteredTransform();
|
|
1306
|
-
}
|
|
1307
|
-
removeTouchDragListeners() {
|
|
1308
|
-
this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
|
|
1309
|
-
}
|
|
1310
|
-
performTransform(e) {
|
|
1311
|
-
this.config.onBeforeTransformChange(), this.canvas.patchViewportMatrix(e), this.config.onTransformChange();
|
|
1312
|
-
}
|
|
1313
|
-
startRegisteredTransform() {
|
|
1314
|
-
this.transformInProgress = !0, this.config.onTransformStarted();
|
|
1315
|
-
}
|
|
1316
|
-
finishRegisteredTransform() {
|
|
1317
|
-
this.transformInProgress = !1, this.config.onTransformFinished();
|
|
1318
|
-
}
|
|
1319
|
-
}
|
|
1320
|
-
class X {
|
|
1321
|
-
constructor(e, t, s, i, n, h) {
|
|
1322
|
-
o(this, "canvasResizeObserver");
|
|
1323
|
-
o(this, "nodeHorizontal");
|
|
1324
|
-
o(this, "nodeVertical");
|
|
1325
|
-
o(this, "viewport");
|
|
1326
|
-
o(this, "viewportWidth", 0);
|
|
1327
|
-
o(this, "viewportHeight", 0);
|
|
1328
|
-
o(this, "viewportMatrix");
|
|
1329
|
-
o(this, "loadedArea", {
|
|
1330
|
-
xFrom: 1 / 0,
|
|
1331
|
-
xTo: 1 / 0,
|
|
1332
|
-
yFrom: 1 / 0,
|
|
1333
|
-
yTo: 1 / 0
|
|
1334
|
-
});
|
|
1335
|
-
o(this, "updateLoadedArea", (e) => {
|
|
1336
|
-
this.loadedArea = {
|
|
1337
|
-
xFrom: e.x,
|
|
1338
|
-
xTo: e.x + e.width,
|
|
1339
|
-
yFrom: e.y,
|
|
1340
|
-
yTo: e.y + e.height
|
|
1341
|
-
};
|
|
1342
|
-
});
|
|
1343
|
-
o(this, "onBeforeDestroy", () => {
|
|
1344
|
-
this.trigger.unsubscribe(this.updateLoadedArea), this.canvasResizeObserver.unobserve(this.element), this.canvas.viewport.onAfterUpdated.unsubscribe(
|
|
1345
|
-
this.onAfterViewportUpdated
|
|
1346
|
-
), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy);
|
|
1347
|
-
});
|
|
1348
|
-
o(this, "onAfterViewportUpdated", () => {
|
|
1349
|
-
this.userTransformInProgress || (this.viewportMatrix = this.viewport.getViewportMatrix(), this.loadAreaAroundViewport());
|
|
1350
|
-
});
|
|
1351
|
-
o(this, "userTransformInProgress", !1);
|
|
1352
|
-
var f, v, A, m, x;
|
|
1353
|
-
this.canvas = e, this.element = t, this.window = s, this.trigger = n, this.virtualScrollOptions = h, this.nodeHorizontal = this.virtualScrollOptions.nodeContainingRadius.horizontal, this.nodeVertical = this.virtualScrollOptions.nodeContainingRadius.vertical, this.canvasResizeObserver = new ResizeObserver((b) => {
|
|
1354
|
-
const T = b[0];
|
|
1355
|
-
this.viewportWidth = T.contentRect.width, this.viewportHeight = T.contentRect.height, this.scheduleLoadAreaAroundViewport();
|
|
1356
|
-
}), this.viewport = e.viewport;
|
|
1357
|
-
const a = ((f = i == null ? void 0 : i.events) == null ? void 0 : f.onResizeTransformStarted) ?? (() => {
|
|
1358
|
-
}), d = ((v = i == null ? void 0 : i.events) == null ? void 0 : v.onResizeTransformFinished) ?? (() => {
|
|
1359
|
-
}), c = ((A = i == null ? void 0 : i.events) == null ? void 0 : A.onTransformChange) ?? (() => {
|
|
1360
|
-
}), g = ((m = i == null ? void 0 : i.events) == null ? void 0 : m.onBeforeTransformChange) ?? (() => {
|
|
1361
|
-
}), l = ((x = i == null ? void 0 : i.events) == null ? void 0 : x.onTransformFinished) ?? (() => {
|
|
1362
|
-
}), p = {
|
|
1363
|
-
...i,
|
|
1364
|
-
events: {
|
|
1365
|
-
...i == null ? void 0 : i.events,
|
|
1366
|
-
onResizeTransformStarted: () => {
|
|
1367
|
-
this.userTransformInProgress = !0, a();
|
|
1368
|
-
},
|
|
1369
|
-
onResizeTransformFinished: () => {
|
|
1370
|
-
this.userTransformInProgress = !1, d();
|
|
1371
|
-
},
|
|
1372
|
-
onBeforeTransformChange: () => {
|
|
1373
|
-
this.userTransformInProgress = !0, g();
|
|
1374
|
-
},
|
|
1375
|
-
onTransformChange: () => {
|
|
1376
|
-
this.userTransformInProgress = !1;
|
|
1377
|
-
const b = this.viewportMatrix;
|
|
1378
|
-
this.viewportMatrix = this.viewport.getViewportMatrix(), b.scale !== this.viewportMatrix.scale && this.scheduleEnsureViewportAreaLoaded(), c();
|
|
1379
|
-
},
|
|
1380
|
-
onTransformFinished: () => {
|
|
1381
|
-
this.scheduleLoadAreaAroundViewport(), l();
|
|
1382
|
-
}
|
|
1383
|
-
}
|
|
1384
|
-
};
|
|
1385
|
-
U.configure(
|
|
1386
|
-
e,
|
|
1387
|
-
this.element,
|
|
1388
|
-
this.window,
|
|
1389
|
-
p
|
|
1390
|
-
), this.viewportMatrix = this.viewport.getViewportMatrix(), this.trigger.subscribe(this.updateLoadedArea), this.canvasResizeObserver.observe(this.element), this.canvas.viewport.onAfterUpdated.subscribe(this.onAfterViewportUpdated), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
|
|
1391
|
-
}
|
|
1392
|
-
static configure(e, t, s, i, n, h) {
|
|
1393
|
-
new X(
|
|
1394
|
-
e,
|
|
1395
|
-
t,
|
|
1396
|
-
s,
|
|
1397
|
-
i,
|
|
1398
|
-
n,
|
|
1399
|
-
h
|
|
1400
|
-
);
|
|
1401
|
-
}
|
|
1402
|
-
scheduleLoadAreaAroundViewport() {
|
|
1403
|
-
setTimeout(() => {
|
|
1404
|
-
this.loadAreaAroundViewport();
|
|
1405
|
-
});
|
|
1406
|
-
}
|
|
1407
|
-
scheduleEnsureViewportAreaLoaded() {
|
|
1408
|
-
const e = this.viewportWidth * this.viewportMatrix.scale, t = this.viewportHeight * this.viewportMatrix.scale, s = this.viewportMatrix.x - this.nodeHorizontal, i = this.viewportMatrix.y - this.nodeVertical, n = this.viewportMatrix.x + e + this.nodeHorizontal, h = this.viewportMatrix.y + t + this.nodeVertical;
|
|
1409
|
-
this.loadedArea.xFrom < s && this.loadedArea.xTo > n && this.loadedArea.yFrom < i && this.loadedArea.yTo > h || this.scheduleLoadAreaAroundViewport();
|
|
1410
|
-
}
|
|
1411
|
-
loadAreaAroundViewport() {
|
|
1412
|
-
const e = this.viewportWidth * this.viewportMatrix.scale, t = this.viewportHeight * this.viewportMatrix.scale, s = this.viewportMatrix.x - e - this.nodeHorizontal, i = this.viewportMatrix.y - t - this.nodeVertical, n = 3 * e + 2 * this.nodeHorizontal, h = 3 * t + 2 * this.nodeVertical;
|
|
1413
|
-
this.trigger.emit({ x: s, y: i, width: n, height: h });
|
|
1414
|
-
}
|
|
1415
|
-
}
|
|
1416
|
-
const Fe = () => {
|
|
1417
|
-
const r = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
1418
|
-
return r.style.position = "absolute", r.style.inset = "0", r;
|
|
1419
|
-
}, Oe = () => {
|
|
1420
|
-
const r = document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
|
1421
|
-
return r.setAttribute("fill", "url(#pattern)"), r;
|
|
1422
|
-
}, ke = () => {
|
|
1423
|
-
const r = document.createElementNS(
|
|
1424
|
-
"http://www.w3.org/2000/svg",
|
|
1425
|
-
"pattern"
|
|
1426
|
-
);
|
|
1427
|
-
return r.setAttribute("id", "pattern"), r;
|
|
1428
|
-
}, ze = (r, e) => {
|
|
1429
|
-
const t = document.createElementNS(
|
|
1430
|
-
"http://www.w3.org/2000/svg",
|
|
1431
|
-
"circle"
|
|
1432
|
-
);
|
|
1433
|
-
return t.setAttribute("cx", "0"), t.setAttribute("cy", "0"), t.setAttribute("r", `${r}`), t.setAttribute("fill", `${e}`), t;
|
|
1434
|
-
}, Xe = (r) => r instanceof SVGElement ? r : ze(
|
|
1435
|
-
(r == null ? void 0 : r.radius) ?? 1.5,
|
|
1436
|
-
(r == null ? void 0 : r.color) ?? "#d8d8d8"
|
|
1437
|
-
), Ye = (r) => {
|
|
1438
|
-
const e = r.tileDimensions, t = (e == null ? void 0 : e.width) ?? 25, s = (e == null ? void 0 : e.height) ?? 25, i = Xe(r.renderer ?? {});
|
|
1439
|
-
return {
|
|
1440
|
-
tileWidth: t,
|
|
1441
|
-
tileHeight: s,
|
|
1442
|
-
renderer: i,
|
|
1443
|
-
maxViewportScale: r.maxViewportScale ?? 10
|
|
1444
|
-
};
|
|
1445
|
-
};
|
|
1446
|
-
class Y {
|
|
1447
|
-
constructor(e, t, s) {
|
|
1448
|
-
o(this, "svg", Fe());
|
|
1449
|
-
o(this, "patternRenderingRectangle", Oe());
|
|
1450
|
-
o(this, "pattern", ke());
|
|
1451
|
-
o(this, "patternContent");
|
|
1452
|
-
o(this, "tileWidth");
|
|
1453
|
-
o(this, "tileHeight");
|
|
1454
|
-
o(this, "halfTileWidth");
|
|
1455
|
-
o(this, "halfTileHeight");
|
|
1456
|
-
o(this, "maxViewportScale");
|
|
1457
|
-
o(this, "visible", !1);
|
|
1458
|
-
o(this, "resizeObserver", new ResizeObserver((e) => {
|
|
1459
|
-
const t = e[0], { width: s, height: i } = t.contentRect;
|
|
1460
|
-
this.svg.setAttribute("width", `${s}`), this.svg.setAttribute("height", `${i}`), this.patternRenderingRectangle.setAttribute("width", `${s}`), this.patternRenderingRectangle.setAttribute("height", `${i}`);
|
|
1461
|
-
const n = this.tileWidth / s, h = this.tileHeight / i;
|
|
1462
|
-
this.pattern.setAttribute("width", `${n}`), this.pattern.setAttribute("height", `${h}`);
|
|
1463
|
-
}));
|
|
1464
|
-
o(this, "onAfterTransformUpdated", () => {
|
|
1465
|
-
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})`;
|
|
1466
|
-
this.pattern.setAttribute("patternTransform", i), this.updateVisibility();
|
|
1467
|
-
});
|
|
1468
|
-
o(this, "onBeforeDestroy", () => {
|
|
1469
|
-
this.resizeObserver.unobserve(this.host), this.host.removeChild(this.svg), this.canvas.viewport.onAfterUpdated.unsubscribe(
|
|
1470
|
-
this.onAfterTransformUpdated
|
|
1471
|
-
), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy);
|
|
1472
|
-
});
|
|
1473
|
-
this.canvas = e, this.host = s;
|
|
1474
|
-
const i = Ye(t);
|
|
1475
|
-
this.tileWidth = i.tileWidth, this.tileHeight = i.tileHeight, this.halfTileWidth = this.tileWidth / 2, this.halfTileHeight = this.tileHeight / 2, this.patternContent = i.renderer, this.maxViewportScale = i.maxViewportScale;
|
|
1476
|
-
const n = `translate(${this.halfTileWidth}, ${this.halfTileHeight})`;
|
|
1477
|
-
this.patternContent.setAttribute("transform", n), this.pattern.appendChild(this.patternContent);
|
|
1478
|
-
const h = document.createElementNS("http://www.w3.org/2000/svg", "defs");
|
|
1479
|
-
h.appendChild(this.pattern), this.svg.appendChild(h), this.svg.appendChild(this.patternRenderingRectangle), this.resizeObserver.observe(this.host), this.canvas.viewport.onAfterUpdated.subscribe(this.onAfterTransformUpdated), this.onAfterTransformUpdated(), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
|
|
1480
|
-
}
|
|
1481
|
-
static configure(e, t, s) {
|
|
1482
|
-
new Y(e, t, s);
|
|
1483
|
-
}
|
|
1484
|
-
updateVisibility() {
|
|
1485
|
-
const t = this.canvas.viewport.getViewportMatrix().scale > this.maxViewportScale;
|
|
1486
|
-
t && this.visible ? (this.visible = !1, this.host.removeChild(this.svg)) : !t && !this.visible && (this.visible = !0, this.host.appendChild(this.svg));
|
|
1487
|
-
}
|
|
1488
|
-
}
|
|
1489
|
-
const ce = (r, e) => ({
|
|
1490
|
-
x: r / 2,
|
|
1491
|
-
y: e / 2
|
|
1492
|
-
});
|
|
1493
|
-
class H {
|
|
1494
|
-
constructor(e, t, s, i, n) {
|
|
1495
|
-
o(this, "overlayCanvas");
|
|
1496
|
-
o(this, "staticOverlayPortId", "static");
|
|
1497
|
-
o(this, "draggingOverlayPortId", "dragging");
|
|
1498
|
-
o(this, "staticPortId", null);
|
|
1499
|
-
o(this, "isDirect", !0);
|
|
1500
|
-
o(this, "onAfterPortMarked", (e) => {
|
|
1501
|
-
const t = this.canvas.graph.getPort(e);
|
|
1502
|
-
this.canvas.graph.getElementPortsIds(t.element).length === 1 && this.hookPortEvents(t.element);
|
|
1503
|
-
});
|
|
1504
|
-
o(this, "onBeforePortUnmarked", (e) => {
|
|
1505
|
-
const t = this.canvas.graph.getPort(e);
|
|
1506
|
-
this.canvas.graph.getElementPortsIds(t.element).length === 1 && this.unhookPortEvents(t.element);
|
|
1507
|
-
});
|
|
1508
|
-
o(this, "onPortMouseDown", (e) => {
|
|
1509
|
-
const t = e.currentTarget;
|
|
1510
|
-
this.config.mouseDownEventVerifier(e) && this.isPortConnectionAllowed(t) && (e.stopPropagation(), this.grabPort(t, { x: e.clientX, y: e.clientY }), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
|
|
1511
|
-
passive: !0
|
|
1512
|
-
}), this.window.addEventListener("mouseup", this.onWindowMouseUp, {
|
|
1513
|
-
passive: !0
|
|
1514
|
-
}));
|
|
1515
|
-
});
|
|
1516
|
-
o(this, "onWindowMouseMove", (e) => {
|
|
1517
|
-
if (!N(
|
|
1518
|
-
this.window,
|
|
1519
|
-
this.overlayLayer,
|
|
1520
|
-
e.clientX,
|
|
1521
|
-
e.clientY
|
|
1522
|
-
)) {
|
|
1523
|
-
this.stopMouseDrag();
|
|
1524
|
-
return;
|
|
1525
|
-
}
|
|
1526
|
-
this.moveDraggingNode({ x: e.clientX, y: e.clientY });
|
|
1527
|
-
});
|
|
1528
|
-
o(this, "onWindowMouseUp", (e) => {
|
|
1529
|
-
this.config.mouseUpEventVerifier(e) && (this.tryCreateConnection({ x: e.clientX, y: e.clientY }), this.stopMouseDrag());
|
|
1530
|
-
});
|
|
1531
|
-
o(this, "onPortTouchStart", (e) => {
|
|
1532
|
-
const t = e.currentTarget;
|
|
1533
|
-
if (!(e.touches.length === 1 && this.isPortConnectionAllowed(t)))
|
|
1534
|
-
return;
|
|
1535
|
-
e.stopPropagation();
|
|
1536
|
-
const i = e.touches[0];
|
|
1537
|
-
this.grabPort(t, { x: i.clientX, y: i.clientY }), this.window.addEventListener("touchmove", this.onWindowTouchMove, {
|
|
1538
|
-
passive: !0
|
|
1539
|
-
}), this.window.addEventListener("touchend", this.onWindowTouchFinish, {
|
|
1540
|
-
passive: !0
|
|
1541
|
-
}), this.window.addEventListener("touchcancel", this.onWindowTouchFinish, {
|
|
1542
|
-
passive: !0
|
|
1543
|
-
});
|
|
1544
|
-
});
|
|
1545
|
-
o(this, "onWindowTouchMove", (e) => {
|
|
1546
|
-
const t = e.touches[0];
|
|
1547
|
-
if (!N(
|
|
1548
|
-
this.window,
|
|
1549
|
-
this.overlayLayer,
|
|
1550
|
-
t.clientX,
|
|
1551
|
-
t.clientY
|
|
1552
|
-
)) {
|
|
1553
|
-
this.stopTouchDrag();
|
|
1554
|
-
return;
|
|
1555
|
-
}
|
|
1556
|
-
this.moveDraggingNode({ x: t.clientX, y: t.clientY });
|
|
1557
|
-
});
|
|
1558
|
-
o(this, "onWindowTouchFinish", (e) => {
|
|
1559
|
-
const t = e.changedTouches[0];
|
|
1560
|
-
this.tryCreateConnection({ x: t.clientX, y: t.clientY }), this.stopTouchDrag();
|
|
1561
|
-
});
|
|
1562
|
-
o(this, "onBeforeClear", () => {
|
|
1563
|
-
this.canvas.graph.getAllPortIds().forEach((e) => {
|
|
1564
|
-
const t = this.canvas.graph.getPort(e);
|
|
1565
|
-
this.unhookPortEvents(t.element);
|
|
1566
|
-
});
|
|
1567
|
-
});
|
|
1568
|
-
o(this, "onBeforeDestroy", () => {
|
|
1569
|
-
this.stopMouseDrag(), this.stopTouchDrag(), this.canvas.graph.onAfterPortMarked.unsubscribe(this.onAfterPortMarked), this.canvas.graph.onBeforePortUnmarked.unsubscribe(
|
|
1570
|
-
this.onBeforePortUnmarked
|
|
1571
|
-
), this.canvas.graph.onBeforeClear.unsubscribe(this.onBeforeClear), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy);
|
|
1572
|
-
});
|
|
1573
|
-
o(this, "onEdgeCreated", (e) => {
|
|
1574
|
-
this.config.onAfterEdgeCreated(e);
|
|
1575
|
-
});
|
|
1576
|
-
this.canvas = e, this.overlayLayer = t, this.viewportStore = s, this.window = i, this.config = n;
|
|
1577
|
-
const h = new de(), a = new ne(
|
|
1279
|
+
}, k = (r, e, t, s) => {
|
|
1280
|
+
const n = [
|
|
1281
|
+
w,
|
|
1282
|
+
{ x: t, y: s },
|
|
1283
|
+
{ x: t, y: -s }
|
|
1284
|
+
].map((c) => m(c, r, w)).map((c) => ({ x: c.x + e.x, y: c.y + e.y })), h = `M ${n[0].x} ${n[0].y}`, a = `L ${n[1].x} ${n[1].y}`, d = `L ${n[2].x} ${n[2].y}`;
|
|
1285
|
+
return `${h} ${a} ${d} Z`;
|
|
1286
|
+
}, u = Object.freeze({
|
|
1287
|
+
color: "#777777",
|
|
1288
|
+
width: 1,
|
|
1289
|
+
arrowLength: 15,
|
|
1290
|
+
arrowWidth: 4,
|
|
1291
|
+
arrowOffset: 15,
|
|
1292
|
+
hasSourceArrow: !1,
|
|
1293
|
+
hasTargetArrow: !1,
|
|
1294
|
+
cycleRadius: 30,
|
|
1295
|
+
cycleSquareSide: 30,
|
|
1296
|
+
roundness: 10,
|
|
1297
|
+
detourDistance: 100,
|
|
1298
|
+
detourDirection: -Math.PI / 2,
|
|
1299
|
+
detourDirectionVertical: 0,
|
|
1300
|
+
smallCycleRadius: 15,
|
|
1301
|
+
curvature: 90,
|
|
1302
|
+
interactiveWidth: 10,
|
|
1303
|
+
preOffset: 0
|
|
1304
|
+
}), ne = (r, e, t) => ({ x: e * Math.cos(r), y: t * Math.sin(r) });
|
|
1305
|
+
class W {
|
|
1306
|
+
constructor(e) {
|
|
1307
|
+
o(this, "svg");
|
|
1308
|
+
o(this, "group", xe());
|
|
1309
|
+
o(this, "line");
|
|
1310
|
+
o(this, "sourceArrow", null);
|
|
1311
|
+
o(this, "targetArrow", null);
|
|
1312
|
+
o(this, "onAfterRender");
|
|
1313
|
+
o(this, "afterRenderEmitter");
|
|
1314
|
+
this.params = e, [this.afterRenderEmitter, this.onAfterRender] = A(), this.svg = Ae(e.color), this.svg.appendChild(this.group), this.line = Se(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));
|
|
1315
|
+
}
|
|
1316
|
+
render(e) {
|
|
1317
|
+
const { x: t, y: s, width: i, height: n, flipX: h, flipY: a } = be(
|
|
1318
|
+
e.from,
|
|
1319
|
+
e.to
|
|
1320
|
+
);
|
|
1321
|
+
Ee(this.svg, { x: t, y: s, width: i, height: n }), this.group.style.transform = `scale(${h}, ${a})`;
|
|
1322
|
+
const d = ne(
|
|
1323
|
+
e.from.direction,
|
|
1578
1324
|
h,
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
shapeFactory: this.config.edgeShapeFactory,
|
|
1588
|
-
priorityFn: () => 0
|
|
1589
|
-
},
|
|
1590
|
-
ports: {
|
|
1591
|
-
direction: 0
|
|
1592
|
-
}
|
|
1325
|
+
a
|
|
1326
|
+
), c = ne(
|
|
1327
|
+
e.to.direction,
|
|
1328
|
+
h,
|
|
1329
|
+
a
|
|
1330
|
+
), l = {
|
|
1331
|
+
x: i,
|
|
1332
|
+
y: n
|
|
1593
1333
|
};
|
|
1594
|
-
|
|
1595
|
-
|
|
1334
|
+
let g = c, p = -this.params.arrowLength, f;
|
|
1335
|
+
e.from.portId === e.to.portId ? (f = this.params.createCyclePath, g = d, p = this.params.arrowLength) : e.from.nodeId === e.to.nodeId ? f = this.params.createDetourPath : f = this.params.createLinePath;
|
|
1336
|
+
const v = f(
|
|
1337
|
+
d,
|
|
1338
|
+
c,
|
|
1339
|
+
l,
|
|
1596
1340
|
h,
|
|
1597
|
-
|
|
1598
|
-
a,
|
|
1599
|
-
d
|
|
1600
|
-
), 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);
|
|
1601
|
-
}
|
|
1602
|
-
static configure(e, t, s, i, n) {
|
|
1603
|
-
new H(
|
|
1604
|
-
e,
|
|
1605
|
-
t,
|
|
1606
|
-
s,
|
|
1607
|
-
i,
|
|
1608
|
-
n
|
|
1341
|
+
a
|
|
1609
1342
|
);
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
};
|
|
1629
|
-
this.isDirect = n === "direct";
|
|
1630
|
-
const A = this.isDirect ? f : v, m = this.isDirect ? v : f;
|
|
1631
|
-
this.createOverlayGraph(A, m);
|
|
1632
|
-
}
|
|
1633
|
-
hookPortEvents(e) {
|
|
1634
|
-
e.addEventListener("mousedown", this.onPortMouseDown, {
|
|
1635
|
-
passive: !0
|
|
1636
|
-
}), e.addEventListener("touchstart", this.onPortTouchStart, {
|
|
1637
|
-
passive: !0
|
|
1638
|
-
});
|
|
1639
|
-
}
|
|
1640
|
-
unhookPortEvents(e) {
|
|
1641
|
-
e.removeEventListener("mousedown", this.onPortMouseDown), e.removeEventListener("touchstart", this.onPortTouchStart);
|
|
1642
|
-
}
|
|
1643
|
-
stopMouseDrag() {
|
|
1644
|
-
this.resetDragState(), this.window.removeEventListener("mouseup", this.onWindowMouseUp), this.window.removeEventListener("mousemove", this.onWindowMouseMove);
|
|
1645
|
-
}
|
|
1646
|
-
stopTouchDrag() {
|
|
1647
|
-
this.resetDragState(), this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
|
|
1648
|
-
}
|
|
1649
|
-
resetDragState() {
|
|
1650
|
-
this.staticPortId = null, this.isDirect = !0, this.overlayCanvas.clear();
|
|
1651
|
-
}
|
|
1652
|
-
createOverlayGraph(e, t) {
|
|
1653
|
-
const s = this.createAddNodeRequest(e);
|
|
1654
|
-
this.overlayCanvas.addNode(s);
|
|
1655
|
-
const i = this.createAddNodeRequest(t);
|
|
1656
|
-
this.overlayCanvas.addNode(i), this.overlayCanvas.addEdge({
|
|
1657
|
-
from: e.overlayId,
|
|
1658
|
-
to: t.overlayId
|
|
1343
|
+
this.line.setAttribute("d", v.path);
|
|
1344
|
+
let y = null;
|
|
1345
|
+
this.sourceArrow && (y = k(
|
|
1346
|
+
d,
|
|
1347
|
+
w,
|
|
1348
|
+
this.params.arrowLength,
|
|
1349
|
+
this.params.arrowWidth
|
|
1350
|
+
), this.sourceArrow.setAttribute("d", y));
|
|
1351
|
+
let E = null;
|
|
1352
|
+
this.targetArrow && (E = k(
|
|
1353
|
+
g,
|
|
1354
|
+
l,
|
|
1355
|
+
p,
|
|
1356
|
+
this.params.arrowWidth
|
|
1357
|
+
), this.targetArrow.setAttribute("d", E)), this.afterRenderEmitter.emit({
|
|
1358
|
+
edgePath: v,
|
|
1359
|
+
sourceArrowPath: y,
|
|
1360
|
+
targetArrowPath: E
|
|
1659
1361
|
});
|
|
1660
1362
|
}
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1363
|
+
}
|
|
1364
|
+
class Ze {
|
|
1365
|
+
constructor(e) {
|
|
1366
|
+
o(this, "svg");
|
|
1367
|
+
o(this, "group");
|
|
1368
|
+
o(this, "line");
|
|
1369
|
+
o(this, "sourceArrow");
|
|
1370
|
+
o(this, "targetArrow");
|
|
1371
|
+
o(this, "onAfterRender");
|
|
1372
|
+
o(this, "arrowLength");
|
|
1373
|
+
o(this, "arrowWidth");
|
|
1374
|
+
o(this, "curvature");
|
|
1375
|
+
o(this, "portCycleRadius");
|
|
1376
|
+
o(this, "portCycleSmallRadius");
|
|
1377
|
+
o(this, "detourDirection");
|
|
1378
|
+
o(this, "detourDistance");
|
|
1379
|
+
o(this, "hasSourceArrow");
|
|
1380
|
+
o(this, "hasTargetArrow");
|
|
1381
|
+
o(this, "pathShape");
|
|
1382
|
+
o(this, "createCyclePath", (e) => new Ge({
|
|
1383
|
+
sourceDirection: e,
|
|
1384
|
+
radius: this.portCycleRadius,
|
|
1385
|
+
smallRadius: this.portCycleSmallRadius,
|
|
1386
|
+
arrowLength: this.arrowLength,
|
|
1387
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
1388
|
+
hasTargetArrow: this.hasTargetArrow
|
|
1389
|
+
}));
|
|
1390
|
+
o(this, "createDetourPath", (e, t, s, i, n) => new Xe({
|
|
1391
|
+
to: s,
|
|
1392
|
+
sourceDirection: e,
|
|
1393
|
+
targetDirection: t,
|
|
1394
|
+
flipX: i,
|
|
1395
|
+
flipY: n,
|
|
1396
|
+
arrowLength: this.arrowLength,
|
|
1397
|
+
detourDirection: this.detourDirection,
|
|
1398
|
+
detourDistance: this.detourDistance,
|
|
1399
|
+
curvature: this.curvature,
|
|
1400
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
1401
|
+
hasTargetArrow: this.hasTargetArrow
|
|
1402
|
+
}));
|
|
1403
|
+
o(this, "createLinePath", (e, t, s) => new ze({
|
|
1404
|
+
to: s,
|
|
1405
|
+
sourceDirection: e,
|
|
1406
|
+
targetDirection: t,
|
|
1407
|
+
arrowLength: this.arrowLength,
|
|
1408
|
+
curvature: this.curvature,
|
|
1409
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
1410
|
+
hasTargetArrow: this.hasTargetArrow
|
|
1411
|
+
}));
|
|
1412
|
+
this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.curvature = (e == null ? void 0 : e.curvature) ?? u.curvature, this.portCycleRadius = (e == null ? void 0 : e.cycleRadius) ?? u.cycleRadius, this.portCycleSmallRadius = (e == null ? void 0 : e.smallCycleRadius) ?? u.smallCycleRadius, this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow, this.pathShape = new W({
|
|
1413
|
+
color: (e == null ? void 0 : e.color) ?? u.color,
|
|
1414
|
+
width: (e == null ? void 0 : e.width) ?? u.width,
|
|
1415
|
+
arrowLength: this.arrowLength,
|
|
1416
|
+
arrowWidth: this.arrowWidth,
|
|
1417
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
1418
|
+
hasTargetArrow: this.hasTargetArrow,
|
|
1419
|
+
createCyclePath: this.createCyclePath,
|
|
1420
|
+
createDetourPath: this.createDetourPath,
|
|
1421
|
+
createLinePath: this.createLinePath
|
|
1422
|
+
}), this.svg = this.pathShape.svg, this.group = this.pathShape.group, this.line = this.pathShape.line, this.sourceArrow = this.pathShape.sourceArrow, this.targetArrow = this.pathShape.targetArrow, this.onAfterRender = this.pathShape.onAfterRender;
|
|
1676
1423
|
}
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
if (t === null) {
|
|
1680
|
-
this.config.onEdgeCreationInterrupted(this.staticPortId, this.isDirect);
|
|
1681
|
-
return;
|
|
1682
|
-
}
|
|
1683
|
-
const s = this.isDirect ? this.staticPortId : t, i = this.isDirect ? t : this.staticPortId, n = { from: s, to: i }, h = this.config.connectionPreprocessor(n);
|
|
1684
|
-
h !== null ? (this.canvas.graph.onAfterEdgeAdded.subscribe(this.onEdgeCreated), this.canvas.addEdge(h), this.canvas.graph.onAfterEdgeAdded.unsubscribe(this.onEdgeCreated)) : this.config.onEdgeCreationPrevented(n);
|
|
1424
|
+
render(e) {
|
|
1425
|
+
this.pathShape.render(e);
|
|
1685
1426
|
}
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1427
|
+
}
|
|
1428
|
+
class Je {
|
|
1429
|
+
constructor(e) {
|
|
1430
|
+
o(this, "svg");
|
|
1431
|
+
o(this, "group");
|
|
1432
|
+
o(this, "line");
|
|
1433
|
+
o(this, "sourceArrow");
|
|
1434
|
+
o(this, "targetArrow");
|
|
1435
|
+
o(this, "onAfterRender");
|
|
1436
|
+
o(this, "arrowLength");
|
|
1437
|
+
o(this, "arrowWidth");
|
|
1438
|
+
o(this, "arrowOffset");
|
|
1439
|
+
o(this, "roundness");
|
|
1440
|
+
o(this, "cycleSquareSide");
|
|
1441
|
+
o(this, "detourDirection");
|
|
1442
|
+
o(this, "detourDistance");
|
|
1443
|
+
o(this, "hasSourceArrow");
|
|
1444
|
+
o(this, "hasTargetArrow");
|
|
1445
|
+
o(this, "pathShape");
|
|
1446
|
+
o(this, "createCyclePath", (e) => new j({
|
|
1447
|
+
sourceDirection: e,
|
|
1448
|
+
arrowLength: this.arrowLength,
|
|
1449
|
+
side: this.cycleSquareSide,
|
|
1450
|
+
arrowOffset: this.arrowOffset,
|
|
1451
|
+
roundness: this.roundness,
|
|
1452
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
1453
|
+
hasTargetArrow: this.hasTargetArrow
|
|
1454
|
+
}));
|
|
1455
|
+
o(this, "createDetourPath", (e, t, s, i, n) => new H({
|
|
1456
|
+
to: s,
|
|
1457
|
+
sourceDirection: e,
|
|
1458
|
+
targetDirection: t,
|
|
1459
|
+
flipX: i,
|
|
1460
|
+
flipY: n,
|
|
1461
|
+
arrowLength: this.arrowLength,
|
|
1462
|
+
arrowOffset: this.arrowOffset,
|
|
1463
|
+
roundness: this.roundness,
|
|
1464
|
+
detourDirection: this.detourDirection,
|
|
1465
|
+
detourDistance: this.detourDistance,
|
|
1466
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
1467
|
+
hasTargetArrow: this.hasTargetArrow
|
|
1468
|
+
}));
|
|
1469
|
+
o(this, "createLinePath", (e, t, s, i) => new Ye({
|
|
1470
|
+
to: s,
|
|
1471
|
+
sourceDirection: e,
|
|
1472
|
+
targetDirection: t,
|
|
1473
|
+
flipX: i,
|
|
1474
|
+
arrowLength: this.arrowLength,
|
|
1475
|
+
arrowOffset: this.arrowOffset,
|
|
1476
|
+
roundness: this.roundness,
|
|
1477
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
1478
|
+
hasTargetArrow: this.hasTargetArrow
|
|
1479
|
+
}));
|
|
1480
|
+
this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? u.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? u.cycleSquareSide;
|
|
1481
|
+
const t = (e == null ? void 0 : e.roundness) ?? u.roundness;
|
|
1482
|
+
this.roundness = Math.min(
|
|
1483
|
+
t,
|
|
1484
|
+
this.arrowOffset,
|
|
1485
|
+
this.cycleSquareSide / 2
|
|
1486
|
+
), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow, this.pathShape = new W({
|
|
1487
|
+
color: (e == null ? void 0 : e.color) ?? u.color,
|
|
1488
|
+
width: (e == null ? void 0 : e.width) ?? u.width,
|
|
1489
|
+
arrowLength: this.arrowLength,
|
|
1490
|
+
arrowWidth: this.arrowWidth,
|
|
1491
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
1492
|
+
hasTargetArrow: this.hasTargetArrow,
|
|
1493
|
+
createCyclePath: this.createCyclePath,
|
|
1494
|
+
createDetourPath: this.createDetourPath,
|
|
1495
|
+
createLinePath: this.createLinePath
|
|
1496
|
+
}), this.svg = this.pathShape.svg, this.group = this.pathShape.group, this.line = this.pathShape.line, this.sourceArrow = this.pathShape.sourceArrow, this.targetArrow = this.pathShape.targetArrow, this.onAfterRender = this.pathShape.onAfterRender;
|
|
1695
1497
|
}
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
for (const s of t) {
|
|
1699
|
-
const i = this.findPortAtElement(s);
|
|
1700
|
-
if (i !== null)
|
|
1701
|
-
return i;
|
|
1702
|
-
}
|
|
1703
|
-
return null;
|
|
1498
|
+
render(e) {
|
|
1499
|
+
this.pathShape.render(e);
|
|
1704
1500
|
}
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1501
|
+
}
|
|
1502
|
+
class Qe {
|
|
1503
|
+
constructor(e) {
|
|
1504
|
+
o(this, "svg");
|
|
1505
|
+
o(this, "group");
|
|
1506
|
+
o(this, "line");
|
|
1507
|
+
o(this, "sourceArrow");
|
|
1508
|
+
o(this, "targetArrow");
|
|
1509
|
+
o(this, "onAfterRender");
|
|
1510
|
+
o(this, "arrowLength");
|
|
1511
|
+
o(this, "arrowWidth");
|
|
1512
|
+
o(this, "arrowOffset");
|
|
1513
|
+
o(this, "roundness");
|
|
1514
|
+
o(this, "cycleSquareSide");
|
|
1515
|
+
o(this, "detourDirection");
|
|
1516
|
+
o(this, "detourDistance");
|
|
1517
|
+
o(this, "hasSourceArrow");
|
|
1518
|
+
o(this, "hasTargetArrow");
|
|
1519
|
+
o(this, "pathShape");
|
|
1520
|
+
o(this, "createCyclePath", (e) => new j({
|
|
1521
|
+
sourceDirection: e,
|
|
1522
|
+
arrowLength: this.arrowLength,
|
|
1523
|
+
side: this.cycleSquareSide,
|
|
1524
|
+
arrowOffset: this.arrowOffset,
|
|
1525
|
+
roundness: this.roundness,
|
|
1526
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
1527
|
+
hasTargetArrow: this.hasTargetArrow
|
|
1528
|
+
}));
|
|
1529
|
+
o(this, "createDetourPath", (e, t, s, i, n) => new H({
|
|
1530
|
+
to: s,
|
|
1531
|
+
sourceDirection: e,
|
|
1532
|
+
targetDirection: t,
|
|
1533
|
+
flipX: i,
|
|
1534
|
+
flipY: n,
|
|
1535
|
+
arrowLength: this.arrowLength,
|
|
1536
|
+
arrowOffset: this.arrowOffset,
|
|
1537
|
+
roundness: this.roundness,
|
|
1538
|
+
detourDirection: this.detourDirection,
|
|
1539
|
+
detourDistance: this.detourDistance,
|
|
1540
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
1541
|
+
hasTargetArrow: this.hasTargetArrow
|
|
1542
|
+
}));
|
|
1543
|
+
o(this, "createLinePath", (e, t, s) => new He({
|
|
1544
|
+
to: s,
|
|
1545
|
+
sourceDirection: e,
|
|
1546
|
+
targetDirection: t,
|
|
1547
|
+
arrowLength: this.arrowLength,
|
|
1548
|
+
arrowOffset: this.arrowOffset,
|
|
1549
|
+
roundness: this.roundness,
|
|
1550
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
1551
|
+
hasTargetArrow: this.hasTargetArrow
|
|
1552
|
+
}));
|
|
1553
|
+
this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? u.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? u.cycleSquareSide;
|
|
1554
|
+
const t = (e == null ? void 0 : e.roundness) ?? u.roundness;
|
|
1555
|
+
this.roundness = Math.min(
|
|
1556
|
+
t,
|
|
1557
|
+
this.arrowOffset,
|
|
1558
|
+
this.cycleSquareSide / 2
|
|
1559
|
+
), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow, this.pathShape = new W({
|
|
1560
|
+
color: (e == null ? void 0 : e.color) ?? u.color,
|
|
1561
|
+
width: (e == null ? void 0 : e.width) ?? u.width,
|
|
1562
|
+
arrowLength: this.arrowLength,
|
|
1563
|
+
arrowWidth: this.arrowWidth,
|
|
1564
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
1565
|
+
hasTargetArrow: this.hasTargetArrow,
|
|
1566
|
+
createCyclePath: this.createCyclePath,
|
|
1567
|
+
createDetourPath: this.createDetourPath,
|
|
1568
|
+
createLinePath: this.createLinePath
|
|
1569
|
+
}), this.svg = this.pathShape.svg, this.group = this.pathShape.group, this.line = this.pathShape.line, this.sourceArrow = this.pathShape.sourceArrow, this.targetArrow = this.pathShape.targetArrow, this.onAfterRender = this.pathShape.onAfterRender;
|
|
1710
1570
|
}
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
return this.config.connectionTypeResolver(t) !== null;
|
|
1571
|
+
render(e) {
|
|
1572
|
+
this.pathShape.render(e);
|
|
1714
1573
|
}
|
|
1715
1574
|
}
|
|
1716
|
-
|
|
1717
|
-
const r = document.createElement("div");
|
|
1718
|
-
return r.style.width = "100%", r.style.height = "100%", r.style.position = "relative", r;
|
|
1719
|
-
}, $ = () => {
|
|
1720
|
-
const r = document.createElement("div");
|
|
1721
|
-
return r.style.position = "absolute", r.style.inset = "0", r;
|
|
1722
|
-
};
|
|
1723
|
-
class je {
|
|
1575
|
+
class _e {
|
|
1724
1576
|
constructor(e) {
|
|
1725
|
-
o(this, "
|
|
1726
|
-
o(this, "
|
|
1727
|
-
o(this, "
|
|
1728
|
-
o(this, "
|
|
1729
|
-
|
|
1577
|
+
o(this, "svg");
|
|
1578
|
+
o(this, "group");
|
|
1579
|
+
o(this, "line");
|
|
1580
|
+
o(this, "sourceArrow");
|
|
1581
|
+
o(this, "targetArrow");
|
|
1582
|
+
o(this, "onAfterRender");
|
|
1583
|
+
o(this, "arrowLength");
|
|
1584
|
+
o(this, "arrowWidth");
|
|
1585
|
+
o(this, "arrowOffset");
|
|
1586
|
+
o(this, "roundness");
|
|
1587
|
+
o(this, "cycleSquareSide");
|
|
1588
|
+
o(this, "detourDirection");
|
|
1589
|
+
o(this, "detourDistance");
|
|
1590
|
+
o(this, "hasSourceArrow");
|
|
1591
|
+
o(this, "hasTargetArrow");
|
|
1592
|
+
o(this, "pathShape");
|
|
1593
|
+
o(this, "createCyclePath", (e) => new j({
|
|
1594
|
+
sourceDirection: e,
|
|
1595
|
+
arrowLength: this.arrowLength,
|
|
1596
|
+
side: this.cycleSquareSide,
|
|
1597
|
+
arrowOffset: this.arrowOffset,
|
|
1598
|
+
roundness: this.roundness,
|
|
1599
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
1600
|
+
hasTargetArrow: this.hasTargetArrow
|
|
1601
|
+
}));
|
|
1602
|
+
o(this, "createDetourPath", (e, t, s, i, n) => new H({
|
|
1603
|
+
to: s,
|
|
1604
|
+
sourceDirection: e,
|
|
1605
|
+
targetDirection: t,
|
|
1606
|
+
flipX: i,
|
|
1607
|
+
flipY: n,
|
|
1608
|
+
arrowLength: this.arrowLength,
|
|
1609
|
+
arrowOffset: this.arrowOffset,
|
|
1610
|
+
roundness: this.roundness,
|
|
1611
|
+
detourDirection: this.detourDirection,
|
|
1612
|
+
detourDistance: this.detourDistance,
|
|
1613
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
1614
|
+
hasTargetArrow: this.hasTargetArrow
|
|
1615
|
+
}));
|
|
1616
|
+
o(this, "createLinePath", (e, t, s, i, n) => new je({
|
|
1617
|
+
to: s,
|
|
1618
|
+
sourceDirection: e,
|
|
1619
|
+
targetDirection: t,
|
|
1620
|
+
flipY: n,
|
|
1621
|
+
arrowLength: this.arrowLength,
|
|
1622
|
+
arrowOffset: this.arrowOffset,
|
|
1623
|
+
roundness: this.roundness,
|
|
1624
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
1625
|
+
hasTargetArrow: this.hasTargetArrow
|
|
1626
|
+
}));
|
|
1627
|
+
this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? u.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? u.cycleSquareSide;
|
|
1628
|
+
const t = (e == null ? void 0 : e.roundness) ?? u.roundness;
|
|
1629
|
+
this.roundness = Math.min(
|
|
1630
|
+
t,
|
|
1631
|
+
this.arrowOffset,
|
|
1632
|
+
this.cycleSquareSide / 2
|
|
1633
|
+
), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirectionVertical, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow, this.pathShape = new W({
|
|
1634
|
+
color: (e == null ? void 0 : e.color) ?? u.color,
|
|
1635
|
+
width: (e == null ? void 0 : e.width) ?? u.width,
|
|
1636
|
+
arrowLength: this.arrowLength,
|
|
1637
|
+
arrowWidth: this.arrowWidth,
|
|
1638
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
1639
|
+
hasTargetArrow: this.hasTargetArrow,
|
|
1640
|
+
createCyclePath: this.createCyclePath,
|
|
1641
|
+
createDetourPath: this.createDetourPath,
|
|
1642
|
+
createLinePath: this.createLinePath
|
|
1643
|
+
}), this.svg = this.pathShape.svg, this.group = this.pathShape.group, this.line = this.pathShape.line, this.sourceArrow = this.pathShape.sourceArrow, this.targetArrow = this.pathShape.targetArrow, this.onAfterRender = this.pathShape.onAfterRender;
|
|
1730
1644
|
}
|
|
1731
|
-
|
|
1732
|
-
this.
|
|
1645
|
+
render(e) {
|
|
1646
|
+
this.pathShape.render(e);
|
|
1733
1647
|
}
|
|
1734
1648
|
}
|
|
1735
|
-
const
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1649
|
+
const he = (r) => {
|
|
1650
|
+
if (r.diagonalDistance === 0)
|
|
1651
|
+
return "";
|
|
1652
|
+
const e = r.offset / r.diagonalDistance, t = r.flip * r.to.x, s = r.flip * r.to.y, i = {
|
|
1653
|
+
x: t * e + r.shift.x,
|
|
1654
|
+
y: s * e + r.shift.y
|
|
1655
|
+
}, n = {
|
|
1656
|
+
x: t / r.diagonalDistance,
|
|
1657
|
+
y: s / r.diagonalDistance
|
|
1744
1658
|
};
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1659
|
+
return k(
|
|
1660
|
+
n,
|
|
1661
|
+
i,
|
|
1662
|
+
r.arrowLength,
|
|
1663
|
+
r.arrowWidth
|
|
1664
|
+
);
|
|
1751
1665
|
};
|
|
1752
|
-
class
|
|
1753
|
-
constructor(e) {
|
|
1754
|
-
o(this, "path");
|
|
1755
|
-
o(this, "median");
|
|
1756
|
-
this.params = e;
|
|
1757
|
-
const t = this.params.to;
|
|
1758
|
-
this.median = { x: t.x / 2, y: t.y / 2 };
|
|
1759
|
-
const s = y(
|
|
1760
|
-
{ x: this.params.arrowLength, y: w.y },
|
|
1761
|
-
this.params.sourceDirection,
|
|
1762
|
-
w
|
|
1763
|
-
), i = y(
|
|
1764
|
-
{ x: this.params.to.x - this.params.arrowLength, y: this.params.to.y },
|
|
1765
|
-
this.params.targetDirection,
|
|
1766
|
-
this.params.to
|
|
1767
|
-
), n = {
|
|
1768
|
-
x: s.x + this.params.sourceDirection.x * this.params.curvature,
|
|
1769
|
-
y: s.y + this.params.sourceDirection.y * this.params.curvature
|
|
1770
|
-
}, h = {
|
|
1771
|
-
x: i.x - this.params.targetDirection.x * this.params.curvature,
|
|
1772
|
-
y: i.y - this.params.targetDirection.y * this.params.curvature
|
|
1773
|
-
}, a = `M ${s.x} ${s.y} C ${n.x} ${n.y}, ${h.x} ${h.y}, ${i.x} ${i.y}`, d = this.params.hasSourceArrow ? "" : `M ${w.x} ${w.y} L ${s.x} ${s.y} `, c = this.params.hasTargetArrow ? "" : ` M ${i.x} ${i.y} L ${this.params.to.x} ${this.params.to.y}`;
|
|
1774
|
-
this.path = `${d}${a}${c}`;
|
|
1775
|
-
}
|
|
1776
|
-
}
|
|
1777
|
-
const le = (r, e, t, s) => ({
|
|
1778
|
-
x: e * r.x + (1 - e) / 2 * s.x,
|
|
1779
|
-
y: t * r.y + (1 - t) / 2 * s.y
|
|
1780
|
-
});
|
|
1781
|
-
class Ke {
|
|
1666
|
+
class Pe {
|
|
1782
1667
|
constructor(e) {
|
|
1783
|
-
o(this, "
|
|
1784
|
-
o(this, "
|
|
1785
|
-
this
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
) : this.params.to, i = this.params.arrowLength, n = Math.cos(this.params.detourDirection) * this.params.detourDistance, h = Math.sin(this.params.detourDirection) * this.params.detourDistance, a = n * this.params.flipX, d = h * this.params.flipY, c = y(
|
|
1798
|
-
{ x: i, y: w.y },
|
|
1799
|
-
this.params.sourceDirection,
|
|
1800
|
-
w
|
|
1801
|
-
), g = {
|
|
1802
|
-
x: c.x + a,
|
|
1803
|
-
y: c.y + d
|
|
1804
|
-
}, l = y(
|
|
1805
|
-
{ x: this.params.to.x - i, y: this.params.to.y },
|
|
1806
|
-
this.params.targetDirection,
|
|
1807
|
-
this.params.to
|
|
1808
|
-
), p = {
|
|
1809
|
-
x: l.x + a,
|
|
1810
|
-
y: l.y + d
|
|
1811
|
-
}, f = {
|
|
1812
|
-
x: (g.x + p.x) / 2,
|
|
1813
|
-
y: (g.y + p.y) / 2
|
|
1814
|
-
}, v = {
|
|
1815
|
-
x: c.x + this.params.curvature * this.params.sourceDirection.x,
|
|
1816
|
-
y: c.y + this.params.curvature * this.params.sourceDirection.y
|
|
1817
|
-
}, A = {
|
|
1818
|
-
x: l.x - this.params.curvature * this.params.targetDirection.x,
|
|
1819
|
-
y: l.y - this.params.curvature * this.params.targetDirection.y
|
|
1820
|
-
}, m = {
|
|
1821
|
-
x: c.x + a,
|
|
1822
|
-
y: c.y + d
|
|
1823
|
-
}, x = {
|
|
1824
|
-
x: l.x + a,
|
|
1825
|
-
y: l.y + d
|
|
1826
|
-
};
|
|
1827
|
-
this.path = [
|
|
1828
|
-
`M ${t.x} ${t.y}`,
|
|
1829
|
-
`L ${c.x} ${c.y}`,
|
|
1830
|
-
`C ${v.x} ${v.y} ${m.x} ${m.y} ${f.x} ${f.y}`,
|
|
1831
|
-
`C ${x.x} ${x.y} ${A.x} ${A.y} ${l.x} ${l.y}`,
|
|
1832
|
-
`L ${s.x} ${s.y}`
|
|
1833
|
-
].join(" "), this.median = le(f, e.flipX, e.flipY, e.to);
|
|
1668
|
+
o(this, "svg");
|
|
1669
|
+
o(this, "group", xe());
|
|
1670
|
+
o(this, "line");
|
|
1671
|
+
o(this, "sourceArrow", null);
|
|
1672
|
+
o(this, "targetArrow", null);
|
|
1673
|
+
o(this, "color");
|
|
1674
|
+
o(this, "width");
|
|
1675
|
+
o(this, "arrowLength");
|
|
1676
|
+
o(this, "arrowWidth");
|
|
1677
|
+
o(this, "sourceOffset");
|
|
1678
|
+
o(this, "targetOffset");
|
|
1679
|
+
o(this, "onAfterRender");
|
|
1680
|
+
o(this, "afterRenderEmitter");
|
|
1681
|
+
[this.afterRenderEmitter, this.onAfterRender] = A(), this.color = (e == null ? void 0 : e.color) ?? u.color, this.width = (e == null ? void 0 : e.width) ?? u.width, this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.sourceOffset = (e == null ? void 0 : e.sourceOffset) ?? u.preOffset, this.targetOffset = (e == null ? void 0 : e.targetOffset) ?? u.preOffset, this.svg = Ae(this.color), this.svg.appendChild(this.group), this.line = Se(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));
|
|
1834
1682
|
}
|
|
1835
|
-
|
|
1836
|
-
const
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1683
|
+
render(e) {
|
|
1684
|
+
const { x: t, y: s, width: i, height: n, flipX: h, flipY: a } = be(
|
|
1685
|
+
e.from,
|
|
1686
|
+
e.to
|
|
1687
|
+
);
|
|
1688
|
+
Ee(this.svg, { x: t, y: s, width: i, height: n }), this.group.style.transform = `scale(${h}, ${a})`;
|
|
1689
|
+
const d = { x: i, y: n }, c = new Ke({
|
|
1690
|
+
to: d,
|
|
1691
|
+
sourceOffset: this.sourceOffset,
|
|
1692
|
+
targetOffset: this.targetOffset,
|
|
1693
|
+
hasSourceArrow: this.sourceArrow !== null,
|
|
1694
|
+
hasTargetArrow: this.targetArrow !== null,
|
|
1695
|
+
arrowLength: this.arrowLength
|
|
1696
|
+
});
|
|
1697
|
+
this.line.setAttribute("d", c.path);
|
|
1698
|
+
let l = null;
|
|
1699
|
+
this.sourceArrow && (l = he({
|
|
1700
|
+
diagonalDistance: c.diagonalDistance,
|
|
1701
|
+
to: d,
|
|
1702
|
+
offset: this.sourceOffset,
|
|
1703
|
+
flip: 1,
|
|
1704
|
+
shift: w,
|
|
1705
|
+
arrowWidth: this.arrowWidth,
|
|
1706
|
+
arrowLength: this.arrowLength
|
|
1707
|
+
}), this.sourceArrow.setAttribute("d", l));
|
|
1708
|
+
let g = null;
|
|
1709
|
+
this.targetArrow && (g = he({
|
|
1710
|
+
diagonalDistance: c.diagonalDistance,
|
|
1711
|
+
to: d,
|
|
1712
|
+
offset: this.targetOffset,
|
|
1713
|
+
flip: -1,
|
|
1714
|
+
shift: d,
|
|
1715
|
+
arrowWidth: this.arrowWidth,
|
|
1716
|
+
arrowLength: this.arrowLength
|
|
1717
|
+
}), this.targetArrow.setAttribute("d", g)), this.afterRenderEmitter.emit({
|
|
1718
|
+
edgePath: c,
|
|
1719
|
+
sourceArrowPath: l,
|
|
1720
|
+
targetArrowPath: g
|
|
1852
1721
|
});
|
|
1853
1722
|
}
|
|
1854
|
-
|
|
1723
|
+
}
|
|
1724
|
+
const qe = () => {
|
|
1725
|
+
const r = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
|
1726
|
+
return r.style.pointerEvents = "auto", r.style.cursor = "pointer", r;
|
|
1727
|
+
}, et = (r) => {
|
|
1728
|
+
const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
1729
|
+
return e.setAttribute("stroke", "transparent"), e.setAttribute("stroke-width", `${r}`), e.setAttribute("fill", "none"), e.setAttribute("stroke-linecap", "round"), e;
|
|
1730
|
+
}, ae = (r) => {
|
|
1731
|
+
const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
1732
|
+
return e.setAttribute("stroke-linejoin", "round"), e.setAttribute("stroke-width", `${r}`), e.setAttribute("fill", "transparent"), e.setAttribute("stroke", "transparent"), e;
|
|
1855
1733
|
};
|
|
1856
|
-
class
|
|
1734
|
+
class tt extends Error {
|
|
1857
1735
|
constructor(e) {
|
|
1858
|
-
|
|
1859
|
-
o(this, "median");
|
|
1860
|
-
this.params = e;
|
|
1861
|
-
const t = this.params.to;
|
|
1862
|
-
this.median = { x: t.x / 2, y: t.y / 2 };
|
|
1863
|
-
const s = this.params.hasSourceArrow ? y(
|
|
1864
|
-
{ x: this.params.arrowLength, y: w.y },
|
|
1865
|
-
this.params.sourceDirection,
|
|
1866
|
-
w
|
|
1867
|
-
) : w, i = this.params.hasTargetArrow ? y(
|
|
1868
|
-
{
|
|
1869
|
-
x: this.params.to.x - this.params.arrowLength,
|
|
1870
|
-
y: this.params.to.y
|
|
1871
|
-
},
|
|
1872
|
-
this.params.targetDirection,
|
|
1873
|
-
this.params.to
|
|
1874
|
-
) : this.params.to, n = this.params.arrowLength + this.params.arrowOffset, h = n - this.params.roundness, a = y(
|
|
1875
|
-
{ x: h, y: w.y },
|
|
1876
|
-
this.params.sourceDirection,
|
|
1877
|
-
w
|
|
1878
|
-
), d = y(
|
|
1879
|
-
{ x: this.params.to.x - h, y: this.params.to.y },
|
|
1880
|
-
this.params.targetDirection,
|
|
1881
|
-
this.params.to
|
|
1882
|
-
), c = Math.max((a.x + d.x) / 2, n), g = this.params.to.y / 2, l = {
|
|
1883
|
-
x: this.params.flipX > 0 ? c : -n,
|
|
1884
|
-
y: a.y
|
|
1885
|
-
}, p = { x: l.x, y: g }, f = {
|
|
1886
|
-
x: this.params.flipX > 0 ? this.params.to.x - c : this.params.to.x + n,
|
|
1887
|
-
y: d.y
|
|
1888
|
-
}, v = { x: f.x, y: g };
|
|
1889
|
-
this.path = R(
|
|
1890
|
-
[s, a, l, p, v, f, d, i],
|
|
1891
|
-
this.params.roundness
|
|
1892
|
-
);
|
|
1736
|
+
super(e), this.name = "InteractiveEdgeError";
|
|
1893
1737
|
}
|
|
1894
1738
|
}
|
|
1895
|
-
class
|
|
1896
|
-
constructor(e) {
|
|
1897
|
-
o(this, "
|
|
1898
|
-
o(this, "
|
|
1899
|
-
this
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
)
|
|
1916
|
-
{ x: this.params.to.x - i, y: this.params.to.y },
|
|
1917
|
-
this.params.targetDirection,
|
|
1918
|
-
this.params.to
|
|
1919
|
-
), p = { x: l.x + d, y: l.y + c }, f = { x: (g.x + p.x) / 2, y: (g.y + p.y) / 2 };
|
|
1920
|
-
this.median = le(f, e.flipX, e.flipY, e.to), this.path = R(
|
|
1921
|
-
[t, n, g, p, l, s],
|
|
1922
|
-
this.params.roundness
|
|
1923
|
-
);
|
|
1739
|
+
class Te {
|
|
1740
|
+
constructor(e, t) {
|
|
1741
|
+
o(this, "svg");
|
|
1742
|
+
o(this, "group");
|
|
1743
|
+
o(this, "line");
|
|
1744
|
+
o(this, "sourceArrow");
|
|
1745
|
+
o(this, "targetArrow");
|
|
1746
|
+
o(this, "handle", qe());
|
|
1747
|
+
o(this, "onAfterRender");
|
|
1748
|
+
o(this, "interactiveLine");
|
|
1749
|
+
o(this, "interactiveSourceArrow", null);
|
|
1750
|
+
o(this, "interactiveTargetArrow", null);
|
|
1751
|
+
if (this.baseEdge = e, e instanceof Te)
|
|
1752
|
+
throw new tt(
|
|
1753
|
+
"interactive edge can be configured only once"
|
|
1754
|
+
);
|
|
1755
|
+
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;
|
|
1756
|
+
const s = (t == null ? void 0 : t.width) ?? u.interactiveWidth;
|
|
1757
|
+
this.interactiveLine = et(s), this.handle.appendChild(this.interactiveLine), this.sourceArrow && (this.interactiveSourceArrow = ae(s), this.handle.appendChild(this.interactiveSourceArrow)), this.targetArrow && (this.interactiveTargetArrow = ae(s), this.handle.appendChild(this.interactiveTargetArrow)), this.group.appendChild(this.handle), this.baseEdge.onAfterRender.subscribe((i) => {
|
|
1758
|
+
this.interactiveLine.setAttribute("d", i.edgePath.path), this.interactiveSourceArrow && this.interactiveSourceArrow.setAttribute("d", i.sourceArrowPath), this.interactiveTargetArrow && this.interactiveTargetArrow.setAttribute("d", i.targetArrowPath);
|
|
1759
|
+
});
|
|
1924
1760
|
}
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
constructor(e) {
|
|
1928
|
-
o(this, "path");
|
|
1929
|
-
o(this, "median");
|
|
1930
|
-
this.params = e;
|
|
1931
|
-
const t = this.params.to;
|
|
1932
|
-
this.median = { x: t.x / 2, y: t.y / 2 };
|
|
1933
|
-
const s = this.params.hasSourceArrow ? y(
|
|
1934
|
-
{ x: this.params.arrowLength, y: w.y },
|
|
1935
|
-
this.params.sourceDirection,
|
|
1936
|
-
w
|
|
1937
|
-
) : w, i = this.params.hasTargetArrow ? y(
|
|
1938
|
-
{
|
|
1939
|
-
x: this.params.to.x - this.params.arrowLength,
|
|
1940
|
-
y: this.params.to.y
|
|
1941
|
-
},
|
|
1942
|
-
this.params.targetDirection,
|
|
1943
|
-
this.params.to
|
|
1944
|
-
) : this.params.to, n = this.params.arrowLength + this.params.arrowOffset, h = y(
|
|
1945
|
-
{ x: n, y: w.y },
|
|
1946
|
-
this.params.sourceDirection,
|
|
1947
|
-
w
|
|
1948
|
-
), a = y(
|
|
1949
|
-
{ x: this.params.to.x - n, y: this.params.to.y },
|
|
1950
|
-
this.params.targetDirection,
|
|
1951
|
-
this.params.to
|
|
1952
|
-
);
|
|
1953
|
-
this.path = R([s, h, a, i], this.params.roundness);
|
|
1761
|
+
render(e) {
|
|
1762
|
+
this.baseEdge.render(e);
|
|
1954
1763
|
}
|
|
1955
1764
|
}
|
|
1956
|
-
class
|
|
1957
|
-
constructor(e) {
|
|
1958
|
-
o(this, "
|
|
1959
|
-
o(this, "
|
|
1960
|
-
this
|
|
1961
|
-
|
|
1962
|
-
this
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
this.params.sourceDirection,
|
|
1977
|
-
w
|
|
1978
|
-
), d = y(
|
|
1979
|
-
{ x: this.params.to.x - h, y: this.params.to.y },
|
|
1980
|
-
this.params.targetDirection,
|
|
1981
|
-
this.params.to
|
|
1982
|
-
), c = Math.max((a.y + d.y) / 2, n), g = this.params.to.x / 2, l = {
|
|
1983
|
-
x: a.x,
|
|
1984
|
-
y: this.params.flipY > 0 ? c : -n
|
|
1985
|
-
}, p = { x: g, y: l.y }, f = {
|
|
1986
|
-
x: d.x,
|
|
1987
|
-
y: this.params.flipY > 0 ? this.params.to.y - c : this.params.to.y + n
|
|
1988
|
-
}, v = { x: g, y: f.y };
|
|
1989
|
-
this.path = R(
|
|
1990
|
-
[s, a, l, p, v, f, d, i],
|
|
1991
|
-
this.params.roundness
|
|
1992
|
-
);
|
|
1765
|
+
class xt {
|
|
1766
|
+
constructor(e, t) {
|
|
1767
|
+
o(this, "group");
|
|
1768
|
+
o(this, "line");
|
|
1769
|
+
o(this, "sourceArrow");
|
|
1770
|
+
o(this, "targetArrow");
|
|
1771
|
+
o(this, "onAfterRender");
|
|
1772
|
+
o(this, "svg");
|
|
1773
|
+
/**
|
|
1774
|
+
* @deprecated
|
|
1775
|
+
* use midpointElement instead
|
|
1776
|
+
*/
|
|
1777
|
+
o(this, "medianElement");
|
|
1778
|
+
this.baseShape = e, this.midpointElement = t, this.medianElement = this.midpointElement, 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) => {
|
|
1779
|
+
const i = s.edgePath.midpoint, n = `translate(${i.x}px, ${i.y}px)`;
|
|
1780
|
+
this.midpointElement.style.setProperty("transform", n);
|
|
1781
|
+
});
|
|
1782
|
+
}
|
|
1783
|
+
render(e) {
|
|
1784
|
+
this.baseShape.render(e);
|
|
1993
1785
|
}
|
|
1994
1786
|
}
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
1787
|
+
const De = (r, e) => {
|
|
1788
|
+
const t = new fe(), s = new ue(t, e, r), i = {
|
|
1789
|
+
nodes: {
|
|
1790
|
+
centerFn: me,
|
|
1791
|
+
priorityFn: () => 0
|
|
1792
|
+
},
|
|
1793
|
+
edges: {
|
|
1794
|
+
shapeFactory: () => new Pe(),
|
|
1795
|
+
priorityFn: () => 0
|
|
1796
|
+
},
|
|
1797
|
+
ports: {
|
|
1798
|
+
direction: 0
|
|
1799
|
+
}
|
|
1800
|
+
};
|
|
1801
|
+
return new we(
|
|
1802
|
+
r,
|
|
1803
|
+
t,
|
|
1804
|
+
e,
|
|
1805
|
+
s,
|
|
1806
|
+
i
|
|
1807
|
+
);
|
|
1808
|
+
};
|
|
1809
|
+
class K {
|
|
1810
|
+
constructor(e, t, s, i) {
|
|
1811
|
+
o(this, "grabbedNodeId", null);
|
|
1812
|
+
o(this, "maxNodePriority", 0);
|
|
1813
|
+
o(this, "previousTouchCoordinates", null);
|
|
1814
|
+
o(this, "graph");
|
|
1815
|
+
o(this, "onAfterNodeAdded", (e) => {
|
|
1816
|
+
this.updateMaxNodePriority(e);
|
|
1817
|
+
const t = this.graph.getNode(e);
|
|
1818
|
+
t.element.addEventListener("mousedown", this.onMouseDown, {
|
|
1819
|
+
passive: !0
|
|
1820
|
+
}), t.element.addEventListener("touchstart", this.onTouchStart, {
|
|
1821
|
+
passive: !0
|
|
1822
|
+
});
|
|
1823
|
+
});
|
|
1824
|
+
o(this, "onAfterNodeUpdated", (e) => {
|
|
1825
|
+
this.updateMaxNodePriority(e);
|
|
1826
|
+
});
|
|
1827
|
+
o(this, "onBeforeNodeRemoved", (e) => {
|
|
1828
|
+
const t = this.graph.getNode(e);
|
|
1829
|
+
t.element.removeEventListener("mousedown", this.onMouseDown), t.element.removeEventListener("touchstart", this.onTouchStart);
|
|
1830
|
+
});
|
|
1831
|
+
o(this, "onBeforeDestroy", () => {
|
|
1832
|
+
this.graph.onAfterNodeAdded.unsubscribe(this.onAfterNodeAdded), this.graph.onAfterNodeUpdated.unsubscribe(this.onAfterNodeUpdated), this.graph.onBeforeNodeRemoved.unsubscribe(this.onBeforeNodeRemoved), this.graph.onBeforeClear.unsubscribe(this.onBeforeClear), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy), this.removeMouseDragListeners(), this.removeTouchDragListeners();
|
|
1833
|
+
});
|
|
1834
|
+
o(this, "onBeforeClear", () => {
|
|
1835
|
+
this.canvas.graph.getAllNodeIds().forEach((e) => {
|
|
1836
|
+
const t = this.canvas.graph.getNode(e);
|
|
1837
|
+
t.element.removeEventListener("mousedown", this.onMouseDown), t.element.removeEventListener("touchstart", this.onTouchStart);
|
|
1838
|
+
}), this.maxNodePriority = 0;
|
|
1839
|
+
});
|
|
1840
|
+
o(this, "onMouseDown", (e) => {
|
|
1841
|
+
if (!this.config.mouseDownEventVerifier(e))
|
|
1842
|
+
return;
|
|
1843
|
+
const t = e.currentTarget, s = this.graph.getElementNodeId(t), i = this.graph.getNode(s);
|
|
1844
|
+
this.config.onBeforeNodeDrag({
|
|
1845
|
+
nodeId: s,
|
|
1846
|
+
element: i.element,
|
|
1847
|
+
x: i.x,
|
|
1848
|
+
y: i.y
|
|
1849
|
+
}) && (e.stopImmediatePropagation(), this.grabbedNodeId = s, U(this.element, this.config.dragCursor), this.moveNodeOnTop(s), this.window.addEventListener("mouseup", this.onWindowMouseUp, {
|
|
1850
|
+
passive: !0
|
|
1851
|
+
}), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
|
|
1852
|
+
passive: !0
|
|
1853
|
+
}));
|
|
1854
|
+
});
|
|
1855
|
+
o(this, "onTouchStart", (e) => {
|
|
1856
|
+
if (e.touches.length !== 1)
|
|
1857
|
+
return;
|
|
1858
|
+
e.stopImmediatePropagation(), this.previousTouchCoordinates = {
|
|
1859
|
+
x: e.touches[0].clientX,
|
|
1860
|
+
y: e.touches[0].clientY
|
|
1861
|
+
};
|
|
1862
|
+
const t = e.currentTarget, s = this.canvas.graph.getElementNodeId(t), i = this.graph.getNode(s);
|
|
1863
|
+
this.config.onBeforeNodeDrag({
|
|
1864
|
+
nodeId: s,
|
|
1865
|
+
element: i.element,
|
|
1866
|
+
x: i.x,
|
|
1867
|
+
y: i.y
|
|
1868
|
+
}) && (this.grabbedNodeId = s, this.moveNodeOnTop(s), this.window.addEventListener("touchmove", this.onWindowTouchMove, {
|
|
1869
|
+
passive: !0
|
|
1870
|
+
}), this.window.addEventListener("touchend", this.onWindowTouchFinish, {
|
|
1871
|
+
passive: !0
|
|
1872
|
+
}), this.window.addEventListener("touchcancel", this.onWindowTouchFinish, {
|
|
1873
|
+
passive: !0
|
|
1874
|
+
}));
|
|
1875
|
+
});
|
|
1876
|
+
o(this, "onWindowMouseMove", (e) => {
|
|
1877
|
+
if (!L(
|
|
1878
|
+
this.window,
|
|
1879
|
+
this.element,
|
|
1880
|
+
e.clientX,
|
|
1881
|
+
e.clientY
|
|
1882
|
+
)) {
|
|
1883
|
+
this.cancelMouseDrag();
|
|
1884
|
+
return;
|
|
1885
|
+
}
|
|
1886
|
+
this.grabbedNodeId !== null && this.dragNode(this.grabbedNodeId, e.movementX, e.movementY);
|
|
1887
|
+
});
|
|
1888
|
+
o(this, "onWindowMouseUp", (e) => {
|
|
1889
|
+
this.config.mouseUpEventVerifier(e) && this.cancelMouseDrag();
|
|
1890
|
+
});
|
|
1891
|
+
o(this, "onWindowTouchMove", (e) => {
|
|
1892
|
+
if (e.touches.length !== 1)
|
|
1893
|
+
return;
|
|
1894
|
+
const t = e.touches[0];
|
|
1895
|
+
if (!L(
|
|
1896
|
+
this.window,
|
|
1897
|
+
this.element,
|
|
1898
|
+
t.clientX,
|
|
1899
|
+
t.clientY
|
|
1900
|
+
)) {
|
|
1901
|
+
this.cancelTouchDrag();
|
|
1902
|
+
return;
|
|
1903
|
+
}
|
|
1904
|
+
if (this.grabbedNodeId !== null && this.previousTouchCoordinates !== null) {
|
|
1905
|
+
const i = t.clientX - this.previousTouchCoordinates.x, n = t.clientY - this.previousTouchCoordinates.y;
|
|
1906
|
+
this.dragNode(this.grabbedNodeId, i, n), this.previousTouchCoordinates = {
|
|
1907
|
+
x: e.touches[0].clientX,
|
|
1908
|
+
y: e.touches[0].clientY
|
|
1909
|
+
};
|
|
1910
|
+
}
|
|
1911
|
+
});
|
|
1912
|
+
o(this, "onWindowTouchFinish", () => {
|
|
1913
|
+
this.previousTouchCoordinates = null, this.cancelTouchDrag();
|
|
1914
|
+
});
|
|
1915
|
+
this.canvas = e, this.element = t, this.window = s, this.config = 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);
|
|
2013
1916
|
}
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
constructor(e) {
|
|
2017
|
-
o(this, "path");
|
|
2018
|
-
o(this, "median");
|
|
2019
|
-
this.params = e;
|
|
2020
|
-
const t = this.params.smallRadius, s = this.params.radius, i = t + s, n = t * s / i, h = Math.sqrt(i * i - t * t), a = h * t / i, d = h + s + this.params.arrowLength, c = this.params.arrowLength + a, l = [
|
|
2021
|
-
{ x: this.params.arrowLength, y: w.y },
|
|
2022
|
-
{ x: c, y: n },
|
|
2023
|
-
{ x: c, y: -n },
|
|
2024
|
-
{ x: d, y: 0 }
|
|
2025
|
-
].map(
|
|
2026
|
-
(v) => y(v, this.params.sourceDirection, w)
|
|
2027
|
-
), p = [
|
|
2028
|
-
`M ${l[0].x} ${l[0].y}`,
|
|
2029
|
-
`A ${t} ${t} 0 0 1 ${l[1].x} ${l[1].y}`,
|
|
2030
|
-
`A ${s} ${s} 0 1 0 ${l[2].x} ${l[2].y}`,
|
|
2031
|
-
`A ${t} ${t} 0 0 1 ${l[0].x} ${l[0].y}`
|
|
2032
|
-
].join(" "), f = `M 0 0 L ${l[0].x} ${l[0].y} `;
|
|
2033
|
-
this.path = `${this.params.hasSourceArrow || this.params.hasTargetArrow ? "" : f}${p}`, this.median = l[3];
|
|
1917
|
+
static configure(e, t, s, i) {
|
|
1918
|
+
new K(e, t, s, i);
|
|
2034
1919
|
}
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
o(this, "path");
|
|
2039
|
-
o(this, "median");
|
|
2040
|
-
o(this, "diagonalDistance");
|
|
2041
|
-
this.params = e;
|
|
2042
|
-
const t = this.params.to;
|
|
2043
|
-
if (this.median = { x: t.x / 2, y: t.y / 2 }, this.diagonalDistance = Math.sqrt(
|
|
2044
|
-
this.params.to.x * this.params.to.x + this.params.to.y * this.params.to.y
|
|
2045
|
-
), Math.sqrt(
|
|
2046
|
-
this.params.to.x * this.params.to.x + this.params.to.y * this.params.to.y
|
|
2047
|
-
) === 0) {
|
|
2048
|
-
this.path = "";
|
|
1920
|
+
dragNode(e, t, s) {
|
|
1921
|
+
const i = this.graph.getNode(e);
|
|
1922
|
+
if (i === null)
|
|
2049
1923
|
return;
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
1924
|
+
const n = this.canvas.viewport.getContentMatrix(), h = T(n, {
|
|
1925
|
+
x: i.x,
|
|
1926
|
+
y: i.y
|
|
1927
|
+
}), a = T(
|
|
1928
|
+
{ scale: 1, x: t, y: s },
|
|
1929
|
+
h
|
|
1930
|
+
), d = this.canvas.viewport.getViewportMatrix(), c = T(d, a);
|
|
1931
|
+
this.canvas.updateNode(e, { x: c.x, y: c.y }), this.config.onNodeDrag({
|
|
1932
|
+
nodeId: e,
|
|
1933
|
+
element: i.element,
|
|
1934
|
+
x: c.x,
|
|
1935
|
+
y: c.y
|
|
2061
1936
|
});
|
|
2062
|
-
this.path = `M ${i.x} ${i.y} L ${n.x} ${n.y}`;
|
|
2063
1937
|
}
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
1938
|
+
moveNodeOnTop(e) {
|
|
1939
|
+
if (this.config.moveOnTop) {
|
|
1940
|
+
if (this.maxNodePriority++, this.config.moveEdgesOnTop) {
|
|
1941
|
+
const t = this.maxNodePriority;
|
|
1942
|
+
this.maxNodePriority++, this.graph.getNodeAdjacentEdgeIds(e).forEach((i) => {
|
|
1943
|
+
this.canvas.updateEdge(i, { priority: t });
|
|
1944
|
+
});
|
|
1945
|
+
}
|
|
1946
|
+
this.canvas.updateNode(e, { priority: this.maxNodePriority });
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
cancelMouseDrag() {
|
|
1950
|
+
const e = this.graph.getNode(this.grabbedNodeId);
|
|
1951
|
+
e !== null && this.config.onNodeDragFinished({
|
|
1952
|
+
nodeId: this.grabbedNodeId,
|
|
1953
|
+
element: e.element,
|
|
1954
|
+
x: e.x,
|
|
1955
|
+
y: e.y
|
|
1956
|
+
}), this.grabbedNodeId = null, U(this.element, null), this.removeMouseDragListeners();
|
|
1957
|
+
}
|
|
1958
|
+
removeMouseDragListeners() {
|
|
1959
|
+
this.window.removeEventListener("mouseup", this.onWindowMouseUp), this.window.removeEventListener("mousemove", this.onWindowMouseMove);
|
|
1960
|
+
}
|
|
1961
|
+
cancelTouchDrag() {
|
|
1962
|
+
this.previousTouchCoordinates = null;
|
|
1963
|
+
const e = this.graph.getNode(this.grabbedNodeId);
|
|
1964
|
+
e !== null && this.config.onNodeDragFinished({
|
|
1965
|
+
nodeId: this.grabbedNodeId,
|
|
1966
|
+
element: e.element,
|
|
1967
|
+
x: e.x,
|
|
1968
|
+
y: e.y
|
|
1969
|
+
}), this.grabbedNodeId = null, this.removeTouchDragListeners();
|
|
1970
|
+
}
|
|
1971
|
+
removeTouchDragListeners() {
|
|
1972
|
+
this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
|
|
1973
|
+
}
|
|
1974
|
+
updateMaxNodePriority(e) {
|
|
1975
|
+
const t = this.graph.getNode(e).priority;
|
|
1976
|
+
this.maxNodePriority = Math.max(this.maxNodePriority, t);
|
|
2070
1977
|
}
|
|
2071
1978
|
}
|
|
2072
|
-
const
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
}),
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
y: r.y + r.height / 2
|
|
2092
|
-
}, s = {
|
|
2093
|
-
x: e.x + e.width / 2,
|
|
2094
|
-
y: e.y + e.height / 2
|
|
2095
|
-
}, i = Math.min(t.x, s.x), n = Math.min(t.y, s.y), h = Math.abs(s.x - t.x), a = Math.abs(s.y - t.y), d = t.x <= s.x ? 1 : -1, c = t.y <= s.y ? 1 : -1;
|
|
1979
|
+
const rt = (r, e, t) => ({
|
|
1980
|
+
scale: r.scale,
|
|
1981
|
+
x: r.x + r.scale * e,
|
|
1982
|
+
y: r.y + r.scale * t
|
|
1983
|
+
}), ot = (r, e, t, s) => ({
|
|
1984
|
+
scale: r.scale * e,
|
|
1985
|
+
x: r.scale * (1 - e) * t + r.x,
|
|
1986
|
+
y: r.scale * (1 - e) * s + r.y
|
|
1987
|
+
}), I = (r) => {
|
|
1988
|
+
const e = [], t = r.touches.length;
|
|
1989
|
+
for (let a = 0; a < t; a++)
|
|
1990
|
+
e.push([r.touches[a].clientX, r.touches[a].clientY]);
|
|
1991
|
+
const s = e.reduce(
|
|
1992
|
+
(a, d) => [a[0] + d[0], a[1] + d[1]],
|
|
1993
|
+
[0, 0]
|
|
1994
|
+
), i = [s[0] / t, s[1] / t], h = e.map((a) => [a[0] - i[0], a[1] - i[1]]).reduce(
|
|
1995
|
+
(a, d) => a + Math.sqrt(d[0] * d[0] + d[1] * d[1]),
|
|
1996
|
+
0
|
|
1997
|
+
);
|
|
2096
1998
|
return {
|
|
2097
|
-
x: i,
|
|
2098
|
-
y:
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
flipY: c
|
|
1999
|
+
x: i[0],
|
|
2000
|
+
y: i[1],
|
|
2001
|
+
scale: h / t,
|
|
2002
|
+
touchesCnt: t,
|
|
2003
|
+
touches: e
|
|
2103
2004
|
};
|
|
2104
|
-
}
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
o(this, "
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
o(this, "
|
|
2139
|
-
|
|
2005
|
+
};
|
|
2006
|
+
class $ {
|
|
2007
|
+
constructor(e, t, s, i) {
|
|
2008
|
+
o(this, "viewport");
|
|
2009
|
+
o(this, "prevTouches", null);
|
|
2010
|
+
o(this, "wheelFinishTimer", null);
|
|
2011
|
+
o(this, "transformInProgress", !1);
|
|
2012
|
+
o(this, "onBeforeDestroy", () => {
|
|
2013
|
+
this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.observer.unobserve(this.element), this.element.removeEventListener("mousedown", this.onMouseDown), this.element.removeEventListener("wheel", this.onWheelScroll), this.element.removeEventListener("touchstart", this.onTouchStart), this.element.removeEventListener("wheel", this.preventWheelScaleListener), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy);
|
|
2014
|
+
});
|
|
2015
|
+
o(this, "onMouseDown", (e) => {
|
|
2016
|
+
this.element === null || !this.params.mouseDownEventVerifier(e) || (U(this.element, this.params.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
|
|
2017
|
+
passive: !0
|
|
2018
|
+
}), this.window.addEventListener("mouseup", this.onWindowMouseUp, {
|
|
2019
|
+
passive: !0
|
|
2020
|
+
}), this.startRegisteredTransform());
|
|
2021
|
+
});
|
|
2022
|
+
o(this, "onWindowMouseMove", (e) => {
|
|
2023
|
+
const t = L(
|
|
2024
|
+
this.window,
|
|
2025
|
+
this.element,
|
|
2026
|
+
e.clientX,
|
|
2027
|
+
e.clientY
|
|
2028
|
+
);
|
|
2029
|
+
if (this.element === null || !t) {
|
|
2030
|
+
this.stopMouseDrag();
|
|
2031
|
+
return;
|
|
2032
|
+
}
|
|
2033
|
+
const s = -e.movementX, i = -e.movementY;
|
|
2034
|
+
this.moveViewport(s, i);
|
|
2035
|
+
});
|
|
2036
|
+
o(this, "onWindowMouseUp", (e) => {
|
|
2037
|
+
this.element === null || !this.params.mouseUpEventVerifier(e) || this.stopMouseDrag();
|
|
2038
|
+
});
|
|
2039
|
+
o(this, "onWheelScroll", (e) => {
|
|
2040
|
+
if (!this.params.mouseWheelEventVerifier(e))
|
|
2041
|
+
return;
|
|
2042
|
+
const { left: t, top: s } = this.element.getBoundingClientRect(), i = e.clientX - t, n = e.clientY - s, a = 1 / (e.deltaY < 0 ? this.params.wheelSensitivity : 1 / this.params.wheelSensitivity);
|
|
2043
|
+
this.wheelFinishTimer === null && this.params.onTransformStarted(), this.scaleViewport(a, i, n), this.wheelFinishTimer !== null && clearTimeout(this.wheelFinishTimer), this.wheelFinishTimer = setTimeout(() => {
|
|
2044
|
+
this.transformInProgress || this.params.onTransformFinished(), this.wheelFinishTimer = null;
|
|
2045
|
+
}, this.params.scaleWheelFinishTimeout);
|
|
2046
|
+
});
|
|
2047
|
+
o(this, "onTouchStart", (e) => {
|
|
2048
|
+
if (this.prevTouches !== null) {
|
|
2049
|
+
this.prevTouches = I(e);
|
|
2050
|
+
return;
|
|
2051
|
+
}
|
|
2052
|
+
this.prevTouches = I(e), this.window.addEventListener("touchmove", this.onWindowTouchMove, {
|
|
2053
|
+
passive: !0
|
|
2054
|
+
}), this.window.addEventListener("touchend", this.onWindowTouchFinish, {
|
|
2055
|
+
passive: !0
|
|
2056
|
+
}), this.window.addEventListener("touchcancel", this.onWindowTouchFinish, {
|
|
2057
|
+
passive: !0
|
|
2058
|
+
}), this.startRegisteredTransform();
|
|
2059
|
+
});
|
|
2060
|
+
o(this, "onWindowTouchMove", (e) => {
|
|
2061
|
+
const t = I(e);
|
|
2062
|
+
if (!t.touches.every(
|
|
2063
|
+
(i) => L(this.window, this.element, i[0], i[1])
|
|
2064
|
+
)) {
|
|
2065
|
+
this.stopTouchDrag();
|
|
2066
|
+
return;
|
|
2067
|
+
}
|
|
2068
|
+
if ((t.touchesCnt === 1 || t.touchesCnt === 2) && this.moveViewport(
|
|
2069
|
+
-(t.x - this.prevTouches.x),
|
|
2070
|
+
-(t.y - this.prevTouches.y)
|
|
2071
|
+
), t.touchesCnt === 2) {
|
|
2072
|
+
const { left: i, top: n } = this.element.getBoundingClientRect(), h = this.prevTouches.x - i, a = this.prevTouches.y - n, c = 1 / (t.scale / this.prevTouches.scale);
|
|
2073
|
+
this.scaleViewport(c, h, a);
|
|
2074
|
+
}
|
|
2075
|
+
this.prevTouches = t;
|
|
2076
|
+
});
|
|
2077
|
+
o(this, "onWindowTouchFinish", (e) => {
|
|
2078
|
+
e.touches.length > 0 ? this.prevTouches = I(e) : this.stopTouchDrag();
|
|
2079
|
+
});
|
|
2080
|
+
o(this, "observer", new ResizeObserver(() => {
|
|
2081
|
+
const e = this.viewport.getViewportMatrix(), { width: t, height: s } = this.element.getBoundingClientRect(), i = this.params.transformPreprocessor({
|
|
2082
|
+
prevTransform: e,
|
|
2083
|
+
nextTransform: e,
|
|
2084
|
+
canvasWidth: t,
|
|
2085
|
+
canvasHeight: s
|
|
2086
|
+
});
|
|
2087
|
+
this.params.onResizeTransformStarted(), this.canvas.patchViewportMatrix(i), this.params.onResizeTransformFinished();
|
|
2088
|
+
}));
|
|
2089
|
+
o(this, "preventWheelScaleListener", (e) => {
|
|
2090
|
+
e.preventDefault();
|
|
2091
|
+
});
|
|
2092
|
+
this.canvas = e, this.element = t, this.window = s, this.params = i, this.element.addEventListener("wheel", this.preventWheelScaleListener, {
|
|
2093
|
+
passive: !1
|
|
2094
|
+
}), this.viewport = e.viewport, this.observer.observe(this.element), this.element.addEventListener("mousedown", this.onMouseDown, {
|
|
2095
|
+
passive: !0
|
|
2096
|
+
}), this.element.addEventListener("wheel", this.onWheelScroll, {
|
|
2097
|
+
passive: !0
|
|
2098
|
+
}), this.element.addEventListener("touchstart", this.onTouchStart, {
|
|
2099
|
+
passive: !0
|
|
2100
|
+
}), e.onBeforeDestroy.subscribe(this.onBeforeDestroy);
|
|
2101
|
+
}
|
|
2102
|
+
static configure(e, t, s, i) {
|
|
2103
|
+
new $(e, t, s, i);
|
|
2104
|
+
}
|
|
2105
|
+
moveViewport(e, t) {
|
|
2106
|
+
const s = this.viewport.getViewportMatrix(), i = rt(s, e, t), { width: n, height: h } = this.element.getBoundingClientRect(), a = this.params.transformPreprocessor({
|
|
2107
|
+
prevTransform: s,
|
|
2108
|
+
nextTransform: i,
|
|
2109
|
+
canvasWidth: n,
|
|
2110
|
+
canvasHeight: h
|
|
2111
|
+
});
|
|
2112
|
+
this.performTransform(a);
|
|
2140
2113
|
}
|
|
2141
|
-
|
|
2142
|
-
const
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
const d = oe(
|
|
2148
|
-
e.from.direction,
|
|
2149
|
-
h,
|
|
2150
|
-
a
|
|
2151
|
-
), c = oe(
|
|
2152
|
-
e.to.direction,
|
|
2153
|
-
h,
|
|
2154
|
-
a
|
|
2155
|
-
), g = {
|
|
2156
|
-
x: i,
|
|
2157
|
-
y: n
|
|
2158
|
-
};
|
|
2159
|
-
let l = c, p = -this.params.arrowLength, f;
|
|
2160
|
-
e.from.portId === e.to.portId ? (f = this.params.createCyclePath, l = d, p = this.params.arrowLength) : e.from.nodeId === e.to.nodeId ? f = this.params.createDetourPath : f = this.params.createLinePath;
|
|
2161
|
-
const v = f(
|
|
2162
|
-
d,
|
|
2163
|
-
c,
|
|
2164
|
-
g,
|
|
2165
|
-
h,
|
|
2166
|
-
a
|
|
2167
|
-
);
|
|
2168
|
-
this.line.setAttribute("d", v.path);
|
|
2169
|
-
let A = null;
|
|
2170
|
-
this.sourceArrow && (A = O(
|
|
2171
|
-
d,
|
|
2172
|
-
w,
|
|
2173
|
-
this.params.arrowLength,
|
|
2174
|
-
this.params.arrowWidth
|
|
2175
|
-
), this.sourceArrow.setAttribute("d", A));
|
|
2176
|
-
let m = null;
|
|
2177
|
-
this.targetArrow && (m = O(
|
|
2178
|
-
l,
|
|
2179
|
-
g,
|
|
2180
|
-
p,
|
|
2181
|
-
this.params.arrowWidth
|
|
2182
|
-
), this.targetArrow.setAttribute("d", m)), this.afterRenderEmitter.emit({
|
|
2183
|
-
edgePath: v,
|
|
2184
|
-
sourceArrowPath: A,
|
|
2185
|
-
targetArrowPath: m
|
|
2114
|
+
scaleViewport(e, t, s) {
|
|
2115
|
+
const i = this.canvas.viewport.getViewportMatrix(), n = ot(i, e, t, s), { width: h, height: a } = this.element.getBoundingClientRect(), d = this.params.transformPreprocessor({
|
|
2116
|
+
prevTransform: i,
|
|
2117
|
+
nextTransform: n,
|
|
2118
|
+
canvasWidth: h,
|
|
2119
|
+
canvasHeight: a
|
|
2186
2120
|
});
|
|
2121
|
+
this.performTransform(d);
|
|
2187
2122
|
}
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
constructor(e) {
|
|
2191
|
-
o(this, "svg");
|
|
2192
|
-
o(this, "group");
|
|
2193
|
-
o(this, "line");
|
|
2194
|
-
o(this, "sourceArrow");
|
|
2195
|
-
o(this, "targetArrow");
|
|
2196
|
-
o(this, "onAfterRender");
|
|
2197
|
-
o(this, "arrowLength");
|
|
2198
|
-
o(this, "arrowWidth");
|
|
2199
|
-
o(this, "curvature");
|
|
2200
|
-
o(this, "portCycleRadius");
|
|
2201
|
-
o(this, "portCycleSmallRadius");
|
|
2202
|
-
o(this, "detourDirection");
|
|
2203
|
-
o(this, "detourDistance");
|
|
2204
|
-
o(this, "hasSourceArrow");
|
|
2205
|
-
o(this, "hasTargetArrow");
|
|
2206
|
-
o(this, "pathShape");
|
|
2207
|
-
o(this, "createCyclePath", (e) => new et({
|
|
2208
|
-
sourceDirection: e,
|
|
2209
|
-
radius: this.portCycleRadius,
|
|
2210
|
-
smallRadius: this.portCycleSmallRadius,
|
|
2211
|
-
arrowLength: this.arrowLength,
|
|
2212
|
-
hasSourceArrow: this.hasSourceArrow,
|
|
2213
|
-
hasTargetArrow: this.hasTargetArrow
|
|
2214
|
-
}));
|
|
2215
|
-
o(this, "createDetourPath", (e, t, s, i, n) => new Ke({
|
|
2216
|
-
to: s,
|
|
2217
|
-
sourceDirection: e,
|
|
2218
|
-
targetDirection: t,
|
|
2219
|
-
flipX: i,
|
|
2220
|
-
flipY: n,
|
|
2221
|
-
arrowLength: this.arrowLength,
|
|
2222
|
-
detourDirection: this.detourDirection,
|
|
2223
|
-
detourDistance: this.detourDistance,
|
|
2224
|
-
curvature: this.curvature,
|
|
2225
|
-
hasSourceArrow: this.hasSourceArrow,
|
|
2226
|
-
hasTargetArrow: this.hasTargetArrow
|
|
2227
|
-
}));
|
|
2228
|
-
o(this, "createLinePath", (e, t, s) => new Je({
|
|
2229
|
-
to: s,
|
|
2230
|
-
sourceDirection: e,
|
|
2231
|
-
targetDirection: t,
|
|
2232
|
-
arrowLength: this.arrowLength,
|
|
2233
|
-
curvature: this.curvature,
|
|
2234
|
-
hasSourceArrow: this.hasSourceArrow,
|
|
2235
|
-
hasTargetArrow: this.hasTargetArrow
|
|
2236
|
-
}));
|
|
2237
|
-
this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.curvature = (e == null ? void 0 : e.curvature) ?? u.curvature, this.portCycleRadius = (e == null ? void 0 : e.cycleRadius) ?? u.cycleRadius, this.portCycleSmallRadius = (e == null ? void 0 : e.smallCycleRadius) ?? u.smallCycleRadius, this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow, this.pathShape = new C({
|
|
2238
|
-
color: (e == null ? void 0 : e.color) ?? u.color,
|
|
2239
|
-
width: (e == null ? void 0 : e.width) ?? u.width,
|
|
2240
|
-
arrowLength: this.arrowLength,
|
|
2241
|
-
arrowWidth: this.arrowWidth,
|
|
2242
|
-
hasSourceArrow: this.hasSourceArrow,
|
|
2243
|
-
hasTargetArrow: this.hasTargetArrow,
|
|
2244
|
-
createCyclePath: this.createCyclePath,
|
|
2245
|
-
createDetourPath: this.createDetourPath,
|
|
2246
|
-
createLinePath: this.createLinePath
|
|
2247
|
-
}), this.svg = this.pathShape.svg, this.group = this.pathShape.group, this.line = this.pathShape.line, this.sourceArrow = this.pathShape.sourceArrow, this.targetArrow = this.pathShape.targetArrow, this.onAfterRender = this.pathShape.onAfterRender;
|
|
2123
|
+
stopMouseDrag() {
|
|
2124
|
+
U(this.element, null), this.removeMouseDragListeners(), this.finishRegisteredTransform();
|
|
2248
2125
|
}
|
|
2249
|
-
|
|
2250
|
-
this.
|
|
2126
|
+
removeMouseDragListeners() {
|
|
2127
|
+
this.window.removeEventListener("mousemove", this.onWindowMouseMove), this.window.removeEventListener("mouseup", this.onWindowMouseUp);
|
|
2251
2128
|
}
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
constructor(e) {
|
|
2255
|
-
o(this, "svg");
|
|
2256
|
-
o(this, "group");
|
|
2257
|
-
o(this, "line");
|
|
2258
|
-
o(this, "sourceArrow");
|
|
2259
|
-
o(this, "targetArrow");
|
|
2260
|
-
o(this, "onAfterRender");
|
|
2261
|
-
o(this, "arrowLength");
|
|
2262
|
-
o(this, "arrowWidth");
|
|
2263
|
-
o(this, "arrowOffset");
|
|
2264
|
-
o(this, "roundness");
|
|
2265
|
-
o(this, "cycleSquareSide");
|
|
2266
|
-
o(this, "detourDirection");
|
|
2267
|
-
o(this, "detourDistance");
|
|
2268
|
-
o(this, "hasSourceArrow");
|
|
2269
|
-
o(this, "hasTargetArrow");
|
|
2270
|
-
o(this, "pathShape");
|
|
2271
|
-
o(this, "createCyclePath", (e) => new G({
|
|
2272
|
-
sourceDirection: e,
|
|
2273
|
-
arrowLength: this.arrowLength,
|
|
2274
|
-
side: this.cycleSquareSide,
|
|
2275
|
-
arrowOffset: this.arrowOffset,
|
|
2276
|
-
roundness: this.roundness,
|
|
2277
|
-
hasSourceArrow: this.hasSourceArrow,
|
|
2278
|
-
hasTargetArrow: this.hasTargetArrow
|
|
2279
|
-
}));
|
|
2280
|
-
o(this, "createDetourPath", (e, t, s, i, n) => new j({
|
|
2281
|
-
to: s,
|
|
2282
|
-
sourceDirection: e,
|
|
2283
|
-
targetDirection: t,
|
|
2284
|
-
flipX: i,
|
|
2285
|
-
flipY: n,
|
|
2286
|
-
arrowLength: this.arrowLength,
|
|
2287
|
-
arrowOffset: this.arrowOffset,
|
|
2288
|
-
roundness: this.roundness,
|
|
2289
|
-
detourDirection: this.detourDirection,
|
|
2290
|
-
detourDistance: this.detourDistance,
|
|
2291
|
-
hasSourceArrow: this.hasSourceArrow,
|
|
2292
|
-
hasTargetArrow: this.hasTargetArrow
|
|
2293
|
-
}));
|
|
2294
|
-
o(this, "createLinePath", (e, t, s, i) => new Qe({
|
|
2295
|
-
to: s,
|
|
2296
|
-
sourceDirection: e,
|
|
2297
|
-
targetDirection: t,
|
|
2298
|
-
flipX: i,
|
|
2299
|
-
arrowLength: this.arrowLength,
|
|
2300
|
-
arrowOffset: this.arrowOffset,
|
|
2301
|
-
roundness: this.roundness,
|
|
2302
|
-
hasSourceArrow: this.hasSourceArrow,
|
|
2303
|
-
hasTargetArrow: this.hasTargetArrow
|
|
2304
|
-
}));
|
|
2305
|
-
this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? u.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? u.cycleSquareSide;
|
|
2306
|
-
const t = (e == null ? void 0 : e.roundness) ?? u.roundness;
|
|
2307
|
-
this.roundness = Math.min(
|
|
2308
|
-
t,
|
|
2309
|
-
this.arrowOffset,
|
|
2310
|
-
this.cycleSquareSide / 2
|
|
2311
|
-
), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow, this.pathShape = new C({
|
|
2312
|
-
color: (e == null ? void 0 : e.color) ?? u.color,
|
|
2313
|
-
width: (e == null ? void 0 : e.width) ?? u.width,
|
|
2314
|
-
arrowLength: this.arrowLength,
|
|
2315
|
-
arrowWidth: this.arrowWidth,
|
|
2316
|
-
hasSourceArrow: this.hasSourceArrow,
|
|
2317
|
-
hasTargetArrow: this.hasTargetArrow,
|
|
2318
|
-
createCyclePath: this.createCyclePath,
|
|
2319
|
-
createDetourPath: this.createDetourPath,
|
|
2320
|
-
createLinePath: this.createLinePath
|
|
2321
|
-
}), this.svg = this.pathShape.svg, this.group = this.pathShape.group, this.line = this.pathShape.line, this.sourceArrow = this.pathShape.sourceArrow, this.targetArrow = this.pathShape.targetArrow, this.onAfterRender = this.pathShape.onAfterRender;
|
|
2129
|
+
stopTouchDrag() {
|
|
2130
|
+
this.prevTouches = null, this.removeTouchDragListeners(), this.finishRegisteredTransform();
|
|
2322
2131
|
}
|
|
2323
|
-
|
|
2324
|
-
this.
|
|
2132
|
+
removeTouchDragListeners() {
|
|
2133
|
+
this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
|
|
2134
|
+
}
|
|
2135
|
+
performTransform(e) {
|
|
2136
|
+
this.params.onBeforeTransformChange(), this.canvas.patchViewportMatrix(e), this.params.onTransformChange();
|
|
2137
|
+
}
|
|
2138
|
+
startRegisteredTransform() {
|
|
2139
|
+
this.transformInProgress = !0, this.params.onTransformStarted();
|
|
2140
|
+
}
|
|
2141
|
+
finishRegisteredTransform() {
|
|
2142
|
+
this.transformInProgress = !1, this.params.onTransformFinished();
|
|
2325
2143
|
}
|
|
2326
2144
|
}
|
|
2327
|
-
class
|
|
2328
|
-
constructor(e) {
|
|
2329
|
-
o(this, "
|
|
2330
|
-
o(this, "
|
|
2331
|
-
o(this, "
|
|
2332
|
-
o(this, "
|
|
2333
|
-
o(this, "
|
|
2334
|
-
o(this, "
|
|
2335
|
-
o(this, "
|
|
2336
|
-
o(this, "
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
o(this, "
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2145
|
+
class Z {
|
|
2146
|
+
constructor(e, t, s, i, n, h) {
|
|
2147
|
+
o(this, "canvasResizeObserver");
|
|
2148
|
+
o(this, "nodeHorizontal");
|
|
2149
|
+
o(this, "nodeVertical");
|
|
2150
|
+
o(this, "viewport");
|
|
2151
|
+
o(this, "viewportWidth", 0);
|
|
2152
|
+
o(this, "viewportHeight", 0);
|
|
2153
|
+
o(this, "viewportMatrix");
|
|
2154
|
+
o(this, "loadedArea", {
|
|
2155
|
+
xFrom: 1 / 0,
|
|
2156
|
+
xTo: 1 / 0,
|
|
2157
|
+
yFrom: 1 / 0,
|
|
2158
|
+
yTo: 1 / 0
|
|
2159
|
+
});
|
|
2160
|
+
o(this, "updateLoadedArea", (e) => {
|
|
2161
|
+
this.loadedArea = {
|
|
2162
|
+
xFrom: e.x,
|
|
2163
|
+
xTo: e.x + e.width,
|
|
2164
|
+
yFrom: e.y,
|
|
2165
|
+
yTo: e.y + e.height
|
|
2166
|
+
};
|
|
2167
|
+
});
|
|
2168
|
+
o(this, "onBeforeDestroy", () => {
|
|
2169
|
+
this.trigger.unsubscribe(this.updateLoadedArea), this.canvasResizeObserver.unobserve(this.element), this.canvas.viewport.onAfterUpdated.unsubscribe(
|
|
2170
|
+
this.onAfterViewportUpdated
|
|
2171
|
+
), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy);
|
|
2172
|
+
});
|
|
2173
|
+
o(this, "onAfterViewportUpdated", () => {
|
|
2174
|
+
this.userTransformInProgress || (this.viewportMatrix = this.viewport.getViewportMatrix(), this.loadAreaAroundViewport());
|
|
2175
|
+
});
|
|
2176
|
+
o(this, "userTransformInProgress", !1);
|
|
2177
|
+
this.canvas = e, this.element = t, this.window = s, this.trigger = n, this.params = h, this.nodeHorizontal = this.params.nodeContainingRadius.horizontal, this.nodeVertical = this.params.nodeContainingRadius.vertical, this.canvasResizeObserver = new ResizeObserver((d) => {
|
|
2178
|
+
const c = d[0];
|
|
2179
|
+
this.viewportWidth = c.contentRect.width, this.viewportHeight = c.contentRect.height, this.scheduleLoadAreaAroundViewport();
|
|
2180
|
+
}), this.viewport = e.viewport;
|
|
2181
|
+
const a = {
|
|
2182
|
+
...i,
|
|
2183
|
+
onResizeTransformStarted: () => {
|
|
2184
|
+
this.userTransformInProgress = !0, i.onResizeTransformStarted();
|
|
2185
|
+
},
|
|
2186
|
+
onResizeTransformFinished: () => {
|
|
2187
|
+
this.userTransformInProgress = !1, i.onResizeTransformFinished();
|
|
2188
|
+
},
|
|
2189
|
+
onBeforeTransformChange: () => {
|
|
2190
|
+
this.userTransformInProgress = !0, i.onBeforeTransformChange();
|
|
2191
|
+
},
|
|
2192
|
+
onTransformChange: () => {
|
|
2193
|
+
this.userTransformInProgress = !1;
|
|
2194
|
+
const d = this.viewportMatrix;
|
|
2195
|
+
this.viewportMatrix = this.viewport.getViewportMatrix(), d.scale !== this.viewportMatrix.scale && this.scheduleEnsureViewportAreaLoaded(), i.onTransformChange();
|
|
2196
|
+
},
|
|
2197
|
+
onTransformFinished: () => {
|
|
2198
|
+
this.scheduleLoadAreaAroundViewport(), i.onTransformFinished();
|
|
2199
|
+
}
|
|
2200
|
+
};
|
|
2201
|
+
$.configure(
|
|
2202
|
+
e,
|
|
2203
|
+
this.element,
|
|
2204
|
+
this.window,
|
|
2205
|
+
a
|
|
2206
|
+
), this.viewportMatrix = this.viewport.getViewportMatrix(), this.trigger.subscribe(this.updateLoadedArea), this.canvasResizeObserver.observe(this.element), this.canvas.viewport.onAfterUpdated.subscribe(this.onAfterViewportUpdated), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
|
|
2207
|
+
}
|
|
2208
|
+
static configure(e, t, s, i, n, h) {
|
|
2209
|
+
new Z(
|
|
2210
|
+
e,
|
|
2381
2211
|
t,
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
arrowLength: this.arrowLength,
|
|
2388
|
-
arrowWidth: this.arrowWidth,
|
|
2389
|
-
hasSourceArrow: this.hasSourceArrow,
|
|
2390
|
-
hasTargetArrow: this.hasTargetArrow,
|
|
2391
|
-
createCyclePath: this.createCyclePath,
|
|
2392
|
-
createDetourPath: this.createDetourPath,
|
|
2393
|
-
createLinePath: this.createLinePath
|
|
2394
|
-
}), this.svg = this.pathShape.svg, this.group = this.pathShape.group, this.line = this.pathShape.line, this.sourceArrow = this.pathShape.sourceArrow, this.targetArrow = this.pathShape.targetArrow, this.onAfterRender = this.pathShape.onAfterRender;
|
|
2212
|
+
s,
|
|
2213
|
+
i,
|
|
2214
|
+
n,
|
|
2215
|
+
h
|
|
2216
|
+
);
|
|
2395
2217
|
}
|
|
2396
|
-
|
|
2397
|
-
|
|
2218
|
+
scheduleLoadAreaAroundViewport() {
|
|
2219
|
+
setTimeout(() => {
|
|
2220
|
+
this.loadAreaAroundViewport();
|
|
2221
|
+
});
|
|
2398
2222
|
}
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
o(this, "svg");
|
|
2403
|
-
o(this, "group");
|
|
2404
|
-
o(this, "line");
|
|
2405
|
-
o(this, "sourceArrow");
|
|
2406
|
-
o(this, "targetArrow");
|
|
2407
|
-
o(this, "onAfterRender");
|
|
2408
|
-
o(this, "arrowLength");
|
|
2409
|
-
o(this, "arrowWidth");
|
|
2410
|
-
o(this, "arrowOffset");
|
|
2411
|
-
o(this, "roundness");
|
|
2412
|
-
o(this, "cycleSquareSide");
|
|
2413
|
-
o(this, "detourDirection");
|
|
2414
|
-
o(this, "detourDistance");
|
|
2415
|
-
o(this, "hasSourceArrow");
|
|
2416
|
-
o(this, "hasTargetArrow");
|
|
2417
|
-
o(this, "pathShape");
|
|
2418
|
-
o(this, "createCyclePath", (e) => new G({
|
|
2419
|
-
sourceDirection: e,
|
|
2420
|
-
arrowLength: this.arrowLength,
|
|
2421
|
-
side: this.cycleSquareSide,
|
|
2422
|
-
arrowOffset: this.arrowOffset,
|
|
2423
|
-
roundness: this.roundness,
|
|
2424
|
-
hasSourceArrow: this.hasSourceArrow,
|
|
2425
|
-
hasTargetArrow: this.hasTargetArrow
|
|
2426
|
-
}));
|
|
2427
|
-
o(this, "createDetourPath", (e, t, s, i, n) => new j({
|
|
2428
|
-
to: s,
|
|
2429
|
-
sourceDirection: e,
|
|
2430
|
-
targetDirection: t,
|
|
2431
|
-
flipX: i,
|
|
2432
|
-
flipY: n,
|
|
2433
|
-
arrowLength: this.arrowLength,
|
|
2434
|
-
arrowOffset: this.arrowOffset,
|
|
2435
|
-
roundness: this.roundness,
|
|
2436
|
-
detourDirection: this.detourDirection,
|
|
2437
|
-
detourDistance: this.detourDistance,
|
|
2438
|
-
hasSourceArrow: this.hasSourceArrow,
|
|
2439
|
-
hasTargetArrow: this.hasTargetArrow
|
|
2440
|
-
}));
|
|
2441
|
-
o(this, "createLinePath", (e, t, s, i, n) => new qe({
|
|
2442
|
-
to: s,
|
|
2443
|
-
sourceDirection: e,
|
|
2444
|
-
targetDirection: t,
|
|
2445
|
-
flipY: n,
|
|
2446
|
-
arrowLength: this.arrowLength,
|
|
2447
|
-
arrowOffset: this.arrowOffset,
|
|
2448
|
-
roundness: this.roundness,
|
|
2449
|
-
hasSourceArrow: this.hasSourceArrow,
|
|
2450
|
-
hasTargetArrow: this.hasTargetArrow
|
|
2451
|
-
}));
|
|
2452
|
-
this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? u.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? u.cycleSquareSide;
|
|
2453
|
-
const t = (e == null ? void 0 : e.roundness) ?? u.roundness;
|
|
2454
|
-
this.roundness = Math.min(
|
|
2455
|
-
t,
|
|
2456
|
-
this.arrowOffset,
|
|
2457
|
-
this.cycleSquareSide / 2
|
|
2458
|
-
), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirectionVertical, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow, this.pathShape = new C({
|
|
2459
|
-
color: (e == null ? void 0 : e.color) ?? u.color,
|
|
2460
|
-
width: (e == null ? void 0 : e.width) ?? u.width,
|
|
2461
|
-
arrowLength: this.arrowLength,
|
|
2462
|
-
arrowWidth: this.arrowWidth,
|
|
2463
|
-
hasSourceArrow: this.hasSourceArrow,
|
|
2464
|
-
hasTargetArrow: this.hasTargetArrow,
|
|
2465
|
-
createCyclePath: this.createCyclePath,
|
|
2466
|
-
createDetourPath: this.createDetourPath,
|
|
2467
|
-
createLinePath: this.createLinePath
|
|
2468
|
-
}), this.svg = this.pathShape.svg, this.group = this.pathShape.group, this.line = this.pathShape.line, this.sourceArrow = this.pathShape.sourceArrow, this.targetArrow = this.pathShape.targetArrow, this.onAfterRender = this.pathShape.onAfterRender;
|
|
2223
|
+
scheduleEnsureViewportAreaLoaded() {
|
|
2224
|
+
const e = this.viewportWidth * this.viewportMatrix.scale, t = this.viewportHeight * this.viewportMatrix.scale, s = this.viewportMatrix.x - this.nodeHorizontal, i = this.viewportMatrix.y - this.nodeVertical, n = this.viewportMatrix.x + e + this.nodeHorizontal, h = this.viewportMatrix.y + t + this.nodeVertical;
|
|
2225
|
+
this.loadedArea.xFrom < s && this.loadedArea.xTo > n && this.loadedArea.yFrom < i && this.loadedArea.yTo > h || this.scheduleLoadAreaAroundViewport();
|
|
2469
2226
|
}
|
|
2470
|
-
|
|
2471
|
-
this.
|
|
2227
|
+
loadAreaAroundViewport() {
|
|
2228
|
+
const e = this.viewportWidth * this.viewportMatrix.scale, t = this.viewportHeight * this.viewportMatrix.scale, s = this.viewportMatrix.x - e - this.nodeHorizontal, i = this.viewportMatrix.y - t - this.nodeVertical, n = 3 * e + 2 * this.nodeHorizontal, h = 3 * t + 2 * this.nodeVertical;
|
|
2229
|
+
this.trigger.emit({ x: s, y: i, width: n, height: h });
|
|
2472
2230
|
}
|
|
2473
2231
|
}
|
|
2474
|
-
const
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
return O(
|
|
2485
|
-
n,
|
|
2486
|
-
i,
|
|
2487
|
-
r.arrowLength,
|
|
2488
|
-
r.arrowWidth
|
|
2232
|
+
const st = () => {
|
|
2233
|
+
const r = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
2234
|
+
return r.style.position = "absolute", r.style.inset = "0", r;
|
|
2235
|
+
}, it = () => {
|
|
2236
|
+
const r = document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
|
2237
|
+
return r.setAttribute("fill", "url(#pattern)"), r;
|
|
2238
|
+
}, nt = () => {
|
|
2239
|
+
const r = document.createElementNS(
|
|
2240
|
+
"http://www.w3.org/2000/svg",
|
|
2241
|
+
"pattern"
|
|
2489
2242
|
);
|
|
2243
|
+
return r.setAttribute("id", "pattern"), r;
|
|
2490
2244
|
};
|
|
2491
|
-
class
|
|
2492
|
-
constructor(e) {
|
|
2493
|
-
o(this, "svg");
|
|
2494
|
-
o(this, "
|
|
2495
|
-
o(this, "
|
|
2496
|
-
o(this, "
|
|
2497
|
-
o(this, "
|
|
2498
|
-
o(this, "
|
|
2499
|
-
o(this, "
|
|
2500
|
-
o(this, "
|
|
2501
|
-
o(this, "
|
|
2502
|
-
o(this, "
|
|
2503
|
-
o(this, "
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2245
|
+
class J {
|
|
2246
|
+
constructor(e, t, s) {
|
|
2247
|
+
o(this, "svg", st());
|
|
2248
|
+
o(this, "patternRenderingRectangle", it());
|
|
2249
|
+
o(this, "pattern", nt());
|
|
2250
|
+
o(this, "patternContent");
|
|
2251
|
+
o(this, "tileWidth");
|
|
2252
|
+
o(this, "tileHeight");
|
|
2253
|
+
o(this, "halfTileWidth");
|
|
2254
|
+
o(this, "halfTileHeight");
|
|
2255
|
+
o(this, "maxViewportScale");
|
|
2256
|
+
o(this, "visible", !1);
|
|
2257
|
+
o(this, "resizeObserver", new ResizeObserver((e) => {
|
|
2258
|
+
const t = e[0], { width: s, height: i } = t.contentRect;
|
|
2259
|
+
this.svg.setAttribute("width", `${s}`), this.svg.setAttribute("height", `${i}`), this.patternRenderingRectangle.setAttribute("width", `${s}`), this.patternRenderingRectangle.setAttribute("height", `${i}`);
|
|
2260
|
+
const n = this.tileWidth / s, h = this.tileHeight / i;
|
|
2261
|
+
this.pattern.setAttribute("width", `${n}`), this.pattern.setAttribute("height", `${h}`);
|
|
2262
|
+
}));
|
|
2263
|
+
o(this, "onAfterTransformUpdated", () => {
|
|
2264
|
+
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})`;
|
|
2265
|
+
this.pattern.setAttribute("patternTransform", i), this.updateVisibility();
|
|
2266
|
+
});
|
|
2267
|
+
o(this, "onBeforeDestroy", () => {
|
|
2268
|
+
this.resizeObserver.unobserve(this.host), this.host.removeChild(this.svg), this.canvas.viewport.onAfterUpdated.unsubscribe(
|
|
2269
|
+
this.onAfterTransformUpdated
|
|
2270
|
+
), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy);
|
|
2271
|
+
});
|
|
2272
|
+
this.canvas = e, this.host = 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;
|
|
2273
|
+
const i = `translate(${this.halfTileWidth}, ${this.halfTileHeight})`;
|
|
2274
|
+
this.patternContent.setAttribute("transform", i), this.pattern.appendChild(this.patternContent);
|
|
2275
|
+
const n = document.createElementNS("http://www.w3.org/2000/svg", "defs");
|
|
2276
|
+
n.appendChild(this.pattern), this.svg.appendChild(n), this.svg.appendChild(this.patternRenderingRectangle), this.resizeObserver.observe(this.host), this.canvas.viewport.onAfterUpdated.subscribe(this.onAfterTransformUpdated), this.onAfterTransformUpdated(), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
|
|
2277
|
+
}
|
|
2278
|
+
static configure(e, t, s) {
|
|
2279
|
+
new J(e, t, s);
|
|
2280
|
+
}
|
|
2281
|
+
updateVisibility() {
|
|
2282
|
+
const t = this.canvas.viewport.getViewportMatrix().scale > this.maxViewportScale;
|
|
2283
|
+
t && this.visible ? (this.visible = !1, this.host.removeChild(this.svg)) : !t && !this.visible && (this.visible = !0, this.host.appendChild(this.svg));
|
|
2284
|
+
}
|
|
2285
|
+
}
|
|
2286
|
+
class F {
|
|
2287
|
+
constructor(e, t, s, i) {
|
|
2288
|
+
o(this, "onAfterPortMarked", (e) => {
|
|
2289
|
+
const t = this.canvas.graph.getPort(e);
|
|
2290
|
+
this.canvas.graph.getElementPortIds(t.element).length === 1 && this.hookPortEvents(t.element);
|
|
2291
|
+
});
|
|
2292
|
+
o(this, "onBeforePortUnmarked", (e) => {
|
|
2293
|
+
const t = this.canvas.graph.getPort(e);
|
|
2294
|
+
this.canvas.graph.getElementPortIds(t.element).length === 1 && this.unhookPortEvents(t.element);
|
|
2295
|
+
});
|
|
2296
|
+
o(this, "onPortMouseDown", (e) => {
|
|
2297
|
+
if (!this.params.mouseDownEventVerifier(e))
|
|
2298
|
+
return;
|
|
2299
|
+
const t = e.currentTarget, s = this.canvas.graph.getElementPortIds(t)[0];
|
|
2300
|
+
this.params.onPortPointerDown(s, {
|
|
2301
|
+
x: e.clientX,
|
|
2302
|
+
y: e.clientY
|
|
2303
|
+
}) && (e.stopPropagation(), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
|
|
2304
|
+
passive: !0
|
|
2305
|
+
}), this.window.addEventListener("mouseup", this.onWindowMouseUp, {
|
|
2306
|
+
passive: !0
|
|
2307
|
+
}));
|
|
2308
|
+
});
|
|
2309
|
+
o(this, "onWindowMouseMove", (e) => {
|
|
2310
|
+
if (!L(
|
|
2311
|
+
this.window,
|
|
2312
|
+
this.element,
|
|
2313
|
+
e.clientX,
|
|
2314
|
+
e.clientY
|
|
2315
|
+
)) {
|
|
2316
|
+
this.stopMouseDrag();
|
|
2317
|
+
return;
|
|
2318
|
+
}
|
|
2319
|
+
this.params.onPointerMove({ x: e.clientX, y: e.clientY });
|
|
2320
|
+
});
|
|
2321
|
+
o(this, "onWindowMouseUp", (e) => {
|
|
2322
|
+
this.params.mouseUpEventVerifier(e) && (this.params.onPointerUp({ x: e.clientX, y: e.clientY }), this.stopMouseDrag());
|
|
2323
|
+
});
|
|
2324
|
+
o(this, "onPortTouchStart", (e) => {
|
|
2325
|
+
if (e.touches.length !== 1)
|
|
2326
|
+
return;
|
|
2327
|
+
const t = e.touches[0], s = e.currentTarget, i = this.canvas.graph.getElementPortIds(s)[0];
|
|
2328
|
+
this.params.onPortPointerDown(i, {
|
|
2329
|
+
x: t.clientX,
|
|
2330
|
+
y: t.clientY
|
|
2331
|
+
}) && (e.stopPropagation(), this.window.addEventListener("touchmove", this.onWindowTouchMove, {
|
|
2332
|
+
passive: !0
|
|
2333
|
+
}), this.window.addEventListener("touchend", this.onWindowTouchFinish, {
|
|
2334
|
+
passive: !0
|
|
2335
|
+
}), this.window.addEventListener("touchcancel", this.onWindowTouchFinish, {
|
|
2336
|
+
passive: !0
|
|
2337
|
+
}));
|
|
2338
|
+
});
|
|
2339
|
+
o(this, "onWindowTouchMove", (e) => {
|
|
2340
|
+
const t = e.touches[0];
|
|
2341
|
+
if (!L(
|
|
2342
|
+
this.window,
|
|
2343
|
+
this.element,
|
|
2344
|
+
t.clientX,
|
|
2345
|
+
t.clientY
|
|
2346
|
+
)) {
|
|
2347
|
+
this.stopTouchDrag();
|
|
2348
|
+
return;
|
|
2349
|
+
}
|
|
2350
|
+
this.params.onPointerMove({ x: t.clientX, y: t.clientY });
|
|
2351
|
+
});
|
|
2352
|
+
o(this, "onWindowTouchFinish", (e) => {
|
|
2353
|
+
const t = e.changedTouches[0];
|
|
2354
|
+
this.params.onPointerUp({ x: t.clientX, y: t.clientY }), this.stopTouchDrag();
|
|
2355
|
+
});
|
|
2356
|
+
o(this, "onBeforeClear", () => {
|
|
2357
|
+
this.canvas.graph.getAllPortIds().forEach((e) => {
|
|
2358
|
+
const t = this.canvas.graph.getPort(e);
|
|
2359
|
+
this.unhookPortEvents(t.element);
|
|
2360
|
+
});
|
|
2361
|
+
});
|
|
2362
|
+
o(this, "onBeforeDestroy", () => {
|
|
2363
|
+
this.stopMouseDrag(), this.stopTouchDrag(), this.canvas.graph.onAfterPortMarked.unsubscribe(this.onAfterPortMarked), this.canvas.graph.onBeforePortUnmarked.unsubscribe(
|
|
2364
|
+
this.onBeforePortUnmarked
|
|
2365
|
+
), this.canvas.graph.onBeforeClear.unsubscribe(this.onBeforeClear), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy);
|
|
2366
|
+
});
|
|
2367
|
+
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);
|
|
2368
|
+
}
|
|
2369
|
+
static configure(e, t, s, i) {
|
|
2370
|
+
new F(e, t, s, i);
|
|
2371
|
+
}
|
|
2372
|
+
hookPortEvents(e) {
|
|
2373
|
+
e.addEventListener("mousedown", this.onPortMouseDown, {
|
|
2374
|
+
passive: !0
|
|
2375
|
+
}), e.addEventListener("touchstart", this.onPortTouchStart, {
|
|
2376
|
+
passive: !0
|
|
2377
|
+
});
|
|
2378
|
+
}
|
|
2379
|
+
unhookPortEvents(e) {
|
|
2380
|
+
e.removeEventListener("mousedown", this.onPortMouseDown), e.removeEventListener("touchstart", this.onPortTouchStart);
|
|
2381
|
+
}
|
|
2382
|
+
stopMouseDrag() {
|
|
2383
|
+
this.params.onStopDrag(), this.window.removeEventListener("mouseup", this.onWindowMouseUp), this.window.removeEventListener("mousemove", this.onWindowMouseMove);
|
|
2384
|
+
}
|
|
2385
|
+
stopTouchDrag() {
|
|
2386
|
+
this.params.onStopDrag(), this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
|
|
2507
2387
|
}
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2388
|
+
}
|
|
2389
|
+
class Q {
|
|
2390
|
+
constructor(e, t, s, i, n) {
|
|
2391
|
+
o(this, "overlayCanvas");
|
|
2392
|
+
o(this, "staticPortId", null);
|
|
2393
|
+
o(this, "isTargetDragging", !0);
|
|
2394
|
+
o(this, "onEdgeCreated", (e) => {
|
|
2395
|
+
this.params.onAfterEdgeCreated(e);
|
|
2396
|
+
});
|
|
2397
|
+
this.canvas = e, this.overlayLayer = t, this.viewportStore = s, this.window = i, this.params = n, this.overlayCanvas = De(
|
|
2398
|
+
this.overlayLayer,
|
|
2399
|
+
this.viewportStore
|
|
2400
|
+
), F.configure(
|
|
2401
|
+
this.canvas,
|
|
2402
|
+
this.overlayLayer,
|
|
2403
|
+
this.window,
|
|
2404
|
+
{
|
|
2405
|
+
mouseDownEventVerifier: this.params.mouseDownEventVerifier,
|
|
2406
|
+
mouseUpEventVerifier: this.params.mouseUpEventVerifier,
|
|
2407
|
+
onStopDrag: () => {
|
|
2408
|
+
this.resetDragState();
|
|
2409
|
+
},
|
|
2410
|
+
onPortPointerDown: (h, a) => {
|
|
2411
|
+
const d = this.params.connectionTypeResolver(h);
|
|
2412
|
+
return d === null ? !1 : (this.grabPort(h, a, d), !0);
|
|
2413
|
+
},
|
|
2414
|
+
onPointerMove: (h) => {
|
|
2415
|
+
this.moveDraggingPort(h);
|
|
2416
|
+
},
|
|
2417
|
+
onPointerUp: (h) => {
|
|
2418
|
+
this.tryCreateConnection(h);
|
|
2419
|
+
}
|
|
2420
|
+
}
|
|
2512
2421
|
);
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2422
|
+
}
|
|
2423
|
+
static configure(e, t, s, i, n) {
|
|
2424
|
+
new Q(
|
|
2425
|
+
e,
|
|
2426
|
+
t,
|
|
2427
|
+
s,
|
|
2428
|
+
i,
|
|
2429
|
+
n
|
|
2430
|
+
);
|
|
2431
|
+
}
|
|
2432
|
+
grabPort(e, t, s) {
|
|
2433
|
+
const i = this.canvas.graph.getPort(e);
|
|
2434
|
+
this.staticPortId = e;
|
|
2435
|
+
const n = i.element.getBoundingClientRect(), h = n.x + n.width / 2, a = n.y + n.height / 2, d = this.overlayLayer.getBoundingClientRect(), c = this.canvas.viewport.getViewportMatrix(), l = T(c, {
|
|
2436
|
+
x: h - d.x,
|
|
2437
|
+
y: a - d.y
|
|
2438
|
+
}), g = T(c, {
|
|
2439
|
+
x: t.x - d.x,
|
|
2440
|
+
y: t.y - d.y
|
|
2441
|
+
}), p = {
|
|
2442
|
+
overlayId: b.Static,
|
|
2443
|
+
portCoords: l,
|
|
2444
|
+
portDirection: i.direction
|
|
2445
|
+
}, f = {
|
|
2446
|
+
overlayId: b.Dragging,
|
|
2447
|
+
portCoords: g,
|
|
2448
|
+
portDirection: this.params.dragPortDirection
|
|
2449
|
+
};
|
|
2450
|
+
this.isTargetDragging = s === "direct";
|
|
2451
|
+
const [v, y] = this.isTargetDragging ? [p, f] : [f, p];
|
|
2452
|
+
this.overlayCanvas.addNode(V(v)), this.overlayCanvas.addNode(V(y)), this.overlayCanvas.addEdge({
|
|
2453
|
+
from: v.overlayId,
|
|
2454
|
+
to: y.overlayId,
|
|
2455
|
+
shape: this.params.edgeShapeFactory(b.Edge)
|
|
2521
2456
|
});
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
this.
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
}
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2457
|
+
}
|
|
2458
|
+
resetDragState() {
|
|
2459
|
+
this.staticPortId = null, this.isTargetDragging = !0, this.overlayCanvas.clear();
|
|
2460
|
+
}
|
|
2461
|
+
tryCreateConnection(e) {
|
|
2462
|
+
const t = ve(this.canvas.graph, e);
|
|
2463
|
+
if (t === null) {
|
|
2464
|
+
this.params.onEdgeCreationInterrupted(
|
|
2465
|
+
this.staticPortId,
|
|
2466
|
+
this.isTargetDragging
|
|
2467
|
+
);
|
|
2468
|
+
return;
|
|
2469
|
+
}
|
|
2470
|
+
const s = this.isTargetDragging ? this.staticPortId : t, i = this.isTargetDragging ? t : this.staticPortId, n = { from: s, to: i }, h = this.params.connectionPreprocessor(n);
|
|
2471
|
+
h !== null ? (this.canvas.graph.onAfterEdgeAdded.subscribe(this.onEdgeCreated), this.canvas.addEdge(h), this.canvas.graph.onAfterEdgeAdded.unsubscribe(this.onEdgeCreated)) : this.params.onEdgeCreationPrevented(n);
|
|
2472
|
+
}
|
|
2473
|
+
moveDraggingPort(e) {
|
|
2474
|
+
const t = this.overlayLayer.getBoundingClientRect(), s = {
|
|
2475
|
+
x: e.x - t.x,
|
|
2476
|
+
y: e.y - t.y
|
|
2477
|
+
}, i = this.canvas.viewport.getViewportMatrix(), n = T(i, s);
|
|
2478
|
+
this.overlayCanvas.updateNode(b.Dragging, {
|
|
2479
|
+
x: n.x,
|
|
2480
|
+
y: n.y
|
|
2546
2481
|
});
|
|
2547
2482
|
}
|
|
2548
2483
|
}
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2484
|
+
class _ {
|
|
2485
|
+
constructor(e, t, s, i, n) {
|
|
2486
|
+
o(this, "overlayCanvas");
|
|
2487
|
+
o(this, "staticPortId", null);
|
|
2488
|
+
o(this, "isTargetDragging", !0);
|
|
2489
|
+
o(this, "draggingEdge", null);
|
|
2490
|
+
o(this, "onEdgeReattached", (e) => {
|
|
2491
|
+
this.params.onAfterEdgeReattached(e);
|
|
2492
|
+
});
|
|
2493
|
+
this.canvas = e, this.overlayLayer = t, this.viewportStore = s, this.window = i, this.params = n, this.overlayCanvas = De(
|
|
2494
|
+
this.overlayLayer,
|
|
2495
|
+
this.viewportStore
|
|
2496
|
+
), F.configure(
|
|
2497
|
+
this.canvas,
|
|
2498
|
+
this.overlayLayer,
|
|
2499
|
+
this.window,
|
|
2500
|
+
{
|
|
2501
|
+
mouseDownEventVerifier: this.params.mouseDownEventVerifier,
|
|
2502
|
+
mouseUpEventVerifier: this.params.mouseUpEventVerifier,
|
|
2503
|
+
onStopDrag: () => {
|
|
2504
|
+
this.resetDragState();
|
|
2505
|
+
},
|
|
2506
|
+
onPortPointerDown: (h, a) => this.tryStartEdgeDragging(h, a),
|
|
2507
|
+
onPointerMove: (h) => {
|
|
2508
|
+
this.moveDraggingPort(h);
|
|
2509
|
+
},
|
|
2510
|
+
onPointerUp: (h) => {
|
|
2511
|
+
this.tryCreateConnection(h);
|
|
2512
|
+
}
|
|
2513
|
+
}
|
|
2514
|
+
);
|
|
2562
2515
|
}
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
this.
|
|
2581
|
-
const
|
|
2582
|
-
|
|
2583
|
-
|
|
2516
|
+
static configure(e, t, s, i, n) {
|
|
2517
|
+
new _(
|
|
2518
|
+
e,
|
|
2519
|
+
t,
|
|
2520
|
+
s,
|
|
2521
|
+
i,
|
|
2522
|
+
n
|
|
2523
|
+
);
|
|
2524
|
+
}
|
|
2525
|
+
tryStartEdgeDragging(e, t) {
|
|
2526
|
+
const s = this.params.draggingEdgeResolver(e);
|
|
2527
|
+
if (s === null)
|
|
2528
|
+
return !1;
|
|
2529
|
+
const i = this.canvas.graph.getEdge(s);
|
|
2530
|
+
if (i === null)
|
|
2531
|
+
return !1;
|
|
2532
|
+
const n = e === i.from, h = e === i.to, a = n ? i.to : i.from;
|
|
2533
|
+
this.staticPortId = a, this.isTargetDragging = h;
|
|
2534
|
+
const d = this.canvas.graph.getPort(e), c = this.canvas.graph.getPort(a), l = c.element.getBoundingClientRect(), g = {
|
|
2535
|
+
x: l.x + l.width / 2,
|
|
2536
|
+
y: l.y + l.height / 2
|
|
2537
|
+
}, p = this.canvas.viewport.getViewportMatrix(), f = this.overlayLayer.getBoundingClientRect(), v = T(p, {
|
|
2538
|
+
x: g.x - f.x,
|
|
2539
|
+
y: g.y - f.y
|
|
2540
|
+
}), y = T(p, {
|
|
2541
|
+
x: t.x - f.x,
|
|
2542
|
+
y: t.y - f.y
|
|
2543
|
+
});
|
|
2544
|
+
this.draggingEdge = i, this.canvas.removeEdge(s);
|
|
2545
|
+
const E = {
|
|
2546
|
+
overlayId: b.Static,
|
|
2547
|
+
portCoords: v,
|
|
2548
|
+
portDirection: c.direction
|
|
2549
|
+
}, x = {
|
|
2550
|
+
overlayId: b.Dragging,
|
|
2551
|
+
portCoords: y,
|
|
2552
|
+
portDirection: d.direction
|
|
2553
|
+
}, [P, D] = this.isTargetDragging ? [E, x] : [x, E];
|
|
2554
|
+
this.overlayCanvas.addNode(V(P)), this.overlayCanvas.addNode(V(D));
|
|
2555
|
+
const N = this.params.draggingEdgeShapeFactory !== null ? this.params.draggingEdgeShapeFactory(b.Edge) : i.shape;
|
|
2556
|
+
return this.overlayCanvas.addEdge({
|
|
2557
|
+
id: b.Edge,
|
|
2558
|
+
from: P.overlayId,
|
|
2559
|
+
to: D.overlayId,
|
|
2560
|
+
shape: N
|
|
2561
|
+
}), !0;
|
|
2562
|
+
}
|
|
2563
|
+
resetDragState() {
|
|
2564
|
+
this.draggingEdge = null, this.staticPortId = null, this.isTargetDragging = !0, this.overlayCanvas.clear();
|
|
2565
|
+
}
|
|
2566
|
+
moveDraggingPort(e) {
|
|
2567
|
+
const t = this.overlayLayer.getBoundingClientRect(), s = {
|
|
2568
|
+
x: e.x - t.x,
|
|
2569
|
+
y: e.y - t.y
|
|
2570
|
+
}, i = this.canvas.viewport.getViewportMatrix(), n = T(i, s);
|
|
2571
|
+
this.overlayCanvas.updateNode(b.Dragging, {
|
|
2572
|
+
x: n.x,
|
|
2573
|
+
y: n.y
|
|
2584
2574
|
});
|
|
2585
2575
|
}
|
|
2586
|
-
|
|
2587
|
-
this.
|
|
2576
|
+
tryCreateConnection(e) {
|
|
2577
|
+
const t = ve(this.canvas.graph, e);
|
|
2578
|
+
if (this.overlayCanvas.removeEdge(b.Edge), t === null) {
|
|
2579
|
+
this.params.onEdgeReattachInterrupted(this.draggingEdge);
|
|
2580
|
+
return;
|
|
2581
|
+
}
|
|
2582
|
+
const [s, i] = this.isTargetDragging ? [this.staticPortId, t] : [t, this.staticPortId], n = {
|
|
2583
|
+
from: s,
|
|
2584
|
+
to: i,
|
|
2585
|
+
shape: this.draggingEdge.shape,
|
|
2586
|
+
priority: this.draggingEdge.priority
|
|
2587
|
+
}, h = this.params.connectionPreprocessor(n);
|
|
2588
|
+
h !== null ? (this.canvas.graph.onAfterEdgeAdded.subscribe(this.onEdgeReattached), this.canvas.addEdge(h), this.canvas.graph.onAfterEdgeAdded.unsubscribe(this.onEdgeReattached)) : this.params.onEdgeReattachPrevented(this.draggingEdge);
|
|
2588
2589
|
}
|
|
2589
2590
|
}
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2591
|
+
const ht = () => {
|
|
2592
|
+
const r = document.createElement("div");
|
|
2593
|
+
return r.style.width = "100%", r.style.height = "100%", r.style.position = "relative", r;
|
|
2594
|
+
}, z = () => {
|
|
2595
|
+
const r = document.createElement("div");
|
|
2596
|
+
return r.style.position = "absolute", r.style.inset = "0", r;
|
|
2597
|
+
}, de = () => {
|
|
2598
|
+
const r = z();
|
|
2599
|
+
return r.style.pointerEvents = "none", r;
|
|
2600
|
+
};
|
|
2601
|
+
class at {
|
|
2602
|
+
constructor(e) {
|
|
2603
|
+
o(this, "background", z());
|
|
2604
|
+
o(this, "main", z());
|
|
2605
|
+
o(this, "overlayConnectablePorts", de());
|
|
2606
|
+
o(this, "overlayDraggableEdges", de());
|
|
2607
|
+
o(this, "host", ht());
|
|
2608
|
+
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);
|
|
2602
2609
|
}
|
|
2603
|
-
|
|
2604
|
-
this.
|
|
2610
|
+
destroy() {
|
|
2611
|
+
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);
|
|
2605
2612
|
}
|
|
2606
2613
|
}
|
|
2607
|
-
const
|
|
2614
|
+
const X = (r) => () => r, ce = X(0), dt = () => {
|
|
2615
|
+
let r = 0;
|
|
2616
|
+
return () => r++;
|
|
2617
|
+
}, ct = (r, e) => {
|
|
2618
|
+
let t = ce, s = ce;
|
|
2619
|
+
const i = dt();
|
|
2620
|
+
return r === "incremental" && (t = i), e === "incremental" && (s = i), typeof r == "number" && (t = X(r)), typeof e == "number" && (s = X(e)), typeof r == "function" && (t = r), typeof e == "function" && (s = e), {
|
|
2621
|
+
nodesPriorityFn: t,
|
|
2622
|
+
edgesPriorityFn: s
|
|
2623
|
+
};
|
|
2624
|
+
}, q = (r) => {
|
|
2608
2625
|
if (typeof r == "function")
|
|
2609
2626
|
return r;
|
|
2610
2627
|
switch (r == null ? void 0 : r.type) {
|
|
2611
2628
|
case "straight":
|
|
2612
|
-
return () => new
|
|
2629
|
+
return () => new Qe({
|
|
2613
2630
|
color: r.color,
|
|
2614
2631
|
width: r.width,
|
|
2615
2632
|
arrowLength: r.arrowLength,
|
|
@@ -2623,7 +2640,7 @@ const ye = (r) => {
|
|
|
2623
2640
|
detourDirection: r.detourDirection
|
|
2624
2641
|
});
|
|
2625
2642
|
case "horizontal":
|
|
2626
|
-
return () => new
|
|
2643
|
+
return () => new Je({
|
|
2627
2644
|
color: r.color,
|
|
2628
2645
|
width: r.width,
|
|
2629
2646
|
arrowLength: r.arrowLength,
|
|
@@ -2637,7 +2654,7 @@ const ye = (r) => {
|
|
|
2637
2654
|
detourDirection: r.detourDirection
|
|
2638
2655
|
});
|
|
2639
2656
|
case "vertical":
|
|
2640
|
-
return () => new
|
|
2657
|
+
return () => new _e({
|
|
2641
2658
|
color: r.color,
|
|
2642
2659
|
width: r.width,
|
|
2643
2660
|
arrowLength: r.arrowLength,
|
|
@@ -2651,7 +2668,7 @@ const ye = (r) => {
|
|
|
2651
2668
|
detourDirection: r.detourDirection
|
|
2652
2669
|
});
|
|
2653
2670
|
case "direct":
|
|
2654
|
-
return () => new
|
|
2671
|
+
return () => new Pe({
|
|
2655
2672
|
color: r.color,
|
|
2656
2673
|
width: r.width,
|
|
2657
2674
|
arrowLength: r.arrowLength,
|
|
@@ -2662,7 +2679,7 @@ const ye = (r) => {
|
|
|
2662
2679
|
targetOffset: r.targetOffset
|
|
2663
2680
|
});
|
|
2664
2681
|
default:
|
|
2665
|
-
return () => new
|
|
2682
|
+
return () => new Ze({
|
|
2666
2683
|
color: r.color,
|
|
2667
2684
|
width: r.width,
|
|
2668
2685
|
arrowLength: r.arrowLength,
|
|
@@ -2676,27 +2693,146 @@ const ye = (r) => {
|
|
|
2676
2693
|
detourDirection: r.detourDirection
|
|
2677
2694
|
});
|
|
2678
2695
|
}
|
|
2679
|
-
},
|
|
2696
|
+
}, gt = (r) => {
|
|
2680
2697
|
var t, s, i, n, h;
|
|
2681
|
-
const e =
|
|
2698
|
+
const e = ct(
|
|
2682
2699
|
(t = r.nodes) == null ? void 0 : t.priority,
|
|
2683
2700
|
(s = r.edges) == null ? void 0 : s.priority
|
|
2684
2701
|
);
|
|
2685
2702
|
return {
|
|
2686
2703
|
nodes: {
|
|
2687
|
-
centerFn: ((i = r.nodes) == null ? void 0 : i.centerFn) ??
|
|
2704
|
+
centerFn: ((i = r.nodes) == null ? void 0 : i.centerFn) ?? me,
|
|
2688
2705
|
priorityFn: e.nodesPriorityFn
|
|
2689
2706
|
},
|
|
2690
2707
|
ports: {
|
|
2691
2708
|
direction: ((n = r.ports) == null ? void 0 : n.direction) ?? 0
|
|
2692
2709
|
},
|
|
2693
2710
|
edges: {
|
|
2694
|
-
shapeFactory:
|
|
2711
|
+
shapeFactory: q(((h = r.edges) == null ? void 0 : h.shape) ?? {}),
|
|
2695
2712
|
priorityFn: e.edgesPriorityFn
|
|
2696
2713
|
}
|
|
2697
2714
|
};
|
|
2698
|
-
}, lt = (r
|
|
2699
|
-
var
|
|
2715
|
+
}, lt = (r) => {
|
|
2716
|
+
var p, f, v, y, E, x;
|
|
2717
|
+
const e = ((p = r == null ? void 0 : r.events) == null ? void 0 : p.onNodeDrag) ?? (() => {
|
|
2718
|
+
}), t = ((f = r == null ? void 0 : r.events) == null ? void 0 : f.onBeforeNodeDrag) ?? (() => !0), s = ((v = r == null ? void 0 : r.events) == null ? void 0 : v.onNodeDragFinished) ?? (() => {
|
|
2719
|
+
}), i = (r == null ? void 0 : r.moveOnTop) !== !1, n = (r == null ? void 0 : r.moveEdgesOnTop) !== !1 && i, h = (y = r == null ? void 0 : r.mouse) == null ? void 0 : y.dragCursor, a = h !== void 0 ? h : "grab", d = (E = r == null ? void 0 : r.mouse) == null ? void 0 : E.mouseDownEventVerifier, c = d !== void 0 ? d : (P) => P.button === 0, l = (x = r == null ? void 0 : r.mouse) == null ? void 0 : x.mouseUpEventVerifier;
|
|
2720
|
+
return {
|
|
2721
|
+
moveOnTop: i,
|
|
2722
|
+
moveEdgesOnTop: n,
|
|
2723
|
+
dragCursor: a,
|
|
2724
|
+
mouseDownEventVerifier: c,
|
|
2725
|
+
mouseUpEventVerifier: l !== void 0 ? l : (P) => P.button === 0,
|
|
2726
|
+
onNodeDrag: e,
|
|
2727
|
+
onBeforeNodeDrag: t,
|
|
2728
|
+
onNodeDragFinished: s
|
|
2729
|
+
};
|
|
2730
|
+
}, ut = (r) => {
|
|
2731
|
+
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;
|
|
2732
|
+
return (n) => {
|
|
2733
|
+
let h = n.nextTransform.x, a = n.nextTransform.y;
|
|
2734
|
+
h < e && h < n.prevTransform.x && (h = Math.min(n.prevTransform.x, e));
|
|
2735
|
+
const d = n.canvasWidth * n.prevTransform.scale, c = t - d;
|
|
2736
|
+
h > c && h > n.prevTransform.x && (h = Math.max(n.prevTransform.x, c)), a < s && a < n.prevTransform.y && (a = Math.min(n.prevTransform.y, s));
|
|
2737
|
+
const l = n.canvasHeight * n.prevTransform.scale, g = i - l;
|
|
2738
|
+
return a > g && a > n.prevTransform.y && (a = Math.max(n.prevTransform.y, g)), { scale: n.nextTransform.scale, x: h, y: a };
|
|
2739
|
+
};
|
|
2740
|
+
}, pt = (r) => {
|
|
2741
|
+
const e = r.maxContentScale, t = r.minContentScale, s = e !== null ? 1 / e : 0, i = t !== null ? 1 / t : 1 / 0;
|
|
2742
|
+
return (n) => {
|
|
2743
|
+
const h = n.prevTransform, a = n.nextTransform;
|
|
2744
|
+
let d = a.scale, c = a.x, l = a.y;
|
|
2745
|
+
if (a.scale > i && a.scale > h.scale) {
|
|
2746
|
+
d = Math.max(h.scale, i), c = h.x, l = h.y;
|
|
2747
|
+
const g = (d - h.scale) / (a.scale - h.scale);
|
|
2748
|
+
c = h.x + (a.x - h.x) * g, l = h.y + (a.y - h.y) * g;
|
|
2749
|
+
}
|
|
2750
|
+
if (a.scale < s && a.scale < h.scale) {
|
|
2751
|
+
d = Math.min(h.scale, s), c = h.x, l = h.y;
|
|
2752
|
+
const g = (d - h.scale) / (a.scale - h.scale);
|
|
2753
|
+
c = h.x + (a.x - h.x) * g, l = h.y + (a.y - h.y) * g;
|
|
2754
|
+
}
|
|
2755
|
+
return {
|
|
2756
|
+
scale: d,
|
|
2757
|
+
x: c,
|
|
2758
|
+
y: l
|
|
2759
|
+
};
|
|
2760
|
+
};
|
|
2761
|
+
}, wt = (r) => (e) => r.reduce(
|
|
2762
|
+
(t, s) => s({
|
|
2763
|
+
prevTransform: e.prevTransform,
|
|
2764
|
+
nextTransform: t,
|
|
2765
|
+
canvasWidth: e.canvasWidth,
|
|
2766
|
+
canvasHeight: e.canvasHeight
|
|
2767
|
+
}),
|
|
2768
|
+
e.nextTransform
|
|
2769
|
+
), ge = (r) => {
|
|
2770
|
+
if (typeof r == "function")
|
|
2771
|
+
return r;
|
|
2772
|
+
switch (r.type) {
|
|
2773
|
+
case "scale-limit":
|
|
2774
|
+
return pt({
|
|
2775
|
+
minContentScale: r.minContentScale ?? 0,
|
|
2776
|
+
maxContentScale: r.maxContentScale ?? 1 / 0
|
|
2777
|
+
});
|
|
2778
|
+
case "shift-limit":
|
|
2779
|
+
return ut({
|
|
2780
|
+
minX: r.minX ?? -1 / 0,
|
|
2781
|
+
maxX: r.maxX ?? 1 / 0,
|
|
2782
|
+
minY: r.minY ?? -1 / 0,
|
|
2783
|
+
maxY: r.maxY ?? 1 / 0
|
|
2784
|
+
});
|
|
2785
|
+
}
|
|
2786
|
+
}, le = (r) => {
|
|
2787
|
+
var v, y, E, x, P, D, N, R, ee, te, re, oe;
|
|
2788
|
+
const e = (v = r == null ? void 0 : r.scale) == null ? void 0 : v.mouseWheelSensitivity, t = e !== void 0 ? e : 1.2, s = r == null ? void 0 : r.transformPreprocessor;
|
|
2789
|
+
let i;
|
|
2790
|
+
s !== void 0 ? Array.isArray(s) ? i = wt(
|
|
2791
|
+
s.map(
|
|
2792
|
+
(M) => ge(M)
|
|
2793
|
+
)
|
|
2794
|
+
) : i = ge(s) : i = (M) => M.nextTransform;
|
|
2795
|
+
const n = ((y = r == null ? void 0 : r.shift) == null ? void 0 : y.cursor) !== void 0 ? r.shift.cursor : "grab", h = ((E = r == null ? void 0 : r.events) == null ? void 0 : E.onBeforeTransformChange) ?? (() => {
|
|
2796
|
+
}), a = ((x = r == null ? void 0 : r.events) == null ? void 0 : x.onTransformChange) ?? (() => {
|
|
2797
|
+
}), d = (P = r == null ? void 0 : r.shift) == null ? void 0 : P.mouseDownEventVerifier, c = d !== void 0 ? d : (M) => M.button === 0, l = (D = r == null ? void 0 : r.shift) == null ? void 0 : D.mouseUpEventVerifier, g = l !== void 0 ? l : (M) => M.button === 0, p = (N = r == null ? void 0 : r.scale) == null ? void 0 : N.mouseWheelEventVerifier, f = p !== void 0 ? p : () => !0;
|
|
2798
|
+
return {
|
|
2799
|
+
wheelSensitivity: t,
|
|
2800
|
+
onTransformStarted: ((R = r == null ? void 0 : r.events) == null ? void 0 : R.onTransformStarted) ?? (() => {
|
|
2801
|
+
}),
|
|
2802
|
+
onTransformFinished: ((ee = r == null ? void 0 : r.events) == null ? void 0 : ee.onTransformFinished) ?? (() => {
|
|
2803
|
+
}),
|
|
2804
|
+
onBeforeTransformChange: h,
|
|
2805
|
+
onTransformChange: a,
|
|
2806
|
+
transformPreprocessor: i,
|
|
2807
|
+
shiftCursor: n,
|
|
2808
|
+
mouseDownEventVerifier: c,
|
|
2809
|
+
mouseUpEventVerifier: g,
|
|
2810
|
+
mouseWheelEventVerifier: f,
|
|
2811
|
+
scaleWheelFinishTimeout: ((te = r == null ? void 0 : r.scale) == null ? void 0 : te.wheelFinishTimeout) ?? 500,
|
|
2812
|
+
onResizeTransformStarted: ((re = r == null ? void 0 : r.events) == null ? void 0 : re.onResizeTransformStarted) ?? (() => {
|
|
2813
|
+
}),
|
|
2814
|
+
onResizeTransformFinished: ((oe = r == null ? void 0 : r.events) == null ? void 0 : oe.onResizeTransformFinished) ?? (() => {
|
|
2815
|
+
})
|
|
2816
|
+
};
|
|
2817
|
+
}, ft = (r, e) => {
|
|
2818
|
+
const t = document.createElementNS(
|
|
2819
|
+
"http://www.w3.org/2000/svg",
|
|
2820
|
+
"circle"
|
|
2821
|
+
);
|
|
2822
|
+
return t.setAttribute("cx", "0"), t.setAttribute("cy", "0"), t.setAttribute("r", `${r}`), t.setAttribute("fill", `${e}`), t;
|
|
2823
|
+
}, vt = (r) => r instanceof SVGElement ? r : ft(
|
|
2824
|
+
(r == null ? void 0 : r.radius) ?? 1.5,
|
|
2825
|
+
(r == null ? void 0 : r.color) ?? "#d8d8d8"
|
|
2826
|
+
), mt = (r) => {
|
|
2827
|
+
const e = r.tileDimensions, t = (e == null ? void 0 : e.width) ?? 25, s = (e == null ? void 0 : e.height) ?? 25, i = vt(r.renderer ?? {});
|
|
2828
|
+
return {
|
|
2829
|
+
tileWidth: t,
|
|
2830
|
+
tileHeight: s,
|
|
2831
|
+
renderer: i,
|
|
2832
|
+
maxViewportScale: r.maxViewportScale ?? 10
|
|
2833
|
+
};
|
|
2834
|
+
}, yt = (r, e, t) => {
|
|
2835
|
+
var c, l, g;
|
|
2700
2836
|
const s = () => "direct", i = (p) => p, n = (p) => p.button === 0, h = () => {
|
|
2701
2837
|
}, a = () => {
|
|
2702
2838
|
}, d = () => {
|
|
@@ -2707,13 +2843,32 @@ const ye = (r) => {
|
|
|
2707
2843
|
mouseDownEventVerifier: r.mouseDownEventVerifier ?? n,
|
|
2708
2844
|
mouseUpEventVerifier: r.mouseUpEventVerifier ?? n,
|
|
2709
2845
|
onAfterEdgeCreated: ((c = r.events) == null ? void 0 : c.onAfterEdgeCreated) ?? h,
|
|
2710
|
-
onEdgeCreationInterrupted: ((
|
|
2711
|
-
onEdgeCreationPrevented: ((
|
|
2846
|
+
onEdgeCreationInterrupted: ((l = r.events) == null ? void 0 : l.onEdgeCreationInterrupted) ?? d,
|
|
2847
|
+
onEdgeCreationPrevented: ((g = r.events) == null ? void 0 : g.onEdgeCreationPrevented) ?? a,
|
|
2712
2848
|
dragPortDirection: r.dragPortDirection ?? t,
|
|
2713
|
-
edgeShapeFactory: r.edgeShape !== void 0 ?
|
|
2849
|
+
edgeShapeFactory: r.edgeShape !== void 0 ? q(r.edgeShape) : e
|
|
2850
|
+
};
|
|
2851
|
+
}, Et = (r, e) => {
|
|
2852
|
+
var c, l, g;
|
|
2853
|
+
const t = (p) => p, s = (p) => p.button === 0 && p.ctrlKey, i = (p) => p.button === 0, n = (p) => {
|
|
2854
|
+
const f = e.getPortAdjacentEdgeIds(p);
|
|
2855
|
+
return f.length > 0 ? f[f.length - 1] : null;
|
|
2856
|
+
}, h = () => {
|
|
2857
|
+
}, a = () => {
|
|
2858
|
+
}, d = () => {
|
|
2859
|
+
};
|
|
2860
|
+
return {
|
|
2861
|
+
connectionPreprocessor: r.connectionPreprocessor ?? t,
|
|
2862
|
+
mouseDownEventVerifier: r.mouseDownEventVerifier ?? s,
|
|
2863
|
+
mouseUpEventVerifier: r.mouseUpEventVerifier ?? i,
|
|
2864
|
+
draggingEdgeResolver: r.draggingEdgeResolver ?? n,
|
|
2865
|
+
draggingEdgeShapeFactory: r.draggingEdgeShape !== void 0 ? q(r.draggingEdgeShape) : null,
|
|
2866
|
+
onAfterEdgeReattached: ((c = r.events) == null ? void 0 : c.onAfterEdgeReattached) ?? h,
|
|
2867
|
+
onEdgeReattachInterrupted: ((l = r.events) == null ? void 0 : l.onEdgeReattachInterrupted) ?? d,
|
|
2868
|
+
onEdgeReattachPrevented: ((g = r.events) == null ? void 0 : g.onEdgeReattachPrevented) ?? a
|
|
2714
2869
|
};
|
|
2715
2870
|
};
|
|
2716
|
-
class
|
|
2871
|
+
class St {
|
|
2717
2872
|
constructor(e) {
|
|
2718
2873
|
o(this, "element", null);
|
|
2719
2874
|
o(this, "canvasDefaults", {});
|
|
@@ -2721,12 +2876,14 @@ class wt {
|
|
|
2721
2876
|
o(this, "transformConfig", {});
|
|
2722
2877
|
o(this, "backgroundConfig", {});
|
|
2723
2878
|
o(this, "connectablePortsConfig", {});
|
|
2879
|
+
o(this, "draggableEdgesConfig", {});
|
|
2724
2880
|
o(this, "virtualScrollConfig");
|
|
2725
2881
|
o(this, "hasDraggableNode", !1);
|
|
2726
2882
|
o(this, "hasTransformableViewport", !1);
|
|
2727
2883
|
o(this, "hasResizeReactiveNodes", !1);
|
|
2728
2884
|
o(this, "hasBackground", !1);
|
|
2729
2885
|
o(this, "hasUserConnectablePorts", !1);
|
|
2886
|
+
o(this, "hasUserDraggableEdges", !1);
|
|
2730
2887
|
o(this, "boxRenderingTrigger");
|
|
2731
2888
|
o(this, "window", window);
|
|
2732
2889
|
e !== void 0 && (this.element = e);
|
|
@@ -2787,6 +2944,9 @@ class wt {
|
|
|
2787
2944
|
enableUserConnectablePorts(e) {
|
|
2788
2945
|
return this.connectablePortsConfig = e ?? {}, this.hasUserConnectablePorts = !0, this;
|
|
2789
2946
|
}
|
|
2947
|
+
enableUserDraggableEdges(e) {
|
|
2948
|
+
return this.hasUserDraggableEdges = !0, this.draggableEdgesConfig = e ?? {}, this;
|
|
2949
|
+
}
|
|
2790
2950
|
/**
|
|
2791
2951
|
* builds final canvas
|
|
2792
2952
|
*/
|
|
@@ -2796,59 +2956,74 @@ class wt {
|
|
|
2796
2956
|
"unable to build canvas when no attach element specified"
|
|
2797
2957
|
);
|
|
2798
2958
|
let e = this.boxRenderingTrigger;
|
|
2799
|
-
this.virtualScrollConfig !== void 0 && e === void 0 && (e = new
|
|
2800
|
-
const t = new
|
|
2801
|
-
let n = new
|
|
2959
|
+
this.virtualScrollConfig !== void 0 && e === void 0 && (e = new pe());
|
|
2960
|
+
const t = new fe(), s = new $e(), i = new at(this.element);
|
|
2961
|
+
let n = new ue(
|
|
2802
2962
|
t,
|
|
2803
2963
|
s,
|
|
2804
2964
|
i.main
|
|
2805
2965
|
);
|
|
2806
|
-
e !== void 0 && (n = new
|
|
2807
|
-
const h =
|
|
2966
|
+
e !== void 0 && (n = new Ue(n, t, e));
|
|
2967
|
+
const h = gt(this.canvasDefaults), a = new we(
|
|
2808
2968
|
this.element,
|
|
2809
2969
|
t,
|
|
2810
2970
|
s,
|
|
2811
2971
|
n,
|
|
2812
2972
|
h
|
|
2813
|
-
)
|
|
2814
|
-
|
|
2815
|
-
};
|
|
2816
|
-
if (a.onBeforeDestroy.subscribe(d), this.hasBackground && Y.configure(
|
|
2973
|
+
);
|
|
2974
|
+
if (this.hasBackground && J.configure(
|
|
2817
2975
|
a,
|
|
2818
|
-
this.backgroundConfig,
|
|
2976
|
+
mt(this.backgroundConfig),
|
|
2819
2977
|
i.background
|
|
2820
|
-
), this.hasResizeReactiveNodes &&
|
|
2978
|
+
), this.hasResizeReactiveNodes && Y.configure(a), this.hasDraggableNode && K.configure(
|
|
2821
2979
|
a,
|
|
2822
2980
|
i.main,
|
|
2823
2981
|
this.window,
|
|
2824
|
-
this.dragConfig
|
|
2982
|
+
lt(this.dragConfig)
|
|
2825
2983
|
), this.hasUserConnectablePorts) {
|
|
2826
|
-
const c =
|
|
2984
|
+
const c = yt(
|
|
2827
2985
|
this.connectablePortsConfig,
|
|
2828
2986
|
h.edges.shapeFactory,
|
|
2829
2987
|
h.ports.direction
|
|
2830
2988
|
);
|
|
2831
|
-
|
|
2989
|
+
Q.configure(
|
|
2990
|
+
a,
|
|
2991
|
+
i.overlayConnectablePorts,
|
|
2992
|
+
s,
|
|
2993
|
+
this.window,
|
|
2994
|
+
c
|
|
2995
|
+
);
|
|
2996
|
+
}
|
|
2997
|
+
if (this.hasUserDraggableEdges) {
|
|
2998
|
+
const c = Et(
|
|
2999
|
+
this.draggableEdgesConfig,
|
|
3000
|
+
a.graph
|
|
3001
|
+
);
|
|
3002
|
+
_.configure(
|
|
2832
3003
|
a,
|
|
2833
|
-
i.
|
|
3004
|
+
i.overlayDraggableEdges,
|
|
2834
3005
|
s,
|
|
2835
3006
|
this.window,
|
|
2836
3007
|
c
|
|
2837
3008
|
);
|
|
2838
3009
|
}
|
|
2839
|
-
|
|
3010
|
+
this.virtualScrollConfig !== void 0 ? Z.configure(
|
|
2840
3011
|
a,
|
|
2841
3012
|
i.main,
|
|
2842
3013
|
this.window,
|
|
2843
|
-
this.transformConfig,
|
|
3014
|
+
le(this.transformConfig),
|
|
2844
3015
|
e,
|
|
2845
3016
|
this.virtualScrollConfig
|
|
2846
|
-
) : this.hasTransformableViewport &&
|
|
3017
|
+
) : this.hasTransformableViewport && $.configure(
|
|
2847
3018
|
a,
|
|
2848
3019
|
i.main,
|
|
2849
3020
|
this.window,
|
|
2850
|
-
this.transformConfig
|
|
2851
|
-
), this.reset()
|
|
3021
|
+
le(this.transformConfig)
|
|
3022
|
+
), this.reset();
|
|
3023
|
+
const d = () => {
|
|
3024
|
+
i.destroy(), a.onBeforeDestroy.unsubscribe(d);
|
|
3025
|
+
};
|
|
3026
|
+
return a.onBeforeDestroy.subscribe(d), a;
|
|
2852
3027
|
}
|
|
2853
3028
|
/**
|
|
2854
3029
|
* @deprecated
|
|
@@ -2859,16 +3034,17 @@ class wt {
|
|
|
2859
3034
|
}
|
|
2860
3035
|
}
|
|
2861
3036
|
export {
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
3037
|
+
Ze as BezierEdgeShape,
|
|
3038
|
+
St as CanvasBuilder,
|
|
3039
|
+
Pe as DirectEdgeShape,
|
|
3040
|
+
pe as EventSubject,
|
|
3041
|
+
Je as HorizontalEdgeShape,
|
|
2867
3042
|
S as HtmlGraphError,
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
3043
|
+
tt as InteractiveEdgeError,
|
|
3044
|
+
Te as InteractiveEdgeShape,
|
|
3045
|
+
W as LineEdgeShape,
|
|
3046
|
+
xt as MedianEdgeShape,
|
|
3047
|
+
xt as MidpointEdgeShape,
|
|
3048
|
+
Qe as StraightEdgeShape,
|
|
3049
|
+
_e as VerticalEdgeShape
|
|
2874
3050
|
};
|