UNPKG

@scandit/web-datacapture-barcode

Version:

Scandit Data Capture SDK for the Web

1 lines • 3.88 kB
var e=class{constructor(e,t,n){this.captureListenerSet=!1,this.areGlowListener=null,this.areSyncStateListener=null,this.areBarcodeCaptureMode=null,this.coreEngine=e,this.Module=t,this.workerFunctions=n,this.setup()}barcodeCaptureDidUpdateSession(e){this.workerFunctions.postMessage({type:`barcodeCaptureDidUpdateSession`,payload:JSON.parse(e.toJson())})}barcodeBatchDidUpdateSession(e){this.workerFunctions.postMessage({type:`barcodeBatchDidUpdateSession`,payload:JSON.parse(e.toJson())})}getCaptureDeserializer(){return this.barcodeCaptureDeserializer}getTrackingDeserializer(){return this.barcodeBatchDeserializer}setup(){let e=this.Module.BarcodeCaptureListener.extend(`BarcodeCaptureListener`,{didScan:(e,t,n)=>{this.barcodeCaptureDidScan(t,n),e.delete(),n.delete(),t.delete()},didUpdateSession:(e,t,n)=>{this.barcodeCaptureDidUpdateSession(t),e.delete(),n.delete(),t.delete()}}),t=this.Module.Feedback.extend(`Feedback`,{emit:()=>{this.successFeedback()}}),n=this.Module.AreServiceListener.extend(`AreServiceListener`,{onAreServiceDispatchStarted:(e,t,n)=>{this.barcodeCaptureAreServiceDispatchStarted(e,t,n),e.delete()},onAreServiceResponse:(e,t,n)=>{this.barcodeCaptureAreServiceResponse(e,t,n)},onAreServiceError:(e,t,n)=>{this.barcodeCaptureAreServiceError(e,t,n)}}),r=new e,i=new t,a=new n,o=this.Module.BarcodeCaptureDeserializerListener.extend(`BarcodeCaptureDeserializerListener`,{onModeDeserializationFinished:(e,t,n)=>{t.addListener(r,1),t.setSuccessFeedback(i),t.addAreServiceListener(a);let o=this.setupAreListeners(t);e.delete(),o||t.delete(),n.delete()},onModeDeserializationStarted(e,t,n){e.delete(),t.delete(),n.delete()},onSettingsDeserializationStarted(e,t,n){e.delete(),t.delete(),n.delete()},onSettingsDeserializationFinished(e,t,n){e.delete(),t.delete(),n.delete()}});this.barcodeCaptureDeserializer=new this.Module.BarcodeCaptureDeserializer,this.barcodeCaptureDeserializer.setListener(new o)}successFeedback(){this.workerFunctions.postMessage({type:`successFeedback`})}setupAreListeners(e){var t;return((t=this.areBarcodeCaptureMode)==null?void 0:t.isAliasOf(e))===!0?!1:(this.releaseAreMode(),this.areGlowListener??=new(this.Module.AreGlowListener.extend(`AreGlowListener`,{onGlowActiveChanged:e=>{this.workerFunctions.postMessage({type:`barcodeCaptureAreGlowActiveChanged`,payload:{active:e}})}})),this.areSyncStateListener??=new(this.Module.AreSyncStateListener.extend(`AreSyncStateListener`,{onAreSyncStateChanged:()=>{this.postAreSyncState()}})),this.areBarcodeCaptureMode=e,e.addAreGlowListener(this.areGlowListener),e.setAreSyncStateListener(this.areSyncStateListener),this.postAreSyncState(),!0)}releaseAreGlowBridge(){this.releaseAreMode()}releaseAreMode(){let e=this.areBarcodeCaptureMode;e&&(this.areBarcodeCaptureMode=null,this.areGlowListener&&e.removeAreGlowListener(this.areGlowListener),e.setAreSyncStateListener(null),e.delete())}postAreSyncState(){var e;let t=((e=this.areBarcodeCaptureMode)==null?void 0:e.hasSyncAreComponent())??!1;this.workerFunctions.postMessage({type:`barcodeCaptureAreSyncStateChanged`,payload:{hasSyncComponent:t}})}barcodeCaptureDidScan(e,t){let n=this.coreEngine.prepareFrameForListener(t);this.workerFunctions.postMessage({type:`barcodeCaptureDidScan`,payload:{session:JSON.parse(e.toJson()),frameData:n}})}barcodeCaptureAreServiceDispatchStarted(e,t,n){let r=this.coreEngine.prepareFrameForListener(e);this.workerFunctions.postMessage({type:`barcodeCaptureAreServiceDispatchStarted`,payload:{frameData:r,frameId:t,barcodes:JSON.parse(n)}})}barcodeCaptureAreServiceResponse(e,t,n){this.workerFunctions.postMessage({type:`barcodeCaptureAreServiceResponse`,payload:{response:e,frameId:t,barcodes:JSON.parse(n)}})}barcodeCaptureAreServiceError(e,t,n){this.workerFunctions.postMessage({type:`barcodeCaptureAreServiceError`,payload:{reason:e,frameId:t,barcodes:JSON.parse(n)}})}};export{e as BarcodeCaptureMode};