import type { TocItem } from './types.js'; /** * A live table of contents: the headings scanned from the current page, plus * the id of the section currently in view. */ export type Toc = { /** Headings of the current page, in document order. */ readonly items: TocItem[]; /** Id of the heading whose section is currently in view, or `null`. */ readonly activeId: string | null; /** Re-scan the content element. Call after each navigation. */ refresh: () => Promise; }; /** * Create a table of contents bound to a content element. * * Two jobs, both re-run whenever the page changes: * - `refresh()` re-scans the rendered headings (call it from `afterNavigate` so * client-side navigation updates the list, not just a full reload). * - a single `IntersectionObserver` tracks which heading is in view for * scroll-spy highlighting, re-observing the new headings after each refresh. * * Deliberately small: no section wrappers, no multi-threshold ratio math, no * parent-highlight bookkeeping. One observer, one active id. */ export declare function createToc(contentFn: () => HTMLElement | null): Toc;