@shopgate/pwa-core 7.12.7-beta.1 → 7.20.0-beta.10

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.
Files changed (43) hide show
  1. package/classes/AppCommand/index.js +3 -3
  2. package/classes/AppCommand/spec.js +1 -1
  3. package/classes/AppCommandRequest/index.js +78 -0
  4. package/classes/AppPermissionsRequest/AppPermissionsRequest.js +12 -39
  5. package/classes/AppPermissionsRequest/GetAppPermissionsRequest.js +5 -5
  6. package/classes/AppPermissionsRequest/RequestAppPermissionsRequest.js +5 -5
  7. package/classes/Bridge/index.js +1 -1
  8. package/classes/BrightnessRequest/index.js +4 -4
  9. package/classes/BrightnessRequest/spec.js +3 -3
  10. package/classes/BrowserConnector/index.js +19 -19
  11. package/classes/Conditioner/index.js +4 -4
  12. package/classes/Conditioner/spec.js +1 -1
  13. package/classes/DataRequest/index.js +7 -7
  14. package/classes/DevServerBridge/index.js +2 -2
  15. package/classes/ErrorManager/index.js +14 -5
  16. package/classes/ErrorManager/spec.js +1 -1
  17. package/classes/Event/index.js +12 -9
  18. package/classes/HttpRequest/index.js +9 -9
  19. package/classes/PipelineDependencies/index.js +2 -2
  20. package/classes/PipelineManager/index.js +9 -9
  21. package/classes/PipelineRequest/index.js +5 -5
  22. package/classes/PipelineRequest/mock.js +11 -11
  23. package/classes/PipelineSequence/index.js +2 -2
  24. package/classes/Request/index.js +8 -8
  25. package/classes/RequestBuffer/index.js +4 -3
  26. package/classes/RequestManager/index.js +2 -2
  27. package/classes/RequestManager/spec.js +1 -1
  28. package/classes/Scanner/index.js +61 -11
  29. package/classes/ScannerEvent/index.js +8 -4
  30. package/classes/ScannerEventHandler/index.js +15 -5
  31. package/classes/ScannerEventListener/index.js +14 -5
  32. package/classes/ScannerManager/ScanProcessingError.js +3 -3
  33. package/classes/ScannerManager/index.js +6 -6
  34. package/classes/WebStorageRequest/index.js +7 -7
  35. package/commands/brightness.js +1 -1
  36. package/commands/scanner.js +2 -2
  37. package/constants/AppEvents.js +1 -1
  38. package/constants/AppPermissions.js +18 -4
  39. package/constants/Trilean.js +3 -0
  40. package/helpers/index.js +1 -1
  41. package/helpers/version.js +7 -7
  42. package/index.js +1 -1
  43. package/package.json +1 -1
