@scandit/web-datacapture-parser 8.5.0-beta.1 → 8.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/THIRD_PARTY.txt +45 -0
- package/build/js/{ParserInterfaceProxy-BCpaNnoO.js → ParserInterfaceProxy-Bxsr1X9T.js} +1 -1
- package/build/js/ParserLoader-BgJeKji6.js +1 -0
- package/build/js/moduleLoader.js +1 -1
- package/build/js/parser/Parser.js +1 -1
- package/build/js/parser/private/ParserInterfaceProxy.js +1 -1
- package/build/js/parser/private/ParserLoader.js +1 -1
- package/build/js/worker/ParserComponent.js +1 -1
- package/package.json +3 -3
- package/sdc-lib/parser-worker-8.5.0.js +1 -0
- package/sdc-lib/scandit-datacapture-sdk-parser-pthreads.js +1 -1
- package/sdc-lib/scandit-datacapture-sdk-parser-pthreads.wasm +0 -0
- package/sdc-lib/scandit-datacapture-sdk-parser-simd-pthreads.js +1 -1
- package/sdc-lib/scandit-datacapture-sdk-parser-simd-pthreads.wasm +0 -0
- package/sdc-lib/scandit-datacapture-sdk-parser-simd.js +1 -1
- package/sdc-lib/scandit-datacapture-sdk-parser-simd.wasm +0 -0
- package/sdc-lib/scandit-datacapture-sdk-parser.js +1 -1
- package/sdc-lib/scandit-datacapture-sdk-parser.wasm +0 -0
- package/build/js/ParserLoader-BeiQF80N.js +0 -1
- package/sdc-lib/parser-worker-8.5.0-beta.1.js +0 -1
- /package/sdc-lib/resources/models/{qr_module_prediction_model_spatial_transformer.e790edc14d39.model → qr_model_1.e790edc14d39.model} +0 -0
- /package/sdc-lib/resources/models/{qr_module_prediction.515757826ca3.model → qr_model_2.515757826ca3.model} +0 -0
package/THIRD_PARTY.txt
CHANGED
|
@@ -199,3 +199,48 @@
|
|
|
199
199
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
200
|
See the License for the specific language governing permissions and
|
|
201
201
|
limitations under the License.
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
================================================================================
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
Copyright (c) 2014 Arnout Kazemier
|
|
208
|
+
Copyright (c) 2018 Copyright 2018 Klaus Hartl, Fagner Brack, GitHub Contributors
|
|
209
|
+
Copyright (c) 2013-2020 James Simpson and GoldFire Studios, Inc.
|
|
210
|
+
Copyright (c) 2012-2024 Faisal Salman <f@faisalman.com>
|
|
211
|
+
Copyright (c) 2017-2018 Fredrik Nicol
|
|
212
|
+
Copyright (c) 2005-2014 Rich Felker, et al.
|
|
213
|
+
Copyright (c) 2010-2014 Emscripten authors, see AUTHORS file.
|
|
214
|
+
|
|
215
|
+
Permission is hereby granted, free of charge, to any person
|
|
216
|
+
obtaining a copy of this software and associated documentation
|
|
217
|
+
files (the "Software"), to deal in the Software without
|
|
218
|
+
restriction, including without limitation the rights to use, copy,
|
|
219
|
+
modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
220
|
+
of the Software, and to permit persons to whom the Software is
|
|
221
|
+
furnished to do so, subject to the following conditions:
|
|
222
|
+
|
|
223
|
+
The above copyright notice and this permission notice shall be
|
|
224
|
+
included in all copies or substantial portions of the Software.
|
|
225
|
+
|
|
226
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
227
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
228
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
229
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
230
|
+
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
231
|
+
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
232
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
233
|
+
SOFTWARE.
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
================================================================================
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
This project is licensed under the MIT license.
|
|
240
|
+
Copyrights are respective of each contributor listed at the beginning of each definition file.
|
|
241
|
+
|
|
242
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
243
|
+
|
|
244
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
245
|
+
|
|
246
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./ParserLoader-
|
|
1
|
+
import{t as e}from"./ParserLoader-BgJeKji6.js";import{AbstractProxyableClass as t}from"./private/decorators/AbstractProxyableClass.js";import{MirrorToWorkerClass as n,proxy as r}from"./private/decorators/Proxyable.js";function i(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let a=class extends t{constructor(...e){super(...e),this.command=`djinniAction`}get worker(){return e.worker}async parseStringToJson(e){return{}}async setOptions(e){return!1}getId(){return`${this.dataFormat}`}async create(e){return this.dataFormat=e,``}};i([r()],a.prototype,`parseStringToJson`,null),i([r({argumentsSerializer:e=>[JSON.stringify(e[0])]})],a.prototype,`setOptions`,null),i([r()],a.prototype,`create`,null),a=i([n(`ParserInterface`)],a);export{a as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{WorkersRegistry as e}from"./parser/private/WorkersRegistry.js";import{Deferred as t}from"@scandit/web-datacapture-core/build/js/private/utils/deferred.js";var n=`parser-worker-8.5.0.js`;function r(e){try{var t=e.endsWith(`/`)?e:e+`/`;return new URL(n,t).href}catch(t){var r=t instanceof Error?t.message:String(t);throw Error(`Invalid worker URL: `+e+`/`+n+` (`+r+`)`)}}function i(e){try{return new URL(e).origin===location.origin}catch(n){var t=n instanceof Error?n.message:String(n);return console.warn(`Could not determine origin for worker URL "`+e+`": `+t+`. Defaulting to cross-origin path.`),!1}}function a(e,t){/javascript|ecmascript/i.test(e.type)||(e=new Blob([e],{type:`application/javascript`}));var n=URL.createObjectURL(e),r=new Worker(n,{name:t});return setTimeout(function(){URL.revokeObjectURL(n)},0),r}async function o(e){if(!e||!e.libraryLocation)throw Error(`ExternalWorker requires options.libraryLocation`);var t=r(e.libraryLocation);try{var n=await fetch(t,i(t)?{}:{mode:`cors`});if(!n.ok)throw Error(`Failed to load worker script: `+t+` (status `+n.status+`)`);var o=await n.blob();return i(t)?new Worker(t,{name:e.name}):a(o,e.name)}catch(e){throw e instanceof Error&&e.message.startsWith(`Failed to load worker script:`)?e:Error(`Failed to load worker script: `+t+` (`+(e instanceof Error?e.message:e)+`)`)}}var s=class n{constructor(e){this.moduleName=`Parser`,this.id=0,this.loadingOptions=e}static get worker(){return e.get(`ParserWorker`)}static async create(t){if(!e.has(`ParserWorker`)){let n=await o({name:`ParserWorker`,libraryLocation:t.libraryLocation});e.set(`ParserWorker`,n)}return new n(t)}async load(){await this.sendMessage({id:this.id++,methodName:`load`,className:`ParserLoader`,args:[{libraryLocation:this.loadingOptions.libraryLocation,simdSupport:this.loadingOptions.simdSupport,threadsSupport:this.loadingOptions.threadsSupport,verifyResponseHash:this.loadingOptions.verifyResponseHash,referredOrigin:this.loadingOptions.referredOrigin??``}]})}async setLogLevel(e){await this.sendMessage({id:this.id++,methodName:`setLogLevel`,className:`ParserLoader`,args:[e]})}async sendMessage(e){let r=new t,i=t=>{let{data:a}=t;e.id===a.payload.id&&(a.payload.result.type===`result`?r.resolve(a.payload.result.result):r.reject(a.payload.result.error),n.worker.removeEventListener(`message`,i))};return n.worker.addEventListener(`message`,i),n.worker.postMessage(e),r.promise}};export{s as t};
|
package/build/js/moduleLoader.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./ParserLoader-
|
|
1
|
+
import{t as e}from"./ParserLoader-BgJeKji6.js";import{Logger as t}from"@scandit/web-datacapture-core";import{normalizeLibraryLocation as n}from"@scandit/web-datacapture-core/build/js/private/Helper.js";function r(r){return r!=null&&r.libraryLocation&&(r.libraryLocation=n(r.libraryLocation)),{moduleName:`Parser`,load:async n=>{let i=n,a=await e.create({libraryLocation:(r==null?void 0:r.libraryLocation)??i.libraryLocation,simdSupport:i.simdSupport,threadsSupport:i.threadsSupport,verifyResponseHash:!0,referredOrigin:globalThis.location.origin});await a.setLogLevel(n.logLevel??t.Level.Debug),await a.load()}}}export{r as parserLoader};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"../ParserInterfaceProxy-
|
|
1
|
+
import{t as e}from"../ParserInterfaceProxy-Bxsr1X9T.js";import{ParserSettings as t}from"./private/ParserSettings.js";import{LicensedFeature as n}from"@scandit/web-datacapture-core/build/js/worker/index.js";var r=class r{constructor(e){this.type=`parser`,this.settings=new t,this.settings.dataFormat=e}get id(){return`${this.settings.dataFormat}`}static async forFormat(t,i){let a=t,o=new r(i);if(o.parserProxy=new e,!await a.isFeatureSupported(n.Parser))throw Error(`Parser not supported by the current license`);return await o.parserProxy.create(i),o}async parseStringToJson(e){return this.parserProxy.parseStringToJson(e)}async setOptions(e){return this.parserProxy.setOptions(e)}toJSONObject(){return{type:this.type,settings:this.settings.toJSONObject()}}};export{r as Parser};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"../../ParserInterfaceProxy-
|
|
1
|
+
import{t as e}from"../../ParserInterfaceProxy-Bxsr1X9T.js";export{e as ParserInterfaceProxy};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"../../ParserLoader-
|
|
1
|
+
import{t as e}from"../../ParserLoader-BgJeKji6.js";export{e as ParserLoader};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DataCaptureError as e,DataCaptureVersion as t,Logger as n}from"@scandit/web-datacapture-core";import{getLibraryLocationURIs as r}from"@scandit/web-datacapture-core/build/js/private/Helper.js";import{Deferred as i}from"@scandit/web-datacapture-core/build/js/private/utils/deferred.js";import{isWorkerScope as a}from"@scandit/web-datacapture-core/build/js/private/utils/isWorkerScope.js";import{instantiateWebAssembly as o}from"@scandit/web-datacapture-core/build/js/worker/helper.js";import{setWasmMetadata as s}from"@scandit/web-datacapture-core/build/js/worker/helperFetch.js";import{importWasmScript as c}from"@scandit/web-datacapture-core/build/js/worker/importWasmScript.js";const l=e=>e.result!=null&&e.error==null;function u(e,t){return{type:`djinniResult`,payload:{id:e.id,className:e.className,methodName:e.methodName,instanceId:e.instanceId,result:t}}}function d(e,t){return{type:`parserLoaderResult`,payload:{id:e.id,className:e.className,methodName:e.methodName,result:t}}}var f=class{constructor(e,t){this.parsers=new Map,this.onMessageListener=this.onMessage.bind(this),this.setupPromise=null,this.workerSelf=e,this.moduleHandler=t,a(e)&&(this.workerFunctions={postMessage:this.workerSelf.postMessage.bind(this.workerSelf)},this.listenToMessages()),s({"scandit-datacapture-sdk-parser-
|
|
1
|
+
import{DataCaptureError as e,DataCaptureVersion as t,Logger as n}from"@scandit/web-datacapture-core";import{getLibraryLocationURIs as r}from"@scandit/web-datacapture-core/build/js/private/Helper.js";import{Deferred as i}from"@scandit/web-datacapture-core/build/js/private/utils/deferred.js";import{isWorkerScope as a}from"@scandit/web-datacapture-core/build/js/private/utils/isWorkerScope.js";import{instantiateWebAssembly as o}from"@scandit/web-datacapture-core/build/js/worker/helper.js";import{setWasmMetadata as s}from"@scandit/web-datacapture-core/build/js/worker/helperFetch.js";import{importWasmScript as c}from"@scandit/web-datacapture-core/build/js/worker/importWasmScript.js";const l=e=>e.result!=null&&e.error==null;function u(e,t){return{type:`djinniResult`,payload:{id:e.id,className:e.className,methodName:e.methodName,instanceId:e.instanceId,result:t}}}function d(e,t){return{type:`parserLoaderResult`,payload:{id:e.id,className:e.className,methodName:e.methodName,result:t}}}var f=class{constructor(e,t){this.parsers=new Map,this.onMessageListener=this.onMessage.bind(this),this.setupPromise=null,this.workerSelf=e,this.moduleHandler=t,a(e)&&(this.workerFunctions={postMessage:this.workerSelf.postMessage.bind(this.workerSelf)},this.listenToMessages()),s({"scandit-datacapture-sdk-parser-pthreads.wasm":{bytes:7204067},"scandit-datacapture-sdk-parser-simd.wasm":{bytes:7175715},"scandit-datacapture-sdk-parser.wasm":{bytes:7230747},"scandit-datacapture-sdk-parser-simd-pthreads.wasm":{bytes:7162507}})}get Module(){return this.moduleHandler.get()}setLogLevel(e){n.setLevel(e.args[0]),this.workerFunctions.postMessage(d(e,{type:`result`,result:!0}))}async load(e){try{await this.setup(e.args[0]),this.workerFunctions.postMessage(d(e,{type:`result`,result:!0}))}catch(t){this.workerFunctions.postMessage(d(e,{type:`error`,error:t}))}}listenToMessages(){this.workerSelf.addEventListener(`message`,this.onMessageListener),this.workerSelf.addEventListener(`error`,e=>{n.log(n.Level.Error,e)}),this.workerSelf.addEventListener(`messageerror`,e=>{n.log(n.Level.Error,e)})}onMessage(e){return e.data.className===`ParserLoader`&&e.data.methodName===`load`&&this.load(e.data),e.data.className===`ParserLoader`&&e.data.methodName===`setLogLevel`&&this.setLogLevel(e.data),e.data.className===`ParserInterface`&&this.performDjinniAction(e.data),!0}async performDjinniAction(e){let t;if(n.log(n.Level.Debug,`${e.className}::${e.methodName}(`,e.args,`)`),e.methodName===`create`){let r=e.args[0].toString();if(this.parsers.has(r)){this.workerFunctions.postMessage(u(e,{type:`result`,result:r}));return}t=this.createParser(e),n.log(n.Level.Debug,t),this.workerFunctions.postMessage(t);return}let r=this.parsers.get(e.instanceId??``);if(r==null){this.workerFunctions.postMessage(u(e,{type:`error`,error:`parser is not defined: try to access instance with id ${e.instanceId??``}`}));return}let i=r[e.methodName](...e.args);t=l(i)?u(e,i):u(e,{type:`error`,error:i.error}),this.workerFunctions.postMessage(t)}async setup({libraryLocation:a,threadsSupport:s,simdSupport:l,verifyResponseHash:u,referredOrigin:d}){if(this.setupPromise!=null)return this.setupPromise;let{resolve:f,reject:p,promise:m}=new i;this.setupPromise=m;let h=t.sdkVersion();if(h===``)throw new e({name:`Invalid library version`,message:`Library version is not defined or empty, cannot generate proper path to library files.`});let{jsURI:g,wasmURI:_}=r(h,a,this.getWasmParserFileName(l,s));return this.moduleHandler.set({mainScriptUrlOrBlob:g,locateFile:e=>a+e,onMainComplete:()=>{},onRuntimeInitialized:()=>{f()},print:e=>{n.log(n.Level.Info,e)},instantiateWasm:(e,t)=>(o({importObject:e,wasmURI:_,expectedHash:this.getWasmParserExpectedHash(l,s),verifyResponseHash:u,successCallback:t,progressCallback:()=>{},referredOrigin:d}),{})}),await c(g,h)||p(`Couldn't retrieve Parser library at ${g}, did you configure the path for it correctly?`),m}createParser(e){var t;let r=this.Module.ParserInterface.create(e.args[0]);if(n.log(n.Level.Debug,`Parser:create returns ${r.type}`,r),r.type===`error`)return u(e,r);let i=((t=e.args[0])==null?void 0:t.toString())??``,a=u(e,{type:`result`,result:i});return this.parsers.set(i,r.result),a}getWasmParserExpectedHash(e,t){return t?e?`824c2b12f6377c7bd250ad4e2eaac8021792d7d3b61ce0ba4a692144d46263c9`:`1be78d1343e09afa19d4cac54347d81d529d0207c19037b491cd27d04bb78aaa`:e?`edae43f1437a26f72008ba312288a135549ca52bb2c18539152c85aa79da6ddb`:`bfa14a62e722453a06029c25795f64948042d0ba7f555ceada0a7186d378c2fe`}getWasmParserFileName(e,t){return t?e?`scandit-datacapture-sdk-parser-simd-pthreads.wasm`:`scandit-datacapture-sdk-parser-pthreads.wasm`:e?`scandit-datacapture-sdk-parser-simd.wasm`:`scandit-datacapture-sdk-parser.wasm`}};export{f as ParserComponent};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scandit/web-datacapture-parser",
|
|
3
|
-
"version": "8.5.0
|
|
3
|
+
"version": "8.5.0",
|
|
4
4
|
"description": "Scandit Data Capture SDK for the Web",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -95,8 +95,8 @@
|
|
|
95
95
|
"check-ci": "biome ci --diagnostic-level=error ."
|
|
96
96
|
},
|
|
97
97
|
"peerDependencies": {
|
|
98
|
-
"@scandit/web-datacapture-barcode": "8.5.0
|
|
99
|
-
"@scandit/web-datacapture-core": "8.5.0
|
|
98
|
+
"@scandit/web-datacapture-barcode": "8.5.0",
|
|
99
|
+
"@scandit/web-datacapture-core": "8.5.0"
|
|
100
100
|
},
|
|
101
101
|
"dependencies": {
|
|
102
102
|
"@types/emscripten": "1.40.1"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(){let e;(function(e){e.Level=function(e){return e.Debug=`debug`,e.Info=`info`,e.Warn=`warn`,e.Error=`error`,e.Quiet=`quiet`,e}({});let t=new Map([[`debug`,1],[`info`,2],[`warn`,3],[`error`,4],[`quiet`,5]]),n=`debug`;function r(e){n=e}e.setLevel=r;function i(e,...r){if(!(t.get(n)>t.get(e)))switch(e){case`debug`:console.debug(...r);break;case`info`:console.log(...r);break;case`warn`:console.warn(...r);break;case`error`:console.error(...r);break;default:break}}e.log=i;function a(...e){i(`warn`,...e)}e.warn=a;function o(...e){i(`debug`,...e)}e.debug=o;function s(...e){i(`info`,...e)}e.info=s;function c(...e){i(`error`,...e)}e.error=c})(e||={});var t=class e extends Error{constructor(t){super(t.message),Object.setPrototypeOf(this,e.prototype),this.name=t.name}toString(){return`${this.name}: ${this.message}`}};function n(e){return/^https?:\/\/(?:[^./]*\.)*cdn.jsdelivr.net\//.test(e)?{result:!0,cdnBaseURL:`https://cdn.jsdelivr.net/npm/`}:/^https?:\/\/(?:[^./]*\.)*unpkg.com\//.test(e)?{result:!0,cdnBaseURL:`https://unpkg.com/`}:{result:!1,cdnBaseURL:``}}function r(e){let t=/@scandit\/web-datacapture-[a-z]+/i.exec(e);return t?t[0]:null}function i(e,t,i){let a=t,o=n(a);if(o.result){let t=r(a);t!=null&&(a=`${o.cdnBaseURL}${t}@${e}/sdc-lib/`)}let s=i.replace(`.wasm`,``);return o.result?{jsURI:`${a}${s}.js`,wasmURI:`${a}${s}.wasm`}:{jsURI:`${a}${s}.js?v=${e}`,wasmURI:`${a}${s}.wasm?v=${e}`}}let a;(function(e){function n(){let e=`8.5.0`;if(e==null)throw new t({name:`Invalid library version`,message:`Library version is not defined or empty.`});return e}e.sdkVersion=n})(a||={});function o(e){return typeof e==`object`&&!!e&&e.document==null&&`addEventListener`in e&&typeof e.importScripts==`function`}var s=class{constructor(){this.promise=new Promise((e,t)=>{this.reject=t,this.resolve=e})}};let c={};function l(e){return[...new Uint8Array(e)].map(e=>{let t=e.toString(16);return t.length===1?`0${t}`:t}).join(``)}async function*u(e){let t=e.getReader();try{for(;;){let{done:e,value:n}=await t.read();if(e)return;yield n}}finally{t.releaseLock()}}async function d(e){let t=[],n=0,r=0;for await(let r of u(e))t.push(r),n+=r.length;let i=new Uint8Array(n);for(let e of t)i.set(e,r),r+=e.length;return i.buffer}(function(e){return e.VALID=`VALID`,e.INVALID=`INVALID`,e.NOT_VERIFIABLE=`NOT_VERIFIABLE`,e})({});async function f(t,n,r){if(typeof crypto.subtle.digest!=`function`)return e.log(e.Level.Warn,`Insecure context (see https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts): The hash of the Scandit Data Capture library WASM file found at ${r} could not be verified`),`NOT_VERIFIABLE`;try{let i=t instanceof Promise?await t:t,a=l(await crypto.subtle.digest(`SHA-256`,i));return n==null?(e.log(e.Level.Warn,`The library hash is not defined or empty, cannot correctly verify integrity.`),`NOT_VERIFIABLE`):a===n?(e.log(e.Level.Debug,`Data Capture library WASM integrity found at ${r} has been verified correctly.`),`VALID`):(e.log(e.Level.Warn,`The Scandit Data Capture library WASM file found at ${r} seems invalid: expected file hash doesn't match (received: ${a}, expected: ${n}). Please ensure the correct Scandit Data Capture file (with correct version) is retrieved.`),`INVALID`)}catch(t){return e.log(e.Level.Warn,`Wasm response could not be verified`,t),`NOT_VERIFIABLE`}}let p=new Map([[`br`,4.4],[`gzip`,2.9],[`none`,1]]);function m(e){let t=`content-encoding`;if(e==null||e.get(t)==null)return p.get(`none`);let n=new Set((e.get(t)??``).split(`,`).map(e=>e.trim()));for(let[e,t]of p)if(n.has(e))return t;return p.get(`none`)}function h(e){if(e==null)return 0;let t=m(e)??1,n=Number.parseInt(e.get(`content-length`)??`0`,10);return Number.isNaN(n)?0:Math.floor(n*t*100)/100}function g(e){let{pathname:t}=new URL(e);for(let[e,n]of Object.entries(c))if(t.endsWith(e))return n.bytes;return 0}function _(e){c=e}let v=(e,t)=>{let n=h(t);return n===0?g(e):n};function y(t,n,r,{onProgress:i,onError:a,onComplete:o}){if(!n.body)return[n];let s=v(t,n.headers),c=0,l=0;if(typeof TransformStream>`u`)return e.warn(`TransformStream is not supported in this environment. Progress tracking will be disabled.`),[n];let[u,d]=r?n.body.tee():[n.body],f=u.pipeThrough(new TransformStream({async transform(e,n){try{c+=e.length,l=Number((c/s*100).toFixed(2)),s>0&&e.length>0&&l<100?i?.({percentage:l,loadedBytes:c,privateUri:t}):s===0&&e.length>0&&i?.({percentage:null,loadedBytes:c,privateUri:t}),n.enqueue(e)}catch(e){n.error(e),a?.({error:e})}},flush(e){i?.({percentage:100,loadedBytes:c,privateUri:t}),o?.({percentage:100,loadedBytes:c,privateUri:t}),e.terminate()}}));return[new Response(f,{headers:new Headers(n.headers),status:n.status,statusText:n.statusText}),d]}async function b({wasmURI:e,expectedHash:t,verifyResponseHash:n,onProgress:r,onComplete:i,onError:a,referredOrigin:o}){let s=await fetch(e,{referrerPolicy:`origin`,referrer:o??``});if(!s.ok)throw Error(`HTTP status code is not ok: ${s.status}, ${s.statusText}`);let[c,l]=y(e,s,n,{onProgress:r,onError:a,onComplete:i});return l!=null&&f(d(l),t,e),c}function x({wasmURI:t,expectedHash:n,verifyResponseHash:r,progressCallback:i,successCallback:a,errorCallback:o,importObject:s,referredOrigin:c}){async function l(l){try{let e=await b({wasmURI:t,expectedHash:n,verifyResponseHash:r,onProgress:i,referredOrigin:c}),o=await(l??e).arrayBuffer(),u=await globalThis.WebAssembly.instantiate(o,s);a(u.instance,u.module)}catch(n){e.log(e.Level.Error,n),e.log(e.Level.Error,`Couldn't instantiate Scandit SDK DataCapture library at ${t}, did you configure the path for it correctly?`),o?.(n)}}async function u(){let o;try{o=await b({wasmURI:t,expectedHash:n,verifyResponseHash:r,onProgress:i,referredOrigin:c});let e=await globalThis.WebAssembly.instantiateStreaming(o,s);a(e.instance,e.module)}catch(t){e.log(e.Level.Warn,t),e.log(e.Level.Warn,`WebAssembly streaming compile failed. Falling back to ArrayBuffer instantiation (this will make things slower)`),l(o?.bodyUsed===!0?void 0:o)}}typeof globalThis.WebAssembly.instantiateStreaming==`function`?u():l()}async function S(e,t,n,r){return new Promise((i,a)=>{e().then(i).catch(o=>{let s=t*2;if(s>n){a(o);return}r(o),globalThis.setTimeout(()=>{S(e,s,n,r).then(i).catch(a)},t)})})}async function C(t,n){function r(t){try{return new URL(t,self.location.href).origin!==self.location.origin}catch(n){return e.log(e.Level.Warn,`Could not determine origin for WASM JS URL "${t}": ${n instanceof Error?n.message:String(n)}. Defaulting to same-origin path.`),!1}}function i(n){e.log(e.Level.Warn,n),e.log(e.Level.Warn,`Couldn't retrieve Scandit Data Capture library at ${t}, retrying...`)}try{if(r(t)){let e=await S(async()=>{let e=await fetch(t,{mode:`cors`,credentials:`omit`});if(!e.ok)throw Error(`Failed to load WASM JS script: ${t} (status ${e.status})`);let n=await e.blob();return/javascript|ecmascript/i.test(n.type)?n:new Blob([n],{type:`application/javascript`})},250,4e3,i),n=URL.createObjectURL(e);try{await importScripts(n)}finally{URL.revokeObjectURL(n)}self.Module.mainScriptUrlOrBlob=e}else await S(async()=>importScripts(t),250,4e3,i),self.Module.mainScriptUrlOrBlob=t;let a=globalThis.SDC_WASM_JS_VERSION;return a!==n&&e.log(e.Level.Warn,`The Scandit Data Capture library JS file found at ${t} seems invalid: expected version doesn't match (received: ${a}, expected: ${n}). Please ensure the correct Scandit Data Capture file (with correct version) is retrieved.`),!0}catch(t){return e.log(e.Level.Error,t),!1}}let w=e=>e.result!=null&&e.error==null;function T(e,t){return{type:`djinniResult`,payload:{id:e.id,className:e.className,methodName:e.methodName,instanceId:e.instanceId,result:t}}}function E(e,t){return{type:`parserLoaderResult`,payload:{id:e.id,className:e.className,methodName:e.methodName,result:t}}}new class{constructor(e,t){this.parsers=new Map,this.onMessageListener=this.onMessage.bind(this),this.setupPromise=null,this.workerSelf=e,this.moduleHandler=t,o(e)&&(this.workerFunctions={postMessage:this.workerSelf.postMessage.bind(this.workerSelf)},this.listenToMessages()),_({"scandit-datacapture-sdk-parser-pthreads.wasm":{bytes:7204067},"scandit-datacapture-sdk-parser-simd.wasm":{bytes:7175715},"scandit-datacapture-sdk-parser.wasm":{bytes:7230747},"scandit-datacapture-sdk-parser-simd-pthreads.wasm":{bytes:7162507}})}get Module(){return this.moduleHandler.get()}setLogLevel(t){e.setLevel(t.args[0]),this.workerFunctions.postMessage(E(t,{type:`result`,result:!0}))}async load(e){try{await this.setup(e.args[0]),this.workerFunctions.postMessage(E(e,{type:`result`,result:!0}))}catch(t){this.workerFunctions.postMessage(E(e,{type:`error`,error:t}))}}listenToMessages(){this.workerSelf.addEventListener(`message`,this.onMessageListener),this.workerSelf.addEventListener(`error`,t=>{e.log(e.Level.Error,t)}),this.workerSelf.addEventListener(`messageerror`,t=>{e.log(e.Level.Error,t)})}onMessage(e){return e.data.className===`ParserLoader`&&e.data.methodName===`load`&&this.load(e.data),e.data.className===`ParserLoader`&&e.data.methodName===`setLogLevel`&&this.setLogLevel(e.data),e.data.className===`ParserInterface`&&this.performDjinniAction(e.data),!0}async performDjinniAction(t){let n;if(e.log(e.Level.Debug,`${t.className}::${t.methodName}(`,t.args,`)`),t.methodName===`create`){let r=t.args[0].toString();if(this.parsers.has(r)){this.workerFunctions.postMessage(T(t,{type:`result`,result:r}));return}n=this.createParser(t),e.log(e.Level.Debug,n),this.workerFunctions.postMessage(n);return}let r=this.parsers.get(t.instanceId??``);if(r==null){this.workerFunctions.postMessage(T(t,{type:`error`,error:`parser is not defined: try to access instance with id ${t.instanceId??``}`}));return}let i=r[t.methodName](...t.args);n=w(i)?T(t,i):T(t,{type:`error`,error:i.error}),this.workerFunctions.postMessage(n)}async setup({libraryLocation:n,threadsSupport:r,simdSupport:o,verifyResponseHash:c,referredOrigin:l}){if(this.setupPromise!=null)return this.setupPromise;let{resolve:u,reject:d,promise:f}=new s;this.setupPromise=f;let p=a.sdkVersion();if(p===``)throw new t({name:`Invalid library version`,message:`Library version is not defined or empty, cannot generate proper path to library files.`});let{jsURI:m,wasmURI:h}=i(p,n,this.getWasmParserFileName(o,r));return this.moduleHandler.set({mainScriptUrlOrBlob:m,locateFile:e=>n+e,onMainComplete:()=>{},onRuntimeInitialized:()=>{u()},print:t=>{e.log(e.Level.Info,t)},instantiateWasm:(e,t)=>(x({importObject:e,wasmURI:h,expectedHash:this.getWasmParserExpectedHash(o,r),verifyResponseHash:c,successCallback:t,progressCallback:()=>{},referredOrigin:l}),{})}),await C(m,p)||d(`Couldn't retrieve Parser library at ${m}, did you configure the path for it correctly?`),f}createParser(t){let n=this.Module.ParserInterface.create(t.args[0]);if(e.log(e.Level.Debug,`Parser:create returns ${n.type}`,n),n.type===`error`)return T(t,n);let r=t.args[0]?.toString()??``,i=T(t,{type:`result`,result:r});return this.parsers.set(r,n.result),i}getWasmParserExpectedHash(e,t){return t?e?`824c2b12f6377c7bd250ad4e2eaac8021792d7d3b61ce0ba4a692144d46263c9`:`1be78d1343e09afa19d4cac54347d81d529d0207c19037b491cd27d04bb78aaa`:e?`edae43f1437a26f72008ba312288a135549ca52bb2c18539152c85aa79da6ddb`:`bfa14a62e722453a06029c25795f64948042d0ba7f555ceada0a7186d378c2fe`}getWasmParserFileName(e,t){return t?e?`scandit-datacapture-sdk-parser-simd-pthreads.wasm`:`scandit-datacapture-sdk-parser-pthreads.wasm`:e?`scandit-datacapture-sdk-parser-simd.wasm`:`scandit-datacapture-sdk-parser.wasm`}}(globalThis,{get:()=>globalThis.Module,set:e=>{globalThis.Module=e}})})();
|