@html-graph/html-graph 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/html-graph.d.ts +72 -40
- package/dist/html-graph.js +382 -402
- package/dist/html-graph.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/html-graph.js
CHANGED
|
@@ -1,22 +1,47 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var i = (t, e, o) =>
|
|
4
|
-
class
|
|
1
|
+
var oe = Object.defineProperty;
|
|
2
|
+
var re = (t, e, o) => e in t ? oe(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o;
|
|
3
|
+
var i = (t, e, o) => re(t, typeof e != "symbol" ? e + "" : e, o);
|
|
4
|
+
class ie {
|
|
5
5
|
constructor(e) {
|
|
6
6
|
i(this, "onAfterNodeAdded");
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated
|
|
9
|
+
* use onAfterNodeUpdated instead
|
|
10
|
+
*/
|
|
7
11
|
i(this, "onAfterNodeCoordinatesUpdated");
|
|
12
|
+
i(this, "onAfterNodeUpdated");
|
|
8
13
|
i(this, "onAfterNodePriorityUpdated");
|
|
9
14
|
i(this, "onBeforeNodeRemoved");
|
|
15
|
+
i(this, "onAfterPortMarked");
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated
|
|
18
|
+
* use onAfterPortMarked instead
|
|
19
|
+
*/
|
|
10
20
|
i(this, "onAfterPortAdded");
|
|
21
|
+
i(this, "onAfterPortUpdated");
|
|
22
|
+
/**
|
|
23
|
+
* @deprecated
|
|
24
|
+
* use onAfterPortUpdated instead
|
|
25
|
+
*/
|
|
11
26
|
i(this, "onAfterPortDirectionUpdated");
|
|
27
|
+
i(this, "onBeforePortUnmarked");
|
|
28
|
+
/**
|
|
29
|
+
* @deprecated
|
|
30
|
+
* use onBeforePortUnmarked instead
|
|
31
|
+
*/
|
|
12
32
|
i(this, "onBeforePortRemoved");
|
|
13
33
|
i(this, "onAfterEdgeAdded");
|
|
14
34
|
i(this, "onAfterEdgeShapeUpdated");
|
|
35
|
+
i(this, "onAfterEdgeUpdated");
|
|
36
|
+
/**
|
|
37
|
+
* @deprecated
|
|
38
|
+
* use onAfterEdgeUpdated instead
|
|
39
|
+
*/
|
|
15
40
|
i(this, "onAfterEdgeAdjacentPortsUpdated");
|
|
16
41
|
i(this, "onAfterEdgePriorityUpdated");
|
|
17
42
|
i(this, "onBeforeEdgeRemoved");
|
|
18
43
|
i(this, "onBeforeClear");
|
|
19
|
-
this.graphStore = e, this.onAfterNodeAdded = this.graphStore.onAfterNodeAdded, this.
|
|
44
|
+
this.graphStore = e, this.onAfterNodeAdded = this.graphStore.onAfterNodeAdded, this.onAfterNodeUpdated = this.graphStore.onAfterNodeUpdated, this.onAfterNodeCoordinatesUpdated = this.onAfterNodeUpdated, this.onAfterNodePriorityUpdated = this.graphStore.onAfterNodePriorityUpdated, this.onBeforeNodeRemoved = this.graphStore.onBeforeNodeRemoved, this.onAfterPortMarked = this.graphStore.onAfterPortAdded, this.onAfterPortAdded = this.onAfterPortMarked, this.onAfterPortUpdated = this.graphStore.onAfterPortUpdated, this.onAfterPortDirectionUpdated = this.onAfterPortUpdated, this.onBeforePortUnmarked = this.graphStore.onBeforePortRemoved, this.onBeforePortRemoved = this.onBeforePortUnmarked, this.onAfterEdgeAdded = this.graphStore.onAfterEdgeAdded, this.onAfterEdgeShapeUpdated = this.graphStore.onAfterEdgeShapeUpdated, this.onAfterEdgeUpdated = this.graphStore.onAfterEdgeUpdated, this.onAfterEdgeAdjacentPortsUpdated = this.onAfterEdgeUpdated, this.onAfterEdgePriorityUpdated = this.graphStore.onAfterEdgePriorityUpdated, this.onBeforeEdgeRemoved = this.graphStore.onBeforeEdgeRemoved, this.onBeforeClear = this.graphStore.onBeforeClear;
|
|
20
45
|
}
|
|
21
46
|
getNode(e) {
|
|
22
47
|
const o = this.graphStore.getNode(e);
|
|
@@ -85,9 +110,11 @@ class re {
|
|
|
85
110
|
return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeAdjacentEdgeIds(e);
|
|
86
111
|
}
|
|
87
112
|
}
|
|
88
|
-
class
|
|
113
|
+
class se {
|
|
89
114
|
constructor(e) {
|
|
90
|
-
this
|
|
115
|
+
i(this, "onBeforeUpdated");
|
|
116
|
+
i(this, "onAfterUpdated");
|
|
117
|
+
this.transformer = e, this.onBeforeUpdated = this.transformer.onBeforeUpdated, this.onAfterUpdated = this.transformer.onAfterUpdated;
|
|
91
118
|
}
|
|
92
119
|
getViewportMatrix() {
|
|
93
120
|
return { ...this.transformer.getViewportMatrix() };
|
|
@@ -96,11 +123,61 @@ class ie {
|
|
|
96
123
|
return { ...this.transformer.getContentMatrix() };
|
|
97
124
|
}
|
|
98
125
|
}
|
|
99
|
-
class
|
|
126
|
+
class ne {
|
|
100
127
|
constructor(e, o, r) {
|
|
101
128
|
i(this, "viewport");
|
|
102
129
|
i(this, "graph");
|
|
103
|
-
this
|
|
130
|
+
i(this, "onAfterNodeAdded", (e) => {
|
|
131
|
+
this.htmlView.attachNode(e);
|
|
132
|
+
});
|
|
133
|
+
i(this, "onAfterNodeUpdated", (e) => {
|
|
134
|
+
this.htmlView.updateNodePosition(e), this.graphStore.getNodeAdjacentEdgeIds(e).forEach((r) => {
|
|
135
|
+
this.htmlView.renderEdge(r);
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
i(this, "onAfterNodePriorityUpdated", (e) => {
|
|
139
|
+
this.htmlView.updateNodePriority(e);
|
|
140
|
+
});
|
|
141
|
+
i(this, "onBeforeNodeRemoved", (e) => {
|
|
142
|
+
this.graphStore.getNodePortIds(e).forEach((o) => {
|
|
143
|
+
this.unmarkPort(o);
|
|
144
|
+
}), this.htmlView.detachNode(e);
|
|
145
|
+
});
|
|
146
|
+
i(this, "onAfterPortUpdated", (e) => {
|
|
147
|
+
this.graphStore.getPortAdjacentEdgeIds(e).forEach((r) => {
|
|
148
|
+
this.htmlView.renderEdge(r);
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
i(this, "onBeforePortUnmarked", (e) => {
|
|
152
|
+
this.graphStore.getPortAdjacentEdgeIds(e).forEach((o) => {
|
|
153
|
+
this.removeEdge(o);
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
i(this, "onAfterEdgeAdded", (e) => {
|
|
157
|
+
this.htmlView.attachEdge(e);
|
|
158
|
+
});
|
|
159
|
+
i(this, "onAfterEdgeShapeUpdated", (e) => {
|
|
160
|
+
this.htmlView.updateEdgeShape(e);
|
|
161
|
+
});
|
|
162
|
+
i(this, "onAfterEdgeUpdated", (e) => {
|
|
163
|
+
this.htmlView.renderEdge(e);
|
|
164
|
+
});
|
|
165
|
+
i(this, "onAfterEdgePriorityUpdated", (e) => {
|
|
166
|
+
this.htmlView.updateEdgePriority(e);
|
|
167
|
+
});
|
|
168
|
+
i(this, "onBeforeEdgeRemoved", (e) => {
|
|
169
|
+
this.htmlView.detachEdge(e);
|
|
170
|
+
});
|
|
171
|
+
i(this, "onBeforeClear", () => {
|
|
172
|
+
this.htmlView.clear();
|
|
173
|
+
});
|
|
174
|
+
this.graphStore = e, this.viewportStore = o, this.htmlView = r, this.graphStore.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graphStore.onAfterNodeUpdated.subscribe(this.onAfterNodeUpdated), this.graphStore.onAfterNodePriorityUpdated.subscribe(
|
|
175
|
+
this.onAfterNodePriorityUpdated
|
|
176
|
+
), this.graphStore.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.graphStore.onAfterPortUpdated.subscribe(this.onAfterPortUpdated), this.graphStore.onBeforePortRemoved.subscribe(this.onBeforePortUnmarked), this.graphStore.onAfterEdgeAdded.subscribe(this.onAfterEdgeAdded), this.graphStore.onAfterEdgeShapeUpdated.subscribe(
|
|
177
|
+
this.onAfterEdgeShapeUpdated
|
|
178
|
+
), this.graphStore.onAfterEdgeUpdated.subscribe(this.onAfterEdgeUpdated), this.graphStore.onAfterEdgePriorityUpdated.subscribe(
|
|
179
|
+
this.onAfterEdgePriorityUpdated
|
|
180
|
+
), this.graphStore.onBeforeEdgeRemoved.subscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.subscribe(this.onBeforeClear), this.graph = new ie(this.graphStore), this.viewport = new se(this.viewportStore);
|
|
104
181
|
}
|
|
105
182
|
attach(e) {
|
|
106
183
|
this.htmlView.attach(e);
|
|
@@ -109,46 +186,31 @@ class se {
|
|
|
109
186
|
this.htmlView.detach();
|
|
110
187
|
}
|
|
111
188
|
addNode(e) {
|
|
112
|
-
this.graphStore.addNode(e)
|
|
189
|
+
this.graphStore.addNode(e);
|
|
113
190
|
}
|
|
114
191
|
updateNode(e, o) {
|
|
115
|
-
this.graphStore.
|
|
116
|
-
x: o.x,
|
|
117
|
-
y: o.y,
|
|
118
|
-
centerFn: o.centerFn
|
|
119
|
-
}), this.htmlView.updateNodeCoordinates(e), o.priority !== void 0 && (this.graphStore.updateNodePriority(e, o.priority), this.htmlView.updateNodePriority(e)), this.graphStore.getNodeAdjacentEdgeIds(e).forEach((n) => {
|
|
120
|
-
this.htmlView.renderEdge(n);
|
|
121
|
-
});
|
|
192
|
+
this.graphStore.updateNode(e, o);
|
|
122
193
|
}
|
|
123
194
|
removeNode(e) {
|
|
124
|
-
this.graphStore.
|
|
125
|
-
this.unmarkPort(o);
|
|
126
|
-
}), this.graphStore.removeNode(e), this.htmlView.detachNode(e);
|
|
195
|
+
this.graphStore.removeNode(e);
|
|
127
196
|
}
|
|
128
197
|
markPort(e) {
|
|
129
198
|
this.graphStore.addPort(e);
|
|
130
199
|
}
|
|
131
200
|
updatePort(e, o) {
|
|
132
|
-
|
|
133
|
-
this.htmlView.renderEdge(n);
|
|
134
|
-
});
|
|
201
|
+
this.graphStore.updatePort(e, o);
|
|
135
202
|
}
|
|
136
203
|
unmarkPort(e) {
|
|
137
|
-
this.graphStore.
|
|
138
|
-
this.removeEdge(o);
|
|
139
|
-
}), this.graphStore.removePort(e);
|
|
204
|
+
this.graphStore.removePort(e);
|
|
140
205
|
}
|
|
141
206
|
addEdge(e) {
|
|
142
|
-
this.graphStore.addEdge(e)
|
|
207
|
+
this.graphStore.addEdge(e);
|
|
143
208
|
}
|
|
144
209
|
updateEdge(e, o) {
|
|
145
|
-
|
|
146
|
-
from: o.from,
|
|
147
|
-
to: o.to
|
|
148
|
-
}), o.shape !== void 0 && (this.graphStore.updateEdgeShape(e, o.shape), this.htmlView.updateEdgeShape(e)), this.htmlView.renderEdge(e), o.priority !== void 0 && (this.graphStore.updateEdgePriority(e, o.priority), this.htmlView.updateEdgePriority(e));
|
|
210
|
+
this.graphStore.updateEdge(e, o);
|
|
149
211
|
}
|
|
150
212
|
removeEdge(e) {
|
|
151
|
-
this.graphStore.removeEdge(e)
|
|
213
|
+
this.graphStore.removeEdge(e);
|
|
152
214
|
}
|
|
153
215
|
patchViewportMatrix(e) {
|
|
154
216
|
this.viewportStore.patchViewportMatrix(e);
|
|
@@ -157,33 +219,39 @@ class se {
|
|
|
157
219
|
this.viewportStore.patchContentMatrix(e);
|
|
158
220
|
}
|
|
159
221
|
clear() {
|
|
160
|
-
this.
|
|
222
|
+
this.graphStore.clear();
|
|
161
223
|
}
|
|
162
224
|
destroy() {
|
|
163
|
-
this.
|
|
225
|
+
this.graphStore.onAfterNodeAdded.unsubscribe(this.onAfterNodeAdded), this.graphStore.onAfterNodeUpdated.unsubscribe(this.onAfterNodeUpdated), this.graphStore.onAfterNodePriorityUpdated.unsubscribe(
|
|
226
|
+
this.onAfterNodePriorityUpdated
|
|
227
|
+
), this.graphStore.onBeforeNodeRemoved.unsubscribe(this.onBeforeNodeRemoved), this.graphStore.onAfterPortUpdated.unsubscribe(this.onAfterPortUpdated), this.graphStore.onBeforePortRemoved.unsubscribe(this.onBeforePortUnmarked), this.graphStore.onAfterEdgeAdded.unsubscribe(this.onAfterEdgeAdded), this.graphStore.onAfterEdgeShapeUpdated.unsubscribe(
|
|
228
|
+
this.onAfterEdgeShapeUpdated
|
|
229
|
+
), this.graphStore.onAfterEdgeUpdated.unsubscribe(this.onAfterEdgeUpdated), this.graphStore.onAfterEdgePriorityUpdated.unsubscribe(
|
|
230
|
+
this.onAfterEdgePriorityUpdated
|
|
231
|
+
), this.graphStore.onBeforeEdgeRemoved.unsubscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.unsubscribe(this.onBeforeClear), this.clear(), this.htmlView.destroy();
|
|
164
232
|
}
|
|
165
233
|
}
|
|
166
|
-
const
|
|
234
|
+
const U = (t, e, o) => {
|
|
167
235
|
const { x: r, y: n, width: h, height: s } = t.getBoundingClientRect();
|
|
168
236
|
return e >= r && e <= r + h && o >= n && o <= n + s;
|
|
169
|
-
},
|
|
237
|
+
}, $ = (t, e, o) => e >= 0 && e <= t.innerWidth && o >= 0 && o <= t.innerHeight, R = (t, e) => {
|
|
170
238
|
e !== null ? t.style.cursor = e : t.style.removeProperty("cursor");
|
|
171
|
-
},
|
|
172
|
-
var g, f, x,
|
|
239
|
+
}, he = (t) => {
|
|
240
|
+
var g, f, x, v, S, p;
|
|
173
241
|
const e = ((g = t == null ? void 0 : t.events) == null ? void 0 : g.onNodeDrag) ?? (() => {
|
|
174
242
|
}), o = ((f = t == null ? void 0 : t.events) == null ? void 0 : f.onBeforeNodeDrag) ?? (() => !0), r = ((x = t == null ? void 0 : t.events) == null ? void 0 : x.onNodeDragFinished) ?? (() => {
|
|
175
|
-
}), n = (t == null ? void 0 : t.moveOnTop) === !1, h = (
|
|
243
|
+
}), n = (t == null ? void 0 : t.moveOnTop) === !1, h = (v = t == null ? void 0 : t.mouse) == null ? void 0 : v.dragCursor, s = h !== void 0 ? h : "grab", d = (S = t == null ? void 0 : t.mouse) == null ? void 0 : S.mouseDownEventVerifier, c = d !== void 0 ? d : (N) => N.button === 0, a = (p = t == null ? void 0 : t.mouse) == null ? void 0 : p.mouseUpEventVerifier;
|
|
176
244
|
return {
|
|
177
245
|
freezePriority: n,
|
|
178
246
|
dragCursor: s,
|
|
179
247
|
mouseDownEventVerifier: c,
|
|
180
|
-
mouseUpEventVerifier: a !== void 0 ? a : (
|
|
248
|
+
mouseUpEventVerifier: a !== void 0 ? a : (N) => N.button === 0,
|
|
181
249
|
onNodeDrag: e,
|
|
182
250
|
onBeforeNodeDrag: o,
|
|
183
251
|
onNodeDragFinished: r
|
|
184
252
|
};
|
|
185
253
|
};
|
|
186
|
-
class
|
|
254
|
+
class de {
|
|
187
255
|
constructor(e, o) {
|
|
188
256
|
i(this, "graph");
|
|
189
257
|
i(this, "viewport");
|
|
@@ -192,7 +260,7 @@ class he {
|
|
|
192
260
|
i(this, "grabbedNodeId", null);
|
|
193
261
|
i(this, "element", null);
|
|
194
262
|
i(this, "onWindowMouseMove", (e) => {
|
|
195
|
-
if (this.element !== null && (
|
|
263
|
+
if (this.element !== null && (!U(this.element, e.clientX, e.clientY) || !$(this.window, e.clientX, e.clientY))) {
|
|
196
264
|
this.cancelMouseDrag();
|
|
197
265
|
return;
|
|
198
266
|
}
|
|
@@ -205,7 +273,7 @@ class he {
|
|
|
205
273
|
if (e.touches.length !== 1)
|
|
206
274
|
return;
|
|
207
275
|
const o = e.touches[0];
|
|
208
|
-
if (this.element !== null && (
|
|
276
|
+
if (this.element !== null && (!U(this.element, o.clientX, o.clientY) || !$(this.window, o.clientX, o.clientY))) {
|
|
209
277
|
this.cancelTouchDrag();
|
|
210
278
|
return;
|
|
211
279
|
}
|
|
@@ -223,7 +291,7 @@ class he {
|
|
|
223
291
|
i(this, "previousTouchCoords", null);
|
|
224
292
|
i(this, "window", window);
|
|
225
293
|
i(this, "options");
|
|
226
|
-
this.canvas = e, this.viewport = this.canvas.viewport, this.graph = this.canvas.graph, this.options =
|
|
294
|
+
this.canvas = e, this.viewport = this.canvas.viewport, this.graph = this.canvas.graph, this.options = he(o ?? {});
|
|
227
295
|
}
|
|
228
296
|
attach(e) {
|
|
229
297
|
this.detach(), this.element = e, this.canvas.attach(this.element);
|
|
@@ -354,7 +422,7 @@ class he {
|
|
|
354
422
|
this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
|
|
355
423
|
}
|
|
356
424
|
}
|
|
357
|
-
const
|
|
425
|
+
const ce = (t) => {
|
|
358
426
|
const e = t.minX !== null ? t.minX : -1 / 0, o = t.maxX !== null ? t.maxX : 1 / 0, r = t.minY !== null ? t.minY : -1 / 0, n = t.maxY !== null ? t.maxY : 1 / 0;
|
|
359
427
|
return (h) => {
|
|
360
428
|
let s = h.nextTransform.x, d = h.nextTransform.y;
|
|
@@ -364,7 +432,7 @@ const de = (t) => {
|
|
|
364
432
|
const l = h.canvasHeight * h.prevTransform.scale, g = n - l;
|
|
365
433
|
return d > g && d > h.prevTransform.y && (d = Math.max(h.prevTransform.y, g)), { scale: h.nextTransform.scale, x: s, y: d };
|
|
366
434
|
};
|
|
367
|
-
},
|
|
435
|
+
}, ae = (t) => {
|
|
368
436
|
const e = t.maxContentScale, o = t.minContentScale, r = e !== null ? 1 / e : 0, n = o !== null ? 1 / o : 1 / 0;
|
|
369
437
|
return (h) => {
|
|
370
438
|
const s = h.prevTransform, d = h.nextTransform;
|
|
@@ -385,7 +453,7 @@ const de = (t) => {
|
|
|
385
453
|
y: l
|
|
386
454
|
};
|
|
387
455
|
};
|
|
388
|
-
},
|
|
456
|
+
}, le = (t) => (e) => t.reduce(
|
|
389
457
|
(o, r) => r({
|
|
390
458
|
prevTransform: e.prevTransform,
|
|
391
459
|
nextTransform: o,
|
|
@@ -393,40 +461,40 @@ const de = (t) => {
|
|
|
393
461
|
canvasHeight: e.canvasHeight
|
|
394
462
|
}),
|
|
395
463
|
e.nextTransform
|
|
396
|
-
),
|
|
464
|
+
), Q = (t) => {
|
|
397
465
|
if (typeof t == "function")
|
|
398
466
|
return t;
|
|
399
467
|
switch (t.type) {
|
|
400
468
|
case "scale-limit":
|
|
401
|
-
return
|
|
469
|
+
return ae({
|
|
402
470
|
minContentScale: t.minContentScale ?? 0,
|
|
403
471
|
maxContentScale: t.maxContentScale ?? 1 / 0
|
|
404
472
|
});
|
|
405
473
|
case "shift-limit":
|
|
406
|
-
return
|
|
474
|
+
return ce({
|
|
407
475
|
minX: t.minX ?? -1 / 0,
|
|
408
476
|
maxX: t.maxX ?? 1 / 0,
|
|
409
477
|
minY: t.minY ?? -1 / 0,
|
|
410
478
|
maxY: t.maxY ?? 1 / 0
|
|
411
479
|
});
|
|
412
480
|
}
|
|
413
|
-
},
|
|
414
|
-
var
|
|
415
|
-
const e = (
|
|
481
|
+
}, ge = (t) => {
|
|
482
|
+
var v, S, p, N, k, M, V, L, G, _, J, K;
|
|
483
|
+
const e = (v = t == null ? void 0 : t.scale) == null ? void 0 : v.mouseWheelSensitivity, o = e !== void 0 ? e : 1.2, r = t == null ? void 0 : t.transformPreprocessor;
|
|
416
484
|
let n;
|
|
417
|
-
r !== void 0 ? Array.isArray(r) ? n =
|
|
485
|
+
r !== void 0 ? Array.isArray(r) ? n = le(
|
|
418
486
|
r.map(
|
|
419
|
-
(
|
|
487
|
+
(b) => Q(b)
|
|
420
488
|
)
|
|
421
|
-
) : n =
|
|
489
|
+
) : n = Q(r) : n = (b) => b.nextTransform;
|
|
422
490
|
const h = ((S = t == null ? void 0 : t.shift) == null ? void 0 : S.cursor) !== void 0 ? t.shift.cursor : "grab", s = ((p = t == null ? void 0 : t.events) == null ? void 0 : p.onBeforeTransformChange) ?? (() => {
|
|
423
|
-
}), d = ((
|
|
424
|
-
}), c = (k = t == null ? void 0 : t.shift) == null ? void 0 : k.mouseDownEventVerifier, a = c !== void 0 ? c : (
|
|
491
|
+
}), d = ((N = t == null ? void 0 : t.events) == null ? void 0 : N.onTransformChange) ?? (() => {
|
|
492
|
+
}), c = (k = t == null ? void 0 : t.shift) == null ? void 0 : k.mouseDownEventVerifier, a = c !== void 0 ? c : (b) => b.button === 0, l = (M = t == null ? void 0 : t.shift) == null ? void 0 : M.mouseUpEventVerifier, g = l !== void 0 ? l : (b) => b.button === 0, f = (V = t == null ? void 0 : t.scale) == null ? void 0 : V.mouseWheelEventVerifier, x = f !== void 0 ? f : () => !0;
|
|
425
493
|
return {
|
|
426
494
|
wheelSensitivity: o,
|
|
427
|
-
onTransformStarted: ((
|
|
495
|
+
onTransformStarted: ((L = t == null ? void 0 : t.events) == null ? void 0 : L.onTransformStarted) ?? (() => {
|
|
428
496
|
}),
|
|
429
|
-
onTransformFinished: ((
|
|
497
|
+
onTransformFinished: ((G = t == null ? void 0 : t.events) == null ? void 0 : G.onTransformFinished) ?? (() => {
|
|
430
498
|
}),
|
|
431
499
|
onBeforeTransformChange: s,
|
|
432
500
|
onTransformChange: d,
|
|
@@ -435,13 +503,13 @@ const de = (t) => {
|
|
|
435
503
|
mouseDownEventVerifier: a,
|
|
436
504
|
mouseUpEventVerifier: g,
|
|
437
505
|
mouseWheelEventVerifier: x,
|
|
438
|
-
scaleWheelFinishTimeout: ((
|
|
439
|
-
onResizeTransformStarted: ((
|
|
506
|
+
scaleWheelFinishTimeout: ((_ = t == null ? void 0 : t.scale) == null ? void 0 : _.wheelFinishTimeout) ?? 500,
|
|
507
|
+
onResizeTransformStarted: ((J = t == null ? void 0 : t.events) == null ? void 0 : J.onResizeTransformStarted) ?? (() => {
|
|
440
508
|
}),
|
|
441
|
-
onResizeTransformFinished: ((
|
|
509
|
+
onResizeTransformFinished: ((K = t == null ? void 0 : t.events) == null ? void 0 : K.onResizeTransformFinished) ?? (() => {
|
|
442
510
|
})
|
|
443
511
|
};
|
|
444
|
-
},
|
|
512
|
+
}, C = (t) => {
|
|
445
513
|
const e = [], o = t.touches.length;
|
|
446
514
|
for (let d = 0; d < o; d++)
|
|
447
515
|
e.push([t.touches[d].clientX, t.touches[d].clientY]);
|
|
@@ -459,16 +527,16 @@ const de = (t) => {
|
|
|
459
527
|
touchesCnt: o,
|
|
460
528
|
touches: e
|
|
461
529
|
};
|
|
462
|
-
},
|
|
530
|
+
}, ue = (t, e, o) => ({
|
|
463
531
|
scale: t.scale,
|
|
464
532
|
x: t.x + t.scale * e,
|
|
465
533
|
y: t.y + t.scale * o
|
|
466
|
-
}),
|
|
534
|
+
}), we = (t, e, o, r) => ({
|
|
467
535
|
scale: t.scale * e,
|
|
468
536
|
x: t.scale * (1 - e) * o + t.x,
|
|
469
537
|
y: t.scale * (1 - e) * r + t.y
|
|
470
538
|
});
|
|
471
|
-
class
|
|
539
|
+
class ee {
|
|
472
540
|
constructor(e, o) {
|
|
473
541
|
i(this, "graph");
|
|
474
542
|
i(this, "viewport");
|
|
@@ -480,7 +548,7 @@ class q {
|
|
|
480
548
|
this.element === null || !this.options.mouseDownEventVerifier(e) || (R(this.element, this.options.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.options.onTransformStarted());
|
|
481
549
|
});
|
|
482
550
|
i(this, "onWindowMouseMove", (e) => {
|
|
483
|
-
if (this.element === null ||
|
|
551
|
+
if (this.element === null || !U(this.element, e.clientX, e.clientY) || !$(this.window, e.clientX, e.clientY)) {
|
|
484
552
|
this.stopMouseDrag();
|
|
485
553
|
return;
|
|
486
554
|
}
|
|
@@ -501,18 +569,18 @@ class q {
|
|
|
501
569
|
});
|
|
502
570
|
i(this, "onTouchStart", (e) => {
|
|
503
571
|
if (this.prevTouches !== null) {
|
|
504
|
-
this.prevTouches =
|
|
572
|
+
this.prevTouches = C(e);
|
|
505
573
|
return;
|
|
506
574
|
}
|
|
507
|
-
this.prevTouches =
|
|
575
|
+
this.prevTouches = C(e), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish), this.options.onTransformStarted();
|
|
508
576
|
});
|
|
509
577
|
i(this, "onWindowTouchMove", (e) => {
|
|
510
578
|
const o = this.element;
|
|
511
579
|
if (o === null)
|
|
512
580
|
return;
|
|
513
|
-
const r =
|
|
581
|
+
const r = C(e);
|
|
514
582
|
if (!r.touches.every(
|
|
515
|
-
(h) =>
|
|
583
|
+
(h) => U(o, h[0], h[1]) && $(this.window, h[0], h[1])
|
|
516
584
|
)) {
|
|
517
585
|
this.stopTouchDrag();
|
|
518
586
|
return;
|
|
@@ -528,7 +596,7 @@ class q {
|
|
|
528
596
|
this.prevTouches = r;
|
|
529
597
|
});
|
|
530
598
|
i(this, "onWindowTouchFinish", (e) => {
|
|
531
|
-
e.touches.length > 0 ? this.prevTouches =
|
|
599
|
+
e.touches.length > 0 ? this.prevTouches = C(e) : this.stopTouchDrag();
|
|
532
600
|
});
|
|
533
601
|
i(this, "observer", new ResizeObserver(() => {
|
|
534
602
|
const e = this.canvas.viewport.getViewportMatrix(), { width: o, height: r } = this.element.getBoundingClientRect(), n = this.options.transformPreprocessor({
|
|
@@ -540,7 +608,7 @@ class q {
|
|
|
540
608
|
this.options.onResizeTransformStarted(), this.canvas.patchViewportMatrix(n), this.options.onResizeTransformFinished();
|
|
541
609
|
}));
|
|
542
610
|
i(this, "options");
|
|
543
|
-
this.canvas = e, this.options =
|
|
611
|
+
this.canvas = e, this.options = ge(o), this.viewport = this.canvas.viewport, this.graph = this.canvas.graph;
|
|
544
612
|
}
|
|
545
613
|
attach(e) {
|
|
546
614
|
this.detach(), this.element = e, this.observer.observe(this.element), this.element.addEventListener("mousedown", this.onMouseDown), this.element.addEventListener("wheel", this.onWheelScroll), this.element.addEventListener("touchstart", this.onTouchStart), this.canvas.attach(this.element);
|
|
@@ -588,7 +656,7 @@ class q {
|
|
|
588
656
|
this.detach(), this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.canvas.destroy();
|
|
589
657
|
}
|
|
590
658
|
moveViewport(e, o, r) {
|
|
591
|
-
const n = this.viewport.getViewportMatrix(), h =
|
|
659
|
+
const n = this.viewport.getViewportMatrix(), h = ue(n, o, r), { width: s, height: d } = e.getBoundingClientRect(), c = this.options.transformPreprocessor({
|
|
592
660
|
prevTransform: n,
|
|
593
661
|
nextTransform: h,
|
|
594
662
|
canvasWidth: s,
|
|
@@ -597,7 +665,7 @@ class q {
|
|
|
597
665
|
this.performTransform(c);
|
|
598
666
|
}
|
|
599
667
|
scaleViewport(e, o, r, n) {
|
|
600
|
-
const h = this.canvas.viewport.getViewportMatrix(), s =
|
|
668
|
+
const h = this.canvas.viewport.getViewportMatrix(), s = we(h, o, r, n), { width: d, height: c } = e.getBoundingClientRect(), a = this.options.transformPreprocessor({
|
|
601
669
|
prevTransform: h,
|
|
602
670
|
nextTransform: s,
|
|
603
671
|
canvasWidth: d,
|
|
@@ -621,112 +689,7 @@ class q {
|
|
|
621
689
|
this.options.onBeforeTransformChange(), this.canvas.patchViewportMatrix(e), this.options.onTransformChange();
|
|
622
690
|
}
|
|
623
691
|
}
|
|
624
|
-
class we {
|
|
625
|
-
constructor() {
|
|
626
|
-
i(this, "keyMap", /* @__PURE__ */ new Map());
|
|
627
|
-
i(this, "valueMap", /* @__PURE__ */ new Map());
|
|
628
|
-
}
|
|
629
|
-
set(e, o) {
|
|
630
|
-
this.keyMap.set(e, o), this.valueMap.set(o, e);
|
|
631
|
-
}
|
|
632
|
-
hasKey(e) {
|
|
633
|
-
return this.keyMap.has(e);
|
|
634
|
-
}
|
|
635
|
-
hasValue(e) {
|
|
636
|
-
return this.valueMap.has(e);
|
|
637
|
-
}
|
|
638
|
-
getByKey(e) {
|
|
639
|
-
return this.keyMap.get(e);
|
|
640
|
-
}
|
|
641
|
-
getByValue(e) {
|
|
642
|
-
return this.valueMap.get(e);
|
|
643
|
-
}
|
|
644
|
-
deleteByKey(e) {
|
|
645
|
-
const o = this.keyMap.get(e);
|
|
646
|
-
o !== void 0 && this.valueMap.delete(o), this.keyMap.delete(e);
|
|
647
|
-
}
|
|
648
|
-
deleteByValue(e) {
|
|
649
|
-
const o = this.valueMap.get(e);
|
|
650
|
-
o !== void 0 && this.keyMap.delete(o), this.valueMap.delete(e);
|
|
651
|
-
}
|
|
652
|
-
forEach(e) {
|
|
653
|
-
this.keyMap.forEach((o, r) => {
|
|
654
|
-
e(o, r);
|
|
655
|
-
});
|
|
656
|
-
}
|
|
657
|
-
clear() {
|
|
658
|
-
this.keyMap.clear(), this.valueMap.clear();
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
692
|
class fe {
|
|
662
|
-
constructor(e) {
|
|
663
|
-
i(this, "viewport");
|
|
664
|
-
i(this, "graph");
|
|
665
|
-
i(this, "nodes", new we());
|
|
666
|
-
i(this, "nodesResizeObserver");
|
|
667
|
-
i(this, "window", window);
|
|
668
|
-
this.canvas = e, this.nodesResizeObserver = new this.window.ResizeObserver((o) => {
|
|
669
|
-
o.forEach((r) => {
|
|
670
|
-
const n = r.target;
|
|
671
|
-
this.handleNodeResize(n);
|
|
672
|
-
});
|
|
673
|
-
}), this.viewport = this.canvas.viewport, this.graph = this.canvas.graph;
|
|
674
|
-
}
|
|
675
|
-
attach(e) {
|
|
676
|
-
this.canvas.attach(e);
|
|
677
|
-
}
|
|
678
|
-
detach() {
|
|
679
|
-
this.canvas.detach();
|
|
680
|
-
}
|
|
681
|
-
addNode(e) {
|
|
682
|
-
this.canvas.addNode(e), this.nodes.set(e.id, e.element), this.nodesResizeObserver.observe(e.element);
|
|
683
|
-
}
|
|
684
|
-
updateNode(e, o) {
|
|
685
|
-
this.canvas.updateNode(e, o);
|
|
686
|
-
}
|
|
687
|
-
removeNode(e) {
|
|
688
|
-
this.canvas.removeNode(e);
|
|
689
|
-
const o = this.nodes.getByKey(e);
|
|
690
|
-
this.nodes.deleteByKey(e), this.nodesResizeObserver.unobserve(o);
|
|
691
|
-
}
|
|
692
|
-
markPort(e) {
|
|
693
|
-
this.canvas.markPort(e);
|
|
694
|
-
}
|
|
695
|
-
updatePort(e, o) {
|
|
696
|
-
this.canvas.updatePort(e, o);
|
|
697
|
-
}
|
|
698
|
-
unmarkPort(e) {
|
|
699
|
-
this.canvas.unmarkPort(e);
|
|
700
|
-
}
|
|
701
|
-
addEdge(e) {
|
|
702
|
-
this.canvas.addEdge(e);
|
|
703
|
-
}
|
|
704
|
-
updateEdge(e, o) {
|
|
705
|
-
this.canvas.updateEdge(e, o);
|
|
706
|
-
}
|
|
707
|
-
removeEdge(e) {
|
|
708
|
-
this.canvas.removeEdge(e);
|
|
709
|
-
}
|
|
710
|
-
patchViewportMatrix(e) {
|
|
711
|
-
this.canvas.patchViewportMatrix(e);
|
|
712
|
-
}
|
|
713
|
-
patchContentMatrix(e) {
|
|
714
|
-
this.canvas.patchContentMatrix(e);
|
|
715
|
-
}
|
|
716
|
-
clear() {
|
|
717
|
-
this.canvas.clear(), this.nodesResizeObserver.disconnect(), this.nodes.clear();
|
|
718
|
-
}
|
|
719
|
-
destroy() {
|
|
720
|
-
this.clear(), this.canvas.destroy();
|
|
721
|
-
}
|
|
722
|
-
handleNodeResize(e) {
|
|
723
|
-
const o = this.nodes.getByValue(e);
|
|
724
|
-
this.canvas.updateNode(o, {}), this.graph.getNodeAdjacentEdgeIds(o).forEach((n) => {
|
|
725
|
-
this.canvas.updateEdge(n, {});
|
|
726
|
-
});
|
|
727
|
-
}
|
|
728
|
-
}
|
|
729
|
-
class ye {
|
|
730
693
|
constructor(e, o, r, n) {
|
|
731
694
|
i(this, "graph");
|
|
732
695
|
i(this, "viewport");
|
|
@@ -773,7 +736,7 @@ class ye {
|
|
|
773
736
|
}
|
|
774
737
|
}
|
|
775
738
|
};
|
|
776
|
-
this.canvas = new
|
|
739
|
+
this.canvas = new ee(
|
|
777
740
|
e,
|
|
778
741
|
d
|
|
779
742
|
), this.viewportMatrix = this.canvas.viewport.getViewportMatrix(), this.viewport = this.canvas.viewport, this.graph = this.canvas.graph, this.trigger.subscribe(this.updateLoadedArea);
|
|
@@ -840,10 +803,10 @@ class ye {
|
|
|
840
803
|
const ve = () => {
|
|
841
804
|
const t = document.createElement("div");
|
|
842
805
|
return t.style.width = "100%", t.style.height = "100%", t.style.position = "relative", t.style.overflow = "hidden", t;
|
|
843
|
-
},
|
|
806
|
+
}, ye = () => {
|
|
844
807
|
const t = document.createElement("div");
|
|
845
808
|
return t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.width = "0", t.style.height = "0", t;
|
|
846
|
-
},
|
|
809
|
+
}, xe = () => {
|
|
847
810
|
const t = document.createElement("div");
|
|
848
811
|
return t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.visibility = "hidden", t;
|
|
849
812
|
};
|
|
@@ -851,14 +814,14 @@ class Ae {
|
|
|
851
814
|
constructor(e, o) {
|
|
852
815
|
i(this, "canvasWrapper", null);
|
|
853
816
|
i(this, "host", ve());
|
|
854
|
-
i(this, "container",
|
|
817
|
+
i(this, "container", ye());
|
|
855
818
|
i(this, "nodeIdToWrapperElementMap", /* @__PURE__ */ new Map());
|
|
856
819
|
i(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
|
|
857
820
|
i(this, "applyTransform", () => {
|
|
858
821
|
const e = this.viewportStore.getContentMatrix();
|
|
859
822
|
this.container.style.transform = `matrix(${e.scale}, 0, 0, ${e.scale}, ${e.x}, ${e.y})`;
|
|
860
823
|
});
|
|
861
|
-
this.graphStore = e, this.viewportStore = o, this.host.appendChild(this.container), this.viewportStore.
|
|
824
|
+
this.graphStore = e, this.viewportStore = o, this.host.appendChild(this.container), this.viewportStore.onAfterUpdated.subscribe(this.applyTransform);
|
|
862
825
|
}
|
|
863
826
|
attach(e) {
|
|
864
827
|
this.detach(), this.canvasWrapper = e, this.canvasWrapper.appendChild(this.host), this.graphStore.getAllEdgeIds().forEach((o) => {
|
|
@@ -869,8 +832,8 @@ class Ae {
|
|
|
869
832
|
this.canvasWrapper !== null && (this.canvasWrapper.removeChild(this.host), this.canvasWrapper = null);
|
|
870
833
|
}
|
|
871
834
|
attachNode(e) {
|
|
872
|
-
const o = this.graphStore.getNode(e), r =
|
|
873
|
-
r.appendChild(o.element), this.container.appendChild(r), this.nodeIdToWrapperElementMap.set(e, r), this.
|
|
835
|
+
const o = this.graphStore.getNode(e), r = xe();
|
|
836
|
+
r.appendChild(o.element), this.container.appendChild(r), this.nodeIdToWrapperElementMap.set(e, r), this.updateNodePosition(e), this.updateNodePriority(e), r.style.visibility = "visible";
|
|
874
837
|
}
|
|
875
838
|
detachNode(e) {
|
|
876
839
|
const o = this.nodeIdToWrapperElementMap.get(e);
|
|
@@ -892,9 +855,9 @@ class Ae {
|
|
|
892
855
|
});
|
|
893
856
|
}
|
|
894
857
|
destroy() {
|
|
895
|
-
this.viewportStore.
|
|
858
|
+
this.viewportStore.onAfterUpdated.unsubscribe(this.applyTransform), this.clear(), this.detach(), this.host.removeChild(this.container);
|
|
896
859
|
}
|
|
897
|
-
|
|
860
|
+
updateNodePosition(e) {
|
|
898
861
|
const o = this.nodeIdToWrapperElementMap.get(e), r = this.graphStore.getNode(e), { width: n, height: h } = r.element.getBoundingClientRect(), s = this.viewportStore.getViewportMatrix().scale, d = r.centerFn(n, h), c = r.x - s * d.x, a = r.y - s * d.y;
|
|
899
862
|
o.style.transform = `translate(${c}px, ${a}px)`;
|
|
900
863
|
}
|
|
@@ -942,7 +905,7 @@ class Ae {
|
|
|
942
905
|
o.shape.svg.style.zIndex = `${o.priority}`;
|
|
943
906
|
}
|
|
944
907
|
}
|
|
945
|
-
class
|
|
908
|
+
class Ee {
|
|
946
909
|
constructor(e) {
|
|
947
910
|
i(this, "xFrom", 1 / 0);
|
|
948
911
|
i(this, "yFrom", 1 / 0);
|
|
@@ -962,7 +925,7 @@ class pe {
|
|
|
962
925
|
return d <= this.xTo && c >= this.xFrom && a <= this.yTo && l >= this.yFrom;
|
|
963
926
|
}
|
|
964
927
|
}
|
|
965
|
-
class
|
|
928
|
+
class pe {
|
|
966
929
|
constructor(e, o, r) {
|
|
967
930
|
i(this, "attachedNodes", /* @__PURE__ */ new Set());
|
|
968
931
|
i(this, "attachedEdges", /* @__PURE__ */ new Set());
|
|
@@ -986,7 +949,7 @@ class Se {
|
|
|
986
949
|
this.handleAttachEdge(s);
|
|
987
950
|
});
|
|
988
951
|
});
|
|
989
|
-
this.htmlView = e, this.graphStore = o, this.trigger = r, this.renderingBox = new
|
|
952
|
+
this.htmlView = e, this.graphStore = o, this.trigger = r, this.renderingBox = new Ee(this.graphStore), this.trigger.subscribe(this.updateViewport);
|
|
990
953
|
}
|
|
991
954
|
attach(e) {
|
|
992
955
|
this.htmlView.attach(e);
|
|
@@ -1006,8 +969,8 @@ class Se {
|
|
|
1006
969
|
detachEdge(e) {
|
|
1007
970
|
this.attachedEdges.has(e) && this.handleDetachEdge(e);
|
|
1008
971
|
}
|
|
1009
|
-
|
|
1010
|
-
this.attachedNodes.has(e) ? this.htmlView.
|
|
972
|
+
updateNodePosition(e) {
|
|
973
|
+
this.attachedNodes.has(e) ? this.htmlView.updateNodePosition(e) : this.renderingBox.hasNode(e) && (this.handleAttachNode(e), this.graphStore.getNodeAdjacentEdgeIds(e).forEach((o) => {
|
|
1011
974
|
this.attachEdgeEntities(o);
|
|
1012
975
|
}));
|
|
1013
976
|
}
|
|
@@ -1046,7 +1009,7 @@ class Se {
|
|
|
1046
1009
|
this.htmlView.detachEdge(e), this.attachedEdges.delete(e);
|
|
1047
1010
|
}
|
|
1048
1011
|
}
|
|
1049
|
-
class
|
|
1012
|
+
class te {
|
|
1050
1013
|
constructor() {
|
|
1051
1014
|
i(this, "callbacks", /* @__PURE__ */ new Set());
|
|
1052
1015
|
}
|
|
@@ -1062,8 +1025,8 @@ class ee {
|
|
|
1062
1025
|
});
|
|
1063
1026
|
}
|
|
1064
1027
|
}
|
|
1065
|
-
const
|
|
1066
|
-
const t = new
|
|
1028
|
+
const A = () => {
|
|
1029
|
+
const t = new te();
|
|
1067
1030
|
return [t, t];
|
|
1068
1031
|
};
|
|
1069
1032
|
class z {
|
|
@@ -1082,29 +1045,29 @@ class z {
|
|
|
1082
1045
|
this.counter = 0;
|
|
1083
1046
|
}
|
|
1084
1047
|
}
|
|
1085
|
-
class
|
|
1048
|
+
class E extends Error {
|
|
1086
1049
|
constructor() {
|
|
1087
1050
|
super(...arguments);
|
|
1088
1051
|
i(this, "name", "HtmlGraphError");
|
|
1089
1052
|
}
|
|
1090
1053
|
}
|
|
1091
|
-
const
|
|
1054
|
+
const Se = (t, e) => ({
|
|
1092
1055
|
x: t / 2,
|
|
1093
1056
|
y: e / 2
|
|
1094
|
-
}), Y = (t) => () => t,
|
|
1057
|
+
}), Y = (t) => () => t, Z = Y(0), Ne = () => {
|
|
1095
1058
|
let t = 0;
|
|
1096
1059
|
return () => t++;
|
|
1097
|
-
},
|
|
1098
|
-
let o =
|
|
1060
|
+
}, Te = (t, e) => {
|
|
1061
|
+
let o = Z, r = Z;
|
|
1099
1062
|
const n = Ne();
|
|
1100
1063
|
return t === "incremental" && (o = n), e === "incremental" && (r = n), typeof t == "number" && (o = Y(t)), typeof e == "number" && (r = Y(e)), typeof t == "function" && (o = t), typeof e == "function" && (r = e), {
|
|
1101
1064
|
nodesPriorityFn: o,
|
|
1102
1065
|
edgesPriorityFn: r
|
|
1103
1066
|
};
|
|
1104
|
-
},
|
|
1067
|
+
}, y = (t, e, o) => ({
|
|
1105
1068
|
x: e.x * t.x - e.y * t.y + ((1 - e.x) * o.x + e.y * o.y),
|
|
1106
1069
|
y: e.y * t.x + e.x * t.y + ((1 - e.x) * o.y - e.y * o.x)
|
|
1107
|
-
}),
|
|
1070
|
+
}), T = (t, e, o) => ({ x: e * Math.cos(t), y: o * Math.sin(t) }), w = {
|
|
1108
1071
|
x: 0,
|
|
1109
1072
|
y: 0
|
|
1110
1073
|
}, m = (t, e, o, r) => {
|
|
@@ -1112,23 +1075,23 @@ const Te = (t, e) => ({
|
|
|
1112
1075
|
w,
|
|
1113
1076
|
{ x: o, y: r },
|
|
1114
1077
|
{ x: o, y: -r }
|
|
1115
|
-
].map((a) =>
|
|
1078
|
+
].map((a) => y(a, t, w)).map((a) => ({ x: a.x + e.x, y: a.y + e.y })), s = `M ${h[0].x} ${h[0].y}`, d = `L ${h[1].x} ${h[1].y}`, c = `L ${h[2].x} ${h[2].y}`;
|
|
1116
1079
|
return `${s} ${d} ${c}`;
|
|
1117
|
-
},
|
|
1080
|
+
}, D = (t, e) => {
|
|
1118
1081
|
const o = [];
|
|
1119
1082
|
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) {
|
|
1120
1083
|
const r = t.length - 1;
|
|
1121
1084
|
let n = 0, h = 0, s = 0;
|
|
1122
1085
|
t.forEach((d, c) => {
|
|
1123
1086
|
let a = 0, l = 0, g = 0;
|
|
1124
|
-
const f = c > 0, x = c < r,
|
|
1087
|
+
const f = c > 0, x = c < r, v = f && x;
|
|
1125
1088
|
if (f && (a = -n, l = -h, g = s), x) {
|
|
1126
|
-
const
|
|
1127
|
-
n =
|
|
1089
|
+
const L = t[c + 1];
|
|
1090
|
+
n = L.x - d.x, h = L.y - d.y, s = Math.sqrt(n * n + h * h);
|
|
1128
1091
|
}
|
|
1129
|
-
const p = s !== 0 ? Math.min((
|
|
1130
|
-
c > 0 && o.push(`L ${
|
|
1131
|
-
`C ${d.x} ${d.y} ${d.x} ${d.y} ${
|
|
1092
|
+
const p = s !== 0 ? Math.min((v ? e : 0) / s, c < r - 1 ? 0.5 : 1) : 0, N = v ? { x: d.x + n * p, y: d.y + h * p } : d, M = g !== 0 ? Math.min((v ? e : 0) / g, c > 1 ? 0.5 : 1) : 0, V = v ? { x: d.x + a * M, y: d.y + l * M } : d;
|
|
1093
|
+
c > 0 && o.push(`L ${V.x} ${V.y}`), v && o.push(
|
|
1094
|
+
`C ${d.x} ${d.y} ${d.x} ${d.y} ${N.x} ${N.y}`
|
|
1132
1095
|
);
|
|
1133
1096
|
});
|
|
1134
1097
|
}
|
|
@@ -1136,13 +1099,13 @@ const Te = (t, e) => ({
|
|
|
1136
1099
|
}, I = () => {
|
|
1137
1100
|
const t = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
1138
1101
|
return t.style.pointerEvents = "none", t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.overflow = "visible", t;
|
|
1139
|
-
},
|
|
1102
|
+
}, W = () => {
|
|
1140
1103
|
const t = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
|
1141
1104
|
return t.style.transformOrigin = "50% 50%", t;
|
|
1142
|
-
},
|
|
1105
|
+
}, F = (t, e) => {
|
|
1143
1106
|
const o = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
1144
1107
|
return o.setAttribute("stroke", t), o.setAttribute("stroke-width", `${e}`), o.setAttribute("fill", "none"), o;
|
|
1145
|
-
},
|
|
1108
|
+
}, P = (t) => {
|
|
1146
1109
|
const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
1147
1110
|
return e.setAttribute("fill", t), e;
|
|
1148
1111
|
}, B = (t, e) => {
|
|
@@ -1161,12 +1124,12 @@ const Te = (t, e) => ({
|
|
|
1161
1124
|
flipX: c,
|
|
1162
1125
|
flipY: a
|
|
1163
1126
|
};
|
|
1164
|
-
},
|
|
1165
|
-
const e =
|
|
1127
|
+
}, me = (t) => {
|
|
1128
|
+
const e = y(
|
|
1166
1129
|
{ x: t.arrowLength, y: w.y },
|
|
1167
1130
|
t.fromVect,
|
|
1168
1131
|
w
|
|
1169
|
-
), o =
|
|
1132
|
+
), o = y(
|
|
1170
1133
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
1171
1134
|
t.toVect,
|
|
1172
1135
|
t.to
|
|
@@ -1179,22 +1142,22 @@ const Te = (t, e) => ({
|
|
|
1179
1142
|
}, h = `M ${e.x} ${e.y} C ${r.x} ${r.y}, ${n.x} ${n.y}, ${o.x} ${o.y}`, s = 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}`;
|
|
1180
1143
|
return `${s}${h}${d}`;
|
|
1181
1144
|
}, Pe = (t) => {
|
|
1182
|
-
const e = t.hasSourceArrow ?
|
|
1145
|
+
const e = t.hasSourceArrow ? y(
|
|
1183
1146
|
{ x: t.arrowLength, y: w.y },
|
|
1184
1147
|
t.fromVect,
|
|
1185
1148
|
w
|
|
1186
|
-
) : w, o = t.hasTargetArrow ?
|
|
1149
|
+
) : w, o = t.hasTargetArrow ? y(
|
|
1187
1150
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
1188
1151
|
t.toVect,
|
|
1189
1152
|
t.to
|
|
1190
|
-
) : t.to, r = t.arrowLength, n = Math.cos(t.detourDirection) * t.detourDistance, h = Math.sin(t.detourDirection) * t.detourDistance, s = n * t.flipX, d = h * t.flipY, c =
|
|
1153
|
+
) : t.to, r = t.arrowLength, n = Math.cos(t.detourDirection) * t.detourDistance, h = Math.sin(t.detourDirection) * t.detourDistance, s = n * t.flipX, d = h * t.flipY, c = y(
|
|
1191
1154
|
{ x: r, y: w.y },
|
|
1192
1155
|
t.fromVect,
|
|
1193
1156
|
w
|
|
1194
1157
|
), a = {
|
|
1195
1158
|
x: c.x + s,
|
|
1196
1159
|
y: c.y + d
|
|
1197
|
-
}, l =
|
|
1160
|
+
}, l = y(
|
|
1198
1161
|
{ x: t.to.x - r, y: t.to.y },
|
|
1199
1162
|
t.toVect,
|
|
1200
1163
|
t.to
|
|
@@ -1204,7 +1167,7 @@ const Te = (t, e) => ({
|
|
|
1204
1167
|
}, f = { x: (a.x + g.x) / 2, y: (a.y + g.y) / 2 }, x = {
|
|
1205
1168
|
x: c.x + t.curvature * t.fromVect.x,
|
|
1206
1169
|
y: c.y + t.curvature * t.fromVect.y
|
|
1207
|
-
},
|
|
1170
|
+
}, v = {
|
|
1208
1171
|
x: l.x - t.curvature * t.toVect.x,
|
|
1209
1172
|
y: l.y - t.curvature * t.toVect.y
|
|
1210
1173
|
}, S = {
|
|
@@ -1218,19 +1181,19 @@ const Te = (t, e) => ({
|
|
|
1218
1181
|
`M ${e.x} ${e.y}`,
|
|
1219
1182
|
`L ${c.x} ${c.y}`,
|
|
1220
1183
|
`C ${x.x} ${x.y} ${S.x} ${S.y} ${f.x} ${f.y}`,
|
|
1221
|
-
`C ${p.x} ${p.y} ${
|
|
1184
|
+
`C ${p.x} ${p.y} ${v.x} ${v.y} ${l.x} ${l.y}`,
|
|
1222
1185
|
`L ${o.x} ${o.y}`
|
|
1223
1186
|
].join(" ");
|
|
1224
|
-
},
|
|
1225
|
-
const e = t.hasSourceArrow ?
|
|
1187
|
+
}, be = (t) => {
|
|
1188
|
+
const e = t.hasSourceArrow ? y(
|
|
1226
1189
|
{ x: t.arrowLength, y: w.y },
|
|
1227
1190
|
t.fromVect,
|
|
1228
1191
|
w
|
|
1229
|
-
) : w, o = t.hasTargetArrow ?
|
|
1192
|
+
) : w, o = t.hasTargetArrow ? y(
|
|
1230
1193
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
1231
1194
|
t.toVect,
|
|
1232
1195
|
t.to
|
|
1233
|
-
) : t.to, r = t.arrowLength + t.arrowOffset, n = r - t.roundness, h =
|
|
1196
|
+
) : t.to, r = t.arrowLength + t.arrowOffset, n = r - t.roundness, h = y({ x: n, y: w.y }, t.fromVect, w), s = y(
|
|
1234
1197
|
{ x: t.to.x - n, y: t.to.y },
|
|
1235
1198
|
t.toVect,
|
|
1236
1199
|
t.to
|
|
@@ -1238,57 +1201,57 @@ const Te = (t, e) => ({
|
|
|
1238
1201
|
x: t.flipX > 0 ? t.to.x - d : t.to.x + r,
|
|
1239
1202
|
y: s.y
|
|
1240
1203
|
}, f = { x: g.x, y: c };
|
|
1241
|
-
return
|
|
1204
|
+
return D(
|
|
1242
1205
|
[e, h, a, l, f, g, s, o],
|
|
1243
1206
|
t.roundness
|
|
1244
1207
|
);
|
|
1245
1208
|
}, X = (t) => {
|
|
1246
|
-
const e = t.hasSourceArrow ?
|
|
1209
|
+
const e = t.hasSourceArrow ? y(
|
|
1247
1210
|
{ x: t.arrowLength, y: w.y },
|
|
1248
1211
|
t.fromVect,
|
|
1249
1212
|
w
|
|
1250
|
-
) : w, o = t.hasTargetArrow ?
|
|
1213
|
+
) : w, o = t.hasTargetArrow ? y(
|
|
1251
1214
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
1252
1215
|
t.toVect,
|
|
1253
1216
|
t.to
|
|
1254
|
-
) : t.to, r = t.arrowLength + t.arrowOffset, n =
|
|
1217
|
+
) : t.to, r = t.arrowLength + t.arrowOffset, n = y(
|
|
1255
1218
|
{ x: r, y: w.y },
|
|
1256
1219
|
t.fromVect,
|
|
1257
1220
|
w
|
|
1258
|
-
), h = Math.cos(t.detourDirection) * t.detourDistance, s = Math.sin(t.detourDirection) * t.detourDistance, d = h * t.flipX, c = s * t.flipY, a = { x: n.x + d, y: n.y + c }, l =
|
|
1221
|
+
), h = Math.cos(t.detourDirection) * t.detourDistance, s = Math.sin(t.detourDirection) * t.detourDistance, d = h * t.flipX, c = s * t.flipY, a = { x: n.x + d, y: n.y + c }, l = y(
|
|
1259
1222
|
{ x: t.to.x - r, y: t.to.y },
|
|
1260
1223
|
t.toVect,
|
|
1261
1224
|
t.to
|
|
1262
1225
|
), g = { x: l.x + d, y: l.y + c };
|
|
1263
|
-
return
|
|
1226
|
+
return D(
|
|
1264
1227
|
[e, n, a, g, l, o],
|
|
1265
1228
|
t.roundness
|
|
1266
1229
|
);
|
|
1267
|
-
},
|
|
1268
|
-
const e = t.hasSourceArrow ?
|
|
1230
|
+
}, Me = (t) => {
|
|
1231
|
+
const e = t.hasSourceArrow ? y(
|
|
1269
1232
|
{ x: t.arrowLength, y: w.y },
|
|
1270
1233
|
t.fromVect,
|
|
1271
1234
|
w
|
|
1272
|
-
) : w, o = t.hasTargetArrow ?
|
|
1235
|
+
) : w, o = t.hasTargetArrow ? y(
|
|
1273
1236
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
1274
1237
|
t.toVect,
|
|
1275
1238
|
t.to
|
|
1276
|
-
) : t.to, r = t.arrowLength + t.arrowOffset, n =
|
|
1239
|
+
) : t.to, r = t.arrowLength + t.arrowOffset, n = y({ x: r, y: w.y }, t.fromVect, w), h = y(
|
|
1277
1240
|
{ x: t.to.x - r, y: t.to.y },
|
|
1278
1241
|
t.toVect,
|
|
1279
1242
|
t.to
|
|
1280
1243
|
);
|
|
1281
|
-
return
|
|
1282
|
-
},
|
|
1283
|
-
const e = t.hasSourceArrow ?
|
|
1244
|
+
return D([e, n, h, o], t.roundness);
|
|
1245
|
+
}, Ve = (t) => {
|
|
1246
|
+
const e = t.hasSourceArrow ? y(
|
|
1284
1247
|
{ x: t.arrowLength, y: w.y },
|
|
1285
1248
|
t.fromVect,
|
|
1286
1249
|
w
|
|
1287
|
-
) : w, o = t.hasTargetArrow ?
|
|
1250
|
+
) : w, o = t.hasTargetArrow ? y(
|
|
1288
1251
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
1289
1252
|
t.toVect,
|
|
1290
1253
|
t.to
|
|
1291
|
-
) : t.to, r = t.arrowLength + t.arrowOffset, n = r - t.roundness, h =
|
|
1254
|
+
) : t.to, r = t.arrowLength + t.arrowOffset, n = r - t.roundness, h = y({ x: n, y: w.y }, t.fromVect, w), s = y(
|
|
1292
1255
|
{ x: t.to.x - n, y: t.to.y },
|
|
1293
1256
|
t.toVect,
|
|
1294
1257
|
t.to
|
|
@@ -1296,11 +1259,11 @@ const Te = (t, e) => ({
|
|
|
1296
1259
|
x: s.x,
|
|
1297
1260
|
y: t.flipY > 0 ? t.to.y - d : t.to.y + r
|
|
1298
1261
|
}, f = { x: c, y: g.y };
|
|
1299
|
-
return
|
|
1262
|
+
return D(
|
|
1300
1263
|
[e, h, a, l, f, g, s, o],
|
|
1301
1264
|
t.roundness
|
|
1302
1265
|
);
|
|
1303
|
-
},
|
|
1266
|
+
}, H = (t) => {
|
|
1304
1267
|
const e = t.arrowOffset, o = t.side, r = t.arrowLength + e, n = r + 2 * o, s = [
|
|
1305
1268
|
{ x: t.arrowLength, y: w.y },
|
|
1306
1269
|
{ x: r, y: w.y },
|
|
@@ -1311,15 +1274,15 @@ const Te = (t, e) => ({
|
|
|
1311
1274
|
{ x: r, y: w.y },
|
|
1312
1275
|
{ x: t.arrowLength, y: w.y }
|
|
1313
1276
|
].map(
|
|
1314
|
-
(c) =>
|
|
1277
|
+
(c) => y(c, t.fromVect, w)
|
|
1315
1278
|
), d = `M ${w.x} ${w.y} L ${s[0].x} ${s[0].y} `;
|
|
1316
|
-
return `${t.hasSourceArrow || t.hasTargetArrow ? "" : d}${
|
|
1279
|
+
return `${t.hasSourceArrow || t.hasTargetArrow ? "" : d}${D(s, t.roundness)}`;
|
|
1317
1280
|
}, Le = (t) => {
|
|
1318
1281
|
const e = t.smallRadius, o = t.radius, r = Math.sqrt(e * e + o * o), n = e + o, h = t.arrowLength + r * (1 - o / n), s = e * o / n, c = [
|
|
1319
1282
|
{ x: t.arrowLength, y: w.y },
|
|
1320
1283
|
{ x: h, y: s },
|
|
1321
1284
|
{ x: h, y: -s }
|
|
1322
|
-
].map((g) =>
|
|
1285
|
+
].map((g) => y(g, t.fromVect, w)), a = [
|
|
1323
1286
|
`M ${c[0].x} ${c[0].y}`,
|
|
1324
1287
|
`A ${e} ${e} 0 0 1 ${c[1].x} ${c[1].y}`,
|
|
1325
1288
|
`A ${o} ${o} 0 1 0 ${c[2].x} ${c[2].y}`,
|
|
@@ -1343,10 +1306,10 @@ const Te = (t, e) => ({
|
|
|
1343
1306
|
smallCycleRadius: 15,
|
|
1344
1307
|
curvature: 90
|
|
1345
1308
|
});
|
|
1346
|
-
class
|
|
1309
|
+
class De {
|
|
1347
1310
|
constructor(e) {
|
|
1348
1311
|
i(this, "svg", I());
|
|
1349
|
-
i(this, "group",
|
|
1312
|
+
i(this, "group", W());
|
|
1350
1313
|
i(this, "line");
|
|
1351
1314
|
i(this, "sourceArrow", null);
|
|
1352
1315
|
i(this, "targetArrow", null);
|
|
@@ -1361,7 +1324,7 @@ class be {
|
|
|
1361
1324
|
i(this, "hasTargetArrow");
|
|
1362
1325
|
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;
|
|
1363
1326
|
const o = (e == null ? void 0 : e.color) ?? u.color, r = (e == null ? void 0 : e.width) ?? u.width;
|
|
1364
|
-
this.svg.appendChild(this.group), this.line =
|
|
1327
|
+
this.svg.appendChild(this.group), this.line = F(o, r), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = P(o), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = P(o), this.group.appendChild(this.targetArrow));
|
|
1365
1328
|
}
|
|
1366
1329
|
render(e) {
|
|
1367
1330
|
const { x: o, y: r, width: n, height: h, flipX: s, flipY: d } = B(
|
|
@@ -1369,11 +1332,11 @@ class be {
|
|
|
1369
1332
|
e.to
|
|
1370
1333
|
);
|
|
1371
1334
|
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${n}px`, this.svg.style.height = `${h}px`, this.group.style.transform = `scale(${s}, ${d})`;
|
|
1372
|
-
const c =
|
|
1335
|
+
const c = T(
|
|
1373
1336
|
e.from.direction,
|
|
1374
1337
|
s,
|
|
1375
1338
|
d
|
|
1376
|
-
), a =
|
|
1339
|
+
), a = T(e.to.direction, s, d), l = {
|
|
1377
1340
|
x: n,
|
|
1378
1341
|
y: h
|
|
1379
1342
|
};
|
|
@@ -1397,7 +1360,7 @@ class be {
|
|
|
1397
1360
|
curvature: this.curvature,
|
|
1398
1361
|
hasSourceArrow: this.hasSourceArrow,
|
|
1399
1362
|
hasTargetArrow: this.hasTargetArrow
|
|
1400
|
-
}) : g =
|
|
1363
|
+
}) : g = me({
|
|
1401
1364
|
to: l,
|
|
1402
1365
|
fromVect: c,
|
|
1403
1366
|
toVect: a,
|
|
@@ -1406,29 +1369,29 @@ class be {
|
|
|
1406
1369
|
hasSourceArrow: this.hasSourceArrow,
|
|
1407
1370
|
hasTargetArrow: this.hasTargetArrow
|
|
1408
1371
|
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
1409
|
-
const
|
|
1372
|
+
const v = m(
|
|
1410
1373
|
c,
|
|
1411
1374
|
w,
|
|
1412
1375
|
this.arrowLength,
|
|
1413
1376
|
this.arrowWidth
|
|
1414
1377
|
);
|
|
1415
|
-
this.sourceArrow.setAttribute("d",
|
|
1378
|
+
this.sourceArrow.setAttribute("d", v);
|
|
1416
1379
|
}
|
|
1417
1380
|
if (this.targetArrow) {
|
|
1418
|
-
const
|
|
1381
|
+
const v = m(
|
|
1419
1382
|
f,
|
|
1420
1383
|
l,
|
|
1421
1384
|
x,
|
|
1422
1385
|
this.arrowWidth
|
|
1423
1386
|
);
|
|
1424
|
-
this.targetArrow.setAttribute("d",
|
|
1387
|
+
this.targetArrow.setAttribute("d", v);
|
|
1425
1388
|
}
|
|
1426
1389
|
}
|
|
1427
1390
|
}
|
|
1428
|
-
class
|
|
1391
|
+
class Ce {
|
|
1429
1392
|
constructor(e) {
|
|
1430
1393
|
i(this, "svg", I());
|
|
1431
|
-
i(this, "group",
|
|
1394
|
+
i(this, "group", W());
|
|
1432
1395
|
i(this, "line");
|
|
1433
1396
|
i(this, "sourceArrow", null);
|
|
1434
1397
|
i(this, "targetArrow", null);
|
|
@@ -1449,7 +1412,7 @@ class $e {
|
|
|
1449
1412
|
this.cycleSquareSide / 2
|
|
1450
1413
|
), 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;
|
|
1451
1414
|
const r = (e == null ? void 0 : e.color) ?? u.color, n = (e == null ? void 0 : e.width) ?? u.width;
|
|
1452
|
-
this.svg.appendChild(this.group), this.line =
|
|
1415
|
+
this.svg.appendChild(this.group), this.line = F(r, n), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = P(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = P(r), this.group.appendChild(this.targetArrow));
|
|
1453
1416
|
}
|
|
1454
1417
|
render(e) {
|
|
1455
1418
|
const { x: o, y: r, width: n, height: h, flipX: s, flipY: d } = B(
|
|
@@ -1457,16 +1420,16 @@ class $e {
|
|
|
1457
1420
|
e.to
|
|
1458
1421
|
);
|
|
1459
1422
|
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${n}px`, this.svg.style.height = `${h}px`, this.group.style.transform = `scale(${s}, ${d})`;
|
|
1460
|
-
const c =
|
|
1423
|
+
const c = T(
|
|
1461
1424
|
e.from.direction,
|
|
1462
1425
|
s,
|
|
1463
1426
|
d
|
|
1464
|
-
), a =
|
|
1427
|
+
), a = T(e.to.direction, s, d), l = {
|
|
1465
1428
|
x: n,
|
|
1466
1429
|
y: h
|
|
1467
1430
|
};
|
|
1468
1431
|
let g, f = a, x = -this.arrowLength;
|
|
1469
|
-
if (e.from.portId === e.to.portId ? (g =
|
|
1432
|
+
if (e.from.portId === e.to.portId ? (g = H({
|
|
1470
1433
|
fromVect: c,
|
|
1471
1434
|
arrowLength: this.arrowLength,
|
|
1472
1435
|
side: this.cycleSquareSide,
|
|
@@ -1487,7 +1450,7 @@ class $e {
|
|
|
1487
1450
|
detourDistance: this.detourDistance,
|
|
1488
1451
|
hasSourceArrow: this.hasSourceArrow,
|
|
1489
1452
|
hasTargetArrow: this.hasTargetArrow
|
|
1490
|
-
}) : g =
|
|
1453
|
+
}) : g = be({
|
|
1491
1454
|
to: l,
|
|
1492
1455
|
fromVect: c,
|
|
1493
1456
|
toVect: a,
|
|
@@ -1498,29 +1461,29 @@ class $e {
|
|
|
1498
1461
|
hasSourceArrow: this.hasSourceArrow,
|
|
1499
1462
|
hasTargetArrow: this.hasTargetArrow
|
|
1500
1463
|
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
1501
|
-
const
|
|
1464
|
+
const v = m(
|
|
1502
1465
|
c,
|
|
1503
1466
|
w,
|
|
1504
1467
|
this.arrowLength,
|
|
1505
1468
|
this.arrowWidth
|
|
1506
1469
|
);
|
|
1507
|
-
this.sourceArrow.setAttribute("d",
|
|
1470
|
+
this.sourceArrow.setAttribute("d", v);
|
|
1508
1471
|
}
|
|
1509
1472
|
if (this.targetArrow) {
|
|
1510
|
-
const
|
|
1473
|
+
const v = m(
|
|
1511
1474
|
f,
|
|
1512
1475
|
l,
|
|
1513
1476
|
x,
|
|
1514
1477
|
this.arrowWidth
|
|
1515
1478
|
);
|
|
1516
|
-
this.targetArrow.setAttribute("d",
|
|
1479
|
+
this.targetArrow.setAttribute("d", v);
|
|
1517
1480
|
}
|
|
1518
1481
|
}
|
|
1519
1482
|
}
|
|
1520
|
-
class
|
|
1483
|
+
class Ue {
|
|
1521
1484
|
constructor(e) {
|
|
1522
1485
|
i(this, "svg", I());
|
|
1523
|
-
i(this, "group",
|
|
1486
|
+
i(this, "group", W());
|
|
1524
1487
|
i(this, "line");
|
|
1525
1488
|
i(this, "sourceArrow", null);
|
|
1526
1489
|
i(this, "targetArrow", null);
|
|
@@ -1541,7 +1504,7 @@ class We {
|
|
|
1541
1504
|
this.cycleSquareSide / 2
|
|
1542
1505
|
), 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;
|
|
1543
1506
|
const r = (e == null ? void 0 : e.color) ?? u.color, n = (e == null ? void 0 : e.width) ?? u.width;
|
|
1544
|
-
this.svg.appendChild(this.group), this.line =
|
|
1507
|
+
this.svg.appendChild(this.group), this.line = F(r, n), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = P(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = P(r), this.group.appendChild(this.targetArrow));
|
|
1545
1508
|
}
|
|
1546
1509
|
render(e) {
|
|
1547
1510
|
const { x: o, y: r, width: n, height: h, flipX: s, flipY: d } = B(
|
|
@@ -1549,16 +1512,16 @@ class We {
|
|
|
1549
1512
|
e.to
|
|
1550
1513
|
);
|
|
1551
1514
|
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${n}px`, this.svg.style.height = `${h}px`, this.group.style.transform = `scale(${s}, ${d})`;
|
|
1552
|
-
const c =
|
|
1515
|
+
const c = T(
|
|
1553
1516
|
e.from.direction,
|
|
1554
1517
|
s,
|
|
1555
1518
|
d
|
|
1556
|
-
), a =
|
|
1519
|
+
), a = T(e.to.direction, s, d), l = {
|
|
1557
1520
|
x: n,
|
|
1558
1521
|
y: h
|
|
1559
1522
|
};
|
|
1560
1523
|
let g, f = a, x = -this.arrowLength;
|
|
1561
|
-
if (e.from.portId === e.to.portId ? (g =
|
|
1524
|
+
if (e.from.portId === e.to.portId ? (g = H({
|
|
1562
1525
|
fromVect: c,
|
|
1563
1526
|
arrowLength: this.arrowLength,
|
|
1564
1527
|
side: this.cycleSquareSide,
|
|
@@ -1579,7 +1542,7 @@ class We {
|
|
|
1579
1542
|
detourDistance: this.detourDistance,
|
|
1580
1543
|
hasSourceArrow: this.hasSourceArrow,
|
|
1581
1544
|
hasTargetArrow: this.hasTargetArrow
|
|
1582
|
-
}) : g =
|
|
1545
|
+
}) : g = Me({
|
|
1583
1546
|
to: l,
|
|
1584
1547
|
fromVect: c,
|
|
1585
1548
|
toVect: a,
|
|
@@ -1589,29 +1552,29 @@ class We {
|
|
|
1589
1552
|
hasSourceArrow: this.hasSourceArrow,
|
|
1590
1553
|
hasTargetArrow: this.hasTargetArrow
|
|
1591
1554
|
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
1592
|
-
const
|
|
1555
|
+
const v = m(
|
|
1593
1556
|
c,
|
|
1594
1557
|
w,
|
|
1595
1558
|
this.arrowLength,
|
|
1596
1559
|
this.arrowWidth
|
|
1597
1560
|
);
|
|
1598
|
-
this.sourceArrow.setAttribute("d",
|
|
1561
|
+
this.sourceArrow.setAttribute("d", v);
|
|
1599
1562
|
}
|
|
1600
1563
|
if (this.targetArrow) {
|
|
1601
|
-
const
|
|
1564
|
+
const v = m(
|
|
1602
1565
|
f,
|
|
1603
1566
|
l,
|
|
1604
1567
|
x,
|
|
1605
1568
|
this.arrowWidth
|
|
1606
1569
|
);
|
|
1607
|
-
this.targetArrow.setAttribute("d",
|
|
1570
|
+
this.targetArrow.setAttribute("d", v);
|
|
1608
1571
|
}
|
|
1609
1572
|
}
|
|
1610
1573
|
}
|
|
1611
|
-
class
|
|
1574
|
+
class $e {
|
|
1612
1575
|
constructor(e) {
|
|
1613
1576
|
i(this, "svg", I());
|
|
1614
|
-
i(this, "group",
|
|
1577
|
+
i(this, "group", W());
|
|
1615
1578
|
i(this, "line");
|
|
1616
1579
|
i(this, "sourceArrow", null);
|
|
1617
1580
|
i(this, "targetArrow", null);
|
|
@@ -1632,7 +1595,7 @@ class Re {
|
|
|
1632
1595
|
this.cycleSquareSide / 2
|
|
1633
1596
|
), 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;
|
|
1634
1597
|
const r = (e == null ? void 0 : e.color) ?? u.color, n = (e == null ? void 0 : e.width) ?? u.width;
|
|
1635
|
-
this.svg.appendChild(this.group), this.line =
|
|
1598
|
+
this.svg.appendChild(this.group), this.line = F(r, n), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = P(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = P(r), this.group.appendChild(this.targetArrow));
|
|
1636
1599
|
}
|
|
1637
1600
|
render(e) {
|
|
1638
1601
|
const { x: o, y: r, width: n, height: h, flipX: s, flipY: d } = B(
|
|
@@ -1640,16 +1603,16 @@ class Re {
|
|
|
1640
1603
|
e.to
|
|
1641
1604
|
);
|
|
1642
1605
|
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${n}px`, this.svg.style.height = `${h}px`, this.group.style.transform = `scale(${s}, ${d})`;
|
|
1643
|
-
const c =
|
|
1606
|
+
const c = T(
|
|
1644
1607
|
e.from.direction,
|
|
1645
1608
|
s,
|
|
1646
1609
|
d
|
|
1647
|
-
), a =
|
|
1610
|
+
), a = T(e.to.direction, s, d), l = {
|
|
1648
1611
|
x: n,
|
|
1649
1612
|
y: h
|
|
1650
1613
|
};
|
|
1651
1614
|
let g, f = a, x = -this.arrowLength;
|
|
1652
|
-
if (e.from.portId === e.to.portId ? (g =
|
|
1615
|
+
if (e.from.portId === e.to.portId ? (g = H({
|
|
1653
1616
|
fromVect: c,
|
|
1654
1617
|
arrowLength: this.arrowLength,
|
|
1655
1618
|
side: this.cycleSquareSide,
|
|
@@ -1670,7 +1633,7 @@ class Re {
|
|
|
1670
1633
|
detourDistance: this.detourDistance,
|
|
1671
1634
|
hasSourceArrow: this.hasSourceArrow,
|
|
1672
1635
|
hasTargetArrow: this.hasTargetArrow
|
|
1673
|
-
}) : g =
|
|
1636
|
+
}) : g = Ve({
|
|
1674
1637
|
to: l,
|
|
1675
1638
|
fromVect: c,
|
|
1676
1639
|
toVect: a,
|
|
@@ -1681,31 +1644,31 @@ class Re {
|
|
|
1681
1644
|
hasSourceArrow: this.hasSourceArrow,
|
|
1682
1645
|
hasTargetArrow: this.hasTargetArrow
|
|
1683
1646
|
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
1684
|
-
const
|
|
1647
|
+
const v = m(
|
|
1685
1648
|
c,
|
|
1686
1649
|
w,
|
|
1687
1650
|
this.arrowLength,
|
|
1688
1651
|
this.arrowWidth
|
|
1689
1652
|
);
|
|
1690
|
-
this.sourceArrow.setAttribute("d",
|
|
1653
|
+
this.sourceArrow.setAttribute("d", v);
|
|
1691
1654
|
}
|
|
1692
1655
|
if (this.targetArrow) {
|
|
1693
|
-
const
|
|
1656
|
+
const v = m(
|
|
1694
1657
|
f,
|
|
1695
1658
|
l,
|
|
1696
1659
|
x,
|
|
1697
1660
|
this.arrowWidth
|
|
1698
1661
|
);
|
|
1699
|
-
this.targetArrow.setAttribute("d",
|
|
1662
|
+
this.targetArrow.setAttribute("d", v);
|
|
1700
1663
|
}
|
|
1701
1664
|
}
|
|
1702
1665
|
}
|
|
1703
|
-
const
|
|
1666
|
+
const Re = (t) => {
|
|
1704
1667
|
if (typeof t == "function")
|
|
1705
1668
|
return t;
|
|
1706
1669
|
switch (t == null ? void 0 : t.type) {
|
|
1707
1670
|
case "straight":
|
|
1708
|
-
return () => new
|
|
1671
|
+
return () => new Ue({
|
|
1709
1672
|
color: t.color,
|
|
1710
1673
|
width: t.width,
|
|
1711
1674
|
arrowLength: t.arrowLength,
|
|
@@ -1719,7 +1682,7 @@ const Ie = (t) => {
|
|
|
1719
1682
|
detourDirection: t.detourDirection
|
|
1720
1683
|
});
|
|
1721
1684
|
case "horizontal":
|
|
1722
|
-
return () => new
|
|
1685
|
+
return () => new Ce({
|
|
1723
1686
|
color: t.color,
|
|
1724
1687
|
width: t.width,
|
|
1725
1688
|
arrowLength: t.arrowLength,
|
|
@@ -1733,7 +1696,7 @@ const Ie = (t) => {
|
|
|
1733
1696
|
detourDirection: t.detourDirection
|
|
1734
1697
|
});
|
|
1735
1698
|
case "vertical":
|
|
1736
|
-
return () => new
|
|
1699
|
+
return () => new $e({
|
|
1737
1700
|
color: t.color,
|
|
1738
1701
|
width: t.width,
|
|
1739
1702
|
arrowLength: t.arrowLength,
|
|
@@ -1747,7 +1710,7 @@ const Ie = (t) => {
|
|
|
1747
1710
|
detourDirection: t.detourDirection
|
|
1748
1711
|
});
|
|
1749
1712
|
default:
|
|
1750
|
-
return () => new
|
|
1713
|
+
return () => new De({
|
|
1751
1714
|
color: t.color,
|
|
1752
1715
|
width: t.width,
|
|
1753
1716
|
arrowLength: t.arrowLength,
|
|
@@ -1761,27 +1724,27 @@ const Ie = (t) => {
|
|
|
1761
1724
|
detourDirection: t.detourDirection
|
|
1762
1725
|
});
|
|
1763
1726
|
}
|
|
1764
|
-
},
|
|
1727
|
+
}, Ie = (t) => {
|
|
1765
1728
|
var o, r, n, h, s;
|
|
1766
|
-
const e =
|
|
1729
|
+
const e = Te(
|
|
1767
1730
|
(o = t == null ? void 0 : t.nodes) == null ? void 0 : o.priority,
|
|
1768
1731
|
(r = t == null ? void 0 : t.edges) == null ? void 0 : r.priority
|
|
1769
1732
|
);
|
|
1770
1733
|
return {
|
|
1771
1734
|
nodes: {
|
|
1772
|
-
centerFn: ((n = t == null ? void 0 : t.nodes) == null ? void 0 : n.centerFn) ??
|
|
1735
|
+
centerFn: ((n = t == null ? void 0 : t.nodes) == null ? void 0 : n.centerFn) ?? Se,
|
|
1773
1736
|
priorityFn: e.nodesPriorityFn
|
|
1774
1737
|
},
|
|
1775
1738
|
ports: {
|
|
1776
1739
|
direction: ((h = t == null ? void 0 : t.ports) == null ? void 0 : h.direction) ?? 0
|
|
1777
1740
|
},
|
|
1778
1741
|
edges: {
|
|
1779
|
-
shapeFactory:
|
|
1742
|
+
shapeFactory: Re(((s = t == null ? void 0 : t.edges) == null ? void 0 : s.shape) ?? {}),
|
|
1780
1743
|
priorityFn: e.edgesPriorityFn
|
|
1781
1744
|
}
|
|
1782
1745
|
};
|
|
1783
1746
|
};
|
|
1784
|
-
class
|
|
1747
|
+
class We {
|
|
1785
1748
|
constructor(e, o) {
|
|
1786
1749
|
i(this, "nodeIdGenerator", new z(
|
|
1787
1750
|
(e) => this.graph.getNode(e) !== null
|
|
@@ -1801,7 +1764,7 @@ class Ue {
|
|
|
1801
1764
|
* provides api for accessing viewport state
|
|
1802
1765
|
*/
|
|
1803
1766
|
i(this, "viewport");
|
|
1804
|
-
this.controller = e, this.defaults =
|
|
1767
|
+
this.controller = e, this.defaults = Ie(o), this.graph = e.graph, this.viewport = e.viewport;
|
|
1805
1768
|
}
|
|
1806
1769
|
/**
|
|
1807
1770
|
* attaches canvas to given element
|
|
@@ -1822,7 +1785,7 @@ class Ue {
|
|
|
1822
1785
|
addNode(e) {
|
|
1823
1786
|
const o = this.nodeIdGenerator.create(e.id);
|
|
1824
1787
|
if (this.graph.getNode(o) !== null)
|
|
1825
|
-
throw new
|
|
1788
|
+
throw new E("failed to add node with existing id");
|
|
1826
1789
|
if (this.controller.addNode({
|
|
1827
1790
|
id: o,
|
|
1828
1791
|
element: e.element,
|
|
@@ -1845,7 +1808,7 @@ class Ue {
|
|
|
1845
1808
|
*/
|
|
1846
1809
|
updateNode(e, o) {
|
|
1847
1810
|
if (this.graph.getNode(e) === null)
|
|
1848
|
-
throw new
|
|
1811
|
+
throw new E("failed to update nonexisting node");
|
|
1849
1812
|
return this.controller.updateNode(e, o ?? {}), this;
|
|
1850
1813
|
}
|
|
1851
1814
|
/**
|
|
@@ -1855,7 +1818,7 @@ class Ue {
|
|
|
1855
1818
|
*/
|
|
1856
1819
|
removeNode(e) {
|
|
1857
1820
|
if (this.graph.getNode(e) === null)
|
|
1858
|
-
throw new
|
|
1821
|
+
throw new E("failed to remove nonexisting node");
|
|
1859
1822
|
return this.controller.removeNode(e), this;
|
|
1860
1823
|
}
|
|
1861
1824
|
/**
|
|
@@ -1864,9 +1827,9 @@ class Ue {
|
|
|
1864
1827
|
markPort(e) {
|
|
1865
1828
|
const o = this.portIdGenerator.create(e.id);
|
|
1866
1829
|
if (this.graph.getPort(o) !== null)
|
|
1867
|
-
throw new
|
|
1830
|
+
throw new E("failed to add port with existing id");
|
|
1868
1831
|
if (this.graph.getNode(e.nodeId) === null)
|
|
1869
|
-
throw new
|
|
1832
|
+
throw new E("failed to set port on nonexisting node");
|
|
1870
1833
|
return this.controller.markPort({
|
|
1871
1834
|
id: o,
|
|
1872
1835
|
element: e.element,
|
|
@@ -1879,7 +1842,7 @@ class Ue {
|
|
|
1879
1842
|
*/
|
|
1880
1843
|
updatePort(e, o) {
|
|
1881
1844
|
if (this.graph.getPort(e) === null)
|
|
1882
|
-
throw new
|
|
1845
|
+
throw new E("failed to unset nonexisting port");
|
|
1883
1846
|
return this.controller.updatePort(e, o ?? {}), this;
|
|
1884
1847
|
}
|
|
1885
1848
|
/**
|
|
@@ -1888,7 +1851,7 @@ class Ue {
|
|
|
1888
1851
|
*/
|
|
1889
1852
|
unmarkPort(e) {
|
|
1890
1853
|
if (this.graph.getPort(e) === null)
|
|
1891
|
-
throw new
|
|
1854
|
+
throw new E("failed to unset nonexisting port");
|
|
1892
1855
|
return this.controller.unmarkPort(e), this;
|
|
1893
1856
|
}
|
|
1894
1857
|
/**
|
|
@@ -1897,11 +1860,11 @@ class Ue {
|
|
|
1897
1860
|
addEdge(e) {
|
|
1898
1861
|
const o = this.edgeIdGenerator.create(e.id);
|
|
1899
1862
|
if (this.graph.getEdge(o) !== null)
|
|
1900
|
-
throw new
|
|
1863
|
+
throw new E("failed to add edge with existing id");
|
|
1901
1864
|
if (this.graph.getPort(e.from) === null)
|
|
1902
|
-
throw new
|
|
1865
|
+
throw new E("failed to add edge from nonexisting port");
|
|
1903
1866
|
if (this.graph.getPort(e.to) === null)
|
|
1904
|
-
throw new
|
|
1867
|
+
throw new E("failed to add edge to nonexisting port");
|
|
1905
1868
|
return this.controller.addEdge({
|
|
1906
1869
|
id: o,
|
|
1907
1870
|
from: e.from,
|
|
@@ -1915,7 +1878,7 @@ class Ue {
|
|
|
1915
1878
|
*/
|
|
1916
1879
|
updateEdge(e, o) {
|
|
1917
1880
|
if (this.graph.getEdge(e) === null)
|
|
1918
|
-
throw new
|
|
1881
|
+
throw new E("failed to update nonexisting edge");
|
|
1919
1882
|
return this.controller.updateEdge(e, o ?? {}), this;
|
|
1920
1883
|
}
|
|
1921
1884
|
/**
|
|
@@ -1923,7 +1886,7 @@ class Ue {
|
|
|
1923
1886
|
*/
|
|
1924
1887
|
removeEdge(e) {
|
|
1925
1888
|
if (this.graph.getEdge(e) === null)
|
|
1926
|
-
throw new
|
|
1889
|
+
throw new E("failed to remove nonexisting edge");
|
|
1927
1890
|
return this.controller.removeEdge(e), this;
|
|
1928
1891
|
}
|
|
1929
1892
|
/**
|
|
@@ -1953,7 +1916,7 @@ class Ue {
|
|
|
1953
1916
|
this.controller.destroy();
|
|
1954
1917
|
}
|
|
1955
1918
|
}
|
|
1956
|
-
class
|
|
1919
|
+
class Fe {
|
|
1957
1920
|
constructor() {
|
|
1958
1921
|
i(this, "nodes", /* @__PURE__ */ new Map());
|
|
1959
1922
|
i(this, "ports", /* @__PURE__ */ new Map());
|
|
@@ -1961,42 +1924,33 @@ class Be {
|
|
|
1961
1924
|
i(this, "incommingEdges", /* @__PURE__ */ new Map());
|
|
1962
1925
|
i(this, "outcommingEdges", /* @__PURE__ */ new Map());
|
|
1963
1926
|
i(this, "cycleEdges", /* @__PURE__ */ new Map());
|
|
1964
|
-
i(this, "
|
|
1927
|
+
i(this, "afterNodeAddedEmitter");
|
|
1965
1928
|
i(this, "onAfterNodeAdded");
|
|
1966
|
-
i(this, "
|
|
1967
|
-
i(this, "
|
|
1968
|
-
i(this, "
|
|
1929
|
+
i(this, "afterNodeUpdatedEmitter");
|
|
1930
|
+
i(this, "onAfterNodeUpdated");
|
|
1931
|
+
i(this, "afterNodePriorityUpdatedEmitter");
|
|
1969
1932
|
i(this, "onAfterNodePriorityUpdated");
|
|
1970
|
-
i(this, "
|
|
1933
|
+
i(this, "beforeNodeRemovedEmitter");
|
|
1971
1934
|
i(this, "onBeforeNodeRemoved");
|
|
1972
|
-
i(this, "
|
|
1935
|
+
i(this, "afterPortAddedEmitter");
|
|
1973
1936
|
i(this, "onAfterPortAdded");
|
|
1974
|
-
i(this, "
|
|
1975
|
-
i(this, "
|
|
1976
|
-
i(this, "
|
|
1937
|
+
i(this, "afterPortUpdatedEmitter");
|
|
1938
|
+
i(this, "onAfterPortUpdated");
|
|
1939
|
+
i(this, "beforePortRemovedEmitter");
|
|
1977
1940
|
i(this, "onBeforePortRemoved");
|
|
1978
|
-
i(this, "
|
|
1941
|
+
i(this, "afterEdgeAddedEmitter");
|
|
1979
1942
|
i(this, "onAfterEdgeAdded");
|
|
1980
|
-
i(this, "
|
|
1943
|
+
i(this, "afterEdgeShapeUpdatedEmitter");
|
|
1981
1944
|
i(this, "onAfterEdgeShapeUpdated");
|
|
1982
|
-
i(this, "
|
|
1983
|
-
i(this, "
|
|
1984
|
-
i(this, "
|
|
1945
|
+
i(this, "afterEdgeUpdatedEmitter");
|
|
1946
|
+
i(this, "onAfterEdgeUpdated");
|
|
1947
|
+
i(this, "afterEdgePriorityUpdatedEmitter");
|
|
1985
1948
|
i(this, "onAfterEdgePriorityUpdated");
|
|
1986
|
-
i(this, "
|
|
1949
|
+
i(this, "beforeEdgeRemovedEmitter");
|
|
1987
1950
|
i(this, "onBeforeEdgeRemoved");
|
|
1988
|
-
i(this, "
|
|
1951
|
+
i(this, "beforeClearEmitter");
|
|
1989
1952
|
i(this, "onBeforeClear");
|
|
1990
|
-
[this.
|
|
1991
|
-
this.onAfterNodeCoordinatesUpdatedEmitter,
|
|
1992
|
-
this.onAfterNodeCoordinatesUpdated
|
|
1993
|
-
] = E(), [this.onAfterNodePriorityUpdatedEmitter, this.onAfterNodePriorityUpdated] = E(), [this.onBeforeNodeRemovedEmitter, this.onBeforeNodeRemoved] = E(), [this.onAfterPortAddedEmitter, this.onAfterPortAdded] = E(), [
|
|
1994
|
-
this.onAfterPortDirectionUpdatedEmitter,
|
|
1995
|
-
this.onAfterPortDirectionUpdated
|
|
1996
|
-
] = E(), [this.onBeforePortRemovedEmitter, this.onBeforePortRemoved] = E(), [this.onAfterEdgeAddedEmitter, this.onAfterEdgeAdded] = E(), [this.onAfterEdgeShapeUpdatedEmitter, this.onAfterEdgeShapeUpdated] = E(), [
|
|
1997
|
-
this.onAfterEdgeAdjacentPortsUpdatedEmitter,
|
|
1998
|
-
this.onAfterEdgeAdjacentPortsUpdated
|
|
1999
|
-
] = E(), [this.onAfterEdgePriorityUpdatedEmitter, this.onAfterEdgePriorityUpdated] = E(), [this.onBeforeEdgeRemovedEmitter, this.onBeforeEdgeRemoved] = E(), [this.onBeforeClearEmitter, this.onBeforeClear] = E();
|
|
1953
|
+
[this.afterNodeAddedEmitter, this.onAfterNodeAdded] = A(), [this.afterNodeUpdatedEmitter, this.onAfterNodeUpdated] = A(), [this.afterNodePriorityUpdatedEmitter, this.onAfterNodePriorityUpdated] = A(), [this.beforeNodeRemovedEmitter, this.onBeforeNodeRemoved] = A(), [this.afterPortAddedEmitter, this.onAfterPortAdded] = A(), [this.afterPortUpdatedEmitter, this.onAfterPortUpdated] = A(), [this.beforePortRemovedEmitter, this.onBeforePortRemoved] = A(), [this.afterEdgeAddedEmitter, this.onAfterEdgeAdded] = A(), [this.afterEdgeShapeUpdatedEmitter, this.onAfterEdgeShapeUpdated] = A(), [this.afterEdgeUpdatedEmitter, this.onAfterEdgeUpdated] = A(), [this.afterEdgePriorityUpdatedEmitter, this.onAfterEdgePriorityUpdated] = A(), [this.beforeEdgeRemovedEmitter, this.onBeforeEdgeRemoved] = A(), [this.beforeClearEmitter, this.onBeforeClear] = A();
|
|
2000
1954
|
}
|
|
2001
1955
|
addNode(e) {
|
|
2002
1956
|
const o = /* @__PURE__ */ new Map(), r = {
|
|
@@ -2007,7 +1961,7 @@ class Be {
|
|
|
2007
1961
|
priority: e.priority,
|
|
2008
1962
|
ports: o
|
|
2009
1963
|
};
|
|
2010
|
-
this.nodes.set(e.id, r), this.
|
|
1964
|
+
this.nodes.set(e.id, r), this.afterNodeAddedEmitter.emit(e.id);
|
|
2011
1965
|
}
|
|
2012
1966
|
getAllNodeIds() {
|
|
2013
1967
|
return Array.from(this.nodes.keys());
|
|
@@ -2015,30 +1969,26 @@ class Be {
|
|
|
2015
1969
|
getNode(e) {
|
|
2016
1970
|
return this.nodes.get(e);
|
|
2017
1971
|
}
|
|
2018
|
-
|
|
2019
|
-
const r = this.nodes.get(e);
|
|
2020
|
-
r.x = (o == null ? void 0 : o.x) ?? r.x, r.y = (o == null ? void 0 : o.y) ?? r.y, r.centerFn = o.centerFn ?? r.centerFn, this.onAfterNodeCoordinatesUpdatedEmitter.emit(e);
|
|
2021
|
-
}
|
|
2022
|
-
updateNodePriority(e, o) {
|
|
1972
|
+
updateNode(e, o) {
|
|
2023
1973
|
const r = this.nodes.get(e);
|
|
2024
|
-
r.priority = o, this.
|
|
1974
|
+
r.x = o.x ?? r.x, r.y = o.y ?? r.y, r.centerFn = o.centerFn ?? r.centerFn, o.priority !== void 0 && (r.priority = o.priority, this.afterNodePriorityUpdatedEmitter.emit(e)), this.afterNodeUpdatedEmitter.emit(e);
|
|
2025
1975
|
}
|
|
2026
1976
|
removeNode(e) {
|
|
2027
|
-
this.
|
|
1977
|
+
this.beforeNodeRemovedEmitter.emit(e), this.nodes.delete(e);
|
|
2028
1978
|
}
|
|
2029
1979
|
addPort(e) {
|
|
2030
1980
|
this.ports.set(e.id, {
|
|
2031
1981
|
element: e.element,
|
|
2032
1982
|
direction: e.direction,
|
|
2033
1983
|
nodeId: e.nodeId
|
|
2034
|
-
}), this.cycleEdges.set(e.id, /* @__PURE__ */ new Set()), this.incommingEdges.set(e.id, /* @__PURE__ */ new Set()), this.outcommingEdges.set(e.id, /* @__PURE__ */ new Set()), this.nodes.get(e.nodeId).ports.set(e.id, e.element), this.
|
|
1984
|
+
}), this.cycleEdges.set(e.id, /* @__PURE__ */ new Set()), this.incommingEdges.set(e.id, /* @__PURE__ */ new Set()), this.outcommingEdges.set(e.id, /* @__PURE__ */ new Set()), this.nodes.get(e.nodeId).ports.set(e.id, e.element), this.afterPortAddedEmitter.emit(e.id);
|
|
2035
1985
|
}
|
|
2036
1986
|
getPort(e) {
|
|
2037
1987
|
return this.ports.get(e);
|
|
2038
1988
|
}
|
|
2039
|
-
|
|
1989
|
+
updatePort(e, o) {
|
|
2040
1990
|
const r = this.ports.get(e);
|
|
2041
|
-
r.direction = o, this.
|
|
1991
|
+
r.direction = o.direction ?? r.direction, this.afterPortUpdatedEmitter.emit(e);
|
|
2042
1992
|
}
|
|
2043
1993
|
getAllPortIds() {
|
|
2044
1994
|
return Array.from(this.ports.keys());
|
|
@@ -2050,28 +2000,24 @@ class Be {
|
|
|
2050
2000
|
}
|
|
2051
2001
|
removePort(e) {
|
|
2052
2002
|
const o = this.ports.get(e).nodeId;
|
|
2053
|
-
this.
|
|
2003
|
+
this.beforePortRemovedEmitter.emit(e), this.nodes.get(o).ports.delete(e), this.ports.delete(e);
|
|
2054
2004
|
}
|
|
2055
2005
|
addEdge(e) {
|
|
2056
|
-
this.addEdgeInternal(e), this.
|
|
2057
|
-
}
|
|
2058
|
-
updateEdgeShape(e, o) {
|
|
2059
|
-
const r = this.edges.get(e);
|
|
2060
|
-
r.shape = o, this.onAfterEdgeShapeUpdatedEmitter.emit(e);
|
|
2006
|
+
this.addEdgeInternal(e), this.afterEdgeAddedEmitter.emit(e.id);
|
|
2061
2007
|
}
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2008
|
+
updateEdge(e, o) {
|
|
2009
|
+
if (o.from !== void 0 || o.to !== void 0) {
|
|
2010
|
+
const n = this.edges.get(e);
|
|
2011
|
+
this.removeEdgeInternal(e), this.addEdgeInternal({
|
|
2012
|
+
id: e,
|
|
2013
|
+
from: o.from ?? n.from,
|
|
2014
|
+
to: o.to ?? n.to,
|
|
2015
|
+
shape: n.shape,
|
|
2016
|
+
priority: n.priority
|
|
2017
|
+
});
|
|
2018
|
+
}
|
|
2073
2019
|
const r = this.edges.get(e);
|
|
2074
|
-
r.priority = o, this.
|
|
2020
|
+
o.shape !== void 0 && (r.shape = o.shape, this.afterEdgeShapeUpdatedEmitter.emit(e)), o.priority !== void 0 && (r.priority = o.priority, this.afterEdgePriorityUpdatedEmitter.emit(e)), this.afterEdgeUpdatedEmitter.emit(e);
|
|
2075
2021
|
}
|
|
2076
2022
|
getAllEdgeIds() {
|
|
2077
2023
|
return Array.from(this.edges.keys());
|
|
@@ -2080,10 +2026,10 @@ class Be {
|
|
|
2080
2026
|
return this.edges.get(e);
|
|
2081
2027
|
}
|
|
2082
2028
|
removeEdge(e) {
|
|
2083
|
-
this.
|
|
2029
|
+
this.beforeEdgeRemovedEmitter.emit(e), this.removeEdgeInternal(e);
|
|
2084
2030
|
}
|
|
2085
2031
|
clear() {
|
|
2086
|
-
this.
|
|
2032
|
+
this.beforeClearEmitter.emit(), this.incommingEdges.clear(), this.outcommingEdges.clear(), this.cycleEdges.clear(), this.edges.clear(), this.ports.clear(), this.nodes.clear();
|
|
2087
2033
|
}
|
|
2088
2034
|
getPortIncomingEdgeIds(e) {
|
|
2089
2035
|
return Array.from(this.incommingEdges.get(e));
|
|
@@ -2142,22 +2088,24 @@ class Be {
|
|
|
2142
2088
|
this.cycleEdges.get(r).delete(e), this.cycleEdges.get(n).delete(e), this.incommingEdges.get(r).delete(e), this.incommingEdges.get(n).delete(e), this.outcommingEdges.get(r).delete(e), this.outcommingEdges.get(n).delete(e), this.edges.delete(e);
|
|
2143
2089
|
}
|
|
2144
2090
|
}
|
|
2145
|
-
const
|
|
2091
|
+
const O = (t) => ({
|
|
2146
2092
|
scale: 1 / t.scale,
|
|
2147
2093
|
x: -t.x / t.scale,
|
|
2148
2094
|
y: -t.y / t.scale
|
|
2149
|
-
}),
|
|
2095
|
+
}), q = {
|
|
2150
2096
|
scale: 1,
|
|
2151
2097
|
x: 0,
|
|
2152
2098
|
y: 0
|
|
2153
2099
|
};
|
|
2154
|
-
class
|
|
2100
|
+
class Be {
|
|
2155
2101
|
constructor() {
|
|
2156
|
-
i(this, "viewportMatrix",
|
|
2157
|
-
i(this, "contentMatrix",
|
|
2158
|
-
i(this, "
|
|
2159
|
-
i(this, "
|
|
2160
|
-
|
|
2102
|
+
i(this, "viewportMatrix", q);
|
|
2103
|
+
i(this, "contentMatrix", q);
|
|
2104
|
+
i(this, "afterUpdateEmitter");
|
|
2105
|
+
i(this, "onAfterUpdated");
|
|
2106
|
+
i(this, "beforeUpdateEmitter");
|
|
2107
|
+
i(this, "onBeforeUpdated");
|
|
2108
|
+
[this.afterUpdateEmitter, this.onAfterUpdated] = A(), [this.beforeUpdateEmitter, this.onBeforeUpdated] = A();
|
|
2161
2109
|
}
|
|
2162
2110
|
getViewportMatrix() {
|
|
2163
2111
|
return this.viewportMatrix;
|
|
@@ -2166,21 +2114,53 @@ class ke {
|
|
|
2166
2114
|
return this.contentMatrix;
|
|
2167
2115
|
}
|
|
2168
2116
|
patchViewportMatrix(e) {
|
|
2169
|
-
this.viewportMatrix = {
|
|
2117
|
+
this.beforeUpdateEmitter.emit(), this.viewportMatrix = {
|
|
2170
2118
|
scale: e.scale ?? this.viewportMatrix.scale,
|
|
2171
2119
|
x: e.x ?? this.viewportMatrix.x,
|
|
2172
2120
|
y: e.y ?? this.viewportMatrix.y
|
|
2173
|
-
}, this.contentMatrix =
|
|
2121
|
+
}, this.contentMatrix = O(this.viewportMatrix), this.afterUpdateEmitter.emit();
|
|
2174
2122
|
}
|
|
2175
2123
|
patchContentMatrix(e) {
|
|
2176
|
-
this.contentMatrix = {
|
|
2124
|
+
this.beforeUpdateEmitter.emit(), this.contentMatrix = {
|
|
2177
2125
|
scale: e.scale ?? this.contentMatrix.scale,
|
|
2178
2126
|
x: e.x ?? this.contentMatrix.x,
|
|
2179
2127
|
y: e.y ?? this.contentMatrix.y
|
|
2180
|
-
}, this.viewportMatrix =
|
|
2128
|
+
}, this.viewportMatrix = O(this.contentMatrix), this.afterUpdateEmitter.emit();
|
|
2129
|
+
}
|
|
2130
|
+
}
|
|
2131
|
+
class j {
|
|
2132
|
+
constructor(e) {
|
|
2133
|
+
i(this, "elementToNodeId", /* @__PURE__ */ new Map());
|
|
2134
|
+
i(this, "nodesResizeObserver");
|
|
2135
|
+
i(this, "onAfterNodeAdded", (e) => {
|
|
2136
|
+
const o = this.canvas.graph.getNode(e);
|
|
2137
|
+
this.elementToNodeId.set(o.element, e), this.nodesResizeObserver.observe(o.element);
|
|
2138
|
+
});
|
|
2139
|
+
i(this, "onBeforeNodeRemoved", (e) => {
|
|
2140
|
+
const o = this.canvas.graph.getNode(e);
|
|
2141
|
+
this.elementToNodeId.delete(o.element), this.nodesResizeObserver.unobserve(o.element);
|
|
2142
|
+
});
|
|
2143
|
+
i(this, "onBeforeClear", () => {
|
|
2144
|
+
this.nodesResizeObserver.disconnect(), this.elementToNodeId.clear();
|
|
2145
|
+
});
|
|
2146
|
+
this.canvas = e, this.nodesResizeObserver = new ResizeObserver((o) => {
|
|
2147
|
+
o.forEach((r) => {
|
|
2148
|
+
const n = r.target;
|
|
2149
|
+
this.handleNodeResize(n);
|
|
2150
|
+
});
|
|
2151
|
+
}), this.canvas.graph.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.canvas.graph.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.canvas.graph.onBeforeClear.subscribe(this.onBeforeClear);
|
|
2152
|
+
}
|
|
2153
|
+
static configure(e) {
|
|
2154
|
+
new j(e);
|
|
2155
|
+
}
|
|
2156
|
+
handleNodeResize(e) {
|
|
2157
|
+
const o = this.elementToNodeId.get(e);
|
|
2158
|
+
this.canvas.updateNode(o), this.canvas.graph.getNodeAdjacentEdgeIds(o).forEach((n) => {
|
|
2159
|
+
this.canvas.updateEdge(n);
|
|
2160
|
+
});
|
|
2181
2161
|
}
|
|
2182
2162
|
}
|
|
2183
|
-
class
|
|
2163
|
+
class ze {
|
|
2184
2164
|
constructor() {
|
|
2185
2165
|
i(this, "canvasDefaults", {});
|
|
2186
2166
|
i(this, "dragOptions");
|
|
@@ -2236,40 +2216,40 @@ class Ye {
|
|
|
2236
2216
|
*/
|
|
2237
2217
|
build() {
|
|
2238
2218
|
let e = this.boxRenderingTrigger;
|
|
2239
|
-
this.virtualScrollOptions !== void 0 && e === void 0 && (e = new
|
|
2240
|
-
const o = new
|
|
2219
|
+
this.virtualScrollOptions !== void 0 && e === void 0 && (e = new te());
|
|
2220
|
+
const o = new Fe(), r = new Be();
|
|
2241
2221
|
let n = new Ae(o, r);
|
|
2242
|
-
e !== void 0 && (n = new
|
|
2243
|
-
let h = new
|
|
2222
|
+
e !== void 0 && (n = new pe(n, o, e));
|
|
2223
|
+
let h = new ne(
|
|
2244
2224
|
o,
|
|
2245
2225
|
r,
|
|
2246
2226
|
n
|
|
2247
2227
|
);
|
|
2248
|
-
this.
|
|
2228
|
+
this.hasDraggableNode && (h = new de(
|
|
2249
2229
|
h,
|
|
2250
2230
|
this.dragOptions
|
|
2251
|
-
)), this.virtualScrollOptions !== void 0 ? h = new
|
|
2231
|
+
)), this.virtualScrollOptions !== void 0 ? h = new fe(
|
|
2252
2232
|
h,
|
|
2253
2233
|
e,
|
|
2254
2234
|
this.transformOptions,
|
|
2255
2235
|
this.virtualScrollOptions
|
|
2256
|
-
) : this.hasTransformableViewport && (h = new
|
|
2236
|
+
) : this.hasTransformableViewport && (h = new ee(
|
|
2257
2237
|
h,
|
|
2258
2238
|
this.transformOptions
|
|
2259
2239
|
));
|
|
2260
|
-
const s = new
|
|
2261
|
-
return this.reset(), s;
|
|
2240
|
+
const s = new We(h, this.canvasDefaults);
|
|
2241
|
+
return this.hasResizeReactiveNodes && j.configure(s), this.reset(), s;
|
|
2262
2242
|
}
|
|
2263
2243
|
reset() {
|
|
2264
2244
|
this.canvasDefaults = {}, this.dragOptions = void 0, this.transformOptions = void 0, this.virtualScrollOptions = void 0, this.hasDraggableNode = !1, this.hasTransformableViewport = !1, this.hasResizeReactiveNodes = !1, this.boxRenderingTrigger = void 0;
|
|
2265
2245
|
}
|
|
2266
2246
|
}
|
|
2267
2247
|
export {
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2248
|
+
De as BezierEdgeShape,
|
|
2249
|
+
ze as CanvasBuilder,
|
|
2250
|
+
te as EventSubject,
|
|
2251
|
+
Ce as HorizontalEdgeShape,
|
|
2252
|
+
E as HtmlGraphError,
|
|
2253
|
+
Ue as StraightEdgeShape,
|
|
2254
|
+
$e as VerticalEdgeShape
|
|
2275
2255
|
};
|