@shopgate/pwa-common 7.12.7-beta.1 → 7.20.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/App.js +6 -6
- package/actions/app/handleLink.js +7 -5
- package/actions/client/fetchClientInformation.js +1 -1
- package/actions/page/fetchPageConfig.js +2 -2
- package/actions/router/historyReplace.js +11 -1
- package/actions/user/getUser.js +1 -0
- package/actions/user/login.js +2 -2
- package/collections/AuthRoutes.js +3 -3
- package/collections/Configuration.js +3 -3
- package/collections/EmbeddedMedia.js +13 -3
- package/collections/PersistedReducers.js +2 -2
- package/collections/Redirects.js +3 -3
- package/collections/media-providers/MediaProvider.js +32 -4
- package/collections/media-providers/Vimeo.js +26 -7
- package/collections/media-providers/YouTube.js +10 -5
- package/collections/media-providers/style.js +2 -1
- package/components/Backdrop/index.js +11 -11
- package/components/Button/index.js +7 -7
- package/components/Checkbox/index.js +27 -14
- package/components/CountdownTimer/index.js +7 -7
- package/components/Drawer/index.js +13 -13
- package/components/Dropdown/index.js +5 -5
- package/components/Ellipsis/index.js +1 -1
- package/components/EmbeddedMedia/index.js +5 -5
- package/components/ErrorBoundary/index.js +5 -5
- package/components/Grid/components/Item/index.js +4 -4
- package/components/Grid/index.js +4 -4
- package/components/HtmlSanitizer/connector.js +9 -0
- package/components/HtmlSanitizer/index.js +11 -11
- package/components/HtmlSanitizer/spec.js +4 -4
- package/components/I18n/components/FormatPrice/index.js +2 -2
- package/components/I18n/components/I18nProvider/index.js +9 -9
- package/components/I18n/components/Translate/index.js +11 -7
- package/components/Icon/index.js +1 -1
- package/components/Image/index.js +9 -9
- package/components/Image/spec.js +2 -2
- package/components/InfiniteContainer/index.js +21 -21
- package/components/Input/components/DateInput.js +2 -2
- package/components/Input/components/MultiLineInput.js +10 -10
- package/components/Input/components/SimpleInput.js +27 -21
- package/components/KeyboardConsumer/index.js +7 -7
- package/components/Link/connector.js +1 -1
- package/components/Link/index.js +8 -5
- package/components/List/components/Item/index.js +1 -1
- package/components/List/index.js +1 -1
- package/components/Modal/style.js +1 -1
- package/components/Picker/components/List/index.js +1 -1
- package/components/Picker/components/Modal/index.js +7 -7
- package/components/Picker/index.js +19 -9
- package/components/Portal/index.js +15 -11
- package/components/ProductCharacteristics/helpers/index.js +1 -1
- package/components/ProductCharacteristics/index.js +27 -12
- package/components/RangeSlider/index.js +33 -24
- package/components/Route/RouteNotFound.js +3 -3
- package/components/Route/index.js +12 -5
- package/components/Router/index.js +18 -10
- package/components/ScannerContainer/index.js +3 -3
- package/components/Select/index.js +25 -15
- package/components/SelectBox/components/Item/index.js +5 -3
- package/components/SelectBox/index.js +17 -8
- package/components/Swiper/components/SwiperItem/spec.js +1 -1
- package/components/Swiper/index.js +3 -3
- package/components/Swiper/styles.js +4 -1
- package/components/Transition/index.js +4 -4
- package/components/Widgets/components/Widget/index.js +4 -4
- package/components/Widgets/components/WidgetGrid/index.js +5 -5
- package/components/Widgets/index.js +6 -6
- package/components/index.js +1 -2
- package/constants/Configuration.js +1 -1
- package/constants/Device.js +2 -2
- package/constants/Portals.js +2 -2
- package/helpers/config/mock.js +2 -2
- package/helpers/config/theme.js +2 -2
- package/helpers/dom/index.js +2 -1
- package/helpers/html/parseHTML.js +10 -3
- package/helpers/i18n/getNumberFormatter.js +1 -1
- package/helpers/i18n/getTranslator.js +10 -4
- package/helpers/i18n/index.js +1 -1
- package/helpers/i18n/mergeTranslations.js +1 -1
- package/helpers/portals/portalCollection.js +3 -3
- package/helpers/redux/shouldFetchData.js +1 -1
- package/helpers/style/index.js +2 -2
- package/package.json +5 -5
- package/providers/loading/index.js +24 -14
- package/providers/toast/index.js +10 -8
- package/reducers/page/index.js +1 -1
- package/reducers/router/index.js +1 -1
- package/selectors/client.js +9 -7
- package/streams/app.js +8 -2
- package/streams/main.js +1 -1
- package/streams/view.js +12 -0
- package/subscriptions/error.js +4 -4
- package/subscriptions/helpers/handleLinks.js +2 -2
- package/subscriptions/menu.js +4 -2
- package/subscriptions/router.js +6 -6
- package/subscriptions/user.js +1 -1
|
@@ -10,6 +10,6 @@ if(messageCache[hash]){return messageCache[hash];}messageCache[hash]=new IntlMes
|
|
|
10
10
|
* Get a formatted number by a language code.
|
|
11
11
|
* @param {string} langCode A language code.
|
|
12
12
|
* @param {number} value The number to format.
|
|
13
|
-
* @param {boolean} fractions
|
|
13
|
+
* @param {boolean} fractions Number of digits after dot.
|
|
14
14
|
* @returns {string}
|
|
15
15
|
*/var formatNumber=function formatNumber(langCode,value,fractions){return getFormattedNumberFromCache(langCode,fractions).format({value:value});};var getNumberFormatter=curry(formatNumber);export default getNumberFormatter;
|
|
@@ -10,16 +10,22 @@ import{default as getPath}from'lodash/get';import moment from'moment';import mes
|
|
|
10
10
|
* @param {Object} locales A locales object.
|
|
11
11
|
* @param {string} langCode A language code.
|
|
12
12
|
* @param {string} key A translation key.
|
|
13
|
+
* @param {Object} options Additional options for the translator
|
|
14
|
+
* @param {boolean} [options.acceptPlainTextWithPlaceholders = false] When set to TRUE, the
|
|
15
|
+
* translator can also handle human readable texts that contain text replacement placeholders.
|
|
13
16
|
* @returns {IntlMessageFormat}
|
|
14
|
-
*/var getMessageFromCache=function getMessageFromCache(locales,langCode,key){var hash="".concat(langCode,"_").concat(key);// Check if a cached instance already exists.
|
|
15
|
-
if(messageCache[hash]){return messageCache[hash];}var message=getPath(locales,key);if(typeof message!=='string'||message.length===0){return pureReturn(key);}// Prevent the app from crashing when strings (like product names) don't comply with the format
|
|
17
|
+
*/var getMessageFromCache=function getMessageFromCache(locales,langCode,key){var options=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{};var _options$acceptPlainT=options.acceptPlainTextWithPlaceholders,acceptPlainTextWithPlaceholders=_options$acceptPlainT===void 0?false:_options$acceptPlainT;var hash="".concat(langCode,"_").concat(key,"_").concat(acceptPlainTextWithPlaceholders?1:0);// Check if a cached instance already exists.
|
|
18
|
+
if(messageCache[hash]){return messageCache[hash];}var message=getPath(locales,key,acceptPlainTextWithPlaceholders?key:undefined);if(typeof message!=='string'||message.length===0){return pureReturn(key);}// Prevent the app from crashing when strings (like product names) don't comply with the format
|
|
16
19
|
try{messageCache[hash]=new IntlMessageFormat(message,langCode,getPath(locales,'formats'));}catch(e){messageCache[hash]=pureReturn(key);}return messageCache[hash];};/**
|
|
17
20
|
* Get a translation for a given key.
|
|
18
21
|
* @param {Object} locales A locales object.
|
|
19
22
|
* @param {string} langCode A language code.
|
|
20
23
|
* @param {string} key A translation key.
|
|
21
24
|
* @param {Object} [args] Arguments for the translation.
|
|
25
|
+
* @param {Object} options Additional options for the translator
|
|
26
|
+
* @param {boolean} [options.acceptPlainTextWithPlaceholders = false] When set to TRUE, the
|
|
27
|
+
* translator can also handle human readable texts that contain text replacement placeholders.
|
|
22
28
|
* @returns {string}
|
|
23
|
-
*/var translate=function translate(locales,langCode,key){var args=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{};/**
|
|
29
|
+
*/var translate=function translate(locales,langCode,key){var args=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{};var options=arguments.length>4&&arguments[4]!==undefined?arguments[4]:{};/**
|
|
24
30
|
* @returns {Object}
|
|
25
|
-
*/var sanitizeArgs=function sanitizeArgs(){if(_typeof(args)!=='object'||args===null){return args;}return Object.keys(args).reduce(function(acc,arg){var date=moment(args[arg],moment.ISO_8601,true);if(date.isValid()&&date.toISOString()===args[arg]){acc[arg]=new Date(args[arg]).getTime();}else{acc[arg]=args[arg];}return acc;},{});};return getMessageFromCache(locales,langCode,key).format(sanitizeArgs());};export default curry(translate);
|
|
31
|
+
*/var sanitizeArgs=function sanitizeArgs(){if(_typeof(args)!=='object'||args===null){return args;}return Object.keys(args).reduce(function(acc,arg){var date=moment(args[arg],moment.ISO_8601,true);if(date.isValid()&&date.toISOString()===args[arg]){acc[arg]=new Date(args[arg]).getTime();}else{acc[arg]=args[arg];}return acc;},{});};return getMessageFromCache(locales,langCode,key,options).format(sanitizeArgs());};export default curry(translate);
|
package/helpers/i18n/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export{default as getTranslator}from"./getTranslator";export{default as getPriceFormatter}from"./getPriceFormatter";export{default as getDateFormatter}from"./getDateFormatter";export{default as getTimeFormatter}from"./getTimeFormatter";export{default as getNumberFormatter}from"./getNumberFormatter";
|
|
@@ -17,5 +17,5 @@ var _themeLocale$split=themeLocale.split('-'),_themeLocale$split2=_slicedToArray
|
|
|
17
17
|
* @return {Object}
|
|
18
18
|
*/var mergeTranslations=function mergeTranslations(theme,extensions){var locale=arguments.length>2&&arguments[2]!==undefined?arguments[2]:process.env.LOCALE_FILE;if(!isPlainObject(extensions)||Object.keys(extensions).length===0){// No extension translations provided.
|
|
19
19
|
return cloneDeep(theme);}return Object.keys(extensions).reduce(function(result,extensionLocale){if(!localesMatch(locale,extensionLocale)){// Continue if the current extension locale doesn't match the theme locale.
|
|
20
|
-
return result;}// Merge the
|
|
20
|
+
return result;}// Merge the current extensions into the result.
|
|
21
21
|
return merge(result,extensions[extensionLocale]);},cloneDeep(theme));};export default mergeTranslations;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
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;}/**
|
|
2
2
|
* The portals collection.
|
|
3
|
-
*/var PortalCollection=/*#__PURE__*/function(){function PortalCollection(){_classCallCheck(this,PortalCollection);}_createClass(PortalCollection,[{key:"getPortals"
|
|
3
|
+
*/var PortalCollection=/*#__PURE__*/function(){function PortalCollection(){_classCallCheck(this,PortalCollection);}return _createClass(PortalCollection,[{key:"getPortals",value:/**
|
|
4
4
|
* Returns the portal definitions.
|
|
5
5
|
* @return {Object}
|
|
6
|
-
*/
|
|
6
|
+
*/function getPortals(){return this.portals;}/**
|
|
7
7
|
* Registers the portal definitions.
|
|
8
8
|
* @param {Object} [portals={}] The portals to register.
|
|
9
9
|
*/},{key:"registerPortals",value:function registerPortals(){var portals=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};this.portals=portals;}/**
|
|
@@ -12,4 +12,4 @@ function _classCallCheck(instance,Constructor){if(!(instance instanceof Construc
|
|
|
12
12
|
*/},{key:"registerConfig",value:function registerConfig(){var config=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};this.config=config;}/**
|
|
13
13
|
* Returns the portal config.
|
|
14
14
|
* @return {Object}
|
|
15
|
-
*/},{key:"getConfig",value:function getConfig(){return this.config;}}]);
|
|
15
|
+
*/},{key:"getConfig",value:function getConfig(){return this.config;}}]);}();export default new PortalCollection();
|
|
@@ -10,7 +10,7 @@ if(!item){return true;}// Fetch data if we have an empty object in the store.
|
|
|
10
10
|
if(isObject(item)&&Object.keys(item).length===0){return true;}// Check that the item is not fetching currently.
|
|
11
11
|
if(!item.isFetching){// Fetch data if the expiry date has expired or is set to 0 (initially set).
|
|
12
12
|
if(item.expires===0||item.expires&&item.expires>0&&item.expires<Date.now()){return true;}// Check for a specific key inside items and fetch it if it's not found.
|
|
13
|
-
if(itemKey&&Array.isArray(item[itemKey])){var _item$
|
|
13
|
+
if(itemKey&&Array.isArray(item[itemKey])){var _item$totalResultCoun2=item.totalResultCount,totalResultCount=_item$totalResultCoun2===void 0?item[itemKey].length:_item$totalResultCoun2;// 1. Fetch by requiredCount.
|
|
14
14
|
if(requiredCount){var assertCount=Math.min(requiredCount,totalResultCount);// Fetch is needed to assert N of items in store.
|
|
15
15
|
if(item[itemKey].length!==assertCount){return true;}}// 2. Sync items when totalResultCount is less
|
|
16
16
|
if(!requiredCount&&item[itemKey].length>totalResultCount){return true;}}}return false;}
|
package/helpers/style/index.js
CHANGED
|
@@ -12,5 +12,5 @@ function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj
|
|
|
12
12
|
* @param {string} property Css property name.
|
|
13
13
|
* @param {number} [size=1] Requested physical pixel size.
|
|
14
14
|
* @returns {Object}
|
|
15
|
-
*/export var physicalPixelSize=function physicalPixelSize(property){var
|
|
16
|
-
if(navigator&&navigator.userAgent&&navigator.userAgent.includes('Android')){return _defineProperty({},property,size);}var _double=Math.round(size/2*100)/100;var triple=Math.round(size/3*100)/100;return
|
|
15
|
+
*/export var physicalPixelSize=function physicalPixelSize(property){var size=arguments.length>1&&arguments[1]!==undefined?arguments[1]:1;// Android doesn't accept decimals.
|
|
16
|
+
if(navigator&&navigator.userAgent&&navigator.userAgent.includes('Android')){return _defineProperty({},property,size);}var _double=Math.round(size/2*100)/100;var triple=Math.round(size/3*100)/100;return _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({},property,size),'@media (min-device-pixel-ratio: 2)',_defineProperty({},property,_double)),'@media (-webkit-min-device-pixel-ratio: 2)',_defineProperty({},property,_double)),'@media (min-device-pixel-ratio: 3)',_defineProperty({},property,triple)),'@media (-webkit-min-device-pixel-ratio: 3)',_defineProperty({},property,triple));};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopgate/pwa-common",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.20.0-beta.10",
|
|
4
4
|
"description": "Common library for the Shopgate Connect PWA.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Shopgate <support@shopgate.com>",
|
|
@@ -16,16 +16,16 @@
|
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@sentry/browser": "6.0.1",
|
|
19
|
-
"@shopgate/pwa-benchmark": "7.
|
|
19
|
+
"@shopgate/pwa-benchmark": "7.20.0-beta.10",
|
|
20
20
|
"@virtuous/conductor": "~2.5.0",
|
|
21
21
|
"@virtuous/react-conductor": "~2.5.0",
|
|
22
22
|
"@virtuous/redux-persister": "1.1.0-beta.7",
|
|
23
|
-
"classnames": "
|
|
23
|
+
"classnames": "2.3.3",
|
|
24
24
|
"crypto-js": "3.1.9-1",
|
|
25
25
|
"glamor": "^2.20.40",
|
|
26
26
|
"gsap": "^3.6.0",
|
|
27
27
|
"history": "^4.9.0",
|
|
28
|
-
"intl-messageformat": "^
|
|
28
|
+
"intl-messageformat": "^7.8.3",
|
|
29
29
|
"jsdom": "11.1.0",
|
|
30
30
|
"path-match": "^1.2.4",
|
|
31
31
|
"react-dotdotdot": "~1.3.0",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"url-search-params": "^0.10.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@shopgate/pwa-core": "7.
|
|
47
|
+
"@shopgate/pwa-core": "7.20.0-beta.10",
|
|
48
48
|
"lodash": "^4.17.4",
|
|
49
49
|
"prop-types": "~15.7.2",
|
|
50
50
|
"react": "~16.12.0",
|
|
@@ -1,21 +1,31 @@
|
|
|
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 _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key];}}return target;}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}function _toPropertyKey(arg){var key=_toPrimitive(arg,"string");return _typeof(key)==="symbol"?key:String(key);}function _toPrimitive(input,hint){if(_typeof(input)!=="object"||input===null)return input;var prim=input[Symbol.toPrimitive];if(prim!==undefined){var res=prim.call(input,hint||"default");if(_typeof(res)!=="object")return res;throw new TypeError("@@toPrimitive must return a primitive value.");}return(hint==="string"?String:Number)(input);}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 _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function
|
|
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 _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key];}}return target;}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}function _toPropertyKey(arg){var key=_toPrimitive(arg,"string");return _typeof(key)==="symbol"?key:String(key);}function _toPrimitive(input,hint){if(_typeof(input)!=="object"||input===null)return input;var prim=input[Symbol.toPrimitive];if(prim!==undefined){var res=prim.call(input,hint||"default");if(_typeof(res)!=="object")return res;throw new TypeError("@@toPrimitive must return a primitive value.");}return(hint==="string"?String:Number)(input);}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 _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 LoadingContext from"./context";/**
|
|
2
2
|
* The LoadingProvider component.
|
|
3
|
-
*/var LoadingProvider=/*#__PURE__*/function(_Component){
|
|
3
|
+
*/var LoadingProvider=/*#__PURE__*/function(_Component){/**
|
|
4
|
+
* @param {Object} props The component props.
|
|
5
|
+
*/function LoadingProvider(props){var _this2;_classCallCheck(this,LoadingProvider);_this2=_callSuper(this,LoadingProvider,[props]);/**
|
|
6
|
+
* Adds or increases the loading counter for a path.
|
|
7
|
+
* @param {string} path The path which loads.
|
|
8
|
+
*/_defineProperty(_this2,"setLoading",function(path){var _this3=_this2,loading=_this3.loading;var newLoading=_extends({},loading,_defineProperty({},path,loading[path]?loading[path]+1:1));// Immediately updates state due to multiple sets before actual rerender.
|
|
9
|
+
_this2.loading=newLoading;_this2.setState({loading:newLoading});});/**
|
|
4
10
|
* Resets the loading counter for a path.
|
|
5
11
|
* @param {string} path The path which loads.
|
|
6
|
-
*/
|
|
12
|
+
*/_defineProperty(_this2,"resetLoading",function(path){var _this2$loading=_this2.loading,removedPath=_this2$loading[path],remaining=_objectWithoutProperties(_this2$loading,[path].map(_toPropertyKey));// Immediately updates state due to multiple sets before actual rerender.
|
|
13
|
+
_this2.loading=remaining;_this2.setState({loading:remaining});});/**
|
|
7
14
|
* Decreases the loading counter for a path.
|
|
8
15
|
* @param {string} path The path which loads.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
*/_defineProperty(_this2,"unsetLoading",function(path){var _this4=_this2,loading=_this4.loading;if(typeof loading[path]==='undefined'){return;}if(loading[path]<=1){_this2.resetLoading(path);return;}var newLoading=_extends({},loading,_defineProperty({},path,loading[path]-1));// Immediately updates state due to multiple sets before actual rerender.
|
|
17
|
+
_this2.loading=newLoading;_this2.setState({loading:newLoading});});/**
|
|
18
|
+
* Checks if a path is loading.
|
|
19
|
+
* @param {string} path The path it inspect.
|
|
20
|
+
* @return {boolean}
|
|
21
|
+
*/_defineProperty(_this2,"isLoading",function(path){var loading=_this2.state.loading;return!!loading[path];});_this2.loading={};_this2.state={loading:{}};UIEvents.addListener(_this2.constructor.SET,_this2.setLoading);UIEvents.addListener(_this2.constructor.RESET,_this2.resetLoading);UIEvents.addListener(_this2.constructor.UNSET,_this2.unsetLoading);return _this2;}/**
|
|
15
22
|
* Removes the event listeners when the component unmounts.
|
|
16
|
-
*/_createClass(LoadingProvider,[{key:"componentWillUnmount",value:function componentWillUnmount(){UIEvents.removeListener(this.constructor.SET,this.setLoading);UIEvents.removeListener(this.constructor.RESET,this.resetLoading);UIEvents.removeListener(this.constructor.UNSET,this.unsetLoading);}
|
|
17
|
-
* Adds or increases the loading counter for a path.
|
|
18
|
-
* @param {string} path The path which loads.
|
|
19
|
-
*/},{key:"render",/**
|
|
23
|
+
*/_inherits(LoadingProvider,_Component);return _createClass(LoadingProvider,[{key:"componentWillUnmount",value:function componentWillUnmount(){UIEvents.removeListener(this.constructor.SET,this.setLoading);UIEvents.removeListener(this.constructor.RESET,this.resetLoading);UIEvents.removeListener(this.constructor.UNSET,this.unsetLoading);}},{key:"render",value:/**
|
|
20
24
|
* @return {JSX}
|
|
21
|
-
*/
|
|
25
|
+
*/function render(){var value={loading:this.state.loading,setLoading:this.setLoading,unsetLoading:this.unsetLoading,isLoading:this.isLoading};return React.createElement(LoadingContext.Provider,{value:value},this.props.children);}}],[{key:"setLoading",value:function setLoading(path){UIEvents.emit(LoadingProvider.SET,path);}/**
|
|
26
|
+
* Resets the loading counter for a path.
|
|
27
|
+
* @param {string} path The path which loads.
|
|
28
|
+
*/},{key:"resetLoading",value:function resetLoading(path){UIEvents.emit(LoadingProvider.RESET,path);}/**
|
|
29
|
+
* Decreases the loading counter for a path.
|
|
30
|
+
* @param {string} path The path which loads.
|
|
31
|
+
*/},{key:"unsetLoading",value:function unsetLoading(path){UIEvents.emit(LoadingProvider.UNSET,path);}}]);}(Component);_defineProperty(LoadingProvider,"SET",'loading_set');_defineProperty(LoadingProvider,"RESET",'loading_reset');_defineProperty(LoadingProvider,"UNSET",'loading_unset');export default LoadingProvider;
|
package/providers/toast/index.js
CHANGED
|
@@ -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
|
|
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){
|
|
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});}
|
|
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
|
-
*/
|
|
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;
|
package/reducers/page/index.js
CHANGED
|
@@ -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$
|
|
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;}}
|
package/reducers/router/index.js
CHANGED
|
@@ -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
|
|
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;}}
|
package/selectors/client.js
CHANGED
|
@@ -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
|
|
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
|
|
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$;}
|
package/streams/view.js
ADDED
|
@@ -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||0;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$;};
|
package/subscriptions/error.js
CHANGED
|
@@ -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){
|
|
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=(
|
|
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',
|
|
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
|
|
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){
|
|
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}
|
package/subscriptions/menu.js
CHANGED
|
@@ -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))
|
|
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));}});}
|
package/subscriptions/router.js
CHANGED
|
@@ -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,
|
|
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&¤tPathname===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;}
|
|
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)){
|
|
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();}}
|
|
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(
|
|
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(
|
|
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}));}});}
|
package/subscriptions/user.js
CHANGED
|
@@ -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)
|
|
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));});}
|