@scandit/web-datacapture-barcode
Version:
Scandit Data Capture SDK for the Web
1 lines • 1.82 kB
JavaScript
import{defaultBarcodeBatch as e}from"./defaults/DefaultsBarcodeBatch.js";import{PrivateBarcodeBatchBasicOverlayListener as t}from"./PrivateBarcodeBatchBasicOverlayListener.js";let n=function(e){return e.Frame=`frame`,e.Dot=`dot`,e}({});var r=class n{constructor(){this.type=`barcodeTrackingBasic`,this._style=e.BarcodeBatchBasicOverlay.defaultStyle,this._shouldShowScanAreaGuides=!1,this._brushesForBarcodes=new Map}get style(){return this._style}get listener(){return this._listener}set listener(e){this._listener=e}get brush(){return this._brush}static async withBarcodeBatch(e){return n.withBarcodeBatchForView(e,null)}static async withBarcodeBatchForView(t,r){return n.withBarcodeBatchForViewWithStyle(t,r,e.BarcodeBatchBasicOverlay.defaultStyle)}static async withBarcodeBatchForViewWithStyle(r,i,a){let o=new n;return o.barcodeBatch=r,o._style=a,o._brush=e.BarcodeBatchBasicOverlay.styles[o.style].DefaultBrush.clone(),i&&await i.addOverlay(o),o.privateListener=new t(o),r.addPrivateListener(o.privateListener),o}async setBrush(e){this._brush=e,await this.barcodeBatch.notifyContext()}shouldShowScanAreaGuides(){return this._shouldShowScanAreaGuides}async setShouldShowScanAreaGuides(e){this._shouldShowScanAreaGuides=e,await this.barcodeBatch.notifyContext()}async setBrushForTrackedBarcode(e,t){this._brushesForBarcodes.set(t.identifier,e),await this.barcodeBatch.notifyContext()}async clearTrackedBarcodeBrushes(){this._brushesForBarcodes.clear(),await this.barcodeBatch.notifyContext()}toJSONObject(){return{type:this.type,brush:this._brush.toJSONObject(),shouldShowScanAreaGuides:this._shouldShowScanAreaGuides,style:this._style,brushesForBarcodes:[...this._brushesForBarcodes.entries()].reduce((e,[t,n])=>(e[t]=n.toJSONObject(),e),{})}}};export{r as BarcodeBatchBasicOverlay,n as BarcodeBatchBasicOverlayStyle};