@html-graph/html-graph 0.1.2 → 0.1.4
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 +20 -34
- package/dist/main.d.ts +4 -4
- package/dist/main.js +451 -441
- package/dist/main.umd.cjs +1 -1
- package/package.json +3 -1
package/dist/main.js
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
var O = Object.defineProperty;
|
|
2
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
|
|
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
|
+
}, N = (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
|
|
25
|
-
e.forEach((d,
|
|
26
|
-
let l = 0, a = 0,
|
|
27
|
-
const y =
|
|
28
|
-
if (y && (l = -
|
|
29
|
-
const z = e[
|
|
30
|
-
|
|
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
|
-
|
|
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
34
|
`C ${d.x} ${d.y} ${d.x} ${d.y} ${X.x} ${X.y}`
|
|
35
35
|
);
|
|
36
36
|
});
|
|
@@ -55,20 +55,20 @@ const _ = (e, t) => ({
|
|
|
55
55
|
}, r = {
|
|
56
56
|
x: t.x + t.width / 2,
|
|
57
57
|
y: t.y + t.height / 2
|
|
58
|
-
},
|
|
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
|
-
x:
|
|
61
|
-
y:
|
|
62
|
-
width:
|
|
60
|
+
x: i,
|
|
61
|
+
y: s,
|
|
62
|
+
width: h,
|
|
63
63
|
height: d,
|
|
64
|
-
flipX:
|
|
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,
|
|
@@ -76,160 +76,160 @@ const _ = (e, t) => ({
|
|
|
76
76
|
), r = {
|
|
77
77
|
x: t.x + e.fromVect.x * e.curvature,
|
|
78
78
|
y: t.y + e.fromVect.y * e.curvature
|
|
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,
|
|
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 +
|
|
104
|
+
), g = {
|
|
105
|
+
x: a.x + h,
|
|
106
106
|
y: a.y + d
|
|
107
|
-
}, y = { x: (l.x +
|
|
108
|
-
x:
|
|
109
|
-
y:
|
|
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
113
|
}, p = {
|
|
114
|
-
x:
|
|
115
|
-
y:
|
|
114
|
+
x: c.x + h,
|
|
115
|
+
y: c.y + d
|
|
116
116
|
}, M = {
|
|
117
|
-
x: a.x +
|
|
117
|
+
x: a.x + h,
|
|
118
118
|
y: a.y + d
|
|
119
119
|
};
|
|
120
120
|
return [
|
|
121
121
|
`M ${t.x} ${t.y}`,
|
|
122
|
-
`L ${
|
|
122
|
+
`L ${c.x} ${c.y}`,
|
|
123
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,
|
|
137
|
-
{ x: e.to.x -
|
|
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
|
+
{ x: e.to.x - i, y: e.to.y },
|
|
138
138
|
e.toVect,
|
|
139
139
|
e.to
|
|
140
|
-
), d = Math.max((
|
|
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
141
|
x: e.flipX > 0 ? e.to.x - d : e.to.x + r,
|
|
142
|
-
y:
|
|
143
|
-
}, y = { x:
|
|
144
|
-
return
|
|
145
|
-
[t,
|
|
142
|
+
y: h.y
|
|
143
|
+
}, y = { x: g.x, y: c };
|
|
144
|
+
return N(
|
|
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
|
-
) : e.to, r = e.arrowLength + e.arrowOffset,
|
|
158
|
-
{ x: r, y:
|
|
157
|
+
) : e.to, r = e.arrowLength + e.arrowOffset, i = f(
|
|
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,
|
|
165
|
+
), g = { x: a.x + d, y: a.y + c };
|
|
166
|
+
return N(
|
|
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,
|
|
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 N([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,
|
|
195
|
-
{ x: e.to.x -
|
|
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
|
+
{ x: e.to.x - i, y: e.to.y },
|
|
196
196
|
e.toVect,
|
|
197
197
|
e.to
|
|
198
|
-
), d = Math.max((
|
|
199
|
-
x:
|
|
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
200
|
y: e.flipY > 0 ? e.to.y - d : e.to.y + r
|
|
201
|
-
}, y = { x:
|
|
202
|
-
return
|
|
203
|
-
[t,
|
|
201
|
+
}, y = { x: c, y: g.y };
|
|
202
|
+
return N(
|
|
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,
|
|
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
|
-
{ x:
|
|
212
|
-
{ x:
|
|
211
|
+
{ x: i, y: e.side },
|
|
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
|
-
), d = `M ${
|
|
219
|
-
return `${e.hasSourceArrow || e.hasTargetArrow ? "" : d}${
|
|
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}${N(h, e.roundness)}`;
|
|
220
220
|
}, et = (e) => {
|
|
221
|
-
const t = e.smallRadius, o = e.radius, r = Math.sqrt(t * t + o * 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,
|
|
@@ -248,55 +248,55 @@ const _ = (e, t) => ({
|
|
|
248
248
|
});
|
|
249
249
|
class ot {
|
|
250
250
|
constructor(t) {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
this.arrowLength = (t == null ? void 0 : t.arrowLength) ??
|
|
266
|
-
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;
|
|
267
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));
|
|
268
268
|
}
|
|
269
269
|
render(t) {
|
|
270
|
-
const { x: o, y: r, width:
|
|
270
|
+
const { x: o, y: r, width: i, height: s, flipX: h, flipY: d } = b(
|
|
271
271
|
t.source,
|
|
272
272
|
t.target
|
|
273
273
|
);
|
|
274
|
-
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${
|
|
275
|
-
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(
|
|
276
276
|
t.source.direction,
|
|
277
|
-
|
|
277
|
+
h,
|
|
278
278
|
d
|
|
279
279
|
), l = A(
|
|
280
280
|
t.target.direction,
|
|
281
|
-
|
|
281
|
+
h,
|
|
282
282
|
d
|
|
283
283
|
), a = {
|
|
284
|
-
x:
|
|
285
|
-
y:
|
|
284
|
+
x: i,
|
|
285
|
+
y: s
|
|
286
286
|
};
|
|
287
|
-
let
|
|
288
|
-
if (t.source.portId === t.target.portId ? (
|
|
289
|
-
fromVect:
|
|
287
|
+
let g, y = l, x = -this.arrowLength;
|
|
288
|
+
if (t.source.portId === t.target.portId ? (g = et({
|
|
289
|
+
fromVect: c,
|
|
290
290
|
radius: this.portCycleRadius,
|
|
291
291
|
smallRadius: this.portCycleSmallRadius,
|
|
292
292
|
arrowLength: this.arrowLength,
|
|
293
293
|
hasSourceArrow: this.hasSourceArrow,
|
|
294
294
|
hasTargetArrow: this.hasTargetArrow
|
|
295
|
-
}), y =
|
|
295
|
+
}), y = c, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g = Q({
|
|
296
296
|
to: a,
|
|
297
|
-
fromVect:
|
|
297
|
+
fromVect: c,
|
|
298
298
|
toVect: l,
|
|
299
|
-
flipX:
|
|
299
|
+
flipX: h,
|
|
300
300
|
flipY: d,
|
|
301
301
|
arrowLength: this.arrowLength,
|
|
302
302
|
detourDirection: this.detourDirection,
|
|
@@ -304,18 +304,18 @@ class ot {
|
|
|
304
304
|
curvature: this.curvature,
|
|
305
305
|
hasSourceArrow: this.hasSourceArrow,
|
|
306
306
|
hasTargetArrow: this.hasTargetArrow
|
|
307
|
-
}) :
|
|
307
|
+
}) : g = J({
|
|
308
308
|
to: a,
|
|
309
|
-
fromVect:
|
|
309
|
+
fromVect: c,
|
|
310
310
|
toVect: l,
|
|
311
311
|
arrowLength: this.arrowLength,
|
|
312
312
|
curvature: this.curvature,
|
|
313
313
|
hasSourceArrow: this.hasSourceArrow,
|
|
314
314
|
hasTargetArrow: this.hasTargetArrow
|
|
315
|
-
}), this.line.setAttribute("d",
|
|
315
|
+
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
316
316
|
const v = E(
|
|
317
|
-
|
|
318
|
-
|
|
317
|
+
c,
|
|
318
|
+
w,
|
|
319
319
|
this.arrowLength,
|
|
320
320
|
this.arrowWidth
|
|
321
321
|
);
|
|
@@ -334,62 +334,62 @@ class ot {
|
|
|
334
334
|
}
|
|
335
335
|
class rt {
|
|
336
336
|
constructor(t) {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
this.arrowLength = (t == null ? void 0 : t.arrowLength) ??
|
|
352
|
-
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;
|
|
353
353
|
this.roundness = Math.min(
|
|
354
354
|
o,
|
|
355
355
|
this.arrowOffset,
|
|
356
356
|
this.cycleSquareSide / 2
|
|
357
|
-
), this.detourDirection = (t == null ? void 0 : t.detourDirection) ??
|
|
358
|
-
const r = (t == null ? void 0 : t.color) ??
|
|
359
|
-
this.svg.appendChild(this.group), this.line = m(r,
|
|
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;
|
|
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));
|
|
360
360
|
}
|
|
361
361
|
render(t) {
|
|
362
|
-
const { x: o, y: r, width:
|
|
362
|
+
const { x: o, y: r, width: i, height: s, flipX: h, flipY: d } = b(
|
|
363
363
|
t.source,
|
|
364
364
|
t.target
|
|
365
365
|
);
|
|
366
|
-
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${
|
|
367
|
-
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(
|
|
368
368
|
t.source.direction,
|
|
369
|
-
|
|
369
|
+
h,
|
|
370
370
|
d
|
|
371
371
|
), l = A(
|
|
372
372
|
t.target.direction,
|
|
373
|
-
|
|
373
|
+
h,
|
|
374
374
|
d
|
|
375
375
|
), a = {
|
|
376
|
-
x:
|
|
377
|
-
y:
|
|
376
|
+
x: i,
|
|
377
|
+
y: s
|
|
378
378
|
};
|
|
379
|
-
let
|
|
380
|
-
if (t.source.portId === t.target.portId ? (
|
|
381
|
-
fromVect:
|
|
379
|
+
let g, y = l, x = -this.arrowLength;
|
|
380
|
+
if (t.source.portId === t.target.portId ? (g = Y({
|
|
381
|
+
fromVect: c,
|
|
382
382
|
arrowLength: this.arrowLength,
|
|
383
383
|
side: this.cycleSquareSide,
|
|
384
384
|
arrowOffset: this.arrowOffset,
|
|
385
385
|
roundness: this.roundness,
|
|
386
386
|
hasSourceArrow: this.hasSourceArrow,
|
|
387
387
|
hasTargetArrow: this.hasTargetArrow
|
|
388
|
-
}), y =
|
|
388
|
+
}), y = c, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g = R({
|
|
389
389
|
to: a,
|
|
390
|
-
fromVect:
|
|
390
|
+
fromVect: c,
|
|
391
391
|
toVect: l,
|
|
392
|
-
flipX:
|
|
392
|
+
flipX: h,
|
|
393
393
|
flipY: d,
|
|
394
394
|
arrowLength: this.arrowLength,
|
|
395
395
|
arrowOffset: this.arrowOffset,
|
|
@@ -398,20 +398,20 @@ class rt {
|
|
|
398
398
|
detourDistance: this.detourDistance,
|
|
399
399
|
hasSourceArrow: this.hasSourceArrow,
|
|
400
400
|
hasTargetArrow: this.hasTargetArrow
|
|
401
|
-
}) :
|
|
401
|
+
}) : g = Z({
|
|
402
402
|
to: a,
|
|
403
|
-
fromVect:
|
|
403
|
+
fromVect: c,
|
|
404
404
|
toVect: l,
|
|
405
|
-
flipX:
|
|
405
|
+
flipX: h,
|
|
406
406
|
arrowLength: this.arrowLength,
|
|
407
407
|
arrowOffset: this.arrowOffset,
|
|
408
408
|
roundness: this.roundness,
|
|
409
409
|
hasSourceArrow: this.hasSourceArrow,
|
|
410
410
|
hasTargetArrow: this.hasTargetArrow
|
|
411
|
-
}), this.line.setAttribute("d",
|
|
411
|
+
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
412
412
|
const v = E(
|
|
413
|
-
|
|
414
|
-
|
|
413
|
+
c,
|
|
414
|
+
w,
|
|
415
415
|
this.arrowLength,
|
|
416
416
|
this.arrowWidth
|
|
417
417
|
);
|
|
@@ -430,62 +430,62 @@ class rt {
|
|
|
430
430
|
}
|
|
431
431
|
class it {
|
|
432
432
|
constructor(t) {
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
this.arrowLength = (t == null ? void 0 : t.arrowLength) ??
|
|
448
|
-
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;
|
|
449
449
|
this.roundness = Math.min(
|
|
450
450
|
o,
|
|
451
451
|
this.arrowOffset,
|
|
452
452
|
this.cycleSquareSide / 2
|
|
453
|
-
), this.detourDirection = (t == null ? void 0 : t.detourDirection) ??
|
|
454
|
-
const r = (t == null ? void 0 : t.color) ??
|
|
455
|
-
this.svg.appendChild(this.group), this.line = m(r,
|
|
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;
|
|
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));
|
|
456
456
|
}
|
|
457
457
|
render(t) {
|
|
458
|
-
const { x: o, y: r, width:
|
|
458
|
+
const { x: o, y: r, width: i, height: s, flipX: h, flipY: d } = b(
|
|
459
459
|
t.source,
|
|
460
460
|
t.target
|
|
461
461
|
);
|
|
462
|
-
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${
|
|
463
|
-
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(
|
|
464
464
|
t.source.direction,
|
|
465
|
-
|
|
465
|
+
h,
|
|
466
466
|
d
|
|
467
467
|
), l = A(
|
|
468
468
|
t.target.direction,
|
|
469
|
-
|
|
469
|
+
h,
|
|
470
470
|
d
|
|
471
471
|
), a = {
|
|
472
|
-
x:
|
|
473
|
-
y:
|
|
472
|
+
x: i,
|
|
473
|
+
y: s
|
|
474
474
|
};
|
|
475
|
-
let
|
|
476
|
-
if (t.source.portId === t.target.portId ? (
|
|
477
|
-
fromVect:
|
|
475
|
+
let g, y = l, x = -this.arrowLength;
|
|
476
|
+
if (t.source.portId === t.target.portId ? (g = Y({
|
|
477
|
+
fromVect: c,
|
|
478
478
|
arrowLength: this.arrowLength,
|
|
479
479
|
side: this.cycleSquareSide,
|
|
480
480
|
arrowOffset: this.arrowOffset,
|
|
481
481
|
roundness: this.roundness,
|
|
482
482
|
hasSourceArrow: this.hasSourceArrow,
|
|
483
483
|
hasTargetArrow: this.hasTargetArrow
|
|
484
|
-
}), y =
|
|
484
|
+
}), y = c, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g = R({
|
|
485
485
|
to: a,
|
|
486
|
-
fromVect:
|
|
486
|
+
fromVect: c,
|
|
487
487
|
toVect: l,
|
|
488
|
-
flipX:
|
|
488
|
+
flipX: h,
|
|
489
489
|
flipY: d,
|
|
490
490
|
arrowLength: this.arrowLength,
|
|
491
491
|
arrowOffset: this.arrowOffset,
|
|
@@ -494,19 +494,19 @@ class it {
|
|
|
494
494
|
detourDistance: this.detourDistance,
|
|
495
495
|
hasSourceArrow: this.hasSourceArrow,
|
|
496
496
|
hasTargetArrow: this.hasTargetArrow
|
|
497
|
-
}) :
|
|
497
|
+
}) : g = q({
|
|
498
498
|
to: a,
|
|
499
|
-
fromVect:
|
|
499
|
+
fromVect: c,
|
|
500
500
|
toVect: l,
|
|
501
501
|
arrowLength: this.arrowLength,
|
|
502
502
|
arrowOffset: this.arrowOffset,
|
|
503
503
|
roundness: this.roundness,
|
|
504
504
|
hasSourceArrow: this.hasSourceArrow,
|
|
505
505
|
hasTargetArrow: this.hasTargetArrow
|
|
506
|
-
}), this.line.setAttribute("d",
|
|
506
|
+
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
507
507
|
const v = E(
|
|
508
|
-
|
|
509
|
-
|
|
508
|
+
c,
|
|
509
|
+
w,
|
|
510
510
|
this.arrowLength,
|
|
511
511
|
this.arrowWidth
|
|
512
512
|
);
|
|
@@ -525,62 +525,62 @@ class it {
|
|
|
525
525
|
}
|
|
526
526
|
class nt {
|
|
527
527
|
constructor(t) {
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
this.arrowLength = (t == null ? void 0 : t.arrowLength) ??
|
|
543
|
-
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;
|
|
544
544
|
this.roundness = Math.min(
|
|
545
545
|
o,
|
|
546
546
|
this.arrowOffset,
|
|
547
547
|
this.cycleSquareSide / 2
|
|
548
|
-
), this.detourDirection = (t == null ? void 0 : t.detourDirection) ??
|
|
549
|
-
const r = (t == null ? void 0 : t.color) ??
|
|
550
|
-
this.svg.appendChild(this.group), this.line = m(r,
|
|
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;
|
|
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));
|
|
551
551
|
}
|
|
552
552
|
render(t) {
|
|
553
|
-
const { x: o, y: r, width:
|
|
553
|
+
const { x: o, y: r, width: i, height: s, flipX: h, flipY: d } = b(
|
|
554
554
|
t.source,
|
|
555
555
|
t.target
|
|
556
556
|
);
|
|
557
|
-
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${
|
|
558
|
-
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(
|
|
559
559
|
t.source.direction,
|
|
560
|
-
|
|
560
|
+
h,
|
|
561
561
|
d
|
|
562
562
|
), l = A(
|
|
563
563
|
t.target.direction,
|
|
564
|
-
|
|
564
|
+
h,
|
|
565
565
|
d
|
|
566
566
|
), a = {
|
|
567
|
-
x:
|
|
568
|
-
y:
|
|
567
|
+
x: i,
|
|
568
|
+
y: s
|
|
569
569
|
};
|
|
570
|
-
let
|
|
571
|
-
if (t.source.portId === t.target.portId ? (
|
|
572
|
-
fromVect:
|
|
570
|
+
let g, y = l, x = -this.arrowLength;
|
|
571
|
+
if (t.source.portId === t.target.portId ? (g = Y({
|
|
572
|
+
fromVect: c,
|
|
573
573
|
arrowLength: this.arrowLength,
|
|
574
574
|
side: this.cycleSquareSide,
|
|
575
575
|
arrowOffset: this.arrowOffset,
|
|
576
576
|
roundness: this.roundness,
|
|
577
577
|
hasSourceArrow: this.hasSourceArrow,
|
|
578
578
|
hasTargetArrow: this.hasTargetArrow
|
|
579
|
-
}), y =
|
|
579
|
+
}), y = c, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g = R({
|
|
580
580
|
to: a,
|
|
581
|
-
fromVect:
|
|
581
|
+
fromVect: c,
|
|
582
582
|
toVect: l,
|
|
583
|
-
flipX:
|
|
583
|
+
flipX: h,
|
|
584
584
|
flipY: d,
|
|
585
585
|
arrowLength: this.arrowLength,
|
|
586
586
|
arrowOffset: this.arrowOffset,
|
|
@@ -589,9 +589,9 @@ class nt {
|
|
|
589
589
|
detourDistance: this.detourDistance,
|
|
590
590
|
hasSourceArrow: this.hasSourceArrow,
|
|
591
591
|
hasTargetArrow: this.hasTargetArrow
|
|
592
|
-
}) :
|
|
592
|
+
}) : g = tt({
|
|
593
593
|
to: a,
|
|
594
|
-
fromVect:
|
|
594
|
+
fromVect: c,
|
|
595
595
|
toVect: l,
|
|
596
596
|
flipY: d,
|
|
597
597
|
arrowLength: this.arrowLength,
|
|
@@ -599,10 +599,10 @@ class nt {
|
|
|
599
599
|
roundness: this.roundness,
|
|
600
600
|
hasSourceArrow: this.hasSourceArrow,
|
|
601
601
|
hasTargetArrow: this.hasTargetArrow
|
|
602
|
-
}), this.line.setAttribute("d",
|
|
602
|
+
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
603
603
|
const v = E(
|
|
604
|
-
|
|
605
|
-
|
|
604
|
+
c,
|
|
605
|
+
w,
|
|
606
606
|
this.arrowLength,
|
|
607
607
|
this.arrowWidth
|
|
608
608
|
);
|
|
@@ -686,41 +686,41 @@ const st = (e) => {
|
|
|
686
686
|
}, ht = (e, t) => {
|
|
687
687
|
let o = G, r = G;
|
|
688
688
|
e === "incremental" && (o = V()), t === "incremental" && (r = V());
|
|
689
|
-
const
|
|
690
|
-
return e === "shared-incremental" && (o =
|
|
689
|
+
const i = V();
|
|
690
|
+
return e === "shared-incremental" && (o = i), t === "shared-incremental" && (r = i), typeof e == "number" && (o = F(e)), typeof t == "number" && (r = F(t)), typeof e == "function" && (o = e), typeof t == "function" && (r = t), {
|
|
691
691
|
nodesPriorityFn: o,
|
|
692
692
|
edgesPriorityFn: r
|
|
693
693
|
};
|
|
694
694
|
}, dt = (e) => {
|
|
695
|
-
var o, r,
|
|
695
|
+
var o, r, i, s, h;
|
|
696
696
|
const t = ht(
|
|
697
697
|
(o = e == null ? void 0 : e.nodes) == null ? void 0 : o.priority,
|
|
698
698
|
(r = e == null ? void 0 : e.edges) == null ? void 0 : r.priority
|
|
699
699
|
);
|
|
700
700
|
return {
|
|
701
701
|
nodes: {
|
|
702
|
-
centerFn: ((
|
|
702
|
+
centerFn: ((i = e == null ? void 0 : e.nodes) == null ? void 0 : i.centerFn) ?? _,
|
|
703
703
|
priorityFn: t.nodesPriorityFn
|
|
704
704
|
},
|
|
705
705
|
ports: {
|
|
706
|
-
direction: ((
|
|
706
|
+
direction: ((s = e == null ? void 0 : e.ports) == null ? void 0 : s.direction) ?? 0
|
|
707
707
|
},
|
|
708
708
|
edges: {
|
|
709
|
-
shapeFactory: st(((
|
|
709
|
+
shapeFactory: st(((h = e == null ? void 0 : e.edges) == null ? void 0 : h.shape) ?? {}),
|
|
710
710
|
priorityFn: t.edgesPriorityFn
|
|
711
711
|
}
|
|
712
712
|
};
|
|
713
713
|
};
|
|
714
714
|
class ct {
|
|
715
715
|
constructor() {
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
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());
|
|
724
724
|
}
|
|
725
725
|
addNode(t) {
|
|
726
726
|
this.nodes.set(t.nodeId, {
|
|
@@ -799,8 +799,8 @@ class ct {
|
|
|
799
799
|
return this.edges.get(t);
|
|
800
800
|
}
|
|
801
801
|
removeEdge(t) {
|
|
802
|
-
const o = this.edges.get(t), r = o.from,
|
|
803
|
-
this.cycleEdges.get(r).delete(t), this.cycleEdges.get(
|
|
802
|
+
const o = this.edges.get(t), r = o.from, i = o.to;
|
|
803
|
+
this.cycleEdges.get(r).delete(t), this.cycleEdges.get(i).delete(t), this.incommingEdges.get(r).delete(t), this.incommingEdges.get(i).delete(t), this.outcommingEdges.get(r).delete(t), this.outcommingEdges.get(i).delete(t), this.edges.delete(t);
|
|
804
804
|
}
|
|
805
805
|
clear() {
|
|
806
806
|
this.nodes.clear(), this.ports.clear(), this.nodePorts.clear(), this.portNodeId.clear(), this.edges.clear(), this.incommingEdges.clear(), this.outcommingEdges.clear(), this.cycleEdges.clear();
|
|
@@ -824,22 +824,22 @@ class ct {
|
|
|
824
824
|
getNodeIncomingEdgeIds(t) {
|
|
825
825
|
const o = Array.from(this.nodePorts.get(t).keys());
|
|
826
826
|
let r = [];
|
|
827
|
-
return o.forEach((
|
|
828
|
-
r = [...r, ...this.getPortIncomingEdgeIds(
|
|
827
|
+
return o.forEach((i) => {
|
|
828
|
+
r = [...r, ...this.getPortIncomingEdgeIds(i)];
|
|
829
829
|
}), r;
|
|
830
830
|
}
|
|
831
831
|
getNodeOutcomingEdgeIds(t) {
|
|
832
832
|
const o = Array.from(this.nodePorts.get(t).keys());
|
|
833
833
|
let r = [];
|
|
834
|
-
return o.forEach((
|
|
835
|
-
r = [...r, ...this.getPortOutcomingEdgeIds(
|
|
834
|
+
return o.forEach((i) => {
|
|
835
|
+
r = [...r, ...this.getPortOutcomingEdgeIds(i)];
|
|
836
836
|
}), r;
|
|
837
837
|
}
|
|
838
838
|
getNodeCycleEdgeIds(t) {
|
|
839
839
|
const o = Array.from(this.nodePorts.get(t).keys());
|
|
840
840
|
let r = [];
|
|
841
|
-
return o.forEach((
|
|
842
|
-
r = [...r, ...this.getPortCycleEdgeIds(
|
|
841
|
+
return o.forEach((i) => {
|
|
842
|
+
r = [...r, ...this.getPortCycleEdgeIds(i)];
|
|
843
843
|
}), r;
|
|
844
844
|
}
|
|
845
845
|
getNodeAdjacentEdgeIds(t) {
|
|
@@ -926,8 +926,8 @@ const j = (e) => ({
|
|
|
926
926
|
};
|
|
927
927
|
class at {
|
|
928
928
|
constructor() {
|
|
929
|
-
|
|
930
|
-
|
|
929
|
+
n(this, "viewportMatrix", H);
|
|
930
|
+
n(this, "contentMatrix", H);
|
|
931
931
|
}
|
|
932
932
|
getViewportMatrix() {
|
|
933
933
|
return this.viewportMatrix;
|
|
@@ -973,11 +973,11 @@ const ut = () => {
|
|
|
973
973
|
};
|
|
974
974
|
class ft {
|
|
975
975
|
constructor(t, o) {
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
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());
|
|
981
981
|
this.graphStore = t, this.viewportTransformer = o, this.host.appendChild(this.container);
|
|
982
982
|
}
|
|
983
983
|
attach(t) {
|
|
@@ -1017,8 +1017,8 @@ class ft {
|
|
|
1017
1017
|
this.clear(), this.detach(), this.host.removeChild(this.container);
|
|
1018
1018
|
}
|
|
1019
1019
|
updateNodeCoordinates(t) {
|
|
1020
|
-
const o = this.nodeIdToWrapperElementMap.get(t), r = this.graphStore.getNode(t), { width:
|
|
1021
|
-
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)`;
|
|
1022
1022
|
}
|
|
1023
1023
|
updateNodePriority(t) {
|
|
1024
1024
|
const o = this.graphStore.getNode(t), r = this.nodeIdToWrapperElementMap.get(t);
|
|
@@ -1031,31 +1031,31 @@ class ft {
|
|
|
1031
1031
|
this.edgeIdToElementMap.set(t, r.shape.svg), this.container.appendChild(r.shape.svg);
|
|
1032
1032
|
}
|
|
1033
1033
|
renderEdge(t) {
|
|
1034
|
-
const o = this.graphStore.getEdge(t), r = this.graphStore.getPort(o.from),
|
|
1035
|
-
x:
|
|
1036
|
-
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
|
|
1037
1037
|
}, a = {
|
|
1038
|
-
x:
|
|
1039
|
-
y:
|
|
1040
|
-
},
|
|
1038
|
+
x: c.scale * (h.left - d.left) + c.dx,
|
|
1039
|
+
y: c.scale * (h.top - d.top) + c.dy
|
|
1040
|
+
}, g = {
|
|
1041
1041
|
x: l.x,
|
|
1042
1042
|
y: l.y,
|
|
1043
|
-
width:
|
|
1044
|
-
height:
|
|
1043
|
+
width: s.width * c.scale,
|
|
1044
|
+
height: s.height * c.scale,
|
|
1045
1045
|
direction: r.direction,
|
|
1046
1046
|
portId: o.from,
|
|
1047
1047
|
nodeId: this.graphStore.getPortNodeId(o.from)
|
|
1048
1048
|
}, y = {
|
|
1049
1049
|
x: a.x,
|
|
1050
1050
|
y: a.y,
|
|
1051
|
-
width:
|
|
1052
|
-
height:
|
|
1053
|
-
direction:
|
|
1051
|
+
width: h.width * c.scale,
|
|
1052
|
+
height: h.height * c.scale,
|
|
1053
|
+
direction: i.direction,
|
|
1054
1054
|
portId: o.to,
|
|
1055
1055
|
nodeId: this.graphStore.getPortNodeId(o.to)
|
|
1056
1056
|
};
|
|
1057
1057
|
o.shape.render({
|
|
1058
|
-
source:
|
|
1058
|
+
source: g,
|
|
1059
1059
|
target: y
|
|
1060
1060
|
});
|
|
1061
1061
|
}
|
|
@@ -1064,9 +1064,9 @@ class ft {
|
|
|
1064
1064
|
o.shape.svg.style.zIndex = `${o.priority}`;
|
|
1065
1065
|
}
|
|
1066
1066
|
}
|
|
1067
|
-
class
|
|
1067
|
+
class C {
|
|
1068
1068
|
constructor(t) {
|
|
1069
|
-
|
|
1069
|
+
n(this, "counter", 0);
|
|
1070
1070
|
this.checkExists = t;
|
|
1071
1071
|
}
|
|
1072
1072
|
create(t) {
|
|
@@ -1083,21 +1083,21 @@ class N {
|
|
|
1083
1083
|
class S extends Error {
|
|
1084
1084
|
constructor() {
|
|
1085
1085
|
super(...arguments);
|
|
1086
|
-
|
|
1086
|
+
n(this, "name", "HtmlGraphError");
|
|
1087
1087
|
}
|
|
1088
1088
|
}
|
|
1089
1089
|
class vt {
|
|
1090
|
-
constructor(t, o, r,
|
|
1091
|
-
|
|
1090
|
+
constructor(t, o, r, i, s, h, d) {
|
|
1091
|
+
n(this, "nodeIdGenerator", new C(
|
|
1092
1092
|
(t) => this.graphStore.getNode(t) !== void 0
|
|
1093
1093
|
));
|
|
1094
|
-
|
|
1094
|
+
n(this, "portIdGenerator", new C(
|
|
1095
1095
|
(t) => this.graphStore.getPort(t) !== void 0
|
|
1096
1096
|
));
|
|
1097
|
-
|
|
1097
|
+
n(this, "edgeIdGenerator", new C(
|
|
1098
1098
|
(t) => this.graphStore.getEdge(t) !== void 0
|
|
1099
1099
|
));
|
|
1100
|
-
this.graphStore = t, this.htmlController = o, this.viewportTransformer = r, this.defaultNodesCenterFn =
|
|
1100
|
+
this.graphStore = t, this.htmlController = o, this.viewportTransformer = r, this.defaultNodesCenterFn = i, this.defaultPortsDirection = s, this.defaultNodesPriorityFn = h, this.defaultEdgesPriorityFn = d;
|
|
1101
1101
|
}
|
|
1102
1102
|
attach(t) {
|
|
1103
1103
|
this.htmlController.attach(t);
|
|
@@ -1164,16 +1164,16 @@ class vt {
|
|
|
1164
1164
|
const r = this.graphStore.getPort(t);
|
|
1165
1165
|
if (r === void 0)
|
|
1166
1166
|
throw new S("failed to unset nonexisting port");
|
|
1167
|
-
r.direction = o.direction ?? r.direction, this.graphStore.getPortAdjacentEdgeIds(t).forEach((
|
|
1168
|
-
this.htmlController.renderEdge(
|
|
1167
|
+
r.direction = o.direction ?? r.direction, this.graphStore.getPortAdjacentEdgeIds(t).forEach((s) => {
|
|
1168
|
+
this.htmlController.renderEdge(s);
|
|
1169
1169
|
});
|
|
1170
1170
|
}
|
|
1171
1171
|
updateNode(t, o) {
|
|
1172
1172
|
const r = this.graphStore.getNode(t);
|
|
1173
1173
|
if (r === void 0)
|
|
1174
1174
|
throw new S("failed to update nonexisting node");
|
|
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((
|
|
1176
|
-
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);
|
|
1177
1177
|
});
|
|
1178
1178
|
}
|
|
1179
1179
|
removeEdge(t) {
|
|
@@ -1210,17 +1210,17 @@ class vt {
|
|
|
1210
1210
|
}
|
|
1211
1211
|
class xt {
|
|
1212
1212
|
constructor(t) {
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1213
|
+
n(this, "transformation");
|
|
1214
|
+
n(this, "model");
|
|
1215
|
+
n(this, "canvasController");
|
|
1216
|
+
n(this, "edgeShapeFactory");
|
|
1217
1217
|
this.apiOptions = t;
|
|
1218
|
-
const o = dt(this.apiOptions), r = new at(),
|
|
1219
|
-
this.model = new lt(
|
|
1220
|
-
const
|
|
1218
|
+
const o = dt(this.apiOptions), r = new at(), i = new ct();
|
|
1219
|
+
this.model = new lt(i), this.transformation = new gt(r);
|
|
1220
|
+
const s = new ft(i, r);
|
|
1221
1221
|
this.canvasController = new vt(
|
|
1222
|
-
n,
|
|
1223
1222
|
i,
|
|
1223
|
+
s,
|
|
1224
1224
|
r,
|
|
1225
1225
|
o.nodes.centerFn,
|
|
1226
1226
|
o.ports.direction,
|
|
@@ -1307,36 +1307,36 @@ class xt {
|
|
|
1307
1307
|
}
|
|
1308
1308
|
}
|
|
1309
1309
|
const P = (e, t, o) => {
|
|
1310
|
-
const { x: r, y:
|
|
1311
|
-
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;
|
|
1312
1312
|
}, L = (e, t, o) => t >= 0 && t <= e.innerWidth && o >= 0 && o <= e.innerHeight, D = (e, t) => {
|
|
1313
1313
|
t !== null ? e.style.cursor = t : e.style.removeProperty("cursor");
|
|
1314
1314
|
};
|
|
1315
1315
|
class St {
|
|
1316
1316
|
constructor(t, o) {
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
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 C(
|
|
1326
1326
|
(t) => this.nodes.has(t)
|
|
1327
1327
|
));
|
|
1328
|
-
|
|
1329
|
-
|
|
1328
|
+
n(this, "element", null);
|
|
1329
|
+
n(this, "onWindowMouseMove", (t) => {
|
|
1330
1330
|
if (this.element !== null && (!P(this.element, t.clientX, t.clientY) || !L(this.window, t.clientX, t.clientY))) {
|
|
1331
1331
|
this.cancelMouseDrag();
|
|
1332
1332
|
return;
|
|
1333
1333
|
}
|
|
1334
1334
|
this.grabbedNodeId !== null && this.dragNode(this.grabbedNodeId, t.movementX, t.movementY);
|
|
1335
1335
|
});
|
|
1336
|
-
|
|
1336
|
+
n(this, "onWindowMouseUp", (t) => {
|
|
1337
1337
|
t.button === 0 && this.cancelMouseDrag();
|
|
1338
1338
|
});
|
|
1339
|
-
|
|
1339
|
+
n(this, "onWindowTouchMove", (t) => {
|
|
1340
1340
|
if (t.touches.length !== 1)
|
|
1341
1341
|
return;
|
|
1342
1342
|
const o = t.touches[0];
|
|
@@ -1345,26 +1345,23 @@ class St {
|
|
|
1345
1345
|
return;
|
|
1346
1346
|
}
|
|
1347
1347
|
if (this.grabbedNodeId !== null && this.previousTouchCoords !== null) {
|
|
1348
|
-
const r = o.clientX - this.previousTouchCoords.x,
|
|
1349
|
-
this.dragNode(this.grabbedNodeId, r,
|
|
1348
|
+
const r = o.clientX - this.previousTouchCoords.x, i = o.clientY - this.previousTouchCoords.y;
|
|
1349
|
+
this.dragNode(this.grabbedNodeId, r, i), this.previousTouchCoords = {
|
|
1350
1350
|
x: t.touches[0].clientX,
|
|
1351
1351
|
y: t.touches[0].clientY
|
|
1352
1352
|
};
|
|
1353
1353
|
}
|
|
1354
1354
|
});
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
x: t.touches[0].clientX,
|
|
1358
|
-
y: t.touches[0].clientY
|
|
1359
|
-
} : this.cancelTouchDrag();
|
|
1355
|
+
n(this, "onWindowTouchFinish", () => {
|
|
1356
|
+
this.previousTouchCoords = null, this.cancelTouchDrag();
|
|
1360
1357
|
});
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
var r,
|
|
1358
|
+
n(this, "previousTouchCoords", null);
|
|
1359
|
+
n(this, "freezePriority");
|
|
1360
|
+
n(this, "window", window);
|
|
1361
|
+
n(this, "dragCursor");
|
|
1362
|
+
var r, i, s;
|
|
1366
1363
|
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) ?? (() => {
|
|
1367
|
-
}), this.onBeforeNodeDrag = ((
|
|
1364
|
+
}), 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
1365
|
}), this.freezePriority = (o == null ? void 0 : o.moveOnTop) === !1, this.dragCursor = (o == null ? void 0 : o.dragCursor) !== void 0 ? o.dragCursor : "grab";
|
|
1369
1366
|
}
|
|
1370
1367
|
attach(t) {
|
|
@@ -1376,34 +1373,36 @@ class St {
|
|
|
1376
1373
|
addNode(t) {
|
|
1377
1374
|
const o = this.nodeIdGenerator.create(t.id);
|
|
1378
1375
|
this.canvas.addNode({ ...t, id: o }), this.updateMaxNodePriority(o);
|
|
1379
|
-
const r = (
|
|
1380
|
-
if (this.element === null ||
|
|
1376
|
+
const r = (s) => {
|
|
1377
|
+
if (this.element === null || s.button !== 0)
|
|
1381
1378
|
return;
|
|
1382
|
-
const
|
|
1379
|
+
const h = this.model.getNode(o);
|
|
1383
1380
|
this.onBeforeNodeDrag({
|
|
1384
1381
|
nodeId: o,
|
|
1385
1382
|
element: t.element,
|
|
1386
|
-
x:
|
|
1387
|
-
y:
|
|
1388
|
-
}) && (
|
|
1389
|
-
},
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1383
|
+
x: h.x,
|
|
1384
|
+
y: h.y
|
|
1385
|
+
}) && (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));
|
|
1386
|
+
}, i = (s) => {
|
|
1387
|
+
if (s.touches.length !== 1)
|
|
1388
|
+
return;
|
|
1389
|
+
s.stopImmediatePropagation(), this.previousTouchCoords = {
|
|
1390
|
+
x: s.touches[0].clientX,
|
|
1391
|
+
y: s.touches[0].clientY
|
|
1393
1392
|
};
|
|
1394
|
-
const
|
|
1393
|
+
const h = this.model.getNode(o);
|
|
1395
1394
|
this.onBeforeNodeDrag({
|
|
1396
1395
|
nodeId: o,
|
|
1397
1396
|
element: t.element,
|
|
1398
|
-
x:
|
|
1399
|
-
y:
|
|
1400
|
-
}) &&
|
|
1397
|
+
x: h.x,
|
|
1398
|
+
y: h.y
|
|
1399
|
+
}) && (this.grabbedNodeId = o, this.moveNodeOnTop(o), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish));
|
|
1401
1400
|
};
|
|
1402
1401
|
return this.nodes.set(o, {
|
|
1403
1402
|
element: t.element,
|
|
1404
1403
|
onMouseDown: r,
|
|
1405
|
-
onTouchStart:
|
|
1406
|
-
}), t.element.addEventListener("mousedown", r), t.element.addEventListener("touchstart",
|
|
1404
|
+
onTouchStart: i
|
|
1405
|
+
}), t.element.addEventListener("mousedown", r), t.element.addEventListener("touchstart", i), this;
|
|
1407
1406
|
}
|
|
1408
1407
|
updateNode(t, o) {
|
|
1409
1408
|
return this.canvas.updateNode(t, o), this.updateMaxNodePriority(t), this;
|
|
@@ -1445,15 +1444,15 @@ class St {
|
|
|
1445
1444
|
this.detach(), this.clear(), this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.canvas.destroy();
|
|
1446
1445
|
}
|
|
1447
1446
|
dragNode(t, o, r) {
|
|
1448
|
-
const
|
|
1449
|
-
if (
|
|
1447
|
+
const i = this.model.getNode(t);
|
|
1448
|
+
if (i === null)
|
|
1450
1449
|
return;
|
|
1451
|
-
const
|
|
1452
|
-
this.canvas.updateNode(t, { x:
|
|
1450
|
+
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;
|
|
1451
|
+
this.canvas.updateNode(t, { x: g, y }), this.onNodeDrag({
|
|
1453
1452
|
nodeId: t,
|
|
1454
|
-
element:
|
|
1455
|
-
x:
|
|
1456
|
-
y:
|
|
1453
|
+
element: i.element,
|
|
1454
|
+
x: i.x,
|
|
1455
|
+
y: i.y
|
|
1457
1456
|
});
|
|
1458
1457
|
}
|
|
1459
1458
|
updateMaxNodePriority(t) {
|
|
@@ -1465,8 +1464,8 @@ class St {
|
|
|
1465
1464
|
return;
|
|
1466
1465
|
this.maxNodePriority += 2, this.updateNode(t, { priority: this.maxNodePriority });
|
|
1467
1466
|
const o = this.maxNodePriority - 1;
|
|
1468
|
-
this.model.getNodeAdjacentEdgeIds(t).forEach((
|
|
1469
|
-
this.updateEdge(
|
|
1467
|
+
this.model.getNodeAdjacentEdgeIds(t).forEach((i) => {
|
|
1468
|
+
this.updateEdge(i, { priority: o });
|
|
1470
1469
|
});
|
|
1471
1470
|
}
|
|
1472
1471
|
cancelMouseDrag() {
|
|
@@ -1496,23 +1495,34 @@ class St {
|
|
|
1496
1495
|
}
|
|
1497
1496
|
}
|
|
1498
1497
|
const At = (e) => {
|
|
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,
|
|
1500
|
-
return (
|
|
1501
|
-
let
|
|
1502
|
-
|
|
1503
|
-
const
|
|
1504
|
-
|
|
1505
|
-
const l =
|
|
1506
|
-
return d >
|
|
1498
|
+
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;
|
|
1499
|
+
return (s) => {
|
|
1500
|
+
let h = s.nextTransform.dx, d = s.nextTransform.dy;
|
|
1501
|
+
h < t && h < s.prevTransform.dx && (h = Math.min(s.prevTransform.dx, t));
|
|
1502
|
+
const c = s.canvasWidth * s.prevTransform.scale;
|
|
1503
|
+
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));
|
|
1504
|
+
const l = s.canvasHeight * s.prevTransform.scale;
|
|
1505
|
+
return d > i - l && d > s.prevTransform.dy && (d = Math.max(s.prevTransform.dy, i - l)), { scale: s.nextTransform.scale, dx: h, dy: d };
|
|
1507
1506
|
};
|
|
1508
1507
|
}, Et = (e) => {
|
|
1509
|
-
const t = e.maxContentScale, o = e.minContentScale, r = t !== null ? 1 / t : 0,
|
|
1510
|
-
return (
|
|
1511
|
-
|
|
1512
|
-
|
|
1508
|
+
const t = e.maxContentScale, o = e.minContentScale, r = t !== null ? 1 / t : 0, i = o !== null ? 1 / o : 1 / 0;
|
|
1509
|
+
return (s) => {
|
|
1510
|
+
const h = s.prevTransform, d = s.nextTransform;
|
|
1511
|
+
let c = d.scale, l = d.dx, a = d.dy;
|
|
1512
|
+
if (d.scale > i && d.scale > h.scale) {
|
|
1513
|
+
c = Math.max(h.scale, i), l = h.dx, a = h.dy;
|
|
1514
|
+
const g = (c - h.scale) / (d.scale - h.scale);
|
|
1515
|
+
l = h.dx + (d.dx - h.dx) * g, a = h.dy + (d.dy - h.dy) * g;
|
|
1516
|
+
}
|
|
1517
|
+
if (d.scale < r && d.scale < h.scale) {
|
|
1518
|
+
c = Math.min(h.scale, r), l = h.dx, a = h.dy;
|
|
1519
|
+
const g = (c - h.scale) / (d.scale - h.scale);
|
|
1520
|
+
l = h.dx + (d.dx - h.dx) * g, a = h.dy + (d.dy - h.dy) * g;
|
|
1521
|
+
}
|
|
1522
|
+
return {
|
|
1513
1523
|
scale: c,
|
|
1514
|
-
dx:
|
|
1515
|
-
dy:
|
|
1524
|
+
dx: l,
|
|
1525
|
+
dy: a
|
|
1516
1526
|
};
|
|
1517
1527
|
};
|
|
1518
1528
|
}, Tt = (e) => (t) => e.reduce(
|
|
@@ -1541,62 +1551,62 @@ const At = (e) => {
|
|
|
1541
1551
|
});
|
|
1542
1552
|
}
|
|
1543
1553
|
}, Mt = (e) => {
|
|
1544
|
-
var
|
|
1545
|
-
const t = (
|
|
1546
|
-
let
|
|
1547
|
-
r !== void 0 ? Array.isArray(r) ?
|
|
1554
|
+
var c, l, a, g;
|
|
1555
|
+
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;
|
|
1556
|
+
let i;
|
|
1557
|
+
r !== void 0 ? Array.isArray(r) ? i = Tt(
|
|
1548
1558
|
r.map(
|
|
1549
1559
|
(y) => U(y)
|
|
1550
1560
|
)
|
|
1551
|
-
) :
|
|
1552
|
-
const
|
|
1553
|
-
}), d = ((
|
|
1561
|
+
) : i = U(r) : i = (y) => y.nextTransform;
|
|
1562
|
+
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.onBeforeTransformChange) ?? (() => {
|
|
1563
|
+
}), d = ((g = e == null ? void 0 : e.events) == null ? void 0 : g.onTransformChange) ?? (() => {
|
|
1554
1564
|
});
|
|
1555
1565
|
return {
|
|
1556
1566
|
wheelSensitivity: o,
|
|
1557
|
-
onBeforeTransformStarted:
|
|
1567
|
+
onBeforeTransformStarted: h,
|
|
1558
1568
|
onTransformFinished: d,
|
|
1559
|
-
transformPreprocessor:
|
|
1560
|
-
shiftCursor:
|
|
1569
|
+
transformPreprocessor: i,
|
|
1570
|
+
shiftCursor: s
|
|
1561
1571
|
};
|
|
1562
1572
|
}, W = (e) => {
|
|
1563
1573
|
const t = [], o = e.touches.length;
|
|
1564
1574
|
for (let d = 0; d < o; d++)
|
|
1565
1575
|
t.push([e.touches[d].clientX, e.touches[d].clientY]);
|
|
1566
1576
|
const r = t.reduce(
|
|
1567
|
-
(d,
|
|
1577
|
+
(d, c) => [d[0] + c[0], d[1] + c[1]],
|
|
1568
1578
|
[0, 0]
|
|
1569
|
-
),
|
|
1570
|
-
(d,
|
|
1579
|
+
), i = [r[0] / o, r[1] / o], h = t.map((d) => [d[0] - i[0], d[1] - i[1]]).reduce(
|
|
1580
|
+
(d, c) => d + Math.sqrt(c[0] * c[0] + c[1] * c[1]),
|
|
1571
1581
|
0
|
|
1572
1582
|
);
|
|
1573
1583
|
return {
|
|
1574
|
-
x:
|
|
1575
|
-
y:
|
|
1576
|
-
scale:
|
|
1584
|
+
x: i[0],
|
|
1585
|
+
y: i[1],
|
|
1586
|
+
scale: h / o,
|
|
1577
1587
|
touchesCnt: o,
|
|
1578
1588
|
touches: t
|
|
1579
1589
|
};
|
|
1580
|
-
},
|
|
1590
|
+
}, Ct = (e, t, o) => ({
|
|
1581
1591
|
scale: e.scale,
|
|
1582
1592
|
dx: e.dx + e.scale * t,
|
|
1583
1593
|
dy: e.dy + e.scale * o
|
|
1584
|
-
}),
|
|
1594
|
+
}), Nt = (e, t, o, r) => ({
|
|
1585
1595
|
scale: e.scale * t,
|
|
1586
1596
|
dx: e.scale * (1 - t) * o + e.dx,
|
|
1587
1597
|
dy: e.scale * (1 - t) * r + e.dy
|
|
1588
1598
|
});
|
|
1589
1599
|
class Pt {
|
|
1590
1600
|
constructor(t, o) {
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1601
|
+
n(this, "model");
|
|
1602
|
+
n(this, "transformation");
|
|
1603
|
+
n(this, "element", null);
|
|
1604
|
+
n(this, "prevTouches", null);
|
|
1605
|
+
n(this, "window", window);
|
|
1606
|
+
n(this, "onMouseDown", (t) => {
|
|
1597
1607
|
this.element === null || t.button !== 0 || (D(this.element, this.options.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove), this.window.addEventListener("mouseup", this.onWindowMouseUp));
|
|
1598
1608
|
});
|
|
1599
|
-
|
|
1609
|
+
n(this, "onWindowMouseMove", (t) => {
|
|
1600
1610
|
if (this.element === null || !P(this.element, t.clientX, t.clientY) || !L(this.window, t.clientX, t.clientY)) {
|
|
1601
1611
|
this.stopMouseDrag();
|
|
1602
1612
|
return;
|
|
@@ -1604,24 +1614,24 @@ class Pt {
|
|
|
1604
1614
|
const o = -t.movementX, r = -t.movementY;
|
|
1605
1615
|
this.moveViewport(this.element, o, r);
|
|
1606
1616
|
});
|
|
1607
|
-
|
|
1617
|
+
n(this, "onWindowMouseUp", (t) => {
|
|
1608
1618
|
this.element === null || t.button !== 0 || this.stopMouseDrag();
|
|
1609
1619
|
});
|
|
1610
|
-
|
|
1620
|
+
n(this, "onWheelScroll", (t) => {
|
|
1611
1621
|
t.preventDefault();
|
|
1612
|
-
const { left: o, top: r } = this.element.getBoundingClientRect(),
|
|
1613
|
-
this.scaleViewport(this.element, d,
|
|
1622
|
+
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);
|
|
1623
|
+
this.scaleViewport(this.element, d, i, s);
|
|
1614
1624
|
});
|
|
1615
|
-
|
|
1625
|
+
n(this, "onTouchStart", (t) => {
|
|
1616
1626
|
this.prevTouches = W(t), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish);
|
|
1617
1627
|
});
|
|
1618
|
-
|
|
1628
|
+
n(this, "onWindowTouchMove", (t) => {
|
|
1619
1629
|
const o = this.element;
|
|
1620
1630
|
if (o === null)
|
|
1621
1631
|
return;
|
|
1622
1632
|
const r = W(t);
|
|
1623
1633
|
if (!r.touches.every(
|
|
1624
|
-
(
|
|
1634
|
+
(s) => P(o, s[0], s[1]) && L(this.window, s[0], s[1])
|
|
1625
1635
|
)) {
|
|
1626
1636
|
this.stopTouchDrag();
|
|
1627
1637
|
return;
|
|
@@ -1631,24 +1641,24 @@ class Pt {
|
|
|
1631
1641
|
-(r.x - this.prevTouches.x),
|
|
1632
1642
|
-(r.y - this.prevTouches.y)
|
|
1633
1643
|
), r.touchesCnt === 2) {
|
|
1634
|
-
const { left:
|
|
1635
|
-
this.scaleViewport(o, a, d,
|
|
1644
|
+
const { left: s, top: h } = o.getBoundingClientRect(), d = this.prevTouches.x - s, c = this.prevTouches.y - h, a = 1 / (r.scale / this.prevTouches.scale);
|
|
1645
|
+
this.scaleViewport(o, a, d, c);
|
|
1636
1646
|
}
|
|
1637
1647
|
this.prevTouches = r;
|
|
1638
1648
|
});
|
|
1639
|
-
|
|
1649
|
+
n(this, "onWindowTouchFinish", (t) => {
|
|
1640
1650
|
t.touches.length > 0 ? this.prevTouches = W(t) : this.stopTouchDrag();
|
|
1641
1651
|
});
|
|
1642
|
-
|
|
1643
|
-
const t = this.canvas.transformation.getViewportMatrix(), { width: o, height: r } = this.element.getBoundingClientRect(),
|
|
1652
|
+
n(this, "observer", new ResizeObserver(() => {
|
|
1653
|
+
const t = this.canvas.transformation.getViewportMatrix(), { width: o, height: r } = this.element.getBoundingClientRect(), i = this.options.transformPreprocessor({
|
|
1644
1654
|
prevTransform: t,
|
|
1645
1655
|
nextTransform: t,
|
|
1646
1656
|
canvasWidth: o,
|
|
1647
1657
|
canvasHeight: r
|
|
1648
1658
|
});
|
|
1649
|
-
this.canvas.patchViewportMatrix(
|
|
1659
|
+
this.canvas.patchViewportMatrix(i), this.options.onTransformFinished();
|
|
1650
1660
|
}));
|
|
1651
|
-
|
|
1661
|
+
n(this, "options");
|
|
1652
1662
|
this.canvas = t, this.options = Mt(o), this.transformation = this.canvas.transformation, this.model = this.canvas.model;
|
|
1653
1663
|
}
|
|
1654
1664
|
attach(t) {
|
|
@@ -1698,21 +1708,21 @@ class Pt {
|
|
|
1698
1708
|
}
|
|
1699
1709
|
moveViewport(t, o, r) {
|
|
1700
1710
|
this.options.onBeforeTransformStarted();
|
|
1701
|
-
const
|
|
1702
|
-
prevTransform:
|
|
1703
|
-
nextTransform:
|
|
1704
|
-
canvasWidth:
|
|
1711
|
+
const i = this.transformation.getViewportMatrix(), s = Ct(i, o, r), { width: h, height: d } = t.getBoundingClientRect(), c = this.options.transformPreprocessor({
|
|
1712
|
+
prevTransform: i,
|
|
1713
|
+
nextTransform: s,
|
|
1714
|
+
canvasWidth: h,
|
|
1705
1715
|
canvasHeight: d
|
|
1706
1716
|
});
|
|
1707
|
-
this.canvas.patchViewportMatrix(
|
|
1717
|
+
this.canvas.patchViewportMatrix(c), this.options.onTransformFinished();
|
|
1708
1718
|
}
|
|
1709
|
-
scaleViewport(t, o, r,
|
|
1719
|
+
scaleViewport(t, o, r, i) {
|
|
1710
1720
|
this.options.onBeforeTransformStarted();
|
|
1711
|
-
const
|
|
1712
|
-
prevTransform:
|
|
1713
|
-
nextTransform:
|
|
1721
|
+
const s = this.canvas.transformation.getViewportMatrix(), h = Nt(s, o, r, i), { width: d, height: c } = t.getBoundingClientRect(), l = this.options.transformPreprocessor({
|
|
1722
|
+
prevTransform: s,
|
|
1723
|
+
nextTransform: h,
|
|
1714
1724
|
canvasWidth: d,
|
|
1715
|
-
canvasHeight:
|
|
1725
|
+
canvasHeight: c
|
|
1716
1726
|
});
|
|
1717
1727
|
this.canvas.patchViewportMatrix(l), this.options.onTransformFinished();
|
|
1718
1728
|
}
|
|
@@ -1731,8 +1741,8 @@ class Pt {
|
|
|
1731
1741
|
}
|
|
1732
1742
|
class Lt {
|
|
1733
1743
|
constructor() {
|
|
1734
|
-
|
|
1735
|
-
|
|
1744
|
+
n(this, "keyMap", /* @__PURE__ */ new Map());
|
|
1745
|
+
n(this, "valueMap", /* @__PURE__ */ new Map());
|
|
1736
1746
|
}
|
|
1737
1747
|
set(t, o) {
|
|
1738
1748
|
this.keyMap.set(t, o), this.valueMap.set(o, t);
|
|
@@ -1768,17 +1778,17 @@ class Lt {
|
|
|
1768
1778
|
}
|
|
1769
1779
|
class Dt {
|
|
1770
1780
|
constructor(t) {
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1781
|
+
n(this, "transformation");
|
|
1782
|
+
n(this, "model");
|
|
1783
|
+
n(this, "nodes", new Lt());
|
|
1784
|
+
n(this, "nodeIdGenerator", new C(
|
|
1775
1785
|
(t) => this.nodes.hasKey(t)
|
|
1776
1786
|
));
|
|
1777
|
-
|
|
1787
|
+
n(this, "nodesResizeObserver");
|
|
1778
1788
|
this.canvas = t, this.nodesResizeObserver = new window.ResizeObserver((o) => {
|
|
1779
1789
|
o.forEach((r) => {
|
|
1780
|
-
const
|
|
1781
|
-
this.reactNodeChange(
|
|
1790
|
+
const i = r.target;
|
|
1791
|
+
this.reactNodeChange(i);
|
|
1782
1792
|
});
|
|
1783
1793
|
}), this.transformation = this.canvas.transformation, this.model = this.canvas.model;
|
|
1784
1794
|
}
|
|
@@ -1835,19 +1845,19 @@ class Dt {
|
|
|
1835
1845
|
}
|
|
1836
1846
|
reactNodeChange(t) {
|
|
1837
1847
|
const o = this.nodes.getByValue(t);
|
|
1838
|
-
this.canvas.updateNode(o), this.model.getNodeAdjacentEdgeIds(o).forEach((
|
|
1839
|
-
this.canvas.updateEdge(
|
|
1848
|
+
this.canvas.updateNode(o), this.model.getNodeAdjacentEdgeIds(o).forEach((i) => {
|
|
1849
|
+
this.canvas.updateEdge(i);
|
|
1840
1850
|
});
|
|
1841
1851
|
}
|
|
1842
1852
|
}
|
|
1843
1853
|
class mt {
|
|
1844
1854
|
constructor() {
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1855
|
+
n(this, "coreOptions");
|
|
1856
|
+
n(this, "dragOptions");
|
|
1857
|
+
n(this, "transformOptions");
|
|
1858
|
+
n(this, "isDraggable", !1);
|
|
1859
|
+
n(this, "isTransformable", !1);
|
|
1860
|
+
n(this, "hasResizeReactiveNodes", !1);
|
|
1851
1861
|
}
|
|
1852
1862
|
setOptions(t) {
|
|
1853
1863
|
return this.coreOptions = t, this;
|