@html-graph/html-graph 3.0.0 → 3.1.0
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/html-graph.d.ts +36 -72
- package/dist/html-graph.js +1156 -1263
- package/dist/html-graph.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/html-graph.js
CHANGED
|
@@ -1,7 +1,234 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var i = (t, e, o) =>
|
|
4
|
-
|
|
1
|
+
var ie = Object.defineProperty;
|
|
2
|
+
var se = (t, e, o) => e in t ? ie(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o;
|
|
3
|
+
var i = (t, e, o) => se(t, typeof e != "symbol" ? e + "" : e, o);
|
|
4
|
+
const ne = () => {
|
|
5
|
+
const t = document.createElement("div");
|
|
6
|
+
return t.style.width = "100%", t.style.height = "100%", t.style.position = "relative", t.style.overflow = "hidden", t;
|
|
7
|
+
}, he = () => {
|
|
8
|
+
const t = document.createElement("div");
|
|
9
|
+
return t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.width = "0", t.style.height = "0", t;
|
|
10
|
+
}, de = () => {
|
|
11
|
+
const t = document.createElement("div");
|
|
12
|
+
return t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.visibility = "hidden", t;
|
|
13
|
+
};
|
|
14
|
+
class ce {
|
|
15
|
+
constructor(e, o, r) {
|
|
16
|
+
i(this, "host", ne());
|
|
17
|
+
i(this, "container", he());
|
|
18
|
+
i(this, "nodeIdToWrapperElementMap", /* @__PURE__ */ new Map());
|
|
19
|
+
i(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
|
|
20
|
+
i(this, "applyTransform", () => {
|
|
21
|
+
const e = this.viewportStore.getContentMatrix();
|
|
22
|
+
this.container.style.transform = `matrix(${e.scale}, 0, 0, ${e.scale}, ${e.x}, ${e.y})`;
|
|
23
|
+
});
|
|
24
|
+
this.graphStore = e, this.viewportStore = o, this.element = r, this.element.appendChild(this.host), this.host.appendChild(this.container), this.viewportStore.onAfterUpdated.subscribe(this.applyTransform);
|
|
25
|
+
}
|
|
26
|
+
attachNode(e) {
|
|
27
|
+
const o = this.graphStore.getNode(e), r = de();
|
|
28
|
+
r.appendChild(o.element), this.container.appendChild(r), this.nodeIdToWrapperElementMap.set(e, r), this.updateNodePosition(e), this.updateNodePriority(e), r.style.visibility = "visible";
|
|
29
|
+
}
|
|
30
|
+
detachNode(e) {
|
|
31
|
+
const o = this.nodeIdToWrapperElementMap.get(e);
|
|
32
|
+
o.removeChild(o.firstChild), this.container.removeChild(o), this.nodeIdToWrapperElementMap.delete(e);
|
|
33
|
+
}
|
|
34
|
+
attachEdge(e) {
|
|
35
|
+
const o = this.graphStore.getEdge(e).shape.svg;
|
|
36
|
+
this.edgeIdToElementMap.set(e, o), this.container.appendChild(o), this.renderEdge(e), this.updateEdgePriority(e);
|
|
37
|
+
}
|
|
38
|
+
detachEdge(e) {
|
|
39
|
+
const o = this.edgeIdToElementMap.get(e);
|
|
40
|
+
this.container.removeChild(o), this.edgeIdToElementMap.delete(e);
|
|
41
|
+
}
|
|
42
|
+
clear() {
|
|
43
|
+
this.edgeIdToElementMap.forEach((e, o) => {
|
|
44
|
+
this.detachEdge(o);
|
|
45
|
+
}), this.nodeIdToWrapperElementMap.forEach((e, o) => {
|
|
46
|
+
this.detachNode(o);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
destroy() {
|
|
50
|
+
this.viewportStore.onAfterUpdated.unsubscribe(this.applyTransform), this.clear(), this.element.removeChild(this.host), this.host.removeChild(this.container);
|
|
51
|
+
}
|
|
52
|
+
updateNodePosition(e) {
|
|
53
|
+
const o = this.nodeIdToWrapperElementMap.get(e), r = this.graphStore.getNode(e), { width: s, height: d } = r.element.getBoundingClientRect(), n = this.viewportStore.getViewportMatrix().scale, h = r.centerFn(s, d), c = r.x - n * h.x, a = r.y - n * h.y;
|
|
54
|
+
o.style.transform = `translate(${c}px, ${a}px)`;
|
|
55
|
+
}
|
|
56
|
+
updateNodePriority(e) {
|
|
57
|
+
const o = this.graphStore.getNode(e), r = this.nodeIdToWrapperElementMap.get(e);
|
|
58
|
+
r.style.zIndex = `${o.priority}`;
|
|
59
|
+
}
|
|
60
|
+
updateEdgeShape(e) {
|
|
61
|
+
const o = this.edgeIdToElementMap.get(e);
|
|
62
|
+
this.container.removeChild(o);
|
|
63
|
+
const r = this.graphStore.getEdge(e);
|
|
64
|
+
this.edgeIdToElementMap.set(e, r.shape.svg), this.container.appendChild(r.shape.svg);
|
|
65
|
+
}
|
|
66
|
+
renderEdge(e) {
|
|
67
|
+
const o = this.graphStore.getEdge(e), r = this.graphStore.getPort(o.from), s = this.graphStore.getPort(o.to), d = r.element.getBoundingClientRect(), n = s.element.getBoundingClientRect(), h = this.host.getBoundingClientRect(), c = this.viewportStore.getViewportMatrix(), a = {
|
|
68
|
+
x: c.scale * (d.left - h.left) + c.x,
|
|
69
|
+
y: c.scale * (d.top - h.top) + c.y
|
|
70
|
+
}, l = {
|
|
71
|
+
x: c.scale * (n.left - h.left) + c.x,
|
|
72
|
+
y: c.scale * (n.top - h.top) + c.y
|
|
73
|
+
}, g = {
|
|
74
|
+
x: a.x,
|
|
75
|
+
y: a.y,
|
|
76
|
+
width: d.width * c.scale,
|
|
77
|
+
height: d.height * c.scale,
|
|
78
|
+
direction: r.direction,
|
|
79
|
+
portId: o.from,
|
|
80
|
+
nodeId: r.nodeId
|
|
81
|
+
}, f = {
|
|
82
|
+
x: l.x,
|
|
83
|
+
y: l.y,
|
|
84
|
+
width: n.width * c.scale,
|
|
85
|
+
height: n.height * c.scale,
|
|
86
|
+
direction: s.direction,
|
|
87
|
+
portId: o.to,
|
|
88
|
+
nodeId: s.nodeId
|
|
89
|
+
};
|
|
90
|
+
o.shape.render({
|
|
91
|
+
from: g,
|
|
92
|
+
to: f
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
updateEdgePriority(e) {
|
|
96
|
+
const o = this.graphStore.getEdge(e);
|
|
97
|
+
o.shape.svg.style.zIndex = `${o.priority}`;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
class ae {
|
|
101
|
+
constructor(e) {
|
|
102
|
+
i(this, "xFrom", 1 / 0);
|
|
103
|
+
i(this, "yFrom", 1 / 0);
|
|
104
|
+
i(this, "xTo", 1 / 0);
|
|
105
|
+
i(this, "yTo", 1 / 0);
|
|
106
|
+
this.graphStore = e;
|
|
107
|
+
}
|
|
108
|
+
setRenderingBox(e) {
|
|
109
|
+
this.xFrom = e.x, this.xTo = e.x + e.width, this.yFrom = e.y, this.yTo = e.y + e.height;
|
|
110
|
+
}
|
|
111
|
+
hasNode(e) {
|
|
112
|
+
const o = this.graphStore.getNode(e);
|
|
113
|
+
return o.x >= this.xFrom && o.x <= this.xTo && o.y >= this.yFrom && o.y <= this.yTo;
|
|
114
|
+
}
|
|
115
|
+
hasEdge(e) {
|
|
116
|
+
const o = this.graphStore.getEdge(e), r = this.graphStore.getPort(o.from).nodeId, s = this.graphStore.getPort(o.to).nodeId, d = this.graphStore.getNode(r), n = this.graphStore.getNode(s), h = Math.min(d.x, n.x), c = Math.max(d.x, n.x), a = Math.min(d.y, n.y), l = Math.max(d.y, n.y);
|
|
117
|
+
return h <= this.xTo && c >= this.xFrom && a <= this.yTo && l >= this.yFrom;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
class le {
|
|
121
|
+
constructor(e, o, r) {
|
|
122
|
+
i(this, "attachedNodes", /* @__PURE__ */ new Set());
|
|
123
|
+
i(this, "attachedEdges", /* @__PURE__ */ new Set());
|
|
124
|
+
i(this, "renderingBox");
|
|
125
|
+
i(this, "updateViewport", (e) => {
|
|
126
|
+
this.renderingBox.setRenderingBox(e);
|
|
127
|
+
const o = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set();
|
|
128
|
+
this.graphStore.getAllNodeIds().forEach((n) => {
|
|
129
|
+
const h = this.renderingBox.hasNode(n), c = this.attachedNodes.has(n);
|
|
130
|
+
h && !c ? o.add(n) : !h && c && r.add(n);
|
|
131
|
+
}), this.graphStore.getAllEdgeIds().forEach((n) => {
|
|
132
|
+
const h = this.renderingBox.hasEdge(n), c = this.attachedEdges.has(n), a = this.graphStore.getEdge(n), l = this.graphStore.getPort(a.from).nodeId, g = this.graphStore.getPort(a.to).nodeId;
|
|
133
|
+
h && (this.renderingBox.hasNode(l) || (o.add(l), r.delete(l)), this.renderingBox.hasNode(g) || (o.add(g), r.delete(g))), h && !c ? s.add(n) : !h && c && d.add(n);
|
|
134
|
+
}), d.forEach((n) => {
|
|
135
|
+
this.handleDetachEdge(n);
|
|
136
|
+
}), r.forEach((n) => {
|
|
137
|
+
this.handleDetachNode(n);
|
|
138
|
+
}), o.forEach((n) => {
|
|
139
|
+
this.attachedNodes.has(n) || this.handleAttachNode(n);
|
|
140
|
+
}), s.forEach((n) => {
|
|
141
|
+
this.handleAttachEdge(n);
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
this.htmlView = e, this.graphStore = o, this.trigger = r, this.renderingBox = new ae(this.graphStore), this.trigger.subscribe(this.updateViewport);
|
|
145
|
+
}
|
|
146
|
+
attachNode(e) {
|
|
147
|
+
this.renderingBox.hasNode(e) && this.handleAttachNode(e);
|
|
148
|
+
}
|
|
149
|
+
detachNode(e) {
|
|
150
|
+
this.attachedNodes.has(e) && this.handleDetachNode(e);
|
|
151
|
+
}
|
|
152
|
+
attachEdge(e) {
|
|
153
|
+
this.renderingBox.hasEdge(e) && this.attachEdgeEntities(e);
|
|
154
|
+
}
|
|
155
|
+
detachEdge(e) {
|
|
156
|
+
this.attachedEdges.has(e) && this.handleDetachEdge(e);
|
|
157
|
+
}
|
|
158
|
+
updateNodePosition(e) {
|
|
159
|
+
this.attachedNodes.has(e) ? this.htmlView.updateNodePosition(e) : this.renderingBox.hasNode(e) && (this.handleAttachNode(e), this.graphStore.getNodeAdjacentEdgeIds(e).forEach((o) => {
|
|
160
|
+
this.attachEdgeEntities(o);
|
|
161
|
+
}));
|
|
162
|
+
}
|
|
163
|
+
updateNodePriority(e) {
|
|
164
|
+
this.attachedNodes.has(e) && this.htmlView.updateNodePriority(e);
|
|
165
|
+
}
|
|
166
|
+
updateEdgeShape(e) {
|
|
167
|
+
this.attachedEdges.has(e) && this.htmlView.updateEdgeShape(e);
|
|
168
|
+
}
|
|
169
|
+
renderEdge(e) {
|
|
170
|
+
this.attachedEdges.has(e) && this.htmlView.renderEdge(e);
|
|
171
|
+
}
|
|
172
|
+
updateEdgePriority(e) {
|
|
173
|
+
this.attachedEdges.has(e) && this.htmlView.updateEdgePriority(e);
|
|
174
|
+
}
|
|
175
|
+
clear() {
|
|
176
|
+
this.htmlView.clear(), this.attachedNodes.clear(), this.attachedEdges.clear();
|
|
177
|
+
}
|
|
178
|
+
destroy() {
|
|
179
|
+
this.clear(), this.htmlView.destroy(), this.trigger.unsubscribe(this.updateViewport);
|
|
180
|
+
}
|
|
181
|
+
attachEdgeEntities(e) {
|
|
182
|
+
const o = this.graphStore.getEdge(e), r = this.graphStore.getPort(o.from).nodeId, s = this.graphStore.getPort(o.to).nodeId;
|
|
183
|
+
this.attachedNodes.has(r) || this.handleAttachNode(r), this.attachedNodes.has(s) || this.handleAttachNode(s), this.handleAttachEdge(e);
|
|
184
|
+
}
|
|
185
|
+
handleAttachNode(e) {
|
|
186
|
+
this.attachedNodes.add(e), this.htmlView.attachNode(e);
|
|
187
|
+
}
|
|
188
|
+
handleDetachNode(e) {
|
|
189
|
+
this.htmlView.detachNode(e), this.attachedNodes.delete(e);
|
|
190
|
+
}
|
|
191
|
+
handleAttachEdge(e) {
|
|
192
|
+
this.attachedEdges.add(e), this.htmlView.attachEdge(e);
|
|
193
|
+
}
|
|
194
|
+
handleDetachEdge(e) {
|
|
195
|
+
this.htmlView.detachEdge(e), this.attachedEdges.delete(e);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
class re {
|
|
199
|
+
constructor() {
|
|
200
|
+
i(this, "callbacks", /* @__PURE__ */ new Set());
|
|
201
|
+
}
|
|
202
|
+
subscribe(e) {
|
|
203
|
+
this.callbacks.add(e);
|
|
204
|
+
}
|
|
205
|
+
unsubscribe(e) {
|
|
206
|
+
this.callbacks.delete(e);
|
|
207
|
+
}
|
|
208
|
+
emit(e) {
|
|
209
|
+
this.callbacks.forEach((o) => {
|
|
210
|
+
o(e);
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
const A = () => {
|
|
215
|
+
const t = new re();
|
|
216
|
+
return [t, t];
|
|
217
|
+
};
|
|
218
|
+
class ge {
|
|
219
|
+
constructor(e) {
|
|
220
|
+
i(this, "onBeforeUpdated");
|
|
221
|
+
i(this, "onAfterUpdated");
|
|
222
|
+
this.transformer = e, this.onBeforeUpdated = this.transformer.onBeforeUpdated, this.onAfterUpdated = this.transformer.onAfterUpdated;
|
|
223
|
+
}
|
|
224
|
+
getViewportMatrix() {
|
|
225
|
+
return { ...this.transformer.getViewportMatrix() };
|
|
226
|
+
}
|
|
227
|
+
getContentMatrix() {
|
|
228
|
+
return { ...this.transformer.getContentMatrix() };
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
class ue {
|
|
5
232
|
constructor(e) {
|
|
6
233
|
i(this, "onAfterNodeAdded");
|
|
7
234
|
i(this, "onAfterNodeUpdated");
|
|
@@ -77,960 +304,86 @@ class ie {
|
|
|
77
304
|
return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeAdjacentEdgeIds(e);
|
|
78
305
|
}
|
|
79
306
|
}
|
|
80
|
-
class
|
|
307
|
+
class X {
|
|
81
308
|
constructor(e) {
|
|
82
|
-
i(this, "
|
|
83
|
-
|
|
84
|
-
this.transformer = e, this.onBeforeUpdated = this.transformer.onBeforeUpdated, this.onAfterUpdated = this.transformer.onAfterUpdated;
|
|
309
|
+
i(this, "counter", 0);
|
|
310
|
+
this.checkExists = e;
|
|
85
311
|
}
|
|
86
|
-
|
|
87
|
-
|
|
312
|
+
create(e) {
|
|
313
|
+
if (e !== void 0)
|
|
314
|
+
return e;
|
|
315
|
+
for (; this.checkExists(this.counter); )
|
|
316
|
+
this.counter++;
|
|
317
|
+
return this.counter;
|
|
88
318
|
}
|
|
89
|
-
|
|
90
|
-
|
|
319
|
+
reset() {
|
|
320
|
+
this.counter = 0;
|
|
91
321
|
}
|
|
92
322
|
}
|
|
93
|
-
class
|
|
94
|
-
constructor(e, o, r) {
|
|
95
|
-
i(this, "viewport");
|
|
96
|
-
i(this, "graph");
|
|
97
|
-
i(this, "onAfterNodeAdded", (e) => {
|
|
98
|
-
this.htmlView.attachNode(e);
|
|
99
|
-
});
|
|
100
|
-
i(this, "onAfterNodeUpdated", (e) => {
|
|
101
|
-
this.htmlView.updateNodePosition(e), this.graphStore.getNodeAdjacentEdgeIds(e).forEach((r) => {
|
|
102
|
-
this.htmlView.renderEdge(r);
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
i(this, "onAfterNodePriorityUpdated", (e) => {
|
|
106
|
-
this.htmlView.updateNodePriority(e);
|
|
107
|
-
});
|
|
108
|
-
i(this, "onBeforeNodeRemoved", (e) => {
|
|
109
|
-
this.graphStore.getNodePortIds(e).forEach((o) => {
|
|
110
|
-
this.unmarkPort(o);
|
|
111
|
-
}), this.htmlView.detachNode(e);
|
|
112
|
-
});
|
|
113
|
-
i(this, "onAfterPortUpdated", (e) => {
|
|
114
|
-
this.graphStore.getPortAdjacentEdgeIds(e).forEach((r) => {
|
|
115
|
-
this.htmlView.renderEdge(r);
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
i(this, "onBeforePortUnmarked", (e) => {
|
|
119
|
-
this.graphStore.getPortAdjacentEdgeIds(e).forEach((o) => {
|
|
120
|
-
this.removeEdge(o);
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
i(this, "onAfterEdgeAdded", (e) => {
|
|
124
|
-
this.htmlView.attachEdge(e);
|
|
125
|
-
});
|
|
126
|
-
i(this, "onAfterEdgeShapeUpdated", (e) => {
|
|
127
|
-
this.htmlView.updateEdgeShape(e);
|
|
128
|
-
});
|
|
129
|
-
i(this, "onAfterEdgeUpdated", (e) => {
|
|
130
|
-
this.htmlView.renderEdge(e);
|
|
131
|
-
});
|
|
132
|
-
i(this, "onAfterEdgePriorityUpdated", (e) => {
|
|
133
|
-
this.htmlView.updateEdgePriority(e);
|
|
134
|
-
});
|
|
135
|
-
i(this, "onBeforeEdgeRemoved", (e) => {
|
|
136
|
-
this.htmlView.detachEdge(e);
|
|
137
|
-
});
|
|
138
|
-
i(this, "onBeforeClear", () => {
|
|
139
|
-
this.htmlView.clear();
|
|
140
|
-
});
|
|
141
|
-
this.graphStore = e, this.viewportStore = o, this.htmlView = r, this.graphStore.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graphStore.onAfterNodeUpdated.subscribe(this.onAfterNodeUpdated), this.graphStore.onAfterNodePriorityUpdated.subscribe(
|
|
142
|
-
this.onAfterNodePriorityUpdated
|
|
143
|
-
), this.graphStore.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.graphStore.onAfterPortUpdated.subscribe(this.onAfterPortUpdated), this.graphStore.onBeforePortRemoved.subscribe(this.onBeforePortUnmarked), this.graphStore.onAfterEdgeAdded.subscribe(this.onAfterEdgeAdded), this.graphStore.onAfterEdgeShapeUpdated.subscribe(
|
|
144
|
-
this.onAfterEdgeShapeUpdated
|
|
145
|
-
), this.graphStore.onAfterEdgeUpdated.subscribe(this.onAfterEdgeUpdated), this.graphStore.onAfterEdgePriorityUpdated.subscribe(
|
|
146
|
-
this.onAfterEdgePriorityUpdated
|
|
147
|
-
), this.graphStore.onBeforeEdgeRemoved.subscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.subscribe(this.onBeforeClear), this.graph = new ie(this.graphStore), this.viewport = new se(this.viewportStore);
|
|
148
|
-
}
|
|
149
|
-
addNode(e) {
|
|
150
|
-
this.graphStore.addNode(e);
|
|
151
|
-
}
|
|
152
|
-
updateNode(e, o) {
|
|
153
|
-
this.graphStore.updateNode(e, o);
|
|
154
|
-
}
|
|
155
|
-
removeNode(e) {
|
|
156
|
-
this.graphStore.removeNode(e);
|
|
157
|
-
}
|
|
158
|
-
markPort(e) {
|
|
159
|
-
this.graphStore.addPort(e);
|
|
160
|
-
}
|
|
161
|
-
updatePort(e, o) {
|
|
162
|
-
this.graphStore.updatePort(e, o);
|
|
163
|
-
}
|
|
164
|
-
unmarkPort(e) {
|
|
165
|
-
this.graphStore.removePort(e);
|
|
166
|
-
}
|
|
167
|
-
addEdge(e) {
|
|
168
|
-
this.graphStore.addEdge(e);
|
|
169
|
-
}
|
|
170
|
-
updateEdge(e, o) {
|
|
171
|
-
this.graphStore.updateEdge(e, o);
|
|
172
|
-
}
|
|
173
|
-
removeEdge(e) {
|
|
174
|
-
this.graphStore.removeEdge(e);
|
|
175
|
-
}
|
|
176
|
-
patchViewportMatrix(e) {
|
|
177
|
-
this.viewportStore.patchViewportMatrix(e);
|
|
178
|
-
}
|
|
179
|
-
patchContentMatrix(e) {
|
|
180
|
-
this.viewportStore.patchContentMatrix(e);
|
|
181
|
-
}
|
|
182
|
-
clear() {
|
|
183
|
-
this.graphStore.clear();
|
|
184
|
-
}
|
|
185
|
-
destroy() {
|
|
186
|
-
this.graphStore.onAfterNodeAdded.unsubscribe(this.onAfterNodeAdded), this.graphStore.onAfterNodeUpdated.unsubscribe(this.onAfterNodeUpdated), this.graphStore.onAfterNodePriorityUpdated.unsubscribe(
|
|
187
|
-
this.onAfterNodePriorityUpdated
|
|
188
|
-
), this.graphStore.onBeforeNodeRemoved.unsubscribe(this.onBeforeNodeRemoved), this.graphStore.onAfterPortUpdated.unsubscribe(this.onAfterPortUpdated), this.graphStore.onBeforePortRemoved.unsubscribe(this.onBeforePortUnmarked), this.graphStore.onAfterEdgeAdded.unsubscribe(this.onAfterEdgeAdded), this.graphStore.onAfterEdgeShapeUpdated.unsubscribe(
|
|
189
|
-
this.onAfterEdgeShapeUpdated
|
|
190
|
-
), this.graphStore.onAfterEdgeUpdated.unsubscribe(this.onAfterEdgeUpdated), this.graphStore.onAfterEdgePriorityUpdated.unsubscribe(
|
|
191
|
-
this.onAfterEdgePriorityUpdated
|
|
192
|
-
), this.graphStore.onBeforeEdgeRemoved.unsubscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.unsubscribe(this.onBeforeClear), this.clear(), this.htmlView.destroy();
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
const U = (t, e, o) => {
|
|
196
|
-
const { x: r, y: s, width: d, height: n } = t.getBoundingClientRect();
|
|
197
|
-
return e >= r && e <= r + d && o >= s && o <= s + n;
|
|
198
|
-
}, $ = (t, e, o) => e >= 0 && e <= t.innerWidth && o >= 0 && o <= t.innerHeight, R = (t, e) => {
|
|
199
|
-
e !== null ? t.style.cursor = e : t.style.removeProperty("cursor");
|
|
200
|
-
}, he = (t) => {
|
|
201
|
-
var g, f, x, y, p, S;
|
|
202
|
-
const e = ((g = t == null ? void 0 : t.events) == null ? void 0 : g.onNodeDrag) ?? (() => {
|
|
203
|
-
}), o = ((f = t == null ? void 0 : t.events) == null ? void 0 : f.onBeforeNodeDrag) ?? (() => !0), r = ((x = t == null ? void 0 : t.events) == null ? void 0 : x.onNodeDragFinished) ?? (() => {
|
|
204
|
-
}), s = (t == null ? void 0 : t.moveOnTop) === !1, d = (y = t == null ? void 0 : t.mouse) == null ? void 0 : y.dragCursor, n = d !== void 0 ? d : "grab", h = (p = t == null ? void 0 : t.mouse) == null ? void 0 : p.mouseDownEventVerifier, c = h !== void 0 ? h : (N) => N.button === 0, a = (S = t == null ? void 0 : t.mouse) == null ? void 0 : S.mouseUpEventVerifier;
|
|
205
|
-
return {
|
|
206
|
-
freezePriority: s,
|
|
207
|
-
dragCursor: n,
|
|
208
|
-
mouseDownEventVerifier: c,
|
|
209
|
-
mouseUpEventVerifier: a !== void 0 ? a : (N) => N.button === 0,
|
|
210
|
-
onNodeDrag: e,
|
|
211
|
-
onBeforeNodeDrag: o,
|
|
212
|
-
onNodeDragFinished: r
|
|
213
|
-
};
|
|
214
|
-
};
|
|
215
|
-
class de {
|
|
216
|
-
constructor(e, o, r) {
|
|
217
|
-
i(this, "graph");
|
|
218
|
-
i(this, "viewport");
|
|
219
|
-
i(this, "maxNodePriority", 0);
|
|
220
|
-
i(this, "nodes", /* @__PURE__ */ new Map());
|
|
221
|
-
i(this, "grabbedNodeId", null);
|
|
222
|
-
i(this, "onWindowMouseMove", (e) => {
|
|
223
|
-
if (!U(this.element, e.clientX, e.clientY) || !$(this.window, e.clientX, e.clientY)) {
|
|
224
|
-
this.cancelMouseDrag();
|
|
225
|
-
return;
|
|
226
|
-
}
|
|
227
|
-
this.grabbedNodeId !== null && this.dragNode(this.grabbedNodeId, e.movementX, e.movementY);
|
|
228
|
-
});
|
|
229
|
-
i(this, "onWindowMouseUp", (e) => {
|
|
230
|
-
this.options.mouseUpEventVerifier(e) && this.cancelMouseDrag();
|
|
231
|
-
});
|
|
232
|
-
i(this, "onWindowTouchMove", (e) => {
|
|
233
|
-
if (e.touches.length !== 1)
|
|
234
|
-
return;
|
|
235
|
-
const o = e.touches[0];
|
|
236
|
-
if (!U(this.element, o.clientX, o.clientY) || !$(this.window, o.clientX, o.clientY)) {
|
|
237
|
-
this.cancelTouchDrag();
|
|
238
|
-
return;
|
|
239
|
-
}
|
|
240
|
-
if (this.grabbedNodeId !== null && this.previousTouchCoords !== null) {
|
|
241
|
-
const r = o.clientX - this.previousTouchCoords.x, s = o.clientY - this.previousTouchCoords.y;
|
|
242
|
-
this.dragNode(this.grabbedNodeId, r, s), this.previousTouchCoords = {
|
|
243
|
-
x: e.touches[0].clientX,
|
|
244
|
-
y: e.touches[0].clientY
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
i(this, "onWindowTouchFinish", () => {
|
|
249
|
-
this.previousTouchCoords = null, this.cancelTouchDrag();
|
|
250
|
-
});
|
|
251
|
-
i(this, "previousTouchCoords", null);
|
|
252
|
-
i(this, "window", window);
|
|
253
|
-
i(this, "options");
|
|
254
|
-
this.canvas = e, this.element = o, this.viewport = this.canvas.viewport, this.graph = this.canvas.graph, this.options = he(r ?? {});
|
|
255
|
-
}
|
|
256
|
-
addNode(e) {
|
|
257
|
-
this.canvas.addNode(e), this.updateMaxNodePriority(e.id);
|
|
258
|
-
const o = (s) => {
|
|
259
|
-
if (!this.options.mouseDownEventVerifier(s))
|
|
260
|
-
return;
|
|
261
|
-
const d = this.graph.getNode(e.id);
|
|
262
|
-
this.options.onBeforeNodeDrag({
|
|
263
|
-
nodeId: e.id,
|
|
264
|
-
element: e.element,
|
|
265
|
-
x: d.x,
|
|
266
|
-
y: d.y
|
|
267
|
-
}) && (s.stopImmediatePropagation(), this.grabbedNodeId = e.id, R(this.element, this.options.dragCursor), this.moveNodeOnTop(e.id), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.window.addEventListener("mousemove", this.onWindowMouseMove));
|
|
268
|
-
}, r = (s) => {
|
|
269
|
-
if (s.touches.length !== 1)
|
|
270
|
-
return;
|
|
271
|
-
s.stopImmediatePropagation(), this.previousTouchCoords = {
|
|
272
|
-
x: s.touches[0].clientX,
|
|
273
|
-
y: s.touches[0].clientY
|
|
274
|
-
};
|
|
275
|
-
const d = this.graph.getNode(e.id);
|
|
276
|
-
this.options.onBeforeNodeDrag({
|
|
277
|
-
nodeId: e.id,
|
|
278
|
-
element: e.element,
|
|
279
|
-
x: d.x,
|
|
280
|
-
y: d.y
|
|
281
|
-
}) && (this.grabbedNodeId = e.id, this.moveNodeOnTop(e.id), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish));
|
|
282
|
-
};
|
|
283
|
-
this.nodes.set(e.id, {
|
|
284
|
-
element: e.element,
|
|
285
|
-
onMouseDown: o,
|
|
286
|
-
onTouchStart: r
|
|
287
|
-
}), e.element.addEventListener("mousedown", o), e.element.addEventListener("touchstart", r);
|
|
288
|
-
}
|
|
289
|
-
updateNode(e, o) {
|
|
290
|
-
this.canvas.updateNode(e, o), this.updateMaxNodePriority(e);
|
|
291
|
-
}
|
|
292
|
-
removeNode(e) {
|
|
293
|
-
const o = this.nodes.get(e);
|
|
294
|
-
o !== void 0 && (o.element.removeEventListener("mousedown", o.onMouseDown), o.element.removeEventListener("touchstart", o.onTouchStart)), this.nodes.delete(e), this.canvas.removeNode(e);
|
|
295
|
-
}
|
|
296
|
-
markPort(e) {
|
|
297
|
-
this.canvas.markPort(e);
|
|
298
|
-
}
|
|
299
|
-
updatePort(e, o) {
|
|
300
|
-
this.canvas.updatePort(e, o);
|
|
301
|
-
}
|
|
302
|
-
unmarkPort(e) {
|
|
303
|
-
this.canvas.unmarkPort(e);
|
|
304
|
-
}
|
|
305
|
-
addEdge(e) {
|
|
306
|
-
this.canvas.addEdge(e);
|
|
307
|
-
}
|
|
308
|
-
updateEdge(e, o) {
|
|
309
|
-
this.canvas.updateEdge(e, o);
|
|
310
|
-
}
|
|
311
|
-
removeEdge(e) {
|
|
312
|
-
this.canvas.removeEdge(e);
|
|
313
|
-
}
|
|
314
|
-
patchViewportMatrix(e) {
|
|
315
|
-
this.canvas.patchViewportMatrix(e);
|
|
316
|
-
}
|
|
317
|
-
patchContentMatrix(e) {
|
|
318
|
-
this.canvas.patchContentMatrix(e);
|
|
319
|
-
}
|
|
320
|
-
clear() {
|
|
321
|
-
this.canvas.clear(), this.nodes.forEach((e) => {
|
|
322
|
-
e.element.removeEventListener("mousedown", e.onMouseDown), e.element.removeEventListener("touchstart", e.onTouchStart);
|
|
323
|
-
}), this.nodes.clear(), this.maxNodePriority = 0;
|
|
324
|
-
}
|
|
325
|
-
destroy() {
|
|
326
|
-
this.clear(), this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.canvas.destroy();
|
|
327
|
-
}
|
|
328
|
-
dragNode(e, o, r) {
|
|
329
|
-
const s = this.graph.getNode(e);
|
|
330
|
-
if (s === null)
|
|
331
|
-
return;
|
|
332
|
-
const d = this.canvas.viewport.getContentMatrix(), n = d.scale * s.x + d.x, h = d.scale * s.y + d.y, c = n + o, a = h + r, l = this.canvas.viewport.getViewportMatrix(), g = l.scale * c + l.x, f = l.scale * a + l.y;
|
|
333
|
-
this.canvas.updateNode(e, { x: g, y: f }), this.options.onNodeDrag({
|
|
334
|
-
nodeId: e,
|
|
335
|
-
element: s.element,
|
|
336
|
-
x: g,
|
|
337
|
-
y: f
|
|
338
|
-
});
|
|
339
|
-
}
|
|
340
|
-
updateMaxNodePriority(e) {
|
|
341
|
-
const o = this.graph.getNode(e).priority;
|
|
342
|
-
this.maxNodePriority = Math.max(this.maxNodePriority, o);
|
|
343
|
-
}
|
|
344
|
-
moveNodeOnTop(e) {
|
|
345
|
-
if (this.options.freezePriority)
|
|
346
|
-
return;
|
|
347
|
-
this.maxNodePriority += 2, this.updateNode(e, { priority: this.maxNodePriority });
|
|
348
|
-
const o = this.maxNodePriority - 1;
|
|
349
|
-
this.graph.getNodeAdjacentEdgeIds(e).forEach((s) => {
|
|
350
|
-
this.updateEdge(s, { priority: o });
|
|
351
|
-
});
|
|
352
|
-
}
|
|
353
|
-
cancelMouseDrag() {
|
|
354
|
-
const e = this.graph.getNode(this.grabbedNodeId);
|
|
355
|
-
e !== null && this.options.onNodeDragFinished({
|
|
356
|
-
nodeId: this.grabbedNodeId,
|
|
357
|
-
element: e.element,
|
|
358
|
-
x: e.x,
|
|
359
|
-
y: e.y
|
|
360
|
-
}), this.grabbedNodeId = null, R(this.element, null), this.removeMouseDragListeners();
|
|
361
|
-
}
|
|
362
|
-
removeMouseDragListeners() {
|
|
363
|
-
this.window.removeEventListener("mouseup", this.onWindowMouseUp), this.window.removeEventListener("mousemove", this.onWindowMouseMove);
|
|
364
|
-
}
|
|
365
|
-
cancelTouchDrag() {
|
|
366
|
-
this.previousTouchCoords = null;
|
|
367
|
-
const e = this.graph.getNode(this.grabbedNodeId);
|
|
368
|
-
e !== null && this.options.onNodeDragFinished({
|
|
369
|
-
nodeId: this.grabbedNodeId,
|
|
370
|
-
element: e.element,
|
|
371
|
-
x: e.x,
|
|
372
|
-
y: e.y
|
|
373
|
-
}), this.grabbedNodeId = null, this.removeTouchDragListeners();
|
|
374
|
-
}
|
|
375
|
-
removeTouchDragListeners() {
|
|
376
|
-
this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
const ce = (t) => {
|
|
380
|
-
const e = t.minX !== null ? t.minX : -1 / 0, o = t.maxX !== null ? t.maxX : 1 / 0, r = t.minY !== null ? t.minY : -1 / 0, s = t.maxY !== null ? t.maxY : 1 / 0;
|
|
381
|
-
return (d) => {
|
|
382
|
-
let n = d.nextTransform.x, h = d.nextTransform.y;
|
|
383
|
-
n < e && n < d.prevTransform.x && (n = Math.min(d.prevTransform.x, e));
|
|
384
|
-
const c = d.canvasWidth * d.prevTransform.scale, a = o - c;
|
|
385
|
-
n > a && n > d.prevTransform.x && (n = Math.max(d.prevTransform.x, a)), h < r && h < d.prevTransform.y && (h = Math.min(d.prevTransform.y, r));
|
|
386
|
-
const l = d.canvasHeight * d.prevTransform.scale, g = s - l;
|
|
387
|
-
return h > g && h > d.prevTransform.y && (h = Math.max(d.prevTransform.y, g)), { scale: d.nextTransform.scale, x: n, y: h };
|
|
388
|
-
};
|
|
389
|
-
}, ae = (t) => {
|
|
390
|
-
const e = t.maxContentScale, o = t.minContentScale, r = e !== null ? 1 / e : 0, s = o !== null ? 1 / o : 1 / 0;
|
|
391
|
-
return (d) => {
|
|
392
|
-
const n = d.prevTransform, h = d.nextTransform;
|
|
393
|
-
let c = h.scale, a = h.x, l = h.y;
|
|
394
|
-
if (h.scale > s && h.scale > n.scale) {
|
|
395
|
-
c = Math.max(n.scale, s), a = n.x, l = n.y;
|
|
396
|
-
const g = (c - n.scale) / (h.scale - n.scale);
|
|
397
|
-
a = n.x + (h.x - n.x) * g, l = n.y + (h.y - n.y) * g;
|
|
398
|
-
}
|
|
399
|
-
if (h.scale < r && h.scale < n.scale) {
|
|
400
|
-
c = Math.min(n.scale, r), a = n.x, l = n.y;
|
|
401
|
-
const g = (c - n.scale) / (h.scale - n.scale);
|
|
402
|
-
a = n.x + (h.x - n.x) * g, l = n.y + (h.y - n.y) * g;
|
|
403
|
-
}
|
|
404
|
-
return {
|
|
405
|
-
scale: c,
|
|
406
|
-
x: a,
|
|
407
|
-
y: l
|
|
408
|
-
};
|
|
409
|
-
};
|
|
410
|
-
}, le = (t) => (e) => t.reduce(
|
|
411
|
-
(o, r) => r({
|
|
412
|
-
prevTransform: e.prevTransform,
|
|
413
|
-
nextTransform: o,
|
|
414
|
-
canvasWidth: e.canvasWidth,
|
|
415
|
-
canvasHeight: e.canvasHeight
|
|
416
|
-
}),
|
|
417
|
-
e.nextTransform
|
|
418
|
-
), Q = (t) => {
|
|
419
|
-
if (typeof t == "function")
|
|
420
|
-
return t;
|
|
421
|
-
switch (t.type) {
|
|
422
|
-
case "scale-limit":
|
|
423
|
-
return ae({
|
|
424
|
-
minContentScale: t.minContentScale ?? 0,
|
|
425
|
-
maxContentScale: t.maxContentScale ?? 1 / 0
|
|
426
|
-
});
|
|
427
|
-
case "shift-limit":
|
|
428
|
-
return ce({
|
|
429
|
-
minX: t.minX ?? -1 / 0,
|
|
430
|
-
maxX: t.maxX ?? 1 / 0,
|
|
431
|
-
minY: t.minY ?? -1 / 0,
|
|
432
|
-
maxY: t.maxY ?? 1 / 0
|
|
433
|
-
});
|
|
434
|
-
}
|
|
435
|
-
}, ge = (t) => {
|
|
436
|
-
var y, p, S, N, z, M, V, L, G, _, J, K;
|
|
437
|
-
const e = (y = t == null ? void 0 : t.scale) == null ? void 0 : y.mouseWheelSensitivity, o = e !== void 0 ? e : 1.2, r = t == null ? void 0 : t.transformPreprocessor;
|
|
438
|
-
let s;
|
|
439
|
-
r !== void 0 ? Array.isArray(r) ? s = le(
|
|
440
|
-
r.map(
|
|
441
|
-
(P) => Q(P)
|
|
442
|
-
)
|
|
443
|
-
) : s = Q(r) : s = (P) => P.nextTransform;
|
|
444
|
-
const d = ((p = t == null ? void 0 : t.shift) == null ? void 0 : p.cursor) !== void 0 ? t.shift.cursor : "grab", n = ((S = t == null ? void 0 : t.events) == null ? void 0 : S.onBeforeTransformChange) ?? (() => {
|
|
445
|
-
}), h = ((N = t == null ? void 0 : t.events) == null ? void 0 : N.onTransformChange) ?? (() => {
|
|
446
|
-
}), c = (z = t == null ? void 0 : t.shift) == null ? void 0 : z.mouseDownEventVerifier, a = c !== void 0 ? c : (P) => P.button === 0, l = (M = t == null ? void 0 : t.shift) == null ? void 0 : M.mouseUpEventVerifier, g = l !== void 0 ? l : (P) => P.button === 0, f = (V = t == null ? void 0 : t.scale) == null ? void 0 : V.mouseWheelEventVerifier, x = f !== void 0 ? f : () => !0;
|
|
447
|
-
return {
|
|
448
|
-
wheelSensitivity: o,
|
|
449
|
-
onTransformStarted: ((L = t == null ? void 0 : t.events) == null ? void 0 : L.onTransformStarted) ?? (() => {
|
|
450
|
-
}),
|
|
451
|
-
onTransformFinished: ((G = t == null ? void 0 : t.events) == null ? void 0 : G.onTransformFinished) ?? (() => {
|
|
452
|
-
}),
|
|
453
|
-
onBeforeTransformChange: n,
|
|
454
|
-
onTransformChange: h,
|
|
455
|
-
transformPreprocessor: s,
|
|
456
|
-
shiftCursor: d,
|
|
457
|
-
mouseDownEventVerifier: a,
|
|
458
|
-
mouseUpEventVerifier: g,
|
|
459
|
-
mouseWheelEventVerifier: x,
|
|
460
|
-
scaleWheelFinishTimeout: ((_ = t == null ? void 0 : t.scale) == null ? void 0 : _.wheelFinishTimeout) ?? 500,
|
|
461
|
-
onResizeTransformStarted: ((J = t == null ? void 0 : t.events) == null ? void 0 : J.onResizeTransformStarted) ?? (() => {
|
|
462
|
-
}),
|
|
463
|
-
onResizeTransformFinished: ((K = t == null ? void 0 : t.events) == null ? void 0 : K.onResizeTransformFinished) ?? (() => {
|
|
464
|
-
})
|
|
465
|
-
};
|
|
466
|
-
}, C = (t) => {
|
|
467
|
-
const e = [], o = t.touches.length;
|
|
468
|
-
for (let h = 0; h < o; h++)
|
|
469
|
-
e.push([t.touches[h].clientX, t.touches[h].clientY]);
|
|
470
|
-
const r = e.reduce(
|
|
471
|
-
(h, c) => [h[0] + c[0], h[1] + c[1]],
|
|
472
|
-
[0, 0]
|
|
473
|
-
), s = [r[0] / o, r[1] / o], n = e.map((h) => [h[0] - s[0], h[1] - s[1]]).reduce(
|
|
474
|
-
(h, c) => h + Math.sqrt(c[0] * c[0] + c[1] * c[1]),
|
|
475
|
-
0
|
|
476
|
-
);
|
|
477
|
-
return {
|
|
478
|
-
x: s[0],
|
|
479
|
-
y: s[1],
|
|
480
|
-
scale: n / o,
|
|
481
|
-
touchesCnt: o,
|
|
482
|
-
touches: e
|
|
483
|
-
};
|
|
484
|
-
}, ue = (t, e, o) => ({
|
|
485
|
-
scale: t.scale,
|
|
486
|
-
x: t.x + t.scale * e,
|
|
487
|
-
y: t.y + t.scale * o
|
|
488
|
-
}), we = (t, e, o, r) => ({
|
|
489
|
-
scale: t.scale * e,
|
|
490
|
-
x: t.scale * (1 - e) * o + t.x,
|
|
491
|
-
y: t.scale * (1 - e) * r + t.y
|
|
492
|
-
});
|
|
493
|
-
class ee {
|
|
494
|
-
constructor(e, o, r) {
|
|
495
|
-
i(this, "graph");
|
|
496
|
-
i(this, "viewport");
|
|
497
|
-
i(this, "prevTouches", null);
|
|
498
|
-
i(this, "window", window);
|
|
499
|
-
i(this, "wheelFinishTimer", null);
|
|
500
|
-
i(this, "onMouseDown", (e) => {
|
|
501
|
-
this.element === null || !this.options.mouseDownEventVerifier(e) || (R(this.element, this.options.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.options.onTransformStarted());
|
|
502
|
-
});
|
|
503
|
-
i(this, "onWindowMouseMove", (e) => {
|
|
504
|
-
if (this.element === null || !U(this.element, e.clientX, e.clientY) || !$(this.window, e.clientX, e.clientY)) {
|
|
505
|
-
this.stopMouseDrag();
|
|
506
|
-
return;
|
|
507
|
-
}
|
|
508
|
-
const o = -e.movementX, r = -e.movementY;
|
|
509
|
-
this.moveViewport(o, r);
|
|
510
|
-
});
|
|
511
|
-
i(this, "onWindowMouseUp", (e) => {
|
|
512
|
-
this.element === null || !this.options.mouseUpEventVerifier(e) || this.stopMouseDrag();
|
|
513
|
-
});
|
|
514
|
-
i(this, "onWheelScroll", (e) => {
|
|
515
|
-
if (!this.options.mouseWheelEventVerifier(e))
|
|
516
|
-
return;
|
|
517
|
-
e.preventDefault();
|
|
518
|
-
const { left: o, top: r } = this.element.getBoundingClientRect(), s = e.clientX - o, d = e.clientY - r, h = 1 / (e.deltaY < 0 ? this.options.wheelSensitivity : 1 / this.options.wheelSensitivity);
|
|
519
|
-
this.wheelFinishTimer === null && this.options.onTransformStarted(), this.scaleViewport(h, s, d), this.wheelFinishTimer !== null && clearTimeout(this.wheelFinishTimer), this.wheelFinishTimer = setTimeout(() => {
|
|
520
|
-
this.options.onTransformFinished(), this.wheelFinishTimer = null;
|
|
521
|
-
}, this.options.scaleWheelFinishTimeout);
|
|
522
|
-
});
|
|
523
|
-
i(this, "onTouchStart", (e) => {
|
|
524
|
-
if (this.prevTouches !== null) {
|
|
525
|
-
this.prevTouches = C(e);
|
|
526
|
-
return;
|
|
527
|
-
}
|
|
528
|
-
this.prevTouches = C(e), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish), this.options.onTransformStarted();
|
|
529
|
-
});
|
|
530
|
-
i(this, "onWindowTouchMove", (e) => {
|
|
531
|
-
const o = C(e);
|
|
532
|
-
if (!o.touches.every(
|
|
533
|
-
(s) => U(this.element, s[0], s[1]) && $(this.window, s[0], s[1])
|
|
534
|
-
)) {
|
|
535
|
-
this.stopTouchDrag();
|
|
536
|
-
return;
|
|
537
|
-
}
|
|
538
|
-
if ((o.touchesCnt === 1 || o.touchesCnt === 2) && this.moveViewport(
|
|
539
|
-
-(o.x - this.prevTouches.x),
|
|
540
|
-
-(o.y - this.prevTouches.y)
|
|
541
|
-
), o.touchesCnt === 2) {
|
|
542
|
-
const { left: s, top: d } = this.element.getBoundingClientRect(), n = this.prevTouches.x - s, h = this.prevTouches.y - d, a = 1 / (o.scale / this.prevTouches.scale);
|
|
543
|
-
this.scaleViewport(a, n, h);
|
|
544
|
-
}
|
|
545
|
-
this.prevTouches = o;
|
|
546
|
-
});
|
|
547
|
-
i(this, "onWindowTouchFinish", (e) => {
|
|
548
|
-
e.touches.length > 0 ? this.prevTouches = C(e) : this.stopTouchDrag();
|
|
549
|
-
});
|
|
550
|
-
i(this, "observer", new ResizeObserver(() => {
|
|
551
|
-
const e = this.canvas.viewport.getViewportMatrix(), { width: o, height: r } = this.element.getBoundingClientRect(), s = this.options.transformPreprocessor({
|
|
552
|
-
prevTransform: e,
|
|
553
|
-
nextTransform: e,
|
|
554
|
-
canvasWidth: o,
|
|
555
|
-
canvasHeight: r
|
|
556
|
-
});
|
|
557
|
-
this.options.onResizeTransformStarted(), this.canvas.patchViewportMatrix(s), this.options.onResizeTransformFinished();
|
|
558
|
-
}));
|
|
559
|
-
i(this, "options");
|
|
560
|
-
this.canvas = e, this.element = o, this.options = ge(r), this.viewport = this.canvas.viewport, this.graph = this.canvas.graph, this.observer.observe(this.element), this.element.addEventListener("mousedown", this.onMouseDown), this.element.addEventListener("wheel", this.onWheelScroll), this.element.addEventListener("touchstart", this.onTouchStart);
|
|
561
|
-
}
|
|
562
|
-
addNode(e) {
|
|
563
|
-
this.canvas.addNode(e);
|
|
564
|
-
}
|
|
565
|
-
updateNode(e, o) {
|
|
566
|
-
this.canvas.updateNode(e, o);
|
|
567
|
-
}
|
|
568
|
-
removeNode(e) {
|
|
569
|
-
this.canvas.removeNode(e);
|
|
570
|
-
}
|
|
571
|
-
markPort(e) {
|
|
572
|
-
this.canvas.markPort(e);
|
|
573
|
-
}
|
|
574
|
-
updatePort(e, o) {
|
|
575
|
-
this.canvas.updatePort(e, o);
|
|
576
|
-
}
|
|
577
|
-
unmarkPort(e) {
|
|
578
|
-
this.canvas.unmarkPort(e);
|
|
579
|
-
}
|
|
580
|
-
addEdge(e) {
|
|
581
|
-
this.canvas.addEdge(e);
|
|
582
|
-
}
|
|
583
|
-
updateEdge(e, o) {
|
|
584
|
-
this.canvas.updateEdge(e, o);
|
|
585
|
-
}
|
|
586
|
-
removeEdge(e) {
|
|
587
|
-
this.canvas.removeEdge(e);
|
|
588
|
-
}
|
|
589
|
-
patchViewportMatrix(e) {
|
|
590
|
-
this.canvas.patchViewportMatrix(e);
|
|
591
|
-
}
|
|
592
|
-
patchContentMatrix(e) {
|
|
593
|
-
this.canvas.patchContentMatrix(e);
|
|
594
|
-
}
|
|
595
|
-
clear() {
|
|
596
|
-
this.canvas.clear();
|
|
597
|
-
}
|
|
598
|
-
destroy() {
|
|
599
|
-
this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.observer.unobserve(this.element), this.element.removeEventListener("mousedown", this.onMouseDown), this.element.removeEventListener("wheel", this.onWheelScroll), this.element.removeEventListener("touchstart", this.onTouchStart), this.canvas.destroy();
|
|
600
|
-
}
|
|
601
|
-
moveViewport(e, o) {
|
|
602
|
-
const r = this.viewport.getViewportMatrix(), s = ue(r, e, o), { width: d, height: n } = this.element.getBoundingClientRect(), h = this.options.transformPreprocessor({
|
|
603
|
-
prevTransform: r,
|
|
604
|
-
nextTransform: s,
|
|
605
|
-
canvasWidth: d,
|
|
606
|
-
canvasHeight: n
|
|
607
|
-
});
|
|
608
|
-
this.performTransform(h);
|
|
609
|
-
}
|
|
610
|
-
scaleViewport(e, o, r) {
|
|
611
|
-
const s = this.canvas.viewport.getViewportMatrix(), d = we(s, e, o, r), { width: n, height: h } = this.element.getBoundingClientRect(), c = this.options.transformPreprocessor({
|
|
612
|
-
prevTransform: s,
|
|
613
|
-
nextTransform: d,
|
|
614
|
-
canvasWidth: n,
|
|
615
|
-
canvasHeight: h
|
|
616
|
-
});
|
|
617
|
-
this.performTransform(c);
|
|
618
|
-
}
|
|
619
|
-
stopMouseDrag() {
|
|
620
|
-
R(this.element, null), this.removeMouseDragListeners(), this.options.onTransformFinished();
|
|
621
|
-
}
|
|
622
|
-
removeMouseDragListeners() {
|
|
623
|
-
this.window.removeEventListener("mousemove", this.onWindowMouseMove), this.window.removeEventListener("mouseup", this.onWindowMouseUp);
|
|
624
|
-
}
|
|
625
|
-
stopTouchDrag() {
|
|
626
|
-
this.prevTouches = null, this.removeTouchDragListeners(), this.options.onTransformFinished();
|
|
627
|
-
}
|
|
628
|
-
removeTouchDragListeners() {
|
|
629
|
-
this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
|
|
630
|
-
}
|
|
631
|
-
performTransform(e) {
|
|
632
|
-
this.options.onBeforeTransformChange(), this.canvas.patchViewportMatrix(e), this.options.onTransformChange();
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
|
-
class fe {
|
|
636
|
-
constructor(e, o, r, s, d) {
|
|
637
|
-
i(this, "graph");
|
|
638
|
-
i(this, "viewport");
|
|
639
|
-
i(this, "canvas");
|
|
640
|
-
i(this, "canvasResizeObserver");
|
|
641
|
-
i(this, "window", window);
|
|
642
|
-
i(this, "nodeHorizontal");
|
|
643
|
-
i(this, "nodeVertical");
|
|
644
|
-
i(this, "viewportWidth", 0);
|
|
645
|
-
i(this, "viewportHeight", 0);
|
|
646
|
-
i(this, "viewportMatrix");
|
|
647
|
-
i(this, "loadedArea", {
|
|
648
|
-
xFrom: 1 / 0,
|
|
649
|
-
xTo: 1 / 0,
|
|
650
|
-
yFrom: 1 / 0,
|
|
651
|
-
yTo: 1 / 0
|
|
652
|
-
});
|
|
653
|
-
i(this, "updateLoadedArea", (e) => {
|
|
654
|
-
this.loadedArea = {
|
|
655
|
-
xFrom: e.x,
|
|
656
|
-
xTo: e.x + e.width,
|
|
657
|
-
yFrom: e.y,
|
|
658
|
-
yTo: e.y + e.height
|
|
659
|
-
};
|
|
660
|
-
});
|
|
661
|
-
var a, l;
|
|
662
|
-
this.trigger = o, this.virtualScrollOptions = s, this.element = d, this.nodeHorizontal = this.virtualScrollOptions.nodeContainingRadius.horizontal, this.nodeVertical = this.virtualScrollOptions.nodeContainingRadius.vertical, this.canvasResizeObserver = new this.window.ResizeObserver((g) => {
|
|
663
|
-
const f = g[0];
|
|
664
|
-
this.viewportWidth = f.contentRect.width, this.viewportHeight = f.contentRect.height, this.scheduleLoadAreaAroundViewport();
|
|
665
|
-
});
|
|
666
|
-
const n = ((a = r == null ? void 0 : r.events) == null ? void 0 : a.onTransformFinished) ?? (() => {
|
|
667
|
-
}), h = ((l = r == null ? void 0 : r.events) == null ? void 0 : l.onTransformChange) ?? (() => {
|
|
668
|
-
}), c = {
|
|
669
|
-
...r,
|
|
670
|
-
events: {
|
|
671
|
-
...r == null ? void 0 : r.events,
|
|
672
|
-
onTransformChange: () => {
|
|
673
|
-
const g = this.viewportMatrix;
|
|
674
|
-
this.viewportMatrix = this.canvas.viewport.getViewportMatrix(), g.scale !== this.viewportMatrix.scale && this.scheduleEnsureViewportAreaLoaded(), h();
|
|
675
|
-
},
|
|
676
|
-
onTransformFinished: () => {
|
|
677
|
-
this.scheduleLoadAreaAroundViewport(), n();
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
};
|
|
681
|
-
this.canvas = new ee(
|
|
682
|
-
e,
|
|
683
|
-
this.element,
|
|
684
|
-
c
|
|
685
|
-
), this.viewportMatrix = this.canvas.viewport.getViewportMatrix(), this.viewport = this.canvas.viewport, this.graph = this.canvas.graph, this.trigger.subscribe(this.updateLoadedArea), this.canvasResizeObserver.observe(this.element);
|
|
686
|
-
}
|
|
687
|
-
addNode(e) {
|
|
688
|
-
this.canvas.addNode(e);
|
|
689
|
-
}
|
|
690
|
-
updateNode(e, o) {
|
|
691
|
-
this.canvas.updateNode(e, o);
|
|
692
|
-
}
|
|
693
|
-
removeNode(e) {
|
|
694
|
-
this.canvas.removeNode(e);
|
|
695
|
-
}
|
|
696
|
-
markPort(e) {
|
|
697
|
-
this.canvas.markPort(e);
|
|
698
|
-
}
|
|
699
|
-
updatePort(e, o) {
|
|
700
|
-
this.canvas.updatePort(e, o);
|
|
701
|
-
}
|
|
702
|
-
unmarkPort(e) {
|
|
703
|
-
this.canvas.unmarkPort(e);
|
|
704
|
-
}
|
|
705
|
-
addEdge(e) {
|
|
706
|
-
this.canvas.addEdge(e);
|
|
707
|
-
}
|
|
708
|
-
updateEdge(e, o) {
|
|
709
|
-
this.canvas.updateEdge(e, o);
|
|
710
|
-
}
|
|
711
|
-
removeEdge(e) {
|
|
712
|
-
this.canvas.removeEdge(e);
|
|
713
|
-
}
|
|
714
|
-
patchViewportMatrix(e) {
|
|
715
|
-
this.canvas.patchViewportMatrix(e), this.viewportMatrix = this.canvas.viewport.getViewportMatrix(), this.loadAreaAroundViewport();
|
|
716
|
-
}
|
|
717
|
-
patchContentMatrix(e) {
|
|
718
|
-
this.canvas.patchContentMatrix(e), this.viewportMatrix = this.canvas.viewport.getViewportMatrix(), this.loadAreaAroundViewport();
|
|
719
|
-
}
|
|
720
|
-
clear() {
|
|
721
|
-
this.canvas.clear();
|
|
722
|
-
}
|
|
723
|
-
destroy() {
|
|
724
|
-
this.trigger.unsubscribe(this.updateLoadedArea), this.canvasResizeObserver.unobserve(this.element), this.canvas.destroy();
|
|
725
|
-
}
|
|
726
|
-
scheduleLoadAreaAroundViewport() {
|
|
727
|
-
setTimeout(() => {
|
|
728
|
-
this.loadAreaAroundViewport();
|
|
729
|
-
});
|
|
730
|
-
}
|
|
731
|
-
scheduleEnsureViewportAreaLoaded() {
|
|
732
|
-
const e = this.viewportWidth * this.viewportMatrix.scale, o = this.viewportHeight * this.viewportMatrix.scale, r = this.viewportMatrix.x - this.nodeHorizontal, s = this.viewportMatrix.y - this.nodeVertical, d = this.viewportMatrix.x + e + this.nodeHorizontal, n = this.viewportMatrix.y + o + this.nodeVertical;
|
|
733
|
-
this.loadedArea.xFrom < r && this.loadedArea.xTo > d && this.loadedArea.yFrom < s && this.loadedArea.yTo > n || this.scheduleLoadAreaAroundViewport();
|
|
734
|
-
}
|
|
735
|
-
loadAreaAroundViewport() {
|
|
736
|
-
const e = this.viewportWidth * this.viewportMatrix.scale, o = this.viewportHeight * this.viewportMatrix.scale, r = this.viewportMatrix.x - e - this.nodeHorizontal, s = this.viewportMatrix.y - o - this.nodeVertical, d = 3 * e + 2 * this.nodeHorizontal, n = 3 * o + 2 * this.nodeVertical;
|
|
737
|
-
this.trigger.emit({ x: r, y: s, width: d, height: n });
|
|
738
|
-
}
|
|
739
|
-
}
|
|
740
|
-
const ye = () => {
|
|
741
|
-
const t = document.createElement("div");
|
|
742
|
-
return t.style.width = "100%", t.style.height = "100%", t.style.position = "relative", t.style.overflow = "hidden", t;
|
|
743
|
-
}, ve = () => {
|
|
744
|
-
const t = document.createElement("div");
|
|
745
|
-
return t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.width = "0", t.style.height = "0", t;
|
|
746
|
-
}, xe = () => {
|
|
747
|
-
const t = document.createElement("div");
|
|
748
|
-
return t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.visibility = "hidden", t;
|
|
749
|
-
};
|
|
750
|
-
class Ee {
|
|
751
|
-
constructor(e, o, r) {
|
|
752
|
-
i(this, "host", ye());
|
|
753
|
-
i(this, "container", ve());
|
|
754
|
-
i(this, "nodeIdToWrapperElementMap", /* @__PURE__ */ new Map());
|
|
755
|
-
i(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
|
|
756
|
-
i(this, "applyTransform", () => {
|
|
757
|
-
const e = this.viewportStore.getContentMatrix();
|
|
758
|
-
this.container.style.transform = `matrix(${e.scale}, 0, 0, ${e.scale}, ${e.x}, ${e.y})`;
|
|
759
|
-
});
|
|
760
|
-
this.graphStore = e, this.viewportStore = o, this.element = r, this.element.appendChild(this.host), this.host.appendChild(this.container), this.viewportStore.onAfterUpdated.subscribe(this.applyTransform);
|
|
761
|
-
}
|
|
762
|
-
attachNode(e) {
|
|
763
|
-
const o = this.graphStore.getNode(e), r = xe();
|
|
764
|
-
r.appendChild(o.element), this.container.appendChild(r), this.nodeIdToWrapperElementMap.set(e, r), this.updateNodePosition(e), this.updateNodePriority(e), r.style.visibility = "visible";
|
|
765
|
-
}
|
|
766
|
-
detachNode(e) {
|
|
767
|
-
const o = this.nodeIdToWrapperElementMap.get(e);
|
|
768
|
-
o.removeChild(o.firstChild), this.container.removeChild(o), this.nodeIdToWrapperElementMap.delete(e);
|
|
769
|
-
}
|
|
770
|
-
attachEdge(e) {
|
|
771
|
-
const o = this.graphStore.getEdge(e).shape.svg;
|
|
772
|
-
this.edgeIdToElementMap.set(e, o), this.container.appendChild(o), this.renderEdge(e), this.updateEdgePriority(e);
|
|
773
|
-
}
|
|
774
|
-
detachEdge(e) {
|
|
775
|
-
const o = this.edgeIdToElementMap.get(e);
|
|
776
|
-
this.container.removeChild(o), this.edgeIdToElementMap.delete(e);
|
|
777
|
-
}
|
|
778
|
-
clear() {
|
|
779
|
-
this.edgeIdToElementMap.forEach((e, o) => {
|
|
780
|
-
this.detachEdge(o);
|
|
781
|
-
}), this.nodeIdToWrapperElementMap.forEach((e, o) => {
|
|
782
|
-
this.detachNode(o);
|
|
783
|
-
});
|
|
784
|
-
}
|
|
785
|
-
destroy() {
|
|
786
|
-
this.viewportStore.onAfterUpdated.unsubscribe(this.applyTransform), this.clear(), this.element.removeChild(this.host), this.host.removeChild(this.container);
|
|
787
|
-
}
|
|
788
|
-
updateNodePosition(e) {
|
|
789
|
-
const o = this.nodeIdToWrapperElementMap.get(e), r = this.graphStore.getNode(e), { width: s, height: d } = r.element.getBoundingClientRect(), n = this.viewportStore.getViewportMatrix().scale, h = r.centerFn(s, d), c = r.x - n * h.x, a = r.y - n * h.y;
|
|
790
|
-
o.style.transform = `translate(${c}px, ${a}px)`;
|
|
791
|
-
}
|
|
792
|
-
updateNodePriority(e) {
|
|
793
|
-
const o = this.graphStore.getNode(e), r = this.nodeIdToWrapperElementMap.get(e);
|
|
794
|
-
r.style.zIndex = `${o.priority}`;
|
|
795
|
-
}
|
|
796
|
-
updateEdgeShape(e) {
|
|
797
|
-
const o = this.edgeIdToElementMap.get(e);
|
|
798
|
-
this.container.removeChild(o);
|
|
799
|
-
const r = this.graphStore.getEdge(e);
|
|
800
|
-
this.edgeIdToElementMap.set(e, r.shape.svg), this.container.appendChild(r.shape.svg);
|
|
801
|
-
}
|
|
802
|
-
renderEdge(e) {
|
|
803
|
-
const o = this.graphStore.getEdge(e), r = this.graphStore.getPort(o.from), s = this.graphStore.getPort(o.to), d = r.element.getBoundingClientRect(), n = s.element.getBoundingClientRect(), h = this.host.getBoundingClientRect(), c = this.viewportStore.getViewportMatrix(), a = {
|
|
804
|
-
x: c.scale * (d.left - h.left) + c.x,
|
|
805
|
-
y: c.scale * (d.top - h.top) + c.y
|
|
806
|
-
}, l = {
|
|
807
|
-
x: c.scale * (n.left - h.left) + c.x,
|
|
808
|
-
y: c.scale * (n.top - h.top) + c.y
|
|
809
|
-
}, g = {
|
|
810
|
-
x: a.x,
|
|
811
|
-
y: a.y,
|
|
812
|
-
width: d.width * c.scale,
|
|
813
|
-
height: d.height * c.scale,
|
|
814
|
-
direction: r.direction,
|
|
815
|
-
portId: o.from,
|
|
816
|
-
nodeId: r.nodeId
|
|
817
|
-
}, f = {
|
|
818
|
-
x: l.x,
|
|
819
|
-
y: l.y,
|
|
820
|
-
width: n.width * c.scale,
|
|
821
|
-
height: n.height * c.scale,
|
|
822
|
-
direction: s.direction,
|
|
823
|
-
portId: o.to,
|
|
824
|
-
nodeId: s.nodeId
|
|
825
|
-
};
|
|
826
|
-
o.shape.render({
|
|
827
|
-
from: g,
|
|
828
|
-
to: f
|
|
829
|
-
});
|
|
830
|
-
}
|
|
831
|
-
updateEdgePriority(e) {
|
|
832
|
-
const o = this.graphStore.getEdge(e);
|
|
833
|
-
o.shape.svg.style.zIndex = `${o.priority}`;
|
|
834
|
-
}
|
|
835
|
-
}
|
|
836
|
-
class Ae {
|
|
837
|
-
constructor(e) {
|
|
838
|
-
i(this, "xFrom", 1 / 0);
|
|
839
|
-
i(this, "yFrom", 1 / 0);
|
|
840
|
-
i(this, "xTo", 1 / 0);
|
|
841
|
-
i(this, "yTo", 1 / 0);
|
|
842
|
-
this.graphStore = e;
|
|
843
|
-
}
|
|
844
|
-
setRenderingBox(e) {
|
|
845
|
-
this.xFrom = e.x, this.xTo = e.x + e.width, this.yFrom = e.y, this.yTo = e.y + e.height;
|
|
846
|
-
}
|
|
847
|
-
hasNode(e) {
|
|
848
|
-
const o = this.graphStore.getNode(e);
|
|
849
|
-
return o.x >= this.xFrom && o.x <= this.xTo && o.y >= this.yFrom && o.y <= this.yTo;
|
|
850
|
-
}
|
|
851
|
-
hasEdge(e) {
|
|
852
|
-
const o = this.graphStore.getEdge(e), r = this.graphStore.getPort(o.from).nodeId, s = this.graphStore.getPort(o.to).nodeId, d = this.graphStore.getNode(r), n = this.graphStore.getNode(s), h = Math.min(d.x, n.x), c = Math.max(d.x, n.x), a = Math.min(d.y, n.y), l = Math.max(d.y, n.y);
|
|
853
|
-
return h <= this.xTo && c >= this.xFrom && a <= this.yTo && l >= this.yFrom;
|
|
854
|
-
}
|
|
855
|
-
}
|
|
856
|
-
class Se {
|
|
857
|
-
constructor(e, o, r) {
|
|
858
|
-
i(this, "attachedNodes", /* @__PURE__ */ new Set());
|
|
859
|
-
i(this, "attachedEdges", /* @__PURE__ */ new Set());
|
|
860
|
-
i(this, "renderingBox");
|
|
861
|
-
i(this, "updateViewport", (e) => {
|
|
862
|
-
this.renderingBox.setRenderingBox(e);
|
|
863
|
-
const o = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set();
|
|
864
|
-
this.graphStore.getAllNodeIds().forEach((n) => {
|
|
865
|
-
const h = this.renderingBox.hasNode(n), c = this.attachedNodes.has(n);
|
|
866
|
-
h && !c ? o.add(n) : !h && c && r.add(n);
|
|
867
|
-
}), this.graphStore.getAllEdgeIds().forEach((n) => {
|
|
868
|
-
const h = this.renderingBox.hasEdge(n), c = this.attachedEdges.has(n), a = this.graphStore.getEdge(n), l = this.graphStore.getPort(a.from).nodeId, g = this.graphStore.getPort(a.to).nodeId;
|
|
869
|
-
h && (this.renderingBox.hasNode(l) || (o.add(l), r.delete(l)), this.renderingBox.hasNode(g) || (o.add(g), r.delete(g))), h && !c ? s.add(n) : !h && c && d.add(n);
|
|
870
|
-
}), d.forEach((n) => {
|
|
871
|
-
this.handleDetachEdge(n);
|
|
872
|
-
}), r.forEach((n) => {
|
|
873
|
-
this.handleDetachNode(n);
|
|
874
|
-
}), o.forEach((n) => {
|
|
875
|
-
this.attachedNodes.has(n) || this.handleAttachNode(n);
|
|
876
|
-
}), s.forEach((n) => {
|
|
877
|
-
this.handleAttachEdge(n);
|
|
878
|
-
});
|
|
879
|
-
});
|
|
880
|
-
this.htmlView = e, this.graphStore = o, this.trigger = r, this.renderingBox = new Ae(this.graphStore), this.trigger.subscribe(this.updateViewport);
|
|
881
|
-
}
|
|
882
|
-
attachNode(e) {
|
|
883
|
-
this.renderingBox.hasNode(e) && this.handleAttachNode(e);
|
|
884
|
-
}
|
|
885
|
-
detachNode(e) {
|
|
886
|
-
this.attachedNodes.has(e) && this.handleDetachNode(e);
|
|
887
|
-
}
|
|
888
|
-
attachEdge(e) {
|
|
889
|
-
this.renderingBox.hasEdge(e) && this.attachEdgeEntities(e);
|
|
890
|
-
}
|
|
891
|
-
detachEdge(e) {
|
|
892
|
-
this.attachedEdges.has(e) && this.handleDetachEdge(e);
|
|
893
|
-
}
|
|
894
|
-
updateNodePosition(e) {
|
|
895
|
-
this.attachedNodes.has(e) ? this.htmlView.updateNodePosition(e) : this.renderingBox.hasNode(e) && (this.handleAttachNode(e), this.graphStore.getNodeAdjacentEdgeIds(e).forEach((o) => {
|
|
896
|
-
this.attachEdgeEntities(o);
|
|
897
|
-
}));
|
|
898
|
-
}
|
|
899
|
-
updateNodePriority(e) {
|
|
900
|
-
this.attachedNodes.has(e) && this.htmlView.updateNodePriority(e);
|
|
901
|
-
}
|
|
902
|
-
updateEdgeShape(e) {
|
|
903
|
-
this.attachedEdges.has(e) && this.htmlView.updateEdgeShape(e);
|
|
904
|
-
}
|
|
905
|
-
renderEdge(e) {
|
|
906
|
-
this.attachedEdges.has(e) && this.htmlView.renderEdge(e);
|
|
907
|
-
}
|
|
908
|
-
updateEdgePriority(e) {
|
|
909
|
-
this.attachedEdges.has(e) && this.htmlView.updateEdgePriority(e);
|
|
910
|
-
}
|
|
911
|
-
clear() {
|
|
912
|
-
this.htmlView.clear(), this.attachedNodes.clear(), this.attachedEdges.clear();
|
|
913
|
-
}
|
|
914
|
-
destroy() {
|
|
915
|
-
this.clear(), this.htmlView.destroy(), this.trigger.unsubscribe(this.updateViewport);
|
|
916
|
-
}
|
|
917
|
-
attachEdgeEntities(e) {
|
|
918
|
-
const o = this.graphStore.getEdge(e), r = this.graphStore.getPort(o.from).nodeId, s = this.graphStore.getPort(o.to).nodeId;
|
|
919
|
-
this.attachedNodes.has(r) || this.handleAttachNode(r), this.attachedNodes.has(s) || this.handleAttachNode(s), this.handleAttachEdge(e);
|
|
920
|
-
}
|
|
921
|
-
handleAttachNode(e) {
|
|
922
|
-
this.attachedNodes.add(e), this.htmlView.attachNode(e);
|
|
923
|
-
}
|
|
924
|
-
handleDetachNode(e) {
|
|
925
|
-
this.htmlView.detachNode(e), this.attachedNodes.delete(e);
|
|
926
|
-
}
|
|
927
|
-
handleAttachEdge(e) {
|
|
928
|
-
this.attachedEdges.add(e), this.htmlView.attachEdge(e);
|
|
929
|
-
}
|
|
930
|
-
handleDetachEdge(e) {
|
|
931
|
-
this.htmlView.detachEdge(e), this.attachedEdges.delete(e);
|
|
932
|
-
}
|
|
933
|
-
}
|
|
934
|
-
class te {
|
|
935
|
-
constructor() {
|
|
936
|
-
i(this, "callbacks", /* @__PURE__ */ new Set());
|
|
937
|
-
}
|
|
938
|
-
subscribe(e) {
|
|
939
|
-
this.callbacks.add(e);
|
|
940
|
-
}
|
|
941
|
-
unsubscribe(e) {
|
|
942
|
-
this.callbacks.delete(e);
|
|
943
|
-
}
|
|
944
|
-
emit(e) {
|
|
945
|
-
this.callbacks.forEach((o) => {
|
|
946
|
-
o(e);
|
|
947
|
-
});
|
|
948
|
-
}
|
|
949
|
-
}
|
|
950
|
-
const E = () => {
|
|
951
|
-
const t = new te();
|
|
952
|
-
return [t, t];
|
|
953
|
-
};
|
|
954
|
-
class Y {
|
|
955
|
-
constructor(e) {
|
|
956
|
-
i(this, "counter", 0);
|
|
957
|
-
this.checkExists = e;
|
|
958
|
-
}
|
|
959
|
-
create(e) {
|
|
960
|
-
if (e !== void 0)
|
|
961
|
-
return e;
|
|
962
|
-
for (; this.checkExists(this.counter); )
|
|
963
|
-
this.counter++;
|
|
964
|
-
return this.counter;
|
|
965
|
-
}
|
|
966
|
-
reset() {
|
|
967
|
-
this.counter = 0;
|
|
968
|
-
}
|
|
969
|
-
}
|
|
970
|
-
class A extends Error {
|
|
323
|
+
class S extends Error {
|
|
971
324
|
constructor() {
|
|
972
325
|
super(...arguments);
|
|
973
326
|
i(this, "name", "HtmlGraphError");
|
|
974
327
|
}
|
|
975
328
|
}
|
|
976
|
-
const
|
|
329
|
+
const we = (t, e) => ({
|
|
977
330
|
x: t / 2,
|
|
978
331
|
y: e / 2
|
|
979
|
-
}), k = (t) => () => t,
|
|
332
|
+
}), k = (t) => () => t, O = k(0), fe = () => {
|
|
980
333
|
let t = 0;
|
|
981
334
|
return () => t++;
|
|
982
|
-
},
|
|
983
|
-
let o =
|
|
984
|
-
const s =
|
|
335
|
+
}, ye = (t, e) => {
|
|
336
|
+
let o = O, r = O;
|
|
337
|
+
const s = fe();
|
|
985
338
|
return t === "incremental" && (o = s), e === "incremental" && (r = s), typeof t == "number" && (o = k(t)), typeof e == "number" && (r = k(e)), typeof t == "function" && (o = t), typeof e == "function" && (r = e), {
|
|
986
339
|
nodesPriorityFn: o,
|
|
987
340
|
edgesPriorityFn: r
|
|
988
341
|
};
|
|
989
|
-
},
|
|
342
|
+
}, x = (t, e, o) => ({
|
|
990
343
|
x: e.x * t.x - e.y * t.y + ((1 - e.x) * o.x + e.y * o.y),
|
|
991
344
|
y: e.y * t.x + e.x * t.y + ((1 - e.x) * o.y - e.y * o.x)
|
|
992
|
-
}),
|
|
345
|
+
}), b = (t, e, o) => ({ x: e * Math.cos(t), y: o * Math.sin(t) }), w = {
|
|
993
346
|
x: 0,
|
|
994
347
|
y: 0
|
|
995
|
-
},
|
|
348
|
+
}, N = (t, e, o, r) => {
|
|
996
349
|
const d = [
|
|
997
350
|
w,
|
|
998
351
|
{ x: o, y: r },
|
|
999
352
|
{ x: o, y: -r }
|
|
1000
|
-
].map((a) =>
|
|
353
|
+
].map((a) => x(a, t, w)).map((a) => ({ x: a.x + e.x, y: a.y + e.y })), n = `M ${d[0].x} ${d[0].y}`, h = `L ${d[1].x} ${d[1].y}`, c = `L ${d[2].x} ${d[2].y}`;
|
|
1001
354
|
return `${n} ${h} ${c}`;
|
|
1002
|
-
},
|
|
355
|
+
}, L = (t, e) => {
|
|
1003
356
|
const o = [];
|
|
1004
357
|
if (t.length > 0 && o.push(`M ${t[0].x} ${t[0].y}`), t.length === 2 && o.push(`L ${t[1].x} ${t[1].y}`), t.length > 2) {
|
|
1005
358
|
const r = t.length - 1;
|
|
1006
359
|
let s = 0, d = 0, n = 0;
|
|
1007
360
|
t.forEach((h, c) => {
|
|
1008
361
|
let a = 0, l = 0, g = 0;
|
|
1009
|
-
const f = c > 0,
|
|
1010
|
-
if (f && (a = -s, l = -d, g = n),
|
|
1011
|
-
const
|
|
1012
|
-
s =
|
|
362
|
+
const f = c > 0, v = c < r, y = f && v;
|
|
363
|
+
if (f && (a = -s, l = -d, g = n), v) {
|
|
364
|
+
const V = t[c + 1];
|
|
365
|
+
s = V.x - h.x, d = V.y - h.y, n = Math.sqrt(s * s + d * d);
|
|
1013
366
|
}
|
|
1014
|
-
const
|
|
1015
|
-
c > 0 && o.push(`L ${
|
|
1016
|
-
`C ${h.x} ${h.y} ${h.x} ${h.y} ${
|
|
367
|
+
const E = n !== 0 ? Math.min((y ? e : 0) / n, c < r - 1 ? 0.5 : 1) : 0, T = y ? { x: h.x + s * E, y: h.y + d * E } : h, D = g !== 0 ? Math.min((y ? e : 0) / g, c > 1 ? 0.5 : 1) : 0, M = y ? { x: h.x + a * D, y: h.y + l * D } : h;
|
|
368
|
+
c > 0 && o.push(`L ${M.x} ${M.y}`), y && o.push(
|
|
369
|
+
`C ${h.x} ${h.y} ${h.x} ${h.y} ${T.x} ${T.y}`
|
|
1017
370
|
);
|
|
1018
371
|
});
|
|
1019
372
|
}
|
|
1020
373
|
return o.join(" ");
|
|
1021
|
-
},
|
|
374
|
+
}, B = () => {
|
|
1022
375
|
const t = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
1023
376
|
return t.style.pointerEvents = "none", t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.overflow = "visible", t;
|
|
1024
|
-
},
|
|
377
|
+
}, $ = () => {
|
|
1025
378
|
const t = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
|
1026
379
|
return t.style.transformOrigin = "50% 50%", t;
|
|
1027
|
-
},
|
|
380
|
+
}, W = (t, e) => {
|
|
1028
381
|
const o = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
1029
382
|
return o.setAttribute("stroke", t), o.setAttribute("stroke-width", `${e}`), o.setAttribute("fill", "none"), o;
|
|
1030
|
-
},
|
|
383
|
+
}, m = (t) => {
|
|
1031
384
|
const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
1032
385
|
return e.setAttribute("fill", t), e;
|
|
1033
|
-
},
|
|
386
|
+
}, F = (t, e) => {
|
|
1034
387
|
const o = {
|
|
1035
388
|
x: t.x + t.width / 2,
|
|
1036
389
|
y: t.y + t.height / 2
|
|
@@ -1046,12 +399,12 @@ const pe = (t, e) => ({
|
|
|
1046
399
|
flipX: c,
|
|
1047
400
|
flipY: a
|
|
1048
401
|
};
|
|
1049
|
-
},
|
|
1050
|
-
const e =
|
|
402
|
+
}, ve = (t) => {
|
|
403
|
+
const e = x(
|
|
1051
404
|
{ x: t.arrowLength, y: w.y },
|
|
1052
405
|
t.fromVect,
|
|
1053
406
|
w
|
|
1054
|
-
), o =
|
|
407
|
+
), o = x(
|
|
1055
408
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
1056
409
|
t.toVect,
|
|
1057
410
|
t.to
|
|
@@ -1063,30 +416,30 @@ const pe = (t, e) => ({
|
|
|
1063
416
|
y: o.y - t.toVect.y * t.curvature
|
|
1064
417
|
}, d = `M ${e.x} ${e.y} C ${r.x} ${r.y}, ${s.x} ${s.y}, ${o.x} ${o.y}`, n = t.hasSourceArrow ? "" : `M ${w.x} ${w.y} L ${e.x} ${e.y} `, h = t.hasTargetArrow ? "" : ` M ${o.x} ${o.y} L ${t.to.x} ${t.to.y}`;
|
|
1065
418
|
return `${n}${d}${h}`;
|
|
1066
|
-
},
|
|
1067
|
-
const e = t.hasSourceArrow ?
|
|
419
|
+
}, xe = (t) => {
|
|
420
|
+
const e = t.hasSourceArrow ? x(
|
|
1068
421
|
{ x: t.arrowLength, y: w.y },
|
|
1069
422
|
t.fromVect,
|
|
1070
423
|
w
|
|
1071
|
-
) : w, o = t.hasTargetArrow ?
|
|
424
|
+
) : w, o = t.hasTargetArrow ? x(
|
|
1072
425
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
1073
426
|
t.toVect,
|
|
1074
427
|
t.to
|
|
1075
|
-
) : t.to, r = t.arrowLength, s = Math.cos(t.detourDirection) * t.detourDistance, d = Math.sin(t.detourDirection) * t.detourDistance, n = s * t.flipX, h = d * t.flipY, c =
|
|
428
|
+
) : t.to, r = t.arrowLength, s = Math.cos(t.detourDirection) * t.detourDistance, d = Math.sin(t.detourDirection) * t.detourDistance, n = s * t.flipX, h = d * t.flipY, c = x(
|
|
1076
429
|
{ x: r, y: w.y },
|
|
1077
430
|
t.fromVect,
|
|
1078
431
|
w
|
|
1079
432
|
), a = {
|
|
1080
433
|
x: c.x + n,
|
|
1081
434
|
y: c.y + h
|
|
1082
|
-
}, l =
|
|
435
|
+
}, l = x(
|
|
1083
436
|
{ x: t.to.x - r, y: t.to.y },
|
|
1084
437
|
t.toVect,
|
|
1085
438
|
t.to
|
|
1086
439
|
), g = {
|
|
1087
440
|
x: l.x + n,
|
|
1088
441
|
y: l.y + h
|
|
1089
|
-
}, f = { x: (a.x + g.x) / 2, y: (a.y + g.y) / 2 },
|
|
442
|
+
}, f = { x: (a.x + g.x) / 2, y: (a.y + g.y) / 2 }, v = {
|
|
1090
443
|
x: c.x + t.curvature * t.fromVect.x,
|
|
1091
444
|
y: c.y + t.curvature * t.fromVect.y
|
|
1092
445
|
}, y = {
|
|
@@ -1095,27 +448,27 @@ const pe = (t, e) => ({
|
|
|
1095
448
|
}, p = {
|
|
1096
449
|
x: c.x + n,
|
|
1097
450
|
y: c.y + h
|
|
1098
|
-
},
|
|
451
|
+
}, E = {
|
|
1099
452
|
x: l.x + n,
|
|
1100
453
|
y: l.y + h
|
|
1101
454
|
};
|
|
1102
455
|
return [
|
|
1103
456
|
`M ${e.x} ${e.y}`,
|
|
1104
457
|
`L ${c.x} ${c.y}`,
|
|
1105
|
-
`C ${
|
|
1106
|
-
`C ${
|
|
458
|
+
`C ${v.x} ${v.y} ${p.x} ${p.y} ${f.x} ${f.y}`,
|
|
459
|
+
`C ${E.x} ${E.y} ${y.x} ${y.y} ${l.x} ${l.y}`,
|
|
1107
460
|
`L ${o.x} ${o.y}`
|
|
1108
461
|
].join(" ");
|
|
1109
|
-
},
|
|
1110
|
-
const e = t.hasSourceArrow ?
|
|
462
|
+
}, Ae = (t) => {
|
|
463
|
+
const e = t.hasSourceArrow ? x(
|
|
1111
464
|
{ x: t.arrowLength, y: w.y },
|
|
1112
465
|
t.fromVect,
|
|
1113
466
|
w
|
|
1114
|
-
) : w, o = t.hasTargetArrow ?
|
|
467
|
+
) : w, o = t.hasTargetArrow ? x(
|
|
1115
468
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
1116
469
|
t.toVect,
|
|
1117
470
|
t.to
|
|
1118
|
-
) : t.to, r = t.arrowLength + t.arrowOffset, s = r - t.roundness, d =
|
|
471
|
+
) : t.to, r = t.arrowLength + t.arrowOffset, s = r - t.roundness, d = x({ x: s, y: w.y }, t.fromVect, w), n = x(
|
|
1119
472
|
{ x: t.to.x - s, y: t.to.y },
|
|
1120
473
|
t.toVect,
|
|
1121
474
|
t.to
|
|
@@ -1123,57 +476,57 @@ const pe = (t, e) => ({
|
|
|
1123
476
|
x: t.flipX > 0 ? t.to.x - h : t.to.x + r,
|
|
1124
477
|
y: n.y
|
|
1125
478
|
}, f = { x: g.x, y: c };
|
|
1126
|
-
return
|
|
479
|
+
return L(
|
|
1127
480
|
[e, d, a, l, f, g, n, o],
|
|
1128
481
|
t.roundness
|
|
1129
482
|
);
|
|
1130
|
-
},
|
|
1131
|
-
const e = t.hasSourceArrow ?
|
|
483
|
+
}, H = (t) => {
|
|
484
|
+
const e = t.hasSourceArrow ? x(
|
|
1132
485
|
{ x: t.arrowLength, y: w.y },
|
|
1133
486
|
t.fromVect,
|
|
1134
487
|
w
|
|
1135
|
-
) : w, o = t.hasTargetArrow ?
|
|
488
|
+
) : w, o = t.hasTargetArrow ? x(
|
|
1136
489
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
1137
490
|
t.toVect,
|
|
1138
491
|
t.to
|
|
1139
|
-
) : t.to, r = t.arrowLength + t.arrowOffset, s =
|
|
492
|
+
) : t.to, r = t.arrowLength + t.arrowOffset, s = x(
|
|
1140
493
|
{ x: r, y: w.y },
|
|
1141
494
|
t.fromVect,
|
|
1142
495
|
w
|
|
1143
|
-
), d = Math.cos(t.detourDirection) * t.detourDistance, n = Math.sin(t.detourDirection) * t.detourDistance, h = d * t.flipX, c = n * t.flipY, a = { x: s.x + h, y: s.y + c }, l =
|
|
496
|
+
), d = Math.cos(t.detourDirection) * t.detourDistance, n = Math.sin(t.detourDirection) * t.detourDistance, h = d * t.flipX, c = n * t.flipY, a = { x: s.x + h, y: s.y + c }, l = x(
|
|
1144
497
|
{ x: t.to.x - r, y: t.to.y },
|
|
1145
498
|
t.toVect,
|
|
1146
499
|
t.to
|
|
1147
500
|
), g = { x: l.x + h, y: l.y + c };
|
|
1148
|
-
return
|
|
501
|
+
return L(
|
|
1149
502
|
[e, s, a, g, l, o],
|
|
1150
503
|
t.roundness
|
|
1151
504
|
);
|
|
1152
|
-
},
|
|
1153
|
-
const e = t.hasSourceArrow ?
|
|
505
|
+
}, Ee = (t) => {
|
|
506
|
+
const e = t.hasSourceArrow ? x(
|
|
1154
507
|
{ x: t.arrowLength, y: w.y },
|
|
1155
508
|
t.fromVect,
|
|
1156
509
|
w
|
|
1157
|
-
) : w, o = t.hasTargetArrow ?
|
|
510
|
+
) : w, o = t.hasTargetArrow ? x(
|
|
1158
511
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
1159
512
|
t.toVect,
|
|
1160
513
|
t.to
|
|
1161
|
-
) : t.to, r = t.arrowLength + t.arrowOffset, s =
|
|
514
|
+
) : t.to, r = t.arrowLength + t.arrowOffset, s = x({ x: r, y: w.y }, t.fromVect, w), d = x(
|
|
1162
515
|
{ x: t.to.x - r, y: t.to.y },
|
|
1163
516
|
t.toVect,
|
|
1164
517
|
t.to
|
|
1165
518
|
);
|
|
1166
|
-
return
|
|
1167
|
-
},
|
|
1168
|
-
const e = t.hasSourceArrow ?
|
|
519
|
+
return L([e, s, d, o], t.roundness);
|
|
520
|
+
}, Se = (t) => {
|
|
521
|
+
const e = t.hasSourceArrow ? x(
|
|
1169
522
|
{ x: t.arrowLength, y: w.y },
|
|
1170
523
|
t.fromVect,
|
|
1171
524
|
w
|
|
1172
|
-
) : w, o = t.hasTargetArrow ?
|
|
525
|
+
) : w, o = t.hasTargetArrow ? x(
|
|
1173
526
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
1174
527
|
t.toVect,
|
|
1175
528
|
t.to
|
|
1176
|
-
) : t.to, r = t.arrowLength + t.arrowOffset, s = r - t.roundness, d =
|
|
529
|
+
) : t.to, r = t.arrowLength + t.arrowOffset, s = r - t.roundness, d = x({ x: s, y: w.y }, t.fromVect, w), n = x(
|
|
1177
530
|
{ x: t.to.x - s, y: t.to.y },
|
|
1178
531
|
t.toVect,
|
|
1179
532
|
t.to
|
|
@@ -1181,11 +534,11 @@ const pe = (t, e) => ({
|
|
|
1181
534
|
x: n.x,
|
|
1182
535
|
y: t.flipY > 0 ? t.to.y - h : t.to.y + r
|
|
1183
536
|
}, f = { x: c, y: g.y };
|
|
1184
|
-
return
|
|
537
|
+
return L(
|
|
1185
538
|
[e, d, a, l, f, g, n, o],
|
|
1186
539
|
t.roundness
|
|
1187
540
|
);
|
|
1188
|
-
},
|
|
541
|
+
}, j = (t) => {
|
|
1189
542
|
const e = t.arrowOffset, o = t.side, r = t.arrowLength + e, s = r + 2 * o, n = [
|
|
1190
543
|
{ x: t.arrowLength, y: w.y },
|
|
1191
544
|
{ x: r, y: w.y },
|
|
@@ -1196,15 +549,15 @@ const pe = (t, e) => ({
|
|
|
1196
549
|
{ x: r, y: w.y },
|
|
1197
550
|
{ x: t.arrowLength, y: w.y }
|
|
1198
551
|
].map(
|
|
1199
|
-
(c) =>
|
|
552
|
+
(c) => x(c, t.fromVect, w)
|
|
1200
553
|
), h = `M ${w.x} ${w.y} L ${n[0].x} ${n[0].y} `;
|
|
1201
|
-
return `${t.hasSourceArrow || t.hasTargetArrow ? "" : h}${
|
|
1202
|
-
},
|
|
554
|
+
return `${t.hasSourceArrow || t.hasTargetArrow ? "" : h}${L(n, t.roundness)}`;
|
|
555
|
+
}, pe = (t) => {
|
|
1203
556
|
const e = t.smallRadius, o = t.radius, r = Math.sqrt(e * e + o * o), s = e + o, d = t.arrowLength + r * (1 - o / s), n = e * o / s, c = [
|
|
1204
557
|
{ x: t.arrowLength, y: w.y },
|
|
1205
558
|
{ x: d, y: n },
|
|
1206
559
|
{ x: d, y: -n }
|
|
1207
|
-
].map((g) =>
|
|
560
|
+
].map((g) => x(g, t.fromVect, w)), a = [
|
|
1208
561
|
`M ${c[0].x} ${c[0].y}`,
|
|
1209
562
|
`A ${e} ${e} 0 0 1 ${c[1].x} ${c[1].y}`,
|
|
1210
563
|
`A ${o} ${o} 0 1 0 ${c[2].x} ${c[2].y}`,
|
|
@@ -1228,10 +581,10 @@ const pe = (t, e) => ({
|
|
|
1228
581
|
smallCycleRadius: 15,
|
|
1229
582
|
curvature: 90
|
|
1230
583
|
});
|
|
1231
|
-
class
|
|
584
|
+
class Te {
|
|
1232
585
|
constructor(e) {
|
|
1233
|
-
i(this, "svg",
|
|
1234
|
-
i(this, "group",
|
|
586
|
+
i(this, "svg", B());
|
|
587
|
+
i(this, "group", $());
|
|
1235
588
|
i(this, "line");
|
|
1236
589
|
i(this, "sourceArrow", null);
|
|
1237
590
|
i(this, "targetArrow", null);
|
|
@@ -1246,31 +599,31 @@ class De {
|
|
|
1246
599
|
i(this, "hasTargetArrow");
|
|
1247
600
|
this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.curvature = (e == null ? void 0 : e.curvature) ?? u.curvature, this.portCycleRadius = (e == null ? void 0 : e.cycleRadius) ?? u.cycleRadius, this.portCycleSmallRadius = (e == null ? void 0 : e.smallCycleRadius) ?? u.smallCycleRadius, this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow;
|
|
1248
601
|
const o = (e == null ? void 0 : e.color) ?? u.color, r = (e == null ? void 0 : e.width) ?? u.width;
|
|
1249
|
-
this.svg.appendChild(this.group), this.line =
|
|
602
|
+
this.svg.appendChild(this.group), this.line = W(o, r), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = m(o), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = m(o), this.group.appendChild(this.targetArrow));
|
|
1250
603
|
}
|
|
1251
604
|
render(e) {
|
|
1252
|
-
const { x: o, y: r, width: s, height: d, flipX: n, flipY: h } =
|
|
605
|
+
const { x: o, y: r, width: s, height: d, flipX: n, flipY: h } = F(
|
|
1253
606
|
e.from,
|
|
1254
607
|
e.to
|
|
1255
608
|
);
|
|
1256
609
|
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${s}px`, this.svg.style.height = `${d}px`, this.group.style.transform = `scale(${n}, ${h})`;
|
|
1257
|
-
const c =
|
|
610
|
+
const c = b(
|
|
1258
611
|
e.from.direction,
|
|
1259
612
|
n,
|
|
1260
613
|
h
|
|
1261
|
-
), a =
|
|
614
|
+
), a = b(e.to.direction, n, h), l = {
|
|
1262
615
|
x: s,
|
|
1263
616
|
y: d
|
|
1264
617
|
};
|
|
1265
|
-
let g, f = a,
|
|
1266
|
-
if (e.from.portId === e.to.portId ? (g =
|
|
618
|
+
let g, f = a, v = -this.arrowLength;
|
|
619
|
+
if (e.from.portId === e.to.portId ? (g = pe({
|
|
1267
620
|
fromVect: c,
|
|
1268
621
|
radius: this.portCycleRadius,
|
|
1269
622
|
smallRadius: this.portCycleSmallRadius,
|
|
1270
623
|
arrowLength: this.arrowLength,
|
|
1271
624
|
hasSourceArrow: this.hasSourceArrow,
|
|
1272
625
|
hasTargetArrow: this.hasTargetArrow
|
|
1273
|
-
}), f = c,
|
|
626
|
+
}), f = c, v = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = xe({
|
|
1274
627
|
to: l,
|
|
1275
628
|
fromVect: c,
|
|
1276
629
|
toVect: a,
|
|
@@ -1282,7 +635,7 @@ class De {
|
|
|
1282
635
|
curvature: this.curvature,
|
|
1283
636
|
hasSourceArrow: this.hasSourceArrow,
|
|
1284
637
|
hasTargetArrow: this.hasTargetArrow
|
|
1285
|
-
}) : g =
|
|
638
|
+
}) : g = ve({
|
|
1286
639
|
to: l,
|
|
1287
640
|
fromVect: c,
|
|
1288
641
|
toVect: a,
|
|
@@ -1291,7 +644,7 @@ class De {
|
|
|
1291
644
|
hasSourceArrow: this.hasSourceArrow,
|
|
1292
645
|
hasTargetArrow: this.hasTargetArrow
|
|
1293
646
|
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
1294
|
-
const y =
|
|
647
|
+
const y = N(
|
|
1295
648
|
c,
|
|
1296
649
|
w,
|
|
1297
650
|
this.arrowLength,
|
|
@@ -1300,20 +653,20 @@ class De {
|
|
|
1300
653
|
this.sourceArrow.setAttribute("d", y);
|
|
1301
654
|
}
|
|
1302
655
|
if (this.targetArrow) {
|
|
1303
|
-
const y =
|
|
656
|
+
const y = N(
|
|
1304
657
|
f,
|
|
1305
658
|
l,
|
|
1306
|
-
|
|
659
|
+
v,
|
|
1307
660
|
this.arrowWidth
|
|
1308
661
|
);
|
|
1309
662
|
this.targetArrow.setAttribute("d", y);
|
|
1310
663
|
}
|
|
1311
664
|
}
|
|
1312
665
|
}
|
|
1313
|
-
class
|
|
666
|
+
class be {
|
|
1314
667
|
constructor(e) {
|
|
1315
|
-
i(this, "svg",
|
|
1316
|
-
i(this, "group",
|
|
668
|
+
i(this, "svg", B());
|
|
669
|
+
i(this, "group", $());
|
|
1317
670
|
i(this, "line");
|
|
1318
671
|
i(this, "sourceArrow", null);
|
|
1319
672
|
i(this, "targetArrow", null);
|
|
@@ -1334,24 +687,24 @@ class Ce {
|
|
|
1334
687
|
this.cycleSquareSide / 2
|
|
1335
688
|
), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow;
|
|
1336
689
|
const r = (e == null ? void 0 : e.color) ?? u.color, s = (e == null ? void 0 : e.width) ?? u.width;
|
|
1337
|
-
this.svg.appendChild(this.group), this.line =
|
|
690
|
+
this.svg.appendChild(this.group), this.line = W(r, s), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = m(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = m(r), this.group.appendChild(this.targetArrow));
|
|
1338
691
|
}
|
|
1339
692
|
render(e) {
|
|
1340
|
-
const { x: o, y: r, width: s, height: d, flipX: n, flipY: h } =
|
|
693
|
+
const { x: o, y: r, width: s, height: d, flipX: n, flipY: h } = F(
|
|
1341
694
|
e.from,
|
|
1342
695
|
e.to
|
|
1343
696
|
);
|
|
1344
697
|
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${s}px`, this.svg.style.height = `${d}px`, this.group.style.transform = `scale(${n}, ${h})`;
|
|
1345
|
-
const c =
|
|
698
|
+
const c = b(
|
|
1346
699
|
e.from.direction,
|
|
1347
700
|
n,
|
|
1348
701
|
h
|
|
1349
|
-
), a =
|
|
702
|
+
), a = b(e.to.direction, n, h), l = {
|
|
1350
703
|
x: s,
|
|
1351
704
|
y: d
|
|
1352
705
|
};
|
|
1353
|
-
let g, f = a,
|
|
1354
|
-
if (e.from.portId === e.to.portId ? (g =
|
|
706
|
+
let g, f = a, v = -this.arrowLength;
|
|
707
|
+
if (e.from.portId === e.to.portId ? (g = j({
|
|
1355
708
|
fromVect: c,
|
|
1356
709
|
arrowLength: this.arrowLength,
|
|
1357
710
|
side: this.cycleSquareSide,
|
|
@@ -1359,7 +712,7 @@ class Ce {
|
|
|
1359
712
|
roundness: this.roundness,
|
|
1360
713
|
hasSourceArrow: this.hasSourceArrow,
|
|
1361
714
|
hasTargetArrow: this.hasTargetArrow
|
|
1362
|
-
}), f = c,
|
|
715
|
+
}), f = c, v = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = H({
|
|
1363
716
|
to: l,
|
|
1364
717
|
fromVect: c,
|
|
1365
718
|
toVect: a,
|
|
@@ -1372,7 +725,7 @@ class Ce {
|
|
|
1372
725
|
detourDistance: this.detourDistance,
|
|
1373
726
|
hasSourceArrow: this.hasSourceArrow,
|
|
1374
727
|
hasTargetArrow: this.hasTargetArrow
|
|
1375
|
-
}) : g =
|
|
728
|
+
}) : g = Ae({
|
|
1376
729
|
to: l,
|
|
1377
730
|
fromVect: c,
|
|
1378
731
|
toVect: a,
|
|
@@ -1383,7 +736,7 @@ class Ce {
|
|
|
1383
736
|
hasSourceArrow: this.hasSourceArrow,
|
|
1384
737
|
hasTargetArrow: this.hasTargetArrow
|
|
1385
738
|
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
1386
|
-
const y =
|
|
739
|
+
const y = N(
|
|
1387
740
|
c,
|
|
1388
741
|
w,
|
|
1389
742
|
this.arrowLength,
|
|
@@ -1392,20 +745,20 @@ class Ce {
|
|
|
1392
745
|
this.sourceArrow.setAttribute("d", y);
|
|
1393
746
|
}
|
|
1394
747
|
if (this.targetArrow) {
|
|
1395
|
-
const y =
|
|
748
|
+
const y = N(
|
|
1396
749
|
f,
|
|
1397
750
|
l,
|
|
1398
|
-
|
|
751
|
+
v,
|
|
1399
752
|
this.arrowWidth
|
|
1400
753
|
);
|
|
1401
754
|
this.targetArrow.setAttribute("d", y);
|
|
1402
755
|
}
|
|
1403
756
|
}
|
|
1404
757
|
}
|
|
1405
|
-
class
|
|
758
|
+
class Ne {
|
|
1406
759
|
constructor(e) {
|
|
1407
|
-
i(this, "svg",
|
|
1408
|
-
i(this, "group",
|
|
760
|
+
i(this, "svg", B());
|
|
761
|
+
i(this, "group", $());
|
|
1409
762
|
i(this, "line");
|
|
1410
763
|
i(this, "sourceArrow", null);
|
|
1411
764
|
i(this, "targetArrow", null);
|
|
@@ -1426,24 +779,24 @@ class Ue {
|
|
|
1426
779
|
this.cycleSquareSide / 2
|
|
1427
780
|
), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow;
|
|
1428
781
|
const r = (e == null ? void 0 : e.color) ?? u.color, s = (e == null ? void 0 : e.width) ?? u.width;
|
|
1429
|
-
this.svg.appendChild(this.group), this.line =
|
|
782
|
+
this.svg.appendChild(this.group), this.line = W(r, s), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = m(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = m(r), this.group.appendChild(this.targetArrow));
|
|
1430
783
|
}
|
|
1431
784
|
render(e) {
|
|
1432
|
-
const { x: o, y: r, width: s, height: d, flipX: n, flipY: h } =
|
|
785
|
+
const { x: o, y: r, width: s, height: d, flipX: n, flipY: h } = F(
|
|
1433
786
|
e.from,
|
|
1434
787
|
e.to
|
|
1435
788
|
);
|
|
1436
789
|
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${s}px`, this.svg.style.height = `${d}px`, this.group.style.transform = `scale(${n}, ${h})`;
|
|
1437
|
-
const c =
|
|
790
|
+
const c = b(
|
|
1438
791
|
e.from.direction,
|
|
1439
792
|
n,
|
|
1440
793
|
h
|
|
1441
|
-
), a =
|
|
794
|
+
), a = b(e.to.direction, n, h), l = {
|
|
1442
795
|
x: s,
|
|
1443
796
|
y: d
|
|
1444
797
|
};
|
|
1445
|
-
let g, f = a,
|
|
1446
|
-
if (e.from.portId === e.to.portId ? (g =
|
|
798
|
+
let g, f = a, v = -this.arrowLength;
|
|
799
|
+
if (e.from.portId === e.to.portId ? (g = j({
|
|
1447
800
|
fromVect: c,
|
|
1448
801
|
arrowLength: this.arrowLength,
|
|
1449
802
|
side: this.cycleSquareSide,
|
|
@@ -1451,7 +804,7 @@ class Ue {
|
|
|
1451
804
|
roundness: this.roundness,
|
|
1452
805
|
hasSourceArrow: this.hasSourceArrow,
|
|
1453
806
|
hasTargetArrow: this.hasTargetArrow
|
|
1454
|
-
}), f = c,
|
|
807
|
+
}), f = c, v = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = H({
|
|
1455
808
|
to: l,
|
|
1456
809
|
fromVect: c,
|
|
1457
810
|
toVect: a,
|
|
@@ -1464,7 +817,7 @@ class Ue {
|
|
|
1464
817
|
detourDistance: this.detourDistance,
|
|
1465
818
|
hasSourceArrow: this.hasSourceArrow,
|
|
1466
819
|
hasTargetArrow: this.hasTargetArrow
|
|
1467
|
-
}) : g =
|
|
820
|
+
}) : g = Ee({
|
|
1468
821
|
to: l,
|
|
1469
822
|
fromVect: c,
|
|
1470
823
|
toVect: a,
|
|
@@ -1474,7 +827,7 @@ class Ue {
|
|
|
1474
827
|
hasSourceArrow: this.hasSourceArrow,
|
|
1475
828
|
hasTargetArrow: this.hasTargetArrow
|
|
1476
829
|
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
1477
|
-
const y =
|
|
830
|
+
const y = N(
|
|
1478
831
|
c,
|
|
1479
832
|
w,
|
|
1480
833
|
this.arrowLength,
|
|
@@ -1483,20 +836,20 @@ class Ue {
|
|
|
1483
836
|
this.sourceArrow.setAttribute("d", y);
|
|
1484
837
|
}
|
|
1485
838
|
if (this.targetArrow) {
|
|
1486
|
-
const y =
|
|
839
|
+
const y = N(
|
|
1487
840
|
f,
|
|
1488
841
|
l,
|
|
1489
|
-
|
|
842
|
+
v,
|
|
1490
843
|
this.arrowWidth
|
|
1491
844
|
);
|
|
1492
845
|
this.targetArrow.setAttribute("d", y);
|
|
1493
846
|
}
|
|
1494
847
|
}
|
|
1495
848
|
}
|
|
1496
|
-
class
|
|
849
|
+
class me {
|
|
1497
850
|
constructor(e) {
|
|
1498
|
-
i(this, "svg",
|
|
1499
|
-
i(this, "group",
|
|
851
|
+
i(this, "svg", B());
|
|
852
|
+
i(this, "group", $());
|
|
1500
853
|
i(this, "line");
|
|
1501
854
|
i(this, "sourceArrow", null);
|
|
1502
855
|
i(this, "targetArrow", null);
|
|
@@ -1517,24 +870,24 @@ class $e {
|
|
|
1517
870
|
this.cycleSquareSide / 2
|
|
1518
871
|
), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirectionVertical, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow;
|
|
1519
872
|
const r = (e == null ? void 0 : e.color) ?? u.color, s = (e == null ? void 0 : e.width) ?? u.width;
|
|
1520
|
-
this.svg.appendChild(this.group), this.line =
|
|
873
|
+
this.svg.appendChild(this.group), this.line = W(r, s), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = m(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = m(r), this.group.appendChild(this.targetArrow));
|
|
1521
874
|
}
|
|
1522
875
|
render(e) {
|
|
1523
|
-
const { x: o, y: r, width: s, height: d, flipX: n, flipY: h } =
|
|
876
|
+
const { x: o, y: r, width: s, height: d, flipX: n, flipY: h } = F(
|
|
1524
877
|
e.from,
|
|
1525
878
|
e.to
|
|
1526
879
|
);
|
|
1527
880
|
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${s}px`, this.svg.style.height = `${d}px`, this.group.style.transform = `scale(${n}, ${h})`;
|
|
1528
|
-
const c =
|
|
881
|
+
const c = b(
|
|
1529
882
|
e.from.direction,
|
|
1530
883
|
n,
|
|
1531
884
|
h
|
|
1532
|
-
), a =
|
|
885
|
+
), a = b(e.to.direction, n, h), l = {
|
|
1533
886
|
x: s,
|
|
1534
887
|
y: d
|
|
1535
888
|
};
|
|
1536
|
-
let g, f = a,
|
|
1537
|
-
if (e.from.portId === e.to.portId ? (g =
|
|
889
|
+
let g, f = a, v = -this.arrowLength;
|
|
890
|
+
if (e.from.portId === e.to.portId ? (g = j({
|
|
1538
891
|
fromVect: c,
|
|
1539
892
|
arrowLength: this.arrowLength,
|
|
1540
893
|
side: this.cycleSquareSide,
|
|
@@ -1542,7 +895,7 @@ class $e {
|
|
|
1542
895
|
roundness: this.roundness,
|
|
1543
896
|
hasSourceArrow: this.hasSourceArrow,
|
|
1544
897
|
hasTargetArrow: this.hasTargetArrow
|
|
1545
|
-
}), f = c,
|
|
898
|
+
}), f = c, v = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = H({
|
|
1546
899
|
to: l,
|
|
1547
900
|
fromVect: c,
|
|
1548
901
|
toVect: a,
|
|
@@ -1555,7 +908,7 @@ class $e {
|
|
|
1555
908
|
detourDistance: this.detourDistance,
|
|
1556
909
|
hasSourceArrow: this.hasSourceArrow,
|
|
1557
910
|
hasTargetArrow: this.hasTargetArrow
|
|
1558
|
-
}) : g =
|
|
911
|
+
}) : g = Se({
|
|
1559
912
|
to: l,
|
|
1560
913
|
fromVect: c,
|
|
1561
914
|
toVect: a,
|
|
@@ -1566,7 +919,7 @@ class $e {
|
|
|
1566
919
|
hasSourceArrow: this.hasSourceArrow,
|
|
1567
920
|
hasTargetArrow: this.hasTargetArrow
|
|
1568
921
|
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
1569
|
-
const y =
|
|
922
|
+
const y = N(
|
|
1570
923
|
c,
|
|
1571
924
|
w,
|
|
1572
925
|
this.arrowLength,
|
|
@@ -1575,22 +928,22 @@ class $e {
|
|
|
1575
928
|
this.sourceArrow.setAttribute("d", y);
|
|
1576
929
|
}
|
|
1577
930
|
if (this.targetArrow) {
|
|
1578
|
-
const y =
|
|
931
|
+
const y = N(
|
|
1579
932
|
f,
|
|
1580
933
|
l,
|
|
1581
|
-
|
|
934
|
+
v,
|
|
1582
935
|
this.arrowWidth
|
|
1583
936
|
);
|
|
1584
937
|
this.targetArrow.setAttribute("d", y);
|
|
1585
938
|
}
|
|
1586
939
|
}
|
|
1587
940
|
}
|
|
1588
|
-
const
|
|
941
|
+
const Pe = (t) => {
|
|
1589
942
|
if (typeof t == "function")
|
|
1590
943
|
return t;
|
|
1591
944
|
switch (t == null ? void 0 : t.type) {
|
|
1592
945
|
case "straight":
|
|
1593
|
-
return () => new
|
|
946
|
+
return () => new Ne({
|
|
1594
947
|
color: t.color,
|
|
1595
948
|
width: t.width,
|
|
1596
949
|
arrowLength: t.arrowLength,
|
|
@@ -1604,7 +957,7 @@ const Re = (t) => {
|
|
|
1604
957
|
detourDirection: t.detourDirection
|
|
1605
958
|
});
|
|
1606
959
|
case "horizontal":
|
|
1607
|
-
return () => new
|
|
960
|
+
return () => new be({
|
|
1608
961
|
color: t.color,
|
|
1609
962
|
width: t.width,
|
|
1610
963
|
arrowLength: t.arrowLength,
|
|
@@ -1618,7 +971,7 @@ const Re = (t) => {
|
|
|
1618
971
|
detourDirection: t.detourDirection
|
|
1619
972
|
});
|
|
1620
973
|
case "vertical":
|
|
1621
|
-
return () => new
|
|
974
|
+
return () => new me({
|
|
1622
975
|
color: t.color,
|
|
1623
976
|
width: t.width,
|
|
1624
977
|
arrowLength: t.arrowLength,
|
|
@@ -1632,7 +985,7 @@ const Re = (t) => {
|
|
|
1632
985
|
detourDirection: t.detourDirection
|
|
1633
986
|
});
|
|
1634
987
|
default:
|
|
1635
|
-
return () => new
|
|
988
|
+
return () => new Te({
|
|
1636
989
|
color: t.color,
|
|
1637
990
|
width: t.width,
|
|
1638
991
|
arrowLength: t.arrowLength,
|
|
@@ -1646,38 +999,28 @@ const Re = (t) => {
|
|
|
1646
999
|
detourDirection: t.detourDirection
|
|
1647
1000
|
});
|
|
1648
1001
|
}
|
|
1649
|
-
},
|
|
1002
|
+
}, De = (t) => {
|
|
1650
1003
|
var o, r, s, d, n;
|
|
1651
|
-
const e =
|
|
1004
|
+
const e = ye(
|
|
1652
1005
|
(o = t == null ? void 0 : t.nodes) == null ? void 0 : o.priority,
|
|
1653
1006
|
(r = t == null ? void 0 : t.edges) == null ? void 0 : r.priority
|
|
1654
1007
|
);
|
|
1655
1008
|
return {
|
|
1656
1009
|
nodes: {
|
|
1657
|
-
centerFn: ((s = t == null ? void 0 : t.nodes) == null ? void 0 : s.centerFn) ??
|
|
1010
|
+
centerFn: ((s = t == null ? void 0 : t.nodes) == null ? void 0 : s.centerFn) ?? we,
|
|
1658
1011
|
priorityFn: e.nodesPriorityFn
|
|
1659
1012
|
},
|
|
1660
1013
|
ports: {
|
|
1661
1014
|
direction: ((d = t == null ? void 0 : t.ports) == null ? void 0 : d.direction) ?? 0
|
|
1662
1015
|
},
|
|
1663
1016
|
edges: {
|
|
1664
|
-
shapeFactory:
|
|
1017
|
+
shapeFactory: Pe(((n = t == null ? void 0 : t.edges) == null ? void 0 : n.shape) ?? {}),
|
|
1665
1018
|
priorityFn: e.edgesPriorityFn
|
|
1666
1019
|
}
|
|
1667
1020
|
};
|
|
1668
1021
|
};
|
|
1669
|
-
class
|
|
1670
|
-
constructor(e, o, r) {
|
|
1671
|
-
i(this, "nodeIdGenerator", new Y(
|
|
1672
|
-
(e) => this.graph.getNode(e) !== null
|
|
1673
|
-
));
|
|
1674
|
-
i(this, "portIdGenerator", new Y(
|
|
1675
|
-
(e) => this.graph.getPort(e) !== null
|
|
1676
|
-
));
|
|
1677
|
-
i(this, "edgeIdGenerator", new Y(
|
|
1678
|
-
(e) => this.graph.getEdge(e) !== null
|
|
1679
|
-
));
|
|
1680
|
-
i(this, "defaults");
|
|
1022
|
+
class Me {
|
|
1023
|
+
constructor(e, o, r, s, d) {
|
|
1681
1024
|
/**
|
|
1682
1025
|
* provides api for accessing graph model
|
|
1683
1026
|
*/
|
|
@@ -1686,7 +1029,69 @@ class We {
|
|
|
1686
1029
|
* provides api for accessing viewport state
|
|
1687
1030
|
*/
|
|
1688
1031
|
i(this, "viewport");
|
|
1689
|
-
this
|
|
1032
|
+
i(this, "defaults");
|
|
1033
|
+
i(this, "nodeIdGenerator", new X(
|
|
1034
|
+
(e) => this.graph.getNode(e) !== null
|
|
1035
|
+
));
|
|
1036
|
+
i(this, "portIdGenerator", new X(
|
|
1037
|
+
(e) => this.graph.getPort(e) !== null
|
|
1038
|
+
));
|
|
1039
|
+
i(this, "edgeIdGenerator", new X(
|
|
1040
|
+
(e) => this.graph.getEdge(e) !== null
|
|
1041
|
+
));
|
|
1042
|
+
i(this, "onAfterNodeAdded", (e) => {
|
|
1043
|
+
this.htmlView.attachNode(e);
|
|
1044
|
+
});
|
|
1045
|
+
i(this, "onAfterNodeUpdated", (e) => {
|
|
1046
|
+
this.htmlView.updateNodePosition(e), this.graphStore.getNodeAdjacentEdgeIds(e).forEach((r) => {
|
|
1047
|
+
this.htmlView.renderEdge(r);
|
|
1048
|
+
});
|
|
1049
|
+
});
|
|
1050
|
+
i(this, "onAfterNodePriorityUpdated", (e) => {
|
|
1051
|
+
this.htmlView.updateNodePriority(e);
|
|
1052
|
+
});
|
|
1053
|
+
i(this, "onBeforeNodeRemoved", (e) => {
|
|
1054
|
+
this.graphStore.getNodePortIds(e).forEach((o) => {
|
|
1055
|
+
this.unmarkPort(o);
|
|
1056
|
+
}), this.htmlView.detachNode(e);
|
|
1057
|
+
});
|
|
1058
|
+
i(this, "onAfterPortUpdated", (e) => {
|
|
1059
|
+
this.graphStore.getPortAdjacentEdgeIds(e).forEach((r) => {
|
|
1060
|
+
this.htmlView.renderEdge(r);
|
|
1061
|
+
});
|
|
1062
|
+
});
|
|
1063
|
+
i(this, "onBeforePortUnmarked", (e) => {
|
|
1064
|
+
this.graphStore.getPortAdjacentEdgeIds(e).forEach((o) => {
|
|
1065
|
+
this.removeEdge(o);
|
|
1066
|
+
});
|
|
1067
|
+
});
|
|
1068
|
+
i(this, "onAfterEdgeAdded", (e) => {
|
|
1069
|
+
this.htmlView.attachEdge(e);
|
|
1070
|
+
});
|
|
1071
|
+
i(this, "onAfterEdgeShapeUpdated", (e) => {
|
|
1072
|
+
this.htmlView.updateEdgeShape(e);
|
|
1073
|
+
});
|
|
1074
|
+
i(this, "onAfterEdgeUpdated", (e) => {
|
|
1075
|
+
this.htmlView.renderEdge(e);
|
|
1076
|
+
});
|
|
1077
|
+
i(this, "onAfterEdgePriorityUpdated", (e) => {
|
|
1078
|
+
this.htmlView.updateEdgePriority(e);
|
|
1079
|
+
});
|
|
1080
|
+
i(this, "onBeforeEdgeRemoved", (e) => {
|
|
1081
|
+
this.htmlView.detachEdge(e);
|
|
1082
|
+
});
|
|
1083
|
+
i(this, "onBeforeClear", () => {
|
|
1084
|
+
this.nodeIdGenerator.reset(), this.portIdGenerator.reset(), this.edgeIdGenerator.reset(), this.htmlView.clear();
|
|
1085
|
+
});
|
|
1086
|
+
i(this, "onBeforeDestroyEmitter");
|
|
1087
|
+
i(this, "onBeforeDestroy");
|
|
1088
|
+
this.element = e, this.graphStore = o, this.viewportStore = r, this.htmlView = s, this.defaults = De(d), this.graph = new ue(this.graphStore), this.viewport = new ge(this.viewportStore), this.graphStore.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graphStore.onAfterNodeUpdated.subscribe(this.onAfterNodeUpdated), this.graphStore.onAfterNodePriorityUpdated.subscribe(
|
|
1089
|
+
this.onAfterNodePriorityUpdated
|
|
1090
|
+
), this.graphStore.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.graphStore.onAfterPortUpdated.subscribe(this.onAfterPortUpdated), this.graphStore.onBeforePortRemoved.subscribe(this.onBeforePortUnmarked), this.graphStore.onAfterEdgeAdded.subscribe(this.onAfterEdgeAdded), this.graphStore.onAfterEdgeShapeUpdated.subscribe(
|
|
1091
|
+
this.onAfterEdgeShapeUpdated
|
|
1092
|
+
), this.graphStore.onAfterEdgeUpdated.subscribe(this.onAfterEdgeUpdated), this.graphStore.onAfterEdgePriorityUpdated.subscribe(
|
|
1093
|
+
this.onAfterEdgePriorityUpdated
|
|
1094
|
+
), this.graphStore.onBeforeEdgeRemoved.subscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.subscribe(this.onBeforeClear), [this.onBeforeDestroyEmitter, this.onBeforeDestroy] = A();
|
|
1690
1095
|
}
|
|
1691
1096
|
/**
|
|
1692
1097
|
* adds node to graph
|
|
@@ -1694,8 +1099,8 @@ class We {
|
|
|
1694
1099
|
addNode(e) {
|
|
1695
1100
|
const o = this.nodeIdGenerator.create(e.id);
|
|
1696
1101
|
if (this.graph.getNode(o) !== null)
|
|
1697
|
-
throw new
|
|
1698
|
-
if (this.
|
|
1102
|
+
throw new S("failed to add node with existing id");
|
|
1103
|
+
if (this.graphStore.addNode({
|
|
1699
1104
|
id: o,
|
|
1700
1105
|
element: e.element,
|
|
1701
1106
|
x: e.x,
|
|
@@ -1717,8 +1122,8 @@ class We {
|
|
|
1717
1122
|
*/
|
|
1718
1123
|
updateNode(e, o) {
|
|
1719
1124
|
if (this.graph.getNode(e) === null)
|
|
1720
|
-
throw new
|
|
1721
|
-
return this.
|
|
1125
|
+
throw new S("failed to update nonexisting node");
|
|
1126
|
+
return this.graphStore.updateNode(e, o ?? {}), this;
|
|
1722
1127
|
}
|
|
1723
1128
|
/**
|
|
1724
1129
|
* removes node from graph
|
|
@@ -1727,8 +1132,8 @@ class We {
|
|
|
1727
1132
|
*/
|
|
1728
1133
|
removeNode(e) {
|
|
1729
1134
|
if (this.graph.getNode(e) === null)
|
|
1730
|
-
throw new
|
|
1731
|
-
return this.
|
|
1135
|
+
throw new S("failed to remove nonexisting node");
|
|
1136
|
+
return this.graphStore.removeNode(e), this;
|
|
1732
1137
|
}
|
|
1733
1138
|
/**
|
|
1734
1139
|
* marks element as port of node
|
|
@@ -1736,10 +1141,10 @@ class We {
|
|
|
1736
1141
|
markPort(e) {
|
|
1737
1142
|
const o = this.portIdGenerator.create(e.id);
|
|
1738
1143
|
if (this.graph.getPort(o) !== null)
|
|
1739
|
-
throw new
|
|
1144
|
+
throw new S("failed to add port with existing id");
|
|
1740
1145
|
if (this.graph.getNode(e.nodeId) === null)
|
|
1741
|
-
throw new
|
|
1742
|
-
return this.
|
|
1146
|
+
throw new S("failed to mark port for nonexisting node");
|
|
1147
|
+
return this.graphStore.addPort({
|
|
1743
1148
|
id: o,
|
|
1744
1149
|
element: e.element,
|
|
1745
1150
|
nodeId: e.nodeId,
|
|
@@ -1751,8 +1156,8 @@ class We {
|
|
|
1751
1156
|
*/
|
|
1752
1157
|
updatePort(e, o) {
|
|
1753
1158
|
if (this.graph.getPort(e) === null)
|
|
1754
|
-
throw new
|
|
1755
|
-
return this.
|
|
1159
|
+
throw new S("failed to update nonexisting port");
|
|
1160
|
+
return this.graphStore.updatePort(e, o ?? {}), this;
|
|
1756
1161
|
}
|
|
1757
1162
|
/**
|
|
1758
1163
|
* ummarks element as port of node
|
|
@@ -1760,8 +1165,8 @@ class We {
|
|
|
1760
1165
|
*/
|
|
1761
1166
|
unmarkPort(e) {
|
|
1762
1167
|
if (this.graph.getPort(e) === null)
|
|
1763
|
-
throw new
|
|
1764
|
-
return this.
|
|
1168
|
+
throw new S("failed to unmark nonexisting port");
|
|
1169
|
+
return this.graphStore.removePort(e), this;
|
|
1765
1170
|
}
|
|
1766
1171
|
/**
|
|
1767
1172
|
* adds edge to graph
|
|
@@ -1769,12 +1174,12 @@ class We {
|
|
|
1769
1174
|
addEdge(e) {
|
|
1770
1175
|
const o = this.edgeIdGenerator.create(e.id);
|
|
1771
1176
|
if (this.graph.getEdge(o) !== null)
|
|
1772
|
-
throw new
|
|
1177
|
+
throw new S("failed to add edge with existing id");
|
|
1773
1178
|
if (this.graph.getPort(e.from) === null)
|
|
1774
|
-
throw new
|
|
1179
|
+
throw new S("failed to add edge from nonexisting port");
|
|
1775
1180
|
if (this.graph.getPort(e.to) === null)
|
|
1776
|
-
throw new
|
|
1777
|
-
return this.
|
|
1181
|
+
throw new S("failed to add edge to nonexisting port");
|
|
1182
|
+
return this.graphStore.addEdge({
|
|
1778
1183
|
id: o,
|
|
1779
1184
|
from: e.from,
|
|
1780
1185
|
to: e.to,
|
|
@@ -1787,45 +1192,51 @@ class We {
|
|
|
1787
1192
|
*/
|
|
1788
1193
|
updateEdge(e, o) {
|
|
1789
1194
|
if (this.graph.getEdge(e) === null)
|
|
1790
|
-
throw new
|
|
1791
|
-
return this.
|
|
1195
|
+
throw new S("failed to update nonexisting edge");
|
|
1196
|
+
return this.graphStore.updateEdge(e, o ?? {}), this;
|
|
1792
1197
|
}
|
|
1793
1198
|
/**
|
|
1794
1199
|
* removes edge from graph
|
|
1795
1200
|
*/
|
|
1796
1201
|
removeEdge(e) {
|
|
1797
1202
|
if (this.graph.getEdge(e) === null)
|
|
1798
|
-
throw new
|
|
1799
|
-
return this.
|
|
1203
|
+
throw new S("failed to remove nonexisting edge");
|
|
1204
|
+
return this.graphStore.removeEdge(e), this;
|
|
1800
1205
|
}
|
|
1801
1206
|
/**
|
|
1802
1207
|
* applies transformation for viewport
|
|
1803
1208
|
*/
|
|
1804
1209
|
patchViewportMatrix(e) {
|
|
1805
|
-
return this.
|
|
1210
|
+
return this.viewportStore.patchViewportMatrix(e), this;
|
|
1806
1211
|
}
|
|
1807
1212
|
/**
|
|
1808
1213
|
* applies transformation for content
|
|
1809
1214
|
*/
|
|
1810
1215
|
patchContentMatrix(e) {
|
|
1811
|
-
return this.
|
|
1216
|
+
return this.viewportStore.patchContentMatrix(e), this;
|
|
1812
1217
|
}
|
|
1813
1218
|
/**
|
|
1814
1219
|
* clears canvas from nodes and edges
|
|
1815
1220
|
* canvas gets rolled back to initial state and can be reused
|
|
1816
1221
|
*/
|
|
1817
1222
|
clear() {
|
|
1818
|
-
return this.
|
|
1223
|
+
return this.graphStore.clear(), this;
|
|
1819
1224
|
}
|
|
1820
1225
|
/**
|
|
1821
1226
|
* destroys canvas
|
|
1822
1227
|
* canvas element gets rolled back to initial state, and can not be reused
|
|
1823
1228
|
*/
|
|
1824
1229
|
destroy() {
|
|
1825
|
-
this.
|
|
1230
|
+
this.onBeforeDestroyEmitter.emit(), this.graphStore.onAfterNodeAdded.unsubscribe(this.onAfterNodeAdded), this.graphStore.onAfterNodeUpdated.unsubscribe(this.onAfterNodeUpdated), this.graphStore.onAfterNodePriorityUpdated.unsubscribe(
|
|
1231
|
+
this.onAfterNodePriorityUpdated
|
|
1232
|
+
), this.graphStore.onBeforeNodeRemoved.unsubscribe(this.onBeforeNodeRemoved), this.graphStore.onAfterPortUpdated.unsubscribe(this.onAfterPortUpdated), this.graphStore.onBeforePortRemoved.unsubscribe(this.onBeforePortUnmarked), this.graphStore.onAfterEdgeAdded.unsubscribe(this.onAfterEdgeAdded), this.graphStore.onAfterEdgeShapeUpdated.unsubscribe(
|
|
1233
|
+
this.onAfterEdgeShapeUpdated
|
|
1234
|
+
), this.graphStore.onAfterEdgeUpdated.unsubscribe(this.onAfterEdgeUpdated), this.graphStore.onAfterEdgePriorityUpdated.unsubscribe(
|
|
1235
|
+
this.onAfterEdgePriorityUpdated
|
|
1236
|
+
), this.graphStore.onBeforeEdgeRemoved.unsubscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.unsubscribe(this.onBeforeClear), this.clear(), this.htmlView.destroy();
|
|
1826
1237
|
}
|
|
1827
1238
|
}
|
|
1828
|
-
class
|
|
1239
|
+
class Ve {
|
|
1829
1240
|
constructor() {
|
|
1830
1241
|
i(this, "nodes", /* @__PURE__ */ new Map());
|
|
1831
1242
|
i(this, "ports", /* @__PURE__ */ new Map());
|
|
@@ -1859,222 +1270,710 @@ class Fe {
|
|
|
1859
1270
|
i(this, "onBeforeEdgeRemoved");
|
|
1860
1271
|
i(this, "beforeClearEmitter");
|
|
1861
1272
|
i(this, "onBeforeClear");
|
|
1862
|
-
[this.afterNodeAddedEmitter, this.onAfterNodeAdded] =
|
|
1273
|
+
[this.afterNodeAddedEmitter, this.onAfterNodeAdded] = A(), [this.afterNodeUpdatedEmitter, this.onAfterNodeUpdated] = A(), [this.afterNodePriorityUpdatedEmitter, this.onAfterNodePriorityUpdated] = A(), [this.beforeNodeRemovedEmitter, this.onBeforeNodeRemoved] = A(), [this.afterPortAddedEmitter, this.onAfterPortAdded] = A(), [this.afterPortUpdatedEmitter, this.onAfterPortUpdated] = A(), [this.beforePortRemovedEmitter, this.onBeforePortRemoved] = A(), [this.afterEdgeAddedEmitter, this.onAfterEdgeAdded] = A(), [this.afterEdgeShapeUpdatedEmitter, this.onAfterEdgeShapeUpdated] = A(), [this.afterEdgeUpdatedEmitter, this.onAfterEdgeUpdated] = A(), [this.afterEdgePriorityUpdatedEmitter, this.onAfterEdgePriorityUpdated] = A(), [this.beforeEdgeRemovedEmitter, this.onBeforeEdgeRemoved] = A(), [this.beforeClearEmitter, this.onBeforeClear] = A();
|
|
1274
|
+
}
|
|
1275
|
+
addNode(e) {
|
|
1276
|
+
const o = /* @__PURE__ */ new Map(), r = {
|
|
1277
|
+
element: e.element,
|
|
1278
|
+
x: e.x,
|
|
1279
|
+
y: e.y,
|
|
1280
|
+
centerFn: e.centerFn,
|
|
1281
|
+
priority: e.priority,
|
|
1282
|
+
ports: o
|
|
1283
|
+
};
|
|
1284
|
+
this.nodes.set(e.id, r), this.afterNodeAddedEmitter.emit(e.id);
|
|
1285
|
+
}
|
|
1286
|
+
getAllNodeIds() {
|
|
1287
|
+
return Array.from(this.nodes.keys());
|
|
1288
|
+
}
|
|
1289
|
+
getNode(e) {
|
|
1290
|
+
return this.nodes.get(e);
|
|
1291
|
+
}
|
|
1292
|
+
updateNode(e, o) {
|
|
1293
|
+
const r = this.nodes.get(e);
|
|
1294
|
+
r.x = o.x ?? r.x, r.y = o.y ?? r.y, r.centerFn = o.centerFn ?? r.centerFn, o.priority !== void 0 && (r.priority = o.priority, this.afterNodePriorityUpdatedEmitter.emit(e)), this.afterNodeUpdatedEmitter.emit(e);
|
|
1295
|
+
}
|
|
1296
|
+
removeNode(e) {
|
|
1297
|
+
this.beforeNodeRemovedEmitter.emit(e), this.nodes.delete(e);
|
|
1298
|
+
}
|
|
1299
|
+
addPort(e) {
|
|
1300
|
+
this.ports.set(e.id, {
|
|
1301
|
+
element: e.element,
|
|
1302
|
+
direction: e.direction,
|
|
1303
|
+
nodeId: e.nodeId
|
|
1304
|
+
}), this.cycleEdges.set(e.id, /* @__PURE__ */ new Set()), this.incommingEdges.set(e.id, /* @__PURE__ */ new Set()), this.outcommingEdges.set(e.id, /* @__PURE__ */ new Set()), this.nodes.get(e.nodeId).ports.set(e.id, e.element), this.afterPortAddedEmitter.emit(e.id);
|
|
1305
|
+
}
|
|
1306
|
+
getPort(e) {
|
|
1307
|
+
return this.ports.get(e);
|
|
1308
|
+
}
|
|
1309
|
+
updatePort(e, o) {
|
|
1310
|
+
const r = this.ports.get(e);
|
|
1311
|
+
r.direction = o.direction ?? r.direction, this.afterPortUpdatedEmitter.emit(e);
|
|
1312
|
+
}
|
|
1313
|
+
getAllPortIds() {
|
|
1314
|
+
return Array.from(this.ports.keys());
|
|
1315
|
+
}
|
|
1316
|
+
getNodePortIds(e) {
|
|
1317
|
+
const o = this.nodes.get(e);
|
|
1318
|
+
if (o !== void 0)
|
|
1319
|
+
return Array.from(o.ports.keys());
|
|
1320
|
+
}
|
|
1321
|
+
removePort(e) {
|
|
1322
|
+
const o = this.ports.get(e).nodeId;
|
|
1323
|
+
this.beforePortRemovedEmitter.emit(e), this.nodes.get(o).ports.delete(e), this.ports.delete(e);
|
|
1324
|
+
}
|
|
1325
|
+
addEdge(e) {
|
|
1326
|
+
this.addEdgeInternal(e), this.afterEdgeAddedEmitter.emit(e.id);
|
|
1327
|
+
}
|
|
1328
|
+
updateEdge(e, o) {
|
|
1329
|
+
if (o.from !== void 0 || o.to !== void 0) {
|
|
1330
|
+
const s = this.edges.get(e);
|
|
1331
|
+
this.removeEdgeInternal(e), this.addEdgeInternal({
|
|
1332
|
+
id: e,
|
|
1333
|
+
from: o.from ?? s.from,
|
|
1334
|
+
to: o.to ?? s.to,
|
|
1335
|
+
shape: s.shape,
|
|
1336
|
+
priority: s.priority
|
|
1337
|
+
});
|
|
1338
|
+
}
|
|
1339
|
+
const r = this.edges.get(e);
|
|
1340
|
+
o.shape !== void 0 && (r.shape = o.shape, this.afterEdgeShapeUpdatedEmitter.emit(e)), o.priority !== void 0 && (r.priority = o.priority, this.afterEdgePriorityUpdatedEmitter.emit(e)), this.afterEdgeUpdatedEmitter.emit(e);
|
|
1341
|
+
}
|
|
1342
|
+
getAllEdgeIds() {
|
|
1343
|
+
return Array.from(this.edges.keys());
|
|
1344
|
+
}
|
|
1345
|
+
getEdge(e) {
|
|
1346
|
+
return this.edges.get(e);
|
|
1347
|
+
}
|
|
1348
|
+
removeEdge(e) {
|
|
1349
|
+
this.beforeEdgeRemovedEmitter.emit(e), this.removeEdgeInternal(e);
|
|
1350
|
+
}
|
|
1351
|
+
clear() {
|
|
1352
|
+
this.beforeClearEmitter.emit(), this.incommingEdges.clear(), this.outcommingEdges.clear(), this.cycleEdges.clear(), this.edges.clear(), this.ports.clear(), this.nodes.clear();
|
|
1353
|
+
}
|
|
1354
|
+
getPortIncomingEdgeIds(e) {
|
|
1355
|
+
return Array.from(this.incommingEdges.get(e));
|
|
1356
|
+
}
|
|
1357
|
+
getPortOutcomingEdgeIds(e) {
|
|
1358
|
+
return Array.from(this.outcommingEdges.get(e));
|
|
1359
|
+
}
|
|
1360
|
+
getPortCycleEdgeIds(e) {
|
|
1361
|
+
return Array.from(this.cycleEdges.get(e));
|
|
1362
|
+
}
|
|
1363
|
+
getPortAdjacentEdgeIds(e) {
|
|
1364
|
+
return [
|
|
1365
|
+
...this.getPortIncomingEdgeIds(e),
|
|
1366
|
+
...this.getPortOutcomingEdgeIds(e),
|
|
1367
|
+
...this.getPortCycleEdgeIds(e)
|
|
1368
|
+
];
|
|
1369
|
+
}
|
|
1370
|
+
getNodeIncomingEdgeIds(e) {
|
|
1371
|
+
const o = Array.from(this.nodes.get(e).ports.keys());
|
|
1372
|
+
let r = [];
|
|
1373
|
+
return o.forEach((s) => {
|
|
1374
|
+
r = [...r, ...this.getPortIncomingEdgeIds(s)];
|
|
1375
|
+
}), r;
|
|
1376
|
+
}
|
|
1377
|
+
getNodeOutcomingEdgeIds(e) {
|
|
1378
|
+
const o = Array.from(this.nodes.get(e).ports.keys());
|
|
1379
|
+
let r = [];
|
|
1380
|
+
return o.forEach((s) => {
|
|
1381
|
+
r = [...r, ...this.getPortOutcomingEdgeIds(s)];
|
|
1382
|
+
}), r;
|
|
1383
|
+
}
|
|
1384
|
+
getNodeCycleEdgeIds(e) {
|
|
1385
|
+
const o = Array.from(this.nodes.get(e).ports.keys());
|
|
1386
|
+
let r = [];
|
|
1387
|
+
return o.forEach((s) => {
|
|
1388
|
+
r = [...r, ...this.getPortCycleEdgeIds(s)];
|
|
1389
|
+
}), r;
|
|
1390
|
+
}
|
|
1391
|
+
getNodeAdjacentEdgeIds(e) {
|
|
1392
|
+
return [
|
|
1393
|
+
...this.getNodeIncomingEdgeIds(e),
|
|
1394
|
+
...this.getNodeOutcomingEdgeIds(e),
|
|
1395
|
+
...this.getNodeCycleEdgeIds(e)
|
|
1396
|
+
];
|
|
1397
|
+
}
|
|
1398
|
+
addEdgeInternal(e) {
|
|
1399
|
+
this.edges.set(e.id, {
|
|
1400
|
+
from: e.from,
|
|
1401
|
+
to: e.to,
|
|
1402
|
+
shape: e.shape,
|
|
1403
|
+
priority: e.priority
|
|
1404
|
+
}), e.from !== e.to ? (this.outcommingEdges.get(e.from).add(e.id), this.incommingEdges.get(e.to).add(e.id)) : this.cycleEdges.get(e.from).add(e.id);
|
|
1405
|
+
}
|
|
1406
|
+
removeEdgeInternal(e) {
|
|
1407
|
+
const o = this.edges.get(e), r = o.from, s = o.to;
|
|
1408
|
+
this.cycleEdges.get(r).delete(e), this.cycleEdges.get(s).delete(e), this.incommingEdges.get(r).delete(e), this.incommingEdges.get(s).delete(e), this.outcommingEdges.get(r).delete(e), this.outcommingEdges.get(s).delete(e), this.edges.delete(e);
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
const ee = (t) => ({
|
|
1412
|
+
scale: 1 / t.scale,
|
|
1413
|
+
x: -t.x / t.scale,
|
|
1414
|
+
y: -t.y / t.scale
|
|
1415
|
+
}), te = {
|
|
1416
|
+
scale: 1,
|
|
1417
|
+
x: 0,
|
|
1418
|
+
y: 0
|
|
1419
|
+
};
|
|
1420
|
+
class Le {
|
|
1421
|
+
constructor() {
|
|
1422
|
+
i(this, "viewportMatrix", te);
|
|
1423
|
+
i(this, "contentMatrix", te);
|
|
1424
|
+
i(this, "afterUpdateEmitter");
|
|
1425
|
+
i(this, "onAfterUpdated");
|
|
1426
|
+
i(this, "beforeUpdateEmitter");
|
|
1427
|
+
i(this, "onBeforeUpdated");
|
|
1428
|
+
[this.afterUpdateEmitter, this.onAfterUpdated] = A(), [this.beforeUpdateEmitter, this.onBeforeUpdated] = A();
|
|
1429
|
+
}
|
|
1430
|
+
getViewportMatrix() {
|
|
1431
|
+
return this.viewportMatrix;
|
|
1432
|
+
}
|
|
1433
|
+
getContentMatrix() {
|
|
1434
|
+
return this.contentMatrix;
|
|
1435
|
+
}
|
|
1436
|
+
patchViewportMatrix(e) {
|
|
1437
|
+
this.beforeUpdateEmitter.emit(), this.viewportMatrix = {
|
|
1438
|
+
scale: e.scale ?? this.viewportMatrix.scale,
|
|
1439
|
+
x: e.x ?? this.viewportMatrix.x,
|
|
1440
|
+
y: e.y ?? this.viewportMatrix.y
|
|
1441
|
+
}, this.contentMatrix = ee(this.viewportMatrix), this.afterUpdateEmitter.emit();
|
|
1442
|
+
}
|
|
1443
|
+
patchContentMatrix(e) {
|
|
1444
|
+
this.beforeUpdateEmitter.emit(), this.contentMatrix = {
|
|
1445
|
+
scale: e.scale ?? this.contentMatrix.scale,
|
|
1446
|
+
x: e.x ?? this.contentMatrix.x,
|
|
1447
|
+
y: e.y ?? this.contentMatrix.y
|
|
1448
|
+
}, this.viewportMatrix = ee(this.contentMatrix), this.afterUpdateEmitter.emit();
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1451
|
+
class G {
|
|
1452
|
+
constructor(e) {
|
|
1453
|
+
i(this, "elementToNodeId", /* @__PURE__ */ new Map());
|
|
1454
|
+
i(this, "nodesResizeObserver");
|
|
1455
|
+
i(this, "onAfterNodeAdded", (e) => {
|
|
1456
|
+
const o = this.canvas.graph.getNode(e);
|
|
1457
|
+
this.elementToNodeId.set(o.element, e), this.nodesResizeObserver.observe(o.element);
|
|
1458
|
+
});
|
|
1459
|
+
i(this, "onBeforeNodeRemoved", (e) => {
|
|
1460
|
+
const o = this.canvas.graph.getNode(e);
|
|
1461
|
+
this.elementToNodeId.delete(o.element), this.nodesResizeObserver.unobserve(o.element);
|
|
1462
|
+
});
|
|
1463
|
+
i(this, "onBeforeClear", () => {
|
|
1464
|
+
this.nodesResizeObserver.disconnect(), this.elementToNodeId.clear();
|
|
1465
|
+
});
|
|
1466
|
+
i(this, "onBeforeDestroy", () => {
|
|
1467
|
+
this.canvas.graph.onAfterNodeAdded.unsubscribe(this.onAfterNodeAdded), this.canvas.graph.onBeforeNodeRemoved.unsubscribe(this.onBeforeNodeRemoved), this.canvas.graph.onBeforeClear.unsubscribe(this.onBeforeClear), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy);
|
|
1468
|
+
});
|
|
1469
|
+
this.canvas = e, this.nodesResizeObserver = new ResizeObserver((o) => {
|
|
1470
|
+
o.forEach((r) => {
|
|
1471
|
+
const s = r.target;
|
|
1472
|
+
this.handleNodeResize(s);
|
|
1473
|
+
});
|
|
1474
|
+
}), this.canvas.graph.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.canvas.graph.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.canvas.graph.onBeforeClear.subscribe(this.onBeforeClear), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
|
|
1863
1475
|
}
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
element: e.element,
|
|
1867
|
-
x: e.x,
|
|
1868
|
-
y: e.y,
|
|
1869
|
-
centerFn: e.centerFn,
|
|
1870
|
-
priority: e.priority,
|
|
1871
|
-
ports: o
|
|
1872
|
-
};
|
|
1873
|
-
this.nodes.set(e.id, r), this.afterNodeAddedEmitter.emit(e.id);
|
|
1476
|
+
static configure(e) {
|
|
1477
|
+
new G(e);
|
|
1874
1478
|
}
|
|
1875
|
-
|
|
1876
|
-
|
|
1479
|
+
handleNodeResize(e) {
|
|
1480
|
+
const o = this.elementToNodeId.get(e);
|
|
1481
|
+
this.canvas.updateNode(o), this.canvas.graph.getNodeAdjacentEdgeIds(o).forEach((s) => {
|
|
1482
|
+
this.canvas.updateEdge(s);
|
|
1483
|
+
});
|
|
1877
1484
|
}
|
|
1878
|
-
|
|
1879
|
-
|
|
1485
|
+
}
|
|
1486
|
+
const Ce = (t) => {
|
|
1487
|
+
var g, f, v, y, p, E;
|
|
1488
|
+
const e = ((g = t == null ? void 0 : t.events) == null ? void 0 : g.onNodeDrag) ?? (() => {
|
|
1489
|
+
}), o = ((f = t == null ? void 0 : t.events) == null ? void 0 : f.onBeforeNodeDrag) ?? (() => !0), r = ((v = t == null ? void 0 : t.events) == null ? void 0 : v.onNodeDragFinished) ?? (() => {
|
|
1490
|
+
}), s = (t == null ? void 0 : t.moveOnTop) === !1, d = (y = t == null ? void 0 : t.mouse) == null ? void 0 : y.dragCursor, n = d !== void 0 ? d : "grab", h = (p = t == null ? void 0 : t.mouse) == null ? void 0 : p.mouseDownEventVerifier, c = h !== void 0 ? h : (T) => T.button === 0, a = (E = t == null ? void 0 : t.mouse) == null ? void 0 : E.mouseUpEventVerifier;
|
|
1491
|
+
return {
|
|
1492
|
+
freezePriority: s,
|
|
1493
|
+
dragCursor: n,
|
|
1494
|
+
mouseDownEventVerifier: c,
|
|
1495
|
+
mouseUpEventVerifier: a !== void 0 ? a : (T) => T.button === 0,
|
|
1496
|
+
onNodeDrag: e,
|
|
1497
|
+
onBeforeNodeDrag: o,
|
|
1498
|
+
onNodeDragFinished: r
|
|
1499
|
+
};
|
|
1500
|
+
}, R = (t, e, o) => {
|
|
1501
|
+
const { x: r, y: s, width: d, height: n } = t.getBoundingClientRect();
|
|
1502
|
+
return e >= r && e <= r + d && o >= s && o <= s + n;
|
|
1503
|
+
}, U = (t, e, o) => e >= 0 && e <= t.innerWidth && o >= 0 && o <= t.innerHeight, I = (t, e) => {
|
|
1504
|
+
e !== null ? t.style.cursor = e : t.style.removeProperty("cursor");
|
|
1505
|
+
};
|
|
1506
|
+
class J {
|
|
1507
|
+
constructor(e, o) {
|
|
1508
|
+
i(this, "grabbedNodeId", null);
|
|
1509
|
+
i(this, "maxNodePriority", 0);
|
|
1510
|
+
i(this, "previousTouchCoords", null);
|
|
1511
|
+
i(this, "nodeIds", /* @__PURE__ */ new Map());
|
|
1512
|
+
i(this, "window", window);
|
|
1513
|
+
i(this, "graph");
|
|
1514
|
+
i(this, "element");
|
|
1515
|
+
i(this, "onAfterNodeAdded", (e) => {
|
|
1516
|
+
this.updateMaxNodePriority(e);
|
|
1517
|
+
const o = this.graph.getNode(e);
|
|
1518
|
+
this.nodeIds.set(o.element, e), o.element.addEventListener("mousedown", this.onMouseDown), o.element.addEventListener("touchstart", this.onTouchStart);
|
|
1519
|
+
});
|
|
1520
|
+
i(this, "onAfterNodeUpdated", (e) => {
|
|
1521
|
+
this.updateMaxNodePriority(e);
|
|
1522
|
+
});
|
|
1523
|
+
i(this, "onBeforeNodeRemoved", (e) => {
|
|
1524
|
+
const o = this.graph.getNode(e);
|
|
1525
|
+
this.nodeIds.delete(o.element), o.element.removeEventListener("mousedown", this.onMouseDown), o.element.removeEventListener("touchstart", this.onTouchStart);
|
|
1526
|
+
});
|
|
1527
|
+
i(this, "onBeforeDestroy", () => {
|
|
1528
|
+
this.graph.onAfterNodeAdded.unsubscribe(this.onAfterNodeAdded), this.graph.onAfterNodeUpdated.unsubscribe(this.onAfterNodeUpdated), this.graph.onBeforeNodeRemoved.unsubscribe(this.onBeforeNodeRemoved), this.graph.onBeforeClear.unsubscribe(this.onBeforeClear), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy), this.removeMouseDragListeners(), this.removeTouchDragListeners();
|
|
1529
|
+
});
|
|
1530
|
+
i(this, "onBeforeClear", () => {
|
|
1531
|
+
this.nodeIds.forEach((e, o) => {
|
|
1532
|
+
o.removeEventListener("mousedown", this.onMouseDown), o.removeEventListener("touchstart", this.onTouchStart);
|
|
1533
|
+
}), this.nodeIds.clear(), this.maxNodePriority = 0;
|
|
1534
|
+
});
|
|
1535
|
+
i(this, "onMouseDown", (e) => {
|
|
1536
|
+
if (!this.options.mouseDownEventVerifier(e))
|
|
1537
|
+
return;
|
|
1538
|
+
const o = e.currentTarget, r = this.nodeIds.get(o), s = this.graph.getNode(r);
|
|
1539
|
+
this.options.onBeforeNodeDrag({
|
|
1540
|
+
nodeId: r,
|
|
1541
|
+
element: s.element,
|
|
1542
|
+
x: s.x,
|
|
1543
|
+
y: s.y
|
|
1544
|
+
}) && (e.stopImmediatePropagation(), this.grabbedNodeId = r, I(this.element, this.options.dragCursor), this.moveNodeOnTop(r), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.window.addEventListener("mousemove", this.onWindowMouseMove));
|
|
1545
|
+
});
|
|
1546
|
+
i(this, "onTouchStart", (e) => {
|
|
1547
|
+
if (e.touches.length !== 1)
|
|
1548
|
+
return;
|
|
1549
|
+
e.stopImmediatePropagation(), this.previousTouchCoords = {
|
|
1550
|
+
x: e.touches[0].clientX,
|
|
1551
|
+
y: e.touches[0].clientY
|
|
1552
|
+
};
|
|
1553
|
+
const o = e.currentTarget, r = this.nodeIds.get(o), s = this.graph.getNode(r);
|
|
1554
|
+
this.options.onBeforeNodeDrag({
|
|
1555
|
+
nodeId: r,
|
|
1556
|
+
element: s.element,
|
|
1557
|
+
x: s.x,
|
|
1558
|
+
y: s.y
|
|
1559
|
+
}) && (this.grabbedNodeId = r, this.moveNodeOnTop(r), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish));
|
|
1560
|
+
});
|
|
1561
|
+
i(this, "onWindowMouseMove", (e) => {
|
|
1562
|
+
if (!R(this.element, e.clientX, e.clientY) || !U(this.window, e.clientX, e.clientY)) {
|
|
1563
|
+
this.cancelMouseDrag();
|
|
1564
|
+
return;
|
|
1565
|
+
}
|
|
1566
|
+
this.grabbedNodeId !== null && this.dragNode(this.grabbedNodeId, e.movementX, e.movementY);
|
|
1567
|
+
});
|
|
1568
|
+
i(this, "onWindowMouseUp", (e) => {
|
|
1569
|
+
this.options.mouseUpEventVerifier(e) && this.cancelMouseDrag();
|
|
1570
|
+
});
|
|
1571
|
+
i(this, "onWindowTouchMove", (e) => {
|
|
1572
|
+
if (e.touches.length !== 1)
|
|
1573
|
+
return;
|
|
1574
|
+
const o = e.touches[0];
|
|
1575
|
+
if (!R(this.element, o.clientX, o.clientY) || !U(this.window, o.clientX, o.clientY)) {
|
|
1576
|
+
this.cancelTouchDrag();
|
|
1577
|
+
return;
|
|
1578
|
+
}
|
|
1579
|
+
if (this.grabbedNodeId !== null && this.previousTouchCoords !== null) {
|
|
1580
|
+
const r = o.clientX - this.previousTouchCoords.x, s = o.clientY - this.previousTouchCoords.y;
|
|
1581
|
+
this.dragNode(this.grabbedNodeId, r, s), this.previousTouchCoords = {
|
|
1582
|
+
x: e.touches[0].clientX,
|
|
1583
|
+
y: e.touches[0].clientY
|
|
1584
|
+
};
|
|
1585
|
+
}
|
|
1586
|
+
});
|
|
1587
|
+
i(this, "onWindowTouchFinish", () => {
|
|
1588
|
+
this.previousTouchCoords = null, this.cancelTouchDrag();
|
|
1589
|
+
});
|
|
1590
|
+
i(this, "options");
|
|
1591
|
+
this.canvas = e, this.options = Ce(o), this.graph = e.graph, this.element = e.element, this.graph.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graph.onAfterNodeUpdated.subscribe(this.onAfterNodeUpdated), this.graph.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.graph.onBeforeClear.subscribe(this.onBeforeClear), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
|
|
1880
1592
|
}
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
r.x = o.x ?? r.x, r.y = o.y ?? r.y, r.centerFn = o.centerFn ?? r.centerFn, o.priority !== void 0 && (r.priority = o.priority, this.afterNodePriorityUpdatedEmitter.emit(e)), this.afterNodeUpdatedEmitter.emit(e);
|
|
1593
|
+
static configure(e, o) {
|
|
1594
|
+
new J(e, o);
|
|
1884
1595
|
}
|
|
1885
|
-
|
|
1886
|
-
|
|
1596
|
+
dragNode(e, o, r) {
|
|
1597
|
+
const s = this.graph.getNode(e);
|
|
1598
|
+
if (s === null)
|
|
1599
|
+
return;
|
|
1600
|
+
const d = this.canvas.viewport.getContentMatrix(), n = d.scale * s.x + d.x, h = d.scale * s.y + d.y, c = n + o, a = h + r, l = this.canvas.viewport.getViewportMatrix(), g = l.scale * c + l.x, f = l.scale * a + l.y;
|
|
1601
|
+
this.canvas.updateNode(e, { x: g, y: f }), this.options.onNodeDrag({
|
|
1602
|
+
nodeId: e,
|
|
1603
|
+
element: s.element,
|
|
1604
|
+
x: g,
|
|
1605
|
+
y: f
|
|
1606
|
+
});
|
|
1887
1607
|
}
|
|
1888
|
-
|
|
1889
|
-
this.
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1608
|
+
moveNodeOnTop(e) {
|
|
1609
|
+
if (this.options.freezePriority)
|
|
1610
|
+
return;
|
|
1611
|
+
this.maxNodePriority += 2, this.canvas.updateNode(e, { priority: this.maxNodePriority });
|
|
1612
|
+
const o = this.maxNodePriority - 1;
|
|
1613
|
+
this.graph.getNodeAdjacentEdgeIds(e).forEach((s) => {
|
|
1614
|
+
this.canvas.updateEdge(s, { priority: o });
|
|
1615
|
+
});
|
|
1894
1616
|
}
|
|
1895
|
-
|
|
1896
|
-
|
|
1617
|
+
cancelMouseDrag() {
|
|
1618
|
+
const e = this.graph.getNode(this.grabbedNodeId);
|
|
1619
|
+
e !== null && this.options.onNodeDragFinished({
|
|
1620
|
+
nodeId: this.grabbedNodeId,
|
|
1621
|
+
element: e.element,
|
|
1622
|
+
x: e.x,
|
|
1623
|
+
y: e.y
|
|
1624
|
+
}), this.grabbedNodeId = null, I(this.canvas.element, null), this.removeMouseDragListeners();
|
|
1897
1625
|
}
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
r.direction = o.direction ?? r.direction, this.afterPortUpdatedEmitter.emit(e);
|
|
1626
|
+
removeMouseDragListeners() {
|
|
1627
|
+
this.window.removeEventListener("mouseup", this.onWindowMouseUp), this.window.removeEventListener("mousemove", this.onWindowMouseMove);
|
|
1901
1628
|
}
|
|
1902
|
-
|
|
1903
|
-
|
|
1629
|
+
cancelTouchDrag() {
|
|
1630
|
+
this.previousTouchCoords = null;
|
|
1631
|
+
const e = this.graph.getNode(this.grabbedNodeId);
|
|
1632
|
+
e !== null && this.options.onNodeDragFinished({
|
|
1633
|
+
nodeId: this.grabbedNodeId,
|
|
1634
|
+
element: e.element,
|
|
1635
|
+
x: e.x,
|
|
1636
|
+
y: e.y
|
|
1637
|
+
}), this.grabbedNodeId = null, this.removeTouchDragListeners();
|
|
1904
1638
|
}
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
if (o !== void 0)
|
|
1908
|
-
return Array.from(o.ports.keys());
|
|
1639
|
+
removeTouchDragListeners() {
|
|
1640
|
+
this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
|
|
1909
1641
|
}
|
|
1910
|
-
|
|
1911
|
-
const o = this.
|
|
1912
|
-
this.
|
|
1642
|
+
updateMaxNodePriority(e) {
|
|
1643
|
+
const o = this.graph.getNode(e).priority;
|
|
1644
|
+
this.maxNodePriority = Math.max(this.maxNodePriority, o);
|
|
1913
1645
|
}
|
|
1914
|
-
|
|
1915
|
-
|
|
1646
|
+
}
|
|
1647
|
+
const Re = (t) => {
|
|
1648
|
+
const e = t.minX !== null ? t.minX : -1 / 0, o = t.maxX !== null ? t.maxX : 1 / 0, r = t.minY !== null ? t.minY : -1 / 0, s = t.maxY !== null ? t.maxY : 1 / 0;
|
|
1649
|
+
return (d) => {
|
|
1650
|
+
let n = d.nextTransform.x, h = d.nextTransform.y;
|
|
1651
|
+
n < e && n < d.prevTransform.x && (n = Math.min(d.prevTransform.x, e));
|
|
1652
|
+
const c = d.canvasWidth * d.prevTransform.scale, a = o - c;
|
|
1653
|
+
n > a && n > d.prevTransform.x && (n = Math.max(d.prevTransform.x, a)), h < r && h < d.prevTransform.y && (h = Math.min(d.prevTransform.y, r));
|
|
1654
|
+
const l = d.canvasHeight * d.prevTransform.scale, g = s - l;
|
|
1655
|
+
return h > g && h > d.prevTransform.y && (h = Math.max(d.prevTransform.y, g)), { scale: d.nextTransform.scale, x: n, y: h };
|
|
1656
|
+
};
|
|
1657
|
+
}, Ue = (t) => {
|
|
1658
|
+
const e = t.maxContentScale, o = t.minContentScale, r = e !== null ? 1 / e : 0, s = o !== null ? 1 / o : 1 / 0;
|
|
1659
|
+
return (d) => {
|
|
1660
|
+
const n = d.prevTransform, h = d.nextTransform;
|
|
1661
|
+
let c = h.scale, a = h.x, l = h.y;
|
|
1662
|
+
if (h.scale > s && h.scale > n.scale) {
|
|
1663
|
+
c = Math.max(n.scale, s), a = n.x, l = n.y;
|
|
1664
|
+
const g = (c - n.scale) / (h.scale - n.scale);
|
|
1665
|
+
a = n.x + (h.x - n.x) * g, l = n.y + (h.y - n.y) * g;
|
|
1666
|
+
}
|
|
1667
|
+
if (h.scale < r && h.scale < n.scale) {
|
|
1668
|
+
c = Math.min(n.scale, r), a = n.x, l = n.y;
|
|
1669
|
+
const g = (c - n.scale) / (h.scale - n.scale);
|
|
1670
|
+
a = n.x + (h.x - n.x) * g, l = n.y + (h.y - n.y) * g;
|
|
1671
|
+
}
|
|
1672
|
+
return {
|
|
1673
|
+
scale: c,
|
|
1674
|
+
x: a,
|
|
1675
|
+
y: l
|
|
1676
|
+
};
|
|
1677
|
+
};
|
|
1678
|
+
}, Ie = (t) => (e) => t.reduce(
|
|
1679
|
+
(o, r) => r({
|
|
1680
|
+
prevTransform: e.prevTransform,
|
|
1681
|
+
nextTransform: o,
|
|
1682
|
+
canvasWidth: e.canvasWidth,
|
|
1683
|
+
canvasHeight: e.canvasHeight
|
|
1684
|
+
}),
|
|
1685
|
+
e.nextTransform
|
|
1686
|
+
), oe = (t) => {
|
|
1687
|
+
if (typeof t == "function")
|
|
1688
|
+
return t;
|
|
1689
|
+
switch (t.type) {
|
|
1690
|
+
case "scale-limit":
|
|
1691
|
+
return Ue({
|
|
1692
|
+
minContentScale: t.minContentScale ?? 0,
|
|
1693
|
+
maxContentScale: t.maxContentScale ?? 1 / 0
|
|
1694
|
+
});
|
|
1695
|
+
case "shift-limit":
|
|
1696
|
+
return Re({
|
|
1697
|
+
minX: t.minX ?? -1 / 0,
|
|
1698
|
+
maxX: t.maxX ?? 1 / 0,
|
|
1699
|
+
minY: t.minY ?? -1 / 0,
|
|
1700
|
+
maxY: t.maxY ?? 1 / 0
|
|
1701
|
+
});
|
|
1916
1702
|
}
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1703
|
+
}, Be = (t) => {
|
|
1704
|
+
var y, p, E, T, Y, D, M, V, Q, Z, _, q;
|
|
1705
|
+
const e = (y = t == null ? void 0 : t.scale) == null ? void 0 : y.mouseWheelSensitivity, o = e !== void 0 ? e : 1.2, r = t == null ? void 0 : t.transformPreprocessor;
|
|
1706
|
+
let s;
|
|
1707
|
+
r !== void 0 ? Array.isArray(r) ? s = Ie(
|
|
1708
|
+
r.map(
|
|
1709
|
+
(P) => oe(P)
|
|
1710
|
+
)
|
|
1711
|
+
) : s = oe(r) : s = (P) => P.nextTransform;
|
|
1712
|
+
const d = ((p = t == null ? void 0 : t.shift) == null ? void 0 : p.cursor) !== void 0 ? t.shift.cursor : "grab", n = ((E = t == null ? void 0 : t.events) == null ? void 0 : E.onBeforeTransformChange) ?? (() => {
|
|
1713
|
+
}), h = ((T = t == null ? void 0 : t.events) == null ? void 0 : T.onTransformChange) ?? (() => {
|
|
1714
|
+
}), c = (Y = t == null ? void 0 : t.shift) == null ? void 0 : Y.mouseDownEventVerifier, a = c !== void 0 ? c : (P) => P.button === 0, l = (D = t == null ? void 0 : t.shift) == null ? void 0 : D.mouseUpEventVerifier, g = l !== void 0 ? l : (P) => P.button === 0, f = (M = t == null ? void 0 : t.scale) == null ? void 0 : M.mouseWheelEventVerifier, v = f !== void 0 ? f : () => !0;
|
|
1715
|
+
return {
|
|
1716
|
+
wheelSensitivity: o,
|
|
1717
|
+
onTransformStarted: ((V = t == null ? void 0 : t.events) == null ? void 0 : V.onTransformStarted) ?? (() => {
|
|
1718
|
+
}),
|
|
1719
|
+
onTransformFinished: ((Q = t == null ? void 0 : t.events) == null ? void 0 : Q.onTransformFinished) ?? (() => {
|
|
1720
|
+
}),
|
|
1721
|
+
onBeforeTransformChange: n,
|
|
1722
|
+
onTransformChange: h,
|
|
1723
|
+
transformPreprocessor: s,
|
|
1724
|
+
shiftCursor: d,
|
|
1725
|
+
mouseDownEventVerifier: a,
|
|
1726
|
+
mouseUpEventVerifier: g,
|
|
1727
|
+
mouseWheelEventVerifier: v,
|
|
1728
|
+
scaleWheelFinishTimeout: ((Z = t == null ? void 0 : t.scale) == null ? void 0 : Z.wheelFinishTimeout) ?? 500,
|
|
1729
|
+
onResizeTransformStarted: ((_ = t == null ? void 0 : t.events) == null ? void 0 : _.onResizeTransformStarted) ?? (() => {
|
|
1730
|
+
}),
|
|
1731
|
+
onResizeTransformFinished: ((q = t == null ? void 0 : t.events) == null ? void 0 : q.onResizeTransformFinished) ?? (() => {
|
|
1732
|
+
})
|
|
1733
|
+
};
|
|
1734
|
+
}, $e = (t, e, o) => ({
|
|
1735
|
+
scale: t.scale,
|
|
1736
|
+
x: t.x + t.scale * e,
|
|
1737
|
+
y: t.y + t.scale * o
|
|
1738
|
+
}), We = (t, e, o, r) => ({
|
|
1739
|
+
scale: t.scale * e,
|
|
1740
|
+
x: t.scale * (1 - e) * o + t.x,
|
|
1741
|
+
y: t.scale * (1 - e) * r + t.y
|
|
1742
|
+
}), C = (t) => {
|
|
1743
|
+
const e = [], o = t.touches.length;
|
|
1744
|
+
for (let h = 0; h < o; h++)
|
|
1745
|
+
e.push([t.touches[h].clientX, t.touches[h].clientY]);
|
|
1746
|
+
const r = e.reduce(
|
|
1747
|
+
(h, c) => [h[0] + c[0], h[1] + c[1]],
|
|
1748
|
+
[0, 0]
|
|
1749
|
+
), s = [r[0] / o, r[1] / o], n = e.map((h) => [h[0] - s[0], h[1] - s[1]]).reduce(
|
|
1750
|
+
(h, c) => h + Math.sqrt(c[0] * c[0] + c[1] * c[1]),
|
|
1751
|
+
0
|
|
1752
|
+
);
|
|
1753
|
+
return {
|
|
1754
|
+
x: s[0],
|
|
1755
|
+
y: s[1],
|
|
1756
|
+
scale: n / o,
|
|
1757
|
+
touchesCnt: o,
|
|
1758
|
+
touches: e
|
|
1759
|
+
};
|
|
1760
|
+
};
|
|
1761
|
+
class z {
|
|
1762
|
+
constructor(e, o) {
|
|
1763
|
+
i(this, "element");
|
|
1764
|
+
i(this, "window", window);
|
|
1765
|
+
i(this, "viewport");
|
|
1766
|
+
i(this, "prevTouches", null);
|
|
1767
|
+
i(this, "wheelFinishTimer", null);
|
|
1768
|
+
i(this, "transformInProgress", !1);
|
|
1769
|
+
i(this, "onBeforeDestroy", () => {
|
|
1770
|
+
this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.observer.unobserve(this.element), this.element.removeEventListener("mousedown", this.onMouseDown), this.element.removeEventListener("wheel", this.onWheelScroll), this.element.removeEventListener("touchstart", this.onTouchStart), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy);
|
|
1771
|
+
});
|
|
1772
|
+
i(this, "onMouseDown", (e) => {
|
|
1773
|
+
this.element === null || !this.options.mouseDownEventVerifier(e) || (I(this.element, this.options.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.startRegisteredTransform());
|
|
1774
|
+
});
|
|
1775
|
+
i(this, "onWindowMouseMove", (e) => {
|
|
1776
|
+
if (this.element === null || !R(this.element, e.clientX, e.clientY) || !U(this.window, e.clientX, e.clientY)) {
|
|
1777
|
+
this.stopMouseDrag();
|
|
1778
|
+
return;
|
|
1779
|
+
}
|
|
1780
|
+
const o = -e.movementX, r = -e.movementY;
|
|
1781
|
+
this.moveViewport(o, r);
|
|
1782
|
+
});
|
|
1783
|
+
i(this, "onWindowMouseUp", (e) => {
|
|
1784
|
+
this.element === null || !this.options.mouseUpEventVerifier(e) || this.stopMouseDrag();
|
|
1785
|
+
});
|
|
1786
|
+
i(this, "onWheelScroll", (e) => {
|
|
1787
|
+
if (!this.options.mouseWheelEventVerifier(e))
|
|
1788
|
+
return;
|
|
1789
|
+
e.preventDefault();
|
|
1790
|
+
const { left: o, top: r } = this.element.getBoundingClientRect(), s = e.clientX - o, d = e.clientY - r, h = 1 / (e.deltaY < 0 ? this.options.wheelSensitivity : 1 / this.options.wheelSensitivity);
|
|
1791
|
+
this.wheelFinishTimer === null && this.options.onTransformStarted(), this.scaleViewport(h, s, d), this.wheelFinishTimer !== null && clearTimeout(this.wheelFinishTimer), this.wheelFinishTimer = setTimeout(() => {
|
|
1792
|
+
this.transformInProgress || this.options.onTransformFinished(), this.wheelFinishTimer = null;
|
|
1793
|
+
}, this.options.scaleWheelFinishTimeout);
|
|
1794
|
+
});
|
|
1795
|
+
i(this, "onTouchStart", (e) => {
|
|
1796
|
+
if (this.prevTouches !== null) {
|
|
1797
|
+
this.prevTouches = C(e);
|
|
1798
|
+
return;
|
|
1799
|
+
}
|
|
1800
|
+
this.prevTouches = C(e), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish), this.startRegisteredTransform();
|
|
1801
|
+
});
|
|
1802
|
+
i(this, "onWindowTouchMove", (e) => {
|
|
1803
|
+
const o = C(e);
|
|
1804
|
+
if (!o.touches.every(
|
|
1805
|
+
(s) => R(this.element, s[0], s[1]) && U(this.window, s[0], s[1])
|
|
1806
|
+
)) {
|
|
1807
|
+
this.stopTouchDrag();
|
|
1808
|
+
return;
|
|
1809
|
+
}
|
|
1810
|
+
if ((o.touchesCnt === 1 || o.touchesCnt === 2) && this.moveViewport(
|
|
1811
|
+
-(o.x - this.prevTouches.x),
|
|
1812
|
+
-(o.y - this.prevTouches.y)
|
|
1813
|
+
), o.touchesCnt === 2) {
|
|
1814
|
+
const { left: s, top: d } = this.element.getBoundingClientRect(), n = this.prevTouches.x - s, h = this.prevTouches.y - d, a = 1 / (o.scale / this.prevTouches.scale);
|
|
1815
|
+
this.scaleViewport(a, n, h);
|
|
1816
|
+
}
|
|
1817
|
+
this.prevTouches = o;
|
|
1818
|
+
});
|
|
1819
|
+
i(this, "onWindowTouchFinish", (e) => {
|
|
1820
|
+
e.touches.length > 0 ? this.prevTouches = C(e) : this.stopTouchDrag();
|
|
1821
|
+
});
|
|
1822
|
+
i(this, "observer", new ResizeObserver(() => {
|
|
1823
|
+
const e = this.viewport.getViewportMatrix(), { width: o, height: r } = this.element.getBoundingClientRect(), s = this.options.transformPreprocessor({
|
|
1824
|
+
prevTransform: e,
|
|
1825
|
+
nextTransform: e,
|
|
1826
|
+
canvasWidth: o,
|
|
1827
|
+
canvasHeight: r
|
|
1926
1828
|
});
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
getAllEdgeIds() {
|
|
1932
|
-
return Array.from(this.edges.keys());
|
|
1933
|
-
}
|
|
1934
|
-
getEdge(e) {
|
|
1935
|
-
return this.edges.get(e);
|
|
1936
|
-
}
|
|
1937
|
-
removeEdge(e) {
|
|
1938
|
-
this.beforeEdgeRemovedEmitter.emit(e), this.removeEdgeInternal(e);
|
|
1939
|
-
}
|
|
1940
|
-
clear() {
|
|
1941
|
-
this.beforeClearEmitter.emit(), this.incommingEdges.clear(), this.outcommingEdges.clear(), this.cycleEdges.clear(), this.edges.clear(), this.ports.clear(), this.nodes.clear();
|
|
1942
|
-
}
|
|
1943
|
-
getPortIncomingEdgeIds(e) {
|
|
1944
|
-
return Array.from(this.incommingEdges.get(e));
|
|
1945
|
-
}
|
|
1946
|
-
getPortOutcomingEdgeIds(e) {
|
|
1947
|
-
return Array.from(this.outcommingEdges.get(e));
|
|
1948
|
-
}
|
|
1949
|
-
getPortCycleEdgeIds(e) {
|
|
1950
|
-
return Array.from(this.cycleEdges.get(e));
|
|
1951
|
-
}
|
|
1952
|
-
getPortAdjacentEdgeIds(e) {
|
|
1953
|
-
return [
|
|
1954
|
-
...this.getPortIncomingEdgeIds(e),
|
|
1955
|
-
...this.getPortOutcomingEdgeIds(e),
|
|
1956
|
-
...this.getPortCycleEdgeIds(e)
|
|
1957
|
-
];
|
|
1958
|
-
}
|
|
1959
|
-
getNodeIncomingEdgeIds(e) {
|
|
1960
|
-
const o = Array.from(this.nodes.get(e).ports.keys());
|
|
1961
|
-
let r = [];
|
|
1962
|
-
return o.forEach((s) => {
|
|
1963
|
-
r = [...r, ...this.getPortIncomingEdgeIds(s)];
|
|
1964
|
-
}), r;
|
|
1829
|
+
this.options.onResizeTransformStarted(), this.canvas.patchViewportMatrix(s), this.options.onResizeTransformFinished();
|
|
1830
|
+
}));
|
|
1831
|
+
i(this, "options");
|
|
1832
|
+
this.canvas = e, this.options = Be(o), this.element = e.element, this.viewport = e.viewport, this.observer.observe(this.element), this.element.addEventListener("mousedown", this.onMouseDown), this.element.addEventListener("wheel", this.onWheelScroll), this.element.addEventListener("touchstart", this.onTouchStart), e.onBeforeDestroy.subscribe(this.onBeforeDestroy);
|
|
1965
1833
|
}
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
let r = [];
|
|
1969
|
-
return o.forEach((s) => {
|
|
1970
|
-
r = [...r, ...this.getPortOutcomingEdgeIds(s)];
|
|
1971
|
-
}), r;
|
|
1834
|
+
static configure(e, o) {
|
|
1835
|
+
new z(e, o);
|
|
1972
1836
|
}
|
|
1973
|
-
|
|
1974
|
-
const
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1837
|
+
moveViewport(e, o) {
|
|
1838
|
+
const r = this.viewport.getViewportMatrix(), s = $e(r, e, o), { width: d, height: n } = this.element.getBoundingClientRect(), h = this.options.transformPreprocessor({
|
|
1839
|
+
prevTransform: r,
|
|
1840
|
+
nextTransform: s,
|
|
1841
|
+
canvasWidth: d,
|
|
1842
|
+
canvasHeight: n
|
|
1843
|
+
});
|
|
1844
|
+
this.performTransform(h);
|
|
1979
1845
|
}
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1846
|
+
scaleViewport(e, o, r) {
|
|
1847
|
+
const s = this.canvas.viewport.getViewportMatrix(), d = We(s, e, o, r), { width: n, height: h } = this.element.getBoundingClientRect(), c = this.options.transformPreprocessor({
|
|
1848
|
+
prevTransform: s,
|
|
1849
|
+
nextTransform: d,
|
|
1850
|
+
canvasWidth: n,
|
|
1851
|
+
canvasHeight: h
|
|
1852
|
+
});
|
|
1853
|
+
this.performTransform(c);
|
|
1986
1854
|
}
|
|
1987
|
-
|
|
1988
|
-
this.
|
|
1989
|
-
from: e.from,
|
|
1990
|
-
to: e.to,
|
|
1991
|
-
shape: e.shape,
|
|
1992
|
-
priority: e.priority
|
|
1993
|
-
}), e.from !== e.to ? (this.outcommingEdges.get(e.from).add(e.id), this.incommingEdges.get(e.to).add(e.id)) : this.cycleEdges.get(e.from).add(e.id);
|
|
1855
|
+
stopMouseDrag() {
|
|
1856
|
+
I(this.element, null), this.removeMouseDragListeners(), this.finishRegisteredTransform();
|
|
1994
1857
|
}
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
this.cycleEdges.get(r).delete(e), this.cycleEdges.get(s).delete(e), this.incommingEdges.get(r).delete(e), this.incommingEdges.get(s).delete(e), this.outcommingEdges.get(r).delete(e), this.outcommingEdges.get(s).delete(e), this.edges.delete(e);
|
|
1858
|
+
removeMouseDragListeners() {
|
|
1859
|
+
this.window.removeEventListener("mousemove", this.onWindowMouseMove), this.window.removeEventListener("mouseup", this.onWindowMouseUp);
|
|
1998
1860
|
}
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
scale: 1 / t.scale,
|
|
2002
|
-
x: -t.x / t.scale,
|
|
2003
|
-
y: -t.y / t.scale
|
|
2004
|
-
}), O = {
|
|
2005
|
-
scale: 1,
|
|
2006
|
-
x: 0,
|
|
2007
|
-
y: 0
|
|
2008
|
-
};
|
|
2009
|
-
class Be {
|
|
2010
|
-
constructor() {
|
|
2011
|
-
i(this, "viewportMatrix", O);
|
|
2012
|
-
i(this, "contentMatrix", O);
|
|
2013
|
-
i(this, "afterUpdateEmitter");
|
|
2014
|
-
i(this, "onAfterUpdated");
|
|
2015
|
-
i(this, "beforeUpdateEmitter");
|
|
2016
|
-
i(this, "onBeforeUpdated");
|
|
2017
|
-
[this.afterUpdateEmitter, this.onAfterUpdated] = E(), [this.beforeUpdateEmitter, this.onBeforeUpdated] = E();
|
|
1861
|
+
stopTouchDrag() {
|
|
1862
|
+
this.prevTouches = null, this.removeTouchDragListeners(), this.finishRegisteredTransform();
|
|
2018
1863
|
}
|
|
2019
|
-
|
|
2020
|
-
|
|
1864
|
+
removeTouchDragListeners() {
|
|
1865
|
+
this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
|
|
2021
1866
|
}
|
|
2022
|
-
|
|
2023
|
-
|
|
1867
|
+
performTransform(e) {
|
|
1868
|
+
this.options.onBeforeTransformChange(), this.canvas.patchViewportMatrix(e), this.options.onTransformChange();
|
|
2024
1869
|
}
|
|
2025
|
-
|
|
2026
|
-
this.
|
|
2027
|
-
scale: e.scale ?? this.viewportMatrix.scale,
|
|
2028
|
-
x: e.x ?? this.viewportMatrix.x,
|
|
2029
|
-
y: e.y ?? this.viewportMatrix.y
|
|
2030
|
-
}, this.contentMatrix = q(this.viewportMatrix), this.afterUpdateEmitter.emit();
|
|
1870
|
+
startRegisteredTransform() {
|
|
1871
|
+
this.transformInProgress = !0, this.options.onTransformStarted();
|
|
2031
1872
|
}
|
|
2032
|
-
|
|
2033
|
-
this.
|
|
2034
|
-
scale: e.scale ?? this.contentMatrix.scale,
|
|
2035
|
-
x: e.x ?? this.contentMatrix.x,
|
|
2036
|
-
y: e.y ?? this.contentMatrix.y
|
|
2037
|
-
}, this.viewportMatrix = q(this.contentMatrix), this.afterUpdateEmitter.emit();
|
|
1873
|
+
finishRegisteredTransform() {
|
|
1874
|
+
this.transformInProgress = !1, this.options.onTransformFinished();
|
|
2038
1875
|
}
|
|
2039
1876
|
}
|
|
2040
|
-
class
|
|
2041
|
-
constructor(e) {
|
|
2042
|
-
i(this, "
|
|
2043
|
-
i(this, "
|
|
2044
|
-
i(this, "
|
|
2045
|
-
|
|
2046
|
-
|
|
1877
|
+
class K {
|
|
1878
|
+
constructor(e, o, r, s) {
|
|
1879
|
+
i(this, "canvasResizeObserver");
|
|
1880
|
+
i(this, "window", window);
|
|
1881
|
+
i(this, "nodeHorizontal");
|
|
1882
|
+
i(this, "nodeVertical");
|
|
1883
|
+
i(this, "viewport");
|
|
1884
|
+
i(this, "element");
|
|
1885
|
+
i(this, "viewportWidth", 0);
|
|
1886
|
+
i(this, "viewportHeight", 0);
|
|
1887
|
+
i(this, "viewportMatrix");
|
|
1888
|
+
i(this, "loadedArea", {
|
|
1889
|
+
xFrom: 1 / 0,
|
|
1890
|
+
xTo: 1 / 0,
|
|
1891
|
+
yFrom: 1 / 0,
|
|
1892
|
+
yTo: 1 / 0
|
|
2047
1893
|
});
|
|
2048
|
-
i(this, "
|
|
2049
|
-
|
|
2050
|
-
|
|
1894
|
+
i(this, "updateLoadedArea", (e) => {
|
|
1895
|
+
this.loadedArea = {
|
|
1896
|
+
xFrom: e.x,
|
|
1897
|
+
xTo: e.x + e.width,
|
|
1898
|
+
yFrom: e.y,
|
|
1899
|
+
yTo: e.y + e.height
|
|
1900
|
+
};
|
|
2051
1901
|
});
|
|
2052
|
-
i(this, "
|
|
2053
|
-
this.
|
|
1902
|
+
i(this, "onBeforeDestroy", () => {
|
|
1903
|
+
this.trigger.unsubscribe(this.updateLoadedArea), this.canvasResizeObserver.unobserve(this.element), this.canvas.viewport.onAfterUpdated.unsubscribe(
|
|
1904
|
+
this.onAfterViewportUpdated
|
|
1905
|
+
), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy);
|
|
2054
1906
|
});
|
|
2055
|
-
this
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
1907
|
+
i(this, "onAfterViewportUpdated", () => {
|
|
1908
|
+
this.userTransformInProgress || (this.viewportMatrix = this.viewport.getViewportMatrix(), this.loadAreaAroundViewport());
|
|
1909
|
+
});
|
|
1910
|
+
i(this, "userTransformInProgress", !1);
|
|
1911
|
+
var g, f, v, y, p;
|
|
1912
|
+
this.canvas = e, this.trigger = r, this.virtualScrollOptions = s, this.nodeHorizontal = this.virtualScrollOptions.nodeContainingRadius.horizontal, this.nodeVertical = this.virtualScrollOptions.nodeContainingRadius.vertical, this.canvasResizeObserver = new this.window.ResizeObserver((E) => {
|
|
1913
|
+
const T = E[0];
|
|
1914
|
+
this.viewportWidth = T.contentRect.width, this.viewportHeight = T.contentRect.height, this.scheduleLoadAreaAroundViewport();
|
|
1915
|
+
}), this.viewport = e.viewport, this.element = e.element;
|
|
1916
|
+
const d = ((g = o == null ? void 0 : o.events) == null ? void 0 : g.onResizeTransformStarted) ?? (() => {
|
|
1917
|
+
}), n = ((f = o == null ? void 0 : o.events) == null ? void 0 : f.onResizeTransformFinished) ?? (() => {
|
|
1918
|
+
}), h = ((v = o == null ? void 0 : o.events) == null ? void 0 : v.onTransformChange) ?? (() => {
|
|
1919
|
+
}), c = ((y = o == null ? void 0 : o.events) == null ? void 0 : y.onBeforeTransformChange) ?? (() => {
|
|
1920
|
+
}), a = ((p = o == null ? void 0 : o.events) == null ? void 0 : p.onTransformFinished) ?? (() => {
|
|
1921
|
+
}), l = {
|
|
1922
|
+
...o,
|
|
1923
|
+
events: {
|
|
1924
|
+
...o == null ? void 0 : o.events,
|
|
1925
|
+
onResizeTransformStarted: () => {
|
|
1926
|
+
this.userTransformInProgress = !0, d();
|
|
1927
|
+
},
|
|
1928
|
+
onResizeTransformFinished: () => {
|
|
1929
|
+
this.userTransformInProgress = !1, n();
|
|
1930
|
+
},
|
|
1931
|
+
onBeforeTransformChange: () => {
|
|
1932
|
+
this.userTransformInProgress = !0, c();
|
|
1933
|
+
},
|
|
1934
|
+
onTransformChange: () => {
|
|
1935
|
+
this.userTransformInProgress = !1;
|
|
1936
|
+
const E = this.viewportMatrix;
|
|
1937
|
+
this.viewportMatrix = this.viewport.getViewportMatrix(), E.scale !== this.viewportMatrix.scale && this.scheduleEnsureViewportAreaLoaded(), h();
|
|
1938
|
+
},
|
|
1939
|
+
onTransformFinished: () => {
|
|
1940
|
+
this.scheduleLoadAreaAroundViewport(), a();
|
|
1941
|
+
}
|
|
1942
|
+
}
|
|
1943
|
+
};
|
|
1944
|
+
z.configure(
|
|
1945
|
+
e,
|
|
1946
|
+
l
|
|
1947
|
+
), this.viewportMatrix = this.viewport.getViewportMatrix(), this.trigger.subscribe(this.updateLoadedArea), this.canvasResizeObserver.observe(this.element), this.canvas.viewport.onAfterUpdated.subscribe(this.onAfterViewportUpdated), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
|
|
2061
1948
|
}
|
|
2062
|
-
static configure(e) {
|
|
2063
|
-
new
|
|
1949
|
+
static configure(e, o, r, s) {
|
|
1950
|
+
new K(
|
|
1951
|
+
e,
|
|
1952
|
+
o,
|
|
1953
|
+
r,
|
|
1954
|
+
s
|
|
1955
|
+
);
|
|
2064
1956
|
}
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
this.canvas.updateEdge(s);
|
|
1957
|
+
scheduleLoadAreaAroundViewport() {
|
|
1958
|
+
setTimeout(() => {
|
|
1959
|
+
this.loadAreaAroundViewport();
|
|
2069
1960
|
});
|
|
2070
1961
|
}
|
|
1962
|
+
scheduleEnsureViewportAreaLoaded() {
|
|
1963
|
+
const e = this.viewportWidth * this.viewportMatrix.scale, o = this.viewportHeight * this.viewportMatrix.scale, r = this.viewportMatrix.x - this.nodeHorizontal, s = this.viewportMatrix.y - this.nodeVertical, d = this.viewportMatrix.x + e + this.nodeHorizontal, n = this.viewportMatrix.y + o + this.nodeVertical;
|
|
1964
|
+
this.loadedArea.xFrom < r && this.loadedArea.xTo > d && this.loadedArea.yFrom < s && this.loadedArea.yTo > n || this.scheduleLoadAreaAroundViewport();
|
|
1965
|
+
}
|
|
1966
|
+
loadAreaAroundViewport() {
|
|
1967
|
+
const e = this.viewportWidth * this.viewportMatrix.scale, o = this.viewportHeight * this.viewportMatrix.scale, r = this.viewportMatrix.x - e - this.nodeHorizontal, s = this.viewportMatrix.y - o - this.nodeVertical, d = 3 * e + 2 * this.nodeHorizontal, n = 3 * o + 2 * this.nodeVertical;
|
|
1968
|
+
this.trigger.emit({ x: r, y: s, width: d, height: n });
|
|
1969
|
+
}
|
|
2071
1970
|
}
|
|
2072
|
-
class
|
|
1971
|
+
class ze {
|
|
2073
1972
|
constructor() {
|
|
2074
1973
|
i(this, "element", null);
|
|
2075
1974
|
i(this, "canvasDefaults", {});
|
|
2076
|
-
i(this, "dragOptions");
|
|
2077
|
-
i(this, "transformOptions");
|
|
1975
|
+
i(this, "dragOptions", {});
|
|
1976
|
+
i(this, "transformOptions", {});
|
|
2078
1977
|
i(this, "virtualScrollOptions");
|
|
2079
1978
|
i(this, "hasDraggableNode", !1);
|
|
2080
1979
|
i(this, "hasTransformableViewport", !1);
|
|
@@ -2094,13 +1993,13 @@ class Ye {
|
|
|
2094
1993
|
* enables nodes draggable by user
|
|
2095
1994
|
*/
|
|
2096
1995
|
enableUserDraggableNodes(e) {
|
|
2097
|
-
return this.hasDraggableNode = !0, this.dragOptions = e, this;
|
|
1996
|
+
return this.hasDraggableNode = !0, this.dragOptions = e ?? {}, this;
|
|
2098
1997
|
}
|
|
2099
1998
|
/**
|
|
2100
1999
|
* enables viewport transformable by user
|
|
2101
2000
|
*/
|
|
2102
2001
|
enableUserTransformableViewport(e) {
|
|
2103
|
-
return this.hasTransformableViewport = !0, this.transformOptions = e, this;
|
|
2002
|
+
return this.hasTransformableViewport = !0, this.transformOptions = e ?? {}, this;
|
|
2104
2003
|
}
|
|
2105
2004
|
/**
|
|
2106
2005
|
* enables automatic edges update on node resize
|
|
@@ -2122,51 +2021,45 @@ class Ye {
|
|
|
2122
2021
|
*/
|
|
2123
2022
|
build() {
|
|
2124
2023
|
if (this.element === null)
|
|
2125
|
-
throw new
|
|
2024
|
+
throw new S(
|
|
2126
2025
|
"unable to build canvas when no attach element specified"
|
|
2127
2026
|
);
|
|
2128
2027
|
let e = this.boxRenderingTrigger;
|
|
2129
|
-
this.virtualScrollOptions !== void 0 && e === void 0 && (e = new
|
|
2130
|
-
const o = new
|
|
2131
|
-
let s = new
|
|
2028
|
+
this.virtualScrollOptions !== void 0 && e === void 0 && (e = new re());
|
|
2029
|
+
const o = new Ve(), r = new Le();
|
|
2030
|
+
let s = new ce(
|
|
2132
2031
|
o,
|
|
2133
2032
|
r,
|
|
2134
2033
|
this.element
|
|
2135
2034
|
);
|
|
2136
|
-
e !== void 0 && (s = new
|
|
2137
|
-
|
|
2035
|
+
e !== void 0 && (s = new le(s, o, e));
|
|
2036
|
+
const d = new Me(
|
|
2037
|
+
this.element,
|
|
2138
2038
|
o,
|
|
2139
2039
|
r,
|
|
2140
|
-
s
|
|
2040
|
+
s,
|
|
2041
|
+
this.canvasDefaults
|
|
2141
2042
|
);
|
|
2142
|
-
this.hasDraggableNode && (d
|
|
2143
|
-
d,
|
|
2144
|
-
this.element,
|
|
2145
|
-
this.dragOptions
|
|
2146
|
-
)), this.virtualScrollOptions !== void 0 ? d = new fe(
|
|
2043
|
+
return this.hasResizeReactiveNodes && G.configure(d), this.hasDraggableNode && J.configure(d, this.dragOptions), this.virtualScrollOptions !== void 0 ? K.configure(
|
|
2147
2044
|
d,
|
|
2148
|
-
e,
|
|
2149
2045
|
this.transformOptions,
|
|
2150
|
-
|
|
2151
|
-
this.
|
|
2152
|
-
) : this.hasTransformableViewport && (
|
|
2046
|
+
e,
|
|
2047
|
+
this.virtualScrollOptions
|
|
2048
|
+
) : this.hasTransformableViewport && z.configure(
|
|
2153
2049
|
d,
|
|
2154
|
-
this.element,
|
|
2155
2050
|
this.transformOptions
|
|
2156
|
-
));
|
|
2157
|
-
const n = new We(this.element, d, this.canvasDefaults);
|
|
2158
|
-
return this.hasResizeReactiveNodes && j.configure(n), this.reset(), n;
|
|
2051
|
+
), this.reset(), d;
|
|
2159
2052
|
}
|
|
2160
2053
|
reset() {
|
|
2161
|
-
this.element = null, this.canvasDefaults = {}, this.dragOptions =
|
|
2054
|
+
this.element = null, this.canvasDefaults = {}, this.dragOptions = {}, this.transformOptions = {}, this.virtualScrollOptions = void 0, this.hasDraggableNode = !1, this.hasTransformableViewport = !1, this.hasResizeReactiveNodes = !1, this.boxRenderingTrigger = void 0;
|
|
2162
2055
|
}
|
|
2163
2056
|
}
|
|
2164
2057
|
export {
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2058
|
+
Te as BezierEdgeShape,
|
|
2059
|
+
ze as CanvasBuilder,
|
|
2060
|
+
re as EventSubject,
|
|
2061
|
+
be as HorizontalEdgeShape,
|
|
2062
|
+
S as HtmlGraphError,
|
|
2063
|
+
Ne as StraightEdgeShape,
|
|
2064
|
+
me as VerticalEdgeShape
|
|
2172
2065
|
};
|