Browse Source

Merge pull request #322 from ThibG/master

Add option not to use a blob: URL for the worker source
pull/333/head
jeromewu 5 years ago committed by GitHub
parent
commit
b6e9d6c6a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      src/browser/index.js
  2. 1
      src/common/TesseractWorker.js
  3. 4
      src/common/options.js

5
src/browser/index.js

@ -124,10 +124,11 @@ exports.defaultOptions = { @@ -124,10 +124,11 @@ exports.defaultOptions = {
* @param {object} instance - TesseractWorker instance
* @param {object} options
* @param {string} options.workerPath - worker script path
* @param {boolean} options.workerBlobURL - Use a blob:// URL for the worker script
*/
exports.spawnWorker = (instance, { workerPath }) => {
exports.spawnWorker = (instance, { workerPath, workerBlobURL }) => {
let worker;
if (Blob && URL) {
if (Blob && URL && workerBlobURL) {
const blob = new Blob([`importScripts("${workerPath}");`], {
type: 'application/javascript',
});

1
src/common/TesseractWorker.js

@ -32,6 +32,7 @@ class TesseractWorker { @@ -32,6 +32,7 @@ class TesseractWorker {
* In browser-like environment, it is downloaded from a CDN service.
* Please update this option if you self-host the worker script.
* In Node.js environment, this option is not used as the worker script is in local.
* @param {boolean} [options.workerBlobURL=true] - Use a blob: URL for the worker script
* @param {string} options.corePath -
* A remote path to load tesseract.js-core script.
* In browser-like environment, it is downloaded from a CDN service.

4
src/common/options.js

@ -8,6 +8,10 @@ module.exports = { @@ -8,6 +8,10 @@ module.exports = {
* of 20 MB.
*/
langPath: 'https://tessdata.projectnaptha.com/4.0.0',
/*
* Use BlobURL for worker script by default
*/
workerBlobURL: true,
},
/*
* default params for recognize()

Loading…
Cancel
Save