@html-graph/html-graph 3.2.0 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/html-graph.d.ts +39 -7
- package/dist/html-graph.js +669 -410
- package/dist/html-graph.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/html-graph.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var i = (t, e, o) =>
|
|
4
|
-
const
|
|
1
|
+
var ae = Object.defineProperty;
|
|
2
|
+
var le = (t, e, o) => e in t ? ae(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o;
|
|
3
|
+
var i = (t, e, o) => le(t, typeof e != "symbol" ? e + "" : e, o);
|
|
4
|
+
const ge = () => {
|
|
5
5
|
const t = document.createElement("div");
|
|
6
6
|
return t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.width = "0", t.style.height = "0", t;
|
|
7
|
-
},
|
|
7
|
+
}, ue = () => {
|
|
8
8
|
const t = document.createElement("div");
|
|
9
9
|
return t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.visibility = "hidden", t;
|
|
10
|
-
},
|
|
10
|
+
}, we = () => {
|
|
11
11
|
const t = document.createElement("div");
|
|
12
12
|
return t.style.width = "100%", t.style.height = "100%", t.style.position = "relative", t.style.overflow = "hidden", t;
|
|
13
13
|
};
|
|
14
|
-
class
|
|
14
|
+
class ne {
|
|
15
15
|
constructor(e, o, r) {
|
|
16
|
-
i(this, "host",
|
|
17
|
-
i(this, "container",
|
|
16
|
+
i(this, "host", we());
|
|
17
|
+
i(this, "container", ge());
|
|
18
18
|
i(this, "nodeIdToWrapperElementMap", /* @__PURE__ */ new Map());
|
|
19
19
|
i(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
|
|
20
20
|
i(this, "applyTransform", () => {
|
|
@@ -24,7 +24,7 @@ class le {
|
|
|
24
24
|
this.graphStore = e, this.viewportStore = o, this.element = r, this.element.appendChild(this.host), this.host.appendChild(this.container), this.viewportStore.onAfterUpdated.subscribe(this.applyTransform);
|
|
25
25
|
}
|
|
26
26
|
attachNode(e) {
|
|
27
|
-
const o = this.graphStore.getNode(e), r =
|
|
27
|
+
const o = this.graphStore.getNode(e), r = ue();
|
|
28
28
|
r.appendChild(o.element), this.container.appendChild(r), this.nodeIdToWrapperElementMap.set(e, r), this.updateNodePosition(e), this.updateNodePriority(e), r.style.visibility = "visible";
|
|
29
29
|
}
|
|
30
30
|
detachNode(e) {
|
|
@@ -50,7 +50,7 @@ class le {
|
|
|
50
50
|
this.viewportStore.onAfterUpdated.unsubscribe(this.applyTransform), this.clear(), this.element.removeChild(this.host), this.host.removeChild(this.container);
|
|
51
51
|
}
|
|
52
52
|
updateNodePosition(e) {
|
|
53
|
-
const o = this.nodeIdToWrapperElementMap.get(e), r = this.graphStore.getNode(e), { width: s, height:
|
|
53
|
+
const o = this.nodeIdToWrapperElementMap.get(e), r = this.graphStore.getNode(e), { width: s, height: h } = r.element.getBoundingClientRect(), n = this.viewportStore.getViewportMatrix().scale, d = r.centerFn(s, h), c = r.x - n * d.x, a = r.y - n * d.y;
|
|
54
54
|
o.style.transform = `translate(${c}px, ${a}px)`;
|
|
55
55
|
}
|
|
56
56
|
updateNodePriority(e) {
|
|
@@ -64,40 +64,37 @@ class le {
|
|
|
64
64
|
this.edgeIdToElementMap.set(e, r.shape.svg), this.container.appendChild(r.shape.svg);
|
|
65
65
|
}
|
|
66
66
|
renderEdge(e) {
|
|
67
|
-
const o = this.graphStore.getEdge(e), r = this.graphStore.getPort(o.from), s = this.graphStore.getPort(o.to),
|
|
68
|
-
x: c.scale *
|
|
69
|
-
y: c.scale *
|
|
70
|
-
},
|
|
71
|
-
x: c.scale *
|
|
72
|
-
y: c.scale *
|
|
73
|
-
},
|
|
74
|
-
x:
|
|
75
|
-
y:
|
|
76
|
-
width:
|
|
77
|
-
height:
|
|
67
|
+
const o = this.graphStore.getEdge(e), r = this.graphStore.getPort(o.from), s = this.graphStore.getPort(o.to), h = r.element.getBoundingClientRect(), n = s.element.getBoundingClientRect(), d = this.host.getBoundingClientRect(), c = this.viewportStore.getViewportMatrix(), a = h.left - d.left, l = h.top - d.top, g = n.left - d.left, y = n.top - d.top, v = {
|
|
68
|
+
x: c.scale * a + c.x,
|
|
69
|
+
y: c.scale * l + c.y
|
|
70
|
+
}, f = {
|
|
71
|
+
x: c.scale * g + c.x,
|
|
72
|
+
y: c.scale * y + c.y
|
|
73
|
+
}, p = {
|
|
74
|
+
x: v.x,
|
|
75
|
+
y: v.y,
|
|
76
|
+
width: h.width * c.scale,
|
|
77
|
+
height: h.height * c.scale,
|
|
78
78
|
direction: r.direction,
|
|
79
79
|
portId: o.from,
|
|
80
80
|
nodeId: r.nodeId
|
|
81
|
-
},
|
|
82
|
-
x:
|
|
83
|
-
y:
|
|
81
|
+
}, A = {
|
|
82
|
+
x: f.x,
|
|
83
|
+
y: f.y,
|
|
84
84
|
width: n.width * c.scale,
|
|
85
85
|
height: n.height * c.scale,
|
|
86
86
|
direction: s.direction,
|
|
87
87
|
portId: o.to,
|
|
88
88
|
nodeId: s.nodeId
|
|
89
89
|
};
|
|
90
|
-
o.shape.render({
|
|
91
|
-
from: g,
|
|
92
|
-
to: f
|
|
93
|
-
});
|
|
90
|
+
o.shape.render({ from: p, to: A });
|
|
94
91
|
}
|
|
95
92
|
updateEdgePriority(e) {
|
|
96
93
|
const o = this.graphStore.getEdge(e);
|
|
97
94
|
o.shape.svg.style.zIndex = `${o.priority}`;
|
|
98
95
|
}
|
|
99
96
|
}
|
|
100
|
-
class
|
|
97
|
+
class fe {
|
|
101
98
|
constructor(e) {
|
|
102
99
|
i(this, "xFrom", 1 / 0);
|
|
103
100
|
i(this, "yFrom", 1 / 0);
|
|
@@ -113,25 +110,25 @@ class ge {
|
|
|
113
110
|
return o.x >= this.xFrom && o.x <= this.xTo && o.y >= this.yFrom && o.y <= this.yTo;
|
|
114
111
|
}
|
|
115
112
|
hasEdge(e) {
|
|
116
|
-
const o = this.graphStore.getEdge(e), r = this.graphStore.getPort(o.from).nodeId, s = this.graphStore.getPort(o.to).nodeId,
|
|
117
|
-
return
|
|
113
|
+
const o = this.graphStore.getEdge(e), r = this.graphStore.getPort(o.from).nodeId, s = this.graphStore.getPort(o.to).nodeId, h = this.graphStore.getNode(r), n = this.graphStore.getNode(s), d = Math.min(h.x, n.x), c = Math.max(h.x, n.x), a = Math.min(h.y, n.y), l = Math.max(h.y, n.y);
|
|
114
|
+
return d <= this.xTo && c >= this.xFrom && a <= this.yTo && l >= this.yFrom;
|
|
118
115
|
}
|
|
119
116
|
}
|
|
120
|
-
class
|
|
117
|
+
class ye {
|
|
121
118
|
constructor(e, o, r) {
|
|
122
119
|
i(this, "attachedNodes", /* @__PURE__ */ new Set());
|
|
123
120
|
i(this, "attachedEdges", /* @__PURE__ */ new Set());
|
|
124
121
|
i(this, "renderingBox");
|
|
125
122
|
i(this, "updateViewport", (e) => {
|
|
126
123
|
this.renderingBox.setRenderingBox(e);
|
|
127
|
-
const o = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(),
|
|
124
|
+
const o = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Set();
|
|
128
125
|
this.graphStore.getAllNodeIds().forEach((n) => {
|
|
129
|
-
const
|
|
130
|
-
|
|
126
|
+
const d = this.renderingBox.hasNode(n), c = this.attachedNodes.has(n);
|
|
127
|
+
d && !c ? o.add(n) : !d && c && r.add(n);
|
|
131
128
|
}), this.graphStore.getAllEdgeIds().forEach((n) => {
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
}),
|
|
129
|
+
const d = this.renderingBox.hasEdge(n), c = this.attachedEdges.has(n), a = this.graphStore.getEdge(n), l = this.graphStore.getPort(a.from).nodeId, g = this.graphStore.getPort(a.to).nodeId;
|
|
130
|
+
d && (this.renderingBox.hasNode(l) || (o.add(l), r.delete(l)), this.renderingBox.hasNode(g) || (o.add(g), r.delete(g))), d && !c ? s.add(n) : !d && c && h.add(n);
|
|
131
|
+
}), h.forEach((n) => {
|
|
135
132
|
this.handleDetachEdge(n);
|
|
136
133
|
}), r.forEach((n) => {
|
|
137
134
|
this.handleDetachNode(n);
|
|
@@ -141,7 +138,7 @@ class ue {
|
|
|
141
138
|
this.handleAttachEdge(n);
|
|
142
139
|
});
|
|
143
140
|
});
|
|
144
|
-
this.htmlView = e, this.graphStore = o, this.trigger = r, this.renderingBox = new
|
|
141
|
+
this.htmlView = e, this.graphStore = o, this.trigger = r, this.renderingBox = new fe(this.graphStore), this.trigger.subscribe(this.updateViewport);
|
|
145
142
|
}
|
|
146
143
|
attachNode(e) {
|
|
147
144
|
this.renderingBox.hasNode(e) && this.handleAttachNode(e);
|
|
@@ -195,7 +192,7 @@ class ue {
|
|
|
195
192
|
this.htmlView.detachEdge(e), this.attachedEdges.delete(e);
|
|
196
193
|
}
|
|
197
194
|
}
|
|
198
|
-
class
|
|
195
|
+
class he {
|
|
199
196
|
constructor() {
|
|
200
197
|
i(this, "callbacks", /* @__PURE__ */ new Set());
|
|
201
198
|
}
|
|
@@ -211,24 +208,24 @@ class se {
|
|
|
211
208
|
});
|
|
212
209
|
}
|
|
213
210
|
}
|
|
214
|
-
const
|
|
215
|
-
const t = new
|
|
211
|
+
const E = () => {
|
|
212
|
+
const t = new he();
|
|
216
213
|
return [t, t];
|
|
217
214
|
};
|
|
218
|
-
class
|
|
215
|
+
class ve {
|
|
219
216
|
constructor(e) {
|
|
220
217
|
i(this, "onBeforeUpdated");
|
|
221
218
|
i(this, "onAfterUpdated");
|
|
222
|
-
this.
|
|
219
|
+
this.viewportStore = e, this.onBeforeUpdated = this.viewportStore.onBeforeUpdated, this.onAfterUpdated = this.viewportStore.onAfterUpdated;
|
|
223
220
|
}
|
|
224
221
|
getViewportMatrix() {
|
|
225
|
-
return { ...this.
|
|
222
|
+
return { ...this.viewportStore.getViewportMatrix() };
|
|
226
223
|
}
|
|
227
224
|
getContentMatrix() {
|
|
228
|
-
return { ...this.
|
|
225
|
+
return { ...this.viewportStore.getContentMatrix() };
|
|
229
226
|
}
|
|
230
227
|
}
|
|
231
|
-
class
|
|
228
|
+
class xe {
|
|
232
229
|
constructor(e) {
|
|
233
230
|
i(this, "onAfterNodeAdded");
|
|
234
231
|
i(this, "onAfterNodeUpdated");
|
|
@@ -304,7 +301,7 @@ class fe {
|
|
|
304
301
|
return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeAdjacentEdgeIds(e);
|
|
305
302
|
}
|
|
306
303
|
}
|
|
307
|
-
class
|
|
304
|
+
class Y {
|
|
308
305
|
constructor(e) {
|
|
309
306
|
i(this, "counter", 0);
|
|
310
307
|
this.checkExists = e;
|
|
@@ -320,21 +317,21 @@ class X {
|
|
|
320
317
|
this.counter = 0;
|
|
321
318
|
}
|
|
322
319
|
}
|
|
323
|
-
class
|
|
320
|
+
class S extends Error {
|
|
324
321
|
constructor() {
|
|
325
322
|
super(...arguments);
|
|
326
323
|
i(this, "name", "HtmlGraphError");
|
|
327
324
|
}
|
|
328
325
|
}
|
|
329
|
-
const
|
|
326
|
+
const Ae = (t, e) => ({
|
|
330
327
|
x: t / 2,
|
|
331
328
|
y: e / 2
|
|
332
|
-
}), H = (t) => () => t,
|
|
329
|
+
}), H = (t) => () => t, oe = H(0), pe = () => {
|
|
333
330
|
let t = 0;
|
|
334
331
|
return () => t++;
|
|
335
|
-
},
|
|
336
|
-
let o =
|
|
337
|
-
const s =
|
|
332
|
+
}, Ee = (t, e) => {
|
|
333
|
+
let o = oe, r = oe;
|
|
334
|
+
const s = pe();
|
|
338
335
|
return t === "incremental" && (o = s), e === "incremental" && (r = s), typeof t == "number" && (o = H(t)), typeof e == "number" && (r = H(e)), typeof t == "function" && (o = t), typeof e == "function" && (r = e), {
|
|
339
336
|
nodesPriorityFn: o,
|
|
340
337
|
edgesPriorityFn: r
|
|
@@ -345,33 +342,33 @@ const ye = (t, e) => ({
|
|
|
345
342
|
}), T = (t, e, o) => ({ x: e * Math.cos(t), y: o * Math.sin(t) }), w = {
|
|
346
343
|
x: 0,
|
|
347
344
|
y: 0
|
|
348
|
-
},
|
|
349
|
-
const
|
|
345
|
+
}, N = (t, e, o, r) => {
|
|
346
|
+
const h = [
|
|
350
347
|
w,
|
|
351
348
|
{ x: o, y: r },
|
|
352
349
|
{ x: o, y: -r }
|
|
353
|
-
].map((a) => x(a, t, w)).map((a) => ({ x: a.x + e.x, y: a.y + e.y })), n = `M ${
|
|
354
|
-
return `${n} ${
|
|
355
|
-
},
|
|
350
|
+
].map((a) => x(a, t, w)).map((a) => ({ x: a.x + e.x, y: a.y + e.y })), n = `M ${h[0].x} ${h[0].y}`, d = `L ${h[1].x} ${h[1].y}`, c = `L ${h[2].x} ${h[2].y}`;
|
|
351
|
+
return `${n} ${d} ${c}`;
|
|
352
|
+
}, I = (t, e) => {
|
|
356
353
|
const o = [];
|
|
357
354
|
if (t.length > 0 && o.push(`M ${t[0].x} ${t[0].y}`), t.length === 2 && o.push(`L ${t[1].x} ${t[1].y}`), t.length > 2) {
|
|
358
355
|
const r = t.length - 1;
|
|
359
|
-
let s = 0,
|
|
360
|
-
t.forEach((
|
|
356
|
+
let s = 0, h = 0, n = 0;
|
|
357
|
+
t.forEach((d, c) => {
|
|
361
358
|
let a = 0, l = 0, g = 0;
|
|
362
|
-
const
|
|
363
|
-
if (
|
|
364
|
-
const
|
|
365
|
-
s =
|
|
359
|
+
const y = c > 0, v = c < r, f = y && v;
|
|
360
|
+
if (y && (a = -s, l = -h, g = n), v) {
|
|
361
|
+
const R = t[c + 1];
|
|
362
|
+
s = R.x - d.x, h = R.y - d.y, n = Math.sqrt(s * s + h * h);
|
|
366
363
|
}
|
|
367
|
-
const
|
|
368
|
-
c > 0 && o.push(`L ${
|
|
369
|
-
`C ${
|
|
364
|
+
const A = n !== 0 ? Math.min((f ? e : 0) / n, c < r - 1 ? 0.5 : 1) : 0, b = f ? { x: d.x + s * A, y: d.y + h * A } : d, m = g !== 0 ? Math.min((f ? e : 0) / g, c > 1 ? 0.5 : 1) : 0, L = f ? { x: d.x + a * m, y: d.y + l * m } : d;
|
|
365
|
+
c > 0 && o.push(`L ${L.x} ${L.y}`), f && o.push(
|
|
366
|
+
`C ${d.x} ${d.y} ${d.x} ${d.y} ${b.x} ${b.y}`
|
|
370
367
|
);
|
|
371
368
|
});
|
|
372
369
|
}
|
|
373
370
|
return o.join(" ");
|
|
374
|
-
},
|
|
371
|
+
}, $ = () => {
|
|
375
372
|
const t = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
376
373
|
return t.style.pointerEvents = "none", t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.overflow = "visible", t;
|
|
377
374
|
}, W = () => {
|
|
@@ -380,7 +377,7 @@ const ye = (t, e) => ({
|
|
|
380
377
|
}, F = (t, e) => {
|
|
381
378
|
const o = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
382
379
|
return o.setAttribute("stroke", t), o.setAttribute("stroke-width", `${e}`), o.setAttribute("fill", "none"), o;
|
|
383
|
-
},
|
|
380
|
+
}, P = (t) => {
|
|
384
381
|
const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
385
382
|
return e.setAttribute("fill", t), e;
|
|
386
383
|
}, z = (t, e) => {
|
|
@@ -390,16 +387,16 @@ const ye = (t, e) => ({
|
|
|
390
387
|
}, r = {
|
|
391
388
|
x: e.x + e.width / 2,
|
|
392
389
|
y: e.y + e.height / 2
|
|
393
|
-
}, s = Math.min(o.x, r.x),
|
|
390
|
+
}, s = Math.min(o.x, r.x), h = Math.min(o.y, r.y), n = Math.abs(r.x - o.x), d = Math.abs(r.y - o.y), c = o.x <= r.x ? 1 : -1, a = o.y <= r.y ? 1 : -1;
|
|
394
391
|
return {
|
|
395
392
|
x: s,
|
|
396
|
-
y:
|
|
393
|
+
y: h,
|
|
397
394
|
width: n,
|
|
398
|
-
height:
|
|
395
|
+
height: d,
|
|
399
396
|
flipX: c,
|
|
400
397
|
flipY: a
|
|
401
398
|
};
|
|
402
|
-
},
|
|
399
|
+
}, Se = (t) => {
|
|
403
400
|
const e = x(
|
|
404
401
|
{ x: t.arrowLength, y: w.y },
|
|
405
402
|
t.fromVector,
|
|
@@ -414,9 +411,9 @@ const ye = (t, e) => ({
|
|
|
414
411
|
}, s = {
|
|
415
412
|
x: o.x - t.toVector.x * t.curvature,
|
|
416
413
|
y: o.y - t.toVector.y * t.curvature
|
|
417
|
-
},
|
|
418
|
-
return `${n}${
|
|
419
|
-
},
|
|
414
|
+
}, h = `M ${e.x} ${e.y} C ${r.x} ${r.y}, ${s.x} ${s.y}, ${o.x} ${o.y}`, n = t.hasSourceArrow ? "" : `M ${w.x} ${w.y} L ${e.x} ${e.y} `, d = t.hasTargetArrow ? "" : ` M ${o.x} ${o.y} L ${t.to.x} ${t.to.y}`;
|
|
415
|
+
return `${n}${h}${d}`;
|
|
416
|
+
}, be = (t) => {
|
|
420
417
|
const e = t.hasSourceArrow ? x(
|
|
421
418
|
{ x: t.arrowLength, y: w.y },
|
|
422
419
|
t.fromVector,
|
|
@@ -425,41 +422,41 @@ const ye = (t, e) => ({
|
|
|
425
422
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
426
423
|
t.toVector,
|
|
427
424
|
t.to
|
|
428
|
-
) : t.to, r = t.arrowLength, s = Math.cos(t.detourDirection) * t.detourDistance,
|
|
425
|
+
) : t.to, r = t.arrowLength, s = Math.cos(t.detourDirection) * t.detourDistance, h = Math.sin(t.detourDirection) * t.detourDistance, n = s * t.flipX, d = h * t.flipY, c = x(
|
|
429
426
|
{ x: r, y: w.y },
|
|
430
427
|
t.fromVector,
|
|
431
428
|
w
|
|
432
429
|
), a = {
|
|
433
430
|
x: c.x + n,
|
|
434
|
-
y: c.y +
|
|
431
|
+
y: c.y + d
|
|
435
432
|
}, l = x(
|
|
436
433
|
{ x: t.to.x - r, y: t.to.y },
|
|
437
434
|
t.toVector,
|
|
438
435
|
t.to
|
|
439
436
|
), g = {
|
|
440
437
|
x: l.x + n,
|
|
441
|
-
y: l.y +
|
|
442
|
-
},
|
|
438
|
+
y: l.y + d
|
|
439
|
+
}, y = { x: (a.x + g.x) / 2, y: (a.y + g.y) / 2 }, v = {
|
|
443
440
|
x: c.x + t.curvature * t.fromVector.x,
|
|
444
441
|
y: c.y + t.curvature * t.fromVector.y
|
|
445
|
-
},
|
|
442
|
+
}, f = {
|
|
446
443
|
x: l.x - t.curvature * t.toVector.x,
|
|
447
444
|
y: l.y - t.curvature * t.toVector.y
|
|
448
445
|
}, p = {
|
|
449
446
|
x: c.x + n,
|
|
450
|
-
y: c.y +
|
|
451
|
-
},
|
|
447
|
+
y: c.y + d
|
|
448
|
+
}, A = {
|
|
452
449
|
x: l.x + n,
|
|
453
|
-
y: l.y +
|
|
450
|
+
y: l.y + d
|
|
454
451
|
};
|
|
455
452
|
return [
|
|
456
453
|
`M ${e.x} ${e.y}`,
|
|
457
454
|
`L ${c.x} ${c.y}`,
|
|
458
|
-
`C ${v.x} ${v.y} ${p.x} ${p.y} ${
|
|
459
|
-
`C ${
|
|
455
|
+
`C ${v.x} ${v.y} ${p.x} ${p.y} ${y.x} ${y.y}`,
|
|
456
|
+
`C ${A.x} ${A.y} ${f.x} ${f.y} ${l.x} ${l.y}`,
|
|
460
457
|
`L ${o.x} ${o.y}`
|
|
461
458
|
].join(" ");
|
|
462
|
-
},
|
|
459
|
+
}, me = (t) => {
|
|
463
460
|
const e = t.hasSourceArrow ? x(
|
|
464
461
|
{ x: t.arrowLength, y: w.y },
|
|
465
462
|
t.fromVector,
|
|
@@ -468,7 +465,7 @@ const ye = (t, e) => ({
|
|
|
468
465
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
469
466
|
t.toVector,
|
|
470
467
|
t.to
|
|
471
|
-
) : t.to, r = t.arrowLength + t.arrowOffset, s = r - t.roundness,
|
|
468
|
+
) : t.to, r = t.arrowLength + t.arrowOffset, s = r - t.roundness, h = x(
|
|
472
469
|
{ x: s, y: w.y },
|
|
473
470
|
t.fromVector,
|
|
474
471
|
w
|
|
@@ -476,18 +473,18 @@ const ye = (t, e) => ({
|
|
|
476
473
|
{ x: t.to.x - s, y: t.to.y },
|
|
477
474
|
t.toVector,
|
|
478
475
|
t.to
|
|
479
|
-
),
|
|
480
|
-
x: t.flipX > 0 ?
|
|
481
|
-
y:
|
|
476
|
+
), d = Math.max((h.x + n.x) / 2, r), c = t.to.y / 2, a = {
|
|
477
|
+
x: t.flipX > 0 ? d : -r,
|
|
478
|
+
y: h.y
|
|
482
479
|
}, l = { x: a.x, y: c }, g = {
|
|
483
|
-
x: t.flipX > 0 ? t.to.x -
|
|
480
|
+
x: t.flipX > 0 ? t.to.x - d : t.to.x + r,
|
|
484
481
|
y: n.y
|
|
485
|
-
},
|
|
486
|
-
return
|
|
487
|
-
[e,
|
|
482
|
+
}, y = { x: g.x, y: c };
|
|
483
|
+
return I(
|
|
484
|
+
[e, h, a, l, y, g, n, o],
|
|
488
485
|
t.roundness
|
|
489
486
|
);
|
|
490
|
-
},
|
|
487
|
+
}, j = (t) => {
|
|
491
488
|
const e = t.hasSourceArrow ? x(
|
|
492
489
|
{ x: t.arrowLength, y: w.y },
|
|
493
490
|
t.fromVector,
|
|
@@ -500,16 +497,16 @@ const ye = (t, e) => ({
|
|
|
500
497
|
{ x: r, y: w.y },
|
|
501
498
|
t.fromVector,
|
|
502
499
|
w
|
|
503
|
-
),
|
|
500
|
+
), h = Math.cos(t.detourDirection) * t.detourDistance, n = Math.sin(t.detourDirection) * t.detourDistance, d = h * t.flipX, c = n * t.flipY, a = { x: s.x + d, y: s.y + c }, l = x(
|
|
504
501
|
{ x: t.to.x - r, y: t.to.y },
|
|
505
502
|
t.toVector,
|
|
506
503
|
t.to
|
|
507
|
-
), g = { x: l.x +
|
|
508
|
-
return
|
|
504
|
+
), g = { x: l.x + d, y: l.y + c };
|
|
505
|
+
return I(
|
|
509
506
|
[e, s, a, g, l, o],
|
|
510
507
|
t.roundness
|
|
511
508
|
);
|
|
512
|
-
},
|
|
509
|
+
}, Te = (t) => {
|
|
513
510
|
const e = t.hasSourceArrow ? x(
|
|
514
511
|
{ x: t.arrowLength, y: w.y },
|
|
515
512
|
t.fromVector,
|
|
@@ -522,13 +519,13 @@ const ye = (t, e) => ({
|
|
|
522
519
|
{ x: r, y: w.y },
|
|
523
520
|
t.fromVector,
|
|
524
521
|
w
|
|
525
|
-
),
|
|
522
|
+
), h = x(
|
|
526
523
|
{ x: t.to.x - r, y: t.to.y },
|
|
527
524
|
t.toVector,
|
|
528
525
|
t.to
|
|
529
526
|
);
|
|
530
|
-
return
|
|
531
|
-
},
|
|
527
|
+
return I([e, s, h, o], t.roundness);
|
|
528
|
+
}, Ne = (t) => {
|
|
532
529
|
const e = t.hasSourceArrow ? x(
|
|
533
530
|
{ x: t.arrowLength, y: w.y },
|
|
534
531
|
t.fromVector,
|
|
@@ -537,7 +534,7 @@ const ye = (t, e) => ({
|
|
|
537
534
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
538
535
|
t.toVector,
|
|
539
536
|
t.to
|
|
540
|
-
) : t.to, r = t.arrowLength + t.arrowOffset, s = r - t.roundness,
|
|
537
|
+
) : t.to, r = t.arrowLength + t.arrowOffset, s = r - t.roundness, h = x(
|
|
541
538
|
{ x: s, y: w.y },
|
|
542
539
|
t.fromVector,
|
|
543
540
|
w
|
|
@@ -545,18 +542,18 @@ const ye = (t, e) => ({
|
|
|
545
542
|
{ x: t.to.x - s, y: t.to.y },
|
|
546
543
|
t.toVector,
|
|
547
544
|
t.to
|
|
548
|
-
),
|
|
549
|
-
x:
|
|
550
|
-
y: t.flipY > 0 ?
|
|
545
|
+
), d = Math.max((h.y + n.y) / 2, r), c = t.to.x / 2, a = {
|
|
546
|
+
x: h.x,
|
|
547
|
+
y: t.flipY > 0 ? d : -r
|
|
551
548
|
}, l = { x: c, y: a.y }, g = {
|
|
552
549
|
x: n.x,
|
|
553
|
-
y: t.flipY > 0 ? t.to.y -
|
|
554
|
-
},
|
|
555
|
-
return
|
|
556
|
-
[e,
|
|
550
|
+
y: t.flipY > 0 ? t.to.y - d : t.to.y + r
|
|
551
|
+
}, y = { x: c, y: g.y };
|
|
552
|
+
return I(
|
|
553
|
+
[e, h, a, l, y, g, n, o],
|
|
557
554
|
t.roundness
|
|
558
555
|
);
|
|
559
|
-
},
|
|
556
|
+
}, G = (t) => {
|
|
560
557
|
const e = t.arrowOffset, o = t.side, r = t.arrowLength + e, s = r + 2 * o, n = [
|
|
561
558
|
{ x: t.arrowLength, y: w.y },
|
|
562
559
|
{ x: r, y: w.y },
|
|
@@ -568,13 +565,13 @@ const ye = (t, e) => ({
|
|
|
568
565
|
{ x: t.arrowLength, y: w.y }
|
|
569
566
|
].map(
|
|
570
567
|
(c) => x(c, t.fromVector, w)
|
|
571
|
-
),
|
|
572
|
-
return `${t.hasSourceArrow || t.hasTargetArrow ? "" :
|
|
573
|
-
},
|
|
574
|
-
const e = t.smallRadius, o = t.radius, r = Math.sqrt(e * e + o * o), s = e + o,
|
|
568
|
+
), d = `M ${w.x} ${w.y} L ${n[0].x} ${n[0].y} `;
|
|
569
|
+
return `${t.hasSourceArrow || t.hasTargetArrow ? "" : d}${I(n, t.roundness)}`;
|
|
570
|
+
}, Pe = (t) => {
|
|
571
|
+
const e = t.smallRadius, o = t.radius, r = Math.sqrt(e * e + o * o), s = e + o, h = t.arrowLength + r * (1 - o / s), n = e * o / s, c = [
|
|
575
572
|
{ x: t.arrowLength, y: w.y },
|
|
576
|
-
{ x:
|
|
577
|
-
{ x:
|
|
573
|
+
{ x: h, y: n },
|
|
574
|
+
{ x: h, y: -n }
|
|
578
575
|
].map(
|
|
579
576
|
(g) => x(g, t.fromVector, w)
|
|
580
577
|
), a = [
|
|
@@ -601,9 +598,9 @@ const ye = (t, e) => ({
|
|
|
601
598
|
smallCycleRadius: 15,
|
|
602
599
|
curvature: 90
|
|
603
600
|
});
|
|
604
|
-
class
|
|
601
|
+
class De {
|
|
605
602
|
constructor(e) {
|
|
606
|
-
i(this, "svg",
|
|
603
|
+
i(this, "svg", $());
|
|
607
604
|
i(this, "group", W());
|
|
608
605
|
i(this, "line");
|
|
609
606
|
i(this, "sourceArrow", null);
|
|
@@ -619,43 +616,43 @@ class me {
|
|
|
619
616
|
i(this, "hasTargetArrow");
|
|
620
617
|
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;
|
|
621
618
|
const o = (e == null ? void 0 : e.color) ?? u.color, r = (e == null ? void 0 : e.width) ?? u.width;
|
|
622
|
-
this.svg.appendChild(this.group), this.line = F(o, r), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow =
|
|
619
|
+
this.svg.appendChild(this.group), this.line = F(o, r), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = P(o), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = P(o), this.group.appendChild(this.targetArrow));
|
|
623
620
|
}
|
|
624
621
|
render(e) {
|
|
625
|
-
const { x: o, y: r, width: s, height:
|
|
622
|
+
const { x: o, y: r, width: s, height: h, flipX: n, flipY: d } = z(
|
|
626
623
|
e.from,
|
|
627
624
|
e.to
|
|
628
625
|
);
|
|
629
|
-
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${s}px`, this.svg.style.height = `${
|
|
626
|
+
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${Math.max(s, 1)}px`, this.svg.style.height = `${Math.max(h, 1)}px`, this.group.style.transform = `scale(${n}, ${d})`;
|
|
630
627
|
const c = T(
|
|
631
628
|
e.from.direction,
|
|
632
629
|
n,
|
|
633
|
-
|
|
634
|
-
), a = T(e.to.direction, n,
|
|
630
|
+
d
|
|
631
|
+
), a = T(e.to.direction, n, d), l = {
|
|
635
632
|
x: s,
|
|
636
|
-
y:
|
|
633
|
+
y: h
|
|
637
634
|
};
|
|
638
|
-
let g,
|
|
639
|
-
if (e.from.portId === e.to.portId ? (g =
|
|
635
|
+
let g, y = a, v = -this.arrowLength;
|
|
636
|
+
if (e.from.portId === e.to.portId ? (g = Pe({
|
|
640
637
|
fromVector: c,
|
|
641
638
|
radius: this.portCycleRadius,
|
|
642
639
|
smallRadius: this.portCycleSmallRadius,
|
|
643
640
|
arrowLength: this.arrowLength,
|
|
644
641
|
hasSourceArrow: this.hasSourceArrow,
|
|
645
642
|
hasTargetArrow: this.hasTargetArrow
|
|
646
|
-
}),
|
|
643
|
+
}), y = c, v = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = be({
|
|
647
644
|
to: l,
|
|
648
645
|
fromVector: c,
|
|
649
646
|
toVector: a,
|
|
650
647
|
flipX: n,
|
|
651
|
-
flipY:
|
|
648
|
+
flipY: d,
|
|
652
649
|
arrowLength: this.arrowLength,
|
|
653
650
|
detourDirection: this.detourDirection,
|
|
654
651
|
detourDistance: this.detourDistance,
|
|
655
652
|
curvature: this.curvature,
|
|
656
653
|
hasSourceArrow: this.hasSourceArrow,
|
|
657
654
|
hasTargetArrow: this.hasTargetArrow
|
|
658
|
-
}) : g =
|
|
655
|
+
}) : g = Se({
|
|
659
656
|
to: l,
|
|
660
657
|
fromVector: c,
|
|
661
658
|
toVector: a,
|
|
@@ -664,28 +661,28 @@ class me {
|
|
|
664
661
|
hasSourceArrow: this.hasSourceArrow,
|
|
665
662
|
hasTargetArrow: this.hasTargetArrow
|
|
666
663
|
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
667
|
-
const
|
|
664
|
+
const f = N(
|
|
668
665
|
c,
|
|
669
666
|
w,
|
|
670
667
|
this.arrowLength,
|
|
671
668
|
this.arrowWidth
|
|
672
669
|
);
|
|
673
|
-
this.sourceArrow.setAttribute("d",
|
|
670
|
+
this.sourceArrow.setAttribute("d", f);
|
|
674
671
|
}
|
|
675
672
|
if (this.targetArrow) {
|
|
676
|
-
const
|
|
677
|
-
|
|
673
|
+
const f = N(
|
|
674
|
+
y,
|
|
678
675
|
l,
|
|
679
676
|
v,
|
|
680
677
|
this.arrowWidth
|
|
681
678
|
);
|
|
682
|
-
this.targetArrow.setAttribute("d",
|
|
679
|
+
this.targetArrow.setAttribute("d", f);
|
|
683
680
|
}
|
|
684
681
|
}
|
|
685
682
|
}
|
|
686
|
-
class
|
|
683
|
+
class Me {
|
|
687
684
|
constructor(e) {
|
|
688
|
-
i(this, "svg",
|
|
685
|
+
i(this, "svg", $());
|
|
689
686
|
i(this, "group", W());
|
|
690
687
|
i(this, "line");
|
|
691
688
|
i(this, "sourceArrow", null);
|
|
@@ -707,24 +704,24 @@ class Ne {
|
|
|
707
704
|
this.cycleSquareSide / 2
|
|
708
705
|
), 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;
|
|
709
706
|
const r = (e == null ? void 0 : e.color) ?? u.color, s = (e == null ? void 0 : e.width) ?? u.width;
|
|
710
|
-
this.svg.appendChild(this.group), this.line = F(r, s), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow =
|
|
707
|
+
this.svg.appendChild(this.group), this.line = F(r, s), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = P(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = P(r), this.group.appendChild(this.targetArrow));
|
|
711
708
|
}
|
|
712
709
|
render(e) {
|
|
713
|
-
const { x: o, y: r, width: s, height:
|
|
710
|
+
const { x: o, y: r, width: s, height: h, flipX: n, flipY: d } = z(
|
|
714
711
|
e.from,
|
|
715
712
|
e.to
|
|
716
713
|
);
|
|
717
|
-
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${s}px`, this.svg.style.height = `${
|
|
714
|
+
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${Math.max(s, 1)}px`, this.svg.style.height = `${Math.max(h, 1)}px`, this.group.style.transform = `scale(${n}, ${d})`;
|
|
718
715
|
const c = T(
|
|
719
716
|
e.from.direction,
|
|
720
717
|
n,
|
|
721
|
-
|
|
722
|
-
), a = T(e.to.direction, n,
|
|
718
|
+
d
|
|
719
|
+
), a = T(e.to.direction, n, d), l = {
|
|
723
720
|
x: s,
|
|
724
|
-
y:
|
|
721
|
+
y: h
|
|
725
722
|
};
|
|
726
|
-
let g,
|
|
727
|
-
if (e.from.portId === e.to.portId ? (g =
|
|
723
|
+
let g, y = a, v = -this.arrowLength;
|
|
724
|
+
if (e.from.portId === e.to.portId ? (g = G({
|
|
728
725
|
fromVector: c,
|
|
729
726
|
arrowLength: this.arrowLength,
|
|
730
727
|
side: this.cycleSquareSide,
|
|
@@ -732,12 +729,12 @@ class Ne {
|
|
|
732
729
|
roundness: this.roundness,
|
|
733
730
|
hasSourceArrow: this.hasSourceArrow,
|
|
734
731
|
hasTargetArrow: this.hasTargetArrow
|
|
735
|
-
}),
|
|
732
|
+
}), y = c, v = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = j({
|
|
736
733
|
to: l,
|
|
737
734
|
fromVector: c,
|
|
738
735
|
toVector: a,
|
|
739
736
|
flipX: n,
|
|
740
|
-
flipY:
|
|
737
|
+
flipY: d,
|
|
741
738
|
arrowLength: this.arrowLength,
|
|
742
739
|
arrowOffset: this.arrowOffset,
|
|
743
740
|
roundness: this.roundness,
|
|
@@ -745,7 +742,7 @@ class Ne {
|
|
|
745
742
|
detourDistance: this.detourDistance,
|
|
746
743
|
hasSourceArrow: this.hasSourceArrow,
|
|
747
744
|
hasTargetArrow: this.hasTargetArrow
|
|
748
|
-
}) : g =
|
|
745
|
+
}) : g = me({
|
|
749
746
|
to: l,
|
|
750
747
|
fromVector: c,
|
|
751
748
|
toVector: a,
|
|
@@ -756,28 +753,28 @@ class Ne {
|
|
|
756
753
|
hasSourceArrow: this.hasSourceArrow,
|
|
757
754
|
hasTargetArrow: this.hasTargetArrow
|
|
758
755
|
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
759
|
-
const
|
|
756
|
+
const f = N(
|
|
760
757
|
c,
|
|
761
758
|
w,
|
|
762
759
|
this.arrowLength,
|
|
763
760
|
this.arrowWidth
|
|
764
761
|
);
|
|
765
|
-
this.sourceArrow.setAttribute("d",
|
|
762
|
+
this.sourceArrow.setAttribute("d", f);
|
|
766
763
|
}
|
|
767
764
|
if (this.targetArrow) {
|
|
768
|
-
const
|
|
769
|
-
|
|
765
|
+
const f = N(
|
|
766
|
+
y,
|
|
770
767
|
l,
|
|
771
768
|
v,
|
|
772
769
|
this.arrowWidth
|
|
773
770
|
);
|
|
774
|
-
this.targetArrow.setAttribute("d",
|
|
771
|
+
this.targetArrow.setAttribute("d", f);
|
|
775
772
|
}
|
|
776
773
|
}
|
|
777
774
|
}
|
|
778
|
-
class
|
|
775
|
+
class Ce {
|
|
779
776
|
constructor(e) {
|
|
780
|
-
i(this, "svg",
|
|
777
|
+
i(this, "svg", $());
|
|
781
778
|
i(this, "group", W());
|
|
782
779
|
i(this, "line");
|
|
783
780
|
i(this, "sourceArrow", null);
|
|
@@ -799,24 +796,24 @@ class Pe {
|
|
|
799
796
|
this.cycleSquareSide / 2
|
|
800
797
|
), 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;
|
|
801
798
|
const r = (e == null ? void 0 : e.color) ?? u.color, s = (e == null ? void 0 : e.width) ?? u.width;
|
|
802
|
-
this.svg.appendChild(this.group), this.line = F(r, s), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow =
|
|
799
|
+
this.svg.appendChild(this.group), this.line = F(r, s), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = P(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = P(r), this.group.appendChild(this.targetArrow));
|
|
803
800
|
}
|
|
804
801
|
render(e) {
|
|
805
|
-
const { x: o, y: r, width: s, height:
|
|
802
|
+
const { x: o, y: r, width: s, height: h, flipX: n, flipY: d } = z(
|
|
806
803
|
e.from,
|
|
807
804
|
e.to
|
|
808
805
|
);
|
|
809
|
-
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${s}px`, this.svg.style.height = `${
|
|
806
|
+
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${Math.max(s, 1)}px`, this.svg.style.height = `${Math.max(h, 1)}px`, this.group.style.transform = `scale(${n}, ${d})`;
|
|
810
807
|
const c = T(
|
|
811
808
|
e.from.direction,
|
|
812
809
|
n,
|
|
813
|
-
|
|
814
|
-
), a = T(e.to.direction, n,
|
|
810
|
+
d
|
|
811
|
+
), a = T(e.to.direction, n, d), l = {
|
|
815
812
|
x: s,
|
|
816
|
-
y:
|
|
813
|
+
y: h
|
|
817
814
|
};
|
|
818
|
-
let g,
|
|
819
|
-
if (e.from.portId === e.to.portId ? (g =
|
|
815
|
+
let g, y = a, v = -this.arrowLength;
|
|
816
|
+
if (e.from.portId === e.to.portId ? (g = G({
|
|
820
817
|
fromVector: c,
|
|
821
818
|
arrowLength: this.arrowLength,
|
|
822
819
|
side: this.cycleSquareSide,
|
|
@@ -824,12 +821,12 @@ class Pe {
|
|
|
824
821
|
roundness: this.roundness,
|
|
825
822
|
hasSourceArrow: this.hasSourceArrow,
|
|
826
823
|
hasTargetArrow: this.hasTargetArrow
|
|
827
|
-
}),
|
|
824
|
+
}), y = c, v = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = j({
|
|
828
825
|
to: l,
|
|
829
826
|
fromVector: c,
|
|
830
827
|
toVector: a,
|
|
831
828
|
flipX: n,
|
|
832
|
-
flipY:
|
|
829
|
+
flipY: d,
|
|
833
830
|
arrowLength: this.arrowLength,
|
|
834
831
|
arrowOffset: this.arrowOffset,
|
|
835
832
|
roundness: this.roundness,
|
|
@@ -837,7 +834,7 @@ class Pe {
|
|
|
837
834
|
detourDistance: this.detourDistance,
|
|
838
835
|
hasSourceArrow: this.hasSourceArrow,
|
|
839
836
|
hasTargetArrow: this.hasTargetArrow
|
|
840
|
-
}) : g =
|
|
837
|
+
}) : g = Te({
|
|
841
838
|
to: l,
|
|
842
839
|
fromVector: c,
|
|
843
840
|
toVector: a,
|
|
@@ -847,28 +844,28 @@ class Pe {
|
|
|
847
844
|
hasSourceArrow: this.hasSourceArrow,
|
|
848
845
|
hasTargetArrow: this.hasTargetArrow
|
|
849
846
|
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
850
|
-
const
|
|
847
|
+
const f = N(
|
|
851
848
|
c,
|
|
852
849
|
w,
|
|
853
850
|
this.arrowLength,
|
|
854
851
|
this.arrowWidth
|
|
855
852
|
);
|
|
856
|
-
this.sourceArrow.setAttribute("d",
|
|
853
|
+
this.sourceArrow.setAttribute("d", f);
|
|
857
854
|
}
|
|
858
855
|
if (this.targetArrow) {
|
|
859
|
-
const
|
|
860
|
-
|
|
856
|
+
const f = N(
|
|
857
|
+
y,
|
|
861
858
|
l,
|
|
862
859
|
v,
|
|
863
860
|
this.arrowWidth
|
|
864
861
|
);
|
|
865
|
-
this.targetArrow.setAttribute("d",
|
|
862
|
+
this.targetArrow.setAttribute("d", f);
|
|
866
863
|
}
|
|
867
864
|
}
|
|
868
865
|
}
|
|
869
866
|
class Ve {
|
|
870
867
|
constructor(e) {
|
|
871
|
-
i(this, "svg",
|
|
868
|
+
i(this, "svg", $());
|
|
872
869
|
i(this, "group", W());
|
|
873
870
|
i(this, "line");
|
|
874
871
|
i(this, "sourceArrow", null);
|
|
@@ -890,24 +887,24 @@ class Ve {
|
|
|
890
887
|
this.cycleSquareSide / 2
|
|
891
888
|
), 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;
|
|
892
889
|
const r = (e == null ? void 0 : e.color) ?? u.color, s = (e == null ? void 0 : e.width) ?? u.width;
|
|
893
|
-
this.svg.appendChild(this.group), this.line = F(r, s), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow =
|
|
890
|
+
this.svg.appendChild(this.group), this.line = F(r, s), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = P(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = P(r), this.group.appendChild(this.targetArrow));
|
|
894
891
|
}
|
|
895
892
|
render(e) {
|
|
896
|
-
const { x: o, y: r, width: s, height:
|
|
893
|
+
const { x: o, y: r, width: s, height: h, flipX: n, flipY: d } = z(
|
|
897
894
|
e.from,
|
|
898
895
|
e.to
|
|
899
896
|
);
|
|
900
|
-
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${s}px`, this.svg.style.height = `${
|
|
897
|
+
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${Math.max(s, 1)}px`, this.svg.style.height = `${Math.max(h, 1)}px`, this.group.style.transform = `scale(${n}, ${d})`;
|
|
901
898
|
const c = T(
|
|
902
899
|
e.from.direction,
|
|
903
900
|
n,
|
|
904
|
-
|
|
905
|
-
), a = T(e.to.direction, n,
|
|
901
|
+
d
|
|
902
|
+
), a = T(e.to.direction, n, d), l = {
|
|
906
903
|
x: s,
|
|
907
|
-
y:
|
|
904
|
+
y: h
|
|
908
905
|
};
|
|
909
|
-
let g,
|
|
910
|
-
if (e.from.portId === e.to.portId ? (g =
|
|
906
|
+
let g, y = a, v = -this.arrowLength;
|
|
907
|
+
if (e.from.portId === e.to.portId ? (g = G({
|
|
911
908
|
fromVector: c,
|
|
912
909
|
arrowLength: this.arrowLength,
|
|
913
910
|
side: this.cycleSquareSide,
|
|
@@ -915,12 +912,12 @@ class Ve {
|
|
|
915
912
|
roundness: this.roundness,
|
|
916
913
|
hasSourceArrow: this.hasSourceArrow,
|
|
917
914
|
hasTargetArrow: this.hasTargetArrow
|
|
918
|
-
}),
|
|
915
|
+
}), y = c, v = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = j({
|
|
919
916
|
to: l,
|
|
920
917
|
fromVector: c,
|
|
921
918
|
toVector: a,
|
|
922
919
|
flipX: n,
|
|
923
|
-
flipY:
|
|
920
|
+
flipY: d,
|
|
924
921
|
arrowLength: this.arrowLength,
|
|
925
922
|
arrowOffset: this.arrowOffset,
|
|
926
923
|
roundness: this.roundness,
|
|
@@ -928,42 +925,42 @@ class Ve {
|
|
|
928
925
|
detourDistance: this.detourDistance,
|
|
929
926
|
hasSourceArrow: this.hasSourceArrow,
|
|
930
927
|
hasTargetArrow: this.hasTargetArrow
|
|
931
|
-
}) : g =
|
|
928
|
+
}) : g = Ne({
|
|
932
929
|
to: l,
|
|
933
930
|
fromVector: c,
|
|
934
931
|
toVector: a,
|
|
935
|
-
flipY:
|
|
932
|
+
flipY: d,
|
|
936
933
|
arrowLength: this.arrowLength,
|
|
937
934
|
arrowOffset: this.arrowOffset,
|
|
938
935
|
roundness: this.roundness,
|
|
939
936
|
hasSourceArrow: this.hasSourceArrow,
|
|
940
937
|
hasTargetArrow: this.hasTargetArrow
|
|
941
938
|
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
942
|
-
const
|
|
939
|
+
const f = N(
|
|
943
940
|
c,
|
|
944
941
|
w,
|
|
945
942
|
this.arrowLength,
|
|
946
943
|
this.arrowWidth
|
|
947
944
|
);
|
|
948
|
-
this.sourceArrow.setAttribute("d",
|
|
945
|
+
this.sourceArrow.setAttribute("d", f);
|
|
949
946
|
}
|
|
950
947
|
if (this.targetArrow) {
|
|
951
|
-
const
|
|
952
|
-
|
|
948
|
+
const f = N(
|
|
949
|
+
y,
|
|
953
950
|
l,
|
|
954
951
|
v,
|
|
955
952
|
this.arrowWidth
|
|
956
953
|
);
|
|
957
|
-
this.targetArrow.setAttribute("d",
|
|
954
|
+
this.targetArrow.setAttribute("d", f);
|
|
958
955
|
}
|
|
959
956
|
}
|
|
960
957
|
}
|
|
961
|
-
const
|
|
958
|
+
const Le = (t) => {
|
|
962
959
|
if (typeof t == "function")
|
|
963
960
|
return t;
|
|
964
961
|
switch (t == null ? void 0 : t.type) {
|
|
965
962
|
case "straight":
|
|
966
|
-
return () => new
|
|
963
|
+
return () => new Ce({
|
|
967
964
|
color: t.color,
|
|
968
965
|
width: t.width,
|
|
969
966
|
arrowLength: t.arrowLength,
|
|
@@ -977,7 +974,7 @@ const De = (t) => {
|
|
|
977
974
|
detourDirection: t.detourDirection
|
|
978
975
|
});
|
|
979
976
|
case "horizontal":
|
|
980
|
-
return () => new
|
|
977
|
+
return () => new Me({
|
|
981
978
|
color: t.color,
|
|
982
979
|
width: t.width,
|
|
983
980
|
arrowLength: t.arrowLength,
|
|
@@ -1005,7 +1002,7 @@ const De = (t) => {
|
|
|
1005
1002
|
detourDirection: t.detourDirection
|
|
1006
1003
|
});
|
|
1007
1004
|
default:
|
|
1008
|
-
return () => new
|
|
1005
|
+
return () => new De({
|
|
1009
1006
|
color: t.color,
|
|
1010
1007
|
width: t.width,
|
|
1011
1008
|
arrowLength: t.arrowLength,
|
|
@@ -1019,28 +1016,28 @@ const De = (t) => {
|
|
|
1019
1016
|
detourDirection: t.detourDirection
|
|
1020
1017
|
});
|
|
1021
1018
|
}
|
|
1022
|
-
},
|
|
1023
|
-
var o, r, s,
|
|
1024
|
-
const e =
|
|
1019
|
+
}, Re = (t) => {
|
|
1020
|
+
var o, r, s, h, n;
|
|
1021
|
+
const e = Ee(
|
|
1025
1022
|
(o = t == null ? void 0 : t.nodes) == null ? void 0 : o.priority,
|
|
1026
1023
|
(r = t == null ? void 0 : t.edges) == null ? void 0 : r.priority
|
|
1027
1024
|
);
|
|
1028
1025
|
return {
|
|
1029
1026
|
nodes: {
|
|
1030
|
-
centerFn: ((s = t == null ? void 0 : t.nodes) == null ? void 0 : s.centerFn) ??
|
|
1027
|
+
centerFn: ((s = t == null ? void 0 : t.nodes) == null ? void 0 : s.centerFn) ?? Ae,
|
|
1031
1028
|
priorityFn: e.nodesPriorityFn
|
|
1032
1029
|
},
|
|
1033
1030
|
ports: {
|
|
1034
|
-
direction: ((
|
|
1031
|
+
direction: ((h = t == null ? void 0 : t.ports) == null ? void 0 : h.direction) ?? 0
|
|
1035
1032
|
},
|
|
1036
1033
|
edges: {
|
|
1037
|
-
shapeFactory:
|
|
1034
|
+
shapeFactory: Le(((n = t == null ? void 0 : t.edges) == null ? void 0 : n.shape) ?? {}),
|
|
1038
1035
|
priorityFn: e.edgesPriorityFn
|
|
1039
1036
|
}
|
|
1040
1037
|
};
|
|
1041
1038
|
};
|
|
1042
|
-
class
|
|
1043
|
-
constructor(e, o, r, s,
|
|
1039
|
+
class de {
|
|
1040
|
+
constructor(e, o, r, s, h) {
|
|
1044
1041
|
/**
|
|
1045
1042
|
* provides api for accessing model of rendered graph
|
|
1046
1043
|
*/
|
|
@@ -1050,13 +1047,13 @@ class Le {
|
|
|
1050
1047
|
*/
|
|
1051
1048
|
i(this, "viewport");
|
|
1052
1049
|
i(this, "defaults");
|
|
1053
|
-
i(this, "nodeIdGenerator", new
|
|
1050
|
+
i(this, "nodeIdGenerator", new Y(
|
|
1054
1051
|
(e) => this.graph.getNode(e) !== null
|
|
1055
1052
|
));
|
|
1056
|
-
i(this, "portIdGenerator", new
|
|
1053
|
+
i(this, "portIdGenerator", new Y(
|
|
1057
1054
|
(e) => this.graph.getPort(e) !== null
|
|
1058
1055
|
));
|
|
1059
|
-
i(this, "edgeIdGenerator", new
|
|
1056
|
+
i(this, "edgeIdGenerator", new Y(
|
|
1060
1057
|
(e) => this.graph.getEdge(e) !== null
|
|
1061
1058
|
));
|
|
1062
1059
|
i(this, "onAfterNodeAdded", (e) => {
|
|
@@ -1104,14 +1101,17 @@ class Le {
|
|
|
1104
1101
|
this.nodeIdGenerator.reset(), this.portIdGenerator.reset(), this.edgeIdGenerator.reset(), this.htmlView.clear();
|
|
1105
1102
|
});
|
|
1106
1103
|
i(this, "onBeforeDestroyEmitter");
|
|
1104
|
+
/**
|
|
1105
|
+
* emits event just before destruction of canvas
|
|
1106
|
+
*/
|
|
1107
1107
|
i(this, "onBeforeDestroy");
|
|
1108
|
-
this.element = e, this.graphStore = o, this.viewportStore = r, this.htmlView = s, this.defaults =
|
|
1108
|
+
this.element = e, this.graphStore = o, this.viewportStore = r, this.htmlView = s, this.defaults = Re(h), this.graph = new xe(this.graphStore), this.viewport = new ve(this.viewportStore), this.graphStore.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graphStore.onAfterNodeUpdated.subscribe(this.onAfterNodeUpdated), this.graphStore.onAfterNodePriorityUpdated.subscribe(
|
|
1109
1109
|
this.onAfterNodePriorityUpdated
|
|
1110
1110
|
), 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(
|
|
1111
1111
|
this.onAfterEdgeShapeUpdated
|
|
1112
1112
|
), this.graphStore.onAfterEdgeUpdated.subscribe(this.onAfterEdgeUpdated), this.graphStore.onAfterEdgePriorityUpdated.subscribe(
|
|
1113
1113
|
this.onAfterEdgePriorityUpdated
|
|
1114
|
-
), this.graphStore.onBeforeEdgeRemoved.subscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.subscribe(this.onBeforeClear), [this.onBeforeDestroyEmitter, this.onBeforeDestroy] =
|
|
1114
|
+
), this.graphStore.onBeforeEdgeRemoved.subscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.subscribe(this.onBeforeClear), [this.onBeforeDestroyEmitter, this.onBeforeDestroy] = E();
|
|
1115
1115
|
}
|
|
1116
1116
|
/**
|
|
1117
1117
|
* adds new node
|
|
@@ -1119,7 +1119,7 @@ class Le {
|
|
|
1119
1119
|
addNode(e) {
|
|
1120
1120
|
const o = this.nodeIdGenerator.create(e.id);
|
|
1121
1121
|
if (this.graph.getNode(o) !== null)
|
|
1122
|
-
throw new
|
|
1122
|
+
throw new S("failed to add node with existing id");
|
|
1123
1123
|
if (this.graphStore.addNode({
|
|
1124
1124
|
id: o,
|
|
1125
1125
|
element: e.element,
|
|
@@ -1142,7 +1142,7 @@ class Le {
|
|
|
1142
1142
|
*/
|
|
1143
1143
|
updateNode(e, o) {
|
|
1144
1144
|
if (this.graph.getNode(e) === null)
|
|
1145
|
-
throw new
|
|
1145
|
+
throw new S("failed to update non existing node");
|
|
1146
1146
|
return this.graphStore.updateNode(e, o ?? {}), this;
|
|
1147
1147
|
}
|
|
1148
1148
|
/**
|
|
@@ -1152,7 +1152,7 @@ class Le {
|
|
|
1152
1152
|
*/
|
|
1153
1153
|
removeNode(e) {
|
|
1154
1154
|
if (this.graph.getNode(e) === null)
|
|
1155
|
-
throw new
|
|
1155
|
+
throw new S("failed to remove non existing node");
|
|
1156
1156
|
return this.graphStore.removeNode(e), this;
|
|
1157
1157
|
}
|
|
1158
1158
|
/**
|
|
@@ -1161,9 +1161,9 @@ class Le {
|
|
|
1161
1161
|
markPort(e) {
|
|
1162
1162
|
const o = this.portIdGenerator.create(e.id);
|
|
1163
1163
|
if (this.graph.getPort(o) !== null)
|
|
1164
|
-
throw new
|
|
1164
|
+
throw new S("failed to add port with existing id");
|
|
1165
1165
|
if (this.graph.getNode(e.nodeId) === null)
|
|
1166
|
-
throw new
|
|
1166
|
+
throw new S("failed to mark port for nonexistent node");
|
|
1167
1167
|
return this.graphStore.addPort({
|
|
1168
1168
|
id: o,
|
|
1169
1169
|
element: e.element,
|
|
@@ -1176,7 +1176,7 @@ class Le {
|
|
|
1176
1176
|
*/
|
|
1177
1177
|
updatePort(e, o) {
|
|
1178
1178
|
if (this.graph.getPort(e) === null)
|
|
1179
|
-
throw new
|
|
1179
|
+
throw new S("failed to update nonexistent port");
|
|
1180
1180
|
return this.graphStore.updatePort(e, o ?? {}), this;
|
|
1181
1181
|
}
|
|
1182
1182
|
/**
|
|
@@ -1185,7 +1185,7 @@ class Le {
|
|
|
1185
1185
|
*/
|
|
1186
1186
|
unmarkPort(e) {
|
|
1187
1187
|
if (this.graph.getPort(e) === null)
|
|
1188
|
-
throw new
|
|
1188
|
+
throw new S("failed to unmark non existing port");
|
|
1189
1189
|
return this.graphStore.removePort(e), this;
|
|
1190
1190
|
}
|
|
1191
1191
|
/**
|
|
@@ -1194,11 +1194,11 @@ class Le {
|
|
|
1194
1194
|
addEdge(e) {
|
|
1195
1195
|
const o = this.edgeIdGenerator.create(e.id);
|
|
1196
1196
|
if (this.graph.getEdge(o) !== null)
|
|
1197
|
-
throw new
|
|
1197
|
+
throw new S("failed to add edge with existing id");
|
|
1198
1198
|
if (this.graph.getPort(e.from) === null)
|
|
1199
|
-
throw new
|
|
1199
|
+
throw new S("failed to add edge from nonexistent port");
|
|
1200
1200
|
if (this.graph.getPort(e.to) === null)
|
|
1201
|
-
throw new
|
|
1201
|
+
throw new S("failed to add edge to nonexistent port");
|
|
1202
1202
|
return this.graphStore.addEdge({
|
|
1203
1203
|
id: o,
|
|
1204
1204
|
from: e.from,
|
|
@@ -1212,7 +1212,7 @@ class Le {
|
|
|
1212
1212
|
*/
|
|
1213
1213
|
updateEdge(e, o) {
|
|
1214
1214
|
if (this.graph.getEdge(e) === null)
|
|
1215
|
-
throw new
|
|
1215
|
+
throw new S("failed to update nonexistent edge");
|
|
1216
1216
|
return this.graphStore.updateEdge(e, o ?? {}), this;
|
|
1217
1217
|
}
|
|
1218
1218
|
/**
|
|
@@ -1220,7 +1220,7 @@ class Le {
|
|
|
1220
1220
|
*/
|
|
1221
1221
|
removeEdge(e) {
|
|
1222
1222
|
if (this.graph.getEdge(e) === null)
|
|
1223
|
-
throw new
|
|
1223
|
+
throw new S("failed to remove nonexistent edge");
|
|
1224
1224
|
return this.graphStore.removeEdge(e), this;
|
|
1225
1225
|
}
|
|
1226
1226
|
/**
|
|
@@ -1247,16 +1247,16 @@ class Le {
|
|
|
1247
1247
|
* canvas element gets rolled back to initial state, and can not be reused
|
|
1248
1248
|
*/
|
|
1249
1249
|
destroy() {
|
|
1250
|
-
this.onBeforeDestroyEmitter.emit(), this.graphStore.onAfterNodeAdded.unsubscribe(this.onAfterNodeAdded), this.graphStore.onAfterNodeUpdated.unsubscribe(this.onAfterNodeUpdated), this.graphStore.onAfterNodePriorityUpdated.unsubscribe(
|
|
1250
|
+
this.onBeforeDestroyEmitter.emit(), this.clear(), this.graphStore.onAfterNodeAdded.unsubscribe(this.onAfterNodeAdded), this.graphStore.onAfterNodeUpdated.unsubscribe(this.onAfterNodeUpdated), this.graphStore.onAfterNodePriorityUpdated.unsubscribe(
|
|
1251
1251
|
this.onAfterNodePriorityUpdated
|
|
1252
1252
|
), this.graphStore.onBeforeNodeRemoved.unsubscribe(this.onBeforeNodeRemoved), this.graphStore.onAfterPortUpdated.unsubscribe(this.onAfterPortUpdated), this.graphStore.onBeforePortRemoved.unsubscribe(this.onBeforePortUnmarked), this.graphStore.onAfterEdgeAdded.unsubscribe(this.onAfterEdgeAdded), this.graphStore.onAfterEdgeShapeUpdated.unsubscribe(
|
|
1253
1253
|
this.onAfterEdgeShapeUpdated
|
|
1254
1254
|
), this.graphStore.onAfterEdgeUpdated.unsubscribe(this.onAfterEdgeUpdated), this.graphStore.onAfterEdgePriorityUpdated.unsubscribe(
|
|
1255
1255
|
this.onAfterEdgePriorityUpdated
|
|
1256
|
-
), this.graphStore.onBeforeEdgeRemoved.unsubscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.unsubscribe(this.onBeforeClear), this.
|
|
1256
|
+
), this.graphStore.onBeforeEdgeRemoved.unsubscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.unsubscribe(this.onBeforeClear), this.htmlView.destroy();
|
|
1257
1257
|
}
|
|
1258
1258
|
}
|
|
1259
|
-
class
|
|
1259
|
+
class ce {
|
|
1260
1260
|
constructor() {
|
|
1261
1261
|
i(this, "nodes", /* @__PURE__ */ new Map());
|
|
1262
1262
|
i(this, "ports", /* @__PURE__ */ new Map());
|
|
@@ -1290,7 +1290,7 @@ class Ce {
|
|
|
1290
1290
|
i(this, "onBeforeEdgeRemoved");
|
|
1291
1291
|
i(this, "beforeClearEmitter");
|
|
1292
1292
|
i(this, "onBeforeClear");
|
|
1293
|
-
[this.afterNodeAddedEmitter, this.onAfterNodeAdded] =
|
|
1293
|
+
[this.afterNodeAddedEmitter, this.onAfterNodeAdded] = E(), [this.afterNodeUpdatedEmitter, this.onAfterNodeUpdated] = E(), [this.afterNodePriorityUpdatedEmitter, this.onAfterNodePriorityUpdated] = E(), [this.beforeNodeRemovedEmitter, this.onBeforeNodeRemoved] = E(), [this.afterPortAddedEmitter, this.onAfterPortAdded] = E(), [this.afterPortUpdatedEmitter, this.onAfterPortUpdated] = E(), [this.beforePortRemovedEmitter, this.onBeforePortRemoved] = E(), [this.afterEdgeAddedEmitter, this.onAfterEdgeAdded] = E(), [this.afterEdgeShapeUpdatedEmitter, this.onAfterEdgeShapeUpdated] = E(), [this.afterEdgeUpdatedEmitter, this.onAfterEdgeUpdated] = E(), [this.afterEdgePriorityUpdatedEmitter, this.onAfterEdgePriorityUpdated] = E(), [this.beforeEdgeRemovedEmitter, this.onBeforeEdgeRemoved] = E(), [this.beforeClearEmitter, this.onBeforeClear] = E();
|
|
1294
1294
|
}
|
|
1295
1295
|
addNode(e) {
|
|
1296
1296
|
const o = /* @__PURE__ */ new Map(), r = {
|
|
@@ -1428,24 +1428,24 @@ class Ce {
|
|
|
1428
1428
|
this.cycleEdges.get(r).delete(e), this.cycleEdges.get(s).delete(e), this.incomingEdges.get(r).delete(e), this.incomingEdges.get(s).delete(e), this.outcomingEdges.get(r).delete(e), this.outcomingEdges.get(s).delete(e), this.edges.delete(e);
|
|
1429
1429
|
}
|
|
1430
1430
|
}
|
|
1431
|
-
const
|
|
1431
|
+
const re = (t) => ({
|
|
1432
1432
|
scale: 1 / t.scale,
|
|
1433
1433
|
x: -t.x / t.scale,
|
|
1434
1434
|
y: -t.y / t.scale
|
|
1435
|
-
}),
|
|
1435
|
+
}), ie = {
|
|
1436
1436
|
scale: 1,
|
|
1437
1437
|
x: 0,
|
|
1438
1438
|
y: 0
|
|
1439
1439
|
};
|
|
1440
|
-
class
|
|
1440
|
+
class Ie {
|
|
1441
1441
|
constructor() {
|
|
1442
|
-
i(this, "viewportMatrix",
|
|
1443
|
-
i(this, "contentMatrix",
|
|
1442
|
+
i(this, "viewportMatrix", ie);
|
|
1443
|
+
i(this, "contentMatrix", ie);
|
|
1444
1444
|
i(this, "afterUpdateEmitter");
|
|
1445
1445
|
i(this, "onAfterUpdated");
|
|
1446
1446
|
i(this, "beforeUpdateEmitter");
|
|
1447
1447
|
i(this, "onBeforeUpdated");
|
|
1448
|
-
[this.afterUpdateEmitter, this.onAfterUpdated] =
|
|
1448
|
+
[this.afterUpdateEmitter, this.onAfterUpdated] = E(), [this.beforeUpdateEmitter, this.onBeforeUpdated] = E();
|
|
1449
1449
|
}
|
|
1450
1450
|
getViewportMatrix() {
|
|
1451
1451
|
return this.viewportMatrix;
|
|
@@ -1458,17 +1458,17 @@ class Re {
|
|
|
1458
1458
|
scale: e.scale ?? this.viewportMatrix.scale,
|
|
1459
1459
|
x: e.x ?? this.viewportMatrix.x,
|
|
1460
1460
|
y: e.y ?? this.viewportMatrix.y
|
|
1461
|
-
}, this.contentMatrix =
|
|
1461
|
+
}, this.contentMatrix = re(this.viewportMatrix), this.afterUpdateEmitter.emit();
|
|
1462
1462
|
}
|
|
1463
1463
|
patchContentMatrix(e) {
|
|
1464
1464
|
this.beforeUpdateEmitter.emit(), this.contentMatrix = {
|
|
1465
1465
|
scale: e.scale ?? this.contentMatrix.scale,
|
|
1466
1466
|
x: e.x ?? this.contentMatrix.x,
|
|
1467
1467
|
y: e.y ?? this.contentMatrix.y
|
|
1468
|
-
}, this.viewportMatrix =
|
|
1468
|
+
}, this.viewportMatrix = re(this.contentMatrix), this.afterUpdateEmitter.emit();
|
|
1469
1469
|
}
|
|
1470
1470
|
}
|
|
1471
|
-
class
|
|
1471
|
+
class J {
|
|
1472
1472
|
constructor(e) {
|
|
1473
1473
|
i(this, "elementToNodeId", /* @__PURE__ */ new Map());
|
|
1474
1474
|
i(this, "nodesResizeObserver");
|
|
@@ -1494,7 +1494,7 @@ class G {
|
|
|
1494
1494
|
}), 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);
|
|
1495
1495
|
}
|
|
1496
1496
|
static configure(e) {
|
|
1497
|
-
new
|
|
1497
|
+
new J(e);
|
|
1498
1498
|
}
|
|
1499
1499
|
handleNodeResize(e) {
|
|
1500
1500
|
const o = this.elementToNodeId.get(e);
|
|
@@ -1503,33 +1503,35 @@ class G {
|
|
|
1503
1503
|
});
|
|
1504
1504
|
}
|
|
1505
1505
|
}
|
|
1506
|
-
const
|
|
1507
|
-
var g,
|
|
1506
|
+
const Be = (t) => {
|
|
1507
|
+
var g, y, v, f, p, A;
|
|
1508
1508
|
const e = ((g = t == null ? void 0 : t.events) == null ? void 0 : g.onNodeDrag) ?? (() => {
|
|
1509
|
-
}), o = ((
|
|
1510
|
-
}), s = (t == null ? void 0 : t.moveOnTop) === !1,
|
|
1509
|
+
}), o = ((y = t == null ? void 0 : t.events) == null ? void 0 : y.onBeforeNodeDrag) ?? (() => !0), r = ((v = t == null ? void 0 : t.events) == null ? void 0 : v.onNodeDragFinished) ?? (() => {
|
|
1510
|
+
}), s = (t == null ? void 0 : t.moveOnTop) === !1, h = (f = t == null ? void 0 : t.mouse) == null ? void 0 : f.dragCursor, n = h !== void 0 ? h : "grab", d = (p = t == null ? void 0 : t.mouse) == null ? void 0 : p.mouseDownEventVerifier, c = d !== void 0 ? d : (b) => b.button === 0, a = (A = t == null ? void 0 : t.mouse) == null ? void 0 : A.mouseUpEventVerifier;
|
|
1511
1511
|
return {
|
|
1512
1512
|
freezePriority: s,
|
|
1513
1513
|
dragCursor: n,
|
|
1514
1514
|
mouseDownEventVerifier: c,
|
|
1515
|
-
mouseUpEventVerifier: a !== void 0 ? a : (
|
|
1515
|
+
mouseUpEventVerifier: a !== void 0 ? a : (b) => b.button === 0,
|
|
1516
1516
|
onNodeDrag: e,
|
|
1517
1517
|
onBeforeNodeDrag: o,
|
|
1518
1518
|
onNodeDragFinished: r
|
|
1519
1519
|
};
|
|
1520
|
-
},
|
|
1521
|
-
const { x: r, y: s, width:
|
|
1522
|
-
return e >= r && e <= r +
|
|
1523
|
-
},
|
|
1520
|
+
}, Ue = (t, e, o) => {
|
|
1521
|
+
const { x: r, y: s, width: h, height: n } = t.getBoundingClientRect();
|
|
1522
|
+
return e >= r && e <= r + h && o >= s && o <= s + n;
|
|
1523
|
+
}, $e = (t, e, o) => e >= 0 && e <= t.innerWidth && o >= 0 && o <= t.innerHeight, V = (t, e, o, r) => Ue(e, o, r) && $e(t, o, r), U = (t, e) => {
|
|
1524
1524
|
e !== null ? t.style.cursor = e : t.style.removeProperty("cursor");
|
|
1525
|
-
}
|
|
1526
|
-
|
|
1527
|
-
|
|
1525
|
+
}, C = (t, e) => ({
|
|
1526
|
+
x: t.scale * e.x + t.x,
|
|
1527
|
+
y: t.scale * e.y + t.y
|
|
1528
|
+
});
|
|
1529
|
+
class K {
|
|
1530
|
+
constructor(e, o, r, s) {
|
|
1528
1531
|
i(this, "grabbedNodeId", null);
|
|
1529
1532
|
i(this, "maxNodePriority", 0);
|
|
1530
1533
|
i(this, "previousTouchCoordinates", null);
|
|
1531
1534
|
i(this, "nodeIds", /* @__PURE__ */ new Map());
|
|
1532
|
-
i(this, "window", window);
|
|
1533
1535
|
i(this, "graph");
|
|
1534
1536
|
i(this, "onAfterNodeAdded", (e) => {
|
|
1535
1537
|
this.updateMaxNodePriority(e);
|
|
@@ -1560,7 +1562,7 @@ class J {
|
|
|
1560
1562
|
element: s.element,
|
|
1561
1563
|
x: s.x,
|
|
1562
1564
|
y: s.y
|
|
1563
|
-
}) && (e.stopImmediatePropagation(), this.grabbedNodeId = r,
|
|
1565
|
+
}) && (e.stopImmediatePropagation(), this.grabbedNodeId = r, U(this.element, this.options.dragCursor), this.moveNodeOnTop(r), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.window.addEventListener("mousemove", this.onWindowMouseMove));
|
|
1564
1566
|
});
|
|
1565
1567
|
i(this, "onTouchStart", (e) => {
|
|
1566
1568
|
if (e.touches.length !== 1)
|
|
@@ -1578,7 +1580,12 @@ class J {
|
|
|
1578
1580
|
}) && (this.grabbedNodeId = r, this.moveNodeOnTop(r), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish));
|
|
1579
1581
|
});
|
|
1580
1582
|
i(this, "onWindowMouseMove", (e) => {
|
|
1581
|
-
if (!
|
|
1583
|
+
if (!V(
|
|
1584
|
+
this.window,
|
|
1585
|
+
this.element,
|
|
1586
|
+
e.clientX,
|
|
1587
|
+
e.clientY
|
|
1588
|
+
)) {
|
|
1582
1589
|
this.cancelMouseDrag();
|
|
1583
1590
|
return;
|
|
1584
1591
|
}
|
|
@@ -1591,13 +1598,18 @@ class J {
|
|
|
1591
1598
|
if (e.touches.length !== 1)
|
|
1592
1599
|
return;
|
|
1593
1600
|
const o = e.touches[0];
|
|
1594
|
-
if (!
|
|
1601
|
+
if (!V(
|
|
1602
|
+
this.window,
|
|
1603
|
+
this.element,
|
|
1604
|
+
o.clientX,
|
|
1605
|
+
o.clientY
|
|
1606
|
+
)) {
|
|
1595
1607
|
this.cancelTouchDrag();
|
|
1596
1608
|
return;
|
|
1597
1609
|
}
|
|
1598
1610
|
if (this.grabbedNodeId !== null && this.previousTouchCoordinates !== null) {
|
|
1599
|
-
const
|
|
1600
|
-
this.dragNode(this.grabbedNodeId,
|
|
1611
|
+
const s = o.clientX - this.previousTouchCoordinates.x, h = o.clientY - this.previousTouchCoordinates.y;
|
|
1612
|
+
this.dragNode(this.grabbedNodeId, s, h), this.previousTouchCoordinates = {
|
|
1601
1613
|
x: e.touches[0].clientX,
|
|
1602
1614
|
y: e.touches[0].clientY
|
|
1603
1615
|
};
|
|
@@ -1607,21 +1619,27 @@ class J {
|
|
|
1607
1619
|
this.previousTouchCoordinates = null, this.cancelTouchDrag();
|
|
1608
1620
|
});
|
|
1609
1621
|
i(this, "options");
|
|
1610
|
-
this.canvas = e, this.element = o, this.options =
|
|
1622
|
+
this.canvas = e, this.element = o, this.window = r, this.options = Be(s), 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);
|
|
1611
1623
|
}
|
|
1612
|
-
static configure(e, o, r) {
|
|
1613
|
-
new
|
|
1624
|
+
static configure(e, o, r, s) {
|
|
1625
|
+
new K(e, o, r, s);
|
|
1614
1626
|
}
|
|
1615
1627
|
dragNode(e, o, r) {
|
|
1616
1628
|
const s = this.graph.getNode(e);
|
|
1617
1629
|
if (s === null)
|
|
1618
1630
|
return;
|
|
1619
|
-
const
|
|
1620
|
-
|
|
1631
|
+
const h = this.canvas.viewport.getContentMatrix(), n = C(h, {
|
|
1632
|
+
x: s.x,
|
|
1633
|
+
y: s.y
|
|
1634
|
+
}), d = C(
|
|
1635
|
+
{ scale: 1, x: o, y: r },
|
|
1636
|
+
n
|
|
1637
|
+
), c = this.canvas.viewport.getViewportMatrix(), a = C(c, d);
|
|
1638
|
+
this.canvas.updateNode(e, { x: a.x, y: a.y }), this.options.onNodeDrag({
|
|
1621
1639
|
nodeId: e,
|
|
1622
1640
|
element: s.element,
|
|
1623
|
-
x:
|
|
1624
|
-
y:
|
|
1641
|
+
x: a.x,
|
|
1642
|
+
y: a.y
|
|
1625
1643
|
});
|
|
1626
1644
|
}
|
|
1627
1645
|
moveNodeOnTop(e) {
|
|
@@ -1640,7 +1658,7 @@ class J {
|
|
|
1640
1658
|
element: e.element,
|
|
1641
1659
|
x: e.x,
|
|
1642
1660
|
y: e.y
|
|
1643
|
-
}), this.grabbedNodeId = null,
|
|
1661
|
+
}), this.grabbedNodeId = null, U(this.element, null), this.removeMouseDragListeners();
|
|
1644
1662
|
}
|
|
1645
1663
|
removeMouseDragListeners() {
|
|
1646
1664
|
this.window.removeEventListener("mouseup", this.onWindowMouseUp), this.window.removeEventListener("mousemove", this.onWindowMouseMove);
|
|
@@ -1663,30 +1681,30 @@ class J {
|
|
|
1663
1681
|
this.maxNodePriority = Math.max(this.maxNodePriority, o);
|
|
1664
1682
|
}
|
|
1665
1683
|
}
|
|
1666
|
-
const
|
|
1684
|
+
const We = (t) => {
|
|
1667
1685
|
const e = t.minX !== null ? t.minX : -1 / 0, o = t.maxX !== null ? t.maxX : 1 / 0, r = t.minY !== null ? t.minY : -1 / 0, s = t.maxY !== null ? t.maxY : 1 / 0;
|
|
1668
|
-
return (
|
|
1669
|
-
let n =
|
|
1670
|
-
n < e && n <
|
|
1671
|
-
const c =
|
|
1672
|
-
n > a && n >
|
|
1673
|
-
const l =
|
|
1674
|
-
return
|
|
1686
|
+
return (h) => {
|
|
1687
|
+
let n = h.nextTransform.x, d = h.nextTransform.y;
|
|
1688
|
+
n < e && n < h.prevTransform.x && (n = Math.min(h.prevTransform.x, e));
|
|
1689
|
+
const c = h.canvasWidth * h.prevTransform.scale, a = o - c;
|
|
1690
|
+
n > a && n > h.prevTransform.x && (n = Math.max(h.prevTransform.x, a)), d < r && d < h.prevTransform.y && (d = Math.min(h.prevTransform.y, r));
|
|
1691
|
+
const l = h.canvasHeight * h.prevTransform.scale, g = s - l;
|
|
1692
|
+
return d > g && d > h.prevTransform.y && (d = Math.max(h.prevTransform.y, g)), { scale: h.nextTransform.scale, x: n, y: d };
|
|
1675
1693
|
};
|
|
1676
|
-
},
|
|
1694
|
+
}, Fe = (t) => {
|
|
1677
1695
|
const e = t.maxContentScale, o = t.minContentScale, r = e !== null ? 1 / e : 0, s = o !== null ? 1 / o : 1 / 0;
|
|
1678
|
-
return (
|
|
1679
|
-
const n =
|
|
1680
|
-
let c =
|
|
1681
|
-
if (
|
|
1696
|
+
return (h) => {
|
|
1697
|
+
const n = h.prevTransform, d = h.nextTransform;
|
|
1698
|
+
let c = d.scale, a = d.x, l = d.y;
|
|
1699
|
+
if (d.scale > s && d.scale > n.scale) {
|
|
1682
1700
|
c = Math.max(n.scale, s), a = n.x, l = n.y;
|
|
1683
|
-
const g = (c - n.scale) / (
|
|
1684
|
-
a = n.x + (
|
|
1701
|
+
const g = (c - n.scale) / (d.scale - n.scale);
|
|
1702
|
+
a = n.x + (d.x - n.x) * g, l = n.y + (d.y - n.y) * g;
|
|
1685
1703
|
}
|
|
1686
|
-
if (
|
|
1704
|
+
if (d.scale < r && d.scale < n.scale) {
|
|
1687
1705
|
c = Math.min(n.scale, r), a = n.x, l = n.y;
|
|
1688
|
-
const g = (c - n.scale) / (
|
|
1689
|
-
a = n.x + (
|
|
1706
|
+
const g = (c - n.scale) / (d.scale - n.scale);
|
|
1707
|
+
a = n.x + (d.x - n.x) * g, l = n.y + (d.y - n.y) * g;
|
|
1690
1708
|
}
|
|
1691
1709
|
return {
|
|
1692
1710
|
scale: c,
|
|
@@ -1694,7 +1712,7 @@ const Be = (t) => {
|
|
|
1694
1712
|
y: l
|
|
1695
1713
|
};
|
|
1696
1714
|
};
|
|
1697
|
-
},
|
|
1715
|
+
}, ze = (t) => (e) => t.reduce(
|
|
1698
1716
|
(o, r) => r({
|
|
1699
1717
|
prevTransform: e.prevTransform,
|
|
1700
1718
|
nextTransform: o,
|
|
@@ -1702,71 +1720,71 @@ const Be = (t) => {
|
|
|
1702
1720
|
canvasHeight: e.canvasHeight
|
|
1703
1721
|
}),
|
|
1704
1722
|
e.nextTransform
|
|
1705
|
-
),
|
|
1723
|
+
), se = (t) => {
|
|
1706
1724
|
if (typeof t == "function")
|
|
1707
1725
|
return t;
|
|
1708
1726
|
switch (t.type) {
|
|
1709
1727
|
case "scale-limit":
|
|
1710
|
-
return
|
|
1728
|
+
return Fe({
|
|
1711
1729
|
minContentScale: t.minContentScale ?? 0,
|
|
1712
1730
|
maxContentScale: t.maxContentScale ?? 1 / 0
|
|
1713
1731
|
});
|
|
1714
1732
|
case "shift-limit":
|
|
1715
|
-
return
|
|
1733
|
+
return We({
|
|
1716
1734
|
minX: t.minX ?? -1 / 0,
|
|
1717
1735
|
maxX: t.maxX ?? 1 / 0,
|
|
1718
1736
|
minY: t.minY ?? -1 / 0,
|
|
1719
1737
|
maxY: t.maxY ?? 1 / 0
|
|
1720
1738
|
});
|
|
1721
1739
|
}
|
|
1722
|
-
},
|
|
1723
|
-
var
|
|
1724
|
-
const e = (
|
|
1740
|
+
}, ke = (t) => {
|
|
1741
|
+
var f, p, A, b, D, m, L, R, q, O, ee, te;
|
|
1742
|
+
const e = (f = t == null ? void 0 : t.scale) == null ? void 0 : f.mouseWheelSensitivity, o = e !== void 0 ? e : 1.2, r = t == null ? void 0 : t.transformPreprocessor;
|
|
1725
1743
|
let s;
|
|
1726
|
-
r !== void 0 ? Array.isArray(r) ? s =
|
|
1744
|
+
r !== void 0 ? Array.isArray(r) ? s = ze(
|
|
1727
1745
|
r.map(
|
|
1728
|
-
(
|
|
1746
|
+
(M) => se(M)
|
|
1729
1747
|
)
|
|
1730
|
-
) : s =
|
|
1731
|
-
const
|
|
1732
|
-
}),
|
|
1733
|
-
}), c = (
|
|
1748
|
+
) : s = se(r) : s = (M) => M.nextTransform;
|
|
1749
|
+
const h = ((p = t == null ? void 0 : t.shift) == null ? void 0 : p.cursor) !== void 0 ? t.shift.cursor : "grab", n = ((A = t == null ? void 0 : t.events) == null ? void 0 : A.onBeforeTransformChange) ?? (() => {
|
|
1750
|
+
}), d = ((b = t == null ? void 0 : t.events) == null ? void 0 : b.onTransformChange) ?? (() => {
|
|
1751
|
+
}), c = (D = t == null ? void 0 : t.shift) == null ? void 0 : D.mouseDownEventVerifier, a = c !== void 0 ? c : (M) => M.button === 0, l = (m = t == null ? void 0 : t.shift) == null ? void 0 : m.mouseUpEventVerifier, g = l !== void 0 ? l : (M) => M.button === 0, y = (L = t == null ? void 0 : t.scale) == null ? void 0 : L.mouseWheelEventVerifier, v = y !== void 0 ? y : () => !0;
|
|
1734
1752
|
return {
|
|
1735
1753
|
wheelSensitivity: o,
|
|
1736
|
-
onTransformStarted: ((
|
|
1754
|
+
onTransformStarted: ((R = t == null ? void 0 : t.events) == null ? void 0 : R.onTransformStarted) ?? (() => {
|
|
1737
1755
|
}),
|
|
1738
|
-
onTransformFinished: ((
|
|
1756
|
+
onTransformFinished: ((q = t == null ? void 0 : t.events) == null ? void 0 : q.onTransformFinished) ?? (() => {
|
|
1739
1757
|
}),
|
|
1740
1758
|
onBeforeTransformChange: n,
|
|
1741
|
-
onTransformChange:
|
|
1759
|
+
onTransformChange: d,
|
|
1742
1760
|
transformPreprocessor: s,
|
|
1743
|
-
shiftCursor:
|
|
1761
|
+
shiftCursor: h,
|
|
1744
1762
|
mouseDownEventVerifier: a,
|
|
1745
1763
|
mouseUpEventVerifier: g,
|
|
1746
1764
|
mouseWheelEventVerifier: v,
|
|
1747
|
-
scaleWheelFinishTimeout: ((
|
|
1748
|
-
onResizeTransformStarted: ((
|
|
1765
|
+
scaleWheelFinishTimeout: ((O = t == null ? void 0 : t.scale) == null ? void 0 : O.wheelFinishTimeout) ?? 500,
|
|
1766
|
+
onResizeTransformStarted: ((ee = t == null ? void 0 : t.events) == null ? void 0 : ee.onResizeTransformStarted) ?? (() => {
|
|
1749
1767
|
}),
|
|
1750
|
-
onResizeTransformFinished: ((
|
|
1768
|
+
onResizeTransformFinished: ((te = t == null ? void 0 : t.events) == null ? void 0 : te.onResizeTransformFinished) ?? (() => {
|
|
1751
1769
|
})
|
|
1752
1770
|
};
|
|
1753
|
-
},
|
|
1771
|
+
}, Ye = (t, e, o) => ({
|
|
1754
1772
|
scale: t.scale,
|
|
1755
1773
|
x: t.x + t.scale * e,
|
|
1756
1774
|
y: t.y + t.scale * o
|
|
1757
|
-
}),
|
|
1775
|
+
}), Xe = (t, e, o, r) => ({
|
|
1758
1776
|
scale: t.scale * e,
|
|
1759
1777
|
x: t.scale * (1 - e) * o + t.x,
|
|
1760
1778
|
y: t.scale * (1 - e) * r + t.y
|
|
1761
|
-
}),
|
|
1779
|
+
}), B = (t) => {
|
|
1762
1780
|
const e = [], o = t.touches.length;
|
|
1763
|
-
for (let
|
|
1764
|
-
e.push([t.touches[
|
|
1781
|
+
for (let d = 0; d < o; d++)
|
|
1782
|
+
e.push([t.touches[d].clientX, t.touches[d].clientY]);
|
|
1765
1783
|
const r = e.reduce(
|
|
1766
|
-
(
|
|
1784
|
+
(d, c) => [d[0] + c[0], d[1] + c[1]],
|
|
1767
1785
|
[0, 0]
|
|
1768
|
-
), s = [r[0] / o, r[1] / o], n = e.map((
|
|
1769
|
-
(
|
|
1786
|
+
), s = [r[0] / o, r[1] / o], n = e.map((d) => [d[0] - s[0], d[1] - s[1]]).reduce(
|
|
1787
|
+
(d, c) => d + Math.sqrt(c[0] * c[0] + c[1] * c[1]),
|
|
1770
1788
|
0
|
|
1771
1789
|
);
|
|
1772
1790
|
return {
|
|
@@ -1777,9 +1795,8 @@ const Be = (t) => {
|
|
|
1777
1795
|
touches: e
|
|
1778
1796
|
};
|
|
1779
1797
|
};
|
|
1780
|
-
class
|
|
1781
|
-
constructor(e, o, r) {
|
|
1782
|
-
i(this, "window", window);
|
|
1798
|
+
class k {
|
|
1799
|
+
constructor(e, o, r, s) {
|
|
1783
1800
|
i(this, "viewport");
|
|
1784
1801
|
i(this, "prevTouches", null);
|
|
1785
1802
|
i(this, "wheelFinishTimer", null);
|
|
@@ -1788,15 +1805,21 @@ class Y {
|
|
|
1788
1805
|
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.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy);
|
|
1789
1806
|
});
|
|
1790
1807
|
i(this, "onMouseDown", (e) => {
|
|
1791
|
-
this.element === null || !this.options.mouseDownEventVerifier(e) || (
|
|
1808
|
+
this.element === null || !this.options.mouseDownEventVerifier(e) || (U(this.element, this.options.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.startRegisteredTransform());
|
|
1792
1809
|
});
|
|
1793
1810
|
i(this, "onWindowMouseMove", (e) => {
|
|
1794
|
-
|
|
1811
|
+
const o = V(
|
|
1812
|
+
this.window,
|
|
1813
|
+
this.element,
|
|
1814
|
+
e.clientX,
|
|
1815
|
+
e.clientY
|
|
1816
|
+
);
|
|
1817
|
+
if (this.element === null || !o) {
|
|
1795
1818
|
this.stopMouseDrag();
|
|
1796
1819
|
return;
|
|
1797
1820
|
}
|
|
1798
|
-
const
|
|
1799
|
-
this.moveViewport(
|
|
1821
|
+
const r = -e.movementX, s = -e.movementY;
|
|
1822
|
+
this.moveViewport(r, s);
|
|
1800
1823
|
});
|
|
1801
1824
|
i(this, "onWindowMouseUp", (e) => {
|
|
1802
1825
|
this.element === null || !this.options.mouseUpEventVerifier(e) || this.stopMouseDrag();
|
|
@@ -1805,22 +1828,22 @@ class Y {
|
|
|
1805
1828
|
if (!this.options.mouseWheelEventVerifier(e))
|
|
1806
1829
|
return;
|
|
1807
1830
|
e.preventDefault();
|
|
1808
|
-
const { left: o, top: r } = this.element.getBoundingClientRect(), s = e.clientX - o,
|
|
1809
|
-
this.wheelFinishTimer === null && this.options.onTransformStarted(), this.scaleViewport(
|
|
1831
|
+
const { left: o, top: r } = this.element.getBoundingClientRect(), s = e.clientX - o, h = e.clientY - r, d = 1 / (e.deltaY < 0 ? this.options.wheelSensitivity : 1 / this.options.wheelSensitivity);
|
|
1832
|
+
this.wheelFinishTimer === null && this.options.onTransformStarted(), this.scaleViewport(d, s, h), this.wheelFinishTimer !== null && clearTimeout(this.wheelFinishTimer), this.wheelFinishTimer = setTimeout(() => {
|
|
1810
1833
|
this.transformInProgress || this.options.onTransformFinished(), this.wheelFinishTimer = null;
|
|
1811
1834
|
}, this.options.scaleWheelFinishTimeout);
|
|
1812
1835
|
});
|
|
1813
1836
|
i(this, "onTouchStart", (e) => {
|
|
1814
1837
|
if (this.prevTouches !== null) {
|
|
1815
|
-
this.prevTouches =
|
|
1838
|
+
this.prevTouches = B(e);
|
|
1816
1839
|
return;
|
|
1817
1840
|
}
|
|
1818
|
-
this.prevTouches =
|
|
1841
|
+
this.prevTouches = B(e), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish), this.startRegisteredTransform();
|
|
1819
1842
|
});
|
|
1820
1843
|
i(this, "onWindowTouchMove", (e) => {
|
|
1821
|
-
const o =
|
|
1844
|
+
const o = B(e);
|
|
1822
1845
|
if (!o.touches.every(
|
|
1823
|
-
(s) =>
|
|
1846
|
+
(s) => V(this.window, this.element, s[0], s[1])
|
|
1824
1847
|
)) {
|
|
1825
1848
|
this.stopTouchDrag();
|
|
1826
1849
|
return;
|
|
@@ -1829,13 +1852,13 @@ class Y {
|
|
|
1829
1852
|
-(o.x - this.prevTouches.x),
|
|
1830
1853
|
-(o.y - this.prevTouches.y)
|
|
1831
1854
|
), o.touchesCnt === 2) {
|
|
1832
|
-
const { left: s, top:
|
|
1833
|
-
this.scaleViewport(a, n,
|
|
1855
|
+
const { left: s, top: h } = this.element.getBoundingClientRect(), n = this.prevTouches.x - s, d = this.prevTouches.y - h, a = 1 / (o.scale / this.prevTouches.scale);
|
|
1856
|
+
this.scaleViewport(a, n, d);
|
|
1834
1857
|
}
|
|
1835
1858
|
this.prevTouches = o;
|
|
1836
1859
|
});
|
|
1837
1860
|
i(this, "onWindowTouchFinish", (e) => {
|
|
1838
|
-
e.touches.length > 0 ? this.prevTouches =
|
|
1861
|
+
e.touches.length > 0 ? this.prevTouches = B(e) : this.stopTouchDrag();
|
|
1839
1862
|
});
|
|
1840
1863
|
i(this, "observer", new ResizeObserver(() => {
|
|
1841
1864
|
const e = this.viewport.getViewportMatrix(), { width: o, height: r } = this.element.getBoundingClientRect(), s = this.options.transformPreprocessor({
|
|
@@ -1847,35 +1870,36 @@ class Y {
|
|
|
1847
1870
|
this.options.onResizeTransformStarted(), this.canvas.patchViewportMatrix(s), this.options.onResizeTransformFinished();
|
|
1848
1871
|
}));
|
|
1849
1872
|
i(this, "options");
|
|
1850
|
-
this.canvas = e, this.element = o, this.options =
|
|
1873
|
+
this.canvas = e, this.element = o, this.window = r, this.options = ke(s), this.viewport = e.viewport, this.observer.observe(this.element), this.element.addEventListener("mousedown", this.onMouseDown), this.element.addEventListener("wheel", this.onWheelScroll), this.element.addEventListener("touchstart", this.onTouchStart), e.onBeforeDestroy.subscribe(this.onBeforeDestroy);
|
|
1851
1874
|
}
|
|
1852
|
-
static configure(e, o, r) {
|
|
1853
|
-
new
|
|
1875
|
+
static configure(e, o, r, s) {
|
|
1876
|
+
new k(
|
|
1854
1877
|
e,
|
|
1855
1878
|
o,
|
|
1856
|
-
r
|
|
1879
|
+
r,
|
|
1880
|
+
s
|
|
1857
1881
|
);
|
|
1858
1882
|
}
|
|
1859
1883
|
moveViewport(e, o) {
|
|
1860
|
-
const r = this.viewport.getViewportMatrix(), s =
|
|
1884
|
+
const r = this.viewport.getViewportMatrix(), s = Ye(r, e, o), { width: h, height: n } = this.element.getBoundingClientRect(), d = this.options.transformPreprocessor({
|
|
1861
1885
|
prevTransform: r,
|
|
1862
1886
|
nextTransform: s,
|
|
1863
|
-
canvasWidth:
|
|
1887
|
+
canvasWidth: h,
|
|
1864
1888
|
canvasHeight: n
|
|
1865
1889
|
});
|
|
1866
|
-
this.performTransform(
|
|
1890
|
+
this.performTransform(d);
|
|
1867
1891
|
}
|
|
1868
1892
|
scaleViewport(e, o, r) {
|
|
1869
|
-
const s = this.canvas.viewport.getViewportMatrix(),
|
|
1893
|
+
const s = this.canvas.viewport.getViewportMatrix(), h = Xe(s, e, o, r), { width: n, height: d } = this.element.getBoundingClientRect(), c = this.options.transformPreprocessor({
|
|
1870
1894
|
prevTransform: s,
|
|
1871
|
-
nextTransform:
|
|
1895
|
+
nextTransform: h,
|
|
1872
1896
|
canvasWidth: n,
|
|
1873
|
-
canvasHeight:
|
|
1897
|
+
canvasHeight: d
|
|
1874
1898
|
});
|
|
1875
1899
|
this.performTransform(c);
|
|
1876
1900
|
}
|
|
1877
1901
|
stopMouseDrag() {
|
|
1878
|
-
|
|
1902
|
+
U(this.element, null), this.removeMouseDragListeners(), this.finishRegisteredTransform();
|
|
1879
1903
|
}
|
|
1880
1904
|
removeMouseDragListeners() {
|
|
1881
1905
|
this.window.removeEventListener("mousemove", this.onWindowMouseMove), this.window.removeEventListener("mouseup", this.onWindowMouseUp);
|
|
@@ -1896,10 +1920,9 @@ class Y {
|
|
|
1896
1920
|
this.transformInProgress = !1, this.options.onTransformFinished();
|
|
1897
1921
|
}
|
|
1898
1922
|
}
|
|
1899
|
-
class
|
|
1900
|
-
constructor(e, o, r, s,
|
|
1923
|
+
class Q {
|
|
1924
|
+
constructor(e, o, r, s, h, n) {
|
|
1901
1925
|
i(this, "canvasResizeObserver");
|
|
1902
|
-
i(this, "window", window);
|
|
1903
1926
|
i(this, "nodeHorizontal");
|
|
1904
1927
|
i(this, "nodeVertical");
|
|
1905
1928
|
i(this, "viewport");
|
|
@@ -1929,52 +1952,54 @@ class K {
|
|
|
1929
1952
|
this.userTransformInProgress || (this.viewportMatrix = this.viewport.getViewportMatrix(), this.loadAreaAroundViewport());
|
|
1930
1953
|
});
|
|
1931
1954
|
i(this, "userTransformInProgress", !1);
|
|
1932
|
-
var
|
|
1933
|
-
this.canvas = e, this.element = o, this.trigger =
|
|
1934
|
-
const
|
|
1935
|
-
this.viewportWidth =
|
|
1955
|
+
var v, f, p, A, b;
|
|
1956
|
+
this.canvas = e, this.element = o, this.window = r, this.trigger = h, this.virtualScrollOptions = n, this.nodeHorizontal = this.virtualScrollOptions.nodeContainingRadius.horizontal, this.nodeVertical = this.virtualScrollOptions.nodeContainingRadius.vertical, this.canvasResizeObserver = new ResizeObserver((D) => {
|
|
1957
|
+
const m = D[0];
|
|
1958
|
+
this.viewportWidth = m.contentRect.width, this.viewportHeight = m.contentRect.height, this.scheduleLoadAreaAroundViewport();
|
|
1936
1959
|
}), this.viewport = e.viewport;
|
|
1937
|
-
const
|
|
1938
|
-
}),
|
|
1939
|
-
}),
|
|
1940
|
-
}),
|
|
1941
|
-
}),
|
|
1942
|
-
}),
|
|
1943
|
-
...
|
|
1960
|
+
const d = ((v = s == null ? void 0 : s.events) == null ? void 0 : v.onResizeTransformStarted) ?? (() => {
|
|
1961
|
+
}), c = ((f = s == null ? void 0 : s.events) == null ? void 0 : f.onResizeTransformFinished) ?? (() => {
|
|
1962
|
+
}), a = ((p = s == null ? void 0 : s.events) == null ? void 0 : p.onTransformChange) ?? (() => {
|
|
1963
|
+
}), l = ((A = s == null ? void 0 : s.events) == null ? void 0 : A.onBeforeTransformChange) ?? (() => {
|
|
1964
|
+
}), g = ((b = s == null ? void 0 : s.events) == null ? void 0 : b.onTransformFinished) ?? (() => {
|
|
1965
|
+
}), y = {
|
|
1966
|
+
...s,
|
|
1944
1967
|
events: {
|
|
1945
|
-
...
|
|
1968
|
+
...s == null ? void 0 : s.events,
|
|
1946
1969
|
onResizeTransformStarted: () => {
|
|
1947
|
-
this.userTransformInProgress = !0,
|
|
1970
|
+
this.userTransformInProgress = !0, d();
|
|
1948
1971
|
},
|
|
1949
1972
|
onResizeTransformFinished: () => {
|
|
1950
|
-
this.userTransformInProgress = !1,
|
|
1973
|
+
this.userTransformInProgress = !1, c();
|
|
1951
1974
|
},
|
|
1952
1975
|
onBeforeTransformChange: () => {
|
|
1953
|
-
this.userTransformInProgress = !0,
|
|
1976
|
+
this.userTransformInProgress = !0, l();
|
|
1954
1977
|
},
|
|
1955
1978
|
onTransformChange: () => {
|
|
1956
1979
|
this.userTransformInProgress = !1;
|
|
1957
|
-
const
|
|
1958
|
-
this.viewportMatrix = this.viewport.getViewportMatrix(),
|
|
1980
|
+
const D = this.viewportMatrix;
|
|
1981
|
+
this.viewportMatrix = this.viewport.getViewportMatrix(), D.scale !== this.viewportMatrix.scale && this.scheduleEnsureViewportAreaLoaded(), a();
|
|
1959
1982
|
},
|
|
1960
1983
|
onTransformFinished: () => {
|
|
1961
|
-
this.scheduleLoadAreaAroundViewport(),
|
|
1984
|
+
this.scheduleLoadAreaAroundViewport(), g();
|
|
1962
1985
|
}
|
|
1963
1986
|
}
|
|
1964
1987
|
};
|
|
1965
|
-
|
|
1988
|
+
k.configure(
|
|
1966
1989
|
e,
|
|
1967
1990
|
this.element,
|
|
1968
|
-
|
|
1991
|
+
this.window,
|
|
1992
|
+
y
|
|
1969
1993
|
), 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);
|
|
1970
1994
|
}
|
|
1971
|
-
static configure(e, o, r, s,
|
|
1972
|
-
new
|
|
1995
|
+
static configure(e, o, r, s, h, n) {
|
|
1996
|
+
new Q(
|
|
1973
1997
|
e,
|
|
1974
1998
|
o,
|
|
1975
1999
|
r,
|
|
1976
2000
|
s,
|
|
1977
|
-
|
|
2001
|
+
h,
|
|
2002
|
+
n
|
|
1978
2003
|
);
|
|
1979
2004
|
}
|
|
1980
2005
|
scheduleLoadAreaAroundViewport() {
|
|
@@ -1983,37 +2008,37 @@ class K {
|
|
|
1983
2008
|
});
|
|
1984
2009
|
}
|
|
1985
2010
|
scheduleEnsureViewportAreaLoaded() {
|
|
1986
|
-
const e = this.viewportWidth * this.viewportMatrix.scale, o = this.viewportHeight * this.viewportMatrix.scale, r = this.viewportMatrix.x - this.nodeHorizontal, s = this.viewportMatrix.y - this.nodeVertical,
|
|
1987
|
-
this.loadedArea.xFrom < r && this.loadedArea.xTo >
|
|
2011
|
+
const e = this.viewportWidth * this.viewportMatrix.scale, o = this.viewportHeight * this.viewportMatrix.scale, r = this.viewportMatrix.x - this.nodeHorizontal, s = this.viewportMatrix.y - this.nodeVertical, h = this.viewportMatrix.x + e + this.nodeHorizontal, n = this.viewportMatrix.y + o + this.nodeVertical;
|
|
2012
|
+
this.loadedArea.xFrom < r && this.loadedArea.xTo > h && this.loadedArea.yFrom < s && this.loadedArea.yTo > n || this.scheduleLoadAreaAroundViewport();
|
|
1988
2013
|
}
|
|
1989
2014
|
loadAreaAroundViewport() {
|
|
1990
|
-
const e = this.viewportWidth * this.viewportMatrix.scale, o = this.viewportHeight * this.viewportMatrix.scale, r = this.viewportMatrix.x - e - this.nodeHorizontal, s = this.viewportMatrix.y - o - this.nodeVertical,
|
|
1991
|
-
this.trigger.emit({ x: r, y: s, width:
|
|
2015
|
+
const e = this.viewportWidth * this.viewportMatrix.scale, o = this.viewportHeight * this.viewportMatrix.scale, r = this.viewportMatrix.x - e - this.nodeHorizontal, s = this.viewportMatrix.y - o - this.nodeVertical, h = 3 * e + 2 * this.nodeHorizontal, n = 3 * o + 2 * this.nodeVertical;
|
|
2016
|
+
this.trigger.emit({ x: r, y: s, width: h, height: n });
|
|
1992
2017
|
}
|
|
1993
2018
|
}
|
|
1994
|
-
const
|
|
2019
|
+
const He = () => {
|
|
1995
2020
|
const t = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
1996
2021
|
return t.style.position = "absolute", t.style.inset = "0", t;
|
|
1997
|
-
},
|
|
2022
|
+
}, je = () => {
|
|
1998
2023
|
const t = document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
|
1999
2024
|
return t.setAttribute("fill", "url(#pattern)"), t;
|
|
2000
|
-
},
|
|
2025
|
+
}, Ge = () => {
|
|
2001
2026
|
const t = document.createElementNS(
|
|
2002
2027
|
"http://www.w3.org/2000/svg",
|
|
2003
2028
|
"pattern"
|
|
2004
2029
|
);
|
|
2005
2030
|
return t.setAttribute("id", "pattern"), t;
|
|
2006
|
-
},
|
|
2031
|
+
}, Je = (t, e) => {
|
|
2007
2032
|
const o = document.createElementNS(
|
|
2008
2033
|
"http://www.w3.org/2000/svg",
|
|
2009
2034
|
"circle"
|
|
2010
2035
|
);
|
|
2011
2036
|
return o.setAttribute("cx", "0"), o.setAttribute("cy", "0"), o.setAttribute("r", `${t}`), o.setAttribute("fill", `${e}`), o;
|
|
2012
|
-
},
|
|
2037
|
+
}, Ke = (t) => t instanceof SVGElement ? t : Je(
|
|
2013
2038
|
(t == null ? void 0 : t.radius) ?? 1.5,
|
|
2014
2039
|
(t == null ? void 0 : t.color) ?? "#d8d8d8"
|
|
2015
|
-
),
|
|
2016
|
-
const e = t.tileDimensions, o = (e == null ? void 0 : e.width) ?? 25, r = (e == null ? void 0 : e.height) ?? 25, s =
|
|
2040
|
+
), Qe = (t) => {
|
|
2041
|
+
const e = t.tileDimensions, o = (e == null ? void 0 : e.width) ?? 25, r = (e == null ? void 0 : e.height) ?? 25, s = Ke(t.renderer ?? {});
|
|
2017
2042
|
return {
|
|
2018
2043
|
tileWidth: o,
|
|
2019
2044
|
tileHeight: r,
|
|
@@ -2021,11 +2046,11 @@ const Ye = () => {
|
|
|
2021
2046
|
maxViewportScale: t.maxViewportScale ?? 10
|
|
2022
2047
|
};
|
|
2023
2048
|
};
|
|
2024
|
-
class
|
|
2049
|
+
class Z {
|
|
2025
2050
|
constructor(e, o, r) {
|
|
2026
|
-
i(this, "svg",
|
|
2027
|
-
i(this, "patternRenderingRectangle",
|
|
2028
|
-
i(this, "pattern",
|
|
2051
|
+
i(this, "svg", He());
|
|
2052
|
+
i(this, "patternRenderingRectangle", je());
|
|
2053
|
+
i(this, "pattern", Ge());
|
|
2029
2054
|
i(this, "patternContent");
|
|
2030
2055
|
i(this, "tileWidth");
|
|
2031
2056
|
i(this, "tileHeight");
|
|
@@ -2036,8 +2061,8 @@ class Q {
|
|
|
2036
2061
|
i(this, "resizeObserver", new ResizeObserver((e) => {
|
|
2037
2062
|
const o = e[0], { width: r, height: s } = o.contentRect;
|
|
2038
2063
|
this.svg.setAttribute("width", `${r}`), this.svg.setAttribute("height", `${s}`), this.patternRenderingRectangle.setAttribute("width", `${r}`), this.patternRenderingRectangle.setAttribute("height", `${s}`);
|
|
2039
|
-
const
|
|
2040
|
-
this.pattern.setAttribute("width", `${
|
|
2064
|
+
const h = this.tileWidth / r, n = this.tileHeight / s;
|
|
2065
|
+
this.pattern.setAttribute("width", `${h}`), this.pattern.setAttribute("height", `${n}`);
|
|
2041
2066
|
}));
|
|
2042
2067
|
i(this, "onAfterTransformUpdated", () => {
|
|
2043
2068
|
const e = this.canvas.viewport.getContentMatrix(), o = e.x - this.halfTileWidth * e.scale, r = e.y - this.halfTileHeight * e.scale, s = `matrix(${e.scale}, 0, 0, ${e.scale}, ${o}, ${r})`;
|
|
@@ -2049,52 +2074,263 @@ class Q {
|
|
|
2049
2074
|
), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy);
|
|
2050
2075
|
});
|
|
2051
2076
|
this.canvas = e, this.host = r;
|
|
2052
|
-
const s =
|
|
2077
|
+
const s = Qe(o);
|
|
2053
2078
|
this.tileWidth = s.tileWidth, this.tileHeight = s.tileHeight, this.halfTileWidth = this.tileWidth / 2, this.halfTileHeight = this.tileHeight / 2, this.patternContent = s.renderer, this.maxViewportScale = s.maxViewportScale;
|
|
2054
|
-
const
|
|
2055
|
-
this.patternContent.setAttribute("transform",
|
|
2079
|
+
const h = `translate(${this.halfTileWidth}, ${this.halfTileHeight})`;
|
|
2080
|
+
this.patternContent.setAttribute("transform", h), this.pattern.appendChild(this.patternContent);
|
|
2056
2081
|
const n = document.createElementNS("http://www.w3.org/2000/svg", "defs");
|
|
2057
2082
|
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);
|
|
2058
2083
|
}
|
|
2059
2084
|
static configure(e, o, r) {
|
|
2060
|
-
new
|
|
2085
|
+
new Z(e, o, r);
|
|
2061
2086
|
}
|
|
2062
2087
|
updateVisibility() {
|
|
2063
2088
|
const o = this.canvas.viewport.getViewportMatrix().scale > this.maxViewportScale;
|
|
2064
2089
|
o && this.visible ? (this.visible = !1, this.host.removeChild(this.svg)) : !o && !this.visible && (this.visible = !0, this.host.appendChild(this.svg));
|
|
2065
2090
|
}
|
|
2066
2091
|
}
|
|
2067
|
-
const
|
|
2092
|
+
const Ze = () => "direct", _e = (t) => t, qe = (t) => t.button === 0, Oe = () => {
|
|
2093
|
+
}, et = (t) => {
|
|
2094
|
+
var e;
|
|
2095
|
+
return {
|
|
2096
|
+
connectionTypeResolver: t.connectionTypeResolver ?? Ze,
|
|
2097
|
+
connectionPreprocessor: t.connectionPreprocessor ?? _e,
|
|
2098
|
+
mouseDownEventVerifier: t.mouseDownEventVerifier ?? qe,
|
|
2099
|
+
onAfterEdgeCreated: ((e = t.events) == null ? void 0 : e.onAfterEdgeCreated) ?? Oe
|
|
2100
|
+
};
|
|
2101
|
+
};
|
|
2102
|
+
class _ {
|
|
2103
|
+
constructor(e, o, r, s, h, n) {
|
|
2104
|
+
i(this, "options");
|
|
2105
|
+
i(this, "overlayCanvas");
|
|
2106
|
+
i(this, "ports", /* @__PURE__ */ new Map());
|
|
2107
|
+
i(this, "staticOverlayPortId", "static");
|
|
2108
|
+
i(this, "draggingOverlayPortId", "dragging");
|
|
2109
|
+
i(this, "staticPortId", null);
|
|
2110
|
+
i(this, "isDirect", !0);
|
|
2111
|
+
i(this, "onAfterPortMarked", (e) => {
|
|
2112
|
+
const o = this.canvas.graph.getPort(e);
|
|
2113
|
+
this.hookPortEvents(o.element), this.ports.set(o.element, e);
|
|
2114
|
+
});
|
|
2115
|
+
i(this, "onBeforePortUnmarked", (e) => {
|
|
2116
|
+
const o = this.canvas.graph.getPort(e);
|
|
2117
|
+
this.unhookPortEvents(o.element), this.ports.delete(o.element);
|
|
2118
|
+
});
|
|
2119
|
+
i(this, "onPortMouseDown", (e) => {
|
|
2120
|
+
const o = e.currentTarget;
|
|
2121
|
+
this.options.mouseDownEventVerifier(e) && this.isPortConnectionAllowed(o) && (e.stopPropagation(), this.grabPort(o, { x: e.clientX, y: e.clientY }), this.window.addEventListener("mousemove", this.onWindowMouseMove), this.window.addEventListener("mouseup", this.onWindowMouseUp));
|
|
2122
|
+
});
|
|
2123
|
+
i(this, "onWindowMouseMove", (e) => {
|
|
2124
|
+
if (!V(
|
|
2125
|
+
this.window,
|
|
2126
|
+
this.overlayLayer,
|
|
2127
|
+
e.clientX,
|
|
2128
|
+
e.clientY
|
|
2129
|
+
)) {
|
|
2130
|
+
this.stopMouseDrag();
|
|
2131
|
+
return;
|
|
2132
|
+
}
|
|
2133
|
+
this.moveDraggingNode({ x: e.clientX, y: e.clientY });
|
|
2134
|
+
});
|
|
2135
|
+
i(this, "onWindowMouseUp", (e) => {
|
|
2136
|
+
this.tryCreateConnection({ x: e.clientX, y: e.clientY }), this.stopMouseDrag();
|
|
2137
|
+
});
|
|
2138
|
+
i(this, "onPortTouchStart", (e) => {
|
|
2139
|
+
const o = e.currentTarget;
|
|
2140
|
+
if (!(e.touches.length === 1 && this.isPortConnectionAllowed(o)))
|
|
2141
|
+
return;
|
|
2142
|
+
e.stopPropagation();
|
|
2143
|
+
const s = e.touches[0];
|
|
2144
|
+
this.grabPort(o, { x: s.clientX, y: s.clientY }), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish);
|
|
2145
|
+
});
|
|
2146
|
+
i(this, "onWindowTouchMove", (e) => {
|
|
2147
|
+
const o = e.touches[0];
|
|
2148
|
+
if (!V(
|
|
2149
|
+
this.window,
|
|
2150
|
+
this.overlayLayer,
|
|
2151
|
+
o.clientX,
|
|
2152
|
+
o.clientY
|
|
2153
|
+
)) {
|
|
2154
|
+
this.stopTouchDrag();
|
|
2155
|
+
return;
|
|
2156
|
+
}
|
|
2157
|
+
this.moveDraggingNode({ x: o.clientX, y: o.clientY });
|
|
2158
|
+
});
|
|
2159
|
+
i(this, "onWindowTouchFinish", (e) => {
|
|
2160
|
+
const o = e.changedTouches[0];
|
|
2161
|
+
this.tryCreateConnection({ x: o.clientX, y: o.clientY }), this.stopTouchDrag();
|
|
2162
|
+
});
|
|
2163
|
+
i(this, "onBeforeClear", () => {
|
|
2164
|
+
this.ports.forEach((e, o) => {
|
|
2165
|
+
this.unhookPortEvents(o);
|
|
2166
|
+
}), this.ports.clear();
|
|
2167
|
+
});
|
|
2168
|
+
i(this, "onBeforeDestroy", () => {
|
|
2169
|
+
this.stopMouseDrag(), this.stopTouchDrag(), this.canvas.graph.onAfterPortMarked.unsubscribe(this.onAfterPortMarked), this.canvas.graph.onBeforePortUnmarked.unsubscribe(
|
|
2170
|
+
this.onBeforePortUnmarked
|
|
2171
|
+
), this.canvas.graph.onBeforeClear.unsubscribe(this.onBeforeClear), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy);
|
|
2172
|
+
});
|
|
2173
|
+
i(this, "onEdgeCreated", (e) => {
|
|
2174
|
+
this.options.onAfterEdgeCreated(e);
|
|
2175
|
+
});
|
|
2176
|
+
this.canvas = e, this.overlayLayer = o, this.viewportStore = r, this.window = s, this.options = et(n);
|
|
2177
|
+
const d = new ce(), c = new ne(
|
|
2178
|
+
d,
|
|
2179
|
+
this.viewportStore,
|
|
2180
|
+
this.overlayLayer
|
|
2181
|
+
);
|
|
2182
|
+
this.overlayCanvas = new de(
|
|
2183
|
+
this.overlayLayer,
|
|
2184
|
+
d,
|
|
2185
|
+
this.viewportStore,
|
|
2186
|
+
c,
|
|
2187
|
+
h
|
|
2188
|
+
), 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);
|
|
2189
|
+
}
|
|
2190
|
+
static configure(e, o, r, s, h, n) {
|
|
2191
|
+
new _(
|
|
2192
|
+
e,
|
|
2193
|
+
o,
|
|
2194
|
+
r,
|
|
2195
|
+
s,
|
|
2196
|
+
h,
|
|
2197
|
+
n
|
|
2198
|
+
);
|
|
2199
|
+
}
|
|
2200
|
+
grabPort(e, o) {
|
|
2201
|
+
const r = this.ports.get(e), s = this.canvas.graph.getPort(r);
|
|
2202
|
+
this.staticPortId = r;
|
|
2203
|
+
const h = this.options.connectionTypeResolver(this.staticPortId), n = e.getBoundingClientRect(), d = n.x + n.width / 2, c = n.y + n.height / 2, a = this.overlayLayer.getBoundingClientRect(), l = this.canvas.viewport.getViewportMatrix(), g = C(l, {
|
|
2204
|
+
x: d - a.x,
|
|
2205
|
+
y: c - a.y
|
|
2206
|
+
}), y = C(l, {
|
|
2207
|
+
x: o.x - a.x,
|
|
2208
|
+
y: o.y - a.y
|
|
2209
|
+
}), v = {
|
|
2210
|
+
overlayId: this.staticOverlayPortId,
|
|
2211
|
+
portCoords: g,
|
|
2212
|
+
portDirection: s.direction
|
|
2213
|
+
}, f = {
|
|
2214
|
+
overlayId: this.draggingOverlayPortId,
|
|
2215
|
+
portCoords: y,
|
|
2216
|
+
portDirection: void 0
|
|
2217
|
+
};
|
|
2218
|
+
this.isDirect = h === "direct";
|
|
2219
|
+
const p = this.isDirect ? v : f, A = this.isDirect ? f : v;
|
|
2220
|
+
this.createOverlayGraph(p, A);
|
|
2221
|
+
}
|
|
2222
|
+
hookPortEvents(e) {
|
|
2223
|
+
e.addEventListener("mousedown", this.onPortMouseDown), e.addEventListener("touchstart", this.onPortTouchStart);
|
|
2224
|
+
}
|
|
2225
|
+
unhookPortEvents(e) {
|
|
2226
|
+
e.removeEventListener("mousedown", this.onPortMouseDown), e.removeEventListener("touchstart", this.onPortTouchStart);
|
|
2227
|
+
}
|
|
2228
|
+
stopMouseDrag() {
|
|
2229
|
+
this.resetDragState(), this.window.removeEventListener("mouseup", this.onWindowMouseUp), this.window.removeEventListener("mousemove", this.onWindowMouseMove);
|
|
2230
|
+
}
|
|
2231
|
+
stopTouchDrag() {
|
|
2232
|
+
this.resetDragState(), this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
|
|
2233
|
+
}
|
|
2234
|
+
resetDragState() {
|
|
2235
|
+
this.staticPortId = null, this.isDirect = !0, this.overlayCanvas.clear();
|
|
2236
|
+
}
|
|
2237
|
+
createOverlayGraph(e, o) {
|
|
2238
|
+
const r = this.createAddNodeRequest(e);
|
|
2239
|
+
this.overlayCanvas.addNode(r);
|
|
2240
|
+
const s = this.createAddNodeRequest(o);
|
|
2241
|
+
this.overlayCanvas.addNode(s), this.overlayCanvas.addEdge({
|
|
2242
|
+
from: e.overlayId,
|
|
2243
|
+
to: o.overlayId
|
|
2244
|
+
});
|
|
2245
|
+
}
|
|
2246
|
+
createAddNodeRequest(e) {
|
|
2247
|
+
const o = document.createElement("div");
|
|
2248
|
+
return {
|
|
2249
|
+
id: e.overlayId,
|
|
2250
|
+
element: o,
|
|
2251
|
+
x: e.portCoords.x,
|
|
2252
|
+
y: e.portCoords.y,
|
|
2253
|
+
ports: [
|
|
2254
|
+
{
|
|
2255
|
+
id: e.overlayId,
|
|
2256
|
+
element: o,
|
|
2257
|
+
direction: e.portDirection
|
|
2258
|
+
}
|
|
2259
|
+
]
|
|
2260
|
+
};
|
|
2261
|
+
}
|
|
2262
|
+
tryCreateConnection(e) {
|
|
2263
|
+
const o = this.findPortAtPoint(e);
|
|
2264
|
+
if (o === null)
|
|
2265
|
+
return;
|
|
2266
|
+
const r = this.isDirect ? this.staticPortId : o, s = this.isDirect ? o : this.staticPortId, h = { from: r, to: s }, n = this.options.connectionPreprocessor(h);
|
|
2267
|
+
n !== null && (this.canvas.graph.onAfterEdgeAdded.subscribe(this.onEdgeCreated), this.canvas.addEdge(n), this.canvas.graph.onAfterEdgeAdded.unsubscribe(this.onEdgeCreated));
|
|
2268
|
+
}
|
|
2269
|
+
moveDraggingNode(e) {
|
|
2270
|
+
const o = this.overlayLayer.getBoundingClientRect(), r = {
|
|
2271
|
+
x: e.x - o.x,
|
|
2272
|
+
y: e.y - o.y
|
|
2273
|
+
}, s = this.canvas.viewport.getViewportMatrix(), h = C(s, r);
|
|
2274
|
+
this.overlayCanvas.updateNode(this.draggingOverlayPortId, {
|
|
2275
|
+
x: h.x,
|
|
2276
|
+
y: h.y
|
|
2277
|
+
});
|
|
2278
|
+
}
|
|
2279
|
+
findPortAtPoint(e) {
|
|
2280
|
+
const o = document.elementsFromPoint(e.x, e.y);
|
|
2281
|
+
for (const r of o) {
|
|
2282
|
+
const s = this.findPortAtElement(r);
|
|
2283
|
+
if (s !== null)
|
|
2284
|
+
return s;
|
|
2285
|
+
}
|
|
2286
|
+
return null;
|
|
2287
|
+
}
|
|
2288
|
+
findPortAtElement(e) {
|
|
2289
|
+
let o = e, r = null;
|
|
2290
|
+
for (; o !== null && (r = this.ports.get(o) ?? null, r === null); )
|
|
2291
|
+
o = o.parentElement;
|
|
2292
|
+
return r;
|
|
2293
|
+
}
|
|
2294
|
+
isPortConnectionAllowed(e) {
|
|
2295
|
+
const o = this.ports.get(e);
|
|
2296
|
+
return this.options.connectionTypeResolver(o) !== null;
|
|
2297
|
+
}
|
|
2298
|
+
}
|
|
2299
|
+
const tt = () => {
|
|
2068
2300
|
const t = document.createElement("div");
|
|
2069
2301
|
return t.style.width = "100%", t.style.height = "100%", t.style.position = "relative", t;
|
|
2070
|
-
},
|
|
2302
|
+
}, X = () => {
|
|
2071
2303
|
const t = document.createElement("div");
|
|
2072
2304
|
return t.style.position = "absolute", t.style.inset = "0", t;
|
|
2073
2305
|
};
|
|
2074
|
-
class
|
|
2306
|
+
class ot {
|
|
2075
2307
|
constructor(e) {
|
|
2076
|
-
i(this, "background",
|
|
2077
|
-
i(this, "main",
|
|
2078
|
-
i(this, "
|
|
2079
|
-
|
|
2308
|
+
i(this, "background", X());
|
|
2309
|
+
i(this, "main", X());
|
|
2310
|
+
i(this, "overlay", X());
|
|
2311
|
+
i(this, "host", tt());
|
|
2312
|
+
this.element = e, this.element.appendChild(this.host), this.host.appendChild(this.background), this.host.appendChild(this.main), this.overlay.style.pointerEvents = "none", this.host.appendChild(this.overlay);
|
|
2080
2313
|
}
|
|
2081
2314
|
destroy() {
|
|
2082
|
-
this.host.removeChild(this.main), this.host.removeChild(this.
|
|
2315
|
+
this.host.removeChild(this.background), this.host.removeChild(this.main), this.host.removeChild(this.overlay), this.element.removeChild(this.host);
|
|
2083
2316
|
}
|
|
2084
2317
|
}
|
|
2085
|
-
class
|
|
2318
|
+
class it {
|
|
2086
2319
|
constructor() {
|
|
2087
2320
|
i(this, "element", null);
|
|
2088
2321
|
i(this, "canvasDefaults", {});
|
|
2089
2322
|
i(this, "dragOptions", {});
|
|
2090
2323
|
i(this, "transformOptions", {});
|
|
2091
2324
|
i(this, "backgroundOptions", {});
|
|
2325
|
+
i(this, "connectablePortsOptions", {});
|
|
2092
2326
|
i(this, "virtualScrollOptions");
|
|
2093
2327
|
i(this, "hasDraggableNode", !1);
|
|
2094
2328
|
i(this, "hasTransformableViewport", !1);
|
|
2095
2329
|
i(this, "hasResizeReactiveNodes", !1);
|
|
2096
2330
|
i(this, "hasBackground", !1);
|
|
2331
|
+
i(this, "hasUserConnectablePorts", !1);
|
|
2097
2332
|
i(this, "boxRenderingTrigger");
|
|
2333
|
+
i(this, "window", window);
|
|
2098
2334
|
}
|
|
2099
2335
|
setElement(e) {
|
|
2100
2336
|
return this.element = e, this;
|
|
@@ -2129,55 +2365,78 @@ class Ze {
|
|
|
2129
2365
|
enableBoxAreaRendering(e) {
|
|
2130
2366
|
return this.boxRenderingTrigger = e, this;
|
|
2131
2367
|
}
|
|
2368
|
+
/**
|
|
2369
|
+
* enables built-in virtual scroll behavior, when only nodes and edges close
|
|
2370
|
+
* to viewport are rendered
|
|
2371
|
+
*/
|
|
2132
2372
|
enableVirtualScroll(e) {
|
|
2133
2373
|
return this.virtualScrollOptions = e, this;
|
|
2134
2374
|
}
|
|
2375
|
+
/**
|
|
2376
|
+
* enables built-in background rendering
|
|
2377
|
+
*/
|
|
2135
2378
|
enableBackground(e) {
|
|
2136
2379
|
return this.hasBackground = !0, this.backgroundOptions = e ?? {}, this;
|
|
2137
2380
|
}
|
|
2381
|
+
/**
|
|
2382
|
+
* enables edge creation by dragging one port to another
|
|
2383
|
+
*/
|
|
2384
|
+
enableUserConnectablePorts(e) {
|
|
2385
|
+
return this.connectablePortsOptions = e ?? {}, this.hasUserConnectablePorts = !0, this;
|
|
2386
|
+
}
|
|
2138
2387
|
/**
|
|
2139
2388
|
* builds final canvas
|
|
2140
2389
|
*/
|
|
2141
2390
|
build() {
|
|
2142
2391
|
if (this.element === null)
|
|
2143
|
-
throw new
|
|
2392
|
+
throw new S(
|
|
2144
2393
|
"unable to build canvas when no attach element specified"
|
|
2145
2394
|
);
|
|
2146
2395
|
let e = this.boxRenderingTrigger;
|
|
2147
|
-
this.virtualScrollOptions !== void 0 && e === void 0 && (e = new
|
|
2148
|
-
const o = new
|
|
2149
|
-
let
|
|
2396
|
+
this.virtualScrollOptions !== void 0 && e === void 0 && (e = new he());
|
|
2397
|
+
const o = new ce(), r = new Ie(), s = new ot(this.element);
|
|
2398
|
+
let h = new ne(
|
|
2150
2399
|
o,
|
|
2151
2400
|
r,
|
|
2152
2401
|
s.main
|
|
2153
2402
|
);
|
|
2154
|
-
e !== void 0 && (
|
|
2155
|
-
const n = new
|
|
2403
|
+
e !== void 0 && (h = new ye(h, o, e));
|
|
2404
|
+
const n = new de(
|
|
2156
2405
|
this.element,
|
|
2157
2406
|
o,
|
|
2158
2407
|
r,
|
|
2159
|
-
|
|
2408
|
+
h,
|
|
2160
2409
|
this.canvasDefaults
|
|
2161
|
-
),
|
|
2162
|
-
s.destroy(), n.onBeforeDestroy.unsubscribe(
|
|
2410
|
+
), d = () => {
|
|
2411
|
+
s.destroy(), n.onBeforeDestroy.unsubscribe(d);
|
|
2163
2412
|
};
|
|
2164
|
-
return n.onBeforeDestroy.subscribe(
|
|
2413
|
+
return n.onBeforeDestroy.subscribe(d), this.hasBackground && Z.configure(
|
|
2165
2414
|
n,
|
|
2166
2415
|
this.backgroundOptions,
|
|
2167
2416
|
s.background
|
|
2168
|
-
), this.hasResizeReactiveNodes &&
|
|
2417
|
+
), this.hasResizeReactiveNodes && J.configure(n), this.hasDraggableNode && K.configure(
|
|
2169
2418
|
n,
|
|
2170
2419
|
s.main,
|
|
2420
|
+
this.window,
|
|
2171
2421
|
this.dragOptions
|
|
2172
|
-
), this.
|
|
2422
|
+
), this.hasUserConnectablePorts && _.configure(
|
|
2423
|
+
n,
|
|
2424
|
+
s.overlay,
|
|
2425
|
+
r,
|
|
2426
|
+
this.window,
|
|
2427
|
+
this.canvasDefaults,
|
|
2428
|
+
this.connectablePortsOptions
|
|
2429
|
+
), this.virtualScrollOptions !== void 0 ? Q.configure(
|
|
2173
2430
|
n,
|
|
2174
2431
|
s.main,
|
|
2432
|
+
this.window,
|
|
2175
2433
|
this.transformOptions,
|
|
2176
2434
|
e,
|
|
2177
2435
|
this.virtualScrollOptions
|
|
2178
|
-
) : this.hasTransformableViewport &&
|
|
2436
|
+
) : this.hasTransformableViewport && k.configure(
|
|
2179
2437
|
n,
|
|
2180
2438
|
s.main,
|
|
2439
|
+
this.window,
|
|
2181
2440
|
this.transformOptions
|
|
2182
2441
|
), this.reset(), n;
|
|
2183
2442
|
}
|
|
@@ -2186,15 +2445,15 @@ class Ze {
|
|
|
2186
2445
|
* CanvasBuilder should be single use object
|
|
2187
2446
|
*/
|
|
2188
2447
|
reset() {
|
|
2189
|
-
this.element = null, this.canvasDefaults = {}, this.dragOptions = {}, this.transformOptions = {}, this.backgroundOptions = {}, this.virtualScrollOptions = void 0, this.hasDraggableNode = !1, this.hasTransformableViewport = !1, this.hasResizeReactiveNodes = !1, this.hasBackground = !1, this.boxRenderingTrigger = void 0;
|
|
2448
|
+
this.element = null, this.canvasDefaults = {}, this.dragOptions = {}, this.transformOptions = {}, this.backgroundOptions = {}, this.virtualScrollOptions = void 0, this.hasDraggableNode = !1, this.hasTransformableViewport = !1, this.hasResizeReactiveNodes = !1, this.hasBackground = !1, this.boxRenderingTrigger = void 0, this.hasUserConnectablePorts = !1;
|
|
2190
2449
|
}
|
|
2191
2450
|
}
|
|
2192
2451
|
export {
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2452
|
+
De as BezierEdgeShape,
|
|
2453
|
+
it as CanvasBuilder,
|
|
2454
|
+
he as EventSubject,
|
|
2455
|
+
Me as HorizontalEdgeShape,
|
|
2456
|
+
S as HtmlGraphError,
|
|
2457
|
+
Ce as StraightEdgeShape,
|
|
2199
2458
|
Ve as VerticalEdgeShape
|
|
2200
2459
|
};
|