@opendata-ai/openchart-vanilla 8.9.1 → 9.0.0-rc.2

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.
Files changed (51) hide show
  1. package/README.md +4 -4
  2. package/dist/{chunk-REH5UQCL.js → chunk-46E3QB6O.js} +6 -20
  3. package/dist/chunk-46E3QB6O.js.map +1 -0
  4. package/dist/{chunk-APMUBW72.js → chunk-5OQZRGUL.js} +1565 -294
  5. package/dist/chunk-5OQZRGUL.js.map +1 -0
  6. package/dist/{chunk-GX6BWMJD.js → chunk-5ZLSMZRM.js} +466 -330
  7. package/dist/chunk-5ZLSMZRM.js.map +1 -0
  8. package/dist/{chunk-SDJHUELU.js → chunk-A5C4VCUO.js} +26 -45
  9. package/dist/chunk-A5C4VCUO.js.map +1 -0
  10. package/dist/{chunk-MGFXAROR.js → chunk-CMIJA63X.js} +5 -3
  11. package/dist/chunk-CMIJA63X.js.map +1 -0
  12. package/dist/chunk-FFP5GXIP.js +45 -0
  13. package/dist/chunk-FFP5GXIP.js.map +1 -0
  14. package/dist/{chunk-Q7YEEF2X.js → chunk-LDSPJFOU.js} +16 -50
  15. package/dist/chunk-LDSPJFOU.js.map +1 -0
  16. package/dist/chunk-NLKQ5AOA.js +448 -0
  17. package/dist/chunk-NLKQ5AOA.js.map +1 -0
  18. package/dist/{chunk-R5TZHNTG.js → chunk-RBXIZJPE.js} +17 -5
  19. package/dist/chunk-RBXIZJPE.js.map +1 -0
  20. package/dist/{chunk-CCRFYGHU.js → chunk-RY5JEGFM.js} +2368 -2339
  21. package/dist/chunk-RY5JEGFM.js.map +1 -0
  22. package/dist/export-gif.d.ts +2 -2
  23. package/dist/export-gif.js +4 -3
  24. package/dist/graph-3d/index.d.ts +28 -1
  25. package/dist/graph-3d/index.js +26 -12
  26. package/dist/graph-3d/index.js.map +1 -1
  27. package/dist/index.d.ts +155 -29
  28. package/dist/index.js +1774 -186
  29. package/dist/index.js.map +1 -1
  30. package/dist/{mount-TEjIdF0m.d.ts → mount-types-DeUCa2hy.d.ts} +34 -21
  31. package/dist/{renderer-registry-Cng76n8F.d.ts → renderer-registry-Bu22Roek.d.ts} +5 -22
  32. package/dist/simulation-worker.js +27 -26
  33. package/dist/static.d.ts +4 -2
  34. package/dist/static.js +34 -10
  35. package/dist/static.js.map +1 -1
  36. package/dist/story/index.d.ts +8 -6
  37. package/dist/story/index.js +15 -12
  38. package/dist/story/index.js.map +1 -1
  39. package/dist/styles.css +1 -1
  40. package/dist/styles.css.map +1 -1
  41. package/package.json +3 -3
  42. package/dist/chunk-APMUBW72.js.map +0 -1
  43. package/dist/chunk-CCRFYGHU.js.map +0 -1
  44. package/dist/chunk-GX6BWMJD.js.map +0 -1
  45. package/dist/chunk-MGFXAROR.js.map +0 -1
  46. package/dist/chunk-Q7YEEF2X.js.map +0 -1
  47. package/dist/chunk-R5TZHNTG.js.map +0 -1
  48. package/dist/chunk-REH5UQCL.js.map +0 -1
  49. package/dist/chunk-SDJHUELU.js.map +0 -1
  50. package/dist/chunk-UC4IHEUO.js +0 -73
  51. package/dist/chunk-UC4IHEUO.js.map +0 -1
@@ -7,11 +7,16 @@ import {
7
7
  prefersReducedMotion,
8
8
  resolveDarkMode,
9
9
  resolveEase
10
- } from "./chunk-REH5UQCL.js";
10
+ } from "./chunk-46E3QB6O.js";
11
11
  import {
12
- resolvedSurface,
13
- warnDeprecated
14
- } from "./chunk-UC4IHEUO.js";
12
+ renderAttributionBrand,
13
+ renderChromeElement,
14
+ stampThemeProperties
15
+ } from "./chunk-NLKQ5AOA.js";
16
+ import {
17
+ createSVGElement,
18
+ setAttrs
19
+ } from "./chunk-FFP5GXIP.js";
15
20
 
16
21
  // src/graph/renderer-registry.ts
17
22
  var registry = /* @__PURE__ */ new Map();
