@fusion.dev/helix-graph 0.235.1 → 0.237.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.
@@ -242,6 +242,8 @@ export const connectGraph = (frame, driver, options = {}) => {
242
242
  if (owed) {
243
243
  owed = false;
244
244
  ready();
245
+ framed = undefined;
246
+ frameSelection();
245
247
  }
246
248
  });
247
249
  const stop = stopSettling;
@@ -40,6 +40,12 @@ export interface GraphColors {
40
40
  * **Not yet rather than never.** A stylesheet being swapped takes the tokens
41
41
  * away for a moment, which is `null` here, and the connector asks again on the
42
42
  * next change.
43
+ *
44
+ * **A see-through token is laid over the ground**, the color it is seen as in
45
+ * the drawing. A theme may write its border as white at 12%, as the Fusion
46
+ * site does, and an opaque reading refused it: the colors never arrived, and
47
+ * the Cortex trace drew every note in the renderer's own gray, its chosen
48
+ * answer unlit and its groups unnamed.
43
49
  */
44
50
  export declare const graphColorsFrom: (element: Element) => GraphColors | null;
45
51
  /** An `rgb()` color's red, green and blue, from 0 to 255, each `missing` where the color does not say. */
@@ -1,4 +1,4 @@
1
- import { readColor } from '@fusion.dev/helix-core';
1
+ import { readColorAlpha } from '@fusion.dev/helix-core';
2
2
  const SERIES = 24;
3
3
  const TOKENS = {
4
4
  accent: '--helix-color-accent',
@@ -22,13 +22,22 @@ export const graphColorsFrom = (element) => {
22
22
  probe.setAttribute('aria-hidden', 'true');
23
23
  element.append(probe);
24
24
  try {
25
- const read = (token) => {
25
+ const bytesOf = (token) => {
26
26
  if (getComputedStyle(probe).getPropertyValue(token).trim() === '') {
27
27
  return null;
28
28
  }
29
29
  probe.style.color = `var(${token})`;
30
- const bytes = readColor(getComputedStyle(probe).color);
31
- return bytes ? `rgb(${bytes[0]}, ${bytes[1]}, ${bytes[2]})` : null;
30
+ return readColorAlpha(getComputedStyle(probe).color) ?? null;
31
+ };
32
+ const ground = bytesOf(TOKENS.ground);
33
+ const read = (token) => {
34
+ const bytes = bytesOf(token);
35
+ if (!bytes || !ground) {
36
+ return null;
37
+ }
38
+ const [red, green, blue, alpha] = bytes;
39
+ const over = (one, under) => Math.round(one * alpha + under * (1 - alpha));
40
+ return `rgb(${over(red, ground[0])}, ${over(green, ground[1])}, ${over(blue, ground[2])})`;
32
41
  };
33
42
  const named = Object.fromEntries(Object.entries(TOKENS).map(([name, token]) => [name, read(token)]));
34
43
  if (Object.values(named).some((one) => one === null)) {
@@ -62,7 +71,7 @@ export const toneColor = (colors, tone) => tone === undefined || tone === 'prima
62
71
  : tone === 'neutral'
63
72
  ? colors.muted
64
73
  : colors[tone];
65
- const FADED = 0.75;
74
+ const FADED = 0.6;
66
75
  export const looksOf = (options) => {
67
76
  const { colors, keyed, near, noteOf, selected, shown } = options;
68
77
  const order = new Map([...new Set(options.groups)].sort().map((group, at) => [group, at]));
@@ -8,6 +8,11 @@
8
8
  * The square root, so a note with a hundred links is not ten times the size
9
9
  * of one with ten, and no larger than a note with thirty-six, so a hub with
10
10
  * thousands does not cover its own region.
11
+ *
12
+ * **A note with no links is as large as one with a single link.** Sized by its
13
+ * none it drew a dot under 6 pixels across, in the muted ink of a note in no
14
+ * group, which read as a speck on the ground and not as a note: a note alone
15
+ * is still a note, and the reader came to the graph to find it.
11
16
  */
12
17
  export declare const sizeOf: (size: number | undefined, links: number) => number;
13
18
  /** A note's drawn radius in pixels, from its relative size: a leaf about four, a busy hub about nine. */
@@ -1,2 +1,2 @@
1
- export const sizeOf = (size, links) => Number.isFinite(size) ? size : 1 + Math.min(Math.sqrt(links), 6);
1
+ export const sizeOf = (size, links) => Number.isFinite(size) ? size : 1 + Math.min(Math.sqrt(Math.max(links, 1)), 6);
2
2
  export const pixelsOf = (size) => 1.6 + 1.35 * Math.max(size, 0);
@@ -8,6 +8,7 @@ const MORPH = 1400;
8
8
  const ZOOM = 1.5;
9
9
  const SAMPLE = 24;
10
10
  const pixels = (size) => 0.5 * (1.6 + 1.35 * Math.max(size, 0));
11
+ const floorOf = (count) => Math.min(3, 3 * Math.sqrt(250 / Math.max(count, 1)));
11
12
  const CLUSTER = 0.1;
12
13
  const FOLLOW = 1000;
13
14
  const PADDING = 0.08;
@@ -233,6 +234,9 @@ export const cosmosDriver = (graph, container, options = {}) => {
233
234
  index = new Map(ids.map((id, at) => [id, at]));
234
235
  drawnNow = new Map(nodes.map((node) => [node.id, node]));
235
236
  sizes = nodes.map((node) => pixels(node.size));
237
+ const least = sizes.reduce((low, size) => Math.min(low, size), Infinity);
238
+ const lift = Math.max(1, floorOf(nodes.length) / least);
239
+ sizes = sizes.map((size) => size * lift);
236
240
  hovered = undefined;
237
241
  links = next.filter((link) => index.has(link.source) && index.has(link.target));
238
242
  linksOf = new Map();
@@ -290,8 +290,8 @@ export const clearOf = (box, others) => others.every((other) => box.right < othe
290
290
  box.bottom < other.top ||
291
291
  box.top > other.bottom);
292
292
  export const nameStart = (at, width, box, avoid, room, rightToLeft = false) => {
293
- const right = at.x + at.radius + 4;
294
- const left = at.x - at.radius - 4 - width;
293
+ const right = at.x + at.radius + 8;
294
+ const left = at.x - at.radius - 8 - width;
295
295
  const [after, before] = rightToLeft ? [left, right] : [right, left];
296
296
  const fits = (start) => {
297
297
  const placed = box(start);
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.235.1",
4
+ "version": "0.237.0",
5
5
  "license": "MIT",
6
6
  "author": "Fusion Development Group",
7
7
  "repository": {
@@ -60,12 +60,12 @@
60
60
  },
61
61
  "bugs": "https://github.com/project-fusion/fusion/issues",
62
62
  "dependencies": {
63
- "@fusion.dev/helix-core": "0.235.1"
63
+ "@fusion.dev/helix-core": "0.237.0"
64
64
  },
65
65
  "devDependencies": {
66
66
  "@cosmos.gl/graph": "^3.5.1",
67
- "@fusion.dev/helix-headless": "0.235.1",
68
- "@fusion.dev/helix-testing": "0.235.1",
67
+ "@fusion.dev/helix-headless": "0.237.0",
68
+ "@fusion.dev/helix-testing": "0.237.0",
69
69
  "@luma.gl/core": "~9.3.6",
70
70
  "@luma.gl/engine": "~9.3.6",
71
71
  "@luma.gl/shadertools": "~9.3.6",