/** One extracted section: a heading (or `null` for untitled lead text). */ export interface Section { readonly heading: string | null; readonly body: string; } /** * Success extraction result: ordered section buckets. Carries the raw- * byte hash so {@link diffDocuments} can fall back without re-reading. */ export interface ExtractedSections { readonly ok: true; readonly sections: Section[]; readonly hash: string; } /** Failed extraction: bytes are not HTML-shaped, caller falls back to hashing. */ export interface ExtractionFailure { readonly ok: false; readonly reason: "no-html"; readonly hash: string; } export type ExtractionResult = ExtractedSections | ExtractionFailure; /** Structural diff identifiers: heading texts (or position placeholders). */ export interface SectionDiff { readonly added: string[]; readonly removed: string[]; readonly changed: string[]; } /** Document-level outcome: section diff, or hash verdict for non-HTML. */ export interface DocumentDiff extends SectionDiff { readonly hashOnly: boolean; } /** * HTML media-type gate (review: classify by Content-Type, not by byte * sniffing): extraction is structural ONLY for HTML responses. A * `text/plain` or `application/json` body that happens to contain an * ``-like token must go down the hash-only path — otherwise two * different plain-text bodies can extract identical (empty) section * lists and report a silent no-change instead of a `(hash)` verdict. * Unknown/missing content types keep the legacy sniff path (old * Wayback replays often carry none). Returns null = "unknown": the * caller falls back to extractSections' own HTML-shaped detection. */ export declare function isHtmlContentType(contentType?: string): boolean | null; /** * Extract ordered heading/paragraph sections from raw bytes. * * A single forward scan tokenizes tags case-insensitively, tolerates * missing closers and arbitrary attributes, and flushes a text buffer as * a new section whenever a heading (`h1`..`h6`) opens; other block tags * merely separate paragraphs inside the current section's body. */ export declare function extractSections(raw: Uint8Array, charsetHint?: string): ExtractionResult; /** * Heading-anchored structural diff over two extracted section lists. * * Matched by normalized heading text (duplicates pair ordinally in source * order); identical heading + identical normalized body = no change, * different body = changed. Headings present on only one side are added * or removed — a heading reword therefore reports removed+added, never * changed. Untitled lead sections pair positionally and report as * `(intro)` when their body changed. Output arrays follow source order. */ export declare function diffSections(a: readonly Section[], b: readonly Section[]): SectionDiff; /** * Diff two extraction results at the document level. * * Both sides extracted → straight into the structural section diff — * there is NO whole-document byte-identical short-circuit on this * path; equal bytes just happen to yield equal sections (empty diff). * Callers wanting the cheap equality check compare the `hash` fields * before calling. Any extraction failure (either side) degrades to * the hash-only path: sha256 over the RAW bytes, changed reported as * `(hash)` — identical non-HTML bytes → no change, any byte * difference → change. */ export declare function diffDocuments(a: ExtractionResult, b: ExtractionResult): DocumentDiff; /** * Forced hash-only extraction (review Content-Type gate): the media * type says non-HTML, so structural extraction is skipped entirely and * the result is the same failure shape extractSections produces for * non-HTML-shaped bytes — {@link diffDocuments} then lands on the * raw-hash verdict. */ export declare function extractSectionsHashOnly(raw: Uint8Array): ExtractionFailure; /** * sha256 hex digest over raw bytes — never over the decoded string, so * the same text encoded UTF-8 vs GBK hashes differently. */ export declare function hashRaw(raw: Uint8Array): string; //# sourceMappingURL=section-diff.d.ts.map