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