import type { CfiRange, ParsedCfi } from "./parse.ts"; /** * Get all ancestors of a node, including the node itself */ export declare function getAncestors(node: Node): Node[]; /** * Find the closest common ancestor of two nodes */ export declare function findCommonAncestor(nodeA: Node, nodeB: Node): Node | null; /** * Special characters in CFI that need to be escaped according to the spec * These are: [ ] ^ , ( ) ; */ export declare const CFI_SPECIAL_CHARS: RegExp; /** * Escape special characters in a CFI string * @param str The string to escape * @returns The escaped string */ export declare function cfiEscape(str: string): string; /** * Regular expression to check if a string is a valid CFI. Its values can hold * line breaks, such as a text assertion spanning lines, so it matches across * them. */ export declare const isCFI: RegExp; /** * @important Make it non browser runtime specific */ export declare const isElement: (node: Node) => node is Element; /** * @important Make it non browser runtime specific */ export declare const isNode: (node: any) => node is Node; /** * Text and CDATA nodes: the character data a CFI step can address * (EPUB CFI 3.1.1). Comments and processing instructions are ignored. */ export declare const isCharacterData: (node: Node) => node is CharacterData; /** * The even step of an element: twice its 1-based position among its parent's * element children. */ export declare const getElementStep: (node: Node) => number; /** * The step of the character data chunk a node belongs to, and the number of * characters that chunk holds before the node. * * Character data between two element children forms one chunk with an odd * index (1 before the first element, 3 after it, and so on), whatever the * number of DOM nodes it spans: adjacent text nodes, CDATA sections and the * comments between them all belong to the same chunk, and a character offset * counts from its start. */ export declare const getCharacterDataStep: (node: Node) => { step: number; base: number; }; /** * What an odd step addresses under `parent`: the first node of its chunk of * character data, or, when that chunk is empty, the boundary it stands for in * the parent (the child index right after the preceding element, 0 before * the first one). `undefined` when the parent has fewer element children * than the step needs. */ export type CharacterDataChunk = { kind: "node"; node: CharacterData; } | { kind: "boundary"; parent: Node; childIndex: number; }; export declare const findCharacterDataChunk: (parent: Node, step: number) => CharacterDataChunk | undefined; /** * The node and local offset a chunk offset lands on, counting from `first`, * the chunk's first node. A boundary between two nodes lands at the start of * the later one; an offset past the chunk keeps its excess on the last node. */ export declare const locateInCharacterDataChunk: (first: CharacterData, offset: number) => { node: CharacterData; offset: number; }; /** * Checks if a parsed CFI only contains indirection with no further path * For example: epubcfi(/6/2[cover]!) */ export declare function isIndirectionOnly(parsed: ParsedCfi): boolean; /** * Check if a parsed CFI is a range */ export declare function isParsedCfiRange(parsed: ParsedCfi): parsed is CfiRange;