@scandit/web-datacapture-core
Version:
Scandit Data Capture SDK for the Web
1 lines • 1.72 kB
JavaScript
import {f}from'./chunk-B5JOQVFY.js';import {a}from'./chunk-XR65N6EG.js';function v({wasmURI:e,expectedHash:t,verifyResponseHash:l,progressCallback:o,successCallback:a$1,errorCallback:n,importObject:m,referredOrigin:u}){async function b(r){try{let i=await f({wasmURI:e,expectedHash:t,verifyResponseHash:l,onProgress:o,referredOrigin:u}),y=await(r!=null?r:i).arrayBuffer(),c=await globalThis.WebAssembly.instantiate(y,m);a$1(c.instance,c.module);}catch(i){a.log(a.Level.Error,i),a.log(a.Level.Error,`Couldn't instantiate Scandit SDK DataCapture library at ${e}, did you configure the path for it correctly?`),n==null||n(i);}}async function f$1(){let r;try{r=await f({wasmURI:e,expectedHash:t,verifyResponseHash:l,onProgress:o,referredOrigin:u});let i=await globalThis.WebAssembly.instantiateStreaming(r,m);a$1(i.instance,i.module);}catch(i){a.log(a.Level.Warn,i),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)===true?void 0:r);}}typeof globalThis.WebAssembly.instantiateStreaming=="function"?f$1():b();}async function d(e,t,l,o){return new Promise((a,n)=>{e().then(a).catch(m=>{let u=t*2;if(u>l){n(m);return}o(m),globalThis.setTimeout(()=>{d(e,u,l,o).then(a).catch(n);},t);});})}function w(e){var o,a;let t="unknown";if((o=e.href)!=null&&o.startsWith("blob:null/"))t="localhost";else {let n=((a=e.pathname)==null?void 0:a.length)>1&&!e.pathname.startsWith("/");t=new URL(n?e.pathname:e.origin).hostname;}return t.startsWith("[")&&t.endsWith("]")?(t=t.slice(1,-1),t):(/^(\d{1,3}\.){3}\d{1,3}$/.test(t)&&(t=t.split(".").map(n=>Number.parseInt(n,10).toString()).join(".")),t)}export{v as a,d as b,w as c};