@@ -1,19 +1,69 @@
1
- import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import{logger}from"../../helpers";import{isLibVersionAtLeast}from"../../helpers/version";import ScannerEvent from"../ScannerEvent";import ScannerEventHandler from"../ScannerEventHandler";import appEvent from"../Event";import registerEvents from"../../commands/registerEvents";import{APP_EVENT_SCANNER_DID_SCAN}from"../../constants/AppEvents";import{SCANNER_MODE_ON,SCANNER_TYPE_BARCODE,SCANNER_TYPE_IMAGE,SCANNER_ANIMATION_NONE,SCANNER_MIN_APP_LIB_VERSION}from"../../constants/Scanner";import{openScanner as openAppScanner,startScanner as startAppScanner,stopScanner as stopAppScanner,closeScanner as closeAppScanner,setFlashlightMode as setAppScannerFlashlightMode}from"../../commands/scanner";/**
1
+ import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import{logger}from"../../helpers";import{isLibVersionAtLeast}from"../../helpers/version";import ScannerEvent from"../ScannerEvent";import ScannerEventHandler from"../ScannerEventHandler";import appEvent from"../Event";import registerEvents from"../../commands/registerEvents";import{APP_EVENT_SCANNER_DID_SCAN}from"../../constants/AppEvents";import{SCANNER_MODE_ON,SCANNER_TYPE_BARCODE,SCANNER_TYPE_IMAGE,SCANNER_ANIMATION_NONE,SCANNER_MIN_APP_LIB_VERSION}from"../../constants/Scanner";import{openScanner as openAppScanner,startScanner as startAppScanner,stopScanner as stopAppScanner,closeScanner as closeAppScanner,setFlashlightMode as setAppScannerFlashlightMode}from"../../commands/scanner";/**
2
2
  * Represents the app scanner.
3
- */export var Scanner=/**
3
+ */export var Scanner=/*#__PURE__*/_createClass(/**
4
4
  * Initializes the scanner
5
- */function Scanner(){var _this=this;_classCallCheck(this,Scanner);_defineProperty(this,"reset",function(){_this.scope=null;_this.type=null;_this.opened=false;_this.running=false;_this.handling=false;_this.flashlightEnabled=false;_this.closeHandler=null;});_defineProperty(this,"addListener",function(eventListener){_this.eventHandler.attach(eventListener);});_defineProperty(this,"removeListener",function(eventListener){return _this.eventHandler.detach(eventListener);});_defineProperty(this,"open",/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(scope){var type,closeHandler,source,animation,errMsgPrefix,libVersionResult,err,_err,_err2,_err3,_err4,_args=arguments;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:type=_args.length>1&&_args[1]!==undefined?_args[1]:SCANNER_TYPE_BARCODE;closeHandler=_args.length>2&&_args[2]!==undefined?_args[2]:null;source=_args.length>3&&_args[3]!==undefined?_args[3]:null;animation=_args.length>4&&_args[4]!==undefined?_args[4]:null;errMsgPrefix='Failed to open scanner:';// A minimum app lib version is required, which is defined above.
5
+ */function Scanner(){var _this=this;_classCallCheck(this,Scanner);/**
6
+ * Reset Scanner state
7
+ */_defineProperty(this,"reset",function(){_this.scope=null;_this.type=null;_this.opened=false;_this.running=false;_this.handling=false;_this.flashlightEnabled=false;_this.closeHandler=null;});/**
8
+ * Adds an event listener to the scanner.
9
+ * @param {ScannerEventListener} eventListener The eventListener to add.
10
+ */_defineProperty(this,"addListener",function(eventListener){_this.eventHandler.attach(eventListener);});/**
11
+ * @param {ScannerEventListener} eventListener The event listener to remove.
12
+ * @returns {boolean} Returns false if the listener was not found by id. Returns true otherwise.
13
+ */_defineProperty(this,"removeListener",function(eventListener){return _this.eventHandler.detach(eventListener);});/**
14
+ * Callback for the close handler for the scanner. The scanner stops scanning and notifies
15
+ * the close handler when it's done. The close handler can either shut down the Scanner instance
16
+ * by calling its close() method or restart it to continue scanning.
17
+ *
18
+ * @callback Scanner~CloseHandler
19
+ * @param {Scanner} scannerInstance The instance of the scanner which requested closing.
20
+ * @returns {undefined|null} The return value is ignored.
21
+ */ /**
22
+ * Starts the app scanner. It will instantly start the scanning process for type
23
+ * "barcodeRecognition". The image scanner requires user interaction to scan.
24
+ * @param {string} scope The initially activated scanner scope.
25
+ * @param {ScannerType|string} type The initially activated scanner type.
26
+ * @param {CloseHandler|null} [closeHandler] This handler is called when the Scanner is closed.
27
+ * @param {string|null} [source] Tells the app which overlay to use, null for "current".
28
+ * @param {string|null} [animation] Tells the app what type of animation to apply when opening.
29
+ */_defineProperty(this,"open",/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(scope){var type,closeHandler,source,animation,errMsgPrefix,libVersionResult,err,_err,_err2,_err3,_err4,_args=arguments;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:type=_args.length>1&&_args[1]!==undefined?_args[1]:SCANNER_TYPE_BARCODE;closeHandler=_args.length>2&&_args[2]!==undefined?_args[2]:null;source=_args.length>3&&_args[3]!==undefined?_args[3]:null;animation=_args.length>4&&_args[4]!==undefined?_args[4]:null;errMsgPrefix='Failed to open scanner:';// A minimum app lib version is required, which is defined above.
6
30
  _context.prev=5;_context.next=8;return isLibVersionAtLeast(SCANNER_MIN_APP_LIB_VERSION);case 8:libVersionResult=_context.sent;_context.next=15;break;case 11:_context.prev=11;_context.t0=_context["catch"](5);logger.error("".concat(errMsgPrefix," Could not fetch app lib version. Instead received error:"),_context.t0);return _context.abrupt("return");case 15:if(libVersionResult){_context.next=19;break;}err=new Error("".concat(errMsgPrefix," App lib version must be at least equal to or higher than ").concat(SCANNER_MIN_APP_LIB_VERSION,"."));logger.error(err);return _context.abrupt("return");case 19:if(!(!scope||scope==='')){_context.next=23;break;}_err=new Error("".concat(errMsgPrefix," Scope can not be empty."));logger.error(_err);return _context.abrupt("return");case 23:if(_this.supportedTypes.includes(type)){_context.next=27;break;}_err2=new Error("".concat(errMsgPrefix," ").concat(type," is a not supported scanner type."));logger.error(_err2);return _context.abrupt("return");case 27:if(!_this.opened){_context.next=31;break;}_err3=new Error("".concat(errMsgPrefix," An instance with scope \"").concat(_this.scope,"\" is already running."));logger.error(_err3);return _context.abrupt("return");case 31:if(!(closeHandler!==null&&typeof closeHandler!=='function')){_context.next=35;break;}_err4=new Error("".concat(errMsgPrefix," Close handler must be a function."));logger.error(_err4);return _context.abrupt("return");case 35:// Add a listener to the scannerDidScan app event to process scanned data.
7
31
  appEvent.addCallback(APP_EVENT_SCANNER_DID_SCAN,_this.handleScan);// Open the app scanner.
8
32
  openAppScanner({src:source||'',modes:_defineProperty({},type,SCANNER_MODE_ON),animation:animation||SCANNER_ANIMATION_NONE});// Initialize internal states
9
33
  _this.scope=scope;_this.type=type;_this.opened=true;// Image scanner does not automatically scan
10
- _this.running=_this.type!==SCANNER_TYPE_IMAGE;_this.closeHandler=closeHandler||null;case 42:case"end":return _context.stop();}}},_callee,null,[[5,11]]);}));return function(_x){return _ref.apply(this,arguments);};}());_defineProperty(this,"start",function(){if(!_this.opened){logger.error(new Error("Can't start Scanner: Scanner is not opened."));return;}_this.handling=false;// Start only if not already running.
11
- if(!_this.running){_this.running=true;startAppScanner();}});_defineProperty(this,"stop",function(){if(!_this.opened){logger.error(new Error("Can't start Scanner: Scanner is not opened."));return;}// Stop only if is running at the moment.
12
- if(_this.isRunning){_this.running=false;stopAppScanner();}});_defineProperty(this,"close",function(){if(!_this.opened){logger.warn("Can't close Scanner: Scanner is not opened.");return;}// Remove the listener to avoid further scan results.
34
+ _this.running=_this.type!==SCANNER_TYPE_IMAGE;_this.closeHandler=closeHandler||null;case 42:case"end":return _context.stop();}},_callee,null,[[5,11]]);}));return function(_x){return _ref.apply(this,arguments);};}());/**
35
+ * Starts the Scanner if it is opened and not already running.
36
+ */_defineProperty(this,"start",function(){if(!_this.opened){logger.error(new Error("Can't start Scanner: Scanner is not opened."));return;}_this.handling=false;// Start only if not already running.
37
+ if(!_this.running){_this.running=true;startAppScanner();}});/**
38
+ * Stops the scanner if it is opened and running.
39
+ */_defineProperty(this,"stop",function(){if(!_this.opened){logger.error(new Error("Can't start Scanner: Scanner is not opened."));return;}// Stop only if is running at the moment.
40
+ if(_this.isRunning){_this.running=false;stopAppScanner();}});/**
41
+ * Close the app scanner.
42
+ */_defineProperty(this,"close",function(){if(!_this.opened){logger.warn("Can't close Scanner: Scanner is not opened.");return;}// Remove the listener to avoid further scan results.
13
43
  appEvent.removeCallback(APP_EVENT_SCANNER_DID_SCAN,_this.handleScan);// Switch off flashlight to make sure it does not stay enabled.
14
- _this.toggleFlashlight(false);closeAppScanner();_this.reset();});_defineProperty(this,"toggleFlashlight",function(){var enable=arguments.length>0&&arguments[0]!==undefined?arguments[0]:undefined;if(!_this.opened){logger.error(new Error("Can't toggle the flashlight: Scanner not opened!"));return false;}if(enable!==undefined){_this.flashlightEnabled=!!enable;}else{_this.flashlightEnabled=!_this.flashlightEnabled;}setAppScannerFlashlightMode(_this.flashlightEnabled);return _this.flashlightEnabled;});_defineProperty(this,"isOpened",function(){return _this.opened;});_defineProperty(this,"isRunning",function(){return _this.running;});_defineProperty(this,"isFlashlightEnabled",function(){return _this.flashlightEnabled;});_defineProperty(this,"handleScan",/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(payload){var event;return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1){switch(_context2.prev=_context2.next){case 0:event=new ScannerEvent(_this.scope,_this.type,payload);if(_this.eventHandler.hasListenersForEvent(event)){_context2.next=4;break;}logger.warn('No scanner listeners',payload);return _context2.abrupt("return");case 4:if(!_this.handling){_context2.next=7;break;}logger.warn('Scan result ignored in handling stage',payload);return _context2.abrupt("return");case 7:_this.handling=true;_this.stop();_context2.prev=9;_context2.next=12;return _this.eventHandler.notifyAllListeners(event);case 12:// Notify the close handler that the Scanner is done doing his work.
44
+ _this.toggleFlashlight(false);closeAppScanner();_this.reset();});/**
45
+ * Switches between the flashlight being on or off. The return result might not always
46
+ * be reliable when the app is brought into the background or if other apps interfere.
47
+ * Can only be toggled when the scanner is opened.
48
+ * @param {boolean|undefined} [enable] True/false to switch on/off or leave out for toggle.
49
+ * @returns {boolean} Returns the new flashlight on/off state.
50
+ */_defineProperty(this,"toggleFlashlight",function(){var enable=arguments.length>0&&arguments[0]!==undefined?arguments[0]:undefined;if(!_this.opened){logger.error(new Error("Can't toggle the flashlight: Scanner not opened!"));return false;}if(enable!==undefined){_this.flashlightEnabled=!!enable;}else{_this.flashlightEnabled=!_this.flashlightEnabled;}setAppScannerFlashlightMode(_this.flashlightEnabled);return _this.flashlightEnabled;});/**
51
+ * Because opening the scanner can fail silently, this is a way to check if it was
52
+ * opened properly.
53
+ * @returns {boolean}
54
+ */_defineProperty(this,"isOpened",function(){return _this.opened;});/**
55
+ * Some scanner types don't start and all of them stop running after a successful scan.
56
+ * This method allows checking if a scan is currently in progress.
57
+ * @returns {boolean}
58
+ */_defineProperty(this,"isRunning",function(){return _this.running;});/**
59
+ * Helps checking the current state of the flashlight. This might not be reliable as the
60
+ * flashlight is turned off without notice, when the app is pushed into the background.
61
+ * @returns {boolean}
62
+ */_defineProperty(this,"isFlashlightEnabled",function(){return _this.flashlightEnabled;});/**
63
+ * The internal handler for the "scannerDidScan" app event.
64
+ * @private
65
+ * @param {ScannerEventPayload} payload The payload of the scanner event for the scanned result.
66
+ */_defineProperty(this,"handleScan",/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(payload){var event;return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:event=new ScannerEvent(_this.scope,_this.type,payload);if(_this.eventHandler.hasListenersForEvent(event)){_context2.next=4;break;}logger.warn('No scanner listeners',payload);return _context2.abrupt("return");case 4:if(!_this.handling){_context2.next=7;break;}logger.warn('Scan result ignored in handling stage',payload);return _context2.abrupt("return");case 7:_this.handling=true;_this.stop();_context2.prev=9;_context2.next=12;return _this.eventHandler.notifyAllListeners(event);case 12:// Notify the close handler that the Scanner is done doing his work.
15
67
  if(_this.closeHandler){_this.closeHandler(_this);}_context2.next=19;break;case 15:_context2.prev=15;_context2.t0=_context2["catch"](9);logger.warn('Scan handler threw error:',_context2.t0);// Force restart when a handler throws an error.
16
- _this.start();case 19:case"end":return _context2.stop();}}},_callee2,null,[[9,15]]);}));return function(_x2){return _ref2.apply(this,arguments);};}());this.supportedTypes=[SCANNER_TYPE_BARCODE,SCANNER_TYPE_IMAGE];this.eventHandler=new ScannerEventHandler();// Register app scan event to listen for.
17
- registerEvents([APP_EVENT_SCANNER_DID_SCAN]);this.reset();}/**
18
- * Reset Scanner state
19
- */;export default new Scanner();
68
+ _this.start();case 19:case"end":return _context2.stop();}},_callee2,null,[[9,15]]);}));return function(_x2){return _ref2.apply(this,arguments);};}());this.supportedTypes=[SCANNER_TYPE_BARCODE,SCANNER_TYPE_IMAGE];this.eventHandler=new ScannerEventHandler();// Register app scan event to listen for.
69
+ registerEvents([APP_EVENT_SCANNER_DID_SCAN]);this.reset();});export default new Scanner();
@@ -1,13 +1,17 @@
1
- function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}/**
1
+ function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}/**
2
2
  * @typedef {Object} ScannerEventPayload
3
3
  * @property {string} format
4
4
  * @property {string} code
5
5
  *
6
6
  * Defines an event which is emitted when the scanner scans something.
7
- */var ScannerEvent=/**
7
+ */var ScannerEvent=/*#__PURE__*/_createClass(/**
8
8
  * @param {string} scope The scanner instance, that was running when this event was emitted.
9
9
  * @param {string} type The type of scanner that produced this result.
10
10
  * @param {ScannerEventPayload} payload The payload of the scan result.
11
- */function ScannerEvent(scope,type,payload){var _this=this;_classCallCheck(this,ScannerEvent);_defineProperty(this,"getScope",function(){return _this.scope;});_defineProperty(this,"getType",function(){return _this.type;});_defineProperty(this,"getPayload",function(){return _this.payload;});this.scope=scope;this.type=type;this.payload=payload;}/**
11
+ */function ScannerEvent(scope,type,payload){var _this=this;_classCallCheck(this,ScannerEvent);/**
12
12
  * @returns {string}
13
- */;export{ScannerEvent as default};
13
+ */_defineProperty(this,"getScope",function(){return _this.scope;});/**
14
+ * @returns {string}
15
+ */_defineProperty(this,"getType",function(){return _this.type;});/**
16
+ * @returns {ScannerEventPayload}
17
+ */_defineProperty(this,"getPayload",function(){return _this.payload;});this.scope=scope;this.type=type;this.payload=payload;});export{ScannerEvent as default};
@@ -1,8 +1,18 @@
1
- function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}/**
1
+ function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}/**
2
2
  * Manages scanner event listeners.
3
- */var ScannerEventHandler=/**
3
+ */var ScannerEventHandler=/*#__PURE__*/_createClass(/**
4
4
  * Initializes the event handler.
5
- */function ScannerEventHandler(){var _this=this;_classCallCheck(this,ScannerEventHandler);_defineProperty(this,"attach",function(eventListener){_this.eventListeners.add(eventListener);});_defineProperty(this,"detach",function(eventListener){return _this.eventListeners["delete"](eventListener);});_defineProperty(this,"hasListenersForEvent",function(event){return Array.from(_this.eventListeners).some(function(listener){return listener.canHandleEvent(event);});});_defineProperty(this,"notifyAllListeners",function(event){var notifyResults=[];_this.eventListeners.forEach(function(listener){notifyResults.push(listener.notify(event));});// Forward occurring errors only, because there should be no return value from "notify"
6
- return Promise.all(notifyResults).then(function(){});});this.eventListeners=new Set();}/**
5
+ */function ScannerEventHandler(){var _this=this;_classCallCheck(this,ScannerEventHandler);/**
7
6
  * @param {ScannerEventListener} eventListener The event listener to attach to the handler.
8
- */;export{ScannerEventHandler as default};
7
+ */_defineProperty(this,"attach",function(eventListener){_this.eventListeners.add(eventListener);});/**
8
+ * @param {ScannerEventListener} eventListener The event listener to detach from the handler.
9
+ * @returns {boolean} Returns true if the event listener was detached successfully.
10
+ */_defineProperty(this,"detach",function(eventListener){return _this.eventListeners["delete"](eventListener);});/**
11
+ * @param {ScannerEvent} event The event which has been emitted by the scanner.
12
+ * @returns {boolean}
13
+ */_defineProperty(this,"hasListenersForEvent",function(event){return Array.from(_this.eventListeners).some(function(listener){return listener.canHandleEvent(event);});});/**
14
+ * @param {ScannerEvent} event The event which has been emitted by the scanner.
15
+ * @returns {Promise<undefined>}
16
+ * @throws {Error}
17
+ */_defineProperty(this,"notifyAllListeners",function(event){var notifyResults=[];_this.eventListeners.forEach(function(listener){notifyResults.push(listener.notify(event));});// Forward occurring errors only, because there should be no return value from "notify"
18
+ return Promise.all(notifyResults).then(function(){});});this.eventListeners=new Set();});export{ScannerEventHandler as default};
@@ -1,12 +1,11 @@
1
- import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import{logger}from"../../helpers";import AppScanner from"../Scanner";/**
1
+ import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import{logger}from"../../helpers";import AppScanner from"../Scanner";/**
2
2
  * Allows anyone to listen for scan results based on scope, type or both.
3
- */var ScannerEventListener=/**
3
+ */var ScannerEventListener=/*#__PURE__*/_createClass(/**
4
4
  * @param {string|null} name A name for the listener object to refer to.
5
5
  * @param {string|null} scope The scanner scope to listen for.
6
6
  * @param {string|null} type THe type of scanner events to listen for.
7
7
  * @param {Array} formats The formats which can be processed by the listener.
8
- */function ScannerEventListener(){var _this=this;var name=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;var scope=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;var type=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;var formats=arguments.length>3&&arguments[3]!==undefined?arguments[3]:[];_classCallCheck(this,ScannerEventListener);_defineProperty(this,"setHandler",function(handler){if(typeof handler!=='function'){logger.error(new Error('The ScannerEventListener handler must be a function!'));}_this.handler=handler;return _this;});_defineProperty(this,"canHandleEvent",function(event){if(!_this.handler){logger.warn("No event handler defined for eventListener \"".concat(_this.name,"\""));return false;}if(_this.type&&_this.type!==event.getType()){return false;}if(_this.scope&&_this.scope!==event.getScope()){return false;}var _ref=event.getPayload()||{},format=_ref.format;if(_this.formats.length&&!_this.formats.includes(format)){return false;}return true;});_defineProperty(this,"attach",function(){AppScanner.addListener(_this);});_defineProperty(this,"notify",/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(event){var handlerResult;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:if(_this.canHandleEvent(event)){_context.next=2;break;}return _context.abrupt("return");case 2:_context.next=4;return _this.handler(event);case 4:handlerResult=_context.sent;// Don't expect anything else than undefined or null
9
- if(handlerResult!==undefined&&handlerResult!==null){logger.warn("Expected the ScannerEventListener::Handler \"".concat(_this.name,"\" to return no value,"),"but it returned \"".concat(handlerResult,"\""));}case 6:case"end":return _context.stop();}}},_callee);}));return function(_x){return _ref2.apply(this,arguments);};}());this.name=name||'unnamed';this.scope=scope||null;this.type=type||null;this.formats=formats||[];this.handler=null;}/**
8
+ */function ScannerEventListener(){var _this=this;var name=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;var scope=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;var type=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;var formats=arguments.length>3&&arguments[3]!==undefined?arguments[3]:[];_classCallCheck(this,ScannerEventListener);/**
10
9
  * Callback for an instance of an event listener. It is expected to return no value on success.
11
10
  * Throw an Error() to force the scanner to restart.
12
11
  *
@@ -17,4 +16,14 @@ if(handlerResult!==undefined&&handlerResult!==null){logger.warn("Expected the Sc
17
16
  */ /**
18
17
  * @param {Handler} handler The function which is called when a scan is done.
19
18
  * @returns {ScannerEventListener}
20
- */;export default ScannerEventListener;
19
+ */_defineProperty(this,"setHandler",function(handler){if(typeof handler!=='function'){logger.error(new Error('The ScannerEventListener handler must be a function!'));}_this.handler=handler;return _this;});/**
20
+ * Checks if the event fits to the handler.
21
+ * @param {ScannerEvent} event The scanner event which was emitted.
22
+ * @returns {boolean}
23
+ */_defineProperty(this,"canHandleEvent",function(event){if(!_this.handler){logger.warn("No event handler defined for eventListener \"".concat(_this.name,"\""));return false;}if(_this.type&&_this.type!==event.getType()){return false;}if(_this.scope&&_this.scope!==event.getScope()){return false;}var _ref=event.getPayload()||{},format=_ref.format;if(_this.formats.length&&!_this.formats.includes(format)){return false;}return true;});/**
24
+ * Attach the current event listener to the app scanner.
25
+ */_defineProperty(this,"attach",function(){AppScanner.addListener(_this);});/**
26
+ * Checks the event to see, if the listener is interested in it and call it's handler.
27
+ * @param {ScannerEvent} event The scanner event which was emitted.
28
+ */_defineProperty(this,"notify",/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(event){var handlerResult;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:if(_this.canHandleEvent(event)){_context.next=2;break;}return _context.abrupt("return");case 2:_context.next=4;return _this.handler(event);case 4:handlerResult=_context.sent;// Don't expect anything else than undefined or null
29
+ if(handlerResult!==undefined&&handlerResult!==null){logger.warn("Expected the ScannerEventListener::Handler \"".concat(_this.name,"\" to return no value,"),"but it returned \"".concat(handlerResult,"\""));}case 6:case"end":return _context.stop();}},_callee);}));return function(_x){return _ref2.apply(this,arguments);};}());this.name=name||'unnamed';this.scope=scope||null;this.type=type||null;this.formats=formats||[];this.handler=null;});export default ScannerEventListener;
@@ -1,9 +1,9 @@
1
- function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _wrapNativeSuper(Class){var _cache=typeof Map==="function"?new Map():undefined;_wrapNativeSuper=function _wrapNativeSuper(Class){if(Class===null||!_isNativeFunction(Class))return Class;if(typeof Class!=="function"){throw new TypeError("Super expression must either be null or a function");}if(typeof _cache!=="undefined"){if(_cache.has(Class))return _cache.get(Class);_cache.set(Class,Wrapper);}function Wrapper(){return _construct(Class,arguments,_getPrototypeOf(this).constructor);}Wrapper.prototype=Object.create(Class.prototype,{constructor:{value:Wrapper,enumerable:false,writable:true,configurable:true}});return _setPrototypeOf(Wrapper,Class);};return _wrapNativeSuper(Class);}function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Date.prototype.toString.call(Reflect.construct(Date,[],function(){}));return true;}catch(e){return false;}}function _construct(Parent,args,Class){if(isNativeReflectConstruct()){_construct=Reflect.construct;}else{_construct=function _construct(Parent,args,Class){var a=[null];a.push.apply(a,args);var Constructor=Function.bind.apply(Parent,a);var instance=new Constructor();if(Class)_setPrototypeOf(instance,Class.prototype);return instance;};}return _construct.apply(null,arguments);}function _isNativeFunction(fn){return Function.toString.call(fn).indexOf("[native code]")!==-1;}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}/**
1
+ function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _wrapNativeSuper(Class){var _cache=typeof Map==="function"?new Map():undefined;_wrapNativeSuper=function _wrapNativeSuper(Class){if(Class===null||!_isNativeFunction(Class))return Class;if(typeof Class!=="function"){throw new TypeError("Super expression must either be null or a function");}if(typeof _cache!=="undefined"){if(_cache.has(Class))return _cache.get(Class);_cache.set(Class,Wrapper);}function Wrapper(){return _construct(Class,arguments,_getPrototypeOf(this).constructor);}Wrapper.prototype=Object.create(Class.prototype,{constructor:{value:Wrapper,enumerable:false,writable:true,configurable:true}});return _setPrototypeOf(Wrapper,Class);};return _wrapNativeSuper(Class);}function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Date.prototype.toString.call(Reflect.construct(Date,[],function(){}));return true;}catch(e){return false;}}function _construct(Parent,args,Class){if(isNativeReflectConstruct()){_construct=Reflect.construct;}else{_construct=function _construct(Parent,args,Class){var a=[null];a.push.apply(a,args);var Constructor=Function.bind.apply(Parent,a);var instance=new Constructor();if(Class)_setPrototypeOf(instance,Class.prototype);return instance;};}return _construct.apply(null,arguments);}function _isNativeFunction(fn){return Function.toString.call(fn).indexOf("[native code]")!==-1;}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}/**
2
2
  * The ScanProcessingError is supposed to be thrown in case of a processing error of the scanned
3
3
  * content. It's properties will be used to display an error message to the user.
4
4
  * @extends Error
5
- */var ScanProcessingError=/*#__PURE__*/function(_Error){_inherits(ScanProcessingError,_Error);/**
5
+ */var ScanProcessingError=/*#__PURE__*/function(_Error){/**
6
6
  * Constructor for the ScanProcessingError
7
7
  * @param {string} message The message of the error.
8
8
  * @param {string} [title=null] The title of the error.
9
- */function ScanProcessingError(message){var _this;var title=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;_classCallCheck(this,ScanProcessingError);_this=_possibleConstructorReturn(this,_getPrototypeOf(ScanProcessingError).call(this,message));_this.title=title;return _this;}return ScanProcessingError;}(_wrapNativeSuper(Error));export default ScanProcessingError;
9
+ */function ScanProcessingError(message){var _this2;var title=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;_classCallCheck(this,ScanProcessingError);_this2=_callSuper(this,ScanProcessingError,[message]);_this2.title=title;return _this2;}_inherits(ScanProcessingError,_Error);return _createClass(ScanProcessingError);}(/*#__PURE__*/_wrapNativeSuper(Error));export default ScanProcessingError;
@@ -1,4 +1,4 @@
1
- import _regeneratorRuntime from"@babel/runtime/regenerator";function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key];}}return target;}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}import{logger}from"../../helpers";import event from"../Event";import registerEvents from"../../commands/registerEvents";import broadcastEvent from"../../commands/broadcastEvent";import{SCANNER_MODE_ON,SCANNER_TYPE_BARCODE,SCANNER_TYPE_IMAGE}from"../../constants/Scanner";import{openScanner as _openScanner,closeScanner as _closeScanner,startScanner}from"../../commands/scanner";export var APP_EVENT_CLOSE_SCANNER='closeScanner';export var APP_EVENT_SCANNER_DID_SCAN='scannerDidScan';export var APP_EVENT_SCANNER_ERROR_CONFIRMED='scannerErrorConfirmed';export var APP_EVENT_SCANNER_RESULT_PROCESSED='scannerResultProcessed';var eventsRegistered=false;/**
1
+ import _regeneratorRuntime from"@babel/runtime/regenerator";var _excluded=["requestId","scannerType"];function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key];}}return target;}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}import{logger}from"../../helpers";import event from"../Event";import registerEvents from"../../commands/registerEvents";import broadcastEvent from"../../commands/broadcastEvent";import{SCANNER_MODE_ON,SCANNER_TYPE_BARCODE,SCANNER_TYPE_IMAGE}from"../../constants/Scanner";import{openScanner as _openScanner,closeScanner as _closeScanner,startScanner}from"../../commands/scanner";export var APP_EVENT_CLOSE_SCANNER='closeScanner';export var APP_EVENT_SCANNER_DID_SCAN='scannerDidScan';export var APP_EVENT_SCANNER_ERROR_CONFIRMED='scannerErrorConfirmed';export var APP_EVENT_SCANNER_RESULT_PROCESSED='scannerResultProcessed';var eventsRegistered=false;/**
2
2
  * A callback that is invoked whenever the scanner recognized supported content.
3
3
  * @callback scanHandler
4
4
  * @param {Object} payload The event payload for a successful content scan.
@@ -20,7 +20,7 @@ registerEvents([APP_EVENT_CLOSE_SCANNER,APP_EVENT_SCANNER_DID_SCAN,APP_EVENT_SCA
20
20
  * The internal handler for the "scannerDidScan" app event.
21
21
  * @private
22
22
  * @param {Object} payload The event payload.
23
- */_createClass(ScannerManager,[{key:"scannerDidScanListener",value:function scannerDidScanListener(payload){var _this=this;/**
23
+ */return _createClass(ScannerManager,[{key:"scannerDidScanListener",value:function scannerDidScanListener(payload){var _this=this;/**
24
24
  * Trigger a scannerResultProcessed event to inform the scanner view
25
25
  * about the outcome of the scan payload processing.
26
26
  * @param {string} requestId The id of the scanner request.
@@ -28,10 +28,10 @@ registerEvents([APP_EVENT_CLOSE_SCANNER,APP_EVENT_SCANNER_DID_SCAN,APP_EVENT_SCA
28
28
  * @param {Object|null} message An object that contains properties for a dialog popup.
29
29
  */var scannerResultProcessedEvent=function scannerResultProcessedEvent(requestId){var success=arguments.length>1&&arguments[1]!==undefined?arguments[1]:true;var message=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;broadcastEvent({event:APP_EVENT_SCANNER_RESULT_PROCESSED,parameters:[requestId,success,message]});};/**
30
30
  * Wrapper function to enable execution of async code within an EventEmitter callback.
31
- */var execScanCallback=/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){var requestId,scannerType,data,message,_error$title,title;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:requestId=payload.requestId,scannerType=payload.scannerType,data=_objectWithoutProperties(payload,["requestId","scannerType"]);_context.prev=1;_context.next=4;return _this.scanHandler({scannerType:scannerType,requestId:requestId,data:data});case 4:// Inform the scanner view about the outcome.
31
+ */var execScanCallback=/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){var requestId,scannerType,data,message,_error$title2,title;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:requestId=payload.requestId,scannerType=payload.scannerType,data=_objectWithoutProperties(payload,_excluded);_context.prev=1;_context.next=4;return _this.scanHandler({scannerType:scannerType,requestId:requestId,data:data});case 4:// Inform the scanner view about the outcome.
32
32
  scannerResultProcessedEvent(requestId);if(_this.autoClose){// Close the scanner after a successful scan.
33
- _this.closeScanner();}_context.next=12;break;case 8:_context.prev=8;_context.t0=_context["catch"](1);message=_context.t0.message,_error$title=_context.t0.title,title=_error$title===void 0?null:_error$title;// Trigger an error message within the scanner webview when content processing failed.
34
- scannerResultProcessedEvent(requestId,false,{message:message,title:title});case 12:case"end":return _context.stop();}}},_callee,null,[[1,8]]);}));return function execScanCallback(){return _ref.apply(this,arguments);};}();execScanCallback();}/**
33
+ _this.closeScanner();}_context.next=12;break;case 8:_context.prev=8;_context.t0=_context["catch"](1);message=_context.t0.message,_error$title2=_context.t0.title,title=_error$title2===void 0?null:_error$title2;// Trigger an error message within the scanner webview when content processing failed.
34
+ scannerResultProcessedEvent(requestId,false,{message:message,title:title});case 12:case"end":return _context.stop();}},_callee,null,[[1,8]]);}));return function execScanCallback(){return _ref.apply(this,arguments);};}();execScanCallback();}/**
35
35
  * Register a handler to process scanned content. Errors that are thrown inside will be displayed
36
36
  * to the user as a notification, so that the webview can stay open for further scan attempts.
37
37
  * It's recommended to use the ScanProcessingError for that purpose,
@@ -52,4 +52,4 @@ _openScanner({modes:_defineProperty({},type,SCANNER_MODE_ON)});return this;}/**
52
52
  * @return {ScannerManager}
53
53
  */},{key:"closeScanner",value:function closeScanner(){// Remove the listeners to avoid further execution by other instances.
54
54
  event.removeCallback(APP_EVENT_CLOSE_SCANNER,this.closeScanner);event.removeCallback(APP_EVENT_SCANNER_DID_SCAN,this.scannerDidScanListener);event.removeCallback(APP_EVENT_SCANNER_ERROR_CONFIRMED,startScanner);// Close the scanner webview.
55
- _closeScanner();return this;}}]);return ScannerManager;}();export default ScannerManager;
55
+ _closeScanner();return this;}}]);}();export default ScannerManager;
@@ -1,20 +1,20 @@
1
- function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}import event from"../Event";import{logger}from"../../helpers";import logGroup from"../../helpers/logGroup";import Request from"../Request";import requestBuffer from"../RequestBuffer";import Bridge from"../Bridge";var localSerial=0;/**
1
+ function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}import event from"../Event";import{logger}from"../../helpers";import logGroup from"../../helpers/logGroup";import Request from"../Request";import requestBuffer from"../RequestBuffer";import Bridge from"../Bridge";var localSerial=0;/**
2
2
  * The WebStorageRequest class.
3
- */var WebStorageRequest=/*#__PURE__*/function(_Request){_inherits(WebStorageRequest,_Request);/**
3
+ */var WebStorageRequest=/*#__PURE__*/function(_Request){/**
4
4
  * @param {string} name The name of the WebStorage entry.
5
- */function WebStorageRequest(){var _this;var name=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'';_classCallCheck(this,WebStorageRequest);_this=_possibleConstructorReturn(this,_getPrototypeOf(WebStorageRequest).call(this));_this.name=name;_this.params=null;_this.createSerial(_this.name);_this.createEventCallbackName('webStorageResponse');return _this;}/**
5
+ */function WebStorageRequest(){var _this2;var name=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'';_classCallCheck(this,WebStorageRequest);_this2=_callSuper(this,WebStorageRequest);_this2.name=name;_this2.params=null;_this2.createSerial(_this2.name);_this2.createEventCallbackName('webStorageResponse');return _this2;}/**
6
6
  * Generates the serial for this web storage request. Since the setWebStorageEntry expects
7
7
  * a number value here, the default createSerial method cannot be used by now.
8
- */_createClass(WebStorageRequest,[{key:"createSerial",value:function createSerial(){// Increase the local serial and use it for the request
8
+ */_inherits(WebStorageRequest,_Request);return _createClass(WebStorageRequest,[{key:"createSerial",value:function createSerial(){// Increase the local serial and use it for the request
9
9
  localSerial+=1;this.serial=localSerial;}/**
10
10
  * Dispatches the web storage request.
11
11
  * @param {Function} resolve The resolve() callback of the request promise.
12
12
  * @return {boolean}
13
- */},{key:"onDispatch",value:function onDispatch(resolve){var _this2=this;// Add the request to the buffer.
13
+ */},{key:"onDispatch",value:function onDispatch(resolve){var _this3=this;// Add the request to the buffer.
14
14
  requestBuffer.add(this,this.serial);var requestCallbackName=this.getEventCallbackName();/**
15
15
  * The request event callback for the response call.
16
16
  * @param {string} serial The serial that was used to identify the DataRequest callback.
17
17
  * @param {number} age The age of the entry.
18
18
  * @param {*} value The value for the getWebStorageEntry request.
19
- */var requestCallback=function requestCallback(serial,age,value){event.removeCallback(requestCallbackName,requestCallback);requestBuffer.remove(serial);var response={age:age,value:value};logGroup("WebStorageResponse %c".concat(_this2.name),{response:response,serial:_this2.serial},'#f39c12');resolve(response);};// Apply the event callback.
20
- event.addCallback(requestCallbackName,requestCallback);logGroup("WebStorageRequest %c".concat(this.name),{serial:this.serial},'#e67e22');var params={name:this.name,serial:this.serial};var command={c:'getWebStorageEntry',p:params};var bridge=new Bridge();try{bridge.dispatchCommand(command,'9.0');}catch(exception){logger.error(exception);return false;}return true;}}]);return WebStorageRequest;}(Request);export default WebStorageRequest;
19
+ */var requestCallback=function requestCallback(serial,age,value){event.removeCallback(requestCallbackName,requestCallback);requestBuffer.remove(serial);var response={age:age,value:value};logGroup("WebStorageResponse %c".concat(_this3.name),{response:response,serial:_this3.serial},'#f39c12');resolve(response);};// Apply the event callback.
20
+ event.addCallback(requestCallbackName,requestCallback);logGroup("WebStorageRequest %c".concat(this.name),{serial:this.serial},'#e67e22');var params={name:this.name,serial:this.serial};var command={c:'getWebStorageEntry',p:params};var bridge=new Bridge();try{bridge.dispatchCommand(command,'9.0');}catch(exception){logger.error(exception);return false;}return true;}}]);}(Request);export default WebStorageRequest;
@@ -7,4 +7,4 @@ var libVersion='17.0';/**
7
7
  */export function resetBrightness(){new AppCommand().setCommandName('resetBrightness').setLibVersion(libVersion).dispatch();}/**
8
8
  * Returns a promise that resolves with current screen brightness (number).
9
9
  * @return {Promise}
10
- */export function getCurrentBrightness(){return _getCurrentBrightness.apply(this,arguments);}function _getCurrentBrightness(){_getCurrentBrightness=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){var response;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:_context.prev=0;_context.next=3;return brightnessRequest.dispatch();case 3:response=_context.sent;_context.next=10;break;case 6:_context.prev=6;_context.t0=_context["catch"](0);logger.error(_context.t0);throw _context.t0;case 10:return _context.abrupt("return",response);case 11:case"end":return _context.stop();}}},_callee,null,[[0,6]]);}));return _getCurrentBrightness.apply(this,arguments);}
10
+ */export function getCurrentBrightness(){return _getCurrentBrightness.apply(this,arguments);}function _getCurrentBrightness(){_getCurrentBrightness=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){var response;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:_context.prev=0;_context.next=3;return brightnessRequest.dispatch();case 3:response=_context.sent;_context.next=10;break;case 6:_context.prev=6;_context.t0=_context["catch"](0);logger.error(_context.t0);throw _context.t0;case 10:return _context.abrupt("return",response);case 11:case"end":return _context.stop();}},_callee,null,[[0,6]]);}));return _getCurrentBrightness.apply(this,arguments);}
@@ -13,7 +13,7 @@ import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGenera
13
13
  * "updateTemplateContent" SGEvent to the scanner webview.
