Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from Aug 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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