Browse Source

Fix process is not defined issue

pull/305/head
Jerome Wu 6 years ago
parent
commit
57ae937646
  1. 2
      src/browser/index.js
  2. 2
      src/common/TesseractWorker.js

2
src/browser/index.js

@ -105,7 +105,7 @@ const downloadFile = (path, blob) => {
*/ */
exports.defaultOptions = { exports.defaultOptions = {
...defaultOptions, ...defaultOptions,
workerPath: process.env.TESS_ENV === 'development' workerPath: (typeof process !== 'undefined' && process.env.TESS_ENV === 'development')
? resolveURL(`/dist/worker.dev.js?nocache=${Math.random().toString(36).slice(3)}`) ? resolveURL(`/dist/worker.dev.js?nocache=${Math.random().toString(36).slice(3)}`)
: `https://unpkg.com/tesseract.js@v${version}/dist/worker.min.js`, : `https://unpkg.com/tesseract.js@v${version}/dist/worker.min.js`,
/* /*

2
src/common/TesseractWorker.js

@ -8,7 +8,7 @@
* @author Jerome Wu <jeromewus@gmail.com> * @author Jerome Wu <jeromewus@gmail.com>
*/ */
const check = require('check-types'); const check = require('check-types');
const resolveURL = process.browser ? require('resolve-url') : s => s; const resolveURL = (typeof window !== 'undefined' && typeof window.document !== 'undefined') ? require('resolve-url') : s => s;
const adapter = require('../node'); const adapter = require('../node');
const circularize = require('./circularize'); const circularize = require('./circularize');
const TesseractJob = require('./TesseractJob'); const TesseractJob = require('./TesseractJob');

Loading…
Cancel
Save