14
14
  * @param {string} [params.animation] The entry animation for the webview.
15
15
  * @param {ScannerModes} params.modes The scanner modes.
16
- */export function openScanner(params){var _modes,_modes2;var defaults={src:'sgapi:scanner',animation:SCANNER_ANIMATION_FOREGROUND_BOTTOM,modes:(_modes={},_defineProperty(_modes,SCANNER_TYPE_BARCODE,SCANNER_MODE_OFF),_defineProperty(_modes,SCANNER_TYPE_IMAGE,SCANNER_MODE_OFF),_defineProperty(_modes,SCANNER_TYPE_CARD,SCANNER_MODE_OFF),_modes)};var merged=merge(defaults,params);var _merged$modes=merged.modes,barcodeRecognition=_merged$modes.barcodeRecognition,imageCapturing=_merged$modes.imageCapturing,cardRecognition=_merged$modes.cardRecognition;var eventParams={eventParams:{scannerData:{modes:(_modes2={},_defineProperty(_modes2,SCANNER_TYPE_BARCODE,barcodeRecognition===SCANNER_MODE_ON),_defineProperty(_modes2,SCANNER_TYPE_IMAGE,imageCapturing===SCANNER_MODE_ON),_defineProperty(_modes2,SCANNER_TYPE_CARD,cardRecognition===SCANNER_MODE_ON),_modes2)},sourceTab:PWA_DEFAULT_TAB}};merged=merge(merged,eventParams);var command=new AppCommand();command.setCommandName('openScanner').dispatch(merged);}/**
16
+ */export function openScanner(params){var defaults={src:'sgapi:scanner',animation:SCANNER_ANIMATION_FOREGROUND_BOTTOM,modes:_defineProperty(_defineProperty(_defineProperty({},SCANNER_TYPE_BARCODE,SCANNER_MODE_OFF),SCANNER_TYPE_IMAGE,SCANNER_MODE_OFF),SCANNER_TYPE_CARD,SCANNER_MODE_OFF)};var merged=merge(defaults,params);var _merged$modes=merged.modes,barcodeRecognition=_merged$modes.barcodeRecognition,imageCapturing=_merged$modes.imageCapturing,cardRecognition=_merged$modes.cardRecognition;var eventParams={eventParams:{scannerData:{modes:_defineProperty(_defineProperty(_defineProperty({},SCANNER_TYPE_BARCODE,barcodeRecognition===SCANNER_MODE_ON),SCANNER_TYPE_IMAGE,imageCapturing===SCANNER_MODE_ON),SCANNER_TYPE_CARD,cardRecognition===SCANNER_MODE_ON)},sourceTab:PWA_DEFAULT_TAB}};merged=merge(merged,eventParams);var command=new AppCommand();command.setCommandName('openScanner').dispatch(merged);}/**
17
17
  * Sends a closeScanner command to the app.
18
18
  * @param {Object} params The command parameters.
19
19
  * @param {string} [params.animation] The exit animation for the webview.
@@ -26,4 +26,4 @@ import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGenera
26
26
  */export function stopScanner(){return _stopScanner.apply(this,arguments);}/**
27
27
  * Sends a setFlashlightMode command to the app.
28
28
  * @param {boolean} enable Enables or disables the flashlight of the camera.
29
- */function _stopScanner(){_stopScanner=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){var command;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:command=new AppCommand();_context.next=3;return command.setCommandName('stopScanner').dispatch();case 3:case"end":return _context.stop();}}},_callee);}));return _stopScanner.apply(this,arguments);}export function setFlashlightMode(enable){var command=new AppCommand();command.setCommandName('setFlashlightMode').dispatch({mode:enable?SCANNER_MODE_ON:SCANNER_MODE_OFF});}
29
+ */function _stopScanner(){_stopScanner=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){var command;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:command=new AppCommand();_context.next=3;return command.setCommandName('stopScanner').dispatch();case 3:case"end":return _context.stop();}},_callee);}));return _stopScanner.apply(this,arguments);}export function setFlashlightMode(enable){var command=new AppCommand();command.setCommandName('setFlashlightMode').dispatch({mode:enable?SCANNER_MODE_ON:SCANNER_MODE_OFF});}
@@ -1 +1 @@
1
- export var EVENT_KEYBOARD_WILL_CHANGE='keyboardWillChange';export var APP_EVENT_VIEW_DID_APPEAR='viewDidAppear';export var APP_EVENT_VIEW_WILL_APPEAR='viewWillAppear';export var APP_EVENT_VIEW_WILL_DISAPPEAR='viewWillDisappear';export var APP_EVENT_VIEW_DID_DISAPPEAR='viewDidDisappear';export var APP_EVENT_APPLICATION_WILL_ENTER_FOREGROUND='applicationWillEnterForeground';export var APP_EVENT_SCANNER_DID_SCAN='scannerDidScan';export var APP_EVENT_SCANNER_DID_APPEAR='scannerDidAppear';export var APP_EVENT_SCANNER_DID_DISAPPEAR='scannerDidDisappear';export var APP_EVENT_GET_APP_PERMISSIONS_RESPONSE='getAppPermissionsResponse';export var APP_EVENT_REQUEST_APP_PERMISSIONS_RESPONSE='requestAppPermissionsResponse';
1
+ export var EVENT_KEYBOARD_WILL_CHANGE='keyboardWillChange';export var APP_EVENT_VIEW_DID_APPEAR='viewDidAppear';export var APP_EVENT_VIEW_WILL_APPEAR='viewWillAppear';export var APP_EVENT_VIEW_WILL_DISAPPEAR='viewWillDisappear';export var APP_EVENT_VIEW_DID_DISAPPEAR='viewDidDisappear';export var APP_EVENT_APPLICATION_WILL_ENTER_FOREGROUND='applicationWillEnterForeground';export var APP_EVENT_SCANNER_DID_SCAN='scannerDidScan';export var APP_EVENT_SCANNER_DID_APPEAR='scannerDidAppear';export var APP_EVENT_SCANNER_DID_DISAPPEAR='scannerDidDisappear';
@@ -1,10 +1,24 @@
1
1
  /**
2
2
  * Permission ids.
3
3
  */export var PERMISSION_ID_LOCATION='location';export var PERMISSION_ID_CAMERA='camera';// Only available on Android
