@html-graph/html-graph 2.4.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -8
- package/dist/html-graph.d.ts +5 -50
- package/dist/html-graph.js +395 -478
- package/dist/html-graph.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/html-graph.js
CHANGED
|
@@ -4,44 +4,19 @@ var i = (t, e, o) => re(t, typeof e != "symbol" ? e + "" : e, o);
|
|
|
4
4
|
class ie {
|
|
5
5
|
constructor(e) {
|
|
6
6
|
i(this, "onAfterNodeAdded");
|
|
7
|
-
/**
|
|
8
|
-
* @deprecated
|
|
9
|
-
* use onAfterNodeUpdated instead
|
|
10
|
-
*/
|
|
11
|
-
i(this, "onAfterNodeCoordinatesUpdated");
|
|
12
7
|
i(this, "onAfterNodeUpdated");
|
|
13
8
|
i(this, "onAfterNodePriorityUpdated");
|
|
14
9
|
i(this, "onBeforeNodeRemoved");
|
|
15
10
|
i(this, "onAfterPortMarked");
|
|
16
|
-
/**
|
|
17
|
-
* @deprecated
|
|
18
|
-
* use onAfterPortMarked instead
|
|
19
|
-
*/
|
|
20
|
-
i(this, "onAfterPortAdded");
|
|
21
11
|
i(this, "onAfterPortUpdated");
|
|
22
|
-
/**
|
|
23
|
-
* @deprecated
|
|
24
|
-
* use onAfterPortUpdated instead
|
|
25
|
-
*/
|
|
26
|
-
i(this, "onAfterPortDirectionUpdated");
|
|
27
12
|
i(this, "onBeforePortUnmarked");
|
|
28
|
-
/**
|
|
29
|
-
* @deprecated
|
|
30
|
-
* use onBeforePortUnmarked instead
|
|
31
|
-
*/
|
|
32
|
-
i(this, "onBeforePortRemoved");
|
|
33
13
|
i(this, "onAfterEdgeAdded");
|
|
34
14
|
i(this, "onAfterEdgeShapeUpdated");
|
|
35
15
|
i(this, "onAfterEdgeUpdated");
|
|
36
|
-
/**
|
|
37
|
-
* @deprecated
|
|
38
|
-
* use onAfterEdgeUpdated instead
|
|
39
|
-
*/
|
|
40
|
-
i(this, "onAfterEdgeAdjacentPortsUpdated");
|
|
41
16
|
i(this, "onAfterEdgePriorityUpdated");
|
|
42
17
|
i(this, "onBeforeEdgeRemoved");
|
|
43
18
|
i(this, "onBeforeClear");
|
|
44
|
-
this.graphStore = e, this.onAfterNodeAdded = this.graphStore.onAfterNodeAdded, this.onAfterNodeUpdated = this.graphStore.onAfterNodeUpdated, this.
|
|
19
|
+
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;
|
|
45
20
|
}
|
|
46
21
|
getNode(e) {
|
|
47
22
|
const o = this.graphStore.getNode(e);
|
|
@@ -70,14 +45,6 @@ class ie {
|
|
|
70
45
|
getNodePortIds(e) {
|
|
71
46
|
return this.graphStore.getNodePortIds(e) ?? null;
|
|
72
47
|
}
|
|
73
|
-
/**
|
|
74
|
-
* @deprecated
|
|
75
|
-
* use graph.getPort()?.nodeId ?? null instead
|
|
76
|
-
*/
|
|
77
|
-
getPortNodeId(e) {
|
|
78
|
-
var o;
|
|
79
|
-
return ((o = this.graphStore.getPort(e)) == null ? void 0 : o.nodeId) ?? null;
|
|
80
|
-
}
|
|
81
48
|
getAllEdgeIds() {
|
|
82
49
|
return this.graphStore.getAllEdgeIds();
|
|
83
50
|
}
|
|
@@ -179,12 +146,6 @@ class ne {
|
|
|
179
146
|
this.onAfterEdgePriorityUpdated
|
|
180
147
|
), this.graphStore.onBeforeEdgeRemoved.subscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.subscribe(this.onBeforeClear), this.graph = new ie(this.graphStore), this.viewport = new se(this.viewportStore);
|
|
181
148
|
}
|
|
182
|
-
attach(e) {
|
|
183
|
-
this.htmlView.attach(e);
|
|
184
|
-
}
|
|
185
|
-
detach() {
|
|
186
|
-
this.htmlView.detach();
|
|
187
|
-
}
|
|
188
149
|
addNode(e) {
|
|
189
150
|
this.graphStore.addNode(e);
|
|
190
151
|
}
|
|
@@ -232,18 +193,18 @@ class ne {
|
|
|
232
193
|
}
|
|
233
194
|
}
|
|
234
195
|
const U = (t, e, o) => {
|
|
235
|
-
const { x: r, y:
|
|
236
|
-
return e >= r && e <= r +
|
|
196
|
+
const { x: r, y: s, width: d, height: n } = t.getBoundingClientRect();
|
|
197
|
+
return e >= r && e <= r + d && o >= s && o <= s + n;
|
|
237
198
|
}, $ = (t, e, o) => e >= 0 && e <= t.innerWidth && o >= 0 && o <= t.innerHeight, R = (t, e) => {
|
|
238
199
|
e !== null ? t.style.cursor = e : t.style.removeProperty("cursor");
|
|
239
200
|
}, he = (t) => {
|
|
240
|
-
var g, f, x,
|
|
201
|
+
var g, f, x, y, p, S;
|
|
241
202
|
const e = ((g = t == null ? void 0 : t.events) == null ? void 0 : g.onNodeDrag) ?? (() => {
|
|
242
203
|
}), o = ((f = t == null ? void 0 : t.events) == null ? void 0 : f.onBeforeNodeDrag) ?? (() => !0), r = ((x = t == null ? void 0 : t.events) == null ? void 0 : x.onNodeDragFinished) ?? (() => {
|
|
243
|
-
}),
|
|
204
|
+
}), s = (t == null ? void 0 : t.moveOnTop) === !1, d = (y = t == null ? void 0 : t.mouse) == null ? void 0 : y.dragCursor, n = d !== void 0 ? d : "grab", h = (p = t == null ? void 0 : t.mouse) == null ? void 0 : p.mouseDownEventVerifier, c = h !== void 0 ? h : (N) => N.button === 0, a = (S = t == null ? void 0 : t.mouse) == null ? void 0 : S.mouseUpEventVerifier;
|
|
244
205
|
return {
|
|
245
|
-
freezePriority:
|
|
246
|
-
dragCursor:
|
|
206
|
+
freezePriority: s,
|
|
207
|
+
dragCursor: n,
|
|
247
208
|
mouseDownEventVerifier: c,
|
|
248
209
|
mouseUpEventVerifier: a !== void 0 ? a : (N) => N.button === 0,
|
|
249
210
|
onNodeDrag: e,
|
|
@@ -252,15 +213,14 @@ const U = (t, e, o) => {
|
|
|
252
213
|
};
|
|
253
214
|
};
|
|
254
215
|
class de {
|
|
255
|
-
constructor(e, o) {
|
|
216
|
+
constructor(e, o, r) {
|
|
256
217
|
i(this, "graph");
|
|
257
218
|
i(this, "viewport");
|
|
258
219
|
i(this, "maxNodePriority", 0);
|
|
259
220
|
i(this, "nodes", /* @__PURE__ */ new Map());
|
|
260
221
|
i(this, "grabbedNodeId", null);
|
|
261
|
-
i(this, "element", null);
|
|
262
222
|
i(this, "onWindowMouseMove", (e) => {
|
|
263
|
-
if (
|
|
223
|
+
if (!U(this.element, e.clientX, e.clientY) || !$(this.window, e.clientX, e.clientY)) {
|
|
264
224
|
this.cancelMouseDrag();
|
|
265
225
|
return;
|
|
266
226
|
}
|
|
@@ -273,13 +233,13 @@ class de {
|
|
|
273
233
|
if (e.touches.length !== 1)
|
|
274
234
|
return;
|
|
275
235
|
const o = e.touches[0];
|
|
276
|
-
if (
|
|
236
|
+
if (!U(this.element, o.clientX, o.clientY) || !$(this.window, o.clientX, o.clientY)) {
|
|
277
237
|
this.cancelTouchDrag();
|
|
278
238
|
return;
|
|
279
239
|
}
|
|
280
240
|
if (this.grabbedNodeId !== null && this.previousTouchCoords !== null) {
|
|
281
|
-
const r = o.clientX - this.previousTouchCoords.x,
|
|
282
|
-
this.dragNode(this.grabbedNodeId, r,
|
|
241
|
+
const r = o.clientX - this.previousTouchCoords.x, s = o.clientY - this.previousTouchCoords.y;
|
|
242
|
+
this.dragNode(this.grabbedNodeId, r, s), this.previousTouchCoords = {
|
|
283
243
|
x: e.touches[0].clientX,
|
|
284
244
|
y: e.touches[0].clientY
|
|
285
245
|
};
|
|
@@ -291,39 +251,33 @@ class de {
|
|
|
291
251
|
i(this, "previousTouchCoords", null);
|
|
292
252
|
i(this, "window", window);
|
|
293
253
|
i(this, "options");
|
|
294
|
-
this.canvas = e, this.viewport = this.canvas.viewport, this.graph = this.canvas.graph, this.options = he(
|
|
295
|
-
}
|
|
296
|
-
attach(e) {
|
|
297
|
-
this.detach(), this.element = e, this.canvas.attach(this.element);
|
|
298
|
-
}
|
|
299
|
-
detach() {
|
|
300
|
-
this.canvas.detach(), this.element !== null && (this.element = null);
|
|
254
|
+
this.canvas = e, this.element = o, this.viewport = this.canvas.viewport, this.graph = this.canvas.graph, this.options = he(r ?? {});
|
|
301
255
|
}
|
|
302
256
|
addNode(e) {
|
|
303
257
|
this.canvas.addNode(e), this.updateMaxNodePriority(e.id);
|
|
304
|
-
const o = (
|
|
305
|
-
if (
|
|
258
|
+
const o = (s) => {
|
|
259
|
+
if (!this.options.mouseDownEventVerifier(s))
|
|
306
260
|
return;
|
|
307
|
-
const
|
|
261
|
+
const d = this.graph.getNode(e.id);
|
|
308
262
|
this.options.onBeforeNodeDrag({
|
|
309
263
|
nodeId: e.id,
|
|
310
264
|
element: e.element,
|
|
311
|
-
x:
|
|
312
|
-
y:
|
|
313
|
-
}) && (
|
|
314
|
-
}, r = (
|
|
315
|
-
if (
|
|
265
|
+
x: d.x,
|
|
266
|
+
y: d.y
|
|
267
|
+
}) && (s.stopImmediatePropagation(), this.grabbedNodeId = e.id, R(this.element, this.options.dragCursor), this.moveNodeOnTop(e.id), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.window.addEventListener("mousemove", this.onWindowMouseMove));
|
|
268
|
+
}, r = (s) => {
|
|
269
|
+
if (s.touches.length !== 1)
|
|
316
270
|
return;
|
|
317
|
-
|
|
318
|
-
x:
|
|
319
|
-
y:
|
|
271
|
+
s.stopImmediatePropagation(), this.previousTouchCoords = {
|
|
272
|
+
x: s.touches[0].clientX,
|
|
273
|
+
y: s.touches[0].clientY
|
|
320
274
|
};
|
|
321
|
-
const
|
|
275
|
+
const d = this.graph.getNode(e.id);
|
|
322
276
|
this.options.onBeforeNodeDrag({
|
|
323
277
|
nodeId: e.id,
|
|
324
278
|
element: e.element,
|
|
325
|
-
x:
|
|
326
|
-
y:
|
|
279
|
+
x: d.x,
|
|
280
|
+
y: d.y
|
|
327
281
|
}) && (this.grabbedNodeId = e.id, this.moveNodeOnTop(e.id), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish));
|
|
328
282
|
};
|
|
329
283
|
this.nodes.set(e.id, {
|
|
@@ -369,16 +323,16 @@ class de {
|
|
|
369
323
|
}), this.nodes.clear(), this.maxNodePriority = 0;
|
|
370
324
|
}
|
|
371
325
|
destroy() {
|
|
372
|
-
this.
|
|
326
|
+
this.clear(), this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.canvas.destroy();
|
|
373
327
|
}
|
|
374
328
|
dragNode(e, o, r) {
|
|
375
|
-
const
|
|
376
|
-
if (
|
|
329
|
+
const s = this.graph.getNode(e);
|
|
330
|
+
if (s === null)
|
|
377
331
|
return;
|
|
378
|
-
const
|
|
332
|
+
const d = this.canvas.viewport.getContentMatrix(), n = d.scale * s.x + d.x, h = d.scale * s.y + d.y, c = n + o, a = h + r, l = this.canvas.viewport.getViewportMatrix(), g = l.scale * c + l.x, f = l.scale * a + l.y;
|
|
379
333
|
this.canvas.updateNode(e, { x: g, y: f }), this.options.onNodeDrag({
|
|
380
334
|
nodeId: e,
|
|
381
|
-
element:
|
|
335
|
+
element: s.element,
|
|
382
336
|
x: g,
|
|
383
337
|
y: f
|
|
384
338
|
});
|
|
@@ -392,8 +346,8 @@ class de {
|
|
|
392
346
|
return;
|
|
393
347
|
this.maxNodePriority += 2, this.updateNode(e, { priority: this.maxNodePriority });
|
|
394
348
|
const o = this.maxNodePriority - 1;
|
|
395
|
-
this.graph.getNodeAdjacentEdgeIds(e).forEach((
|
|
396
|
-
this.updateEdge(
|
|
349
|
+
this.graph.getNodeAdjacentEdgeIds(e).forEach((s) => {
|
|
350
|
+
this.updateEdge(s, { priority: o });
|
|
397
351
|
});
|
|
398
352
|
}
|
|
399
353
|
cancelMouseDrag() {
|
|
@@ -403,7 +357,7 @@ class de {
|
|
|
403
357
|
element: e.element,
|
|
404
358
|
x: e.x,
|
|
405
359
|
y: e.y
|
|
406
|
-
}), this.grabbedNodeId = null,
|
|
360
|
+
}), this.grabbedNodeId = null, R(this.element, null), this.removeMouseDragListeners();
|
|
407
361
|
}
|
|
408
362
|
removeMouseDragListeners() {
|
|
409
363
|
this.window.removeEventListener("mouseup", this.onWindowMouseUp), this.window.removeEventListener("mousemove", this.onWindowMouseMove);
|
|
@@ -423,29 +377,29 @@ class de {
|
|
|
423
377
|
}
|
|
424
378
|
}
|
|
425
379
|
const ce = (t) => {
|
|
426
|
-
const e = t.minX !== null ? t.minX : -1 / 0, o = t.maxX !== null ? t.maxX : 1 / 0, r = t.minY !== null ? t.minY : -1 / 0,
|
|
427
|
-
return (
|
|
428
|
-
let
|
|
429
|
-
|
|
430
|
-
const c =
|
|
431
|
-
|
|
432
|
-
const l =
|
|
433
|
-
return
|
|
380
|
+
const e = t.minX !== null ? t.minX : -1 / 0, o = t.maxX !== null ? t.maxX : 1 / 0, r = t.minY !== null ? t.minY : -1 / 0, s = t.maxY !== null ? t.maxY : 1 / 0;
|
|
381
|
+
return (d) => {
|
|
382
|
+
let n = d.nextTransform.x, h = d.nextTransform.y;
|
|
383
|
+
n < e && n < d.prevTransform.x && (n = Math.min(d.prevTransform.x, e));
|
|
384
|
+
const c = d.canvasWidth * d.prevTransform.scale, a = o - c;
|
|
385
|
+
n > a && n > d.prevTransform.x && (n = Math.max(d.prevTransform.x, a)), h < r && h < d.prevTransform.y && (h = Math.min(d.prevTransform.y, r));
|
|
386
|
+
const l = d.canvasHeight * d.prevTransform.scale, g = s - l;
|
|
387
|
+
return h > g && h > d.prevTransform.y && (h = Math.max(d.prevTransform.y, g)), { scale: d.nextTransform.scale, x: n, y: h };
|
|
434
388
|
};
|
|
435
389
|
}, ae = (t) => {
|
|
436
|
-
const e = t.maxContentScale, o = t.minContentScale, r = e !== null ? 1 / e : 0,
|
|
437
|
-
return (
|
|
438
|
-
const
|
|
439
|
-
let c =
|
|
440
|
-
if (
|
|
441
|
-
c = Math.max(
|
|
442
|
-
const g = (c -
|
|
443
|
-
a =
|
|
390
|
+
const e = t.maxContentScale, o = t.minContentScale, r = e !== null ? 1 / e : 0, s = o !== null ? 1 / o : 1 / 0;
|
|
391
|
+
return (d) => {
|
|
392
|
+
const n = d.prevTransform, h = d.nextTransform;
|
|
393
|
+
let c = h.scale, a = h.x, l = h.y;
|
|
394
|
+
if (h.scale > s && h.scale > n.scale) {
|
|
395
|
+
c = Math.max(n.scale, s), a = n.x, l = n.y;
|
|
396
|
+
const g = (c - n.scale) / (h.scale - n.scale);
|
|
397
|
+
a = n.x + (h.x - n.x) * g, l = n.y + (h.y - n.y) * g;
|
|
444
398
|
}
|
|
445
|
-
if (
|
|
446
|
-
c = Math.min(
|
|
447
|
-
const g = (c -
|
|
448
|
-
a =
|
|
399
|
+
if (h.scale < r && h.scale < n.scale) {
|
|
400
|
+
c = Math.min(n.scale, r), a = n.x, l = n.y;
|
|
401
|
+
const g = (c - n.scale) / (h.scale - n.scale);
|
|
402
|
+
a = n.x + (h.x - n.x) * g, l = n.y + (h.y - n.y) * g;
|
|
449
403
|
}
|
|
450
404
|
return {
|
|
451
405
|
scale: c,
|
|
@@ -479,27 +433,27 @@ const ce = (t) => {
|
|
|
479
433
|
});
|
|
480
434
|
}
|
|
481
435
|
}, ge = (t) => {
|
|
482
|
-
var
|
|
483
|
-
const e = (
|
|
484
|
-
let
|
|
485
|
-
r !== void 0 ? Array.isArray(r) ?
|
|
436
|
+
var y, p, S, N, z, M, V, L, G, _, J, K;
|
|
437
|
+
const e = (y = t == null ? void 0 : t.scale) == null ? void 0 : y.mouseWheelSensitivity, o = e !== void 0 ? e : 1.2, r = t == null ? void 0 : t.transformPreprocessor;
|
|
438
|
+
let s;
|
|
439
|
+
r !== void 0 ? Array.isArray(r) ? s = le(
|
|
486
440
|
r.map(
|
|
487
|
-
(
|
|
441
|
+
(P) => Q(P)
|
|
488
442
|
)
|
|
489
|
-
) :
|
|
490
|
-
const
|
|
491
|
-
}),
|
|
492
|
-
}), c = (
|
|
443
|
+
) : s = Q(r) : s = (P) => P.nextTransform;
|
|
444
|
+
const d = ((p = t == null ? void 0 : t.shift) == null ? void 0 : p.cursor) !== void 0 ? t.shift.cursor : "grab", n = ((S = t == null ? void 0 : t.events) == null ? void 0 : S.onBeforeTransformChange) ?? (() => {
|
|
445
|
+
}), h = ((N = t == null ? void 0 : t.events) == null ? void 0 : N.onTransformChange) ?? (() => {
|
|
446
|
+
}), c = (z = t == null ? void 0 : t.shift) == null ? void 0 : z.mouseDownEventVerifier, a = c !== void 0 ? c : (P) => P.button === 0, l = (M = t == null ? void 0 : t.shift) == null ? void 0 : M.mouseUpEventVerifier, g = l !== void 0 ? l : (P) => P.button === 0, f = (V = t == null ? void 0 : t.scale) == null ? void 0 : V.mouseWheelEventVerifier, x = f !== void 0 ? f : () => !0;
|
|
493
447
|
return {
|
|
494
448
|
wheelSensitivity: o,
|
|
495
449
|
onTransformStarted: ((L = t == null ? void 0 : t.events) == null ? void 0 : L.onTransformStarted) ?? (() => {
|
|
496
450
|
}),
|
|
497
451
|
onTransformFinished: ((G = t == null ? void 0 : t.events) == null ? void 0 : G.onTransformFinished) ?? (() => {
|
|
498
452
|
}),
|
|
499
|
-
onBeforeTransformChange:
|
|
500
|
-
onTransformChange:
|
|
501
|
-
transformPreprocessor:
|
|
502
|
-
shiftCursor:
|
|
453
|
+
onBeforeTransformChange: n,
|
|
454
|
+
onTransformChange: h,
|
|
455
|
+
transformPreprocessor: s,
|
|
456
|
+
shiftCursor: d,
|
|
503
457
|
mouseDownEventVerifier: a,
|
|
504
458
|
mouseUpEventVerifier: g,
|
|
505
459
|
mouseWheelEventVerifier: x,
|
|
@@ -511,19 +465,19 @@ const ce = (t) => {
|
|
|
511
465
|
};
|
|
512
466
|
}, C = (t) => {
|
|
513
467
|
const e = [], o = t.touches.length;
|
|
514
|
-
for (let
|
|
515
|
-
e.push([t.touches[
|
|
468
|
+
for (let h = 0; h < o; h++)
|
|
469
|
+
e.push([t.touches[h].clientX, t.touches[h].clientY]);
|
|
516
470
|
const r = e.reduce(
|
|
517
|
-
(
|
|
471
|
+
(h, c) => [h[0] + c[0], h[1] + c[1]],
|
|
518
472
|
[0, 0]
|
|
519
|
-
),
|
|
520
|
-
(
|
|
473
|
+
), s = [r[0] / o, r[1] / o], n = e.map((h) => [h[0] - s[0], h[1] - s[1]]).reduce(
|
|
474
|
+
(h, c) => h + Math.sqrt(c[0] * c[0] + c[1] * c[1]),
|
|
521
475
|
0
|
|
522
476
|
);
|
|
523
477
|
return {
|
|
524
|
-
x:
|
|
525
|
-
y:
|
|
526
|
-
scale:
|
|
478
|
+
x: s[0],
|
|
479
|
+
y: s[1],
|
|
480
|
+
scale: n / o,
|
|
527
481
|
touchesCnt: o,
|
|
528
482
|
touches: e
|
|
529
483
|
};
|
|
@@ -537,10 +491,9 @@ const ce = (t) => {
|
|
|
537
491
|
y: t.scale * (1 - e) * r + t.y
|
|
538
492
|
});
|
|
539
493
|
class ee {
|
|
540
|
-
constructor(e, o) {
|
|
494
|
+
constructor(e, o, r) {
|
|
541
495
|
i(this, "graph");
|
|
542
496
|
i(this, "viewport");
|
|
543
|
-
i(this, "element", null);
|
|
544
497
|
i(this, "prevTouches", null);
|
|
545
498
|
i(this, "window", window);
|
|
546
499
|
i(this, "wheelFinishTimer", null);
|
|
@@ -553,7 +506,7 @@ class ee {
|
|
|
553
506
|
return;
|
|
554
507
|
}
|
|
555
508
|
const o = -e.movementX, r = -e.movementY;
|
|
556
|
-
this.moveViewport(
|
|
509
|
+
this.moveViewport(o, r);
|
|
557
510
|
});
|
|
558
511
|
i(this, "onWindowMouseUp", (e) => {
|
|
559
512
|
this.element === null || !this.options.mouseUpEventVerifier(e) || this.stopMouseDrag();
|
|
@@ -562,8 +515,8 @@ class ee {
|
|
|
562
515
|
if (!this.options.mouseWheelEventVerifier(e))
|
|
563
516
|
return;
|
|
564
517
|
e.preventDefault();
|
|
565
|
-
const { left: o, top: r } = this.element.getBoundingClientRect(),
|
|
566
|
-
this.wheelFinishTimer === null && this.options.onTransformStarted(), this.scaleViewport(
|
|
518
|
+
const { left: o, top: r } = this.element.getBoundingClientRect(), s = e.clientX - o, d = e.clientY - r, h = 1 / (e.deltaY < 0 ? this.options.wheelSensitivity : 1 / this.options.wheelSensitivity);
|
|
519
|
+
this.wheelFinishTimer === null && this.options.onTransformStarted(), this.scaleViewport(h, s, d), this.wheelFinishTimer !== null && clearTimeout(this.wheelFinishTimer), this.wheelFinishTimer = setTimeout(() => {
|
|
567
520
|
this.options.onTransformFinished(), this.wheelFinishTimer = null;
|
|
568
521
|
}, this.options.scaleWheelFinishTimeout);
|
|
569
522
|
});
|
|
@@ -575,46 +528,36 @@ class ee {
|
|
|
575
528
|
this.prevTouches = C(e), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish), this.options.onTransformStarted();
|
|
576
529
|
});
|
|
577
530
|
i(this, "onWindowTouchMove", (e) => {
|
|
578
|
-
const o =
|
|
579
|
-
if (o
|
|
580
|
-
|
|
581
|
-
const r = C(e);
|
|
582
|
-
if (!r.touches.every(
|
|
583
|
-
(h) => U(o, h[0], h[1]) && $(this.window, h[0], h[1])
|
|
531
|
+
const o = C(e);
|
|
532
|
+
if (!o.touches.every(
|
|
533
|
+
(s) => U(this.element, s[0], s[1]) && $(this.window, s[0], s[1])
|
|
584
534
|
)) {
|
|
585
535
|
this.stopTouchDrag();
|
|
586
536
|
return;
|
|
587
537
|
}
|
|
588
|
-
if ((
|
|
589
|
-
o,
|
|
590
|
-
-(
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
this.scaleViewport(o, l, d, c);
|
|
538
|
+
if ((o.touchesCnt === 1 || o.touchesCnt === 2) && this.moveViewport(
|
|
539
|
+
-(o.x - this.prevTouches.x),
|
|
540
|
+
-(o.y - this.prevTouches.y)
|
|
541
|
+
), o.touchesCnt === 2) {
|
|
542
|
+
const { left: s, top: d } = this.element.getBoundingClientRect(), n = this.prevTouches.x - s, h = this.prevTouches.y - d, a = 1 / (o.scale / this.prevTouches.scale);
|
|
543
|
+
this.scaleViewport(a, n, h);
|
|
595
544
|
}
|
|
596
|
-
this.prevTouches =
|
|
545
|
+
this.prevTouches = o;
|
|
597
546
|
});
|
|
598
547
|
i(this, "onWindowTouchFinish", (e) => {
|
|
599
548
|
e.touches.length > 0 ? this.prevTouches = C(e) : this.stopTouchDrag();
|
|
600
549
|
});
|
|
601
550
|
i(this, "observer", new ResizeObserver(() => {
|
|
602
|
-
const e = this.canvas.viewport.getViewportMatrix(), { width: o, height: r } = this.element.getBoundingClientRect(),
|
|
551
|
+
const e = this.canvas.viewport.getViewportMatrix(), { width: o, height: r } = this.element.getBoundingClientRect(), s = this.options.transformPreprocessor({
|
|
603
552
|
prevTransform: e,
|
|
604
553
|
nextTransform: e,
|
|
605
554
|
canvasWidth: o,
|
|
606
555
|
canvasHeight: r
|
|
607
556
|
});
|
|
608
|
-
this.options.onResizeTransformStarted(), this.canvas.patchViewportMatrix(
|
|
557
|
+
this.options.onResizeTransformStarted(), this.canvas.patchViewportMatrix(s), this.options.onResizeTransformFinished();
|
|
609
558
|
}));
|
|
610
559
|
i(this, "options");
|
|
611
|
-
this.canvas = e, this.options = ge(
|
|
612
|
-
}
|
|
613
|
-
attach(e) {
|
|
614
|
-
this.detach(), this.element = e, this.observer.observe(this.element), this.element.addEventListener("mousedown", this.onMouseDown), this.element.addEventListener("wheel", this.onWheelScroll), this.element.addEventListener("touchstart", this.onTouchStart), this.canvas.attach(this.element);
|
|
615
|
-
}
|
|
616
|
-
detach() {
|
|
617
|
-
this.canvas.detach(), this.element !== null && (this.observer.unobserve(this.element), this.element.removeEventListener("mousedown", this.onMouseDown), this.element.removeEventListener("wheel", this.onWheelScroll), this.element.removeEventListener("touchstart", this.onTouchStart), this.element = null);
|
|
560
|
+
this.canvas = e, this.element = o, this.options = ge(r), this.viewport = this.canvas.viewport, this.graph = this.canvas.graph, this.observer.observe(this.element), this.element.addEventListener("mousedown", this.onMouseDown), this.element.addEventListener("wheel", this.onWheelScroll), this.element.addEventListener("touchstart", this.onTouchStart);
|
|
618
561
|
}
|
|
619
562
|
addNode(e) {
|
|
620
563
|
this.canvas.addNode(e);
|
|
@@ -653,28 +596,28 @@ class ee {
|
|
|
653
596
|
this.canvas.clear();
|
|
654
597
|
}
|
|
655
598
|
destroy() {
|
|
656
|
-
this.
|
|
657
|
-
}
|
|
658
|
-
moveViewport(e, o, r) {
|
|
659
|
-
const n = this.viewport.getViewportMatrix(), h = ue(n, o, r), { width: s, height: d } = e.getBoundingClientRect(), c = this.options.transformPreprocessor({
|
|
660
|
-
prevTransform: n,
|
|
661
|
-
nextTransform: h,
|
|
662
|
-
canvasWidth: s,
|
|
663
|
-
canvasHeight: d
|
|
664
|
-
});
|
|
665
|
-
this.performTransform(c);
|
|
599
|
+
this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.observer.unobserve(this.element), this.element.removeEventListener("mousedown", this.onMouseDown), this.element.removeEventListener("wheel", this.onWheelScroll), this.element.removeEventListener("touchstart", this.onTouchStart), this.canvas.destroy();
|
|
666
600
|
}
|
|
667
|
-
|
|
668
|
-
const
|
|
669
|
-
prevTransform:
|
|
601
|
+
moveViewport(e, o) {
|
|
602
|
+
const r = this.viewport.getViewportMatrix(), s = ue(r, e, o), { width: d, height: n } = this.element.getBoundingClientRect(), h = this.options.transformPreprocessor({
|
|
603
|
+
prevTransform: r,
|
|
670
604
|
nextTransform: s,
|
|
671
605
|
canvasWidth: d,
|
|
672
|
-
canvasHeight:
|
|
606
|
+
canvasHeight: n
|
|
607
|
+
});
|
|
608
|
+
this.performTransform(h);
|
|
609
|
+
}
|
|
610
|
+
scaleViewport(e, o, r) {
|
|
611
|
+
const s = this.canvas.viewport.getViewportMatrix(), d = we(s, e, o, r), { width: n, height: h } = this.element.getBoundingClientRect(), c = this.options.transformPreprocessor({
|
|
612
|
+
prevTransform: s,
|
|
613
|
+
nextTransform: d,
|
|
614
|
+
canvasWidth: n,
|
|
615
|
+
canvasHeight: h
|
|
673
616
|
});
|
|
674
|
-
this.performTransform(
|
|
617
|
+
this.performTransform(c);
|
|
675
618
|
}
|
|
676
619
|
stopMouseDrag() {
|
|
677
|
-
|
|
620
|
+
R(this.element, null), this.removeMouseDragListeners(), this.options.onTransformFinished();
|
|
678
621
|
}
|
|
679
622
|
removeMouseDragListeners() {
|
|
680
623
|
this.window.removeEventListener("mousemove", this.onWindowMouseMove), this.window.removeEventListener("mouseup", this.onWindowMouseUp);
|
|
@@ -690,11 +633,10 @@ class ee {
|
|
|
690
633
|
}
|
|
691
634
|
}
|
|
692
635
|
class fe {
|
|
693
|
-
constructor(e, o, r,
|
|
636
|
+
constructor(e, o, r, s, d) {
|
|
694
637
|
i(this, "graph");
|
|
695
638
|
i(this, "viewport");
|
|
696
639
|
i(this, "canvas");
|
|
697
|
-
i(this, "element", null);
|
|
698
640
|
i(this, "canvasResizeObserver");
|
|
699
641
|
i(this, "window", window);
|
|
700
642
|
i(this, "nodeHorizontal");
|
|
@@ -716,36 +658,31 @@ class fe {
|
|
|
716
658
|
yTo: e.y + e.height
|
|
717
659
|
};
|
|
718
660
|
});
|
|
719
|
-
var
|
|
720
|
-
this.trigger = o, this.virtualScrollOptions =
|
|
721
|
-
const
|
|
722
|
-
this.viewportWidth =
|
|
661
|
+
var a, l;
|
|
662
|
+
this.trigger = o, this.virtualScrollOptions = s, this.element = d, this.nodeHorizontal = this.virtualScrollOptions.nodeContainingRadius.horizontal, this.nodeVertical = this.virtualScrollOptions.nodeContainingRadius.vertical, this.canvasResizeObserver = new this.window.ResizeObserver((g) => {
|
|
663
|
+
const f = g[0];
|
|
664
|
+
this.viewportWidth = f.contentRect.width, this.viewportHeight = f.contentRect.height, this.scheduleLoadAreaAroundViewport();
|
|
723
665
|
});
|
|
724
|
-
const
|
|
725
|
-
}),
|
|
726
|
-
}),
|
|
666
|
+
const n = ((a = r == null ? void 0 : r.events) == null ? void 0 : a.onTransformFinished) ?? (() => {
|
|
667
|
+
}), h = ((l = r == null ? void 0 : r.events) == null ? void 0 : l.onTransformChange) ?? (() => {
|
|
668
|
+
}), c = {
|
|
727
669
|
...r,
|
|
728
670
|
events: {
|
|
729
671
|
...r == null ? void 0 : r.events,
|
|
730
672
|
onTransformChange: () => {
|
|
731
|
-
const
|
|
732
|
-
this.viewportMatrix = this.canvas.viewport.getViewportMatrix(),
|
|
673
|
+
const g = this.viewportMatrix;
|
|
674
|
+
this.viewportMatrix = this.canvas.viewport.getViewportMatrix(), g.scale !== this.viewportMatrix.scale && this.scheduleEnsureViewportAreaLoaded(), h();
|
|
733
675
|
},
|
|
734
676
|
onTransformFinished: () => {
|
|
735
|
-
this.scheduleLoadAreaAroundViewport(),
|
|
677
|
+
this.scheduleLoadAreaAroundViewport(), n();
|
|
736
678
|
}
|
|
737
679
|
}
|
|
738
680
|
};
|
|
739
681
|
this.canvas = new ee(
|
|
740
682
|
e,
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
attach(e) {
|
|
745
|
-
this.detach(), this.element = e, this.canvasResizeObserver.observe(this.element), this.canvas.attach(e);
|
|
746
|
-
}
|
|
747
|
-
detach() {
|
|
748
|
-
this.element !== null && (this.canvasResizeObserver.unobserve(this.element), this.element = null, this.viewportWidth = 0, this.viewportHeight = 0), this.canvas.detach();
|
|
683
|
+
this.element,
|
|
684
|
+
c
|
|
685
|
+
), this.viewportMatrix = this.canvas.viewport.getViewportMatrix(), this.viewport = this.canvas.viewport, this.graph = this.canvas.graph, this.trigger.subscribe(this.updateLoadedArea), this.canvasResizeObserver.observe(this.element);
|
|
749
686
|
}
|
|
750
687
|
addNode(e) {
|
|
751
688
|
this.canvas.addNode(e);
|
|
@@ -784,7 +721,7 @@ class fe {
|
|
|
784
721
|
this.canvas.clear();
|
|
785
722
|
}
|
|
786
723
|
destroy() {
|
|
787
|
-
this.trigger.unsubscribe(this.updateLoadedArea), this.canvas.destroy();
|
|
724
|
+
this.trigger.unsubscribe(this.updateLoadedArea), this.canvasResizeObserver.unobserve(this.element), this.canvas.destroy();
|
|
788
725
|
}
|
|
789
726
|
scheduleLoadAreaAroundViewport() {
|
|
790
727
|
setTimeout(() => {
|
|
@@ -792,44 +729,35 @@ class fe {
|
|
|
792
729
|
});
|
|
793
730
|
}
|
|
794
731
|
scheduleEnsureViewportAreaLoaded() {
|
|
795
|
-
const e = this.viewportWidth * this.viewportMatrix.scale, o = this.viewportHeight * this.viewportMatrix.scale, r = this.viewportMatrix.x - this.nodeHorizontal,
|
|
796
|
-
this.loadedArea.xFrom < r && this.loadedArea.xTo >
|
|
732
|
+
const e = this.viewportWidth * this.viewportMatrix.scale, o = this.viewportHeight * this.viewportMatrix.scale, r = this.viewportMatrix.x - this.nodeHorizontal, s = this.viewportMatrix.y - this.nodeVertical, d = this.viewportMatrix.x + e + this.nodeHorizontal, n = this.viewportMatrix.y + o + this.nodeVertical;
|
|
733
|
+
this.loadedArea.xFrom < r && this.loadedArea.xTo > d && this.loadedArea.yFrom < s && this.loadedArea.yTo > n || this.scheduleLoadAreaAroundViewport();
|
|
797
734
|
}
|
|
798
735
|
loadAreaAroundViewport() {
|
|
799
|
-
const e = this.viewportWidth * this.viewportMatrix.scale, o = this.viewportHeight * this.viewportMatrix.scale, r = this.viewportMatrix.x - e - this.nodeHorizontal,
|
|
800
|
-
this.trigger.emit({ x: r, y:
|
|
736
|
+
const e = this.viewportWidth * this.viewportMatrix.scale, o = this.viewportHeight * this.viewportMatrix.scale, r = this.viewportMatrix.x - e - this.nodeHorizontal, s = this.viewportMatrix.y - o - this.nodeVertical, d = 3 * e + 2 * this.nodeHorizontal, n = 3 * o + 2 * this.nodeVertical;
|
|
737
|
+
this.trigger.emit({ x: r, y: s, width: d, height: n });
|
|
801
738
|
}
|
|
802
739
|
}
|
|
803
|
-
const
|
|
740
|
+
const ye = () => {
|
|
804
741
|
const t = document.createElement("div");
|
|
805
742
|
return t.style.width = "100%", t.style.height = "100%", t.style.position = "relative", t.style.overflow = "hidden", t;
|
|
806
|
-
},
|
|
743
|
+
}, ve = () => {
|
|
807
744
|
const t = document.createElement("div");
|
|
808
745
|
return t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.width = "0", t.style.height = "0", t;
|
|
809
746
|
}, xe = () => {
|
|
810
747
|
const t = document.createElement("div");
|
|
811
748
|
return t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.visibility = "hidden", t;
|
|
812
749
|
};
|
|
813
|
-
class
|
|
814
|
-
constructor(e, o) {
|
|
815
|
-
i(this, "
|
|
816
|
-
i(this, "
|
|
817
|
-
i(this, "container", ye());
|
|
750
|
+
class Ee {
|
|
751
|
+
constructor(e, o, r) {
|
|
752
|
+
i(this, "host", ye());
|
|
753
|
+
i(this, "container", ve());
|
|
818
754
|
i(this, "nodeIdToWrapperElementMap", /* @__PURE__ */ new Map());
|
|
819
755
|
i(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
|
|
820
756
|
i(this, "applyTransform", () => {
|
|
821
757
|
const e = this.viewportStore.getContentMatrix();
|
|
822
758
|
this.container.style.transform = `matrix(${e.scale}, 0, 0, ${e.scale}, ${e.x}, ${e.y})`;
|
|
823
759
|
});
|
|
824
|
-
this.graphStore = e, this.viewportStore = o, this.host.appendChild(this.container), this.viewportStore.onAfterUpdated.subscribe(this.applyTransform);
|
|
825
|
-
}
|
|
826
|
-
attach(e) {
|
|
827
|
-
this.detach(), this.canvasWrapper = e, this.canvasWrapper.appendChild(this.host), this.graphStore.getAllEdgeIds().forEach((o) => {
|
|
828
|
-
this.renderEdge(o);
|
|
829
|
-
});
|
|
830
|
-
}
|
|
831
|
-
detach() {
|
|
832
|
-
this.canvasWrapper !== null && (this.canvasWrapper.removeChild(this.host), this.canvasWrapper = null);
|
|
760
|
+
this.graphStore = e, this.viewportStore = o, this.element = r, this.element.appendChild(this.host), this.host.appendChild(this.container), this.viewportStore.onAfterUpdated.subscribe(this.applyTransform);
|
|
833
761
|
}
|
|
834
762
|
attachNode(e) {
|
|
835
763
|
const o = this.graphStore.getNode(e), r = xe();
|
|
@@ -855,10 +783,10 @@ class Ae {
|
|
|
855
783
|
});
|
|
856
784
|
}
|
|
857
785
|
destroy() {
|
|
858
|
-
this.viewportStore.onAfterUpdated.unsubscribe(this.applyTransform), this.clear(), this.
|
|
786
|
+
this.viewportStore.onAfterUpdated.unsubscribe(this.applyTransform), this.clear(), this.element.removeChild(this.host), this.host.removeChild(this.container);
|
|
859
787
|
}
|
|
860
788
|
updateNodePosition(e) {
|
|
861
|
-
const o = this.nodeIdToWrapperElementMap.get(e), r = this.graphStore.getNode(e), { width:
|
|
789
|
+
const o = this.nodeIdToWrapperElementMap.get(e), r = this.graphStore.getNode(e), { width: s, height: d } = r.element.getBoundingClientRect(), n = this.viewportStore.getViewportMatrix().scale, h = r.centerFn(s, d), c = r.x - n * h.x, a = r.y - n * h.y;
|
|
862
790
|
o.style.transform = `translate(${c}px, ${a}px)`;
|
|
863
791
|
}
|
|
864
792
|
updateNodePriority(e) {
|
|
@@ -872,28 +800,28 @@ class Ae {
|
|
|
872
800
|
this.edgeIdToElementMap.set(e, r.shape.svg), this.container.appendChild(r.shape.svg);
|
|
873
801
|
}
|
|
874
802
|
renderEdge(e) {
|
|
875
|
-
const o = this.graphStore.getEdge(e), r = this.graphStore.getPort(o.from),
|
|
876
|
-
x: c.scale * (
|
|
877
|
-
y: c.scale * (
|
|
803
|
+
const o = this.graphStore.getEdge(e), r = this.graphStore.getPort(o.from), s = this.graphStore.getPort(o.to), d = r.element.getBoundingClientRect(), n = s.element.getBoundingClientRect(), h = this.host.getBoundingClientRect(), c = this.viewportStore.getViewportMatrix(), a = {
|
|
804
|
+
x: c.scale * (d.left - h.left) + c.x,
|
|
805
|
+
y: c.scale * (d.top - h.top) + c.y
|
|
878
806
|
}, l = {
|
|
879
|
-
x: c.scale * (
|
|
880
|
-
y: c.scale * (
|
|
807
|
+
x: c.scale * (n.left - h.left) + c.x,
|
|
808
|
+
y: c.scale * (n.top - h.top) + c.y
|
|
881
809
|
}, g = {
|
|
882
810
|
x: a.x,
|
|
883
811
|
y: a.y,
|
|
884
|
-
width:
|
|
885
|
-
height:
|
|
812
|
+
width: d.width * c.scale,
|
|
813
|
+
height: d.height * c.scale,
|
|
886
814
|
direction: r.direction,
|
|
887
815
|
portId: o.from,
|
|
888
816
|
nodeId: r.nodeId
|
|
889
817
|
}, f = {
|
|
890
818
|
x: l.x,
|
|
891
819
|
y: l.y,
|
|
892
|
-
width:
|
|
893
|
-
height:
|
|
894
|
-
direction:
|
|
820
|
+
width: n.width * c.scale,
|
|
821
|
+
height: n.height * c.scale,
|
|
822
|
+
direction: s.direction,
|
|
895
823
|
portId: o.to,
|
|
896
|
-
nodeId:
|
|
824
|
+
nodeId: s.nodeId
|
|
897
825
|
};
|
|
898
826
|
o.shape.render({
|
|
899
827
|
from: g,
|
|
@@ -905,7 +833,7 @@ class Ae {
|
|
|
905
833
|
o.shape.svg.style.zIndex = `${o.priority}`;
|
|
906
834
|
}
|
|
907
835
|
}
|
|
908
|
-
class
|
|
836
|
+
class Ae {
|
|
909
837
|
constructor(e) {
|
|
910
838
|
i(this, "xFrom", 1 / 0);
|
|
911
839
|
i(this, "yFrom", 1 / 0);
|
|
@@ -921,41 +849,35 @@ class Ee {
|
|
|
921
849
|
return o.x >= this.xFrom && o.x <= this.xTo && o.y >= this.yFrom && o.y <= this.yTo;
|
|
922
850
|
}
|
|
923
851
|
hasEdge(e) {
|
|
924
|
-
const o = this.graphStore.getEdge(e), r = this.graphStore.getPort(o.from).nodeId,
|
|
925
|
-
return
|
|
852
|
+
const o = this.graphStore.getEdge(e), r = this.graphStore.getPort(o.from).nodeId, s = this.graphStore.getPort(o.to).nodeId, d = this.graphStore.getNode(r), n = this.graphStore.getNode(s), h = Math.min(d.x, n.x), c = Math.max(d.x, n.x), a = Math.min(d.y, n.y), l = Math.max(d.y, n.y);
|
|
853
|
+
return h <= this.xTo && c >= this.xFrom && a <= this.yTo && l >= this.yFrom;
|
|
926
854
|
}
|
|
927
855
|
}
|
|
928
|
-
class
|
|
856
|
+
class Se {
|
|
929
857
|
constructor(e, o, r) {
|
|
930
858
|
i(this, "attachedNodes", /* @__PURE__ */ new Set());
|
|
931
859
|
i(this, "attachedEdges", /* @__PURE__ */ new Set());
|
|
932
860
|
i(this, "renderingBox");
|
|
933
861
|
i(this, "updateViewport", (e) => {
|
|
934
862
|
this.renderingBox.setRenderingBox(e);
|
|
935
|
-
const o = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(),
|
|
936
|
-
this.graphStore.getAllNodeIds().forEach((
|
|
937
|
-
const
|
|
938
|
-
|
|
939
|
-
}), this.graphStore.getAllEdgeIds().forEach((
|
|
940
|
-
const
|
|
941
|
-
|
|
942
|
-
}),
|
|
943
|
-
this.handleDetachEdge(
|
|
944
|
-
}), r.forEach((
|
|
945
|
-
this.handleDetachNode(
|
|
946
|
-
}), o.forEach((
|
|
947
|
-
this.attachedNodes.has(
|
|
948
|
-
}),
|
|
949
|
-
this.handleAttachEdge(
|
|
863
|
+
const o = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set();
|
|
864
|
+
this.graphStore.getAllNodeIds().forEach((n) => {
|
|
865
|
+
const h = this.renderingBox.hasNode(n), c = this.attachedNodes.has(n);
|
|
866
|
+
h && !c ? o.add(n) : !h && c && r.add(n);
|
|
867
|
+
}), this.graphStore.getAllEdgeIds().forEach((n) => {
|
|
868
|
+
const h = this.renderingBox.hasEdge(n), c = this.attachedEdges.has(n), a = this.graphStore.getEdge(n), l = this.graphStore.getPort(a.from).nodeId, g = this.graphStore.getPort(a.to).nodeId;
|
|
869
|
+
h && (this.renderingBox.hasNode(l) || (o.add(l), r.delete(l)), this.renderingBox.hasNode(g) || (o.add(g), r.delete(g))), h && !c ? s.add(n) : !h && c && d.add(n);
|
|
870
|
+
}), d.forEach((n) => {
|
|
871
|
+
this.handleDetachEdge(n);
|
|
872
|
+
}), r.forEach((n) => {
|
|
873
|
+
this.handleDetachNode(n);
|
|
874
|
+
}), o.forEach((n) => {
|
|
875
|
+
this.attachedNodes.has(n) || this.handleAttachNode(n);
|
|
876
|
+
}), s.forEach((n) => {
|
|
877
|
+
this.handleAttachEdge(n);
|
|
950
878
|
});
|
|
951
879
|
});
|
|
952
|
-
this.htmlView = e, this.graphStore = o, this.trigger = r, this.renderingBox = new
|
|
953
|
-
}
|
|
954
|
-
attach(e) {
|
|
955
|
-
this.htmlView.attach(e);
|
|
956
|
-
}
|
|
957
|
-
detach() {
|
|
958
|
-
this.htmlView.detach();
|
|
880
|
+
this.htmlView = e, this.graphStore = o, this.trigger = r, this.renderingBox = new Ae(this.graphStore), this.trigger.subscribe(this.updateViewport);
|
|
959
881
|
}
|
|
960
882
|
attachNode(e) {
|
|
961
883
|
this.renderingBox.hasNode(e) && this.handleAttachNode(e);
|
|
@@ -993,8 +915,8 @@ class pe {
|
|
|
993
915
|
this.clear(), this.htmlView.destroy(), this.trigger.unsubscribe(this.updateViewport);
|
|
994
916
|
}
|
|
995
917
|
attachEdgeEntities(e) {
|
|
996
|
-
const o = this.graphStore.getEdge(e), r = this.graphStore.getPort(o.from).nodeId,
|
|
997
|
-
this.attachedNodes.has(r) || this.handleAttachNode(r), this.attachedNodes.has(
|
|
918
|
+
const o = this.graphStore.getEdge(e), r = this.graphStore.getPort(o.from).nodeId, s = this.graphStore.getPort(o.to).nodeId;
|
|
919
|
+
this.attachedNodes.has(r) || this.handleAttachNode(r), this.attachedNodes.has(s) || this.handleAttachNode(s), this.handleAttachEdge(e);
|
|
998
920
|
}
|
|
999
921
|
handleAttachNode(e) {
|
|
1000
922
|
this.attachedNodes.add(e), this.htmlView.attachNode(e);
|
|
@@ -1025,11 +947,11 @@ class te {
|
|
|
1025
947
|
});
|
|
1026
948
|
}
|
|
1027
949
|
}
|
|
1028
|
-
const
|
|
950
|
+
const E = () => {
|
|
1029
951
|
const t = new te();
|
|
1030
952
|
return [t, t];
|
|
1031
953
|
};
|
|
1032
|
-
class
|
|
954
|
+
class Y {
|
|
1033
955
|
constructor(e) {
|
|
1034
956
|
i(this, "counter", 0);
|
|
1035
957
|
this.checkExists = e;
|
|
@@ -1045,53 +967,53 @@ class z {
|
|
|
1045
967
|
this.counter = 0;
|
|
1046
968
|
}
|
|
1047
969
|
}
|
|
1048
|
-
class
|
|
970
|
+
class A extends Error {
|
|
1049
971
|
constructor() {
|
|
1050
972
|
super(...arguments);
|
|
1051
973
|
i(this, "name", "HtmlGraphError");
|
|
1052
974
|
}
|
|
1053
975
|
}
|
|
1054
|
-
const
|
|
976
|
+
const pe = (t, e) => ({
|
|
1055
977
|
x: t / 2,
|
|
1056
978
|
y: e / 2
|
|
1057
|
-
}),
|
|
979
|
+
}), k = (t) => () => t, Z = k(0), Ne = () => {
|
|
1058
980
|
let t = 0;
|
|
1059
981
|
return () => t++;
|
|
1060
982
|
}, Te = (t, e) => {
|
|
1061
983
|
let o = Z, r = Z;
|
|
1062
|
-
const
|
|
1063
|
-
return t === "incremental" && (o =
|
|
984
|
+
const s = Ne();
|
|
985
|
+
return t === "incremental" && (o = s), e === "incremental" && (r = s), typeof t == "number" && (o = k(t)), typeof e == "number" && (r = k(e)), typeof t == "function" && (o = t), typeof e == "function" && (r = e), {
|
|
1064
986
|
nodesPriorityFn: o,
|
|
1065
987
|
edgesPriorityFn: r
|
|
1066
988
|
};
|
|
1067
|
-
},
|
|
989
|
+
}, v = (t, e, o) => ({
|
|
1068
990
|
x: e.x * t.x - e.y * t.y + ((1 - e.x) * o.x + e.y * o.y),
|
|
1069
991
|
y: e.y * t.x + e.x * t.y + ((1 - e.x) * o.y - e.y * o.x)
|
|
1070
992
|
}), T = (t, e, o) => ({ x: e * Math.cos(t), y: o * Math.sin(t) }), w = {
|
|
1071
993
|
x: 0,
|
|
1072
994
|
y: 0
|
|
1073
995
|
}, m = (t, e, o, r) => {
|
|
1074
|
-
const
|
|
996
|
+
const d = [
|
|
1075
997
|
w,
|
|
1076
998
|
{ x: o, y: r },
|
|
1077
999
|
{ x: o, y: -r }
|
|
1078
|
-
].map((a) =>
|
|
1079
|
-
return `${
|
|
1000
|
+
].map((a) => v(a, t, w)).map((a) => ({ x: a.x + e.x, y: a.y + e.y })), n = `M ${d[0].x} ${d[0].y}`, h = `L ${d[1].x} ${d[1].y}`, c = `L ${d[2].x} ${d[2].y}`;
|
|
1001
|
+
return `${n} ${h} ${c}`;
|
|
1080
1002
|
}, D = (t, e) => {
|
|
1081
1003
|
const o = [];
|
|
1082
1004
|
if (t.length > 0 && o.push(`M ${t[0].x} ${t[0].y}`), t.length === 2 && o.push(`L ${t[1].x} ${t[1].y}`), t.length > 2) {
|
|
1083
1005
|
const r = t.length - 1;
|
|
1084
|
-
let
|
|
1085
|
-
t.forEach((
|
|
1006
|
+
let s = 0, d = 0, n = 0;
|
|
1007
|
+
t.forEach((h, c) => {
|
|
1086
1008
|
let a = 0, l = 0, g = 0;
|
|
1087
|
-
const f = c > 0, x = c < r,
|
|
1088
|
-
if (f && (a = -
|
|
1009
|
+
const f = c > 0, x = c < r, y = f && x;
|
|
1010
|
+
if (f && (a = -s, l = -d, g = n), x) {
|
|
1089
1011
|
const L = t[c + 1];
|
|
1090
|
-
|
|
1012
|
+
s = L.x - h.x, d = L.y - h.y, n = Math.sqrt(s * s + d * d);
|
|
1091
1013
|
}
|
|
1092
|
-
const
|
|
1093
|
-
c > 0 && o.push(`L ${V.x} ${V.y}`),
|
|
1094
|
-
`C ${
|
|
1014
|
+
const S = n !== 0 ? Math.min((y ? e : 0) / n, c < r - 1 ? 0.5 : 1) : 0, N = y ? { x: h.x + s * S, y: h.y + d * S } : h, M = g !== 0 ? Math.min((y ? e : 0) / g, c > 1 ? 0.5 : 1) : 0, V = y ? { x: h.x + a * M, y: h.y + l * M } : h;
|
|
1015
|
+
c > 0 && o.push(`L ${V.x} ${V.y}`), y && o.push(
|
|
1016
|
+
`C ${h.x} ${h.y} ${h.x} ${h.y} ${N.x} ${N.y}`
|
|
1095
1017
|
);
|
|
1096
1018
|
});
|
|
1097
1019
|
}
|
|
@@ -1105,7 +1027,7 @@ const Se = (t, e) => ({
|
|
|
1105
1027
|
}, F = (t, e) => {
|
|
1106
1028
|
const o = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
1107
1029
|
return o.setAttribute("stroke", t), o.setAttribute("stroke-width", `${e}`), o.setAttribute("fill", "none"), o;
|
|
1108
|
-
},
|
|
1030
|
+
}, b = (t) => {
|
|
1109
1031
|
const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
1110
1032
|
return e.setAttribute("fill", t), e;
|
|
1111
1033
|
}, B = (t, e) => {
|
|
@@ -1115,174 +1037,174 @@ const Se = (t, e) => ({
|
|
|
1115
1037
|
}, r = {
|
|
1116
1038
|
x: e.x + e.width / 2,
|
|
1117
1039
|
y: e.y + e.height / 2
|
|
1118
|
-
},
|
|
1040
|
+
}, s = Math.min(o.x, r.x), d = Math.min(o.y, r.y), n = Math.abs(r.x - o.x), h = Math.abs(r.y - o.y), c = o.x <= r.x ? 1 : -1, a = o.y <= r.y ? 1 : -1;
|
|
1119
1041
|
return {
|
|
1120
|
-
x:
|
|
1121
|
-
y:
|
|
1122
|
-
width:
|
|
1123
|
-
height:
|
|
1042
|
+
x: s,
|
|
1043
|
+
y: d,
|
|
1044
|
+
width: n,
|
|
1045
|
+
height: h,
|
|
1124
1046
|
flipX: c,
|
|
1125
1047
|
flipY: a
|
|
1126
1048
|
};
|
|
1127
1049
|
}, me = (t) => {
|
|
1128
|
-
const e =
|
|
1050
|
+
const e = v(
|
|
1129
1051
|
{ x: t.arrowLength, y: w.y },
|
|
1130
1052
|
t.fromVect,
|
|
1131
1053
|
w
|
|
1132
|
-
), o =
|
|
1054
|
+
), o = v(
|
|
1133
1055
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
1134
1056
|
t.toVect,
|
|
1135
1057
|
t.to
|
|
1136
1058
|
), r = {
|
|
1137
1059
|
x: e.x + t.fromVect.x * t.curvature,
|
|
1138
1060
|
y: e.y + t.fromVect.y * t.curvature
|
|
1139
|
-
},
|
|
1061
|
+
}, s = {
|
|
1140
1062
|
x: o.x - t.toVect.x * t.curvature,
|
|
1141
1063
|
y: o.y - t.toVect.y * t.curvature
|
|
1142
|
-
},
|
|
1143
|
-
return `${
|
|
1144
|
-
},
|
|
1145
|
-
const e = t.hasSourceArrow ?
|
|
1064
|
+
}, d = `M ${e.x} ${e.y} C ${r.x} ${r.y}, ${s.x} ${s.y}, ${o.x} ${o.y}`, n = t.hasSourceArrow ? "" : `M ${w.x} ${w.y} L ${e.x} ${e.y} `, h = t.hasTargetArrow ? "" : ` M ${o.x} ${o.y} L ${t.to.x} ${t.to.y}`;
|
|
1065
|
+
return `${n}${d}${h}`;
|
|
1066
|
+
}, be = (t) => {
|
|
1067
|
+
const e = t.hasSourceArrow ? v(
|
|
1146
1068
|
{ x: t.arrowLength, y: w.y },
|
|
1147
1069
|
t.fromVect,
|
|
1148
1070
|
w
|
|
1149
|
-
) : w, o = t.hasTargetArrow ?
|
|
1071
|
+
) : w, o = t.hasTargetArrow ? v(
|
|
1150
1072
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
1151
1073
|
t.toVect,
|
|
1152
1074
|
t.to
|
|
1153
|
-
) : t.to, r = t.arrowLength,
|
|
1075
|
+
) : t.to, r = t.arrowLength, s = Math.cos(t.detourDirection) * t.detourDistance, d = Math.sin(t.detourDirection) * t.detourDistance, n = s * t.flipX, h = d * t.flipY, c = v(
|
|
1154
1076
|
{ x: r, y: w.y },
|
|
1155
1077
|
t.fromVect,
|
|
1156
1078
|
w
|
|
1157
1079
|
), a = {
|
|
1158
|
-
x: c.x +
|
|
1159
|
-
y: c.y +
|
|
1160
|
-
}, l =
|
|
1080
|
+
x: c.x + n,
|
|
1081
|
+
y: c.y + h
|
|
1082
|
+
}, l = v(
|
|
1161
1083
|
{ x: t.to.x - r, y: t.to.y },
|
|
1162
1084
|
t.toVect,
|
|
1163
1085
|
t.to
|
|
1164
1086
|
), g = {
|
|
1165
|
-
x: l.x +
|
|
1166
|
-
y: l.y +
|
|
1087
|
+
x: l.x + n,
|
|
1088
|
+
y: l.y + h
|
|
1167
1089
|
}, f = { x: (a.x + g.x) / 2, y: (a.y + g.y) / 2 }, x = {
|
|
1168
1090
|
x: c.x + t.curvature * t.fromVect.x,
|
|
1169
1091
|
y: c.y + t.curvature * t.fromVect.y
|
|
1170
|
-
},
|
|
1092
|
+
}, y = {
|
|
1171
1093
|
x: l.x - t.curvature * t.toVect.x,
|
|
1172
1094
|
y: l.y - t.curvature * t.toVect.y
|
|
1173
|
-
}, S = {
|
|
1174
|
-
x: c.x + s,
|
|
1175
|
-
y: c.y + d
|
|
1176
1095
|
}, p = {
|
|
1177
|
-
x:
|
|
1178
|
-
y:
|
|
1096
|
+
x: c.x + n,
|
|
1097
|
+
y: c.y + h
|
|
1098
|
+
}, S = {
|
|
1099
|
+
x: l.x + n,
|
|
1100
|
+
y: l.y + h
|
|
1179
1101
|
};
|
|
1180
1102
|
return [
|
|
1181
1103
|
`M ${e.x} ${e.y}`,
|
|
1182
1104
|
`L ${c.x} ${c.y}`,
|
|
1183
|
-
`C ${x.x} ${x.y} ${
|
|
1184
|
-
`C ${
|
|
1105
|
+
`C ${x.x} ${x.y} ${p.x} ${p.y} ${f.x} ${f.y}`,
|
|
1106
|
+
`C ${S.x} ${S.y} ${y.x} ${y.y} ${l.x} ${l.y}`,
|
|
1185
1107
|
`L ${o.x} ${o.y}`
|
|
1186
1108
|
].join(" ");
|
|
1187
|
-
},
|
|
1188
|
-
const e = t.hasSourceArrow ?
|
|
1109
|
+
}, Pe = (t) => {
|
|
1110
|
+
const e = t.hasSourceArrow ? v(
|
|
1189
1111
|
{ x: t.arrowLength, y: w.y },
|
|
1190
1112
|
t.fromVect,
|
|
1191
1113
|
w
|
|
1192
|
-
) : w, o = t.hasTargetArrow ?
|
|
1114
|
+
) : w, o = t.hasTargetArrow ? v(
|
|
1193
1115
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
1194
1116
|
t.toVect,
|
|
1195
1117
|
t.to
|
|
1196
|
-
) : t.to, r = t.arrowLength + t.arrowOffset,
|
|
1197
|
-
{ x: t.to.x -
|
|
1118
|
+
) : t.to, r = t.arrowLength + t.arrowOffset, s = r - t.roundness, d = v({ x: s, y: w.y }, t.fromVect, w), n = v(
|
|
1119
|
+
{ x: t.to.x - s, y: t.to.y },
|
|
1198
1120
|
t.toVect,
|
|
1199
1121
|
t.to
|
|
1200
|
-
),
|
|
1201
|
-
x: t.flipX > 0 ? t.to.x -
|
|
1202
|
-
y:
|
|
1122
|
+
), h = Math.max((d.x + n.x) / 2, r), c = t.to.y / 2, a = { x: t.flipX > 0 ? h : -r, y: d.y }, l = { x: a.x, y: c }, g = {
|
|
1123
|
+
x: t.flipX > 0 ? t.to.x - h : t.to.x + r,
|
|
1124
|
+
y: n.y
|
|
1203
1125
|
}, f = { x: g.x, y: c };
|
|
1204
1126
|
return D(
|
|
1205
|
-
[e,
|
|
1127
|
+
[e, d, a, l, f, g, n, o],
|
|
1206
1128
|
t.roundness
|
|
1207
1129
|
);
|
|
1208
1130
|
}, X = (t) => {
|
|
1209
|
-
const e = t.hasSourceArrow ?
|
|
1131
|
+
const e = t.hasSourceArrow ? v(
|
|
1210
1132
|
{ x: t.arrowLength, y: w.y },
|
|
1211
1133
|
t.fromVect,
|
|
1212
1134
|
w
|
|
1213
|
-
) : w, o = t.hasTargetArrow ?
|
|
1135
|
+
) : w, o = t.hasTargetArrow ? v(
|
|
1214
1136
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
1215
1137
|
t.toVect,
|
|
1216
1138
|
t.to
|
|
1217
|
-
) : t.to, r = t.arrowLength + t.arrowOffset,
|
|
1139
|
+
) : t.to, r = t.arrowLength + t.arrowOffset, s = v(
|
|
1218
1140
|
{ x: r, y: w.y },
|
|
1219
1141
|
t.fromVect,
|
|
1220
1142
|
w
|
|
1221
|
-
),
|
|
1143
|
+
), d = Math.cos(t.detourDirection) * t.detourDistance, n = Math.sin(t.detourDirection) * t.detourDistance, h = d * t.flipX, c = n * t.flipY, a = { x: s.x + h, y: s.y + c }, l = v(
|
|
1222
1144
|
{ x: t.to.x - r, y: t.to.y },
|
|
1223
1145
|
t.toVect,
|
|
1224
1146
|
t.to
|
|
1225
|
-
), g = { x: l.x +
|
|
1147
|
+
), g = { x: l.x + h, y: l.y + c };
|
|
1226
1148
|
return D(
|
|
1227
|
-
[e,
|
|
1149
|
+
[e, s, a, g, l, o],
|
|
1228
1150
|
t.roundness
|
|
1229
1151
|
);
|
|
1230
1152
|
}, Me = (t) => {
|
|
1231
|
-
const e = t.hasSourceArrow ?
|
|
1153
|
+
const e = t.hasSourceArrow ? v(
|
|
1232
1154
|
{ x: t.arrowLength, y: w.y },
|
|
1233
1155
|
t.fromVect,
|
|
1234
1156
|
w
|
|
1235
|
-
) : w, o = t.hasTargetArrow ?
|
|
1157
|
+
) : w, o = t.hasTargetArrow ? v(
|
|
1236
1158
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
1237
1159
|
t.toVect,
|
|
1238
1160
|
t.to
|
|
1239
|
-
) : t.to, r = t.arrowLength + t.arrowOffset,
|
|
1161
|
+
) : t.to, r = t.arrowLength + t.arrowOffset, s = v({ x: r, y: w.y }, t.fromVect, w), d = v(
|
|
1240
1162
|
{ x: t.to.x - r, y: t.to.y },
|
|
1241
1163
|
t.toVect,
|
|
1242
1164
|
t.to
|
|
1243
1165
|
);
|
|
1244
|
-
return D([e,
|
|
1166
|
+
return D([e, s, d, o], t.roundness);
|
|
1245
1167
|
}, Ve = (t) => {
|
|
1246
|
-
const e = t.hasSourceArrow ?
|
|
1168
|
+
const e = t.hasSourceArrow ? v(
|
|
1247
1169
|
{ x: t.arrowLength, y: w.y },
|
|
1248
1170
|
t.fromVect,
|
|
1249
1171
|
w
|
|
1250
|
-
) : w, o = t.hasTargetArrow ?
|
|
1172
|
+
) : w, o = t.hasTargetArrow ? v(
|
|
1251
1173
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
1252
1174
|
t.toVect,
|
|
1253
1175
|
t.to
|
|
1254
|
-
) : t.to, r = t.arrowLength + t.arrowOffset,
|
|
1255
|
-
{ x: t.to.x -
|
|
1176
|
+
) : t.to, r = t.arrowLength + t.arrowOffset, s = r - t.roundness, d = v({ x: s, y: w.y }, t.fromVect, w), n = v(
|
|
1177
|
+
{ x: t.to.x - s, y: t.to.y },
|
|
1256
1178
|
t.toVect,
|
|
1257
1179
|
t.to
|
|
1258
|
-
),
|
|
1259
|
-
x:
|
|
1260
|
-
y: t.flipY > 0 ? t.to.y -
|
|
1180
|
+
), h = Math.max((d.y + n.y) / 2, r), c = t.to.x / 2, a = { x: d.x, y: t.flipY > 0 ? h : -r }, l = { x: c, y: a.y }, g = {
|
|
1181
|
+
x: n.x,
|
|
1182
|
+
y: t.flipY > 0 ? t.to.y - h : t.to.y + r
|
|
1261
1183
|
}, f = { x: c, y: g.y };
|
|
1262
1184
|
return D(
|
|
1263
|
-
[e,
|
|
1185
|
+
[e, d, a, l, f, g, n, o],
|
|
1264
1186
|
t.roundness
|
|
1265
1187
|
);
|
|
1266
1188
|
}, H = (t) => {
|
|
1267
|
-
const e = t.arrowOffset, o = t.side, r = t.arrowLength + e,
|
|
1189
|
+
const e = t.arrowOffset, o = t.side, r = t.arrowLength + e, s = r + 2 * o, n = [
|
|
1268
1190
|
{ x: t.arrowLength, y: w.y },
|
|
1269
1191
|
{ x: r, y: w.y },
|
|
1270
1192
|
{ x: r, y: t.side },
|
|
1271
|
-
{ x:
|
|
1272
|
-
{ x:
|
|
1193
|
+
{ x: s, y: t.side },
|
|
1194
|
+
{ x: s, y: -t.side },
|
|
1273
1195
|
{ x: r, y: -t.side },
|
|
1274
1196
|
{ x: r, y: w.y },
|
|
1275
1197
|
{ x: t.arrowLength, y: w.y }
|
|
1276
1198
|
].map(
|
|
1277
|
-
(c) =>
|
|
1278
|
-
),
|
|
1279
|
-
return `${t.hasSourceArrow || t.hasTargetArrow ? "" :
|
|
1199
|
+
(c) => v(c, t.fromVect, w)
|
|
1200
|
+
), h = `M ${w.x} ${w.y} L ${n[0].x} ${n[0].y} `;
|
|
1201
|
+
return `${t.hasSourceArrow || t.hasTargetArrow ? "" : h}${D(n, t.roundness)}`;
|
|
1280
1202
|
}, Le = (t) => {
|
|
1281
|
-
const e = t.smallRadius, o = t.radius, r = Math.sqrt(e * e + o * o),
|
|
1203
|
+
const e = t.smallRadius, o = t.radius, r = Math.sqrt(e * e + o * o), s = e + o, d = t.arrowLength + r * (1 - o / s), n = e * o / s, c = [
|
|
1282
1204
|
{ x: t.arrowLength, y: w.y },
|
|
1283
|
-
{ x:
|
|
1284
|
-
{ x:
|
|
1285
|
-
].map((g) =>
|
|
1205
|
+
{ x: d, y: n },
|
|
1206
|
+
{ x: d, y: -n }
|
|
1207
|
+
].map((g) => v(g, t.fromVect, w)), a = [
|
|
1286
1208
|
`M ${c[0].x} ${c[0].y}`,
|
|
1287
1209
|
`A ${e} ${e} 0 0 1 ${c[1].x} ${c[1].y}`,
|
|
1288
1210
|
`A ${o} ${o} 0 1 0 ${c[2].x} ${c[2].y}`,
|
|
@@ -1324,21 +1246,21 @@ class De {
|
|
|
1324
1246
|
i(this, "hasTargetArrow");
|
|
1325
1247
|
this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.curvature = (e == null ? void 0 : e.curvature) ?? u.curvature, this.portCycleRadius = (e == null ? void 0 : e.cycleRadius) ?? u.cycleRadius, this.portCycleSmallRadius = (e == null ? void 0 : e.smallCycleRadius) ?? u.smallCycleRadius, this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow;
|
|
1326
1248
|
const o = (e == null ? void 0 : e.color) ?? u.color, r = (e == null ? void 0 : e.width) ?? u.width;
|
|
1327
|
-
this.svg.appendChild(this.group), this.line = F(o, r), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow =
|
|
1249
|
+
this.svg.appendChild(this.group), this.line = F(o, r), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = b(o), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = b(o), this.group.appendChild(this.targetArrow));
|
|
1328
1250
|
}
|
|
1329
1251
|
render(e) {
|
|
1330
|
-
const { x: o, y: r, width:
|
|
1252
|
+
const { x: o, y: r, width: s, height: d, flipX: n, flipY: h } = B(
|
|
1331
1253
|
e.from,
|
|
1332
1254
|
e.to
|
|
1333
1255
|
);
|
|
1334
|
-
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${
|
|
1256
|
+
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${s}px`, this.svg.style.height = `${d}px`, this.group.style.transform = `scale(${n}, ${h})`;
|
|
1335
1257
|
const c = T(
|
|
1336
1258
|
e.from.direction,
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
), a = T(e.to.direction,
|
|
1340
|
-
x:
|
|
1341
|
-
y:
|
|
1259
|
+
n,
|
|
1260
|
+
h
|
|
1261
|
+
), a = T(e.to.direction, n, h), l = {
|
|
1262
|
+
x: s,
|
|
1263
|
+
y: d
|
|
1342
1264
|
};
|
|
1343
1265
|
let g, f = a, x = -this.arrowLength;
|
|
1344
1266
|
if (e.from.portId === e.to.portId ? (g = Le({
|
|
@@ -1348,12 +1270,12 @@ class De {
|
|
|
1348
1270
|
arrowLength: this.arrowLength,
|
|
1349
1271
|
hasSourceArrow: this.hasSourceArrow,
|
|
1350
1272
|
hasTargetArrow: this.hasTargetArrow
|
|
1351
|
-
}), f = c, x = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g =
|
|
1273
|
+
}), f = c, x = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = be({
|
|
1352
1274
|
to: l,
|
|
1353
1275
|
fromVect: c,
|
|
1354
1276
|
toVect: a,
|
|
1355
|
-
flipX:
|
|
1356
|
-
flipY:
|
|
1277
|
+
flipX: n,
|
|
1278
|
+
flipY: h,
|
|
1357
1279
|
arrowLength: this.arrowLength,
|
|
1358
1280
|
detourDirection: this.detourDirection,
|
|
1359
1281
|
detourDistance: this.detourDistance,
|
|
@@ -1369,22 +1291,22 @@ class De {
|
|
|
1369
1291
|
hasSourceArrow: this.hasSourceArrow,
|
|
1370
1292
|
hasTargetArrow: this.hasTargetArrow
|
|
1371
1293
|
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
1372
|
-
const
|
|
1294
|
+
const y = m(
|
|
1373
1295
|
c,
|
|
1374
1296
|
w,
|
|
1375
1297
|
this.arrowLength,
|
|
1376
1298
|
this.arrowWidth
|
|
1377
1299
|
);
|
|
1378
|
-
this.sourceArrow.setAttribute("d",
|
|
1300
|
+
this.sourceArrow.setAttribute("d", y);
|
|
1379
1301
|
}
|
|
1380
1302
|
if (this.targetArrow) {
|
|
1381
|
-
const
|
|
1303
|
+
const y = m(
|
|
1382
1304
|
f,
|
|
1383
1305
|
l,
|
|
1384
1306
|
x,
|
|
1385
1307
|
this.arrowWidth
|
|
1386
1308
|
);
|
|
1387
|
-
this.targetArrow.setAttribute("d",
|
|
1309
|
+
this.targetArrow.setAttribute("d", y);
|
|
1388
1310
|
}
|
|
1389
1311
|
}
|
|
1390
1312
|
}
|
|
@@ -1411,22 +1333,22 @@ class Ce {
|
|
|
1411
1333
|
this.arrowOffset,
|
|
1412
1334
|
this.cycleSquareSide / 2
|
|
1413
1335
|
), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow;
|
|
1414
|
-
const r = (e == null ? void 0 : e.color) ?? u.color,
|
|
1415
|
-
this.svg.appendChild(this.group), this.line = F(r,
|
|
1336
|
+
const r = (e == null ? void 0 : e.color) ?? u.color, s = (e == null ? void 0 : e.width) ?? u.width;
|
|
1337
|
+
this.svg.appendChild(this.group), this.line = F(r, s), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = b(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = b(r), this.group.appendChild(this.targetArrow));
|
|
1416
1338
|
}
|
|
1417
1339
|
render(e) {
|
|
1418
|
-
const { x: o, y: r, width:
|
|
1340
|
+
const { x: o, y: r, width: s, height: d, flipX: n, flipY: h } = B(
|
|
1419
1341
|
e.from,
|
|
1420
1342
|
e.to
|
|
1421
1343
|
);
|
|
1422
|
-
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${
|
|
1344
|
+
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${s}px`, this.svg.style.height = `${d}px`, this.group.style.transform = `scale(${n}, ${h})`;
|
|
1423
1345
|
const c = T(
|
|
1424
1346
|
e.from.direction,
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
), a = T(e.to.direction,
|
|
1428
|
-
x:
|
|
1429
|
-
y:
|
|
1347
|
+
n,
|
|
1348
|
+
h
|
|
1349
|
+
), a = T(e.to.direction, n, h), l = {
|
|
1350
|
+
x: s,
|
|
1351
|
+
y: d
|
|
1430
1352
|
};
|
|
1431
1353
|
let g, f = a, x = -this.arrowLength;
|
|
1432
1354
|
if (e.from.portId === e.to.portId ? (g = H({
|
|
@@ -1441,8 +1363,8 @@ class Ce {
|
|
|
1441
1363
|
to: l,
|
|
1442
1364
|
fromVect: c,
|
|
1443
1365
|
toVect: a,
|
|
1444
|
-
flipX:
|
|
1445
|
-
flipY:
|
|
1366
|
+
flipX: n,
|
|
1367
|
+
flipY: h,
|
|
1446
1368
|
arrowLength: this.arrowLength,
|
|
1447
1369
|
arrowOffset: this.arrowOffset,
|
|
1448
1370
|
roundness: this.roundness,
|
|
@@ -1450,33 +1372,33 @@ class Ce {
|
|
|
1450
1372
|
detourDistance: this.detourDistance,
|
|
1451
1373
|
hasSourceArrow: this.hasSourceArrow,
|
|
1452
1374
|
hasTargetArrow: this.hasTargetArrow
|
|
1453
|
-
}) : g =
|
|
1375
|
+
}) : g = Pe({
|
|
1454
1376
|
to: l,
|
|
1455
1377
|
fromVect: c,
|
|
1456
1378
|
toVect: a,
|
|
1457
|
-
flipX:
|
|
1379
|
+
flipX: n,
|
|
1458
1380
|
arrowLength: this.arrowLength,
|
|
1459
1381
|
arrowOffset: this.arrowOffset,
|
|
1460
1382
|
roundness: this.roundness,
|
|
1461
1383
|
hasSourceArrow: this.hasSourceArrow,
|
|
1462
1384
|
hasTargetArrow: this.hasTargetArrow
|
|
1463
1385
|
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
1464
|
-
const
|
|
1386
|
+
const y = m(
|
|
1465
1387
|
c,
|
|
1466
1388
|
w,
|
|
1467
1389
|
this.arrowLength,
|
|
1468
1390
|
this.arrowWidth
|
|
1469
1391
|
);
|
|
1470
|
-
this.sourceArrow.setAttribute("d",
|
|
1392
|
+
this.sourceArrow.setAttribute("d", y);
|
|
1471
1393
|
}
|
|
1472
1394
|
if (this.targetArrow) {
|
|
1473
|
-
const
|
|
1395
|
+
const y = m(
|
|
1474
1396
|
f,
|
|
1475
1397
|
l,
|
|
1476
1398
|
x,
|
|
1477
1399
|
this.arrowWidth
|
|
1478
1400
|
);
|
|
1479
|
-
this.targetArrow.setAttribute("d",
|
|
1401
|
+
this.targetArrow.setAttribute("d", y);
|
|
1480
1402
|
}
|
|
1481
1403
|
}
|
|
1482
1404
|
}
|
|
@@ -1503,22 +1425,22 @@ class Ue {
|
|
|
1503
1425
|
this.arrowOffset,
|
|
1504
1426
|
this.cycleSquareSide / 2
|
|
1505
1427
|
), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow;
|
|
1506
|
-
const r = (e == null ? void 0 : e.color) ?? u.color,
|
|
1507
|
-
this.svg.appendChild(this.group), this.line = F(r,
|
|
1428
|
+
const r = (e == null ? void 0 : e.color) ?? u.color, s = (e == null ? void 0 : e.width) ?? u.width;
|
|
1429
|
+
this.svg.appendChild(this.group), this.line = F(r, s), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = b(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = b(r), this.group.appendChild(this.targetArrow));
|
|
1508
1430
|
}
|
|
1509
1431
|
render(e) {
|
|
1510
|
-
const { x: o, y: r, width:
|
|
1432
|
+
const { x: o, y: r, width: s, height: d, flipX: n, flipY: h } = B(
|
|
1511
1433
|
e.from,
|
|
1512
1434
|
e.to
|
|
1513
1435
|
);
|
|
1514
|
-
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${
|
|
1436
|
+
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${s}px`, this.svg.style.height = `${d}px`, this.group.style.transform = `scale(${n}, ${h})`;
|
|
1515
1437
|
const c = T(
|
|
1516
1438
|
e.from.direction,
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
), a = T(e.to.direction,
|
|
1520
|
-
x:
|
|
1521
|
-
y:
|
|
1439
|
+
n,
|
|
1440
|
+
h
|
|
1441
|
+
), a = T(e.to.direction, n, h), l = {
|
|
1442
|
+
x: s,
|
|
1443
|
+
y: d
|
|
1522
1444
|
};
|
|
1523
1445
|
let g, f = a, x = -this.arrowLength;
|
|
1524
1446
|
if (e.from.portId === e.to.portId ? (g = H({
|
|
@@ -1533,8 +1455,8 @@ class Ue {
|
|
|
1533
1455
|
to: l,
|
|
1534
1456
|
fromVect: c,
|
|
1535
1457
|
toVect: a,
|
|
1536
|
-
flipX:
|
|
1537
|
-
flipY:
|
|
1458
|
+
flipX: n,
|
|
1459
|
+
flipY: h,
|
|
1538
1460
|
arrowLength: this.arrowLength,
|
|
1539
1461
|
arrowOffset: this.arrowOffset,
|
|
1540
1462
|
roundness: this.roundness,
|
|
@@ -1552,22 +1474,22 @@ class Ue {
|
|
|
1552
1474
|
hasSourceArrow: this.hasSourceArrow,
|
|
1553
1475
|
hasTargetArrow: this.hasTargetArrow
|
|
1554
1476
|
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
1555
|
-
const
|
|
1477
|
+
const y = m(
|
|
1556
1478
|
c,
|
|
1557
1479
|
w,
|
|
1558
1480
|
this.arrowLength,
|
|
1559
1481
|
this.arrowWidth
|
|
1560
1482
|
);
|
|
1561
|
-
this.sourceArrow.setAttribute("d",
|
|
1483
|
+
this.sourceArrow.setAttribute("d", y);
|
|
1562
1484
|
}
|
|
1563
1485
|
if (this.targetArrow) {
|
|
1564
|
-
const
|
|
1486
|
+
const y = m(
|
|
1565
1487
|
f,
|
|
1566
1488
|
l,
|
|
1567
1489
|
x,
|
|
1568
1490
|
this.arrowWidth
|
|
1569
1491
|
);
|
|
1570
|
-
this.targetArrow.setAttribute("d",
|
|
1492
|
+
this.targetArrow.setAttribute("d", y);
|
|
1571
1493
|
}
|
|
1572
1494
|
}
|
|
1573
1495
|
}
|
|
@@ -1594,22 +1516,22 @@ class $e {
|
|
|
1594
1516
|
this.arrowOffset,
|
|
1595
1517
|
this.cycleSquareSide / 2
|
|
1596
1518
|
), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirectionVertical, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow;
|
|
1597
|
-
const r = (e == null ? void 0 : e.color) ?? u.color,
|
|
1598
|
-
this.svg.appendChild(this.group), this.line = F(r,
|
|
1519
|
+
const r = (e == null ? void 0 : e.color) ?? u.color, s = (e == null ? void 0 : e.width) ?? u.width;
|
|
1520
|
+
this.svg.appendChild(this.group), this.line = F(r, s), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = b(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = b(r), this.group.appendChild(this.targetArrow));
|
|
1599
1521
|
}
|
|
1600
1522
|
render(e) {
|
|
1601
|
-
const { x: o, y: r, width:
|
|
1523
|
+
const { x: o, y: r, width: s, height: d, flipX: n, flipY: h } = B(
|
|
1602
1524
|
e.from,
|
|
1603
1525
|
e.to
|
|
1604
1526
|
);
|
|
1605
|
-
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${
|
|
1527
|
+
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${s}px`, this.svg.style.height = `${d}px`, this.group.style.transform = `scale(${n}, ${h})`;
|
|
1606
1528
|
const c = T(
|
|
1607
1529
|
e.from.direction,
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
), a = T(e.to.direction,
|
|
1611
|
-
x:
|
|
1612
|
-
y:
|
|
1530
|
+
n,
|
|
1531
|
+
h
|
|
1532
|
+
), a = T(e.to.direction, n, h), l = {
|
|
1533
|
+
x: s,
|
|
1534
|
+
y: d
|
|
1613
1535
|
};
|
|
1614
1536
|
let g, f = a, x = -this.arrowLength;
|
|
1615
1537
|
if (e.from.portId === e.to.portId ? (g = H({
|
|
@@ -1624,8 +1546,8 @@ class $e {
|
|
|
1624
1546
|
to: l,
|
|
1625
1547
|
fromVect: c,
|
|
1626
1548
|
toVect: a,
|
|
1627
|
-
flipX:
|
|
1628
|
-
flipY:
|
|
1549
|
+
flipX: n,
|
|
1550
|
+
flipY: h,
|
|
1629
1551
|
arrowLength: this.arrowLength,
|
|
1630
1552
|
arrowOffset: this.arrowOffset,
|
|
1631
1553
|
roundness: this.roundness,
|
|
@@ -1637,29 +1559,29 @@ class $e {
|
|
|
1637
1559
|
to: l,
|
|
1638
1560
|
fromVect: c,
|
|
1639
1561
|
toVect: a,
|
|
1640
|
-
flipY:
|
|
1562
|
+
flipY: h,
|
|
1641
1563
|
arrowLength: this.arrowLength,
|
|
1642
1564
|
arrowOffset: this.arrowOffset,
|
|
1643
1565
|
roundness: this.roundness,
|
|
1644
1566
|
hasSourceArrow: this.hasSourceArrow,
|
|
1645
1567
|
hasTargetArrow: this.hasTargetArrow
|
|
1646
1568
|
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
1647
|
-
const
|
|
1569
|
+
const y = m(
|
|
1648
1570
|
c,
|
|
1649
1571
|
w,
|
|
1650
1572
|
this.arrowLength,
|
|
1651
1573
|
this.arrowWidth
|
|
1652
1574
|
);
|
|
1653
|
-
this.sourceArrow.setAttribute("d",
|
|
1575
|
+
this.sourceArrow.setAttribute("d", y);
|
|
1654
1576
|
}
|
|
1655
1577
|
if (this.targetArrow) {
|
|
1656
|
-
const
|
|
1578
|
+
const y = m(
|
|
1657
1579
|
f,
|
|
1658
1580
|
l,
|
|
1659
1581
|
x,
|
|
1660
1582
|
this.arrowWidth
|
|
1661
1583
|
);
|
|
1662
|
-
this.targetArrow.setAttribute("d",
|
|
1584
|
+
this.targetArrow.setAttribute("d", y);
|
|
1663
1585
|
}
|
|
1664
1586
|
}
|
|
1665
1587
|
}
|
|
@@ -1725,34 +1647,34 @@ const Re = (t) => {
|
|
|
1725
1647
|
});
|
|
1726
1648
|
}
|
|
1727
1649
|
}, Ie = (t) => {
|
|
1728
|
-
var o, r,
|
|
1650
|
+
var o, r, s, d, n;
|
|
1729
1651
|
const e = Te(
|
|
1730
1652
|
(o = t == null ? void 0 : t.nodes) == null ? void 0 : o.priority,
|
|
1731
1653
|
(r = t == null ? void 0 : t.edges) == null ? void 0 : r.priority
|
|
1732
1654
|
);
|
|
1733
1655
|
return {
|
|
1734
1656
|
nodes: {
|
|
1735
|
-
centerFn: ((
|
|
1657
|
+
centerFn: ((s = t == null ? void 0 : t.nodes) == null ? void 0 : s.centerFn) ?? pe,
|
|
1736
1658
|
priorityFn: e.nodesPriorityFn
|
|
1737
1659
|
},
|
|
1738
1660
|
ports: {
|
|
1739
|
-
direction: ((
|
|
1661
|
+
direction: ((d = t == null ? void 0 : t.ports) == null ? void 0 : d.direction) ?? 0
|
|
1740
1662
|
},
|
|
1741
1663
|
edges: {
|
|
1742
|
-
shapeFactory: Re(((
|
|
1664
|
+
shapeFactory: Re(((n = t == null ? void 0 : t.edges) == null ? void 0 : n.shape) ?? {}),
|
|
1743
1665
|
priorityFn: e.edgesPriorityFn
|
|
1744
1666
|
}
|
|
1745
1667
|
};
|
|
1746
1668
|
};
|
|
1747
1669
|
class We {
|
|
1748
|
-
constructor(e, o) {
|
|
1749
|
-
i(this, "nodeIdGenerator", new
|
|
1670
|
+
constructor(e, o, r) {
|
|
1671
|
+
i(this, "nodeIdGenerator", new Y(
|
|
1750
1672
|
(e) => this.graph.getNode(e) !== null
|
|
1751
1673
|
));
|
|
1752
|
-
i(this, "portIdGenerator", new
|
|
1674
|
+
i(this, "portIdGenerator", new Y(
|
|
1753
1675
|
(e) => this.graph.getPort(e) !== null
|
|
1754
1676
|
));
|
|
1755
|
-
i(this, "edgeIdGenerator", new
|
|
1677
|
+
i(this, "edgeIdGenerator", new Y(
|
|
1756
1678
|
(e) => this.graph.getEdge(e) !== null
|
|
1757
1679
|
));
|
|
1758
1680
|
i(this, "defaults");
|
|
@@ -1764,20 +1686,7 @@ class We {
|
|
|
1764
1686
|
* provides api for accessing viewport state
|
|
1765
1687
|
*/
|
|
1766
1688
|
i(this, "viewport");
|
|
1767
|
-
this.
|
|
1768
|
-
}
|
|
1769
|
-
/**
|
|
1770
|
-
* attaches canvas to given element
|
|
1771
|
-
* detaches element first when canvas is attached
|
|
1772
|
-
*/
|
|
1773
|
-
attach(e) {
|
|
1774
|
-
return this.controller.attach(e), this;
|
|
1775
|
-
}
|
|
1776
|
-
/**
|
|
1777
|
-
* detaches canvas from element when attached
|
|
1778
|
-
*/
|
|
1779
|
-
detach() {
|
|
1780
|
-
return this.controller.detach(), this;
|
|
1689
|
+
this.element = e, this.controller = o, this.defaults = Ie(r), this.graph = o.graph, this.viewport = o.viewport;
|
|
1781
1690
|
}
|
|
1782
1691
|
/**
|
|
1783
1692
|
* adds node to graph
|
|
@@ -1785,7 +1694,7 @@ class We {
|
|
|
1785
1694
|
addNode(e) {
|
|
1786
1695
|
const o = this.nodeIdGenerator.create(e.id);
|
|
1787
1696
|
if (this.graph.getNode(o) !== null)
|
|
1788
|
-
throw new
|
|
1697
|
+
throw new A("failed to add node with existing id");
|
|
1789
1698
|
if (this.controller.addNode({
|
|
1790
1699
|
id: o,
|
|
1791
1700
|
element: e.element,
|
|
@@ -1808,7 +1717,7 @@ class We {
|
|
|
1808
1717
|
*/
|
|
1809
1718
|
updateNode(e, o) {
|
|
1810
1719
|
if (this.graph.getNode(e) === null)
|
|
1811
|
-
throw new
|
|
1720
|
+
throw new A("failed to update nonexisting node");
|
|
1812
1721
|
return this.controller.updateNode(e, o ?? {}), this;
|
|
1813
1722
|
}
|
|
1814
1723
|
/**
|
|
@@ -1818,7 +1727,7 @@ class We {
|
|
|
1818
1727
|
*/
|
|
1819
1728
|
removeNode(e) {
|
|
1820
1729
|
if (this.graph.getNode(e) === null)
|
|
1821
|
-
throw new
|
|
1730
|
+
throw new A("failed to remove nonexisting node");
|
|
1822
1731
|
return this.controller.removeNode(e), this;
|
|
1823
1732
|
}
|
|
1824
1733
|
/**
|
|
@@ -1827,9 +1736,9 @@ class We {
|
|
|
1827
1736
|
markPort(e) {
|
|
1828
1737
|
const o = this.portIdGenerator.create(e.id);
|
|
1829
1738
|
if (this.graph.getPort(o) !== null)
|
|
1830
|
-
throw new
|
|
1739
|
+
throw new A("failed to add port with existing id");
|
|
1831
1740
|
if (this.graph.getNode(e.nodeId) === null)
|
|
1832
|
-
throw new
|
|
1741
|
+
throw new A("failed to set port on nonexisting node");
|
|
1833
1742
|
return this.controller.markPort({
|
|
1834
1743
|
id: o,
|
|
1835
1744
|
element: e.element,
|
|
@@ -1842,7 +1751,7 @@ class We {
|
|
|
1842
1751
|
*/
|
|
1843
1752
|
updatePort(e, o) {
|
|
1844
1753
|
if (this.graph.getPort(e) === null)
|
|
1845
|
-
throw new
|
|
1754
|
+
throw new A("failed to unset nonexisting port");
|
|
1846
1755
|
return this.controller.updatePort(e, o ?? {}), this;
|
|
1847
1756
|
}
|
|
1848
1757
|
/**
|
|
@@ -1851,7 +1760,7 @@ class We {
|
|
|
1851
1760
|
*/
|
|
1852
1761
|
unmarkPort(e) {
|
|
1853
1762
|
if (this.graph.getPort(e) === null)
|
|
1854
|
-
throw new
|
|
1763
|
+
throw new A("failed to unset nonexisting port");
|
|
1855
1764
|
return this.controller.unmarkPort(e), this;
|
|
1856
1765
|
}
|
|
1857
1766
|
/**
|
|
@@ -1860,11 +1769,11 @@ class We {
|
|
|
1860
1769
|
addEdge(e) {
|
|
1861
1770
|
const o = this.edgeIdGenerator.create(e.id);
|
|
1862
1771
|
if (this.graph.getEdge(o) !== null)
|
|
1863
|
-
throw new
|
|
1772
|
+
throw new A("failed to add edge with existing id");
|
|
1864
1773
|
if (this.graph.getPort(e.from) === null)
|
|
1865
|
-
throw new
|
|
1774
|
+
throw new A("failed to add edge from nonexisting port");
|
|
1866
1775
|
if (this.graph.getPort(e.to) === null)
|
|
1867
|
-
throw new
|
|
1776
|
+
throw new A("failed to add edge to nonexisting port");
|
|
1868
1777
|
return this.controller.addEdge({
|
|
1869
1778
|
id: o,
|
|
1870
1779
|
from: e.from,
|
|
@@ -1878,7 +1787,7 @@ class We {
|
|
|
1878
1787
|
*/
|
|
1879
1788
|
updateEdge(e, o) {
|
|
1880
1789
|
if (this.graph.getEdge(e) === null)
|
|
1881
|
-
throw new
|
|
1790
|
+
throw new A("failed to update nonexisting edge");
|
|
1882
1791
|
return this.controller.updateEdge(e, o ?? {}), this;
|
|
1883
1792
|
}
|
|
1884
1793
|
/**
|
|
@@ -1886,7 +1795,7 @@ class We {
|
|
|
1886
1795
|
*/
|
|
1887
1796
|
removeEdge(e) {
|
|
1888
1797
|
if (this.graph.getEdge(e) === null)
|
|
1889
|
-
throw new
|
|
1798
|
+
throw new A("failed to remove nonexisting edge");
|
|
1890
1799
|
return this.controller.removeEdge(e), this;
|
|
1891
1800
|
}
|
|
1892
1801
|
/**
|
|
@@ -1950,7 +1859,7 @@ class Fe {
|
|
|
1950
1859
|
i(this, "onBeforeEdgeRemoved");
|
|
1951
1860
|
i(this, "beforeClearEmitter");
|
|
1952
1861
|
i(this, "onBeforeClear");
|
|
1953
|
-
[this.afterNodeAddedEmitter, this.onAfterNodeAdded] =
|
|
1862
|
+
[this.afterNodeAddedEmitter, this.onAfterNodeAdded] = E(), [this.afterNodeUpdatedEmitter, this.onAfterNodeUpdated] = E(), [this.afterNodePriorityUpdatedEmitter, this.onAfterNodePriorityUpdated] = E(), [this.beforeNodeRemovedEmitter, this.onBeforeNodeRemoved] = E(), [this.afterPortAddedEmitter, this.onAfterPortAdded] = E(), [this.afterPortUpdatedEmitter, this.onAfterPortUpdated] = E(), [this.beforePortRemovedEmitter, this.onBeforePortRemoved] = E(), [this.afterEdgeAddedEmitter, this.onAfterEdgeAdded] = E(), [this.afterEdgeShapeUpdatedEmitter, this.onAfterEdgeShapeUpdated] = E(), [this.afterEdgeUpdatedEmitter, this.onAfterEdgeUpdated] = E(), [this.afterEdgePriorityUpdatedEmitter, this.onAfterEdgePriorityUpdated] = E(), [this.beforeEdgeRemovedEmitter, this.onBeforeEdgeRemoved] = E(), [this.beforeClearEmitter, this.onBeforeClear] = E();
|
|
1954
1863
|
}
|
|
1955
1864
|
addNode(e) {
|
|
1956
1865
|
const o = /* @__PURE__ */ new Map(), r = {
|
|
@@ -2007,13 +1916,13 @@ class Fe {
|
|
|
2007
1916
|
}
|
|
2008
1917
|
updateEdge(e, o) {
|
|
2009
1918
|
if (o.from !== void 0 || o.to !== void 0) {
|
|
2010
|
-
const
|
|
1919
|
+
const s = this.edges.get(e);
|
|
2011
1920
|
this.removeEdgeInternal(e), this.addEdgeInternal({
|
|
2012
1921
|
id: e,
|
|
2013
|
-
from: o.from ??
|
|
2014
|
-
to: o.to ??
|
|
2015
|
-
shape:
|
|
2016
|
-
priority:
|
|
1922
|
+
from: o.from ?? s.from,
|
|
1923
|
+
to: o.to ?? s.to,
|
|
1924
|
+
shape: s.shape,
|
|
1925
|
+
priority: s.priority
|
|
2017
1926
|
});
|
|
2018
1927
|
}
|
|
2019
1928
|
const r = this.edges.get(e);
|
|
@@ -2050,22 +1959,22 @@ class Fe {
|
|
|
2050
1959
|
getNodeIncomingEdgeIds(e) {
|
|
2051
1960
|
const o = Array.from(this.nodes.get(e).ports.keys());
|
|
2052
1961
|
let r = [];
|
|
2053
|
-
return o.forEach((
|
|
2054
|
-
r = [...r, ...this.getPortIncomingEdgeIds(
|
|
1962
|
+
return o.forEach((s) => {
|
|
1963
|
+
r = [...r, ...this.getPortIncomingEdgeIds(s)];
|
|
2055
1964
|
}), r;
|
|
2056
1965
|
}
|
|
2057
1966
|
getNodeOutcomingEdgeIds(e) {
|
|
2058
1967
|
const o = Array.from(this.nodes.get(e).ports.keys());
|
|
2059
1968
|
let r = [];
|
|
2060
|
-
return o.forEach((
|
|
2061
|
-
r = [...r, ...this.getPortOutcomingEdgeIds(
|
|
1969
|
+
return o.forEach((s) => {
|
|
1970
|
+
r = [...r, ...this.getPortOutcomingEdgeIds(s)];
|
|
2062
1971
|
}), r;
|
|
2063
1972
|
}
|
|
2064
1973
|
getNodeCycleEdgeIds(e) {
|
|
2065
1974
|
const o = Array.from(this.nodes.get(e).ports.keys());
|
|
2066
1975
|
let r = [];
|
|
2067
|
-
return o.forEach((
|
|
2068
|
-
r = [...r, ...this.getPortCycleEdgeIds(
|
|
1976
|
+
return o.forEach((s) => {
|
|
1977
|
+
r = [...r, ...this.getPortCycleEdgeIds(s)];
|
|
2069
1978
|
}), r;
|
|
2070
1979
|
}
|
|
2071
1980
|
getNodeAdjacentEdgeIds(e) {
|
|
@@ -2084,28 +1993,28 @@ class Fe {
|
|
|
2084
1993
|
}), e.from !== e.to ? (this.outcommingEdges.get(e.from).add(e.id), this.incommingEdges.get(e.to).add(e.id)) : this.cycleEdges.get(e.from).add(e.id);
|
|
2085
1994
|
}
|
|
2086
1995
|
removeEdgeInternal(e) {
|
|
2087
|
-
const o = this.edges.get(e), r = o.from,
|
|
2088
|
-
this.cycleEdges.get(r).delete(e), this.cycleEdges.get(
|
|
1996
|
+
const o = this.edges.get(e), r = o.from, s = o.to;
|
|
1997
|
+
this.cycleEdges.get(r).delete(e), this.cycleEdges.get(s).delete(e), this.incommingEdges.get(r).delete(e), this.incommingEdges.get(s).delete(e), this.outcommingEdges.get(r).delete(e), this.outcommingEdges.get(s).delete(e), this.edges.delete(e);
|
|
2089
1998
|
}
|
|
2090
1999
|
}
|
|
2091
|
-
const
|
|
2000
|
+
const q = (t) => ({
|
|
2092
2001
|
scale: 1 / t.scale,
|
|
2093
2002
|
x: -t.x / t.scale,
|
|
2094
2003
|
y: -t.y / t.scale
|
|
2095
|
-
}),
|
|
2004
|
+
}), O = {
|
|
2096
2005
|
scale: 1,
|
|
2097
2006
|
x: 0,
|
|
2098
2007
|
y: 0
|
|
2099
2008
|
};
|
|
2100
2009
|
class Be {
|
|
2101
2010
|
constructor() {
|
|
2102
|
-
i(this, "viewportMatrix",
|
|
2103
|
-
i(this, "contentMatrix",
|
|
2011
|
+
i(this, "viewportMatrix", O);
|
|
2012
|
+
i(this, "contentMatrix", O);
|
|
2104
2013
|
i(this, "afterUpdateEmitter");
|
|
2105
2014
|
i(this, "onAfterUpdated");
|
|
2106
2015
|
i(this, "beforeUpdateEmitter");
|
|
2107
2016
|
i(this, "onBeforeUpdated");
|
|
2108
|
-
[this.afterUpdateEmitter, this.onAfterUpdated] =
|
|
2017
|
+
[this.afterUpdateEmitter, this.onAfterUpdated] = E(), [this.beforeUpdateEmitter, this.onBeforeUpdated] = E();
|
|
2109
2018
|
}
|
|
2110
2019
|
getViewportMatrix() {
|
|
2111
2020
|
return this.viewportMatrix;
|
|
@@ -2118,14 +2027,14 @@ class Be {
|
|
|
2118
2027
|
scale: e.scale ?? this.viewportMatrix.scale,
|
|
2119
2028
|
x: e.x ?? this.viewportMatrix.x,
|
|
2120
2029
|
y: e.y ?? this.viewportMatrix.y
|
|
2121
|
-
}, this.contentMatrix =
|
|
2030
|
+
}, this.contentMatrix = q(this.viewportMatrix), this.afterUpdateEmitter.emit();
|
|
2122
2031
|
}
|
|
2123
2032
|
patchContentMatrix(e) {
|
|
2124
2033
|
this.beforeUpdateEmitter.emit(), this.contentMatrix = {
|
|
2125
2034
|
scale: e.scale ?? this.contentMatrix.scale,
|
|
2126
2035
|
x: e.x ?? this.contentMatrix.x,
|
|
2127
2036
|
y: e.y ?? this.contentMatrix.y
|
|
2128
|
-
}, this.viewportMatrix =
|
|
2037
|
+
}, this.viewportMatrix = q(this.contentMatrix), this.afterUpdateEmitter.emit();
|
|
2129
2038
|
}
|
|
2130
2039
|
}
|
|
2131
2040
|
class j {
|
|
@@ -2145,8 +2054,8 @@ class j {
|
|
|
2145
2054
|
});
|
|
2146
2055
|
this.canvas = e, this.nodesResizeObserver = new ResizeObserver((o) => {
|
|
2147
2056
|
o.forEach((r) => {
|
|
2148
|
-
const
|
|
2149
|
-
this.handleNodeResize(
|
|
2057
|
+
const s = r.target;
|
|
2058
|
+
this.handleNodeResize(s);
|
|
2150
2059
|
});
|
|
2151
2060
|
}), this.canvas.graph.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.canvas.graph.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.canvas.graph.onBeforeClear.subscribe(this.onBeforeClear);
|
|
2152
2061
|
}
|
|
@@ -2155,13 +2064,14 @@ class j {
|
|
|
2155
2064
|
}
|
|
2156
2065
|
handleNodeResize(e) {
|
|
2157
2066
|
const o = this.elementToNodeId.get(e);
|
|
2158
|
-
this.canvas.updateNode(o), this.canvas.graph.getNodeAdjacentEdgeIds(o).forEach((
|
|
2159
|
-
this.canvas.updateEdge(
|
|
2067
|
+
this.canvas.updateNode(o), this.canvas.graph.getNodeAdjacentEdgeIds(o).forEach((s) => {
|
|
2068
|
+
this.canvas.updateEdge(s);
|
|
2160
2069
|
});
|
|
2161
2070
|
}
|
|
2162
2071
|
}
|
|
2163
|
-
class
|
|
2072
|
+
class Ye {
|
|
2164
2073
|
constructor() {
|
|
2074
|
+
i(this, "element", null);
|
|
2165
2075
|
i(this, "canvasDefaults", {});
|
|
2166
2076
|
i(this, "dragOptions");
|
|
2167
2077
|
i(this, "transformOptions");
|
|
@@ -2171,19 +2081,15 @@ class ze {
|
|
|
2171
2081
|
i(this, "hasResizeReactiveNodes", !1);
|
|
2172
2082
|
i(this, "boxRenderingTrigger");
|
|
2173
2083
|
}
|
|
2084
|
+
setElement(e) {
|
|
2085
|
+
return this.element = e, this;
|
|
2086
|
+
}
|
|
2174
2087
|
/**
|
|
2175
2088
|
* specifies default values for graph entities
|
|
2176
2089
|
*/
|
|
2177
2090
|
setDefaults(e) {
|
|
2178
2091
|
return this.canvasDefaults = e, this;
|
|
2179
2092
|
}
|
|
2180
|
-
/**
|
|
2181
|
-
* @deprecated
|
|
2182
|
-
* use setDefaults instead
|
|
2183
|
-
*/
|
|
2184
|
-
setOptions(e) {
|
|
2185
|
-
return this.setDefaults(e), this;
|
|
2186
|
-
}
|
|
2187
2093
|
/**
|
|
2188
2094
|
* enables nodes draggable by user
|
|
2189
2095
|
*/
|
|
@@ -2215,41 +2121,52 @@ class ze {
|
|
|
2215
2121
|
* builds final canvas
|
|
2216
2122
|
*/
|
|
2217
2123
|
build() {
|
|
2124
|
+
if (this.element === null)
|
|
2125
|
+
throw new A(
|
|
2126
|
+
"unable to build canvas when no attach element specified"
|
|
2127
|
+
);
|
|
2218
2128
|
let e = this.boxRenderingTrigger;
|
|
2219
2129
|
this.virtualScrollOptions !== void 0 && e === void 0 && (e = new te());
|
|
2220
2130
|
const o = new Fe(), r = new Be();
|
|
2221
|
-
let
|
|
2222
|
-
|
|
2223
|
-
|
|
2131
|
+
let s = new Ee(
|
|
2132
|
+
o,
|
|
2133
|
+
r,
|
|
2134
|
+
this.element
|
|
2135
|
+
);
|
|
2136
|
+
e !== void 0 && (s = new Se(s, o, e));
|
|
2137
|
+
let d = new ne(
|
|
2224
2138
|
o,
|
|
2225
2139
|
r,
|
|
2226
|
-
|
|
2140
|
+
s
|
|
2227
2141
|
);
|
|
2228
|
-
this.hasDraggableNode && (
|
|
2229
|
-
|
|
2142
|
+
this.hasDraggableNode && (d = new de(
|
|
2143
|
+
d,
|
|
2144
|
+
this.element,
|
|
2230
2145
|
this.dragOptions
|
|
2231
|
-
)), this.virtualScrollOptions !== void 0 ?
|
|
2232
|
-
|
|
2146
|
+
)), this.virtualScrollOptions !== void 0 ? d = new fe(
|
|
2147
|
+
d,
|
|
2233
2148
|
e,
|
|
2234
2149
|
this.transformOptions,
|
|
2235
|
-
this.virtualScrollOptions
|
|
2236
|
-
|
|
2237
|
-
|
|
2150
|
+
this.virtualScrollOptions,
|
|
2151
|
+
this.element
|
|
2152
|
+
) : this.hasTransformableViewport && (d = new ee(
|
|
2153
|
+
d,
|
|
2154
|
+
this.element,
|
|
2238
2155
|
this.transformOptions
|
|
2239
2156
|
));
|
|
2240
|
-
const
|
|
2241
|
-
return this.hasResizeReactiveNodes && j.configure(
|
|
2157
|
+
const n = new We(this.element, d, this.canvasDefaults);
|
|
2158
|
+
return this.hasResizeReactiveNodes && j.configure(n), this.reset(), n;
|
|
2242
2159
|
}
|
|
2243
2160
|
reset() {
|
|
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;
|
|
2161
|
+
this.element = null, 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;
|
|
2245
2162
|
}
|
|
2246
2163
|
}
|
|
2247
2164
|
export {
|
|
2248
2165
|
De as BezierEdgeShape,
|
|
2249
|
-
|
|
2166
|
+
Ye as CanvasBuilder,
|
|
2250
2167
|
te as EventSubject,
|
|
2251
2168
|
Ce as HorizontalEdgeShape,
|
|
2252
|
-
|
|
2169
|
+
A as HtmlGraphError,
|
|
2253
2170
|
Ue as StraightEdgeShape,
|
|
2254
2171
|
$e as VerticalEdgeShape
|
|
2255
2172
|
};
|