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