UNPKG

@scandit/web-datacapture-barcode

Version:

Scandit Data Capture SDK for the Web

1 lines 1.75 kB
import{defaultSparkScan as e}from"../../defaults/DefaultsSparkScan.js";import{sparkScanErrorSound as t,sparkScanSuccessSound as n}from"../sounds.js";import{Feedback as r,Vibration as i}from"@scandit/web-datacapture-core";const a=i.withPattern([40]);var o=class o{constructor(o,s){this.soundEnabled=!0,this.hapticEnabled=!0,this.tapVibration=this.hapticEnabled?a:null,this.tapFeedback=new r(this.tapVibration,null),this.successSound=this.soundEnabled?n:null,this.successVibration=this.hapticEnabled?a:null,this.successFeedback=new r(this.successVibration,this.successSound),this.errorSound=this.soundEnabled?t:null,this.noFeedback=new r(null,null),this.errorVibration=this.hapticEnabled?i.withPattern(e.SparkScanFeedback.errorVibrationPattern):null,this.errorFeedback=new r(this.errorVibration,this.errorSound),this.soundEnabled=o,this.hapticEnabled=s}static withDefaults(e,t){return new o(e,t)}setSoundEnabled(e){this.soundEnabled=e,this.successSound=e?n:null,this.successFeedback=new r(this.successVibration,this.successSound),this.errorSound=e?t:null,this.errorFeedback=new r(this.errorVibration,this.errorSound)}setHapticEnabled(t){this.hapticEnabled=t,this.tapVibration=t?a:null,this.tapFeedback=new r(this.tapVibration,null),this.successVibration=t?i.defaultVibration:null,this.successFeedback=new r(this.successVibration,this.successSound),this.errorVibration=t?i.withPattern(e.SparkScanFeedback.errorVibrationPattern):null,this.errorFeedback=new r(this.errorVibration,this.errorSound)}emitTapFeedback(){this.tapFeedback.emit()}emitBarcodeFeedback(e){new r(this.hapticEnabled?(e==null?void 0:e.feedback.vibration)??null:null,this.soundEnabled?(e==null?void 0:e.feedback.sound)??null:null).emit()}};export{o as SparkScanViewFeedbackManager};