@html-graph/html-graph 1.0.0 → 1.1.1
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 +5 -5
- package/dist/main.d.ts +194 -39
- package/dist/main.js +1657 -1337
- package/dist/main.umd.cjs +1 -1
- package/package.json +1 -3
package/dist/main.js
CHANGED
|
@@ -1,235 +1,235 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
const
|
|
5
|
-
x:
|
|
6
|
-
y:
|
|
7
|
-
}), v = (
|
|
8
|
-
x:
|
|
9
|
-
y:
|
|
10
|
-
}),
|
|
1
|
+
var de = Object.defineProperty;
|
|
2
|
+
var ce = (t, e, r) => e in t ? de(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
3
|
+
var i = (t, e, r) => ce(t, typeof e != "symbol" ? e + "" : e, r);
|
|
4
|
+
const Z = (t, e) => ({
|
|
5
|
+
x: t / 2,
|
|
6
|
+
y: e / 2
|
|
7
|
+
}), v = (t, e, r) => ({
|
|
8
|
+
x: e.x * t.x - e.y * t.y + ((1 - e.x) * r.x + e.y * r.y),
|
|
9
|
+
y: e.y * t.x + e.x * t.y + ((1 - e.x) * r.y - e.y * r.x)
|
|
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
|
-
},
|
|
14
|
-
const
|
|
13
|
+
}, T = (t, e, r, o) => {
|
|
14
|
+
const d = [
|
|
15
15
|
w,
|
|
16
|
-
{ x:
|
|
17
|
-
{ x:
|
|
18
|
-
].map((
|
|
19
|
-
return `${
|
|
20
|
-
}, $ = (
|
|
21
|
-
const
|
|
22
|
-
if (
|
|
23
|
-
const
|
|
24
|
-
let
|
|
25
|
-
|
|
26
|
-
let
|
|
27
|
-
const
|
|
28
|
-
if (
|
|
29
|
-
const
|
|
30
|
-
|
|
16
|
+
{ x: r, y: o },
|
|
17
|
+
{ x: r, y: -o }
|
|
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
|
+
}, $ = (t, e) => {
|
|
21
|
+
const r = [];
|
|
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
|
+
const o = t.length - 1;
|
|
24
|
+
let n = 0, d = 0, s = 0;
|
|
25
|
+
t.forEach((h, c) => {
|
|
26
|
+
let a = 0, l = 0, u = 0;
|
|
27
|
+
const f = c > 0, A = c < o, y = f && A;
|
|
28
|
+
if (f && (a = -n, l = -d, u = s), A) {
|
|
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 =
|
|
33
|
-
|
|
34
|
-
`C ${
|
|
32
|
+
const E = s !== 0 ? Math.min((y ? e : 0) / s, c < o - 1 ? 0.5 : 1) : 0, C = y ? { x: h.x + n * E, y: h.y + d * E } : h, P = u !== 0 ? Math.min((y ? e : 0) / u, c > 1 ? 0.5 : 1) : 0, D = y ? { x: h.x + a * P, y: h.y + l * P } : h;
|
|
33
|
+
c > 0 && r.push(`L ${D.x} ${D.y}`), y && r.push(
|
|
34
|
+
`C ${h.x} ${h.y} ${h.x} ${h.y} ${C.x} ${C.y}`
|
|
35
35
|
);
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
|
-
return
|
|
39
|
-
},
|
|
40
|
-
const
|
|
41
|
-
return
|
|
42
|
-
},
|
|
43
|
-
const
|
|
44
|
-
return
|
|
45
|
-
},
|
|
46
|
-
const
|
|
47
|
-
return
|
|
48
|
-
},
|
|
49
|
-
const
|
|
50
|
-
return
|
|
51
|
-
},
|
|
52
|
-
const
|
|
53
|
-
x: e.x + e.width / 2,
|
|
54
|
-
y: e.y + e.height / 2
|
|
55
|
-
}, r = {
|
|
38
|
+
return r.join(" ");
|
|
39
|
+
}, B = () => {
|
|
40
|
+
const t = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
41
|
+
return t.style.pointerEvents = "none", t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.overflow = "visible", t;
|
|
42
|
+
}, k = () => {
|
|
43
|
+
const t = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
|
44
|
+
return t.style.transformOrigin = "50% 50%", t;
|
|
45
|
+
}, Y = (t, e) => {
|
|
46
|
+
const r = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
47
|
+
return r.setAttribute("stroke", t), r.setAttribute("stroke-width", `${e}`), r.setAttribute("fill", "none"), r;
|
|
48
|
+
}, p = (t) => {
|
|
49
|
+
const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
50
|
+
return e.setAttribute("fill", t), e;
|
|
51
|
+
}, X = (t, e) => {
|
|
52
|
+
const r = {
|
|
56
53
|
x: t.x + t.width / 2,
|
|
57
54
|
y: t.y + t.height / 2
|
|
58
|
-
},
|
|
55
|
+
}, o = {
|
|
56
|
+
x: e.x + e.width / 2,
|
|
57
|
+
y: e.y + e.height / 2
|
|
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:
|
|
61
|
-
y:
|
|
62
|
-
width:
|
|
63
|
-
height:
|
|
64
|
-
flipX:
|
|
65
|
-
flipY:
|
|
60
|
+
x: n,
|
|
61
|
+
y: d,
|
|
62
|
+
width: s,
|
|
63
|
+
height: h,
|
|
64
|
+
flipX: c,
|
|
65
|
+
flipY: a
|
|
66
66
|
};
|
|
67
|
-
},
|
|
68
|
-
const
|
|
69
|
-
{ x:
|
|
70
|
-
|
|
67
|
+
}, ae = (t) => {
|
|
68
|
+
const e = v(
|
|
69
|
+
{ x: t.arrowLength, y: w.y },
|
|
70
|
+
t.fromVect,
|
|
71
71
|
w
|
|
72
|
-
),
|
|
73
|
-
{ x:
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
),
|
|
77
|
-
x:
|
|
78
|
-
y:
|
|
79
|
-
},
|
|
80
|
-
x:
|
|
81
|
-
y:
|
|
82
|
-
},
|
|
83
|
-
return `${
|
|
84
|
-
},
|
|
85
|
-
const
|
|
86
|
-
{ x:
|
|
87
|
-
|
|
72
|
+
), r = v(
|
|
73
|
+
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
74
|
+
t.toVect,
|
|
75
|
+
t.to
|
|
76
|
+
), o = {
|
|
77
|
+
x: e.x + t.fromVect.x * t.curvature,
|
|
78
|
+
y: e.y + t.fromVect.y * t.curvature
|
|
79
|
+
}, n = {
|
|
80
|
+
x: r.x - t.toVect.x * t.curvature,
|
|
81
|
+
y: r.y - t.toVect.y * t.curvature
|
|
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
|
+
}, le = (t) => {
|
|
85
|
+
const e = t.hasSourceArrow ? v(
|
|
86
|
+
{ x: t.arrowLength, y: w.y },
|
|
87
|
+
t.fromVect,
|
|
88
88
|
w
|
|
89
|
-
) : w,
|
|
90
|
-
{ x:
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
) :
|
|
94
|
-
{ x:
|
|
95
|
-
|
|
89
|
+
) : w, r = t.hasTargetArrow ? v(
|
|
90
|
+
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
91
|
+
t.toVect,
|
|
92
|
+
t.to
|
|
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
|
+
{ x: o, y: w.y },
|
|
95
|
+
t.fromVect,
|
|
96
96
|
w
|
|
97
|
-
),
|
|
98
|
-
x:
|
|
99
|
-
y:
|
|
100
|
-
},
|
|
101
|
-
{ x:
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
),
|
|
105
|
-
x:
|
|
106
|
-
y:
|
|
107
|
-
},
|
|
108
|
-
x:
|
|
109
|
-
y:
|
|
110
|
-
},
|
|
111
|
-
x:
|
|
112
|
-
y:
|
|
113
|
-
},
|
|
114
|
-
x:
|
|
115
|
-
y:
|
|
97
|
+
), a = {
|
|
98
|
+
x: c.x + s,
|
|
99
|
+
y: c.y + h
|
|
100
|
+
}, l = v(
|
|
101
|
+
{ x: t.to.x - o, y: t.to.y },
|
|
102
|
+
t.toVect,
|
|
103
|
+
t.to
|
|
104
|
+
), u = {
|
|
105
|
+
x: l.x + s,
|
|
106
|
+
y: l.y + h
|
|
107
|
+
}, f = { x: (a.x + u.x) / 2, y: (a.y + u.y) / 2 }, A = {
|
|
108
|
+
x: c.x + t.curvature * t.fromVect.x,
|
|
109
|
+
y: c.y + t.curvature * t.fromVect.y
|
|
110
|
+
}, y = {
|
|
111
|
+
x: l.x - t.curvature * t.toVect.x,
|
|
112
|
+
y: l.y - t.curvature * t.toVect.y
|
|
113
|
+
}, m = {
|
|
114
|
+
x: c.x + s,
|
|
115
|
+
y: c.y + h
|
|
116
116
|
}, E = {
|
|
117
|
-
x:
|
|
118
|
-
y:
|
|
117
|
+
x: l.x + s,
|
|
118
|
+
y: l.y + h
|
|
119
119
|
};
|
|
120
120
|
return [
|
|
121
|
-
`M ${
|
|
122
|
-
`L ${
|
|
123
|
-
`C ${
|
|
124
|
-
`C ${E.x} ${E.y} ${
|
|
125
|
-
`L ${
|
|
121
|
+
`M ${e.x} ${e.y}`,
|
|
122
|
+
`L ${c.x} ${c.y}`,
|
|
123
|
+
`C ${A.x} ${A.y} ${m.x} ${m.y} ${f.x} ${f.y}`,
|
|
124
|
+
`C ${E.x} ${E.y} ${y.x} ${y.y} ${l.x} ${l.y}`,
|
|
125
|
+
`L ${r.x} ${r.y}`
|
|
126
126
|
].join(" ");
|
|
127
|
-
},
|
|
128
|
-
const
|
|
129
|
-
{ x:
|
|
130
|
-
|
|
127
|
+
}, ue = (t) => {
|
|
128
|
+
const e = t.hasSourceArrow ? v(
|
|
129
|
+
{ x: t.arrowLength, y: w.y },
|
|
130
|
+
t.fromVect,
|
|
131
131
|
w
|
|
132
|
-
) : w,
|
|
133
|
-
{ x:
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
) :
|
|
137
|
-
{ x:
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
),
|
|
141
|
-
x:
|
|
142
|
-
y:
|
|
143
|
-
},
|
|
132
|
+
) : w, r = t.hasTargetArrow ? v(
|
|
133
|
+
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
134
|
+
t.toVect,
|
|
135
|
+
t.to
|
|
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
|
+
t.toVect,
|
|
139
|
+
t.to
|
|
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 }, u = {
|
|
141
|
+
x: t.flipX > 0 ? t.to.x - h : t.to.x + o,
|
|
142
|
+
y: s.y
|
|
143
|
+
}, f = { x: u.x, y: c };
|
|
144
144
|
return $(
|
|
145
|
-
[
|
|
146
|
-
|
|
145
|
+
[e, d, a, l, f, u, s, r],
|
|
146
|
+
t.roundness
|
|
147
147
|
);
|
|
148
|
-
},
|
|
149
|
-
const
|
|
150
|
-
{ x:
|
|
151
|
-
|
|
148
|
+
}, j = (t) => {
|
|
149
|
+
const e = t.hasSourceArrow ? v(
|
|
150
|
+
{ x: t.arrowLength, y: w.y },
|
|
151
|
+
t.fromVect,
|
|
152
152
|
w
|
|
153
|
-
) : w,
|
|
154
|
-
{ x:
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
) :
|
|
158
|
-
{ x:
|
|
159
|
-
|
|
153
|
+
) : w, r = t.hasTargetArrow ? v(
|
|
154
|
+
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
155
|
+
t.toVect,
|
|
156
|
+
t.to
|
|
157
|
+
) : t.to, o = t.arrowLength + t.arrowOffset, n = v(
|
|
158
|
+
{ x: o, y: w.y },
|
|
159
|
+
t.fromVect,
|
|
160
160
|
w
|
|
161
|
-
),
|
|
162
|
-
{ x:
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
),
|
|
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
|
+
{ x: t.to.x - o, y: t.to.y },
|
|
163
|
+
t.toVect,
|
|
164
|
+
t.to
|
|
165
|
+
), u = { x: l.x + h, y: l.y + c };
|
|
166
166
|
return $(
|
|
167
|
-
[
|
|
168
|
-
|
|
167
|
+
[e, n, a, u, l, r],
|
|
168
|
+
t.roundness
|
|
169
169
|
);
|
|
170
|
-
},
|
|
171
|
-
const
|
|
172
|
-
{ x:
|
|
173
|
-
|
|
170
|
+
}, ge = (t) => {
|
|
171
|
+
const e = t.hasSourceArrow ? v(
|
|
172
|
+
{ x: t.arrowLength, y: w.y },
|
|
173
|
+
t.fromVect,
|
|
174
174
|
w
|
|
175
|
-
) : w,
|
|
176
|
-
{ x:
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
) :
|
|
180
|
-
{ x:
|
|
181
|
-
|
|
182
|
-
|
|
175
|
+
) : w, r = t.hasTargetArrow ? v(
|
|
176
|
+
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
177
|
+
t.toVect,
|
|
178
|
+
t.to
|
|
179
|
+
) : t.to, o = t.arrowLength + t.arrowOffset, n = v({ x: o, y: w.y }, t.fromVect, w), d = v(
|
|
180
|
+
{ x: t.to.x - o, y: t.to.y },
|
|
181
|
+
t.toVect,
|
|
182
|
+
t.to
|
|
183
183
|
);
|
|
184
|
-
return $([
|
|
185
|
-
},
|
|
186
|
-
const
|
|
187
|
-
{ x:
|
|
188
|
-
|
|
184
|
+
return $([e, n, d, r], t.roundness);
|
|
185
|
+
}, we = (t) => {
|
|
186
|
+
const e = t.hasSourceArrow ? v(
|
|
187
|
+
{ x: t.arrowLength, y: w.y },
|
|
188
|
+
t.fromVect,
|
|
189
189
|
w
|
|
190
|
-
) : w,
|
|
191
|
-
{ x:
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
) :
|
|
195
|
-
{ x:
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
),
|
|
199
|
-
x:
|
|
200
|
-
y:
|
|
201
|
-
},
|
|
190
|
+
) : w, r = t.hasTargetArrow ? v(
|
|
191
|
+
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
192
|
+
t.toVect,
|
|
193
|
+
t.to
|
|
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
|
+
t.toVect,
|
|
197
|
+
t.to
|
|
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 }, u = {
|
|
199
|
+
x: s.x,
|
|
200
|
+
y: t.flipY > 0 ? t.to.y - h : t.to.y + o
|
|
201
|
+
}, f = { x: c, y: u.y };
|
|
202
202
|
return $(
|
|
203
|
-
[
|
|
204
|
-
|
|
203
|
+
[e, d, a, l, f, u, s, r],
|
|
204
|
+
t.roundness
|
|
205
205
|
);
|
|
206
|
-
},
|
|
207
|
-
const
|
|
208
|
-
{ x:
|
|
209
|
-
{ x:
|
|
210
|
-
{ x:
|
|
211
|
-
{ x:
|
|
212
|
-
{ x:
|
|
213
|
-
{ x:
|
|
214
|
-
{ x:
|
|
215
|
-
{ x:
|
|
206
|
+
}, H = (t) => {
|
|
207
|
+
const e = t.arrowOffset, r = t.side, o = t.arrowLength + e, n = o + 2 * r, s = [
|
|
208
|
+
{ x: t.arrowLength, y: w.y },
|
|
209
|
+
{ x: o, y: w.y },
|
|
210
|
+
{ x: o, y: t.side },
|
|
211
|
+
{ x: n, y: t.side },
|
|
212
|
+
{ x: n, y: -t.side },
|
|
213
|
+
{ x: o, y: -t.side },
|
|
214
|
+
{ x: o, y: w.y },
|
|
215
|
+
{ x: t.arrowLength, y: w.y }
|
|
216
216
|
].map(
|
|
217
|
-
(
|
|
218
|
-
),
|
|
219
|
-
return `${
|
|
220
|
-
},
|
|
221
|
-
const
|
|
222
|
-
{ x:
|
|
223
|
-
{ x:
|
|
224
|
-
{ x:
|
|
225
|
-
].map((
|
|
226
|
-
`M ${
|
|
227
|
-
`A ${
|
|
228
|
-
`A ${
|
|
229
|
-
`A ${
|
|
230
|
-
].join(" "),
|
|
231
|
-
return `${
|
|
232
|
-
},
|
|
217
|
+
(c) => v(c, t.fromVect, w)
|
|
218
|
+
), h = `M ${w.x} ${w.y} L ${s[0].x} ${s[0].y} `;
|
|
219
|
+
return `${t.hasSourceArrow || t.hasTargetArrow ? "" : h}${$(s, t.roundness)}`;
|
|
220
|
+
}, fe = (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
|
+
{ x: t.arrowLength, y: w.y },
|
|
223
|
+
{ x: d, y: s },
|
|
224
|
+
{ x: d, y: -s }
|
|
225
|
+
].map((u) => v(u, t.fromVect, w)), a = [
|
|
226
|
+
`M ${c[0].x} ${c[0].y}`,
|
|
227
|
+
`A ${e} ${e} 0 0 1 ${c[1].x} ${c[1].y}`,
|
|
228
|
+
`A ${r} ${r} 0 1 0 ${c[2].x} ${c[2].y}`,
|
|
229
|
+
`A ${e} ${e} 0 0 1 ${c[0].x} ${c[0].y}`
|
|
230
|
+
].join(" "), l = `M 0 0 L ${c[0].x} ${c[0].y} `;
|
|
231
|
+
return `${t.hasSourceArrow || t.hasTargetArrow ? "" : l}${a}`;
|
|
232
|
+
}, g = Object.freeze({
|
|
233
233
|
color: "#777777",
|
|
234
234
|
width: 1,
|
|
235
235
|
arrowLength: 15,
|
|
@@ -246,143 +246,143 @@ const O = (e, t) => ({
|
|
|
246
246
|
smallCycleRadius: 15,
|
|
247
247
|
curvature: 90
|
|
248
248
|
});
|
|
249
|
-
class
|
|
250
|
-
constructor(
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
this.arrowLength = (
|
|
266
|
-
const
|
|
267
|
-
this.svg.appendChild(this.group), this.line =
|
|
268
|
-
}
|
|
269
|
-
render(
|
|
270
|
-
const { x:
|
|
271
|
-
|
|
272
|
-
|
|
249
|
+
class q {
|
|
250
|
+
constructor(e) {
|
|
251
|
+
i(this, "svg", B());
|
|
252
|
+
i(this, "group", k());
|
|
253
|
+
i(this, "line");
|
|
254
|
+
i(this, "sourceArrow", null);
|
|
255
|
+
i(this, "targetArrow", null);
|
|
256
|
+
i(this, "arrowLength");
|
|
257
|
+
i(this, "arrowWidth");
|
|
258
|
+
i(this, "curvature");
|
|
259
|
+
i(this, "portCycleRadius");
|
|
260
|
+
i(this, "portCycleSmallRadius");
|
|
261
|
+
i(this, "detourDirection");
|
|
262
|
+
i(this, "detourDistance");
|
|
263
|
+
i(this, "hasSourceArrow");
|
|
264
|
+
i(this, "hasTargetArrow");
|
|
265
|
+
this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? g.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? g.arrowWidth, this.curvature = (e == null ? void 0 : e.curvature) ?? g.curvature, this.portCycleRadius = (e == null ? void 0 : e.cycleRadius) ?? g.cycleRadius, this.portCycleSmallRadius = (e == null ? void 0 : e.smallCycleRadius) ?? g.smallCycleRadius, this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? g.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? g.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? g.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? g.hasTargetArrow;
|
|
266
|
+
const r = (e == null ? void 0 : e.color) ?? g.color, o = (e == null ? void 0 : e.width) ?? g.width;
|
|
267
|
+
this.svg.appendChild(this.group), this.line = Y(r, o), 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));
|
|
268
|
+
}
|
|
269
|
+
render(e) {
|
|
270
|
+
const { x: r, y: o, width: n, height: d, flipX: s, flipY: h } = X(
|
|
271
|
+
e.from,
|
|
272
|
+
e.to
|
|
273
273
|
);
|
|
274
|
-
this.svg.style.transform = `translate(${
|
|
275
|
-
const
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
),
|
|
280
|
-
x:
|
|
281
|
-
y:
|
|
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
|
+
e.from.direction,
|
|
277
|
+
s,
|
|
278
|
+
h
|
|
279
|
+
), a = N(e.to.direction, s, h), l = {
|
|
280
|
+
x: n,
|
|
281
|
+
y: d
|
|
282
282
|
};
|
|
283
|
-
let
|
|
284
|
-
if (
|
|
285
|
-
fromVect:
|
|
283
|
+
let u, f = a, A = -this.arrowLength;
|
|
284
|
+
if (e.from.portId === e.to.portId ? (u = fe({
|
|
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
|
-
}),
|
|
292
|
-
to:
|
|
293
|
-
fromVect:
|
|
294
|
-
toVect:
|
|
295
|
-
flipX:
|
|
296
|
-
flipY:
|
|
291
|
+
}), f = c, A = this.arrowLength) : e.from.nodeId === e.to.nodeId ? u = le({
|
|
292
|
+
to: l,
|
|
293
|
+
fromVect: c,
|
|
294
|
+
toVect: a,
|
|
295
|
+
flipX: s,
|
|
296
|
+
flipY: h,
|
|
297
297
|
arrowLength: this.arrowLength,
|
|
298
298
|
detourDirection: this.detourDirection,
|
|
299
299
|
detourDistance: this.detourDistance,
|
|
300
300
|
curvature: this.curvature,
|
|
301
301
|
hasSourceArrow: this.hasSourceArrow,
|
|
302
302
|
hasTargetArrow: this.hasTargetArrow
|
|
303
|
-
}) :
|
|
304
|
-
to:
|
|
305
|
-
fromVect:
|
|
306
|
-
toVect:
|
|
303
|
+
}) : u = ae({
|
|
304
|
+
to: l,
|
|
305
|
+
fromVect: c,
|
|
306
|
+
toVect: a,
|
|
307
307
|
arrowLength: this.arrowLength,
|
|
308
308
|
curvature: this.curvature,
|
|
309
309
|
hasSourceArrow: this.hasSourceArrow,
|
|
310
310
|
hasTargetArrow: this.hasTargetArrow
|
|
311
|
-
}), this.line.setAttribute("d",
|
|
312
|
-
const
|
|
313
|
-
|
|
311
|
+
}), this.line.setAttribute("d", u), this.sourceArrow) {
|
|
312
|
+
const y = T(
|
|
313
|
+
c,
|
|
314
314
|
w,
|
|
315
315
|
this.arrowLength,
|
|
316
316
|
this.arrowWidth
|
|
317
317
|
);
|
|
318
|
-
this.sourceArrow.setAttribute("d",
|
|
318
|
+
this.sourceArrow.setAttribute("d", y);
|
|
319
319
|
}
|
|
320
320
|
if (this.targetArrow) {
|
|
321
|
-
const
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
321
|
+
const y = T(
|
|
322
|
+
f,
|
|
323
|
+
l,
|
|
324
|
+
A,
|
|
325
325
|
this.arrowWidth
|
|
326
326
|
);
|
|
327
|
-
this.targetArrow.setAttribute("d",
|
|
327
|
+
this.targetArrow.setAttribute("d", y);
|
|
328
328
|
}
|
|
329
329
|
}
|
|
330
330
|
}
|
|
331
|
-
class
|
|
332
|
-
constructor(
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
this.arrowLength = (
|
|
348
|
-
const
|
|
331
|
+
class O {
|
|
332
|
+
constructor(e) {
|
|
333
|
+
i(this, "svg", B());
|
|
334
|
+
i(this, "group", k());
|
|
335
|
+
i(this, "line");
|
|
336
|
+
i(this, "sourceArrow", null);
|
|
337
|
+
i(this, "targetArrow", null);
|
|
338
|
+
i(this, "arrowLength");
|
|
339
|
+
i(this, "arrowWidth");
|
|
340
|
+
i(this, "arrowOffset");
|
|
341
|
+
i(this, "roundness");
|
|
342
|
+
i(this, "cycleSquareSide");
|
|
343
|
+
i(this, "detourDirection");
|
|
344
|
+
i(this, "detourDistance");
|
|
345
|
+
i(this, "hasSourceArrow");
|
|
346
|
+
i(this, "hasTargetArrow");
|
|
347
|
+
this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? g.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? g.arrowWidth, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? g.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? g.cycleSquareSide;
|
|
348
|
+
const r = (e == null ? void 0 : e.roundness) ?? g.roundness;
|
|
349
349
|
this.roundness = Math.min(
|
|
350
|
-
|
|
350
|
+
r,
|
|
351
351
|
this.arrowOffset,
|
|
352
352
|
this.cycleSquareSide / 2
|
|
353
|
-
), this.detourDirection = (
|
|
354
|
-
const
|
|
355
|
-
this.svg.appendChild(this.group), this.line =
|
|
356
|
-
}
|
|
357
|
-
render(
|
|
358
|
-
const { x:
|
|
359
|
-
|
|
360
|
-
|
|
353
|
+
), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? g.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? g.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? g.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? g.hasTargetArrow;
|
|
354
|
+
const o = (e == null ? void 0 : e.color) ?? g.color, n = (e == null ? void 0 : e.width) ?? g.width;
|
|
355
|
+
this.svg.appendChild(this.group), this.line = Y(o, n), 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));
|
|
356
|
+
}
|
|
357
|
+
render(e) {
|
|
358
|
+
const { x: r, y: o, width: n, height: d, flipX: s, flipY: h } = X(
|
|
359
|
+
e.from,
|
|
360
|
+
e.to
|
|
361
361
|
);
|
|
362
|
-
this.svg.style.transform = `translate(${
|
|
363
|
-
const
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
),
|
|
368
|
-
x:
|
|
369
|
-
y:
|
|
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
|
+
e.from.direction,
|
|
365
|
+
s,
|
|
366
|
+
h
|
|
367
|
+
), a = N(e.to.direction, s, h), l = {
|
|
368
|
+
x: n,
|
|
369
|
+
y: d
|
|
370
370
|
};
|
|
371
|
-
let
|
|
372
|
-
if (
|
|
373
|
-
fromVect:
|
|
371
|
+
let u, f = a, A = -this.arrowLength;
|
|
372
|
+
if (e.from.portId === e.to.portId ? (u = H({
|
|
373
|
+
fromVect: c,
|
|
374
374
|
arrowLength: this.arrowLength,
|
|
375
375
|
side: this.cycleSquareSide,
|
|
376
376
|
arrowOffset: this.arrowOffset,
|
|
377
377
|
roundness: this.roundness,
|
|
378
378
|
hasSourceArrow: this.hasSourceArrow,
|
|
379
379
|
hasTargetArrow: this.hasTargetArrow
|
|
380
|
-
}),
|
|
381
|
-
to:
|
|
382
|
-
fromVect:
|
|
383
|
-
toVect:
|
|
384
|
-
flipX:
|
|
385
|
-
flipY:
|
|
380
|
+
}), f = c, A = this.arrowLength) : e.from.nodeId === e.to.nodeId ? u = j({
|
|
381
|
+
to: l,
|
|
382
|
+
fromVect: c,
|
|
383
|
+
toVect: a,
|
|
384
|
+
flipX: s,
|
|
385
|
+
flipY: h,
|
|
386
386
|
arrowLength: this.arrowLength,
|
|
387
387
|
arrowOffset: this.arrowOffset,
|
|
388
388
|
roundness: this.roundness,
|
|
@@ -390,91 +390,91 @@ class st {
|
|
|
390
390
|
detourDistance: this.detourDistance,
|
|
391
391
|
hasSourceArrow: this.hasSourceArrow,
|
|
392
392
|
hasTargetArrow: this.hasTargetArrow
|
|
393
|
-
}) :
|
|
394
|
-
to:
|
|
395
|
-
fromVect:
|
|
396
|
-
toVect:
|
|
397
|
-
flipX:
|
|
393
|
+
}) : u = ue({
|
|
394
|
+
to: l,
|
|
395
|
+
fromVect: c,
|
|
396
|
+
toVect: a,
|
|
397
|
+
flipX: s,
|
|
398
398
|
arrowLength: this.arrowLength,
|
|
399
399
|
arrowOffset: this.arrowOffset,
|
|
400
400
|
roundness: this.roundness,
|
|
401
401
|
hasSourceArrow: this.hasSourceArrow,
|
|
402
402
|
hasTargetArrow: this.hasTargetArrow
|
|
403
|
-
}), this.line.setAttribute("d",
|
|
404
|
-
const
|
|
405
|
-
|
|
403
|
+
}), this.line.setAttribute("d", u), this.sourceArrow) {
|
|
404
|
+
const y = T(
|
|
405
|
+
c,
|
|
406
406
|
w,
|
|
407
407
|
this.arrowLength,
|
|
408
408
|
this.arrowWidth
|
|
409
409
|
);
|
|
410
|
-
this.sourceArrow.setAttribute("d",
|
|
410
|
+
this.sourceArrow.setAttribute("d", y);
|
|
411
411
|
}
|
|
412
412
|
if (this.targetArrow) {
|
|
413
|
-
const
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
413
|
+
const y = T(
|
|
414
|
+
f,
|
|
415
|
+
l,
|
|
416
|
+
A,
|
|
417
417
|
this.arrowWidth
|
|
418
418
|
);
|
|
419
|
-
this.targetArrow.setAttribute("d",
|
|
419
|
+
this.targetArrow.setAttribute("d", y);
|
|
420
420
|
}
|
|
421
421
|
}
|
|
422
422
|
}
|
|
423
|
-
class
|
|
424
|
-
constructor(
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
this.arrowLength = (
|
|
440
|
-
const
|
|
423
|
+
class ee {
|
|
424
|
+
constructor(e) {
|
|
425
|
+
i(this, "svg", B());
|
|
426
|
+
i(this, "group", k());
|
|
427
|
+
i(this, "line");
|
|
428
|
+
i(this, "sourceArrow", null);
|
|
429
|
+
i(this, "targetArrow", null);
|
|
430
|
+
i(this, "arrowLength");
|
|
431
|
+
i(this, "arrowWidth");
|
|
432
|
+
i(this, "arrowOffset");
|
|
433
|
+
i(this, "roundness");
|
|
434
|
+
i(this, "cycleSquareSide");
|
|
435
|
+
i(this, "detourDirection");
|
|
436
|
+
i(this, "detourDistance");
|
|
437
|
+
i(this, "hasSourceArrow");
|
|
438
|
+
i(this, "hasTargetArrow");
|
|
439
|
+
this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? g.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? g.arrowWidth, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? g.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? g.cycleSquareSide;
|
|
440
|
+
const r = (e == null ? void 0 : e.roundness) ?? g.roundness;
|
|
441
441
|
this.roundness = Math.min(
|
|
442
|
-
|
|
442
|
+
r,
|
|
443
443
|
this.arrowOffset,
|
|
444
444
|
this.cycleSquareSide / 2
|
|
445
|
-
), this.detourDirection = (
|
|
446
|
-
const
|
|
447
|
-
this.svg.appendChild(this.group), this.line =
|
|
448
|
-
}
|
|
449
|
-
render(
|
|
450
|
-
const { x:
|
|
451
|
-
|
|
452
|
-
|
|
445
|
+
), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? g.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? g.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? g.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? g.hasTargetArrow;
|
|
446
|
+
const o = (e == null ? void 0 : e.color) ?? g.color, n = (e == null ? void 0 : e.width) ?? g.width;
|
|
447
|
+
this.svg.appendChild(this.group), this.line = Y(o, n), 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));
|
|
448
|
+
}
|
|
449
|
+
render(e) {
|
|
450
|
+
const { x: r, y: o, width: n, height: d, flipX: s, flipY: h } = X(
|
|
451
|
+
e.from,
|
|
452
|
+
e.to
|
|
453
453
|
);
|
|
454
|
-
this.svg.style.transform = `translate(${
|
|
455
|
-
const
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
),
|
|
460
|
-
x:
|
|
461
|
-
y:
|
|
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
|
+
e.from.direction,
|
|
457
|
+
s,
|
|
458
|
+
h
|
|
459
|
+
), a = N(e.to.direction, s, h), l = {
|
|
460
|
+
x: n,
|
|
461
|
+
y: d
|
|
462
462
|
};
|
|
463
|
-
let
|
|
464
|
-
if (
|
|
465
|
-
fromVect:
|
|
463
|
+
let u, f = a, A = -this.arrowLength;
|
|
464
|
+
if (e.from.portId === e.to.portId ? (u = H({
|
|
465
|
+
fromVect: c,
|
|
466
466
|
arrowLength: this.arrowLength,
|
|
467
467
|
side: this.cycleSquareSide,
|
|
468
468
|
arrowOffset: this.arrowOffset,
|
|
469
469
|
roundness: this.roundness,
|
|
470
470
|
hasSourceArrow: this.hasSourceArrow,
|
|
471
471
|
hasTargetArrow: this.hasTargetArrow
|
|
472
|
-
}),
|
|
473
|
-
to:
|
|
474
|
-
fromVect:
|
|
475
|
-
toVect:
|
|
476
|
-
flipX:
|
|
477
|
-
flipY:
|
|
472
|
+
}), f = c, A = this.arrowLength) : e.from.nodeId === e.to.nodeId ? u = j({
|
|
473
|
+
to: l,
|
|
474
|
+
fromVect: c,
|
|
475
|
+
toVect: a,
|
|
476
|
+
flipX: s,
|
|
477
|
+
flipY: h,
|
|
478
478
|
arrowLength: this.arrowLength,
|
|
479
479
|
arrowOffset: this.arrowOffset,
|
|
480
480
|
roundness: this.roundness,
|
|
@@ -482,90 +482,90 @@ class ht {
|
|
|
482
482
|
detourDistance: this.detourDistance,
|
|
483
483
|
hasSourceArrow: this.hasSourceArrow,
|
|
484
484
|
hasTargetArrow: this.hasTargetArrow
|
|
485
|
-
}) :
|
|
486
|
-
to:
|
|
487
|
-
fromVect:
|
|
488
|
-
toVect:
|
|
485
|
+
}) : u = ge({
|
|
486
|
+
to: l,
|
|
487
|
+
fromVect: c,
|
|
488
|
+
toVect: a,
|
|
489
489
|
arrowLength: this.arrowLength,
|
|
490
490
|
arrowOffset: this.arrowOffset,
|
|
491
491
|
roundness: this.roundness,
|
|
492
492
|
hasSourceArrow: this.hasSourceArrow,
|
|
493
493
|
hasTargetArrow: this.hasTargetArrow
|
|
494
|
-
}), this.line.setAttribute("d",
|
|
495
|
-
const
|
|
496
|
-
|
|
494
|
+
}), this.line.setAttribute("d", u), this.sourceArrow) {
|
|
495
|
+
const y = T(
|
|
496
|
+
c,
|
|
497
497
|
w,
|
|
498
498
|
this.arrowLength,
|
|
499
499
|
this.arrowWidth
|
|
500
500
|
);
|
|
501
|
-
this.sourceArrow.setAttribute("d",
|
|
501
|
+
this.sourceArrow.setAttribute("d", y);
|
|
502
502
|
}
|
|
503
503
|
if (this.targetArrow) {
|
|
504
|
-
const
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
504
|
+
const y = T(
|
|
505
|
+
f,
|
|
506
|
+
l,
|
|
507
|
+
A,
|
|
508
508
|
this.arrowWidth
|
|
509
509
|
);
|
|
510
|
-
this.targetArrow.setAttribute("d",
|
|
510
|
+
this.targetArrow.setAttribute("d", y);
|
|
511
511
|
}
|
|
512
512
|
}
|
|
513
513
|
}
|
|
514
|
-
class
|
|
515
|
-
constructor(
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
this.arrowLength = (
|
|
531
|
-
const
|
|
514
|
+
class te {
|
|
515
|
+
constructor(e) {
|
|
516
|
+
i(this, "svg", B());
|
|
517
|
+
i(this, "group", k());
|
|
518
|
+
i(this, "line");
|
|
519
|
+
i(this, "sourceArrow", null);
|
|
520
|
+
i(this, "targetArrow", null);
|
|
521
|
+
i(this, "arrowLength");
|
|
522
|
+
i(this, "arrowWidth");
|
|
523
|
+
i(this, "arrowOffset");
|
|
524
|
+
i(this, "roundness");
|
|
525
|
+
i(this, "cycleSquareSide");
|
|
526
|
+
i(this, "detourDirection");
|
|
527
|
+
i(this, "detourDistance");
|
|
528
|
+
i(this, "hasSourceArrow");
|
|
529
|
+
i(this, "hasTargetArrow");
|
|
530
|
+
this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? g.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? g.arrowWidth, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? g.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? g.cycleSquareSide;
|
|
531
|
+
const r = (e == null ? void 0 : e.roundness) ?? g.roundness;
|
|
532
532
|
this.roundness = Math.min(
|
|
533
|
-
|
|
533
|
+
r,
|
|
534
534
|
this.arrowOffset,
|
|
535
535
|
this.cycleSquareSide / 2
|
|
536
|
-
), this.detourDirection = (
|
|
537
|
-
const
|
|
538
|
-
this.svg.appendChild(this.group), this.line =
|
|
539
|
-
}
|
|
540
|
-
render(
|
|
541
|
-
const { x:
|
|
542
|
-
|
|
543
|
-
|
|
536
|
+
), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? g.detourDirectionVertical, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? g.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? g.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? g.hasTargetArrow;
|
|
537
|
+
const o = (e == null ? void 0 : e.color) ?? g.color, n = (e == null ? void 0 : e.width) ?? g.width;
|
|
538
|
+
this.svg.appendChild(this.group), this.line = Y(o, n), 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));
|
|
539
|
+
}
|
|
540
|
+
render(e) {
|
|
541
|
+
const { x: r, y: o, width: n, height: d, flipX: s, flipY: h } = X(
|
|
542
|
+
e.from,
|
|
543
|
+
e.to
|
|
544
544
|
);
|
|
545
|
-
this.svg.style.transform = `translate(${
|
|
546
|
-
const
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
),
|
|
551
|
-
x:
|
|
552
|
-
y:
|
|
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
|
+
e.from.direction,
|
|
548
|
+
s,
|
|
549
|
+
h
|
|
550
|
+
), a = N(e.to.direction, s, h), l = {
|
|
551
|
+
x: n,
|
|
552
|
+
y: d
|
|
553
553
|
};
|
|
554
|
-
let
|
|
555
|
-
if (
|
|
556
|
-
fromVect:
|
|
554
|
+
let u, f = a, A = -this.arrowLength;
|
|
555
|
+
if (e.from.portId === e.to.portId ? (u = H({
|
|
556
|
+
fromVect: c,
|
|
557
557
|
arrowLength: this.arrowLength,
|
|
558
558
|
side: this.cycleSquareSide,
|
|
559
559
|
arrowOffset: this.arrowOffset,
|
|
560
560
|
roundness: this.roundness,
|
|
561
561
|
hasSourceArrow: this.hasSourceArrow,
|
|
562
562
|
hasTargetArrow: this.hasTargetArrow
|
|
563
|
-
}),
|
|
564
|
-
to:
|
|
565
|
-
fromVect:
|
|
566
|
-
toVect:
|
|
567
|
-
flipX:
|
|
568
|
-
flipY:
|
|
563
|
+
}), f = c, A = this.arrowLength) : e.from.nodeId === e.to.nodeId ? u = j({
|
|
564
|
+
to: l,
|
|
565
|
+
fromVect: c,
|
|
566
|
+
toVect: a,
|
|
567
|
+
flipX: s,
|
|
568
|
+
flipY: h,
|
|
569
569
|
arrowLength: this.arrowLength,
|
|
570
570
|
arrowOffset: this.arrowOffset,
|
|
571
571
|
roundness: this.roundness,
|
|
@@ -573,280 +573,302 @@ class ct {
|
|
|
573
573
|
detourDistance: this.detourDistance,
|
|
574
574
|
hasSourceArrow: this.hasSourceArrow,
|
|
575
575
|
hasTargetArrow: this.hasTargetArrow
|
|
576
|
-
}) :
|
|
577
|
-
to:
|
|
578
|
-
fromVect:
|
|
579
|
-
toVect:
|
|
580
|
-
flipY:
|
|
576
|
+
}) : u = we({
|
|
577
|
+
to: l,
|
|
578
|
+
fromVect: c,
|
|
579
|
+
toVect: a,
|
|
580
|
+
flipY: h,
|
|
581
581
|
arrowLength: this.arrowLength,
|
|
582
582
|
arrowOffset: this.arrowOffset,
|
|
583
583
|
roundness: this.roundness,
|
|
584
584
|
hasSourceArrow: this.hasSourceArrow,
|
|
585
585
|
hasTargetArrow: this.hasTargetArrow
|
|
586
|
-
}), this.line.setAttribute("d",
|
|
587
|
-
const
|
|
588
|
-
|
|
586
|
+
}), this.line.setAttribute("d", u), this.sourceArrow) {
|
|
587
|
+
const y = T(
|
|
588
|
+
c,
|
|
589
589
|
w,
|
|
590
590
|
this.arrowLength,
|
|
591
591
|
this.arrowWidth
|
|
592
592
|
);
|
|
593
|
-
this.sourceArrow.setAttribute("d",
|
|
593
|
+
this.sourceArrow.setAttribute("d", y);
|
|
594
594
|
}
|
|
595
595
|
if (this.targetArrow) {
|
|
596
|
-
const
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
596
|
+
const y = T(
|
|
597
|
+
f,
|
|
598
|
+
l,
|
|
599
|
+
A,
|
|
600
600
|
this.arrowWidth
|
|
601
601
|
);
|
|
602
|
-
this.targetArrow.setAttribute("d",
|
|
602
|
+
this.targetArrow.setAttribute("d", y);
|
|
603
603
|
}
|
|
604
604
|
}
|
|
605
605
|
}
|
|
606
|
-
const
|
|
607
|
-
if (typeof
|
|
608
|
-
return
|
|
609
|
-
switch (
|
|
606
|
+
const ye = (t) => {
|
|
607
|
+
if (typeof t == "function")
|
|
608
|
+
return t;
|
|
609
|
+
switch (t == null ? void 0 : t.type) {
|
|
610
610
|
case "straight":
|
|
611
|
-
return () => new
|
|
612
|
-
color:
|
|
613
|
-
width:
|
|
614
|
-
arrowLength:
|
|
615
|
-
arrowWidth:
|
|
616
|
-
arrowOffset:
|
|
617
|
-
hasSourceArrow:
|
|
618
|
-
hasTargetArrow:
|
|
619
|
-
cycleSquareSide:
|
|
620
|
-
roundness:
|
|
621
|
-
detourDistance:
|
|
622
|
-
detourDirection:
|
|
611
|
+
return () => new ee({
|
|
612
|
+
color: t.color,
|
|
613
|
+
width: t.width,
|
|
614
|
+
arrowLength: t.arrowLength,
|
|
615
|
+
arrowWidth: t.arrowWidth,
|
|
616
|
+
arrowOffset: t.arrowOffset,
|
|
617
|
+
hasSourceArrow: t.hasSourceArrow,
|
|
618
|
+
hasTargetArrow: t.hasTargetArrow,
|
|
619
|
+
cycleSquareSide: t.cycleSquareSide,
|
|
620
|
+
roundness: t.roundness,
|
|
621
|
+
detourDistance: t.detourDistance,
|
|
622
|
+
detourDirection: t.detourDirection
|
|
623
623
|
});
|
|
624
624
|
case "horizontal":
|
|
625
|
-
return () => new
|
|
626
|
-
color:
|
|
627
|
-
width:
|
|
628
|
-
arrowLength:
|
|
629
|
-
arrowWidth:
|
|
630
|
-
arrowOffset:
|
|
631
|
-
hasSourceArrow:
|
|
632
|
-
hasTargetArrow:
|
|
633
|
-
cycleSquareSide:
|
|
634
|
-
roundness:
|
|
635
|
-
detourDistance:
|
|
636
|
-
detourDirection:
|
|
625
|
+
return () => new O({
|
|
626
|
+
color: t.color,
|
|
627
|
+
width: t.width,
|
|
628
|
+
arrowLength: t.arrowLength,
|
|
629
|
+
arrowWidth: t.arrowWidth,
|
|
630
|
+
arrowOffset: t.arrowOffset,
|
|
631
|
+
hasSourceArrow: t.hasSourceArrow,
|
|
632
|
+
hasTargetArrow: t.hasTargetArrow,
|
|
633
|
+
cycleSquareSide: t.cycleSquareSide,
|
|
634
|
+
roundness: t.roundness,
|
|
635
|
+
detourDistance: t.detourDistance,
|
|
636
|
+
detourDirection: t.detourDirection
|
|
637
637
|
});
|
|
638
638
|
case "vertical":
|
|
639
|
-
return () => new
|
|
640
|
-
color:
|
|
641
|
-
width:
|
|
642
|
-
arrowLength:
|
|
643
|
-
arrowWidth:
|
|
644
|
-
arrowOffset:
|
|
645
|
-
hasSourceArrow:
|
|
646
|
-
hasTargetArrow:
|
|
647
|
-
cycleSquareSide:
|
|
648
|
-
roundness:
|
|
649
|
-
detourDistance:
|
|
650
|
-
detourDirection:
|
|
639
|
+
return () => new te({
|
|
640
|
+
color: t.color,
|
|
641
|
+
width: t.width,
|
|
642
|
+
arrowLength: t.arrowLength,
|
|
643
|
+
arrowWidth: t.arrowWidth,
|
|
644
|
+
arrowOffset: t.arrowOffset,
|
|
645
|
+
hasSourceArrow: t.hasSourceArrow,
|
|
646
|
+
hasTargetArrow: t.hasTargetArrow,
|
|
647
|
+
cycleSquareSide: t.cycleSquareSide,
|
|
648
|
+
roundness: t.roundness,
|
|
649
|
+
detourDistance: t.detourDistance,
|
|
650
|
+
detourDirection: t.detourDirection
|
|
651
651
|
});
|
|
652
652
|
default:
|
|
653
|
-
return () => new
|
|
654
|
-
color:
|
|
655
|
-
width:
|
|
656
|
-
arrowLength:
|
|
657
|
-
arrowWidth:
|
|
658
|
-
hasSourceArrow:
|
|
659
|
-
hasTargetArrow:
|
|
660
|
-
cycleRadius:
|
|
661
|
-
smallCycleRadius:
|
|
662
|
-
curvature:
|
|
663
|
-
detourDistance:
|
|
664
|
-
detourDirection:
|
|
653
|
+
return () => new q({
|
|
654
|
+
color: t.color,
|
|
655
|
+
width: t.width,
|
|
656
|
+
arrowLength: t.arrowLength,
|
|
657
|
+
arrowWidth: t.arrowWidth,
|
|
658
|
+
hasSourceArrow: t.hasSourceArrow,
|
|
659
|
+
hasTargetArrow: t.hasTargetArrow,
|
|
660
|
+
cycleRadius: t.cycleRadius,
|
|
661
|
+
smallCycleRadius: t.smallCycleRadius,
|
|
662
|
+
curvature: t.curvature,
|
|
663
|
+
detourDistance: t.detourDistance,
|
|
664
|
+
detourDirection: t.detourDirection
|
|
665
665
|
});
|
|
666
666
|
}
|
|
667
|
-
},
|
|
668
|
-
let
|
|
669
|
-
return () =>
|
|
670
|
-
},
|
|
671
|
-
let
|
|
672
|
-
|
|
673
|
-
const
|
|
674
|
-
return
|
|
675
|
-
nodesPriorityFn:
|
|
676
|
-
edgesPriorityFn:
|
|
667
|
+
}, V = (t) => () => t, I = V(0), M = () => {
|
|
668
|
+
let t = 0;
|
|
669
|
+
return () => t++;
|
|
670
|
+
}, ve = (t, e) => {
|
|
671
|
+
let r = I, o = I;
|
|
672
|
+
t === "incremental" && (r = M()), e === "incremental" && (o = M());
|
|
673
|
+
const n = M();
|
|
674
|
+
return t === "shared-incremental" && (r = n), e === "shared-incremental" && (o = n), typeof t == "number" && (r = V(t)), typeof e == "number" && (o = V(e)), typeof t == "function" && (r = t), typeof e == "function" && (o = e), {
|
|
675
|
+
nodesPriorityFn: r,
|
|
676
|
+
edgesPriorityFn: o
|
|
677
677
|
};
|
|
678
|
-
},
|
|
679
|
-
var o,
|
|
680
|
-
const
|
|
681
|
-
(
|
|
682
|
-
(
|
|
678
|
+
}, Ae = (t) => {
|
|
679
|
+
var r, o, n, d, s;
|
|
680
|
+
const e = ve(
|
|
681
|
+
(r = t == null ? void 0 : t.nodes) == null ? void 0 : r.priority,
|
|
682
|
+
(o = t == null ? void 0 : t.edges) == null ? void 0 : o.priority
|
|
683
683
|
);
|
|
684
684
|
return {
|
|
685
685
|
nodes: {
|
|
686
|
-
centerFn: ((
|
|
687
|
-
priorityFn:
|
|
686
|
+
centerFn: ((n = t == null ? void 0 : t.nodes) == null ? void 0 : n.centerFn) ?? Z,
|
|
687
|
+
priorityFn: e.nodesPriorityFn
|
|
688
688
|
},
|
|
689
689
|
ports: {
|
|
690
|
-
direction: ((
|
|
690
|
+
direction: ((d = t == null ? void 0 : t.ports) == null ? void 0 : d.direction) ?? 0
|
|
691
691
|
},
|
|
692
692
|
edges: {
|
|
693
|
-
shapeFactory:
|
|
694
|
-
priorityFn:
|
|
693
|
+
shapeFactory: ye(((s = t == null ? void 0 : t.edges) == null ? void 0 : s.shape) ?? {}),
|
|
694
|
+
priorityFn: e.edgesPriorityFn
|
|
695
695
|
}
|
|
696
696
|
};
|
|
697
697
|
};
|
|
698
|
-
class
|
|
698
|
+
class re {
|
|
699
699
|
constructor() {
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
}
|
|
709
|
-
addNode(
|
|
710
|
-
this.nodes.set(
|
|
711
|
-
element:
|
|
712
|
-
x:
|
|
713
|
-
y:
|
|
714
|
-
centerFn:
|
|
715
|
-
priority:
|
|
716
|
-
}), this.nodePorts.set(
|
|
700
|
+
i(this, "nodes", /* @__PURE__ */ new Map());
|
|
701
|
+
i(this, "ports", /* @__PURE__ */ new Map());
|
|
702
|
+
i(this, "nodePorts", /* @__PURE__ */ new Map());
|
|
703
|
+
i(this, "portNodeId", /* @__PURE__ */ new Map());
|
|
704
|
+
i(this, "edges", /* @__PURE__ */ new Map());
|
|
705
|
+
i(this, "incommingEdges", /* @__PURE__ */ new Map());
|
|
706
|
+
i(this, "outcommingEdges", /* @__PURE__ */ new Map());
|
|
707
|
+
i(this, "cycleEdges", /* @__PURE__ */ new Map());
|
|
708
|
+
}
|
|
709
|
+
addNode(e) {
|
|
710
|
+
this.nodes.set(e.nodeId, {
|
|
711
|
+
element: e.element,
|
|
712
|
+
x: e.x,
|
|
713
|
+
y: e.y,
|
|
714
|
+
centerFn: e.centerFn,
|
|
715
|
+
priority: e.priority
|
|
716
|
+
}), this.nodePorts.set(e.nodeId, /* @__PURE__ */ new Map());
|
|
717
717
|
}
|
|
718
718
|
getAllNodeIds() {
|
|
719
719
|
return Array.from(this.nodes.keys());
|
|
720
720
|
}
|
|
721
|
-
getNode(
|
|
722
|
-
return this.nodes.get(
|
|
721
|
+
getNode(e) {
|
|
722
|
+
return this.nodes.get(e);
|
|
723
723
|
}
|
|
724
|
-
removeNode(
|
|
725
|
-
this.nodes.delete(
|
|
724
|
+
removeNode(e) {
|
|
725
|
+
this.nodes.delete(e), this.nodePorts.delete(e);
|
|
726
726
|
}
|
|
727
|
-
addPort(
|
|
728
|
-
this.ports.set(
|
|
729
|
-
element:
|
|
730
|
-
direction:
|
|
731
|
-
}), this.cycleEdges.set(
|
|
727
|
+
addPort(e) {
|
|
728
|
+
this.ports.set(e.portId, {
|
|
729
|
+
element: e.element,
|
|
730
|
+
direction: e.direction
|
|
731
|
+
}), this.cycleEdges.set(e.portId, /* @__PURE__ */ new Set()), this.incommingEdges.set(e.portId, /* @__PURE__ */ new Set()), this.outcommingEdges.set(e.portId, /* @__PURE__ */ new Set()), this.portNodeId.set(e.portId, e.nodeId), this.nodePorts.get(e.nodeId).set(e.portId, e.element);
|
|
732
732
|
}
|
|
733
|
-
getPort(
|
|
734
|
-
return this.ports.get(
|
|
733
|
+
getPort(e) {
|
|
734
|
+
return this.ports.get(e);
|
|
735
735
|
}
|
|
736
736
|
getAllPortIds() {
|
|
737
737
|
return Array.from(this.ports.keys());
|
|
738
738
|
}
|
|
739
|
-
getNodePortIds(
|
|
740
|
-
const
|
|
741
|
-
if (
|
|
742
|
-
return Array.from(
|
|
743
|
-
}
|
|
744
|
-
getPortNodeId(
|
|
745
|
-
return this.portNodeId.get(
|
|
746
|
-
}
|
|
747
|
-
removePort(
|
|
748
|
-
const
|
|
749
|
-
this.portNodeId.delete(
|
|
750
|
-
}
|
|
751
|
-
addEdge(
|
|
752
|
-
this.edges.set(
|
|
753
|
-
from:
|
|
754
|
-
to:
|
|
755
|
-
shape:
|
|
756
|
-
priority:
|
|
757
|
-
}),
|
|
758
|
-
}
|
|
759
|
-
updateEdgeFrom(
|
|
760
|
-
const
|
|
761
|
-
this.removeEdge(
|
|
762
|
-
edgeId:
|
|
763
|
-
from:
|
|
764
|
-
to:
|
|
765
|
-
shape:
|
|
766
|
-
priority:
|
|
739
|
+
getNodePortIds(e) {
|
|
740
|
+
const r = this.nodePorts.get(e);
|
|
741
|
+
if (r !== void 0)
|
|
742
|
+
return Array.from(r.keys());
|
|
743
|
+
}
|
|
744
|
+
getPortNodeId(e) {
|
|
745
|
+
return this.portNodeId.get(e);
|
|
746
|
+
}
|
|
747
|
+
removePort(e) {
|
|
748
|
+
const r = this.portNodeId.get(e);
|
|
749
|
+
this.portNodeId.delete(e), this.nodePorts.get(r).delete(e), this.ports.delete(e);
|
|
750
|
+
}
|
|
751
|
+
addEdge(e) {
|
|
752
|
+
this.edges.set(e.edgeId, {
|
|
753
|
+
from: e.from,
|
|
754
|
+
to: e.to,
|
|
755
|
+
shape: e.shape,
|
|
756
|
+
priority: e.priority
|
|
757
|
+
}), e.from !== e.to ? (this.outcommingEdges.get(e.from).add(e.edgeId), this.incommingEdges.get(e.to).add(e.edgeId)) : this.cycleEdges.get(e.from).add(e.edgeId);
|
|
758
|
+
}
|
|
759
|
+
updateEdgeFrom(e, r) {
|
|
760
|
+
const o = this.edges.get(e);
|
|
761
|
+
this.removeEdge(e), this.addEdge({
|
|
762
|
+
edgeId: e,
|
|
763
|
+
from: r,
|
|
764
|
+
to: o.to,
|
|
765
|
+
shape: o.shape,
|
|
766
|
+
priority: o.priority
|
|
767
767
|
});
|
|
768
768
|
}
|
|
769
|
-
updateEdgeTo(
|
|
770
|
-
const
|
|
771
|
-
this.removeEdge(
|
|
772
|
-
edgeId:
|
|
773
|
-
from:
|
|
774
|
-
to:
|
|
775
|
-
shape:
|
|
776
|
-
priority:
|
|
769
|
+
updateEdgeTo(e, r) {
|
|
770
|
+
const o = this.edges.get(e);
|
|
771
|
+
this.removeEdge(e), this.addEdge({
|
|
772
|
+
edgeId: e,
|
|
773
|
+
from: o.from,
|
|
774
|
+
to: r,
|
|
775
|
+
shape: o.shape,
|
|
776
|
+
priority: o.priority
|
|
777
777
|
});
|
|
778
778
|
}
|
|
779
779
|
getAllEdgeIds() {
|
|
780
780
|
return Array.from(this.edges.keys());
|
|
781
781
|
}
|
|
782
|
-
getEdge(
|
|
783
|
-
return this.edges.get(
|
|
782
|
+
getEdge(e) {
|
|
783
|
+
return this.edges.get(e);
|
|
784
784
|
}
|
|
785
|
-
removeEdge(
|
|
786
|
-
const
|
|
787
|
-
this.cycleEdges.get(
|
|
785
|
+
removeEdge(e) {
|
|
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
|
-
this.
|
|
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();
|
|
791
791
|
}
|
|
792
|
-
getPortIncomingEdgeIds(
|
|
793
|
-
return Array.from(this.incommingEdges.get(
|
|
792
|
+
getPortIncomingEdgeIds(e) {
|
|
793
|
+
return Array.from(this.incommingEdges.get(e));
|
|
794
794
|
}
|
|
795
|
-
getPortOutcomingEdgeIds(
|
|
796
|
-
return Array.from(this.outcommingEdges.get(
|
|
795
|
+
getPortOutcomingEdgeIds(e) {
|
|
796
|
+
return Array.from(this.outcommingEdges.get(e));
|
|
797
797
|
}
|
|
798
|
-
getPortCycleEdgeIds(
|
|
799
|
-
return Array.from(this.cycleEdges.get(
|
|
798
|
+
getPortCycleEdgeIds(e) {
|
|
799
|
+
return Array.from(this.cycleEdges.get(e));
|
|
800
800
|
}
|
|
801
|
-
getPortAdjacentEdgeIds(
|
|
801
|
+
getPortAdjacentEdgeIds(e) {
|
|
802
802
|
return [
|
|
803
|
-
...this.getPortIncomingEdgeIds(
|
|
804
|
-
...this.getPortOutcomingEdgeIds(
|
|
805
|
-
...this.getPortCycleEdgeIds(
|
|
803
|
+
...this.getPortIncomingEdgeIds(e),
|
|
804
|
+
...this.getPortOutcomingEdgeIds(e),
|
|
805
|
+
...this.getPortCycleEdgeIds(e)
|
|
806
806
|
];
|
|
807
807
|
}
|
|
808
|
-
getNodeIncomingEdgeIds(
|
|
809
|
-
const
|
|
810
|
-
let
|
|
811
|
-
return
|
|
812
|
-
|
|
813
|
-
}),
|
|
814
|
-
}
|
|
815
|
-
getNodeOutcomingEdgeIds(
|
|
816
|
-
const
|
|
817
|
-
let
|
|
818
|
-
return
|
|
819
|
-
|
|
820
|
-
}),
|
|
821
|
-
}
|
|
822
|
-
getNodeCycleEdgeIds(
|
|
823
|
-
const
|
|
824
|
-
let
|
|
825
|
-
return
|
|
826
|
-
|
|
827
|
-
}),
|
|
828
|
-
}
|
|
829
|
-
getNodeAdjacentEdgeIds(
|
|
808
|
+
getNodeIncomingEdgeIds(e) {
|
|
809
|
+
const r = Array.from(this.nodePorts.get(e).keys());
|
|
810
|
+
let o = [];
|
|
811
|
+
return r.forEach((n) => {
|
|
812
|
+
o = [...o, ...this.getPortIncomingEdgeIds(n)];
|
|
813
|
+
}), o;
|
|
814
|
+
}
|
|
815
|
+
getNodeOutcomingEdgeIds(e) {
|
|
816
|
+
const r = Array.from(this.nodePorts.get(e).keys());
|
|
817
|
+
let o = [];
|
|
818
|
+
return r.forEach((n) => {
|
|
819
|
+
o = [...o, ...this.getPortOutcomingEdgeIds(n)];
|
|
820
|
+
}), o;
|
|
821
|
+
}
|
|
822
|
+
getNodeCycleEdgeIds(e) {
|
|
823
|
+
const r = Array.from(this.nodePorts.get(e).keys());
|
|
824
|
+
let o = [];
|
|
825
|
+
return r.forEach((n) => {
|
|
826
|
+
o = [...o, ...this.getPortCycleEdgeIds(n)];
|
|
827
|
+
}), o;
|
|
828
|
+
}
|
|
829
|
+
getNodeAdjacentEdgeIds(e) {
|
|
830
830
|
return [
|
|
831
|
-
...this.getNodeIncomingEdgeIds(
|
|
832
|
-
...this.getNodeOutcomingEdgeIds(
|
|
833
|
-
...this.getNodeCycleEdgeIds(
|
|
831
|
+
...this.getNodeIncomingEdgeIds(e),
|
|
832
|
+
...this.getNodeOutcomingEdgeIds(e),
|
|
833
|
+
...this.getNodeCycleEdgeIds(e)
|
|
834
834
|
];
|
|
835
835
|
}
|
|
836
836
|
}
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
837
|
+
class xe {
|
|
838
|
+
constructor() {
|
|
839
|
+
i(this, "callbacks", /* @__PURE__ */ new Set());
|
|
840
|
+
}
|
|
841
|
+
subscribe(e) {
|
|
842
|
+
this.callbacks.add(e);
|
|
843
|
+
}
|
|
844
|
+
unsubscribe(e) {
|
|
845
|
+
this.callbacks.delete(e);
|
|
846
|
+
}
|
|
847
|
+
emit(e) {
|
|
848
|
+
this.callbacks.forEach((r) => {
|
|
849
|
+
r(e);
|
|
850
|
+
});
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
const S = () => {
|
|
854
|
+
const t = new xe();
|
|
855
|
+
return [t, t];
|
|
856
|
+
}, _ = (t) => ({
|
|
857
|
+
scale: 1 / t.scale,
|
|
858
|
+
x: -t.x / t.scale,
|
|
859
|
+
y: -t.y / t.scale
|
|
860
|
+
}), J = {
|
|
842
861
|
scale: 1,
|
|
843
862
|
x: 0,
|
|
844
863
|
y: 0
|
|
845
864
|
};
|
|
846
|
-
class
|
|
865
|
+
class oe {
|
|
847
866
|
constructor() {
|
|
848
|
-
|
|
849
|
-
|
|
867
|
+
i(this, "viewportMatrix", J);
|
|
868
|
+
i(this, "contentMatrix", J);
|
|
869
|
+
i(this, "emitter");
|
|
870
|
+
i(this, "onAfterUpdate");
|
|
871
|
+
[this.emitter, this.onAfterUpdate] = S();
|
|
850
872
|
}
|
|
851
873
|
getViewportMatrix() {
|
|
852
874
|
return this.viewportMatrix;
|
|
@@ -854,24 +876,24 @@ class ut {
|
|
|
854
876
|
getContentMatrix() {
|
|
855
877
|
return this.contentMatrix;
|
|
856
878
|
}
|
|
857
|
-
patchViewportMatrix(
|
|
879
|
+
patchViewportMatrix(e) {
|
|
858
880
|
this.viewportMatrix = {
|
|
859
|
-
scale:
|
|
860
|
-
x:
|
|
861
|
-
y:
|
|
862
|
-
}, this.contentMatrix =
|
|
881
|
+
scale: e.scale ?? this.viewportMatrix.scale,
|
|
882
|
+
x: e.x ?? this.viewportMatrix.x,
|
|
883
|
+
y: e.y ?? this.viewportMatrix.y
|
|
884
|
+
}, this.contentMatrix = _(this.viewportMatrix), this.emitter.emit();
|
|
863
885
|
}
|
|
864
|
-
patchContentMatrix(
|
|
886
|
+
patchContentMatrix(e) {
|
|
865
887
|
this.contentMatrix = {
|
|
866
|
-
scale:
|
|
867
|
-
x:
|
|
868
|
-
y:
|
|
869
|
-
}, this.viewportMatrix =
|
|
888
|
+
scale: e.scale ?? this.contentMatrix.scale,
|
|
889
|
+
x: e.x ?? this.contentMatrix.x,
|
|
890
|
+
y: e.y ?? this.contentMatrix.y
|
|
891
|
+
}, this.viewportMatrix = _(this.contentMatrix), this.emitter.emit();
|
|
870
892
|
}
|
|
871
893
|
}
|
|
872
|
-
class
|
|
873
|
-
constructor(
|
|
874
|
-
this.transformer =
|
|
894
|
+
class ie {
|
|
895
|
+
constructor(e) {
|
|
896
|
+
this.transformer = e;
|
|
875
897
|
}
|
|
876
898
|
getViewportMatrix() {
|
|
877
899
|
return { ...this.transformer.getViewportMatrix() };
|
|
@@ -880,117 +902,117 @@ class wt {
|
|
|
880
902
|
return { ...this.transformer.getContentMatrix() };
|
|
881
903
|
}
|
|
882
904
|
}
|
|
883
|
-
const
|
|
884
|
-
const
|
|
885
|
-
return
|
|
886
|
-
},
|
|
887
|
-
const
|
|
888
|
-
return
|
|
889
|
-
},
|
|
890
|
-
const
|
|
891
|
-
return
|
|
905
|
+
const Ee = () => {
|
|
906
|
+
const t = document.createElement("div");
|
|
907
|
+
return t.style.width = "100%", t.style.height = "100%", t.style.position = "relative", t.style.overflow = "hidden", t;
|
|
908
|
+
}, Se = () => {
|
|
909
|
+
const t = document.createElement("div");
|
|
910
|
+
return t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.width = "0", t.style.height = "0", t;
|
|
911
|
+
}, me = () => {
|
|
912
|
+
const t = document.createElement("div");
|
|
913
|
+
return t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.visibility = "hidden", t;
|
|
892
914
|
};
|
|
893
|
-
class
|
|
894
|
-
constructor(
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
this.graphStore =
|
|
901
|
-
}
|
|
902
|
-
attach(
|
|
903
|
-
this.detach(), this.canvasWrapper =
|
|
915
|
+
class ne {
|
|
916
|
+
constructor(e, r) {
|
|
917
|
+
i(this, "canvasWrapper", null);
|
|
918
|
+
i(this, "host", Ee());
|
|
919
|
+
i(this, "container", Se());
|
|
920
|
+
i(this, "nodeIdToWrapperElementMap", /* @__PURE__ */ new Map());
|
|
921
|
+
i(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
|
|
922
|
+
this.graphStore = e, this.viewportTransformer = r, this.host.appendChild(this.container);
|
|
923
|
+
}
|
|
924
|
+
attach(e) {
|
|
925
|
+
this.detach(), this.canvasWrapper = e, this.canvasWrapper.appendChild(this.host);
|
|
904
926
|
}
|
|
905
927
|
detach() {
|
|
906
928
|
this.canvasWrapper !== null && (this.canvasWrapper.removeChild(this.host), this.canvasWrapper = null);
|
|
907
929
|
}
|
|
908
930
|
applyTransform() {
|
|
909
|
-
const
|
|
910
|
-
this.container.style.transform = `matrix(${
|
|
931
|
+
const e = this.viewportTransformer.getContentMatrix();
|
|
932
|
+
this.container.style.transform = `matrix(${e.scale}, 0, 0, ${e.scale}, ${e.x}, ${e.y})`;
|
|
911
933
|
}
|
|
912
|
-
attachNode(
|
|
913
|
-
const
|
|
914
|
-
|
|
934
|
+
attachNode(e) {
|
|
935
|
+
const r = this.graphStore.getNode(e), o = me();
|
|
936
|
+
o.appendChild(r.element), this.container.appendChild(o), this.nodeIdToWrapperElementMap.set(e, o), this.updateNodeCoordinates(e), this.updateNodePriority(e), o.style.visibility = "visible";
|
|
915
937
|
}
|
|
916
|
-
detachNode(
|
|
917
|
-
const
|
|
918
|
-
|
|
938
|
+
detachNode(e) {
|
|
939
|
+
const r = this.graphStore.getNode(e), o = this.nodeIdToWrapperElementMap.get(e);
|
|
940
|
+
o.removeChild(r.element), this.container.removeChild(o), this.nodeIdToWrapperElementMap.delete(e);
|
|
919
941
|
}
|
|
920
|
-
attachEdge(
|
|
921
|
-
const
|
|
922
|
-
this.edgeIdToElementMap.set(
|
|
942
|
+
attachEdge(e) {
|
|
943
|
+
const r = this.graphStore.getEdge(e);
|
|
944
|
+
this.edgeIdToElementMap.set(e, r.shape.svg), this.container.appendChild(r.shape.svg), this.renderEdge(e), this.updateEdgePriority(e);
|
|
923
945
|
}
|
|
924
|
-
detachEdge(
|
|
925
|
-
const
|
|
926
|
-
this.container.removeChild(
|
|
946
|
+
detachEdge(e) {
|
|
947
|
+
const r = this.graphStore.getEdge(e);
|
|
948
|
+
this.container.removeChild(r.shape.svg), this.edgeIdToElementMap.delete(e);
|
|
927
949
|
}
|
|
928
950
|
clear() {
|
|
929
|
-
this.edgeIdToElementMap.forEach((
|
|
930
|
-
this.detachEdge(
|
|
931
|
-
}), this.nodeIdToWrapperElementMap.forEach((
|
|
932
|
-
this.detachNode(
|
|
951
|
+
this.edgeIdToElementMap.forEach((e, r) => {
|
|
952
|
+
this.detachEdge(r);
|
|
953
|
+
}), this.nodeIdToWrapperElementMap.forEach((e, r) => {
|
|
954
|
+
this.detachNode(r);
|
|
933
955
|
});
|
|
934
956
|
}
|
|
935
957
|
destroy() {
|
|
936
958
|
this.clear(), this.detach(), this.host.removeChild(this.container);
|
|
937
959
|
}
|
|
938
|
-
updateNodeCoordinates(
|
|
939
|
-
const
|
|
940
|
-
|
|
941
|
-
}
|
|
942
|
-
updateNodePriority(
|
|
943
|
-
const
|
|
944
|
-
|
|
945
|
-
}
|
|
946
|
-
updateEdgeShape(
|
|
947
|
-
const
|
|
948
|
-
this.container.removeChild(
|
|
949
|
-
const
|
|
950
|
-
this.edgeIdToElementMap.set(
|
|
951
|
-
}
|
|
952
|
-
renderEdge(
|
|
953
|
-
const
|
|
954
|
-
x:
|
|
955
|
-
y:
|
|
956
|
-
},
|
|
957
|
-
x:
|
|
958
|
-
y:
|
|
959
|
-
},
|
|
960
|
-
x: l.x,
|
|
961
|
-
y: l.y,
|
|
962
|
-
width: s.width * d.scale,
|
|
963
|
-
height: s.height * d.scale,
|
|
964
|
-
direction: r.direction,
|
|
965
|
-
portId: o.from,
|
|
966
|
-
nodeId: this.graphStore.getPortNodeId(o.from)
|
|
967
|
-
}, y = {
|
|
960
|
+
updateNodeCoordinates(e) {
|
|
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
|
+
r.style.transform = `translate(${c}px, ${a}px)`;
|
|
963
|
+
}
|
|
964
|
+
updateNodePriority(e) {
|
|
965
|
+
const r = this.graphStore.getNode(e), o = this.nodeIdToWrapperElementMap.get(e);
|
|
966
|
+
o.style.zIndex = `${r.priority}`;
|
|
967
|
+
}
|
|
968
|
+
updateEdgeShape(e) {
|
|
969
|
+
const r = this.edgeIdToElementMap.get(e);
|
|
970
|
+
this.container.removeChild(r);
|
|
971
|
+
const o = this.graphStore.getEdge(e);
|
|
972
|
+
this.edgeIdToElementMap.set(e, o.shape.svg), this.container.appendChild(o.shape.svg);
|
|
973
|
+
}
|
|
974
|
+
renderEdge(e) {
|
|
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
|
+
x: c.scale * (d.left - h.left) + c.x,
|
|
977
|
+
y: c.scale * (d.top - h.top) + c.y
|
|
978
|
+
}, l = {
|
|
979
|
+
x: c.scale * (s.left - h.left) + c.x,
|
|
980
|
+
y: c.scale * (s.top - h.top) + c.y
|
|
981
|
+
}, u = {
|
|
968
982
|
x: a.x,
|
|
969
983
|
y: a.y,
|
|
970
|
-
width:
|
|
971
|
-
height:
|
|
972
|
-
direction:
|
|
973
|
-
portId:
|
|
974
|
-
nodeId: this.graphStore.getPortNodeId(
|
|
984
|
+
width: d.width * c.scale,
|
|
985
|
+
height: d.height * c.scale,
|
|
986
|
+
direction: o.direction,
|
|
987
|
+
portId: r.from,
|
|
988
|
+
nodeId: this.graphStore.getPortNodeId(r.from)
|
|
989
|
+
}, f = {
|
|
990
|
+
x: l.x,
|
|
991
|
+
y: l.y,
|
|
992
|
+
width: s.width * c.scale,
|
|
993
|
+
height: s.height * c.scale,
|
|
994
|
+
direction: n.direction,
|
|
995
|
+
portId: r.to,
|
|
996
|
+
nodeId: this.graphStore.getPortNodeId(r.to)
|
|
975
997
|
};
|
|
976
|
-
|
|
977
|
-
from:
|
|
978
|
-
to:
|
|
998
|
+
r.shape.render({
|
|
999
|
+
from: u,
|
|
1000
|
+
to: f
|
|
979
1001
|
});
|
|
980
1002
|
}
|
|
981
|
-
updateEdgePriority(
|
|
982
|
-
const
|
|
983
|
-
|
|
1003
|
+
updateEdgePriority(e) {
|
|
1004
|
+
const r = this.graphStore.getEdge(e);
|
|
1005
|
+
r.shape.svg.style.zIndex = `${r.priority}`;
|
|
984
1006
|
}
|
|
985
1007
|
}
|
|
986
|
-
class
|
|
987
|
-
constructor(
|
|
988
|
-
|
|
989
|
-
this.checkExists =
|
|
990
|
-
}
|
|
991
|
-
create(
|
|
992
|
-
if (
|
|
993
|
-
return
|
|
1008
|
+
class U {
|
|
1009
|
+
constructor(e) {
|
|
1010
|
+
i(this, "counter", 0);
|
|
1011
|
+
this.checkExists = e;
|
|
1012
|
+
}
|
|
1013
|
+
create(e) {
|
|
1014
|
+
if (e !== void 0)
|
|
1015
|
+
return e;
|
|
994
1016
|
for (; this.checkExists(this.counter); )
|
|
995
1017
|
this.counter++;
|
|
996
1018
|
return this.counter;
|
|
@@ -999,706 +1021,991 @@ class I {
|
|
|
999
1021
|
this.counter = 0;
|
|
1000
1022
|
}
|
|
1001
1023
|
}
|
|
1002
|
-
class
|
|
1024
|
+
class x extends Error {
|
|
1003
1025
|
constructor() {
|
|
1004
1026
|
super(...arguments);
|
|
1005
|
-
|
|
1027
|
+
i(this, "name", "HtmlGraphError");
|
|
1006
1028
|
}
|
|
1007
1029
|
}
|
|
1008
|
-
class
|
|
1009
|
-
constructor(
|
|
1010
|
-
|
|
1011
|
-
(
|
|
1030
|
+
class se {
|
|
1031
|
+
constructor(e, r) {
|
|
1032
|
+
i(this, "nodeIdGenerator", new U(
|
|
1033
|
+
(e) => this.graphStore.getNode(e) !== void 0
|
|
1012
1034
|
));
|
|
1013
|
-
|
|
1014
|
-
(
|
|
1035
|
+
i(this, "portIdGenerator", new U(
|
|
1036
|
+
(e) => this.graphStore.getPort(e) !== void 0
|
|
1015
1037
|
));
|
|
1016
|
-
|
|
1017
|
-
(
|
|
1038
|
+
i(this, "edgeIdGenerator", new U(
|
|
1039
|
+
(e) => this.graphStore.getEdge(e) !== void 0
|
|
1018
1040
|
));
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
this
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
this
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1041
|
+
i(this, "onAfterNodeAdded");
|
|
1042
|
+
i(this, "onAfterNodeAddedEmitter");
|
|
1043
|
+
i(this, "onAfterEdgeAdded");
|
|
1044
|
+
i(this, "onAfterEdgeAddedEmitter");
|
|
1045
|
+
i(this, "onAfterEdgeShapeUpdated");
|
|
1046
|
+
i(this, "onAfterEdgeShapeUpdatedEmitter");
|
|
1047
|
+
i(this, "onAfterEdgePriorityUpdated");
|
|
1048
|
+
i(this, "onAfterEdgePriorityUpdatedEmitter");
|
|
1049
|
+
i(this, "onAfterEdgeUpdated");
|
|
1050
|
+
i(this, "onAfterEdgeUpdatedEmitter");
|
|
1051
|
+
i(this, "onAfterPortUpdated");
|
|
1052
|
+
i(this, "onAfterPortUpdatedEmitter");
|
|
1053
|
+
i(this, "onAfterNodePriorityUpdated");
|
|
1054
|
+
i(this, "onAfterNodePriorityUpdatedEmitter");
|
|
1055
|
+
i(this, "onAfterNodeUpdated");
|
|
1056
|
+
i(this, "onAfterNodeUpdatedEmitter");
|
|
1057
|
+
i(this, "onBeforeEdgeRemoved");
|
|
1058
|
+
i(this, "onBeforeEdgeRemovedEmitter");
|
|
1059
|
+
i(this, "onBeforeNodeRemoved");
|
|
1060
|
+
i(this, "onBeforeNodeRemovedEmitter");
|
|
1061
|
+
this.graphStore = e, this.options = r, [this.onAfterNodeAddedEmitter, this.onAfterNodeAdded] = S(), [this.onAfterEdgeAddedEmitter, this.onAfterEdgeAdded] = S(), [this.onAfterEdgeShapeUpdatedEmitter, this.onAfterEdgeShapeUpdated] = S(), [this.onAfterEdgePriorityUpdatedEmitter, this.onAfterEdgePriorityUpdated] = S(), [this.onAfterEdgeUpdatedEmitter, this.onAfterEdgeUpdated] = S(), [this.onAfterPortUpdatedEmitter, this.onAfterPortUpdated] = S(), [this.onAfterNodePriorityUpdatedEmitter, this.onAfterNodePriorityUpdated] = S(), [this.onAfterNodeUpdatedEmitter, this.onAfterNodeUpdated] = S(), [this.onBeforeEdgeRemovedEmitter, this.onBeforeEdgeRemoved] = S(), [this.onBeforeNodeRemovedEmitter, this.onBeforeNodeRemoved] = S();
|
|
1062
|
+
}
|
|
1063
|
+
addNode(e) {
|
|
1064
|
+
const r = this.nodeIdGenerator.create(e.id);
|
|
1065
|
+
if (this.graphStore.getNode(r) !== void 0)
|
|
1066
|
+
throw new x("failed to add node with existing id");
|
|
1031
1067
|
this.graphStore.addNode({
|
|
1032
|
-
nodeId:
|
|
1033
|
-
element:
|
|
1034
|
-
x:
|
|
1035
|
-
y:
|
|
1036
|
-
centerFn:
|
|
1037
|
-
priority:
|
|
1038
|
-
}), this.
|
|
1068
|
+
nodeId: r,
|
|
1069
|
+
element: e.element,
|
|
1070
|
+
x: e.x,
|
|
1071
|
+
y: e.y,
|
|
1072
|
+
centerFn: e.centerFn ?? this.options.nodes.centerFn,
|
|
1073
|
+
priority: e.priority ?? this.options.nodes.priorityFn()
|
|
1074
|
+
}), this.onAfterNodeAddedEmitter.emit(r), Array.from(e.ports ?? []).forEach((o) => {
|
|
1039
1075
|
this.markPort({
|
|
1040
|
-
|
|
1041
|
-
element:
|
|
1042
|
-
nodeId:
|
|
1043
|
-
direction:
|
|
1076
|
+
id: o.id,
|
|
1077
|
+
element: o.element,
|
|
1078
|
+
nodeId: r,
|
|
1079
|
+
direction: o.direction
|
|
1044
1080
|
});
|
|
1045
1081
|
});
|
|
1046
1082
|
}
|
|
1047
|
-
markPort(
|
|
1048
|
-
const
|
|
1049
|
-
if (this.graphStore.getPort(
|
|
1050
|
-
throw new
|
|
1051
|
-
if (this.graphStore.getNode(
|
|
1052
|
-
throw new
|
|
1083
|
+
markPort(e) {
|
|
1084
|
+
const r = this.portIdGenerator.create(e.id);
|
|
1085
|
+
if (this.graphStore.getPort(r) !== void 0)
|
|
1086
|
+
throw new x("failed to add port with existing id");
|
|
1087
|
+
if (this.graphStore.getNode(e.nodeId) === void 0)
|
|
1088
|
+
throw new x("failed to set port on nonexisting node");
|
|
1053
1089
|
this.graphStore.addPort({
|
|
1054
|
-
portId:
|
|
1055
|
-
element:
|
|
1056
|
-
nodeId:
|
|
1057
|
-
direction:
|
|
1090
|
+
portId: r,
|
|
1091
|
+
element: e.element,
|
|
1092
|
+
nodeId: e.nodeId,
|
|
1093
|
+
direction: e.direction ?? this.options.ports.direction
|
|
1058
1094
|
});
|
|
1059
1095
|
}
|
|
1060
|
-
addEdge(
|
|
1061
|
-
const
|
|
1062
|
-
if (this.graphStore.getEdge(
|
|
1063
|
-
throw new
|
|
1064
|
-
if (this.graphStore.getPort(
|
|
1065
|
-
throw new
|
|
1066
|
-
if (this.graphStore.getPort(
|
|
1067
|
-
throw new
|
|
1096
|
+
addEdge(e) {
|
|
1097
|
+
const r = this.edgeIdGenerator.create(e.id);
|
|
1098
|
+
if (this.graphStore.getEdge(r) !== void 0)
|
|
1099
|
+
throw new x("failed to add edge with existing id");
|
|
1100
|
+
if (this.graphStore.getPort(e.from) === void 0)
|
|
1101
|
+
throw new x("failed to add edge from nonexisting port");
|
|
1102
|
+
if (this.graphStore.getPort(e.to) === void 0)
|
|
1103
|
+
throw new x("failed to add edge to nonexisting port");
|
|
1068
1104
|
this.graphStore.addEdge({
|
|
1069
|
-
edgeId:
|
|
1070
|
-
from:
|
|
1071
|
-
to:
|
|
1072
|
-
shape:
|
|
1073
|
-
priority:
|
|
1074
|
-
}), this.
|
|
1075
|
-
}
|
|
1076
|
-
updateEdge(
|
|
1077
|
-
const o = this.graphStore.getEdge(
|
|
1105
|
+
edgeId: r,
|
|
1106
|
+
from: e.from,
|
|
1107
|
+
to: e.to,
|
|
1108
|
+
shape: e.shape ?? this.options.edges.shapeFactory(),
|
|
1109
|
+
priority: e.priority ?? this.options.edges.priorityFn()
|
|
1110
|
+
}), this.onAfterEdgeAddedEmitter.emit(r);
|
|
1111
|
+
}
|
|
1112
|
+
updateEdge(e, r) {
|
|
1113
|
+
const o = this.graphStore.getEdge(e);
|
|
1078
1114
|
if (o === void 0)
|
|
1079
|
-
throw new
|
|
1080
|
-
|
|
1081
|
-
}
|
|
1082
|
-
updatePort(t, o) {
|
|
1083
|
-
const r = this.graphStore.getPort(t);
|
|
1084
|
-
if (r === void 0)
|
|
1085
|
-
throw new S("failed to unset nonexisting port");
|
|
1086
|
-
r.direction = o.direction ?? r.direction, this.graphStore.getPortAdjacentEdgeIds(t).forEach((s) => {
|
|
1087
|
-
this.htmlController.renderEdge(s);
|
|
1088
|
-
});
|
|
1089
|
-
}
|
|
1090
|
-
updateNode(t, o) {
|
|
1091
|
-
const r = this.graphStore.getNode(t);
|
|
1092
|
-
if (r === void 0)
|
|
1093
|
-
throw new S("failed to update nonexisting node");
|
|
1094
|
-
r.x = (o == null ? void 0 : o.x) ?? r.x, r.y = (o == null ? void 0 : o.y) ?? r.y, r.centerFn = (o == null ? void 0 : o.centerFn) ?? r.centerFn, r.priority = (o == null ? void 0 : o.priority) ?? r.priority, this.htmlController.updateNodeCoordinates(t), this.htmlController.updateNodePriority(t), this.graphStore.getNodeAdjacentEdgeIds(t).forEach((s) => {
|
|
1095
|
-
this.htmlController.renderEdge(s);
|
|
1096
|
-
});
|
|
1097
|
-
}
|
|
1098
|
-
removeEdge(t) {
|
|
1099
|
-
if (this.graphStore.getEdge(t) === void 0)
|
|
1100
|
-
throw new S("failed to remove nonexisting edge");
|
|
1101
|
-
this.htmlController.detachEdge(t), this.graphStore.removeEdge(t);
|
|
1115
|
+
throw new x("failed to update nonexisting edge");
|
|
1116
|
+
r.shape !== void 0 && (o.shape = r.shape, this.onAfterEdgeShapeUpdatedEmitter.emit(e)), r.from !== void 0 && this.graphStore.updateEdgeFrom(e, r.from), r.to !== void 0 && this.graphStore.updateEdgeTo(e, r.to), this.onAfterEdgeUpdatedEmitter.emit(e), r.priority !== void 0 && (o.priority = r.priority, this.onAfterEdgePriorityUpdatedEmitter.emit(e));
|
|
1102
1117
|
}
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
}), this.graphStore.removePort(t);
|
|
1109
|
-
}
|
|
1110
|
-
removeNode(t) {
|
|
1111
|
-
if (this.graphStore.getNode(t) === void 0)
|
|
1112
|
-
throw new S("failed to remove nonexisting node");
|
|
1113
|
-
this.graphStore.getNodePortIds(t).forEach((o) => {
|
|
1114
|
-
this.unmarkPort(o);
|
|
1115
|
-
}), this.htmlController.detachNode(t), this.graphStore.removeNode(t);
|
|
1116
|
-
}
|
|
1117
|
-
patchViewportMatrix(t) {
|
|
1118
|
-
this.viewportTransformer.patchViewportMatrix(t), this.htmlController.applyTransform();
|
|
1118
|
+
updatePort(e, r) {
|
|
1119
|
+
const o = this.graphStore.getPort(e);
|
|
1120
|
+
if (o === void 0)
|
|
1121
|
+
throw new x("failed to unset nonexisting port");
|
|
1122
|
+
o.direction = r.direction ?? o.direction, this.onAfterPortUpdatedEmitter.emit(e);
|
|
1119
1123
|
}
|
|
1120
|
-
|
|
1121
|
-
|
|
1124
|
+
updateNode(e, r) {
|
|
1125
|
+
const o = this.graphStore.getNode(e);
|
|
1126
|
+
if (o === void 0)
|
|
1127
|
+
throw new x("failed to update nonexisting node");
|
|
1128
|
+
o.x = (r == null ? void 0 : r.x) ?? o.x, o.y = (r == null ? void 0 : r.y) ?? o.y, o.centerFn = r.centerFn ?? o.centerFn, this.onAfterNodeUpdatedEmitter.emit(e), r.priority !== void 0 && (o.priority = r.priority, this.onAfterNodePriorityUpdatedEmitter.emit(e));
|
|
1129
|
+
}
|
|
1130
|
+
removeEdge(e) {
|
|
1131
|
+
if (this.graphStore.getEdge(e) === void 0)
|
|
1132
|
+
throw new x("failed to remove nonexisting edge");
|
|
1133
|
+
this.onBeforeEdgeRemovedEmitter.emit(e), this.graphStore.removeEdge(e);
|
|
1134
|
+
}
|
|
1135
|
+
unmarkPort(e) {
|
|
1136
|
+
if (this.graphStore.getPort(e) === void 0)
|
|
1137
|
+
throw new x("failed to unset nonexisting port");
|
|
1138
|
+
this.graphStore.getPortAdjacentEdgeIds(e).forEach((r) => {
|
|
1139
|
+
this.removeEdge(r);
|
|
1140
|
+
}), this.graphStore.removePort(e);
|
|
1141
|
+
}
|
|
1142
|
+
removeNode(e) {
|
|
1143
|
+
if (this.graphStore.getNode(e) === void 0)
|
|
1144
|
+
throw new x("failed to remove nonexisting node");
|
|
1145
|
+
this.graphStore.getNodePortIds(e).forEach((r) => {
|
|
1146
|
+
this.unmarkPort(r);
|
|
1147
|
+
}), this.onBeforeNodeRemovedEmitter.emit(e), this.graphStore.removeNode(e);
|
|
1122
1148
|
}
|
|
1123
1149
|
clear() {
|
|
1124
|
-
this.
|
|
1125
|
-
}
|
|
1126
|
-
destroy() {
|
|
1127
|
-
this.clear(), this.htmlController.destroy();
|
|
1150
|
+
this.graphStore.clear(), this.nodeIdGenerator.reset(), this.portIdGenerator.reset(), this.edgeIdGenerator.reset();
|
|
1128
1151
|
}
|
|
1129
1152
|
}
|
|
1130
|
-
class
|
|
1131
|
-
constructor(
|
|
1132
|
-
this.graphStore =
|
|
1133
|
-
}
|
|
1134
|
-
getNode(
|
|
1135
|
-
const
|
|
1136
|
-
return
|
|
1137
|
-
element:
|
|
1138
|
-
x:
|
|
1139
|
-
y:
|
|
1140
|
-
centerFn:
|
|
1141
|
-
priority:
|
|
1153
|
+
class he {
|
|
1154
|
+
constructor(e) {
|
|
1155
|
+
this.graphStore = e;
|
|
1156
|
+
}
|
|
1157
|
+
getNode(e) {
|
|
1158
|
+
const r = this.graphStore.getNode(e);
|
|
1159
|
+
return r === void 0 ? null : {
|
|
1160
|
+
element: r.element,
|
|
1161
|
+
x: r.x,
|
|
1162
|
+
y: r.y,
|
|
1163
|
+
centerFn: r.centerFn,
|
|
1164
|
+
priority: r.priority
|
|
1142
1165
|
};
|
|
1143
1166
|
}
|
|
1144
1167
|
getAllNodeIds() {
|
|
1145
1168
|
return this.graphStore.getAllNodeIds();
|
|
1146
1169
|
}
|
|
1147
|
-
getPort(
|
|
1148
|
-
const
|
|
1149
|
-
return
|
|
1150
|
-
element:
|
|
1151
|
-
direction:
|
|
1170
|
+
getPort(e) {
|
|
1171
|
+
const r = this.graphStore.getPort(e);
|
|
1172
|
+
return r === void 0 ? null : {
|
|
1173
|
+
element: r.element,
|
|
1174
|
+
direction: r.direction
|
|
1152
1175
|
};
|
|
1153
1176
|
}
|
|
1154
1177
|
getAllPortIds() {
|
|
1155
1178
|
return this.graphStore.getAllPortIds();
|
|
1156
1179
|
}
|
|
1157
|
-
getNodePortIds(
|
|
1158
|
-
return this.graphStore.getNode(
|
|
1180
|
+
getNodePortIds(e) {
|
|
1181
|
+
return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodePortIds(e);
|
|
1159
1182
|
}
|
|
1160
|
-
getPortNodeId(
|
|
1161
|
-
return this.graphStore.getPortNodeId(
|
|
1183
|
+
getPortNodeId(e) {
|
|
1184
|
+
return this.graphStore.getPortNodeId(e) ?? null;
|
|
1162
1185
|
}
|
|
1163
1186
|
getAllEdgeIds() {
|
|
1164
1187
|
return this.graphStore.getAllEdgeIds();
|
|
1165
1188
|
}
|
|
1166
|
-
getEdge(
|
|
1167
|
-
const
|
|
1168
|
-
return
|
|
1189
|
+
getEdge(e) {
|
|
1190
|
+
const r = this.graphStore.getEdge(e);
|
|
1191
|
+
return r === void 0 ? null : { from: r.from, to: r.to, priority: r.priority };
|
|
1169
1192
|
}
|
|
1170
|
-
getPortIncomingEdgeIds(
|
|
1171
|
-
return this.graphStore.getPort(
|
|
1193
|
+
getPortIncomingEdgeIds(e) {
|
|
1194
|
+
return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortIncomingEdgeIds(e);
|
|
1172
1195
|
}
|
|
1173
|
-
getPortOutcomingEdgeIds(
|
|
1174
|
-
return this.graphStore.getPort(
|
|
1196
|
+
getPortOutcomingEdgeIds(e) {
|
|
1197
|
+
return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortOutcomingEdgeIds(e);
|
|
1175
1198
|
}
|
|
1176
|
-
getPortCycleEdgeIds(
|
|
1177
|
-
return this.graphStore.getPort(
|
|
1199
|
+
getPortCycleEdgeIds(e) {
|
|
1200
|
+
return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortCycleEdgeIds(e);
|
|
1178
1201
|
}
|
|
1179
|
-
getPortAdjacentEdgeIds(
|
|
1180
|
-
return this.graphStore.getPort(
|
|
1202
|
+
getPortAdjacentEdgeIds(e) {
|
|
1203
|
+
return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortAdjacentEdgeIds(e);
|
|
1181
1204
|
}
|
|
1182
|
-
getNodeIncomingEdgeIds(
|
|
1183
|
-
return this.graphStore.getNode(
|
|
1205
|
+
getNodeIncomingEdgeIds(e) {
|
|
1206
|
+
return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeIncomingEdgeIds(e);
|
|
1184
1207
|
}
|
|
1185
|
-
getNodeOutcomingEdgeIds(
|
|
1186
|
-
return this.graphStore.getNode(
|
|
1208
|
+
getNodeOutcomingEdgeIds(e) {
|
|
1209
|
+
return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeOutcomingEdgeIds(e);
|
|
1187
1210
|
}
|
|
1188
|
-
getNodeCycleEdgeIds(
|
|
1189
|
-
return this.graphStore.getNode(
|
|
1211
|
+
getNodeCycleEdgeIds(e) {
|
|
1212
|
+
return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeCycleEdgeIds(e);
|
|
1190
1213
|
}
|
|
1191
|
-
getNodeAdjacentEdgeIds(
|
|
1192
|
-
return this.graphStore.getNode(
|
|
1214
|
+
getNodeAdjacentEdgeIds(e) {
|
|
1215
|
+
return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeAdjacentEdgeIds(e);
|
|
1193
1216
|
}
|
|
1194
1217
|
}
|
|
1195
|
-
class
|
|
1196
|
-
constructor(
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
this
|
|
1202
|
-
|
|
1203
|
-
this
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1218
|
+
class ke {
|
|
1219
|
+
constructor(e) {
|
|
1220
|
+
i(this, "transformation");
|
|
1221
|
+
i(this, "model");
|
|
1222
|
+
i(this, "internalTransformation");
|
|
1223
|
+
i(this, "internalModel");
|
|
1224
|
+
i(this, "graphStoreController");
|
|
1225
|
+
i(this, "htmlController");
|
|
1226
|
+
i(this, "onAfterNodeAdded", (e) => {
|
|
1227
|
+
this.htmlController.attachNode(e);
|
|
1228
|
+
});
|
|
1229
|
+
i(this, "onAfterEdgeAdded", (e) => {
|
|
1230
|
+
this.htmlController.attachEdge(e);
|
|
1231
|
+
});
|
|
1232
|
+
i(this, "onAfterEdgeShapeUpdated", (e) => {
|
|
1233
|
+
this.htmlController.updateEdgeShape(e);
|
|
1234
|
+
});
|
|
1235
|
+
i(this, "onAfterEdgePriorityUpdated", (e) => {
|
|
1236
|
+
this.htmlController.updateEdgePriority(e);
|
|
1237
|
+
});
|
|
1238
|
+
i(this, "onAfterEdgeUpdated", (e) => {
|
|
1239
|
+
this.htmlController.renderEdge(e);
|
|
1240
|
+
});
|
|
1241
|
+
i(this, "onAfterPortUpdated", (e) => {
|
|
1242
|
+
this.internalModel.getPortAdjacentEdgeIds(e).forEach((o) => {
|
|
1243
|
+
this.htmlController.renderEdge(o);
|
|
1244
|
+
});
|
|
1245
|
+
});
|
|
1246
|
+
i(this, "onAfterNodePriorityUpdated", (e) => {
|
|
1247
|
+
this.htmlController.updateNodePriority(e);
|
|
1248
|
+
});
|
|
1249
|
+
i(this, "onAfterNodeUpdated", (e) => {
|
|
1250
|
+
this.htmlController.updateNodeCoordinates(e), this.internalModel.getNodeAdjacentEdgeIds(e).forEach((o) => {
|
|
1251
|
+
this.htmlController.renderEdge(o);
|
|
1252
|
+
});
|
|
1253
|
+
});
|
|
1254
|
+
i(this, "onBeforeEdgeRemoved", (e) => {
|
|
1255
|
+
this.htmlController.detachEdge(e);
|
|
1256
|
+
});
|
|
1257
|
+
i(this, "onBeforeNodeRemoved", (e) => {
|
|
1258
|
+
this.htmlController.detachNode(e);
|
|
1259
|
+
});
|
|
1260
|
+
i(this, "onAfterTransformUpdate", () => {
|
|
1261
|
+
this.htmlController.applyTransform();
|
|
1262
|
+
});
|
|
1263
|
+
this.internalModel = new re(), this.model = new he(this.internalModel), this.internalTransformation = new oe(), this.transformation = new ie(
|
|
1264
|
+
this.internalTransformation
|
|
1265
|
+
), this.htmlController = new ne(
|
|
1266
|
+
this.internalModel,
|
|
1267
|
+
this.internalTransformation
|
|
1268
|
+
), this.graphStoreController = new se(
|
|
1269
|
+
this.internalModel,
|
|
1270
|
+
Ae(e)
|
|
1271
|
+
), this.internalTransformation.onAfterUpdate.subscribe(
|
|
1272
|
+
this.onAfterTransformUpdate
|
|
1273
|
+
), this.graphStoreController.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graphStoreController.onAfterEdgeAdded.subscribe(this.onAfterEdgeAdded), this.graphStoreController.onAfterEdgeShapeUpdated.subscribe(
|
|
1274
|
+
this.onAfterEdgeShapeUpdated
|
|
1275
|
+
), this.graphStoreController.onAfterEdgePriorityUpdated.subscribe(
|
|
1276
|
+
this.onAfterEdgePriorityUpdated
|
|
1277
|
+
), this.graphStoreController.onAfterEdgeUpdated.subscribe(
|
|
1278
|
+
this.onAfterEdgeUpdated
|
|
1279
|
+
), this.graphStoreController.onAfterPortUpdated.subscribe(
|
|
1280
|
+
this.onAfterPortUpdated
|
|
1281
|
+
), this.graphStoreController.onAfterNodePriorityUpdated.subscribe(
|
|
1282
|
+
this.onAfterNodePriorityUpdated
|
|
1283
|
+
), this.graphStoreController.onAfterNodeUpdated.subscribe(
|
|
1284
|
+
this.onAfterNodeUpdated
|
|
1285
|
+
), this.graphStoreController.onBeforeEdgeRemoved.subscribe(
|
|
1286
|
+
this.onBeforeEdgeRemoved
|
|
1287
|
+
), this.graphStoreController.onBeforeNodeRemoved.subscribe(
|
|
1288
|
+
this.onBeforeNodeRemoved
|
|
1289
|
+
);
|
|
1290
|
+
}
|
|
1291
|
+
attach(e) {
|
|
1292
|
+
return this.htmlController.attach(e), this;
|
|
1293
|
+
}
|
|
1294
|
+
detach() {
|
|
1295
|
+
return this.htmlController.detach(), this;
|
|
1296
|
+
}
|
|
1297
|
+
addNode(e) {
|
|
1298
|
+
return this.graphStoreController.addNode(e), this;
|
|
1299
|
+
}
|
|
1300
|
+
updateNode(e, r) {
|
|
1301
|
+
return this.graphStoreController.updateNode(e, r ?? {}), this;
|
|
1302
|
+
}
|
|
1303
|
+
removeNode(e) {
|
|
1304
|
+
return this.graphStoreController.removeNode(e), this;
|
|
1305
|
+
}
|
|
1306
|
+
addEdge(e) {
|
|
1307
|
+
return this.graphStoreController.addEdge(e), this;
|
|
1308
|
+
}
|
|
1309
|
+
updateEdge(e, r) {
|
|
1310
|
+
return this.graphStoreController.updateEdge(e, r ?? {}), this;
|
|
1311
|
+
}
|
|
1312
|
+
removeEdge(e) {
|
|
1313
|
+
return this.graphStoreController.removeEdge(e), this;
|
|
1314
|
+
}
|
|
1315
|
+
markPort(e) {
|
|
1316
|
+
return this.graphStoreController.markPort(e), this;
|
|
1214
1317
|
}
|
|
1215
|
-
|
|
1216
|
-
return this.
|
|
1318
|
+
updatePort(e, r) {
|
|
1319
|
+
return this.graphStoreController.updatePort(e, r ?? {}), this;
|
|
1320
|
+
}
|
|
1321
|
+
unmarkPort(e) {
|
|
1322
|
+
return this.graphStoreController.unmarkPort(e), this;
|
|
1323
|
+
}
|
|
1324
|
+
patchViewportMatrix(e) {
|
|
1325
|
+
return this.internalTransformation.patchViewportMatrix(e), this;
|
|
1326
|
+
}
|
|
1327
|
+
patchContentMatrix(e) {
|
|
1328
|
+
return this.internalTransformation.patchContentMatrix(e), this;
|
|
1329
|
+
}
|
|
1330
|
+
clear() {
|
|
1331
|
+
return this.htmlController.clear(), this.graphStoreController.clear(), this;
|
|
1332
|
+
}
|
|
1333
|
+
destroy() {
|
|
1334
|
+
this.htmlController.destroy(), this.graphStoreController.clear(), this.internalTransformation.onAfterUpdate.unsubscribe(
|
|
1335
|
+
this.onAfterTransformUpdate
|
|
1336
|
+
), this.graphStoreController.onAfterNodeAdded.unsubscribe(
|
|
1337
|
+
this.onAfterNodeAdded
|
|
1338
|
+
), this.graphStoreController.onAfterEdgeAdded.unsubscribe(
|
|
1339
|
+
this.onAfterEdgeAdded
|
|
1340
|
+
), this.graphStoreController.onAfterEdgeShapeUpdated.unsubscribe(
|
|
1341
|
+
this.onAfterEdgeShapeUpdated
|
|
1342
|
+
), this.graphStoreController.onAfterEdgePriorityUpdated.unsubscribe(
|
|
1343
|
+
this.onAfterEdgePriorityUpdated
|
|
1344
|
+
), this.graphStoreController.onAfterEdgeUpdated.unsubscribe(
|
|
1345
|
+
this.onAfterEdgeUpdated
|
|
1346
|
+
), this.graphStoreController.onAfterPortUpdated.unsubscribe(
|
|
1347
|
+
this.onAfterPortUpdated
|
|
1348
|
+
), this.graphStoreController.onAfterNodePriorityUpdated.unsubscribe(
|
|
1349
|
+
this.onAfterNodePriorityUpdated
|
|
1350
|
+
), this.graphStoreController.onAfterNodeUpdated.unsubscribe(
|
|
1351
|
+
this.onAfterNodeUpdated
|
|
1352
|
+
), this.graphStoreController.onBeforeEdgeRemoved.unsubscribe(
|
|
1353
|
+
this.onBeforeEdgeRemoved
|
|
1354
|
+
), this.graphStoreController.onBeforeNodeRemoved.unsubscribe(
|
|
1355
|
+
this.onBeforeNodeRemoved
|
|
1356
|
+
);
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
class Ce {
|
|
1360
|
+
constructor(e) {
|
|
1361
|
+
i(this, "transformation");
|
|
1362
|
+
i(this, "model");
|
|
1363
|
+
i(this, "internalTransformation");
|
|
1364
|
+
i(this, "internalModel");
|
|
1365
|
+
i(this, "graphStoreController");
|
|
1366
|
+
i(this, "htmlController");
|
|
1367
|
+
i(this, "onAfterNodeAdded", (e) => {
|
|
1368
|
+
this.htmlController.attachNode(e);
|
|
1369
|
+
});
|
|
1370
|
+
i(this, "onAfterEdgeAdded", (e) => {
|
|
1371
|
+
this.htmlController.attachEdge(e);
|
|
1372
|
+
});
|
|
1373
|
+
i(this, "onAfterEdgeShapeUpdated", (e) => {
|
|
1374
|
+
this.htmlController.updateEdgeShape(e);
|
|
1375
|
+
});
|
|
1376
|
+
i(this, "onAfterEdgePriorityUpdated", (e) => {
|
|
1377
|
+
this.htmlController.updateEdgePriority(e);
|
|
1378
|
+
});
|
|
1379
|
+
i(this, "onAfterEdgeUpdated", (e) => {
|
|
1380
|
+
this.htmlController.renderEdge(e);
|
|
1381
|
+
});
|
|
1382
|
+
i(this, "onAfterPortUpdated", (e) => {
|
|
1383
|
+
this.internalModel.getPortAdjacentEdgeIds(e).forEach((o) => {
|
|
1384
|
+
this.htmlController.renderEdge(o);
|
|
1385
|
+
});
|
|
1386
|
+
});
|
|
1387
|
+
i(this, "onAfterNodePriorityUpdated", (e) => {
|
|
1388
|
+
this.htmlController.updateNodePriority(e);
|
|
1389
|
+
});
|
|
1390
|
+
i(this, "onAfterNodeUpdated", (e) => {
|
|
1391
|
+
this.htmlController.updateNodeCoordinates(e), this.internalModel.getNodeAdjacentEdgeIds(e).forEach((o) => {
|
|
1392
|
+
this.htmlController.renderEdge(o);
|
|
1393
|
+
});
|
|
1394
|
+
});
|
|
1395
|
+
i(this, "onBeforeEdgeRemoved", (e) => {
|
|
1396
|
+
this.htmlController.detachEdge(e);
|
|
1397
|
+
});
|
|
1398
|
+
i(this, "onBeforeNodeRemoved", (e) => {
|
|
1399
|
+
this.htmlController.detachNode(e);
|
|
1400
|
+
});
|
|
1401
|
+
i(this, "onAfterTransformUpdate", () => {
|
|
1402
|
+
this.htmlController.applyTransform();
|
|
1403
|
+
});
|
|
1404
|
+
this.model = e.publicGraphStore, this.internalModel = e.graphStore, this.internalTransformation = e.viewportTransformer, this.transformation = e.publicViewportTransformer, this.htmlController = e.htmlController, this.graphStoreController = e.graphStoreController, this.internalTransformation.onAfterUpdate.subscribe(
|
|
1405
|
+
this.onAfterTransformUpdate
|
|
1406
|
+
), this.graphStoreController.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graphStoreController.onAfterEdgeAdded.subscribe(this.onAfterEdgeAdded), this.graphStoreController.onAfterEdgeShapeUpdated.subscribe(
|
|
1407
|
+
this.onAfterEdgeShapeUpdated
|
|
1408
|
+
), this.graphStoreController.onAfterEdgePriorityUpdated.subscribe(
|
|
1409
|
+
this.onAfterEdgePriorityUpdated
|
|
1410
|
+
), this.graphStoreController.onAfterEdgeUpdated.subscribe(
|
|
1411
|
+
this.onAfterEdgeUpdated
|
|
1412
|
+
), this.graphStoreController.onAfterPortUpdated.subscribe(
|
|
1413
|
+
this.onAfterPortUpdated
|
|
1414
|
+
), this.graphStoreController.onAfterNodePriorityUpdated.subscribe(
|
|
1415
|
+
this.onAfterNodePriorityUpdated
|
|
1416
|
+
), this.graphStoreController.onAfterNodeUpdated.subscribe(
|
|
1417
|
+
this.onAfterNodeUpdated
|
|
1418
|
+
), this.graphStoreController.onBeforeEdgeRemoved.subscribe(
|
|
1419
|
+
this.onBeforeEdgeRemoved
|
|
1420
|
+
), this.graphStoreController.onBeforeNodeRemoved.subscribe(
|
|
1421
|
+
this.onBeforeNodeRemoved
|
|
1422
|
+
);
|
|
1423
|
+
}
|
|
1424
|
+
attach(e) {
|
|
1425
|
+
return this.htmlController.attach(e), this;
|
|
1217
1426
|
}
|
|
1218
1427
|
detach() {
|
|
1219
|
-
return this.
|
|
1220
|
-
}
|
|
1221
|
-
addNode(
|
|
1222
|
-
return this.
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
return this.canvasController.updateEdge({
|
|
1254
|
-
edgeId: t,
|
|
1255
|
-
shape: o == null ? void 0 : o.shape,
|
|
1256
|
-
priority: o == null ? void 0 : o.priority,
|
|
1257
|
-
from: o == null ? void 0 : o.from,
|
|
1258
|
-
to: o == null ? void 0 : o.to
|
|
1259
|
-
}), this;
|
|
1260
|
-
}
|
|
1261
|
-
removeEdge(t) {
|
|
1262
|
-
return this.canvasController.removeEdge(t), this;
|
|
1263
|
-
}
|
|
1264
|
-
markPort(t) {
|
|
1265
|
-
return this.canvasController.markPort({
|
|
1266
|
-
portId: t.id,
|
|
1267
|
-
element: t.element,
|
|
1268
|
-
nodeId: t.nodeId,
|
|
1269
|
-
direction: t.direction
|
|
1270
|
-
}), this;
|
|
1271
|
-
}
|
|
1272
|
-
updatePort(t, o) {
|
|
1273
|
-
return this.canvasController.updatePort(t, {
|
|
1274
|
-
direction: o == null ? void 0 : o.direction
|
|
1275
|
-
}), this;
|
|
1276
|
-
}
|
|
1277
|
-
unmarkPort(t) {
|
|
1278
|
-
return this.canvasController.unmarkPort(t), this;
|
|
1279
|
-
}
|
|
1280
|
-
patchViewportMatrix(t) {
|
|
1281
|
-
return this.canvasController.patchViewportMatrix(t), this;
|
|
1282
|
-
}
|
|
1283
|
-
patchContentMatrix(t) {
|
|
1284
|
-
return this.canvasController.patchContentMatrix(t), this;
|
|
1428
|
+
return this.htmlController.detach(), this;
|
|
1429
|
+
}
|
|
1430
|
+
addNode(e) {
|
|
1431
|
+
return this.graphStoreController.addNode(e), this;
|
|
1432
|
+
}
|
|
1433
|
+
updateNode(e, r) {
|
|
1434
|
+
return this.graphStoreController.updateNode(e, r ?? {}), this;
|
|
1435
|
+
}
|
|
1436
|
+
removeNode(e) {
|
|
1437
|
+
return this.graphStoreController.removeNode(e), this;
|
|
1438
|
+
}
|
|
1439
|
+
addEdge(e) {
|
|
1440
|
+
return this.graphStoreController.addEdge(e), this;
|
|
1441
|
+
}
|
|
1442
|
+
updateEdge(e, r) {
|
|
1443
|
+
return this.graphStoreController.updateEdge(e, r ?? {}), this;
|
|
1444
|
+
}
|
|
1445
|
+
removeEdge(e) {
|
|
1446
|
+
return this.graphStoreController.removeEdge(e), this;
|
|
1447
|
+
}
|
|
1448
|
+
markPort(e) {
|
|
1449
|
+
return this.graphStoreController.markPort(e), this;
|
|
1450
|
+
}
|
|
1451
|
+
updatePort(e, r) {
|
|
1452
|
+
return this.graphStoreController.updatePort(e, r ?? {}), this;
|
|
1453
|
+
}
|
|
1454
|
+
unmarkPort(e) {
|
|
1455
|
+
return this.graphStoreController.unmarkPort(e), this;
|
|
1456
|
+
}
|
|
1457
|
+
patchViewportMatrix(e) {
|
|
1458
|
+
return this.internalTransformation.patchViewportMatrix(e), this;
|
|
1459
|
+
}
|
|
1460
|
+
patchContentMatrix(e) {
|
|
1461
|
+
return this.internalTransformation.patchContentMatrix(e), this;
|
|
1285
1462
|
}
|
|
1286
1463
|
clear() {
|
|
1287
|
-
return this.
|
|
1464
|
+
return this.htmlController.clear(), this.graphStoreController.clear(), this;
|
|
1288
1465
|
}
|
|
1289
1466
|
destroy() {
|
|
1290
|
-
this.clear(), this.
|
|
1467
|
+
this.htmlController.destroy(), this.graphStoreController.clear(), this.internalTransformation.onAfterUpdate.unsubscribe(
|
|
1468
|
+
this.onAfterTransformUpdate
|
|
1469
|
+
), this.graphStoreController.onAfterNodeAdded.unsubscribe(
|
|
1470
|
+
this.onAfterNodeAdded
|
|
1471
|
+
), this.graphStoreController.onAfterEdgeAdded.unsubscribe(
|
|
1472
|
+
this.onAfterEdgeAdded
|
|
1473
|
+
), this.graphStoreController.onAfterEdgeShapeUpdated.unsubscribe(
|
|
1474
|
+
this.onAfterEdgeShapeUpdated
|
|
1475
|
+
), this.graphStoreController.onAfterEdgePriorityUpdated.unsubscribe(
|
|
1476
|
+
this.onAfterEdgePriorityUpdated
|
|
1477
|
+
), this.graphStoreController.onAfterEdgeUpdated.unsubscribe(
|
|
1478
|
+
this.onAfterEdgeUpdated
|
|
1479
|
+
), this.graphStoreController.onAfterPortUpdated.unsubscribe(
|
|
1480
|
+
this.onAfterPortUpdated
|
|
1481
|
+
), this.graphStoreController.onAfterNodePriorityUpdated.unsubscribe(
|
|
1482
|
+
this.onAfterNodePriorityUpdated
|
|
1483
|
+
), this.graphStoreController.onAfterNodeUpdated.unsubscribe(
|
|
1484
|
+
this.onAfterNodeUpdated
|
|
1485
|
+
), this.graphStoreController.onBeforeEdgeRemoved.unsubscribe(
|
|
1486
|
+
this.onBeforeEdgeRemoved
|
|
1487
|
+
), this.graphStoreController.onBeforeNodeRemoved.unsubscribe(
|
|
1488
|
+
this.onBeforeNodeRemoved
|
|
1489
|
+
);
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
const Ne = (t) => {
|
|
1493
|
+
if (typeof t == "function")
|
|
1494
|
+
return t;
|
|
1495
|
+
switch (t == null ? void 0 : t.type) {
|
|
1496
|
+
case "straight":
|
|
1497
|
+
return () => new ee({
|
|
1498
|
+
color: t.color,
|
|
1499
|
+
width: t.width,
|
|
1500
|
+
arrowLength: t.arrowLength,
|
|
1501
|
+
arrowWidth: t.arrowWidth,
|
|
1502
|
+
arrowOffset: t.arrowOffset,
|
|
1503
|
+
hasSourceArrow: t.hasSourceArrow,
|
|
1504
|
+
hasTargetArrow: t.hasTargetArrow,
|
|
1505
|
+
cycleSquareSide: t.cycleSquareSide,
|
|
1506
|
+
roundness: t.roundness,
|
|
1507
|
+
detourDistance: t.detourDistance,
|
|
1508
|
+
detourDirection: t.detourDirection
|
|
1509
|
+
});
|
|
1510
|
+
case "horizontal":
|
|
1511
|
+
return () => new O({
|
|
1512
|
+
color: t.color,
|
|
1513
|
+
width: t.width,
|
|
1514
|
+
arrowLength: t.arrowLength,
|
|
1515
|
+
arrowWidth: t.arrowWidth,
|
|
1516
|
+
arrowOffset: t.arrowOffset,
|
|
1517
|
+
hasSourceArrow: t.hasSourceArrow,
|
|
1518
|
+
hasTargetArrow: t.hasTargetArrow,
|
|
1519
|
+
cycleSquareSide: t.cycleSquareSide,
|
|
1520
|
+
roundness: t.roundness,
|
|
1521
|
+
detourDistance: t.detourDistance,
|
|
1522
|
+
detourDirection: t.detourDirection
|
|
1523
|
+
});
|
|
1524
|
+
case "vertical":
|
|
1525
|
+
return () => new te({
|
|
1526
|
+
color: t.color,
|
|
1527
|
+
width: t.width,
|
|
1528
|
+
arrowLength: t.arrowLength,
|
|
1529
|
+
arrowWidth: t.arrowWidth,
|
|
1530
|
+
arrowOffset: t.arrowOffset,
|
|
1531
|
+
hasSourceArrow: t.hasSourceArrow,
|
|
1532
|
+
hasTargetArrow: t.hasTargetArrow,
|
|
1533
|
+
cycleSquareSide: t.cycleSquareSide,
|
|
1534
|
+
roundness: t.roundness,
|
|
1535
|
+
detourDistance: t.detourDistance,
|
|
1536
|
+
detourDirection: t.detourDirection
|
|
1537
|
+
});
|
|
1538
|
+
default:
|
|
1539
|
+
return () => new q({
|
|
1540
|
+
color: t.color,
|
|
1541
|
+
width: t.width,
|
|
1542
|
+
arrowLength: t.arrowLength,
|
|
1543
|
+
arrowWidth: t.arrowWidth,
|
|
1544
|
+
hasSourceArrow: t.hasSourceArrow,
|
|
1545
|
+
hasTargetArrow: t.hasTargetArrow,
|
|
1546
|
+
cycleRadius: t.cycleRadius,
|
|
1547
|
+
smallCycleRadius: t.smallCycleRadius,
|
|
1548
|
+
curvature: t.curvature,
|
|
1549
|
+
detourDistance: t.detourDistance,
|
|
1550
|
+
detourDirection: t.detourDirection
|
|
1551
|
+
});
|
|
1552
|
+
}
|
|
1553
|
+
}, Te = (t, e) => {
|
|
1554
|
+
let r = I, o = I;
|
|
1555
|
+
t === "incremental" && (r = M()), e === "incremental" && (o = M());
|
|
1556
|
+
const n = M();
|
|
1557
|
+
return t === "shared-incremental" && (r = n), e === "shared-incremental" && (o = n), typeof t == "number" && (r = V(t)), typeof e == "number" && (o = V(e)), typeof t == "function" && (r = t), typeof e == "function" && (o = e), {
|
|
1558
|
+
nodesPriorityFn: r,
|
|
1559
|
+
edgesPriorityFn: o
|
|
1560
|
+
};
|
|
1561
|
+
}, pe = (t) => {
|
|
1562
|
+
var r, o, n, d, s;
|
|
1563
|
+
const e = Te(
|
|
1564
|
+
(r = t == null ? void 0 : t.nodes) == null ? void 0 : r.priority,
|
|
1565
|
+
(o = t == null ? void 0 : t.edges) == null ? void 0 : o.priority
|
|
1566
|
+
);
|
|
1567
|
+
return {
|
|
1568
|
+
nodes: {
|
|
1569
|
+
centerFn: ((n = t == null ? void 0 : t.nodes) == null ? void 0 : n.centerFn) ?? Z,
|
|
1570
|
+
priorityFn: e.nodesPriorityFn
|
|
1571
|
+
},
|
|
1572
|
+
ports: {
|
|
1573
|
+
direction: ((d = t == null ? void 0 : t.ports) == null ? void 0 : d.direction) ?? 0
|
|
1574
|
+
},
|
|
1575
|
+
edges: {
|
|
1576
|
+
shapeFactory: Ne(((s = t == null ? void 0 : t.edges) == null ? void 0 : s.shape) ?? {}),
|
|
1577
|
+
priorityFn: e.edgesPriorityFn
|
|
1578
|
+
}
|
|
1579
|
+
};
|
|
1580
|
+
};
|
|
1581
|
+
class be {
|
|
1582
|
+
constructor(e) {
|
|
1583
|
+
i(this, "publicViewportTransformer");
|
|
1584
|
+
i(this, "publicGraphStore");
|
|
1585
|
+
i(this, "viewportTransformer");
|
|
1586
|
+
i(this, "graphStore");
|
|
1587
|
+
i(this, "htmlController");
|
|
1588
|
+
i(this, "graphStoreController");
|
|
1589
|
+
this.graphStore = new re(), this.publicGraphStore = new he(this.graphStore), this.viewportTransformer = new oe(), this.publicViewportTransformer = new ie(
|
|
1590
|
+
this.viewportTransformer
|
|
1591
|
+
), this.htmlController = new ne(
|
|
1592
|
+
this.graphStore,
|
|
1593
|
+
this.viewportTransformer
|
|
1594
|
+
), this.graphStoreController = new se(
|
|
1595
|
+
this.graphStore,
|
|
1596
|
+
pe(e)
|
|
1597
|
+
);
|
|
1291
1598
|
}
|
|
1292
1599
|
}
|
|
1293
|
-
const
|
|
1294
|
-
const { x:
|
|
1295
|
-
return
|
|
1296
|
-
},
|
|
1297
|
-
|
|
1298
|
-
},
|
|
1299
|
-
var
|
|
1300
|
-
const
|
|
1301
|
-
}),
|
|
1302
|
-
}),
|
|
1600
|
+
const W = (t, e, r) => {
|
|
1601
|
+
const { x: o, y: n, width: d, height: s } = t.getBoundingClientRect();
|
|
1602
|
+
return e >= o && e <= o + d && r >= n && r <= n + s;
|
|
1603
|
+
}, R = (t, e, r) => e >= 0 && e <= t.innerWidth && r >= 0 && r <= t.innerHeight, F = (t, e) => {
|
|
1604
|
+
e !== null ? t.style.cursor = e : t.style.removeProperty("cursor");
|
|
1605
|
+
}, Me = (t) => {
|
|
1606
|
+
var u, f, A, y, m, E;
|
|
1607
|
+
const e = ((u = t == null ? void 0 : t.events) == null ? void 0 : u.onNodeDrag) ?? (() => {
|
|
1608
|
+
}), r = ((f = t == null ? void 0 : t.events) == null ? void 0 : f.onBeforeNodeDrag) ?? (() => !0), o = ((A = t == null ? void 0 : t.events) == null ? void 0 : A.onNodeDragFinished) ?? (() => {
|
|
1609
|
+
}), 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 = (m = t == null ? void 0 : t.mouse) == null ? void 0 : m.mouseDownEventVerifier, c = h !== void 0 ? h : (C) => C.button === 0, a = (E = t == null ? void 0 : t.mouse) == null ? void 0 : E.mouseUpEventVerifier;
|
|
1303
1610
|
return {
|
|
1304
|
-
freezePriority:
|
|
1305
|
-
dragCursor:
|
|
1306
|
-
mouseDownEventVerifier:
|
|
1307
|
-
mouseUpEventVerifier:
|
|
1308
|
-
onNodeDrag:
|
|
1309
|
-
onBeforeNodeDrag:
|
|
1310
|
-
onNodeDragFinished:
|
|
1611
|
+
freezePriority: n,
|
|
1612
|
+
dragCursor: s,
|
|
1613
|
+
mouseDownEventVerifier: c,
|
|
1614
|
+
mouseUpEventVerifier: a !== void 0 ? a : (C) => C.button === 0,
|
|
1615
|
+
onNodeDrag: e,
|
|
1616
|
+
onBeforeNodeDrag: r,
|
|
1617
|
+
onNodeDragFinished: o
|
|
1311
1618
|
};
|
|
1312
1619
|
};
|
|
1313
|
-
class
|
|
1314
|
-
constructor(
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
(
|
|
1620
|
+
class Pe {
|
|
1621
|
+
constructor(e, r) {
|
|
1622
|
+
i(this, "model");
|
|
1623
|
+
i(this, "transformation");
|
|
1624
|
+
i(this, "maxNodePriority", 0);
|
|
1625
|
+
i(this, "nodes", /* @__PURE__ */ new Map());
|
|
1626
|
+
i(this, "grabbedNodeId", null);
|
|
1627
|
+
i(this, "nodeIdGenerator", new U(
|
|
1628
|
+
(e) => this.nodes.has(e)
|
|
1322
1629
|
));
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
if (this.element !== null && (!
|
|
1630
|
+
i(this, "element", null);
|
|
1631
|
+
i(this, "onWindowMouseMove", (e) => {
|
|
1632
|
+
if (this.element !== null && (!W(this.element, e.clientX, e.clientY) || !R(this.window, e.clientX, e.clientY))) {
|
|
1326
1633
|
this.cancelMouseDrag();
|
|
1327
1634
|
return;
|
|
1328
1635
|
}
|
|
1329
|
-
this.grabbedNodeId !== null && this.dragNode(this.grabbedNodeId,
|
|
1636
|
+
this.grabbedNodeId !== null && this.dragNode(this.grabbedNodeId, e.movementX, e.movementY);
|
|
1330
1637
|
});
|
|
1331
|
-
|
|
1332
|
-
this.options.mouseUpEventVerifier(
|
|
1638
|
+
i(this, "onWindowMouseUp", (e) => {
|
|
1639
|
+
this.options.mouseUpEventVerifier(e) && this.cancelMouseDrag();
|
|
1333
1640
|
});
|
|
1334
|
-
|
|
1335
|
-
if (
|
|
1641
|
+
i(this, "onWindowTouchMove", (e) => {
|
|
1642
|
+
if (e.touches.length !== 1)
|
|
1336
1643
|
return;
|
|
1337
|
-
const
|
|
1338
|
-
if (this.element !== null && (!
|
|
1644
|
+
const r = e.touches[0];
|
|
1645
|
+
if (this.element !== null && (!W(this.element, r.clientX, r.clientY) || !R(this.window, r.clientX, r.clientY))) {
|
|
1339
1646
|
this.cancelTouchDrag();
|
|
1340
1647
|
return;
|
|
1341
1648
|
}
|
|
1342
1649
|
if (this.grabbedNodeId !== null && this.previousTouchCoords !== null) {
|
|
1343
|
-
const
|
|
1344
|
-
this.dragNode(this.grabbedNodeId,
|
|
1345
|
-
x:
|
|
1346
|
-
y:
|
|
1650
|
+
const o = r.clientX - this.previousTouchCoords.x, n = r.clientY - this.previousTouchCoords.y;
|
|
1651
|
+
this.dragNode(this.grabbedNodeId, o, n), this.previousTouchCoords = {
|
|
1652
|
+
x: e.touches[0].clientX,
|
|
1653
|
+
y: e.touches[0].clientY
|
|
1347
1654
|
};
|
|
1348
1655
|
}
|
|
1349
1656
|
});
|
|
1350
|
-
|
|
1657
|
+
i(this, "onWindowTouchFinish", () => {
|
|
1351
1658
|
this.previousTouchCoords = null, this.cancelTouchDrag();
|
|
1352
1659
|
});
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
this.canvas =
|
|
1660
|
+
i(this, "previousTouchCoords", null);
|
|
1661
|
+
i(this, "window", window);
|
|
1662
|
+
i(this, "options");
|
|
1663
|
+
this.canvas = e, this.transformation = this.canvas.transformation, this.model = this.canvas.model, this.options = Me(r ?? {});
|
|
1357
1664
|
}
|
|
1358
|
-
attach(
|
|
1359
|
-
return this.detach(), this.element =
|
|
1665
|
+
attach(e) {
|
|
1666
|
+
return this.detach(), this.element = e, this.canvas.attach(this.element), this;
|
|
1360
1667
|
}
|
|
1361
1668
|
detach() {
|
|
1362
1669
|
return this.canvas.detach(), this.element !== null && (this.element = null), this;
|
|
1363
1670
|
}
|
|
1364
|
-
addNode(
|
|
1365
|
-
const
|
|
1366
|
-
this.canvas.addNode({ ...
|
|
1367
|
-
const
|
|
1368
|
-
if (this.element === null || !this.options.mouseDownEventVerifier(
|
|
1671
|
+
addNode(e) {
|
|
1672
|
+
const r = this.nodeIdGenerator.create(e.id);
|
|
1673
|
+
this.canvas.addNode({ ...e, id: r }), this.updateMaxNodePriority(r);
|
|
1674
|
+
const o = (d) => {
|
|
1675
|
+
if (this.element === null || !this.options.mouseDownEventVerifier(d))
|
|
1369
1676
|
return;
|
|
1370
|
-
const
|
|
1677
|
+
const s = this.model.getNode(r);
|
|
1371
1678
|
this.options.onBeforeNodeDrag({
|
|
1372
|
-
nodeId:
|
|
1373
|
-
element:
|
|
1374
|
-
x:
|
|
1375
|
-
y:
|
|
1376
|
-
}) && (
|
|
1377
|
-
},
|
|
1378
|
-
if (
|
|
1679
|
+
nodeId: r,
|
|
1680
|
+
element: e.element,
|
|
1681
|
+
x: s.x,
|
|
1682
|
+
y: s.y
|
|
1683
|
+
}) && (d.stopImmediatePropagation(), this.grabbedNodeId = r, F(this.element, this.options.dragCursor), this.moveNodeOnTop(r), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.window.addEventListener("mousemove", this.onWindowMouseMove));
|
|
1684
|
+
}, n = (d) => {
|
|
1685
|
+
if (d.touches.length !== 1)
|
|
1379
1686
|
return;
|
|
1380
|
-
|
|
1381
|
-
x:
|
|
1382
|
-
y:
|
|
1687
|
+
d.stopImmediatePropagation(), this.previousTouchCoords = {
|
|
1688
|
+
x: d.touches[0].clientX,
|
|
1689
|
+
y: d.touches[0].clientY
|
|
1383
1690
|
};
|
|
1384
|
-
const
|
|
1691
|
+
const s = this.model.getNode(r);
|
|
1385
1692
|
this.options.onBeforeNodeDrag({
|
|
1386
|
-
nodeId:
|
|
1387
|
-
element:
|
|
1388
|
-
x:
|
|
1389
|
-
y:
|
|
1390
|
-
}) && (this.grabbedNodeId =
|
|
1693
|
+
nodeId: r,
|
|
1694
|
+
element: e.element,
|
|
1695
|
+
x: s.x,
|
|
1696
|
+
y: s.y
|
|
1697
|
+
}) && (this.grabbedNodeId = r, this.moveNodeOnTop(r), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish));
|
|
1391
1698
|
};
|
|
1392
|
-
return this.nodes.set(
|
|
1393
|
-
element:
|
|
1394
|
-
onMouseDown:
|
|
1395
|
-
onTouchStart:
|
|
1396
|
-
}),
|
|
1699
|
+
return this.nodes.set(r, {
|
|
1700
|
+
element: e.element,
|
|
1701
|
+
onMouseDown: o,
|
|
1702
|
+
onTouchStart: n
|
|
1703
|
+
}), e.element.addEventListener("mousedown", o), e.element.addEventListener("touchstart", n), this;
|
|
1397
1704
|
}
|
|
1398
|
-
updateNode(
|
|
1399
|
-
return this.canvas.updateNode(
|
|
1705
|
+
updateNode(e, r) {
|
|
1706
|
+
return this.canvas.updateNode(e, r), this.updateMaxNodePriority(e), this;
|
|
1400
1707
|
}
|
|
1401
|
-
removeNode(
|
|
1402
|
-
const
|
|
1403
|
-
return
|
|
1708
|
+
removeNode(e) {
|
|
1709
|
+
const r = this.nodes.get(e);
|
|
1710
|
+
return r !== void 0 && (r.element.removeEventListener("mousedown", r.onMouseDown), r.element.removeEventListener("touchstart", r.onTouchStart)), this.nodes.delete(e), this.canvas.removeNode(e), this;
|
|
1404
1711
|
}
|
|
1405
|
-
markPort(
|
|
1406
|
-
return this.canvas.markPort(
|
|
1712
|
+
markPort(e) {
|
|
1713
|
+
return this.canvas.markPort(e), this;
|
|
1407
1714
|
}
|
|
1408
|
-
updatePort(
|
|
1409
|
-
return this.canvas.updatePort(
|
|
1715
|
+
updatePort(e, r) {
|
|
1716
|
+
return this.canvas.updatePort(e, r), this;
|
|
1410
1717
|
}
|
|
1411
|
-
unmarkPort(
|
|
1412
|
-
return this.canvas.unmarkPort(
|
|
1718
|
+
unmarkPort(e) {
|
|
1719
|
+
return this.canvas.unmarkPort(e), this;
|
|
1413
1720
|
}
|
|
1414
|
-
addEdge(
|
|
1415
|
-
return this.canvas.addEdge(
|
|
1721
|
+
addEdge(e) {
|
|
1722
|
+
return this.canvas.addEdge(e), this;
|
|
1416
1723
|
}
|
|
1417
|
-
updateEdge(
|
|
1418
|
-
return this.canvas.updateEdge(
|
|
1724
|
+
updateEdge(e, r) {
|
|
1725
|
+
return this.canvas.updateEdge(e, r), this;
|
|
1419
1726
|
}
|
|
1420
|
-
removeEdge(
|
|
1421
|
-
return this.canvas.removeEdge(
|
|
1727
|
+
removeEdge(e) {
|
|
1728
|
+
return this.canvas.removeEdge(e), this;
|
|
1422
1729
|
}
|
|
1423
|
-
patchViewportMatrix(
|
|
1424
|
-
return this.canvas.patchViewportMatrix(
|
|
1730
|
+
patchViewportMatrix(e) {
|
|
1731
|
+
return this.canvas.patchViewportMatrix(e), this;
|
|
1425
1732
|
}
|
|
1426
|
-
patchContentMatrix(
|
|
1427
|
-
return this.canvas.patchContentMatrix(
|
|
1733
|
+
patchContentMatrix(e) {
|
|
1734
|
+
return this.canvas.patchContentMatrix(e), this;
|
|
1428
1735
|
}
|
|
1429
1736
|
clear() {
|
|
1430
|
-
return this.canvas.clear(), this.nodes.forEach((
|
|
1431
|
-
|
|
1737
|
+
return this.canvas.clear(), this.nodes.forEach((e) => {
|
|
1738
|
+
e.element.removeEventListener("mousedown", e.onMouseDown), e.element.removeEventListener("touchstart", e.onTouchStart);
|
|
1432
1739
|
}), this.nodes.clear(), this.maxNodePriority = 0, this;
|
|
1433
1740
|
}
|
|
1434
1741
|
destroy() {
|
|
1435
1742
|
this.detach(), this.clear(), this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.canvas.destroy();
|
|
1436
1743
|
}
|
|
1437
|
-
dragNode(
|
|
1438
|
-
const
|
|
1439
|
-
if (
|
|
1744
|
+
dragNode(e, r, o) {
|
|
1745
|
+
const n = this.model.getNode(e);
|
|
1746
|
+
if (n === null)
|
|
1440
1747
|
return;
|
|
1441
|
-
const
|
|
1442
|
-
this.canvas.updateNode(
|
|
1443
|
-
nodeId:
|
|
1444
|
-
element:
|
|
1445
|
-
x:
|
|
1446
|
-
y
|
|
1748
|
+
const d = this.canvas.transformation.getContentMatrix(), s = d.scale * n.x + d.x, h = d.scale * n.y + d.y, c = s + r, a = h + o, l = this.canvas.transformation.getViewportMatrix(), u = l.scale * c + l.x, f = l.scale * a + l.y;
|
|
1749
|
+
this.canvas.updateNode(e, { x: u, y: f }), this.options.onNodeDrag({
|
|
1750
|
+
nodeId: e,
|
|
1751
|
+
element: n.element,
|
|
1752
|
+
x: u,
|
|
1753
|
+
y: f
|
|
1447
1754
|
});
|
|
1448
1755
|
}
|
|
1449
|
-
updateMaxNodePriority(
|
|
1450
|
-
const
|
|
1451
|
-
this.maxNodePriority = Math.max(this.maxNodePriority,
|
|
1756
|
+
updateMaxNodePriority(e) {
|
|
1757
|
+
const r = this.model.getNode(e).priority;
|
|
1758
|
+
this.maxNodePriority = Math.max(this.maxNodePriority, r);
|
|
1452
1759
|
}
|
|
1453
|
-
moveNodeOnTop(
|
|
1760
|
+
moveNodeOnTop(e) {
|
|
1454
1761
|
if (this.options.freezePriority)
|
|
1455
1762
|
return;
|
|
1456
|
-
this.maxNodePriority += 2, this.updateNode(
|
|
1457
|
-
const
|
|
1458
|
-
this.model.getNodeAdjacentEdgeIds(
|
|
1459
|
-
this.updateEdge(
|
|
1763
|
+
this.maxNodePriority += 2, this.updateNode(e, { priority: this.maxNodePriority });
|
|
1764
|
+
const r = this.maxNodePriority - 1;
|
|
1765
|
+
this.model.getNodeAdjacentEdgeIds(e).forEach((n) => {
|
|
1766
|
+
this.updateEdge(n, { priority: r });
|
|
1460
1767
|
});
|
|
1461
1768
|
}
|
|
1462
1769
|
cancelMouseDrag() {
|
|
1463
|
-
const
|
|
1464
|
-
|
|
1770
|
+
const e = this.model.getNode(this.grabbedNodeId);
|
|
1771
|
+
e !== null && this.options.onNodeDragFinished({
|
|
1465
1772
|
nodeId: this.grabbedNodeId,
|
|
1466
|
-
element:
|
|
1467
|
-
x:
|
|
1468
|
-
y:
|
|
1469
|
-
}), this.grabbedNodeId = null, this.element !== null &&
|
|
1773
|
+
element: e.element,
|
|
1774
|
+
x: e.x,
|
|
1775
|
+
y: e.y
|
|
1776
|
+
}), this.grabbedNodeId = null, this.element !== null && F(this.element, null), this.removeMouseDragListeners();
|
|
1470
1777
|
}
|
|
1471
1778
|
removeMouseDragListeners() {
|
|
1472
1779
|
this.window.removeEventListener("mouseup", this.onWindowMouseUp), this.window.removeEventListener("mousemove", this.onWindowMouseMove);
|
|
1473
1780
|
}
|
|
1474
1781
|
cancelTouchDrag() {
|
|
1475
1782
|
this.previousTouchCoords = null;
|
|
1476
|
-
const
|
|
1477
|
-
|
|
1783
|
+
const e = this.model.getNode(this.grabbedNodeId);
|
|
1784
|
+
e !== null && this.options.onNodeDragFinished({
|
|
1478
1785
|
nodeId: this.grabbedNodeId,
|
|
1479
|
-
element:
|
|
1480
|
-
x:
|
|
1481
|
-
y:
|
|
1786
|
+
element: e.element,
|
|
1787
|
+
x: e.x,
|
|
1788
|
+
y: e.y
|
|
1482
1789
|
}), this.grabbedNodeId = null, this.removeTouchDragListeners();
|
|
1483
1790
|
}
|
|
1484
1791
|
removeTouchDragListeners() {
|
|
1485
1792
|
this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
|
|
1486
1793
|
}
|
|
1487
1794
|
}
|
|
1488
|
-
const
|
|
1489
|
-
const
|
|
1490
|
-
return (
|
|
1491
|
-
let
|
|
1492
|
-
|
|
1493
|
-
const
|
|
1494
|
-
|
|
1495
|
-
const
|
|
1496
|
-
return
|
|
1795
|
+
const De = (t) => {
|
|
1796
|
+
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;
|
|
1797
|
+
return (d) => {
|
|
1798
|
+
let s = d.nextTransform.x, h = d.nextTransform.y;
|
|
1799
|
+
s < e && s < d.prevTransform.x && (s = Math.min(d.prevTransform.x, e));
|
|
1800
|
+
const c = d.canvasWidth * d.prevTransform.scale, a = r - c;
|
|
1801
|
+
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));
|
|
1802
|
+
const l = d.canvasHeight * d.prevTransform.scale, u = n - l;
|
|
1803
|
+
return h > u && h > d.prevTransform.y && (h = Math.max(d.prevTransform.y, u)), { scale: d.nextTransform.scale, x: s, y: h };
|
|
1497
1804
|
};
|
|
1498
|
-
},
|
|
1499
|
-
const
|
|
1500
|
-
return (
|
|
1501
|
-
const
|
|
1502
|
-
let
|
|
1503
|
-
if (
|
|
1504
|
-
|
|
1505
|
-
const
|
|
1506
|
-
|
|
1805
|
+
}, Le = (t) => {
|
|
1806
|
+
const e = t.maxContentScale, r = t.minContentScale, o = e !== null ? 1 / e : 0, n = r !== null ? 1 / r : 1 / 0;
|
|
1807
|
+
return (d) => {
|
|
1808
|
+
const s = d.prevTransform, h = d.nextTransform;
|
|
1809
|
+
let c = h.scale, a = h.x, l = h.y;
|
|
1810
|
+
if (h.scale > n && h.scale > s.scale) {
|
|
1811
|
+
c = Math.max(s.scale, n), a = s.x, l = s.y;
|
|
1812
|
+
const u = (c - s.scale) / (h.scale - s.scale);
|
|
1813
|
+
a = s.x + (h.x - s.x) * u, l = s.y + (h.y - s.y) * u;
|
|
1507
1814
|
}
|
|
1508
|
-
if (
|
|
1509
|
-
|
|
1510
|
-
const
|
|
1511
|
-
|
|
1815
|
+
if (h.scale < o && h.scale < s.scale) {
|
|
1816
|
+
c = Math.min(s.scale, o), a = s.x, l = s.y;
|
|
1817
|
+
const u = (c - s.scale) / (h.scale - s.scale);
|
|
1818
|
+
a = s.x + (h.x - s.x) * u, l = s.y + (h.y - s.y) * u;
|
|
1512
1819
|
}
|
|
1513
1820
|
return {
|
|
1514
|
-
scale:
|
|
1515
|
-
x:
|
|
1516
|
-
y:
|
|
1821
|
+
scale: c,
|
|
1822
|
+
x: a,
|
|
1823
|
+
y: l
|
|
1517
1824
|
};
|
|
1518
1825
|
};
|
|
1519
|
-
},
|
|
1520
|
-
(
|
|
1521
|
-
prevTransform:
|
|
1522
|
-
nextTransform:
|
|
1523
|
-
canvasWidth:
|
|
1524
|
-
canvasHeight:
|
|
1826
|
+
}, Ue = (t) => (e) => t.reduce(
|
|
1827
|
+
(r, o) => o({
|
|
1828
|
+
prevTransform: e.prevTransform,
|
|
1829
|
+
nextTransform: r,
|
|
1830
|
+
canvasWidth: e.canvasWidth,
|
|
1831
|
+
canvasHeight: e.canvasHeight
|
|
1525
1832
|
}),
|
|
1526
|
-
|
|
1527
|
-
),
|
|
1528
|
-
if (typeof
|
|
1529
|
-
return
|
|
1530
|
-
switch (
|
|
1833
|
+
e.nextTransform
|
|
1834
|
+
), Q = (t) => {
|
|
1835
|
+
if (typeof t == "function")
|
|
1836
|
+
return t;
|
|
1837
|
+
switch (t.type) {
|
|
1531
1838
|
case "scale-limit":
|
|
1532
|
-
return
|
|
1533
|
-
minContentScale:
|
|
1534
|
-
maxContentScale:
|
|
1839
|
+
return Le({
|
|
1840
|
+
minContentScale: t.minContentScale ?? 0,
|
|
1841
|
+
maxContentScale: t.maxContentScale ?? 1 / 0
|
|
1535
1842
|
});
|
|
1536
1843
|
case "shift-limit":
|
|
1537
|
-
return
|
|
1538
|
-
minX:
|
|
1539
|
-
maxX:
|
|
1540
|
-
minY:
|
|
1541
|
-
maxY:
|
|
1844
|
+
return De({
|
|
1845
|
+
minX: t.minX ?? -1 / 0,
|
|
1846
|
+
maxX: t.maxX ?? 1 / 0,
|
|
1847
|
+
minY: t.minY ?? -1 / 0,
|
|
1848
|
+
maxY: t.maxY ?? 1 / 0
|
|
1542
1849
|
});
|
|
1543
1850
|
}
|
|
1544
|
-
},
|
|
1545
|
-
var
|
|
1546
|
-
const
|
|
1547
|
-
let
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
(
|
|
1851
|
+
}, Ve = (t) => {
|
|
1852
|
+
var y, m, E, C, z, P, D, L, K;
|
|
1853
|
+
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;
|
|
1854
|
+
let n;
|
|
1855
|
+
o !== void 0 ? Array.isArray(o) ? n = Ue(
|
|
1856
|
+
o.map(
|
|
1857
|
+
(b) => Q(b)
|
|
1551
1858
|
)
|
|
1552
|
-
) :
|
|
1553
|
-
const
|
|
1554
|
-
}),
|
|
1555
|
-
}),
|
|
1859
|
+
) : n = Q(o) : n = (b) => b.nextTransform;
|
|
1860
|
+
const d = ((m = t == null ? void 0 : t.shift) == null ? void 0 : m.cursor) !== void 0 ? t.shift.cursor : "grab", s = ((E = t == null ? void 0 : t.events) == null ? void 0 : E.onBeforeTransformChange) ?? (() => {
|
|
1861
|
+
}), h = ((C = t == null ? void 0 : t.events) == null ? void 0 : C.onTransformChange) ?? (() => {
|
|
1862
|
+
}), c = (z = t == null ? void 0 : t.shift) == null ? void 0 : z.mouseDownEventVerifier, a = c !== void 0 ? c : (b) => b.button === 0, l = (P = t == null ? void 0 : t.shift) == null ? void 0 : P.mouseUpEventVerifier, u = l !== void 0 ? l : (b) => b.button === 0, f = (D = t == null ? void 0 : t.scale) == null ? void 0 : D.mouseWheelEventVerifier, A = f !== void 0 ? f : () => !0;
|
|
1556
1863
|
return {
|
|
1557
|
-
wheelSensitivity:
|
|
1558
|
-
onTransformStarted: ((
|
|
1864
|
+
wheelSensitivity: r,
|
|
1865
|
+
onTransformStarted: ((L = t == null ? void 0 : t.events) == null ? void 0 : L.onTransformStarted) ?? (() => {
|
|
1559
1866
|
}),
|
|
1560
|
-
onTransformFinished: ((
|
|
1867
|
+
onTransformFinished: ((K = t == null ? void 0 : t.events) == null ? void 0 : K.onTransformFinished) ?? (() => {
|
|
1561
1868
|
}),
|
|
1562
|
-
onBeforeTransformChange:
|
|
1563
|
-
onTransformChange:
|
|
1564
|
-
transformPreprocessor:
|
|
1565
|
-
shiftCursor:
|
|
1566
|
-
mouseDownEventVerifier:
|
|
1567
|
-
mouseUpEventVerifier:
|
|
1568
|
-
mouseWheelEventVerifier:
|
|
1869
|
+
onBeforeTransformChange: s,
|
|
1870
|
+
onTransformChange: h,
|
|
1871
|
+
transformPreprocessor: n,
|
|
1872
|
+
shiftCursor: d,
|
|
1873
|
+
mouseDownEventVerifier: a,
|
|
1874
|
+
mouseUpEventVerifier: u,
|
|
1875
|
+
mouseWheelEventVerifier: A
|
|
1569
1876
|
};
|
|
1570
|
-
},
|
|
1571
|
-
const
|
|
1572
|
-
for (let
|
|
1573
|
-
|
|
1574
|
-
const
|
|
1575
|
-
(
|
|
1877
|
+
}, G = (t) => {
|
|
1878
|
+
const e = [], r = t.touches.length;
|
|
1879
|
+
for (let h = 0; h < r; h++)
|
|
1880
|
+
e.push([t.touches[h].clientX, t.touches[h].clientY]);
|
|
1881
|
+
const o = e.reduce(
|
|
1882
|
+
(h, c) => [h[0] + c[0], h[1] + c[1]],
|
|
1576
1883
|
[0, 0]
|
|
1577
|
-
),
|
|
1578
|
-
(
|
|
1884
|
+
), n = [o[0] / r, o[1] / r], s = e.map((h) => [h[0] - n[0], h[1] - n[1]]).reduce(
|
|
1885
|
+
(h, c) => h + Math.sqrt(c[0] * c[0] + c[1] * c[1]),
|
|
1579
1886
|
0
|
|
1580
1887
|
);
|
|
1581
1888
|
return {
|
|
1582
|
-
x:
|
|
1583
|
-
y:
|
|
1584
|
-
scale:
|
|
1585
|
-
touchesCnt:
|
|
1586
|
-
touches:
|
|
1889
|
+
x: n[0],
|
|
1890
|
+
y: n[1],
|
|
1891
|
+
scale: s / r,
|
|
1892
|
+
touchesCnt: r,
|
|
1893
|
+
touches: e
|
|
1587
1894
|
};
|
|
1588
|
-
},
|
|
1589
|
-
scale:
|
|
1590
|
-
x:
|
|
1591
|
-
y:
|
|
1592
|
-
}),
|
|
1593
|
-
scale:
|
|
1594
|
-
x:
|
|
1595
|
-
y:
|
|
1895
|
+
}, $e = (t, e, r) => ({
|
|
1896
|
+
scale: t.scale,
|
|
1897
|
+
x: t.x + t.scale * e,
|
|
1898
|
+
y: t.y + t.scale * r
|
|
1899
|
+
}), Ie = (t, e, r, o) => ({
|
|
1900
|
+
scale: t.scale * e,
|
|
1901
|
+
x: t.scale * (1 - e) * r + t.x,
|
|
1902
|
+
y: t.scale * (1 - e) * o + t.y
|
|
1596
1903
|
});
|
|
1597
|
-
class
|
|
1598
|
-
constructor(
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
this.element === null || !this.options.mouseDownEventVerifier(
|
|
1904
|
+
class We {
|
|
1905
|
+
constructor(e, r) {
|
|
1906
|
+
i(this, "model");
|
|
1907
|
+
i(this, "transformation");
|
|
1908
|
+
i(this, "element", null);
|
|
1909
|
+
i(this, "prevTouches", null);
|
|
1910
|
+
i(this, "window", window);
|
|
1911
|
+
i(this, "onMouseDown", (e) => {
|
|
1912
|
+
this.element === null || !this.options.mouseDownEventVerifier(e) || (F(this.element, this.options.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.options.onTransformStarted());
|
|
1606
1913
|
});
|
|
1607
|
-
|
|
1608
|
-
if (this.element === null || !
|
|
1914
|
+
i(this, "onWindowMouseMove", (e) => {
|
|
1915
|
+
if (this.element === null || !W(this.element, e.clientX, e.clientY) || !R(this.window, e.clientX, e.clientY)) {
|
|
1609
1916
|
this.stopMouseDrag();
|
|
1610
1917
|
return;
|
|
1611
1918
|
}
|
|
1612
|
-
const
|
|
1613
|
-
this.moveViewport(this.element,
|
|
1919
|
+
const r = -e.movementX, o = -e.movementY;
|
|
1920
|
+
this.moveViewport(this.element, r, o);
|
|
1614
1921
|
});
|
|
1615
|
-
|
|
1616
|
-
this.element === null || !this.options.mouseUpEventVerifier(
|
|
1922
|
+
i(this, "onWindowMouseUp", (e) => {
|
|
1923
|
+
this.element === null || !this.options.mouseUpEventVerifier(e) || this.stopMouseDrag();
|
|
1617
1924
|
});
|
|
1618
|
-
|
|
1619
|
-
if (!this.options.mouseWheelEventVerifier(
|
|
1925
|
+
i(this, "onWheelScroll", (e) => {
|
|
1926
|
+
if (!this.options.mouseWheelEventVerifier(e))
|
|
1620
1927
|
return;
|
|
1621
|
-
|
|
1622
|
-
const { left:
|
|
1623
|
-
this.scaleViewport(this.element,
|
|
1928
|
+
e.preventDefault(), this.options.onTransformStarted();
|
|
1929
|
+
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);
|
|
1930
|
+
this.scaleViewport(this.element, h, n, d), this.options.onTransformFinished();
|
|
1624
1931
|
});
|
|
1625
|
-
|
|
1626
|
-
this.prevTouches =
|
|
1932
|
+
i(this, "onTouchStart", (e) => {
|
|
1933
|
+
this.prevTouches = G(e), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish), this.options.onTransformStarted();
|
|
1627
1934
|
});
|
|
1628
|
-
|
|
1629
|
-
const
|
|
1630
|
-
if (
|
|
1935
|
+
i(this, "onWindowTouchMove", (e) => {
|
|
1936
|
+
const r = this.element;
|
|
1937
|
+
if (r === null)
|
|
1631
1938
|
return;
|
|
1632
|
-
const
|
|
1633
|
-
if (!
|
|
1634
|
-
(
|
|
1939
|
+
const o = G(e);
|
|
1940
|
+
if (!o.touches.every(
|
|
1941
|
+
(d) => W(r, d[0], d[1]) && R(this.window, d[0], d[1])
|
|
1635
1942
|
)) {
|
|
1636
1943
|
this.stopTouchDrag();
|
|
1637
1944
|
return;
|
|
1638
1945
|
}
|
|
1639
|
-
if ((
|
|
1640
|
-
|
|
1641
|
-
-(
|
|
1642
|
-
-(
|
|
1643
|
-
),
|
|
1644
|
-
const { left:
|
|
1645
|
-
this.scaleViewport(
|
|
1946
|
+
if ((o.touchesCnt === 1 || o.touchesCnt === 2) && this.moveViewport(
|
|
1947
|
+
r,
|
|
1948
|
+
-(o.x - this.prevTouches.x),
|
|
1949
|
+
-(o.y - this.prevTouches.y)
|
|
1950
|
+
), o.touchesCnt === 2) {
|
|
1951
|
+
const { left: d, top: s } = r.getBoundingClientRect(), h = this.prevTouches.x - d, c = this.prevTouches.y - s, l = 1 / (o.scale / this.prevTouches.scale);
|
|
1952
|
+
this.scaleViewport(r, l, h, c);
|
|
1646
1953
|
}
|
|
1647
|
-
this.prevTouches =
|
|
1954
|
+
this.prevTouches = o;
|
|
1648
1955
|
});
|
|
1649
|
-
|
|
1650
|
-
|
|
1956
|
+
i(this, "onWindowTouchFinish", (e) => {
|
|
1957
|
+
e.touches.length > 0 ? this.prevTouches = G(e) : this.stopTouchDrag();
|
|
1651
1958
|
});
|
|
1652
|
-
|
|
1653
|
-
const
|
|
1654
|
-
prevTransform:
|
|
1655
|
-
nextTransform:
|
|
1656
|
-
canvasWidth:
|
|
1657
|
-
canvasHeight:
|
|
1959
|
+
i(this, "observer", new ResizeObserver(() => {
|
|
1960
|
+
const e = this.canvas.transformation.getViewportMatrix(), { width: r, height: o } = this.element.getBoundingClientRect(), n = this.options.transformPreprocessor({
|
|
1961
|
+
prevTransform: e,
|
|
1962
|
+
nextTransform: e,
|
|
1963
|
+
canvasWidth: r,
|
|
1964
|
+
canvasHeight: o
|
|
1658
1965
|
});
|
|
1659
|
-
this.canvas.patchViewportMatrix(
|
|
1966
|
+
this.canvas.patchViewportMatrix(n), this.options.onTransformChange();
|
|
1660
1967
|
}));
|
|
1661
|
-
|
|
1662
|
-
this.canvas =
|
|
1968
|
+
i(this, "options");
|
|
1969
|
+
this.canvas = e, this.options = Ve(r), this.transformation = this.canvas.transformation, this.model = this.canvas.model;
|
|
1663
1970
|
}
|
|
1664
|
-
attach(
|
|
1665
|
-
return this.detach(), this.element =
|
|
1971
|
+
attach(e) {
|
|
1972
|
+
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;
|
|
1666
1973
|
}
|
|
1667
1974
|
detach() {
|
|
1668
1975
|
return this.canvas.detach(), this.element !== null && (this.observer.unobserve(this.element), this.element.removeEventListener("mousedown", this.onMouseDown), this.element.removeEventListener("wheel", this.onWheelScroll), this.element.removeEventListener("touchstart", this.onTouchStart), this.element = null), this;
|
|
1669
1976
|
}
|
|
1670
|
-
addNode(
|
|
1671
|
-
return this.canvas.addNode(
|
|
1977
|
+
addNode(e) {
|
|
1978
|
+
return this.canvas.addNode(e), this;
|
|
1672
1979
|
}
|
|
1673
|
-
updateNode(
|
|
1674
|
-
return this.canvas.updateNode(
|
|
1980
|
+
updateNode(e, r) {
|
|
1981
|
+
return this.canvas.updateNode(e, r), this;
|
|
1675
1982
|
}
|
|
1676
|
-
removeNode(
|
|
1677
|
-
return this.canvas.removeNode(
|
|
1983
|
+
removeNode(e) {
|
|
1984
|
+
return this.canvas.removeNode(e), this;
|
|
1678
1985
|
}
|
|
1679
|
-
markPort(
|
|
1680
|
-
return this.canvas.markPort(
|
|
1986
|
+
markPort(e) {
|
|
1987
|
+
return this.canvas.markPort(e), this;
|
|
1681
1988
|
}
|
|
1682
|
-
updatePort(
|
|
1683
|
-
return this.canvas.updatePort(
|
|
1989
|
+
updatePort(e, r) {
|
|
1990
|
+
return this.canvas.updatePort(e, r), this;
|
|
1684
1991
|
}
|
|
1685
|
-
unmarkPort(
|
|
1686
|
-
return this.canvas.unmarkPort(
|
|
1992
|
+
unmarkPort(e) {
|
|
1993
|
+
return this.canvas.unmarkPort(e), this;
|
|
1687
1994
|
}
|
|
1688
|
-
addEdge(
|
|
1689
|
-
return this.canvas.addEdge(
|
|
1995
|
+
addEdge(e) {
|
|
1996
|
+
return this.canvas.addEdge(e), this;
|
|
1690
1997
|
}
|
|
1691
|
-
updateEdge(
|
|
1692
|
-
return this.canvas.updateEdge(
|
|
1998
|
+
updateEdge(e, r) {
|
|
1999
|
+
return this.canvas.updateEdge(e, r), this;
|
|
1693
2000
|
}
|
|
1694
|
-
removeEdge(
|
|
1695
|
-
return this.canvas.removeEdge(
|
|
2001
|
+
removeEdge(e) {
|
|
2002
|
+
return this.canvas.removeEdge(e), this;
|
|
1696
2003
|
}
|
|
1697
|
-
patchViewportMatrix(
|
|
1698
|
-
return this.canvas.patchViewportMatrix(
|
|
2004
|
+
patchViewportMatrix(e) {
|
|
2005
|
+
return this.canvas.patchViewportMatrix(e), this;
|
|
1699
2006
|
}
|
|
1700
|
-
patchContentMatrix(
|
|
1701
|
-
return this.canvas.patchContentMatrix(
|
|
2007
|
+
patchContentMatrix(e) {
|
|
2008
|
+
return this.canvas.patchContentMatrix(e), this;
|
|
1702
2009
|
}
|
|
1703
2010
|
clear() {
|
|
1704
2011
|
return this.canvas.clear(), this;
|
|
@@ -1706,28 +2013,28 @@ class It {
|
|
|
1706
2013
|
destroy() {
|
|
1707
2014
|
this.detach(), this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.canvas.destroy();
|
|
1708
2015
|
}
|
|
1709
|
-
moveViewport(
|
|
2016
|
+
moveViewport(e, r, o) {
|
|
1710
2017
|
this.options.onBeforeTransformChange();
|
|
1711
|
-
const
|
|
1712
|
-
prevTransform:
|
|
1713
|
-
nextTransform:
|
|
1714
|
-
canvasWidth:
|
|
1715
|
-
canvasHeight:
|
|
2018
|
+
const n = this.transformation.getViewportMatrix(), d = $e(n, r, o), { width: s, height: h } = e.getBoundingClientRect(), c = this.options.transformPreprocessor({
|
|
2019
|
+
prevTransform: n,
|
|
2020
|
+
nextTransform: d,
|
|
2021
|
+
canvasWidth: s,
|
|
2022
|
+
canvasHeight: h
|
|
1716
2023
|
});
|
|
1717
|
-
this.canvas.patchViewportMatrix(
|
|
2024
|
+
this.canvas.patchViewportMatrix(c), this.options.onTransformChange();
|
|
1718
2025
|
}
|
|
1719
|
-
scaleViewport(
|
|
2026
|
+
scaleViewport(e, r, o, n) {
|
|
1720
2027
|
this.options.onBeforeTransformChange();
|
|
1721
|
-
const
|
|
1722
|
-
prevTransform:
|
|
1723
|
-
nextTransform:
|
|
1724
|
-
canvasWidth:
|
|
1725
|
-
canvasHeight:
|
|
2028
|
+
const d = this.canvas.transformation.getViewportMatrix(), s = Ie(d, r, o, n), { width: h, height: c } = e.getBoundingClientRect(), a = this.options.transformPreprocessor({
|
|
2029
|
+
prevTransform: d,
|
|
2030
|
+
nextTransform: s,
|
|
2031
|
+
canvasWidth: h,
|
|
2032
|
+
canvasHeight: c
|
|
1726
2033
|
});
|
|
1727
|
-
this.canvas.patchViewportMatrix(
|
|
2034
|
+
this.canvas.patchViewportMatrix(a), this.options.onTransformChange();
|
|
1728
2035
|
}
|
|
1729
2036
|
stopMouseDrag() {
|
|
1730
|
-
this.element !== null &&
|
|
2037
|
+
this.element !== null && F(this.element, null), this.removeMouseDragListeners(), this.options.onTransformFinished();
|
|
1731
2038
|
}
|
|
1732
2039
|
removeMouseDragListeners() {
|
|
1733
2040
|
this.window.removeEventListener("mousemove", this.onWindowMouseMove), this.window.removeEventListener("mouseup", this.onWindowMouseUp);
|
|
@@ -1739,103 +2046,103 @@ class It {
|
|
|
1739
2046
|
this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
|
|
1740
2047
|
}
|
|
1741
2048
|
}
|
|
1742
|
-
class
|
|
2049
|
+
class Re {
|
|
1743
2050
|
constructor() {
|
|
1744
|
-
|
|
1745
|
-
|
|
2051
|
+
i(this, "keyMap", /* @__PURE__ */ new Map());
|
|
2052
|
+
i(this, "valueMap", /* @__PURE__ */ new Map());
|
|
1746
2053
|
}
|
|
1747
|
-
set(
|
|
1748
|
-
this.keyMap.set(
|
|
2054
|
+
set(e, r) {
|
|
2055
|
+
this.keyMap.set(e, r), this.valueMap.set(r, e);
|
|
1749
2056
|
}
|
|
1750
|
-
hasKey(
|
|
1751
|
-
return this.keyMap.has(
|
|
2057
|
+
hasKey(e) {
|
|
2058
|
+
return this.keyMap.has(e);
|
|
1752
2059
|
}
|
|
1753
|
-
hasValue(
|
|
1754
|
-
return this.valueMap.has(
|
|
2060
|
+
hasValue(e) {
|
|
2061
|
+
return this.valueMap.has(e);
|
|
1755
2062
|
}
|
|
1756
|
-
getByKey(
|
|
1757
|
-
return this.keyMap.get(
|
|
2063
|
+
getByKey(e) {
|
|
2064
|
+
return this.keyMap.get(e);
|
|
1758
2065
|
}
|
|
1759
|
-
getByValue(
|
|
1760
|
-
return this.valueMap.get(
|
|
2066
|
+
getByValue(e) {
|
|
2067
|
+
return this.valueMap.get(e);
|
|
1761
2068
|
}
|
|
1762
|
-
deleteByKey(
|
|
1763
|
-
const
|
|
1764
|
-
|
|
2069
|
+
deleteByKey(e) {
|
|
2070
|
+
const r = this.keyMap.get(e);
|
|
2071
|
+
r !== void 0 && this.valueMap.delete(r), this.keyMap.delete(e);
|
|
1765
2072
|
}
|
|
1766
|
-
deleteByValue(
|
|
1767
|
-
const
|
|
1768
|
-
|
|
2073
|
+
deleteByValue(e) {
|
|
2074
|
+
const r = this.valueMap.get(e);
|
|
2075
|
+
r !== void 0 && this.keyMap.delete(r), this.valueMap.delete(e);
|
|
1769
2076
|
}
|
|
1770
|
-
forEach(
|
|
1771
|
-
this.keyMap.forEach((
|
|
1772
|
-
|
|
2077
|
+
forEach(e) {
|
|
2078
|
+
this.keyMap.forEach((r, o) => {
|
|
2079
|
+
e(r, o);
|
|
1773
2080
|
});
|
|
1774
2081
|
}
|
|
1775
2082
|
clear() {
|
|
1776
2083
|
this.keyMap.clear(), this.valueMap.clear();
|
|
1777
2084
|
}
|
|
1778
2085
|
}
|
|
1779
|
-
class
|
|
1780
|
-
constructor(
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
(
|
|
2086
|
+
class Fe {
|
|
2087
|
+
constructor(e) {
|
|
2088
|
+
i(this, "transformation");
|
|
2089
|
+
i(this, "model");
|
|
2090
|
+
i(this, "nodes", new Re());
|
|
2091
|
+
i(this, "nodeIdGenerator", new U(
|
|
2092
|
+
(e) => this.nodes.hasKey(e)
|
|
1786
2093
|
));
|
|
1787
|
-
|
|
1788
|
-
this.canvas =
|
|
1789
|
-
|
|
1790
|
-
const
|
|
1791
|
-
this.
|
|
2094
|
+
i(this, "nodesResizeObserver");
|
|
2095
|
+
this.canvas = e, this.nodesResizeObserver = new window.ResizeObserver((r) => {
|
|
2096
|
+
r.forEach((o) => {
|
|
2097
|
+
const n = o.target;
|
|
2098
|
+
this.handleNodeResize(n);
|
|
1792
2099
|
});
|
|
1793
2100
|
}), this.transformation = this.canvas.transformation, this.model = this.canvas.model;
|
|
1794
2101
|
}
|
|
1795
|
-
attach(
|
|
1796
|
-
return this.canvas.attach(
|
|
2102
|
+
attach(e) {
|
|
2103
|
+
return this.canvas.attach(e), this;
|
|
1797
2104
|
}
|
|
1798
2105
|
detach() {
|
|
1799
2106
|
return this.canvas.detach(), this;
|
|
1800
2107
|
}
|
|
1801
|
-
addNode(
|
|
1802
|
-
const
|
|
2108
|
+
addNode(e) {
|
|
2109
|
+
const r = this.nodeIdGenerator.create(e.id);
|
|
1803
2110
|
return this.canvas.addNode({
|
|
1804
|
-
...
|
|
1805
|
-
id:
|
|
1806
|
-
}), this.nodes.set(
|
|
2111
|
+
...e,
|
|
2112
|
+
id: r
|
|
2113
|
+
}), this.nodes.set(r, e.element), this.nodesResizeObserver.observe(e.element), this;
|
|
1807
2114
|
}
|
|
1808
|
-
updateNode(
|
|
1809
|
-
return this.canvas.updateNode(
|
|
2115
|
+
updateNode(e, r) {
|
|
2116
|
+
return this.canvas.updateNode(e, r), this;
|
|
1810
2117
|
}
|
|
1811
|
-
removeNode(
|
|
1812
|
-
this.canvas.removeNode(
|
|
1813
|
-
const
|
|
1814
|
-
return this.nodes.deleteByKey(
|
|
2118
|
+
removeNode(e) {
|
|
2119
|
+
this.canvas.removeNode(e);
|
|
2120
|
+
const r = this.nodes.getByKey(e);
|
|
2121
|
+
return this.nodes.deleteByKey(e), this.nodesResizeObserver.unobserve(r), this;
|
|
1815
2122
|
}
|
|
1816
|
-
markPort(
|
|
1817
|
-
return this.canvas.markPort(
|
|
2123
|
+
markPort(e) {
|
|
2124
|
+
return this.canvas.markPort(e), this;
|
|
1818
2125
|
}
|
|
1819
|
-
updatePort(
|
|
1820
|
-
return this.canvas.updatePort(
|
|
2126
|
+
updatePort(e, r) {
|
|
2127
|
+
return this.canvas.updatePort(e, r), this;
|
|
1821
2128
|
}
|
|
1822
|
-
unmarkPort(
|
|
1823
|
-
return this.canvas.unmarkPort(
|
|
2129
|
+
unmarkPort(e) {
|
|
2130
|
+
return this.canvas.unmarkPort(e), this;
|
|
1824
2131
|
}
|
|
1825
|
-
addEdge(
|
|
1826
|
-
return this.canvas.addEdge(
|
|
2132
|
+
addEdge(e) {
|
|
2133
|
+
return this.canvas.addEdge(e), this;
|
|
1827
2134
|
}
|
|
1828
|
-
updateEdge(
|
|
1829
|
-
return this.canvas.updateEdge(
|
|
2135
|
+
updateEdge(e, r) {
|
|
2136
|
+
return this.canvas.updateEdge(e, r), this;
|
|
1830
2137
|
}
|
|
1831
|
-
removeEdge(
|
|
1832
|
-
return this.canvas.removeEdge(
|
|
2138
|
+
removeEdge(e) {
|
|
2139
|
+
return this.canvas.removeEdge(e), this;
|
|
1833
2140
|
}
|
|
1834
|
-
patchViewportMatrix(
|
|
1835
|
-
return this.canvas.patchViewportMatrix(
|
|
2141
|
+
patchViewportMatrix(e) {
|
|
2142
|
+
return this.canvas.patchViewportMatrix(e), this;
|
|
1836
2143
|
}
|
|
1837
|
-
patchContentMatrix(
|
|
1838
|
-
return this.canvas.patchContentMatrix(
|
|
2144
|
+
patchContentMatrix(e) {
|
|
2145
|
+
return this.canvas.patchContentMatrix(e), this;
|
|
1839
2146
|
}
|
|
1840
2147
|
clear() {
|
|
1841
2148
|
return this.canvas.clear(), this.nodesResizeObserver.disconnect(), this.nodes.clear(), this;
|
|
@@ -1843,48 +2150,61 @@ class Vt {
|
|
|
1843
2150
|
destroy() {
|
|
1844
2151
|
this.clear(), this.canvas.destroy();
|
|
1845
2152
|
}
|
|
1846
|
-
|
|
1847
|
-
const
|
|
1848
|
-
this.canvas.updateNode(
|
|
1849
|
-
this.canvas.updateEdge(
|
|
2153
|
+
handleNodeResize(e) {
|
|
2154
|
+
const r = this.nodes.getByValue(e);
|
|
2155
|
+
this.canvas.updateNode(r), this.model.getNodeAdjacentEdgeIds(r).forEach((n) => {
|
|
2156
|
+
this.canvas.updateEdge(n);
|
|
1850
2157
|
});
|
|
1851
2158
|
}
|
|
1852
2159
|
}
|
|
1853
|
-
class
|
|
2160
|
+
class Ye {
|
|
1854
2161
|
constructor() {
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
2162
|
+
i(this, "coreOptions", {});
|
|
2163
|
+
i(this, "dragOptions");
|
|
2164
|
+
i(this, "transformOptions");
|
|
2165
|
+
i(this, "hasDraggableNode", !1);
|
|
2166
|
+
i(this, "hasTransformableViewport", !1);
|
|
2167
|
+
i(this, "hasResizeReactiveNodes", !1);
|
|
1861
2168
|
}
|
|
1862
|
-
setOptions(
|
|
1863
|
-
return this.coreOptions =
|
|
2169
|
+
setOptions(e) {
|
|
2170
|
+
return this.coreOptions = e, this;
|
|
1864
2171
|
}
|
|
1865
|
-
setUserDraggableNodes(
|
|
1866
|
-
return this.
|
|
2172
|
+
setUserDraggableNodes(e) {
|
|
2173
|
+
return this.hasDraggableNode = !0, this.dragOptions = e, this;
|
|
1867
2174
|
}
|
|
1868
|
-
|
|
1869
|
-
|
|
2175
|
+
/**
|
|
2176
|
+
* @deprecated
|
|
2177
|
+
* use setUserTransformableViewport instead
|
|
2178
|
+
*/
|
|
2179
|
+
setUserTransformableCanvas(e) {
|
|
2180
|
+
return this.setUserTransformableViewport(e);
|
|
2181
|
+
}
|
|
2182
|
+
setUserTransformableViewport(e) {
|
|
2183
|
+
return this.hasTransformableViewport = !0, this.transformOptions = e, this;
|
|
1870
2184
|
}
|
|
1871
2185
|
setResizeReactiveNodes() {
|
|
1872
2186
|
return this.hasResizeReactiveNodes = !0, this;
|
|
1873
2187
|
}
|
|
1874
2188
|
build() {
|
|
1875
|
-
|
|
1876
|
-
|
|
2189
|
+
const e = new be(this.coreOptions);
|
|
2190
|
+
let r = new Ce(e);
|
|
2191
|
+
return this.hasResizeReactiveNodes && (r = new Fe(r)), this.hasDraggableNode && (r = new Pe(r, this.dragOptions)), this.hasTransformableViewport && (r = new We(
|
|
2192
|
+
r,
|
|
2193
|
+
this.transformOptions
|
|
2194
|
+
)), r;
|
|
1877
2195
|
}
|
|
1878
2196
|
}
|
|
1879
2197
|
export {
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
2198
|
+
q as BezierEdgeShape,
|
|
2199
|
+
Ye as CanvasBuilder,
|
|
2200
|
+
ke as CanvasCore,
|
|
2201
|
+
O as HorizontalEdgeShape,
|
|
2202
|
+
Ye as HtmlGraphBuilder,
|
|
2203
|
+
x as HtmlGraphError,
|
|
2204
|
+
Fe as ResizeReactiveNodesCanvas,
|
|
2205
|
+
ee as StraightEdgeShape,
|
|
2206
|
+
Pe as UserDraggableNodesCanvas,
|
|
2207
|
+
We as UserTransformableCanvas,
|
|
2208
|
+
We as UserTransformableViewportCanvas,
|
|
2209
|
+
te as VerticalEdgeShape
|
|
1890
2210
|
};
|