@html-graph/html-graph 7.4.0 → 7.5.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 +18 -1
- package/dist/html-graph.js +219 -181
- package/dist/html-graph.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/html-graph.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var i = (r, e, t) =>
|
|
1
|
+
var ze = Object.defineProperty;
|
|
2
|
+
var ke = (r, e, t) => e in r ? ze(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
|
+
var i = (r, e, t) => ke(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
const C = (r, e) => ({
|
|
5
5
|
x: r.scale * e.x + r.x,
|
|
6
6
|
y: r.scale * e.y + r.y
|
|
@@ -198,7 +198,7 @@ class je {
|
|
|
198
198
|
this.htmlView.detachEdge(e), this.attachedEdges.delete(e);
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
|
-
class
|
|
201
|
+
class qe {
|
|
202
202
|
constructor(e, t) {
|
|
203
203
|
i(this, "deferredNodes", /* @__PURE__ */ new Set());
|
|
204
204
|
i(this, "deferredEdges", /* @__PURE__ */ new Set());
|
|
@@ -507,10 +507,10 @@ class ve {
|
|
|
507
507
|
this.onAfterEdgeShapeUpdated
|
|
508
508
|
), this.graphStore.onAfterEdgeUpdated.unsubscribe(this.onAfterEdgeUpdated), this.graphStore.onAfterEdgePriorityUpdated.unsubscribe(
|
|
509
509
|
this.onAfterEdgePriorityUpdated
|
|
510
|
-
), this.graphStore.onBeforeEdgeRemoved.unsubscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.unsubscribe(this.onBeforeClear), this.htmlView.destroy(), this.destroyed = !0);
|
|
510
|
+
), this.graphStore.onBeforeEdgeRemoved.unsubscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.unsubscribe(this.onBeforeClear), this.htmlView.destroy(), this.viewportStore.destroy(), this.destroyed = !0);
|
|
511
511
|
}
|
|
512
512
|
}
|
|
513
|
-
class
|
|
513
|
+
class Ke {
|
|
514
514
|
constructor() {
|
|
515
515
|
i(this, "singleToMultiMap", /* @__PURE__ */ new Map());
|
|
516
516
|
i(this, "multiToSingleMap", /* @__PURE__ */ new Map());
|
|
@@ -550,7 +550,7 @@ class Qe {
|
|
|
550
550
|
return this.multiToSingleMap.get(e) !== void 0;
|
|
551
551
|
}
|
|
552
552
|
}
|
|
553
|
-
class
|
|
553
|
+
class Ae {
|
|
554
554
|
constructor() {
|
|
555
555
|
i(this, "nodes", /* @__PURE__ */ new Map());
|
|
556
556
|
i(this, "ports", /* @__PURE__ */ new Map());
|
|
@@ -559,7 +559,7 @@ class xe {
|
|
|
559
559
|
i(this, "portIncomingEdges", /* @__PURE__ */ new Map());
|
|
560
560
|
i(this, "portOutcomingEdges", /* @__PURE__ */ new Map());
|
|
561
561
|
i(this, "portCycleEdges", /* @__PURE__ */ new Map());
|
|
562
|
-
i(this, "elementPorts", new
|
|
562
|
+
i(this, "elementPorts", new Ke());
|
|
563
563
|
i(this, "afterNodeAddedEmitter");
|
|
564
564
|
i(this, "onAfterNodeAdded");
|
|
565
565
|
i(this, "afterNodeUpdatedEmitter");
|
|
@@ -766,13 +766,20 @@ const ce = (r) => ({
|
|
|
766
766
|
x: 0,
|
|
767
767
|
y: 0
|
|
768
768
|
};
|
|
769
|
-
class
|
|
770
|
-
constructor() {
|
|
769
|
+
class Qe {
|
|
770
|
+
constructor(e) {
|
|
771
771
|
i(this, "viewportMatrix", le);
|
|
772
772
|
i(this, "contentMatrix", le);
|
|
773
|
+
i(this, "beforeUpdateEmitter");
|
|
774
|
+
i(this, "onBeforeUpdated");
|
|
773
775
|
i(this, "afterUpdateEmitter");
|
|
774
776
|
i(this, "onAfterUpdated");
|
|
775
|
-
|
|
777
|
+
i(this, "afterResizeEmitter");
|
|
778
|
+
i(this, "onAfterResize");
|
|
779
|
+
i(this, "observer", new ResizeObserver(() => {
|
|
780
|
+
this.afterResizeEmitter.emit();
|
|
781
|
+
}));
|
|
782
|
+
this.host = e, [this.afterUpdateEmitter, this.onAfterUpdated] = E(), [this.beforeUpdateEmitter, this.onBeforeUpdated] = E(), [this.afterResizeEmitter, this.onAfterResize] = E(), this.observer.observe(this.host);
|
|
776
783
|
}
|
|
777
784
|
getViewportMatrix() {
|
|
778
785
|
return this.viewportMatrix;
|
|
@@ -785,17 +792,24 @@ class Ze {
|
|
|
785
792
|
scale: e.scale ?? this.viewportMatrix.scale,
|
|
786
793
|
x: e.x ?? this.viewportMatrix.x,
|
|
787
794
|
y: e.y ?? this.viewportMatrix.y
|
|
788
|
-
}, this.contentMatrix = ce(this.viewportMatrix), this.afterUpdateEmitter.emit();
|
|
795
|
+
}, this.beforeUpdateEmitter.emit(), this.contentMatrix = ce(this.viewportMatrix), this.afterUpdateEmitter.emit();
|
|
789
796
|
}
|
|
790
797
|
patchContentMatrix(e) {
|
|
791
798
|
this.contentMatrix = {
|
|
792
799
|
scale: e.scale ?? this.contentMatrix.scale,
|
|
793
800
|
x: e.x ?? this.contentMatrix.x,
|
|
794
801
|
y: e.y ?? this.contentMatrix.y
|
|
795
|
-
}, this.viewportMatrix = ce(this.contentMatrix), this.afterUpdateEmitter.emit();
|
|
802
|
+
}, this.beforeUpdateEmitter.emit(), this.viewportMatrix = ce(this.contentMatrix), this.afterUpdateEmitter.emit();
|
|
803
|
+
}
|
|
804
|
+
getDimensions() {
|
|
805
|
+
const { width: e, height: t } = this.host.getBoundingClientRect();
|
|
806
|
+
return { width: e, height: t };
|
|
807
|
+
}
|
|
808
|
+
destroy() {
|
|
809
|
+
this.observer.disconnect();
|
|
796
810
|
}
|
|
797
811
|
}
|
|
798
|
-
class
|
|
812
|
+
class q {
|
|
799
813
|
constructor(e) {
|
|
800
814
|
i(this, "elementToNodeId", /* @__PURE__ */ new Map());
|
|
801
815
|
i(this, "nodesResizeObserver");
|
|
@@ -818,17 +832,17 @@ class K {
|
|
|
818
832
|
}), this.canvas.graph.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.canvas.graph.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.canvas.graph.onBeforeClear.subscribe(this.onBeforeClear);
|
|
819
833
|
}
|
|
820
834
|
static configure(e) {
|
|
821
|
-
new
|
|
835
|
+
new q(e);
|
|
822
836
|
}
|
|
823
837
|
handleNodeResize(e) {
|
|
824
838
|
const t = this.elementToNodeId.get(e);
|
|
825
839
|
this.canvas.updateNode(t);
|
|
826
840
|
}
|
|
827
841
|
}
|
|
828
|
-
const
|
|
842
|
+
const Ze = (r, e, t) => {
|
|
829
843
|
const { x: s, y: o, width: n, height: a } = r.getBoundingClientRect();
|
|
830
844
|
return e >= s && e <= s + n && t >= o && t <= o + a;
|
|
831
|
-
}, Je = (r, e, t) => e >= 0 && e <= r.innerWidth && t >= 0 && t <= r.innerHeight, V = (r, e, t, s) =>
|
|
845
|
+
}, Je = (r, e, t) => e >= 0 && e <= r.innerWidth && t >= 0 && t <= r.innerHeight, V = (r, e, t, s) => Ze(e, t, s) && Je(r, t, s), U = (r, e) => {
|
|
832
846
|
e !== null ? r.style.cursor = e : r.style.removeProperty("cursor");
|
|
833
847
|
}, B = (r) => {
|
|
834
848
|
const e = document.createElement("div");
|
|
@@ -864,19 +878,19 @@ const qe = (r, e, t) => {
|
|
|
864
878
|
status: "notFound"
|
|
865
879
|
};
|
|
866
880
|
};
|
|
867
|
-
function*
|
|
881
|
+
function* Ee(r, e) {
|
|
868
882
|
const t = r.elementsFromPoint(e.x, e.y);
|
|
869
883
|
for (const s of t) {
|
|
870
884
|
if (s.shadowRoot !== null) {
|
|
871
|
-
const o =
|
|
885
|
+
const o = Ee(s.shadowRoot, e);
|
|
872
886
|
for (const n of o)
|
|
873
887
|
yield n;
|
|
874
888
|
}
|
|
875
889
|
yield s;
|
|
876
890
|
}
|
|
877
891
|
}
|
|
878
|
-
const
|
|
879
|
-
const t =
|
|
892
|
+
const xe = (r, e) => {
|
|
893
|
+
const t = Ee(document, e);
|
|
880
894
|
for (const s of t) {
|
|
881
895
|
const o = _e(r, s);
|
|
882
896
|
if (o.status === "portFound")
|
|
@@ -977,10 +991,10 @@ class tt {
|
|
|
977
991
|
}, y = {
|
|
978
992
|
x: c.x + this.params.curvature * this.params.sourceDirection.x,
|
|
979
993
|
y: c.y + this.params.curvature * this.params.sourceDirection.y
|
|
980
|
-
},
|
|
994
|
+
}, A = {
|
|
981
995
|
x: l.x - this.params.curvature * this.params.targetDirection.x,
|
|
982
996
|
y: l.y - this.params.curvature * this.params.targetDirection.y
|
|
983
|
-
},
|
|
997
|
+
}, x = {
|
|
984
998
|
x: c.x + h,
|
|
985
999
|
y: c.y + d
|
|
986
1000
|
}, S = {
|
|
@@ -990,23 +1004,23 @@ class tt {
|
|
|
990
1004
|
this.path = [
|
|
991
1005
|
`M ${t.x} ${t.y}`,
|
|
992
1006
|
`L ${c.x} ${c.y}`,
|
|
993
|
-
`C ${y.x} ${y.y} ${
|
|
994
|
-
`C ${S.x} ${S.y} ${
|
|
1007
|
+
`C ${y.x} ${y.y} ${x.x} ${x.y} ${w.x} ${w.y}`,
|
|
1008
|
+
`C ${S.x} ${S.y} ${A.x} ${A.y} ${l.x} ${l.y}`,
|
|
995
1009
|
`L ${s.x} ${s.y}`
|
|
996
1010
|
].join(" "), this.midpoint = W(w, e.flipX, e.flipY, e.to);
|
|
997
1011
|
}
|
|
998
1012
|
}
|
|
999
|
-
const
|
|
1013
|
+
const K = Object.freeze({
|
|
1000
1014
|
edgeColor: "--edge-color"
|
|
1001
1015
|
}), Pe = (r) => {
|
|
1002
1016
|
const e = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
1003
|
-
return e.style.pointerEvents = "none", e.style.position = "absolute", e.style.top = "0", e.style.left = "0", e.style.overflow = "visible", e.style.setProperty(
|
|
1017
|
+
return e.style.pointerEvents = "none", e.style.position = "absolute", e.style.top = "0", e.style.left = "0", e.style.overflow = "visible", e.style.setProperty(K.edgeColor, r), e;
|
|
1004
1018
|
}, Te = (r) => {
|
|
1005
1019
|
const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
1006
|
-
return e.setAttribute("stroke", `var(${
|
|
1020
|
+
return e.setAttribute("stroke", `var(${K.edgeColor})`), e.setAttribute("stroke-width", `${r}`), e.setAttribute("fill", "none"), e;
|
|
1007
1021
|
}, O = () => {
|
|
1008
1022
|
const r = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
1009
|
-
return r.setAttribute("fill", `var(${
|
|
1023
|
+
return r.setAttribute("fill", `var(${K.edgeColor})`), r;
|
|
1010
1024
|
}, De = () => {
|
|
1011
1025
|
const r = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
|
1012
1026
|
return r.style.transformOrigin = "50% 50%", r;
|
|
@@ -1024,7 +1038,7 @@ const Q = Object.freeze({
|
|
|
1024
1038
|
const F = r[d + 1];
|
|
1025
1039
|
o = F.x - h.x, n = F.y - h.y, a = Math.sqrt(o * o + n * n);
|
|
1026
1040
|
}
|
|
1027
|
-
const
|
|
1041
|
+
const x = a !== 0 ? Math.min((y ? e : 0) / a, d < s - 1 ? 0.5 : 1) : 0, S = y ? { x: h.x + o * x, y: h.y + n * x } : h, P = l !== 0 ? Math.min((y ? e : 0) / l, d > 1 ? 0.5 : 1) : 0, N = y ? { x: h.x + c * P, y: h.y + g * P } : h;
|
|
1028
1042
|
d > 0 && t.push(`L ${N.x} ${N.y}`), y && t.push(
|
|
1029
1043
|
`C ${h.x} ${h.y} ${h.x} ${h.y} ${S.x} ${S.y}`
|
|
1030
1044
|
);
|
|
@@ -1171,7 +1185,7 @@ class it {
|
|
|
1171
1185
|
);
|
|
1172
1186
|
}
|
|
1173
1187
|
}
|
|
1174
|
-
class
|
|
1188
|
+
class Q {
|
|
1175
1189
|
constructor(e) {
|
|
1176
1190
|
i(this, "path");
|
|
1177
1191
|
i(this, "midpoint");
|
|
@@ -1353,7 +1367,7 @@ const f = Object.freeze({
|
|
|
1353
1367
|
interactiveWidth: 10,
|
|
1354
1368
|
preOffset: 0
|
|
1355
1369
|
}), ge = (r, e, t) => ({ x: e * Math.cos(r), y: t * Math.sin(r) });
|
|
1356
|
-
class
|
|
1370
|
+
class z {
|
|
1357
1371
|
constructor(e) {
|
|
1358
1372
|
i(this, "svg");
|
|
1359
1373
|
i(this, "group", De());
|
|
@@ -1399,15 +1413,15 @@ class k {
|
|
|
1399
1413
|
shift: p,
|
|
1400
1414
|
arrowLength: this.params.arrowLength
|
|
1401
1415
|
}), this.sourceArrow.setAttribute("d", y));
|
|
1402
|
-
let
|
|
1403
|
-
this.targetArrow && (
|
|
1416
|
+
let A = null;
|
|
1417
|
+
this.targetArrow && (A = this.arrowRenderer({
|
|
1404
1418
|
direction: l,
|
|
1405
1419
|
shift: g,
|
|
1406
1420
|
arrowLength: this.params.arrowLength
|
|
1407
|
-
}), this.targetArrow.setAttribute("d",
|
|
1421
|
+
}), this.targetArrow.setAttribute("d", A)), this.afterRenderEmitter.emit({
|
|
1408
1422
|
edgePath: w,
|
|
1409
1423
|
sourceArrowPath: y,
|
|
1410
|
-
targetArrowPath:
|
|
1424
|
+
targetArrowPath: A
|
|
1411
1425
|
});
|
|
1412
1426
|
}
|
|
1413
1427
|
}
|
|
@@ -1519,7 +1533,7 @@ class ut {
|
|
|
1519
1533
|
hasSourceArrow: this.hasSourceArrow,
|
|
1520
1534
|
hasTargetArrow: this.hasTargetArrow
|
|
1521
1535
|
}));
|
|
1522
|
-
this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? f.arrowLength, this.curvature = (e == null ? void 0 : e.curvature) ?? f.curvature, this.portCycleRadius = (e == null ? void 0 : e.cycleRadius) ?? f.cycleRadius, this.portCycleSmallRadius = (e == null ? void 0 : e.smallCycleRadius) ?? f.smallCycleRadius, this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? f.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? f.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? f.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? f.hasTargetArrow, this.pathShape = new
|
|
1536
|
+
this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? f.arrowLength, this.curvature = (e == null ? void 0 : e.curvature) ?? f.curvature, this.portCycleRadius = (e == null ? void 0 : e.cycleRadius) ?? f.cycleRadius, this.portCycleSmallRadius = (e == null ? void 0 : e.smallCycleRadius) ?? f.smallCycleRadius, this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? f.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? f.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? f.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? f.hasTargetArrow, this.pathShape = new z({
|
|
1523
1537
|
color: (e == null ? void 0 : e.color) ?? f.color,
|
|
1524
1538
|
width: (e == null ? void 0 : e.width) ?? f.width,
|
|
1525
1539
|
arrowRenderer: I((e == null ? void 0 : e.arrowRenderer) ?? {}),
|
|
@@ -1551,7 +1565,7 @@ class pt {
|
|
|
1551
1565
|
i(this, "hasSourceArrow");
|
|
1552
1566
|
i(this, "hasTargetArrow");
|
|
1553
1567
|
i(this, "pathShape");
|
|
1554
|
-
i(this, "createCyclePath", (e) => new
|
|
1568
|
+
i(this, "createCyclePath", (e) => new Q({
|
|
1555
1569
|
sourceDirection: e,
|
|
1556
1570
|
arrowLength: this.arrowLength,
|
|
1557
1571
|
side: this.cycleSquareSide,
|
|
@@ -1590,7 +1604,7 @@ class pt {
|
|
|
1590
1604
|
t,
|
|
1591
1605
|
this.arrowOffset,
|
|
1592
1606
|
this.cycleSquareSide / 2
|
|
1593
|
-
), this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? f.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? f.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? f.hasTargetArrow, this.pathShape = new
|
|
1607
|
+
), this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? f.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? f.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? f.hasTargetArrow, this.pathShape = new z({
|
|
1594
1608
|
color: (e == null ? void 0 : e.color) ?? f.color,
|
|
1595
1609
|
width: (e == null ? void 0 : e.width) ?? f.width,
|
|
1596
1610
|
arrowRenderer: I((e == null ? void 0 : e.arrowRenderer) ?? {}),
|
|
@@ -1623,7 +1637,7 @@ class wt {
|
|
|
1623
1637
|
i(this, "hasSourceArrow");
|
|
1624
1638
|
i(this, "hasTargetArrow");
|
|
1625
1639
|
i(this, "pathShape");
|
|
1626
|
-
i(this, "createCyclePath", (e) => new
|
|
1640
|
+
i(this, "createCyclePath", (e) => new Q({
|
|
1627
1641
|
sourceDirection: e,
|
|
1628
1642
|
arrowLength: this.arrowLength,
|
|
1629
1643
|
side: this.cycleSquareSide,
|
|
@@ -1662,7 +1676,7 @@ class wt {
|
|
|
1662
1676
|
t,
|
|
1663
1677
|
this.arrowOffset,
|
|
1664
1678
|
this.cycleSquareSide / 2
|
|
1665
|
-
), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? f.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? f.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? f.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? f.hasTargetArrow, this.pathShape = new
|
|
1679
|
+
), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? f.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? f.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? f.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? f.hasTargetArrow, this.pathShape = new z({
|
|
1666
1680
|
color: (e == null ? void 0 : e.color) ?? f.color,
|
|
1667
1681
|
width: (e == null ? void 0 : e.width) ?? f.width,
|
|
1668
1682
|
arrowRenderer: I((e == null ? void 0 : e.arrowRenderer) ?? {}),
|
|
@@ -1694,7 +1708,7 @@ class ft {
|
|
|
1694
1708
|
i(this, "hasSourceArrow");
|
|
1695
1709
|
i(this, "hasTargetArrow");
|
|
1696
1710
|
i(this, "pathShape");
|
|
1697
|
-
i(this, "createCyclePath", (e) => new
|
|
1711
|
+
i(this, "createCyclePath", (e) => new Q({
|
|
1698
1712
|
sourceDirection: e,
|
|
1699
1713
|
arrowLength: this.arrowLength,
|
|
1700
1714
|
side: this.cycleSquareSide,
|
|
@@ -1733,7 +1747,7 @@ class ft {
|
|
|
1733
1747
|
t,
|
|
1734
1748
|
this.arrowOffset,
|
|
1735
1749
|
this.cycleSquareSide / 2
|
|
1736
|
-
), this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? f.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? f.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? f.hasTargetArrow, this.pathShape = new
|
|
1750
|
+
), this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? f.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? f.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? f.hasTargetArrow, this.pathShape = new z({
|
|
1737
1751
|
color: (e == null ? void 0 : e.color) ?? f.color,
|
|
1738
1752
|
width: (e == null ? void 0 : e.width) ?? f.width,
|
|
1739
1753
|
arrowRenderer: I((e == null ? void 0 : e.arrowRenderer) ?? {}),
|
|
@@ -1976,8 +1990,10 @@ class Le {
|
|
|
1976
1990
|
}
|
|
1977
1991
|
class Re {
|
|
1978
1992
|
constructor(e) {
|
|
1993
|
+
i(this, "onBeforeUpdated");
|
|
1979
1994
|
i(this, "onAfterUpdated");
|
|
1980
|
-
this
|
|
1995
|
+
i(this, "onAfterResize");
|
|
1996
|
+
this.viewportStore = e, this.onBeforeUpdated = this.viewportStore.onBeforeUpdated, this.onAfterUpdated = this.viewportStore.onAfterUpdated, this.onAfterResize = this.viewportStore.onAfterResize;
|
|
1981
1997
|
}
|
|
1982
1998
|
getViewportMatrix() {
|
|
1983
1999
|
return { ...this.viewportStore.getViewportMatrix() };
|
|
@@ -1985,9 +2001,12 @@ class Re {
|
|
|
1985
2001
|
getContentMatrix() {
|
|
1986
2002
|
return { ...this.viewportStore.getContentMatrix() };
|
|
1987
2003
|
}
|
|
2004
|
+
getDimensions() {
|
|
2005
|
+
return this.viewportStore.getDimensions();
|
|
2006
|
+
}
|
|
1988
2007
|
}
|
|
1989
2008
|
const Ve = (r, e) => {
|
|
1990
|
-
const t = new
|
|
2009
|
+
const t = new Ae(), s = new Le(t), o = new Re(e), n = new me(t, e, r), a = {
|
|
1991
2010
|
nodes: {
|
|
1992
2011
|
centerFn: Se,
|
|
1993
2012
|
priorityFn: () => 0
|
|
@@ -2009,7 +2028,7 @@ const Ve = (r, e) => {
|
|
|
2009
2028
|
a
|
|
2010
2029
|
);
|
|
2011
2030
|
};
|
|
2012
|
-
class
|
|
2031
|
+
class k {
|
|
2013
2032
|
constructor(e, t, s, o) {
|
|
2014
2033
|
i(this, "onAfterPortMarked", (e) => {
|
|
2015
2034
|
const t = this.canvas.graph.getPort(e);
|
|
@@ -2091,7 +2110,7 @@ class z {
|
|
|
2091
2110
|
this.canvas = e, this.element = t, this.window = s, this.params = o, this.canvas.graph.onAfterPortMarked.subscribe(this.onAfterPortMarked), this.canvas.graph.onBeforePortUnmarked.subscribe(this.onBeforePortUnmarked), this.canvas.graph.onBeforeClear.subscribe(this.onBeforeClear), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
|
|
2092
2111
|
}
|
|
2093
2112
|
static configure(e, t, s, o) {
|
|
2094
|
-
new
|
|
2113
|
+
new k(e, t, s, o);
|
|
2095
2114
|
}
|
|
2096
2115
|
hookPortEvents(e) {
|
|
2097
2116
|
e.addEventListener("mousedown", this.onPortMouseDown, {
|
|
@@ -2116,7 +2135,7 @@ class z {
|
|
|
2116
2135
|
this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
|
|
2117
2136
|
}
|
|
2118
2137
|
}
|
|
2119
|
-
class
|
|
2138
|
+
class Z {
|
|
2120
2139
|
constructor(e, t, s, o) {
|
|
2121
2140
|
i(this, "grabbedNode", null);
|
|
2122
2141
|
i(this, "maxNodePriority", 0);
|
|
@@ -2237,7 +2256,7 @@ class q {
|
|
|
2237
2256
|
this.canvas = e, this.element = t, this.window = s, this.params = o, this.graph = e.graph, this.graph.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graph.onAfterNodeUpdated.subscribe(this.onAfterNodeUpdated), this.graph.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.graph.onBeforeClear.subscribe(this.onBeforeClear), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
|
|
2238
2257
|
}
|
|
2239
2258
|
static configure(e, t, s, o) {
|
|
2240
|
-
new
|
|
2259
|
+
new Z(e, t, s, o);
|
|
2241
2260
|
}
|
|
2242
2261
|
moveNode(e, t) {
|
|
2243
2262
|
if (this.graph.getNode(e.nodeId) === null)
|
|
@@ -2306,11 +2325,11 @@ class q {
|
|
|
2306
2325
|
return e;
|
|
2307
2326
|
}
|
|
2308
2327
|
}
|
|
2309
|
-
const
|
|
2328
|
+
const At = (r, e, t) => ({
|
|
2310
2329
|
scale: r.scale,
|
|
2311
2330
|
x: r.x + r.scale * e,
|
|
2312
2331
|
y: r.y + r.scale * t
|
|
2313
|
-
}),
|
|
2332
|
+
}), Et = (r, e, t, s) => ({
|
|
2314
2333
|
scale: r.scale * e,
|
|
2315
2334
|
x: r.scale * (1 - e) * t + r.x,
|
|
2316
2335
|
y: r.scale * (1 - e) * s + r.y
|
|
@@ -2364,7 +2383,7 @@ class H {
|
|
|
2364
2383
|
this.moveViewport(s, o);
|
|
2365
2384
|
});
|
|
2366
2385
|
i(this, "onWindowMouseUp", (e) => {
|
|
2367
|
-
this.
|
|
2386
|
+
this.params.mouseUpEventVerifier(e) && this.stopMouseDrag();
|
|
2368
2387
|
});
|
|
2369
2388
|
i(this, "onWheelScroll", (e) => {
|
|
2370
2389
|
if (!this.params.mouseWheelEventVerifier(e))
|
|
@@ -2407,21 +2426,14 @@ class H {
|
|
|
2407
2426
|
i(this, "onWindowTouchFinish", (e) => {
|
|
2408
2427
|
e.touches.length > 0 ? this.prevTouches = $(e) : this.stopTouchDrag();
|
|
2409
2428
|
});
|
|
2410
|
-
i(this, "observer", new ResizeObserver(() => {
|
|
2411
|
-
const e = this.viewport.getViewportMatrix(), { width: t, height: s } = this.element.getBoundingClientRect(), o = this.params.transformPreprocessor({
|
|
2412
|
-
prevTransform: e,
|
|
2413
|
-
nextTransform: e,
|
|
2414
|
-
canvasWidth: t,
|
|
2415
|
-
canvasHeight: s
|
|
2416
|
-
});
|
|
2417
|
-
this.params.onResizeTransformStarted(), this.canvas.patchViewportMatrix(o), this.params.onResizeTransformFinished();
|
|
2418
|
-
}));
|
|
2419
2429
|
i(this, "preventWheelScaleListener", (e) => {
|
|
2420
2430
|
e.preventDefault();
|
|
2421
2431
|
});
|
|
2422
2432
|
this.canvas = e, this.element = t, this.window = s, this.params = o, this.element.addEventListener("wheel", this.preventWheelScaleListener, {
|
|
2423
2433
|
passive: !1
|
|
2424
|
-
}), this.viewport = e.viewport, this.
|
|
2434
|
+
}), this.viewport = e.viewport, this.handleResize(), this.viewport.onAfterResize.subscribe(() => {
|
|
2435
|
+
this.handleResize();
|
|
2436
|
+
}), this.element.addEventListener("mousedown", this.onMouseDown, {
|
|
2425
2437
|
passive: !0
|
|
2426
2438
|
}), this.element.addEventListener("wheel", this.onWheelScroll, {
|
|
2427
2439
|
passive: !0
|
|
@@ -2433,7 +2445,7 @@ class H {
|
|
|
2433
2445
|
new H(e, t, s, o);
|
|
2434
2446
|
}
|
|
2435
2447
|
moveViewport(e, t) {
|
|
2436
|
-
const s = this.viewport.getViewportMatrix(), o =
|
|
2448
|
+
const s = this.viewport.getViewportMatrix(), o = At(s, e, t), { width: n, height: a } = this.viewport.getDimensions(), h = this.params.transformPreprocessor({
|
|
2437
2449
|
prevTransform: s,
|
|
2438
2450
|
nextTransform: o,
|
|
2439
2451
|
canvasWidth: n,
|
|
@@ -2442,7 +2454,7 @@ class H {
|
|
|
2442
2454
|
this.performTransform(h);
|
|
2443
2455
|
}
|
|
2444
2456
|
scaleViewport(e, t, s) {
|
|
2445
|
-
const o = this.canvas.viewport.getViewportMatrix(), n =
|
|
2457
|
+
const o = this.canvas.viewport.getViewportMatrix(), n = Et(o, e, t, s), { width: a, height: h } = this.viewport.getDimensions(), d = this.params.transformPreprocessor({
|
|
2446
2458
|
prevTransform: o,
|
|
2447
2459
|
nextTransform: n,
|
|
2448
2460
|
canvasWidth: a,
|
|
@@ -2471,16 +2483,22 @@ class H {
|
|
|
2471
2483
|
finishRegisteredTransform() {
|
|
2472
2484
|
this.transformInProgress = !1, this.params.onTransformFinished();
|
|
2473
2485
|
}
|
|
2486
|
+
handleResize() {
|
|
2487
|
+
const e = this.viewport.getViewportMatrix(), { width: t, height: s } = this.viewport.getDimensions(), o = this.params.transformPreprocessor({
|
|
2488
|
+
prevTransform: e,
|
|
2489
|
+
nextTransform: e,
|
|
2490
|
+
canvasWidth: t,
|
|
2491
|
+
canvasHeight: s
|
|
2492
|
+
});
|
|
2493
|
+
this.params.onResizeTransformStarted(), this.canvas.patchViewportMatrix(o), this.params.onResizeTransformFinished();
|
|
2494
|
+
}
|
|
2474
2495
|
}
|
|
2475
2496
|
class J {
|
|
2476
2497
|
constructor(e, t, s, o, n, a) {
|
|
2477
|
-
i(this, "canvasResizeObserver");
|
|
2478
2498
|
i(this, "nodeHorizontal");
|
|
2479
2499
|
i(this, "nodeVertical");
|
|
2480
2500
|
i(this, "viewport");
|
|
2481
|
-
i(this, "
|
|
2482
|
-
i(this, "viewportHeight", 0);
|
|
2483
|
-
i(this, "viewportMatrix");
|
|
2501
|
+
i(this, "currentScale");
|
|
2484
2502
|
i(this, "loadedArea", {
|
|
2485
2503
|
xFrom: 1 / 0,
|
|
2486
2504
|
xTo: 1 / 0,
|
|
@@ -2496,13 +2514,12 @@ class J {
|
|
|
2496
2514
|
};
|
|
2497
2515
|
});
|
|
2498
2516
|
i(this, "onAfterViewportUpdated", () => {
|
|
2499
|
-
this.userTransformInProgress ||
|
|
2517
|
+
this.userTransformInProgress || this.loadAreaAroundViewport();
|
|
2500
2518
|
});
|
|
2501
2519
|
i(this, "userTransformInProgress", !1);
|
|
2502
|
-
this.canvas = e, this.element = t, this.window = s, this.trigger = n, this.params = a, this.nodeHorizontal = this.params.nodeVerticalRadius, this.nodeVertical = this.params.nodeHorizontalRadius, this.
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
}), this.viewport = e.viewport;
|
|
2520
|
+
this.canvas = e, this.element = t, this.window = s, this.trigger = n, this.params = a, this.nodeHorizontal = this.params.nodeVerticalRadius, this.nodeVertical = this.params.nodeHorizontalRadius, this.viewport = e.viewport, this.currentScale = this.viewport.getViewportMatrix().scale, this.scheduleLoadAreaAroundViewport(), this.viewport.onAfterResize.subscribe(() => {
|
|
2521
|
+
this.scheduleLoadAreaAroundViewport();
|
|
2522
|
+
});
|
|
2506
2523
|
const h = {
|
|
2507
2524
|
...o,
|
|
2508
2525
|
onResizeTransformStarted: () => {
|
|
@@ -2516,8 +2533,8 @@ class J {
|
|
|
2516
2533
|
},
|
|
2517
2534
|
onTransformChange: () => {
|
|
2518
2535
|
this.userTransformInProgress = !1;
|
|
2519
|
-
const d = this.
|
|
2520
|
-
this.
|
|
2536
|
+
const d = this.currentScale;
|
|
2537
|
+
this.currentScale = this.viewport.getViewportMatrix().scale, d !== this.currentScale && this.scheduleEnsureViewportAreaLoaded(), o.onTransformChange();
|
|
2521
2538
|
},
|
|
2522
2539
|
onTransformFinished: () => {
|
|
2523
2540
|
this.scheduleLoadAreaAroundViewport(), o.onTransformFinished();
|
|
@@ -2528,7 +2545,7 @@ class J {
|
|
|
2528
2545
|
this.element,
|
|
2529
2546
|
this.window,
|
|
2530
2547
|
h
|
|
2531
|
-
), this.
|
|
2548
|
+
), this.trigger.subscribe(this.updateLoadedArea), this.canvas.viewport.onAfterUpdated.subscribe(this.onAfterViewportUpdated);
|
|
2532
2549
|
}
|
|
2533
2550
|
static configure(e, t, s, o, n, a) {
|
|
2534
2551
|
new J(
|
|
@@ -2546,15 +2563,22 @@ class J {
|
|
|
2546
2563
|
});
|
|
2547
2564
|
}
|
|
2548
2565
|
scheduleEnsureViewportAreaLoaded() {
|
|
2549
|
-
|
|
2550
|
-
|
|
2566
|
+
setTimeout(() => {
|
|
2567
|
+
const { width: e, height: t } = this.viewport.getDimensions(), { scale: s, x: o, y: n } = this.viewport.getViewportMatrix(), a = e * s, h = t * s, d = o - this.nodeHorizontal, c = n - this.nodeVertical, g = o + a + this.nodeHorizontal, l = n + h + this.nodeVertical;
|
|
2568
|
+
this.loadedArea.xFrom < d && this.loadedArea.xTo > g && this.loadedArea.yFrom < c && this.loadedArea.yTo > l || this.loadAreaAroundViewport();
|
|
2569
|
+
});
|
|
2551
2570
|
}
|
|
2552
2571
|
loadAreaAroundViewport() {
|
|
2553
|
-
const e = this.
|
|
2554
|
-
this.trigger.emit({
|
|
2572
|
+
const { width: e, height: t } = this.viewport.getDimensions(), { scale: s, x: o, y: n } = this.viewport.getViewportMatrix(), a = e * s, h = t * s, d = o - a - this.nodeHorizontal, c = n - h - this.nodeVertical, g = 3 * a + 2 * this.nodeHorizontal, l = 3 * h + 2 * this.nodeVertical;
|
|
2573
|
+
this.trigger.emit({
|
|
2574
|
+
x: d,
|
|
2575
|
+
y: c,
|
|
2576
|
+
width: g,
|
|
2577
|
+
height: l
|
|
2578
|
+
});
|
|
2555
2579
|
}
|
|
2556
2580
|
}
|
|
2557
|
-
const
|
|
2581
|
+
const xt = () => {
|
|
2558
2582
|
const r = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
2559
2583
|
return r.style.position = "absolute", r.style.inset = "0", r;
|
|
2560
2584
|
}, St = () => {
|
|
@@ -2569,7 +2593,7 @@ const Et = () => {
|
|
|
2569
2593
|
};
|
|
2570
2594
|
class _ {
|
|
2571
2595
|
constructor(e, t, s) {
|
|
2572
|
-
i(this, "svg",
|
|
2596
|
+
i(this, "svg", xt());
|
|
2573
2597
|
i(this, "patternRenderingRectangle", St());
|
|
2574
2598
|
i(this, "pattern", bt());
|
|
2575
2599
|
i(this, "patternContent");
|
|
@@ -2579,12 +2603,6 @@ class _ {
|
|
|
2579
2603
|
i(this, "halfTileHeight");
|
|
2580
2604
|
i(this, "maxViewportScale");
|
|
2581
2605
|
i(this, "visible", !1);
|
|
2582
|
-
i(this, "resizeObserver", new ResizeObserver((e) => {
|
|
2583
|
-
const t = e[0], { width: s, height: o } = t.contentRect;
|
|
2584
|
-
this.svg.setAttribute("width", `${s}`), this.svg.setAttribute("height", `${o}`), this.patternRenderingRectangle.setAttribute("width", `${s}`), this.patternRenderingRectangle.setAttribute("height", `${o}`);
|
|
2585
|
-
const n = this.tileWidth / s, a = this.tileHeight / o;
|
|
2586
|
-
this.pattern.setAttribute("width", `${n}`), this.pattern.setAttribute("height", `${a}`);
|
|
2587
|
-
}));
|
|
2588
2606
|
i(this, "onAfterTransformUpdated", () => {
|
|
2589
2607
|
const e = this.canvas.viewport.getContentMatrix(), t = e.x - this.halfTileWidth * e.scale, s = e.y - this.halfTileHeight * e.scale, o = `matrix(${e.scale}, 0, 0, ${e.scale}, ${t}, ${s})`;
|
|
2590
2608
|
this.pattern.setAttribute("patternTransform", o), this.updateVisibility();
|
|
@@ -2593,7 +2611,9 @@ class _ {
|
|
|
2593
2611
|
const o = `translate(${this.halfTileWidth}, ${this.halfTileHeight})`;
|
|
2594
2612
|
this.patternContent.setAttribute("transform", o), this.pattern.appendChild(this.patternContent);
|
|
2595
2613
|
const n = document.createElementNS("http://www.w3.org/2000/svg", "defs");
|
|
2596
|
-
n.appendChild(this.pattern), this.svg.appendChild(n), this.svg.appendChild(this.patternRenderingRectangle), this.
|
|
2614
|
+
n.appendChild(this.pattern), this.svg.appendChild(n), this.svg.appendChild(this.patternRenderingRectangle), this.updateDimensions(), this.canvas.viewport.onAfterResize.subscribe(() => {
|
|
2615
|
+
this.updateDimensions();
|
|
2616
|
+
}), this.canvas.viewport.onAfterUpdated.subscribe(this.onAfterTransformUpdated), this.onAfterTransformUpdated();
|
|
2597
2617
|
}
|
|
2598
2618
|
static configure(e, t, s) {
|
|
2599
2619
|
new _(e, t, s);
|
|
@@ -2602,6 +2622,12 @@ class _ {
|
|
|
2602
2622
|
const t = this.canvas.viewport.getViewportMatrix().scale > this.maxViewportScale;
|
|
2603
2623
|
t && this.visible ? (this.visible = !1, this.backgroundHost.removeChild(this.svg)) : !t && !this.visible && (this.visible = !0, this.backgroundHost.appendChild(this.svg));
|
|
2604
2624
|
}
|
|
2625
|
+
updateDimensions() {
|
|
2626
|
+
const { width: e, height: t } = this.canvas.viewport.getDimensions();
|
|
2627
|
+
this.svg.setAttribute("width", `${e}`), this.svg.setAttribute("height", `${t}`), this.patternRenderingRectangle.setAttribute("width", `${e}`), this.patternRenderingRectangle.setAttribute("height", `${t}`);
|
|
2628
|
+
const s = this.tileWidth / e, o = this.tileHeight / t;
|
|
2629
|
+
this.pattern.setAttribute("width", `${s}`), this.pattern.setAttribute("height", `${o}`);
|
|
2630
|
+
}
|
|
2605
2631
|
}
|
|
2606
2632
|
class ee {
|
|
2607
2633
|
constructor(e, t, s, o, n) {
|
|
@@ -2614,7 +2640,7 @@ class ee {
|
|
|
2614
2640
|
this.canvas = e, this.overlayLayer = t, this.viewportStore = s, this.window = o, this.params = n, this.overlayCanvas = Ve(
|
|
2615
2641
|
this.overlayLayer,
|
|
2616
2642
|
this.viewportStore
|
|
2617
|
-
),
|
|
2643
|
+
), k.configure(
|
|
2618
2644
|
this.canvas,
|
|
2619
2645
|
this.overlayLayer,
|
|
2620
2646
|
this.window,
|
|
@@ -2665,10 +2691,10 @@ class ee {
|
|
|
2665
2691
|
portDirection: this.params.dragPortDirection
|
|
2666
2692
|
};
|
|
2667
2693
|
this.isTargetDragging = s === "direct";
|
|
2668
|
-
const [y,
|
|
2669
|
-
this.overlayCanvas.addNode(B(y)), this.overlayCanvas.addNode(B(
|
|
2694
|
+
const [y, A] = this.isTargetDragging ? [u, w] : [w, u];
|
|
2695
|
+
this.overlayCanvas.addNode(B(y)), this.overlayCanvas.addNode(B(A)), this.overlayCanvas.addEdge({
|
|
2670
2696
|
from: y.overlayId,
|
|
2671
|
-
to:
|
|
2697
|
+
to: A.overlayId,
|
|
2672
2698
|
shape: this.params.edgeShapeFactory(T.Edge)
|
|
2673
2699
|
});
|
|
2674
2700
|
}
|
|
@@ -2676,7 +2702,7 @@ class ee {
|
|
|
2676
2702
|
this.staticPortId = null, this.isTargetDragging = !0, this.overlayCanvas.clear();
|
|
2677
2703
|
}
|
|
2678
2704
|
tryCreateConnection(e) {
|
|
2679
|
-
const t =
|
|
2705
|
+
const t = xe(this.canvas.graph, e), s = this.staticPortId;
|
|
2680
2706
|
if (t === null) {
|
|
2681
2707
|
this.params.onEdgeCreationInterrupted({
|
|
2682
2708
|
staticPortId: s,
|
|
@@ -2710,7 +2736,7 @@ class te {
|
|
|
2710
2736
|
this.canvas = e, this.overlayLayer = t, this.viewportStore = s, this.window = o, this.params = n, this.overlayCanvas = Ve(
|
|
2711
2737
|
this.overlayLayer,
|
|
2712
2738
|
this.viewportStore
|
|
2713
|
-
),
|
|
2739
|
+
), k.configure(
|
|
2714
2740
|
this.canvas,
|
|
2715
2741
|
this.overlayLayer,
|
|
2716
2742
|
this.window,
|
|
@@ -2754,7 +2780,7 @@ class te {
|
|
|
2754
2780
|
}, u = this.canvas.viewport.getViewportMatrix(), w = this.overlayLayer.getBoundingClientRect(), y = C(u, {
|
|
2755
2781
|
x: l.x - w.x,
|
|
2756
2782
|
y: l.y - w.y
|
|
2757
|
-
}),
|
|
2783
|
+
}), A = C(u, {
|
|
2758
2784
|
x: t.x - w.x,
|
|
2759
2785
|
y: t.y - w.y
|
|
2760
2786
|
});
|
|
@@ -2765,15 +2791,15 @@ class te {
|
|
|
2765
2791
|
shape: o.shape,
|
|
2766
2792
|
priority: o.priority
|
|
2767
2793
|
}, this.canvas.removeEdge(s);
|
|
2768
|
-
const
|
|
2794
|
+
const x = {
|
|
2769
2795
|
overlayId: T.Static,
|
|
2770
2796
|
portCoords: y,
|
|
2771
2797
|
portDirection: c.direction
|
|
2772
2798
|
}, S = {
|
|
2773
2799
|
overlayId: T.Dragging,
|
|
2774
|
-
portCoords:
|
|
2800
|
+
portCoords: A,
|
|
2775
2801
|
portDirection: d.direction
|
|
2776
|
-
}, [D, P] = this.isTargetDragging ? [
|
|
2802
|
+
}, [D, P] = this.isTargetDragging ? [x, S] : [S, x];
|
|
2777
2803
|
this.overlayCanvas.addNode(B(D)), this.overlayCanvas.addNode(B(P));
|
|
2778
2804
|
const N = this.params.draggingEdgeShapeFactory !== null ? this.params.draggingEdgeShapeFactory(T.Edge) : o.shape;
|
|
2779
2805
|
return this.overlayCanvas.addEdge({
|
|
@@ -2797,7 +2823,7 @@ class te {
|
|
|
2797
2823
|
});
|
|
2798
2824
|
}
|
|
2799
2825
|
tryCreateConnection(e) {
|
|
2800
|
-
const t =
|
|
2826
|
+
const t = xe(this.canvas.graph, e);
|
|
2801
2827
|
if (this.overlayCanvas.removeEdge(T.Edge), t === null) {
|
|
2802
2828
|
const d = this.draggingEdgePayload;
|
|
2803
2829
|
this.params.onEdgeReattachInterrupted({
|
|
@@ -3055,11 +3081,11 @@ const G = (r) => () => r, we = G(0), Nt = () => {
|
|
|
3055
3081
|
}
|
|
3056
3082
|
};
|
|
3057
3083
|
}, Rt = (r) => {
|
|
3058
|
-
var w, y,
|
|
3084
|
+
var w, y, A, x, S, D;
|
|
3059
3085
|
const e = ((w = r.events) == null ? void 0 : w.onNodeDragStarted) ?? (() => {
|
|
3060
3086
|
}), t = ((y = r.events) == null ? void 0 : y.onNodeDrag) ?? (() => {
|
|
3061
|
-
}), s = r.nodeDragVerifier ?? (() => !0), o = ((
|
|
3062
|
-
}), n = r.moveOnTop !== !1, a = r.moveEdgesOnTop !== !1 && n, h = (
|
|
3087
|
+
}), s = r.nodeDragVerifier ?? (() => !0), o = ((A = r.events) == null ? void 0 : A.onNodeDragFinished) ?? (() => {
|
|
3088
|
+
}), n = r.moveOnTop !== !1, a = r.moveEdgesOnTop !== !1 && n, h = (x = r.mouse) == null ? void 0 : x.dragCursor, d = h !== void 0 ? h : "grab", c = (S = r.mouse) == null ? void 0 : S.mouseDownEventVerifier, g = c !== void 0 ? c : (P) => P.button === 0, l = (D = r.mouse) == null ? void 0 : D.mouseUpEventVerifier, u = l !== void 0 ? l : (P) => P.button === 0;
|
|
3063
3089
|
return {
|
|
3064
3090
|
moveOnTop: n,
|
|
3065
3091
|
moveEdgesOnTop: a,
|
|
@@ -3129,7 +3155,7 @@ const G = (r) => () => r, we = G(0), Nt = () => {
|
|
|
3129
3155
|
});
|
|
3130
3156
|
}
|
|
3131
3157
|
}, ye = (r) => {
|
|
3132
|
-
var y,
|
|
3158
|
+
var y, A, x, S, D, P, N, F, ne, ae, he, de;
|
|
3133
3159
|
const e = (y = r == null ? void 0 : r.scale) == null ? void 0 : y.mouseWheelSensitivity, t = e !== void 0 ? e : 1.2, s = r == null ? void 0 : r.transformPreprocessor;
|
|
3134
3160
|
let o;
|
|
3135
3161
|
s !== void 0 ? Array.isArray(s) ? o = It(
|
|
@@ -3137,7 +3163,7 @@ const G = (r) => () => r, we = G(0), Nt = () => {
|
|
|
3137
3163
|
(M) => fe(M)
|
|
3138
3164
|
)
|
|
3139
3165
|
) : o = fe(s) : o = (M) => M.nextTransform;
|
|
3140
|
-
const n = ((
|
|
3166
|
+
const n = ((A = r == null ? void 0 : r.shift) == null ? void 0 : A.cursor) !== void 0 ? r.shift.cursor : "grab", a = ((x = r == null ? void 0 : r.events) == null ? void 0 : x.onBeforeTransformChange) ?? (() => {
|
|
3141
3167
|
}), h = ((S = r == null ? void 0 : r.events) == null ? void 0 : S.onTransformChange) ?? (() => {
|
|
3142
3168
|
}), d = (D = r == null ? void 0 : r.shift) == null ? void 0 : D.mouseDownEventVerifier, c = d !== void 0 ? d : (M) => M.button === 0, g = (P = r == null ? void 0 : r.shift) == null ? void 0 : P.mouseUpEventVerifier, l = g !== void 0 ? g : (M) => M.button === 0, u = (N = r == null ? void 0 : r.scale) == null ? void 0 : N.mouseWheelEventVerifier, w = u !== void 0 ? u : () => !0;
|
|
3143
3169
|
return {
|
|
@@ -3212,10 +3238,10 @@ const G = (r) => () => r, we = G(0), Nt = () => {
|
|
|
3212
3238
|
onEdgeReattachInterrupted: ((g = r.events) == null ? void 0 : g.onEdgeReattachInterrupted) ?? d,
|
|
3213
3239
|
onEdgeReattachPrevented: ((l = r.events) == null ? void 0 : l.onEdgeReattachPrevented) ?? h
|
|
3214
3240
|
};
|
|
3215
|
-
},
|
|
3241
|
+
}, zt = (r) => ({
|
|
3216
3242
|
nodeVerticalRadius: r.nodeContainingRadius.vertical,
|
|
3217
3243
|
nodeHorizontalRadius: r.nodeContainingRadius.horizontal
|
|
3218
|
-
}),
|
|
3244
|
+
}), kt = (r) => {
|
|
3219
3245
|
var e, t;
|
|
3220
3246
|
return {
|
|
3221
3247
|
onAfterNodeDetached: ((e = r == null ? void 0 : r.events) == null ? void 0 : e.onAfterNodeDetached) ?? (() => {
|
|
@@ -3268,17 +3294,7 @@ class Fe {
|
|
|
3268
3294
|
});
|
|
3269
3295
|
}
|
|
3270
3296
|
}
|
|
3271
|
-
|
|
3272
|
-
const s = /* @__PURE__ */ new Map(), o = r.getAllNodeIds(), n = Math.sqrt(o.length) * t;
|
|
3273
|
-
return o.forEach((a) => {
|
|
3274
|
-
const h = r.getNode(a);
|
|
3275
|
-
s.set(a, {
|
|
3276
|
-
x: h.x ?? n * e(),
|
|
3277
|
-
y: h.y ?? n * e()
|
|
3278
|
-
});
|
|
3279
|
-
}), s;
|
|
3280
|
-
};
|
|
3281
|
-
class $e {
|
|
3297
|
+
class Ie {
|
|
3282
3298
|
constructor(e) {
|
|
3283
3299
|
i(this, "PI2", 2 * Math.PI);
|
|
3284
3300
|
this.rand = e;
|
|
@@ -3297,7 +3313,7 @@ class $e {
|
|
|
3297
3313
|
return { ex: h, ey: d, d: a };
|
|
3298
3314
|
}
|
|
3299
3315
|
}
|
|
3300
|
-
const
|
|
3316
|
+
const $e = (r) => {
|
|
3301
3317
|
if (r.distance === 0)
|
|
3302
3318
|
return r.maxForce;
|
|
3303
3319
|
const e = r.coefficient * (r.sourceCharge * r.targetCharge / (r.distance * r.distance));
|
|
@@ -3322,14 +3338,14 @@ class Xt {
|
|
|
3322
3338
|
);
|
|
3323
3339
|
if (l.d > this.effectiveDistance)
|
|
3324
3340
|
continue;
|
|
3325
|
-
const u =
|
|
3341
|
+
const u = $e({
|
|
3326
3342
|
coefficient: 1,
|
|
3327
3343
|
sourceCharge: this.nodeCharge,
|
|
3328
3344
|
targetCharge: this.nodeCharge,
|
|
3329
3345
|
distance: l.d,
|
|
3330
3346
|
maxForce: this.maxForce
|
|
3331
|
-
}), w = u * l.ex, y = u * l.ey,
|
|
3332
|
-
|
|
3347
|
+
}), w = u * l.ex, y = u * l.ey, A = t.get(a), x = t.get(d);
|
|
3348
|
+
A.x -= w, A.y -= y, x.x += w, x.y += y;
|
|
3333
3349
|
}
|
|
3334
3350
|
}
|
|
3335
3351
|
}
|
|
@@ -3636,7 +3652,7 @@ class jt {
|
|
|
3636
3652
|
const t = this.distanceVectorGenerator.create(
|
|
3637
3653
|
e.sourceCoords,
|
|
3638
3654
|
e.targetCoords
|
|
3639
|
-
), s =
|
|
3655
|
+
), s = $e({
|
|
3640
3656
|
coefficient: this.nodeForceCoefficient,
|
|
3641
3657
|
sourceCharge: e.sourceCharge,
|
|
3642
3658
|
targetCharge: e.targetCharge,
|
|
@@ -3671,7 +3687,7 @@ class jt {
|
|
|
3671
3687
|
}
|
|
3672
3688
|
}
|
|
3673
3689
|
}
|
|
3674
|
-
const
|
|
3690
|
+
const Ue = (r) => r.theta !== 0 ? new jt({
|
|
3675
3691
|
nodeCharge: r.nodeCharge,
|
|
3676
3692
|
nodeForceCoefficient: r.nodeForceCoefficient,
|
|
3677
3693
|
distanceVectorGenerator: r.distanceVectorGenerator,
|
|
@@ -3686,49 +3702,71 @@ const Be = (r) => r.theta !== 0 ? new jt({
|
|
|
3686
3702
|
effectiveDistance: r.effectiveDistance,
|
|
3687
3703
|
maxForce: r.maxForce
|
|
3688
3704
|
});
|
|
3689
|
-
class
|
|
3705
|
+
class Be {
|
|
3706
|
+
constructor(e) {
|
|
3707
|
+
i(this, "rand");
|
|
3708
|
+
i(this, "sparsity");
|
|
3709
|
+
this.rand = e.rand, this.sparsity = e.sparsity;
|
|
3710
|
+
}
|
|
3711
|
+
calculateCoordinates(e) {
|
|
3712
|
+
const t = /* @__PURE__ */ new Map(), s = e.getAllNodeIds(), o = Math.sqrt(s.length) * this.sparsity;
|
|
3713
|
+
return s.forEach((n) => {
|
|
3714
|
+
const a = e.getNode(n);
|
|
3715
|
+
t.set(n, {
|
|
3716
|
+
x: a.x ?? o * this.rand(),
|
|
3717
|
+
y: a.y ?? o * this.rand()
|
|
3718
|
+
});
|
|
3719
|
+
}), t;
|
|
3720
|
+
}
|
|
3721
|
+
}
|
|
3722
|
+
class qt {
|
|
3690
3723
|
constructor(e) {
|
|
3691
3724
|
i(this, "distanceVectorGenerator");
|
|
3692
3725
|
i(this, "nodeForcesApplicationStrategy");
|
|
3693
|
-
this
|
|
3694
|
-
|
|
3695
|
-
|
|
3726
|
+
i(this, "fillerLayoutAlgorithm");
|
|
3727
|
+
i(this, "maxIterations");
|
|
3728
|
+
i(this, "dtSec");
|
|
3729
|
+
i(this, "nodeMass");
|
|
3730
|
+
i(this, "edgeEquilibriumLength");
|
|
3731
|
+
i(this, "edgeStiffness");
|
|
3732
|
+
i(this, "convergenceDelta");
|
|
3733
|
+
i(this, "convergenceVelocity");
|
|
3734
|
+
this.maxIterations = e.maxIterations, this.dtSec = e.dtSec, this.nodeMass = e.nodeMass, this.edgeEquilibriumLength = e.edgeEquilibriumLength, this.edgeStiffness = e.edgeStiffness, this.convergenceDelta = e.convergenceDelta, this.convergenceVelocity = e.convergenceVelocity, this.distanceVectorGenerator = new Ie(e.rand), this.nodeForcesApplicationStrategy = Ue({
|
|
3696
3735
|
distanceVectorGenerator: this.distanceVectorGenerator,
|
|
3697
|
-
nodeCharge:
|
|
3698
|
-
effectiveDistance:
|
|
3699
|
-
maxForce:
|
|
3700
|
-
nodeForceCoefficient:
|
|
3701
|
-
theta:
|
|
3702
|
-
areaRadiusThreshold:
|
|
3703
|
-
nodeMass:
|
|
3736
|
+
nodeCharge: e.nodeCharge,
|
|
3737
|
+
effectiveDistance: e.effectiveDistance,
|
|
3738
|
+
maxForce: e.maxForce,
|
|
3739
|
+
nodeForceCoefficient: e.nodeForceCoefficient,
|
|
3740
|
+
theta: e.barnesHutTheta,
|
|
3741
|
+
areaRadiusThreshold: e.barnesHutAreaRadiusThreshold,
|
|
3742
|
+
nodeMass: e.nodeMass
|
|
3743
|
+
}), this.fillerLayoutAlgorithm = new Be({
|
|
3744
|
+
rand: e.rand,
|
|
3745
|
+
sparsity: e.edgeEquilibriumLength
|
|
3704
3746
|
});
|
|
3705
3747
|
}
|
|
3706
3748
|
calculateCoordinates(e) {
|
|
3707
|
-
const t =
|
|
3708
|
-
|
|
3709
|
-
this.params.rand,
|
|
3710
|
-
this.params.edgeEquilibriumLength
|
|
3711
|
-
);
|
|
3712
|
-
for (let s = 0; s < this.params.maxIterations; s++) {
|
|
3749
|
+
const t = this.fillerLayoutAlgorithm.calculateCoordinates(e);
|
|
3750
|
+
for (let s = 0; s < this.maxIterations; s++) {
|
|
3713
3751
|
const o = new Fe(
|
|
3714
3752
|
e,
|
|
3715
3753
|
t,
|
|
3716
3754
|
{
|
|
3717
3755
|
distanceVectorGenerator: this.distanceVectorGenerator,
|
|
3718
3756
|
nodeForcesApplicationStrategy: this.nodeForcesApplicationStrategy,
|
|
3719
|
-
dtSec: this.
|
|
3720
|
-
nodeMass: this.
|
|
3721
|
-
edgeEquilibriumLength: this.
|
|
3722
|
-
edgeStiffness: this.
|
|
3757
|
+
dtSec: this.dtSec,
|
|
3758
|
+
nodeMass: this.nodeMass,
|
|
3759
|
+
edgeEquilibriumLength: this.edgeEquilibriumLength,
|
|
3760
|
+
edgeStiffness: this.edgeStiffness
|
|
3723
3761
|
}
|
|
3724
3762
|
), [n, a] = o.apply();
|
|
3725
|
-
if (n < this.
|
|
3763
|
+
if (n < this.convergenceDelta || a < this.convergenceVelocity)
|
|
3726
3764
|
break;
|
|
3727
3765
|
}
|
|
3728
3766
|
return t;
|
|
3729
3767
|
}
|
|
3730
3768
|
}
|
|
3731
|
-
class
|
|
3769
|
+
class Kt {
|
|
3732
3770
|
constructor(e) {
|
|
3733
3771
|
i(this, "distanceVectorGenerator");
|
|
3734
3772
|
i(this, "nodeForcesApplicationStrategy");
|
|
@@ -3738,8 +3776,8 @@ class Qt {
|
|
|
3738
3776
|
i(this, "nodeMass");
|
|
3739
3777
|
i(this, "edgeEquilibriumLength");
|
|
3740
3778
|
i(this, "edgeStiffness");
|
|
3741
|
-
i(this, "
|
|
3742
|
-
this.convergenceDelta = e.convergenceDelta, this.convergenceVelocity = e.convergenceVelocity, this.maxTimeDeltaSec = e.maxTimeDeltaSec, this.nodeMass = e.nodeMass, this.edgeEquilibriumLength = e.edgeEquilibriumLength, this.edgeStiffness = e.edgeStiffness, this.
|
|
3779
|
+
i(this, "fillerLayoutAlgorithm");
|
|
3780
|
+
this.convergenceDelta = e.convergenceDelta, this.convergenceVelocity = e.convergenceVelocity, this.maxTimeDeltaSec = e.maxTimeDeltaSec, this.nodeMass = e.nodeMass, this.edgeEquilibriumLength = e.edgeEquilibriumLength, this.edgeStiffness = e.edgeStiffness, this.distanceVectorGenerator = new Ie(e.rand), this.nodeForcesApplicationStrategy = Ue({
|
|
3743
3781
|
distanceVectorGenerator: this.distanceVectorGenerator,
|
|
3744
3782
|
nodeCharge: e.nodeCharge,
|
|
3745
3783
|
effectiveDistance: e.effectiveDistance,
|
|
@@ -3748,14 +3786,13 @@ class Qt {
|
|
|
3748
3786
|
theta: e.barnesHutTheta,
|
|
3749
3787
|
areaRadiusThreshold: e.barnesHutAreaRadiusThreshold,
|
|
3750
3788
|
nodeMass: e.nodeMass
|
|
3789
|
+
}), this.fillerLayoutAlgorithm = new Be({
|
|
3790
|
+
rand: e.rand,
|
|
3791
|
+
sparsity: e.edgeEquilibriumLength
|
|
3751
3792
|
});
|
|
3752
3793
|
}
|
|
3753
3794
|
calculateNextCoordinates(e, t) {
|
|
3754
|
-
const s =
|
|
3755
|
-
e,
|
|
3756
|
-
this.rand,
|
|
3757
|
-
this.edgeEquilibriumLength
|
|
3758
|
-
), o = new Fe(
|
|
3795
|
+
const s = this.fillerLayoutAlgorithm.calculateCoordinates(e), o = new Fe(
|
|
3759
3796
|
e,
|
|
3760
3797
|
s,
|
|
3761
3798
|
{
|
|
@@ -3798,14 +3835,14 @@ const Oe = (r) => {
|
|
|
3798
3835
|
nodeForceCoefficient: 1,
|
|
3799
3836
|
barnesHutAreaRadiusThreshold: 0.01,
|
|
3800
3837
|
barnesHutTheta: 1
|
|
3801
|
-
}),
|
|
3838
|
+
}), Qt = (r) => {
|
|
3802
3839
|
var e, t, s;
|
|
3803
3840
|
switch ((e = r == null ? void 0 : r.algorithm) == null ? void 0 : e.type) {
|
|
3804
3841
|
case "custom":
|
|
3805
3842
|
return r.algorithm.instance;
|
|
3806
3843
|
default: {
|
|
3807
3844
|
const o = r == null ? void 0 : r.algorithm, n = Oe((o == null ? void 0 : o.seed) ?? v.seed), a = We(n[0], n[1], n[2], n[3]);
|
|
3808
|
-
return new
|
|
3845
|
+
return new Kt({
|
|
3809
3846
|
rand: a,
|
|
3810
3847
|
maxTimeDeltaSec: (o == null ? void 0 : o.maxTimeDeltaSec) ?? v.maxTimeDeltaSec,
|
|
3811
3848
|
nodeCharge: (o == null ? void 0 : o.nodeCharge) ?? v.nodeCharge,
|
|
@@ -3822,7 +3859,7 @@ const Oe = (r) => {
|
|
|
3822
3859
|
});
|
|
3823
3860
|
}
|
|
3824
3861
|
}
|
|
3825
|
-
},
|
|
3862
|
+
}, Zt = (r) => r instanceof j ? {
|
|
3826
3863
|
type: "manual",
|
|
3827
3864
|
trigger: r
|
|
3828
3865
|
} : {
|
|
@@ -3834,7 +3871,7 @@ const Oe = (r) => {
|
|
|
3834
3871
|
return r.instance;
|
|
3835
3872
|
default: {
|
|
3836
3873
|
const s = Oe((r == null ? void 0 : r.seed) ?? v.seed), o = We(s[0], s[1], s[2], s[3]);
|
|
3837
|
-
return new
|
|
3874
|
+
return new qt({
|
|
3838
3875
|
dtSec: (r == null ? void 0 : r.dtSec) ?? v.dtSec,
|
|
3839
3876
|
maxIterations: (r == null ? void 0 : r.maxIterations) ?? v.maxIterations,
|
|
3840
3877
|
rand: o,
|
|
@@ -3854,7 +3891,7 @@ const Oe = (r) => {
|
|
|
3854
3891
|
}
|
|
3855
3892
|
}, _t = (r) => ({
|
|
3856
3893
|
algorithm: Jt(r == null ? void 0 : r.algorithm),
|
|
3857
|
-
applyOn:
|
|
3894
|
+
applyOn: Zt(r == null ? void 0 : r.applyOn)
|
|
3858
3895
|
}), er = (r, e) => ({
|
|
3859
3896
|
...r,
|
|
3860
3897
|
onNodeDragStarted: (t) => {
|
|
@@ -3891,13 +3928,13 @@ class or {
|
|
|
3891
3928
|
i(this, "hasAnimatedLayout", !1);
|
|
3892
3929
|
i(this, "hasLayout", !1);
|
|
3893
3930
|
i(this, "boxRenderingTrigger", new j());
|
|
3894
|
-
i(this, "graphStore"
|
|
3895
|
-
i(this, "viewportStore"
|
|
3896
|
-
i(this, "graph"
|
|
3897
|
-
i(this, "viewport"
|
|
3931
|
+
i(this, "graphStore");
|
|
3932
|
+
i(this, "viewportStore");
|
|
3933
|
+
i(this, "graph");
|
|
3934
|
+
i(this, "viewport");
|
|
3898
3935
|
i(this, "window", window);
|
|
3899
3936
|
i(this, "animationStaticNodes", /* @__PURE__ */ new Set());
|
|
3900
|
-
this.element = e;
|
|
3937
|
+
this.element = e, this.viewportStore = new Qe(this.element), this.viewport = new Re(this.viewportStore), this.graphStore = new Ae(), this.graph = new Le(this.graphStore);
|
|
3901
3938
|
}
|
|
3902
3939
|
/**
|
|
3903
3940
|
* specifies default values for graph entities
|
|
@@ -3967,19 +4004,7 @@ class or {
|
|
|
3967
4004
|
if (this.used)
|
|
3968
4005
|
throw new Ht("CanvasBuilder is a single use object");
|
|
3969
4006
|
this.used = !0;
|
|
3970
|
-
const e = new Ct(this.element)
|
|
3971
|
-
let t = new me(
|
|
3972
|
-
this.graphStore,
|
|
3973
|
-
this.viewportStore,
|
|
3974
|
-
e.main
|
|
3975
|
-
);
|
|
3976
|
-
this.virtualScrollConfig !== void 0 && (t = new je(
|
|
3977
|
-
t,
|
|
3978
|
-
this.graphStore,
|
|
3979
|
-
this.boxRenderingTrigger,
|
|
3980
|
-
zt(this.virtualScrollConfig)
|
|
3981
|
-
)), t = new Ke(t, this.graphStore);
|
|
3982
|
-
const s = Lt(this.canvasDefaults), o = new ve(
|
|
4007
|
+
const e = new Ct(this.element), t = this.createHtmlView(e.main), s = Lt(this.canvasDefaults), o = new ve(
|
|
3983
4008
|
this.graph,
|
|
3984
4009
|
this.viewport,
|
|
3985
4010
|
this.graphStore,
|
|
@@ -3991,12 +4016,12 @@ class or {
|
|
|
3991
4016
|
o,
|
|
3992
4017
|
Bt(this.backgroundConfig),
|
|
3993
4018
|
e.background
|
|
3994
|
-
), this.hasNodeResizeReactiveEdges &&
|
|
4019
|
+
), this.hasNodeResizeReactiveEdges && q.configure(o), this.hasDraggableNodes) {
|
|
3995
4020
|
let a = Rt(this.dragConfig);
|
|
3996
4021
|
this.hasAnimatedLayout && (a = er(
|
|
3997
4022
|
a,
|
|
3998
4023
|
this.animationStaticNodes
|
|
3999
|
-
)),
|
|
4024
|
+
)), Z.configure(
|
|
4000
4025
|
o,
|
|
4001
4026
|
e.main,
|
|
4002
4027
|
this.window,
|
|
@@ -4036,7 +4061,7 @@ class or {
|
|
|
4036
4061
|
this.window,
|
|
4037
4062
|
ye(this.transformConfig),
|
|
4038
4063
|
this.boxRenderingTrigger,
|
|
4039
|
-
|
|
4064
|
+
zt(this.virtualScrollConfig)
|
|
4040
4065
|
) : this.hasTransformableViewport && H.configure(
|
|
4041
4066
|
o,
|
|
4042
4067
|
e.main,
|
|
@@ -4050,7 +4075,7 @@ class or {
|
|
|
4050
4075
|
this.animationStaticNodes
|
|
4051
4076
|
), oe.configure(
|
|
4052
4077
|
o,
|
|
4053
|
-
|
|
4078
|
+
Qt(this.animatedLayoutConfig),
|
|
4054
4079
|
this.animationStaticNodes,
|
|
4055
4080
|
this.window
|
|
4056
4081
|
));
|
|
@@ -4059,6 +4084,19 @@ class or {
|
|
|
4059
4084
|
};
|
|
4060
4085
|
return o.onBeforeDestroy.subscribe(n), o;
|
|
4061
4086
|
}
|
|
4087
|
+
createHtmlView(e) {
|
|
4088
|
+
let t = new me(
|
|
4089
|
+
this.graphStore,
|
|
4090
|
+
this.viewportStore,
|
|
4091
|
+
e
|
|
4092
|
+
);
|
|
4093
|
+
return this.virtualScrollConfig !== void 0 && (t = new je(
|
|
4094
|
+
t,
|
|
4095
|
+
this.graphStore,
|
|
4096
|
+
this.boxRenderingTrigger,
|
|
4097
|
+
kt(this.virtualScrollConfig)
|
|
4098
|
+
)), new qe(t, this.graphStore);
|
|
4099
|
+
}
|
|
4062
4100
|
}
|
|
4063
4101
|
export {
|
|
4064
4102
|
ut as BezierEdgeShape,
|