Socket
Socket
Sign inDemoInstall

tesseract.js

Package Overview
Dependencies
18
Maintainers
4
Versions
67
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.0.3 to 4.0.4

benchmarks/browser/auto-rotate-benchmark.html

16

docs/local-installation.md

@@ -13,5 +13,5 @@ ## Local Installation

Tesseract.recognize(image, langs, {
workerPath: 'https://unpkg.com/tesseract.js@v4.0.1/dist/worker.min.js',
workerPath: 'https://cdn.jsdelivr.net/npm/tesseract.js@v4.0.3/dist/worker.min.js',
langPath: 'https://tessdata.projectnaptha.com/4.0.0',
corePath: 'https://unpkg.com/tesseract.js-core@v4.0.1/tesseract-core.wasm.js',
corePath: 'https://cdn.jsdelivr.net/npm/tesseract.js-core@v4.0.3',
})

@@ -24,5 +24,5 @@ ```

const worker = await createWorker({
workerPath: 'https://unpkg.com/tesseract.js@v4.0.1/dist/worker.min.js',
workerPath: 'https://cdn.jsdelivr.net/npm/tesseract.js@v4.0.3/dist/worker.min.js',
langPath: 'https://tessdata.projectnaptha.com/4.0.0',
corePath: 'https://unpkg.com/tesseract.js-core@v4.0.1/tesseract-core.wasm.js',
corePath: 'https://cdn.jsdelivr.net/npm/tesseract.js-core@v4.0.3',
});

@@ -32,3 +32,3 @@ ```

### workerPath
A string specifying the location of the [worker.js](./dist/worker.min.js) file.
A string specifying the location of the `worker.js` file.

@@ -39,4 +39,6 @@ ### langPath

