@shopgate/pwa-core 7.30.0-alpha.7 → 7.30.0-alpha.9

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 (85) hide show
  1. package/classes/AppCommand/index.js +115 -11
  2. package/classes/AppCommand/spec.js +260 -6
  3. package/classes/AppCommandRequest/index.js +129 -20
  4. package/classes/AppPermissionsRequest/AppPermissionsRequest.js +45 -7
  5. package/classes/AppPermissionsRequest/GetAppPermissionsRequest.js +48 -9
  6. package/classes/AppPermissionsRequest/RequestAppPermissionsRequest.js +54 -9
  7. package/classes/Bridge/index.js +34 -4
  8. package/classes/Bridge/spec.js +24 -1
  9. package/classes/BrightnessRequest/index.js +59 -10
  10. package/classes/BrightnessRequest/spec.js +111 -6
  11. package/classes/BrowserConnector/index.js +180 -26
  12. package/classes/Conditioner/index.js +74 -8
  13. package/classes/Conditioner/spec.js +75 -1
  14. package/classes/DataRequest/index.js +116 -13
  15. package/classes/DevServerBridge/index.js +85 -9
  16. package/classes/DevServerBridge/spec.js +230 -14
  17. package/classes/ErrorManager/index.js +144 -20
  18. package/classes/ErrorManager/spec.js +244 -2
  19. package/classes/Event/index.js +101 -15
  20. package/classes/HttpRequest/index.js +182 -21
  21. package/classes/PipelineDependencies/index.js +42 -6
  22. package/classes/PipelineDependencies/spec.js +46 -3
  23. package/classes/PipelineManager/index.js +517 -71
  24. package/classes/PipelineManager/spec.js +733 -15
  25. package/classes/PipelineRequest/index.js +167 -19
  26. package/classes/PipelineRequest/mock.js +118 -21
  27. package/classes/PipelineRequest/spec.js +333 -2
  28. package/classes/PipelineSequence/index.js +34 -6
  29. package/classes/Request/index.js +61 -13
  30. package/classes/RequestBuffer/index.js +43 -6
  31. package/classes/RequestManager/index.js +216 -33
  32. package/classes/RequestManager/spec.js +188 -1
  33. package/classes/Scanner/index.js +246 -67
  34. package/classes/ScannerEvent/index.js +23 -9
  35. package/classes/ScannerEventHandler/index.js +39 -16
  36. package/classes/ScannerEventListener/index.js +84 -24
  37. package/classes/ScannerManager/ScanProcessingError.js +11 -3
  38. package/classes/ScannerManager/index.js +133 -21
  39. package/classes/WebStorageRequest/index.js +76 -9
  40. package/commands/analyticsSetCustomValues.js +8 -2
  41. package/commands/appPermissions.js +10 -3
  42. package/commands/brightness.js +33 -5
  43. package/commands/broadcastEvent.js +8 -2
  44. package/commands/cleanTab.js +11 -3
  45. package/commands/closeInAppBrowser.js +22 -2
  46. package/commands/flushTab.js +8 -2
  47. package/commands/getWebStorageEntry.js +11 -2
  48. package/commands/hideMenuBar.js +8 -2
  49. package/commands/hideNavigationBar.js +8 -2
  50. package/commands/hideSplashScreen.js +8 -2
  51. package/commands/onload.js +13 -3
  52. package/commands/openAppSettings.js +8 -2
  53. package/commands/openPage.js +8 -2
  54. package/commands/openPageExtern.js +8 -2
  55. package/commands/performCommandsAfterDelay.js +11 -3
  56. package/commands/plotProjects.js +65 -7
  57. package/commands/popTabToRoot.js +11 -3
  58. package/commands/registerEvents.js +10 -2
  59. package/commands/scanner.js +76 -7
  60. package/commands/setCookie.js +8 -2
  61. package/commands/setDebugLoggingEnabled.js +8 -2
  62. package/commands/setScrollingEnabled.js +7 -2
  63. package/commands/setWebStorageEntry.js +8 -2
  64. package/commands/shareItem.js +18 -2
  65. package/commands/showNavigationBar.js +8 -2
  66. package/commands/showTab.js +13 -2
  67. package/commands/unifiedTracking.js +128 -30
  68. package/constants/AppCommands.js +6 -1
  69. package/constants/AppEvents.js +9 -1
  70. package/constants/AppPermissions.js +57 -13
  71. package/constants/Command.js +1 -1
  72. package/constants/ErrorHandleTypes.js +2 -1
  73. package/constants/ErrorManager.js +15 -1
  74. package/constants/Pipeline.js +52 -17
  75. package/constants/ProcessTypes.js +3 -1
  76. package/constants/RequestManagerModes.js +19 -7
  77. package/constants/RequestTypes.js +2 -1
  78. package/constants/Scanner.js +39 -10
  79. package/constants/Trilean.js +6 -1
  80. package/emitters/ui.js +2 -1
  81. package/helpers/index.js +66 -8
  82. package/helpers/logGroup.js +56 -8
  83. package/helpers/version.js +216 -22
  84. package/index.js +60 -5
  85. package/package.json +1 -2
