@reddb-io/ui 0.1.1
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/LICENSE +17 -0
- package/bin/red-ui.js +259 -0
- package/build/CNAME +1 -0
- package/build/_app/env.js +1 -0
- package/build/_app/immutable/assets/0.C63jY5jX.css +1 -0
- package/build/_app/immutable/assets/10.Dblyk0Kr.css +1 -0
- package/build/_app/immutable/assets/EmptyState.RXcH7ryE.css +1 -0
- package/build/_app/immutable/assets/Workspace.BCzG1DsH.css +1 -0
- package/build/_app/immutable/assets/inter-cyrillic-ext-wght-normal.BOeWTOD4.woff2 +0 -0
- package/build/_app/immutable/assets/inter-cyrillic-wght-normal.DqGufNeO.woff2 +0 -0
- package/build/_app/immutable/assets/inter-greek-ext-wght-normal.DlzME5K_.woff2 +0 -0
- package/build/_app/immutable/assets/inter-greek-wght-normal.CkhJZR-_.woff2 +0 -0
- package/build/_app/immutable/assets/inter-latin-ext-wght-normal.DO1Apj_S.woff2 +0 -0
- package/build/_app/immutable/assets/inter-latin-wght-normal.Dx4kXJAl.woff2 +0 -0
- package/build/_app/immutable/assets/inter-vietnamese-wght-normal.CBcvBZtf.woff2 +0 -0
- package/build/_app/immutable/assets/jetbrains-mono-cyrillic-wght-normal.D73BlboJ.woff2 +0 -0
- package/build/_app/immutable/assets/jetbrains-mono-greek-wght-normal.Bw9x6K1M.woff2 +0 -0
- package/build/_app/immutable/assets/jetbrains-mono-latin-ext-wght-normal.DBQx-q_a.woff2 +0 -0
- package/build/_app/immutable/assets/jetbrains-mono-latin-wght-normal.B9CIFXIH.woff2 +0 -0
- package/build/_app/immutable/assets/jetbrains-mono-vietnamese-wght-normal.Bt-aOZkq.woff2 +0 -0
- package/build/_app/immutable/chunks/3j4cZ58b.js +1 -0
- package/build/_app/immutable/chunks/69_IOA4Y.js +1 -0
- package/build/_app/immutable/chunks/ALqaDrNQ.js +2 -0
- package/build/_app/immutable/chunks/BGcIe2ep.js +2 -0
- package/build/_app/immutable/chunks/BMHKbvs8.js +1 -0
- package/build/_app/immutable/chunks/BQHbwf54.js +916 -0
- package/build/_app/immutable/chunks/Bgso8cDH.js +311 -0
- package/build/_app/immutable/chunks/Bmgx1mfv.js +310 -0
- package/build/_app/immutable/chunks/BrvvOVaJ.js +1 -0
- package/build/_app/immutable/chunks/Bzak7iHL.js +1 -0
- package/build/_app/immutable/chunks/D9CTkMjK.js +1 -0
- package/build/_app/immutable/chunks/DIeogL5L.js +1 -0
- package/build/_app/immutable/chunks/DXY_Rxa7.js +113 -0
- package/build/_app/immutable/chunks/DhEqZVGG.js +1 -0
- package/build/_app/immutable/chunks/Ov8N-vxt.js +1 -0
- package/build/_app/immutable/chunks/oiO4RLqp.js +1 -0
- package/build/_app/immutable/entry/app.D_IVtpdv.js +2 -0
- package/build/_app/immutable/entry/start.3oC0UQ_Q.js +1 -0
- package/build/_app/immutable/nodes/0.CHPiFxDo.js +1 -0
- package/build/_app/immutable/nodes/1.BC_4YZ0h.js +1 -0
- package/build/_app/immutable/nodes/10.B7DMKSNc.js +60 -0
- package/build/_app/immutable/nodes/2.CAG5_cGP.js +1 -0
- package/build/_app/immutable/nodes/3.CAG5_cGP.js +1 -0
- package/build/_app/immutable/nodes/4.CAG5_cGP.js +1 -0
- package/build/_app/immutable/nodes/5.CAG5_cGP.js +1 -0
- package/build/_app/immutable/nodes/6.CAG5_cGP.js +1 -0
- package/build/_app/immutable/nodes/7.BZX9Iird.js +134 -0
- package/build/_app/immutable/nodes/8.CAG5_cGP.js +1 -0
- package/build/_app/immutable/nodes/9.CAG5_cGP.js +1 -0
- package/build/_app/version.json +1 -0
- package/build/favicon.png +0 -0
- package/build/index.html +59 -0
- package/dist/embed/RedUiEmbedRoot-BGoLxJf1.js +26562 -0
- package/dist/embed/RedUiEmbedRoot-BGoLxJf1.js.map +1 -0
- package/dist/embed/bundle-mjs-UuVRz3O4.js +3047 -0
- package/dist/embed/bundle-mjs-UuVRz3O4.js.map +1 -0
- package/dist/embed/core-QuRYvMt8.js +118 -0
- package/dist/embed/core-QuRYvMt8.js.map +1 -0
- package/dist/embed/index-B6ZQhCsu.js +577 -0
- package/dist/embed/index-B6ZQhCsu.js.map +1 -0
- package/dist/embed/index-client-ItCEU64C.js +3087 -0
- package/dist/embed/index-client-ItCEU64C.js.map +1 -0
- package/dist/embed/index-fad77a13.esm-BqPj0saH.js +1318 -0
- package/dist/embed/index-fad77a13.esm-BqPj0saH.js.map +1 -0
- package/dist/embed/index.js +11 -0
- package/dist/embed/index.js.map +1 -0
- package/dist/embed/sigma-node-border.esm-CGtlgqmo.js +432 -0
- package/dist/embed/sigma-node-border.esm-CGtlgqmo.js.map +1 -0
- package/dist/embed/sigma.esm-y0qgY-OC.js +2355 -0
- package/dist/embed/sigma.esm-y0qgY-OC.js.map +1 -0
- package/dist/embed/ui.css +1 -0
- package/package.json +101 -0
- package/src/app.css +238 -0
- package/src/lib/ActivityIndicator.svelte +100 -0
- package/src/lib/ClusterNode.svelte +119 -0
- package/src/lib/ClusterView.svelte +541 -0
- package/src/lib/CollectionHistory.svelte +266 -0
- package/src/lib/CollectionsView.svelte +14 -0
- package/src/lib/CommandPalette.svelte +237 -0
- package/src/lib/ConnectDropdown.svelte +222 -0
- package/src/lib/EmptyState.svelte +27 -0
- package/src/lib/LiveChanges.svelte +195 -0
- package/src/lib/MasterPasswordDialog.svelte +168 -0
- package/src/lib/PageHeader.svelte +32 -0
- package/src/lib/PendingChangesPanel.svelte +153 -0
- package/src/lib/QueryEditor.svelte +122 -0
- package/src/lib/ResultsPane.svelte +747 -0
- package/src/lib/SchemaTree.svelte +193 -0
- package/src/lib/SecurityView.svelte +255 -0
- package/src/lib/ShortcutOverlay.svelte +104 -0
- package/src/lib/Splash.svelte +46 -0
- package/src/lib/StatusBar.svelte +163 -0
- package/src/lib/SubNav.svelte +62 -0
- package/src/lib/Topbar.svelte +119 -0
- package/src/lib/Workspace.svelte +247 -0
- package/src/lib/activity.svelte.ts +91 -0
- package/src/lib/build-info.ts +41 -0
- package/src/lib/capability.ts +221 -0
- package/src/lib/cn.ts +6 -0
- package/src/lib/collection-catalog.ts +116 -0
- package/src/lib/collection-pages.ts +33 -0
- package/src/lib/connection-history.ts +301 -0
- package/src/lib/connections.svelte.ts +493 -0
- package/src/lib/embed/RedUiEmbedRoot.svelte +31 -0
- package/src/lib/embed/index.ts +234 -0
- package/src/lib/graph-loader/contract.ts +336 -0
- package/src/lib/graph-loader/drilldown.ts +334 -0
- package/src/lib/graph-loader/index.ts +13 -0
- package/src/lib/index.ts +114 -0
- package/src/lib/pending-changes.svelte.ts +149 -0
- package/src/lib/query-tabs.svelte.ts +130 -0
- package/src/lib/reddb/boot-params.ts +254 -0
- package/src/lib/reddb/cdc-stream-client.ts +234 -0
- package/src/lib/reddb/client.ts +698 -0
- package/src/lib/reddb/connection-bootstrap.ts +260 -0
- package/src/lib/reddb/connection-provider.contract.ts +72 -0
- package/src/lib/reddb/connection-provider.ts +72 -0
- package/src/lib/reddb/index.ts +14 -0
- package/src/lib/reddb/injected-client-provider.ts +76 -0
- package/src/lib/reddb/local-url-provider.ts +245 -0
- package/src/lib/reddb/secure-store.ts +41 -0
- package/src/lib/reddb/server-capabilities.ts +71 -0
- package/src/lib/reddb/tauri-encrypted-store.ts +64 -0
- package/src/lib/reddb/transports.ts +89 -0
- package/src/lib/reddb/types.ts +32 -0
- package/src/lib/reddb/uri.ts +54 -0
- package/src/lib/reddb/web-encrypted-store.ts +201 -0
- package/src/lib/renderers/DiffRenderer.svelte +184 -0
- package/src/lib/renderers/DocumentRenderer.svelte +134 -0
- package/src/lib/renderers/GraphRenderer.svelte +1328 -0
- package/src/lib/renderers/HypertableRenderer.svelte +253 -0
- package/src/lib/renderers/JsonRenderer.svelte +30 -0
- package/src/lib/renderers/KvRenderer.svelte +150 -0
- package/src/lib/renderers/QueueRenderer.svelte +286 -0
- package/src/lib/renderers/StatsRenderer.svelte +123 -0
- package/src/lib/renderers/TableRenderer.svelte +440 -0
- package/src/lib/renderers/VectorRenderer.svelte +388 -0
- package/src/lib/renderers/diff-render.ts +122 -0
- package/src/lib/renderers/diff.ts +9 -0
- package/src/lib/renderers/document-render.ts +64 -0
- package/src/lib/renderers/document.ts +9 -0
- package/src/lib/renderers/graph-render.ts +631 -0
- package/src/lib/renderers/graph-sigma.ts +395 -0
- package/src/lib/renderers/graph.ts +9 -0
- package/src/lib/renderers/hypertable-render.ts +320 -0
- package/src/lib/renderers/hypertable.ts +9 -0
- package/src/lib/renderers/index.ts +42 -0
- package/src/lib/renderers/json-render.ts +89 -0
- package/src/lib/renderers/json.ts +10 -0
- package/src/lib/renderers/kv-render.ts +193 -0
- package/src/lib/renderers/kv.ts +9 -0
- package/src/lib/renderers/queue-render.ts +197 -0
- package/src/lib/renderers/queue.ts +9 -0
- package/src/lib/renderers/registry.ts +68 -0
- package/src/lib/renderers/stats-render.ts +73 -0
- package/src/lib/renderers/stats.ts +9 -0
- package/src/lib/renderers/table-render.ts +156 -0
- package/src/lib/renderers/table.ts +11 -0
- package/src/lib/renderers/types.ts +33 -0
- package/src/lib/renderers/vector-render.ts +154 -0
- package/src/lib/renderers/vector.ts +9 -0
- package/src/lib/router.svelte.ts +163 -0
- package/src/lib/secureStore.svelte.ts +148 -0
- package/src/lib/shadow-dom-spike/ShadowDomSpikeCore.svelte +198 -0
- package/src/lib/shadow-dom-spike/mount-shadow-dom-spike.ts +94 -0
- package/src/lib/shortcuts.ts +22 -0
- package/src/lib/surface.ts +80 -0
- package/src/lib/tabs.svelte.ts +115 -0
- package/src/lib/theme.svelte.ts +63 -0
|
@@ -0,0 +1,2355 @@
|
|
|
1
|
+
import { g as Y, e as O, d as Z, c as j, i as Q, n as Re, o as Ne, p as Me, N as Ge, a as Ie, E as Fe, h as v, f as c, j as ne, r as ge, m as ve, k as ze, _ as Ae } from "./index-fad77a13.esm-BqPj0saH.js";
|
|
2
|
+
import { e as Ue, r as He, g as Be } from "./RedUiEmbedRoot-BGoLxJf1.js";
|
|
3
|
+
var ue = /* @__PURE__ */ (function(s) {
|
|
4
|
+
function n() {
|
|
5
|
+
var i;
|
|
6
|
+
return Z(this, n), i = j(this, n), i.rawEmitter = i, i;
|
|
7
|
+
}
|
|
8
|
+
return Y(n, s), O(n);
|
|
9
|
+
})(Ue.EventEmitter), We = He();
|
|
10
|
+
const Oe = /* @__PURE__ */ Be(We);
|
|
11
|
+
var Ze = function(n) {
|
|
12
|
+
return n;
|
|
13
|
+
}, _e = function(n) {
|
|
14
|
+
return n * n;
|
|
15
|
+
}, Ve = function(n) {
|
|
16
|
+
return n * (2 - n);
|
|
17
|
+
}, qe = function(n) {
|
|
18
|
+
return (n *= 2) < 1 ? 0.5 * n * n : -0.5 * (--n * (n - 2) - 1);
|
|
19
|
+
}, Ye = function(n) {
|
|
20
|
+
return n * n * n;
|
|
21
|
+
}, je = function(n) {
|
|
22
|
+
return --n * n * n + 1;
|
|
23
|
+
}, Xe = function(n) {
|
|
24
|
+
return (n *= 2) < 1 ? 0.5 * n * n * n : 0.5 * ((n -= 2) * n * n + 2);
|
|
25
|
+
}, Ke = {
|
|
26
|
+
linear: Ze,
|
|
27
|
+
quadraticIn: _e,
|
|
28
|
+
quadraticOut: Ve,
|
|
29
|
+
quadraticInOut: qe,
|
|
30
|
+
cubicIn: Ye,
|
|
31
|
+
cubicOut: je,
|
|
32
|
+
cubicInOut: Xe
|
|
33
|
+
}, Je = {
|
|
34
|
+
easing: "quadraticInOut",
|
|
35
|
+
duration: 150
|
|
36
|
+
};
|
|
37
|
+
function N() {
|
|
38
|
+
return Float32Array.of(1, 0, 0, 0, 1, 0, 0, 0, 1);
|
|
39
|
+
}
|
|
40
|
+
function ee(s, n, i) {
|
|
41
|
+
return s[0] = n, s[4] = typeof i == "number" ? i : n, s;
|
|
42
|
+
}
|
|
43
|
+
function fe(s, n) {
|
|
44
|
+
var i = Math.sin(n), e = Math.cos(n);
|
|
45
|
+
return s[0] = e, s[1] = i, s[3] = -i, s[4] = e, s;
|
|
46
|
+
}
|
|
47
|
+
function me(s, n, i) {
|
|
48
|
+
return s[6] = n, s[7] = i, s;
|
|
49
|
+
}
|
|
50
|
+
function W(s, n) {
|
|
51
|
+
var i = s[0], e = s[1], t = s[2], a = s[3], r = s[4], o = s[5], h = s[6], d = s[7], l = s[8], u = n[0], g = n[1], f = n[2], m = n[3], p = n[4], y = n[5], E = n[6], b = n[7], x = n[8];
|
|
52
|
+
return s[0] = u * i + g * a + f * h, s[1] = u * e + g * r + f * d, s[2] = u * t + g * o + f * l, s[3] = m * i + p * a + y * h, s[4] = m * e + p * r + y * d, s[5] = m * t + p * o + y * l, s[6] = E * i + b * a + x * h, s[7] = E * e + b * r + x * d, s[8] = E * t + b * o + x * l, s;
|
|
53
|
+
}
|
|
54
|
+
function de(s, n) {
|
|
55
|
+
var i = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 1, e = s[0], t = s[1], a = s[3], r = s[4], o = s[6], h = s[7], d = n.x, l = n.y;
|
|
56
|
+
return {
|
|
57
|
+
x: d * e + l * a + o * i,
|
|
58
|
+
y: d * t + l * r + h * i
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function Qe(s, n) {
|
|
62
|
+
var i = s.height / s.width, e = n.height / n.width;
|
|
63
|
+
return i < 1 && e > 1 || i > 1 && e < 1 ? 1 : Math.min(Math.max(e, 1 / e), Math.max(1 / i, i));
|
|
64
|
+
}
|
|
65
|
+
function X(s, n, i, e, t) {
|
|
66
|
+
var a = s.angle, r = s.ratio, o = s.x, h = s.y, d = n.width, l = n.height, u = N(), g = Math.min(d, l) - 2 * e, f = Qe(n, i);
|
|
67
|
+
return t ? (W(u, me(N(), o, h)), W(u, ee(N(), r)), W(u, fe(N(), a)), W(u, ee(N(), d / g / 2 / f, l / g / 2 / f))) : (W(u, ee(N(), 2 * (g / d) * f, 2 * (g / l) * f)), W(u, fe(N(), -a)), W(u, ee(N(), 1 / r)), W(u, me(N(), -o, -h))), u;
|
|
68
|
+
}
|
|
69
|
+
function $e(s, n, i) {
|
|
70
|
+
var e = de(s, {
|
|
71
|
+
x: Math.cos(n.angle),
|
|
72
|
+
y: Math.sin(n.angle)
|
|
73
|
+
}, 0), t = e.x, a = e.y;
|
|
74
|
+
return 1 / Math.sqrt(Math.pow(t, 2) + Math.pow(a, 2)) / i.width;
|
|
75
|
+
}
|
|
76
|
+
function et(s) {
|
|
77
|
+
if (!s.order) return {
|
|
78
|
+
x: [0, 1],
|
|
79
|
+
y: [0, 1]
|
|
80
|
+
};
|
|
81
|
+
var n = 1 / 0, i = -1 / 0, e = 1 / 0, t = -1 / 0;
|
|
82
|
+
return s.forEachNode(function(a, r) {
|
|
83
|
+
var o = r.x, h = r.y;
|
|
84
|
+
o < n && (n = o), o > i && (i = o), h < e && (e = h), h > t && (t = h);
|
|
85
|
+
}), {
|
|
86
|
+
x: [n, i],
|
|
87
|
+
y: [e, t]
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function tt(s) {
|
|
91
|
+
if (!Oe(s)) throw new Error("Sigma: invalid graph instance.");
|
|
92
|
+
s.forEachNode(function(n, i) {
|
|
93
|
+
if (!Number.isFinite(i.x) || !Number.isFinite(i.y))
|
|
94
|
+
throw new Error("Sigma: Coordinates of node ".concat(n, " are invalid. A node must have a numeric 'x' and 'y' attribute."));
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
function it(s, n, i) {
|
|
98
|
+
var e = document.createElement(s);
|
|
99
|
+
if (n)
|
|
100
|
+
for (var t in n)
|
|
101
|
+
e.style[t] = n[t];
|
|
102
|
+
if (i)
|
|
103
|
+
for (var a in i)
|
|
104
|
+
e.setAttribute(a, i[a]);
|
|
105
|
+
return e;
|
|
106
|
+
}
|
|
107
|
+
function pe() {
|
|
108
|
+
return typeof window.devicePixelRatio < "u" ? window.devicePixelRatio : 1;
|
|
109
|
+
}
|
|
110
|
+
function ye(s, n, i) {
|
|
111
|
+
return i.sort(function(e, t) {
|
|
112
|
+
var a = n(e) || 0, r = n(t) || 0;
|
|
113
|
+
return a < r ? -1 : a > r ? 1 : 0;
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
function be(s) {
|
|
117
|
+
var n = Q(s.x, 2), i = n[0], e = n[1], t = Q(s.y, 2), a = t[0], r = t[1], o = Math.max(e - i, r - a), h = (e + i) / 2, d = (r + a) / 2;
|
|
118
|
+
(o === 0 || Math.abs(o) === 1 / 0 || isNaN(o)) && (o = 1), isNaN(h) && (h = 0), isNaN(d) && (d = 0);
|
|
119
|
+
var l = function(g) {
|
|
120
|
+
return {
|
|
121
|
+
x: 0.5 + (g.x - h) / o,
|
|
122
|
+
y: 0.5 + (g.y - d) / o
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
return l.applyTo = function(u) {
|
|
126
|
+
u.x = 0.5 + (u.x - h) / o, u.y = 0.5 + (u.y - d) / o;
|
|
127
|
+
}, l.inverse = function(u) {
|
|
128
|
+
return {
|
|
129
|
+
x: h + o * (u.x - 0.5),
|
|
130
|
+
y: d + o * (u.y - 0.5)
|
|
131
|
+
};
|
|
132
|
+
}, l.ratio = o, l;
|
|
133
|
+
}
|
|
134
|
+
function le(s) {
|
|
135
|
+
"@babel/helpers - typeof";
|
|
136
|
+
return le = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(n) {
|
|
137
|
+
return typeof n;
|
|
138
|
+
} : function(n) {
|
|
139
|
+
return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n;
|
|
140
|
+
}, le(s);
|
|
141
|
+
}
|
|
142
|
+
function xe(s, n) {
|
|
143
|
+
var i = n.size;
|
|
144
|
+
if (i !== 0) {
|
|
145
|
+
var e = s.length;
|
|
146
|
+
s.length += i;
|
|
147
|
+
var t = 0;
|
|
148
|
+
n.forEach(function(a) {
|
|
149
|
+
s[e + t] = a, t++;
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
function se(s) {
|
|
154
|
+
s = s || {};
|
|
155
|
+
for (var n = 0, i = arguments.length <= 1 ? 0 : arguments.length - 1; n < i; n++) {
|
|
156
|
+
var e = n + 1 < 1 || arguments.length <= n + 1 ? void 0 : arguments[n + 1];
|
|
157
|
+
e && Object.assign(s, e);
|
|
158
|
+
}
|
|
159
|
+
return s;
|
|
160
|
+
}
|
|
161
|
+
var ce = {
|
|
162
|
+
// Performance
|
|
163
|
+
hideEdgesOnMove: !1,
|
|
164
|
+
hideLabelsOnMove: !1,
|
|
165
|
+
renderLabels: !0,
|
|
166
|
+
renderEdgeLabels: !1,
|
|
167
|
+
enableEdgeEvents: !1,
|
|
168
|
+
// Component rendering
|
|
169
|
+
defaultNodeColor: "#999",
|
|
170
|
+
defaultNodeType: "circle",
|
|
171
|
+
defaultEdgeColor: "#ccc",
|
|
172
|
+
defaultEdgeType: "line",
|
|
173
|
+
labelFont: "Arial",
|
|
174
|
+
labelSize: 14,
|
|
175
|
+
labelWeight: "normal",
|
|
176
|
+
labelColor: {
|
|
177
|
+
color: "#000"
|
|
178
|
+
},
|
|
179
|
+
edgeLabelFont: "Arial",
|
|
180
|
+
edgeLabelSize: 14,
|
|
181
|
+
edgeLabelWeight: "normal",
|
|
182
|
+
edgeLabelColor: {
|
|
183
|
+
attribute: "color"
|
|
184
|
+
},
|
|
185
|
+
stagePadding: 30,
|
|
186
|
+
defaultDrawEdgeLabel: Me,
|
|
187
|
+
defaultDrawNodeLabel: Ne,
|
|
188
|
+
defaultDrawNodeHover: Re,
|
|
189
|
+
minEdgeThickness: 1.7,
|
|
190
|
+
antiAliasingFeather: 1,
|
|
191
|
+
// Mouse and touch settings
|
|
192
|
+
dragTimeout: 100,
|
|
193
|
+
draggedEventsTolerance: 3,
|
|
194
|
+
inertiaDuration: 200,
|
|
195
|
+
inertiaRatio: 3,
|
|
196
|
+
zoomDuration: 250,
|
|
197
|
+
zoomingRatio: 1.7,
|
|
198
|
+
doubleClickTimeout: 300,
|
|
199
|
+
doubleClickZoomingRatio: 2.2,
|
|
200
|
+
doubleClickZoomingDuration: 200,
|
|
201
|
+
tapMoveTolerance: 10,
|
|
202
|
+
// Size and scaling
|
|
203
|
+
zoomToSizeRatioFunction: Math.sqrt,
|
|
204
|
+
itemSizesReference: "screen",
|
|
205
|
+
autoRescale: !0,
|
|
206
|
+
autoCenter: !0,
|
|
207
|
+
// Labels
|
|
208
|
+
labelDensity: 1,
|
|
209
|
+
labelGridCellSize: 100,
|
|
210
|
+
labelRenderedSizeThreshold: 6,
|
|
211
|
+
// Reducers
|
|
212
|
+
nodeReducer: null,
|
|
213
|
+
edgeReducer: null,
|
|
214
|
+
// Features
|
|
215
|
+
zIndex: !1,
|
|
216
|
+
minCameraRatio: null,
|
|
217
|
+
maxCameraRatio: null,
|
|
218
|
+
enableCameraZooming: !0,
|
|
219
|
+
enableCameraPanning: !0,
|
|
220
|
+
enableCameraRotation: !0,
|
|
221
|
+
cameraPanBoundaries: null,
|
|
222
|
+
// Lifecycle
|
|
223
|
+
allowInvalidContainer: !1,
|
|
224
|
+
// Program classes
|
|
225
|
+
nodeProgramClasses: {},
|
|
226
|
+
nodeHoverProgramClasses: {},
|
|
227
|
+
edgeProgramClasses: {}
|
|
228
|
+
}, at = {
|
|
229
|
+
circle: Ge
|
|
230
|
+
}, rt = {
|
|
231
|
+
arrow: Fe,
|
|
232
|
+
line: Ie
|
|
233
|
+
};
|
|
234
|
+
function oe(s) {
|
|
235
|
+
if (typeof s.labelDensity != "number" || s.labelDensity < 0)
|
|
236
|
+
throw new Error("Settings: invalid `labelDensity`. Expecting a positive number.");
|
|
237
|
+
var n = s.minCameraRatio, i = s.maxCameraRatio;
|
|
238
|
+
if (typeof n == "number" && typeof i == "number" && i < n)
|
|
239
|
+
throw new Error("Settings: invalid camera ratio boundaries. Expecting `maxCameraRatio` to be greater than `minCameraRatio`.");
|
|
240
|
+
}
|
|
241
|
+
function nt(s) {
|
|
242
|
+
var n = se({}, ce, s);
|
|
243
|
+
return n.nodeProgramClasses = se({}, at, n.nodeProgramClasses), n.edgeProgramClasses = se({}, rt, n.edgeProgramClasses), n;
|
|
244
|
+
}
|
|
245
|
+
var te = 1.5, Ce = /* @__PURE__ */ (function(s) {
|
|
246
|
+
function n() {
|
|
247
|
+
var i;
|
|
248
|
+
return Z(this, n), i = j(this, n), c(i, "x", 0.5), c(i, "y", 0.5), c(i, "angle", 0), c(i, "ratio", 1), c(i, "minRatio", null), c(i, "maxRatio", null), c(i, "enabledZooming", !0), c(i, "enabledPanning", !0), c(i, "enabledRotation", !0), c(i, "clean", null), c(i, "nextFrame", null), c(i, "previousState", null), c(i, "enabled", !0), i.previousState = i.getState(), i;
|
|
249
|
+
}
|
|
250
|
+
return Y(n, s), O(n, [{
|
|
251
|
+
key: "enable",
|
|
252
|
+
value: (
|
|
253
|
+
/**
|
|
254
|
+
* Method used to enable the camera.
|
|
255
|
+
*/
|
|
256
|
+
function() {
|
|
257
|
+
return this.enabled = !0, this;
|
|
258
|
+
}
|
|
259
|
+
)
|
|
260
|
+
/**
|
|
261
|
+
* Method used to disable the camera.
|
|
262
|
+
*/
|
|
263
|
+
}, {
|
|
264
|
+
key: "disable",
|
|
265
|
+
value: function() {
|
|
266
|
+
return this.enabled = !1, this;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Method used to retrieve the camera's current state.
|
|
270
|
+
*/
|
|
271
|
+
}, {
|
|
272
|
+
key: "getState",
|
|
273
|
+
value: function() {
|
|
274
|
+
return {
|
|
275
|
+
x: this.x,
|
|
276
|
+
y: this.y,
|
|
277
|
+
angle: this.angle,
|
|
278
|
+
ratio: this.ratio
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Method used to check whether the camera has the given state.
|
|
283
|
+
*/
|
|
284
|
+
}, {
|
|
285
|
+
key: "hasState",
|
|
286
|
+
value: function(e) {
|
|
287
|
+
return this.x === e.x && this.y === e.y && this.ratio === e.ratio && this.angle === e.angle;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Method used to retrieve the camera's previous state.
|
|
291
|
+
*/
|
|
292
|
+
}, {
|
|
293
|
+
key: "getPreviousState",
|
|
294
|
+
value: function() {
|
|
295
|
+
var e = this.previousState;
|
|
296
|
+
return e ? {
|
|
297
|
+
x: e.x,
|
|
298
|
+
y: e.y,
|
|
299
|
+
angle: e.angle,
|
|
300
|
+
ratio: e.ratio
|
|
301
|
+
} : null;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Method used to check minRatio and maxRatio values.
|
|
305
|
+
*/
|
|
306
|
+
}, {
|
|
307
|
+
key: "getBoundedRatio",
|
|
308
|
+
value: function(e) {
|
|
309
|
+
var t = e;
|
|
310
|
+
return typeof this.minRatio == "number" && (t = Math.max(t, this.minRatio)), typeof this.maxRatio == "number" && (t = Math.min(t, this.maxRatio)), t;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Method used to check various things to return a legit state candidate.
|
|
314
|
+
*/
|
|
315
|
+
}, {
|
|
316
|
+
key: "validateState",
|
|
317
|
+
value: function(e) {
|
|
318
|
+
var t = {};
|
|
319
|
+
return this.enabledPanning && typeof e.x == "number" && (t.x = e.x), this.enabledPanning && typeof e.y == "number" && (t.y = e.y), this.enabledZooming && typeof e.ratio == "number" && (t.ratio = this.getBoundedRatio(e.ratio)), this.enabledRotation && typeof e.angle == "number" && (t.angle = e.angle), this.clean ? this.clean(v(v({}, this.getState()), t)) : t;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Method used to check whether the camera is currently being animated.
|
|
323
|
+
*/
|
|
324
|
+
}, {
|
|
325
|
+
key: "isAnimated",
|
|
326
|
+
value: function() {
|
|
327
|
+
return !!this.nextFrame;
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Method used to set the camera's state.
|
|
331
|
+
*/
|
|
332
|
+
}, {
|
|
333
|
+
key: "setState",
|
|
334
|
+
value: function(e) {
|
|
335
|
+
if (!this.enabled) return this;
|
|
336
|
+
this.previousState = this.getState();
|
|
337
|
+
var t = this.validateState(e);
|
|
338
|
+
return typeof t.x == "number" && (this.x = t.x), typeof t.y == "number" && (this.y = t.y), typeof t.ratio == "number" && (this.ratio = t.ratio), typeof t.angle == "number" && (this.angle = t.angle), this.hasState(this.previousState) || this.emit("updated", this.getState()), this;
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Method used to update the camera's state using a function.
|
|
342
|
+
*/
|
|
343
|
+
}, {
|
|
344
|
+
key: "updateState",
|
|
345
|
+
value: function(e) {
|
|
346
|
+
return this.setState(e(this.getState())), this;
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Method used to animate the camera.
|
|
350
|
+
*/
|
|
351
|
+
}, {
|
|
352
|
+
key: "animate",
|
|
353
|
+
value: function(e) {
|
|
354
|
+
var t = this, a = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, r = arguments.length > 2 ? arguments[2] : void 0;
|
|
355
|
+
if (!r) return new Promise(function(f) {
|
|
356
|
+
return t.animate(e, a, f);
|
|
357
|
+
});
|
|
358
|
+
if (this.enabled) {
|
|
359
|
+
var o = v(v({}, Je), a), h = this.validateState(e), d = typeof o.easing == "function" ? o.easing : Ke[o.easing], l = Date.now(), u = this.getState(), g = function() {
|
|
360
|
+
var m = (Date.now() - l) / o.duration;
|
|
361
|
+
if (m >= 1) {
|
|
362
|
+
t.nextFrame = null, t.setState(h), t.animationCallback && (t.animationCallback.call(null), t.animationCallback = void 0);
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
var p = d(m), y = {};
|
|
366
|
+
typeof h.x == "number" && (y.x = u.x + (h.x - u.x) * p), typeof h.y == "number" && (y.y = u.y + (h.y - u.y) * p), t.enabledRotation && typeof h.angle == "number" && (y.angle = u.angle + (h.angle - u.angle) * p), typeof h.ratio == "number" && (y.ratio = u.ratio + (h.ratio - u.ratio) * p), t.setState(y), t.nextFrame = requestAnimationFrame(g);
|
|
367
|
+
};
|
|
368
|
+
this.nextFrame ? (cancelAnimationFrame(this.nextFrame), this.animationCallback && this.animationCallback.call(null), this.nextFrame = requestAnimationFrame(g)) : g(), this.animationCallback = r;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Method used to zoom the camera.
|
|
373
|
+
*/
|
|
374
|
+
}, {
|
|
375
|
+
key: "animatedZoom",
|
|
376
|
+
value: function(e) {
|
|
377
|
+
return e ? typeof e == "number" ? this.animate({
|
|
378
|
+
ratio: this.ratio / e
|
|
379
|
+
}) : this.animate({
|
|
380
|
+
ratio: this.ratio / (e.factor || te)
|
|
381
|
+
}, e) : this.animate({
|
|
382
|
+
ratio: this.ratio / te
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Method used to unzoom the camera.
|
|
387
|
+
*/
|
|
388
|
+
}, {
|
|
389
|
+
key: "animatedUnzoom",
|
|
390
|
+
value: function(e) {
|
|
391
|
+
return e ? typeof e == "number" ? this.animate({
|
|
392
|
+
ratio: this.ratio * e
|
|
393
|
+
}) : this.animate({
|
|
394
|
+
ratio: this.ratio * (e.factor || te)
|
|
395
|
+
}, e) : this.animate({
|
|
396
|
+
ratio: this.ratio * te
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Method used to reset the camera.
|
|
401
|
+
*/
|
|
402
|
+
}, {
|
|
403
|
+
key: "animatedReset",
|
|
404
|
+
value: function(e) {
|
|
405
|
+
return this.animate({
|
|
406
|
+
x: 0.5,
|
|
407
|
+
y: 0.5,
|
|
408
|
+
ratio: 1,
|
|
409
|
+
angle: 0
|
|
410
|
+
}, e);
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* Returns a new Camera instance, with the same state as the current camera.
|
|
414
|
+
*/
|
|
415
|
+
}, {
|
|
416
|
+
key: "copy",
|
|
417
|
+
value: function() {
|
|
418
|
+
return n.from(this.getState());
|
|
419
|
+
}
|
|
420
|
+
}], [{
|
|
421
|
+
key: "from",
|
|
422
|
+
value: function(e) {
|
|
423
|
+
var t = new n();
|
|
424
|
+
return t.setState(e);
|
|
425
|
+
}
|
|
426
|
+
}]);
|
|
427
|
+
})(ue);
|
|
428
|
+
function M(s, n) {
|
|
429
|
+
var i = n.getBoundingClientRect();
|
|
430
|
+
return {
|
|
431
|
+
x: s.clientX - i.left,
|
|
432
|
+
y: s.clientY - i.top
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
function F(s, n) {
|
|
436
|
+
var i = v(v({}, M(s, n)), {}, {
|
|
437
|
+
sigmaDefaultPrevented: !1,
|
|
438
|
+
preventSigmaDefault: function() {
|
|
439
|
+
i.sigmaDefaultPrevented = !0;
|
|
440
|
+
},
|
|
441
|
+
original: s
|
|
442
|
+
});
|
|
443
|
+
return i;
|
|
444
|
+
}
|
|
445
|
+
function K(s) {
|
|
446
|
+
var n = "x" in s ? s : v(v({}, s.touches[0] || s.previousTouches[0]), {}, {
|
|
447
|
+
original: s.original,
|
|
448
|
+
sigmaDefaultPrevented: s.sigmaDefaultPrevented,
|
|
449
|
+
preventSigmaDefault: function() {
|
|
450
|
+
s.sigmaDefaultPrevented = !0, n.sigmaDefaultPrevented = !0;
|
|
451
|
+
}
|
|
452
|
+
});
|
|
453
|
+
return n;
|
|
454
|
+
}
|
|
455
|
+
function st(s, n) {
|
|
456
|
+
return v(v({}, F(s, n)), {}, {
|
|
457
|
+
delta: Te(s)
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
var ot = 2;
|
|
461
|
+
function ie(s) {
|
|
462
|
+
for (var n = [], i = 0, e = Math.min(s.length, ot); i < e; i++) n.push(s[i]);
|
|
463
|
+
return n;
|
|
464
|
+
}
|
|
465
|
+
function J(s, n, i) {
|
|
466
|
+
var e = {
|
|
467
|
+
touches: ie(s.touches).map(function(t) {
|
|
468
|
+
return M(t, i);
|
|
469
|
+
}),
|
|
470
|
+
previousTouches: n.map(function(t) {
|
|
471
|
+
return M(t, i);
|
|
472
|
+
}),
|
|
473
|
+
sigmaDefaultPrevented: !1,
|
|
474
|
+
preventSigmaDefault: function() {
|
|
475
|
+
e.sigmaDefaultPrevented = !0;
|
|
476
|
+
},
|
|
477
|
+
original: s
|
|
478
|
+
};
|
|
479
|
+
return e;
|
|
480
|
+
}
|
|
481
|
+
function Te(s) {
|
|
482
|
+
if (typeof s.deltaY < "u") return s.deltaY * -3 / 360;
|
|
483
|
+
if (typeof s.detail < "u") return s.detail / -9;
|
|
484
|
+
throw new Error("Captor: could not extract delta from event.");
|
|
485
|
+
}
|
|
486
|
+
var De = /* @__PURE__ */ (function(s) {
|
|
487
|
+
function n(i, e) {
|
|
488
|
+
var t;
|
|
489
|
+
return Z(this, n), t = j(this, n), t.container = i, t.renderer = e, t;
|
|
490
|
+
}
|
|
491
|
+
return Y(n, s), O(n);
|
|
492
|
+
})(ue), ht = ["doubleClickTimeout", "doubleClickZoomingDuration", "doubleClickZoomingRatio", "dragTimeout", "draggedEventsTolerance", "inertiaDuration", "inertiaRatio", "zoomDuration", "zoomingRatio"], dt = ht.reduce(function(s, n) {
|
|
493
|
+
return v(v({}, s), {}, c({}, n, ce[n]));
|
|
494
|
+
}, {}), lt = /* @__PURE__ */ (function(s) {
|
|
495
|
+
function n(i, e) {
|
|
496
|
+
var t;
|
|
497
|
+
return Z(this, n), t = j(this, n, [i, e]), c(t, "enabled", !0), c(t, "draggedEvents", 0), c(t, "downStartTime", null), c(t, "lastMouseX", null), c(t, "lastMouseY", null), c(t, "isMouseDown", !1), c(t, "isMoving", !1), c(t, "movingTimeout", null), c(t, "startCameraState", null), c(t, "clicks", 0), c(t, "doubleClickTimeout", null), c(t, "currentWheelDirection", 0), c(t, "settings", dt), t.handleClick = t.handleClick.bind(t), t.handleRightClick = t.handleRightClick.bind(t), t.handleDown = t.handleDown.bind(t), t.handleUp = t.handleUp.bind(t), t.handleMove = t.handleMove.bind(t), t.handleWheel = t.handleWheel.bind(t), t.handleLeave = t.handleLeave.bind(t), t.handleEnter = t.handleEnter.bind(t), i.addEventListener("click", t.handleClick, {
|
|
498
|
+
capture: !1
|
|
499
|
+
}), i.addEventListener("contextmenu", t.handleRightClick, {
|
|
500
|
+
capture: !1
|
|
501
|
+
}), i.addEventListener("mousedown", t.handleDown, {
|
|
502
|
+
capture: !1
|
|
503
|
+
}), i.addEventListener("wheel", t.handleWheel, {
|
|
504
|
+
capture: !1
|
|
505
|
+
}), i.addEventListener("mouseleave", t.handleLeave, {
|
|
506
|
+
capture: !1
|
|
507
|
+
}), i.addEventListener("mouseenter", t.handleEnter, {
|
|
508
|
+
capture: !1
|
|
509
|
+
}), document.addEventListener("mousemove", t.handleMove, {
|
|
510
|
+
capture: !1
|
|
511
|
+
}), document.addEventListener("mouseup", t.handleUp, {
|
|
512
|
+
capture: !1
|
|
513
|
+
}), t;
|
|
514
|
+
}
|
|
515
|
+
return Y(n, s), O(n, [{
|
|
516
|
+
key: "kill",
|
|
517
|
+
value: function() {
|
|
518
|
+
var e = this.container;
|
|
519
|
+
e.removeEventListener("click", this.handleClick), e.removeEventListener("contextmenu", this.handleRightClick), e.removeEventListener("mousedown", this.handleDown), e.removeEventListener("wheel", this.handleWheel), e.removeEventListener("mouseleave", this.handleLeave), e.removeEventListener("mouseenter", this.handleEnter), document.removeEventListener("mousemove", this.handleMove), document.removeEventListener("mouseup", this.handleUp);
|
|
520
|
+
}
|
|
521
|
+
}, {
|
|
522
|
+
key: "handleClick",
|
|
523
|
+
value: function(e) {
|
|
524
|
+
var t = this;
|
|
525
|
+
if (this.enabled) {
|
|
526
|
+
if (this.clicks++, this.clicks === 2)
|
|
527
|
+
return this.clicks = 0, typeof this.doubleClickTimeout == "number" && (clearTimeout(this.doubleClickTimeout), this.doubleClickTimeout = null), this.handleDoubleClick(e);
|
|
528
|
+
setTimeout(function() {
|
|
529
|
+
t.clicks = 0, t.doubleClickTimeout = null;
|
|
530
|
+
}, this.settings.doubleClickTimeout), this.draggedEvents < this.settings.draggedEventsTolerance && this.emit("click", F(e, this.container));
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
}, {
|
|
534
|
+
key: "handleRightClick",
|
|
535
|
+
value: function(e) {
|
|
536
|
+
this.enabled && this.emit("rightClick", F(e, this.container));
|
|
537
|
+
}
|
|
538
|
+
}, {
|
|
539
|
+
key: "handleDoubleClick",
|
|
540
|
+
value: function(e) {
|
|
541
|
+
if (this.enabled) {
|
|
542
|
+
e.preventDefault(), e.stopPropagation();
|
|
543
|
+
var t = F(e, this.container);
|
|
544
|
+
if (this.emit("doubleClick", t), !t.sigmaDefaultPrevented) {
|
|
545
|
+
var a = this.renderer.getCamera(), r = a.getBoundedRatio(a.getState().ratio / this.settings.doubleClickZoomingRatio);
|
|
546
|
+
a.animate(this.renderer.getViewportZoomedState(M(e, this.container), r), {
|
|
547
|
+
easing: "quadraticInOut",
|
|
548
|
+
duration: this.settings.doubleClickZoomingDuration
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
}, {
|
|
554
|
+
key: "handleDown",
|
|
555
|
+
value: function(e) {
|
|
556
|
+
if (this.enabled) {
|
|
557
|
+
if (e.button === 0) {
|
|
558
|
+
this.startCameraState = this.renderer.getCamera().getState();
|
|
559
|
+
var t = M(e, this.container), a = t.x, r = t.y;
|
|
560
|
+
this.lastMouseX = a, this.lastMouseY = r, this.draggedEvents = 0, this.downStartTime = Date.now(), this.isMouseDown = !0;
|
|
561
|
+
}
|
|
562
|
+
this.emit("mousedown", F(e, this.container));
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
}, {
|
|
566
|
+
key: "handleUp",
|
|
567
|
+
value: function(e) {
|
|
568
|
+
var t = this;
|
|
569
|
+
if (!(!this.enabled || !this.isMouseDown)) {
|
|
570
|
+
var a = this.renderer.getCamera();
|
|
571
|
+
this.isMouseDown = !1, typeof this.movingTimeout == "number" && (clearTimeout(this.movingTimeout), this.movingTimeout = null);
|
|
572
|
+
var r = M(e, this.container), o = r.x, h = r.y, d = a.getState(), l = a.getPreviousState() || {
|
|
573
|
+
x: 0,
|
|
574
|
+
y: 0
|
|
575
|
+
};
|
|
576
|
+
this.isMoving ? a.animate({
|
|
577
|
+
x: d.x + this.settings.inertiaRatio * (d.x - l.x),
|
|
578
|
+
y: d.y + this.settings.inertiaRatio * (d.y - l.y)
|
|
579
|
+
}, {
|
|
580
|
+
duration: this.settings.inertiaDuration,
|
|
581
|
+
easing: "quadraticOut"
|
|
582
|
+
}) : (this.lastMouseX !== o || this.lastMouseY !== h) && a.setState({
|
|
583
|
+
x: d.x,
|
|
584
|
+
y: d.y
|
|
585
|
+
}), this.isMoving = !1, setTimeout(function() {
|
|
586
|
+
var u = t.draggedEvents > 0;
|
|
587
|
+
t.draggedEvents = 0, u && t.renderer.getSetting("hideEdgesOnMove") && t.renderer.refresh();
|
|
588
|
+
}, 0), this.emit("mouseup", F(e, this.container));
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
}, {
|
|
592
|
+
key: "handleMove",
|
|
593
|
+
value: function(e) {
|
|
594
|
+
var t = this;
|
|
595
|
+
if (this.enabled) {
|
|
596
|
+
var a = F(e, this.container);
|
|
597
|
+
if (this.emit("mousemovebody", a), (e.target === this.container || e.composedPath()[0] === this.container) && this.emit("mousemove", a), !a.sigmaDefaultPrevented && this.isMouseDown) {
|
|
598
|
+
this.isMoving = !0, this.draggedEvents++, typeof this.movingTimeout == "number" && clearTimeout(this.movingTimeout), this.movingTimeout = window.setTimeout(function() {
|
|
599
|
+
t.movingTimeout = null, t.isMoving = !1;
|
|
600
|
+
}, this.settings.dragTimeout);
|
|
601
|
+
var r = this.renderer.getCamera(), o = M(e, this.container), h = o.x, d = o.y, l = this.renderer.viewportToFramedGraph({
|
|
602
|
+
x: this.lastMouseX,
|
|
603
|
+
y: this.lastMouseY
|
|
604
|
+
}), u = this.renderer.viewportToFramedGraph({
|
|
605
|
+
x: h,
|
|
606
|
+
y: d
|
|
607
|
+
}), g = l.x - u.x, f = l.y - u.y, m = r.getState(), p = m.x + g, y = m.y + f;
|
|
608
|
+
r.setState({
|
|
609
|
+
x: p,
|
|
610
|
+
y
|
|
611
|
+
}), this.lastMouseX = h, this.lastMouseY = d, e.preventDefault(), e.stopPropagation();
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
}, {
|
|
616
|
+
key: "handleLeave",
|
|
617
|
+
value: function(e) {
|
|
618
|
+
this.emit("mouseleave", F(e, this.container));
|
|
619
|
+
}
|
|
620
|
+
}, {
|
|
621
|
+
key: "handleEnter",
|
|
622
|
+
value: function(e) {
|
|
623
|
+
this.emit("mouseenter", F(e, this.container));
|
|
624
|
+
}
|
|
625
|
+
}, {
|
|
626
|
+
key: "handleWheel",
|
|
627
|
+
value: function(e) {
|
|
628
|
+
var t = this, a = this.renderer.getCamera();
|
|
629
|
+
if (!(!this.enabled || !a.enabledZooming)) {
|
|
630
|
+
var r = Te(e);
|
|
631
|
+
if (r) {
|
|
632
|
+
var o = st(e, this.container);
|
|
633
|
+
if (this.emit("wheel", o), o.sigmaDefaultPrevented) {
|
|
634
|
+
e.preventDefault(), e.stopPropagation();
|
|
635
|
+
return;
|
|
636
|
+
}
|
|
637
|
+
var h = a.getState().ratio, d = r > 0 ? 1 / this.settings.zoomingRatio : this.settings.zoomingRatio, l = a.getBoundedRatio(h * d), u = r > 0 ? 1 : -1, g = Date.now();
|
|
638
|
+
h !== l && (e.preventDefault(), e.stopPropagation(), !(this.currentWheelDirection === u && this.lastWheelTriggerTime && g - this.lastWheelTriggerTime < this.settings.zoomDuration / 5) && (a.animate(this.renderer.getViewportZoomedState(M(e, this.container), l), {
|
|
639
|
+
easing: "quadraticOut",
|
|
640
|
+
duration: this.settings.zoomDuration
|
|
641
|
+
}, function() {
|
|
642
|
+
t.currentWheelDirection = 0;
|
|
643
|
+
}), this.currentWheelDirection = u, this.lastWheelTriggerTime = g));
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
}, {
|
|
648
|
+
key: "setSettings",
|
|
649
|
+
value: function(e) {
|
|
650
|
+
this.settings = e;
|
|
651
|
+
}
|
|
652
|
+
}]);
|
|
653
|
+
})(De), ut = ["dragTimeout", "inertiaDuration", "inertiaRatio", "doubleClickTimeout", "doubleClickZoomingRatio", "doubleClickZoomingDuration", "tapMoveTolerance"], ct = ut.reduce(function(s, n) {
|
|
654
|
+
return v(v({}, s), {}, c({}, n, ce[n]));
|
|
655
|
+
}, {}), gt = /* @__PURE__ */ (function(s) {
|
|
656
|
+
function n(i, e) {
|
|
657
|
+
var t;
|
|
658
|
+
return Z(this, n), t = j(this, n, [i, e]), c(t, "enabled", !0), c(t, "isMoving", !1), c(t, "hasMoved", !1), c(t, "touchMode", 0), c(t, "startTouchesPositions", []), c(t, "lastTouches", []), c(t, "lastTap", null), c(t, "settings", ct), t.handleStart = t.handleStart.bind(t), t.handleLeave = t.handleLeave.bind(t), t.handleMove = t.handleMove.bind(t), i.addEventListener("touchstart", t.handleStart, {
|
|
659
|
+
capture: !1
|
|
660
|
+
}), i.addEventListener("touchcancel", t.handleLeave, {
|
|
661
|
+
capture: !1
|
|
662
|
+
}), document.addEventListener("touchend", t.handleLeave, {
|
|
663
|
+
capture: !1,
|
|
664
|
+
passive: !1
|
|
665
|
+
}), document.addEventListener("touchmove", t.handleMove, {
|
|
666
|
+
capture: !1,
|
|
667
|
+
passive: !1
|
|
668
|
+
}), t;
|
|
669
|
+
}
|
|
670
|
+
return Y(n, s), O(n, [{
|
|
671
|
+
key: "kill",
|
|
672
|
+
value: function() {
|
|
673
|
+
var e = this.container;
|
|
674
|
+
e.removeEventListener("touchstart", this.handleStart), e.removeEventListener("touchcancel", this.handleLeave), document.removeEventListener("touchend", this.handleLeave), document.removeEventListener("touchmove", this.handleMove);
|
|
675
|
+
}
|
|
676
|
+
}, {
|
|
677
|
+
key: "getDimensions",
|
|
678
|
+
value: function() {
|
|
679
|
+
return {
|
|
680
|
+
width: this.container.offsetWidth,
|
|
681
|
+
height: this.container.offsetHeight
|
|
682
|
+
};
|
|
683
|
+
}
|
|
684
|
+
}, {
|
|
685
|
+
key: "handleStart",
|
|
686
|
+
value: function(e) {
|
|
687
|
+
var t = this;
|
|
688
|
+
if (this.enabled) {
|
|
689
|
+
e.preventDefault();
|
|
690
|
+
var a = ie(e.touches);
|
|
691
|
+
if (this.touchMode = a.length, this.startCameraState = this.renderer.getCamera().getState(), this.startTouchesPositions = a.map(function(f) {
|
|
692
|
+
return M(f, t.container);
|
|
693
|
+
}), this.touchMode === 2) {
|
|
694
|
+
var r = Q(this.startTouchesPositions, 2), o = r[0], h = o.x, d = o.y, l = r[1], u = l.x, g = l.y;
|
|
695
|
+
this.startTouchesAngle = Math.atan2(g - d, u - h), this.startTouchesDistance = Math.sqrt(Math.pow(u - h, 2) + Math.pow(g - d, 2));
|
|
696
|
+
}
|
|
697
|
+
this.emit("touchdown", J(e, this.lastTouches, this.container)), this.lastTouches = a, this.lastTouchesPositions = this.startTouchesPositions;
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
}, {
|
|
701
|
+
key: "handleLeave",
|
|
702
|
+
value: function(e) {
|
|
703
|
+
if (!(!this.enabled || !this.startTouchesPositions.length)) {
|
|
704
|
+
switch (e.cancelable && e.preventDefault(), this.movingTimeout && (this.isMoving = !1, clearTimeout(this.movingTimeout)), this.touchMode) {
|
|
705
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
706
|
+
// @ts-ignore
|
|
707
|
+
case 2:
|
|
708
|
+
if (e.touches.length === 1) {
|
|
709
|
+
this.handleStart(e), e.preventDefault();
|
|
710
|
+
break;
|
|
711
|
+
}
|
|
712
|
+
/* falls through */
|
|
713
|
+
case 1:
|
|
714
|
+
if (this.isMoving) {
|
|
715
|
+
var t = this.renderer.getCamera(), a = t.getState(), r = t.getPreviousState() || {
|
|
716
|
+
x: 0,
|
|
717
|
+
y: 0
|
|
718
|
+
};
|
|
719
|
+
t.animate({
|
|
720
|
+
x: a.x + this.settings.inertiaRatio * (a.x - r.x),
|
|
721
|
+
y: a.y + this.settings.inertiaRatio * (a.y - r.y)
|
|
722
|
+
}, {
|
|
723
|
+
duration: this.settings.inertiaDuration,
|
|
724
|
+
easing: "quadraticOut"
|
|
725
|
+
});
|
|
726
|
+
}
|
|
727
|
+
this.hasMoved = !1, this.isMoving = !1, this.touchMode = 0;
|
|
728
|
+
break;
|
|
729
|
+
}
|
|
730
|
+
if (this.emit("touchup", J(e, this.lastTouches, this.container)), !e.touches.length) {
|
|
731
|
+
var o = M(this.lastTouches[0], this.container), h = this.startTouchesPositions[0], d = Math.pow(o.x - h.x, 2) + Math.pow(o.y - h.y, 2);
|
|
732
|
+
if (!e.touches.length && d < Math.pow(this.settings.tapMoveTolerance, 2))
|
|
733
|
+
if (this.lastTap && Date.now() - this.lastTap.time < this.settings.doubleClickTimeout) {
|
|
734
|
+
var l = J(e, this.lastTouches, this.container);
|
|
735
|
+
if (this.emit("doubletap", l), this.lastTap = null, !l.sigmaDefaultPrevented) {
|
|
736
|
+
var u = this.renderer.getCamera(), g = u.getBoundedRatio(u.getState().ratio / this.settings.doubleClickZoomingRatio);
|
|
737
|
+
u.animate(this.renderer.getViewportZoomedState(o, g), {
|
|
738
|
+
easing: "quadraticInOut",
|
|
739
|
+
duration: this.settings.doubleClickZoomingDuration
|
|
740
|
+
});
|
|
741
|
+
}
|
|
742
|
+
} else {
|
|
743
|
+
var f = J(e, this.lastTouches, this.container);
|
|
744
|
+
this.emit("tap", f), this.lastTap = {
|
|
745
|
+
time: Date.now(),
|
|
746
|
+
position: f.touches[0] || f.previousTouches[0]
|
|
747
|
+
};
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
this.lastTouches = ie(e.touches), this.startTouchesPositions = [];
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
}, {
|
|
754
|
+
key: "handleMove",
|
|
755
|
+
value: function(e) {
|
|
756
|
+
var t = this;
|
|
757
|
+
if (!(!this.enabled || !this.startTouchesPositions.length)) {
|
|
758
|
+
e.preventDefault();
|
|
759
|
+
var a = ie(e.touches), r = a.map(function(B) {
|
|
760
|
+
return M(B, t.container);
|
|
761
|
+
}), o = this.lastTouches;
|
|
762
|
+
this.lastTouches = a, this.lastTouchesPositions = r;
|
|
763
|
+
var h = J(e, o, this.container);
|
|
764
|
+
if (this.emit("touchmove", h), !h.sigmaDefaultPrevented && (this.hasMoved || (this.hasMoved = r.some(function(B, ae) {
|
|
765
|
+
var G = t.startTouchesPositions[ae];
|
|
766
|
+
return G && (B.x !== G.x || B.y !== G.y);
|
|
767
|
+
})), !!this.hasMoved)) {
|
|
768
|
+
this.isMoving = !0, this.movingTimeout && clearTimeout(this.movingTimeout), this.movingTimeout = window.setTimeout(function() {
|
|
769
|
+
t.isMoving = !1;
|
|
770
|
+
}, this.settings.dragTimeout);
|
|
771
|
+
var d = this.renderer.getCamera(), l = this.startCameraState, u = this.renderer.getSetting("stagePadding");
|
|
772
|
+
switch (this.touchMode) {
|
|
773
|
+
case 1: {
|
|
774
|
+
var g = this.renderer.viewportToFramedGraph((this.startTouchesPositions || [])[0]), f = g.x, m = g.y, p = this.renderer.viewportToFramedGraph(r[0]), y = p.x, E = p.y;
|
|
775
|
+
d.setState({
|
|
776
|
+
x: l.x + f - y,
|
|
777
|
+
y: l.y + m - E
|
|
778
|
+
});
|
|
779
|
+
break;
|
|
780
|
+
}
|
|
781
|
+
case 2: {
|
|
782
|
+
var b = {
|
|
783
|
+
x: 0.5,
|
|
784
|
+
y: 0.5,
|
|
785
|
+
angle: 0,
|
|
786
|
+
ratio: 1
|
|
787
|
+
}, x = r[0], C = x.x, I = x.y, A = r[1], w = A.x, k = A.y, T = Math.atan2(k - I, w - C) - this.startTouchesAngle, L = Math.hypot(k - I, w - C) / this.startTouchesDistance, D = d.getBoundedRatio(l.ratio / L);
|
|
788
|
+
b.ratio = D, b.angle = l.angle + T;
|
|
789
|
+
var S = this.getDimensions(), _ = this.renderer.viewportToFramedGraph((this.startTouchesPositions || [])[0], {
|
|
790
|
+
cameraState: l
|
|
791
|
+
}), P = Math.min(S.width, S.height) - 2 * u, R = P / S.width, U = P / S.height, $ = D / P, q = C - P / 2 / R, V = I - P / 2 / U, H = [q * Math.cos(-b.angle) - V * Math.sin(-b.angle), V * Math.cos(-b.angle) + q * Math.sin(-b.angle)];
|
|
792
|
+
q = H[0], V = H[1], b.x = _.x - q * $, b.y = _.y + V * $, d.setState(b);
|
|
793
|
+
break;
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
}, {
|
|
800
|
+
key: "setSettings",
|
|
801
|
+
value: function(e) {
|
|
802
|
+
this.settings = e;
|
|
803
|
+
}
|
|
804
|
+
}]);
|
|
805
|
+
})(De);
|
|
806
|
+
function vt(s) {
|
|
807
|
+
if (Array.isArray(s)) return Ae(s);
|
|
808
|
+
}
|
|
809
|
+
function ft(s) {
|
|
810
|
+
if (typeof Symbol < "u" && s[Symbol.iterator] != null || s["@@iterator"] != null) return Array.from(s);
|
|
811
|
+
}
|
|
812
|
+
function mt() {
|
|
813
|
+
throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
814
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
|
|
815
|
+
}
|
|
816
|
+
function Ee(s) {
|
|
817
|
+
return vt(s) || ft(s) || ze(s) || mt();
|
|
818
|
+
}
|
|
819
|
+
function pt(s, n) {
|
|
820
|
+
if (s == null) return {};
|
|
821
|
+
var i = {};
|
|
822
|
+
for (var e in s) if ({}.hasOwnProperty.call(s, e)) {
|
|
823
|
+
if (n.indexOf(e) !== -1) continue;
|
|
824
|
+
i[e] = s[e];
|
|
825
|
+
}
|
|
826
|
+
return i;
|
|
827
|
+
}
|
|
828
|
+
function he(s, n) {
|
|
829
|
+
if (s == null) return {};
|
|
830
|
+
var i, e, t = pt(s, n);
|
|
831
|
+
if (Object.getOwnPropertySymbols) {
|
|
832
|
+
var a = Object.getOwnPropertySymbols(s);
|
|
833
|
+
for (e = 0; e < a.length; e++) i = a[e], n.indexOf(i) === -1 && {}.propertyIsEnumerable.call(s, i) && (t[i] = s[i]);
|
|
834
|
+
}
|
|
835
|
+
return t;
|
|
836
|
+
}
|
|
837
|
+
var we = /* @__PURE__ */ (function() {
|
|
838
|
+
function s(n, i) {
|
|
839
|
+
Z(this, s), this.key = n, this.size = i;
|
|
840
|
+
}
|
|
841
|
+
return O(s, null, [{
|
|
842
|
+
key: "compare",
|
|
843
|
+
value: function(i, e) {
|
|
844
|
+
return i.size > e.size ? -1 : i.size < e.size || i.key > e.key ? 1 : -1;
|
|
845
|
+
}
|
|
846
|
+
}]);
|
|
847
|
+
})(), Le = /* @__PURE__ */ (function() {
|
|
848
|
+
function s() {
|
|
849
|
+
Z(this, s), c(this, "width", 0), c(this, "height", 0), c(this, "cellSize", 0), c(this, "columns", 0), c(this, "rows", 0), c(this, "cells", {});
|
|
850
|
+
}
|
|
851
|
+
return O(s, [{
|
|
852
|
+
key: "resizeAndClear",
|
|
853
|
+
value: function(i, e) {
|
|
854
|
+
this.width = i.width, this.height = i.height, this.cellSize = e, this.columns = Math.ceil(i.width / e), this.rows = Math.ceil(i.height / e), this.cells = {};
|
|
855
|
+
}
|
|
856
|
+
}, {
|
|
857
|
+
key: "getIndex",
|
|
858
|
+
value: function(i) {
|
|
859
|
+
var e = Math.floor(i.x / this.cellSize), t = Math.floor(i.y / this.cellSize);
|
|
860
|
+
return t * this.columns + e;
|
|
861
|
+
}
|
|
862
|
+
}, {
|
|
863
|
+
key: "add",
|
|
864
|
+
value: function(i, e, t) {
|
|
865
|
+
var a = new we(i, e), r = this.getIndex(t), o = this.cells[r];
|
|
866
|
+
o || (o = [], this.cells[r] = o), o.push(a);
|
|
867
|
+
}
|
|
868
|
+
}, {
|
|
869
|
+
key: "organize",
|
|
870
|
+
value: function() {
|
|
871
|
+
for (var i in this.cells) {
|
|
872
|
+
var e = this.cells[i];
|
|
873
|
+
e.sort(we.compare);
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
}, {
|
|
877
|
+
key: "getLabelsToDisplay",
|
|
878
|
+
value: function(i, e) {
|
|
879
|
+
var t = this.cellSize * this.cellSize, a = t / i / i, r = a * e / t, o = Math.ceil(r), h = [];
|
|
880
|
+
for (var d in this.cells)
|
|
881
|
+
for (var l = this.cells[d], u = 0; u < Math.min(o, l.length); u++)
|
|
882
|
+
h.push(l[u].key);
|
|
883
|
+
return h;
|
|
884
|
+
}
|
|
885
|
+
}]);
|
|
886
|
+
})();
|
|
887
|
+
function yt(s) {
|
|
888
|
+
var n = s.graph, i = s.hoveredNode, e = s.highlightedNodes, t = s.displayedNodeLabels, a = [];
|
|
889
|
+
return n.forEachEdge(function(r, o, h, d) {
|
|
890
|
+
(h === i || d === i || e.has(h) || e.has(d) || t.has(h) && t.has(d)) && a.push(r);
|
|
891
|
+
}), a;
|
|
892
|
+
}
|
|
893
|
+
var Se = 150, Pe = 50, z = Object.prototype.hasOwnProperty;
|
|
894
|
+
function bt(s, n, i) {
|
|
895
|
+
if (!z.call(i, "x") || !z.call(i, "y")) throw new Error('Sigma: could not find a valid position (x, y) for node "'.concat(n, '". All your nodes must have a number "x" and "y". Maybe your forgot to apply a layout or your "nodeReducer" is not returning the correct data?'));
|
|
896
|
+
return i.color || (i.color = s.defaultNodeColor), !i.label && i.label !== "" && (i.label = null), i.label !== void 0 && i.label !== null ? i.label = "" + i.label : i.label = null, i.size || (i.size = 2), z.call(i, "hidden") || (i.hidden = !1), z.call(i, "highlighted") || (i.highlighted = !1), z.call(i, "forceLabel") || (i.forceLabel = !1), (!i.type || i.type === "") && (i.type = s.defaultNodeType), i.zIndex || (i.zIndex = 0), i;
|
|
897
|
+
}
|
|
898
|
+
function xt(s, n, i) {
|
|
899
|
+
return i.color || (i.color = s.defaultEdgeColor), i.label || (i.label = ""), i.size || (i.size = 0.5), z.call(i, "hidden") || (i.hidden = !1), z.call(i, "forceLabel") || (i.forceLabel = !1), (!i.type || i.type === "") && (i.type = s.defaultEdgeType), i.zIndex || (i.zIndex = 0), i;
|
|
900
|
+
}
|
|
901
|
+
var Ct = /* @__PURE__ */ (function(s) {
|
|
902
|
+
function n(i, e) {
|
|
903
|
+
var t, a = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
904
|
+
if (Z(this, n), t = j(this, n), c(t, "elements", {}), c(t, "canvasContexts", {}), c(t, "webGLContexts", {}), c(t, "pickingLayers", /* @__PURE__ */ new Set()), c(t, "textures", {}), c(t, "frameBuffers", {}), c(t, "activeListeners", {}), c(t, "labelGrid", new Le()), c(t, "nodeDataCache", {}), c(t, "edgeDataCache", {}), c(t, "nodeProgramIndex", {}), c(t, "edgeProgramIndex", {}), c(t, "nodesWithForcedLabels", /* @__PURE__ */ new Set()), c(t, "edgesWithForcedLabels", /* @__PURE__ */ new Set()), c(t, "nodeExtent", {
|
|
905
|
+
x: [0, 1],
|
|
906
|
+
y: [0, 1]
|
|
907
|
+
}), c(t, "nodeZExtent", [1 / 0, -1 / 0]), c(t, "edgeZExtent", [1 / 0, -1 / 0]), c(t, "matrix", N()), c(t, "invMatrix", N()), c(t, "correctionRatio", 1), c(t, "customBBox", null), c(t, "normalizationFunction", be({
|
|
908
|
+
x: [0, 1],
|
|
909
|
+
y: [0, 1]
|
|
910
|
+
})), c(t, "graphToViewportRatio", 1), c(t, "itemIDsIndex", {}), c(t, "nodeIndices", {}), c(t, "edgeIndices", {}), c(t, "width", 0), c(t, "height", 0), c(t, "pixelRatio", pe()), c(t, "pickingDownSizingRatio", 2 * t.pixelRatio), c(t, "displayedNodeLabels", /* @__PURE__ */ new Set()), c(t, "displayedEdgeLabels", /* @__PURE__ */ new Set()), c(t, "highlightedNodes", /* @__PURE__ */ new Set()), c(t, "hoveredNode", null), c(t, "hoveredEdge", null), c(t, "renderFrame", null), c(t, "renderHighlightedNodesFrame", null), c(t, "needToProcess", !1), c(t, "checkEdgesEventsFrame", null), c(t, "nodePrograms", {}), c(t, "nodeHoverPrograms", {}), c(t, "edgePrograms", {}), t.settings = nt(a), oe(t.settings), tt(i), !(e instanceof HTMLElement)) throw new Error("Sigma: container should be an html element.");
|
|
911
|
+
t.graph = i, t.container = e, t.createWebGLContext("edges", {
|
|
912
|
+
picking: a.enableEdgeEvents
|
|
913
|
+
}), t.createCanvasContext("edgeLabels"), t.createWebGLContext("nodes", {
|
|
914
|
+
picking: !0
|
|
915
|
+
}), t.createCanvasContext("labels"), t.createCanvasContext("hovers"), t.createWebGLContext("hoverNodes"), t.createCanvasContext("mouse", {
|
|
916
|
+
style: {
|
|
917
|
+
touchAction: "none",
|
|
918
|
+
userSelect: "none"
|
|
919
|
+
}
|
|
920
|
+
}), t.resize();
|
|
921
|
+
for (var r in t.settings.nodeProgramClasses)
|
|
922
|
+
t.registerNodeProgram(r, t.settings.nodeProgramClasses[r], t.settings.nodeHoverProgramClasses[r]);
|
|
923
|
+
for (var o in t.settings.edgeProgramClasses)
|
|
924
|
+
t.registerEdgeProgram(o, t.settings.edgeProgramClasses[o]);
|
|
925
|
+
return t.camera = new Ce(), t.bindCameraHandlers(), t.mouseCaptor = new lt(t.elements.mouse, t), t.mouseCaptor.setSettings(t.settings), t.touchCaptor = new gt(t.elements.mouse, t), t.touchCaptor.setSettings(t.settings), t.bindEventHandlers(), t.bindGraphHandlers(), t.handleSettingsUpdate(), t.refresh(), t;
|
|
926
|
+
}
|
|
927
|
+
return Y(n, s), O(n, [{
|
|
928
|
+
key: "registerNodeProgram",
|
|
929
|
+
value: function(e, t, a) {
|
|
930
|
+
return this.nodePrograms[e] && this.nodePrograms[e].kill(), this.nodeHoverPrograms[e] && this.nodeHoverPrograms[e].kill(), this.nodePrograms[e] = new t(this.webGLContexts.nodes, this.frameBuffers.nodes, this), this.nodeHoverPrograms[e] = new (a || t)(this.webGLContexts.hoverNodes, null, this), this;
|
|
931
|
+
}
|
|
932
|
+
/**
|
|
933
|
+
* Internal function used to register an edge program
|
|
934
|
+
*
|
|
935
|
+
* @param {string} key - The program's key, matching the related edges "type" values.
|
|
936
|
+
* @param {EdgeProgramType} EdgeProgramClass - An edges program class.
|
|
937
|
+
* @return {Sigma}
|
|
938
|
+
*/
|
|
939
|
+
}, {
|
|
940
|
+
key: "registerEdgeProgram",
|
|
941
|
+
value: function(e, t) {
|
|
942
|
+
return this.edgePrograms[e] && this.edgePrograms[e].kill(), this.edgePrograms[e] = new t(this.webGLContexts.edges, this.frameBuffers.edges, this), this;
|
|
943
|
+
}
|
|
944
|
+
/**
|
|
945
|
+
* Internal function used to unregister a node program
|
|
946
|
+
*
|
|
947
|
+
* @param {string} key - The program's key, matching the related nodes "type" values.
|
|
948
|
+
* @return {Sigma}
|
|
949
|
+
*/
|
|
950
|
+
}, {
|
|
951
|
+
key: "unregisterNodeProgram",
|
|
952
|
+
value: function(e) {
|
|
953
|
+
if (this.nodePrograms[e]) {
|
|
954
|
+
var t = this.nodePrograms, a = t[e], r = he(t, [e].map(ne));
|
|
955
|
+
a.kill(), this.nodePrograms = r;
|
|
956
|
+
}
|
|
957
|
+
if (this.nodeHoverPrograms[e]) {
|
|
958
|
+
var o = this.nodeHoverPrograms, h = o[e], d = he(o, [e].map(ne));
|
|
959
|
+
h.kill(), this.nodePrograms = d;
|
|
960
|
+
}
|
|
961
|
+
return this;
|
|
962
|
+
}
|
|
963
|
+
/**
|
|
964
|
+
* Internal function used to unregister an edge program
|
|
965
|
+
*
|
|
966
|
+
* @param {string} key - The program's key, matching the related edges "type" values.
|
|
967
|
+
* @return {Sigma}
|
|
968
|
+
*/
|
|
969
|
+
}, {
|
|
970
|
+
key: "unregisterEdgeProgram",
|
|
971
|
+
value: function(e) {
|
|
972
|
+
if (this.edgePrograms[e]) {
|
|
973
|
+
var t = this.edgePrograms, a = t[e], r = he(t, [e].map(ne));
|
|
974
|
+
a.kill(), this.edgePrograms = r;
|
|
975
|
+
}
|
|
976
|
+
return this;
|
|
977
|
+
}
|
|
978
|
+
/**
|
|
979
|
+
* Method (re)binding WebGL texture (for picking).
|
|
980
|
+
*
|
|
981
|
+
* @return {Sigma}
|
|
982
|
+
*/
|
|
983
|
+
}, {
|
|
984
|
+
key: "resetWebGLTexture",
|
|
985
|
+
value: function(e) {
|
|
986
|
+
var t = this.webGLContexts[e], a = this.frameBuffers[e], r = this.textures[e];
|
|
987
|
+
r && t.deleteTexture(r);
|
|
988
|
+
var o = t.createTexture();
|
|
989
|
+
return t.bindFramebuffer(t.FRAMEBUFFER, a), t.bindTexture(t.TEXTURE_2D, o), t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, this.width, this.height, 0, t.RGBA, t.UNSIGNED_BYTE, null), t.framebufferTexture2D(t.FRAMEBUFFER, t.COLOR_ATTACHMENT0, t.TEXTURE_2D, o, 0), this.textures[e] = o, this;
|
|
990
|
+
}
|
|
991
|
+
/**
|
|
992
|
+
* Method binding camera handlers.
|
|
993
|
+
*
|
|
994
|
+
* @return {Sigma}
|
|
995
|
+
*/
|
|
996
|
+
}, {
|
|
997
|
+
key: "bindCameraHandlers",
|
|
998
|
+
value: function() {
|
|
999
|
+
var e = this;
|
|
1000
|
+
return this.activeListeners.camera = function() {
|
|
1001
|
+
e.scheduleRender();
|
|
1002
|
+
}, this.camera.on("updated", this.activeListeners.camera), this;
|
|
1003
|
+
}
|
|
1004
|
+
/**
|
|
1005
|
+
* Method unbinding camera handlers.
|
|
1006
|
+
*
|
|
1007
|
+
* @return {Sigma}
|
|
1008
|
+
*/
|
|
1009
|
+
}, {
|
|
1010
|
+
key: "unbindCameraHandlers",
|
|
1011
|
+
value: function() {
|
|
1012
|
+
return this.camera.removeListener("updated", this.activeListeners.camera), this;
|
|
1013
|
+
}
|
|
1014
|
+
/**
|
|
1015
|
+
* Method that returns the closest node to a given position.
|
|
1016
|
+
*/
|
|
1017
|
+
}, {
|
|
1018
|
+
key: "getNodeAtPosition",
|
|
1019
|
+
value: function(e) {
|
|
1020
|
+
var t = e.x, a = e.y, r = ge(this.webGLContexts.nodes, this.frameBuffers.nodes, t, a, this.pixelRatio, this.pickingDownSizingRatio), o = ve.apply(void 0, Ee(r)), h = this.itemIDsIndex[o];
|
|
1021
|
+
return h && h.type === "node" ? h.id : null;
|
|
1022
|
+
}
|
|
1023
|
+
/**
|
|
1024
|
+
* Method binding event handlers.
|
|
1025
|
+
*
|
|
1026
|
+
* @return {Sigma}
|
|
1027
|
+
*/
|
|
1028
|
+
}, {
|
|
1029
|
+
key: "bindEventHandlers",
|
|
1030
|
+
value: function() {
|
|
1031
|
+
var e = this;
|
|
1032
|
+
this.activeListeners.handleResize = function() {
|
|
1033
|
+
e.scheduleRefresh();
|
|
1034
|
+
}, window.addEventListener("resize", this.activeListeners.handleResize), this.activeListeners.handleMove = function(a) {
|
|
1035
|
+
var r = K(a), o = {
|
|
1036
|
+
event: r,
|
|
1037
|
+
preventSigmaDefault: function() {
|
|
1038
|
+
r.preventSigmaDefault();
|
|
1039
|
+
}
|
|
1040
|
+
}, h = e.getNodeAtPosition(r);
|
|
1041
|
+
if (h && e.hoveredNode !== h && !e.nodeDataCache[h].hidden) {
|
|
1042
|
+
e.hoveredNode && e.emit("leaveNode", v(v({}, o), {}, {
|
|
1043
|
+
node: e.hoveredNode
|
|
1044
|
+
})), e.hoveredNode = h, e.emit("enterNode", v(v({}, o), {}, {
|
|
1045
|
+
node: h
|
|
1046
|
+
})), e.scheduleHighlightedNodesRender();
|
|
1047
|
+
return;
|
|
1048
|
+
}
|
|
1049
|
+
if (e.hoveredNode && e.getNodeAtPosition(r) !== e.hoveredNode) {
|
|
1050
|
+
var d = e.hoveredNode;
|
|
1051
|
+
e.hoveredNode = null, e.emit("leaveNode", v(v({}, o), {}, {
|
|
1052
|
+
node: d
|
|
1053
|
+
})), e.scheduleHighlightedNodesRender();
|
|
1054
|
+
return;
|
|
1055
|
+
}
|
|
1056
|
+
if (e.settings.enableEdgeEvents) {
|
|
1057
|
+
var l = e.hoveredNode ? null : e.getEdgeAtPoint(o.event.x, o.event.y);
|
|
1058
|
+
l !== e.hoveredEdge && (e.hoveredEdge && e.emit("leaveEdge", v(v({}, o), {}, {
|
|
1059
|
+
edge: e.hoveredEdge
|
|
1060
|
+
})), l && e.emit("enterEdge", v(v({}, o), {}, {
|
|
1061
|
+
edge: l
|
|
1062
|
+
})), e.hoveredEdge = l);
|
|
1063
|
+
}
|
|
1064
|
+
}, this.activeListeners.handleMoveBody = function(a) {
|
|
1065
|
+
var r = K(a);
|
|
1066
|
+
e.emit("moveBody", {
|
|
1067
|
+
event: r,
|
|
1068
|
+
preventSigmaDefault: function() {
|
|
1069
|
+
r.preventSigmaDefault();
|
|
1070
|
+
}
|
|
1071
|
+
});
|
|
1072
|
+
}, this.activeListeners.handleLeave = function(a) {
|
|
1073
|
+
var r = K(a), o = {
|
|
1074
|
+
event: r,
|
|
1075
|
+
preventSigmaDefault: function() {
|
|
1076
|
+
r.preventSigmaDefault();
|
|
1077
|
+
}
|
|
1078
|
+
};
|
|
1079
|
+
e.hoveredNode && (e.emit("leaveNode", v(v({}, o), {}, {
|
|
1080
|
+
node: e.hoveredNode
|
|
1081
|
+
})), e.scheduleHighlightedNodesRender()), e.settings.enableEdgeEvents && e.hoveredEdge && (e.emit("leaveEdge", v(v({}, o), {}, {
|
|
1082
|
+
edge: e.hoveredEdge
|
|
1083
|
+
})), e.scheduleHighlightedNodesRender()), e.emit("leaveStage", v({}, o));
|
|
1084
|
+
}, this.activeListeners.handleEnter = function(a) {
|
|
1085
|
+
var r = K(a), o = {
|
|
1086
|
+
event: r,
|
|
1087
|
+
preventSigmaDefault: function() {
|
|
1088
|
+
r.preventSigmaDefault();
|
|
1089
|
+
}
|
|
1090
|
+
};
|
|
1091
|
+
e.emit("enterStage", v({}, o));
|
|
1092
|
+
};
|
|
1093
|
+
var t = function(r) {
|
|
1094
|
+
return function(o) {
|
|
1095
|
+
var h = K(o), d = {
|
|
1096
|
+
event: h,
|
|
1097
|
+
preventSigmaDefault: function() {
|
|
1098
|
+
h.preventSigmaDefault();
|
|
1099
|
+
}
|
|
1100
|
+
}, l = e.getNodeAtPosition(h);
|
|
1101
|
+
if (l) return e.emit("".concat(r, "Node"), v(v({}, d), {}, {
|
|
1102
|
+
node: l
|
|
1103
|
+
}));
|
|
1104
|
+
if (e.settings.enableEdgeEvents) {
|
|
1105
|
+
var u = e.getEdgeAtPoint(h.x, h.y);
|
|
1106
|
+
if (u) return e.emit("".concat(r, "Edge"), v(v({}, d), {}, {
|
|
1107
|
+
edge: u
|
|
1108
|
+
}));
|
|
1109
|
+
}
|
|
1110
|
+
return e.emit("".concat(r, "Stage"), d);
|
|
1111
|
+
};
|
|
1112
|
+
};
|
|
1113
|
+
return this.activeListeners.handleClick = t("click"), this.activeListeners.handleRightClick = t("rightClick"), this.activeListeners.handleDoubleClick = t("doubleClick"), this.activeListeners.handleWheel = t("wheel"), this.activeListeners.handleDown = t("down"), this.activeListeners.handleUp = t("up"), this.mouseCaptor.on("mousemove", this.activeListeners.handleMove), this.mouseCaptor.on("mousemovebody", this.activeListeners.handleMoveBody), this.mouseCaptor.on("click", this.activeListeners.handleClick), this.mouseCaptor.on("rightClick", this.activeListeners.handleRightClick), this.mouseCaptor.on("doubleClick", this.activeListeners.handleDoubleClick), this.mouseCaptor.on("wheel", this.activeListeners.handleWheel), this.mouseCaptor.on("mousedown", this.activeListeners.handleDown), this.mouseCaptor.on("mouseup", this.activeListeners.handleUp), this.mouseCaptor.on("mouseleave", this.activeListeners.handleLeave), this.mouseCaptor.on("mouseenter", this.activeListeners.handleEnter), this.touchCaptor.on("touchdown", this.activeListeners.handleDown), this.touchCaptor.on("touchdown", this.activeListeners.handleMove), this.touchCaptor.on("touchup", this.activeListeners.handleUp), this.touchCaptor.on("touchmove", this.activeListeners.handleMove), this.touchCaptor.on("tap", this.activeListeners.handleClick), this.touchCaptor.on("doubletap", this.activeListeners.handleDoubleClick), this.touchCaptor.on("touchmove", this.activeListeners.handleMoveBody), this;
|
|
1114
|
+
}
|
|
1115
|
+
/**
|
|
1116
|
+
* Method binding graph handlers
|
|
1117
|
+
*
|
|
1118
|
+
* @return {Sigma}
|
|
1119
|
+
*/
|
|
1120
|
+
}, {
|
|
1121
|
+
key: "bindGraphHandlers",
|
|
1122
|
+
value: function() {
|
|
1123
|
+
var e = this, t = this.graph, a = /* @__PURE__ */ new Set(["x", "y", "zIndex", "type"]);
|
|
1124
|
+
return this.activeListeners.eachNodeAttributesUpdatedGraphUpdate = function(r) {
|
|
1125
|
+
var o, h = (o = r.hints) === null || o === void 0 ? void 0 : o.attributes;
|
|
1126
|
+
e.graph.forEachNode(function(l) {
|
|
1127
|
+
return e.updateNode(l);
|
|
1128
|
+
});
|
|
1129
|
+
var d = !h || h.some(function(l) {
|
|
1130
|
+
return a.has(l);
|
|
1131
|
+
});
|
|
1132
|
+
e.refresh({
|
|
1133
|
+
partialGraph: {
|
|
1134
|
+
nodes: t.nodes()
|
|
1135
|
+
},
|
|
1136
|
+
skipIndexation: !d,
|
|
1137
|
+
schedule: !0
|
|
1138
|
+
});
|
|
1139
|
+
}, this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate = function(r) {
|
|
1140
|
+
var o, h = (o = r.hints) === null || o === void 0 ? void 0 : o.attributes;
|
|
1141
|
+
e.graph.forEachEdge(function(l) {
|
|
1142
|
+
return e.updateEdge(l);
|
|
1143
|
+
});
|
|
1144
|
+
var d = h && ["zIndex", "type"].some(function(l) {
|
|
1145
|
+
return h == null ? void 0 : h.includes(l);
|
|
1146
|
+
});
|
|
1147
|
+
e.refresh({
|
|
1148
|
+
partialGraph: {
|
|
1149
|
+
edges: t.edges()
|
|
1150
|
+
},
|
|
1151
|
+
skipIndexation: !d,
|
|
1152
|
+
schedule: !0
|
|
1153
|
+
});
|
|
1154
|
+
}, this.activeListeners.addNodeGraphUpdate = function(r) {
|
|
1155
|
+
var o = r.key;
|
|
1156
|
+
e.addNode(o), e.refresh({
|
|
1157
|
+
partialGraph: {
|
|
1158
|
+
nodes: [o]
|
|
1159
|
+
},
|
|
1160
|
+
skipIndexation: !1,
|
|
1161
|
+
schedule: !0
|
|
1162
|
+
});
|
|
1163
|
+
}, this.activeListeners.updateNodeGraphUpdate = function(r) {
|
|
1164
|
+
var o = r.key;
|
|
1165
|
+
e.refresh({
|
|
1166
|
+
partialGraph: {
|
|
1167
|
+
nodes: [o]
|
|
1168
|
+
},
|
|
1169
|
+
skipIndexation: !1,
|
|
1170
|
+
schedule: !0
|
|
1171
|
+
});
|
|
1172
|
+
}, this.activeListeners.dropNodeGraphUpdate = function(r) {
|
|
1173
|
+
var o = r.key;
|
|
1174
|
+
e.removeNode(o), e.refresh({
|
|
1175
|
+
schedule: !0
|
|
1176
|
+
});
|
|
1177
|
+
}, this.activeListeners.addEdgeGraphUpdate = function(r) {
|
|
1178
|
+
var o = r.key;
|
|
1179
|
+
e.addEdge(o), e.refresh({
|
|
1180
|
+
partialGraph: {
|
|
1181
|
+
edges: [o]
|
|
1182
|
+
},
|
|
1183
|
+
schedule: !0
|
|
1184
|
+
});
|
|
1185
|
+
}, this.activeListeners.updateEdgeGraphUpdate = function(r) {
|
|
1186
|
+
var o = r.key;
|
|
1187
|
+
e.refresh({
|
|
1188
|
+
partialGraph: {
|
|
1189
|
+
edges: [o]
|
|
1190
|
+
},
|
|
1191
|
+
skipIndexation: !1,
|
|
1192
|
+
schedule: !0
|
|
1193
|
+
});
|
|
1194
|
+
}, this.activeListeners.dropEdgeGraphUpdate = function(r) {
|
|
1195
|
+
var o = r.key;
|
|
1196
|
+
e.removeEdge(o), e.refresh({
|
|
1197
|
+
schedule: !0
|
|
1198
|
+
});
|
|
1199
|
+
}, this.activeListeners.clearEdgesGraphUpdate = function() {
|
|
1200
|
+
e.clearEdgeState(), e.clearEdgeIndices(), e.refresh({
|
|
1201
|
+
schedule: !0
|
|
1202
|
+
});
|
|
1203
|
+
}, this.activeListeners.clearGraphUpdate = function() {
|
|
1204
|
+
e.clearEdgeState(), e.clearNodeState(), e.clearEdgeIndices(), e.clearNodeIndices(), e.refresh({
|
|
1205
|
+
schedule: !0
|
|
1206
|
+
});
|
|
1207
|
+
}, t.on("nodeAdded", this.activeListeners.addNodeGraphUpdate), t.on("nodeDropped", this.activeListeners.dropNodeGraphUpdate), t.on("nodeAttributesUpdated", this.activeListeners.updateNodeGraphUpdate), t.on("eachNodeAttributesUpdated", this.activeListeners.eachNodeAttributesUpdatedGraphUpdate), t.on("edgeAdded", this.activeListeners.addEdgeGraphUpdate), t.on("edgeDropped", this.activeListeners.dropEdgeGraphUpdate), t.on("edgeAttributesUpdated", this.activeListeners.updateEdgeGraphUpdate), t.on("eachEdgeAttributesUpdated", this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate), t.on("edgesCleared", this.activeListeners.clearEdgesGraphUpdate), t.on("cleared", this.activeListeners.clearGraphUpdate), this;
|
|
1208
|
+
}
|
|
1209
|
+
/**
|
|
1210
|
+
* Method used to unbind handlers from the graph.
|
|
1211
|
+
*
|
|
1212
|
+
* @return {undefined}
|
|
1213
|
+
*/
|
|
1214
|
+
}, {
|
|
1215
|
+
key: "unbindGraphHandlers",
|
|
1216
|
+
value: function() {
|
|
1217
|
+
var e = this.graph;
|
|
1218
|
+
e.removeListener("nodeAdded", this.activeListeners.addNodeGraphUpdate), e.removeListener("nodeDropped", this.activeListeners.dropNodeGraphUpdate), e.removeListener("nodeAttributesUpdated", this.activeListeners.updateNodeGraphUpdate), e.removeListener("eachNodeAttributesUpdated", this.activeListeners.eachNodeAttributesUpdatedGraphUpdate), e.removeListener("edgeAdded", this.activeListeners.addEdgeGraphUpdate), e.removeListener("edgeDropped", this.activeListeners.dropEdgeGraphUpdate), e.removeListener("edgeAttributesUpdated", this.activeListeners.updateEdgeGraphUpdate), e.removeListener("eachEdgeAttributesUpdated", this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate), e.removeListener("edgesCleared", this.activeListeners.clearEdgesGraphUpdate), e.removeListener("cleared", this.activeListeners.clearGraphUpdate);
|
|
1219
|
+
}
|
|
1220
|
+
/**
|
|
1221
|
+
* Method looking for an edge colliding with a given point at (x, y). Returns
|
|
1222
|
+
* the key of the edge if any, or null else.
|
|
1223
|
+
*/
|
|
1224
|
+
}, {
|
|
1225
|
+
key: "getEdgeAtPoint",
|
|
1226
|
+
value: function(e, t) {
|
|
1227
|
+
var a = ge(this.webGLContexts.edges, this.frameBuffers.edges, e, t, this.pixelRatio, this.pickingDownSizingRatio), r = ve.apply(void 0, Ee(a)), o = this.itemIDsIndex[r];
|
|
1228
|
+
return o && o.type === "edge" ? o.id : null;
|
|
1229
|
+
}
|
|
1230
|
+
/**
|
|
1231
|
+
* Method used to process the whole graph's data.
|
|
1232
|
+
* - extent
|
|
1233
|
+
* - normalizationFunction
|
|
1234
|
+
* - compute node's coordinate
|
|
1235
|
+
* - labelgrid
|
|
1236
|
+
* - program data allocation
|
|
1237
|
+
* @return {Sigma}
|
|
1238
|
+
*/
|
|
1239
|
+
}, {
|
|
1240
|
+
key: "process",
|
|
1241
|
+
value: function() {
|
|
1242
|
+
var e = this;
|
|
1243
|
+
this.emit("beforeProcess");
|
|
1244
|
+
var t = this.graph, a = this.settings, r = this.getDimensions();
|
|
1245
|
+
if (this.nodeExtent = et(this.graph), !this.settings.autoRescale) {
|
|
1246
|
+
var o = r.width, h = r.height, d = this.nodeExtent, l = d.x, u = d.y;
|
|
1247
|
+
this.nodeExtent = {
|
|
1248
|
+
x: [(l[0] + l[1]) / 2 - o / 2, (l[0] + l[1]) / 2 + o / 2],
|
|
1249
|
+
y: [(u[0] + u[1]) / 2 - h / 2, (u[0] + u[1]) / 2 + h / 2]
|
|
1250
|
+
};
|
|
1251
|
+
}
|
|
1252
|
+
this.normalizationFunction = be(this.customBBox || this.nodeExtent);
|
|
1253
|
+
var g = new Ce(), f = X(g.getState(), r, this.getGraphDimensions(), this.getStagePadding());
|
|
1254
|
+
this.labelGrid.resizeAndClear(r, a.labelGridCellSize);
|
|
1255
|
+
for (var m = {}, p = {}, y = {}, E = {}, b = 1, x = t.nodes(), C = 0, I = x.length; C < I; C++) {
|
|
1256
|
+
var A = x[C], w = this.nodeDataCache[A], k = t.getNodeAttributes(A);
|
|
1257
|
+
w.x = k.x, w.y = k.y, this.normalizationFunction.applyTo(w), typeof w.label == "string" && !w.hidden && this.labelGrid.add(A, w.size, this.framedGraphToViewport(w, {
|
|
1258
|
+
matrix: f
|
|
1259
|
+
})), m[w.type] = (m[w.type] || 0) + 1;
|
|
1260
|
+
}
|
|
1261
|
+
this.labelGrid.organize();
|
|
1262
|
+
for (var T in this.nodePrograms) {
|
|
1263
|
+
if (!z.call(this.nodePrograms, T))
|
|
1264
|
+
throw new Error('Sigma: could not find a suitable program for node type "'.concat(T, '"!'));
|
|
1265
|
+
this.nodePrograms[T].reallocate(m[T] || 0), m[T] = 0;
|
|
1266
|
+
}
|
|
1267
|
+
this.settings.zIndex && this.nodeZExtent[0] !== this.nodeZExtent[1] && (x = ye(this.nodeZExtent, function(re) {
|
|
1268
|
+
return e.nodeDataCache[re].zIndex;
|
|
1269
|
+
}, x));
|
|
1270
|
+
for (var L = 0, D = x.length; L < D; L++) {
|
|
1271
|
+
var S = x[L];
|
|
1272
|
+
p[S] = b, E[p[S]] = {
|
|
1273
|
+
type: "node",
|
|
1274
|
+
id: S
|
|
1275
|
+
}, b++;
|
|
1276
|
+
var _ = this.nodeDataCache[S];
|
|
1277
|
+
this.addNodeToProgram(S, p[S], m[_.type]++);
|
|
1278
|
+
}
|
|
1279
|
+
for (var P = {}, R = t.edges(), U = 0, $ = R.length; U < $; U++) {
|
|
1280
|
+
var q = R[U], V = this.edgeDataCache[q];
|
|
1281
|
+
P[V.type] = (P[V.type] || 0) + 1;
|
|
1282
|
+
}
|
|
1283
|
+
this.settings.zIndex && this.edgeZExtent[0] !== this.edgeZExtent[1] && (R = ye(this.edgeZExtent, function(re) {
|
|
1284
|
+
return e.edgeDataCache[re].zIndex;
|
|
1285
|
+
}, R));
|
|
1286
|
+
for (var H in this.edgePrograms) {
|
|
1287
|
+
if (!z.call(this.edgePrograms, H))
|
|
1288
|
+
throw new Error('Sigma: could not find a suitable program for edge type "'.concat(H, '"!'));
|
|
1289
|
+
this.edgePrograms[H].reallocate(P[H] || 0), P[H] = 0;
|
|
1290
|
+
}
|
|
1291
|
+
for (var B = 0, ae = R.length; B < ae; B++) {
|
|
1292
|
+
var G = R[B];
|
|
1293
|
+
y[G] = b, E[y[G]] = {
|
|
1294
|
+
type: "edge",
|
|
1295
|
+
id: G
|
|
1296
|
+
}, b++;
|
|
1297
|
+
var ke = this.edgeDataCache[G];
|
|
1298
|
+
this.addEdgeToProgram(G, y[G], P[ke.type]++);
|
|
1299
|
+
}
|
|
1300
|
+
return this.itemIDsIndex = E, this.nodeIndices = p, this.edgeIndices = y, this.emit("afterProcess"), this;
|
|
1301
|
+
}
|
|
1302
|
+
/**
|
|
1303
|
+
* Method that backports potential settings updates where it's needed.
|
|
1304
|
+
* @private
|
|
1305
|
+
*/
|
|
1306
|
+
}, {
|
|
1307
|
+
key: "handleSettingsUpdate",
|
|
1308
|
+
value: function(e) {
|
|
1309
|
+
var t = this, a = this.settings;
|
|
1310
|
+
if (this.camera.minRatio = a.minCameraRatio, this.camera.maxRatio = a.maxCameraRatio, this.camera.enabledZooming = a.enableCameraZooming, this.camera.enabledPanning = a.enableCameraPanning, this.camera.enabledRotation = a.enableCameraRotation, a.cameraPanBoundaries ? this.camera.clean = function(l) {
|
|
1311
|
+
return t.cleanCameraState(l, a.cameraPanBoundaries && le(a.cameraPanBoundaries) === "object" ? a.cameraPanBoundaries : {});
|
|
1312
|
+
} : this.camera.clean = null, this.camera.setState(this.camera.validateState(this.camera.getState())), e) {
|
|
1313
|
+
if (e.edgeProgramClasses !== a.edgeProgramClasses) {
|
|
1314
|
+
for (var r in a.edgeProgramClasses)
|
|
1315
|
+
a.edgeProgramClasses[r] !== e.edgeProgramClasses[r] && this.registerEdgeProgram(r, a.edgeProgramClasses[r]);
|
|
1316
|
+
for (var o in e.edgeProgramClasses)
|
|
1317
|
+
a.edgeProgramClasses[o] || this.unregisterEdgeProgram(o);
|
|
1318
|
+
}
|
|
1319
|
+
if (e.nodeProgramClasses !== a.nodeProgramClasses || e.nodeHoverProgramClasses !== a.nodeHoverProgramClasses) {
|
|
1320
|
+
for (var h in a.nodeProgramClasses)
|
|
1321
|
+
(a.nodeProgramClasses[h] !== e.nodeProgramClasses[h] || a.nodeHoverProgramClasses[h] !== e.nodeHoverProgramClasses[h]) && this.registerNodeProgram(h, a.nodeProgramClasses[h], a.nodeHoverProgramClasses[h]);
|
|
1322
|
+
for (var d in e.nodeProgramClasses)
|
|
1323
|
+
a.nodeProgramClasses[d] || this.unregisterNodeProgram(d);
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
return this.mouseCaptor.setSettings(this.settings), this.touchCaptor.setSettings(this.settings), this;
|
|
1327
|
+
}
|
|
1328
|
+
}, {
|
|
1329
|
+
key: "cleanCameraState",
|
|
1330
|
+
value: function(e) {
|
|
1331
|
+
var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, a = t.tolerance, r = a === void 0 ? 0 : a, o = t.boundaries, h = v({}, e), d = o || this.nodeExtent, l = Q(d.x, 2), u = l[0], g = l[1], f = Q(d.y, 2), m = f[0], p = f[1], y = [this.graphToViewport({
|
|
1332
|
+
x: u,
|
|
1333
|
+
y: m
|
|
1334
|
+
}, {
|
|
1335
|
+
cameraState: e
|
|
1336
|
+
}), this.graphToViewport({
|
|
1337
|
+
x: g,
|
|
1338
|
+
y: m
|
|
1339
|
+
}, {
|
|
1340
|
+
cameraState: e
|
|
1341
|
+
}), this.graphToViewport({
|
|
1342
|
+
x: u,
|
|
1343
|
+
y: p
|
|
1344
|
+
}, {
|
|
1345
|
+
cameraState: e
|
|
1346
|
+
}), this.graphToViewport({
|
|
1347
|
+
x: g,
|
|
1348
|
+
y: p
|
|
1349
|
+
}, {
|
|
1350
|
+
cameraState: e
|
|
1351
|
+
})], E = 1 / 0, b = -1 / 0, x = 1 / 0, C = -1 / 0;
|
|
1352
|
+
y.forEach(function(P) {
|
|
1353
|
+
var R = P.x, U = P.y;
|
|
1354
|
+
E = Math.min(E, R), b = Math.max(b, R), x = Math.min(x, U), C = Math.max(C, U);
|
|
1355
|
+
});
|
|
1356
|
+
var I = b - E, A = C - x, w = this.getDimensions(), k = w.width, T = w.height, L = 0, D = 0;
|
|
1357
|
+
if (I >= k ? b < k - r ? L = b - (k - r) : E > r && (L = E - r) : b > k + r ? L = b - (k + r) : E < -r && (L = E + r), A >= T ? C < T - r ? D = C - (T - r) : x > r && (D = x - r) : C > T + r ? D = C - (T + r) : x < -r && (D = x + r), L || D) {
|
|
1358
|
+
var S = this.viewportToFramedGraph({
|
|
1359
|
+
x: 0,
|
|
1360
|
+
y: 0
|
|
1361
|
+
}, {
|
|
1362
|
+
cameraState: e
|
|
1363
|
+
}), _ = this.viewportToFramedGraph({
|
|
1364
|
+
x: L,
|
|
1365
|
+
y: D
|
|
1366
|
+
}, {
|
|
1367
|
+
cameraState: e
|
|
1368
|
+
});
|
|
1369
|
+
L = _.x - S.x, D = _.y - S.y, h.x += L, h.y += D;
|
|
1370
|
+
}
|
|
1371
|
+
return h;
|
|
1372
|
+
}
|
|
1373
|
+
/**
|
|
1374
|
+
* Method used to render labels.
|
|
1375
|
+
*
|
|
1376
|
+
* @return {Sigma}
|
|
1377
|
+
*/
|
|
1378
|
+
}, {
|
|
1379
|
+
key: "renderLabels",
|
|
1380
|
+
value: function() {
|
|
1381
|
+
if (!this.settings.renderLabels) return this;
|
|
1382
|
+
var e = this.camera.getState(), t = this.labelGrid.getLabelsToDisplay(e.ratio, this.settings.labelDensity);
|
|
1383
|
+
xe(t, this.nodesWithForcedLabels), this.displayedNodeLabels = /* @__PURE__ */ new Set();
|
|
1384
|
+
for (var a = this.canvasContexts.labels, r = 0, o = t.length; r < o; r++) {
|
|
1385
|
+
var h = t[r], d = this.nodeDataCache[h];
|
|
1386
|
+
if (!this.displayedNodeLabels.has(h) && !d.hidden) {
|
|
1387
|
+
var l = this.framedGraphToViewport(d), u = l.x, g = l.y, f = this.scaleSize(d.size);
|
|
1388
|
+
if (!(!d.forceLabel && f < this.settings.labelRenderedSizeThreshold) && !(u < -Se || u > this.width + Se || g < -Pe || g > this.height + Pe)) {
|
|
1389
|
+
this.displayedNodeLabels.add(h);
|
|
1390
|
+
var m = this.settings.defaultDrawNodeLabel, p = this.nodePrograms[d.type], y = (p == null ? void 0 : p.drawLabel) || m;
|
|
1391
|
+
y(a, v(v({
|
|
1392
|
+
key: h
|
|
1393
|
+
}, d), {}, {
|
|
1394
|
+
size: f,
|
|
1395
|
+
x: u,
|
|
1396
|
+
y: g
|
|
1397
|
+
}), this.settings);
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
return this;
|
|
1402
|
+
}
|
|
1403
|
+
/**
|
|
1404
|
+
* Method used to render edge labels, based on which node labels were
|
|
1405
|
+
* rendered.
|
|
1406
|
+
*
|
|
1407
|
+
* @return {Sigma}
|
|
1408
|
+
*/
|
|
1409
|
+
}, {
|
|
1410
|
+
key: "renderEdgeLabels",
|
|
1411
|
+
value: function() {
|
|
1412
|
+
if (!this.settings.renderEdgeLabels) return this;
|
|
1413
|
+
var e = this.canvasContexts.edgeLabels;
|
|
1414
|
+
e.clearRect(0, 0, this.width, this.height);
|
|
1415
|
+
var t = yt({
|
|
1416
|
+
graph: this.graph,
|
|
1417
|
+
hoveredNode: this.hoveredNode,
|
|
1418
|
+
displayedNodeLabels: this.displayedNodeLabels,
|
|
1419
|
+
highlightedNodes: this.highlightedNodes
|
|
1420
|
+
});
|
|
1421
|
+
xe(t, this.edgesWithForcedLabels);
|
|
1422
|
+
for (var a = /* @__PURE__ */ new Set(), r = 0, o = t.length; r < o; r++) {
|
|
1423
|
+
var h = t[r], d = this.graph.extremities(h), l = this.nodeDataCache[d[0]], u = this.nodeDataCache[d[1]], g = this.edgeDataCache[h];
|
|
1424
|
+
if (!a.has(h) && !(g.hidden || l.hidden || u.hidden)) {
|
|
1425
|
+
var f = this.settings.defaultDrawEdgeLabel, m = this.edgePrograms[g.type], p = (m == null ? void 0 : m.drawLabel) || f;
|
|
1426
|
+
p(e, v(v({
|
|
1427
|
+
key: h
|
|
1428
|
+
}, g), {}, {
|
|
1429
|
+
size: this.scaleSize(g.size)
|
|
1430
|
+
}), v(v(v({
|
|
1431
|
+
key: d[0]
|
|
1432
|
+
}, l), this.framedGraphToViewport(l)), {}, {
|
|
1433
|
+
size: this.scaleSize(l.size)
|
|
1434
|
+
}), v(v(v({
|
|
1435
|
+
key: d[1]
|
|
1436
|
+
}, u), this.framedGraphToViewport(u)), {}, {
|
|
1437
|
+
size: this.scaleSize(u.size)
|
|
1438
|
+
}), this.settings), a.add(h);
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1441
|
+
return this.displayedEdgeLabels = a, this;
|
|
1442
|
+
}
|
|
1443
|
+
/**
|
|
1444
|
+
* Method used to render the highlighted nodes.
|
|
1445
|
+
*
|
|
1446
|
+
* @return {Sigma}
|
|
1447
|
+
*/
|
|
1448
|
+
}, {
|
|
1449
|
+
key: "renderHighlightedNodes",
|
|
1450
|
+
value: function() {
|
|
1451
|
+
var e = this, t = this.canvasContexts.hovers;
|
|
1452
|
+
t.clearRect(0, 0, this.width, this.height);
|
|
1453
|
+
var a = function(f) {
|
|
1454
|
+
var m = e.nodeDataCache[f], p = e.framedGraphToViewport(m), y = p.x, E = p.y, b = e.scaleSize(m.size), x = e.settings.defaultDrawNodeHover, C = e.nodePrograms[m.type], I = (C == null ? void 0 : C.drawHover) || x;
|
|
1455
|
+
I(t, v(v({
|
|
1456
|
+
key: f
|
|
1457
|
+
}, m), {}, {
|
|
1458
|
+
size: b,
|
|
1459
|
+
x: y,
|
|
1460
|
+
y: E
|
|
1461
|
+
}), e.settings);
|
|
1462
|
+
}, r = [];
|
|
1463
|
+
this.hoveredNode && !this.nodeDataCache[this.hoveredNode].hidden && r.push(this.hoveredNode), this.highlightedNodes.forEach(function(g) {
|
|
1464
|
+
g !== e.hoveredNode && r.push(g);
|
|
1465
|
+
}), r.forEach(function(g) {
|
|
1466
|
+
return a(g);
|
|
1467
|
+
});
|
|
1468
|
+
var o = {};
|
|
1469
|
+
r.forEach(function(g) {
|
|
1470
|
+
var f = e.nodeDataCache[g].type;
|
|
1471
|
+
o[f] = (o[f] || 0) + 1;
|
|
1472
|
+
});
|
|
1473
|
+
for (var h in this.nodeHoverPrograms)
|
|
1474
|
+
this.nodeHoverPrograms[h].reallocate(o[h] || 0), o[h] = 0;
|
|
1475
|
+
r.forEach(function(g) {
|
|
1476
|
+
var f = e.nodeDataCache[g];
|
|
1477
|
+
e.nodeHoverPrograms[f.type].process(0, o[f.type]++, f);
|
|
1478
|
+
}), this.webGLContexts.hoverNodes.clear(this.webGLContexts.hoverNodes.COLOR_BUFFER_BIT);
|
|
1479
|
+
var d = this.getRenderParams();
|
|
1480
|
+
for (var l in this.nodeHoverPrograms) {
|
|
1481
|
+
var u = this.nodeHoverPrograms[l];
|
|
1482
|
+
u.render(d);
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
/**
|
|
1486
|
+
* Method used to schedule a hover render.
|
|
1487
|
+
*
|
|
1488
|
+
*/
|
|
1489
|
+
}, {
|
|
1490
|
+
key: "scheduleHighlightedNodesRender",
|
|
1491
|
+
value: function() {
|
|
1492
|
+
var e = this;
|
|
1493
|
+
this.renderHighlightedNodesFrame || this.renderFrame || (this.renderHighlightedNodesFrame = requestAnimationFrame(function() {
|
|
1494
|
+
e.renderHighlightedNodesFrame = null, e.renderHighlightedNodes(), e.renderEdgeLabels();
|
|
1495
|
+
}));
|
|
1496
|
+
}
|
|
1497
|
+
/**
|
|
1498
|
+
* Method used to render.
|
|
1499
|
+
*
|
|
1500
|
+
* @return {Sigma}
|
|
1501
|
+
*/
|
|
1502
|
+
}, {
|
|
1503
|
+
key: "render",
|
|
1504
|
+
value: function() {
|
|
1505
|
+
var e = this;
|
|
1506
|
+
this.emit("beforeRender");
|
|
1507
|
+
var t = function() {
|
|
1508
|
+
return e.emit("afterRender"), e;
|
|
1509
|
+
};
|
|
1510
|
+
if (this.renderFrame && (cancelAnimationFrame(this.renderFrame), this.renderFrame = null), this.resize(), this.needToProcess && this.process(), this.needToProcess = !1, this.clear(), this.pickingLayers.forEach(function(y) {
|
|
1511
|
+
return e.resetWebGLTexture(y);
|
|
1512
|
+
}), !this.graph.order) return t();
|
|
1513
|
+
var a = this.mouseCaptor, r = this.camera.isAnimated() || a.isMoving || a.draggedEvents || a.currentWheelDirection, o = this.camera.getState(), h = this.getDimensions(), d = this.getGraphDimensions(), l = this.getStagePadding();
|
|
1514
|
+
this.matrix = X(o, h, d, l), this.invMatrix = X(o, h, d, l, !0), this.correctionRatio = $e(this.matrix, o, h), this.graphToViewportRatio = this.getGraphToViewportRatio();
|
|
1515
|
+
var u = this.getRenderParams();
|
|
1516
|
+
for (var g in this.nodePrograms) {
|
|
1517
|
+
var f = this.nodePrograms[g];
|
|
1518
|
+
f.render(u);
|
|
1519
|
+
}
|
|
1520
|
+
if (!this.settings.hideEdgesOnMove || !r)
|
|
1521
|
+
for (var m in this.edgePrograms) {
|
|
1522
|
+
var p = this.edgePrograms[m];
|
|
1523
|
+
p.render(u);
|
|
1524
|
+
}
|
|
1525
|
+
return this.settings.hideLabelsOnMove && r || (this.renderLabels(), this.renderEdgeLabels(), this.renderHighlightedNodes()), t();
|
|
1526
|
+
}
|
|
1527
|
+
/**
|
|
1528
|
+
* Add a node in the internal data structures.
|
|
1529
|
+
* @private
|
|
1530
|
+
* @param key The node's graphology ID
|
|
1531
|
+
*/
|
|
1532
|
+
}, {
|
|
1533
|
+
key: "addNode",
|
|
1534
|
+
value: function(e) {
|
|
1535
|
+
var t = Object.assign({}, this.graph.getNodeAttributes(e));
|
|
1536
|
+
this.settings.nodeReducer && (t = this.settings.nodeReducer(e, t));
|
|
1537
|
+
var a = bt(this.settings, e, t);
|
|
1538
|
+
this.nodeDataCache[e] = a, this.nodesWithForcedLabels.delete(e), a.forceLabel && !a.hidden && this.nodesWithForcedLabels.add(e), this.highlightedNodes.delete(e), a.highlighted && !a.hidden && this.highlightedNodes.add(e), this.settings.zIndex && (a.zIndex < this.nodeZExtent[0] && (this.nodeZExtent[0] = a.zIndex), a.zIndex > this.nodeZExtent[1] && (this.nodeZExtent[1] = a.zIndex));
|
|
1539
|
+
}
|
|
1540
|
+
/**
|
|
1541
|
+
* Update a node the internal data structures.
|
|
1542
|
+
* @private
|
|
1543
|
+
* @param key The node's graphology ID
|
|
1544
|
+
*/
|
|
1545
|
+
}, {
|
|
1546
|
+
key: "updateNode",
|
|
1547
|
+
value: function(e) {
|
|
1548
|
+
this.addNode(e);
|
|
1549
|
+
var t = this.nodeDataCache[e];
|
|
1550
|
+
this.normalizationFunction.applyTo(t);
|
|
1551
|
+
}
|
|
1552
|
+
/**
|
|
1553
|
+
* Remove a node from the internal data structures.
|
|
1554
|
+
* @private
|
|
1555
|
+
* @param key The node's graphology ID
|
|
1556
|
+
*/
|
|
1557
|
+
}, {
|
|
1558
|
+
key: "removeNode",
|
|
1559
|
+
value: function(e) {
|
|
1560
|
+
delete this.nodeDataCache[e], delete this.nodeProgramIndex[e], this.highlightedNodes.delete(e), this.hoveredNode === e && (this.hoveredNode = null), this.nodesWithForcedLabels.delete(e);
|
|
1561
|
+
}
|
|
1562
|
+
/**
|
|
1563
|
+
* Add an edge into the internal data structures.
|
|
1564
|
+
* @private
|
|
1565
|
+
* @param key The edge's graphology ID
|
|
1566
|
+
*/
|
|
1567
|
+
}, {
|
|
1568
|
+
key: "addEdge",
|
|
1569
|
+
value: function(e) {
|
|
1570
|
+
var t = Object.assign({}, this.graph.getEdgeAttributes(e));
|
|
1571
|
+
this.settings.edgeReducer && (t = this.settings.edgeReducer(e, t));
|
|
1572
|
+
var a = xt(this.settings, e, t);
|
|
1573
|
+
this.edgeDataCache[e] = a, this.edgesWithForcedLabels.delete(e), a.forceLabel && !a.hidden && this.edgesWithForcedLabels.add(e), this.settings.zIndex && (a.zIndex < this.edgeZExtent[0] && (this.edgeZExtent[0] = a.zIndex), a.zIndex > this.edgeZExtent[1] && (this.edgeZExtent[1] = a.zIndex));
|
|
1574
|
+
}
|
|
1575
|
+
/**
|
|
1576
|
+
* Update an edge in the internal data structures.
|
|
1577
|
+
* @private
|
|
1578
|
+
* @param key The edge's graphology ID
|
|
1579
|
+
*/
|
|
1580
|
+
}, {
|
|
1581
|
+
key: "updateEdge",
|
|
1582
|
+
value: function(e) {
|
|
1583
|
+
this.addEdge(e);
|
|
1584
|
+
}
|
|
1585
|
+
/**
|
|
1586
|
+
* Remove an edge from the internal data structures.
|
|
1587
|
+
* @private
|
|
1588
|
+
* @param key The edge's graphology ID
|
|
1589
|
+
*/
|
|
1590
|
+
}, {
|
|
1591
|
+
key: "removeEdge",
|
|
1592
|
+
value: function(e) {
|
|
1593
|
+
delete this.edgeDataCache[e], delete this.edgeProgramIndex[e], this.hoveredEdge === e && (this.hoveredEdge = null), this.edgesWithForcedLabels.delete(e);
|
|
1594
|
+
}
|
|
1595
|
+
/**
|
|
1596
|
+
* Clear all indices related to nodes.
|
|
1597
|
+
* @private
|
|
1598
|
+
*/
|
|
1599
|
+
}, {
|
|
1600
|
+
key: "clearNodeIndices",
|
|
1601
|
+
value: function() {
|
|
1602
|
+
this.labelGrid = new Le(), this.nodeExtent = {
|
|
1603
|
+
x: [0, 1],
|
|
1604
|
+
y: [0, 1]
|
|
1605
|
+
}, this.nodeDataCache = {}, this.edgeProgramIndex = {}, this.nodesWithForcedLabels = /* @__PURE__ */ new Set(), this.nodeZExtent = [1 / 0, -1 / 0], this.highlightedNodes = /* @__PURE__ */ new Set();
|
|
1606
|
+
}
|
|
1607
|
+
/**
|
|
1608
|
+
* Clear all indices related to edges.
|
|
1609
|
+
* @private
|
|
1610
|
+
*/
|
|
1611
|
+
}, {
|
|
1612
|
+
key: "clearEdgeIndices",
|
|
1613
|
+
value: function() {
|
|
1614
|
+
this.edgeDataCache = {}, this.edgeProgramIndex = {}, this.edgesWithForcedLabels = /* @__PURE__ */ new Set(), this.edgeZExtent = [1 / 0, -1 / 0];
|
|
1615
|
+
}
|
|
1616
|
+
/**
|
|
1617
|
+
* Clear all indices.
|
|
1618
|
+
* @private
|
|
1619
|
+
*/
|
|
1620
|
+
}, {
|
|
1621
|
+
key: "clearIndices",
|
|
1622
|
+
value: function() {
|
|
1623
|
+
this.clearEdgeIndices(), this.clearNodeIndices();
|
|
1624
|
+
}
|
|
1625
|
+
/**
|
|
1626
|
+
* Clear all graph state related to nodes.
|
|
1627
|
+
* @private
|
|
1628
|
+
*/
|
|
1629
|
+
}, {
|
|
1630
|
+
key: "clearNodeState",
|
|
1631
|
+
value: function() {
|
|
1632
|
+
this.displayedNodeLabels = /* @__PURE__ */ new Set(), this.highlightedNodes = /* @__PURE__ */ new Set(), this.hoveredNode = null;
|
|
1633
|
+
}
|
|
1634
|
+
/**
|
|
1635
|
+
* Clear all graph state related to edges.
|
|
1636
|
+
* @private
|
|
1637
|
+
*/
|
|
1638
|
+
}, {
|
|
1639
|
+
key: "clearEdgeState",
|
|
1640
|
+
value: function() {
|
|
1641
|
+
this.displayedEdgeLabels = /* @__PURE__ */ new Set(), this.highlightedNodes = /* @__PURE__ */ new Set(), this.hoveredEdge = null;
|
|
1642
|
+
}
|
|
1643
|
+
/**
|
|
1644
|
+
* Clear all graph state.
|
|
1645
|
+
* @private
|
|
1646
|
+
*/
|
|
1647
|
+
}, {
|
|
1648
|
+
key: "clearState",
|
|
1649
|
+
value: function() {
|
|
1650
|
+
this.clearEdgeState(), this.clearNodeState();
|
|
1651
|
+
}
|
|
1652
|
+
/**
|
|
1653
|
+
* Add the node data to its program.
|
|
1654
|
+
* @private
|
|
1655
|
+
* @param node The node's graphology ID
|
|
1656
|
+
* @param fingerprint A fingerprint used to identity the node with picking
|
|
1657
|
+
* @param position The index where to place the node in the program
|
|
1658
|
+
*/
|
|
1659
|
+
}, {
|
|
1660
|
+
key: "addNodeToProgram",
|
|
1661
|
+
value: function(e, t, a) {
|
|
1662
|
+
var r = this.nodeDataCache[e], o = this.nodePrograms[r.type];
|
|
1663
|
+
if (!o) throw new Error('Sigma: could not find a suitable program for node type "'.concat(r.type, '"!'));
|
|
1664
|
+
o.process(t, a, r), this.nodeProgramIndex[e] = a;
|
|
1665
|
+
}
|
|
1666
|
+
/**
|
|
1667
|
+
* Add the edge data to its program.
|
|
1668
|
+
* @private
|
|
1669
|
+
* @param edge The edge's graphology ID
|
|
1670
|
+
* @param fingerprint A fingerprint used to identity the edge with picking
|
|
1671
|
+
* @param position The index where to place the edge in the program
|
|
1672
|
+
*/
|
|
1673
|
+
}, {
|
|
1674
|
+
key: "addEdgeToProgram",
|
|
1675
|
+
value: function(e, t, a) {
|
|
1676
|
+
var r = this.edgeDataCache[e], o = this.edgePrograms[r.type];
|
|
1677
|
+
if (!o) throw new Error('Sigma: could not find a suitable program for edge type "'.concat(r.type, '"!'));
|
|
1678
|
+
var h = this.graph.extremities(e), d = this.nodeDataCache[h[0]], l = this.nodeDataCache[h[1]];
|
|
1679
|
+
o.process(t, a, d, l, r), this.edgeProgramIndex[e] = a;
|
|
1680
|
+
}
|
|
1681
|
+
/**---------------------------------------------------------------------------
|
|
1682
|
+
* Public API.
|
|
1683
|
+
**---------------------------------------------------------------------------
|
|
1684
|
+
*/
|
|
1685
|
+
/**
|
|
1686
|
+
* Function used to get the render params.
|
|
1687
|
+
*
|
|
1688
|
+
* @return {RenderParams}
|
|
1689
|
+
*/
|
|
1690
|
+
}, {
|
|
1691
|
+
key: "getRenderParams",
|
|
1692
|
+
value: function() {
|
|
1693
|
+
return {
|
|
1694
|
+
matrix: this.matrix,
|
|
1695
|
+
invMatrix: this.invMatrix,
|
|
1696
|
+
width: this.width,
|
|
1697
|
+
height: this.height,
|
|
1698
|
+
pixelRatio: this.pixelRatio,
|
|
1699
|
+
zoomRatio: this.camera.ratio,
|
|
1700
|
+
cameraAngle: this.camera.angle,
|
|
1701
|
+
sizeRatio: 1 / this.scaleSize(),
|
|
1702
|
+
correctionRatio: this.correctionRatio,
|
|
1703
|
+
downSizingRatio: this.pickingDownSizingRatio,
|
|
1704
|
+
minEdgeThickness: this.settings.minEdgeThickness,
|
|
1705
|
+
antiAliasingFeather: this.settings.antiAliasingFeather
|
|
1706
|
+
};
|
|
1707
|
+
}
|
|
1708
|
+
/**
|
|
1709
|
+
* Function used to retrieve the actual stage padding value.
|
|
1710
|
+
*
|
|
1711
|
+
* @return {number}
|
|
1712
|
+
*/
|
|
1713
|
+
}, {
|
|
1714
|
+
key: "getStagePadding",
|
|
1715
|
+
value: function() {
|
|
1716
|
+
var e = this.settings, t = e.stagePadding, a = e.autoRescale;
|
|
1717
|
+
return a && t || 0;
|
|
1718
|
+
}
|
|
1719
|
+
/**
|
|
1720
|
+
* Function used to create a layer element.
|
|
1721
|
+
*
|
|
1722
|
+
* @param {string} id - Context's id.
|
|
1723
|
+
* @param {string} tag - The HTML tag to use.
|
|
1724
|
+
* @param options
|
|
1725
|
+
* @return {Sigma}
|
|
1726
|
+
*/
|
|
1727
|
+
}, {
|
|
1728
|
+
key: "createLayer",
|
|
1729
|
+
value: function(e, t) {
|
|
1730
|
+
var a = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
1731
|
+
if (this.elements[e]) throw new Error('Sigma: a layer named "'.concat(e, '" already exists'));
|
|
1732
|
+
var r = it(t, {
|
|
1733
|
+
position: "absolute"
|
|
1734
|
+
}, {
|
|
1735
|
+
class: "sigma-".concat(e)
|
|
1736
|
+
});
|
|
1737
|
+
return a.style && Object.assign(r.style, a.style), this.elements[e] = r, "beforeLayer" in a && a.beforeLayer ? this.elements[a.beforeLayer].before(r) : "afterLayer" in a && a.afterLayer ? this.elements[a.afterLayer].after(r) : this.container.appendChild(r), r;
|
|
1738
|
+
}
|
|
1739
|
+
/**
|
|
1740
|
+
* Function used to create a canvas element.
|
|
1741
|
+
*
|
|
1742
|
+
* @param {string} id - Context's id.
|
|
1743
|
+
* @param options
|
|
1744
|
+
* @return {Sigma}
|
|
1745
|
+
*/
|
|
1746
|
+
}, {
|
|
1747
|
+
key: "createCanvas",
|
|
1748
|
+
value: function(e) {
|
|
1749
|
+
var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
1750
|
+
return this.createLayer(e, "canvas", t);
|
|
1751
|
+
}
|
|
1752
|
+
/**
|
|
1753
|
+
* Function used to create a canvas context and add the relevant DOM elements.
|
|
1754
|
+
*
|
|
1755
|
+
* @param {string} id - Context's id.
|
|
1756
|
+
* @param options
|
|
1757
|
+
* @return {Sigma}
|
|
1758
|
+
*/
|
|
1759
|
+
}, {
|
|
1760
|
+
key: "createCanvasContext",
|
|
1761
|
+
value: function(e) {
|
|
1762
|
+
var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, a = this.createCanvas(e, t), r = {
|
|
1763
|
+
preserveDrawingBuffer: !1,
|
|
1764
|
+
antialias: !1
|
|
1765
|
+
};
|
|
1766
|
+
return this.canvasContexts[e] = a.getContext("2d", r), this;
|
|
1767
|
+
}
|
|
1768
|
+
/**
|
|
1769
|
+
* Function used to create a WebGL context and add the relevant DOM
|
|
1770
|
+
* elements.
|
|
1771
|
+
*
|
|
1772
|
+
* @param {string} id - Context's id.
|
|
1773
|
+
* @param {object?} options - #getContext params to override (optional)
|
|
1774
|
+
* @return {WebGLRenderingContext}
|
|
1775
|
+
*/
|
|
1776
|
+
}, {
|
|
1777
|
+
key: "createWebGLContext",
|
|
1778
|
+
value: function(e) {
|
|
1779
|
+
var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, a = (t == null ? void 0 : t.canvas) || this.createCanvas(e, t);
|
|
1780
|
+
t.hidden && a.remove();
|
|
1781
|
+
var r = v({
|
|
1782
|
+
preserveDrawingBuffer: !1,
|
|
1783
|
+
antialias: !1
|
|
1784
|
+
}, t), o;
|
|
1785
|
+
o = a.getContext("webgl2", r), o || (o = a.getContext("webgl", r)), o || (o = a.getContext("experimental-webgl", r));
|
|
1786
|
+
var h = o;
|
|
1787
|
+
if (this.webGLContexts[e] = h, h.blendFunc(h.ONE, h.ONE_MINUS_SRC_ALPHA), t.picking) {
|
|
1788
|
+
this.pickingLayers.add(e);
|
|
1789
|
+
var d = h.createFramebuffer();
|
|
1790
|
+
if (!d) throw new Error("Sigma: cannot create a new frame buffer for layer ".concat(e));
|
|
1791
|
+
this.frameBuffers[e] = d;
|
|
1792
|
+
}
|
|
1793
|
+
return h;
|
|
1794
|
+
}
|
|
1795
|
+
/**
|
|
1796
|
+
* Function used to properly kill a layer.
|
|
1797
|
+
*
|
|
1798
|
+
* @param {string} id - Layer id.
|
|
1799
|
+
* @return {Sigma}
|
|
1800
|
+
*/
|
|
1801
|
+
}, {
|
|
1802
|
+
key: "killLayer",
|
|
1803
|
+
value: function(e) {
|
|
1804
|
+
var t = this.elements[e];
|
|
1805
|
+
if (!t) throw new Error("Sigma: cannot kill layer ".concat(e, ", which does not exist"));
|
|
1806
|
+
if (this.webGLContexts[e]) {
|
|
1807
|
+
var a, r = this.webGLContexts[e];
|
|
1808
|
+
(a = r.getExtension("WEBGL_lose_context")) === null || a === void 0 || a.loseContext(), delete this.webGLContexts[e];
|
|
1809
|
+
} else this.canvasContexts[e] && delete this.canvasContexts[e];
|
|
1810
|
+
return t.remove(), delete this.elements[e], this;
|
|
1811
|
+
}
|
|
1812
|
+
/**
|
|
1813
|
+
* Method returning the renderer's camera.
|
|
1814
|
+
*
|
|
1815
|
+
* @return {Camera}
|
|
1816
|
+
*/
|
|
1817
|
+
}, {
|
|
1818
|
+
key: "getCamera",
|
|
1819
|
+
value: function() {
|
|
1820
|
+
return this.camera;
|
|
1821
|
+
}
|
|
1822
|
+
/**
|
|
1823
|
+
* Method setting the renderer's camera.
|
|
1824
|
+
*
|
|
1825
|
+
* @param {Camera} camera - New camera.
|
|
1826
|
+
* @return {Sigma}
|
|
1827
|
+
*/
|
|
1828
|
+
}, {
|
|
1829
|
+
key: "setCamera",
|
|
1830
|
+
value: function(e) {
|
|
1831
|
+
this.unbindCameraHandlers(), this.camera = e, this.bindCameraHandlers();
|
|
1832
|
+
}
|
|
1833
|
+
/**
|
|
1834
|
+
* Method returning the container DOM element.
|
|
1835
|
+
*
|
|
1836
|
+
* @return {HTMLElement}
|
|
1837
|
+
*/
|
|
1838
|
+
}, {
|
|
1839
|
+
key: "getContainer",
|
|
1840
|
+
value: function() {
|
|
1841
|
+
return this.container;
|
|
1842
|
+
}
|
|
1843
|
+
/**
|
|
1844
|
+
* Method returning the renderer's graph.
|
|
1845
|
+
*
|
|
1846
|
+
* @return {Graph}
|
|
1847
|
+
*/
|
|
1848
|
+
}, {
|
|
1849
|
+
key: "getGraph",
|
|
1850
|
+
value: function() {
|
|
1851
|
+
return this.graph;
|
|
1852
|
+
}
|
|
1853
|
+
/**
|
|
1854
|
+
* Method used to set the renderer's graph.
|
|
1855
|
+
*
|
|
1856
|
+
* @return {Graph}
|
|
1857
|
+
*/
|
|
1858
|
+
}, {
|
|
1859
|
+
key: "setGraph",
|
|
1860
|
+
value: function(e) {
|
|
1861
|
+
e !== this.graph && (this.hoveredNode && !e.hasNode(this.hoveredNode) && (this.hoveredNode = null), this.hoveredEdge && !e.hasEdge(this.hoveredEdge) && (this.hoveredEdge = null), this.unbindGraphHandlers(), this.checkEdgesEventsFrame !== null && (cancelAnimationFrame(this.checkEdgesEventsFrame), this.checkEdgesEventsFrame = null), this.graph = e, this.bindGraphHandlers(), this.refresh());
|
|
1862
|
+
}
|
|
1863
|
+
/**
|
|
1864
|
+
* Method returning the mouse captor.
|
|
1865
|
+
*
|
|
1866
|
+
* @return {MouseCaptor}
|
|
1867
|
+
*/
|
|
1868
|
+
}, {
|
|
1869
|
+
key: "getMouseCaptor",
|
|
1870
|
+
value: function() {
|
|
1871
|
+
return this.mouseCaptor;
|
|
1872
|
+
}
|
|
1873
|
+
/**
|
|
1874
|
+
* Method returning the touch captor.
|
|
1875
|
+
*
|
|
1876
|
+
* @return {TouchCaptor}
|
|
1877
|
+
*/
|
|
1878
|
+
}, {
|
|
1879
|
+
key: "getTouchCaptor",
|
|
1880
|
+
value: function() {
|
|
1881
|
+
return this.touchCaptor;
|
|
1882
|
+
}
|
|
1883
|
+
/**
|
|
1884
|
+
* Method returning the current renderer's dimensions.
|
|
1885
|
+
*
|
|
1886
|
+
* @return {Dimensions}
|
|
1887
|
+
*/
|
|
1888
|
+
}, {
|
|
1889
|
+
key: "getDimensions",
|
|
1890
|
+
value: function() {
|
|
1891
|
+
return {
|
|
1892
|
+
width: this.width,
|
|
1893
|
+
height: this.height
|
|
1894
|
+
};
|
|
1895
|
+
}
|
|
1896
|
+
/**
|
|
1897
|
+
* Method returning the current graph's dimensions.
|
|
1898
|
+
*
|
|
1899
|
+
* @return {Dimensions}
|
|
1900
|
+
*/
|
|
1901
|
+
}, {
|
|
1902
|
+
key: "getGraphDimensions",
|
|
1903
|
+
value: function() {
|
|
1904
|
+
var e = this.customBBox || this.nodeExtent;
|
|
1905
|
+
return {
|
|
1906
|
+
width: e.x[1] - e.x[0] || 1,
|
|
1907
|
+
height: e.y[1] - e.y[0] || 1
|
|
1908
|
+
};
|
|
1909
|
+
}
|
|
1910
|
+
/**
|
|
1911
|
+
* Method used to get all the sigma node attributes.
|
|
1912
|
+
* It's useful for example to get the position of a node
|
|
1913
|
+
* and to get values that are set by the nodeReducer
|
|
1914
|
+
*
|
|
1915
|
+
* @param {string} key - The node's key.
|
|
1916
|
+
* @return {NodeDisplayData | undefined} A copy of the desired node's attribute or undefined if not found
|
|
1917
|
+
*/
|
|
1918
|
+
}, {
|
|
1919
|
+
key: "getNodeDisplayData",
|
|
1920
|
+
value: function(e) {
|
|
1921
|
+
var t = this.nodeDataCache[e];
|
|
1922
|
+
return t ? Object.assign({}, t) : void 0;
|
|
1923
|
+
}
|
|
1924
|
+
/**
|
|
1925
|
+
* Method used to get all the sigma edge attributes.
|
|
1926
|
+
* It's useful for example to get values that are set by the edgeReducer.
|
|
1927
|
+
*
|
|
1928
|
+
* @param {string} key - The edge's key.
|
|
1929
|
+
* @return {EdgeDisplayData | undefined} A copy of the desired edge's attribute or undefined if not found
|
|
1930
|
+
*/
|
|
1931
|
+
}, {
|
|
1932
|
+
key: "getEdgeDisplayData",
|
|
1933
|
+
value: function(e) {
|
|
1934
|
+
var t = this.edgeDataCache[e];
|
|
1935
|
+
return t ? Object.assign({}, t) : void 0;
|
|
1936
|
+
}
|
|
1937
|
+
/**
|
|
1938
|
+
* Method used to get the set of currently displayed node labels.
|
|
1939
|
+
*
|
|
1940
|
+
* @return {Set<string>} A set of node keys whose label is displayed.
|
|
1941
|
+
*/
|
|
1942
|
+
}, {
|
|
1943
|
+
key: "getNodeDisplayedLabels",
|
|
1944
|
+
value: function() {
|
|
1945
|
+
return new Set(this.displayedNodeLabels);
|
|
1946
|
+
}
|
|
1947
|
+
/**
|
|
1948
|
+
* Method used to get the set of currently displayed edge labels.
|
|
1949
|
+
*
|
|
1950
|
+
* @return {Set<string>} A set of edge keys whose label is displayed.
|
|
1951
|
+
*/
|
|
1952
|
+
}, {
|
|
1953
|
+
key: "getEdgeDisplayedLabels",
|
|
1954
|
+
value: function() {
|
|
1955
|
+
return new Set(this.displayedEdgeLabels);
|
|
1956
|
+
}
|
|
1957
|
+
/**
|
|
1958
|
+
* Method returning a copy of the settings collection.
|
|
1959
|
+
*
|
|
1960
|
+
* @return {Settings} A copy of the settings collection.
|
|
1961
|
+
*/
|
|
1962
|
+
}, {
|
|
1963
|
+
key: "getSettings",
|
|
1964
|
+
value: function() {
|
|
1965
|
+
return v({}, this.settings);
|
|
1966
|
+
}
|
|
1967
|
+
/**
|
|
1968
|
+
* Method returning the current value for a given setting key.
|
|
1969
|
+
*
|
|
1970
|
+
* @param {string} key - The setting key to get.
|
|
1971
|
+
* @return {any} The value attached to this setting key or undefined if not found
|
|
1972
|
+
*/
|
|
1973
|
+
}, {
|
|
1974
|
+
key: "getSetting",
|
|
1975
|
+
value: function(e) {
|
|
1976
|
+
return this.settings[e];
|
|
1977
|
+
}
|
|
1978
|
+
/**
|
|
1979
|
+
* Method setting the value of a given setting key. Note that this will schedule
|
|
1980
|
+
* a new render next frame.
|
|
1981
|
+
*
|
|
1982
|
+
* @param {string} key - The setting key to set.
|
|
1983
|
+
* @param {any} value - The value to set.
|
|
1984
|
+
* @return {Sigma}
|
|
1985
|
+
*/
|
|
1986
|
+
}, {
|
|
1987
|
+
key: "setSetting",
|
|
1988
|
+
value: function(e, t) {
|
|
1989
|
+
var a = v({}, this.settings);
|
|
1990
|
+
return this.settings[e] = t, oe(this.settings), this.handleSettingsUpdate(a), this.scheduleRefresh(), this;
|
|
1991
|
+
}
|
|
1992
|
+
/**
|
|
1993
|
+
* Method updating the value of a given setting key using the provided function.
|
|
1994
|
+
* Note that this will schedule a new render next frame.
|
|
1995
|
+
*
|
|
1996
|
+
* @param {string} key - The setting key to set.
|
|
1997
|
+
* @param {function} updater - The update function.
|
|
1998
|
+
* @return {Sigma}
|
|
1999
|
+
*/
|
|
2000
|
+
}, {
|
|
2001
|
+
key: "updateSetting",
|
|
2002
|
+
value: function(e, t) {
|
|
2003
|
+
return this.setSetting(e, t(this.settings[e])), this;
|
|
2004
|
+
}
|
|
2005
|
+
/**
|
|
2006
|
+
* Method setting multiple settings at once.
|
|
2007
|
+
*
|
|
2008
|
+
* @param {Partial<Settings>} settings - The settings to set.
|
|
2009
|
+
* @return {Sigma}
|
|
2010
|
+
*/
|
|
2011
|
+
}, {
|
|
2012
|
+
key: "setSettings",
|
|
2013
|
+
value: function(e) {
|
|
2014
|
+
var t = v({}, this.settings);
|
|
2015
|
+
return this.settings = v(v({}, this.settings), e), oe(this.settings), this.handleSettingsUpdate(t), this.scheduleRefresh(), this;
|
|
2016
|
+
}
|
|
2017
|
+
/**
|
|
2018
|
+
* Method used to resize the renderer.
|
|
2019
|
+
*
|
|
2020
|
+
* @param {boolean} force - If true, then resize is processed even if size is unchanged (optional).
|
|
2021
|
+
* @return {Sigma}
|
|
2022
|
+
*/
|
|
2023
|
+
}, {
|
|
2024
|
+
key: "resize",
|
|
2025
|
+
value: function(e) {
|
|
2026
|
+
var t = this.width, a = this.height;
|
|
2027
|
+
if (this.width = this.container.offsetWidth, this.height = this.container.offsetHeight, this.pixelRatio = pe(), this.width === 0)
|
|
2028
|
+
if (this.settings.allowInvalidContainer) this.width = 1;
|
|
2029
|
+
else throw new Error("Sigma: Container has no width. You can set the allowInvalidContainer setting to true to stop seeing this error.");
|
|
2030
|
+
if (this.height === 0)
|
|
2031
|
+
if (this.settings.allowInvalidContainer) this.height = 1;
|
|
2032
|
+
else throw new Error("Sigma: Container has no height. You can set the allowInvalidContainer setting to true to stop seeing this error.");
|
|
2033
|
+
if (!e && t === this.width && a === this.height) return this;
|
|
2034
|
+
for (var r in this.elements) {
|
|
2035
|
+
var o = this.elements[r];
|
|
2036
|
+
o.style.width = this.width + "px", o.style.height = this.height + "px";
|
|
2037
|
+
}
|
|
2038
|
+
for (var h in this.canvasContexts)
|
|
2039
|
+
this.elements[h].setAttribute("width", this.width * this.pixelRatio + "px"), this.elements[h].setAttribute("height", this.height * this.pixelRatio + "px"), this.pixelRatio !== 1 && this.canvasContexts[h].scale(this.pixelRatio, this.pixelRatio);
|
|
2040
|
+
for (var d in this.webGLContexts) {
|
|
2041
|
+
this.elements[d].setAttribute("width", this.width * this.pixelRatio + "px"), this.elements[d].setAttribute("height", this.height * this.pixelRatio + "px");
|
|
2042
|
+
var l = this.webGLContexts[d];
|
|
2043
|
+
if (l.viewport(0, 0, this.width * this.pixelRatio, this.height * this.pixelRatio), this.pickingLayers.has(d)) {
|
|
2044
|
+
var u = this.textures[d];
|
|
2045
|
+
u && l.deleteTexture(u);
|
|
2046
|
+
}
|
|
2047
|
+
}
|
|
2048
|
+
return this.emit("resize"), this;
|
|
2049
|
+
}
|
|
2050
|
+
/**
|
|
2051
|
+
* Method used to clear all the canvases.
|
|
2052
|
+
*
|
|
2053
|
+
* @return {Sigma}
|
|
2054
|
+
*/
|
|
2055
|
+
}, {
|
|
2056
|
+
key: "clear",
|
|
2057
|
+
value: function() {
|
|
2058
|
+
return this.emit("beforeClear"), this.webGLContexts.nodes.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER, null), this.webGLContexts.nodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT), this.webGLContexts.edges.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER, null), this.webGLContexts.edges.clear(WebGLRenderingContext.COLOR_BUFFER_BIT), this.webGLContexts.hoverNodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT), this.canvasContexts.labels.clearRect(0, 0, this.width, this.height), this.canvasContexts.hovers.clearRect(0, 0, this.width, this.height), this.canvasContexts.edgeLabels.clearRect(0, 0, this.width, this.height), this.emit("afterClear"), this;
|
|
2059
|
+
}
|
|
2060
|
+
/**
|
|
2061
|
+
* Method used to refresh, i.e. force the renderer to reprocess graph
|
|
2062
|
+
* data and render, but keep the state.
|
|
2063
|
+
* - if a partialGraph is provided, we only reprocess those nodes & edges.
|
|
2064
|
+
* - if schedule is TRUE, we schedule a render instead of sync render
|
|
2065
|
+
* - if skipIndexation is TRUE, then labelGrid & program indexation are skipped (can be used if you haven't modify x, y, zIndex & size)
|
|
2066
|
+
*
|
|
2067
|
+
* @return {Sigma}
|
|
2068
|
+
*/
|
|
2069
|
+
}, {
|
|
2070
|
+
key: "refresh",
|
|
2071
|
+
value: function(e) {
|
|
2072
|
+
var t = this, a = (e == null ? void 0 : e.skipIndexation) !== void 0 ? e == null ? void 0 : e.skipIndexation : !1, r = (e == null ? void 0 : e.schedule) !== void 0 ? e.schedule : !1, o = !e || !e.partialGraph;
|
|
2073
|
+
if (o)
|
|
2074
|
+
this.clearEdgeIndices(), this.clearNodeIndices(), this.graph.forEachNode(function(C) {
|
|
2075
|
+
return t.addNode(C);
|
|
2076
|
+
}), this.graph.forEachEdge(function(C) {
|
|
2077
|
+
return t.addEdge(C);
|
|
2078
|
+
});
|
|
2079
|
+
else {
|
|
2080
|
+
for (var h, d, l = ((h = e.partialGraph) === null || h === void 0 ? void 0 : h.nodes) || [], u = 0, g = (l == null ? void 0 : l.length) || 0; u < g; u++) {
|
|
2081
|
+
var f = l[u];
|
|
2082
|
+
if (this.updateNode(f), a) {
|
|
2083
|
+
var m = this.nodeProgramIndex[f];
|
|
2084
|
+
if (m === void 0) throw new Error('Sigma: node "'.concat(f, `" can't be repaint`));
|
|
2085
|
+
this.addNodeToProgram(f, this.nodeIndices[f], m);
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
for (var p = (e == null || (d = e.partialGraph) === null || d === void 0 ? void 0 : d.edges) || [], y = 0, E = p.length; y < E; y++) {
|
|
2089
|
+
var b = p[y];
|
|
2090
|
+
if (this.updateEdge(b), a) {
|
|
2091
|
+
var x = this.edgeProgramIndex[b];
|
|
2092
|
+
if (x === void 0) throw new Error('Sigma: edge "'.concat(b, `" can't be repaint`));
|
|
2093
|
+
this.addEdgeToProgram(b, this.edgeIndices[b], x);
|
|
2094
|
+
}
|
|
2095
|
+
}
|
|
2096
|
+
}
|
|
2097
|
+
return (o || !a) && (this.needToProcess = !0), r ? this.scheduleRender() : this.render(), this;
|
|
2098
|
+
}
|
|
2099
|
+
/**
|
|
2100
|
+
* Method used to schedule a render at the next available frame.
|
|
2101
|
+
* This method can be safely called on a same frame because it basically
|
|
2102
|
+
* debounces refresh to the next frame.
|
|
2103
|
+
*
|
|
2104
|
+
* @return {Sigma}
|
|
2105
|
+
*/
|
|
2106
|
+
}, {
|
|
2107
|
+
key: "scheduleRender",
|
|
2108
|
+
value: function() {
|
|
2109
|
+
var e = this;
|
|
2110
|
+
return this.renderFrame || (this.renderFrame = requestAnimationFrame(function() {
|
|
2111
|
+
e.render();
|
|
2112
|
+
})), this;
|
|
2113
|
+
}
|
|
2114
|
+
/**
|
|
2115
|
+
* Method used to schedule a refresh (i.e. fully reprocess graph data and render)
|
|
2116
|
+
* at the next available frame.
|
|
2117
|
+
* This method can be safely called on a same frame because it basically
|
|
2118
|
+
* debounces refresh to the next frame.
|
|
2119
|
+
*
|
|
2120
|
+
* @return {Sigma}
|
|
2121
|
+
*/
|
|
2122
|
+
}, {
|
|
2123
|
+
key: "scheduleRefresh",
|
|
2124
|
+
value: function(e) {
|
|
2125
|
+
return this.refresh(v(v({}, e), {}, {
|
|
2126
|
+
schedule: !0
|
|
2127
|
+
}));
|
|
2128
|
+
}
|
|
2129
|
+
/**
|
|
2130
|
+
* Method used to (un)zoom, while preserving the position of a viewport point.
|
|
2131
|
+
* Used for instance to zoom "on the mouse cursor".
|
|
2132
|
+
*
|
|
2133
|
+
* @param viewportTarget
|
|
2134
|
+
* @param newRatio
|
|
2135
|
+
* @return {CameraState}
|
|
2136
|
+
*/
|
|
2137
|
+
}, {
|
|
2138
|
+
key: "getViewportZoomedState",
|
|
2139
|
+
value: function(e, t) {
|
|
2140
|
+
var a = this.camera.getState(), r = a.ratio, o = a.angle, h = a.x, d = a.y, l = this.settings, u = l.minCameraRatio, g = l.maxCameraRatio;
|
|
2141
|
+
typeof g == "number" && (t = Math.min(t, g)), typeof u == "number" && (t = Math.max(t, u));
|
|
2142
|
+
var f = t / r, m = {
|
|
2143
|
+
x: this.width / 2,
|
|
2144
|
+
y: this.height / 2
|
|
2145
|
+
}, p = this.viewportToFramedGraph(e), y = this.viewportToFramedGraph(m);
|
|
2146
|
+
return {
|
|
2147
|
+
angle: o,
|
|
2148
|
+
x: (p.x - y.x) * (1 - f) + h,
|
|
2149
|
+
y: (p.y - y.y) * (1 - f) + d,
|
|
2150
|
+
ratio: t
|
|
2151
|
+
};
|
|
2152
|
+
}
|
|
2153
|
+
/**
|
|
2154
|
+
* Method returning the abstract rectangle containing the graph according
|
|
2155
|
+
* to the camera's state.
|
|
2156
|
+
*
|
|
2157
|
+
* @return {object} - The view's rectangle.
|
|
2158
|
+
*/
|
|
2159
|
+
}, {
|
|
2160
|
+
key: "viewRectangle",
|
|
2161
|
+
value: function() {
|
|
2162
|
+
var e = this.viewportToFramedGraph({
|
|
2163
|
+
x: 0,
|
|
2164
|
+
y: 0
|
|
2165
|
+
}), t = this.viewportToFramedGraph({
|
|
2166
|
+
x: this.width,
|
|
2167
|
+
y: 0
|
|
2168
|
+
}), a = this.viewportToFramedGraph({
|
|
2169
|
+
x: 0,
|
|
2170
|
+
y: this.height
|
|
2171
|
+
});
|
|
2172
|
+
return {
|
|
2173
|
+
x1: e.x,
|
|
2174
|
+
y1: e.y,
|
|
2175
|
+
x2: t.x,
|
|
2176
|
+
y2: t.y,
|
|
2177
|
+
height: t.y - a.y
|
|
2178
|
+
};
|
|
2179
|
+
}
|
|
2180
|
+
/**
|
|
2181
|
+
* Method returning the coordinates of a point from the framed graph system to the viewport system. It allows
|
|
2182
|
+
* overriding anything that is used to get the translation matrix, or even the matrix itself.
|
|
2183
|
+
*
|
|
2184
|
+
* Be careful if overriding dimensions, padding or cameraState, as the computation of the matrix is not the lightest
|
|
2185
|
+
* of computations.
|
|
2186
|
+
*/
|
|
2187
|
+
}, {
|
|
2188
|
+
key: "framedGraphToViewport",
|
|
2189
|
+
value: function(e) {
|
|
2190
|
+
var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, a = !!t.cameraState || !!t.viewportDimensions || !!t.graphDimensions, r = t.matrix ? t.matrix : a ? X(t.cameraState || this.camera.getState(), t.viewportDimensions || this.getDimensions(), t.graphDimensions || this.getGraphDimensions(), t.padding || this.getStagePadding()) : this.matrix, o = de(r, e);
|
|
2191
|
+
return {
|
|
2192
|
+
x: (1 + o.x) * this.width / 2,
|
|
2193
|
+
y: (1 - o.y) * this.height / 2
|
|
2194
|
+
};
|
|
2195
|
+
}
|
|
2196
|
+
/**
|
|
2197
|
+
* Method returning the coordinates of a point from the viewport system to the framed graph system. It allows
|
|
2198
|
+
* overriding anything that is used to get the translation matrix, or even the matrix itself.
|
|
2199
|
+
*
|
|
2200
|
+
* Be careful if overriding dimensions, padding or cameraState, as the computation of the matrix is not the lightest
|
|
2201
|
+
* of computations.
|
|
2202
|
+
*/
|
|
2203
|
+
}, {
|
|
2204
|
+
key: "viewportToFramedGraph",
|
|
2205
|
+
value: function(e) {
|
|
2206
|
+
var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, a = !!t.cameraState || !!t.viewportDimensions || !t.graphDimensions, r = t.matrix ? t.matrix : a ? X(t.cameraState || this.camera.getState(), t.viewportDimensions || this.getDimensions(), t.graphDimensions || this.getGraphDimensions(), t.padding || this.getStagePadding(), !0) : this.invMatrix, o = de(r, {
|
|
2207
|
+
x: e.x / this.width * 2 - 1,
|
|
2208
|
+
y: 1 - e.y / this.height * 2
|
|
2209
|
+
});
|
|
2210
|
+
return isNaN(o.x) && (o.x = 0), isNaN(o.y) && (o.y = 0), o;
|
|
2211
|
+
}
|
|
2212
|
+
/**
|
|
2213
|
+
* Method used to translate a point's coordinates from the viewport system (pixel distance from the top-left of the
|
|
2214
|
+
* stage) to the graph system (the reference system of data as they are in the given graph instance).
|
|
2215
|
+
*
|
|
2216
|
+
* This method accepts an optional camera which can be useful if you need to translate coordinates
|
|
2217
|
+
* based on a different view than the one being currently being displayed on screen.
|
|
2218
|
+
*
|
|
2219
|
+
* @param {Coordinates} viewportPoint
|
|
2220
|
+
* @param {CoordinateConversionOverride} override
|
|
2221
|
+
*/
|
|
2222
|
+
}, {
|
|
2223
|
+
key: "viewportToGraph",
|
|
2224
|
+
value: function(e) {
|
|
2225
|
+
var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
2226
|
+
return this.normalizationFunction.inverse(this.viewportToFramedGraph(e, t));
|
|
2227
|
+
}
|
|
2228
|
+
/**
|
|
2229
|
+
* Method used to translate a point's coordinates from the graph system (the reference system of data as they are in
|
|
2230
|
+
* the given graph instance) to the viewport system (pixel distance from the top-left of the stage).
|
|
2231
|
+
*
|
|
2232
|
+
* This method accepts an optional camera which can be useful if you need to translate coordinates
|
|
2233
|
+
* based on a different view than the one being currently being displayed on screen.
|
|
2234
|
+
*
|
|
2235
|
+
* @param {Coordinates} graphPoint
|
|
2236
|
+
* @param {CoordinateConversionOverride} override
|
|
2237
|
+
*/
|
|
2238
|
+
}, {
|
|
2239
|
+
key: "graphToViewport",
|
|
2240
|
+
value: function(e) {
|
|
2241
|
+
var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
2242
|
+
return this.framedGraphToViewport(this.normalizationFunction(e), t);
|
|
2243
|
+
}
|
|
2244
|
+
/**
|
|
2245
|
+
* Method returning the distance multiplier between the graph system and the
|
|
2246
|
+
* viewport system.
|
|
2247
|
+
*/
|
|
2248
|
+
}, {
|
|
2249
|
+
key: "getGraphToViewportRatio",
|
|
2250
|
+
value: function() {
|
|
2251
|
+
var e = {
|
|
2252
|
+
x: 0,
|
|
2253
|
+
y: 0
|
|
2254
|
+
}, t = {
|
|
2255
|
+
x: 1,
|
|
2256
|
+
y: 1
|
|
2257
|
+
}, a = Math.sqrt(Math.pow(e.x - t.x, 2) + Math.pow(e.y - t.y, 2)), r = this.graphToViewport(e), o = this.graphToViewport(t), h = Math.sqrt(Math.pow(r.x - o.x, 2) + Math.pow(r.y - o.y, 2));
|
|
2258
|
+
return h / a;
|
|
2259
|
+
}
|
|
2260
|
+
/**
|
|
2261
|
+
* Method returning the graph's bounding box.
|
|
2262
|
+
*
|
|
2263
|
+
* @return {{ x: Extent, y: Extent }}
|
|
2264
|
+
*/
|
|
2265
|
+
}, {
|
|
2266
|
+
key: "getBBox",
|
|
2267
|
+
value: function() {
|
|
2268
|
+
return this.nodeExtent;
|
|
2269
|
+
}
|
|
2270
|
+
/**
|
|
2271
|
+
* Method returning the graph's custom bounding box, if any.
|
|
2272
|
+
*
|
|
2273
|
+
* @return {{ x: Extent, y: Extent } | null}
|
|
2274
|
+
*/
|
|
2275
|
+
}, {
|
|
2276
|
+
key: "getCustomBBox",
|
|
2277
|
+
value: function() {
|
|
2278
|
+
return this.customBBox;
|
|
2279
|
+
}
|
|
2280
|
+
/**
|
|
2281
|
+
* Method used to override the graph's bounding box with a custom one. Give `null` as the argument to stop overriding.
|
|
2282
|
+
*
|
|
2283
|
+
* @return {Sigma}
|
|
2284
|
+
*/
|
|
2285
|
+
}, {
|
|
2286
|
+
key: "setCustomBBox",
|
|
2287
|
+
value: function(e) {
|
|
2288
|
+
return this.customBBox = e, this.scheduleRender(), this;
|
|
2289
|
+
}
|
|
2290
|
+
/**
|
|
2291
|
+
* Method used to shut the container & release event listeners.
|
|
2292
|
+
*
|
|
2293
|
+
* @return {undefined}
|
|
2294
|
+
*/
|
|
2295
|
+
}, {
|
|
2296
|
+
key: "kill",
|
|
2297
|
+
value: function() {
|
|
2298
|
+
this.emit("kill"), this.removeAllListeners(), this.unbindCameraHandlers(), window.removeEventListener("resize", this.activeListeners.handleResize), this.mouseCaptor.kill(), this.touchCaptor.kill(), this.unbindGraphHandlers(), this.clearIndices(), this.clearState(), this.nodeDataCache = {}, this.edgeDataCache = {}, this.highlightedNodes.clear(), this.renderFrame && (cancelAnimationFrame(this.renderFrame), this.renderFrame = null), this.renderHighlightedNodesFrame && (cancelAnimationFrame(this.renderHighlightedNodesFrame), this.renderHighlightedNodesFrame = null);
|
|
2299
|
+
for (var e = this.container; e.firstChild; ) e.removeChild(e.firstChild);
|
|
2300
|
+
for (var t in this.nodePrograms)
|
|
2301
|
+
this.nodePrograms[t].kill();
|
|
2302
|
+
for (var a in this.nodeHoverPrograms)
|
|
2303
|
+
this.nodeHoverPrograms[a].kill();
|
|
2304
|
+
for (var r in this.edgePrograms)
|
|
2305
|
+
this.edgePrograms[r].kill();
|
|
2306
|
+
this.nodePrograms = {}, this.nodeHoverPrograms = {}, this.edgePrograms = {};
|
|
2307
|
+
for (var o in this.elements)
|
|
2308
|
+
this.killLayer(o);
|
|
2309
|
+
this.canvasContexts = {}, this.webGLContexts = {}, this.elements = {};
|
|
2310
|
+
}
|
|
2311
|
+
/**
|
|
2312
|
+
* Method used to scale the given size according to the camera's ratio, i.e.
|
|
2313
|
+
* zooming state.
|
|
2314
|
+
*
|
|
2315
|
+
* @param {number?} size - The size to scale (node size, edge thickness etc.).
|
|
2316
|
+
* @param {number?} cameraRatio - A camera ratio (defaults to the actual camera ratio).
|
|
2317
|
+
* @return {number} - The scaled size.
|
|
2318
|
+
*/
|
|
2319
|
+
}, {
|
|
2320
|
+
key: "scaleSize",
|
|
2321
|
+
value: function() {
|
|
2322
|
+
var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 1, t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : this.camera.ratio;
|
|
2323
|
+
return e / this.settings.zoomToSizeRatioFunction(t) * (this.getSetting("itemSizesReference") === "positions" ? t * this.graphToViewportRatio : 1);
|
|
2324
|
+
}
|
|
2325
|
+
/**
|
|
2326
|
+
* Method that returns the collection of all used canvases.
|
|
2327
|
+
* At the moment, the instantiated canvases are the following, and in the
|
|
2328
|
+
* following order in the DOM:
|
|
2329
|
+
* - `edges`
|
|
2330
|
+
* - `nodes`
|
|
2331
|
+
* - `edgeLabels`
|
|
2332
|
+
* - `labels`
|
|
2333
|
+
* - `hovers`
|
|
2334
|
+
* - `hoverNodes`
|
|
2335
|
+
* - `mouse`
|
|
2336
|
+
*
|
|
2337
|
+
* @return {PlainObject<HTMLCanvasElement>} - The collection of canvases.
|
|
2338
|
+
*/
|
|
2339
|
+
}, {
|
|
2340
|
+
key: "getCanvases",
|
|
2341
|
+
value: function() {
|
|
2342
|
+
var e = {};
|
|
2343
|
+
for (var t in this.elements) this.elements[t] instanceof HTMLCanvasElement && (e[t] = this.elements[t]);
|
|
2344
|
+
return e;
|
|
2345
|
+
}
|
|
2346
|
+
}]);
|
|
2347
|
+
})(ue), Lt = Ct;
|
|
2348
|
+
export {
|
|
2349
|
+
Ce as Camera,
|
|
2350
|
+
lt as MouseCaptor,
|
|
2351
|
+
Ct as Sigma,
|
|
2352
|
+
gt as TouchCaptor,
|
|
2353
|
+
Lt as default
|
|
2354
|
+
};
|
|
2355
|
+
//# sourceMappingURL=sigma.esm-y0qgY-OC.js.map
|