Merge pull request #141 from mikewesthad/master

Node fix: allowing a local langPath to be used when looking for language files
master
Kevin Kwok 7 years ago committed by GitHub
commit 8e9f7861ac
  1. 8
      dist/tesseract.js
  2. 336
      dist/worker.js
  3. 2972
      package-lock.json
  4. 3
      package.json
  5. 15
      src/node/lang.js

8
dist/tesseract.js vendored

@ -169,6 +169,10 @@ process.off = noop;
process.removeListener = noop;
process.removeAllListeners = noop;
process.emit = noop;
process.prependListener = noop;
process.prependOnceListener = noop;
process.listeners = function (name) { return [] }
process.binding = function (name) {
throw new Error('process.binding is not supported');
@ -203,6 +207,7 @@ module.exports={
"browserify": "^13.1.0",
"envify": "^3.4.1",
"http-server": "^0.9.0",
"isomorphic-fetch": "^2.2.1",
"pako": "^1.0.3",
"watchify": "^3.7.0"
},
@ -225,6 +230,7 @@ module.exports={
},
"homepage": "https://github.com/naptha/tesseract.js"
}
},{}],3:[function(require,module,exports){
(function (process){
'use strict';
@ -571,6 +577,8 @@ var TesseractWorker = function () {
value: function terminate() {
if (this.worker) adapter.terminateWorker(this);
this.worker = null;
this._currentJob = null;
this._queue = [];
}
}, {
key: '_delay',

336
dist/worker.js vendored

@ -82,7 +82,7 @@ AbstractChainedBatch.prototype.write = function (options, callback) {
module.exports = AbstractChainedBatch
}).call(this,require('_process'))
},{"_process":32}],2:[function(require,module,exports){
},{"_process":31}],2:[function(require,module,exports){
(function (process){
/* Copyright (c) 2013 Rod Vagg, MIT License */
@ -135,7 +135,7 @@ AbstractIterator.prototype.end = function (callback) {
module.exports = AbstractIterator
}).call(this,require('_process'))
},{"_process":32}],3:[function(require,module,exports){
},{"_process":31}],3:[function(require,module,exports){
(function (Buffer,process){
/* Copyright (c) 2013 Rod Vagg, MIT License */
@ -395,7 +395,7 @@ module.exports.AbstractIterator = AbstractIterator
module.exports.AbstractChainedBatch = AbstractChainedBatch
}).call(this,{"isBuffer":require("../is-buffer/index.js")},require('_process'))
},{"../is-buffer/index.js":10,"./abstract-chained-batch":1,"./abstract-iterator":2,"_process":32,"xtend":4}],4:[function(require,module,exports){
},{"../is-buffer/index.js":9,"./abstract-chained-batch":1,"./abstract-iterator":2,"_process":31,"xtend":4}],4:[function(require,module,exports){
module.exports = extend
function extend() {
@ -450,22 +450,22 @@ function placeHoldersCount (b64) {
function byteLength (b64) {
// base64 is 4/3 + up to two characters of the original data
return b64.length * 3 / 4 - placeHoldersCount(b64)
return (b64.length * 3 / 4) - placeHoldersCount(b64)
}
function toByteArray (b64) {
var i, j, l, tmp, placeHolders, arr
var i, l, tmp, placeHolders, arr
var len = b64.length
placeHolders = placeHoldersCount(b64)
arr = new Arr(len * 3 / 4 - placeHolders)
arr = new Arr((len * 3 / 4) - placeHolders)
// if there are placeholders, only get up to the last complete 4 chars
l = placeHolders > 0 ? len - 4 : len
var L = 0
for (i = 0, j = 0; i < l; i += 4, j += 3) {
for (i = 0; i < l; i += 4) {
tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)]
arr[L++] = (tmp >> 16) & 0xFF
arr[L++] = (tmp >> 8) & 0xFF
@ -2323,7 +2323,7 @@ function isnan (val) {
}
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"base64-js":5,"ieee754":8,"isarray":11}],7:[function(require,module,exports){
},{"base64-js":5,"ieee754":8,"isarray":10}],7:[function(require,module,exports){
/*global window:false, self:false, define:false, module:false */
/**
@ -3817,31 +3817,6 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
}
},{}],9:[function(require,module,exports){
if (typeof Object.create === 'function') {
// implementation from standard node.js 'util' module
module.exports = function inherits(ctor, superCtor) {
ctor.super_ = superCtor
ctor.prototype = Object.create(superCtor.prototype, {
constructor: {
value: ctor,
enumerable: false,
writable: true,
configurable: true
}
});
};
} else {
// old school shim for old browsers
module.exports = function inherits(ctor, superCtor) {
ctor.super_ = superCtor
var TempCtor = function () {}
TempCtor.prototype = superCtor.prototype
ctor.prototype = new TempCtor()
ctor.prototype.constructor = ctor
}
}
},{}],10:[function(require,module,exports){
/*!
* Determine if an object is a Buffer
*
@ -3864,14 +3839,14 @@ function isSlowBuffer (obj) {
return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
}
},{}],11:[function(require,module,exports){
},{}],10:[function(require,module,exports){
var toString = {}.toString;
module.exports = Array.isArray || function (arr) {
return toString.call(arr) == '[object Array]';
};
},{}],12:[function(require,module,exports){
},{}],11:[function(require,module,exports){
var Buffer = require('buffer').Buffer;
module.exports = isBuffer;
@ -3881,7 +3856,7 @@ function isBuffer (o) {
|| /\[object (.+Array|Array.+)\]/.test(Object.prototype.toString.call(o));
}
},{"buffer":6}],13:[function(require,module,exports){
},{"buffer":6}],12:[function(require,module,exports){
(function (Buffer){
module.exports = Level
@ -4059,7 +4034,7 @@ var checkKeyValue = Level.prototype._checkKeyValue = function (obj, type) {
}
}).call(this,require("buffer").Buffer)
},{"./iterator":14,"abstract-leveldown":3,"buffer":6,"idb-wrapper":7,"isbuffer":12,"typedarray-to-buffer":33,"util":35,"xtend":37}],14:[function(require,module,exports){
},{"./iterator":13,"abstract-leveldown":3,"buffer":6,"idb-wrapper":7,"isbuffer":11,"typedarray-to-buffer":32,"util":35,"xtend":37}],13:[function(require,module,exports){
var util = require('util')
var AbstractIterator = require('abstract-leveldown').AbstractIterator
var ltgt = require('ltgt')
@ -4133,7 +4108,7 @@ Iterator.prototype._next = function (callback) {
this.callback = callback
}
},{"abstract-leveldown":3,"ltgt":15,"util":35}],15:[function(require,module,exports){
},{"abstract-leveldown":3,"ltgt":14,"util":35}],14:[function(require,module,exports){
(function (Buffer){
exports.compare = function (a, b) {
@ -4181,28 +4156,28 @@ var lowerBoundKey = exports.lowerBoundKey = function (range) {
)
}
var lowerBound = exports.lowerBound = function (range) {
var lowerBound = exports.lowerBound = function (range, def) {
var k = lowerBoundKey(range)
return k && range[k]
return k ? range[k] : def
}
exports.lowerBoundInclusive = function (range) {
var lowerBoundInclusive = exports.lowerBoundInclusive = function (range) {
return has(range, 'gt') ? false : true
}
exports.upperBoundInclusive =
var upperBoundInclusive = exports.upperBoundInclusive =
function (range) {
return has(range, 'lt') || !range.minEx ? false : true
return (has(range, 'lt') /*&& !range.maxEx*/) ? false : true
}
var lowerBoundExclusive = exports.lowerBoundExclusive =
function (range) {
return has(range, 'gt') || range.minEx ? true : false
return !lowerBoundInclusive(range)
}
var upperBoundExclusive = exports.upperBoundExclusive =
function (range) {
return has(range, 'lt') ? true : false
return !upperBoundInclusive(range)
}
var upperBoundKey = exports.upperBoundKey = function (range) {
@ -4215,9 +4190,30 @@ var upperBoundKey = exports.upperBoundKey = function (range) {
)
}
var upperBound = exports.upperBound = function (range) {
var upperBound = exports.upperBound = function (range, def) {
var k = upperBoundKey(range)
return k && range[k]
return k ? range[k] : def
}
exports.start = function (range, def) {
return range.reverse ? upperBound(range, def) : lowerBound(range, def)
}
exports.end = function (range, def) {
return range.reverse ? lowerBound(range, def) : upperBound(range, def)
}
exports.startInclusive = function (range) {
return (
range.reverse
? upperBoundInclusive(range)
: lowerBoundInclusive(range)
)
}
exports.endInclusive = function (range) {
return (
range.reverse
? lowerBoundInclusive(range)
: upperBoundInclusive(range)
)
}
function id (e) { return e }
@ -4282,8 +4278,10 @@ exports.filter = function (range, compare) {
}
}
}).call(this,{"isBuffer":require("../is-buffer/index.js")})
},{"../is-buffer/index.js":10}],16:[function(require,module,exports){
},{"../is-buffer/index.js":9}],15:[function(require,module,exports){
var hasOwn = Object.prototype.hasOwnProperty;
var toString = Object.prototype.toString;
@ -4325,11 +4323,11 @@ module.exports = function forEach(obj, fn) {
};
},{}],17:[function(require,module,exports){
},{}],16:[function(require,module,exports){
module.exports = Object.keys || require('./shim');
},{"./shim":19}],18:[function(require,module,exports){
},{"./shim":18}],17:[function(require,module,exports){
var toString = Object.prototype.toString;
module.exports = function isArguments(value) {
@ -4347,7 +4345,7 @@ module.exports = function isArguments(value) {
};
},{}],19:[function(require,module,exports){
},{}],18:[function(require,module,exports){
(function () {
"use strict";
@ -4411,7 +4409,7 @@ module.exports = function isArguments(value) {
}());
},{"./foreach":16,"./isArguments":18}],20:[function(require,module,exports){
},{"./foreach":15,"./isArguments":17}],19:[function(require,module,exports){
'use strict';
@ -4795,7 +4793,7 @@ function inflate(input, options) {
inflator.push(input, true);
// That will never happens, if you don't cheat with options :)
if (inflator.err) { throw inflator.msg; }
if (inflator.err) { throw inflator.msg || msg[inflator.err]; }
return inflator.result;
}
@ -4831,7 +4829,7 @@ exports.inflate = inflate;
exports.inflateRaw = inflateRaw;
exports.ungzip = inflate;
},{"./utils/common":21,"./utils/strings":22,"./zlib/constants":24,"./zlib/gzheader":26,"./zlib/inflate":28,"./zlib/messages":30,"./zlib/zstream":31}],21:[function(require,module,exports){
},{"./utils/common":20,"./utils/strings":21,"./zlib/constants":23,"./zlib/gzheader":25,"./zlib/inflate":27,"./zlib/messages":29,"./zlib/zstream":30}],20:[function(require,module,exports){
'use strict';
@ -4935,7 +4933,7 @@ exports.setTyped = function (on) {
exports.setTyped(TYPED_OK);
},{}],22:[function(require,module,exports){
},{}],21:[function(require,module,exports){
// String encode/decode helpers
'use strict';
@ -5122,13 +5120,32 @@ exports.utf8border = function (buf, max) {
return (pos + _utf8len[buf[pos]] > max) ? pos : max;
};
},{"./common":21}],23:[function(require,module,exports){
},{"./common":20}],22:[function(require,module,exports){
'use strict';
// Note: adler32 takes 12% for level 0 and 2% for level 6.
// It doesn't worth to make additional optimizationa as in original.
// Small size is preferable.
// (C) 1995-2013 Jean-loup Gailly and Mark Adler
// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
function adler32(adler, buf, len, pos) {
var s1 = (adler & 0xffff) |0,
s2 = ((adler >>> 16) & 0xffff) |0,
@ -5156,9 +5173,27 @@ function adler32(adler, buf, len, pos) {
module.exports = adler32;
},{}],24:[function(require,module,exports){
},{}],23:[function(require,module,exports){
'use strict';
// (C) 1995-2013 Jean-loup Gailly and Mark Adler
// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
module.exports = {
@ -5208,13 +5243,31 @@ module.exports = {
//Z_NULL: null // Use -1 or null inline, depending on var type
};
},{}],25:[function(require,module,exports){
},{}],24:[function(require,module,exports){
'use strict';
// Note: we can't get significant speed boost here.
// So write code to minimize size - no pregenerated tables
// and array tools dependencies.
// (C) 1995-2013 Jean-loup Gailly and Mark Adler
// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
// Use ordinary array, since untyped makes no boost here
function makeTable() {
@ -5251,9 +5304,27 @@ function crc32(crc, buf, len, pos) {
module.exports = crc32;
},{}],26:[function(require,module,exports){
},{}],25:[function(require,module,exports){
'use strict';
// (C) 1995-2013 Jean-loup Gailly and Mark Adler
// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
function GZheader() {
/* true if compressed data believed to be text */
@ -5293,9 +5364,28 @@ function GZheader() {
module.exports = GZheader;
},{}],27:[function(require,module,exports){
},{}],26:[function(require,module,exports){
'use strict';
// (C) 1995-2013 Jean-loup Gailly and Mark Adler
// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
// See state defs from inflate.js
var BAD = 30; /* got a data error -- remain here until reset */
var TYPE = 12; /* i: waiting for type bits, including last-flag bit */
@ -5621,9 +5711,27 @@ module.exports = function inflate_fast(strm, start) {
return;
};
},{}],28:[function(require,module,exports){
},{}],27:[function(require,module,exports){
'use strict';
// (C) 1995-2013 Jean-loup Gailly and Mark Adler
// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
var utils = require('../utils/common');
var adler32 = require('./adler32');
@ -7161,9 +7269,27 @@ exports.inflateSyncPoint = inflateSyncPoint;
exports.inflateUndermine = inflateUndermine;
*/
},{"../utils/common":21,"./adler32":23,"./crc32":25,"./inffast":27,"./inftrees":29}],29:[function(require,module,exports){
},{"../utils/common":20,"./adler32":22,"./crc32":24,"./inffast":26,"./inftrees":28}],28:[function(require,module,exports){
'use strict';
// (C) 1995-2013 Jean-loup Gailly and Mark Adler
// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
var utils = require('../utils/common');
@ -7391,10 +7517,8 @@ module.exports = function inflate_table(type, lens, lens_index, codes, table, ta
return 1;
}
var i = 0;
/* process all codes and make table entries */
for (;;) {
i++;
/* create table entry */
here_bits = len - drop;
if (work[sym] < end) {
@ -7490,9 +7614,28 @@ module.exports = function inflate_table(type, lens, lens_index, codes, table, ta
return 0;
};
},{"../utils/common":21}],30:[function(require,module,exports){
},{"../utils/common":20}],29:[function(require,module,exports){
'use strict';
// (C) 1995-2013 Jean-loup Gailly and Mark Adler
// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
module.exports = {
2: 'need dictionary', /* Z_NEED_DICT 2 */
1: 'stream end', /* Z_STREAM_END 1 */
@ -7505,9 +7648,27 @@ module.exports = {
'-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */
};
},{}],31:[function(require,module,exports){
},{}],30:[function(require,module,exports){
'use strict';
// (C) 1995-2013 Jean-loup Gailly and Mark Adler
// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
function ZStream() {
/* next input byte */
@ -7536,7 +7697,7 @@ function ZStream() {
module.exports = ZStream;
},{}],32:[function(require,module,exports){
},{}],31:[function(require,module,exports){
// shim for using process in browser
var process = module.exports = {};
@ -7707,6 +7868,10 @@ process.off = noop;
process.removeListener = noop;
process.removeAllListeners = noop;
process.emit = noop;
process.prependListener = noop;
process.prependOnceListener = noop;
process.listeners = function (name) { return [] }
process.binding = function (name) {
throw new Error('process.binding is not supported');
@ -7718,7 +7883,7 @@ process.chdir = function (dir) {
};
process.umask = function() { return 0; };
},{}],33:[function(require,module,exports){
},{}],32:[function(require,module,exports){
(function (Buffer){
/**
* Convert a typed array to a Buffer without a copy
@ -7741,7 +7906,32 @@ module.exports = function (arr) {
}
}).call(this,require("buffer").Buffer)
},{"buffer":6}],34:[function(require,module,exports){
},{"buffer":6}],33:[function(require,module,exports){
if (typeof Object.create === 'function') {
// implementation from standard node.js 'util' module
module.exports = function inherits(ctor, superCtor) {
ctor.super_ = superCtor
ctor.prototype = Object.create(superCtor.prototype, {
constructor: {
value: ctor,
enumerable: false,
writable: true,
configurable: true
}
});
};
} else {
// old school shim for old browsers
module.exports = function inherits(ctor, superCtor) {
ctor.super_ = superCtor
var TempCtor = function () {}
TempCtor.prototype = superCtor.prototype
ctor.prototype = new TempCtor()
ctor.prototype.constructor = ctor
}
}
},{}],34:[function(require,module,exports){
module.exports = function isBuffer(arg) {
return arg && typeof arg === 'object'
&& typeof arg.copy === 'function'
@ -8338,7 +8528,7 @@ function hasOwnProperty(obj, prop) {
}
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"./support/isBuffer":34,"_process":32,"inherits":9}],36:[function(require,module,exports){
},{"./support/isBuffer":34,"_process":31,"inherits":33}],36:[function(require,module,exports){
module.exports = hasKeys
function hasKeys(source) {
@ -8374,7 +8564,7 @@ function extend() {
return target
}
},{"./has-keys":36,"object-keys":17}],38:[function(require,module,exports){
},{"./has-keys":36,"object-keys":16}],38:[function(require,module,exports){
'use strict';
var leveljs = require('level-js');
@ -8458,7 +8648,7 @@ function fetchLanguageData(req, res, cb) {
xhr.send();
}
},{"../common/langdata.json":42,"level-js":13,"pako/lib/inflate.js":20}],39:[function(require,module,exports){
},{"../common/langdata.json":42,"level-js":12,"pako/lib/inflate.js":19}],39:[function(require,module,exports){
(function (process,global){
'use strict';
@ -8489,7 +8679,7 @@ exports.getLanguageData = require('./lang.js');
workerUtils.setAdapter(module.exports);
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"../common/worker.js":43,"./lang.js":38,"_process":32}],40:[function(require,module,exports){
},{"../common/worker.js":43,"./lang.js":38,"_process":31}],40:[function(require,module,exports){
'use strict';
// This converts an image to grayscale

2972
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -25,6 +25,7 @@
},
"dependencies": {
"file-type": "^3.8.0",
"isomorphic-fetch": "^2.2.1",
"is-url": "^1.2.2",
"jpeg-js": "^0.2.0",
"level-js": "^2.2.4",
@ -41,4 +42,4 @@
"url": "https://github.com/naptha/tesseract.js/issues"
},
"homepage": "https://github.com/naptha/tesseract.js"
}
}

@ -1,15 +1,22 @@
const http = require("http"),
zlib = require("zlib"),
fs = require("fs"),
path = require("path");
path = require("path"),
isURL = require("is-url");
var langdata = require('../common/langdata.json')
function getLanguageData(req, res, cb){
var lang = req.options.lang,
langfile = lang + '.traineddata.gz';
fs.readFile(lang + '.traineddata', function (err, data) {
// langPath defaults to a URL where languages can be downloaded. If a custom path is specified
// and it is a local path, use that instead
var localPath = isURL(req.workerOptions.langPath) ?
lang + '.traineddata' :
path.join(req.workerOptions.langPath, lang + '.traineddata');
fs.readFile(localPath, function (err, data) {
if(!err) return cb(new Uint8Array(data));
http.get(req.workerOptions.langPath + langfile, stream => {
@ -34,4 +41,4 @@ function getLanguageData(req, res, cb){
}
module.exports = getLanguageData;
module.exports = getLanguageData;

Loading…
Cancel
Save