import { Book } from './types'; /** * Input types accepted by parsers. */ export type ParserInput = File | Blob | string | ArrayBuffer; /** * Options that can be passed to a parser. */ export interface ParserOptions { /** * Custom SHA-1 function for font deobfuscation (EPUB). * If not provided, uses Web Crypto (requires secure context). */ sha1?: (data: ArrayBuffer) => Promise; /** * Called during parsing to report progress. */ onProgress?: (progress: number, message?: string) => void; /** * DOM adapter for XML/HTML parsing. * If not provided, uses browser DOMParser (browser-only). */ domAdapter?: import('./dom-adapter').DOMAdapter; /** * URL factory for creating resource URLs. * If not provided, uses URL.createObjectURL (browser-only). */ urlFactory?: import('./url-factory').URLFactory; } /** * The Parser interface. * Implement this to add support for a new e-book format. */ export interface Parser { /** * Parse the input and return a Book object. */ parse(input: ParserInput, options?: ParserOptions): Promise; /** * Check if this parser can handle the given input. * Returns true if the format is recognized. */ canParse(input: ParserInput): Promise | boolean; /** * Priority for auto-detection (higher = checked first). * Default is 0. Use higher values for more specific formats. * For example, EPUB (10) should be checked before generic ZIP-based formats like CBZ (0). */ priority?: number; } /** * A parser factory is a function that creates parser instances. * Used for registration with the auto-detection system. */ export type ParserFactory = () => Parser; /** * Registry of parsers for auto-detection. */ export declare class ParserRegistry { private parsers; /** * Register a parser with a name. * @param name - Parser name * @param factory - Factory function to create parser instances * @param priority - Detection priority (higher = checked first). * If not provided, uses parser.priority or defaults to 0. */ register(name: string, factory: ParserFactory, priority?: number): void; /** * Unregister a parser. */ unregister(name: string): void; /** * Get a parser by name. */ get(name: string): Parser | undefined; /** * Auto-detect the format and return a suitable parser. * Parsers are checked in priority order (highest first). */ detect(input: ParserInput): Promise; /** * Auto-detect, parse, and return a Book. */ open(input: ParserInput, options?: ParserOptions): Promise; /** * List all registered parser names. */ list(): string[]; } /** * Global parser registry. */ export declare const registry: ParserRegistry; //# sourceMappingURL=parser.d.ts.map