Browse Source

moving things to shared

pull/12/head
Kevin Kwok 8 years ago
parent
commit
733328e99b
  1. 0
      src/shared/circularize.js
  2. 0
      src/shared/desaturate.js
  3. 0
      src/shared/dump.js
  4. 0
      src/shared/fileSizes.js
  5. 2
      src/worker/detect.js
  6. 4
      src/worker/index.js
  7. 4
      src/worker/loadLanguage.js
  8. 8
      src/worker/recognize.js
  9. 12
      webpack.config.dev.js

0
src/worker/circularize.js → src/shared/circularize.js

0
src/worker/desaturate.js → src/shared/desaturate.js

0
src/worker/dump.js → src/shared/dump.js

0
src/worker/fileSizes.js → src/shared/fileSizes.js

2
src/worker/detect.js

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
import desaturate from './desaturate'
import desaturate from '../shared/desaturate'
import loadLanguage from './loadLanguage'
export default function detect(jobId, image, cb){

4
src/worker/index.js

@ -29,9 +29,9 @@ onmessage = function(e) { @@ -29,9 +29,9 @@ onmessage = function(e) {
} else if(action === 'recognize'){
var {image, options} = args
recognize(jobId, image, options,
(error, result) => postMessage({jobId, error, result}))
(error, result) => postMessage({jobId, error: error.message, result}))
} else if(action === 'detect'){
detect(jobId, args.image,
(error, result) => postMessage({jobId, error, result}))
(error, result) => postMessage({jobId, error: error.message, result}))
}
}

4
src/worker/loadLanguage.js

@ -1,11 +1,11 @@ @@ -1,11 +1,11 @@
import {ungzip} from 'pako'
import db from './db'
import fileSizes from './fileSizes'
import fileSizes from '../shared/fileSizes'
function getLanguageData(lang, progress, cb){
var xhr = new XMLHttpRequest();
xhr.responseType = 'arraybuffer';
xhr.open('GET', self.LANG_URL + lang + '.traineddata.gz', true);
xhr.open('GET', self.langUrl + lang + '.traineddata.gz', true);
xhr.onerror = e => {
xhr.onprogress = xhr.onload = null
cb(xhr, null)

8
src/worker/recognize.js

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
import desaturate from './desaturate'
import desaturate from '../shared/desaturate'
import loadLanguage from './loadLanguage'
import circularize from './circularize'
import dump from './dump'
import circularize from '../shared/circularize'
import dump from '../shared/dump'
var loaded_langs = []
@ -22,7 +22,7 @@ export default function recognize(jobId, image, options, cb){ @@ -22,7 +22,7 @@ export default function recognize(jobId, image, options, cb){
self.base.Init(null, lang)
postMessage({
jobId,
jobId,
'progress': {
'initialized_with_lang': lang
}

12
webpack.config.dev.js

@ -1,11 +1,11 @@ @@ -1,11 +1,11 @@
var path = require('path');
var webpack = require('webpack');
function config({entry, output, include}) {
function config(opt) {
return {
devtool: 'cheap-module-eval-source-map',
entry,
output: Object.assign({}, output, {
entry: opt.entry,
output: Object.assign({}, opt.output, {
path: path.join(__dirname, 'build'),
publicPath: '/tesseract/',
}),
@ -16,7 +16,7 @@ function config({entry, output, include}) { @@ -16,7 +16,7 @@ function config({entry, output, include}) {
loaders: [{
test: /\.js$/,
loaders: ['babel'],
include
include: opt.include
}]
},
node: {
@ -32,11 +32,11 @@ module.exports = [{ @@ -32,11 +32,11 @@ module.exports = [{
library: "Tesseract",
libraryTarget: "umd"
},
include: [path.join(__dirname, 'src/browser')]
include: [path.join(__dirname, 'src/browser'), path.join(__dirname, 'src/shared')]
}, {
entry: './src/worker/index.js',
output: {
filename: 'tesseract.worker.js',
},
include: [path.join(__dirname, 'src/worker')]
include: [path.join(__dirname, 'src/worker'), path.join(__dirname, 'src/shared')]
}].map(config);
Loading…
Cancel
Save