@html-graph/html-graph 0.1.4 → 0.1.6
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 -1
- package/dist/main.d.ts +13 -12
- package/dist/main.js +332 -316
- package/dist/main.umd.cjs +1 -1
- package/package.json +5 -3
package/dist/main.js
CHANGED
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var n = (e, t, o) =>
|
|
4
|
-
const
|
|
1
|
+
var Q = Object.defineProperty;
|
|
2
|
+
var Z = (e, t, o) => t in e ? Q(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o;
|
|
3
|
+
var n = (e, t, o) => Z(e, typeof t != "symbol" ? t + "" : t, o);
|
|
4
|
+
const O = (e, t) => ({
|
|
5
5
|
x: e / 2,
|
|
6
6
|
y: t / 2
|
|
7
|
-
}),
|
|
7
|
+
}), v = (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
|
-
}),
|
|
10
|
+
}), M = (e, t, o) => ({ x: t * Math.cos(e), y: o * Math.sin(e) }), w = {
|
|
11
11
|
x: 0,
|
|
12
12
|
y: 0
|
|
13
|
-
},
|
|
13
|
+
}, C = (e, t, o, r) => {
|
|
14
14
|
const s = [
|
|
15
15
|
w,
|
|
16
16
|
{ x: o, y: r },
|
|
17
17
|
{ x: o, y: -r }
|
|
18
|
-
].map((l) =>
|
|
18
|
+
].map((l) => v(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
19
|
return `${h} ${d} ${c}`;
|
|
20
|
-
},
|
|
20
|
+
}, $ = (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
24
|
let i = 0, s = 0, h = 0;
|
|
25
25
|
e.forEach((d, c) => {
|
|
26
26
|
let l = 0, a = 0, g = 0;
|
|
27
|
-
const y = c > 0, x = c < r,
|
|
27
|
+
const y = c > 0, x = c < r, f = y && x;
|
|
28
28
|
if (y && (l = -i, a = -s, g = h), x) {
|
|
29
|
-
const
|
|
30
|
-
i =
|
|
29
|
+
const I = e[c + 1];
|
|
30
|
+
i = I.x - d.x, s = I.y - d.y, h = Math.sqrt(i * i + s * s);
|
|
31
31
|
}
|
|
32
|
-
const
|
|
33
|
-
c > 0 && o.push(`L ${
|
|
34
|
-
`C ${d.x} ${d.y} ${d.x} ${d.y} ${
|
|
32
|
+
const S = h !== 0 ? Math.min((f ? t : 0) / h, c < r - 1 ? 0.5 : 1) : 0, T = f ? { x: d.x + i * S, y: d.y + s * S } : d, P = g !== 0 ? Math.min((f ? t : 0) / g, c > 1 ? 0.5 : 1) : 0, D = f ? { x: d.x + l * P, y: d.y + a * P } : d;
|
|
33
|
+
c > 0 && o.push(`L ${D.x} ${D.y}`), f && o.push(
|
|
34
|
+
`C ${d.x} ${d.y} ${d.x} ${d.y} ${T.x} ${T.y}`
|
|
35
35
|
);
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
return o.join(" ");
|
|
39
|
-
},
|
|
39
|
+
}, W = () => {
|
|
40
40
|
const e = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
41
41
|
return e.style.pointerEvents = "none", e.style.position = "absolute", e.style.top = "0", e.style.left = "0", e.style.overflow = "visible", e;
|
|
42
|
-
},
|
|
42
|
+
}, F = () => {
|
|
43
43
|
const e = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
|
44
44
|
return e.style.transformOrigin = "50% 50%", e;
|
|
45
|
-
},
|
|
45
|
+
}, R = (e, t) => {
|
|
46
46
|
const o = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
47
47
|
return o.setAttribute("stroke", e), o.setAttribute("stroke-width", `${t}`), o.setAttribute("fill", "none"), o;
|
|
48
|
-
},
|
|
48
|
+
}, N = (e) => {
|
|
49
49
|
const t = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
50
50
|
return t.setAttribute("fill", e), t;
|
|
51
|
-
},
|
|
51
|
+
}, Y = (e, t) => {
|
|
52
52
|
const o = {
|
|
53
53
|
x: e.x + e.width / 2,
|
|
54
54
|
y: e.y + e.height / 2
|
|
@@ -64,12 +64,12 @@ const _ = (e, t) => ({
|
|
|
64
64
|
flipX: c,
|
|
65
65
|
flipY: l
|
|
66
66
|
};
|
|
67
|
-
},
|
|
68
|
-
const t =
|
|
67
|
+
}, q = (e) => {
|
|
68
|
+
const t = v(
|
|
69
69
|
{ x: e.arrowLength, y: w.y },
|
|
70
70
|
e.fromVect,
|
|
71
71
|
w
|
|
72
|
-
), o =
|
|
72
|
+
), o = v(
|
|
73
73
|
{ x: e.to.x - e.arrowLength, y: e.to.y },
|
|
74
74
|
e.toVect,
|
|
75
75
|
e.to
|
|
@@ -81,23 +81,23 @@ const _ = (e, t) => ({
|
|
|
81
81
|
y: o.y - e.toVect.y * e.curvature
|
|
82
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
83
|
return `${h}${s}${d}`;
|
|
84
|
-
},
|
|
85
|
-
const t = e.hasSourceArrow ?
|
|
84
|
+
}, tt = (e) => {
|
|
85
|
+
const t = e.hasSourceArrow ? v(
|
|
86
86
|
{ x: e.arrowLength, y: w.y },
|
|
87
87
|
e.fromVect,
|
|
88
88
|
w
|
|
89
|
-
) : w, o = e.hasTargetArrow ?
|
|
89
|
+
) : w, o = e.hasTargetArrow ? v(
|
|
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, s = Math.sin(e.detourDirection) * e.detourDistance, h = i * e.flipX, d = s * e.flipY, c =
|
|
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 = v(
|
|
94
94
|
{ x: r, y: w.y },
|
|
95
95
|
e.fromVect,
|
|
96
96
|
w
|
|
97
97
|
), l = {
|
|
98
98
|
x: c.x + h,
|
|
99
99
|
y: c.y + d
|
|
100
|
-
}, a =
|
|
100
|
+
}, a = v(
|
|
101
101
|
{ x: e.to.x - r, y: e.to.y },
|
|
102
102
|
e.toVect,
|
|
103
103
|
e.to
|
|
@@ -107,33 +107,33 @@ const _ = (e, t) => ({
|
|
|
107
107
|
}, y = { x: (l.x + g.x) / 2, y: (l.y + g.y) / 2 }, x = {
|
|
108
108
|
x: c.x + e.curvature * e.fromVect.x,
|
|
109
109
|
y: c.y + e.curvature * e.fromVect.y
|
|
110
|
-
},
|
|
110
|
+
}, f = {
|
|
111
111
|
x: a.x - e.curvature * e.toVect.x,
|
|
112
112
|
y: a.y - e.curvature * e.toVect.y
|
|
113
|
-
},
|
|
113
|
+
}, A = {
|
|
114
114
|
x: c.x + h,
|
|
115
115
|
y: c.y + d
|
|
116
|
-
},
|
|
116
|
+
}, S = {
|
|
117
117
|
x: a.x + h,
|
|
118
118
|
y: a.y + d
|
|
119
119
|
};
|
|
120
120
|
return [
|
|
121
121
|
`M ${t.x} ${t.y}`,
|
|
122
122
|
`L ${c.x} ${c.y}`,
|
|
123
|
-
`C ${x.x} ${x.y} ${
|
|
124
|
-
`C ${
|
|
123
|
+
`C ${x.x} ${x.y} ${A.x} ${A.y} ${y.x} ${y.y}`,
|
|
124
|
+
`C ${S.x} ${S.y} ${f.x} ${f.y} ${a.x} ${a.y}`,
|
|
125
125
|
`L ${o.x} ${o.y}`
|
|
126
126
|
].join(" ");
|
|
127
|
-
},
|
|
128
|
-
const t = e.hasSourceArrow ?
|
|
127
|
+
}, et = (e) => {
|
|
128
|
+
const t = e.hasSourceArrow ? v(
|
|
129
129
|
{ x: e.arrowLength, y: w.y },
|
|
130
130
|
e.fromVect,
|
|
131
131
|
w
|
|
132
|
-
) : w, o = e.hasTargetArrow ?
|
|
132
|
+
) : w, o = e.hasTargetArrow ? v(
|
|
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, s =
|
|
136
|
+
) : e.to, r = e.arrowLength + e.arrowOffset, i = r - e.roundness, s = v({ x: i, y: w.y }, e.fromVect, w), h = v(
|
|
137
137
|
{ x: e.to.x - i, y: e.to.y },
|
|
138
138
|
e.toVect,
|
|
139
139
|
e.to
|
|
@@ -141,57 +141,57 @@ const _ = (e, t) => ({
|
|
|
141
141
|
x: e.flipX > 0 ? e.to.x - d : e.to.x + r,
|
|
142
142
|
y: h.y
|
|
143
143
|
}, y = { x: g.x, y: c };
|
|
144
|
-
return
|
|
144
|
+
return $(
|
|
145
145
|
[t, s, l, a, y, g, h, o],
|
|
146
146
|
e.roundness
|
|
147
147
|
);
|
|
148
|
-
},
|
|
149
|
-
const t = e.hasSourceArrow ?
|
|
148
|
+
}, G = (e) => {
|
|
149
|
+
const t = e.hasSourceArrow ? v(
|
|
150
150
|
{ x: e.arrowLength, y: w.y },
|
|
151
151
|
e.fromVect,
|
|
152
152
|
w
|
|
153
|
-
) : w, o = e.hasTargetArrow ?
|
|
153
|
+
) : w, o = e.hasTargetArrow ? v(
|
|
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, i =
|
|
157
|
+
) : e.to, r = e.arrowLength + e.arrowOffset, i = v(
|
|
158
158
|
{ x: r, y: w.y },
|
|
159
159
|
e.fromVect,
|
|
160
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 =
|
|
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 = v(
|
|
162
162
|
{ x: e.to.x - r, y: e.to.y },
|
|
163
163
|
e.toVect,
|
|
164
164
|
e.to
|
|
165
165
|
), g = { x: a.x + d, y: a.y + c };
|
|
166
|
-
return
|
|
166
|
+
return $(
|
|
167
167
|
[t, i, l, g, a, o],
|
|
168
168
|
e.roundness
|
|
169
169
|
);
|
|
170
|
-
},
|
|
171
|
-
const t = e.hasSourceArrow ?
|
|
170
|
+
}, ot = (e) => {
|
|
171
|
+
const t = e.hasSourceArrow ? v(
|
|
172
172
|
{ x: e.arrowLength, y: w.y },
|
|
173
173
|
e.fromVect,
|
|
174
174
|
w
|
|
175
|
-
) : w, o = e.hasTargetArrow ?
|
|
175
|
+
) : w, o = e.hasTargetArrow ? v(
|
|
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 =
|
|
179
|
+
) : e.to, r = e.arrowLength + e.arrowOffset, i = v({ x: r, y: w.y }, e.fromVect, w), s = v(
|
|
180
180
|
{ x: e.to.x - r, y: e.to.y },
|
|
181
181
|
e.toVect,
|
|
182
182
|
e.to
|
|
183
183
|
);
|
|
184
|
-
return
|
|
185
|
-
},
|
|
186
|
-
const t = e.hasSourceArrow ?
|
|
184
|
+
return $([t, i, s, o], e.roundness);
|
|
185
|
+
}, rt = (e) => {
|
|
186
|
+
const t = e.hasSourceArrow ? v(
|
|
187
187
|
{ x: e.arrowLength, y: w.y },
|
|
188
188
|
e.fromVect,
|
|
189
189
|
w
|
|
190
|
-
) : w, o = e.hasTargetArrow ?
|
|
190
|
+
) : w, o = e.hasTargetArrow ? v(
|
|
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, s =
|
|
194
|
+
) : e.to, r = e.arrowLength + e.arrowOffset, i = r - e.roundness, s = v({ x: i, y: w.y }, e.fromVect, w), h = v(
|
|
195
195
|
{ x: e.to.x - i, y: e.to.y },
|
|
196
196
|
e.toVect,
|
|
197
197
|
e.to
|
|
@@ -199,11 +199,11 @@ const _ = (e, t) => ({
|
|
|
199
199
|
x: h.x,
|
|
200
200
|
y: e.flipY > 0 ? e.to.y - d : e.to.y + r
|
|
201
201
|
}, y = { x: c, y: g.y };
|
|
202
|
-
return
|
|
202
|
+
return $(
|
|
203
203
|
[t, s, l, a, y, g, h, o],
|
|
204
204
|
e.roundness
|
|
205
205
|
);
|
|
206
|
-
},
|
|
206
|
+
}, U = (e) => {
|
|
207
207
|
const t = e.arrowOffset, o = e.side, r = e.arrowLength + t, i = r + 2 * o, h = [
|
|
208
208
|
{ x: e.arrowLength, y: w.y },
|
|
209
209
|
{ x: r, y: w.y },
|
|
@@ -214,15 +214,15 @@ const _ = (e, t) => ({
|
|
|
214
214
|
{ x: r, y: w.y },
|
|
215
215
|
{ x: e.arrowLength, y: w.y }
|
|
216
216
|
].map(
|
|
217
|
-
(c) =>
|
|
217
|
+
(c) => v(c, e.fromVect, w)
|
|
218
218
|
), d = `M ${w.x} ${w.y} L ${h[0].x} ${h[0].y} `;
|
|
219
|
-
return `${e.hasSourceArrow || e.hasTargetArrow ? "" : d}${
|
|
220
|
-
},
|
|
219
|
+
return `${e.hasSourceArrow || e.hasTargetArrow ? "" : d}${$(h, e.roundness)}`;
|
|
220
|
+
}, it = (e) => {
|
|
221
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
222
|
{ x: e.arrowLength, y: w.y },
|
|
223
223
|
{ x: s, y: h },
|
|
224
224
|
{ x: s, y: -h }
|
|
225
|
-
].map((g) =>
|
|
225
|
+
].map((g) => v(g, e.fromVect, w)), l = [
|
|
226
226
|
`M ${c[0].x} ${c[0].y}`,
|
|
227
227
|
`A ${t} ${t} 0 0 1 ${c[1].x} ${c[1].y}`,
|
|
228
228
|
`A ${o} ${o} 0 1 0 ${c[2].x} ${c[2].y}`,
|
|
@@ -230,7 +230,7 @@ const _ = (e, t) => ({
|
|
|
230
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
|
-
color: "#
|
|
233
|
+
color: "#777777",
|
|
234
234
|
width: 1,
|
|
235
235
|
arrowLength: 15,
|
|
236
236
|
arrowWidth: 4,
|
|
@@ -246,10 +246,10 @@ const _ = (e, t) => ({
|
|
|
246
246
|
smallCycleRadius: 15,
|
|
247
247
|
curvature: 90
|
|
248
248
|
});
|
|
249
|
-
class
|
|
249
|
+
class nt {
|
|
250
250
|
constructor(t) {
|
|
251
|
-
n(this, "svg",
|
|
252
|
-
n(this, "group",
|
|
251
|
+
n(this, "svg", W());
|
|
252
|
+
n(this, "group", F());
|
|
253
253
|
n(this, "line");
|
|
254
254
|
n(this, "sourceArrow", null);
|
|
255
255
|
n(this, "targetArrow", null);
|
|
@@ -264,19 +264,19 @@ class ot {
|
|
|
264
264
|
n(this, "hasTargetArrow");
|
|
265
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
266
|
const o = (t == null ? void 0 : t.color) ?? u.color, r = (t == null ? void 0 : t.width) ?? u.width;
|
|
267
|
-
this.svg.appendChild(this.group), this.line =
|
|
267
|
+
this.svg.appendChild(this.group), this.line = R(o, r), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = N(o), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = N(o), this.group.appendChild(this.targetArrow));
|
|
268
268
|
}
|
|
269
269
|
render(t) {
|
|
270
|
-
const { x: o, y: r, width: i, height: s, flipX: h, flipY: d } =
|
|
270
|
+
const { x: o, y: r, width: i, height: s, flipX: h, flipY: d } = Y(
|
|
271
271
|
t.source,
|
|
272
272
|
t.target
|
|
273
273
|
);
|
|
274
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 =
|
|
275
|
+
const c = M(
|
|
276
276
|
t.source.direction,
|
|
277
277
|
h,
|
|
278
278
|
d
|
|
279
|
-
), l =
|
|
279
|
+
), l = M(
|
|
280
280
|
t.target.direction,
|
|
281
281
|
h,
|
|
282
282
|
d
|
|
@@ -285,14 +285,14 @@ class ot {
|
|
|
285
285
|
y: s
|
|
286
286
|
};
|
|
287
287
|
let g, y = l, x = -this.arrowLength;
|
|
288
|
-
if (t.source.portId === t.target.portId ? (g =
|
|
288
|
+
if (t.source.portId === t.target.portId ? (g = it({
|
|
289
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 = c, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g =
|
|
295
|
+
}), y = c, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g = tt({
|
|
296
296
|
to: a,
|
|
297
297
|
fromVect: c,
|
|
298
298
|
toVect: l,
|
|
@@ -304,7 +304,7 @@ class ot {
|
|
|
304
304
|
curvature: this.curvature,
|
|
305
305
|
hasSourceArrow: this.hasSourceArrow,
|
|
306
306
|
hasTargetArrow: this.hasTargetArrow
|
|
307
|
-
}) : g =
|
|
307
|
+
}) : g = q({
|
|
308
308
|
to: a,
|
|
309
309
|
fromVect: c,
|
|
310
310
|
toVect: l,
|
|
@@ -313,29 +313,29 @@ class ot {
|
|
|
313
313
|
hasSourceArrow: this.hasSourceArrow,
|
|
314
314
|
hasTargetArrow: this.hasTargetArrow
|
|
315
315
|
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
316
|
-
const
|
|
316
|
+
const f = C(
|
|
317
317
|
c,
|
|
318
318
|
w,
|
|
319
319
|
this.arrowLength,
|
|
320
320
|
this.arrowWidth
|
|
321
321
|
);
|
|
322
|
-
this.sourceArrow.setAttribute("d",
|
|
322
|
+
this.sourceArrow.setAttribute("d", f);
|
|
323
323
|
}
|
|
324
324
|
if (this.targetArrow) {
|
|
325
|
-
const
|
|
325
|
+
const f = C(
|
|
326
326
|
y,
|
|
327
327
|
a,
|
|
328
328
|
x,
|
|
329
329
|
this.arrowWidth
|
|
330
330
|
);
|
|
331
|
-
this.targetArrow.setAttribute("d",
|
|
331
|
+
this.targetArrow.setAttribute("d", f);
|
|
332
332
|
}
|
|
333
333
|
}
|
|
334
334
|
}
|
|
335
|
-
class
|
|
335
|
+
class st {
|
|
336
336
|
constructor(t) {
|
|
337
|
-
n(this, "svg",
|
|
338
|
-
n(this, "group",
|
|
337
|
+
n(this, "svg", W());
|
|
338
|
+
n(this, "group", F());
|
|
339
339
|
n(this, "line");
|
|
340
340
|
n(this, "sourceArrow", null);
|
|
341
341
|
n(this, "targetArrow", null);
|
|
@@ -356,19 +356,19 @@ class rt {
|
|
|
356
356
|
this.cycleSquareSide / 2
|
|
357
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
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 =
|
|
359
|
+
this.svg.appendChild(this.group), this.line = R(r, i), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = N(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = N(r), this.group.appendChild(this.targetArrow));
|
|
360
360
|
}
|
|
361
361
|
render(t) {
|
|
362
|
-
const { x: o, y: r, width: i, height: s, flipX: h, flipY: d } =
|
|
362
|
+
const { x: o, y: r, width: i, height: s, flipX: h, flipY: d } = Y(
|
|
363
363
|
t.source,
|
|
364
364
|
t.target
|
|
365
365
|
);
|
|
366
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 =
|
|
367
|
+
const c = M(
|
|
368
368
|
t.source.direction,
|
|
369
369
|
h,
|
|
370
370
|
d
|
|
371
|
-
), l =
|
|
371
|
+
), l = M(
|
|
372
372
|
t.target.direction,
|
|
373
373
|
h,
|
|
374
374
|
d
|
|
@@ -377,7 +377,7 @@ class rt {
|
|
|
377
377
|
y: s
|
|
378
378
|
};
|
|
379
379
|
let g, y = l, x = -this.arrowLength;
|
|
380
|
-
if (t.source.portId === t.target.portId ? (g =
|
|
380
|
+
if (t.source.portId === t.target.portId ? (g = U({
|
|
381
381
|
fromVect: c,
|
|
382
382
|
arrowLength: this.arrowLength,
|
|
383
383
|
side: this.cycleSquareSide,
|
|
@@ -385,7 +385,7 @@ class rt {
|
|
|
385
385
|
roundness: this.roundness,
|
|
386
386
|
hasSourceArrow: this.hasSourceArrow,
|
|
387
387
|
hasTargetArrow: this.hasTargetArrow
|
|
388
|
-
}), y = c, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g =
|
|
388
|
+
}), y = c, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g = G({
|
|
389
389
|
to: a,
|
|
390
390
|
fromVect: c,
|
|
391
391
|
toVect: l,
|
|
@@ -398,7 +398,7 @@ class rt {
|
|
|
398
398
|
detourDistance: this.detourDistance,
|
|
399
399
|
hasSourceArrow: this.hasSourceArrow,
|
|
400
400
|
hasTargetArrow: this.hasTargetArrow
|
|
401
|
-
}) : g =
|
|
401
|
+
}) : g = et({
|
|
402
402
|
to: a,
|
|
403
403
|
fromVect: c,
|
|
404
404
|
toVect: l,
|
|
@@ -409,29 +409,29 @@ class rt {
|
|
|
409
409
|
hasSourceArrow: this.hasSourceArrow,
|
|
410
410
|
hasTargetArrow: this.hasTargetArrow
|
|
411
411
|
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
412
|
-
const
|
|
412
|
+
const f = C(
|
|
413
413
|
c,
|
|
414
414
|
w,
|
|
415
415
|
this.arrowLength,
|
|
416
416
|
this.arrowWidth
|
|
417
417
|
);
|
|
418
|
-
this.sourceArrow.setAttribute("d",
|
|
418
|
+
this.sourceArrow.setAttribute("d", f);
|
|
419
419
|
}
|
|
420
420
|
if (this.targetArrow) {
|
|
421
|
-
const
|
|
421
|
+
const f = C(
|
|
422
422
|
y,
|
|
423
423
|
a,
|
|
424
424
|
x,
|
|
425
425
|
this.arrowWidth
|
|
426
426
|
);
|
|
427
|
-
this.targetArrow.setAttribute("d",
|
|
427
|
+
this.targetArrow.setAttribute("d", f);
|
|
428
428
|
}
|
|
429
429
|
}
|
|
430
430
|
}
|
|
431
|
-
class
|
|
431
|
+
class ht {
|
|
432
432
|
constructor(t) {
|
|
433
|
-
n(this, "svg",
|
|
434
|
-
n(this, "group",
|
|
433
|
+
n(this, "svg", W());
|
|
434
|
+
n(this, "group", F());
|
|
435
435
|
n(this, "line");
|
|
436
436
|
n(this, "sourceArrow", null);
|
|
437
437
|
n(this, "targetArrow", null);
|
|
@@ -452,19 +452,19 @@ class it {
|
|
|
452
452
|
this.cycleSquareSide / 2
|
|
453
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
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 =
|
|
455
|
+
this.svg.appendChild(this.group), this.line = R(r, i), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = N(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = N(r), this.group.appendChild(this.targetArrow));
|
|
456
456
|
}
|
|
457
457
|
render(t) {
|
|
458
|
-
const { x: o, y: r, width: i, height: s, flipX: h, flipY: d } =
|
|
458
|
+
const { x: o, y: r, width: i, height: s, flipX: h, flipY: d } = Y(
|
|
459
459
|
t.source,
|
|
460
460
|
t.target
|
|
461
461
|
);
|
|
462
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 =
|
|
463
|
+
const c = M(
|
|
464
464
|
t.source.direction,
|
|
465
465
|
h,
|
|
466
466
|
d
|
|
467
|
-
), l =
|
|
467
|
+
), l = M(
|
|
468
468
|
t.target.direction,
|
|
469
469
|
h,
|
|
470
470
|
d
|
|
@@ -473,7 +473,7 @@ class it {
|
|
|
473
473
|
y: s
|
|
474
474
|
};
|
|
475
475
|
let g, y = l, x = -this.arrowLength;
|
|
476
|
-
if (t.source.portId === t.target.portId ? (g =
|
|
476
|
+
if (t.source.portId === t.target.portId ? (g = U({
|
|
477
477
|
fromVect: c,
|
|
478
478
|
arrowLength: this.arrowLength,
|
|
479
479
|
side: this.cycleSquareSide,
|
|
@@ -481,7 +481,7 @@ class it {
|
|
|
481
481
|
roundness: this.roundness,
|
|
482
482
|
hasSourceArrow: this.hasSourceArrow,
|
|
483
483
|
hasTargetArrow: this.hasTargetArrow
|
|
484
|
-
}), y = c, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g =
|
|
484
|
+
}), y = c, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g = G({
|
|
485
485
|
to: a,
|
|
486
486
|
fromVect: c,
|
|
487
487
|
toVect: l,
|
|
@@ -494,7 +494,7 @@ class it {
|
|
|
494
494
|
detourDistance: this.detourDistance,
|
|
495
495
|
hasSourceArrow: this.hasSourceArrow,
|
|
496
496
|
hasTargetArrow: this.hasTargetArrow
|
|
497
|
-
}) : g =
|
|
497
|
+
}) : g = ot({
|
|
498
498
|
to: a,
|
|
499
499
|
fromVect: c,
|
|
500
500
|
toVect: l,
|
|
@@ -504,29 +504,29 @@ class it {
|
|
|
504
504
|
hasSourceArrow: this.hasSourceArrow,
|
|
505
505
|
hasTargetArrow: this.hasTargetArrow
|
|
506
506
|
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
507
|
-
const
|
|
507
|
+
const f = C(
|
|
508
508
|
c,
|
|
509
509
|
w,
|
|
510
510
|
this.arrowLength,
|
|
511
511
|
this.arrowWidth
|
|
512
512
|
);
|
|
513
|
-
this.sourceArrow.setAttribute("d",
|
|
513
|
+
this.sourceArrow.setAttribute("d", f);
|
|
514
514
|
}
|
|
515
515
|
if (this.targetArrow) {
|
|
516
|
-
const
|
|
516
|
+
const f = C(
|
|
517
517
|
y,
|
|
518
518
|
a,
|
|
519
519
|
x,
|
|
520
520
|
this.arrowWidth
|
|
521
521
|
);
|
|
522
|
-
this.targetArrow.setAttribute("d",
|
|
522
|
+
this.targetArrow.setAttribute("d", f);
|
|
523
523
|
}
|
|
524
524
|
}
|
|
525
525
|
}
|
|
526
|
-
class
|
|
526
|
+
class dt {
|
|
527
527
|
constructor(t) {
|
|
528
|
-
n(this, "svg",
|
|
529
|
-
n(this, "group",
|
|
528
|
+
n(this, "svg", W());
|
|
529
|
+
n(this, "group", F());
|
|
530
530
|
n(this, "line");
|
|
531
531
|
n(this, "sourceArrow", null);
|
|
532
532
|
n(this, "targetArrow", null);
|
|
@@ -547,19 +547,19 @@ class nt {
|
|
|
547
547
|
this.cycleSquareSide / 2
|
|
548
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
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 =
|
|
550
|
+
this.svg.appendChild(this.group), this.line = R(r, i), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = N(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = N(r), this.group.appendChild(this.targetArrow));
|
|
551
551
|
}
|
|
552
552
|
render(t) {
|
|
553
|
-
const { x: o, y: r, width: i, height: s, flipX: h, flipY: d } =
|
|
553
|
+
const { x: o, y: r, width: i, height: s, flipX: h, flipY: d } = Y(
|
|
554
554
|
t.source,
|
|
555
555
|
t.target
|
|
556
556
|
);
|
|
557
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 =
|
|
558
|
+
const c = M(
|
|
559
559
|
t.source.direction,
|
|
560
560
|
h,
|
|
561
561
|
d
|
|
562
|
-
), l =
|
|
562
|
+
), l = M(
|
|
563
563
|
t.target.direction,
|
|
564
564
|
h,
|
|
565
565
|
d
|
|
@@ -568,7 +568,7 @@ class nt {
|
|
|
568
568
|
y: s
|
|
569
569
|
};
|
|
570
570
|
let g, y = l, x = -this.arrowLength;
|
|
571
|
-
if (t.source.portId === t.target.portId ? (g =
|
|
571
|
+
if (t.source.portId === t.target.portId ? (g = U({
|
|
572
572
|
fromVect: c,
|
|
573
573
|
arrowLength: this.arrowLength,
|
|
574
574
|
side: this.cycleSquareSide,
|
|
@@ -576,7 +576,7 @@ class nt {
|
|
|
576
576
|
roundness: this.roundness,
|
|
577
577
|
hasSourceArrow: this.hasSourceArrow,
|
|
578
578
|
hasTargetArrow: this.hasTargetArrow
|
|
579
|
-
}), y = c, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g =
|
|
579
|
+
}), y = c, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g = G({
|
|
580
580
|
to: a,
|
|
581
581
|
fromVect: c,
|
|
582
582
|
toVect: l,
|
|
@@ -589,7 +589,7 @@ class nt {
|
|
|
589
589
|
detourDistance: this.detourDistance,
|
|
590
590
|
hasSourceArrow: this.hasSourceArrow,
|
|
591
591
|
hasTargetArrow: this.hasTargetArrow
|
|
592
|
-
}) : g =
|
|
592
|
+
}) : g = rt({
|
|
593
593
|
to: a,
|
|
594
594
|
fromVect: c,
|
|
595
595
|
toVect: l,
|
|
@@ -600,31 +600,31 @@ class nt {
|
|
|
600
600
|
hasSourceArrow: this.hasSourceArrow,
|
|
601
601
|
hasTargetArrow: this.hasTargetArrow
|
|
602
602
|
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
603
|
-
const
|
|
603
|
+
const f = C(
|
|
604
604
|
c,
|
|
605
605
|
w,
|
|
606
606
|
this.arrowLength,
|
|
607
607
|
this.arrowWidth
|
|
608
608
|
);
|
|
609
|
-
this.sourceArrow.setAttribute("d",
|
|
609
|
+
this.sourceArrow.setAttribute("d", f);
|
|
610
610
|
}
|
|
611
611
|
if (this.targetArrow) {
|
|
612
|
-
const
|
|
612
|
+
const f = C(
|
|
613
613
|
y,
|
|
614
614
|
a,
|
|
615
615
|
x,
|
|
616
616
|
this.arrowWidth
|
|
617
617
|
);
|
|
618
|
-
this.targetArrow.setAttribute("d",
|
|
618
|
+
this.targetArrow.setAttribute("d", f);
|
|
619
619
|
}
|
|
620
620
|
}
|
|
621
621
|
}
|
|
622
|
-
const
|
|
622
|
+
const ct = (e) => {
|
|
623
623
|
if (typeof e == "function")
|
|
624
624
|
return e;
|
|
625
625
|
switch (e == null ? void 0 : e.type) {
|
|
626
626
|
case "straight":
|
|
627
|
-
return () => new
|
|
627
|
+
return () => new ht({
|
|
628
628
|
color: e.color,
|
|
629
629
|
width: e.width,
|
|
630
630
|
arrowLength: e.arrowLength,
|
|
@@ -638,7 +638,7 @@ const st = (e) => {
|
|
|
638
638
|
detourDirection: e.detourDirection
|
|
639
639
|
});
|
|
640
640
|
case "horizontal":
|
|
641
|
-
return () => new
|
|
641
|
+
return () => new st({
|
|
642
642
|
color: e.color,
|
|
643
643
|
width: e.width,
|
|
644
644
|
arrowLength: e.arrowLength,
|
|
@@ -652,7 +652,7 @@ const st = (e) => {
|
|
|
652
652
|
detourDirection: e.detourDirection
|
|
653
653
|
});
|
|
654
654
|
case "vertical":
|
|
655
|
-
return () => new
|
|
655
|
+
return () => new dt({
|
|
656
656
|
color: e.color,
|
|
657
657
|
width: e.width,
|
|
658
658
|
arrowLength: e.arrowLength,
|
|
@@ -666,7 +666,7 @@ const st = (e) => {
|
|
|
666
666
|
detourDirection: e.detourDirection
|
|
667
667
|
});
|
|
668
668
|
default:
|
|
669
|
-
return () => new
|
|
669
|
+
return () => new nt({
|
|
670
670
|
color: e.color,
|
|
671
671
|
width: e.width,
|
|
672
672
|
arrowLength: e.arrowLength,
|
|
@@ -680,38 +680,38 @@ const st = (e) => {
|
|
|
680
680
|
detourDirection: e.detourDirection
|
|
681
681
|
});
|
|
682
682
|
}
|
|
683
|
-
},
|
|
683
|
+
}, z = (e) => () => e, H = z(0), k = () => {
|
|
684
684
|
let e = 0;
|
|
685
685
|
return () => e++;
|
|
686
|
-
},
|
|
687
|
-
let o =
|
|
688
|
-
e === "incremental" && (o =
|
|
689
|
-
const i =
|
|
690
|
-
return e === "shared-incremental" && (o = i), t === "shared-incremental" && (r = i), typeof e == "number" && (o =
|
|
686
|
+
}, lt = (e, t) => {
|
|
687
|
+
let o = H, r = H;
|
|
688
|
+
e === "incremental" && (o = k()), t === "incremental" && (r = k());
|
|
689
|
+
const i = k();
|
|
690
|
+
return e === "shared-incremental" && (o = i), t === "shared-incremental" && (r = i), typeof e == "number" && (o = z(e)), typeof t == "number" && (r = z(t)), typeof e == "function" && (o = e), typeof t == "function" && (r = t), {
|
|
691
691
|
nodesPriorityFn: o,
|
|
692
692
|
edgesPriorityFn: r
|
|
693
693
|
};
|
|
694
|
-
},
|
|
694
|
+
}, at = (e) => {
|
|
695
695
|
var o, r, i, s, h;
|
|
696
|
-
const t =
|
|
696
|
+
const t = lt(
|
|
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: ((i = e == null ? void 0 : e.nodes) == null ? void 0 : i.centerFn) ??
|
|
702
|
+
centerFn: ((i = e == null ? void 0 : e.nodes) == null ? void 0 : i.centerFn) ?? O,
|
|
703
703
|
priorityFn: t.nodesPriorityFn
|
|
704
704
|
},
|
|
705
705
|
ports: {
|
|
706
706
|
direction: ((s = e == null ? void 0 : e.ports) == null ? void 0 : s.direction) ?? 0
|
|
707
707
|
},
|
|
708
708
|
edges: {
|
|
709
|
-
shapeFactory:
|
|
709
|
+
shapeFactory: ct(((h = e == null ? void 0 : e.edges) == null ? void 0 : h.shape) ?? {}),
|
|
710
710
|
priorityFn: t.edgesPriorityFn
|
|
711
711
|
}
|
|
712
712
|
};
|
|
713
713
|
};
|
|
714
|
-
class
|
|
714
|
+
class gt {
|
|
715
715
|
constructor() {
|
|
716
716
|
n(this, "nodes", /* @__PURE__ */ new Map());
|
|
717
717
|
n(this, "ports", /* @__PURE__ */ new Map());
|
|
@@ -850,84 +850,19 @@ class ct {
|
|
|
850
850
|
];
|
|
851
851
|
}
|
|
852
852
|
}
|
|
853
|
-
|
|
854
|
-
constructor(t) {
|
|
855
|
-
this.graphStore = t;
|
|
856
|
-
}
|
|
857
|
-
getNode(t) {
|
|
858
|
-
const o = this.graphStore.getNode(t);
|
|
859
|
-
return o === void 0 ? null : {
|
|
860
|
-
element: o.element,
|
|
861
|
-
x: o.x,
|
|
862
|
-
y: o.y,
|
|
863
|
-
centerFn: o.centerFn,
|
|
864
|
-
priority: o.priority
|
|
865
|
-
};
|
|
866
|
-
}
|
|
867
|
-
getAllNodeIds() {
|
|
868
|
-
return this.graphStore.getAllNodeIds();
|
|
869
|
-
}
|
|
870
|
-
getPort(t) {
|
|
871
|
-
const o = this.graphStore.getPort(t);
|
|
872
|
-
return o === void 0 ? null : {
|
|
873
|
-
element: o.element,
|
|
874
|
-
direction: o.direction
|
|
875
|
-
};
|
|
876
|
-
}
|
|
877
|
-
getAllPortIds() {
|
|
878
|
-
return this.graphStore.getAllPortIds();
|
|
879
|
-
}
|
|
880
|
-
getNodePortIds(t) {
|
|
881
|
-
return this.graphStore.getNodePortIds(t);
|
|
882
|
-
}
|
|
883
|
-
getPortNodeId(t) {
|
|
884
|
-
return this.graphStore.getPortNodeId(t) ?? null;
|
|
885
|
-
}
|
|
886
|
-
getAllEdgeIds() {
|
|
887
|
-
return this.graphStore.getAllEdgeIds();
|
|
888
|
-
}
|
|
889
|
-
getEdge(t) {
|
|
890
|
-
const o = this.graphStore.getEdge(t);
|
|
891
|
-
return o === void 0 ? null : { from: o.from, to: o.to, priority: o.priority };
|
|
892
|
-
}
|
|
893
|
-
getPortIncomingEdgeIds(t) {
|
|
894
|
-
return this.graphStore.getPortIncomingEdgeIds(t);
|
|
895
|
-
}
|
|
896
|
-
getPortOutcomingEdgeIds(t) {
|
|
897
|
-
return this.graphStore.getPortOutcomingEdgeIds(t);
|
|
898
|
-
}
|
|
899
|
-
getPortCycleEdgeIds(t) {
|
|
900
|
-
return this.graphStore.getPortCycleEdgeIds(t);
|
|
901
|
-
}
|
|
902
|
-
getPortAdjacentEdgeIds(t) {
|
|
903
|
-
return this.graphStore.getPortAdjacentEdgeIds(t);
|
|
904
|
-
}
|
|
905
|
-
getNodeIncomingEdgeIds(t) {
|
|
906
|
-
return this.graphStore.getNodeIncomingEdgeIds(t);
|
|
907
|
-
}
|
|
908
|
-
getNodeOutcomingEdgeIds(t) {
|
|
909
|
-
return this.graphStore.getNodeOutcomingEdgeIds(t);
|
|
910
|
-
}
|
|
911
|
-
getNodeCycleEdgeIds(t) {
|
|
912
|
-
return this.graphStore.getNodeCycleEdgeIds(t);
|
|
913
|
-
}
|
|
914
|
-
getNodeAdjacentEdgeIds(t) {
|
|
915
|
-
return this.graphStore.getNodeAdjacentEdgeIds(t);
|
|
916
|
-
}
|
|
917
|
-
}
|
|
918
|
-
const j = (e) => ({
|
|
853
|
+
const K = (e) => ({
|
|
919
854
|
scale: 1 / e.scale,
|
|
920
855
|
dx: -e.dx / e.scale,
|
|
921
856
|
dy: -e.dy / e.scale
|
|
922
|
-
}),
|
|
857
|
+
}), _ = {
|
|
923
858
|
scale: 1,
|
|
924
859
|
dx: 0,
|
|
925
860
|
dy: 0
|
|
926
861
|
};
|
|
927
|
-
class
|
|
862
|
+
class ut {
|
|
928
863
|
constructor() {
|
|
929
|
-
n(this, "viewportMatrix",
|
|
930
|
-
n(this, "contentMatrix",
|
|
864
|
+
n(this, "viewportMatrix", _);
|
|
865
|
+
n(this, "contentMatrix", _);
|
|
931
866
|
}
|
|
932
867
|
getViewportMatrix() {
|
|
933
868
|
return this.viewportMatrix;
|
|
@@ -940,17 +875,17 @@ class at {
|
|
|
940
875
|
scale: t.scale ?? this.viewportMatrix.scale,
|
|
941
876
|
dx: t.dx ?? this.viewportMatrix.dx,
|
|
942
877
|
dy: t.dy ?? this.viewportMatrix.dy
|
|
943
|
-
}, this.contentMatrix =
|
|
878
|
+
}, this.contentMatrix = K(this.viewportMatrix);
|
|
944
879
|
}
|
|
945
880
|
patchContentMatrix(t) {
|
|
946
881
|
this.contentMatrix = {
|
|
947
882
|
scale: t.scale ?? this.contentMatrix.scale,
|
|
948
883
|
dx: t.dx ?? this.contentMatrix.dx,
|
|
949
884
|
dy: t.dy ?? this.contentMatrix.dy
|
|
950
|
-
}, this.viewportMatrix =
|
|
885
|
+
}, this.viewportMatrix = K(this.contentMatrix);
|
|
951
886
|
}
|
|
952
887
|
}
|
|
953
|
-
class
|
|
888
|
+
class wt {
|
|
954
889
|
constructor(t) {
|
|
955
890
|
this.transformer = t;
|
|
956
891
|
}
|
|
@@ -961,21 +896,21 @@ class gt {
|
|
|
961
896
|
return { ...this.transformer.getContentMatrix() };
|
|
962
897
|
}
|
|
963
898
|
}
|
|
964
|
-
const
|
|
899
|
+
const yt = () => {
|
|
965
900
|
const e = document.createElement("div");
|
|
966
901
|
return e.style.width = "100%", e.style.height = "100%", e.style.position = "relative", e.style.overflow = "hidden", e;
|
|
967
|
-
},
|
|
902
|
+
}, ft = () => {
|
|
968
903
|
const e = document.createElement("div");
|
|
969
904
|
return e.style.position = "absolute", e.style.top = "0", e.style.left = "0", e.style.width = "0", e.style.height = "0", e;
|
|
970
|
-
},
|
|
905
|
+
}, vt = () => {
|
|
971
906
|
const e = document.createElement("div");
|
|
972
907
|
return e.style.position = "absolute", e.style.top = "0", e.style.left = "0", e.style.visibility = "hidden", e;
|
|
973
908
|
};
|
|
974
|
-
class
|
|
909
|
+
class xt {
|
|
975
910
|
constructor(t, o) {
|
|
976
911
|
n(this, "canvasWrapper", null);
|
|
977
|
-
n(this, "host",
|
|
978
|
-
n(this, "container",
|
|
912
|
+
n(this, "host", yt());
|
|
913
|
+
n(this, "container", ft());
|
|
979
914
|
n(this, "nodeIdToWrapperElementMap", /* @__PURE__ */ new Map());
|
|
980
915
|
n(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
|
|
981
916
|
this.graphStore = t, this.viewportTransformer = o, this.host.appendChild(this.container);
|
|
@@ -991,7 +926,7 @@ class ft {
|
|
|
991
926
|
this.container.style.transform = `matrix(${t.scale}, 0, 0, ${t.scale}, ${t.dx}, ${t.dy})`;
|
|
992
927
|
}
|
|
993
928
|
attachNode(t) {
|
|
994
|
-
const o = this.graphStore.getNode(t), r =
|
|
929
|
+
const o = this.graphStore.getNode(t), r = vt();
|
|
995
930
|
r.appendChild(o.element), this.container.appendChild(r), this.nodeIdToWrapperElementMap.set(t, r), this.updateNodeCoordinates(t), this.updateNodePriority(t), r.style.visibility = "visible";
|
|
996
931
|
}
|
|
997
932
|
detachNode(t) {
|
|
@@ -1064,7 +999,7 @@ class ft {
|
|
|
1064
999
|
o.shape.svg.style.zIndex = `${o.priority}`;
|
|
1065
1000
|
}
|
|
1066
1001
|
}
|
|
1067
|
-
class
|
|
1002
|
+
class m {
|
|
1068
1003
|
constructor(t) {
|
|
1069
1004
|
n(this, "counter", 0);
|
|
1070
1005
|
this.checkExists = t;
|
|
@@ -1080,21 +1015,21 @@ class C {
|
|
|
1080
1015
|
this.counter = 0;
|
|
1081
1016
|
}
|
|
1082
1017
|
}
|
|
1083
|
-
class
|
|
1018
|
+
class E extends Error {
|
|
1084
1019
|
constructor() {
|
|
1085
1020
|
super(...arguments);
|
|
1086
1021
|
n(this, "name", "HtmlGraphError");
|
|
1087
1022
|
}
|
|
1088
1023
|
}
|
|
1089
|
-
class
|
|
1024
|
+
class Et {
|
|
1090
1025
|
constructor(t, o, r, i, s, h, d) {
|
|
1091
|
-
n(this, "nodeIdGenerator", new
|
|
1026
|
+
n(this, "nodeIdGenerator", new m(
|
|
1092
1027
|
(t) => this.graphStore.getNode(t) !== void 0
|
|
1093
1028
|
));
|
|
1094
|
-
n(this, "portIdGenerator", new
|
|
1029
|
+
n(this, "portIdGenerator", new m(
|
|
1095
1030
|
(t) => this.graphStore.getPort(t) !== void 0
|
|
1096
1031
|
));
|
|
1097
|
-
n(this, "edgeIdGenerator", new
|
|
1032
|
+
n(this, "edgeIdGenerator", new m(
|
|
1098
1033
|
(t) => this.graphStore.getEdge(t) !== void 0
|
|
1099
1034
|
));
|
|
1100
1035
|
this.graphStore = t, this.htmlController = o, this.viewportTransformer = r, this.defaultNodesCenterFn = i, this.defaultPortsDirection = s, this.defaultNodesPriorityFn = h, this.defaultEdgesPriorityFn = d;
|
|
@@ -1108,7 +1043,7 @@ class vt {
|
|
|
1108
1043
|
addNode(t) {
|
|
1109
1044
|
const o = this.nodeIdGenerator.create(t.nodeId);
|
|
1110
1045
|
if (this.graphStore.getNode(o) !== void 0)
|
|
1111
|
-
throw new
|
|
1046
|
+
throw new E("failed to add node with existing id");
|
|
1112
1047
|
this.graphStore.addNode({
|
|
1113
1048
|
nodeId: o,
|
|
1114
1049
|
element: t.element,
|
|
@@ -1128,9 +1063,9 @@ class vt {
|
|
|
1128
1063
|
markPort(t) {
|
|
1129
1064
|
const o = this.portIdGenerator.create(t.portId);
|
|
1130
1065
|
if (this.graphStore.getPort(o) !== void 0)
|
|
1131
|
-
throw new
|
|
1066
|
+
throw new E("failed to add port with existing id");
|
|
1132
1067
|
if (this.graphStore.getNode(t.nodeId) === void 0)
|
|
1133
|
-
throw new
|
|
1068
|
+
throw new E("failed to set port on nonexisting node");
|
|
1134
1069
|
this.graphStore.addPort({
|
|
1135
1070
|
portId: o,
|
|
1136
1071
|
element: t.element,
|
|
@@ -1141,11 +1076,11 @@ class vt {
|
|
|
1141
1076
|
addEdge(t) {
|
|
1142
1077
|
const o = this.edgeIdGenerator.create(t.edgeId);
|
|
1143
1078
|
if (this.graphStore.getEdge(o) !== void 0)
|
|
1144
|
-
throw new
|
|
1079
|
+
throw new E("failed to add edge with existing id");
|
|
1145
1080
|
if (this.graphStore.getPort(t.from) === void 0)
|
|
1146
|
-
throw new
|
|
1081
|
+
throw new E("failed to add edge from nonexisting port");
|
|
1147
1082
|
if (this.graphStore.getPort(t.to) === void 0)
|
|
1148
|
-
throw new
|
|
1083
|
+
throw new E("failed to add edge to nonexisting port");
|
|
1149
1084
|
this.graphStore.addEdge({
|
|
1150
1085
|
edgeId: o,
|
|
1151
1086
|
from: t.from,
|
|
@@ -1157,13 +1092,13 @@ class vt {
|
|
|
1157
1092
|
updateEdge(t) {
|
|
1158
1093
|
const o = this.graphStore.getEdge(t.edgeId);
|
|
1159
1094
|
if (o === void 0)
|
|
1160
|
-
throw new
|
|
1095
|
+
throw new E("failed to update nonexisting edge");
|
|
1161
1096
|
t.shape !== void 0 && (o.shape = t.shape, this.htmlController.updateEdgeShape(t.edgeId)), t.priority !== void 0 && (o.priority = t.priority, this.htmlController.updateEdgePriority(t.edgeId)), t.from !== void 0 && this.graphStore.updateEdgeFrom(t.edgeId, t.from), t.to !== void 0 && this.graphStore.updateEdgeTo(t.edgeId, t.to), this.htmlController.renderEdge(t.edgeId);
|
|
1162
1097
|
}
|
|
1163
1098
|
updatePort(t, o) {
|
|
1164
1099
|
const r = this.graphStore.getPort(t);
|
|
1165
1100
|
if (r === void 0)
|
|
1166
|
-
throw new
|
|
1101
|
+
throw new E("failed to unset nonexisting port");
|
|
1167
1102
|
r.direction = o.direction ?? r.direction, this.graphStore.getPortAdjacentEdgeIds(t).forEach((s) => {
|
|
1168
1103
|
this.htmlController.renderEdge(s);
|
|
1169
1104
|
});
|
|
@@ -1171,26 +1106,26 @@ class vt {
|
|
|
1171
1106
|
updateNode(t, o) {
|
|
1172
1107
|
const r = this.graphStore.getNode(t);
|
|
1173
1108
|
if (r === void 0)
|
|
1174
|
-
throw new
|
|
1109
|
+
throw new E("failed to update nonexisting node");
|
|
1175
1110
|
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
1111
|
this.htmlController.renderEdge(s);
|
|
1177
1112
|
});
|
|
1178
1113
|
}
|
|
1179
1114
|
removeEdge(t) {
|
|
1180
1115
|
if (this.graphStore.getEdge(t) === void 0)
|
|
1181
|
-
throw new
|
|
1116
|
+
throw new E("failed to remove nonexisting edge");
|
|
1182
1117
|
this.htmlController.detachEdge(t), this.graphStore.removeEdge(t);
|
|
1183
1118
|
}
|
|
1184
1119
|
unmarkPort(t) {
|
|
1185
1120
|
if (this.graphStore.getPort(t) === void 0)
|
|
1186
|
-
throw new
|
|
1121
|
+
throw new E("failed to unset nonexisting port");
|
|
1187
1122
|
this.graphStore.getPortAdjacentEdgeIds(t).forEach((o) => {
|
|
1188
1123
|
this.removeEdge(o);
|
|
1189
1124
|
}), this.graphStore.removePort(t);
|
|
1190
1125
|
}
|
|
1191
1126
|
removeNode(t) {
|
|
1192
1127
|
if (this.graphStore.getNode(t) === void 0)
|
|
1193
|
-
throw new
|
|
1128
|
+
throw new E("failed to remove nonexisting node");
|
|
1194
1129
|
this.graphStore.getNodePortIds(t).forEach((o) => {
|
|
1195
1130
|
this.unmarkPort(o);
|
|
1196
1131
|
}), this.htmlController.detachNode(t), this.graphStore.removeNode(t);
|
|
@@ -1208,17 +1143,82 @@ class vt {
|
|
|
1208
1143
|
this.clear(), this.htmlController.destroy();
|
|
1209
1144
|
}
|
|
1210
1145
|
}
|
|
1211
|
-
class
|
|
1146
|
+
class St {
|
|
1147
|
+
constructor(t) {
|
|
1148
|
+
this.graphStore = t;
|
|
1149
|
+
}
|
|
1150
|
+
getNode(t) {
|
|
1151
|
+
const o = this.graphStore.getNode(t);
|
|
1152
|
+
return o === void 0 ? null : {
|
|
1153
|
+
element: o.element,
|
|
1154
|
+
x: o.x,
|
|
1155
|
+
y: o.y,
|
|
1156
|
+
centerFn: o.centerFn,
|
|
1157
|
+
priority: o.priority
|
|
1158
|
+
};
|
|
1159
|
+
}
|
|
1160
|
+
getAllNodeIds() {
|
|
1161
|
+
return this.graphStore.getAllNodeIds();
|
|
1162
|
+
}
|
|
1163
|
+
getPort(t) {
|
|
1164
|
+
const o = this.graphStore.getPort(t);
|
|
1165
|
+
return o === void 0 ? null : {
|
|
1166
|
+
element: o.element,
|
|
1167
|
+
direction: o.direction
|
|
1168
|
+
};
|
|
1169
|
+
}
|
|
1170
|
+
getAllPortIds() {
|
|
1171
|
+
return this.graphStore.getAllPortIds();
|
|
1172
|
+
}
|
|
1173
|
+
getNodePortIds(t) {
|
|
1174
|
+
return this.graphStore.getNodePortIds(t);
|
|
1175
|
+
}
|
|
1176
|
+
getPortNodeId(t) {
|
|
1177
|
+
return this.graphStore.getPortNodeId(t) ?? null;
|
|
1178
|
+
}
|
|
1179
|
+
getAllEdgeIds() {
|
|
1180
|
+
return this.graphStore.getAllEdgeIds();
|
|
1181
|
+
}
|
|
1182
|
+
getEdge(t) {
|
|
1183
|
+
const o = this.graphStore.getEdge(t);
|
|
1184
|
+
return o === void 0 ? null : { from: o.from, to: o.to, priority: o.priority };
|
|
1185
|
+
}
|
|
1186
|
+
getPortIncomingEdgeIds(t) {
|
|
1187
|
+
return this.graphStore.getPortIncomingEdgeIds(t);
|
|
1188
|
+
}
|
|
1189
|
+
getPortOutcomingEdgeIds(t) {
|
|
1190
|
+
return this.graphStore.getPortOutcomingEdgeIds(t);
|
|
1191
|
+
}
|
|
1192
|
+
getPortCycleEdgeIds(t) {
|
|
1193
|
+
return this.graphStore.getPortCycleEdgeIds(t);
|
|
1194
|
+
}
|
|
1195
|
+
getPortAdjacentEdgeIds(t) {
|
|
1196
|
+
return this.graphStore.getPortAdjacentEdgeIds(t);
|
|
1197
|
+
}
|
|
1198
|
+
getNodeIncomingEdgeIds(t) {
|
|
1199
|
+
return this.graphStore.getNodeIncomingEdgeIds(t);
|
|
1200
|
+
}
|
|
1201
|
+
getNodeOutcomingEdgeIds(t) {
|
|
1202
|
+
return this.graphStore.getNodeOutcomingEdgeIds(t);
|
|
1203
|
+
}
|
|
1204
|
+
getNodeCycleEdgeIds(t) {
|
|
1205
|
+
return this.graphStore.getNodeCycleEdgeIds(t);
|
|
1206
|
+
}
|
|
1207
|
+
getNodeAdjacentEdgeIds(t) {
|
|
1208
|
+
return this.graphStore.getNodeAdjacentEdgeIds(t);
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
class At {
|
|
1212
1212
|
constructor(t) {
|
|
1213
1213
|
n(this, "transformation");
|
|
1214
1214
|
n(this, "model");
|
|
1215
1215
|
n(this, "canvasController");
|
|
1216
1216
|
n(this, "edgeShapeFactory");
|
|
1217
1217
|
this.apiOptions = t;
|
|
1218
|
-
const o =
|
|
1219
|
-
this.model = new
|
|
1220
|
-
const s = new
|
|
1221
|
-
this.canvasController = new
|
|
1218
|
+
const o = at(this.apiOptions), r = new ut(), i = new gt();
|
|
1219
|
+
this.model = new St(i), this.transformation = new wt(r);
|
|
1220
|
+
const s = new xt(i, r);
|
|
1221
|
+
this.canvasController = new Et(
|
|
1222
1222
|
i,
|
|
1223
1223
|
s,
|
|
1224
1224
|
r,
|
|
@@ -1306,41 +1306,52 @@ class xt {
|
|
|
1306
1306
|
this.clear(), this.canvasController.destroy();
|
|
1307
1307
|
}
|
|
1308
1308
|
}
|
|
1309
|
-
const
|
|
1309
|
+
const V = (e, t, o) => {
|
|
1310
1310
|
const { x: r, y: i, width: s, height: h } = e.getBoundingClientRect();
|
|
1311
1311
|
return t >= r && t <= r + s && o >= i && o <= i + h;
|
|
1312
|
-
},
|
|
1312
|
+
}, b = (e, t, o) => t >= 0 && t <= e.innerWidth && o >= 0 && o <= e.innerHeight, p = (e, t) => {
|
|
1313
1313
|
t !== null ? e.style.cursor = t : e.style.removeProperty("cursor");
|
|
1314
|
+
}, Tt = (e) => {
|
|
1315
|
+
var g, y, x, f, A, S;
|
|
1316
|
+
const t = ((g = e == null ? void 0 : e.events) == null ? void 0 : g.onNodeDrag) ?? (() => {
|
|
1317
|
+
}), o = ((y = e == null ? void 0 : e.events) == null ? void 0 : y.onBeforeNodeDrag) ?? (() => !0), r = ((x = e == null ? void 0 : e.events) == null ? void 0 : x.onNodeDragFinished) ?? (() => {
|
|
1318
|
+
}), i = (e == null ? void 0 : e.moveOnTop) === !1, s = (f = e == null ? void 0 : e.mouse) == null ? void 0 : f.dragCursor, h = s !== void 0 ? s : "grab", d = (A = e == null ? void 0 : e.mouse) == null ? void 0 : A.mouseDownEventValidator, c = d !== void 0 ? d : (T) => T.button === 0, l = (S = e == null ? void 0 : e.mouse) == null ? void 0 : S.mouseUpEventValidator;
|
|
1319
|
+
return {
|
|
1320
|
+
freezePriority: i,
|
|
1321
|
+
dragCursor: h,
|
|
1322
|
+
mouseDownEventValidator: c,
|
|
1323
|
+
mouseUpEventValidator: l !== void 0 ? l : (T) => T.button === 0,
|
|
1324
|
+
onNodeDrag: t,
|
|
1325
|
+
onBeforeNodeDrag: o,
|
|
1326
|
+
onNodeDragFinished: r
|
|
1327
|
+
};
|
|
1314
1328
|
};
|
|
1315
|
-
class
|
|
1329
|
+
class Mt {
|
|
1316
1330
|
constructor(t, o) {
|
|
1317
1331
|
n(this, "model");
|
|
1318
1332
|
n(this, "transformation");
|
|
1319
1333
|
n(this, "maxNodePriority", 0);
|
|
1320
1334
|
n(this, "nodes", /* @__PURE__ */ new Map());
|
|
1321
1335
|
n(this, "grabbedNodeId", null);
|
|
1322
|
-
n(this, "
|
|
1323
|
-
n(this, "onBeforeNodeDrag");
|
|
1324
|
-
n(this, "onNodeDragFinished");
|
|
1325
|
-
n(this, "nodeIdGenerator", new C(
|
|
1336
|
+
n(this, "nodeIdGenerator", new m(
|
|
1326
1337
|
(t) => this.nodes.has(t)
|
|
1327
1338
|
));
|
|
1328
1339
|
n(this, "element", null);
|
|
1329
1340
|
n(this, "onWindowMouseMove", (t) => {
|
|
1330
|
-
if (this.element !== null && (!
|
|
1341
|
+
if (this.element !== null && (!V(this.element, t.clientX, t.clientY) || !b(this.window, t.clientX, t.clientY))) {
|
|
1331
1342
|
this.cancelMouseDrag();
|
|
1332
1343
|
return;
|
|
1333
1344
|
}
|
|
1334
1345
|
this.grabbedNodeId !== null && this.dragNode(this.grabbedNodeId, t.movementX, t.movementY);
|
|
1335
1346
|
});
|
|
1336
1347
|
n(this, "onWindowMouseUp", (t) => {
|
|
1337
|
-
t
|
|
1348
|
+
this.options.mouseUpEventValidator(t) && this.cancelMouseDrag();
|
|
1338
1349
|
});
|
|
1339
1350
|
n(this, "onWindowTouchMove", (t) => {
|
|
1340
1351
|
if (t.touches.length !== 1)
|
|
1341
1352
|
return;
|
|
1342
1353
|
const o = t.touches[0];
|
|
1343
|
-
if (this.element !== null && (!
|
|
1354
|
+
if (this.element !== null && (!V(this.element, o.clientX, o.clientY) || !b(this.window, o.clientX, o.clientY))) {
|
|
1344
1355
|
this.cancelTouchDrag();
|
|
1345
1356
|
return;
|
|
1346
1357
|
}
|
|
@@ -1356,13 +1367,9 @@ class St {
|
|
|
1356
1367
|
this.previousTouchCoords = null, this.cancelTouchDrag();
|
|
1357
1368
|
});
|
|
1358
1369
|
n(this, "previousTouchCoords", null);
|
|
1359
|
-
n(this, "freezePriority");
|
|
1360
1370
|
n(this, "window", window);
|
|
1361
|
-
n(this, "
|
|
1362
|
-
|
|
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) ?? (() => {
|
|
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) ?? (() => {
|
|
1365
|
-
}), this.freezePriority = (o == null ? void 0 : o.moveOnTop) === !1, this.dragCursor = (o == null ? void 0 : o.dragCursor) !== void 0 ? o.dragCursor : "grab";
|
|
1371
|
+
n(this, "options");
|
|
1372
|
+
this.canvas = t, this.transformation = this.canvas.transformation, this.model = this.canvas.model, this.options = Tt(o ?? {});
|
|
1366
1373
|
}
|
|
1367
1374
|
attach(t) {
|
|
1368
1375
|
return this.detach(), this.element = t, this.canvas.attach(this.element), this;
|
|
@@ -1374,15 +1381,15 @@ class St {
|
|
|
1374
1381
|
const o = this.nodeIdGenerator.create(t.id);
|
|
1375
1382
|
this.canvas.addNode({ ...t, id: o }), this.updateMaxNodePriority(o);
|
|
1376
1383
|
const r = (s) => {
|
|
1377
|
-
if (this.element === null || s
|
|
1384
|
+
if (this.element === null || !this.options.mouseDownEventValidator(s))
|
|
1378
1385
|
return;
|
|
1379
1386
|
const h = this.model.getNode(o);
|
|
1380
|
-
this.onBeforeNodeDrag({
|
|
1387
|
+
this.options.onBeforeNodeDrag({
|
|
1381
1388
|
nodeId: o,
|
|
1382
1389
|
element: t.element,
|
|
1383
1390
|
x: h.x,
|
|
1384
1391
|
y: h.y
|
|
1385
|
-
}) && (s.stopImmediatePropagation(), this.grabbedNodeId = o,
|
|
1392
|
+
}) && (s.stopImmediatePropagation(), this.grabbedNodeId = o, p(this.element, this.options.dragCursor), this.moveNodeOnTop(o), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.window.addEventListener("mousemove", this.onWindowMouseMove));
|
|
1386
1393
|
}, i = (s) => {
|
|
1387
1394
|
if (s.touches.length !== 1)
|
|
1388
1395
|
return;
|
|
@@ -1391,7 +1398,7 @@ class St {
|
|
|
1391
1398
|
y: s.touches[0].clientY
|
|
1392
1399
|
};
|
|
1393
1400
|
const h = this.model.getNode(o);
|
|
1394
|
-
this.onBeforeNodeDrag({
|
|
1401
|
+
this.options.onBeforeNodeDrag({
|
|
1395
1402
|
nodeId: o,
|
|
1396
1403
|
element: t.element,
|
|
1397
1404
|
x: h.x,
|
|
@@ -1448,7 +1455,7 @@ class St {
|
|
|
1448
1455
|
if (i === null)
|
|
1449
1456
|
return;
|
|
1450
1457
|
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({
|
|
1458
|
+
this.canvas.updateNode(t, { x: g, y }), this.options.onNodeDrag({
|
|
1452
1459
|
nodeId: t,
|
|
1453
1460
|
element: i.element,
|
|
1454
1461
|
x: i.x,
|
|
@@ -1460,7 +1467,7 @@ class St {
|
|
|
1460
1467
|
this.maxNodePriority = Math.max(this.maxNodePriority, o);
|
|
1461
1468
|
}
|
|
1462
1469
|
moveNodeOnTop(t) {
|
|
1463
|
-
if (this.freezePriority)
|
|
1470
|
+
if (this.options.freezePriority)
|
|
1464
1471
|
return;
|
|
1465
1472
|
this.maxNodePriority += 2, this.updateNode(t, { priority: this.maxNodePriority });
|
|
1466
1473
|
const o = this.maxNodePriority - 1;
|
|
@@ -1470,12 +1477,12 @@ class St {
|
|
|
1470
1477
|
}
|
|
1471
1478
|
cancelMouseDrag() {
|
|
1472
1479
|
const t = this.model.getNode(this.grabbedNodeId);
|
|
1473
|
-
t !== null && this.onNodeDragFinished({
|
|
1480
|
+
t !== null && this.options.onNodeDragFinished({
|
|
1474
1481
|
nodeId: this.grabbedNodeId,
|
|
1475
1482
|
element: t.element,
|
|
1476
1483
|
x: t.x,
|
|
1477
1484
|
y: t.y
|
|
1478
|
-
}), this.grabbedNodeId = null, this.element !== null &&
|
|
1485
|
+
}), this.grabbedNodeId = null, this.element !== null && p(this.element, null), this.removeMouseDragListeners();
|
|
1479
1486
|
}
|
|
1480
1487
|
removeMouseDragListeners() {
|
|
1481
1488
|
this.window.removeEventListener("mouseup", this.onWindowMouseUp), this.window.removeEventListener("mousemove", this.onWindowMouseMove);
|
|
@@ -1483,7 +1490,7 @@ class St {
|
|
|
1483
1490
|
cancelTouchDrag() {
|
|
1484
1491
|
this.previousTouchCoords = null;
|
|
1485
1492
|
const t = this.model.getNode(this.grabbedNodeId);
|
|
1486
|
-
t !== null && this.onNodeDragFinished({
|
|
1493
|
+
t !== null && this.options.onNodeDragFinished({
|
|
1487
1494
|
nodeId: this.grabbedNodeId,
|
|
1488
1495
|
element: t.element,
|
|
1489
1496
|
x: t.x,
|
|
@@ -1494,7 +1501,7 @@ class St {
|
|
|
1494
1501
|
this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
|
|
1495
1502
|
}
|
|
1496
1503
|
}
|
|
1497
|
-
const
|
|
1504
|
+
const Ct = (e) => {
|
|
1498
1505
|
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
1506
|
return (s) => {
|
|
1500
1507
|
let h = s.nextTransform.dx, d = s.nextTransform.dy;
|
|
@@ -1504,7 +1511,7 @@ const At = (e) => {
|
|
|
1504
1511
|
const l = s.canvasHeight * s.prevTransform.scale;
|
|
1505
1512
|
return d > i - l && d > s.prevTransform.dy && (d = Math.max(s.prevTransform.dy, i - l)), { scale: s.nextTransform.scale, dx: h, dy: d };
|
|
1506
1513
|
};
|
|
1507
|
-
},
|
|
1514
|
+
}, Nt = (e) => {
|
|
1508
1515
|
const t = e.maxContentScale, o = e.minContentScale, r = t !== null ? 1 / t : 0, i = o !== null ? 1 / o : 1 / 0;
|
|
1509
1516
|
return (s) => {
|
|
1510
1517
|
const h = s.prevTransform, d = s.nextTransform;
|
|
@@ -1525,7 +1532,7 @@ const At = (e) => {
|
|
|
1525
1532
|
dy: a
|
|
1526
1533
|
};
|
|
1527
1534
|
};
|
|
1528
|
-
},
|
|
1535
|
+
}, Lt = (e) => (t) => e.reduce(
|
|
1529
1536
|
(o, r) => r({
|
|
1530
1537
|
prevTransform: t.prevTransform,
|
|
1531
1538
|
nextTransform: o,
|
|
@@ -1533,43 +1540,50 @@ const At = (e) => {
|
|
|
1533
1540
|
canvasHeight: t.canvasHeight
|
|
1534
1541
|
}),
|
|
1535
1542
|
t.nextTransform
|
|
1536
|
-
),
|
|
1543
|
+
), J = (e) => {
|
|
1537
1544
|
if (typeof e == "function")
|
|
1538
1545
|
return e;
|
|
1539
1546
|
switch (e.type) {
|
|
1540
1547
|
case "scale-limit":
|
|
1541
|
-
return
|
|
1548
|
+
return Nt({
|
|
1542
1549
|
minContentScale: e.minContentScale ?? 0,
|
|
1543
1550
|
maxContentScale: e.maxContentScale ?? 1 / 0
|
|
1544
1551
|
});
|
|
1545
1552
|
case "shift-limit":
|
|
1546
|
-
return
|
|
1553
|
+
return Ct({
|
|
1547
1554
|
minX: e.minX ?? -1 / 0,
|
|
1548
1555
|
maxX: e.maxX ?? 1 / 0,
|
|
1549
1556
|
minY: e.minY ?? -1 / 0,
|
|
1550
1557
|
maxY: e.maxY ?? 1 / 0
|
|
1551
1558
|
});
|
|
1552
1559
|
}
|
|
1553
|
-
},
|
|
1554
|
-
var
|
|
1555
|
-
const t = (
|
|
1560
|
+
}, Pt = (e) => {
|
|
1561
|
+
var f, A, S, T, X, P, D, I, j;
|
|
1562
|
+
const t = (f = e == null ? void 0 : e.scale) == null ? void 0 : f.mouseWheelSensitivity, o = t !== void 0 ? t : 1.2, r = e == null ? void 0 : e.transformPreprocessor;
|
|
1556
1563
|
let i;
|
|
1557
|
-
r !== void 0 ? Array.isArray(r) ? i =
|
|
1564
|
+
r !== void 0 ? Array.isArray(r) ? i = Lt(
|
|
1558
1565
|
r.map(
|
|
1559
|
-
(
|
|
1566
|
+
(L) => J(L)
|
|
1560
1567
|
)
|
|
1561
|
-
) : i =
|
|
1562
|
-
const s = ((
|
|
1563
|
-
}), d = ((
|
|
1564
|
-
});
|
|
1568
|
+
) : i = J(r) : i = (L) => L.nextTransform;
|
|
1569
|
+
const s = ((A = e == null ? void 0 : e.shift) == null ? void 0 : A.cursor) !== void 0 ? e.shift.cursor : "grab", h = ((S = e == null ? void 0 : e.events) == null ? void 0 : S.onBeforeTransformChange) ?? (() => {
|
|
1570
|
+
}), d = ((T = e == null ? void 0 : e.events) == null ? void 0 : T.onTransformChange) ?? (() => {
|
|
1571
|
+
}), c = (X = e == null ? void 0 : e.shift) == null ? void 0 : X.mouseDownEventValidator, l = c !== void 0 ? c : (L) => L.button === 0, a = (P = e == null ? void 0 : e.shift) == null ? void 0 : P.mouseUpEventValidator, g = a !== void 0 ? a : (L) => L.button === 0, y = (D = e == null ? void 0 : e.scale) == null ? void 0 : D.mouseWheelEventValidator, x = y !== void 0 ? y : () => !0;
|
|
1565
1572
|
return {
|
|
1566
1573
|
wheelSensitivity: o,
|
|
1567
|
-
|
|
1568
|
-
|
|
1574
|
+
onTransformStarted: ((I = e == null ? void 0 : e.events) == null ? void 0 : I.onTransformStarted) ?? (() => {
|
|
1575
|
+
}),
|
|
1576
|
+
onTransformFinished: ((j = e == null ? void 0 : e.events) == null ? void 0 : j.onTransformFinished) ?? (() => {
|
|
1577
|
+
}),
|
|
1578
|
+
onBeforeTransformChange: h,
|
|
1579
|
+
onTransformChange: d,
|
|
1569
1580
|
transformPreprocessor: i,
|
|
1570
|
-
shiftCursor: s
|
|
1581
|
+
shiftCursor: s,
|
|
1582
|
+
mouseDownEventValidator: l,
|
|
1583
|
+
mouseUpEventValidator: g,
|
|
1584
|
+
mouseWheelEventValidator: x
|
|
1571
1585
|
};
|
|
1572
|
-
},
|
|
1586
|
+
}, B = (e) => {
|
|
1573
1587
|
const t = [], o = e.touches.length;
|
|
1574
1588
|
for (let d = 0; d < o; d++)
|
|
1575
1589
|
t.push([e.touches[d].clientX, e.touches[d].clientY]);
|
|
@@ -1587,16 +1601,16 @@ const At = (e) => {
|
|
|
1587
1601
|
touchesCnt: o,
|
|
1588
1602
|
touches: t
|
|
1589
1603
|
};
|
|
1590
|
-
},
|
|
1604
|
+
}, Dt = (e, t, o) => ({
|
|
1591
1605
|
scale: e.scale,
|
|
1592
1606
|
dx: e.dx + e.scale * t,
|
|
1593
1607
|
dy: e.dy + e.scale * o
|
|
1594
|
-
}),
|
|
1608
|
+
}), It = (e, t, o, r) => ({
|
|
1595
1609
|
scale: e.scale * t,
|
|
1596
1610
|
dx: e.scale * (1 - t) * o + e.dx,
|
|
1597
1611
|
dy: e.scale * (1 - t) * r + e.dy
|
|
1598
1612
|
});
|
|
1599
|
-
class
|
|
1613
|
+
class mt {
|
|
1600
1614
|
constructor(t, o) {
|
|
1601
1615
|
n(this, "model");
|
|
1602
1616
|
n(this, "transformation");
|
|
@@ -1604,10 +1618,10 @@ class Pt {
|
|
|
1604
1618
|
n(this, "prevTouches", null);
|
|
1605
1619
|
n(this, "window", window);
|
|
1606
1620
|
n(this, "onMouseDown", (t) => {
|
|
1607
|
-
this.element === null || t
|
|
1621
|
+
this.element === null || !this.options.mouseDownEventValidator(t) || (p(this.element, this.options.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.options.onTransformStarted());
|
|
1608
1622
|
});
|
|
1609
1623
|
n(this, "onWindowMouseMove", (t) => {
|
|
1610
|
-
if (this.element === null || !
|
|
1624
|
+
if (this.element === null || !V(this.element, t.clientX, t.clientY) || !b(this.window, t.clientX, t.clientY)) {
|
|
1611
1625
|
this.stopMouseDrag();
|
|
1612
1626
|
return;
|
|
1613
1627
|
}
|
|
@@ -1615,23 +1629,25 @@ class Pt {
|
|
|
1615
1629
|
this.moveViewport(this.element, o, r);
|
|
1616
1630
|
});
|
|
1617
1631
|
n(this, "onWindowMouseUp", (t) => {
|
|
1618
|
-
this.element === null || t
|
|
1632
|
+
this.element === null || !this.options.mouseUpEventValidator(t) || this.stopMouseDrag();
|
|
1619
1633
|
});
|
|
1620
1634
|
n(this, "onWheelScroll", (t) => {
|
|
1635
|
+
if (!this.options.mouseWheelEventValidator(t))
|
|
1636
|
+
return;
|
|
1621
1637
|
t.preventDefault();
|
|
1622
1638
|
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
1639
|
this.scaleViewport(this.element, d, i, s);
|
|
1624
1640
|
});
|
|
1625
1641
|
n(this, "onTouchStart", (t) => {
|
|
1626
|
-
this.prevTouches =
|
|
1642
|
+
this.prevTouches = B(t), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish), this.options.onTransformStarted();
|
|
1627
1643
|
});
|
|
1628
1644
|
n(this, "onWindowTouchMove", (t) => {
|
|
1629
1645
|
const o = this.element;
|
|
1630
1646
|
if (o === null)
|
|
1631
1647
|
return;
|
|
1632
|
-
const r =
|
|
1648
|
+
const r = B(t);
|
|
1633
1649
|
if (!r.touches.every(
|
|
1634
|
-
(s) =>
|
|
1650
|
+
(s) => V(o, s[0], s[1]) && b(this.window, s[0], s[1])
|
|
1635
1651
|
)) {
|
|
1636
1652
|
this.stopTouchDrag();
|
|
1637
1653
|
return;
|
|
@@ -1647,7 +1663,7 @@ class Pt {
|
|
|
1647
1663
|
this.prevTouches = r;
|
|
1648
1664
|
});
|
|
1649
1665
|
n(this, "onWindowTouchFinish", (t) => {
|
|
1650
|
-
t.touches.length > 0 ? this.prevTouches =
|
|
1666
|
+
t.touches.length > 0 ? this.prevTouches = B(t) : this.stopTouchDrag();
|
|
1651
1667
|
});
|
|
1652
1668
|
n(this, "observer", new ResizeObserver(() => {
|
|
1653
1669
|
const t = this.canvas.transformation.getViewportMatrix(), { width: o, height: r } = this.element.getBoundingClientRect(), i = this.options.transformPreprocessor({
|
|
@@ -1656,10 +1672,10 @@ class Pt {
|
|
|
1656
1672
|
canvasWidth: o,
|
|
1657
1673
|
canvasHeight: r
|
|
1658
1674
|
});
|
|
1659
|
-
this.canvas.patchViewportMatrix(i), this.options.
|
|
1675
|
+
this.canvas.patchViewportMatrix(i), this.options.onTransformChange();
|
|
1660
1676
|
}));
|
|
1661
1677
|
n(this, "options");
|
|
1662
|
-
this.canvas = t, this.options =
|
|
1678
|
+
this.canvas = t, this.options = Pt(o), this.transformation = this.canvas.transformation, this.model = this.canvas.model;
|
|
1663
1679
|
}
|
|
1664
1680
|
attach(t) {
|
|
1665
1681
|
return this.detach(), this.element = t, this.observer.observe(this.element), this.element.addEventListener("mousedown", this.onMouseDown), this.element.addEventListener("wheel", this.onWheelScroll), this.element.addEventListener("touchstart", this.onTouchStart), this.canvas.attach(this.element), this;
|
|
@@ -1707,39 +1723,39 @@ class Pt {
|
|
|
1707
1723
|
this.detach(), this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.canvas.destroy();
|
|
1708
1724
|
}
|
|
1709
1725
|
moveViewport(t, o, r) {
|
|
1710
|
-
this.options.
|
|
1711
|
-
const i = this.transformation.getViewportMatrix(), s =
|
|
1726
|
+
this.options.onBeforeTransformChange();
|
|
1727
|
+
const i = this.transformation.getViewportMatrix(), s = Dt(i, o, r), { width: h, height: d } = t.getBoundingClientRect(), c = this.options.transformPreprocessor({
|
|
1712
1728
|
prevTransform: i,
|
|
1713
1729
|
nextTransform: s,
|
|
1714
1730
|
canvasWidth: h,
|
|
1715
1731
|
canvasHeight: d
|
|
1716
1732
|
});
|
|
1717
|
-
this.canvas.patchViewportMatrix(c), this.options.
|
|
1733
|
+
this.canvas.patchViewportMatrix(c), this.options.onTransformChange();
|
|
1718
1734
|
}
|
|
1719
1735
|
scaleViewport(t, o, r, i) {
|
|
1720
|
-
this.options.
|
|
1721
|
-
const s = this.canvas.transformation.getViewportMatrix(), h =
|
|
1736
|
+
this.options.onBeforeTransformChange();
|
|
1737
|
+
const s = this.canvas.transformation.getViewportMatrix(), h = It(s, o, r, i), { width: d, height: c } = t.getBoundingClientRect(), l = this.options.transformPreprocessor({
|
|
1722
1738
|
prevTransform: s,
|
|
1723
1739
|
nextTransform: h,
|
|
1724
1740
|
canvasWidth: d,
|
|
1725
1741
|
canvasHeight: c
|
|
1726
1742
|
});
|
|
1727
|
-
this.canvas.patchViewportMatrix(l), this.options.
|
|
1743
|
+
this.canvas.patchViewportMatrix(l), this.options.onTransformChange();
|
|
1728
1744
|
}
|
|
1729
1745
|
stopMouseDrag() {
|
|
1730
|
-
this.element !== null &&
|
|
1746
|
+
this.element !== null && p(this.element, null), this.removeMouseDragListeners(), this.options.onTransformFinished();
|
|
1731
1747
|
}
|
|
1732
1748
|
removeMouseDragListeners() {
|
|
1733
1749
|
this.window.removeEventListener("mousemove", this.onWindowMouseMove), this.window.removeEventListener("mouseup", this.onWindowMouseUp);
|
|
1734
1750
|
}
|
|
1735
1751
|
stopTouchDrag() {
|
|
1736
|
-
this.prevTouches = null, this.removeTouchDragListeners();
|
|
1752
|
+
this.prevTouches = null, this.removeTouchDragListeners(), this.options.onTransformFinished();
|
|
1737
1753
|
}
|
|
1738
1754
|
removeTouchDragListeners() {
|
|
1739
1755
|
this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
|
|
1740
1756
|
}
|
|
1741
1757
|
}
|
|
1742
|
-
class
|
|
1758
|
+
class $t {
|
|
1743
1759
|
constructor() {
|
|
1744
1760
|
n(this, "keyMap", /* @__PURE__ */ new Map());
|
|
1745
1761
|
n(this, "valueMap", /* @__PURE__ */ new Map());
|
|
@@ -1776,12 +1792,12 @@ class Lt {
|
|
|
1776
1792
|
this.keyMap.clear(), this.valueMap.clear();
|
|
1777
1793
|
}
|
|
1778
1794
|
}
|
|
1779
|
-
class
|
|
1795
|
+
class Vt {
|
|
1780
1796
|
constructor(t) {
|
|
1781
1797
|
n(this, "transformation");
|
|
1782
1798
|
n(this, "model");
|
|
1783
|
-
n(this, "nodes", new
|
|
1784
|
-
n(this, "nodeIdGenerator", new
|
|
1799
|
+
n(this, "nodes", new $t());
|
|
1800
|
+
n(this, "nodeIdGenerator", new m(
|
|
1785
1801
|
(t) => this.nodes.hasKey(t)
|
|
1786
1802
|
));
|
|
1787
1803
|
n(this, "nodesResizeObserver");
|
|
@@ -1850,7 +1866,7 @@ class Dt {
|
|
|
1850
1866
|
});
|
|
1851
1867
|
}
|
|
1852
1868
|
}
|
|
1853
|
-
class
|
|
1869
|
+
class pt {
|
|
1854
1870
|
constructor() {
|
|
1855
1871
|
n(this, "coreOptions");
|
|
1856
1872
|
n(this, "dragOptions");
|
|
@@ -1872,19 +1888,19 @@ class mt {
|
|
|
1872
1888
|
return this.hasResizeReactiveNodes = !0, this;
|
|
1873
1889
|
}
|
|
1874
1890
|
build() {
|
|
1875
|
-
let t = new
|
|
1876
|
-
return this.hasResizeReactiveNodes && (t = new
|
|
1891
|
+
let t = new At(this.coreOptions);
|
|
1892
|
+
return this.hasResizeReactiveNodes && (t = new Vt(t)), this.isDraggable && (t = new Mt(t, this.dragOptions)), this.isTransformable && (t = new mt(t, this.transformOptions)), t;
|
|
1877
1893
|
}
|
|
1878
1894
|
}
|
|
1879
1895
|
export {
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1896
|
+
nt as BezierEdgeShape,
|
|
1897
|
+
At as CanvasCore,
|
|
1898
|
+
st as HorizontalEdgeShape,
|
|
1899
|
+
pt as HtmlGraphBuilder,
|
|
1900
|
+
E as HtmlGraphError,
|
|
1901
|
+
Vt as ResizeReactiveNodesCanvas,
|
|
1902
|
+
ht as StraightEdgeShape,
|
|
1903
|
+
Mt as UserDraggableNodesCanvas,
|
|
1904
|
+
mt as UserTransformableCanvas,
|
|
1905
|
+
dt as VerticalEdgeShape
|
|
1890
1906
|
};
|