@html-graph/html-graph 0.0.49 → 0.0.51
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 +4 -4
- package/dist/main.d.ts +55 -35
- package/dist/main.js +615 -505
- package/dist/main.umd.cjs +1 -1
- package/package.json +8 -2
package/dist/main.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var n = (
|
|
4
|
-
class
|
|
5
|
-
constructor(t, e, s,
|
|
1
|
+
var W = Object.defineProperty;
|
|
2
|
+
var j = (r, t, e) => t in r ? W(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
|
|
3
|
+
var n = (r, t, e) => j(r, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
class R {
|
|
5
|
+
constructor(t, e, s, o, i) {
|
|
6
6
|
n(this, "canvasWrapper", null);
|
|
7
7
|
n(this, "host");
|
|
8
8
|
n(this, "nodesContainer");
|
|
9
|
-
n(this, "
|
|
9
|
+
n(this, "edgesContainer");
|
|
10
10
|
n(this, "canvas");
|
|
11
11
|
n(this, "canvasCtx");
|
|
12
12
|
n(this, "hostResizeObserver");
|
|
@@ -14,15 +14,15 @@ class k {
|
|
|
14
14
|
n(this, "nodeElementToIdMap", /* @__PURE__ */ new Map());
|
|
15
15
|
n(this, "nodeWrapperElementToIdMap", /* @__PURE__ */ new Map());
|
|
16
16
|
n(this, "nodeIdToWrapperElementMap", /* @__PURE__ */ new Map());
|
|
17
|
-
n(this, "
|
|
17
|
+
n(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
|
|
18
18
|
n(this, "currentZIndex", 0);
|
|
19
19
|
n(this, "layers", {
|
|
20
20
|
"edges-on-top": {
|
|
21
21
|
create: () => {
|
|
22
|
-
this.host.appendChild(this.nodesContainer), this.host.appendChild(this.
|
|
22
|
+
this.host.appendChild(this.nodesContainer), this.host.appendChild(this.edgesContainer);
|
|
23
23
|
},
|
|
24
24
|
update: (t, e, s) => {
|
|
25
|
-
this.nodesContainer.style.transform = `matrix(${t}, 0, 0, ${t}, ${e}, ${s})`, this.
|
|
25
|
+
this.nodesContainer.style.transform = `matrix(${t}, 0, 0, ${t}, ${e}, ${s})`, this.edgesContainer.style.transform = `matrix(${t}, 0, 0, ${t}, ${e}, ${s})`;
|
|
26
26
|
},
|
|
27
27
|
moveOnTop: (t) => {
|
|
28
28
|
this.currentZIndex += 1;
|
|
@@ -32,24 +32,24 @@ class k {
|
|
|
32
32
|
},
|
|
33
33
|
"edges-follow-node": {
|
|
34
34
|
create: () => {
|
|
35
|
-
this.host.appendChild(this.nodesContainer), this.
|
|
35
|
+
this.host.appendChild(this.nodesContainer), this.edgesContainer = this.nodesContainer;
|
|
36
36
|
},
|
|
37
37
|
update: (t, e, s) => {
|
|
38
38
|
this.nodesContainer.style.transform = `matrix(${t}, 0, 0, ${t}, ${e}, ${s})`;
|
|
39
39
|
},
|
|
40
40
|
moveOnTop: (t) => {
|
|
41
41
|
const e = this.nodeIdToWrapperElementMap.get(t);
|
|
42
|
-
this.currentZIndex += 2, e.style.zIndex = `${this.currentZIndex}`, this.graphStore.
|
|
43
|
-
this.
|
|
42
|
+
this.currentZIndex += 2, e.style.zIndex = `${this.currentZIndex}`, this.graphStore.getNodeAdjacentEdges(t).forEach((o) => {
|
|
43
|
+
this.edgeIdToElementMap.get(o).style.zIndex = `${this.currentZIndex - 1}`;
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
47
|
"nodes-on-top": {
|
|
48
48
|
create: () => {
|
|
49
|
-
this.host.appendChild(this.
|
|
49
|
+
this.host.appendChild(this.edgesContainer), this.host.appendChild(this.nodesContainer);
|
|
50
50
|
},
|
|
51
51
|
update: (t, e, s) => {
|
|
52
|
-
this.nodesContainer.style.transform = `matrix(${t}, 0, 0, ${t}, ${e}, ${s})`, this.
|
|
52
|
+
this.nodesContainer.style.transform = `matrix(${t}, 0, 0, ${t}, ${e}, ${s})`, this.edgesContainer.style.transform = `matrix(${t}, 0, 0, ${t}, ${e}, ${s})`;
|
|
53
53
|
},
|
|
54
54
|
moveOnTop: (t) => {
|
|
55
55
|
this.currentZIndex += 1;
|
|
@@ -58,15 +58,15 @@ class k {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
});
|
|
61
|
-
this.graphStore = t, this.viewportTransformer = e, this.publicViewportTransformer = s, this.layersMode =
|
|
62
|
-
const
|
|
63
|
-
if (
|
|
61
|
+
this.graphStore = t, this.viewportTransformer = e, this.publicViewportTransformer = s, this.layersMode = o, this.backgroundDrawingFn = i, this.host = this.createHost(), this.canvas = this.createCanvas(), this.nodesContainer = this.createNodesContainer(), this.edgesContainer = this.createEdgesContainer();
|
|
62
|
+
const h = this.canvas.getContext("2d");
|
|
63
|
+
if (h === null)
|
|
64
64
|
throw new Error("unable to get canvas context");
|
|
65
|
-
this.canvasCtx =
|
|
65
|
+
this.canvasCtx = h, this.host.appendChild(this.canvas), this.layers[this.layersMode].create(), this.hostResizeObserver = this.createHostResizeObserver(), this.hostResizeObserver.observe(this.host), this.nodesResizeObserver = this.createNodesResizeObserver();
|
|
66
66
|
}
|
|
67
67
|
clear() {
|
|
68
|
-
Array.from(this.
|
|
69
|
-
this.
|
|
68
|
+
Array.from(this.edgeIdToElementMap.keys()).forEach((t) => {
|
|
69
|
+
this.detachEdge(t);
|
|
70
70
|
}), Array.from(this.nodeElementToIdMap.values()).forEach((t) => {
|
|
71
71
|
this.detachNode(t);
|
|
72
72
|
});
|
|
@@ -78,7 +78,7 @@ class k {
|
|
|
78
78
|
this.canvasWrapper !== null && (this.canvasWrapper.removeChild(this.host), this.canvasWrapper = null);
|
|
79
79
|
}
|
|
80
80
|
destroy() {
|
|
81
|
-
this.hostResizeObserver.disconnect(), this.nodesResizeObserver.disconnect(), this.host.removeChild(this.canvas), this.host.removeChild(this.
|
|
81
|
+
this.hostResizeObserver.disconnect(), this.nodesResizeObserver.disconnect(), this.host.removeChild(this.canvas), this.host.removeChild(this.edgesContainer), this.host.removeChild(this.nodesContainer), this.canvasWrapper !== null && (this.canvasWrapper.removeChild(this.host), this.canvasWrapper = null);
|
|
82
82
|
}
|
|
83
83
|
applyTransform() {
|
|
84
84
|
this.backgroundDrawingFn(this.canvasCtx, this.publicViewportTransformer);
|
|
@@ -95,26 +95,26 @@ class k {
|
|
|
95
95
|
const s = this.nodeIdToWrapperElementMap.get(t);
|
|
96
96
|
s.removeChild(e.element), this.nodeElementToIdMap.delete(e.element), this.nodeWrapperElementToIdMap.delete(s), this.nodeIdToWrapperElementMap.delete(t);
|
|
97
97
|
}
|
|
98
|
-
|
|
99
|
-
const s = this.graphStore.
|
|
100
|
-
s.style.transformOrigin = "50% 50%", s.style.position = "absolute", s.style.top = "0", s.style.left = "0", s.style.zIndex = `${this.currentZIndex}`, this.currentZIndex += 1, this.
|
|
98
|
+
attachEdge(t) {
|
|
99
|
+
const s = this.graphStore.getEdge(t).controller.svg;
|
|
100
|
+
s.style.transformOrigin = "50% 50%", s.style.position = "absolute", s.style.top = "0", s.style.left = "0", s.style.zIndex = `${this.currentZIndex}`, this.currentZIndex += 1, this.edgeIdToElementMap.set(t, s), this.updateEdgeCoords(t), this.edgesContainer.appendChild(s);
|
|
101
101
|
}
|
|
102
|
-
|
|
103
|
-
const e = this.
|
|
104
|
-
this.
|
|
102
|
+
detachEdge(t) {
|
|
103
|
+
const e = this.edgeIdToElementMap.get(t);
|
|
104
|
+
this.edgeIdToElementMap.delete(t), this.edgesContainer.removeChild(e);
|
|
105
105
|
}
|
|
106
106
|
moveNodeOnTop(t) {
|
|
107
107
|
this.layers[this.layersMode].moveOnTop(t);
|
|
108
108
|
}
|
|
109
109
|
updateNodeCoordinates(t) {
|
|
110
|
-
const e = this.graphStore.getNode(t), s = this.graphStore.
|
|
111
|
-
this.updateNodeCoords(t, e.x, e.y), s.forEach((
|
|
112
|
-
this.
|
|
110
|
+
const e = this.graphStore.getNode(t), s = this.graphStore.getNodeAdjacentEdges(t);
|
|
111
|
+
this.updateNodeCoords(t, e.x, e.y), s.forEach((o) => {
|
|
112
|
+
this.updateEdgeCoords(o);
|
|
113
113
|
});
|
|
114
114
|
}
|
|
115
|
-
|
|
116
|
-
this.graphStore.
|
|
117
|
-
this.
|
|
115
|
+
updatePortEdges(t) {
|
|
116
|
+
this.graphStore.getPortAdjacentEdges(t).forEach((s) => {
|
|
117
|
+
this.updateEdgeCoords(s);
|
|
118
118
|
});
|
|
119
119
|
}
|
|
120
120
|
getViewportDimensions() {
|
|
@@ -133,7 +133,7 @@ class k {
|
|
|
133
133
|
const t = document.createElement("div");
|
|
134
134
|
return t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.width = "0", t.style.height = "0", t;
|
|
135
135
|
}
|
|
136
|
-
|
|
136
|
+
createEdgesContainer() {
|
|
137
137
|
const t = document.createElement("div");
|
|
138
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
139
|
}
|
|
@@ -145,9 +145,9 @@ class k {
|
|
|
145
145
|
createNodesResizeObserver() {
|
|
146
146
|
return new ResizeObserver((t) => {
|
|
147
147
|
t.forEach((e) => {
|
|
148
|
-
const s = e.target,
|
|
149
|
-
this.updateNodeCoords(
|
|
150
|
-
this.
|
|
148
|
+
const s = e.target, o = this.nodeWrapperElementToIdMap.get(s), i = this.graphStore.getNode(o);
|
|
149
|
+
this.updateNodeCoords(o, i.x, i.y), this.graphStore.getNodeAdjacentEdges(o).forEach((a) => {
|
|
150
|
+
this.updateEdgeCoords(a);
|
|
151
151
|
});
|
|
152
152
|
});
|
|
153
153
|
});
|
|
@@ -157,27 +157,27 @@ class k {
|
|
|
157
157
|
this.canvas.width = t, this.canvas.height = e;
|
|
158
158
|
}
|
|
159
159
|
updateNodeCoords(t, e, s) {
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
const e = this.graphStore.
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
), [
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
),
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
), [
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
),
|
|
177
|
-
e.controller.update(
|
|
160
|
+
const o = this.nodeIdToWrapperElementMap.get(t), { width: i, height: h } = o.getBoundingClientRect(), a = this.viewportTransformer.getAbsScale(), c = this.graphStore.getNode(t), [l, d] = c.centerFn(i, h);
|
|
161
|
+
o.style.transform = `matrix(1, 0, 0, 1, ${e - a * l}, ${s - a * d})`;
|
|
162
|
+
}
|
|
163
|
+
updateEdgeCoords(t) {
|
|
164
|
+
const e = this.graphStore.getEdge(t), s = this.graphStore.getPort(e.from), o = this.graphStore.getPort(e.to), i = s.element.getBoundingClientRect(), h = o.element.getBoundingClientRect(), a = this.host.getBoundingClientRect(), [c, l] = this.viewportTransformer.getAbsCoords(
|
|
165
|
+
i.left - a.left,
|
|
166
|
+
i.top - a.top
|
|
167
|
+
), [d, u] = this.viewportTransformer.getAbsCoords(
|
|
168
|
+
h.left - a.left,
|
|
169
|
+
h.top - a.top
|
|
170
|
+
), g = this.viewportTransformer.getAbsScale(), [w, m] = s.centerFn(
|
|
171
|
+
i.width * g,
|
|
172
|
+
i.height * g
|
|
173
|
+
), [f, p] = o.centerFn(
|
|
174
|
+
h.width * g,
|
|
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);
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
|
-
class
|
|
180
|
+
class B {
|
|
181
181
|
constructor() {
|
|
182
182
|
n(this, "state", {
|
|
183
183
|
scale: 1,
|
|
@@ -211,7 +211,7 @@ class W {
|
|
|
211
211
|
};
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
|
-
class
|
|
214
|
+
class Y {
|
|
215
215
|
constructor(t) {
|
|
216
216
|
this.transformer = t;
|
|
217
217
|
}
|
|
@@ -244,22 +244,19 @@ class j {
|
|
|
244
244
|
return this.transformer.getAbsScale();
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
|
-
class
|
|
247
|
+
class X {
|
|
248
248
|
constructor() {
|
|
249
249
|
n(this, "nodes", /* @__PURE__ */ Object.create(null));
|
|
250
250
|
n(this, "ports", /* @__PURE__ */ Object.create(null));
|
|
251
251
|
n(this, "nodePorts", /* @__PURE__ */ Object.create(null));
|
|
252
252
|
n(this, "portNodeId", /* @__PURE__ */ Object.create(null));
|
|
253
|
-
n(this, "
|
|
254
|
-
n(this, "
|
|
255
|
-
n(this, "
|
|
256
|
-
n(this, "
|
|
257
|
-
}
|
|
258
|
-
getAllNodes() {
|
|
259
|
-
return this.nodes;
|
|
253
|
+
n(this, "edges", /* @__PURE__ */ Object.create(null));
|
|
254
|
+
n(this, "incommingEdges", /* @__PURE__ */ Object.create(null));
|
|
255
|
+
n(this, "outcommingEdges", /* @__PURE__ */ Object.create(null));
|
|
256
|
+
n(this, "cycleEdges", /* @__PURE__ */ Object.create(null));
|
|
260
257
|
}
|
|
261
|
-
addNode(t, e, s,
|
|
262
|
-
this.nodes[t] = { element: e, x: s, y:
|
|
258
|
+
addNode(t, e, s, o, i) {
|
|
259
|
+
this.nodes[t] = { element: e, x: s, y: o, centerFn: i }, this.nodePorts[t] = /* @__PURE__ */ Object.create(null);
|
|
263
260
|
}
|
|
264
261
|
hasNode(t) {
|
|
265
262
|
return this.nodes[t] !== void 0;
|
|
@@ -270,22 +267,22 @@ class R {
|
|
|
270
267
|
updateNodeCoords(t, e, s) {
|
|
271
268
|
this.nodes[t].x = e, this.nodes[t].y = s;
|
|
272
269
|
}
|
|
273
|
-
|
|
274
|
-
this.
|
|
270
|
+
updateEdgeController(t, e) {
|
|
271
|
+
this.edges[t].controller = e;
|
|
275
272
|
}
|
|
276
273
|
removeNode(t) {
|
|
277
|
-
this.
|
|
278
|
-
this.
|
|
274
|
+
this.getNodeAdjacentEdges(t).forEach((o) => {
|
|
275
|
+
this.removeEdge(o);
|
|
279
276
|
}), delete this.nodes[t];
|
|
280
277
|
const s = this.nodePorts[t];
|
|
281
|
-
Object.keys(s).forEach((
|
|
282
|
-
delete this.portNodeId[
|
|
278
|
+
Object.keys(s).forEach((o) => {
|
|
279
|
+
delete this.portNodeId[o];
|
|
283
280
|
}), delete this.nodePorts[t];
|
|
284
281
|
}
|
|
285
|
-
addPort(t, e, s,
|
|
286
|
-
this.ports[t] = { element: e, centerFn:
|
|
287
|
-
const
|
|
288
|
-
|
|
282
|
+
addPort(t, e, s, o, i) {
|
|
283
|
+
this.ports[t] = { element: e, centerFn: o, direction: i }, this.cycleEdges[t] = {}, this.incommingEdges[t] = {}, this.outcommingEdges[t] = {}, this.portNodeId[t] = s;
|
|
284
|
+
const h = this.nodePorts[s];
|
|
285
|
+
h !== void 0 && (h[t] = e);
|
|
289
286
|
}
|
|
290
287
|
getPort(t) {
|
|
291
288
|
return this.ports[t];
|
|
@@ -297,363 +294,465 @@ class R {
|
|
|
297
294
|
return this.portNodeId[t] !== void 0;
|
|
298
295
|
}
|
|
299
296
|
removePort(t) {
|
|
300
|
-
Object.keys(this.
|
|
301
|
-
this.
|
|
302
|
-
}), delete this.
|
|
303
|
-
this.
|
|
304
|
-
}), delete this.
|
|
305
|
-
this.
|
|
306
|
-
}), delete this.
|
|
297
|
+
Object.keys(this.cycleEdges[t]).forEach((o) => {
|
|
298
|
+
this.removeEdge(o);
|
|
299
|
+
}), delete this.cycleEdges[t], Object.keys(this.incommingEdges[t]).forEach((o) => {
|
|
300
|
+
this.removeEdge(o);
|
|
301
|
+
}), delete this.incommingEdges[t], Object.keys(this.outcommingEdges[t]).forEach((o) => {
|
|
302
|
+
this.removeEdge(o);
|
|
303
|
+
}), delete this.outcommingEdges[t];
|
|
307
304
|
const e = this.portNodeId[t];
|
|
308
305
|
delete this.portNodeId[t];
|
|
309
306
|
const s = this.nodePorts[e];
|
|
310
307
|
delete s[t], delete this.ports[t];
|
|
311
308
|
}
|
|
312
|
-
|
|
313
|
-
this.
|
|
309
|
+
addEdge(t, e, s, o) {
|
|
310
|
+
this.edges[t] = {
|
|
314
311
|
from: e,
|
|
315
312
|
to: s,
|
|
316
|
-
controller:
|
|
317
|
-
}, e !== s ? (this.
|
|
313
|
+
controller: o
|
|
314
|
+
}, e !== s ? (this.outcommingEdges[e][t] = !0, this.incommingEdges[s][t] = !0) : this.cycleEdges[e][t] = !0;
|
|
318
315
|
}
|
|
319
|
-
|
|
320
|
-
return this.
|
|
316
|
+
getEdge(t) {
|
|
317
|
+
return this.edges[t];
|
|
321
318
|
}
|
|
322
|
-
|
|
323
|
-
return this.
|
|
319
|
+
hasEdge(t) {
|
|
320
|
+
return this.edges[t] !== void 0;
|
|
324
321
|
}
|
|
325
|
-
|
|
326
|
-
const e = this.
|
|
327
|
-
delete this.
|
|
322
|
+
removeEdge(t) {
|
|
323
|
+
const e = this.edges[t], s = e.from, o = e.to;
|
|
324
|
+
delete this.cycleEdges[s][t], delete this.cycleEdges[o][t], delete this.incommingEdges[s][t], delete this.incommingEdges[o][t], delete this.outcommingEdges[s][t], delete this.outcommingEdges[o][t], delete this.edges[t];
|
|
328
325
|
}
|
|
329
|
-
|
|
326
|
+
getPortAdjacentEdges(t) {
|
|
330
327
|
return [
|
|
331
|
-
...this.
|
|
332
|
-
...this.
|
|
333
|
-
...this.
|
|
328
|
+
...this.getPortIncomingEdges(t),
|
|
329
|
+
...this.getPortOutcomingEdges(t),
|
|
330
|
+
...this.getPortCycleEdges(t)
|
|
334
331
|
];
|
|
335
332
|
}
|
|
336
|
-
|
|
333
|
+
getNodeAdjacentEdges(t) {
|
|
337
334
|
return [
|
|
338
|
-
...this.
|
|
339
|
-
...this.
|
|
340
|
-
...this.
|
|
335
|
+
...this.getNodeIncomingEdges(t),
|
|
336
|
+
...this.getNodeOutcomingEdges(t),
|
|
337
|
+
...this.getNodeCycleEdges(t)
|
|
341
338
|
];
|
|
342
339
|
}
|
|
343
340
|
clear() {
|
|
344
|
-
this.nodes = /* @__PURE__ */ Object.create(null), this.ports = /* @__PURE__ */ Object.create(null), this.nodePorts = /* @__PURE__ */ Object.create(null), this.portNodeId = /* @__PURE__ */ Object.create(null), this.
|
|
341
|
+
this.nodes = /* @__PURE__ */ Object.create(null), this.ports = /* @__PURE__ */ Object.create(null), this.nodePorts = /* @__PURE__ */ Object.create(null), this.portNodeId = /* @__PURE__ */ Object.create(null), this.edges = /* @__PURE__ */ Object.create(null), this.incommingEdges = /* @__PURE__ */ Object.create(null), this.outcommingEdges = /* @__PURE__ */ Object.create(null), this.cycleEdges = /* @__PURE__ */ Object.create(null);
|
|
345
342
|
}
|
|
346
|
-
|
|
347
|
-
return Object.keys(this.
|
|
343
|
+
getPortIncomingEdges(t) {
|
|
344
|
+
return Object.keys(this.incommingEdges[t] ?? {});
|
|
348
345
|
}
|
|
349
|
-
|
|
350
|
-
return Object.keys(this.
|
|
346
|
+
getPortOutcomingEdges(t) {
|
|
347
|
+
return Object.keys(this.outcommingEdges[t] ?? {});
|
|
351
348
|
}
|
|
352
|
-
|
|
353
|
-
return Object.keys(this.
|
|
349
|
+
getPortCycleEdges(t) {
|
|
350
|
+
return Object.keys(this.cycleEdges[t] ?? {});
|
|
354
351
|
}
|
|
355
|
-
|
|
352
|
+
getNodeIncomingEdges(t) {
|
|
356
353
|
const e = Object.keys(this.nodePorts[t]);
|
|
357
354
|
let s = [];
|
|
358
|
-
return e.forEach((
|
|
359
|
-
s = [...s, ...this.
|
|
355
|
+
return e.forEach((o) => {
|
|
356
|
+
s = [...s, ...this.getPortIncomingEdges(o)];
|
|
360
357
|
}), s;
|
|
361
358
|
}
|
|
362
|
-
|
|
359
|
+
getNodeOutcomingEdges(t) {
|
|
363
360
|
const e = Object.keys(this.nodePorts[t]);
|
|
364
361
|
let s = [];
|
|
365
|
-
return e.forEach((
|
|
366
|
-
s = [...s, ...this.
|
|
362
|
+
return e.forEach((o) => {
|
|
363
|
+
s = [...s, ...this.getPortOutcomingEdges(o)];
|
|
367
364
|
}), s;
|
|
368
365
|
}
|
|
369
|
-
|
|
366
|
+
getNodeCycleEdges(t) {
|
|
370
367
|
const e = Object.keys(this.nodePorts[t]);
|
|
371
368
|
let s = [];
|
|
372
|
-
return e.forEach((
|
|
373
|
-
s = [...s, ...this.
|
|
369
|
+
return e.forEach((o) => {
|
|
370
|
+
s = [...s, ...this.getPortCycleEdges(o)];
|
|
374
371
|
}), s;
|
|
375
372
|
}
|
|
376
373
|
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
]
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
[0, 0],
|
|
394
|
-
[r, a],
|
|
395
|
-
[r, -a]
|
|
396
|
-
].map((l) => this.rotate(l, t, [0, 0])).map((l) => [l[0] + e, l[1] + s]), i = `M ${h[0][0]} ${h[0][1]}`, d = `L ${h[1][0]} ${h[1][1]}`, g = `L ${h[2][0]} ${h[2][1]}`;
|
|
397
|
-
return `${i} ${d} ${g}`;
|
|
398
|
-
}
|
|
399
|
-
static getArrowOffsetPath(t, e, s, r, a) {
|
|
400
|
-
const h = [
|
|
401
|
-
[r, 0],
|
|
402
|
-
[r + a, 0]
|
|
403
|
-
].map((i) => this.rotate(i, t, [0, 0])).map((i) => [i[0] + e, i[1] + s]);
|
|
404
|
-
return `M ${h[0][0]} ${h[0][1]} L ${h[1][0]} ${h[1][1]}`;
|
|
405
|
-
}
|
|
406
|
-
static createStraightPath(t) {
|
|
407
|
-
return t.map((e, s) => `${s === 0 ? "M" : "L"} ${e[0]} ${e[1]}`).join(" ");
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
class B {
|
|
411
|
-
constructor(t, e, s, r, a, c, h) {
|
|
374
|
+
const $ = (r) => {
|
|
375
|
+
const { top: t, left: e, width: s, height: o } = r.element.getBoundingClientRect(), i = r.centerFn(s, o);
|
|
376
|
+
return [e + i[0], t + i[1]];
|
|
377
|
+
}, b = (r, t, e) => [
|
|
378
|
+
t[0] * r[0] - t[1] * r[1] + ((1 - t[0]) * e[0] + t[1] * e[1]),
|
|
379
|
+
t[1] * r[0] + t[0] * r[1] + ((1 - t[0]) * e[1] - t[1] * e[0])
|
|
380
|
+
], N = (r, t, e) => [t * Math.cos(r), e * Math.sin(r)], S = (r, t, e, s, o) => {
|
|
381
|
+
const h = [
|
|
382
|
+
[0, 0],
|
|
383
|
+
[s, o],
|
|
384
|
+
[s, -o]
|
|
385
|
+
].map((d) => b(d, r, [0, 0])).map((d) => [d[0] + t, d[1] + e]), a = `M ${h[0][0]} ${h[0][1]}`, c = `L ${h[1][0]} ${h[1][1]}`, l = `L ${h[2][0]} ${h[2][1]}`;
|
|
386
|
+
return `${a} ${c} ${l}`;
|
|
387
|
+
};
|
|
388
|
+
class z {
|
|
389
|
+
constructor(t, e, s, o, i, h, a) {
|
|
412
390
|
n(this, "svg");
|
|
413
391
|
n(this, "group");
|
|
414
392
|
n(this, "line");
|
|
415
393
|
n(this, "sourceArrow", null);
|
|
416
394
|
n(this, "targetArrow", null);
|
|
417
|
-
this.color = t, this.width = e, this.curvature = s, this.arrowLength =
|
|
395
|
+
this.color = t, this.width = e, 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%", h && (this.sourceArrow = document.createElementNS(
|
|
418
396
|
"http://www.w3.org/2000/svg",
|
|
419
397
|
"path"
|
|
420
|
-
), this.sourceArrow.setAttribute("fill", this.color), this.group.appendChild(this.sourceArrow)),
|
|
398
|
+
), this.sourceArrow.setAttribute("fill", this.color), this.group.appendChild(this.sourceArrow)), a && (this.targetArrow = document.createElementNS(
|
|
421
399
|
"http://www.w3.org/2000/svg",
|
|
422
400
|
"path"
|
|
423
401
|
), this.targetArrow.setAttribute("fill", this.color), this.group.appendChild(this.targetArrow)), this.svg.style.overflow = "visible";
|
|
424
402
|
}
|
|
425
|
-
update(t, e, s,
|
|
426
|
-
this.svg.style.width = `${s}px`, this.svg.style.height = `${
|
|
427
|
-
const
|
|
428
|
-
this.svg.style.transform = `translate(${t}px, ${e}px)`, this.group.style.transform = `scale(${
|
|
429
|
-
const
|
|
403
|
+
update(t, e, s, o, i, h) {
|
|
404
|
+
this.svg.style.width = `${s}px`, this.svg.style.height = `${o}px`;
|
|
405
|
+
const a = $(i), c = $(h), l = a[0] <= c[0] ? 1 : -1, d = a[1] <= c[1] ? 1 : -1;
|
|
406
|
+
this.svg.style.transform = `translate(${t}px, ${e}px)`, this.group.style.transform = `scale(${l}, ${d})`;
|
|
407
|
+
const u = N(i.direction, l, d), g = N(h.direction, l, d), w = b([this.arrowLength, 0], u, [0, 0]), m = b([s - this.arrowLength, o], g, [
|
|
430
408
|
s,
|
|
431
|
-
|
|
432
|
-
]),
|
|
433
|
-
w[0] +
|
|
434
|
-
w[1] +
|
|
435
|
-
],
|
|
436
|
-
m[0] -
|
|
437
|
-
m[1] -
|
|
438
|
-
],
|
|
439
|
-
if (this.line.setAttribute("d",
|
|
440
|
-
const
|
|
441
|
-
|
|
409
|
+
o
|
|
410
|
+
]), f = [
|
|
411
|
+
w[0] + u[0] * this.curvature,
|
|
412
|
+
w[1] + u[1] * this.curvature
|
|
413
|
+
], p = [
|
|
414
|
+
m[0] - g[0] * this.curvature,
|
|
415
|
+
m[1] - g[1] * this.curvature
|
|
416
|
+
], C = `M ${w[0]} ${w[1]} C ${f[0]} ${f[1]}, ${p[0]} ${p[1]}, ${m[0]} ${m[1]}`, v = this.sourceArrow ? "" : `M 0 0 L ${w[0]} ${w[1]} `, E = this.targetArrow ? "" : ` M ${m[0]} ${m[1]} L ${s} ${o}`, A = `${v}${C}${E}`;
|
|
417
|
+
if (this.line.setAttribute("d", A), this.sourceArrow) {
|
|
418
|
+
const y = S(
|
|
419
|
+
u,
|
|
442
420
|
0,
|
|
443
421
|
0,
|
|
444
422
|
this.arrowLength,
|
|
445
423
|
this.arrowWidth
|
|
446
424
|
);
|
|
447
|
-
this.sourceArrow.setAttribute("d",
|
|
425
|
+
this.sourceArrow.setAttribute("d", y);
|
|
448
426
|
}
|
|
449
427
|
if (this.targetArrow) {
|
|
450
|
-
const
|
|
451
|
-
|
|
428
|
+
const y = S(
|
|
429
|
+
g,
|
|
452
430
|
s,
|
|
453
|
-
|
|
431
|
+
o,
|
|
454
432
|
-this.arrowLength,
|
|
455
433
|
this.arrowWidth
|
|
456
434
|
);
|
|
457
|
-
this.targetArrow.setAttribute("d",
|
|
435
|
+
this.targetArrow.setAttribute("d", y);
|
|
458
436
|
}
|
|
459
437
|
}
|
|
460
438
|
}
|
|
461
|
-
|
|
462
|
-
|
|
439
|
+
const V = (r, t) => {
|
|
440
|
+
const e = [];
|
|
441
|
+
if (r.length > 0 && e.push(`M ${r[0][0]} ${r[0][1]}`), r.length === 2 && e.push(`L ${r[1][0]} ${r[1][1]}`), r.length > 2) {
|
|
442
|
+
const s = r.length - 1;
|
|
443
|
+
let o = 0, i = 0, h = 0;
|
|
444
|
+
r.forEach((a, c) => {
|
|
445
|
+
let l = 0, d = 0, u = 0;
|
|
446
|
+
const g = c > 0, w = c < s, m = g && w;
|
|
447
|
+
if (g && (l = -o, d = -i, u = h), w) {
|
|
448
|
+
const y = r[c + 1];
|
|
449
|
+
o = y[0] - a[0], i = y[1] - a[1], h = Math.sqrt(o * o + i * i);
|
|
450
|
+
}
|
|
451
|
+
const p = Math.min((m ? t : 0) / h, c < s - 1 ? 0.5 : 1), C = m ? [a[0] + o * p, a[1] + i * p] : a, E = Math.min((m ? t : 0) / u, c > 1 ? 0.5 : 1), A = m ? [a[0] + l * E, a[1] + d * E] : a;
|
|
452
|
+
c > 0 && e.push(`L ${A[0]} ${A[1]}`), m && e.push(
|
|
453
|
+
`C ${a[0]} ${a[1]} ${a[0]} ${a[1]} ${C[0]} ${C[1]}`
|
|
454
|
+
);
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
return e.join(" ");
|
|
458
|
+
};
|
|
459
|
+
class G {
|
|
460
|
+
constructor(t, e, s, o, i, h, a, c) {
|
|
463
461
|
n(this, "svg");
|
|
464
462
|
n(this, "group");
|
|
465
463
|
n(this, "line");
|
|
466
464
|
n(this, "sourceArrow", null);
|
|
467
465
|
n(this, "targetArrow", null);
|
|
468
|
-
|
|
469
|
-
this.color = t, this.width = e, this.arrowLength = s, this.arrowWidth = r, this.minPortOffset = a, this.roundness = Math.min(this.minPortOffset, 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%", c && (this.sourceArrow = document.createElementNS(
|
|
466
|
+
this.color = t, this.width = e, this.arrowLength = s, this.arrowWidth = o, this.arrowOffset = i, 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%", h && (this.sourceArrow = document.createElementNS(
|
|
470
467
|
"http://www.w3.org/2000/svg",
|
|
471
468
|
"path"
|
|
472
|
-
), this.sourceArrow.setAttribute("fill", this.color), this.group.appendChild(this.sourceArrow)),
|
|
469
|
+
), this.sourceArrow.setAttribute("fill", this.color), this.group.appendChild(this.sourceArrow)), a && (this.targetArrow = document.createElementNS(
|
|
473
470
|
"http://www.w3.org/2000/svg",
|
|
474
471
|
"path"
|
|
475
472
|
), this.targetArrow.setAttribute("fill", this.color), this.group.appendChild(this.targetArrow)), this.svg.style.overflow = "visible";
|
|
476
473
|
}
|
|
477
|
-
update(t, e, s,
|
|
478
|
-
this.svg.style.width = `${s}px`, this.svg.style.height = `${
|
|
479
|
-
const
|
|
480
|
-
this.svg.style.transform = `translate(${t}px, ${e}px)`, this.group.style.transform = `scale(${
|
|
481
|
-
const
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
[C, m[1]],
|
|
486
|
-
[C, p[1]],
|
|
487
|
-
[p[0], p[1]]
|
|
488
|
-
]) : v.createStraightPath([
|
|
489
|
-
[m[0], m[1]],
|
|
490
|
-
[m[0], f],
|
|
491
|
-
[p[0], f],
|
|
492
|
-
[p[0], p[1]]
|
|
493
|
-
]), E = v.getArrowOffsetPath(
|
|
494
|
-
l,
|
|
495
|
-
0,
|
|
496
|
-
0,
|
|
497
|
-
this.arrowLength,
|
|
498
|
-
this.minPortOffset
|
|
499
|
-
), $ = v.getArrowOffsetPath(
|
|
500
|
-
u,
|
|
474
|
+
update(t, e, s, o, i, h) {
|
|
475
|
+
this.svg.style.width = `${s}px`, this.svg.style.height = `${o}px`;
|
|
476
|
+
const a = $(i), c = $(h), l = a[0] <= c[0] ? 1 : -1, d = a[1] <= c[1] ? 1 : -1;
|
|
477
|
+
this.svg.style.transform = `translate(${t}px, ${e}px)`, this.group.style.transform = `scale(${l}, ${d})`;
|
|
478
|
+
const u = N(i.direction, l, d), g = N(h.direction, l, d), w = this.sourceArrow ? b([this.arrowLength, 0], u, [0, 0]) : [0, 0], m = this.targetArrow ? b([s - this.arrowLength, o], g, [
|
|
479
|
+
s,
|
|
480
|
+
o
|
|
481
|
+
]) : [s, o], f = this.arrowLength + this.arrowOffset, p = b([f, 0], u, [0, 0]), C = b([s - f, o], g, [
|
|
501
482
|
s,
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
const x = v.getArrowPath(
|
|
508
|
-
l,
|
|
483
|
+
o
|
|
484
|
+
]), v = V([w, p, C, m], this.roundness);
|
|
485
|
+
if (this.line.setAttribute("d", v), this.sourceArrow) {
|
|
486
|
+
const E = S(
|
|
487
|
+
u,
|
|
509
488
|
0,
|
|
510
489
|
0,
|
|
511
490
|
this.arrowLength,
|
|
512
491
|
this.arrowWidth
|
|
513
492
|
);
|
|
514
|
-
this.sourceArrow.setAttribute("d",
|
|
493
|
+
this.sourceArrow.setAttribute("d", E);
|
|
515
494
|
}
|
|
516
495
|
if (this.targetArrow) {
|
|
517
|
-
const
|
|
518
|
-
|
|
496
|
+
const E = S(
|
|
497
|
+
g,
|
|
519
498
|
s,
|
|
520
|
-
|
|
499
|
+
o,
|
|
521
500
|
-this.arrowLength,
|
|
522
501
|
this.arrowWidth
|
|
523
502
|
);
|
|
524
|
-
this.targetArrow.setAttribute("d",
|
|
503
|
+
this.targetArrow.setAttribute("d", E);
|
|
525
504
|
}
|
|
526
505
|
}
|
|
527
506
|
}
|
|
528
|
-
class
|
|
529
|
-
constructor(t, e, s,
|
|
507
|
+
class Z {
|
|
508
|
+
constructor(t, e, s, o, i, h, a) {
|
|
530
509
|
n(this, "svg");
|
|
531
510
|
n(this, "group");
|
|
532
511
|
n(this, "line");
|
|
533
512
|
n(this, "arrow", null);
|
|
534
|
-
this.color = t, this.width = e, this.arrowLength = s, this.arrowWidth =
|
|
513
|
+
this.color = t, this.width = e, this.arrowLength = s, this.arrowWidth = o, this.radius = h, 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%", i && (this.arrow = document.createElementNS(
|
|
535
514
|
"http://www.w3.org/2000/svg",
|
|
536
515
|
"path"
|
|
537
516
|
), 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";
|
|
538
517
|
}
|
|
539
|
-
update(t, e, s,
|
|
518
|
+
update(t, e, s, o, i) {
|
|
540
519
|
this.svg.style.transform = `translate(${t}px, ${e}px)`;
|
|
541
|
-
const
|
|
520
|
+
const h = N(i.direction, 1, 1), a = this.smallRadius, c = this.radius, l = Math.sqrt(a * a + c * c), d = a + c, u = this.arrowLength + l * (1 - c / d), g = a * c / d, m = [
|
|
542
521
|
[this.arrowLength, 0],
|
|
543
|
-
[
|
|
544
|
-
[
|
|
545
|
-
].map((
|
|
522
|
+
[u, g],
|
|
523
|
+
[u, -g]
|
|
524
|
+
].map((v) => b(v, h, [0, 0])), f = [
|
|
546
525
|
`M ${m[0][0]} ${m[0][1]}`,
|
|
547
|
-
`A ${
|
|
548
|
-
`A ${
|
|
549
|
-
`A ${
|
|
550
|
-
].join(" "),
|
|
551
|
-
if (this.line.setAttribute("d",
|
|
552
|
-
const
|
|
553
|
-
|
|
526
|
+
`A ${a} ${a} 0 0 1 ${m[1][0]} ${m[1][1]}`,
|
|
527
|
+
`A ${c} ${c} 0 1 0 ${m[2][0]} ${m[2][1]}`,
|
|
528
|
+
`A ${a} ${a} 0 0 1 ${m[0][0]} ${m[0][1]}`
|
|
529
|
+
].join(" "), p = `M 0 0 L ${m[0][0]} ${m[0][1]} `, C = `${this.arrow !== null ? "" : p}${f}`;
|
|
530
|
+
if (this.line.setAttribute("d", C), this.arrow) {
|
|
531
|
+
const v = S(
|
|
532
|
+
h,
|
|
554
533
|
0,
|
|
555
534
|
0,
|
|
556
535
|
this.arrowLength,
|
|
557
536
|
this.arrowWidth
|
|
558
537
|
);
|
|
559
|
-
this.arrow.setAttribute("d",
|
|
538
|
+
this.arrow.setAttribute("d", v);
|
|
560
539
|
}
|
|
561
540
|
}
|
|
562
541
|
}
|
|
563
|
-
class
|
|
564
|
-
constructor(t, e, s,
|
|
542
|
+
class U {
|
|
543
|
+
constructor(t, e, s, o, i, h, a, c) {
|
|
565
544
|
n(this, "svg");
|
|
566
545
|
n(this, "group");
|
|
567
546
|
n(this, "line");
|
|
568
547
|
n(this, "arrow", null);
|
|
569
548
|
n(this, "roundness");
|
|
570
|
-
n(this, "
|
|
571
|
-
this.color = t, this.width = e, this.arrowLength = s, this.arrowWidth =
|
|
549
|
+
n(this, "linePoints");
|
|
550
|
+
this.color = t, this.width = e, this.arrowLength = s, this.arrowWidth = o, this.side = h, 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%", i && (this.arrow = document.createElementNS(
|
|
572
551
|
"http://www.w3.org/2000/svg",
|
|
573
552
|
"path"
|
|
574
553
|
), 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";
|
|
575
|
-
const
|
|
576
|
-
console.log(
|
|
554
|
+
const l = this.minPortOffset, d = this.side, u = this.arrowLength + l, g = this.roundness, w = u + 2 * d;
|
|
555
|
+
console.log(g), this.linePoints = [
|
|
577
556
|
[this.arrowLength, 0],
|
|
578
|
-
[
|
|
579
|
-
[
|
|
580
|
-
[
|
|
581
|
-
[
|
|
582
|
-
[
|
|
583
|
-
[
|
|
584
|
-
[
|
|
585
|
-
[f, -g],
|
|
586
|
-
[m, -g],
|
|
587
|
-
[l, -p],
|
|
588
|
-
[l, -u]
|
|
557
|
+
[u, 0],
|
|
558
|
+
[u, this.side],
|
|
559
|
+
[w, this.side],
|
|
560
|
+
[w, -this.side],
|
|
561
|
+
[u, -this.side],
|
|
562
|
+
[u, 0],
|
|
563
|
+
[this.arrowLength, 0]
|
|
589
564
|
];
|
|
590
565
|
}
|
|
591
|
-
update(t, e, s,
|
|
566
|
+
update(t, e, s, o, i) {
|
|
592
567
|
this.svg.style.transform = `translate(${t}px, ${e}px)`;
|
|
593
|
-
const
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
`A ${h} ${h} 0 0 1 ${i[2][0]} ${i[2][1]}`,
|
|
597
|
-
`L ${i[3][0]} ${i[3][1]}`,
|
|
598
|
-
`A ${h} ${h} 0 0 0 ${i[4][0]} ${i[4][1]}`,
|
|
599
|
-
`L ${i[5][0]} ${i[5][1]}`,
|
|
600
|
-
`A ${h} ${h} 0 0 0 ${i[6][0]} ${i[6][1]}`,
|
|
601
|
-
`L ${i[7][0]} ${i[7][1]}`,
|
|
602
|
-
`A ${h} ${h} 0 0 0 ${i[8][0]} ${i[8][1]}`,
|
|
603
|
-
`L ${i[9][0]} ${i[9][1]}`,
|
|
604
|
-
`A ${h} ${h} 0 0 0 ${i[10][0]} ${i[10][1]}`,
|
|
605
|
-
`L ${i[11][0]} ${i[11][1]}`,
|
|
606
|
-
`A ${h} ${h} 0 0 1 ${i[1][0]} ${i[1][1]}`
|
|
607
|
-
].join(" "), g = `M 0 0 L ${i[0][0]} ${i[0][1]} `, l = `${this.arrow ? "" : g}${d}`;
|
|
568
|
+
const h = N(i.direction, 1, 1), a = this.linePoints.map(
|
|
569
|
+
(d) => b(d, h, [0, 0])
|
|
570
|
+
), c = `M 0 0 L ${a[0][0]} ${a[0][1]} `, l = `${this.arrow ? "" : c}${V(a, this.roundness)}`;
|
|
608
571
|
if (this.line.setAttribute("d", l), this.arrow) {
|
|
609
|
-
const
|
|
610
|
-
|
|
572
|
+
const d = S(
|
|
573
|
+
h,
|
|
574
|
+
0,
|
|
575
|
+
0,
|
|
576
|
+
this.arrowLength,
|
|
577
|
+
this.arrowWidth
|
|
578
|
+
);
|
|
579
|
+
this.arrow.setAttribute("d", d);
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
class H {
|
|
584
|
+
constructor(t, e, s, o, i, h, a, c, l, d) {
|
|
585
|
+
n(this, "svg");
|
|
586
|
+
n(this, "group");
|
|
587
|
+
n(this, "line");
|
|
588
|
+
n(this, "sourceArrow", null);
|
|
589
|
+
n(this, "targetArrow", null);
|
|
590
|
+
n(this, "detourX");
|
|
591
|
+
n(this, "detourY");
|
|
592
|
+
this.color = t, this.width = e, this.arrowLength = s, this.arrowWidth = o, this.arrowOffset = i, 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%", h && (this.sourceArrow = document.createElementNS(
|
|
593
|
+
"http://www.w3.org/2000/svg",
|
|
594
|
+
"path"
|
|
595
|
+
), this.sourceArrow.setAttribute("fill", this.color), this.group.appendChild(this.sourceArrow)), a && (this.targetArrow = document.createElementNS(
|
|
596
|
+
"http://www.w3.org/2000/svg",
|
|
597
|
+
"path"
|
|
598
|
+
), this.targetArrow.setAttribute("fill", this.color), this.group.appendChild(this.targetArrow)), this.svg.style.overflow = "visible";
|
|
599
|
+
}
|
|
600
|
+
update(t, e, s, o, i, h) {
|
|
601
|
+
this.svg.style.width = `${s}px`, this.svg.style.height = `${o}px`;
|
|
602
|
+
const a = $(i), c = $(h), l = a[0] <= c[0] ? 1 : -1, d = a[1] <= c[1] ? 1 : -1;
|
|
603
|
+
this.svg.style.transform = `translate(${t}px, ${e}px)`, this.group.style.transform = `scale(${l}, ${d})`;
|
|
604
|
+
const u = N(i.direction, l, d), g = N(h.direction, l, d), w = this.sourceArrow ? b([this.arrowLength, 0], u, [0, 0]) : [0, 0], m = this.targetArrow ? b([s - this.arrowLength, o], g, [
|
|
605
|
+
s,
|
|
606
|
+
o
|
|
607
|
+
]) : [s, o], f = this.arrowLength + this.arrowOffset, p = b([f, 0], u, [0, 0]), C = [p[0] + this.detourX, p[1] + this.detourY], v = b([s - f, o], g, [
|
|
608
|
+
s,
|
|
609
|
+
o
|
|
610
|
+
]), E = [v[0] + this.detourX, v[1] + this.detourY], A = V(
|
|
611
|
+
[w, p, C, E, v, m],
|
|
612
|
+
this.roundness
|
|
613
|
+
);
|
|
614
|
+
if (this.line.setAttribute("d", A), this.sourceArrow) {
|
|
615
|
+
const y = S(
|
|
616
|
+
u,
|
|
617
|
+
0,
|
|
618
|
+
0,
|
|
619
|
+
this.arrowLength,
|
|
620
|
+
this.arrowWidth
|
|
621
|
+
);
|
|
622
|
+
this.sourceArrow.setAttribute("d", y);
|
|
623
|
+
}
|
|
624
|
+
if (this.targetArrow) {
|
|
625
|
+
const y = S(
|
|
626
|
+
g,
|
|
627
|
+
s,
|
|
628
|
+
o,
|
|
629
|
+
-this.arrowLength,
|
|
630
|
+
this.arrowWidth
|
|
631
|
+
);
|
|
632
|
+
this.targetArrow.setAttribute("d", y);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
var T = /* @__PURE__ */ ((r) => (r.Regular = "regular", r.PortCycle = "port-cycle", r.NodeCycle = "node-cycle", r))(T || {});
|
|
637
|
+
class q {
|
|
638
|
+
constructor(t, e, s, o, i, h, a, c, l) {
|
|
639
|
+
n(this, "svg");
|
|
640
|
+
n(this, "group");
|
|
641
|
+
n(this, "line");
|
|
642
|
+
n(this, "sourceArrow", null);
|
|
643
|
+
n(this, "targetArrow", null);
|
|
644
|
+
n(this, "detourX");
|
|
645
|
+
n(this, "detourY");
|
|
646
|
+
this.color = t, this.width = e, this.curvature = s, this.arrowLength = o, this.arrowWidth = i, 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%", h && (this.sourceArrow = document.createElementNS(
|
|
647
|
+
"http://www.w3.org/2000/svg",
|
|
648
|
+
"path"
|
|
649
|
+
), this.sourceArrow.setAttribute("fill", this.color), this.group.appendChild(this.sourceArrow)), a && (this.targetArrow = document.createElementNS(
|
|
650
|
+
"http://www.w3.org/2000/svg",
|
|
651
|
+
"path"
|
|
652
|
+
), this.targetArrow.setAttribute("fill", this.color), this.group.appendChild(this.targetArrow)), this.svg.style.overflow = "visible";
|
|
653
|
+
}
|
|
654
|
+
update(t, e, s, o, i, h) {
|
|
655
|
+
this.svg.style.width = `${s}px`, this.svg.style.height = `${o}px`;
|
|
656
|
+
const a = $(i), c = $(h), l = a[0] <= c[0] ? 1 : -1, d = a[1] <= c[1] ? 1 : -1;
|
|
657
|
+
this.svg.style.transform = `translate(${t}px, ${e}px)`, this.group.style.transform = `scale(${l}, ${d})`;
|
|
658
|
+
const u = N(i.direction, l, d), g = N(h.direction, l, d), w = this.sourceArrow ? b([this.arrowLength, 0], u, [0, 0]) : [0, 0], m = this.targetArrow ? b([s - this.arrowLength, o], g, [
|
|
659
|
+
s,
|
|
660
|
+
o
|
|
661
|
+
]) : [s, o], f = this.arrowLength, p = b([f, 0], u, [0, 0]), C = [p[0] + this.detourX, p[1] + this.detourY], v = b([s - f, o], g, [
|
|
662
|
+
s,
|
|
663
|
+
o
|
|
664
|
+
]), E = [v[0] + this.detourX, v[1] + this.detourY], A = [(C[0] + E[0]) / 2, (C[1] + E[1]) / 2], y = [
|
|
665
|
+
p[0] - this.curvature * Math.cos(i.direction),
|
|
666
|
+
p[1] - this.curvature * Math.sin(i.direction)
|
|
667
|
+
], x = [
|
|
668
|
+
v[0] + this.curvature * Math.cos(h.direction),
|
|
669
|
+
v[1] + this.curvature * Math.sin(h.direction)
|
|
670
|
+
], P = [p[0] + this.detourX, p[1] + this.detourY], M = [v[0] + this.detourX, v[1] + this.detourY], k = [
|
|
671
|
+
`M ${w[0]} ${w[1]}`,
|
|
672
|
+
`L ${p[0]} ${p[1]}`,
|
|
673
|
+
`C ${y[0]} ${y[1]} ${P[0]} ${P[1]} ${A[0]} ${A[1]}`,
|
|
674
|
+
`C ${M[0]} ${M[1]} ${x[0]} ${x[1]} ${v[0]} ${v[1]}`,
|
|
675
|
+
`L ${m[0]} ${m[1]}`
|
|
676
|
+
].join(" ");
|
|
677
|
+
if (this.line.setAttribute("d", k), this.sourceArrow) {
|
|
678
|
+
const O = S(
|
|
679
|
+
u,
|
|
611
680
|
0,
|
|
612
681
|
0,
|
|
613
682
|
this.arrowLength,
|
|
614
683
|
this.arrowWidth
|
|
615
684
|
);
|
|
616
|
-
this.
|
|
685
|
+
this.sourceArrow.setAttribute("d", O);
|
|
686
|
+
}
|
|
687
|
+
if (this.targetArrow) {
|
|
688
|
+
const O = S(
|
|
689
|
+
g,
|
|
690
|
+
s,
|
|
691
|
+
o,
|
|
692
|
+
-this.arrowLength,
|
|
693
|
+
this.arrowWidth
|
|
694
|
+
);
|
|
695
|
+
this.targetArrow.setAttribute("d", O);
|
|
617
696
|
}
|
|
618
697
|
}
|
|
619
698
|
}
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
o.color,
|
|
639
|
-
o.width,
|
|
640
|
-
o.arrowLength,
|
|
641
|
-
o.arrowWidth,
|
|
642
|
-
o.hasSourceArrow || o.hasTargetArrow,
|
|
643
|
-
o.cycleSquareSide,
|
|
644
|
-
o.minPortOffset,
|
|
645
|
-
o.roundness
|
|
699
|
+
const _ = (r) => (t) => t === T.PortCycle ? new Z(
|
|
700
|
+
r.color,
|
|
701
|
+
r.width,
|
|
702
|
+
r.arrowLength,
|
|
703
|
+
r.arrowWidth,
|
|
704
|
+
r.hasSourceArrow || r.hasTargetArrow,
|
|
705
|
+
r.cycleRadius,
|
|
706
|
+
r.smallCycleRadius
|
|
707
|
+
) : t === T.NodeCycle ? new q(
|
|
708
|
+
r.color,
|
|
709
|
+
r.width,
|
|
710
|
+
r.curvature,
|
|
711
|
+
r.arrowLength,
|
|
712
|
+
r.arrowWidth,
|
|
713
|
+
r.hasSourceArrow,
|
|
714
|
+
r.hasTargetArrow,
|
|
715
|
+
r.detourDistance,
|
|
716
|
+
r.detourDirection
|
|
646
717
|
) : new z(
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
718
|
+
r.color,
|
|
719
|
+
r.width,
|
|
720
|
+
r.curvature,
|
|
721
|
+
r.arrowLength,
|
|
722
|
+
r.arrowWidth,
|
|
723
|
+
r.hasSourceArrow,
|
|
724
|
+
r.hasTargetArrow
|
|
725
|
+
), J = (r) => (t) => t === T.PortCycle ? new U(
|
|
726
|
+
r.color,
|
|
727
|
+
r.width,
|
|
728
|
+
r.arrowLength,
|
|
729
|
+
r.arrowWidth,
|
|
730
|
+
r.hasSourceArrow || r.hasTargetArrow,
|
|
731
|
+
r.cycleSquareSide,
|
|
732
|
+
r.arrowOffset,
|
|
733
|
+
r.roundness
|
|
734
|
+
) : t === T.NodeCycle ? new H(
|
|
735
|
+
r.color,
|
|
736
|
+
r.width,
|
|
737
|
+
r.arrowLength,
|
|
738
|
+
r.arrowWidth,
|
|
739
|
+
r.arrowOffset,
|
|
740
|
+
r.hasSourceArrow,
|
|
741
|
+
r.hasTargetArrow,
|
|
742
|
+
r.roundness,
|
|
743
|
+
r.detourDistance,
|
|
744
|
+
r.detourDirection
|
|
745
|
+
) : new G(
|
|
746
|
+
r.color,
|
|
747
|
+
r.width,
|
|
748
|
+
r.arrowLength,
|
|
749
|
+
r.arrowWidth,
|
|
750
|
+
r.arrowOffset,
|
|
751
|
+
r.hasSourceArrow,
|
|
752
|
+
r.hasTargetArrow,
|
|
753
|
+
r.roundness
|
|
655
754
|
);
|
|
656
|
-
class
|
|
755
|
+
class L {
|
|
657
756
|
constructor() {
|
|
658
757
|
n(this, "counter", 0);
|
|
659
758
|
}
|
|
@@ -665,19 +764,19 @@ class S {
|
|
|
665
764
|
this.counter = 0;
|
|
666
765
|
}
|
|
667
766
|
}
|
|
668
|
-
class
|
|
669
|
-
constructor(t, e, s,
|
|
670
|
-
n(this, "nodeIdGenerator", new
|
|
671
|
-
n(this, "portIdGenerator", new
|
|
672
|
-
n(this, "
|
|
673
|
-
this.graphStore = t, this.htmlController = e, this.viewportTransformer = s, this.nodesCenterFn =
|
|
767
|
+
class K {
|
|
768
|
+
constructor(t, e, s, o, i, h) {
|
|
769
|
+
n(this, "nodeIdGenerator", new L());
|
|
770
|
+
n(this, "portIdGenerator", new L());
|
|
771
|
+
n(this, "edgeIdGenerator", new L());
|
|
772
|
+
this.graphStore = t, this.htmlController = e, this.viewportTransformer = s, this.nodesCenterFn = o, this.portsCenterFn = i, this.portsDirection = h;
|
|
674
773
|
}
|
|
675
774
|
moveNodeOnTop(t) {
|
|
676
775
|
if (!this.graphStore.hasNode(t))
|
|
677
776
|
throw new Error("failed to move on top nonexisting node");
|
|
678
777
|
this.htmlController.moveNodeOnTop(t);
|
|
679
778
|
}
|
|
680
|
-
addNode(t, e, s,
|
|
779
|
+
addNode(t, e, s, o, i, h) {
|
|
681
780
|
if (t === void 0)
|
|
682
781
|
do
|
|
683
782
|
t = this.nodeIdGenerator.next();
|
|
@@ -688,19 +787,25 @@ class U {
|
|
|
688
787
|
t,
|
|
689
788
|
e,
|
|
690
789
|
s,
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
), this.htmlController.attachNode(t),
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
790
|
+
o,
|
|
791
|
+
h ?? this.nodesCenterFn
|
|
792
|
+
), this.htmlController.attachNode(t), i !== void 0 && Object.entries(i).forEach(([a, c]) => {
|
|
793
|
+
c instanceof HTMLElement ? this.markPort(
|
|
794
|
+
a,
|
|
795
|
+
c,
|
|
697
796
|
t,
|
|
698
|
-
|
|
699
|
-
|
|
797
|
+
this.portsCenterFn,
|
|
798
|
+
this.portsDirection
|
|
799
|
+
) : this.markPort(
|
|
800
|
+
a,
|
|
801
|
+
c.element,
|
|
802
|
+
t,
|
|
803
|
+
c.centerFn ?? this.portsCenterFn,
|
|
804
|
+
c.direction ?? this.portsDirection
|
|
700
805
|
);
|
|
701
806
|
});
|
|
702
807
|
}
|
|
703
|
-
markPort(t, e, s,
|
|
808
|
+
markPort(t, e, s, o, i) {
|
|
704
809
|
if (t === void 0)
|
|
705
810
|
do
|
|
706
811
|
t = this.portIdGenerator.next();
|
|
@@ -713,43 +818,44 @@ class U {
|
|
|
713
818
|
t,
|
|
714
819
|
e,
|
|
715
820
|
s,
|
|
716
|
-
|
|
717
|
-
|
|
821
|
+
o ?? this.portsCenterFn,
|
|
822
|
+
i ?? 0
|
|
718
823
|
);
|
|
719
824
|
}
|
|
720
|
-
|
|
825
|
+
updatePortEdges(t) {
|
|
721
826
|
if (!this.graphStore.hasPort(t))
|
|
722
827
|
throw new Error("failed to unset nonexisting port");
|
|
723
|
-
this.htmlController.
|
|
828
|
+
this.htmlController.updatePortEdges(t);
|
|
724
829
|
}
|
|
725
830
|
unmarkPort(t) {
|
|
726
831
|
if (!this.graphStore.hasPort(t))
|
|
727
832
|
throw new Error("failed to unset nonexisting port");
|
|
728
|
-
this.graphStore.
|
|
729
|
-
this.
|
|
833
|
+
this.graphStore.getPortAdjacentEdges(t).forEach((e) => {
|
|
834
|
+
this.removeEdge(e);
|
|
730
835
|
}), this.graphStore.removePort(t);
|
|
731
836
|
}
|
|
732
|
-
|
|
837
|
+
addEdge(t, e, s, o) {
|
|
733
838
|
if (t === void 0)
|
|
734
839
|
do
|
|
735
|
-
t = this.
|
|
736
|
-
while (this.graphStore.
|
|
840
|
+
t = this.edgeIdGenerator.next();
|
|
841
|
+
while (this.graphStore.hasEdge(t));
|
|
737
842
|
if (!this.graphStore.hasPort(e))
|
|
738
|
-
throw new Error("failed to add
|
|
843
|
+
throw new Error("failed to add edge from nonexisting port");
|
|
739
844
|
if (!this.graphStore.hasPort(s))
|
|
740
|
-
throw new Error("failed to add
|
|
741
|
-
let
|
|
742
|
-
|
|
845
|
+
throw new Error("failed to add edge to nonexisting port");
|
|
846
|
+
let i = T.Regular;
|
|
847
|
+
const h = this.graphStore.getPortNode(e), a = this.graphStore.getPortNode(s);
|
|
848
|
+
e === s ? i = T.PortCycle : h === a && (i = T.NodeCycle), this.graphStore.addEdge(
|
|
743
849
|
t,
|
|
744
850
|
e,
|
|
745
851
|
s,
|
|
746
|
-
|
|
747
|
-
), this.htmlController.
|
|
852
|
+
o(i)
|
|
853
|
+
), this.htmlController.attachEdge(t);
|
|
748
854
|
}
|
|
749
|
-
|
|
750
|
-
if (!this.graphStore.
|
|
751
|
-
throw new Error("failed to remove nonexisting
|
|
752
|
-
this.htmlController.
|
|
855
|
+
removeEdge(t) {
|
|
856
|
+
if (!this.graphStore.hasEdge(t))
|
|
857
|
+
throw new Error("failed to remove nonexisting edge");
|
|
858
|
+
this.htmlController.detachEdge(t), this.graphStore.removeEdge(t);
|
|
753
859
|
}
|
|
754
860
|
removeNode(t) {
|
|
755
861
|
if (!this.graphStore.hasNode(t))
|
|
@@ -762,24 +868,24 @@ class U {
|
|
|
762
868
|
moveToNodes(t) {
|
|
763
869
|
if (t.length === 0)
|
|
764
870
|
return;
|
|
765
|
-
const e = t.map((
|
|
871
|
+
const e = t.map((g) => this.graphStore.getNode(g)).filter((g) => g !== void 0);
|
|
766
872
|
if (e.length < t.length)
|
|
767
873
|
throw new Error("failed to move to nonexisting node");
|
|
768
|
-
const [s,
|
|
769
|
-
(
|
|
874
|
+
const [s, o] = e.reduce(
|
|
875
|
+
(g, w) => [g[0] + w.x, g[1] + w.y],
|
|
770
876
|
[0, 0]
|
|
771
|
-
),
|
|
772
|
-
this.patchViewportState(null,
|
|
877
|
+
), i = s / e.length, h = o / e.length, [a, c] = this.htmlController.getViewportDimensions(), l = this.viewportTransformer.getAbsScale(), d = i - l * a / 2, u = h - l * c / 2;
|
|
878
|
+
this.patchViewportState(null, d, u);
|
|
773
879
|
}
|
|
774
880
|
updateNodeCoordinates(t, e, s) {
|
|
775
881
|
if (!this.graphStore.hasNode(t))
|
|
776
882
|
throw new Error("failed to update coordinates of nonexisting node");
|
|
777
883
|
this.graphStore.updateNodeCoords(t, e, s), this.htmlController.updateNodeCoordinates(t);
|
|
778
884
|
}
|
|
779
|
-
|
|
780
|
-
if (!this.graphStore.
|
|
781
|
-
throw new Error("failed to update nonexisting
|
|
782
|
-
this.htmlController.
|
|
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);
|
|
783
889
|
}
|
|
784
890
|
attach(t) {
|
|
785
891
|
this.htmlController.attach(t);
|
|
@@ -788,145 +894,152 @@ class U {
|
|
|
788
894
|
this.htmlController.detach();
|
|
789
895
|
}
|
|
790
896
|
clear() {
|
|
791
|
-
this.htmlController.clear(), this.graphStore.clear(), this.nodeIdGenerator.reset(), this.portIdGenerator.reset(), this.
|
|
897
|
+
this.htmlController.clear(), this.graphStore.clear(), this.nodeIdGenerator.reset(), this.portIdGenerator.reset(), this.edgeIdGenerator.reset();
|
|
792
898
|
}
|
|
793
899
|
destroy() {
|
|
794
900
|
this.htmlController.destroy();
|
|
795
901
|
}
|
|
796
902
|
}
|
|
797
|
-
class
|
|
798
|
-
constructor(t, e, s,
|
|
903
|
+
class Q {
|
|
904
|
+
constructor(t, e, s, o, i) {
|
|
799
905
|
n(this, "publicViewportTransformer");
|
|
800
906
|
n(this, "canvasController");
|
|
801
|
-
const
|
|
802
|
-
this.publicViewportTransformer = new
|
|
803
|
-
|
|
907
|
+
const h = new B(), a = new X();
|
|
908
|
+
this.publicViewportTransformer = new Y(
|
|
909
|
+
h
|
|
804
910
|
);
|
|
805
|
-
const
|
|
806
|
-
c,
|
|
911
|
+
const c = new R(
|
|
807
912
|
a,
|
|
913
|
+
h,
|
|
808
914
|
this.publicViewportTransformer,
|
|
809
915
|
t,
|
|
810
916
|
e
|
|
811
917
|
);
|
|
812
|
-
this.canvasController = new
|
|
918
|
+
this.canvasController = new K(
|
|
919
|
+
a,
|
|
813
920
|
c,
|
|
814
921
|
h,
|
|
815
|
-
a,
|
|
816
922
|
s,
|
|
817
|
-
|
|
923
|
+
o,
|
|
924
|
+
i
|
|
818
925
|
);
|
|
819
926
|
}
|
|
820
927
|
}
|
|
821
|
-
const
|
|
822
|
-
|
|
928
|
+
const D = (r, t) => [
|
|
929
|
+
r / 2,
|
|
823
930
|
t / 2
|
|
824
|
-
],
|
|
825
|
-
},
|
|
826
|
-
|
|
827
|
-
const
|
|
828
|
-
let
|
|
931
|
+
], I = () => () => {
|
|
932
|
+
}, tt = (r, t, e, s, o, i) => {
|
|
933
|
+
r.clearRect(0, 0, r.canvas.width, r.canvas.height), r.fillStyle = i, r.fillRect(0, 0, r.canvas.width, r.canvas.height);
|
|
934
|
+
const h = t.getViewCoords(0, 0), a = t.getViewScale(), c = s * a;
|
|
935
|
+
let l = 0, d = 0, u = c / 2;
|
|
829
936
|
do
|
|
830
|
-
|
|
831
|
-
while (
|
|
832
|
-
const
|
|
833
|
-
|
|
834
|
-
for (let
|
|
835
|
-
for (let
|
|
836
|
-
|
|
837
|
-
},
|
|
838
|
-
|
|
839
|
-
r,
|
|
840
|
-
a,
|
|
937
|
+
u *= 2, l = r.canvas.width / u, d = r.canvas.height / u;
|
|
938
|
+
while (l * d > 1e4);
|
|
939
|
+
const g = h[0] - Math.floor(h[0] / u) * u, w = h[1] - Math.floor(h[1] / u) * u, m = o * a, f = 2 * Math.PI, p = g - u, C = w - u, v = r.canvas.width + g, E = r.canvas.height + w;
|
|
940
|
+
r.fillStyle = e;
|
|
941
|
+
for (let A = p; A <= v; A += u)
|
|
942
|
+
for (let y = C; y <= E; y += u)
|
|
943
|
+
r.beginPath(), r.arc(A, y, m, 0, f), r.closePath(), r.fill();
|
|
944
|
+
}, et = (r, t, e, s) => (o, i) => {
|
|
945
|
+
tt(
|
|
841
946
|
o,
|
|
947
|
+
i,
|
|
948
|
+
r,
|
|
842
949
|
t,
|
|
843
950
|
e,
|
|
844
951
|
s
|
|
845
952
|
);
|
|
846
|
-
},
|
|
847
|
-
|
|
848
|
-
},
|
|
849
|
-
|
|
850
|
-
},
|
|
851
|
-
switch (
|
|
953
|
+
}, st = (r, t) => {
|
|
954
|
+
r.fillStyle = t, r.fillRect(0, 0, r.canvas.width, r.canvas.height);
|
|
955
|
+
}, rt = (r) => (t) => {
|
|
956
|
+
st(t, r);
|
|
957
|
+
}, ot = (r) => {
|
|
958
|
+
switch (r == null ? void 0 : r.type) {
|
|
852
959
|
case "custom":
|
|
853
|
-
return
|
|
960
|
+
return r.drawingFn;
|
|
854
961
|
case "dots":
|
|
855
|
-
return
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
962
|
+
return et(
|
|
963
|
+
r.dotColor ?? "#d8d8d8",
|
|
964
|
+
r.dotGap ?? 25,
|
|
965
|
+
r.dotRadius ?? 1.5,
|
|
966
|
+
r.color ?? "#ffffff"
|
|
860
967
|
);
|
|
861
968
|
case "color":
|
|
862
|
-
return
|
|
969
|
+
return rt(r.color ?? "#ffffff");
|
|
863
970
|
default:
|
|
864
|
-
return
|
|
971
|
+
return I();
|
|
865
972
|
}
|
|
866
|
-
},
|
|
867
|
-
switch (
|
|
973
|
+
}, F = (r) => {
|
|
974
|
+
switch (r == null ? void 0 : r.type) {
|
|
868
975
|
case "custom":
|
|
869
|
-
return
|
|
976
|
+
return r.controllerFactory;
|
|
870
977
|
case "straight":
|
|
871
|
-
return
|
|
872
|
-
color:
|
|
873
|
-
width:
|
|
874
|
-
arrowLength:
|
|
875
|
-
arrowWidth:
|
|
876
|
-
|
|
877
|
-
hasSourceArrow:
|
|
878
|
-
hasTargetArrow:
|
|
879
|
-
cycleSquareSide:
|
|
880
|
-
roundness:
|
|
978
|
+
return J({
|
|
979
|
+
color: r.color ?? "#5c5c5c",
|
|
980
|
+
width: r.width ?? 1,
|
|
981
|
+
arrowLength: r.arrowLength ?? 15,
|
|
982
|
+
arrowWidth: r.arrowWidth ?? 4,
|
|
983
|
+
arrowOffset: r.arrowOffset ?? 15,
|
|
984
|
+
hasSourceArrow: r.hasSourceArrow ?? !1,
|
|
985
|
+
hasTargetArrow: r.hasTargetArrow ?? !1,
|
|
986
|
+
cycleSquareSide: r.cycleSquareSide ?? 30,
|
|
987
|
+
roundness: r.roundness ?? 10,
|
|
988
|
+
detourDistance: r.detourDistance ?? 100,
|
|
989
|
+
detourDirection: r.detourDirection ?? -Math.PI / 2
|
|
881
990
|
});
|
|
882
991
|
default:
|
|
883
|
-
return
|
|
884
|
-
color:
|
|
885
|
-
width:
|
|
886
|
-
curvature:
|
|
887
|
-
arrowLength:
|
|
888
|
-
arrowWidth:
|
|
889
|
-
hasSourceArrow:
|
|
890
|
-
hasTargetArrow:
|
|
891
|
-
cycleRadius:
|
|
892
|
-
smallCycleRadius:
|
|
992
|
+
return _({
|
|
993
|
+
color: r.color ?? "#5c5c5c",
|
|
994
|
+
width: r.width ?? 1,
|
|
995
|
+
curvature: r.curvature ?? 90,
|
|
996
|
+
arrowLength: r.arrowLength ?? 15,
|
|
997
|
+
arrowWidth: r.arrowWidth ?? 4,
|
|
998
|
+
hasSourceArrow: r.hasSourceArrow ?? !1,
|
|
999
|
+
hasTargetArrow: r.hasTargetArrow ?? !1,
|
|
1000
|
+
cycleRadius: r.cycleRadius ?? 30,
|
|
1001
|
+
smallCycleRadius: r.smallCycleRadius ?? 15,
|
|
1002
|
+
detourDistance: r.detourDistance ?? 100,
|
|
1003
|
+
detourDirection: r.detourDirection ?? -Math.PI / 2
|
|
893
1004
|
});
|
|
894
1005
|
}
|
|
895
|
-
},
|
|
896
|
-
var t, e, s;
|
|
1006
|
+
}, nt = (r) => {
|
|
1007
|
+
var t, e, s, o;
|
|
897
1008
|
return {
|
|
898
1009
|
background: {
|
|
899
|
-
drawingFn:
|
|
900
|
-
|
|
1010
|
+
drawingFn: ot(
|
|
1011
|
+
r.background ?? { type: "none" }
|
|
901
1012
|
)
|
|
902
1013
|
},
|
|
903
1014
|
nodes: {
|
|
904
|
-
centerFn: ((t =
|
|
1015
|
+
centerFn: ((t = r.nodes) == null ? void 0 : t.centerFn) ?? D
|
|
905
1016
|
},
|
|
906
1017
|
ports: {
|
|
907
|
-
centerFn: ((e =
|
|
1018
|
+
centerFn: ((e = r.ports) == null ? void 0 : e.centerFn) ?? D,
|
|
1019
|
+
direction: ((s = r.ports) == null ? void 0 : s.direction) ?? 0
|
|
908
1020
|
},
|
|
909
1021
|
edges: {
|
|
910
|
-
controllerFactory:
|
|
1022
|
+
controllerFactory: F(r.edges ?? {})
|
|
911
1023
|
},
|
|
912
1024
|
layers: {
|
|
913
|
-
mode: ((
|
|
1025
|
+
mode: ((o = r.layers) == null ? void 0 : o.mode) ?? "edges-follow-node"
|
|
914
1026
|
}
|
|
915
1027
|
};
|
|
916
1028
|
};
|
|
917
|
-
class
|
|
1029
|
+
class it {
|
|
918
1030
|
constructor(t) {
|
|
919
1031
|
n(this, "transformation");
|
|
920
1032
|
n(this, "di");
|
|
921
|
-
n(this, "
|
|
1033
|
+
n(this, "edgeControllerFactory");
|
|
922
1034
|
this.apiOptions = t;
|
|
923
|
-
const e =
|
|
924
|
-
this.di = new
|
|
1035
|
+
const e = nt(this.apiOptions ?? {});
|
|
1036
|
+
this.di = new Q(
|
|
925
1037
|
e.layers.mode,
|
|
926
1038
|
e.background.drawingFn,
|
|
927
1039
|
e.nodes.centerFn,
|
|
928
|
-
e.ports.centerFn
|
|
929
|
-
|
|
1040
|
+
e.ports.centerFn,
|
|
1041
|
+
e.ports.direction
|
|
1042
|
+
), this.transformation = this.di.publicViewportTransformer, this.edgeControllerFactory = e.edges.controllerFactory;
|
|
930
1043
|
}
|
|
931
1044
|
addNode(t) {
|
|
932
1045
|
return this.di.canvasController.addNode(
|
|
@@ -954,14 +1067,14 @@ class et {
|
|
|
954
1067
|
), this;
|
|
955
1068
|
}
|
|
956
1069
|
updatePortEdges(t) {
|
|
957
|
-
return this.di.canvasController.
|
|
1070
|
+
return this.di.canvasController.updatePortEdges(t), this;
|
|
958
1071
|
}
|
|
959
1072
|
unmarkPort(t) {
|
|
960
1073
|
return this.di.canvasController.unmarkPort(t), this;
|
|
961
1074
|
}
|
|
962
1075
|
addEdge(t) {
|
|
963
|
-
const e = t.options !== void 0 ?
|
|
964
|
-
return this.di.canvasController.
|
|
1076
|
+
const e = t.options !== void 0 ? F(t.options) : this.edgeControllerFactory;
|
|
1077
|
+
return this.di.canvasController.addEdge(
|
|
965
1078
|
t.id,
|
|
966
1079
|
t.from,
|
|
967
1080
|
t.to,
|
|
@@ -969,7 +1082,7 @@ class et {
|
|
|
969
1082
|
), this;
|
|
970
1083
|
}
|
|
971
1084
|
removeEdge(t) {
|
|
972
|
-
return this.di.canvasController.
|
|
1085
|
+
return this.di.canvasController.removeEdge(t), this;
|
|
973
1086
|
}
|
|
974
1087
|
patchViewportState(t) {
|
|
975
1088
|
return this.di.canvasController.patchViewportState(
|
|
@@ -984,11 +1097,8 @@ class et {
|
|
|
984
1097
|
updateNodeCoordinates(t, e, s) {
|
|
985
1098
|
return this.di.canvasController.updateNodeCoordinates(t, e, s), this;
|
|
986
1099
|
}
|
|
987
|
-
|
|
988
|
-
return e.controller !== void 0 && this.di.canvasController.
|
|
989
|
-
t,
|
|
990
|
-
e.controller
|
|
991
|
-
), this;
|
|
1100
|
+
updateEdge(t, e) {
|
|
1101
|
+
return e.controller !== void 0 && this.di.canvasController.updateEdgeController(t, e.controller), this;
|
|
992
1102
|
}
|
|
993
1103
|
clear() {
|
|
994
1104
|
return this.di.canvasController.clear(), this;
|
|
@@ -1003,14 +1113,14 @@ class et {
|
|
|
1003
1113
|
this.di.canvasController.destroy();
|
|
1004
1114
|
}
|
|
1005
1115
|
}
|
|
1006
|
-
class
|
|
1116
|
+
class ht {
|
|
1007
1117
|
constructor(t, e) {
|
|
1008
1118
|
n(this, "transformation");
|
|
1009
1119
|
n(this, "nodes", /* @__PURE__ */ new Map());
|
|
1010
1120
|
n(this, "grabbedNodeId", null);
|
|
1011
1121
|
n(this, "onNodeDrag");
|
|
1012
1122
|
n(this, "onBeforeNodeDrag");
|
|
1013
|
-
n(this, "nodeIdGenerator", new
|
|
1123
|
+
n(this, "nodeIdGenerator", new L());
|
|
1014
1124
|
n(this, "element", null);
|
|
1015
1125
|
n(this, "onCanvasMouseUp", () => {
|
|
1016
1126
|
this.setCursor(null), this.grabbedNodeId = null;
|
|
@@ -1044,13 +1154,13 @@ class st {
|
|
|
1044
1154
|
] : (this.previousTouchCoords = null, this.grabbedNodeId = null);
|
|
1045
1155
|
});
|
|
1046
1156
|
n(this, "previousTouchCoords", null);
|
|
1047
|
-
var
|
|
1157
|
+
var i, h;
|
|
1048
1158
|
this.canvas = t, this.transformation = this.canvas.transformation;
|
|
1049
1159
|
const s = () => {
|
|
1050
1160
|
};
|
|
1051
|
-
this.onNodeDrag = ((
|
|
1052
|
-
const
|
|
1053
|
-
this.onBeforeNodeDrag = ((
|
|
1161
|
+
this.onNodeDrag = ((i = e == null ? void 0 : e.events) == null ? void 0 : i.onNodeDrag) ?? s;
|
|
1162
|
+
const o = () => !0;
|
|
1163
|
+
this.onBeforeNodeDrag = ((h = e == null ? void 0 : e.events) == null ? void 0 : h.onBeforeNodeDrag) ?? o;
|
|
1054
1164
|
}
|
|
1055
1165
|
addNode(t) {
|
|
1056
1166
|
let e = t.id;
|
|
@@ -1059,28 +1169,28 @@ class st {
|
|
|
1059
1169
|
e = this.nodeIdGenerator.next();
|
|
1060
1170
|
while (this.nodes.has(e));
|
|
1061
1171
|
this.canvas.addNode(t);
|
|
1062
|
-
const s = (
|
|
1172
|
+
const s = (i) => {
|
|
1063
1173
|
this.onBeforeNodeDrag({
|
|
1064
1174
|
nodeId: e,
|
|
1065
1175
|
element: t.element,
|
|
1066
1176
|
x: t.x,
|
|
1067
1177
|
y: t.y
|
|
1068
|
-
}) && (
|
|
1069
|
-
},
|
|
1178
|
+
}) && (i.stopImmediatePropagation(), this.grabbedNodeId = e, this.setCursor("grab"), this.canvas.moveNodeOnTop(e));
|
|
1179
|
+
}, o = (i) => {
|
|
1070
1180
|
this.onBeforeNodeDrag({
|
|
1071
1181
|
nodeId: e,
|
|
1072
1182
|
element: t.element,
|
|
1073
1183
|
x: t.x,
|
|
1074
1184
|
y: t.y
|
|
1075
|
-
}) &&
|
|
1185
|
+
}) && i.touches.length === 1 && (this.grabbedNodeId = e, this.canvas.moveNodeOnTop(e));
|
|
1076
1186
|
};
|
|
1077
1187
|
return this.nodes.set(e, {
|
|
1078
1188
|
element: t.element,
|
|
1079
1189
|
onMouseDown: s,
|
|
1080
|
-
onTouchStart:
|
|
1190
|
+
onTouchStart: o,
|
|
1081
1191
|
x: t.x,
|
|
1082
1192
|
y: t.y
|
|
1083
|
-
}), t.element.addEventListener("mousedown", s), t.element.addEventListener("touchstart",
|
|
1193
|
+
}), t.element.addEventListener("mousedown", s), t.element.addEventListener("touchstart", o), this;
|
|
1084
1194
|
}
|
|
1085
1195
|
removeNode(t) {
|
|
1086
1196
|
const e = this.nodes.get(t);
|
|
@@ -1110,8 +1220,8 @@ class st {
|
|
|
1110
1220
|
updateNodeCoordinates(t, e, s) {
|
|
1111
1221
|
return this.canvas.updateNodeCoordinates(t, e, s), this;
|
|
1112
1222
|
}
|
|
1113
|
-
|
|
1114
|
-
return this.canvas.
|
|
1223
|
+
updateEdge(t, e) {
|
|
1224
|
+
return this.canvas.updateEdge(t, e), this;
|
|
1115
1225
|
}
|
|
1116
1226
|
moveNodeOnTop(t) {
|
|
1117
1227
|
return this.canvas.moveNodeOnTop(t), this;
|
|
@@ -1136,19 +1246,19 @@ class st {
|
|
|
1136
1246
|
this.element !== null && (t !== null ? this.element.style.cursor = t : this.element.style.removeProperty("cursor"));
|
|
1137
1247
|
}
|
|
1138
1248
|
dragNode(t, e, s) {
|
|
1139
|
-
const
|
|
1140
|
-
if (
|
|
1249
|
+
const o = this.nodes.get(t);
|
|
1250
|
+
if (o === void 0)
|
|
1141
1251
|
throw new Error("failed to drag nonexisting node");
|
|
1142
|
-
const [
|
|
1143
|
-
|
|
1252
|
+
const [i, h] = this.transformation.getViewCoords(o.x, o.y), a = i + e, c = h + s, [l, d] = this.transformation.getAbsCoords(a, c);
|
|
1253
|
+
o.x = l, o.y = d, this.canvas.updateNodeCoordinates(t, l, d), this.onNodeDrag({
|
|
1144
1254
|
nodeId: t,
|
|
1145
|
-
element:
|
|
1146
|
-
x:
|
|
1147
|
-
y:
|
|
1255
|
+
element: o.element,
|
|
1256
|
+
x: o.x,
|
|
1257
|
+
y: o.y
|
|
1148
1258
|
});
|
|
1149
1259
|
}
|
|
1150
1260
|
}
|
|
1151
|
-
class
|
|
1261
|
+
class at {
|
|
1152
1262
|
constructor(t, e) {
|
|
1153
1263
|
n(this, "transformation");
|
|
1154
1264
|
n(this, "element", null);
|
|
@@ -1177,8 +1287,8 @@ class ot {
|
|
|
1177
1287
|
if (this.element === null || this.isScalable === !1)
|
|
1178
1288
|
return;
|
|
1179
1289
|
t.preventDefault();
|
|
1180
|
-
const { left: e, top: s } = this.element.getBoundingClientRect(),
|
|
1181
|
-
this.scaleViewport(
|
|
1290
|
+
const { left: e, top: s } = this.element.getBoundingClientRect(), o = t.clientX - e, i = t.clientY - s, a = 1 / (t.deltaY < 0 ? this.wheelSensitivity : 1 / this.wheelSensitivity);
|
|
1291
|
+
this.scaleViewport(a, o, i);
|
|
1182
1292
|
});
|
|
1183
1293
|
n(this, "onTouchStart", (t) => {
|
|
1184
1294
|
this.prevTouches = this.getAverageTouch(t);
|
|
@@ -1191,25 +1301,25 @@ class ot {
|
|
|
1191
1301
|
-(e.x - this.prevTouches.x),
|
|
1192
1302
|
-(e.y - this.prevTouches.y)
|
|
1193
1303
|
), e.touchesCnt === 2 && this.isScalable) {
|
|
1194
|
-
const { left: s, top:
|
|
1195
|
-
this.scaleViewport(
|
|
1304
|
+
const { left: s, top: o } = this.element.getBoundingClientRect(), i = this.prevTouches.x - s, h = this.prevTouches.y - o, c = 1 / (e.scale / this.prevTouches.scale);
|
|
1305
|
+
this.scaleViewport(c, i, h);
|
|
1196
1306
|
}
|
|
1197
1307
|
this.prevTouches = e, t.preventDefault();
|
|
1198
1308
|
});
|
|
1199
1309
|
n(this, "onTouchEnd", (t) => {
|
|
1200
1310
|
t.touches.length > 0 ? this.prevTouches = this.getAverageTouch(t) : this.prevTouches = null;
|
|
1201
1311
|
});
|
|
1202
|
-
var
|
|
1312
|
+
var c, l, d, u, g, w, m, f, p, C, v, E;
|
|
1203
1313
|
this.canvas = t, this.options = e, this.transformation = this.canvas.transformation;
|
|
1204
|
-
const s = ((
|
|
1205
|
-
this.isScalable = ((w = (
|
|
1206
|
-
const
|
|
1207
|
-
this.wheelSensitivity =
|
|
1208
|
-
const
|
|
1314
|
+
const s = ((l = (c = this.options) == null ? void 0 : c.scale) == null ? void 0 : l.min) ?? null, o = ((u = (d = this.options) == null ? void 0 : d.scale) == null ? void 0 : u.max) ?? null;
|
|
1315
|
+
this.isScalable = ((w = (g = this.options) == null ? void 0 : g.scale) == null ? void 0 : w.enabled) !== !1, this.minViewScale = o !== null ? 1 / o : null, this.maxViewScale = s !== null ? 1 / s : null, this.isShiftable = ((f = (m = this.options) == null ? void 0 : m.shift) == null ? void 0 : f.enabled) !== !1;
|
|
1316
|
+
const i = (C = (p = this.options) == null ? void 0 : p.scale) == null ? void 0 : C.wheelSensitivity;
|
|
1317
|
+
this.wheelSensitivity = i !== void 0 ? i : 1.2;
|
|
1318
|
+
const h = () => {
|
|
1209
1319
|
};
|
|
1210
|
-
this.onTransform = ((
|
|
1211
|
-
const
|
|
1212
|
-
this.onBeforeTransform = ((
|
|
1320
|
+
this.onTransform = ((v = e == null ? void 0 : e.events) == null ? void 0 : v.onTransform) ?? h;
|
|
1321
|
+
const a = () => !0;
|
|
1322
|
+
this.onBeforeTransform = ((E = e == null ? void 0 : e.events) == null ? void 0 : E.onBeforeTransform) ?? a;
|
|
1213
1323
|
}
|
|
1214
1324
|
addNode(t) {
|
|
1215
1325
|
return this.canvas.addNode(t), this;
|
|
@@ -1241,8 +1351,8 @@ class ot {
|
|
|
1241
1351
|
updateNodeCoordinates(t, e, s) {
|
|
1242
1352
|
return this.canvas.updateNodeCoordinates(t, e, s), this;
|
|
1243
1353
|
}
|
|
1244
|
-
|
|
1245
|
-
return this.canvas.
|
|
1354
|
+
updateEdge(t, e) {
|
|
1355
|
+
return this.canvas.updateEdge(t, e), this;
|
|
1246
1356
|
}
|
|
1247
1357
|
moveNodeOnTop(t) {
|
|
1248
1358
|
return this.canvas.moveNodeOnTop(t), this;
|
|
@@ -1261,37 +1371,37 @@ class ot {
|
|
|
1261
1371
|
}
|
|
1262
1372
|
getAverageTouch(t) {
|
|
1263
1373
|
const e = [], s = t.touches.length;
|
|
1264
|
-
for (let
|
|
1265
|
-
e.push([t.touches[
|
|
1266
|
-
const
|
|
1267
|
-
(
|
|
1374
|
+
for (let c = 0; c < s; c++)
|
|
1375
|
+
e.push([t.touches[c].clientX, t.touches[c].clientY]);
|
|
1376
|
+
const o = e.reduce(
|
|
1377
|
+
(c, l) => [c[0] + l[0], c[1] + l[1]],
|
|
1268
1378
|
[0, 0]
|
|
1269
|
-
),
|
|
1270
|
-
(
|
|
1379
|
+
), i = [o[0] / s, o[1] / s], a = e.map((c) => [c[0] - i[0], c[1] - i[1]]).reduce(
|
|
1380
|
+
(c, l) => c + Math.sqrt(l[0] * l[0] + l[1] * l[1]),
|
|
1271
1381
|
0
|
|
1272
1382
|
);
|
|
1273
|
-
return { x:
|
|
1383
|
+
return { x: i[0], y: i[1], scale: a / s, touchesCnt: s };
|
|
1274
1384
|
}
|
|
1275
1385
|
setCursor(t) {
|
|
1276
1386
|
this.element !== null && (t !== null ? this.element.style.cursor = t : this.element.style.removeProperty("cursor"));
|
|
1277
1387
|
}
|
|
1278
1388
|
moveViewport(t, e) {
|
|
1279
|
-
const [s,
|
|
1280
|
-
scale:
|
|
1281
|
-
x: s +
|
|
1282
|
-
y:
|
|
1389
|
+
const [s, o] = this.transformation.getAbsCoords(0, 0), i = this.canvas.transformation.getAbsScale(), h = {
|
|
1390
|
+
scale: i,
|
|
1391
|
+
x: s + i * t,
|
|
1392
|
+
y: o + i * e
|
|
1283
1393
|
};
|
|
1284
|
-
this.onBeforeTransform({ ...
|
|
1394
|
+
this.onBeforeTransform({ ...h }) && (this.canvas.patchViewportState(h), this.onTransform(h));
|
|
1285
1395
|
}
|
|
1286
1396
|
scaleViewport(t, e, s) {
|
|
1287
|
-
const [
|
|
1288
|
-
if (this.maxViewScale !== null &&
|
|
1397
|
+
const [o, i] = this.canvas.transformation.getAbsCoords(0, 0), h = this.canvas.transformation.getAbsScale(), a = h * t, c = h * (1 - t) * e + o, l = h * (1 - t) * s + i;
|
|
1398
|
+
if (this.maxViewScale !== null && a > this.maxViewScale && a > h || this.minViewScale !== null && a < this.minViewScale && a < h)
|
|
1289
1399
|
return;
|
|
1290
|
-
const
|
|
1291
|
-
this.onBeforeTransform({ ...
|
|
1400
|
+
const d = { scale: a, x: c, y: l };
|
|
1401
|
+
this.onBeforeTransform({ ...d }) && (this.canvas.patchViewportState(d), this.onTransform(d));
|
|
1292
1402
|
}
|
|
1293
1403
|
}
|
|
1294
|
-
class
|
|
1404
|
+
class lt {
|
|
1295
1405
|
constructor() {
|
|
1296
1406
|
n(this, "coreOptions");
|
|
1297
1407
|
n(this, "dragOptions");
|
|
@@ -1309,21 +1419,21 @@ class nt {
|
|
|
1309
1419
|
return this.isTransformable = !0, this.transformOptions = t, this;
|
|
1310
1420
|
}
|
|
1311
1421
|
build() {
|
|
1312
|
-
let t = new
|
|
1313
|
-
return this.isDraggable && (t = new
|
|
1422
|
+
let t = new it(this.coreOptions);
|
|
1423
|
+
return this.isDraggable && (t = new ht(t, this.dragOptions)), this.isTransformable && (t = new at(t, this.transformOptions)), t;
|
|
1314
1424
|
}
|
|
1315
1425
|
}
|
|
1316
1426
|
export {
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1427
|
+
z as BezierEdgeController,
|
|
1428
|
+
it as CanvasCore,
|
|
1429
|
+
Z as CycleCircleEdgeController,
|
|
1430
|
+
U as CycleSquareEdgeController,
|
|
1431
|
+
H as DetourStraightEdgeController,
|
|
1321
1432
|
T as EdgeType,
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
Z as createStraightEdgeControllerFactory
|
|
1433
|
+
lt as HtmlGraphBuilder,
|
|
1434
|
+
G as StraightEdgeController,
|
|
1435
|
+
ht as UserDraggableNodesCanvas,
|
|
1436
|
+
at as UserTransformableCanvas,
|
|
1437
|
+
_ as createBezierEdgeControllerFactory,
|
|
1438
|
+
J as createStraightEdgeControllerFactory
|
|
1329
1439
|
};
|