@memnest/ui-core 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +44 -0
- package/dist/chunk-JCMPD6YF.js +1076 -0
- package/dist/chunk-JCMPD6YF.js.map +1 -0
- package/dist/index.cjs +2398 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +513 -0
- package/dist/index.d.ts +513 -0
- package/dist/index.js +1277 -0
- package/dist/index.js.map +1 -0
- package/dist/layout-worker-CLScIQSu.d.cts +142 -0
- package/dist/layout-worker-CLScIQSu.d.ts +142 -0
- package/dist/layout-worker.cjs +1051 -0
- package/dist/layout-worker.cjs.map +1 -0
- package/dist/layout-worker.d.cts +1 -0
- package/dist/layout-worker.d.ts +1 -0
- package/dist/layout-worker.js +10 -0
- package/dist/layout-worker.js.map +1 -0
- package/package.json +81 -0
|
@@ -0,0 +1,1051 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/layout-worker.ts
|
|
21
|
+
var layout_worker_exports = {};
|
|
22
|
+
__export(layout_worker_exports, {
|
|
23
|
+
serveLayoutRequests: () => serveLayoutRequests
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(layout_worker_exports);
|
|
26
|
+
|
|
27
|
+
// ../../node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/add.js
|
|
28
|
+
function add_default(d) {
|
|
29
|
+
const x3 = +this._x.call(null, d), y3 = +this._y.call(null, d);
|
|
30
|
+
return add(this.cover(x3, y3), x3, y3, d);
|
|
31
|
+
}
|
|
32
|
+
function add(tree, x3, y3, d) {
|
|
33
|
+
if (isNaN(x3) || isNaN(y3)) return tree;
|
|
34
|
+
var parent, node = tree._root, leaf = { data: d }, x0 = tree._x0, y0 = tree._y0, x1 = tree._x1, y1 = tree._y1, xm, ym, xp, yp, right, bottom, i, j;
|
|
35
|
+
if (!node) return tree._root = leaf, tree;
|
|
36
|
+
while (node.length) {
|
|
37
|
+
if (right = x3 >= (xm = (x0 + x1) / 2)) x0 = xm;
|
|
38
|
+
else x1 = xm;
|
|
39
|
+
if (bottom = y3 >= (ym = (y0 + y1) / 2)) y0 = ym;
|
|
40
|
+
else y1 = ym;
|
|
41
|
+
if (parent = node, !(node = node[i = bottom << 1 | right])) return parent[i] = leaf, tree;
|
|
42
|
+
}
|
|
43
|
+
xp = +tree._x.call(null, node.data);
|
|
44
|
+
yp = +tree._y.call(null, node.data);
|
|
45
|
+
if (x3 === xp && y3 === yp) return leaf.next = node, parent ? parent[i] = leaf : tree._root = leaf, tree;
|
|
46
|
+
do {
|
|
47
|
+
parent = parent ? parent[i] = new Array(4) : tree._root = new Array(4);
|
|
48
|
+
if (right = x3 >= (xm = (x0 + x1) / 2)) x0 = xm;
|
|
49
|
+
else x1 = xm;
|
|
50
|
+
if (bottom = y3 >= (ym = (y0 + y1) / 2)) y0 = ym;
|
|
51
|
+
else y1 = ym;
|
|
52
|
+
} while ((i = bottom << 1 | right) === (j = (yp >= ym) << 1 | xp >= xm));
|
|
53
|
+
return parent[j] = node, parent[i] = leaf, tree;
|
|
54
|
+
}
|
|
55
|
+
function addAll(data) {
|
|
56
|
+
var d, i, n = data.length, x3, y3, xz = new Array(n), yz = new Array(n), x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;
|
|
57
|
+
for (i = 0; i < n; ++i) {
|
|
58
|
+
if (isNaN(x3 = +this._x.call(null, d = data[i])) || isNaN(y3 = +this._y.call(null, d))) continue;
|
|
59
|
+
xz[i] = x3;
|
|
60
|
+
yz[i] = y3;
|
|
61
|
+
if (x3 < x0) x0 = x3;
|
|
62
|
+
if (x3 > x1) x1 = x3;
|
|
63
|
+
if (y3 < y0) y0 = y3;
|
|
64
|
+
if (y3 > y1) y1 = y3;
|
|
65
|
+
}
|
|
66
|
+
if (x0 > x1 || y0 > y1) return this;
|
|
67
|
+
this.cover(x0, y0).cover(x1, y1);
|
|
68
|
+
for (i = 0; i < n; ++i) {
|
|
69
|
+
add(this, xz[i], yz[i], data[i]);
|
|
70
|
+
}
|
|
71
|
+
return this;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// ../../node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/cover.js
|
|
75
|
+
function cover_default(x3, y3) {
|
|
76
|
+
if (isNaN(x3 = +x3) || isNaN(y3 = +y3)) return this;
|
|
77
|
+
var x0 = this._x0, y0 = this._y0, x1 = this._x1, y1 = this._y1;
|
|
78
|
+
if (isNaN(x0)) {
|
|
79
|
+
x1 = (x0 = Math.floor(x3)) + 1;
|
|
80
|
+
y1 = (y0 = Math.floor(y3)) + 1;
|
|
81
|
+
} else {
|
|
82
|
+
var z = x1 - x0 || 1, node = this._root, parent, i;
|
|
83
|
+
while (x0 > x3 || x3 >= x1 || y0 > y3 || y3 >= y1) {
|
|
84
|
+
i = (y3 < y0) << 1 | x3 < x0;
|
|
85
|
+
parent = new Array(4), parent[i] = node, node = parent, z *= 2;
|
|
86
|
+
switch (i) {
|
|
87
|
+
case 0:
|
|
88
|
+
x1 = x0 + z, y1 = y0 + z;
|
|
89
|
+
break;
|
|
90
|
+
case 1:
|
|
91
|
+
x0 = x1 - z, y1 = y0 + z;
|
|
92
|
+
break;
|
|
93
|
+
case 2:
|
|
94
|
+
x1 = x0 + z, y0 = y1 - z;
|
|
95
|
+
break;
|
|
96
|
+
case 3:
|
|
97
|
+
x0 = x1 - z, y0 = y1 - z;
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (this._root && this._root.length) this._root = node;
|
|
102
|
+
}
|
|
103
|
+
this._x0 = x0;
|
|
104
|
+
this._y0 = y0;
|
|
105
|
+
this._x1 = x1;
|
|
106
|
+
this._y1 = y1;
|
|
107
|
+
return this;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// ../../node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/data.js
|
|
111
|
+
function data_default() {
|
|
112
|
+
var data = [];
|
|
113
|
+
this.visit(function(node) {
|
|
114
|
+
if (!node.length) do
|
|
115
|
+
data.push(node.data);
|
|
116
|
+
while (node = node.next);
|
|
117
|
+
});
|
|
118
|
+
return data;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// ../../node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/extent.js
|
|
122
|
+
function extent_default(_) {
|
|
123
|
+
return arguments.length ? this.cover(+_[0][0], +_[0][1]).cover(+_[1][0], +_[1][1]) : isNaN(this._x0) ? void 0 : [[this._x0, this._y0], [this._x1, this._y1]];
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// ../../node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/quad.js
|
|
127
|
+
function quad_default(node, x0, y0, x1, y1) {
|
|
128
|
+
this.node = node;
|
|
129
|
+
this.x0 = x0;
|
|
130
|
+
this.y0 = y0;
|
|
131
|
+
this.x1 = x1;
|
|
132
|
+
this.y1 = y1;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// ../../node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/find.js
|
|
136
|
+
function find_default(x3, y3, radius) {
|
|
137
|
+
var data, x0 = this._x0, y0 = this._y0, x1, y1, x22, y22, x32 = this._x1, y32 = this._y1, quads = [], node = this._root, q, i;
|
|
138
|
+
if (node) quads.push(new quad_default(node, x0, y0, x32, y32));
|
|
139
|
+
if (radius == null) radius = Infinity;
|
|
140
|
+
else {
|
|
141
|
+
x0 = x3 - radius, y0 = y3 - radius;
|
|
142
|
+
x32 = x3 + radius, y32 = y3 + radius;
|
|
143
|
+
radius *= radius;
|
|
144
|
+
}
|
|
145
|
+
while (q = quads.pop()) {
|
|
146
|
+
if (!(node = q.node) || (x1 = q.x0) > x32 || (y1 = q.y0) > y32 || (x22 = q.x1) < x0 || (y22 = q.y1) < y0) continue;
|
|
147
|
+
if (node.length) {
|
|
148
|
+
var xm = (x1 + x22) / 2, ym = (y1 + y22) / 2;
|
|
149
|
+
quads.push(
|
|
150
|
+
new quad_default(node[3], xm, ym, x22, y22),
|
|
151
|
+
new quad_default(node[2], x1, ym, xm, y22),
|
|
152
|
+
new quad_default(node[1], xm, y1, x22, ym),
|
|
153
|
+
new quad_default(node[0], x1, y1, xm, ym)
|
|
154
|
+
);
|
|
155
|
+
if (i = (y3 >= ym) << 1 | x3 >= xm) {
|
|
156
|
+
q = quads[quads.length - 1];
|
|
157
|
+
quads[quads.length - 1] = quads[quads.length - 1 - i];
|
|
158
|
+
quads[quads.length - 1 - i] = q;
|
|
159
|
+
}
|
|
160
|
+
} else {
|
|
161
|
+
var dx = x3 - +this._x.call(null, node.data), dy = y3 - +this._y.call(null, node.data), d2 = dx * dx + dy * dy;
|
|
162
|
+
if (d2 < radius) {
|
|
163
|
+
var d = Math.sqrt(radius = d2);
|
|
164
|
+
x0 = x3 - d, y0 = y3 - d;
|
|
165
|
+
x32 = x3 + d, y32 = y3 + d;
|
|
166
|
+
data = node.data;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return data;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// ../../node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/remove.js
|
|
174
|
+
function remove_default(d) {
|
|
175
|
+
if (isNaN(x3 = +this._x.call(null, d)) || isNaN(y3 = +this._y.call(null, d))) return this;
|
|
176
|
+
var parent, node = this._root, retainer, previous, next, x0 = this._x0, y0 = this._y0, x1 = this._x1, y1 = this._y1, x3, y3, xm, ym, right, bottom, i, j;
|
|
177
|
+
if (!node) return this;
|
|
178
|
+
if (node.length) while (true) {
|
|
179
|
+
if (right = x3 >= (xm = (x0 + x1) / 2)) x0 = xm;
|
|
180
|
+
else x1 = xm;
|
|
181
|
+
if (bottom = y3 >= (ym = (y0 + y1) / 2)) y0 = ym;
|
|
182
|
+
else y1 = ym;
|
|
183
|
+
if (!(parent = node, node = node[i = bottom << 1 | right])) return this;
|
|
184
|
+
if (!node.length) break;
|
|
185
|
+
if (parent[i + 1 & 3] || parent[i + 2 & 3] || parent[i + 3 & 3]) retainer = parent, j = i;
|
|
186
|
+
}
|
|
187
|
+
while (node.data !== d) if (!(previous = node, node = node.next)) return this;
|
|
188
|
+
if (next = node.next) delete node.next;
|
|
189
|
+
if (previous) return next ? previous.next = next : delete previous.next, this;
|
|
190
|
+
if (!parent) return this._root = next, this;
|
|
191
|
+
next ? parent[i] = next : delete parent[i];
|
|
192
|
+
if ((node = parent[0] || parent[1] || parent[2] || parent[3]) && node === (parent[3] || parent[2] || parent[1] || parent[0]) && !node.length) {
|
|
193
|
+
if (retainer) retainer[j] = node;
|
|
194
|
+
else this._root = node;
|
|
195
|
+
}
|
|
196
|
+
return this;
|
|
197
|
+
}
|
|
198
|
+
function removeAll(data) {
|
|
199
|
+
for (var i = 0, n = data.length; i < n; ++i) this.remove(data[i]);
|
|
200
|
+
return this;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// ../../node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/root.js
|
|
204
|
+
function root_default() {
|
|
205
|
+
return this._root;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// ../../node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/size.js
|
|
209
|
+
function size_default() {
|
|
210
|
+
var size = 0;
|
|
211
|
+
this.visit(function(node) {
|
|
212
|
+
if (!node.length) do
|
|
213
|
+
++size;
|
|
214
|
+
while (node = node.next);
|
|
215
|
+
});
|
|
216
|
+
return size;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// ../../node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/visit.js
|
|
220
|
+
function visit_default(callback) {
|
|
221
|
+
var quads = [], q, node = this._root, child, x0, y0, x1, y1;
|
|
222
|
+
if (node) quads.push(new quad_default(node, this._x0, this._y0, this._x1, this._y1));
|
|
223
|
+
while (q = quads.pop()) {
|
|
224
|
+
if (!callback(node = q.node, x0 = q.x0, y0 = q.y0, x1 = q.x1, y1 = q.y1) && node.length) {
|
|
225
|
+
var xm = (x0 + x1) / 2, ym = (y0 + y1) / 2;
|
|
226
|
+
if (child = node[3]) quads.push(new quad_default(child, xm, ym, x1, y1));
|
|
227
|
+
if (child = node[2]) quads.push(new quad_default(child, x0, ym, xm, y1));
|
|
228
|
+
if (child = node[1]) quads.push(new quad_default(child, xm, y0, x1, ym));
|
|
229
|
+
if (child = node[0]) quads.push(new quad_default(child, x0, y0, xm, ym));
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return this;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// ../../node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/visitAfter.js
|
|
236
|
+
function visitAfter_default(callback) {
|
|
237
|
+
var quads = [], next = [], q;
|
|
238
|
+
if (this._root) quads.push(new quad_default(this._root, this._x0, this._y0, this._x1, this._y1));
|
|
239
|
+
while (q = quads.pop()) {
|
|
240
|
+
var node = q.node;
|
|
241
|
+
if (node.length) {
|
|
242
|
+
var child, x0 = q.x0, y0 = q.y0, x1 = q.x1, y1 = q.y1, xm = (x0 + x1) / 2, ym = (y0 + y1) / 2;
|
|
243
|
+
if (child = node[0]) quads.push(new quad_default(child, x0, y0, xm, ym));
|
|
244
|
+
if (child = node[1]) quads.push(new quad_default(child, xm, y0, x1, ym));
|
|
245
|
+
if (child = node[2]) quads.push(new quad_default(child, x0, ym, xm, y1));
|
|
246
|
+
if (child = node[3]) quads.push(new quad_default(child, xm, ym, x1, y1));
|
|
247
|
+
}
|
|
248
|
+
next.push(q);
|
|
249
|
+
}
|
|
250
|
+
while (q = next.pop()) {
|
|
251
|
+
callback(q.node, q.x0, q.y0, q.x1, q.y1);
|
|
252
|
+
}
|
|
253
|
+
return this;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// ../../node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/x.js
|
|
257
|
+
function defaultX(d) {
|
|
258
|
+
return d[0];
|
|
259
|
+
}
|
|
260
|
+
function x_default(_) {
|
|
261
|
+
return arguments.length ? (this._x = _, this) : this._x;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// ../../node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/y.js
|
|
265
|
+
function defaultY(d) {
|
|
266
|
+
return d[1];
|
|
267
|
+
}
|
|
268
|
+
function y_default(_) {
|
|
269
|
+
return arguments.length ? (this._y = _, this) : this._y;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// ../../node_modules/.pnpm/d3-quadtree@3.0.1/node_modules/d3-quadtree/src/quadtree.js
|
|
273
|
+
function quadtree(nodes, x3, y3) {
|
|
274
|
+
var tree = new Quadtree(x3 == null ? defaultX : x3, y3 == null ? defaultY : y3, NaN, NaN, NaN, NaN);
|
|
275
|
+
return nodes == null ? tree : tree.addAll(nodes);
|
|
276
|
+
}
|
|
277
|
+
function Quadtree(x3, y3, x0, y0, x1, y1) {
|
|
278
|
+
this._x = x3;
|
|
279
|
+
this._y = y3;
|
|
280
|
+
this._x0 = x0;
|
|
281
|
+
this._y0 = y0;
|
|
282
|
+
this._x1 = x1;
|
|
283
|
+
this._y1 = y1;
|
|
284
|
+
this._root = void 0;
|
|
285
|
+
}
|
|
286
|
+
function leaf_copy(leaf) {
|
|
287
|
+
var copy = { data: leaf.data }, next = copy;
|
|
288
|
+
while (leaf = leaf.next) next = next.next = { data: leaf.data };
|
|
289
|
+
return copy;
|
|
290
|
+
}
|
|
291
|
+
var treeProto = quadtree.prototype = Quadtree.prototype;
|
|
292
|
+
treeProto.copy = function() {
|
|
293
|
+
var copy = new Quadtree(this._x, this._y, this._x0, this._y0, this._x1, this._y1), node = this._root, nodes, child;
|
|
294
|
+
if (!node) return copy;
|
|
295
|
+
if (!node.length) return copy._root = leaf_copy(node), copy;
|
|
296
|
+
nodes = [{ source: node, target: copy._root = new Array(4) }];
|
|
297
|
+
while (node = nodes.pop()) {
|
|
298
|
+
for (var i = 0; i < 4; ++i) {
|
|
299
|
+
if (child = node.source[i]) {
|
|
300
|
+
if (child.length) nodes.push({ source: child, target: node.target[i] = new Array(4) });
|
|
301
|
+
else node.target[i] = leaf_copy(child);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
return copy;
|
|
306
|
+
};
|
|
307
|
+
treeProto.add = add_default;
|
|
308
|
+
treeProto.addAll = addAll;
|
|
309
|
+
treeProto.cover = cover_default;
|
|
310
|
+
treeProto.data = data_default;
|
|
311
|
+
treeProto.extent = extent_default;
|
|
312
|
+
treeProto.find = find_default;
|
|
313
|
+
treeProto.remove = remove_default;
|
|
314
|
+
treeProto.removeAll = removeAll;
|
|
315
|
+
treeProto.root = root_default;
|
|
316
|
+
treeProto.size = size_default;
|
|
317
|
+
treeProto.visit = visit_default;
|
|
318
|
+
treeProto.visitAfter = visitAfter_default;
|
|
319
|
+
treeProto.x = x_default;
|
|
320
|
+
treeProto.y = y_default;
|
|
321
|
+
|
|
322
|
+
// ../../node_modules/.pnpm/d3-force@3.0.0/node_modules/d3-force/src/constant.js
|
|
323
|
+
function constant_default(x3) {
|
|
324
|
+
return function() {
|
|
325
|
+
return x3;
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// ../../node_modules/.pnpm/d3-force@3.0.0/node_modules/d3-force/src/jiggle.js
|
|
330
|
+
function jiggle_default(random) {
|
|
331
|
+
return (random() - 0.5) * 1e-6;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// ../../node_modules/.pnpm/d3-force@3.0.0/node_modules/d3-force/src/collide.js
|
|
335
|
+
function x(d) {
|
|
336
|
+
return d.x + d.vx;
|
|
337
|
+
}
|
|
338
|
+
function y(d) {
|
|
339
|
+
return d.y + d.vy;
|
|
340
|
+
}
|
|
341
|
+
function collide_default(radius) {
|
|
342
|
+
var nodes, radii, random, strength = 1, iterations = 1;
|
|
343
|
+
if (typeof radius !== "function") radius = constant_default(radius == null ? 1 : +radius);
|
|
344
|
+
function force() {
|
|
345
|
+
var i, n = nodes.length, tree, node, xi, yi, ri, ri2;
|
|
346
|
+
for (var k = 0; k < iterations; ++k) {
|
|
347
|
+
tree = quadtree(nodes, x, y).visitAfter(prepare);
|
|
348
|
+
for (i = 0; i < n; ++i) {
|
|
349
|
+
node = nodes[i];
|
|
350
|
+
ri = radii[node.index], ri2 = ri * ri;
|
|
351
|
+
xi = node.x + node.vx;
|
|
352
|
+
yi = node.y + node.vy;
|
|
353
|
+
tree.visit(apply);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
function apply(quad, x0, y0, x1, y1) {
|
|
357
|
+
var data = quad.data, rj = quad.r, r = ri + rj;
|
|
358
|
+
if (data) {
|
|
359
|
+
if (data.index > node.index) {
|
|
360
|
+
var x3 = xi - data.x - data.vx, y3 = yi - data.y - data.vy, l = x3 * x3 + y3 * y3;
|
|
361
|
+
if (l < r * r) {
|
|
362
|
+
if (x3 === 0) x3 = jiggle_default(random), l += x3 * x3;
|
|
363
|
+
if (y3 === 0) y3 = jiggle_default(random), l += y3 * y3;
|
|
364
|
+
l = (r - (l = Math.sqrt(l))) / l * strength;
|
|
365
|
+
node.vx += (x3 *= l) * (r = (rj *= rj) / (ri2 + rj));
|
|
366
|
+
node.vy += (y3 *= l) * r;
|
|
367
|
+
data.vx -= x3 * (r = 1 - r);
|
|
368
|
+
data.vy -= y3 * r;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
return x0 > xi + r || x1 < xi - r || y0 > yi + r || y1 < yi - r;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
function prepare(quad) {
|
|
377
|
+
if (quad.data) return quad.r = radii[quad.data.index];
|
|
378
|
+
for (var i = quad.r = 0; i < 4; ++i) {
|
|
379
|
+
if (quad[i] && quad[i].r > quad.r) {
|
|
380
|
+
quad.r = quad[i].r;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
function initialize() {
|
|
385
|
+
if (!nodes) return;
|
|
386
|
+
var i, n = nodes.length, node;
|
|
387
|
+
radii = new Array(n);
|
|
388
|
+
for (i = 0; i < n; ++i) node = nodes[i], radii[node.index] = +radius(node, i, nodes);
|
|
389
|
+
}
|
|
390
|
+
force.initialize = function(_nodes, _random) {
|
|
391
|
+
nodes = _nodes;
|
|
392
|
+
random = _random;
|
|
393
|
+
initialize();
|
|
394
|
+
};
|
|
395
|
+
force.iterations = function(_) {
|
|
396
|
+
return arguments.length ? (iterations = +_, force) : iterations;
|
|
397
|
+
};
|
|
398
|
+
force.strength = function(_) {
|
|
399
|
+
return arguments.length ? (strength = +_, force) : strength;
|
|
400
|
+
};
|
|
401
|
+
force.radius = function(_) {
|
|
402
|
+
return arguments.length ? (radius = typeof _ === "function" ? _ : constant_default(+_), initialize(), force) : radius;
|
|
403
|
+
};
|
|
404
|
+
return force;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// ../../node_modules/.pnpm/d3-force@3.0.0/node_modules/d3-force/src/link.js
|
|
408
|
+
function index(d) {
|
|
409
|
+
return d.index;
|
|
410
|
+
}
|
|
411
|
+
function find(nodeById, nodeId) {
|
|
412
|
+
var node = nodeById.get(nodeId);
|
|
413
|
+
if (!node) throw new Error("node not found: " + nodeId);
|
|
414
|
+
return node;
|
|
415
|
+
}
|
|
416
|
+
function link_default(links) {
|
|
417
|
+
var id = index, strength = defaultStrength, strengths, distance = constant_default(30), distances, nodes, count, bias, random, iterations = 1;
|
|
418
|
+
if (links == null) links = [];
|
|
419
|
+
function defaultStrength(link) {
|
|
420
|
+
return 1 / Math.min(count[link.source.index], count[link.target.index]);
|
|
421
|
+
}
|
|
422
|
+
function force(alpha) {
|
|
423
|
+
for (var k = 0, n = links.length; k < iterations; ++k) {
|
|
424
|
+
for (var i = 0, link, source, target, x3, y3, l, b; i < n; ++i) {
|
|
425
|
+
link = links[i], source = link.source, target = link.target;
|
|
426
|
+
x3 = target.x + target.vx - source.x - source.vx || jiggle_default(random);
|
|
427
|
+
y3 = target.y + target.vy - source.y - source.vy || jiggle_default(random);
|
|
428
|
+
l = Math.sqrt(x3 * x3 + y3 * y3);
|
|
429
|
+
l = (l - distances[i]) / l * alpha * strengths[i];
|
|
430
|
+
x3 *= l, y3 *= l;
|
|
431
|
+
target.vx -= x3 * (b = bias[i]);
|
|
432
|
+
target.vy -= y3 * b;
|
|
433
|
+
source.vx += x3 * (b = 1 - b);
|
|
434
|
+
source.vy += y3 * b;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
function initialize() {
|
|
439
|
+
if (!nodes) return;
|
|
440
|
+
var i, n = nodes.length, m2 = links.length, nodeById = new Map(nodes.map((d, i2) => [id(d, i2, nodes), d])), link;
|
|
441
|
+
for (i = 0, count = new Array(n); i < m2; ++i) {
|
|
442
|
+
link = links[i], link.index = i;
|
|
443
|
+
if (typeof link.source !== "object") link.source = find(nodeById, link.source);
|
|
444
|
+
if (typeof link.target !== "object") link.target = find(nodeById, link.target);
|
|
445
|
+
count[link.source.index] = (count[link.source.index] || 0) + 1;
|
|
446
|
+
count[link.target.index] = (count[link.target.index] || 0) + 1;
|
|
447
|
+
}
|
|
448
|
+
for (i = 0, bias = new Array(m2); i < m2; ++i) {
|
|
449
|
+
link = links[i], bias[i] = count[link.source.index] / (count[link.source.index] + count[link.target.index]);
|
|
450
|
+
}
|
|
451
|
+
strengths = new Array(m2), initializeStrength();
|
|
452
|
+
distances = new Array(m2), initializeDistance();
|
|
453
|
+
}
|
|
454
|
+
function initializeStrength() {
|
|
455
|
+
if (!nodes) return;
|
|
456
|
+
for (var i = 0, n = links.length; i < n; ++i) {
|
|
457
|
+
strengths[i] = +strength(links[i], i, links);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
function initializeDistance() {
|
|
461
|
+
if (!nodes) return;
|
|
462
|
+
for (var i = 0, n = links.length; i < n; ++i) {
|
|
463
|
+
distances[i] = +distance(links[i], i, links);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
force.initialize = function(_nodes, _random) {
|
|
467
|
+
nodes = _nodes;
|
|
468
|
+
random = _random;
|
|
469
|
+
initialize();
|
|
470
|
+
};
|
|
471
|
+
force.links = function(_) {
|
|
472
|
+
return arguments.length ? (links = _, initialize(), force) : links;
|
|
473
|
+
};
|
|
474
|
+
force.id = function(_) {
|
|
475
|
+
return arguments.length ? (id = _, force) : id;
|
|
476
|
+
};
|
|
477
|
+
force.iterations = function(_) {
|
|
478
|
+
return arguments.length ? (iterations = +_, force) : iterations;
|
|
479
|
+
};
|
|
480
|
+
force.strength = function(_) {
|
|
481
|
+
return arguments.length ? (strength = typeof _ === "function" ? _ : constant_default(+_), initializeStrength(), force) : strength;
|
|
482
|
+
};
|
|
483
|
+
force.distance = function(_) {
|
|
484
|
+
return arguments.length ? (distance = typeof _ === "function" ? _ : constant_default(+_), initializeDistance(), force) : distance;
|
|
485
|
+
};
|
|
486
|
+
return force;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
// ../../node_modules/.pnpm/d3-dispatch@3.0.1/node_modules/d3-dispatch/src/dispatch.js
|
|
490
|
+
var noop = { value: () => {
|
|
491
|
+
} };
|
|
492
|
+
function dispatch() {
|
|
493
|
+
for (var i = 0, n = arguments.length, _ = {}, t; i < n; ++i) {
|
|
494
|
+
if (!(t = arguments[i] + "") || t in _ || /[\s.]/.test(t)) throw new Error("illegal type: " + t);
|
|
495
|
+
_[t] = [];
|
|
496
|
+
}
|
|
497
|
+
return new Dispatch(_);
|
|
498
|
+
}
|
|
499
|
+
function Dispatch(_) {
|
|
500
|
+
this._ = _;
|
|
501
|
+
}
|
|
502
|
+
function parseTypenames(typenames, types) {
|
|
503
|
+
return typenames.trim().split(/^|\s+/).map(function(t) {
|
|
504
|
+
var name = "", i = t.indexOf(".");
|
|
505
|
+
if (i >= 0) name = t.slice(i + 1), t = t.slice(0, i);
|
|
506
|
+
if (t && !types.hasOwnProperty(t)) throw new Error("unknown type: " + t);
|
|
507
|
+
return { type: t, name };
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
Dispatch.prototype = dispatch.prototype = {
|
|
511
|
+
constructor: Dispatch,
|
|
512
|
+
on: function(typename, callback) {
|
|
513
|
+
var _ = this._, T = parseTypenames(typename + "", _), t, i = -1, n = T.length;
|
|
514
|
+
if (arguments.length < 2) {
|
|
515
|
+
while (++i < n) if ((t = (typename = T[i]).type) && (t = get(_[t], typename.name))) return t;
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
if (callback != null && typeof callback !== "function") throw new Error("invalid callback: " + callback);
|
|
519
|
+
while (++i < n) {
|
|
520
|
+
if (t = (typename = T[i]).type) _[t] = set(_[t], typename.name, callback);
|
|
521
|
+
else if (callback == null) for (t in _) _[t] = set(_[t], typename.name, null);
|
|
522
|
+
}
|
|
523
|
+
return this;
|
|
524
|
+
},
|
|
525
|
+
copy: function() {
|
|
526
|
+
var copy = {}, _ = this._;
|
|
527
|
+
for (var t in _) copy[t] = _[t].slice();
|
|
528
|
+
return new Dispatch(copy);
|
|
529
|
+
},
|
|
530
|
+
call: function(type, that) {
|
|
531
|
+
if ((n = arguments.length - 2) > 0) for (var args = new Array(n), i = 0, n, t; i < n; ++i) args[i] = arguments[i + 2];
|
|
532
|
+
if (!this._.hasOwnProperty(type)) throw new Error("unknown type: " + type);
|
|
533
|
+
for (t = this._[type], i = 0, n = t.length; i < n; ++i) t[i].value.apply(that, args);
|
|
534
|
+
},
|
|
535
|
+
apply: function(type, that, args) {
|
|
536
|
+
if (!this._.hasOwnProperty(type)) throw new Error("unknown type: " + type);
|
|
537
|
+
for (var t = this._[type], i = 0, n = t.length; i < n; ++i) t[i].value.apply(that, args);
|
|
538
|
+
}
|
|
539
|
+
};
|
|
540
|
+
function get(type, name) {
|
|
541
|
+
for (var i = 0, n = type.length, c2; i < n; ++i) {
|
|
542
|
+
if ((c2 = type[i]).name === name) {
|
|
543
|
+
return c2.value;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
function set(type, name, callback) {
|
|
548
|
+
for (var i = 0, n = type.length; i < n; ++i) {
|
|
549
|
+
if (type[i].name === name) {
|
|
550
|
+
type[i] = noop, type = type.slice(0, i).concat(type.slice(i + 1));
|
|
551
|
+
break;
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
if (callback != null) type.push({ name, value: callback });
|
|
555
|
+
return type;
|
|
556
|
+
}
|
|
557
|
+
var dispatch_default = dispatch;
|
|
558
|
+
|
|
559
|
+
// ../../node_modules/.pnpm/d3-timer@3.0.1/node_modules/d3-timer/src/timer.js
|
|
560
|
+
var frame = 0;
|
|
561
|
+
var timeout = 0;
|
|
562
|
+
var interval = 0;
|
|
563
|
+
var pokeDelay = 1e3;
|
|
564
|
+
var taskHead;
|
|
565
|
+
var taskTail;
|
|
566
|
+
var clockLast = 0;
|
|
567
|
+
var clockNow = 0;
|
|
568
|
+
var clockSkew = 0;
|
|
569
|
+
var clock = typeof performance === "object" && performance.now ? performance : Date;
|
|
570
|
+
var setFrame = typeof window === "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function(f) {
|
|
571
|
+
setTimeout(f, 17);
|
|
572
|
+
};
|
|
573
|
+
function now() {
|
|
574
|
+
return clockNow || (setFrame(clearNow), clockNow = clock.now() + clockSkew);
|
|
575
|
+
}
|
|
576
|
+
function clearNow() {
|
|
577
|
+
clockNow = 0;
|
|
578
|
+
}
|
|
579
|
+
function Timer() {
|
|
580
|
+
this._call = this._time = this._next = null;
|
|
581
|
+
}
|
|
582
|
+
Timer.prototype = timer.prototype = {
|
|
583
|
+
constructor: Timer,
|
|
584
|
+
restart: function(callback, delay, time) {
|
|
585
|
+
if (typeof callback !== "function") throw new TypeError("callback is not a function");
|
|
586
|
+
time = (time == null ? now() : +time) + (delay == null ? 0 : +delay);
|
|
587
|
+
if (!this._next && taskTail !== this) {
|
|
588
|
+
if (taskTail) taskTail._next = this;
|
|
589
|
+
else taskHead = this;
|
|
590
|
+
taskTail = this;
|
|
591
|
+
}
|
|
592
|
+
this._call = callback;
|
|
593
|
+
this._time = time;
|
|
594
|
+
sleep();
|
|
595
|
+
},
|
|
596
|
+
stop: function() {
|
|
597
|
+
if (this._call) {
|
|
598
|
+
this._call = null;
|
|
599
|
+
this._time = Infinity;
|
|
600
|
+
sleep();
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
};
|
|
604
|
+
function timer(callback, delay, time) {
|
|
605
|
+
var t = new Timer();
|
|
606
|
+
t.restart(callback, delay, time);
|
|
607
|
+
return t;
|
|
608
|
+
}
|
|
609
|
+
function timerFlush() {
|
|
610
|
+
now();
|
|
611
|
+
++frame;
|
|
612
|
+
var t = taskHead, e;
|
|
613
|
+
while (t) {
|
|
614
|
+
if ((e = clockNow - t._time) >= 0) t._call.call(void 0, e);
|
|
615
|
+
t = t._next;
|
|
616
|
+
}
|
|
617
|
+
--frame;
|
|
618
|
+
}
|
|
619
|
+
function wake() {
|
|
620
|
+
clockNow = (clockLast = clock.now()) + clockSkew;
|
|
621
|
+
frame = timeout = 0;
|
|
622
|
+
try {
|
|
623
|
+
timerFlush();
|
|
624
|
+
} finally {
|
|
625
|
+
frame = 0;
|
|
626
|
+
nap();
|
|
627
|
+
clockNow = 0;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
function poke() {
|
|
631
|
+
var now2 = clock.now(), delay = now2 - clockLast;
|
|
632
|
+
if (delay > pokeDelay) clockSkew -= delay, clockLast = now2;
|
|
633
|
+
}
|
|
634
|
+
function nap() {
|
|
635
|
+
var t0, t1 = taskHead, t2, time = Infinity;
|
|
636
|
+
while (t1) {
|
|
637
|
+
if (t1._call) {
|
|
638
|
+
if (time > t1._time) time = t1._time;
|
|
639
|
+
t0 = t1, t1 = t1._next;
|
|
640
|
+
} else {
|
|
641
|
+
t2 = t1._next, t1._next = null;
|
|
642
|
+
t1 = t0 ? t0._next = t2 : taskHead = t2;
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
taskTail = t0;
|
|
646
|
+
sleep(time);
|
|
647
|
+
}
|
|
648
|
+
function sleep(time) {
|
|
649
|
+
if (frame) return;
|
|
650
|
+
if (timeout) timeout = clearTimeout(timeout);
|
|
651
|
+
var delay = time - clockNow;
|
|
652
|
+
if (delay > 24) {
|
|
653
|
+
if (time < Infinity) timeout = setTimeout(wake, time - clock.now() - clockSkew);
|
|
654
|
+
if (interval) interval = clearInterval(interval);
|
|
655
|
+
} else {
|
|
656
|
+
if (!interval) clockLast = clock.now(), interval = setInterval(poke, pokeDelay);
|
|
657
|
+
frame = 1, setFrame(wake);
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
// ../../node_modules/.pnpm/d3-force@3.0.0/node_modules/d3-force/src/lcg.js
|
|
662
|
+
var a = 1664525;
|
|
663
|
+
var c = 1013904223;
|
|
664
|
+
var m = 4294967296;
|
|
665
|
+
function lcg_default() {
|
|
666
|
+
let s = 1;
|
|
667
|
+
return () => (s = (a * s + c) % m) / m;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
// ../../node_modules/.pnpm/d3-force@3.0.0/node_modules/d3-force/src/simulation.js
|
|
671
|
+
function x2(d) {
|
|
672
|
+
return d.x;
|
|
673
|
+
}
|
|
674
|
+
function y2(d) {
|
|
675
|
+
return d.y;
|
|
676
|
+
}
|
|
677
|
+
var initialRadius = 10;
|
|
678
|
+
var initialAngle = Math.PI * (3 - Math.sqrt(5));
|
|
679
|
+
function simulation_default(nodes) {
|
|
680
|
+
var simulation, alpha = 1, alphaMin = 1e-3, alphaDecay = 1 - Math.pow(alphaMin, 1 / 300), alphaTarget = 0, velocityDecay = 0.6, forces = /* @__PURE__ */ new Map(), stepper = timer(step), event = dispatch_default("tick", "end"), random = lcg_default();
|
|
681
|
+
if (nodes == null) nodes = [];
|
|
682
|
+
function step() {
|
|
683
|
+
tick();
|
|
684
|
+
event.call("tick", simulation);
|
|
685
|
+
if (alpha < alphaMin) {
|
|
686
|
+
stepper.stop();
|
|
687
|
+
event.call("end", simulation);
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
function tick(iterations) {
|
|
691
|
+
var i, n = nodes.length, node;
|
|
692
|
+
if (iterations === void 0) iterations = 1;
|
|
693
|
+
for (var k = 0; k < iterations; ++k) {
|
|
694
|
+
alpha += (alphaTarget - alpha) * alphaDecay;
|
|
695
|
+
forces.forEach(function(force) {
|
|
696
|
+
force(alpha);
|
|
697
|
+
});
|
|
698
|
+
for (i = 0; i < n; ++i) {
|
|
699
|
+
node = nodes[i];
|
|
700
|
+
if (node.fx == null) node.x += node.vx *= velocityDecay;
|
|
701
|
+
else node.x = node.fx, node.vx = 0;
|
|
702
|
+
if (node.fy == null) node.y += node.vy *= velocityDecay;
|
|
703
|
+
else node.y = node.fy, node.vy = 0;
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
return simulation;
|
|
707
|
+
}
|
|
708
|
+
function initializeNodes() {
|
|
709
|
+
for (var i = 0, n = nodes.length, node; i < n; ++i) {
|
|
710
|
+
node = nodes[i], node.index = i;
|
|
711
|
+
if (node.fx != null) node.x = node.fx;
|
|
712
|
+
if (node.fy != null) node.y = node.fy;
|
|
713
|
+
if (isNaN(node.x) || isNaN(node.y)) {
|
|
714
|
+
var radius = initialRadius * Math.sqrt(0.5 + i), angle = i * initialAngle;
|
|
715
|
+
node.x = radius * Math.cos(angle);
|
|
716
|
+
node.y = radius * Math.sin(angle);
|
|
717
|
+
}
|
|
718
|
+
if (isNaN(node.vx) || isNaN(node.vy)) {
|
|
719
|
+
node.vx = node.vy = 0;
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
function initializeForce(force) {
|
|
724
|
+
if (force.initialize) force.initialize(nodes, random);
|
|
725
|
+
return force;
|
|
726
|
+
}
|
|
727
|
+
initializeNodes();
|
|
728
|
+
return simulation = {
|
|
729
|
+
tick,
|
|
730
|
+
restart: function() {
|
|
731
|
+
return stepper.restart(step), simulation;
|
|
732
|
+
},
|
|
733
|
+
stop: function() {
|
|
734
|
+
return stepper.stop(), simulation;
|
|
735
|
+
},
|
|
736
|
+
nodes: function(_) {
|
|
737
|
+
return arguments.length ? (nodes = _, initializeNodes(), forces.forEach(initializeForce), simulation) : nodes;
|
|
738
|
+
},
|
|
739
|
+
alpha: function(_) {
|
|
740
|
+
return arguments.length ? (alpha = +_, simulation) : alpha;
|
|
741
|
+
},
|
|
742
|
+
alphaMin: function(_) {
|
|
743
|
+
return arguments.length ? (alphaMin = +_, simulation) : alphaMin;
|
|
744
|
+
},
|
|
745
|
+
alphaDecay: function(_) {
|
|
746
|
+
return arguments.length ? (alphaDecay = +_, simulation) : +alphaDecay;
|
|
747
|
+
},
|
|
748
|
+
alphaTarget: function(_) {
|
|
749
|
+
return arguments.length ? (alphaTarget = +_, simulation) : alphaTarget;
|
|
750
|
+
},
|
|
751
|
+
velocityDecay: function(_) {
|
|
752
|
+
return arguments.length ? (velocityDecay = 1 - _, simulation) : 1 - velocityDecay;
|
|
753
|
+
},
|
|
754
|
+
randomSource: function(_) {
|
|
755
|
+
return arguments.length ? (random = _, forces.forEach(initializeForce), simulation) : random;
|
|
756
|
+
},
|
|
757
|
+
force: function(name, _) {
|
|
758
|
+
return arguments.length > 1 ? (_ == null ? forces.delete(name) : forces.set(name, initializeForce(_)), simulation) : forces.get(name);
|
|
759
|
+
},
|
|
760
|
+
find: function(x3, y3, radius) {
|
|
761
|
+
var i = 0, n = nodes.length, dx, dy, d2, node, closest;
|
|
762
|
+
if (radius == null) radius = Infinity;
|
|
763
|
+
else radius *= radius;
|
|
764
|
+
for (i = 0; i < n; ++i) {
|
|
765
|
+
node = nodes[i];
|
|
766
|
+
dx = x3 - node.x;
|
|
767
|
+
dy = y3 - node.y;
|
|
768
|
+
d2 = dx * dx + dy * dy;
|
|
769
|
+
if (d2 < radius) closest = node, radius = d2;
|
|
770
|
+
}
|
|
771
|
+
return closest;
|
|
772
|
+
},
|
|
773
|
+
on: function(name, _) {
|
|
774
|
+
return arguments.length > 1 ? (event.on(name, _), simulation) : event.on(name);
|
|
775
|
+
}
|
|
776
|
+
};
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
// ../../node_modules/.pnpm/d3-force@3.0.0/node_modules/d3-force/src/manyBody.js
|
|
780
|
+
function manyBody_default() {
|
|
781
|
+
var nodes, node, random, alpha, strength = constant_default(-30), strengths, distanceMin2 = 1, distanceMax2 = Infinity, theta2 = 0.81;
|
|
782
|
+
function force(_) {
|
|
783
|
+
var i, n = nodes.length, tree = quadtree(nodes, x2, y2).visitAfter(accumulate);
|
|
784
|
+
for (alpha = _, i = 0; i < n; ++i) node = nodes[i], tree.visit(apply);
|
|
785
|
+
}
|
|
786
|
+
function initialize() {
|
|
787
|
+
if (!nodes) return;
|
|
788
|
+
var i, n = nodes.length, node2;
|
|
789
|
+
strengths = new Array(n);
|
|
790
|
+
for (i = 0; i < n; ++i) node2 = nodes[i], strengths[node2.index] = +strength(node2, i, nodes);
|
|
791
|
+
}
|
|
792
|
+
function accumulate(quad) {
|
|
793
|
+
var strength2 = 0, q, c2, weight = 0, x3, y3, i;
|
|
794
|
+
if (quad.length) {
|
|
795
|
+
for (x3 = y3 = i = 0; i < 4; ++i) {
|
|
796
|
+
if ((q = quad[i]) && (c2 = Math.abs(q.value))) {
|
|
797
|
+
strength2 += q.value, weight += c2, x3 += c2 * q.x, y3 += c2 * q.y;
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
quad.x = x3 / weight;
|
|
801
|
+
quad.y = y3 / weight;
|
|
802
|
+
} else {
|
|
803
|
+
q = quad;
|
|
804
|
+
q.x = q.data.x;
|
|
805
|
+
q.y = q.data.y;
|
|
806
|
+
do
|
|
807
|
+
strength2 += strengths[q.data.index];
|
|
808
|
+
while (q = q.next);
|
|
809
|
+
}
|
|
810
|
+
quad.value = strength2;
|
|
811
|
+
}
|
|
812
|
+
function apply(quad, x1, _, x22) {
|
|
813
|
+
if (!quad.value) return true;
|
|
814
|
+
var x3 = quad.x - node.x, y3 = quad.y - node.y, w = x22 - x1, l = x3 * x3 + y3 * y3;
|
|
815
|
+
if (w * w / theta2 < l) {
|
|
816
|
+
if (l < distanceMax2) {
|
|
817
|
+
if (x3 === 0) x3 = jiggle_default(random), l += x3 * x3;
|
|
818
|
+
if (y3 === 0) y3 = jiggle_default(random), l += y3 * y3;
|
|
819
|
+
if (l < distanceMin2) l = Math.sqrt(distanceMin2 * l);
|
|
820
|
+
node.vx += x3 * quad.value * alpha / l;
|
|
821
|
+
node.vy += y3 * quad.value * alpha / l;
|
|
822
|
+
}
|
|
823
|
+
return true;
|
|
824
|
+
} else if (quad.length || l >= distanceMax2) return;
|
|
825
|
+
if (quad.data !== node || quad.next) {
|
|
826
|
+
if (x3 === 0) x3 = jiggle_default(random), l += x3 * x3;
|
|
827
|
+
if (y3 === 0) y3 = jiggle_default(random), l += y3 * y3;
|
|
828
|
+
if (l < distanceMin2) l = Math.sqrt(distanceMin2 * l);
|
|
829
|
+
}
|
|
830
|
+
do
|
|
831
|
+
if (quad.data !== node) {
|
|
832
|
+
w = strengths[quad.data.index] * alpha / l;
|
|
833
|
+
node.vx += x3 * w;
|
|
834
|
+
node.vy += y3 * w;
|
|
835
|
+
}
|
|
836
|
+
while (quad = quad.next);
|
|
837
|
+
}
|
|
838
|
+
force.initialize = function(_nodes, _random) {
|
|
839
|
+
nodes = _nodes;
|
|
840
|
+
random = _random;
|
|
841
|
+
initialize();
|
|
842
|
+
};
|
|
843
|
+
force.strength = function(_) {
|
|
844
|
+
return arguments.length ? (strength = typeof _ === "function" ? _ : constant_default(+_), initialize(), force) : strength;
|
|
845
|
+
};
|
|
846
|
+
force.distanceMin = function(_) {
|
|
847
|
+
return arguments.length ? (distanceMin2 = _ * _, force) : Math.sqrt(distanceMin2);
|
|
848
|
+
};
|
|
849
|
+
force.distanceMax = function(_) {
|
|
850
|
+
return arguments.length ? (distanceMax2 = _ * _, force) : Math.sqrt(distanceMax2);
|
|
851
|
+
};
|
|
852
|
+
force.theta = function(_) {
|
|
853
|
+
return arguments.length ? (theta2 = _ * _, force) : Math.sqrt(theta2);
|
|
854
|
+
};
|
|
855
|
+
return force;
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
// ../../node_modules/.pnpm/d3-force@3.0.0/node_modules/d3-force/src/x.js
|
|
859
|
+
function x_default2(x3) {
|
|
860
|
+
var strength = constant_default(0.1), nodes, strengths, xz;
|
|
861
|
+
if (typeof x3 !== "function") x3 = constant_default(x3 == null ? 0 : +x3);
|
|
862
|
+
function force(alpha) {
|
|
863
|
+
for (var i = 0, n = nodes.length, node; i < n; ++i) {
|
|
864
|
+
node = nodes[i], node.vx += (xz[i] - node.x) * strengths[i] * alpha;
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
function initialize() {
|
|
868
|
+
if (!nodes) return;
|
|
869
|
+
var i, n = nodes.length;
|
|
870
|
+
strengths = new Array(n);
|
|
871
|
+
xz = new Array(n);
|
|
872
|
+
for (i = 0; i < n; ++i) {
|
|
873
|
+
strengths[i] = isNaN(xz[i] = +x3(nodes[i], i, nodes)) ? 0 : +strength(nodes[i], i, nodes);
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
force.initialize = function(_) {
|
|
877
|
+
nodes = _;
|
|
878
|
+
initialize();
|
|
879
|
+
};
|
|
880
|
+
force.strength = function(_) {
|
|
881
|
+
return arguments.length ? (strength = typeof _ === "function" ? _ : constant_default(+_), initialize(), force) : strength;
|
|
882
|
+
};
|
|
883
|
+
force.x = function(_) {
|
|
884
|
+
return arguments.length ? (x3 = typeof _ === "function" ? _ : constant_default(+_), initialize(), force) : x3;
|
|
885
|
+
};
|
|
886
|
+
return force;
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
// ../../node_modules/.pnpm/d3-force@3.0.0/node_modules/d3-force/src/y.js
|
|
890
|
+
function y_default2(y3) {
|
|
891
|
+
var strength = constant_default(0.1), nodes, strengths, yz;
|
|
892
|
+
if (typeof y3 !== "function") y3 = constant_default(y3 == null ? 0 : +y3);
|
|
893
|
+
function force(alpha) {
|
|
894
|
+
for (var i = 0, n = nodes.length, node; i < n; ++i) {
|
|
895
|
+
node = nodes[i], node.vy += (yz[i] - node.y) * strengths[i] * alpha;
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
function initialize() {
|
|
899
|
+
if (!nodes) return;
|
|
900
|
+
var i, n = nodes.length;
|
|
901
|
+
strengths = new Array(n);
|
|
902
|
+
yz = new Array(n);
|
|
903
|
+
for (i = 0; i < n; ++i) {
|
|
904
|
+
strengths[i] = isNaN(yz[i] = +y3(nodes[i], i, nodes)) ? 0 : +strength(nodes[i], i, nodes);
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
force.initialize = function(_) {
|
|
908
|
+
nodes = _;
|
|
909
|
+
initialize();
|
|
910
|
+
};
|
|
911
|
+
force.strength = function(_) {
|
|
912
|
+
return arguments.length ? (strength = typeof _ === "function" ? _ : constant_default(+_), initialize(), force) : strength;
|
|
913
|
+
};
|
|
914
|
+
force.y = function(_) {
|
|
915
|
+
return arguments.length ? (y3 = typeof _ === "function" ? _ : constant_default(+_), initialize(), force) : y3;
|
|
916
|
+
};
|
|
917
|
+
return force;
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
// src/layout/force.ts
|
|
921
|
+
function seededRandom(seed) {
|
|
922
|
+
let state = seed >>> 0;
|
|
923
|
+
return () => {
|
|
924
|
+
state = state + 1831565813 >>> 0;
|
|
925
|
+
let t = state;
|
|
926
|
+
t = Math.imul(t ^ t >>> 15, t | 1);
|
|
927
|
+
t ^= t + Math.imul(t ^ t >>> 7, t | 61);
|
|
928
|
+
return ((t ^ t >>> 14) >>> 0) / 4294967296;
|
|
929
|
+
};
|
|
930
|
+
}
|
|
931
|
+
function forceLayout(nodes, edges, options = {}) {
|
|
932
|
+
const initial = options.initial instanceof Map ? options.initial : new Map(options.initial ?? []);
|
|
933
|
+
const scatter = seededRandom((options.seed ?? 1) * 7919);
|
|
934
|
+
const disk = Math.sqrt(nodes.length) * ((options.linkDistance ?? 36) * 0.9);
|
|
935
|
+
const simNodes = nodes.map((n2) => {
|
|
936
|
+
const start = initial.get(n2.id);
|
|
937
|
+
if (start) return { id: n2.id, r: n2.r ?? 6, x: start.x, y: start.y };
|
|
938
|
+
const angle = scatter() * Math.PI * 2;
|
|
939
|
+
const radius = Math.sqrt(scatter()) * disk;
|
|
940
|
+
return { id: n2.id, r: n2.r ?? 6, x: Math.cos(angle) * radius, y: Math.sin(angle) * radius };
|
|
941
|
+
});
|
|
942
|
+
const ids = new Set(simNodes.map((n2) => n2.id));
|
|
943
|
+
const links = edges.filter((e) => ids.has(e.from) && ids.has(e.to) && e.from !== e.to).map((e) => ({ source: e.from, target: e.to }));
|
|
944
|
+
const n = simNodes.length;
|
|
945
|
+
const iterations = options.iterations ?? (n > 1e3 ? 240 : 300);
|
|
946
|
+
const simulation = simulation_default(simNodes).randomSource(seededRandom(options.seed ?? 1)).alphaDecay(1 - Math.pow(1e-3, 1 / iterations)).force(
|
|
947
|
+
"link",
|
|
948
|
+
link_default(links).id((d) => d.id).distance(options.linkDistance ?? 36).strength(0.6)
|
|
949
|
+
).force("charge", manyBody_default().strength(options.charge ?? -40).theta(0.9)).force("collide", collide_default((d) => d.r + (options.collidePadding ?? 2)).iterations(options.collideIterations ?? 1)).force("x", x_default2(0).strength(0.04)).force("y", y_default2(0).strength(0.04)).stop();
|
|
950
|
+
for (let i = 0; i < iterations; i++) simulation.tick();
|
|
951
|
+
const positions = /* @__PURE__ */ new Map();
|
|
952
|
+
for (const node of simNodes) positions.set(node.id, { x: Math.round(node.x * 10) / 10, y: Math.round(node.y * 10) / 10 });
|
|
953
|
+
return positions;
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
// src/layout/layered.ts
|
|
957
|
+
function layeredLayout(nodes, edges, options = {}) {
|
|
958
|
+
const layerGap = options.layerGap ?? 220;
|
|
959
|
+
const nodeGap = options.nodeGap ?? 84;
|
|
960
|
+
const sweeps = options.sweeps ?? 6;
|
|
961
|
+
const ids = nodes.map((n) => n.id);
|
|
962
|
+
const known = new Set(ids);
|
|
963
|
+
const out = new Map(ids.map((id) => [id, []]));
|
|
964
|
+
const incoming = new Map(ids.map((id) => [id, []]));
|
|
965
|
+
for (const { from, to } of edges) {
|
|
966
|
+
if (!known.has(from) || !known.has(to) || from === to) continue;
|
|
967
|
+
out.get(from).push(to);
|
|
968
|
+
incoming.get(to).push(from);
|
|
969
|
+
}
|
|
970
|
+
const layer = new Map(ids.map((id) => [id, 0]));
|
|
971
|
+
const remaining = new Map(ids.map((id) => [id, incoming.get(id).length]));
|
|
972
|
+
const queue = ids.filter((id) => remaining.get(id) === 0);
|
|
973
|
+
const acyclicOut = new Map(ids.map((id) => [id, []]));
|
|
974
|
+
for (let i = 0; i < queue.length; i++) {
|
|
975
|
+
const id = queue[i];
|
|
976
|
+
for (const to of out.get(id)) {
|
|
977
|
+
layer.set(to, Math.max(layer.get(to), layer.get(id) + 1));
|
|
978
|
+
acyclicOut.get(id).push(to);
|
|
979
|
+
remaining.set(to, remaining.get(to) - 1);
|
|
980
|
+
if (remaining.get(to) === 0) queue.push(to);
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
const layers = [];
|
|
984
|
+
for (const id of ids) {
|
|
985
|
+
const l = layer.get(id);
|
|
986
|
+
(layers[l] ??= []).push(id);
|
|
987
|
+
}
|
|
988
|
+
const predecessors = new Map(ids.map((id) => [id, []]));
|
|
989
|
+
for (const [from, tos] of acyclicOut) for (const to of tos) predecessors.get(to).push(from);
|
|
990
|
+
const position = /* @__PURE__ */ new Map();
|
|
991
|
+
const index2 = () => layers.forEach((members) => members.forEach((id, i) => position.set(id, i)));
|
|
992
|
+
index2();
|
|
993
|
+
const barycentre = (neighbours, fallback) => neighbours.length === 0 ? fallback : neighbours.reduce((sum, n) => sum + position.get(n), 0) / neighbours.length;
|
|
994
|
+
for (let sweep = 0; sweep < sweeps; sweep++) {
|
|
995
|
+
const down = sweep % 2 === 0;
|
|
996
|
+
const order = down ? layers.slice(1) : layers.slice(0, -1).reverse();
|
|
997
|
+
for (const members of order) {
|
|
998
|
+
const keyed = members.map((id, i) => ({
|
|
999
|
+
id,
|
|
1000
|
+
i,
|
|
1001
|
+
key: barycentre(down ? predecessors.get(id) : acyclicOut.get(id), position.get(id))
|
|
1002
|
+
}));
|
|
1003
|
+
keyed.sort((a2, z) => a2.key - z.key || a2.i - z.i);
|
|
1004
|
+
members.splice(0, members.length, ...keyed.map((k) => k.id));
|
|
1005
|
+
members.forEach((id, i) => position.set(id, i));
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
const positions = /* @__PURE__ */ new Map();
|
|
1009
|
+
layers.forEach((members, l) => {
|
|
1010
|
+
members.forEach((id, i) => positions.set(id, { x: l * layerGap, y: (i - (members.length - 1) / 2) * nodeGap }));
|
|
1011
|
+
});
|
|
1012
|
+
return positions;
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
// src/layout/index.ts
|
|
1016
|
+
function runLayoutRequest(request) {
|
|
1017
|
+
return request.algorithm === "layered" ? layeredLayout(request.nodes, request.edges, request.options) : forceLayout(request.nodes, request.edges, request.options);
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
// src/layout/runner.ts
|
|
1021
|
+
function encodePositions(positions) {
|
|
1022
|
+
const ids = [...positions.keys()];
|
|
1023
|
+
const coords = new Float64Array(ids.length * 2);
|
|
1024
|
+
ids.forEach((id, i) => {
|
|
1025
|
+
const p = positions.get(id);
|
|
1026
|
+
coords[i * 2] = p.x;
|
|
1027
|
+
coords[i * 2 + 1] = p.y;
|
|
1028
|
+
});
|
|
1029
|
+
return { ids, coords };
|
|
1030
|
+
}
|
|
1031
|
+
function serveLayoutRequests(port) {
|
|
1032
|
+
const listener = (event) => {
|
|
1033
|
+
const { id, request } = event.data;
|
|
1034
|
+
try {
|
|
1035
|
+
const { ids, coords } = encodePositions(runLayoutRequest(request));
|
|
1036
|
+
port.postMessage({ id, ids, coords });
|
|
1037
|
+
} catch (error) {
|
|
1038
|
+
port.postMessage({ id, error: error instanceof Error ? error.message : String(error) });
|
|
1039
|
+
}
|
|
1040
|
+
};
|
|
1041
|
+
port.addEventListener("message", listener);
|
|
1042
|
+
return () => port.removeEventListener("message", listener);
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
// src/layout-worker.ts
|
|
1046
|
+
if (typeof self !== "undefined" && typeof self.postMessage === "function") serveLayoutRequests(self);
|
|
1047
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1048
|
+
0 && (module.exports = {
|
|
1049
|
+
serveLayoutRequests
|
|
1050
|
+
});
|
|
1051
|
+
//# sourceMappingURL=layout-worker.cjs.map
|