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