import type { Dispatch, MutableRefObject, ReactNode } from 'react'; import type { GetQuickLinks, MemoCache, Resource, RootNode, ScrollSnapshot, SpanNode, VisibleSpanEvent } from './types'; export interface TraceViewerState { /** * The root node for the tree */ root: RootNode; /** * A map of spanId to span nodes */ spanMap: Record; /** * A map of resource name to resource */ resourceMap: Record; /** * The current (debounced) search input value */ filter: string; /** * The span that is currently focused and visible in the panel */ selected: SpanNode | null; /** * The initial scale of the trace. At this scale the entire trace is visible */ baseScale: number; /** * The multiplier of the base scale to get the current scale */ scaleRatio: number; /** * The scale of 1ms in pixels */ scale: number; /** * The width of the entire trace viewer in pixels */ width: number; /** * The height of the entire trace viewer in pixels */ height: number; /** * The width of the timeline view in pixels */ timelineWidth: number; /** * The height of the timeline view in pixels */ timelineHeight: number; /** * The width of the side panel in pixels */ panelWidth: number; /** * The height of the side panel in pixels */ panelHeight: number; /** * The width of scrollbars on this device */ scrollbarWidth: number; /** * A ref for the timeline element */ timelineRef: MutableRefObject; /** * A ref for updating timeline scroll position immediately after a scale operation */ scrollSnapshotRef: MutableRefObject; /** * A reference for the last time each node was mutated. Used for more efficent control * of what React re-renders and when. */ memoCacheRef: MutableRefObject; /** * A constant, wrapped version of the getQuickLinks property with caching */ getQuickLinks: GetQuickLinks; /** * Whether the panel is being rendered attached to the timeline */ withPanel: boolean; /** * Whether the trace viewer is small enough that it should be in mobile mode */ isMobile: boolean; /** * A function to provide custom class names for spans. */ customSpanClassNameFunc?: (span: SpanNode) => string; /** * A function to provide custom class names for span events. */ customSpanEventClassNameFunc?: (event: VisibleSpanEvent) => string; } export type TraceViewerAction = { type: 'setRoot'; root: RootNode; spanMap: Record; resources: Resource[]; } | { type: 'setSize'; width: number; height: number; } | { type: 'setPanelWidth'; width: number; } | { type: 'setFilter'; filter: string; } | { type: 'deselect'; } | { type: 'select'; id: string; } | { type: 'escape'; } | { type: 'toggleSelection'; id: string; } | { type: 'detectBaseScale'; } | { type: 'setScale'; scale: number; } | { type: 'resetScale'; } | { type: 'scaleToNode'; id: string; } | { type: 'scaleToRange'; t1: number; t2: number; } | { type: 'adjustScaleRatio'; direction: -1 | 0 | 1; } | { type: 'trackpadScale'; delta: number; anchorT: number; anchorX: number; } | { type: 'minScale'; } | { type: 'setScrollSnapshot'; /** * The time that will remain the same location after scaling */ anchorT: number; /** * The anchor point relative to the timeline's left position */ anchorX: number; } | { type: 'setWithPanel'; withPanel: boolean; } | { type: 'forceRender'; } | { /** Like setRoot but preserves scroll position and memo cache (for incremental data updates) */ type: 'updateRoot'; root: RootNode; spanMap: Record; resources: Resource[]; }; export interface TraceViewerContextProps { state: TraceViewerState; dispatch: Dispatch; } export declare const initialState: TraceViewerState; export declare const TraceViewerContext: import("react").Context; export declare function TraceViewerContextProvider({ getQuickLinks, withPanel, children, customSpanClassNameFunc, customSpanEventClassNameFunc, customPanelComponent, }: { getQuickLinks?: GetQuickLinks; withPanel?: boolean; children: ReactNode; customSpanClassNameFunc?: (span: SpanNode) => string; customSpanEventClassNameFunc?: (event: VisibleSpanEvent) => string; customPanelComponent?: ReactNode; }): ReactNode; export declare const useTraceViewer: () => TraceViewerContextProps; export declare const useCustomPanelComponent: () => ReactNode | null; //# sourceMappingURL=context.d.ts.map