@html-graph/html-graph 3.6.0 → 3.8.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 +63 -54
- package/dist/html-graph.d.ts +130 -12
- package/dist/html-graph.js +1525 -1440
- package/dist/html-graph.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/html-graph.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
const
|
|
1
|
+
var ae = Object.defineProperty;
|
|
2
|
+
var le = (t, e, o) => e in t ? ae(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o;
|
|
3
|
+
var r = (t, e, o) => le(t, typeof e != "symbol" ? e + "" : e, o);
|
|
4
|
+
const ue = () => {
|
|
5
5
|
const t = document.createElement("div");
|
|
6
6
|
return t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.width = "0", t.style.height = "0", t;
|
|
7
|
-
},
|
|
7
|
+
}, ge = () => {
|
|
8
8
|
const t = document.createElement("div");
|
|
9
9
|
return t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.visibility = "hidden", t;
|
|
10
|
-
},
|
|
10
|
+
}, we = () => {
|
|
11
11
|
const t = document.createElement("div");
|
|
12
12
|
return t.style.width = "100%", t.style.height = "100%", t.style.position = "relative", t.style.overflow = "hidden", t;
|
|
13
13
|
};
|
|
14
|
-
class
|
|
15
|
-
constructor(e, o,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
class ie {
|
|
15
|
+
constructor(e, o, i) {
|
|
16
|
+
r(this, "host", we());
|
|
17
|
+
r(this, "container", ue());
|
|
18
|
+
r(this, "nodeIdToWrapperElementMap", /* @__PURE__ */ new Map());
|
|
19
|
+
r(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
|
|
20
|
+
r(this, "applyTransform", () => {
|
|
21
21
|
const e = this.viewportStore.getContentMatrix();
|
|
22
22
|
this.container.style.transform = `matrix(${e.scale}, 0, 0, ${e.scale}, ${e.x}, ${e.y})`;
|
|
23
23
|
});
|
|
24
|
-
this.graphStore = e, this.viewportStore = o, this.element =
|
|
24
|
+
this.graphStore = e, this.viewportStore = o, this.element = i, this.element.appendChild(this.host), this.host.appendChild(this.container), this.viewportStore.onAfterUpdated.subscribe(this.applyTransform);
|
|
25
25
|
}
|
|
26
26
|
attachNode(e) {
|
|
27
|
-
const o = this.graphStore.getNode(e),
|
|
28
|
-
|
|
27
|
+
const o = this.graphStore.getNode(e), i = ge();
|
|
28
|
+
i.appendChild(o.element), this.container.appendChild(i), this.nodeIdToWrapperElementMap.set(e, i), this.updateNodePosition(e), this.updateNodePriority(e), i.style.visibility = "visible";
|
|
29
29
|
}
|
|
30
30
|
detachNode(e) {
|
|
31
31
|
const o = this.nodeIdToWrapperElementMap.get(e);
|
|
@@ -50,35 +50,35 @@ class re {
|
|
|
50
50
|
this.viewportStore.onAfterUpdated.unsubscribe(this.applyTransform), this.clear(), this.element.removeChild(this.host), this.host.removeChild(this.container);
|
|
51
51
|
}
|
|
52
52
|
updateNodePosition(e) {
|
|
53
|
-
const o = this.nodeIdToWrapperElementMap.get(e),
|
|
53
|
+
const o = this.nodeIdToWrapperElementMap.get(e), i = this.graphStore.getNode(e), { width: s, height: h } = i.element.getBoundingClientRect(), n = this.viewportStore.getViewportMatrix().scale, d = i.centerFn(s, h), c = i.x - n * d.x, a = i.y - n * d.y;
|
|
54
54
|
o.style.transform = `translate(${c}px, ${a}px)`;
|
|
55
55
|
}
|
|
56
56
|
updateNodePriority(e) {
|
|
57
|
-
const o = this.graphStore.getNode(e),
|
|
58
|
-
|
|
57
|
+
const o = this.graphStore.getNode(e), i = this.nodeIdToWrapperElementMap.get(e);
|
|
58
|
+
i.style.zIndex = `${o.priority}`;
|
|
59
59
|
}
|
|
60
60
|
updateEdgeShape(e) {
|
|
61
61
|
const o = this.edgeIdToElementMap.get(e);
|
|
62
62
|
this.container.removeChild(o);
|
|
63
|
-
const
|
|
64
|
-
this.edgeIdToElementMap.set(e,
|
|
63
|
+
const i = this.graphStore.getEdge(e);
|
|
64
|
+
this.edgeIdToElementMap.set(e, i.shape.svg), this.container.appendChild(i.shape.svg);
|
|
65
65
|
}
|
|
66
66
|
renderEdge(e) {
|
|
67
|
-
const o = this.graphStore.getEdge(e),
|
|
67
|
+
const o = this.graphStore.getEdge(e), i = this.graphStore.getPort(o.from), s = this.graphStore.getPort(o.to), h = i.element.getBoundingClientRect(), n = s.element.getBoundingClientRect(), d = this.host.getBoundingClientRect(), c = this.viewportStore.getViewportMatrix(), a = h.left - d.left, l = h.top - d.top, g = n.left - d.left, y = n.top - d.top, p = {
|
|
68
68
|
x: c.scale * a + c.x,
|
|
69
69
|
y: c.scale * l + c.y
|
|
70
70
|
}, f = {
|
|
71
71
|
x: c.scale * g + c.x,
|
|
72
72
|
y: c.scale * y + c.y
|
|
73
|
-
},
|
|
73
|
+
}, A = {
|
|
74
74
|
x: p.x,
|
|
75
75
|
y: p.y,
|
|
76
76
|
width: h.width * c.scale,
|
|
77
77
|
height: h.height * c.scale,
|
|
78
|
-
direction:
|
|
78
|
+
direction: i.direction,
|
|
79
79
|
portId: o.from,
|
|
80
|
-
nodeId:
|
|
81
|
-
},
|
|
80
|
+
nodeId: i.nodeId
|
|
81
|
+
}, E = {
|
|
82
82
|
x: f.x,
|
|
83
83
|
y: f.y,
|
|
84
84
|
width: n.width * c.scale,
|
|
@@ -87,19 +87,19 @@ class re {
|
|
|
87
87
|
portId: o.to,
|
|
88
88
|
nodeId: s.nodeId
|
|
89
89
|
};
|
|
90
|
-
o.shape.render({ from:
|
|
90
|
+
o.shape.render({ from: A, to: E });
|
|
91
91
|
}
|
|
92
92
|
updateEdgePriority(e) {
|
|
93
93
|
const o = this.graphStore.getEdge(e);
|
|
94
94
|
o.shape.svg.style.zIndex = `${o.priority}`;
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
-
class
|
|
97
|
+
class fe {
|
|
98
98
|
constructor(e) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
99
|
+
r(this, "xFrom", 1 / 0);
|
|
100
|
+
r(this, "yFrom", 1 / 0);
|
|
101
|
+
r(this, "xTo", 1 / 0);
|
|
102
|
+
r(this, "yTo", 1 / 0);
|
|
103
103
|
this.graphStore = e;
|
|
104
104
|
}
|
|
105
105
|
setRenderingBox(e) {
|
|
@@ -110,27 +110,27 @@ class ge {
|
|
|
110
110
|
return o.x >= this.xFrom && o.x <= this.xTo && o.y >= this.yFrom && o.y <= this.yTo;
|
|
111
111
|
}
|
|
112
112
|
hasEdge(e) {
|
|
113
|
-
const o = this.graphStore.getEdge(e),
|
|
113
|
+
const o = this.graphStore.getEdge(e), i = this.graphStore.getPort(o.from).nodeId, s = this.graphStore.getPort(o.to).nodeId, h = this.graphStore.getNode(i), n = this.graphStore.getNode(s), d = Math.min(h.x, n.x), c = Math.max(h.x, n.x), a = Math.min(h.y, n.y), l = Math.max(h.y, n.y);
|
|
114
114
|
return d <= this.xTo && c >= this.xFrom && a <= this.yTo && l >= this.yFrom;
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
|
-
class
|
|
118
|
-
constructor(e, o,
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
117
|
+
class ve {
|
|
118
|
+
constructor(e, o, i) {
|
|
119
|
+
r(this, "attachedNodes", /* @__PURE__ */ new Set());
|
|
120
|
+
r(this, "attachedEdges", /* @__PURE__ */ new Set());
|
|
121
|
+
r(this, "renderingBox");
|
|
122
|
+
r(this, "updateViewport", (e) => {
|
|
123
123
|
this.renderingBox.setRenderingBox(e);
|
|
124
|
-
const o = /* @__PURE__ */ new Set(),
|
|
124
|
+
const o = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Set();
|
|
125
125
|
this.graphStore.getAllNodeIds().forEach((n) => {
|
|
126
126
|
const d = this.renderingBox.hasNode(n), c = this.attachedNodes.has(n);
|
|
127
|
-
d && !c ? o.add(n) : !d && c &&
|
|
127
|
+
d && !c ? o.add(n) : !d && c && i.add(n);
|
|
128
128
|
}), this.graphStore.getAllEdgeIds().forEach((n) => {
|
|
129
129
|
const d = 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;
|
|
130
|
-
d && (this.renderingBox.hasNode(l) || (o.add(l),
|
|
130
|
+
d && (this.renderingBox.hasNode(l) || (o.add(l), i.delete(l)), this.renderingBox.hasNode(g) || (o.add(g), i.delete(g))), d && !c ? s.add(n) : !d && c && h.add(n);
|
|
131
131
|
}), h.forEach((n) => {
|
|
132
132
|
this.handleDetachEdge(n);
|
|
133
|
-
}),
|
|
133
|
+
}), i.forEach((n) => {
|
|
134
134
|
this.handleDetachNode(n);
|
|
135
135
|
}), o.forEach((n) => {
|
|
136
136
|
this.attachedNodes.has(n) || this.handleAttachNode(n);
|
|
@@ -138,7 +138,7 @@ class ue {
|
|
|
138
138
|
this.handleAttachEdge(n);
|
|
139
139
|
});
|
|
140
140
|
});
|
|
141
|
-
this.htmlView = e, this.graphStore = o, this.trigger =
|
|
141
|
+
this.htmlView = e, this.graphStore = o, this.trigger = i, this.renderingBox = new fe(this.graphStore), this.trigger.subscribe(this.updateViewport);
|
|
142
142
|
}
|
|
143
143
|
attachNode(e) {
|
|
144
144
|
this.renderingBox.hasNode(e) && this.handleAttachNode(e);
|
|
@@ -176,8 +176,8 @@ class ue {
|
|
|
176
176
|
this.clear(), this.htmlView.destroy(), this.trigger.unsubscribe(this.updateViewport);
|
|
177
177
|
}
|
|
178
178
|
attachEdgeEntities(e) {
|
|
179
|
-
const o = this.graphStore.getEdge(e),
|
|
180
|
-
this.attachedNodes.has(
|
|
179
|
+
const o = this.graphStore.getEdge(e), i = this.graphStore.getPort(o.from).nodeId, s = this.graphStore.getPort(o.to).nodeId;
|
|
180
|
+
this.attachedNodes.has(i) || this.handleAttachNode(i), this.attachedNodes.has(s) || this.handleAttachNode(s), this.handleAttachEdge(e);
|
|
181
181
|
}
|
|
182
182
|
handleAttachNode(e) {
|
|
183
183
|
this.attachedNodes.add(e), this.htmlView.attachNode(e);
|
|
@@ -192,9 +192,9 @@ class ue {
|
|
|
192
192
|
this.htmlView.detachEdge(e), this.attachedEdges.delete(e);
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
|
-
class
|
|
195
|
+
class se {
|
|
196
196
|
constructor() {
|
|
197
|
-
|
|
197
|
+
r(this, "callbacks", /* @__PURE__ */ new Set());
|
|
198
198
|
}
|
|
199
199
|
subscribe(e) {
|
|
200
200
|
this.callbacks.add(e);
|
|
@@ -208,14 +208,14 @@ class ie {
|
|
|
208
208
|
});
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
|
-
const
|
|
212
|
-
const t = new
|
|
211
|
+
const x = () => {
|
|
212
|
+
const t = new se();
|
|
213
213
|
return [t, t];
|
|
214
214
|
};
|
|
215
|
-
class
|
|
215
|
+
class ye {
|
|
216
216
|
constructor(e) {
|
|
217
|
-
|
|
218
|
-
|
|
217
|
+
r(this, "onBeforeUpdated");
|
|
218
|
+
r(this, "onAfterUpdated");
|
|
219
219
|
this.viewportStore = e, this.onBeforeUpdated = this.viewportStore.onBeforeUpdated, this.onAfterUpdated = this.viewportStore.onAfterUpdated;
|
|
220
220
|
}
|
|
221
221
|
getViewportMatrix() {
|
|
@@ -225,21 +225,21 @@ class we {
|
|
|
225
225
|
return { ...this.viewportStore.getContentMatrix() };
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
|
-
class
|
|
228
|
+
class pe {
|
|
229
229
|
constructor(e) {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
230
|
+
r(this, "onAfterNodeAdded");
|
|
231
|
+
r(this, "onAfterNodeUpdated");
|
|
232
|
+
r(this, "onAfterNodePriorityUpdated");
|
|
233
|
+
r(this, "onBeforeNodeRemoved");
|
|
234
|
+
r(this, "onAfterPortMarked");
|
|
235
|
+
r(this, "onAfterPortUpdated");
|
|
236
|
+
r(this, "onBeforePortUnmarked");
|
|
237
|
+
r(this, "onAfterEdgeAdded");
|
|
238
|
+
r(this, "onAfterEdgeShapeUpdated");
|
|
239
|
+
r(this, "onAfterEdgeUpdated");
|
|
240
|
+
r(this, "onAfterEdgePriorityUpdated");
|
|
241
|
+
r(this, "onBeforeEdgeRemoved");
|
|
242
|
+
r(this, "onBeforeClear");
|
|
243
243
|
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;
|
|
244
244
|
}
|
|
245
245
|
getNode(e) {
|
|
@@ -252,6 +252,10 @@ class fe {
|
|
|
252
252
|
priority: o.priority
|
|
253
253
|
};
|
|
254
254
|
}
|
|
255
|
+
getElementNodeId(e) {
|
|
256
|
+
return this.graphStore.getElementNodeId(e) ?? null;
|
|
257
|
+
}
|
|
258
|
+
// TODO: use Set in v4
|
|
255
259
|
getAllNodeIds() {
|
|
256
260
|
return this.graphStore.getAllNodeIds();
|
|
257
261
|
}
|
|
@@ -263,12 +267,19 @@ class fe {
|
|
|
263
267
|
nodeId: o.nodeId
|
|
264
268
|
};
|
|
265
269
|
}
|
|
270
|
+
// TODO: use Set in v4
|
|
266
271
|
getAllPortIds() {
|
|
267
272
|
return this.graphStore.getAllPortIds();
|
|
268
273
|
}
|
|
274
|
+
// TODO: use Set in v4
|
|
269
275
|
getNodePortIds(e) {
|
|
270
276
|
return this.graphStore.getNodePortIds(e) ?? null;
|
|
271
277
|
}
|
|
278
|
+
// TODO: use Set in v4
|
|
279
|
+
getElementPortsIds(e) {
|
|
280
|
+
return [...this.graphStore.getElementPortsIds(e)];
|
|
281
|
+
}
|
|
282
|
+
// TODO: use Set in v4
|
|
272
283
|
getAllEdgeIds() {
|
|
273
284
|
return this.graphStore.getAllEdgeIds();
|
|
274
285
|
}
|
|
@@ -276,34 +287,42 @@ class fe {
|
|
|
276
287
|
const o = this.graphStore.getEdge(e);
|
|
277
288
|
return o === void 0 ? null : { from: o.from, to: o.to, priority: o.priority };
|
|
278
289
|
}
|
|
290
|
+
// TODO: use Set in v4
|
|
279
291
|
getPortIncomingEdgeIds(e) {
|
|
280
292
|
return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortIncomingEdgeIds(e);
|
|
281
293
|
}
|
|
294
|
+
// TODO: use Set in v4
|
|
282
295
|
getPortOutcomingEdgeIds(e) {
|
|
283
296
|
return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortOutcomingEdgeIds(e);
|
|
284
297
|
}
|
|
298
|
+
// TODO: use Set in v4
|
|
285
299
|
getPortCycleEdgeIds(e) {
|
|
286
300
|
return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortCycleEdgeIds(e);
|
|
287
301
|
}
|
|
302
|
+
// TODO: use Set in v4
|
|
288
303
|
getPortAdjacentEdgeIds(e) {
|
|
289
304
|
return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortAdjacentEdgeIds(e);
|
|
290
305
|
}
|
|
306
|
+
// TODO: use Set in v4
|
|
291
307
|
getNodeIncomingEdgeIds(e) {
|
|
292
308
|
return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeIncomingEdgeIds(e);
|
|
293
309
|
}
|
|
310
|
+
// TODO: use Set in v4
|
|
294
311
|
getNodeOutcomingEdgeIds(e) {
|
|
295
312
|
return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeOutcomingEdgeIds(e);
|
|
296
313
|
}
|
|
314
|
+
// TODO: use Set in v4
|
|
297
315
|
getNodeCycleEdgeIds(e) {
|
|
298
316
|
return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeCycleEdgeIds(e);
|
|
299
317
|
}
|
|
318
|
+
// TODO: use Set in v4
|
|
300
319
|
getNodeAdjacentEdgeIds(e) {
|
|
301
320
|
return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeAdjacentEdgeIds(e);
|
|
302
321
|
}
|
|
303
322
|
}
|
|
304
323
|
class C {
|
|
305
324
|
constructor(e) {
|
|
306
|
-
|
|
325
|
+
r(this, "counter", 0);
|
|
307
326
|
this.checkExists = e;
|
|
308
327
|
}
|
|
309
328
|
create(e) {
|
|
@@ -320,772 +339,84 @@ class C {
|
|
|
320
339
|
class S extends Error {
|
|
321
340
|
constructor() {
|
|
322
341
|
super(...arguments);
|
|
323
|
-
|
|
342
|
+
r(this, "name", "HtmlGraphError");
|
|
324
343
|
}
|
|
325
344
|
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
t.toVector,
|
|
353
|
-
t.to
|
|
354
|
-
), r = {
|
|
355
|
-
x: e.x + t.fromVector.x * t.curvature,
|
|
356
|
-
y: e.y + t.fromVector.y * t.curvature
|
|
357
|
-
}, s = {
|
|
358
|
-
x: o.x - t.toVector.x * t.curvature,
|
|
359
|
-
y: o.y - t.toVector.y * t.curvature
|
|
360
|
-
}, h = `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} `, d = t.hasTargetArrow ? "" : ` M ${o.x} ${o.y} L ${t.to.x} ${t.to.y}`;
|
|
361
|
-
return `${n}${h}${d}`;
|
|
362
|
-
}, Ee = (t) => {
|
|
363
|
-
const e = t.hasSourceArrow ? v(
|
|
364
|
-
{ x: t.arrowLength, y: w.y },
|
|
365
|
-
t.fromVector,
|
|
366
|
-
w
|
|
367
|
-
) : w, o = t.hasTargetArrow ? v(
|
|
368
|
-
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
369
|
-
t.toVector,
|
|
370
|
-
t.to
|
|
371
|
-
) : t.to, r = t.arrowLength, s = Math.cos(t.detourDirection) * t.detourDistance, h = Math.sin(t.detourDirection) * t.detourDistance, n = s * t.flipX, d = h * t.flipY, c = v(
|
|
372
|
-
{ x: r, y: w.y },
|
|
373
|
-
t.fromVector,
|
|
374
|
-
w
|
|
375
|
-
), a = {
|
|
376
|
-
x: c.x + n,
|
|
377
|
-
y: c.y + d
|
|
378
|
-
}, l = v(
|
|
379
|
-
{ x: t.to.x - r, y: t.to.y },
|
|
380
|
-
t.toVector,
|
|
381
|
-
t.to
|
|
382
|
-
), g = {
|
|
383
|
-
x: l.x + n,
|
|
384
|
-
y: l.y + d
|
|
385
|
-
}, y = { x: (a.x + g.x) / 2, y: (a.y + g.y) / 2 }, p = {
|
|
386
|
-
x: c.x + t.curvature * t.fromVector.x,
|
|
387
|
-
y: c.y + t.curvature * t.fromVector.y
|
|
388
|
-
}, f = {
|
|
389
|
-
x: l.x - t.curvature * t.toVector.x,
|
|
390
|
-
y: l.y - t.curvature * t.toVector.y
|
|
391
|
-
}, E = {
|
|
392
|
-
x: c.x + n,
|
|
393
|
-
y: c.y + d
|
|
394
|
-
}, x = {
|
|
395
|
-
x: l.x + n,
|
|
396
|
-
y: l.y + d
|
|
397
|
-
};
|
|
398
|
-
return [
|
|
399
|
-
`M ${e.x} ${e.y}`,
|
|
400
|
-
`L ${c.x} ${c.y}`,
|
|
401
|
-
`C ${p.x} ${p.y} ${E.x} ${E.y} ${y.x} ${y.y}`,
|
|
402
|
-
`C ${x.x} ${x.y} ${f.x} ${f.y} ${l.x} ${l.y}`,
|
|
403
|
-
`L ${o.x} ${o.y}`
|
|
404
|
-
].join(" ");
|
|
405
|
-
}, L = (t, e) => {
|
|
406
|
-
const o = [];
|
|
407
|
-
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) {
|
|
408
|
-
const r = t.length - 1;
|
|
409
|
-
let s = 0, h = 0, n = 0;
|
|
410
|
-
t.forEach((d, c) => {
|
|
411
|
-
let a = 0, l = 0, g = 0;
|
|
412
|
-
const y = c > 0, p = c < r, f = y && p;
|
|
413
|
-
if (y && (a = -s, l = -h, g = n), p) {
|
|
414
|
-
const V = t[c + 1];
|
|
415
|
-
s = V.x - d.x, h = V.y - d.y, n = Math.sqrt(s * s + h * h);
|
|
416
|
-
}
|
|
417
|
-
const x = n !== 0 ? Math.min((f ? e : 0) / n, c < r - 1 ? 0.5 : 1) : 0, T = f ? { x: d.x + s * x, y: d.y + h * x } : d, m = g !== 0 ? Math.min((f ? e : 0) / g, c > 1 ? 0.5 : 1) : 0, D = f ? { x: d.x + a * m, y: d.y + l * m } : d;
|
|
418
|
-
c > 0 && o.push(`L ${D.x} ${D.y}`), f && o.push(
|
|
419
|
-
`C ${d.x} ${d.y} ${d.x} ${d.y} ${T.x} ${T.y}`
|
|
420
|
-
);
|
|
345
|
+
class ne {
|
|
346
|
+
constructor(e, o, i, s, h) {
|
|
347
|
+
/**
|
|
348
|
+
* provides api for accessing model of rendered graph
|
|
349
|
+
*/
|
|
350
|
+
r(this, "graph");
|
|
351
|
+
/**
|
|
352
|
+
* provides api for accessing viewport state
|
|
353
|
+
*/
|
|
354
|
+
r(this, "viewport");
|
|
355
|
+
r(this, "nodeIdGenerator", new C(
|
|
356
|
+
(e) => this.graph.getNode(e) !== null
|
|
357
|
+
));
|
|
358
|
+
r(this, "portIdGenerator", new C(
|
|
359
|
+
(e) => this.graph.getPort(e) !== null
|
|
360
|
+
));
|
|
361
|
+
r(this, "edgeIdGenerator", new C(
|
|
362
|
+
(e) => this.graph.getEdge(e) !== null
|
|
363
|
+
));
|
|
364
|
+
r(this, "onAfterNodeAdded", (e) => {
|
|
365
|
+
this.htmlView.attachNode(e);
|
|
366
|
+
});
|
|
367
|
+
r(this, "onAfterNodeUpdated", (e) => {
|
|
368
|
+
this.htmlView.updateNodePosition(e), this.graphStore.getNodeAdjacentEdgeIds(e).forEach((i) => {
|
|
369
|
+
this.htmlView.renderEdge(i);
|
|
370
|
+
});
|
|
421
371
|
});
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
return L(
|
|
471
|
-
[e, s, a, g, l, o],
|
|
472
|
-
t.roundness
|
|
473
|
-
);
|
|
474
|
-
}, Se = (t) => {
|
|
475
|
-
const e = t.hasSourceArrow ? v(
|
|
476
|
-
{ x: t.arrowLength, y: w.y },
|
|
477
|
-
t.fromVector,
|
|
478
|
-
w
|
|
479
|
-
) : w, o = t.hasTargetArrow ? v(
|
|
480
|
-
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
481
|
-
t.toVector,
|
|
482
|
-
t.to
|
|
483
|
-
) : t.to, r = t.arrowLength + t.arrowOffset, s = v(
|
|
484
|
-
{ x: r, y: w.y },
|
|
485
|
-
t.fromVector,
|
|
486
|
-
w
|
|
487
|
-
), h = v(
|
|
488
|
-
{ x: t.to.x - r, y: t.to.y },
|
|
489
|
-
t.toVector,
|
|
490
|
-
t.to
|
|
491
|
-
);
|
|
492
|
-
return L([e, s, h, o], t.roundness);
|
|
493
|
-
}, Te = (t) => {
|
|
494
|
-
const e = t.hasSourceArrow ? v(
|
|
495
|
-
{ x: t.arrowLength, y: w.y },
|
|
496
|
-
t.fromVector,
|
|
497
|
-
w
|
|
498
|
-
) : w, o = t.hasTargetArrow ? v(
|
|
499
|
-
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
500
|
-
t.toVector,
|
|
501
|
-
t.to
|
|
502
|
-
) : t.to, r = t.arrowLength + t.arrowOffset, s = r - t.roundness, h = v(
|
|
503
|
-
{ x: s, y: w.y },
|
|
504
|
-
t.fromVector,
|
|
505
|
-
w
|
|
506
|
-
), n = v(
|
|
507
|
-
{ x: t.to.x - s, y: t.to.y },
|
|
508
|
-
t.toVector,
|
|
509
|
-
t.to
|
|
510
|
-
), d = Math.max((h.y + n.y) / 2, r), c = t.to.x / 2, a = {
|
|
511
|
-
x: h.x,
|
|
512
|
-
y: t.flipY > 0 ? d : -r
|
|
513
|
-
}, l = { x: c, y: a.y }, g = {
|
|
514
|
-
x: n.x,
|
|
515
|
-
y: t.flipY > 0 ? t.to.y - d : t.to.y + r
|
|
516
|
-
}, y = { x: c, y: g.y };
|
|
517
|
-
return L(
|
|
518
|
-
[e, h, a, l, y, g, n, o],
|
|
519
|
-
t.roundness
|
|
520
|
-
);
|
|
521
|
-
}, z = (t) => {
|
|
522
|
-
const e = t.arrowOffset, o = t.side, r = t.arrowLength + e, s = r + 2 * o, n = [
|
|
523
|
-
{ x: t.arrowLength, y: w.y },
|
|
524
|
-
{ x: r, y: w.y },
|
|
525
|
-
{ x: r, y: t.side },
|
|
526
|
-
{ x: s, y: t.side },
|
|
527
|
-
{ x: s, y: -t.side },
|
|
528
|
-
{ x: r, y: -t.side },
|
|
529
|
-
{ x: r, y: w.y },
|
|
530
|
-
{ x: t.arrowLength, y: w.y }
|
|
531
|
-
].map(
|
|
532
|
-
(c) => v(c, t.fromVector, w)
|
|
533
|
-
), d = `M ${w.x} ${w.y} L ${n[0].x} ${n[0].y} `;
|
|
534
|
-
return `${t.hasSourceArrow || t.hasTargetArrow ? "" : d}${L(n, t.roundness)}`;
|
|
535
|
-
}, me = (t) => {
|
|
536
|
-
const e = t.smallRadius, o = t.radius, r = Math.sqrt(e * e + o * o), s = e + o, h = t.arrowLength + r * (1 - o / s), n = e * o / s, c = [
|
|
537
|
-
{ x: t.arrowLength, y: w.y },
|
|
538
|
-
{ x: h, y: n },
|
|
539
|
-
{ x: h, y: -n }
|
|
540
|
-
].map(
|
|
541
|
-
(g) => v(g, t.fromVector, w)
|
|
542
|
-
), a = [
|
|
543
|
-
`M ${c[0].x} ${c[0].y}`,
|
|
544
|
-
`A ${e} ${e} 0 0 1 ${c[1].x} ${c[1].y}`,
|
|
545
|
-
`A ${o} ${o} 0 1 0 ${c[2].x} ${c[2].y}`,
|
|
546
|
-
`A ${e} ${e} 0 0 1 ${c[0].x} ${c[0].y}`
|
|
547
|
-
].join(" "), l = `M 0 0 L ${c[0].x} ${c[0].y} `;
|
|
548
|
-
return `${t.hasSourceArrow || t.hasTargetArrow ? "" : l}${a}`;
|
|
549
|
-
}, u = Object.freeze({
|
|
550
|
-
color: "#777777",
|
|
551
|
-
width: 1,
|
|
552
|
-
arrowLength: 15,
|
|
553
|
-
arrowWidth: 4,
|
|
554
|
-
arrowOffset: 15,
|
|
555
|
-
hasSourceArrow: !1,
|
|
556
|
-
hasTargetArrow: !1,
|
|
557
|
-
cycleRadius: 30,
|
|
558
|
-
cycleSquareSide: 30,
|
|
559
|
-
roundness: 10,
|
|
560
|
-
detourDistance: 100,
|
|
561
|
-
detourDirection: -Math.PI / 2,
|
|
562
|
-
detourDirectionVertical: 0,
|
|
563
|
-
smallCycleRadius: 15,
|
|
564
|
-
curvature: 90
|
|
565
|
-
}), Z = (t, e, o, r) => {
|
|
566
|
-
const h = [
|
|
567
|
-
w,
|
|
568
|
-
{ x: o, y: r },
|
|
569
|
-
{ x: o, y: -r }
|
|
570
|
-
].map((a) => v(a, t, w)).map((a) => ({ x: a.x + e.x, y: a.y + e.y })), n = `M ${h[0].x} ${h[0].y}`, d = `L ${h[1].x} ${h[1].y}`, c = `L ${h[2].x} ${h[2].y}`;
|
|
571
|
-
return `${n} ${d} ${c}`;
|
|
572
|
-
}, _ = (t) => {
|
|
573
|
-
const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
574
|
-
return e.setAttribute("fill", t), e;
|
|
575
|
-
}, be = () => {
|
|
576
|
-
const t = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
|
577
|
-
return t.style.transformOrigin = "50% 50%", t;
|
|
578
|
-
}, Pe = (t, e) => {
|
|
579
|
-
const o = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
580
|
-
return o.setAttribute("stroke", t), o.setAttribute("stroke-width", `${e}`), o.setAttribute("fill", "none"), o;
|
|
581
|
-
}, Ne = (t, e) => {
|
|
582
|
-
const o = {
|
|
583
|
-
x: t.x + t.width / 2,
|
|
584
|
-
y: t.y + t.height / 2
|
|
585
|
-
}, r = {
|
|
586
|
-
x: e.x + e.width / 2,
|
|
587
|
-
y: e.y + e.height / 2
|
|
588
|
-
}, s = Math.min(o.x, r.x), h = Math.min(o.y, r.y), n = Math.abs(r.x - o.x), d = Math.abs(r.y - o.y), c = o.x <= r.x ? 1 : -1, a = o.y <= r.y ? 1 : -1;
|
|
589
|
-
return {
|
|
590
|
-
x: s,
|
|
591
|
-
y: h,
|
|
592
|
-
width: n,
|
|
593
|
-
height: d,
|
|
594
|
-
flipX: c,
|
|
595
|
-
flipY: a
|
|
596
|
-
};
|
|
597
|
-
}, Me = () => {
|
|
598
|
-
const t = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
599
|
-
return t.style.pointerEvents = "none", t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.overflow = "visible", t;
|
|
600
|
-
}, q = (t, e, o) => ({ x: e * Math.cos(t), y: o * Math.sin(t) });
|
|
601
|
-
class I {
|
|
602
|
-
constructor(e) {
|
|
603
|
-
i(this, "svg", Me());
|
|
604
|
-
i(this, "group", be());
|
|
605
|
-
i(this, "line");
|
|
606
|
-
i(this, "sourceArrow", null);
|
|
607
|
-
i(this, "targetArrow", null);
|
|
608
|
-
this.params = e, this.svg.appendChild(this.group), this.line = Pe(e.color, e.width), this.group.appendChild(this.line), e.hasSourceArrow && (this.sourceArrow = _(e.color), this.group.appendChild(this.sourceArrow)), e.hasTargetArrow && (this.targetArrow = _(e.color), this.group.appendChild(this.targetArrow));
|
|
609
|
-
}
|
|
610
|
-
render(e) {
|
|
611
|
-
const { x: o, y: r, width: s, height: h, flipX: n, flipY: d } = Ne(
|
|
612
|
-
e.from,
|
|
613
|
-
e.to
|
|
614
|
-
);
|
|
615
|
-
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${Math.max(s, 1)}px`, this.svg.style.height = `${Math.max(h, 1)}px`, this.group.style.transform = `scale(${n}, ${d})`;
|
|
616
|
-
const c = q(
|
|
617
|
-
e.from.direction,
|
|
618
|
-
n,
|
|
619
|
-
d
|
|
620
|
-
), a = q(
|
|
621
|
-
e.to.direction,
|
|
622
|
-
n,
|
|
623
|
-
d
|
|
624
|
-
), l = {
|
|
625
|
-
x: s,
|
|
626
|
-
y: h
|
|
627
|
-
};
|
|
628
|
-
let g, y = a, p = -this.params.arrowLength;
|
|
629
|
-
if (e.from.portId === e.to.portId ? (g = this.params.createCyclePath(
|
|
630
|
-
c,
|
|
631
|
-
a,
|
|
632
|
-
l,
|
|
633
|
-
n,
|
|
634
|
-
d
|
|
635
|
-
), y = c, p = this.params.arrowLength) : e.from.nodeId === e.to.nodeId ? g = this.params.createDetourPath(
|
|
636
|
-
c,
|
|
637
|
-
a,
|
|
638
|
-
l,
|
|
639
|
-
n,
|
|
640
|
-
d
|
|
641
|
-
) : g = this.params.createLinePath(
|
|
642
|
-
c,
|
|
643
|
-
a,
|
|
644
|
-
l,
|
|
645
|
-
n,
|
|
646
|
-
d
|
|
647
|
-
), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
648
|
-
const f = Z(
|
|
649
|
-
c,
|
|
650
|
-
w,
|
|
651
|
-
this.params.arrowLength,
|
|
652
|
-
this.params.arrowWidth
|
|
653
|
-
);
|
|
654
|
-
this.sourceArrow.setAttribute("d", f);
|
|
655
|
-
}
|
|
656
|
-
if (this.targetArrow) {
|
|
657
|
-
const f = Z(
|
|
658
|
-
y,
|
|
659
|
-
l,
|
|
660
|
-
p,
|
|
661
|
-
this.params.arrowWidth
|
|
662
|
-
);
|
|
663
|
-
this.targetArrow.setAttribute("d", f);
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
class De {
|
|
668
|
-
constructor(e) {
|
|
669
|
-
i(this, "svg");
|
|
670
|
-
i(this, "arrowLength");
|
|
671
|
-
i(this, "arrowWidth");
|
|
672
|
-
i(this, "curvature");
|
|
673
|
-
i(this, "portCycleRadius");
|
|
674
|
-
i(this, "portCycleSmallRadius");
|
|
675
|
-
i(this, "detourDirection");
|
|
676
|
-
i(this, "detourDistance");
|
|
677
|
-
i(this, "hasSourceArrow");
|
|
678
|
-
i(this, "hasTargetArrow");
|
|
679
|
-
i(this, "genericShape");
|
|
680
|
-
i(this, "createCyclePath", (e) => me({
|
|
681
|
-
fromVector: e,
|
|
682
|
-
radius: this.portCycleRadius,
|
|
683
|
-
smallRadius: this.portCycleSmallRadius,
|
|
684
|
-
arrowLength: this.arrowLength,
|
|
685
|
-
hasSourceArrow: this.hasSourceArrow,
|
|
686
|
-
hasTargetArrow: this.hasTargetArrow
|
|
687
|
-
}));
|
|
688
|
-
i(this, "createDetourPath", (e, o, r, s, h) => Ee({
|
|
689
|
-
to: r,
|
|
690
|
-
fromVector: e,
|
|
691
|
-
toVector: o,
|
|
692
|
-
flipX: s,
|
|
693
|
-
flipY: h,
|
|
694
|
-
arrowLength: this.arrowLength,
|
|
695
|
-
detourDirection: this.detourDirection,
|
|
696
|
-
detourDistance: this.detourDistance,
|
|
697
|
-
curvature: this.curvature,
|
|
698
|
-
hasSourceArrow: this.hasSourceArrow,
|
|
699
|
-
hasTargetArrow: this.hasTargetArrow
|
|
700
|
-
}));
|
|
701
|
-
i(this, "createLinePath", (e, o, r) => xe({
|
|
702
|
-
to: r,
|
|
703
|
-
fromVector: e,
|
|
704
|
-
toVector: o,
|
|
705
|
-
arrowLength: this.arrowLength,
|
|
706
|
-
curvature: this.curvature,
|
|
707
|
-
hasSourceArrow: this.hasSourceArrow,
|
|
708
|
-
hasTargetArrow: this.hasTargetArrow
|
|
709
|
-
}));
|
|
710
|
-
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, this.genericShape = new I({
|
|
711
|
-
color: (e == null ? void 0 : e.color) ?? u.color,
|
|
712
|
-
width: (e == null ? void 0 : e.width) ?? u.width,
|
|
713
|
-
arrowLength: this.arrowLength,
|
|
714
|
-
arrowWidth: this.arrowWidth,
|
|
715
|
-
hasSourceArrow: this.hasSourceArrow,
|
|
716
|
-
hasTargetArrow: this.hasTargetArrow,
|
|
717
|
-
createCyclePath: this.createCyclePath,
|
|
718
|
-
createDetourPath: this.createDetourPath,
|
|
719
|
-
createLinePath: this.createLinePath
|
|
720
|
-
}), this.svg = this.genericShape.svg;
|
|
721
|
-
}
|
|
722
|
-
render(e) {
|
|
723
|
-
this.genericShape.render(e);
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
class Ve {
|
|
727
|
-
constructor(e) {
|
|
728
|
-
i(this, "svg");
|
|
729
|
-
i(this, "arrowLength");
|
|
730
|
-
i(this, "arrowWidth");
|
|
731
|
-
i(this, "arrowOffset");
|
|
732
|
-
i(this, "roundness");
|
|
733
|
-
i(this, "cycleSquareSide");
|
|
734
|
-
i(this, "detourDirection");
|
|
735
|
-
i(this, "detourDistance");
|
|
736
|
-
i(this, "hasSourceArrow");
|
|
737
|
-
i(this, "hasTargetArrow");
|
|
738
|
-
i(this, "genericShape");
|
|
739
|
-
i(this, "createCyclePath", (e) => z({
|
|
740
|
-
fromVector: e,
|
|
741
|
-
arrowLength: this.arrowLength,
|
|
742
|
-
side: this.cycleSquareSide,
|
|
743
|
-
arrowOffset: this.arrowOffset,
|
|
744
|
-
roundness: this.roundness,
|
|
745
|
-
hasSourceArrow: this.hasSourceArrow,
|
|
746
|
-
hasTargetArrow: this.hasTargetArrow
|
|
747
|
-
}));
|
|
748
|
-
i(this, "createDetourPath", (e, o, r, s, h) => F({
|
|
749
|
-
to: r,
|
|
750
|
-
fromVector: e,
|
|
751
|
-
toVector: o,
|
|
752
|
-
flipX: s,
|
|
753
|
-
flipY: h,
|
|
754
|
-
arrowLength: this.arrowLength,
|
|
755
|
-
arrowOffset: this.arrowOffset,
|
|
756
|
-
roundness: this.roundness,
|
|
757
|
-
detourDirection: this.detourDirection,
|
|
758
|
-
detourDistance: this.detourDistance,
|
|
759
|
-
hasSourceArrow: this.hasSourceArrow,
|
|
760
|
-
hasTargetArrow: this.hasTargetArrow
|
|
761
|
-
}));
|
|
762
|
-
i(this, "createLinePath", (e, o, r, s) => Ae({
|
|
763
|
-
to: r,
|
|
764
|
-
fromVector: e,
|
|
765
|
-
toVector: o,
|
|
766
|
-
flipX: s,
|
|
767
|
-
arrowLength: this.arrowLength,
|
|
768
|
-
arrowOffset: this.arrowOffset,
|
|
769
|
-
roundness: this.roundness,
|
|
770
|
-
hasSourceArrow: this.hasSourceArrow,
|
|
771
|
-
hasTargetArrow: this.hasTargetArrow
|
|
772
|
-
}));
|
|
773
|
-
this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? u.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? u.cycleSquareSide;
|
|
774
|
-
const o = (e == null ? void 0 : e.roundness) ?? u.roundness;
|
|
775
|
-
this.roundness = Math.min(
|
|
776
|
-
o,
|
|
777
|
-
this.arrowOffset,
|
|
778
|
-
this.cycleSquareSide / 2
|
|
779
|
-
), 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, this.genericShape = new I({
|
|
780
|
-
color: (e == null ? void 0 : e.color) ?? u.color,
|
|
781
|
-
width: (e == null ? void 0 : e.width) ?? u.width,
|
|
782
|
-
arrowLength: this.arrowLength,
|
|
783
|
-
arrowWidth: this.arrowWidth,
|
|
784
|
-
hasSourceArrow: this.hasSourceArrow,
|
|
785
|
-
hasTargetArrow: this.hasTargetArrow,
|
|
786
|
-
createCyclePath: this.createCyclePath,
|
|
787
|
-
createDetourPath: this.createDetourPath,
|
|
788
|
-
createLinePath: this.createLinePath
|
|
789
|
-
}), this.svg = this.genericShape.svg;
|
|
790
|
-
}
|
|
791
|
-
render(e) {
|
|
792
|
-
this.genericShape.render(e);
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
class Le {
|
|
796
|
-
constructor(e) {
|
|
797
|
-
i(this, "svg");
|
|
798
|
-
i(this, "arrowLength");
|
|
799
|
-
i(this, "arrowWidth");
|
|
800
|
-
i(this, "arrowOffset");
|
|
801
|
-
i(this, "roundness");
|
|
802
|
-
i(this, "cycleSquareSide");
|
|
803
|
-
i(this, "detourDirection");
|
|
804
|
-
i(this, "detourDistance");
|
|
805
|
-
i(this, "hasSourceArrow");
|
|
806
|
-
i(this, "hasTargetArrow");
|
|
807
|
-
i(this, "genericShape");
|
|
808
|
-
i(this, "createCyclePath", (e) => z({
|
|
809
|
-
fromVector: e,
|
|
810
|
-
arrowLength: this.arrowLength,
|
|
811
|
-
side: this.cycleSquareSide,
|
|
812
|
-
arrowOffset: this.arrowOffset,
|
|
813
|
-
roundness: this.roundness,
|
|
814
|
-
hasSourceArrow: this.hasSourceArrow,
|
|
815
|
-
hasTargetArrow: this.hasTargetArrow
|
|
816
|
-
}));
|
|
817
|
-
i(this, "createDetourPath", (e, o, r, s, h) => F({
|
|
818
|
-
to: r,
|
|
819
|
-
fromVector: e,
|
|
820
|
-
toVector: o,
|
|
821
|
-
flipX: s,
|
|
822
|
-
flipY: h,
|
|
823
|
-
arrowLength: this.arrowLength,
|
|
824
|
-
arrowOffset: this.arrowOffset,
|
|
825
|
-
roundness: this.roundness,
|
|
826
|
-
detourDirection: this.detourDirection,
|
|
827
|
-
detourDistance: this.detourDistance,
|
|
828
|
-
hasSourceArrow: this.hasSourceArrow,
|
|
829
|
-
hasTargetArrow: this.hasTargetArrow
|
|
830
|
-
}));
|
|
831
|
-
i(this, "createLinePath", (e, o, r) => Se({
|
|
832
|
-
to: r,
|
|
833
|
-
fromVector: e,
|
|
834
|
-
toVector: o,
|
|
835
|
-
arrowLength: this.arrowLength,
|
|
836
|
-
arrowOffset: this.arrowOffset,
|
|
837
|
-
roundness: this.roundness,
|
|
838
|
-
hasSourceArrow: this.hasSourceArrow,
|
|
839
|
-
hasTargetArrow: this.hasTargetArrow
|
|
840
|
-
}));
|
|
841
|
-
this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? u.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? u.cycleSquareSide;
|
|
842
|
-
const o = (e == null ? void 0 : e.roundness) ?? u.roundness;
|
|
843
|
-
this.roundness = Math.min(
|
|
844
|
-
o,
|
|
845
|
-
this.arrowOffset,
|
|
846
|
-
this.cycleSquareSide / 2
|
|
847
|
-
), 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, this.genericShape = new I({
|
|
848
|
-
color: (e == null ? void 0 : e.color) ?? u.color,
|
|
849
|
-
width: (e == null ? void 0 : e.width) ?? u.width,
|
|
850
|
-
arrowLength: this.arrowLength,
|
|
851
|
-
arrowWidth: this.arrowWidth,
|
|
852
|
-
hasSourceArrow: this.hasSourceArrow,
|
|
853
|
-
hasTargetArrow: this.hasTargetArrow,
|
|
854
|
-
createCyclePath: this.createCyclePath,
|
|
855
|
-
createDetourPath: this.createDetourPath,
|
|
856
|
-
createLinePath: this.createLinePath
|
|
857
|
-
}), this.svg = this.genericShape.svg;
|
|
858
|
-
}
|
|
859
|
-
render(e) {
|
|
860
|
-
this.genericShape.render(e);
|
|
861
|
-
}
|
|
862
|
-
}
|
|
863
|
-
class Re {
|
|
864
|
-
constructor(e) {
|
|
865
|
-
i(this, "svg");
|
|
866
|
-
i(this, "arrowLength");
|
|
867
|
-
i(this, "arrowWidth");
|
|
868
|
-
i(this, "arrowOffset");
|
|
869
|
-
i(this, "roundness");
|
|
870
|
-
i(this, "cycleSquareSide");
|
|
871
|
-
i(this, "detourDirection");
|
|
872
|
-
i(this, "detourDistance");
|
|
873
|
-
i(this, "hasSourceArrow");
|
|
874
|
-
i(this, "hasTargetArrow");
|
|
875
|
-
i(this, "genericShape");
|
|
876
|
-
i(this, "createCyclePath", (e) => z({
|
|
877
|
-
fromVector: e,
|
|
878
|
-
arrowLength: this.arrowLength,
|
|
879
|
-
side: this.cycleSquareSide,
|
|
880
|
-
arrowOffset: this.arrowOffset,
|
|
881
|
-
roundness: this.roundness,
|
|
882
|
-
hasSourceArrow: this.hasSourceArrow,
|
|
883
|
-
hasTargetArrow: this.hasTargetArrow
|
|
884
|
-
}));
|
|
885
|
-
i(this, "createDetourPath", (e, o, r, s, h) => F({
|
|
886
|
-
to: r,
|
|
887
|
-
fromVector: e,
|
|
888
|
-
toVector: o,
|
|
889
|
-
flipX: s,
|
|
890
|
-
flipY: h,
|
|
891
|
-
arrowLength: this.arrowLength,
|
|
892
|
-
arrowOffset: this.arrowOffset,
|
|
893
|
-
roundness: this.roundness,
|
|
894
|
-
detourDirection: this.detourDirection,
|
|
895
|
-
detourDistance: this.detourDistance,
|
|
896
|
-
hasSourceArrow: this.hasSourceArrow,
|
|
897
|
-
hasTargetArrow: this.hasTargetArrow
|
|
898
|
-
}));
|
|
899
|
-
i(this, "createLinePath", (e, o, r, s, h) => Te({
|
|
900
|
-
to: r,
|
|
901
|
-
fromVector: e,
|
|
902
|
-
toVector: o,
|
|
903
|
-
flipY: h,
|
|
904
|
-
arrowLength: this.arrowLength,
|
|
905
|
-
arrowOffset: this.arrowOffset,
|
|
906
|
-
roundness: this.roundness,
|
|
907
|
-
hasSourceArrow: this.hasSourceArrow,
|
|
908
|
-
hasTargetArrow: this.hasTargetArrow
|
|
909
|
-
}));
|
|
910
|
-
this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? u.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? u.cycleSquareSide;
|
|
911
|
-
const o = (e == null ? void 0 : e.roundness) ?? u.roundness;
|
|
912
|
-
this.roundness = Math.min(
|
|
913
|
-
o,
|
|
914
|
-
this.arrowOffset,
|
|
915
|
-
this.cycleSquareSide / 2
|
|
916
|
-
), 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, this.genericShape = new I({
|
|
917
|
-
color: (e == null ? void 0 : e.color) ?? u.color,
|
|
918
|
-
width: (e == null ? void 0 : e.width) ?? u.width,
|
|
919
|
-
arrowLength: this.arrowLength,
|
|
920
|
-
arrowWidth: this.arrowWidth,
|
|
921
|
-
hasSourceArrow: this.hasSourceArrow,
|
|
922
|
-
hasTargetArrow: this.hasTargetArrow,
|
|
923
|
-
createCyclePath: this.createCyclePath,
|
|
924
|
-
createDetourPath: this.createDetourPath,
|
|
925
|
-
createLinePath: this.createLinePath
|
|
926
|
-
}), this.svg = this.genericShape.svg;
|
|
927
|
-
}
|
|
928
|
-
render(e) {
|
|
929
|
-
this.genericShape.render(e);
|
|
930
|
-
}
|
|
931
|
-
}
|
|
932
|
-
const Be = (t) => {
|
|
933
|
-
if (typeof t == "function")
|
|
934
|
-
return t;
|
|
935
|
-
switch (t == null ? void 0 : t.type) {
|
|
936
|
-
case "straight":
|
|
937
|
-
return () => new Le({
|
|
938
|
-
color: t.color,
|
|
939
|
-
width: t.width,
|
|
940
|
-
arrowLength: t.arrowLength,
|
|
941
|
-
arrowWidth: t.arrowWidth,
|
|
942
|
-
arrowOffset: t.arrowOffset,
|
|
943
|
-
hasSourceArrow: t.hasSourceArrow,
|
|
944
|
-
hasTargetArrow: t.hasTargetArrow,
|
|
945
|
-
cycleSquareSide: t.cycleSquareSide,
|
|
946
|
-
roundness: t.roundness,
|
|
947
|
-
detourDistance: t.detourDistance,
|
|
948
|
-
detourDirection: t.detourDirection
|
|
949
|
-
});
|
|
950
|
-
case "horizontal":
|
|
951
|
-
return () => new Ve({
|
|
952
|
-
color: t.color,
|
|
953
|
-
width: t.width,
|
|
954
|
-
arrowLength: t.arrowLength,
|
|
955
|
-
arrowWidth: t.arrowWidth,
|
|
956
|
-
arrowOffset: t.arrowOffset,
|
|
957
|
-
hasSourceArrow: t.hasSourceArrow,
|
|
958
|
-
hasTargetArrow: t.hasTargetArrow,
|
|
959
|
-
cycleSquareSide: t.cycleSquareSide,
|
|
960
|
-
roundness: t.roundness,
|
|
961
|
-
detourDistance: t.detourDistance,
|
|
962
|
-
detourDirection: t.detourDirection
|
|
963
|
-
});
|
|
964
|
-
case "vertical":
|
|
965
|
-
return () => new Re({
|
|
966
|
-
color: t.color,
|
|
967
|
-
width: t.width,
|
|
968
|
-
arrowLength: t.arrowLength,
|
|
969
|
-
arrowWidth: t.arrowWidth,
|
|
970
|
-
arrowOffset: t.arrowOffset,
|
|
971
|
-
hasSourceArrow: t.hasSourceArrow,
|
|
972
|
-
hasTargetArrow: t.hasTargetArrow,
|
|
973
|
-
cycleSquareSide: t.cycleSquareSide,
|
|
974
|
-
roundness: t.roundness,
|
|
975
|
-
detourDistance: t.detourDistance,
|
|
976
|
-
detourDirection: t.detourDirection
|
|
977
|
-
});
|
|
978
|
-
default:
|
|
979
|
-
return () => new De({
|
|
980
|
-
color: t.color,
|
|
981
|
-
width: t.width,
|
|
982
|
-
arrowLength: t.arrowLength,
|
|
983
|
-
arrowWidth: t.arrowWidth,
|
|
984
|
-
hasSourceArrow: t.hasSourceArrow,
|
|
985
|
-
hasTargetArrow: t.hasTargetArrow,
|
|
986
|
-
cycleRadius: t.cycleRadius,
|
|
987
|
-
smallCycleRadius: t.smallCycleRadius,
|
|
988
|
-
curvature: t.curvature,
|
|
989
|
-
detourDistance: t.detourDistance,
|
|
990
|
-
detourDirection: t.detourDirection
|
|
991
|
-
});
|
|
992
|
-
}
|
|
993
|
-
}, Ie = (t) => {
|
|
994
|
-
var o, r, s, h, n;
|
|
995
|
-
const e = pe(
|
|
996
|
-
(o = t == null ? void 0 : t.nodes) == null ? void 0 : o.priority,
|
|
997
|
-
(r = t == null ? void 0 : t.edges) == null ? void 0 : r.priority
|
|
998
|
-
);
|
|
999
|
-
return {
|
|
1000
|
-
nodes: {
|
|
1001
|
-
centerFn: ((s = t == null ? void 0 : t.nodes) == null ? void 0 : s.centerFn) ?? ve,
|
|
1002
|
-
priorityFn: e.nodesPriorityFn
|
|
1003
|
-
},
|
|
1004
|
-
ports: {
|
|
1005
|
-
direction: ((h = t == null ? void 0 : t.ports) == null ? void 0 : h.direction) ?? 0
|
|
1006
|
-
},
|
|
1007
|
-
edges: {
|
|
1008
|
-
shapeFactory: Be(((n = t == null ? void 0 : t.edges) == null ? void 0 : n.shape) ?? {}),
|
|
1009
|
-
priorityFn: e.edgesPriorityFn
|
|
1010
|
-
}
|
|
1011
|
-
};
|
|
1012
|
-
};
|
|
1013
|
-
class se {
|
|
1014
|
-
constructor(e, o, r, s, h) {
|
|
1015
|
-
/**
|
|
1016
|
-
* provides api for accessing model of rendered graph
|
|
1017
|
-
*/
|
|
1018
|
-
i(this, "graph");
|
|
1019
|
-
/**
|
|
1020
|
-
* provides api for accessing viewport state
|
|
1021
|
-
*/
|
|
1022
|
-
i(this, "viewport");
|
|
1023
|
-
i(this, "defaults");
|
|
1024
|
-
i(this, "nodeIdGenerator", new C(
|
|
1025
|
-
(e) => this.graph.getNode(e) !== null
|
|
1026
|
-
));
|
|
1027
|
-
i(this, "portIdGenerator", new C(
|
|
1028
|
-
(e) => this.graph.getPort(e) !== null
|
|
1029
|
-
));
|
|
1030
|
-
i(this, "edgeIdGenerator", new C(
|
|
1031
|
-
(e) => this.graph.getEdge(e) !== null
|
|
1032
|
-
));
|
|
1033
|
-
i(this, "onAfterNodeAdded", (e) => {
|
|
1034
|
-
this.htmlView.attachNode(e);
|
|
1035
|
-
});
|
|
1036
|
-
i(this, "onAfterNodeUpdated", (e) => {
|
|
1037
|
-
this.htmlView.updateNodePosition(e), this.graphStore.getNodeAdjacentEdgeIds(e).forEach((r) => {
|
|
1038
|
-
this.htmlView.renderEdge(r);
|
|
1039
|
-
});
|
|
1040
|
-
});
|
|
1041
|
-
i(this, "onAfterNodePriorityUpdated", (e) => {
|
|
1042
|
-
this.htmlView.updateNodePriority(e);
|
|
1043
|
-
});
|
|
1044
|
-
i(this, "onBeforeNodeRemoved", (e) => {
|
|
1045
|
-
this.graphStore.getNodePortIds(e).forEach((o) => {
|
|
1046
|
-
this.unmarkPort(o);
|
|
1047
|
-
}), this.htmlView.detachNode(e);
|
|
1048
|
-
});
|
|
1049
|
-
i(this, "onAfterPortUpdated", (e) => {
|
|
1050
|
-
this.graphStore.getPortAdjacentEdgeIds(e).forEach((r) => {
|
|
1051
|
-
this.htmlView.renderEdge(r);
|
|
1052
|
-
});
|
|
1053
|
-
});
|
|
1054
|
-
i(this, "onBeforePortUnmarked", (e) => {
|
|
1055
|
-
this.graphStore.getPortAdjacentEdgeIds(e).forEach((o) => {
|
|
1056
|
-
this.removeEdge(o);
|
|
1057
|
-
});
|
|
1058
|
-
});
|
|
1059
|
-
i(this, "onAfterEdgeAdded", (e) => {
|
|
1060
|
-
this.htmlView.attachEdge(e);
|
|
1061
|
-
});
|
|
1062
|
-
i(this, "onAfterEdgeShapeUpdated", (e) => {
|
|
1063
|
-
this.htmlView.updateEdgeShape(e);
|
|
1064
|
-
});
|
|
1065
|
-
i(this, "onAfterEdgeUpdated", (e) => {
|
|
1066
|
-
this.htmlView.renderEdge(e);
|
|
1067
|
-
});
|
|
1068
|
-
i(this, "onAfterEdgePriorityUpdated", (e) => {
|
|
1069
|
-
this.htmlView.updateEdgePriority(e);
|
|
1070
|
-
});
|
|
1071
|
-
i(this, "onBeforeEdgeRemoved", (e) => {
|
|
1072
|
-
this.htmlView.detachEdge(e);
|
|
1073
|
-
});
|
|
1074
|
-
i(this, "onBeforeClear", () => {
|
|
1075
|
-
this.nodeIdGenerator.reset(), this.portIdGenerator.reset(), this.edgeIdGenerator.reset(), this.htmlView.clear();
|
|
1076
|
-
});
|
|
1077
|
-
i(this, "onBeforeDestroyEmitter");
|
|
1078
|
-
/**
|
|
1079
|
-
* emits event just before destruction of canvas
|
|
1080
|
-
*/
|
|
1081
|
-
i(this, "onBeforeDestroy");
|
|
1082
|
-
this.element = e, this.graphStore = o, this.viewportStore = r, this.htmlView = s, this.defaults = Ie(h), this.graph = new fe(this.graphStore), this.viewport = new we(this.viewportStore), this.graphStore.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graphStore.onAfterNodeUpdated.subscribe(this.onAfterNodeUpdated), this.graphStore.onAfterNodePriorityUpdated.subscribe(
|
|
1083
|
-
this.onAfterNodePriorityUpdated
|
|
1084
|
-
), 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(
|
|
1085
|
-
this.onAfterEdgeShapeUpdated
|
|
1086
|
-
), this.graphStore.onAfterEdgeUpdated.subscribe(this.onAfterEdgeUpdated), this.graphStore.onAfterEdgePriorityUpdated.subscribe(
|
|
1087
|
-
this.onAfterEdgePriorityUpdated
|
|
1088
|
-
), this.graphStore.onBeforeEdgeRemoved.subscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.subscribe(this.onBeforeClear), [this.onBeforeDestroyEmitter, this.onBeforeDestroy] = A();
|
|
372
|
+
r(this, "onAfterNodePriorityUpdated", (e) => {
|
|
373
|
+
this.htmlView.updateNodePriority(e);
|
|
374
|
+
});
|
|
375
|
+
r(this, "onBeforeNodeRemoved", (e) => {
|
|
376
|
+
this.graphStore.getNodePortIds(e).forEach((o) => {
|
|
377
|
+
this.unmarkPort(o);
|
|
378
|
+
}), this.htmlView.detachNode(e);
|
|
379
|
+
});
|
|
380
|
+
r(this, "onAfterPortUpdated", (e) => {
|
|
381
|
+
this.graphStore.getPortAdjacentEdgeIds(e).forEach((i) => {
|
|
382
|
+
this.htmlView.renderEdge(i);
|
|
383
|
+
});
|
|
384
|
+
});
|
|
385
|
+
r(this, "onBeforePortUnmarked", (e) => {
|
|
386
|
+
this.graphStore.getPortAdjacentEdgeIds(e).forEach((o) => {
|
|
387
|
+
this.removeEdge(o);
|
|
388
|
+
});
|
|
389
|
+
});
|
|
390
|
+
r(this, "onAfterEdgeAdded", (e) => {
|
|
391
|
+
this.htmlView.attachEdge(e);
|
|
392
|
+
});
|
|
393
|
+
r(this, "onAfterEdgeShapeUpdated", (e) => {
|
|
394
|
+
this.htmlView.updateEdgeShape(e);
|
|
395
|
+
});
|
|
396
|
+
r(this, "onAfterEdgeUpdated", (e) => {
|
|
397
|
+
this.htmlView.renderEdge(e);
|
|
398
|
+
});
|
|
399
|
+
r(this, "onAfterEdgePriorityUpdated", (e) => {
|
|
400
|
+
this.htmlView.updateEdgePriority(e);
|
|
401
|
+
});
|
|
402
|
+
r(this, "onBeforeEdgeRemoved", (e) => {
|
|
403
|
+
this.htmlView.detachEdge(e);
|
|
404
|
+
});
|
|
405
|
+
r(this, "onBeforeClear", () => {
|
|
406
|
+
this.nodeIdGenerator.reset(), this.portIdGenerator.reset(), this.edgeIdGenerator.reset(), this.htmlView.clear();
|
|
407
|
+
});
|
|
408
|
+
r(this, "onBeforeDestroyEmitter");
|
|
409
|
+
/**
|
|
410
|
+
* emits event just before destruction of canvas
|
|
411
|
+
*/
|
|
412
|
+
r(this, "onBeforeDestroy");
|
|
413
|
+
this.element = e, this.graphStore = o, this.viewportStore = i, this.htmlView = s, this.defaults = h, this.graph = new pe(this.graphStore), this.viewport = new ye(this.viewportStore), this.graphStore.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graphStore.onAfterNodeUpdated.subscribe(this.onAfterNodeUpdated), this.graphStore.onAfterNodePriorityUpdated.subscribe(
|
|
414
|
+
this.onAfterNodePriorityUpdated
|
|
415
|
+
), 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(
|
|
416
|
+
this.onAfterEdgeShapeUpdated
|
|
417
|
+
), this.graphStore.onAfterEdgeUpdated.subscribe(this.onAfterEdgeUpdated), this.graphStore.onAfterEdgePriorityUpdated.subscribe(
|
|
418
|
+
this.onAfterEdgePriorityUpdated
|
|
419
|
+
), this.graphStore.onBeforeEdgeRemoved.subscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.subscribe(this.onBeforeClear), [this.onBeforeDestroyEmitter, this.onBeforeDestroy] = x();
|
|
1089
420
|
}
|
|
1090
421
|
/**
|
|
1091
422
|
* adds new node
|
|
@@ -1102,12 +433,12 @@ class se {
|
|
|
1102
433
|
centerFn: e.centerFn ?? this.defaults.nodes.centerFn,
|
|
1103
434
|
priority: e.priority ?? this.defaults.nodes.priorityFn()
|
|
1104
435
|
}), e.ports !== void 0)
|
|
1105
|
-
for (const
|
|
436
|
+
for (const i of e.ports)
|
|
1106
437
|
this.markPort({
|
|
1107
|
-
id:
|
|
1108
|
-
element:
|
|
438
|
+
id: i.id,
|
|
439
|
+
element: i.element,
|
|
1109
440
|
nodeId: o,
|
|
1110
|
-
direction:
|
|
441
|
+
direction: i.direction
|
|
1111
442
|
});
|
|
1112
443
|
return this;
|
|
1113
444
|
}
|
|
@@ -1177,7 +508,7 @@ class se {
|
|
|
1177
508
|
id: o,
|
|
1178
509
|
from: e.from,
|
|
1179
510
|
to: e.to,
|
|
1180
|
-
shape: e.shape ?? this.defaults.edges.shapeFactory(),
|
|
511
|
+
shape: e.shape ?? this.defaults.edges.shapeFactory(o),
|
|
1181
512
|
priority: e.priority ?? this.defaults.edges.priorityFn()
|
|
1182
513
|
}), this;
|
|
1183
514
|
}
|
|
@@ -1216,58 +547,100 @@ class se {
|
|
|
1216
547
|
clear() {
|
|
1217
548
|
return this.graphStore.clear(), this;
|
|
1218
549
|
}
|
|
1219
|
-
/**
|
|
1220
|
-
* destroys canvas
|
|
1221
|
-
* canvas element gets rolled back to initial state, and can not be reused
|
|
1222
|
-
*/
|
|
1223
|
-
destroy() {
|
|
1224
|
-
this.clear(), this.onBeforeDestroyEmitter.emit(), this.graphStore.onAfterNodeAdded.unsubscribe(this.onAfterNodeAdded), this.graphStore.onAfterNodeUpdated.unsubscribe(this.onAfterNodeUpdated), this.graphStore.onAfterNodePriorityUpdated.unsubscribe(
|
|
1225
|
-
this.onAfterNodePriorityUpdated
|
|
1226
|
-
), 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(
|
|
1227
|
-
this.onAfterEdgeShapeUpdated
|
|
1228
|
-
), this.graphStore.onAfterEdgeUpdated.unsubscribe(this.onAfterEdgeUpdated), this.graphStore.onAfterEdgePriorityUpdated.unsubscribe(
|
|
1229
|
-
this.onAfterEdgePriorityUpdated
|
|
1230
|
-
), this.graphStore.onBeforeEdgeRemoved.unsubscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.unsubscribe(this.onBeforeClear), this.htmlView.destroy();
|
|
550
|
+
/**
|
|
551
|
+
* destroys canvas
|
|
552
|
+
* canvas element gets rolled back to initial state, and can not be reused
|
|
553
|
+
*/
|
|
554
|
+
destroy() {
|
|
555
|
+
this.clear(), this.onBeforeDestroyEmitter.emit(), this.graphStore.onAfterNodeAdded.unsubscribe(this.onAfterNodeAdded), this.graphStore.onAfterNodeUpdated.unsubscribe(this.onAfterNodeUpdated), this.graphStore.onAfterNodePriorityUpdated.unsubscribe(
|
|
556
|
+
this.onAfterNodePriorityUpdated
|
|
557
|
+
), 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(
|
|
558
|
+
this.onAfterEdgeShapeUpdated
|
|
559
|
+
), this.graphStore.onAfterEdgeUpdated.unsubscribe(this.onAfterEdgeUpdated), this.graphStore.onAfterEdgePriorityUpdated.unsubscribe(
|
|
560
|
+
this.onAfterEdgePriorityUpdated
|
|
561
|
+
), this.graphStore.onBeforeEdgeRemoved.unsubscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.unsubscribe(this.onBeforeClear), this.htmlView.destroy();
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
class he {
|
|
565
|
+
constructor() {
|
|
566
|
+
r(this, "singleToMultiMap", /* @__PURE__ */ new Map());
|
|
567
|
+
r(this, "multiToSingleMap", /* @__PURE__ */ new Map());
|
|
568
|
+
}
|
|
569
|
+
addRecord(e, o) {
|
|
570
|
+
const i = this.singleToMultiMap.get(e);
|
|
571
|
+
i === void 0 ? this.singleToMultiMap.set(e, /* @__PURE__ */ new Set([o])) : i.add(o), this.multiToSingleMap.set(o, e);
|
|
572
|
+
}
|
|
573
|
+
getMultiBySingle(e) {
|
|
574
|
+
const o = this.singleToMultiMap.get(e) ?? /* @__PURE__ */ new Set();
|
|
575
|
+
return Array.from(o.values());
|
|
576
|
+
}
|
|
577
|
+
removeByMulti(e) {
|
|
578
|
+
const o = this.multiToSingleMap.get(e), i = this.singleToMultiMap.get(o);
|
|
579
|
+
i.delete(e), i.size === 0 && this.singleToMultiMap.delete(o), this.multiToSingleMap.delete(e);
|
|
580
|
+
}
|
|
581
|
+
getByMulti(e) {
|
|
582
|
+
return this.multiToSingleMap.get(e);
|
|
583
|
+
}
|
|
584
|
+
removeBySingle(e) {
|
|
585
|
+
this.singleToMultiMap.get(e).forEach((i) => {
|
|
586
|
+
this.multiToSingleMap.delete(i);
|
|
587
|
+
}), this.singleToMultiMap.delete(e);
|
|
588
|
+
}
|
|
589
|
+
clear() {
|
|
590
|
+
this.singleToMultiMap.clear(), this.multiToSingleMap.clear();
|
|
591
|
+
}
|
|
592
|
+
forEachSingle(e) {
|
|
593
|
+
this.singleToMultiMap.forEach((o, i) => {
|
|
594
|
+
e(i);
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
hasSingle(e) {
|
|
598
|
+
return this.singleToMultiMap.get(e) !== void 0;
|
|
599
|
+
}
|
|
600
|
+
hasMulti(e) {
|
|
601
|
+
return this.multiToSingleMap.get(e) !== void 0;
|
|
1231
602
|
}
|
|
1232
603
|
}
|
|
1233
|
-
class
|
|
604
|
+
class de {
|
|
1234
605
|
constructor() {
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
606
|
+
r(this, "nodes", /* @__PURE__ */ new Map());
|
|
607
|
+
r(this, "ports", /* @__PURE__ */ new Map());
|
|
608
|
+
r(this, "edges", /* @__PURE__ */ new Map());
|
|
609
|
+
r(this, "nodesElementsMap", /* @__PURE__ */ new Map());
|
|
610
|
+
r(this, "incomingEdges", /* @__PURE__ */ new Map());
|
|
611
|
+
r(this, "outcomingEdges", /* @__PURE__ */ new Map());
|
|
612
|
+
r(this, "cycleEdges", /* @__PURE__ */ new Map());
|
|
613
|
+
r(this, "elementPorts", new he());
|
|
614
|
+
r(this, "afterNodeAddedEmitter");
|
|
615
|
+
r(this, "onAfterNodeAdded");
|
|
616
|
+
r(this, "afterNodeUpdatedEmitter");
|
|
617
|
+
r(this, "onAfterNodeUpdated");
|
|
618
|
+
r(this, "afterNodePriorityUpdatedEmitter");
|
|
619
|
+
r(this, "onAfterNodePriorityUpdated");
|
|
620
|
+
r(this, "beforeNodeRemovedEmitter");
|
|
621
|
+
r(this, "onBeforeNodeRemoved");
|
|
622
|
+
r(this, "afterPortAddedEmitter");
|
|
623
|
+
r(this, "onAfterPortAdded");
|
|
624
|
+
r(this, "afterPortUpdatedEmitter");
|
|
625
|
+
r(this, "onAfterPortUpdated");
|
|
626
|
+
r(this, "beforePortRemovedEmitter");
|
|
627
|
+
r(this, "onBeforePortRemoved");
|
|
628
|
+
r(this, "afterEdgeAddedEmitter");
|
|
629
|
+
r(this, "onAfterEdgeAdded");
|
|
630
|
+
r(this, "afterEdgeShapeUpdatedEmitter");
|
|
631
|
+
r(this, "onAfterEdgeShapeUpdated");
|
|
632
|
+
r(this, "afterEdgeUpdatedEmitter");
|
|
633
|
+
r(this, "onAfterEdgeUpdated");
|
|
634
|
+
r(this, "afterEdgePriorityUpdatedEmitter");
|
|
635
|
+
r(this, "onAfterEdgePriorityUpdated");
|
|
636
|
+
r(this, "beforeEdgeRemovedEmitter");
|
|
637
|
+
r(this, "onBeforeEdgeRemoved");
|
|
638
|
+
r(this, "beforeClearEmitter");
|
|
639
|
+
r(this, "onBeforeClear");
|
|
640
|
+
[this.afterNodeAddedEmitter, this.onAfterNodeAdded] = x(), [this.afterNodeUpdatedEmitter, this.onAfterNodeUpdated] = x(), [this.afterNodePriorityUpdatedEmitter, this.onAfterNodePriorityUpdated] = x(), [this.beforeNodeRemovedEmitter, this.onBeforeNodeRemoved] = x(), [this.afterPortAddedEmitter, this.onAfterPortAdded] = x(), [this.afterPortUpdatedEmitter, this.onAfterPortUpdated] = x(), [this.beforePortRemovedEmitter, this.onBeforePortRemoved] = x(), [this.afterEdgeAddedEmitter, this.onAfterEdgeAdded] = x(), [this.afterEdgeShapeUpdatedEmitter, this.onAfterEdgeShapeUpdated] = x(), [this.afterEdgeUpdatedEmitter, this.onAfterEdgeUpdated] = x(), [this.afterEdgePriorityUpdatedEmitter, this.onAfterEdgePriorityUpdated] = x(), [this.beforeEdgeRemovedEmitter, this.onBeforeEdgeRemoved] = x(), [this.beforeClearEmitter, this.onBeforeClear] = x();
|
|
1268
641
|
}
|
|
1269
642
|
addNode(e) {
|
|
1270
|
-
const o = /* @__PURE__ */ new Map(),
|
|
643
|
+
const o = /* @__PURE__ */ new Map(), i = {
|
|
1271
644
|
element: e.element,
|
|
1272
645
|
x: e.x,
|
|
1273
646
|
y: e.y,
|
|
@@ -1275,7 +648,7 @@ class ne {
|
|
|
1275
648
|
priority: e.priority,
|
|
1276
649
|
ports: o
|
|
1277
650
|
};
|
|
1278
|
-
this.nodes.set(e.id,
|
|
651
|
+
this.nodes.set(e.id, i), this.nodesElementsMap.set(e.element, e.id), this.afterNodeAddedEmitter.emit(e.id);
|
|
1279
652
|
}
|
|
1280
653
|
getAllNodeIds() {
|
|
1281
654
|
return Array.from(this.nodes.keys());
|
|
@@ -1283,30 +656,38 @@ class ne {
|
|
|
1283
656
|
getNode(e) {
|
|
1284
657
|
return this.nodes.get(e);
|
|
1285
658
|
}
|
|
659
|
+
getElementNodeId(e) {
|
|
660
|
+
return this.nodesElementsMap.get(e);
|
|
661
|
+
}
|
|
1286
662
|
updateNode(e, o) {
|
|
1287
|
-
const
|
|
1288
|
-
|
|
663
|
+
const i = this.nodes.get(e);
|
|
664
|
+
i.x = o.x ?? i.x, i.y = o.y ?? i.y, i.centerFn = o.centerFn ?? i.centerFn, o.priority !== void 0 && (i.priority = o.priority, this.afterNodePriorityUpdatedEmitter.emit(e)), this.afterNodeUpdatedEmitter.emit(e);
|
|
1289
665
|
}
|
|
1290
666
|
removeNode(e) {
|
|
1291
|
-
this.beforeNodeRemovedEmitter.emit(e)
|
|
667
|
+
this.beforeNodeRemovedEmitter.emit(e);
|
|
668
|
+
const o = this.nodes.get(e);
|
|
669
|
+
this.nodesElementsMap.delete(o.element), this.nodes.delete(e);
|
|
1292
670
|
}
|
|
1293
671
|
addPort(e) {
|
|
1294
672
|
this.ports.set(e.id, {
|
|
1295
673
|
element: e.element,
|
|
1296
674
|
direction: e.direction,
|
|
1297
675
|
nodeId: e.nodeId
|
|
1298
|
-
}), this.cycleEdges.set(e.id, /* @__PURE__ */ new Set()), this.incomingEdges.set(e.id, /* @__PURE__ */ new Set()), this.outcomingEdges.set(e.id, /* @__PURE__ */ new Set()), this.nodes.get(e.nodeId).ports.set(e.id, e.element), this.afterPortAddedEmitter.emit(e.id);
|
|
676
|
+
}), this.elementPorts.addRecord(e.element, e.id), this.cycleEdges.set(e.id, /* @__PURE__ */ new Set()), this.incomingEdges.set(e.id, /* @__PURE__ */ new Set()), this.outcomingEdges.set(e.id, /* @__PURE__ */ new Set()), this.nodes.get(e.nodeId).ports.set(e.id, e.element), this.afterPortAddedEmitter.emit(e.id);
|
|
1299
677
|
}
|
|
1300
678
|
getPort(e) {
|
|
1301
679
|
return this.ports.get(e);
|
|
1302
680
|
}
|
|
1303
681
|
updatePort(e, o) {
|
|
1304
|
-
const
|
|
1305
|
-
|
|
682
|
+
const i = this.ports.get(e);
|
|
683
|
+
i.direction = o.direction ?? i.direction, this.afterPortUpdatedEmitter.emit(e);
|
|
1306
684
|
}
|
|
1307
685
|
getAllPortIds() {
|
|
1308
686
|
return Array.from(this.ports.keys());
|
|
1309
687
|
}
|
|
688
|
+
getElementPortsIds(e) {
|
|
689
|
+
return this.elementPorts.getMultiBySingle(e);
|
|
690
|
+
}
|
|
1310
691
|
getNodePortIds(e) {
|
|
1311
692
|
const o = this.nodes.get(e);
|
|
1312
693
|
if (o !== void 0)
|
|
@@ -1314,7 +695,7 @@ class ne {
|
|
|
1314
695
|
}
|
|
1315
696
|
removePort(e) {
|
|
1316
697
|
const o = this.ports.get(e).nodeId;
|
|
1317
|
-
this.beforePortRemovedEmitter.emit(e), this.nodes.get(o).ports.delete(e), this.ports.delete(e);
|
|
698
|
+
this.beforePortRemovedEmitter.emit(e), this.nodes.get(o).ports.delete(e), this.ports.delete(e), this.elementPorts.removeByMulti(e);
|
|
1318
699
|
}
|
|
1319
700
|
addEdge(e) {
|
|
1320
701
|
this.addEdgeInternal(e), this.afterEdgeAddedEmitter.emit(e.id);
|
|
@@ -1330,8 +711,8 @@ class ne {
|
|
|
1330
711
|
priority: s.priority
|
|
1331
712
|
});
|
|
1332
713
|
}
|
|
1333
|
-
const
|
|
1334
|
-
o.shape !== void 0 && (
|
|
714
|
+
const i = this.edges.get(e);
|
|
715
|
+
o.shape !== void 0 && (i.shape = o.shape, this.afterEdgeShapeUpdatedEmitter.emit(e)), o.priority !== void 0 && (i.priority = o.priority, this.afterEdgePriorityUpdatedEmitter.emit(e)), this.afterEdgeUpdatedEmitter.emit(e);
|
|
1335
716
|
}
|
|
1336
717
|
getAllEdgeIds() {
|
|
1337
718
|
return Array.from(this.edges.keys());
|
|
@@ -1343,7 +724,7 @@ class ne {
|
|
|
1343
724
|
this.beforeEdgeRemovedEmitter.emit(e), this.removeEdgeInternal(e);
|
|
1344
725
|
}
|
|
1345
726
|
clear() {
|
|
1346
|
-
this.beforeClearEmitter.emit(), this.incomingEdges.clear(), this.outcomingEdges.clear(), this.cycleEdges.clear(), this.edges.clear(), this.ports.clear(), this.nodes.clear();
|
|
727
|
+
this.beforeClearEmitter.emit(), this.incomingEdges.clear(), this.outcomingEdges.clear(), this.cycleEdges.clear(), this.elementPorts.clear(), this.nodesElementsMap.clear(), this.edges.clear(), this.ports.clear(), this.nodes.clear();
|
|
1347
728
|
}
|
|
1348
729
|
getPortIncomingEdgeIds(e) {
|
|
1349
730
|
return Array.from(this.incomingEdges.get(e));
|
|
@@ -1363,24 +744,24 @@ class ne {
|
|
|
1363
744
|
}
|
|
1364
745
|
getNodeIncomingEdgeIds(e) {
|
|
1365
746
|
const o = Array.from(this.nodes.get(e).ports.keys());
|
|
1366
|
-
let
|
|
747
|
+
let i = [];
|
|
1367
748
|
return o.forEach((s) => {
|
|
1368
|
-
|
|
1369
|
-
}),
|
|
749
|
+
i = [...i, ...this.getPortIncomingEdgeIds(s)];
|
|
750
|
+
}), i;
|
|
1370
751
|
}
|
|
1371
752
|
getNodeOutcomingEdgeIds(e) {
|
|
1372
753
|
const o = Array.from(this.nodes.get(e).ports.keys());
|
|
1373
|
-
let
|
|
754
|
+
let i = [];
|
|
1374
755
|
return o.forEach((s) => {
|
|
1375
|
-
|
|
1376
|
-
}),
|
|
756
|
+
i = [...i, ...this.getPortOutcomingEdgeIds(s)];
|
|
757
|
+
}), i;
|
|
1377
758
|
}
|
|
1378
759
|
getNodeCycleEdgeIds(e) {
|
|
1379
760
|
const o = Array.from(this.nodes.get(e).ports.keys());
|
|
1380
|
-
let
|
|
761
|
+
let i = [];
|
|
1381
762
|
return o.forEach((s) => {
|
|
1382
|
-
|
|
1383
|
-
}),
|
|
763
|
+
i = [...i, ...this.getPortCycleEdgeIds(s)];
|
|
764
|
+
}), i;
|
|
1384
765
|
}
|
|
1385
766
|
getNodeAdjacentEdgeIds(e) {
|
|
1386
767
|
return [
|
|
@@ -1398,28 +779,28 @@ class ne {
|
|
|
1398
779
|
}), e.from !== e.to ? (this.outcomingEdges.get(e.from).add(e.id), this.incomingEdges.get(e.to).add(e.id)) : this.cycleEdges.get(e.from).add(e.id);
|
|
1399
780
|
}
|
|
1400
781
|
removeEdgeInternal(e) {
|
|
1401
|
-
const o = this.edges.get(e),
|
|
1402
|
-
this.cycleEdges.get(
|
|
782
|
+
const o = this.edges.get(e), i = o.from, s = o.to;
|
|
783
|
+
this.cycleEdges.get(i).delete(e), this.cycleEdges.get(s).delete(e), this.incomingEdges.get(i).delete(e), this.incomingEdges.get(s).delete(e), this.outcomingEdges.get(i).delete(e), this.outcomingEdges.get(s).delete(e), this.edges.delete(e);
|
|
1403
784
|
}
|
|
1404
785
|
}
|
|
1405
|
-
const
|
|
786
|
+
const K = (t) => ({
|
|
1406
787
|
scale: 1 / t.scale,
|
|
1407
788
|
x: -t.x / t.scale,
|
|
1408
789
|
y: -t.y / t.scale
|
|
1409
|
-
}),
|
|
790
|
+
}), Q = {
|
|
1410
791
|
scale: 1,
|
|
1411
792
|
x: 0,
|
|
1412
793
|
y: 0
|
|
1413
794
|
};
|
|
1414
|
-
class
|
|
795
|
+
class Ae {
|
|
1415
796
|
constructor() {
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
[this.afterUpdateEmitter, this.onAfterUpdated] =
|
|
797
|
+
r(this, "viewportMatrix", Q);
|
|
798
|
+
r(this, "contentMatrix", Q);
|
|
799
|
+
r(this, "afterUpdateEmitter");
|
|
800
|
+
r(this, "onAfterUpdated");
|
|
801
|
+
r(this, "beforeUpdateEmitter");
|
|
802
|
+
r(this, "onBeforeUpdated");
|
|
803
|
+
[this.afterUpdateEmitter, this.onAfterUpdated] = x(), [this.beforeUpdateEmitter, this.onBeforeUpdated] = x();
|
|
1423
804
|
}
|
|
1424
805
|
getViewportMatrix() {
|
|
1425
806
|
return this.viewportMatrix;
|
|
@@ -1432,80 +813,80 @@ class Ue {
|
|
|
1432
813
|
scale: e.scale ?? this.viewportMatrix.scale,
|
|
1433
814
|
x: e.x ?? this.viewportMatrix.x,
|
|
1434
815
|
y: e.y ?? this.viewportMatrix.y
|
|
1435
|
-
}, this.contentMatrix =
|
|
816
|
+
}, this.contentMatrix = K(this.viewportMatrix), this.afterUpdateEmitter.emit();
|
|
1436
817
|
}
|
|
1437
818
|
patchContentMatrix(e) {
|
|
1438
819
|
this.beforeUpdateEmitter.emit(), this.contentMatrix = {
|
|
1439
820
|
scale: e.scale ?? this.contentMatrix.scale,
|
|
1440
821
|
x: e.x ?? this.contentMatrix.x,
|
|
1441
822
|
y: e.y ?? this.contentMatrix.y
|
|
1442
|
-
}, this.viewportMatrix =
|
|
823
|
+
}, this.viewportMatrix = K(this.contentMatrix), this.afterUpdateEmitter.emit();
|
|
1443
824
|
}
|
|
1444
825
|
}
|
|
1445
|
-
class
|
|
826
|
+
class F {
|
|
1446
827
|
constructor(e) {
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
828
|
+
r(this, "elementToNodeId", /* @__PURE__ */ new Map());
|
|
829
|
+
r(this, "nodesResizeObserver");
|
|
830
|
+
r(this, "onAfterNodeAdded", (e) => {
|
|
1450
831
|
const o = this.canvas.graph.getNode(e);
|
|
1451
832
|
this.elementToNodeId.set(o.element, e), this.nodesResizeObserver.observe(o.element);
|
|
1452
833
|
});
|
|
1453
|
-
|
|
834
|
+
r(this, "onBeforeNodeRemoved", (e) => {
|
|
1454
835
|
const o = this.canvas.graph.getNode(e);
|
|
1455
836
|
this.elementToNodeId.delete(o.element), this.nodesResizeObserver.unobserve(o.element);
|
|
1456
837
|
});
|
|
1457
|
-
|
|
838
|
+
r(this, "onBeforeClear", () => {
|
|
1458
839
|
this.nodesResizeObserver.disconnect(), this.elementToNodeId.clear();
|
|
1459
840
|
});
|
|
1460
|
-
|
|
841
|
+
r(this, "onBeforeDestroy", () => {
|
|
1461
842
|
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);
|
|
1462
843
|
});
|
|
1463
844
|
this.canvas = e, this.nodesResizeObserver = new ResizeObserver((o) => {
|
|
1464
|
-
o.forEach((
|
|
1465
|
-
const s =
|
|
845
|
+
o.forEach((i) => {
|
|
846
|
+
const s = i.target;
|
|
1466
847
|
this.handleNodeResize(s);
|
|
1467
848
|
});
|
|
1468
849
|
}), 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);
|
|
1469
850
|
}
|
|
1470
851
|
static configure(e) {
|
|
1471
|
-
new
|
|
852
|
+
new F(e);
|
|
1472
853
|
}
|
|
1473
854
|
handleNodeResize(e) {
|
|
1474
855
|
const o = this.elementToNodeId.get(e);
|
|
1475
856
|
this.canvas.updateNode(o);
|
|
1476
857
|
}
|
|
1477
858
|
}
|
|
1478
|
-
const
|
|
1479
|
-
var g, y, p, f,
|
|
859
|
+
const Ee = (t) => {
|
|
860
|
+
var g, y, p, f, A, E;
|
|
1480
861
|
const e = ((g = t == null ? void 0 : t.events) == null ? void 0 : g.onNodeDrag) ?? (() => {
|
|
1481
|
-
}), o = ((y = t == null ? void 0 : t.events) == null ? void 0 : y.onBeforeNodeDrag) ?? (() => !0),
|
|
1482
|
-
}), s = (t == null ? void 0 : t.moveOnTop) === !1, h = (f = t == null ? void 0 : t.mouse) == null ? void 0 : f.dragCursor, n = h !== void 0 ? h : "grab", d = (
|
|
862
|
+
}), o = ((y = t == null ? void 0 : t.events) == null ? void 0 : y.onBeforeNodeDrag) ?? (() => !0), i = ((p = t == null ? void 0 : t.events) == null ? void 0 : p.onNodeDragFinished) ?? (() => {
|
|
863
|
+
}), s = (t == null ? void 0 : t.moveOnTop) === !1, h = (f = t == null ? void 0 : t.mouse) == null ? void 0 : f.dragCursor, n = h !== void 0 ? h : "grab", d = (A = t == null ? void 0 : t.mouse) == null ? void 0 : A.mouseDownEventVerifier, c = d !== void 0 ? d : (m) => m.button === 0, a = (E = t == null ? void 0 : t.mouse) == null ? void 0 : E.mouseUpEventVerifier;
|
|
1483
864
|
return {
|
|
1484
865
|
freezePriority: s,
|
|
1485
866
|
dragCursor: n,
|
|
1486
867
|
mouseDownEventVerifier: c,
|
|
1487
|
-
mouseUpEventVerifier: a !== void 0 ? a : (
|
|
868
|
+
mouseUpEventVerifier: a !== void 0 ? a : (m) => m.button === 0,
|
|
1488
869
|
onNodeDrag: e,
|
|
1489
870
|
onBeforeNodeDrag: o,
|
|
1490
|
-
onNodeDragFinished:
|
|
871
|
+
onNodeDragFinished: i
|
|
1491
872
|
};
|
|
1492
|
-
},
|
|
1493
|
-
const { x:
|
|
1494
|
-
return e >=
|
|
1495
|
-
},
|
|
873
|
+
}, xe = (t, e, o) => {
|
|
874
|
+
const { x: i, y: s, width: h, height: n } = t.getBoundingClientRect();
|
|
875
|
+
return e >= i && e <= i + h && o >= s && o <= s + n;
|
|
876
|
+
}, Se = (t, e, o) => e >= 0 && e <= t.innerWidth && o >= 0 && o <= t.innerHeight, M = (t, e, o, i) => xe(e, o, i) && Se(t, o, i), B = (t, e) => {
|
|
1496
877
|
e !== null ? t.style.cursor = e : t.style.removeProperty("cursor");
|
|
1497
878
|
}, N = (t, e) => ({
|
|
1498
879
|
x: t.scale * e.x + t.x,
|
|
1499
880
|
y: t.scale * e.y + t.y
|
|
1500
881
|
});
|
|
1501
|
-
class
|
|
1502
|
-
constructor(e, o,
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
882
|
+
class k {
|
|
883
|
+
constructor(e, o, i, s) {
|
|
884
|
+
r(this, "grabbedNodeId", null);
|
|
885
|
+
r(this, "maxNodePriority", 0);
|
|
886
|
+
r(this, "previousTouchCoordinates", null);
|
|
887
|
+
r(this, "nodeIds", /* @__PURE__ */ new Map());
|
|
888
|
+
r(this, "graph");
|
|
889
|
+
r(this, "onAfterNodeAdded", (e) => {
|
|
1509
890
|
this.updateMaxNodePriority(e);
|
|
1510
891
|
const o = this.graph.getNode(e);
|
|
1511
892
|
this.nodeIds.set(o.element, e), o.element.addEventListener("mousedown", this.onMouseDown, {
|
|
@@ -1514,50 +895,50 @@ class O {
|
|
|
1514
895
|
passive: !0
|
|
1515
896
|
});
|
|
1516
897
|
});
|
|
1517
|
-
|
|
898
|
+
r(this, "onAfterNodeUpdated", (e) => {
|
|
1518
899
|
this.updateMaxNodePriority(e);
|
|
1519
900
|
});
|
|
1520
|
-
|
|
901
|
+
r(this, "onBeforeNodeRemoved", (e) => {
|
|
1521
902
|
const o = this.graph.getNode(e);
|
|
1522
903
|
this.nodeIds.delete(o.element), o.element.removeEventListener("mousedown", this.onMouseDown), o.element.removeEventListener("touchstart", this.onTouchStart);
|
|
1523
904
|
});
|
|
1524
|
-
|
|
905
|
+
r(this, "onBeforeDestroy", () => {
|
|
1525
906
|
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();
|
|
1526
907
|
});
|
|
1527
|
-
|
|
908
|
+
r(this, "onBeforeClear", () => {
|
|
1528
909
|
this.nodeIds.forEach((e, o) => {
|
|
1529
910
|
o.removeEventListener("mousedown", this.onMouseDown), o.removeEventListener("touchstart", this.onTouchStart);
|
|
1530
911
|
}), this.nodeIds.clear(), this.maxNodePriority = 0;
|
|
1531
912
|
});
|
|
1532
|
-
|
|
913
|
+
r(this, "onMouseDown", (e) => {
|
|
1533
914
|
if (!this.config.mouseDownEventVerifier(e))
|
|
1534
915
|
return;
|
|
1535
|
-
const o = e.currentTarget,
|
|
916
|
+
const o = e.currentTarget, i = this.nodeIds.get(o), s = this.graph.getNode(i);
|
|
1536
917
|
this.config.onBeforeNodeDrag({
|
|
1537
|
-
nodeId:
|
|
918
|
+
nodeId: i,
|
|
1538
919
|
element: s.element,
|
|
1539
920
|
x: s.x,
|
|
1540
921
|
y: s.y
|
|
1541
|
-
}) && (e.stopImmediatePropagation(), this.grabbedNodeId =
|
|
922
|
+
}) && (e.stopImmediatePropagation(), this.grabbedNodeId = i, B(this.element, this.config.dragCursor), this.moveNodeOnTop(i), this.window.addEventListener("mouseup", this.onWindowMouseUp, {
|
|
1542
923
|
passive: !0
|
|
1543
924
|
}), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
|
|
1544
925
|
passive: !0
|
|
1545
926
|
}));
|
|
1546
927
|
});
|
|
1547
|
-
|
|
928
|
+
r(this, "onTouchStart", (e) => {
|
|
1548
929
|
if (e.touches.length !== 1)
|
|
1549
930
|
return;
|
|
1550
931
|
e.stopImmediatePropagation(), this.previousTouchCoordinates = {
|
|
1551
932
|
x: e.touches[0].clientX,
|
|
1552
933
|
y: e.touches[0].clientY
|
|
1553
934
|
};
|
|
1554
|
-
const o = e.currentTarget,
|
|
935
|
+
const o = e.currentTarget, i = this.nodeIds.get(o), s = this.graph.getNode(i);
|
|
1555
936
|
this.config.onBeforeNodeDrag({
|
|
1556
|
-
nodeId:
|
|
937
|
+
nodeId: i,
|
|
1557
938
|
element: s.element,
|
|
1558
939
|
x: s.x,
|
|
1559
940
|
y: s.y
|
|
1560
|
-
}) && (this.grabbedNodeId =
|
|
941
|
+
}) && (this.grabbedNodeId = i, this.moveNodeOnTop(i), this.window.addEventListener("touchmove", this.onWindowTouchMove, {
|
|
1561
942
|
passive: !0
|
|
1562
943
|
}), this.window.addEventListener("touchend", this.onWindowTouchFinish, {
|
|
1563
944
|
passive: !0
|
|
@@ -1565,7 +946,7 @@ class O {
|
|
|
1565
946
|
passive: !0
|
|
1566
947
|
}));
|
|
1567
948
|
});
|
|
1568
|
-
|
|
949
|
+
r(this, "onWindowMouseMove", (e) => {
|
|
1569
950
|
if (!M(
|
|
1570
951
|
this.window,
|
|
1571
952
|
this.element,
|
|
@@ -1577,10 +958,10 @@ class O {
|
|
|
1577
958
|
}
|
|
1578
959
|
this.grabbedNodeId !== null && this.dragNode(this.grabbedNodeId, e.movementX, e.movementY);
|
|
1579
960
|
});
|
|
1580
|
-
|
|
961
|
+
r(this, "onWindowMouseUp", (e) => {
|
|
1581
962
|
this.config.mouseUpEventVerifier(e) && this.cancelMouseDrag();
|
|
1582
963
|
});
|
|
1583
|
-
|
|
964
|
+
r(this, "onWindowTouchMove", (e) => {
|
|
1584
965
|
if (e.touches.length !== 1)
|
|
1585
966
|
return;
|
|
1586
967
|
const o = e.touches[0];
|
|
@@ -1601,16 +982,16 @@ class O {
|
|
|
1601
982
|
};
|
|
1602
983
|
}
|
|
1603
984
|
});
|
|
1604
|
-
|
|
985
|
+
r(this, "onWindowTouchFinish", () => {
|
|
1605
986
|
this.previousTouchCoordinates = null, this.cancelTouchDrag();
|
|
1606
987
|
});
|
|
1607
|
-
|
|
1608
|
-
this.canvas = e, this.element = o, this.window =
|
|
988
|
+
r(this, "config");
|
|
989
|
+
this.canvas = e, this.element = o, this.window = i, this.config = Ee(s), this.graph = e.graph, 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);
|
|
1609
990
|
}
|
|
1610
|
-
static configure(e, o,
|
|
1611
|
-
new
|
|
991
|
+
static configure(e, o, i, s) {
|
|
992
|
+
new k(e, o, i, s);
|
|
1612
993
|
}
|
|
1613
|
-
dragNode(e, o,
|
|
994
|
+
dragNode(e, o, i) {
|
|
1614
995
|
const s = this.graph.getNode(e);
|
|
1615
996
|
if (s === null)
|
|
1616
997
|
return;
|
|
@@ -1618,7 +999,7 @@ class O {
|
|
|
1618
999
|
x: s.x,
|
|
1619
1000
|
y: s.y
|
|
1620
1001
|
}), d = N(
|
|
1621
|
-
{ scale: 1, x: o, y:
|
|
1002
|
+
{ scale: 1, x: o, y: i },
|
|
1622
1003
|
n
|
|
1623
1004
|
), c = this.canvas.viewport.getViewportMatrix(), a = N(c, d);
|
|
1624
1005
|
this.canvas.updateNode(e, { x: a.x, y: a.y }), this.config.onNodeDrag({
|
|
@@ -1667,18 +1048,18 @@ class O {
|
|
|
1667
1048
|
this.maxNodePriority = Math.max(this.maxNodePriority, o);
|
|
1668
1049
|
}
|
|
1669
1050
|
}
|
|
1670
|
-
const
|
|
1671
|
-
const e = t.minX !== null ? t.minX : -1 / 0, o = t.maxX !== null ? t.maxX : 1 / 0,
|
|
1051
|
+
const me = (t) => {
|
|
1052
|
+
const e = t.minX !== null ? t.minX : -1 / 0, o = t.maxX !== null ? t.maxX : 1 / 0, i = t.minY !== null ? t.minY : -1 / 0, s = t.maxY !== null ? t.maxY : 1 / 0;
|
|
1672
1053
|
return (h) => {
|
|
1673
1054
|
let n = h.nextTransform.x, d = h.nextTransform.y;
|
|
1674
1055
|
n < e && n < h.prevTransform.x && (n = Math.min(h.prevTransform.x, e));
|
|
1675
1056
|
const c = h.canvasWidth * h.prevTransform.scale, a = o - c;
|
|
1676
|
-
n > a && n > h.prevTransform.x && (n = Math.max(h.prevTransform.x, a)), d <
|
|
1057
|
+
n > a && n > h.prevTransform.x && (n = Math.max(h.prevTransform.x, a)), d < i && d < h.prevTransform.y && (d = Math.min(h.prevTransform.y, i));
|
|
1677
1058
|
const l = h.canvasHeight * h.prevTransform.scale, g = s - l;
|
|
1678
1059
|
return d > g && d > h.prevTransform.y && (d = Math.max(h.prevTransform.y, g)), { scale: h.nextTransform.scale, x: n, y: d };
|
|
1679
1060
|
};
|
|
1680
|
-
},
|
|
1681
|
-
const e = t.maxContentScale, o = t.minContentScale,
|
|
1061
|
+
}, be = (t) => {
|
|
1062
|
+
const e = t.maxContentScale, o = t.minContentScale, i = e !== null ? 1 / e : 0, s = o !== null ? 1 / o : 1 / 0;
|
|
1682
1063
|
return (h) => {
|
|
1683
1064
|
const n = h.prevTransform, d = h.nextTransform;
|
|
1684
1065
|
let c = d.scale, a = d.x, l = d.y;
|
|
@@ -1687,8 +1068,8 @@ const Fe = (t) => {
|
|
|
1687
1068
|
const g = (c - n.scale) / (d.scale - n.scale);
|
|
1688
1069
|
a = n.x + (d.x - n.x) * g, l = n.y + (d.y - n.y) * g;
|
|
1689
1070
|
}
|
|
1690
|
-
if (d.scale <
|
|
1691
|
-
c = Math.min(n.scale,
|
|
1071
|
+
if (d.scale < i && d.scale < n.scale) {
|
|
1072
|
+
c = Math.min(n.scale, i), a = n.x, l = n.y;
|
|
1692
1073
|
const g = (c - n.scale) / (d.scale - n.scale);
|
|
1693
1074
|
a = n.x + (d.x - n.x) * g, l = n.y + (d.y - n.y) * g;
|
|
1694
1075
|
}
|
|
@@ -1698,46 +1079,46 @@ const Fe = (t) => {
|
|
|
1698
1079
|
y: l
|
|
1699
1080
|
};
|
|
1700
1081
|
};
|
|
1701
|
-
},
|
|
1702
|
-
(o,
|
|
1082
|
+
}, Te = (t) => (e) => t.reduce(
|
|
1083
|
+
(o, i) => i({
|
|
1703
1084
|
prevTransform: e.prevTransform,
|
|
1704
1085
|
nextTransform: o,
|
|
1705
1086
|
canvasWidth: e.canvasWidth,
|
|
1706
1087
|
canvasHeight: e.canvasHeight
|
|
1707
1088
|
}),
|
|
1708
1089
|
e.nextTransform
|
|
1709
|
-
),
|
|
1090
|
+
), _ = (t) => {
|
|
1710
1091
|
if (typeof t == "function")
|
|
1711
1092
|
return t;
|
|
1712
1093
|
switch (t.type) {
|
|
1713
1094
|
case "scale-limit":
|
|
1714
|
-
return
|
|
1095
|
+
return be({
|
|
1715
1096
|
minContentScale: t.minContentScale ?? 0,
|
|
1716
1097
|
maxContentScale: t.maxContentScale ?? 1 / 0
|
|
1717
1098
|
});
|
|
1718
1099
|
case "shift-limit":
|
|
1719
|
-
return
|
|
1100
|
+
return me({
|
|
1720
1101
|
minX: t.minX ?? -1 / 0,
|
|
1721
1102
|
maxX: t.maxX ?? 1 / 0,
|
|
1722
1103
|
minY: t.minY ?? -1 / 0,
|
|
1723
1104
|
maxY: t.maxY ?? 1 / 0
|
|
1724
1105
|
});
|
|
1725
1106
|
}
|
|
1726
|
-
},
|
|
1727
|
-
var f, E,
|
|
1728
|
-
const e = (f = t == null ? void 0 : t.scale) == null ? void 0 : f.mouseWheelSensitivity, o = e !== void 0 ? e : 1.2,
|
|
1107
|
+
}, Pe = (t) => {
|
|
1108
|
+
var f, A, E, m, T, b, D, L, j, G, Z, J;
|
|
1109
|
+
const e = (f = t == null ? void 0 : t.scale) == null ? void 0 : f.mouseWheelSensitivity, o = e !== void 0 ? e : 1.2, i = t == null ? void 0 : t.transformPreprocessor;
|
|
1729
1110
|
let s;
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
(P) =>
|
|
1111
|
+
i !== void 0 ? Array.isArray(i) ? s = Te(
|
|
1112
|
+
i.map(
|
|
1113
|
+
(P) => _(P)
|
|
1733
1114
|
)
|
|
1734
|
-
) : s =
|
|
1735
|
-
const h = ((
|
|
1736
|
-
}), d = ((
|
|
1737
|
-
}), c = (
|
|
1115
|
+
) : s = _(i) : s = (P) => P.nextTransform;
|
|
1116
|
+
const h = ((A = t == null ? void 0 : t.shift) == null ? void 0 : A.cursor) !== void 0 ? t.shift.cursor : "grab", n = ((E = t == null ? void 0 : t.events) == null ? void 0 : E.onBeforeTransformChange) ?? (() => {
|
|
1117
|
+
}), d = ((m = t == null ? void 0 : t.events) == null ? void 0 : m.onTransformChange) ?? (() => {
|
|
1118
|
+
}), c = (T = t == null ? void 0 : t.shift) == null ? void 0 : T.mouseDownEventVerifier, a = c !== void 0 ? c : (P) => P.button === 0, l = (b = t == null ? void 0 : t.shift) == null ? void 0 : b.mouseUpEventVerifier, g = l !== void 0 ? l : (P) => P.button === 0, y = (D = t == null ? void 0 : t.scale) == null ? void 0 : D.mouseWheelEventVerifier, p = y !== void 0 ? y : () => !0;
|
|
1738
1119
|
return {
|
|
1739
1120
|
wheelSensitivity: o,
|
|
1740
|
-
onTransformStarted: ((
|
|
1121
|
+
onTransformStarted: ((L = t == null ? void 0 : t.events) == null ? void 0 : L.onTransformStarted) ?? (() => {
|
|
1741
1122
|
}),
|
|
1742
1123
|
onTransformFinished: ((j = t == null ? void 0 : t.events) == null ? void 0 : j.onTransformFinished) ?? (() => {
|
|
1743
1124
|
}),
|
|
@@ -1749,27 +1130,27 @@ const Fe = (t) => {
|
|
|
1749
1130
|
mouseUpEventVerifier: g,
|
|
1750
1131
|
mouseWheelEventVerifier: p,
|
|
1751
1132
|
scaleWheelFinishTimeout: ((G = t == null ? void 0 : t.scale) == null ? void 0 : G.wheelFinishTimeout) ?? 500,
|
|
1752
|
-
onResizeTransformStarted: ((
|
|
1133
|
+
onResizeTransformStarted: ((Z = t == null ? void 0 : t.events) == null ? void 0 : Z.onResizeTransformStarted) ?? (() => {
|
|
1753
1134
|
}),
|
|
1754
|
-
onResizeTransformFinished: ((
|
|
1135
|
+
onResizeTransformFinished: ((J = t == null ? void 0 : t.events) == null ? void 0 : J.onResizeTransformFinished) ?? (() => {
|
|
1755
1136
|
})
|
|
1756
1137
|
};
|
|
1757
|
-
},
|
|
1138
|
+
}, Ne = (t, e, o) => ({
|
|
1758
1139
|
scale: t.scale,
|
|
1759
1140
|
x: t.x + t.scale * e,
|
|
1760
1141
|
y: t.y + t.scale * o
|
|
1761
|
-
}),
|
|
1142
|
+
}), Me = (t, e, o, i) => ({
|
|
1762
1143
|
scale: t.scale * e,
|
|
1763
1144
|
x: t.scale * (1 - e) * o + t.x,
|
|
1764
|
-
y: t.scale * (1 - e) *
|
|
1145
|
+
y: t.scale * (1 - e) * i + t.y
|
|
1765
1146
|
}), R = (t) => {
|
|
1766
1147
|
const e = [], o = t.touches.length;
|
|
1767
1148
|
for (let d = 0; d < o; d++)
|
|
1768
1149
|
e.push([t.touches[d].clientX, t.touches[d].clientY]);
|
|
1769
|
-
const
|
|
1150
|
+
const i = e.reduce(
|
|
1770
1151
|
(d, c) => [d[0] + c[0], d[1] + c[1]],
|
|
1771
1152
|
[0, 0]
|
|
1772
|
-
), s = [
|
|
1153
|
+
), s = [i[0] / o, i[1] / o], n = e.map((d) => [d[0] - s[0], d[1] - s[1]]).reduce(
|
|
1773
1154
|
(d, c) => d + Math.sqrt(c[0] * c[0] + c[1] * c[1]),
|
|
1774
1155
|
0
|
|
1775
1156
|
);
|
|
@@ -1781,23 +1162,23 @@ const Fe = (t) => {
|
|
|
1781
1162
|
touches: e
|
|
1782
1163
|
};
|
|
1783
1164
|
};
|
|
1784
|
-
class
|
|
1785
|
-
constructor(e, o,
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1165
|
+
class I {
|
|
1166
|
+
constructor(e, o, i, s) {
|
|
1167
|
+
r(this, "viewport");
|
|
1168
|
+
r(this, "prevTouches", null);
|
|
1169
|
+
r(this, "wheelFinishTimer", null);
|
|
1170
|
+
r(this, "transformInProgress", !1);
|
|
1171
|
+
r(this, "onBeforeDestroy", () => {
|
|
1791
1172
|
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.element.removeEventListener("wheel", this.preventWheelScaleListener), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy);
|
|
1792
1173
|
});
|
|
1793
|
-
|
|
1174
|
+
r(this, "onMouseDown", (e) => {
|
|
1794
1175
|
this.element === null || !this.config.mouseDownEventVerifier(e) || (B(this.element, this.config.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
|
|
1795
1176
|
passive: !0
|
|
1796
1177
|
}), this.window.addEventListener("mouseup", this.onWindowMouseUp, {
|
|
1797
1178
|
passive: !0
|
|
1798
1179
|
}), this.startRegisteredTransform());
|
|
1799
1180
|
});
|
|
1800
|
-
|
|
1181
|
+
r(this, "onWindowMouseMove", (e) => {
|
|
1801
1182
|
const o = M(
|
|
1802
1183
|
this.window,
|
|
1803
1184
|
this.element,
|
|
@@ -1808,21 +1189,21 @@ class U {
|
|
|
1808
1189
|
this.stopMouseDrag();
|
|
1809
1190
|
return;
|
|
1810
1191
|
}
|
|
1811
|
-
const
|
|
1812
|
-
this.moveViewport(
|
|
1192
|
+
const i = -e.movementX, s = -e.movementY;
|
|
1193
|
+
this.moveViewport(i, s);
|
|
1813
1194
|
});
|
|
1814
|
-
|
|
1195
|
+
r(this, "onWindowMouseUp", (e) => {
|
|
1815
1196
|
this.element === null || !this.config.mouseUpEventVerifier(e) || this.stopMouseDrag();
|
|
1816
1197
|
});
|
|
1817
|
-
|
|
1198
|
+
r(this, "onWheelScroll", (e) => {
|
|
1818
1199
|
if (!this.config.mouseWheelEventVerifier(e))
|
|
1819
1200
|
return;
|
|
1820
|
-
const { left: o, top:
|
|
1201
|
+
const { left: o, top: i } = this.element.getBoundingClientRect(), s = e.clientX - o, h = e.clientY - i, d = 1 / (e.deltaY < 0 ? this.config.wheelSensitivity : 1 / this.config.wheelSensitivity);
|
|
1821
1202
|
this.wheelFinishTimer === null && this.config.onTransformStarted(), this.scaleViewport(d, s, h), this.wheelFinishTimer !== null && clearTimeout(this.wheelFinishTimer), this.wheelFinishTimer = setTimeout(() => {
|
|
1822
1203
|
this.transformInProgress || this.config.onTransformFinished(), this.wheelFinishTimer = null;
|
|
1823
1204
|
}, this.config.scaleWheelFinishTimeout);
|
|
1824
1205
|
});
|
|
1825
|
-
|
|
1206
|
+
r(this, "onTouchStart", (e) => {
|
|
1826
1207
|
if (this.prevTouches !== null) {
|
|
1827
1208
|
this.prevTouches = R(e);
|
|
1828
1209
|
return;
|
|
@@ -1835,7 +1216,7 @@ class U {
|
|
|
1835
1216
|
passive: !0
|
|
1836
1217
|
}), this.startRegisteredTransform();
|
|
1837
1218
|
});
|
|
1838
|
-
|
|
1219
|
+
r(this, "onWindowTouchMove", (e) => {
|
|
1839
1220
|
const o = R(e);
|
|
1840
1221
|
if (!o.touches.every(
|
|
1841
1222
|
(s) => M(this.window, this.element, s[0], s[1])
|
|
@@ -1852,25 +1233,25 @@ class U {
|
|
|
1852
1233
|
}
|
|
1853
1234
|
this.prevTouches = o;
|
|
1854
1235
|
});
|
|
1855
|
-
|
|
1236
|
+
r(this, "onWindowTouchFinish", (e) => {
|
|
1856
1237
|
e.touches.length > 0 ? this.prevTouches = R(e) : this.stopTouchDrag();
|
|
1857
1238
|
});
|
|
1858
|
-
|
|
1859
|
-
const e = this.viewport.getViewportMatrix(), { width: o, height:
|
|
1239
|
+
r(this, "observer", new ResizeObserver(() => {
|
|
1240
|
+
const e = this.viewport.getViewportMatrix(), { width: o, height: i } = this.element.getBoundingClientRect(), s = this.config.transformPreprocessor({
|
|
1860
1241
|
prevTransform: e,
|
|
1861
1242
|
nextTransform: e,
|
|
1862
1243
|
canvasWidth: o,
|
|
1863
|
-
canvasHeight:
|
|
1244
|
+
canvasHeight: i
|
|
1864
1245
|
});
|
|
1865
1246
|
this.config.onResizeTransformStarted(), this.canvas.patchViewportMatrix(s), this.config.onResizeTransformFinished();
|
|
1866
1247
|
}));
|
|
1867
|
-
|
|
1868
|
-
|
|
1248
|
+
r(this, "config");
|
|
1249
|
+
r(this, "preventWheelScaleListener", (e) => {
|
|
1869
1250
|
e.preventDefault();
|
|
1870
1251
|
});
|
|
1871
|
-
this.canvas = e, this.element = o, this.window =
|
|
1252
|
+
this.canvas = e, this.element = o, this.window = i, this.element.addEventListener("wheel", this.preventWheelScaleListener, {
|
|
1872
1253
|
passive: !1
|
|
1873
|
-
}), this.config =
|
|
1254
|
+
}), this.config = Pe(s), this.viewport = e.viewport, this.observer.observe(this.element), this.element.addEventListener("mousedown", this.onMouseDown, {
|
|
1874
1255
|
passive: !0
|
|
1875
1256
|
}), this.element.addEventListener("wheel", this.onWheelScroll, {
|
|
1876
1257
|
passive: !0
|
|
@@ -1878,25 +1259,25 @@ class U {
|
|
|
1878
1259
|
passive: !0
|
|
1879
1260
|
}), e.onBeforeDestroy.subscribe(this.onBeforeDestroy);
|
|
1880
1261
|
}
|
|
1881
|
-
static configure(e, o,
|
|
1882
|
-
new
|
|
1262
|
+
static configure(e, o, i, s) {
|
|
1263
|
+
new I(
|
|
1883
1264
|
e,
|
|
1884
1265
|
o,
|
|
1885
|
-
|
|
1266
|
+
i,
|
|
1886
1267
|
s
|
|
1887
1268
|
);
|
|
1888
1269
|
}
|
|
1889
1270
|
moveViewport(e, o) {
|
|
1890
|
-
const
|
|
1891
|
-
prevTransform:
|
|
1271
|
+
const i = this.viewport.getViewportMatrix(), s = Ne(i, e, o), { width: h, height: n } = this.element.getBoundingClientRect(), d = this.config.transformPreprocessor({
|
|
1272
|
+
prevTransform: i,
|
|
1892
1273
|
nextTransform: s,
|
|
1893
1274
|
canvasWidth: h,
|
|
1894
1275
|
canvasHeight: n
|
|
1895
1276
|
});
|
|
1896
1277
|
this.performTransform(d);
|
|
1897
1278
|
}
|
|
1898
|
-
scaleViewport(e, o,
|
|
1899
|
-
const s = this.canvas.viewport.getViewportMatrix(), h =
|
|
1279
|
+
scaleViewport(e, o, i) {
|
|
1280
|
+
const s = this.canvas.viewport.getViewportMatrix(), h = Me(s, e, o, i), { width: n, height: d } = this.element.getBoundingClientRect(), c = this.config.transformPreprocessor({
|
|
1900
1281
|
prevTransform: s,
|
|
1901
1282
|
nextTransform: h,
|
|
1902
1283
|
canvasWidth: n,
|
|
@@ -1926,22 +1307,22 @@ class U {
|
|
|
1926
1307
|
this.transformInProgress = !1, this.config.onTransformFinished();
|
|
1927
1308
|
}
|
|
1928
1309
|
}
|
|
1929
|
-
class
|
|
1930
|
-
constructor(e, o,
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1310
|
+
class z {
|
|
1311
|
+
constructor(e, o, i, s, h, n) {
|
|
1312
|
+
r(this, "canvasResizeObserver");
|
|
1313
|
+
r(this, "nodeHorizontal");
|
|
1314
|
+
r(this, "nodeVertical");
|
|
1315
|
+
r(this, "viewport");
|
|
1316
|
+
r(this, "viewportWidth", 0);
|
|
1317
|
+
r(this, "viewportHeight", 0);
|
|
1318
|
+
r(this, "viewportMatrix");
|
|
1319
|
+
r(this, "loadedArea", {
|
|
1939
1320
|
xFrom: 1 / 0,
|
|
1940
1321
|
xTo: 1 / 0,
|
|
1941
1322
|
yFrom: 1 / 0,
|
|
1942
1323
|
yTo: 1 / 0
|
|
1943
1324
|
});
|
|
1944
|
-
|
|
1325
|
+
r(this, "updateLoadedArea", (e) => {
|
|
1945
1326
|
this.loadedArea = {
|
|
1946
1327
|
xFrom: e.x,
|
|
1947
1328
|
xTo: e.x + e.width,
|
|
@@ -1949,25 +1330,25 @@ class X {
|
|
|
1949
1330
|
yTo: e.y + e.height
|
|
1950
1331
|
};
|
|
1951
1332
|
});
|
|
1952
|
-
|
|
1333
|
+
r(this, "onBeforeDestroy", () => {
|
|
1953
1334
|
this.trigger.unsubscribe(this.updateLoadedArea), this.canvasResizeObserver.unobserve(this.element), this.canvas.viewport.onAfterUpdated.unsubscribe(
|
|
1954
1335
|
this.onAfterViewportUpdated
|
|
1955
1336
|
), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy);
|
|
1956
1337
|
});
|
|
1957
|
-
|
|
1338
|
+
r(this, "onAfterViewportUpdated", () => {
|
|
1958
1339
|
this.userTransformInProgress || (this.viewportMatrix = this.viewport.getViewportMatrix(), this.loadAreaAroundViewport());
|
|
1959
1340
|
});
|
|
1960
|
-
|
|
1961
|
-
var p, f,
|
|
1962
|
-
this.canvas = e, this.element = o, this.window =
|
|
1963
|
-
const
|
|
1964
|
-
this.viewportWidth =
|
|
1341
|
+
r(this, "userTransformInProgress", !1);
|
|
1342
|
+
var p, f, A, E, m;
|
|
1343
|
+
this.canvas = e, this.element = o, this.window = i, this.trigger = h, this.virtualScrollOptions = n, this.nodeHorizontal = this.virtualScrollOptions.nodeContainingRadius.horizontal, this.nodeVertical = this.virtualScrollOptions.nodeContainingRadius.vertical, this.canvasResizeObserver = new ResizeObserver((T) => {
|
|
1344
|
+
const b = T[0];
|
|
1345
|
+
this.viewportWidth = b.contentRect.width, this.viewportHeight = b.contentRect.height, this.scheduleLoadAreaAroundViewport();
|
|
1965
1346
|
}), this.viewport = e.viewport;
|
|
1966
1347
|
const d = ((p = s == null ? void 0 : s.events) == null ? void 0 : p.onResizeTransformStarted) ?? (() => {
|
|
1967
1348
|
}), c = ((f = s == null ? void 0 : s.events) == null ? void 0 : f.onResizeTransformFinished) ?? (() => {
|
|
1968
|
-
}), a = ((
|
|
1969
|
-
}), l = ((
|
|
1970
|
-
}), g = ((
|
|
1349
|
+
}), a = ((A = s == null ? void 0 : s.events) == null ? void 0 : A.onTransformChange) ?? (() => {
|
|
1350
|
+
}), l = ((E = s == null ? void 0 : s.events) == null ? void 0 : E.onBeforeTransformChange) ?? (() => {
|
|
1351
|
+
}), g = ((m = s == null ? void 0 : s.events) == null ? void 0 : m.onTransformFinished) ?? (() => {
|
|
1971
1352
|
}), y = {
|
|
1972
1353
|
...s,
|
|
1973
1354
|
events: {
|
|
@@ -1983,26 +1364,26 @@ class X {
|
|
|
1983
1364
|
},
|
|
1984
1365
|
onTransformChange: () => {
|
|
1985
1366
|
this.userTransformInProgress = !1;
|
|
1986
|
-
const
|
|
1987
|
-
this.viewportMatrix = this.viewport.getViewportMatrix(),
|
|
1367
|
+
const T = this.viewportMatrix;
|
|
1368
|
+
this.viewportMatrix = this.viewport.getViewportMatrix(), T.scale !== this.viewportMatrix.scale && this.scheduleEnsureViewportAreaLoaded(), a();
|
|
1988
1369
|
},
|
|
1989
1370
|
onTransformFinished: () => {
|
|
1990
1371
|
this.scheduleLoadAreaAroundViewport(), g();
|
|
1991
1372
|
}
|
|
1992
1373
|
}
|
|
1993
1374
|
};
|
|
1994
|
-
|
|
1375
|
+
I.configure(
|
|
1995
1376
|
e,
|
|
1996
1377
|
this.element,
|
|
1997
1378
|
this.window,
|
|
1998
1379
|
y
|
|
1999
1380
|
), 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);
|
|
2000
1381
|
}
|
|
2001
|
-
static configure(e, o,
|
|
2002
|
-
new
|
|
1382
|
+
static configure(e, o, i, s, h, n) {
|
|
1383
|
+
new z(
|
|
2003
1384
|
e,
|
|
2004
1385
|
o,
|
|
2005
|
-
|
|
1386
|
+
i,
|
|
2006
1387
|
s,
|
|
2007
1388
|
h,
|
|
2008
1389
|
n
|
|
@@ -2013,393 +1394,1094 @@ class X {
|
|
|
2013
1394
|
this.loadAreaAroundViewport();
|
|
2014
1395
|
});
|
|
2015
1396
|
}
|
|
2016
|
-
scheduleEnsureViewportAreaLoaded() {
|
|
2017
|
-
const e = this.viewportWidth * this.viewportMatrix.scale, o = this.viewportHeight * this.viewportMatrix.scale,
|
|
2018
|
-
this.loadedArea.xFrom <
|
|
1397
|
+
scheduleEnsureViewportAreaLoaded() {
|
|
1398
|
+
const e = this.viewportWidth * this.viewportMatrix.scale, o = this.viewportHeight * this.viewportMatrix.scale, i = this.viewportMatrix.x - this.nodeHorizontal, s = this.viewportMatrix.y - this.nodeVertical, h = this.viewportMatrix.x + e + this.nodeHorizontal, n = this.viewportMatrix.y + o + this.nodeVertical;
|
|
1399
|
+
this.loadedArea.xFrom < i && this.loadedArea.xTo > h && this.loadedArea.yFrom < s && this.loadedArea.yTo > n || this.scheduleLoadAreaAroundViewport();
|
|
1400
|
+
}
|
|
1401
|
+
loadAreaAroundViewport() {
|
|
1402
|
+
const e = this.viewportWidth * this.viewportMatrix.scale, o = this.viewportHeight * this.viewportMatrix.scale, i = this.viewportMatrix.x - e - this.nodeHorizontal, s = this.viewportMatrix.y - o - this.nodeVertical, h = 3 * e + 2 * this.nodeHorizontal, n = 3 * o + 2 * this.nodeVertical;
|
|
1403
|
+
this.trigger.emit({ x: i, y: s, width: h, height: n });
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
const De = () => {
|
|
1407
|
+
const t = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
1408
|
+
return t.style.position = "absolute", t.style.inset = "0", t;
|
|
1409
|
+
}, Le = () => {
|
|
1410
|
+
const t = document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
|
1411
|
+
return t.setAttribute("fill", "url(#pattern)"), t;
|
|
1412
|
+
}, Ve = () => {
|
|
1413
|
+
const t = document.createElementNS(
|
|
1414
|
+
"http://www.w3.org/2000/svg",
|
|
1415
|
+
"pattern"
|
|
1416
|
+
);
|
|
1417
|
+
return t.setAttribute("id", "pattern"), t;
|
|
1418
|
+
}, Re = (t, e) => {
|
|
1419
|
+
const o = document.createElementNS(
|
|
1420
|
+
"http://www.w3.org/2000/svg",
|
|
1421
|
+
"circle"
|
|
1422
|
+
);
|
|
1423
|
+
return o.setAttribute("cx", "0"), o.setAttribute("cy", "0"), o.setAttribute("r", `${t}`), o.setAttribute("fill", `${e}`), o;
|
|
1424
|
+
}, Be = (t) => t instanceof SVGElement ? t : Re(
|
|
1425
|
+
(t == null ? void 0 : t.radius) ?? 1.5,
|
|
1426
|
+
(t == null ? void 0 : t.color) ?? "#d8d8d8"
|
|
1427
|
+
), Ie = (t) => {
|
|
1428
|
+
const e = t.tileDimensions, o = (e == null ? void 0 : e.width) ?? 25, i = (e == null ? void 0 : e.height) ?? 25, s = Be(t.renderer ?? {});
|
|
1429
|
+
return {
|
|
1430
|
+
tileWidth: o,
|
|
1431
|
+
tileHeight: i,
|
|
1432
|
+
renderer: s,
|
|
1433
|
+
maxViewportScale: t.maxViewportScale ?? 10
|
|
1434
|
+
};
|
|
1435
|
+
};
|
|
1436
|
+
class O {
|
|
1437
|
+
constructor(e, o, i) {
|
|
1438
|
+
r(this, "svg", De());
|
|
1439
|
+
r(this, "patternRenderingRectangle", Le());
|
|
1440
|
+
r(this, "pattern", Ve());
|
|
1441
|
+
r(this, "patternContent");
|
|
1442
|
+
r(this, "tileWidth");
|
|
1443
|
+
r(this, "tileHeight");
|
|
1444
|
+
r(this, "halfTileWidth");
|
|
1445
|
+
r(this, "halfTileHeight");
|
|
1446
|
+
r(this, "maxViewportScale");
|
|
1447
|
+
r(this, "visible", !1);
|
|
1448
|
+
r(this, "resizeObserver", new ResizeObserver((e) => {
|
|
1449
|
+
const o = e[0], { width: i, height: s } = o.contentRect;
|
|
1450
|
+
this.svg.setAttribute("width", `${i}`), this.svg.setAttribute("height", `${s}`), this.patternRenderingRectangle.setAttribute("width", `${i}`), this.patternRenderingRectangle.setAttribute("height", `${s}`);
|
|
1451
|
+
const h = this.tileWidth / i, n = this.tileHeight / s;
|
|
1452
|
+
this.pattern.setAttribute("width", `${h}`), this.pattern.setAttribute("height", `${n}`);
|
|
1453
|
+
}));
|
|
1454
|
+
r(this, "onAfterTransformUpdated", () => {
|
|
1455
|
+
const e = this.canvas.viewport.getContentMatrix(), o = e.x - this.halfTileWidth * e.scale, i = e.y - this.halfTileHeight * e.scale, s = `matrix(${e.scale}, 0, 0, ${e.scale}, ${o}, ${i})`;
|
|
1456
|
+
this.pattern.setAttribute("patternTransform", s), this.updateVisibility();
|
|
1457
|
+
});
|
|
1458
|
+
r(this, "onBeforeDestroy", () => {
|
|
1459
|
+
this.resizeObserver.unobserve(this.host), this.host.removeChild(this.svg), this.canvas.viewport.onAfterUpdated.unsubscribe(
|
|
1460
|
+
this.onAfterTransformUpdated
|
|
1461
|
+
), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy);
|
|
1462
|
+
});
|
|
1463
|
+
this.canvas = e, this.host = i;
|
|
1464
|
+
const s = Ie(o);
|
|
1465
|
+
this.tileWidth = s.tileWidth, this.tileHeight = s.tileHeight, this.halfTileWidth = this.tileWidth / 2, this.halfTileHeight = this.tileHeight / 2, this.patternContent = s.renderer, this.maxViewportScale = s.maxViewportScale;
|
|
1466
|
+
const h = `translate(${this.halfTileWidth}, ${this.halfTileHeight})`;
|
|
1467
|
+
this.patternContent.setAttribute("transform", h), this.pattern.appendChild(this.patternContent);
|
|
1468
|
+
const n = document.createElementNS("http://www.w3.org/2000/svg", "defs");
|
|
1469
|
+
n.appendChild(this.pattern), this.svg.appendChild(n), this.svg.appendChild(this.patternRenderingRectangle), this.resizeObserver.observe(this.host), this.canvas.viewport.onAfterUpdated.subscribe(this.onAfterTransformUpdated), this.onAfterTransformUpdated(), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
|
|
1470
|
+
}
|
|
1471
|
+
static configure(e, o, i) {
|
|
1472
|
+
new O(e, o, i);
|
|
1473
|
+
}
|
|
1474
|
+
updateVisibility() {
|
|
1475
|
+
const o = this.canvas.viewport.getViewportMatrix().scale > this.maxViewportScale;
|
|
1476
|
+
o && this.visible ? (this.visible = !1, this.host.removeChild(this.svg)) : !o && !this.visible && (this.visible = !0, this.host.appendChild(this.svg));
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
const Ue = (t) => {
|
|
1480
|
+
var d, c, a;
|
|
1481
|
+
const e = () => "direct", o = (l) => l, i = (l) => l.button === 0, s = () => {
|
|
1482
|
+
}, h = () => {
|
|
1483
|
+
}, n = () => {
|
|
1484
|
+
};
|
|
1485
|
+
return {
|
|
1486
|
+
connectionTypeResolver: t.connectionTypeResolver ?? e,
|
|
1487
|
+
connectionPreprocessor: t.connectionPreprocessor ?? o,
|
|
1488
|
+
mouseDownEventVerifier: t.mouseDownEventVerifier ?? i,
|
|
1489
|
+
mouseUpEventVerifier: t.mouseUpEventVerifier ?? i,
|
|
1490
|
+
onAfterEdgeCreated: ((d = t.events) == null ? void 0 : d.onAfterEdgeCreated) ?? s,
|
|
1491
|
+
onEdgeCreationInterrupted: ((c = t.events) == null ? void 0 : c.onEdgeCreationInterrupted) ?? n,
|
|
1492
|
+
onEdgeCreationPrevented: ((a = t.events) == null ? void 0 : a.onEdgeCreationPrevented) ?? h,
|
|
1493
|
+
dragPortDirection: t.dragPortDirection ?? void 0
|
|
1494
|
+
};
|
|
1495
|
+
};
|
|
1496
|
+
class X {
|
|
1497
|
+
constructor(e, o, i, s, h, n) {
|
|
1498
|
+
r(this, "config");
|
|
1499
|
+
r(this, "overlayCanvas");
|
|
1500
|
+
r(this, "ports", new he());
|
|
1501
|
+
r(this, "staticOverlayPortId", "static");
|
|
1502
|
+
r(this, "draggingOverlayPortId", "dragging");
|
|
1503
|
+
r(this, "staticPortId", null);
|
|
1504
|
+
r(this, "isDirect", !0);
|
|
1505
|
+
r(this, "onAfterPortMarked", (e) => {
|
|
1506
|
+
const o = this.canvas.graph.getPort(e);
|
|
1507
|
+
this.ports.hasSingle(o.element) || this.hookPortEvents(o.element), this.ports.addRecord(o.element, e);
|
|
1508
|
+
});
|
|
1509
|
+
r(this, "onBeforePortUnmarked", (e) => {
|
|
1510
|
+
const o = this.canvas.graph.getPort(e);
|
|
1511
|
+
this.ports.removeByMulti(e), this.ports.hasSingle(o.element) || this.unhookPortEvents(o.element);
|
|
1512
|
+
});
|
|
1513
|
+
r(this, "onPortMouseDown", (e) => {
|
|
1514
|
+
const o = e.currentTarget;
|
|
1515
|
+
this.config.mouseDownEventVerifier(e) && this.isPortConnectionAllowed(o) && (e.stopPropagation(), this.grabPort(o, { x: e.clientX, y: e.clientY }), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
|
|
1516
|
+
passive: !0
|
|
1517
|
+
}), this.window.addEventListener("mouseup", this.onWindowMouseUp, {
|
|
1518
|
+
passive: !0
|
|
1519
|
+
}));
|
|
1520
|
+
});
|
|
1521
|
+
r(this, "onWindowMouseMove", (e) => {
|
|
1522
|
+
if (!M(
|
|
1523
|
+
this.window,
|
|
1524
|
+
this.overlayLayer,
|
|
1525
|
+
e.clientX,
|
|
1526
|
+
e.clientY
|
|
1527
|
+
)) {
|
|
1528
|
+
this.stopMouseDrag();
|
|
1529
|
+
return;
|
|
1530
|
+
}
|
|
1531
|
+
this.moveDraggingNode({ x: e.clientX, y: e.clientY });
|
|
1532
|
+
});
|
|
1533
|
+
r(this, "onWindowMouseUp", (e) => {
|
|
1534
|
+
this.config.mouseUpEventVerifier(e) && (this.tryCreateConnection({ x: e.clientX, y: e.clientY }), this.stopMouseDrag());
|
|
1535
|
+
});
|
|
1536
|
+
r(this, "onPortTouchStart", (e) => {
|
|
1537
|
+
const o = e.currentTarget;
|
|
1538
|
+
if (!(e.touches.length === 1 && this.isPortConnectionAllowed(o)))
|
|
1539
|
+
return;
|
|
1540
|
+
e.stopPropagation();
|
|
1541
|
+
const s = e.touches[0];
|
|
1542
|
+
this.grabPort(o, { x: s.clientX, y: s.clientY }), this.window.addEventListener("touchmove", this.onWindowTouchMove, {
|
|
1543
|
+
passive: !0
|
|
1544
|
+
}), this.window.addEventListener("touchend", this.onWindowTouchFinish, {
|
|
1545
|
+
passive: !0
|
|
1546
|
+
}), this.window.addEventListener("touchcancel", this.onWindowTouchFinish, {
|
|
1547
|
+
passive: !0
|
|
1548
|
+
});
|
|
1549
|
+
});
|
|
1550
|
+
r(this, "onWindowTouchMove", (e) => {
|
|
1551
|
+
const o = e.touches[0];
|
|
1552
|
+
if (!M(
|
|
1553
|
+
this.window,
|
|
1554
|
+
this.overlayLayer,
|
|
1555
|
+
o.clientX,
|
|
1556
|
+
o.clientY
|
|
1557
|
+
)) {
|
|
1558
|
+
this.stopTouchDrag();
|
|
1559
|
+
return;
|
|
1560
|
+
}
|
|
1561
|
+
this.moveDraggingNode({ x: o.clientX, y: o.clientY });
|
|
1562
|
+
});
|
|
1563
|
+
r(this, "onWindowTouchFinish", (e) => {
|
|
1564
|
+
const o = e.changedTouches[0];
|
|
1565
|
+
this.tryCreateConnection({ x: o.clientX, y: o.clientY }), this.stopTouchDrag();
|
|
1566
|
+
});
|
|
1567
|
+
r(this, "onBeforeClear", () => {
|
|
1568
|
+
this.ports.forEachSingle((e) => {
|
|
1569
|
+
this.unhookPortEvents(e);
|
|
1570
|
+
}), this.ports.clear();
|
|
1571
|
+
});
|
|
1572
|
+
r(this, "onBeforeDestroy", () => {
|
|
1573
|
+
this.stopMouseDrag(), this.stopTouchDrag(), this.canvas.graph.onAfterPortMarked.unsubscribe(this.onAfterPortMarked), this.canvas.graph.onBeforePortUnmarked.unsubscribe(
|
|
1574
|
+
this.onBeforePortUnmarked
|
|
1575
|
+
), this.canvas.graph.onBeforeClear.unsubscribe(this.onBeforeClear), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy);
|
|
1576
|
+
});
|
|
1577
|
+
r(this, "onEdgeCreated", (e) => {
|
|
1578
|
+
this.config.onAfterEdgeCreated(e);
|
|
1579
|
+
});
|
|
1580
|
+
this.canvas = e, this.overlayLayer = o, this.viewportStore = i, this.window = s, this.config = Ue(n);
|
|
1581
|
+
const d = new de(), c = new ie(
|
|
1582
|
+
d,
|
|
1583
|
+
this.viewportStore,
|
|
1584
|
+
this.overlayLayer
|
|
1585
|
+
);
|
|
1586
|
+
this.overlayCanvas = new ne(
|
|
1587
|
+
this.overlayLayer,
|
|
1588
|
+
d,
|
|
1589
|
+
this.viewportStore,
|
|
1590
|
+
c,
|
|
1591
|
+
h
|
|
1592
|
+
), this.canvas.graph.onAfterPortMarked.subscribe(this.onAfterPortMarked), this.canvas.graph.onBeforePortUnmarked.subscribe(this.onBeforePortUnmarked), this.canvas.graph.onBeforeClear.subscribe(this.onBeforeClear), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
|
|
1593
|
+
}
|
|
1594
|
+
static configure(e, o, i, s, h, n) {
|
|
1595
|
+
new X(
|
|
1596
|
+
e,
|
|
1597
|
+
o,
|
|
1598
|
+
i,
|
|
1599
|
+
s,
|
|
1600
|
+
h,
|
|
1601
|
+
n
|
|
1602
|
+
);
|
|
1603
|
+
}
|
|
1604
|
+
grabPort(e, o) {
|
|
1605
|
+
const i = this.ports.getMultiBySingle(e)[0], s = this.canvas.graph.getPort(i);
|
|
1606
|
+
this.staticPortId = i;
|
|
1607
|
+
const h = this.config.connectionTypeResolver(this.staticPortId), n = e.getBoundingClientRect(), d = n.x + n.width / 2, c = n.y + n.height / 2, a = this.overlayLayer.getBoundingClientRect(), l = this.canvas.viewport.getViewportMatrix(), g = N(l, {
|
|
1608
|
+
x: d - a.x,
|
|
1609
|
+
y: c - a.y
|
|
1610
|
+
}), y = N(l, {
|
|
1611
|
+
x: o.x - a.x,
|
|
1612
|
+
y: o.y - a.y
|
|
1613
|
+
}), p = {
|
|
1614
|
+
overlayId: this.staticOverlayPortId,
|
|
1615
|
+
portCoords: g,
|
|
1616
|
+
portDirection: s.direction
|
|
1617
|
+
}, f = {
|
|
1618
|
+
overlayId: this.draggingOverlayPortId,
|
|
1619
|
+
portCoords: y,
|
|
1620
|
+
portDirection: this.config.dragPortDirection
|
|
1621
|
+
};
|
|
1622
|
+
this.isDirect = h === "direct";
|
|
1623
|
+
const A = this.isDirect ? p : f, E = this.isDirect ? f : p;
|
|
1624
|
+
this.createOverlayGraph(A, E);
|
|
1625
|
+
}
|
|
1626
|
+
hookPortEvents(e) {
|
|
1627
|
+
e.addEventListener("mousedown", this.onPortMouseDown, {
|
|
1628
|
+
passive: !0
|
|
1629
|
+
}), e.addEventListener("touchstart", this.onPortTouchStart, {
|
|
1630
|
+
passive: !0
|
|
1631
|
+
});
|
|
1632
|
+
}
|
|
1633
|
+
unhookPortEvents(e) {
|
|
1634
|
+
e.removeEventListener("mousedown", this.onPortMouseDown), e.removeEventListener("touchstart", this.onPortTouchStart);
|
|
1635
|
+
}
|
|
1636
|
+
stopMouseDrag() {
|
|
1637
|
+
this.resetDragState(), this.window.removeEventListener("mouseup", this.onWindowMouseUp), this.window.removeEventListener("mousemove", this.onWindowMouseMove);
|
|
1638
|
+
}
|
|
1639
|
+
stopTouchDrag() {
|
|
1640
|
+
this.resetDragState(), this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
|
|
1641
|
+
}
|
|
1642
|
+
resetDragState() {
|
|
1643
|
+
this.staticPortId = null, this.isDirect = !0, this.overlayCanvas.clear();
|
|
1644
|
+
}
|
|
1645
|
+
createOverlayGraph(e, o) {
|
|
1646
|
+
const i = this.createAddNodeRequest(e);
|
|
1647
|
+
this.overlayCanvas.addNode(i);
|
|
1648
|
+
const s = this.createAddNodeRequest(o);
|
|
1649
|
+
this.overlayCanvas.addNode(s), this.overlayCanvas.addEdge({
|
|
1650
|
+
from: e.overlayId,
|
|
1651
|
+
to: o.overlayId
|
|
1652
|
+
});
|
|
1653
|
+
}
|
|
1654
|
+
createAddNodeRequest(e) {
|
|
1655
|
+
const o = document.createElement("div");
|
|
1656
|
+
return {
|
|
1657
|
+
id: e.overlayId,
|
|
1658
|
+
element: o,
|
|
1659
|
+
x: e.portCoords.x,
|
|
1660
|
+
y: e.portCoords.y,
|
|
1661
|
+
ports: [
|
|
1662
|
+
{
|
|
1663
|
+
id: e.overlayId,
|
|
1664
|
+
element: o,
|
|
1665
|
+
direction: e.portDirection
|
|
1666
|
+
}
|
|
1667
|
+
]
|
|
1668
|
+
};
|
|
1669
|
+
}
|
|
1670
|
+
tryCreateConnection(e) {
|
|
1671
|
+
const o = this.findPortAtPoint(e);
|
|
1672
|
+
if (o === null) {
|
|
1673
|
+
this.config.onEdgeCreationInterrupted(this.staticPortId, this.isDirect);
|
|
1674
|
+
return;
|
|
1675
|
+
}
|
|
1676
|
+
const i = this.isDirect ? this.staticPortId : o, s = this.isDirect ? o : this.staticPortId, h = { from: i, to: s }, n = this.config.connectionPreprocessor(h);
|
|
1677
|
+
n !== null ? (this.canvas.graph.onAfterEdgeAdded.subscribe(this.onEdgeCreated), this.canvas.addEdge(n), this.canvas.graph.onAfterEdgeAdded.unsubscribe(this.onEdgeCreated)) : this.config.onEdgeCreationPrevented(h);
|
|
1678
|
+
}
|
|
1679
|
+
moveDraggingNode(e) {
|
|
1680
|
+
const o = this.overlayLayer.getBoundingClientRect(), i = {
|
|
1681
|
+
x: e.x - o.x,
|
|
1682
|
+
y: e.y - o.y
|
|
1683
|
+
}, s = this.canvas.viewport.getViewportMatrix(), h = N(s, i);
|
|
1684
|
+
this.overlayCanvas.updateNode(this.draggingOverlayPortId, {
|
|
1685
|
+
x: h.x,
|
|
1686
|
+
y: h.y
|
|
1687
|
+
});
|
|
1688
|
+
}
|
|
1689
|
+
findPortAtPoint(e) {
|
|
1690
|
+
const o = document.elementsFromPoint(e.x, e.y);
|
|
1691
|
+
for (const i of o) {
|
|
1692
|
+
const s = this.findPortAtElement(i);
|
|
1693
|
+
if (s !== null)
|
|
1694
|
+
return s;
|
|
1695
|
+
}
|
|
1696
|
+
return null;
|
|
1697
|
+
}
|
|
1698
|
+
findPortAtElement(e) {
|
|
1699
|
+
let o = e, i = null;
|
|
1700
|
+
for (; o !== null && (i = this.ports.getMultiBySingle(o)[0] ?? null, i === null); )
|
|
1701
|
+
o = o.parentElement;
|
|
1702
|
+
return i;
|
|
2019
1703
|
}
|
|
2020
|
-
|
|
2021
|
-
const
|
|
2022
|
-
this.
|
|
1704
|
+
isPortConnectionAllowed(e) {
|
|
1705
|
+
const o = this.ports.getMultiBySingle(e)[0];
|
|
1706
|
+
return this.config.connectionTypeResolver(o) !== null;
|
|
2023
1707
|
}
|
|
2024
1708
|
}
|
|
2025
|
-
const
|
|
2026
|
-
const t = document.
|
|
1709
|
+
const Ce = () => {
|
|
1710
|
+
const t = document.createElement("div");
|
|
1711
|
+
return t.style.width = "100%", t.style.height = "100%", t.style.position = "relative", t;
|
|
1712
|
+
}, W = () => {
|
|
1713
|
+
const t = document.createElement("div");
|
|
2027
1714
|
return t.style.position = "absolute", t.style.inset = "0", t;
|
|
2028
|
-
}, je = () => {
|
|
2029
|
-
const t = document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
|
2030
|
-
return t.setAttribute("fill", "url(#pattern)"), t;
|
|
2031
|
-
}, Ge = () => {
|
|
2032
|
-
const t = document.createElementNS(
|
|
2033
|
-
"http://www.w3.org/2000/svg",
|
|
2034
|
-
"pattern"
|
|
2035
|
-
);
|
|
2036
|
-
return t.setAttribute("id", "pattern"), t;
|
|
2037
|
-
}, Je = (t, e) => {
|
|
2038
|
-
const o = document.createElementNS(
|
|
2039
|
-
"http://www.w3.org/2000/svg",
|
|
2040
|
-
"circle"
|
|
2041
|
-
);
|
|
2042
|
-
return o.setAttribute("cx", "0"), o.setAttribute("cy", "0"), o.setAttribute("r", `${t}`), o.setAttribute("fill", `${e}`), o;
|
|
2043
|
-
}, Ke = (t) => t instanceof SVGElement ? t : Je(
|
|
2044
|
-
(t == null ? void 0 : t.radius) ?? 1.5,
|
|
2045
|
-
(t == null ? void 0 : t.color) ?? "#d8d8d8"
|
|
2046
|
-
), Qe = (t) => {
|
|
2047
|
-
const e = t.tileDimensions, o = (e == null ? void 0 : e.width) ?? 25, r = (e == null ? void 0 : e.height) ?? 25, s = Ke(t.renderer ?? {});
|
|
2048
|
-
return {
|
|
2049
|
-
tileWidth: o,
|
|
2050
|
-
tileHeight: r,
|
|
2051
|
-
renderer: s,
|
|
2052
|
-
maxViewportScale: t.maxViewportScale ?? 10
|
|
2053
|
-
};
|
|
2054
1715
|
};
|
|
2055
|
-
class
|
|
2056
|
-
constructor(e
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
i(this, "tileHeight");
|
|
2063
|
-
i(this, "halfTileWidth");
|
|
2064
|
-
i(this, "halfTileHeight");
|
|
2065
|
-
i(this, "maxViewportScale");
|
|
2066
|
-
i(this, "visible", !1);
|
|
2067
|
-
i(this, "resizeObserver", new ResizeObserver((e) => {
|
|
2068
|
-
const o = e[0], { width: r, height: s } = o.contentRect;
|
|
2069
|
-
this.svg.setAttribute("width", `${r}`), this.svg.setAttribute("height", `${s}`), this.patternRenderingRectangle.setAttribute("width", `${r}`), this.patternRenderingRectangle.setAttribute("height", `${s}`);
|
|
2070
|
-
const h = this.tileWidth / r, n = this.tileHeight / s;
|
|
2071
|
-
this.pattern.setAttribute("width", `${h}`), this.pattern.setAttribute("height", `${n}`);
|
|
2072
|
-
}));
|
|
2073
|
-
i(this, "onAfterTransformUpdated", () => {
|
|
2074
|
-
const e = this.canvas.viewport.getContentMatrix(), o = e.x - this.halfTileWidth * e.scale, r = e.y - this.halfTileHeight * e.scale, s = `matrix(${e.scale}, 0, 0, ${e.scale}, ${o}, ${r})`;
|
|
2075
|
-
this.pattern.setAttribute("patternTransform", s), this.updateVisibility();
|
|
2076
|
-
});
|
|
2077
|
-
i(this, "onBeforeDestroy", () => {
|
|
2078
|
-
this.resizeObserver.unobserve(this.host), this.host.removeChild(this.svg), this.canvas.viewport.onAfterUpdated.unsubscribe(
|
|
2079
|
-
this.onAfterTransformUpdated
|
|
2080
|
-
), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy);
|
|
2081
|
-
});
|
|
2082
|
-
this.canvas = e, this.host = r;
|
|
2083
|
-
const s = Qe(o);
|
|
2084
|
-
this.tileWidth = s.tileWidth, this.tileHeight = s.tileHeight, this.halfTileWidth = this.tileWidth / 2, this.halfTileHeight = this.tileHeight / 2, this.patternContent = s.renderer, this.maxViewportScale = s.maxViewportScale;
|
|
2085
|
-
const h = `translate(${this.halfTileWidth}, ${this.halfTileHeight})`;
|
|
2086
|
-
this.patternContent.setAttribute("transform", h), this.pattern.appendChild(this.patternContent);
|
|
2087
|
-
const n = document.createElementNS("http://www.w3.org/2000/svg", "defs");
|
|
2088
|
-
n.appendChild(this.pattern), this.svg.appendChild(n), this.svg.appendChild(this.patternRenderingRectangle), this.resizeObserver.observe(this.host), this.canvas.viewport.onAfterUpdated.subscribe(this.onAfterTransformUpdated), this.onAfterTransformUpdated(), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
|
|
2089
|
-
}
|
|
2090
|
-
static configure(e, o, r) {
|
|
2091
|
-
new Y(e, o, r);
|
|
1716
|
+
class We {
|
|
1717
|
+
constructor(e) {
|
|
1718
|
+
r(this, "background", W());
|
|
1719
|
+
r(this, "main", W());
|
|
1720
|
+
r(this, "overlay", W());
|
|
1721
|
+
r(this, "host", Ce());
|
|
1722
|
+
this.element = e, this.element.appendChild(this.host), this.host.appendChild(this.background), this.host.appendChild(this.main), this.overlay.style.pointerEvents = "none", this.host.appendChild(this.overlay);
|
|
2092
1723
|
}
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
o && this.visible ? (this.visible = !1, this.host.removeChild(this.svg)) : !o && !this.visible && (this.visible = !0, this.host.appendChild(this.svg));
|
|
1724
|
+
destroy() {
|
|
1725
|
+
this.host.removeChild(this.background), this.host.removeChild(this.main), this.host.removeChild(this.overlay), this.element.removeChild(this.host);
|
|
2096
1726
|
}
|
|
2097
1727
|
}
|
|
2098
|
-
const
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
1728
|
+
const $e = (t, e) => ({
|
|
1729
|
+
x: t / 2,
|
|
1730
|
+
y: e / 2
|
|
1731
|
+
}), $ = (t) => () => t, q = $(0), Fe = () => {
|
|
1732
|
+
let t = 0;
|
|
1733
|
+
return () => t++;
|
|
1734
|
+
}, ke = (t, e) => {
|
|
1735
|
+
let o = q, i = q;
|
|
1736
|
+
const s = Fe();
|
|
1737
|
+
return t === "incremental" && (o = s), e === "incremental" && (i = s), typeof t == "number" && (o = $(t)), typeof e == "number" && (i = $(e)), typeof t == "function" && (o = t), typeof e == "function" && (i = e), {
|
|
1738
|
+
nodesPriorityFn: o,
|
|
1739
|
+
edgesPriorityFn: i
|
|
2103
1740
|
};
|
|
1741
|
+
}, v = (t, e, o) => ({
|
|
1742
|
+
x: e.x * t.x - e.y * t.y + ((1 - e.x) * o.x + e.y * o.y),
|
|
1743
|
+
y: e.y * t.x + e.x * t.y + ((1 - e.x) * o.y - e.y * o.x)
|
|
1744
|
+
}), w = {
|
|
1745
|
+
x: 0,
|
|
1746
|
+
y: 0
|
|
1747
|
+
}, ze = (t) => {
|
|
1748
|
+
const e = v(
|
|
1749
|
+
{ x: t.arrowLength, y: w.y },
|
|
1750
|
+
t.fromVector,
|
|
1751
|
+
w
|
|
1752
|
+
), o = v(
|
|
1753
|
+
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
1754
|
+
t.toVector,
|
|
1755
|
+
t.to
|
|
1756
|
+
), i = {
|
|
1757
|
+
x: e.x + t.fromVector.x * t.curvature,
|
|
1758
|
+
y: e.y + t.fromVector.y * t.curvature
|
|
1759
|
+
}, s = {
|
|
1760
|
+
x: o.x - t.toVector.x * t.curvature,
|
|
1761
|
+
y: o.y - t.toVector.y * t.curvature
|
|
1762
|
+
}, h = `M ${e.x} ${e.y} C ${i.x} ${i.y}, ${s.x} ${s.y}, ${o.x} ${o.y}`, n = t.hasSourceArrow ? "" : `M ${w.x} ${w.y} L ${e.x} ${e.y} `, d = t.hasTargetArrow ? "" : ` M ${o.x} ${o.y} L ${t.to.x} ${t.to.y}`;
|
|
1763
|
+
return `${n}${h}${d}`;
|
|
1764
|
+
}, Oe = (t) => {
|
|
1765
|
+
const e = t.hasSourceArrow ? v(
|
|
1766
|
+
{ x: t.arrowLength, y: w.y },
|
|
1767
|
+
t.fromVector,
|
|
1768
|
+
w
|
|
1769
|
+
) : w, o = t.hasTargetArrow ? v(
|
|
1770
|
+
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
1771
|
+
t.toVector,
|
|
1772
|
+
t.to
|
|
1773
|
+
) : t.to, i = t.arrowLength, s = Math.cos(t.detourDirection) * t.detourDistance, h = Math.sin(t.detourDirection) * t.detourDistance, n = s * t.flipX, d = h * t.flipY, c = v(
|
|
1774
|
+
{ x: i, y: w.y },
|
|
1775
|
+
t.fromVector,
|
|
1776
|
+
w
|
|
1777
|
+
), a = {
|
|
1778
|
+
x: c.x + n,
|
|
1779
|
+
y: c.y + d
|
|
1780
|
+
}, l = v(
|
|
1781
|
+
{ x: t.to.x - i, y: t.to.y },
|
|
1782
|
+
t.toVector,
|
|
1783
|
+
t.to
|
|
1784
|
+
), g = {
|
|
1785
|
+
x: l.x + n,
|
|
1786
|
+
y: l.y + d
|
|
1787
|
+
}, y = { x: (a.x + g.x) / 2, y: (a.y + g.y) / 2 }, p = {
|
|
1788
|
+
x: c.x + t.curvature * t.fromVector.x,
|
|
1789
|
+
y: c.y + t.curvature * t.fromVector.y
|
|
1790
|
+
}, f = {
|
|
1791
|
+
x: l.x - t.curvature * t.toVector.x,
|
|
1792
|
+
y: l.y - t.curvature * t.toVector.y
|
|
1793
|
+
}, A = {
|
|
1794
|
+
x: c.x + n,
|
|
1795
|
+
y: c.y + d
|
|
1796
|
+
}, E = {
|
|
1797
|
+
x: l.x + n,
|
|
1798
|
+
y: l.y + d
|
|
1799
|
+
};
|
|
1800
|
+
return [
|
|
1801
|
+
`M ${e.x} ${e.y}`,
|
|
1802
|
+
`L ${c.x} ${c.y}`,
|
|
1803
|
+
`C ${p.x} ${p.y} ${A.x} ${A.y} ${y.x} ${y.y}`,
|
|
1804
|
+
`C ${E.x} ${E.y} ${f.x} ${f.y} ${l.x} ${l.y}`,
|
|
1805
|
+
`L ${o.x} ${o.y}`
|
|
1806
|
+
].join(" ");
|
|
1807
|
+
}, V = (t, e) => {
|
|
1808
|
+
const o = [];
|
|
1809
|
+
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) {
|
|
1810
|
+
const i = t.length - 1;
|
|
1811
|
+
let s = 0, h = 0, n = 0;
|
|
1812
|
+
t.forEach((d, c) => {
|
|
1813
|
+
let a = 0, l = 0, g = 0;
|
|
1814
|
+
const y = c > 0, p = c < i, f = y && p;
|
|
1815
|
+
if (y && (a = -s, l = -h, g = n), p) {
|
|
1816
|
+
const L = t[c + 1];
|
|
1817
|
+
s = L.x - d.x, h = L.y - d.y, n = Math.sqrt(s * s + h * h);
|
|
1818
|
+
}
|
|
1819
|
+
const E = n !== 0 ? Math.min((f ? e : 0) / n, c < i - 1 ? 0.5 : 1) : 0, m = f ? { x: d.x + s * E, y: d.y + h * E } : d, b = g !== 0 ? Math.min((f ? e : 0) / g, c > 1 ? 0.5 : 1) : 0, D = f ? { x: d.x + a * b, y: d.y + l * b } : d;
|
|
1820
|
+
c > 0 && o.push(`L ${D.x} ${D.y}`), f && o.push(
|
|
1821
|
+
`C ${d.x} ${d.y} ${d.x} ${d.y} ${m.x} ${m.y}`
|
|
1822
|
+
);
|
|
1823
|
+
});
|
|
1824
|
+
}
|
|
1825
|
+
return o.join(" ");
|
|
1826
|
+
}, Xe = (t) => {
|
|
1827
|
+
const e = t.hasSourceArrow ? v(
|
|
1828
|
+
{ x: t.arrowLength, y: w.y },
|
|
1829
|
+
t.fromVector,
|
|
1830
|
+
w
|
|
1831
|
+
) : w, o = t.hasTargetArrow ? v(
|
|
1832
|
+
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
1833
|
+
t.toVector,
|
|
1834
|
+
t.to
|
|
1835
|
+
) : t.to, i = t.arrowLength + t.arrowOffset, s = i - t.roundness, h = v(
|
|
1836
|
+
{ x: s, y: w.y },
|
|
1837
|
+
t.fromVector,
|
|
1838
|
+
w
|
|
1839
|
+
), n = v(
|
|
1840
|
+
{ x: t.to.x - s, y: t.to.y },
|
|
1841
|
+
t.toVector,
|
|
1842
|
+
t.to
|
|
1843
|
+
), d = Math.max((h.x + n.x) / 2, i), c = t.to.y / 2, a = {
|
|
1844
|
+
x: t.flipX > 0 ? d : -i,
|
|
1845
|
+
y: h.y
|
|
1846
|
+
}, l = { x: a.x, y: c }, g = {
|
|
1847
|
+
x: t.flipX > 0 ? t.to.x - d : t.to.x + i,
|
|
1848
|
+
y: n.y
|
|
1849
|
+
}, y = { x: g.x, y: c };
|
|
1850
|
+
return V(
|
|
1851
|
+
[e, h, a, l, y, g, n, o],
|
|
1852
|
+
t.roundness
|
|
1853
|
+
);
|
|
1854
|
+
}, Y = (t) => {
|
|
1855
|
+
const e = t.hasSourceArrow ? v(
|
|
1856
|
+
{ x: t.arrowLength, y: w.y },
|
|
1857
|
+
t.fromVector,
|
|
1858
|
+
w
|
|
1859
|
+
) : w, o = t.hasTargetArrow ? v(
|
|
1860
|
+
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
1861
|
+
t.toVector,
|
|
1862
|
+
t.to
|
|
1863
|
+
) : t.to, i = t.arrowLength + t.arrowOffset, s = v(
|
|
1864
|
+
{ x: i, y: w.y },
|
|
1865
|
+
t.fromVector,
|
|
1866
|
+
w
|
|
1867
|
+
), h = Math.cos(t.detourDirection) * t.detourDistance, n = Math.sin(t.detourDirection) * t.detourDistance, d = h * t.flipX, c = n * t.flipY, a = { x: s.x + d, y: s.y + c }, l = v(
|
|
1868
|
+
{ x: t.to.x - i, y: t.to.y },
|
|
1869
|
+
t.toVector,
|
|
1870
|
+
t.to
|
|
1871
|
+
), g = { x: l.x + d, y: l.y + c };
|
|
1872
|
+
return V(
|
|
1873
|
+
[e, s, a, g, l, o],
|
|
1874
|
+
t.roundness
|
|
1875
|
+
);
|
|
1876
|
+
}, Ye = (t) => {
|
|
1877
|
+
const e = t.hasSourceArrow ? v(
|
|
1878
|
+
{ x: t.arrowLength, y: w.y },
|
|
1879
|
+
t.fromVector,
|
|
1880
|
+
w
|
|
1881
|
+
) : w, o = t.hasTargetArrow ? v(
|
|
1882
|
+
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
1883
|
+
t.toVector,
|
|
1884
|
+
t.to
|
|
1885
|
+
) : t.to, i = t.arrowLength + t.arrowOffset, s = v(
|
|
1886
|
+
{ x: i, y: w.y },
|
|
1887
|
+
t.fromVector,
|
|
1888
|
+
w
|
|
1889
|
+
), h = v(
|
|
1890
|
+
{ x: t.to.x - i, y: t.to.y },
|
|
1891
|
+
t.toVector,
|
|
1892
|
+
t.to
|
|
1893
|
+
);
|
|
1894
|
+
return V([e, s, h, o], t.roundness);
|
|
1895
|
+
}, He = (t) => {
|
|
1896
|
+
const e = t.hasSourceArrow ? v(
|
|
1897
|
+
{ x: t.arrowLength, y: w.y },
|
|
1898
|
+
t.fromVector,
|
|
1899
|
+
w
|
|
1900
|
+
) : w, o = t.hasTargetArrow ? v(
|
|
1901
|
+
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
1902
|
+
t.toVector,
|
|
1903
|
+
t.to
|
|
1904
|
+
) : t.to, i = t.arrowLength + t.arrowOffset, s = i - t.roundness, h = v(
|
|
1905
|
+
{ x: s, y: w.y },
|
|
1906
|
+
t.fromVector,
|
|
1907
|
+
w
|
|
1908
|
+
), n = v(
|
|
1909
|
+
{ x: t.to.x - s, y: t.to.y },
|
|
1910
|
+
t.toVector,
|
|
1911
|
+
t.to
|
|
1912
|
+
), d = Math.max((h.y + n.y) / 2, i), c = t.to.x / 2, a = {
|
|
1913
|
+
x: h.x,
|
|
1914
|
+
y: t.flipY > 0 ? d : -i
|
|
1915
|
+
}, l = { x: c, y: a.y }, g = {
|
|
1916
|
+
x: n.x,
|
|
1917
|
+
y: t.flipY > 0 ? t.to.y - d : t.to.y + i
|
|
1918
|
+
}, y = { x: c, y: g.y };
|
|
1919
|
+
return V(
|
|
1920
|
+
[e, h, a, l, y, g, n, o],
|
|
1921
|
+
t.roundness
|
|
1922
|
+
);
|
|
1923
|
+
}, H = (t) => {
|
|
1924
|
+
const e = t.arrowOffset, o = t.side, i = t.arrowLength + e, s = i + 2 * o, n = [
|
|
1925
|
+
{ x: t.arrowLength, y: w.y },
|
|
1926
|
+
{ x: i, y: w.y },
|
|
1927
|
+
{ x: i, y: t.side },
|
|
1928
|
+
{ x: s, y: t.side },
|
|
1929
|
+
{ x: s, y: -t.side },
|
|
1930
|
+
{ x: i, y: -t.side },
|
|
1931
|
+
{ x: i, y: w.y },
|
|
1932
|
+
{ x: t.arrowLength, y: w.y }
|
|
1933
|
+
].map(
|
|
1934
|
+
(c) => v(c, t.fromVector, w)
|
|
1935
|
+
), d = `M ${w.x} ${w.y} L ${n[0].x} ${n[0].y} `;
|
|
1936
|
+
return `${t.hasSourceArrow || t.hasTargetArrow ? "" : d}${V(n, t.roundness)}`;
|
|
1937
|
+
}, je = (t) => {
|
|
1938
|
+
const e = t.smallRadius, o = t.radius, i = Math.sqrt(e * e + o * o), s = e + o, h = t.arrowLength + i * (1 - o / s), n = e * o / s, c = [
|
|
1939
|
+
{ x: t.arrowLength, y: w.y },
|
|
1940
|
+
{ x: h, y: n },
|
|
1941
|
+
{ x: h, y: -n }
|
|
1942
|
+
].map(
|
|
1943
|
+
(g) => v(g, t.fromVector, w)
|
|
1944
|
+
), a = [
|
|
1945
|
+
`M ${c[0].x} ${c[0].y}`,
|
|
1946
|
+
`A ${e} ${e} 0 0 1 ${c[1].x} ${c[1].y}`,
|
|
1947
|
+
`A ${o} ${o} 0 1 0 ${c[2].x} ${c[2].y}`,
|
|
1948
|
+
`A ${e} ${e} 0 0 1 ${c[0].x} ${c[0].y}`
|
|
1949
|
+
].join(" "), l = `M 0 0 L ${c[0].x} ${c[0].y} `;
|
|
1950
|
+
return `${t.hasSourceArrow || t.hasTargetArrow ? "" : l}${a}`;
|
|
1951
|
+
}, u = Object.freeze({
|
|
1952
|
+
color: "#777777",
|
|
1953
|
+
width: 1,
|
|
1954
|
+
arrowLength: 15,
|
|
1955
|
+
arrowWidth: 4,
|
|
1956
|
+
arrowOffset: 15,
|
|
1957
|
+
hasSourceArrow: !1,
|
|
1958
|
+
hasTargetArrow: !1,
|
|
1959
|
+
cycleRadius: 30,
|
|
1960
|
+
cycleSquareSide: 30,
|
|
1961
|
+
roundness: 10,
|
|
1962
|
+
detourDistance: 100,
|
|
1963
|
+
detourDirection: -Math.PI / 2,
|
|
1964
|
+
detourDirectionVertical: 0,
|
|
1965
|
+
smallCycleRadius: 15,
|
|
1966
|
+
curvature: 90,
|
|
1967
|
+
interactiveWidth: 10
|
|
1968
|
+
}), ee = (t, e, o, i) => {
|
|
1969
|
+
const h = [
|
|
1970
|
+
w,
|
|
1971
|
+
{ x: o, y: i },
|
|
1972
|
+
{ x: o, y: -i }
|
|
1973
|
+
].map((a) => v(a, t, w)).map((a) => ({ x: a.x + e.x, y: a.y + e.y })), n = `M ${h[0].x} ${h[0].y}`, d = `L ${h[1].x} ${h[1].y}`, c = `L ${h[2].x} ${h[2].y}`;
|
|
1974
|
+
return `${n} ${d} ${c} Z`;
|
|
1975
|
+
}, te = (t) => {
|
|
1976
|
+
const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
1977
|
+
return e.setAttribute("fill", t), e;
|
|
1978
|
+
}, Ge = () => {
|
|
1979
|
+
const t = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
|
1980
|
+
return t.style.transformOrigin = "50% 50%", t;
|
|
1981
|
+
}, Ze = (t, e) => {
|
|
1982
|
+
const o = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
1983
|
+
return o.setAttribute("stroke", t), o.setAttribute("stroke-width", `${e}`), o.setAttribute("fill", "none"), o;
|
|
1984
|
+
}, Je = (t, e) => {
|
|
1985
|
+
const o = {
|
|
1986
|
+
x: t.x + t.width / 2,
|
|
1987
|
+
y: t.y + t.height / 2
|
|
1988
|
+
}, i = {
|
|
1989
|
+
x: e.x + e.width / 2,
|
|
1990
|
+
y: e.y + e.height / 2
|
|
1991
|
+
}, s = Math.min(o.x, i.x), h = Math.min(o.y, i.y), n = Math.abs(i.x - o.x), d = Math.abs(i.y - o.y), c = o.x <= i.x ? 1 : -1, a = o.y <= i.y ? 1 : -1;
|
|
2104
1992
|
return {
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
onEdgeCreationPrevented: ((a = t.events) == null ? void 0 : a.onEdgeCreationPrevented) ?? h,
|
|
2112
|
-
dragPortDirection: t.dragPortDirection ?? void 0
|
|
1993
|
+
x: s,
|
|
1994
|
+
y: h,
|
|
1995
|
+
width: n,
|
|
1996
|
+
height: d,
|
|
1997
|
+
flipX: c,
|
|
1998
|
+
flipY: a
|
|
2113
1999
|
};
|
|
2114
|
-
}
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
r
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
return o === void 0 ? void 0 : Array.from(o.values())[0];
|
|
2127
|
-
}
|
|
2128
|
-
removeByMulti(e) {
|
|
2129
|
-
const o = this.multiToSingleMap.get(e), r = this.singleToMultiMap.get(o);
|
|
2130
|
-
r.delete(e), r.size === 0 && this.singleToMultiMap.delete(o), this.multiToSingleMap.delete(e);
|
|
2131
|
-
}
|
|
2132
|
-
getByMulti(e) {
|
|
2133
|
-
return this.multiToSingleMap.get(e);
|
|
2134
|
-
}
|
|
2135
|
-
removeBySingle(e) {
|
|
2136
|
-
this.singleToMultiMap.get(e).forEach((r) => {
|
|
2137
|
-
this.multiToSingleMap.delete(r);
|
|
2138
|
-
}), this.singleToMultiMap.delete(e);
|
|
2139
|
-
}
|
|
2140
|
-
clear() {
|
|
2141
|
-
this.singleToMultiMap.clear(), this.multiToSingleMap.clear();
|
|
2142
|
-
}
|
|
2143
|
-
forEachSingle(e) {
|
|
2144
|
-
this.singleToMultiMap.forEach((o, r) => {
|
|
2145
|
-
e(r);
|
|
2146
|
-
});
|
|
2147
|
-
}
|
|
2148
|
-
hasSingle(e) {
|
|
2149
|
-
return this.singleToMultiMap.get(e) !== void 0;
|
|
2150
|
-
}
|
|
2151
|
-
hasMulti(e) {
|
|
2152
|
-
return this.multiToSingleMap.get(e) !== void 0;
|
|
2000
|
+
}, Ke = () => {
|
|
2001
|
+
const t = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
2002
|
+
return t.style.pointerEvents = "none", t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.overflow = "visible", t;
|
|
2003
|
+
}, oe = (t, e, o) => ({ x: e * Math.cos(t), y: o * Math.sin(t) });
|
|
2004
|
+
class U {
|
|
2005
|
+
constructor(e) {
|
|
2006
|
+
r(this, "svg", Ke());
|
|
2007
|
+
r(this, "group", Ge());
|
|
2008
|
+
r(this, "line");
|
|
2009
|
+
r(this, "sourceArrow", null);
|
|
2010
|
+
r(this, "targetArrow", null);
|
|
2011
|
+
this.params = e, this.svg.appendChild(this.group), this.line = Ze(e.color, e.width), this.group.appendChild(this.line), e.hasSourceArrow && (this.sourceArrow = te(e.color), this.group.appendChild(this.sourceArrow)), e.hasTargetArrow && (this.targetArrow = te(e.color), this.group.appendChild(this.targetArrow));
|
|
2153
2012
|
}
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
i(this, "overlayCanvas");
|
|
2159
|
-
i(this, "ports", new _e());
|
|
2160
|
-
i(this, "staticOverlayPortId", "static");
|
|
2161
|
-
i(this, "draggingOverlayPortId", "dragging");
|
|
2162
|
-
i(this, "staticPortId", null);
|
|
2163
|
-
i(this, "isDirect", !0);
|
|
2164
|
-
i(this, "onAfterPortMarked", (e) => {
|
|
2165
|
-
const o = this.canvas.graph.getPort(e);
|
|
2166
|
-
this.ports.hasSingle(o.element) || this.hookPortEvents(o.element), this.ports.addRecord(o.element, e);
|
|
2167
|
-
});
|
|
2168
|
-
i(this, "onBeforePortUnmarked", (e) => {
|
|
2169
|
-
const o = this.canvas.graph.getPort(e);
|
|
2170
|
-
this.ports.removeByMulti(e), this.ports.hasSingle(o.element) || this.unhookPortEvents(o.element);
|
|
2171
|
-
});
|
|
2172
|
-
i(this, "onPortMouseDown", (e) => {
|
|
2173
|
-
const o = e.currentTarget;
|
|
2174
|
-
this.config.mouseDownEventVerifier(e) && this.isPortConnectionAllowed(o) && (e.stopPropagation(), this.grabPort(o, { x: e.clientX, y: e.clientY }), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
|
|
2175
|
-
passive: !0
|
|
2176
|
-
}), this.window.addEventListener("mouseup", this.onWindowMouseUp, {
|
|
2177
|
-
passive: !0
|
|
2178
|
-
}));
|
|
2179
|
-
});
|
|
2180
|
-
i(this, "onWindowMouseMove", (e) => {
|
|
2181
|
-
if (!M(
|
|
2182
|
-
this.window,
|
|
2183
|
-
this.overlayLayer,
|
|
2184
|
-
e.clientX,
|
|
2185
|
-
e.clientY
|
|
2186
|
-
)) {
|
|
2187
|
-
this.stopMouseDrag();
|
|
2188
|
-
return;
|
|
2189
|
-
}
|
|
2190
|
-
this.moveDraggingNode({ x: e.clientX, y: e.clientY });
|
|
2191
|
-
});
|
|
2192
|
-
i(this, "onWindowMouseUp", (e) => {
|
|
2193
|
-
this.config.mouseUpEventVerifier(e) && (this.tryCreateConnection({ x: e.clientX, y: e.clientY }), this.stopMouseDrag());
|
|
2194
|
-
});
|
|
2195
|
-
i(this, "onPortTouchStart", (e) => {
|
|
2196
|
-
const o = e.currentTarget;
|
|
2197
|
-
if (!(e.touches.length === 1 && this.isPortConnectionAllowed(o)))
|
|
2198
|
-
return;
|
|
2199
|
-
e.stopPropagation();
|
|
2200
|
-
const s = e.touches[0];
|
|
2201
|
-
this.grabPort(o, { x: s.clientX, y: s.clientY }), this.window.addEventListener("touchmove", this.onWindowTouchMove, {
|
|
2202
|
-
passive: !0
|
|
2203
|
-
}), this.window.addEventListener("touchend", this.onWindowTouchFinish, {
|
|
2204
|
-
passive: !0
|
|
2205
|
-
}), this.window.addEventListener("touchcancel", this.onWindowTouchFinish, {
|
|
2206
|
-
passive: !0
|
|
2207
|
-
});
|
|
2208
|
-
});
|
|
2209
|
-
i(this, "onWindowTouchMove", (e) => {
|
|
2210
|
-
const o = e.touches[0];
|
|
2211
|
-
if (!M(
|
|
2212
|
-
this.window,
|
|
2213
|
-
this.overlayLayer,
|
|
2214
|
-
o.clientX,
|
|
2215
|
-
o.clientY
|
|
2216
|
-
)) {
|
|
2217
|
-
this.stopTouchDrag();
|
|
2218
|
-
return;
|
|
2219
|
-
}
|
|
2220
|
-
this.moveDraggingNode({ x: o.clientX, y: o.clientY });
|
|
2221
|
-
});
|
|
2222
|
-
i(this, "onWindowTouchFinish", (e) => {
|
|
2223
|
-
const o = e.changedTouches[0];
|
|
2224
|
-
this.tryCreateConnection({ x: o.clientX, y: o.clientY }), this.stopTouchDrag();
|
|
2225
|
-
});
|
|
2226
|
-
i(this, "onBeforeClear", () => {
|
|
2227
|
-
this.ports.forEachSingle((e) => {
|
|
2228
|
-
this.unhookPortEvents(e);
|
|
2229
|
-
}), this.ports.clear();
|
|
2230
|
-
});
|
|
2231
|
-
i(this, "onBeforeDestroy", () => {
|
|
2232
|
-
this.stopMouseDrag(), this.stopTouchDrag(), this.canvas.graph.onAfterPortMarked.unsubscribe(this.onAfterPortMarked), this.canvas.graph.onBeforePortUnmarked.unsubscribe(
|
|
2233
|
-
this.onBeforePortUnmarked
|
|
2234
|
-
), this.canvas.graph.onBeforeClear.unsubscribe(this.onBeforeClear), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy);
|
|
2235
|
-
});
|
|
2236
|
-
i(this, "onEdgeCreated", (e) => {
|
|
2237
|
-
this.config.onAfterEdgeCreated(e);
|
|
2238
|
-
});
|
|
2239
|
-
this.canvas = e, this.overlayLayer = o, this.viewportStore = r, this.window = s, this.config = Ze(n);
|
|
2240
|
-
const d = new ne(), c = new re(
|
|
2241
|
-
d,
|
|
2242
|
-
this.viewportStore,
|
|
2243
|
-
this.overlayLayer
|
|
2013
|
+
render(e) {
|
|
2014
|
+
const { x: o, y: i, width: s, height: h, flipX: n, flipY: d } = Je(
|
|
2015
|
+
e.from,
|
|
2016
|
+
e.to
|
|
2244
2017
|
);
|
|
2245
|
-
this.
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2018
|
+
this.svg.style.transform = `translate(${o}px, ${i}px)`, this.svg.style.width = `${Math.max(s, 1)}px`, this.svg.style.height = `${Math.max(h, 1)}px`, this.group.style.transform = `scale(${n}, ${d})`;
|
|
2019
|
+
const c = oe(
|
|
2020
|
+
e.from.direction,
|
|
2021
|
+
n,
|
|
2022
|
+
d
|
|
2023
|
+
), a = oe(
|
|
2024
|
+
e.to.direction,
|
|
2025
|
+
n,
|
|
2026
|
+
d
|
|
2027
|
+
), l = {
|
|
2028
|
+
x: s,
|
|
2029
|
+
y: h
|
|
2030
|
+
};
|
|
2031
|
+
let g = a, y = -this.params.arrowLength, p;
|
|
2032
|
+
e.from.portId === e.to.portId ? (p = this.params.createCyclePath, g = c, y = this.params.arrowLength) : e.from.nodeId === e.to.nodeId ? p = this.params.createDetourPath : p = this.params.createLinePath;
|
|
2033
|
+
const f = p(
|
|
2249
2034
|
c,
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
new H(
|
|
2255
|
-
e,
|
|
2256
|
-
o,
|
|
2257
|
-
r,
|
|
2258
|
-
s,
|
|
2259
|
-
h,
|
|
2260
|
-
n
|
|
2035
|
+
a,
|
|
2036
|
+
l,
|
|
2037
|
+
n,
|
|
2038
|
+
d
|
|
2261
2039
|
);
|
|
2040
|
+
if (this.line.setAttribute("d", f), this.sourceArrow) {
|
|
2041
|
+
const A = ee(
|
|
2042
|
+
c,
|
|
2043
|
+
w,
|
|
2044
|
+
this.params.arrowLength,
|
|
2045
|
+
this.params.arrowWidth
|
|
2046
|
+
);
|
|
2047
|
+
this.sourceArrow.setAttribute("d", A);
|
|
2048
|
+
}
|
|
2049
|
+
if (this.targetArrow) {
|
|
2050
|
+
const A = ee(
|
|
2051
|
+
g,
|
|
2052
|
+
l,
|
|
2053
|
+
y,
|
|
2054
|
+
this.params.arrowWidth
|
|
2055
|
+
);
|
|
2056
|
+
this.targetArrow.setAttribute("d", A);
|
|
2057
|
+
}
|
|
2262
2058
|
}
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
this
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
})
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
this
|
|
2059
|
+
}
|
|
2060
|
+
class Qe {
|
|
2061
|
+
constructor(e) {
|
|
2062
|
+
r(this, "svg");
|
|
2063
|
+
r(this, "group");
|
|
2064
|
+
r(this, "line");
|
|
2065
|
+
r(this, "sourceArrow");
|
|
2066
|
+
r(this, "targetArrow");
|
|
2067
|
+
r(this, "arrowLength");
|
|
2068
|
+
r(this, "arrowWidth");
|
|
2069
|
+
r(this, "curvature");
|
|
2070
|
+
r(this, "portCycleRadius");
|
|
2071
|
+
r(this, "portCycleSmallRadius");
|
|
2072
|
+
r(this, "detourDirection");
|
|
2073
|
+
r(this, "detourDistance");
|
|
2074
|
+
r(this, "hasSourceArrow");
|
|
2075
|
+
r(this, "hasTargetArrow");
|
|
2076
|
+
r(this, "lineShape");
|
|
2077
|
+
r(this, "createCyclePath", (e) => je({
|
|
2078
|
+
fromVector: e,
|
|
2079
|
+
radius: this.portCycleRadius,
|
|
2080
|
+
smallRadius: this.portCycleSmallRadius,
|
|
2081
|
+
arrowLength: this.arrowLength,
|
|
2082
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
2083
|
+
hasTargetArrow: this.hasTargetArrow
|
|
2084
|
+
}));
|
|
2085
|
+
r(this, "createDetourPath", (e, o, i, s, h) => Oe({
|
|
2086
|
+
to: i,
|
|
2087
|
+
fromVector: e,
|
|
2088
|
+
toVector: o,
|
|
2089
|
+
flipX: s,
|
|
2090
|
+
flipY: h,
|
|
2091
|
+
arrowLength: this.arrowLength,
|
|
2092
|
+
detourDirection: this.detourDirection,
|
|
2093
|
+
detourDistance: this.detourDistance,
|
|
2094
|
+
curvature: this.curvature,
|
|
2095
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
2096
|
+
hasTargetArrow: this.hasTargetArrow
|
|
2097
|
+
}));
|
|
2098
|
+
r(this, "createLinePath", (e, o, i) => ze({
|
|
2099
|
+
to: i,
|
|
2100
|
+
fromVector: e,
|
|
2101
|
+
toVector: o,
|
|
2102
|
+
arrowLength: this.arrowLength,
|
|
2103
|
+
curvature: this.curvature,
|
|
2104
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
2105
|
+
hasTargetArrow: this.hasTargetArrow
|
|
2106
|
+
}));
|
|
2107
|
+
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, this.lineShape = new U({
|
|
2108
|
+
color: (e == null ? void 0 : e.color) ?? u.color,
|
|
2109
|
+
width: (e == null ? void 0 : e.width) ?? u.width,
|
|
2110
|
+
arrowLength: this.arrowLength,
|
|
2111
|
+
arrowWidth: this.arrowWidth,
|
|
2112
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
2113
|
+
hasTargetArrow: this.hasTargetArrow,
|
|
2114
|
+
createCyclePath: this.createCyclePath,
|
|
2115
|
+
createDetourPath: this.createDetourPath,
|
|
2116
|
+
createLinePath: this.createLinePath
|
|
2117
|
+
}), this.svg = this.lineShape.svg, this.group = this.lineShape.group, this.line = this.lineShape.line, this.sourceArrow = this.lineShape.sourceArrow, this.targetArrow = this.lineShape.targetArrow;
|
|
2303
2118
|
}
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
this.overlayCanvas.addNode(r);
|
|
2307
|
-
const s = this.createAddNodeRequest(o);
|
|
2308
|
-
this.overlayCanvas.addNode(s), this.overlayCanvas.addEdge({
|
|
2309
|
-
from: e.overlayId,
|
|
2310
|
-
to: o.overlayId
|
|
2311
|
-
});
|
|
2119
|
+
render(e) {
|
|
2120
|
+
this.lineShape.render(e);
|
|
2312
2121
|
}
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2122
|
+
}
|
|
2123
|
+
class _e {
|
|
2124
|
+
constructor(e) {
|
|
2125
|
+
r(this, "svg");
|
|
2126
|
+
r(this, "group");
|
|
2127
|
+
r(this, "line");
|
|
2128
|
+
r(this, "sourceArrow");
|
|
2129
|
+
r(this, "targetArrow");
|
|
2130
|
+
r(this, "arrowLength");
|
|
2131
|
+
r(this, "arrowWidth");
|
|
2132
|
+
r(this, "arrowOffset");
|
|
2133
|
+
r(this, "roundness");
|
|
2134
|
+
r(this, "cycleSquareSide");
|
|
2135
|
+
r(this, "detourDirection");
|
|
2136
|
+
r(this, "detourDistance");
|
|
2137
|
+
r(this, "hasSourceArrow");
|
|
2138
|
+
r(this, "hasTargetArrow");
|
|
2139
|
+
r(this, "lineShape");
|
|
2140
|
+
r(this, "createCyclePath", (e) => H({
|
|
2141
|
+
fromVector: e,
|
|
2142
|
+
arrowLength: this.arrowLength,
|
|
2143
|
+
side: this.cycleSquareSide,
|
|
2144
|
+
arrowOffset: this.arrowOffset,
|
|
2145
|
+
roundness: this.roundness,
|
|
2146
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
2147
|
+
hasTargetArrow: this.hasTargetArrow
|
|
2148
|
+
}));
|
|
2149
|
+
r(this, "createDetourPath", (e, o, i, s, h) => Y({
|
|
2150
|
+
to: i,
|
|
2151
|
+
fromVector: e,
|
|
2152
|
+
toVector: o,
|
|
2153
|
+
flipX: s,
|
|
2154
|
+
flipY: h,
|
|
2155
|
+
arrowLength: this.arrowLength,
|
|
2156
|
+
arrowOffset: this.arrowOffset,
|
|
2157
|
+
roundness: this.roundness,
|
|
2158
|
+
detourDirection: this.detourDirection,
|
|
2159
|
+
detourDistance: this.detourDistance,
|
|
2160
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
2161
|
+
hasTargetArrow: this.hasTargetArrow
|
|
2162
|
+
}));
|
|
2163
|
+
r(this, "createLinePath", (e, o, i, s) => Xe({
|
|
2164
|
+
to: i,
|
|
2165
|
+
fromVector: e,
|
|
2166
|
+
toVector: o,
|
|
2167
|
+
flipX: s,
|
|
2168
|
+
arrowLength: this.arrowLength,
|
|
2169
|
+
arrowOffset: this.arrowOffset,
|
|
2170
|
+
roundness: this.roundness,
|
|
2171
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
2172
|
+
hasTargetArrow: this.hasTargetArrow
|
|
2173
|
+
}));
|
|
2174
|
+
this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? u.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? u.cycleSquareSide;
|
|
2175
|
+
const o = (e == null ? void 0 : e.roundness) ?? u.roundness;
|
|
2176
|
+
this.roundness = Math.min(
|
|
2177
|
+
o,
|
|
2178
|
+
this.arrowOffset,
|
|
2179
|
+
this.cycleSquareSide / 2
|
|
2180
|
+
), 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, this.lineShape = new U({
|
|
2181
|
+
color: (e == null ? void 0 : e.color) ?? u.color,
|
|
2182
|
+
width: (e == null ? void 0 : e.width) ?? u.width,
|
|
2183
|
+
arrowLength: this.arrowLength,
|
|
2184
|
+
arrowWidth: this.arrowWidth,
|
|
2185
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
2186
|
+
hasTargetArrow: this.hasTargetArrow,
|
|
2187
|
+
createCyclePath: this.createCyclePath,
|
|
2188
|
+
createDetourPath: this.createDetourPath,
|
|
2189
|
+
createLinePath: this.createLinePath
|
|
2190
|
+
}), this.svg = this.lineShape.svg, this.group = this.lineShape.group, this.line = this.lineShape.line, this.sourceArrow = this.lineShape.sourceArrow, this.targetArrow = this.lineShape.targetArrow;
|
|
2328
2191
|
}
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
if (o === null) {
|
|
2332
|
-
this.config.onEdgeCreationInterrupted(this.staticPortId, this.isDirect);
|
|
2333
|
-
return;
|
|
2334
|
-
}
|
|
2335
|
-
const r = this.isDirect ? this.staticPortId : o, s = this.isDirect ? o : this.staticPortId, h = { from: r, to: s }, n = this.config.connectionPreprocessor(h);
|
|
2336
|
-
n !== null ? (this.canvas.graph.onAfterEdgeAdded.subscribe(this.onEdgeCreated), this.canvas.addEdge(n), this.canvas.graph.onAfterEdgeAdded.unsubscribe(this.onEdgeCreated)) : this.config.onEdgeCreationPrevented(h);
|
|
2192
|
+
render(e) {
|
|
2193
|
+
this.lineShape.render(e);
|
|
2337
2194
|
}
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2195
|
+
}
|
|
2196
|
+
class qe {
|
|
2197
|
+
constructor(e) {
|
|
2198
|
+
r(this, "svg");
|
|
2199
|
+
r(this, "group");
|
|
2200
|
+
r(this, "line");
|
|
2201
|
+
r(this, "sourceArrow");
|
|
2202
|
+
r(this, "targetArrow");
|
|
2203
|
+
r(this, "arrowLength");
|
|
2204
|
+
r(this, "arrowWidth");
|
|
2205
|
+
r(this, "arrowOffset");
|
|
2206
|
+
r(this, "roundness");
|
|
2207
|
+
r(this, "cycleSquareSide");
|
|
2208
|
+
r(this, "detourDirection");
|
|
2209
|
+
r(this, "detourDistance");
|
|
2210
|
+
r(this, "hasSourceArrow");
|
|
2211
|
+
r(this, "hasTargetArrow");
|
|
2212
|
+
r(this, "lineShape");
|
|
2213
|
+
r(this, "createCyclePath", (e) => H({
|
|
2214
|
+
fromVector: e,
|
|
2215
|
+
arrowLength: this.arrowLength,
|
|
2216
|
+
side: this.cycleSquareSide,
|
|
2217
|
+
arrowOffset: this.arrowOffset,
|
|
2218
|
+
roundness: this.roundness,
|
|
2219
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
2220
|
+
hasTargetArrow: this.hasTargetArrow
|
|
2221
|
+
}));
|
|
2222
|
+
r(this, "createDetourPath", (e, o, i, s, h) => Y({
|
|
2223
|
+
to: i,
|
|
2224
|
+
fromVector: e,
|
|
2225
|
+
toVector: o,
|
|
2226
|
+
flipX: s,
|
|
2227
|
+
flipY: h,
|
|
2228
|
+
arrowLength: this.arrowLength,
|
|
2229
|
+
arrowOffset: this.arrowOffset,
|
|
2230
|
+
roundness: this.roundness,
|
|
2231
|
+
detourDirection: this.detourDirection,
|
|
2232
|
+
detourDistance: this.detourDistance,
|
|
2233
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
2234
|
+
hasTargetArrow: this.hasTargetArrow
|
|
2235
|
+
}));
|
|
2236
|
+
r(this, "createLinePath", (e, o, i) => Ye({
|
|
2237
|
+
to: i,
|
|
2238
|
+
fromVector: e,
|
|
2239
|
+
toVector: o,
|
|
2240
|
+
arrowLength: this.arrowLength,
|
|
2241
|
+
arrowOffset: this.arrowOffset,
|
|
2242
|
+
roundness: this.roundness,
|
|
2243
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
2244
|
+
hasTargetArrow: this.hasTargetArrow
|
|
2245
|
+
}));
|
|
2246
|
+
this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? u.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? u.cycleSquareSide;
|
|
2247
|
+
const o = (e == null ? void 0 : e.roundness) ?? u.roundness;
|
|
2248
|
+
this.roundness = Math.min(
|
|
2249
|
+
o,
|
|
2250
|
+
this.arrowOffset,
|
|
2251
|
+
this.cycleSquareSide / 2
|
|
2252
|
+
), 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, this.lineShape = new U({
|
|
2253
|
+
color: (e == null ? void 0 : e.color) ?? u.color,
|
|
2254
|
+
width: (e == null ? void 0 : e.width) ?? u.width,
|
|
2255
|
+
arrowLength: this.arrowLength,
|
|
2256
|
+
arrowWidth: this.arrowWidth,
|
|
2257
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
2258
|
+
hasTargetArrow: this.hasTargetArrow,
|
|
2259
|
+
createCyclePath: this.createCyclePath,
|
|
2260
|
+
createDetourPath: this.createDetourPath,
|
|
2261
|
+
createLinePath: this.createLinePath
|
|
2262
|
+
}), this.svg = this.lineShape.svg, this.group = this.lineShape.group, this.line = this.lineShape.line, this.sourceArrow = this.lineShape.sourceArrow, this.targetArrow = this.lineShape.targetArrow;
|
|
2347
2263
|
}
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
for (const r of o) {
|
|
2351
|
-
const s = this.findPortAtElement(r);
|
|
2352
|
-
if (s !== null)
|
|
2353
|
-
return s;
|
|
2354
|
-
}
|
|
2355
|
-
return null;
|
|
2264
|
+
render(e) {
|
|
2265
|
+
this.lineShape.render(e);
|
|
2356
2266
|
}
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2267
|
+
}
|
|
2268
|
+
class et {
|
|
2269
|
+
constructor(e) {
|
|
2270
|
+
r(this, "svg");
|
|
2271
|
+
r(this, "group");
|
|
2272
|
+
r(this, "line");
|
|
2273
|
+
r(this, "sourceArrow");
|
|
2274
|
+
r(this, "targetArrow");
|
|
2275
|
+
r(this, "arrowLength");
|
|
2276
|
+
r(this, "arrowWidth");
|
|
2277
|
+
r(this, "arrowOffset");
|
|
2278
|
+
r(this, "roundness");
|
|
2279
|
+
r(this, "cycleSquareSide");
|
|
2280
|
+
r(this, "detourDirection");
|
|
2281
|
+
r(this, "detourDistance");
|
|
2282
|
+
r(this, "hasSourceArrow");
|
|
2283
|
+
r(this, "hasTargetArrow");
|
|
2284
|
+
r(this, "lineShape");
|
|
2285
|
+
r(this, "createCyclePath", (e) => H({
|
|
2286
|
+
fromVector: e,
|
|
2287
|
+
arrowLength: this.arrowLength,
|
|
2288
|
+
side: this.cycleSquareSide,
|
|
2289
|
+
arrowOffset: this.arrowOffset,
|
|
2290
|
+
roundness: this.roundness,
|
|
2291
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
2292
|
+
hasTargetArrow: this.hasTargetArrow
|
|
2293
|
+
}));
|
|
2294
|
+
r(this, "createDetourPath", (e, o, i, s, h) => Y({
|
|
2295
|
+
to: i,
|
|
2296
|
+
fromVector: e,
|
|
2297
|
+
toVector: o,
|
|
2298
|
+
flipX: s,
|
|
2299
|
+
flipY: h,
|
|
2300
|
+
arrowLength: this.arrowLength,
|
|
2301
|
+
arrowOffset: this.arrowOffset,
|
|
2302
|
+
roundness: this.roundness,
|
|
2303
|
+
detourDirection: this.detourDirection,
|
|
2304
|
+
detourDistance: this.detourDistance,
|
|
2305
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
2306
|
+
hasTargetArrow: this.hasTargetArrow
|
|
2307
|
+
}));
|
|
2308
|
+
r(this, "createLinePath", (e, o, i, s, h) => He({
|
|
2309
|
+
to: i,
|
|
2310
|
+
fromVector: e,
|
|
2311
|
+
toVector: o,
|
|
2312
|
+
flipY: h,
|
|
2313
|
+
arrowLength: this.arrowLength,
|
|
2314
|
+
arrowOffset: this.arrowOffset,
|
|
2315
|
+
roundness: this.roundness,
|
|
2316
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
2317
|
+
hasTargetArrow: this.hasTargetArrow
|
|
2318
|
+
}));
|
|
2319
|
+
this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? u.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? u.cycleSquareSide;
|
|
2320
|
+
const o = (e == null ? void 0 : e.roundness) ?? u.roundness;
|
|
2321
|
+
this.roundness = Math.min(
|
|
2322
|
+
o,
|
|
2323
|
+
this.arrowOffset,
|
|
2324
|
+
this.cycleSquareSide / 2
|
|
2325
|
+
), 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, this.lineShape = new U({
|
|
2326
|
+
color: (e == null ? void 0 : e.color) ?? u.color,
|
|
2327
|
+
width: (e == null ? void 0 : e.width) ?? u.width,
|
|
2328
|
+
arrowLength: this.arrowLength,
|
|
2329
|
+
arrowWidth: this.arrowWidth,
|
|
2330
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
2331
|
+
hasTargetArrow: this.hasTargetArrow,
|
|
2332
|
+
createCyclePath: this.createCyclePath,
|
|
2333
|
+
createDetourPath: this.createDetourPath,
|
|
2334
|
+
createLinePath: this.createLinePath
|
|
2335
|
+
}), this.svg = this.lineShape.svg, this.group = this.lineShape.group, this.line = this.lineShape.line, this.sourceArrow = this.lineShape.sourceArrow, this.targetArrow = this.lineShape.targetArrow;
|
|
2362
2336
|
}
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
return this.config.connectionTypeResolver(o) !== null;
|
|
2337
|
+
render(e) {
|
|
2338
|
+
this.lineShape.render(e);
|
|
2366
2339
|
}
|
|
2367
2340
|
}
|
|
2368
|
-
const
|
|
2369
|
-
const t = document.
|
|
2370
|
-
return t.style.
|
|
2371
|
-
},
|
|
2372
|
-
const
|
|
2373
|
-
return
|
|
2341
|
+
const tt = () => {
|
|
2342
|
+
const t = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
|
2343
|
+
return t.style.pointerEvents = "auto", t.style.cursor = "pointer", t;
|
|
2344
|
+
}, ot = (t) => {
|
|
2345
|
+
const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
2346
|
+
return e.setAttribute("stroke", "transparent"), e.setAttribute("stroke-width", `${t}`), e.setAttribute("fill", "none"), e.setAttribute("stroke-linecap", "round"), e;
|
|
2347
|
+
}, re = (t) => {
|
|
2348
|
+
const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
2349
|
+
return e.setAttribute("stroke-linejoin", "round"), e.setAttribute("stroke-width", `${t}`), e.setAttribute("fill", "transparent"), e.setAttribute("stroke", "transparent"), e;
|
|
2374
2350
|
};
|
|
2375
|
-
class
|
|
2351
|
+
class rt extends Error {
|
|
2376
2352
|
constructor(e) {
|
|
2377
|
-
|
|
2378
|
-
i(this, "main", W());
|
|
2379
|
-
i(this, "overlay", W());
|
|
2380
|
-
i(this, "host", qe());
|
|
2381
|
-
this.element = e, this.element.appendChild(this.host), this.host.appendChild(this.background), this.host.appendChild(this.main), this.overlay.style.pointerEvents = "none", this.host.appendChild(this.overlay);
|
|
2353
|
+
super(e), this.name = "InteractiveEdgeError";
|
|
2382
2354
|
}
|
|
2383
|
-
|
|
2384
|
-
|
|
2355
|
+
}
|
|
2356
|
+
class ce {
|
|
2357
|
+
constructor(e, o) {
|
|
2358
|
+
r(this, "svg");
|
|
2359
|
+
r(this, "group");
|
|
2360
|
+
r(this, "line");
|
|
2361
|
+
r(this, "sourceArrow");
|
|
2362
|
+
r(this, "targetArrow");
|
|
2363
|
+
r(this, "handle", tt());
|
|
2364
|
+
r(this, "interactiveLine");
|
|
2365
|
+
r(this, "interactiveSourceArrow", null);
|
|
2366
|
+
r(this, "interactiveTargetArrow", null);
|
|
2367
|
+
if (this.structuredEdge = e, e instanceof ce)
|
|
2368
|
+
throw new rt(
|
|
2369
|
+
"interactive edge can be configured only once"
|
|
2370
|
+
);
|
|
2371
|
+
this.svg = this.structuredEdge.svg, this.group = this.structuredEdge.group, this.line = this.structuredEdge.line, this.sourceArrow = this.structuredEdge.sourceArrow, this.targetArrow = this.structuredEdge.targetArrow;
|
|
2372
|
+
const i = (o == null ? void 0 : o.width) ?? u.interactiveWidth;
|
|
2373
|
+
this.interactiveLine = ot(i), this.handle.appendChild(this.interactiveLine), this.sourceArrow && (this.interactiveSourceArrow = re(i), this.handle.appendChild(this.interactiveSourceArrow)), this.targetArrow && (this.interactiveTargetArrow = re(i), this.handle.appendChild(this.interactiveTargetArrow)), this.group.appendChild(this.handle);
|
|
2374
|
+
}
|
|
2375
|
+
render(e) {
|
|
2376
|
+
this.structuredEdge.render(e);
|
|
2377
|
+
const o = this.line.getAttribute("d");
|
|
2378
|
+
if (this.interactiveLine.setAttribute("d", o), this.sourceArrow) {
|
|
2379
|
+
const i = this.sourceArrow.getAttribute("d");
|
|
2380
|
+
this.interactiveSourceArrow.setAttribute("d", i);
|
|
2381
|
+
}
|
|
2382
|
+
if (this.targetArrow) {
|
|
2383
|
+
const i = this.targetArrow.getAttribute("d");
|
|
2384
|
+
this.interactiveTargetArrow.setAttribute("d", i);
|
|
2385
|
+
}
|
|
2385
2386
|
}
|
|
2386
2387
|
}
|
|
2387
|
-
|
|
2388
|
+
const it = (t) => {
|
|
2389
|
+
if (typeof t == "function")
|
|
2390
|
+
return t;
|
|
2391
|
+
switch (t == null ? void 0 : t.type) {
|
|
2392
|
+
case "straight":
|
|
2393
|
+
return () => new qe({
|
|
2394
|
+
color: t.color,
|
|
2395
|
+
width: t.width,
|
|
2396
|
+
arrowLength: t.arrowLength,
|
|
2397
|
+
arrowWidth: t.arrowWidth,
|
|
2398
|
+
arrowOffset: t.arrowOffset,
|
|
2399
|
+
hasSourceArrow: t.hasSourceArrow,
|
|
2400
|
+
hasTargetArrow: t.hasTargetArrow,
|
|
2401
|
+
cycleSquareSide: t.cycleSquareSide,
|
|
2402
|
+
roundness: t.roundness,
|
|
2403
|
+
detourDistance: t.detourDistance,
|
|
2404
|
+
detourDirection: t.detourDirection
|
|
2405
|
+
});
|
|
2406
|
+
case "horizontal":
|
|
2407
|
+
return () => new _e({
|
|
2408
|
+
color: t.color,
|
|
2409
|
+
width: t.width,
|
|
2410
|
+
arrowLength: t.arrowLength,
|
|
2411
|
+
arrowWidth: t.arrowWidth,
|
|
2412
|
+
arrowOffset: t.arrowOffset,
|
|
2413
|
+
hasSourceArrow: t.hasSourceArrow,
|
|
2414
|
+
hasTargetArrow: t.hasTargetArrow,
|
|
2415
|
+
cycleSquareSide: t.cycleSquareSide,
|
|
2416
|
+
roundness: t.roundness,
|
|
2417
|
+
detourDistance: t.detourDistance,
|
|
2418
|
+
detourDirection: t.detourDirection
|
|
2419
|
+
});
|
|
2420
|
+
case "vertical":
|
|
2421
|
+
return () => new et({
|
|
2422
|
+
color: t.color,
|
|
2423
|
+
width: t.width,
|
|
2424
|
+
arrowLength: t.arrowLength,
|
|
2425
|
+
arrowWidth: t.arrowWidth,
|
|
2426
|
+
arrowOffset: t.arrowOffset,
|
|
2427
|
+
hasSourceArrow: t.hasSourceArrow,
|
|
2428
|
+
hasTargetArrow: t.hasTargetArrow,
|
|
2429
|
+
cycleSquareSide: t.cycleSquareSide,
|
|
2430
|
+
roundness: t.roundness,
|
|
2431
|
+
detourDistance: t.detourDistance,
|
|
2432
|
+
detourDirection: t.detourDirection
|
|
2433
|
+
});
|
|
2434
|
+
default:
|
|
2435
|
+
return () => new Qe({
|
|
2436
|
+
color: t.color,
|
|
2437
|
+
width: t.width,
|
|
2438
|
+
arrowLength: t.arrowLength,
|
|
2439
|
+
arrowWidth: t.arrowWidth,
|
|
2440
|
+
hasSourceArrow: t.hasSourceArrow,
|
|
2441
|
+
hasTargetArrow: t.hasTargetArrow,
|
|
2442
|
+
cycleRadius: t.cycleRadius,
|
|
2443
|
+
smallCycleRadius: t.smallCycleRadius,
|
|
2444
|
+
curvature: t.curvature,
|
|
2445
|
+
detourDistance: t.detourDistance,
|
|
2446
|
+
detourDirection: t.detourDirection
|
|
2447
|
+
});
|
|
2448
|
+
}
|
|
2449
|
+
}, st = (t) => {
|
|
2450
|
+
var o, i, s, h, n;
|
|
2451
|
+
const e = ke(
|
|
2452
|
+
(o = t.nodes) == null ? void 0 : o.priority,
|
|
2453
|
+
(i = t.edges) == null ? void 0 : i.priority
|
|
2454
|
+
);
|
|
2455
|
+
return {
|
|
2456
|
+
nodes: {
|
|
2457
|
+
centerFn: ((s = t.nodes) == null ? void 0 : s.centerFn) ?? $e,
|
|
2458
|
+
priorityFn: e.nodesPriorityFn
|
|
2459
|
+
},
|
|
2460
|
+
ports: {
|
|
2461
|
+
direction: ((h = t.ports) == null ? void 0 : h.direction) ?? 0
|
|
2462
|
+
},
|
|
2463
|
+
edges: {
|
|
2464
|
+
shapeFactory: it(((n = t.edges) == null ? void 0 : n.shape) ?? {}),
|
|
2465
|
+
priorityFn: e.edgesPriorityFn
|
|
2466
|
+
}
|
|
2467
|
+
};
|
|
2468
|
+
};
|
|
2469
|
+
class ht {
|
|
2388
2470
|
constructor(e) {
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2471
|
+
r(this, "element", null);
|
|
2472
|
+
r(this, "canvasDefaults", {});
|
|
2473
|
+
r(this, "dragConfig", {});
|
|
2474
|
+
r(this, "transformConfig", {});
|
|
2475
|
+
r(this, "backgroundConfig", {});
|
|
2476
|
+
r(this, "connectablePortsConfig", {});
|
|
2477
|
+
r(this, "virtualScrollConfig");
|
|
2478
|
+
r(this, "hasDraggableNode", !1);
|
|
2479
|
+
r(this, "hasTransformableViewport", !1);
|
|
2480
|
+
r(this, "hasResizeReactiveNodes", !1);
|
|
2481
|
+
r(this, "hasBackground", !1);
|
|
2482
|
+
r(this, "hasUserConnectablePorts", !1);
|
|
2483
|
+
r(this, "boxRenderingTrigger");
|
|
2484
|
+
r(this, "window", window);
|
|
2403
2485
|
e !== void 0 && (this.element = e);
|
|
2404
2486
|
}
|
|
2405
2487
|
/**
|
|
@@ -2467,52 +2549,52 @@ class ot {
|
|
|
2467
2549
|
"unable to build canvas when no attach element specified"
|
|
2468
2550
|
);
|
|
2469
2551
|
let e = this.boxRenderingTrigger;
|
|
2470
|
-
this.virtualScrollConfig !== void 0 && e === void 0 && (e = new
|
|
2471
|
-
const o = new
|
|
2472
|
-
let h = new
|
|
2552
|
+
this.virtualScrollConfig !== void 0 && e === void 0 && (e = new se());
|
|
2553
|
+
const o = new de(), i = new Ae(), s = new We(this.element);
|
|
2554
|
+
let h = new ie(
|
|
2473
2555
|
o,
|
|
2474
|
-
|
|
2556
|
+
i,
|
|
2475
2557
|
s.main
|
|
2476
2558
|
);
|
|
2477
|
-
e !== void 0 && (h = new
|
|
2478
|
-
const n = new
|
|
2559
|
+
e !== void 0 && (h = new ve(h, o, e));
|
|
2560
|
+
const n = st(this.canvasDefaults), d = new ne(
|
|
2479
2561
|
this.element,
|
|
2480
2562
|
o,
|
|
2481
|
-
|
|
2563
|
+
i,
|
|
2482
2564
|
h,
|
|
2483
|
-
|
|
2484
|
-
),
|
|
2485
|
-
s.destroy(),
|
|
2565
|
+
n
|
|
2566
|
+
), c = () => {
|
|
2567
|
+
s.destroy(), d.onBeforeDestroy.unsubscribe(c);
|
|
2486
2568
|
};
|
|
2487
|
-
return
|
|
2488
|
-
|
|
2569
|
+
return d.onBeforeDestroy.subscribe(c), this.hasBackground && O.configure(
|
|
2570
|
+
d,
|
|
2489
2571
|
this.backgroundConfig,
|
|
2490
2572
|
s.background
|
|
2491
|
-
), this.hasResizeReactiveNodes &&
|
|
2492
|
-
|
|
2573
|
+
), this.hasResizeReactiveNodes && F.configure(d), this.hasDraggableNode && k.configure(
|
|
2574
|
+
d,
|
|
2493
2575
|
s.main,
|
|
2494
2576
|
this.window,
|
|
2495
2577
|
this.dragConfig
|
|
2496
|
-
), this.hasUserConnectablePorts &&
|
|
2497
|
-
|
|
2578
|
+
), this.hasUserConnectablePorts && X.configure(
|
|
2579
|
+
d,
|
|
2498
2580
|
s.overlay,
|
|
2499
|
-
|
|
2581
|
+
i,
|
|
2500
2582
|
this.window,
|
|
2501
|
-
this.canvasDefaults,
|
|
2502
|
-
this.connectablePortsConfig
|
|
2503
|
-
), this.virtualScrollConfig !== void 0 ? X.configure(
|
|
2504
2583
|
n,
|
|
2584
|
+
this.connectablePortsConfig
|
|
2585
|
+
), this.virtualScrollConfig !== void 0 ? z.configure(
|
|
2586
|
+
d,
|
|
2505
2587
|
s.main,
|
|
2506
2588
|
this.window,
|
|
2507
2589
|
this.transformConfig,
|
|
2508
2590
|
e,
|
|
2509
2591
|
this.virtualScrollConfig
|
|
2510
|
-
) : this.hasTransformableViewport &&
|
|
2511
|
-
|
|
2592
|
+
) : this.hasTransformableViewport && I.configure(
|
|
2593
|
+
d,
|
|
2512
2594
|
s.main,
|
|
2513
2595
|
this.window,
|
|
2514
2596
|
this.transformConfig
|
|
2515
|
-
), this.reset(),
|
|
2597
|
+
), this.reset(), d;
|
|
2516
2598
|
}
|
|
2517
2599
|
/**
|
|
2518
2600
|
* @deprecated
|
|
@@ -2523,11 +2605,14 @@ class ot {
|
|
|
2523
2605
|
}
|
|
2524
2606
|
}
|
|
2525
2607
|
export {
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2608
|
+
Qe as BezierEdgeShape,
|
|
2609
|
+
ht as CanvasBuilder,
|
|
2610
|
+
se as EventSubject,
|
|
2611
|
+
_e as HorizontalEdgeShape,
|
|
2530
2612
|
S as HtmlGraphError,
|
|
2531
|
-
|
|
2532
|
-
|
|
2613
|
+
rt as InteractiveEdgeError,
|
|
2614
|
+
ce as InteractiveEdgeShape,
|
|
2615
|
+
U as LineEdgeShape,
|
|
2616
|
+
qe as StraightEdgeShape,
|
|
2617
|
+
et as VerticalEdgeShape
|
|
2533
2618
|
};
|