@html-graph/html-graph 3.1.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/README.md +1 -0
- package/dist/html-graph.d.ts +116 -25
- package/dist/html-graph.js +863 -469
- 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
|
|
5
|
-
const t = document.createElement("div");
|
|
6
|
-
return t.style.width = "100%", t.style.height = "100%", t.style.position = "relative", t.style.overflow = "hidden", t;
|
|
7
|
-
}, he = () => {
|
|
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 = () => {
|
|
8
5
|
const t = document.createElement("div");
|
|
9
6
|
return t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.width = "0", t.style.height = "0", t;
|
|
10
|
-
},
|
|
7
|
+
}, ue = () => {
|
|
11
8
|
const t = document.createElement("div");
|
|
12
9
|
return t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.visibility = "hidden", t;
|
|
10
|
+
}, we = () => {
|
|
11
|
+
const t = document.createElement("div");
|
|
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 ce {
|
|
|
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 ce {
|
|
|
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 ce {
|
|
|
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 ae {
|
|
|
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 le {
|
|
|
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 le {
|
|
|
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 re {
|
|
|
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 ue {
|
|
|
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;
|
|
@@ -326,219 +323,237 @@ class S extends Error {
|
|
|
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
|
-
}),
|
|
329
|
+
}), H = (t) => () => t, oe = H(0), pe = () => {
|
|
333
330
|
let t = 0;
|
|
334
331
|
return () => t++;
|
|
335
|
-
},
|
|
336
|
-
let o =
|
|
337
|
-
const s =
|
|
338
|
-
return t === "incremental" && (o = s), e === "incremental" && (r = s), typeof t == "number" && (o =
|
|
332
|
+
}, Ee = (t, e) => {
|
|
333
|
+
let o = oe, r = oe;
|
|
334
|
+
const s = pe();
|
|
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
|
|
341
338
|
};
|
|
342
339
|
}, x = (t, e, o) => ({
|
|
343
340
|
x: e.x * t.x - e.y * t.y + ((1 - e.x) * o.x + e.y * o.y),
|
|
344
341
|
y: e.y * t.x + e.x * t.y + ((1 - e.x) * o.y - e.y * o.x)
|
|
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
345
|
}, N = (t, e, o, r) => {
|
|
349
|
-
const
|
|
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 = () => {
|
|
378
375
|
const t = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
|
379
376
|
return t.style.transformOrigin = "50% 50%", t;
|
|
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) => {
|
|
387
384
|
const o = {
|
|
388
385
|
x: t.x + t.width / 2,
|
|
389
386
|
y: t.y + t.height / 2
|
|
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
|
-
t.
|
|
402
|
+
t.fromVector,
|
|
406
403
|
w
|
|
407
404
|
), o = x(
|
|
408
405
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
409
|
-
t.
|
|
406
|
+
t.toVector,
|
|
410
407
|
t.to
|
|
411
408
|
), r = {
|
|
412
|
-
x: e.x + t.
|
|
413
|
-
y: e.y + t.
|
|
409
|
+
x: e.x + t.fromVector.x * t.curvature,
|
|
410
|
+
y: e.y + t.fromVector.y * t.curvature
|
|
414
411
|
}, s = {
|
|
415
|
-
x: o.x - t.
|
|
416
|
-
y: o.y - t.
|
|
417
|
-
},
|
|
418
|
-
return `${n}${
|
|
419
|
-
},
|
|
412
|
+
x: o.x - t.toVector.x * t.curvature,
|
|
413
|
+
y: o.y - t.toVector.y * t.curvature
|
|
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
|
-
t.
|
|
419
|
+
t.fromVector,
|
|
423
420
|
w
|
|
424
421
|
) : w, o = t.hasTargetArrow ? x(
|
|
425
422
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
426
|
-
t.
|
|
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
|
-
t.
|
|
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
|
-
t.
|
|
434
|
+
t.toVector,
|
|
438
435
|
t.to
|
|
439
436
|
), g = {
|
|
440
437
|
x: l.x + n,
|
|
441
|
-
y: l.y +
|
|
442
|
-
},
|
|
443
|
-
x: c.x + t.curvature * t.
|
|
444
|
-
y: c.y + t.curvature * t.
|
|
445
|
-
},
|
|
446
|
-
x: l.x - t.curvature * t.
|
|
447
|
-
y: l.y - t.curvature * t.
|
|
438
|
+
y: l.y + d
|
|
439
|
+
}, y = { x: (a.x + g.x) / 2, y: (a.y + g.y) / 2 }, v = {
|
|
440
|
+
x: c.x + t.curvature * t.fromVector.x,
|
|
441
|
+
y: c.y + t.curvature * t.fromVector.y
|
|
442
|
+
}, f = {
|
|
443
|
+
x: l.x - t.curvature * t.toVector.x,
|
|
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
|
-
t.
|
|
462
|
+
t.fromVector,
|
|
466
463
|
w
|
|
467
464
|
) : w, o = t.hasTargetArrow ? x(
|
|
468
465
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
469
|
-
t.
|
|
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(
|
|
469
|
+
{ x: s, y: w.y },
|
|
470
|
+
t.fromVector,
|
|
471
|
+
w
|
|
472
|
+
), n = x(
|
|
472
473
|
{ x: t.to.x - s, y: t.to.y },
|
|
473
|
-
t.
|
|
474
|
+
t.toVector,
|
|
474
475
|
t.to
|
|
475
|
-
),
|
|
476
|
-
x: t.flipX > 0 ?
|
|
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
|
|
479
|
+
}, l = { x: a.x, y: c }, g = {
|
|
480
|
+
x: t.flipX > 0 ? t.to.x - d : t.to.x + r,
|
|
477
481
|
y: n.y
|
|
478
|
-
},
|
|
479
|
-
return
|
|
480
|
-
[e,
|
|
482
|
+
}, y = { x: g.x, y: c };
|
|
483
|
+
return I(
|
|
484
|
+
[e, h, a, l, y, g, n, o],
|
|
481
485
|
t.roundness
|
|
482
486
|
);
|
|
483
|
-
},
|
|
487
|
+
}, j = (t) => {
|
|
484
488
|
const e = t.hasSourceArrow ? x(
|
|
485
489
|
{ x: t.arrowLength, y: w.y },
|
|
486
|
-
t.
|
|
490
|
+
t.fromVector,
|
|
487
491
|
w
|
|
488
492
|
) : w, o = t.hasTargetArrow ? x(
|
|
489
493
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
490
|
-
t.
|
|
494
|
+
t.toVector,
|
|
491
495
|
t.to
|
|
492
496
|
) : t.to, r = t.arrowLength + t.arrowOffset, s = x(
|
|
493
497
|
{ x: r, y: w.y },
|
|
494
|
-
t.
|
|
498
|
+
t.fromVector,
|
|
495
499
|
w
|
|
496
|
-
),
|
|
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(
|
|
497
501
|
{ x: t.to.x - r, y: t.to.y },
|
|
498
|
-
t.
|
|
502
|
+
t.toVector,
|
|
499
503
|
t.to
|
|
500
|
-
), g = { x: l.x +
|
|
501
|
-
return
|
|
504
|
+
), g = { x: l.x + d, y: l.y + c };
|
|
505
|
+
return I(
|
|
502
506
|
[e, s, a, g, l, o],
|
|
503
507
|
t.roundness
|
|
504
508
|
);
|
|
505
|
-
},
|
|
509
|
+
}, Te = (t) => {
|
|
506
510
|
const e = t.hasSourceArrow ? x(
|
|
507
511
|
{ x: t.arrowLength, y: w.y },
|
|
508
|
-
t.
|
|
512
|
+
t.fromVector,
|
|
509
513
|
w
|
|
510
514
|
) : w, o = t.hasTargetArrow ? x(
|
|
511
515
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
512
|
-
t.
|
|
516
|
+
t.toVector,
|
|
513
517
|
t.to
|
|
514
|
-
) : t.to, r = t.arrowLength + t.arrowOffset, s = x(
|
|
518
|
+
) : t.to, r = t.arrowLength + t.arrowOffset, s = x(
|
|
519
|
+
{ x: r, y: w.y },
|
|
520
|
+
t.fromVector,
|
|
521
|
+
w
|
|
522
|
+
), h = x(
|
|
515
523
|
{ x: t.to.x - r, y: t.to.y },
|
|
516
|
-
t.
|
|
524
|
+
t.toVector,
|
|
517
525
|
t.to
|
|
518
526
|
);
|
|
519
|
-
return
|
|
520
|
-
},
|
|
527
|
+
return I([e, s, h, o], t.roundness);
|
|
528
|
+
}, Ne = (t) => {
|
|
521
529
|
const e = t.hasSourceArrow ? x(
|
|
522
530
|
{ x: t.arrowLength, y: w.y },
|
|
523
|
-
t.
|
|
531
|
+
t.fromVector,
|
|
524
532
|
w
|
|
525
533
|
) : w, o = t.hasTargetArrow ? x(
|
|
526
534
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
527
|
-
t.
|
|
535
|
+
t.toVector,
|
|
528
536
|
t.to
|
|
529
|
-
) : 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(
|
|
538
|
+
{ x: s, y: w.y },
|
|
539
|
+
t.fromVector,
|
|
540
|
+
w
|
|
541
|
+
), n = x(
|
|
530
542
|
{ x: t.to.x - s, y: t.to.y },
|
|
531
|
-
t.
|
|
543
|
+
t.toVector,
|
|
532
544
|
t.to
|
|
533
|
-
),
|
|
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
|
|
548
|
+
}, l = { x: c, y: a.y }, g = {
|
|
534
549
|
x: n.x,
|
|
535
|
-
y: t.flipY > 0 ? t.to.y -
|
|
536
|
-
},
|
|
537
|
-
return
|
|
538
|
-
[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],
|
|
539
554
|
t.roundness
|
|
540
555
|
);
|
|
541
|
-
},
|
|
556
|
+
}, G = (t) => {
|
|
542
557
|
const e = t.arrowOffset, o = t.side, r = t.arrowLength + e, s = r + 2 * o, n = [
|
|
543
558
|
{ x: t.arrowLength, y: w.y },
|
|
544
559
|
{ x: r, y: w.y },
|
|
@@ -549,15 +564,17 @@ const we = (t, e) => ({
|
|
|
549
564
|
{ x: r, y: w.y },
|
|
550
565
|
{ x: t.arrowLength, y: w.y }
|
|
551
566
|
].map(
|
|
552
|
-
(c) => x(c, t.
|
|
553
|
-
),
|
|
554
|
-
return `${t.hasSourceArrow || t.hasTargetArrow ? "" :
|
|
555
|
-
},
|
|
556
|
-
const e = t.smallRadius, o = t.radius, r = Math.sqrt(e * e + o * o), s = e + o,
|
|
567
|
+
(c) => x(c, t.fromVector, w)
|
|
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 = [
|
|
557
572
|
{ x: t.arrowLength, y: w.y },
|
|
558
|
-
{ x:
|
|
559
|
-
{ x:
|
|
560
|
-
].map(
|
|
573
|
+
{ x: h, y: n },
|
|
574
|
+
{ x: h, y: -n }
|
|
575
|
+
].map(
|
|
576
|
+
(g) => x(g, t.fromVector, w)
|
|
577
|
+
), a = [
|
|
561
578
|
`M ${c[0].x} ${c[0].y}`,
|
|
562
579
|
`A ${e} ${e} 0 0 1 ${c[1].x} ${c[1].y}`,
|
|
563
580
|
`A ${o} ${o} 0 1 0 ${c[2].x} ${c[2].y}`,
|
|
@@ -581,10 +598,10 @@ const we = (t, e) => ({
|
|
|
581
598
|
smallCycleRadius: 15,
|
|
582
599
|
curvature: 90
|
|
583
600
|
});
|
|
584
|
-
class
|
|
601
|
+
class De {
|
|
585
602
|
constructor(e) {
|
|
586
|
-
i(this, "svg",
|
|
587
|
-
i(this, "group",
|
|
603
|
+
i(this, "svg", $());
|
|
604
|
+
i(this, "group", W());
|
|
588
605
|
i(this, "line");
|
|
589
606
|
i(this, "sourceArrow", null);
|
|
590
607
|
i(this, "targetArrow", null);
|
|
@@ -599,74 +616,74 @@ class Te {
|
|
|
599
616
|
i(this, "hasTargetArrow");
|
|
600
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;
|
|
601
618
|
const o = (e == null ? void 0 : e.color) ?? u.color, r = (e == null ? void 0 : e.width) ?? u.width;
|
|
602
|
-
this.svg.appendChild(this.group), this.line =
|
|
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));
|
|
603
620
|
}
|
|
604
621
|
render(e) {
|
|
605
|
-
const { x: o, y: r, width: s, height:
|
|
622
|
+
const { x: o, y: r, width: s, height: h, flipX: n, flipY: d } = z(
|
|
606
623
|
e.from,
|
|
607
624
|
e.to
|
|
608
625
|
);
|
|
609
|
-
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${s}px`, this.svg.style.height = `${
|
|
610
|
-
const c =
|
|
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})`;
|
|
627
|
+
const c = T(
|
|
611
628
|
e.from.direction,
|
|
612
629
|
n,
|
|
613
|
-
|
|
614
|
-
), a =
|
|
630
|
+
d
|
|
631
|
+
), a = T(e.to.direction, n, d), l = {
|
|
615
632
|
x: s,
|
|
616
|
-
y:
|
|
633
|
+
y: h
|
|
617
634
|
};
|
|
618
|
-
let g,
|
|
619
|
-
if (e.from.portId === e.to.portId ? (g =
|
|
620
|
-
|
|
635
|
+
let g, y = a, v = -this.arrowLength;
|
|
636
|
+
if (e.from.portId === e.to.portId ? (g = Pe({
|
|
637
|
+
fromVector: c,
|
|
621
638
|
radius: this.portCycleRadius,
|
|
622
639
|
smallRadius: this.portCycleSmallRadius,
|
|
623
640
|
arrowLength: this.arrowLength,
|
|
624
641
|
hasSourceArrow: this.hasSourceArrow,
|
|
625
642
|
hasTargetArrow: this.hasTargetArrow
|
|
626
|
-
}),
|
|
643
|
+
}), y = c, v = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = be({
|
|
627
644
|
to: l,
|
|
628
|
-
|
|
629
|
-
|
|
645
|
+
fromVector: c,
|
|
646
|
+
toVector: a,
|
|
630
647
|
flipX: n,
|
|
631
|
-
flipY:
|
|
648
|
+
flipY: d,
|
|
632
649
|
arrowLength: this.arrowLength,
|
|
633
650
|
detourDirection: this.detourDirection,
|
|
634
651
|
detourDistance: this.detourDistance,
|
|
635
652
|
curvature: this.curvature,
|
|
636
653
|
hasSourceArrow: this.hasSourceArrow,
|
|
637
654
|
hasTargetArrow: this.hasTargetArrow
|
|
638
|
-
}) : g =
|
|
655
|
+
}) : g = Se({
|
|
639
656
|
to: l,
|
|
640
|
-
|
|
641
|
-
|
|
657
|
+
fromVector: c,
|
|
658
|
+
toVector: a,
|
|
642
659
|
arrowLength: this.arrowLength,
|
|
643
660
|
curvature: this.curvature,
|
|
644
661
|
hasSourceArrow: this.hasSourceArrow,
|
|
645
662
|
hasTargetArrow: this.hasTargetArrow
|
|
646
663
|
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
647
|
-
const
|
|
664
|
+
const f = N(
|
|
648
665
|
c,
|
|
649
666
|
w,
|
|
650
667
|
this.arrowLength,
|
|
651
668
|
this.arrowWidth
|
|
652
669
|
);
|
|
653
|
-
this.sourceArrow.setAttribute("d",
|
|
670
|
+
this.sourceArrow.setAttribute("d", f);
|
|
654
671
|
}
|
|
655
672
|
if (this.targetArrow) {
|
|
656
|
-
const
|
|
657
|
-
|
|
673
|
+
const f = N(
|
|
674
|
+
y,
|
|
658
675
|
l,
|
|
659
676
|
v,
|
|
660
677
|
this.arrowWidth
|
|
661
678
|
);
|
|
662
|
-
this.targetArrow.setAttribute("d",
|
|
679
|
+
this.targetArrow.setAttribute("d", f);
|
|
663
680
|
}
|
|
664
681
|
}
|
|
665
682
|
}
|
|
666
|
-
class
|
|
683
|
+
class Me {
|
|
667
684
|
constructor(e) {
|
|
668
|
-
i(this, "svg",
|
|
669
|
-
i(this, "group",
|
|
685
|
+
i(this, "svg", $());
|
|
686
|
+
i(this, "group", W());
|
|
670
687
|
i(this, "line");
|
|
671
688
|
i(this, "sourceArrow", null);
|
|
672
689
|
i(this, "targetArrow", null);
|
|
@@ -687,37 +704,37 @@ class be {
|
|
|
687
704
|
this.cycleSquareSide / 2
|
|
688
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;
|
|
689
706
|
const r = (e == null ? void 0 : e.color) ?? u.color, s = (e == null ? void 0 : e.width) ?? u.width;
|
|
690
|
-
this.svg.appendChild(this.group), this.line =
|
|
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));
|
|
691
708
|
}
|
|
692
709
|
render(e) {
|
|
693
|
-
const { x: o, y: r, width: s, height:
|
|
710
|
+
const { x: o, y: r, width: s, height: h, flipX: n, flipY: d } = z(
|
|
694
711
|
e.from,
|
|
695
712
|
e.to
|
|
696
713
|
);
|
|
697
|
-
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${s}px`, this.svg.style.height = `${
|
|
698
|
-
const c =
|
|
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})`;
|
|
715
|
+
const c = T(
|
|
699
716
|
e.from.direction,
|
|
700
717
|
n,
|
|
701
|
-
|
|
702
|
-
), a =
|
|
718
|
+
d
|
|
719
|
+
), a = T(e.to.direction, n, d), l = {
|
|
703
720
|
x: s,
|
|
704
|
-
y:
|
|
721
|
+
y: h
|
|
705
722
|
};
|
|
706
|
-
let g,
|
|
707
|
-
if (e.from.portId === e.to.portId ? (g =
|
|
708
|
-
|
|
723
|
+
let g, y = a, v = -this.arrowLength;
|
|
724
|
+
if (e.from.portId === e.to.portId ? (g = G({
|
|
725
|
+
fromVector: c,
|
|
709
726
|
arrowLength: this.arrowLength,
|
|
710
727
|
side: this.cycleSquareSide,
|
|
711
728
|
arrowOffset: this.arrowOffset,
|
|
712
729
|
roundness: this.roundness,
|
|
713
730
|
hasSourceArrow: this.hasSourceArrow,
|
|
714
731
|
hasTargetArrow: this.hasTargetArrow
|
|
715
|
-
}),
|
|
732
|
+
}), y = c, v = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = j({
|
|
716
733
|
to: l,
|
|
717
|
-
|
|
718
|
-
|
|
734
|
+
fromVector: c,
|
|
735
|
+
toVector: a,
|
|
719
736
|
flipX: n,
|
|
720
|
-
flipY:
|
|
737
|
+
flipY: d,
|
|
721
738
|
arrowLength: this.arrowLength,
|
|
722
739
|
arrowOffset: this.arrowOffset,
|
|
723
740
|
roundness: this.roundness,
|
|
@@ -725,10 +742,10 @@ class be {
|
|
|
725
742
|
detourDistance: this.detourDistance,
|
|
726
743
|
hasSourceArrow: this.hasSourceArrow,
|
|
727
744
|
hasTargetArrow: this.hasTargetArrow
|
|
728
|
-
}) : g =
|
|
745
|
+
}) : g = me({
|
|
729
746
|
to: l,
|
|
730
|
-
|
|
731
|
-
|
|
747
|
+
fromVector: c,
|
|
748
|
+
toVector: a,
|
|
732
749
|
flipX: n,
|
|
733
750
|
arrowLength: this.arrowLength,
|
|
734
751
|
arrowOffset: this.arrowOffset,
|
|
@@ -736,29 +753,29 @@ class be {
|
|
|
736
753
|
hasSourceArrow: this.hasSourceArrow,
|
|
737
754
|
hasTargetArrow: this.hasTargetArrow
|
|
738
755
|
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
739
|
-
const
|
|
756
|
+
const f = N(
|
|
740
757
|
c,
|
|
741
758
|
w,
|
|
742
759
|
this.arrowLength,
|
|
743
760
|
this.arrowWidth
|
|
744
761
|
);
|
|
745
|
-
this.sourceArrow.setAttribute("d",
|
|
762
|
+
this.sourceArrow.setAttribute("d", f);
|
|
746
763
|
}
|
|
747
764
|
if (this.targetArrow) {
|
|
748
|
-
const
|
|
749
|
-
|
|
765
|
+
const f = N(
|
|
766
|
+
y,
|
|
750
767
|
l,
|
|
751
768
|
v,
|
|
752
769
|
this.arrowWidth
|
|
753
770
|
);
|
|
754
|
-
this.targetArrow.setAttribute("d",
|
|
771
|
+
this.targetArrow.setAttribute("d", f);
|
|
755
772
|
}
|
|
756
773
|
}
|
|
757
774
|
}
|
|
758
|
-
class
|
|
775
|
+
class Ce {
|
|
759
776
|
constructor(e) {
|
|
760
|
-
i(this, "svg",
|
|
761
|
-
i(this, "group",
|
|
777
|
+
i(this, "svg", $());
|
|
778
|
+
i(this, "group", W());
|
|
762
779
|
i(this, "line");
|
|
763
780
|
i(this, "sourceArrow", null);
|
|
764
781
|
i(this, "targetArrow", null);
|
|
@@ -779,37 +796,37 @@ class Ne {
|
|
|
779
796
|
this.cycleSquareSide / 2
|
|
780
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;
|
|
781
798
|
const r = (e == null ? void 0 : e.color) ?? u.color, s = (e == null ? void 0 : e.width) ?? u.width;
|
|
782
|
-
this.svg.appendChild(this.group), this.line =
|
|
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));
|
|
783
800
|
}
|
|
784
801
|
render(e) {
|
|
785
|
-
const { x: o, y: r, width: s, height:
|
|
802
|
+
const { x: o, y: r, width: s, height: h, flipX: n, flipY: d } = z(
|
|
786
803
|
e.from,
|
|
787
804
|
e.to
|
|
788
805
|
);
|
|
789
|
-
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${s}px`, this.svg.style.height = `${
|
|
790
|
-
const c =
|
|
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})`;
|
|
807
|
+
const c = T(
|
|
791
808
|
e.from.direction,
|
|
792
809
|
n,
|
|
793
|
-
|
|
794
|
-
), a =
|
|
810
|
+
d
|
|
811
|
+
), a = T(e.to.direction, n, d), l = {
|
|
795
812
|
x: s,
|
|
796
|
-
y:
|
|
813
|
+
y: h
|
|
797
814
|
};
|
|
798
|
-
let g,
|
|
799
|
-
if (e.from.portId === e.to.portId ? (g =
|
|
800
|
-
|
|
815
|
+
let g, y = a, v = -this.arrowLength;
|
|
816
|
+
if (e.from.portId === e.to.portId ? (g = G({
|
|
817
|
+
fromVector: c,
|
|
801
818
|
arrowLength: this.arrowLength,
|
|
802
819
|
side: this.cycleSquareSide,
|
|
803
820
|
arrowOffset: this.arrowOffset,
|
|
804
821
|
roundness: this.roundness,
|
|
805
822
|
hasSourceArrow: this.hasSourceArrow,
|
|
806
823
|
hasTargetArrow: this.hasTargetArrow
|
|
807
|
-
}),
|
|
824
|
+
}), y = c, v = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = j({
|
|
808
825
|
to: l,
|
|
809
|
-
|
|
810
|
-
|
|
826
|
+
fromVector: c,
|
|
827
|
+
toVector: a,
|
|
811
828
|
flipX: n,
|
|
812
|
-
flipY:
|
|
829
|
+
flipY: d,
|
|
813
830
|
arrowLength: this.arrowLength,
|
|
814
831
|
arrowOffset: this.arrowOffset,
|
|
815
832
|
roundness: this.roundness,
|
|
@@ -817,39 +834,39 @@ class Ne {
|
|
|
817
834
|
detourDistance: this.detourDistance,
|
|
818
835
|
hasSourceArrow: this.hasSourceArrow,
|
|
819
836
|
hasTargetArrow: this.hasTargetArrow
|
|
820
|
-
}) : g =
|
|
837
|
+
}) : g = Te({
|
|
821
838
|
to: l,
|
|
822
|
-
|
|
823
|
-
|
|
839
|
+
fromVector: c,
|
|
840
|
+
toVector: a,
|
|
824
841
|
arrowLength: this.arrowLength,
|
|
825
842
|
arrowOffset: this.arrowOffset,
|
|
826
843
|
roundness: this.roundness,
|
|
827
844
|
hasSourceArrow: this.hasSourceArrow,
|
|
828
845
|
hasTargetArrow: this.hasTargetArrow
|
|
829
846
|
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
830
|
-
const
|
|
847
|
+
const f = N(
|
|
831
848
|
c,
|
|
832
849
|
w,
|
|
833
850
|
this.arrowLength,
|
|
834
851
|
this.arrowWidth
|
|
835
852
|
);
|
|
836
|
-
this.sourceArrow.setAttribute("d",
|
|
853
|
+
this.sourceArrow.setAttribute("d", f);
|
|
837
854
|
}
|
|
838
855
|
if (this.targetArrow) {
|
|
839
|
-
const
|
|
840
|
-
|
|
856
|
+
const f = N(
|
|
857
|
+
y,
|
|
841
858
|
l,
|
|
842
859
|
v,
|
|
843
860
|
this.arrowWidth
|
|
844
861
|
);
|
|
845
|
-
this.targetArrow.setAttribute("d",
|
|
862
|
+
this.targetArrow.setAttribute("d", f);
|
|
846
863
|
}
|
|
847
864
|
}
|
|
848
865
|
}
|
|
849
|
-
class
|
|
866
|
+
class Ve {
|
|
850
867
|
constructor(e) {
|
|
851
|
-
i(this, "svg",
|
|
852
|
-
i(this, "group",
|
|
868
|
+
i(this, "svg", $());
|
|
869
|
+
i(this, "group", W());
|
|
853
870
|
i(this, "line");
|
|
854
871
|
i(this, "sourceArrow", null);
|
|
855
872
|
i(this, "targetArrow", null);
|
|
@@ -870,37 +887,37 @@ class me {
|
|
|
870
887
|
this.cycleSquareSide / 2
|
|
871
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;
|
|
872
889
|
const r = (e == null ? void 0 : e.color) ?? u.color, s = (e == null ? void 0 : e.width) ?? u.width;
|
|
873
|
-
this.svg.appendChild(this.group), this.line =
|
|
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));
|
|
874
891
|
}
|
|
875
892
|
render(e) {
|
|
876
|
-
const { x: o, y: r, width: s, height:
|
|
893
|
+
const { x: o, y: r, width: s, height: h, flipX: n, flipY: d } = z(
|
|
877
894
|
e.from,
|
|
878
895
|
e.to
|
|
879
896
|
);
|
|
880
|
-
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${s}px`, this.svg.style.height = `${
|
|
881
|
-
const c =
|
|
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})`;
|
|
898
|
+
const c = T(
|
|
882
899
|
e.from.direction,
|
|
883
900
|
n,
|
|
884
|
-
|
|
885
|
-
), a =
|
|
901
|
+
d
|
|
902
|
+
), a = T(e.to.direction, n, d), l = {
|
|
886
903
|
x: s,
|
|
887
|
-
y:
|
|
904
|
+
y: h
|
|
888
905
|
};
|
|
889
|
-
let g,
|
|
890
|
-
if (e.from.portId === e.to.portId ? (g =
|
|
891
|
-
|
|
906
|
+
let g, y = a, v = -this.arrowLength;
|
|
907
|
+
if (e.from.portId === e.to.portId ? (g = G({
|
|
908
|
+
fromVector: c,
|
|
892
909
|
arrowLength: this.arrowLength,
|
|
893
910
|
side: this.cycleSquareSide,
|
|
894
911
|
arrowOffset: this.arrowOffset,
|
|
895
912
|
roundness: this.roundness,
|
|
896
913
|
hasSourceArrow: this.hasSourceArrow,
|
|
897
914
|
hasTargetArrow: this.hasTargetArrow
|
|
898
|
-
}),
|
|
915
|
+
}), y = c, v = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = j({
|
|
899
916
|
to: l,
|
|
900
|
-
|
|
901
|
-
|
|
917
|
+
fromVector: c,
|
|
918
|
+
toVector: a,
|
|
902
919
|
flipX: n,
|
|
903
|
-
flipY:
|
|
920
|
+
flipY: d,
|
|
904
921
|
arrowLength: this.arrowLength,
|
|
905
922
|
arrowOffset: this.arrowOffset,
|
|
906
923
|
roundness: this.roundness,
|
|
@@ -908,42 +925,42 @@ class me {
|
|
|
908
925
|
detourDistance: this.detourDistance,
|
|
909
926
|
hasSourceArrow: this.hasSourceArrow,
|
|
910
927
|
hasTargetArrow: this.hasTargetArrow
|
|
911
|
-
}) : g =
|
|
928
|
+
}) : g = Ne({
|
|
912
929
|
to: l,
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
flipY:
|
|
930
|
+
fromVector: c,
|
|
931
|
+
toVector: a,
|
|
932
|
+
flipY: d,
|
|
916
933
|
arrowLength: this.arrowLength,
|
|
917
934
|
arrowOffset: this.arrowOffset,
|
|
918
935
|
roundness: this.roundness,
|
|
919
936
|
hasSourceArrow: this.hasSourceArrow,
|
|
920
937
|
hasTargetArrow: this.hasTargetArrow
|
|
921
938
|
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
922
|
-
const
|
|
939
|
+
const f = N(
|
|
923
940
|
c,
|
|
924
941
|
w,
|
|
925
942
|
this.arrowLength,
|
|
926
943
|
this.arrowWidth
|
|
927
944
|
);
|
|
928
|
-
this.sourceArrow.setAttribute("d",
|
|
945
|
+
this.sourceArrow.setAttribute("d", f);
|
|
929
946
|
}
|
|
930
947
|
if (this.targetArrow) {
|
|
931
|
-
const
|
|
932
|
-
|
|
948
|
+
const f = N(
|
|
949
|
+
y,
|
|
933
950
|
l,
|
|
934
951
|
v,
|
|
935
952
|
this.arrowWidth
|
|
936
953
|
);
|
|
937
|
-
this.targetArrow.setAttribute("d",
|
|
954
|
+
this.targetArrow.setAttribute("d", f);
|
|
938
955
|
}
|
|
939
956
|
}
|
|
940
957
|
}
|
|
941
|
-
const
|
|
958
|
+
const Le = (t) => {
|
|
942
959
|
if (typeof t == "function")
|
|
943
960
|
return t;
|
|
944
961
|
switch (t == null ? void 0 : t.type) {
|
|
945
962
|
case "straight":
|
|
946
|
-
return () => new
|
|
963
|
+
return () => new Ce({
|
|
947
964
|
color: t.color,
|
|
948
965
|
width: t.width,
|
|
949
966
|
arrowLength: t.arrowLength,
|
|
@@ -957,7 +974,7 @@ const Pe = (t) => {
|
|
|
957
974
|
detourDirection: t.detourDirection
|
|
958
975
|
});
|
|
959
976
|
case "horizontal":
|
|
960
|
-
return () => new
|
|
977
|
+
return () => new Me({
|
|
961
978
|
color: t.color,
|
|
962
979
|
width: t.width,
|
|
963
980
|
arrowLength: t.arrowLength,
|
|
@@ -971,7 +988,7 @@ const Pe = (t) => {
|
|
|
971
988
|
detourDirection: t.detourDirection
|
|
972
989
|
});
|
|
973
990
|
case "vertical":
|
|
974
|
-
return () => new
|
|
991
|
+
return () => new Ve({
|
|
975
992
|
color: t.color,
|
|
976
993
|
width: t.width,
|
|
977
994
|
arrowLength: t.arrowLength,
|
|
@@ -985,7 +1002,7 @@ const Pe = (t) => {
|
|
|
985
1002
|
detourDirection: t.detourDirection
|
|
986
1003
|
});
|
|
987
1004
|
default:
|
|
988
|
-
return () => new
|
|
1005
|
+
return () => new De({
|
|
989
1006
|
color: t.color,
|
|
990
1007
|
width: t.width,
|
|
991
1008
|
arrowLength: t.arrowLength,
|
|
@@ -999,30 +1016,30 @@ const Pe = (t) => {
|
|
|
999
1016
|
detourDirection: t.detourDirection
|
|
1000
1017
|
});
|
|
1001
1018
|
}
|
|
1002
|
-
},
|
|
1003
|
-
var o, r, s,
|
|
1004
|
-
const e =
|
|
1019
|
+
}, Re = (t) => {
|
|
1020
|
+
var o, r, s, h, n;
|
|
1021
|
+
const e = Ee(
|
|
1005
1022
|
(o = t == null ? void 0 : t.nodes) == null ? void 0 : o.priority,
|
|
1006
1023
|
(r = t == null ? void 0 : t.edges) == null ? void 0 : r.priority
|
|
1007
1024
|
);
|
|
1008
1025
|
return {
|
|
1009
1026
|
nodes: {
|
|
1010
|
-
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,
|
|
1011
1028
|
priorityFn: e.nodesPriorityFn
|
|
1012
1029
|
},
|
|
1013
1030
|
ports: {
|
|
1014
|
-
direction: ((
|
|
1031
|
+
direction: ((h = t == null ? void 0 : t.ports) == null ? void 0 : h.direction) ?? 0
|
|
1015
1032
|
},
|
|
1016
1033
|
edges: {
|
|
1017
|
-
shapeFactory:
|
|
1034
|
+
shapeFactory: Le(((n = t == null ? void 0 : t.edges) == null ? void 0 : n.shape) ?? {}),
|
|
1018
1035
|
priorityFn: e.edgesPriorityFn
|
|
1019
1036
|
}
|
|
1020
1037
|
};
|
|
1021
1038
|
};
|
|
1022
|
-
class
|
|
1023
|
-
constructor(e, o, r, s,
|
|
1039
|
+
class de {
|
|
1040
|
+
constructor(e, o, r, s, h) {
|
|
1024
1041
|
/**
|
|
1025
|
-
* provides api for accessing graph
|
|
1042
|
+
* provides api for accessing model of rendered graph
|
|
1026
1043
|
*/
|
|
1027
1044
|
i(this, "graph");
|
|
1028
1045
|
/**
|
|
@@ -1030,13 +1047,13 @@ class Me {
|
|
|
1030
1047
|
*/
|
|
1031
1048
|
i(this, "viewport");
|
|
1032
1049
|
i(this, "defaults");
|
|
1033
|
-
i(this, "nodeIdGenerator", new
|
|
1050
|
+
i(this, "nodeIdGenerator", new Y(
|
|
1034
1051
|
(e) => this.graph.getNode(e) !== null
|
|
1035
1052
|
));
|
|
1036
|
-
i(this, "portIdGenerator", new
|
|
1053
|
+
i(this, "portIdGenerator", new Y(
|
|
1037
1054
|
(e) => this.graph.getPort(e) !== null
|
|
1038
1055
|
));
|
|
1039
|
-
i(this, "edgeIdGenerator", new
|
|
1056
|
+
i(this, "edgeIdGenerator", new Y(
|
|
1040
1057
|
(e) => this.graph.getEdge(e) !== null
|
|
1041
1058
|
));
|
|
1042
1059
|
i(this, "onAfterNodeAdded", (e) => {
|
|
@@ -1084,17 +1101,20 @@ class Me {
|
|
|
1084
1101
|
this.nodeIdGenerator.reset(), this.portIdGenerator.reset(), this.edgeIdGenerator.reset(), this.htmlView.clear();
|
|
1085
1102
|
});
|
|
1086
1103
|
i(this, "onBeforeDestroyEmitter");
|
|
1104
|
+
/**
|
|
1105
|
+
* emits event just before destruction of canvas
|
|
1106
|
+
*/
|
|
1087
1107
|
i(this, "onBeforeDestroy");
|
|
1088
|
-
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(
|
|
1089
1109
|
this.onAfterNodePriorityUpdated
|
|
1090
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(
|
|
1091
1111
|
this.onAfterEdgeShapeUpdated
|
|
1092
1112
|
), this.graphStore.onAfterEdgeUpdated.subscribe(this.onAfterEdgeUpdated), this.graphStore.onAfterEdgePriorityUpdated.subscribe(
|
|
1093
1113
|
this.onAfterEdgePriorityUpdated
|
|
1094
|
-
), 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();
|
|
1095
1115
|
}
|
|
1096
1116
|
/**
|
|
1097
|
-
* adds node
|
|
1117
|
+
* adds new node
|
|
1098
1118
|
*/
|
|
1099
1119
|
addNode(e) {
|
|
1100
1120
|
const o = this.nodeIdGenerator.create(e.id);
|
|
@@ -1122,28 +1142,28 @@ class Me {
|
|
|
1122
1142
|
*/
|
|
1123
1143
|
updateNode(e, o) {
|
|
1124
1144
|
if (this.graph.getNode(e) === null)
|
|
1125
|
-
throw new S("failed to update
|
|
1145
|
+
throw new S("failed to update non existing node");
|
|
1126
1146
|
return this.graphStore.updateNode(e, o ?? {}), this;
|
|
1127
1147
|
}
|
|
1128
1148
|
/**
|
|
1129
|
-
* removes node
|
|
1149
|
+
* removes specified node
|
|
1130
1150
|
* all the ports of node get unmarked
|
|
1131
1151
|
* all the edges adjacent to node get removed
|
|
1132
1152
|
*/
|
|
1133
1153
|
removeNode(e) {
|
|
1134
1154
|
if (this.graph.getNode(e) === null)
|
|
1135
|
-
throw new S("failed to remove
|
|
1155
|
+
throw new S("failed to remove non existing node");
|
|
1136
1156
|
return this.graphStore.removeNode(e), this;
|
|
1137
1157
|
}
|
|
1138
1158
|
/**
|
|
1139
|
-
* marks element as port
|
|
1159
|
+
* marks specified element as a port for specified node
|
|
1140
1160
|
*/
|
|
1141
1161
|
markPort(e) {
|
|
1142
1162
|
const o = this.portIdGenerator.create(e.id);
|
|
1143
1163
|
if (this.graph.getPort(o) !== null)
|
|
1144
1164
|
throw new S("failed to add port with existing id");
|
|
1145
1165
|
if (this.graph.getNode(e.nodeId) === null)
|
|
1146
|
-
throw new S("failed to mark port for
|
|
1166
|
+
throw new S("failed to mark port for nonexistent node");
|
|
1147
1167
|
return this.graphStore.addPort({
|
|
1148
1168
|
id: o,
|
|
1149
1169
|
element: e.element,
|
|
@@ -1152,33 +1172,33 @@ class Me {
|
|
|
1152
1172
|
}), this;
|
|
1153
1173
|
}
|
|
1154
1174
|
/**
|
|
1155
|
-
* updates port and attached
|
|
1175
|
+
* updates port and edges attached to it
|
|
1156
1176
|
*/
|
|
1157
1177
|
updatePort(e, o) {
|
|
1158
1178
|
if (this.graph.getPort(e) === null)
|
|
1159
|
-
throw new S("failed to update
|
|
1179
|
+
throw new S("failed to update nonexistent port");
|
|
1160
1180
|
return this.graphStore.updatePort(e, o ?? {}), this;
|
|
1161
1181
|
}
|
|
1162
1182
|
/**
|
|
1163
|
-
*
|
|
1164
|
-
* all the edges adjacent to port get removed
|
|
1183
|
+
* unmarks specified port
|
|
1184
|
+
* all the edges adjacent to the port get removed
|
|
1165
1185
|
*/
|
|
1166
1186
|
unmarkPort(e) {
|
|
1167
1187
|
if (this.graph.getPort(e) === null)
|
|
1168
|
-
throw new S("failed to unmark
|
|
1188
|
+
throw new S("failed to unmark non existing port");
|
|
1169
1189
|
return this.graphStore.removePort(e), this;
|
|
1170
1190
|
}
|
|
1171
1191
|
/**
|
|
1172
|
-
* adds edge
|
|
1192
|
+
* adds new edge
|
|
1173
1193
|
*/
|
|
1174
1194
|
addEdge(e) {
|
|
1175
1195
|
const o = this.edgeIdGenerator.create(e.id);
|
|
1176
1196
|
if (this.graph.getEdge(o) !== null)
|
|
1177
1197
|
throw new S("failed to add edge with existing id");
|
|
1178
1198
|
if (this.graph.getPort(e.from) === null)
|
|
1179
|
-
throw new S("failed to add edge from
|
|
1199
|
+
throw new S("failed to add edge from nonexistent port");
|
|
1180
1200
|
if (this.graph.getPort(e.to) === null)
|
|
1181
|
-
throw new S("failed to add edge to
|
|
1201
|
+
throw new S("failed to add edge to nonexistent port");
|
|
1182
1202
|
return this.graphStore.addEdge({
|
|
1183
1203
|
id: o,
|
|
1184
1204
|
from: e.from,
|
|
@@ -1188,29 +1208,29 @@ class Me {
|
|
|
1188
1208
|
}), this;
|
|
1189
1209
|
}
|
|
1190
1210
|
/**
|
|
1191
|
-
* updates edge
|
|
1211
|
+
* updates specified edge
|
|
1192
1212
|
*/
|
|
1193
1213
|
updateEdge(e, o) {
|
|
1194
1214
|
if (this.graph.getEdge(e) === null)
|
|
1195
|
-
throw new S("failed to update
|
|
1215
|
+
throw new S("failed to update nonexistent edge");
|
|
1196
1216
|
return this.graphStore.updateEdge(e, o ?? {}), this;
|
|
1197
1217
|
}
|
|
1198
1218
|
/**
|
|
1199
|
-
* removes edge
|
|
1219
|
+
* removes specified edge
|
|
1200
1220
|
*/
|
|
1201
1221
|
removeEdge(e) {
|
|
1202
1222
|
if (this.graph.getEdge(e) === null)
|
|
1203
|
-
throw new S("failed to remove
|
|
1223
|
+
throw new S("failed to remove nonexistent edge");
|
|
1204
1224
|
return this.graphStore.removeEdge(e), this;
|
|
1205
1225
|
}
|
|
1206
1226
|
/**
|
|
1207
|
-
* applies transformation for viewport
|
|
1227
|
+
* applies transformation for viewport matrix
|
|
1208
1228
|
*/
|
|
1209
1229
|
patchViewportMatrix(e) {
|
|
1210
1230
|
return this.viewportStore.patchViewportMatrix(e), this;
|
|
1211
1231
|
}
|
|
1212
1232
|
/**
|
|
1213
|
-
* applies transformation for content
|
|
1233
|
+
* applies transformation for content matrix
|
|
1214
1234
|
*/
|
|
1215
1235
|
patchContentMatrix(e) {
|
|
1216
1236
|
return this.viewportStore.patchContentMatrix(e), this;
|
|
@@ -1227,22 +1247,22 @@ class Me {
|
|
|
1227
1247
|
* canvas element gets rolled back to initial state, and can not be reused
|
|
1228
1248
|
*/
|
|
1229
1249
|
destroy() {
|
|
1230
|
-
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(
|
|
1231
1251
|
this.onAfterNodePriorityUpdated
|
|
1232
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(
|
|
1233
1253
|
this.onAfterEdgeShapeUpdated
|
|
1234
1254
|
), this.graphStore.onAfterEdgeUpdated.unsubscribe(this.onAfterEdgeUpdated), this.graphStore.onAfterEdgePriorityUpdated.unsubscribe(
|
|
1235
1255
|
this.onAfterEdgePriorityUpdated
|
|
1236
|
-
), 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();
|
|
1237
1257
|
}
|
|
1238
1258
|
}
|
|
1239
|
-
class
|
|
1259
|
+
class ce {
|
|
1240
1260
|
constructor() {
|
|
1241
1261
|
i(this, "nodes", /* @__PURE__ */ new Map());
|
|
1242
1262
|
i(this, "ports", /* @__PURE__ */ new Map());
|
|
1243
1263
|
i(this, "edges", /* @__PURE__ */ new Map());
|
|
1244
|
-
i(this, "
|
|
1245
|
-
i(this, "
|
|
1264
|
+
i(this, "incomingEdges", /* @__PURE__ */ new Map());
|
|
1265
|
+
i(this, "outcomingEdges", /* @__PURE__ */ new Map());
|
|
1246
1266
|
i(this, "cycleEdges", /* @__PURE__ */ new Map());
|
|
1247
1267
|
i(this, "afterNodeAddedEmitter");
|
|
1248
1268
|
i(this, "onAfterNodeAdded");
|
|
@@ -1270,7 +1290,7 @@ class Ve {
|
|
|
1270
1290
|
i(this, "onBeforeEdgeRemoved");
|
|
1271
1291
|
i(this, "beforeClearEmitter");
|
|
1272
1292
|
i(this, "onBeforeClear");
|
|
1273
|
-
[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();
|
|
1274
1294
|
}
|
|
1275
1295
|
addNode(e) {
|
|
1276
1296
|
const o = /* @__PURE__ */ new Map(), r = {
|
|
@@ -1301,7 +1321,7 @@ class Ve {
|
|
|
1301
1321
|
element: e.element,
|
|
1302
1322
|
direction: e.direction,
|
|
1303
1323
|
nodeId: e.nodeId
|
|
1304
|
-
}), this.cycleEdges.set(e.id, /* @__PURE__ */ new Set()), this.
|
|
1324
|
+
}), this.cycleEdges.set(e.id, /* @__PURE__ */ new Set()), this.incomingEdges.set(e.id, /* @__PURE__ */ new Set()), this.outcomingEdges.set(e.id, /* @__PURE__ */ new Set()), this.nodes.get(e.nodeId).ports.set(e.id, e.element), this.afterPortAddedEmitter.emit(e.id);
|
|
1305
1325
|
}
|
|
1306
1326
|
getPort(e) {
|
|
1307
1327
|
return this.ports.get(e);
|
|
@@ -1349,13 +1369,13 @@ class Ve {
|
|
|
1349
1369
|
this.beforeEdgeRemovedEmitter.emit(e), this.removeEdgeInternal(e);
|
|
1350
1370
|
}
|
|
1351
1371
|
clear() {
|
|
1352
|
-
this.beforeClearEmitter.emit(), this.
|
|
1372
|
+
this.beforeClearEmitter.emit(), this.incomingEdges.clear(), this.outcomingEdges.clear(), this.cycleEdges.clear(), this.edges.clear(), this.ports.clear(), this.nodes.clear();
|
|
1353
1373
|
}
|
|
1354
1374
|
getPortIncomingEdgeIds(e) {
|
|
1355
|
-
return Array.from(this.
|
|
1375
|
+
return Array.from(this.incomingEdges.get(e));
|
|
1356
1376
|
}
|
|
1357
1377
|
getPortOutcomingEdgeIds(e) {
|
|
1358
|
-
return Array.from(this.
|
|
1378
|
+
return Array.from(this.outcomingEdges.get(e));
|
|
1359
1379
|
}
|
|
1360
1380
|
getPortCycleEdgeIds(e) {
|
|
1361
1381
|
return Array.from(this.cycleEdges.get(e));
|
|
@@ -1401,31 +1421,31 @@ class Ve {
|
|
|
1401
1421
|
to: e.to,
|
|
1402
1422
|
shape: e.shape,
|
|
1403
1423
|
priority: e.priority
|
|
1404
|
-
}), e.from !== e.to ? (this.
|
|
1424
|
+
}), e.from !== e.to ? (this.outcomingEdges.get(e.from).add(e.id), this.incomingEdges.get(e.to).add(e.id)) : this.cycleEdges.get(e.from).add(e.id);
|
|
1405
1425
|
}
|
|
1406
1426
|
removeEdgeInternal(e) {
|
|
1407
1427
|
const o = this.edges.get(e), r = o.from, s = o.to;
|
|
1408
|
-
this.cycleEdges.get(r).delete(e), this.cycleEdges.get(s).delete(e), this.
|
|
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);
|
|
1409
1429
|
}
|
|
1410
1430
|
}
|
|
1411
|
-
const
|
|
1431
|
+
const re = (t) => ({
|
|
1412
1432
|
scale: 1 / t.scale,
|
|
1413
1433
|
x: -t.x / t.scale,
|
|
1414
1434
|
y: -t.y / t.scale
|
|
1415
|
-
}),
|
|
1435
|
+
}), ie = {
|
|
1416
1436
|
scale: 1,
|
|
1417
1437
|
x: 0,
|
|
1418
1438
|
y: 0
|
|
1419
1439
|
};
|
|
1420
|
-
class
|
|
1440
|
+
class Ie {
|
|
1421
1441
|
constructor() {
|
|
1422
|
-
i(this, "viewportMatrix",
|
|
1423
|
-
i(this, "contentMatrix",
|
|
1442
|
+
i(this, "viewportMatrix", ie);
|
|
1443
|
+
i(this, "contentMatrix", ie);
|
|
1424
1444
|
i(this, "afterUpdateEmitter");
|
|
1425
1445
|
i(this, "onAfterUpdated");
|
|
1426
1446
|
i(this, "beforeUpdateEmitter");
|
|
1427
1447
|
i(this, "onBeforeUpdated");
|
|
1428
|
-
[this.afterUpdateEmitter, this.onAfterUpdated] =
|
|
1448
|
+
[this.afterUpdateEmitter, this.onAfterUpdated] = E(), [this.beforeUpdateEmitter, this.onBeforeUpdated] = E();
|
|
1429
1449
|
}
|
|
1430
1450
|
getViewportMatrix() {
|
|
1431
1451
|
return this.viewportMatrix;
|
|
@@ -1438,17 +1458,17 @@ class Le {
|
|
|
1438
1458
|
scale: e.scale ?? this.viewportMatrix.scale,
|
|
1439
1459
|
x: e.x ?? this.viewportMatrix.x,
|
|
1440
1460
|
y: e.y ?? this.viewportMatrix.y
|
|
1441
|
-
}, this.contentMatrix =
|
|
1461
|
+
}, this.contentMatrix = re(this.viewportMatrix), this.afterUpdateEmitter.emit();
|
|
1442
1462
|
}
|
|
1443
1463
|
patchContentMatrix(e) {
|
|
1444
1464
|
this.beforeUpdateEmitter.emit(), this.contentMatrix = {
|
|
1445
1465
|
scale: e.scale ?? this.contentMatrix.scale,
|
|
1446
1466
|
x: e.x ?? this.contentMatrix.x,
|
|
1447
1467
|
y: e.y ?? this.contentMatrix.y
|
|
1448
|
-
}, this.viewportMatrix =
|
|
1468
|
+
}, this.viewportMatrix = re(this.contentMatrix), this.afterUpdateEmitter.emit();
|
|
1449
1469
|
}
|
|
1450
1470
|
}
|
|
1451
|
-
class
|
|
1471
|
+
class J {
|
|
1452
1472
|
constructor(e) {
|
|
1453
1473
|
i(this, "elementToNodeId", /* @__PURE__ */ new Map());
|
|
1454
1474
|
i(this, "nodesResizeObserver");
|
|
@@ -1474,7 +1494,7 @@ class G {
|
|
|
1474
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);
|
|
1475
1495
|
}
|
|
1476
1496
|
static configure(e) {
|
|
1477
|
-
new
|
|
1497
|
+
new J(e);
|
|
1478
1498
|
}
|
|
1479
1499
|
handleNodeResize(e) {
|
|
1480
1500
|
const o = this.elementToNodeId.get(e);
|
|
@@ -1483,35 +1503,36 @@ class G {
|
|
|
1483
1503
|
});
|
|
1484
1504
|
}
|
|
1485
1505
|
}
|
|
1486
|
-
const
|
|
1487
|
-
var g,
|
|
1506
|
+
const Be = (t) => {
|
|
1507
|
+
var g, y, v, f, p, A;
|
|
1488
1508
|
const e = ((g = t == null ? void 0 : t.events) == null ? void 0 : g.onNodeDrag) ?? (() => {
|
|
1489
|
-
}), o = ((
|
|
1490
|
-
}), 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;
|
|
1491
1511
|
return {
|
|
1492
1512
|
freezePriority: s,
|
|
1493
1513
|
dragCursor: n,
|
|
1494
1514
|
mouseDownEventVerifier: c,
|
|
1495
|
-
mouseUpEventVerifier: a !== void 0 ? a : (
|
|
1515
|
+
mouseUpEventVerifier: a !== void 0 ? a : (b) => b.button === 0,
|
|
1496
1516
|
onNodeDrag: e,
|
|
1497
1517
|
onBeforeNodeDrag: o,
|
|
1498
1518
|
onNodeDragFinished: r
|
|
1499
1519
|
};
|
|
1500
|
-
},
|
|
1501
|
-
const { x: r, y: s, width:
|
|
1502
|
-
return e >= r && e <= r +
|
|
1503
|
-
},
|
|
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) => {
|
|
1504
1524
|
e !== null ? t.style.cursor = e : t.style.removeProperty("cursor");
|
|
1505
|
-
}
|
|
1506
|
-
|
|
1507
|
-
|
|
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) {
|
|
1508
1531
|
i(this, "grabbedNodeId", null);
|
|
1509
1532
|
i(this, "maxNodePriority", 0);
|
|
1510
|
-
i(this, "
|
|
1533
|
+
i(this, "previousTouchCoordinates", null);
|
|
1511
1534
|
i(this, "nodeIds", /* @__PURE__ */ new Map());
|
|
1512
|
-
i(this, "window", window);
|
|
1513
1535
|
i(this, "graph");
|
|
1514
|
-
i(this, "element");
|
|
1515
1536
|
i(this, "onAfterNodeAdded", (e) => {
|
|
1516
1537
|
this.updateMaxNodePriority(e);
|
|
1517
1538
|
const o = this.graph.getNode(e);
|
|
@@ -1541,12 +1562,12 @@ class J {
|
|
|
1541
1562
|
element: s.element,
|
|
1542
1563
|
x: s.x,
|
|
1543
1564
|
y: s.y
|
|
1544
|
-
}) && (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));
|
|
1545
1566
|
});
|
|
1546
1567
|
i(this, "onTouchStart", (e) => {
|
|
1547
1568
|
if (e.touches.length !== 1)
|
|
1548
1569
|
return;
|
|
1549
|
-
e.stopImmediatePropagation(), this.
|
|
1570
|
+
e.stopImmediatePropagation(), this.previousTouchCoordinates = {
|
|
1550
1571
|
x: e.touches[0].clientX,
|
|
1551
1572
|
y: e.touches[0].clientY
|
|
1552
1573
|
};
|
|
@@ -1559,7 +1580,12 @@ class J {
|
|
|
1559
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));
|
|
1560
1581
|
});
|
|
1561
1582
|
i(this, "onWindowMouseMove", (e) => {
|
|
1562
|
-
if (!
|
|
1583
|
+
if (!V(
|
|
1584
|
+
this.window,
|
|
1585
|
+
this.element,
|
|
1586
|
+
e.clientX,
|
|
1587
|
+
e.clientY
|
|
1588
|
+
)) {
|
|
1563
1589
|
this.cancelMouseDrag();
|
|
1564
1590
|
return;
|
|
1565
1591
|
}
|
|
@@ -1572,37 +1598,48 @@ class J {
|
|
|
1572
1598
|
if (e.touches.length !== 1)
|
|
1573
1599
|
return;
|
|
1574
1600
|
const o = e.touches[0];
|
|
1575
|
-
if (!
|
|
1601
|
+
if (!V(
|
|
1602
|
+
this.window,
|
|
1603
|
+
this.element,
|
|
1604
|
+
o.clientX,
|
|
1605
|
+
o.clientY
|
|
1606
|
+
)) {
|
|
1576
1607
|
this.cancelTouchDrag();
|
|
1577
1608
|
return;
|
|
1578
1609
|
}
|
|
1579
|
-
if (this.grabbedNodeId !== null && this.
|
|
1580
|
-
const
|
|
1581
|
-
this.dragNode(this.grabbedNodeId,
|
|
1610
|
+
if (this.grabbedNodeId !== null && this.previousTouchCoordinates !== null) {
|
|
1611
|
+
const s = o.clientX - this.previousTouchCoordinates.x, h = o.clientY - this.previousTouchCoordinates.y;
|
|
1612
|
+
this.dragNode(this.grabbedNodeId, s, h), this.previousTouchCoordinates = {
|
|
1582
1613
|
x: e.touches[0].clientX,
|
|
1583
1614
|
y: e.touches[0].clientY
|
|
1584
1615
|
};
|
|
1585
1616
|
}
|
|
1586
1617
|
});
|
|
1587
1618
|
i(this, "onWindowTouchFinish", () => {
|
|
1588
|
-
this.
|
|
1619
|
+
this.previousTouchCoordinates = null, this.cancelTouchDrag();
|
|
1589
1620
|
});
|
|
1590
1621
|
i(this, "options");
|
|
1591
|
-
this.canvas = e, this.
|
|
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);
|
|
1592
1623
|
}
|
|
1593
|
-
static configure(e, o) {
|
|
1594
|
-
new
|
|
1624
|
+
static configure(e, o, r, s) {
|
|
1625
|
+
new K(e, o, r, s);
|
|
1595
1626
|
}
|
|
1596
1627
|
dragNode(e, o, r) {
|
|
1597
1628
|
const s = this.graph.getNode(e);
|
|
1598
1629
|
if (s === null)
|
|
1599
1630
|
return;
|
|
1600
|
-
const
|
|
1601
|
-
|
|
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({
|
|
1602
1639
|
nodeId: e,
|
|
1603
1640
|
element: s.element,
|
|
1604
|
-
x:
|
|
1605
|
-
y:
|
|
1641
|
+
x: a.x,
|
|
1642
|
+
y: a.y
|
|
1606
1643
|
});
|
|
1607
1644
|
}
|
|
1608
1645
|
moveNodeOnTop(e) {
|
|
@@ -1621,13 +1658,13 @@ class J {
|
|
|
1621
1658
|
element: e.element,
|
|
1622
1659
|
x: e.x,
|
|
1623
1660
|
y: e.y
|
|
1624
|
-
}), this.grabbedNodeId = null,
|
|
1661
|
+
}), this.grabbedNodeId = null, U(this.element, null), this.removeMouseDragListeners();
|
|
1625
1662
|
}
|
|
1626
1663
|
removeMouseDragListeners() {
|
|
1627
1664
|
this.window.removeEventListener("mouseup", this.onWindowMouseUp), this.window.removeEventListener("mousemove", this.onWindowMouseMove);
|
|
1628
1665
|
}
|
|
1629
1666
|
cancelTouchDrag() {
|
|
1630
|
-
this.
|
|
1667
|
+
this.previousTouchCoordinates = null;
|
|
1631
1668
|
const e = this.graph.getNode(this.grabbedNodeId);
|
|
1632
1669
|
e !== null && this.options.onNodeDragFinished({
|
|
1633
1670
|
nodeId: this.grabbedNodeId,
|
|
@@ -1644,30 +1681,30 @@ class J {
|
|
|
1644
1681
|
this.maxNodePriority = Math.max(this.maxNodePriority, o);
|
|
1645
1682
|
}
|
|
1646
1683
|
}
|
|
1647
|
-
const
|
|
1684
|
+
const We = (t) => {
|
|
1648
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;
|
|
1649
|
-
return (
|
|
1650
|
-
let n =
|
|
1651
|
-
n < e && n <
|
|
1652
|
-
const c =
|
|
1653
|
-
n > a && n >
|
|
1654
|
-
const l =
|
|
1655
|
-
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 };
|
|
1656
1693
|
};
|
|
1657
|
-
},
|
|
1694
|
+
}, Fe = (t) => {
|
|
1658
1695
|
const e = t.maxContentScale, o = t.minContentScale, r = e !== null ? 1 / e : 0, s = o !== null ? 1 / o : 1 / 0;
|
|
1659
|
-
return (
|
|
1660
|
-
const n =
|
|
1661
|
-
let c =
|
|
1662
|
-
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) {
|
|
1663
1700
|
c = Math.max(n.scale, s), a = n.x, l = n.y;
|
|
1664
|
-
const g = (c - n.scale) / (
|
|
1665
|
-
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;
|
|
1666
1703
|
}
|
|
1667
|
-
if (
|
|
1704
|
+
if (d.scale < r && d.scale < n.scale) {
|
|
1668
1705
|
c = Math.min(n.scale, r), a = n.x, l = n.y;
|
|
1669
|
-
const g = (c - n.scale) / (
|
|
1670
|
-
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;
|
|
1671
1708
|
}
|
|
1672
1709
|
return {
|
|
1673
1710
|
scale: c,
|
|
@@ -1675,7 +1712,7 @@ const Re = (t) => {
|
|
|
1675
1712
|
y: l
|
|
1676
1713
|
};
|
|
1677
1714
|
};
|
|
1678
|
-
},
|
|
1715
|
+
}, ze = (t) => (e) => t.reduce(
|
|
1679
1716
|
(o, r) => r({
|
|
1680
1717
|
prevTransform: e.prevTransform,
|
|
1681
1718
|
nextTransform: o,
|
|
@@ -1683,71 +1720,71 @@ const Re = (t) => {
|
|
|
1683
1720
|
canvasHeight: e.canvasHeight
|
|
1684
1721
|
}),
|
|
1685
1722
|
e.nextTransform
|
|
1686
|
-
),
|
|
1723
|
+
), se = (t) => {
|
|
1687
1724
|
if (typeof t == "function")
|
|
1688
1725
|
return t;
|
|
1689
1726
|
switch (t.type) {
|
|
1690
1727
|
case "scale-limit":
|
|
1691
|
-
return
|
|
1728
|
+
return Fe({
|
|
1692
1729
|
minContentScale: t.minContentScale ?? 0,
|
|
1693
1730
|
maxContentScale: t.maxContentScale ?? 1 / 0
|
|
1694
1731
|
});
|
|
1695
1732
|
case "shift-limit":
|
|
1696
|
-
return
|
|
1733
|
+
return We({
|
|
1697
1734
|
minX: t.minX ?? -1 / 0,
|
|
1698
1735
|
maxX: t.maxX ?? 1 / 0,
|
|
1699
1736
|
minY: t.minY ?? -1 / 0,
|
|
1700
1737
|
maxY: t.maxY ?? 1 / 0
|
|
1701
1738
|
});
|
|
1702
1739
|
}
|
|
1703
|
-
},
|
|
1704
|
-
var
|
|
1705
|
-
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;
|
|
1706
1743
|
let s;
|
|
1707
|
-
r !== void 0 ? Array.isArray(r) ? s =
|
|
1744
|
+
r !== void 0 ? Array.isArray(r) ? s = ze(
|
|
1708
1745
|
r.map(
|
|
1709
|
-
(
|
|
1746
|
+
(M) => se(M)
|
|
1710
1747
|
)
|
|
1711
|
-
) : s =
|
|
1712
|
-
const
|
|
1713
|
-
}),
|
|
1714
|
-
}), 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;
|
|
1715
1752
|
return {
|
|
1716
1753
|
wheelSensitivity: o,
|
|
1717
|
-
onTransformStarted: ((
|
|
1754
|
+
onTransformStarted: ((R = t == null ? void 0 : t.events) == null ? void 0 : R.onTransformStarted) ?? (() => {
|
|
1718
1755
|
}),
|
|
1719
|
-
onTransformFinished: ((
|
|
1756
|
+
onTransformFinished: ((q = t == null ? void 0 : t.events) == null ? void 0 : q.onTransformFinished) ?? (() => {
|
|
1720
1757
|
}),
|
|
1721
1758
|
onBeforeTransformChange: n,
|
|
1722
|
-
onTransformChange:
|
|
1759
|
+
onTransformChange: d,
|
|
1723
1760
|
transformPreprocessor: s,
|
|
1724
|
-
shiftCursor:
|
|
1761
|
+
shiftCursor: h,
|
|
1725
1762
|
mouseDownEventVerifier: a,
|
|
1726
1763
|
mouseUpEventVerifier: g,
|
|
1727
1764
|
mouseWheelEventVerifier: v,
|
|
1728
|
-
scaleWheelFinishTimeout: ((
|
|
1729
|
-
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) ?? (() => {
|
|
1730
1767
|
}),
|
|
1731
|
-
onResizeTransformFinished: ((
|
|
1768
|
+
onResizeTransformFinished: ((te = t == null ? void 0 : t.events) == null ? void 0 : te.onResizeTransformFinished) ?? (() => {
|
|
1732
1769
|
})
|
|
1733
1770
|
};
|
|
1734
|
-
},
|
|
1771
|
+
}, Ye = (t, e, o) => ({
|
|
1735
1772
|
scale: t.scale,
|
|
1736
1773
|
x: t.x + t.scale * e,
|
|
1737
1774
|
y: t.y + t.scale * o
|
|
1738
|
-
}),
|
|
1775
|
+
}), Xe = (t, e, o, r) => ({
|
|
1739
1776
|
scale: t.scale * e,
|
|
1740
1777
|
x: t.scale * (1 - e) * o + t.x,
|
|
1741
1778
|
y: t.scale * (1 - e) * r + t.y
|
|
1742
|
-
}),
|
|
1779
|
+
}), B = (t) => {
|
|
1743
1780
|
const e = [], o = t.touches.length;
|
|
1744
|
-
for (let
|
|
1745
|
-
e.push([t.touches[
|
|
1781
|
+
for (let d = 0; d < o; d++)
|
|
1782
|
+
e.push([t.touches[d].clientX, t.touches[d].clientY]);
|
|
1746
1783
|
const r = e.reduce(
|
|
1747
|
-
(
|
|
1784
|
+
(d, c) => [d[0] + c[0], d[1] + c[1]],
|
|
1748
1785
|
[0, 0]
|
|
1749
|
-
), s = [r[0] / o, r[1] / o], n = e.map((
|
|
1750
|
-
(
|
|
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]),
|
|
1751
1788
|
0
|
|
1752
1789
|
);
|
|
1753
1790
|
return {
|
|
@@ -1758,10 +1795,8 @@ const Re = (t) => {
|
|
|
1758
1795
|
touches: e
|
|
1759
1796
|
};
|
|
1760
1797
|
};
|
|
1761
|
-
class
|
|
1762
|
-
constructor(e, o) {
|
|
1763
|
-
i(this, "element");
|
|
1764
|
-
i(this, "window", window);
|
|
1798
|
+
class k {
|
|
1799
|
+
constructor(e, o, r, s) {
|
|
1765
1800
|
i(this, "viewport");
|
|
1766
1801
|
i(this, "prevTouches", null);
|
|
1767
1802
|
i(this, "wheelFinishTimer", null);
|
|
@@ -1770,15 +1805,21 @@ class z {
|
|
|
1770
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);
|
|
1771
1806
|
});
|
|
1772
1807
|
i(this, "onMouseDown", (e) => {
|
|
1773
|
-
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());
|
|
1774
1809
|
});
|
|
1775
1810
|
i(this, "onWindowMouseMove", (e) => {
|
|
1776
|
-
|
|
1811
|
+
const o = V(
|
|
1812
|
+
this.window,
|
|
1813
|
+
this.element,
|
|
1814
|
+
e.clientX,
|
|
1815
|
+
e.clientY
|
|
1816
|
+
);
|
|
1817
|
+
if (this.element === null || !o) {
|
|
1777
1818
|
this.stopMouseDrag();
|
|
1778
1819
|
return;
|
|
1779
1820
|
}
|
|
1780
|
-
const
|
|
1781
|
-
this.moveViewport(
|
|
1821
|
+
const r = -e.movementX, s = -e.movementY;
|
|
1822
|
+
this.moveViewport(r, s);
|
|
1782
1823
|
});
|
|
1783
1824
|
i(this, "onWindowMouseUp", (e) => {
|
|
1784
1825
|
this.element === null || !this.options.mouseUpEventVerifier(e) || this.stopMouseDrag();
|
|
@@ -1787,22 +1828,22 @@ class z {
|
|
|
1787
1828
|
if (!this.options.mouseWheelEventVerifier(e))
|
|
1788
1829
|
return;
|
|
1789
1830
|
e.preventDefault();
|
|
1790
|
-
const { left: o, top: r } = this.element.getBoundingClientRect(), s = e.clientX - o,
|
|
1791
|
-
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(() => {
|
|
1792
1833
|
this.transformInProgress || this.options.onTransformFinished(), this.wheelFinishTimer = null;
|
|
1793
1834
|
}, this.options.scaleWheelFinishTimeout);
|
|
1794
1835
|
});
|
|
1795
1836
|
i(this, "onTouchStart", (e) => {
|
|
1796
1837
|
if (this.prevTouches !== null) {
|
|
1797
|
-
this.prevTouches =
|
|
1838
|
+
this.prevTouches = B(e);
|
|
1798
1839
|
return;
|
|
1799
1840
|
}
|
|
1800
|
-
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();
|
|
1801
1842
|
});
|
|
1802
1843
|
i(this, "onWindowTouchMove", (e) => {
|
|
1803
|
-
const o =
|
|
1844
|
+
const o = B(e);
|
|
1804
1845
|
if (!o.touches.every(
|
|
1805
|
-
(s) =>
|
|
1846
|
+
(s) => V(this.window, this.element, s[0], s[1])
|
|
1806
1847
|
)) {
|
|
1807
1848
|
this.stopTouchDrag();
|
|
1808
1849
|
return;
|
|
@@ -1811,13 +1852,13 @@ class z {
|
|
|
1811
1852
|
-(o.x - this.prevTouches.x),
|
|
1812
1853
|
-(o.y - this.prevTouches.y)
|
|
1813
1854
|
), o.touchesCnt === 2) {
|
|
1814
|
-
const { left: s, top:
|
|
1815
|
-
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);
|
|
1816
1857
|
}
|
|
1817
1858
|
this.prevTouches = o;
|
|
1818
1859
|
});
|
|
1819
1860
|
i(this, "onWindowTouchFinish", (e) => {
|
|
1820
|
-
e.touches.length > 0 ? this.prevTouches =
|
|
1861
|
+
e.touches.length > 0 ? this.prevTouches = B(e) : this.stopTouchDrag();
|
|
1821
1862
|
});
|
|
1822
1863
|
i(this, "observer", new ResizeObserver(() => {
|
|
1823
1864
|
const e = this.viewport.getViewportMatrix(), { width: o, height: r } = this.element.getBoundingClientRect(), s = this.options.transformPreprocessor({
|
|
@@ -1829,31 +1870,36 @@ class z {
|
|
|
1829
1870
|
this.options.onResizeTransformStarted(), this.canvas.patchViewportMatrix(s), this.options.onResizeTransformFinished();
|
|
1830
1871
|
}));
|
|
1831
1872
|
i(this, "options");
|
|
1832
|
-
this.canvas = e, this.
|
|
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);
|
|
1833
1874
|
}
|
|
1834
|
-
static configure(e, o) {
|
|
1835
|
-
new
|
|
1875
|
+
static configure(e, o, r, s) {
|
|
1876
|
+
new k(
|
|
1877
|
+
e,
|
|
1878
|
+
o,
|
|
1879
|
+
r,
|
|
1880
|
+
s
|
|
1881
|
+
);
|
|
1836
1882
|
}
|
|
1837
1883
|
moveViewport(e, o) {
|
|
1838
|
-
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({
|
|
1839
1885
|
prevTransform: r,
|
|
1840
1886
|
nextTransform: s,
|
|
1841
|
-
canvasWidth:
|
|
1887
|
+
canvasWidth: h,
|
|
1842
1888
|
canvasHeight: n
|
|
1843
1889
|
});
|
|
1844
|
-
this.performTransform(
|
|
1890
|
+
this.performTransform(d);
|
|
1845
1891
|
}
|
|
1846
1892
|
scaleViewport(e, o, r) {
|
|
1847
|
-
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({
|
|
1848
1894
|
prevTransform: s,
|
|
1849
|
-
nextTransform:
|
|
1895
|
+
nextTransform: h,
|
|
1850
1896
|
canvasWidth: n,
|
|
1851
|
-
canvasHeight:
|
|
1897
|
+
canvasHeight: d
|
|
1852
1898
|
});
|
|
1853
1899
|
this.performTransform(c);
|
|
1854
1900
|
}
|
|
1855
1901
|
stopMouseDrag() {
|
|
1856
|
-
|
|
1902
|
+
U(this.element, null), this.removeMouseDragListeners(), this.finishRegisteredTransform();
|
|
1857
1903
|
}
|
|
1858
1904
|
removeMouseDragListeners() {
|
|
1859
1905
|
this.window.removeEventListener("mousemove", this.onWindowMouseMove), this.window.removeEventListener("mouseup", this.onWindowMouseUp);
|
|
@@ -1874,14 +1920,12 @@ class z {
|
|
|
1874
1920
|
this.transformInProgress = !1, this.options.onTransformFinished();
|
|
1875
1921
|
}
|
|
1876
1922
|
}
|
|
1877
|
-
class
|
|
1878
|
-
constructor(e, o, r, s) {
|
|
1923
|
+
class Q {
|
|
1924
|
+
constructor(e, o, r, s, h, n) {
|
|
1879
1925
|
i(this, "canvasResizeObserver");
|
|
1880
|
-
i(this, "window", window);
|
|
1881
1926
|
i(this, "nodeHorizontal");
|
|
1882
1927
|
i(this, "nodeVertical");
|
|
1883
1928
|
i(this, "viewport");
|
|
1884
|
-
i(this, "element");
|
|
1885
1929
|
i(this, "viewportWidth", 0);
|
|
1886
1930
|
i(this, "viewportHeight", 0);
|
|
1887
1931
|
i(this, "viewportMatrix");
|
|
@@ -1908,50 +1952,54 @@ class K {
|
|
|
1908
1952
|
this.userTransformInProgress || (this.viewportMatrix = this.viewport.getViewportMatrix(), this.loadAreaAroundViewport());
|
|
1909
1953
|
});
|
|
1910
1954
|
i(this, "userTransformInProgress", !1);
|
|
1911
|
-
var
|
|
1912
|
-
this.canvas = e, this.
|
|
1913
|
-
const
|
|
1914
|
-
this.viewportWidth =
|
|
1915
|
-
}), this.viewport = e.viewport
|
|
1916
|
-
const d = ((
|
|
1917
|
-
}),
|
|
1918
|
-
}),
|
|
1919
|
-
}),
|
|
1920
|
-
}),
|
|
1921
|
-
}),
|
|
1922
|
-
...
|
|
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();
|
|
1959
|
+
}), this.viewport = e.viewport;
|
|
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,
|
|
1923
1967
|
events: {
|
|
1924
|
-
...
|
|
1968
|
+
...s == null ? void 0 : s.events,
|
|
1925
1969
|
onResizeTransformStarted: () => {
|
|
1926
1970
|
this.userTransformInProgress = !0, d();
|
|
1927
1971
|
},
|
|
1928
1972
|
onResizeTransformFinished: () => {
|
|
1929
|
-
this.userTransformInProgress = !1,
|
|
1973
|
+
this.userTransformInProgress = !1, c();
|
|
1930
1974
|
},
|
|
1931
1975
|
onBeforeTransformChange: () => {
|
|
1932
|
-
this.userTransformInProgress = !0,
|
|
1976
|
+
this.userTransformInProgress = !0, l();
|
|
1933
1977
|
},
|
|
1934
1978
|
onTransformChange: () => {
|
|
1935
1979
|
this.userTransformInProgress = !1;
|
|
1936
|
-
const
|
|
1937
|
-
this.viewportMatrix = this.viewport.getViewportMatrix(),
|
|
1980
|
+
const D = this.viewportMatrix;
|
|
1981
|
+
this.viewportMatrix = this.viewport.getViewportMatrix(), D.scale !== this.viewportMatrix.scale && this.scheduleEnsureViewportAreaLoaded(), a();
|
|
1938
1982
|
},
|
|
1939
1983
|
onTransformFinished: () => {
|
|
1940
|
-
this.scheduleLoadAreaAroundViewport(),
|
|
1984
|
+
this.scheduleLoadAreaAroundViewport(), g();
|
|
1941
1985
|
}
|
|
1942
1986
|
}
|
|
1943
1987
|
};
|
|
1944
|
-
|
|
1988
|
+
k.configure(
|
|
1945
1989
|
e,
|
|
1946
|
-
|
|
1990
|
+
this.element,
|
|
1991
|
+
this.window,
|
|
1992
|
+
y
|
|
1947
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);
|
|
1948
1994
|
}
|
|
1949
|
-
static configure(e, o, r, s) {
|
|
1950
|
-
new
|
|
1995
|
+
static configure(e, o, r, s, h, n) {
|
|
1996
|
+
new Q(
|
|
1951
1997
|
e,
|
|
1952
1998
|
o,
|
|
1953
1999
|
r,
|
|
1954
|
-
s
|
|
2000
|
+
s,
|
|
2001
|
+
h,
|
|
2002
|
+
n
|
|
1955
2003
|
);
|
|
1956
2004
|
}
|
|
1957
2005
|
scheduleLoadAreaAroundViewport() {
|
|
@@ -1960,25 +2008,329 @@ class K {
|
|
|
1960
2008
|
});
|
|
1961
2009
|
}
|
|
1962
2010
|
scheduleEnsureViewportAreaLoaded() {
|
|
1963
|
-
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,
|
|
1964
|
-
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();
|
|
1965
2013
|
}
|
|
1966
2014
|
loadAreaAroundViewport() {
|
|
1967
|
-
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,
|
|
1968
|
-
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 });
|
|
2017
|
+
}
|
|
2018
|
+
}
|
|
2019
|
+
const He = () => {
|
|
2020
|
+
const t = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
2021
|
+
return t.style.position = "absolute", t.style.inset = "0", t;
|
|
2022
|
+
}, je = () => {
|
|
2023
|
+
const t = document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
|
2024
|
+
return t.setAttribute("fill", "url(#pattern)"), t;
|
|
2025
|
+
}, Ge = () => {
|
|
2026
|
+
const t = document.createElementNS(
|
|
2027
|
+
"http://www.w3.org/2000/svg",
|
|
2028
|
+
"pattern"
|
|
2029
|
+
);
|
|
2030
|
+
return t.setAttribute("id", "pattern"), t;
|
|
2031
|
+
}, Je = (t, e) => {
|
|
2032
|
+
const o = document.createElementNS(
|
|
2033
|
+
"http://www.w3.org/2000/svg",
|
|
2034
|
+
"circle"
|
|
2035
|
+
);
|
|
2036
|
+
return o.setAttribute("cx", "0"), o.setAttribute("cy", "0"), o.setAttribute("r", `${t}`), o.setAttribute("fill", `${e}`), o;
|
|
2037
|
+
}, Ke = (t) => t instanceof SVGElement ? t : Je(
|
|
2038
|
+
(t == null ? void 0 : t.radius) ?? 1.5,
|
|
2039
|
+
(t == null ? void 0 : t.color) ?? "#d8d8d8"
|
|
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 ?? {});
|
|
2042
|
+
return {
|
|
2043
|
+
tileWidth: o,
|
|
2044
|
+
tileHeight: r,
|
|
2045
|
+
renderer: s,
|
|
2046
|
+
maxViewportScale: t.maxViewportScale ?? 10
|
|
2047
|
+
};
|
|
2048
|
+
};
|
|
2049
|
+
class Z {
|
|
2050
|
+
constructor(e, o, r) {
|
|
2051
|
+
i(this, "svg", He());
|
|
2052
|
+
i(this, "patternRenderingRectangle", je());
|
|
2053
|
+
i(this, "pattern", Ge());
|
|
2054
|
+
i(this, "patternContent");
|
|
2055
|
+
i(this, "tileWidth");
|
|
2056
|
+
i(this, "tileHeight");
|
|
2057
|
+
i(this, "halfTileWidth");
|
|
2058
|
+
i(this, "halfTileHeight");
|
|
2059
|
+
i(this, "maxViewportScale");
|
|
2060
|
+
i(this, "visible", !1);
|
|
2061
|
+
i(this, "resizeObserver", new ResizeObserver((e) => {
|
|
2062
|
+
const o = e[0], { width: r, height: s } = o.contentRect;
|
|
2063
|
+
this.svg.setAttribute("width", `${r}`), this.svg.setAttribute("height", `${s}`), this.patternRenderingRectangle.setAttribute("width", `${r}`), this.patternRenderingRectangle.setAttribute("height", `${s}`);
|
|
2064
|
+
const h = this.tileWidth / r, n = this.tileHeight / s;
|
|
2065
|
+
this.pattern.setAttribute("width", `${h}`), this.pattern.setAttribute("height", `${n}`);
|
|
2066
|
+
}));
|
|
2067
|
+
i(this, "onAfterTransformUpdated", () => {
|
|
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})`;
|
|
2069
|
+
this.pattern.setAttribute("patternTransform", s), this.updateVisibility();
|
|
2070
|
+
});
|
|
2071
|
+
i(this, "onBeforeDestroy", () => {
|
|
2072
|
+
this.resizeObserver.unobserve(this.host), this.host.removeChild(this.svg), this.canvas.viewport.onAfterUpdated.unsubscribe(
|
|
2073
|
+
this.onAfterTransformUpdated
|
|
2074
|
+
), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy);
|
|
2075
|
+
});
|
|
2076
|
+
this.canvas = e, this.host = r;
|
|
2077
|
+
const s = Qe(o);
|
|
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;
|
|
2079
|
+
const h = `translate(${this.halfTileWidth}, ${this.halfTileHeight})`;
|
|
2080
|
+
this.patternContent.setAttribute("transform", h), this.pattern.appendChild(this.patternContent);
|
|
2081
|
+
const n = document.createElementNS("http://www.w3.org/2000/svg", "defs");
|
|
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);
|
|
2083
|
+
}
|
|
2084
|
+
static configure(e, o, r) {
|
|
2085
|
+
new Z(e, o, r);
|
|
2086
|
+
}
|
|
2087
|
+
updateVisibility() {
|
|
2088
|
+
const o = this.canvas.viewport.getViewportMatrix().scale > this.maxViewportScale;
|
|
2089
|
+
o && this.visible ? (this.visible = !1, this.host.removeChild(this.svg)) : !o && !this.visible && (this.visible = !0, this.host.appendChild(this.svg));
|
|
1969
2090
|
}
|
|
1970
2091
|
}
|
|
1971
|
-
|
|
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 = () => {
|
|
2300
|
+
const t = document.createElement("div");
|
|
2301
|
+
return t.style.width = "100%", t.style.height = "100%", t.style.position = "relative", t;
|
|
2302
|
+
}, X = () => {
|
|
2303
|
+
const t = document.createElement("div");
|
|
2304
|
+
return t.style.position = "absolute", t.style.inset = "0", t;
|
|
2305
|
+
};
|
|
2306
|
+
class ot {
|
|
2307
|
+
constructor(e) {
|
|
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);
|
|
2313
|
+
}
|
|
2314
|
+
destroy() {
|
|
2315
|
+
this.host.removeChild(this.background), this.host.removeChild(this.main), this.host.removeChild(this.overlay), this.element.removeChild(this.host);
|
|
2316
|
+
}
|
|
2317
|
+
}
|
|
2318
|
+
class it {
|
|
1972
2319
|
constructor() {
|
|
1973
2320
|
i(this, "element", null);
|
|
1974
2321
|
i(this, "canvasDefaults", {});
|
|
1975
2322
|
i(this, "dragOptions", {});
|
|
1976
2323
|
i(this, "transformOptions", {});
|
|
2324
|
+
i(this, "backgroundOptions", {});
|
|
2325
|
+
i(this, "connectablePortsOptions", {});
|
|
1977
2326
|
i(this, "virtualScrollOptions");
|
|
1978
2327
|
i(this, "hasDraggableNode", !1);
|
|
1979
2328
|
i(this, "hasTransformableViewport", !1);
|
|
1980
2329
|
i(this, "hasResizeReactiveNodes", !1);
|
|
2330
|
+
i(this, "hasBackground", !1);
|
|
2331
|
+
i(this, "hasUserConnectablePorts", !1);
|
|
1981
2332
|
i(this, "boxRenderingTrigger");
|
|
2333
|
+
i(this, "window", window);
|
|
1982
2334
|
}
|
|
1983
2335
|
setElement(e) {
|
|
1984
2336
|
return this.element = e, this;
|
|
@@ -2013,9 +2365,25 @@ class ze {
|
|
|
2013
2365
|
enableBoxAreaRendering(e) {
|
|
2014
2366
|
return this.boxRenderingTrigger = e, this;
|
|
2015
2367
|
}
|
|
2368
|
+
/**
|
|
2369
|
+
* enables built-in virtual scroll behavior, when only nodes and edges close
|
|
2370
|
+
* to viewport are rendered
|
|
2371
|
+
*/
|
|
2016
2372
|
enableVirtualScroll(e) {
|
|
2017
2373
|
return this.virtualScrollOptions = e, this;
|
|
2018
2374
|
}
|
|
2375
|
+
/**
|
|
2376
|
+
* enables built-in background rendering
|
|
2377
|
+
*/
|
|
2378
|
+
enableBackground(e) {
|
|
2379
|
+
return this.hasBackground = !0, this.backgroundOptions = e ?? {}, this;
|
|
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
|
+
}
|
|
2019
2387
|
/**
|
|
2020
2388
|
* builds final canvas
|
|
2021
2389
|
*/
|
|
@@ -2025,41 +2393,67 @@ class ze {
|
|
|
2025
2393
|
"unable to build canvas when no attach element specified"
|
|
2026
2394
|
);
|
|
2027
2395
|
let e = this.boxRenderingTrigger;
|
|
2028
|
-
this.virtualScrollOptions !== void 0 && e === void 0 && (e = new
|
|
2029
|
-
const o = new
|
|
2030
|
-
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(
|
|
2031
2399
|
o,
|
|
2032
2400
|
r,
|
|
2033
|
-
|
|
2401
|
+
s.main
|
|
2034
2402
|
);
|
|
2035
|
-
e !== void 0 && (
|
|
2036
|
-
const
|
|
2403
|
+
e !== void 0 && (h = new ye(h, o, e));
|
|
2404
|
+
const n = new de(
|
|
2037
2405
|
this.element,
|
|
2038
2406
|
o,
|
|
2039
2407
|
r,
|
|
2040
|
-
|
|
2408
|
+
h,
|
|
2041
2409
|
this.canvasDefaults
|
|
2042
|
-
)
|
|
2043
|
-
|
|
2044
|
-
|
|
2410
|
+
), d = () => {
|
|
2411
|
+
s.destroy(), n.onBeforeDestroy.unsubscribe(d);
|
|
2412
|
+
};
|
|
2413
|
+
return n.onBeforeDestroy.subscribe(d), this.hasBackground && Z.configure(
|
|
2414
|
+
n,
|
|
2415
|
+
this.backgroundOptions,
|
|
2416
|
+
s.background
|
|
2417
|
+
), this.hasResizeReactiveNodes && J.configure(n), this.hasDraggableNode && K.configure(
|
|
2418
|
+
n,
|
|
2419
|
+
s.main,
|
|
2420
|
+
this.window,
|
|
2421
|
+
this.dragOptions
|
|
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(
|
|
2430
|
+
n,
|
|
2431
|
+
s.main,
|
|
2432
|
+
this.window,
|
|
2045
2433
|
this.transformOptions,
|
|
2046
2434
|
e,
|
|
2047
2435
|
this.virtualScrollOptions
|
|
2048
|
-
) : this.hasTransformableViewport &&
|
|
2049
|
-
|
|
2436
|
+
) : this.hasTransformableViewport && k.configure(
|
|
2437
|
+
n,
|
|
2438
|
+
s.main,
|
|
2439
|
+
this.window,
|
|
2050
2440
|
this.transformOptions
|
|
2051
|
-
), this.reset(),
|
|
2441
|
+
), this.reset(), n;
|
|
2052
2442
|
}
|
|
2443
|
+
/**
|
|
2444
|
+
* @deprecated
|
|
2445
|
+
* CanvasBuilder should be single use object
|
|
2446
|
+
*/
|
|
2053
2447
|
reset() {
|
|
2054
|
-
this.element = null, this.canvasDefaults = {}, this.dragOptions = {}, this.transformOptions = {}, this.virtualScrollOptions = void 0, this.hasDraggableNode = !1, this.hasTransformableViewport = !1, this.hasResizeReactiveNodes = !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;
|
|
2055
2449
|
}
|
|
2056
2450
|
}
|
|
2057
2451
|
export {
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2452
|
+
De as BezierEdgeShape,
|
|
2453
|
+
it as CanvasBuilder,
|
|
2454
|
+
he as EventSubject,
|
|
2455
|
+
Me as HorizontalEdgeShape,
|
|
2062
2456
|
S as HtmlGraphError,
|
|
2063
|
-
|
|
2064
|
-
|
|
2457
|
+
Ce as StraightEdgeShape,
|
|
2458
|
+
Ve as VerticalEdgeShape
|
|
2065
2459
|
};
|