@fusion.dev/helix-graph 0.177.2 → 0.178.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.
@@ -93,6 +93,7 @@ export const connectGraph = (frame, driver, options = {}) => {
93
93
  ?.trim()
94
94
  .replace(/^["']|["']$/g, ''),
95
95
  groups: nodes.flatMap((node) => (node.group === undefined ? [] : [node.group])),
96
+ keyed: graph.keyed?.id,
96
97
  links: links.length,
97
98
  near: reached?.near ?? new Set(),
98
99
  noteOf: (id) => notes.get(id),
@@ -292,6 +293,18 @@ export const connectGraph = (frame, driver, options = {}) => {
292
293
  }
293
294
  pressed = undefined;
294
295
  };
296
+ let keyedShown;
297
+ const showKeyed = () => {
298
+ const keyed = graph.keyed;
299
+ const id = keyed?.id;
300
+ if (id !== keyedShown &&
301
+ keyed?.walked &&
302
+ drawnNodes.has(keyed.id) &&
303
+ options.center !== false) {
304
+ driver.center?.(keyed.id, !still());
305
+ }
306
+ keyedShown = id;
307
+ };
295
308
  const handlePartChange = (event) => {
296
309
  const { kind } = event.detail;
297
310
  if (kind === 'data') {
@@ -301,6 +314,7 @@ export const connectGraph = (frame, driver, options = {}) => {
301
314
  else if (kind === 'focus') {
302
315
  restyle();
303
316
  frameSelection();
317
+ showKeyed();
304
318
  }
305
319
  else {
306
320
  driver.gestures?.(graph.gestureMode ?? 'free');
@@ -67,6 +67,12 @@ export interface NodeLook {
67
67
  glow: number;
68
68
  /** What it is drawn as made of, where the note says. */
69
69
  material?: 'frosted' | 'glass' | undefined;
70
+ /**
71
+ * The note the keys are on in the frame's list or search field, which a
72
+ * renderer marks as it marks the note under the pointer, so a reader moving
73
+ * by the keys sees where they are in the drawing.
74
+ */
75
+ keyed?: boolean | undefined;
70
76
  /** Drawn over the rest, as the selected note and its neighbors are. */
71
77
  raised: boolean;
72
78
  /** The selected note. */
@@ -105,6 +111,8 @@ export interface GraphLooks {
105
111
  ground: string;
106
112
  /** The color the labels are drawn in. */
107
113
  ink: string;
114
+ /** The note the keys are on in the frame's list or search field, which a renderer marks as it marks the note under the pointer. */
115
+ keyed?: string | undefined;
108
116
  /** What a name is drawn on while the pointer is over its note. */
109
117
  overlay: string;
110
118
  /** The quieter ink a name at rest is drawn in, beside the selected note's and its neighbors'. */
@@ -136,6 +144,8 @@ export declare const looksOf: (options: {
136
144
  colors: GraphColors;
137
145
  font?: string | undefined;
138
146
  groups: readonly string[];
147
+ /** The note the keys are on in the frame's list or search field, where they are on one. */
148
+ keyed?: string | undefined;
139
149
  /** How many links the graph draws, which sets how far a link at rest steps back. */
140
150
  links?: number | undefined;
141
151
  near: ReadonlySet<string>;
@@ -64,7 +64,7 @@ export const toneColor = (colors, tone) => tone === undefined || tone === 'prima
64
64
  : colors[tone];
65
65
  const FADED = 0.75;
66
66
  export const looksOf = (options) => {
67
- const { colors, near, noteOf, selected, shown } = options;
67
+ const { colors, keyed, near, noteOf, selected, shown } = options;
68
68
  const order = new Map([...new Set(options.groups)].sort().map((group, at) => [group, at]));
69
69
  const own = (id) => {
70
70
  const note = noteOf(id);
@@ -87,6 +87,7 @@ export const looksOf = (options) => {
87
87
  font: options.font || 'sans-serif',
88
88
  ground: colors.ground,
89
89
  ink: colors.ink,
90
+ keyed,
90
91
  link: (source, target) => {
91
92
  const touches = focused &&
92
93
  (options.along ? options.along(source, target) : source === selected || target === selected);
@@ -109,19 +110,22 @@ export const looksOf = (options) => {
109
110
  color: own(id),
110
111
  glow: 1,
111
112
  hidden: hidden(id),
113
+ keyed: id === keyed,
112
114
  label: 'always',
113
115
  raised: true,
114
116
  selected: true,
115
117
  };
116
118
  }
117
119
  const neighbor = focused && near.has(id);
120
+ const faded = focused && !neighbor && id !== keyed;
118
121
  return {
119
122
  ...facts,
120
- color: focused && !neighbor ? mixRgb(own(id), colors.ground, FADED) : own(id),
123
+ color: faded ? mixRgb(own(id), colors.ground, FADED) : own(id),
121
124
  glow: 0,
122
125
  hidden: hidden(id),
123
- label: focused && !neighbor ? 'never' : 'room',
124
- raised: neighbor,
126
+ keyed: id === keyed,
127
+ label: id === keyed ? 'always' : faded ? 'never' : 'room',
128
+ raised: neighbor || id === keyed,
125
129
  selected: false,
126
130
  };
127
131
  },
@@ -262,6 +262,7 @@ export const sigmaDriver = (sigma, options = {}) => {
262
262
  forceLabel: look.label === 'always',
263
263
  glow: look.glow,
264
264
  hidden: look.hidden,
265
+ highlighted: look.keyed === true,
265
266
  label: named ? data.label : null,
266
267
  materialCode: MATERIALS[look.material ?? options.material ?? 'flat'],
267
268
  shapeCode: SHAPES[look.shape ?? options.shape ?? 'circle'],
@@ -273,10 +274,11 @@ export const sigmaDriver = (sigma, options = {}) => {
273
274
  });
274
275
  sigma.setSetting('edgeReducer', (_edge, data) => {
275
276
  const look = looks.link(String(data.from), String(data.to));
276
- const lit = hovered !== undefined && (data.from === hovered || data.to === hovered);
277
+ const near = hovered ?? looks.keyed;
278
+ const lit = near !== undefined && (data.from === near || data.to === near);
277
279
  return {
278
280
  ...data,
279
- color: lit ? looks.node(hovered).color : look.color,
281
+ color: lit ? looks.node(near).color : look.color,
280
282
  hidden: look.hidden,
281
283
  size: look.raised || lit ? 1.6 : 0.8,
282
284
  zIndex: look.raised || lit ? 1 : 0,
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.177.2",
4
+ "version": "0.178.0",
5
5
  "license": "MIT",
6
6
  "author": "Ross Sheppard <ross.sheppard@fusion.dev>",
7
7
  "repository": {
@@ -55,12 +55,12 @@
55
55
  },
56
56
  "bugs": "https://github.com/project-fusion/fusion/issues",
57
57
  "dependencies": {
58
- "@fusion.dev/helix-core": "0.177.2"
58
+ "@fusion.dev/helix-core": "0.178.0"
59
59
  },
60
60
  "devDependencies": {
61
61
  "@cosmos.gl/graph": "^3.4.2",
62
- "@fusion.dev/helix-headless": "0.177.2",
63
- "@fusion.dev/helix-testing": "0.177.2",
62
+ "@fusion.dev/helix-headless": "0.178.0",
63
+ "@fusion.dev/helix-testing": "0.178.0",
64
64
  "@types/bun": "^1.4.2",
65
65
  "@types/three": "^0.186.0",
66
66
  "d3-force-3d": "^3.0.6",