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. 6
      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 @@
import desaturate from './desaturate' import desaturate from '../shared/desaturate'
import loadLanguage from './loadLanguage' import loadLanguage from './loadLanguage'
export default function detect(jobId, image, cb){ export default function detect(jobId, image, cb){

4
src/worker/index.js

@ -29,9 +29,9 @@ onmessage = function(e) {
} else if(action === 'recognize'){ } else if(action === 'recognize'){
var {image, options} = args var {image, options} = args
recognize(jobId, image, options, recognize(jobId, image, options,
(error, result) => postMessage({jobId, error, result})) (error, result) => postMessage({jobId, error: error.message, result}))
} else if(action === 'detect'){ } else if(action === 'detect'){
detect(jobId, args.image, 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 @@
import {ungzip} from 'pako' import {ungzip} from 'pako'
import db from './db' import db from './db'
import fileSizes from './fileSizes' import fileSizes from '../shared/fileSizes'
function getLanguageData(lang, progress, cb){ function getLanguageData(lang, progress, cb){
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.responseType = 'arraybuffer'; 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.onerror = e => {
xhr.onprogress = xhr.onload = null xhr.onprogress = xhr.onload = null
cb(xhr, null) cb(xhr, null)

6
src/worker/recognize.js

@ -1,7 +1,7 @@
import desaturate from './desaturate' import desaturate from '../shared/desaturate'
import loadLanguage from './loadLanguage' import loadLanguage from './loadLanguage'
import circularize from './circularize' import circularize from '../shared/circularize'
import dump from './dump' import dump from '../shared/dump'
var loaded_langs = [] var loaded_langs = []

12
webpack.config.dev.js

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