@dxos/react-ui-graph 0.8.4-main.fffef41 → 0.9.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.
Files changed (138) hide show
  1. package/LICENSE +102 -5
  2. package/README.md +5 -7
  3. package/dist/lib/browser/chunk-EASNZZ7B.mjs +52 -0
  4. package/dist/lib/browser/chunk-EASNZZ7B.mjs.map +7 -0
  5. package/dist/lib/browser/index.mjs +2729 -592
  6. package/dist/lib/browser/index.mjs.map +4 -4
  7. package/dist/lib/browser/meta.json +1 -1
  8. package/dist/lib/browser/testing/index.mjs +16 -16
  9. package/dist/lib/browser/testing/index.mjs.map +3 -3
  10. package/dist/lib/node-esm/chunk-JSE2X4ML.mjs +54 -0
  11. package/dist/lib/node-esm/chunk-JSE2X4ML.mjs.map +7 -0
  12. package/dist/lib/node-esm/index.mjs +2729 -592
  13. package/dist/lib/node-esm/index.mjs.map +4 -4
  14. package/dist/lib/node-esm/meta.json +1 -1
  15. package/dist/lib/node-esm/testing/index.mjs +16 -16
  16. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  17. package/dist/types/src/components/Graph/Graph.d.ts +23 -6
  18. package/dist/types/src/components/Graph/Graph.d.ts.map +1 -1
  19. package/dist/types/src/components/Graph/Graph.stories.d.ts +6 -6
  20. package/dist/types/src/components/Graph/Graph.stories.d.ts.map +1 -1
  21. package/dist/types/src/components/Mesh/Mesh.d.ts.map +1 -1
  22. package/dist/types/src/components/Mesh/Mesh.stories.d.ts.map +1 -1
  23. package/dist/types/src/components/SVG/FPS.d.ts +20 -0
  24. package/dist/types/src/components/SVG/FPS.d.ts.map +1 -0
  25. package/dist/types/src/components/SVG/Grid.d.ts.map +1 -1
  26. package/dist/types/src/components/SVG/Markers.d.ts.map +1 -1
  27. package/dist/types/src/components/SVG/Root.d.ts +8 -4
  28. package/dist/types/src/components/SVG/Root.d.ts.map +1 -1
  29. package/dist/types/src/components/SVG/SVG.d.ts +17 -18
  30. package/dist/types/src/components/SVG/SVG.d.ts.map +1 -1
  31. package/dist/types/src/components/SVG/Svg.stories.d.ts +1 -1
  32. package/dist/types/src/components/SVG/Svg.stories.d.ts.map +1 -1
  33. package/dist/types/src/fx/fx.stories.d.ts +3 -3
  34. package/dist/types/src/fx/fx.stories.d.ts.map +1 -1
  35. package/dist/types/src/fx/pulsar.d.ts.map +1 -1
  36. package/dist/types/src/graph/markers.d.ts.map +1 -1
  37. package/dist/types/src/graph/projector/graph-bundle-projector.d.ts +47 -0
  38. package/dist/types/src/graph/projector/graph-bundle-projector.d.ts.map +1 -0
  39. package/dist/types/src/graph/projector/graph-cluster-projector.d.ts +65 -0
  40. package/dist/types/src/graph/projector/graph-cluster-projector.d.ts.map +1 -0
  41. package/dist/types/src/graph/projector/graph-drag.d.ts.map +1 -1
  42. package/dist/types/src/graph/projector/graph-force-projector.d.ts +1 -1
  43. package/dist/types/src/graph/projector/graph-force-projector.d.ts.map +1 -1
  44. package/dist/types/src/graph/projector/graph-forces.d.ts.map +1 -1
  45. package/dist/types/src/graph/projector/graph-hierarchical-projector.d.ts +1 -1
  46. package/dist/types/src/graph/projector/graph-hierarchical-projector.d.ts.map +1 -1
  47. package/dist/types/src/graph/projector/graph-lattice-projector.d.ts +23 -0
  48. package/dist/types/src/graph/projector/graph-lattice-projector.d.ts.map +1 -0
  49. package/dist/types/src/graph/projector/graph-plexus-projector.d.ts +67 -0
  50. package/dist/types/src/graph/projector/graph-plexus-projector.d.ts.map +1 -0
  51. package/dist/types/src/graph/projector/graph-plexus-projector.test.d.ts +2 -0
  52. package/dist/types/src/graph/projector/graph-plexus-projector.test.d.ts.map +1 -0
  53. package/dist/types/src/graph/projector/graph-projector.d.ts +10 -2
  54. package/dist/types/src/graph/projector/graph-projector.d.ts.map +1 -1
  55. package/dist/types/src/graph/projector/graph-radial-projector.d.ts +7 -1
  56. package/dist/types/src/graph/projector/graph-radial-projector.d.ts.map +1 -1
  57. package/dist/types/src/graph/projector/graph-relational-projector.d.ts +1 -1
  58. package/dist/types/src/graph/projector/graph-relational-projector.d.ts.map +1 -1
  59. package/dist/types/src/graph/projector/graph-swarm-projector.d.ts +72 -0
  60. package/dist/types/src/graph/projector/graph-swarm-projector.d.ts.map +1 -0
  61. package/dist/types/src/graph/projector/index.d.ts +5 -0
  62. package/dist/types/src/graph/projector/index.d.ts.map +1 -1
  63. package/dist/types/src/graph/projector/projector.d.ts +10 -1
  64. package/dist/types/src/graph/projector/projector.d.ts.map +1 -1
  65. package/dist/types/src/graph/renderer/bullets.d.ts.map +1 -1
  66. package/dist/types/src/graph/renderer/graph-renderer.d.ts +41 -1
  67. package/dist/types/src/graph/renderer/graph-renderer.d.ts.map +1 -1
  68. package/dist/types/src/graph/renderer/index.d.ts +1 -0
  69. package/dist/types/src/graph/renderer/index.d.ts.map +1 -1
  70. package/dist/types/src/graph/renderer/labels.d.ts +33 -0
  71. package/dist/types/src/graph/renderer/labels.d.ts.map +1 -0
  72. package/dist/types/src/graph/renderer/renderer.d.ts +12 -1
  73. package/dist/types/src/graph/renderer/renderer.d.ts.map +1 -1
  74. package/dist/types/src/graph/types.d.ts +15 -1
  75. package/dist/types/src/graph/types.d.ts.map +1 -1
  76. package/dist/types/src/hooks/useGrid.d.ts.map +1 -1
  77. package/dist/types/src/hooks/useStateRef.d.ts.map +1 -1
  78. package/dist/types/src/hooks/useSvgContext.d.ts.map +1 -1
  79. package/dist/types/src/hooks/useZoom.d.ts.map +1 -1
  80. package/dist/types/src/stories/experimental.stories.d.ts +7 -0
  81. package/dist/types/src/stories/experimental.stories.d.ts.map +1 -0
  82. package/dist/types/src/stories/hooks.stories.d.ts +4 -3
  83. package/dist/types/src/stories/hooks.stories.d.ts.map +1 -1
  84. package/dist/types/src/testing/data.d.ts +5 -5
  85. package/dist/types/src/testing/data.d.ts.map +1 -1
  86. package/dist/types/src/testing/hooks.d.ts +2 -16
  87. package/dist/types/src/testing/hooks.d.ts.map +1 -1
  88. package/dist/types/src/testing/model.d.ts +4 -8
  89. package/dist/types/src/testing/model.d.ts.map +1 -1
  90. package/dist/types/src/util/events.d.ts.map +1 -1
  91. package/dist/types/src/util/fraction.d.ts +1 -1
  92. package/dist/types/src/util/fraction.d.ts.map +1 -1
  93. package/dist/types/src/util/points.d.ts.map +1 -1
  94. package/dist/types/src/util/scale.d.ts.map +1 -1
  95. package/dist/types/src/util/screen.d.ts.map +1 -1
  96. package/dist/types/src/util/vector.d.ts.map +1 -1
  97. package/dist/types/tsconfig.tsbuildinfo +1 -1
  98. package/package.json +33 -35
  99. package/src/components/Graph/Graph.stories.tsx +45 -39
  100. package/src/components/Graph/Graph.tsx +126 -23
  101. package/src/components/Mesh/Mesh.stories.tsx +8 -7
  102. package/src/components/Mesh/Mesh.tsx +43 -35
  103. package/src/components/SVG/FPS.tsx +91 -0
  104. package/src/components/SVG/Grid.tsx +1 -1
  105. package/src/components/SVG/Root.tsx +42 -9
  106. package/src/components/SVG/SVG.tsx +14 -3
  107. package/src/components/SVG/Svg.stories.tsx +4 -5
  108. package/src/fx/fx.stories.tsx +7 -8
  109. package/src/graph/projector/graph-bundle-projector.ts +210 -0
  110. package/src/graph/projector/graph-cluster-projector.ts +337 -0
  111. package/src/graph/projector/graph-drag.ts +0 -1
  112. package/src/graph/projector/graph-force-projector.ts +7 -3
  113. package/src/graph/projector/graph-hierarchical-projector.ts +4 -4
  114. package/src/graph/projector/graph-lattice-projector.ts +86 -0
  115. package/src/graph/projector/graph-plexus-projector.test.ts +102 -0
  116. package/src/graph/projector/graph-plexus-projector.ts +309 -0
  117. package/src/graph/projector/graph-projector.ts +24 -4
  118. package/src/graph/projector/graph-radial-projector.ts +31 -4
  119. package/src/graph/projector/graph-relational-projector.ts +4 -4
  120. package/src/graph/projector/graph-swarm-projector.ts +373 -0
  121. package/src/graph/projector/index.ts +5 -0
  122. package/src/graph/projector/projector.ts +12 -3
  123. package/src/graph/renderer/graph-renderer.ts +289 -31
  124. package/src/graph/renderer/index.ts +1 -0
  125. package/src/graph/renderer/labels.ts +138 -0
  126. package/src/graph/renderer/renderer.ts +15 -4
  127. package/src/graph/types.ts +15 -1
  128. package/src/stories/experimental.stories.tsx +446 -0
  129. package/src/stories/hooks.stories.tsx +21 -10
  130. package/src/testing/data.ts +14 -14
  131. package/src/testing/hooks.ts +3 -4
  132. package/src/testing/model.ts +6 -6
  133. package/src/util/fraction.ts +1 -1
  134. package/styles/graph.css +341 -43
  135. package/dist/lib/browser/chunk-XWA2XJDX.mjs +0 -955
  136. package/dist/lib/browser/chunk-XWA2XJDX.mjs.map +0 -7
  137. package/dist/lib/node-esm/chunk-3RLSFEEV.mjs +0 -957
  138. package/dist/lib/node-esm/chunk-3RLSFEEV.mjs.map +0 -7
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../src/components/Graph/Graph.tsx", "../../../src/graph/markers.ts", "../../../src/graph/projector/graph-drag.ts", "../../../src/graph/types.ts", "../../../src/graph/projector/projector.ts", "../../../src/graph/projector/graph-projector.ts", "../../../src/graph/projector/graph-force-projector.ts", "../../../src/graph/projector/graph-forces.ts", "../../../src/graph/projector/graph-hierarchical-projector.ts", "../../../src/graph/projector/graph-radial-projector.ts", "../../../src/graph/projector/graph-relational-projector.ts", "../../../src/graph/renderer/graph-renderer.ts", "../../../src/graph/renderer/bullets.ts", "../../../src/graph/renderer/renderer.ts", "../../../src/graph/renderer/linker.ts", "../../../src/components/Mesh/Mesh.tsx", "../../../src/components/SVG/Grid.tsx", "../../../src/components/SVG/Markers.tsx", "../../../src/components/SVG/Root.tsx", "../../../src/components/SVG/Zoom.tsx", "../../../src/components/SVG/SVG.tsx", "../../../src/fx/pulsar.ts"],
4
- "sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\nimport { effect } from '@preact/signals-core';\nimport React, { type JSX, type Ref, forwardRef, useEffect, useImperativeHandle, useMemo, useRef } from 'react';\n\nimport { combine } from '@dxos/async';\nimport { type BaseGraphEdge, type BaseGraphNode, type GraphModel } from '@dxos/graph';\nimport { log } from '@dxos/log';\nimport { type ThemedClassName } from '@dxos/react-ui';\nimport { mx } from '@dxos/react-ui-theme';\n\nimport {\n GraphForceProjector,\n type GraphLayoutNode,\n type GraphProjector,\n GraphRenderer,\n type GraphRendererOptions,\n createGraphDrag,\n} from '../../graph';\nimport { useSvgContext } from '../../hooks';\n\nexport type GraphController = {\n refresh: () => void;\n repaint: () => void;\n findNode: (id: string) => SVGGElement | null;\n};\n\nexport type GraphProps<Node extends BaseGraphNode = any, Edge extends BaseGraphEdge = any> = ThemedClassName<\n Pick<GraphRendererOptions<Node>, 'labels' | 'subgraphs' | 'attributes'> & {\n model?: GraphModel<Node, Edge>; // TODO(burdon): ReactiveGraphModel\n projector?: GraphProjector<Node>;\n renderer?: GraphRenderer<Node>;\n drag?: boolean;\n arrows?: boolean;\n onSelect?: (node: GraphLayoutNode<Node>, event: MouseEvent) => void;\n onInspect?: (node: GraphLayoutNode<Node>, event: MouseEvent) => void;\n }\n>;\n\nexport const GraphInner = <Node extends BaseGraphNode = any, Edge extends BaseGraphEdge = any>(\n {\n classNames,\n model,\n projector: _projector,\n renderer: _renderer,\n drag,\n arrows,\n onSelect,\n onInspect,\n ...props\n }: GraphProps<Node, Edge>,\n forwardedRef: Ref<GraphController>,\n) => {\n const context = useSvgContext();\n const graphRef = useRef<SVGGElement>(null);\n\n const { projector, renderer } = useMemo(() => {\n let projector = _projector;\n if (!projector) {\n projector = new GraphForceProjector<Node>(context);\n }\n\n let renderer = _renderer;\n if (!renderer) {\n renderer = new GraphRenderer<Node>(context, graphRef, {\n ...props,\n // TODO(burdon): Replace drag when projector is updated.\n drag: drag ? createGraphDrag(context, projector) : undefined,\n arrows: { end: arrows },\n onNodeClick: onSelect ? (node: GraphLayoutNode, event) => onSelect(node, event) : undefined,\n onNodePointerEnter: onInspect ? (node: GraphLayoutNode, event) => onInspect(node, event) : undefined,\n });\n }\n\n return { projector, renderer };\n }, [context, _projector, _renderer, drag]);\n\n // External API.\n useImperativeHandle(\n forwardedRef,\n () => ({\n refresh: () => {\n projector.updateData(model?.graph);\n },\n repaint: () => {\n renderer.render(projector.layout);\n },\n findNode: (id: string) => {\n return graphRef.current?.querySelector<SVGGElement>(`g[data-id=\"${id}\"]`);\n },\n }),\n [model, projector, renderer],\n );\n\n // Subscriptions.\n useEffect(() => {\n return combine(\n effect(() => {\n projector.updateData(model?.graph);\n }),\n projector.updated.on(({ layout }) => {\n try {\n renderer.render(layout);\n } catch (error) {\n void projector.stop();\n log.catch(error);\n }\n }),\n );\n }, [model, projector, renderer]);\n\n // Start.\n useEffect(() => {\n void projector.start();\n return () => {\n void projector.stop();\n };\n }, [projector]);\n\n return <g ref={graphRef} className={mx('dx-graph', classNames)} />;\n};\n\n/**\n * SVG Graph.\n */\nexport const Graph = forwardRef(GraphInner) as <Node extends BaseGraphNode = any, Edge extends BaseGraphEdge = any>(\n props: GraphProps<Node, Edge> & { ref?: Ref<GraphController> },\n) => JSX.Element;\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { line, select } from 'd3';\n\nimport { type D3Callable } from '../util';\n\nconst createLine = line();\n\nexport type MarkerOptions = {\n arrowSize?: number;\n};\n\nconst createArrow =\n (length: number, offset: number, start: boolean): D3Callable =>\n (el) => {\n const height = length * 0.5;\n el.attr('markerWidth', length * 2)\n .attr('markerHeight', height * 2)\n .attr('viewBox', `-${length},-${height},${length * 2},${height * 2}`)\n .attr('orient', 'auto')\n .attr('refX', offset)\n .append('path')\n .attr('fill', 'none')\n // Inherit stroke from path.\n .attr('stroke', 'context-stroke')\n .attr(\n 'd',\n createLine([\n start ? [length, height] : [-length, -height],\n [0, 0],\n start ? [length, -height] : [-length, height],\n ]),\n );\n };\n\nconst createDot =\n (size: number): D3Callable =>\n (el) => {\n el.attr('markerWidth', size * 2)\n .attr('markerHeight', size * 2)\n .attr('viewBox', `-${size},-${size},${size * 2},${size * 2}`)\n .attr('orient', 'auto')\n .append('circle')\n // Inherit stroke from path.\n .attr('fill', 'context-stroke')\n .attr('r', size / 2 - 1);\n };\n\n/**\n * https://developer.mozilla.org/en-US/docs/Web/SVG/Element/marker\n * https://www.dashingd3js.com/svg-paths-and-d3js\n * http://bl.ocks.org/dustinlarimer/5888271\n */\nexport const createMarkers =\n ({ arrowSize = 12 }: MarkerOptions = {}): D3Callable =>\n (group) => {\n return group\n .selectAll('marker')\n .data([\n {\n id: 'marker-arrow-start',\n generator: createArrow(arrowSize, -0.5, true),\n className: 'dx-arrow',\n },\n {\n id: 'marker-arrow-end',\n generator: createArrow(arrowSize, 0.5, false),\n className: 'dx-arrow',\n },\n {\n id: 'marker-dot',\n generator: createDot(6),\n className: 'dx-dot',\n },\n ])\n .join('marker')\n .attr('id', (d) => d.id)\n .attr('markerUnits', 'strokeWidth')\n .attr('class', (d) => d.className)\n .each((d, i, nodes) => {\n select(nodes[i]).call(d.generator);\n });\n };\n", "//\n// Copyright 2021 DXOS.org\n//\n\nimport { drag, pointer, select } from 'd3';\n\nimport { type SVGContext } from '../../hooks';\nimport { type Point } from '../../util';\nimport { type GraphLayoutNode } from '../types';\n\nimport { type GraphProjector } from './graph-projector';\n\nenum Mode {\n MOVE = 0,\n LINK = 1,\n}\n\nexport interface DragOptions<N> {\n dragMod?: string;\n linkMod?: string;\n freezeMod?: string;\n onDrag?: (source?: GraphLayoutNode<N>, target?: GraphLayoutNode<N>, point?: Point) => void;\n onDrop?: (source: GraphLayoutNode<N>, target?: GraphLayoutNode<N>) => void;\n}\n\nconst defaultDragOptions: DragOptions<any> = {\n linkMod: 'metaKey',\n freezeMod: 'shiftKey',\n};\n\n/**\n * Create drag handler.\n */\nexport const createGraphDrag = <NodeData>(\n context: SVGContext,\n projector: GraphProjector<NodeData>,\n options: DragOptions<NodeData> = defaultDragOptions,\n) => {\n let mode: Mode;\n let source: GraphLayoutNode<NodeData>;\n let target: GraphLayoutNode<NodeData> | undefined;\n let offset: Point | undefined;\n let moved = false;\n\n const keyMod = (event: MouseEvent, key: string): boolean => {\n const modKey = options?.[key] ?? defaultDragOptions[key];\n return modKey === undefined || event[modKey];\n };\n\n return drag<SVGElement, GraphLayoutNode<NodeData>>()\n .filter((event: MouseEvent) => !event.ctrlKey)\n .on('start', function (event, d) {\n source = d;\n offset = pointer(event, this.parentElement);\n\n if (options?.onDrop && keyMod(event.sourceEvent, 'linkMod')) {\n mode = Mode.LINK;\n } else if (keyMod(event.sourceEvent, 'dragMod')) {\n mode = Mode.MOVE;\n }\n })\n .on('drag', function (event, d) {\n const parent = this.closest('g.node');\n select(parent).classed('dragging', true).raise();\n\n // Calculate position.\n const [dx, dy] = pointer(event, this.parentElement);\n const x = d.x + dx - offset[0];\n const y = d.y + dy - offset[1];\n const point: Point = [x, y];\n\n switch (mode) {\n case Mode.MOVE: {\n select(context.svg).attr('cursor', 'grabbing');\n\n // Freeze node while dragging.\n event.subject.x = event.subject.fx = point[0];\n event.subject.y = event.subject.fy = point[1];\n projector.refresh(true);\n moved = true;\n break;\n }\n\n case Mode.LINK: {\n // Get drop target.\n if (options?.onDrag) {\n target = projector.findNode(event.x, event.y, 16);\n if (source === target) {\n select(context.svg).attr('cursor', undefined);\n options?.onDrag?.();\n } else {\n select(context.svg).attr('cursor', target ? 'alias' : 'cell');\n options?.onDrag?.(source, target, point);\n }\n }\n }\n }\n })\n .on('end', function (event) {\n select(context.svg).attr('cursor', undefined);\n select(this.parentElement).classed('dragging', false);\n switch (mode) {\n case Mode.LINK: {\n options?.onDrop?.(source, target);\n break;\n }\n }\n\n // Freeze node.\n if (!keyMod(event.sourceEvent, 'freezeMod')) {\n event.subject.fx = null;\n event.subject.fy = null;\n }\n\n mode = undefined;\n source = undefined;\n target = undefined;\n offset = undefined;\n\n if (moved) {\n projector.refresh(false);\n moved = false;\n }\n });\n};\n", "//\n// Copyright 2021 DXOS.org\n//\n\n//\n// Data\n// Generic graph data type.\n//\n\nimport { type Graph } from '@dxos/graph';\nimport { invariant } from '@dxos/invariant';\n\nimport { type Point } from '../util';\n\nexport type IdAccessor<N = any> = (node: N) => string;\n\nexport const defaultIdAccessor: IdAccessor = (node: any) => {\n invariant(node.id);\n return node.id;\n};\n\nexport const emptyGraph: Graph = {\n nodes: [],\n edges: [],\n};\n\n//\n// Layout\n// Graph layout used by graph renderers.\n//\n\nexport type GraphGuide = {\n id: string;\n type: string;\n cx: number;\n cy: number;\n r: number;\n classes?: {\n circle?: string;\n };\n};\n\nexport type GraphLayoutNode<NodeData = any> = {\n id: string;\n type?: string;\n order?: number;\n data?: NodeData;\n x?: number;\n y?: number;\n r?: number;\n classes?: {\n circle?: string;\n text?: string;\n };\n children?: number;\n initialized?: boolean;\n last?: Point;\n};\n\nexport type GraphLayoutEdge<NodeData = any, EdgeData = any> = {\n id: string;\n type?: string;\n order?: number;\n source: GraphLayoutNode<NodeData>;\n target: GraphLayoutNode<NodeData>;\n data?: EdgeData;\n linkForce?: boolean;\n classes?: {\n path?: string;\n };\n};\n\nexport type GraphLayout<NodeData = any, EdgeData = any> = {\n id?: string;\n guides?: GraphGuide[];\n graph: {\n nodes: GraphLayoutNode<NodeData>[];\n edges: GraphLayoutEdge<NodeData, EdgeData>[];\n };\n};\n", "//\n// Copyright 2021 DXOS.org\n//\n\nimport { type SVGContext } from '../../hooks';\nimport { EventEmitter } from '../../util';\nimport { type IdAccessor, defaultIdAccessor } from '../types';\n\nexport type ProjectorOptions = {\n idAccessor?: IdAccessor;\n};\n\n/**\n * Generates a layout to be rendered.\n */\nexport abstract class Projector<NodeData, Layout, Options extends ProjectorOptions> {\n public readonly updated = new EventEmitter<{ layout: Layout }>();\n\n private readonly _options: Options;\n\n constructor(\n private readonly _context: SVGContext,\n options?: Partial<Options>,\n ) {\n this._options = Object.assign(\n {\n idAccessor: defaultIdAccessor,\n },\n options,\n ) as Options;\n }\n\n abstract get layout(): Layout;\n\n get context(): SVGContext {\n return this._context;\n }\n\n get options(): Options {\n return this._options;\n }\n\n refresh(dragging = false) {\n this.onRefresh(dragging);\n }\n\n updateData(data?: NodeData) {\n this.onUpdate(data);\n }\n\n emitUpdate() {\n this.updated.emit({ layout: this.layout });\n }\n\n async clear() {\n await this.onClear();\n }\n\n async start() {\n await this.onStart();\n }\n\n async stop() {\n await this.onStop();\n }\n\n protected onRefresh(dragging = false): void {}\n protected onUpdate(data?: NodeData): void {}\n protected async onClear(): Promise<void> {}\n protected async onStart(): Promise<void> {}\n protected async onStop(): Promise<void> {}\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Graph, type SelectionModel } from '@dxos/graph';\n\nimport { type SVGContext } from '../../hooks';\nimport { type GraphLayout, type GraphLayoutNode, emptyGraph } from '../types';\n\nimport { Projector, type ProjectorOptions } from './projector';\n\nexport type GraphProjectorOptions = ProjectorOptions & {};\n\n/**\n * Base class for graph projectors.\n */\nexport abstract class GraphProjector<NodeData = any, Options extends GraphProjectorOptions = any> extends Projector<\n Graph,\n GraphLayout<NodeData>,\n Options\n> {\n private readonly _layout: GraphLayout<NodeData>;\n\n // TODO(burdon): Change to object props.\n constructor(\n context: SVGContext,\n options?: Options,\n private readonly _selection?: SelectionModel,\n layout?: GraphLayout<NodeData>,\n ) {\n super(context, options);\n this._layout = {\n id: (Math.random() * 10).toString().slice(8),\n graph: {\n nodes: [...(layout?.graph.nodes ?? [])],\n edges: [...(layout?.graph.edges ?? [])],\n },\n };\n }\n\n get layout() {\n return this._layout;\n }\n\n get selection() {\n return this._selection;\n }\n\n numChildren(node: GraphLayoutNode) {\n return this._layout.graph.edges.filter((edge) => edge.source.id === this.options.idAccessor(node)).length;\n }\n\n reset() {\n this._layout.graph.nodes = [];\n this._layout.graph.edges = [];\n this.emitUpdate();\n }\n\n /**\n * Merge external data with internal representation (e.g., so force properties like position are preserved).\n * @param data\n */\n protected mergeData(data: Graph = emptyGraph) {\n // Merge nodes.\n const nodes: GraphLayoutNode[] = data.nodes.map((node) => {\n let current: GraphLayoutNode = this._layout.graph.nodes.find((n) => n.id === this.options.idAccessor(node));\n if (!current) {\n current = {\n id: this.options.idAccessor(node),\n };\n }\n\n current.data = node;\n return current;\n });\n\n // Replace edges.\n const edges = data.edges\n .map((edge) => ({\n id: edge.id,\n source: nodes.find((n) => n.id === edge.source),\n target: nodes.find((n) => n.id === edge.target),\n data: edge.data,\n }))\n .filter((edge) => edge.source && edge.target);\n\n Object.assign(this._layout, {\n graph: {\n nodes,\n edges,\n },\n });\n }\n\n override async onClear() {\n this.reset();\n }\n\n abstract findNode(x: number, y: number, radius: number): GraphLayoutNode<NodeData> | undefined;\n}\n", "//\n// Copyright 2021 DXOS.org\n//\n\nimport {\n type Force,\n forceCenter,\n forceCollide,\n forceLink,\n forceManyBody,\n forceRadial,\n forceSimulation,\n forceX,\n forceY,\n} from 'd3';\n\nimport { type Graph } from '@dxos/graph';\nimport { log } from '@dxos/log';\n\nimport { type GraphLayoutEdge, type GraphLayoutNode } from '../types';\n\nimport { forcePoint } from './graph-forces';\nimport { GraphProjector, type GraphProjectorOptions } from './graph-projector';\n\n/**\n * Return value or invoke function.\n * @param valueOrFunction\n * @param invoker\n * @param defaultValue\n */\nconst getValue = <T>(\n valueOrFunction: T | ((...args: any[]) => T) | undefined,\n invoker: (fn: (...args: any[]) => T) => T,\n defaultValue: T,\n) => {\n return (\n (typeof valueOrFunction === 'function' ? invoker(valueOrFunction as (...args: any[]) => T) : valueOrFunction) ??\n defaultValue\n );\n};\n\n/**\n * Returns the config object or an empty object if the property is set to true (or defaults to true).\n * Otherwise returns undefined.\n * @param options\n * @param cb\n * @param defaultValue\n */\nconst maybeForce = <Config>(\n options: Config | boolean,\n cb: (config: Config) => Force<any, any>,\n defaultValue = undefined,\n) => {\n const value = typeof options === 'boolean' ? (options ? {} : undefined) : (options ?? defaultValue);\n if (value) {\n return cb(value);\n }\n};\n\n//\n// Forces\n// TODO(burdon): Provide utils for function properties (e.g., count edges).\n//\n\n/**\n * https://github.com/d3/d3-force#forceLink\n */\nexport type ForceLinkOptions = {\n // Default: edge => 1 / Math.min(2, count(edge.source), count(edge.target))\n strength?: number | ((edge: GraphLayoutEdge<any>) => number);\n distance?: number;\n iterations?: number;\n};\n\n/**\n * https://github.com/d3/d3-force#forceManyBody\n */\nexport type ForceManyBodyOptions = {\n strength?: number | ((node: GraphLayoutNode<any>) => number);\n distanceMax?: number;\n};\n\n/**\n * https://github.com/d3/d3-force#centering\n */\nexport type ForceCenterOptions = {\n x?: number;\n y?: number;\n strength?: number;\n};\n\n/**\n * https://github.com/d3/d3-force#forceCollide\n */\nexport type ForceCollideOptions = {\n radius?: number;\n strength?: number;\n};\n\n/**\n * https://github.com/d3/d3-force#forceRadial\n */\nexport type ForceRadialOptions = {\n delay?: number;\n x?: number;\n y?: number;\n radius?: number;\n strength?: number;\n};\n\n/**\n * https://github.com/d3/d3-force#positioning\n */\nexport type ForcePositioningOptions = {\n x?: number;\n y?: number;\n strength?: number;\n};\n\n/**\n * All force options.\n * NOTE: A value of `true` enables the force with the default option.\n */\n// TODO(burdon): Options for alpha, etc.\n// TODO(burdon): Change to map of forces by type (i.e., support multiple forces of the same type).\nexport type ForceOptions = {\n link?: boolean | ForceLinkOptions;\n manyBody?: boolean | ForceManyBodyOptions;\n center?: boolean | ForceCenterOptions;\n collide?: boolean | ForceCollideOptions;\n radial?: boolean | ForceRadialOptions;\n point?: boolean | ForcePositioningOptions;\n x?: boolean | ForcePositioningOptions;\n y?: boolean | ForcePositioningOptions;\n};\n\nexport const defaultForceOptions: ForceOptions = {\n link: true,\n manyBody: true,\n // center: true,\n point: true,\n};\n\nexport type GraphForceProjectorOptions = GraphProjectorOptions & {\n guides?: boolean;\n forces?: ForceOptions;\n radius?: number;\n attributes?: {\n radius?: number | ((node: GraphLayoutNode<any>, children: number) => number);\n linkForce?: boolean | ((edge: GraphLayoutEdge<any>) => boolean);\n };\n};\n\n/**\n * D3 force directed graph layout using d3 simulation..\n */\nexport class GraphForceProjector<NodeData = any> extends GraphProjector<NodeData, GraphForceProjectorOptions> {\n // https://github.com/d3/d3-force\n private _simulation = forceSimulation<GraphLayoutNode, GraphLayoutEdge>();\n\n private _timeout?: NodeJS.Timeout;\n\n get forces() {\n return this.options.forces ?? defaultForceOptions;\n }\n\n get simulation() {\n return this._simulation;\n }\n\n restart() {\n this._simulation.alpha(1).restart();\n }\n\n override findNode(x: number, y: number, radius: number): GraphLayoutNode<NodeData> | undefined {\n return this._simulation.find(x, y, radius);\n }\n\n override async onStart() {\n clearTimeout(this._timeout);\n let propagating = true;\n\n // Delay radial force until other forces have settled.\n const { radial, ...forces } = this.forces;\n const delay = typeof radial === 'object' ? radial.delay : undefined;\n if (delay) {\n propagating = false;\n this.updateForces(forces);\n this._timeout = setTimeout(() => {\n this.updateForces(this.forces);\n this.restart();\n this._timeout = setTimeout(() => {\n propagating = true;\n }, delay);\n }, delay);\n } else {\n this.updateForces(this.forces);\n }\n\n this._simulation\n .on('tick', () => propagating && this.emitUpdate())\n .velocityDecay(0.3)\n .alphaDecay(1 - Math.pow(0.001, 1 / 300))\n .alpha(1)\n .restart();\n }\n\n override async onStop() {\n clearTimeout(this._timeout);\n this._simulation.stop();\n }\n\n override onRefresh(dragging = false) {\n // Disable centering force while dragging.\n if (this.forces.center) {\n if (dragging) {\n this._simulation.force('center', null);\n } else {\n this.updateForces(this.forces);\n }\n }\n\n this.restart();\n }\n\n override onUpdate(graph?: Graph): void {\n log('onUpdate', { graph: { nodes: graph?.nodes.length, edges: graph?.edges.length } });\n this._simulation.stop();\n this.mergeData(graph);\n this.updateLayout();\n this.updateForces(this.forces);\n this.restart();\n }\n\n private updateLayout() {\n // Guides.\n this.layout.guides = this.options.guides\n ? [\n {\n id: 'g-1',\n type: 'circle',\n cx: 0,\n cy: 0,\n r: this.context.scale.model.toValue([10, 1]),\n },\n ]\n : undefined;\n\n // Initialize nodes.\n this.layout.graph.nodes.forEach((node) => {\n if (!node.initialized) {\n // Get starting point from linked element.\n // const edge = this.layout.graph.edges.find((edge) => edge.target.id === this.options.idAccessor(node));\n const a = 2 * Math.PI * Math.random();\n const r = this.options.radius ?? 200;\n\n // Initial positions.\n Object.assign(node, {\n initialized: true,\n\n // TODO(burdon): Only when new nodes added to initial layout.\n // Position around center or parent; must have delta to avoid spike.\n // x: edge?.source?.x ?? Math.cos(a) * r,\n // y: edge?.source?.y ?? Math.sin(a) * r,\n x: Math.cos(a) * r,\n y: Math.sin(a) * r,\n });\n }\n\n // TODO(burdon): Ignored by renderer?\n Object.assign(node, {\n r: getValue<number>(this.options?.attributes?.radius, (fn) => fn(node, this.numChildren(node)), 6),\n });\n });\n\n // Initialize edges.\n this.layout.graph.edges.forEach((edge) => {\n Object.assign(edge, {\n linkForce: getValue<boolean>(this.options.attributes?.linkForce, (fn) => fn(edge), true),\n });\n });\n }\n\n /**\n * Update all forces.\n */\n private updateForces(forces: ForceOptions): void {\n log('updateForces', { forces });\n\n // https://github.com/d3/d3-force#simulation_force\n this._simulation\n\n // Nodes\n // https://github.com/d3/d3-force#simulation_nodes\n .nodes(this.layout.graph.nodes)\n\n // Links.\n // https://github.com/d3/d3-force#forceLink\n .force(\n 'link',\n maybeForce<ForceLinkOptions>(\n forces?.link,\n (config) => {\n const force = forceLink()\n .id((d: GraphLayoutNode) => d.id)\n .links(this.layout.graph.edges.filter((edge) => edge.linkForce));\n if (config.distance != null) {\n force.distance(config.distance);\n }\n if (config.strength != null) {\n force.strength(config.strength);\n }\n if (config.iterations != null) {\n force.iterations(config.iterations);\n }\n return force;\n },\n forces?.link === false ? undefined : {},\n ),\n )\n\n // Repulsion.\n // https://github.com/d3/d3-force#forceManyBody\n .force(\n 'manyBody',\n maybeForce<ForceManyBodyOptions>(\n forces?.manyBody,\n (config) => {\n const force = forceManyBody();\n if (config.distanceMax != null) {\n force.distanceMax(config.distanceMax);\n }\n if (config.strength != null) {\n force.strength(config.strength);\n }\n return force;\n },\n forces?.manyBody === false ? undefined : {},\n ),\n )\n\n // Collision.\n // https://github.com/d3/d3-force#forceCollide\n .force(\n 'collide',\n maybeForce<ForceCollideOptions>(forces?.collide, (config) => {\n const force = forceCollide();\n force.radius(config.radius ?? 8);\n if (config.strength != null) {\n force.strength(config.strength);\n }\n return force;\n }),\n )\n\n // Radial.\n // https://github.com/d3/d3-force#forceRadial\n .force(\n 'radial',\n maybeForce<ForceRadialOptions>(forces?.radial, (config) => {\n const force = forceRadial(config.radius ?? 100, config.x ?? 0, config.y ?? 0);\n if (config.strength != null) {\n force.strength(config.strength);\n }\n return force;\n }),\n )\n\n // Centering.\n // NOTE: This moves all nodes such that the center of mass is at the origin.\n // It is different from the positional force which attracts nodes to a point.\n // https://github.com/d3/d3-force#centering\n .force(\n 'center',\n maybeForce<ForceCenterOptions>(forces?.center, (config) => {\n const force = forceCenter()\n .x(config.x ?? 0)\n .y(config.y ?? 0);\n if (config.strength != null) {\n force.strength(config.strength);\n }\n return force;\n }),\n )\n\n // Positioning.\n // https://github.com/d3/d3-force#forcePoint\n .force(\n 'point',\n maybeForce<ForcePositioningOptions>(forces?.point, ({ x = 0, y = 0, strength }) => {\n return forcePoint({ x, y, strength });\n }),\n )\n .force(\n 'x',\n maybeForce<ForcePositioningOptions>(forces?.x, (config: ForcePositioningOptions) => {\n const force = forceX(config.x ?? 0);\n if (config.strength != null) {\n force.strength(config.strength);\n }\n return force;\n }),\n )\n .force(\n 'y',\n maybeForce<ForcePositioningOptions>(forces?.y, (config: ForcePositioningOptions) => {\n const force = forceY(config.y ?? 0);\n if (config.strength != null) {\n force.strength(config.strength);\n }\n return force;\n }),\n );\n }\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Force, type SimulationLinkDatum, type SimulationNodeDatum, forceX, forceY } from 'd3';\n\nexport type ForcePointOptions = {\n x?: number;\n y?: number;\n strength?: number;\n};\n\nexport const forcePoint = <\n NodeDatum extends SimulationNodeDatum,\n LinkDatum extends SimulationLinkDatum<NodeDatum> | undefined,\n>({\n x,\n y,\n strength = 0.01,\n}: ForcePointOptions): Force<NodeDatum, LinkDatum> => {\n const fx = x != null ? forceX(x).strength(strength) : undefined;\n const fy = y != null ? forceY(y).strength(strength) : undefined;\n\n const force = (alpha: number) => {\n fx?.(alpha);\n fy?.(alpha);\n };\n\n force.initialize = (nodes: any[], random: () => number) => {\n fx?.initialize(nodes, random);\n fy?.initialize(nodes, random);\n };\n\n return force;\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Graph } from '@dxos/graph';\nimport { log } from '@dxos/log';\n\nimport { type GraphLayoutNode } from '../types';\n\nimport { type GraphProjectorOptions } from './graph-projector';\nimport { GraphRadialProjector, layoutRadial, updateNode } from './graph-radial-projector';\n\nexport type GraphHierarchicalProjectorOptions = GraphProjectorOptions & {\n radius?: number;\n margin?: number;\n duration?: number;\n};\n\nexport class GraphHierarchicalProjector<\n NodeData = any,\n Options extends GraphHierarchicalProjectorOptions = any,\n> extends GraphRadialProjector<NodeData, Options> {\n protected override onUpdate(graph?: Graph) {\n log('onUpdate', {\n graph: { nodes: graph?.nodes.length, edges: graph?.edges.length },\n selection: this.selection?.selected.value,\n });\n\n this.mergeData(graph);\n const selected = this.selection?.selected.value?.[0];\n if (selected) {\n const node = this.layout.graph.nodes.find((node) => node.id === selected);\n if (node) {\n this.doHierarchicalLayout(node);\n return;\n }\n }\n\n this.doRadialLayout();\n }\n\n protected doHierarchicalLayout(selected: GraphLayoutNode) {\n if (!this.context.size) {\n return;\n }\n\n const r2 =\n this.options.radius ??\n Math.min(this.context.size.width, this.context.size.height) / 2 - (this.options.margin ?? 80);\n const r1 = r2 / 2;\n\n const children = this.layout.graph.edges\n .filter((edge) => edge.source.id === selected.id)\n .map((edge) => edge.target);\n\n // Root.\n updateNode(selected, [0, 0], 20);\n\n // Inner.\n {\n const radial = layoutRadial(0, 0, r1, children.length);\n children.forEach((node, i) => {\n const [tx, ty] = radial(i);\n updateNode(node, [tx, ty]);\n });\n }\n\n // Outer.\n {\n const radial = layoutRadial(0, 0, r2, this.layout.graph.nodes.length - 1 - children.length);\n this.layout.graph.nodes\n .filter((node) => node.id !== selected.id && !children.includes(node))\n .forEach((node, i) => {\n const [tx, ty] = radial(i);\n updateNode(node, [tx, ty]);\n });\n }\n\n this.animate();\n }\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Timer, easeCubic, timer } from 'd3';\n\nimport { type Graph } from '@dxos/graph';\nimport { log } from '@dxos/log';\n\nimport { type Point } from '../../util';\nimport { type GraphLayoutNode } from '../types';\n\nimport { GraphProjector, type GraphProjectorOptions } from './graph-projector';\n\nexport type GraphRadialProjectorOptions = GraphProjectorOptions & {\n radius?: number;\n margin?: number;\n duration?: number;\n};\n\nexport class GraphRadialProjector<\n NodeData = any,\n Options extends GraphRadialProjectorOptions = any,\n> extends GraphProjector<NodeData, Options> {\n private _timer?: Timer;\n\n override findNode(x: number, y: number, radius: number): GraphLayoutNode<NodeData> | undefined {\n return undefined;\n }\n\n protected override onUpdate(graph?: Graph) {\n log('onUpdate', { graph: { nodes: graph?.nodes.length, edges: graph?.edges.length } });\n this.mergeData(graph);\n this.doRadialLayout();\n }\n\n protected animate() {\n const start = Date.now();\n if (this.options.duration) {\n this._timer = timer(() => {\n const t = Math.min(1, (Date.now() - start) / this.options.duration);\n const d = easeCubic(t);\n\n this.layout.graph.nodes.forEach((node: any) => {\n node.x = node.sx + (node.tx - node.sx) * d;\n node.y = node.sy + (node.ty - node.sy) * d;\n node.r = node.sr + (node.tr - node.sr) * d;\n });\n\n this.emitUpdate();\n if (t >= 1) {\n this._timer.stop();\n this._timer = undefined;\n }\n });\n } else {\n this.emitUpdate();\n }\n }\n\n protected override async onStop() {\n this._timer?.stop();\n this._timer = undefined;\n }\n\n protected doRadialLayout() {\n if (!this.context.size) {\n return;\n }\n\n const radial = layoutRadial(\n 0,\n 0,\n this.options.radius ??\n Math.min(this.context.size.width, this.context.size.height) / 2 - (this.options.margin ?? 80),\n this.layout.graph.nodes.length,\n );\n\n this.layout.graph.nodes.forEach((node, i) => {\n const [tx, ty] = radial(i);\n updateNode(node, [tx, ty]);\n });\n\n this.animate();\n }\n}\n\n/**\n * Update node target.\n */\nexport const updateNode = (node: GraphLayoutNode, [tx, ty]: Point, tr = 8) => {\n const sx = node.x ?? tx;\n const sy = node.y ?? ty;\n const sr = node.r ?? tr;\n Object.assign(node, {\n initialized: true,\n // Start.\n sx,\n sy,\n sr,\n // Target.\n tx,\n ty,\n tr,\n // Current.\n x: sx,\n y: sy,\n r: sr,\n });\n};\n\n/**\n * Radial position generator.\n */\nexport const layoutRadial = (x: number, y: number, r: number, n: number, start = -Math.PI / 2) => {\n const da = (2 * Math.PI) / n;\n return (i: number): Point => {\n const a = start + i * da;\n return [x + Math.cos(a) * r, y + Math.sin(a) * r];\n };\n};\n\n/**\n * Horizontal position generator.\n */\nexport const layoutHorizontal = (x: number, y: number, w: number, n: number) => {\n const dx = n > 1 ? w / (n - 1) : 0;\n const sx = x - ((n - 1) * dx) / 2;\n return (i: number): Point => {\n return [sx + i * dx, y];\n };\n};\n\n/**\n * Vertical position generator.\n */\nexport const layoutVertical = (x: number, y: number, h: number, n: number) => {\n const dy = n > 1 ? h / (n - 1) : 0;\n const sy = y - ((n - 1) * dy) / 2;\n return (i: number): Point => {\n return [x, sy + i * dy];\n };\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Graph } from '@dxos/graph';\nimport { log } from '@dxos/log';\n\nimport { type GraphLayoutNode } from '../types';\n\nimport { type GraphProjectorOptions } from './graph-projector';\nimport { GraphRadialProjector, layoutHorizontal, layoutRadial, updateNode } from './graph-radial-projector';\n\nexport type GraphRelationalProjectorOptions = GraphProjectorOptions & {\n radius?: number;\n margin?: number;\n duration?: number;\n};\n\nexport class GraphRelationalProjector<\n NodeData = any,\n Options extends GraphRelationalProjectorOptions = any,\n> extends GraphRadialProjector<NodeData, Options> {\n protected override onUpdate(graph?: Graph) {\n log('onUpdate', {\n graph: { nodes: graph?.nodes.length, edges: graph?.edges.length },\n selection: this.selection?.selected.value,\n });\n\n this.mergeData(graph);\n const selected = this.selection?.selected.value?.[0];\n if (selected) {\n const node = this.layout.graph.nodes.find((node) => node.id === selected);\n if (node) {\n this.doRelationalLayout(node);\n return;\n }\n }\n\n this.doRadialLayout();\n }\n\n protected doRelationalLayout(selected: GraphLayoutNode) {\n if (!this.context.size) {\n return;\n }\n\n // TODO(burdon): Generate edge types.\n const r2 =\n this.options.radius ??\n Math.min(this.context.size.width, this.context.size.height) / 2 - (this.options.margin ?? 80);\n const r1 = r2 * 0.5;\n\n this.layout.graph.nodes.forEach((node) => (node.type = undefined));\n this.layout.graph.edges.forEach((edge) => {\n edge.order = 0;\n edge.type = undefined;\n });\n\n const children = this.layout.graph.edges\n .filter((edge) => edge.source.id === selected.id)\n .map((edge) => {\n edge.order = 1;\n edge.type = '1';\n edge.target.type = '1';\n return edge.target;\n });\n\n const parents = this.layout.graph.edges\n .filter((edge) => edge.target.id === selected.id)\n .map((edge) => {\n edge.order = 2;\n edge.type = '2';\n edge.source.type = '2';\n return edge.source;\n });\n\n // Root.\n updateNode(selected, [0, 0], 30);\n\n // Children.\n {\n const vertical = layoutHorizontal(0, r1, r1 * 2, children.length);\n children.forEach((node, i) => {\n const [tx, ty] = vertical(i);\n updateNode(node, [tx, ty], 20);\n });\n }\n\n // Parents.\n {\n const vertical = layoutHorizontal(0, -r1, r1, parents.length);\n parents.forEach((node, i) => {\n const [tx, ty] = vertical(i);\n updateNode(node, [tx, ty], 20);\n });\n }\n\n // Outer.\n {\n const radial = layoutRadial(0, 0, r2, this.layout.graph.nodes.length - 1 - children.length - parents.length);\n this.layout.graph.nodes\n .filter((node) => node.id !== selected.id && !children.includes(node) && !parents.includes(node))\n .forEach((node, i) => {\n const [tx, ty] = radial(i);\n updateNode(node, [tx, ty]);\n });\n }\n\n this.animate();\n }\n}\n", "//\n// Copyright 2021 DXOS.org\n//\n\nimport { easeCubicOut, line, polygonHull, select } from 'd3';\nimport * as Clipper from 'js-clipper';\n\nimport { log } from '@dxos/log';\n\nimport { type D3Callable, type D3Selection, type Point, getCircumferencePoints } from '../../util';\nimport { type GraphLayout, type GraphLayoutEdge, type GraphLayoutNode } from '../types';\n\nimport { createBullets } from './bullets';\nimport { Renderer, type RendererOptions } from './renderer';\n\nconst createLine = line<Point>();\n\nexport type LabelOptions<NodeData = any> = {\n text: (node: GraphLayoutNode<NodeData>, highlight?: boolean) => string | undefined;\n};\n\nexport type AttributesOptions<NodeData = any, EdgeData = any> = {\n node?: (node: GraphLayoutNode<NodeData>) => {\n classes?: Record<string, boolean>;\n data?: Record<string, string | undefined>;\n };\n\n edge?: (edge: GraphLayoutEdge<NodeData, EdgeData>) => {\n classes?: Record<string, boolean>;\n data?: Record<string, string | undefined>;\n };\n};\n\nexport type GraphRendererOptions<NodeData = any, EdgeData = any> = RendererOptions<{\n drag?: D3Callable;\n arrows?: {\n start?: boolean; // TODO(burdon): Replace with marker id.\n end?: boolean;\n };\n highlight?: boolean;\n labels?: LabelOptions<NodeData>;\n subgraphs?: boolean;\n attributes?: AttributesOptions<NodeData>;\n transition?: () => any;\n onNodeClick?: (node: GraphLayoutNode<NodeData>, event: MouseEvent) => void;\n onNodePointerEnter?: (node: GraphLayoutNode<NodeData>, event: MouseEvent) => void;\n onLinkClick?: (link: GraphLayoutEdge<NodeData, EdgeData>, event: MouseEvent) => void;\n}>;\n\n// TODO(burdon): Perf\n// - Leaking JS event listeners.\n// - Don't update unless data changes.\n// - Cache subgraph components in layout.\n\n/**\n * Renders the Graph layout.\n */\nexport class GraphRenderer<NodeData = any, EdgeData = any> extends Renderer<\n GraphLayout<NodeData, EdgeData>,\n GraphRendererOptions<NodeData, EdgeData>\n> {\n override render(layout: GraphLayout<NodeData, EdgeData>) {\n log('render', layout);\n\n const root = select(this.root);\n\n //\n // Guides\n //\n\n if (layout.guides) {\n root\n .selectAll('g.dx-guides')\n .data([{ id: 'guides' }])\n .join('g')\n .classed('dx-guides', true)\n .selectAll<SVGCircleElement, { cx: number; cy: number; r: number }>('circle')\n .data(layout.guides ?? [])\n .join(\n (enter) => enter.append('circle').attr('r', 0),\n (update) => update,\n (exit) => exit.transition().duration(500).attr('r', 0).remove(),\n )\n .attr('cx', (d) => d.cx)\n .attr('cy', (d) => d.cy)\n .attr('r', (d) => d.r);\n }\n\n //\n // Subgraphs (aka components)\n //\n\n const scale = 100;\n const offsetDistance = 24 * scale;\n\n if (this._options.subgraphs) {\n // TODO(burdon): Cache components in layout.\n // TODO(burdon): Separate force system for each subgraph.\n const components = this._options.subgraphs\n ? findConnectedComponents({\n nodes: layout.graph?.nodes ?? [],\n edges: (layout.graph?.edges ?? []).map(({ source, target }) => ({ source: source.id, target: target.id })),\n })\n .filter((component) => component.length > 2)\n .map((component, i) => ({ id: `subgraph-${i}`, component }))\n : [];\n\n root\n .selectAll('g.dx-subgraphs')\n .data([{ id: 'subgraphs' }])\n .join('g')\n .classed('dx-subgraphs', true)\n .selectAll<SVGPathElement, { id: string }>('path')\n .data(components)\n .join(\n (enter) => enter.append('path').classed('dx-subgraph', true),\n (update) => {\n return update.attr('d', ({ component }) => {\n const points: Point[] =\n layout.graph?.nodes.filter((node) => component.includes(node.id)).map((node) => [node.x, node.y]) ?? [];\n\n // https://d3js.org/d3-polygon\n const hullPoints = polygonHull(points);\n\n // https://www.npmjs.com/package/js-clipper\n const co = new Clipper.ClipperOffset();\n const solution = [];\n const clipperPath = hullPoints.map(([x, y]) => ({ X: x * scale, Y: y * scale }));\n co.AddPath(clipperPath, Clipper.JoinType.jtRound, Clipper.EndType.etClosedPolygon);\n co.Execute(solution, offsetDistance);\n if (solution.length > 0) {\n const offset = solution[0].map(({ X, Y }) => [X / scale, Y / scale]);\n return createLine([...offset, offset[0]]);\n }\n });\n },\n );\n }\n\n //\n // Edges and nodes\n // TODO(burdon): Only call join when data changes (otherwise exit transitions are called multiple times).\n //\n\n const edgeGroup = root\n .selectAll('g.dx-edges')\n .data([{ id: 'edges' }], (d: any) => d.id)\n .join('g')\n .classed('dx-edges', true);\n\n const nodeGroup = root\n .selectAll('g.dx-nodes')\n .data([{ id: 'nodes' }], (d: any) => d.id)\n .join('g')\n .classed('dx-nodes', true);\n\n //\n // Nodes\n //\n\n nodeGroup\n .selectAll<SVGCircleElement, GraphLayoutNode<NodeData>>('g.dx-node')\n .data(layout.graph?.nodes ?? [], (d) => d.id)\n .join(\n (enter) =>\n enter\n .append('g')\n .attr('data-id', (d) => d.id)\n .attr('opacity', 1)\n .classed('dx-node', true)\n .call(createNode, this.options),\n (update) => update.call(updateNode, this.options),\n (exit) => {\n // Fade out.\n return exit\n .transition()\n .ease(easeCubicOut)\n .duration(300)\n .attr('opacity', 0)\n .on('end', function (d) {\n select(this).remove();\n });\n },\n )\n .sort((a, b) => (a.order ?? 0) - (b.order ?? 0));\n\n //\n // Edges\n //\n\n edgeGroup\n .selectAll<SVGPathElement, GraphLayoutEdge<NodeData, EdgeData>>('g.dx-edge')\n .data(layout.graph?.edges ?? [], (d) => d.id)\n .join(\n (enter) =>\n enter\n .append('g')\n .attr('data-id', (d) => d.id)\n .classed('dx-edge', true)\n .call(createEdge, this.options),\n (update) => update.call(updateEdge, this.options, nodeGroup).each((d) => {}),\n (exit) => exit.remove(),\n )\n .sort((a, b) => (a.order ?? 0) - (b.order ?? 0));\n }\n\n /**\n * Trigger path bullets.\n * @param node\n */\n fireBullet(node: GraphLayoutNode<NodeData>) {\n select(this.root).selectAll('g.dx-edges').selectAll('path').call(createBullets(this.root, node.id));\n }\n}\n\n/**\n * Create node elements.\n * @param group\n * @param options\n */\nconst createNode: D3Callable = <Data>(group: D3Selection, options: GraphRendererOptions<Data>) => {\n // Circle.\n const circle = group.append('circle');\n\n // Drag.\n // TODO(burdon): Update when layout changes.\n if (options.drag) {\n circle.call(options.drag);\n }\n\n // Click.\n if (options.onNodeClick) {\n group.on('click', (event: MouseEvent) => {\n const node = select<SVGElement, GraphLayoutNode<Data>>(event.target as SVGGElement).datum();\n options.onNodeClick(node, event);\n });\n }\n\n // Label.\n if (options.labels && !options.onNodePointerEnter) {\n const g = group.append('g').classed('dx-label', true);\n g.append('line');\n g.append('rect');\n g.append('text').style('dominant-baseline', 'middle');\n }\n\n // Hover.\n if (options.onNodePointerEnter) {\n circle.on('pointerenter', function (event: PointerEvent) {\n const node = select<any, GraphLayoutNode<Data>>(this.parentElement).datum();\n options.onNodePointerEnter(node, event);\n });\n\n group.attr('data-hover', 'handled'); // TODO(burdon): ???\n } else if (options.highlight !== false) {\n circle.on('pointerenter', function () {\n select(this.closest('g.dx-node')).raise();\n if (options.labels) {\n select(this.parentElement).classed('dx-active', true).classed('dx-highlight', true);\n }\n });\n\n group.on('pointerleave', function () {\n if (options.labels) {\n select(this).classed('dx-active', false);\n setTimeout(() => {\n if (!select(this).classed('dx-active')) {\n select(this).classed('dx-highlight', false);\n }\n }, 300);\n }\n });\n }\n};\n\n/**\n * Update node elements.\n * @param group\n * @param options\n */\nconst updateNode: D3Callable = <NodeData = any, EdgeData = any>(\n group: D3Selection,\n options: GraphRendererOptions<NodeData, EdgeData>,\n) => {\n group.attr('transform', (d) => {\n return d.x != null && d.y != null ? `translate(${d.x},${d.y})` : undefined;\n });\n\n // Custom attributes.\n if (options.attributes?.node) {\n try {\n group.each((d, i, nodes) => {\n const node = select(nodes[i]);\n const { classes, data } = options.attributes?.node?.(d) ?? {};\n if (classes) {\n applyClasses(node, classes);\n }\n if (data) {\n Object.entries(data).forEach(([key, value]) => {\n node.attr(`data-${key}`, value);\n });\n }\n });\n } catch (error: any) {\n log.error('updateNode', { error: error?.message });\n }\n }\n\n // Optional transition.\n const groupOrTransition: D3Selection = options.transition\n ? (group.transition(options.transition()) as unknown as D3Selection)\n : group;\n\n // Update circles.\n groupOrTransition.select<SVGCircleElement>('circle').attr('r', (d) => d.r ?? 16);\n\n // Update labels.\n if (options.labels) {\n const bx = 1;\n const px = 4;\n const py = 2;\n const offset = 16;\n const dx = (d: any, offset = 0) => (offset + (d.r ?? 0)) * (d.x > 0 ? 1 : -1);\n\n groupOrTransition\n .select<SVGTextElement>('text')\n .text((d) => options.labels.text(d))\n .style('text-anchor', (d) => (d.x > 0 ? 'start' : 'end'))\n .attr('dx', (d) => dx(d, offset))\n .attr('dy', 1)\n .text((d) => options.labels.text(d))\n .each(function (d) {\n // Cache bounding box.\n let bbox = d.bbox;\n if (!bbox) {\n bbox = this.getBBox();\n d.bbox = bbox;\n }\n\n const width = bbox.width + (bx + px) * 2;\n const height = bbox.height + py * 2;\n\n select(this.parentElement)\n .select('rect')\n .attr('x', dx(d, offset - (bx + px)) + (d.x > 0 ? 0 : -1) * width)\n .attr('y', -height / 2)\n .attr('width', width)\n .attr('height', height)\n .attr('rx', 4);\n\n select(this.parentElement)\n .select('line')\n .attr('x1', dx(d, 1))\n .attr('y1', 0)\n .attr('x2', dx(d, offset - (bx + px)))\n .attr('y2', 0);\n });\n }\n};\n\n/**\n * Create edge elements.\n * @param group\n * @param options\n * @param nodes\n */\nconst createEdge: D3Callable = <NodeData = any, EdgeData = any>(\n group: D3Selection,\n options: GraphRendererOptions<NodeData, EdgeData>,\n) => {\n if (options.onLinkClick) {\n // Shadow path with wide stroke for click handler.\n group\n .append('path')\n .classed('dx-click', true)\n .on('click', (event: MouseEvent) => {\n const edge = select<SVGLineElement, GraphLayoutEdge<NodeData, EdgeData>>(\n event.target as SVGLineElement,\n ).datum();\n options.onLinkClick(edge, event);\n });\n }\n\n group\n .append('path')\n .attr('pointer-events', 'none')\n .attr('marker-start', () => (options.arrows?.start ? 'url(#marker-arrow-start)' : undefined))\n .attr('marker-end', () => (options.arrows?.end ? 'url(#marker-arrow-end)' : undefined));\n};\n\n/**\n * Update edge elements.\n * @param group\n * @param options\n */\nconst updateEdge: D3Callable = <NodeData = any, EdgeData = any>(\n group: D3Selection,\n options: GraphRendererOptions<NodeData, EdgeData>,\n nodeGroup: D3Selection,\n) => {\n // Custom attributes.\n try {\n group.each((d, i, edges) => {\n const edge = select(edges[i]);\n edge.classed('dx-dashed', d.linkForce === false);\n const { classes, data } = options.attributes?.edge?.(d) ?? {};\n if (classes) {\n applyClasses(edge, classes);\n }\n if (data) {\n Object.entries(data).forEach(([key, value]) => {\n edge.attr(`data-${key}`, value);\n });\n }\n });\n } catch (error: any) {\n log.error('updateEdge', { error: error?.message });\n }\n\n // Optional transition.\n const groupOrTransition: D3Selection = options.transition\n ? (group.transition(options.transition()) as unknown as D3Selection)\n : group;\n\n groupOrTransition.selectAll<SVGPathElement, GraphLayoutEdge<NodeData, EdgeData>>('path').attr('d', function () {\n // NOTE: `d` is stale after layout is switched so get the datum from the parent element.\n const { source, target } = select(this.parentElement).datum() as GraphLayoutEdge<NodeData, EdgeData>;\n if (!source.initialized || !target.initialized) {\n return;\n }\n\n return createLine(getCircumferencePoints([source.x, source.y], [target.x, target.y], source.r, target.r));\n });\n};\n\n// TODO(burdon): Factor out.\n\nconst applyClasses = (el: D3Selection, classes: Record<string, boolean>) => {\n for (const [className, value] of Object.entries(classes)) {\n el.classed(className, value);\n }\n};\n\n/**\n * Find connected components (subgraphs) in a graph.\n */\nconst findConnectedComponents = (graph: {\n nodes: { id: string }[];\n edges: { source: string; target: string }[];\n}): string[][] => {\n const adj: Record<string, string[]> = {};\n for (const node of graph.nodes) {\n adj[node.id] = [];\n }\n\n for (const { source, target } of graph.edges) {\n adj[source].push(target);\n adj[target].push(source);\n }\n\n const visited = new Set<string>();\n const components: string[][] = [];\n for (const node of graph.nodes) {\n if (visited.has(node.id)) {\n continue;\n }\n\n const stack = [node.id];\n const componentIds: string[] = [];\n\n while (stack.length) {\n const current = stack.pop()!;\n if (visited.has(current)) {\n continue;\n }\n visited.add(current);\n componentIds.push(current);\n stack.push(...adj[current]);\n }\n\n components.push(componentIds);\n }\n\n return components;\n};\n", "//\n// Copyright 2019 DXOS.org\n//\n\nimport { easeLinear, interpolate, select } from 'd3';\n\nimport { type D3Callable, type D3Selection } from '../../util';\n\nexport type BulletOptions = {\n max?: number;\n radius?: number;\n delay?: number;\n minDuration?: number;\n maxDuration?: number;\n};\n\n/**\n * Generate animated bullets that follow selected paths.\n * @param group\n * @param nodeId\n * @param options\n */\nexport const createBullets = (group: SVGGElement, nodeId: string, options: BulletOptions = {}): D3Callable => {\n return (selection: D3Selection) => {\n const { max = 32, radius = 3, delay = 50, minDuration = 100, maxDuration = 500 } = options;\n\n // Edge selection.\n selection.each(function (d, i, edges) {\n const { source, target } = d;\n\n // Match source node.\n if (source.id === nodeId) {\n const path = select(edges[i]);\n const p = path.node().getPointAtLength(0);\n\n const bullet = select(group)\n .append('circle')\n .attr('class', 'dx-bullet')\n .attr('cx', p.x)\n .attr('cy', p.y)\n .attr('r', radius);\n\n bullet\n // Start animation.\n .transition()\n .delay(delay)\n .duration(minDuration + Math.random() * maxDuration)\n .ease(easeLinear)\n .tween('pathTween', function () {\n const length = path.node().getTotalLength();\n const r = interpolate(0, length);\n\n return (t) => {\n const point = path.node().getPointAtLength(r(t));\n select(this).attr('cx', point.x).attr('cy', point.y);\n };\n })\n\n // End of transition.\n .on('end', function () {\n select(this).remove();\n\n // Propagate with circuit breaker to prevent infinite recursion.\n const num = select(group).selectAll('circle.dx-bullet').size();\n if (num < max) {\n selection.call(createBullets(group, target.id));\n }\n });\n }\n });\n };\n};\n", "//\n// Copyright 2021 DXOS.org\n//\n\nimport { type RefObject } from 'react';\n\nimport { invariant } from '@dxos/invariant';\n\nimport { type SVGContext } from '../../hooks';\nimport { type IdAccessor, defaultIdAccessor } from '../types';\n\nexport type RendererOptions<T = any> = {\n idAccessor: IdAccessor;\n} & T;\n\n/**\n * Base class for renderer that draw layouts.\n */\nexport abstract class Renderer<LAYOUT, OPTIONS extends RendererOptions> {\n protected readonly _options?: OPTIONS;\n\n constructor(\n protected readonly _context: SVGContext,\n protected readonly _root: RefObject<SVGGElement>,\n options?: Partial<OPTIONS>,\n ) {\n this._options = Object.assign(\n {\n idAccessor: defaultIdAccessor,\n },\n options,\n ) as OPTIONS;\n }\n\n get context(): SVGContext {\n return this._context;\n }\n\n get root(): SVGGElement {\n invariant(this._root.current, 'SVG root is not initialized');\n return this._root.current;\n }\n\n get options() {\n return this._options;\n }\n\n abstract render(layout: LAYOUT): void;\n}\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { line } from 'd3';\n\nimport { type D3Callable, type Point } from '../../util';\nimport { getCircumferencePoints } from '../../util';\nimport { type GraphLayoutNode } from '../types';\n\nconst createLine = line();\n\nexport type LinkOptions = {\n source?: GraphLayoutNode<any>;\n target?: GraphLayoutNode<any>;\n point?: Point;\n};\n\n/**\n * Render linker while dragging.\n */\nexport const linkerRenderer: D3Callable = (root, { source, target, point }: LinkOptions = {}) => {\n root\n .selectAll('g.dx-linker')\n .data([{ id: 'linker' }])\n .join('g')\n .attr('class', 'dx-linker')\n .selectAll<SVGPathElement, any>('path')\n .data(source ? [{ id: 'edge' }] : [])\n .join('path')\n .attr('marker-end', () => (target ? 'url(#marker-arrow-end)' : 'url(#marker-dot)'))\n .attr('d', () => {\n return createLine(\n getCircumferencePoints(\n [source.x, source.y],\n target ? [target.x, target.y] : point,\n source.r,\n target ? target.r : 0,\n ),\n );\n });\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { type GeoStream, geoPath, select } from 'd3';\nimport { useEffect } from 'react';\nimport { feature, mesh } from 'topojson-client';\nimport { type GeometryCollection, type GeometryObject, type Objects, type Topology } from 'topojson-specification';\n\nimport { useSvgContext } from '../../hooks';\nimport { type Size } from '../../util';\n\nexport type MeshProps = {\n radius?: number;\n value?: number;\n};\n\n// https://d3og.com/mbostock/5249328\nexport const Mesh = ({ radius = 16, value = 0.5 }: MeshProps) => {\n const { svg, size } = useSvgContext();\n\n useEffect(() => {\n if (size) {\n // TODO(burdon): Resize doesn't trigger.\n const topology = hexTopology(size, radius, value);\n const projection = hexProjection(radius);\n const path = geoPath().projection(projection);\n\n select(svg)\n .append('g')\n .attr('class', 'hexagon')\n .selectAll('path')\n .data(topology.objects.hexagons.geometries)\n .enter()\n .append('path')\n .attr('d', (d) => path(feature(topology, d)))\n .attr('class', (d) => ((d.properties as Custom)?.fill ? 'fill' : null));\n // .on('mousedown', mousedown)\n // .on('mousemove', mousemove)\n // .on('mouseup', mouseup);\n\n select(svg).append('path').datum(mesh(topology, topology.objects.hexagons)).attr('class', 'mesh').attr('d', path);\n\n const redraw = (border: any) => {\n border.attr(\n 'd',\n path(\n mesh(\n topology,\n topology.objects.hexagons,\n (a, b) => (a.properties as Custom).fill !== (b.properties as Custom).fill,\n ),\n ),\n );\n };\n\n select(svg).append('path').attr('class', 'border').call(redraw);\n }\n }, [svg, size, value]);\n\n return null;\n};\n\ntype Custom = { fill: boolean };\n\ninterface HexObjects extends Objects<{ fill: boolean }> {\n hexagons: GeometryCollection<Custom>;\n}\n\nconst hexTopology = ({ width, height }: Size, radius: number, value = 1): Topology<HexObjects> => {\n const dx = radius * 2 * Math.sin(Math.PI / 3);\n const dy = radius * 1.5;\n const m = Math.ceil((height + radius) / dy) + 1;\n const n = Math.ceil(width / dx) + 1;\n const geometries: Array<GeometryObject<{ fill: boolean }>> = [];\n const arcs = [];\n\n for (let j = -1; j <= m; ++j) {\n for (let i = -1; i <= n; ++i) {\n const y = j * 2;\n const x = (i + (j & 1) / 2) * 2;\n arcs.push(\n [\n [x, y - 1],\n [1, 1],\n ],\n [\n [x + 1, y],\n [0, 1],\n ],\n [\n [x + 1, y + 1],\n [-1, 1],\n ],\n );\n }\n }\n\n for (let j = 0, q = 3; j < m; ++j, q += 6) {\n for (let i = 0; i < n; ++i, q += 3) {\n geometries.push({\n type: 'Polygon',\n arcs: [[q, q + 1, q + 2, ~(q + (n + 2 - (j & 1)) * 3), ~(q - 2), ~(q - (n + 2 + (j & 1)) * 3 + 2)]],\n properties: {\n fill: Math.random() > (i / n) * (1 / value),\n },\n });\n }\n }\n\n const hexagons: GeometryCollection<{ fill: boolean }> = { type: 'GeometryCollection', geometries };\n\n return {\n type: 'Topology',\n transform: { translate: [0, 0], scale: [1, 1] },\n objects: { hexagons },\n arcs,\n };\n};\n\nconst hexProjection = (radius: number) => {\n const dx = radius * 2 * Math.sin(Math.PI / 3);\n const dy = radius * 1.5;\n return {\n stream: (stream: GeoStream) => ({\n point: (x: number, y: number) => {\n stream.point((x * dx) / 2, ((y - (2 - (y & 1)) / 3) * dy) / 2);\n },\n lineStart: () => {\n stream.lineStart();\n },\n lineEnd: () => {\n stream.lineEnd();\n },\n polygonStart: () => {\n stream.polygonStart();\n },\n polygonEnd: () => {\n stream.polygonEnd();\n },\n }),\n };\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport React from 'react';\n\nimport { type ThemedClassName } from '@dxos/react-ui';\nimport { mx } from '@dxos/react-ui-theme';\n\nimport { type GridOptions, useGrid } from '../../hooks';\n\nexport type GridProps = ThemedClassName<GridOptions>;\n\n/**\n * SVG grid wrapper.\n */\nexport const Grid = ({ classNames, ...props }: GridProps) => {\n const { ref } = useGrid(props);\n return <g ref={ref} className={mx('dx-grid', classNames)} />;\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { select } from 'd3';\nimport React, { useEffect, useRef } from 'react';\n\nimport { createMarkers } from '../../graph';\n\nexport type MarkersProps = {\n arrowSize?: number;\n className?: string;\n};\n\n/**\n * SVG markers wrapper.\n */\nexport const Markers = ({ arrowSize, className }: MarkersProps) => {\n const ref = useRef(null);\n useEffect(() => {\n select(ref.current).call(createMarkers({ arrowSize }));\n }, [ref]);\n\n return <defs ref={ref} className={className} />;\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { select } from 'd3';\nimport React, { type PropsWithChildren, forwardRef, useEffect, useImperativeHandle, useMemo } from 'react';\nimport { useResizeDetector } from 'react-resize-detector';\n\nimport { type ThemedClassName } from '@dxos/react-ui';\nimport { mx } from '@dxos/react-ui-theme';\n\nimport { SVGContext, type SVGContextOptions, SVGContextProvider } from '../../hooks';\n\nexport type RootProps = ThemedClassName<PropsWithChildren<SVGContextOptions>>;\n\n/**\n * Makes the SVG context available to child nodes.\n * Automatically resizes the SVG element, which expands to fit the container.\n */\nexport const Root = forwardRef<SVGContext, RootProps>(({ classNames, children, ...props }, ref) => {\n const { ref: containerRef, width = 0, height = 0 } = useResizeDetector({ refreshRate: 200 });\n\n const context = useMemo<SVGContext>(() => {\n return new SVGContext(props);\n }, [props.scale, props.centered]);\n\n useImperativeHandle(ref, () => context, [context]);\n\n useEffect(() => {\n if (width && height) {\n context.setSize({ width, height });\n select(context.svg)\n .attr('display', 'block')\n .attr('viewBox', context.viewBox)\n .attr('width', width)\n .attr('height', height);\n }\n }, [context, width, height]);\n\n const ready = width !== 0 && height !== 0;\n\n return (\n <SVGContextProvider value={context}>\n <div ref={containerRef} className={mx('grid grow overflow-hidden', classNames)}>\n <svg\n xmlns='http://www.w3.org/2000/svg'\n ref={context.ref}\n className={mx('transition-opacity opacity-0 duration-1000', ready && 'opacity-100')}\n >\n {ready && children}\n </svg>\n </div>\n </SVGContextProvider>\n );\n});\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport React, { type ReactNode, memo, useMemo } from 'react';\n\nimport { type ZoomExtent, useZoom } from '../../hooks';\n\nexport type ZoomProps = {\n extent?: ZoomExtent;\n className?: string;\n children?: ReactNode;\n};\n\n/**\n * SVG zoomable component wrapper.\n */\nexport const Zoom = memo(({ extent, className, children }: ZoomProps) => {\n const options = useMemo(() => ({ extent }), [JSON.stringify(extent)]); // TODO(burdon): Avoid stringify.\n const zoom = useZoom(options);\n\n return (\n <g ref={zoom.ref as any} className={className}>\n {children}\n </g>\n );\n});\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { type PropsWithChildren } from 'react';\n\nimport { type ThemedClassName } from '@dxos/react-ui';\n\nimport { Graph, type GraphProps as SVGGraphProps } from '../Graph';\nimport { Mesh, type MeshProps as SVGMeshProps } from '../Mesh';\n\nimport { Grid, type GridProps as SVGGridProps } from './Grid';\nimport { Markers, type MarkersProps as SVGMarkersProps } from './Markers';\nimport { Root, type RootProps as SVGRootProps } from './Root';\nimport { type ZoomProps as SVGZoomProps, Zoom } from './Zoom';\n\nexport type SVGProps = PropsWithChildren<ThemedClassName>;\n\nexport const SVG = {\n Root,\n Grid,\n Markers,\n Mesh,\n Zoom,\n Graph,\n};\n\nexport type { SVGRootProps, SVGGridProps, SVGMarkersProps, SVGZoomProps, SVGGraphProps, SVGMeshProps };\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { easeCubicOut, select } from 'd3';\n\nimport { type D3Callable, type D3Selection } from '../util';\n\nconst PROP_PULSAR_ACTIVE = 'dx-pulsar-active';\n\n/**\n * Pulsar effect.\n */\nexport namespace Pulsar {\n export const has = (group: D3Selection<SVGGElement>) => group.select('circle.dx-pulsar').empty();\n\n export const create: D3Callable<SVGGElement> = (group, r: number, options: PulsarOptions = {}) => {\n const pulsar = group\n .append('circle')\n .classed('dx-pulsar', true)\n .classed('stroke-2 stroke-red-500 fill-none', true)\n .property(PROP_PULSAR_ACTIVE, true);\n\n startAnimation(pulsar, r, options);\n };\n\n export const remove: D3Callable<SVGGElement> = (group) => {\n group.select('circle.dx-pulsar').property(PROP_PULSAR_ACTIVE, false);\n };\n\n export type Options = PulsarOptions;\n}\n\ntype PulsarOptions = {\n period?: number;\n duration?: number;\n ratio?: number;\n};\n\nconst startAnimation = (pulsar: D3Selection<SVGCircleElement>, r: number, options: PulsarOptions = {}) => {\n const { period = 1_000, duration = 800, ratio = 3 } = options;\n return pulsar\n .attr('r', r)\n .attr('opacity', 1)\n .transition('pulsar')\n .delay(period - (Date.now() % period))\n .duration(Math.min(duration, period - 20))\n .ease(easeCubicOut)\n .attr('r', r * ratio)\n .attr('opacity', -0.1)\n .on('end', function () {\n if (select(this).property(PROP_PULSAR_ACTIVE)) {\n startAnimation(select(this), r, options);\n } else {\n select(this).remove();\n }\n });\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAIA,SAASA,cAAc;AACvB,OAAOC,SAA6BC,YAAYC,WAAWC,qBAAqBC,SAASC,cAAc;AAEvG,SAASC,eAAe;AAExB,SAASC,OAAAA,YAAW;AAEpB,SAASC,UAAU;;;ACPnB,SAASC,MAAMC,cAAc;AAI7B,IAAMC,aAAaC,KAAAA;AAMnB,IAAMC,cACJ,CAACC,QAAgBC,QAAgBC,UACjC,C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AkC,CAACH,OAAOI,GAAWC,UAAyB,CAAC,MAAC;AAC3F,UAAMC,SAASN,MACZO,OAAO,QAAA,EACPC,QAAQ,aAAa,IAAA,EACrBA,QAAQ,qCAAqC,IAAA,EAC7CC,SAASZ,oBAAoB,IAAA;AAEhCa,mBAAeJ,QAAQF,GAAGC,OAAAA;EAC5B;UAEaM,SAAkC,CAACX,UAAAA;AAC9CA,UAAMC,OAAO,kBAAA,EAAoBQ,SAASZ,oBAAoB,KAAA;EAChE;AAGF,GAlBiBC,WAAAA,SAAAA,CAAAA,EAAAA;AA0BjB,IAAMY,iBAAiB,CAACJ,QAAuCF,GAAWC,UAAyB,CAAC,MAAC;AACnG,QAAM,EAAEO,SAAS,KAAOC,WAAW,KAAKC,QAAQ,EAAC,IAAKT;AACtD,SAAOC,OACJS,KAAK,KAAKX,CAAAA,EACVW,KAAK,WAAW,CAAA,EAChBC,WAAW,QAAA,EACXC,MAAML,SAAUM,KAAKC,IAAG,IAAKP,MAAAA,EAC7BC,SAASO,KAAKC,IAAIR,UAAUD,SAAS,EAAA,CAAA,EACrCU,KAAKC,aAAAA,EACLR,KAAK,KAAKX,IAAIU,KAAAA,EACdC,KAAK,WAAW,IAAC,EACjBS,GAAG,OAAO,WAAA;AACT,QAAIvB,QAAO,IAAI,EAAEQ,SAASZ,kBAAAA,GAAqB;AAC7Ca,qBAAeT,QAAO,IAAI,GAAGG,GAAGC,OAAAA;IAClC,OAAO;AACLJ,MAAAA,QAAO,IAAI,EAAEU,OAAM;IACrB;EACF,CAAA;AACJ;;",
6
- "names": ["effect", "React", "forwardRef", "useEffect", "useImperativeHandle", "useMemo", "useRef", "combine", "log", "mx", "line", "select", "createLine", "line", "createArrow", "length", "offset", "start", "el", "height", "attr", "append", "createDot", "size", "createMarkers", "arrowSize", "group", "selectAll", "data", "id", "generator", "className", "join", "d", "each", "i", "nodes", "select", "call", "drag", "pointer", "select", "defaultDragOptions", "linkMod", "freezeMod", "createGraphDrag", "context", "projector", "options", "mode", "source", "target", "offset", "moved", "keyMod", "event", "key", "modKey", "undefined", "drag", "filter", "ctrlKey", "on", "d", "pointer", "parentElement", "onDrop", "sourceEvent", "parent", "closest", "select", "classed", "raise", "dx", "dy", "x", "y", "point", "svg", "attr", "subject", "fx", "fy", "refresh", "onDrag", "findNode", "invariant", "defaultIdAccessor", "node", "id", "emptyGraph", "nodes", "edges", "Projector", "updated", "EventEmitter", "_options", "_context", "options", "Object", "assign", "idAccessor", "defaultIdAccessor", "context", "refresh", "dragging", "onRefresh", "updateData", "data", "onUpdate", "emitUpdate", "emit", "layout", "clear", "onClear", "start", "onStart", "stop", "onStop", "GraphProjector", "Projector", "_layout", "context", "options", "_selection", "layout", "id", "Math", "random", "toString", "slice", "graph", "nodes", "edges", "selection", "numChildren", "node", "filter", "edge", "source", "idAccessor", "length", "reset", "emitUpdate", "mergeData", "data", "emptyGraph", "map", "current", "find", "n", "target", "Object", "assign", "onClear", "forceCenter", "forceCollide", "forceLink", "forceManyBody", "forceRadial", "forceSimulation", "forceX", "forceY", "log", "forceX", "forceY", "forcePoint", "x", "y", "strength", "fx", "forceX", "undefined", "fy", "forceY", "force", "alpha", "initialize", "nodes", "random", "getValue", "valueOrFunction", "invoker", "defaultValue", "maybeForce", "options", "cb", "undefined", "value", "defaultForceOptions", "link", "manyBody", "point", "GraphForceProjector", "GraphProjector", "_simulation", "forceSimulation", "_timeout", "forces", "simulation", "restart", "alpha", "findNode", "x", "y", "radius", "find", "onStart", "clearTimeout", "propagating", "radial", "delay", "updateForces", "setTimeout", "on", "emitUpdate", "velocityDecay", "alphaDecay", "Math", "pow", "onStop", "stop", "onRefresh", "dragging", "center", "force", "onUpdate", "graph", "log", "nodes", "length", "edges", "mergeData", "updateLayout", "layout", "guides", "id", "type", "cx", "cy", "r", "context", "scale", "model", "toValue", "forEach", "node", "initialized", "a", "PI", "random", "Object", "assign", "cos", "sin", "attributes", "fn", "numChildren", "edge", "linkForce", "config", "forceLink", "d", "links", "filter", "distance", "strength", "iterations", "forceManyBody", "distanceMax", "collide", "forceCollide", "forceRadial", "forceCenter", "forcePoint", "forceX", "forceY", "log", "easeCubic", "timer", "log", "GraphRadialProjector", "GraphProjector", "_timer", "findNode", "x", "y", "radius", "undefined", "onUpdate", "graph", "log", "nodes", "length", "edges", "mergeData", "doRadialLayout", "animate", "start", "Date", "now", "options", "duration", "timer", "t", "Math", "min", "d", "easeCubic", "layout", "forEach", "node", "sx", "tx", "sy", "ty", "r", "sr", "tr", "emitUpdate", "stop", "onStop", "context", "size", "radial", "layoutRadial", "width", "height", "margin", "i", "updateNode", "Object", "assign", "initialized", "n", "PI", "da", "a", "cos", "sin", "layoutHorizontal", "w", "dx", "layoutVertical", "h", "dy", "GraphHierarchicalProjector", "GraphRadialProjector", "onUpdate", "graph", "log", "nodes", "length", "edges", "selection", "selected", "value", "mergeData", "node", "layout", "find", "id", "doHierarchicalLayout", "doRadialLayout", "context", "size", "r2", "options", "radius", "Math", "min", "width", "height", "margin", "r1", "children", "filter", "edge", "source", "map", "target", "updateNode", "radial", "layoutRadial", "forEach", "i", "tx", "ty", "includes", "animate", "log", "GraphRelationalProjector", "GraphRadialProjector", "onUpdate", "graph", "log", "nodes", "length", "edges", "selection", "selected", "value", "mergeData", "node", "layout", "find", "id", "doRelationalLayout", "doRadialLayout", "context", "size", "r2", "options", "radius", "Math", "min", "width", "height", "margin", "r1", "forEach", "type", "undefined", "edge", "order", "children", "filter", "source", "map", "target", "parents", "updateNode", "vertical", "layoutHorizontal", "i", "tx", "ty", "radial", "layoutRadial", "includes", "animate", "easeCubicOut", "line", "polygonHull", "select", "Clipper", "log", "easeLinear", "interpolate", "select", "createBullets", "group", "nodeId", "options", "selection", "max", "radius", "delay", "minDuration", "maxDuration", "each", "d", "i", "edges", "source", "target", "id", "path", "select", "p", "node", "getPointAtLength", "bullet", "append", "attr", "x", "y", "transition", "duration", "Math", "random", "ease", "easeLinear", "tween", "length", "getTotalLength", "r", "interpolate", "t", "point", "on", "remove", "num", "selectAll", "size", "call", "invariant", "Renderer", "_options", "_context", "_root", "options", "Object", "assign", "idAccessor", "defaultIdAccessor", "context", "root", "invariant", "current", "createLine", "line", "GraphRenderer", "Renderer", "render", "layout", "log", "root", "select", "guides", "selectAll", "data", "id", "join", "classed", "enter", "append", "attr", "update", "exit", "transition", "duration", "remove", "d", "cx", "cy", "r", "scale", "offsetDistance", "_options", "subgraphs", "components", "findConnectedComponents", "nodes", "graph", "edges", "map", "source", "target", "filter", "component", "length", "i", "points", "node", "includes", "x", "y", "hullPoints", "polygonHull", "co", "ClipperOffset", "solution", "clipperPath", "X", "Y", "AddPath", "JoinType", "jtRound", "EndType", "etClosedPolygon", "Execute", "offset", "edgeGroup", "nodeGroup", "call", "createNode", "options", "updateNode", "ease", "easeCubicOut", "on", "sort", "a", "b", "order", "createEdge", "updateEdge", "each", "fireBullet", "createBullets", "group", "circle", "drag", "onNodeClick", "event", "datum", "labels", "onNodePointerEnter", "g", "style", "parentElement", "highlight", "closest", "raise", "setTimeout", "undefined", "attributes", "classes", "applyClasses", "Object", "entries", "forEach", "key", "value", "error", "message", "groupOrTransition", "bx", "px", "py", "dx", "text", "bbox", "getBBox", "width", "height", "onLinkClick", "edge", "arrows", "start", "end", "linkForce", "initialized", "getCircumferencePoints", "el", "className", "adj", "push", "visited", "Set", "has", "stack", "componentIds", "current", "pop", "add", "line", "createLine", "line", "linkerRenderer", "root", "source", "target", "point", "selectAll", "data", "id", "join", "attr", "getCircumferencePoints", "x", "y", "r", "GraphInner", "classNames", "model", "projector", "_projector", "renderer", "_renderer", "drag", "arrows", "onSelect", "onInspect", "props", "forwardedRef", "context", "useSvgContext", "graphRef", "useRef", "useMemo", "GraphForceProjector", "GraphRenderer", "createGraphDrag", "undefined", "end", "onNodeClick", "node", "event", "onNodePointerEnter", "useImperativeHandle", "refresh", "updateData", "graph", "repaint", "render", "layout", "findNode", "id", "current", "querySelector", "useEffect", "combine", "effect", "updated", "on", "error", "stop", "log", "catch", "start", "g", "ref", "className", "mx", "Graph", "forwardRef", "geoPath", "select", "useEffect", "feature", "mesh", "Mesh", "radius", "value", "svg", "size", "useSvgContext", "useEffect", "topology", "hexTopology", "projection", "hexProjection", "path", "geoPath", "select", "append", "attr", "selectAll", "data", "objects", "hexagons", "geometries", "enter", "d", "feature", "properties", "fill", "datum", "mesh", "redraw", "border", "a", "b", "call", "width", "height", "dx", "Math", "sin", "PI", "dy", "m", "ceil", "n", "arcs", "j", "i", "y", "x", "push", "q", "type", "random", "transform", "translate", "scale", "stream", "point", "lineStart", "lineEnd", "polygonStart", "polygonEnd", "React", "mx", "Grid", "classNames", "props", "ref", "useGrid", "React", "g", "className", "mx", "select", "React", "useEffect", "useRef", "Markers", "arrowSize", "className", "ref", "useRef", "useEffect", "select", "current", "call", "createMarkers", "React", "defs", "select", "React", "forwardRef", "useEffect", "useImperativeHandle", "useMemo", "useResizeDetector", "mx", "Root", "forwardRef", "classNames", "children", "props", "ref", "containerRef", "width", "height", "useResizeDetector", "refreshRate", "context", "useMemo", "SVGContext", "scale", "centered", "useImperativeHandle", "useEffect", "setSize", "select", "svg", "attr", "viewBox", "ready", "React", "SVGContextProvider", "value", "div", "className", "mx", "xmlns", "React", "memo", "useMemo", "Zoom", "memo", "extent", "className", "children", "options", "useMemo", "JSON", "stringify", "zoom", "useZoom", "React", "g", "ref", "SVG", "Root", "Grid", "Markers", "Mesh", "Zoom", "Graph", "easeCubicOut", "select", "PROP_PULSAR_ACTIVE", "Pulsar", "has", "group", "select", "empty", "create", "r", "options", "pulsar", "append", "classed", "property", "startAnimation", "remove", "period", "duration", "ratio", "attr", "transition", "delay", "Date", "now", "Math", "min", "ease", "easeCubicOut", "on"]
3
+ "sources": ["../../../src/components/Graph/Graph.tsx", "../../../src/graph/markers.ts", "../../../src/graph/projector/graph-bundle-projector.ts", "../../../src/graph/projector/graph-radial-projector.ts", "../../../src/graph/types.ts", "../../../src/util/events.ts", "../../../src/util/fraction.ts", "../../../src/util/points.ts", "../../../src/util/scale.ts", "../../../src/util/screen.ts", "../../../src/util/vector.ts", "../../../src/graph/projector/projector.ts", "../../../src/graph/projector/graph-projector.ts", "../../../src/graph/projector/graph-cluster-projector.ts", "../../../src/graph/projector/graph-drag.ts", "../../../src/graph/projector/graph-force-projector.ts", "../../../src/graph/projector/graph-forces.ts", "../../../src/graph/projector/graph-hierarchical-projector.ts", "../../../src/graph/projector/graph-lattice-projector.ts", "../../../src/graph/projector/graph-plexus-projector.ts", "../../../src/graph/projector/graph-relational-projector.ts", "../../../src/graph/projector/graph-swarm-projector.ts", "../../../src/graph/renderer/graph-renderer.ts", "../../../src/graph/renderer/bullets.ts", "../../../src/graph/renderer/renderer.ts", "../../../src/graph/renderer/labels.ts", "../../../src/graph/renderer/linker.ts", "../../../src/hooks/useGrid.ts", "../../../src/hooks/useSvgContext.ts", "../../../src/hooks/useZoom.ts", "../../../src/components/Mesh/Mesh.tsx", "../../../src/components/SVG/FPS.tsx", "../../../src/components/SVG/Grid.tsx", "../../../src/components/SVG/Markers.tsx", "../../../src/components/SVG/Root.tsx", "../../../src/components/SVG/Zoom.tsx", "../../../src/components/SVG/SVG.tsx", "../../../src/fx/pulsar.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\nimport React, { type JSX, type Ref, forwardRef, useEffect, useImperativeHandle, useMemo, useRef } from 'react';\n\nimport { combine } from '@dxos/async';\nimport { GraphModel, type Graph as Graph$ } from '@dxos/graph';\nimport { log } from '@dxos/log';\nimport { type ThemedClassName } from '@dxos/react-ui';\nimport { mx } from '@dxos/ui-theme';\n\nimport {\n GraphForceProjector,\n type GraphLayoutNode,\n type GraphProjector,\n GraphRenderer,\n type GraphRendererOptions,\n createGraphDrag,\n} from '../../graph';\nimport { useSvgContext } from '../../hooks';\n\nexport type GraphController = {\n refresh: () => void;\n repaint: () => void;\n findNode: (id: string) => SVGGElement | null;\n};\n\n/** Cursor position expressed in the same SVG model coordinates that node `x/y` live in (centered origin, post-zoom). */\nexport type ModelPoint = { x: number; y: number };\n\nexport type GraphProps<Node extends Graph$.Node.Any = any, Edge extends Graph$.Edge.Any = any> = ThemedClassName<\n Pick<\n GraphRendererOptions<Node>,\n 'labels' | 'subgraphs' | 'attributes' | 'renderNode' | 'highlightOnHover' | 'applyNode' | 'edgeOpacity'\n > & {\n model?: GraphModel.ReactiveGraphModel<Node, Edge>;\n projector?: GraphProjector<Node>;\n renderer?: GraphRenderer<Node>;\n drag?: boolean;\n arrows?: boolean;\n onSelect?: (node: GraphLayoutNode<Node>, event: MouseEvent) => void;\n /**\n * Fires on pointerenter with the hovered node, and on pointerleave with `null`.\n * Use the `null` signal to clear hover-driven previews / highlights.\n */\n onInspect?: (node: GraphLayoutNode<Node> | null, event: MouseEvent) => void;\n /**\n * Pointer-move in SVG model coordinates (the same space `node.x/y` live in — centered\n * origin, post-zoom). The CTM lookup is done against the dx-graph group, so zoom + viewBox\n * are both undone in one step. Pair with `onPointerLeave` to clear cursor-driven state.\n * When either handler is set the renderer's `<svg>` is given `pointer-events: all` so\n * events fire across empty canvas, not just over painted nodes.\n */\n onPointerMove?: (point: ModelPoint, event: PointerEvent) => void;\n onPointerLeave?: (event: PointerEvent) => void;\n }\n>;\n\nconst GraphInner = <Node extends Graph$.Node.Any = any, Edge extends Graph$.Edge.Any = any>(\n {\n classNames,\n model,\n projector: projectorProp,\n renderer: rendererProp,\n drag,\n arrows,\n onSelect,\n onInspect,\n onPointerMove,\n onPointerLeave,\n ...props\n }: GraphProps<Node, Edge>,\n forwardedRef: Ref<GraphController>,\n) => {\n const context = useSvgContext();\n const graphRef = useRef<SVGGElement>(null);\n\n const { projector, renderer } = useMemo(() => {\n let projector = projectorProp;\n if (!projector) {\n projector = new GraphForceProjector<Node>(context);\n }\n\n let renderer = rendererProp;\n if (!renderer) {\n renderer = new GraphRenderer<Node>(context, graphRef, {\n ...props,\n // TODO(burdon): Replace drag when projector is updated.\n drag: drag ? createGraphDrag(context, projector) : undefined,\n arrows: { end: arrows },\n // Projector intercept first so built-in interactions (e.g. cluster collapse) can\n // run without consumers wiring them. Returning true suppresses the user handler.\n onNodeClick: (node, event) => {\n if (projector.handleNodeClick(node, event)) {\n return;\n }\n onSelect?.(node, event);\n },\n onNodePointerEnter: onInspect ? (node, event) => onInspect(node, event) : undefined,\n // Pair pointerenter with leave so consumers can clear hover-driven previews.\n // The callback receives `null` on leave (event still carries the source).\n onNodePointerLeave: onInspect ? (_node, event) => onInspect(null, event) : undefined,\n });\n }\n\n return { projector, renderer };\n // Renderer options are baked into the instance — re-memo when any of them change\n // so a swapped `renderNode` / handler is actually applied.\n }, [\n context,\n projectorProp,\n rendererProp,\n drag,\n arrows,\n onSelect,\n onInspect,\n props.labels,\n props.subgraphs,\n props.attributes,\n props.renderNode,\n props.highlightOnHover,\n props.applyNode,\n props.edgeOpacity,\n ]);\n\n // External API.\n useImperativeHandle(\n forwardedRef,\n () => ({\n refresh: () => {\n projector.updateData(model?.graph);\n },\n repaint: () => {\n renderer.render(projector.layout);\n },\n findNode: (id: string) => {\n return graphRef.current?.querySelector<SVGGElement>(`g[data-id=\"${id}\"]`);\n },\n }),\n [model, projector, renderer],\n );\n\n // Subscriptions.\n useEffect(() => {\n // Wire the renderer listener BEFORE calling updateData so the synchronous\n // 'topology' emit (fired from inside onUpdate) reaches the renderer.\n const cleanup = combine(\n // Subscribe to model changes if reactive model.\n model\n ? model.subscribe(() => {\n projector.updateData(model?.graph);\n })\n : undefined,\n\n projector.updated.on(({ layout, kind }) => {\n try {\n // 'positions' is the per-tick fast path; 'topology' (and unset, for back-compat) is the full render.\n if (kind === 'positions') {\n renderer.applyPositions(layout);\n } else {\n renderer.render(layout);\n }\n } catch (error) {\n log.catch(error);\n void projector.stop();\n }\n }),\n );\n\n projector.updateData(model?.graph);\n\n return cleanup;\n }, [model, projector, renderer]);\n\n // Start.\n useEffect(() => {\n void projector.start();\n return () => {\n void projector.stop();\n };\n }, [projector]);\n\n // Model-space pointer events. Attached to the SVG element so they fire across the entire\n // canvas (with pointer-events: all), not just over painted nodes. The dx-graph group's CTM\n // undoes both the centered viewBox and any active zoom in one step, landing the cursor in\n // the same coordinate space the projector reads.\n useEffect(() => {\n if (!onPointerMove && !onPointerLeave) {\n return;\n }\n const svg = context.svg;\n if (!svg) {\n return;\n }\n const previousPointerEvents = svg.style.pointerEvents;\n svg.style.pointerEvents = 'all';\n const handleMove = (event: PointerEvent) => {\n if (!onPointerMove) {\n return;\n }\n const target = graphRef.current;\n const ctm = target?.getScreenCTM();\n if (!target || !ctm) {\n return;\n }\n const point = svg.createSVGPoint();\n point.x = event.clientX;\n point.y = event.clientY;\n const modelPoint = point.matrixTransform(ctm.inverse());\n onPointerMove({ x: modelPoint.x, y: modelPoint.y }, event);\n };\n const handleLeave = (event: PointerEvent) => {\n onPointerLeave?.(event);\n };\n svg.addEventListener('pointermove', handleMove);\n svg.addEventListener('pointerleave', handleLeave);\n return () => {\n svg.removeEventListener('pointermove', handleMove);\n svg.removeEventListener('pointerleave', handleLeave);\n svg.style.pointerEvents = previousPointerEvents;\n };\n }, [context, onPointerMove, onPointerLeave]);\n\n return <g ref={graphRef} className={mx('dx-graph', classNames)} />;\n};\n\n/**\n * SVG Graph.\n */\nexport const Graph = forwardRef(GraphInner) as <Node extends Graph$.Node.Any = any, Edge extends Graph$.Edge.Any = any>(\n props: GraphProps<Node, Edge> & { ref?: Ref<GraphController> },\n) => JSX.Element;\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { line, select } from 'd3';\n\nimport { type D3Callable } from '../util';\n\nconst createLine = line();\n\nexport type MarkerOptions = {\n arrowSize?: number;\n};\n\nconst createArrow =\n (length: number, offset: number, start: boolean): D3Callable =>\n (el) => {\n const height = length * 0.5;\n el.attr('markerWidth', length * 2)\n .attr('markerHeight', height * 2)\n .attr('viewBox', `-${length},-${height},${length * 2},${height * 2}`)\n .attr('orient', 'auto')\n .attr('refX', offset)\n .append('path')\n .attr('fill', 'none')\n // Inherit stroke from path.\n .attr('stroke', 'context-stroke')\n .attr(\n 'd',\n createLine([\n start ? [length, height] : [-length, -height],\n [0, 0],\n start ? [length, -height] : [-length, height],\n ]),\n );\n };\n\nconst createDot =\n (size: number): D3Callable =>\n (el) => {\n el.attr('markerWidth', size * 2)\n .attr('markerHeight', size * 2)\n .attr('viewBox', `-${size},-${size},${size * 2},${size * 2}`)\n .attr('orient', 'auto')\n .append('circle')\n // Inherit stroke from path.\n .attr('fill', 'context-stroke')\n .attr('r', size / 2 - 1);\n };\n\n/**\n * https://developer.mozilla.org/en-US/docs/Web/SVG/Element/marker\n * https://www.dashingd3js.com/svg-paths-and-d3js\n * http://bl.ocks.org/dustinlarimer/5888271\n */\nexport const createMarkers =\n ({ arrowSize = 12 }: MarkerOptions = {}): D3Callable =>\n (group) => {\n return group\n .selectAll('marker')\n .data([\n {\n id: 'marker-arrow-start',\n generator: createArrow(arrowSize, -0.5, true),\n className: 'dx-arrow',\n },\n {\n id: 'marker-arrow-end',\n generator: createArrow(arrowSize, 0.5, false),\n className: 'dx-arrow',\n },\n {\n id: 'marker-dot',\n generator: createDot(6),\n className: 'dx-dot',\n },\n ])\n .join('marker')\n .attr('id', (d) => d.id)\n .attr('markerUnits', 'strokeWidth')\n .attr('class', (d) => d.className)\n .each((d, i, nodes) => {\n select(nodes[i]).call(d.generator);\n });\n };\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport { type HierarchyNode, cluster as d3Cluster, curveBundle, hierarchy, lineRadial } from 'd3';\n\nimport { type Graph } from '@dxos/graph';\nimport { log } from '@dxos/log';\n\nimport { type GraphLayoutEdge, type GraphLayoutNode } from '../types';\nimport { GraphRadialProjector, type GraphRadialProjectorOptions, updateNode } from './graph-radial-projector';\n\nexport type GraphBundleProjectorOptions = GraphRadialProjectorOptions & {\n /** Reserved space around the bundle (screen pixels). */\n margin?: number;\n /** Radius for leaf nodes. Default 4. */\n leafRadius?: number;\n /**\n * Group key for each node — synthetic intermediate nodes are created per unique key\n * to give the bundling layout a routing point (lowest common ancestor) for edges\n * between leaves in different groups. Return `undefined` to attach the node directly\n * to the root (all such leaves bundle through the root).\n */\n groupOf?: (node: GraphLayoutNode) => string | undefined;\n /** Bundling tension passed to `d3.curveBundle.beta`. 0 = straight chord, 1 = max bundled. */\n tension?: number;\n};\n\nconst ROOT_ID = '__bundle_root__';\nconst GROUP_PREFIX = '__bundle_group__:';\n\n/**\n * Cartesian → d3-radial polar. d3 measures angle clockwise from \"up\" (the -y direction).\n * Inverse of `[cos(a - π/2) * r, sin(a - π/2) * r]`.\n */\nconst cartesianToPolar = (x: number, y: number): { angle: number; radius: number } => ({\n angle: Math.atan2(x, -y),\n radius: Math.hypot(x, y),\n});\n\ntype PolarPoint = { angle: number; radius: number };\n\n/**\n * Hierarchical edge bundling — Holten 2006 / d3 observable notebook\n * (https://observablehq.com/@d3/hierarchical-edge-bundling).\n *\n * Synthesizes the same root → group → leaf hierarchy as `GraphClusterProjector`, runs\n * d3.cluster to give every node a polar position, but renders ONLY the leaves\n * (root + groups are routing anchors, not visible nodes). Each data edge is replaced\n * with a curve generated by `lineRadial(curveBundle.beta(tension))` over the polar\n * positions of `source.path(target)` — i.e. the chain of ancestors through the lowest\n * common ancestor.\n *\n * Per-frame `onTickFrame` refreshes the leaf endpoints (first + last point of every\n * path) from current cartesian positions so the curves stay glued to leaves during a\n * cross-variant tween (force → bundle, lattice → bundle). Internal ancestor positions\n * are fixed at d3.cluster's final polar layout, which means during the tween curves\n * route through the destination \"pivot points\" while the leaf endpoints catch up —\n * visually the bundle \"snaps into shape\" as the leaves arrive.\n */\nexport class GraphBundleProjector<\n NodeData = any,\n Options extends GraphBundleProjectorOptions = any,\n> extends GraphRadialProjector<NodeData, Options> {\n // Per-edge polar point arrays. Points 0 and N-1 are the source / target leaves and are\n // overwritten from current cartesian on every tick; intermediate points stay fixed at\n // their cluster-layout polar coordinates.\n #edgePoints = new Map<string, PolarPoint[]>();\n #lineGen = lineRadial<PolarPoint>()\n .radius((d) => d.radius)\n .angle((d) => d.angle);\n\n protected override onUpdate(graph?: Graph.Any) {\n log('onUpdate', { graph: { nodes: graph?.nodes.length, edges: graph?.edges.length } });\n this.mergeData(graph);\n this.doBundleLayout();\n this.emitUpdate('topology');\n this.animate();\n }\n\n /**\n * Refresh leaf endpoint polar values from current cartesian so the curve tracks\n * its endpoints during the tween. Internal hierarchy positions stay constant.\n */\n protected override onTickFrame(_t: number): void {\n for (const edge of this.layout.graph.edges) {\n if (edge.type !== 'bundle') {\n continue;\n }\n const points = this.#edgePoints.get(edge.id);\n if (!points || points.length < 2) {\n continue;\n }\n const s = cartesianToPolar(edge.source.x ?? 0, edge.source.y ?? 0);\n const t = cartesianToPolar(edge.target.x ?? 0, edge.target.y ?? 0);\n points[0] = { angle: s.angle, radius: s.radius };\n points[points.length - 1] = { angle: t.angle, radius: t.radius };\n edge.path = this.#lineGen(points) ?? undefined;\n }\n }\n\n private doBundleLayout() {\n if (!this.context.size) {\n return;\n }\n const dataNodes = [...this.layout.graph.nodes];\n if (!dataNodes.length) {\n return;\n }\n\n const groupOf = this.options.groupOf;\n\n // Synthesize root → groups → leaves hierarchy so d3.cluster gives every node\n // (including the routing-only internal ones) a polar coordinate.\n type HierNode = { id: string; parent?: string; node?: GraphLayoutNode<NodeData> };\n const items: HierNode[] = [{ id: ROOT_ID }];\n const groupIds = new Map<string, string>();\n for (const node of dataNodes) {\n const key = groupOf?.(node);\n let parent = ROOT_ID;\n if (key !== undefined) {\n let groupId = groupIds.get(key);\n if (!groupId) {\n groupId = `${GROUP_PREFIX}${key}`;\n groupIds.set(key, groupId);\n items.push({ id: groupId, parent: ROOT_ID });\n }\n parent = groupId;\n }\n items.push({ id: node.id, parent, node });\n }\n\n const childrenByParent = new Map<string, HierNode[]>();\n for (const item of items) {\n if (item.parent) {\n const list = childrenByParent.get(item.parent) ?? [];\n list.push(item);\n childrenByParent.set(item.parent, list);\n }\n }\n\n const root = hierarchy<HierNode>({ id: ROOT_ID }, (d) => childrenByParent.get(d.id) ?? []);\n\n const { width, height } = this.context.size;\n const margin = this.options.margin ?? 120;\n const ringRadius = Math.max(0, Math.min(width, height) / 2 - margin);\n\n d3Cluster<HierNode>()\n .size([2 * Math.PI, ringRadius])\n .separation((a: any, b: any) => (a.parent === b.parent ? 1 : 2) / Math.max(1, a.depth))(root);\n\n const leafR = this.options.leafRadius ?? 4;\n\n // Re-bake the line generator with the configured tension. d3 curve factories return\n // a new curve when `.beta` is called, so this must happen whenever options change.\n const tension = this.options.tension ?? 0.85;\n this.#lineGen = lineRadial<PolarPoint>()\n .curve(curveBundle.beta(tension))\n .radius((d) => d.radius)\n .angle((d) => d.angle);\n\n // Index hierarchy nodes by data id for fast lookup when building edge paths.\n const hierById = new Map<string, HierarchyNode<HierNode>>();\n root.each((d) => {\n hierById.set(d.data.id, d);\n });\n\n // Position the leaf data nodes (cartesian); internal nodes stay layout-only.\n root.leaves().forEach((d: any) => {\n const angle = d.x;\n const radius = d.y;\n const x = Math.cos(angle - Math.PI / 2) * radius;\n const y = Math.sin(angle - Math.PI / 2) * radius;\n if (d.data.node) {\n updateNode(d.data.node, [x, y], leafR);\n }\n });\n this.layout.graph.nodes = dataNodes;\n\n // Build bundle edges. `mergeData` already populated `layout.graph.edges` with data\n // edges referencing the leaf GraphLayoutNodes — keep those references (so node\n // animations & hover wiring continue to work) and enhance each with a routed path\n // through the hierarchy.\n this.#edgePoints.clear();\n const incomingEdges = [...this.layout.graph.edges];\n const bundleEdges: GraphLayoutEdge<NodeData>[] = [];\n for (const edge of incomingEdges) {\n const sourceHier = hierById.get(edge.source.id);\n const targetHier = hierById.get(edge.target.id);\n if (!sourceHier || !targetHier || sourceHier === targetHier) {\n continue;\n }\n // hierarchy.path returns [source, ...up to LCA, ...down to target] (inclusive endpoints).\n const pathNodes = sourceHier.path(targetHier);\n const points: PolarPoint[] = pathNodes.map((n: any) => ({ angle: n.x, radius: n.y }));\n this.#edgePoints.set(edge.id, points);\n bundleEdges.push({\n id: edge.id,\n type: 'bundle',\n source: edge.source,\n target: edge.target,\n data: edge.data,\n });\n }\n this.layout.graph.edges = bundleEdges;\n\n // Seed initial paths so the topology emit has correct geometry to enter into the DOM.\n this.onTickFrame(0);\n }\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Timer, easeCubic, timer } from 'd3';\n\nimport { type Graph } from '@dxos/graph';\nimport { log } from '@dxos/log';\n\nimport { type Point } from '../../util';\nimport { type GraphLayoutNode } from '../types';\nimport { GraphProjector, type GraphProjectorOptions } from './graph-projector';\n\nexport type GraphRadialProjectorOptions = GraphProjectorOptions & {\n radius?: number;\n margin?: number;\n duration?: number;\n};\n\nexport class GraphRadialProjector<\n NodeData = any,\n Options extends GraphRadialProjectorOptions = any,\n> extends GraphProjector<NodeData, Options> {\n private _timer?: Timer;\n\n override findNode(x: number, y: number, radius: number): GraphLayoutNode<NodeData> | undefined {\n return undefined;\n }\n\n protected override onUpdate(graph?: Graph.Any) {\n log('onUpdate', { graph: { nodes: graph?.nodes.length, edges: graph?.edges.length } });\n this.mergeData(graph);\n // Bind enter/exit once before the tween starts; subsequent animate frames emit 'positions'.\n this.emitUpdate('topology');\n this.doRadialLayout();\n }\n\n protected animate() {\n // Cancel any in-flight tween so a fresh onUpdate doesn't race against the\n // previous timer (both would be mutating x/y at different rates).\n this._timer?.stop();\n this._timer = undefined;\n\n const start = Date.now();\n if (this.options.duration) {\n this._timer = timer(() => {\n const t = Math.min(1, (Date.now() - start) / this.options.duration);\n const d = easeCubic(t);\n\n this.layout.graph.nodes.forEach((node: any) => {\n node.x = node.sx + (node.tx - node.sx) * d;\n node.y = node.sy + (node.ty - node.sy) * d;\n node.r = node.sr + (node.tr - node.sr) * d;\n });\n\n // Subclass hook: derived projectors (e.g. cluster) can mutate edge.path\n // here so curves track moving endpoints during the tween. The renderer's\n // applyPositions reads edge.path fresh each frame.\n this.onTickFrame(d);\n\n // Tween frames only mutate `x/y/r`; emit 'positions' so the renderer can fast-path.\n this.emitUpdate('positions');\n if (t >= 1) {\n this._timer.stop();\n this._timer = undefined;\n }\n });\n } else {\n // No duration: snap nodes to their target. Without this the layout would\n // sit at `sx/sy/sr` (= previous positions) and never reach the new target.\n this.layout.graph.nodes.forEach((node: any) => {\n node.x = node.tx;\n node.y = node.ty;\n node.r = node.tr;\n });\n this.onTickFrame(1);\n this.emitUpdate('positions');\n }\n }\n\n /**\n * Per-frame hook called after node x/y/r are interpolated and before the\n * 'positions' emit. Subclasses override to update edge geometry (`edge.path`)\n * so curves stay glued to moving endpoints. `t` is the eased progress in [0, 1].\n */\n protected onTickFrame(t: number): void {}\n\n protected override async onStop() {\n this._timer?.stop();\n this._timer = undefined;\n }\n\n protected doRadialLayout() {\n if (!this.context.size) {\n return;\n }\n\n const radial = layoutRadial(\n 0,\n 0,\n this.options.radius ??\n Math.min(this.context.size.width, this.context.size.height) / 2 - (this.options.margin ?? 80),\n this.layout.graph.nodes.length,\n );\n\n this.layout.graph.nodes.forEach((node, i) => {\n const [tx, ty] = radial(i);\n updateNode(node, [tx, ty]);\n });\n\n this.animate();\n }\n}\n\n/**\n * Update node target.\n */\nexport const updateNode = (node: GraphLayoutNode, [tx, ty]: Point, tr = 8) => {\n const sx = node.x ?? tx;\n const sy = node.y ?? ty;\n const sr = node.r ?? tr;\n Object.assign(node, {\n initialized: true,\n // Start.\n sx,\n sy,\n sr,\n // Target.\n tx,\n ty,\n tr,\n // Current.\n x: sx,\n y: sy,\n r: sr,\n });\n};\n\n/**\n * Radial position generator.\n */\nexport const layoutRadial = (x: number, y: number, r: number, n: number, start = -Math.PI / 2) => {\n const da = (2 * Math.PI) / n;\n return (i: number): Point => {\n const a = start + i * da;\n return [x + Math.cos(a) * r, y + Math.sin(a) * r];\n };\n};\n\n/**\n * Horizontal position generator.\n */\nexport const layoutHorizontal = (x: number, y: number, w: number, n: number) => {\n const dx = n > 1 ? w / (n - 1) : 0;\n const sx = x - ((n - 1) * dx) / 2;\n return (i: number): Point => {\n return [sx + i * dx, y];\n };\n};\n\n/**\n * Vertical position generator.\n */\nexport const layoutVertical = (x: number, y: number, h: number, n: number) => {\n const dy = n > 1 ? h / (n - 1) : 0;\n const sy = y - ((n - 1) * dy) / 2;\n return (i: number): Point => {\n return [x, sy + i * dy];\n };\n};\n", "//\n// Copyright 2021 DXOS.org\n//\n\n//\n// Data\n// Generic graph data type.\n//\n\nimport { type Graph } from '@dxos/graph';\nimport { invariant } from '@dxos/invariant';\n\nimport { type Point } from '../util';\n\nexport type IdAccessor<N = any> = (node: N) => string;\n\nexport const defaultIdAccessor: IdAccessor = (node: any) => {\n invariant(node.id);\n return node.id;\n};\n\nexport const emptyGraph: Graph.Any = {\n nodes: [],\n edges: [],\n};\n\n//\n// Layout\n// Graph layout used by graph renderers.\n//\n\nexport type GraphGuide = {\n id: string;\n type: string;\n cx: number;\n cy: number;\n r: number;\n classes?: {\n circle?: string;\n };\n};\n\nexport type GraphLayoutNode<NodeData = any> = {\n id: string;\n type?: string;\n order?: number;\n data?: NodeData;\n /** Human-readable label. Synthetic nodes (e.g. cluster root / group) carry this so\n * consumer renderNode callbacks can label them without parsing internal id formats. */\n label?: string;\n /** When true the node remains in the layout but is rendered with opacity 0 and no\n * pointer events — used by the cluster's collapse animation so hidden leaves can\n * tween to their parent's position rather than popping out, and tween back when the\n * parent is re-expanded. */\n hidden?: boolean;\n x?: number;\n y?: number;\n r?: number;\n classes?: {\n circle?: string;\n text?: string;\n };\n children?: number;\n initialized?: boolean;\n last?: Point;\n};\n\nexport type GraphLayoutEdge<NodeData = any, EdgeData = any> = {\n id: string;\n type?: string;\n order?: number;\n source: GraphLayoutNode<NodeData>;\n target: GraphLayoutNode<NodeData>;\n data?: EdgeData;\n linkForce?: boolean;\n /**\n * Precomputed SVG `d` attribute. When set, the renderer uses this instead of\n * deriving a straight-line path from `source/target` positions. Lets projectors\n * own edge geometry (e.g. radial elbows, bundled curves) without renderer changes.\n */\n path?: string;\n classes?: {\n path?: string;\n };\n};\n\nexport type GraphLayout<NodeData = any, EdgeData = any> = {\n id?: string;\n guides?: GraphGuide[];\n graph: {\n nodes: GraphLayoutNode<NodeData>[];\n edges: GraphLayoutEdge<NodeData, EdgeData>[];\n };\n};\n", "//\n// Copyright 2021 DXOS.org\n//\n\ntype EventListener<T> = (value: T) => void;\n\nexport type EventHandle = () => void;\n\nexport class EventEmitter<T> {\n private readonly _listeners = new Set<EventListener<T>>();\n\n clear(): void {\n this._listeners.clear();\n }\n\n on(onEvent: EventListener<T>): EventHandle {\n this._listeners.add(onEvent);\n return () => this._listeners.delete(onEvent);\n }\n\n public emit(value: T): void {\n this._listeners.forEach((listener) => listener(value));\n }\n}\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport { invariant } from '@dxos/invariant';\n\n// TODO(burdon): Protobuf mapping?\nexport type Fraction = [num: number, denum: number];\n\nexport type Num = number | Fraction;\n\nexport class FractionUtil {\n /**\n * Convert number to fraction.\n * @param n\n */\n static toFraction = (n: Num): Fraction => {\n return typeof n === 'number' ? [n, 1] : n;\n };\n\n static validate = (...fraction: Fraction[]): Fraction[] => {\n fraction.forEach(([n, d]) => {\n if (!Number.isFinite(n) || !Number.isFinite(d) || d === 0) {\n throw new Error(`Invalid fraction: ${n}/${d}`);\n }\n });\n\n return fraction;\n };\n\n /**\n * @param {Fraction}\n * Convert to rounded-sm number.\n */\n static toNumber = ([n, d]: Fraction): number => {\n FractionUtil.validate([n, d]);\n return n / d;\n };\n\n /**\n * Round the number to the nearest fraction.\n * Example: 3/5 => 1/1; 3/5 (precision 2) => 1/2.\n * @param {Fraction}\n * @param p Precision (e.g., 1/2, 1/4, etc.)\n */\n static round = ([n, d]: Fraction, p = 1): Fraction => {\n FractionUtil.validate([n, d]);\n const v = Math.round(FractionUtil.toNumber(FractionUtil.divide([n, d], [1, p])));\n return FractionUtil.simplify([v, p]);\n };\n\n //\n // Boolean.\n //\n\n /**\n * Tests if equals.\n * @param n1\n * @param n2\n */\n static equals = (n1: Fraction, n2: Fraction) => {\n return n1[0] * n2[1] === n1[1] * n2[0];\n };\n\n /**\n * @param {Fraction}\n * True if zero.\n */\n static isZero = ([n]: Fraction): boolean => {\n return n === 0;\n };\n\n //\n // Normalization.\n //\n\n /**\n * Simplify fraction finding LCDs.\n * @param n\n * @param d\n */\n static simplify = ([n, d]: Fraction): Fraction => {\n FractionUtil.validate([n, d]);\n if (d < 1) {\n const t = n / d;\n if (Math.floor(t) === t) {\n n = t;\n d = 1;\n }\n }\n\n // Find highest common denominator.\n const fn = FractionUtil.factors(n).reverse();\n const fd = FractionUtil.factors(d).reverse();\n\n let c;\n for (let i = 0; i < fn.length; i++) {\n c = fd.find((n) => n === fn[i]);\n if (c) {\n return [n / c, d / c];\n }\n }\n\n // TODO(burdon): Convert to number if d == 1.\n return [n, d];\n };\n\n /**\n * Return common factors.\n * @param n\n */\n static factors = (n: number): number[] => {\n invariant(Number.isFinite(n), `Invalid number: ${n}`);\n\n const factors = [1];\n if (Number.isSafeInteger(n)) {\n let f = 1;\n do {\n if (n % ++f === 0) {\n factors.push(f);\n }\n } while (n / f > 1 && f < 100);\n }\n\n return factors;\n };\n\n //\n // Basic arithmetic.\n //\n\n /**\n * @param n1\n * @param n2\n */\n static add = (n1: Fraction, n2: Fraction): Fraction => {\n FractionUtil.validate(n1, n2);\n const d = n1[1] * n2[1]; // Same denom.\n const n = n1[0] * n2[1] + n2[0] * n1[1];\n return FractionUtil.simplify([n, d]);\n };\n\n /**\n * @param n1\n * @param n2\n */\n static subtract = (n1: Fraction, n2: Fraction): Fraction => {\n FractionUtil.validate(n1, n2);\n const d = n1[1] * n2[1]; // Same denom.\n const n = n1[0] * n2[1] - n2[0] * n1[1];\n return FractionUtil.simplify([n, d]);\n };\n\n /**\n * @param n1\n * @param n2\n */\n static multiply = (n1: Fraction, n2: Fraction): Fraction => {\n FractionUtil.validate(n1, n2);\n const n = n1[0] * n2[0];\n const d = n1[1] * n2[1];\n return FractionUtil.simplify([n, d]);\n };\n\n /**\n * @param n1\n * @param n2\n */\n static divide = (n1: Fraction, n2: Fraction): Fraction => {\n FractionUtil.validate(n1, n2);\n const n = n1[0] * n2[1];\n const d = n1[1] * n2[0];\n return FractionUtil.simplify([n, d]);\n };\n}\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { type Point } from './types';\n\n/**\n * Creates an array of points on the the circumference of two circles.\n * http://www.math.com/tables/geometry/circles.htm\n *\n * @param p1\n * @param p2\n * @param r1\n * @param r2\n * @return {[Point, Point]}\n */\nexport const getCircumferencePoints = (p1: Point, p2: Point, r1 = 0, r2 = 0): [Point, Point] => {\n const [x1, y1] = p1;\n const [x2, y2] = p2;\n\n const theta = Math.atan2(x2 - x1, y2 - y1);\n\n return [\n [\n // p1\n x1 + (r1 === 0 ? 0 : r1 * Math.sin(theta)),\n y1 + (r1 === 0 ? 0 : r1 * Math.cos(theta)),\n ],\n [\n // p2\n x2 - (r2 === 0 ? 0 : r2 * Math.cos(Math.PI / 2 - theta)),\n y2 - (r2 === 0 ? 0 : r2 * Math.sin(Math.PI / 2 - theta)),\n ],\n ];\n};\n\n// Compute unit normal for a line segment.\nexport const normal = (p1: Point, p2: Point): Point => {\n const dx = p2[0] - p1[0];\n const dy = p2[1] - p1[1];\n const len = Math.hypot(dx, dy);\n return [dy / len, -dx / len]; // rotated +90°\n};\n\n// Average adjacent normals.\nexport const offsetPoints = (points: Point[], distance: number, closed: boolean): Point[] => {\n const len = points.length;\n const out: Point[] = [];\n\n for (let i = 0; i < len; i++) {\n const p0 = points[(i - 1 + len) % len];\n const p1 = points[i];\n const p2 = points[(i + 1) % len];\n\n const n1 = normal(p0, p1);\n const n2 = normal(p1, p2);\n const nx = (n1[0] + n2[0]) / 2;\n const ny = (n1[1] + n2[1]) / 2;\n const norm = Math.hypot(nx, ny) || 1;\n out.push([p1[0] + (distance * nx) / norm, p1[1] + (distance * ny) / norm]);\n\n if (!closed && (i === 0 || i === len - 1)) {\n out[i] = [p1[0] + distance * normal(p0, p1)[0], p1[1] + distance * normal(p0, p1)[1]];\n }\n }\n\n return out;\n};\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport { type ZoomTransform, zoomIdentity } from 'd3';\n\nimport { FractionUtil } from './fraction';\nimport { type Fraction } from './fraction';\nimport { type Point, type Rect } from './types';\nimport { type Bounds, type Vertex } from './vector';\n\n/**\n * Scale to map vector space to view (screen) space.\n */\nexport class Scale {\n private _transform?: ZoomTransform;\n\n constructor(private readonly _gridSize: number = 32) {}\n\n get gridSize() {\n return this._gridSize;\n }\n\n get transform() {\n return this._transform || zoomIdentity;\n }\n\n setTransform(transform: ZoomTransform): boolean {\n if (\n this._transform?.x === transform.x &&\n this._transform?.y === transform.y &&\n this._transform?.k === transform.k\n ) {\n return false;\n }\n\n this._transform = transform;\n return true;\n }\n\n /**\n * Translate a screen point to a logical point.\n * @param point\n */\n translate(point: Point): Point {\n const { x, y, k } = this._transform ?? { x: 0, y: 0, k: 1 };\n return [(point[0] - x) / k, (point[1] - y) / k];\n }\n\n /**\n * Map model to screen.\n * Model points are represented by fractions (to preserve precision) and use normal cartesian coordinates.\n */\n readonly model = {\n // TODO(burdon): Precision depends on scale.\n snapValues: (array: Fraction[]): Fraction[] => array.map((n) => FractionUtil.round(n)),\n\n snapVertex: ({ x, y }: Vertex): Vertex => {\n const [sx, sy] = this.model.snapValues([x, y]);\n return { x: sx, y: sy };\n },\n\n snapBounds: ({ x, y, width, height }: { x: Fraction; y: Fraction; width: Fraction; height: Fraction }): Bounds => {\n [x, y, width, height] = this.model.snapValues([x, y, width, height]);\n return { x, y, width, height };\n },\n\n toValue: (value: Fraction): number => {\n return Math.round(FractionUtil.toNumber(value) * this._gridSize);\n },\n\n toValues: (values: Fraction[]): number[] => {\n return values.map((value) => Math.round(FractionUtil.toNumber(value) * this._gridSize));\n },\n\n toPoint: (point: Vertex): Point => {\n const [x, y] = this.model.toValues([point.x, point.y]);\n return [x, y === 0 ? 0 : -y]; // Prevent -0.\n },\n\n toBounds: ({ x, y, width, height }: Bounds): Rect => {\n const point = this.model.toPoint({ x, y });\n const [width2, height2] = this.model.toValues([width, height]);\n\n return {\n x: point[0],\n y: point[1] - height2,\n width: width2,\n height: height2,\n };\n },\n };\n\n /**\n * Map screen to model.\n * Screen points are represented by floating numbers and use translated SVG coordinates (with the y-axis inverted).\n */\n readonly screen = {\n snapValues: (array: number[]): number[] => array.map((n) => Math.round(n / this._gridSize) * this._gridSize),\n\n snapPoint: ([x, y]: [number, number]): Point =>\n [x, y].map((n) => Math.round(n / this._gridSize) * this._gridSize) as Point,\n\n snapBounds: ({ x, y, width, height }: { x: number; y: number; width: number; height: number }): Rect => {\n [x, y, width, height] = this.screen.snapValues([x, y, width, height]);\n return { x, y, width, height };\n },\n\n toValue: (value: number): Fraction => {\n return FractionUtil.divide(FractionUtil.toFraction(value), [this._gridSize, 1]);\n },\n\n toValues: (values: number[]): Fraction[] => {\n return values.map((value) => FractionUtil.divide(FractionUtil.toFraction(value), [this._gridSize, 1]));\n },\n\n toVertex: (point: Point): Vertex => {\n const [x, y] = point;\n return {\n x: FractionUtil.toFraction(x / this._gridSize),\n y: FractionUtil.toFraction(-y / this._gridSize),\n };\n },\n\n toBounds: (bounds: Rect): Bounds => {\n const { x, y } = this.screen.toVertex([bounds.x, bounds.y]);\n const [width, height] = this.screen.toValues([bounds.width, bounds.height]);\n\n return {\n x,\n y: FractionUtil.subtract(y, height),\n width,\n height,\n };\n },\n };\n}\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport { type Point, type Rect } from './types';\n\nexport type Modifiers = {\n center?: boolean;\n constrain?: boolean;\n};\n\nexport class Screen {\n static createBounds = ([x1, y1]: Point, [x2, y2]: Point, mod: Modifiers = {}): Rect => {\n const { constrain, center } = mod;\n\n const x = Math.min(x1, x2);\n const y = Math.min(y1, y2);\n\n let width = Math.abs(x2 - x1);\n let height = Math.abs(y2 - y1);\n if (constrain) {\n width = height = Math.max(width, height);\n }\n\n if (center) {\n return {\n x: x - width,\n y: y - height,\n width: width * 2,\n height: height * 2,\n };\n } else {\n return {\n x,\n y,\n width,\n height,\n };\n }\n };\n\n static center = ({ x, y, width, height }: Rect): Point => {\n return [x + width / 2, y + height / 2];\n };\n\n static contains = (bounds: Rect, point: Point): boolean => {\n const [x, y] = point;\n\n if (x < bounds.x || y < bounds.y) {\n return false;\n }\n\n if (x > bounds.x + bounds.width || y > bounds.y + bounds.height) {\n return false;\n }\n\n return true;\n };\n\n /**\n * Distance between two points.\n * @param p1\n * @param p2\n */\n static len = (p1: Point, p2: Point) => {\n return Math.sqrt(Math.pow(Math.abs(p1[0] - p2[0]), 2) + Math.pow(Math.abs(p1[1] - p2[1]), 2));\n };\n\n /**\n * Distance to line segment.\n * https://stackoverflow.com/questions/849211/shortest-distance-between-a-point-and-a-line-segment#1501725\n * @param v1\n * @param v2\n * @param p\n */\n static normal = (v1: Point, v2: Point, p: Point) => {\n const d2 = (p1: Point, p2: Point) => Math.pow(Math.abs(p1[0] - p2[0]), 2) + Math.pow(Math.abs(p1[1] - p2[1]), 2);\n\n let d: number;\n const len2 = d2(v1, v2);\n if (len2 === 0) {\n d = d2(p, v1);\n } else {\n let t = ((p[0] - v1[0]) * (v2[0] - v1[0]) + (p[1] - v1[1]) * (v2[1] - v1[1])) / len2;\n t = Math.max(0, Math.min(1, t));\n d = d2(p, [v1[0] + t * (v2[0] - v1[0]), v1[1] + t * (v2[1] - v1[1])]);\n }\n\n return Math.sqrt(d);\n };\n}\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport { type Fraction, FractionUtil, type Num } from './fraction';\n\nexport type Vertex = { x: Fraction; y: Fraction };\n\nexport type Bounds = {\n x: Fraction;\n y: Fraction;\n width: Fraction;\n height: Fraction;\n};\n\nexport class Vector {\n /**\n * Convert to Vertex.\n * @param x\n * @param y\n */\n static toVertex = ({ x, y }: { x: Num; y: Num }): Vertex => ({\n x: FractionUtil.toFraction(x),\n y: FractionUtil.toFraction(y),\n });\n\n /**\n * Convert to Bounds.\n * @param bounds\n */\n static toBounds = ({ x, y, width, height }: { x: Num; y: Num; width: Num; height: Num }): Bounds => ({\n x: FractionUtil.toFraction(x),\n y: FractionUtil.toFraction(y),\n width: FractionUtil.toFraction(width),\n height: FractionUtil.toFraction(height),\n });\n\n /**\n * Calculate center point.\n * @param bounds\n */\n static center = ({ x, y, width, height }: Bounds): Vertex => {\n const cx = FractionUtil.add(x, FractionUtil.multiply(width, [1, 2]));\n const cy = FractionUtil.add(y, FractionUtil.multiply(height, [1, 2]));\n return { x: cx, y: cy };\n };\n\n /**\n * Calculate centered left edge.\n * @param bounds\n */\n static left = ({ x, y, height }: Bounds): Vertex => {\n const cx = x;\n const cy = FractionUtil.add(y, FractionUtil.multiply(height, [1, 2]));\n return { x: cx, y: cy };\n };\n\n /**\n * Calculate centered right edge.\n * @param bounds\n */\n static right = ({ x, y, width, height }: Bounds): Vertex => {\n const cx = FractionUtil.add(x, width);\n const cy = FractionUtil.add(y, FractionUtil.multiply(height, [1, 2]));\n return { x: cx, y: cy };\n };\n}\n", "//\n// Copyright 2021 DXOS.org\n//\n\nimport { type SVGContext } from '../../hooks';\nimport { EventEmitter } from '../../util';\nimport { type IdAccessor, defaultIdAccessor } from '../types';\n\nexport type ProjectorOptions = {\n idAccessor?: IdAccessor;\n};\n\n/**\n * Update kinds signal what changed since the previous render.\n * - `topology`: nodes/edges added or removed, or per-node attributes may have changed.\n * The renderer should perform a full enter/exit join and re-run attribute callbacks.\n * - `positions`: only `x/y` (and similar transient layout state) changed.\n * The renderer can fast-path: just update transforms and edge geometry.\n */\nexport type ProjectorUpdateKind = 'topology' | 'positions';\n\n/**\n * Generates a layout to be rendered.\n */\nexport abstract class Projector<NodeData, Layout, Options extends ProjectorOptions> {\n public readonly updated = new EventEmitter<{ layout: Layout; kind: ProjectorUpdateKind }>();\n\n private readonly _options: Options;\n\n constructor(\n private readonly _context: SVGContext,\n options?: Partial<Options>,\n ) {\n this._options = Object.assign(\n {\n idAccessor: defaultIdAccessor,\n },\n options,\n ) as Options;\n }\n\n abstract get layout(): Layout;\n\n get context(): SVGContext {\n return this._context;\n }\n\n get options(): Options {\n return this._options;\n }\n\n refresh(dragging = false) {\n this.onRefresh(dragging);\n }\n\n updateData(data?: NodeData) {\n this.onUpdate(data);\n }\n\n emitUpdate(kind: ProjectorUpdateKind = 'topology') {\n this.updated.emit({ layout: this.layout, kind });\n }\n\n async clear() {\n await this.onClear();\n }\n\n async start() {\n await this.onStart();\n }\n\n async stop() {\n await this.onStop();\n }\n\n protected onRefresh(dragging = false): void {}\n protected onUpdate(data?: NodeData): void {}\n protected async onClear(): Promise<void> {}\n protected async onStart(): Promise<void> {}\n protected async onStop(): Promise<void> {}\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Graph, type SelectionModel } from '@dxos/graph';\n\nimport { type SVGContext } from '../../hooks';\nimport { type GraphLayout, type GraphLayoutNode, emptyGraph } from '../types';\nimport { Projector, type ProjectorOptions } from './projector';\n\nexport type GraphProjectorOptions = ProjectorOptions & {};\n\n/**\n * Base class for graph projectors.\n */\nexport abstract class GraphProjector<NodeData = any, Options extends GraphProjectorOptions = any> extends Projector<\n Graph.Any,\n GraphLayout<NodeData>,\n Options\n> {\n private readonly _layout: GraphLayout<NodeData>;\n\n // TODO(burdon): Change to object props.\n constructor(\n context: SVGContext,\n options?: Options,\n private readonly _selection?: SelectionModel,\n layout?: GraphLayout<NodeData>,\n ) {\n super(context, options);\n this._layout = {\n id: (Math.random() * 10).toString().slice(8),\n graph: {\n nodes: [...(layout?.graph.nodes ?? [])],\n edges: [...(layout?.graph.edges ?? [])],\n },\n };\n }\n\n get layout() {\n return this._layout;\n }\n\n get selection() {\n return this._selection;\n }\n\n numChildren(node: GraphLayoutNode) {\n return this._layout.graph.edges.filter((edge) => edge.source.id === this.options.idAccessor(node)).length;\n }\n\n reset() {\n this._layout.graph.nodes = [];\n this._layout.graph.edges = [];\n this.emitUpdate();\n }\n\n /**\n * Merge external data with internal representation (e.g., so force properties like position are preserved).\n * @param data\n */\n protected mergeData(data: Graph.Any = emptyGraph) {\n // Merge nodes.\n const nodes: GraphLayoutNode[] = data.nodes.map((node) => {\n let current: GraphLayoutNode = this._layout.graph.nodes.find((n) => n.id === this.options.idAccessor(node));\n if (!current) {\n current = {\n id: this.options.idAccessor(node),\n };\n }\n\n current.data = node;\n // `hidden` is a transient flag set by the cluster projector to fade\n // collapsed leaves. Reset it on every merge so that (a) switching\n // away from cluster to another projector — which inherits the\n // previous layout via `prev` — doesn't carry forward stale hidden\n // flags, and (b) the cluster projector itself re-applies the flag\n // each `doClusterLayout` pass.\n current.hidden = false;\n return current;\n });\n\n // Replace edges. Preserve `type` so projectors can classify edges by their source\n // semantics (e.g. the plexus projector groups by relation vs ref); projectors that\n // synthesize their own edges (bundle, cluster) overwrite this downstream.\n const edges = data.edges\n .map((edge) => ({\n id: edge.id,\n type: (edge as { type?: string }).type,\n source: nodes.find((n) => n.id === edge.source),\n target: nodes.find((n) => n.id === edge.target),\n data: edge.data,\n }))\n .filter((edge) => edge.source && edge.target);\n\n Object.assign(this._layout, {\n graph: {\n nodes,\n edges,\n },\n });\n }\n\n override async onClear() {\n this.reset();\n }\n\n /**\n * Optional projector-owned click intercept. The Graph component invokes this BEFORE\n * forwarding to the consumer's `onSelect`, so projectors can implement built-in\n * interactions (e.g. cluster collapse) without each consumer wiring them. Returning\n * `true` indicates the click was handled — consumer's `onSelect` is suppressed.\n * Default no-op returns `false` so consumer handlers still run.\n */\n handleNodeClick(_node: GraphLayoutNode<NodeData>, _event: MouseEvent): boolean {\n return false;\n }\n\n abstract findNode(x: number, y: number, radius: number): GraphLayoutNode<NodeData> | undefined;\n}\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport { cluster as d3Cluster, hierarchy, linkRadial } from 'd3';\n\nimport { type Graph } from '@dxos/graph';\nimport { log } from '@dxos/log';\n\nimport { type GraphLayoutEdge, type GraphLayoutNode } from '../types';\nimport { GraphRadialProjector, type GraphRadialProjectorOptions, updateNode } from './graph-radial-projector';\n\nexport type GraphClusterProjectorOptions = GraphRadialProjectorOptions & {\n /** Reserved space around the cluster (screen pixels). */\n margin?: number;\n /** Radius for leaf nodes. Default 4. */\n leafRadius?: number;\n /** Radius for the synthetic group nodes (visible as smaller intermediate dots). Default 3. */\n groupRadius?: number;\n /** Radius for the synthetic root node. Default 5. */\n rootRadius?: number;\n /**\n * Group key for each node — synthetic intermediate nodes are created per unique key,\n * giving a root → group → leaf hierarchy. Return `undefined` to attach the node\n * directly to the root.\n */\n groupOf?: (node: GraphLayoutNode) => string | undefined;\n /** Root id used for the synthetic root node. */\n rootId?: string;\n /** Display label set on the synthetic root node. Renderers read `node.label`. */\n rootLabel?: string;\n /** Optional formatter applied to the `groupOf` key to derive the group's display label.\n * Defaults to the key itself. */\n groupLabel?: (key: string) => string;\n};\n\nconst ROOT_ID = '__cluster_root__';\nconst GROUP_PREFIX = '__group__:';\nconst HIER_EDGE_PREFIX = '__hier__:';\n\n/** Node type tags so consumer renderers can distinguish leaves from synthetic structural nodes. */\nexport const CLUSTER_NODE_TYPE_LEAF = 'leaf';\nexport const CLUSTER_NODE_TYPE_GROUP = 'group';\nexport const CLUSTER_NODE_TYPE_ROOT = 'root';\n\n/**\n * Standard d3 radial link generator — `curveBumpRadial`. Same shape as the original\n * `RadialTree` component (and the d3 radial-cluster observable notebook).\n *\n * IMPORTANT: relies on the `dx-edge path` CSS setting `fill: none`. Without that, the SVG\n * default fill (black) closes the curve across the source-target chord and visually\n * swallows part of the stroke. The Graph engine's `createEdge` doesn't set `fill='none'`\n * inline (unlike the original RadialTree), so the rule lives in graph.css.\n */\nconst linkPath = linkRadial<any, any>()\n .angle((d: any) => d.x)\n .radius((d: any) => d.y);\n\n/**\n * Cartesian → d3-radial polar. d3 measures angle clockwise from \"up\" (the -y direction).\n * Inverse of `[cos(a - π/2) * r, sin(a - π/2) * r]`.\n */\nconst cartesianToPolar = (x: number, y: number): { angle: number; radius: number } => ({\n angle: Math.atan2(x, -y),\n radius: Math.hypot(x, y),\n});\n\n/**\n * Radial cluster (d3.cluster) layout. Materializes a root → group → leaf\n * hierarchy from the `groupOf` callback, runs d3.cluster, and:\n *\n * - Places leaves around the outer ring; synthetic group nodes sit on an\n * inner ring; the root sits at the origin. All three kinds are added to the\n * layout so they render via the consumer's `renderNode` (the `type` field\n * identifies which is which).\n * - Each hierarchy edge carries a `path` string (d3's `linkRadial` curve)\n * computed from CURRENT cartesian endpoint positions every frame via\n * `onTickFrame`. The curve therefore tracks moving endpoints during a\n * cross-variant tween (e.g. force → cluster) instead of snapping to the\n * final polar shape.\n */\nexport class GraphClusterProjector<\n NodeData = any,\n Options extends GraphClusterProjectorOptions = any,\n> extends GraphRadialProjector<NodeData, Options> {\n // Synthetic-node ids (root id, or `${GROUP_PREFIX}${key}`) whose subtree is currently\n // hidden. Clicking the corresponding rendered circle calls toggleCollapsed to flip\n // membership, then re-runs the layout so the renderer's exit transition fades the\n // hidden leaves + hierarchy edges out (and back in on expand).\n readonly #collapsed = new Set<string>();\n\n // Snapshot of the full data-node set as of the last mergeData. doClusterLayout always\n // reads from this rather than `layout.graph.nodes` — the layout view is filtered (it\n // drops hidden leaves so the renderer doesn't see them), so re-reading from there\n // would permanently lose the hidden leaves and they couldn't reappear on expand.\n #dataNodes: GraphLayoutNode<NodeData>[] = [];\n\n /**\n * Built-in click semantics: clicking a synthetic root / group node toggles its subtree.\n * Leaf clicks fall through to the consumer's `onSelect` (returns `false`).\n */\n override handleNodeClick(node: GraphLayoutNode<NodeData>, _event: MouseEvent): boolean {\n if (node.type !== CLUSTER_NODE_TYPE_ROOT && node.type !== CLUSTER_NODE_TYPE_GROUP) {\n return false;\n }\n this.toggleCollapsed(node.id);\n return true;\n }\n\n /** Toggle collapse state for a synthetic node id. Triggers a topology re-emit. */\n toggleCollapsed(id: string): void {\n if (this.#collapsed.has(id)) {\n this.#collapsed.delete(id);\n } else {\n this.#collapsed.add(id);\n }\n // Re-run the layout against the current model data so hidden / re-shown nodes are\n // exited / entered through the renderer's join.\n this.doClusterLayout();\n this.emitUpdate('topology');\n this.animate();\n }\n\n /** Whether a synthetic-node id is currently collapsed. */\n isCollapsed(id: string): boolean {\n return this.#collapsed.has(id);\n }\n\n protected override onUpdate(graph?: Graph.Any) {\n log('onUpdate', { graph: { nodes: graph?.nodes.length, edges: graph?.edges.length } });\n this.mergeData(graph);\n // Snapshot the full data-node set right after mergeData — before doClusterLayout\n // overwrites `layout.graph.nodes` with the filtered (collapse-aware) view.\n this.#dataNodes = [...this.layout.graph.nodes];\n this.doClusterLayout();\n this.emitUpdate('topology');\n this.animate();\n }\n\n /**\n * Recompute each hierarchy edge's `path` from current cartesian source/target positions,\n * so the curves track moving endpoints during a cross-variant tween (e.g. force → cluster)\n * instead of being pinned to the final polar layout.\n */\n protected override onTickFrame(_t: number): void {\n for (const edge of this.layout.graph.edges) {\n if (edge.type !== 'hierarchy') {\n continue;\n }\n const { source, target } = edge;\n const s = cartesianToPolar(source.x ?? 0, source.y ?? 0);\n const t = cartesianToPolar(target.x ?? 0, target.y ?? 0);\n edge.path = linkPath({ source: { x: s.angle, y: s.radius }, target: { x: t.angle, y: t.radius } });\n }\n }\n\n private doClusterLayout() {\n if (!this.context.size) {\n return;\n }\n\n // Read from the post-mergeData snapshot, not from `layout.graph.nodes`. The layout\n // view is a FILTERED projection (hidden leaves are dropped so the renderer's d3 join\n // fades them out); reading from it would shrink monotonically across collapses and\n // hidden leaves could never reappear on expand. The snapshot also avoids the\n // \"synthetic root re-pushed as its own child → d3.hierarchy infinite recursion\" hang\n // we'd otherwise hit, because synthetic stubs were never in this set to begin with.\n const dataNodes = this.#dataNodes;\n if (!dataNodes.length) {\n return;\n }\n\n const groupOf = this.options.groupOf;\n const rootId = this.options.rootId ?? ROOT_ID;\n\n // Synthesize the hierarchy: root → groups → leaves. `groupKey` is carried on synthetic\n // group HierNodes so the rendered stub can pick up the original groupOf return value\n // (the typename, in plugin-explorer's case) as its display label.\n type HierNode = { id: string; parent?: string; node?: GraphLayoutNode<NodeData>; groupKey?: string };\n const items: HierNode[] = [{ id: rootId }];\n const groupIds = new Map<string, string>();\n // Collapsed root → render only the root circle (no groups, no leaves).\n const rootCollapsed = this.#collapsed.has(rootId);\n if (!rootCollapsed) {\n for (const node of dataNodes) {\n const key = groupOf?.(node);\n let parent = rootId;\n if (key !== undefined) {\n let groupId = groupIds.get(key);\n if (!groupId) {\n groupId = `${GROUP_PREFIX}${key}`;\n groupIds.set(key, groupId);\n items.push({ id: groupId, parent: rootId, groupKey: key });\n }\n parent = groupId;\n }\n // Collapsed group → drop its leaves. The group itself still renders so the user\n // can click it again to expand.\n if (this.#collapsed.has(parent)) {\n continue;\n }\n items.push({ id: node.id, parent, node });\n }\n }\n\n const childrenByParent = new Map<string, HierNode[]>();\n for (const item of items) {\n if (item.parent) {\n const list = childrenByParent.get(item.parent) ?? [];\n list.push(item);\n childrenByParent.set(item.parent, list);\n }\n }\n\n const root = hierarchy<HierNode>({ id: rootId }, (d) => childrenByParent.get(d.id) ?? []);\n\n const { width, height } = this.context.size;\n const margin = this.options.margin ?? 80;\n const ringRadius = Math.max(0, Math.min(width, height) / 2 - margin);\n\n d3Cluster<HierNode>()\n .size([2 * Math.PI, ringRadius])\n // Tighter sibling spacing at deeper levels — matches the previous standalone\n // RadialTree component. Without the `/depth` divisor, large groups span a\n // wide angular arc; the linkRadial(curveBumpPolar) curve to a leaf at the\n // edge of that arc then has its control points placed far apart in\n // cartesian, producing a wide swoop that visually misses the target.\n .separation((a: any, b: any) => (a.parent === b.parent ? 1 : 2) / Math.max(1, a.depth))(root);\n\n const leafR = this.options.leafRadius ?? 4;\n const groupR = this.options.groupRadius ?? 3;\n const rootR = this.options.rootRadius ?? 5;\n\n // Index any synthetic root / group stubs from the previous layout pass so we can\n // REUSE them (preserving their current x/y as the tween start) instead of creating\n // fresh `{x:0,y:0}` stubs that would snap the DOM element to the origin first.\n const prevStubsById = new Map<string, GraphLayoutNode<NodeData>>();\n for (const node of this.layout.graph.nodes) {\n if (node.type === CLUSTER_NODE_TYPE_ROOT || node.type === CLUSTER_NODE_TYPE_GROUP) {\n prevStubsById.set(node.id, node);\n }\n }\n\n // Build the new node set: existing data nodes (re-positioned), plus synthetic root + groups.\n const syntheticNodes = new Map<string, GraphLayoutNode<NodeData>>();\n root.each((d: any) => {\n const id = d.data.id;\n const angle = d.x;\n const radius = d.y;\n const x = Math.cos(angle - Math.PI / 2) * radius;\n const y = Math.sin(angle - Math.PI / 2) * radius;\n\n if (d.data.node) {\n // Real leaf — tween its position and mark visible.\n updateNode(d.data.node, [x, y], leafR);\n (d.data.node as any).type = CLUSTER_NODE_TYPE_LEAF;\n (d.data.node as any).hidden = false;\n } else {\n // Synthetic root or group. On the very first cluster mount the stub is brand-new\n // so seed it at origin — root stays put while groups grow outward. On subsequent\n // mounts (toggleCollapsed) we reuse the previous-render stub so its current x/y\n // becomes the tween start; otherwise the DOM element would jump to origin before\n // animating to the new target position.\n const isRoot = id === rootId;\n const stub = prevStubsById.get(id) ?? ({ id, x: 0, y: 0 } as GraphLayoutNode<NodeData>);\n updateNode(stub, [x, y], isRoot ? rootR : groupR);\n stub.type = isRoot ? CLUSTER_NODE_TYPE_ROOT : CLUSTER_NODE_TYPE_GROUP;\n // Surface a display label so renderNode callbacks don't have to parse internal ids.\n if (isRoot) {\n stub.label = this.options.rootLabel;\n } else if (d.data.groupKey !== undefined) {\n stub.label = this.options.groupLabel ? this.options.groupLabel(d.data.groupKey) : d.data.groupKey;\n }\n syntheticNodes.set(id, stub);\n }\n });\n\n // Collapse animation: hidden leaves stay in the layout but their target position is\n // the parent group's target (or root for ungrouped leaves). animate() then tweens them\n // toward the parent — visually \"absorbed in\", while their opacity transitions to 0 via\n // the renderer's hidden-flag transition. On re-expand they tween back out to their ring.\n const visibleLeafIds = new Set<string>();\n for (const item of items) {\n if (item.node) {\n visibleLeafIds.add(item.id);\n }\n }\n for (const node of dataNodes) {\n if (visibleLeafIds.has(node.id)) {\n continue;\n }\n // Hidden leaf — find its parent group's target. groupOf may have changed since the\n // last layout pass (rare in practice but cheap to handle), so re-compute the key.\n const key = groupOf?.(node);\n const parentId = key !== undefined && groupIds.has(key) ? (groupIds.get(key) as string) : rootId;\n const parentStub = syntheticNodes.get(parentId);\n const targetX = (parentStub as any)?.tx ?? 0;\n const targetY = (parentStub as any)?.ty ?? 0;\n updateNode(node, [targetX, targetY], leafR);\n (node as any).type = CLUSTER_NODE_TYPE_LEAF;\n node.hidden = true;\n }\n\n // Compose the rendered node list: synthetic structure first (so leaves draw on top).\n const nextNodes: GraphLayoutNode<NodeData>[] = [];\n for (const stub of syntheticNodes.values()) {\n nextNodes.push(stub);\n }\n for (const node of dataNodes) {\n nextNodes.push(node);\n }\n this.layout.graph.nodes = nextNodes;\n\n // Build hierarchy edges referencing source/target nodes. The `path` is filled by\n // onTickFrame (and again per tween frame) from current cartesian positions, so we\n // don't precompute it here — leaving it undefined would briefly produce a straight\n // line on first paint, but the tween's first tick (t=0) writes the correct path\n // before the renderer's positions-emit reaches the DOM.\n const hierarchyEdges: GraphLayoutEdge<NodeData>[] = [];\n root.links().forEach((link: any) => {\n const sid = link.source.data.id;\n const tid = link.target.data.id;\n const sourceNode = link.source.data.node ?? syntheticNodes.get(sid);\n const targetNode = link.target.data.node ?? syntheticNodes.get(tid);\n hierarchyEdges.push({\n id: `${HIER_EDGE_PREFIX}${sid}->${tid}`,\n type: 'hierarchy',\n source: sourceNode!,\n target: targetNode!,\n data: undefined,\n });\n });\n this.layout.graph.edges = hierarchyEdges;\n // Seed initial paths so the topology emit has correct geometry to enter into the DOM.\n this.onTickFrame(0);\n }\n}\n", "//\n// Copyright 2021 DXOS.org\n//\n\nimport { drag, pointer, select } from 'd3';\n\nimport { type SVGContext } from '../../hooks';\nimport { type Point } from '../../util';\nimport { type GraphLayoutNode } from '../types';\nimport { type GraphProjector } from './graph-projector';\n\nenum Mode {\n MOVE = 0,\n LINK = 1,\n}\n\nexport interface DragOptions<N> {\n dragMod?: string;\n linkMod?: string;\n freezeMod?: string;\n onDrag?: (source?: GraphLayoutNode<N>, target?: GraphLayoutNode<N>, point?: Point) => void;\n onDrop?: (source: GraphLayoutNode<N>, target?: GraphLayoutNode<N>) => void;\n}\n\nconst defaultDragOptions: DragOptions<any> = {\n linkMod: 'metaKey',\n freezeMod: 'shiftKey',\n};\n\n/**\n * Create drag handler.\n */\nexport const createGraphDrag = <NodeData>(\n context: SVGContext,\n projector: GraphProjector<NodeData>,\n options: DragOptions<NodeData> = defaultDragOptions,\n) => {\n let mode: Mode;\n let source: GraphLayoutNode<NodeData>;\n let target: GraphLayoutNode<NodeData> | undefined;\n let offset: Point | undefined;\n let moved = false;\n\n const keyMod = (event: MouseEvent, key: string): boolean => {\n const modKey = options?.[key] ?? defaultDragOptions[key];\n return modKey === undefined || event[modKey];\n };\n\n return drag<SVGElement, GraphLayoutNode<NodeData>>()\n .filter((event: MouseEvent) => !event.ctrlKey)\n .on('start', function (event, d) {\n source = d;\n offset = pointer(event, this.parentElement);\n\n if (options?.onDrop && keyMod(event.sourceEvent, 'linkMod')) {\n mode = Mode.LINK;\n } else if (keyMod(event.sourceEvent, 'dragMod')) {\n mode = Mode.MOVE;\n }\n })\n .on('drag', function (event, d) {\n const parent = this.closest('g.node');\n select(parent).classed('dragging', true).raise();\n\n // Calculate position.\n const [dx, dy] = pointer(event, this.parentElement);\n const x = d.x + dx - offset[0];\n const y = d.y + dy - offset[1];\n const point: Point = [x, y];\n\n switch (mode) {\n case Mode.MOVE: {\n select(context.svg).attr('cursor', 'grabbing');\n\n // Freeze node while dragging.\n event.subject.x = event.subject.fx = point[0];\n event.subject.y = event.subject.fy = point[1];\n projector.refresh(true);\n moved = true;\n break;\n }\n\n case Mode.LINK: {\n // Get drop target.\n if (options?.onDrag) {\n target = projector.findNode(event.x, event.y, 16);\n if (source === target) {\n select(context.svg).attr('cursor', undefined);\n options?.onDrag?.();\n } else {\n select(context.svg).attr('cursor', target ? 'alias' : 'cell');\n options?.onDrag?.(source, target, point);\n }\n }\n }\n }\n })\n .on('end', function (event) {\n select(context.svg).attr('cursor', undefined);\n select(this.parentElement).classed('dragging', false);\n switch (mode) {\n case Mode.LINK: {\n options?.onDrop?.(source, target);\n break;\n }\n }\n\n // Freeze node.\n if (!keyMod(event.sourceEvent, 'freezeMod')) {\n event.subject.fx = null;\n event.subject.fy = null;\n }\n\n mode = undefined;\n source = undefined;\n target = undefined;\n offset = undefined;\n\n if (moved) {\n projector.refresh(false);\n moved = false;\n }\n });\n};\n", "//\n// Copyright 2021 DXOS.org\n//\n\nimport {\n type Force,\n forceCenter,\n forceCollide,\n forceLink,\n forceManyBody,\n forceRadial,\n forceSimulation,\n forceX,\n forceY,\n} from 'd3';\n\nimport { type Graph } from '@dxos/graph';\nimport { log } from '@dxos/log';\n\nimport { type GraphLayoutEdge, type GraphLayoutNode } from '../types';\nimport { forcePoint } from './graph-forces';\nimport { GraphProjector, type GraphProjectorOptions } from './graph-projector';\n\n/**\n * Return value or invoke function.\n * @param valueOrFunction\n * @param invoker\n * @param defaultValue\n */\nconst getValue = <T>(\n valueOrFunction: T | ((...args: any[]) => T) | undefined,\n invoker: (fn: (...args: any[]) => T) => T,\n defaultValue: T,\n) => {\n return (\n (typeof valueOrFunction === 'function' ? invoker(valueOrFunction as (...args: any[]) => T) : valueOrFunction) ??\n defaultValue\n );\n};\n\n/**\n * Returns the config object or an empty object if the property is set to true (or defaults to true).\n * Otherwise returns undefined.\n * @param options\n * @param cb\n * @param defaultValue\n */\nconst maybeForce = <Config>(\n options: Config | boolean,\n cb: (config: Config) => Force<any, any>,\n defaultValue = undefined,\n) => {\n const value = typeof options === 'boolean' ? (options ? {} : undefined) : (options ?? defaultValue);\n if (value) {\n return cb(value);\n }\n};\n\n//\n// Forces\n// TODO(burdon): Provide utils for function properties (e.g., count edges).\n//\n\n/**\n * https://github.com/d3/d3-force#forceLink\n */\nexport type ForceLinkOptions = {\n // Default: edge => 1 / Math.min(2, count(edge.source), count(edge.target))\n strength?: number | ((edge: GraphLayoutEdge<any>) => number);\n distance?: number;\n iterations?: number;\n};\n\n/**\n * https://github.com/d3/d3-force#forceManyBody\n */\nexport type ForceManyBodyOptions = {\n strength?: number | ((node: GraphLayoutNode<any>) => number);\n distanceMax?: number;\n};\n\n/**\n * https://github.com/d3/d3-force#centering\n */\nexport type ForceCenterOptions = {\n x?: number;\n y?: number;\n strength?: number;\n};\n\n/**\n * https://github.com/d3/d3-force#forceCollide\n */\nexport type ForceCollideOptions = {\n radius?: number;\n strength?: number;\n};\n\n/**\n * https://github.com/d3/d3-force#forceRadial\n */\nexport type ForceRadialOptions = {\n delay?: number;\n x?: number;\n y?: number;\n radius?: number;\n strength?: number;\n};\n\n/**\n * https://github.com/d3/d3-force#positioning\n */\nexport type ForcePositioningOptions = {\n x?: number;\n y?: number;\n strength?: number;\n};\n\n/**\n * All force options.\n * NOTE: A value of `true` enables the force with the default option.\n */\n// TODO(burdon): Options for alpha, etc.\n// TODO(burdon): Change to map of forces by type (i.e., support multiple forces of the same type).\nexport type ForceOptions = {\n link?: boolean | ForceLinkOptions;\n manyBody?: boolean | ForceManyBodyOptions;\n center?: boolean | ForceCenterOptions;\n collide?: boolean | ForceCollideOptions;\n radial?: boolean | ForceRadialOptions;\n point?: boolean | ForcePositioningOptions;\n x?: boolean | ForcePositioningOptions;\n y?: boolean | ForcePositioningOptions;\n};\n\nexport const defaultForceOptions: ForceOptions = {\n link: true,\n manyBody: true,\n // center: true,\n point: true,\n};\n\nexport type GraphForceProjectorOptions = GraphProjectorOptions & {\n guides?: boolean;\n forces?: ForceOptions;\n radius?: number;\n attributes?: {\n radius?: number | ((node: GraphLayoutNode<any>, children: number) => number);\n linkForce?: boolean | ((edge: GraphLayoutEdge<any>) => boolean);\n };\n};\n\n/**\n * D3 force directed graph layout using d3 simulation..\n */\n// TODO(burdon): Rename ForceGraphProjector.\nexport class GraphForceProjector<NodeData = any> extends GraphProjector<NodeData, GraphForceProjectorOptions> {\n // https://github.com/d3/d3-force\n private _simulation = forceSimulation<GraphLayoutNode, GraphLayoutEdge>();\n\n private _timeout?: NodeJS.Timeout;\n\n get forces() {\n return this.options.forces ?? defaultForceOptions;\n }\n\n get simulation() {\n return this._simulation;\n }\n\n restart() {\n this._simulation.alpha(1).restart();\n }\n\n override findNode(x: number, y: number, radius: number): GraphLayoutNode<NodeData> | undefined {\n return this._simulation.find(x, y, radius);\n }\n\n override async onStart() {\n clearTimeout(this._timeout);\n let propagating = true;\n\n // Delay radial force until other forces have settled.\n const { radial, ...forces } = this.forces;\n const delay = typeof radial === 'object' ? radial.delay : undefined;\n if (delay) {\n propagating = false;\n this.updateForces(forces);\n this._timeout = setTimeout(() => {\n this.updateForces(this.forces);\n this.restart();\n this._timeout = setTimeout(() => {\n propagating = true;\n }, delay);\n }, delay);\n } else {\n this.updateForces(this.forces);\n }\n\n this._simulation\n // Each tick only mutates `x/y` — emit 'positions' so the renderer can fast-path.\n .on('tick', () => propagating && this.emitUpdate('positions'))\n .velocityDecay(0.3)\n .alphaDecay(1 - Math.pow(0.001, 1 / 300))\n .alpha(1)\n .restart();\n }\n\n override async onStop() {\n clearTimeout(this._timeout);\n this._simulation.stop();\n }\n\n override onRefresh(dragging = false) {\n // Disable centering force while dragging.\n if (this.forces.center) {\n if (dragging) {\n this._simulation.force('center', null);\n } else {\n this.updateForces(this.forces);\n }\n }\n\n this.restart();\n }\n\n override onUpdate(graph?: Graph.Any): void {\n log('onUpdate', { graph: { nodes: graph?.nodes.length, edges: graph?.edges.length } });\n this._simulation.stop();\n this.mergeData(graph);\n this.updateLayout();\n this.updateForces(this.forces);\n // Signal topology change so the renderer rebinds enter/exit and runs attribute callbacks once.\n // Subsequent ticks emit 'positions' and skip the expensive path.\n this.emitUpdate('topology');\n this.restart();\n }\n\n private updateLayout() {\n // Guides.\n this.layout.guides = this.options.guides\n ? [\n {\n id: 'g-1',\n type: 'circle',\n cx: 0,\n cy: 0,\n r: this.context.scale.model.toValue([10, 1]),\n },\n ]\n : undefined;\n\n // Initialize nodes.\n this.layout.graph.nodes.forEach((node) => {\n if (!node.initialized) {\n // Get starting point from linked element.\n // const edge = this.layout.graph.edges.find((edge) => edge.target.id === this.options.idAccessor(node));\n const a = 2 * Math.PI * Math.random();\n const r = this.options.radius ?? 200;\n\n // Initial positions.\n Object.assign(node, {\n initialized: true,\n\n // TODO(burdon): Only when new nodes added to initial layout.\n // Position around center or parent; must have delta to avoid spike.\n // x: edge?.source?.x ?? Math.cos(a) * r,\n // y: edge?.source?.y ?? Math.sin(a) * r,\n x: Math.cos(a) * r,\n y: Math.sin(a) * r,\n });\n }\n\n // TODO(burdon): Ignored by renderer?\n Object.assign(node, {\n r: getValue<number>(this.options?.attributes?.radius, (fn) => fn(node, this.numChildren(node)), 6),\n });\n });\n\n // Initialize edges.\n this.layout.graph.edges.forEach((edge) => {\n Object.assign(edge, {\n linkForce: getValue<boolean>(this.options.attributes?.linkForce, (fn) => fn(edge), true),\n });\n });\n }\n\n /**\n * Update all forces.\n */\n private updateForces(forces: ForceOptions): void {\n log('updateForces', { forces });\n\n // https://github.com/d3/d3-force#simulation_force\n this._simulation\n\n // Nodes\n // https://github.com/d3/d3-force#simulation_nodes\n .nodes(this.layout.graph.nodes)\n\n // Links.\n // https://github.com/d3/d3-force#forceLink\n .force(\n 'link',\n maybeForce<ForceLinkOptions>(\n forces?.link,\n (config) => {\n const force = forceLink()\n .id((d: GraphLayoutNode) => d.id)\n .links(this.layout.graph.edges.filter((edge) => edge.linkForce));\n if (config.distance != null) {\n force.distance(config.distance);\n }\n if (config.strength != null) {\n force.strength(config.strength);\n }\n if (config.iterations != null) {\n force.iterations(config.iterations);\n }\n return force;\n },\n forces?.link === false ? undefined : {},\n ),\n )\n\n // Repulsion.\n // https://github.com/d3/d3-force#forceManyBody\n .force(\n 'manyBody',\n maybeForce<ForceManyBodyOptions>(\n forces?.manyBody,\n (config) => {\n const force = forceManyBody();\n if (config.distanceMax != null) {\n force.distanceMax(config.distanceMax);\n }\n if (config.strength != null) {\n force.strength(config.strength);\n }\n return force;\n },\n forces?.manyBody === false ? undefined : {},\n ),\n )\n\n // Collision.\n // https://github.com/d3/d3-force#forceCollide\n .force(\n 'collide',\n maybeForce<ForceCollideOptions>(forces?.collide, (config) => {\n const force = forceCollide();\n force.radius(config.radius ?? 8);\n if (config.strength != null) {\n force.strength(config.strength);\n }\n return force;\n }),\n )\n\n // Radial.\n // https://github.com/d3/d3-force#forceRadial\n .force(\n 'radial',\n maybeForce<ForceRadialOptions>(forces?.radial, (config) => {\n const force = forceRadial(config.radius ?? 100, config.x ?? 0, config.y ?? 0);\n if (config.strength != null) {\n force.strength(config.strength);\n }\n return force;\n }),\n )\n\n // Centering.\n // NOTE: This moves all nodes such that the center of mass is at the origin.\n // It is different from the positional force which attracts nodes to a point.\n // https://github.com/d3/d3-force#centering\n .force(\n 'center',\n maybeForce<ForceCenterOptions>(forces?.center, (config) => {\n const force = forceCenter()\n .x(config.x ?? 0)\n .y(config.y ?? 0);\n if (config.strength != null) {\n force.strength(config.strength);\n }\n return force;\n }),\n )\n\n // Positioning.\n // https://github.com/d3/d3-force#forcePoint\n .force(\n 'point',\n maybeForce<ForcePositioningOptions>(forces?.point, ({ x = 0, y = 0, strength }) => {\n return forcePoint({ x, y, strength });\n }),\n )\n .force(\n 'x',\n maybeForce<ForcePositioningOptions>(forces?.x, (config: ForcePositioningOptions) => {\n const force = forceX(config.x ?? 0);\n if (config.strength != null) {\n force.strength(config.strength);\n }\n return force;\n }),\n )\n .force(\n 'y',\n maybeForce<ForcePositioningOptions>(forces?.y, (config: ForcePositioningOptions) => {\n const force = forceY(config.y ?? 0);\n if (config.strength != null) {\n force.strength(config.strength);\n }\n return force;\n }),\n );\n }\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Force, type SimulationLinkDatum, type SimulationNodeDatum, forceX, forceY } from 'd3';\n\nexport type ForcePointOptions = {\n x?: number;\n y?: number;\n strength?: number;\n};\n\nexport const forcePoint = <\n NodeDatum extends SimulationNodeDatum,\n LinkDatum extends SimulationLinkDatum<NodeDatum> | undefined,\n>({\n x,\n y,\n strength = 0.01,\n}: ForcePointOptions): Force<NodeDatum, LinkDatum> => {\n const fx = x != null ? forceX(x).strength(strength) : undefined;\n const fy = y != null ? forceY(y).strength(strength) : undefined;\n\n const force = (alpha: number) => {\n fx?.(alpha);\n fy?.(alpha);\n };\n\n force.initialize = (nodes: any[], random: () => number) => {\n fx?.initialize(nodes, random);\n fy?.initialize(nodes, random);\n };\n\n return force;\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Graph } from '@dxos/graph';\nimport { log } from '@dxos/log';\n\nimport { type GraphLayoutNode } from '../types';\nimport { type GraphProjectorOptions } from './graph-projector';\nimport { GraphRadialProjector, layoutRadial, updateNode } from './graph-radial-projector';\n\nexport type GraphHierarchicalProjectorOptions = GraphProjectorOptions & {\n radius?: number;\n margin?: number;\n duration?: number;\n};\n\nexport class GraphHierarchicalProjector<\n NodeData = any,\n Options extends GraphHierarchicalProjectorOptions = any,\n> extends GraphRadialProjector<NodeData, Options> {\n protected override onUpdate(graph?: Graph.Any) {\n log('onUpdate', {\n graph: { nodes: graph?.nodes.length, edges: graph?.edges.length },\n selection: this.selection?.getSelectedIds(),\n });\n\n this.mergeData(graph);\n this.emitUpdate('topology');\n const selected = this.selection?.getSelectedIds()[0];\n if (selected) {\n const node = this.layout.graph.nodes.find((node) => node.id === selected);\n if (node) {\n this.doHierarchicalLayout(node);\n return;\n }\n }\n\n this.doRadialLayout();\n }\n\n protected doHierarchicalLayout(selected: GraphLayoutNode) {\n if (!this.context.size) {\n return;\n }\n\n const r2 =\n this.options.radius ??\n Math.min(this.context.size.width, this.context.size.height) / 2 - (this.options.margin ?? 80);\n const r1 = r2 / 2;\n\n const children = this.layout.graph.edges\n .filter((edge) => edge.source.id === selected.id)\n .map((edge) => edge.target);\n\n // Root.\n updateNode(selected, [0, 0], 20);\n\n // Inner.\n {\n const radial = layoutRadial(0, 0, r1, children.length);\n children.forEach((node, i) => {\n const [tx, ty] = radial(i);\n updateNode(node, [tx, ty]);\n });\n }\n\n // Outer.\n {\n const radial = layoutRadial(0, 0, r2, this.layout.graph.nodes.length - 1 - children.length);\n this.layout.graph.nodes\n .filter((node) => node.id !== selected.id && !children.includes(node))\n .forEach((node, i) => {\n const [tx, ty] = radial(i);\n updateNode(node, [tx, ty]);\n });\n }\n\n this.animate();\n }\n}\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport { type Graph } from '@dxos/graph';\nimport { log } from '@dxos/log';\n\nimport { type GraphLayoutNode } from '../types';\nimport { GraphRadialProjector, type GraphRadialProjectorOptions, updateNode } from './graph-radial-projector';\n\nexport type GraphLatticeProjectorOptions = GraphRadialProjectorOptions & {\n /** Reserved space around the lattice (screen pixels). */\n margin?: number;\n /** Node radius used by `renderNode` consumers. Defaults to the force-graph default (6) so animations across variants don't resize nodes. */\n radius?: number;\n /** Sort key for cells; defaults to the node label / id. Same-typename nodes naturally cluster. */\n sortBy?: (node: GraphLayoutNode) => string;\n};\n\n/**\n * Lays out nodes as a square-as-possible grid that fits the container.\n * Extends `GraphRadialProjector` to inherit the tween (`updateNode` + `animate`),\n * so switching to / from this layout animates each node from its current\n * position to the grid cell — and the initial mount can also \"grow\" from\n * existing positions if seeded with a prior projector's layout.\n */\nexport class GraphLatticeProjector<\n NodeData = any,\n Options extends GraphLatticeProjectorOptions = any,\n> extends GraphRadialProjector<NodeData, Options> {\n protected override onUpdate(graph?: Graph.Any) {\n log('onUpdate', { graph: { nodes: graph?.nodes.length, edges: graph?.edges.length } });\n this.mergeData(graph);\n // Compute layout (assigns sx/sy/tx/ty + initial x/y) BEFORE emitting topology so the\n // renderer's first render uses meaningful positions. animate() then tweens to target.\n this.doLatticeLayout();\n this.emitUpdate('topology');\n this.animate();\n }\n\n private doLatticeLayout() {\n if (!this.context.size) {\n return;\n }\n\n const nodes = this.layout.graph.nodes;\n const count = nodes.length;\n if (!count) {\n return;\n }\n\n const sortBy = this.options.sortBy ?? ((n: GraphLayoutNode) => (n.data as any)?.label ?? n.id);\n nodes.sort((a, b) => sortBy(a).localeCompare(sortBy(b)));\n\n // Columns ≈ √N so the grid stays as square as possible.\n const columns = Math.max(1, Math.ceil(Math.sqrt(count)));\n const rows = Math.ceil(count / columns);\n\n const margin = this.options.margin ?? 16;\n const { width, height } = this.context.size;\n const innerW = Math.max(0, width - 2 * margin);\n const innerH = Math.max(0, height - 2 * margin);\n // Default radius matches the force-graph default (6) so cross-variant animations\n // tween position only, not size. Consumers can pass a smaller `radius` for a\n // denser matrix look.\n const r = this.options.radius ?? 6;\n // Cell size sets the spacing between nodes. Cap at a small multiple of `r`\n // so the lattice stays tight rather than ballooning to fill the container;\n // wide enough that edges crossing between non-adjacent cells remain visible\n // in the gaps between nodes.\n const fit = Math.min(innerW / columns, innerH / rows);\n const cellSize = Math.max(0, Math.min(fit, r * 6));\n\n // Center the lattice (SVG viewBox is centered at origin in `<SVG.Root>`).\n const gridW = cellSize * columns;\n const gridH = cellSize * rows;\n const offsetX = -gridW / 2 + cellSize / 2;\n const offsetY = -gridH / 2 + cellSize / 2;\n\n nodes.forEach((node, i) => {\n const tx = offsetX + (i % columns) * cellSize;\n const ty = offsetY + Math.floor(i / columns) * cellSize;\n updateNode(node, [tx, ty], r);\n });\n }\n}\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport { cluster as d3Cluster, hierarchy, linkRadial } from 'd3';\n\nimport { type Graph } from '@dxos/graph';\nimport { log } from '@dxos/log';\n\nimport { type GraphLayoutEdge, type GraphLayoutNode } from '../types';\nimport {\n GraphRadialProjector,\n type GraphRadialProjectorOptions,\n layoutRadial,\n updateNode,\n} from './graph-radial-projector';\n\n/** Display info for a relation group. */\nexport type PlexusRelation = {\n /** Stable grouping key — edges sharing a key fan out from the same relation node. */\n key: string;\n /** Human-readable label rendered on the relation node. */\n label: string;\n};\n\nexport type GraphPlexusProjectorOptions = GraphRadialProjectorOptions & {\n /** Id of the focused node placed at the centre. When unset the layout falls back to a plain ring. */\n focus?: string;\n /** Reserved space around the outer ring (screen pixels). Default 100. */\n margin?: number;\n /** Radius for object leaf nodes — the base size shared by all non-focus nodes. Default 5. */\n leafRadius?: number;\n /** Radius for the synthetic relation nodes. Defaults to the leaf radius. */\n relationRadius?: number;\n /** Radius for the focused centre node. Defaults to double the leaf radius. */\n focusRadius?: number;\n /**\n * Classify an edge incident to the focus into a relation group. Return `undefined` to\n * ignore the edge (e.g. when the focus is not one of the edge's endpoints). The neighbour\n * placed under the relation is the edge endpoint that is NOT the focus, so both sides of a\n * relation are supported: classify outgoing edges (focus is source) and incoming edges\n * (focus is target) under different keys to get a separate relation node for each side.\n * Mirrors the `groupOf` callback used by the cluster / bundle projectors — all ECHO\n * knowledge stays in the consumer.\n */\n relationOf?: (edge: GraphLayoutEdge, focusId: string) => PlexusRelation | undefined;\n};\n\nconst RELATION_PREFIX = '__plexus_relation__:';\nconst HIER_EDGE_PREFIX = '__plexus_hier__:';\n\n/** Node type tags so consumer renderers can distinguish the three kinds of node. */\nexport const PLEXUS_NODE_TYPE_FOCUS = 'plexus-focus';\nexport const PLEXUS_NODE_TYPE_RELATION = 'plexus-relation';\nexport const PLEXUS_NODE_TYPE_OBJECT = 'plexus-object';\n\n/**\n * Standard d3 radial link generator — `curveBumpRadial` (same as the cluster projector).\n * Relies on `dx-edge path { fill: none }` from graph.css.\n */\nconst linkPath = linkRadial<any, any>()\n .angle((d: any) => d.x)\n .radius((d: any) => d.y);\n\n/**\n * Cartesian → d3-radial polar. d3 measures angle clockwise from \"up\" (the -y direction).\n * Inverse of `[cos(a - π/2) * r, sin(a - π/2) * r]`.\n */\nconst cartesianToPolar = (x: number, y: number): { angle: number; radius: number } => ({\n angle: Math.atan2(x, -y),\n radius: Math.hypot(x, y),\n});\n\n/**\n * Focus-centric radial layout. A single focused object sits at the centre; its immediate\n * neighbourhood fans out around it, grouped by the relation that connects each neighbour\n * to the focus:\n *\n * - **Focus** (depth 0) — the focused data node, at the origin.\n * - **Relation nodes** (depth 1) — synthetic group nodes (one per `relationOf` key) on an\n * inner ring.\n * - **Object nodes** (depth 2) — the neighbours reached through each relation, on the\n * outer ring.\n *\n * Built on the same `d3.cluster` machinery as `GraphClusterProjector`: the synthesized\n * `focus → relation → object` hierarchy is laid out radially and each hierarchy edge gets\n * a `linkRadial` `path` recomputed from current cartesian endpoints every tick, so curves\n * track moving nodes during a cross-focus (or cross-variant) tween.\n *\n * Focus itself is owned by the consumer (passed via `options.focus`); re-focusing is a\n * matter of recreating the projector with the new focus and the previous layout as `prev`,\n * which makes persistent nodes animate into their new positions.\n */\nexport class GraphPlexusProjector<\n NodeData = any,\n Options extends GraphPlexusProjectorOptions = any,\n> extends GraphRadialProjector<NodeData, Options> {\n // Full node / edge snapshots taken right after mergeData — doPlexusLayout reads from\n // these because it overwrites layout.graph with the filtered focus-centric view.\n #dataNodes: GraphLayoutNode<NodeData>[] = [];\n #dataEdges: GraphLayoutEdge<NodeData>[] = [];\n\n protected override onUpdate(graph?: Graph.Any) {\n log('onUpdate', { graph: { nodes: graph?.nodes.length, edges: graph?.edges.length } });\n this.mergeData(graph);\n this.#dataNodes = [...this.layout.graph.nodes];\n this.#dataEdges = [...this.layout.graph.edges];\n this.doPlexusLayout();\n this.emitUpdate('topology');\n this.animate();\n }\n\n /**\n * Recompute each hierarchy edge's `path` from current cartesian endpoints so curves track\n * moving nodes during the tween (identical strategy to the cluster projector).\n */\n protected override onTickFrame(_t: number): void {\n for (const edge of this.layout.graph.edges) {\n if (edge.type !== 'hierarchy') {\n continue;\n }\n const { source, target } = edge;\n const s = cartesianToPolar(source.x ?? 0, source.y ?? 0);\n const t = cartesianToPolar(target.x ?? 0, target.y ?? 0);\n edge.path = linkPath({ source: { x: s.angle, y: s.radius }, target: { x: t.angle, y: t.radius } });\n }\n }\n\n private doPlexusLayout() {\n if (!this.context.size) {\n return;\n }\n\n const dataNodes = this.#dataNodes;\n if (!dataNodes.length) {\n return;\n }\n\n const focusId = this.options.focus;\n const focusNode = focusId ? dataNodes.find((node) => node.id === focusId) : undefined;\n\n // No focus (or it dropped out of the graph): degrade to a plain ring of all nodes so the\n // surface is never blank. In practice the consumer dispatches to the bundle projector\n // when there is no focus, so this is just a safety net.\n if (!focusNode) {\n const radial = layoutRadial(\n 0,\n 0,\n Math.min(this.context.size.width, this.context.size.height) / 2 - (this.options.margin ?? 100),\n dataNodes.length,\n );\n dataNodes.forEach((node, index) => updateNode(node, radial(index), this.options.leafRadius ?? 5));\n this.layout.graph.nodes = dataNodes;\n this.layout.graph.edges = [];\n this.animate();\n return;\n }\n\n const relationOf = this.options.relationOf ?? defaultRelationOf;\n\n // Group neighbours by relation. A neighbour reachable through more than one relation is\n // placed once (first relation wins) — keeps hierarchy ids unique for v1.\n type Group = { id: string; label: string; leaves: GraphLayoutNode<NodeData>[] };\n const groups = new Map<string, Group>();\n const placed = new Set<string>([focusId!]);\n for (const edge of this.#dataEdges) {\n const relation = relationOf(edge, focusId!);\n if (!relation) {\n continue;\n }\n const neighbour = edge.source.id === focusId ? edge.target : edge.source;\n if (placed.has(neighbour.id)) {\n continue;\n }\n placed.add(neighbour.id);\n let group = groups.get(relation.key);\n if (!group) {\n group = { id: `${RELATION_PREFIX}${relation.key}`, label: relation.label, leaves: [] };\n groups.set(relation.key, group);\n }\n group.leaves.push(neighbour);\n }\n\n // Synthesize the focus → relation → object hierarchy.\n type HierNode = {\n id: string;\n parent?: string;\n node?: GraphLayoutNode<NodeData>;\n relationLabel?: string;\n };\n const items: HierNode[] = [{ id: focusId!, node: focusNode }];\n for (const group of groups.values()) {\n items.push({ id: group.id, parent: focusId, relationLabel: group.label });\n for (const leaf of group.leaves) {\n items.push({ id: leaf.id, parent: group.id, node: leaf });\n }\n }\n\n const childrenByParent = new Map<string, HierNode[]>();\n for (const item of items) {\n if (item.parent) {\n const list = childrenByParent.get(item.parent) ?? [];\n list.push(item);\n childrenByParent.set(item.parent, list);\n }\n }\n\n const root = hierarchy<HierNode>({ id: focusId!, node: focusNode }, (d) => childrenByParent.get(d.id) ?? []);\n\n const { width, height } = this.context.size;\n const margin = this.options.margin ?? 100;\n const ringRadius = Math.max(0, Math.min(width, height) / 2 - margin);\n\n d3Cluster<HierNode>()\n .size([2 * Math.PI, ringRadius])\n .separation((a: any, b: any) => (a.parent === b.parent ? 1 : 2) / Math.max(1, a.depth))(root);\n\n // All non-focus nodes share the leaf radius; the focus is double.\n const leafR = this.options.leafRadius ?? 5;\n const relationR = this.options.relationRadius ?? leafR;\n const focusR = this.options.focusRadius ?? leafR * 2;\n\n // Reuse synthetic relation stubs from the previous pass so their current x/y becomes the\n // tween start instead of snapping to the origin first.\n const prevStubsById = new Map<string, GraphLayoutNode<NodeData>>();\n for (const node of this.layout.graph.nodes) {\n if (node.type === PLEXUS_NODE_TYPE_RELATION) {\n prevStubsById.set(node.id, node);\n }\n }\n\n const relationStubs = new Map<string, GraphLayoutNode<NodeData>>();\n root.each((d: any) => {\n const angle = d.x;\n const radius = d.y;\n const x = Math.cos(angle - Math.PI / 2) * radius;\n const y = Math.sin(angle - Math.PI / 2) * radius;\n const id = d.data.id;\n\n if (id === focusId) {\n // Real focus node at the centre.\n updateNode(focusNode, [x, y], focusR);\n (focusNode as any).type = PLEXUS_NODE_TYPE_FOCUS;\n focusNode.hidden = false;\n } else if (d.data.node) {\n // Real object leaf.\n updateNode(d.data.node, [x, y], leafR);\n (d.data.node as any).type = PLEXUS_NODE_TYPE_OBJECT;\n d.data.node.hidden = false;\n } else {\n // Synthetic relation node.\n const stub = prevStubsById.get(id) ?? ({ id, x: 0, y: 0 } as GraphLayoutNode<NodeData>);\n updateNode(stub, [x, y], relationR);\n stub.type = PLEXUS_NODE_TYPE_RELATION;\n stub.label = d.data.relationLabel;\n relationStubs.set(id, stub);\n }\n });\n\n // Compose the rendered node list: relations first, then leaves, focus last (drawn on top).\n const nextNodes: GraphLayoutNode<NodeData>[] = [];\n for (const stub of relationStubs.values()) {\n nextNodes.push(stub);\n }\n for (const group of groups.values()) {\n for (const leaf of group.leaves) {\n nextNodes.push(leaf);\n }\n }\n nextNodes.push(focusNode);\n this.layout.graph.nodes = nextNodes;\n\n // Build hierarchy edges (focus → relation, relation → object). Paths are filled by\n // onTickFrame from current cartesian positions.\n const edges: GraphLayoutEdge<NodeData>[] = [];\n root.links().forEach((link: any) => {\n const sid = link.source.data.id;\n const tid = link.target.data.id;\n const sourceNode = sid === focusId ? focusNode : (link.source.data.node ?? relationStubs.get(sid));\n const targetNode = link.target.data.node ?? relationStubs.get(tid);\n if (!sourceNode || !targetNode) {\n return;\n }\n edges.push({\n id: `${HIER_EDGE_PREFIX}${sid}->${tid}`,\n type: 'hierarchy',\n source: sourceNode,\n target: targetNode,\n data: undefined,\n });\n });\n this.layout.graph.edges = edges;\n\n // Seed initial paths so the topology emit has correct geometry to enter into the DOM.\n this.onTickFrame(0);\n }\n}\n\n/** Fallback grouping: every edge incident to the focus becomes a relation keyed by edge type + direction. */\nconst defaultRelationOf = (edge: GraphLayoutEdge, focusId: string): PlexusRelation | undefined => {\n const outgoing = edge.source.id === focusId;\n const incoming = edge.target.id === focusId;\n if (!outgoing && !incoming) {\n return undefined;\n }\n const type = edge.type ?? 'edge';\n const arrow = outgoing ? '→' : '←';\n return { key: `${type}:${outgoing ? 'out' : 'in'}`, label: `${type} ${arrow}` };\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Graph } from '@dxos/graph';\nimport { log } from '@dxos/log';\n\nimport { type GraphLayoutNode } from '../types';\nimport { type GraphProjectorOptions } from './graph-projector';\nimport { GraphRadialProjector, layoutHorizontal, layoutRadial, updateNode } from './graph-radial-projector';\n\nexport type GraphRelationalProjectorOptions = GraphProjectorOptions & {\n radius?: number;\n margin?: number;\n duration?: number;\n};\n\nexport class GraphRelationalProjector<\n NodeData = any,\n Options extends GraphRelationalProjectorOptions = any,\n> extends GraphRadialProjector<NodeData, Options> {\n protected override onUpdate(graph?: Graph.Any) {\n log('onUpdate', {\n graph: { nodes: graph?.nodes.length, edges: graph?.edges.length },\n selection: this.selection?.getSelectedIds(),\n });\n\n this.mergeData(graph);\n this.emitUpdate('topology');\n const selected = this.selection?.getSelectedIds()[0];\n if (selected) {\n const node = this.layout.graph.nodes.find((node) => node.id === selected);\n if (node) {\n this.doRelationalLayout(node);\n return;\n }\n }\n\n this.doRadialLayout();\n }\n\n protected doRelationalLayout(selected: GraphLayoutNode) {\n if (!this.context.size) {\n return;\n }\n\n // TODO(burdon): Generate edge types.\n const r2 =\n this.options.radius ??\n Math.min(this.context.size.width, this.context.size.height) / 2 - (this.options.margin ?? 80);\n const r1 = r2 * 0.5;\n\n this.layout.graph.nodes.forEach((node) => (node.type = undefined));\n this.layout.graph.edges.forEach((edge) => {\n edge.order = 0;\n edge.type = undefined;\n });\n\n const children = this.layout.graph.edges\n .filter((edge) => edge.source.id === selected.id)\n .map((edge) => {\n edge.order = 1;\n edge.type = '1';\n edge.target.type = '1';\n return edge.target;\n });\n\n const parents = this.layout.graph.edges\n .filter((edge) => edge.target.id === selected.id)\n .map((edge) => {\n edge.order = 2;\n edge.type = '2';\n edge.source.type = '2';\n return edge.source;\n });\n\n // Root.\n updateNode(selected, [0, 0], 30);\n\n // Children.\n {\n const vertical = layoutHorizontal(0, r1, r1 * 2, children.length);\n children.forEach((node, i) => {\n const [tx, ty] = vertical(i);\n updateNode(node, [tx, ty], 20);\n });\n }\n\n // Parents.\n {\n const vertical = layoutHorizontal(0, -r1, r1, parents.length);\n parents.forEach((node, i) => {\n const [tx, ty] = vertical(i);\n updateNode(node, [tx, ty], 20);\n });\n }\n\n // Outer.\n {\n const radial = layoutRadial(0, 0, r2, this.layout.graph.nodes.length - 1 - children.length - parents.length);\n this.layout.graph.nodes\n .filter((node) => node.id !== selected.id && !children.includes(node) && !parents.includes(node))\n .forEach((node, i) => {\n const [tx, ty] = radial(i);\n updateNode(node, [tx, ty]);\n });\n }\n\n this.animate();\n }\n}\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport { type Timer, timer } from 'd3';\n\nimport { type Graph } from '@dxos/graph';\nimport { log } from '@dxos/log';\n\nimport { type GraphLayoutNode } from '../types';\nimport { GraphProjector, type GraphProjectorOptions } from './graph-projector';\n\n// Boids swarming simulation rendered through the react-ui-graph SVG renderer.\n// Mirrors the canvas Swarm component's tick (alignment / cohesion / separation)\n// but mutates `x/y` on `GraphLayoutNode` instances directly and emits 'positions'\n// each frame so `GraphRenderer.applyPositions` can fast-path SVG transforms,\n// exactly like `GraphForceProjector`.\n//\n// https://en.wikipedia.org/wiki/Boids\n\nconst SWARMMATE_RADIUS = 60;\nconst SEPARATION_DISTANCE = 30;\n\n/** Per-frame state stored on a layout node by the projector. */\nexport type SwarmNode = GraphLayoutNode & {\n vx?: number;\n vy?: number;\n ax?: number;\n ay?: number;\n /**\n * Shallow ring buffer of recent absolute positions (oldest first). One position is\n * pushed per tick BEFORE integration, so after a tick the most recent entry is the\n * pre-tick position. Cleared whenever the boid wraps a viewBox edge so the trail\n * doesn't streak across the canvas.\n */\n history?: Array<{ x: number; y: number }>;\n};\n\nexport type GraphSwarmProjectorOptions = GraphProjectorOptions & {\n /** Initial spread (px) of new boids around the origin. */\n spawnRadius?: number;\n /** Hard cap on per-tick velocity. */\n maxVelocity?: number;\n /** Per-force weights — match Swarm's normalisation (divided by 100 on apply). */\n alignment?: number;\n cohesion?: number;\n separation?: number;\n /** Pixel radius (in SVG model coords) of the invisible repel zone tracking the pointer. 0 disables. */\n cursorRepel?: number;\n /** Avoidance force weight (divided by 10 on apply, matching canvas Swarm). */\n avoidance?: number;\n /**\n * Number of previous positions retained per boid (one per simulation tick). The visible\n * tail spans roughly `trailLength * maxVelocity` pixels — at 60 fps a value of 30 is\n * about a half-second streak. Dense per-tick sampling avoids the \"snap\" artifact a\n * coarser sample interval introduces when only the head moves between samples.\n */\n trailLength?: number;\n};\n\nconst DEFAULTS: Required<\n Pick<\n GraphSwarmProjectorOptions,\n | 'spawnRadius'\n | 'maxVelocity'\n | 'alignment'\n | 'cohesion'\n | 'separation'\n | 'cursorRepel'\n | 'avoidance'\n | 'trailLength'\n >\n> = {\n spawnRadius: 200,\n maxVelocity: 1.2,\n alignment: 3,\n cohesion: 3,\n separation: 3,\n cursorRepel: 120,\n avoidance: 3,\n trailLength: 30,\n};\n\n/**\n * Boids projector. One simulation timer (d3 `timer`) drives the tick; nodes are\n * the boids, with `vx/vy/ax/ay` carried alongside `x/y`. Edges are kept in the\n * layout so the renderer still draws them between connected boids, but they do\n * NOT exert a link force — boid motion is governed purely by alignment, cohesion\n * and separation, with viewBox-wrap at the SVG bounds.\n */\nexport class GraphSwarmProjector<NodeData = any> extends GraphProjector<NodeData, GraphSwarmProjectorOptions> {\n #timer?: Timer;\n /** Cursor in SVG model coordinates, or null when the pointer is outside the surface. */\n #cursor: { x: number; y: number } | null = null;\n\n override findNode(): GraphLayoutNode<NodeData> | undefined {\n // Boids have no spatial index — drag isn't supported in this variant.\n return undefined;\n }\n\n /**\n * Tell the projector where the pointer is, in SVG model coordinates (the same space\n * `node.x/y` live in — center origin, post-zoom). Pass `null` (or omit args) on\n * pointer-leave to disable cursor avoidance.\n */\n setCursor(x?: number | null, y?: number | null): void {\n if (x == null || y == null) {\n this.#cursor = null;\n } else {\n this.#cursor = { x, y };\n }\n }\n\n protected override onUpdate(graph?: Graph.Any): void {\n log('onUpdate', { graph: { nodes: graph?.nodes.length, edges: graph?.edges.length } });\n this.mergeData(graph);\n this.initializeNodes();\n // Bind enter/exit once before motion starts; subsequent ticks emit 'positions'.\n this.emitUpdate('topology');\n }\n\n protected override async onStart(): Promise<void> {\n this.startTimer();\n }\n\n protected override async onStop(): Promise<void> {\n this.stopTimer();\n }\n\n protected override onRefresh(): void {\n if (!this.#timer) {\n this.startTimer();\n }\n }\n\n #opt<K extends keyof typeof DEFAULTS>(key: K): number {\n return (this.options[key] as number | undefined) ?? DEFAULTS[key];\n }\n\n private initializeNodes(): void {\n const spawnRadius = this.#opt('spawnRadius');\n const maxVelocity = this.#opt('maxVelocity');\n for (const node of this.layout.graph.nodes as SwarmNode[]) {\n if (!node.initialized) {\n const theta = Math.random() * 2 * Math.PI;\n const r = Math.random() * spawnRadius;\n node.x = Math.cos(theta) * r;\n node.y = Math.sin(theta) * r;\n // Random initial velocity bounded by maxVelocity.\n const phi = Math.random() * 2 * Math.PI;\n const speed = (0.3 + Math.random() * 0.7) * maxVelocity;\n node.vx = Math.cos(phi) * speed;\n node.vy = Math.sin(phi) * speed;\n node.ax = 0;\n node.ay = 0;\n node.initialized = true;\n } else {\n // Make sure velocity / acceleration exist on nodes inherited from a prior layout.\n node.vx ??= 0;\n node.vy ??= 0;\n node.ax ??= 0;\n node.ay ??= 0;\n }\n // Default render radius — matches the force projector default.\n node.r ??= 6;\n // Reset the trail history. On fresh entry (`prev` from force/lattice/...) the field\n // is undefined; on re-entry from a prior swarm session the layout node is reused and\n // still carries stale absolute positions which would draw the tail back to wherever\n // the boid was last time. Seed with the current position so the tail grows from the\n // boid's actual starting point.\n node.history = [{ x: node.x ?? 0, y: node.y ?? 0 }];\n }\n }\n\n private startTimer(): void {\n this.stopTimer();\n this.#timer = timer(() => this.tick());\n }\n\n private stopTimer(): void {\n this.#timer?.stop();\n this.#timer = undefined;\n }\n\n /**\n * One simulation step. Modeled on `tick` in Swarm.tsx, but operating in the\n * SVG centered-origin coordinate space and writing to `node.x/y` directly so\n * the existing `GraphRenderer.applyPositions` reads them unchanged.\n */\n private tick(): void {\n const size = this.context.size;\n if (!size) {\n return;\n }\n const { width, height } = size;\n // SVG.Root with `centered: true` (the default) uses a viewBox where origin is\n // the center and bounds are [-w/2, w/2] x [-h/2, h/2].\n const halfW = width / 2;\n const halfH = height / 2;\n\n const nodes = this.layout.graph.nodes as SwarmNode[];\n const maxVelocity = this.#opt('maxVelocity');\n // Match Swarm's force normalisation so weight semantics line up across variants.\n const alignmentW = this.#opt('alignment') / 100;\n const cohesionW = this.#opt('cohesion') / 100;\n const separationW = this.#opt('separation') / 100;\n const avoidanceW = this.#opt('avoidance') / 10;\n const cursorRepel = this.#opt('cursorRepel');\n const cursor = cursorRepel > 0 ? this.#cursor : null;\n\n // Two-pass per tick: (1) compute acceleration from neighbours, (2) integrate.\n for (const b1 of nodes) {\n let ax = 0;\n let ay = 0;\n let alignX = 0;\n let alignY = 0;\n let alignActive = false;\n let cohX = 0;\n let cohY = 0;\n let cohActive = false;\n let sepX = 0;\n let sepY = 0;\n let sepActive = false;\n let avoidX = 0;\n let avoidY = 0;\n let avoidActive = false;\n\n // Cursor repulsion: when the cursor is within the repel zone, push the boid\n // directly away. Mirrors the canvas Swarm's `repel` (treats the cursor as a\n // SwarmObstacle with radius = cursorRepel).\n if (cursor) {\n const dx = cursor.x - (b1.x ?? 0);\n const dy = cursor.y - (b1.y ?? 0);\n const distSq = dx * dx + dy * dy;\n if (distSq > 0 && distSq < cursorRepel * cursorRepel) {\n const dist = Math.sqrt(distSq);\n // Inverse-distance push, matching the canvas variant's `diff.scaleTo(-1 / distance)`.\n avoidX = (-dx / dist) * (1 / dist);\n avoidY = (-dy / dist) * (1 / dist);\n avoidActive = true;\n }\n }\n\n // Mirror the canvas variant: while a boid is being avoided, ignore swarmmate\n // forces so it commits fully to escaping the cursor.\n if (!avoidActive) {\n for (const b2 of nodes) {\n if (b1 === b2) {\n continue;\n }\n\n const dx = (b2.x ?? 0) - (b1.x ?? 0);\n const dy = (b2.y ?? 0) - (b1.y ?? 0);\n const distSq = dx * dx + dy * dy;\n if (distSq === 0) {\n continue;\n }\n const dist = Math.sqrt(distSq);\n\n if (dist < SEPARATION_DISTANCE) {\n // Push away — inverse-distance weighting matches the canvas variant.\n sepX += (-dx / dist) * (1 / dist);\n sepY += (-dy / dist) * (1 / dist);\n sepActive = true;\n }\n if (dist < SWARMMATE_RADIUS) {\n cohX += dx;\n cohY += dy;\n cohActive = true;\n alignX += b2.vx ?? 0;\n alignY += b2.vy ?? 0;\n alignActive = true;\n }\n }\n }\n\n const applyForce = (fx: number, fy: number, weight: number, active: boolean): void => {\n if (!active || weight === 0) {\n return;\n }\n // Steer = target_velocity - current_velocity, then truncate to weight.\n const len = Math.sqrt(fx * fx + fy * fy);\n if (len === 0) {\n return;\n }\n const sx = (fx * maxVelocity) / len - (b1.vx ?? 0);\n const sy = (fy * maxVelocity) / len - (b1.vy ?? 0);\n const slen = Math.sqrt(sx * sx + sy * sy);\n if (slen > weight) {\n ax += (sx * weight) / slen;\n ay += (sy * weight) / slen;\n } else {\n ax += sx;\n ay += sy;\n }\n };\n\n applyForce(alignX, alignY, alignmentW, alignActive);\n applyForce(cohX, cohY, cohesionW, cohActive);\n applyForce(sepX, sepY, separationW, sepActive);\n applyForce(avoidX, avoidY, avoidanceW, avoidActive);\n\n b1.ax = ax;\n b1.ay = ay;\n }\n\n // Integrate + viewBox-wrap + trail bookkeeping.\n const trailLength = Math.max(0, Math.round(this.#opt('trailLength')));\n for (const b of nodes) {\n let vx = (b.vx ?? 0) + (b.ax ?? 0);\n let vy = (b.vy ?? 0) + (b.ay ?? 0);\n const vlen = Math.sqrt(vx * vx + vy * vy);\n if (vlen > maxVelocity) {\n vx = (vx * maxVelocity) / vlen;\n vy = (vy * maxVelocity) / vlen;\n }\n b.vx = vx;\n b.vy = vy;\n\n // Push the pre-integration position into history every tick. Dense sampling means\n // the path-end shifts by a sub-pixel amount per frame — the curve evolves\n // continuously and the tail-end gradient stop tracks smoothly, avoiding the snap\n // / flicker a sparser sample interval would introduce.\n if (trailLength > 0) {\n const history = b.history ?? (b.history = []);\n history.push({ x: b.x ?? 0, y: b.y ?? 0 });\n if (history.length > trailLength) {\n history.splice(0, history.length - trailLength);\n }\n }\n\n let x = (b.x ?? 0) + vx;\n let y = (b.y ?? 0) + vy;\n // Wrap at the centered viewBox edges so boids leaving one side reappear on the opposite.\n // On wrap we clear the trail so the line doesn't streak across the canvas (matches\n // the canvas Swarm's wrap-aware trail rendering, but simpler).\n let wrapped = false;\n if (x > halfW) {\n x -= width;\n wrapped = true;\n } else if (x < -halfW) {\n x += width;\n wrapped = true;\n }\n if (y > halfH) {\n y -= height;\n wrapped = true;\n } else if (y < -halfH) {\n y += height;\n wrapped = true;\n }\n if (wrapped && b.history) {\n b.history.length = 0;\n }\n b.x = x;\n b.y = y;\n }\n\n // Edge geometry: quadratic Bézier with control at the origin so every edge bends\n // toward the center — visually echoing the bundle projector's centre-routed\n // curves while staying cheap to compute. The renderer's `applyPositions` reads\n // `edge.path` directly when present.\n for (const edge of this.layout.graph.edges) {\n const sx = edge.source.x ?? 0;\n const sy = edge.source.y ?? 0;\n const tx = edge.target.x ?? 0;\n const ty = edge.target.y ?? 0;\n edge.path = `M ${sx} ${sy} Q 0 0 ${tx} ${ty}`;\n }\n\n this.emitUpdate('positions');\n }\n}\n", "//\n// Copyright 2021 DXOS.org\n//\n\nimport { easeCubicOut, line, polygonHull, select } from 'd3';\nimport * as Clipper from 'js-clipper';\n\nimport { log } from '@dxos/log';\n\nimport { type D3Callable, type D3Selection, type Point, getCircumferencePoints } from '../../util';\nimport { type GraphLayout, type GraphLayoutEdge, type GraphLayoutNode } from '../types';\nimport { createBullets } from './bullets';\nimport { Renderer, type RendererOptions } from './renderer';\n\n/**\n * Replace the default `<circle>` with a custom node shape. Invoked once per\n * entering node — append your own elements to the supplied `<g>`. Position and\n * `attributes.node` callbacks are still applied by the renderer.\n */\nexport type RenderNode<NodeData = any> = (group: D3Selection<SVGGElement>, node: GraphLayoutNode<NodeData>) => void;\n\nconst createLine = line<Point>();\n\n/** Duration for edge opacity transitions on enter / exit (ms). Matches node enter/exit timing. */\nconst EDGE_FADE_MS = 300;\n\n/** Duration for node hide/show opacity transitions (ms). Matches the projector's tween\n * duration so a cluster collapse/expand fades opacity over the same window the position\n * is tweening toward / away from the parent group. */\nconst NODE_HIDE_MS = 500;\n\nexport type LabelOptions<NodeData = any> = {\n text: (node: GraphLayoutNode<NodeData>, highlight?: boolean) => string | undefined;\n};\n\nexport type AttributesOptions<NodeData = any, EdgeData = any> = {\n node?: (node: GraphLayoutNode<NodeData>) => {\n classes?: Record<string, boolean>;\n data?: Record<string, string | undefined>;\n };\n\n edge?: (edge: GraphLayoutEdge<NodeData, EdgeData>) => {\n classes?: Record<string, boolean>;\n data?: Record<string, string | undefined>;\n };\n};\n\nexport type GraphRendererOptions<NodeData = any, EdgeData = any> = RendererOptions<{\n drag?: D3Callable;\n arrows?: {\n start?: boolean; // TODO(burdon): Replace with marker id.\n end?: boolean;\n };\n highlight?: boolean;\n labels?: LabelOptions<NodeData>;\n subgraphs?: boolean;\n attributes?: AttributesOptions<NodeData>;\n /**\n * Override the default `<circle>` node shape. When set, the renderer appends\n * whatever this callback creates instead. Use for lattice rects, custom icons, etc.\n */\n renderNode?: RenderNode<NodeData>;\n /**\n * Per-tick per-node callback invoked from `applyPositions` AFTER the dx-node group's\n * transform is updated. Use it to keep node-local SVG (trail paths, gradient axes,\n * per-frame decorations) in sync with the node's current position. The group is the\n * dx-node `<g>` (head at 0,0 in local coords); the node is the live layout node.\n * Runs only on the positions fast-path; full `render` calls don't invoke it.\n */\n applyNode?: (group: SVGGElement, node: GraphLayoutNode<NodeData>) => void;\n /**\n * Opacity applied to the `dx-edges` group. Set < 1 to dim edges relative to nodes\n * (e.g. swarm trails over routing edges). Default is the inherited group opacity.\n */\n edgeOpacity?: number;\n transition?: () => any;\n /**\n * On node pointerenter, color outgoing edges orange, incoming edges sky-blue, dim\n * unrelated edges, and stroke connected nodes / dim unrelated ones. Cleared on\n * pointerleave. Designed for the bundle variant; harmless for variants where the\n * topology doesn't carry meaningful direction.\n */\n highlightOnHover?: boolean;\n onNodeClick?: (node: GraphLayoutNode<NodeData>, event: MouseEvent) => void;\n onNodePointerEnter?: (node: GraphLayoutNode<NodeData>, event: MouseEvent) => void;\n /** Fires on pointerleave from a node hit-target. Pair with `onNodePointerEnter` to clear hover state. */\n onNodePointerLeave?: (node: GraphLayoutNode<NodeData>, event: MouseEvent) => void;\n onLinkClick?: (link: GraphLayoutEdge<NodeData, EdgeData>, event: MouseEvent) => void;\n}>;\n\n/**\n * Renders the Graph layout.\n */\nexport class GraphRenderer<NodeData = any, EdgeData = any> extends Renderer<\n GraphLayout<NodeData, EdgeData>,\n GraphRendererOptions<NodeData, EdgeData>\n> {\n // First render of this instance — used to clear DOM left behind by a previous\n // renderer pointing at the same `<g>` (e.g. when the consumer swaps projectors\n // and a new renderer is constructed for the same SVG root). Without this, the\n // previous variant's node shapes (e.g. circles) would persist as d3.join sees\n // them in the `update` set instead of `enter`.\n #firstRender = true;\n\n override render(layout: GraphLayout<NodeData, EdgeData>) {\n // The SVG group ref is unset between mount cycles and before the container has sized;\n // skip the render rather than throw — the projector will emit again on the next tick.\n if (!this.root) {\n return;\n }\n\n if (this.#firstRender) {\n this.#firstRender = false;\n // Drop any DOM left by a prior renderer so this render's `renderNode` runs from scratch.\n this.root.replaceChildren();\n }\n\n log('render', layout);\n\n const root = select(this.root);\n\n //\n // Guides\n //\n\n if (layout.guides) {\n root\n .selectAll('g.dx-guides')\n .data([{ id: 'guides' }])\n .join('g')\n .classed('dx-guides', true)\n .selectAll<SVGCircleElement, { cx: number; cy: number; r: number }>('circle')\n .data(layout.guides ?? [])\n .join(\n (enter) => enter.append('circle').attr('r', 0),\n (update) => update,\n (exit) => exit.transition().duration(500).attr('r', 0).remove(),\n )\n .attr('cx', (d) => d.cx)\n .attr('cy', (d) => d.cy)\n .attr('r', (d) => d.r);\n }\n\n //\n // Subgraphs (aka components)\n //\n\n const scale = 100;\n const offsetDistance = 24 * scale;\n\n if (this._options.subgraphs) {\n // TODO(burdon): Cache components in layout.\n // TODO(burdon): Separate force system for each subgraph.\n const components = this._options.subgraphs\n ? findConnectedComponents({\n nodes: layout.graph?.nodes ?? [],\n edges: (layout.graph?.edges ?? []).map(({ source, target }) => ({ source: source.id, target: target.id })),\n })\n .filter((component) => component.length > 2)\n .map((component, i) => ({ id: `subgraph-${i}`, component }))\n : [];\n\n root\n .selectAll('g.dx-subgraphs')\n .data([{ id: 'subgraphs' }])\n .join('g')\n .classed('dx-subgraphs', true)\n .selectAll<SVGPathElement, { id: string }>('path')\n .data(components)\n .join(\n (enter) => enter.append('path').classed('dx-subgraph', true),\n (update) => {\n return update.attr('d', ({ component }) => {\n const points: Point[] =\n layout.graph?.nodes.filter((node) => component.includes(node.id)).map((node) => [node.x, node.y]) ?? [];\n\n // https://d3js.org/d3-polygon\n const hullPoints = polygonHull(points);\n\n // https://www.npmjs.com/package/js-clipper\n const co = new Clipper.ClipperOffset();\n const solution = [];\n const clipperPath = hullPoints.map(([x, y]) => ({ X: x * scale, Y: y * scale }));\n co.AddPath(clipperPath, Clipper.JoinType.jtRound, Clipper.EndType.etClosedPolygon);\n co.Execute(solution, offsetDistance);\n if (solution.length > 0) {\n const offset = solution[0].map(({ X, Y }) => [X / scale, Y / scale]);\n return createLine([...offset, offset[0]]);\n }\n });\n },\n );\n }\n\n //\n // Edges and nodes\n // TODO(burdon): Only call join when data changes (otherwise exit transitions are called multiple times).\n //\n\n const edgeGroup = root\n .selectAll('g.dx-edges')\n .data([{ id: 'edges' }], (d: any) => d.id)\n .join('g')\n .classed('dx-edges', true)\n .style('opacity', this.options.edgeOpacity != null ? String(this.options.edgeOpacity) : null);\n\n const nodeGroup = root\n .selectAll('g.dx-nodes')\n .data([{ id: 'nodes' }], (d: any) => d.id)\n .join('g')\n .classed('dx-nodes', true);\n\n //\n // Nodes\n //\n\n nodeGroup\n .selectAll<SVGCircleElement, GraphLayoutNode<NodeData>>('g.dx-node')\n .data(layout.graph?.nodes ?? [], (d) => d.id)\n .join(\n (enter) =>\n enter\n .append('g')\n .attr('data-id', (d) => d.id)\n // Initial opacity matches `hidden` so a node that enters already-collapsed is\n // invisible from the first frame; updateNode's named 'hide' transition then\n // handles any subsequent toggles.\n .attr('opacity', (d) => (d.hidden ? 0 : 1))\n .classed('dx-node', true)\n .call(createNode, this.options),\n (update) => update,\n (exit) => {\n // Fade out.\n return exit\n .transition()\n .ease(easeCubicOut)\n .duration(300)\n .attr('opacity', 0)\n .on('end', function (d) {\n select(this).remove();\n });\n },\n )\n // Apply update (transform / attributes / labels) to enter+update so the first render\n // also populates `data-*` attributes and transforms — not just subsequent ticks.\n .call(updateNode, this.options)\n .sort((a, b) => (a.order ?? 0) - (b.order ?? 0));\n\n //\n // Edges\n //\n\n edgeGroup\n .selectAll<SVGPathElement, GraphLayoutEdge<NodeData, EdgeData>>('g.dx-edge')\n .data(layout.graph?.edges ?? [], (d) => d.id)\n .join(\n (enter) =>\n enter\n .append('g')\n .attr('data-id', (d) => d.id)\n .classed('dx-edge', true)\n .call(createEdge, this.options),\n (update) => update,\n // Exit fade: edges removed by a topology change (e.g. variant switch from cluster\n // back to force replaces hierarchy edges with data edges) ease out rather than pop.\n (exit) =>\n exit\n .transition()\n .ease(easeCubicOut)\n .duration(EDGE_FADE_MS)\n .attr('opacity', 0)\n .on('end', function () {\n select(this).remove();\n }),\n )\n // Apply edge updates (paths / attributes) to enter+update — see note on nodes above.\n .call(updateEdge, this.options, nodeGroup)\n .sort((a, b) => (a.order ?? 0) - (b.order ?? 0));\n }\n\n /**\n * Fast positions-only update. Skips enter/exit, attribute callbacks, label sizing,\n * and the subgraph hull pass; just writes `transform` per node and `d` per edge.\n * Called per simulation tick / animation frame.\n */\n override applyPositions(layout: GraphLayout<NodeData, EdgeData>) {\n if (!this.root) {\n return;\n }\n\n const root = select(this.root);\n\n // Transforms only — no attribute callback, no label measurement.\n const applyNode = this.options.applyNode;\n root\n .select('g.dx-nodes')\n .selectAll<SVGGElement, GraphLayoutNode<NodeData>>('g.dx-node')\n .attr('transform', (d) => (d.x != null && d.y != null ? `translate(${d.x},${d.y})` : null))\n .each(\n applyNode\n ? function (d) {\n // Per-tick consumer hook (e.g. swarm trail). Group transform is already up to date,\n // so node-local coords land in the same frame as the head position.\n applyNode(this, d);\n }\n : () => {},\n );\n\n // Edge geometry — either precomputed (`edge.path`) or derived from endpoint positions.\n root\n .select('g.dx-edges')\n .selectAll<SVGGElement, GraphLayoutEdge<NodeData, EdgeData>>('g.dx-edge')\n .selectAll<SVGPathElement, GraphLayoutEdge<NodeData, EdgeData>>('path')\n .attr('d', function () {\n // NOTE: `d` is stale after layout is switched so get the datum from the parent element.\n const edge = select(this.parentElement).datum() as GraphLayoutEdge<NodeData, EdgeData>;\n if (edge.path) {\n return edge.path;\n }\n const { source, target } = edge;\n if (!source.initialized || !target.initialized) {\n return null;\n }\n return createLine(getCircumferencePoints([source.x, source.y], [target.x, target.y], source.r, target.r));\n });\n }\n\n /**\n * Trigger path bullets.\n * @param node\n */\n fireBullet(node: GraphLayoutNode<NodeData>) {\n if (!this.root) {\n return;\n }\n select(this.root).selectAll('g.dx-edges').selectAll('path').call(createBullets(this.root, node.id));\n }\n}\n\n/**\n * Create node elements.\n * @param group\n * @param options\n */\nconst SHAPE_CLASS = 'dx-shape';\n\nconst renderCustomShape = <Data>(group: D3Selection, options: GraphRendererOptions<Data>) => {\n group.each(function (d) {\n const g = select<SVGGElement, GraphLayoutNode<Data>>(this);\n // Clear any previous custom shape so subsequent renders pick up updated\n // node.r / node.data without leaving stale elements behind.\n g.selectAll(`.${SHAPE_CLASS}`).remove();\n // Wrap the consumer's drawing in a `<g class=\"dx-shape\">` so we have a\n // stable selector for the cleanup above.\n const shapeGroup = g.append('g').classed(SHAPE_CLASS, true);\n options.renderNode!(shapeGroup, d);\n });\n};\n\nconst createNode: D3Callable = <Data>(group: D3Selection, options: GraphRendererOptions<Data>) => {\n // Custom node shape: consumer appends its own elements (e.g. <rect>) and the\n // renderer skips the default <circle>. Drag/hover handlers attach to the\n // wrapping <g> so the custom shape acts as the hit target.\n const useCustom = !!options.renderNode;\n if (useCustom) {\n renderCustomShape(group, options);\n }\n const hitTarget = useCustom ? group : group.append('circle');\n\n // Drag.\n // TODO(burdon): Update when layout changes.\n if (options.drag) {\n hitTarget.call(options.drag);\n }\n\n // Click. d3 invokes `on` listeners as `(event, datum)` where datum is the bound data on\n // the listener's host element (the dx-node `<g>`). Use it directly — reading from\n // `event.target` returned undefined for the inner circle / text (which don't inherit\n // __data__), and `this` plus `select(this).datum()` was producing inconsistent results\n // across HMR reloads.\n if (options.onNodeClick) {\n group.on('click', (event: MouseEvent, d: GraphLayoutNode<Data>) => {\n options.onNodeClick(d, event);\n });\n }\n\n // Label.\n if (options.labels && !options.onNodePointerEnter) {\n const g = group.append('g').classed('dx-label', true);\n g.append('line');\n g.append('rect');\n g.append('text').style('dominant-baseline', 'middle');\n }\n\n // Hover.\n if (options.onNodePointerEnter || options.onNodePointerLeave || options.highlightOnHover) {\n hitTarget.on('pointerenter', function (event: PointerEvent) {\n const node = select<any, GraphLayoutNode<Data>>(useCustom ? this : this.parentElement).datum();\n options.onNodePointerEnter?.(node, event);\n if (options.highlightOnHover) {\n applyHoverHighlight((this as Element).closest('g.dx-graph') as SVGGElement | null, node.id);\n }\n });\n hitTarget.on('pointerleave', function (event: PointerEvent) {\n const node = select<any, GraphLayoutNode<Data>>(useCustom ? this : this.parentElement).datum();\n options.onNodePointerLeave?.(node, event);\n if (options.highlightOnHover) {\n applyHoverHighlight((this as Element).closest('g.dx-graph') as SVGGElement | null, null);\n }\n });\n\n group.attr('data-hover', 'handled');\n } else if (options.highlight !== false && !useCustom) {\n hitTarget.on('pointerenter', function () {\n select(this.closest('g.dx-node')).raise();\n if (options.labels) {\n select(this.parentElement).classed('dx-node-active', true).classed('dx-highlight', true);\n }\n });\n\n group.on('pointerleave', function () {\n if (options.labels) {\n select(this).classed('dx-node-active', false);\n setTimeout(() => {\n if (!select(this).classed('dx-node-active')) {\n select(this).classed('dx-highlight', false);\n }\n }, 300);\n }\n });\n }\n};\n\n/**\n * Update node elements.\n * @param group\n * @param options\n */\nconst updateNode: D3Callable = <NodeData = any, EdgeData = any>(\n group: D3Selection,\n options: GraphRendererOptions<NodeData, EdgeData>,\n) => {\n group.attr('transform', (d) => {\n return d.x != null && d.y != null ? `translate(${d.x},${d.y})` : undefined;\n });\n\n // Hidden state: drive pointer-events + the hover opacity via the `dx-hidden` class;\n // tween the actual opacity attribute on a named transition so it doesn't fight the\n // CSS hover transition (different namespaces, different durations).\n group.classed('dx-hidden', (d) => d.hidden ?? false);\n group\n .transition('hide')\n .ease(easeCubicOut)\n .duration(NODE_HIDE_MS)\n .attr('opacity', (d) => (d.hidden ? 0 : 1));\n\n // Re-run the custom shape on every full render so a topology / data update\n // refreshes geometry (e.g. lattice node.r changes on resize, fill changes on\n // typename change). The cheap fast path (`applyPositions`) doesn't touch\n // shapes, so this only runs on the rarer topology-emit code path.\n if (options.renderNode) {\n renderCustomShape(group, options);\n }\n\n // Custom attributes.\n if (options.attributes?.node) {\n try {\n group.each((d, i, nodes) => {\n const node = select(nodes[i]);\n const { classes, data } = options.attributes?.node?.(d) ?? {};\n if (classes) {\n applyClasses(node, classes);\n }\n if (data) {\n Object.entries(data).forEach(([key, value]) => {\n node.attr(`data-${key}`, value);\n });\n }\n });\n } catch (error: any) {\n log.error('updateNode', { error: error?.message });\n }\n }\n\n // Optional transition.\n const groupOrTransition: D3Selection = options.transition\n ? (group.transition(options.transition()) as unknown as D3Selection)\n : group;\n\n // Update circles. Skipped when the consumer supplied a custom node shape.\n if (!options.renderNode) {\n groupOrTransition.select<SVGCircleElement>('circle').attr('r', (d) => d.r ?? 16);\n }\n\n // Update labels.\n if (options.labels) {\n const bx = 1;\n const px = 4;\n const py = 2;\n const offset = 16;\n const dx = (d: any, offset = 0) => (offset + (d.r ?? 0)) * (d.x > 0 ? 1 : -1);\n\n groupOrTransition\n .select<SVGTextElement>('text')\n .text((d) => options.labels.text(d))\n .style('text-anchor', (d) => (d.x > 0 ? 'start' : 'end'))\n .attr('dx', (d) => dx(d, offset))\n .attr('dy', 1)\n .text((d) => options.labels.text(d))\n .each(function (d) {\n // Cache bounding box.\n let bbox = d.bbox;\n if (!bbox) {\n bbox = this.getBBox();\n d.bbox = bbox;\n }\n\n const width = bbox.width + (bx + px) * 2;\n const height = bbox.height + py * 2;\n\n select(this.parentElement)\n .select('rect')\n .attr('x', dx(d, offset - (bx + px)) + (d.x > 0 ? 0 : -1) * width)\n .attr('y', -height / 2)\n .attr('width', width)\n .attr('height', height)\n .attr('rx', 4);\n\n select(this.parentElement)\n .select('line')\n .attr('x1', dx(d, 1))\n .attr('y1', 0)\n .attr('x2', dx(d, offset - (bx + px)))\n .attr('y2', 0);\n });\n }\n};\n\n/**\n * Create edge elements.\n * @param group\n * @param options\n * @param nodes\n */\nconst createEdge: D3Callable = <NodeData = any, EdgeData = any>(\n group: D3Selection,\n options: GraphRendererOptions<NodeData, EdgeData>,\n) => {\n if (options.onLinkClick) {\n // Shadow path with wide stroke for click handler.\n group\n .append('path')\n .classed('dx-click', true)\n .on('click', (event: MouseEvent) => {\n const edge = select<SVGLineElement, GraphLayoutEdge<NodeData, EdgeData>>(\n event.target as SVGLineElement,\n ).datum();\n options.onLinkClick(edge, event);\n });\n }\n\n group\n .append('path')\n .attr('pointer-events', 'none')\n .attr('marker-start', () => (options.arrows?.start ? 'url(#marker-arrow-start)' : undefined))\n .attr('marker-end', () => (options.arrows?.end ? 'url(#marker-arrow-end)' : undefined));\n};\n\n/**\n * Update edge elements.\n * @param group\n * @param options\n */\nconst updateEdge: D3Callable = <NodeData = any, EdgeData = any>(\n group: D3Selection,\n options: GraphRendererOptions<NodeData, EdgeData>,\n nodeGroup: D3Selection,\n) => {\n // Custom attributes.\n try {\n group.each((d, i, edges) => {\n const edge = select(edges[i]);\n edge.classed('dx-dashed', d.linkForce === false);\n const { classes, data } = options.attributes?.edge?.(d) ?? {};\n if (classes) {\n applyClasses(edge, classes);\n }\n if (data) {\n Object.entries(data).forEach(([key, value]) => {\n edge.attr(`data-${key}`, value);\n });\n }\n });\n } catch (error: any) {\n log.error('updateEdge', { error: error?.message });\n }\n\n // Optional transition.\n const groupOrTransition: D3Selection = options.transition\n ? (group.transition(options.transition()) as unknown as D3Selection)\n : group;\n\n groupOrTransition.selectAll<SVGPathElement, GraphLayoutEdge<NodeData, EdgeData>>('path').attr('d', function () {\n // NOTE: `d` is stale after layout is switched so get the datum from the parent element.\n const edge = select(this.parentElement).datum() as GraphLayoutEdge<NodeData, EdgeData>;\n if (edge.path) {\n return edge.path;\n }\n const { source, target } = edge;\n if (!source.initialized || !target.initialized) {\n return;\n }\n\n return createLine(getCircumferencePoints([source.x, source.y], [target.x, target.y], source.r, target.r));\n });\n};\n\n/**\n * Hover-driven directional highlight: when `focusedId` is set, paint outgoing edges\n * orange, incoming edges sky-blue, dim unrelated edges, stroke connected nodes, and\n * dim unrelated nodes. When `focusedId` is null, clear every inline override so the\n * graph returns to its default styling.\n */\nconst applyHoverHighlight = (root: SVGGElement | null, focusedId: string | null) => {\n if (!root) {\n return;\n }\n const r = select(root);\n const on = focusedId != null;\n\n const outgoing = new Set<string>();\n const incoming = new Set<string>();\n if (on) {\n r.select('g.dx-edges')\n .selectAll<SVGGElement, GraphLayoutEdge>('g.dx-edge')\n .each((edge) => {\n if (edge.source.id === focusedId) {\n outgoing.add(edge.target.id);\n }\n if (edge.target.id === focusedId) {\n incoming.add(edge.source.id);\n }\n });\n }\n\n r.select('g.dx-edges')\n .selectAll<SVGGElement, GraphLayoutEdge>('g.dx-edge')\n .each(function (edge) {\n // Visible edge path — exclude the wider transparent click target when present.\n const path = select(this).select<SVGPathElement>('path:not(.dx-click)');\n if (!on) {\n path.style('stroke', null).style('stroke-width', null).style('opacity', null);\n return;\n }\n if (edge.source.id === focusedId) {\n path.style('stroke', 'var(--color-orange-500)').style('stroke-width', '1.5px').style('opacity', null);\n } else if (edge.target.id === focusedId) {\n path.style('stroke', 'var(--color-sky-500)').style('stroke-width', '1.5px').style('opacity', null);\n } else {\n path.style('stroke', null).style('stroke-width', null).style('opacity', '0.8');\n }\n });\n\n r.select('g.dx-nodes')\n .selectAll<SVGGElement, GraphLayoutNode>('g.dx-node')\n .each(function (node) {\n const groupSel = select(this);\n const shape = groupSel.select<SVGGraphicsElement>('circle, rect');\n // Hidden nodes (e.g. cluster-collapsed leaves) are kept invisible via the\n // group's `opacity` attribute — set by `updateNode`. style.opacity would\n // override that attribute, so leave hidden nodes alone.\n if (node.hidden) {\n return;\n }\n if (!on) {\n groupSel.style('opacity', null);\n shape.style('stroke', null).style('stroke-width', null);\n return;\n }\n const connected = outgoing.has(node.id) || incoming.has(node.id);\n if (node.id === focusedId) {\n groupSel.style('opacity', null);\n shape.style('stroke', null).style('stroke-width', null);\n } else if (connected) {\n groupSel.style('opacity', null);\n shape.style('stroke', 'var(--color-orange-400)').style('stroke-width', '2.5px');\n } else {\n groupSel.style('opacity', '0.4');\n shape.style('stroke', null).style('stroke-width', null);\n }\n });\n};\n\n// TODO(burdon): Factor out.\n\nconst applyClasses = (el: D3Selection, classes: Record<string, boolean>) => {\n for (const [className, value] of Object.entries(classes)) {\n el.classed(className, value);\n }\n};\n\n/**\n * Find connected components (subgraphs) in a graph.\n */\nconst findConnectedComponents = (graph: {\n nodes: { id: string }[];\n edges: { source: string; target: string }[];\n}): string[][] => {\n const adj: Record<string, string[]> = {};\n for (const node of graph.nodes) {\n adj[node.id] = [];\n }\n\n for (const { source, target } of graph.edges) {\n adj[source].push(target);\n adj[target].push(source);\n }\n\n const visited = new Set<string>();\n const components: string[][] = [];\n for (const node of graph.nodes) {\n if (visited.has(node.id)) {\n continue;\n }\n\n const stack = [node.id];\n const componentIds: string[] = [];\n\n while (stack.length) {\n const current = stack.pop()!;\n if (visited.has(current)) {\n continue;\n }\n visited.add(current);\n componentIds.push(current);\n stack.push(...adj[current]);\n }\n\n components.push(componentIds);\n }\n\n return components;\n};\n", "//\n// Copyright 2019 DXOS.org\n//\n\nimport { easeLinear, interpolate, select } from 'd3';\n\nimport { type D3Callable, type D3Selection } from '../../util';\n\nexport type BulletOptions = {\n max?: number;\n radius?: number;\n delay?: number;\n minDuration?: number;\n maxDuration?: number;\n};\n\n/**\n * Generate animated bullets that follow selected paths.\n * @param group\n * @param nodeId\n * @param options\n */\nexport const createBullets = (group: SVGGElement, nodeId: string, options: BulletOptions = {}): D3Callable => {\n return (selection: D3Selection) => {\n const { max = 32, radius = 3, delay = 50, minDuration = 100, maxDuration = 500 } = options;\n\n // Edge selection.\n selection.each(function (d, i, edges) {\n const { source, target } = d;\n\n // Match source node.\n if (source.id === nodeId) {\n const path = select(edges[i]);\n const p = path.node().getPointAtLength(0);\n\n const bullet = select(group)\n .append('circle')\n .attr('class', 'dx-bullet')\n .attr('cx', p.x)\n .attr('cy', p.y)\n .attr('r', radius);\n\n bullet\n // Start animation.\n .transition()\n .delay(delay)\n .duration(minDuration + Math.random() * maxDuration)\n .ease(easeLinear)\n .tween('pathTween', function () {\n const length = path.node().getTotalLength();\n const r = interpolate(0, length);\n\n return (t) => {\n const point = path.node().getPointAtLength(r(t));\n select(this).attr('cx', point.x).attr('cy', point.y);\n };\n })\n\n // End of transition.\n .on('end', function () {\n select(this).remove();\n\n // Propagate with circuit breaker to prevent infinite recursion.\n const num = select(group).selectAll('circle.dx-bullet').size();\n if (num < max) {\n selection.call(createBullets(group, target.id));\n }\n });\n }\n });\n };\n};\n", "//\n// Copyright 2021 DXOS.org\n//\n\nimport { type RefObject } from 'react';\n\nimport { type SVGContext } from '../../hooks';\nimport { type IdAccessor, defaultIdAccessor } from '../types';\n\nexport type RendererOptions<T = any> = {\n idAccessor: IdAccessor;\n} & T;\n\n/**\n * Base class for renderer that draw layouts.\n */\nexport abstract class Renderer<LAYOUT, OPTIONS extends RendererOptions> {\n protected readonly _options?: OPTIONS;\n\n constructor(\n protected readonly _context: SVGContext,\n protected readonly _root: RefObject<SVGGElement>,\n options?: Partial<OPTIONS>,\n ) {\n this._options = Object.assign(\n {\n idAccessor: defaultIdAccessor,\n },\n options,\n ) as OPTIONS;\n }\n\n get context(): SVGContext {\n return this._context;\n }\n\n /**\n * Returns the SVG group root if mounted.\n * The ref may be null between mount/unmount cycles or before the SVG container has sized.\n * Callers should treat null as \"skip this render\" rather than as an error.\n */\n get root(): SVGGElement | null {\n return this._root.current;\n }\n\n get options() {\n return this._options;\n }\n\n abstract render(layout: LAYOUT): void;\n\n /**\n * Fast path invoked when only positions changed.\n * Default falls back to a full `render`; subclasses can override to skip\n * enter/exit joins and attribute callbacks for per-tick updates.\n */\n applyPositions(layout: LAYOUT): void {\n this.render(layout);\n }\n}\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport { type D3Selection } from '../../util';\nimport { type GraphLayoutNode } from '../types';\n\nexport type LabelOptionsBase = {\n /**\n * Delay before fading the label in (ms). Default 0. Pair with the projector's tween\n * duration so labels appear after the layout settles.\n */\n delay?: number;\n /** Fade-in duration (ms). Default 200. */\n duration?: number;\n /** Radial offset from the node center (px). Default 4. */\n offset?: number;\n /** Additional CSS class(es) to set on the text element. */\n className?: string;\n};\n\nconst DEFAULT_DURATION = 200;\nconst DEFAULT_OFFSET = 4;\n\n/** Read the target (post-tween) position from a node. Falls back to current x/y on entry. */\nconst getTarget = (node: GraphLayoutNode): { x: number; y: number } => {\n const tx = (node as any).tx;\n const ty = (node as any).ty;\n return { x: tx ?? node.x ?? 0, y: ty ?? node.y ?? 0 };\n};\n\n/**\n * Append a radial leaf label outside the node ring, oriented outward toward the TARGET\n * position so the label rotates with the layout tween rather than the pre-tween position.\n * Used by cluster + bundle variants for typename-grouped leaves.\n */\nexport const appendRadialLeafLabel = (\n group: D3Selection<SVGGElement>,\n node: GraphLayoutNode,\n label: string,\n r: number,\n options: LabelOptionsBase = {},\n): void => {\n if (!label) {\n return;\n }\n const { delay = 0, duration = DEFAULT_DURATION, offset = DEFAULT_OFFSET, className = 'dx-cluster-label' } = options;\n const { x: targetX, y: targetY } = getTarget(node);\n const angleDeg = (Math.atan2(targetY, targetX) * 180) / Math.PI;\n const flipped = angleDeg > 90 || angleDeg < -90;\n group\n .append('text')\n .attr('class', className)\n .attr('dy', '0.32em')\n .attr('transform', `rotate(${flipped ? angleDeg + 180 : angleDeg})`)\n .attr('x', flipped ? -(r + offset) : r + offset)\n .attr('text-anchor', flipped ? 'end' : 'start')\n .attr('opacity', 0)\n .style('cursor', 'pointer')\n .text(label)\n .transition()\n .delay(delay)\n .duration(duration)\n .attr('opacity', 1);\n};\n\n/**\n * Append a radial group label inside the node ring (anchored toward center), oriented along\n * the TARGET radial direction. Mirrors `appendRadialLeafLabel` but anchored on the opposite\n * side so leaf and group labels don't collide.\n */\nexport const appendRadialGroupLabel = (\n group: D3Selection<SVGGElement>,\n node: GraphLayoutNode,\n label: string,\n r: number,\n options: LabelOptionsBase = {},\n): void => {\n if (!label) {\n return;\n }\n const {\n delay = 0,\n duration = DEFAULT_DURATION,\n offset = DEFAULT_OFFSET,\n className = 'dx-cluster-label dx-cluster-label-group',\n } = options;\n const { x: targetX, y: targetY } = getTarget(node);\n const angleDeg = (Math.atan2(targetY, targetX) * 180) / Math.PI;\n const flipped = angleDeg > 90 || angleDeg < -90;\n group\n .append('text')\n .attr('class', className)\n .attr('dy', '0.32em')\n .attr('transform', `rotate(${flipped ? angleDeg + 180 : angleDeg})`)\n .attr('x', flipped ? r + offset : -(r + offset))\n .attr('text-anchor', flipped ? 'start' : 'end')\n .attr('opacity', 0)\n .style('pointer-events', 'none')\n .text(label)\n .transition()\n .delay(delay)\n .duration(duration)\n .attr('opacity', 1);\n};\n\n/**\n * Append a centered root label above the node. Used by the cluster variant for the synthetic\n * root circle so the database / collection name reads from above the ring.\n */\nexport const appendRootLabel = (\n group: D3Selection<SVGGElement>,\n label: string,\n r: number,\n options: LabelOptionsBase = {},\n): void => {\n if (!label) {\n return;\n }\n const {\n delay = 0,\n duration = DEFAULT_DURATION,\n offset = 6,\n className = 'dx-cluster-label dx-cluster-label-root',\n } = options;\n group\n .append('text')\n .attr('class', className)\n .attr('text-anchor', 'middle')\n .attr('y', -(r + offset))\n .attr('opacity', 0)\n .style('pointer-events', 'none')\n .text(label)\n .transition()\n .delay(delay)\n .duration(duration)\n .attr('opacity', 1);\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { line } from 'd3';\n\nimport { type D3Callable, type Point } from '../../util';\nimport { getCircumferencePoints } from '../../util';\nimport { type GraphLayoutNode } from '../types';\n\nconst createLine = line();\n\nexport type LinkOptions = {\n source?: GraphLayoutNode<any>;\n target?: GraphLayoutNode<any>;\n point?: Point;\n};\n\n/**\n * Render linker while dragging.\n */\nexport const linkerRenderer: D3Callable = (root, { source, target, point }: LinkOptions = {}) => {\n root\n .selectAll('g.dx-linker')\n .data([{ id: 'linker' }])\n .join('g')\n .attr('class', 'dx-linker')\n .selectAll<SVGPathElement, any>('path')\n .data(source ? [{ id: 'edge' }] : [])\n .join('path')\n .attr('marker-end', () => (target ? 'url(#marker-arrow-end)' : 'url(#marker-dot)'))\n .attr('d', () => {\n return createLine(\n getCircumferencePoints(\n [source.x, source.y],\n target ? [target.x, target.y] : point,\n source.r,\n target ? target.r : 0,\n ),\n );\n });\n};\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport { line, range, select } from 'd3';\nimport { type RefObject, useEffect, useMemo, useRef } from 'react';\n\nimport { type SVGContext, useSvgContext } from './useSvgContext';\n\nconst createLine = line();\n\ntype PathGroup = {\n id: string;\n class: string;\n path: string;\n};\n\n/**\n * Create grid based on size and current zoom transform.\n */\nconst createGrid = (context: SVGContext, options: GridOptions): PathGroup[] => {\n if (!context.size) {\n return [];\n }\n\n const paths = [];\n const { width, height } = context.size;\n const { x, y, k } = context.scale.transform;\n const s = 1 / k;\n\n // Offset.\n const w = width * s;\n const h = height * s;\n const dx = -(x + width / 2) * s;\n const dy = -(y + height / 2) * s;\n\n // TODO(burdon): Use the transform to create the range?\n // https://github.com/d3/d3-zoom#transform_rescaleX\n\n // Axis.\n if (options.axis) {\n const axis = [\n [\n [0, dy],\n [0, dy + h],\n ],\n [\n [dx, 0],\n [dx + w, 0],\n ],\n ];\n\n paths.push({\n id: 'axis',\n class: 'dx-axis',\n path: axis.map((line) => createLine(line as any)).join(),\n });\n }\n\n // Grid.\n if (options.grid) {\n // Scale grid size.\n const mod = (n: number, size: number, delta = 0) => Math.floor(n / size + delta) * size;\n\n // Major grid lines.\n const majorSize = context.scale.gridSize;\n const xMajor = range(-mod((x + width / 2) * s, majorSize), mod((-x + width / 2) * s, majorSize, 1), majorSize);\n const yMajor = range(-mod((y + height / 2) * s, majorSize), mod((-y + height / 2) * s, majorSize, 1), majorSize);\n const major = [\n ...xMajor\n .filter((x) => !options.axis || x)\n .map((x) => [\n [x, dy],\n [x, dy + h],\n ]),\n ...yMajor\n .filter((y) => !options.axis || y)\n .map((y) => [\n [dx, y],\n [dx + w, y],\n ]),\n ];\n\n paths.push({\n id: 'major',\n class: 'dx-major',\n path: major.map((line) => createLine(line as any)).join(),\n });\n\n // Minor grid lines.\n // Find nearest power of 2 to gridSize.\n // TODO(burdon): Doesn't work is scale is not power of 2.\n const minorSize = Math.pow(2, Math.round(Math.log2(s * context.scale.gridSize)));\n if (majorSize > minorSize) {\n const xMinor = range(-mod((x + width / 2) * s, minorSize), mod((-x + width / 2) * s, minorSize, 1), minorSize);\n const yMinor = range(-mod((y + height / 2) * s, minorSize), mod((-y + height / 2) * s, minorSize, 1), minorSize);\n const minor = [\n ...xMinor\n .filter((x) => xMajor.indexOf(x) === -1)\n .map((x) => [\n [x, dy],\n [x, dy + h],\n ]),\n ...yMinor\n .filter((y) => yMajor.indexOf(y) === -1)\n .map((y) => [\n [dx, y],\n [dx + w, y],\n ]),\n ];\n\n paths.push({\n id: 'minor',\n class: 'dx-minor',\n path: minor.map((line) => createLine(line as any)).join(),\n });\n }\n }\n\n return paths;\n};\n\nexport type GridOptions = {\n visible?: boolean;\n axis?: boolean;\n grid?: boolean;\n};\n\nconst defaultGridOptions: GridOptions = {\n visible: true,\n axis: true,\n grid: true,\n};\n\nexport class GridController {\n _visible = false;\n\n constructor(\n private readonly _ref: RefObject<SVGGElement>,\n private readonly _context: SVGContext,\n private readonly _options: GridOptions,\n ) {\n this._visible = this._options.visible ?? true;\n }\n\n get ref() {\n return this._ref;\n }\n\n get visible() {\n return this._visible;\n }\n\n draw(): void {\n if (!this._context.size) {\n return;\n }\n\n const paths = this._visible ? createGrid(this._context, this._options) : [];\n const root = select(this._ref.current!);\n\n root\n .selectAll<SVGPathElement, PathGroup>('path')\n .data(paths, (path) => path.id)\n .join('path')\n .style('pointer-events', 'none')\n .attr('d', (d) => d.path)\n .attr('class', (d) => d.class);\n\n const transform = this._context.scale.transform;\n if (transform) {\n root.attr('transform', transform as any);\n root.attr('stroke-width', 1 / transform.k);\n }\n }\n\n setVisible(visible: boolean): this {\n this._visible = visible;\n this.draw();\n return this;\n }\n}\n\n/**\n * Creates a reference to a SVG Group element which renders a grid.\n * @param options\n */\nexport const useGrid = (options: GridOptions = defaultGridOptions): GridController => {\n const ref = useRef<SVGGElement>(null);\n const context = useSvgContext();\n const controller = useMemo(() => new GridController(ref, context, options), []);\n useEffect(() => context.resized.on(() => controller.draw()), [context, controller]);\n return controller;\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { type ZoomTransform } from 'd3';\nimport { createContext, useContext } from 'react';\nimport { type RefObject, createRef } from 'react';\n\nimport { raise } from '@dxos/debug';\n\nimport { EventEmitter, type Point, Scale, type Size } from '../util';\n\nexport type SVGContextOptions = {\n scale?: Scale;\n centered?: boolean;\n};\n\n/**\n * Contains a reference to the root SVG element and objects and configuration required by child nodes.\n */\nexport class SVGContext {\n private readonly _ref = createRef<SVGSVGElement>();\n\n private _scale: Scale;\n private _centered: boolean;\n private _size?: Size;\n private _center?: Point;\n\n readonly resized = new EventEmitter<SVGContext>();\n\n constructor({ scale = new Scale(), centered = true }: SVGContextOptions) {\n this._scale = scale;\n this._centered = centered;\n }\n\n get ref(): RefObject<SVGSVGElement> {\n return this._ref;\n }\n\n get svg(): SVGSVGElement {\n return this._ref.current!;\n }\n\n get scale(): Scale {\n return this._scale;\n }\n\n get center(): Point {\n return this._center!;\n }\n\n get size(): Size | undefined {\n return this._size;\n }\n\n /**\n * https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/viewBox\n */\n get viewBox() {\n const [x, y] = this.center;\n return `${x},${y},${this._size!.width},${this._size!.height}`;\n }\n\n setSize(size: Size): void {\n this._size = { ...size };\n this._center = this._centered ? [-Math.floor(size.width / 2), -Math.floor(size.height / 2)] : [0, 0];\n this.resized.emit(this);\n }\n\n setTransform(transform: ZoomTransform): void {\n if (this._scale.setTransform(transform)) {\n this.resized.emit(this);\n }\n }\n\n /**\n * https://developer.mozilla.org/en-US/docs/Web/API/Document/elementFromPoint\n * @param point\n */\n elementFromPoint(point: Point): Element {\n const [x, y] = point;\n const [cx, cy] = this._center!;\n return document.elementFromPoint(cx + x, cy + y)!; // TODO(burdon): Scale?\n }\n}\n\nconst SVGContextType = createContext<SVGContext | undefined>(undefined);\n\nexport const SVGContextProvider = SVGContextType.Provider;\n\n/**\n * Get SVG context from the React context.\n */\nexport const useSvgContext = (): SVGContext => {\n return useContext(SVGContextType) ?? raise(new Error('Missing SVGRoot'));\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { type ZoomBehavior, type ZoomTransform, select, zoom, zoomIdentity } from 'd3';\nimport defaultsDeep from 'lodash.defaultsdeep';\nimport { type RefObject, useEffect, useMemo, useRef } from 'react';\n\nimport { type SVGContext, useSvgContext } from './useSvgContext';\n\nexport type ZoomExtent = [min: number, max: number];\n\nexport type ZoomOptions = {\n enabled?: boolean;\n extent?: ZoomExtent;\n onDblClick?: (zoom: ZoomHandler) => void;\n};\n\nconst defaultZoomOptions: ZoomOptions = {\n enabled: true,\n extent: [1 / 4, 4],\n onDblClick: (zoom: ZoomHandler) => zoom.reset(),\n};\n\n/**\n * Zoom API.\n */\nexport class ZoomHandler {\n private readonly _zoom: ZoomBehavior<SVGGElement, unknown>;\n private readonly _options: ZoomOptions;\n private _enabled: boolean;\n\n constructor(\n private readonly _ref: RefObject<SVGGElement>,\n private readonly _context: SVGContext,\n options: ZoomOptions,\n ) {\n this._options = defaultsDeep({}, options, defaultZoomOptions);\n this._enabled = this._options.enabled ?? true;\n\n // https://github.com/d3/d3-zoom#zoom\n this._zoom = zoom<SVGGElement, unknown>().scaleExtent(this._options.extent ?? (defaultZoomOptions.extent as any));\n }\n\n /**\n * Gets the reference which the transform is applied to.\n */\n get ref() {\n return this._ref;\n }\n\n get zoom() {\n return this._zoom;\n }\n\n init(): this {\n this.setEnabled(this._enabled);\n this.reset(0);\n return this;\n }\n\n setEnabled(enable: boolean): this {\n if (enable) {\n select(this._context.svg)\n .call(this._zoom as any)\n .on(\n 'dblclick.zoom',\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n this._options?.onDblClick\n ? () => {\n this._options?.onDblClick!(this);\n }\n : null,\n );\n } else {\n select(this._context.svg).on('.zoom', null); // Unbind the internal event handler.\n }\n\n this._enabled = enable;\n return this;\n }\n\n reset(duration = 500): this {\n // TODO(burdon): Scale to midpoint in extent.\n const scale = 1; // this._options.extent?.[0] ?? 1;\n const transform = zoomIdentity.scale(scale);\n select(this._context.svg)\n .transition()\n .duration(duration)\n .call(this._zoom.transform as any, transform);\n\n return this;\n }\n}\n\n/**\n * Creates the zoom handler.\n * @param options\n */\nexport const useZoom = (options: ZoomOptions = defaultZoomOptions): ZoomHandler => {\n const context = useSvgContext();\n const ref = useRef<SVGGElement>(null);\n const handler = useMemo(() => new ZoomHandler(ref, context, options), [context, options]);\n\n // TODO(burdon): Distinguish between zoom and pan.\n useEffect(() => {\n // Transform container.\n handler.zoom.on('zoom', ({ transform }: { transform: ZoomTransform }) => {\n context.setTransform(transform); // Fires the resize event (e.g., to update grid).\n select(ref.current!).attr('transform', transform as any);\n });\n\n handler.init();\n }, [handler]);\n\n return handler;\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { type GeoStream, geoPath, select } from 'd3';\nimport { useEffect } from 'react';\nimport { feature, mesh } from 'topojson-client';\nimport { type GeometryCollection, type GeometryObject, type Objects, type Topology } from 'topojson-specification';\n\nimport { useSvgContext } from '../../hooks';\nimport { type Size } from '../../util';\n\nexport type MeshProps = {\n radius?: number;\n value?: number;\n};\n\n// https://d3og.com/mbostock/5249328\nexport const Mesh = ({ radius = 16, value = 0.5 }: MeshProps) => {\n const { svg, size } = useSvgContext();\n\n useEffect(() => {\n if (!size) {\n return;\n }\n\n const topology = hexTopology(size, radius, value);\n const projection = hexProjection(radius);\n const path = geoPath().projection(projection);\n\n // Replace the previous render: idempotent join on a single keyed root group, then\n // recreate the inner layers. Without this the effect re-runs (e.g. animating `value`\n // or on resize) appended new groups on top of the old ones instead of replacing them.\n const root = select(svg)\n .selectAll<SVGGElement, null>('g.dx-mesh-root')\n .data([null])\n .join('g')\n .classed('dx-mesh-root', true);\n root.selectAll('*').remove();\n\n root\n .append('g')\n .attr('class', 'hexagon')\n .selectAll('path')\n .data(topology.objects.hexagons.geometries)\n .enter()\n .append('path')\n .attr('d', (d) => path(feature(topology, d)))\n .attr('class', (d) => ((d.properties as Custom)?.fill ? 'fill' : null));\n\n root.append('path').datum(mesh(topology, topology.objects.hexagons)).attr('class', 'mesh').attr('d', path);\n\n const redraw = (border: any) => {\n border.attr(\n 'd',\n path(\n mesh(\n topology,\n topology.objects.hexagons,\n (a, b) => (a.properties as Custom).fill !== (b.properties as Custom).fill,\n ),\n ),\n );\n };\n\n root.append('path').attr('class', 'border').call(redraw);\n }, [svg, size, value, radius]);\n\n return null;\n};\n\ntype Custom = { fill: boolean };\n\ninterface HexObjects extends Objects<{ fill: boolean }> {\n hexagons: GeometryCollection<Custom>;\n}\n\nconst hexTopology = ({ width, height }: Size, radius: number, value = 1): Topology<HexObjects> => {\n const dx = radius * 2 * Math.sin(Math.PI / 3);\n const dy = radius * 1.5;\n const m = Math.ceil((height + radius) / dy) + 1;\n const n = Math.ceil(width / dx) + 1;\n const geometries: Array<GeometryObject<{ fill: boolean }>> = [];\n const arcs = [];\n\n for (let j = -1; j <= m; ++j) {\n for (let i = -1; i <= n; ++i) {\n const y = j * 2;\n const x = (i + (j & 1) / 2) * 2;\n arcs.push(\n [\n [x, y - 1],\n [1, 1],\n ],\n [\n [x + 1, y],\n [0, 1],\n ],\n [\n [x + 1, y + 1],\n [-1, 1],\n ],\n );\n }\n }\n\n for (let j = 0, q = 3; j < m; ++j, q += 6) {\n for (let i = 0; i < n; ++i, q += 3) {\n geometries.push({\n type: 'Polygon',\n arcs: [[q, q + 1, q + 2, ~(q + (n + 2 - (j & 1)) * 3), ~(q - 2), ~(q - (n + 2 + (j & 1)) * 3 + 2)]],\n properties: {\n fill: Math.random() > (i / n) * (1 / value),\n },\n });\n }\n }\n\n const hexagons: GeometryCollection<{ fill: boolean }> = { type: 'GeometryCollection', geometries };\n\n return {\n type: 'Topology',\n transform: { translate: [0, 0], scale: [1, 1] },\n objects: { hexagons },\n arcs,\n };\n};\n\nconst hexProjection = (radius: number) => {\n const dx = radius * 2 * Math.sin(Math.PI / 3);\n const dy = radius * 1.5;\n return {\n stream: (stream: GeoStream) => ({\n point: (x: number, y: number) => {\n stream.point((x * dx) / 2, ((y - (2 - (y & 1)) / 3) * dy) / 2);\n },\n lineStart: () => {\n stream.lineStart();\n },\n lineEnd: () => {\n stream.lineEnd();\n },\n polygonStart: () => {\n stream.polygonStart();\n },\n polygonEnd: () => {\n stream.polygonEnd();\n },\n }),\n };\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport React, { useEffect, useState } from 'react';\n\nimport { type ThemedClassName } from '@dxos/react-ui';\nimport { mx } from '@dxos/ui-theme';\n\nimport { useSvgContext } from '../../hooks';\n\nexport type FPSCorner = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';\n\nexport type FPSProps = ThemedClassName<{\n /** Which corner of the SVG viewport to anchor the readout to. */\n corner?: FPSCorner;\n /** Pixels of padding from the chosen corner. */\n margin?: number;\n}>;\n\nconst PADDING = 8;\n\n/**\n * Frame-rate readout — drops into an `<SVG.Root>` alongside `<SVG.Graph>` to display a\n * rolling 1-second average of the browser's repaint rate. Self-contained: runs its own\n * `requestAnimationFrame` loop, so the number reflects actual render rate independent of\n * whichever projector is driving the graph.\n *\n * Anchored to a corner of the SVG viewBox via the `<text>`'s `text-anchor` and `dy`\n * attributes — re-renders on `context.resized` so the position tracks container resizes.\n */\nexport const FPS = ({ classNames, corner = 'top-right', margin = PADDING }: FPSProps) => {\n const context = useSvgContext();\n const [size, setSize] = useState(context.size);\n const [fps, setFps] = useState<number | null>(null);\n\n // Keep `size` in sync with the SVG context so the corner anchor follows container resizes.\n useEffect(() => {\n setSize(context.size);\n return context.resized.on((ctx) => setSize(ctx.size));\n }, [context]);\n\n // Independent rAF loop — measures the browser's actual repaint rate, not any specific\n // projector's tick rate. Rolling 1-second window so the number is responsive but stable.\n useEffect(() => {\n let frames = 0;\n let windowStart = performance.now();\n let rafId = 0;\n const loop = (now: number) => {\n frames++;\n const elapsed = now - windowStart;\n if (elapsed >= 1000) {\n setFps((frames * 1000) / elapsed);\n frames = 0;\n windowStart = now;\n }\n rafId = requestAnimationFrame(loop);\n };\n rafId = requestAnimationFrame(loop);\n return () => cancelAnimationFrame(rafId);\n }, []);\n\n if (!size) {\n return null;\n }\n\n // The SVG.Root viewBox is centered ([-w/2, w/2] × [-h/2, h/2]); offset from the chosen\n // corner inward by `margin` and pick the corresponding text-anchor / dominant-baseline.\n const halfW = size.width / 2;\n const halfH = size.height / 2;\n const left = corner === 'top-left' || corner === 'bottom-left';\n const top = corner === 'top-left' || corner === 'top-right';\n const x = left ? -halfW + margin : halfW - margin;\n const y = top ? -halfH + margin : halfH - margin;\n const textAnchor = left ? 'start' : 'end';\n const dominantBaseline = top ? 'hanging' : 'alphabetic';\n\n return (\n <g className='dx-fps' style={{ pointerEvents: 'none' }}>\n <text\n x={x}\n y={y}\n textAnchor={textAnchor}\n dominantBaseline={dominantBaseline}\n className={mx('font-mono text-xs fill-neutral-500 tabular-nums', classNames)}\n >\n {fps == null ? '— fps' : `${fps.toFixed(0)} fps`}\n </text>\n </g>\n );\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport React from 'react';\n\nimport { type ThemedClassName } from '@dxos/react-ui';\nimport { mx } from '@dxos/ui-theme';\n\nimport { type GridOptions, useGrid } from '../../hooks';\n\nexport type GridProps = ThemedClassName<GridOptions>;\n\n/**\n * SVG grid wrapper.\n */\nexport const Grid = ({ classNames, ...props }: GridProps) => {\n const { ref } = useGrid(props);\n return <g ref={ref} className={mx('dx-grid', classNames)} />;\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { select } from 'd3';\nimport React, { useEffect, useRef } from 'react';\n\nimport { createMarkers } from '../../graph';\n\nexport type MarkersProps = {\n arrowSize?: number;\n className?: string;\n};\n\n/**\n * SVG markers wrapper.\n */\nexport const Markers = ({ arrowSize, className }: MarkersProps) => {\n const ref = useRef(null);\n useEffect(() => {\n select(ref.current).call(createMarkers({ arrowSize }));\n }, [ref]);\n\n return <defs ref={ref} className={className} />;\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { select } from 'd3';\nimport React, {\n type ComponentPropsWithoutRef,\n type PropsWithChildren,\n forwardRef,\n useEffect,\n useImperativeHandle,\n useMemo,\n useState,\n} from 'react';\n\nimport { type ThemedClassName } from '@dxos/react-ui';\nimport { composableProps } from '@dxos/react-ui';\nimport { mx } from '@dxos/ui-theme';\n\nimport { SVGContext, type SVGContextOptions, SVGContextProvider } from '../../hooks';\n\nexport type RootProps = ThemedClassName<PropsWithChildren<SVGContextOptions & ComponentPropsWithoutRef<'div'>>>;\n\n/**\n * Makes the SVG context available to child nodes.\n * Automatically resizes the SVG element, which expands to fit the container.\n *\n * NOTE: Uses `ResizeObserver` directly rather than `react-resize-detector` — the latter's\n * `useResizeDetector` was flaky in our Storybook environment (sometimes never fired its\n * initial measurement), leaving the SVG stuck at `opacity-0` with no rendered content.\n */\nexport const Root = forwardRef<SVGContext, RootProps>(({ children, scale, centered, ...props }, ref) => {\n const [container, setContainer] = useState<HTMLDivElement | null>(null);\n const [size, setSize] = useState<{ width: number; height: number }>({ width: 0, height: 0 });\n\n useEffect(() => {\n if (!container) {\n return;\n }\n const rect = container.getBoundingClientRect();\n setSize({ width: rect.width, height: rect.height });\n const observer = new ResizeObserver((entries) => {\n const entry = entries[0];\n if (!entry) {\n return;\n }\n const { width, height } = entry.contentRect;\n setSize((prev) => (prev.width === width && prev.height === height ? prev : { width, height }));\n });\n observer.observe(container);\n return () => observer.disconnect();\n }, [container]);\n\n const { width, height } = size;\n\n const context = useMemo<SVGContext>(() => {\n return new SVGContext({ scale, centered });\n }, [scale, centered]);\n\n useImperativeHandle(ref, () => context, [context]);\n\n useEffect(() => {\n if (width && height) {\n context.setSize({ width, height });\n select(context.svg)\n .attr('display', 'block')\n .attr('viewBox', context.viewBox)\n .attr('width', width)\n .attr('height', height);\n }\n }, [context, width, height]);\n\n const ready = width !== 0 && height !== 0;\n\n return (\n <SVGContextProvider value={context}>\n <div {...composableProps(props, { classNames: 'dx-expander' })} ref={setContainer}>\n <svg\n xmlns='http://www.w3.org/2000/svg'\n ref={context.ref}\n className={mx('transition-opacity opacity-0 duration-1000', ready && 'opacity-100')}\n >\n {ready && children}\n </svg>\n </div>\n </SVGContextProvider>\n );\n});\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport React, { type ReactNode, memo, useMemo } from 'react';\n\nimport { type ZoomExtent, useZoom } from '../../hooks';\n\nexport type ZoomProps = {\n extent?: ZoomExtent;\n className?: string;\n children?: ReactNode;\n};\n\n/**\n * SVG zoomable component wrapper.\n */\nexport const Zoom = memo(({ extent, className, children }: ZoomProps) => {\n const options = useMemo(() => ({ extent }), [JSON.stringify(extent)]); // TODO(burdon): Avoid stringify.\n const zoom = useZoom(options);\n\n return (\n <g ref={zoom.ref as any} className={className}>\n {children}\n </g>\n );\n});\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { type PropsWithChildren } from 'react';\n\nimport { type ThemedClassName } from '@dxos/react-ui';\n\nimport { Graph, type GraphProps as SVGGraphProps } from '../Graph';\nimport { Mesh, type MeshProps as SVGMeshProps } from '../Mesh';\nimport { FPS, type FPSProps as SVGFPSProps } from './FPS';\nimport { Grid, type GridProps as SVGGridProps } from './Grid';\nimport { Markers, type MarkersProps as SVGMarkersProps } from './Markers';\nimport { Root, type RootProps as SVGRootProps } from './Root';\nimport { type ZoomProps as SVGZoomProps, Zoom } from './Zoom';\n\nexport type SVGProps = PropsWithChildren<ThemedClassName>;\n\ntype SVG = {\n Root: typeof Root;\n Grid: typeof Grid;\n Markers: typeof Markers;\n Mesh: typeof Mesh;\n Zoom: typeof Zoom;\n Graph: typeof Graph;\n FPS: typeof FPS;\n};\n\nexport const SVG: SVG = {\n Root,\n Grid,\n Markers,\n Mesh,\n Zoom,\n Graph,\n FPS,\n};\n\nexport type { SVGRootProps, SVGGridProps, SVGMarkersProps, SVGZoomProps, SVGGraphProps, SVGMeshProps, SVGFPSProps };\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { easeCubicOut, select } from 'd3';\n\nimport { type D3Callable, type D3Selection } from '../util';\n\nconst PROP_PULSAR_ACTIVE = 'dx-pulsar-active';\n\n/**\n * Pulsar effect.\n */\nexport namespace Pulsar {\n export const has = (group: D3Selection<SVGGElement>) => group.select('circle.dx-pulsar').empty();\n\n export const create: D3Callable<SVGGElement> = (group, r: number, options: PulsarOptions = {}) => {\n const pulsar = group\n .append('circle')\n .classed('dx-pulsar', true)\n .classed('stroke-2 stroke-red-500 fill-none', true)\n .property(PROP_PULSAR_ACTIVE, true);\n\n startAnimation(pulsar, r, options);\n };\n\n export const remove: D3Callable<SVGGElement> = (group) => {\n group.select('circle.dx-pulsar').property(PROP_PULSAR_ACTIVE, false);\n };\n\n export type Options = PulsarOptions;\n}\n\ntype PulsarOptions = {\n period?: number;\n duration?: number;\n ratio?: number;\n};\n\nconst startAnimation = (pulsar: D3Selection<SVGCircleElement>, r: number, options: PulsarOptions = {}) => {\n const { period = 1_000, duration = 800, ratio = 3 } = options;\n return pulsar\n .attr('r', r)\n .attr('opacity', 1)\n .transition('pulsar')\n .delay(period - (Date.now() % period))\n .duration(Math.min(duration, period - 20))\n .ease(easeCubicOut)\n .attr('r', r * ratio)\n .attr('opacity', -0.1)\n .on('end', function () {\n if (select(this).property(PROP_PULSAR_ACTIVE)) {\n startAnimation(select(this), r, options);\n } else {\n select(this).remove();\n }\n });\n};\n"],
5
+ "mappings": ";;;;;;;AAIA,OAAOA,SAA6BC,YAAYC,aAAAA,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MJ,OAAO,kBAAA,EAAoBK,MAAK;UAEjFC,SAAkC,CAACF,OAAOG,GAAWC,UAAyB,CAAC,MAAC;AAC3F,UAAMC,SAASL,MACZM,OAAO,QAAA,EACPC,QAAQ,aAAa,IAAA,EACrBA,QAAQ,qCAAqC,IAAA,EAC7CC,SAASX,oBAAoB,IAAA;AAEhCY,mBAAeJ,QAAQF,GAAGC,OAAAA;EAC5B;UAEaM,SAAkC,CAACV,UAAAA;AAC9CA,UAAMJ,OAAO,kBAAA,EAAoBY,SAASX,oBAAoB,KAAA;EAChE;AAGF,GAlBiBC,WAAAA,SAAAA,CAAAA,EAAAA;AA0BjB,IAAMW,iBAAiB,CAACJ,QAAuCF,GAAWC,UAAyB,CAAC,MAAC;AACnG,QAAM,EAAEO,SAAS,KAAOC,WAAW,KAAKC,QAAQ,EAAC,IAAKT;AACtD,SAAOC,OACJS,KAAK,KAAKX,CAAAA,EACVW,KAAK,WAAW,CAAA,EAChBC,WAAW,QAAA,EACXC,MAAML,SAAUM,KAAKC,IAAG,IAAKP,MAAAA,EAC7BC,SAASO,KAAKC,IAAIR,UAAUD,SAAS,EAAA,CAAA,EACrCU,KAAK1B,aAAAA,EACLmB,KAAK,KAAKX,IAAIU,KAAAA,EACdC,KAAK,WAAW,IAAC,EACjBQ,GAAG,OAAO,WAAA;AACT,QAAI1B,SAAO,IAAI,EAAEY,SAASX,kBAAAA,GAAqB;AAC7CY,qBAAeb,SAAO,IAAI,GAAGO,GAAGC,OAAAA;IAClC,OAAO;AACLR,MAAAA,SAAO,IAAI,EAAEc,OAAM;IACrB;EACF,CAAA;AACJ;;",
6
+ "names": ["React", "forwardRef", "useEffect", "useImperativeHandle", "useMemo", "useRef", "combine", "log", "mx", "line", "select", "createLine", "createArrow", "length", "offset", "start", "el", "height", "attr", "append", "createDot", "size", "createMarkers", "arrowSize", "group", "selectAll", "data", "id", "generator", "className", "join", "d", "each", "i", "nodes", "call", "cluster", "d3Cluster", "curveBundle", "hierarchy", "lineRadial", "log", "easeCubic", "timer", "log", "invariant", "defaultIdAccessor", "node", "emptyGraph", "edges", "EventEmitter", "_listeners", "Set", "clear", "on", "onEvent", "add", "delete", "emit", "value", "forEach", "listener", "invariant", "__dxlog_file", "FractionUtil", "n", "validate", "Number", "isFinite", "Error", "d", "p", "Math", "t", "c", "i", "length", "factors", "f", "n1", "n2", "simplify", "getCircumferencePoints", "p1", "p2", "r1", "r2", "x1", "y1", "x2", "y2", "theta", "Math", "atan2", "sin", "cos", "PI", "normal", "dx", "dy", "len", "hypot", "offsetPoints", "points", "distance", "closed", "length", "out", "i", "p0", "n1", "n2", "nx", "ny", "norm", "push", "zoomIdentity", "Scale", "_transform", "_gridSize", "gridSize", "transform", "zoomIdentity", "setTransform", "x", "y", "k", "translate", "point", "model", "snapValues", "array", "map", "n", "FractionUtil", "round", "snapVertex", "sx", "sy", "snapBounds", "width", "height", "toValue", "value", "Math", "toNumber", "toValues", "values", "toPoint", "toBounds", "width2", "height2", "screen", "snapPoint", "divide", "toFraction", "toVertex", "bounds", "subtract", "Screen", "createBounds", "x1", "y1", "x2", "y2", "mod", "constrain", "center", "x", "Math", "min", "y", "width", "abs", "height", "max", "contains", "bounds", "point", "len", "p1", "p2", "sqrt", "pow", "normal", "v1", "v2", "p", "d2", "d", "len2", "t", "Vector", "toVertex", "x", "y", "FractionUtil", "toFraction", "toBounds", "width", "height", "center", "cx", "add", "multiply", "cy", "left", "right", "Projector", "updated", "EventEmitter", "_options", "_context", "options", "Object", "assign", "idAccessor", "defaultIdAccessor", "context", "refresh", "dragging", "onRefresh", "updateData", "data", "onUpdate", "emitUpdate", "kind", "emit", "layout", "clear", "onClear", "start", "onStart", "stop", "onStop", "GraphProjector", "Projector", "_layout", "context", "options", "_selection", "layout", "id", "Math", "random", "toString", "slice", "graph", "nodes", "edges", "selection", "numChildren", "node", "filter", "edge", "source", "idAccessor", "length", "reset", "emitUpdate", "mergeData", "data", "emptyGraph", "map", "current", "find", "n", "hidden", "type", "target", "Object", "assign", "onClear", "handleNodeClick", "_node", "_event", "__dxlog_file", "GraphRadialProjector", "findNode", "x", "onUpdate", "graph", "edges", "emitUpdate", "animate", "start", "Date", "options", "_timer", "timer", "t", "easeCubic", "layout", "nodes", "forEach", "node", "sy", "r", "sr", "tr", "d", "stop", "ty", "onTickFrame", "doRadialLayout", "i", "updateNode", "tx", "Object", "assign", "initialized", "sx", "a", "Math", "y", "__dxlog_file", "radius", "x", "y", "onUpdate", "graph", "edges", "doBundleLayout", "emitUpdate", "animate", "edge", "type", "points", "angle", "s", "length", "dataNodes", "ROOT_ID", "groupOf", "parent", "key", "undefined", "groupId", "GROUP_PREFIX", "groupIds", "set", "items", "node", "list", "childrenByParent", "push", "item", "d", "width", "margin", "options", "ringRadius", "Math", "max", "d3Cluster", "size", "separation", "hierById", "Map", "data", "id", "root", "cos", "sin", "updateNode", "leafR", "layout", "bundleEdges", "sourceHier", "targetHier", "get", "source", "target", "onTickFrame", "cluster", "d3Cluster", "hierarchy", "linkRadial", "log", "__dxlog_file", "HIER_EDGE_PREFIX", "GROUP_PREFIX", "CLUSTER_NODE_TYPE_GROUP", "radius", "x", "y", "toggleCollapsed", "id", "add", "animate", "onUpdate", "graph", "edges", "doClusterLayout", "edge", "type", "t", "cartesianToPolar", "target", "path", "source", "s", "items", "ROOT_ID", "rootId", "rootCollapsed", "node", "dataNodes", "groupOf", "parent", "key", "undefined", "groupId", "groupIds", "set", "groupKey", "list", "childrenByParent", "push", "item", "d", "width", "margin", "options", "ringRadius", "Math", "max", "d3Cluster", "size", "groupR", "groupRadius", "rootR", "rootRadius", "CLUSTER_NODE_TYPE_ROOT", "prevStubsById", "angle", "cos", "sin", "data", "updateNode", "leafR", "isRoot", "stub", "label", "groupLabel", "syntheticNodes", "visibleLeafIds", "parentStub", "targetX", "targetY", "hidden", "nextNodes", "nodes", "tid", "sourceNode", "targetNode", "hierarchyEdges", "sid", "layout", "onTickFrame", "drag", "pointer", "select", "defaultDragOptions", "linkMod", "freezeMod", "createGraphDrag", "context", "projector", "options", "mode", "source", "target", "offset", "moved", "keyMod", "event", "key", "modKey", "undefined", "drag", "filter", "ctrlKey", "on", "d", "pointer", "parentElement", "onDrop", "sourceEvent", "parent", "closest", "select", "classed", "raise", "dx", "dy", "x", "y", "point", "svg", "attr", "subject", "fx", "fy", "refresh", "onDrag", "findNode", "forceCenter", "forceCollide", "forceLink", "forceManyBody", "forceRadial", "forceSimulation", "forceX", "forceY", "log", "forceX", "forceY", "forcePoint", "x", "y", "strength", "fx", "undefined", "fy", "force", "alpha", "initialize", "nodes", "random", "__dxlog_file", "value", "manyBody", "point", "_simulation", "simulation", "restart", "findNode", "x", "onStart", "propagating", "delay", "updateForces", "_timeout", "setTimeout", "onStop", "onRefresh", "center", "forces", "onUpdate", "graph", "edges", "updateLayout", "cx", "cy", "r", "undefined", "Object", "assign", "node", "linkForce", "getValue", "options", "log", "nodes", "force", "maybeForce", "distance", "config", "iterations", "distanceMax", "collide", "radius", "strength", "y", "log", "__dxlog_file", "GraphHierarchicalProjector", "graph", "edges", "selection", "emitUpdate", "selected", "layout", "node", "doHierarchicalLayout", "children", "filter", "edge", "source", "id", "target", "updateNode", "ty", "i", "tx", "animate", "log", "__dxlog_file", "log", "graph", "edges", "animate", "doLatticeLayout", "count", "nodes", "columns", "Math", "sqrt", "margin", "options", "height", "context", "innerW", "max", "width", "innerH", "gridW", "cellSize", "offsetX", "offsetY", "forEach", "node", "i", "ty", "updateNode", "tx", "r", "cluster", "d3Cluster", "hierarchy", "linkRadial", "log", "__dxlog_file", "RELATION_PREFIX", "HIER_EDGE_PREFIX", "PLEXUS_NODE_TYPE_RELATION", "radius", "x", "y", "onUpdate", "graph", "edges", "layout", "doPlexusLayout", "animate", "edge", "type", "t", "cartesianToPolar", "target", "path", "source", "s", "dataNodes", "forEach", "placed", "Set", "focusId", "relation", "group", "label", "leaves", "groups", "push", "neighbour", "items", "id", "parent", "relationLabel", "node", "leaf", "list", "childrenByParent", "item", "focusNode", "d", "width", "margin", "options", "ringRadius", "Math", "max", "d3Cluster", "size", "separation", "leafRadius", "focusR", "prevStubsById", "set", "root", "cos", "sin", "data", "updateNode", "leafR", "relationR", "stub", "relationStubs", "nextNodes", "sid", "tid", "sourceNode", "targetNode", "undefined", "onTickFrame", "outgoing", "incoming", "key", "log", "__dxlog_file", "GraphRelationalProjector", "graph", "edges", "selection", "emitUpdate", "selected", "layout", "node", "doRelationalLayout", "forEach", "type", "undefined", "edge", "order", "children", "target", "parents", "source", "updateNode", "ty", "i", "tx", "animate", "timer", "log", "__dxlog_file", "DEFAULTS", "spawnRadius", "maxVelocity", "alignment", "cohesion", "separation", "cursorRepel", "avoidance", "trailLength", "findNode", "undefined", "y", "onUpdate", "graph", "edges", "initializeNodes", "emitUpdate", "onStart", "onStop", "onRefresh", "layout", "initialized", "theta", "Math", "random", "r", "node", "cos", "sin", "phi", "vx", "speed", "vy", "ax", "ay", "startTimer", "stopTimer", "timer", "size", "nodes", "alignmentW", "separationW", "avoidanceW", "cursor", "b1", "alignX", "alignY", "alignActive", "cohX", "cohY", "cohActive", "sepX", "sepY", "sepActive", "avoidX", "avoidY", "avoidActive", "dy", "distSq", "dx", "dist", "sqrt", "SWARMMATE_RADIUS", "b2", "slen", "sx", "sy", "weight", "applyForce", "b", "vlen", "history", "x", "length", "width", "wrapped", "halfH", "height", "edge", "source", "tx", "target", "ty", "path", "easeCubicOut", "line", "polygonHull", "select", "Clipper", "log", "easeLinear", "interpolate", "select", "createBullets", "group", "nodeId", "options", "selection", "max", "radius", "delay", "minDuration", "maxDuration", "each", "d", "i", "edges", "source", "target", "id", "path", "p", "node", "getPointAtLength", "bullet", "append", "attr", "x", "y", "transition", "duration", "Math", "random", "ease", "tween", "length", "getTotalLength", "r", "t", "point", "on", "remove", "num", "selectAll", "size", "call", "Renderer", "_options", "_context", "_root", "options", "Object", "assign", "idAccessor", "defaultIdAccessor", "context", "root", "current", "applyPositions", "layout", "render", "__dxlog_file", "createLine", "line", "root", "replaceChildren", "layout", "log", "select", "_options", "edges", "graph", "source", "target", "component", "id", "selectAll", "points", "nodes", "filter", "node", "hullPoints", "co", "Clipper", "ClipperOffset", "clipperPath", "x", "scale", "AddPath", "Execute", "solution", "offset", "X", "d", "transition", "easeCubicOut", "duration", "attr", "call", "updateNode", "exit", "EDGE_FADE_MS", "updateEdge", "options", "applyNode", "edge", "parentElement", "datum", "group", "each", "renderCustomShape", "useCustom", "onNodeClick", "g", "append", "onNodePointerEnter", "event", "highlightOnHover", "applyHoverHighlight", "closest", "hitTarget", "onNodePointerLeave", "on", "raise", "classed", "setTimeout", "i", "classes", "applyClasses", "data", "error", "px", "py", "dx", "groupOrTransition", "bbox", "width", "onLinkClick", "outgoing", "Set", "incoming", "focusedId", "path", "style", "groupSel", "shape", "connected", "className", "value", "adj", "visited", "componentIds", "stack", "push", "current", "components", "DEFAULT_DURATION", "DEFAULT_OFFSET", "getTarget", "node", "tx", "ty", "x", "y", "appendRadialLeafLabel", "group", "label", "r", "options", "delay", "duration", "offset", "className", "targetX", "targetY", "angleDeg", "Math", "atan2", "PI", "flipped", "append", "attr", "style", "text", "transition", "appendRadialGroupLabel", "appendRootLabel", "line", "createLine", "line", "linkerRenderer", "root", "source", "target", "point", "selectAll", "data", "id", "join", "attr", "getCircumferencePoints", "x", "y", "r", "line", "range", "select", "useEffect", "useMemo", "useRef", "createContext", "useContext", "createRef", "raise", "SVGContext", "_ref", "createRef", "_scale", "_centered", "_size", "_center", "resized", "EventEmitter", "scale", "Scale", "centered", "ref", "svg", "current", "center", "size", "viewBox", "x", "y", "width", "height", "setSize", "Math", "floor", "emit", "setTransform", "transform", "elementFromPoint", "point", "cx", "cy", "document", "SVGContextType", "createContext", "undefined", "SVGContextProvider", "Provider", "useSvgContext", "useContext", "raise", "Error", "createLine", "line", "createGrid", "context", "options", "size", "paths", "width", "height", "x", "y", "k", "scale", "transform", "s", "w", "h", "dx", "dy", "axis", "push", "id", "class", "path", "map", "join", "grid", "mod", "n", "delta", "Math", "floor", "majorSize", "gridSize", "xMajor", "range", "yMajor", "major", "filter", "minorSize", "pow", "round", "log2", "xMinor", "yMinor", "minor", "indexOf", "defaultGridOptions", "visible", "GridController", "_visible", "_ref", "_context", "_options", "ref", "draw", "root", "select", "current", "selectAll", "data", "style", "attr", "d", "setVisible", "useGrid", "useRef", "useSvgContext", "controller", "useMemo", "useEffect", "resized", "on", "select", "zoom", "zoomIdentity", "defaultsDeep", "useEffect", "useMemo", "useRef", "defaultZoomOptions", "enabled", "extent", "onDblClick", "zoom", "reset", "ZoomHandler", "_zoom", "_options", "_enabled", "_ref", "_context", "options", "defaultsDeep", "scaleExtent", "ref", "init", "setEnabled", "enable", "select", "svg", "call", "on", "duration", "scale", "transform", "zoomIdentity", "transition", "useZoom", "context", "useSvgContext", "useRef", "handler", "useMemo", "useEffect", "setTransform", "current", "attr", "__dxlog_file", "GraphInner", "graphRef", "useRef", "drag", "projector", "projectorProp", "useMemo", "renderer", "rendererProp", "props", "end", "arrows", "onSelect", "onNodePointerEnter", "onInspect", "attributes", "renderNode", "highlightOnHover", "applyNode", "edgeOpacity", "useImperativeHandle", "model", "repaint", "findNode", "id", "useEffect", "updateData", "undefined", "updated", "render", "layout", "log", "stop", "svg", "handleMove", "event", "onPointerMove", "target", "point", "y", "clientY", "modelPoint", "x", "handleLeave", "addEventListener", "removeEventListener", "style", "previousPointerEvents", "context", "onPointerLeave", "classNames", "geoPath", "select", "useEffect", "feature", "mesh", "Mesh", "radius", "value", "svg", "size", "useSvgContext", "useEffect", "topology", "hexTopology", "projection", "hexProjection", "path", "geoPath", "root", "select", "selectAll", "data", "join", "classed", "remove", "append", "attr", "objects", "hexagons", "geometries", "enter", "d", "feature", "properties", "fill", "datum", "mesh", "redraw", "border", "a", "b", "call", "width", "height", "dx", "Math", "sin", "PI", "dy", "m", "ceil", "n", "arcs", "j", "i", "y", "x", "push", "q", "type", "random", "transform", "translate", "scale", "stream", "point", "lineStart", "lineEnd", "polygonStart", "polygonEnd", "React", "useEffect", "useState", "mx", "PADDING", "FPS", "classNames", "corner", "margin", "context", "useSvgContext", "size", "setSize", "useState", "fps", "setFps", "useEffect", "resized", "on", "ctx", "frames", "windowStart", "performance", "now", "rafId", "loop", "elapsed", "requestAnimationFrame", "cancelAnimationFrame", "halfW", "width", "halfH", "height", "left", "top", "x", "y", "textAnchor", "dominantBaseline", "React", "g", "className", "style", "pointerEvents", "text", "mx", "toFixed", "React", "mx", "Grid", "classNames", "props", "ref", "useGrid", "React", "g", "className", "mx", "select", "React", "useEffect", "useRef", "Markers", "arrowSize", "className", "ref", "useRef", "useEffect", "select", "current", "call", "createMarkers", "React", "defs", "select", "React", "forwardRef", "useEffect", "useImperativeHandle", "useMemo", "useState", "composableProps", "mx", "Root", "forwardRef", "children", "scale", "centered", "props", "ref", "container", "setContainer", "useState", "size", "setSize", "width", "height", "useEffect", "rect", "getBoundingClientRect", "observer", "ResizeObserver", "entries", "entry", "contentRect", "prev", "observe", "disconnect", "context", "useMemo", "SVGContext", "useImperativeHandle", "select", "svg", "attr", "viewBox", "ready", "React", "SVGContextProvider", "value", "div", "composableProps", "classNames", "xmlns", "className", "mx", "React", "memo", "useMemo", "Zoom", "memo", "extent", "className", "children", "options", "useMemo", "JSON", "stringify", "zoom", "useZoom", "React", "g", "ref", "SVG", "Root", "Grid", "Markers", "Mesh", "Zoom", "Graph", "FPS", "easeCubicOut", "select", "PROP_PULSAR_ACTIVE", "Pulsar", "has", "group", "empty", "create", "r", "options", "pulsar", "append", "classed", "property", "startAnimation", "remove", "period", "duration", "ratio", "attr", "transition", "delay", "Date", "now", "Math", "min", "ease", "on"]
7
7
  }