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