@dxos/react-ui-graph 0.8.3 → 0.8.4-main.1c7ec43d41

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 (126) hide show
  1. package/README.md +5 -7
  2. package/dist/lib/browser/chunk-EASNZZ7B.mjs +52 -0
  3. package/dist/lib/browser/chunk-EASNZZ7B.mjs.map +7 -0
  4. package/dist/lib/browser/index.mjs +1109 -319
  5. package/dist/lib/browser/index.mjs.map +4 -4
  6. package/dist/lib/browser/meta.json +1 -1
  7. package/dist/lib/browser/testing/index.mjs +19 -19
  8. package/dist/lib/browser/testing/index.mjs.map +3 -3
  9. package/dist/lib/node-esm/chunk-JSE2X4ML.mjs +54 -0
  10. package/dist/lib/node-esm/chunk-JSE2X4ML.mjs.map +7 -0
  11. package/dist/lib/node-esm/index.mjs +1109 -319
  12. package/dist/lib/node-esm/index.mjs.map +4 -4
  13. package/dist/lib/node-esm/meta.json +1 -1
  14. package/dist/lib/node-esm/testing/index.mjs +19 -19
  15. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  16. package/dist/types/src/components/Graph/Graph.d.ts +4 -5
  17. package/dist/types/src/components/Graph/Graph.d.ts.map +1 -1
  18. package/dist/types/src/components/Graph/Graph.stories.d.ts +21 -12
  19. package/dist/types/src/components/Graph/Graph.stories.d.ts.map +1 -1
  20. package/dist/types/src/components/Mesh/Mesh.d.ts.map +1 -1
  21. package/dist/types/src/components/Mesh/Mesh.stories.d.ts +10 -6
  22. package/dist/types/src/components/Mesh/Mesh.stories.d.ts.map +1 -1
  23. package/dist/types/src/components/SVG/Grid.d.ts.map +1 -1
  24. package/dist/types/src/components/SVG/Markers.d.ts.map +1 -1
  25. package/dist/types/src/components/SVG/Root.d.ts +4 -4
  26. package/dist/types/src/components/SVG/Root.d.ts.map +1 -1
  27. package/dist/types/src/components/SVG/SVG.d.ts +14 -17
  28. package/dist/types/src/components/SVG/SVG.d.ts.map +1 -1
  29. package/dist/types/src/components/SVG/Svg.stories.d.ts +11 -9
  30. package/dist/types/src/components/SVG/Svg.stories.d.ts.map +1 -1
  31. package/dist/types/src/components/SVG/Zoom.d.ts.map +1 -1
  32. package/dist/types/src/fx/fx.stories.d.ts +16 -15
  33. package/dist/types/src/fx/fx.stories.d.ts.map +1 -1
  34. package/dist/types/src/fx/pulsar.d.ts.map +1 -1
  35. package/dist/types/src/graph/markers.d.ts.map +1 -1
  36. package/dist/types/src/graph/projector/graph-drag.d.ts +1 -1
  37. package/dist/types/src/graph/projector/graph-drag.d.ts.map +1 -1
  38. package/dist/types/src/graph/projector/graph-force-projector.d.ts +2 -2
  39. package/dist/types/src/graph/projector/graph-force-projector.d.ts.map +1 -1
  40. package/dist/types/src/graph/projector/graph-forces.d.ts.map +1 -1
  41. package/dist/types/src/graph/projector/graph-hierarchical-projector.d.ts +2 -2
  42. package/dist/types/src/graph/projector/graph-hierarchical-projector.d.ts.map +1 -1
  43. package/dist/types/src/graph/projector/graph-projector.d.ts +4 -4
  44. package/dist/types/src/graph/projector/graph-projector.d.ts.map +1 -1
  45. package/dist/types/src/graph/projector/graph-radial-projector.d.ts +2 -2
  46. package/dist/types/src/graph/projector/graph-radial-projector.d.ts.map +1 -1
  47. package/dist/types/src/graph/projector/graph-relational-projector.d.ts +2 -2
  48. package/dist/types/src/graph/projector/graph-relational-projector.d.ts.map +1 -1
  49. package/dist/types/src/graph/projector/projector.d.ts.map +1 -1
  50. package/dist/types/src/graph/renderer/bullets.d.ts.map +1 -1
  51. package/dist/types/src/graph/renderer/graph-renderer.d.ts +1 -1
  52. package/dist/types/src/graph/renderer/graph-renderer.d.ts.map +1 -1
  53. package/dist/types/src/graph/renderer/renderer.d.ts.map +1 -1
  54. package/dist/types/src/graph/types.d.ts +1 -1
  55. package/dist/types/src/graph/types.d.ts.map +1 -1
  56. package/dist/types/src/hooks/useGrid.d.ts.map +1 -1
  57. package/dist/types/src/hooks/useStateRef.d.ts.map +1 -1
  58. package/dist/types/src/hooks/useSvgContext.d.ts.map +1 -1
  59. package/dist/types/src/hooks/useZoom.d.ts.map +1 -1
  60. package/dist/types/src/stories/hooks.stories.d.ts +15 -10
  61. package/dist/types/src/stories/hooks.stories.d.ts.map +1 -1
  62. package/dist/types/src/testing/data.d.ts +5 -5
  63. package/dist/types/src/testing/data.d.ts.map +1 -1
  64. package/dist/types/src/testing/hooks.d.ts +2 -16
  65. package/dist/types/src/testing/hooks.d.ts.map +1 -1
  66. package/dist/types/src/testing/model.d.ts +4 -8
  67. package/dist/types/src/testing/model.d.ts.map +1 -1
  68. package/dist/types/src/util/events.d.ts.map +1 -1
  69. package/dist/types/src/util/fraction.d.ts +1 -1
  70. package/dist/types/src/util/fraction.d.ts.map +1 -1
  71. package/dist/types/src/util/index.d.ts +2 -2
  72. package/dist/types/src/util/index.d.ts.map +1 -1
  73. package/dist/types/src/util/points.d.ts.map +1 -1
  74. package/dist/types/src/util/scale.d.ts.map +1 -1
  75. package/dist/types/src/util/screen.d.ts +1 -1
  76. package/dist/types/src/util/screen.d.ts.map +1 -1
  77. package/dist/types/src/util/vector.d.ts +1 -1
  78. package/dist/types/src/util/vector.d.ts.map +1 -1
  79. package/dist/types/tsconfig.tsbuildinfo +1 -1
  80. package/package.json +32 -34
  81. package/src/components/Graph/Graph.stories.tsx +73 -69
  82. package/src/components/Graph/Graph.tsx +25 -20
  83. package/src/components/Mesh/Mesh.stories.tsx +10 -9
  84. package/src/components/Mesh/Mesh.tsx +1 -1
  85. package/src/components/SVG/Grid.tsx +2 -2
  86. package/src/components/SVG/Markers.tsx +1 -1
  87. package/src/components/SVG/Root.tsx +14 -7
  88. package/src/components/SVG/SVG.tsx +13 -4
  89. package/src/components/SVG/Svg.stories.tsx +23 -19
  90. package/src/components/SVG/Zoom.tsx +1 -1
  91. package/src/fx/fx.stories.tsx +18 -15
  92. package/src/graph/projector/graph-drag.ts +1 -1
  93. package/src/graph/projector/graph-force-projector.ts +3 -3
  94. package/src/graph/projector/graph-forces.ts +1 -1
  95. package/src/graph/projector/graph-hierarchical-projector.ts +4 -4
  96. package/src/graph/projector/graph-projector.ts +5 -5
  97. package/src/graph/projector/graph-radial-projector.ts +3 -3
  98. package/src/graph/projector/graph-relational-projector.ts +4 -4
  99. package/src/graph/projector/projector.ts +1 -1
  100. package/src/graph/renderer/bullets.ts +1 -1
  101. package/src/graph/renderer/graph-renderer.ts +7 -7
  102. package/src/graph/renderer/renderer.ts +1 -1
  103. package/src/graph/types.ts +1 -1
  104. package/src/hooks/useStateRef.ts +1 -1
  105. package/src/hooks/useZoom.ts +1 -1
  106. package/src/stories/hooks.stories.tsx +43 -36
  107. package/src/testing/data.ts +14 -14
  108. package/src/testing/hooks.ts +5 -5
  109. package/src/testing/model.ts +6 -6
  110. package/src/util/fraction.ts +1 -1
  111. package/src/util/index.ts +2 -2
  112. package/src/util/screen.test.ts +1 -1
  113. package/src/util/screen.ts +1 -1
  114. package/src/util/vector.ts +1 -1
  115. package/styles/graph.css +292 -43
  116. package/dist/lib/browser/chunk-2YMRPQU7.mjs +0 -979
  117. package/dist/lib/browser/chunk-2YMRPQU7.mjs.map +0 -7
  118. package/dist/lib/node/chunk-WFHWEMPB.cjs +0 -919
  119. package/dist/lib/node/chunk-WFHWEMPB.cjs.map +0 -7
  120. package/dist/lib/node/index.cjs +0 -1547
  121. package/dist/lib/node/index.cjs.map +0 -7
  122. package/dist/lib/node/meta.json +0 -1
  123. package/dist/lib/node/testing/index.cjs +0 -214
  124. package/dist/lib/node/testing/index.cjs.map +0 -7
  125. package/dist/lib/node-esm/chunk-ITHTKQOY.mjs +0 -981
  126. package/dist/lib/node-esm/chunk-ITHTKQOY.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 createGraphDrag,\n GraphForceProjector,\n type GraphLayoutNode,\n type GraphProjector,\n GraphRenderer,\n type GraphRendererOptions,\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>();\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 GraphProjector } from './graph-projector';\nimport { type SVGContext } from '../../hooks';\nimport { type Point } from '../../util';\nimport { type GraphLayoutNode } from '../types';\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 { defaultIdAccessor, type IdAccessor } 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 SelectionModel, type Graph } from '@dxos/graph';\n\nimport { Projector, type ProjectorOptions } from './projector';\nimport { type SVGContext } from '../../hooks';\nimport { emptyGraph, type GraphLayout, type GraphLayoutNode } from '../types';\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 { forcePoint } from './graph-forces';\nimport { GraphProjector, type GraphProjectorOptions } from './graph-projector';\nimport { type GraphLayoutEdge, type GraphLayoutNode } from '../types';\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, forceX, forceY, type SimulationLinkDatum, type SimulationNodeDatum } 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 GraphProjectorOptions } from './graph-projector';\nimport { GraphRadialProjector, layoutRadial, updateNode } from './graph-radial-projector';\nimport { type GraphLayoutNode } from '../types';\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 { easeCubic, timer, type Timer } from 'd3';\n\nimport { type Graph } from '@dxos/graph';\nimport { log } from '@dxos/log';\n\nimport { GraphProjector, type GraphProjectorOptions } from './graph-projector';\nimport { type Point } from '../../util';\nimport { type GraphLayoutNode } from '../types';\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 GraphProjectorOptions } from './graph-projector';\nimport { GraphRadialProjector, layoutHorizontal, layoutRadial, updateNode } from './graph-radial-projector';\nimport { type GraphLayoutNode } from '../types';\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 { line, select, polygonHull, easeCubicOut } from 'd3';\nimport * as Clipper from 'js-clipper';\n\nimport { log } from '@dxos/log';\n\nimport { createBullets } from './bullets';\nimport { Renderer, type RendererOptions } from './renderer';\nimport { getCircumferencePoints, type D3Selection, type D3Callable, type Point } from '../../util';\nimport { type GraphLayout, type GraphLayoutEdge, type GraphLayoutNode } from '../types';\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 D3Selection, type D3Callable } 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 { defaultIdAccessor, type IdAccessor } 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 { geoPath, select, type GeoStream } 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 { useGrid, type GridOptions } 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();\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, { forwardRef, type PropsWithChildren, useEffect, useMemo, useImperativeHandle } 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 { useZoom, type ZoomExtent } 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 { Grid, type GridProps as SVGGridProps } from './Grid';\nimport { Markers, type MarkersProps as SVGMarkersProps } from './Markers';\nimport { Root, type RootProps as SVGRootProps } from './Root';\nimport { Zoom, type ZoomProps as SVGZoomProps } from './Zoom';\nimport { Graph, type GraphProps as SVGGraphProps } from '../Graph';\nimport { Mesh, type MeshProps as SVGMeshProps } from '../Mesh';\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,CAACC,OAAAA;AACC,QAAMC,SAASJ,SAAS;AACxBG,KAAGE,KAAK,eAAeL,SAAS,CAAA,EAC7BK,KAAK,gBAAgBD,SAAS,CAAA,EAC9BC,KAAK,WAAW,IAAIL,MAAAA,KAAWI,MAAAA,IAAUJ,SAAS,CAAA,IAAKI,SAAS,CAAA,EAAG,EACnEC,KAAK,UAAU,MAAA,EACfA,KAAK,QAAQJ,MAAAA,EACbK,OAAO,MAAA,EACPD,KAAK,QAAQ,MAAA,EAEbA,KAAK,UAAU,gBAAA,EACfA,KACC,KACAR,WAAW;IACTK,QAAQ;MAACF;MAAQI;QAAU;MAAC,CAACJ;MAAQ,CAACI;;IACtC;MAAC;MAAG;;IACJF,QAAQ;MAACF;MAAQ,CAACI;QAAU;MAAC,CAACJ;MAAQI;;GACvC,CAAA;AAEP;AAEF,IAAMG,YACJ,CAACC,SACD,CAACL,OAAAA;AACCA,KAAGE,KAAK,eAAeG,OAAO,CAAA,EAC3BH,KAAK,gBAAgBG,OAAO,CAAA,EAC5BH,KAAK,WAAW,IAAIG,IAAAA,K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X,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", "_context", "options", "updated", "EventEmitter", "_options", "Object", "assign", "idAccessor", "defaultIdAccessor", "context", "refresh", "dragging", "onRefresh", "updateData", "data", "onUpdate", "emitUpdate", "emit", "layout", "clear", "onClear", "start", "onStart", "stop", "onStop", "GraphProjector", "Projector", "context", "options", "_selection", "layout", "_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", "forces", "simulation", "restart", "alpha", "findNode", "x", "y", "radius", "find", "onStart", "clearTimeout", "_timeout", "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", "findNode", "x", "y", "radius", "undefined", "onUpdate", "graph", "log", "nodes", "length", "edges", "mergeData", "doRadialLayout", "animate", "start", "Date", "now", "options", "duration", "_timer", "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", "line", "select", "polygonHull", "easeCubicOut", "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", "_context", "_root", "options", "_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", "useMemo", "useImperativeHandle", "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-drag.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-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/hooks/useGrid.ts", "../../../src/hooks/useSvgContext.ts", "../../../src/hooks/useZoom.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 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\nexport type GraphProps<Node extends Graph$.Node.Any = any, Edge extends Graph$.Edge.Any = any> = ThemedClassName<\n Pick<GraphRendererOptions<Node>, 'labels' | 'subgraphs' | 'attributes'> & {\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 onInspect?: (node: GraphLayoutNode<Node>, event: MouseEvent) => 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 ...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 onNodeClick: onSelect,\n onNodePointerEnter: onInspect,\n });\n }\n\n return { projector, renderer };\n }, [context, projectorProp, rendererProp, 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 projector.updateData(model?.graph);\n\n return 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 }) => {\n try {\n renderer.render(layout);\n } catch (error) {\n log.catch(error);\n void projector.stop();\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 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 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\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 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\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 * 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';\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 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';\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.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 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 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 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 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';\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 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 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\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');\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-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 // 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 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 // 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/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} from 'react';\nimport { useResizeDetector } from 'react-resize-detector';\n\nimport { type ThemedClassName } from '@dxos/react-ui';\nimport { composableProps, 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 */\nexport const Root = forwardRef<SVGContext, RootProps>(({ children, scale, centered, ...props }, ref) => {\n const { ref: containerRef, width = 0, height = 0 } = useResizeDetector({ refreshRate: 200 });\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={containerRef}>\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 { 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};\n\nexport const SVG: 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,OAAOA,SAA6BC,YAAYC,aAAAA,YAAWC,qBAAqBC,WAAAA,UAASC,UAAAA,eAAc;AAEvG,SAASC,eAAe;AAExB,SAASC,OAAAA,YAAW;AAEpB,SAASC,UAAU;;;ACNnB,SAASC,MAAMC,cAAc;AAI7B,IAAMC,aAAaF,KAAAA;AAMnB,IAAMG,cACJ,CAACC,QAAgBC,QAAgBC,UACjC,CAACC,OAAAA;AACC,QAAMC,SAASJ,SAAS;AACxBG,KAAGE,KAAK,eAAeL,SAAS,CAAA,EAC7BK,KAAK,gBAAgBD,SAAS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S,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", "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", "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", "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", "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", "nodes", "force", "maybeForce", "distance", "config", "iterations", "distanceMax", "collide", "radius", "strength", "y", "log", "easeCubic", "timer", "log", "__dxlog_file", "GraphRadialProjector", "findNode", "x", "onUpdate", "graph", "edges", "doRadialLayout", "animate", "_timer", "timer", "t", "easeCubic", "layout", "nodes", "forEach", "node", "sy", "r", "sr", "tr", "d", "emitUpdate", "stop", "ty", "i", "updateNode", "tx", "Object", "assign", "initialized", "sx", "a", "start", "Math", "y", "__dxlog_file", "GraphHierarchicalProjector", "graph", "edges", "selection", "selected", "getSelectedIds", "layout", "node", "doHierarchicalLayout", "children", "filter", "edge", "source", "id", "target", "updateNode", "ty", "i", "tx", "animate", "log", "__dxlog_file", "GraphRelationalProjector", "graph", "edges", "selection", "selected", "getSelectedIds", "layout", "node", "doRelationalLayout", "forEach", "type", "undefined", "edge", "order", "children", "target", "parents", "source", "updateNode", "ty", "i", "tx", "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", "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", "invariant", "__dxlog_file", "_options", "_root", "Object", "idAccessor", "options", "context", "root", "invariant", "__dxlog_file", "createLine", "line", "log", "layout", "root", "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", "ease", "easeCubicOut", "duration", "attr", "on", "updateNode", "b", "order", "circle", "group", "options", "onNodeClick", "g", "append", "onNodePointerEnter", "event", "parentElement", "classed", "setTimeout", "i", "classes", "applyClasses", "data", "error", "groupOrTransition", "px", "py", "dx", "bbox", "width", "onLinkClick", "edge", "className", "value", "adj", "visited", "Set", "componentIds", "stack", "push", "current", "components", "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", "onNodeClick", "onNodePointerEnter", "context", "useImperativeHandle", "model", "repaint", "findNode", "id", "useEffect", "combine", "subscribe", "undefined", "updated", "layout", "log", "error", "stop", "classNames", "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", "composableProps", "mx", "Root", "forwardRef", "children", "scale", "centered", "props", "ref", "containerRef", "width", "height", "useResizeDetector", "refreshRate", "context", "useMemo", "SVGContext", "useImperativeHandle", "useEffect", "setSize", "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", "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
  }