@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,9 +1,26 @@
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);}import AppCommand from"../classes/AppCommand";import{logger}from"../helpers";/**
1
+ import AppCommand from "../classes/AppCommand";
2
+ import { logger } from "../helpers";
3
+
4
+ /**
2
5
  * Enables the geofencing provider plotProjects
3
6
  * @param {string} token The public token that is needed to enable plot projects
4
- */export function plotProjectsEnable(token){var command=new AppCommand();command.setCommandName('plotProjectsEnable').setLibVersion('18.0').dispatch({publicToken:token});}/**
7
+ */
8
+ export function plotProjectsEnable(token) {
9
+ const command = new AppCommand();
10
+ command.setCommandName('plotProjectsEnable').setLibVersion('18.0').dispatch({
11
+ publicToken: token
12
+ });
13
+ }
14
+
15
+ /**
5
16
  * Disables the geofencing provider plotProjects
6
- */export function plotProjectsDisable(){var command=new AppCommand();command.setCommandName('plotProjectsDisable').setLibVersion('18.0').dispatch();}/**
17
+ */
18
+ export function plotProjectsDisable() {
19
+ const command = new AppCommand();
20
+ command.setCommandName('plotProjectsDisable').setLibVersion('18.0').dispatch();
21
+ }
22
+
23
+ /**
7
24
  * This command sets a Segmentation Properties within PlotProjects
8
25
  * @param {Array} inputProperties Array that contains the information about the segmentation
9
26
  * properties
@@ -15,7 +32,48 @@ function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="s
15
32
  * @param {any} [inputProperties.value] The value that shall be set for that property. In case the
16
33
  * value is <Null> or omitted, the property will be cleared. Only supported for strings
17
34
  * @return {boolean|undefined}
18
- */export function plotProjectsSetSegmentationProperties(inputProperties){var possibleTypes=['string','integer','double','date','bool',null];// validate properties
19
- var properties=inputProperties.filter(function(_ref){var key=_ref.key,type=_ref.type,value=_ref.value;if(typeof key!=='string'){logger.error("Unsupported plotprojects property \"key\". found \"".concat(key,"\" (typeof \"").concat(_typeof(key),"\") expected \"string\""));return false;}// plotProjects only allows max 40 characters as key
20
- if(key.length>40){logger.error('plotprojects property "key" exceeded length limit of 40');return false;}if(typeof value==='string'&&value.length>40){logger.error('plotprojects property "value" exceeded length limit of 40');return false;}if(typeof type!=='undefined'&&!possibleTypes.includes(type)){logger.error("Unsupported plotprojects property \"type\". found \"".concat(type,"\" expected:"),possibleTypes);return false;}// clear is only supported for strings at the moment
21
- if(typeof type!=='string'&&(value===null||typeof value==='undefined')){logger.error("plotprojects. Clearing is only supported for type=string. found \"".concat(value,"\" for type \"").concat(type,"\""));return false;}return true;});if(!properties.length){logger.error('No valid plotprojects properties found',inputProperties);return false;}var command=new AppCommand();return command.setCommandName('plotProjectsSetSegmentationProperties').setCommandParams({properties:properties}).setLibVersion('25.0').dispatch();}
35
+ */
36
+ export function plotProjectsSetSegmentationProperties(inputProperties) {
37
+ const possibleTypes = ['string', 'integer', 'double', 'date', 'bool', null];
38
+
39
+ // validate properties
40
+ const properties = inputProperties.filter(({
41
+ key,
42
+ type,
43
+ value
44
+ }) => {
45
+ if (typeof key !== 'string') {
46
+ logger.error(`Unsupported plotprojects property "key". found "${key}" (typeof "${typeof key}") expected "string"`);
47
+ return false;
48
+ }
49
+
50
+ // plotProjects only allows max 40 characters as key
51
+ if (key.length > 40) {
52
+ logger.error('plotprojects property "key" exceeded length limit of 40');
53
+ return false;
54
+ }
55
+ if (typeof value === 'string' && value.length > 40) {
56
+ logger.error('plotprojects property "value" exceeded length limit of 40');
57
+ return false;
58
+ }
59
+ if (typeof type !== 'undefined' && !possibleTypes.includes(type)) {
60
+ logger.error(`Unsupported plotprojects property "type". found "${type}" expected:`, possibleTypes);
61
+ return false;
62
+ }
63
+
64
+ // clear is only supported for strings at the moment
65
+ if (typeof type !== 'string' && (value === null || typeof value === 'undefined')) {
66
+ logger.error(`plotprojects. Clearing is only supported for type=string. found "${value}" for type "${type}"`);
67
+ return false;
68
+ }
69
+ return true;
70
+ });
71
+ if (!properties.length) {
72
+ logger.error('No valid plotprojects properties found', inputProperties);
73
+ return false;
74
+ }
75
+ const command = new AppCommand();
76
+ return command.setCommandName('plotProjectsSetSegmentationProperties').setCommandParams({
77
+ properties
78
+ }).setLibVersion('25.0').dispatch();
79
+ }
@@ -1,10 +1,18 @@
1
- import AppCommand from"../classes/AppCommand";/**
1
+ import AppCommand from "../classes/AppCommand";
2
+
3
+ /**
2
4
  * Builds an popTabToRoot command.
3
5
  * @param {Object} params The command parameters.
4
6
  * @param {string} params.targetTab The navigation stack that shall be popped to root view.
5
7
  * @return {AppCommand}
6
- */export var popTabToRootCmd=function popTabToRootCmd(params){return new AppCommand().setCommandName('popTabToRoot').setCommandParams(params);};/**
8
+ */
9
+ export const popTabToRootCmd = params => new AppCommand().setCommandName('popTabToRoot').setCommandParams(params);
10
+
11
+ /**
7
12
  * Sends an popTabToRoot command to the app.
8
13
  * @param {Object} params The command parameters.
9
14
  * @param {string} params.targetTab The navigation stack that shall be popped to root view.
10
- */export default function popTabToRoot(params){popTabToRootCmd(params).dispatch();}
15
+ */
16
+ export default function popTabToRoot(params) {
17
+ popTabToRootCmd(params).dispatch();
18
+ }
@@ -1,5 +1,13 @@
1
- import AppCommand from"../classes/AppCommand";/**
1
+ import AppCommand from "../classes/AppCommand";
2
+
3
+ /**
2
4
  * Sends registerEvents command to the app.
3
5
  * This registers the WebView to certain app events.
4
6
  * @param {Array} events Events that should be registered.
5
- */export default function registerEvents(events){var command=new AppCommand(true,false);command.setCommandName('registerEvents').dispatch({events:events});}
7
+ */
8
+ export default function registerEvents(events) {
9
+ const command = new AppCommand(true, false);
10
+ command.setCommandName('registerEvents').dispatch({
11
+ events
12
+ });
13
+ }
@@ -1,11 +1,18 @@
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 _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 merge from'lodash/merge';import AppCommand from"../classes/AppCommand";import{PWA_DEFAULT_TAB}from"../constants/Command";import{SCANNER_ANIMATION_FOREGROUND_BOTTOM,SCANNER_TYPE_BARCODE,SCANNER_TYPE_CARD,SCANNER_TYPE_IMAGE,SCANNER_MODE_ON,SCANNER_MODE_OFF}from"../constants/Scanner";/**
1
+ import merge from 'lodash/merge';
2
+ import AppCommand from "../classes/AppCommand";
3
+ import { PWA_DEFAULT_TAB } from "../constants/Command";
4
+ import { SCANNER_ANIMATION_FOREGROUND_BOTTOM, SCANNER_TYPE_BARCODE, SCANNER_TYPE_CARD, SCANNER_TYPE_IMAGE, SCANNER_MODE_ON, SCANNER_MODE_OFF } from "../constants/Scanner";
5
+
6
+ /**
2
7
  * Data definition the scanner modes parameters. Possible values are "on" or "off".
3
8
  * @typedef {string} ScannerType
4
9
  * @typedef {Object} ScannerModes
5
10
  * @property {ScannerType} barcodeRecognition Shall the scanner try to recognize barcodes.
6
11
  * @property {ScannerType} imageCapturing Shall the scanner try to capture images.
7
12
  * @property {ScannerType} cardRecognition Shall the scanner try to recognize credit cards.
8
- */ /**
13
+ */
14
+
15
+ /**
9
16
  * Sends an openScanner command to the app.
10
17
  * @param {Object} params The command parameters.
11
18
  * @param {string} params.src The URL to the webview which overlays the scanner feed.
@@ -13,17 +20,79 @@ import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGenera
13
20
  * "updateTemplateContent" SGEvent to the scanner webview.
14
21
  * @param {string} [params.animation] The entry animation for the webview.
15
22
  * @param {ScannerModes} params.modes The scanner modes.
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);}/**
23
+ */
24
+ export function openScanner(params) {
25
+ const defaults = {
26
+ src: 'sgapi:scanner',
27
+ animation: SCANNER_ANIMATION_FOREGROUND_BOTTOM,
28
+ modes: {
29
+ [SCANNER_TYPE_BARCODE]: SCANNER_MODE_OFF,
30
+ [SCANNER_TYPE_IMAGE]: SCANNER_MODE_OFF,
31
+ [SCANNER_TYPE_CARD]: SCANNER_MODE_OFF
32
+ }
33
+ };
34
+ let merged = merge(defaults, params);
35
+ const {
36
+ barcodeRecognition,
37
+ imageCapturing,
38
+ cardRecognition
39
+ } = merged.modes;
40
+ const eventParams = {
41
+ eventParams: {
42
+ scannerData: {
43
+ modes: {
44
+ [SCANNER_TYPE_BARCODE]: barcodeRecognition === SCANNER_MODE_ON,
45
+ [SCANNER_TYPE_IMAGE]: imageCapturing === SCANNER_MODE_ON,
46
+ [SCANNER_TYPE_CARD]: cardRecognition === SCANNER_MODE_ON
47
+ }
48
+ },
49
+ sourceTab: PWA_DEFAULT_TAB
50
+ }
51
+ };
52
+ merged = merge(merged, eventParams);
53
+ const command = new AppCommand();
54
+ command.setCommandName('openScanner').dispatch(merged);
55
+ }
56
+
57
+ /**
17
58
  * Sends a closeScanner command to the app.
18
59
  * @param {Object} params The command parameters.
19
60
  * @param {string} [params.animation] The exit animation for the webview.
20
- */export function closeScanner(){var params=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var defaults={animation:SCANNER_ANIMATION_FOREGROUND_BOTTOM};var merged=merge(defaults,params);var command=new AppCommand();command.setCommandName('closeScanner').dispatch(merged);}/**
61
+ */
62
+ export function closeScanner(params = {}) {
63
+ const defaults = {
64
+ animation: SCANNER_ANIMATION_FOREGROUND_BOTTOM
65
+ };
66
+ const merged = merge(defaults, params);
67
+ const command = new AppCommand();
68
+ command.setCommandName('closeScanner').dispatch(merged);
69
+ }
70
+
71
+ /**
21
72
  * Sends a startScanner command to the app.
22
73
  * It activates the content recognition of the scanner.
23
- */export function startScanner(){var command=new AppCommand();command.setCommandName('startScanner').dispatch();}/**
74
+ */
75
+ export function startScanner() {
76
+ const command = new AppCommand();
77
+ command.setCommandName('startScanner').dispatch();
78
+ }
79
+
80
+ /**
24
81
  * Sends a stopScanner command to the app.
25
82
  * It deactivates the content recognition of the scanner.
26
- */export function stopScanner(){return _stopScanner.apply(this,arguments);}/**
83
+ */
84
+ export async function stopScanner() {
85
+ const command = new AppCommand();
86
+ await command.setCommandName('stopScanner').dispatch();
87
+ }
88
+
89
+ /**
27
90
  * Sends a setFlashlightMode command to the app.
28
91
  * @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});}
92
+ */
93
+ export function setFlashlightMode(enable) {
94
+ const command = new AppCommand();
95
+ command.setCommandName('setFlashlightMode').dispatch({
96
+ mode: enable ? SCANNER_MODE_ON : SCANNER_MODE_OFF
97
+ });
98
+ }
@@ -1,4 +1,6 @@
1
- import AppCommand from"../classes/AppCommand";/**
1
+ import AppCommand from "../classes/AppCommand";
2
+
3
+ /**
2
4
  * Sends an setCookie command to the app.
3
5
  * @param {Object} params The command parameters
4
6
  * @param {string} params.name The name of the cookie
@@ -8,4 +10,8 @@ import AppCommand from"../classes/AppCommand";/**
8
10
  * @param {string} params.path The path for the cookie
9
11
  * @param {boolean} params.secure Set is secure
10
12
  * @param {boolean} params.httpOnly Set is http only
11
- */export default function setCookie(params){var command=new AppCommand();command.setCommandName('setCookie').setLibVersion('14.0').dispatch(params);}
13
+ */
14
+ export default function setCookie(params) {
15
+ const command = new AppCommand();
16
+ command.setCommandName('setCookie').setLibVersion('14.0').dispatch(params);
17
+ }
@@ -1,4 +1,10 @@
1
- import AppCommand from"../classes/AppCommand";/**
1
+ import AppCommand from "../classes/AppCommand";
2
+
3
+ /**
2
4
  * Sends a setDebugLoggingEnabled command to the app.
3
5
  * @param {Object} params The command parameters.
4
- */export default function setDebugLoggingEnabled(){var params=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var command=new AppCommand();command.setCommandName('setDebugLoggingEnabled').dispatch(params);}
6
+ */
7
+ export default function setDebugLoggingEnabled(params = {}) {
8
+ const command = new AppCommand();
9
+ command.setCommandName('setDebugLoggingEnabled').dispatch(params);
10
+ }
@@ -1,5 +1,10 @@
1
- import AppCommand from"../classes/AppCommand";/**
1
+ import AppCommand from "../classes/AppCommand";
2
+
3
+ /**
2
4
  * Sends a setScrollingEnabled command to the app.
3
5
  * @param {Object} params The command parameters.
4
6
  * @param {boolean} params.enabled Target tab for the page.
5
- */export default function setScrollingEnabled(params){new AppCommand().setCommandName('setScrollingEnabled').setCommandParams(params).dispatch();}
7
+ */
8
+ export default function setScrollingEnabled(params) {
9
+ new AppCommand().setCommandName('setScrollingEnabled').setCommandParams(params).dispatch();
10
+ }
@@ -1,4 +1,6 @@
1
- import AppCommand from"../classes/AppCommand";/**
1
+ import AppCommand from "../classes/AppCommand";
2
+
3
+ /**
2
4
  * This commands set up entries with values in the WebStorageRequest. This storage is mainly meant
3
5
  * to be a data storage for web views. The entry with its value can fetched by using
4
6
  * getWebStorageEntry.
@@ -8,4 +10,8 @@ import AppCommand from"../classes/AppCommand";/**
8
10
  * that the entry will be deleted.
9
11
  * @param {number} params.timeout The cache time how long the entry shall be stored in seconds
10
12
  * 0 or omitting means that the entry won't be deleted automatically
11
- */export default function setWebStorageEntry(params){var command=new AppCommand();command.setCommandName('setWebStorageEntry').dispatch(params);}
13
+ */
14
+ export default function setWebStorageEntry(params) {
15
+ const command = new AppCommand();
16
+ command.setCommandName('setWebStorageEntry').dispatch(params);
17
+ }
@@ -1,7 +1,23 @@
1
- function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import AppCommand from"../classes/AppCommand";/**
1
+ import "core-js/modules/es.string.replace.js";
2
+ import AppCommand from "../classes/AppCommand";
3
+
4
+ /**
2
5
  * Sends a shareItem command to the app.
3
6
  * @param {Object} params The command paramters.
4
7
  * @param {string} params.title The product title
5
8
  * @param {string} params.imageURL The products image url to be loaded
6
9
  * @param {string} params.deepLink The products deep link
7
- */export default(function(params){var merged=_extends({title:'',imageURL:'',deepLink:''},params);if(merged.deepLink){merged.deepLink=merged.deepLink.replace(/(\?|&)shopgate_redirect=1/i,'');}var command=new AppCommand();command.setCommandName('shareItem').dispatch(merged);});
10
+ */
11
+ export default params => {
12
+ const merged = {
13
+ title: '',
14
+ imageURL: '',
15
+ deepLink: '',
16
+ ...params
17
+ };
18
+ if (merged.deepLink) {
19
+ merged.deepLink = merged.deepLink.replace(/(\?|&)shopgate_redirect=1/i, '');
20
+ }
21
+ const command = new AppCommand();
22
+ command.setCommandName('shareItem').dispatch(merged);
23
+ };
@@ -1,4 +1,10 @@
1
- import AppCommand from"../classes/AppCommand";/**
1
+ import AppCommand from "../classes/AppCommand";
2
+
3
+ /**
2
4
  * Sends showNavigationBar command to the app.
3
5
  * @param {Object} [params=null] The command parameters.
4
- */export default function showNavigationBar(){var params=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;var command=new AppCommand();command.setCommandName('showNavigationBar').dispatch(params);}
6
+ */
7
+ export default function showNavigationBar(params = null) {
8
+ const command = new AppCommand();
9
+ command.setCommandName('showNavigationBar').dispatch(params);
10
+ }
@@ -1,8 +1,19 @@
1
- import AppCommand from"../classes/AppCommand";import{logger,hasSGJavaScriptBridge}from"../helpers";/**
1
+ import AppCommand from "../classes/AppCommand";
2
+ import { logger, hasSGJavaScriptBridge } from "../helpers";
3
+
4
+ /**
2
5
  * Sends a showTab command to the app.
3
6
  * @param {params} params The command parameters
4
7
  * @param {string} params.targetTab The navigation stack which shall be displayed.
5
8
  * @param {string} [params.transition] The type of the transition.
6
9
  * @param {number} [params.speedFactor] Speeds up or slows down the transition. Number
7
10
  * between 0 and 1 speeds up. Number above 1 slows down.
8
- */export default function showTab(params){if(!hasSGJavaScriptBridge()){logger.warn('WARNING: \'showTab\' can only be called in an app environment!');return;}var command=new AppCommand();command.setCommandName('showTab').dispatch(params);}
11
+ */
12
+ export default function showTab(params) {
13
+ if (!hasSGJavaScriptBridge()) {
14
+ logger.warn('WARNING: \'showTab\' can only be called in an app environment!');
15
+ return;
16
+ }
17
+ const command = new AppCommand();
18
+ command.setCommandName('showTab').dispatch(params);
19
+ }
@@ -1,13 +1,19 @@
1
- import AppCommand from"../classes/AppCommand";/**
1
+ import AppCommand from "../classes/AppCommand";
2
+
3
+ /**
2
4
  * Data definitions of the multiple tracking events
3
- */ /**
5
+ */
6
+
7
+ /**
4
8
  * Data definition for a pageview event within the unified tracking system
5
9
  * @typedef {Object} UnifiedPageview
6
10
  * @property {string} type The type of the current page. Something like "Product" or "Checkout"
7
11
  * @property {string} id A unique identifier for the current page, like an item number or page title
8
12
  * @property {string} name A name to easier distinguish this item in the tracking tool
9
13
  * @property {UnifiedRestrictions} [restrictions] Restrictions for the command
10
- */ /**
14
+ */
15
+
16
+ /**
11
17
  * Data definition for the payload of a custom event within the unified tracking system
12
18
  * @typedef {Object} UnifiedEvent
13
19
  * @property {string} shortName Short name of the event that shall be logged
@@ -16,7 +22,9 @@ import AppCommand from"../classes/AppCommand";/**
16
22
  * @property {string} name Name of the event
17
23
  * @property {Object} [customParams] Custom parameters that will be logged with the event
18
24
  * @property {UnifiedRestrictions} [restrictions] Restrictions for the command
19
- */ /**
25
+ */
26
+
27
+ /**
20
28
  * Data definition for a purchase event within the unified tracking system
21
29
  * @typedef {Object} UnifiedPurchase
22
30
  * @property {string} id A unique ID representing the transaction.
@@ -35,19 +43,25 @@ import AppCommand from"../classes/AppCommand";/**
35
43
  * @property {string} [type] Type of checkout
36
44
  * @property {boolean} [success] Whether the Purchase was successful, or not
37
45
  * @property {UnifiedRestrictions} [restrictions] Restrictions for the command
38
- */ /**
46
+ */
47
+
48
+ /**
39
49
  * Data definition for an addToCart event within the unified tracking system
40
50
  * @typedef {Object} UnifiedAddToCart
41
51
  * @property {UnifiedAddToCartItem[]} items Array of unified items
42
52
  * @property {string} position Position where the add to cart took place
43
53
  * @property {UnifiedRestrictions} [restrictions] Restrictions for the command
44
- */ /**
54
+ */
55
+
56
+ /**
45
57
  * Data definition for an addedPaymentInfo event within the unified tracking system
46
58
  * @typedef {Object} UnifiedAddedPaymentInfo
47
59
  * @property {bool} success If it was success or not
48
60
  * @property {string} name Name of the payment method
49
61
  * @property {UnifiedRestrictions} [restrictions] Restrictions for the command
50
- */ /**
62
+ */
63
+
64
+ /**
51
65
  * Data definition for an InitiatedCheckout event within the unified tracking system
52
66
  * @typedef {Object} UnifiedInitiatedCheckout
53
67
  * @property {number} valueNet The net value of the items in the cart
@@ -57,18 +71,24 @@ import AppCommand from"../classes/AppCommand";/**
57
71
  * @property {boolean} [paymentInfoAvailable] Whether the paymentInfo is available
58
72
  * @property {string} [currency] The currency code as ISO 4217 string.
59
73
  * @property {UnifiedRestrictions} [restrictions] Restrictions for the command
60
- */ /**
74
+ */
75
+
76
+ /**
61
77
  * Data definition for a completedRegistration within the unified tracking system
62
78
  * @typedef {Object} UnifiedCompletedRegistration
63
79
  * @property {string} registrationMethod The type of the registration
64
80
  * (default_account, guest_account, facebook, 'connect_register')
65
81
  * @property {UnifiedRestrictions} [restrictions] Restrictions for the command
66
- */ /**
82
+ */
83
+
84
+ /**
67
85
  * Data definition for an addToWishlist event within the unified tracking system
68
86
  * @typedef {Object} UnifiedAddToWishlist
69
87
  * @property {UnifiedAddToWishlistItem[]} items Array of unified wishlist items
70
88
  * @property {UnifiedRestrictions} [restrictions] Restrictions for the command
71
- */ /**
89
+ */
90
+
91
+ /**
72
92
  * Data definition for an addToWishlist item within the unified tracking system
73
93
  * @typedef {Object} UnifiedAddToWishlistItem
74
94
  * @property {number} priceNet The net price of the product
@@ -80,7 +100,9 @@ import AppCommand from"../classes/AppCommand";/**
80
100
  * @property {string} type The type of the item, eg "product"
81
101
  * @property {string} name The name of the item
82
102
  * @property {string} [brand] The brand of the product
83
- */ /**
103
+ */
104
+
105
+ /**
84
106
  * Data definition for an search event within the unified tracking system
85
107
  * @typedef {Object} UnifiedSearched
86
108
  * @property {string} [query] The query string that has been used for the search
@@ -88,12 +110,16 @@ import AppCommand from"../classes/AppCommand";/**
88
110
  * @property {string} [type] The type of the content that has been searched
89
111
  * @property {number} [hits] Amount of hits, the search brought.
90
112
  * @property {UnifiedRestrictions} [restrictions] Restrictions for the command
91
- */ /**
113
+ */
114
+
115
+ /**
92
116
  * Data definition for a set campaign with url command payload within the unified tracking system
93
117
  * @typedef {Object} UnifiedSetCampaignWithUrl
94
118
  * @property {string} url The campaign url that shall be set
95
119
  * @property {UnifiedRestrictions} [restrictions] Restrictions for the command
96
- */ /**
120
+ */
121
+
122
+ /**
97
123
  * Data definition for a log item view command payload within the unified tracking system
98
124
  * @typedef {Object} UnifiedItemView
99
125
  * @property {string} id A unique identifier for the item
@@ -107,58 +133,130 @@ import AppCommand from"../classes/AppCommand";/**
107
133
  * @property {string} [categoryId] A unique identifier for the category of the item
108
134
  * @property {string} [categoryName] Category path of the item (apparel/shoes/sneakers)
109
135
  * @property {UnifiedRestrictions} [restrictions] Restrictions for the command
110
- */ /**
136
+ */
137
+
138
+ /**
111
139
  * Data definition for a log login command payload within the unified tracking system
112
140
  * @typedef {Object} UnifiedLogin
113
141
  * @property {string} type Defines the type of the login. “guest”, “facebook”.
114
142
  * @property {UnifiedRestrictions} [restrictions] Restrictions for the command
115
- */ /**
143
+ */
144
+
145
+ /**
116
146
  * Additional definitions of data for the multiple tracking events
117
- */ /**
147
+ */
148
+
149
+ /**
118
150
  * Restrictions for a unified tracking command
119
151
  * @typedef {Object} UnifiedRestrictions
120
152
  * @property {boolean} blacklist If set to TRUE, this event is not sent to the trackers named
121
153
  * in the tracker-array within this restriction object, if set to FALSE, this event is only sent
122
154
  * to the trackers in the tracker-array.
123
155
  * @property {Array} trackers List of tracker names that are concerned of this restriction
124
- */ /**
156
+ */
157
+
158
+ /**
125
159
  * Executes a unified tracking command
126
160
  * @param {string} name The name of the command
127
161
  * @param {Object} params The payload for the command
128
- */function executeCommand(){var name=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'';var params=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var command=new AppCommand();command.setCommandName(name).dispatch(params);}/**
162
+ */
163
+ function executeCommand(name = '', params = {}) {
164
+ const command = new AppCommand();
165
+ command.setCommandName(name).dispatch(params);
166
+ }
167
+
168
+ /**
129
169
  * This command can be used to log a viewContent event to all installed trackers. *
130
170
  * @param {UnifiedPageview} data The payload for the command
131
- */export function analyticsLogPageview(data){executeCommand('analyticsLogPageview',data);}/**
171
+ */
172
+ export function analyticsLogPageview(data) {
173
+ executeCommand('analyticsLogPageview', data);
174
+ }
175
+
176
+ /**
132
177
  * This command can be used to log an event to all installed trackers.
133
178
  * @param {UnifiedEvent} data The payload for the command
134
- */export function analyticsLogEvent(data){executeCommand('analyticsLogEvent',data);}/**
179
+ */
180
+ export function analyticsLogEvent(data) {
181
+ executeCommand('analyticsLogEvent', data);
182
+ }
183
+
184
+ /**
135
185
  * This command can be used to log a purchase event to all installed trackers.
136
186
  * @param {UnifiedPurchase} data The payload for the command
137
- */export function analyticsLogPurchase(data){executeCommand('analyticsLogPurchase',data);}/**
187
+ */
188
+ export function analyticsLogPurchase(data) {
189
+ executeCommand('analyticsLogPurchase', data);
190
+ }
191
+
192
+ /**
138
193
  * This command can be used to log an addToCart event to all installed trackers.
139
194
  * @param {UnifiedAddToCart} data The payload for the command
140
- */export function analyticsLogAddToCart(data){executeCommand('analyticsLogAddToCart',data);}/**
195
+ */
196
+ export function analyticsLogAddToCart(data) {
197
+ executeCommand('analyticsLogAddToCart', data);
198
+ }
199
+
200
+ /**
141
201
  * This command can be used to log an analyticsLogAddedPaymentInfo event to all installed trackers.
142
202
  * @param {UnifiedAddedPaymentInfo} data The payload for the command
143
- */export function analyticsLogAddedPaymentInfo(data){executeCommand('analyticsLogAddedPaymentInfo',data);}/**
203
+ */
204
+ export function analyticsLogAddedPaymentInfo(data) {
205
+ executeCommand('analyticsLogAddedPaymentInfo', data);
206
+ }
207
+
208
+ /**
144
209
  * This command can be used to log an initiated checkout event.
145
210
  * @param {UnifiedInitiatedCheckout} data The payload for the command
146
- */export function analyticsLogInitiatedCheckout(data){executeCommand('analyticsLogInitiatedCheckout',data);}/**
211
+ */
212
+ export function analyticsLogInitiatedCheckout(data) {
213
+ executeCommand('analyticsLogInitiatedCheckout', data);
214
+ }
215
+
216
+ /**
147
217
  * Logs which registration type was done.
148
218
  * @param {UnifiedCompletedRegistration} data The payload for the command
149
- */export function analyticsLogCompletedRegistration(data){executeCommand('analyticsLogCompletedRegistration',data);}/**
219
+ */
220
+ export function analyticsLogCompletedRegistration(data) {
221
+ executeCommand('analyticsLogCompletedRegistration', data);
222
+ }
223
+
224
+ /**
150
225
  * This command can be used to log an addToWishlist event to all installed trackers.
151
226
  * @param {UnifiedAddToWishlist} data The payload for the command
152
- */export function analyticsLogAddToWishlist(data){executeCommand('analyticsLogAddToWishlist',data);}/**
227
+ */
228
+ export function analyticsLogAddToWishlist(data) {
229
+ executeCommand('analyticsLogAddToWishlist', data);
230
+ }
231
+
232
+ /**
153
233
  * This command can be used to log a searched event to all installed trackers.
154
234
  * @param {UnifiedSearched} data The payload for the command
155
- */export function analyticsLogSearch(data){executeCommand('analyticsLogSearch',data);}/**
235
+ */
236
+ export function analyticsLogSearch(data) {
237
+ executeCommand('analyticsLogSearch', data);
238
+ }
239
+
240
+ /**
156
241
  * This command set a campaign url a user followed.
157
242
  * @param {UnifiedSetCampaignWithUrl} data The payload for the command
158
- */export function analyticsSetCampaignWithUrl(data){executeCommand('analyticsSetCampaignWithUrl',data);}/**
243
+ */
244
+ export function analyticsSetCampaignWithUrl(data) {
245
+ executeCommand('analyticsSetCampaignWithUrl', data);
246
+ }
247
+
248
+ /**
159
249
  * This command can be used to log an item view event to all installed trackers.
160
250
  * @param {UnifiedItemView} data The payload for the command
161
- */export function analyticsLogItemView(data){executeCommand('analyticsLogItemView',data);}/**
251
+ */
252
+ export function analyticsLogItemView(data) {
253
+ executeCommand('analyticsLogItemView', data);
254
+ }
255
+
256
+ /**
162
257
  * This command can be used to log a login event to all installed trackers.
163
258
  * @param {UnifiedLogin} data The payload for the command
164
- */export function analyticsLogLogin(data){executeCommand('analyticsLogLogin',data);}
259
+ */
260
+ export function analyticsLogLogin(data) {
261
+ executeCommand('analyticsLogLogin', data);
262
+ }
@@ -1 +1,6 @@
1
- export var COMMAND_SEND_PIPELINE_REQUEST='sendPipelineRequest';export var COMMAND_SEND_HTTP_REQUEST='sendHttpRequest';export var COMMAND_SEND_DATA_REQUEST='sendDataRequest';export var COMMAND_GET_WEBSTORAGE_ENTRY='getWebStorageEntry';export var COMMAND_GET_APP_PERMISSIONS='getAppPermissions';export var COMMAND_REQUEST_APP_PERMISSIONS='requestAppPermissions';
1
+ export const COMMAND_SEND_PIPELINE_REQUEST = 'sendPipelineRequest';
2
+ export const COMMAND_SEND_HTTP_REQUEST = 'sendHttpRequest';
3
+ export const COMMAND_SEND_DATA_REQUEST = 'sendDataRequest';
4
+ export const COMMAND_GET_WEBSTORAGE_ENTRY = 'getWebStorageEntry';
5
+ export const COMMAND_GET_APP_PERMISSIONS = 'getAppPermissions';
6
+ export const COMMAND_REQUEST_APP_PERMISSIONS = 'requestAppPermissions';
@@ -1 +1,9 @@
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
+ export const EVENT_KEYBOARD_WILL_CHANGE = 'keyboardWillChange';
2
+ export const APP_EVENT_VIEW_DID_APPEAR = 'viewDidAppear';
3
+ export const APP_EVENT_VIEW_WILL_APPEAR = 'viewWillAppear';
4
+ export const APP_EVENT_VIEW_WILL_DISAPPEAR = 'viewWillDisappear';
5
+ export const APP_EVENT_VIEW_DID_DISAPPEAR = 'viewDidDisappear';
6
+ export const APP_EVENT_APPLICATION_WILL_ENTER_FOREGROUND = 'applicationWillEnterForeground';
7
+ export const APP_EVENT_SCANNER_DID_SCAN = 'scannerDidScan';
8
+ export const APP_EVENT_SCANNER_DID_APPEAR = 'scannerDidAppear';
9
+ export const APP_EVENT_SCANNER_DID_DISAPPEAR = 'scannerDidDisappear';