import type { Root, Definition } from 'mdast'; /** The document-global label tables of one tree. */ export interface DocumentLabels { /** Link/image reference definitions by lowercased identifier (first wins). */ readonly definitions: ReadonlyMap; /** Namespaced label identifiers — `l:` for reference definitions, `f:` for * footnote definitions — so a link def `x` stays distinct from a footnote def * `x`. This is the set the incremental parser's reuse guard compares. */ readonly ids: ReadonlySet; } /** Test/benchmark hook: reads (and optionally resets) the number of mdast nodes * visited by definition collection. A streamed append must visit only the freshly * parsed tail blocks — reused prefix blocks contribute their already-collected * definitions without being re-walked. */ export declare function definitionNodesVisited(reset?: boolean): number; /** Test/benchmark hook: reads (and optionally resets) the number of TOP-LEVEL * BLOCKS examined by definition collection (memoized or not). A streamed append * must examine only the freshly parsed tail blocks — the reused prefix is carried * over as already-merged entries, so this stays CONSTANT as the document grows * rather than sweeping every block per change. */ export declare function definitionBlocksScanned(reset?: boolean): number; /** The document-global labels of `root` (see {@link DocumentLabels}). */ export declare function collectDocumentLabels(root: Root): DocumentLabels; /** Walk the tree and collect every link/image reference definition, keyed by * lowercased identifier (so `linkReference`/`imageReference` nodes can resolve). * The result is the WHOLE-document table — a definition anywhere, including one * that arrives late in a streamed tail, resolves for a reference anywhere. * * Collection is incremental: blocks reused from the previous parse contribute * their already-collected definitions instead of being re-walked, so a streamed * append costs O(tail) rather than O(document). * * BREAKING (behaviour, not just the type): this used to build and hand back a * FRESH, safely-mutable `Map` on every call. It now returns the LIVE memoized * table for that tree. The `ReadonlyMap` type says so, but a cast defeats it — * `(collectDefinitions(root) as Map).delete('r')` permanently * poisons the cache for `root`, and every later render of that tree sees the * damage. Copy it (`new Map(collectDefinitions(root))`) if you need to mutate. * For the same reason the tree itself is treated as immutable once parsed: do not * mutate a tree's nodes and re-collect, the memo will not notice. */ export declare function collectDefinitions(root: Root): ReadonlyMap; /** The namespaced label ids contributed by the first `count` top-level blocks of * `root` — what the incremental parser injects ahead of a tail parse so a tail * reference pointing at a PREFIX definition still forms a reference node. */ export declare function prefixLabelIds(root: Root, count: number): ReadonlySet; /** Derive `root`'s label tables INCREMENTALLY from `previousRoot`'s. * * The caller must guarantee that `root.children[i] === previousRoot.children[i]` * for every `i < reusedPrefix` — which is precisely what `incrementalParse` * constructs (it slices the reused blocks off the previous tree, preserving their * indices). Under that guarantee the first `reusedPrefix` blocks' contributions * are carried over verbatim and only the freshly-parsed tail is walked. */ export declare function deriveDocumentLabels(root: Root, previousRoot: Root, reusedPrefix: number): DocumentLabels; //# sourceMappingURL=definitions.d.ts.map