@html-graph/html-graph 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.d.ts +123 -88
- package/dist/main.js +496 -356
- package/dist/main.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var i = (t, e, r) =>
|
|
4
|
-
const
|
|
1
|
+
var le = Object.defineProperty;
|
|
2
|
+
var ge = (t, e, r) => e in t ? le(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
3
|
+
var i = (t, e, r) => ge(t, typeof e != "symbol" ? e + "" : e, r);
|
|
4
|
+
const O = (t, e) => ({
|
|
5
5
|
x: t / 2,
|
|
6
6
|
y: e / 2
|
|
7
7
|
}), v = (t, e, r) => ({
|
|
8
8
|
x: e.x * t.x - e.y * t.y + ((1 - e.x) * r.x + e.y * r.y),
|
|
9
9
|
y: e.y * t.x + e.x * t.y + ((1 - e.x) * r.y - e.y * r.x)
|
|
10
|
-
}),
|
|
10
|
+
}), N = (t, e, r) => ({ x: e * Math.cos(t), y: r * Math.sin(t) }), w = {
|
|
11
11
|
x: 0,
|
|
12
12
|
y: 0
|
|
13
13
|
}, T = (t, e, r, o) => {
|
|
@@ -15,56 +15,56 @@ const q = (t, e) => ({
|
|
|
15
15
|
w,
|
|
16
16
|
{ x: r, y: o },
|
|
17
17
|
{ x: r, y: -o }
|
|
18
|
-
].map((a) => v(a, t, w)).map((a) => ({ x: a.x + e.x, y: a.y + e.y })),
|
|
19
|
-
return `${
|
|
18
|
+
].map((a) => v(a, t, w)).map((a) => ({ x: a.x + e.x, y: a.y + e.y })), s = `M ${d[0].x} ${d[0].y}`, h = `L ${d[1].x} ${d[1].y}`, c = `L ${d[2].x} ${d[2].y}`;
|
|
19
|
+
return `${s} ${h} ${c}`;
|
|
20
20
|
}, U = (t, e) => {
|
|
21
21
|
const r = [];
|
|
22
22
|
if (t.length > 0 && r.push(`M ${t[0].x} ${t[0].y}`), t.length === 2 && r.push(`L ${t[1].x} ${t[1].y}`), t.length > 2) {
|
|
23
23
|
const o = t.length - 1;
|
|
24
|
-
let
|
|
24
|
+
let n = 0, d = 0, s = 0;
|
|
25
25
|
t.forEach((h, c) => {
|
|
26
26
|
let a = 0, l = 0, g = 0;
|
|
27
27
|
const f = c > 0, x = c < o, y = f && x;
|
|
28
|
-
if (f && (a = -
|
|
29
|
-
const
|
|
30
|
-
|
|
28
|
+
if (f && (a = -n, l = -d, g = s), x) {
|
|
29
|
+
const L = t[c + 1];
|
|
30
|
+
n = L.x - h.x, d = L.y - h.y, s = Math.sqrt(n * n + d * d);
|
|
31
31
|
}
|
|
32
|
-
const E =
|
|
32
|
+
const E = s !== 0 ? Math.min((y ? e : 0) / s, c < o - 1 ? 0.5 : 1) : 0, m = y ? { x: h.x + n * E, y: h.y + d * E } : h, P = g !== 0 ? Math.min((y ? e : 0) / g, c > 1 ? 0.5 : 1) : 0, V = y ? { x: h.x + a * P, y: h.y + l * P } : h;
|
|
33
33
|
c > 0 && r.push(`L ${V.x} ${V.y}`), y && r.push(
|
|
34
|
-
`C ${h.x} ${h.y} ${h.x} ${h.y} ${
|
|
34
|
+
`C ${h.x} ${h.y} ${h.x} ${h.y} ${m.x} ${m.y}`
|
|
35
35
|
);
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
return r.join(" ");
|
|
39
|
-
},
|
|
39
|
+
}, k = () => {
|
|
40
40
|
const t = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
41
41
|
return t.style.pointerEvents = "none", t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.overflow = "visible", t;
|
|
42
|
-
},
|
|
42
|
+
}, Y = () => {
|
|
43
43
|
const t = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
|
44
44
|
return t.style.transformOrigin = "50% 50%", t;
|
|
45
|
-
},
|
|
45
|
+
}, X = (t, e) => {
|
|
46
46
|
const r = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
47
47
|
return r.setAttribute("stroke", t), r.setAttribute("stroke-width", `${e}`), r.setAttribute("fill", "none"), r;
|
|
48
|
-
},
|
|
48
|
+
}, M = (t) => {
|
|
49
49
|
const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
50
50
|
return e.setAttribute("fill", t), e;
|
|
51
|
-
},
|
|
51
|
+
}, z = (t, e) => {
|
|
52
52
|
const r = {
|
|
53
53
|
x: t.x + t.width / 2,
|
|
54
54
|
y: t.y + t.height / 2
|
|
55
55
|
}, o = {
|
|
56
56
|
x: e.x + e.width / 2,
|
|
57
57
|
y: e.y + e.height / 2
|
|
58
|
-
},
|
|
58
|
+
}, n = Math.min(r.x, o.x), d = Math.min(r.y, o.y), s = Math.abs(o.x - r.x), h = Math.abs(o.y - r.y), c = r.x <= o.x ? 1 : -1, a = r.y <= o.y ? 1 : -1;
|
|
59
59
|
return {
|
|
60
|
-
x:
|
|
60
|
+
x: n,
|
|
61
61
|
y: d,
|
|
62
|
-
width:
|
|
62
|
+
width: s,
|
|
63
63
|
height: h,
|
|
64
64
|
flipX: c,
|
|
65
65
|
flipY: a
|
|
66
66
|
};
|
|
67
|
-
},
|
|
67
|
+
}, ue = (t) => {
|
|
68
68
|
const e = v(
|
|
69
69
|
{ x: t.arrowLength, y: w.y },
|
|
70
70
|
t.fromVect,
|
|
@@ -76,12 +76,12 @@ const q = (t, e) => ({
|
|
|
76
76
|
), o = {
|
|
77
77
|
x: e.x + t.fromVect.x * t.curvature,
|
|
78
78
|
y: e.y + t.fromVect.y * t.curvature
|
|
79
|
-
},
|
|
79
|
+
}, n = {
|
|
80
80
|
x: r.x - t.toVect.x * t.curvature,
|
|
81
81
|
y: r.y - t.toVect.y * t.curvature
|
|
82
|
-
}, d = `M ${e.x} ${e.y} C ${o.x} ${o.y}, ${
|
|
83
|
-
return `${
|
|
84
|
-
},
|
|
82
|
+
}, d = `M ${e.x} ${e.y} C ${o.x} ${o.y}, ${n.x} ${n.y}, ${r.x} ${r.y}`, s = t.hasSourceArrow ? "" : `M ${w.x} ${w.y} L ${e.x} ${e.y} `, h = t.hasTargetArrow ? "" : ` M ${r.x} ${r.y} L ${t.to.x} ${t.to.y}`;
|
|
83
|
+
return `${s}${d}${h}`;
|
|
84
|
+
}, we = (t) => {
|
|
85
85
|
const e = t.hasSourceArrow ? v(
|
|
86
86
|
{ x: t.arrowLength, y: w.y },
|
|
87
87
|
t.fromVect,
|
|
@@ -90,19 +90,19 @@ const q = (t, e) => ({
|
|
|
90
90
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
91
91
|
t.toVect,
|
|
92
92
|
t.to
|
|
93
|
-
) : t.to, o = t.arrowLength,
|
|
93
|
+
) : t.to, o = t.arrowLength, n = Math.cos(t.detourDirection) * t.detourDistance, d = Math.sin(t.detourDirection) * t.detourDistance, s = n * t.flipX, h = d * t.flipY, c = v(
|
|
94
94
|
{ x: o, y: w.y },
|
|
95
95
|
t.fromVect,
|
|
96
96
|
w
|
|
97
97
|
), a = {
|
|
98
|
-
x: c.x +
|
|
98
|
+
x: c.x + s,
|
|
99
99
|
y: c.y + h
|
|
100
100
|
}, l = v(
|
|
101
101
|
{ x: t.to.x - o, y: t.to.y },
|
|
102
102
|
t.toVect,
|
|
103
103
|
t.to
|
|
104
104
|
), g = {
|
|
105
|
-
x: l.x +
|
|
105
|
+
x: l.x + s,
|
|
106
106
|
y: l.y + h
|
|
107
107
|
}, f = { x: (a.x + g.x) / 2, y: (a.y + g.y) / 2 }, x = {
|
|
108
108
|
x: c.x + t.curvature * t.fromVect.x,
|
|
@@ -110,21 +110,21 @@ const q = (t, e) => ({
|
|
|
110
110
|
}, y = {
|
|
111
111
|
x: l.x - t.curvature * t.toVect.x,
|
|
112
112
|
y: l.y - t.curvature * t.toVect.y
|
|
113
|
-
},
|
|
114
|
-
x: c.x +
|
|
113
|
+
}, p = {
|
|
114
|
+
x: c.x + s,
|
|
115
115
|
y: c.y + h
|
|
116
116
|
}, E = {
|
|
117
|
-
x: l.x +
|
|
117
|
+
x: l.x + s,
|
|
118
118
|
y: l.y + h
|
|
119
119
|
};
|
|
120
120
|
return [
|
|
121
121
|
`M ${e.x} ${e.y}`,
|
|
122
122
|
`L ${c.x} ${c.y}`,
|
|
123
|
-
`C ${x.x} ${x.y} ${
|
|
123
|
+
`C ${x.x} ${x.y} ${p.x} ${p.y} ${f.x} ${f.y}`,
|
|
124
124
|
`C ${E.x} ${E.y} ${y.x} ${y.y} ${l.x} ${l.y}`,
|
|
125
125
|
`L ${r.x} ${r.y}`
|
|
126
126
|
].join(" ");
|
|
127
|
-
},
|
|
127
|
+
}, fe = (t) => {
|
|
128
128
|
const e = t.hasSourceArrow ? v(
|
|
129
129
|
{ x: t.arrowLength, y: w.y },
|
|
130
130
|
t.fromVect,
|
|
@@ -133,16 +133,16 @@ const q = (t, e) => ({
|
|
|
133
133
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
134
134
|
t.toVect,
|
|
135
135
|
t.to
|
|
136
|
-
) : t.to, o = t.arrowLength + t.arrowOffset,
|
|
137
|
-
{ x: t.to.x -
|
|
136
|
+
) : t.to, o = t.arrowLength + t.arrowOffset, n = o - t.roundness, d = v({ x: n, y: w.y }, t.fromVect, w), s = v(
|
|
137
|
+
{ x: t.to.x - n, y: t.to.y },
|
|
138
138
|
t.toVect,
|
|
139
139
|
t.to
|
|
140
|
-
), h = Math.max((d.x +
|
|
140
|
+
), h = Math.max((d.x + s.x) / 2, o), c = t.to.y / 2, a = { x: t.flipX > 0 ? h : -o, y: d.y }, l = { x: a.x, y: c }, g = {
|
|
141
141
|
x: t.flipX > 0 ? t.to.x - h : t.to.x + o,
|
|
142
|
-
y:
|
|
142
|
+
y: s.y
|
|
143
143
|
}, f = { x: g.x, y: c };
|
|
144
144
|
return U(
|
|
145
|
-
[e, d, a, l, f, g,
|
|
145
|
+
[e, d, a, l, f, g, s, r],
|
|
146
146
|
t.roundness
|
|
147
147
|
);
|
|
148
148
|
}, j = (t) => {
|
|
@@ -154,20 +154,20 @@ const q = (t, e) => ({
|
|
|
154
154
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
155
155
|
t.toVect,
|
|
156
156
|
t.to
|
|
157
|
-
) : t.to, o = t.arrowLength + t.arrowOffset,
|
|
157
|
+
) : t.to, o = t.arrowLength + t.arrowOffset, n = v(
|
|
158
158
|
{ x: o, y: w.y },
|
|
159
159
|
t.fromVect,
|
|
160
160
|
w
|
|
161
|
-
), d = Math.cos(t.detourDirection) * t.detourDistance,
|
|
161
|
+
), d = Math.cos(t.detourDirection) * t.detourDistance, s = Math.sin(t.detourDirection) * t.detourDistance, h = d * t.flipX, c = s * t.flipY, a = { x: n.x + h, y: n.y + c }, l = v(
|
|
162
162
|
{ x: t.to.x - o, y: t.to.y },
|
|
163
163
|
t.toVect,
|
|
164
164
|
t.to
|
|
165
165
|
), g = { x: l.x + h, y: l.y + c };
|
|
166
166
|
return U(
|
|
167
|
-
[e,
|
|
167
|
+
[e, n, a, g, l, r],
|
|
168
168
|
t.roundness
|
|
169
169
|
);
|
|
170
|
-
},
|
|
170
|
+
}, ye = (t) => {
|
|
171
171
|
const e = t.hasSourceArrow ? v(
|
|
172
172
|
{ x: t.arrowLength, y: w.y },
|
|
173
173
|
t.fromVect,
|
|
@@ -176,13 +176,13 @@ const q = (t, e) => ({
|
|
|
176
176
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
177
177
|
t.toVect,
|
|
178
178
|
t.to
|
|
179
|
-
) : t.to, o = t.arrowLength + t.arrowOffset,
|
|
179
|
+
) : t.to, o = t.arrowLength + t.arrowOffset, n = v({ x: o, y: w.y }, t.fromVect, w), d = v(
|
|
180
180
|
{ x: t.to.x - o, y: t.to.y },
|
|
181
181
|
t.toVect,
|
|
182
182
|
t.to
|
|
183
183
|
);
|
|
184
|
-
return U([e,
|
|
185
|
-
},
|
|
184
|
+
return U([e, n, d, r], t.roundness);
|
|
185
|
+
}, ve = (t) => {
|
|
186
186
|
const e = t.hasSourceArrow ? v(
|
|
187
187
|
{ x: t.arrowLength, y: w.y },
|
|
188
188
|
t.fromVect,
|
|
@@ -191,37 +191,37 @@ const q = (t, e) => ({
|
|
|
191
191
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
192
192
|
t.toVect,
|
|
193
193
|
t.to
|
|
194
|
-
) : t.to, o = t.arrowLength + t.arrowOffset,
|
|
195
|
-
{ x: t.to.x -
|
|
194
|
+
) : t.to, o = t.arrowLength + t.arrowOffset, n = o - t.roundness, d = v({ x: n, y: w.y }, t.fromVect, w), s = v(
|
|
195
|
+
{ x: t.to.x - n, y: t.to.y },
|
|
196
196
|
t.toVect,
|
|
197
197
|
t.to
|
|
198
|
-
), h = Math.max((d.y +
|
|
199
|
-
x:
|
|
198
|
+
), h = Math.max((d.y + s.y) / 2, o), c = t.to.x / 2, a = { x: d.x, y: t.flipY > 0 ? h : -o }, l = { x: c, y: a.y }, g = {
|
|
199
|
+
x: s.x,
|
|
200
200
|
y: t.flipY > 0 ? t.to.y - h : t.to.y + o
|
|
201
201
|
}, f = { x: c, y: g.y };
|
|
202
202
|
return U(
|
|
203
|
-
[e, d, a, l, f, g,
|
|
203
|
+
[e, d, a, l, f, g, s, r],
|
|
204
204
|
t.roundness
|
|
205
205
|
);
|
|
206
|
-
},
|
|
207
|
-
const e = t.arrowOffset, r = t.side, o = t.arrowLength + e,
|
|
206
|
+
}, G = (t) => {
|
|
207
|
+
const e = t.arrowOffset, r = t.side, o = t.arrowLength + e, n = o + 2 * r, s = [
|
|
208
208
|
{ x: t.arrowLength, y: w.y },
|
|
209
209
|
{ x: o, y: w.y },
|
|
210
210
|
{ x: o, y: t.side },
|
|
211
|
-
{ x:
|
|
212
|
-
{ x:
|
|
211
|
+
{ x: n, y: t.side },
|
|
212
|
+
{ x: n, y: -t.side },
|
|
213
213
|
{ x: o, y: -t.side },
|
|
214
214
|
{ x: o, y: w.y },
|
|
215
215
|
{ x: t.arrowLength, y: w.y }
|
|
216
216
|
].map(
|
|
217
217
|
(c) => v(c, t.fromVect, w)
|
|
218
|
-
), h = `M ${w.x} ${w.y} L ${
|
|
219
|
-
return `${t.hasSourceArrow || t.hasTargetArrow ? "" : h}${U(
|
|
220
|
-
},
|
|
221
|
-
const e = t.smallRadius, r = t.radius, o = Math.sqrt(e * e + r * r),
|
|
218
|
+
), h = `M ${w.x} ${w.y} L ${s[0].x} ${s[0].y} `;
|
|
219
|
+
return `${t.hasSourceArrow || t.hasTargetArrow ? "" : h}${U(s, t.roundness)}`;
|
|
220
|
+
}, xe = (t) => {
|
|
221
|
+
const e = t.smallRadius, r = t.radius, o = Math.sqrt(e * e + r * r), n = e + r, d = t.arrowLength + o * (1 - r / n), s = e * r / n, c = [
|
|
222
222
|
{ x: t.arrowLength, y: w.y },
|
|
223
|
-
{ x: d, y:
|
|
224
|
-
{ x: d, y: -
|
|
223
|
+
{ x: d, y: s },
|
|
224
|
+
{ x: d, y: -s }
|
|
225
225
|
].map((g) => v(g, t.fromVect, w)), a = [
|
|
226
226
|
`M ${c[0].x} ${c[0].y}`,
|
|
227
227
|
`A ${e} ${e} 0 0 1 ${c[1].x} ${c[1].y}`,
|
|
@@ -246,10 +246,10 @@ const q = (t, e) => ({
|
|
|
246
246
|
smallCycleRadius: 15,
|
|
247
247
|
curvature: 90
|
|
248
248
|
});
|
|
249
|
-
class
|
|
249
|
+
class ee {
|
|
250
250
|
constructor(e) {
|
|
251
|
-
i(this, "svg",
|
|
252
|
-
i(this, "group",
|
|
251
|
+
i(this, "svg", k());
|
|
252
|
+
i(this, "group", Y());
|
|
253
253
|
i(this, "line");
|
|
254
254
|
i(this, "sourceArrow", null);
|
|
255
255
|
i(this, "targetArrow", null);
|
|
@@ -264,35 +264,35 @@ class O {
|
|
|
264
264
|
i(this, "hasTargetArrow");
|
|
265
265
|
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;
|
|
266
266
|
const r = (e == null ? void 0 : e.color) ?? u.color, o = (e == null ? void 0 : e.width) ?? u.width;
|
|
267
|
-
this.svg.appendChild(this.group), this.line =
|
|
267
|
+
this.svg.appendChild(this.group), this.line = X(r, o), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = M(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = M(r), this.group.appendChild(this.targetArrow));
|
|
268
268
|
}
|
|
269
269
|
render(e) {
|
|
270
|
-
const { x: r, y: o, width:
|
|
270
|
+
const { x: r, y: o, width: n, height: d, flipX: s, flipY: h } = z(
|
|
271
271
|
e.from,
|
|
272
272
|
e.to
|
|
273
273
|
);
|
|
274
|
-
this.svg.style.transform = `translate(${r}px, ${o}px)`, this.svg.style.width = `${
|
|
275
|
-
const c =
|
|
274
|
+
this.svg.style.transform = `translate(${r}px, ${o}px)`, this.svg.style.width = `${n}px`, this.svg.style.height = `${d}px`, this.group.style.transform = `scale(${s}, ${h})`;
|
|
275
|
+
const c = N(
|
|
276
276
|
e.from.direction,
|
|
277
|
-
|
|
277
|
+
s,
|
|
278
278
|
h
|
|
279
|
-
), a =
|
|
280
|
-
x:
|
|
279
|
+
), a = N(e.to.direction, s, h), l = {
|
|
280
|
+
x: n,
|
|
281
281
|
y: d
|
|
282
282
|
};
|
|
283
283
|
let g, f = a, x = -this.arrowLength;
|
|
284
|
-
if (e.from.portId === e.to.portId ? (g =
|
|
284
|
+
if (e.from.portId === e.to.portId ? (g = xe({
|
|
285
285
|
fromVect: c,
|
|
286
286
|
radius: this.portCycleRadius,
|
|
287
287
|
smallRadius: this.portCycleSmallRadius,
|
|
288
288
|
arrowLength: this.arrowLength,
|
|
289
289
|
hasSourceArrow: this.hasSourceArrow,
|
|
290
290
|
hasTargetArrow: this.hasTargetArrow
|
|
291
|
-
}), f = c, x = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g =
|
|
291
|
+
}), f = c, x = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = we({
|
|
292
292
|
to: l,
|
|
293
293
|
fromVect: c,
|
|
294
294
|
toVect: a,
|
|
295
|
-
flipX:
|
|
295
|
+
flipX: s,
|
|
296
296
|
flipY: h,
|
|
297
297
|
arrowLength: this.arrowLength,
|
|
298
298
|
detourDirection: this.detourDirection,
|
|
@@ -300,7 +300,7 @@ class O {
|
|
|
300
300
|
curvature: this.curvature,
|
|
301
301
|
hasSourceArrow: this.hasSourceArrow,
|
|
302
302
|
hasTargetArrow: this.hasTargetArrow
|
|
303
|
-
}) : g =
|
|
303
|
+
}) : g = ue({
|
|
304
304
|
to: l,
|
|
305
305
|
fromVect: c,
|
|
306
306
|
toVect: a,
|
|
@@ -328,10 +328,10 @@ class O {
|
|
|
328
328
|
}
|
|
329
329
|
}
|
|
330
330
|
}
|
|
331
|
-
class
|
|
331
|
+
class te {
|
|
332
332
|
constructor(e) {
|
|
333
|
-
i(this, "svg",
|
|
334
|
-
i(this, "group",
|
|
333
|
+
i(this, "svg", k());
|
|
334
|
+
i(this, "group", Y());
|
|
335
335
|
i(this, "line");
|
|
336
336
|
i(this, "sourceArrow", null);
|
|
337
337
|
i(this, "targetArrow", null);
|
|
@@ -351,25 +351,25 @@ class ee {
|
|
|
351
351
|
this.arrowOffset,
|
|
352
352
|
this.cycleSquareSide / 2
|
|
353
353
|
), 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;
|
|
354
|
-
const o = (e == null ? void 0 : e.color) ?? u.color,
|
|
355
|
-
this.svg.appendChild(this.group), this.line =
|
|
354
|
+
const o = (e == null ? void 0 : e.color) ?? u.color, n = (e == null ? void 0 : e.width) ?? u.width;
|
|
355
|
+
this.svg.appendChild(this.group), this.line = X(o, n), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = M(o), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = M(o), this.group.appendChild(this.targetArrow));
|
|
356
356
|
}
|
|
357
357
|
render(e) {
|
|
358
|
-
const { x: r, y: o, width:
|
|
358
|
+
const { x: r, y: o, width: n, height: d, flipX: s, flipY: h } = z(
|
|
359
359
|
e.from,
|
|
360
360
|
e.to
|
|
361
361
|
);
|
|
362
|
-
this.svg.style.transform = `translate(${r}px, ${o}px)`, this.svg.style.width = `${
|
|
363
|
-
const c =
|
|
362
|
+
this.svg.style.transform = `translate(${r}px, ${o}px)`, this.svg.style.width = `${n}px`, this.svg.style.height = `${d}px`, this.group.style.transform = `scale(${s}, ${h})`;
|
|
363
|
+
const c = N(
|
|
364
364
|
e.from.direction,
|
|
365
|
-
|
|
365
|
+
s,
|
|
366
366
|
h
|
|
367
|
-
), a =
|
|
368
|
-
x:
|
|
367
|
+
), a = N(e.to.direction, s, h), l = {
|
|
368
|
+
x: n,
|
|
369
369
|
y: d
|
|
370
370
|
};
|
|
371
371
|
let g, f = a, x = -this.arrowLength;
|
|
372
|
-
if (e.from.portId === e.to.portId ? (g =
|
|
372
|
+
if (e.from.portId === e.to.portId ? (g = G({
|
|
373
373
|
fromVect: c,
|
|
374
374
|
arrowLength: this.arrowLength,
|
|
375
375
|
side: this.cycleSquareSide,
|
|
@@ -381,7 +381,7 @@ class ee {
|
|
|
381
381
|
to: l,
|
|
382
382
|
fromVect: c,
|
|
383
383
|
toVect: a,
|
|
384
|
-
flipX:
|
|
384
|
+
flipX: s,
|
|
385
385
|
flipY: h,
|
|
386
386
|
arrowLength: this.arrowLength,
|
|
387
387
|
arrowOffset: this.arrowOffset,
|
|
@@ -390,11 +390,11 @@ class ee {
|
|
|
390
390
|
detourDistance: this.detourDistance,
|
|
391
391
|
hasSourceArrow: this.hasSourceArrow,
|
|
392
392
|
hasTargetArrow: this.hasTargetArrow
|
|
393
|
-
}) : g =
|
|
393
|
+
}) : g = fe({
|
|
394
394
|
to: l,
|
|
395
395
|
fromVect: c,
|
|
396
396
|
toVect: a,
|
|
397
|
-
flipX:
|
|
397
|
+
flipX: s,
|
|
398
398
|
arrowLength: this.arrowLength,
|
|
399
399
|
arrowOffset: this.arrowOffset,
|
|
400
400
|
roundness: this.roundness,
|
|
@@ -420,10 +420,10 @@ class ee {
|
|
|
420
420
|
}
|
|
421
421
|
}
|
|
422
422
|
}
|
|
423
|
-
class
|
|
423
|
+
class re {
|
|
424
424
|
constructor(e) {
|
|
425
|
-
i(this, "svg",
|
|
426
|
-
i(this, "group",
|
|
425
|
+
i(this, "svg", k());
|
|
426
|
+
i(this, "group", Y());
|
|
427
427
|
i(this, "line");
|
|
428
428
|
i(this, "sourceArrow", null);
|
|
429
429
|
i(this, "targetArrow", null);
|
|
@@ -443,25 +443,25 @@ class te {
|
|
|
443
443
|
this.arrowOffset,
|
|
444
444
|
this.cycleSquareSide / 2
|
|
445
445
|
), 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;
|
|
446
|
-
const o = (e == null ? void 0 : e.color) ?? u.color,
|
|
447
|
-
this.svg.appendChild(this.group), this.line =
|
|
446
|
+
const o = (e == null ? void 0 : e.color) ?? u.color, n = (e == null ? void 0 : e.width) ?? u.width;
|
|
447
|
+
this.svg.appendChild(this.group), this.line = X(o, n), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = M(o), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = M(o), this.group.appendChild(this.targetArrow));
|
|
448
448
|
}
|
|
449
449
|
render(e) {
|
|
450
|
-
const { x: r, y: o, width:
|
|
450
|
+
const { x: r, y: o, width: n, height: d, flipX: s, flipY: h } = z(
|
|
451
451
|
e.from,
|
|
452
452
|
e.to
|
|
453
453
|
);
|
|
454
|
-
this.svg.style.transform = `translate(${r}px, ${o}px)`, this.svg.style.width = `${
|
|
455
|
-
const c =
|
|
454
|
+
this.svg.style.transform = `translate(${r}px, ${o}px)`, this.svg.style.width = `${n}px`, this.svg.style.height = `${d}px`, this.group.style.transform = `scale(${s}, ${h})`;
|
|
455
|
+
const c = N(
|
|
456
456
|
e.from.direction,
|
|
457
|
-
|
|
457
|
+
s,
|
|
458
458
|
h
|
|
459
|
-
), a =
|
|
460
|
-
x:
|
|
459
|
+
), a = N(e.to.direction, s, h), l = {
|
|
460
|
+
x: n,
|
|
461
461
|
y: d
|
|
462
462
|
};
|
|
463
463
|
let g, f = a, x = -this.arrowLength;
|
|
464
|
-
if (e.from.portId === e.to.portId ? (g =
|
|
464
|
+
if (e.from.portId === e.to.portId ? (g = G({
|
|
465
465
|
fromVect: c,
|
|
466
466
|
arrowLength: this.arrowLength,
|
|
467
467
|
side: this.cycleSquareSide,
|
|
@@ -473,7 +473,7 @@ class te {
|
|
|
473
473
|
to: l,
|
|
474
474
|
fromVect: c,
|
|
475
475
|
toVect: a,
|
|
476
|
-
flipX:
|
|
476
|
+
flipX: s,
|
|
477
477
|
flipY: h,
|
|
478
478
|
arrowLength: this.arrowLength,
|
|
479
479
|
arrowOffset: this.arrowOffset,
|
|
@@ -482,7 +482,7 @@ class te {
|
|
|
482
482
|
detourDistance: this.detourDistance,
|
|
483
483
|
hasSourceArrow: this.hasSourceArrow,
|
|
484
484
|
hasTargetArrow: this.hasTargetArrow
|
|
485
|
-
}) : g =
|
|
485
|
+
}) : g = ye({
|
|
486
486
|
to: l,
|
|
487
487
|
fromVect: c,
|
|
488
488
|
toVect: a,
|
|
@@ -511,10 +511,10 @@ class te {
|
|
|
511
511
|
}
|
|
512
512
|
}
|
|
513
513
|
}
|
|
514
|
-
class
|
|
514
|
+
class oe {
|
|
515
515
|
constructor(e) {
|
|
516
|
-
i(this, "svg",
|
|
517
|
-
i(this, "group",
|
|
516
|
+
i(this, "svg", k());
|
|
517
|
+
i(this, "group", Y());
|
|
518
518
|
i(this, "line");
|
|
519
519
|
i(this, "sourceArrow", null);
|
|
520
520
|
i(this, "targetArrow", null);
|
|
@@ -534,25 +534,25 @@ class re {
|
|
|
534
534
|
this.arrowOffset,
|
|
535
535
|
this.cycleSquareSide / 2
|
|
536
536
|
), 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;
|
|
537
|
-
const o = (e == null ? void 0 : e.color) ?? u.color,
|
|
538
|
-
this.svg.appendChild(this.group), this.line =
|
|
537
|
+
const o = (e == null ? void 0 : e.color) ?? u.color, n = (e == null ? void 0 : e.width) ?? u.width;
|
|
538
|
+
this.svg.appendChild(this.group), this.line = X(o, n), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = M(o), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = M(o), this.group.appendChild(this.targetArrow));
|
|
539
539
|
}
|
|
540
540
|
render(e) {
|
|
541
|
-
const { x: r, y: o, width:
|
|
541
|
+
const { x: r, y: o, width: n, height: d, flipX: s, flipY: h } = z(
|
|
542
542
|
e.from,
|
|
543
543
|
e.to
|
|
544
544
|
);
|
|
545
|
-
this.svg.style.transform = `translate(${r}px, ${o}px)`, this.svg.style.width = `${
|
|
546
|
-
const c =
|
|
545
|
+
this.svg.style.transform = `translate(${r}px, ${o}px)`, this.svg.style.width = `${n}px`, this.svg.style.height = `${d}px`, this.group.style.transform = `scale(${s}, ${h})`;
|
|
546
|
+
const c = N(
|
|
547
547
|
e.from.direction,
|
|
548
|
-
|
|
548
|
+
s,
|
|
549
549
|
h
|
|
550
|
-
), a =
|
|
551
|
-
x:
|
|
550
|
+
), a = N(e.to.direction, s, h), l = {
|
|
551
|
+
x: n,
|
|
552
552
|
y: d
|
|
553
553
|
};
|
|
554
554
|
let g, f = a, x = -this.arrowLength;
|
|
555
|
-
if (e.from.portId === e.to.portId ? (g =
|
|
555
|
+
if (e.from.portId === e.to.portId ? (g = G({
|
|
556
556
|
fromVect: c,
|
|
557
557
|
arrowLength: this.arrowLength,
|
|
558
558
|
side: this.cycleSquareSide,
|
|
@@ -564,7 +564,7 @@ class re {
|
|
|
564
564
|
to: l,
|
|
565
565
|
fromVect: c,
|
|
566
566
|
toVect: a,
|
|
567
|
-
flipX:
|
|
567
|
+
flipX: s,
|
|
568
568
|
flipY: h,
|
|
569
569
|
arrowLength: this.arrowLength,
|
|
570
570
|
arrowOffset: this.arrowOffset,
|
|
@@ -573,7 +573,7 @@ class re {
|
|
|
573
573
|
detourDistance: this.detourDistance,
|
|
574
574
|
hasSourceArrow: this.hasSourceArrow,
|
|
575
575
|
hasTargetArrow: this.hasTargetArrow
|
|
576
|
-
}) : g =
|
|
576
|
+
}) : g = ve({
|
|
577
577
|
to: l,
|
|
578
578
|
fromVect: c,
|
|
579
579
|
toVect: a,
|
|
@@ -603,12 +603,12 @@ class re {
|
|
|
603
603
|
}
|
|
604
604
|
}
|
|
605
605
|
}
|
|
606
|
-
const
|
|
606
|
+
const Ae = (t) => {
|
|
607
607
|
if (typeof t == "function")
|
|
608
608
|
return t;
|
|
609
609
|
switch (t == null ? void 0 : t.type) {
|
|
610
610
|
case "straight":
|
|
611
|
-
return () => new
|
|
611
|
+
return () => new re({
|
|
612
612
|
color: t.color,
|
|
613
613
|
width: t.width,
|
|
614
614
|
arrowLength: t.arrowLength,
|
|
@@ -622,7 +622,7 @@ const ye = (t) => {
|
|
|
622
622
|
detourDirection: t.detourDirection
|
|
623
623
|
});
|
|
624
624
|
case "horizontal":
|
|
625
|
-
return () => new
|
|
625
|
+
return () => new te({
|
|
626
626
|
color: t.color,
|
|
627
627
|
width: t.width,
|
|
628
628
|
arrowLength: t.arrowLength,
|
|
@@ -636,7 +636,7 @@ const ye = (t) => {
|
|
|
636
636
|
detourDirection: t.detourDirection
|
|
637
637
|
});
|
|
638
638
|
case "vertical":
|
|
639
|
-
return () => new
|
|
639
|
+
return () => new oe({
|
|
640
640
|
color: t.color,
|
|
641
641
|
width: t.width,
|
|
642
642
|
arrowLength: t.arrowLength,
|
|
@@ -650,7 +650,7 @@ const ye = (t) => {
|
|
|
650
650
|
detourDirection: t.detourDirection
|
|
651
651
|
});
|
|
652
652
|
default:
|
|
653
|
-
return () => new
|
|
653
|
+
return () => new ee({
|
|
654
654
|
color: t.color,
|
|
655
655
|
width: t.width,
|
|
656
656
|
arrowLength: t.arrowLength,
|
|
@@ -664,38 +664,38 @@ const ye = (t) => {
|
|
|
664
664
|
detourDirection: t.detourDirection
|
|
665
665
|
});
|
|
666
666
|
}
|
|
667
|
-
}, $ = (t) => () => t, I = $(0),
|
|
667
|
+
}, $ = (t) => () => t, I = $(0), C = () => {
|
|
668
668
|
let t = 0;
|
|
669
669
|
return () => t++;
|
|
670
|
-
},
|
|
670
|
+
}, Ee = (t, e) => {
|
|
671
671
|
let r = I, o = I;
|
|
672
|
-
t === "incremental" && (r =
|
|
673
|
-
const
|
|
674
|
-
return t === "shared-incremental" && (r =
|
|
672
|
+
t === "incremental" && (r = C()), e === "incremental" && (o = C());
|
|
673
|
+
const n = C();
|
|
674
|
+
return t === "shared-incremental" && (r = n), e === "shared-incremental" && (o = n), typeof t == "number" && (r = $(t)), typeof e == "number" && (o = $(e)), typeof t == "function" && (r = t), typeof e == "function" && (o = e), {
|
|
675
675
|
nodesPriorityFn: r,
|
|
676
676
|
edgesPriorityFn: o
|
|
677
677
|
};
|
|
678
|
-
},
|
|
679
|
-
var r, o,
|
|
680
|
-
const e =
|
|
678
|
+
}, Se = (t) => {
|
|
679
|
+
var r, o, n, d, s;
|
|
680
|
+
const e = Ee(
|
|
681
681
|
(r = t == null ? void 0 : t.nodes) == null ? void 0 : r.priority,
|
|
682
682
|
(o = t == null ? void 0 : t.edges) == null ? void 0 : o.priority
|
|
683
683
|
);
|
|
684
684
|
return {
|
|
685
685
|
nodes: {
|
|
686
|
-
centerFn: ((
|
|
686
|
+
centerFn: ((n = t == null ? void 0 : t.nodes) == null ? void 0 : n.centerFn) ?? O,
|
|
687
687
|
priorityFn: e.nodesPriorityFn
|
|
688
688
|
},
|
|
689
689
|
ports: {
|
|
690
690
|
direction: ((d = t == null ? void 0 : t.ports) == null ? void 0 : d.direction) ?? 0
|
|
691
691
|
},
|
|
692
692
|
edges: {
|
|
693
|
-
shapeFactory:
|
|
693
|
+
shapeFactory: Ae(((s = t == null ? void 0 : t.edges) == null ? void 0 : s.shape) ?? {}),
|
|
694
694
|
priorityFn: e.edgesPriorityFn
|
|
695
695
|
}
|
|
696
696
|
};
|
|
697
697
|
};
|
|
698
|
-
class
|
|
698
|
+
class ie {
|
|
699
699
|
constructor() {
|
|
700
700
|
i(this, "nodes", /* @__PURE__ */ new Map());
|
|
701
701
|
i(this, "ports", /* @__PURE__ */ new Map());
|
|
@@ -783,8 +783,8 @@ class oe {
|
|
|
783
783
|
return this.edges.get(e);
|
|
784
784
|
}
|
|
785
785
|
removeEdge(e) {
|
|
786
|
-
const r = this.edges.get(e), o = r.from,
|
|
787
|
-
this.cycleEdges.get(o).delete(e), this.cycleEdges.get(
|
|
786
|
+
const r = this.edges.get(e), o = r.from, n = r.to;
|
|
787
|
+
this.cycleEdges.get(o).delete(e), this.cycleEdges.get(n).delete(e), this.incommingEdges.get(o).delete(e), this.incommingEdges.get(n).delete(e), this.outcommingEdges.get(o).delete(e), this.outcommingEdges.get(n).delete(e), this.edges.delete(e);
|
|
788
788
|
}
|
|
789
789
|
clear() {
|
|
790
790
|
this.edges.clear(), this.incommingEdges.clear(), this.outcommingEdges.clear(), this.cycleEdges.clear(), this.ports.clear(), this.nodePorts.clear(), this.portNodeId.clear(), this.nodes.clear();
|
|
@@ -808,22 +808,22 @@ class oe {
|
|
|
808
808
|
getNodeIncomingEdgeIds(e) {
|
|
809
809
|
const r = Array.from(this.nodePorts.get(e).keys());
|
|
810
810
|
let o = [];
|
|
811
|
-
return r.forEach((
|
|
812
|
-
o = [...o, ...this.getPortIncomingEdgeIds(
|
|
811
|
+
return r.forEach((n) => {
|
|
812
|
+
o = [...o, ...this.getPortIncomingEdgeIds(n)];
|
|
813
813
|
}), o;
|
|
814
814
|
}
|
|
815
815
|
getNodeOutcomingEdgeIds(e) {
|
|
816
816
|
const r = Array.from(this.nodePorts.get(e).keys());
|
|
817
817
|
let o = [];
|
|
818
|
-
return r.forEach((
|
|
819
|
-
o = [...o, ...this.getPortOutcomingEdgeIds(
|
|
818
|
+
return r.forEach((n) => {
|
|
819
|
+
o = [...o, ...this.getPortOutcomingEdgeIds(n)];
|
|
820
820
|
}), o;
|
|
821
821
|
}
|
|
822
822
|
getNodeCycleEdgeIds(e) {
|
|
823
823
|
const r = Array.from(this.nodePorts.get(e).keys());
|
|
824
824
|
let o = [];
|
|
825
|
-
return r.forEach((
|
|
826
|
-
o = [...o, ...this.getPortCycleEdgeIds(
|
|
825
|
+
return r.forEach((n) => {
|
|
826
|
+
o = [...o, ...this.getPortCycleEdgeIds(n)];
|
|
827
827
|
}), o;
|
|
828
828
|
}
|
|
829
829
|
getNodeAdjacentEdgeIds(e) {
|
|
@@ -834,7 +834,7 @@ class oe {
|
|
|
834
834
|
];
|
|
835
835
|
}
|
|
836
836
|
}
|
|
837
|
-
class
|
|
837
|
+
class se {
|
|
838
838
|
constructor() {
|
|
839
839
|
i(this, "callbacks", /* @__PURE__ */ new Set());
|
|
840
840
|
}
|
|
@@ -851,21 +851,21 @@ class Ae {
|
|
|
851
851
|
}
|
|
852
852
|
}
|
|
853
853
|
const S = () => {
|
|
854
|
-
const t = new
|
|
854
|
+
const t = new se();
|
|
855
855
|
return [t, t];
|
|
856
|
-
},
|
|
856
|
+
}, Q = (t) => ({
|
|
857
857
|
scale: 1 / t.scale,
|
|
858
858
|
x: -t.x / t.scale,
|
|
859
859
|
y: -t.y / t.scale
|
|
860
|
-
}),
|
|
860
|
+
}), Z = {
|
|
861
861
|
scale: 1,
|
|
862
862
|
x: 0,
|
|
863
863
|
y: 0
|
|
864
864
|
};
|
|
865
|
-
class
|
|
865
|
+
class ne {
|
|
866
866
|
constructor() {
|
|
867
|
-
i(this, "viewportMatrix",
|
|
868
|
-
i(this, "contentMatrix",
|
|
867
|
+
i(this, "viewportMatrix", Z);
|
|
868
|
+
i(this, "contentMatrix", Z);
|
|
869
869
|
i(this, "emitter");
|
|
870
870
|
i(this, "onAfterUpdate");
|
|
871
871
|
[this.emitter, this.onAfterUpdate] = S();
|
|
@@ -881,17 +881,17 @@ class ie {
|
|
|
881
881
|
scale: e.scale ?? this.viewportMatrix.scale,
|
|
882
882
|
x: e.x ?? this.viewportMatrix.x,
|
|
883
883
|
y: e.y ?? this.viewportMatrix.y
|
|
884
|
-
}, this.contentMatrix =
|
|
884
|
+
}, this.contentMatrix = Q(this.viewportMatrix), this.emitter.emit();
|
|
885
885
|
}
|
|
886
886
|
patchContentMatrix(e) {
|
|
887
887
|
this.contentMatrix = {
|
|
888
888
|
scale: e.scale ?? this.contentMatrix.scale,
|
|
889
889
|
x: e.x ?? this.contentMatrix.x,
|
|
890
890
|
y: e.y ?? this.contentMatrix.y
|
|
891
|
-
}, this.viewportMatrix =
|
|
891
|
+
}, this.viewportMatrix = Q(this.contentMatrix), this.emitter.emit();
|
|
892
892
|
}
|
|
893
893
|
}
|
|
894
|
-
class
|
|
894
|
+
class he {
|
|
895
895
|
constructor(e) {
|
|
896
896
|
this.transformer = e;
|
|
897
897
|
}
|
|
@@ -902,21 +902,21 @@ class ne {
|
|
|
902
902
|
return { ...this.transformer.getContentMatrix() };
|
|
903
903
|
}
|
|
904
904
|
}
|
|
905
|
-
const
|
|
905
|
+
const pe = () => {
|
|
906
906
|
const t = document.createElement("div");
|
|
907
907
|
return t.style.width = "100%", t.style.height = "100%", t.style.position = "relative", t.style.overflow = "hidden", t;
|
|
908
|
-
},
|
|
908
|
+
}, me = () => {
|
|
909
909
|
const t = document.createElement("div");
|
|
910
910
|
return t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.width = "0", t.style.height = "0", t;
|
|
911
|
-
},
|
|
911
|
+
}, Ne = () => {
|
|
912
912
|
const t = document.createElement("div");
|
|
913
913
|
return t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.visibility = "hidden", t;
|
|
914
914
|
};
|
|
915
915
|
class K {
|
|
916
916
|
constructor(e, r) {
|
|
917
917
|
i(this, "canvasWrapper", null);
|
|
918
|
-
i(this, "host",
|
|
919
|
-
i(this, "container",
|
|
918
|
+
i(this, "host", pe());
|
|
919
|
+
i(this, "container", me());
|
|
920
920
|
i(this, "nodeIdToWrapperElementMap", /* @__PURE__ */ new Map());
|
|
921
921
|
i(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
|
|
922
922
|
i(this, "applyTransform", () => {
|
|
@@ -932,7 +932,7 @@ class K {
|
|
|
932
932
|
this.canvasWrapper !== null && (this.canvasWrapper.removeChild(this.host), this.canvasWrapper = null);
|
|
933
933
|
}
|
|
934
934
|
attachNode(e) {
|
|
935
|
-
const r = this.graphStore.getNode(e), o =
|
|
935
|
+
const r = this.graphStore.getNode(e), o = Ne();
|
|
936
936
|
o.appendChild(r.element), this.container.appendChild(o), this.nodeIdToWrapperElementMap.set(e, o), this.updateNodeCoordinates(e), this.updateNodePriority(e), o.style.visibility = "visible";
|
|
937
937
|
}
|
|
938
938
|
detachNode(e) {
|
|
@@ -958,7 +958,7 @@ class K {
|
|
|
958
958
|
this.clear(), this.detach(), this.viewportTransformer.onAfterUpdate.unsubscribe(this.applyTransform), this.host.removeChild(this.container);
|
|
959
959
|
}
|
|
960
960
|
updateNodeCoordinates(e) {
|
|
961
|
-
const r = this.nodeIdToWrapperElementMap.get(e), o = this.graphStore.getNode(e), { width:
|
|
961
|
+
const r = this.nodeIdToWrapperElementMap.get(e), o = this.graphStore.getNode(e), { width: n, height: d } = o.element.getBoundingClientRect(), s = this.viewportTransformer.getViewportMatrix().scale, h = o.centerFn(n, d), c = o.x - s * h.x, a = o.y - s * h.y;
|
|
962
962
|
r.style.transform = `translate(${c}px, ${a}px)`;
|
|
963
963
|
}
|
|
964
964
|
updateNodePriority(e) {
|
|
@@ -972,12 +972,12 @@ class K {
|
|
|
972
972
|
this.edgeIdToElementMap.set(e, o.shape.svg), this.container.appendChild(o.shape.svg);
|
|
973
973
|
}
|
|
974
974
|
renderEdge(e) {
|
|
975
|
-
const r = this.graphStore.getEdge(e), o = this.graphStore.getPort(r.from),
|
|
975
|
+
const r = this.graphStore.getEdge(e), o = this.graphStore.getPort(r.from), n = this.graphStore.getPort(r.to), d = o.element.getBoundingClientRect(), s = n.element.getBoundingClientRect(), h = this.host.getBoundingClientRect(), c = this.viewportTransformer.getViewportMatrix(), a = {
|
|
976
976
|
x: c.scale * (d.left - h.left) + c.x,
|
|
977
977
|
y: c.scale * (d.top - h.top) + c.y
|
|
978
978
|
}, l = {
|
|
979
|
-
x: c.scale * (
|
|
980
|
-
y: c.scale * (
|
|
979
|
+
x: c.scale * (s.left - h.left) + c.x,
|
|
980
|
+
y: c.scale * (s.top - h.top) + c.y
|
|
981
981
|
}, g = {
|
|
982
982
|
x: a.x,
|
|
983
983
|
y: a.y,
|
|
@@ -989,9 +989,9 @@ class K {
|
|
|
989
989
|
}, f = {
|
|
990
990
|
x: l.x,
|
|
991
991
|
y: l.y,
|
|
992
|
-
width:
|
|
993
|
-
height:
|
|
994
|
-
direction:
|
|
992
|
+
width: s.width * c.scale,
|
|
993
|
+
height: s.height * c.scale,
|
|
994
|
+
direction: n.direction,
|
|
995
995
|
portId: r.to,
|
|
996
996
|
nodeId: this.graphStore.getPortNodeId(r.to)
|
|
997
997
|
};
|
|
@@ -1005,7 +1005,7 @@ class K {
|
|
|
1005
1005
|
r.shape.svg.style.zIndex = `${r.priority}`;
|
|
1006
1006
|
}
|
|
1007
1007
|
}
|
|
1008
|
-
class
|
|
1008
|
+
class Te {
|
|
1009
1009
|
constructor(e) {
|
|
1010
1010
|
i(this, "xFrom", 1 / 0);
|
|
1011
1011
|
i(this, "yFrom", 1 / 0);
|
|
@@ -1021,35 +1021,35 @@ class Ne {
|
|
|
1021
1021
|
return r.x >= this.xFrom && r.x <= this.xTo && r.y >= this.yFrom && r.y <= this.yTo;
|
|
1022
1022
|
}
|
|
1023
1023
|
hasEdge(e) {
|
|
1024
|
-
const r = this.graphStore.getEdge(e), o = this.graphStore.getPortNodeId(r.from),
|
|
1024
|
+
const r = this.graphStore.getEdge(e), o = this.graphStore.getPortNodeId(r.from), n = this.graphStore.getPortNodeId(r.to), d = this.graphStore.getNode(o), s = this.graphStore.getNode(n), h = Math.min(d.x, s.x), c = Math.max(d.x, s.x), a = Math.min(d.y, s.y), l = Math.max(d.y, s.y);
|
|
1025
1025
|
return h <= this.xTo && c >= this.xFrom && a <= this.yTo && l >= this.yFrom;
|
|
1026
1026
|
}
|
|
1027
1027
|
}
|
|
1028
|
-
class
|
|
1028
|
+
class Me {
|
|
1029
1029
|
constructor(e, r, o) {
|
|
1030
1030
|
i(this, "attachedNodes", /* @__PURE__ */ new Set());
|
|
1031
1031
|
i(this, "attachedEdges", /* @__PURE__ */ new Set());
|
|
1032
1032
|
i(this, "renderingBox");
|
|
1033
1033
|
i(this, "updateViewport", (e) => {
|
|
1034
1034
|
this.renderingBox.setRenderingBox(e);
|
|
1035
|
-
const r = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set(),
|
|
1036
|
-
this.graphStore.getAllNodeIds().forEach((
|
|
1037
|
-
const h = this.renderingBox.hasNode(
|
|
1038
|
-
h && !c ? r.add(
|
|
1039
|
-
}), this.graphStore.getAllEdgeIds().forEach((
|
|
1040
|
-
const h = this.renderingBox.hasEdge(
|
|
1041
|
-
h && (this.renderingBox.hasNode(l) || (r.add(l), o.delete(l)), this.renderingBox.hasNode(g) || (r.add(g), o.delete(g))), h && !c ?
|
|
1042
|
-
}), d.forEach((
|
|
1043
|
-
this.handleDetachEdge(
|
|
1044
|
-
}), o.forEach((
|
|
1045
|
-
this.handleDetachNode(
|
|
1046
|
-
}), r.forEach((
|
|
1047
|
-
this.handleAttachNode(
|
|
1048
|
-
}),
|
|
1049
|
-
this.handleAttachEdge(
|
|
1035
|
+
const r = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set();
|
|
1036
|
+
this.graphStore.getAllNodeIds().forEach((s) => {
|
|
1037
|
+
const h = this.renderingBox.hasNode(s), c = this.attachedNodes.has(s);
|
|
1038
|
+
h && !c ? r.add(s) : !h && c && o.add(s);
|
|
1039
|
+
}), this.graphStore.getAllEdgeIds().forEach((s) => {
|
|
1040
|
+
const h = this.renderingBox.hasEdge(s), c = this.attachedEdges.has(s), a = this.graphStore.getEdge(s), l = this.graphStore.getPortNodeId(a.from), g = this.graphStore.getPortNodeId(a.to);
|
|
1041
|
+
h && (this.renderingBox.hasNode(l) || (r.add(l), o.delete(l)), this.renderingBox.hasNode(g) || (r.add(g), o.delete(g))), h && !c ? n.add(s) : !h && c && d.add(s);
|
|
1042
|
+
}), d.forEach((s) => {
|
|
1043
|
+
this.handleDetachEdge(s);
|
|
1044
|
+
}), o.forEach((s) => {
|
|
1045
|
+
this.handleDetachNode(s);
|
|
1046
|
+
}), r.forEach((s) => {
|
|
1047
|
+
this.attachedNodes.has(s) || this.handleAttachNode(s);
|
|
1048
|
+
}), n.forEach((s) => {
|
|
1049
|
+
this.handleAttachEdge(s);
|
|
1050
1050
|
});
|
|
1051
1051
|
});
|
|
1052
|
-
this.htmlView = e, this.graphStore = r, this.trigger = o, this.renderingBox = new
|
|
1052
|
+
this.htmlView = e, this.graphStore = r, this.trigger = o, this.renderingBox = new Te(this.graphStore), this.trigger.subscribe(this.updateViewport);
|
|
1053
1053
|
}
|
|
1054
1054
|
attach(e) {
|
|
1055
1055
|
this.htmlView.attach(e);
|
|
@@ -1064,14 +1064,14 @@ class pe {
|
|
|
1064
1064
|
this.attachedNodes.has(e) && this.handleDetachNode(e);
|
|
1065
1065
|
}
|
|
1066
1066
|
attachEdge(e) {
|
|
1067
|
-
this.renderingBox.hasEdge(e) && this.
|
|
1067
|
+
this.renderingBox.hasEdge(e) && this.attachEdgeEntities(e);
|
|
1068
1068
|
}
|
|
1069
1069
|
detachEdge(e) {
|
|
1070
1070
|
this.attachedEdges.has(e) && this.handleDetachEdge(e);
|
|
1071
1071
|
}
|
|
1072
1072
|
updateNodeCoordinates(e) {
|
|
1073
1073
|
this.attachedNodes.has(e) ? this.htmlView.updateNodeCoordinates(e) : this.renderingBox.hasNode(e) && (this.handleAttachNode(e), this.graphStore.getNodeAdjacentEdgeIds(e).forEach((r) => {
|
|
1074
|
-
this.
|
|
1074
|
+
this.attachEdgeEntities(r);
|
|
1075
1075
|
}));
|
|
1076
1076
|
}
|
|
1077
1077
|
updateNodePriority(e) {
|
|
@@ -1092,9 +1092,9 @@ class pe {
|
|
|
1092
1092
|
destroy() {
|
|
1093
1093
|
this.clear(), this.htmlView.destroy(), this.trigger.unsubscribe(this.updateViewport);
|
|
1094
1094
|
}
|
|
1095
|
-
|
|
1096
|
-
const r = this.graphStore.getEdge(e), o = this.graphStore.getPortNodeId(r.from),
|
|
1097
|
-
this.attachedNodes.has(o) || this.handleAttachNode(o), this.attachedNodes.has(
|
|
1095
|
+
attachEdgeEntities(e) {
|
|
1096
|
+
const r = this.graphStore.getEdge(e), o = this.graphStore.getPortNodeId(r.from), n = this.graphStore.getPortNodeId(r.to);
|
|
1097
|
+
this.attachedNodes.has(o) || this.handleAttachNode(o), this.attachedNodes.has(n) || this.handleAttachNode(n), this.handleAttachEdge(e);
|
|
1098
1098
|
}
|
|
1099
1099
|
handleAttachNode(e) {
|
|
1100
1100
|
this.attachedNodes.add(e), this.htmlView.attachNode(e);
|
|
@@ -1109,7 +1109,7 @@ class pe {
|
|
|
1109
1109
|
this.htmlView.detachEdge(e), this.attachedEdges.delete(e);
|
|
1110
1110
|
}
|
|
1111
1111
|
}
|
|
1112
|
-
class
|
|
1112
|
+
class D {
|
|
1113
1113
|
constructor(e) {
|
|
1114
1114
|
i(this, "counter", 0);
|
|
1115
1115
|
this.checkExists = e;
|
|
@@ -1131,15 +1131,15 @@ class A extends Error {
|
|
|
1131
1131
|
i(this, "name", "HtmlGraphError");
|
|
1132
1132
|
}
|
|
1133
1133
|
}
|
|
1134
|
-
class
|
|
1134
|
+
class de {
|
|
1135
1135
|
constructor(e, r) {
|
|
1136
|
-
i(this, "nodeIdGenerator", new
|
|
1136
|
+
i(this, "nodeIdGenerator", new D(
|
|
1137
1137
|
(e) => this.graphStore.getNode(e) !== void 0
|
|
1138
1138
|
));
|
|
1139
|
-
i(this, "portIdGenerator", new
|
|
1139
|
+
i(this, "portIdGenerator", new D(
|
|
1140
1140
|
(e) => this.graphStore.getPort(e) !== void 0
|
|
1141
1141
|
));
|
|
1142
|
-
i(this, "edgeIdGenerator", new
|
|
1142
|
+
i(this, "edgeIdGenerator", new D(
|
|
1143
1143
|
(e) => this.graphStore.getEdge(e) !== void 0
|
|
1144
1144
|
));
|
|
1145
1145
|
i(this, "onAfterNodeAdded");
|
|
@@ -1254,7 +1254,7 @@ class se {
|
|
|
1254
1254
|
this.graphStore.clear(), this.nodeIdGenerator.reset(), this.portIdGenerator.reset(), this.edgeIdGenerator.reset();
|
|
1255
1255
|
}
|
|
1256
1256
|
}
|
|
1257
|
-
class
|
|
1257
|
+
class ce {
|
|
1258
1258
|
constructor(e) {
|
|
1259
1259
|
this.graphStore = e;
|
|
1260
1260
|
}
|
|
@@ -1321,7 +1321,9 @@ class he {
|
|
|
1321
1321
|
}
|
|
1322
1322
|
class Ge {
|
|
1323
1323
|
constructor(e) {
|
|
1324
|
+
i(this, "viewport");
|
|
1324
1325
|
i(this, "transformation");
|
|
1326
|
+
i(this, "graph");
|
|
1325
1327
|
i(this, "model");
|
|
1326
1328
|
i(this, "internalTransformation");
|
|
1327
1329
|
i(this, "internalModel");
|
|
@@ -1361,14 +1363,12 @@ class Ge {
|
|
|
1361
1363
|
i(this, "onBeforeNodeRemoved", (e) => {
|
|
1362
1364
|
this.htmlView.detachNode(e);
|
|
1363
1365
|
});
|
|
1364
|
-
this.internalModel = new
|
|
1365
|
-
this.internalTransformation
|
|
1366
|
-
), this.htmlView = new K(
|
|
1366
|
+
this.internalModel = new ie(), this.graph = new ce(this.internalModel), this.model = this.graph, this.internalTransformation = new ne(), this.viewport = new he(this.internalTransformation), this.transformation = this.viewport, this.htmlView = new K(
|
|
1367
1367
|
this.internalModel,
|
|
1368
1368
|
this.internalTransformation
|
|
1369
|
-
), this.graphStoreController = new
|
|
1369
|
+
), this.graphStoreController = new de(
|
|
1370
1370
|
this.internalModel,
|
|
1371
|
-
|
|
1371
|
+
Se(e)
|
|
1372
1372
|
), this.graphStoreController.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graphStoreController.onAfterEdgeAdded.subscribe(this.onAfterEdgeAdded), this.graphStoreController.onAfterEdgeShapeUpdated.subscribe(
|
|
1373
1373
|
this.onAfterEdgeShapeUpdated
|
|
1374
1374
|
), this.graphStoreController.onAfterEdgePriorityUpdated.subscribe(
|
|
@@ -1453,9 +1453,11 @@ class Ge {
|
|
|
1453
1453
|
);
|
|
1454
1454
|
}
|
|
1455
1455
|
}
|
|
1456
|
-
class
|
|
1456
|
+
class be {
|
|
1457
1457
|
constructor(e) {
|
|
1458
|
+
i(this, "viewport");
|
|
1458
1459
|
i(this, "transformation");
|
|
1460
|
+
i(this, "graph");
|
|
1459
1461
|
i(this, "model");
|
|
1460
1462
|
i(this, "internalTransformation");
|
|
1461
1463
|
i(this, "internalModel");
|
|
@@ -1495,7 +1497,7 @@ class Te {
|
|
|
1495
1497
|
i(this, "onBeforeNodeRemoved", (e) => {
|
|
1496
1498
|
this.htmlView.detachNode(e);
|
|
1497
1499
|
});
|
|
1498
|
-
this.
|
|
1500
|
+
this.graph = e.graph, this.model = this.graph, this.internalModel = e.graphStore, this.internalTransformation = e.viewportTransformer, this.viewport = e.viewport, this.transformation = this.viewport, this.htmlView = e.htmlView, this.graphStoreController = e.graphStoreController, this.graphStoreController.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graphStoreController.onAfterEdgeAdded.subscribe(this.onAfterEdgeAdded), this.graphStoreController.onAfterEdgeShapeUpdated.subscribe(
|
|
1499
1501
|
this.onAfterEdgeShapeUpdated
|
|
1500
1502
|
), this.graphStoreController.onAfterEdgePriorityUpdated.subscribe(
|
|
1501
1503
|
this.onAfterEdgePriorityUpdated
|
|
@@ -1579,12 +1581,12 @@ class Te {
|
|
|
1579
1581
|
);
|
|
1580
1582
|
}
|
|
1581
1583
|
}
|
|
1582
|
-
const
|
|
1584
|
+
const Ce = (t) => {
|
|
1583
1585
|
if (typeof t == "function")
|
|
1584
1586
|
return t;
|
|
1585
1587
|
switch (t == null ? void 0 : t.type) {
|
|
1586
1588
|
case "straight":
|
|
1587
|
-
return () => new
|
|
1589
|
+
return () => new re({
|
|
1588
1590
|
color: t.color,
|
|
1589
1591
|
width: t.width,
|
|
1590
1592
|
arrowLength: t.arrowLength,
|
|
@@ -1598,7 +1600,7 @@ const be = (t) => {
|
|
|
1598
1600
|
detourDirection: t.detourDirection
|
|
1599
1601
|
});
|
|
1600
1602
|
case "horizontal":
|
|
1601
|
-
return () => new
|
|
1603
|
+
return () => new te({
|
|
1602
1604
|
color: t.color,
|
|
1603
1605
|
width: t.width,
|
|
1604
1606
|
arrowLength: t.arrowLength,
|
|
@@ -1612,7 +1614,7 @@ const be = (t) => {
|
|
|
1612
1614
|
detourDirection: t.detourDirection
|
|
1613
1615
|
});
|
|
1614
1616
|
case "vertical":
|
|
1615
|
-
return () => new
|
|
1617
|
+
return () => new oe({
|
|
1616
1618
|
color: t.color,
|
|
1617
1619
|
width: t.width,
|
|
1618
1620
|
arrowLength: t.arrowLength,
|
|
@@ -1626,7 +1628,7 @@ const be = (t) => {
|
|
|
1626
1628
|
detourDirection: t.detourDirection
|
|
1627
1629
|
});
|
|
1628
1630
|
default:
|
|
1629
|
-
return () => new
|
|
1631
|
+
return () => new ee({
|
|
1630
1632
|
color: t.color,
|
|
1631
1633
|
width: t.width,
|
|
1632
1634
|
arrowLength: t.arrowLength,
|
|
@@ -1640,87 +1642,87 @@ const be = (t) => {
|
|
|
1640
1642
|
detourDirection: t.detourDirection
|
|
1641
1643
|
});
|
|
1642
1644
|
}
|
|
1643
|
-
},
|
|
1645
|
+
}, Pe = (t, e) => {
|
|
1644
1646
|
let r = I, o = I;
|
|
1645
|
-
t === "incremental" && (r =
|
|
1646
|
-
const
|
|
1647
|
-
return t === "shared-incremental" && (r =
|
|
1647
|
+
t === "incremental" && (r = C()), e === "incremental" && (o = C());
|
|
1648
|
+
const n = C();
|
|
1649
|
+
return t === "shared-incremental" && (r = n), e === "shared-incremental" && (o = n), typeof t == "number" && (r = $(t)), typeof e == "number" && (o = $(e)), typeof t == "function" && (r = t), typeof e == "function" && (o = e), {
|
|
1648
1650
|
nodesPriorityFn: r,
|
|
1649
1651
|
edgesPriorityFn: o
|
|
1650
1652
|
};
|
|
1651
|
-
},
|
|
1652
|
-
var r, o,
|
|
1653
|
-
const e =
|
|
1653
|
+
}, Ve = (t) => {
|
|
1654
|
+
var r, o, n, d, s;
|
|
1655
|
+
const e = Pe(
|
|
1654
1656
|
(r = t == null ? void 0 : t.nodes) == null ? void 0 : r.priority,
|
|
1655
1657
|
(o = t == null ? void 0 : t.edges) == null ? void 0 : o.priority
|
|
1656
1658
|
);
|
|
1657
1659
|
return {
|
|
1658
1660
|
nodes: {
|
|
1659
|
-
centerFn: ((
|
|
1661
|
+
centerFn: ((n = t == null ? void 0 : t.nodes) == null ? void 0 : n.centerFn) ?? O,
|
|
1660
1662
|
priorityFn: e.nodesPriorityFn
|
|
1661
1663
|
},
|
|
1662
1664
|
ports: {
|
|
1663
1665
|
direction: ((d = t == null ? void 0 : t.ports) == null ? void 0 : d.direction) ?? 0
|
|
1664
1666
|
},
|
|
1665
1667
|
edges: {
|
|
1666
|
-
shapeFactory:
|
|
1668
|
+
shapeFactory: Ce(((s = t == null ? void 0 : t.edges) == null ? void 0 : s.shape) ?? {}),
|
|
1667
1669
|
priorityFn: e.edgesPriorityFn
|
|
1668
1670
|
}
|
|
1669
1671
|
};
|
|
1670
1672
|
};
|
|
1671
|
-
class
|
|
1673
|
+
class Le {
|
|
1672
1674
|
constructor(e, r) {
|
|
1673
|
-
i(this, "
|
|
1674
|
-
i(this, "
|
|
1675
|
+
i(this, "viewport");
|
|
1676
|
+
i(this, "graph");
|
|
1675
1677
|
i(this, "viewportTransformer");
|
|
1676
1678
|
i(this, "graphStore");
|
|
1677
1679
|
i(this, "htmlView");
|
|
1678
1680
|
i(this, "graphStoreController");
|
|
1679
|
-
this.graphStore = new
|
|
1680
|
-
this.viewportTransformer
|
|
1681
|
-
), this.htmlView = r(this.graphStore, this.viewportTransformer), this.graphStoreController = new se(
|
|
1681
|
+
this.graphStore = new ie(), this.graph = new ce(this.graphStore), this.viewportTransformer = new ne(), this.viewport = new he(this.viewportTransformer), this.htmlView = r(this.graphStore, this.viewportTransformer), this.graphStoreController = new de(
|
|
1682
1682
|
this.graphStore,
|
|
1683
|
-
|
|
1683
|
+
Ve(e)
|
|
1684
1684
|
);
|
|
1685
1685
|
}
|
|
1686
1686
|
}
|
|
1687
|
-
const
|
|
1687
|
+
const De = (t, e) => new K(t, e), $e = (t) => (e, r) => new Me(
|
|
1688
1688
|
new K(e, r),
|
|
1689
1689
|
e,
|
|
1690
1690
|
t
|
|
1691
|
-
),
|
|
1692
|
-
const { x: o, y:
|
|
1693
|
-
return e >= o && e <= o + d && r >=
|
|
1694
|
-
}, R = (t, e, r) => e >= 0 && e <= t.innerWidth && r >= 0 && r <= t.innerHeight,
|
|
1691
|
+
), F = (t, e, r) => {
|
|
1692
|
+
const { x: o, y: n, width: d, height: s } = t.getBoundingClientRect();
|
|
1693
|
+
return e >= o && e <= o + d && r >= n && r <= n + s;
|
|
1694
|
+
}, R = (t, e, r) => e >= 0 && e <= t.innerWidth && r >= 0 && r <= t.innerHeight, B = (t, e) => {
|
|
1695
1695
|
e !== null ? t.style.cursor = e : t.style.removeProperty("cursor");
|
|
1696
|
-
},
|
|
1697
|
-
var g, f, x, y,
|
|
1696
|
+
}, Ue = (t) => {
|
|
1697
|
+
var g, f, x, y, p, E;
|
|
1698
1698
|
const e = ((g = t == null ? void 0 : t.events) == null ? void 0 : g.onNodeDrag) ?? (() => {
|
|
1699
1699
|
}), r = ((f = t == null ? void 0 : t.events) == null ? void 0 : f.onBeforeNodeDrag) ?? (() => !0), o = ((x = t == null ? void 0 : t.events) == null ? void 0 : x.onNodeDragFinished) ?? (() => {
|
|
1700
|
-
}),
|
|
1700
|
+
}), n = (t == null ? void 0 : t.moveOnTop) === !1, d = (y = t == null ? void 0 : t.mouse) == null ? void 0 : y.dragCursor, s = d !== void 0 ? d : "grab", h = (p = t == null ? void 0 : t.mouse) == null ? void 0 : p.mouseDownEventVerifier, c = h !== void 0 ? h : (m) => m.button === 0, a = (E = t == null ? void 0 : t.mouse) == null ? void 0 : E.mouseUpEventVerifier;
|
|
1701
1701
|
return {
|
|
1702
|
-
freezePriority:
|
|
1703
|
-
dragCursor:
|
|
1702
|
+
freezePriority: n,
|
|
1703
|
+
dragCursor: s,
|
|
1704
1704
|
mouseDownEventVerifier: c,
|
|
1705
|
-
mouseUpEventVerifier: a !== void 0 ? a : (
|
|
1705
|
+
mouseUpEventVerifier: a !== void 0 ? a : (m) => m.button === 0,
|
|
1706
1706
|
onNodeDrag: e,
|
|
1707
1707
|
onBeforeNodeDrag: r,
|
|
1708
1708
|
onNodeDragFinished: o
|
|
1709
1709
|
};
|
|
1710
1710
|
};
|
|
1711
|
-
class
|
|
1711
|
+
class We {
|
|
1712
1712
|
constructor(e, r) {
|
|
1713
|
+
i(this, "graph");
|
|
1713
1714
|
i(this, "model");
|
|
1715
|
+
i(this, "viewport");
|
|
1714
1716
|
i(this, "transformation");
|
|
1715
1717
|
i(this, "maxNodePriority", 0);
|
|
1716
1718
|
i(this, "nodes", /* @__PURE__ */ new Map());
|
|
1717
1719
|
i(this, "grabbedNodeId", null);
|
|
1718
|
-
i(this, "nodeIdGenerator", new
|
|
1720
|
+
i(this, "nodeIdGenerator", new D(
|
|
1719
1721
|
(e) => this.nodes.has(e)
|
|
1720
1722
|
));
|
|
1721
1723
|
i(this, "element", null);
|
|
1722
1724
|
i(this, "onWindowMouseMove", (e) => {
|
|
1723
|
-
if (this.element !== null && (!
|
|
1725
|
+
if (this.element !== null && (!F(this.element, e.clientX, e.clientY) || !R(this.window, e.clientX, e.clientY))) {
|
|
1724
1726
|
this.cancelMouseDrag();
|
|
1725
1727
|
return;
|
|
1726
1728
|
}
|
|
@@ -1733,13 +1735,13 @@ class $e {
|
|
|
1733
1735
|
if (e.touches.length !== 1)
|
|
1734
1736
|
return;
|
|
1735
1737
|
const r = e.touches[0];
|
|
1736
|
-
if (this.element !== null && (!
|
|
1738
|
+
if (this.element !== null && (!F(this.element, r.clientX, r.clientY) || !R(this.window, r.clientX, r.clientY))) {
|
|
1737
1739
|
this.cancelTouchDrag();
|
|
1738
1740
|
return;
|
|
1739
1741
|
}
|
|
1740
1742
|
if (this.grabbedNodeId !== null && this.previousTouchCoords !== null) {
|
|
1741
|
-
const o = r.clientX - this.previousTouchCoords.x,
|
|
1742
|
-
this.dragNode(this.grabbedNodeId, o,
|
|
1743
|
+
const o = r.clientX - this.previousTouchCoords.x, n = r.clientY - this.previousTouchCoords.y;
|
|
1744
|
+
this.dragNode(this.grabbedNodeId, o, n), this.previousTouchCoords = {
|
|
1743
1745
|
x: e.touches[0].clientX,
|
|
1744
1746
|
y: e.touches[0].clientY
|
|
1745
1747
|
};
|
|
@@ -1751,7 +1753,7 @@ class $e {
|
|
|
1751
1753
|
i(this, "previousTouchCoords", null);
|
|
1752
1754
|
i(this, "window", window);
|
|
1753
1755
|
i(this, "options");
|
|
1754
|
-
this.canvas = e, this.
|
|
1756
|
+
this.canvas = e, this.viewport = this.canvas.viewport, this.transformation = this.viewport, this.graph = this.canvas.graph, this.model = this.graph, this.options = Ue(r ?? {});
|
|
1755
1757
|
}
|
|
1756
1758
|
attach(e) {
|
|
1757
1759
|
return this.detach(), this.element = e, this.canvas.attach(this.element), this;
|
|
@@ -1765,33 +1767,33 @@ class $e {
|
|
|
1765
1767
|
const o = (d) => {
|
|
1766
1768
|
if (this.element === null || !this.options.mouseDownEventVerifier(d))
|
|
1767
1769
|
return;
|
|
1768
|
-
const
|
|
1770
|
+
const s = this.graph.getNode(r);
|
|
1769
1771
|
this.options.onBeforeNodeDrag({
|
|
1770
1772
|
nodeId: r,
|
|
1771
1773
|
element: e.element,
|
|
1772
|
-
x:
|
|
1773
|
-
y:
|
|
1774
|
-
}) && (d.stopImmediatePropagation(), this.grabbedNodeId = r,
|
|
1775
|
-
},
|
|
1774
|
+
x: s.x,
|
|
1775
|
+
y: s.y
|
|
1776
|
+
}) && (d.stopImmediatePropagation(), this.grabbedNodeId = r, B(this.element, this.options.dragCursor), this.moveNodeOnTop(r), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.window.addEventListener("mousemove", this.onWindowMouseMove));
|
|
1777
|
+
}, n = (d) => {
|
|
1776
1778
|
if (d.touches.length !== 1)
|
|
1777
1779
|
return;
|
|
1778
1780
|
d.stopImmediatePropagation(), this.previousTouchCoords = {
|
|
1779
1781
|
x: d.touches[0].clientX,
|
|
1780
1782
|
y: d.touches[0].clientY
|
|
1781
1783
|
};
|
|
1782
|
-
const
|
|
1784
|
+
const s = this.graph.getNode(r);
|
|
1783
1785
|
this.options.onBeforeNodeDrag({
|
|
1784
1786
|
nodeId: r,
|
|
1785
1787
|
element: e.element,
|
|
1786
|
-
x:
|
|
1787
|
-
y:
|
|
1788
|
+
x: s.x,
|
|
1789
|
+
y: s.y
|
|
1788
1790
|
}) && (this.grabbedNodeId = r, this.moveNodeOnTop(r), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish));
|
|
1789
1791
|
};
|
|
1790
1792
|
return this.nodes.set(r, {
|
|
1791
1793
|
element: e.element,
|
|
1792
1794
|
onMouseDown: o,
|
|
1793
|
-
onTouchStart:
|
|
1794
|
-
}), e.element.addEventListener("mousedown", o), e.element.addEventListener("touchstart",
|
|
1795
|
+
onTouchStart: n
|
|
1796
|
+
}), e.element.addEventListener("mousedown", o), e.element.addEventListener("touchstart", n), this;
|
|
1795
1797
|
}
|
|
1796
1798
|
updateNode(e, r) {
|
|
1797
1799
|
return this.canvas.updateNode(e, r), this.updateMaxNodePriority(e), this;
|
|
@@ -1833,19 +1835,19 @@ class $e {
|
|
|
1833
1835
|
this.detach(), this.clear(), this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.canvas.destroy();
|
|
1834
1836
|
}
|
|
1835
1837
|
dragNode(e, r, o) {
|
|
1836
|
-
const
|
|
1837
|
-
if (
|
|
1838
|
+
const n = this.graph.getNode(e);
|
|
1839
|
+
if (n === null)
|
|
1838
1840
|
return;
|
|
1839
|
-
const d = this.canvas.
|
|
1841
|
+
const d = this.canvas.viewport.getContentMatrix(), s = d.scale * n.x + d.x, h = d.scale * n.y + d.y, c = s + r, a = h + o, l = this.canvas.viewport.getViewportMatrix(), g = l.scale * c + l.x, f = l.scale * a + l.y;
|
|
1840
1842
|
this.canvas.updateNode(e, { x: g, y: f }), this.options.onNodeDrag({
|
|
1841
1843
|
nodeId: e,
|
|
1842
|
-
element:
|
|
1844
|
+
element: n.element,
|
|
1843
1845
|
x: g,
|
|
1844
1846
|
y: f
|
|
1845
1847
|
});
|
|
1846
1848
|
}
|
|
1847
1849
|
updateMaxNodePriority(e) {
|
|
1848
|
-
const r = this.
|
|
1850
|
+
const r = this.graph.getNode(e).priority;
|
|
1849
1851
|
this.maxNodePriority = Math.max(this.maxNodePriority, r);
|
|
1850
1852
|
}
|
|
1851
1853
|
moveNodeOnTop(e) {
|
|
@@ -1853,25 +1855,25 @@ class $e {
|
|
|
1853
1855
|
return;
|
|
1854
1856
|
this.maxNodePriority += 2, this.updateNode(e, { priority: this.maxNodePriority });
|
|
1855
1857
|
const r = this.maxNodePriority - 1;
|
|
1856
|
-
this.
|
|
1857
|
-
this.updateEdge(
|
|
1858
|
+
this.graph.getNodeAdjacentEdgeIds(e).forEach((n) => {
|
|
1859
|
+
this.updateEdge(n, { priority: r });
|
|
1858
1860
|
});
|
|
1859
1861
|
}
|
|
1860
1862
|
cancelMouseDrag() {
|
|
1861
|
-
const e = this.
|
|
1863
|
+
const e = this.graph.getNode(this.grabbedNodeId);
|
|
1862
1864
|
e !== null && this.options.onNodeDragFinished({
|
|
1863
1865
|
nodeId: this.grabbedNodeId,
|
|
1864
1866
|
element: e.element,
|
|
1865
1867
|
x: e.x,
|
|
1866
1868
|
y: e.y
|
|
1867
|
-
}), this.grabbedNodeId = null, this.element !== null &&
|
|
1869
|
+
}), this.grabbedNodeId = null, this.element !== null && B(this.element, null), this.removeMouseDragListeners();
|
|
1868
1870
|
}
|
|
1869
1871
|
removeMouseDragListeners() {
|
|
1870
1872
|
this.window.removeEventListener("mouseup", this.onWindowMouseUp), this.window.removeEventListener("mousemove", this.onWindowMouseMove);
|
|
1871
1873
|
}
|
|
1872
1874
|
cancelTouchDrag() {
|
|
1873
1875
|
this.previousTouchCoords = null;
|
|
1874
|
-
const e = this.
|
|
1876
|
+
const e = this.graph.getNode(this.grabbedNodeId);
|
|
1875
1877
|
e !== null && this.options.onNodeDragFinished({
|
|
1876
1878
|
nodeId: this.grabbedNodeId,
|
|
1877
1879
|
element: e.element,
|
|
@@ -1883,30 +1885,30 @@ class $e {
|
|
|
1883
1885
|
this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
|
|
1884
1886
|
}
|
|
1885
1887
|
}
|
|
1886
|
-
const
|
|
1887
|
-
const e = t.minX !== null ? t.minX : -1 / 0, r = t.maxX !== null ? t.maxX : 1 / 0, o = t.minY !== null ? t.minY : -1 / 0,
|
|
1888
|
+
const Ie = (t) => {
|
|
1889
|
+
const e = t.minX !== null ? t.minX : -1 / 0, r = t.maxX !== null ? t.maxX : 1 / 0, o = t.minY !== null ? t.minY : -1 / 0, n = t.maxY !== null ? t.maxY : 1 / 0;
|
|
1888
1890
|
return (d) => {
|
|
1889
|
-
let
|
|
1890
|
-
|
|
1891
|
+
let s = d.nextTransform.x, h = d.nextTransform.y;
|
|
1892
|
+
s < e && s < d.prevTransform.x && (s = Math.min(d.prevTransform.x, e));
|
|
1891
1893
|
const c = d.canvasWidth * d.prevTransform.scale, a = r - c;
|
|
1892
|
-
|
|
1893
|
-
const l = d.canvasHeight * d.prevTransform.scale, g =
|
|
1894
|
-
return h > g && h > d.prevTransform.y && (h = Math.max(d.prevTransform.y, g)), { scale: d.nextTransform.scale, x:
|
|
1894
|
+
s > a && s > d.prevTransform.x && (s = Math.max(d.prevTransform.x, a)), h < o && h < d.prevTransform.y && (h = Math.min(d.prevTransform.y, o));
|
|
1895
|
+
const l = d.canvasHeight * d.prevTransform.scale, g = n - l;
|
|
1896
|
+
return h > g && h > d.prevTransform.y && (h = Math.max(d.prevTransform.y, g)), { scale: d.nextTransform.scale, x: s, y: h };
|
|
1895
1897
|
};
|
|
1896
|
-
},
|
|
1897
|
-
const e = t.maxContentScale, r = t.minContentScale, o = e !== null ? 1 / e : 0,
|
|
1898
|
+
}, Fe = (t) => {
|
|
1899
|
+
const e = t.maxContentScale, r = t.minContentScale, o = e !== null ? 1 / e : 0, n = r !== null ? 1 / r : 1 / 0;
|
|
1898
1900
|
return (d) => {
|
|
1899
|
-
const
|
|
1901
|
+
const s = d.prevTransform, h = d.nextTransform;
|
|
1900
1902
|
let c = h.scale, a = h.x, l = h.y;
|
|
1901
|
-
if (h.scale >
|
|
1902
|
-
c = Math.max(
|
|
1903
|
-
const g = (c -
|
|
1904
|
-
a =
|
|
1903
|
+
if (h.scale > n && h.scale > s.scale) {
|
|
1904
|
+
c = Math.max(s.scale, n), a = s.x, l = s.y;
|
|
1905
|
+
const g = (c - s.scale) / (h.scale - s.scale);
|
|
1906
|
+
a = s.x + (h.x - s.x) * g, l = s.y + (h.y - s.y) * g;
|
|
1905
1907
|
}
|
|
1906
|
-
if (h.scale < o && h.scale <
|
|
1907
|
-
c = Math.min(
|
|
1908
|
-
const g = (c -
|
|
1909
|
-
a =
|
|
1908
|
+
if (h.scale < o && h.scale < s.scale) {
|
|
1909
|
+
c = Math.min(s.scale, o), a = s.x, l = s.y;
|
|
1910
|
+
const g = (c - s.scale) / (h.scale - s.scale);
|
|
1911
|
+
a = s.x + (h.x - s.x) * g, l = s.y + (h.y - s.y) * g;
|
|
1910
1912
|
}
|
|
1911
1913
|
return {
|
|
1912
1914
|
scale: c,
|
|
@@ -1914,7 +1916,7 @@ const Ue = (t) => {
|
|
|
1914
1916
|
y: l
|
|
1915
1917
|
};
|
|
1916
1918
|
};
|
|
1917
|
-
},
|
|
1919
|
+
}, Re = (t) => (e) => t.reduce(
|
|
1918
1920
|
(r, o) => o({
|
|
1919
1921
|
prevTransform: e.prevTransform,
|
|
1920
1922
|
nextTransform: r,
|
|
@@ -1922,88 +1924,92 @@ const Ue = (t) => {
|
|
|
1922
1924
|
canvasHeight: e.canvasHeight
|
|
1923
1925
|
}),
|
|
1924
1926
|
e.nextTransform
|
|
1925
|
-
),
|
|
1927
|
+
), q = (t) => {
|
|
1926
1928
|
if (typeof t == "function")
|
|
1927
1929
|
return t;
|
|
1928
1930
|
switch (t.type) {
|
|
1929
1931
|
case "scale-limit":
|
|
1930
|
-
return
|
|
1932
|
+
return Fe({
|
|
1931
1933
|
minContentScale: t.minContentScale ?? 0,
|
|
1932
1934
|
maxContentScale: t.maxContentScale ?? 1 / 0
|
|
1933
1935
|
});
|
|
1934
1936
|
case "shift-limit":
|
|
1935
|
-
return
|
|
1937
|
+
return Ie({
|
|
1936
1938
|
minX: t.minX ?? -1 / 0,
|
|
1937
1939
|
maxX: t.maxX ?? 1 / 0,
|
|
1938
1940
|
minY: t.minY ?? -1 / 0,
|
|
1939
1941
|
maxY: t.maxY ?? 1 / 0
|
|
1940
1942
|
});
|
|
1941
1943
|
}
|
|
1942
|
-
},
|
|
1943
|
-
var y,
|
|
1944
|
+
}, Be = (t) => {
|
|
1945
|
+
var y, p, E, m, H, P, V, L, _, J;
|
|
1944
1946
|
const e = (y = t == null ? void 0 : t.scale) == null ? void 0 : y.mouseWheelSensitivity, r = e !== void 0 ? e : 1.2, o = t == null ? void 0 : t.transformPreprocessor;
|
|
1945
|
-
let
|
|
1946
|
-
o !== void 0 ? Array.isArray(o) ?
|
|
1947
|
+
let n;
|
|
1948
|
+
o !== void 0 ? Array.isArray(o) ? n = Re(
|
|
1947
1949
|
o.map(
|
|
1948
|
-
(
|
|
1950
|
+
(b) => q(b)
|
|
1949
1951
|
)
|
|
1950
|
-
) :
|
|
1951
|
-
const d = ((
|
|
1952
|
-
}), h = ((
|
|
1953
|
-
}), c = (
|
|
1952
|
+
) : n = q(o) : n = (b) => b.nextTransform;
|
|
1953
|
+
const d = ((p = t == null ? void 0 : t.shift) == null ? void 0 : p.cursor) !== void 0 ? t.shift.cursor : "grab", s = ((E = t == null ? void 0 : t.events) == null ? void 0 : E.onBeforeTransformChange) ?? (() => {
|
|
1954
|
+
}), h = ((m = t == null ? void 0 : t.events) == null ? void 0 : m.onTransformChange) ?? (() => {
|
|
1955
|
+
}), c = (H = t == null ? void 0 : t.shift) == null ? void 0 : H.mouseDownEventVerifier, a = c !== void 0 ? c : (b) => b.button === 0, l = (P = t == null ? void 0 : t.shift) == null ? void 0 : P.mouseUpEventVerifier, g = l !== void 0 ? l : (b) => b.button === 0, f = (V = t == null ? void 0 : t.scale) == null ? void 0 : V.mouseWheelEventVerifier, x = f !== void 0 ? f : () => !0;
|
|
1954
1956
|
return {
|
|
1955
1957
|
wheelSensitivity: r,
|
|
1956
|
-
onTransformStarted: ((
|
|
1958
|
+
onTransformStarted: ((L = t == null ? void 0 : t.events) == null ? void 0 : L.onTransformStarted) ?? (() => {
|
|
1957
1959
|
}),
|
|
1958
1960
|
onTransformFinished: ((_ = t == null ? void 0 : t.events) == null ? void 0 : _.onTransformFinished) ?? (() => {
|
|
1959
1961
|
}),
|
|
1960
|
-
onBeforeTransformChange:
|
|
1962
|
+
onBeforeTransformChange: s,
|
|
1961
1963
|
onTransformChange: h,
|
|
1962
|
-
transformPreprocessor:
|
|
1964
|
+
transformPreprocessor: n,
|
|
1963
1965
|
shiftCursor: d,
|
|
1964
1966
|
mouseDownEventVerifier: a,
|
|
1965
1967
|
mouseUpEventVerifier: g,
|
|
1966
|
-
mouseWheelEventVerifier: x
|
|
1968
|
+
mouseWheelEventVerifier: x,
|
|
1969
|
+
scaleWheelFinishTimeout: ((J = t == null ? void 0 : t.scale) == null ? void 0 : J.wheelFinishTimeout) ?? 500
|
|
1967
1970
|
};
|
|
1968
|
-
},
|
|
1971
|
+
}, W = (t) => {
|
|
1969
1972
|
const e = [], r = t.touches.length;
|
|
1970
1973
|
for (let h = 0; h < r; h++)
|
|
1971
1974
|
e.push([t.touches[h].clientX, t.touches[h].clientY]);
|
|
1972
1975
|
const o = e.reduce(
|
|
1973
1976
|
(h, c) => [h[0] + c[0], h[1] + c[1]],
|
|
1974
1977
|
[0, 0]
|
|
1975
|
-
),
|
|
1978
|
+
), n = [o[0] / r, o[1] / r], s = e.map((h) => [h[0] - n[0], h[1] - n[1]]).reduce(
|
|
1976
1979
|
(h, c) => h + Math.sqrt(c[0] * c[0] + c[1] * c[1]),
|
|
1977
1980
|
0
|
|
1978
1981
|
);
|
|
1979
1982
|
return {
|
|
1980
|
-
x:
|
|
1981
|
-
y:
|
|
1982
|
-
scale:
|
|
1983
|
+
x: n[0],
|
|
1984
|
+
y: n[1],
|
|
1985
|
+
scale: s / r,
|
|
1983
1986
|
touchesCnt: r,
|
|
1984
1987
|
touches: e
|
|
1985
1988
|
};
|
|
1986
|
-
},
|
|
1989
|
+
}, ke = (t, e, r) => ({
|
|
1987
1990
|
scale: t.scale,
|
|
1988
1991
|
x: t.x + t.scale * e,
|
|
1989
1992
|
y: t.y + t.scale * r
|
|
1990
|
-
}),
|
|
1993
|
+
}), Ye = (t, e, r, o) => ({
|
|
1991
1994
|
scale: t.scale * e,
|
|
1992
1995
|
x: t.scale * (1 - e) * r + t.x,
|
|
1993
1996
|
y: t.scale * (1 - e) * o + t.y
|
|
1994
1997
|
});
|
|
1995
|
-
class
|
|
1998
|
+
class ae {
|
|
1996
1999
|
constructor(e, r) {
|
|
2000
|
+
i(this, "graph");
|
|
1997
2001
|
i(this, "model");
|
|
2002
|
+
i(this, "viewport");
|
|
1998
2003
|
i(this, "transformation");
|
|
1999
2004
|
i(this, "element", null);
|
|
2000
2005
|
i(this, "prevTouches", null);
|
|
2001
2006
|
i(this, "window", window);
|
|
2007
|
+
i(this, "wheelFinishTimer", null);
|
|
2002
2008
|
i(this, "onMouseDown", (e) => {
|
|
2003
|
-
this.element === null || !this.options.mouseDownEventVerifier(e) || (
|
|
2009
|
+
this.element === null || !this.options.mouseDownEventVerifier(e) || (B(this.element, this.options.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.options.onTransformStarted());
|
|
2004
2010
|
});
|
|
2005
2011
|
i(this, "onWindowMouseMove", (e) => {
|
|
2006
|
-
if (this.element === null || !
|
|
2012
|
+
if (this.element === null || !F(this.element, e.clientX, e.clientY) || !R(this.window, e.clientX, e.clientY)) {
|
|
2007
2013
|
this.stopMouseDrag();
|
|
2008
2014
|
return;
|
|
2009
2015
|
}
|
|
@@ -2016,20 +2022,26 @@ class ke {
|
|
|
2016
2022
|
i(this, "onWheelScroll", (e) => {
|
|
2017
2023
|
if (!this.options.mouseWheelEventVerifier(e))
|
|
2018
2024
|
return;
|
|
2019
|
-
e.preventDefault()
|
|
2020
|
-
const { left: r, top: o } = this.element.getBoundingClientRect(),
|
|
2021
|
-
this.scaleViewport(this.element, h,
|
|
2025
|
+
e.preventDefault();
|
|
2026
|
+
const { left: r, top: o } = this.element.getBoundingClientRect(), n = e.clientX - r, d = e.clientY - o, h = 1 / (e.deltaY < 0 ? this.options.wheelSensitivity : 1 / this.options.wheelSensitivity);
|
|
2027
|
+
this.wheelFinishTimer === null && this.options.onTransformStarted(), this.scaleViewport(this.element, h, n, d), this.wheelFinishTimer !== null && clearTimeout(this.wheelFinishTimer), this.wheelFinishTimer = setTimeout(() => {
|
|
2028
|
+
this.options.onTransformFinished(), this.wheelFinishTimer = null;
|
|
2029
|
+
}, this.options.scaleWheelFinishTimeout);
|
|
2022
2030
|
});
|
|
2023
2031
|
i(this, "onTouchStart", (e) => {
|
|
2024
|
-
|
|
2032
|
+
if (this.prevTouches !== null) {
|
|
2033
|
+
this.prevTouches = W(e);
|
|
2034
|
+
return;
|
|
2035
|
+
}
|
|
2036
|
+
this.prevTouches = W(e), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish), this.options.onTransformStarted();
|
|
2025
2037
|
});
|
|
2026
2038
|
i(this, "onWindowTouchMove", (e) => {
|
|
2027
2039
|
const r = this.element;
|
|
2028
2040
|
if (r === null)
|
|
2029
2041
|
return;
|
|
2030
|
-
const o =
|
|
2042
|
+
const o = W(e);
|
|
2031
2043
|
if (!o.touches.every(
|
|
2032
|
-
(d) =>
|
|
2044
|
+
(d) => F(r, d[0], d[1]) && R(this.window, d[0], d[1])
|
|
2033
2045
|
)) {
|
|
2034
2046
|
this.stopTouchDrag();
|
|
2035
2047
|
return;
|
|
@@ -2039,25 +2051,25 @@ class ke {
|
|
|
2039
2051
|
-(o.x - this.prevTouches.x),
|
|
2040
2052
|
-(o.y - this.prevTouches.y)
|
|
2041
2053
|
), o.touchesCnt === 2) {
|
|
2042
|
-
const { left: d, top:
|
|
2054
|
+
const { left: d, top: s } = r.getBoundingClientRect(), h = this.prevTouches.x - d, c = this.prevTouches.y - s, l = 1 / (o.scale / this.prevTouches.scale);
|
|
2043
2055
|
this.scaleViewport(r, l, h, c);
|
|
2044
2056
|
}
|
|
2045
2057
|
this.prevTouches = o;
|
|
2046
2058
|
});
|
|
2047
2059
|
i(this, "onWindowTouchFinish", (e) => {
|
|
2048
|
-
e.touches.length > 0 ? this.prevTouches =
|
|
2060
|
+
e.touches.length > 0 ? this.prevTouches = W(e) : this.stopTouchDrag();
|
|
2049
2061
|
});
|
|
2050
2062
|
i(this, "observer", new ResizeObserver(() => {
|
|
2051
|
-
const e = this.canvas.
|
|
2063
|
+
const e = this.canvas.viewport.getViewportMatrix(), { width: r, height: o } = this.element.getBoundingClientRect(), n = this.options.transformPreprocessor({
|
|
2052
2064
|
prevTransform: e,
|
|
2053
2065
|
nextTransform: e,
|
|
2054
2066
|
canvasWidth: r,
|
|
2055
2067
|
canvasHeight: o
|
|
2056
2068
|
});
|
|
2057
|
-
this.canvas.patchViewportMatrix(
|
|
2069
|
+
this.canvas.patchViewportMatrix(n);
|
|
2058
2070
|
}));
|
|
2059
2071
|
i(this, "options");
|
|
2060
|
-
this.canvas = e, this.options =
|
|
2072
|
+
this.canvas = e, this.options = Be(r), this.viewport = this.canvas.viewport, this.transformation = this.viewport, this.graph = this.canvas.graph, this.model = this.graph;
|
|
2061
2073
|
}
|
|
2062
2074
|
attach(e) {
|
|
2063
2075
|
return this.detach(), this.element = e, this.observer.observe(this.element), this.element.addEventListener("mousedown", this.onMouseDown), this.element.addEventListener("wheel", this.onWheelScroll), this.element.addEventListener("touchstart", this.onTouchStart), this.canvas.attach(this.element), this;
|
|
@@ -2105,27 +2117,25 @@ class ke {
|
|
|
2105
2117
|
this.detach(), this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.canvas.destroy();
|
|
2106
2118
|
}
|
|
2107
2119
|
moveViewport(e, r, o) {
|
|
2108
|
-
this.options.
|
|
2109
|
-
|
|
2110
|
-
prevTransform: s,
|
|
2120
|
+
const n = this.viewport.getViewportMatrix(), d = ke(n, r, o), { width: s, height: h } = e.getBoundingClientRect(), c = this.options.transformPreprocessor({
|
|
2121
|
+
prevTransform: n,
|
|
2111
2122
|
nextTransform: d,
|
|
2112
|
-
canvasWidth:
|
|
2123
|
+
canvasWidth: s,
|
|
2113
2124
|
canvasHeight: h
|
|
2114
2125
|
});
|
|
2115
|
-
this.
|
|
2126
|
+
this.performTransform(c);
|
|
2116
2127
|
}
|
|
2117
|
-
scaleViewport(e, r, o,
|
|
2118
|
-
this.options.
|
|
2119
|
-
const d = this.canvas.transformation.getViewportMatrix(), n = Be(d, r, o, s), { width: h, height: c } = e.getBoundingClientRect(), a = this.options.transformPreprocessor({
|
|
2128
|
+
scaleViewport(e, r, o, n) {
|
|
2129
|
+
const d = this.canvas.viewport.getViewportMatrix(), s = Ye(d, r, o, n), { width: h, height: c } = e.getBoundingClientRect(), a = this.options.transformPreprocessor({
|
|
2120
2130
|
prevTransform: d,
|
|
2121
|
-
nextTransform:
|
|
2131
|
+
nextTransform: s,
|
|
2122
2132
|
canvasWidth: h,
|
|
2123
2133
|
canvasHeight: c
|
|
2124
2134
|
});
|
|
2125
|
-
this.
|
|
2135
|
+
this.performTransform(a);
|
|
2126
2136
|
}
|
|
2127
2137
|
stopMouseDrag() {
|
|
2128
|
-
this.element !== null &&
|
|
2138
|
+
this.element !== null && B(this.element, null), this.removeMouseDragListeners(), this.options.onTransformFinished();
|
|
2129
2139
|
}
|
|
2130
2140
|
removeMouseDragListeners() {
|
|
2131
2141
|
this.window.removeEventListener("mousemove", this.onWindowMouseMove), this.window.removeEventListener("mouseup", this.onWindowMouseUp);
|
|
@@ -2136,8 +2146,11 @@ class ke {
|
|
|
2136
2146
|
removeTouchDragListeners() {
|
|
2137
2147
|
this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
|
|
2138
2148
|
}
|
|
2149
|
+
performTransform(e) {
|
|
2150
|
+
this.options.onBeforeTransformChange(), this.canvas.patchViewportMatrix(e), this.options.onTransformChange();
|
|
2151
|
+
}
|
|
2139
2152
|
}
|
|
2140
|
-
class
|
|
2153
|
+
class Xe {
|
|
2141
2154
|
constructor() {
|
|
2142
2155
|
i(this, "keyMap", /* @__PURE__ */ new Map());
|
|
2143
2156
|
i(this, "valueMap", /* @__PURE__ */ new Map());
|
|
@@ -2174,21 +2187,24 @@ class Ye {
|
|
|
2174
2187
|
this.keyMap.clear(), this.valueMap.clear();
|
|
2175
2188
|
}
|
|
2176
2189
|
}
|
|
2177
|
-
class
|
|
2190
|
+
class ze {
|
|
2178
2191
|
constructor(e) {
|
|
2192
|
+
i(this, "viewport");
|
|
2179
2193
|
i(this, "transformation");
|
|
2194
|
+
i(this, "graph");
|
|
2180
2195
|
i(this, "model");
|
|
2181
|
-
i(this, "nodes", new
|
|
2182
|
-
i(this, "nodeIdGenerator", new
|
|
2196
|
+
i(this, "nodes", new Xe());
|
|
2197
|
+
i(this, "nodeIdGenerator", new D(
|
|
2183
2198
|
(e) => this.nodes.hasKey(e)
|
|
2184
2199
|
));
|
|
2185
2200
|
i(this, "nodesResizeObserver");
|
|
2186
|
-
this
|
|
2201
|
+
i(this, "window", window);
|
|
2202
|
+
this.canvas = e, this.nodesResizeObserver = new this.window.ResizeObserver((r) => {
|
|
2187
2203
|
r.forEach((o) => {
|
|
2188
|
-
const
|
|
2189
|
-
this.handleNodeResize(
|
|
2204
|
+
const n = o.target;
|
|
2205
|
+
this.handleNodeResize(n);
|
|
2190
2206
|
});
|
|
2191
|
-
}), this.
|
|
2207
|
+
}), this.viewport = this.canvas.viewport, this.transformation = this.viewport, this.graph = this.canvas.graph, this.model = this.graph;
|
|
2192
2208
|
}
|
|
2193
2209
|
attach(e) {
|
|
2194
2210
|
return this.canvas.attach(e), this;
|
|
@@ -2243,20 +2259,134 @@ class Xe {
|
|
|
2243
2259
|
}
|
|
2244
2260
|
handleNodeResize(e) {
|
|
2245
2261
|
const r = this.nodes.getByValue(e);
|
|
2246
|
-
this.canvas.updateNode(r), this.
|
|
2247
|
-
this.canvas.updateEdge(
|
|
2262
|
+
this.canvas.updateNode(r), this.graph.getNodeAdjacentEdgeIds(r).forEach((n) => {
|
|
2263
|
+
this.canvas.updateEdge(n);
|
|
2248
2264
|
});
|
|
2249
2265
|
}
|
|
2250
2266
|
}
|
|
2251
|
-
class
|
|
2267
|
+
class He {
|
|
2268
|
+
constructor(e, r, o, n) {
|
|
2269
|
+
i(this, "graph");
|
|
2270
|
+
i(this, "model");
|
|
2271
|
+
i(this, "viewport");
|
|
2272
|
+
i(this, "transformation");
|
|
2273
|
+
i(this, "canvas");
|
|
2274
|
+
i(this, "element", null);
|
|
2275
|
+
i(this, "canvasResizeObserver");
|
|
2276
|
+
i(this, "window", window);
|
|
2277
|
+
i(this, "nodeHorizontal");
|
|
2278
|
+
i(this, "nodeVertical");
|
|
2279
|
+
i(this, "viewportWidth", 0);
|
|
2280
|
+
i(this, "viewportHeight", 0);
|
|
2281
|
+
i(this, "viewportMatrix");
|
|
2282
|
+
i(this, "loadedArea", {
|
|
2283
|
+
xFrom: 1 / 0,
|
|
2284
|
+
xTo: 1 / 0,
|
|
2285
|
+
yFrom: 1 / 0,
|
|
2286
|
+
yTo: 1 / 0
|
|
2287
|
+
});
|
|
2288
|
+
i(this, "updateLoadedArea", (e) => {
|
|
2289
|
+
this.loadedArea = {
|
|
2290
|
+
xFrom: e.x,
|
|
2291
|
+
xTo: e.x + e.width,
|
|
2292
|
+
yFrom: e.y,
|
|
2293
|
+
yTo: e.y + e.height
|
|
2294
|
+
};
|
|
2295
|
+
});
|
|
2296
|
+
var c, a;
|
|
2297
|
+
this.trigger = r, this.virtualScrollOptions = n, this.nodeHorizontal = this.virtualScrollOptions.maxNodeContainingRadius.horizontal, this.nodeVertical = this.virtualScrollOptions.maxNodeContainingRadius.vertical, this.canvasResizeObserver = new this.window.ResizeObserver((l) => {
|
|
2298
|
+
const g = l[0];
|
|
2299
|
+
this.viewportWidth = g.contentRect.width, this.viewportHeight = g.contentRect.height, this.scheduleLoadAreaAroundViewport();
|
|
2300
|
+
});
|
|
2301
|
+
const d = ((c = o == null ? void 0 : o.events) == null ? void 0 : c.onTransformFinished) ?? (() => {
|
|
2302
|
+
}), s = ((a = o == null ? void 0 : o.events) == null ? void 0 : a.onTransformChange) ?? (() => {
|
|
2303
|
+
}), h = {
|
|
2304
|
+
...o,
|
|
2305
|
+
events: {
|
|
2306
|
+
...o == null ? void 0 : o.events,
|
|
2307
|
+
onTransformChange: () => {
|
|
2308
|
+
const l = this.viewportMatrix;
|
|
2309
|
+
this.viewportMatrix = this.canvas.viewport.getViewportMatrix(), l.scale !== this.viewportMatrix.scale && this.scheduleEnsureViewportAreaLoaded(), s();
|
|
2310
|
+
},
|
|
2311
|
+
onTransformFinished: () => {
|
|
2312
|
+
this.scheduleLoadAreaAroundViewport(), d();
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2315
|
+
};
|
|
2316
|
+
this.canvas = new ae(
|
|
2317
|
+
e,
|
|
2318
|
+
h
|
|
2319
|
+
), this.viewportMatrix = this.canvas.viewport.getViewportMatrix(), this.viewport = this.canvas.viewport, this.transformation = this.viewport, this.graph = this.canvas.graph, this.model = this.graph, this.trigger.subscribe(this.updateLoadedArea);
|
|
2320
|
+
}
|
|
2321
|
+
attach(e) {
|
|
2322
|
+
return this.detach(), this.element = e, this.canvasResizeObserver.observe(this.element), this.canvas.attach(e), this;
|
|
2323
|
+
}
|
|
2324
|
+
detach() {
|
|
2325
|
+
return this.element !== null && (this.canvasResizeObserver.unobserve(this.element), this.element = null, this.viewportWidth = 0, this.viewportHeight = 0), this.canvas.detach(), this;
|
|
2326
|
+
}
|
|
2327
|
+
addNode(e) {
|
|
2328
|
+
return this.canvas.addNode(e), this;
|
|
2329
|
+
}
|
|
2330
|
+
updateNode(e, r) {
|
|
2331
|
+
return this.canvas.updateNode(e, r), this;
|
|
2332
|
+
}
|
|
2333
|
+
removeNode(e) {
|
|
2334
|
+
return this.canvas.removeNode(e), this;
|
|
2335
|
+
}
|
|
2336
|
+
markPort(e) {
|
|
2337
|
+
return this.canvas.markPort(e), this;
|
|
2338
|
+
}
|
|
2339
|
+
updatePort(e, r) {
|
|
2340
|
+
return this.canvas.updatePort(e, r), this;
|
|
2341
|
+
}
|
|
2342
|
+
unmarkPort(e) {
|
|
2343
|
+
return this.canvas.unmarkPort(e), this;
|
|
2344
|
+
}
|
|
2345
|
+
addEdge(e) {
|
|
2346
|
+
return this.canvas.addEdge(e), this;
|
|
2347
|
+
}
|
|
2348
|
+
updateEdge(e, r) {
|
|
2349
|
+
return this.canvas.updateEdge(e, r), this;
|
|
2350
|
+
}
|
|
2351
|
+
removeEdge(e) {
|
|
2352
|
+
return this.canvas.removeEdge(e), this;
|
|
2353
|
+
}
|
|
2354
|
+
patchViewportMatrix(e) {
|
|
2355
|
+
return this.canvas.patchViewportMatrix(e), this.viewportMatrix = this.canvas.viewport.getViewportMatrix(), this.loadAreaAroundViewport(), this;
|
|
2356
|
+
}
|
|
2357
|
+
patchContentMatrix(e) {
|
|
2358
|
+
return this.canvas.patchContentMatrix(e), this.viewportMatrix = this.canvas.viewport.getViewportMatrix(), this.loadAreaAroundViewport(), this;
|
|
2359
|
+
}
|
|
2360
|
+
clear() {
|
|
2361
|
+
return this.canvas.clear(), this;
|
|
2362
|
+
}
|
|
2363
|
+
destroy() {
|
|
2364
|
+
this.trigger.unsubscribe(this.updateLoadedArea), this.canvas.destroy();
|
|
2365
|
+
}
|
|
2366
|
+
scheduleLoadAreaAroundViewport() {
|
|
2367
|
+
setTimeout(() => {
|
|
2368
|
+
this.loadAreaAroundViewport();
|
|
2369
|
+
});
|
|
2370
|
+
}
|
|
2371
|
+
scheduleEnsureViewportAreaLoaded() {
|
|
2372
|
+
const e = this.viewportWidth * this.viewportMatrix.scale, r = this.viewportHeight * this.viewportMatrix.scale, o = this.viewportMatrix.x - this.nodeHorizontal, n = this.viewportMatrix.y - this.nodeVertical, d = this.viewportMatrix.x + e + this.nodeHorizontal, s = this.viewportMatrix.y + r + this.nodeVertical;
|
|
2373
|
+
this.loadedArea.xFrom < o && this.loadedArea.xTo > d && this.loadedArea.yFrom < n && this.loadedArea.yTo > s || this.scheduleLoadAreaAroundViewport();
|
|
2374
|
+
}
|
|
2375
|
+
loadAreaAroundViewport() {
|
|
2376
|
+
const e = this.viewportWidth * this.viewportMatrix.scale, r = this.viewportHeight * this.viewportMatrix.scale, o = this.viewportMatrix.x - e - this.nodeHorizontal, n = this.viewportMatrix.y - r - this.nodeVertical, d = 3 * e + 2 * this.nodeHorizontal, s = 3 * r + 2 * this.nodeVertical;
|
|
2377
|
+
this.trigger.emit({ x: o, y: n, width: d, height: s });
|
|
2378
|
+
}
|
|
2379
|
+
}
|
|
2380
|
+
class Ke {
|
|
2252
2381
|
constructor() {
|
|
2253
2382
|
i(this, "coreOptions", {});
|
|
2254
2383
|
i(this, "dragOptions");
|
|
2255
2384
|
i(this, "transformOptions");
|
|
2385
|
+
i(this, "virtualScrollOptions");
|
|
2256
2386
|
i(this, "hasDraggableNode", !1);
|
|
2257
2387
|
i(this, "hasTransformableViewport", !1);
|
|
2258
2388
|
i(this, "hasResizeReactiveNodes", !1);
|
|
2259
|
-
i(this, "boxRenderingTrigger"
|
|
2389
|
+
i(this, "boxRenderingTrigger");
|
|
2260
2390
|
}
|
|
2261
2391
|
/**
|
|
2262
2392
|
* specifies options for fundamental aspects of visualization
|
|
@@ -2295,30 +2425,40 @@ class je {
|
|
|
2295
2425
|
setBoxRenderingTrigger(e) {
|
|
2296
2426
|
return this.boxRenderingTrigger = e, this;
|
|
2297
2427
|
}
|
|
2428
|
+
setVirtualScroll(e) {
|
|
2429
|
+
return this.virtualScrollOptions = e, this;
|
|
2430
|
+
}
|
|
2298
2431
|
/**
|
|
2299
2432
|
* builds final canvas
|
|
2300
2433
|
*/
|
|
2301
2434
|
build() {
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2435
|
+
let e = this.boxRenderingTrigger;
|
|
2436
|
+
this.virtualScrollOptions !== void 0 && e === void 0 && (e = new se());
|
|
2437
|
+
const r = e !== void 0 ? $e(e) : De, o = new Le(this.coreOptions, r);
|
|
2438
|
+
let n = new be(o);
|
|
2439
|
+
return this.hasResizeReactiveNodes && (n = new ze(n)), this.hasDraggableNode && (n = new We(n, this.dragOptions)), this.virtualScrollOptions !== void 0 ? n = new He(
|
|
2440
|
+
n,
|
|
2441
|
+
e,
|
|
2442
|
+
this.transformOptions,
|
|
2443
|
+
this.virtualScrollOptions
|
|
2444
|
+
) : this.hasTransformableViewport && (n = new ae(
|
|
2445
|
+
n,
|
|
2306
2446
|
this.transformOptions
|
|
2307
|
-
)),
|
|
2447
|
+
)), n;
|
|
2308
2448
|
}
|
|
2309
2449
|
}
|
|
2310
2450
|
export {
|
|
2311
|
-
|
|
2312
|
-
|
|
2451
|
+
ee as BezierEdgeShape,
|
|
2452
|
+
Ke as CanvasBuilder,
|
|
2313
2453
|
Ge as CanvasCore,
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2454
|
+
se as EventSubject,
|
|
2455
|
+
te as HorizontalEdgeShape,
|
|
2456
|
+
Ke as HtmlGraphBuilder,
|
|
2317
2457
|
A as HtmlGraphError,
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2458
|
+
ze as ResizeReactiveNodesCanvas,
|
|
2459
|
+
re as StraightEdgeShape,
|
|
2460
|
+
We as UserDraggableNodesCanvas,
|
|
2461
|
+
ae as UserTransformableCanvas,
|
|
2462
|
+
ae as UserTransformableViewportCanvas,
|
|
2463
|
+
oe as VerticalEdgeShape
|
|
2324
2464
|
};
|