scandit-web-datacapture-core
Version:
Scandit Data Capture SDK for the Web
7 lines (4 loc) • 1.59 kB
JavaScript
import { f } from './chunk-RR3PHYWZ.js';
import { a } from './chunk-SP3HSP4K.js';
function p({wasmURI:e,expectedHash:t,verifyResponseHash:i,progressCallback:s,successCallback:a$1,importObject:l,referredOrigin:m}){async function b(r){try{let o=await f({wasmURI:e,expectedHash:t,verifyResponseHash:i,onProgress:s,referredOrigin:m}),y=await(r!=null?r:o).arrayBuffer(),g=await globalThis.WebAssembly.instantiate(y,l);a$1(g.instance,g.module);}catch(o){a.log(a.Level.Error,o),a.log(a.Level.Error,`Couldn't instantiate Scandit SDK DataCapture library at ${e}, did you configure the path for it correctly?`);}}async function u(){let r;try{r=await f({wasmURI:e,expectedHash:t,verifyResponseHash:i,onProgress:s,referredOrigin:m});let o=await globalThis.WebAssembly.instantiateStreaming(r,l);a$1(o.instance,o.module);}catch(o){a.log(a.Level.Warn,o),a.log(a.Level.Warn,"WebAssembly streaming compile failed. Falling back to ArrayBuffer instantiation (this will make things slower)"),b((r==null?void 0:r.bodyUsed)===!0?void 0:r);}}typeof globalThis.WebAssembly.instantiateStreaming=="function"?u():b();}async function h(e,t,i,s){return new Promise((a,l)=>{e().then(a).catch(m=>{let b=t*2;if(b>i){l(m);return}s(m),globalThis.setTimeout(()=>{h(e,b,i,s).then(a).catch(l);},t);});})}function v(e){var i,s;let t="";if((i=e.href)!=null&&i.startsWith("blob:null/"))t="localhost";else {let a=((s=e.pathname)==null?void 0:s.length)>1&&!e.pathname.startsWith("/");t=new URL(a?e.pathname:e.origin).hostname;}return t.startsWith("[")&&t.endsWith("]")&&(t=t.slice(1,-1)),t}
export { p as a, h as b, v as c };