/**
 * Server-side syntax classification for the viewer's code block.
 *
 * The classes come off the engine's OWN tree-sitter parse (CG-57). Until then
 * the viewer ran a second highlighter — Shiki, plus 56 pruned TextMate grammars
 * shipped beside the binary — over source the engine had already parsed with a
 * real grammar. That is gone: one grammar set, one opinion about what a `.ts`
 * file is, nothing extra in the bundle, and roughly an order of magnitude off
 * the cost on the language that used to be worst (see below).
 *
 * Three properties are unchanged, because they are what make this safe to
 * depend on:
 *
 * * **It never fails a request.** A grammar that will not load, a parse that
 *   throws, a language nobody wrote a grammar for, a slice too big to be worth
 *   parsing — every one of them answers `engine: 'plain'` with a reason and the
 *   source still goes out. Highlighting is the part that degrades; nothing else
 *   does.
 * * **Identifiers survive whatever token boundaries the grammar chose.** Every
 *   code token is split into identifier runs before it goes on the wire, which
 *   is what lets the viewer wrap a call site as a link by *claiming a token*
 *   rather than re-tokenising the line on top of the classifier's answer.
 * * **The classification is a class name, not a colour.** The viewer paints
 *   from CSS custom properties, so one token stream serves light and dark and
 *   the design tokens live in exactly one place.
 *
 * ## Cost, measured
 *
 * On the dev Mac, 3 000 lines, cold (parse + classify + wire):
 *
 * | | TypeScript | Go | Python |
 * |---|---|---|---|
 * | Shiki (was) | ~700 ms | 43–57 ms | 35–47 ms |
 * | tree-sitter (now) | 24–41 ms | ~30 ms | 25–29 ms |
 *
 * Rust, Ruby, PHP, C# and Swift all land between 14 and 27 ms on the same
 * measurement. TypeScript's TextMate grammar was 5–7× every other one and the
 * cost was regex *execution*, not compilation — nothing about the old module
 * could have fixed it, and it is now the same order as everything else. The
 * slice cache still exists, because a re-render (a theme flip, a resize,
 * stepping back through the trail) should cost nothing at all, and because a
 * whole-file view pages the same file repeatedly.
 */
export { COMPONENT_LANGUAGES, grammarFor, isHighlightable } from './languages';
export { SYNTAX_TOKEN_CLASSES as TOKEN_CLASSES } from '../../extraction/syntax-tokens';
/** One token on the wire: its class id, then its text. */
export type WireToken = [number, string];
export interface HighlightResult {
    /** `tree-sitter` when a grammar produced the classes; `plain` when nothing did. */
    engine: 'tree-sitter' | 'plain';
    /** The grammar the source was read with, or null. */
    grammar: string | null;
    /** Class names, indexed by the first element of every {@link WireToken}. */
    classes: readonly string[];
    /** One entry per source line, in order. */
    lines: WireToken[][];
    /** Why the answer is plain, when it is. Absent on the happy path. */
    reason?: string;
}
/**
 * Lines above this are not classified.
 *
 * Matches `MAX_SOURCE_LINES`, so anything the source endpoint will serve, this
 * will try to classify.
 */
export declare const MAX_HIGHLIGHT_LINES = 4000;
/**
 * Characters above this are not classified.
 *
 * The line cap alone does not bound the work: one minified bundle line can be
 * two megabytes, and a parser walks it character by character. This is the
 * guard that keeps a single request from wedging a single-threaded loopback
 * server, and it is generous — 600 kB is far more source than any screen
 * renders.
 */
export declare const MAX_HIGHLIGHT_CHARS = 600000;
/** Classified slices kept in memory. Most are one symbol's body. */
export declare const SLICE_CACHE_LIMIT = 96;
/**
 * Total cached lines, which is the bound that actually matters.
 *
 * The entry count alone does not bound memory: 96 slices of a symbol body is a
 * megabyte, 96 whole 4 000-line files is two orders of magnitude more, and this
 * process is a reader someone leaves open all day. Twenty thousand lines is
 * roughly a working set of every symbol a session visits, or a handful of whole
 * files, and the eviction is the same recency order.
 */
export declare const SLICE_CACHE_LINES = 20000;
/** Drop everything cached. Tests use it; nothing in the server needs to. */
export declare function clearHighlightCache(): void;
/** What the slice cache is holding — for tests, and for anyone diagnosing it. */
export declare function highlightCacheStats(): {
    entries: number;
    lines: number;
};
export interface HighlightOptions {
    /** The engine's language for the file, e.g. `typescript`. */
    language?: string | null;
    /**
     * A key that changes whenever the text does — the file's content hash plus
     * the requested range. Omit it and the slice is classified every time.
     */
    cacheKey?: string;
}
/**
 * Classify `lines` for the viewer's code block.
 *
 * Never throws and never rejects: every failure path returns a plain result
 * carrying the reason, because the caller is serving source and the source is
 * the part that matters.
 */
export declare function highlightLines(lines: readonly string[], options?: HighlightOptions): Promise<HighlightResult>;
//# sourceMappingURL=index.d.ts.map