export declare const CHARSET_PRESETS: Record; /** A named charset bundling a Tesseract whitelist with expected OCR confusions. */ export interface Charset { /** Tesseract character whitelist passed directly to `tessedit_char_whitelist`. */ chars: string; /** Expected glyph → OCR glyphs that are acceptable in its place. */ swaps?: OcrSwaps; } /** Global OCR strategy set by init(). */ export interface OcrStrategy { /** Fallback charset when an element has no explicit charset and name-inference finds nothing. */ defaultCharset?: string; /** Map from element-name substring (case-insensitive) → charset name. Checked before built-in heuristics. */ infer?: Record; /** Global swaps applied when no element-level swaps are configured. */ swaps?: OcrSwaps; /** Global overflow applied when no element-level overflow is configured. */ overflow?: OcrOverflow; /** Global read mode applied when no element-level read is configured. */ read?: FieldRead; } /** * Called by `init()` to register user-defined charsets. * Merges into the existing registry — subsequent calls accumulate charsets rather than replacing them. * Call `setCharsetRegistry({})` (or `release()`) to clear. */ export declare function setCharsetRegistry(registry: Record): void; export declare function setOcrStrategy(strategy: OcrStrategy | undefined): void; export declare function getOcrStrategy(): OcrStrategy | undefined; /** * Resolve a charset using Strategies.Ocr: checks `infer` map first (substring match), * then falls back to `defaultCharset`. Returns undefined when no strategy is set. */ export declare function resolveOcrCharset(elementName: string): string | undefined; /** Look up a registered charset by name, or return undefined if not found. */ export declare function lookupCharset(name: string): Charset | undefined; /** * Resolve the bundled swaps for a charset name string or inline Charset object. * Returns undefined if the name is not registered or the charset has no swaps. */ export declare function resolveCharsetSwaps(charset: string | Charset | undefined): OcrSwaps | undefined; export declare function charsetForField(name?: string, type?: string, preset?: string): string | undefined; export declare function normalizeOcrText(text: string): string; export declare function pickFromOptions(text: string, options?: string[]): string; /** Expected glyph → OCR glyphs allowed in its place. `{ '@': ['Q', 'C'], '5': 'S' }` */ export type OcrSwaps = Record; /** How a field is allowed to clip when the value does not fit the box. */ export type OcrOverflow = 'start' | 'end' | 'both'; /** How to read a field's value. `clipboard` is click / select-all / copy. */ export type FieldRead = 'ocr' | 'clipboard'; export declare function ocrTextMatches(actual: string, expected: string | RegExp, options?: { swaps?: OcrSwaps; exact?: boolean; overflow?: OcrOverflow; overflowSlop?: number; }): boolean; /** * OCR utility for extracting text from images using Tesseract.js */ export declare class OCRUtil { private worker; private language; initialize(language?: string): Promise; private ocrParams; private ensureWorker; /** * Extract text from an image buffer */ extractText(imageBuffer: Buffer, options?: { charset?: string; psm?: string; }): Promise; /** * Extract text with confidence scores and bounding boxes */ extractDetailedText(imageBuffer: Buffer): Promise<{ text: string; confidence: number; words: any; lines: any; }>; /** * Full-page word boxes for authoring (labels next to controls). * Sparse text mode, no charset whitelist. */ extractPageWords(imageBuffer: Buffer): Promise>; terminate(): Promise; } /** * Get or create a shared OCR utility instance */ export declare function getOCRUtil(language?: string): Promise; /** * Clean up the shared OCR utility */ export declare function cleanupOCR(): Promise; //# sourceMappingURL=ocr.d.ts.map