@lincyaw/aegis-ui 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ui/DataTable.cjs +1 -1
- package/dist/components/ui/DataTable.cjs.map +1 -1
- package/dist/components/ui/DataTable.js +205 -207
- package/dist/components/ui/DataTable.js.map +1 -1
- package/dist/components/ui/DetailBeside.cjs +2 -0
- package/dist/components/ui/DetailBeside.cjs.map +1 -0
- package/dist/components/ui/DetailBeside.d.ts +37 -0
- package/dist/components/ui/DetailBeside.js +113 -0
- package/dist/components/ui/DetailBeside.js.map +1 -0
- package/dist/components/ui/FileTree.cjs +1 -1
- package/dist/components/ui/FileTree.cjs.map +1 -1
- package/dist/components/ui/FileTree.js +118 -111
- package/dist/components/ui/FileTree.js.map +1 -1
- package/dist/components/ui/ServiceMap.cjs +1 -1
- package/dist/components/ui/ServiceMap.cjs.map +1 -1
- package/dist/components/ui/ServiceMap.js +305 -262
- package/dist/components/ui/ServiceMap.js.map +1 -1
- package/dist/components/ui/TraceTree.cjs +1 -1
- package/dist/components/ui/TraceTree.cjs.map +1 -1
- package/dist/components/ui/TraceTree.js +182 -178
- package/dist/components/ui/TraceTree.js.map +1 -1
- package/dist/components/ui/index.d.ts +2 -0
- package/dist/components/ui/selectedRowDetail.cjs +2 -0
- package/dist/components/ui/selectedRowDetail.cjs.map +1 -0
- package/dist/components/ui/selectedRowDetail.d.ts +25 -0
- package/dist/components/ui/selectedRowDetail.js +8 -0
- package/dist/components/ui/selectedRowDetail.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +259 -257
- package/dist/index.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServiceMap.js","sources":["../../../src/components/ui/ServiceMap.tsx"],"sourcesContent":["// Service-map composition adapted from HyperDX (MIT, DeploySentinel Inc. 2023):\n// https://github.com/hyperdxio/hyperdx/blob/main/packages/app/src/components/ServiceMap/ServiceMap.tsx\nimport {\n type CSSProperties,\n type ComponentProps,\n type FocusEvent,\n type KeyboardEvent,\n useCallback,\n useEffect,\n useId,\n useMemo,\n useState,\n} from 'react';\n\nimport {\n type EdgeLabel,\n type GraphLabel,\n type NodeLabel,\n layout as dagreLayout,\n graphlib,\n} from '@dagrejs/dagre';\nimport {\n Background,\n BackgroundVariant,\n Controls,\n type Edge,\n type EdgeProps,\n Handle,\n MiniMap,\n type Node,\n type NodeChange,\n type NodeProps,\n Position,\n ReactFlow,\n ReactFlowProvider,\n type XYPosition,\n getViewportForBounds,\n useReactFlow,\n useStore,\n useStoreApi,\n} from '@xyflow/react';\n\nimport { useMediaQuery } from '../../hooks/useMediaQuery';\nimport { useStrings } from '../../locale';\nimport './ServiceMap.css';\nimport { StatusDot } from './StatusDot';\n\n/**\n * Drawn as a dot before the node's label. `active` is work in progress, e.g.\n * a running task: the ink dot pulses.\n */\nexport type ServiceMapStatus = 'ok' | 'active' | 'warn' | 'error' | 'muted';\nexport type ServiceMapDirection = 'LR' | 'TB';\n\nexport interface ServiceMapNode {\n id: string;\n label: string;\n sublabel?: string;\n status?: ServiceMapStatus;\n badge?: number | string;\n data?: Record<string, unknown>;\n}\n\n/**\n * A labelled box around some nodes, e.g. the tasks of one phase. Its id may\n * also be a node's id.\n */\nexport interface ServiceMapGroup {\n id: string;\n label: string;\n nodeIds: string[];\n}\n\n/** For assistive technology, named by its nodes' labels, e.g. \"checkout to payments\". */\nexport interface ServiceMapEdge {\n id: string;\n source: string;\n target: string;\n label?: string;\n /** `active` is a node's state only. */\n status?: Exclude<ServiceMapStatus, 'active'>;\n}\n\nexport interface ServiceMapProps {\n nodes: ServiceMapNode[];\n edges: ServiceMapEdge[];\n /**\n * Boxes drawn around groups of nodes, e.g. the phases of a pipeline. The\n * groups follow one another along `direction` in the order given, each\n * laid out on its own; nodes in no group come after the last group. A\n * node belongs to the first group that lists it.\n */\n groups?: ServiceMapGroup[];\n direction?: ServiceMapDirection;\n /** Height in px. Default: the container's height, at least `--service-map-min-height`. */\n height?: number;\n /**\n * Fill the viewport's height below the shell header\n * (`--service-map-viewport-height`), for a page whose main view is the\n * map. At 768 px and below the map keeps its default height, so a touch\n * can still scroll the page past it. `height` overrides it.\n */\n fillViewport?: boolean;\n /**\n * Called when a node is clicked, or gets Enter or Space while focused.\n * Without it nodes can be neither focused nor selected.\n */\n onNodeClick?: (node: ServiceMapNode) => void;\n /** The same for edges. */\n onEdgeClick?: (edge: ServiceMapEdge) => void;\n /** Drawn inverted, and `aria-current` for assistive technology. */\n selectedNodeId?: string;\n /**\n * Opens at actual size on this node instead of fitting the whole map, and\n * again whenever it changes: fitted to the node and the nodes it has a\n * direct edge to or from when they fit at actual size, otherwise centred\n * on the node alone. Large maps stay readable when they open. An id that\n * is not on the map is ignored.\n *\n * Without it the map opens fitted whole. At 768 px and below a map that\n * fits only below a readable size opens at the smallest readable zoom on\n * its start instead, the left edge for `LR` and the top for `TB`, to be\n * panned from there.\n */\n focusNodeId?: string;\n /**\n * Show the minimap in the bottom-right corner. A fit keeps its strip on\n * the right clear, so a map fitted whole opens with no node under it.\n * Default: shown unless `focusNodeId` is given, since a focused view runs\n * past every edge of the map and the minimap would cover nodes there. It\n * is not shown at 768 px and below.\n */\n minimap?: boolean;\n /**\n * The map's accessible name. Each node is a `group` named by its label\n * and, in a group, described by the group's label; a group's box is not\n * a `group`.\n */\n ariaLabel?: string;\n className?: string;\n}\n\ninterface ServiceNodeData extends Record<string, unknown> {\n node: ServiceMapNode;\n selected: boolean;\n}\n\ninterface ServiceGroupData extends Record<string, unknown> {\n label: string;\n /** The label's element id, which the group's nodes are described by. */\n labelId: string;\n}\n\ntype ServiceFlowNode =\n | Node<ServiceNodeData, 'service'>\n | Node<ServiceGroupData, 'serviceGroup'>;\n\ninterface ServiceEdgeData extends Record<string, unknown> {\n edge: ServiceMapEdge;\n}\n\n/** A node is at least this size; it widens with its label up to NODE_MAX_WIDTH, then wraps it. */\nconst NODE_WIDTH = 180;\nconst NODE_HEIGHT = 64;\nconst NODE_MAX_WIDTH = 320;\n/** Room above a group's nodes for its label. */\nconst GROUP_LABEL_HEIGHT = 28;\n/** Space between consecutive groups along the direction. */\nconst GROUP_GAP = 64;\n\n// The layout reads these sizes, so the CSS node and group boxes read them too.\nconst SIZE_VARS = {\n '--aegis-service-map-node-w': `${String(NODE_WIDTH)}px`,\n '--aegis-service-map-node-h': `${String(NODE_HEIGHT)}px`,\n '--aegis-service-map-node-max-w': `${String(NODE_MAX_WIDTH)}px`,\n '--aegis-service-map-group-label-h': `${String(GROUP_LABEL_HEIGHT)}px`,\n};\n\ninterface Size {\n width: number;\n height: number;\n}\n\nconst DEFAULT_SIZE: Size = { width: NODE_WIDTH, height: NODE_HEIGHT };\n\n/** A stretch of the map laid out on its own: a group's nodes, or the nodes in no group. */\ninterface Part {\n group?: ServiceMapGroup;\n ids: string[];\n}\n\n/** What the layout and the fit read: the map without its nodes' and edges' content. */\ninterface MapShape {\n direction: ServiceMapDirection;\n ids: string[];\n /** The endpoints of each edge between two nodes on the map. */\n links: Array<[string, string]>;\n groups: ServiceMapGroup[];\n}\n\nfunction shapeOf(\n nodes: ServiceMapNode[],\n edges: ServiceMapEdge[],\n groups: ServiceMapGroup[],\n direction: ServiceMapDirection,\n): MapShape {\n const ids = nodes.map((n) => n.id);\n const present = new Set(ids);\n return {\n direction,\n ids,\n links: edges\n .filter((e) => present.has(e.source) && present.has(e.target))\n .map((e) => [e.source, e.target]),\n groups,\n };\n}\n\n/** Each group with the nodes it claims, in the order given, then the nodes in no group. */\nfunction partsOf(ids: string[], groups: ServiceMapGroup[]): Part[] {\n const present = new Set(ids);\n const claimed = new Set<string>();\n const grouped = groups.map((group) => {\n const ids = [...new Set(group.nodeIds)].filter(\n (id) => present.has(id) && !claimed.has(id),\n );\n ids.forEach((id) => claimed.add(id));\n return { group, ids };\n });\n const rest = ids.filter((id) => !claimed.has(id));\n return [...grouped, { ids: rest }].filter((part) => part.ids.length > 0);\n}\n\n/** Lays out one part with dagre: its nodes and the edges between them. Positions are top-left corners. */\nfunction layoutPart(\n ids: string[],\n links: MapShape['links'],\n direction: ServiceMapDirection,\n sizeOf: (id: string) => Size,\n): { positions: Map<string, XYPosition>; width: number; height: number } {\n const g = new graphlib.Graph<GraphLabel, NodeLabel, EdgeLabel>();\n g.setDefaultEdgeLabel(() => ({}));\n g.setGraph({\n rankdir: direction,\n nodesep: 40,\n ranksep: 80,\n marginx: 16,\n marginy: 16,\n });\n for (const id of ids) {\n g.setNode(id, { ...sizeOf(id) });\n }\n for (const [source, target] of links) {\n if (g.hasNode(source) && g.hasNode(target)) {\n g.setEdge(source, target);\n }\n }\n dagreLayout(g);\n const positions = new Map(\n ids.map((id) => {\n const { x = 0, y = 0 } = g.node(id) as { x?: number; y?: number };\n const size = sizeOf(id);\n return [id, { x: x - size.width / 2, y: y - size.height / 2 }];\n }),\n );\n const { width = 0, height = 0 } = g.graph();\n return { positions, width, height };\n}\n\ninterface MapLayout {\n /** The group boxes. */\n groups: ServiceFlowNode[];\n /** Each node's top-left corner. */\n positions: Map<string, XYPosition>;\n /** The label id of the group each grouped node is in. */\n groupLabels: Map<string, string>;\n}\n\n/**\n * Lays the parts out one after another along the direction, each centred\n * across it, with dagre inside each part.\n */\nfunction computeLayout(\n shape: MapShape,\n sizes: ReadonlyMap<string, Size>,\n idPrefix: string,\n): MapLayout {\n const labelIdOf = (group: ServiceMapGroup): string =>\n `${idPrefix}-group-${String(shape.groups.indexOf(group))}`;\n const horizontal = shape.direction === 'LR';\n const parts = partsOf(shape.ids, shape.groups).map((part) => {\n const laid = layoutPart(part.ids, shape.links, shape.direction, (id) => {\n return sizes.get(id) ?? DEFAULT_SIZE;\n });\n const labelHeight = part.group === undefined ? 0 : GROUP_LABEL_HEIGHT;\n return {\n ...part,\n ...laid,\n labelHeight,\n boxHeight: laid.height + labelHeight,\n };\n });\n const across = Math.max(\n 0,\n ...parts.map((part) => (horizontal ? part.boxHeight : part.width)),\n );\n let along = 0;\n const placed = parts.map((part) => {\n const origin = horizontal\n ? { x: along, y: (across - part.boxHeight) / 2 }\n : { x: (across - part.width) / 2, y: along };\n along += (horizontal ? part.width : part.boxHeight) + GROUP_GAP;\n return { ...part, origin };\n });\n return {\n groups: placed.flatMap((part): ServiceFlowNode[] =>\n part.group === undefined\n ? []\n : [\n {\n // Prefixed, so a group may share an id with a node.\n id: `group:${part.group.id}`,\n type: 'serviceGroup',\n position: part.origin,\n width: part.width,\n height: part.boxHeight,\n data: {\n label: part.group.label,\n labelId: labelIdOf(part.group),\n },\n // Not a group for assistive technology: the box contains no\n // nodes in the DOM, so its label is plain text, which its\n // nodes are described by. It cannot be focused, so it has no\n // keyboard help either.\n domAttributes: {\n 'aria-roledescription': undefined,\n 'aria-describedby': undefined,\n },\n // Under the edges, and letting clicks through to them: React\n // Flow gives every node's wrapper pointer events once the map\n // has onNodeClick.\n zIndex: -1,\n style: { pointerEvents: 'none' },\n draggable: false,\n connectable: false,\n selectable: false,\n focusable: false,\n },\n ],\n ),\n positions: new Map(\n placed.flatMap((part) =>\n [...part.positions].map(([id, p]) => [\n id,\n {\n x: part.origin.x + p.x,\n y: part.origin.y + part.labelHeight + p.y,\n },\n ]),\n ),\n ),\n groupLabels: new Map(\n placed.flatMap((part) => {\n const { group } = part;\n return group === undefined\n ? []\n : part.ids.map((id) => [id, labelIdOf(group)] as const);\n }),\n ),\n };\n}\n\nfunction ServiceGroup({\n data,\n}: NodeProps<Node<ServiceGroupData, 'serviceGroup'>>): JSX.Element {\n return (\n <div className=\"aegis-service-map__group\">\n <span id={data.labelId} className=\"aegis-service-map__group-label\">\n {data.label}\n </span>\n </div>\n );\n}\n\nconst DOT_TONE: Record<\n ServiceMapStatus,\n NonNullable<ComponentProps<typeof StatusDot>['tone']>\n> = {\n ok: 'ink',\n active: 'ink',\n warn: 'caution',\n error: 'warning',\n muted: 'muted',\n};\n\nfunction ServiceNode({\n data,\n}: NodeProps<Node<ServiceNodeData, 'service'>>): JSX.Element {\n const { node, selected } = data;\n const status = node.status ?? 'ok';\n const tone = DOT_TONE[status];\n return (\n <div\n className={[\n 'aegis-service-map__node',\n `aegis-service-map__node--${status}`,\n selected ? 'aegis-service-map__node--selected' : '',\n ]\n .filter(Boolean)\n .join(' ')}\n >\n <Handle\n type=\"target\"\n position={Position.Left}\n className=\"aegis-service-map__handle\"\n />\n <div className=\"aegis-service-map__node-body\">\n <div className=\"aegis-service-map__node-label\">\n <StatusDot\n pulse={status === 'active'}\n tone={selected && tone === 'ink' ? 'inverted' : tone}\n />\n <span className=\"aegis-service-map__node-label-text\">\n {node.label}\n </span>\n </div>\n {node.sublabel !== undefined && (\n <div className=\"aegis-service-map__node-sublabel\">\n {node.sublabel}\n </div>\n )}\n </div>\n {node.badge !== undefined && node.badge !== '' && (\n <span\n className={`aegis-service-map__node-badge aegis-service-map__node-badge--${status}`}\n >\n {node.badge}\n </span>\n )}\n <Handle\n type=\"source\"\n position={Position.Right}\n className=\"aegis-service-map__handle\"\n />\n </div>\n );\n}\n\nfunction ServiceEdge(props: EdgeProps<Edge<ServiceEdgeData>>): JSX.Element {\n const { sourceX, sourceY, targetX, targetY, label, markerEnd, style } = props;\n // The label follows the path by its id, which must be unique on the page,\n // also when two maps share edge ids.\n const pathId = useId();\n const midX = (sourceX + targetX) / 2;\n const path = `M${sourceX},${sourceY} C${midX},${sourceY} ${midX},${targetY} ${targetX},${targetY}`;\n return (\n <>\n {/* The focus ring, drawn along the path under it. */}\n <path d={path} className=\"aegis-service-map__edge-focus\" fill=\"none\" />\n <path\n id={pathId}\n d={path}\n className=\"aegis-service-map__edge-path\"\n markerEnd={markerEnd}\n style={style}\n fill=\"none\"\n />\n {label !== undefined && label !== '' && (\n <text className=\"aegis-service-map__edge-label\">\n <textPath href={`#${pathId}`} startOffset=\"50%\" textAnchor=\"middle\">\n {label}\n </textPath>\n </text>\n )}\n </>\n );\n}\n\nconst NODE_TYPES = { service: ServiceNode, serviceGroup: ServiceGroup };\nconst EDGE_TYPES = { service: ServiceEdge };\n\nconst NARROW_QUERY = '(max-width: 768px)';\n/** Space kept clear around fitted nodes, in px. */\nconst FIT_MARGIN = 24;\n/** Low enough that fitting the whole map fits it, so the minimap's strip stays clear. */\nconst MIN_ZOOM = 0.1;\n/** A focused map opens at this zoom, so its labels are readable. */\nconst FOCUS_ZOOM = 1;\n/** The smallest zoom a narrow map opens at: a node's 13 px label reads at 11 px. */\nconst READABLE_ZOOM = 11 / 13;\n// React Flow draws the controls and the minimap in panels inset by 15 px. A\n// control button is 26 px, 28 inside the controls' hairline border.\nconst PANEL_INSET = 15;\nconst CONTROLS_WIDTH = 28;\nconst MINIMAP_WIDTH = 200;\n\n/** A fit padding in px; React Flow reads a bare number as a fraction of the view. */\nconst px = (value: number): `${number}px` => `${value}px`;\n\n/** A node with the nodes it has a direct edge to or from. */\nfunction neighbourhood(id: string, links: MapShape['links']): string[] {\n return [\n ...new Set([\n id,\n ...links.filter(([source]) => source === id).map(([, target]) => target),\n ...links.filter(([, target]) => target === id).map(([source]) => source),\n ]),\n ];\n}\n\n/** The minimap draws groups as outlines, so the nodes inside them stay visible. */\nfunction minimapNodeClass(node: Node): string {\n return node.type === 'serviceGroup' ? 'aegis-service-map__minimap-group' : '';\n}\n\n/**\n * Fits the view once the layout uses every node's measured size, and again\n * when the layout or the focus changes. Nothing else moves the view, so a\n * new status or selection keeps the user's pan and zoom.\n */\nfunction useFit(\n shape: MapShape,\n layout: MapLayout,\n laidOut: boolean,\n focusNodeId: string | undefined,\n showMinimap: boolean,\n narrow: boolean,\n): void {\n const { fitView, getNodes, getNodesBounds, setViewport } = useReactFlow();\n const store = useStoreApi();\n const paneSized = useStore((state) => state.width > 0 && state.height > 0);\n const focus = useMemo(\n () =>\n focusNodeId !== undefined && shape.ids.includes(focusNodeId)\n ? { id: focusNodeId, near: neighbourhood(focusNodeId, shape.links) }\n : undefined,\n [focusNodeId, shape],\n );\n useEffect(() => {\n if (paneSized && laidOut) {\n const padding = {\n top: px(FIT_MARGIN),\n bottom: px(FIT_MARGIN),\n left: px(PANEL_INSET + CONTROLS_WIDTH + FIT_MARGIN),\n right: px(\n showMinimap ? PANEL_INSET + MINIMAP_WIDTH + FIT_MARGIN : FIT_MARGIN,\n ),\n };\n const { width, height } = store.getState();\n if (focus === undefined) {\n const all = getNodes();\n const bounds = getNodesBounds(all);\n const fitted = getViewportForBounds(\n bounds,\n width,\n height,\n MIN_ZOOM,\n 1,\n padding,\n );\n if (narrow && fitted.zoom < READABLE_ZOOM) {\n // A phone has no minimap and too little room for the whole map,\n // so it opens where the map starts, on its first node.\n const zoom = READABLE_ZOOM;\n const horizontal = shape.direction === 'LR';\n const along = (n: Node): number =>\n horizontal ? n.position.x : n.position.y;\n const first = all\n .filter((n) => n.type === 'service')\n .reduce((a, b) => (along(b) < along(a) ? b : a));\n const { width: w = NODE_WIDTH, height: h = NODE_HEIGHT } =\n first.measured ?? {};\n void setViewport(\n horizontal\n ? {\n x:\n PANEL_INSET + CONTROLS_WIDTH + FIT_MARGIN - bounds.x * zoom,\n y: height / 2 - (first.position.y + h / 2) * zoom,\n zoom,\n }\n : {\n x: width / 2 - (first.position.x + w / 2) * zoom,\n y: FIT_MARGIN - bounds.y * zoom,\n zoom,\n },\n );\n } else {\n void fitView({ maxZoom: 1, padding });\n }\n } else {\n const nearFits =\n getViewportForBounds(\n getNodesBounds(focus.near),\n width,\n height,\n MIN_ZOOM,\n FOCUS_ZOOM,\n padding,\n ).zoom >= FOCUS_ZOOM;\n void fitView({\n nodes: (nearFits ? focus.near : [focus.id]).map((id) => ({ id })),\n minZoom: FOCUS_ZOOM,\n maxZoom: FOCUS_ZOOM,\n padding,\n });\n }\n }\n }, [\n paneSized,\n laidOut,\n layout,\n focus,\n showMinimap,\n narrow,\n shape.direction,\n store,\n fitView,\n getNodes,\n getNodesBounds,\n setViewport,\n ]);\n}\n\n/**\n * Pans a node or edge that gets keyboard focus fully into view, centred.\n * React Flow pans only to a node entirely outside the view, and never to\n * an edge.\n */\nfunction usePanToFocused(): (event: FocusEvent<HTMLDivElement>) => void {\n const { getViewport, setViewport } = useReactFlow();\n return useCallback(\n (event: FocusEvent<HTMLDivElement>) => {\n const target = event.target;\n if (\n !(target instanceof Element) ||\n !target.matches(\n '.react-flow__node:focus-visible, .react-flow__edge:focus-visible',\n )\n ) {\n return;\n }\n // The browser has already scrolled the pane to the element, and React\n // Flow scrolls it back, so the offset is added back to place it.\n const { scrollLeft, scrollTop } = event.currentTarget;\n const pane = event.currentTarget.getBoundingClientRect();\n const box = target.getBoundingClientRect();\n const left = box.left - pane.left + scrollLeft;\n const top = box.top - pane.top + scrollTop;\n if (\n left >= 0 &&\n top >= 0 &&\n left + box.width <= pane.width &&\n top + box.height <= pane.height\n ) {\n return;\n }\n const { x, y, zoom } = getViewport();\n void setViewport({\n x: x + pane.width / 2 - (left + box.width / 2),\n y: y + pane.height / 2 - (top + box.height / 2),\n zoom,\n });\n },\n [getViewport, setViewport],\n );\n}\n\nfunction ServiceMapInner({\n nodes,\n edges,\n groups = [],\n direction = 'LR',\n height,\n fillViewport = false,\n onNodeClick,\n onEdgeClick,\n selectedNodeId,\n focusNodeId,\n minimap = focusNodeId === undefined,\n ariaLabel,\n className,\n}: ServiceMapProps): JSX.Element {\n const strings = useStrings();\n const idPrefix = useId();\n // React Flow names its elements after this id ('1' when none is given),\n // so each map passes its own and a page can hold several.\n const flowId = `aegis-service-map${idPrefix.replace(/:/g, '-')}`;\n const nodesSelectable = onNodeClick !== undefined;\n const edgesSelectable = onEdgeClick !== undefined;\n // Node sizes as React Flow measured them; the layout reads them, so a\n // node can be as wide as its label.\n const [measured, setMeasured] = useState<ReadonlyMap<string, Size>>(\n () => new Map(),\n );\n const shapeJson = useMemo(\n () => JSON.stringify(shapeOf(nodes, edges, groups, direction)),\n [nodes, edges, groups, direction],\n );\n // Parsed back from its JSON, so the shape is a new object only when it\n // changes, not when the parent passes equal arrays again.\n const shape = useMemo(() => JSON.parse(shapeJson) as MapShape, [shapeJson]);\n const layout = useMemo(\n () => computeLayout(shape, measured, idPrefix),\n [shape, measured, idPrefix],\n );\n const isHorizontal = direction === 'LR';\n const flowNodes = useMemo(\n (): ServiceFlowNode[] => [\n ...layout.groups,\n ...nodes.map((n): ServiceFlowNode => {\n // A node in a group is described by the group's label. React Flow\n // describes a node by its keyboard help, the element it names\n // `react-flow__node-desc-<rfId>`; a node that cannot be selected\n // has none.\n const describedBy = [\n layout.groupLabels.get(n.id),\n nodesSelectable ? `react-flow__node-desc-${flowId}` : undefined,\n ]\n .filter(Boolean)\n .join(' ');\n return {\n id: n.id,\n type: 'service',\n position: layout.positions.get(n.id) ?? { x: 0, y: 0 },\n // Handed back as applyNodeChanges would, so React Flow keeps the\n // size it measured instead of measuring the node again.\n measured: measured.get(n.id),\n ariaLabel: n.label,\n // React Flow gives only a focusable node a role, and the role\n // description below needs one.\n ariaRole: 'group',\n domAttributes: {\n 'aria-roledescription': strings.serviceMapNodeRole,\n // A group takes no aria-selected.\n 'aria-current': selectedNodeId === n.id ? true : undefined,\n 'aria-describedby': describedBy === '' ? undefined : describedBy,\n },\n data: { node: n, selected: selectedNodeId === n.id },\n sourcePosition: isHorizontal ? Position.Right : Position.Bottom,\n targetPosition: isHorizontal ? Position.Left : Position.Top,\n draggable: false,\n connectable: false,\n selectable: nodesSelectable,\n focusable: nodesSelectable,\n };\n }),\n ],\n [\n layout,\n nodes,\n measured,\n selectedNodeId,\n isHorizontal,\n nodesSelectable,\n flowId,\n strings,\n ],\n );\n const flowEdges = useMemo((): Array<Edge<ServiceEdgeData>> => {\n const labelOf = new Map(nodes.map((n) => [n.id, n.label]));\n return edges.map((e) => ({\n id: e.id,\n source: e.source,\n target: e.target,\n ariaLabel: strings.serviceMapEdgeName(\n labelOf.get(e.source) ?? e.source,\n labelOf.get(e.target) ?? e.target,\n ),\n domAttributes: { 'aria-roledescription': strings.serviceMapEdgeRole },\n type: 'service',\n data: { edge: e },\n label: e.label,\n selectable: edgesSelectable,\n focusable: edgesSelectable,\n className: `aegis-service-map__edge aegis-service-map__edge--${e.status ?? 'ok'}`,\n }));\n }, [nodes, edges, edgesSelectable, strings]);\n\n const { getNode } = useReactFlow();\n const handleNodesChange = useCallback(\n (changes: Array<NodeChange<ServiceFlowNode>>) => {\n const resized = changes.flatMap((change) =>\n change.type === 'dimensions' &&\n change.dimensions !== undefined &&\n getNode(change.id)?.type === 'service'\n ? [[change.id, change.dimensions] as const]\n : [],\n );\n setMeasured((previous) =>\n resized.every(\n ([id, size]) =>\n previous.get(id)?.width === size.width &&\n previous.get(id)?.height === size.height,\n )\n ? previous\n : new Map([...previous, ...resized]),\n );\n },\n [getNode],\n );\n\n const narrow = useMediaQuery(NARROW_QUERY);\n const showMinimap = minimap && !narrow;\n useFit(\n shape,\n layout,\n nodes.every((n) => measured.has(n.id)),\n focusNodeId,\n showMinimap,\n narrow,\n );\n const handleFocus = usePanToFocused();\n\n const handleNodeClick = useCallback(\n (_: unknown, n: ServiceFlowNode) => {\n if (n.type === 'service') {\n onNodeClick?.(n.data.node);\n }\n },\n [onNodeClick],\n );\n const handleEdgeClick = useCallback(\n (_: unknown, e: Edge<ServiceEdgeData>) => {\n if (e.data) {\n onEdgeClick?.(e.data.edge);\n }\n },\n [onEdgeClick],\n );\n // React Flow's own Enter and Space only change its internal selection,\n // which never reaches the host, so a focused node or edge answers the\n // keys here, as a click would.\n const handleKeyDown = useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n if ((event.key !== 'Enter' && event.key !== ' ') || event.repeat) {\n return;\n }\n const target = event.target;\n if (!(target instanceof Element)) {\n return;\n }\n const id = target.getAttribute('data-id');\n if (target.classList.contains('react-flow__node')) {\n const node = nodes.find((n) => n.id === id);\n if (node && onNodeClick) {\n event.preventDefault();\n onNodeClick(node);\n }\n } else if (target.classList.contains('react-flow__edge')) {\n const edge = edges.find((e) => e.id === id);\n if (edge && onEdgeClick) {\n event.preventDefault();\n onEdgeClick(edge);\n }\n }\n },\n [nodes, edges, onNodeClick, onEdgeClick],\n );\n\n const style = {\n ...SIZE_VARS,\n height: height === undefined ? undefined : `${String(height)}px`,\n } as CSSProperties;\n\n return (\n <div\n className={[\n 'aegis-service-map',\n fillViewport ? 'aegis-service-map--fill-viewport' : '',\n className,\n ]\n .filter(Boolean)\n .join(' ')}\n style={style}\n >\n {/* Positioned over the whole box, so React Flow has a definite height\n even when the box only has its min-height. */}\n <div className=\"aegis-service-map__pane\">\n <ReactFlow\n id={flowId}\n aria-label={ariaLabel}\n nodes={flowNodes}\n edges={flowEdges}\n nodeTypes={NODE_TYPES}\n edgeTypes={EDGE_TYPES}\n minZoom={MIN_ZOOM}\n nodesDraggable={false}\n nodesConnectable={false}\n autoPanOnNodeFocus={false}\n panOnDrag\n zoomOnScroll\n proOptions={{ hideAttribution: true }}\n ariaLabelConfig={strings.serviceMapAriaLabels}\n onNodesChange={handleNodesChange}\n onNodeClick={nodesSelectable ? handleNodeClick : undefined}\n onEdgeClick={edgesSelectable ? handleEdgeClick : undefined}\n onKeyDown={handleKeyDown}\n onFocus={handleFocus}\n >\n <Background variant={BackgroundVariant.Dots} gap={16} size={1} />\n <Controls showInteractive={false} position=\"top-left\" />\n {showMinimap && (\n <MiniMap\n pannable\n zoomable\n position=\"bottom-right\"\n style={{ width: MINIMAP_WIDTH }}\n nodeClassName={minimapNodeClass}\n />\n )}\n </ReactFlow>\n </div>\n </div>\n );\n}\n\nexport function ServiceMap(props: ServiceMapProps): JSX.Element {\n return (\n <ReactFlowProvider>\n <ServiceMapInner {...props} />\n </ReactFlowProvider>\n );\n}\n"],"names":["NODE_WIDTH","NODE_HEIGHT","NODE_MAX_WIDTH","GROUP_LABEL_HEIGHT","GROUP_GAP","SIZE_VARS","DEFAULT_SIZE","shapeOf","nodes","edges","groups","direction","ids","n","present","e","partsOf","claimed","grouped","group","id","rest","part","layoutPart","links","sizeOf","g","graphlib","source","target","dagreLayout","positions","x","y","size","width","height","computeLayout","shape","sizes","idPrefix","labelIdOf","horizontal","parts","laid","labelHeight","across","along","placed","origin","p","ServiceGroup","data","jsx","DOT_TONE","ServiceNode","node","selected","status","tone","jsxs","Handle","Position","StatusDot","ServiceEdge","props","sourceX","sourceY","targetX","targetY","label","markerEnd","style","pathId","useId","midX","path","Fragment","NODE_TYPES","EDGE_TYPES","NARROW_QUERY","FIT_MARGIN","MIN_ZOOM","FOCUS_ZOOM","READABLE_ZOOM","PANEL_INSET","CONTROLS_WIDTH","MINIMAP_WIDTH","px","value","neighbourhood","minimapNodeClass","useFit","layout","laidOut","focusNodeId","showMinimap","narrow","fitView","getNodes","getNodesBounds","setViewport","useReactFlow","store","useStoreApi","paneSized","useStore","state","focus","useMemo","useEffect","padding","all","bounds","fitted","getViewportForBounds","zoom","first","a","b","w","h","nearFits","usePanToFocused","getViewport","useCallback","event","scrollLeft","scrollTop","pane","box","left","top","ServiceMapInner","fillViewport","onNodeClick","onEdgeClick","selectedNodeId","minimap","ariaLabel","className","strings","useStrings","flowId","nodesSelectable","edgesSelectable","measured","setMeasured","useState","shapeJson","isHorizontal","flowNodes","describedBy","flowEdges","labelOf","getNode","handleNodesChange","changes","resized","change","previous","useMediaQuery","handleFocus","handleNodeClick","_","handleEdgeClick","handleKeyDown","edge","ReactFlow","Background","BackgroundVariant","Controls","MiniMap","ServiceMap","ReactFlowProvider"],"mappings":";;;;;;;;AAkKA,MAAMA,IAAa,KACbC,IAAc,IACdC,KAAiB,KAEjBC,IAAqB,IAErBC,KAAY,IAGZC,KAAY;AAAA,EAChB,8BAA8B,GAAG,OAAOL,CAAU,CAAC;AAAA,EACnD,8BAA8B,GAAG,OAAOC,CAAW,CAAC;AAAA,EACpD,kCAAkC,GAAG,OAAOC,EAAc,CAAC;AAAA,EAC3D,qCAAqC,GAAG,OAAOC,CAAkB,CAAC;AACpE,GAOMG,KAAqB,EAAE,OAAON,GAAY,QAAQC,EAAA;AAiBxD,SAASM,GACPC,GACAC,GACAC,GACAC,GACU;AACV,QAAMC,IAAMJ,EAAM,IA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AA,EACC,UAAA,gBAAAzH,EAACgF,IAAA,EAAiB,GAAGpE,GAAO,GAC9B;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"ServiceMap.js","sources":["../../../src/components/ui/ServiceMap.tsx"],"sourcesContent":["// Service-map composition adapted from HyperDX (MIT, DeploySentinel Inc. 2023):\n// https://github.com/hyperdxio/hyperdx/blob/main/packages/app/src/components/ServiceMap/ServiceMap.tsx\nimport {\n type CSSProperties,\n type ComponentProps,\n type FocusEvent,\n type KeyboardEvent,\n useCallback,\n useContext,\n useEffect,\n useId,\n useMemo,\n useState,\n} from 'react';\n\nimport {\n type EdgeLabel,\n type GraphLabel,\n type NodeLabel,\n layout as dagreLayout,\n graphlib,\n} from '@dagrejs/dagre';\nimport {\n Background,\n BackgroundVariant,\n Controls,\n type Edge,\n type EdgeProps,\n Handle,\n MiniMap,\n type Node,\n type NodeChange,\n type NodeProps,\n Position,\n ReactFlow,\n ReactFlowProvider,\n type XYPosition,\n getViewportForBounds,\n useInternalNode,\n useReactFlow,\n useStore,\n useStoreApi,\n} from '@xyflow/react';\n\nimport { useIsomorphicLayoutEffect } from '../../hooks/useIsomorphicLayoutEffect';\nimport { useMediaQuery } from '../../hooks/useMediaQuery';\nimport { useStrings } from '../../locale';\nimport './ServiceMap.css';\nimport { StatusDot } from './StatusDot';\nimport {\n type SelectedRowDetail,\n SelectedRowDetailContext,\n} from './selectedRowDetail';\n\n/**\n * Drawn as a dot before the node's label. `active` is work in progress, e.g.\n * a running task: the ink dot pulses.\n */\nexport type ServiceMapStatus = 'ok' | 'active' | 'warn' | 'error' | 'muted';\nexport type ServiceMapDirection = 'LR' | 'TB';\n\nexport interface ServiceMapNode {\n id: string;\n label: string;\n sublabel?: string;\n status?: ServiceMapStatus;\n badge?: number | string;\n data?: Record<string, unknown>;\n}\n\n/**\n * A labelled box around some nodes, e.g. the tasks of one phase. Its id may\n * also be a node's id.\n */\nexport interface ServiceMapGroup {\n id: string;\n label: string;\n nodeIds: string[];\n}\n\n/** For assistive technology, named by its nodes' labels, e.g. \"checkout to payments\". */\nexport interface ServiceMapEdge {\n id: string;\n source: string;\n target: string;\n label?: string;\n /** `active` is a node's state only. */\n status?: Exclude<ServiceMapStatus, 'active'>;\n}\n\nexport interface ServiceMapProps {\n nodes: ServiceMapNode[];\n edges: ServiceMapEdge[];\n /**\n * Boxes drawn around groups of nodes, e.g. the phases of a pipeline. The\n * groups follow one another along `direction` in the order given, each\n * laid out on its own; nodes in no group come after the last group. A\n * node belongs to the first group that lists it.\n */\n groups?: ServiceMapGroup[];\n direction?: ServiceMapDirection;\n /** Height in px. Default: the container's height, at least `--service-map-min-height`. */\n height?: number;\n /**\n * Fill the viewport's height below the shell header\n * (`--service-map-viewport-height`), for a page whose main view is the\n * map. At 768 px and below the map keeps its default height, so a touch\n * can still scroll the page past it. `height` overrides it.\n */\n fillViewport?: boolean;\n /**\n * Called when a node is clicked, or gets Enter or Space while focused.\n * Without it nodes can be neither focused nor selected.\n */\n onNodeClick?: (node: ServiceMapNode) => void;\n /** The same for edges. */\n onEdgeClick?: (edge: ServiceMapEdge) => void;\n /** Drawn inverted, and `aria-current` for assistive technology. */\n selectedNodeId?: string;\n /**\n * Opens at actual size on this node instead of fitting the whole map, and\n * again whenever it changes: fitted to the node and the nodes it has a\n * direct edge to or from when they fit at actual size, otherwise centred\n * on the node alone. Large maps stay readable when they open. An id that\n * is not on the map is ignored.\n *\n * Without it the map opens fitted whole. At 768 px and below a map that\n * fits only below a readable size opens at the smallest readable zoom on\n * its start instead, the left edge for `LR` and the top for `TB`, to be\n * panned from there.\n */\n focusNodeId?: string;\n /**\n * Show the minimap in the bottom-right corner. A fit keeps its strip on\n * the right clear, so a map fitted whole opens with no node under it.\n * Default: shown unless `focusNodeId` is given, since a focused view runs\n * past every edge of the map and the minimap would cover nodes there. It\n * is not shown at 768 px and below.\n */\n minimap?: boolean;\n /**\n * The map's accessible name. Each node is a `group` named by its label\n * and, in a group, described by the group's label; a group's box is not\n * a `group`.\n */\n ariaLabel?: string;\n className?: string;\n}\n\ninterface ServiceNodeData extends Record<string, unknown> {\n node: ServiceMapNode;\n selected: boolean;\n}\n\ninterface ServiceGroupData extends Record<string, unknown> {\n label: string;\n /** The label's element id, which the group's nodes are described by. */\n labelId: string;\n}\n\ntype ServiceFlowNode =\n | Node<ServiceNodeData, 'service'>\n | Node<ServiceGroupData, 'serviceGroup'>;\n\ninterface ServiceEdgeData extends Record<string, unknown> {\n edge: ServiceMapEdge;\n}\n\n/** A node is at least this size; it widens with its label up to NODE_MAX_WIDTH, then wraps it. */\nconst NODE_WIDTH = 180;\nconst NODE_HEIGHT = 64;\nconst NODE_MAX_WIDTH = 320;\n/** Room above a group's nodes for its label. */\nconst GROUP_LABEL_HEIGHT = 28;\n/** Space between consecutive groups along the direction. */\nconst GROUP_GAP = 64;\n\n// The layout reads these sizes, so the CSS node and group boxes read them too.\nconst SIZE_VARS = {\n '--aegis-service-map-node-w': `${String(NODE_WIDTH)}px`,\n '--aegis-service-map-node-h': `${String(NODE_HEIGHT)}px`,\n '--aegis-service-map-node-max-w': `${String(NODE_MAX_WIDTH)}px`,\n '--aegis-service-map-group-label-h': `${String(GROUP_LABEL_HEIGHT)}px`,\n};\n\ninterface Size {\n width: number;\n height: number;\n}\n\nconst DEFAULT_SIZE: Size = { width: NODE_WIDTH, height: NODE_HEIGHT };\n\n/** A stretch of the map laid out on its own: a group's nodes, or the nodes in no group. */\ninterface Part {\n group?: ServiceMapGroup;\n ids: string[];\n}\n\n/** What the layout and the fit read: the map without its nodes' and edges' content. */\ninterface MapShape {\n direction: ServiceMapDirection;\n ids: string[];\n /** The endpoints of each edge between two nodes on the map. */\n links: Array<[string, string]>;\n groups: ServiceMapGroup[];\n}\n\nfunction shapeOf(\n nodes: ServiceMapNode[],\n edges: ServiceMapEdge[],\n groups: ServiceMapGroup[],\n direction: ServiceMapDirection,\n): MapShape {\n const ids = nodes.map((n) => n.id);\n const present = new Set(ids);\n return {\n direction,\n ids,\n links: edges\n .filter((e) => present.has(e.source) && present.has(e.target))\n .map((e) => [e.source, e.target]),\n groups,\n };\n}\n\n/** Each group with the nodes it claims, in the order given, then the nodes in no group. */\nfunction partsOf(ids: string[], groups: ServiceMapGroup[]): Part[] {\n const present = new Set(ids);\n const claimed = new Set<string>();\n const grouped = groups.map((group) => {\n const ids = [...new Set(group.nodeIds)].filter(\n (id) => present.has(id) && !claimed.has(id),\n );\n ids.forEach((id) => claimed.add(id));\n return { group, ids };\n });\n const rest = ids.filter((id) => !claimed.has(id));\n return [...grouped, { ids: rest }].filter((part) => part.ids.length > 0);\n}\n\n/** Lays out one part with dagre: its nodes and the edges between them. Positions are top-left corners. */\nfunction layoutPart(\n ids: string[],\n links: MapShape['links'],\n direction: ServiceMapDirection,\n sizeOf: (id: string) => Size,\n): { positions: Map<string, XYPosition>; width: number; height: number } {\n const g = new graphlib.Graph<GraphLabel, NodeLabel, EdgeLabel>();\n g.setDefaultEdgeLabel(() => ({}));\n g.setGraph({\n rankdir: direction,\n nodesep: 40,\n ranksep: 80,\n marginx: 16,\n marginy: 16,\n });\n for (const id of ids) {\n g.setNode(id, { ...sizeOf(id) });\n }\n for (const [source, target] of links) {\n if (g.hasNode(source) && g.hasNode(target)) {\n g.setEdge(source, target);\n }\n }\n dagreLayout(g);\n const positions = new Map(\n ids.map((id) => {\n const { x = 0, y = 0 } = g.node(id) as { x?: number; y?: number };\n const size = sizeOf(id);\n return [id, { x: x - size.width / 2, y: y - size.height / 2 }];\n }),\n );\n const { width = 0, height = 0 } = g.graph();\n return { positions, width, height };\n}\n\ninterface MapLayout {\n /** The group boxes. */\n groups: ServiceFlowNode[];\n /** Each node's top-left corner. */\n positions: Map<string, XYPosition>;\n /** The label id of the group each grouped node is in. */\n groupLabels: Map<string, string>;\n}\n\n/**\n * Lays the parts out one after another along the direction, each centred\n * across it, with dagre inside each part.\n */\nfunction computeLayout(\n shape: MapShape,\n sizes: ReadonlyMap<string, Size>,\n idPrefix: string,\n): MapLayout {\n const labelIdOf = (group: ServiceMapGroup): string =>\n `${idPrefix}-group-${String(shape.groups.indexOf(group))}`;\n const horizontal = shape.direction === 'LR';\n const parts = partsOf(shape.ids, shape.groups).map((part) => {\n const laid = layoutPart(part.ids, shape.links, shape.direction, (id) => {\n return sizes.get(id) ?? DEFAULT_SIZE;\n });\n const labelHeight = part.group === undefined ? 0 : GROUP_LABEL_HEIGHT;\n return {\n ...part,\n ...laid,\n labelHeight,\n boxHeight: laid.height + labelHeight,\n };\n });\n const across = Math.max(\n 0,\n ...parts.map((part) => (horizontal ? part.boxHeight : part.width)),\n );\n let along = 0;\n const placed = parts.map((part) => {\n const origin = horizontal\n ? { x: along, y: (across - part.boxHeight) / 2 }\n : { x: (across - part.width) / 2, y: along };\n along += (horizontal ? part.width : part.boxHeight) + GROUP_GAP;\n return { ...part, origin };\n });\n return {\n groups: placed.flatMap((part): ServiceFlowNode[] =>\n part.group === undefined\n ? []\n : [\n {\n // Prefixed, so a group may share an id with a node.\n id: `group:${part.group.id}`,\n type: 'serviceGroup',\n position: part.origin,\n width: part.width,\n height: part.boxHeight,\n data: {\n label: part.group.label,\n labelId: labelIdOf(part.group),\n },\n // Not a group for assistive technology: the box contains no\n // nodes in the DOM, so its label is plain text, which its\n // nodes are described by. It cannot be focused, so it has no\n // keyboard help either.\n domAttributes: {\n 'aria-roledescription': undefined,\n 'aria-describedby': undefined,\n },\n // Under the edges, and letting clicks through to them: React\n // Flow gives every node's wrapper pointer events once the map\n // has onNodeClick.\n zIndex: -1,\n style: { pointerEvents: 'none' },\n draggable: false,\n connectable: false,\n selectable: false,\n focusable: false,\n },\n ],\n ),\n positions: new Map(\n placed.flatMap((part) =>\n [...part.positions].map(([id, p]) => [\n id,\n {\n x: part.origin.x + p.x,\n y: part.origin.y + part.labelHeight + p.y,\n },\n ]),\n ),\n ),\n groupLabels: new Map(\n placed.flatMap((part) => {\n const { group } = part;\n return group === undefined\n ? []\n : part.ids.map((id) => [id, labelIdOf(group)] as const);\n }),\n ),\n };\n}\n\nfunction ServiceGroup({\n data,\n}: NodeProps<Node<ServiceGroupData, 'serviceGroup'>>): JSX.Element {\n return (\n <div className=\"aegis-service-map__group\">\n <span id={data.labelId} className=\"aegis-service-map__group-label\">\n {data.label}\n </span>\n </div>\n );\n}\n\nconst DOT_TONE: Record<\n ServiceMapStatus,\n NonNullable<ComponentProps<typeof StatusDot>['tone']>\n> = {\n ok: 'ink',\n active: 'ink',\n warn: 'caution',\n error: 'warning',\n muted: 'muted',\n};\n\nfunction ServiceNode({\n data,\n}: NodeProps<Node<ServiceNodeData, 'service'>>): JSX.Element {\n const { node, selected } = data;\n const status = node.status ?? 'ok';\n const tone = DOT_TONE[status];\n return (\n <div\n className={[\n 'aegis-service-map__node',\n `aegis-service-map__node--${status}`,\n selected ? 'aegis-service-map__node--selected' : '',\n ]\n .filter(Boolean)\n .join(' ')}\n >\n <Handle\n type=\"target\"\n position={Position.Left}\n className=\"aegis-service-map__handle\"\n />\n <div className=\"aegis-service-map__node-body\">\n <div className=\"aegis-service-map__node-label\">\n <StatusDot\n pulse={status === 'active'}\n tone={selected && tone === 'ink' ? 'inverted' : tone}\n />\n <span className=\"aegis-service-map__node-label-text\">\n {node.label}\n </span>\n </div>\n {node.sublabel !== undefined && (\n <div className=\"aegis-service-map__node-sublabel\">\n {node.sublabel}\n </div>\n )}\n </div>\n {node.badge !== undefined && node.badge !== '' && (\n <span\n className={`aegis-service-map__node-badge aegis-service-map__node-badge--${status}`}\n >\n {node.badge}\n </span>\n )}\n <Handle\n type=\"source\"\n position={Position.Right}\n className=\"aegis-service-map__handle\"\n />\n </div>\n );\n}\n\nfunction ServiceEdge(props: EdgeProps<Edge<ServiceEdgeData>>): JSX.Element {\n const { sourceX, sourceY, targetX, targetY, label, markerEnd, style } = props;\n // The label follows the path by its id, which must be unique on the page,\n // also when two maps share edge ids.\n const pathId = useId();\n const midX = (sourceX + targetX) / 2;\n const path = `M${sourceX},${sourceY} C${midX},${sourceY} ${midX},${targetY} ${targetX},${targetY}`;\n return (\n <>\n {/* The focus ring, drawn along the path under it. */}\n <path d={path} className=\"aegis-service-map__edge-focus\" fill=\"none\" />\n <path\n id={pathId}\n d={path}\n className=\"aegis-service-map__edge-path\"\n markerEnd={markerEnd}\n style={style}\n fill=\"none\"\n />\n {label !== undefined && label !== '' && (\n <text className=\"aegis-service-map__edge-label\">\n <textPath href={`#${pathId}`} startOffset=\"50%\" textAnchor=\"middle\">\n {label}\n </textPath>\n </text>\n )}\n </>\n );\n}\n\nconst NODE_TYPES = { service: ServiceNode, serviceGroup: ServiceGroup };\nconst EDGE_TYPES = { service: ServiceEdge };\n\nconst NARROW_QUERY = '(max-width: 768px)';\n/** Space kept clear around fitted nodes, in px. */\nconst FIT_MARGIN = 24;\n/** Low enough that fitting the whole map fits it, so the minimap's strip stays clear. */\nconst MIN_ZOOM = 0.1;\n/** A focused map opens at this zoom, so its labels are readable. */\nconst FOCUS_ZOOM = 1;\n/** The smallest zoom a narrow map opens at: a node's 13 px label reads at 11 px. */\nconst READABLE_ZOOM = 11 / 13;\n// React Flow draws the controls and the minimap in panels inset by 15 px. A\n// control button is 26 px, 28 inside the controls' hairline border.\nconst PANEL_INSET = 15;\nconst CONTROLS_WIDTH = 28;\nconst MINIMAP_WIDTH = 200;\n\n/** A fit padding in px; React Flow reads a bare number as a fraction of the view. */\nconst px = (value: number): `${number}px` => `${value}px`;\n\n/** A node with the nodes it has a direct edge to or from. */\nfunction neighbourhood(id: string, links: MapShape['links']): string[] {\n return [\n ...new Set([\n id,\n ...links.filter(([source]) => source === id).map(([, target]) => target),\n ...links.filter(([, target]) => target === id).map(([source]) => source),\n ]),\n ];\n}\n\n/** The minimap draws groups as outlines, so the nodes inside them stay visible. */\nfunction minimapNodeClass(node: Node): string {\n return node.type === 'serviceGroup' ? 'aegis-service-map__minimap-group' : '';\n}\n\n/**\n * Fits the view once the layout uses every node's measured size, and again\n * when the layout or the focus changes. Nothing else moves the view, so a\n * new status or selection keeps the user's pan and zoom. Returns whether\n * the view has been fitted to the current focus.\n */\nfunction useFit(\n shape: MapShape,\n layout: MapLayout,\n laidOut: boolean,\n focusNodeId: string | undefined,\n showMinimap: boolean,\n narrow: boolean,\n): boolean {\n const { fitView, getNodes, getNodesBounds, setViewport } = useReactFlow();\n const store = useStoreApi();\n const paneSized = useStore((state) => state.width > 0 && state.height > 0);\n const focus = useMemo(\n () =>\n focusNodeId !== undefined && shape.ids.includes(focusNodeId)\n ? { id: focusNodeId, near: neighbourhood(focusNodeId, shape.links) }\n : undefined,\n [focusNodeId, shape],\n );\n const [fittedTo, setFittedTo] = useState<string | null>();\n useEffect(() => {\n if (paneSized && laidOut) {\n const settle = (): void => {\n setFittedTo(focus?.id ?? null);\n };\n const padding = {\n top: px(FIT_MARGIN),\n bottom: px(FIT_MARGIN),\n left: px(PANEL_INSET + CONTROLS_WIDTH + FIT_MARGIN),\n right: px(\n showMinimap ? PANEL_INSET + MINIMAP_WIDTH + FIT_MARGIN : FIT_MARGIN,\n ),\n };\n const { width, height } = store.getState();\n if (focus === undefined) {\n const all = getNodes();\n const bounds = getNodesBounds(all);\n const fitted = getViewportForBounds(\n bounds,\n width,\n height,\n MIN_ZOOM,\n 1,\n padding,\n );\n if (narrow && fitted.zoom < READABLE_ZOOM) {\n // A phone has no minimap and too little room for the whole map,\n // so it opens where the map starts, on its first node.\n const zoom = READABLE_ZOOM;\n const horizontal = shape.direction === 'LR';\n const along = (n: Node): number =>\n horizontal ? n.position.x : n.position.y;\n const first = all\n .filter((n) => n.type === 'service')\n .reduce((a, b) => (along(b) < along(a) ? b : a));\n const { width: w = NODE_WIDTH, height: h = NODE_HEIGHT } =\n first.measured ?? {};\n void setViewport(\n horizontal\n ? {\n x:\n PANEL_INSET + CONTROLS_WIDTH + FIT_MARGIN - bounds.x * zoom,\n y: height / 2 - (first.position.y + h / 2) * zoom,\n zoom,\n }\n : {\n x: width / 2 - (first.position.x + w / 2) * zoom,\n y: FIT_MARGIN - bounds.y * zoom,\n zoom,\n },\n ).then(settle);\n } else {\n void fitView({ maxZoom: 1, padding }).then(settle);\n }\n } else {\n const nearFits =\n getViewportForBounds(\n getNodesBounds(focus.near),\n width,\n height,\n MIN_ZOOM,\n FOCUS_ZOOM,\n padding,\n ).zoom >= FOCUS_ZOOM;\n void fitView({\n nodes: (nearFits ? focus.near : [focus.id]).map((id) => ({ id })),\n minZoom: FOCUS_ZOOM,\n maxZoom: FOCUS_ZOOM,\n padding,\n }).then(settle);\n }\n }\n }, [\n paneSized,\n laidOut,\n layout,\n focus,\n showMinimap,\n narrow,\n shape.direction,\n store,\n fitView,\n getNodes,\n getNodesBounds,\n setViewport,\n ]);\n return fittedTo === (focus?.id ?? null);\n}\n\n/**\n * The selected node of a map in a `DetailBeside`, once the view is fitted:\n * it places the node's box, again whenever the map pans or zooms, and at\n * 768 px and below draws the detail right under the node, over the map,\n * which grows to hold it.\n */\nfunction ServiceMapSelection({\n nodeId,\n selection,\n}: {\n nodeId: string;\n selection: SelectedRowDetail;\n}): JSX.Element | null {\n const transform = useStore((state) => state.transform);\n const domNode = useStore((state) => state.domNode);\n const node = useInternalNode(nodeId);\n // The node goes only with this component, so a pan places the same node\n // again rather than a new one.\n useIsomorphicLayoutEffect(\n () => () => {\n selection.placeRow(null);\n },\n [selection],\n );\n useIsomorphicLayoutEffect(() => {\n const group = domNode?.querySelector(\n `.react-flow__node[data-id=\"${CSS.escape(nodeId)}\"]`,\n );\n if (group instanceof HTMLElement) {\n selection.placeRow(group);\n }\n }, [selection, domNode, nodeId, transform]);\n const height = node?.measured.height;\n if (selection.inline === null || node === undefined || height === undefined) {\n return null;\n }\n const [, y, zoom] = transform;\n const bottom = (node.internals.positionAbsolute.y + height) * zoom + y;\n return (\n <div\n className=\"aegis-service-map__detail\"\n style={{ marginTop: Math.max(bottom, 0) }}\n >\n {selection.inline}\n </div>\n );\n}\n\n/**\n * Pans a node or edge that gets keyboard focus fully into view, centred.\n * React Flow pans only to a node entirely outside the view, and never to\n * an edge.\n */\nfunction usePanToFocused(): (event: FocusEvent<HTMLDivElement>) => void {\n const { getViewport, setViewport } = useReactFlow();\n return useCallback(\n (event: FocusEvent<HTMLDivElement>) => {\n const target = event.target;\n if (\n !(target instanceof Element) ||\n !target.matches(\n '.react-flow__node:focus-visible, .react-flow__edge:focus-visible',\n )\n ) {\n return;\n }\n // The browser has already scrolled the pane to the element, and React\n // Flow scrolls it back, so the offset is added back to place it.\n const { scrollLeft, scrollTop } = event.currentTarget;\n const pane = event.currentTarget.getBoundingClientRect();\n const box = target.getBoundingClientRect();\n const left = box.left - pane.left + scrollLeft;\n const top = box.top - pane.top + scrollTop;\n if (\n left >= 0 &&\n top >= 0 &&\n left + box.width <= pane.width &&\n top + box.height <= pane.height\n ) {\n return;\n }\n const { x, y, zoom } = getViewport();\n void setViewport({\n x: x + pane.width / 2 - (left + box.width / 2),\n y: y + pane.height / 2 - (top + box.height / 2),\n zoom,\n });\n },\n [getViewport, setViewport],\n );\n}\n\nfunction ServiceMapInner({\n nodes,\n edges,\n groups = [],\n direction = 'LR',\n height,\n fillViewport = false,\n onNodeClick,\n onEdgeClick,\n selectedNodeId,\n focusNodeId,\n minimap = focusNodeId === undefined,\n ariaLabel,\n className,\n}: ServiceMapProps): JSX.Element {\n const strings = useStrings();\n const idPrefix = useId();\n // React Flow names its elements after this id ('1' when none is given),\n // so each map passes its own and a page can hold several.\n const flowId = `aegis-service-map${idPrefix.replace(/:/g, '-')}`;\n const nodesSelectable = onNodeClick !== undefined;\n const edgesSelectable = onEdgeClick !== undefined;\n // Node sizes as React Flow measured them; the layout reads them, so a\n // node can be as wide as its label.\n const [measured, setMeasured] = useState<ReadonlyMap<string, Size>>(\n () => new Map(),\n );\n const shapeJson = useMemo(\n () => JSON.stringify(shapeOf(nodes, edges, groups, direction)),\n [nodes, edges, groups, direction],\n );\n // Parsed back from its JSON, so the shape is a new object only when it\n // changes, not when the parent passes equal arrays again.\n const shape = useMemo(() => JSON.parse(shapeJson) as MapShape, [shapeJson]);\n const layout = useMemo(\n () => computeLayout(shape, measured, idPrefix),\n [shape, measured, idPrefix],\n );\n const isHorizontal = direction === 'LR';\n const flowNodes = useMemo(\n (): ServiceFlowNode[] => [\n ...layout.groups,\n ...nodes.map((n): ServiceFlowNode => {\n // A node in a group is described by the group's label. React Flow\n // describes a node by its keyboard help, the element it names\n // `react-flow__node-desc-<rfId>`; a node that cannot be selected\n // has none.\n const describedBy = [\n layout.groupLabels.get(n.id),\n nodesSelectable ? `react-flow__node-desc-${flowId}` : undefined,\n ]\n .filter(Boolean)\n .join(' ');\n return {\n id: n.id,\n type: 'service',\n position: layout.positions.get(n.id) ?? { x: 0, y: 0 },\n // Handed back as applyNodeChanges would, so React Flow keeps the\n // size it measured instead of measuring the node again.\n measured: measured.get(n.id),\n ariaLabel: n.label,\n // React Flow gives only a focusable node a role, and the role\n // description below needs one.\n ariaRole: 'group',\n domAttributes: {\n 'aria-roledescription': strings.serviceMapNodeRole,\n // A group takes no aria-selected.\n 'aria-current': selectedNodeId === n.id ? true : undefined,\n 'aria-describedby': describedBy === '' ? undefined : describedBy,\n },\n data: { node: n, selected: selectedNodeId === n.id },\n sourcePosition: isHorizontal ? Position.Right : Position.Bottom,\n targetPosition: isHorizontal ? Position.Left : Position.Top,\n draggable: false,\n connectable: false,\n selectable: nodesSelectable,\n focusable: nodesSelectable,\n };\n }),\n ],\n [\n layout,\n nodes,\n measured,\n selectedNodeId,\n isHorizontal,\n nodesSelectable,\n flowId,\n strings,\n ],\n );\n const flowEdges = useMemo((): Array<Edge<ServiceEdgeData>> => {\n const labelOf = new Map(nodes.map((n) => [n.id, n.label]));\n return edges.map((e) => ({\n id: e.id,\n source: e.source,\n target: e.target,\n ariaLabel: strings.serviceMapEdgeName(\n labelOf.get(e.source) ?? e.source,\n labelOf.get(e.target) ?? e.target,\n ),\n // React Flow makes an unfocusable edge an img; aria-roledescription needs a group.\n ariaRole: 'group',\n domAttributes: { 'aria-roledescription': strings.serviceMapEdgeRole },\n type: 'service',\n data: { edge: e },\n label: e.label,\n selectable: edgesSelectable,\n focusable: edgesSelectable,\n className: `aegis-service-map__edge aegis-service-map__edge--${e.status ?? 'ok'}`,\n }));\n }, [nodes, edges, edgesSelectable, strings]);\n\n const { getNode } = useReactFlow();\n const handleNodesChange = useCallback(\n (changes: Array<NodeChange<ServiceFlowNode>>) => {\n const resized = changes.flatMap((change) =>\n change.type === 'dimensions' &&\n change.dimensions !== undefined &&\n getNode(change.id)?.type === 'service'\n ? [[change.id, change.dimensions] as const]\n : [],\n );\n setMeasured((previous) =>\n resized.every(\n ([id, size]) =>\n previous.get(id)?.width === size.width &&\n previous.get(id)?.height === size.height,\n )\n ? previous\n : new Map([...previous, ...resized]),\n );\n },\n [getNode],\n );\n\n const narrow = useMediaQuery(NARROW_QUERY);\n const showMinimap = minimap && !narrow;\n const selection = useContext(SelectedRowDetailContext);\n const fitted = useFit(\n shape,\n layout,\n nodes.every((n) => measured.has(n.id)),\n focusNodeId,\n showMinimap,\n narrow,\n );\n const shownId =\n selectedNodeId !== undefined && shape.ids.includes(selectedNodeId)\n ? selectedNodeId\n : undefined;\n // A DetailBeside waits while the view is fitted to a newly selected node.\n useIsomorphicLayoutEffect(() => {\n if (selection === null || shownId === undefined || fitted) {\n return undefined;\n }\n selection.awaitRow();\n return () => {\n selection.placeRow(null);\n };\n }, [selection, shownId, fitted]);\n const handleFocus = usePanToFocused();\n\n const handleNodeClick = useCallback(\n (_: unknown, n: ServiceFlowNode) => {\n if (n.type === 'service') {\n onNodeClick?.(n.data.node);\n }\n },\n [onNodeClick],\n );\n const handleEdgeClick = useCallback(\n (_: unknown, e: Edge<ServiceEdgeData>) => {\n if (e.data) {\n onEdgeClick?.(e.data.edge);\n }\n },\n [onEdgeClick],\n );\n // React Flow's own Enter and Space only change its internal selection,\n // which never reaches the host, so a focused node or edge answers the\n // keys here, as a click would.\n const handleKeyDown = useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n if ((event.key !== 'Enter' && event.key !== ' ') || event.repeat) {\n return;\n }\n const target = event.target;\n if (!(target instanceof Element)) {\n return;\n }\n const id = target.getAttribute('data-id');\n if (target.classList.contains('react-flow__node')) {\n const node = nodes.find((n) => n.id === id);\n if (node && onNodeClick) {\n event.preventDefault();\n onNodeClick(node);\n }\n } else if (target.classList.contains('react-flow__edge')) {\n const edge = edges.find((e) => e.id === id);\n if (edge && onEdgeClick) {\n event.preventDefault();\n onEdgeClick(edge);\n }\n }\n },\n [nodes, edges, onNodeClick, onEdgeClick],\n );\n\n const style = {\n ...SIZE_VARS,\n height: height === undefined ? undefined : `${String(height)}px`,\n } as CSSProperties;\n\n return (\n <div\n className={[\n 'aegis-service-map',\n fillViewport ? 'aegis-service-map--fill-viewport' : '',\n className,\n ]\n .filter(Boolean)\n .join(' ')}\n style={style}\n >\n {/* Positioned over the whole box, so React Flow has a definite height\n even when the box only has its min-height. */}\n <div className=\"aegis-service-map__pane\">\n <ReactFlow\n id={flowId}\n aria-label={ariaLabel}\n nodes={flowNodes}\n edges={flowEdges}\n nodeTypes={NODE_TYPES}\n edgeTypes={EDGE_TYPES}\n minZoom={MIN_ZOOM}\n nodesDraggable={false}\n nodesConnectable={false}\n autoPanOnNodeFocus={false}\n panOnDrag\n zoomOnScroll\n proOptions={{ hideAttribution: true }}\n ariaLabelConfig={strings.serviceMapAriaLabels}\n onNodesChange={handleNodesChange}\n onNodeClick={nodesSelectable ? handleNodeClick : undefined}\n onEdgeClick={edgesSelectable ? handleEdgeClick : undefined}\n onKeyDown={handleKeyDown}\n onFocus={handleFocus}\n >\n <Background variant={BackgroundVariant.Dots} gap={16} size={1} />\n <Controls showInteractive={false} position=\"top-left\" />\n {showMinimap && (\n <MiniMap\n pannable\n zoomable\n position=\"bottom-right\"\n style={{ width: MINIMAP_WIDTH }}\n nodeClassName={minimapNodeClass}\n />\n )}\n </ReactFlow>\n </div>\n {selection !== null && fitted && shownId !== undefined && (\n <ServiceMapSelection nodeId={shownId} selection={selection} />\n )}\n </div>\n );\n}\n\nexport function ServiceMap(props: ServiceMapProps): JSX.Element {\n return (\n <ReactFlowProvider>\n <ServiceMapInner {...props} />\n </ReactFlowProvider>\n );\n}\n"],"names":["NODE_WIDTH","NODE_HEIGHT","NODE_MAX_WIDTH","GROUP_LABEL_HEIGHT","GROUP_GAP","SIZE_VARS","DEFAULT_SIZE","shapeOf","nodes","edges","groups","direction","ids","n","present","e","partsOf","claimed","grouped","group","id","rest","part","layoutPart","links","sizeOf","g","graphlib","source","target","dagreLayout","positions","x","y","size","width","height","computeLayout","shape","sizes","idPrefix","labelIdOf","horizontal","parts","laid","labelHeight","across","along","placed","origin","p","ServiceGroup","data","jsx","DOT_TONE","ServiceNode","node","selected","status","tone","jsxs","Handle","Position","StatusDot","ServiceEdge","props","sourceX","sourceY","targetX","targetY","label","markerEnd","style","pathId","useId","midX","path","Fragment","NODE_TYPES","EDGE_TYPES","NARROW_QUERY","FIT_MARGIN","MIN_ZOOM","FOCUS_ZOOM","READABLE_ZOOM","PANEL_INSET","CONTROLS_WIDTH","MINIMAP_WIDTH","px","value","neighbourhood","minimapNodeClass","useFit","layout","laidOut","focusNodeId","showMinimap","narrow","fitView","getNodes","getNodesBounds","setViewport","useReactFlow","store","useStoreApi","paneSized","useStore","state","focus","useMemo","fittedTo","setFittedTo","useState","useEffect","settle","padding","all","bounds","fitted","getViewportForBounds","zoom","first","a","b","w","h","nearFits","ServiceMapSelection","nodeId","selection","transform","domNode","useInternalNode","useIsomorphicLayoutEffect","bottom","usePanToFocused","getViewport","useCallback","event","scrollLeft","scrollTop","pane","box","left","top","ServiceMapInner","fillViewport","onNodeClick","onEdgeClick","selectedNodeId","minimap","ariaLabel","className","strings","useStrings","flowId","nodesSelectable","edgesSelectable","measured","setMeasured","shapeJson","isHorizontal","flowNodes","describedBy","flowEdges","labelOf","getNode","handleNodesChange","changes","resized","change","previous","useMediaQuery","useContext","SelectedRowDetailContext","shownId","handleFocus","handleNodeClick","_","handleEdgeClick","handleKeyDown","edge","ReactFlow","Background","BackgroundV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AAA,YAClB,oBAAoB;AAAA,YACpB,WAAS;AAAA,YACT,cAAY;AAAA,YACZ,YAAY,EAAE,iBAAiB,GAAA;AAAA,YAC/B,iBAAiBuE,EAAQ;AAAA,YACzB,eAAec;AAAA,YACf,aAAaX,IAAkBqB,KAAkB;AAAA,YACjD,aAAapB,IAAkBsB,KAAkB;AAAA,YACjD,WAAWC;AAAA,YACX,SAASJ;AAAA,YAET,UAAA;AAAA,cAAA,gBAAA3H,EAACkI,MAAW,SAASC,GAAkB,MAAM,KAAK,IAAI,MAAM,GAAG;AAAA,cAC/D,gBAAAnI,EAACoI,IAAA,EAAS,iBAAiB,IAAO,UAAS,YAAW;AAAA,cACrDzF,KACC,gBAAA3C;AAAA,gBAACqI;AAAA,gBAAA;AAAA,kBACC,UAAQ;AAAA,kBACR,UAAQ;AAAA,kBACR,UAAS;AAAA,kBACT,OAAO,EAAE,OAAOnG,GAAA;AAAA,kBAChB,eAAeI;AAAA,gBAAA;AAAA,cAAA;AAAA,YACjB;AAAA,UAAA;AAAA,QAAA,GAGN;AAAA,QACCsC,MAAc,QAAQX,KAAUyD,MAAY,UAC3C,gBAAA1H,EAAC0E,IAAA,EAAoB,QAAQgD,GAAS,WAAA9C,EAAA,CAAsB;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIpE;AAEO,SAAS0D,GAAW1H,GAAqC;AAC9D,2BACG2H,IAAA,EACC,UAAA,gBAAAvI,EAAC4F,IAAA,EAAiB,GAAGhF,GAAO,GAC9B;AAEJ;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),h=require("react"),he=require("antd"),pe=require("../../agent/core/usePrimitiveSurface.cjs"),fe=require("../../hooks/useResizable.cjs"),ge=require("../../lib/breakAtSeparators.cjs"),D=require("../../lib/format.cjs"),me=require("./Chip.cjs"),_e=require("./StatusDot.cjs");;/* empty css */const we=require("./linkComponent.cjs"),xe=require("./selectedRowDetail.cjs"),be=require("./traceStatus.cjs"),Se=require("../../locale/useStrings.cjs"),ve=180,Me=700,je=320;function q(c){return c.startMs!==void 0&&c.durationMs!==void 0}function V(c){c.every(o=>o.span.startMs!==void 0)&&c.sort((o,i)=>(o.span.startMs??0)-(i.span.startMs??0))}function ke(c){const o=new Map;c.forEach(n=>{o.set(n.id,{span:n,parent:null,children:[],depth:0})});const i=[];o.forEach(n=>{const u=n.span.parentId,l=u?o.get(u):void 0;l?(n.parent=l,l.children.push(n)):i.push(n)});const p=new Set,g=(n,u)=>{p.add(n),n.depth=u,n.children.forEach(l=>{g(l,u+1)})};i.forEach(n=>{g(n,0)}),o.forEach(n=>{if(p.has(n))return;const u=new Set;let l=n;for(;l.parent!==null&&!u.has(l);)u.add(l),l=l.parent;const d=l;d.parent!==null&&(d.parent.children=d.parent.children.filter(M=>M!==d),d.parent=null),i.push(d),g(d,0)});const x=n=>{V(n.children),n.children.forEach(x)};return V(i),i.forEach(x),i}function X(c,o,i=[]){return c.forEach((p,g)=>{i.push({node:p,position:g+1,siblings:c.length}),o.has(p.span.id)||X(p.children,o,i)}),i}function Ne({spans:c,selectedId:o,onSelect:i,defaultCollapsedDepth:p=Number.POSITIVE_INFINITY,ariaLabel:g,linkComponent:x=we.DefaultLink,className:n,style:u,surface:l,nameColumnWidth:d,defaultNameColumnWidth:M=je,onNameColumnWidthChange:R,persistKey:C,wrapName:A=!1}){const T=h.useRef(null),L=h.useRef(null),Y=pe.usePrimitiveSurface(l,c,"tree",T),j=Se.useStrings(),G=h.useId(),F=h.useContext(xe.SelectedRowDetailContext),{roots:k,traceDuration:P,traceStart:z,timed:N}=h.useMemo(()=>{const t=ke(c),a=c.filter(q),r=a.length?Math.min(...a.map(e=>e.startMs)):0,f=a.length?Math.max(...a.map(e=>e.startMs+e.durationMs)):1;return{roots:t,traceStart:r,traceDuration:Math.max(f-r,1),timed:a.length>0}},[c]),[b,J]=h.useState(()=>{const t=new Set,a=r=>{r.depth>=p&&r.children.length>0&&t.add(r.span.id),r.children.forEach(a)};return k.forEach(a),t}),[Q,K]=h.useState(void 0),m=h.useMemo(()=>X(k,b),[k,b]),O=t=>t===void 0?-1:m.findIndex(a=>a.node.span.id===t),$=O(Q),Z=$>=0?$:Math.max(O(o),0),ee=C!==void 0?`aegis-trace-tree-name-w:${C}`:void 0,{width:y,handleProps:te,isDragging:re}=fe.useResizable({initialWidth:M,minWidth:ve,maxWidth:Me,side:"left",persistKey:ee}),ae=d??y;h.useEffect(()=>{d===void 0&&R?.(y)},[y,d,R]);const E=t=>{J(a=>{const r=new Set(a);return r.has(t)?r.delete(t):r.add(t),r})},_=t=>{if(t<0||t>=m.length)return;K(m[t].node.span.id),L.current?.querySelectorAll(':scope > [role="treeitem"]')[t]?.focus()},se=(t,a)=>{const{node:r}=m[a],f=r.children.length>0,e=f&&!b.has(r.span.id);switch(t.key){case"ArrowDown":_(a+1);break;case"ArrowUp":_(a-1);break;case"Home":_(0);break;case"End":_(m.length-1);break;case"ArrowRight":e?_(a+1):f&&E(r.span.id);break;case"ArrowLeft":if(e)E(r.span.id);else if(r.parent!==null){const w=r.parent;_(m.findIndex(S=>S.node===w))}break;case"Enter":r.span.to!==void 0?t.currentTarget.querySelector(".aegis-trace-tree__name a")?.click():i?.(r.span);break;case" ":i?.(r.span);break;default:return}t.preventDefault()},ne=(t,a)=>{if(t.target instanceof Element&&t.target.closest("[data-trace-tree-caret]")!==null){E(a.span.id);return}(t.ctrlKey||t.metaKey||t.shiftKey)&&t.target instanceof Element&&t.target.closest(".aegis-trace-tree__name a")!==null||i?.(a.span)},ie=["aegis-trace-tree",re?"aegis-trace-tree--dragging":"",A?"aegis-trace-tree--wrap":"",N?"":"aegis-trace-tree--untimed",n??""].filter(Boolean).join(" "),ce={...u,"--aegis-trace-tree-name-w":`${String(ae)}px`};return s.jsxs("div",{ref:T,className:ie,style:ce,...Y,children:[s.jsx("div",{ref:L,className:"aegis-trace-tree__rows",role:"tree","aria-label":g??j.traceSpans,children:m.map(({node:t,position:a,siblings:r},f)=>{const e=t.span,w=t.children.length>0,S=b.has(e.id),v=o===e.id,oe=["aegis-trace-tree__row",e.muted?"aegis-trace-tree__row--muted":"",v?"aegis-trace-tree__row--selected":"",e.status==="error"?"aegis-trace-tree__row--error":""].filter(Boolean).join(" "),le=q(e)?j.traceSpanTiming(D.formatDuration(e.startMs-z),D.formatDuration(e.durationMs)):"",de=e.kind??"",B=[le,de].filter(Boolean).join(" · "),W=`${G}-note-${String(f)}`,U=e.note!==void 0&&e.note!==null,H=A?ge.breakAtSeparators(e.name):e.name,ue=s.jsxs("div",{className:"aegis-trace-tree__tooltip",children:[s.jsx("div",{className:"aegis-trace-tree__tooltip-name",children:e.name}),B&&s.jsx("div",{className:"aegis-trace-tree__tooltip-meta",children:B})]});return s.jsxs(h.Fragment,{children:[s.jsxs("div",{ref:v?F?.placeRow:void 0,className:oe,role:"treeitem","aria-label":e.ariaLabel,"aria-describedby":U?W:void 0,"aria-level":t.depth+1,"aria-posinset":a,"aria-setsize":r,"aria-expanded":w?!S:void 0,"aria-selected":v?!0:void 0,tabIndex:f===Z?0:-1,onClick:I=>{ne(I,t)},onKeyDown:I=>{se(I,f)},onFocus:()=>{K(e.id)},children:[s.jsxs("div",{className:"aegis-trace-tree__label",style:{"--depth":t.depth},children:[s.jsx("span",{className:w?"aegis-trace-tree__caret":"aegis-trace-tree__caret aegis-trace-tree__caret--leaf","aria-hidden":"true","data-trace-tree-caret":w?"":void 0,children:w?S?"▸":"▾":null}),s.jsx(_e.StatusDot,{tone:be.statusTone(e.status),size:6}),e.kind?s.jsx(me.Chip,{tone:"ghost",className:"aegis-trace-tree__kind",children:e.kind}):null,s.jsx(he.Tooltip,{placement:"topLeft",mouseEnterDelay:.3,styles:{root:{maxWidth:"var(--tooltip-max-width)"}},title:ue,children:s.jsx("span",{className:"aegis-trace-tree__name",children:e.to===void 0?H:s.jsx(x,{to:e.to,className:"aegis-trace-tree__link",tabIndex:-1,children:H})})}),U?s.jsx("span",{id:W,className:"aegis-trace-tree__note","aria-hidden":"true",children:e.note}):null]}),N&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"aegis-trace-tree__gutter","aria-hidden":"true"}),s.jsx("div",{className:"aegis-trace-tree__bar-track","aria-hidden":"true",children:q(e)&&s.jsx("span",{className:"aegis-trace-tree__bar",style:{left:`${((e.startMs-z)/P*100).toString()}%`,width:`${Math.max(e.durationMs/P*100,.5).toString()}%`}})}),s.jsx("div",{className:"aegis-trace-tree__duration",children:e.durationMs!==void 0&&D.formatDuration(e.durationMs)})]})]}),v?F?.inline:null]},e.id)})}),N&&s.jsx("div",{...te,className:"aegis-trace-tree__handle","aria-label":j.resizeNameColumn})]})}exports.TraceTree=Ne;
|
|
2
2
|
//# sourceMappingURL=TraceTree.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TraceTree.cjs","sources":["../../../src/components/ui/TraceTree.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type KeyboardEvent,\n type MouseEvent,\n type ReactNode,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { Tooltip } from 'antd';\n\nimport {\n type PrimitiveSurface,\n usePrimitiveSurface,\n} from '../../agent/core/usePrimitiveSurface';\nimport { useResizable } from '../../hooks/useResizable';\nimport { breakAtSeparators } from '../../lib/breakAtSeparators';\nimport type { ChartColor } from '../../lib/chart';\nimport { formatDuration } from '../../lib/format';\nimport { useStrings } from '../../locale';\nimport { Chip } from './Chip';\nimport { StatusDot } from './StatusDot';\nimport './TraceTree.css';\nimport { DefaultLink, type LinkComponent } from './linkComponent';\nimport { statusTone } from './traceStatus';\n\nexport type TraceTreeSurface = PrimitiveSurface<TraceSpan[]>;\n\nexport interface TraceSpan {\n id: string;\n parentId?: string | null;\n name: string;\n /**\n * Milliseconds since trace start. Leave `startMs` and `durationMs` out for a\n * span whose time is not recorded: its row draws no bar, and siblings that are\n * not all timed keep the order they are given in.\n */\n startMs?: number;\n durationMs?: number;\n status?: 'ok' | 'error' | 'unset';\n /**\n * The span's category: a chip on the left of its `TraceTree` row, and,\n * without `color`, the colour of its `TimelineChart` bar (one per kind).\n */\n kind?: string;\n /**\n * The colour of its `TimelineChart` bar. Set it from a stable key when\n * `kind` is translated, so the colour does not follow the language.\n */\n color?: ChartColor;\n /** Drawn at the end of the span's `TimelineChart` bar. */\n badge?: ReactNode;\n /**\n * Drawn at the end of the span's name in its `TraceTree` row, e.g. a change\n * mark or a count. It is the row's accessible description, not part of its\n * name. Give a Chip in it `inverted` while the span is selected.\n */\n note?: ReactNode;\n /**\n * Draws the span's `TraceTree` row in muted ink, e.g. for a span that only\n * the trace it is compared with has.\n */\n muted?: boolean;\n /** The accessible name of the span's `TraceTree` row. Default: the row's text. */\n ariaLabel?: string;\n /**\n * Makes the span's name in its `TraceTree` row a link to this\n * destination. The row stays the tree's tab stop: the link is not a tab\n * stop, and Enter on the row follows it.\n */\n to?: string;\n /** Free-form attributes — only used by the inspector pane, not by the row itself. */\n attrs?: Record<string, unknown>;\n}\n\ninterface TimedSpan extends TraceSpan {\n startMs: number;\n durationMs: number;\n}\n\ninterface TraceTreeProps {\n /**\n * The spans in any order. A span whose `parentId` names no span is a root;\n * spans whose parents form a cycle are cut at one span of the cycle, which\n * becomes a root.\n */\n spans: TraceSpan[];\n selectedId?: string;\n onSelect?: (span: TraceSpan) => void;\n /**\n * Rows at this depth or deeper start collapsed when they have children.\n * Roots are depth 0, so `0` shows only the roots and `1` the roots and\n * their children. Applies to the spans present when the tree mounts.\n * Default: every row expanded.\n */\n defaultCollapsedDepth?: number;\n /** The tree's accessible name. Default: the locale's `traceSpans`. */\n ariaLabel?: string;\n /** Renders the names of spans with `to`. Defaults to an `<a href>`; routed apps pass their Link adapter. */\n linkComponent?: LinkComponent;\n className?: string;\n style?: CSSProperties;\n surface?: TraceTreeSurface;\n nameColumnWidth?: number;\n defaultNameColumnWidth?: number;\n onNameColumnWidthChange?: (w: number) => void;\n persistKey?: string;\n /**\n * Wraps a long name over lines instead of truncating it: between words and\n * after `_ . - / :`, and inside a word only when it cannot fit a line.\n */\n wrapName?: boolean;\n}\n\ninterface Node {\n span: TraceSpan;\n parent: Node | null;\n children: Node[];\n depth: number;\n}\n\ninterface VisibleRow {\n node: Node;\n /** 1-based position among its siblings. */\n position: number;\n siblings: number;\n}\n\nconst NAME_COL_MIN = 180;\nconst NAME_COL_MAX = 700;\nconst NAME_COL_DEFAULT = 320;\n\nfunction isTimed(span: TraceSpan): span is TimedSpan {\n return span.startMs !== undefined && span.durationMs !== undefined;\n}\n\nfunction sortByStart(nodes: Node[]): void {\n if (nodes.every((n) => n.span.startMs !== undefined)) {\n nodes.sort((a, b) => (a.span.startMs ?? 0) - (b.span.startMs ?? 0));\n }\n}\n\nfunction buildForest(spans: TraceSpan[]): Node[] {\n const byId = new Map<string, Node>();\n spans.forEach((span) => {\n byId.set(span.id, { span, parent: null, children: [], depth: 0 });\n });\n const roots: Node[] = [];\n byId.forEach((node) => {\n const pid = node.span.parentId;\n const parent = pid ? byId.get(pid) : undefined;\n if (parent) {\n node.parent = parent;\n parent.children.push(node);\n } else {\n roots.push(node);\n }\n });\n\n const placed = new Set<Node>();\n const place = (node: Node, depth: number): void => {\n placed.add(node);\n node.depth = depth;\n node.children.forEach((child) => {\n place(child, depth + 1);\n });\n };\n roots.forEach((root) => {\n place(root, 0);\n });\n // A span no root reaches hangs below a cycle of parents. Climbing from it\n // comes back round to a span on the cycle, which becomes a root.\n byId.forEach((node) => {\n if (placed.has(node)) {\n return;\n }\n const climbed = new Set<Node>();\n let onCycle = node;\n while (onCycle.parent !== null && !climbed.has(onCycle)) {\n climbed.add(onCycle);\n onCycle = onCycle.parent;\n }\n const cut = onCycle;\n if (cut.parent !== null) {\n cut.parent.children = cut.parent.children.filter((c) => c !== cut);\n cut.parent = null;\n }\n roots.push(cut);\n place(cut, 0);\n });\n\n const sortRec = (n: Node): void => {\n sortByStart(n.children);\n n.children.forEach(sortRec);\n };\n sortByStart(roots);\n roots.forEach(sortRec);\n return roots;\n}\n\nfunction flatten(\n nodes: Node[],\n collapsed: Set<string>,\n out: VisibleRow[] = [],\n): VisibleRow[] {\n nodes.forEach((node, index) => {\n out.push({ node, position: index + 1, siblings: nodes.length });\n if (!collapsed.has(node.span.id)) {\n flatten(node.children, collapsed, out);\n }\n });\n return out;\n}\n\nexport function TraceTree({\n spans,\n selectedId,\n onSelect,\n defaultCollapsedDepth = Number.POSITIVE_INFINITY,\n ariaLabel,\n linkComponent: Link = DefaultLink,\n className,\n style,\n surface,\n nameColumnWidth,\n defaultNameColumnWidth = NAME_COL_DEFAULT,\n onNameColumnWidthChange,\n persistKey,\n wrapName = false,\n}: TraceTreeProps) {\n const wrapRef = useRef<HTMLDivElement>(null);\n const treeRef = useRef<HTMLDivElement>(null);\n const agentAttrs = usePrimitiveSurface(surface, spans, 'tree', wrapRef);\n const strings = useStrings();\n const idPrefix = useId();\n const { roots, traceDuration, traceStart, timed } = useMemo(() => {\n const r = buildForest(spans);\n const timedSpans = spans.filter(isTimed);\n const start = timedSpans.length\n ? Math.min(...timedSpans.map((s) => s.startMs))\n : 0;\n const end = timedSpans.length\n ? Math.max(...timedSpans.map((s) => s.startMs + s.durationMs))\n : 1;\n return {\n roots: r,\n traceStart: start,\n traceDuration: Math.max(end - start, 1),\n timed: timedSpans.length > 0,\n };\n }, [spans]);\n\n const [collapsed, setCollapsed] = useState<Set<string>>(() => {\n const init = new Set<string>();\n const walk = (n: Node): void => {\n if (n.depth >= defaultCollapsedDepth && n.children.length > 0) {\n init.add(n.span.id);\n }\n n.children.forEach(walk);\n };\n roots.forEach(walk);\n return init;\n });\n const [focusedId, setFocusedId] = useState<string | undefined>(undefined);\n\n const visible = useMemo(() => flatten(roots, collapsed), [roots, collapsed]);\n\n // One tab stop: the row last focused, else the selected row, else the first.\n const rowIndexOf = (id: string | undefined): number =>\n id === undefined ? -1 : visible.findIndex((r) => r.node.span.id === id);\n const focusedIndex = rowIndexOf(focusedId);\n const tabStopIndex =\n focusedIndex >= 0 ? focusedIndex : Math.max(rowIndexOf(selectedId), 0);\n\n const resizePersistKey =\n persistKey !== undefined\n ? `aegis-trace-tree-name-w:${persistKey}`\n : undefined;\n\n const {\n width: internalWidth,\n handleProps,\n isDragging,\n } = useResizable({\n initialWidth: defaultNameColumnWidth,\n minWidth: NAME_COL_MIN,\n maxWidth: NAME_COL_MAX,\n side: 'left',\n persistKey: resizePersistKey,\n });\n\n const effectiveWidth = nameColumnWidth ?? internalWidth;\n\n useEffect(() => {\n if (nameColumnWidth === undefined) {\n onNameColumnWidthChange?.(internalWidth);\n }\n }, [internalWidth, nameColumnWidth, onNameColumnWidthChange]);\n\n const toggle = (id: string): void => {\n setCollapsed((prev) => {\n const next = new Set(prev);\n if (next.has(id)) {\n next.delete(id);\n } else {\n next.add(id);\n }\n return next;\n });\n };\n\n const focusRow = (index: number): void => {\n if (index < 0 || index >= visible.length) {\n return;\n }\n setFocusedId(visible[index].node.span.id);\n const row = treeRef.current?.querySelectorAll<HTMLElement>(\n ':scope > [role=\"treeitem\"]',\n )[index];\n row?.focus();\n };\n\n const handleRowKeyDown = (\n event: KeyboardEvent<HTMLDivElement>,\n index: number,\n ): void => {\n const { node } = visible[index];\n const expandable = node.children.length > 0;\n const expanded = expandable && !collapsed.has(node.span.id);\n switch (event.key) {\n case 'ArrowDown':\n focusRow(index + 1);\n break;\n case 'ArrowUp':\n focusRow(index - 1);\n break;\n case 'Home':\n focusRow(0);\n break;\n case 'End':\n focusRow(visible.length - 1);\n break;\n case 'ArrowRight':\n if (expanded) {\n focusRow(index + 1);\n } else if (expandable) {\n toggle(node.span.id);\n }\n break;\n case 'ArrowLeft':\n if (expanded) {\n toggle(node.span.id);\n } else if (node.parent !== null) {\n const parent = node.parent;\n focusRow(visible.findIndex((r) => r.node === parent));\n }\n break;\n // The link's click reaches the row, which selects it too.\n case 'Enter':\n if (node.span.to !== undefined) {\n event.currentTarget\n .querySelector<HTMLElement>('.aegis-trace-tree__name a')\n ?.click();\n } else {\n onSelect?.(node.span);\n }\n break;\n case ' ':\n onSelect?.(node.span);\n break;\n default:\n return;\n }\n event.preventDefault();\n };\n\n const handleRowClick = (event: MouseEvent<HTMLDivElement>, node: Node) => {\n if (\n event.target instanceof Element &&\n event.target.closest('[data-trace-tree-caret]') !== null\n ) {\n toggle(node.span.id);\n return;\n }\n // A modified click opens the name's link elsewhere and leaves this\n // page's selection alone.\n if (\n (event.ctrlKey || event.metaKey || event.shiftKey) &&\n event.target instanceof Element &&\n event.target.closest('.aegis-trace-tree__name a') !== null\n ) {\n return;\n }\n onSelect?.(node.span);\n };\n\n const cls = [\n 'aegis-trace-tree',\n isDragging ? 'aegis-trace-tree--dragging' : '',\n wrapName ? 'aegis-trace-tree--wrap' : '',\n timed ? '' : 'aegis-trace-tree--untimed',\n className ?? '',\n ]\n .filter(Boolean)\n .join(' ');\n\n const rootStyle = {\n ...style,\n '--aegis-trace-tree-name-w': `${String(effectiveWidth)}px`,\n } as CSSProperties;\n\n return (\n <div ref={wrapRef} className={cls} style={rootStyle} {...agentAttrs}>\n <div\n ref={treeRef}\n className=\"aegis-trace-tree__rows\"\n role=\"tree\"\n aria-label={ariaLabel ?? strings.traceSpans}\n >\n {visible.map(({ node, position, siblings }, index) => {\n const span = node.span;\n const hasChildren = node.children.length > 0;\n const isCollapsed = collapsed.has(span.id);\n const isSelected = selectedId === span.id;\n const rowCls = [\n 'aegis-trace-tree__row',\n span.muted ? 'aegis-trace-tree__row--muted' : '',\n isSelected ? 'aegis-trace-tree__row--selected' : '',\n span.status === 'error' ? 'aegis-trace-tree__row--error' : '',\n ]\n .filter(Boolean)\n .join(' ');\n\n const timing = isTimed(span)\n ? strings.traceSpanTiming(\n formatDuration(span.startMs - traceStart),\n formatDuration(span.durationMs),\n )\n : '';\n const kind = span.kind ?? '';\n const meta = [timing, kind].filter(Boolean).join(' · ');\n const noteId = `${idPrefix}-note-${String(index)}`;\n const hasNote = span.note !== undefined && span.note !== null;\n const name = wrapName ? breakAtSeparators(span.name) : span.name;\n const tooltipContent = (\n <div className=\"aegis-trace-tree__tooltip\">\n <div className=\"aegis-trace-tree__tooltip-name\">{span.name}</div>\n {meta && (\n <div className=\"aegis-trace-tree__tooltip-meta\">{meta}</div>\n )}\n </div>\n );\n\n return (\n <div\n key={span.id}\n className={rowCls}\n role=\"treeitem\"\n aria-label={span.ariaLabel}\n aria-describedby={hasNote ? noteId : undefined}\n aria-level={node.depth + 1}\n aria-posinset={position}\n aria-setsize={siblings}\n aria-expanded={hasChildren ? !isCollapsed : undefined}\n aria-selected={isSelected ? true : undefined}\n tabIndex={index === tabStopIndex ? 0 : -1}\n onClick={(event) => {\n handleRowClick(event, node);\n }}\n onKeyDown={(event) => {\n handleRowKeyDown(event, index);\n }}\n onFocus={() => {\n setFocusedId(span.id);\n }}\n >\n <div\n className=\"aegis-trace-tree__label\"\n style={\n {\n '--depth': node.depth,\n } as CSSProperties\n }\n >\n <span\n className={\n hasChildren\n ? 'aegis-trace-tree__caret'\n : 'aegis-trace-tree__caret aegis-trace-tree__caret--leaf'\n }\n aria-hidden=\"true\"\n data-trace-tree-caret={hasChildren ? '' : undefined}\n >\n {hasChildren ? (isCollapsed ? '▸' : '▾') : null}\n </span>\n <StatusDot tone={statusTone(span.status)} size={6} />\n {span.kind ? (\n <Chip tone=\"ghost\" className=\"aegis-trace-tree__kind\">\n {span.kind}\n </Chip>\n ) : null}\n <Tooltip\n placement=\"topLeft\"\n mouseEnterDelay={0.3}\n styles={{ root: { maxWidth: 'var(--tooltip-max-width)' } }}\n title={tooltipContent}\n >\n <span className=\"aegis-trace-tree__name\">\n {span.to === undefined ? (\n name\n ) : (\n <Link\n to={span.to}\n className=\"aegis-trace-tree__link\"\n tabIndex={-1}\n >\n {name}\n </Link>\n )}\n </span>\n </Tooltip>\n {hasNote ? (\n <span\n id={noteId}\n className=\"aegis-trace-tree__note\"\n aria-hidden=\"true\"\n >\n {span.note}\n </span>\n ) : null}\n </div>\n {timed && (\n <>\n <span\n className=\"aegis-trace-tree__gutter\"\n aria-hidden=\"true\"\n />\n <div\n className=\"aegis-trace-tree__bar-track\"\n aria-hidden=\"true\"\n >\n {isTimed(span) && (\n <span\n className=\"aegis-trace-tree__bar\"\n style={{\n left: `${(((span.startMs - traceStart) / traceDuration) * 100).toString()}%`,\n width: `${Math.max((span.durationMs / traceDuration) * 100, 0.5).toString()}%`,\n }}\n />\n )}\n </div>\n <div className=\"aegis-trace-tree__duration\">\n {span.durationMs !== undefined &&\n formatDuration(span.durationMs)}\n </div>\n </>\n )}\n </div>\n );\n })}\n </div>\n {timed && (\n <div\n {...handleProps}\n className=\"aegis-trace-tree__handle\"\n aria-label={strings.resizeNameColumn}\n />\n )}\n </div>\n );\n}\n"],"names":["NAME_COL_MIN","NAME_COL_MAX","NAME_COL_DEFAULT","isTimed","span","sortByStart","nodes","n","a","b","buildForest","spans","byId","roots","node","pid","parent","placed","place","depth","child","root","climbed","onCycle","cut","c","sortRec","flatten","collapsed","out","index","TraceTree","selectedId","onSelect","defaultCollapsedDepth","ariaLabel","Link","DefaultLink","className","style","surface","nameColumnWidth","defaultNameColumnWidth","onNameColumnWidthChange","persistKey","wrapName","wrapRef","useRef","treeRef","agentAttrs","usePrimitiveSurface","strings","useStrings","idPrefix","useId","traceDuration","traceStart","timed","useMemo","r","timedSpans","start","s","end","setCollapsed","useState","init","walk","focusedId","setFocusedId","visible","rowIndexOf","id","focusedIndex","tabStopIndex","resizePersistKey","internalWidth","handleProps","isDragging","useResizable","effectiveWidth","useEffect","toggle","prev","next","focusRow","handleRowKeyDown","event","expandable","expanded","handleRowClick","cls","rootStyle","jsxs","jsx","position","siblings","hasChildren","isCollapsed","isSelected","rowCls","timing","formatDuration","kind","meta","noteId","hasNote","name","breakAtSeparators","tooltipContent","StatusDot","statusTone","Chip","Tooltip","Fragment"],"mappings":"qhBAmIMA,GAAe,IACfC,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"file":"TraceTree.cjs","sources":["../../../src/components/ui/TraceTree.tsx"],"sourcesContent":["import {\n type CSSProperties,\n Fragment,\n type KeyboardEvent,\n type MouseEvent,\n type ReactNode,\n useContext,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { Tooltip } from 'antd';\n\nimport {\n type PrimitiveSurface,\n usePrimitiveSurface,\n} from '../../agent/core/usePrimitiveSurface';\nimport { useResizable } from '../../hooks/useResizable';\nimport { breakAtSeparators } from '../../lib/breakAtSeparators';\nimport type { ChartColor } from '../../lib/chart';\nimport { formatDuration } from '../../lib/format';\nimport { useStrings } from '../../locale';\nimport { Chip } from './Chip';\nimport { StatusDot } from './StatusDot';\nimport './TraceTree.css';\nimport { DefaultLink, type LinkComponent } from './linkComponent';\nimport { SelectedRowDetailContext } from './selectedRowDetail';\nimport { statusTone } from './traceStatus';\n\nexport type TraceTreeSurface = PrimitiveSurface<TraceSpan[]>;\n\nexport interface TraceSpan {\n id: string;\n parentId?: string | null;\n name: string;\n /**\n * Milliseconds since trace start. Leave `startMs` and `durationMs` out for a\n * span whose time is not recorded: its row draws no bar, and siblings that are\n * not all timed keep the order they are given in.\n */\n startMs?: number;\n durationMs?: number;\n status?: 'ok' | 'error' | 'unset';\n /**\n * The span's category: a chip on the left of its `TraceTree` row, and,\n * without `color`, the colour of its `TimelineChart` bar (one per kind).\n */\n kind?: string;\n /**\n * The colour of its `TimelineChart` bar. Set it from a stable key when\n * `kind` is translated, so the colour does not follow the language.\n */\n color?: ChartColor;\n /** Drawn at the end of the span's `TimelineChart` bar. */\n badge?: ReactNode;\n /**\n * Drawn at the end of the span's name in its `TraceTree` row, e.g. a change\n * mark or a count. It is the row's accessible description, not part of its\n * name. Give a Chip in it `inverted` while the span is selected.\n */\n note?: ReactNode;\n /**\n * Draws the span's `TraceTree` row in muted ink, e.g. for a span that only\n * the trace it is compared with has.\n */\n muted?: boolean;\n /** The accessible name of the span's `TraceTree` row. Default: the row's text. */\n ariaLabel?: string;\n /**\n * Makes the span's name in its `TraceTree` row a link to this\n * destination. The row stays the tree's tab stop: the link is not a tab\n * stop, and Enter on the row follows it.\n */\n to?: string;\n /** Free-form attributes — only used by the inspector pane, not by the row itself. */\n attrs?: Record<string, unknown>;\n}\n\ninterface TimedSpan extends TraceSpan {\n startMs: number;\n durationMs: number;\n}\n\ninterface TraceTreeProps {\n /**\n * The spans in any order. A span whose `parentId` names no span is a root;\n * spans whose parents form a cycle are cut at one span of the cycle, which\n * becomes a root.\n */\n spans: TraceSpan[];\n selectedId?: string;\n onSelect?: (span: TraceSpan) => void;\n /**\n * Rows at this depth or deeper start collapsed when they have children.\n * Roots are depth 0, so `0` shows only the roots and `1` the roots and\n * their children. Applies to the spans present when the tree mounts.\n * Default: every row expanded.\n */\n defaultCollapsedDepth?: number;\n /** The tree's accessible name. Default: the locale's `traceSpans`. */\n ariaLabel?: string;\n /** Renders the names of spans with `to`. Defaults to an `<a href>`; routed apps pass their Link adapter. */\n linkComponent?: LinkComponent;\n className?: string;\n style?: CSSProperties;\n surface?: TraceTreeSurface;\n nameColumnWidth?: number;\n defaultNameColumnWidth?: number;\n onNameColumnWidthChange?: (w: number) => void;\n persistKey?: string;\n /**\n * Wraps a long name over lines instead of truncating it: between words and\n * after `_ . - / :`, and inside a word only when it cannot fit a line.\n */\n wrapName?: boolean;\n}\n\ninterface Node {\n span: TraceSpan;\n parent: Node | null;\n children: Node[];\n depth: number;\n}\n\ninterface VisibleRow {\n node: Node;\n /** 1-based position among its siblings. */\n position: number;\n siblings: number;\n}\n\nconst NAME_COL_MIN = 180;\nconst NAME_COL_MAX = 700;\nconst NAME_COL_DEFAULT = 320;\n\nfunction isTimed(span: TraceSpan): span is TimedSpan {\n return span.startMs !== undefined && span.durationMs !== undefined;\n}\n\nfunction sortByStart(nodes: Node[]): void {\n if (nodes.every((n) => n.span.startMs !== undefined)) {\n nodes.sort((a, b) => (a.span.startMs ?? 0) - (b.span.startMs ?? 0));\n }\n}\n\nfunction buildForest(spans: TraceSpan[]): Node[] {\n const byId = new Map<string, Node>();\n spans.forEach((span) => {\n byId.set(span.id, { span, parent: null, children: [], depth: 0 });\n });\n const roots: Node[] = [];\n byId.forEach((node) => {\n const pid = node.span.parentId;\n const parent = pid ? byId.get(pid) : undefined;\n if (parent) {\n node.parent = parent;\n parent.children.push(node);\n } else {\n roots.push(node);\n }\n });\n\n const placed = new Set<Node>();\n const place = (node: Node, depth: number): void => {\n placed.add(node);\n node.depth = depth;\n node.children.forEach((child) => {\n place(child, depth + 1);\n });\n };\n roots.forEach((root) => {\n place(root, 0);\n });\n // A span no root reaches hangs below a cycle of parents. Climbing from it\n // comes back round to a span on the cycle, which becomes a root.\n byId.forEach((node) => {\n if (placed.has(node)) {\n return;\n }\n const climbed = new Set<Node>();\n let onCycle = node;\n while (onCycle.parent !== null && !climbed.has(onCycle)) {\n climbed.add(onCycle);\n onCycle = onCycle.parent;\n }\n const cut = onCycle;\n if (cut.parent !== null) {\n cut.parent.children = cut.parent.children.filter((c) => c !== cut);\n cut.parent = null;\n }\n roots.push(cut);\n place(cut, 0);\n });\n\n const sortRec = (n: Node): void => {\n sortByStart(n.children);\n n.children.forEach(sortRec);\n };\n sortByStart(roots);\n roots.forEach(sortRec);\n return roots;\n}\n\nfunction flatten(\n nodes: Node[],\n collapsed: Set<string>,\n out: VisibleRow[] = [],\n): VisibleRow[] {\n nodes.forEach((node, index) => {\n out.push({ node, position: index + 1, siblings: nodes.length });\n if (!collapsed.has(node.span.id)) {\n flatten(node.children, collapsed, out);\n }\n });\n return out;\n}\n\nexport function TraceTree({\n spans,\n selectedId,\n onSelect,\n defaultCollapsedDepth = Number.POSITIVE_INFINITY,\n ariaLabel,\n linkComponent: Link = DefaultLink,\n className,\n style,\n surface,\n nameColumnWidth,\n defaultNameColumnWidth = NAME_COL_DEFAULT,\n onNameColumnWidthChange,\n persistKey,\n wrapName = false,\n}: TraceTreeProps) {\n const wrapRef = useRef<HTMLDivElement>(null);\n const treeRef = useRef<HTMLDivElement>(null);\n const agentAttrs = usePrimitiveSurface(surface, spans, 'tree', wrapRef);\n const strings = useStrings();\n const idPrefix = useId();\n const selection = useContext(SelectedRowDetailContext);\n const { roots, traceDuration, traceStart, timed } = useMemo(() => {\n const r = buildForest(spans);\n const timedSpans = spans.filter(isTimed);\n const start = timedSpans.length\n ? Math.min(...timedSpans.map((s) => s.startMs))\n : 0;\n const end = timedSpans.length\n ? Math.max(...timedSpans.map((s) => s.startMs + s.durationMs))\n : 1;\n return {\n roots: r,\n traceStart: start,\n traceDuration: Math.max(end - start, 1),\n timed: timedSpans.length > 0,\n };\n }, [spans]);\n\n const [collapsed, setCollapsed] = useState<Set<string>>(() => {\n const init = new Set<string>();\n const walk = (n: Node): void => {\n if (n.depth >= defaultCollapsedDepth && n.children.length > 0) {\n init.add(n.span.id);\n }\n n.children.forEach(walk);\n };\n roots.forEach(walk);\n return init;\n });\n const [focusedId, setFocusedId] = useState<string | undefined>(undefined);\n\n const visible = useMemo(() => flatten(roots, collapsed), [roots, collapsed]);\n\n // One tab stop: the row last focused, else the selected row, else the first.\n const rowIndexOf = (id: string | undefined): number =>\n id === undefined ? -1 : visible.findIndex((r) => r.node.span.id === id);\n const focusedIndex = rowIndexOf(focusedId);\n const tabStopIndex =\n focusedIndex >= 0 ? focusedIndex : Math.max(rowIndexOf(selectedId), 0);\n\n const resizePersistKey =\n persistKey !== undefined\n ? `aegis-trace-tree-name-w:${persistKey}`\n : undefined;\n\n const {\n width: internalWidth,\n handleProps,\n isDragging,\n } = useResizable({\n initialWidth: defaultNameColumnWidth,\n minWidth: NAME_COL_MIN,\n maxWidth: NAME_COL_MAX,\n side: 'left',\n persistKey: resizePersistKey,\n });\n\n const effectiveWidth = nameColumnWidth ?? internalWidth;\n\n useEffect(() => {\n if (nameColumnWidth === undefined) {\n onNameColumnWidthChange?.(internalWidth);\n }\n }, [internalWidth, nameColumnWidth, onNameColumnWidthChange]);\n\n const toggle = (id: string): void => {\n setCollapsed((prev) => {\n const next = new Set(prev);\n if (next.has(id)) {\n next.delete(id);\n } else {\n next.add(id);\n }\n return next;\n });\n };\n\n const focusRow = (index: number): void => {\n if (index < 0 || index >= visible.length) {\n return;\n }\n setFocusedId(visible[index].node.span.id);\n const row = treeRef.current?.querySelectorAll<HTMLElement>(\n ':scope > [role=\"treeitem\"]',\n )[index];\n row?.focus();\n };\n\n const handleRowKeyDown = (\n event: KeyboardEvent<HTMLDivElement>,\n index: number,\n ): void => {\n const { node } = visible[index];\n const expandable = node.children.length > 0;\n const expanded = expandable && !collapsed.has(node.span.id);\n switch (event.key) {\n case 'ArrowDown':\n focusRow(index + 1);\n break;\n case 'ArrowUp':\n focusRow(index - 1);\n break;\n case 'Home':\n focusRow(0);\n break;\n case 'End':\n focusRow(visible.length - 1);\n break;\n case 'ArrowRight':\n if (expanded) {\n focusRow(index + 1);\n } else if (expandable) {\n toggle(node.span.id);\n }\n break;\n case 'ArrowLeft':\n if (expanded) {\n toggle(node.span.id);\n } else if (node.parent !== null) {\n const parent = node.parent;\n focusRow(visible.findIndex((r) => r.node === parent));\n }\n break;\n // The link's click reaches the row, which selects it too.\n case 'Enter':\n if (node.span.to !== undefined) {\n event.currentTarget\n .querySelector<HTMLElement>('.aegis-trace-tree__name a')\n ?.click();\n } else {\n onSelect?.(node.span);\n }\n break;\n case ' ':\n onSelect?.(node.span);\n break;\n default:\n return;\n }\n event.preventDefault();\n };\n\n const handleRowClick = (event: MouseEvent<HTMLDivElement>, node: Node) => {\n if (\n event.target instanceof Element &&\n event.target.closest('[data-trace-tree-caret]') !== null\n ) {\n toggle(node.span.id);\n return;\n }\n // A modified click opens the name's link elsewhere and leaves this\n // page's selection alone.\n if (\n (event.ctrlKey || event.metaKey || event.shiftKey) &&\n event.target instanceof Element &&\n event.target.closest('.aegis-trace-tree__name a') !== null\n ) {\n return;\n }\n onSelect?.(node.span);\n };\n\n const cls = [\n 'aegis-trace-tree',\n isDragging ? 'aegis-trace-tree--dragging' : '',\n wrapName ? 'aegis-trace-tree--wrap' : '',\n timed ? '' : 'aegis-trace-tree--untimed',\n className ?? '',\n ]\n .filter(Boolean)\n .join(' ');\n\n const rootStyle = {\n ...style,\n '--aegis-trace-tree-name-w': `${String(effectiveWidth)}px`,\n } as CSSProperties;\n\n return (\n <div ref={wrapRef} className={cls} style={rootStyle} {...agentAttrs}>\n <div\n ref={treeRef}\n className=\"aegis-trace-tree__rows\"\n role=\"tree\"\n aria-label={ariaLabel ?? strings.traceSpans}\n >\n {visible.map(({ node, position, siblings }, index) => {\n const span = node.span;\n const hasChildren = node.children.length > 0;\n const isCollapsed = collapsed.has(span.id);\n const isSelected = selectedId === span.id;\n const rowCls = [\n 'aegis-trace-tree__row',\n span.muted ? 'aegis-trace-tree__row--muted' : '',\n isSelected ? 'aegis-trace-tree__row--selected' : '',\n span.status === 'error' ? 'aegis-trace-tree__row--error' : '',\n ]\n .filter(Boolean)\n .join(' ');\n\n const timing = isTimed(span)\n ? strings.traceSpanTiming(\n formatDuration(span.startMs - traceStart),\n formatDuration(span.durationMs),\n )\n : '';\n const kind = span.kind ?? '';\n const meta = [timing, kind].filter(Boolean).join(' · ');\n const noteId = `${idPrefix}-note-${String(index)}`;\n const hasNote = span.note !== undefined && span.note !== null;\n const name = wrapName ? breakAtSeparators(span.name) : span.name;\n const tooltipContent = (\n <div className=\"aegis-trace-tree__tooltip\">\n <div className=\"aegis-trace-tree__tooltip-name\">{span.name}</div>\n {meta && (\n <div className=\"aegis-trace-tree__tooltip-meta\">{meta}</div>\n )}\n </div>\n );\n\n return (\n <Fragment key={span.id}>\n <div\n ref={isSelected ? selection?.placeRow : undefined}\n className={rowCls}\n role=\"treeitem\"\n aria-label={span.ariaLabel}\n aria-describedby={hasNote ? noteId : undefined}\n aria-level={node.depth + 1}\n aria-posinset={position}\n aria-setsize={siblings}\n aria-expanded={hasChildren ? !isCollapsed : undefined}\n aria-selected={isSelected ? true : undefined}\n tabIndex={index === tabStopIndex ? 0 : -1}\n onClick={(event) => {\n handleRowClick(event, node);\n }}\n onKeyDown={(event) => {\n handleRowKeyDown(event, index);\n }}\n onFocus={() => {\n setFocusedId(span.id);\n }}\n >\n <div\n className=\"aegis-trace-tree__label\"\n style={\n {\n '--depth': node.depth,\n } as CSSProperties\n }\n >\n <span\n className={\n hasChildren\n ? 'aegis-trace-tree__caret'\n : 'aegis-trace-tree__caret aegis-trace-tree__caret--leaf'\n }\n aria-hidden=\"true\"\n data-trace-tree-caret={hasChildren ? '' : undefined}\n >\n {hasChildren ? (isCollapsed ? '▸' : '▾') : null}\n </span>\n <StatusDot tone={statusTone(span.status)} size={6} />\n {span.kind ? (\n <Chip tone=\"ghost\" className=\"aegis-trace-tree__kind\">\n {span.kind}\n </Chip>\n ) : null}\n <Tooltip\n placement=\"topLeft\"\n mouseEnterDelay={0.3}\n styles={{ root: { maxWidth: 'var(--tooltip-max-width)' } }}\n title={tooltipContent}\n >\n <span className=\"aegis-trace-tree__name\">\n {span.to === undefined ? (\n name\n ) : (\n <Link\n to={span.to}\n className=\"aegis-trace-tree__link\"\n tabIndex={-1}\n >\n {name}\n </Link>\n )}\n </span>\n </Tooltip>\n {hasNote ? (\n <span\n id={noteId}\n className=\"aegis-trace-tree__note\"\n aria-hidden=\"true\"\n >\n {span.note}\n </span>\n ) : null}\n </div>\n {timed && (\n <>\n <span\n className=\"aegis-trace-tree__gutter\"\n aria-hidden=\"true\"\n />\n <div\n className=\"aegis-trace-tree__bar-track\"\n aria-hidden=\"true\"\n >\n {isTimed(span) && (\n <span\n className=\"aegis-trace-tree__bar\"\n style={{\n left: `${(((span.startMs - traceStart) / traceDuration) * 100).toString()}%`,\n width: `${Math.max((span.durationMs / traceDuration) * 100, 0.5).toString()}%`,\n }}\n />\n )}\n </div>\n <div className=\"aegis-trace-tree__duration\">\n {span.durationMs !== undefined &&\n formatDuration(span.durationMs)}\n </div>\n </>\n )}\n </div>\n {isSelected ? selection?.inline : null}\n </Fragment>\n );\n })}\n </div>\n {timed && (\n <div\n {...handleProps}\n className=\"aegis-trace-tree__handle\"\n aria-label={strings.resizeNameColumn}\n />\n )}\n </div>\n );\n}\n"],"names":["NAME_COL_MIN","NAME_COL_MAX","NAME_COL_DEFAULT","isTimed","span","sortByStart","nodes","n","a","b","buildForest","spans","byId","roots","node","pid","parent","placed","place","depth","child","root","climbed","onCycle","cut","c","sortRec","flatten","collapsed","out","index","TraceTree","selectedId","onSelect","defaultCollapsedDepth","ariaLabel","Link","DefaultLink","className","style","surface","nameColumnWidth","defaultNameColumnWidth","onNameColumnWidthChange","persistKey","wrapName","wrapRef","useRef","treeRef","agentAttrs","usePrimitiveSurface","strings","useStrings","idPrefix","useId","selection","useContext","SelectedRowDetailContext","traceDuration","traceStart","timed","useMemo","r","timedSpans","start","s","end","setCollapsed","useState","init","walk","focusedId","setFocusedId","visible","rowIndexOf","id","focusedIndex","tabStopIndex","resizePersistKey","internalWidth","handleProps","isDragging","useResizable","effectiveWidth","useEffect","toggle","prev","next","focusRow","handleRowKeyDown","event","expandable","expanded","handleRowClick","cls","rootStyle","jsxs","jsx","position","siblings","hasChildren","isCollapsed","isSelected","rowCls","timing","formatDuration","kind","meta","noteId","hasNote","name","breakAtSeparators","tooltipContent","Fragment","StatusDot","statusTone","Chip","Tooltip"],"mappings":"2jBAsIMA,GAAe,IACfC,GAAe,IACfC,GAAmB,IAEzB,SAASC,EAAQC,EAAoC,CACnD,OAAOA,EAAK,UAAY,QAAaA,EAAK,aAAe,MAC3D,CAEA,SAASC,EAAYC,EAAqB,CACpCA,EAAM,MAAOC,GAAMA,EAAE,KAAK,UAAY,MAAS,GACjDD,EAAM,KAAK,CAACE,EAAGC,KAAOD,EAAE,KAAK,SAAW,IAAMC,EAAE,KAAK,SAAW,EAAE,CAEtE,CAEA,SAASC,GAAYC,EAA4B,CAC/C,MAAMC,MAAW,IACjBD,EAAM,QAASP,GAAS,CACtBQ,EAAK,IAAIR,EAAK,GAAI,CAAE,KAAAA,EAAM,OAAQ,KAAM,SAAU,CAAA,EAAI,MAA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