@html-graph/html-graph 0.0.60 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/dist/main.d.ts +240 -105
- package/dist/main.js +1131 -1082
- package/dist/main.umd.cjs +1 -1
- package/package.json +2 -1
package/dist/main.js
CHANGED
|
@@ -1,256 +1,37 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var a = (r, e, t) =>
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}), X = {
|
|
9
|
-
scale: 1,
|
|
10
|
-
dx: 0,
|
|
11
|
-
dy: 0
|
|
12
|
-
};
|
|
13
|
-
class Q {
|
|
14
|
-
constructor() {
|
|
15
|
-
a(this, "viewportMatrix", X);
|
|
16
|
-
a(this, "contentMatrix", X);
|
|
17
|
-
}
|
|
18
|
-
getViewportMatrix() {
|
|
19
|
-
return this.viewportMatrix;
|
|
20
|
-
}
|
|
21
|
-
getContentMatrix() {
|
|
22
|
-
return this.contentMatrix;
|
|
23
|
-
}
|
|
24
|
-
patchViewportMatrix(e, t, s) {
|
|
25
|
-
this.viewportMatrix = {
|
|
26
|
-
scale: e ?? this.viewportMatrix.scale,
|
|
27
|
-
dx: t ?? this.viewportMatrix.dx,
|
|
28
|
-
dy: s ?? this.viewportMatrix.dy
|
|
29
|
-
}, this.contentMatrix = Y(this.viewportMatrix);
|
|
30
|
-
}
|
|
31
|
-
patchContentMatrix(e, t, s) {
|
|
32
|
-
this.contentMatrix = {
|
|
33
|
-
scale: e ?? this.contentMatrix.scale,
|
|
34
|
-
dx: t ?? this.contentMatrix.dx,
|
|
35
|
-
dy: s ?? this.contentMatrix.dy
|
|
36
|
-
}, this.viewportMatrix = Y(this.contentMatrix);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
class Z {
|
|
40
|
-
constructor(e) {
|
|
41
|
-
this.transformer = e;
|
|
42
|
-
}
|
|
43
|
-
getViewportMatrix() {
|
|
44
|
-
return { ...this.transformer.getViewportMatrix() };
|
|
45
|
-
}
|
|
46
|
-
getContentMatrix() {
|
|
47
|
-
return { ...this.transformer.getContentMatrix() };
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
class q {
|
|
51
|
-
constructor() {
|
|
52
|
-
a(this, "nodes", /* @__PURE__ */ new Map());
|
|
53
|
-
a(this, "ports", /* @__PURE__ */ new Map());
|
|
54
|
-
a(this, "nodePorts", /* @__PURE__ */ new Map());
|
|
55
|
-
a(this, "portNodeId", /* @__PURE__ */ new Map());
|
|
56
|
-
a(this, "edges", /* @__PURE__ */ new Map());
|
|
57
|
-
a(this, "incommingEdges", /* @__PURE__ */ new Map());
|
|
58
|
-
a(this, "outcommingEdges", /* @__PURE__ */ new Map());
|
|
59
|
-
a(this, "cycleEdges", /* @__PURE__ */ new Map());
|
|
60
|
-
}
|
|
61
|
-
addNode(e, t, s, o, i, n) {
|
|
62
|
-
this.nodes.set(e, { element: t, x: s, y: o, centerFn: i, priority: n }), this.nodePorts.set(e, /* @__PURE__ */ new Map());
|
|
63
|
-
}
|
|
64
|
-
getAllNodeIds() {
|
|
65
|
-
return Array.from(this.nodes.keys());
|
|
66
|
-
}
|
|
67
|
-
getNode(e) {
|
|
68
|
-
return this.nodes.get(e);
|
|
69
|
-
}
|
|
70
|
-
removeNode(e) {
|
|
71
|
-
this.nodes.delete(e), this.nodePorts.delete(e);
|
|
72
|
-
}
|
|
73
|
-
addPort(e, t, s, o, i) {
|
|
74
|
-
this.ports.set(e, { element: t, centerFn: o, direction: i }), this.cycleEdges.set(e, /* @__PURE__ */ new Set()), this.incommingEdges.set(e, /* @__PURE__ */ new Set()), this.outcommingEdges.set(e, /* @__PURE__ */ new Set()), this.portNodeId.set(e, s), this.nodePorts.get(s).set(e, t);
|
|
75
|
-
}
|
|
76
|
-
getPort(e) {
|
|
77
|
-
return this.ports.get(e);
|
|
78
|
-
}
|
|
79
|
-
getAllPortIds() {
|
|
80
|
-
return Array.from(this.ports.keys());
|
|
81
|
-
}
|
|
82
|
-
getNodePortIds(e) {
|
|
83
|
-
const t = this.nodePorts.get(e);
|
|
84
|
-
if (t !== void 0)
|
|
85
|
-
return Array.from(t.keys());
|
|
86
|
-
}
|
|
87
|
-
getPortNodeId(e) {
|
|
88
|
-
return this.portNodeId.get(e);
|
|
89
|
-
}
|
|
90
|
-
removePort(e) {
|
|
91
|
-
const t = this.portNodeId.get(e);
|
|
92
|
-
this.portNodeId.delete(e), this.nodePorts.get(t).delete(e), this.ports.delete(e);
|
|
93
|
-
}
|
|
94
|
-
addEdge(e, t, s, o, i) {
|
|
95
|
-
this.edges.set(e, {
|
|
96
|
-
from: t,
|
|
97
|
-
to: s,
|
|
98
|
-
shape: o,
|
|
99
|
-
priority: i
|
|
100
|
-
}), t !== s ? (this.outcommingEdges.get(t).add(e), this.incommingEdges.get(s).add(e)) : this.cycleEdges.get(t).add(e);
|
|
101
|
-
}
|
|
102
|
-
getAllEdgeIds() {
|
|
103
|
-
return Array.from(this.edges.keys());
|
|
104
|
-
}
|
|
105
|
-
getEdge(e) {
|
|
106
|
-
return this.edges.get(e);
|
|
107
|
-
}
|
|
108
|
-
removeEdge(e) {
|
|
109
|
-
const t = this.edges.get(e), s = t.from, o = t.to;
|
|
110
|
-
this.cycleEdges.get(s).delete(e), this.cycleEdges.get(o).delete(e), this.incommingEdges.get(s).delete(e), this.incommingEdges.get(o).delete(e), this.outcommingEdges.get(s).delete(e), this.outcommingEdges.get(o).delete(e), this.edges.delete(e);
|
|
111
|
-
}
|
|
112
|
-
clear() {
|
|
113
|
-
this.nodes.clear(), this.ports.clear(), this.nodePorts.clear(), this.portNodeId.clear(), this.edges.clear(), this.incommingEdges.clear(), this.outcommingEdges.clear(), this.cycleEdges.clear();
|
|
114
|
-
}
|
|
115
|
-
getPortIncomingEdgeIds(e) {
|
|
116
|
-
return Array.from(this.incommingEdges.get(e));
|
|
117
|
-
}
|
|
118
|
-
getPortOutcomingEdgeIds(e) {
|
|
119
|
-
return Array.from(this.outcommingEdges.get(e));
|
|
120
|
-
}
|
|
121
|
-
getPortCycleEdgeIds(e) {
|
|
122
|
-
return Array.from(this.cycleEdges.get(e));
|
|
123
|
-
}
|
|
124
|
-
getPortAdjacentEdgeIds(e) {
|
|
125
|
-
return [
|
|
126
|
-
...this.getPortIncomingEdgeIds(e),
|
|
127
|
-
...this.getPortOutcomingEdgeIds(e),
|
|
128
|
-
...this.getPortCycleEdgeIds(e)
|
|
129
|
-
];
|
|
130
|
-
}
|
|
131
|
-
getNodeIncomingEdgeIds(e) {
|
|
132
|
-
const t = Array.from(this.nodePorts.get(e).keys());
|
|
133
|
-
let s = [];
|
|
134
|
-
return t.forEach((o) => {
|
|
135
|
-
s = [...s, ...this.getPortIncomingEdgeIds(o)];
|
|
136
|
-
}), s;
|
|
137
|
-
}
|
|
138
|
-
getNodeOutcomingEdgeIds(e) {
|
|
139
|
-
const t = Array.from(this.nodePorts.get(e).keys());
|
|
140
|
-
let s = [];
|
|
141
|
-
return t.forEach((o) => {
|
|
142
|
-
s = [...s, ...this.getPortOutcomingEdgeIds(o)];
|
|
143
|
-
}), s;
|
|
144
|
-
}
|
|
145
|
-
getNodeCycleEdgeIds(e) {
|
|
146
|
-
const t = Array.from(this.nodePorts.get(e).keys());
|
|
147
|
-
let s = [];
|
|
148
|
-
return t.forEach((o) => {
|
|
149
|
-
s = [...s, ...this.getPortCycleEdgeIds(o)];
|
|
150
|
-
}), s;
|
|
151
|
-
}
|
|
152
|
-
getNodeAdjacentEdgeIds(e) {
|
|
153
|
-
return [
|
|
154
|
-
...this.getNodeIncomingEdgeIds(e),
|
|
155
|
-
...this.getNodeOutcomingEdgeIds(e),
|
|
156
|
-
...this.getNodeCycleEdgeIds(e)
|
|
157
|
-
];
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
class ee {
|
|
161
|
-
constructor(e) {
|
|
162
|
-
this.graphStore = e;
|
|
163
|
-
}
|
|
164
|
-
getNode(e) {
|
|
165
|
-
const t = this.graphStore.getNode(e);
|
|
166
|
-
return t === void 0 ? null : {
|
|
167
|
-
element: t.element,
|
|
168
|
-
x: t.x,
|
|
169
|
-
y: t.y,
|
|
170
|
-
centerFn: t.centerFn,
|
|
171
|
-
priority: t.priority
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
getAllNodeIds() {
|
|
175
|
-
return this.graphStore.getAllNodeIds();
|
|
176
|
-
}
|
|
177
|
-
getPort(e) {
|
|
178
|
-
const t = this.graphStore.getPort(e);
|
|
179
|
-
return t === void 0 ? null : {
|
|
180
|
-
element: t.element,
|
|
181
|
-
centerFn: t.centerFn,
|
|
182
|
-
direction: t.direction
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
getAllPortIds() {
|
|
186
|
-
return this.graphStore.getAllPortIds();
|
|
187
|
-
}
|
|
188
|
-
getNodePortIds(e) {
|
|
189
|
-
return this.graphStore.getNodePortIds(e);
|
|
190
|
-
}
|
|
191
|
-
getPortNodeId(e) {
|
|
192
|
-
return this.graphStore.getPortNodeId(e) ?? null;
|
|
193
|
-
}
|
|
194
|
-
getAllEdgeIds() {
|
|
195
|
-
return this.graphStore.getAllEdgeIds();
|
|
196
|
-
}
|
|
197
|
-
getEdge(e) {
|
|
198
|
-
const t = this.graphStore.getEdge(e);
|
|
199
|
-
return t === void 0 ? null : { from: t.from, to: t.to, priority: t.priority };
|
|
200
|
-
}
|
|
201
|
-
getPortIncomingEdgeIds(e) {
|
|
202
|
-
return this.graphStore.getPortIncomingEdgeIds(e);
|
|
203
|
-
}
|
|
204
|
-
getPortOutcomingEdgeIds(e) {
|
|
205
|
-
return this.graphStore.getPortOutcomingEdgeIds(e);
|
|
206
|
-
}
|
|
207
|
-
getPortCycleEdgeIds(e) {
|
|
208
|
-
return this.graphStore.getPortCycleEdgeIds(e);
|
|
209
|
-
}
|
|
210
|
-
getPortAdjacentEdgeIds(e) {
|
|
211
|
-
return this.graphStore.getPortAdjacentEdgeIds(e);
|
|
212
|
-
}
|
|
213
|
-
getNodeIncomingEdgeIds(e) {
|
|
214
|
-
return this.graphStore.getNodeIncomingEdgeIds(e);
|
|
215
|
-
}
|
|
216
|
-
getNodeOutcomingEdgeIds(e) {
|
|
217
|
-
return this.graphStore.getNodeOutcomingEdgeIds(e);
|
|
218
|
-
}
|
|
219
|
-
getNodeCycleEdgeIds(e) {
|
|
220
|
-
return this.graphStore.getNodeCycleEdgeIds(e);
|
|
221
|
-
}
|
|
222
|
-
getNodeAdjacentEdgeIds(e) {
|
|
223
|
-
return this.graphStore.getNodeAdjacentEdgeIds(e);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
const l = {
|
|
227
|
-
x: 0,
|
|
228
|
-
y: 0
|
|
229
|
-
}, p = (r, e, t) => ({
|
|
1
|
+
var Q = Object.defineProperty;
|
|
2
|
+
var Z = (r, e, t) => e in r ? Q(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
|
+
var a = (r, e, t) => Z(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
const H = (r, e) => ({
|
|
5
|
+
x: r / 2,
|
|
6
|
+
y: e / 2
|
|
7
|
+
}), v = (r, e, t) => ({
|
|
230
8
|
x: e.x * r.x - e.y * r.y + ((1 - e.x) * t.x + e.y * t.y),
|
|
231
9
|
y: e.y * r.x + e.x * r.y + ((1 - e.x) * t.y - e.y * t.x)
|
|
232
|
-
}),
|
|
233
|
-
|
|
10
|
+
}), x = (r, e, t) => ({ x: e * Math.cos(r), y: t * Math.sin(r) }), l = {
|
|
11
|
+
x: 0,
|
|
12
|
+
y: 0
|
|
13
|
+
}, f = (r, e, t, s) => {
|
|
14
|
+
const o = [
|
|
234
15
|
l,
|
|
235
16
|
{ x: t, y: s },
|
|
236
17
|
{ x: t, y: -s }
|
|
237
|
-
].map((
|
|
238
|
-
return `${
|
|
239
|
-
},
|
|
18
|
+
].map((c) => v(c, r, l)).map((c) => ({ x: c.x + e.x, y: c.y + e.y })), h = `M ${o[0].x} ${o[0].y}`, i = `L ${o[1].x} ${o[1].y}`, d = `L ${o[2].x} ${o[2].y}`;
|
|
19
|
+
return `${h} ${i} ${d}`;
|
|
20
|
+
}, W = (r, e) => {
|
|
240
21
|
const t = [];
|
|
241
22
|
if (r.length > 0 && t.push(`M ${r[0].x} ${r[0].y}`), r.length === 2 && t.push(`L ${r[1].x} ${r[1].y}`), r.length > 2) {
|
|
242
23
|
const s = r.length - 1;
|
|
243
|
-
let
|
|
244
|
-
r.forEach((
|
|
245
|
-
let
|
|
246
|
-
const m =
|
|
247
|
-
if (m && (
|
|
248
|
-
const j = r[
|
|
249
|
-
|
|
24
|
+
let n = 0, o = 0, h = 0;
|
|
25
|
+
r.forEach((i, d) => {
|
|
26
|
+
let c = 0, u = 0, w = 0;
|
|
27
|
+
const m = d > 0, y = d < s, p = m && y;
|
|
28
|
+
if (m && (c = -n, u = -o, w = h), y) {
|
|
29
|
+
const j = r[d + 1];
|
|
30
|
+
n = j.x - i.x, o = j.y - i.y, h = Math.sqrt(n * n + o * o);
|
|
250
31
|
}
|
|
251
|
-
const P = Math.min((
|
|
252
|
-
|
|
253
|
-
`C ${
|
|
32
|
+
const P = h !== 0 ? Math.min((p ? e : 0) / h, d < s - 1 ? 0.5 : 1) : 0, S = p ? { x: i.x + n * P, y: i.y + o * P } : i, L = w !== 0 ? Math.min((p ? e : 0) / w, d > 1 ? 0.5 : 1) : 0, F = p ? { x: i.x + c * L, y: i.y + u * L } : i;
|
|
33
|
+
d > 0 && t.push(`L ${F.x} ${F.y}`), p && t.push(
|
|
34
|
+
`C ${i.x} ${i.y} ${i.x} ${i.y} ${S.x} ${S.y}`
|
|
254
35
|
);
|
|
255
36
|
});
|
|
256
37
|
}
|
|
@@ -258,225 +39,225 @@ const l = {
|
|
|
258
39
|
}, N = () => {
|
|
259
40
|
const r = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
260
41
|
return r.style.pointerEvents = "none", r.style.position = "absolute", r.style.top = "0", r.style.left = "0", r.style.overflow = "visible", r;
|
|
261
|
-
},
|
|
42
|
+
}, I = () => {
|
|
262
43
|
const r = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
|
263
44
|
return r.style.transformOrigin = "50% 50%", r;
|
|
264
|
-
},
|
|
45
|
+
}, T = (r, e) => {
|
|
265
46
|
const t = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
266
47
|
return t.setAttribute("stroke", r), t.setAttribute("stroke-width", `${e}`), t.setAttribute("fill", "none"), t;
|
|
267
48
|
}, E = (r) => {
|
|
268
49
|
const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
269
50
|
return e.setAttribute("fill", r), e;
|
|
270
51
|
};
|
|
271
|
-
class
|
|
272
|
-
constructor(e, t, s,
|
|
52
|
+
class O {
|
|
53
|
+
constructor(e, t, s, n, o, h, i) {
|
|
273
54
|
a(this, "svg", N());
|
|
274
|
-
a(this, "group",
|
|
55
|
+
a(this, "group", I());
|
|
275
56
|
a(this, "line");
|
|
276
57
|
a(this, "sourceArrow", null);
|
|
277
58
|
a(this, "targetArrow", null);
|
|
278
|
-
this.curvature = s, this.arrowLength =
|
|
59
|
+
this.curvature = s, this.arrowLength = n, this.arrowWidth = o, this.svg.appendChild(this.group), this.line = T(e, t), this.group.appendChild(this.line), h && (this.sourceArrow = E(e), this.group.appendChild(this.sourceArrow)), i && (this.targetArrow = E(e), this.group.appendChild(this.targetArrow));
|
|
279
60
|
}
|
|
280
|
-
update(e, t, s,
|
|
61
|
+
update(e, t, s, n, o) {
|
|
281
62
|
this.group.style.transform = `scale(${t}, ${s})`;
|
|
282
|
-
const
|
|
283
|
-
if (this.line.setAttribute("d",
|
|
284
|
-
const
|
|
285
|
-
|
|
63
|
+
const h = x(n, t, s), i = x(o, t, s), d = this.createLinePath(e, h, i);
|
|
64
|
+
if (this.line.setAttribute("d", d), this.sourceArrow) {
|
|
65
|
+
const c = f(
|
|
66
|
+
h,
|
|
286
67
|
l,
|
|
287
68
|
this.arrowLength,
|
|
288
69
|
this.arrowWidth
|
|
289
70
|
);
|
|
290
|
-
this.sourceArrow.setAttribute("d",
|
|
71
|
+
this.sourceArrow.setAttribute("d", c);
|
|
291
72
|
}
|
|
292
73
|
if (this.targetArrow) {
|
|
293
|
-
const
|
|
294
|
-
|
|
74
|
+
const c = f(
|
|
75
|
+
i,
|
|
295
76
|
e,
|
|
296
77
|
-this.arrowLength,
|
|
297
78
|
this.arrowWidth
|
|
298
79
|
);
|
|
299
|
-
this.targetArrow.setAttribute("d",
|
|
80
|
+
this.targetArrow.setAttribute("d", c);
|
|
300
81
|
}
|
|
301
82
|
}
|
|
302
83
|
createLinePath(e, t, s) {
|
|
303
|
-
const
|
|
84
|
+
const n = v(
|
|
304
85
|
{ x: this.arrowLength, y: l.y },
|
|
305
86
|
t,
|
|
306
87
|
l
|
|
307
|
-
),
|
|
88
|
+
), o = v(
|
|
308
89
|
{ x: e.x - this.arrowLength, y: e.y },
|
|
309
90
|
s,
|
|
310
91
|
e
|
|
311
|
-
),
|
|
312
|
-
x:
|
|
313
|
-
y:
|
|
314
|
-
},
|
|
315
|
-
x:
|
|
316
|
-
y:
|
|
317
|
-
},
|
|
318
|
-
return `${
|
|
92
|
+
), h = {
|
|
93
|
+
x: n.x + t.x * this.curvature,
|
|
94
|
+
y: n.y + t.y * this.curvature
|
|
95
|
+
}, i = {
|
|
96
|
+
x: o.x - s.x * this.curvature,
|
|
97
|
+
y: o.y - s.y * this.curvature
|
|
98
|
+
}, d = `M ${n.x} ${n.y} C ${h.x} ${h.y}, ${i.x} ${i.y}, ${o.x} ${o.y}`, c = this.sourceArrow ? "" : `M ${l.x} ${l.y} L ${n.x} ${n.y} `, u = this.targetArrow ? "" : ` M ${o.x} ${o.y} L ${e.x} ${e.y}`;
|
|
99
|
+
return `${c}${d}${u}`;
|
|
319
100
|
}
|
|
320
101
|
}
|
|
321
|
-
class
|
|
322
|
-
constructor(e, t, s,
|
|
102
|
+
class q {
|
|
103
|
+
constructor(e, t, s, n, o, h, i, d) {
|
|
323
104
|
a(this, "svg", N());
|
|
324
|
-
a(this, "group",
|
|
105
|
+
a(this, "group", I());
|
|
325
106
|
a(this, "line");
|
|
326
107
|
a(this, "sourceArrow", null);
|
|
327
108
|
a(this, "targetArrow", null);
|
|
328
|
-
this.arrowLength = s, this.arrowWidth =
|
|
109
|
+
this.arrowLength = s, this.arrowWidth = n, this.arrowOffset = o, this.roundness = d, this.svg.appendChild(this.group), this.line = T(e, t), this.group.appendChild(this.line), h && (this.sourceArrow = E(e), this.group.appendChild(this.sourceArrow)), i && (this.targetArrow = E(e), this.group.appendChild(this.targetArrow));
|
|
329
110
|
}
|
|
330
|
-
update(e, t, s,
|
|
111
|
+
update(e, t, s, n, o) {
|
|
331
112
|
this.group.style.transform = `scale(${t}, ${s})`;
|
|
332
|
-
const
|
|
333
|
-
if (this.line.setAttribute("d",
|
|
334
|
-
const
|
|
335
|
-
|
|
113
|
+
const h = x(n, t, s), i = x(o, t, s), d = this.createLinePath(e, h, i);
|
|
114
|
+
if (this.line.setAttribute("d", d), this.sourceArrow) {
|
|
115
|
+
const c = f(
|
|
116
|
+
h,
|
|
336
117
|
l,
|
|
337
118
|
this.arrowLength,
|
|
338
119
|
this.arrowWidth
|
|
339
120
|
);
|
|
340
|
-
this.sourceArrow.setAttribute("d",
|
|
121
|
+
this.sourceArrow.setAttribute("d", c);
|
|
341
122
|
}
|
|
342
123
|
if (this.targetArrow) {
|
|
343
|
-
const
|
|
344
|
-
|
|
124
|
+
const c = f(
|
|
125
|
+
i,
|
|
345
126
|
e,
|
|
346
127
|
-this.arrowLength,
|
|
347
128
|
this.arrowWidth
|
|
348
129
|
);
|
|
349
|
-
this.targetArrow.setAttribute("d",
|
|
130
|
+
this.targetArrow.setAttribute("d", c);
|
|
350
131
|
}
|
|
351
132
|
}
|
|
352
133
|
createLinePath(e, t, s) {
|
|
353
|
-
const
|
|
354
|
-
return
|
|
134
|
+
const n = this.sourceArrow ? v({ x: this.arrowLength, y: l.y }, t, l) : l, o = this.targetArrow ? v({ x: e.x - this.arrowLength, y: e.y }, s, e) : e, h = this.arrowLength + this.arrowOffset, i = v({ x: h, y: l.y }, t, l), d = v({ x: e.x - h, y: e.y }, s, e);
|
|
135
|
+
return W([n, i, d, o], this.roundness);
|
|
355
136
|
}
|
|
356
137
|
}
|
|
357
|
-
class
|
|
358
|
-
constructor(e, t, s,
|
|
138
|
+
class ee {
|
|
139
|
+
constructor(e, t, s, n, o, h, i, d) {
|
|
359
140
|
a(this, "svg", N());
|
|
360
|
-
a(this, "group",
|
|
141
|
+
a(this, "group", I());
|
|
361
142
|
a(this, "line");
|
|
362
143
|
a(this, "sourceArrow", null);
|
|
363
144
|
a(this, "targetArrow", null);
|
|
364
|
-
this.arrowLength = s, this.arrowWidth =
|
|
145
|
+
this.arrowLength = s, this.arrowWidth = n, this.arrowOffset = o, this.roundness = d, this.svg.appendChild(this.group), this.line = T(e, t), this.group.appendChild(this.line), h && (this.sourceArrow = E(e), this.group.appendChild(this.sourceArrow)), i && (this.targetArrow = E(e), this.group.appendChild(this.targetArrow));
|
|
365
146
|
}
|
|
366
|
-
update(e, t, s,
|
|
147
|
+
update(e, t, s, n, o) {
|
|
367
148
|
this.group.style.transform = `scale(${t}, ${s})`;
|
|
368
|
-
const
|
|
369
|
-
if (this.line.setAttribute("d",
|
|
370
|
-
const
|
|
371
|
-
|
|
149
|
+
const h = x(n, t, s), i = x(o, t, s), d = this.createLinePath(e, h, i, t);
|
|
150
|
+
if (this.line.setAttribute("d", d), this.sourceArrow) {
|
|
151
|
+
const c = f(
|
|
152
|
+
h,
|
|
372
153
|
l,
|
|
373
154
|
this.arrowLength,
|
|
374
155
|
this.arrowWidth
|
|
375
156
|
);
|
|
376
|
-
this.sourceArrow.setAttribute("d",
|
|
157
|
+
this.sourceArrow.setAttribute("d", c);
|
|
377
158
|
}
|
|
378
159
|
if (this.targetArrow) {
|
|
379
|
-
const
|
|
380
|
-
|
|
160
|
+
const c = f(
|
|
161
|
+
i,
|
|
381
162
|
e,
|
|
382
163
|
-this.arrowLength,
|
|
383
164
|
this.arrowWidth
|
|
384
165
|
);
|
|
385
|
-
this.targetArrow.setAttribute("d",
|
|
166
|
+
this.targetArrow.setAttribute("d", c);
|
|
386
167
|
}
|
|
387
168
|
}
|
|
388
|
-
createLinePath(e, t, s,
|
|
389
|
-
const
|
|
390
|
-
return
|
|
391
|
-
[
|
|
169
|
+
createLinePath(e, t, s, n) {
|
|
170
|
+
const o = this.sourceArrow ? v({ x: this.arrowLength, y: l.y }, t, l) : l, h = this.targetArrow ? v({ x: e.x - this.arrowLength, y: e.y }, s, e) : e, i = this.arrowLength + this.arrowOffset, d = i - this.roundness, c = v({ x: d, y: l.y }, t, l), u = v({ x: e.x - d, y: e.y }, s, e), w = Math.max((c.x + u.x) / 2, i), m = e.y / 2, y = { x: n > 0 ? w : -i, y: c.y }, p = { x: y.x, y: m }, M = { x: n > 0 ? e.x - w : e.x + i, y: u.y }, P = { x: M.x, y: m };
|
|
171
|
+
return W(
|
|
172
|
+
[o, c, y, p, P, M, u, h],
|
|
392
173
|
this.roundness
|
|
393
174
|
);
|
|
394
175
|
}
|
|
395
176
|
}
|
|
396
|
-
class
|
|
397
|
-
constructor(e, t, s,
|
|
177
|
+
class te {
|
|
178
|
+
constructor(e, t, s, n, o, h, i, d) {
|
|
398
179
|
a(this, "svg", N());
|
|
399
|
-
a(this, "group",
|
|
180
|
+
a(this, "group", I());
|
|
400
181
|
a(this, "line");
|
|
401
182
|
a(this, "sourceArrow", null);
|
|
402
183
|
a(this, "targetArrow", null);
|
|
403
|
-
this.arrowLength = s, this.arrowWidth =
|
|
184
|
+
this.arrowLength = s, this.arrowWidth = n, this.arrowOffset = o, this.roundness = d, this.svg.appendChild(this.group), this.line = T(e, t), this.group.appendChild(this.line), h && (this.sourceArrow = E(e), this.group.appendChild(this.sourceArrow)), i && (this.targetArrow = E(e), this.group.appendChild(this.targetArrow));
|
|
404
185
|
}
|
|
405
|
-
update(e, t, s,
|
|
186
|
+
update(e, t, s, n, o) {
|
|
406
187
|
this.group.style.transform = `scale(${t}, ${s})`;
|
|
407
|
-
const
|
|
408
|
-
if (this.line.setAttribute("d",
|
|
409
|
-
const
|
|
410
|
-
|
|
188
|
+
const h = x(n, t, s), i = x(o, t, s), d = this.createLinePath(e, h, i, s);
|
|
189
|
+
if (this.line.setAttribute("d", d), this.sourceArrow) {
|
|
190
|
+
const c = f(
|
|
191
|
+
h,
|
|
411
192
|
l,
|
|
412
193
|
this.arrowLength,
|
|
413
194
|
this.arrowWidth
|
|
414
195
|
);
|
|
415
|
-
this.sourceArrow.setAttribute("d",
|
|
196
|
+
this.sourceArrow.setAttribute("d", c);
|
|
416
197
|
}
|
|
417
198
|
if (this.targetArrow) {
|
|
418
|
-
const
|
|
419
|
-
|
|
199
|
+
const c = f(
|
|
200
|
+
i,
|
|
420
201
|
e,
|
|
421
202
|
-this.arrowLength,
|
|
422
203
|
this.arrowWidth
|
|
423
204
|
);
|
|
424
|
-
this.targetArrow.setAttribute("d",
|
|
205
|
+
this.targetArrow.setAttribute("d", c);
|
|
425
206
|
}
|
|
426
207
|
}
|
|
427
|
-
createLinePath(e, t, s,
|
|
428
|
-
const
|
|
208
|
+
createLinePath(e, t, s, n) {
|
|
209
|
+
const o = this.sourceArrow ? v({ x: this.arrowLength, y: l.y }, t, l) : l, h = this.targetArrow ? v({ x: e.x - this.arrowLength, y: e.y }, s, e) : e, i = this.arrowLength + this.arrowOffset, d = i - this.roundness, c = v({ x: d, y: l.y }, t, l), u = v({ x: e.x - d, y: e.y }, s, e), w = Math.max((c.y + u.y) / 2, i), m = e.x / 2, y = { x: c.x, y: n > 0 ? w : -i }, p = { x: m, y: y.y }, M = {
|
|
429
210
|
x: u.x,
|
|
430
|
-
y:
|
|
431
|
-
}, P = { x: m, y:
|
|
432
|
-
return
|
|
433
|
-
[
|
|
211
|
+
y: n > 0 ? e.y - w : e.y + i
|
|
212
|
+
}, P = { x: m, y: M.y };
|
|
213
|
+
return W(
|
|
214
|
+
[o, c, y, p, P, M, u, h],
|
|
434
215
|
this.roundness
|
|
435
216
|
);
|
|
436
217
|
}
|
|
437
218
|
}
|
|
438
|
-
class
|
|
439
|
-
constructor(e, t, s,
|
|
219
|
+
class re {
|
|
220
|
+
constructor(e, t, s, n, o, h, i) {
|
|
440
221
|
a(this, "svg", N());
|
|
441
222
|
a(this, "line");
|
|
442
223
|
a(this, "arrow", null);
|
|
443
|
-
this.arrowLength = s, this.arrowWidth =
|
|
224
|
+
this.arrowLength = s, this.arrowWidth = n, this.radius = h, this.smallRadius = i, this.line = T(e, t), this.svg.appendChild(this.line), o && (this.arrow = E(e), this.svg.appendChild(this.arrow));
|
|
444
225
|
}
|
|
445
|
-
update(e, t, s,
|
|
446
|
-
const
|
|
447
|
-
if (this.line.setAttribute("d",
|
|
448
|
-
const
|
|
449
|
-
|
|
226
|
+
update(e, t, s, n) {
|
|
227
|
+
const o = x(n, t, s), h = this.createLinePath(o);
|
|
228
|
+
if (this.line.setAttribute("d", h), this.arrow) {
|
|
229
|
+
const i = f(
|
|
230
|
+
o,
|
|
450
231
|
l,
|
|
451
232
|
this.arrowLength,
|
|
452
233
|
this.arrowWidth
|
|
453
234
|
);
|
|
454
|
-
this.arrow.setAttribute("d",
|
|
235
|
+
this.arrow.setAttribute("d", i);
|
|
455
236
|
}
|
|
456
237
|
}
|
|
457
238
|
createLinePath(e) {
|
|
458
|
-
const t = this.smallRadius, s = this.radius,
|
|
239
|
+
const t = this.smallRadius, s = this.radius, n = Math.sqrt(t * t + s * s), o = t + s, h = this.arrowLength + n * (1 - s / o), i = t * s / o, c = [
|
|
459
240
|
{ x: this.arrowLength, y: l.y },
|
|
460
|
-
{ x:
|
|
461
|
-
{ x:
|
|
462
|
-
].map((m) =>
|
|
463
|
-
`M ${
|
|
464
|
-
`A ${t} ${t} 0 0 1 ${
|
|
465
|
-
`A ${s} ${s} 0 1 0 ${
|
|
466
|
-
`A ${t} ${t} 0 0 1 ${
|
|
467
|
-
].join(" "), w = `M 0 0 L ${
|
|
241
|
+
{ x: h, y: i },
|
|
242
|
+
{ x: h, y: -i }
|
|
243
|
+
].map((m) => v(m, e, l)), u = [
|
|
244
|
+
`M ${c[0].x} ${c[0].y}`,
|
|
245
|
+
`A ${t} ${t} 0 0 1 ${c[1].x} ${c[1].y}`,
|
|
246
|
+
`A ${s} ${s} 0 1 0 ${c[2].x} ${c[2].y}`,
|
|
247
|
+
`A ${t} ${t} 0 0 1 ${c[0].x} ${c[0].y}`
|
|
248
|
+
].join(" "), w = `M 0 0 L ${c[0].x} ${c[0].y} `;
|
|
468
249
|
return `${this.arrow !== null ? "" : w}${u}`;
|
|
469
250
|
}
|
|
470
251
|
}
|
|
471
|
-
class
|
|
472
|
-
constructor(e, t, s,
|
|
252
|
+
class X {
|
|
253
|
+
constructor(e, t, s, n, o, h, i, d) {
|
|
473
254
|
a(this, "svg", N());
|
|
474
255
|
a(this, "line");
|
|
475
256
|
a(this, "arrow", null);
|
|
476
257
|
a(this, "roundness");
|
|
477
258
|
a(this, "linePoints");
|
|
478
|
-
this.arrowLength = s, this.arrowWidth =
|
|
479
|
-
const
|
|
259
|
+
this.arrowLength = s, this.arrowWidth = n, this.side = h, this.minPortOffset = i, this.roundness = Math.min(d, this.minPortOffset, this.side / 2), this.line = T(e, t), this.svg.appendChild(this.line), o && (this.arrow = E(e), this.svg.appendChild(this.arrow));
|
|
260
|
+
const c = this.minPortOffset, u = this.side, w = this.arrowLength + c, m = w + 2 * u;
|
|
480
261
|
this.linePoints = [
|
|
481
262
|
{ x: this.arrowLength, y: l.y },
|
|
482
263
|
{ x: w, y: l.y },
|
|
@@ -488,146 +269,146 @@ class B {
|
|
|
488
269
|
{ x: this.arrowLength, y: l.y }
|
|
489
270
|
];
|
|
490
271
|
}
|
|
491
|
-
update(e, t, s,
|
|
492
|
-
const
|
|
493
|
-
if (this.line.setAttribute("d",
|
|
494
|
-
const
|
|
495
|
-
|
|
272
|
+
update(e, t, s, n) {
|
|
273
|
+
const o = x(n, t, s), h = this.createLinePath(o);
|
|
274
|
+
if (this.line.setAttribute("d", h), this.arrow) {
|
|
275
|
+
const i = f(
|
|
276
|
+
o,
|
|
496
277
|
l,
|
|
497
278
|
this.arrowLength,
|
|
498
279
|
this.arrowWidth
|
|
499
280
|
);
|
|
500
|
-
this.arrow.setAttribute("d",
|
|
281
|
+
this.arrow.setAttribute("d", i);
|
|
501
282
|
}
|
|
502
283
|
}
|
|
503
284
|
createLinePath(e) {
|
|
504
285
|
const t = this.linePoints.map(
|
|
505
|
-
(
|
|
286
|
+
(n) => v(n, e, l)
|
|
506
287
|
), s = `M ${l.x} ${l.y} L ${t[0].x} ${t[0].y} `;
|
|
507
|
-
return `${this.arrow ? "" : s}${
|
|
288
|
+
return `${this.arrow ? "" : s}${W(t, this.roundness)}`;
|
|
508
289
|
}
|
|
509
290
|
}
|
|
510
|
-
class
|
|
511
|
-
constructor(e, t, s, o,
|
|
291
|
+
class se {
|
|
292
|
+
constructor(e, t, s, n, o, h, i, d, c) {
|
|
512
293
|
a(this, "svg", N());
|
|
513
|
-
a(this, "group",
|
|
294
|
+
a(this, "group", I());
|
|
514
295
|
a(this, "line");
|
|
515
296
|
a(this, "sourceArrow", null);
|
|
516
297
|
a(this, "targetArrow", null);
|
|
517
298
|
a(this, "detourX");
|
|
518
299
|
a(this, "detourY");
|
|
519
|
-
this.curvature = s, this.arrowLength =
|
|
300
|
+
this.curvature = s, this.arrowLength = n, this.arrowWidth = o, this.detourX = Math.cos(c) * d, this.detourY = Math.sin(c) * d, this.svg.appendChild(this.group), this.line = T(e, t), this.group.appendChild(this.line), h && (this.sourceArrow = E(e), this.group.appendChild(this.sourceArrow)), i && (this.targetArrow = E(e), this.group.appendChild(this.targetArrow));
|
|
520
301
|
}
|
|
521
|
-
update(e, t, s,
|
|
302
|
+
update(e, t, s, n, o) {
|
|
522
303
|
this.group.style.transform = `scale(${t}, ${s})`;
|
|
523
|
-
const
|
|
524
|
-
if (this.line.setAttribute("d",
|
|
525
|
-
const
|
|
526
|
-
|
|
304
|
+
const h = x(n, t, s), i = x(o, t, s), d = this.createLinePath(e, h, i, t, s);
|
|
305
|
+
if (this.line.setAttribute("d", d), this.sourceArrow) {
|
|
306
|
+
const c = f(
|
|
307
|
+
h,
|
|
527
308
|
l,
|
|
528
309
|
this.arrowLength,
|
|
529
310
|
this.arrowWidth
|
|
530
311
|
);
|
|
531
|
-
this.sourceArrow.setAttribute("d",
|
|
312
|
+
this.sourceArrow.setAttribute("d", c);
|
|
532
313
|
}
|
|
533
314
|
if (this.targetArrow) {
|
|
534
|
-
const
|
|
535
|
-
|
|
315
|
+
const c = f(
|
|
316
|
+
i,
|
|
536
317
|
e,
|
|
537
318
|
-this.arrowLength,
|
|
538
319
|
this.arrowWidth
|
|
539
320
|
);
|
|
540
|
-
this.targetArrow.setAttribute("d",
|
|
321
|
+
this.targetArrow.setAttribute("d", c);
|
|
541
322
|
}
|
|
542
323
|
}
|
|
543
|
-
createLinePath(e, t, s,
|
|
544
|
-
const
|
|
545
|
-
{ x:
|
|
324
|
+
createLinePath(e, t, s, n, o) {
|
|
325
|
+
const h = this.sourceArrow ? v({ x: this.arrowLength, y: l.y }, t, l) : l, i = this.targetArrow ? v({ x: e.x - this.arrowLength, y: e.y }, s, e) : e, d = this.arrowLength, c = this.detourX * n, u = this.detourY * o, w = v(
|
|
326
|
+
{ x: d, y: l.y },
|
|
546
327
|
t,
|
|
547
328
|
l
|
|
548
329
|
), m = {
|
|
549
|
-
x: w.x +
|
|
330
|
+
x: w.x + c,
|
|
550
331
|
y: w.y + u
|
|
551
|
-
}, y =
|
|
552
|
-
{ x: e.x -
|
|
332
|
+
}, y = v(
|
|
333
|
+
{ x: e.x - d, y: e.y },
|
|
553
334
|
s,
|
|
554
335
|
e
|
|
555
|
-
),
|
|
556
|
-
x: y.x +
|
|
336
|
+
), p = {
|
|
337
|
+
x: y.x + c,
|
|
557
338
|
y: y.y + u
|
|
558
|
-
},
|
|
339
|
+
}, M = { x: (m.x + p.x) / 2, y: (m.y + p.y) / 2 }, P = {
|
|
559
340
|
x: w.x + this.curvature * t.x,
|
|
560
341
|
y: w.y + this.curvature * t.y
|
|
561
|
-
},
|
|
342
|
+
}, S = {
|
|
562
343
|
x: y.x - this.curvature * s.x,
|
|
563
344
|
y: y.y - this.curvature * s.y
|
|
564
345
|
}, b = {
|
|
565
|
-
x: w.x +
|
|
346
|
+
x: w.x + c,
|
|
566
347
|
y: w.y + u
|
|
567
|
-
},
|
|
568
|
-
x: y.x +
|
|
348
|
+
}, L = {
|
|
349
|
+
x: y.x + c,
|
|
569
350
|
y: y.y + u
|
|
570
351
|
};
|
|
571
352
|
return [
|
|
572
|
-
`M ${
|
|
353
|
+
`M ${h.x} ${h.y}`,
|
|
573
354
|
`L ${w.x} ${w.y}`,
|
|
574
|
-
`C ${P.x} ${P.y} ${b.x} ${b.y} ${
|
|
575
|
-
`C ${
|
|
576
|
-
`L ${
|
|
355
|
+
`C ${P.x} ${P.y} ${b.x} ${b.y} ${M.x} ${M.y}`,
|
|
356
|
+
`C ${L.x} ${L.y} ${S.x} ${S.y} ${y.x} ${y.y}`,
|
|
357
|
+
`L ${i.x} ${i.y}`
|
|
577
358
|
].join(" ");
|
|
578
359
|
}
|
|
579
360
|
}
|
|
580
361
|
class G {
|
|
581
|
-
constructor(e, t, s, o,
|
|
362
|
+
constructor(e, t, s, n, o, h, i, d, c, u) {
|
|
582
363
|
a(this, "svg", N());
|
|
583
|
-
a(this, "group",
|
|
364
|
+
a(this, "group", I());
|
|
584
365
|
a(this, "line");
|
|
585
366
|
a(this, "sourceArrow", null);
|
|
586
367
|
a(this, "targetArrow", null);
|
|
587
368
|
a(this, "detourX");
|
|
588
369
|
a(this, "detourY");
|
|
589
|
-
this.arrowLength = s, this.arrowWidth =
|
|
370
|
+
this.arrowLength = s, this.arrowWidth = n, this.arrowOffset = o, this.roundness = d, this.detourX = Math.cos(u) * c, this.detourY = Math.sin(u) * c, this.svg.appendChild(this.group), this.line = T(e, t), this.group.appendChild(this.line), h && (this.sourceArrow = E(e), this.group.appendChild(this.sourceArrow)), i && (this.targetArrow = E(e), this.group.appendChild(this.targetArrow));
|
|
590
371
|
}
|
|
591
|
-
update(e, t, s,
|
|
372
|
+
update(e, t, s, n, o) {
|
|
592
373
|
this.group.style.transform = `scale(${t}, ${s})`;
|
|
593
|
-
const
|
|
594
|
-
if (this.line.setAttribute("d",
|
|
595
|
-
const
|
|
596
|
-
|
|
374
|
+
const h = x(n, t, s), i = x(o, t, s), d = this.createLinePath(e, h, i, t, s);
|
|
375
|
+
if (this.line.setAttribute("d", d), this.sourceArrow) {
|
|
376
|
+
const c = f(
|
|
377
|
+
h,
|
|
597
378
|
l,
|
|
598
379
|
this.arrowLength,
|
|
599
380
|
this.arrowWidth
|
|
600
381
|
);
|
|
601
|
-
this.sourceArrow.setAttribute("d",
|
|
382
|
+
this.sourceArrow.setAttribute("d", c);
|
|
602
383
|
}
|
|
603
384
|
if (this.targetArrow) {
|
|
604
|
-
const
|
|
605
|
-
|
|
385
|
+
const c = f(
|
|
386
|
+
i,
|
|
606
387
|
e,
|
|
607
388
|
-this.arrowLength,
|
|
608
389
|
this.arrowWidth
|
|
609
390
|
);
|
|
610
|
-
this.targetArrow.setAttribute("d",
|
|
391
|
+
this.targetArrow.setAttribute("d", c);
|
|
611
392
|
}
|
|
612
393
|
}
|
|
613
|
-
createLinePath(e, t, s,
|
|
614
|
-
const
|
|
615
|
-
{ x:
|
|
394
|
+
createLinePath(e, t, s, n, o) {
|
|
395
|
+
const h = this.sourceArrow ? v({ x: this.arrowLength, y: l.y }, t, l) : l, i = this.targetArrow ? v({ x: e.x - this.arrowLength, y: e.y }, s, e) : e, d = this.arrowLength + this.arrowOffset, c = v(
|
|
396
|
+
{ x: d, y: l.y },
|
|
616
397
|
t,
|
|
617
398
|
l
|
|
618
|
-
), u = this.detourX *
|
|
619
|
-
{ x: e.x -
|
|
399
|
+
), u = this.detourX * n, w = this.detourY * o, m = { x: c.x + u, y: c.y + w }, y = v(
|
|
400
|
+
{ x: e.x - d, y: e.y },
|
|
620
401
|
s,
|
|
621
402
|
e
|
|
622
|
-
),
|
|
623
|
-
return
|
|
624
|
-
[
|
|
403
|
+
), p = { x: y.x + u, y: y.y + w };
|
|
404
|
+
return W(
|
|
405
|
+
[h, c, m, p, y, i],
|
|
625
406
|
this.roundness
|
|
626
407
|
);
|
|
627
408
|
}
|
|
628
409
|
}
|
|
629
|
-
var
|
|
630
|
-
const
|
|
410
|
+
var C = /* @__PURE__ */ ((r) => (r.Regular = "regular", r.PortCycle = "port-cycle", r.NodeCycle = "node-cycle", r))(C || {});
|
|
411
|
+
const oe = (r) => (e) => e === C.PortCycle ? new re(
|
|
631
412
|
r.color,
|
|
632
413
|
r.width,
|
|
633
414
|
r.arrowLength,
|
|
@@ -635,7 +416,7 @@ const ae = (r) => (e) => e === A.PortCycle ? new ie(
|
|
|
635
416
|
r.hasSourceArrow || r.hasTargetArrow,
|
|
636
417
|
r.cycleRadius,
|
|
637
418
|
r.smallCycleRadius
|
|
638
|
-
) : e ===
|
|
419
|
+
) : e === C.NodeCycle ? new se(
|
|
639
420
|
r.color,
|
|
640
421
|
r.width,
|
|
641
422
|
r.curvature,
|
|
@@ -645,7 +426,7 @@ const ae = (r) => (e) => e === A.PortCycle ? new ie(
|
|
|
645
426
|
r.hasTargetArrow,
|
|
646
427
|
r.detourDistance,
|
|
647
428
|
r.detourDirection
|
|
648
|
-
) : new
|
|
429
|
+
) : new O(
|
|
649
430
|
r.color,
|
|
650
431
|
r.width,
|
|
651
432
|
r.curvature,
|
|
@@ -653,7 +434,7 @@ const ae = (r) => (e) => e === A.PortCycle ? new ie(
|
|
|
653
434
|
r.arrowWidth,
|
|
654
435
|
r.hasSourceArrow,
|
|
655
436
|
r.hasTargetArrow
|
|
656
|
-
),
|
|
437
|
+
), ne = (r) => (e) => e === C.PortCycle ? new X(
|
|
657
438
|
r.color,
|
|
658
439
|
r.width,
|
|
659
440
|
r.arrowLength,
|
|
@@ -662,7 +443,7 @@ const ae = (r) => (e) => e === A.PortCycle ? new ie(
|
|
|
662
443
|
r.cycleSquareSide,
|
|
663
444
|
r.arrowOffset,
|
|
664
445
|
r.roundness
|
|
665
|
-
) : e ===
|
|
446
|
+
) : e === C.NodeCycle ? new G(
|
|
666
447
|
r.color,
|
|
667
448
|
r.width,
|
|
668
449
|
r.arrowLength,
|
|
@@ -673,7 +454,7 @@ const ae = (r) => (e) => e === A.PortCycle ? new ie(
|
|
|
673
454
|
r.roundness,
|
|
674
455
|
r.detourDistance,
|
|
675
456
|
r.detourDirection
|
|
676
|
-
) : new
|
|
457
|
+
) : new q(
|
|
677
458
|
r.color,
|
|
678
459
|
r.width,
|
|
679
460
|
r.arrowLength,
|
|
@@ -682,7 +463,7 @@ const ae = (r) => (e) => e === A.PortCycle ? new ie(
|
|
|
682
463
|
r.hasSourceArrow,
|
|
683
464
|
r.hasTargetArrow,
|
|
684
465
|
r.roundness
|
|
685
|
-
),
|
|
466
|
+
), ie = (r) => (e) => e === C.PortCycle ? new X(
|
|
686
467
|
r.color,
|
|
687
468
|
r.width,
|
|
688
469
|
r.arrowLength,
|
|
@@ -691,7 +472,7 @@ const ae = (r) => (e) => e === A.PortCycle ? new ie(
|
|
|
691
472
|
r.cycleSquareSide,
|
|
692
473
|
r.arrowOffset,
|
|
693
474
|
r.roundness
|
|
694
|
-
) : e ===
|
|
475
|
+
) : e === C.NodeCycle ? new G(
|
|
695
476
|
r.color,
|
|
696
477
|
r.width,
|
|
697
478
|
r.arrowLength,
|
|
@@ -702,7 +483,7 @@ const ae = (r) => (e) => e === A.PortCycle ? new ie(
|
|
|
702
483
|
r.roundness,
|
|
703
484
|
r.detourDistance,
|
|
704
485
|
r.detourDirection
|
|
705
|
-
) : new
|
|
486
|
+
) : new te(
|
|
706
487
|
r.color,
|
|
707
488
|
r.width,
|
|
708
489
|
r.arrowLength,
|
|
@@ -711,7 +492,7 @@ const ae = (r) => (e) => e === A.PortCycle ? new ie(
|
|
|
711
492
|
r.hasSourceArrow,
|
|
712
493
|
r.hasTargetArrow,
|
|
713
494
|
r.roundness
|
|
714
|
-
),
|
|
495
|
+
), ae = (r) => (e) => e === C.PortCycle ? new X(
|
|
715
496
|
r.color,
|
|
716
497
|
r.width,
|
|
717
498
|
r.arrowLength,
|
|
@@ -720,7 +501,7 @@ const ae = (r) => (e) => e === A.PortCycle ? new ie(
|
|
|
720
501
|
r.cycleSquareSide,
|
|
721
502
|
r.arrowOffset,
|
|
722
503
|
r.roundness
|
|
723
|
-
) : e ===
|
|
504
|
+
) : e === C.NodeCycle ? new G(
|
|
724
505
|
r.color,
|
|
725
506
|
r.width,
|
|
726
507
|
r.arrowLength,
|
|
@@ -731,7 +512,7 @@ const ae = (r) => (e) => e === A.PortCycle ? new ie(
|
|
|
731
512
|
r.roundness,
|
|
732
513
|
r.detourDistance,
|
|
733
514
|
r.detourDirection
|
|
734
|
-
) : new
|
|
515
|
+
) : new ee(
|
|
735
516
|
r.color,
|
|
736
517
|
r.width,
|
|
737
518
|
r.arrowLength,
|
|
@@ -740,208 +521,363 @@ const ae = (r) => (e) => e === A.PortCycle ? new ie(
|
|
|
740
521
|
r.hasSourceArrow,
|
|
741
522
|
r.hasTargetArrow,
|
|
742
523
|
r.roundness
|
|
743
|
-
)
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
524
|
+
), g = {
|
|
525
|
+
edgeColor: "#5c5c5c",
|
|
526
|
+
edgeWidth: 1,
|
|
527
|
+
edgeArrowLength: 15,
|
|
528
|
+
edgeArrowWidth: 4,
|
|
529
|
+
edgeArrowOffset: 15,
|
|
530
|
+
hasSourceArrow: !1,
|
|
531
|
+
hasTargetArrow: !1,
|
|
532
|
+
cycleSize: 30,
|
|
533
|
+
roundness: 10,
|
|
534
|
+
detourDistance: 100,
|
|
535
|
+
detourDirection: -Math.PI / 2,
|
|
536
|
+
smallCycleSize: 15,
|
|
537
|
+
curvature: 90
|
|
538
|
+
}, B = (r) => {
|
|
539
|
+
switch (r == null ? void 0 : r.type) {
|
|
540
|
+
case "custom":
|
|
541
|
+
return r.factory;
|
|
542
|
+
case "straight":
|
|
543
|
+
return ne({
|
|
544
|
+
color: r.color ?? g.edgeColor,
|
|
545
|
+
width: r.width ?? g.edgeWidth,
|
|
546
|
+
arrowLength: r.arrowLength ?? g.edgeArrowLength,
|
|
547
|
+
arrowWidth: r.arrowWidth ?? g.edgeArrowWidth,
|
|
548
|
+
arrowOffset: r.arrowOffset ?? g.edgeArrowOffset,
|
|
549
|
+
hasSourceArrow: r.hasSourceArrow ?? g.hasSourceArrow,
|
|
550
|
+
hasTargetArrow: r.hasTargetArrow ?? g.hasTargetArrow,
|
|
551
|
+
cycleSquareSide: r.cycleSquareSide ?? g.cycleSize,
|
|
552
|
+
roundness: r.roundness ?? g.roundness,
|
|
553
|
+
detourDistance: r.detourDistance ?? g.detourDistance,
|
|
554
|
+
detourDirection: r.detourDirection ?? g.detourDirection
|
|
555
|
+
});
|
|
556
|
+
case "horizontal":
|
|
557
|
+
return ae({
|
|
558
|
+
color: r.color ?? g.edgeColor,
|
|
559
|
+
width: r.width ?? g.edgeWidth,
|
|
560
|
+
arrowLength: r.arrowLength ?? g.edgeArrowLength,
|
|
561
|
+
arrowWidth: r.arrowWidth ?? g.edgeArrowWidth,
|
|
562
|
+
arrowOffset: r.arrowOffset ?? g.edgeArrowOffset,
|
|
563
|
+
hasSourceArrow: r.hasSourceArrow ?? g.hasSourceArrow,
|
|
564
|
+
hasTargetArrow: r.hasTargetArrow ?? g.hasTargetArrow,
|
|
565
|
+
cycleSquareSide: r.cycleSquareSide ?? g.cycleSize,
|
|
566
|
+
roundness: r.roundness ?? g.roundness,
|
|
567
|
+
detourDistance: r.detourDistance ?? g.detourDistance,
|
|
568
|
+
detourDirection: r.detourDirection ?? g.detourDirection
|
|
569
|
+
});
|
|
570
|
+
case "vertical":
|
|
571
|
+
return ie({
|
|
572
|
+
color: r.color ?? g.edgeColor,
|
|
573
|
+
width: r.width ?? g.edgeWidth,
|
|
574
|
+
arrowLength: r.arrowLength ?? g.edgeArrowLength,
|
|
575
|
+
arrowWidth: r.arrowWidth ?? g.edgeArrowWidth,
|
|
576
|
+
arrowOffset: r.arrowOffset ?? g.edgeArrowOffset,
|
|
577
|
+
hasSourceArrow: r.hasSourceArrow ?? g.hasSourceArrow,
|
|
578
|
+
hasTargetArrow: r.hasTargetArrow ?? g.hasTargetArrow,
|
|
579
|
+
cycleSquareSide: r.cycleSquareSide ?? g.cycleSize,
|
|
580
|
+
roundness: r.roundness ?? g.roundness,
|
|
581
|
+
detourDistance: r.detourDistance ?? g.detourDistance,
|
|
582
|
+
detourDirection: r.detourDirection ?? g.detourDirection
|
|
583
|
+
});
|
|
584
|
+
default:
|
|
585
|
+
return oe({
|
|
586
|
+
color: r.color ?? g.edgeColor,
|
|
587
|
+
width: r.width ?? g.edgeWidth,
|
|
588
|
+
arrowLength: r.arrowLength ?? g.edgeArrowLength,
|
|
589
|
+
arrowWidth: r.arrowWidth ?? g.edgeArrowWidth,
|
|
590
|
+
hasSourceArrow: r.hasSourceArrow ?? g.hasSourceArrow,
|
|
591
|
+
hasTargetArrow: r.hasTargetArrow ?? g.hasTargetArrow,
|
|
592
|
+
cycleRadius: r.cycleRadius ?? g.cycleSize,
|
|
593
|
+
smallCycleRadius: r.smallCycleRadius ?? g.smallCycleSize,
|
|
594
|
+
curvature: r.curvature ?? g.curvature,
|
|
595
|
+
detourDistance: r.detourDistance ?? g.detourDistance,
|
|
596
|
+
detourDirection: r.detourDirection ?? g.detourDirection
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
}, Y = (r) => () => r, U = Y(0), R = () => {
|
|
600
|
+
let r = 0;
|
|
601
|
+
return () => r++;
|
|
602
|
+
}, he = (r, e) => {
|
|
603
|
+
let t = U, s = U;
|
|
604
|
+
r === "incremental" && (t = R()), e === "incremental" && (s = R());
|
|
605
|
+
const n = R();
|
|
606
|
+
return r === "shared-incremental" && (t = n), e === "shared-incremental" && (s = n), typeof r == "number" && (t = Y(r)), typeof e == "number" && (s = Y(e)), typeof r == "function" && (t = r), typeof e == "function" && (s = e), {
|
|
607
|
+
nodesPriorityFn: t,
|
|
608
|
+
edgesPriorityFn: s
|
|
609
|
+
};
|
|
610
|
+
}, de = (r) => {
|
|
611
|
+
var t, s, n, o, h, i;
|
|
612
|
+
const e = he(
|
|
613
|
+
(t = r == null ? void 0 : r.nodes) == null ? void 0 : t.priority,
|
|
614
|
+
(s = r == null ? void 0 : r.edges) == null ? void 0 : s.priority
|
|
615
|
+
);
|
|
616
|
+
return {
|
|
617
|
+
nodes: {
|
|
618
|
+
centerFn: ((n = r == null ? void 0 : r.nodes) == null ? void 0 : n.centerFn) ?? H,
|
|
619
|
+
priorityFn: e.nodesPriorityFn
|
|
620
|
+
},
|
|
621
|
+
ports: {
|
|
622
|
+
centerFn: ((o = r == null ? void 0 : r.ports) == null ? void 0 : o.centerFn) ?? H,
|
|
623
|
+
direction: ((h = r == null ? void 0 : r.ports) == null ? void 0 : h.direction) ?? 0
|
|
624
|
+
},
|
|
625
|
+
edges: {
|
|
626
|
+
shapeFactory: B(((i = r == null ? void 0 : r.edges) == null ? void 0 : i.shape) ?? {}),
|
|
627
|
+
priorityFn: e.edgesPriorityFn
|
|
628
|
+
}
|
|
629
|
+
};
|
|
630
|
+
};
|
|
631
|
+
class ce {
|
|
632
|
+
constructor() {
|
|
633
|
+
a(this, "nodes", /* @__PURE__ */ new Map());
|
|
634
|
+
a(this, "ports", /* @__PURE__ */ new Map());
|
|
635
|
+
a(this, "nodePorts", /* @__PURE__ */ new Map());
|
|
636
|
+
a(this, "portNodeId", /* @__PURE__ */ new Map());
|
|
637
|
+
a(this, "edges", /* @__PURE__ */ new Map());
|
|
638
|
+
a(this, "incommingEdges", /* @__PURE__ */ new Map());
|
|
639
|
+
a(this, "outcommingEdges", /* @__PURE__ */ new Map());
|
|
640
|
+
a(this, "cycleEdges", /* @__PURE__ */ new Map());
|
|
798
641
|
}
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
642
|
+
addNode(e) {
|
|
643
|
+
this.nodes.set(e.nodeId, {
|
|
644
|
+
element: e.element,
|
|
645
|
+
x: e.x,
|
|
646
|
+
y: e.y,
|
|
647
|
+
centerFn: e.centerFn,
|
|
648
|
+
priority: e.priority
|
|
649
|
+
}), this.nodePorts.set(e.nodeId, /* @__PURE__ */ new Map());
|
|
650
|
+
}
|
|
651
|
+
getAllNodeIds() {
|
|
652
|
+
return Array.from(this.nodes.keys());
|
|
653
|
+
}
|
|
654
|
+
getNode(e) {
|
|
655
|
+
return this.nodes.get(e);
|
|
804
656
|
}
|
|
805
657
|
removeNode(e) {
|
|
806
|
-
|
|
807
|
-
throw new C("failed to remove nonexisting node");
|
|
808
|
-
(this.graphStore.getNodePortIds(e) ?? []).forEach((t) => {
|
|
809
|
-
this.unmarkPort(t);
|
|
810
|
-
}), this.htmlController.detachNode(e), this.graphStore.removeNode(e);
|
|
658
|
+
this.nodes.delete(e), this.nodePorts.delete(e);
|
|
811
659
|
}
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
this.
|
|
818
|
-
e,
|
|
819
|
-
t,
|
|
820
|
-
s,
|
|
821
|
-
o ?? this.defaultPortsCenterFn,
|
|
822
|
-
i ?? this.defaultPortsDirection
|
|
823
|
-
);
|
|
660
|
+
addPort(e) {
|
|
661
|
+
this.ports.set(e.portId, {
|
|
662
|
+
element: e.element,
|
|
663
|
+
centerFn: e.centerFn,
|
|
664
|
+
direction: e.direction
|
|
665
|
+
}), this.cycleEdges.set(e.portId, /* @__PURE__ */ new Set()), this.incommingEdges.set(e.portId, /* @__PURE__ */ new Set()), this.outcommingEdges.set(e.portId, /* @__PURE__ */ new Set()), this.portNodeId.set(e.portId, e.nodeId), this.nodePorts.get(e.nodeId).set(e.portId, e.element);
|
|
824
666
|
}
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
if (o === void 0)
|
|
828
|
-
throw new C("failed to unset nonexisting port");
|
|
829
|
-
o.direction = t ?? o.direction, o.centerFn = s ?? o.centerFn, this.htmlController.updatePortEdges(e);
|
|
667
|
+
getPort(e) {
|
|
668
|
+
return this.ports.get(e);
|
|
830
669
|
}
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
throw new C("failed to unset nonexisting port");
|
|
834
|
-
this.graphStore.getPortAdjacentEdgeIds(e).forEach((t) => {
|
|
835
|
-
this.removeEdge(t);
|
|
836
|
-
}), this.graphStore.removePort(e);
|
|
670
|
+
getAllPortIds() {
|
|
671
|
+
return Array.from(this.ports.keys());
|
|
837
672
|
}
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
throw new C("failed to add edge to nonexisting port");
|
|
843
|
-
if (this.graphStore.getEdge(e) !== void 0)
|
|
844
|
-
throw new C("failed to add edge with existing id");
|
|
845
|
-
const n = this.resolveEdgeType(t, s);
|
|
846
|
-
this.graphStore.addEdge(
|
|
847
|
-
e,
|
|
848
|
-
t,
|
|
849
|
-
s,
|
|
850
|
-
o(n),
|
|
851
|
-
i ?? this.defaultEdgesPriorityFn()
|
|
852
|
-
), this.htmlController.attachEdge(e);
|
|
853
|
-
}
|
|
854
|
-
updateEdge(e, t, s) {
|
|
855
|
-
const o = this.graphStore.getEdge(e);
|
|
856
|
-
if (o === void 0)
|
|
857
|
-
throw new C("failed to update nonexisting edge");
|
|
858
|
-
if (t !== void 0) {
|
|
859
|
-
const i = this.resolveEdgeType(o.from, o.to);
|
|
860
|
-
o.shape = t(i), this.htmlController.updateEdgeShape(e);
|
|
861
|
-
}
|
|
862
|
-
s !== void 0 && (o.priority = s, this.htmlController.updateEdgePriority(e));
|
|
673
|
+
getNodePortIds(e) {
|
|
674
|
+
const t = this.nodePorts.get(e);
|
|
675
|
+
if (t !== void 0)
|
|
676
|
+
return Array.from(t.keys());
|
|
863
677
|
}
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
throw new C("failed to remove nonexisting edge");
|
|
867
|
-
this.htmlController.detachEdge(e), this.graphStore.removeEdge(e);
|
|
678
|
+
getPortNodeId(e) {
|
|
679
|
+
return this.portNodeId.get(e);
|
|
868
680
|
}
|
|
869
|
-
|
|
870
|
-
|
|
681
|
+
removePort(e) {
|
|
682
|
+
const t = this.portNodeId.get(e);
|
|
683
|
+
this.portNodeId.delete(e), this.nodePorts.get(t).delete(e), this.ports.delete(e);
|
|
871
684
|
}
|
|
872
|
-
|
|
873
|
-
this.
|
|
685
|
+
addEdge(e) {
|
|
686
|
+
this.edges.set(e.edgeId, {
|
|
687
|
+
from: e.from,
|
|
688
|
+
to: e.to,
|
|
689
|
+
shape: e.shape,
|
|
690
|
+
priority: e.priority
|
|
691
|
+
}), e.from !== e.to ? (this.outcommingEdges.get(e.from).add(e.edgeId), this.incommingEdges.get(e.to).add(e.edgeId)) : this.cycleEdges.get(e.from).add(e.edgeId);
|
|
874
692
|
}
|
|
875
|
-
|
|
876
|
-
this.
|
|
693
|
+
getAllEdgeIds() {
|
|
694
|
+
return Array.from(this.edges.keys());
|
|
877
695
|
}
|
|
878
|
-
|
|
879
|
-
this.
|
|
696
|
+
getEdge(e) {
|
|
697
|
+
return this.edges.get(e);
|
|
698
|
+
}
|
|
699
|
+
removeEdge(e) {
|
|
700
|
+
const t = this.edges.get(e), s = t.from, n = t.to;
|
|
701
|
+
this.cycleEdges.get(s).delete(e), this.cycleEdges.get(n).delete(e), this.incommingEdges.get(s).delete(e), this.incommingEdges.get(n).delete(e), this.outcommingEdges.get(s).delete(e), this.outcommingEdges.get(n).delete(e), this.edges.delete(e);
|
|
880
702
|
}
|
|
881
703
|
clear() {
|
|
882
|
-
this.
|
|
704
|
+
this.nodes.clear(), this.ports.clear(), this.nodePorts.clear(), this.portNodeId.clear(), this.edges.clear(), this.incommingEdges.clear(), this.outcommingEdges.clear(), this.cycleEdges.clear();
|
|
883
705
|
}
|
|
884
|
-
|
|
885
|
-
this.
|
|
706
|
+
getPortIncomingEdgeIds(e) {
|
|
707
|
+
return Array.from(this.incommingEdges.get(e));
|
|
886
708
|
}
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
return
|
|
709
|
+
getPortOutcomingEdgeIds(e) {
|
|
710
|
+
return Array.from(this.outcommingEdges.get(e));
|
|
711
|
+
}
|
|
712
|
+
getPortCycleEdgeIds(e) {
|
|
713
|
+
return Array.from(this.cycleEdges.get(e));
|
|
714
|
+
}
|
|
715
|
+
getPortAdjacentEdgeIds(e) {
|
|
716
|
+
return [
|
|
717
|
+
...this.getPortIncomingEdgeIds(e),
|
|
718
|
+
...this.getPortOutcomingEdgeIds(e),
|
|
719
|
+
...this.getPortCycleEdgeIds(e)
|
|
720
|
+
];
|
|
721
|
+
}
|
|
722
|
+
getNodeIncomingEdgeIds(e) {
|
|
723
|
+
const t = Array.from(this.nodePorts.get(e).keys());
|
|
724
|
+
let s = [];
|
|
725
|
+
return t.forEach((n) => {
|
|
726
|
+
s = [...s, ...this.getPortIncomingEdgeIds(n)];
|
|
727
|
+
}), s;
|
|
728
|
+
}
|
|
729
|
+
getNodeOutcomingEdgeIds(e) {
|
|
730
|
+
const t = Array.from(this.nodePorts.get(e).keys());
|
|
731
|
+
let s = [];
|
|
732
|
+
return t.forEach((n) => {
|
|
733
|
+
s = [...s, ...this.getPortOutcomingEdgeIds(n)];
|
|
734
|
+
}), s;
|
|
735
|
+
}
|
|
736
|
+
getNodeCycleEdgeIds(e) {
|
|
737
|
+
const t = Array.from(this.nodePorts.get(e).keys());
|
|
738
|
+
let s = [];
|
|
739
|
+
return t.forEach((n) => {
|
|
740
|
+
s = [...s, ...this.getPortCycleEdgeIds(n)];
|
|
741
|
+
}), s;
|
|
742
|
+
}
|
|
743
|
+
getNodeAdjacentEdgeIds(e) {
|
|
744
|
+
return [
|
|
745
|
+
...this.getNodeIncomingEdgeIds(e),
|
|
746
|
+
...this.getNodeOutcomingEdgeIds(e),
|
|
747
|
+
...this.getNodeCycleEdgeIds(e)
|
|
748
|
+
];
|
|
892
749
|
}
|
|
893
750
|
}
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
}
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
751
|
+
class le {
|
|
752
|
+
constructor(e) {
|
|
753
|
+
this.graphStore = e;
|
|
754
|
+
}
|
|
755
|
+
getNode(e) {
|
|
756
|
+
const t = this.graphStore.getNode(e);
|
|
757
|
+
return t === void 0 ? null : {
|
|
758
|
+
element: t.element,
|
|
759
|
+
x: t.x,
|
|
760
|
+
y: t.y,
|
|
761
|
+
centerFn: t.centerFn,
|
|
762
|
+
priority: t.priority
|
|
763
|
+
};
|
|
764
|
+
}
|
|
765
|
+
getAllNodeIds() {
|
|
766
|
+
return this.graphStore.getAllNodeIds();
|
|
767
|
+
}
|
|
768
|
+
getPort(e) {
|
|
769
|
+
const t = this.graphStore.getPort(e);
|
|
770
|
+
return t === void 0 ? null : {
|
|
771
|
+
element: t.element,
|
|
772
|
+
centerFn: t.centerFn,
|
|
773
|
+
direction: t.direction
|
|
774
|
+
};
|
|
775
|
+
}
|
|
776
|
+
getAllPortIds() {
|
|
777
|
+
return this.graphStore.getAllPortIds();
|
|
778
|
+
}
|
|
779
|
+
getNodePortIds(e) {
|
|
780
|
+
return this.graphStore.getNodePortIds(e);
|
|
781
|
+
}
|
|
782
|
+
getPortNodeId(e) {
|
|
783
|
+
return this.graphStore.getPortNodeId(e) ?? null;
|
|
784
|
+
}
|
|
785
|
+
getAllEdgeIds() {
|
|
786
|
+
return this.graphStore.getAllEdgeIds();
|
|
787
|
+
}
|
|
788
|
+
getEdge(e) {
|
|
789
|
+
const t = this.graphStore.getEdge(e);
|
|
790
|
+
return t === void 0 ? null : { from: t.from, to: t.to, priority: t.priority };
|
|
791
|
+
}
|
|
792
|
+
getPortIncomingEdgeIds(e) {
|
|
793
|
+
return this.graphStore.getPortIncomingEdgeIds(e);
|
|
794
|
+
}
|
|
795
|
+
getPortOutcomingEdgeIds(e) {
|
|
796
|
+
return this.graphStore.getPortOutcomingEdgeIds(e);
|
|
797
|
+
}
|
|
798
|
+
getPortCycleEdgeIds(e) {
|
|
799
|
+
return this.graphStore.getPortCycleEdgeIds(e);
|
|
800
|
+
}
|
|
801
|
+
getPortAdjacentEdgeIds(e) {
|
|
802
|
+
return this.graphStore.getPortAdjacentEdgeIds(e);
|
|
803
|
+
}
|
|
804
|
+
getNodeIncomingEdgeIds(e) {
|
|
805
|
+
return this.graphStore.getNodeIncomingEdgeIds(e);
|
|
806
|
+
}
|
|
807
|
+
getNodeOutcomingEdgeIds(e) {
|
|
808
|
+
return this.graphStore.getNodeOutcomingEdgeIds(e);
|
|
809
|
+
}
|
|
810
|
+
getNodeCycleEdgeIds(e) {
|
|
811
|
+
return this.graphStore.getNodeCycleEdgeIds(e);
|
|
812
|
+
}
|
|
813
|
+
getNodeAdjacentEdgeIds(e) {
|
|
814
|
+
return this.graphStore.getNodeAdjacentEdgeIds(e);
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
const K = (r) => ({
|
|
818
|
+
scale: 1 / r.scale,
|
|
819
|
+
dx: -r.dx / r.scale,
|
|
820
|
+
dy: -r.dy / r.scale
|
|
821
|
+
}), _ = {
|
|
822
|
+
scale: 1,
|
|
823
|
+
dx: 0,
|
|
824
|
+
dy: 0
|
|
903
825
|
};
|
|
904
|
-
class
|
|
826
|
+
class ge {
|
|
905
827
|
constructor() {
|
|
906
|
-
a(this, "
|
|
907
|
-
a(this, "
|
|
828
|
+
a(this, "viewportMatrix", _);
|
|
829
|
+
a(this, "contentMatrix", _);
|
|
908
830
|
}
|
|
909
|
-
|
|
910
|
-
|
|
831
|
+
getViewportMatrix() {
|
|
832
|
+
return this.viewportMatrix;
|
|
911
833
|
}
|
|
912
|
-
|
|
913
|
-
return this.
|
|
834
|
+
getContentMatrix() {
|
|
835
|
+
return this.contentMatrix;
|
|
914
836
|
}
|
|
915
|
-
|
|
916
|
-
|
|
837
|
+
patchViewportMatrix(e) {
|
|
838
|
+
this.viewportMatrix = {
|
|
839
|
+
scale: e.scale ?? this.viewportMatrix.scale,
|
|
840
|
+
dx: e.dx ?? this.viewportMatrix.dx,
|
|
841
|
+
dy: e.dy ?? this.viewportMatrix.dy
|
|
842
|
+
}, this.contentMatrix = K(this.viewportMatrix);
|
|
917
843
|
}
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
844
|
+
patchContentMatrix(e) {
|
|
845
|
+
this.contentMatrix = {
|
|
846
|
+
scale: e.scale ?? this.contentMatrix.scale,
|
|
847
|
+
dx: e.dx ?? this.contentMatrix.dx,
|
|
848
|
+
dy: e.dy ?? this.contentMatrix.dy
|
|
849
|
+
}, this.viewportMatrix = K(this.contentMatrix);
|
|
921
850
|
}
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
851
|
+
}
|
|
852
|
+
class ue {
|
|
853
|
+
constructor(e) {
|
|
854
|
+
this.transformer = e;
|
|
925
855
|
}
|
|
926
|
-
|
|
927
|
-
this.
|
|
928
|
-
e(t, s);
|
|
929
|
-
});
|
|
856
|
+
getViewportMatrix() {
|
|
857
|
+
return { ...this.transformer.getViewportMatrix() };
|
|
930
858
|
}
|
|
931
|
-
|
|
932
|
-
this.
|
|
859
|
+
getContentMatrix() {
|
|
860
|
+
return { ...this.transformer.getContentMatrix() };
|
|
933
861
|
}
|
|
934
862
|
}
|
|
935
|
-
|
|
936
|
-
|
|
863
|
+
const we = () => {
|
|
864
|
+
const r = document.createElement("div");
|
|
865
|
+
return r.style.width = "100%", r.style.height = "100%", r.style.position = "relative", r.style.overflow = "hidden", r;
|
|
866
|
+
}, ye = () => {
|
|
867
|
+
const r = document.createElement("div");
|
|
868
|
+
return r.style.position = "absolute", r.style.top = "0", r.style.left = "0", r.style.width = "0", r.style.height = "0", r;
|
|
869
|
+
}, me = () => {
|
|
870
|
+
const r = document.createElement("div");
|
|
871
|
+
return r.style.position = "absolute", r.style.top = "0", r.style.left = "0", r.style.visibility = "hidden", r;
|
|
872
|
+
};
|
|
873
|
+
class ve {
|
|
874
|
+
constructor(e, t) {
|
|
937
875
|
a(this, "canvasWrapper", null);
|
|
938
|
-
a(this, "host",
|
|
939
|
-
a(this, "container",
|
|
940
|
-
a(this, "
|
|
941
|
-
a(this, "nodeElementToIdMap", /* @__PURE__ */ new Map());
|
|
942
|
-
a(this, "nodeIdToWrapperElementMap", new ye());
|
|
876
|
+
a(this, "host", we());
|
|
877
|
+
a(this, "container", ye());
|
|
878
|
+
a(this, "nodeIdToWrapperElementMap", /* @__PURE__ */ new Map());
|
|
943
879
|
a(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
|
|
944
|
-
this.
|
|
880
|
+
this.graphStore = e, this.viewportTransformer = t, this.host.appendChild(this.container);
|
|
945
881
|
}
|
|
946
882
|
attach(e) {
|
|
947
883
|
this.detach(), this.canvasWrapper = e, this.canvasWrapper.appendChild(this.host);
|
|
@@ -954,16 +890,16 @@ class me {
|
|
|
954
890
|
this.container.style.transform = `matrix(${e.scale}, 0, 0, ${e.scale}, ${e.dx}, ${e.dy})`;
|
|
955
891
|
}
|
|
956
892
|
attachNode(e) {
|
|
957
|
-
const t = this.graphStore.getNode(e), s =
|
|
958
|
-
s.appendChild(t.element), this.container.appendChild(s), this.
|
|
893
|
+
const t = this.graphStore.getNode(e), s = me();
|
|
894
|
+
s.appendChild(t.element), this.container.appendChild(s), this.nodeIdToWrapperElementMap.set(e, s), this.updateNodeCoordinates(e), this.updateNodePriority(e), s.style.visibility = "visible";
|
|
959
895
|
}
|
|
960
896
|
detachNode(e) {
|
|
961
|
-
const t = this.graphStore.getNode(e), s = this.nodeIdToWrapperElementMap.
|
|
962
|
-
|
|
897
|
+
const t = this.graphStore.getNode(e), s = this.nodeIdToWrapperElementMap.get(e);
|
|
898
|
+
s.removeChild(t.element), this.container.removeChild(s), this.nodeIdToWrapperElementMap.delete(e);
|
|
963
899
|
}
|
|
964
900
|
attachEdge(e) {
|
|
965
901
|
const t = this.graphStore.getEdge(e);
|
|
966
|
-
this.edgeIdToElementMap.set(e, t.shape.svg), this.container.appendChild(t.shape.svg), this.
|
|
902
|
+
this.edgeIdToElementMap.set(e, t.shape.svg), this.container.appendChild(t.shape.svg), this.updateEdge(e), this.updateEdgePriority(e);
|
|
967
903
|
}
|
|
968
904
|
detachEdge(e) {
|
|
969
905
|
const t = this.graphStore.getEdge(e);
|
|
@@ -977,327 +913,322 @@ class me {
|
|
|
977
913
|
});
|
|
978
914
|
}
|
|
979
915
|
destroy() {
|
|
980
|
-
this.
|
|
916
|
+
this.clear(), this.detach(), this.host.removeChild(this.container);
|
|
981
917
|
}
|
|
982
918
|
updateNodeCoordinates(e) {
|
|
983
|
-
const t = this.graphStore.
|
|
984
|
-
|
|
985
|
-
this.updateEdgeCoordinates(s);
|
|
986
|
-
});
|
|
919
|
+
const t = this.nodeIdToWrapperElementMap.get(e), s = this.graphStore.getNode(e), { width: n, height: o } = s.element.getBoundingClientRect(), h = this.viewportTransformer.getViewportMatrix().scale, i = s.centerFn(n, o), d = s.x - h * i.x, c = s.y - h * i.y;
|
|
920
|
+
t.style.transform = `translate(${d}px, ${c}px)`;
|
|
987
921
|
}
|
|
988
922
|
updateNodePriority(e) {
|
|
989
|
-
const t = this.graphStore.getNode(e), s = this.nodeIdToWrapperElementMap.
|
|
923
|
+
const t = this.graphStore.getNode(e), s = this.nodeIdToWrapperElementMap.get(e);
|
|
990
924
|
s.style.zIndex = `${t.priority}`;
|
|
991
925
|
}
|
|
992
926
|
updateEdgeShape(e) {
|
|
993
927
|
const t = this.edgeIdToElementMap.get(e);
|
|
994
928
|
this.container.removeChild(t);
|
|
995
929
|
const s = this.graphStore.getEdge(e);
|
|
996
|
-
this.edgeIdToElementMap.set(e, s.shape.svg), this.container.appendChild(s.shape.svg)
|
|
997
|
-
}
|
|
998
|
-
updateEdgePriority(e) {
|
|
999
|
-
const t = this.graphStore.getEdge(e);
|
|
1000
|
-
t.shape.svg.style.zIndex = `${t.priority}`;
|
|
930
|
+
this.edgeIdToElementMap.set(e, s.shape.svg), this.container.appendChild(s.shape.svg);
|
|
1001
931
|
}
|
|
1002
|
-
|
|
1003
|
-
this.graphStore.
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
}
|
|
1007
|
-
createNodesResizeObserver() {
|
|
1008
|
-
return this.nodeResizeObserverFactory((e) => {
|
|
1009
|
-
e.forEach((t) => {
|
|
1010
|
-
const s = t.target, o = this.nodeIdToWrapperElementMap.getByValue(s);
|
|
1011
|
-
this.updateNodeCoordinatesInternal(o), this.graphStore.getNodeAdjacentEdgeIds(o).forEach((n) => {
|
|
1012
|
-
this.updateEdgeCoordinates(n);
|
|
1013
|
-
});
|
|
1014
|
-
});
|
|
1015
|
-
});
|
|
1016
|
-
}
|
|
1017
|
-
updateNodeCoordinatesInternal(e) {
|
|
1018
|
-
const t = this.nodeIdToWrapperElementMap.getByKey(e), { width: s, height: o } = this.getBoundingClientRect.call(t), i = this.viewportTransformer.getViewportMatrix().scale, n = this.graphStore.getNode(e), { x: h, y: c } = n.centerFn(s, o), d = n.x - i * h, u = n.y - i * c;
|
|
1019
|
-
t.style.transform = `translate(${d}px, ${u}px)`;
|
|
1020
|
-
}
|
|
1021
|
-
updateEdgeCoordinates(e) {
|
|
1022
|
-
const t = this.graphStore.getEdge(e), s = this.graphStore.getPort(t.from), o = this.graphStore.getPort(t.to), i = this.getBoundingClientRect.call(s.element), n = this.getBoundingClientRect.call(o.element), h = this.getBoundingClientRect.call(this.host), c = this.viewportTransformer.getViewportMatrix(), d = {
|
|
1023
|
-
x: c.scale * (i.left - h.left) + c.dx,
|
|
1024
|
-
y: c.scale * (i.top - h.top) + c.dy
|
|
932
|
+
updateEdge(e) {
|
|
933
|
+
const t = this.graphStore.getEdge(e), s = this.graphStore.getPort(t.from), n = this.graphStore.getPort(t.to), o = s.element.getBoundingClientRect(), h = n.element.getBoundingClientRect(), i = this.host.getBoundingClientRect(), d = this.viewportTransformer.getViewportMatrix(), c = {
|
|
934
|
+
x: d.scale * (o.left - i.left) + d.dx,
|
|
935
|
+
y: d.scale * (o.top - i.top) + d.dy
|
|
1025
936
|
}, u = {
|
|
1026
|
-
x:
|
|
1027
|
-
y:
|
|
937
|
+
x: d.scale * (h.left - i.left) + d.dx,
|
|
938
|
+
y: d.scale * (h.top - i.top) + d.dy
|
|
1028
939
|
}, w = s.centerFn(
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
), m =
|
|
1032
|
-
|
|
1033
|
-
|
|
940
|
+
o.width * d.scale,
|
|
941
|
+
o.height * d.scale
|
|
942
|
+
), m = n.centerFn(
|
|
943
|
+
h.width * d.scale,
|
|
944
|
+
h.height * d.scale
|
|
1034
945
|
), y = {
|
|
1035
|
-
x:
|
|
1036
|
-
y:
|
|
1037
|
-
},
|
|
946
|
+
x: c.x + w.x,
|
|
947
|
+
y: c.y + w.y
|
|
948
|
+
}, p = {
|
|
1038
949
|
x: u.x + m.x,
|
|
1039
950
|
y: u.y + m.y
|
|
1040
|
-
},
|
|
1041
|
-
t.shape.svg.style.width = `${
|
|
1042
|
-
const
|
|
951
|
+
}, M = Math.min(y.x, p.x), P = Math.min(y.y, p.y), S = Math.abs(p.x - y.x), b = Math.abs(p.y - y.y);
|
|
952
|
+
t.shape.svg.style.width = `${S}px`, t.shape.svg.style.height = `${b}px`, t.shape.svg.style.transform = `translate(${M}px, ${P}px)`;
|
|
953
|
+
const L = y.x <= p.x ? 1 : -1, F = y.y <= p.y ? 1 : -1;
|
|
1043
954
|
t.shape.update(
|
|
1044
|
-
{ x:
|
|
1045
|
-
|
|
1046
|
-
|
|
955
|
+
{ x: S, y: b },
|
|
956
|
+
L,
|
|
957
|
+
F,
|
|
1047
958
|
s.direction,
|
|
1048
|
-
|
|
959
|
+
n.direction
|
|
1049
960
|
);
|
|
1050
961
|
}
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
a(this, "publicViewportTransformer");
|
|
1055
|
-
a(this, "publicGraphStore");
|
|
1056
|
-
a(this, "canvasController");
|
|
1057
|
-
const c = new Q(), d = new q();
|
|
1058
|
-
this.publicGraphStore = new ee(d), this.publicViewportTransformer = new Z(
|
|
1059
|
-
c
|
|
1060
|
-
);
|
|
1061
|
-
const u = new me(
|
|
1062
|
-
e,
|
|
1063
|
-
t,
|
|
1064
|
-
d,
|
|
1065
|
-
c
|
|
1066
|
-
);
|
|
1067
|
-
this.canvasController = new le(
|
|
1068
|
-
d,
|
|
1069
|
-
u,
|
|
1070
|
-
c,
|
|
1071
|
-
s,
|
|
1072
|
-
o,
|
|
1073
|
-
i,
|
|
1074
|
-
n,
|
|
1075
|
-
h
|
|
1076
|
-
);
|
|
962
|
+
updateEdgePriority(e) {
|
|
963
|
+
const t = this.graphStore.getEdge(e);
|
|
964
|
+
t.shape.svg.style.zIndex = `${t.priority}`;
|
|
1077
965
|
}
|
|
1078
966
|
}
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
roundness: r.roundness ?? g.roundness,
|
|
1139
|
-
detourDistance: r.detourDistance ?? g.detourDistance,
|
|
1140
|
-
detourDirection: r.detourDirection ?? g.detourDirection
|
|
1141
|
-
});
|
|
1142
|
-
default:
|
|
1143
|
-
return ae({
|
|
1144
|
-
color: r.color ?? g.edgeColor,
|
|
1145
|
-
width: r.width ?? g.edgeWidth,
|
|
1146
|
-
arrowLength: r.arrowLength ?? g.edgeArrowLength,
|
|
1147
|
-
arrowWidth: r.arrowWidth ?? g.edgeArrowWidth,
|
|
1148
|
-
hasSourceArrow: r.hasSourceArrow ?? g.hasSourceArrow,
|
|
1149
|
-
hasTargetArrow: r.hasTargetArrow ?? g.hasTargetArrow,
|
|
1150
|
-
cycleRadius: r.cycleRadius ?? g.cycleSize,
|
|
1151
|
-
detourDistance: r.detourDistance ?? g.detourDistance,
|
|
1152
|
-
detourDirection: r.detourDirection ?? g.detourDirection,
|
|
1153
|
-
smallCycleRadius: r.smallCycleRadius ?? g.smallCycleSize,
|
|
1154
|
-
curvature: r.curvature ?? g.curvature
|
|
967
|
+
class $ {
|
|
968
|
+
constructor(e) {
|
|
969
|
+
a(this, "counter", 0);
|
|
970
|
+
this.checkExists = e;
|
|
971
|
+
}
|
|
972
|
+
create(e) {
|
|
973
|
+
if (e !== void 0)
|
|
974
|
+
return e;
|
|
975
|
+
for (; this.checkExists(this.counter); )
|
|
976
|
+
this.counter++;
|
|
977
|
+
return this.counter;
|
|
978
|
+
}
|
|
979
|
+
reset() {
|
|
980
|
+
this.counter = 0;
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
class A extends Error {
|
|
984
|
+
constructor() {
|
|
985
|
+
super(...arguments);
|
|
986
|
+
a(this, "name", "HtmlGraphError");
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
class pe {
|
|
990
|
+
constructor(e, t, s, n, o, h, i, d) {
|
|
991
|
+
a(this, "nodeIdGenerator", new $(
|
|
992
|
+
(e) => this.graphStore.getNode(e) !== void 0
|
|
993
|
+
));
|
|
994
|
+
a(this, "portIdGenerator", new $(
|
|
995
|
+
(e) => this.graphStore.getPort(e) !== void 0
|
|
996
|
+
));
|
|
997
|
+
a(this, "edgeIdGenerator", new $(
|
|
998
|
+
(e) => this.graphStore.getEdge(e) !== void 0
|
|
999
|
+
));
|
|
1000
|
+
this.graphStore = e, this.htmlController = t, this.viewportTransformer = s, this.defaultNodesCenterFn = n, this.defaultPortsCenterFn = o, this.defaultPortsDirection = h, this.defaultNodesPriorityFn = i, this.defaultEdgesPriorityFn = d;
|
|
1001
|
+
}
|
|
1002
|
+
attach(e) {
|
|
1003
|
+
this.htmlController.attach(e);
|
|
1004
|
+
}
|
|
1005
|
+
detach() {
|
|
1006
|
+
this.htmlController.detach();
|
|
1007
|
+
}
|
|
1008
|
+
addNode(e) {
|
|
1009
|
+
const t = this.nodeIdGenerator.create(e.nodeId);
|
|
1010
|
+
if (this.graphStore.getNode(t) !== void 0)
|
|
1011
|
+
throw new A("failed to add node with existing id");
|
|
1012
|
+
this.graphStore.addNode({
|
|
1013
|
+
nodeId: t,
|
|
1014
|
+
element: e.element,
|
|
1015
|
+
x: e.x,
|
|
1016
|
+
y: e.y,
|
|
1017
|
+
centerFn: e.centerFn ?? this.defaultNodesCenterFn,
|
|
1018
|
+
priority: e.priority ?? this.defaultNodesPriorityFn()
|
|
1019
|
+
}), this.htmlController.attachNode(t), Array.from(e.ports ?? []).forEach((s) => {
|
|
1020
|
+
this.markPort({
|
|
1021
|
+
portId: s.id,
|
|
1022
|
+
element: s.element,
|
|
1023
|
+
nodeId: t,
|
|
1024
|
+
centerFn: s.centerFn,
|
|
1025
|
+
direction: s.direction
|
|
1155
1026
|
});
|
|
1027
|
+
});
|
|
1156
1028
|
}
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1029
|
+
markPort(e) {
|
|
1030
|
+
const t = this.portIdGenerator.create(e.portId);
|
|
1031
|
+
if (this.graphStore.getPort(t) !== void 0)
|
|
1032
|
+
throw new A("failed to add port with existing id");
|
|
1033
|
+
if (this.graphStore.getNode(e.nodeId) === void 0)
|
|
1034
|
+
throw new A("failed to set port on nonexisting node");
|
|
1035
|
+
this.graphStore.addPort({
|
|
1036
|
+
portId: t,
|
|
1037
|
+
element: e.element,
|
|
1038
|
+
nodeId: e.nodeId,
|
|
1039
|
+
centerFn: e.centerFn ?? this.defaultPortsCenterFn,
|
|
1040
|
+
direction: e.direction ?? this.defaultPortsDirection
|
|
1041
|
+
});
|
|
1042
|
+
}
|
|
1043
|
+
addEdge(e) {
|
|
1044
|
+
const t = this.edgeIdGenerator.create(e.edgeId);
|
|
1045
|
+
if (this.graphStore.getEdge(t) !== void 0)
|
|
1046
|
+
throw new A("failed to add edge with existing id");
|
|
1047
|
+
if (this.graphStore.getPort(e.from) === void 0)
|
|
1048
|
+
throw new A("failed to add edge from nonexisting port");
|
|
1049
|
+
if (this.graphStore.getPort(e.to) === void 0)
|
|
1050
|
+
throw new A("failed to add edge to nonexisting port");
|
|
1051
|
+
const s = this.resolveEdgeType(e.from, e.to);
|
|
1052
|
+
this.graphStore.addEdge({
|
|
1053
|
+
edgeId: t,
|
|
1054
|
+
from: e.from,
|
|
1055
|
+
to: e.to,
|
|
1056
|
+
shape: e.shapeFactory(s),
|
|
1057
|
+
priority: e.priority ?? this.defaultEdgesPriorityFn()
|
|
1058
|
+
}), this.htmlController.attachEdge(t);
|
|
1059
|
+
}
|
|
1060
|
+
updateEdge(e) {
|
|
1061
|
+
const t = this.graphStore.getEdge(e.edgeId);
|
|
1062
|
+
if (t === void 0)
|
|
1063
|
+
throw new A("failed to update nonexisting edge");
|
|
1064
|
+
if (e.shape !== void 0) {
|
|
1065
|
+
const s = this.resolveEdgeType(t.from, t.to);
|
|
1066
|
+
t.shape = e.shape(s), this.htmlController.updateEdgeShape(e.edgeId);
|
|
1186
1067
|
}
|
|
1187
|
-
|
|
1188
|
-
}
|
|
1068
|
+
e.priority !== void 0 && (t.priority = e.priority, this.htmlController.updateEdgePriority(e.edgeId)), this.htmlController.updateEdge(e.edgeId);
|
|
1069
|
+
}
|
|
1070
|
+
updatePort(e, t) {
|
|
1071
|
+
const s = this.graphStore.getPort(e);
|
|
1072
|
+
if (s === void 0)
|
|
1073
|
+
throw new A("failed to unset nonexisting port");
|
|
1074
|
+
s.direction = t.direction ?? s.direction, s.centerFn = t.centerFn ?? s.centerFn, this.graphStore.getPortAdjacentEdgeIds(e).forEach((o) => {
|
|
1075
|
+
this.htmlController.updateEdge(o);
|
|
1076
|
+
});
|
|
1077
|
+
}
|
|
1078
|
+
updateNode(e, t) {
|
|
1079
|
+
const s = this.graphStore.getNode(e);
|
|
1080
|
+
if (s === void 0)
|
|
1081
|
+
throw new A("failed to update nonexisting node");
|
|
1082
|
+
s.x = (t == null ? void 0 : t.x) ?? s.x, s.y = (t == null ? void 0 : t.y) ?? s.y, s.centerFn = (t == null ? void 0 : t.centerFn) ?? s.centerFn, s.priority = (t == null ? void 0 : t.priority) ?? s.priority, this.htmlController.updateNodeCoordinates(e), this.htmlController.updateNodePriority(e), this.graphStore.getNodeAdjacentEdgeIds(e).forEach((o) => {
|
|
1083
|
+
this.htmlController.updateEdge(o);
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
1086
|
+
removeEdge(e) {
|
|
1087
|
+
if (this.graphStore.getEdge(e) === void 0)
|
|
1088
|
+
throw new A("failed to remove nonexisting edge");
|
|
1089
|
+
this.htmlController.detachEdge(e), this.graphStore.removeEdge(e);
|
|
1090
|
+
}
|
|
1091
|
+
unmarkPort(e) {
|
|
1092
|
+
if (this.graphStore.getPort(e) === void 0)
|
|
1093
|
+
throw new A("failed to unset nonexisting port");
|
|
1094
|
+
this.graphStore.getPortAdjacentEdgeIds(e).forEach((t) => {
|
|
1095
|
+
this.removeEdge(t);
|
|
1096
|
+
}), this.graphStore.removePort(e);
|
|
1097
|
+
}
|
|
1098
|
+
removeNode(e) {
|
|
1099
|
+
if (this.graphStore.getNode(e) === void 0)
|
|
1100
|
+
throw new A("failed to remove nonexisting node");
|
|
1101
|
+
this.graphStore.getNodePortIds(e).forEach((t) => {
|
|
1102
|
+
this.unmarkPort(t);
|
|
1103
|
+
}), this.htmlController.detachNode(e), this.graphStore.removeNode(e);
|
|
1104
|
+
}
|
|
1105
|
+
patchViewportMatrix(e) {
|
|
1106
|
+
this.viewportTransformer.patchViewportMatrix(e), this.htmlController.applyTransform();
|
|
1107
|
+
}
|
|
1108
|
+
patchContentMatrix(e) {
|
|
1109
|
+
this.viewportTransformer.patchContentMatrix(e), this.htmlController.applyTransform();
|
|
1110
|
+
}
|
|
1111
|
+
clear() {
|
|
1112
|
+
this.htmlController.clear(), this.graphStore.clear(), this.nodeIdGenerator.reset(), this.portIdGenerator.reset(), this.edgeIdGenerator.reset();
|
|
1113
|
+
}
|
|
1114
|
+
destroy() {
|
|
1115
|
+
this.clear(), this.htmlController.destroy();
|
|
1116
|
+
}
|
|
1117
|
+
resolveEdgeType(e, t) {
|
|
1118
|
+
if (e === t)
|
|
1119
|
+
return C.PortCycle;
|
|
1120
|
+
const s = this.graphStore.getPortNodeId(e), n = this.graphStore.getPortNodeId(t);
|
|
1121
|
+
return s === n ? C.NodeCycle : C.Regular;
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1189
1124
|
class xe {
|
|
1190
1125
|
constructor(e) {
|
|
1191
1126
|
a(this, "transformation");
|
|
1192
1127
|
a(this, "model");
|
|
1193
|
-
a(this, "
|
|
1128
|
+
a(this, "canvasController");
|
|
1194
1129
|
a(this, "edgeShapeFactory");
|
|
1195
|
-
a(this, "nodeResizeObserverFactory", (e) => new window.ResizeObserver(e));
|
|
1196
1130
|
this.apiOptions = e;
|
|
1197
|
-
const t =
|
|
1198
|
-
this.
|
|
1199
|
-
|
|
1200
|
-
|
|
1131
|
+
const t = de(this.apiOptions), s = new ge(), n = new ce();
|
|
1132
|
+
this.model = new le(n), this.transformation = new ue(s);
|
|
1133
|
+
const o = new ve(n, s);
|
|
1134
|
+
this.canvasController = new pe(
|
|
1135
|
+
n,
|
|
1136
|
+
o,
|
|
1137
|
+
s,
|
|
1201
1138
|
t.nodes.centerFn,
|
|
1202
1139
|
t.ports.centerFn,
|
|
1203
1140
|
t.ports.direction,
|
|
1204
1141
|
t.nodes.priorityFn,
|
|
1205
1142
|
t.edges.priorityFn
|
|
1206
|
-
), this.
|
|
1143
|
+
), this.edgeShapeFactory = t.edges.shapeFactory;
|
|
1144
|
+
}
|
|
1145
|
+
attach(e) {
|
|
1146
|
+
return this.canvasController.attach(e), this;
|
|
1147
|
+
}
|
|
1148
|
+
detach() {
|
|
1149
|
+
return this.canvasController.detach(), this;
|
|
1207
1150
|
}
|
|
1208
1151
|
addNode(e) {
|
|
1209
|
-
return this.
|
|
1210
|
-
e.id,
|
|
1211
|
-
e.element,
|
|
1212
|
-
e.x,
|
|
1213
|
-
e.y,
|
|
1214
|
-
e.ports,
|
|
1215
|
-
e.centerFn,
|
|
1216
|
-
e.priority
|
|
1217
|
-
), this;
|
|
1152
|
+
return this.canvasController.addNode({
|
|
1153
|
+
nodeId: e.id,
|
|
1154
|
+
element: e.element,
|
|
1155
|
+
x: e.x,
|
|
1156
|
+
y: e.y,
|
|
1157
|
+
ports: e.ports,
|
|
1158
|
+
centerFn: e.centerFn,
|
|
1159
|
+
priority: e.priority
|
|
1160
|
+
}), this;
|
|
1218
1161
|
}
|
|
1219
1162
|
updateNode(e, t) {
|
|
1220
|
-
return this.
|
|
1221
|
-
|
|
1222
|
-
t.
|
|
1223
|
-
t.
|
|
1224
|
-
t.
|
|
1225
|
-
|
|
1226
|
-
), this;
|
|
1163
|
+
return this.canvasController.updateNode(e, {
|
|
1164
|
+
x: t == null ? void 0 : t.x,
|
|
1165
|
+
y: t == null ? void 0 : t.y,
|
|
1166
|
+
priority: t == null ? void 0 : t.priority,
|
|
1167
|
+
centerFn: t == null ? void 0 : t.centerFn
|
|
1168
|
+
}), this;
|
|
1227
1169
|
}
|
|
1228
1170
|
removeNode(e) {
|
|
1229
|
-
return this.
|
|
1230
|
-
}
|
|
1231
|
-
markPort(e) {
|
|
1232
|
-
return this.di.canvasController.markPort(
|
|
1233
|
-
e.id,
|
|
1234
|
-
e.element,
|
|
1235
|
-
e.nodeId,
|
|
1236
|
-
e.centerFn,
|
|
1237
|
-
e.direction
|
|
1238
|
-
), this;
|
|
1239
|
-
}
|
|
1240
|
-
updatePort(e, t) {
|
|
1241
|
-
return this.di.canvasController.updatePort(
|
|
1242
|
-
e,
|
|
1243
|
-
t == null ? void 0 : t.direction,
|
|
1244
|
-
t == null ? void 0 : t.centerFn
|
|
1245
|
-
), this;
|
|
1246
|
-
}
|
|
1247
|
-
unmarkPort(e) {
|
|
1248
|
-
return this.di.canvasController.unmarkPort(e), this;
|
|
1171
|
+
return this.canvasController.removeNode(e), this;
|
|
1249
1172
|
}
|
|
1250
1173
|
addEdge(e) {
|
|
1251
|
-
const t = e.shape !== void 0 ?
|
|
1252
|
-
return this.
|
|
1253
|
-
e.id,
|
|
1254
|
-
e.from,
|
|
1255
|
-
e.to,
|
|
1256
|
-
t,
|
|
1257
|
-
e.priority
|
|
1258
|
-
), this;
|
|
1174
|
+
const t = e.shape !== void 0 ? B(e.shape) : this.edgeShapeFactory;
|
|
1175
|
+
return this.canvasController.addEdge({
|
|
1176
|
+
edgeId: e.id,
|
|
1177
|
+
from: e.from,
|
|
1178
|
+
to: e.to,
|
|
1179
|
+
shapeFactory: t,
|
|
1180
|
+
priority: e.priority
|
|
1181
|
+
}), this;
|
|
1259
1182
|
}
|
|
1260
1183
|
updateEdge(e, t) {
|
|
1261
|
-
const s = t.shape !== void 0 ?
|
|
1262
|
-
return this.
|
|
1184
|
+
const s = (t == null ? void 0 : t.shape) !== void 0 ? B(t.shape) : void 0;
|
|
1185
|
+
return this.canvasController.updateEdge({
|
|
1186
|
+
edgeId: e,
|
|
1187
|
+
shape: s,
|
|
1188
|
+
priority: t == null ? void 0 : t.priority
|
|
1189
|
+
}), this;
|
|
1263
1190
|
}
|
|
1264
1191
|
removeEdge(e) {
|
|
1265
|
-
return this.
|
|
1192
|
+
return this.canvasController.removeEdge(e), this;
|
|
1193
|
+
}
|
|
1194
|
+
markPort(e) {
|
|
1195
|
+
return this.canvasController.markPort({
|
|
1196
|
+
portId: e.id,
|
|
1197
|
+
element: e.element,
|
|
1198
|
+
nodeId: e.nodeId,
|
|
1199
|
+
centerFn: e.centerFn,
|
|
1200
|
+
direction: e.direction
|
|
1201
|
+
}), this;
|
|
1202
|
+
}
|
|
1203
|
+
updatePortMark(e, t) {
|
|
1204
|
+
return this.canvasController.updatePort(e, {
|
|
1205
|
+
direction: t == null ? void 0 : t.direction,
|
|
1206
|
+
centerFn: t == null ? void 0 : t.centerFn
|
|
1207
|
+
}), this;
|
|
1208
|
+
}
|
|
1209
|
+
unmarkPort(e) {
|
|
1210
|
+
return this.canvasController.unmarkPort(e), this;
|
|
1266
1211
|
}
|
|
1267
1212
|
patchViewportMatrix(e) {
|
|
1268
|
-
return this.
|
|
1269
|
-
e.scale ?? null,
|
|
1270
|
-
e.dx ?? null,
|
|
1271
|
-
e.dy ?? null
|
|
1272
|
-
), this;
|
|
1213
|
+
return this.canvasController.patchViewportMatrix(e), this;
|
|
1273
1214
|
}
|
|
1274
1215
|
patchContentMatrix(e) {
|
|
1275
|
-
return this.
|
|
1276
|
-
e.scale ?? null,
|
|
1277
|
-
e.dx ?? null,
|
|
1278
|
-
e.dy ?? null
|
|
1279
|
-
), this;
|
|
1216
|
+
return this.canvasController.patchContentMatrix(e), this;
|
|
1280
1217
|
}
|
|
1281
1218
|
clear() {
|
|
1282
|
-
return this.
|
|
1283
|
-
}
|
|
1284
|
-
attach(e) {
|
|
1285
|
-
return this.di.canvasController.attach(e), this;
|
|
1286
|
-
}
|
|
1287
|
-
detach() {
|
|
1288
|
-
return this.di.canvasController.detach(), this;
|
|
1219
|
+
return this.canvasController.clear(), this;
|
|
1289
1220
|
}
|
|
1290
1221
|
destroy() {
|
|
1291
|
-
this.
|
|
1222
|
+
this.clear(), this.canvasController.destroy();
|
|
1292
1223
|
}
|
|
1293
1224
|
}
|
|
1294
|
-
const
|
|
1295
|
-
const { x: s, y:
|
|
1296
|
-
return e >= s && e
|
|
1297
|
-
},
|
|
1225
|
+
const D = (r, e, t) => {
|
|
1226
|
+
const { x: s, y: n, width: o, height: h } = r.getBoundingClientRect();
|
|
1227
|
+
return e >= s && e <= s + o && t >= n && t <= n + h;
|
|
1228
|
+
}, k = (r, e, t) => e >= 0 && e <= r.innerWidth && t >= 0 && t <= r.innerHeight, V = (r, e) => {
|
|
1298
1229
|
e !== null ? r.style.cursor = e : r.style.removeProperty("cursor");
|
|
1299
1230
|
};
|
|
1300
|
-
class
|
|
1231
|
+
class fe {
|
|
1301
1232
|
constructor(e, t) {
|
|
1302
1233
|
a(this, "model");
|
|
1303
1234
|
a(this, "transformation");
|
|
@@ -1306,101 +1237,100 @@ class Ee {
|
|
|
1306
1237
|
a(this, "grabbedNodeId", null);
|
|
1307
1238
|
a(this, "onNodeDrag");
|
|
1308
1239
|
a(this, "onBeforeNodeDrag");
|
|
1309
|
-
a(this, "nodeIdGenerator", new
|
|
1240
|
+
a(this, "nodeIdGenerator", new $(
|
|
1310
1241
|
(e) => this.nodes.has(e)
|
|
1311
1242
|
));
|
|
1312
1243
|
a(this, "element", null);
|
|
1313
|
-
a(this, "
|
|
1314
|
-
this.
|
|
1315
|
-
});
|
|
1316
|
-
a(this, "onCanvasMouseMove", (e) => {
|
|
1317
|
-
if (this.element !== null && (!O(this.element, e.clientX, e.clientY) || !V(this.window, e.clientX, e.clientY))) {
|
|
1244
|
+
a(this, "onWindowMouseMove", (e) => {
|
|
1245
|
+
if (this.element !== null && (!D(this.element, e.clientX, e.clientY) || !k(this.window, e.clientX, e.clientY))) {
|
|
1318
1246
|
this.cancelMouseDrag();
|
|
1319
1247
|
return;
|
|
1320
1248
|
}
|
|
1321
1249
|
this.grabbedNodeId !== null && this.dragNode(this.grabbedNodeId, e.movementX, e.movementY);
|
|
1322
1250
|
});
|
|
1323
|
-
a(this, "
|
|
1324
|
-
|
|
1325
|
-
e.touches[0].clientX,
|
|
1326
|
-
e.touches[0].clientY
|
|
1327
|
-
];
|
|
1251
|
+
a(this, "onWindowMouseUp", (e) => {
|
|
1252
|
+
e.button === 0 && this.cancelMouseDrag();
|
|
1328
1253
|
});
|
|
1329
|
-
a(this, "
|
|
1330
|
-
if (e.touches.length
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
}
|
|
1254
|
+
a(this, "onWindowTouchMove", (e) => {
|
|
1255
|
+
if (e.touches.length !== 1)
|
|
1256
|
+
return;
|
|
1257
|
+
const t = e.touches[0];
|
|
1258
|
+
if (this.element !== null && (!D(this.element, t.clientX, t.clientY) || !k(this.window, t.clientX, t.clientY))) {
|
|
1259
|
+
this.cancelTouchDrag();
|
|
1260
|
+
return;
|
|
1261
|
+
}
|
|
1262
|
+
if (this.grabbedNodeId !== null && this.previousTouchCoords !== null) {
|
|
1263
|
+
const s = t.clientX - this.previousTouchCoords.x, n = t.clientY - this.previousTouchCoords.y;
|
|
1264
|
+
this.dragNode(this.grabbedNodeId, s, n), this.previousTouchCoords = {
|
|
1265
|
+
x: e.touches[0].clientX,
|
|
1266
|
+
y: e.touches[0].clientY
|
|
1267
|
+
};
|
|
1344
1268
|
}
|
|
1345
1269
|
});
|
|
1346
|
-
a(this, "
|
|
1347
|
-
e.touches.length > 0 ? this.previousTouchCoords =
|
|
1348
|
-
e.touches[0].clientX,
|
|
1349
|
-
e.touches[0].clientY
|
|
1350
|
-
|
|
1270
|
+
a(this, "onWindowTouchFinish", (e) => {
|
|
1271
|
+
e.touches.length > 0 ? this.previousTouchCoords = {
|
|
1272
|
+
x: e.touches[0].clientX,
|
|
1273
|
+
y: e.touches[0].clientY
|
|
1274
|
+
} : this.cancelTouchDrag();
|
|
1351
1275
|
});
|
|
1352
1276
|
a(this, "previousTouchCoords", null);
|
|
1353
1277
|
a(this, "freezePriority");
|
|
1354
1278
|
a(this, "window", window);
|
|
1355
1279
|
a(this, "dragCursor");
|
|
1356
|
-
var
|
|
1357
|
-
this.canvas = e, this.transformation = this.canvas.transformation, this.model = this.canvas.model
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1280
|
+
var s, n;
|
|
1281
|
+
this.canvas = e, this.transformation = this.canvas.transformation, this.model = this.canvas.model, this.onNodeDrag = ((s = t == null ? void 0 : t.events) == null ? void 0 : s.onNodeDrag) ?? (() => {
|
|
1282
|
+
}), this.onBeforeNodeDrag = ((n = t == null ? void 0 : t.events) == null ? void 0 : n.onBeforeNodeDrag) ?? (() => !0), this.freezePriority = (t == null ? void 0 : t.moveOnTop) === !1, this.dragCursor = (t == null ? void 0 : t.dragCursor) !== void 0 ? t.dragCursor : "grab";
|
|
1283
|
+
}
|
|
1284
|
+
attach(e) {
|
|
1285
|
+
return this.detach(), this.element = e, this.canvas.attach(this.element), this;
|
|
1286
|
+
}
|
|
1287
|
+
detach() {
|
|
1288
|
+
return this.canvas.detach(), this.element !== null && (this.element = null), this;
|
|
1363
1289
|
}
|
|
1364
1290
|
addNode(e) {
|
|
1365
1291
|
const t = this.nodeIdGenerator.create(e.id);
|
|
1366
1292
|
this.canvas.addNode({ ...e, id: t }), this.updateMaxNodePriority(t);
|
|
1367
|
-
const s = (
|
|
1368
|
-
if (this.element === null)
|
|
1293
|
+
const s = (o) => {
|
|
1294
|
+
if (this.element === null || o.button !== 0)
|
|
1369
1295
|
return;
|
|
1370
|
-
const
|
|
1296
|
+
const h = this.model.getNode(t);
|
|
1371
1297
|
this.onBeforeNodeDrag({
|
|
1372
1298
|
nodeId: t,
|
|
1373
1299
|
element: e.element,
|
|
1374
|
-
x:
|
|
1375
|
-
y:
|
|
1376
|
-
}) && (
|
|
1377
|
-
},
|
|
1378
|
-
|
|
1300
|
+
x: h.x,
|
|
1301
|
+
y: h.y
|
|
1302
|
+
}) && (o.stopImmediatePropagation(), this.grabbedNodeId = t, V(this.element, this.dragCursor), this.moveNodeOnTop(t), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.window.addEventListener("mousemove", this.onWindowMouseMove));
|
|
1303
|
+
}, n = (o) => {
|
|
1304
|
+
o.stopImmediatePropagation(), this.previousTouchCoords = {
|
|
1305
|
+
x: o.touches[0].clientX,
|
|
1306
|
+
y: o.touches[0].clientY
|
|
1307
|
+
};
|
|
1308
|
+
const h = this.model.getNode(t);
|
|
1379
1309
|
this.onBeforeNodeDrag({
|
|
1380
1310
|
nodeId: t,
|
|
1381
1311
|
element: e.element,
|
|
1382
|
-
x:
|
|
1383
|
-
y:
|
|
1384
|
-
}) &&
|
|
1312
|
+
x: h.x,
|
|
1313
|
+
y: h.y
|
|
1314
|
+
}) && o.touches.length === 1 && (this.grabbedNodeId = t, this.moveNodeOnTop(t), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish));
|
|
1385
1315
|
};
|
|
1386
1316
|
return this.nodes.set(t, {
|
|
1387
1317
|
element: e.element,
|
|
1388
1318
|
onMouseDown: s,
|
|
1389
|
-
onTouchStart:
|
|
1390
|
-
}), e.element.addEventListener("mousedown", s), e.element.addEventListener("touchstart",
|
|
1319
|
+
onTouchStart: n
|
|
1320
|
+
}), e.element.addEventListener("mousedown", s), e.element.addEventListener("touchstart", n), this;
|
|
1391
1321
|
}
|
|
1392
1322
|
updateNode(e, t) {
|
|
1393
1323
|
return this.canvas.updateNode(e, t), this.updateMaxNodePriority(e), this;
|
|
1394
1324
|
}
|
|
1395
1325
|
removeNode(e) {
|
|
1396
1326
|
const t = this.nodes.get(e);
|
|
1397
|
-
return t !== void 0 && (t.element.removeEventListener("mousedown", t.onMouseDown), t.element.removeEventListener("touchstart", t.onTouchStart)), this.
|
|
1327
|
+
return t !== void 0 && (t.element.removeEventListener("mousedown", t.onMouseDown), t.element.removeEventListener("touchstart", t.onTouchStart)), this.nodes.delete(e), this.canvas.removeNode(e), this;
|
|
1398
1328
|
}
|
|
1399
1329
|
markPort(e) {
|
|
1400
1330
|
return this.canvas.markPort(e), this;
|
|
1401
1331
|
}
|
|
1402
|
-
|
|
1403
|
-
return this.canvas.
|
|
1332
|
+
updatePortMark(e, t) {
|
|
1333
|
+
return this.canvas.updatePortMark(e, t), this;
|
|
1404
1334
|
}
|
|
1405
1335
|
unmarkPort(e) {
|
|
1406
1336
|
return this.canvas.unmarkPort(e), this;
|
|
@@ -1425,27 +1355,19 @@ class Ee {
|
|
|
1425
1355
|
e.element.removeEventListener("mousedown", e.onMouseDown), e.element.removeEventListener("touchstart", e.onTouchStart);
|
|
1426
1356
|
}), this.nodes.clear(), this.maxNodePriority = 0, this;
|
|
1427
1357
|
}
|
|
1428
|
-
attach(e) {
|
|
1429
|
-
return this.detach(), this.element = e, this.element.addEventListener("touchstart", this.onCanvasTouchStart), this.canvas.attach(this.element), this;
|
|
1430
|
-
}
|
|
1431
|
-
detach() {
|
|
1432
|
-
return this.canvas.detach(), this.element !== null && (this.element.removeEventListener("touchstart", this.onCanvasTouchStart), this.element = null), this;
|
|
1433
|
-
}
|
|
1434
1358
|
destroy() {
|
|
1435
|
-
this.detach(), this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.
|
|
1436
|
-
e.element.removeEventListener("mousedown", e.onMouseDown), e.element.removeEventListener("touchstart", e.onTouchStart);
|
|
1437
|
-
}), this.nodes.clear(), this.canvas.destroy();
|
|
1359
|
+
this.detach(), this.clear(), this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.canvas.destroy();
|
|
1438
1360
|
}
|
|
1439
1361
|
dragNode(e, t, s) {
|
|
1440
|
-
const
|
|
1441
|
-
if (
|
|
1442
|
-
|
|
1443
|
-
const
|
|
1362
|
+
const n = this.model.getNode(e);
|
|
1363
|
+
if (n === null)
|
|
1364
|
+
return;
|
|
1365
|
+
const o = this.canvas.transformation.getContentMatrix(), h = o.scale * n.x + o.dx, i = o.scale * n.y + o.dy, d = h + t, c = i + s, u = this.canvas.transformation.getViewportMatrix(), w = u.scale * d + u.dx, m = u.scale * c + u.dy;
|
|
1444
1366
|
this.canvas.updateNode(e, { x: w, y: m }), this.onNodeDrag({
|
|
1445
1367
|
nodeId: e,
|
|
1446
|
-
element:
|
|
1447
|
-
x:
|
|
1448
|
-
y:
|
|
1368
|
+
element: n.element,
|
|
1369
|
+
x: n.x,
|
|
1370
|
+
y: n.y
|
|
1449
1371
|
});
|
|
1450
1372
|
}
|
|
1451
1373
|
updateMaxNodePriority(e) {
|
|
@@ -1457,137 +1379,184 @@ class Ee {
|
|
|
1457
1379
|
return;
|
|
1458
1380
|
this.maxNodePriority += 2, this.updateNode(e, { priority: this.maxNodePriority });
|
|
1459
1381
|
const t = this.maxNodePriority - 1;
|
|
1460
|
-
this.model.getNodeAdjacentEdgeIds(e).forEach((
|
|
1461
|
-
this.updateEdge(
|
|
1382
|
+
this.model.getNodeAdjacentEdgeIds(e).forEach((n) => {
|
|
1383
|
+
this.updateEdge(n, { priority: t });
|
|
1462
1384
|
});
|
|
1463
1385
|
}
|
|
1464
1386
|
cancelMouseDrag() {
|
|
1465
|
-
this.grabbedNodeId = null, this.element !== null &&
|
|
1387
|
+
this.grabbedNodeId = null, this.element !== null && V(this.element, null), this.removeMouseDragListeners();
|
|
1466
1388
|
}
|
|
1467
1389
|
removeMouseDragListeners() {
|
|
1468
|
-
this.window.removeEventListener("mouseup", this.
|
|
1390
|
+
this.window.removeEventListener("mouseup", this.onWindowMouseUp), this.window.removeEventListener("mousemove", this.onWindowMouseMove);
|
|
1469
1391
|
}
|
|
1470
1392
|
cancelTouchDrag() {
|
|
1471
1393
|
this.previousTouchCoords = null, this.grabbedNodeId = null, this.removeTouchDragListeners();
|
|
1472
1394
|
}
|
|
1473
1395
|
removeTouchDragListeners() {
|
|
1474
|
-
this.window.removeEventListener("touchmove", this.
|
|
1396
|
+
this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
|
|
1475
1397
|
}
|
|
1476
1398
|
}
|
|
1477
|
-
const
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1399
|
+
const Ee = (r) => {
|
|
1400
|
+
const e = r.maxContentScale, t = r.minContentScale, s = e !== null ? 1 / e : 0, n = t !== null ? 1 / t : 1 / 0;
|
|
1401
|
+
return (o) => {
|
|
1402
|
+
let h = o.nextTransform.scale, i = o.nextTransform.dx, d = o.nextTransform.dy;
|
|
1403
|
+
return o.nextTransform.scale > n && o.nextTransform.scale > o.prevTransform.scale && (h = Math.max(o.prevTransform.scale, n), i = o.prevTransform.dx, d = o.prevTransform.dy), o.nextTransform.scale < s && o.nextTransform.scale < o.prevTransform.scale && (h = Math.min(o.prevTransform.scale, s), i = o.prevTransform.dx, d = o.prevTransform.dy), {
|
|
1404
|
+
scale: h,
|
|
1405
|
+
dx: i,
|
|
1406
|
+
dy: d
|
|
1407
|
+
};
|
|
1408
|
+
};
|
|
1409
|
+
}, Ae = (r) => {
|
|
1410
|
+
const e = r.minX !== null ? r.minX : -1 / 0, t = r.maxX !== null ? r.maxX : 1 / 0, s = r.minY !== null ? r.minY : -1 / 0, n = r.maxY !== null ? r.maxY : 1 / 0;
|
|
1411
|
+
return (o) => {
|
|
1412
|
+
let h = o.nextTransform.dx, i = o.nextTransform.dy;
|
|
1413
|
+
h < e && h < o.prevTransform.dx && (h = Math.min(o.prevTransform.dx, e));
|
|
1414
|
+
const d = o.canvasWidth * o.prevTransform.scale;
|
|
1415
|
+
h > t - d && h > o.prevTransform.dx && (h = Math.max(o.prevTransform.dx, t - d)), i < s && i < o.prevTransform.dy && (i = Math.min(o.prevTransform.dy, s));
|
|
1416
|
+
const c = o.canvasHeight * o.prevTransform.scale;
|
|
1417
|
+
return i > n - c && i > o.prevTransform.dy && (i = Math.max(o.prevTransform.dy, n - c)), { scale: o.nextTransform.scale, dx: h, dy: i };
|
|
1418
|
+
};
|
|
1419
|
+
}, J = (r) => {
|
|
1420
|
+
if (typeof r == "function")
|
|
1421
|
+
return r;
|
|
1489
1422
|
switch (r.type) {
|
|
1490
1423
|
case "scale-limit":
|
|
1491
|
-
return
|
|
1492
|
-
r.minContentScale ??
|
|
1493
|
-
r.maxContentScale ??
|
|
1494
|
-
);
|
|
1424
|
+
return Ee({
|
|
1425
|
+
minContentScale: r.minContentScale ?? 0,
|
|
1426
|
+
maxContentScale: r.maxContentScale ?? 1 / 0
|
|
1427
|
+
});
|
|
1495
1428
|
case "shift-limit":
|
|
1496
|
-
return
|
|
1497
|
-
r.minX ??
|
|
1498
|
-
r.maxX ??
|
|
1499
|
-
r.minY ??
|
|
1500
|
-
r.maxY ??
|
|
1501
|
-
);
|
|
1502
|
-
default:
|
|
1503
|
-
return r.preprocessorFn;
|
|
1429
|
+
return Ae({
|
|
1430
|
+
minX: r.minX ?? -1 / 0,
|
|
1431
|
+
maxX: r.maxX ?? 1 / 0,
|
|
1432
|
+
minY: r.minY ?? -1 / 0,
|
|
1433
|
+
maxY: r.maxY ?? 1 / 0
|
|
1434
|
+
});
|
|
1504
1435
|
}
|
|
1505
|
-
},
|
|
1506
|
-
(
|
|
1507
|
-
|
|
1508
|
-
|
|
1436
|
+
}, Ce = (r) => (e) => r.reduce(
|
|
1437
|
+
(t, s) => s({
|
|
1438
|
+
prevTransform: e.prevTransform,
|
|
1439
|
+
nextTransform: t,
|
|
1440
|
+
canvasWidth: e.canvasWidth,
|
|
1441
|
+
canvasHeight: e.canvasHeight
|
|
1442
|
+
}),
|
|
1443
|
+
e.nextTransform
|
|
1444
|
+
), Me = (r) => {
|
|
1445
|
+
var d, c, u, w;
|
|
1446
|
+
const e = (d = r == null ? void 0 : r.scale) == null ? void 0 : d.wheelSensitivity, t = e !== void 0 ? e : 1.2, s = r == null ? void 0 : r.transformPreprocessor;
|
|
1447
|
+
let n;
|
|
1448
|
+
s !== void 0 ? Array.isArray(s) ? n = Ce(
|
|
1449
|
+
s.map(
|
|
1450
|
+
(m) => J(m)
|
|
1451
|
+
)
|
|
1452
|
+
) : n = J(s) : n = (m) => m.nextTransform;
|
|
1453
|
+
const o = ((c = r == null ? void 0 : r.shift) == null ? void 0 : c.cursor) !== void 0 ? r.shift.cursor : "grab", h = ((u = r == null ? void 0 : r.events) == null ? void 0 : u.onBeforeTransformStarted) ?? (() => {
|
|
1454
|
+
}), i = ((w = r == null ? void 0 : r.events) == null ? void 0 : w.onTransformFinished) ?? (() => {
|
|
1455
|
+
});
|
|
1456
|
+
return {
|
|
1457
|
+
wheelSensitivity: t,
|
|
1458
|
+
onBeforeTransformStarted: h,
|
|
1459
|
+
onTransformFinished: i,
|
|
1460
|
+
transformPreprocessor: n,
|
|
1461
|
+
shiftCursor: o
|
|
1462
|
+
};
|
|
1463
|
+
}, z = (r) => {
|
|
1464
|
+
const e = [], t = r.touches.length;
|
|
1465
|
+
for (let i = 0; i < t; i++)
|
|
1466
|
+
e.push([r.touches[i].clientX, r.touches[i].clientY]);
|
|
1467
|
+
const s = e.reduce(
|
|
1468
|
+
(i, d) => [i[0] + d[0], i[1] + d[1]],
|
|
1469
|
+
[0, 0]
|
|
1470
|
+
), n = [s[0] / t, s[1] / t], h = e.map((i) => [i[0] - n[0], i[1] - n[1]]).reduce(
|
|
1471
|
+
(i, d) => i + Math.sqrt(d[0] * d[0] + d[1] * d[1]),
|
|
1472
|
+
0
|
|
1473
|
+
);
|
|
1474
|
+
return {
|
|
1475
|
+
x: n[0],
|
|
1476
|
+
y: n[1],
|
|
1477
|
+
scale: h / t,
|
|
1478
|
+
touchesCnt: t,
|
|
1479
|
+
touches: e
|
|
1480
|
+
};
|
|
1481
|
+
}, Pe = (r, e, t) => ({
|
|
1482
|
+
scale: r.scale,
|
|
1483
|
+
dx: r.dx + r.scale * e,
|
|
1484
|
+
dy: r.dy + r.scale * t
|
|
1485
|
+
}), Se = (r, e, t, s) => ({
|
|
1486
|
+
scale: r.scale * e,
|
|
1487
|
+
dx: r.scale * (1 - e) * t + r.dx,
|
|
1488
|
+
dy: r.scale * (1 - e) * s + r.dy
|
|
1489
|
+
});
|
|
1509
1490
|
class Ne {
|
|
1510
1491
|
constructor(e, t) {
|
|
1511
1492
|
a(this, "model");
|
|
1512
1493
|
a(this, "transformation");
|
|
1513
1494
|
a(this, "element", null);
|
|
1514
1495
|
a(this, "prevTouches", null);
|
|
1515
|
-
a(this, "onTransformFinished");
|
|
1516
|
-
a(this, "transformPreprocessor");
|
|
1517
|
-
a(this, "isScalable");
|
|
1518
|
-
a(this, "isShiftable");
|
|
1519
|
-
a(this, "wheelSensitivity");
|
|
1520
1496
|
a(this, "window", window);
|
|
1521
|
-
a(this, "onMouseDown", () => {
|
|
1522
|
-
this.element
|
|
1497
|
+
a(this, "onMouseDown", (e) => {
|
|
1498
|
+
this.element === null || e.button !== 0 || (V(this.element, this.options.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove), this.window.addEventListener("mouseup", this.onWindowMouseUp));
|
|
1523
1499
|
});
|
|
1524
|
-
a(this, "
|
|
1525
|
-
if (
|
|
1526
|
-
return;
|
|
1527
|
-
if (!O(this.element, e.clientX, e.clientY) || !V(this.window, e.clientX, e.clientY)) {
|
|
1500
|
+
a(this, "onWindowMouseMove", (e) => {
|
|
1501
|
+
if (this.element === null || !D(this.element, e.clientX, e.clientY) || !k(this.window, e.clientX, e.clientY)) {
|
|
1528
1502
|
this.stopMouseDrag();
|
|
1529
1503
|
return;
|
|
1530
1504
|
}
|
|
1531
1505
|
const t = -e.movementX, s = -e.movementY;
|
|
1532
|
-
this.moveViewport(t, s);
|
|
1506
|
+
this.moveViewport(this.element, t, s);
|
|
1533
1507
|
});
|
|
1534
|
-
a(this, "
|
|
1535
|
-
this.stopMouseDrag();
|
|
1508
|
+
a(this, "onWindowMouseUp", (e) => {
|
|
1509
|
+
this.element === null || e.button !== 0 || this.stopMouseDrag();
|
|
1536
1510
|
});
|
|
1537
1511
|
a(this, "onWheelScroll", (e) => {
|
|
1538
|
-
if (this.element === null || this.isScalable === !1)
|
|
1539
|
-
return;
|
|
1540
1512
|
e.preventDefault();
|
|
1541
|
-
const { left: t, top: s } = this.element.getBoundingClientRect(),
|
|
1542
|
-
this.scaleViewport(
|
|
1513
|
+
const { left: t, top: s } = this.element.getBoundingClientRect(), n = e.clientX - t, o = e.clientY - s, i = 1 / (e.deltaY < 0 ? this.options.wheelSensitivity : 1 / this.options.wheelSensitivity);
|
|
1514
|
+
this.scaleViewport(this.element, i, n, o);
|
|
1543
1515
|
});
|
|
1544
1516
|
a(this, "onTouchStart", (e) => {
|
|
1545
|
-
this.prevTouches =
|
|
1517
|
+
this.prevTouches = z(e), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish);
|
|
1546
1518
|
});
|
|
1547
|
-
a(this, "
|
|
1548
|
-
|
|
1519
|
+
a(this, "onWindowTouchMove", (e) => {
|
|
1520
|
+
const t = this.element;
|
|
1521
|
+
if (t === null)
|
|
1549
1522
|
return;
|
|
1550
|
-
const
|
|
1551
|
-
if (!
|
|
1552
|
-
(o) =>
|
|
1523
|
+
const s = z(e);
|
|
1524
|
+
if (!s.touches.every(
|
|
1525
|
+
(o) => D(t, o[0], o[1]) && k(this.window, o[0], o[1])
|
|
1553
1526
|
)) {
|
|
1554
1527
|
this.stopTouchDrag();
|
|
1555
1528
|
return;
|
|
1556
1529
|
}
|
|
1557
|
-
if ((
|
|
1558
|
-
|
|
1559
|
-
-(
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1530
|
+
if ((s.touchesCnt === 1 || s.touchesCnt === 2) && this.moveViewport(
|
|
1531
|
+
t,
|
|
1532
|
+
-(s.x - this.prevTouches.x),
|
|
1533
|
+
-(s.y - this.prevTouches.y)
|
|
1534
|
+
), s.touchesCnt === 2) {
|
|
1535
|
+
const { left: o, top: h } = t.getBoundingClientRect(), i = this.prevTouches.x - o, d = this.prevTouches.y - h, u = 1 / (s.scale / this.prevTouches.scale);
|
|
1536
|
+
this.scaleViewport(t, u, i, d);
|
|
1563
1537
|
}
|
|
1564
|
-
this.prevTouches =
|
|
1538
|
+
this.prevTouches = s;
|
|
1565
1539
|
});
|
|
1566
|
-
a(this, "
|
|
1567
|
-
e.touches.length > 0 ? this.prevTouches =
|
|
1540
|
+
a(this, "onWindowTouchFinish", (e) => {
|
|
1541
|
+
e.touches.length > 0 ? this.prevTouches = z(e) : this.stopTouchDrag();
|
|
1568
1542
|
});
|
|
1569
1543
|
a(this, "observer", new ResizeObserver(() => {
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
this.canvas.patchViewportMatrix(o), this.onTransformFinished();
|
|
1578
|
-
}
|
|
1544
|
+
const e = this.canvas.transformation.getViewportMatrix(), { width: t, height: s } = this.element.getBoundingClientRect(), n = this.options.transformPreprocessor({
|
|
1545
|
+
prevTransform: e,
|
|
1546
|
+
nextTransform: e,
|
|
1547
|
+
canvasWidth: t,
|
|
1548
|
+
canvasHeight: s
|
|
1549
|
+
});
|
|
1550
|
+
this.canvas.patchViewportMatrix(n), this.options.onTransformFinished();
|
|
1579
1551
|
}));
|
|
1580
|
-
a(this, "
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
this.
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
(y) => K(y)
|
|
1589
|
-
)
|
|
1590
|
-
) : this.transformPreprocessor = K(o) : this.transformPreprocessor = Ae, this.shiftCursor = ((m = t == null ? void 0 : t.shift) == null ? void 0 : m.cursor) !== void 0 ? t.shift.cursor : "grab";
|
|
1552
|
+
a(this, "options");
|
|
1553
|
+
this.canvas = e, this.options = Me(t), this.transformation = this.canvas.transformation, this.model = this.canvas.model;
|
|
1554
|
+
}
|
|
1555
|
+
attach(e) {
|
|
1556
|
+
return this.detach(), this.element = e, this.observer.observe(this.element), this.element.addEventListener("mousedown", this.onMouseDown), this.element.addEventListener("wheel", this.onWheelScroll), this.element.addEventListener("touchstart", this.onTouchStart), this.canvas.attach(this.element), this;
|
|
1557
|
+
}
|
|
1558
|
+
detach() {
|
|
1559
|
+
return this.canvas.detach(), this.element !== null && (this.observer.unobserve(this.element), this.element.removeEventListener("mousedown", this.onMouseDown), this.element.removeEventListener("wheel", this.onWheelScroll), this.element.removeEventListener("touchstart", this.onTouchStart), this.element = null), this;
|
|
1591
1560
|
}
|
|
1592
1561
|
addNode(e) {
|
|
1593
1562
|
return this.canvas.addNode(e), this;
|
|
@@ -1601,8 +1570,8 @@ class Ne {
|
|
|
1601
1570
|
markPort(e) {
|
|
1602
1571
|
return this.canvas.markPort(e), this;
|
|
1603
1572
|
}
|
|
1604
|
-
|
|
1605
|
-
return this.canvas.
|
|
1573
|
+
updatePortMark(e, t) {
|
|
1574
|
+
return this.canvas.updatePortMark(e, t), this;
|
|
1606
1575
|
}
|
|
1607
1576
|
unmarkPort(e) {
|
|
1608
1577
|
return this.canvas.unmarkPort(e), this;
|
|
@@ -1625,85 +1594,161 @@ class Ne {
|
|
|
1625
1594
|
clear() {
|
|
1626
1595
|
return this.canvas.clear(), this;
|
|
1627
1596
|
}
|
|
1628
|
-
attach(e) {
|
|
1629
|
-
return this.detach(), this.element = e, this.observer.observe(this.element), this.element.addEventListener("mousedown", this.onMouseDown), this.element.addEventListener("wheel", this.onWheelScroll), this.element.addEventListener("touchstart", this.onTouchStart), this.canvas.attach(this.element), this;
|
|
1630
|
-
}
|
|
1631
|
-
detach() {
|
|
1632
|
-
return this.canvas.detach(), this.element !== null && (this.observer.unobserve(this.element), this.element.removeEventListener("mousedown", this.onMouseDown), this.element.removeEventListener("wheel", this.onWheelScroll), this.element.removeEventListener("touchstart", this.onTouchStart), this.element = null), this;
|
|
1633
|
-
}
|
|
1634
1597
|
destroy() {
|
|
1635
1598
|
this.detach(), this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.canvas.destroy();
|
|
1636
1599
|
}
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
)
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
};
|
|
1655
|
-
|
|
1656
|
-
moveViewport(e, t) {
|
|
1657
|
-
const s = this.transformation.getViewportMatrix(), o = {
|
|
1658
|
-
scale: s.scale,
|
|
1659
|
-
dx: s.dx + s.scale * e,
|
|
1660
|
-
dy: s.dy + s.scale * t
|
|
1661
|
-
};
|
|
1662
|
-
if (this.element !== null) {
|
|
1663
|
-
const { width: i, height: n } = this.element.getBoundingClientRect(), h = this.transformPreprocessor(
|
|
1664
|
-
s,
|
|
1665
|
-
o,
|
|
1666
|
-
i,
|
|
1667
|
-
n
|
|
1668
|
-
);
|
|
1669
|
-
this.canvas.patchViewportMatrix(h), this.onTransformFinished();
|
|
1670
|
-
}
|
|
1671
|
-
}
|
|
1672
|
-
scaleViewport(e, t, s) {
|
|
1673
|
-
if (this.element === null)
|
|
1674
|
-
return;
|
|
1675
|
-
const o = this.canvas.transformation.getViewportMatrix(), i = {
|
|
1676
|
-
scale: o.scale * e,
|
|
1677
|
-
dx: o.scale * (1 - e) * t + o.dx,
|
|
1678
|
-
dy: o.scale * (1 - e) * s + o.dy
|
|
1679
|
-
}, { width: n, height: h } = this.element.getBoundingClientRect(), c = this.transformPreprocessor(
|
|
1680
|
-
o,
|
|
1681
|
-
i,
|
|
1682
|
-
n,
|
|
1683
|
-
h
|
|
1684
|
-
);
|
|
1685
|
-
this.canvas.patchViewportMatrix(c), this.onTransformFinished();
|
|
1600
|
+
moveViewport(e, t, s) {
|
|
1601
|
+
this.options.onBeforeTransformStarted();
|
|
1602
|
+
const n = this.transformation.getViewportMatrix(), o = Pe(n, t, s), { width: h, height: i } = e.getBoundingClientRect(), d = this.options.transformPreprocessor({
|
|
1603
|
+
prevTransform: n,
|
|
1604
|
+
nextTransform: o,
|
|
1605
|
+
canvasWidth: h,
|
|
1606
|
+
canvasHeight: i
|
|
1607
|
+
});
|
|
1608
|
+
this.canvas.patchViewportMatrix(d), this.options.onTransformFinished();
|
|
1609
|
+
}
|
|
1610
|
+
scaleViewport(e, t, s, n) {
|
|
1611
|
+
this.options.onBeforeTransformStarted();
|
|
1612
|
+
const o = this.canvas.transformation.getViewportMatrix(), h = Se(o, t, s, n), { width: i, height: d } = e.getBoundingClientRect(), c = this.options.transformPreprocessor({
|
|
1613
|
+
prevTransform: o,
|
|
1614
|
+
nextTransform: h,
|
|
1615
|
+
canvasWidth: i,
|
|
1616
|
+
canvasHeight: d
|
|
1617
|
+
});
|
|
1618
|
+
this.canvas.patchViewportMatrix(c), this.options.onTransformFinished();
|
|
1686
1619
|
}
|
|
1687
1620
|
stopMouseDrag() {
|
|
1688
|
-
this.element !== null &&
|
|
1621
|
+
this.element !== null && V(this.element, null), this.removeMouseDragListeners();
|
|
1689
1622
|
}
|
|
1690
1623
|
removeMouseDragListeners() {
|
|
1691
|
-
this.window.removeEventListener("mousemove", this.
|
|
1624
|
+
this.window.removeEventListener("mousemove", this.onWindowMouseMove), this.window.removeEventListener("mouseup", this.onWindowMouseUp);
|
|
1692
1625
|
}
|
|
1693
1626
|
stopTouchDrag() {
|
|
1694
1627
|
this.prevTouches = null, this.removeTouchDragListeners();
|
|
1695
1628
|
}
|
|
1696
1629
|
removeTouchDragListeners() {
|
|
1697
|
-
this.window.removeEventListener("touchmove", this.
|
|
1630
|
+
this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
|
|
1698
1631
|
}
|
|
1699
1632
|
}
|
|
1700
1633
|
class Te {
|
|
1634
|
+
constructor() {
|
|
1635
|
+
a(this, "keyMap", /* @__PURE__ */ new Map());
|
|
1636
|
+
a(this, "valueMap", /* @__PURE__ */ new Map());
|
|
1637
|
+
}
|
|
1638
|
+
set(e, t) {
|
|
1639
|
+
this.keyMap.set(e, t), this.valueMap.set(t, e);
|
|
1640
|
+
}
|
|
1641
|
+
hasKey(e) {
|
|
1642
|
+
return this.keyMap.has(e);
|
|
1643
|
+
}
|
|
1644
|
+
hasValue(e) {
|
|
1645
|
+
return this.valueMap.has(e);
|
|
1646
|
+
}
|
|
1647
|
+
getByKey(e) {
|
|
1648
|
+
return this.keyMap.get(e);
|
|
1649
|
+
}
|
|
1650
|
+
getByValue(e) {
|
|
1651
|
+
return this.valueMap.get(e);
|
|
1652
|
+
}
|
|
1653
|
+
deleteByKey(e) {
|
|
1654
|
+
const t = this.keyMap.get(e);
|
|
1655
|
+
t !== void 0 && this.valueMap.delete(t), this.keyMap.delete(e);
|
|
1656
|
+
}
|
|
1657
|
+
deleteByValue(e) {
|
|
1658
|
+
const t = this.valueMap.get(e);
|
|
1659
|
+
t !== void 0 && this.keyMap.delete(t), this.valueMap.delete(e);
|
|
1660
|
+
}
|
|
1661
|
+
forEach(e) {
|
|
1662
|
+
this.keyMap.forEach((t, s) => {
|
|
1663
|
+
e(t, s);
|
|
1664
|
+
});
|
|
1665
|
+
}
|
|
1666
|
+
clear() {
|
|
1667
|
+
this.keyMap.clear(), this.valueMap.clear();
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1670
|
+
class Le {
|
|
1671
|
+
constructor(e) {
|
|
1672
|
+
a(this, "transformation");
|
|
1673
|
+
a(this, "model");
|
|
1674
|
+
a(this, "nodes", new Te());
|
|
1675
|
+
a(this, "nodeIdGenerator", new $(
|
|
1676
|
+
(e) => this.nodes.hasKey(e)
|
|
1677
|
+
));
|
|
1678
|
+
a(this, "nodesResizeObserver");
|
|
1679
|
+
this.canvas = e, this.nodesResizeObserver = new window.ResizeObserver((t) => {
|
|
1680
|
+
t.forEach((s) => {
|
|
1681
|
+
const n = s.target;
|
|
1682
|
+
this.reactNodeChange(n);
|
|
1683
|
+
});
|
|
1684
|
+
}), this.transformation = this.canvas.transformation, this.model = this.canvas.model;
|
|
1685
|
+
}
|
|
1686
|
+
attach(e) {
|
|
1687
|
+
return this.canvas.attach(e), this;
|
|
1688
|
+
}
|
|
1689
|
+
detach() {
|
|
1690
|
+
return this.canvas.detach(), this;
|
|
1691
|
+
}
|
|
1692
|
+
addNode(e) {
|
|
1693
|
+
const t = this.nodeIdGenerator.create(e.id);
|
|
1694
|
+
return this.canvas.addNode({
|
|
1695
|
+
...e,
|
|
1696
|
+
id: t
|
|
1697
|
+
}), this.nodes.set(t, e.element), this.nodesResizeObserver.observe(e.element), this;
|
|
1698
|
+
}
|
|
1699
|
+
updateNode(e, t) {
|
|
1700
|
+
return this.canvas.updateNode(e, t), this;
|
|
1701
|
+
}
|
|
1702
|
+
removeNode(e) {
|
|
1703
|
+
this.canvas.removeNode(e);
|
|
1704
|
+
const t = this.nodes.getByKey(e);
|
|
1705
|
+
return this.nodes.deleteByKey(e), this.nodesResizeObserver.unobserve(t), this;
|
|
1706
|
+
}
|
|
1707
|
+
markPort(e) {
|
|
1708
|
+
return this.canvas.markPort(e), this;
|
|
1709
|
+
}
|
|
1710
|
+
updatePortMark(e, t) {
|
|
1711
|
+
return this.canvas.updatePortMark(e, t), this;
|
|
1712
|
+
}
|
|
1713
|
+
unmarkPort(e) {
|
|
1714
|
+
return this.canvas.unmarkPort(e), this;
|
|
1715
|
+
}
|
|
1716
|
+
addEdge(e) {
|
|
1717
|
+
return this.canvas.addEdge(e), this;
|
|
1718
|
+
}
|
|
1719
|
+
updateEdge(e, t) {
|
|
1720
|
+
return this.canvas.updateEdge(e, t), this;
|
|
1721
|
+
}
|
|
1722
|
+
removeEdge(e) {
|
|
1723
|
+
return this.canvas.removeEdge(e), this;
|
|
1724
|
+
}
|
|
1725
|
+
patchViewportMatrix(e) {
|
|
1726
|
+
return this.canvas.patchViewportMatrix(e), this;
|
|
1727
|
+
}
|
|
1728
|
+
patchContentMatrix(e) {
|
|
1729
|
+
return this.canvas.patchContentMatrix(e), this;
|
|
1730
|
+
}
|
|
1731
|
+
clear() {
|
|
1732
|
+
return this.canvas.clear(), this.nodesResizeObserver.disconnect(), this.nodes.clear(), this;
|
|
1733
|
+
}
|
|
1734
|
+
destroy() {
|
|
1735
|
+
this.clear(), this.canvas.destroy();
|
|
1736
|
+
}
|
|
1737
|
+
reactNodeChange(e) {
|
|
1738
|
+
const t = this.nodes.getByValue(e);
|
|
1739
|
+
this.canvas.updateNode(t), this.model.getNodeAdjacentEdgeIds(t).forEach((n) => {
|
|
1740
|
+
this.canvas.updateEdge(n);
|
|
1741
|
+
});
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
class Ie {
|
|
1701
1745
|
constructor() {
|
|
1702
1746
|
a(this, "coreOptions");
|
|
1703
1747
|
a(this, "dragOptions");
|
|
1704
1748
|
a(this, "transformOptions");
|
|
1705
1749
|
a(this, "isDraggable", !1);
|
|
1706
1750
|
a(this, "isTransformable", !1);
|
|
1751
|
+
a(this, "hasResizeReactiveNodes", !1);
|
|
1707
1752
|
}
|
|
1708
1753
|
setOptions(e) {
|
|
1709
1754
|
return this.coreOptions = e, this;
|
|
@@ -1714,28 +1759,32 @@ class Te {
|
|
|
1714
1759
|
setUserTransformableCanvas(e) {
|
|
1715
1760
|
return this.isTransformable = !0, this.transformOptions = e, this;
|
|
1716
1761
|
}
|
|
1762
|
+
setResizableReactiveNodes() {
|
|
1763
|
+
return this.hasResizeReactiveNodes = !0, this;
|
|
1764
|
+
}
|
|
1717
1765
|
build() {
|
|
1718
1766
|
let e = new xe(this.coreOptions);
|
|
1719
|
-
return this.isDraggable && (e = new
|
|
1767
|
+
return this.hasResizeReactiveNodes && (e = new Le(e)), this.isDraggable && (e = new fe(e, this.dragOptions)), this.isTransformable && (e = new Ne(e, this.transformOptions)), e;
|
|
1720
1768
|
}
|
|
1721
1769
|
}
|
|
1722
1770
|
export {
|
|
1723
|
-
|
|
1771
|
+
O as BezierEdgeShape,
|
|
1724
1772
|
xe as CanvasCore,
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1773
|
+
re as CycleCircleEdgeShape,
|
|
1774
|
+
X as CycleSquareEdgeShape,
|
|
1775
|
+
se as DetourBezierEdgeShape,
|
|
1728
1776
|
G as DetourStraightEdgeShape,
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1777
|
+
C as EdgeType,
|
|
1778
|
+
ee as HorizontalEdgeShape,
|
|
1779
|
+
Ie as HtmlGraphBuilder,
|
|
1780
|
+
A as HtmlGraphError,
|
|
1781
|
+
Le as ResizeReactiveNodesCanvas,
|
|
1782
|
+
q as StraightEdgeShape,
|
|
1783
|
+
fe as UserDraggableNodesCanvas,
|
|
1735
1784
|
Ne as UserTransformableCanvas,
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1785
|
+
te as VerticalEdgeShape,
|
|
1786
|
+
oe as createBezierEdgeShapeFactory,
|
|
1787
|
+
ae as createHorizontalEdgeShapeFactory,
|
|
1788
|
+
ne as createStraightEdgeShareFactory,
|
|
1789
|
+
ie as createVerticalEdgeShapeFactory
|
|
1741
1790
|
};
|