@@ -24,7 +29,8 @@ function getGraphRenderer(dimensions) {
24
29
  var GRAPH_3D_NOT_REGISTERED_ERROR = 'createGraph: dimensions: 3 requires import "@opendata-ai/openchart-vanilla/graph-3d"';
25
30
 
26
31
  // src/graph-mount.ts
27
- import { buildEdgeTooltip, compileGraph } from "@opendata-ai/openchart-engine";
32
+ import { computeChrome } from "@opendata-ai/openchart-core";
33
+ import { compileGraph } from "@opendata-ai/openchart-engine";
28
34
 
29
35
  // src/graph/camera.ts
30
36
  import { interpolateZoom } from "d3-interpolate";
@@ -1124,6 +1130,243 @@ function categoryHighlightSet(activeCategories, nodeCategory) {
1124
1130
  return set;
1125
1131
  }
1126
1132
 
1133
+ // src/graph/focus-model.ts
1134
+ function createGraphFocusModel(ctx) {
1135
+ const { scheduler } = ctx;
1136
+ let highlightSet = null;
1137
+ let highlightDimOpacity = null;
1138
+ let activeCategories = /* @__PURE__ */ new Set();
1139
+ let transientHighlight = null;
1140
+ let transientTarget = null;
1141
+ let focusTransition = null;
1142
+ let focusAnim = null;
1143
+ let hoverRadiusTween = null;
1144
+ function hoverConnectedSet(nodeId) {
1145
+ if (nodeId === null) return null;
1146
+ if (ctx.compilation().interaction.hoverMode === "category") {
1147
+ const nodeCategory = ctx.nodeCategory();
1148
+ const cat = nodeCategory.get(nodeId);
1149
+ const set2 = /* @__PURE__ */ new Set([nodeId]);
1150
+ if (cat !== void 0) {
1151
+ for (const [id, c] of nodeCategory) if (c === cat) set2.add(id);
1152
+ }
1153
+ return set2;
1154
+ }
1155
+ const set = /* @__PURE__ */ new Set([nodeId]);
1156
+ const neighbors = ctx.adjacency().get(nodeId);
1157
+ if (neighbors) for (const nid of neighbors) set.add(nid);
1158
+ return set;
1159
+ }
1160
+ function standingSnapshot() {
1161
+ return composeStandingFocus(highlightSet, ctx.searchMatches(), ctx.selected(), ctx.adjacency());
1162
+ }
1163
+ function targetSnapshot() {
1164
+ const hovered = ctx.hovered();
1165
+ return layerHoverFocus(standingSnapshot(), hovered, hoverConnectedSet(hovered));
1166
+ }
1167
+ function arm(now) {
1168
+ const target = targetSnapshot();
1169
+ const hoverCfg = ctx.compilation().animation?.hover ?? null;
1170
+ const duration = hoverCfg && !prefersReducedMotion() ? hoverCfg.duration : 0;
1171
+ const ease = resolveEase(hoverCfg?.ease ?? "smooth");
1172
+ if (!focusTransition) {
1173
+ focusTransition = new FocusTransition(target, duration, ease, now);
1174
+ return;
1175
+ }
1176
+ focusTransition.retarget(target, now);
1177
+ if (focusAnim) scheduler.remove(focusAnim);
1178
+ focusAnim = {
1179
+ tick: (t) => {
1180
+ const running = focusTransition !== null && !focusTransition.isSettled(t);
1181
+ if (!running) focusAnim = null;
1182
+ return running;
1183
+ },
1184
+ finish: () => {
1185
+ focusAnim = null;
1186
+ },
1187
+ cancel: () => {
1188
+ focusAnim = null;
1189
+ }
1190
+ };
1191
+ scheduler.add(focusAnim);
1192
+ }
1193
+ function resolveHighlightTarget2(target) {
1194
+ return resolveHighlightTarget(target, ctx.compilation().nodes, ctx.adjacency());
1195
+ }
1196
+ function recompute() {
1197
+ const filter = categoryHighlightSet(activeCategories, ctx.nodeCategory());
1198
+ const transient = transientHighlight !== null && transientHighlight.size > 0 ? transientHighlight : null;
1199
+ if (filter !== null && transient !== null) {
1200
+ const inter = /* @__PURE__ */ new Set();
1201
+ for (const id of transient) if (filter.has(id)) inter.add(id);
1202
+ highlightSet = inter.size > 0 ? inter : transient;
1203
+ return;
1204
+ }
1205
+ highlightSet = filter ?? transient;
1206
+ }
1207
+ function refreshTransientHighlight() {
1208
+ if (transientTarget === null) {
1209
+ transientHighlight = null;
1210
+ return;
1211
+ }
1212
+ const nextIds = new Set(ctx.compilation().nodes.map((n) => n.id));
1213
+ const resolved = new Set(
1214
+ [...resolveHighlightTarget2(transientTarget)].filter((id) => nextIds.has(id))
1215
+ );
1216
+ transientHighlight = resolved.size > 0 ? resolved : null;
1217
+ }
1218
+ function effectiveDimOpacity() {
1219
+ const custom = transientHighlight !== null ? highlightDimOpacity : null;
1220
+ return custom ?? ctx.compilation().interaction.dimOpacity;
1221
+ }
1222
+ function hoverRadius(nodeId) {
1223
+ const hoverCfg = ctx.compilation().animation?.hover ?? null;
1224
+ if (nodeId === null || !hoverCfg || prefersReducedMotion()) {
1225
+ hoverRadiusTween = nodeId ? { nodeId, scale: 1.15 } : null;
1226
+ return;
1227
+ }
1228
+ hoverRadiusTween = { nodeId, scale: 1 };
1229
+ const ease = resolveEase(hoverCfg.ease);
1230
+ const tween = createTween({
1231
+ duration: hoverCfg.duration,
1232
+ ease,
1233
+ apply: (t) => {
1234
+ if (hoverRadiusTween?.nodeId === nodeId) hoverRadiusTween.scale = 1 + 0.15 * t;
1235
+ ctx.invalidate();
1236
+ },
1237
+ onDone: () => {
1238
+ if (hoverRadiusTween?.nodeId === nodeId) hoverRadiusTween.scale = 1.15;
1239
+ }
1240
+ });
1241
+ scheduler.add(tween);
1242
+ }
1243
+ function frame(now) {
1244
+ if (!focusTransition) arm(now);
1245
+ const ft = focusTransition;
1246
+ const t = ft.progress(now);
1247
+ const focus = t < 1 ? { t, prev: ft.prev, next: ft.next } : void 0;
1248
+ const settledNext = ft.next;
1249
+ const hoverRadiusScale = hoverRadiusTween ? /* @__PURE__ */ new Map([[hoverRadiusTween.nodeId, hoverRadiusTween.scale]]) : void 0;
1250
+ return {
1251
+ focus: focus ?? { t: 1, prev: settledNext, next: settledNext },
1252
+ hoverRadiusScale,
1253
+ dimOpacity: effectiveDimOpacity()
1254
+ };
1255
+ }
1256
+ return {
1257
+ get highlightSet() {
1258
+ return highlightSet;
1259
+ },
1260
+ get categories() {
1261
+ return activeCategories;
1262
+ },
1263
+ highlight(target, dimOpacity) {
1264
+ transientTarget = target;
1265
+ refreshTransientHighlight();
1266
+ highlightDimOpacity = dimOpacity ?? null;
1267
+ recompute();
1268
+ },
1269
+ clearHighlight() {
1270
+ transientTarget = null;
1271
+ transientHighlight = null;
1272
+ highlightDimOpacity = null;
1273
+ recompute();
1274
+ },
1275
+ setCategories(values) {
1276
+ activeCategories = new Set(values);
1277
+ recompute();
1278
+ },
1279
+ toggleCategory(value) {
1280
+ if (activeCategories.has(value)) activeCategories.delete(value);
1281
+ else activeCategories.add(value);
1282
+ recompute();
1283
+ },
1284
+ applyInitial() {
1285
+ const init = ctx.compilation().initialHighlight;
1286
+ if (!init) return;
1287
+ activeCategories = new Set(init.values);
1288
+ recompute();
1289
+ },
1290
+ reconcile() {
1291
+ refreshTransientHighlight();
1292
+ recompute();
1293
+ },
1294
+ arm,
1295
+ reset() {
1296
+ focusTransition = null;
1297
+ },
1298
+ hoverRadius,
1299
+ frame
1300
+ };
1301
+ }
1302
+
1303
+ // src/graph/graph-data.ts
1304
+ function buildGraphDataMaps(compilation) {
1305
+ const nodeData = new Map(compilation.nodes.map((n) => [n.id, n.data ?? {}]));
1306
+ const edgeData = new Map(
1307
+ compilation.edges.map((e) => [`${e.source}->${e.target}`, e.data ?? {}])
1308
+ );
1309
+ const nodeCategory = /* @__PURE__ */ new Map();
1310
+ const field = compilation.legendField;
1311
+ if (field) {
1312
+ for (const n of compilation.nodes) {
1313
+ const v = n.data?.[field];
1314
+ if (v != null) nodeCategory.set(n.id, String(v));
1315
+ }
1316
+ }
1317
+ return { nodeData, edgeData, nodeCategory };
1318
+ }
1319
+ function buildAdjacencyMap(edges) {
1320
+ const map = /* @__PURE__ */ new Map();
1321
+ for (const edge of edges) {
1322
+ if (!map.has(edge.source)) map.set(edge.source, /* @__PURE__ */ new Set());
1323
+ if (!map.has(edge.target)) map.set(edge.target, /* @__PURE__ */ new Set());
1324
+ map.get(edge.source).add(edge.target);
1325
+ map.get(edge.target).add(edge.source);
1326
+ }
1327
+ return map;
1328
+ }
1329
+ function toSimNodes(nodes) {
1330
+ return nodes.map((n) => ({
1331
+ id: n.id,
1332
+ radius: n.radius,
1333
+ community: n.community
1334
+ }));
1335
+ }
1336
+ function toSimEdges(edges) {
1337
+ return edges.map((e) => ({
1338
+ source: e.source,
1339
+ target: e.target
1340
+ }));
1341
+ }
1342
+ function pointToSegmentDist(px, py, ax, ay, bx, by) {
1343
+ const dx = bx - ax;
1344
+ const dy = by - ay;
1345
+ const lenSq = dx * dx + dy * dy;
1346
+ if (lenSq === 0) return Math.hypot(px - ax, py - ay);
1347
+ const t = Math.max(0, Math.min(1, ((px - ax) * dx + (py - ay) * dy) / lenSq));
1348
+ return Math.hypot(px - (ax + t * dx), py - (ay + t * dy));
1349
+ }
1350
+ function hitTestEdge(edges, graphX, graphY, threshold) {
1351
+ let bestDist = threshold;
1352
+ let bestEdgeId = null;
1353
+ for (const edge of edges) {
1354
+ const dist = pointToSegmentDist(
1355
+ graphX,
1356
+ graphY,
1357
+ edge.sourceX,
1358
+ edge.sourceY,
1359
+ edge.targetX,
1360
+ edge.targetY
1361
+ );
1362
+ if (dist < bestDist) {
1363
+ bestDist = dist;
1364
+ bestEdgeId = `${edge.source}->${edge.target}`;
1365
+ }
1366
+ }
1367
+ return bestEdgeId;
1368
+ }
1369
+
1127
1370
  // src/graph/interaction.ts
1128
1371
  var ZOOM_MIN = 0.05;
1129
1372
  var ZOOM_MAX = 15;
@@ -1678,6 +1921,27 @@ function seedNodePositions(nodes, seed) {
1678
1921
  }
1679
1922
  }
