From c2a06b4b12767a0e47994e9ca0c1a540df95aaa4 Mon Sep 17 00:00:00 2001 From: Kevin Kwok Date: Fri, 7 Oct 2016 23:07:50 -0400 Subject: [PATCH] import with cors --- dist/tesseract.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dist/tesseract.js b/dist/tesseract.js index 117dbd49c..1db4202fb 100644 --- a/dist/tesseract.js +++ b/dist/tesseract.js @@ -9,7 +9,13 @@ exports.defaultOptions = { }; exports.spawnWorker = function spawnWorker(instance, workerOptions) { - var worker = new Worker(workerOptions.workerPath); + if (window.Blob && window.URL) { + var blob = new Blob(['importScripts("' + workerOptions.workerPath + '");']); + var worker = new Worker(window.URL.createObjectURL(blob)); + } else { + var worker = new Worker(workerOptions.workerPath); + } + worker.onmessage = function (e) { var packet = e.data; instance._recv(packet);