Skip to content

Commit

Permalink
Merge pull request #322 from ThibG/master
Browse files Browse the repository at this point in the history
Add option not to use a blob: URL for the worker source
  • Loading branch information
jeromewu committed Aug 27, 2019
2 parents ad66816 + 6fb2195 commit b6e9d6c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/browser/index.js
Expand Up @@ -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',
});
Expand Down
1 change: 1 addition & 0 deletions src/common/TesseractWorker.js
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions src/common/options.js
Expand Up @@ -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()
Expand Down

0 comments on commit b6e9d6c

Please sign in to comment.