import type { EditorState } from '@codemirror/state'; import type { EditorView } from '@codemirror/view'; import type { InlineDiagnostic } from '../../code-editor/inline-diagnostic.js'; /** * Counts of error-severity diagnostics that lie above and below the current * editor viewport. * @internal */ export interface OffScreenErrorCounts { above: number; below: number; } /** * Injectable geometry interface for viewport math — decouples the counting * and nearest-error logic from a live `EditorView` so both can be unit-tested * without a DOM or CodeMirror layout pass. * @internal */ export interface OffScreenErrorGeometry { scrollTop: number; scrollBottom: number; /** * Returns the pixel bounds of the line block containing `pos`, or `null` * when `pos` is out of range (negative or past the document end). */ lineBoundsFor: (pos: number) => { top: number; bottom: number; } | null; } /** * Below this height neither indicator is shown — there is not enough vertical * space for even one pill without it overlapping the editor content heavily. * @internal */ export declare const MIN_HEIGHT_FOR_ANY_INDICATOR = 80; /** * Above this height both the top and bottom indicator may be shown * simultaneously when errors exist in both directions. * @internal */ export declare const MIN_HEIGHT_FOR_BOTH_INDICATORS = 140; /** * Maximum error count shown verbatim in a pill label. Counts above this value * are displayed as "99+ errors". * @internal */ export declare const MAX_DISPLAYED_ERROR_COUNT = 99; /** * Reads the active CodeMirror lint state and returns it as an array of * {@link InlineDiagnostic} objects. * * Uses the `from`/`to` positions supplied by the `forEachDiagnostic` callback * rather than `diagnostic.from`/`.to`, which can go stale after document edits. * Maps CodeMirror's `'hint'` severity level to `'info'`. * @internal */ export declare function collectLintStateDiagnostics(state: EditorState): InlineDiagnostic[]; /** * Builds a snapshot of the current scroll viewport for a CodeMirror editor view. * * The returned object captures the visible vertical range at the moment of the * call and provides a function to map any document position to its pixel bounds. * It satisfies the {@link OffScreenErrorGeometry} interface consumed by the * off-screen error indicator utilities. * * @param view - The CodeMirror editor view to snapshot. */ export declare const getScrollViewport: (view: EditorView) => OffScreenErrorGeometry; /** * Counts how many error-severity diagnostics lie above and below the current * editor viewport, using the geometry from editorView to resolve pixel positions. * * Only `error`-severity items are counted — `warning` and `info` are ignored, * consistent with the `aria-invalid` behaviour. A missing `severity` field * defaults to `'error'`. * @internal */ export declare function countOffScreenErrors(diagnostics: readonly InlineDiagnostic[], scrollViewport: OffScreenErrorGeometry): OffScreenErrorCounts; /** * Returns the document position of the nearest off-screen error in the given * direction, or `null` if no off-screen errors exist in that direction. * * "Nearest above" is the error whose line block bottom is closest to * `scrollTop` — the minimum scroll distance to bring it into view. * "Nearest below" is the error whose line block top is closest to * `scrollBottom`. * @internal */ export declare function findNearestOffScreenError(diagnostics: readonly InlineDiagnostic[], scrollViewport: OffScreenErrorGeometry, direction: 'above' | 'below'): number | null; /** * Resolves which indicator pills should be visible given the current error * counts and the available height of the editor scroller. * * @internal */ export declare function resolveVisibleIndicators(counts: OffScreenErrorCounts, availableHeight: number): { showTop: boolean; showBottom: boolean; }; //# sourceMappingURL=off-screen-diagnostic-indicators.utils.d.ts.map