TesseractJs.Config (tesseract_js v0.1.0)

Copy Markdown View Source

Reads :tesseract_js Application config with sensible defaults and resolves the paths the browser needs (workerPath, corePath, langPath) for either CDN or local mode.

Config keys:

config :tesseract_js,
  base_path: "/assets/vendor/tesseract",  # where local files live (when source: :local)
  lang: "eng",                            # default language
  source: :cdn,                           # :cdn (default) or :local
  tessdata_repo: :standard,               # :standard | :best | :fast
  core_variant: :simd_lstm                # :simd_lstm | :simd | :basic

Summary

Functions

Just the base_path used for local-mode asset URLs.

Returns the merged config map (defaults ← Application env ← overrides).

Returns the runtime configuration the browser needs

Functions

base_path(overrides \\ [])

Just the base_path used for local-mode asset URLs.

get(overrides \\ [])

@spec get(keyword() | map()) :: map()

Returns the merged config map (defaults ← Application env ← overrides).

runtime(overrides \\ [])

@spec runtime(keyword() | map()) :: map()

Returns the runtime configuration the browser needs:

%{
  workerPath: "/assets/vendor/tesseract/worker.min.js",
  corePath:   "<cdn or local>/tesseract-core-simd-lstm.wasm.js",
  langPath:   "<cdn or local>",
  lang:       "eng",
  oem:        1
}

This is what the <.script /> component serializes into window.__tesseractJs. The JS wrapper reads these defaults at boot.

Notes:

  • workerPath is always served from the package's vendored files (small, no benefit to CDN).
  • corePath and langPath flip based on source.
  • For CDN mode, langPath points at the parent jsDelivr directory so tesseract.js's worker can build per-lang URLs from it.