@html-graph/html-graph 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -13
- package/dist/main.d.ts +4 -2
- package/dist/main.js +446 -419
- package/dist/main.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
var
|
|
2
|
-
var K = (e, t, o) => t in e ?
|
|
3
|
-
var
|
|
1
|
+
var O = Object.defineProperty;
|
|
2
|
+
var K = (e, t, o) => t in e ? O(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o;
|
|
3
|
+
var n = (e, t, o) => K(e, typeof t != "symbol" ? t + "" : t, o);
|
|
4
4
|
const _ = (e, t) => ({
|
|
5
5
|
x: e / 2,
|
|
6
6
|
y: t / 2
|
|
7
7
|
}), f = (e, t, o) => ({
|
|
8
8
|
x: t.x * e.x - t.y * e.y + ((1 - t.x) * o.x + t.y * o.y),
|
|
9
9
|
y: t.y * e.x + t.x * e.y + ((1 - t.x) * o.y - t.y * o.x)
|
|
10
|
-
}), A = (e, t, o) => ({ x: t * Math.cos(e), y: o * Math.sin(e) }),
|
|
10
|
+
}), A = (e, t, o) => ({ x: t * Math.cos(e), y: o * Math.sin(e) }), w = {
|
|
11
11
|
x: 0,
|
|
12
12
|
y: 0
|
|
13
13
|
}, E = (e, t, o, r) => {
|
|
14
|
-
const
|
|
15
|
-
|
|
14
|
+
const s = [
|
|
15
|
+
w,
|
|
16
16
|
{ x: o, y: r },
|
|
17
17
|
{ x: o, y: -r }
|
|
18
|
-
].map((l) => f(l, e,
|
|
19
|
-
return `${
|
|
20
|
-
},
|
|
18
|
+
].map((l) => f(l, e, w)).map((l) => ({ x: l.x + t.x, y: l.y + t.y })), h = `M ${s[0].x} ${s[0].y}`, d = `L ${s[1].x} ${s[1].y}`, c = `L ${s[2].x} ${s[2].y}`;
|
|
19
|
+
return `${h} ${d} ${c}`;
|
|
20
|
+
}, C = (e, t) => {
|
|
21
21
|
const o = [];
|
|
22
22
|
if (e.length > 0 && o.push(`M ${e[0].x} ${e[0].y}`), e.length === 2 && o.push(`L ${e[1].x} ${e[1].y}`), e.length > 2) {
|
|
23
23
|
const r = e.length - 1;
|
|
24
|
-
let i = 0,
|
|
25
|
-
e.forEach((
|
|
26
|
-
let l = 0, a = 0,
|
|
27
|
-
const y =
|
|
28
|
-
if (y && (l = -i, a = -
|
|
29
|
-
const z = e[
|
|
30
|
-
i = z.x -
|
|
24
|
+
let i = 0, s = 0, h = 0;
|
|
25
|
+
e.forEach((d, c) => {
|
|
26
|
+
let l = 0, a = 0, g = 0;
|
|
27
|
+
const y = c > 0, x = c < r, v = y && x;
|
|
28
|
+
if (y && (l = -i, a = -s, g = h), x) {
|
|
29
|
+
const z = e[c + 1];
|
|
30
|
+
i = z.x - d.x, s = z.y - d.y, h = Math.sqrt(i * i + s * s);
|
|
31
31
|
}
|
|
32
|
-
const M =
|
|
33
|
-
|
|
34
|
-
`C ${
|
|
32
|
+
const M = h !== 0 ? Math.min((v ? t : 0) / h, c < r - 1 ? 0.5 : 1) : 0, X = v ? { x: d.x + i * M, y: d.y + s * M } : d, k = g !== 0 ? Math.min((v ? t : 0) / g, c > 1 ? 0.5 : 1) : 0, B = v ? { x: d.x + l * k, y: d.y + a * k } : d;
|
|
33
|
+
c > 0 && o.push(`L ${B.x} ${B.y}`), v && o.push(
|
|
34
|
+
`C ${d.x} ${d.y} ${d.x} ${d.y} ${X.x} ${X.y}`
|
|
35
35
|
);
|
|
36
36
|
});
|
|
37
37
|
}
|
|
@@ -48,27 +48,27 @@ const _ = (e, t) => ({
|
|
|
48
48
|
}, T = (e) => {
|
|
49
49
|
const t = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
50
50
|
return t.setAttribute("fill", e), t;
|
|
51
|
-
},
|
|
51
|
+
}, b = (e, t) => {
|
|
52
52
|
const o = {
|
|
53
53
|
x: e.x + e.width / 2,
|
|
54
54
|
y: e.y + e.height / 2
|
|
55
55
|
}, r = {
|
|
56
56
|
x: t.x + t.width / 2,
|
|
57
57
|
y: t.y + t.height / 2
|
|
58
|
-
}, i = Math.min(o.x, r.x),
|
|
58
|
+
}, i = Math.min(o.x, r.x), s = Math.min(o.y, r.y), h = Math.abs(r.x - o.x), d = Math.abs(r.y - o.y), c = o.x <= r.x ? 1 : -1, l = o.y <= r.y ? 1 : -1;
|
|
59
59
|
return {
|
|
60
60
|
x: i,
|
|
61
|
-
y:
|
|
62
|
-
width:
|
|
63
|
-
height:
|
|
64
|
-
flipX:
|
|
61
|
+
y: s,
|
|
62
|
+
width: h,
|
|
63
|
+
height: d,
|
|
64
|
+
flipX: c,
|
|
65
65
|
flipY: l
|
|
66
66
|
};
|
|
67
67
|
}, J = (e) => {
|
|
68
68
|
const t = f(
|
|
69
|
-
{ x: e.arrowLength, y:
|
|
69
|
+
{ x: e.arrowLength, y: w.y },
|
|
70
70
|
e.fromVect,
|
|
71
|
-
|
|
71
|
+
w
|
|
72
72
|
), o = f(
|
|
73
73
|
{ x: e.to.x - e.arrowLength, y: e.to.y },
|
|
74
74
|
e.toVect,
|
|
@@ -79,157 +79,157 @@ const _ = (e, t) => ({
|
|
|
79
79
|
}, i = {
|
|
80
80
|
x: o.x - e.toVect.x * e.curvature,
|
|
81
81
|
y: o.y - e.toVect.y * e.curvature
|
|
82
|
-
},
|
|
83
|
-
return `${
|
|
82
|
+
}, s = `M ${t.x} ${t.y} C ${r.x} ${r.y}, ${i.x} ${i.y}, ${o.x} ${o.y}`, h = e.hasSourceArrow ? "" : `M ${w.x} ${w.y} L ${t.x} ${t.y} `, d = e.hasTargetArrow ? "" : ` M ${o.x} ${o.y} L ${e.to.x} ${e.to.y}`;
|
|
83
|
+
return `${h}${s}${d}`;
|
|
84
84
|
}, Q = (e) => {
|
|
85
85
|
const t = e.hasSourceArrow ? f(
|
|
86
|
-
{ x: e.arrowLength, y:
|
|
86
|
+
{ x: e.arrowLength, y: w.y },
|
|
87
87
|
e.fromVect,
|
|
88
|
-
|
|
89
|
-
) :
|
|
88
|
+
w
|
|
89
|
+
) : w, o = e.hasTargetArrow ? f(
|
|
90
90
|
{ x: e.to.x - e.arrowLength, y: e.to.y },
|
|
91
91
|
e.toVect,
|
|
92
92
|
e.to
|
|
93
|
-
) : e.to, r = e.arrowLength, i = Math.cos(e.detourDirection) * e.detourDistance,
|
|
94
|
-
{ x: r, y:
|
|
93
|
+
) : e.to, r = e.arrowLength, i = Math.cos(e.detourDirection) * e.detourDistance, s = Math.sin(e.detourDirection) * e.detourDistance, h = i * e.flipX, d = s * e.flipY, c = f(
|
|
94
|
+
{ x: r, y: w.y },
|
|
95
95
|
e.fromVect,
|
|
96
|
-
|
|
96
|
+
w
|
|
97
97
|
), l = {
|
|
98
|
-
x:
|
|
99
|
-
y:
|
|
98
|
+
x: c.x + h,
|
|
99
|
+
y: c.y + d
|
|
100
100
|
}, a = f(
|
|
101
101
|
{ x: e.to.x - r, y: e.to.y },
|
|
102
102
|
e.toVect,
|
|
103
103
|
e.to
|
|
104
|
-
),
|
|
105
|
-
x: a.x +
|
|
106
|
-
y: a.y +
|
|
107
|
-
}, y = { x: (l.x +
|
|
108
|
-
x:
|
|
109
|
-
y:
|
|
104
|
+
), g = {
|
|
105
|
+
x: a.x + h,
|
|
106
|
+
y: a.y + d
|
|
107
|
+
}, y = { x: (l.x + g.x) / 2, y: (l.y + g.y) / 2 }, x = {
|
|
108
|
+
x: c.x + e.curvature * e.fromVect.x,
|
|
109
|
+
y: c.y + e.curvature * e.fromVect.y
|
|
110
110
|
}, v = {
|
|
111
111
|
x: a.x - e.curvature * e.toVect.x,
|
|
112
112
|
y: a.y - e.curvature * e.toVect.y
|
|
113
|
-
},
|
|
114
|
-
x:
|
|
115
|
-
y:
|
|
113
|
+
}, p = {
|
|
114
|
+
x: c.x + h,
|
|
115
|
+
y: c.y + d
|
|
116
116
|
}, M = {
|
|
117
|
-
x: a.x +
|
|
118
|
-
y: a.y +
|
|
117
|
+
x: a.x + h,
|
|
118
|
+
y: a.y + d
|
|
119
119
|
};
|
|
120
120
|
return [
|
|
121
121
|
`M ${t.x} ${t.y}`,
|
|
122
|
-
`L ${
|
|
123
|
-
`C ${x.x} ${x.y} ${
|
|
122
|
+
`L ${c.x} ${c.y}`,
|
|
123
|
+
`C ${x.x} ${x.y} ${p.x} ${p.y} ${y.x} ${y.y}`,
|
|
124
124
|
`C ${M.x} ${M.y} ${v.x} ${v.y} ${a.x} ${a.y}`,
|
|
125
125
|
`L ${o.x} ${o.y}`
|
|
126
126
|
].join(" ");
|
|
127
127
|
}, Z = (e) => {
|
|
128
128
|
const t = e.hasSourceArrow ? f(
|
|
129
|
-
{ x: e.arrowLength, y:
|
|
129
|
+
{ x: e.arrowLength, y: w.y },
|
|
130
130
|
e.fromVect,
|
|
131
|
-
|
|
132
|
-
) :
|
|
131
|
+
w
|
|
132
|
+
) : w, o = e.hasTargetArrow ? f(
|
|
133
133
|
{ x: e.to.x - e.arrowLength, y: e.to.y },
|
|
134
134
|
e.toVect,
|
|
135
135
|
e.to
|
|
136
|
-
) : e.to, r = e.arrowLength + e.arrowOffset, i = r - e.roundness,
|
|
136
|
+
) : e.to, r = e.arrowLength + e.arrowOffset, i = r - e.roundness, s = f({ x: i, y: w.y }, e.fromVect, w), h = f(
|
|
137
137
|
{ x: e.to.x - i, y: e.to.y },
|
|
138
138
|
e.toVect,
|
|
139
139
|
e.to
|
|
140
|
-
),
|
|
141
|
-
x: e.flipX > 0 ? e.to.x -
|
|
142
|
-
y:
|
|
143
|
-
}, y = { x:
|
|
144
|
-
return
|
|
145
|
-
[t,
|
|
140
|
+
), d = Math.max((s.x + h.x) / 2, r), c = e.to.y / 2, l = { x: e.flipX > 0 ? d : -r, y: s.y }, a = { x: l.x, y: c }, g = {
|
|
141
|
+
x: e.flipX > 0 ? e.to.x - d : e.to.x + r,
|
|
142
|
+
y: h.y
|
|
143
|
+
}, y = { x: g.x, y: c };
|
|
144
|
+
return C(
|
|
145
|
+
[t, s, l, a, y, g, h, o],
|
|
146
146
|
e.roundness
|
|
147
147
|
);
|
|
148
148
|
}, R = (e) => {
|
|
149
149
|
const t = e.hasSourceArrow ? f(
|
|
150
|
-
{ x: e.arrowLength, y:
|
|
150
|
+
{ x: e.arrowLength, y: w.y },
|
|
151
151
|
e.fromVect,
|
|
152
|
-
|
|
153
|
-
) :
|
|
152
|
+
w
|
|
153
|
+
) : w, o = e.hasTargetArrow ? f(
|
|
154
154
|
{ x: e.to.x - e.arrowLength, y: e.to.y },
|
|
155
155
|
e.toVect,
|
|
156
156
|
e.to
|
|
157
157
|
) : e.to, r = e.arrowLength + e.arrowOffset, i = f(
|
|
158
|
-
{ x: r, y:
|
|
158
|
+
{ x: r, y: w.y },
|
|
159
159
|
e.fromVect,
|
|
160
|
-
|
|
161
|
-
),
|
|
160
|
+
w
|
|
161
|
+
), s = Math.cos(e.detourDirection) * e.detourDistance, h = Math.sin(e.detourDirection) * e.detourDistance, d = s * e.flipX, c = h * e.flipY, l = { x: i.x + d, y: i.y + c }, a = f(
|
|
162
162
|
{ x: e.to.x - r, y: e.to.y },
|
|
163
163
|
e.toVect,
|
|
164
164
|
e.to
|
|
165
|
-
),
|
|
166
|
-
return
|
|
167
|
-
[t, i, l,
|
|
165
|
+
), g = { x: a.x + d, y: a.y + c };
|
|
166
|
+
return C(
|
|
167
|
+
[t, i, l, g, a, o],
|
|
168
168
|
e.roundness
|
|
169
169
|
);
|
|
170
170
|
}, q = (e) => {
|
|
171
171
|
const t = e.hasSourceArrow ? f(
|
|
172
|
-
{ x: e.arrowLength, y:
|
|
172
|
+
{ x: e.arrowLength, y: w.y },
|
|
173
173
|
e.fromVect,
|
|
174
|
-
|
|
175
|
-
) :
|
|
174
|
+
w
|
|
175
|
+
) : w, o = e.hasTargetArrow ? f(
|
|
176
176
|
{ x: e.to.x - e.arrowLength, y: e.to.y },
|
|
177
177
|
e.toVect,
|
|
178
178
|
e.to
|
|
179
|
-
) : e.to, r = e.arrowLength + e.arrowOffset, i = f({ x: r, y:
|
|
179
|
+
) : e.to, r = e.arrowLength + e.arrowOffset, i = f({ x: r, y: w.y }, e.fromVect, w), s = f(
|
|
180
180
|
{ x: e.to.x - r, y: e.to.y },
|
|
181
181
|
e.toVect,
|
|
182
182
|
e.to
|
|
183
183
|
);
|
|
184
|
-
return
|
|
184
|
+
return C([t, i, s, o], e.roundness);
|
|
185
185
|
}, tt = (e) => {
|
|
186
186
|
const t = e.hasSourceArrow ? f(
|
|
187
|
-
{ x: e.arrowLength, y:
|
|
187
|
+
{ x: e.arrowLength, y: w.y },
|
|
188
188
|
e.fromVect,
|
|
189
|
-
|
|
190
|
-
) :
|
|
189
|
+
w
|
|
190
|
+
) : w, o = e.hasTargetArrow ? f(
|
|
191
191
|
{ x: e.to.x - e.arrowLength, y: e.to.y },
|
|
192
192
|
e.toVect,
|
|
193
193
|
e.to
|
|
194
|
-
) : e.to, r = e.arrowLength + e.arrowOffset, i = r - e.roundness,
|
|
194
|
+
) : e.to, r = e.arrowLength + e.arrowOffset, i = r - e.roundness, s = f({ x: i, y: w.y }, e.fromVect, w), h = f(
|
|
195
195
|
{ x: e.to.x - i, y: e.to.y },
|
|
196
196
|
e.toVect,
|
|
197
197
|
e.to
|
|
198
|
-
),
|
|
199
|
-
x:
|
|
200
|
-
y: e.flipY > 0 ? e.to.y -
|
|
201
|
-
}, y = { x:
|
|
202
|
-
return
|
|
203
|
-
[t,
|
|
198
|
+
), d = Math.max((s.y + h.y) / 2, r), c = e.to.x / 2, l = { x: s.x, y: e.flipY > 0 ? d : -r }, a = { x: c, y: l.y }, g = {
|
|
199
|
+
x: h.x,
|
|
200
|
+
y: e.flipY > 0 ? e.to.y - d : e.to.y + r
|
|
201
|
+
}, y = { x: c, y: g.y };
|
|
202
|
+
return C(
|
|
203
|
+
[t, s, l, a, y, g, h, o],
|
|
204
204
|
e.roundness
|
|
205
205
|
);
|
|
206
206
|
}, Y = (e) => {
|
|
207
|
-
const t = e.arrowOffset, o = e.side, r = e.arrowLength + t, i = r + 2 * o,
|
|
208
|
-
{ x: e.arrowLength, y:
|
|
209
|
-
{ x: r, y:
|
|
207
|
+
const t = e.arrowOffset, o = e.side, r = e.arrowLength + t, i = r + 2 * o, h = [
|
|
208
|
+
{ x: e.arrowLength, y: w.y },
|
|
209
|
+
{ x: r, y: w.y },
|
|
210
210
|
{ x: r, y: e.side },
|
|
211
211
|
{ x: i, y: e.side },
|
|
212
212
|
{ x: i, y: -e.side },
|
|
213
213
|
{ x: r, y: -e.side },
|
|
214
|
-
{ x: r, y:
|
|
215
|
-
{ x: e.arrowLength, y:
|
|
214
|
+
{ x: r, y: w.y },
|
|
215
|
+
{ x: e.arrowLength, y: w.y }
|
|
216
216
|
].map(
|
|
217
|
-
(
|
|
218
|
-
),
|
|
219
|
-
return `${e.hasSourceArrow || e.hasTargetArrow ? "" :
|
|
217
|
+
(c) => f(c, e.fromVect, w)
|
|
218
|
+
), d = `M ${w.x} ${w.y} L ${h[0].x} ${h[0].y} `;
|
|
219
|
+
return `${e.hasSourceArrow || e.hasTargetArrow ? "" : d}${C(h, e.roundness)}`;
|
|
220
220
|
}, et = (e) => {
|
|
221
|
-
const t = e.smallRadius, o = e.radius, r = Math.sqrt(t * t + o * o), i = t + o,
|
|
222
|
-
{ x: e.arrowLength, y:
|
|
223
|
-
{ x:
|
|
224
|
-
{ x:
|
|
225
|
-
].map((
|
|
226
|
-
`M ${
|
|
227
|
-
`A ${t} ${t} 0 0 1 ${
|
|
228
|
-
`A ${o} ${o} 0 1 0 ${
|
|
229
|
-
`A ${t} ${t} 0 0 1 ${
|
|
230
|
-
].join(" "), a = `M 0 0 L ${
|
|
221
|
+
const t = e.smallRadius, o = e.radius, r = Math.sqrt(t * t + o * o), i = t + o, s = e.arrowLength + r * (1 - o / i), h = t * o / i, c = [
|
|
222
|
+
{ x: e.arrowLength, y: w.y },
|
|
223
|
+
{ x: s, y: h },
|
|
224
|
+
{ x: s, y: -h }
|
|
225
|
+
].map((g) => f(g, e.fromVect, w)), l = [
|
|
226
|
+
`M ${c[0].x} ${c[0].y}`,
|
|
227
|
+
`A ${t} ${t} 0 0 1 ${c[1].x} ${c[1].y}`,
|
|
228
|
+
`A ${o} ${o} 0 1 0 ${c[2].x} ${c[2].y}`,
|
|
229
|
+
`A ${t} ${t} 0 0 1 ${c[0].x} ${c[0].y}`
|
|
230
|
+
].join(" "), a = `M 0 0 L ${c[0].x} ${c[0].y} `;
|
|
231
231
|
return `${e.hasSourceArrow || e.hasTargetArrow ? "" : a}${l}`;
|
|
232
|
-
},
|
|
232
|
+
}, u = Object.freeze({
|
|
233
233
|
color: "#5c5c5c",
|
|
234
234
|
width: 1,
|
|
235
235
|
arrowLength: 15,
|
|
@@ -242,79 +242,80 @@ const _ = (e, t) => ({
|
|
|
242
242
|
roundness: 10,
|
|
243
243
|
detourDistance: 100,
|
|
244
244
|
detourDirection: -Math.PI / 2,
|
|
245
|
+
detourDirectionVertical: 0,
|
|
245
246
|
smallCycleRadius: 15,
|
|
246
247
|
curvature: 90
|
|
247
248
|
});
|
|
248
249
|
class ot {
|
|
249
250
|
constructor(t) {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
this.arrowLength = (t == null ? void 0 : t.arrowLength) ??
|
|
265
|
-
const o = (t == null ? void 0 : t.color) ??
|
|
251
|
+
n(this, "svg", I());
|
|
252
|
+
n(this, "group", $());
|
|
253
|
+
n(this, "line");
|
|
254
|
+
n(this, "sourceArrow", null);
|
|
255
|
+
n(this, "targetArrow", null);
|
|
256
|
+
n(this, "arrowLength");
|
|
257
|
+
n(this, "arrowWidth");
|
|
258
|
+
n(this, "curvature");
|
|
259
|
+
n(this, "portCycleRadius");
|
|
260
|
+
n(this, "portCycleSmallRadius");
|
|
261
|
+
n(this, "detourDirection");
|
|
262
|
+
n(this, "detourDistance");
|
|
263
|
+
n(this, "hasSourceArrow");
|
|
264
|
+
n(this, "hasTargetArrow");
|
|
265
|
+
this.arrowLength = (t == null ? void 0 : t.arrowLength) ?? u.arrowLength, this.arrowWidth = (t == null ? void 0 : t.arrowWidth) ?? u.arrowWidth, this.curvature = (t == null ? void 0 : t.curvature) ?? u.curvature, this.portCycleRadius = (t == null ? void 0 : t.cycleRadius) ?? u.cycleRadius, this.portCycleSmallRadius = (t == null ? void 0 : t.smallCycleRadius) ?? u.smallCycleRadius, this.detourDirection = (t == null ? void 0 : t.detourDirection) ?? u.detourDirection, this.detourDistance = (t == null ? void 0 : t.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (t == null ? void 0 : t.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (t == null ? void 0 : t.hasTargetArrow) ?? u.hasTargetArrow;
|
|
266
|
+
const o = (t == null ? void 0 : t.color) ?? u.color, r = (t == null ? void 0 : t.width) ?? u.width;
|
|
266
267
|
this.svg.appendChild(this.group), this.line = m(o, r), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = T(o), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = T(o), this.group.appendChild(this.targetArrow));
|
|
267
268
|
}
|
|
268
269
|
render(t) {
|
|
269
|
-
const { x: o, y: r, width: i, height:
|
|
270
|
+
const { x: o, y: r, width: i, height: s, flipX: h, flipY: d } = b(
|
|
270
271
|
t.source,
|
|
271
272
|
t.target
|
|
272
273
|
);
|
|
273
|
-
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${i}px`, this.svg.style.height = `${
|
|
274
|
-
const
|
|
274
|
+
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${i}px`, this.svg.style.height = `${s}px`, this.group.style.transform = `scale(${h}, ${d})`;
|
|
275
|
+
const c = A(
|
|
275
276
|
t.source.direction,
|
|
276
|
-
|
|
277
|
-
|
|
277
|
+
h,
|
|
278
|
+
d
|
|
278
279
|
), l = A(
|
|
279
280
|
t.target.direction,
|
|
280
|
-
|
|
281
|
-
|
|
281
|
+
h,
|
|
282
|
+
d
|
|
282
283
|
), a = {
|
|
283
284
|
x: i,
|
|
284
|
-
y:
|
|
285
|
+
y: s
|
|
285
286
|
};
|
|
286
|
-
let
|
|
287
|
-
if (t.source.portId === t.target.portId ? (
|
|
288
|
-
fromVect:
|
|
287
|
+
let g, y = l, x = -this.arrowLength;
|
|
288
|
+
if (t.source.portId === t.target.portId ? (g = et({
|
|
289
|
+
fromVect: c,
|
|
289
290
|
radius: this.portCycleRadius,
|
|
290
291
|
smallRadius: this.portCycleSmallRadius,
|
|
291
292
|
arrowLength: this.arrowLength,
|
|
292
293
|
hasSourceArrow: this.hasSourceArrow,
|
|
293
294
|
hasTargetArrow: this.hasTargetArrow
|
|
294
|
-
}), y =
|
|
295
|
+
}), y = c, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g = Q({
|
|
295
296
|
to: a,
|
|
296
|
-
fromVect:
|
|
297
|
+
fromVect: c,
|
|
297
298
|
toVect: l,
|
|
298
|
-
flipX:
|
|
299
|
-
flipY:
|
|
299
|
+
flipX: h,
|
|
300
|
+
flipY: d,
|
|
300
301
|
arrowLength: this.arrowLength,
|
|
301
302
|
detourDirection: this.detourDirection,
|
|
302
303
|
detourDistance: this.detourDistance,
|
|
303
304
|
curvature: this.curvature,
|
|
304
305
|
hasSourceArrow: this.hasSourceArrow,
|
|
305
306
|
hasTargetArrow: this.hasTargetArrow
|
|
306
|
-
}) :
|
|
307
|
+
}) : g = J({
|
|
307
308
|
to: a,
|
|
308
|
-
fromVect:
|
|
309
|
+
fromVect: c,
|
|
309
310
|
toVect: l,
|
|
310
311
|
arrowLength: this.arrowLength,
|
|
311
312
|
curvature: this.curvature,
|
|
312
313
|
hasSourceArrow: this.hasSourceArrow,
|
|
313
314
|
hasTargetArrow: this.hasTargetArrow
|
|
314
|
-
}), this.line.setAttribute("d",
|
|
315
|
+
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
315
316
|
const v = E(
|
|
316
|
-
|
|
317
|
-
|
|
317
|
+
c,
|
|
318
|
+
w,
|
|
318
319
|
this.arrowLength,
|
|
319
320
|
this.arrowWidth
|
|
320
321
|
);
|
|
@@ -333,63 +334,63 @@ class ot {
|
|
|
333
334
|
}
|
|
334
335
|
class rt {
|
|
335
336
|
constructor(t) {
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
this.arrowLength = (t == null ? void 0 : t.arrowLength) ??
|
|
351
|
-
const o = (t == null ? void 0 : t.roundness) ??
|
|
337
|
+
n(this, "svg", I());
|
|
338
|
+
n(this, "group", $());
|
|
339
|
+
n(this, "line");
|
|
340
|
+
n(this, "sourceArrow", null);
|
|
341
|
+
n(this, "targetArrow", null);
|
|
342
|
+
n(this, "arrowLength");
|
|
343
|
+
n(this, "arrowWidth");
|
|
344
|
+
n(this, "arrowOffset");
|
|
345
|
+
n(this, "roundness");
|
|
346
|
+
n(this, "cycleSquareSide");
|
|
347
|
+
n(this, "detourDirection");
|
|
348
|
+
n(this, "detourDistance");
|
|
349
|
+
n(this, "hasSourceArrow");
|
|
350
|
+
n(this, "hasTargetArrow");
|
|
351
|
+
this.arrowLength = (t == null ? void 0 : t.arrowLength) ?? u.arrowLength, this.arrowWidth = (t == null ? void 0 : t.arrowWidth) ?? u.arrowWidth, this.arrowOffset = (t == null ? void 0 : t.arrowOffset) ?? u.arrowOffset, this.cycleSquareSide = (t == null ? void 0 : t.cycleSquareSide) ?? u.cycleSquareSide;
|
|
352
|
+
const o = (t == null ? void 0 : t.roundness) ?? u.roundness;
|
|
352
353
|
this.roundness = Math.min(
|
|
353
354
|
o,
|
|
354
355
|
this.arrowOffset,
|
|
355
356
|
this.cycleSquareSide / 2
|
|
356
|
-
), this.detourDirection = (t == null ? void 0 : t.detourDirection) ??
|
|
357
|
-
const r = (t == null ? void 0 : t.color) ??
|
|
357
|
+
), this.detourDirection = (t == null ? void 0 : t.detourDirection) ?? u.detourDirection, this.detourDistance = (t == null ? void 0 : t.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (t == null ? void 0 : t.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (t == null ? void 0 : t.hasTargetArrow) ?? u.hasTargetArrow;
|
|
358
|
+
const r = (t == null ? void 0 : t.color) ?? u.color, i = (t == null ? void 0 : t.width) ?? u.width;
|
|
358
359
|
this.svg.appendChild(this.group), this.line = m(r, i), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = T(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = T(r), this.group.appendChild(this.targetArrow));
|
|
359
360
|
}
|
|
360
361
|
render(t) {
|
|
361
|
-
const { x: o, y: r, width: i, height:
|
|
362
|
+
const { x: o, y: r, width: i, height: s, flipX: h, flipY: d } = b(
|
|
362
363
|
t.source,
|
|
363
364
|
t.target
|
|
364
365
|
);
|
|
365
|
-
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${i}px`, this.svg.style.height = `${
|
|
366
|
-
const
|
|
366
|
+
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${i}px`, this.svg.style.height = `${s}px`, this.group.style.transform = `scale(${h}, ${d})`;
|
|
367
|
+
const c = A(
|
|
367
368
|
t.source.direction,
|
|
368
|
-
|
|
369
|
-
|
|
369
|
+
h,
|
|
370
|
+
d
|
|
370
371
|
), l = A(
|
|
371
372
|
t.target.direction,
|
|
372
|
-
|
|
373
|
-
|
|
373
|
+
h,
|
|
374
|
+
d
|
|
374
375
|
), a = {
|
|
375
376
|
x: i,
|
|
376
|
-
y:
|
|
377
|
+
y: s
|
|
377
378
|
};
|
|
378
|
-
let
|
|
379
|
-
if (t.source.portId === t.target.portId ? (
|
|
380
|
-
fromVect:
|
|
379
|
+
let g, y = l, x = -this.arrowLength;
|
|
380
|
+
if (t.source.portId === t.target.portId ? (g = Y({
|
|
381
|
+
fromVect: c,
|
|
381
382
|
arrowLength: this.arrowLength,
|
|
382
383
|
side: this.cycleSquareSide,
|
|
383
384
|
arrowOffset: this.arrowOffset,
|
|
384
385
|
roundness: this.roundness,
|
|
385
386
|
hasSourceArrow: this.hasSourceArrow,
|
|
386
387
|
hasTargetArrow: this.hasTargetArrow
|
|
387
|
-
}), y =
|
|
388
|
+
}), y = c, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g = R({
|
|
388
389
|
to: a,
|
|
389
|
-
fromVect:
|
|
390
|
+
fromVect: c,
|
|
390
391
|
toVect: l,
|
|
391
|
-
flipX:
|
|
392
|
-
flipY:
|
|
392
|
+
flipX: h,
|
|
393
|
+
flipY: d,
|
|
393
394
|
arrowLength: this.arrowLength,
|
|
394
395
|
arrowOffset: this.arrowOffset,
|
|
395
396
|
roundness: this.roundness,
|
|
@@ -397,20 +398,20 @@ class rt {
|
|
|
397
398
|
detourDistance: this.detourDistance,
|
|
398
399
|
hasSourceArrow: this.hasSourceArrow,
|
|
399
400
|
hasTargetArrow: this.hasTargetArrow
|
|
400
|
-
}) :
|
|
401
|
+
}) : g = Z({
|
|
401
402
|
to: a,
|
|
402
|
-
fromVect:
|
|
403
|
+
fromVect: c,
|
|
403
404
|
toVect: l,
|
|
404
|
-
flipX:
|
|
405
|
+
flipX: h,
|
|
405
406
|
arrowLength: this.arrowLength,
|
|
406
407
|
arrowOffset: this.arrowOffset,
|
|
407
408
|
roundness: this.roundness,
|
|
408
409
|
hasSourceArrow: this.hasSourceArrow,
|
|
409
410
|
hasTargetArrow: this.hasTargetArrow
|
|
410
|
-
}), this.line.setAttribute("d",
|
|
411
|
+
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
411
412
|
const v = E(
|
|
412
|
-
|
|
413
|
-
|
|
413
|
+
c,
|
|
414
|
+
w,
|
|
414
415
|
this.arrowLength,
|
|
415
416
|
this.arrowWidth
|
|
416
417
|
);
|
|
@@ -429,63 +430,63 @@ class rt {
|
|
|
429
430
|
}
|
|
430
431
|
class it {
|
|
431
432
|
constructor(t) {
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
this.arrowLength = (t == null ? void 0 : t.arrowLength) ??
|
|
447
|
-
const o = (t == null ? void 0 : t.roundness) ??
|
|
433
|
+
n(this, "svg", I());
|
|
434
|
+
n(this, "group", $());
|
|
435
|
+
n(this, "line");
|
|
436
|
+
n(this, "sourceArrow", null);
|
|
437
|
+
n(this, "targetArrow", null);
|
|
438
|
+
n(this, "arrowLength");
|
|
439
|
+
n(this, "arrowWidth");
|
|
440
|
+
n(this, "arrowOffset");
|
|
441
|
+
n(this, "roundness");
|
|
442
|
+
n(this, "cycleSquareSide");
|
|
443
|
+
n(this, "detourDirection");
|
|
444
|
+
n(this, "detourDistance");
|
|
445
|
+
n(this, "hasSourceArrow");
|
|
446
|
+
n(this, "hasTargetArrow");
|
|
447
|
+
this.arrowLength = (t == null ? void 0 : t.arrowLength) ?? u.arrowLength, this.arrowWidth = (t == null ? void 0 : t.arrowWidth) ?? u.arrowWidth, this.arrowOffset = (t == null ? void 0 : t.arrowOffset) ?? u.arrowOffset, this.cycleSquareSide = (t == null ? void 0 : t.cycleSquareSide) ?? u.cycleSquareSide;
|
|
448
|
+
const o = (t == null ? void 0 : t.roundness) ?? u.roundness;
|
|
448
449
|
this.roundness = Math.min(
|
|
449
450
|
o,
|
|
450
451
|
this.arrowOffset,
|
|
451
452
|
this.cycleSquareSide / 2
|
|
452
|
-
), this.detourDirection = (t == null ? void 0 : t.detourDirection) ??
|
|
453
|
-
const r = (t == null ? void 0 : t.color) ??
|
|
453
|
+
), this.detourDirection = (t == null ? void 0 : t.detourDirection) ?? u.detourDirection, this.detourDistance = (t == null ? void 0 : t.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (t == null ? void 0 : t.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (t == null ? void 0 : t.hasTargetArrow) ?? u.hasTargetArrow;
|
|
454
|
+
const r = (t == null ? void 0 : t.color) ?? u.color, i = (t == null ? void 0 : t.width) ?? u.width;
|
|
454
455
|
this.svg.appendChild(this.group), this.line = m(r, i), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = T(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = T(r), this.group.appendChild(this.targetArrow));
|
|
455
456
|
}
|
|
456
457
|
render(t) {
|
|
457
|
-
const { x: o, y: r, width: i, height:
|
|
458
|
+
const { x: o, y: r, width: i, height: s, flipX: h, flipY: d } = b(
|
|
458
459
|
t.source,
|
|
459
460
|
t.target
|
|
460
461
|
);
|
|
461
|
-
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${i}px`, this.svg.style.height = `${
|
|
462
|
-
const
|
|
462
|
+
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${i}px`, this.svg.style.height = `${s}px`, this.group.style.transform = `scale(${h}, ${d})`;
|
|
463
|
+
const c = A(
|
|
463
464
|
t.source.direction,
|
|
464
|
-
|
|
465
|
-
|
|
465
|
+
h,
|
|
466
|
+
d
|
|
466
467
|
), l = A(
|
|
467
468
|
t.target.direction,
|
|
468
|
-
|
|
469
|
-
|
|
469
|
+
h,
|
|
470
|
+
d
|
|
470
471
|
), a = {
|
|
471
472
|
x: i,
|
|
472
|
-
y:
|
|
473
|
+
y: s
|
|
473
474
|
};
|
|
474
|
-
let
|
|
475
|
-
if (t.source.portId === t.target.portId ? (
|
|
476
|
-
fromVect:
|
|
475
|
+
let g, y = l, x = -this.arrowLength;
|
|
476
|
+
if (t.source.portId === t.target.portId ? (g = Y({
|
|
477
|
+
fromVect: c,
|
|
477
478
|
arrowLength: this.arrowLength,
|
|
478
479
|
side: this.cycleSquareSide,
|
|
479
480
|
arrowOffset: this.arrowOffset,
|
|
480
481
|
roundness: this.roundness,
|
|
481
482
|
hasSourceArrow: this.hasSourceArrow,
|
|
482
483
|
hasTargetArrow: this.hasTargetArrow
|
|
483
|
-
}), y =
|
|
484
|
+
}), y = c, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g = R({
|
|
484
485
|
to: a,
|
|
485
|
-
fromVect:
|
|
486
|
+
fromVect: c,
|
|
486
487
|
toVect: l,
|
|
487
|
-
flipX:
|
|
488
|
-
flipY:
|
|
488
|
+
flipX: h,
|
|
489
|
+
flipY: d,
|
|
489
490
|
arrowLength: this.arrowLength,
|
|
490
491
|
arrowOffset: this.arrowOffset,
|
|
491
492
|
roundness: this.roundness,
|
|
@@ -493,19 +494,19 @@ class it {
|
|
|
493
494
|
detourDistance: this.detourDistance,
|
|
494
495
|
hasSourceArrow: this.hasSourceArrow,
|
|
495
496
|
hasTargetArrow: this.hasTargetArrow
|
|
496
|
-
}) :
|
|
497
|
+
}) : g = q({
|
|
497
498
|
to: a,
|
|
498
|
-
fromVect:
|
|
499
|
+
fromVect: c,
|
|
499
500
|
toVect: l,
|
|
500
501
|
arrowLength: this.arrowLength,
|
|
501
502
|
arrowOffset: this.arrowOffset,
|
|
502
503
|
roundness: this.roundness,
|
|
503
504
|
hasSourceArrow: this.hasSourceArrow,
|
|
504
505
|
hasTargetArrow: this.hasTargetArrow
|
|
505
|
-
}), this.line.setAttribute("d",
|
|
506
|
+
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
506
507
|
const v = E(
|
|
507
|
-
|
|
508
|
-
|
|
508
|
+
c,
|
|
509
|
+
w,
|
|
509
510
|
this.arrowLength,
|
|
510
511
|
this.arrowWidth
|
|
511
512
|
);
|
|
@@ -524,63 +525,63 @@ class it {
|
|
|
524
525
|
}
|
|
525
526
|
class nt {
|
|
526
527
|
constructor(t) {
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
this.arrowLength = (t == null ? void 0 : t.arrowLength) ??
|
|
542
|
-
const o = (t == null ? void 0 : t.roundness) ??
|
|
528
|
+
n(this, "svg", I());
|
|
529
|
+
n(this, "group", $());
|
|
530
|
+
n(this, "line");
|
|
531
|
+
n(this, "sourceArrow", null);
|
|
532
|
+
n(this, "targetArrow", null);
|
|
533
|
+
n(this, "arrowLength");
|
|
534
|
+
n(this, "arrowWidth");
|
|
535
|
+
n(this, "arrowOffset");
|
|
536
|
+
n(this, "roundness");
|
|
537
|
+
n(this, "cycleSquareSide");
|
|
538
|
+
n(this, "detourDirection");
|
|
539
|
+
n(this, "detourDistance");
|
|
540
|
+
n(this, "hasSourceArrow");
|
|
541
|
+
n(this, "hasTargetArrow");
|
|
542
|
+
this.arrowLength = (t == null ? void 0 : t.arrowLength) ?? u.arrowLength, this.arrowWidth = (t == null ? void 0 : t.arrowWidth) ?? u.arrowWidth, this.arrowOffset = (t == null ? void 0 : t.arrowOffset) ?? u.arrowOffset, this.cycleSquareSide = (t == null ? void 0 : t.cycleSquareSide) ?? u.cycleSquareSide;
|
|
543
|
+
const o = (t == null ? void 0 : t.roundness) ?? u.roundness;
|
|
543
544
|
this.roundness = Math.min(
|
|
544
545
|
o,
|
|
545
546
|
this.arrowOffset,
|
|
546
547
|
this.cycleSquareSide / 2
|
|
547
|
-
), this.detourDirection = (t == null ? void 0 : t.detourDirection) ??
|
|
548
|
-
const r = (t == null ? void 0 : t.color) ??
|
|
548
|
+
), this.detourDirection = (t == null ? void 0 : t.detourDirection) ?? u.detourDirectionVertical, this.detourDistance = (t == null ? void 0 : t.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (t == null ? void 0 : t.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (t == null ? void 0 : t.hasTargetArrow) ?? u.hasTargetArrow;
|
|
549
|
+
const r = (t == null ? void 0 : t.color) ?? u.color, i = (t == null ? void 0 : t.width) ?? u.width;
|
|
549
550
|
this.svg.appendChild(this.group), this.line = m(r, i), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = T(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = T(r), this.group.appendChild(this.targetArrow));
|
|
550
551
|
}
|
|
551
552
|
render(t) {
|
|
552
|
-
const { x: o, y: r, width: i, height:
|
|
553
|
+
const { x: o, y: r, width: i, height: s, flipX: h, flipY: d } = b(
|
|
553
554
|
t.source,
|
|
554
555
|
t.target
|
|
555
556
|
);
|
|
556
|
-
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${i}px`, this.svg.style.height = `${
|
|
557
|
-
const
|
|
557
|
+
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${i}px`, this.svg.style.height = `${s}px`, this.group.style.transform = `scale(${h}, ${d})`;
|
|
558
|
+
const c = A(
|
|
558
559
|
t.source.direction,
|
|
559
|
-
|
|
560
|
-
|
|
560
|
+
h,
|
|
561
|
+
d
|
|
561
562
|
), l = A(
|
|
562
563
|
t.target.direction,
|
|
563
|
-
|
|
564
|
-
|
|
564
|
+
h,
|
|
565
|
+
d
|
|
565
566
|
), a = {
|
|
566
567
|
x: i,
|
|
567
|
-
y:
|
|
568
|
+
y: s
|
|
568
569
|
};
|
|
569
|
-
let
|
|
570
|
-
if (t.source.portId === t.target.portId ? (
|
|
571
|
-
fromVect:
|
|
570
|
+
let g, y = l, x = -this.arrowLength;
|
|
571
|
+
if (t.source.portId === t.target.portId ? (g = Y({
|
|
572
|
+
fromVect: c,
|
|
572
573
|
arrowLength: this.arrowLength,
|
|
573
574
|
side: this.cycleSquareSide,
|
|
574
575
|
arrowOffset: this.arrowOffset,
|
|
575
576
|
roundness: this.roundness,
|
|
576
577
|
hasSourceArrow: this.hasSourceArrow,
|
|
577
578
|
hasTargetArrow: this.hasTargetArrow
|
|
578
|
-
}), y =
|
|
579
|
+
}), y = c, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g = R({
|
|
579
580
|
to: a,
|
|
580
|
-
fromVect:
|
|
581
|
+
fromVect: c,
|
|
581
582
|
toVect: l,
|
|
582
|
-
flipX:
|
|
583
|
-
flipY:
|
|
583
|
+
flipX: h,
|
|
584
|
+
flipY: d,
|
|
584
585
|
arrowLength: this.arrowLength,
|
|
585
586
|
arrowOffset: this.arrowOffset,
|
|
586
587
|
roundness: this.roundness,
|
|
@@ -588,20 +589,20 @@ class nt {
|
|
|
588
589
|
detourDistance: this.detourDistance,
|
|
589
590
|
hasSourceArrow: this.hasSourceArrow,
|
|
590
591
|
hasTargetArrow: this.hasTargetArrow
|
|
591
|
-
}) :
|
|
592
|
+
}) : g = tt({
|
|
592
593
|
to: a,
|
|
593
|
-
fromVect:
|
|
594
|
+
fromVect: c,
|
|
594
595
|
toVect: l,
|
|
595
|
-
flipY:
|
|
596
|
+
flipY: d,
|
|
596
597
|
arrowLength: this.arrowLength,
|
|
597
598
|
arrowOffset: this.arrowOffset,
|
|
598
599
|
roundness: this.roundness,
|
|
599
600
|
hasSourceArrow: this.hasSourceArrow,
|
|
600
601
|
hasTargetArrow: this.hasTargetArrow
|
|
601
|
-
}), this.line.setAttribute("d",
|
|
602
|
+
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
602
603
|
const v = E(
|
|
603
|
-
|
|
604
|
-
|
|
604
|
+
c,
|
|
605
|
+
w,
|
|
605
606
|
this.arrowLength,
|
|
606
607
|
this.arrowWidth
|
|
607
608
|
);
|
|
@@ -690,8 +691,8 @@ const st = (e) => {
|
|
|
690
691
|
nodesPriorityFn: o,
|
|
691
692
|
edgesPriorityFn: r
|
|
692
693
|
};
|
|
693
|
-
},
|
|
694
|
-
var o, r, i,
|
|
694
|
+
}, dt = (e) => {
|
|
695
|
+
var o, r, i, s, h;
|
|
695
696
|
const t = ht(
|
|
696
697
|
(o = e == null ? void 0 : e.nodes) == null ? void 0 : o.priority,
|
|
697
698
|
(r = e == null ? void 0 : e.edges) == null ? void 0 : r.priority
|
|
@@ -702,24 +703,24 @@ const st = (e) => {
|
|
|
702
703
|
priorityFn: t.nodesPriorityFn
|
|
703
704
|
},
|
|
704
705
|
ports: {
|
|
705
|
-
direction: ((
|
|
706
|
+
direction: ((s = e == null ? void 0 : e.ports) == null ? void 0 : s.direction) ?? 0
|
|
706
707
|
},
|
|
707
708
|
edges: {
|
|
708
|
-
shapeFactory: st(((
|
|
709
|
+
shapeFactory: st(((h = e == null ? void 0 : e.edges) == null ? void 0 : h.shape) ?? {}),
|
|
709
710
|
priorityFn: t.edgesPriorityFn
|
|
710
711
|
}
|
|
711
712
|
};
|
|
712
713
|
};
|
|
713
|
-
class
|
|
714
|
+
class ct {
|
|
714
715
|
constructor() {
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
716
|
+
n(this, "nodes", /* @__PURE__ */ new Map());
|
|
717
|
+
n(this, "ports", /* @__PURE__ */ new Map());
|
|
718
|
+
n(this, "nodePorts", /* @__PURE__ */ new Map());
|
|
719
|
+
n(this, "portNodeId", /* @__PURE__ */ new Map());
|
|
720
|
+
n(this, "edges", /* @__PURE__ */ new Map());
|
|
721
|
+
n(this, "incommingEdges", /* @__PURE__ */ new Map());
|
|
722
|
+
n(this, "outcommingEdges", /* @__PURE__ */ new Map());
|
|
723
|
+
n(this, "cycleEdges", /* @__PURE__ */ new Map());
|
|
723
724
|
}
|
|
724
725
|
addNode(t) {
|
|
725
726
|
this.nodes.set(t.nodeId, {
|
|
@@ -925,8 +926,8 @@ const j = (e) => ({
|
|
|
925
926
|
};
|
|
926
927
|
class at {
|
|
927
928
|
constructor() {
|
|
928
|
-
|
|
929
|
-
|
|
929
|
+
n(this, "viewportMatrix", H);
|
|
930
|
+
n(this, "contentMatrix", H);
|
|
930
931
|
}
|
|
931
932
|
getViewportMatrix() {
|
|
932
933
|
return this.viewportMatrix;
|
|
@@ -972,11 +973,11 @@ const ut = () => {
|
|
|
972
973
|
};
|
|
973
974
|
class ft {
|
|
974
975
|
constructor(t, o) {
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
976
|
+
n(this, "canvasWrapper", null);
|
|
977
|
+
n(this, "host", ut());
|
|
978
|
+
n(this, "container", wt());
|
|
979
|
+
n(this, "nodeIdToWrapperElementMap", /* @__PURE__ */ new Map());
|
|
980
|
+
n(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
|
|
980
981
|
this.graphStore = t, this.viewportTransformer = o, this.host.appendChild(this.container);
|
|
981
982
|
}
|
|
982
983
|
attach(t) {
|
|
@@ -1016,8 +1017,8 @@ class ft {
|
|
|
1016
1017
|
this.clear(), this.detach(), this.host.removeChild(this.container);
|
|
1017
1018
|
}
|
|
1018
1019
|
updateNodeCoordinates(t) {
|
|
1019
|
-
const o = this.nodeIdToWrapperElementMap.get(t), r = this.graphStore.getNode(t), { width: i, height:
|
|
1020
|
-
o.style.transform = `translate(${
|
|
1020
|
+
const o = this.nodeIdToWrapperElementMap.get(t), r = this.graphStore.getNode(t), { width: i, height: s } = r.element.getBoundingClientRect(), h = this.viewportTransformer.getViewportMatrix().scale, d = r.centerFn(i, s), c = r.x - h * d.x, l = r.y - h * d.y;
|
|
1021
|
+
o.style.transform = `translate(${c}px, ${l}px)`;
|
|
1021
1022
|
}
|
|
1022
1023
|
updateNodePriority(t) {
|
|
1023
1024
|
const o = this.graphStore.getNode(t), r = this.nodeIdToWrapperElementMap.get(t);
|
|
@@ -1030,31 +1031,31 @@ class ft {
|
|
|
1030
1031
|
this.edgeIdToElementMap.set(t, r.shape.svg), this.container.appendChild(r.shape.svg);
|
|
1031
1032
|
}
|
|
1032
1033
|
renderEdge(t) {
|
|
1033
|
-
const o = this.graphStore.getEdge(t), r = this.graphStore.getPort(o.from), i = this.graphStore.getPort(o.to),
|
|
1034
|
-
x:
|
|
1035
|
-
y:
|
|
1034
|
+
const o = this.graphStore.getEdge(t), r = this.graphStore.getPort(o.from), i = this.graphStore.getPort(o.to), s = r.element.getBoundingClientRect(), h = i.element.getBoundingClientRect(), d = this.host.getBoundingClientRect(), c = this.viewportTransformer.getViewportMatrix(), l = {
|
|
1035
|
+
x: c.scale * (s.left - d.left) + c.dx,
|
|
1036
|
+
y: c.scale * (s.top - d.top) + c.dy
|
|
1036
1037
|
}, a = {
|
|
1037
|
-
x:
|
|
1038
|
-
y:
|
|
1039
|
-
},
|
|
1038
|
+
x: c.scale * (h.left - d.left) + c.dx,
|
|
1039
|
+
y: c.scale * (h.top - d.top) + c.dy
|
|
1040
|
+
}, g = {
|
|
1040
1041
|
x: l.x,
|
|
1041
1042
|
y: l.y,
|
|
1042
|
-
width:
|
|
1043
|
-
height:
|
|
1043
|
+
width: s.width * c.scale,
|
|
1044
|
+
height: s.height * c.scale,
|
|
1044
1045
|
direction: r.direction,
|
|
1045
1046
|
portId: o.from,
|
|
1046
1047
|
nodeId: this.graphStore.getPortNodeId(o.from)
|
|
1047
1048
|
}, y = {
|
|
1048
1049
|
x: a.x,
|
|
1049
1050
|
y: a.y,
|
|
1050
|
-
width:
|
|
1051
|
-
height:
|
|
1051
|
+
width: h.width * c.scale,
|
|
1052
|
+
height: h.height * c.scale,
|
|
1052
1053
|
direction: i.direction,
|
|
1053
1054
|
portId: o.to,
|
|
1054
1055
|
nodeId: this.graphStore.getPortNodeId(o.to)
|
|
1055
1056
|
};
|
|
1056
1057
|
o.shape.render({
|
|
1057
|
-
source:
|
|
1058
|
+
source: g,
|
|
1058
1059
|
target: y
|
|
1059
1060
|
});
|
|
1060
1061
|
}
|
|
@@ -1063,9 +1064,9 @@ class ft {
|
|
|
1063
1064
|
o.shape.svg.style.zIndex = `${o.priority}`;
|
|
1064
1065
|
}
|
|
1065
1066
|
}
|
|
1066
|
-
class
|
|
1067
|
+
class N {
|
|
1067
1068
|
constructor(t) {
|
|
1068
|
-
|
|
1069
|
+
n(this, "counter", 0);
|
|
1069
1070
|
this.checkExists = t;
|
|
1070
1071
|
}
|
|
1071
1072
|
create(t) {
|
|
@@ -1082,21 +1083,21 @@ class C {
|
|
|
1082
1083
|
class S extends Error {
|
|
1083
1084
|
constructor() {
|
|
1084
1085
|
super(...arguments);
|
|
1085
|
-
|
|
1086
|
+
n(this, "name", "HtmlGraphError");
|
|
1086
1087
|
}
|
|
1087
1088
|
}
|
|
1088
1089
|
class vt {
|
|
1089
|
-
constructor(t, o, r, i,
|
|
1090
|
-
|
|
1090
|
+
constructor(t, o, r, i, s, h, d) {
|
|
1091
|
+
n(this, "nodeIdGenerator", new N(
|
|
1091
1092
|
(t) => this.graphStore.getNode(t) !== void 0
|
|
1092
1093
|
));
|
|
1093
|
-
|
|
1094
|
+
n(this, "portIdGenerator", new N(
|
|
1094
1095
|
(t) => this.graphStore.getPort(t) !== void 0
|
|
1095
1096
|
));
|
|
1096
|
-
|
|
1097
|
+
n(this, "edgeIdGenerator", new N(
|
|
1097
1098
|
(t) => this.graphStore.getEdge(t) !== void 0
|
|
1098
1099
|
));
|
|
1099
|
-
this.graphStore = t, this.htmlController = o, this.viewportTransformer = r, this.defaultNodesCenterFn = i, this.defaultPortsDirection =
|
|
1100
|
+
this.graphStore = t, this.htmlController = o, this.viewportTransformer = r, this.defaultNodesCenterFn = i, this.defaultPortsDirection = s, this.defaultNodesPriorityFn = h, this.defaultEdgesPriorityFn = d;
|
|
1100
1101
|
}
|
|
1101
1102
|
attach(t) {
|
|
1102
1103
|
this.htmlController.attach(t);
|
|
@@ -1163,16 +1164,16 @@ class vt {
|
|
|
1163
1164
|
const r = this.graphStore.getPort(t);
|
|
1164
1165
|
if (r === void 0)
|
|
1165
1166
|
throw new S("failed to unset nonexisting port");
|
|
1166
|
-
r.direction = o.direction ?? r.direction, this.graphStore.getPortAdjacentEdgeIds(t).forEach((
|
|
1167
|
-
this.htmlController.renderEdge(
|
|
1167
|
+
r.direction = o.direction ?? r.direction, this.graphStore.getPortAdjacentEdgeIds(t).forEach((s) => {
|
|
1168
|
+
this.htmlController.renderEdge(s);
|
|
1168
1169
|
});
|
|
1169
1170
|
}
|
|
1170
1171
|
updateNode(t, o) {
|
|
1171
1172
|
const r = this.graphStore.getNode(t);
|
|
1172
1173
|
if (r === void 0)
|
|
1173
1174
|
throw new S("failed to update nonexisting node");
|
|
1174
|
-
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((
|
|
1175
|
-
this.htmlController.renderEdge(
|
|
1175
|
+
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) => {
|
|
1176
|
+
this.htmlController.renderEdge(s);
|
|
1176
1177
|
});
|
|
1177
1178
|
}
|
|
1178
1179
|
removeEdge(t) {
|
|
@@ -1209,17 +1210,17 @@ class vt {
|
|
|
1209
1210
|
}
|
|
1210
1211
|
class xt {
|
|
1211
1212
|
constructor(t) {
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1213
|
+
n(this, "transformation");
|
|
1214
|
+
n(this, "model");
|
|
1215
|
+
n(this, "canvasController");
|
|
1216
|
+
n(this, "edgeShapeFactory");
|
|
1216
1217
|
this.apiOptions = t;
|
|
1217
|
-
const o =
|
|
1218
|
+
const o = dt(this.apiOptions), r = new at(), i = new ct();
|
|
1218
1219
|
this.model = new lt(i), this.transformation = new gt(r);
|
|
1219
|
-
const
|
|
1220
|
+
const s = new ft(i, r);
|
|
1220
1221
|
this.canvasController = new vt(
|
|
1221
1222
|
i,
|
|
1222
|
-
|
|
1223
|
+
s,
|
|
1223
1224
|
r,
|
|
1224
1225
|
o.nodes.centerFn,
|
|
1225
1226
|
o.ports.direction,
|
|
@@ -1306,35 +1307,36 @@ class xt {
|
|
|
1306
1307
|
}
|
|
1307
1308
|
}
|
|
1308
1309
|
const P = (e, t, o) => {
|
|
1309
|
-
const { x: r, y: i, width:
|
|
1310
|
-
return t >= r && t <= r +
|
|
1310
|
+
const { x: r, y: i, width: s, height: h } = e.getBoundingClientRect();
|
|
1311
|
+
return t >= r && t <= r + s && o >= i && o <= i + h;
|
|
1311
1312
|
}, L = (e, t, o) => t >= 0 && t <= e.innerWidth && o >= 0 && o <= e.innerHeight, D = (e, t) => {
|
|
1312
1313
|
t !== null ? e.style.cursor = t : e.style.removeProperty("cursor");
|
|
1313
1314
|
};
|
|
1314
1315
|
class St {
|
|
1315
1316
|
constructor(t, o) {
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1317
|
+
n(this, "model");
|
|
1318
|
+
n(this, "transformation");
|
|
1319
|
+
n(this, "maxNodePriority", 0);
|
|
1320
|
+
n(this, "nodes", /* @__PURE__ */ new Map());
|
|
1321
|
+
n(this, "grabbedNodeId", null);
|
|
1322
|
+
n(this, "onNodeDrag");
|
|
1323
|
+
n(this, "onBeforeNodeDrag");
|
|
1324
|
+
n(this, "onNodeDragFinished");
|
|
1325
|
+
n(this, "nodeIdGenerator", new N(
|
|
1324
1326
|
(t) => this.nodes.has(t)
|
|
1325
1327
|
));
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
+
n(this, "element", null);
|
|
1329
|
+
n(this, "onWindowMouseMove", (t) => {
|
|
1328
1330
|
if (this.element !== null && (!P(this.element, t.clientX, t.clientY) || !L(this.window, t.clientX, t.clientY))) {
|
|
1329
1331
|
this.cancelMouseDrag();
|
|
1330
1332
|
return;
|
|
1331
1333
|
}
|
|
1332
1334
|
this.grabbedNodeId !== null && this.dragNode(this.grabbedNodeId, t.movementX, t.movementY);
|
|
1333
1335
|
});
|
|
1334
|
-
|
|
1336
|
+
n(this, "onWindowMouseUp", (t) => {
|
|
1335
1337
|
t.button === 0 && this.cancelMouseDrag();
|
|
1336
1338
|
});
|
|
1337
|
-
|
|
1339
|
+
n(this, "onWindowTouchMove", (t) => {
|
|
1338
1340
|
if (t.touches.length !== 1)
|
|
1339
1341
|
return;
|
|
1340
1342
|
const o = t.touches[0];
|
|
@@ -1350,19 +1352,20 @@ class St {
|
|
|
1350
1352
|
};
|
|
1351
1353
|
}
|
|
1352
1354
|
});
|
|
1353
|
-
|
|
1355
|
+
n(this, "onWindowTouchFinish", (t) => {
|
|
1354
1356
|
t.touches.length > 0 ? this.previousTouchCoords = {
|
|
1355
1357
|
x: t.touches[0].clientX,
|
|
1356
1358
|
y: t.touches[0].clientY
|
|
1357
1359
|
} : this.cancelTouchDrag();
|
|
1358
1360
|
});
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
var r, i;
|
|
1361
|
+
n(this, "previousTouchCoords", null);
|
|
1362
|
+
n(this, "freezePriority");
|
|
1363
|
+
n(this, "window", window);
|
|
1364
|
+
n(this, "dragCursor");
|
|
1365
|
+
var r, i, s;
|
|
1364
1366
|
this.canvas = t, this.transformation = this.canvas.transformation, this.model = this.canvas.model, this.onNodeDrag = ((r = o == null ? void 0 : o.events) == null ? void 0 : r.onNodeDrag) ?? (() => {
|
|
1365
|
-
}), this.onBeforeNodeDrag = ((i = o == null ? void 0 : o.events) == null ? void 0 : i.onBeforeNodeDrag) ?? (() => !0), this.
|
|
1367
|
+
}), this.onBeforeNodeDrag = ((i = o == null ? void 0 : o.events) == null ? void 0 : i.onBeforeNodeDrag) ?? (() => !0), this.onNodeDragFinished = ((s = o == null ? void 0 : o.events) == null ? void 0 : s.onNodeDragFinished) ?? (() => {
|
|
1368
|
+
}), this.freezePriority = (o == null ? void 0 : o.moveOnTop) === !1, this.dragCursor = (o == null ? void 0 : o.dragCursor) !== void 0 ? o.dragCursor : "grab";
|
|
1366
1369
|
}
|
|
1367
1370
|
attach(t) {
|
|
1368
1371
|
return this.detach(), this.element = t, this.canvas.attach(this.element), this;
|
|
@@ -1373,28 +1376,28 @@ class St {
|
|
|
1373
1376
|
addNode(t) {
|
|
1374
1377
|
const o = this.nodeIdGenerator.create(t.id);
|
|
1375
1378
|
this.canvas.addNode({ ...t, id: o }), this.updateMaxNodePriority(o);
|
|
1376
|
-
const r = (
|
|
1377
|
-
if (this.element === null ||
|
|
1379
|
+
const r = (s) => {
|
|
1380
|
+
if (this.element === null || s.button !== 0)
|
|
1378
1381
|
return;
|
|
1379
|
-
const
|
|
1382
|
+
const h = this.model.getNode(o);
|
|
1380
1383
|
this.onBeforeNodeDrag({
|
|
1381
1384
|
nodeId: o,
|
|
1382
1385
|
element: t.element,
|
|
1383
|
-
x:
|
|
1384
|
-
y:
|
|
1385
|
-
}) && (
|
|
1386
|
-
}, i = (
|
|
1387
|
-
|
|
1388
|
-
x:
|
|
1389
|
-
y:
|
|
1386
|
+
x: h.x,
|
|
1387
|
+
y: h.y
|
|
1388
|
+
}) && (s.stopImmediatePropagation(), this.grabbedNodeId = o, D(this.element, this.dragCursor), this.moveNodeOnTop(o), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.window.addEventListener("mousemove", this.onWindowMouseMove));
|
|
1389
|
+
}, i = (s) => {
|
|
1390
|
+
s.stopImmediatePropagation(), this.previousTouchCoords = {
|
|
1391
|
+
x: s.touches[0].clientX,
|
|
1392
|
+
y: s.touches[0].clientY
|
|
1390
1393
|
};
|
|
1391
|
-
const
|
|
1394
|
+
const h = this.model.getNode(o);
|
|
1392
1395
|
this.onBeforeNodeDrag({
|
|
1393
1396
|
nodeId: o,
|
|
1394
1397
|
element: t.element,
|
|
1395
|
-
x:
|
|
1396
|
-
y:
|
|
1397
|
-
}) &&
|
|
1398
|
+
x: h.x,
|
|
1399
|
+
y: h.y
|
|
1400
|
+
}) && s.touches.length === 1 && (this.grabbedNodeId = o, this.moveNodeOnTop(o), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish));
|
|
1398
1401
|
};
|
|
1399
1402
|
return this.nodes.set(o, {
|
|
1400
1403
|
element: t.element,
|
|
@@ -1445,8 +1448,8 @@ class St {
|
|
|
1445
1448
|
const i = this.model.getNode(t);
|
|
1446
1449
|
if (i === null)
|
|
1447
1450
|
return;
|
|
1448
|
-
const
|
|
1449
|
-
this.canvas.updateNode(t, { x:
|
|
1451
|
+
const s = this.canvas.transformation.getContentMatrix(), h = s.scale * i.x + s.dx, d = s.scale * i.y + s.dy, c = h + o, l = d + r, a = this.canvas.transformation.getViewportMatrix(), g = a.scale * c + a.dx, y = a.scale * l + a.dy;
|
|
1452
|
+
this.canvas.updateNode(t, { x: g, y }), this.onNodeDrag({
|
|
1450
1453
|
nodeId: t,
|
|
1451
1454
|
element: i.element,
|
|
1452
1455
|
x: i.x,
|
|
@@ -1467,13 +1470,26 @@ class St {
|
|
|
1467
1470
|
});
|
|
1468
1471
|
}
|
|
1469
1472
|
cancelMouseDrag() {
|
|
1470
|
-
|
|
1473
|
+
const t = this.model.getNode(this.grabbedNodeId);
|
|
1474
|
+
t !== null && this.onNodeDragFinished({
|
|
1475
|
+
nodeId: this.grabbedNodeId,
|
|
1476
|
+
element: t.element,
|
|
1477
|
+
x: t.x,
|
|
1478
|
+
y: t.y
|
|
1479
|
+
}), this.grabbedNodeId = null, this.element !== null && D(this.element, null), this.removeMouseDragListeners();
|
|
1471
1480
|
}
|
|
1472
1481
|
removeMouseDragListeners() {
|
|
1473
1482
|
this.window.removeEventListener("mouseup", this.onWindowMouseUp), this.window.removeEventListener("mousemove", this.onWindowMouseMove);
|
|
1474
1483
|
}
|
|
1475
1484
|
cancelTouchDrag() {
|
|
1476
|
-
this.previousTouchCoords = null
|
|
1485
|
+
this.previousTouchCoords = null;
|
|
1486
|
+
const t = this.model.getNode(this.grabbedNodeId);
|
|
1487
|
+
t !== null && this.onNodeDragFinished({
|
|
1488
|
+
nodeId: this.grabbedNodeId,
|
|
1489
|
+
element: t.element,
|
|
1490
|
+
x: t.x,
|
|
1491
|
+
y: t.y
|
|
1492
|
+
}), this.grabbedNodeId = null, this.removeTouchDragListeners();
|
|
1477
1493
|
}
|
|
1478
1494
|
removeTouchDragListeners() {
|
|
1479
1495
|
this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
|
|
@@ -1481,22 +1497,33 @@ class St {
|
|
|
1481
1497
|
}
|
|
1482
1498
|
const At = (e) => {
|
|
1483
1499
|
const t = e.minX !== null ? e.minX : -1 / 0, o = e.maxX !== null ? e.maxX : 1 / 0, r = e.minY !== null ? e.minY : -1 / 0, i = e.maxY !== null ? e.maxY : 1 / 0;
|
|
1484
|
-
return (
|
|
1485
|
-
let
|
|
1486
|
-
|
|
1487
|
-
const
|
|
1488
|
-
|
|
1489
|
-
const l =
|
|
1490
|
-
return
|
|
1500
|
+
return (s) => {
|
|
1501
|
+
let h = s.nextTransform.dx, d = s.nextTransform.dy;
|
|
1502
|
+
h < t && h < s.prevTransform.dx && (h = Math.min(s.prevTransform.dx, t));
|
|
1503
|
+
const c = s.canvasWidth * s.prevTransform.scale;
|
|
1504
|
+
h > o - c && h > s.prevTransform.dx && (h = Math.max(s.prevTransform.dx, o - c)), d < r && d < s.prevTransform.dy && (d = Math.min(s.prevTransform.dy, r));
|
|
1505
|
+
const l = s.canvasHeight * s.prevTransform.scale;
|
|
1506
|
+
return d > i - l && d > s.prevTransform.dy && (d = Math.max(s.prevTransform.dy, i - l)), { scale: s.nextTransform.scale, dx: h, dy: d };
|
|
1491
1507
|
};
|
|
1492
1508
|
}, Et = (e) => {
|
|
1493
1509
|
const t = e.maxContentScale, o = e.minContentScale, r = t !== null ? 1 / t : 0, i = o !== null ? 1 / o : 1 / 0;
|
|
1494
|
-
return (
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
dx
|
|
1499
|
-
|
|
1510
|
+
return (s) => {
|
|
1511
|
+
const h = s.prevTransform, d = s.nextTransform;
|
|
1512
|
+
let c = d.scale, l = d.dx, a = d.dy;
|
|
1513
|
+
if (d.scale > i && d.scale > h.scale) {
|
|
1514
|
+
c = Math.max(h.scale, i), l = h.dx, a = h.dy;
|
|
1515
|
+
const g = (c - h.scale) / (d.scale - h.scale);
|
|
1516
|
+
l = h.dx + (d.dx - h.dx) * g, a = h.dy + (d.dy - h.dy) * g;
|
|
1517
|
+
}
|
|
1518
|
+
if (d.scale < r && d.scale < h.scale) {
|
|
1519
|
+
c = Math.min(h.scale, r), l = h.dx, a = h.dy;
|
|
1520
|
+
const g = (c - h.scale) / (d.scale - h.scale);
|
|
1521
|
+
l = h.dx + (d.dx - h.dx) * g, a = h.dy + (d.dy - h.dy) * g;
|
|
1522
|
+
}
|
|
1523
|
+
return {
|
|
1524
|
+
scale: c,
|
|
1525
|
+
dx: l,
|
|
1526
|
+
dy: a
|
|
1500
1527
|
};
|
|
1501
1528
|
};
|
|
1502
1529
|
}, Tt = (e) => (t) => e.reduce(
|
|
@@ -1507,7 +1534,7 @@ const At = (e) => {
|
|
|
1507
1534
|
canvasHeight: t.canvasHeight
|
|
1508
1535
|
}),
|
|
1509
1536
|
t.nextTransform
|
|
1510
|
-
),
|
|
1537
|
+
), U = (e) => {
|
|
1511
1538
|
if (typeof e == "function")
|
|
1512
1539
|
return e;
|
|
1513
1540
|
switch (e.type) {
|
|
@@ -1525,62 +1552,62 @@ const At = (e) => {
|
|
|
1525
1552
|
});
|
|
1526
1553
|
}
|
|
1527
1554
|
}, Mt = (e) => {
|
|
1528
|
-
var
|
|
1529
|
-
const t = (
|
|
1555
|
+
var c, l, a, g;
|
|
1556
|
+
const t = (c = e == null ? void 0 : e.scale) == null ? void 0 : c.mouseWheelSensitivity, o = t !== void 0 ? t : 1.2, r = e == null ? void 0 : e.transformPreprocessor;
|
|
1530
1557
|
let i;
|
|
1531
1558
|
r !== void 0 ? Array.isArray(r) ? i = Tt(
|
|
1532
1559
|
r.map(
|
|
1533
|
-
(y) =>
|
|
1560
|
+
(y) => U(y)
|
|
1534
1561
|
)
|
|
1535
|
-
) : i =
|
|
1536
|
-
const
|
|
1537
|
-
}),
|
|
1562
|
+
) : i = U(r) : i = (y) => y.nextTransform;
|
|
1563
|
+
const s = ((l = e == null ? void 0 : e.shift) == null ? void 0 : l.cursor) !== void 0 ? e.shift.cursor : "grab", h = ((a = e == null ? void 0 : e.events) == null ? void 0 : a.onBeforeTransformStarted) ?? (() => {
|
|
1564
|
+
}), d = ((g = e == null ? void 0 : e.events) == null ? void 0 : g.onTransformFinished) ?? (() => {
|
|
1538
1565
|
});
|
|
1539
1566
|
return {
|
|
1540
1567
|
wheelSensitivity: o,
|
|
1541
|
-
onBeforeTransformStarted:
|
|
1542
|
-
onTransformFinished:
|
|
1568
|
+
onBeforeTransformStarted: h,
|
|
1569
|
+
onTransformFinished: d,
|
|
1543
1570
|
transformPreprocessor: i,
|
|
1544
|
-
shiftCursor:
|
|
1571
|
+
shiftCursor: s
|
|
1545
1572
|
};
|
|
1546
1573
|
}, W = (e) => {
|
|
1547
1574
|
const t = [], o = e.touches.length;
|
|
1548
|
-
for (let
|
|
1549
|
-
t.push([e.touches[
|
|
1575
|
+
for (let d = 0; d < o; d++)
|
|
1576
|
+
t.push([e.touches[d].clientX, e.touches[d].clientY]);
|
|
1550
1577
|
const r = t.reduce(
|
|
1551
|
-
(
|
|
1578
|
+
(d, c) => [d[0] + c[0], d[1] + c[1]],
|
|
1552
1579
|
[0, 0]
|
|
1553
|
-
), i = [r[0] / o, r[1] / o],
|
|
1554
|
-
(
|
|
1580
|
+
), i = [r[0] / o, r[1] / o], h = t.map((d) => [d[0] - i[0], d[1] - i[1]]).reduce(
|
|
1581
|
+
(d, c) => d + Math.sqrt(c[0] * c[0] + c[1] * c[1]),
|
|
1555
1582
|
0
|
|
1556
1583
|
);
|
|
1557
1584
|
return {
|
|
1558
1585
|
x: i[0],
|
|
1559
1586
|
y: i[1],
|
|
1560
|
-
scale:
|
|
1587
|
+
scale: h / o,
|
|
1561
1588
|
touchesCnt: o,
|
|
1562
1589
|
touches: t
|
|
1563
1590
|
};
|
|
1564
|
-
},
|
|
1591
|
+
}, Nt = (e, t, o) => ({
|
|
1565
1592
|
scale: e.scale,
|
|
1566
1593
|
dx: e.dx + e.scale * t,
|
|
1567
1594
|
dy: e.dy + e.scale * o
|
|
1568
|
-
}),
|
|
1595
|
+
}), Ct = (e, t, o, r) => ({
|
|
1569
1596
|
scale: e.scale * t,
|
|
1570
1597
|
dx: e.scale * (1 - t) * o + e.dx,
|
|
1571
1598
|
dy: e.scale * (1 - t) * r + e.dy
|
|
1572
1599
|
});
|
|
1573
1600
|
class Pt {
|
|
1574
1601
|
constructor(t, o) {
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1602
|
+
n(this, "model");
|
|
1603
|
+
n(this, "transformation");
|
|
1604
|
+
n(this, "element", null);
|
|
1605
|
+
n(this, "prevTouches", null);
|
|
1606
|
+
n(this, "window", window);
|
|
1607
|
+
n(this, "onMouseDown", (t) => {
|
|
1581
1608
|
this.element === null || t.button !== 0 || (D(this.element, this.options.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove), this.window.addEventListener("mouseup", this.onWindowMouseUp));
|
|
1582
1609
|
});
|
|
1583
|
-
|
|
1610
|
+
n(this, "onWindowMouseMove", (t) => {
|
|
1584
1611
|
if (this.element === null || !P(this.element, t.clientX, t.clientY) || !L(this.window, t.clientX, t.clientY)) {
|
|
1585
1612
|
this.stopMouseDrag();
|
|
1586
1613
|
return;
|
|
@@ -1588,24 +1615,24 @@ class Pt {
|
|
|
1588
1615
|
const o = -t.movementX, r = -t.movementY;
|
|
1589
1616
|
this.moveViewport(this.element, o, r);
|
|
1590
1617
|
});
|
|
1591
|
-
|
|
1618
|
+
n(this, "onWindowMouseUp", (t) => {
|
|
1592
1619
|
this.element === null || t.button !== 0 || this.stopMouseDrag();
|
|
1593
1620
|
});
|
|
1594
|
-
|
|
1621
|
+
n(this, "onWheelScroll", (t) => {
|
|
1595
1622
|
t.preventDefault();
|
|
1596
|
-
const { left: o, top: r } = this.element.getBoundingClientRect(), i = t.clientX - o,
|
|
1597
|
-
this.scaleViewport(this.element,
|
|
1623
|
+
const { left: o, top: r } = this.element.getBoundingClientRect(), i = t.clientX - o, s = t.clientY - r, d = 1 / (t.deltaY < 0 ? this.options.wheelSensitivity : 1 / this.options.wheelSensitivity);
|
|
1624
|
+
this.scaleViewport(this.element, d, i, s);
|
|
1598
1625
|
});
|
|
1599
|
-
|
|
1626
|
+
n(this, "onTouchStart", (t) => {
|
|
1600
1627
|
this.prevTouches = W(t), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish);
|
|
1601
1628
|
});
|
|
1602
|
-
|
|
1629
|
+
n(this, "onWindowTouchMove", (t) => {
|
|
1603
1630
|
const o = this.element;
|
|
1604
1631
|
if (o === null)
|
|
1605
1632
|
return;
|
|
1606
1633
|
const r = W(t);
|
|
1607
1634
|
if (!r.touches.every(
|
|
1608
|
-
(
|
|
1635
|
+
(s) => P(o, s[0], s[1]) && L(this.window, s[0], s[1])
|
|
1609
1636
|
)) {
|
|
1610
1637
|
this.stopTouchDrag();
|
|
1611
1638
|
return;
|
|
@@ -1615,15 +1642,15 @@ class Pt {
|
|
|
1615
1642
|
-(r.x - this.prevTouches.x),
|
|
1616
1643
|
-(r.y - this.prevTouches.y)
|
|
1617
1644
|
), r.touchesCnt === 2) {
|
|
1618
|
-
const { left:
|
|
1619
|
-
this.scaleViewport(o, a,
|
|
1645
|
+
const { left: s, top: h } = o.getBoundingClientRect(), d = this.prevTouches.x - s, c = this.prevTouches.y - h, a = 1 / (r.scale / this.prevTouches.scale);
|
|
1646
|
+
this.scaleViewport(o, a, d, c);
|
|
1620
1647
|
}
|
|
1621
1648
|
this.prevTouches = r;
|
|
1622
1649
|
});
|
|
1623
|
-
|
|
1650
|
+
n(this, "onWindowTouchFinish", (t) => {
|
|
1624
1651
|
t.touches.length > 0 ? this.prevTouches = W(t) : this.stopTouchDrag();
|
|
1625
1652
|
});
|
|
1626
|
-
|
|
1653
|
+
n(this, "observer", new ResizeObserver(() => {
|
|
1627
1654
|
const t = this.canvas.transformation.getViewportMatrix(), { width: o, height: r } = this.element.getBoundingClientRect(), i = this.options.transformPreprocessor({
|
|
1628
1655
|
prevTransform: t,
|
|
1629
1656
|
nextTransform: t,
|
|
@@ -1632,7 +1659,7 @@ class Pt {
|
|
|
1632
1659
|
});
|
|
1633
1660
|
this.canvas.patchViewportMatrix(i), this.options.onTransformFinished();
|
|
1634
1661
|
}));
|
|
1635
|
-
|
|
1662
|
+
n(this, "options");
|
|
1636
1663
|
this.canvas = t, this.options = Mt(o), this.transformation = this.canvas.transformation, this.model = this.canvas.model;
|
|
1637
1664
|
}
|
|
1638
1665
|
attach(t) {
|
|
@@ -1682,21 +1709,21 @@ class Pt {
|
|
|
1682
1709
|
}
|
|
1683
1710
|
moveViewport(t, o, r) {
|
|
1684
1711
|
this.options.onBeforeTransformStarted();
|
|
1685
|
-
const i = this.transformation.getViewportMatrix(),
|
|
1712
|
+
const i = this.transformation.getViewportMatrix(), s = Nt(i, o, r), { width: h, height: d } = t.getBoundingClientRect(), c = this.options.transformPreprocessor({
|
|
1686
1713
|
prevTransform: i,
|
|
1687
|
-
nextTransform:
|
|
1688
|
-
canvasWidth:
|
|
1689
|
-
canvasHeight:
|
|
1714
|
+
nextTransform: s,
|
|
1715
|
+
canvasWidth: h,
|
|
1716
|
+
canvasHeight: d
|
|
1690
1717
|
});
|
|
1691
|
-
this.canvas.patchViewportMatrix(
|
|
1718
|
+
this.canvas.patchViewportMatrix(c), this.options.onTransformFinished();
|
|
1692
1719
|
}
|
|
1693
1720
|
scaleViewport(t, o, r, i) {
|
|
1694
1721
|
this.options.onBeforeTransformStarted();
|
|
1695
|
-
const
|
|
1696
|
-
prevTransform:
|
|
1697
|
-
nextTransform:
|
|
1698
|
-
canvasWidth:
|
|
1699
|
-
canvasHeight:
|
|
1722
|
+
const s = this.canvas.transformation.getViewportMatrix(), h = Ct(s, o, r, i), { width: d, height: c } = t.getBoundingClientRect(), l = this.options.transformPreprocessor({
|
|
1723
|
+
prevTransform: s,
|
|
1724
|
+
nextTransform: h,
|
|
1725
|
+
canvasWidth: d,
|
|
1726
|
+
canvasHeight: c
|
|
1700
1727
|
});
|
|
1701
1728
|
this.canvas.patchViewportMatrix(l), this.options.onTransformFinished();
|
|
1702
1729
|
}
|
|
@@ -1715,8 +1742,8 @@ class Pt {
|
|
|
1715
1742
|
}
|
|
1716
1743
|
class Lt {
|
|
1717
1744
|
constructor() {
|
|
1718
|
-
|
|
1719
|
-
|
|
1745
|
+
n(this, "keyMap", /* @__PURE__ */ new Map());
|
|
1746
|
+
n(this, "valueMap", /* @__PURE__ */ new Map());
|
|
1720
1747
|
}
|
|
1721
1748
|
set(t, o) {
|
|
1722
1749
|
this.keyMap.set(t, o), this.valueMap.set(o, t);
|
|
@@ -1752,13 +1779,13 @@ class Lt {
|
|
|
1752
1779
|
}
|
|
1753
1780
|
class Dt {
|
|
1754
1781
|
constructor(t) {
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1782
|
+
n(this, "transformation");
|
|
1783
|
+
n(this, "model");
|
|
1784
|
+
n(this, "nodes", new Lt());
|
|
1785
|
+
n(this, "nodeIdGenerator", new N(
|
|
1759
1786
|
(t) => this.nodes.hasKey(t)
|
|
1760
1787
|
));
|
|
1761
|
-
|
|
1788
|
+
n(this, "nodesResizeObserver");
|
|
1762
1789
|
this.canvas = t, this.nodesResizeObserver = new window.ResizeObserver((o) => {
|
|
1763
1790
|
o.forEach((r) => {
|
|
1764
1791
|
const i = r.target;
|
|
@@ -1826,12 +1853,12 @@ class Dt {
|
|
|
1826
1853
|
}
|
|
1827
1854
|
class mt {
|
|
1828
1855
|
constructor() {
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1856
|
+
n(this, "coreOptions");
|
|
1857
|
+
n(this, "dragOptions");
|
|
1858
|
+
n(this, "transformOptions");
|
|
1859
|
+
n(this, "isDraggable", !1);
|
|
1860
|
+
n(this, "isTransformable", !1);
|
|
1861
|
+
n(this, "hasResizeReactiveNodes", !1);
|
|
1835
1862
|
}
|
|
1836
1863
|
setOptions(t) {
|
|
1837
1864
|
return this.coreOptions = t, this;
|