@shopgate/pwa-common 7.12.3-beta.1 → 7.20.0-beta.1

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 (88) hide show
  1. package/App.js +6 -6
  2. package/actions/app/handleLink.js +7 -5
  3. package/actions/client/fetchClientInformation.js +1 -1
  4. package/actions/page/fetchPageConfig.js +2 -2
  5. package/actions/user/login.js +2 -2
  6. package/collections/AuthRoutes.js +3 -3
  7. package/collections/Configuration.js +3 -3
  8. package/collections/EmbeddedMedia.js +2 -2
  9. package/collections/PersistedReducers.js +2 -2
  10. package/collections/Redirects.js +3 -3
  11. package/collections/media-providers/MediaProvider.js +2 -2
  12. package/collections/media-providers/Vimeo.js +7 -7
  13. package/collections/media-providers/YouTube.js +5 -5
  14. package/components/Backdrop/index.js +11 -11
  15. package/components/Button/index.js +7 -7
  16. package/components/Checkbox/index.js +27 -14
  17. package/components/CountdownTimer/index.js +7 -7
  18. package/components/Drawer/index.js +13 -13
  19. package/components/Dropdown/index.js +5 -5
  20. package/components/Ellipsis/index.js +1 -1
  21. package/components/ErrorBoundary/index.js +5 -5
  22. package/components/Grid/components/Item/index.js +4 -4
  23. package/components/Grid/index.js +4 -4
  24. package/components/HtmlSanitizer/connector.js +5 -0
  25. package/components/HtmlSanitizer/index.js +10 -10
  26. package/components/HtmlSanitizer/spec.js +3 -3
  27. package/components/I18n/components/FormatPrice/index.js +2 -2
  28. package/components/I18n/components/I18nProvider/index.js +9 -9
  29. package/components/I18n/components/Translate/index.js +11 -7
  30. package/components/Icon/index.js +1 -1
  31. package/components/Image/index.js +9 -9
  32. package/components/Image/spec.js +2 -2
  33. package/components/InfiniteContainer/index.js +21 -21
  34. package/components/Input/components/DateInput.js +2 -2
  35. package/components/Input/components/MultiLineInput.js +10 -10
  36. package/components/Input/components/SimpleInput.js +27 -21
  37. package/components/KeyboardConsumer/index.js +7 -7
  38. package/components/Link/index.js +8 -5
  39. package/components/List/components/Item/index.js +1 -1
  40. package/components/List/index.js +1 -1
  41. package/components/Modal/index.js +1 -1
  42. package/components/Modal/style.js +1 -1
  43. package/components/Picker/components/List/index.js +1 -1
  44. package/components/Picker/components/Modal/index.js +7 -7
  45. package/components/Picker/index.js +19 -9
  46. package/components/Portal/index.js +15 -11
  47. package/components/ProductCharacteristics/helpers/index.js +1 -1
  48. package/components/ProductCharacteristics/index.js +27 -12
  49. package/components/RangeSlider/index.js +33 -24
  50. package/components/Route/RouteNotFound.js +3 -3
  51. package/components/Route/index.js +5 -5
  52. package/components/Router/index.js +18 -10
  53. package/components/ScannerContainer/index.js +3 -3
  54. package/components/Select/index.js +25 -15
  55. package/components/SelectBox/components/Item/index.js +5 -3
  56. package/components/SelectBox/index.js +17 -8
  57. package/components/Swiper/components/SwiperItem/spec.js +1 -1
  58. package/components/Swiper/index.js +3 -3
  59. package/components/Swiper/styles.js +4 -1
  60. package/components/Transition/index.js +4 -4
  61. package/components/Widgets/components/Widget/index.js +4 -4
  62. package/components/Widgets/components/WidgetGrid/index.js +5 -5
  63. package/components/Widgets/index.js +7 -7
  64. package/components/index.js +1 -2
  65. package/constants/Configuration.js +1 -1
  66. package/constants/Device.js +2 -2
  67. package/constants/Portals.js +2 -2
  68. package/helpers/config/mock.js +2 -2
  69. package/helpers/config/theme.js +2 -2
  70. package/helpers/i18n/getTranslator.js +10 -4
  71. package/helpers/portals/portalCollection.js +3 -3
  72. package/helpers/redux/mutable.js +3 -2
  73. package/helpers/redux/shouldFetchData.js +1 -1
  74. package/helpers/style/index.js +2 -2
  75. package/package.json +4 -4
  76. package/providers/loading/index.js +24 -14
  77. package/providers/toast/index.js +10 -8
  78. package/reducers/page/index.js +1 -1
  79. package/reducers/router/index.js +1 -1
  80. package/selectors/client.js +9 -7
  81. package/streams/app.js +8 -2
  82. package/streams/main.js +1 -1
  83. package/streams/view.js +12 -0
  84. package/subscriptions/error.js +4 -4
  85. package/subscriptions/helpers/handleLinks.js +2 -2
  86. package/subscriptions/menu.js +4 -2
  87. package/subscriptions/router.js +6 -6
  88. package/subscriptions/user.js +1 -1
