Browse Source

Add option not to use a blob: URL for the worker source

pull/322/head
Thibaut Girka 6 years ago
parent
commit
eb288fb885
  1. 5
      src/browser/index.js
  2. 1
      src/common/TesseractWorker.js
  3. 1
      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.preventBlobURL - do not use a blob: URL for the worker script
*/
exports.spawnWorker = (instance, { workerPath }) => {
exports.spawnWorker = (instance, { workerPath, preventBlobURL }) => {
let worker;
if (Blob && URL) {
if (Blob && URL && !preventBlobURL) {
const blob = new Blob([`importScripts("${workerPath}");`], {
type: 'application/javascript',
});

1
src/common/TesseractWorker.js

@ -43,6 +43,7 @@ class TesseractWorker { @@ -43,6 +43,7 @@ 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 = {}) {

1
src/common/options.js

@ -8,6 +8,7 @@ module.exports = { @@ -8,6 +8,7 @@ module.exports = {
* of 20 MB.
*/
langPath: 'https://tessdata.projectnaptha.com/4.0.0',
preventBlobURL: false,
},
/*
* default params for recognize()

Loading…
Cancel
Save