/** * EPUB Canonical Fragment Identifier (CFI) utilities * Based on the EPUB CFI 1.1 specification: https://idpf.org/epub/linking/cfi/epub-cfi.html */ /** * Interface for a parsed CFI part * * According to the EPUB CFI 1.1 specification, each step in a CFI path can have * its own properties including ID assertions, character offsets, and extension parameters. * Extensions are parameters in the form of key-value pairs that can be attached to any * step in the CFI path to provide additional information or metadata about that specific step. */ export interface CfiPart { index: number; id?: string; offset?: number; temporal?: number; spatial?: number[]; text?: string[]; side?: string; /** * Extension parameters for this CFI path step * * The EPUB CFI spec allows for extension parameters to be attached to any step in the path. * These are key-value pairs that provide additional information or metadata. * For example, in /6/4[chap01ref]!/4[body01]/10[para05]/2/1:3[;vnd.example.param=value], * the extension parameter is "vnd.example.param" with value "value". */ extensions?: Record; } /** * Interface for a parsed CFI range */ export interface CfiRange { parent: CfiPart[][]; start: CfiPart[][]; end: CfiPart[][]; } /** * Interface for a parsed CFI */ export type ParsedCfi = CfiPart[][] | CfiRange; /** * Unwrap a CFI string from the epubcfi() function, which has to be closed at * the end of the string * @param cfi The CFI string to unwrap * @returns The unwrapped CFI string */ export declare function unwrapCfi(cfi: string): string; /** * Parse a CFI string into a structured representation * * A string that is only partly a CFI is not one, so every character has to be * read as part of it. It throws for a character that cannot be, such as text * after the closing parenthesis, for an `epubcfi(` or an assertion never * closed, and for a step or an offset without its number. It does not check * that the parts come in an order the specification allows. * @param cfi The CFI string to parse * @returns A parsed CFI */ export declare function parse(cfi: string): ParsedCfi;