@@ -1,13 +1,15 @@
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 _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}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 _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}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 React,{Component}from'react';import PropTypes from'prop-types';import{UIEvents}from'@shopgate/pwa-core';import{themeConfig}from'@shopgate/pwa-common/helpers/config';import ToastContext from"./context";var _themeConfig$variable=themeConfig.variables;_themeConfig$variable=_themeConfig$variable===void 0?{}:_themeConfig$variable;var _themeConfig$variable2=_themeConfig$variable.toast;_themeConfig$variable2=_themeConfig$variable2===void 0?{}:_themeConfig$variable2;var _themeConfig$variable3=_themeConfig$variable2.duration,duration=_themeConfig$variable3===void 0?5000:_themeConfig$variable3;/**
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);}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 React,{Component}from'react';import PropTypes from'prop-types';import{UIEvents}from'@shopgate/pwa-core';import{themeConfig}from'@shopgate/pwa-common/helpers/config';import ToastContext from"./context";var _themeConfig$variable=themeConfig.variables,_themeConfig$variable2=_themeConfig$variable===void 0?{}:_themeConfig$variable,_themeConfig$variable3=_themeConfig$variable2.toast,_themeConfig$variable4=_themeConfig$variable3===void 0?{}:_themeConfig$variable3,_themeConfig$variable5=_themeConfig$variable4.duration,duration=_themeConfig$variable5===void 0?5000:_themeConfig$variable5;/**
2
2
  * The ToastProvider component
3
- */var ToastProvider=/*#__PURE__*/function(_Component){_inherits(ToastProvider,_Component);function ToastProvider(props){var _this;_classCallCheck(this,ToastProvider);_this=_possibleConstructorReturn(this,_getPrototypeOf(ToastProvider).call(this,props));_defineProperty(_assertThisInitialized(_this),"addToast",function(toast){if(!toast.message){return;}var toasts=_this.state.toasts;// Check if the toast id already is present.
3
+ */var ToastProvider=/*#__PURE__*/function(_Component){function ToastProvider(props){var _this2;_classCallCheck(this,ToastProvider);_this2=_callSuper(this,ToastProvider,[props]);/**
4
+ * Adds a new, unique, toast to the list.
5
+ * @param {Object} toast The toast object to add.
6
+ */_defineProperty(_this2,"addToast",function(toast){if(!toast.message){return;}var toasts=_this2.state.toasts;// Check if the toast id already is present.
4
7
  var found=toasts.find(function(_ref){var id=_ref.id;return toast.id===id;});// If found, update the toast with the new data.
5
- if(found){found.action=toast.action;found.actionLabel=toast.actionLabel;found.message=toast.message;found.messageParams=toast.messageParams;found.duration=toast.duration||duration;}else{toasts.push({id:toast.id,action:toast.action,actionLabel:toast.actionLabel,message:toast.message,messageParams:toast.messageParams,duration:toast.duration||duration});}_this.setState({toasts:toasts});});_defineProperty(_assertThisInitialized(_this),"removeToast",function(){var toasts=_this.state.toasts;toasts.shift();_this.setState({toasts:toasts});});_defineProperty(_assertThisInitialized(_this),"flushToasts",function(){if(_this.state.toasts.length){_this.setState({toasts:[]});}});_this.state={toasts:[]};UIEvents.addListener(_this.constructor.ADD,_this.addToast);UIEvents.addListener(_this.constructor.FLUSH,_this.flushToasts);return _this;}/**
8
+ if(found){found.action=toast.action;found.actionLabel=toast.actionLabel;found.message=toast.message;found.messageParams=toast.messageParams;found.duration=toast.duration||duration;}else{toasts.push({id:toast.id,action:toast.action,actionLabel:toast.actionLabel,message:toast.message,messageParams:toast.messageParams,duration:toast.duration||duration});}_this2.setState({toasts:toasts});});/**
9
+ * Removes the first toast from the list.
10
+ */_defineProperty(_this2,"removeToast",function(){var toasts=_this2.state.toasts;toasts.shift();_this2.setState({toasts:toasts});});_defineProperty(_this2,"flushToasts",function(){if(_this2.state.toasts.length){_this2.setState({toasts:[]});}});_this2.state={toasts:[]};UIEvents.addListener(_this2.constructor.ADD,_this2.addToast);UIEvents.addListener(_this2.constructor.FLUSH,_this2.flushToasts);return _this2;}/**
6
11
  * Returns the context value to be passed to consumers.
7
12
  * @returns {Object}
8
- */_createClass(ToastProvider,[{key:"render",/**
13
+ */_inherits(ToastProvider,_Component);return _createClass(ToastProvider,[{key:"provided",get:function get(){return{addToast:this.addToast,removeToast:this.removeToast,toasts:this.state.toasts};}},{key:"render",value:/**
9
14
  * @returns {JSX}
10
- */value:function render(){return React.createElement(ToastContext.Provider,{value:this.provided},this.props.children);}},{key:"provided",get:function get(){return{addToast:this.addToast,removeToast:this.removeToast,toasts:this.state.toasts};}/**
11
- * Adds a new, unique, toast to the list.
12
- * @param {Object} toast The toast object to add.
13
- */}]);return ToastProvider;}(Component);_defineProperty(ToastProvider,"ADD",'toast_add');_defineProperty(ToastProvider,"FLUSH",'toast_flush');export default ToastProvider;
15
+ */function render(){return React.createElement(ToastContext.Provider,{value:this.provided},this.props.children);}}]);}(Component);_defineProperty(ToastProvider,"ADD",'toast_add');_defineProperty(ToastProvider,"FLUSH",'toast_flush');export default ToastProvider;
@@ -9,4 +9,4 @@ function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="s
9
9
  * @return {Object} The store data.
10
10
  */export default function pageReducer(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var action=arguments.length>1?arguments[1]:undefined;switch(action.type){case REQUEST_PAGE_CONFIG:return _extends({},state,_defineProperty({},action.pageId,_extends({},state[action.pageId],{isFetching:true,expires:0})));case RECEIVE_PAGE_CONFIG:{return _extends({},state,_defineProperty({},action.pageId,{title:action.config.title,widgets:enrichWidgets(action),isFetching:false,expires:Date.now()+3600000// One hour
11
11
  }));}case ERROR_PAGE_CONFIG:{if(action.errorCode===ENOTFOUND){// Remove the temporary page entry from the state when noting was found for the pageId.
12
- var _action$pageId=action.pageId,ignore=state[_action$pageId],rest=_objectWithoutProperties(state,[_action$pageId].map(_toPropertyKey));return rest;}return _extends({},state,_defineProperty({},action.pageId,_extends({},state[action.pageId],{isFetching:false,expires:0})));}case APP_WILL_START:{return Object.keys(state).reduce(function(acc,pageId){acc[pageId].expires=0;return acc;},_extends({},state));}default:return state;}}
12
+ var _action$pageId2=action.pageId,ignore=state[_action$pageId2],rest=_objectWithoutProperties(state,[_action$pageId2].map(_toPropertyKey));return rest;}return _extends({},state,_defineProperty({},action.pageId,_extends({},state[action.pageId],{isFetching:false,expires:0})));}case APP_WILL_START:{return Object.keys(state).reduce(function(acc,pageId){acc[pageId].expires=0;return acc;},_extends({},state));}default:return state;}}
@@ -2,4 +2,4 @@ function _extends(){_extends=Object.assign||function(target){for(var i=1;i<argum
2
2
  * @param {Object} state The current state.
3
3
  * @param {Object} action The action object.
4
4
  * @returns {Object}
5
- */export default function router(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:defaultState;var action=arguments.length>1?arguments[1]:undefined;switch(action.type){case ROUTE_WILL_LEAVE:case ROUTE_DID_LEAVE:{return _extends({},state,{stack:Array.from(stack.getAll().values())});}case ROUTE_WILL_ENTER:case ROUTE_DID_ENTER:return _extends({},state,{stack:Array.from(stack.getAll().values()),currentRoute:cloneDeep(action.route)});case ROUTE_DID_UPDATE:{var _ref=state.currentRoute||{},currentId=_ref.id;var updatedId=action.route.id;if(currentId===updatedId){return _extends({},state,{stack:Array.from(stack.getAll().values()),currentRoute:cloneDeep(action.route)});}return state;}default:return state;}}
5
+ */export default function router(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:defaultState;var action=arguments.length>1?arguments[1]:undefined;switch(action.type){case ROUTE_WILL_LEAVE:case ROUTE_DID_LEAVE:{return _extends({},state,{stack:Array.from(stack.getAll().values())});}case ROUTE_WILL_ENTER:case ROUTE_DID_ENTER:return _extends({},state,{stack:Array.from(stack.getAll().values()),currentRoute:cloneDeep(action.route)});case ROUTE_DID_UPDATE:{var _ref2=state.currentRoute||{},currentId=_ref2.id;var updatedId=action.route.id;if(currentId===updatedId){return _extends({},state,{stack:Array.from(stack.getAll().values()),currentRoute:cloneDeep(action.route)});}return state;}default:return state;}}
@@ -1,4 +1,4 @@
1
- import{createSelector}from'reselect';import MobileDetect from'mobile-detect';import{hasSGJavaScriptBridge}from'@shopgate/pwa-core/helpers';import{isVersionAtLeast}from'@shopgate/pwa-core/helpers/version';import{SCANNER_MIN_APP_LIB_VERSION}from'@shopgate/pwa-core/constants/Scanner';import{hasWebBridge}from'@shopgate/engage/core/helpers/bridge';import{OS_ANDROID,OS_IOS,MODEL_NAMES_IPHONE_X,PAGE_INSETS_ANDROID,PAGE_INSETS_IOS,PAGE_INSETS_IPHONE_X}from"../constants/Device";var md=new MobileDetect(navigator.userAgent);/**
1
+ import{createSelector}from'reselect';import MobileDetect from'mobile-detect';import{hasSGJavaScriptBridge}from'@shopgate/pwa-core/helpers';import{isVersionAtLeast}from'@shopgate/pwa-core/helpers/version';import{SCANNER_MIN_APP_LIB_VERSION}from'@shopgate/pwa-core/constants/Scanner';import{hasWebBridge}from'@shopgate/engage/core/helpers/bridge';import{OS_ANDROID,OS_IOS,MODEL_NAMES_IPHONE_X,PAGE_INSETS_ANDROID,PAGE_INSETS_IOS,PAGE_INSETS_IPHONE_X,TYPE_TABLET}from"../constants/Device";var md=new MobileDetect(navigator.userAgent);/**
2
2
  * Returns the client state (state.client)
3
3
  * @param {Object} state The application state.
4
4
  * @returns {Object}
@@ -22,17 +22,13 @@ import{createSelector}from'reselect';import MobileDetect from'mobile-detect';imp
22
22
  * @param {string} service The identity service to check.
23
23
  * @returns {Function}
24
24
  */export function makeSupportsIdentityService(service){var getSupportedIdentityServices=makeGetSupportedIdentityServices();return createSelector(getSupportedIdentityServices,function(services){return services.includes(service);});}/**
25
- * Checks if the currently stored lib version is one that supports the scanner.
26
- * @param {Object} state The application state.
27
- * @returns {boolean}
28
- */export var hasScannerSupport=createSelector(getClientInformation,function(clientInformation){return!hasWebBridge()&&isVersionAtLeast(SCANNER_MIN_APP_LIB_VERSION,clientInformation.libVersion);});/**
29
25
  * Returns the device platform.
30
26
  * @param {Object} state The application state.
31
27
  * @return {string|null}
32
- */export var getPlatform=createSelector(getDeviceInformation,function(deviceInformation){var _ref=deviceInformation||{},_ref$os=_ref.os;_ref$os=_ref$os===void 0?{}:_ref$os;var _ref$os$platform=_ref$os.platform,platform=_ref$os$platform===void 0?null:_ref$os$platform;return platform;});/**
28
+ */export var getPlatform=createSelector(getDeviceInformation,function(deviceInformation){var _ref=deviceInformation||{},_ref$os=_ref.os,_ref$os2=_ref$os===void 0?{}:_ref$os,_ref$os2$platform=_ref$os2.platform,platform=_ref$os2$platform===void 0?null:_ref$os2$platform;return platform;});/**
33
29
  * Returns the os version.
34
30
  * @return {string|null}
35
- */export var getOSVersion=createSelector(getDeviceInformation,function(deviceInformation){var _ref2=deviceInformation||{},_ref2$os=_ref2.os;_ref2$os=_ref2$os===void 0?{}:_ref2$os;var _ref2$os$ver=_ref2$os.ver,ver=_ref2$os$ver===void 0?null:_ref2$os$ver;return ver;});/**
31
+ */export var getOSVersion=createSelector(getDeviceInformation,function(deviceInformation){var _ref2=deviceInformation||{},_ref2$os=_ref2.os,_ref2$os2=_ref2$os===void 0?{}:_ref2$os,_ref2$os2$ver=_ref2$os2.ver,ver=_ref2$os2$ver===void 0?null:_ref2$os2$ver;return ver;});/**
36
32
  * Returns the device model.
37
33
  * @param {Object} state The application state.
38
34
  * @return {string|null}
@@ -45,6 +41,12 @@ import{createSelector}from'reselect';import MobileDetect from'mobile-detect';imp
45
41
  * @param {Object} state The application state.
46
42
  * @return {boolean}
47
43
  */export var isIos=createSelector(getPlatform,function(platform){return platform===OS_IOS;});/**
44
+ * Checks if the currently stored lib version is one that supports the scanner.
45
+ * @param {Object} state The application state.
46
+ * @returns {boolean}
47
+ */export var hasScannerSupport=createSelector(getClientInformation,getDeviceInformation,isIos,function(clientInformation,deviceInformation,deviceIsIos){var _ref4=deviceInformation||{},type=_ref4.type;var isIpad=type===TYPE_TABLET&&deviceIsIos;if(isVersionAtLeast('11.0.0',clientInformation.appVersion)){// scanner is supported on all apps based on the react-native based apps
48
+ return true;}// scanner is not supported on iPads with the not react-native based app
49
+ return isVersionAtLeast(SCANNER_MIN_APP_LIB_VERSION,clientInformation.libVersion)&&!isIpad;});/**
48
50
  * Determines page insets for the current device
49
51
  * @param {Object} state The application state.
50
52
  * @returns {Object}
package/streams/app.js CHANGED
@@ -1,4 +1,4 @@
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{getCurrentRoute}from"../selectors/router";import{APP_WILL_INIT,APP_DID_START,APP_WILL_START,PWA_DID_APPEAR,PWA_DID_DISAPPEAR}from"../constants/ActionTypes";import{main$}from"./main";export var appWillInit$=main$.filter(function(_ref){var action=_ref.action;return action.type===APP_WILL_INIT;});/**
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{getCurrentRoute}from"../selectors/router";import{APP_WILL_INIT,APP_DID_START,APP_WILL_START,PWA_DID_APPEAR,PWA_DID_DISAPPEAR,OPEN_PUSH_NOTIFICATION,OPEN_UNIVERSAL_LINK,OPEN_DEEP_LINK}from"../constants/ActionTypes";import{main$}from"./main";export var appWillInit$=main$.filter(function(_ref){var action=_ref.action;return action.type===APP_WILL_INIT;});/**
2
2
  * Gets triggered before the app starts.
3
3
  * @type {Observable}
4
4
  */export var appWillStart$=main$.filter(function(_ref2){var action=_ref2.action;return action.type===APP_WILL_START;});/**
@@ -8,4 +8,10 @@ function _extends(){_extends=Object.assign||function(target){for(var i=1;i<argum
8
8
  * Emits when the PWA appeared again after navigating back from a legacy page.
9
9
  */export var pwaDidAppear$=main$.filter(function(_ref4){var action=_ref4.action;return action.type===PWA_DID_APPEAR;}).map(function(params){return _extends({},params,{action:_extends({},params.action,{route:getCurrentRoute(params.getState())})});});/**
10
10
  * Emits when the PWA disappears
11
- */export var pwaDidDisappear$=main$.filter(function(_ref5){var action=_ref5.action;return action.type===PWA_DID_DISAPPEAR;}).map(function(params){return _extends({},params,{action:_extends({},params.action,{route:getCurrentRoute(params.getState())})});});
11
+ */export var pwaDidDisappear$=main$.filter(function(_ref5){var action=_ref5.action;return action.type===PWA_DID_DISAPPEAR;}).map(function(params){return _extends({},params,{action:_extends({},params.action,{route:getCurrentRoute(params.getState())})});});/**
12
+ * Emits when a push message was opened.
13
+ */export var pushNotificationOpened$=main$.filter(function(_ref6){var action=_ref6.action;return action.type===OPEN_PUSH_NOTIFICATION;});/**
14
+ * Emits when a universal link was opened.
15
+ */export var universalLinkOpened$=main$.filter(function(_ref7){var action=_ref7.action;return action.type===OPEN_UNIVERSAL_LINK;});/**
16
+ * Emits when a deeplink was opened.
17
+ */export var deeplinkOpened$=main$.filter(function(_ref8){var action=_ref8.action;return action.type===OPEN_DEEP_LINK;});
package/streams/main.js CHANGED
@@ -1,4 +1,4 @@
1
- import{Observable}from'rxjs/Observable';import'rxjs/add/observable/from';import'rxjs/add/operator/buffer';import'rxjs/add/operator/filter';import'rxjs/add/operator/first';import'rxjs/add/operator/map';import'rxjs/add/operator/merge';import'rxjs/add/operator/mergeMap';import'rxjs/add/operator/delay';import'rxjs/add/operator/zip';import'rxjs/add/operator/do';import'rxjs/add/operator/shareReplay';import'rxjs/add/operator/distinctUntilChanged';import'rxjs/add/operator/debounceTime';import'rxjs/add/operator/switchMap';import'rxjs/add/operator/withLatestFrom';import'rxjs/add/operator/startWith';import{mainSubject}from"../store/middelwares/streams";/**
1
+ import{Observable}from'rxjs/Observable';import'rxjs/add/observable/from';import'rxjs/add/operator/buffer';import'rxjs/add/operator/bufferTime';import'rxjs/add/operator/filter';import'rxjs/add/operator/first';import'rxjs/add/operator/map';import'rxjs/add/operator/merge';import'rxjs/add/operator/mergeMap';import'rxjs/add/operator/delay';import'rxjs/add/operator/zip';import'rxjs/add/operator/do';import'rxjs/add/operator/shareReplay';import'rxjs/add/operator/distinctUntilChanged';import'rxjs/add/operator/pairwise';import'rxjs/add/operator/debounceTime';import'rxjs/add/operator/switchMap';import'rxjs/add/operator/withLatestFrom';import'rxjs/add/operator/startWith';import{mainSubject}from"../store/middelwares/streams";/**
2
2
  * Gets triggered on every redux action that is dispatched.
3
3
  * @type {Observable}
4
4
  */export var main$=Observable.from(mainSubject);if(window.Cypress){window.main$=main$;}
@@ -0,0 +1,12 @@
1
+ import{Observable}from'rxjs/Observable';import{Subject}from'rxjs/Subject';import{async as asyncScheduler}from'rxjs/scheduler/async';import'rxjs/add/observable/from';import'rxjs/add/observable/fromEvent';import'rxjs/add/operator/do';import'rxjs/add/operator/throttleTime';export var eventsSubject=new Subject();/**
2
+ * Cold observable for View scroll events
3
+ * @type {Observable}
4
+ */export var viewScroll$=Observable.from(eventsSubject);/**
5
+ * @param {HTMLElement} element .
6
+ * @param {number} throttleTime .
7
+ * @returns {Observable}
8
+ */export var emitScrollEvents=function emitScrollEvents(element){var throttleTime=arguments.length>1&&arguments[1]!==undefined?arguments[1]:250;// In rare situation during unmounting a react dom ref might
9
+ // be null due to the execution order of events in fiber nodes.
10
+ if(!element){return undefined;}var previousScrollTop=0;var scroll$=Observable.fromEvent(element,'scroll').throttleTime(throttleTime,asyncScheduler,{leading:false,trailing:true}).map(function(event){var scrollTop=element.scrollY||element.scrollTop;return{event:event,scrollTop:scrollTop,previousScrollTop:previousScrollTop,scrolled:previousScrollTop!==scrollTop,scrollOut:previousScrollTop<scrollTop,scrollIn:previousScrollTop>=scrollTop};})["do"](function(event){// Remember scroll position for next event
11
+ previousScrollTop=event.scrollTop;});// Copy all events to viewScroll$ stream
12
+ scroll$.subscribe(viewScroll$);return scroll$;};
@@ -1,15 +1,15 @@
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);}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 after from'lodash/after';import before from'lodash/before';import over from'lodash/over';import{isAvailable}from'@shopgate/native-modules';import{init,addBreadcrumb,configureScope,captureException,captureMessage,captureEvent,withScope,Severity as SentrySeverity}from'@sentry/browser';import{EBIGAPI,emitter,errorManager,ETIMEOUT,ENETUNREACH,EUNKNOWN}from'@shopgate/pwa-core';import{hasWebBridge}from'@shopgate/engage/core';import{SOURCE_TRACKING,SOURCE_CONSOLE,Severity}from'@shopgate/pwa-core/constants/ErrorManager';import{main$}from"../streams/main";import{// eslint-disable-next-line import/no-named-default
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);}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 after from'lodash/after';import before from'lodash/before';import over from'lodash/over';import{isAvailable}from'@shopgate/native-modules';import{init,addBreadcrumb,configureScope,captureException,captureMessage,captureEvent,withScope,Severity as SentrySeverity}from'@sentry/browser';import{EBIGAPI,emitter,errorManager,ETIMEOUT,ENETUNREACH,EUNKNOWN,EFAVORITE}from'@shopgate/pwa-core';import{hasWebBridge}from'@shopgate/engage/core';import{SOURCE_TRACKING,SOURCE_CONSOLE,Severity}from'@shopgate/pwa-core/constants/ErrorManager';import{main$}from"../streams/main";import{// eslint-disable-next-line import/no-named-default
2
2
  default as appConfig,themeName,pckVersion}from"../helpers/config";import{env}from"../helpers/environment";import{transformGeneralPipelineError}from"./helpers/pipeline";import{historyPop}from"../actions/router";import showModal from"../actions/modal/showModal";import{getUserData}from"../selectors/user";import{userDidUpdate$}from"../streams/user";import{clientInformationDidUpdate$}from"../streams/client";import{appWillInit$,appWillStart$,appDidStart$}from"../streams/app";import{appError$,pipelineError$}from"../streams/error";import{getRouterStack}from"../selectors/router";import{MODAL_PIPELINE_ERROR}from"../constants/ModalTypes";import ToastProvider from"../providers/toast";/**
3
3
  * App errors subscriptions.
4
4
  * @param {Function} subscribe The subscribe function.
5
- */export default(function(subscribe){var _severityMap;/** Set general error transformations */subscribe(appWillStart$,function(){errorManager.setMessage({code:EUNKNOWN,message:transformGeneralPipelineError}).setMessage({code:EBIGAPI,message:transformGeneralPipelineError}).setMessage({code:ETIMEOUT,message:'modal.body_error'}).setMessage({code:ENETUNREACH,message:'modal.body_error'});});/** Show a message to the user in case of pipeline error */subscribe(pipelineError$,function(_ref){var dispatch=_ref.dispatch,getState=_ref.getState,events=_ref.events,action=_ref.action;var error=action.error;var message=error.message,code=error.code,context=error.context,_error$meta=error.meta,meta=_error$meta===void 0?{}:_error$meta;var behavior=meta.behavior;if(behavior){behavior({dispatch:dispatch,getState:getState,events:events,error:error});return;}/** Show modal thunk */var showModalError=function showModalError(){dispatch(showModal({confirm:'modal.ok',dismiss:null,title:null,message:message,type:MODAL_PIPELINE_ERROR,params:{pipeline:context,request:meta.input,message:meta.message,code:code}}));};var shouldShowToast=message==='error.general';if([ETIMEOUT,ENETUNREACH].includes(code)&&message==='modal.body_error'){shouldShowToast=true;}// It was transformed general error. let it popup after 10 toast clicks
5
+ */export default(function(subscribe){/** Set general error transformations */subscribe(appWillStart$,function(){errorManager.setMessage({code:EUNKNOWN,message:transformGeneralPipelineError}).setMessage({code:EBIGAPI,message:transformGeneralPipelineError}).setMessage({code:ETIMEOUT,message:'modal.body_error'}).setMessage({code:ENETUNREACH,message:'modal.body_error'}).setMessage({code:EFAVORITE,message:'favorites.error_general'});});/** Show a message to the user in case of pipeline error */subscribe(pipelineError$,function(_ref){var dispatch=_ref.dispatch,getState=_ref.getState,events=_ref.events,action=_ref.action;var error=action.error;var message=error.message,code=error.code,context=error.context,_error$meta=error.meta,meta=_error$meta===void 0?{}:_error$meta;var behavior=meta.behavior;if(behavior){behavior({dispatch:dispatch,getState:getState,events:events,error:error});return;}/** Show modal thunk */var showModalError=function showModalError(){dispatch(showModal({confirm:'modal.ok',dismiss:null,title:null,message:message,type:MODAL_PIPELINE_ERROR,params:{pipeline:context,request:meta.input,message:meta.message,code:code}}));};var shouldShowToast=message==='error.general';if([ETIMEOUT,ENETUNREACH].includes(code)&&message==='modal.body_error'){shouldShowToast=true;}// It was transformed general error. let it popup after 10 toast clicks
6
6
  if(shouldShowToast){var showToastAfter=after(9,showModalError);// Recursively show same toast message until clicked 10 times
7
7
  var showToast=before(10,function(){events.emit(ToastProvider.ADD,{id:'pipeline.error',message:'error.general',action:over([showToast,showToastAfter])});});showToast();return;}showModalError();});// This subscription is always active despite sentry activation
8
8
  subscribe(appError$,function(_ref2){var dispatch=_ref2.dispatch;// Show modal to user
9
9
  dispatch(showModal({confirm:null,message:'modal.body_error',title:'modal.title_error'}));dispatch(historyPop());});var _appConfig$sentry=appConfig.sentry,enabled=_appConfig$sentry.enabled,level=_appConfig$sentry.level,sampleRate=_appConfig$sentry.sampleRate;// Is not enabled
10
- if(!enabled){return;}var severityMap=(_severityMap={},_defineProperty(_severityMap,Severity.Fatal,SentrySeverity.Fatal),_defineProperty(_severityMap,Severity.Error,SentrySeverity.Error),_defineProperty(_severityMap,Severity.Critical,SentrySeverity.Critical),_defineProperty(_severityMap,Severity.Warning,SentrySeverity.Warning),_defineProperty(_severityMap,Severity.Info,SentrySeverity.Info),_defineProperty(_severityMap,Severity.Debug,SentrySeverity.Debug),_severityMap);var ignoredDefaultBreadcrumbs=['console','fetch','xhr','ui.click'];var trackedSeverities=Object.getOwnPropertySymbols(severityMap).map(function(s){return severityMap[s];});var minSeverityIndex=trackedSeverities.indexOf(level);if(minSeverityIndex>-1){trackedSeverities=trackedSeverities.slice(0,minSeverityIndex+1);}subscribe(appWillInit$,function(_ref3){var getState=_ref3.getState;init({dsn:'https://1a444b262ac6405594ab33fb0102b377@sentry.io/1398210',environment:appConfig.omniStage||env,debug:env==='development',release:pckVersion,attachStacktrace:true,sampleRate:sampleRate,beforeBreadcrumb:function beforeBreadcrumb(breadcrumb){if(ignoredDefaultBreadcrumbs.includes(breadcrumb.category)){return null;}return breadcrumb;},beforeSend:function beforeSend(event){if(event.level&&!trackedSeverities.includes(event.level)){return null;}// eslint-disable-next-line no-param-reassign
10
+ if(!enabled){return;}var severityMap=_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({},Severity.Fatal,SentrySeverity.Fatal),Severity.Error,SentrySeverity.Error),Severity.Critical,SentrySeverity.Critical),Severity.Warning,SentrySeverity.Warning),Severity.Info,SentrySeverity.Info),Severity.Debug,SentrySeverity.Debug);var ignoredDefaultBreadcrumbs=['console','fetch','xhr','ui.click'];var trackedSeverities=Object.getOwnPropertySymbols(severityMap).map(function(s){return severityMap[s];});var minSeverityIndex=trackedSeverities.indexOf(level);if(minSeverityIndex>-1){trackedSeverities=trackedSeverities.slice(0,minSeverityIndex+1);}subscribe(appWillInit$,function(_ref3){var getState=_ref3.getState;init({dsn:'https://1a444b262ac6405594ab33fb0102b377@sentry.io/1398210',environment:appConfig.omniStage||env,debug:env==='development',release:pckVersion,attachStacktrace:true,sampleRate:sampleRate,beforeBreadcrumb:function beforeBreadcrumb(breadcrumb){if(ignoredDefaultBreadcrumbs.includes(breadcrumb.category)){return null;}return breadcrumb;},beforeSend:function beforeSend(event){if(event.level&&!trackedSeverities.includes(event.level)){return null;}// eslint-disable-next-line no-param-reassign
11
11
  event.extra=_extends({},event.extra||{},{routerStack:getRouterStack(getState()).slice(-5)});return event;}});configureScope(function(scope){scope.setTag('marketId',appConfig.marketId);scope.setTag('appId',appConfig.appId);scope.setTag('pwaVersion',pckVersion);scope.setTag('theme',themeName);scope.setTag('language',appConfig.language);scope.setTag('isWebsite',hasWebBridge());scope.setTag('isReactNativeApp',isAvailable());scope.setTag('merchantCode',appConfig.omniMerchantCode);});if(window){window.onerror=function(message,source,lineno,colno,error){captureException(error);};}emitter.addListener(SOURCE_TRACKING,function(error){withScope(function(scope){if(error.context){scope.setExtra('trackerName',error.context);}captureException(error);});});emitter.addListener(SOURCE_CONSOLE,function(args){withScope(function(scope){scope.setLevel(SentrySeverity.Error);scope.setExtra('error',args);captureMessage('Console error');});});});subscribe(main$,function(_ref4){var action=_ref4.action;addBreadcrumb({category:'redux',message:"[Redux] ".concat(action.type),level:SentrySeverity.Info,data:_extends({},action)});});subscribe(userDidUpdate$,function(_ref5){var getState=_ref5.getState;var _getUserData=getUserData(getState()),userId=_getUserData.id;configureScope(function(scope){scope.setTag('userId',userId);});});// Add client lib versions
12
12
  subscribe(clientInformationDidUpdate$,function(_ref6){var action=_ref6.action;var _action$data=action.data,appVersion=_action$data.appVersion,libVersion=_action$data.libVersion,deviceId=_action$data.deviceId;configureScope(function(scope){scope.setTag('appVersion',appVersion);scope.setTag('libVersion',libVersion);scope.setTag('deviceId',deviceId);});});// Add app start event for debugging
13
13
  subscribe(appDidStart$,function(){withScope(function(scope){scope.setLevel(SentrySeverity.Debug);captureMessage('App did start');});});// Add some stack trace and log to sentry
14
14
  subscribe(appError$,function(_ref7){var action=_ref7.action;withScope(function(scope){if(action.error.stack){scope.setExtra('stack',action.error.stack);}captureException(action.error);});});var allErrors$=pipelineError$.merge(appError$);// Log all error messages which are presented to the user
15
- subscribe(allErrors$,function(_ref8){var action=_ref8.action;withScope(function(scope){scope.setTag('error','E_USER');scope.setTag('errorCode',action.error.code);scope.setTag('errorMessage',action.error.message);captureEvent({message:action.error.meta.message,extra:action.error});});});});
15
+ subscribe(allErrors$,function(_ref8){var action=_ref8.action;var _action$error=action.error,error=_action$error===void 0?{}:_action$error;var code=error.code,message=error.message,_error$meta2=error.meta,_error$meta3=_error$meta2===void 0?{}:_error$meta2,metaMessage=_error$meta3.message;withScope(function(scope){scope.setTag('error','E_USER');scope.setTag('errorCode',code);scope.setTag('errorMessage',message);captureEvent({message:metaMessage||message,extra:error});});});});
@@ -1,4 +1,4 @@
1
- import{router,ACTION_REPLACE}from'@virtuous/conductor';import flushTab from'@shopgate/pwa-core/commands/flushTab';import openPage from'@shopgate/pwa-core/commands/openPage';import showTab from'@shopgate/pwa-core/commands/showTab';import{openPageExtern}from'@shopgate/pwa-core';import{logger,hasSGJavaScriptBridge}from'@shopgate/pwa-core/helpers';import appConfig from'@shopgate/pwa-common/helpers/config';import{IS_CONNECT_EXTENSION_ATTACHED}from'@shopgate/pwa-common/constants/Configuration';import configuration from'@shopgate/pwa-common/collections/Configuration';import{hasWebBridge}from'@shopgate/engage/core';import{getCurrentRoute}from'@shopgate/pwa-common/selectors/router';import authRoutes from"../../collections/AuthRoutes";var SHOPGATE_DOMAIN='shopgate.com';var SHOPGATEPG_DOMAIN='shopgatepg.com';var SHOPGATE_DOMAINS=[SHOPGATE_DOMAIN,"www.".concat(SHOPGATE_DOMAIN)];var PROTOCOL_HTTP='http:';var PROTOCOL_HTTPS='https:';var PROTOCOL_TEL='tel:';var PROTOCOL_MAILTO='mailto:';export var LEGACY_LINK_ACCOUNT='/account';export var LEGACY_LINK_STOREFINDER='/storefinder';export var LEGACY_LINK_CHANNEL='/channel';export var LEGACY_LINK_ORDERS='/orders_legacy';export var LEGACY_LINK_CHECKOUT='/checkout_legacy';export var LEGACY_LINK_REGISTER='/register_legacy';export var LEGACY_LINK_REGISTER_GUEST='/register_legacy_guest';export var LEGACY_LINK_CONNECT_REGISTER='/connect_register';var protocols=[PROTOCOL_HTTP,PROTOCOL_HTTPS,PROTOCOL_TEL,PROTOCOL_MAILTO];var legacyPages=['/page/terms','/page/return_policy','/page/privacy','/page/imprint','/page/shipping','/page/payment','/page/warranty'];var legacyLinks=[LEGACY_LINK_ACCOUNT,LEGACY_LINK_STOREFINDER,LEGACY_LINK_CHANNEL,LEGACY_LINK_ORDERS,LEGACY_LINK_CHECKOUT,LEGACY_LINK_REGISTER,LEGACY_LINK_REGISTER_GUEST,LEGACY_LINK_CONNECT_REGISTER];/**
1
+ import{router,ACTION_REPLACE}from'@virtuous/conductor';import flushTab from'@shopgate/pwa-core/commands/flushTab';import openPage from'@shopgate/pwa-core/commands/openPage';import showTab from'@shopgate/pwa-core/commands/showTab';import{openPageExtern}from'@shopgate/pwa-core';import appConfig from'@shopgate/pwa-common/helpers/config';import{hasNewServices,hasWebBridge,logger,hasSGJavaScriptBridge}from'@shopgate/engage/core/helpers';import{getCurrentRoute}from'@shopgate/pwa-common/selectors/router';import authRoutes from"../../collections/AuthRoutes";var SHOPGATE_DOMAIN='shopgate.com';var SHOPGATEPG_DOMAIN='shopgatepg.com';var SHOPGATE_DOMAINS=[SHOPGATE_DOMAIN,"www.".concat(SHOPGATE_DOMAIN)];var PROTOCOL_HTTP='http:';var PROTOCOL_HTTPS='https:';var PROTOCOL_TEL='tel:';var PROTOCOL_MAILTO='mailto:';export var LEGACY_LINK_ACCOUNT='/account';export var LEGACY_LINK_STOREFINDER='/storefinder';export var LEGACY_LINK_CHANNEL='/channel';export var LEGACY_LINK_ORDERS='/orders_legacy';export var LEGACY_LINK_CHECKOUT='/checkout_legacy';export var LEGACY_LINK_REGISTER='/register_legacy';export var LEGACY_LINK_REGISTER_GUEST='/register_legacy_guest';export var LEGACY_LINK_CONNECT_REGISTER='/connect_register';var protocols=[PROTOCOL_HTTP,PROTOCOL_HTTPS,PROTOCOL_TEL,PROTOCOL_MAILTO];var legacyPages=['/page/terms','/page/return_policy','/page/privacy','/page/imprint','/page/shipping','/page/payment','/page/warranty'];var legacyLinks=[LEGACY_LINK_ACCOUNT,LEGACY_LINK_STOREFINDER,LEGACY_LINK_CHANNEL,LEGACY_LINK_ORDERS,LEGACY_LINK_CHECKOUT,LEGACY_LINK_REGISTER,LEGACY_LINK_REGISTER_GUEST,LEGACY_LINK_CONNECT_REGISTER];/**
2
2
  * Checks whether the location starts with a URL protocol.
3
3
  * @param {string} location The location to open.
4
4
  * @return {boolean}
@@ -18,7 +18,7 @@ import{router,ACTION_REPLACE}from'@virtuous/conductor';import flushTab from'@sho
18
18
  * Checks whether it is a legacy link.
19
19
  * @param {string} location The location to open.
20
20
  * @return {boolean}
21
- */export var isLegacyLink=function isLegacyLink(location){var hasConnectExtension=!!configuration.get(IS_CONNECT_EXTENSION_ATTACHED);if(hasConnectExtension&&[LEGACY_LINK_STOREFINDER,LEGACY_LINK_ACCOUNT].some(function(link){return location.startsWith(link);})){return false;}return!!legacyLinks.find(function(link){return location.startsWith(link);});};/**
21
+ */export var isLegacyLink=function isLegacyLink(location){if(hasNewServices()&&[LEGACY_LINK_STOREFINDER,LEGACY_LINK_ACCOUNT].some(function(link){return location.startsWith(link);})){return false;}return!!legacyLinks.find(function(link){return location.startsWith(link);});};/**
22
22
  * Checks whether it is a shop link.
23
23
  * @param {string} location The location to open.
24
24
  * @return {boolean}
@@ -1,6 +1,8 @@
1
- import{appDidStart$}from"../streams";import fetchMenu from"../actions/menu/fetchMenu";import{QUICKLINKS_MENU,LEGAL_MENU}from"../constants/MenuIDs";/**
1
+ import{hasNewServices}from'@shopgate/engage/core/helpers';import{appDidStart$}from"../streams";import fetchMenu from"../actions/menu/fetchMenu";import{QUICKLINKS_MENU,LEGAL_MENU}from"../constants/MenuIDs";/**
2
2
  * Menu subscriptions.
3
3
  * @param {Function} subscribe The subscribe function.
4
4
  */export default function menu(subscribe){/**
5
5
  * Gets triggered when the app starts.
6
- */subscribe(appDidStart$,function(_ref){var dispatch=_ref.dispatch;dispatch(fetchMenu(QUICKLINKS_MENU));dispatch(fetchMenu(LEGAL_MENU));});}
6
+ */subscribe(appDidStart$,function(_ref){var dispatch=_ref.dispatch;dispatch(fetchMenu(QUICKLINKS_MENU));// The "Legal Menu" is maintained inside the Next Admin and not available when running with
7
+ // old services
8
+ if(hasNewServices()){dispatch(fetchMenu(LEGAL_MENU));}});}
@@ -1,7 +1,7 @@
1
1
  import _regeneratorRuntime from"@babel/runtime/regenerator";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);}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 queryString from'query-string';import{router,ACTION_POP,ACTION_PUSH,ACTION_REPLACE,ACTION_RESET}from'@virtuous/conductor';import Route from'@virtuous/conductor/Route';import{HISTORY_RESET_TO}from'@shopgate/pwa-common/constants/ActionTypes';import{logger}from'@shopgate/pwa-core';import{getCurrentRoute,getRouterStackIndex}from"../selectors/router";import{LoadingProvider}from"../providers";import{redirects}from"../collections";import{navigate}from"../action-creators";import{historyRedirect,historyPush,windowOpenOverride}from"../actions/router";import*as handler from"./helpers/handleLinks";import{navigate$,userDidLogin$,appWillStart$,windowOpenOverride$}from"../streams";import{isUserLoggedIn}from"../selectors/user";import{getIsConnected}from"../selectors/client";import{INDEX_PATH}from"../constants/RoutePaths";import appConfig from"../helpers/config";import authRoutes from"../collections/AuthRoutes";import ToastProvider from"../providers/toast";/**
2
2
  * Router subscriptions.
3
3
  * @param {Function} subscribe The subscribe function.
4
- */export default function routerSubscriptions(subscribe){subscribe(navigate$,/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(params){var action,dispatch,getState,events,showConnectivityError,_action$params,silent,steps,resetToPathname,historyAction,routeState,location,state,historyLength,historyEmpty,_ref2,currentPathname,originalLocation,protector,_ref3,redirect,matcher,pathParams,queryParams,_getCurrentRoute,pathname,pattern,_ref4,transform,route,parsedLocation,parsedRedirect,stringifiedQuery,finalRedirect,parsed,_ref5,_pathname,search;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:action=params.action,dispatch=params.dispatch,getState=params.getState,events=params.events;/**
4
+ */export default function routerSubscriptions(subscribe){subscribe(navigate$,/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(params){var action,dispatch,getState,events,showConnectivityError,_action$params,silent,steps,resetToPathname,historyAction,routeState,location,state,historyLength,historyEmpty,_ref2,currentPathname,originalLocation,protector,_ref3,redirect,matcher,pathParams,queryParams,_getCurrentRoute2,pathname,pattern,_ref5,transform,route,parsedLocation,parsedRedirect,stringifiedQuery,finalRedirect,parsed,_ref7,_pathname,search;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:action=params.action,dispatch=params.dispatch,getState=params.getState,events=params.events;/**
5
5
  * Triggers a connectivity error toast message
6
6
  */showConnectivityError=function showConnectivityError(){events.emit(ToastProvider.ADD,{id:'navigate.error',message:'error.general'});};_action$params=action.params,silent=_action$params.silent,steps=_action$params.steps,resetToPathname=_action$params.pathname,historyAction=_action$params.action,routeState=_action$params.state;location=action.params.pathname;state=getState();historyLength=getRouterStackIndex(state)+1;historyEmpty=historyLength===1;_ref2=getCurrentRoute(state)||{},currentPathname=_ref2.pathname;if(!(historyEmpty&&[ACTION_POP,ACTION_RESET,HISTORY_RESET_TO].includes(historyAction))){_context.next=13;break;}if(!(currentPathname&&currentPathname===INDEX_PATH)){_context.next=11;break;}return _context.abrupt("return");case 11:/**
7
7
  * Replace the current route with the index, when a history action is supposed to be
@@ -18,16 +18,16 @@ import _regeneratorRuntime from"@babel/runtime/regenerator";function _extends(){
18
18
  if(location){_context.next=30;break;}return _context.abrupt("return");case 30:if(!(historyAction===ACTION_PUSH&&location===currentPathname)){_context.next=32;break;}return _context.abrupt("return");case 32:if(getIsConnected(state)){_context.next=35;break;}showConnectivityError();return _context.abrupt("return");case 35:if(isUserLoggedIn(state)){_context.next=40;break;}// Determine whether or not this location is protected.
19
19
  protector=authRoutes.getProtector(location);// If protected then navigate to the protector instead.
20
20
  if(!protector){_context.next=40;break;}dispatch(navigate({action:historyAction,pathname:protector,state:{redirect:{location:location,state:routeState}}}));return _context.abrupt("return");case 40:/* eslint-disable prefer-const */ // Check for a redirect and change location if one is found.
21
- _ref3=redirects.getRedirectExtended(location)||{},redirect=_ref3.handler,matcher=_ref3.matcher,pathParams=_ref3.pathParams,queryParams=_ref3.queryParams;/* eslint-enable prefer-const */if(!redirect){_context.next=66;break;}if(!(typeof redirect==='function'||redirect instanceof Promise)){_context.next=61;break;}_getCurrentRoute=getCurrentRoute(state),pathname=_getCurrentRoute.pathname;LoadingProvider.setLoading(pathname);pattern=router.findPattern(location.split('?')[0]);_ref4=router.patterns[pattern]||{},transform=_ref4.transform;route=new Route({pathname:location,pattern:pattern,routeState:routeState,transform:transform});_context.prev=48;_context.next=51;return redirect(_extends({},params,{action:_extends({},params.action,{params:_extends({},params.action.params,{// Merge the sanitized location into the redirect handler payload.
21
+ _ref3=redirects.getRedirectExtended(location)||{},redirect=_ref3.handler,matcher=_ref3.matcher,pathParams=_ref3.pathParams,queryParams=_ref3.queryParams;/* eslint-enable prefer-const */if(!redirect){_context.next=66;break;}if(!(typeof redirect==='function'||redirect instanceof Promise)){_context.next=61;break;}_getCurrentRoute2=getCurrentRoute(state),pathname=_getCurrentRoute2.pathname;LoadingProvider.setLoading(pathname);pattern=router.findPattern(location.split('?')[0]);_ref5=router.patterns[pattern]||{},transform=_ref5.transform;route=new Route({pathname:location,pattern:pattern,routeState:routeState,transform:transform});_context.prev=48;_context.next=51;return redirect(_extends({},params,{action:_extends({},params.action,{params:_extends({},params.action.params,{// Merge the sanitized location into the redirect handler payload.
22
22
  pathname:location}),route:route,redirectMeta:{location:location,matcher:matcher,pathParams:pathParams,queryParams:queryParams}})}));case 51:redirect=_context.sent;_context.next=58;break;case 54:_context.prev=54;_context.t1=_context["catch"](48);redirect=null;logger.error(_context.t1);case 58:LoadingProvider.unsetLoading(pathname);if(redirect){_context.next=61;break;}return _context.abrupt("return");case 61:// Add query parameters from the original location to the redirect
23
23
  parsedLocation=queryString.parseUrl(location);parsedRedirect=queryString.parseUrl(redirect);stringifiedQuery=queryString.stringify(_extends({},parsedLocation.query,{},parsedRedirect.query));finalRedirect=stringifiedQuery?"".concat(parsedRedirect.url,"?").concat(stringifiedQuery):parsedRedirect.url;location=finalRedirect;case 66:parsed=queryString.parseUrl(location);if(parsed.url){_context.next=70;break;}// The URL is not valid - show a toast message
24
24
  showConnectivityError();return _context.abrupt("return");case 70:// Override the location if is Shop link is found.
25
- if(handler.isShopLink(location)){_ref5=new URL(location),_pathname=_ref5.pathname,search=_ref5.search;location="".concat(_pathname).concat(search);}// If there is one of the known protocols in the url.
26
- if(!(location&&handler.hasKnownProtocols(location))){_context.next=74;break;}if(handler.isExternalLink(originalLocation)){handler.openExternalLink(originalLocation,historyAction,state,routeState);}else if(handler.isNativeLink(location)){handler.openNativeLink(location);}return _context.abrupt("return");case 74:if(!(location&&handler.isLegacyPage(location))){_context.next=77;break;}handler.openLegacy(location,historyAction,state);return _context.abrupt("return");case 77:if(!(location&&handler.isLegacyLink(location))){_context.next=80;break;}handler.openLegacyLink(location,historyAction,state);return _context.abrupt("return");case 80:_context.t2=historyAction;_context.next=_context.t2===ACTION_PUSH?83:_context.t2===ACTION_REPLACE?85:87;break;case 83:router.push({pathname:location,state:routeState,emitBefore:silent,emitAfter:silent});return _context.abrupt("break",88);case 85:router.replace({pathname:location,state:routeState,emitBefore:silent,emitAfter:silent});return _context.abrupt("break",88);case 87:return _context.abrupt("break",88);case 88:case"end":return _context.stop();}}},_callee,null,[[48,54]]);}));return function(_x){return _ref.apply(this,arguments);};}());/**
25
+ if(handler.isShopLink(location)){_ref7=new URL(location),_pathname=_ref7.pathname,search=_ref7.search;location="".concat(_pathname).concat(search);}// If there is one of the known protocols in the url.
26
+ if(!(location&&handler.hasKnownProtocols(location))){_context.next=74;break;}if(handler.isExternalLink(originalLocation)){handler.openExternalLink(originalLocation,historyAction,state,routeState);}else if(handler.isNativeLink(location)){handler.openNativeLink(location);}return _context.abrupt("return");case 74:if(!(location&&handler.isLegacyPage(location))){_context.next=77;break;}handler.openLegacy(location,historyAction,state);return _context.abrupt("return");case 77:if(!(location&&handler.isLegacyLink(location))){_context.next=80;break;}handler.openLegacyLink(location,historyAction,state);return _context.abrupt("return");case 80:_context.t2=historyAction;_context.next=_context.t2===ACTION_PUSH?83:_context.t2===ACTION_REPLACE?85:87;break;case 83:router.push({pathname:location,state:routeState,emitBefore:silent,emitAfter:silent});return _context.abrupt("break",88);case 85:router.replace({pathname:location,state:routeState,emitBefore:silent,emitAfter:silent});return _context.abrupt("break",88);case 87:return _context.abrupt("break",88);case 88:case"end":return _context.stop();}},_callee,null,[[48,54]]);}));return function(_x){return _ref.apply(this,arguments);};}());/**
27
27
  * Added a 100ms delay here to allow the Redux action to complete.
28
28
  * Without it the store would show that the user is still not
29
29
  * logged in during the upcoming navigate() action.
30
- */var redirectUser$=userDidLogin$.delay(100);subscribe(redirectUser$,function(_ref6){var action=_ref6.action,dispatch=_ref6.dispatch;if(appConfig.webCheckoutShopify===null){dispatch(historyRedirect(action.redirect));}});subscribe(appWillStart$,function(_ref7){var dispatch=_ref7.dispatch;var windowOpenOriginal=window.open;/**
30
+ */var redirectUser$=userDidLogin$.delay(100);subscribe(redirectUser$,function(_ref8){var action=_ref8.action,dispatch=_ref8.dispatch;if(appConfig.webCheckoutShopify===null){dispatch(historyRedirect(action.redirect));}});subscribe(appWillStart$,function(_ref9){var dispatch=_ref9.dispatch;var windowOpenOriginal=window.open;/**
31
31
  * Override for the window.open method which is usually used by external SDKs to open URLs.
32
32
  * Calls of this method would usually replace the PWA with the passed url. The override ensures
33
33
  * that the URL is passed through the router system which implements logic for various URL
@@ -42,4 +42,4 @@ if(!(location&&handler.hasKnownProtocols(location))){_context.next=74;break;}if(
42
42
  * @param {boolean} [isInternal=false] Whether the method is called by internal logic. This will
43
43
  * invoke the original window.open with the method parameters.
44
44
  * @returns {null}
45
- */window.open=function(){var url=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'';var target=arguments.length>1?arguments[1]:undefined;var windowFeatures=arguments.length>2?arguments[2]:undefined;var isInternal=arguments.length>3&&arguments[3]!==undefined?arguments[3]:false;if(!isInternal){dispatch(windowOpenOverride({pathname:url}));}else{windowOpenOriginal(url,target,windowFeatures);}return null;};});subscribe(windowOpenOverride$,function(_ref8){var action=_ref8.action,dispatch=_ref8.dispatch;if(action.pathname){dispatch(historyPush({pathname:action.pathname}));}});}
45
+ */window.open=function(){var url=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'';var target=arguments.length>1?arguments[1]:undefined;var windowFeatures=arguments.length>2?arguments[2]:undefined;var isInternal=arguments.length>3&&arguments[3]!==undefined?arguments[3]:false;if(!isInternal){dispatch(windowOpenOverride({pathname:url}));}else{windowOpenOriginal(url,target,windowFeatures);}return null;};});subscribe(windowOpenOverride$,function(_ref10){var action=_ref10.action,dispatch=_ref10.dispatch;if(action.pathname){dispatch(historyPush({pathname:action.pathname}));}});}
@@ -3,4 +3,4 @@ import _regeneratorRuntime from"@babel/runtime/regenerator";function _extends(){
3
3
  * @param {Function} subscribe The subscribe function.
4
4
  */export default function user(subscribe){/**
5
5
  * Gets triggered when ever the user data need to be updated.
6
- */var userNeedsUpdate$=appDidStart$.merge(userDidLogin$);subscribe(userDidInitialize$,function(_ref){var events=_ref.events;events.emit(EVENT_USER_INITIALIZED);});subscribe(userWillLogin$,function(){LoadingProvider.setLoading(LOGIN_PATH);});subscribe(userLoginResponse$,function(){LoadingProvider.unsetLoading(LOGIN_PATH);});subscribe(userNeedsUpdate$,function(_ref2){var dispatch=_ref2.dispatch;dispatch(fetchUser());});subscribe(userDidLogout$,/*#__PURE__*/function(){var _ref4=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref3){var dispatch,action,isAutoLogout,confirmed;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:dispatch=_ref3.dispatch,action=_ref3.action;if(!(action.notify===false)){_context.next=3;break;}return _context.abrupt("return");case 3:isAutoLogout=action.autoLogout;if(!(isAutoLogout&&(appConfig===null||appConfig===void 0?void 0:appConfig.disableAutoLogoutModal)===true)){_context.next=6;break;}return _context.abrupt("return");case 6:_context.next=8;return dispatch(showModal(_extends({confirm:'modal.ok',dismiss:null,message:'login.logout_message',title:null},isAutoLogout?{message:'login.auto_logout_message',confirm:'modal.login',dismiss:'modal.close'}:null)));case 8:confirmed=_context.sent;if(isAutoLogout&&confirmed){dispatch(historyPush({pathname:LOGIN_PATH}));}case 10:case"end":return _context.stop();}}},_callee);}));return function(_x){return _ref4.apply(this,arguments);};}());subscribe(appDidStart$,function(_ref5){var dispatch=_ref5.dispatch,getState=_ref5.getState;registerEvents(['userLoggedIn']);event.addCallback('userLoggedIn',function(){var _getCurrentRoute=getCurrentRoute(getState()),_getCurrentRoute$stat=_getCurrentRoute.state;_getCurrentRoute$stat=_getCurrentRoute$stat===void 0?{}:_getCurrentRoute$stat;var redirect=_getCurrentRoute$stat.redirect;dispatch(successLogin(redirect));});});subscribe(legacyConnectRegisterDidFail$,function(_ref6){var dispatch=_ref6.dispatch;dispatch(historyPush({pathname:LEGACY_URL_CONNECT_REGISTER}));});subscribe(userSessionExpired$,function(_ref7){var dispatch=_ref7.dispatch;dispatch(logout(undefined,true));});}
6
+ */var userNeedsUpdate$=appDidStart$.merge(userDidLogin$);subscribe(userDidInitialize$,function(_ref){var events=_ref.events;events.emit(EVENT_USER_INITIALIZED);});subscribe(userWillLogin$,function(){LoadingProvider.setLoading(LOGIN_PATH);});subscribe(userLoginResponse$,function(){LoadingProvider.unsetLoading(LOGIN_PATH);});subscribe(userNeedsUpdate$,function(_ref2){var dispatch=_ref2.dispatch;dispatch(fetchUser());});subscribe(userDidLogout$,/*#__PURE__*/function(){var _ref4=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref3){var dispatch,action,isAutoLogout,confirmed;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:dispatch=_ref3.dispatch,action=_ref3.action;if(!(action.notify===false)){_context.next=3;break;}return _context.abrupt("return");case 3:isAutoLogout=action.autoLogout;if(!(isAutoLogout&&(appConfig===null||appConfig===void 0?void 0:appConfig.disableAutoLogoutModal)===true)){_context.next=6;break;}return _context.abrupt("return");case 6:_context.next=8;return dispatch(showModal(_extends({confirm:'modal.ok',dismiss:null,message:'login.logout_message',title:null},isAutoLogout?{message:'login.auto_logout_message',confirm:'modal.login',dismiss:'modal.close'}:null)));case 8:confirmed=_context.sent;if(isAutoLogout&&confirmed){dispatch(historyPush({pathname:LOGIN_PATH}));}case 10:case"end":return _context.stop();}},_callee);}));return function(_x){return _ref4.apply(this,arguments);};}());subscribe(appDidStart$,function(_ref5){var dispatch=_ref5.dispatch,getState=_ref5.getState;registerEvents(['userLoggedIn']);event.addCallback('userLoggedIn',function(){var _getCurrentRoute=getCurrentRoute(getState()),_getCurrentRoute$stat=_getCurrentRoute.state,_getCurrentRoute$stat2=_getCurrentRoute$stat===void 0?{}:_getCurrentRoute$stat,redirect=_getCurrentRoute$stat2.redirect;dispatch(successLogin(redirect));});});subscribe(legacyConnectRegisterDidFail$,function(_ref6){var dispatch=_ref6.dispatch;dispatch(historyPush({pathname:LEGACY_URL_CONNECT_REGISTER}));});subscribe(userSessionExpired$,function(_ref7){var dispatch=_ref7.dispatch;dispatch(logout(undefined,true));});}