import { type ReactElement, type ReactNode } from 'react'; import { type HtmdxComponentDefinitions } from '../component-definition'; import { type HtmdxDiagnostic } from '../diagnostics'; export type HtmdxReactOptions = { definitions?: HtmdxComponentDefinitions; }; export type HtmdxBlockFailure = { /** Offset of the block's opening tag inside the tokenized source. */ offset: number; name: string; error: unknown; componentStack?: string; }; export type HtmdxDocumentOptions = HtmdxReactOptions & { layout?: string; /** * Opt into degraded rendering: a block that fails to build or to render is * replaced by an error card and reported here instead of failing the * document. Without it a block failure still throws, so compile() keeps * refusing to emit a half-broken page. */ onBlockError?: (failure: HtmdxBlockFailure) => void; }; export declare function compileToReact(source: string, options?: HtmdxReactOptions): ReactElement; export declare function Htmdx(props: { source: string; } & HtmdxReactOptions): ReactElement; export type HtmdxDocument = { element: ReactElement; title: string; headings: { id: string; label: string; }[]; components: string[]; meta: Record; }; export declare function compileDocument(source: string, options?: HtmdxDocumentOptions): HtmdxDocument; export declare const NAV_TOGGLE_LABELS: { readonly expanded: "Minimize navigation panel"; readonly collapsed: "Show navigation panel"; }; export declare function listComponents(source: string, definitions?: HtmdxComponentDefinitions): string[]; export type HtmdxSourceToken = { type: 'markdown'; value: string; } | { type: 'html'; value: string; } | { type: 'component'; name: string; body: string; }; export declare function tokenizeSource(source: string, definitions?: HtmdxComponentDefinitions): HtmdxSourceToken[]; export type HtmdxStructureNode = { type: 'markdown'; value: string; } | { type: 'text'; value: string; } | { type: 'element'; name: string; props: Record; children: HtmdxStructureNode[]; }; export declare function structureOf(source: string, options?: HtmdxReactOptions): HtmdxStructureNode[]; export type ValidationProbe = { offset: number; render: () => ReactNode; }; export declare function collectStructuralDiagnostics(source: string, options?: HtmdxDocumentOptions): { diagnostics: HtmdxDiagnostic[]; probes: ValidationProbe[]; }; export declare function diagnosticForBlock(source: string, block: { offset: number; }, error: unknown): HtmdxDiagnostic;