import { BlockNode, DocumentModel, SectionNode } from "./model.js"; /** * A nested map of heading text to its child headings, mirroring the document's * section nesting. A leaf heading maps to an empty object. The tree carries no * heading levels: nesting is by containment, so a level skipped in the source * (an `h1` followed directly by an `h3`) does not appear as a hole — the engine * owns depth and a consumer never needs it. * * Sibling headings are keyed by text, and every occurrence gets its own key: a * repeated sibling name is not merged. The first occurrence keeps its plain * text; each later occurrence's key has a {@link disambiguatedHeadingText} * suffix appended, so no two sections ever share an address. For * `## Log / ### Monday` followed by `## Log / ### Tuesday`, the tree is * `{ Log: { Monday: {} }, "Log": { Tuesday: {} } }`: both "Log"s, and * both children, are separately addressable. * * The tree therefore enumerates exactly the addresses the resolver accepts — * see {@link headingTreePaths}. */ export interface HeadingTree { [headingText: string]: HeadingTree; } /** * The text a heading-bearing section is keyed/addressed by: its raw heading * text for the first occurrence among same-text siblings under the same * parent, or that text plus a reserved-codepoint suffix for each later * occurrence (in document order). This is the single source of truth both * {@link headingPath} (resolution) and {@link projectMap} (the map a caller * reads) derive from, so the two can never drift apart — an address is always * matched by plain string equality against a freshly recomputed value, never * decoded. Keys produced here are guaranteed unique among a parent's children * as long as no raw heading text already collides with a synthesized suffix, * which {@link buildModel} guards against. */ export declare const disambiguatedHeadingText: (node: SectionNode) => string; /** * Every block in the document, in document order (a pre-order walk of the * section tree). Blocks are addressed globally by id, not scoped to a parent * the way headings are scoped to sibling groups, so disambiguating a * duplicate id needs this full document-order list rather than a single * node's local neighbors. */ export declare const allBlocksInOrder: (root: SectionNode) => BlockNode[]; /** * The id a block is keyed/addressed by: its raw id for the first occurrence * among every block in the document sharing that id, or that id plus a * reserved-codepoint suffix for each later occurrence (in document order). * Mirrors {@link disambiguatedHeadingText}'s role for headings — both * {@link projectMap} and the resolver derive from this one function, so an * address is always matched by plain string equality, never decoded. A raw * block id cannot itself collide with a synthesized suffix: block ids are * constrained to `[a-zA-Z0-9_-]+` by {@link BLOCK_REFERENCE_REGEX} in * model.ts, which cannot contain these (astral, non-ASCII) codepoints, so no * buildModel-time guard is needed here the way there is for headings. */ export declare const disambiguatedBlockId: (block: BlockNode, allBlocks: readonly BlockNode[]) => string; /** * The terse, context-cheap public view of a document, derived from the * {@link DocumentModel}. It carries no in-band grammar: headings nest by * containment in a {@link HeadingTree} and block references are bare ids. */ export interface PublicMap { /** Content-hash token; pass back as an `ifMatch` precondition. */ version: string; /** Top-level frontmatter field names, in document order. */ frontmatterFields: string[]; /** Headings nested by containment; see {@link HeadingTree}. */ headings: HeadingTree; /** * Block reference ids, bare (no `^`), in document order. A duplicate id * gets its own entry per occurrence: the first keeps its bare id, and each * later occurrence's entry has a {@link disambiguatedBlockId} suffix * appended, so no two entries are ever the same string. */ blocks: string[]; } /** * The containment path of a heading-bearing section: the ancestor heading texts * from the top level down to this node (e.g. `["Overview", "Details"]`), one * entry per heading on the path regardless of source level. This is exactly the * address a consumer sends back as a heading target. Shared with the resolver * so map addresses and target matching use one definition. */ export declare const headingPath: (node: SectionNode) => string[]; /** Project the internal model into the public map consumers receive. */ export declare const projectMap: (model: DocumentModel) => PublicMap; /** * Enumerate every addressable heading in a {@link HeadingTree} as its * containment-path target, in document order. This is the walk a consumer runs * to turn a map into the list of heading addresses it can patch. */ export declare const headingTreePaths: (tree: HeadingTree) => string[][]; //# sourceMappingURL=projection.d.ts.map