@html-graph/html-graph 0.1.5 → 0.1.7
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 +7 -8
- package/dist/main.js +275 -270
- package/dist/main.umd.cjs +1 -1
- package/package.json +3 -2
package/dist/main.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
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
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}`, c = `L ${s[1].x} ${s[1].y}`, d = `L ${s[2].x} ${s[2].y}`;
|
|
19
19
|
return `${h} ${c} ${d}`;
|
|
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;
|
|
@@ -26,29 +26,29 @@ const J = (e, t) => ({
|
|
|
26
26
|
let l = 0, a = 0, g = 0;
|
|
27
27
|
const y = d > 0, x = d < r, f = y && x;
|
|
28
28
|
if (y && (l = -i, a = -s, g = h), x) {
|
|
29
|
-
const
|
|
30
|
-
i =
|
|
29
|
+
const I = e[d + 1];
|
|
30
|
+
i = I.x - c.x, s = I.y - c.y, h = Math.sqrt(i * i + s * s);
|
|
31
31
|
}
|
|
32
|
-
const
|
|
33
|
-
d > 0 && o.push(`L ${
|
|
34
|
-
`C ${c.x} ${c.y} ${c.x} ${c.y} ${
|
|
32
|
+
const S = h !== 0 ? Math.min((f ? t : 0) / h, d < r - 1 ? 0.5 : 1) : 0, T = f ? { x: c.x + i * S, y: c.y + s * S } : c, P = g !== 0 ? Math.min((f ? t : 0) / g, d > 1 ? 0.5 : 1) : 0, D = f ? { x: c.x + l * P, y: c.y + a * P } : c;
|
|
33
|
+
d > 0 && o.push(`L ${D.x} ${D.y}`), f && o.push(
|
|
34
|
+
`C ${c.x} ${c.y} ${c.x} ${c.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,7 +64,7 @@ const J = (e, t) => ({
|
|
|
64
64
|
flipX: d,
|
|
65
65
|
flipY: l
|
|
66
66
|
};
|
|
67
|
-
},
|
|
67
|
+
}, q = (e) => {
|
|
68
68
|
const t = v(
|
|
69
69
|
{ x: e.arrowLength, y: w.y },
|
|
70
70
|
e.fromVect,
|
|
@@ -81,7 +81,7 @@ const J = (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} `, c = e.hasTargetArrow ? "" : ` M ${o.x} ${o.y} L ${e.to.x} ${e.to.y}`;
|
|
83
83
|
return `${h}${s}${c}`;
|
|
84
|
-
},
|
|
84
|
+
}, tt = (e) => {
|
|
85
85
|
const t = e.hasSourceArrow ? v(
|
|
86
86
|
{ x: e.arrowLength, y: w.y },
|
|
87
87
|
e.fromVect,
|
|
@@ -110,21 +110,21 @@ const J = (e, t) => ({
|
|
|
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: d.x + h,
|
|
115
115
|
y: d.y + c
|
|
116
|
-
},
|
|
116
|
+
}, S = {
|
|
117
117
|
x: a.x + h,
|
|
118
118
|
y: a.y + c
|
|
119
119
|
};
|
|
120
120
|
return [
|
|
121
121
|
`M ${t.x} ${t.y}`,
|
|
122
122
|
`L ${d.x} ${d.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
|
-
},
|
|
127
|
+
}, et = (e) => {
|
|
128
128
|
const t = e.hasSourceArrow ? v(
|
|
129
129
|
{ x: e.arrowLength, y: w.y },
|
|
130
130
|
e.fromVect,
|
|
@@ -141,11 +141,11 @@ const J = (e, t) => ({
|
|
|
141
141
|
x: e.flipX > 0 ? e.to.x - c : e.to.x + r,
|
|
142
142
|
y: h.y
|
|
143
143
|
}, y = { x: g.x, y: d };
|
|
144
|
-
return
|
|
144
|
+
return $(
|
|
145
145
|
[t, s, l, a, y, g, h, o],
|
|
146
146
|
e.roundness
|
|
147
147
|
);
|
|
148
|
-
},
|
|
148
|
+
}, G = (e) => {
|
|
149
149
|
const t = e.hasSourceArrow ? v(
|
|
150
150
|
{ x: e.arrowLength, y: w.y },
|
|
151
151
|
e.fromVect,
|
|
@@ -163,11 +163,11 @@ const J = (e, t) => ({
|
|
|
163
163
|
e.toVect,
|
|
164
164
|
e.to
|
|
165
165
|
), g = { x: a.x + c, y: a.y + d };
|
|
166
|
-
return
|
|
166
|
+
return $(
|
|
167
167
|
[t, i, l, g, a, o],
|
|
168
168
|
e.roundness
|
|
169
169
|
);
|
|
170
|
-
},
|
|
170
|
+
}, ot = (e) => {
|
|
171
171
|
const t = e.hasSourceArrow ? v(
|
|
172
172
|
{ x: e.arrowLength, y: w.y },
|
|
173
173
|
e.fromVect,
|
|
@@ -181,8 +181,8 @@ const J = (e, t) => ({
|
|
|
181
181
|
e.toVect,
|
|
182
182
|
e.to
|
|
183
183
|
);
|
|
184
|
-
return
|
|
185
|
-
},
|
|
184
|
+
return $([t, i, s, o], e.roundness);
|
|
185
|
+
}, rt = (e) => {
|
|
186
186
|
const t = e.hasSourceArrow ? v(
|
|
187
187
|
{ x: e.arrowLength, y: w.y },
|
|
188
188
|
e.fromVect,
|
|
@@ -199,11 +199,11 @@ const J = (e, t) => ({
|
|
|
199
199
|
x: h.x,
|
|
200
200
|
y: e.flipY > 0 ? e.to.y - c : e.to.y + r
|
|
201
201
|
}, y = { x: d, 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 },
|
|
@@ -216,8 +216,8 @@ const J = (e, t) => ({
|
|
|
216
216
|
].map(
|
|
217
217
|
(d) => v(d, e.fromVect, w)
|
|
218
218
|
), c = `M ${w.x} ${w.y} L ${h[0].x} ${h[0].y} `;
|
|
219
|
-
return `${e.hasSourceArrow || e.hasTargetArrow ? "" : c}${
|
|
220
|
-
},
|
|
219
|
+
return `${e.hasSourceArrow || e.hasTargetArrow ? "" : c}${$(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, d = [
|
|
222
222
|
{ x: e.arrowLength, y: w.y },
|
|
223
223
|
{ x: s, y: h },
|
|
@@ -230,7 +230,7 @@ const J = (e, t) => ({
|
|
|
230
230
|
].join(" "), a = `M 0 0 L ${d[0].x} ${d[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 J = (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: c } =
|
|
270
|
+
const { x: o, y: r, width: i, height: s, flipX: h, flipY: c } = 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}, ${c})`;
|
|
275
|
-
const d =
|
|
275
|
+
const d = M(
|
|
276
276
|
t.source.direction,
|
|
277
277
|
h,
|
|
278
278
|
c
|
|
279
|
-
), l =
|
|
279
|
+
), l = M(
|
|
280
280
|
t.target.direction,
|
|
281
281
|
h,
|
|
282
282
|
c
|
|
@@ -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: d,
|
|
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 = d, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g =
|
|
295
|
+
}), y = d, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g = tt({
|
|
296
296
|
to: a,
|
|
297
297
|
fromVect: d,
|
|
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: d,
|
|
310
310
|
toVect: l,
|
|
@@ -313,7 +313,7 @@ class ot {
|
|
|
313
313
|
hasSourceArrow: this.hasSourceArrow,
|
|
314
314
|
hasTargetArrow: this.hasTargetArrow
|
|
315
315
|
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
316
|
-
const f =
|
|
316
|
+
const f = C(
|
|
317
317
|
d,
|
|
318
318
|
w,
|
|
319
319
|
this.arrowLength,
|
|
@@ -322,7 +322,7 @@ class ot {
|
|
|
322
322
|
this.sourceArrow.setAttribute("d", f);
|
|
323
323
|
}
|
|
324
324
|
if (this.targetArrow) {
|
|
325
|
-
const f =
|
|
325
|
+
const f = C(
|
|
326
326
|
y,
|
|
327
327
|
a,
|
|
328
328
|
x,
|
|
@@ -332,10 +332,10 @@ class ot {
|
|
|
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: c } =
|
|
362
|
+
const { x: o, y: r, width: i, height: s, flipX: h, flipY: c } = 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}, ${c})`;
|
|
367
|
-
const d =
|
|
367
|
+
const d = M(
|
|
368
368
|
t.source.direction,
|
|
369
369
|
h,
|
|
370
370
|
c
|
|
371
|
-
), l =
|
|
371
|
+
), l = M(
|
|
372
372
|
t.target.direction,
|
|
373
373
|
h,
|
|
374
374
|
c
|
|
@@ -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: d,
|
|
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 = d, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g =
|
|
388
|
+
}), y = d, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g = G({
|
|
389
389
|
to: a,
|
|
390
390
|
fromVect: d,
|
|
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: d,
|
|
404
404
|
toVect: l,
|
|
@@ -409,7 +409,7 @@ class rt {
|
|
|
409
409
|
hasSourceArrow: this.hasSourceArrow,
|
|
410
410
|
hasTargetArrow: this.hasTargetArrow
|
|
411
411
|
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
412
|
-
const f =
|
|
412
|
+
const f = C(
|
|
413
413
|
d,
|
|
414
414
|
w,
|
|
415
415
|
this.arrowLength,
|
|
@@ -418,7 +418,7 @@ class rt {
|
|
|
418
418
|
this.sourceArrow.setAttribute("d", f);
|
|
419
419
|
}
|
|
420
420
|
if (this.targetArrow) {
|
|
421
|
-
const f =
|
|
421
|
+
const f = C(
|
|
422
422
|
y,
|
|
423
423
|
a,
|
|
424
424
|
x,
|
|
@@ -428,10 +428,10 @@ class rt {
|
|
|
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: c } =
|
|
458
|
+
const { x: o, y: r, width: i, height: s, flipX: h, flipY: c } = 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}, ${c})`;
|
|
463
|
-
const d =
|
|
463
|
+
const d = M(
|
|
464
464
|
t.source.direction,
|
|
465
465
|
h,
|
|
466
466
|
c
|
|
467
|
-
), l =
|
|
467
|
+
), l = M(
|
|
468
468
|
t.target.direction,
|
|
469
469
|
h,
|
|
470
470
|
c
|
|
@@ -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: d,
|
|
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 = d, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g =
|
|
484
|
+
}), y = d, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g = G({
|
|
485
485
|
to: a,
|
|
486
486
|
fromVect: d,
|
|
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: d,
|
|
500
500
|
toVect: l,
|
|
@@ -504,7 +504,7 @@ class it {
|
|
|
504
504
|
hasSourceArrow: this.hasSourceArrow,
|
|
505
505
|
hasTargetArrow: this.hasTargetArrow
|
|
506
506
|
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
507
|
-
const f =
|
|
507
|
+
const f = C(
|
|
508
508
|
d,
|
|
509
509
|
w,
|
|
510
510
|
this.arrowLength,
|
|
@@ -513,7 +513,7 @@ class it {
|
|
|
513
513
|
this.sourceArrow.setAttribute("d", f);
|
|
514
514
|
}
|
|
515
515
|
if (this.targetArrow) {
|
|
516
|
-
const f =
|
|
516
|
+
const f = C(
|
|
517
517
|
y,
|
|
518
518
|
a,
|
|
519
519
|
x,
|
|
@@ -523,10 +523,10 @@ class it {
|
|
|
523
523
|
}
|
|
524
524
|
}
|
|
525
525
|
}
|
|
526
|
-
class
|
|
526
|
+
class ct {
|
|
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: c } =
|
|
553
|
+
const { x: o, y: r, width: i, height: s, flipX: h, flipY: c } = 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}, ${c})`;
|
|
558
|
-
const d =
|
|
558
|
+
const d = M(
|
|
559
559
|
t.source.direction,
|
|
560
560
|
h,
|
|
561
561
|
c
|
|
562
|
-
), l =
|
|
562
|
+
), l = M(
|
|
563
563
|
t.target.direction,
|
|
564
564
|
h,
|
|
565
565
|
c
|
|
@@ -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: d,
|
|
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 = d, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g =
|
|
579
|
+
}), y = d, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g = G({
|
|
580
580
|
to: a,
|
|
581
581
|
fromVect: d,
|
|
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: d,
|
|
595
595
|
toVect: l,
|
|
@@ -600,7 +600,7 @@ class nt {
|
|
|
600
600
|
hasSourceArrow: this.hasSourceArrow,
|
|
601
601
|
hasTargetArrow: this.hasTargetArrow
|
|
602
602
|
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
603
|
-
const f =
|
|
603
|
+
const f = C(
|
|
604
604
|
d,
|
|
605
605
|
w,
|
|
606
606
|
this.arrowLength,
|
|
@@ -609,7 +609,7 @@ class nt {
|
|
|
609
609
|
this.sourceArrow.setAttribute("d", f);
|
|
610
610
|
}
|
|
611
611
|
if (this.targetArrow) {
|
|
612
|
-
const f =
|
|
612
|
+
const f = C(
|
|
613
613
|
y,
|
|
614
614
|
a,
|
|
615
615
|
x,
|
|
@@ -619,12 +619,12 @@ class nt {
|
|
|
619
619
|
}
|
|
620
620
|
}
|
|
621
621
|
}
|
|
622
|
-
const
|
|
622
|
+
const dt = (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 ct({
|
|
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: dt(((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 dt {
|
|
|
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 L {
|
|
|
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, c) {
|
|
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 = c;
|
|
@@ -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,52 +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
|
-
},
|
|
1315
|
-
var g, y, x, f,
|
|
1314
|
+
}, Tt = (e) => {
|
|
1315
|
+
var g, y, x, f, A, S;
|
|
1316
1316
|
const t = ((g = e == null ? void 0 : e.events) == null ? void 0 : g.onNodeDrag) ?? (() => {
|
|
1317
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", c = (
|
|
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", c = (A = e == null ? void 0 : e.mouse) == null ? void 0 : A.mouseDownEventVerifier, d = c !== void 0 ? c : (T) => T.button === 0, l = (S = e == null ? void 0 : e.mouse) == null ? void 0 : S.mouseUpEventVerifier;
|
|
1319
1319
|
return {
|
|
1320
1320
|
freezePriority: i,
|
|
1321
1321
|
dragCursor: h,
|
|
1322
|
-
|
|
1323
|
-
|
|
1322
|
+
mouseDownEventVerifier: d,
|
|
1323
|
+
mouseUpEventVerifier: l !== void 0 ? l : (T) => T.button === 0,
|
|
1324
1324
|
onNodeDrag: t,
|
|
1325
1325
|
onBeforeNodeDrag: o,
|
|
1326
1326
|
onNodeDragFinished: r
|
|
1327
1327
|
};
|
|
1328
1328
|
};
|
|
1329
|
-
class
|
|
1329
|
+
class Mt {
|
|
1330
1330
|
constructor(t, o) {
|
|
1331
1331
|
n(this, "model");
|
|
1332
1332
|
n(this, "transformation");
|
|
1333
1333
|
n(this, "maxNodePriority", 0);
|
|
1334
1334
|
n(this, "nodes", /* @__PURE__ */ new Map());
|
|
1335
1335
|
n(this, "grabbedNodeId", null);
|
|
1336
|
-
n(this, "nodeIdGenerator", new
|
|
1336
|
+
n(this, "nodeIdGenerator", new m(
|
|
1337
1337
|
(t) => this.nodes.has(t)
|
|
1338
1338
|
));
|
|
1339
1339
|
n(this, "element", null);
|
|
1340
1340
|
n(this, "onWindowMouseMove", (t) => {
|
|
1341
|
-
if (this.element !== null && (!
|
|
1341
|
+
if (this.element !== null && (!V(this.element, t.clientX, t.clientY) || !b(this.window, t.clientX, t.clientY))) {
|
|
1342
1342
|
this.cancelMouseDrag();
|
|
1343
1343
|
return;
|
|
1344
1344
|
}
|
|
1345
1345
|
this.grabbedNodeId !== null && this.dragNode(this.grabbedNodeId, t.movementX, t.movementY);
|
|
1346
1346
|
});
|
|
1347
1347
|
n(this, "onWindowMouseUp", (t) => {
|
|
1348
|
-
this.options.
|
|
1348
|
+
this.options.mouseUpEventVerifier(t) && this.cancelMouseDrag();
|
|
1349
1349
|
});
|
|
1350
1350
|
n(this, "onWindowTouchMove", (t) => {
|
|
1351
1351
|
if (t.touches.length !== 1)
|
|
1352
1352
|
return;
|
|
1353
1353
|
const o = t.touches[0];
|
|
1354
|
-
if (this.element !== null && (!
|
|
1354
|
+
if (this.element !== null && (!V(this.element, o.clientX, o.clientY) || !b(this.window, o.clientX, o.clientY))) {
|
|
1355
1355
|
this.cancelTouchDrag();
|
|
1356
1356
|
return;
|
|
1357
1357
|
}
|
|
@@ -1369,7 +1369,7 @@ class Et {
|
|
|
1369
1369
|
n(this, "previousTouchCoords", null);
|
|
1370
1370
|
n(this, "window", window);
|
|
1371
1371
|
n(this, "options");
|
|
1372
|
-
this.canvas = t, this.transformation = this.canvas.transformation, this.model = this.canvas.model, this.options =
|
|
1372
|
+
this.canvas = t, this.transformation = this.canvas.transformation, this.model = this.canvas.model, this.options = Tt(o ?? {});
|
|
1373
1373
|
}
|
|
1374
1374
|
attach(t) {
|
|
1375
1375
|
return this.detach(), this.element = t, this.canvas.attach(this.element), this;
|
|
@@ -1381,7 +1381,7 @@ class Et {
|
|
|
1381
1381
|
const o = this.nodeIdGenerator.create(t.id);
|
|
1382
1382
|
this.canvas.addNode({ ...t, id: o }), this.updateMaxNodePriority(o);
|
|
1383
1383
|
const r = (s) => {
|
|
1384
|
-
if (this.element === null || !this.options.
|
|
1384
|
+
if (this.element === null || !this.options.mouseDownEventVerifier(s))
|
|
1385
1385
|
return;
|
|
1386
1386
|
const h = this.model.getNode(o);
|
|
1387
1387
|
this.options.onBeforeNodeDrag({
|
|
@@ -1389,7 +1389,7 @@ class Et {
|
|
|
1389
1389
|
element: t.element,
|
|
1390
1390
|
x: h.x,
|
|
1391
1391
|
y: h.y
|
|
1392
|
-
}) && (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));
|
|
1393
1393
|
}, i = (s) => {
|
|
1394
1394
|
if (s.touches.length !== 1)
|
|
1395
1395
|
return;
|
|
@@ -1458,8 +1458,8 @@ class Et {
|
|
|
1458
1458
|
this.canvas.updateNode(t, { x: g, y }), this.options.onNodeDrag({
|
|
1459
1459
|
nodeId: t,
|
|
1460
1460
|
element: i.element,
|
|
1461
|
-
x:
|
|
1462
|
-
y
|
|
1461
|
+
x: g,
|
|
1462
|
+
y
|
|
1463
1463
|
});
|
|
1464
1464
|
}
|
|
1465
1465
|
updateMaxNodePriority(t) {
|
|
@@ -1482,7 +1482,7 @@ class Et {
|
|
|
1482
1482
|
element: t.element,
|
|
1483
1483
|
x: t.x,
|
|
1484
1484
|
y: t.y
|
|
1485
|
-
}), this.grabbedNodeId = null, this.element !== null &&
|
|
1485
|
+
}), this.grabbedNodeId = null, this.element !== null && p(this.element, null), this.removeMouseDragListeners();
|
|
1486
1486
|
}
|
|
1487
1487
|
removeMouseDragListeners() {
|
|
1488
1488
|
this.window.removeEventListener("mouseup", this.onWindowMouseUp), this.window.removeEventListener("mousemove", this.onWindowMouseMove);
|
|
@@ -1501,7 +1501,7 @@ class Et {
|
|
|
1501
1501
|
this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
|
|
1502
1502
|
}
|
|
1503
1503
|
}
|
|
1504
|
-
const
|
|
1504
|
+
const Ct = (e) => {
|
|
1505
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;
|
|
1506
1506
|
return (s) => {
|
|
1507
1507
|
let h = s.nextTransform.dx, c = s.nextTransform.dy;
|
|
@@ -1511,7 +1511,7 @@ const At = (e) => {
|
|
|
1511
1511
|
const l = s.canvasHeight * s.prevTransform.scale;
|
|
1512
1512
|
return c > i - l && c > s.prevTransform.dy && (c = Math.max(s.prevTransform.dy, i - l)), { scale: s.nextTransform.scale, dx: h, dy: c };
|
|
1513
1513
|
};
|
|
1514
|
-
},
|
|
1514
|
+
}, Nt = (e) => {
|
|
1515
1515
|
const t = e.maxContentScale, o = e.minContentScale, r = t !== null ? 1 / t : 0, i = o !== null ? 1 / o : 1 / 0;
|
|
1516
1516
|
return (s) => {
|
|
1517
1517
|
const h = s.prevTransform, c = s.nextTransform;
|
|
@@ -1532,7 +1532,7 @@ const At = (e) => {
|
|
|
1532
1532
|
dy: a
|
|
1533
1533
|
};
|
|
1534
1534
|
};
|
|
1535
|
-
},
|
|
1535
|
+
}, Lt = (e) => (t) => e.reduce(
|
|
1536
1536
|
(o, r) => r({
|
|
1537
1537
|
prevTransform: t.prevTransform,
|
|
1538
1538
|
nextTransform: o,
|
|
@@ -1540,47 +1540,50 @@ const At = (e) => {
|
|
|
1540
1540
|
canvasHeight: t.canvasHeight
|
|
1541
1541
|
}),
|
|
1542
1542
|
t.nextTransform
|
|
1543
|
-
),
|
|
1543
|
+
), J = (e) => {
|
|
1544
1544
|
if (typeof e == "function")
|
|
1545
1545
|
return e;
|
|
1546
1546
|
switch (e.type) {
|
|
1547
1547
|
case "scale-limit":
|
|
1548
|
-
return
|
|
1548
|
+
return Nt({
|
|
1549
1549
|
minContentScale: e.minContentScale ?? 0,
|
|
1550
1550
|
maxContentScale: e.maxContentScale ?? 1 / 0
|
|
1551
1551
|
});
|
|
1552
1552
|
case "shift-limit":
|
|
1553
|
-
return
|
|
1553
|
+
return Ct({
|
|
1554
1554
|
minX: e.minX ?? -1 / 0,
|
|
1555
1555
|
maxX: e.maxX ?? 1 / 0,
|
|
1556
1556
|
minY: e.minY ?? -1 / 0,
|
|
1557
1557
|
maxY: e.maxY ?? 1 / 0
|
|
1558
1558
|
});
|
|
1559
1559
|
}
|
|
1560
|
-
},
|
|
1561
|
-
var
|
|
1562
|
-
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;
|
|
1563
1563
|
let i;
|
|
1564
|
-
r !== void 0 ? Array.isArray(r) ? i =
|
|
1564
|
+
r !== void 0 ? Array.isArray(r) ? i = Lt(
|
|
1565
1565
|
r.map(
|
|
1566
|
-
(
|
|
1566
|
+
(L) => J(L)
|
|
1567
1567
|
)
|
|
1568
|
-
) : i =
|
|
1569
|
-
const s = ((
|
|
1570
|
-
}), c = ((
|
|
1571
|
-
});
|
|
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
|
+
}), c = ((T = e == null ? void 0 : e.events) == null ? void 0 : T.onTransformChange) ?? (() => {
|
|
1571
|
+
}), d = (X = e == null ? void 0 : e.shift) == null ? void 0 : X.mouseDownEventVerifier, l = d !== void 0 ? d : (L) => L.button === 0, a = (P = e == null ? void 0 : e.shift) == null ? void 0 : P.mouseUpEventVerifier, g = a !== void 0 ? a : (L) => L.button === 0, y = (D = e == null ? void 0 : e.scale) == null ? void 0 : D.mouseWheelEventVerifier, x = y !== void 0 ? y : () => !0;
|
|
1572
1572
|
return {
|
|
1573
1573
|
wheelSensitivity: o,
|
|
1574
|
-
onTransformStarted: ((
|
|
1574
|
+
onTransformStarted: ((I = e == null ? void 0 : e.events) == null ? void 0 : I.onTransformStarted) ?? (() => {
|
|
1575
1575
|
}),
|
|
1576
|
-
onTransformFinished: ((
|
|
1576
|
+
onTransformFinished: ((j = e == null ? void 0 : e.events) == null ? void 0 : j.onTransformFinished) ?? (() => {
|
|
1577
1577
|
}),
|
|
1578
1578
|
onBeforeTransformChange: h,
|
|
1579
1579
|
onTransformChange: c,
|
|
1580
1580
|
transformPreprocessor: i,
|
|
1581
|
-
shiftCursor: s
|
|
1581
|
+
shiftCursor: s,
|
|
1582
|
+
mouseDownEventVerifier: l,
|
|
1583
|
+
mouseUpEventVerifier: g,
|
|
1584
|
+
mouseWheelEventVerifier: x
|
|
1582
1585
|
};
|
|
1583
|
-
},
|
|
1586
|
+
}, B = (e) => {
|
|
1584
1587
|
const t = [], o = e.touches.length;
|
|
1585
1588
|
for (let c = 0; c < o; c++)
|
|
1586
1589
|
t.push([e.touches[c].clientX, e.touches[c].clientY]);
|
|
@@ -1598,16 +1601,16 @@ const At = (e) => {
|
|
|
1598
1601
|
touchesCnt: o,
|
|
1599
1602
|
touches: t
|
|
1600
1603
|
};
|
|
1601
|
-
},
|
|
1604
|
+
}, Dt = (e, t, o) => ({
|
|
1602
1605
|
scale: e.scale,
|
|
1603
1606
|
dx: e.dx + e.scale * t,
|
|
1604
1607
|
dy: e.dy + e.scale * o
|
|
1605
|
-
}),
|
|
1608
|
+
}), It = (e, t, o, r) => ({
|
|
1606
1609
|
scale: e.scale * t,
|
|
1607
1610
|
dx: e.scale * (1 - t) * o + e.dx,
|
|
1608
1611
|
dy: e.scale * (1 - t) * r + e.dy
|
|
1609
1612
|
});
|
|
1610
|
-
class
|
|
1613
|
+
class mt {
|
|
1611
1614
|
constructor(t, o) {
|
|
1612
1615
|
n(this, "model");
|
|
1613
1616
|
n(this, "transformation");
|
|
@@ -1615,10 +1618,10 @@ class Pt {
|
|
|
1615
1618
|
n(this, "prevTouches", null);
|
|
1616
1619
|
n(this, "window", window);
|
|
1617
1620
|
n(this, "onMouseDown", (t) => {
|
|
1618
|
-
this.element === null || t
|
|
1621
|
+
this.element === null || !this.options.mouseDownEventVerifier(t) || (p(this.element, this.options.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.options.onTransformStarted());
|
|
1619
1622
|
});
|
|
1620
1623
|
n(this, "onWindowMouseMove", (t) => {
|
|
1621
|
-
if (this.element === null || !
|
|
1624
|
+
if (this.element === null || !V(this.element, t.clientX, t.clientY) || !b(this.window, t.clientX, t.clientY)) {
|
|
1622
1625
|
this.stopMouseDrag();
|
|
1623
1626
|
return;
|
|
1624
1627
|
}
|
|
@@ -1626,23 +1629,25 @@ class Pt {
|
|
|
1626
1629
|
this.moveViewport(this.element, o, r);
|
|
1627
1630
|
});
|
|
1628
1631
|
n(this, "onWindowMouseUp", (t) => {
|
|
1629
|
-
this.element === null || t
|
|
1632
|
+
this.element === null || !this.options.mouseUpEventVerifier(t) || this.stopMouseDrag();
|
|
1630
1633
|
});
|
|
1631
1634
|
n(this, "onWheelScroll", (t) => {
|
|
1632
|
-
|
|
1635
|
+
if (!this.options.mouseWheelEventVerifier(t))
|
|
1636
|
+
return;
|
|
1637
|
+
t.preventDefault(), this.options.onTransformStarted();
|
|
1633
1638
|
const { left: o, top: r } = this.element.getBoundingClientRect(), i = t.clientX - o, s = t.clientY - r, c = 1 / (t.deltaY < 0 ? this.options.wheelSensitivity : 1 / this.options.wheelSensitivity);
|
|
1634
|
-
this.scaleViewport(this.element, c, i, s);
|
|
1639
|
+
this.scaleViewport(this.element, c, i, s), this.options.onTransformFinished();
|
|
1635
1640
|
});
|
|
1636
1641
|
n(this, "onTouchStart", (t) => {
|
|
1637
|
-
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();
|
|
1638
1643
|
});
|
|
1639
1644
|
n(this, "onWindowTouchMove", (t) => {
|
|
1640
1645
|
const o = this.element;
|
|
1641
1646
|
if (o === null)
|
|
1642
1647
|
return;
|
|
1643
|
-
const r =
|
|
1648
|
+
const r = B(t);
|
|
1644
1649
|
if (!r.touches.every(
|
|
1645
|
-
(s) =>
|
|
1650
|
+
(s) => V(o, s[0], s[1]) && b(this.window, s[0], s[1])
|
|
1646
1651
|
)) {
|
|
1647
1652
|
this.stopTouchDrag();
|
|
1648
1653
|
return;
|
|
@@ -1658,7 +1663,7 @@ class Pt {
|
|
|
1658
1663
|
this.prevTouches = r;
|
|
1659
1664
|
});
|
|
1660
1665
|
n(this, "onWindowTouchFinish", (t) => {
|
|
1661
|
-
t.touches.length > 0 ? this.prevTouches =
|
|
1666
|
+
t.touches.length > 0 ? this.prevTouches = B(t) : this.stopTouchDrag();
|
|
1662
1667
|
});
|
|
1663
1668
|
n(this, "observer", new ResizeObserver(() => {
|
|
1664
1669
|
const t = this.canvas.transformation.getViewportMatrix(), { width: o, height: r } = this.element.getBoundingClientRect(), i = this.options.transformPreprocessor({
|
|
@@ -1670,7 +1675,7 @@ class Pt {
|
|
|
1670
1675
|
this.canvas.patchViewportMatrix(i), this.options.onTransformChange();
|
|
1671
1676
|
}));
|
|
1672
1677
|
n(this, "options");
|
|
1673
|
-
this.canvas = t, this.options =
|
|
1678
|
+
this.canvas = t, this.options = Pt(o), this.transformation = this.canvas.transformation, this.model = this.canvas.model;
|
|
1674
1679
|
}
|
|
1675
1680
|
attach(t) {
|
|
1676
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;
|
|
@@ -1719,7 +1724,7 @@ class Pt {
|
|
|
1719
1724
|
}
|
|
1720
1725
|
moveViewport(t, o, r) {
|
|
1721
1726
|
this.options.onBeforeTransformChange();
|
|
1722
|
-
const i = this.transformation.getViewportMatrix(), s =
|
|
1727
|
+
const i = this.transformation.getViewportMatrix(), s = Dt(i, o, r), { width: h, height: c } = t.getBoundingClientRect(), d = this.options.transformPreprocessor({
|
|
1723
1728
|
prevTransform: i,
|
|
1724
1729
|
nextTransform: s,
|
|
1725
1730
|
canvasWidth: h,
|
|
@@ -1729,7 +1734,7 @@ class Pt {
|
|
|
1729
1734
|
}
|
|
1730
1735
|
scaleViewport(t, o, r, i) {
|
|
1731
1736
|
this.options.onBeforeTransformChange();
|
|
1732
|
-
const s = this.canvas.transformation.getViewportMatrix(), h =
|
|
1737
|
+
const s = this.canvas.transformation.getViewportMatrix(), h = It(s, o, r, i), { width: c, height: d } = t.getBoundingClientRect(), l = this.options.transformPreprocessor({
|
|
1733
1738
|
prevTransform: s,
|
|
1734
1739
|
nextTransform: h,
|
|
1735
1740
|
canvasWidth: c,
|
|
@@ -1738,7 +1743,7 @@ class Pt {
|
|
|
1738
1743
|
this.canvas.patchViewportMatrix(l), this.options.onTransformChange();
|
|
1739
1744
|
}
|
|
1740
1745
|
stopMouseDrag() {
|
|
1741
|
-
this.element !== null &&
|
|
1746
|
+
this.element !== null && p(this.element, null), this.removeMouseDragListeners(), this.options.onTransformFinished();
|
|
1742
1747
|
}
|
|
1743
1748
|
removeMouseDragListeners() {
|
|
1744
1749
|
this.window.removeEventListener("mousemove", this.onWindowMouseMove), this.window.removeEventListener("mouseup", this.onWindowMouseUp);
|
|
@@ -1750,7 +1755,7 @@ class Pt {
|
|
|
1750
1755
|
this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
|
|
1751
1756
|
}
|
|
1752
1757
|
}
|
|
1753
|
-
class
|
|
1758
|
+
class $t {
|
|
1754
1759
|
constructor() {
|
|
1755
1760
|
n(this, "keyMap", /* @__PURE__ */ new Map());
|
|
1756
1761
|
n(this, "valueMap", /* @__PURE__ */ new Map());
|
|
@@ -1787,12 +1792,12 @@ class Dt {
|
|
|
1787
1792
|
this.keyMap.clear(), this.valueMap.clear();
|
|
1788
1793
|
}
|
|
1789
1794
|
}
|
|
1790
|
-
class
|
|
1795
|
+
class Vt {
|
|
1791
1796
|
constructor(t) {
|
|
1792
1797
|
n(this, "transformation");
|
|
1793
1798
|
n(this, "model");
|
|
1794
|
-
n(this, "nodes", new
|
|
1795
|
-
n(this, "nodeIdGenerator", new
|
|
1799
|
+
n(this, "nodes", new $t());
|
|
1800
|
+
n(this, "nodeIdGenerator", new m(
|
|
1796
1801
|
(t) => this.nodes.hasKey(t)
|
|
1797
1802
|
));
|
|
1798
1803
|
n(this, "nodesResizeObserver");
|
|
@@ -1883,19 +1888,19 @@ class pt {
|
|
|
1883
1888
|
return this.hasResizeReactiveNodes = !0, this;
|
|
1884
1889
|
}
|
|
1885
1890
|
build() {
|
|
1886
|
-
let t = new
|
|
1887
|
-
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;
|
|
1888
1893
|
}
|
|
1889
1894
|
}
|
|
1890
1895
|
export {
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1896
|
+
nt as BezierEdgeShape,
|
|
1897
|
+
At as CanvasCore,
|
|
1898
|
+
st as HorizontalEdgeShape,
|
|
1894
1899
|
pt as HtmlGraphBuilder,
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1900
|
+
E as HtmlGraphError,
|
|
1901
|
+
Vt as ResizeReactiveNodesCanvas,
|
|
1902
|
+
ht as StraightEdgeShape,
|
|
1903
|
+
Mt as UserDraggableNodesCanvas,
|
|
1904
|
+
mt as UserTransformableCanvas,
|
|
1905
|
+
ct as VerticalEdgeShape
|
|
1901
1906
|
};
|