### corePath
A string specifying the location of the [tesseract.js-core library](https://github.com/naptha/tesseract.js-core), with default value 'https://unpkg.com/tesseract.js-core@v4.0.1/tesseract-core.wasm.js'.
A string specifying the location of the [tesseract.js-core library](https://github.com/naptha/tesseract.js-core), with default value 'https://cdn.jsdelivr.net/npm/tesseract.js-core@v4.0.3'.
Another WASM option is 'https://unpkg.com/tesseract.js-core@v4.0.1/tesseract-core.js' which is a script that loads 'https://unpkg.com/tesseract.js-core@v4.0.1/tesseract-core.wasm'. But it fails to fetch at this moment.
When `corePath` is a directory rather than specific `.js` file (e.g. `https://cdn.jsdelivr.net/npm/tesseract.js-core@v4.0.3`), Tesseract.js loads either `tesseract-core-simd.wasm.js` or `tesseract-core.wasm.js` depending on whether the users' device supports SIMD (see [https://webassembly.org/roadmap/](https://webassembly.org/roadmap/)). Therefore, if self-hosting it is important that both these files are in the location you specify for `corePath`. Having multiple files is necessary as the SIMD-enabled version is *significantly* faster (for the LSTM model [the default]), however is not yet supported on all devices.
When `corePath` is set to a specific `.js` file (e.g. `https://cdn.jsdelivr.net/npm/tesseract.js-core@v4.0.3/tesseract-core.wasm.js`), it will load that file regardless of whether the users' device supports SIMD or not. This behavior exists to preserve backwards compatibility--specifying a directory that contains both files is strongly recommended. Specifying a single file will either result in much slower performance (if `tesseract-core.wasm.js` is specified) or failure to run on certain devices (if `tesseract-core-simd.wasm.js` is specified).
{
"name": "tesseract.js",
"version": "4.0.3",
"version": "4.0.4",
"description": "Pure Javascript Multilingual OCR",

@@ -11,3 +11,3 @@ "main": "src/index.js",

"start": "node scripts/server.js",
"build": "rimraf dist && webpack --config scripts/webpack.config.prod.js && rollup -c scripts/rollup.esm.js",
"build": "rimraf dist && webpack --config scripts/webpack.config.prod.js && rollup -c scripts/rollup.esm.mjs",
"profile:tesseract": "webpack-bundle-analyzer dist/tesseract-stats.json",

@@ -39,38 +39,38 @@ "profile:worker": "webpack-bundle-analyzer dist/worker-stats.json",

"devDependencies": {
"@babel/core": "^7.18.7",
"@babel/preset-env": "^7.18.7",
"@rollup/plugin-commonjs": "^22.0.2",
"acorn": "^6.4.0",
"babel-loader": "^8.2.0",
"@babel/core": "^7.21.4",
"@babel/eslint-parser": "^7.21.3",
"@babel/preset-env": "^7.21.4",
"@rollup/plugin-commonjs": "^24.1.0",
"acorn": "^8.8.2",
"babel-loader": "^9.1.2",
"buffer": "^6.0.3",
"cors": "^2.8.5",
"eslint": "^7.2.0",
"eslint-config-airbnb-base": "^14.2.0",
"eslint-plugin-import": "^2.22.1",
"eslint": "^7.32.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-plugin-import": "^2.27.5",
"expect.js": "^0.3.1",
"express": "^4.17.1",
"mocha": "^10.0.0",
"express": "^4.18.2",
"mocha": "^10.2.0",
"mocha-headless-chrome": "^4.0.0",
"npm-run-all": "^4.1.5",
"nyc": "^15.1.0",
"rimraf": "^2.7.1",
"rollup": "^2.79.0",
"wait-on": "^3.3.0",
"webpack": "^5.74.0",
"webpack-bundle-analyzer": "^4.6.0",
"webpack-cli": "^4.10.0",
"webpack-dev-middleware": "^5.3.3"
"rimraf": "^5.0.0",
"rollup": "^3.20.7",
"wait-on": "^7.0.1",
"webpack": "^5.79.0",
"webpack-bundle-analyzer": "^4.8.0",
"webpack-cli": "^5.0.1",
"webpack-dev-middleware": "^6.0.2"
},
"dependencies": {
"babel-eslint": "^10.1.0",
"bmp-js": "^0.1.0",
"file-type": "^12.4.1",
"idb-keyval": "^3.2.0",
"is-electron": "^2.2.0",
"file-type": "^12.4.2",
"idb-keyval": "^6.2.0",
"is-electron": "^2.2.2",
"is-url": "^1.2.4",
"node-fetch": "^2.6.0",
"opencollective-postinstall": "^2.0.2",
"node-fetch": "^2.6.9",
"opencollective-postinstall": "^2.0.3",
"regenerator-runtime": "^0.13.3",
"resolve-url": "^0.2.1",
"tesseract.js-core": "^4.0.3",
"tesseract.js-core": "^4.0.4",
"wasm-feature-detect": "^1.2.11",

@@ -77,0 +77,0 @@ "zlibjs": "^0.3.1"

@@ -105,3 +105,3 @@ <p align="center">

<!-- v4 -->
<script src='https://unpkg.com/tesseract.js@4.0.2/dist/tesseract.min.js'></script>
<script src='https://cdn.jsdelivr.net/npm/tesseract.js@4/dist/tesseract.min.js'></script>
```

@@ -108,0 +108,0 @@ After including the script the `Tesseract` variable will be globally available.

@@ -11,2 +11,3 @@ const path = require('path');

mode: 'development',
devtool: 'source-map',
entry,

@@ -13,0 +14,0 @@ output: {

@@ -9,18 +9,30 @@ const { simd } = require('wasm-feature-detect');

// If the user specifies a core path, we use that
// Otherwise, we detect the correct core based on SIMD support
let corePathImport = corePath;
if (!corePathImport) {
// Otherwise, default to CDN
const corePathImport = corePath || `https://cdn.jsdelivr.net/npm/tesseract.js-core@v${dependencies['tesseract.js-core'].substring(1)}`;
// If a user specifies a specific JavaScript file, load that file.
// Otherwise, assume a directory has been provided, and load either
// tesseract-core.wasm.js or tesseract-core-simd.wasm.js depending
// on whether this device has SIMD support.
let corePathImportFile;
if (corePathImport.slice(-2) === 'js') {
corePathImportFile = corePathImport;
} else {
const simdSupport = await simd();
if (simdSupport) {
corePathImport = `https://unpkg.com/tesseract.js-core@v${dependencies['tesseract.js-core'].substring(1)}/tesseract-core-simd.wasm.js`;
corePathImportFile = `${corePathImport.replace(/\/$/, '')}/tesseract-core-simd.wasm.js`;
} else {
corePathImport = `https://unpkg.com/tesseract.js-core@v${dependencies['tesseract.js-core'].substring(1)}/tesseract-core.wasm.js`;
corePathImportFile = `${corePathImport.replace(/\/$/, '')}/tesseract-core.wasm.js`;
}
}
global.importScripts(corePathImport);
// Create a module named `global.TesseractCore`
global.importScripts(corePathImportFile);
if (typeof global.TesseractCoreWASM !== 'undefined' && typeof WebAssembly === 'object') {
// Tesseract.js-core versions through 4.0.3 create a module named `global.TesseractCoreWASM`,
// so we account for that here to preserve backwards compatibility.
// This part can be removed when Tesseract.js-core v4.0.3 becomes incompatible for other reasons
if (typeof global.TesseractCore === 'undefined' && typeof global.TesseractCoreWASM !== 'undefined' && typeof WebAssembly === 'object') {
global.TesseractCore = global.TesseractCoreWASM;
} else {
} else if (typeof global.TesseractCore === 'undefined') {
throw Error('Failed to load TesseractCore');

@@ -27,0 +39,0 @@ }

@@ -309,4 +309,8 @@ /**

api.FindLines();
const rotateRadiansCalc = api.GetAngle();
// The function GetAngle will be replaced with GetGradient in 4.0.4,
// but for now we want to maintain compatibility.
// We can switch to only using GetGradient in v5.
const rotateRadiansCalc = api.GetGradient ? api.GetGradient() : api.GetAngle();
// Restore user-provided PSM setting

@@ -313,0 +317,0 @@ if (psmEdit) {

@@ -12,3 +12,3 @@ const resolveURL = require('resolve-url');

? resolveURL(`/dist/worker.dev.js?nocache=${Math.random().toString(36).slice(3)}`)
: `https://unpkg.com/tesseract.js@v${version}/dist/worker.min.js`,
: `https://cdn.jsdelivr.net/npm/tesseract.js@v${version}/dist/worker.min.js`,
/*

@@ -15,0 +15,0 @@ * If browser doesn't support WebAssembly,

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc