@dxos/react-ui-graph 0.8.4-main.d05539e30a → 0.8.4-main.d9fc60f731

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 (52) hide show
  1. package/dist/lib/browser/index.mjs +781 -43
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node-esm/index.mjs +781 -43
  5. package/dist/lib/node-esm/index.mjs.map +4 -4
  6. package/dist/lib/node-esm/meta.json +1 -1
  7. package/dist/types/src/components/Graph/Graph.d.ts +15 -1
  8. package/dist/types/src/components/Graph/Graph.d.ts.map +1 -1
  9. package/dist/types/src/components/SVG/FPS.d.ts +20 -0
  10. package/dist/types/src/components/SVG/FPS.d.ts.map +1 -0
  11. package/dist/types/src/components/SVG/Root.d.ts.map +1 -1
  12. package/dist/types/src/components/SVG/SVG.d.ts +3 -1
  13. package/dist/types/src/components/SVG/SVG.d.ts.map +1 -1
  14. package/dist/types/src/graph/projector/graph-cluster-projector.d.ts +5 -0
  15. package/dist/types/src/graph/projector/graph-cluster-projector.d.ts.map +1 -1
  16. package/dist/types/src/graph/projector/graph-force-projector.d.ts.map +1 -1
  17. package/dist/types/src/graph/projector/graph-plexus-projector.d.ts +67 -0
  18. package/dist/types/src/graph/projector/graph-plexus-projector.d.ts.map +1 -0
  19. package/dist/types/src/graph/projector/graph-plexus-projector.test.d.ts +2 -0
  20. package/dist/types/src/graph/projector/graph-plexus-projector.test.d.ts.map +1 -0
  21. package/dist/types/src/graph/projector/graph-projector.d.ts +8 -0
  22. package/dist/types/src/graph/projector/graph-projector.d.ts.map +1 -1
  23. package/dist/types/src/graph/projector/graph-swarm-projector.d.ts +72 -0
  24. package/dist/types/src/graph/projector/graph-swarm-projector.d.ts.map +1 -0
  25. package/dist/types/src/graph/projector/index.d.ts +2 -0
  26. package/dist/types/src/graph/projector/index.d.ts.map +1 -1
  27. package/dist/types/src/graph/renderer/graph-renderer.d.ts +20 -0
  28. package/dist/types/src/graph/renderer/graph-renderer.d.ts.map +1 -1
  29. package/dist/types/src/graph/renderer/index.d.ts +1 -0
  30. package/dist/types/src/graph/renderer/index.d.ts.map +1 -1
  31. package/dist/types/src/graph/renderer/labels.d.ts +33 -0
  32. package/dist/types/src/graph/renderer/labels.d.ts.map +1 -0
  33. package/dist/types/src/stories/experimental.stories.d.ts +7 -0
  34. package/dist/types/src/stories/experimental.stories.d.ts.map +1 -0
  35. package/dist/types/tsconfig.tsbuildinfo +1 -1
  36. package/package.json +17 -17
  37. package/src/components/Graph/Graph.tsx +70 -2
  38. package/src/components/SVG/FPS.tsx +91 -0
  39. package/src/components/SVG/Root.tsx +2 -1
  40. package/src/components/SVG/SVG.tsx +4 -1
  41. package/src/graph/projector/graph-cluster-projector.ts +12 -0
  42. package/src/graph/projector/graph-force-projector.ts +1 -0
  43. package/src/graph/projector/graph-plexus-projector.test.ts +102 -0
  44. package/src/graph/projector/graph-plexus-projector.ts +309 -0
  45. package/src/graph/projector/graph-projector.ts +15 -1
  46. package/src/graph/projector/graph-swarm-projector.ts +373 -0
  47. package/src/graph/projector/index.ts +2 -0
  48. package/src/graph/renderer/graph-renderer.ts +116 -3
  49. package/src/graph/renderer/index.ts +1 -0
  50. package/src/graph/renderer/labels.ts +138 -0
  51. package/src/stories/experimental.stories.tsx +446 -0
  52. package/styles/graph.css +1 -1
@@ -8,7 +8,7 @@ import {
8
8
  // src/components/Graph/Graph.tsx
9
9
  import React, { forwardRef, useEffect as useEffect3, useImperativeHandle, useMemo as useMemo3, useRef as useRef3 } from "react";
10
10
  import { combine } from "@dxos/async";
11
- import { log as log9 } from "@dxos/log";
11
+ import { log as log11 } from "@dxos/log";
12
12
  import { mx } from "@dxos/ui-theme";
13
13
 
14
14
  // src/graph/markers.ts
@@ -747,6 +747,7 @@ var GraphProjector = class extends Projector {
747
747
  });
748
748
  const edges = data.edges.map((edge) => ({
749
749
  id: edge.id,
750
+ type: edge.type,
750
751
  source: nodes.find((n) => n.id === edge.source),
751
752
  target: nodes.find((n) => n.id === edge.target),
752
753
  data: edge.data
@@ -761,6 +762,16 @@ var GraphProjector = class extends Projector {
761
762
  async onClear() {
762
763
  this.reset();
763
764
  }
765
+ /**
766
+ * Optional projector-owned click intercept. The Graph component invokes this BEFORE
767
+ * forwarding to the consumer's `onSelect`, so projectors can implement built-in
768
+ * interactions (e.g. cluster collapse) without each consumer wiring them. Returning
769
+ * `true` indicates the click was handled — consumer's `onSelect` is suppressed.
770
+ * Default no-op returns `false` so consumer handlers still run.
771
+ */
772
+ handleNodeClick(_node, _event) {
773
+ return false;
774
+ }
764
775
  };
765
776
 
766
777
  // src/graph/projector/graph-radial-projector.ts
@@ -1072,6 +1083,17 @@ var GraphClusterProjector = class extends GraphRadialProjector {
1072
1083
  // drops hidden leaves so the renderer doesn't see them), so re-reading from there
1073
1084
  // would permanently lose the hidden leaves and they couldn't reappear on expand.
1074
1085
  #dataNodes = [];
1086
+ /**
1087
+ * Built-in click semantics: clicking a synthetic root / group node toggles its subtree.
1088
+ * Leaf clicks fall through to the consumer's `onSelect` (returns `false`).
1089
+ */
1090
+ handleNodeClick(node, _event) {
1091
+ if (node.type !== CLUSTER_NODE_TYPE_ROOT && node.type !== CLUSTER_NODE_TYPE_GROUP) {
1092
+ return false;
1093
+ }
1094
+ this.toggleCollapsed(node.id);
1095
+ return true;
1096
+ }
1075
1097
  /** Toggle collapse state for a synthetic node id. Triggers a topology re-emit. */
1076
1098
  toggleCollapsed(id) {
1077
1099
  if (this.#collapsed.has(id)) {
@@ -1093,7 +1115,7 @@ var GraphClusterProjector = class extends GraphRadialProjector {
1093
1115
  nodes: graph?.nodes.length,
1094
1116
  edges: graph?.edges.length
1095
1117
  }
1096
- }, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 69, S: this });
1118
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 79, S: this });
1097
1119
  this.mergeData(graph);
1098
1120
  this.#dataNodes = [
1099
1121
  ...this.layout.graph.nodes
@@ -1454,7 +1476,7 @@ var GraphForceProjector = class extends GraphProjector {
1454
1476
  nodes: graph?.nodes.length,
1455
1477
  edges: graph?.edges.length
1456
1478
  }
1457
- }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 90, S: this });
1479
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 91, S: this });
1458
1480
  this._simulation.stop();
1459
1481
  this.mergeData(graph);
1460
1482
  this.updateLayout();
@@ -1505,7 +1527,7 @@ var GraphForceProjector = class extends GraphProjector {
1505
1527
  updateForces(forces) {
1506
1528
  log4("updateForces", {
1507
1529
  forces
1508
- }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 152, S: this });
1530
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 153, S: this });
1509
1531
  this._simulation.nodes(this.layout.graph.nodes).force("link", maybeForce(forces?.link, (config) => {
1510
1532
  const force = forceLink().id((d) => d.id).links(this.layout.graph.edges.filter((edge) => edge.linkForce));
1511
1533
  if (config.distance != null) {
@@ -1678,18 +1700,253 @@ var GraphLatticeProjector = class extends GraphRadialProjector {
1678
1700
  }
1679
1701
  };
1680
1702
 
1681
- // src/graph/projector/graph-relational-projector.ts
1703
+ // src/graph/projector/graph-plexus-projector.ts
1704
+ import { cluster as d3Cluster3, hierarchy as hierarchy3, linkRadial as linkRadial2 } from "d3";
1682
1705
  import { log as log7 } from "@dxos/log";
1683
- var __dxlog_file9 = "/__w/dxos/dxos/packages/ui/react-ui-graph/src/graph/projector/graph-relational-projector.ts";
1684
- var GraphRelationalProjector = class extends GraphRadialProjector {
1706
+ var __dxlog_file9 = "/__w/dxos/dxos/packages/ui/react-ui-graph/src/graph/projector/graph-plexus-projector.ts";
1707
+ var RELATION_PREFIX = "__plexus_relation__:";
1708
+ var HIER_EDGE_PREFIX2 = "__plexus_hier__:";
1709
+ var PLEXUS_NODE_TYPE_FOCUS = "plexus-focus";
1710
+ var PLEXUS_NODE_TYPE_RELATION = "plexus-relation";
1711
+ var PLEXUS_NODE_TYPE_OBJECT = "plexus-object";
1712
+ var linkPath2 = linkRadial2().angle((d) => d.x).radius((d) => d.y);
1713
+ var cartesianToPolar3 = (x, y) => ({
1714
+ angle: Math.atan2(x, -y),
1715
+ radius: Math.hypot(x, y)
1716
+ });
1717
+ var GraphPlexusProjector = class extends GraphRadialProjector {
1718
+ // Full node / edge snapshots taken right after mergeData — doPlexusLayout reads from
1719
+ // these because it overwrites layout.graph with the filtered focus-centric view.
1720
+ #dataNodes = [];
1721
+ #dataEdges = [];
1685
1722
  onUpdate(graph) {
1686
1723
  log7("onUpdate", {
1724
+ graph: {
1725
+ nodes: graph?.nodes.length,
1726
+ edges: graph?.edges.length
1727
+ }
1728
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file9, L: 48, S: this });
1729
+ this.mergeData(graph);
1730
+ this.#dataNodes = [
1731
+ ...this.layout.graph.nodes
1732
+ ];
1733
+ this.#dataEdges = [
1734
+ ...this.layout.graph.edges
1735
+ ];
1736
+ this.doPlexusLayout();
1737
+ this.emitUpdate("topology");
1738
+ this.animate();
1739
+ }
1740
+ /**
1741
+ * Recompute each hierarchy edge's `path` from current cartesian endpoints so curves track
1742
+ * moving nodes during the tween (identical strategy to the cluster projector).
1743
+ */
1744
+ onTickFrame(_t) {
1745
+ for (const edge of this.layout.graph.edges) {
1746
+ if (edge.type !== "hierarchy") {
1747
+ continue;
1748
+ }
1749
+ const { source, target } = edge;
1750
+ const s = cartesianToPolar3(source.x ?? 0, source.y ?? 0);
1751
+ const t = cartesianToPolar3(target.x ?? 0, target.y ?? 0);
1752
+ edge.path = linkPath2({
1753
+ source: {
1754
+ x: s.angle,
1755
+ y: s.radius
1756
+ },
1757
+ target: {
1758
+ x: t.angle,
1759
+ y: t.radius
1760
+ }
1761
+ });
1762
+ }
1763
+ }
1764
+ doPlexusLayout() {
1765
+ if (!this.context.size) {
1766
+ return;
1767
+ }
1768
+ const dataNodes = this.#dataNodes;
1769
+ if (!dataNodes.length) {
1770
+ return;
1771
+ }
1772
+ const focusId = this.options.focus;
1773
+ const focusNode = focusId ? dataNodes.find((node) => node.id === focusId) : void 0;
1774
+ if (!focusNode) {
1775
+ const radial = layoutRadial(0, 0, Math.min(this.context.size.width, this.context.size.height) / 2 - (this.options.margin ?? 100), dataNodes.length);
1776
+ dataNodes.forEach((node, index) => updateNode(node, radial(index), this.options.leafRadius ?? 5));
1777
+ this.layout.graph.nodes = dataNodes;
1778
+ this.layout.graph.edges = [];
1779
+ this.animate();
1780
+ return;
1781
+ }
1782
+ const relationOf = this.options.relationOf ?? defaultRelationOf;
1783
+ const groups = /* @__PURE__ */ new Map();
1784
+ const placed = /* @__PURE__ */ new Set([
1785
+ focusId
1786
+ ]);
1787
+ for (const edge of this.#dataEdges) {
1788
+ const relation = relationOf(edge, focusId);
1789
+ if (!relation) {
1790
+ continue;
1791
+ }
1792
+ const neighbour = edge.source.id === focusId ? edge.target : edge.source;
1793
+ if (placed.has(neighbour.id)) {
1794
+ continue;
1795
+ }
1796
+ placed.add(neighbour.id);
1797
+ let group = groups.get(relation.key);
1798
+ if (!group) {
1799
+ group = {
1800
+ id: `${RELATION_PREFIX}${relation.key}`,
1801
+ label: relation.label,
1802
+ leaves: []
1803
+ };
1804
+ groups.set(relation.key, group);
1805
+ }
1806
+ group.leaves.push(neighbour);
1807
+ }
1808
+ const items = [
1809
+ {
1810
+ id: focusId,
1811
+ node: focusNode
1812
+ }
1813
+ ];
1814
+ for (const group of groups.values()) {
1815
+ items.push({
1816
+ id: group.id,
1817
+ parent: focusId,
1818
+ relationLabel: group.label
1819
+ });
1820
+ for (const leaf of group.leaves) {
1821
+ items.push({
1822
+ id: leaf.id,
1823
+ parent: group.id,
1824
+ node: leaf
1825
+ });
1826
+ }
1827
+ }
1828
+ const childrenByParent = /* @__PURE__ */ new Map();
1829
+ for (const item of items) {
1830
+ if (item.parent) {
1831
+ const list = childrenByParent.get(item.parent) ?? [];
1832
+ list.push(item);
1833
+ childrenByParent.set(item.parent, list);
1834
+ }
1835
+ }
1836
+ const root = hierarchy3({
1837
+ id: focusId,
1838
+ node: focusNode
1839
+ }, (d) => childrenByParent.get(d.id) ?? []);
1840
+ const { width, height } = this.context.size;
1841
+ const margin = this.options.margin ?? 100;
1842
+ const ringRadius = Math.max(0, Math.min(width, height) / 2 - margin);
1843
+ d3Cluster3().size([
1844
+ 2 * Math.PI,
1845
+ ringRadius
1846
+ ]).separation((a, b) => (a.parent === b.parent ? 1 : 2) / Math.max(1, a.depth))(root);
1847
+ const leafR = this.options.leafRadius ?? 5;
1848
+ const relationR = this.options.relationRadius ?? leafR;
1849
+ const focusR = this.options.focusRadius ?? leafR * 2;
1850
+ const prevStubsById = /* @__PURE__ */ new Map();
1851
+ for (const node of this.layout.graph.nodes) {
1852
+ if (node.type === PLEXUS_NODE_TYPE_RELATION) {
1853
+ prevStubsById.set(node.id, node);
1854
+ }
1855
+ }
1856
+ const relationStubs = /* @__PURE__ */ new Map();
1857
+ root.each((d) => {
1858
+ const angle = d.x;
1859
+ const radius = d.y;
1860
+ const x = Math.cos(angle - Math.PI / 2) * radius;
1861
+ const y = Math.sin(angle - Math.PI / 2) * radius;
1862
+ const id = d.data.id;
1863
+ if (id === focusId) {
1864
+ updateNode(focusNode, [
1865
+ x,
1866
+ y
1867
+ ], focusR);
1868
+ focusNode.type = PLEXUS_NODE_TYPE_FOCUS;
1869
+ focusNode.hidden = false;
1870
+ } else if (d.data.node) {
1871
+ updateNode(d.data.node, [
1872
+ x,
1873
+ y
1874
+ ], leafR);
1875
+ d.data.node.type = PLEXUS_NODE_TYPE_OBJECT;
1876
+ d.data.node.hidden = false;
1877
+ } else {
1878
+ const stub = prevStubsById.get(id) ?? {
1879
+ id,
1880
+ x: 0,
1881
+ y: 0
1882
+ };
1883
+ updateNode(stub, [
1884
+ x,
1885
+ y
1886
+ ], relationR);
1887
+ stub.type = PLEXUS_NODE_TYPE_RELATION;
1888
+ stub.label = d.data.relationLabel;
1889
+ relationStubs.set(id, stub);
1890
+ }
1891
+ });
1892
+ const nextNodes = [];
1893
+ for (const stub of relationStubs.values()) {
1894
+ nextNodes.push(stub);
1895
+ }
1896
+ for (const group of groups.values()) {
1897
+ for (const leaf of group.leaves) {
1898
+ nextNodes.push(leaf);
1899
+ }
1900
+ }
1901
+ nextNodes.push(focusNode);
1902
+ this.layout.graph.nodes = nextNodes;
1903
+ const edges = [];
1904
+ root.links().forEach((link) => {
1905
+ const sid = link.source.data.id;
1906
+ const tid = link.target.data.id;
1907
+ const sourceNode = sid === focusId ? focusNode : link.source.data.node ?? relationStubs.get(sid);
1908
+ const targetNode = link.target.data.node ?? relationStubs.get(tid);
1909
+ if (!sourceNode || !targetNode) {
1910
+ return;
1911
+ }
1912
+ edges.push({
1913
+ id: `${HIER_EDGE_PREFIX2}${sid}->${tid}`,
1914
+ type: "hierarchy",
1915
+ source: sourceNode,
1916
+ target: targetNode,
1917
+ data: void 0
1918
+ });
1919
+ });
1920
+ this.layout.graph.edges = edges;
1921
+ this.onTickFrame(0);
1922
+ }
1923
+ };
1924
+ var defaultRelationOf = (edge, focusId) => {
1925
+ const outgoing = edge.source.id === focusId;
1926
+ const incoming = edge.target.id === focusId;
1927
+ if (!outgoing && !incoming) {
1928
+ return void 0;
1929
+ }
1930
+ const type = edge.type ?? "edge";
1931
+ const arrow = outgoing ? "\u2192" : "\u2190";
1932
+ return {
1933
+ key: `${type}:${outgoing ? "out" : "in"}`,
1934
+ label: `${type} ${arrow}`
1935
+ };
1936
+ };
1937
+
1938
+ // src/graph/projector/graph-relational-projector.ts
1939
+ import { log as log8 } from "@dxos/log";
1940
+ var __dxlog_file10 = "/__w/dxos/dxos/packages/ui/react-ui-graph/src/graph/projector/graph-relational-projector.ts";
1941
+ var GraphRelationalProjector = class extends GraphRadialProjector {
1942
+ onUpdate(graph) {
1943
+ log8("onUpdate", {
1687
1944
  graph: {
1688
1945
  nodes: graph?.nodes.length,
1689
1946
  edges: graph?.edges.length
1690
1947
  },
1691
1948
  selection: this.selection?.getSelectedIds()
1692
- }, { "~LogMeta": "~LogMeta", F: __dxlog_file9, L: 8, S: this });
1949
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file10, L: 8, S: this });
1693
1950
  this.mergeData(graph);
1694
1951
  this.emitUpdate("topology");
1695
1952
  const selected = this.selection?.getSelectedIds()[0];
@@ -1763,10 +2020,267 @@ var GraphRelationalProjector = class extends GraphRadialProjector {
1763
2020
  }
1764
2021
  };
1765
2022
 
2023
+ // src/graph/projector/graph-swarm-projector.ts
2024
+ import { timer as timer2 } from "d3";
2025
+ import { log as log9 } from "@dxos/log";
2026
+ var __dxlog_file11 = "/__w/dxos/dxos/packages/ui/react-ui-graph/src/graph/projector/graph-swarm-projector.ts";
2027
+ var SWARMMATE_RADIUS = 60;
2028
+ var SEPARATION_DISTANCE = 30;
2029
+ var DEFAULTS = {
2030
+ spawnRadius: 200,
2031
+ maxVelocity: 1.2,
2032
+ alignment: 3,
2033
+ cohesion: 3,
2034
+ separation: 3,
2035
+ cursorRepel: 120,
2036
+ avoidance: 3,
2037
+ trailLength: 30
2038
+ };
2039
+ var GraphSwarmProjector = class extends GraphProjector {
2040
+ #timer;
2041
+ /** Cursor in SVG model coordinates, or null when the pointer is outside the surface. */
2042
+ #cursor = null;
2043
+ findNode() {
2044
+ return void 0;
2045
+ }
2046
+ /**
2047
+ * Tell the projector where the pointer is, in SVG model coordinates (the same space
2048
+ * `node.x/y` live in — center origin, post-zoom). Pass `null` (or omit args) on
2049
+ * pointer-leave to disable cursor avoidance.
2050
+ */
2051
+ setCursor(x, y) {
2052
+ if (x == null || y == null) {
2053
+ this.#cursor = null;
2054
+ } else {
2055
+ this.#cursor = {
2056
+ x,
2057
+ y
2058
+ };
2059
+ }
2060
+ }
2061
+ onUpdate(graph) {
2062
+ log9("onUpdate", {
2063
+ graph: {
2064
+ nodes: graph?.nodes.length,
2065
+ edges: graph?.edges.length
2066
+ }
2067
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file11, L: 54, S: this });
2068
+ this.mergeData(graph);
2069
+ this.initializeNodes();
2070
+ this.emitUpdate("topology");
2071
+ }
2072
+ async onStart() {
2073
+ this.startTimer();
2074
+ }
2075
+ async onStop() {
2076
+ this.stopTimer();
2077
+ }
2078
+ onRefresh() {
2079
+ if (!this.#timer) {
2080
+ this.startTimer();
2081
+ }
2082
+ }
2083
+ #opt(key) {
2084
+ return this.options[key] ?? DEFAULTS[key];
2085
+ }
2086
+ initializeNodes() {
2087
+ const spawnRadius = this.#opt("spawnRadius");
2088
+ const maxVelocity = this.#opt("maxVelocity");
2089
+ for (const node of this.layout.graph.nodes) {
2090
+ if (!node.initialized) {
2091
+ const theta = Math.random() * 2 * Math.PI;
2092
+ const r = Math.random() * spawnRadius;
2093
+ node.x = Math.cos(theta) * r;
2094
+ node.y = Math.sin(theta) * r;
2095
+ const phi = Math.random() * 2 * Math.PI;
2096
+ const speed = (0.3 + Math.random() * 0.7) * maxVelocity;
2097
+ node.vx = Math.cos(phi) * speed;
2098
+ node.vy = Math.sin(phi) * speed;
2099
+ node.ax = 0;
2100
+ node.ay = 0;
2101
+ node.initialized = true;
2102
+ } else {
2103
+ node.vx ??= 0;
2104
+ node.vy ??= 0;
2105
+ node.ax ??= 0;
2106
+ node.ay ??= 0;
2107
+ }
2108
+ node.r ??= 6;
2109
+ node.history = [
2110
+ {
2111
+ x: node.x ?? 0,
2112
+ y: node.y ?? 0
2113
+ }
2114
+ ];
2115
+ }
2116
+ }
2117
+ startTimer() {
2118
+ this.stopTimer();
2119
+ this.#timer = timer2(() => this.tick());
2120
+ }
2121
+ stopTimer() {
2122
+ this.#timer?.stop();
2123
+ this.#timer = void 0;
2124
+ }
2125
+ /**
2126
+ * One simulation step. Modeled on `tick` in Swarm.tsx, but operating in the
2127
+ * SVG centered-origin coordinate space and writing to `node.x/y` directly so
2128
+ * the existing `GraphRenderer.applyPositions` reads them unchanged.
2129
+ */
2130
+ tick() {
2131
+ const size = this.context.size;
2132
+ if (!size) {
2133
+ return;
2134
+ }
2135
+ const { width, height } = size;
2136
+ const halfW = width / 2;
2137
+ const halfH = height / 2;
2138
+ const nodes = this.layout.graph.nodes;
2139
+ const maxVelocity = this.#opt("maxVelocity");
2140
+ const alignmentW = this.#opt("alignment") / 100;
2141
+ const cohesionW = this.#opt("cohesion") / 100;
2142
+ const separationW = this.#opt("separation") / 100;
2143
+ const avoidanceW = this.#opt("avoidance") / 10;
2144
+ const cursorRepel = this.#opt("cursorRepel");
2145
+ const cursor = cursorRepel > 0 ? this.#cursor : null;
2146
+ for (const b1 of nodes) {
2147
+ let ax = 0;
2148
+ let ay = 0;
2149
+ let alignX = 0;
2150
+ let alignY = 0;
2151
+ let alignActive = false;
2152
+ let cohX = 0;
2153
+ let cohY = 0;
2154
+ let cohActive = false;
2155
+ let sepX = 0;
2156
+ let sepY = 0;
2157
+ let sepActive = false;
2158
+ let avoidX = 0;
2159
+ let avoidY = 0;
2160
+ let avoidActive = false;
2161
+ if (cursor) {
2162
+ const dx = cursor.x - (b1.x ?? 0);
2163
+ const dy = cursor.y - (b1.y ?? 0);
2164
+ const distSq = dx * dx + dy * dy;
2165
+ if (distSq > 0 && distSq < cursorRepel * cursorRepel) {
2166
+ const dist = Math.sqrt(distSq);
2167
+ avoidX = -dx / dist * (1 / dist);
2168
+ avoidY = -dy / dist * (1 / dist);
2169
+ avoidActive = true;
2170
+ }
2171
+ }
2172
+ if (!avoidActive) {
2173
+ for (const b2 of nodes) {
2174
+ if (b1 === b2) {
2175
+ continue;
2176
+ }
2177
+ const dx = (b2.x ?? 0) - (b1.x ?? 0);
2178
+ const dy = (b2.y ?? 0) - (b1.y ?? 0);
2179
+ const distSq = dx * dx + dy * dy;
2180
+ if (distSq === 0) {
2181
+ continue;
2182
+ }
2183
+ const dist = Math.sqrt(distSq);
2184
+ if (dist < SEPARATION_DISTANCE) {
2185
+ sepX += -dx / dist * (1 / dist);
2186
+ sepY += -dy / dist * (1 / dist);
2187
+ sepActive = true;
2188
+ }
2189
+ if (dist < SWARMMATE_RADIUS) {
2190
+ cohX += dx;
2191
+ cohY += dy;
2192
+ cohActive = true;
2193
+ alignX += b2.vx ?? 0;
2194
+ alignY += b2.vy ?? 0;
2195
+ alignActive = true;
2196
+ }
2197
+ }
2198
+ }
2199
+ const applyForce = (fx, fy, weight, active) => {
2200
+ if (!active || weight === 0) {
2201
+ return;
2202
+ }
2203
+ const len = Math.sqrt(fx * fx + fy * fy);
2204
+ if (len === 0) {
2205
+ return;
2206
+ }
2207
+ const sx = fx * maxVelocity / len - (b1.vx ?? 0);
2208
+ const sy = fy * maxVelocity / len - (b1.vy ?? 0);
2209
+ const slen = Math.sqrt(sx * sx + sy * sy);
2210
+ if (slen > weight) {
2211
+ ax += sx * weight / slen;
2212
+ ay += sy * weight / slen;
2213
+ } else {
2214
+ ax += sx;
2215
+ ay += sy;
2216
+ }
2217
+ };
2218
+ applyForce(alignX, alignY, alignmentW, alignActive);
2219
+ applyForce(cohX, cohY, cohesionW, cohActive);
2220
+ applyForce(sepX, sepY, separationW, sepActive);
2221
+ applyForce(avoidX, avoidY, avoidanceW, avoidActive);
2222
+ b1.ax = ax;
2223
+ b1.ay = ay;
2224
+ }
2225
+ const trailLength = Math.max(0, Math.round(this.#opt("trailLength")));
2226
+ for (const b of nodes) {
2227
+ let vx = (b.vx ?? 0) + (b.ax ?? 0);
2228
+ let vy = (b.vy ?? 0) + (b.ay ?? 0);
2229
+ const vlen = Math.sqrt(vx * vx + vy * vy);
2230
+ if (vlen > maxVelocity) {
2231
+ vx = vx * maxVelocity / vlen;
2232
+ vy = vy * maxVelocity / vlen;
2233
+ }
2234
+ b.vx = vx;
2235
+ b.vy = vy;
2236
+ if (trailLength > 0) {
2237
+ const history = b.history ?? (b.history = []);
2238
+ history.push({
2239
+ x: b.x ?? 0,
2240
+ y: b.y ?? 0
2241
+ });
2242
+ if (history.length > trailLength) {
2243
+ history.splice(0, history.length - trailLength);
2244
+ }
2245
+ }
2246
+ let x = (b.x ?? 0) + vx;
2247
+ let y = (b.y ?? 0) + vy;
2248
+ let wrapped = false;
2249
+ if (x > halfW) {
2250
+ x -= width;
2251
+ wrapped = true;
2252
+ } else if (x < -halfW) {
2253
+ x += width;
2254
+ wrapped = true;
2255
+ }
2256
+ if (y > halfH) {
2257
+ y -= height;
2258
+ wrapped = true;
2259
+ } else if (y < -halfH) {
2260
+ y += height;
2261
+ wrapped = true;
2262
+ }
2263
+ if (wrapped && b.history) {
2264
+ b.history.length = 0;
2265
+ }
2266
+ b.x = x;
2267
+ b.y = y;
2268
+ }
2269
+ for (const edge of this.layout.graph.edges) {
2270
+ const sx = edge.source.x ?? 0;
2271
+ const sy = edge.source.y ?? 0;
2272
+ const tx = edge.target.x ?? 0;
2273
+ const ty = edge.target.y ?? 0;
2274
+ edge.path = `M ${sx} ${sy} Q 0 0 ${tx} ${ty}`;
2275
+ }
2276
+ this.emitUpdate("positions");
2277
+ }
2278
+ };
2279
+
1766
2280
  // src/graph/renderer/graph-renderer.ts
1767
2281
  import { easeCubicOut, line as line2, polygonHull, select as select4 } from "d3";
1768
2282
  import * as Clipper from "js-clipper";
1769
- import { log as log8 } from "@dxos/log";
2283
+ import { log as log10 } from "@dxos/log";
1770
2284
 
1771
2285
  // src/graph/renderer/bullets.ts
1772
2286
  import { easeLinear, interpolate, select as select3 } from "d3";
@@ -1835,7 +2349,7 @@ var Renderer = class {
1835
2349
  };
1836
2350
 
1837
2351
  // src/graph/renderer/graph-renderer.ts
1838
- var __dxlog_file10 = "/__w/dxos/dxos/packages/ui/react-ui-graph/src/graph/renderer/graph-renderer.ts";
2352
+ var __dxlog_file12 = "/__w/dxos/dxos/packages/ui/react-ui-graph/src/graph/renderer/graph-renderer.ts";
1839
2353
  var createLine2 = line2();
1840
2354
  var EDGE_FADE_MS = 300;
1841
2355
  var NODE_HIDE_MS = 500;
@@ -1854,7 +2368,7 @@ var GraphRenderer = class extends Renderer {
1854
2368
  this.#firstRender = false;
1855
2369
  this.root.replaceChildren();
1856
2370
  }
1857
- log8("render", layout, { "~LogMeta": "~LogMeta", F: __dxlog_file10, L: 35, S: this });
2371
+ log10("render", layout, { "~LogMeta": "~LogMeta", F: __dxlog_file12, L: 35, S: this });
1858
2372
  const root = select4(this.root);
1859
2373
  if (layout.guides) {
1860
2374
  root.selectAll("g.dx-guides").data([
@@ -1912,7 +2426,7 @@ var GraphRenderer = class extends Renderer {
1912
2426
  {
1913
2427
  id: "edges"
1914
2428
  }
1915
- ], (d) => d.id).join("g").classed("dx-edges", true);
2429
+ ], (d) => d.id).join("g").classed("dx-edges", true).style("opacity", this.options.edgeOpacity != null ? String(this.options.edgeOpacity) : null);
1916
2430
  const nodeGroup = root.selectAll("g.dx-nodes").data([
1917
2431
  {
1918
2432
  id: "nodes"
@@ -1943,7 +2457,11 @@ var GraphRenderer = class extends Renderer {
1943
2457
  return;
1944
2458
  }
1945
2459
  const root = select4(this.root);
1946
- root.select("g.dx-nodes").selectAll("g.dx-node").attr("transform", (d) => d.x != null && d.y != null ? `translate(${d.x},${d.y})` : null);
2460
+ const applyNode = this.options.applyNode;
2461
+ root.select("g.dx-nodes").selectAll("g.dx-node").attr("transform", (d) => d.x != null && d.y != null ? `translate(${d.x},${d.y})` : null).each(applyNode ? function(d) {
2462
+ applyNode(this, d);
2463
+ } : () => {
2464
+ });
1947
2465
  root.select("g.dx-edges").selectAll("g.dx-edge").selectAll("path").attr("d", function() {
1948
2466
  const edge = select4(this.parentElement).datum();
1949
2467
  if (edge.path) {
@@ -2002,14 +2520,20 @@ var createNode = (group, options) => {
2002
2520
  g.append("rect");
2003
2521
  g.append("text").style("dominant-baseline", "middle");
2004
2522
  }
2005
- if (options.onNodePointerEnter || options.onNodePointerLeave) {
2523
+ if (options.onNodePointerEnter || options.onNodePointerLeave || options.highlightOnHover) {
2006
2524
  hitTarget.on("pointerenter", function(event) {
2007
2525
  const node = select4(useCustom ? this : this.parentElement).datum();
2008
2526
  options.onNodePointerEnter?.(node, event);
2527
+ if (options.highlightOnHover) {
2528
+ applyHoverHighlight(this.closest("g.dx-graph"), node.id);
2529
+ }
2009
2530
  });
2010
2531
  hitTarget.on("pointerleave", function(event) {
2011
2532
  const node = select4(useCustom ? this : this.parentElement).datum();
2012
2533
  options.onNodePointerLeave?.(node, event);
2534
+ if (options.highlightOnHover) {
2535
+ applyHoverHighlight(this.closest("g.dx-graph"), null);
2536
+ }
2013
2537
  });
2014
2538
  group.attr("data-hover", "handled");
2015
2539
  } else if (options.highlight !== false && !useCustom) {
@@ -2055,9 +2579,9 @@ var updateNode2 = (group, options) => {
2055
2579
  }
2056
2580
  });
2057
2581
  } catch (error) {
2058
- log8.error("updateNode", {
2582
+ log10.error("updateNode", {
2059
2583
  error: error?.message
2060
- }, { "~LogMeta": "~LogMeta", F: __dxlog_file10, L: 292, S: void 0 });
2584
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file12, L: 303, S: void 0 });
2061
2585
  }
2062
2586
  }
2063
2587
  const groupOrTransition = options.transition ? group.transition(options.transition()) : group;
@@ -2108,9 +2632,9 @@ var updateEdge = (group, options, nodeGroup) => {
2108
2632
  }
2109
2633
  });
2110
2634
  } catch (error) {
2111
- log8.error("updateEdge", {
2635
+ log10.error("updateEdge", {
2112
2636
  error: error?.message
2113
- }, { "~LogMeta": "~LogMeta", F: __dxlog_file10, L: 360, S: void 0 });
2637
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file12, L: 371, S: void 0 });
2114
2638
  }
2115
2639
  const groupOrTransition = options.transition ? group.transition(options.transition()) : group;
2116
2640
  groupOrTransition.selectAll("path").attr("d", function() {
@@ -2131,6 +2655,62 @@ var updateEdge = (group, options, nodeGroup) => {
2131
2655
  ], source.r, target.r));
2132
2656
  });
