Browse Source

new version

pull/34/head
Kevin Kwok 8 years ago
parent
commit
c09d4655b5
  1. 2
      README.md
  2. 6
      dist/tesseract.js
  3. 28
      dist/worker.js
  4. 2
      package.json

2
README.md

@ -26,7 +26,7 @@ Tesseract.js works with a `<script>` tag via local copy or cdn, with webpack and @@ -26,7 +26,7 @@ Tesseract.js works with a `<script>` tag via local copy or cdn, with webpack and
You can simply include Tesseract.js with a cdn like this:
```html
<script src='https://cdn.rawgit.com/naptha/tesseract.js/1.0.5/dist/tesseract.js'></script>
<script src='https://cdn.rawgit.com/naptha/tesseract.js/1.0.6/dist/tesseract.js'></script>
```
After including your scripts, the `Tesseract` variable should be defined! You can [head to the docs](#docs) for a full treatment of the API.

6
dist/tesseract.js vendored

@ -268,14 +268,14 @@ process.umask = function() { return 0; }; @@ -268,14 +268,14 @@ process.umask = function() { return 0; };
},{}],3:[function(require,module,exports){
module.exports={
"name": "tesseract.js",
"version": "1.0.5",
"version": "1.0.6",
"description": "Pure Javascript Multilingual OCR",
"main": "src/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" & exit 1",
"start": "watchify src/index.js -t [ envify --NODE_ENV development ] -t [ babelify --presets [ es2015 ] ] -o dist/tesseract.dev.js --standalone Tesseract & watchify src/browser/worker.js -t [ envify --NODE_ENV development ] -t [ babelify --presets [ es2015 ] ] -o dist/worker.dev.js & http-server -p 7355",
"build": "browserify src/index.js -t [ babelify --presets [ es2015 ] ] -o dist/tesseract.js --standalone Tesseract && browserify src/browser/worker.js -t [ babelify --presets [ es2015 ] ] -o dist/worker.js",
"release": "git tag `jq -r '.version' package.json`"
"release": "git tag `jq -r '.version' package.json` && git push origin --tags && npm publish"
},
"browser": {
"./src/node/index.js": "./src/browser/index.js"
@ -321,7 +321,7 @@ var defaultOptions = { @@ -321,7 +321,7 @@ var defaultOptions = {
if (process.env.NODE_ENV === "development") {
console.debug('Using Development Configuration');
defaultOptions.workerPath = location.protocol + '//' + location.host + '/dist/worker.dev.js';
defaultOptions.workerPath = location.protocol + '//' + location.host + '/dist/worker.dev.js?nocache=' + Math.random().toString(36).slice(3);
} else {
var version = require('../../package.json').version;
defaultOptions.workerPath = 'https://cdn.rawgit.com/naptha/tesseract.js/' + version + '/dist/worker.js';

28
dist/worker.js vendored

@ -11857,7 +11857,14 @@ function hasOwnProperty(obj, prop) { @@ -11857,7 +11857,14 @@ function hasOwnProperty(obj, prop) {
'use strict';
var leveljs = require('level-js');
var db = typeof indexedDB === 'undefined' ? { open: function open(_, cb) {
// something about trying to store these language files in indexedDB
// causes iOS Safari to crash
var iOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
var noIDB = typeof indexedDB === 'undefined' || iOS;
var db = noIDB ? { open: function open(_, cb) {
return cb(true);
} } : leveljs('./tessdata2');
@ -11867,10 +11874,13 @@ module.exports = function getLanguageData(req, res, cb) { @@ -11867,10 +11874,13 @@ module.exports = function getLanguageData(req, res, cb) {
var lang = req.options.lang;
function saveDataFile(data) {
db.put(lang, data, function (err) {
return console.log('cached', lang, err);
});
cb(data);
try {
db.put(lang, data, function (err) {
return console.log('cached', lang, err);
});
} finally {
cb(data);
}
}
db.open({ compression: false }, function (err) {
@ -11907,17 +11917,20 @@ function fetchLanguageData(req, res, cb) { @@ -11907,17 +11917,20 @@ function fetchLanguageData(req, res, cb) {
xhr.onload = function (e) {
if (!(xhr.status == 200 || xhr.status == 0 && xhr.response)) return res.reject('Error downloading language ' + url);
res.progress({ status: 'unzipping ' + langfile });
res.progress({ status: 'unzipping ' + langfile, progress: 0 });
// in case the gzips are already ungzipped or extra gzipped
var response = new Uint8Array(xhr.response);
try {
var n = 2;
while (response[0] == 0x1f && response[1] == 0x8b) {
response = ungzip(response);
res.progress({ status: 'unzipping ' + langfile, progress: 1 - 1 / n++ });
}
} catch (err) {
return res.reject('Error unzipping language file ' + langfile + '\n' + err.message);
}
res.progress({ status: 'unzipping ' + langfile, progress: 1 });
cb(response);
};
@ -12245,9 +12258,10 @@ function loadLanguage(req, res, cb) { @@ -12245,9 +12258,10 @@ function loadLanguage(req, res, cb) {
if (lang in Module._loadedLanguages) return cb();
adapter.getLanguageData(req, res, function (data) {
res.progress({ status: 'loading ' + lang + '.traineddata', progress: 0 });
Module.FS_createDataFile('tessdata', lang + ".traineddata", data, true, false);
res.progress({ status: 'loading ' + lang + '.traineddata', progress: 1 });
Module._loadedLanguages[lang] = true;
res.progress({ status: 'loading ' + lang + '.traineddata', progress: 1 });
cb();
});
}

2
package.json

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
{
"name": "tesseract.js",
"version": "1.0.5",
"version": "1.0.6",
"description": "Pure Javascript Multilingual OCR",
"main": "src/index.js",
"scripts": {

Loading…
Cancel
Save