-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
654 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
function t(t,e,n,r){return new(n||(n=Promise))((function(i,o){function s(t){try{c(r.next(t))}catch(t){o(t)}}function a(t){try{c(r.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;var e,n=(e=import.meta.url,async function(t={}){var n,r,i=t;i.ready=new Promise(((t,e)=>{n=t,r=e}));var o,s,a,c=Object.assign({},i),_="object"==typeof window,u="function"==typeof importScripts,A="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,f="";if(A){const{createRequire:t}=await Promise.resolve().then((()=>g));var h=t(import.meta.url),l=h("fs"),R=h("path");f=u?R.dirname(f)+"/":h("url").fileURLToPath(new URL("./",import.meta.url)),o=(t,e)=>(t=U(t)?new URL(t):R.normalize(t),l.readFileSync(t,e?void 0:"utf8")),a=t=>{var e=o(t,!0);return e.buffer||(e=new Uint8Array(e)),e},s=(t,e,n,r=!0)=>{t=U(t)?new URL(t):R.normalize(t),l.readFile(t,r?void 0:"utf8",((t,i)=>{t?n(t):e(r?i.buffer:i)}))},!i.thisProgram&&process.argv.length>1&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),i.inspect=()=>"[Emscripten Module object]"}else(_||u)&&(u?f=self.location.href:"undefined"!=typeof document&&document.currentScript&&(f=document.currentScript.src),e&&(f=e),f=0!==f.indexOf("blob:")?f.substr(0,f.replace(/[?#].*/,"").lastIndexOf("/")+1):"",o=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.send(null),e.responseText},u&&(a=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)}),s=(t,e,n)=>{var r=new XMLHttpRequest;r.open("GET",t,!0),r.responseType="arraybuffer",r.onload=()=>{200==r.status||0==r.status&&r.response?e(r.response):n()},r.onerror=n,r.send(null)});var d,m,p,y=i.print||console.log.bind(console),B=i.printErr||console.error.bind(console);Object.assign(i,c),c=null,i.arguments&&i.arguments,i.thisProgram&&i.thisProgram,i.quit&&i.quit,i.wasmBinary&&(d=i.wasmBinary),i.noExitRuntime,"object"!=typeof WebAssembly&&P("no native wasm support detected");var E,I,Z=!1;function v(){var t=m.buffer;i.HEAP8=new Int8Array(t),i.HEAP16=new Int16Array(t),i.HEAP32=new Int32Array(t),i.HEAPU8=E=new Uint8Array(t),i.HEAPU16=new Uint16Array(t),i.HEAPU32=I=new Uint32Array(t),i.HEAPF32=new Float32Array(t),i.HEAPF64=new Float64Array(t)}var b=[],C=[],N=[],S=0,w=null;function P(t){i.onAbort&&i.onAbort(t),B(t="Aborted("+t+")"),Z=!0,t+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(t);throw r(e),e}var T,O,D="data:application/octet-stream;base64,";function F(t){return t.startsWith(D)}function U(t){return t.startsWith("file://")}function H(t){if(t==T&&d)return new Uint8Array(d);if(a)return a(t);throw"both async and sync fetching of the wasm failed"}function G(t,e,n){return function(t){if(!d&&(_||u)){if("function"==typeof fetch&&!U(t))return fetch(t,{credentials:"same-origin"}).then((e=>{if(!e.ok)throw"failed to load wasm binary file at '"+t+"'";return e.arrayBuffer()})).catch((()=>H(t)));if(s)return new Promise(((e,n)=>{s(t,(t=>e(new Uint8Array(t))),n)}))}return Promise.resolve().then((()=>H(t)))}(t).then((t=>WebAssembly.instantiate(t,e))).then((t=>t)).then(n,(t=>{B("failed to asynchronously prepare wasm: "+t),P(t)}))}i.locateFile?F(T="ngx-scanner-qrcode.wasm")||(O=T,T=i.locateFile?i.locateFile(O,f):f+O):T=new URL("ngx-scanner-qrcode.wasm",import.meta.url).href;var L,M=t=>{for(;t.length>0;)t.shift()(i)},x=t=>{var e=t-m.buffer.byteLength+65535>>>16;try{return m.grow(e),v(),1}catch(t){}},W="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,k=[null,[],[]],Y=(t,e)=>{var n=k[t];0===e||10===e?((1===t?y:B)(((t,e,n)=>{for(var r=e+n,i=e;t[i]&&!(i>=r);)++i;if(i-e>16&&t.buffer&&W)return W.decode(t.subarray(e,i));for(var o="";e<i;){var s=t[e++];if(128&s){var a=63&t[e++];if(192!=(224&s)){var c=63&t[e++];if((s=224==(240&s)?(15&s)<<12|a<<6|c:(7&s)<<18|a<<12|c<<6|63&t[e++])<65536)o+=String.fromCharCode(s);else{var _=s-65536;o+=String.fromCharCode(55296|_>>10,56320|1023&_)}}else o+=String.fromCharCode((31&s)<<6|a)}else o+=String.fromCharCode(s)}return o})(n,0)),n.length=0):n.push(e)},j={d:()=>!0,e:function(){return Date.now()},c:t=>{var e=E.length,n=2147483648;if((t>>>=0)>n)return!1;for(var r,i,o=1;o<=4;o*=2){var s=e*(1+.2/o);s=Math.min(s,t+100663296);var a=Math.min(n,(r=Math.max(t,s))+((i=65536)-r%i)%i);if(x(a))return!0}return!1},f:t=>52,b:function(t,e,n,r,i){return 70},a:(t,e,n,r)=>{for(var i=0,o=0;o<n;o++){var s=I[e>>2],a=I[e+4>>2];e+=8;for(var c=0;c<a;c++)Y(t,E[s+c]);i+=a}return I[r>>2]=i,0}};function q(){function t(){L||(L=!0,i.calledRun=!0,Z||(M(C),n(i),i.onRuntimeInitialized&&i.onRuntimeInitialized(),function(){if(i.postRun)for("function"==typeof i.postRun&&(i.postRun=[i.postRun]);i.postRun.length;)t=i.postRun.shift(),N.unshift(t);var t;M(N)}()))}S>0||(function(){if(i.preRun)for("function"==typeof i.preRun&&(i.preRun=[i.preRun]);i.preRun.length;)t=i.preRun.shift(),b.unshift(t);var t;M(b)}(),S>0||(i.setStatus?(i.setStatus("Running..."),setTimeout((function(){setTimeout((function(){i.setStatus("")}),1),t()}),1)):t()))}if(function(){var t,e,n,o,s={a:j};function a(t,e){var n,r=t.exports;return m=(p=r).g,v(),p.s,n=p.h,C.unshift(n),function(t){if(S--,i.monitorRunDependencies&&i.monitorRunDependencies(S),0==S&&w){var e=w;w=null,e()}}(),r}if(S++,i.monitorRunDependencies&&i.monitorRunDependencies(S),i.instantiateWasm)try{return i.instantiateWasm(s,a)}catch(t){B("Module.instantiateWasm callback failed with error: "+t),r(t)}(t=d,e=T,n=s,o=function(t){a(t.instance)},t||"function"!=typeof WebAssembly.instantiateStreaming||F(e)||U(e)||A||"function"!=typeof fetch?G(e,n,o):fetch(e,{credentials:"same-origin"}).then((t=>WebAssembly.instantiateStreaming(t,n).then(o,(function(t){return B("wasm streaming compile failed: "+t),B("falling back to ArrayBuffer instantiation"),G(e,n,o)}))))).catch(r)}(),i._ImageScanner_create=()=>(i._ImageScanner_create=p.i)(),i._ImageScanner_destory=t=>(i._ImageScanner_destory=p.j)(t),i._ImageScanner_set_config=(t,e,n,r)=>(i._ImageScanner_set_config=p.k)(t,e,n,r),i._ImageScanner_enable_cache=(t,e)=>(i._ImageScanner_enable_cache=p.l)(t,e),i._ImageScanner_recycle_image=(t,e)=>(i._ImageScanner_recycle_image=p.m)(t,e),i._ImageScanner_get_results=t=>(i._ImageScanner_get_results=p.n)(t),i._ImageScanner_scan=(t,e)=>(i._ImageScanner_scan=p.o)(t,e),i._Image_create=(t,e,n,r,o,s)=>(i._Image_create=p.p)(t,e,n,r,o,s),i._Image_destory=t=>(i._Image_destory=p.q)(t),i._Image_get_symbols=t=>(i._Image_get_symbols=p.r)(t),i._free=t=>(i._free=p.t)(t),i._malloc=t=>(i._malloc=p.u)(t),w=function t(){L||q(),L||(w=t)},i.preInit)for("function"==typeof i.preInit&&(i.preInit=[i.preInit]);i.preInit.length>0;)i.preInit.pop()();return q(),t.ready});let r;function i(e={}){r=function(){return t(this,void 0,void 0,(function*(){const t=yield n(e);if(t)return t;throw Error("WASM was not loaded")}))}()}function o(){return t(this,void 0,void 0,(function*(){return r||i(),yield r}))}var s,a,c;!function(t){t[t.ZBAR_NONE=0]="ZBAR_NONE",t[t.ZBAR_PARTIAL=1]="ZBAR_PARTIAL",t[t.ZBAR_EAN2=2]="ZBAR_EAN2",t[t.ZBAR_EAN5=5]="ZBAR_EAN5",t[t.ZBAR_EAN8=8]="ZBAR_EAN8",t[t.ZBAR_UPCE=9]="ZBAR_UPCE",t[t.ZBAR_ISBN10=10]="ZBAR_ISBN10",t[t.ZBAR_UPCA=12]="ZBAR_UPCA",t[t.ZBAR_EAN13=13]="ZBAR_EAN13",t[t.ZBAR_ISBN13=14]="ZBAR_ISBN13",t[t.ZBAR_COMPOSITE=15]="ZBAR_COMPOSITE",t[t.ZBAR_I25=25]="ZBAR_I25",t[t.ZBAR_DATABAR=34]="ZBAR_DATABAR",t[t.ZBAR_DATABAR_EXP=35]="ZBAR_DATABAR_EXP",t[t.ZBAR_CODABAR=38]="ZBAR_CODABAR",t[t.ZBAR_CODE39=39]="ZBAR_CODE39",t[t.ZBAR_PDF417=57]="ZBAR_PDF417",t[t.ZBAR_QRCODE=64]="ZBAR_QRCODE",t[t.ZBAR_SQCODE=80]="ZBAR_SQCODE",t[t.ZBAR_CODE93=93]="ZBAR_CODE93",t[t.ZBAR_CODE128=128]="ZBAR_CODE128",t[t.ZBAR_SYMBOL=255]="ZBAR_SYMBOL",t[t.ZBAR_ADDON2=512]="ZBAR_ADDON2",t[t.ZBAR_ADDON5=1280]="ZBAR_ADDON5",t[t.ZBAR_ADDON=1792]="ZBAR_ADDON"}(s||(s={})),function(t){t[t.ZBAR_CFG_ENABLE=0]="ZBAR_CFG_ENABLE",t[t.ZBAR_CFG_ADD_CHECK=1]="ZBAR_CFG_ADD_CHECK",t[t.ZBAR_CFG_EMIT_CHECK=2]="ZBAR_CFG_EMIT_CHECK",t[t.ZBAR_CFG_ASCII=3]="ZBAR_CFG_ASCII",t[t.ZBAR_CFG_BINARY=4]="ZBAR_CFG_BINARY",t[t.ZBAR_CFG_NUM=5]="ZBAR_CFG_NUM",t[t.ZBAR_CFG_MIN_LEN=32]="ZBAR_CFG_MIN_LEN",t[t.ZBAR_CFG_MAX_LEN=33]="ZBAR_CFG_MAX_LEN",t[t.ZBAR_CFG_UNCERTAINTY=64]="ZBAR_CFG_UNCERTAINTY",t[t.ZBAR_CFG_POSITION=128]="ZBAR_CFG_POSITION",t[t.ZBAR_CFG_TEST_INVERTED=129]="ZBAR_CFG_TEST_INVERTED",t[t.ZBAR_CFG_X_DENSITY=256]="ZBAR_CFG_X_DENSITY",t[t.ZBAR_CFG_Y_DENSITY=257]="ZBAR_CFG_Y_DENSITY"}(a||(a={})),function(t){t[t.ZBAR_ORIENT_UNKNOWN=-1]="ZBAR_ORIENT_UNKNOWN",t[t.ZBAR_ORIENT_UP=0]="ZBAR_ORIENT_UP",t[t.ZBAR_ORIENT_RIGHT=1]="ZBAR_ORIENT_RIGHT",t[t.ZBAR_ORIENT_DOWN=2]="ZBAR_ORIENT_DOWN",t[t.ZBAR_ORIENT_LEFT=3]="ZBAR_ORIENT_LEFT"}(c||(c={}));class _{constructor(t,e){this.ptr=t,this.inst=e}checkAlive(){if(!this.ptr)throw Error("Call after destroyed")}getPointer(){return this.checkAlive(),this.ptr}}class u{constructor(t,e){this.ptr=t,this.ptr32=t>>2,this.buf=e,this.HEAP8=new Int8Array(e),this.HEAPU32=new Uint32Array(e),this.HEAP32=new Int32Array(e)}}class A extends u{get type(){return this.HEAPU32[this.ptr32]}get data(){const t=this.HEAPU32[this.ptr32+4],e=this.HEAPU32[this.ptr32+5];return Int8Array.from(this.HEAP8.subarray(e,e+t))}get points(){const t=this.HEAPU32[this.ptr32+7],e=this.HEAPU32[this.ptr32+8]>>2,n=[];for(let r=0;r<t;++r){const t=this.HEAP32[e+2*r],i=this.HEAP32[e+2*r+1];n.push({x:t,y:i})}return n}get orientation(){return this.HEAP32[this.ptr32+9]}get next(){const t=this.HEAPU32[this.ptr32+11];return t?new A(t,this.buf):null}get time(){return this.HEAPU32[this.ptr32+13]}get cacheCount(){return this.HEAP32[this.ptr32+14]}get quality(){return this.HEAP32[this.ptr32+15]}}class f extends u{get head(){const t=this.HEAPU32[this.ptr32+2];return t?new A(t,this.buf):null}}class h{constructor(t){this.type=t.type,this.typeName=s[this.type],this.data=t.data,this.points=t.points,this.orientation=t.orientation,this.time=t.time,this.cacheCount=t.cacheCount,this.quality=t.quality}static createSymbolsFromPtr(t,e){if(0==t)return[];let n=new f(t,e).head;const r=[];for(;null!==n;)r.push(new h(n)),n=n.next;return r}decode(t){return new TextDecoder(t).decode(this.data)}}class l extends _{static createFromGrayBuffer(e,n,r,i=0){return t(this,void 0,void 0,(function*(){const t=yield o(),s=new Uint8Array(r),a=e*n;if(a!==s.byteLength)throw Error(`data length (${s.byteLength} bytes) does not match width and height (${a} bytes)`);const c=t._malloc(a);t.HEAPU8.set(s,c);return new this(t._Image_create(e,n,808466521,c,a,i),t)}))}static createFromRGBABuffer(e,n,r,i=0){return t(this,void 0,void 0,(function*(){const t=yield o(),s=new Uint8Array(r),a=e*n;if(4*a!==s.byteLength)throw Error(`data length (${s.byteLength} bytes) does not match width and height (${4*a} bytes)`);const c=t._malloc(a),_=c+a,u=t.HEAPU8;for(let t=c,e=0;t<_;t++,e+=4)u[t]=19595*s[e]+38469*s[e+1]+7472*s[e+2]>>16;return new this(t._Image_create(e,n,808466521,c,a,i),t)}))}destroy(){this.checkAlive(),this.inst._Image_destory(this.ptr),this.ptr=0}getSymbols(){this.checkAlive();const t=this.inst._Image_get_symbols(this.ptr);return h.createSymbolsFromPtr(t,this.inst.HEAPU8.buffer)}}class R extends _{static create(){return t(this,void 0,void 0,(function*(){const t=yield o();return new this(t._ImageScanner_create(),t)}))}destroy(){this.checkAlive(),this.inst._ImageScanner_destory(this.ptr),this.ptr=0}setConfig(t,e,n){return this.checkAlive(),this.inst._ImageScanner_set_config(this.ptr,t,e,n)}enableCache(t=!0){this.checkAlive(),this.inst._ImageScanner_enable_cache(this.ptr,t)}recycleImage(t){this.checkAlive(),this.inst._ImageScanner_recycle_image(this.ptr,t.getPointer())}getResults(){this.checkAlive();const t=this.inst._ImageScanner_get_results(this.ptr);return h.createSymbolsFromPtr(t,this.inst.HEAPU8.buffer)}scan(t){return this.checkAlive(),this.inst._ImageScanner_scan(this.ptr,t.getPointer())}}const d=()=>t(void 0,void 0,void 0,(function*(){const t=yield R.create();return t.setConfig(s.ZBAR_NONE,a.ZBAR_CFG_BINARY,1),t}));let m;const p=(e,n)=>t(void 0,void 0,void 0,(function*(){void 0===n&&(n=m||(yield d()),m=n);const t=n.scan(e);if(t<0)throw Error("Scan Failed");return 0===t?[]:e.getSymbols()})),y=(e,n,r,i)=>t(void 0,void 0,void 0,(function*(){const t=yield l.createFromGrayBuffer(n,r,e),o=yield p(t,i);return t.destroy(),o})),B=(e,n,r,i)=>t(void 0,void 0,void 0,(function*(){const t=yield l.createFromRGBABuffer(n,r,e),o=yield p(t,i);return t.destroy(),o})),E=(e,n)=>t(void 0,void 0,void 0,(function*(){return yield B(e.data.buffer,e.width,e.height,n)})),g=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{a as ZBarConfigType,l as ZBarImage,c as ZBarOrientation,R as ZBarScanner,h as ZBarSymbol,s as ZBarSymbolType,d as getDefaultScanner,o as getInstance,y as scanGrayBuffer,E as scanImageData,B as scanRGBABuffer,i as setModuleArgs}; | ||
//# sourceMappingURL=index.mjs.map |
Oops, something went wrong.