4
- export var PERMISSION_ID_PHONE='phone';// Only available in iOS
4
+ export var PERMISSION_ID_PHONE='phone';export var PERMISSION_ID_BACKGROUND_LOCATION='background_location';// Only available in iOS
5
5
  export var PERMISSION_ID_PUSH='push';// Only available on iOS
6
- export var PERMISSION_ID_BACKGROUND_APP_REFRESH='backgroundAppRefresh';export var availablePermissionsIds=[PERMISSION_ID_BACKGROUND_APP_REFRESH,PERMISSION_ID_CAMERA,PERMISSION_ID_LOCATION,PERMISSION_ID_PHONE,PERMISSION_ID_PUSH];/**
6
+ export var PERMISSION_ID_BACKGROUND_APP_REFRESH='backgroundAppRefresh';export var PERMISSION_ID_APP_TRACKING_TRANSPARENCY='appTrackingTransparency';export var availablePermissionsIds=[PERMISSION_ID_BACKGROUND_APP_REFRESH,PERMISSION_ID_BACKGROUND_LOCATION,PERMISSION_ID_CAMERA,PERMISSION_ID_LOCATION,PERMISSION_ID_PHONE,PERMISSION_ID_PUSH,PERMISSION_ID_APP_TRACKING_TRANSPARENCY];/**
7
7
  * Permission usages.
8
- */export var USAGE_ALWAYS='always';export var USAGE_WHEN_IN_USE='whenInUse';export var availableUsages=[USAGE_ALWAYS,USAGE_WHEN_IN_USE];/**
8
+ */ /**
9
+ * @deprecated Use PERMISSION_USAGE_ALWAYS instead
10
+ */export var USAGE_ALWAYS='always';/**
11
+ * @deprecated Use PERMISSION_USAGE_WHEN_IN_USE instead
12
+ */export var USAGE_WHEN_IN_USE='whenInUse';export var availableUsages=[USAGE_ALWAYS,USAGE_WHEN_IN_USE];export var PERMISSION_USAGE_ALWAYS='always';export var PERMISSION_USAGE_WHEN_IN_USE='whenInUse';export var availablePermissionUsages=[PERMISSION_USAGE_ALWAYS,PERMISSION_USAGE_WHEN_IN_USE];/**
9
13
  * Permission statuses
10
- */export var STATUS_DENIED='denied';export var STATUS_GRANTED='granted';export var STATUS_NOT_DETERMINED='notDetermined';export var STATUS_NOT_SUPPORTED='notSupported';export var availableStatuses=[STATUS_DENIED,STATUS_GRANTED,STATUS_NOT_DETERMINED,STATUS_NOT_SUPPORTED];
14
+ */ /**
15
+ * @deprecated Use PERMISSION_STATUS_DENIED instead
16
+ */export var STATUS_DENIED='denied';/**
17
+ * @deprecated Use PERMISSION_STATUS_GRANTED instead
18
+ */export var STATUS_GRANTED='granted';/**
19
+ * @deprecated Use PERMISSION_STATUS_NOT_DETERMINED instead
20
+ */export var STATUS_NOT_DETERMINED='notDetermined';/**
21
+ * @deprecated Use PERMISSION_STATUS_NOT_SUPPORTED instead
22
+ */export var STATUS_NOT_SUPPORTED='notSupported';/**
23
+ * @deprecated Use availablePermissionStatuses instead
24
+ */export var availableStatuses=[STATUS_DENIED,STATUS_GRANTED,STATUS_NOT_DETERMINED,STATUS_NOT_SUPPORTED];export var PERMISSION_STATUS_DENIED='denied';export var PERMISSION_STATUS_GRANTED='granted';export var PERMISSION_STATUS_NOT_DETERMINED='notDetermined';export var PERMISSION_STATUS_NOT_SUPPORTED='notSupported';export var availablePermissionStatuses=[PERMISSION_STATUS_DENIED,PERMISSION_STATUS_GRANTED,PERMISSION_STATUS_NOT_DETERMINED,PERMISSION_STATUS_NOT_SUPPORTED];
@@ -0,0 +1,3 @@
1
+ /**
2
+ * @mixin Trilean
3
+ */export var Trilean={FALSE:Symbol(false),TRUE:Symbol(true),NONE:Symbol(null)};
package/helpers/index.js CHANGED
@@ -20,6 +20,6 @@ function _extends(){_extends=Object.assign||function(target){for(var i=1;i<argum
20
20
  * @return {boolean}
21
21
  */export function useBrowserConnector(){if(hasSGJavaScriptBridge()){return false;}if(process.env.NODE_ENV==='development'&&process.env.IP&&process.env.PORT){return false;}return true;}/**
22
22
  * Logs a deprecation warning.
23
- * @param {string} element The deperecated element.
23
+ * @param {string} element The deprecated element.
24
24
  * @param {string} [version='v7.0.0'] The engage version of removal.
25
25
  */export function logDeprecationMessage(element){var version=arguments.length>1&&arguments[1]!==undefined?arguments[1]:'v7.0.0';logger.warn("DEPRECATED: ".concat(element," is deprecated. It will be removed in Engage ").concat(version));}
@@ -42,30 +42,30 @@ if(currentMajor!==requiredMajor){return currentMajor<requiredMajor;}if(currentMi
42
42
  */export var isVersion=function isVersion(requiredVersion,currentVersion){return isVersionAtLeast(requiredVersion,currentVersion)===true&&isVersionAtMost(requiredVersion,currentVersion)===true;};/**
43
43
  * Fetches versions from the client information webStorage entry.
44
44
  * @return {Promise}
45
- */var getVersionsFromClientInformation=/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){var isIdle,clientInformation,libVersion,_clientInformation$va,appVersion,codebaseVersion,device,_ref2,_ref2$os,_ref2$os$platform,platform;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:/**
45
+ */var getVersionsFromClientInformation=/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){var isIdle,clientInformation,libVersion,_clientInformation$va,appVersion,codebaseVersion,device,_ref2,_ref2$os,_ref2$os2,_ref2$os2$platform,platform;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:/**
46
46
  * Checks if currently no request is ongoing.
47
47
  * @return {boolean}
48
48
  */isIdle=function isIdle(){return requesting===false;};if(isIdle()){_context.next=4;break;}_context.next=4;return wait(isIdle);case 4:if(!(versions!==null)){_context.next=6;break;}return _context.abrupt("return",versions);case 6:requesting=true;if(hasSGJavaScriptBridge()){_context.next=11;break;}clientInformation={value:_extends({},defaultClientInformation)};_context.next=14;break;case 11:_context.next=13;return getWebStorageEntry({name:'clientInformation'});case 13:clientInformation=_context.sent;case 14:// Grab all relevant data from the client information.
49
- libVersion=clientInformation.value.libVersion;_clientInformation$va=clientInformation.value,appVersion=_clientInformation$va.appVersion,codebaseVersion=_clientInformation$va.codebaseVersion,device=_clientInformation$va.device;/* istanbul ignore next */_ref2=device||{},_ref2$os=_ref2.os;_ref2$os=_ref2$os===void 0?{}:_ref2$os;_ref2$os$platform=_ref2$os.platform,platform=_ref2$os$platform===void 0?null:_ref2$os$platform;/**
49
+ libVersion=clientInformation.value.libVersion;_clientInformation$va=clientInformation.value,appVersion=_clientInformation$va.appVersion,codebaseVersion=_clientInformation$va.codebaseVersion,device=_clientInformation$va.device;/* istanbul ignore next */_ref2=device||{},_ref2$os=_ref2.os,_ref2$os2=_ref2$os===void 0?{}:_ref2$os,_ref2$os2$platform=_ref2$os2.platform,platform=_ref2$os2$platform===void 0?null:_ref2$os2$platform;/**
50
50
  * Older Android app versions didn't handle the libVersion within the client information like the
51
51
  * iOS apps. Those apps usually send a version 2.0. But since they also support most of the PWA
52
52
  * related commands, the lib version is corrected here to improve handling within the code.
53
53
  */if(platform===PLATFORM_ANDROID&&!isVersionAtLeast('9.0',libVersion)){libVersion=MIN_ANDROID_LIB_VERSION;}// Update the version cache.
54
- versions={libVersion:libVersion,appVersion:appVersion,codebaseVersion:codebaseVersion};requesting=false;return _context.abrupt("return",versions);case 23:case"end":return _context.stop();}}},_callee);}));return function getVersionsFromClientInformation(){return _ref.apply(this,arguments);};}();/**
54
+ versions={libVersion:libVersion,appVersion:appVersion,codebaseVersion:codebaseVersion};requesting=false;return _context.abrupt("return",versions);case 21:case"end":return _context.stop();}},_callee);}));return function getVersionsFromClientInformation(){return _ref.apply(this,arguments);};}();/**
55
55
  * Clears the local versions cache
56
56
  */export var clearVersionCache=function clearVersionCache(){versions=null;};/**
57
57
  * Checks if a required version matches at least the current lib version.
58
58
  * @param {string} requiredVersion The required version - 17[|17.0|17.0.0].
59
59
  * @return {Promise}
60
- */export var isLibVersionAtLeast=/*#__PURE__*/function(){var _ref3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(requiredVersion){var _ref4,libVersion;return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1){switch(_context2.prev=_context2.next){case 0:_context2.next=2;return getVersionsFromClientInformation();case 2:_ref4=_context2.sent;libVersion=_ref4.libVersion;return _context2.abrupt("return",isVersionAtLeast(requiredVersion,libVersion));case 5:case"end":return _context2.stop();}}},_callee2);}));return function isLibVersionAtLeast(_x){return _ref3.apply(this,arguments);};}();/**
60
+ */export var isLibVersionAtLeast=/*#__PURE__*/function(){var _ref3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(requiredVersion){var _ref4,libVersion;return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:_context2.next=2;return getVersionsFromClientInformation();case 2:_ref4=_context2.sent;libVersion=_ref4.libVersion;return _context2.abrupt("return",isVersionAtLeast(requiredVersion,libVersion));case 5:case"end":return _context2.stop();}},_callee2);}));return function isLibVersionAtLeast(_x){return _ref3.apply(this,arguments);};}();/**
61
61
  * Checks if a required version matches at most the current lib version.
62
62
  * @param {string} requiredVersion The required version - 17[|17.0|17.0.0].
63
63
  * @return {Promise}
64
- */export var isLibVersionAtMost=/*#__PURE__*/function(){var _ref5=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(requiredVersion){var _ref6,libVersion;return _regeneratorRuntime.wrap(function _callee3$(_context3){while(1){switch(_context3.prev=_context3.next){case 0:_context3.next=2;return getVersionsFromClientInformation();case 2:_ref6=_context3.sent;libVersion=_ref6.libVersion;return _context3.abrupt("return",isVersionAtMost(requiredVersion,libVersion));case 5:case"end":return _context3.stop();}}},_callee3);}));return function isLibVersionAtMost(_x2){return _ref5.apply(this,arguments);};}();/**
64
+ */export var isLibVersionAtMost=/*#__PURE__*/function(){var _ref5=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(requiredVersion){var _ref6,libVersion;return _regeneratorRuntime.wrap(function _callee3$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:_context3.next=2;return getVersionsFromClientInformation();case 2:_ref6=_context3.sent;libVersion=_ref6.libVersion;return _context3.abrupt("return",isVersionAtMost(requiredVersion,libVersion));case 5:case"end":return _context3.stop();}},_callee3);}));return function isLibVersionAtMost(_x2){return _ref5.apply(this,arguments);};}();/**
65
65
  * Checks if a required version matches the current lib version.
66
66
  * @param {string} requiredVersion The required version - 17[|17.0|17.0.0].
67
67
  * @return {Promise}
68
- */export var isLibVersion=/*#__PURE__*/function(){var _ref7=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(requiredVersion){var _ref8,libVersion;return _regeneratorRuntime.wrap(function _callee4$(_context4){while(1){switch(_context4.prev=_context4.next){case 0:_context4.next=2;return getVersionsFromClientInformation();case 2:_ref8=_context4.sent;libVersion=_ref8.libVersion;return _context4.abrupt("return",isVersion(requiredVersion,libVersion));case 5:case"end":return _context4.stop();}}},_callee4);}));return function isLibVersion(_x3){return _ref7.apply(this,arguments);};}();/**
68
+ */export var isLibVersion=/*#__PURE__*/function(){var _ref7=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(requiredVersion){var _ref8,libVersion;return _regeneratorRuntime.wrap(function _callee4$(_context4){while(1)switch(_context4.prev=_context4.next){case 0:_context4.next=2;return getVersionsFromClientInformation();case 2:_ref8=_context4.sent;libVersion=_ref8.libVersion;return _context4.abrupt("return",isVersion(requiredVersion,libVersion));case 5:case"end":return _context4.stop();}},_callee4);}));return function isLibVersion(_x3){return _ref7.apply(this,arguments);};}();/**
69
69
  * Returns the current libVersion.
70
70
  * @return {Promise}
71
- */export var getLibVersion=/*#__PURE__*/function(){var _ref9=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(){var _ref10,libVersion;return _regeneratorRuntime.wrap(function _callee5$(_context5){while(1){switch(_context5.prev=_context5.next){case 0:_context5.next=2;return getVersionsFromClientInformation();case 2:_ref10=_context5.sent;libVersion=_ref10.libVersion;return _context5.abrupt("return",libVersion);case 5:case"end":return _context5.stop();}}},_callee5);}));return function getLibVersion(){return _ref9.apply(this,arguments);};}();
71
+ */export var getLibVersion=/*#__PURE__*/function(){var _ref9=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(){var _ref10,libVersion;return _regeneratorRuntime.wrap(function _callee5$(_context5){while(1)switch(_context5.prev=_context5.next){case 0:_context5.next=2;return getVersionsFromClientInformation();case 2:_ref10=_context5.sent;libVersion=_ref10.libVersion;return _context5.abrupt("return",libVersion);case 5:case"end":return _context5.stop();}},_callee5);}));return function getLibVersion(){return _ref9.apply(this,arguments);};}();
package/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // Classes
2
2
  export{default as AppCommand}from"./classes/AppCommand";export{default as GetAppPermissionsRequest}from"./classes/AppPermissionsRequest/GetAppPermissionsRequest";export{default as RequestAppPermissionsRequest}from"./classes/AppPermissionsRequest/RequestAppPermissionsRequest";export{default as BrightnessRequest}from"./classes/BrightnessRequest";export{default as Conditioner}from"./classes/Conditioner";export{default as DataRequest}from"./classes/DataRequest";export{default as DevServerBridge}from"./classes/DevServerBridge";export{default as errorManager,emitter}from"./classes/ErrorManager";export{default as event}from"./classes/Event";export{default as HttpRequest}from"./classes/HttpRequest";export{default as PipelineRequest}from"./classes/PipelineRequest";export{default as ScannerManager}from"./classes/ScannerManager";export{default as WebStorageRequest}from"./classes/WebStorageRequest";// Commands
