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