{ "version": 3, "sources": ["libs/proman/src/lib/services/barcode-scanner.service.ts", "apps/frontend/src/app/qr/services/zpl-entity-codes.service.ts", "apps/frontend/src/app/qr/services/qr-code-url.service.ts"], "sourcesContent": ["import { Injectable } from '@angular/core';\nimport { isTouchDevice } from '@proman/utils';\n\n// allowedKeyCodes = return, 0-9, = /?\nconst ALLOWED_BARCODE_KEYCODES = [13, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57];\n// ignoredKeyCodes = /? ; Shift Caps\nconst IGNORED_BARCODE_KEYCODES = [187, 191, 186, 16, 20];\n\ndeclare type ReaderServiceCallback = (data: KeyboardEvent) => boolean;\n\ndeclare interface ReaderServiceCallbackTypeMap {\n isBarcode: boolean, callback: ReaderServiceCallback;\n}\n\nexport const keycodes = {\n backspace: 8,\n tab: 9,\n enter: 13,\n shift: 16,\n ctrl: 17,\n alt: 18,\n pause_break: 19,\n caps_lock: 20,\n escape: 27,\n space: 32,\n page_up: 33,\n page_down: 34,\n end: 35,\n home: 36,\n left_arrow: 37,\n up_arrow: 38,\n right_arrow: 39,\n down_arrow: 40,\n insert: 45,\n delete: 46,\n f1: 112,\n f2: 113,\n f3: 114,\n f4: 115,\n f5: 116,\n f6: 117,\n f7: 118,\n f8: 119,\n f9: 120,\n f10: 121,\n f11: 122,\n f12: 123,\n num_lock: 144,\n scroll_lock: 145\n};\n\n\n@Injectable({ providedIn: 'root' })\nexport class BarcodeScannerService {\n isTouch: boolean = isTouchDevice();\n constructor() { }\n callbacks: ReaderServiceCallbackTypeMap[] = [];\n\n listen = (handler: any, isBarcode = false) => {\n const buffer: any = [];\n const threshold: any = this.isTouch ? 120 : 60; // ms\n let timer: any = null;\n\n function notify() {\n const input = buffer.join('').trim();\n\n clearTimeout(timer);\n buffer.length = 0;\n handler(input);\n }\n\n const callback = (event: KeyboardEvent) => {\n if (timer) clearTimeout(timer);\n\n timer = setTimeout(notify, threshold);\n\n if (event.charCode == keycodes.enter) {\n event.stopImmediatePropagation();\n\n return false;\n }\n\n if (isBarcode) {\n if (IGNORED_BARCODE_KEYCODES.indexOf(event.keyCode) >= 0) {\n return;\n }\n\n if (ALLOWED_BARCODE_KEYCODES.indexOf(event.keyCode) >= 0) {\n buffer.push(String.fromCharCode(event.keyCode));\n } else {\n buffer.length = 0;\n }\n } else {\n buffer.push(String.fromCharCode(event.charCode));\n }\n\n };\n\n if (this.callbacks.length) {\n const lastCallback = this.callbacks[this.callbacks.length - 1].callback;\n document.body.removeEventListener('keypress', lastCallback);\n\n }\n\n this.callbacks.push({ callback, isBarcode });\n\n document.body.addEventListener('keypress', callback);\n\n };\n\n destroy() {\n const lastCallbackItem = this.callbacks.pop();\n\n document.body.removeEventListener('keypress', lastCallbackItem.callback);\n\n if (this.callbacks.length) {\n const lastCallback = this.callbacks[this.callbacks.length - 1];\n console.log(' next callback', lastCallback);\n document.body.addEventListener('keypress', lastCallback.callback);\n\n }\n }\n\n}\n", "import { Injectable } from '@angular/core';\n\nconst map = {\n pc: 'ProductContainer',\n sc: 'ShipmentContainer'\n};\n\n@Injectable()\nexport class ZplEntityCodesService {\n constructor() {}\n\n getCode(name: string) {\n for (let code in map) {\n if (map[code] === name) {\n return code;\n\n }\n\n }\n\n throw new Error('Unkown QR Entity ' + name);\n };\n\n getName(code: string) {\n\n if (!map[code]) {\n throw Error('Unknown QR Entity code ' + code);\n\n }\n\n return map[code];\n };\n\n}\n", "import { Injectable } from '@angular/core';\nimport { ZplEntityCodesService } from './zpl-entity-codes.service';\n\n@Injectable()\nexport class QrCodeUrlService {\n hostUrl: string;\n qrCodeUrl: string;\n\n constructor(private zpl: ZplEntityCodesService) {\n\n this.qrCodeUrl = 'http://' + window.location.hostname + '/qr/';\n }\n\n encode(entityName: string, id: number) {\n return this.qrCodeUrl + this.zpl.getCode(entityName) + '/' + id;\n }\n\n decode(url: any): any {\n let match = /\\/([a-z]{2})\\/(\\d+)$/.exec(url.toLowerCase());\n let reg = /^[0-9]{5,}$/.exec(url.toLowerCase());\n let classCode;\n let id;\n\n if (match) {\n classCode = match[1];\n id = parseInt(match[2]);\n\n return {\n Entity: this.zpl.getName(classCode),\n id\n };\n\n } else if (reg) {\n return {\n Entity: 'Barcode',\n barcode: parseInt(url)\n };\n }\n }\n\n}\n"], "mappings": "uDAIA,IAAMA,EAA2B,CAAC,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,EAAE,EAEtEC,EAA2B,CAAC,IAAK,IAAK,IAAK,GAAI,EAAE,EAQ1CC,EAAW,CACpBC,UAAW,EACXC,IAAK,EACLC,MAAO,GACPC,MAAO,GACPC,KAAM,GACNC,IAAK,GACLC,YAAa,GACbC,UAAW,GACXC,OAAQ,GACRC,MAAO,GACPC,QAAS,GACTC,UAAW,GACXC,IAAK,GACLC,KAAM,GACNC,WAAY,GACZC,SAAU,GACVC,YAAa,GACbC,WAAY,GACZC,OAAQ,GACRC,OAAQ,GACRC,GAAI,IACJC,GAAI,IACJC,GAAI,IACJC,GAAI,IACJC,GAAI,IACJC,GAAI,IACJC,GAAI,IACJC,GAAI,IACJC,GAAI,IACJC,IAAK,IACLC,IAAK,IACLC,IAAK,IACLC,SAAU,IACVC,YAAa,KAKJC,GAAqB,IAAA,CAA5B,MAAOA,CAAqB,CAE9BC,aAAA,CADA,KAAAC,QAAmBC,EAAa,EAEhC,KAAAC,UAA4C,CAAA,EAE5C,KAAAC,OAAS,CAACC,EAAcC,EAAY,KAAS,CACzC,IAAMC,EAAc,CAAA,EACdC,EAAiB,KAAKP,QAAU,IAAM,GACxCQ,EAAa,KAEjB,SAASC,GAAM,CACX,IAAMC,EAAQJ,EAAOK,KAAK,EAAE,EAAEC,KAAI,EAElCC,aAAaL,CAAK,EAClBF,EAAOQ,OAAS,EAChBV,EAAQM,CAAK,CACjB,CAEA,IAAMK,EAAYC,GAAwB,CAKtC,GAJIR,GAAOK,aAAaL,CAAK,EAE7BA,EAAQS,WAAWR,EAAQF,CAAS,EAEhCS,EAAME,UAAYvD,EAASG,M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,CAC9C,CAEAG,QAAQF,EAAY,CAEhB,GAAI,CAACP,EAAIO,CAAI,EACT,MAAMC,MAAM,0BAA4BD,CAAI,EAIhD,OAAOP,EAAIO,CAAI,CACnB,iDAvBSJ,EAAqB,CAAA,iCAArBA,EAAqBO,QAArBP,EAAqBQ,SAAA,CAAA,CAAA,SAArBR,CAAqB,GAAA,ECJlC,IAAaS,GAAgB,IAAA,CAAvB,MAAOA,CAAgB,CAIzBC,YAAoBC,EAA0B,CAA1B,KAAAA,IAAAA,EAEhB,KAAKC,UAAY,UAAYC,OAAOC,SAASC,SAAW,MAC5D,CAEAC,OAAOC,EAAoBC,EAAU,CACjC,OAAO,KAAKN,UAAY,KAAKD,IAAIQ,QAAQF,CAAU,EAAI,IAAMC,CACjE,CAEAE,OAAOC,EAAQ,CACX,IAAIC,EAAQ,uBAAuBC,KAAKF,EAAIG,YAAW,CAAE,EACrDC,EAAM,cAAcF,KAAKF,EAAIG,YAAW,CAAE,EAC1CE,EACAR,EAEJ,GAAII,EACAI,OAAAA,EAAYJ,EAAM,CAAC,EACnBJ,EAAKS,SAASL,EAAM,CAAC,CAAC,EAEf,CACHM,OAAQ,KAAKjB,IAAIkB,QAAQH,CAAS,EAClCR,GAAAA,GAGD,GAAIO,EACP,MAAO,CACHG,OAAQ,UACRE,QAASH,SAASN,CAAG,EAGjC,iDAlCSZ,GAAgBsB,EAAAC,CAAA,CAAA,CAAA,CAAA,iCAAhBvB,EAAgBwB,QAAhBxB,EAAgByB,SAAA,CAAA,CAAA,SAAhBzB,CAAgB,GAAA", "names": ["ALLOWED_BARCODE_KEYCODES", "IGNORED_BARCODE_KEYCODES", "keycodes", "backspace", "tab", "enter", "shift", "ctrl", "alt", "pause_break", "caps_lock", "escape", "space", "page_up", "page_down", "end", "home", "left_arrow", "up_arrow", "right_arrow", "down_arrow", "insert", "delete", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "f10", "f11", "f12", "num_lock", "scroll_lock", "BarcodeScannerService", "constructor", "isTouch", "isTouchDevice", "callbacks", "listen", "handler", "isBarcode", "buffer", "threshold", "timer", "notify", "input", "join", "trim", "clearTimeout", "length", "callback", "event", "setTimeout", "charCode", "stopImmediatePropagation", "indexOf", "keyCode", "push", "String", "fromCharCode", "lastCallback", "document", "body", "removeEventListener", "addEventListener", "destroy", "lastCallbackItem", "pop", "console", "log", "factory", "\u0275fac", "providedIn", "map", "pc", "sc", "ZplEntityCodesService", "constructor", "getCode", "name", "code", "Error", "getName", "factory", "\u0275fac", "QrCodeUrlService", "constructor", "zpl", "qrCodeUrl", "window", "location", "hostname", "encode", "entityName", "id", "getCode", "decode", "url", "match", "exec", "toLowerCase", "reg", "classCode", "parseInt", "Entity", "getName", "barcode", "\u0275\u0275inject", "ZplEntityCodesService", "factory", "\u0275fac"] }