3
3
  export{default as analyticsSetCustomValues}from"./commands/analyticsSetCustomValues";export*from"./commands/appPermissions";export*from"./commands/brightness";export{default as broadcastEvent}from"./commands/broadcastEvent";export{default as cleanTab,cleanTabCmd}from"./commands/cleanTab";export{default as closeInAppBrowser}from"./commands/closeInAppBrowser";export{default as flushTab}from"./commands/flushTab";export{default as hideMenuBar}from"./commands/hideMenuBar";export{default as hideNavigationBar}from"./commands/hideNavigationBar";export{default as hideSplashScreen}from"./commands/hideSplashScreen";export{default as onload}from"./commands/onload";export{default as openAppSettings}from"./commands/openAppSettings";export{default as openPage}from"./commands/openPage";export{default as openPageExtern}from"./commands/openPageExtern";export{default as performCommandsAfterDelay,performCommandsAfterDelayCmd}from"./commands/performCommandsAfterDelay";export*from"./commands/plotProjects";export{default as popTabToRoot,popTabToRootCmd}from"./commands/popTabToRoot";export{default as registerEvents}from"./commands/registerEvents";export*from"./commands/scanner";export{default as setCookie}from"./commands/setCookie";export{default as setDebugLoggingEnabled}from"./commands/setDebugLoggingEnabled";export{default as setScrollingEnabled}from"./commands/setScrollingEnabled";export{default as showNavigationBar}from"./commands/showNavigationBar";export{default as showTab}from"./commands/showTab";export*from"./commands/unifiedTracking";export{default as getWebStorageEntry}from"./commands/getWebStorageEntry";export{default as setWebStorageEntry}from"./commands/setWebStorageEntry";// Constants
4
- export*from"./constants/AppEvents";export*from"./constants/AppPermissions";export*from"./constants/ErrorHandleTypes";export*from"./constants/Pipeline";export*from"./constants/ProcessTypes";export*from"./constants/Scanner";export*from"./constants/ErrorManager";// Emitters
4
+ export*from"./constants/AppEvents";export*from"./constants/AppPermissions";export*from"./constants/ErrorHandleTypes";export*from"./constants/Pipeline";export*from"./constants/ProcessTypes";export*from"./constants/Scanner";export*from"./constants/ErrorManager";export*from"./constants/Trilean";// Emitters
5
5
  export{default as UIEvents}from"./emitters/ui";// Helpers
6
6
  export*from"./helpers";export{default as logGroup}from"./helpers/logGroup";export*from"./helpers/version";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopgate/pwa-core",
3
- "version": "7.12.7-beta.1",
3
+ "version": "7.20.0-beta.10",
4
4
  "description": "Core library for the Shopgate Connect PWA.",
5
5
  "author": "Support <support@shopgate.com>",
6
6
  "license": "Apache-2.0",