diff --git a/src/browser/index.js b/src/browser/index.js index 06e62ab5d..880515093 100644 --- a/src/browser/index.js +++ b/src/browser/index.js @@ -124,11 +124,11 @@ exports.defaultOptions = { * @param {object} instance - TesseractWorker instance * @param {object} options * @param {string} options.workerPath - worker script path - * @param {boolean} options.preventBlobURL - do not use a blob: URL for the worker script + * @param {boolean} options.workerBlobURL - Use a blob:// URL for the worker script */ -exports.spawnWorker = (instance, { workerPath, preventBlobURL }) => { +exports.spawnWorker = (instance, { workerPath, workerBlobURL }) => { let worker; - if (Blob && URL && !preventBlobURL) { + if (Blob && URL && workerBlobURL) { const blob = new Blob([`importScripts("${workerPath}");`], { type: 'application/javascript', }); diff --git a/src/common/TesseractWorker.js b/src/common/TesseractWorker.js index af2d082bb..5b66287c3 100644 --- a/src/common/TesseractWorker.js +++ b/src/common/TesseractWorker.js @@ -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. @@ -43,7 +44,6 @@ class TesseractWorker { * @param {string} [options.cachePath=.] - @see {@link https://github.com/jeromewu/tesseract.js-utils/blob/master/src/loadLang.js} * @param {string} [options.cacheMethod=write] - @see {@link https://github.com/jeromewu/tesseract.js-utils/blob/master/src/loadLang.js} * @param {string} [options.dataPath=.] - @see {@link https://github.com/jeromewu/tesseract.js-utils/blob/master/src/loadLang.js} - * @param {boolean} [options.preventBlobURL=false] - do not use a blob: URL for the worker script * */ constructor(options = {}) { diff --git a/src/common/options.js b/src/common/options.js index df55425d1..a86a263de 100644 --- a/src/common/options.js +++ b/src/common/options.js @@ -8,7 +8,10 @@ module.exports = { * of 20 MB. */ langPath: 'https://tessdata.projectnaptha.com/4.0.0', - preventBlobURL: false, + /* + * Use BlobURL for worker script by default + */ + workerBlobURL: true, }, /* * default params for recognize()