tesseract.js
Advanced tools
Comparing version 4.0.5 to 4.0.6
{ | ||
"name": "tesseract.js", | ||
"version": "4.0.5", | ||
"version": "4.0.6", | ||
"description": "Pure Javascript Multilingual OCR", | ||
@@ -61,3 +61,4 @@ "main": "src/index.js", | ||
"webpack-cli": "^5.0.1", | ||
"webpack-dev-middleware": "^6.0.2" | ||
"webpack-dev-middleware": "^6.0.2", | ||
"rollup-plugin-sourcemaps": "^0.6.3" | ||
}, | ||
@@ -78,2 +79,5 @@ "dependencies": { | ||
}, | ||
"overrides": { | ||
"@rollup/pluginutils": "^5.0.2" | ||
}, | ||
"repository": { | ||
@@ -80,0 +84,0 @@ "type": "git", |
@@ -48,3 +48,3 @@ <p align="center"> | ||
Or more imperative | ||
Or using workers (recommended for production use): | ||
@@ -67,4 +67,4 @@ ```javascript | ||
[Check out the docs](#documentation) for a full explanation of the API. | ||
For a basic overview of the functions, including the pros/cons of different approaches, see the [intro](./docs/intro.md). [Check out the docs](#documentation) for a full explanation of the API. | ||
## Major changes in v4 | ||
@@ -129,2 +129,3 @@ Version 4 includes many new features and bug fixes--see [this issue](https://github.com/naptha/tesseract.js/issues/662) for a full list. Several highlights are below. | ||
* [Intro](./docs/intro.md) | ||
* [Examples](./docs/examples.md) | ||
@@ -139,3 +140,3 @@ * [Image Format](./docs/image-format.md) | ||
- Offline Version: https://github.com/jeromewu/tesseract.js-offline | ||
- Electron Version: https://github.com/jeromewu/tesseract.js-electron | ||
- Electron Version: https://github.com/Balearica/tesseract.js-electron | ||
- Custom Traineddata: https://github.com/jeromewu/tesseract.js-custom-traineddata | ||
@@ -142,0 +143,0 @@ - Chrome Extension #1: https://github.com/jeromewu/tesseract.js-chrome-extension |
@@ -32,2 +32,4 @@ /** | ||
let params = defaultParams; | ||
let cachePathWorker; | ||
let cacheMethodWorker; | ||
@@ -79,2 +81,6 @@ const load = async ({ workerId, jobId, payload: { options: { corePath, logging } } }, res) => { | ||
res) => { | ||
// Remember cache options for later, as cache may be deleted if `initialize` fails | ||
cachePathWorker = cachePath; | ||
cacheMethodWorker = cacheMethod; | ||
const loadAndGunzipFile = async (_lang) => { | ||
@@ -207,2 +213,10 @@ const lang = typeof _lang === 'string' ? _lang : _lang.code; | ||
if (status === -1) { | ||
// Cache is deleted if initialization fails to avoid keeping bad data in cache | ||
// This assumes that initialization failing only occurs due to bad .traineddata, | ||
// this should be refined if other reasons for init failing are encountered. | ||
if (['write', 'refresh', undefined].includes(cacheMethodWorker)) { | ||
const langsArr = langs.split('+'); | ||
const delCachePromise = langsArr.map((lang) => adapter.deleteCache(`${cachePathWorker || '.'}/${lang}.traineddata`)); | ||
await Promise.all(delCachePromise); | ||
} | ||
res.reject('initialization failed'); | ||
@@ -209,0 +223,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1512524
83
3387
213
25