1680
1923
 
1924
+ // src/renderers/attribution-footer.ts
1925
+ function createAttributionFooter(chrome, width, measureText) {
1926
+ if (!chrome.source && !chrome.byline && !chrome.footer && !chrome.brand && !chrome.watermark)
1927
+ return null;
1928
+ const svg = createSVGElement("svg");
1929
+ svg.setAttribute("class", "oc-attribution-footer");
1930
+ setAttrs(svg, {
1931
+ width: "100%",
1932
+ height: chrome.bottomHeight,
1933
+ viewBox: `0 0 ${width} ${chrome.bottomHeight}`
1934
+ });
1935
+ svg.style.display = "block";
1936
+ svg.style.flex = "0 0 auto";
1937
+ for (const key of ["source", "byline", "footer"]) {
1938
+ const element = chrome[key];
1939
+ if (element) renderChromeElement(svg, element, `oc-${key}`, key, measureText);
1940
+ }
1941
+ renderAttributionBrand(svg, chrome, 0, measureText);
1942
+ return svg;
1943
+ }
1944
+
1681
1945
  // src/graph/shell.ts
1682
1946
  var MIN_SURFACE_HEIGHT = 200;
1683
1947
  function getContainerDimensions(container) {
@@ -1697,16 +1961,7 @@ function createGraphShell(container, spec, compilation, options, warn) {
1697
1961
  container.classList.remove("oc-dark");
1698
1962
  }
1699
1963
  const resolvedTheme = compilation.theme;
1700
- if (resolvedTheme) {
1701
- const s = wrapper.style;
1702
- s.setProperty("--oc-bg", resolvedSurface(resolvedTheme));
1703
- s.setProperty("--oc-text", resolvedTheme.colors.text);
1704
- s.setProperty("--oc-text-secondary", resolvedTheme.colors.neutral.secondary);
1705
- s.setProperty("--oc-text-muted", resolvedTheme.colors.axis);
1706
- s.setProperty("--oc-border", resolvedTheme.colors.neutral.border);
1707
- s.setProperty("--oc-font-family", resolvedTheme.fonts.family);
1708
- s.fontFamily = resolvedTheme.fonts.family;
1709
- }
1964
+ if (resolvedTheme) stampThemeProperties(wrapper, resolvedTheme);
1710
1965
  const chromeEl = document.createElement("div");
1711
1966
  chromeEl.className = "oc-graph-chrome";
1712
1967
  wrapper.appendChild(chromeEl);
@@ -1719,6 +1974,9 @@ function createGraphShell(container, spec, compilation, options, warn) {
1719
1974
  }
1720
1975
  container.appendChild(wrapper);
1721
1976
  const tooltipManager = options?.tooltip !== false ? createTooltipManager(wrapper) : null;
1977
+ let footerHeight = compilation.chrome.bottomHeight;
1978
+ let footer = null;
1979
+ let surface = null;
1722
1980
  const shell = {
1723
1981
  container,
1724
1982
  wrapper,
@@ -1727,6 +1985,8 @@ function createGraphShell(container, spec, compilation, options, warn) {
1727
1985
  tooltipManager,
1728
1986
  isDark,
1729
1987
  mountSurface(el) {
1988
+ surface = el;
1989
+ el.style.height = `calc(100% - ${footerHeight}px)`;
1730
1990
  if (legendEl) wrapper.insertBefore(el, legendEl);
1731
1991
  else wrapper.appendChild(el);
1732
1992
  },
@@ -1740,6 +2000,16 @@ function createGraphShell(container, spec, compilation, options, warn) {
1740
2000
  }
1741
2001
  chromeEl.innerHTML = html;
1742
2002
  chromeEl.style.display = html ? "" : "none";
2003
+ footer?.remove();
2004
+ footer = createAttributionFooter(next.chrome, next.dimensions.width);
2005
+ footerHeight = footer ? next.chrome.bottomHeight : 0;
2006
+ if (surface) surface.style.height = `calc(100% - ${footerHeight}px)`;
2007
+ if (footer) {
2008
+ footer.style.position = "absolute";
2009
+ footer.style.bottom = "0";
2010
+ footer.style.left = "0";
2011
+ wrapper.appendChild(footer);
2012
+ }
1743
2013
  },
1744
2014
  /**
1745
2015
  * Keep the chrome block out of the legend's column: the title/subtitle wrap
@@ -1752,10 +2022,10 @@ function createGraphShell(container, spec, compilation, options, warn) {
1752
2022
  },
1753
2023
  getSize() {
1754
2024
  const { width, height } = getContainerDimensions(container);
1755
- return { width, height: Math.max(height, MIN_SURFACE_HEIGHT) };
2025
+ return { width, height: Math.max(1, Math.max(height, MIN_SURFACE_HEIGHT) - footerHeight) };
1756
2026
  },
1757
2027
  observeResize(callback) {
1758
- if (options?.responsive === false) return () => {
2028
+ if (options?.autoResize === false) return () => {
1759
2029
  };
1760
2030
  return observeResize(container, () => {
1761
2031
  callback();
@@ -2045,6 +2315,8 @@ var SimulationManager = class _SimulationManager {
2045
2315
  case "error":
2046
2316
  console.error("[SimulationManager] Worker error:", msg.message);
2047
2317
  break;
2318
+ default:
2319
+ msg;
2048
2320
  }
2049
2321
  };
2050
2322
  worker.postMessage(initMsg);
@@ -2197,6 +2469,48 @@ var SimulationManager = class _SimulationManager {
2197
2469
  }
2198
2470
  };
2199
2471
 
2472
+ // src/graph/tooltip-content.ts
2473
+ import { buildEdgeTooltip } from "@opendata-ai/openchart-engine";
2474
+ function createGraphTooltips(ctx) {
2475
+ function tooltipFormatter() {
2476
+ const t = ctx.options?.tooltip;
2477
+ return t && typeof t === "object" ? t.formatter ?? null : null;
2478
+ }
2479
+ function applyFormatterResult(tooltipManager, result, x, y) {
2480
+ if (result === null) {
2481
+ tooltipManager.hide();
2482
+ } else if (typeof result === "string") {
2483
+ tooltipManager.show({ text: result }, x, y);
2484
+ } else if (result instanceof HTMLElement) {
2485
+ tooltipManager.show({ element: result }, x, y);
2486
+ } else {
2487
+ tooltipManager.show(result, x, y);
2488
+ }
2489
+ }
2490
+ function show(kind, defaults, data, x, y) {
2491
+ const tooltipManager = ctx.manager();
2492
+ if (!tooltipManager) return;
2493
+ const formatter = tooltipFormatter();
2494
+ if (!formatter) {
2495
+ tooltipManager.show(defaults, x, y);
2496
+ return;
2497
+ }
2498
+ applyFormatterResult(tooltipManager, formatter({ kind, data }, defaults), x, y);
2499
+ }
2500
+ return {
2501
+ showNode(nodeId, data, x, y) {
2502
+ const defaults = ctx.compilation().tooltipDescriptors.get(nodeId);
2503
+ if (!defaults) return;
2504
+ show("node", defaults, data, x, y);
2505
+ },
2506
+ showEdge(edgeId, data, x, y) {
2507
+ const edge = ctx.compilation().edges.find((e) => `${e.source}->${e.target}` === edgeId);
2508
+ const defaults = edge ? buildEdgeTooltip(edge) : { title: edgeId, fields: [] };
2509
+ show("edge", defaults, data, x, y);
2510
+ }
2511
+ };
2512
+ }
2513
+
2200
2514
  // src/graph/update-diff-config.ts
2201
2515
  function stableKey(c) {
2202
2516
  return JSON.stringify([
@@ -2355,6 +2669,63 @@ function ratio(numerator, denominator) {
2355
2669
  return denominator > 0 ? numerator / denominator : 0;
2356
2670
  }
2357
2671
 
2672
+ // src/graph/update-fades.ts
2673
+ function createGraphUpdateFades(scheduler, invalidate) {
2674
+ let enterAlphaMap = null;
2675
+ let exitingGhosts = null;
2676
+ function start(diff, compilation) {
2677
+ const updateCfg = compilation.animation?.update ?? null;
2678
+ const exitCfg = compilation.animation?.exit ?? null;
2679
+ const reduced = prefersReducedMotion();
2680
+ if (diff.enteringIds.length > 0 && updateCfg && !reduced) {
2681
+ const entering = diff.enteringIds;
2682
+ enterAlphaMap = new Map(entering.map((id) => [id, 0]));
2683
+ const ease = resolveEase(updateCfg.ease);
2684
+ const tween = createTween({
2685
+ duration: updateCfg.duration,
2686
+ ease,
2687
+ apply: (t) => {
2688
+ const q = Math.round(t * 8) / 8;
2689
+ if (enterAlphaMap) for (const id of entering) enterAlphaMap.set(id, q);
2690
+ invalidate();
2691
+ },
2692
+ onDone: () => {
2693
+ enterAlphaMap = null;
2694
+ invalidate();
2695
+ }
2696
+ });
2697
+ scheduler.add(tween);
2698
+ }
2699
+ if ((diff.exitingNodes.length > 0 || diff.exitingEdges.length > 0) && exitCfg && !reduced) {
2700
+ exitingGhosts = { nodes: diff.exitingNodes, edges: diff.exitingEdges, alpha: 1 };
2701
+ const ease = resolveEase(exitCfg.ease);
2702
+ const tween = createTween({
2703
+ duration: exitCfg.duration,
2704
+ ease,
2705
+ apply: (t) => {
2706
+ if (exitingGhosts) exitingGhosts.alpha = 1 - t;
2707
+ invalidate();
2708
+ },
2709
+ onDone: () => {
2710
+ exitingGhosts = null;
2711
+ invalidate();
2712
+ }
2713
+ });
2714
+ scheduler.add(tween);
2715
+ }
2716
+ }
2717
+ return {
2718
+ start,
2719
+ clear() {
2720
+ enterAlphaMap = null;
2721
+ exitingGhosts = null;
2722
+ },
2723
+ frame() {
2724
+ return { enterAlpha: enterAlphaMap ?? void 0, exiting: exitingGhosts ?? void 0 };
2725
+ }
2726
+ };
2727
+ }
2728
+
2358
2729
  // src/graph-mount.ts
2359
2730
  var SPRINGY_DRAG_MAX_NODES = 5e3;
2360
2731
  var CURSOR_FORCE_MAX_NODES = 2e3;
@@ -2396,17 +2767,9 @@ function createGraph(container, spec, options) {
2396
2767
  let activeFollow = null;
2397
2768
  let lastAlpha = 1;
2398
2769
  let cameraChangePending = false;
2399
- let highlightSet = null;
2400
- let highlightDimOpacity = null;
2401
2770
  let seedIds = /* @__PURE__ */ new Set();
2402
- let activeCategories = /* @__PURE__ */ new Set();
2403
- let transientHighlight = null;
2404
- let transientTarget = null;
2405
2771
  const seenWarnings = /* @__PURE__ */ new Set();
2406
2772
  let nodeCategory = /* @__PURE__ */ new Map();
2407
- let focusTransition = null;
2408
- let focusAnim = null;
2409
- let hoverRadiusTween = null;
2410
2773
  let entranceProgress = 1;
2411
2774
  let entranceActive = false;
2412
2775
  let entranceStagger = false;
@@ -2415,8 +2778,9 @@ function createGraph(container, spec, options) {
2415
2778
  let entranceFitInFlight = false;
2416
2779
  let entranceReveal = null;
2417
2780
  let suppressEntranceOnce = options?.suppressEntrance ?? false;
2418
- let enterAlphaMap = null;
2419
- let exitingGhosts = null;
2781
+ const updateFades = createGraphUpdateFades(scheduler, () => {
2782
+ needsRender = true;
2783
+ });
2420
2784
  function markGesture() {
2421
2785
  isGesturing = true;
2422
2786
  if (gestureTimeout !== null) clearTimeout(gestureTimeout);
@@ -2450,70 +2814,15 @@ function createGraph(container, spec, options) {
2450
2814
  return compileGraph(specToCompile, compileOpts);
2451
2815
  }
2452
2816
  function buildDataMaps() {
2453
- nodeDataMap = new Map(compilation.nodes.map((n) => [n.id, n.data ?? {}]));
2454
- edgeDataMap = new Map(compilation.edges.map((e) => [`${e.source}->${e.target}`, e.data ?? {}]));
2455
- nodeCategory = /* @__PURE__ */ new Map();
2456
- const field = compilation.legendField;
2457
- if (field) {
2458
- for (const n of compilation.nodes) {
2459
- const v = n.data?.[field];
2460
- if (v != null) nodeCategory.set(n.id, String(v));
2461
- }
2462
- }
2463
- }
2464
- function buildAdjacencyMap(edges) {
2465
- const map = /* @__PURE__ */ new Map();
2466
- for (const edge of edges) {
2467
- if (!map.has(edge.source)) map.set(edge.source, /* @__PURE__ */ new Set());
2468
- if (!map.has(edge.target)) map.set(edge.target, /* @__PURE__ */ new Set());
2469
- map.get(edge.source).add(edge.target);
2470
- map.get(edge.target).add(edge.source);
2471
- }
2472
- return map;
2473
- }
2474
- function toSimNodes(nodes) {
2475
- return nodes.map((n) => ({
2476
- id: n.id,
2477
- radius: n.radius,
2478
- community: n.community
2479
- }));
2480
- }
2481
- function toSimEdges(edges) {
2482
- return edges.map((e) => ({
2483
- source: e.source,
2484
- target: e.target
2485
- }));
2817
+ ({
2818
+ nodeData: nodeDataMap,
2819
+ edgeData: edgeDataMap,
2820
+ nodeCategory
2821
+ } = buildGraphDataMaps(compilation));
2486
2822
  }
2487
2823
  function nodeDataById(nodeId) {
2488
2824
  return nodeDataMap.get(nodeId) ?? {};
2489
2825
  }
2490
- function pointToSegmentDist(px, py, ax, ay, bx, by) {
2491
- const dx = bx - ax;
2492
- const dy = by - ay;
2493
- const lenSq = dx * dx + dy * dy;
2494
- if (lenSq === 0) return Math.hypot(px - ax, py - ay);
2495
- const t = Math.max(0, Math.min(1, ((px - ax) * dx + (py - ay) * dy) / lenSq));
2496
- return Math.hypot(px - (ax + t * dx), py - (ay + t * dy));
2497
- }
2498
- function hitTestEdge(graphX, graphY, threshold) {
2499
- let bestDist = threshold;
2500
- let bestEdgeId = null;
2501
- for (const edge of positionedEdges) {
2502
- const dist = pointToSegmentDist(
2503
- graphX,
2504
- graphY,
2505
- edge.sourceX,
2506
- edge.sourceY,
2507
- edge.targetX,
2508
- edge.targetY
2509
- );
2510
- if (dist < bestDist) {
2511
- bestDist = dist;
2512
- bestEdgeId = `${edge.source}->${edge.target}`;
2513
- }
2514
- }
2515
- return bestEdgeId;
2516
- }
2517
2826
  function edgeDataById(edgeId) {
2518
2827
  return edgeDataMap.get(edgeId) ?? null;
2519
2828
  }
@@ -2535,6 +2844,10 @@ function createGraph(container, spec, options) {
2535
2844
  }
2536
2845
  function renderChrome() {
2537
2846
  shell?.renderChrome(compilation);
2847
+ if (shell && renderer) {
2848
+ const size = shell.getSize();
2849
+ renderer.resize(size.width, size.height);
2850
+ }
2538
2851
  }
2539
2852
  function legendSetting() {
2540
2853
  return options?.legend ?? currentSpec.legend;
@@ -2732,176 +3045,42 @@ function createGraph(container, spec, options) {
2732
3045
  if (animFrameId !== null || destroyed) return;
2733
3046
  animFrameId = requestAnimationFrame(renderFrame);
2734
3047
  }
2735
- function hoverConnectedSet(nodeId) {
2736
- if (nodeId === null) return null;
2737
- if (compilation.interaction.hoverMode === "category") {
2738
- const cat = nodeCategory.get(nodeId);
2739
- const set2 = /* @__PURE__ */ new Set([nodeId]);
2740
- if (cat !== void 0) {
2741
- for (const [id, c] of nodeCategory) if (c === cat) set2.add(id);
2742
- }
2743
- return set2;
2744
- }
2745
- const set = /* @__PURE__ */ new Set([nodeId]);
2746
- const neighbors = adjacencyMap.get(nodeId);
2747
- if (neighbors) for (const nid of neighbors) set.add(nid);
2748
- return set;
2749
- }
2750
- function standingSnapshot() {
2751
- return composeStandingFocus(
2752
- highlightSet,
2753
- searchManager.getMatches(),
2754
- selectedNodeIds,
2755
- adjacencyMap
2756
- );
2757
- }
2758
- function targetSnapshot() {
2759
- return layerHoverFocus(standingSnapshot(), hoveredNodeId, hoverConnectedSet(hoveredNodeId));
2760
- }
2761
- function armFocus(now) {
2762
- const target = targetSnapshot();
2763
- const hoverCfg = compilation.animation?.hover ?? null;
2764
- const duration = hoverCfg && !prefersReducedMotion() ? hoverCfg.duration : 0;
2765
- const ease = resolveEase(hoverCfg?.ease ?? "smooth");
2766
- if (!focusTransition) {
2767
- focusTransition = new FocusTransition(target, duration, ease, now);
2768
- return;
3048
+ const focus = createGraphFocusModel({
3049
+ compilation: () => compilation,
3050
+ adjacency: () => adjacencyMap,
3051
+ nodeCategory: () => nodeCategory,
3052
+ searchMatches: () => searchManager.getMatches(),
3053
+ selected: () => selectedNodeIds,
3054
+ hovered: () => hoveredNodeId,
3055
+ scheduler,
3056
+ invalidate: () => {
3057
+ needsRender = true;
2769
3058
  }
2770
- focusTransition.retarget(target, now);
2771
- if (focusAnim) scheduler.remove(focusAnim);
2772
- focusAnim = {
2773
- tick: (t) => {
2774
- const running = focusTransition !== null && !focusTransition.isSettled(t);
2775
- if (!running) focusAnim = null;
2776
- return running;
2777
- },
2778
- finish: () => {
2779
- focusAnim = null;
2780
- },
2781
- cancel: () => {
2782
- focusAnim = null;
2783
- }
2784
- };
2785
- scheduler.add(focusAnim);
2786
- }
3059
+ });
2787
3060
  function refreshFocus() {
2788
- armFocus(performance.now());
3061
+ focus.arm(performance.now());
2789
3062
  needsRender = true;
2790
3063
  scheduleRender();
2791
3064
  }
2792
- function resolveHighlightTarget2(target) {
2793
- return resolveHighlightTarget(target, compilation.nodes, adjacencyMap);
2794
- }
2795
- function categoryHighlightSet2() {
2796
- return categoryHighlightSet(activeCategories, nodeCategory);
2797
- }
2798
- function recomputeHighlight() {
2799
- const filter = categoryHighlightSet2();
2800
- const transient = transientHighlight !== null && transientHighlight.size > 0 ? transientHighlight : null;
2801
- if (filter !== null && transient !== null) {
2802
- const inter = /* @__PURE__ */ new Set();
2803
- for (const id of transient) if (filter.has(id)) inter.add(id);
2804
- highlightSet = inter.size > 0 ? inter : transient;
2805
- return;
2806
- }
2807
- highlightSet = filter ?? transient;
2808
- }
2809
- function refreshTransientHighlight() {
2810
- if (transientTarget === null) {
2811
- transientHighlight = null;
2812
- return;
2813
- }
2814
- const nextIds = new Set(compilation.nodes.map((n) => n.id));
2815
- const resolved = new Set(
2816
- [...resolveHighlightTarget2(transientTarget)].filter((id) => nextIds.has(id))
2817
- );
2818
- transientHighlight = resolved.size > 0 ? resolved : null;
2819
- }
2820
- function effectiveDimOpacity() {
2821
- const custom = transientHighlight !== null ? highlightDimOpacity : null;
2822
- return custom ?? compilation.interaction.dimOpacity;
2823
- }
2824
3065
  function emitHighlightChange() {
3066
+ const highlightSet = focus.highlightSet;
2825
3067
  options?.onHighlightChange?.(highlightSet ? [...highlightSet] : null);
2826
3068
  }
2827
- function applyInitialHighlight() {
2828
- const init = compilation.initialHighlight;
2829
- if (!init) return;
2830
- activeCategories = new Set(init.values);
2831
- recomputeHighlight();
2832
- }
2833
- function startHoverRadiusTween(nodeId) {
2834
- const hoverCfg = compilation.animation?.hover ?? null;
2835
- if (nodeId === null || !hoverCfg || prefersReducedMotion()) {
2836
- hoverRadiusTween = nodeId ? { nodeId, scale: 1.15 } : null;
2837
- return;
2838
- }
2839
- hoverRadiusTween = { nodeId, scale: 1 };
2840
- const ease = resolveEase(hoverCfg.ease);
2841
- const tween = createTween({
2842
- duration: hoverCfg.duration,
2843
- ease,
2844
- apply: (t) => {
2845
- if (hoverRadiusTween?.nodeId === nodeId) hoverRadiusTween.scale = 1 + 0.15 * t;
2846
- needsRender = true;
2847
- },
2848
- onDone: () => {
2849
- if (hoverRadiusTween?.nodeId === nodeId) hoverRadiusTween.scale = 1.15;
2850
- }
2851
- });
2852
- scheduler.add(tween);
2853
- }
3069
+ const tooltips = createGraphTooltips({
3070
+ options,
3071
+ manager: () => tooltipManager,
3072
+ compilation: () => compilation
3073
+ });
2854
3074
  function showNodeTooltip(nodeId) {
2855
3075
  if (!tooltipManager || !interactionManager) return;
2856
- const defaults = compilation.tooltipDescriptors.get(nodeId);
2857
- if (!defaults) return;
2858
3076
  const node = positionedNodes.find((n) => n.id === nodeId);
2859
3077
  if (!node) return;
2860
3078
  const screen = interactionManager.getTransform().graphToScreen(node.x, node.y);
2861
- const formatter = tooltipFormatter();
2862
- if (!formatter) {
2863
- tooltipManager.show(defaults, screen.x, screen.y);
2864
- return;
2865
- }
2866
- const result = formatter({ kind: "node", data: nodeDataById(nodeId) }, defaults);
2867
- applyFormatterResult(result, screen.x, screen.y);
2868
- }
2869
- function showEdgeTooltip(edgeId, data, screenX, screenY) {
2870
- if (!tooltipManager) return;
2871
- const edge = compilation.edges.find((e) => `${e.source}->${e.target}` === edgeId);
2872
- const defaults = edge ? buildEdgeTooltip(edge) : { title: edgeId, fields: [] };
2873
- const formatter = tooltipFormatter();
2874
- if (!formatter) {
2875
- tooltipManager.show(defaults, screenX, screenY);
2876
- return;
2877
- }
2878
- const result = formatter({ kind: "edge", data }, defaults);
2879
- applyFormatterResult(result, screenX, screenY);
2880
- }
2881
- function tooltipFormatter() {
2882
- const t = options?.tooltip;
2883
- return t && typeof t === "object" ? t.formatter ?? null : null;
2884
- }
2885
- function applyFormatterResult(result, x, y) {
2886
- if (!tooltipManager) return;
2887
- if (result === null) {
2888
- tooltipManager.hide();
2889
- } else if (typeof result === "string") {
2890
- tooltipManager.show({ text: result }, x, y);
2891
- } else if (result instanceof HTMLElement) {
2892
- tooltipManager.show({ element: result }, x, y);
2893
- } else {
2894
- tooltipManager.show(result, x, y);
2895
- }
3079
+ tooltips.showNode(nodeId, nodeDataById(nodeId), screen.x, screen.y);
2896
3080
  }
2897
3081
  function buildRenderState(now) {
2898
3082
  const transform = interactionManager.getTransform();
2899
- if (!focusTransition) armFocus(now);
2900
- const ft = focusTransition;
2901
- const t = ft.progress(now);
2902
- const focus = t < 1 ? { t, prev: ft.prev, next: ft.next } : void 0;
2903
- const settledNext = ft.next;
2904
- const hoverRadiusScale = hoverRadiusTween ? /* @__PURE__ */ new Map([[hoverRadiusTween.nodeId, hoverRadiusTween.scale]]) : void 0;
3083
+ const focusState = focus.frame(now);
2905
3084
  return {
2906
3085
  nodes: positionedNodes,
2907
3086
  edges: positionedEdges,
@@ -2914,18 +3093,16 @@ function createGraph(container, spec, options) {
2914
3093
  searchMatches: searchManager.getMatches(),
2915
3094
  exemptIds: seedIds,
2916
3095
  isGesturing,
2917
- watermark: compilation.watermark,
2918
- focus: focus ?? { t: 1, prev: settledNext, next: settledNext },
2919
- hoverRadiusScale,
2920
- dimOpacity: effectiveDimOpacity(),
3096
+ // Shared shell paints the complete measured attribution footer.
3097
+ watermark: false,
3098
+ ...focusState,
2921
3099
  entrance: entranceActive && entranceProgress < 1 ? {
2922
3100
  t: entranceProgress,
2923
3101
  stagger: entranceStagger,
2924
3102
  order: entranceOrderMap ?? void 0,
2925
3103
  offsets: entranceOffsetMap ?? void 0
2926
3104
  } : void 0,
2927
- enterAlpha: enterAlphaMap ?? void 0,
2928
- exiting: exitingGhosts ?? void 0
3105
+ ...updateFades.frame()
2929
3106
  };
2930
3107
  }
2931
3108
  function renderFrame(now) {
@@ -3021,8 +3198,8 @@ function createGraph(container, spec, options) {
3021
3198
  onHoverChange(nodeId) {
3022
3199
  if (nodeId === hoveredNodeId) return;
3023
3200
  hoveredNodeId = nodeId;
3024
- armFocus(performance.now());
3025
- startHoverRadiusTween(nodeId);
3201
+ focus.arm(performance.now());
3202
+ focus.hoverRadius(nodeId);
3026
3203
  needsRender = true;
3027
3204
  scheduleRender();
3028
3205
  if (nodeId && hoveredEdgeId) {
@@ -3053,7 +3230,7 @@ function createGraph(container, spec, options) {
3053
3230
  lastEdgeHitTime = now;
3054
3231
  const transform = interactionManager?.getTransform();
3055
3232
  const threshold = 5 / (transform?.k ?? 1);
3056
- const edgeId = hitTestEdge(graphX, graphY, threshold);
3233
+ const edgeId = hitTestEdge(positionedEdges, graphX, graphY, threshold);
3057
3234
  if (edgeId !== hoveredEdgeId) {
3058
3235
  hoveredEdgeId = edgeId;
3059
3236
  needsRender = true;
@@ -3061,7 +3238,7 @@ function createGraph(container, spec, options) {
3061
3238
  if (edgeId) {
3062
3239
  const data = edgeDataById(edgeId);
3063
3240
  options?.onEdgeHover?.(data);
3064
- if (tooltipManager && data) showEdgeTooltip(edgeId, data, screenX, screenY);
3241
+ if (tooltipManager && data) tooltips.showEdge(edgeId, data, screenX, screenY);
3065
3242
  } else {
3066
3243
  options?.onEdgeHover?.(null);
3067
3244
  tooltipManager?.hide();
@@ -3070,7 +3247,7 @@ function createGraph(container, spec, options) {
3070
3247
  },
3071
3248
  onSelectionChange(nodeIds) {
3072
3249
  selectedNodeIds = new Set(nodeIds);
3073
- armFocus(performance.now());
3250
+ focus.arm(performance.now());
3074
3251
  needsRender = true;
3075
3252
  scheduleRender();
3076
3253
  options?.onSelectionChange?.(nodeIds);
@@ -3116,7 +3293,7 @@ function createGraph(container, spec, options) {
3116
3293
  onSelect(nodeId) {
3117
3294
  selectedNodeIds = /* @__PURE__ */ new Set([nodeId]);
3118
3295
  interactionManager?.setSelection([nodeId]);
3119
- armFocus(performance.now());
3296
+ focus.arm(performance.now());
3120
3297
  needsRender = true;
3121
3298
  scheduleRender();
3122
3299
  options?.onNodeClick?.(nodeDataById(nodeId));
@@ -3125,7 +3302,7 @@ function createGraph(container, spec, options) {
3125
3302
  onDeselect() {
3126
3303
  selectedNodeIds.clear();
3127
3304
  interactionManager?.setSelection([]);
3128
- armFocus(performance.now());
3305
+ focus.arm(performance.now());
3129
3306
  needsRender = true;
3130
3307
  scheduleRender();
3131
3308
  options?.onSelectionChange?.([]);
@@ -3146,7 +3323,7 @@ function createGraph(container, spec, options) {
3146
3323
  }
3147
3324
  function search(query) {
3148
3325
  if (destroyed) return;
3149
- searchManager.search(query, positionedNodes);
3326
+ searchManager.search(query, compilation.nodes);
3150
3327
  needsRender = true;
3151
3328
  scheduleRender();
3152
3329
  }
@@ -3212,23 +3389,18 @@ function createGraph(container, spec, options) {
3212
3389
  }
3213
3390
  function highlight(target, opts) {
3214
3391
  if (destroyed) return;
3215
- transientTarget = target;
3216
- refreshTransientHighlight();
3217
- highlightDimOpacity = opts?.dimOpacity ?? null;
3218
- recomputeHighlight();
3392
+ focus.highlight(target, opts?.dimOpacity);
3219
3393
  refreshFocus();
3220
3394
  emitHighlightChange();
3221
3395
  }
3222
3396
  function clearHighlight() {
3223
3397
  if (destroyed) return;
3224
- transientTarget = null;
3225
- transientHighlight = null;
3226
- highlightDimOpacity = null;
3227
- recomputeHighlight();
3398
+ focus.clearHighlight();
3228
3399
  refreshFocus();
3229
3400
  emitHighlightChange();
3230
3401
  }
3231
3402
  function getHighlight() {
3403
+ const highlightSet = focus.highlightSet;
3232
3404
  return highlightSet ? [...highlightSet] : null;
3233
3405
  }
3234
3406
  function getLegend() {
@@ -3239,7 +3411,7 @@ function createGraph(container, spec, options) {
3239
3411
  label: e.label,
3240
3412
  color: e.color,
3241
3413
  count: e.count,
3242
- active: activeCategories.size === 0 || activeCategories.has(e.label)
3414
+ active: focus.categories.size === 0 || focus.categories.has(e.label)
3243
3415
  })),
3244
3416
  edges: (compilation.edgeLegend ?? []).map((e) => ({
3245
3417
  label: e.label,
@@ -3250,26 +3422,38 @@ function createGraph(container, spec, options) {
3250
3422
  }
3251
3423
  function setActiveCategories(values) {
3252
3424
  if (destroyed) return;
3253
- activeCategories = new Set(values);
3254
- recomputeHighlight();
3425
+ focus.setCategories(values);
3255
3426
  syncLegendActiveState();
3256
3427
  refreshFocus();
3257
3428
  emitHighlightChange();
3258
3429
  }
3259
3430
  function getActiveCategories() {
3260
- return [...activeCategories];
3431
+ return [...focus.categories];
3261
3432
  }
3262
3433
  function toggleLegendCategory(value) {
3263
- if (activeCategories.has(value)) activeCategories.delete(value);
3264
- else activeCategories.add(value);
3265
- recomputeHighlight();
3434
+ focus.toggleCategory(value);
3266
3435
  syncLegendActiveState();
3267
3436
  refreshFocus();
3268
- options?.onLegendToggle?.([...activeCategories]);
3437
+ options?.onLegendToggle?.([...focus.categories]);
3269
3438
  emitHighlightChange();
3270
3439
  }
3271
3440
  function doResize() {
3272
3441
  if (destroyed || !canvas || !renderer || !shell) return;
3442
+ const dimensions = getContainerDimensions2();
3443
+ compilation = {
3444
+ ...compilation,
3445
+ dimensions,
3446
+ chrome: computeChrome(
3447
+ currentSpec.chrome,
3448
+ compilation.theme,
3449
+ dimensions.width,
3450
+ void 0,
3451
+ "full",
3452
+ void 0,
3453
+ compilation.watermark
3454
+ )
3455
+ };
3456
+ shell.renderChrome(compilation);
3273
3457
  const { width, height } = shell.getSize();
3274
3458
  renderer.resize(width, height);
3275
3459
  syncChromeInset();
@@ -3295,8 +3479,7 @@ function createGraph(container, spec, options) {
3295
3479
  entranceProgress = 1;
3296
3480
  entranceFitInFlight = false;
3297
3481
  entranceReveal = null;
3298
- enterAlphaMap = null;
3299
- exitingGhosts = null;
3482
+ updateFades.clear();
3300
3483
  const prevNodes = positionedNodes;
3301
3484
  const prevEdges = positionedEdges;
3302
3485
  const prevConfig = compilation.simulationConfig;
@@ -3332,8 +3515,7 @@ function createGraph(container, spec, options) {
3332
3515
  return { ...edge, sourceX: src.x, sourceY: src.y, targetX: tgt.x, targetY: tgt.y };
3333
3516
  });
3334
3517
  spatialIndex.rebuild(positionedNodes);
3335
- refreshTransientHighlight();
3336
- recomputeHighlight();
3518
+ focus.reconcile();
3337
3519
  reRunSearch();
3338
3520
  renderChrome();
3339
3521
  renderLegend();
@@ -3369,7 +3551,7 @@ function createGraph(container, spec, options) {
3369
3551
  renderChrome();
3370
3552
  renderLegend();
3371
3553
  reconcileStateAfterUpdate();
3372
- startUpdateTransitions(diff);
3554
+ updateFades.start(diff, compilation);
3373
3555
  needsRender = true;
3374
3556
  scheduleRender();
3375
3557
  }
@@ -3386,62 +3568,16 @@ function createGraph(container, spec, options) {
3386
3568
  const survivingSelection = [...selectedNodeIds].filter((id) => nextIds.has(id));
3387
3569
  selectedNodeIds = new Set(survivingSelection);
3388
3570
  interactionManager?.setSelection(survivingSelection);
3389
- refreshTransientHighlight();
3390
- recomputeHighlight();
3571
+ focus.reconcile();
3391
3572
  syncLegendActiveState();
3392
3573
  reRunSearch();
3393
- focusTransition = null;
3394
- armFocus(performance.now());
3574
+ focus.reset();
3575
+ focus.arm(performance.now());
3395
3576
  }
3396
3577
  function reRunSearch() {
3397
3578
  const q = searchManager.getQuery();
3398
3579
  if (q !== null) searchManager.search(q, positionedNodes);
3399
3580
  }
3400
- function startUpdateTransitions(diff) {
3401
- const updateCfg = compilation.animation?.update ?? null;
3402
- const exitCfg = compilation.animation?.exit ?? null;
3403
- const reduced = prefersReducedMotion();
3404
- if (diff.enteringIds.length > 0 && updateCfg && !reduced) {
3405
- const entering = diff.enteringIds;
3406
- enterAlphaMap = new Map(entering.map((id) => [id, 0]));
3407
- const ease = resolveEase(updateCfg.ease);
3408
- const tween = createTween({
3409
- duration: updateCfg.duration,
3410
- ease,
3411
- apply: (t) => {
3412
- const q = Math.round(t * 8) / 8;
3413
- if (enterAlphaMap) for (const id of entering) enterAlphaMap.set(id, q);
3414
- needsRender = true;
3415
- },
3416
- onDone: () => {
3417
- enterAlphaMap = null;
3418
- needsRender = true;
3419
- }
3420
- });
3421
- scheduler.add(tween);
3422
- }
3423
- if ((diff.exitingNodes.length > 0 || diff.exitingEdges.length > 0) && exitCfg && !reduced) {
3424
- exitingGhosts = { nodes: diff.exitingNodes, edges: diff.exitingEdges, alpha: 1 };
3425
- const ease = resolveEase(exitCfg.ease);
3426
- const tween = createTween({
3427
- duration: exitCfg.duration,
3428
- ease,
3429
- apply: (t) => {
3430
- if (exitingGhosts) exitingGhosts.alpha = 1 - t;
3431
- needsRender = true;
3432
- },
3433
- onDone: () => {
3434
- exitingGhosts = null;
3435
- needsRender = true;
3436
- }
3437
- });
3438
- scheduler.add(tween);
3439
- }
3440
- }
3441
- function updateVisuals(newSpec) {
3442
- warnDeprecated("updateVisuals is deprecated; use update.");
3443
- update(newSpec);
3444
- }
3445
3581
  function teardownSimOnly() {
3446
3582
  simulation?.destroy();
3447
3583
  simulation = null;
@@ -3454,8 +3590,7 @@ function createGraph(container, spec, options) {
3454
3590
  entranceActive = false;
3455
3591
  entranceProgress = 1;
3456
3592
  entranceFitInFlight = false;
3457
- enterAlphaMap = null;
3458
- exitingGhosts = null;
3593
+ updateFades.clear();
3459
3594
  if (animFrameId !== null) {
3460
3595
  cancelAnimationFrame(animFrameId);
3461
3596
  animFrameId = null;
@@ -3529,7 +3664,7 @@ function createGraph(container, spec, options) {
3529
3664
  seedIds = new Set(compilation.seedNodeIds);
3530
3665
  adjacencyMap = buildAdjacencyMap(compilation.edges);
3531
3666
  buildDataMaps();
3532
- applyInitialHighlight();
3667
+ focus.applyInitial();
3533
3668
  createSurface();
3534
3669
  initSimulation();
3535
3670
  initInteraction();
@@ -3542,7 +3677,6 @@ function createGraph(container, spec, options) {
3542
3677
  });
3543
3678
  return {
3544
3679
  update,
3545
- updateVisuals,
3546
3680
  search,
3547
3681
  clearSearch,
3548
3682
  zoomToFit,
@@ -3578,8 +3712,10 @@ export {
3578
3712
  createGraphLegend,
3579
3713
  GraphSearchManager,
3580
3714
  seedNodePositions,
3715
+ createAttributionFooter,
3716
+ getContainerDimensions,
3581
3717
  diffGraphUpdate,
3582
3718
  reheatAlpha,
3583
3719
  createGraph
3584
3720
  };
3585
- //# sourceMappingURL=chunk-GX6BWMJD.js.map
3721
+ //# sourceMappingURL=chunk-5ZLSMZRM.js.map