Pure Javascript OCR for more than 100 Languages 📖🎉🖥
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2 lines
12 KiB

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Tesseract=t():e.Tesseract=t()}(window,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([function(e,t,n){const r=n(3),o={corePath:`https://cdn.jsdelivr.net/gh/naptha/tesseract.js-core@2.0.0-beta.4/tesseract${"object"==typeof WebAssembly?"":"asm"}.js`,langPath:"https://cdn.jsdelivr.net/gh/naptha/tessdata@gh-pages/3.02/"};{const{version:e}=n(4);o.workerPath=`https://cdn.jsdelivr.net/gh/naptha/tesseract.js@${e}/dist/worker.js`}t.defaultOptions=o,t.spawnWorker=((e,t)=>{let n;if(window.Blob&&window.URL){const e=new Blob([`importScripts("${t.workerPath}");`]);n=new Worker(window.URL.createObjectURL(e))}else n=new Worker(t.workerPath);return n.onmessage=(({data:t})=>{e._recv(t)}),n}),t.terminateWorker=(e=>{e.worker.terminate()}),t.sendPacket=((e,t)=>{(e=>r(e)?fetch(e).then(e=>e.buffer()):new Promise)(t.payload.image).then(e=>new Uint8Array(e)).then(n=>{e.worker.postMessage({...t,payload:{...t.payload,image:Array.from(n)}})})})},function(e,t,n){const r=n(2),o=n(0),s=n(5),i=n(6);e.exports={TesseractWorker:class{constructor(e={}){this.worker=null,this.workerOptions=Object.assign({},o.defaultOptions,e),this._currentJob=null,this._queue=[]}recognize(e,t={lang:"eng"}){return this._delay(n=>{n._send("recognize",{image:e,options:r.string(t)?{lang:t||"eng"}:t,workerOptions:this.workerOptions})})}detect(e,t={}){return this._delay(n=>{n._send("detect",{image:e,options:t,workerOptions:this.workerOptions})})}terminate(){this.worker&&o.terminateWorker(this),this.worker=null,this._currentJob=null,this._queue=[]}_delay(e){r.null(this.worker)&&(this.worker=o.spawnWorker(this,this.workerOptions));const t=new i(this);return this._queue.push(()=>{this._queue.shift(),this._currentJob=t,e(t)}),r.null(this._currentJob)&&this._dequeue(),t}_dequeue(){this._currentJob=null,this._queue.length&&this._queue[0]()}_recv(e){this._currentJob.id===e.jobId?this._currentJob._handle({...e,data:"resolve"===e.status&&"recognize"===e.action?s(e.data):e.data}):console.warn(`Job ID ${e.jobId} not known.`)}}}},function(e,t,n){var r;!function(o){"use strict";var s,i,u,a,c,f,l,p,h,b,d,y,g;function m(e){return null!=e}function v(e){return"number"==typeof e&&e>b&&e<d}function w(e){return"number"==typeof e&&e%1==0}function j(e,t){return v(e)&&e>t}function _(e,t){return v(e)&&e<t}function k(e,t){return v(e)&&e>=t}function O(e,t){return v(e)&&e<=t}function E(e){return"string"==typeof e}function x(e){return E(e)&&""!==e}function P(e){return"[object Object]"===Object.prototype.toString.call(e)}function S(e,t){try{return e instanceof t}catch(e){return!1}}function I(e,t){var n;for(n in t)if(t.hasOwnProperty(n)){if(!1===e.hasOwnProperty(n)||typeof e[n]!=typeof t[n])return!1;if(P(e[n])&&!1===I(e[n],t[n]))return!1}return!0}function T(e){return y(e)}function q(e){return m(e)&&k(e.length,0)}function A(e){return"function"==typeof e}function J(e,t){var n;for(n=0;n<e.length;n+=1)if(e[n]===t)return t;return!t}function N(e,t){var n,r;for(n in e)if(e.hasOwnProperty(n)){if(P(r=e[n])&&N(r,t)===t)return t;if(r===t)return t}return!t}function M(e,t){return Object
//# sourceMappingURL=tesseract.min.js.map