/** * * Browser worker scripts * * @fileoverview Browser worker implementation * @author Kevin Kwok * @author Guillermo Webster * @author Jerome Wu */ const worker = require('..'); const getCore = require('./getCore'); const gunzip = require('./gunzip'); const cache = require('./cache'); /* * register message handler */ global.addEventListener('message', ({ data }) => { worker.dispatchHandlers(data, (obj) => postMessage(obj)); }); /* * getCore is a sync function to load and return * TesseractCore. */ worker.setAdapter({ getCore, gunzip, fetch: () => {}, ...cache, });