/** * DOCX Module - Immutable Document Mapper * * Provides `mapDocument()` and the `DocxTransformer` interface for rebuilding * a document tree with transformations applied to specific node types. * * Unlike the read-only `walkDocument()` (in walker.ts), this mapper produces * a new document without mutating the input. */ import type { BodyContent, DocxDocument, Paragraph, Run, RunContent, StructuredDocumentTag, Table } from "../types.js"; import type { WalkPath } from "./walker.js"; /** * Transformer interface for immutable document tree rebuilding. * Return the node to keep/replace it, or null to remove it. * For flatMapBodyContent, return an array to expand one node into multiple. */ export interface DocxTransformer { transformParagraph?(para: Paragraph, path: WalkPath): Paragraph | null; transformRun?(run: Run, path: WalkPath): Run | null; transformTable?(table: Table, path: WalkPath): Table | null; transformSdt?(sdt: StructuredDocumentTag, path: WalkPath): StructuredDocumentTag | null; transformRunContent?(content: RunContent, run: Run, path: WalkPath): RunContent | null; /** Transform a body content item. Return null to remove, a single item to replace, or an array to expand. */ transformBodyContent?(content: BodyContent, path: WalkPath): BodyContent | BodyContent[] | null; } /** Options controlling which parts of the document to map. */ export interface MapOptions { readonly includeHeaders?: boolean; readonly includeFooters?: boolean; readonly includeFootnotes?: boolean; readonly includeEndnotes?: boolean; readonly includeComments?: boolean; } /** * Immutable document tree transformation. * Rebuilds the document tree, allowing callers to replace or filter nodes. * Never mutates the input document. * * @param doc - The document to transform. * @param transformer - Callbacks to transform each node type. * @param options - Controls which document parts to include. * @returns A new DocxDocument with transformations applied. */ export declare function mapDocument(doc: DocxDocument, transformer: DocxTransformer, options?: MapOptions): DocxDocument;