/** * A cross-environment OCR {@link @nhtio/adk/batteries/media/contracts!MediaEngine} * backed by tesseract.js (WASM Tesseract — Node and browsers, no binary). * * @module @nhtio/adk/batteries/media/engines/tesseract_js * * @remarks * The local-by-default OCR engine. Language data files download on first use of each * language; point `langPath`/`cachePath` at a writable location to control where (the * factory requires `languages` up front so a deployment never silently fetches packs for * languages it didn't plan for). Workers are created per recognize call and terminated in * `finally` — slower than a pooled setup but leak-free by construction; consumers who need * pooling can BYO an engine that holds a worker. * * `tesseract.js` is an optional peer dependency, lazily imported on first actual use. * * Declares one convert capability: `image/*` to `txt`/`hocr`/`json` (OCR is a format * conversion — image in, text out). Language hints ride `request.options.languages`. */ import type * as TesseractNS from 'tesseract.js'; import type { MediaEngine } from "../contracts"; type TesseractModule = typeof TesseractNS; /** Options for {@link tesseractJsEngine}. */ export interface TesseractJsEngineOptions { /** Languages to load, e.g. `['eng']`. REQUIRED — language packs download on first use. */ languages: readonly string[]; /** Where language data is fetched from / cached (forwarded to createWorker). */ langPath?: string; /** Local cache directory for downloaded language data. */ cachePath?: string; /** Override the module resolution. Default: `import('tesseract.js')`. */ tesseract?: () => TesseractModule | Promise; } /** * Construct the tesseract.js OCR engine. * * @param options - Languages (required) and data-path overrides. * @returns The engine. */ export declare const tesseractJsEngine: (options: TesseractJsEngineOptions) => MediaEngine; export {};