@nhtio/adk/batteries/specialists/ocr/tesseract_js/adapter
tesseract.js (WASM Tesseract, dual-environment) OCR specialist adapter battery.
Remarks
OCR battery backed by tesseract.js — Node and browsers, no native binary. Environment-neutral, mirroring the transformers.js embeddings battery's dual-environment posture.
Divergence from src/batteries/media/engines/tesseract_js.ts: that MediaEngine creates a fresh worker per convert call and terminates it in a finally — correct for a stateless, possibly-concurrent conversion pipeline, but it pays tesseract's ~1-2s WASM boot on every single call. This adapter is a construct-once specialist object (the same posture as @nhtio/adk/batteries/embeddings/transformers_js!TransformersJsEmbeddingsAdapter): a consumer builds it once and calls TesseractJsOcrAdapter.recognize repeatedly, so it holds one cached worker, created single-flight on first use (or via preload), and reused across calls. dispose() terminates it; reset() also terminates it (see its own TSDoc for why that differs from the embeddings adapter's reset()). Consumers who need the per-call-worker, leak-free-by-construction posture should use the media engine instead.
tesseract.js is an optional peer dependency, lazily imported on first actual use.
Classes
| Class | Description |
|---|---|
| TesseractJsOcrAdapter | OCR adapter for tesseract.js. |