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