@@ -1,55 +1,167 @@
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;/**
1
+ import { logger } from "../../helpers";
2
+ import event from "../Event";
3
+ import registerEvents from "../../commands/registerEvents";
4
+ import broadcastEvent from "../../commands/broadcastEvent";
5
+ import { SCANNER_MODE_ON, SCANNER_TYPE_BARCODE, SCANNER_TYPE_IMAGE } from "../../constants/Scanner";
6
+ import { openScanner, closeScanner, startScanner } from "../../commands/scanner";
7
+ export const APP_EVENT_CLOSE_SCANNER = 'closeScanner';
8
+ export const APP_EVENT_SCANNER_DID_SCAN = 'scannerDidScan';
9
+ export const APP_EVENT_SCANNER_ERROR_CONFIRMED = 'scannerErrorConfirmed';
10
+ export const APP_EVENT_SCANNER_RESULT_PROCESSED = 'scannerResultProcessed';
11
+ let eventsRegistered = false;
12
+
13
+ /**
2
14
  * A callback that is invoked whenever the scanner recognized supported content.
3
15
  * @callback scanHandler
4
16
  * @param {Object} payload The event payload for a successful content scan.
5
- */ /**
17
+ */
18
+
19
+ /**
6
20
  * The ScannerManager class. It's intended to simplify the processes that are necessary to
7
21
  * programmatically interact with the scanner feature of the app. It provides the possibility to
8
22
  * register a handler callback to process the scanned content.
9
23
  * @deprecated This is a legacy implementation. Use Scanner instead.
10
- */var ScannerManager=/*#__PURE__*/function(){/**
24
+ */
25
+ class ScannerManager {
26
+ /**
11
27
  * The ScannerManager constructor.
12
28
  * @param {Object} options Options for the ScannerManager.
13
29
  * @param {boolean} [options.autoClose=true] If set to TRUE, the app scanner will close
14
30
  * automatically after a successful scan.
15
- */function ScannerManager(){var options=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};_classCallCheck(this,ScannerManager);this.autoClose=true;if(typeof options.autoClose==='boolean'){this.autoClose=options.autoClose;}this.scanHandler=function(){};this.supportedTypes=[SCANNER_TYPE_BARCODE,SCANNER_TYPE_IMAGE];/**
31
+ */
32
+ constructor(options = {}) {
33
+ this.autoClose = true;
34
+ if (typeof options.autoClose === 'boolean') {
35
+ this.autoClose = options.autoClose;
36
+ }
37
+ this.scanHandler = () => {};
38
+ this.supportedTypes = [SCANNER_TYPE_BARCODE, SCANNER_TYPE_IMAGE];
39
+
40
+ /**
16
41
  * Create references to the app event handler fuctions. They preserve the "this" context of
17
42
  * a ScannerManager instance and can be used to register and unregister event listeners.
18
- */this.scannerDidScanListener=this.scannerDidScanListener.bind(this);this.closeScanner=this.closeScanner.bind(this);if(!eventsRegistered){// Register the necessary events if it not already happened.
19
- registerEvents([APP_EVENT_CLOSE_SCANNER,APP_EVENT_SCANNER_DID_SCAN,APP_EVENT_SCANNER_ERROR_CONFIRMED]);eventsRegistered=true;}}/**
43
+ */
44
+ this.scannerDidScanListener = this.scannerDidScanListener.bind(this);
45
+ this.closeScanner = this.closeScanner.bind(this);
46
+ if (!eventsRegistered) {
47
+ // Register the necessary events if it not already happened.
48
+ registerEvents([APP_EVENT_CLOSE_SCANNER, APP_EVENT_SCANNER_DID_SCAN, APP_EVENT_SCANNER_ERROR_CONFIRMED]);
49
+ eventsRegistered = true;
50
+ }
51
+ }
52
+
53
+ /**
20
54
  * The internal handler for the "scannerDidScan" app event.
21
55
  * @private
22
56
  * @param {Object} payload The event payload.
23
- */return _createClass(ScannerManager,[{key:"scannerDidScanListener",value:function scannerDidScanListener(payload){var _this=this;/**
57
+ */
58
+ scannerDidScanListener(payload) {
59
+ /**
24
60
  * Trigger a scannerResultProcessed event to inform the scanner view
25
61
  * about the outcome of the scan payload processing.
26
62
  * @param {string} requestId The id of the scanner request.
27
63
  * @param {boolean} [success=true] Whether the processing was successful or not.
28
64
  * @param {Object|null} message An object that contains properties for a dialog popup.
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]});};/**
65
+ */
66
+ const scannerResultProcessedEvent = (requestId, success = true, message = null) => {
67
+ broadcastEvent({
68
+ event: APP_EVENT_SCANNER_RESULT_PROCESSED,
69
+ parameters: [requestId, success, message]
70
+ });
71
+ };
72
+
73
+ /**
30
74
  * 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$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
- 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$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();}/**
75
+ */
76
+ const execScanCallback = async () => {
77
+ const {
78
+ requestId,
79
+ scannerType,
80
+ ...data
81
+ } = payload;
82
+ try {
83
+ // Invoke the scan handler. Split the actual scan payload from the meta data.
84
+ await this.scanHandler({
85
+ scannerType,
86
+ requestId,
87
+ data
88
+ });
89
+ // Inform the scanner view about the outcome.
90
+ scannerResultProcessedEvent(requestId);
91
+ if (this.autoClose) {
92
+ // Close the scanner after a successful scan.
93
+ this.closeScanner();
94
+ }
95
+ } catch (error) {
96
+ const {
97
+ message,
98
+ title = null
99
+ } = error;
100
+ // Trigger an error message within the scanner webview when content processing failed.
101
+ scannerResultProcessedEvent(requestId, false, {
102
+ message,
103
+ title
104
+ });
105
+ }
106
+ };
107
+ execScanCallback();
108
+ }
109
+
110
+ /**
35
111
  * Register a handler to process scanned content. Errors that are thrown inside will be displayed
36
112
  * to the user as a notification, so that the webview can stay open for further scan attempts.
37
113
  * It's recommended to use the ScanProcessingError for that purpose,
38
114
  * since it provides the possibility to set a message and a title for the notification.
39
115
  * @param {scanHandler} handler The callback - async functions are supported.
40
116
  * @return {ScannerManager}
41
- */},{key:"registerScanHandler",value:function registerScanHandler(handler){if(typeof handler==='function'){this.scanHandler=handler;}return this;}/**
117
+ */
118
+ registerScanHandler(handler) {
119
+ if (typeof handler === 'function') {
120
+ this.scanHandler = handler;
121
+ }
122
+ return this;
123
+ }
124
+
125
+ /**
42
126
  * Open the scanner webview. It will instantly start the scanning process when the barcode scanner
43
127
  * is active. For the image scanner user interaction is necessary.
44
128
  * @param {string} type The initially activated scanner type.
45
129
  * @return {ScannerManager}
46
- */},{key:"openScanner",value:function openScanner(){var type=arguments.length>0&&arguments[0]!==undefined?arguments[0]:SCANNER_TYPE_BARCODE;if(!this.supportedTypes.includes(type)){logger.error("Scanner opening failed. ".concat(type," is a not supported scanner type."));return this;}// Add a listener to the closeScanner event to react on a close button press in the scanner.
47
- event.addCallback(APP_EVENT_CLOSE_SCANNER,this.closeScanner);// Add a listener to the scannerDidScan event to process scanner data.
48
- event.addCallback(APP_EVENT_SCANNER_DID_SCAN,this.scannerDidScanListener);// Add a listener to restart the scanner recognition after the user accepted the notification.
49
- event.addCallback(APP_EVENT_SCANNER_ERROR_CONFIRMED,startScanner);// Open the scanner webview.
50
- _openScanner({modes:_defineProperty({},type,SCANNER_MODE_ON)});return this;}/**
130
+ */
131
+ openScanner(type = SCANNER_TYPE_BARCODE) {
132
+ if (!this.supportedTypes.includes(type)) {
133
+ logger.error(`Scanner opening failed. ${type} is a not supported scanner type.`);
134
+ return this;
135
+ }
136
+
137
+ // Add a listener to the closeScanner event to react on a close button press in the scanner.
138
+ event.addCallback(APP_EVENT_CLOSE_SCANNER, this.closeScanner);
139
+ // Add a listener to the scannerDidScan event to process scanner data.
140
+ event.addCallback(APP_EVENT_SCANNER_DID_SCAN, this.scannerDidScanListener);
141
+ // Add a listener to restart the scanner recognition after the user accepted the notification.
142
+ event.addCallback(APP_EVENT_SCANNER_ERROR_CONFIRMED, startScanner);
143
+ // Open the scanner webview.
144
+ openScanner({
145
+ modes: {
146
+ [type]: SCANNER_MODE_ON
147
+ }
148
+ });
149
+ return this;
150
+ }
151
+
152
+ /**
51
153
  * Close the scanner webview.
52
154
  * @return {ScannerManager}
53
- */},{key:"closeScanner",value:function closeScanner(){// Remove the listeners to avoid further execution by other instances.
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;}}]);}();export default ScannerManager;
155
+ */
156
+ closeScanner() {
157
+ // Remove the listeners to avoid further execution by other instances.
158
+ event.removeCallback(APP_EVENT_CLOSE_SCANNER, this.closeScanner);
159
+ event.removeCallback(APP_EVENT_SCANNER_DID_SCAN, this.scannerDidScanListener);
160
+ event.removeCallback(APP_EVENT_SCANNER_ERROR_CONFIRMED, startScanner);
161
+
162
+ // Close the scanner webview.
163
+ closeScanner();
164
+ return this;
165
+ }
166
+ }
167
+ export default ScannerManager;
@@ -1,20 +1,87 @@
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;/**
1
+ import event from "../Event";
2
+ import { logger } from "../../helpers";
3
+ import logGroup from "../../helpers/logGroup";
4
+ import Request from "../Request";
5
+ import requestBuffer from "../RequestBuffer";
6
+ import Bridge from "../Bridge";
7
+ let localSerial = 0;
8
+
9
+ /**
2
10
  * The WebStorageRequest class.
3
- */var WebStorageRequest=/*#__PURE__*/function(_Request){/**
11
+ */
12
+ class WebStorageRequest extends Request {
13
+ /**
4
14
  * @param {string} name The name of the WebStorage entry.
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;}/**
15
+ */
16
+ constructor(name = '') {
17
+ super();
18
+ this.name = name;
19
+ this.params = null;
20
+ this.createSerial(this.name);
21
+ this.createEventCallbackName('webStorageResponse');
22
+ }
23
+
24
+ /**
6
25
  * Generates the serial for this web storage request. Since the setWebStorageEntry expects
7
26
  * a number value here, the default createSerial method cannot be used by now.
8
- */_inherits(WebStorageRequest,_Request);return _createClass(WebStorageRequest,[{key:"createSerial",value:function createSerial(){// Increase the local serial and use it for the request
9
- localSerial+=1;this.serial=localSerial;}/**
27
+ */
28
+ createSerial() {
29
+ // Increase the local serial and use it for the request
30
+ localSerial += 1;
31
+ this.serial = localSerial;
32
+ }
33
+
34
+ /**
10
35
  * Dispatches the web storage request.
11
36
  * @param {Function} resolve The resolve() callback of the request promise.
12
37
  * @return {boolean}
13
- */},{key:"onDispatch",value:function onDispatch(resolve){var _this3=this;// Add the request to the buffer.
14
- requestBuffer.add(this,this.serial);var requestCallbackName=this.getEventCallbackName();/**
38
+ */
39
+ onDispatch(resolve) {
40
+ // Add the request to the buffer.
41
+ requestBuffer.add(this, this.serial);
42
+ const requestCallbackName = this.getEventCallbackName();
43
+
44
+ /**
15
45
  * The request event callback for the response call.
16
46
  * @param {string} serial The serial that was used to identify the DataRequest callback.
17
47
  * @param {number} age The age of the entry.
18
48
  * @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(_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;
49
+ */
50
+ const requestCallback = (serial, age, value) => {
51
+ event.removeCallback(requestCallbackName, requestCallback);
52
+ requestBuffer.remove(serial);
53
+ const response = {
54
+ age,
55
+ value
56
+ };
57
+ logGroup(`WebStorageResponse %c${this.name}`, {
58
+ response,
59
+ serial: this.serial
60
+ }, '#f39c12');
61
+ resolve(response);
62
+ };
63
+
64
+ // Apply the event callback.
65
+ event.addCallback(requestCallbackName, requestCallback);
66
+ logGroup(`WebStorageRequest %c${this.name}`, {
67
+ serial: this.serial
68
+ }, '#e67e22');
69
+ const params = {
70
+ name: this.name,
71
+ serial: this.serial
72
+ };
73
+ const command = {
74
+ c: 'getWebStorageEntry',
75
+ p: params
76
+ };
77
+ const bridge = new Bridge();
78
+ try {
79
+ bridge.dispatchCommand(command, '9.0');
80
+ } catch (exception) {
81
+ logger.error(exception);
82
+ return false;
83
+ }
84
+ return true;
85
+ }
86
+ }
87
+ export default WebStorageRequest;
@@ -1,6 +1,12 @@
1
- import AppCommand from"../classes/AppCommand";/**
1
+ import AppCommand from "../classes/AppCommand";
2
+
3
+ /**
2
4
  * Sends an analyticsSetCustomValues command to the app.
3
5
  * @param {Object} params The command parameters
4
6
  * @param {Array} [params.customDimensions] Array of customDimensions
5
7
  * @param {Array} [params.customMetrics] Array of customMetrics
6
- */export default function analyticsSetCustomValues(params){var command=new AppCommand();command.setCommandName('analyticsSetCustomValues').dispatch(params);}
8
+ */
9
+ export default function analyticsSetCustomValues(params) {
10
+ const command = new AppCommand();
11
+ command.setCommandName('analyticsSetCustomValues').dispatch(params);
12
+ }
@@ -1,11 +1,18 @@
1
- import GetAppPermissionsRequest from"../classes/AppPermissionsRequest/GetAppPermissionsRequest";import RequestAppPermissionsRequest from"../classes/AppPermissionsRequest/RequestAppPermissionsRequest";/**
1
+ import GetAppPermissionsRequest from "../classes/AppPermissionsRequest/GetAppPermissionsRequest";
2
+ import RequestAppPermissionsRequest from "../classes/AppPermissionsRequest/RequestAppPermissionsRequest";
3
+
4
+ /**
2
5
  * Gathers the current permissions from the operating system.
3
6
  * @param {Array} [permissionIds=[]] The desired permission ids. If kept empty all will be returned.
4
7
  * @param {Function} [dispatchMock=null] An optional mock for the dispatch logic of the request.
5
8
  * @return {Promise<Array>}
6
- */export var getAppPermissions=function getAppPermissions(){var permissionIds=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];var dispatchMock=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;return new GetAppPermissionsRequest().setPermissionIds(permissionIds).setDispatchMock(dispatchMock).dispatch();};/**
9
+ */
10
+ export const getAppPermissions = (permissionIds = [], dispatchMock = null) => new GetAppPermissionsRequest().setPermissionIds(permissionIds).setDispatchMock(dispatchMock).dispatch();
11
+
12
+ /**
7
13
  * Requests additional permissions from the operating system.
8
14
  * @param {Array} permissions The desired permissions. If kept empty all will be returned.
9
15
  * @param {Function} [dispatchMock=null] An optional mock for the dispatch logic of the request.
10
16
  * @return {Promise<Array>}
11
- */export var requestAppPermissions=function requestAppPermissions(permissions){var dispatchMock=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;return new RequestAppPermissionsRequest().setPermissions(permissions).setDispatchMock(dispatchMock).dispatch();};
17
+ */
18
+ export const requestAppPermissions = (permissions, dispatchMock = null) => new RequestAppPermissionsRequest().setPermissions(permissions).setDispatchMock(dispatchMock).dispatch();
@@ -1,10 +1,38 @@
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);});};}import AppCommand from"../classes/AppCommand";import brightnessRequest from"../classes/BrightnessRequest";import{logger}from"../helpers";// The minimum shopgate lib version for the brightness comamnds
2
- var libVersion='17.0';/**
1
+ import AppCommand from "../classes/AppCommand";
2
+ import brightnessRequest from "../classes/BrightnessRequest";
3
+ import { logger } from "../helpers";
4
+
5
+ // The minimum shopgate lib version for the brightness comamnds
6
+ const libVersion = '17.0';
7
+
8
+ /**
3
9
  * Sets the screen brightness to the designated value.
4
10
  * @param {number} [level=100] Brightness level (from 0 to 100).
5
- */export function setBrightness(){var level=arguments.length>0&&arguments[0]!==undefined?arguments[0]:100;new AppCommand().setCommandName('setBrightness').setCommandParams({brightness:level}).setLibVersion(libVersion).dispatch();}/**
11
+ */
12
+ export function setBrightness(level = 100) {
13
+ new AppCommand().setCommandName('setBrightness').setCommandParams({
14
+ brightness: level
15
+ }).setLibVersion(libVersion).dispatch();
16
+ }
17
+
18
+ /**
6
19
  * Resets the screen brightness to system settings.
7
- */export function resetBrightness(){new AppCommand().setCommandName('resetBrightness').setLibVersion(libVersion).dispatch();}/**
20
+ */
21
+ export function resetBrightness() {
22
+ new AppCommand().setCommandName('resetBrightness').setLibVersion(libVersion).dispatch();
23
+ }
24
+
25
+ /**
8
26
  * Returns a promise that resolves with current screen brightness (number).
9
27
  * @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);}
28
+ */
29
+ export async function getCurrentBrightness() {
30
+ let response;
31
+ try {
32
+ response = await brightnessRequest.dispatch();
33
+ } catch (e) {
34
+ logger.error(e);
35
+ throw e;
36
+ }
37
+ return response;
38
+ }
@@ -1,6 +1,12 @@
1
- import AppCommand from"../classes/AppCommand";/**
1
+ import AppCommand from "../classes/AppCommand";
2
+
3
+ /**
2
4
  * Sends broadcastEvent command to the app.
3
5
  * @param {Object} params The command parameters.
4
6
  * @param {string} params.event The custom event name.
5
7
  * @param {Object} params.parameters The custom event parameters.
6
- */export default function broadcastEvent(params){var command=new AppCommand();command.setCommandName('broadcastEvent').dispatch(params);}
8
+ */
9
+ export default function broadcastEvent(params) {
10
+ const command = new AppCommand();
11
+ command.setCommandName('broadcastEvent').dispatch(params);
12
+ }
@@ -1,10 +1,18 @@
1
- import AppCommand from"../classes/AppCommand";/**
1
+ import AppCommand from "../classes/AppCommand";
2
+
3
+ /**
2
4
  * Builds a cleanTab command.
3
5
  * @param {Object} params The command parameters.
4
6
  * @param {string} params.targetTab Target tab for the page.
5
7
  * @return {AppCommand}
6
- */export var cleanTabCmd=function cleanTabCmd(params){return new AppCommand().setCommandName('cleanTab').setCommandParams(params);};/**
8
+ */
9
+ export const cleanTabCmd = params => new AppCommand().setCommandName('cleanTab').setCommandParams(params);
10
+
11
+ /**
7
12
  * Sends a cleanTab command to the app.
8
13
  * @param {Object} params The command parameters.
9
14
  * @param {string} params.targetTab Target tab for the page.
10
- */export default function cleanTab(params){cleanTabCmd(params).dispatch();}
15
+ */
16
+ export default function cleanTab(params) {
17
+ cleanTabCmd(params).dispatch();
18
+ }
@@ -1,4 +1,24 @@
1
- import{cleanTabCmd}from"./cleanTab";import{popTabToRootCmd}from"./popTabToRoot";import showTab from"./showTab";import performCommandsAfterDelay from"./performCommandsAfterDelay";import{PWA_DEFAULT_TAB}from"../constants/Command";/**
1
+ import { cleanTabCmd } from "./cleanTab";
2
+ import { popTabToRootCmd } from "./popTabToRoot";
3
+ import showTab from "./showTab";
4
+ import performCommandsAfterDelay from "./performCommandsAfterDelay";
5
+ import { PWA_DEFAULT_TAB } from "../constants/Command";
6
+
7
+ /**
2
8
  * Send all commands that are needed to close the inAppBrowser.
3
9
  * @param {boolean} isAndroid True if we are on a android device.
4
- */export default function closeInAppBrowser(isAndroid){var targetTab={targetTab:'in_app_browser'};var delayedCommand=(isAndroid?cleanTabCmd(targetTab):popTabToRootCmd(targetTab)).buildCommand();performCommandsAfterDelay({cmds:[delayedCommand],delay:0.4});showTab({targetTab:PWA_DEFAULT_TAB,transition:'slideOutToBottom'});}
10
+ */
11
+ export default function closeInAppBrowser(isAndroid) {
12
+ const targetTab = {
13
+ targetTab: 'in_app_browser'
14
+ };
15
+ const delayedCommand = (isAndroid ? cleanTabCmd(targetTab) : popTabToRootCmd(targetTab)).buildCommand();
16
+ performCommandsAfterDelay({
17
+ cmds: [delayedCommand],
18
+ delay: 0.4
19
+ });
20
+ showTab({
21
+ targetTab: PWA_DEFAULT_TAB,
22
+ transition: 'slideOutToBottom'
23
+ });
24
+ }
@@ -1,5 +1,11 @@
1
- import AppCommand from"../classes/AppCommand";/**
1
+ import AppCommand from "../classes/AppCommand";
2
+
3
+ /**
2
4
  * Sends a flushTab command to the app.
3
5
  * @param {Object} params The command parameters.
4
6
  * @param {string} params.targetTab Target tab for the page.
5
- */export default function flushTab(params){var command=new AppCommand();command.setCommandName('flushTab').dispatch(params);}
7
+ */
8
+ export default function flushTab(params) {
9
+ const command = new AppCommand();
10
+ command.setCommandName('flushTab').dispatch(params);
11
+ }
@@ -1,7 +1,16 @@
1
- import WebStorageRequest from"../classes/WebStorageRequest";/**
1
+ import WebStorageRequest from "../classes/WebStorageRequest";
2
+
3
+ /**
2
4
  * With this command you can get the value of a WebStorageRequest, that has been set with
3
5
  * setWebStorageEntry.
4
6
  * @param {Object} params The command parameters
5
7
  * @param {string} params.name The name of the entry, that shall be given back.
6
8
  * @return {Promise}
7
- */export default function getWebStorageEntry(params){var name=params.name;var storage=new WebStorageRequest(name);return storage.dispatch();}
9
+ */
10
+ export default function getWebStorageEntry(params) {
11
+ const {
12
+ name
13
+ } = params;
14
+ const storage = new WebStorageRequest(name);
15
+ return storage.dispatch();
16
+ }
@@ -1,4 +1,10 @@
1
- import AppCommand from"../classes/AppCommand";/**
1
+ import AppCommand from "../classes/AppCommand";
2
+
3
+ /**
2
4
  * Sends hideMenuBar command to the app.
3
5
  * @param {Object} [params=null] The command parameters.
4
- */export default function hideMenuBar(){var params=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;var command=new AppCommand();command.setCommandName('hideMenuBar').dispatch(params);}
6
+ */
7
+ export default function hideMenuBar(params = null) {
8
+ const command = new AppCommand();
9
+ command.setCommandName('hideMenuBar').dispatch(params);
10
+ }
@@ -1,4 +1,10 @@
1
- import AppCommand from"../classes/AppCommand";/**
1
+ import AppCommand from "../classes/AppCommand";
2
+
3
+ /**
2
4
  * Sends hideNavigationBar command to the app.
3
5
  * @param {Object} [params=null] The command parameters.
4
- */export default function hideNavigationBar(){var params=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;var command=new AppCommand();command.setCommandName('hideNavigationBar').dispatch(params);}
6
+ */
7
+ export default function hideNavigationBar(params = null) {
8
+ const command = new AppCommand();
9
+ command.setCommandName('hideNavigationBar').dispatch(params);
10
+ }
@@ -1,3 +1,9 @@
1
- import AppCommand from"../classes/AppCommand";/**
1
+ import AppCommand from "../classes/AppCommand";
2
+
3
+ /**
2
4
  * Sends hideSplashScreen command to the app.
3
- */export default function hideSplashScreen(){var command=new AppCommand(true,false);command.setCommandName('hideSplashScreen').dispatch();}
5
+ */
6
+ export default function hideSplashScreen() {
7
+ const command = new AppCommand(true, false);
8
+ command.setCommandName('hideSplashScreen').dispatch();
9
+ }
@@ -1,4 +1,14 @@
1
- import AppCommand from"../classes/AppCommand";import{hasSGJavaScriptBridge}from"../helpers";/**
1
+ import AppCommand from "../classes/AppCommand";
2
+ import { hasSGJavaScriptBridge } from "../helpers";
3
+
4
+ /**
2
5
  * Sends an onload command if in the native app environment.
3
- */export default function onload(){// This command is only needed inside an app environment.
4
- if(!hasSGJavaScriptBridge()){return;}var command=new AppCommand(true,false);command.setCommandName('onload').dispatch();}
6
+ */
7
+ export default function onload() {
8
+ // This command is only needed inside an app environment.
9
+ if (!hasSGJavaScriptBridge()) {
10
+ return;
11
+ }
12
+ const command = new AppCommand(true, false);
13
+ command.setCommandName('onload').dispatch();
14
+ }
@@ -1,3 +1,9 @@
1
- import AppCommand from"../classes/AppCommand";/**
1
+ import AppCommand from "../classes/AppCommand";
2
+
3
+ /**
2
4
  * Sends an openAppSettings command to the app.
3
- */export default function openAppSettings(){var command=new AppCommand();command.setCommandName('openAppSettings').dispatch();}
5
+ */
6
+ export default function openAppSettings() {
7
+ const command = new AppCommand();
8
+ command.setCommandName('openAppSettings').dispatch();
9
+ }
@@ -1,4 +1,6 @@
1
- import AppCommand from"../classes/AppCommand";/**
1
+ import AppCommand from "../classes/AppCommand";
2
+
3
+ /**
2
4
  * Sends an openPage command to the app.
3
5
  * @param {Object} params The command parameters
4
6
  * @param {string} params.src The URL which shall be loaded
@@ -8,4 +10,8 @@ import AppCommand from"../classes/AppCommand";/**
8
10
  * @param {string} params.targetTab Target tab for the page.
9
11
  * @param {string} params.title The title of the opened page
10
12
  * @param {Object} params.navigationBarParams Parameters for the navigation bar.
11
- */export default function openPage(params){var command=new AppCommand();command.setCommandName('openPage').dispatch(params);}
13
+ */
14
+ export default function openPage(params) {
15
+ const command = new AppCommand();
16
+ command.setCommandName('openPage').dispatch(params);
17
+ }
@@ -1,5 +1,11 @@
1
- import AppCommand from"../classes/AppCommand";/**
1
+ import AppCommand from "../classes/AppCommand";
2
+
3
+ /**
2
4
  * Sends an openPageExtern command to the app.
3
5
  * @param {Object} params The command parameters
4
6
  * @param {string} params.src The URL which shall be loaded
5
- */export default function openPageExtern(params){var command=new AppCommand();command.setCommandName('openPageExtern').dispatch(params);}
7
+ */
8
+ export default function openPageExtern(params) {
9
+ const command = new AppCommand();
10
+ command.setCommandName('openPageExtern').dispatch(params);
11
+ }
@@ -1,8 +1,16 @@
1
- import AppCommand from"../classes/AppCommand";/**
1
+ import AppCommand from "../classes/AppCommand";
2
+
3
+ /**
2
4
  * Builds a performCommandsAfterDelay command.
3
5
  * @param {Object} params The command parameters.
4
6
  * @return {AppCommand}
5
- */export var performCommandsAfterDelayCmd=function performCommandsAfterDelayCmd(params){return new AppCommand().setCommandName('performCommandsAfterDelay').setCommandParams(params);};/**
7
+ */
8
+ export const performCommandsAfterDelayCmd = params => new AppCommand().setCommandName('performCommandsAfterDelay').setCommandParams(params);
9
+
10
+ /**
6
11
  * Sends a performCommandsAfterDelay command to the app.
7
12
  * @param {Object} params The command parameters.
8
- */export default function performCommandsAfterDelay(params){performCommandsAfterDelayCmd(params).dispatch();}
13
+ */
14
+ export default function performCommandsAfterDelay(params) {
15
+ performCommandsAfterDelayCmd(params).dispatch();
16
+ }