/** * The Timeline's state model: recorded events plus the reader's filter and * selection, and the rules that keep them consistent as the buffer changes. * * The derivations ({@link toSpans}, {@link filterSpans}, …) are pure, but * applying them is stateful: a selection can fall out of the buffer cap, an * element filter can name an element that Clear just removed, and a deep link * can arrive before the events it names have streamed in. Those rules live * here rather than in `timeline-view`, so they are unit-testable without a * DOM, and the selection key format is defined in one place. * * Framework-free like the rest of `lib/timeline`: the devframe definition * derives server-side through {@link updateCycles} too. */ import type { TimelineEvent } from '../../types/timeline.js'; import type { ComponentRollup, TimelineSpan, UpdateCycle } from './derive.js'; import type { TimeRange } from './range.js'; /** Whether `key` names a Raw-mode row rather than a collapsed span. */ export declare const isRawKey: (key: string) => boolean; /** * Adapts one raw event to the row shape for the list's Raw toggle. * Deliberately drops `groupId`: pairing is what the collapsed mode is for, * and without it the duration cell reads "point event" rather than "still * open". */ export declare const rawRow: (event: TimelineEvent, index: number) => TimelineSpan; /** The element, regex and time-range filters both presentations apply. */ export interface TimelineFilter { /** Element id to show, or null for all elements. */ elementId: number | null; /** Case-insensitive regex source; empty matches everything. */ regex: string; /** Only spans starting inside this window, or null for all of time. */ range: TimeRange | null; } export declare const NO_FILTER: TimelineFilter; /** Applies a {@link TimelineFilter} to spans or Raw-mode rows. */ export declare const applyFilter: (rows: readonly TimelineSpan[], filter: TimelineFilter) => TimelineSpan[]; /** Update cycles over `events`, each attributed to the input it followed. */ export declare const updateCycles: (events: readonly TimelineEvent[]) => UpdateCycle[]; /** {@link updateCycles} plus their per-component {@link rollup}. */ export declare const summarizeUpdates: (events: readonly TimelineEvent[]) => { cycles: UpdateCycle[]; components: ComponentRollup[]; }; /** What the recording shows one element doing, beyond its update ticks. */ export interface ElementActivity { /** Updates its own previous update scheduled; see {@link isSelfCaused}. */ selfCaused: number; /** * Events it dispatched on itself, per type, most frequent first. Only the * Custom events layer records these, so this is empty while it is off. */ dispatched: Array<{ type: string; count: number; }>; } /** * Per element id, its {@link ElementActivity} in `events`. Elements that did * neither are absent. */ export declare const elementActivity: (events: readonly TimelineEvent[]) => Map; /** * Events, filter and selection for the Timeline view, derived lazily and * memoised on identity: the event array is replaced (never mutated) whenever * the buffer changes, and every derived array keeps its identity until one of * its inputs changes, so a selection change does not hand the tracks a new * array and re-pack every lane. */ export declare class TimelineModel { private _events; private _spans; private _elements; private _filter; private _filtered; private _selectedKey; private _range; get events(): readonly TimelineEvent[]; /** `toSpans(events)`. */ get spans(): TimelineSpan[]; /** Distinct elements in the buffer, for the element picker. */ get elements(): Array<{ id: number; tag: string; }>; get filter(): TimelineFilter; /** Whether the regex box holds a pattern that does not compile. */ get regexInvalid(): boolean; /** {@link spans} after the filter. */ get filteredSpans(): TimelineSpan[]; get selectedKey(): string | null; /** * The time range the reader drew, or null. Shared like {@link selectedKey} * so both presentations agree; distinct from `filter.range`, which hides * what lies outside it. */ get range(): TimeRange | null; /** The selected span, or undefined for none or a Raw-mode row. */ get selectedSpan(): TimelineSpan | undefined; /** Id of the selected span's start event, for the URL. */ get selectedEventId(): string | null; /** * Replaces the buffer and reconciles the filter and selection against it. * Returns false when `events` is the buffer it already has. */ setEvents(events: readonly TimelineEvent[]): boolean; setFilter(patch: Partial): void; /** * Draws a range between two times (either order), or clears it with null * or a zero-width drag. Drawing one drops the span selection: the detail * pane shows one or the other, and the latest gesture wins. */ setRange(a: number | null, b?: number | null): void; /** A click on a row or mark. */ select(key: string | null): void; /** * Selects the span a deep link named. Its start event is the natural target * (`span.events[0]`), but any of the span's events matches, so a link to * either half of a pair lands on the same row. An id the buffer does not * hold (evicted, or from another session) clears the selection: leaving the * previous row highlighted would read as if that were it. Returns true when * it found a span. * * Holding a link until the buffer has loaded is `PanelLocation`'s; ask only * once {@link events} has some. */ selectEvent(id: string): boolean; } //# sourceMappingURL=model.d.ts.map