@fusion.dev/helix-graph 0.128.1 → 0.129.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.
|
@@ -15,8 +15,9 @@ export type { DrawnLink, DrawnNode, GraphChanges } from './diff.js';
|
|
|
15
15
|
*/
|
|
16
16
|
export interface GraphDriver {
|
|
17
17
|
/**
|
|
18
|
-
* Draws the graph, replacing whatever was drawn, where each note is
|
|
19
|
-
*
|
|
18
|
+
* Draws the graph whole, replacing whatever was drawn, where each note is
|
|
19
|
+
* placed, and frames it: the first drawing, a graph the page replaced with
|
|
20
|
+
* one that shares no note, or every change for a driver without `update`.
|
|
20
21
|
*/
|
|
21
22
|
draw(graph: {
|
|
22
23
|
links: DrawnLink[];
|
|
@@ -66,6 +66,7 @@ export const connectGraph = (frame, driver, options = {}) => {
|
|
|
66
66
|
?.trim()
|
|
67
67
|
.replace(/^["']|["']$/g, ''),
|
|
68
68
|
groups: nodes.flatMap((node) => (node.group === undefined ? [] : [node.group])),
|
|
69
|
+
links: links.length,
|
|
69
70
|
near,
|
|
70
71
|
noteOf: (id) => notes.get(id),
|
|
71
72
|
selected,
|
|
@@ -103,6 +104,12 @@ export const connectGraph = (frame, driver, options = {}) => {
|
|
|
103
104
|
cancelAnimationFrame(pending);
|
|
104
105
|
const nodes = graph.nodes ?? [];
|
|
105
106
|
const ids = new Set(nodes.map((node) => node.id));
|
|
107
|
+
if (!first &&
|
|
108
|
+
drawnNodes.size > 0 &&
|
|
109
|
+
ids.size > 0 &&
|
|
110
|
+
![...ids].some((id) => drawnNodes.has(id))) {
|
|
111
|
+
whole = true;
|
|
112
|
+
}
|
|
106
113
|
const nextLinks = new Map();
|
|
107
114
|
for (const { label, source, target } of graph.links ?? []) {
|
|
108
115
|
if (source !== target && ids.has(source) && ids.has(target)) {
|
|
@@ -131,6 +131,8 @@ export declare const looksOf: (options: {
|
|
|
131
131
|
colors: GraphColors;
|
|
132
132
|
font?: string | undefined;
|
|
133
133
|
groups: readonly string[];
|
|
134
|
+
/** How many links the graph draws, which sets how far a link at rest steps back. */
|
|
135
|
+
links?: number | undefined;
|
|
134
136
|
near: ReadonlySet<string>;
|
|
135
137
|
noteOf: (id: string) => NoteFacts | undefined;
|
|
136
138
|
selected: string | undefined;
|
|
@@ -79,6 +79,9 @@ export const looksOf = (options) => {
|
|
|
79
79
|
};
|
|
80
80
|
const focused = selected !== undefined;
|
|
81
81
|
const hidden = (id) => shown !== undefined && !shown.has(id);
|
|
82
|
+
const count = options.links ?? 2000;
|
|
83
|
+
const along = Math.min(Math.max(Math.log(count / 50) / Math.log(2000 / 50), 0), 1);
|
|
84
|
+
const rest = 0.35 + (0.72 - 0.35) * along;
|
|
82
85
|
return {
|
|
83
86
|
colorOf: own,
|
|
84
87
|
font: options.font || 'sans-serif',
|
|
@@ -91,7 +94,7 @@ export const looksOf = (options) => {
|
|
|
91
94
|
? own(selected)
|
|
92
95
|
: focused
|
|
93
96
|
? mixRgb(colors.line, colors.ground, 0.6)
|
|
94
|
-
: mixRgb(own(source), colors.ground,
|
|
97
|
+
: mixRgb(own(source), colors.ground, rest),
|
|
95
98
|
hidden: hidden(source) || hidden(target),
|
|
96
99
|
raised: touches,
|
|
97
100
|
};
|
|
@@ -176,6 +176,7 @@ export const sigmaDriver = (sigma, options = {}) => {
|
|
|
176
176
|
},
|
|
177
177
|
draw: ({ links, nodes }) => {
|
|
178
178
|
graph.clear();
|
|
179
|
+
camera.setState({ ratio: 1, x: 0.5, y: 0.5 });
|
|
179
180
|
for (const node of nodes) {
|
|
180
181
|
graph.addNode(node.id, {
|
|
181
182
|
label: node.label,
|
|
@@ -238,7 +239,7 @@ export const sigmaDriver = (sigma, options = {}) => {
|
|
|
238
239
|
sigma.setSetting('minEdgeThickness', 0.8);
|
|
239
240
|
sigma.setSetting('labelFont', looks.font);
|
|
240
241
|
sigma.setSetting('labelRenderedSizeThreshold', 0);
|
|
241
|
-
sigma.setSetting('labelGridCellSize', 130);
|
|
242
|
+
sigma.setSetting('labelGridCellSize', naming === 'all' ? 8 : 130);
|
|
242
243
|
sigma.setSetting('defaultDrawNodeLabel', labelOf(looks, claim, (at, width, box) => nameStart(at, width, box, taken, container.clientWidth)));
|
|
243
244
|
sigma.setSetting('defaultDrawNodeHover', hoverOf(looks));
|
|
244
245
|
sigma.setSetting('nodeReducer', (node, data) => {
|
|
@@ -389,7 +390,7 @@ export const sigmaDriver = (sigma, options = {}) => {
|
|
|
389
390
|
const layout = make(graph);
|
|
390
391
|
layout.start();
|
|
391
392
|
const limit = options.layoutLimit ?? 10000;
|
|
392
|
-
|
|
393
|
+
let started = performance.now();
|
|
393
394
|
let last = positionsOf(graph);
|
|
394
395
|
let done = false;
|
|
395
396
|
let moving = false;
|
|
@@ -407,7 +408,20 @@ export const sigmaDriver = (sigma, options = {}) => {
|
|
|
407
408
|
});
|
|
408
409
|
placed(positionsOf(graph));
|
|
409
410
|
};
|
|
411
|
+
let paused = false;
|
|
410
412
|
const timer = setInterval(() => {
|
|
413
|
+
if (!container.isConnected) {
|
|
414
|
+
if (!paused) {
|
|
415
|
+
paused = true;
|
|
416
|
+
layout.stop();
|
|
417
|
+
}
|
|
418
|
+
started += SAMPLE;
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
if (paused) {
|
|
422
|
+
paused = false;
|
|
423
|
+
layout.start();
|
|
424
|
+
}
|
|
411
425
|
const now = positionsOf(graph);
|
|
412
426
|
let moved = 0;
|
|
413
427
|
let low = Number.POSITIVE_INFINITY;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fusion.dev/helix-graph",
|
|
3
3
|
"description": "Connects the Helix Graph frame to a graph renderer: Sigma.js, cosmos.gl, three.js, or a driver of your own.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.129.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Ross Sheppard <ross.sheppard@fusion.dev>",
|
|
7
7
|
"repository": {
|
|
@@ -51,12 +51,12 @@
|
|
|
51
51
|
},
|
|
52
52
|
"bugs": "https://github.com/project-fusion/fusion/issues",
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@fusion.dev/helix-core": "0.
|
|
54
|
+
"@fusion.dev/helix-core": "0.129.1"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@cosmos.gl/graph": "^3.4.2",
|
|
58
|
-
"@fusion.dev/helix-headless": "0.
|
|
59
|
-
"@fusion.dev/helix-testing": "0.
|
|
58
|
+
"@fusion.dev/helix-headless": "0.129.1",
|
|
59
|
+
"@fusion.dev/helix-testing": "0.129.1",
|
|
60
60
|
"@types/bun": "^1.3.0",
|
|
61
61
|
"@types/three": "^0.186.0",
|
|
62
62
|
"d3-force-3d": "^3.0.6",
|