2133
2657
  };
2658
+ var applyHoverHighlight = (root, focusedId) => {
2659
+ if (!root) {
2660
+ return;
2661
+ }
2662
+ const r = select4(root);
2663
+ const on = focusedId != null;
2664
+ const outgoing = /* @__PURE__ */ new Set();
2665
+ const incoming = /* @__PURE__ */ new Set();
2666
+ if (on) {
2667
+ r.select("g.dx-edges").selectAll("g.dx-edge").each((edge) => {
2668
+ if (edge.source.id === focusedId) {
2669
+ outgoing.add(edge.target.id);
2670
+ }
2671
+ if (edge.target.id === focusedId) {
2672
+ incoming.add(edge.source.id);
2673
+ }
2674
+ });
2675
+ }
2676
+ r.select("g.dx-edges").selectAll("g.dx-edge").each(function(edge) {
2677
+ const path = select4(this).select("path:not(.dx-click)");
2678
+ if (!on) {
2679
+ path.style("stroke", null).style("stroke-width", null).style("opacity", null);
2680
+ return;
2681
+ }
2682
+ if (edge.source.id === focusedId) {
2683
+ path.style("stroke", "var(--color-orange-500)").style("stroke-width", "1.5px").style("opacity", null);
2684
+ } else if (edge.target.id === focusedId) {
2685
+ path.style("stroke", "var(--color-sky-500)").style("stroke-width", "1.5px").style("opacity", null);
2686
+ } else {
2687
+ path.style("stroke", null).style("stroke-width", null).style("opacity", "0.8");
2688
+ }
2689
+ });
2690
+ r.select("g.dx-nodes").selectAll("g.dx-node").each(function(node) {
2691
+ const groupSel = select4(this);
2692
+ const shape = groupSel.select("circle, rect");
2693
+ if (node.hidden) {
2694
+ return;
2695
+ }
2696
+ if (!on) {
2697
+ groupSel.style("opacity", null);
2698
+ shape.style("stroke", null).style("stroke-width", null);
2699
+ return;
2700
+ }
2701
+ const connected = outgoing.has(node.id) || incoming.has(node.id);
2702
+ if (node.id === focusedId) {
2703
+ groupSel.style("opacity", null);
2704
+ shape.style("stroke", null).style("stroke-width", null);
2705
+ } else if (connected) {
2706
+ groupSel.style("opacity", null);
2707
+ shape.style("stroke", "var(--color-orange-400)").style("stroke-width", "2.5px");
2708
+ } else {
2709
+ groupSel.style("opacity", "0.4");
2710
+ shape.style("stroke", null).style("stroke-width", null);
2711
+ }
2712
+ });
2713
+ };
2134
2714
  var applyClasses = (el, classes) => {
2135
2715
  for (const [className, value] of Object.entries(classes)) {
2136
2716
  el.classed(className, value);
@@ -2169,6 +2749,45 @@ var findConnectedComponents = (graph) => {
2169
2749
  return components;
2170
2750
  };
2171
2751
 
2752
+ // src/graph/renderer/labels.ts
2753
+ var DEFAULT_DURATION = 200;
2754
+ var DEFAULT_OFFSET = 4;
2755
+ var getTarget = (node) => {
2756
+ const tx = node.tx;
2757
+ const ty = node.ty;
2758
+ return {
2759
+ x: tx ?? node.x ?? 0,
2760
+ y: ty ?? node.y ?? 0
2761
+ };
2762
+ };
2763
+ var appendRadialLeafLabel = (group, node, label, r, options = {}) => {
2764
+ if (!label) {
2765
+ return;
2766
+ }
2767
+ const { delay = 0, duration = DEFAULT_DURATION, offset = DEFAULT_OFFSET, className = "dx-cluster-label" } = options;
2768
+ const { x: targetX, y: targetY } = getTarget(node);
2769
+ const angleDeg = Math.atan2(targetY, targetX) * 180 / Math.PI;
2770
+ const flipped = angleDeg > 90 || angleDeg < -90;
2771
+ group.append("text").attr("class", className).attr("dy", "0.32em").attr("transform", `rotate(${flipped ? angleDeg + 180 : angleDeg})`).attr("x", flipped ? -(r + offset) : r + offset).attr("text-anchor", flipped ? "end" : "start").attr("opacity", 0).style("cursor", "pointer").text(label).transition().delay(delay).duration(duration).attr("opacity", 1);
2772
+ };
2773
+ var appendRadialGroupLabel = (group, node, label, r, options = {}) => {
2774
+ if (!label) {
2775
+ return;
2776
+ }
2777
+ const { delay = 0, duration = DEFAULT_DURATION, offset = DEFAULT_OFFSET, className = "dx-cluster-label dx-cluster-label-group" } = options;
2778
+ const { x: targetX, y: targetY } = getTarget(node);
2779
+ const angleDeg = Math.atan2(targetY, targetX) * 180 / Math.PI;
2780
+ const flipped = angleDeg > 90 || angleDeg < -90;
2781
+ group.append("text").attr("class", className).attr("dy", "0.32em").attr("transform", `rotate(${flipped ? angleDeg + 180 : angleDeg})`).attr("x", flipped ? r + offset : -(r + offset)).attr("text-anchor", flipped ? "start" : "end").attr("opacity", 0).style("pointer-events", "none").text(label).transition().delay(delay).duration(duration).attr("opacity", 1);
2782
+ };
2783
+ var appendRootLabel = (group, label, r, options = {}) => {
2784
+ if (!label) {
2785
+ return;
2786
+ }
2787
+ const { delay = 0, duration = DEFAULT_DURATION, offset = 6, className = "dx-cluster-label dx-cluster-label-root" } = options;
2788
+ group.append("text").attr("class", className).attr("text-anchor", "middle").attr("y", -(r + offset)).attr("opacity", 0).style("pointer-events", "none").text(label).transition().delay(delay).duration(duration).attr("opacity", 1);
2789
+ };
2790
+
2172
2791
  // src/graph/renderer/linker.ts
2173
2792
  import { line as line3 } from "d3";
2174
2793
  var createLine3 = line3();
@@ -2511,8 +3130,8 @@ var useZoom = (options = defaultZoomOptions) => {
2511
3130
  };
2512
3131
 
2513
3132
  // src/components/Graph/Graph.tsx
2514
- var __dxlog_file11 = "/__w/dxos/dxos/packages/ui/react-ui-graph/src/components/Graph/Graph.tsx";
2515
- var GraphInner = ({ classNames, model, projector: projectorProp, renderer: rendererProp, drag: drag2, arrows, onSelect, onInspect, ...props }, forwardedRef) => {
3133
+ var __dxlog_file13 = "/__w/dxos/dxos/packages/ui/react-ui-graph/src/components/Graph/Graph.tsx";
3134
+ var GraphInner = ({ classNames, model, projector: projectorProp, renderer: rendererProp, drag: drag2, arrows, onSelect, onInspect, onPointerMove, onPointerLeave, ...props }, forwardedRef) => {
2516
3135
  const context = useSvgContext();
2517
3136
  const graphRef = useRef3(null);
2518
3137
  const { projector, renderer } = useMemo3(() => {
@@ -2529,7 +3148,14 @@ var GraphInner = ({ classNames, model, projector: projectorProp, renderer: rende
2529
3148
  arrows: {
2530
3149
  end: arrows
2531
3150
  },
2532
- onNodeClick: onSelect,
3151
+ // Projector intercept first so built-in interactions (e.g. cluster collapse) can
3152
+ // run without consumers wiring them. Returning true suppresses the user handler.
3153
+ onNodeClick: (node, event) => {
3154
+ if (projector2.handleNodeClick(node, event)) {
3155
+ return;
3156
+ }
3157
+ onSelect?.(node, event);
3158
+ },
2533
3159
  onNodePointerEnter: onInspect ? (node, event) => onInspect(node, event) : void 0,
2534
3160
  // Pair pointerenter with leave so consumers can clear hover-driven previews.
2535
3161
  // The callback receives `null` on leave (event still carries the source).
@@ -2551,7 +3177,10 @@ var GraphInner = ({ classNames, model, projector: projectorProp, renderer: rende
2551
3177
  props.labels,
2552
3178
  props.subgraphs,
2553
3179
  props.attributes,
2554
- props.renderNode
3180
+ props.renderNode,
3181
+ props.highlightOnHover,
3182
+ props.applyNode,
3183
+ props.edgeOpacity
2555
3184
  ]);
2556
3185
  useImperativeHandle(forwardedRef, () => ({
2557
3186
  refresh: () => {
@@ -2582,7 +3211,7 @@ var GraphInner = ({ classNames, model, projector: projectorProp, renderer: rende
2582
3211
  renderer.render(layout);
2583
3212
  }
2584
3213
  } catch (error) {
2585
- log9.catch(error, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file11, L: 85, S: void 0 });
3214
+ log11.catch(error, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file13, L: 95, S: void 0 });
2586
3215
  void projector.stop();
2587
3216
  }
2588
3217
  })
@@ -2602,6 +3231,49 @@ var GraphInner = ({ classNames, model, projector: projectorProp, renderer: rende
2602
3231
  }, [
2603
3232
  projector
2604
3233
  ]);
3234
+ useEffect3(() => {
3235
+ if (!onPointerMove && !onPointerLeave) {
3236
+ return;
3237
+ }
3238
+ const svg = context.svg;
3239
+ if (!svg) {
3240
+ return;
3241
+ }
3242
+ const previousPointerEvents = svg.style.pointerEvents;
3243
+ svg.style.pointerEvents = "all";
3244
+ const handleMove = (event) => {
3245
+ if (!onPointerMove) {
3246
+ return;
3247
+ }
3248
+ const target = graphRef.current;
3249
+ const ctm = target?.getScreenCTM();
3250
+ if (!target || !ctm) {
3251
+ return;
3252
+ }
3253
+ const point = svg.createSVGPoint();
3254
+ point.x = event.clientX;
3255
+ point.y = event.clientY;
3256
+ const modelPoint = point.matrixTransform(ctm.inverse());
3257
+ onPointerMove({
3258
+ x: modelPoint.x,
3259
+ y: modelPoint.y
3260
+ }, event);
3261
+ };
3262
+ const handleLeave = (event) => {
3263
+ onPointerLeave?.(event);
3264
+ };
3265
+ svg.addEventListener("pointermove", handleMove);
3266
+ svg.addEventListener("pointerleave", handleLeave);
3267
+ return () => {
3268
+ svg.removeEventListener("pointermove", handleMove);
3269
+ svg.removeEventListener("pointerleave", handleLeave);
3270
+ svg.style.pointerEvents = previousPointerEvents;
3271
+ };
3272
+ }, [
3273
+ context,
3274
+ onPointerMove,
3275
+ onPointerLeave
3276
+ ]);
2605
3277
  return /* @__PURE__ */ React.createElement("g", {
2606
3278
  ref: graphRef,
2607
3279
  className: mx("dx-graph", classNames)
@@ -2747,30 +3419,86 @@ var hexProjection = (radius) => {
2747
3419
  };
2748
3420
  };
2749
3421
 
2750
- // src/components/SVG/Grid.tsx
2751
- import React2 from "react";
3422
+ // src/components/SVG/FPS.tsx
3423
+ import React2, { useEffect as useEffect5, useState } from "react";
2752
3424
  import { mx as mx2 } from "@dxos/ui-theme";
3425
+ var PADDING = 8;
3426
+ var FPS = ({ classNames, corner = "top-right", margin = PADDING }) => {
3427
+ const context = useSvgContext();
3428
+ const [size, setSize] = useState(context.size);
3429
+ const [fps, setFps] = useState(null);
3430
+ useEffect5(() => {
3431
+ setSize(context.size);
3432
+ return context.resized.on((ctx) => setSize(ctx.size));
3433
+ }, [
3434
+ context
3435
+ ]);
3436
+ useEffect5(() => {
3437
+ let frames = 0;
3438
+ let windowStart = performance.now();
3439
+ let rafId = 0;
3440
+ const loop = (now) => {
3441
+ frames++;
3442
+ const elapsed = now - windowStart;
3443
+ if (elapsed >= 1e3) {
3444
+ setFps(frames * 1e3 / elapsed);
3445
+ frames = 0;
3446
+ windowStart = now;
3447
+ }
3448
+ rafId = requestAnimationFrame(loop);
3449
+ };
3450
+ rafId = requestAnimationFrame(loop);
3451
+ return () => cancelAnimationFrame(rafId);
3452
+ }, []);
3453
+ if (!size) {
3454
+ return null;
3455
+ }
3456
+ const halfW = size.width / 2;
3457
+ const halfH = size.height / 2;
3458
+ const left = corner === "top-left" || corner === "bottom-left";
3459
+ const top = corner === "top-left" || corner === "top-right";
3460
+ const x = left ? -halfW + margin : halfW - margin;
3461
+ const y = top ? -halfH + margin : halfH - margin;
3462
+ const textAnchor = left ? "start" : "end";
3463
+ const dominantBaseline = top ? "hanging" : "alphabetic";
3464
+ return /* @__PURE__ */ React2.createElement("g", {
3465
+ className: "dx-fps",
3466
+ style: {
3467
+ pointerEvents: "none"
3468
+ }
3469
+ }, /* @__PURE__ */ React2.createElement("text", {
3470
+ x,
3471
+ y,
3472
+ textAnchor,
3473
+ dominantBaseline,
3474
+ className: mx2("font-mono text-xs fill-neutral-500 tabular-nums", classNames)
3475
+ }, fps == null ? "\u2014 fps" : `${fps.toFixed(0)} fps`));
3476
+ };
3477
+
3478
+ // src/components/SVG/Grid.tsx
3479
+ import React3 from "react";
3480
+ import { mx as mx3 } from "@dxos/ui-theme";
2753
3481
  var Grid = ({ classNames, ...props }) => {
2754
3482
  const { ref } = useGrid(props);
2755
- return /* @__PURE__ */ React2.createElement("g", {
3483
+ return /* @__PURE__ */ React3.createElement("g", {
2756
3484
  ref,
2757
- className: mx2("dx-grid", classNames)
3485
+ className: mx3("dx-grid", classNames)
2758
3486
  });
2759
3487
  };
2760
3488
 
2761
3489
  // src/components/SVG/Markers.tsx
2762
3490
  import { select as select8 } from "d3";
2763
- import React3, { useEffect as useEffect5, useRef as useRef4 } from "react";
3491
+ import React4, { useEffect as useEffect6, useRef as useRef4 } from "react";
2764
3492
  var Markers = ({ arrowSize, className }) => {
2765
3493
  const ref = useRef4(null);
2766
- useEffect5(() => {
3494
+ useEffect6(() => {
2767
3495
  select8(ref.current).call(createMarkers({
2768
3496
  arrowSize
2769
3497
  }));
2770
3498
  }, [
2771
3499
  ref
2772
3500
  ]);
2773
- return /* @__PURE__ */ React3.createElement("defs", {
3501
+ return /* @__PURE__ */ React4.createElement("defs", {
2774
3502
  ref,
2775
3503
  className
2776
3504
  });
@@ -2778,15 +3506,16 @@ var Markers = ({ arrowSize, className }) => {
2778
3506
 
2779
3507
  // src/components/SVG/Root.tsx
2780
3508
  import { select as select9 } from "d3";
2781
- import React4, { forwardRef as forwardRef2, useEffect as useEffect6, useImperativeHandle as useImperativeHandle2, useMemo as useMemo4, useState } from "react";
2782
- import { composableProps, mx as mx3 } from "@dxos/ui-theme";
3509
+ import React5, { forwardRef as forwardRef2, useEffect as useEffect7, useImperativeHandle as useImperativeHandle2, useMemo as useMemo4, useState as useState2 } from "react";
3510
+ import { composableProps } from "@dxos/react-ui";
3511
+ import { mx as mx4 } from "@dxos/ui-theme";
2783
3512
  var Root = /* @__PURE__ */ forwardRef2(({ children, scale, centered, ...props }, ref) => {
2784
- const [container, setContainer] = useState(null);
2785
- const [size, setSize] = useState({
3513
+ const [container, setContainer] = useState2(null);
3514
+ const [size, setSize] = useState2({
2786
3515
  width: 0,
2787
3516
  height: 0
2788
3517
  });
2789
- useEffect6(() => {
3518
+ useEffect7(() => {
2790
3519
  if (!container) {
2791
3520
  return;
2792
3521
  }
@@ -2824,7 +3553,7 @@ var Root = /* @__PURE__ */ forwardRef2(({ children, scale, centered, ...props },
2824
3553
  useImperativeHandle2(ref, () => context, [
2825
3554
  context
2826
3555
  ]);
2827
- useEffect6(() => {
3556
+ useEffect7(() => {
2828
3557
  if (width && height) {
2829
3558
  context.setSize({
2830
3559
  width,
@@ -2838,22 +3567,22 @@ var Root = /* @__PURE__ */ forwardRef2(({ children, scale, centered, ...props },
2838
3567
  height
2839
3568
  ]);
2840
3569
  const ready = width !== 0 && height !== 0;
2841
- return /* @__PURE__ */ React4.createElement(SVGContextProvider, {
3570
+ return /* @__PURE__ */ React5.createElement(SVGContextProvider, {
2842
3571
  value: context
2843
- }, /* @__PURE__ */ React4.createElement("div", {
3572
+ }, /* @__PURE__ */ React5.createElement("div", {
2844
3573
  ...composableProps(props, {
2845
3574
  classNames: "dx-expander"
2846
3575
  }),
2847
3576
  ref: setContainer
2848
- }, /* @__PURE__ */ React4.createElement("svg", {
3577
+ }, /* @__PURE__ */ React5.createElement("svg", {
2849
3578
  xmlns: "http://www.w3.org/2000/svg",
2850
3579
  ref: context.ref,
2851
- className: mx3("transition-opacity opacity-0 duration-1000", ready && "opacity-100")
3580
+ className: mx4("transition-opacity opacity-0 duration-1000", ready && "opacity-100")
2852
3581
  }, ready && children)));
2853
3582
  });
2854
3583
 
2855
3584
  // src/components/SVG/Zoom.tsx
2856
- import React5, { memo, useMemo as useMemo5 } from "react";
3585
+ import React6, { memo, useMemo as useMemo5 } from "react";
2857
3586
  var Zoom = /* @__PURE__ */ memo(({ extent, className, children }) => {
2858
3587
  const options = useMemo5(() => ({
2859
3588
  extent
@@ -2861,7 +3590,7 @@ var Zoom = /* @__PURE__ */ memo(({ extent, className, children }) => {
2861
3590
  JSON.stringify(extent)
2862
3591
  ]);
2863
3592
  const zoom2 = useZoom(options);
2864
- return /* @__PURE__ */ React5.createElement("g", {
3593
+ return /* @__PURE__ */ React6.createElement("g", {
2865
3594
  ref: zoom2.ref,
2866
3595
  className
2867
3596
  }, children);
@@ -2874,7 +3603,8 @@ var SVG = {
2874
3603
  Markers,
2875
3604
  Mesh,
2876
3605
  Zoom,
2877
- Graph
3606
+ Graph,
3607
+ FPS
2878
3608
  };
2879
3609
 
2880
3610
  // src/fx/pulsar.ts
@@ -2913,12 +3643,17 @@ export {
2913
3643
  GraphForceProjector,
2914
3644
  GraphHierarchicalProjector,
2915
3645
  GraphLatticeProjector,
3646
+ GraphPlexusProjector,
2916
3647
  GraphProjector,
2917
3648
  GraphRadialProjector,
2918
3649
  GraphRelationalProjector,
2919
3650
  GraphRenderer,
3651
+ GraphSwarmProjector,
2920
3652
  GridController,
2921
3653
  Mesh,
3654
+ PLEXUS_NODE_TYPE_FOCUS,
3655
+ PLEXUS_NODE_TYPE_OBJECT,
3656
+ PLEXUS_NODE_TYPE_RELATION,
2922
3657
  Projector,
2923
3658
  Pulsar,
2924
3659
  Renderer,
@@ -2929,6 +3664,9 @@ export {
2929
3664
  Screen,
2930
3665
  Vector,
2931
3666
  ZoomHandler,
3667
+ appendRadialGroupLabel,
3668
+ appendRadialLeafLabel,
3669
+ appendRootLabel,
2932
3670
  createGraphDrag,
2933
3671
  createMarkers,
2934
3672
  defaultForceOptions,