@shopgate/engage 6.22.0-beta.3 → 6.22.0-beta.4
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/back-in-stock/reducers/index.js +2 -2
- package/back-in-stock/selectors/index.js +22 -6
- package/back-in-stock/subscriptions/index.js +10 -2
- package/core/action-creators/appPermissions.js +9 -0
- package/core/action-creators/index.js +1 -0
- package/core/actions/getGeolocation.js +1 -1
- package/core/actions/grantCameraPermissions.js +1 -1
- package/core/actions/grantGeolocationPermissions.js +1 -1
- package/core/actions/grantPermissions.js +4 -4
- package/core/actions/grantPushPermissions.js +1 -1
- package/core/actions/index.js +1 -0
- package/core/actions/requestAppPermission.js +7 -0
- package/core/actions/requestAppPermissionStatus.js +7 -0
- package/core/collections/AppInitialization.js +49 -0
- package/core/collections/index.js +1 -0
- package/core/constants/actionTypes.js +1 -0
- package/core/constants/index.js +6 -0
- package/core/index.js +8 -12
- package/core/initialization/index.js +7 -0
- package/core/streams/appPermissions.js +19 -0
- package/core/streams/index.js +1 -0
- package/package.json +7 -7
- package/push-opt-in/components/PushOptInModal/push-opt-in.svg +62 -0
- package/push-opt-in/subscriptions/optInTrigger.js +3 -3
- package/a11y/components/LiveMessage/__tests__/index.spec.js +0 -1
- package/a11y/components/LiveMessenger/__tests__/helpers.spec.js +0 -1
- package/a11y/components/LiveMessenger/__tests__/index.spec.js +0 -1
- package/a11y/components/Navigation/__tests__/index.spec.js +0 -1
- package/a11y/components/Section/__tests__/index.spec.js +0 -1
- package/a11y/index.spec.js +0 -1
- package/cart/index.spec.js +0 -1
- package/category/index.spec.js +0 -1
- package/checkout/index.spec.js +0 -1
- package/components/Footer/__tests__/Footer.spec.js +0 -8
- package/components/Form/Builder/Builder.spec.js +0 -19
- package/components/Form/Builder/classes/ActionListener.spec.js +0 -21
- package/components/Form/Builder/helpers/buildCountryList.spec.js +0 -1
- package/components/Form/Builder/helpers/buildFormDefaults.spec.js +0 -1
- package/components/Form/Builder/helpers/buildFormElements.spec.js +0 -3
- package/components/Form/Builder/helpers/buildProvinceList.spec.js +0 -1
- package/components/IntersectionVisibility/__tests__/index.js +0 -1
- package/components/View/__mocks__/context.js +0 -1
- package/components/View/__mocks__/index.js +0 -5
- package/components/View/__tests__/index.spec.js +0 -1
- package/components/View/__tests__/provider.spec.js +0 -1
- package/components/View/components/Above/__tests__/index.spec.js +0 -1
- package/components/View/components/Below/__tests__/index.spec.js +0 -1
- package/components/View/components/Content/__tests__/index.spec.js +0 -2
- package/components/__mocks__/index.js +0 -4
- package/components/index.spec.js +0 -1
- package/core/actions/__tests__/getGeolocation.spec.js +0 -2
- package/core/actions/__tests__/grantCameraPermissions.spec.js +0 -1
- package/core/actions/__tests__/grantGeolocationPermissions.spec.js +0 -1
- package/core/actions/__tests__/grantPermissions.spec.js +0 -9
- package/core/actions/__tests__/updateStatusBarBackground.spec.js +0 -1
- package/core/classes/__tests__/GeolocationRequest.spec.js +0 -5
- package/core/config/__tests__/getPageConfig.spec.js +0 -1
- package/core/config/__tests__/getPageSettings.spec.js +0 -2
- package/core/config/__tests__/getThemeAssets.spec.js +0 -1
- package/core/config/__tests__/getThemeColors.spec.js +0 -1
- package/core/config/__tests__/getThemeConfig.spec.js +0 -2
- package/core/config/__tests__/getThemeSettings.spec.js +0 -1
- package/core/config/__tests__/getThemeStyles.spec.js +0 -1
- package/core/config/__tests__/getWidgetConfig.spec.js +0 -1
- package/core/config/__tests__/getWidgetSettings.spec.js +0 -3
- package/core/helpers/__mocks__/i18n.js +0 -1
- package/core/helpers/__tests__/i18n.spec.js +0 -1
- package/core/helpers/__tests__/updateLegacyNavigationBar.spec.js +0 -1
- package/core/hocs/__mocks__/withWidgetSettings.js +0 -5
- package/core/hocs/__tests__/withApp.spec.js +0 -2
- package/core/hocs/__tests__/withCurrentProduct.spec.js +0 -2
- package/core/hocs/__tests__/withForwardedRef.spec.js +0 -1
- package/core/hocs/__tests__/withNavigation.spec.js +0 -2
- package/core/hocs/__tests__/withRoute.spec.js +0 -2
- package/core/hocs/__tests__/withTheme.spec.js +0 -2
- package/core/hocs/__tests__/withWidgetSettings.spec.js +0 -2
- package/core/hocs/__tests__/withWidgetStyles.spec.js +0 -2
- package/core/hooks/__tests__/useApp.spec.js +0 -1
- package/core/hooks/__tests__/useNavigation.spec.js +0 -1
- package/core/hooks/__tests__/usePageConfig.spec.js +0 -1
- package/core/hooks/__tests__/usePageSettings.spec.js +0 -1
- package/core/hooks/__tests__/useTheme.spec.js +0 -1
- package/core/hooks/__tests__/useWidgetConfig.spec.js +0 -1
- package/core/hooks/__tests__/useWidgetSettings.spec.js +0 -1
- package/core/hooks/__tests__/useWidgetStyles.spec.js +0 -1
- package/core/index.spec.js +0 -1
- package/core/providers/__tests__/AppProvider.spec.js +0 -2
- package/core/router/__tests__/helpers.spec.js +0 -1
- package/favorites/index.spec.js +0 -1
- package/filter/helpers/__tests__/buildUpdatedFilters.spec.js +0 -1
- package/filter/index.spec.js +0 -1
- package/index.spec.js +0 -1
- package/market/index.spec.js +0 -1
- package/orders/index.spec.js +0 -1
- package/page/index.spec.js +0 -1
- package/product/components/Description/__tests__/Description.spec.js +0 -1
- package/product/components/Media/helpers.spec.js +0 -3
- package/product/components/ProductCharacteristics/helpers/index.spec.js +0 -12
- package/product/components/ProductGridPrice/index.spec.js +0 -1
- package/product/components/ProductProperties/__tests__/Content.spec.js +0 -1
- package/product/components/ProductProperties/__tests__/Group.spec.js +0 -1
- package/product/components/ProductProperties/__tests__/GroupedProperties.spec.js +0 -1
- package/product/components/ProductProperties/__tests__/Lists.spec.js +0 -1
- package/product/components/ProductProperties/__tests__/ProductProperties.spec.js +0 -1
- package/product/components/ProductProperties/__tests__/Row.spec.js +0 -1
- package/product/components/ProductProperties/__tests__/Rows.spec.js +0 -1
- package/product/components/ProductProperties/__tests__/helpers/getGroupsFromProperties.spec.js +0 -1
- package/product/components/ProductProperties/__tests__/helpers/getSubgroupsFromProperties.spec.js +0 -1
- package/product/components/QuantityPicker/helpers.spec.js +0 -1
- package/product/components/__mocks__/context.js +0 -1
- package/product/hocs/withMapPricing.spec.js +0 -4
- package/product/hocs/withPriceCalculation.spec.js +0 -1
- package/product/index.spec.js +0 -1
- package/product/selectors/__tests__/media.spec.js +0 -1
- package/product/selectors/__tests__/price.spec.js +0 -1
- package/product/selectors/__tests__/product.spec.js +0 -2
- package/product/selectors/__tests__/relations.spec.js +0 -1
- package/product/selectors/__tests__/variants.spec.js +0 -1
- package/product/selectors/mocks/productProperties.mock.js +0 -1
- package/push-opt-in/subscriptions/optInTrigger.spec.js +0 -41
- package/reviews/index.spec.js +0 -1
- package/scanner/index.spec.js +0 -1
- package/search/index.spec.js +0 -1
- package/user/index.spec.js +0 -1
- package/user/selectors/__tests__/login.spec.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
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{ADD_BACK_IN_STOCK_SUBSCRIPTION,ADD_BACK_IN_STOCK_SUBSCRIPTION_ERROR,ADD_BACK_IN_STOCK_SUBSCRIPTION_SUCCESS,FETCH_BACK_IN_STOCK_SUBSCRIPTIONS,FETCH_BACK_IN_STOCK_SUBSCRIPTIONS_ERROR,FETCH_BACK_IN_STOCK_SUBSCRIPTIONS_SUCCESS,REMOVE_BACK_IN_STOCK_SUBSCRIPTION,REMOVE_BACK_IN_STOCK_SUBSCRIPTION_ERROR,REMOVE_BACK_IN_STOCK_SUBSCRIPTION_SUCCESS}from'@shopgate/engage/back-in-stock/constants';var initialState={isFetching:false,isInitial:true,subscriptions:[]};/**
|
|
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{PERMISSION_ID_PUSH,APP_PERMISSION_STATUS_RECEIVED}from'@shopgate/engage/core/constants';import{ADD_BACK_IN_STOCK_SUBSCRIPTION,ADD_BACK_IN_STOCK_SUBSCRIPTION_ERROR,ADD_BACK_IN_STOCK_SUBSCRIPTION_SUCCESS,FETCH_BACK_IN_STOCK_SUBSCRIPTIONS,FETCH_BACK_IN_STOCK_SUBSCRIPTIONS_ERROR,FETCH_BACK_IN_STOCK_SUBSCRIPTIONS_SUCCESS,REMOVE_BACK_IN_STOCK_SUBSCRIPTION,REMOVE_BACK_IN_STOCK_SUBSCRIPTION_ERROR,REMOVE_BACK_IN_STOCK_SUBSCRIPTION_SUCCESS}from'@shopgate/engage/back-in-stock/constants';var initialState={isFetching:false,isInitial:true,subscriptions:[],pushPermissionStatus:null};/**
|
|
2
2
|
* @param {Object} state The application state.
|
|
3
3
|
* @param {Object} action The redux action.
|
|
4
4
|
* @returns {Object}
|
|
5
|
-
*/export default(function(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:initialState;var action=arguments.length>1?arguments[1]:undefined;switch(action.type){case FETCH_BACK_IN_STOCK_SUBSCRIPTIONS:{return _extends({},state,{isFetching:true});}case FETCH_BACK_IN_STOCK_SUBSCRIPTIONS_SUCCESS:{return _extends({},state,{isInitial:false,isFetching:false,subscriptions:action.subscriptions});}case FETCH_BACK_IN_STOCK_SUBSCRIPTIONS_ERROR:{return _extends({},state,{isFetching:false});}case ADD_BACK_IN_STOCK_SUBSCRIPTION:{return _extends({},state,{isFetching:true});}case ADD_BACK_IN_STOCK_SUBSCRIPTION_SUCCESS:{return _extends({},state,{isFetching:false});}case ADD_BACK_IN_STOCK_SUBSCRIPTION_ERROR:{return _extends({},state,{isFetching:false});}case REMOVE_BACK_IN_STOCK_SUBSCRIPTION:{return _extends({},state,{isFetching:true});}case REMOVE_BACK_IN_STOCK_SUBSCRIPTION_SUCCESS:{return _extends({},state,{isFetching:false});}case REMOVE_BACK_IN_STOCK_SUBSCRIPTION_ERROR:{return _extends({},state,{isFetching:false});}default:return state;}});
|
|
5
|
+
*/export default(function(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:initialState;var action=arguments.length>1?arguments[1]:undefined;switch(action.type){case FETCH_BACK_IN_STOCK_SUBSCRIPTIONS:{return _extends({},state,{isFetching:true});}case FETCH_BACK_IN_STOCK_SUBSCRIPTIONS_SUCCESS:{return _extends({},state,{isInitial:false,isFetching:false,subscriptions:action.subscriptions});}case FETCH_BACK_IN_STOCK_SUBSCRIPTIONS_ERROR:{return _extends({},state,{isFetching:false});}case ADD_BACK_IN_STOCK_SUBSCRIPTION:{return _extends({},state,{isFetching:true});}case ADD_BACK_IN_STOCK_SUBSCRIPTION_SUCCESS:{return _extends({},state,{isFetching:false});}case ADD_BACK_IN_STOCK_SUBSCRIPTION_ERROR:{return _extends({},state,{isFetching:false});}case REMOVE_BACK_IN_STOCK_SUBSCRIPTION:{return _extends({},state,{isFetching:true});}case REMOVE_BACK_IN_STOCK_SUBSCRIPTION_SUCCESS:{return _extends({},state,{isFetching:false});}case REMOVE_BACK_IN_STOCK_SUBSCRIPTION_ERROR:{return _extends({},state,{isFetching:false});}case APP_PERMISSION_STATUS_RECEIVED:{if(action.permissionId!==PERMISSION_ID_PUSH){return state;}return _extends({},state,{pushPermissionStatus:action.status});}default:return state;}});
|
|
@@ -1,13 +1,20 @@
|
|
|
1
|
-
import{createSelector}from'reselect';import{makeGetProductByCharacteristics}from'@shopgate/engage/product';import{appConfig}from'@shopgate/engage';/**
|
|
1
|
+
function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i];}return arr2;}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}import{createSelector}from'reselect';import{makeGetProductByCharacteristics}from'@shopgate/engage/product';import{appConfig}from'@shopgate/engage';import{getClientInformation,isIos as getIsIos}from'@shopgate/engage/core';import{PERMISSION_STATUS_GRANTED,PERMISSION_STATUS_NOT_SUPPORTED}from'@shopgate/engage/core/constants';/**
|
|
2
2
|
* @param {Object} state The application state.
|
|
3
3
|
* @returns {Object}
|
|
4
|
-
*/export var
|
|
4
|
+
*/export var getBackInStockState=function getBackInStockState(state){return state.backInStock;};/**
|
|
5
5
|
* @param {Object} state The application state.
|
|
6
6
|
* @returns {Object}
|
|
7
|
-
*/export var
|
|
7
|
+
*/export var getBackInStockSubscriptions=createSelector(getBackInStockState,function(state){return state.subscriptions;});/**
|
|
8
8
|
* @param {Object} state The application state.
|
|
9
9
|
* @returns {Object}
|
|
10
|
-
*/export var
|
|
10
|
+
*/export var getBackInStockSubscriptionsFetching=createSelector(getBackInStockState,function(state){return state.isFetching;});/**
|
|
11
|
+
* @param {Object} state The application state.
|
|
12
|
+
* @returns {Object}
|
|
13
|
+
*/export var getBackInStockSubscriptionsInitial=createSelector(getBackInStockState,function(state){return state.isInitial;});/**
|
|
14
|
+
* Creates a selector to retrieve the current status of the push app permission
|
|
15
|
+
* @param {Object} state The application state.
|
|
16
|
+
* @returns {Object}
|
|
17
|
+
*/export var getBackInStockPushPermissionStatus=createSelector(getBackInStockState,function(state){return state.pushPermissionStatus;});/**
|
|
11
18
|
* Creates a selector that retrieves the subscription of
|
|
12
19
|
* a product / variant or null by its variantId / productId
|
|
13
20
|
* @returns {Function}
|
|
@@ -16,9 +23,18 @@ import{createSelector}from'reselect';import{makeGetProductByCharacteristics}from
|
|
|
16
23
|
* a product / variant by its characteristics
|
|
17
24
|
* @returns {Function}
|
|
18
25
|
*/export var makeGetSubscriptionByCharacteristics=function makeGetSubscriptionByCharacteristics(){var getProductByCharacteristics=makeGetProductByCharacteristics();return createSelector(getProductByCharacteristics,getBackInStockSubscriptions,function(product,subscriptions){if(!product){return null;}return subscriptions.find(function(_ref2){var productCode=_ref2.productCode;return productCode===product.id;})||null;});};/**
|
|
19
|
-
*
|
|
26
|
+
* Creates a selector to determine if the back-in-stock feature is enabled
|
|
27
|
+
* @returns {Function}
|
|
28
|
+
*/export var getIsBackInStockEnabled=createSelector(getClientInformation,getIsIos,getBackInStockPushPermissionStatus,function(clientInformation,isIos,pushPermissionStatus){var isRNEngage=navigator.userAgent.includes('RN Engage');/**
|
|
29
|
+
* No support for the react-native-engage dev app on iOS since push token handling will not
|
|
30
|
+
* work as expected, and back-in-stock related requests will fail.
|
|
31
|
+
*/if(isIos&&isRNEngage){return false;}var _clientInformation$co=clientInformation.codebaseVersion,codebaseVersion=_clientInformation$co===void 0?'0.0.0':_clientInformation$co;var _codebaseVersion$spli=codebaseVersion.split('.'),_codebaseVersion$spli2=_slicedToArray(_codebaseVersion$spli,1),major=_codebaseVersion$spli2[0];/**
|
|
32
|
+
* The feature can be enabled on react-native-engage based apps (>= 11.0.0) with proper
|
|
33
|
+
* support for push permissions checks
|
|
34
|
+
*/if(parseInt(major,10)<11||pushPermissionStatus===PERMISSION_STATUS_NOT_SUPPORTED){return false;}return(appConfig===null||appConfig===void 0?void 0:appConfig.showBackInStock)||false;});/**
|
|
35
|
+
* Creates a selector to determine if back-in-stock related requests are currently possible.
|
|
20
36
|
* @returns {Function}
|
|
21
|
-
*/export var getIsBackInStockEnabled
|
|
37
|
+
*/export var getAreBackInStockRequestsPossible=createSelector(getIsBackInStockEnabled,getBackInStockPushPermissionStatus,function(featureEnabled,pushPermissionStatus){return featureEnabled&&pushPermissionStatus===PERMISSION_STATUS_GRANTED;});/**
|
|
22
38
|
* Returns if subscription list is in use
|
|
23
39
|
* @returns {Function}
|
|
24
40
|
*/export var getHasBackInStockSubscriptions=createSelector(getBackInStockSubscriptions,function(subscriptions){return!!subscriptions.length;});
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
-
import showModal from'@shopgate/pwa-common/actions/modal/showModal';import{fetchBackInStockSubscriptions}from'@shopgate/engage/back-in-stock/actions';import{addBackInStockReminderSuccess$,backInStockReminderNeedsFetch$}from'@shopgate/engage/back-in-stock/streams';/**
|
|
1
|
+
import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}import{appWillInit$}from'@shopgate/engage/core';import{PERMISSION_ID_PUSH}from'@shopgate/engage/core/constants';import{appInitialization}from'@shopgate/engage/core/collections';import{requestAppPermissionStatus}from'@shopgate/engage/core/actions';import showModal from'@shopgate/pwa-common/actions/modal/showModal';import{fetchBackInStockSubscriptions}from'@shopgate/engage/back-in-stock/actions';import{addBackInStockReminderSuccess$,backInStockReminderNeedsFetch$}from'@shopgate/engage/back-in-stock/streams';import{getIsBackInStockEnabled,getAreBackInStockRequestsPossible}from'@shopgate/engage/back-in-stock/selectors';/**
|
|
2
2
|
* @param {Function} subscribe The subscribe function.
|
|
3
|
-
*/export default function backInStock(subscribe){subscribe(
|
|
3
|
+
*/export default function backInStock(subscribe){subscribe(appWillInit$,function(){/**
|
|
4
|
+
* Back-in-stock requests are only possible when users granted push permissions. Otherwise
|
|
5
|
+
* the backend will not be able to assign the subscriptions to a device.
|
|
6
|
+
*
|
|
7
|
+
* So in the next block we register a new handler to the "appInitialization" collection which
|
|
8
|
+
* will retrieve the current status of the push permission before the React app starts.
|
|
9
|
+
*
|
|
10
|
+
* The back-in-stock reducer will store the status, so that selectors can work with it.
|
|
11
|
+
*/appInitialization.set('back-in-stock',/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref){var dispatch,getState,isEnabled;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:dispatch=_ref.dispatch,getState=_ref.getState;isEnabled=getIsBackInStockEnabled(getState());if(!isEnabled){_context.next=5;break;}_context.next=5;return dispatch(requestAppPermissionStatus({permissionId:PERMISSION_ID_PUSH}));case 5:case"end":return _context.stop();}}},_callee);}));return function(_x){return _ref2.apply(this,arguments);};}());});subscribe(backInStockReminderNeedsFetch$,function(_ref3){var dispatch=_ref3.dispatch,getState=_ref3.getState;var requestsPossible=getAreBackInStockRequestsPossible(getState());if(requestsPossible){dispatch(fetchBackInStockSubscriptions());}});subscribe(addBackInStockReminderSuccess$,function(_ref4){var dispatch=_ref4.dispatch;dispatch(showModal({title:'back_in_stock.add_back_in_stock_success_modal.title',message:'back_in_stock.add_back_in_stock_success_modal.message',confirm:'modal.confirm',dismiss:null}));});}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import{APP_PERMISSION_STATUS_RECEIVED}from"../constants/actionTypes";/**
|
|
2
|
+
* Creates the APP_PERMISSION_STATUS_RECEIVED Redux action object that's supposed to be dispatched
|
|
3
|
+
* when a permission status was requested from the app.
|
|
4
|
+
* @param {Object} params Action params
|
|
5
|
+
* @param {string} params.permissionId The updated permission id
|
|
6
|
+
* @param {string} params.status The new status
|
|
7
|
+
* @param {Object} [params.options={}], Extended options for the permission
|
|
8
|
+
* @returns {Object} The Redux action object
|
|
9
|
+
*/export var appPermissionStatusReceived=function appPermissionStatusReceived(_ref){var permissionId=_ref.permissionId,status=_ref.status,_ref$options=_ref.options,options=_ref$options===void 0?{}:_ref$options;return{type:APP_PERMISSION_STATUS_RECEIVED,permissionId:permissionId,status:status,options:options};};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"./appPermissions";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}import grantGeolocationPermissions from"./grantGeolocationPermissions";import GeolocationRequest from"../classes/GeolocationRequest"
|
|
1
|
+
import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}import{GEOLOCATION_ERROR_DENIED}from'@shopgate/engage/core/constants';import grantGeolocationPermissions from"./grantGeolocationPermissions";import GeolocationRequest from"../classes/GeolocationRequest";/**
|
|
2
2
|
* Determines the geolocation of the user. When not geolocation permissions are granted yet,
|
|
3
3
|
* the user will be prompted to grant access.
|
|
4
4
|
* @param {Object} options Action options.
|
|
@@ -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{PERMISSION_ID_CAMERA}from'@shopgate/
|
|
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{PERMISSION_ID_CAMERA}from'@shopgate/engage/core/constants';import grantPermissions from"./grantPermissions";/**
|
|
2
2
|
* Determines the current state of the camera permissions.
|
|
3
3
|
* If not already happened, the user will be prompted to grant permissions.
|
|
4
4
|
* The action returns a promise which resolves with a boolean value, that indicates the state.
|
|
@@ -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{PERMISSION_ID_LOCATION}from'@shopgate/
|
|
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{PERMISSION_ID_LOCATION}from'@shopgate/engage/core/constants';import grantPermissions from"./grantPermissions";/**
|
|
2
2
|
* Determines the current state of the geolocation permissions.
|
|
3
3
|
* If not already happened, the user will be prompted to grant permissions.
|
|
4
4
|
* The action returns a promise which resolves with a boolean value, that indicates the state.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _regeneratorRuntime from"@babel/runtime/regenerator";function
|
|
1
|
+
import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}import event from'@shopgate/pwa-core/classes/Event';import openAppSettings from'@shopgate/pwa-core/commands/openAppSettings';import{showModal}from'@shopgate/engage/core';import{PERMISSION_STATUS_DENIED,PERMISSION_STATUS_GRANTED,PERMISSION_STATUS_NOT_DETERMINED,PERMISSION_STATUS_NOT_SUPPORTED,APP_EVENT_APPLICATION_WILL_ENTER_FOREGROUND,availablePermissionsIds}from'@shopgate/engage/core/constants';import{logger}from'@shopgate/pwa-core/helpers';import requestAppPermission from"./requestAppPermission";import requestAppPermissionStatus from"./requestAppPermissionStatus";/**
|
|
2
2
|
* Determines the current state of a specific permission for an app feature. If not already
|
|
3
3
|
* happened, the user will be prompted to grant permissions.
|
|
4
4
|
* The action returns a promise which resolves with a boolean value, that indicates the state.
|
|
@@ -20,10 +20,10 @@ import _regeneratorRuntime from"@babel/runtime/regenerator";function _slicedToAr
|
|
|
20
20
|
* @param {string} options.modal.dismiss Label for the dismiss button.
|
|
21
21
|
* @param {Object} options.modal.params Additional parameters for i18n strings.
|
|
22
22
|
* @return { Function } A redux thunk.
|
|
23
|
-
*/var grantPermissions=function grantPermissions(){var options=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return function(dispatch){return new Promise(/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(resolve){var permissionId,_options$useSettingsM,useSettingsModal,_options$useRationale,useRationaleModal,_options$rationaleMod,rationaleModalOptions,_options$modal,modalOptions,status,
|
|
23
|
+
*/var grantPermissions=function grantPermissions(){var options=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return function(dispatch){return new Promise(/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(resolve){var permissionId,_options$useSettingsM,useSettingsModal,_options$useRationale,useRationaleModal,_options$rationaleMod,rationaleModalOptions,_options$modal,modalOptions,status,requestAllowed,openSettings,handler;return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1){switch(_context2.prev=_context2.next){case 0:permissionId=options.permissionId,_options$useSettingsM=options.useSettingsModal,useSettingsModal=_options$useSettingsM===void 0?false:_options$useSettingsM,_options$useRationale=options.useRationaleModal,useRationaleModal=_options$useRationale===void 0?false:_options$useRationale,_options$rationaleMod=options.rationaleModal,rationaleModalOptions=_options$rationaleMod===void 0?{}:_options$rationaleMod,_options$modal=options.modal,modalOptions=_options$modal===void 0?{}:_options$modal;if(availablePermissionsIds.includes(permissionId)){_context2.next=5;break;}logger.error('grandPermissions: %s is no valid permission id',permissionId);resolve(false);return _context2.abrupt("return");case 5:_context2.next=7;return dispatch(requestAppPermissionStatus({permissionId:permissionId}));case 7:status=_context2.sent;if(!(status===PERMISSION_STATUS_NOT_SUPPORTED)){_context2.next=11;break;}resolve(false);return _context2.abrupt("return");case 11:if(!(status===PERMISSION_STATUS_NOT_DETERMINED)){_context2.next=25;break;}if(!useRationaleModal){_context2.next=19;break;}_context2.next=15;return dispatch(showModal({message:rationaleModalOptions.message||'',confirm:rationaleModalOptions.confirm||'',dismiss:rationaleModalOptions.dismiss||'',params:rationaleModalOptions.params}));case 15:requestAllowed=_context2.sent;if(!(requestAllowed===false)){_context2.next=19;break;}resolve(false);return _context2.abrupt("return");case 19:_context2.next=21;return dispatch(requestAppPermission({permissionId:permissionId}));case 21:status=_context2.sent;if(![PERMISSION_STATUS_DENIED,PERMISSION_STATUS_NOT_DETERMINED].includes(status)){_context2.next=25;break;}resolve(false);return _context2.abrupt("return");case 25:if(!(status===PERMISSION_STATUS_GRANTED)){_context2.next=28;break;}resolve(true);return _context2.abrupt("return");case 28:if(!(status===PERMISSION_STATUS_DENIED)){_context2.next=41;break;}if(useSettingsModal){_context2.next=32;break;}resolve(false);return _context2.abrupt("return");case 32:_context2.next=34;return dispatch(showModal({title:modalOptions.title||null,message:modalOptions.message,confirm:modalOptions.confirm,dismiss:modalOptions.dismiss,params:modalOptions.params}));case 34:openSettings=_context2.sent;if(openSettings){_context2.next=38;break;}resolve(false);return _context2.abrupt("return");case 38:/**
|
|
24
24
|
* Handler for the app event.
|
|
25
|
-
*/handler=/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){
|
|
25
|
+
*/handler=/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:event.removeCallback(APP_EVENT_APPLICATION_WILL_ENTER_FOREGROUND,handler);_context.next=3;return dispatch(requestAppPermissionStatus({permissionId:permissionId}));case 3:status=_context.sent;resolve(status===PERMISSION_STATUS_GRANTED);case 5:case"end":return _context.stop();}}},_callee);}));return function handler(){return _ref2.apply(this,arguments);};}();/**
|
|
26
26
|
* Register an event handler, so that we can perform the permissions check again,
|
|
27
27
|
* when the user comes back from the settings.
|
|
28
28
|
*/event.addCallback(APP_EVENT_APPLICATION_WILL_ENTER_FOREGROUND,handler);// Open the settings (protected by a timeout, so that the modal closes before the app is left).
|
|
29
|
-
setTimeout(function(){openAppSettings();},0);case
|
|
29
|
+
setTimeout(function(){openAppSettings();},0);case 41:case"end":return _context2.stop();}}},_callee2);}));return function(_x){return _ref.apply(this,arguments);};}());};};export default grantPermissions;
|
|
@@ -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{PERMISSION_ID_PUSH}from'@shopgate/
|
|
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{PERMISSION_ID_PUSH}from'@shopgate/engage/core/constants';import grantPermissions from"./grantPermissions";/**
|
|
2
2
|
* Determines the current state of the push permissions.
|
|
3
3
|
* If not already happened, the user will be prompted to grant permissions.
|
|
4
4
|
* The action returns a promise which resolves with a boolean value, that indicates the state.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{default as getGeolocation}from"./getGeolocation";export{default as grantCameraPermissions}from"./grantCameraPermissions";export{default as grantGeolocationPermissions}from"./grantGeolocationPermissions";export{default as grantPushPermissions}from"./grantPushPermissions";export{default as requestAppPermission}from"./requestAppPermission";export{default as requestAppPermissionStatus}from"./requestAppPermissionStatus";export{default as updateStatusBarBackground}from"./updateStatusBarBackground";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import _regeneratorRuntime from"@babel/runtime/regenerator";function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i];}return arr2;}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}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{requestAppPermissions}from'@shopgate/pwa-core/commands/appPermissions';import{PERMISSION_STATUS_NOT_SUPPORTED}from'@shopgate/engage/core/constants';import{appPermissionStatusReceived}from"../action-creators";/**
|
|
2
|
+
* Requests an additional app permission from the operating system.
|
|
3
|
+
* Additionally it propagates * the received status via the APP_PERMISSION_STATUS_RECEIVED action.
|
|
4
|
+
* @param {Object} params The action params
|
|
5
|
+
* @param {string} params.permissionId The desired app permission id
|
|
6
|
+
* @returns {Function} A Redux thunk
|
|
7
|
+
*/var requestAppPermission=function requestAppPermission(_ref){var permissionId=_ref.permissionId;return/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch){var _yield$requestAppPerm;var _ref3,_ref4,_ref4$,status,options;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:_context.next=2;return requestAppPermissions([{permissionId:permissionId}]);case 2:_context.t1=_yield$requestAppPerm=_context.sent;_context.t0=_context.t1!==null;if(!_context.t0){_context.next=6;break;}_context.t0=_yield$requestAppPerm!==void 0;case 6:if(!_context.t0){_context.next=10;break;}_context.t2=_yield$requestAppPerm;_context.next=11;break;case 10:_context.t2=[];case 11:_ref3=_context.t2;_ref4=_slicedToArray(_ref3,1);_ref4$=_ref4[0];_ref4$=_ref4$===void 0?{status:PERMISSION_STATUS_NOT_SUPPORTED}:_ref4$;status=_ref4$.status,options=_ref4$.options;dispatch(appPermissionStatusReceived({permissionId:permissionId,status:status,options:options}));return _context.abrupt("return",status);case 18:case"end":return _context.stop();}}},_callee);}));return function(_x){return _ref2.apply(this,arguments);};}();};export default requestAppPermission;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import _regeneratorRuntime from"@babel/runtime/regenerator";function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i];}return arr2;}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}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{getAppPermissions}from'@shopgate/pwa-core/commands/appPermissions';import{PERMISSION_STATUS_NOT_SUPPORTED}from'@shopgate/engage/core/constants';import{appPermissionStatusReceived}from"../action-creators";/**
|
|
2
|
+
* Determines the current status of an app permission from the operating system.
|
|
3
|
+
* Additionally it propagates the received status via the APP_PERMISSION_STATUS_RECEIVED action.
|
|
4
|
+
* @param {Object} params The action params
|
|
5
|
+
* @param {string} params.permissionId The desired app permission id
|
|
6
|
+
* @returns {Function} A Redux thunk
|
|
7
|
+
*/var requestAppPermissionStatus=function requestAppPermissionStatus(_ref){var permissionId=_ref.permissionId;return/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch){var _yield$getAppPermissi;var _ref3,_ref4,_ref4$,status,options;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:_context.next=2;return getAppPermissions([permissionId]);case 2:_context.t1=_yield$getAppPermissi=_context.sent;_context.t0=_context.t1!==null;if(!_context.t0){_context.next=6;break;}_context.t0=_yield$getAppPermissi!==void 0;case 6:if(!_context.t0){_context.next=10;break;}_context.t2=_yield$getAppPermissi;_context.next=11;break;case 10:_context.t2=[];case 11:_ref3=_context.t2;_ref4=_slicedToArray(_ref3,1);_ref4$=_ref4[0];_ref4$=_ref4$===void 0?{status:PERMISSION_STATUS_NOT_SUPPORTED}:_ref4$;status=_ref4$.status,options=_ref4$.options;dispatch(appPermissionStatusReceived({permissionId:permissionId,status:status,options:options}));return _context.abrupt("return",status);case 18:case"end":return _context.stop();}}},_callee);}));return function(_x){return _ref2.apply(this,arguments);};}();};export default requestAppPermissionStatus;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import _regeneratorRuntime from"@babel/runtime/regenerator";function _createForOfIteratorHelper(o,allowArrayLike){var it=typeof Symbol!=="undefined"&&o[Symbol.iterator]||o["@@iterator"];if(!it){if(Array.isArray(o)||(it=_unsupportedIterableToArray(o))||allowArrayLike&&o&&typeof o.length==="number"){if(it)o=it;var i=0;var F=function F(){};return{s:F,n:function n(){if(i>=o.length)return{done:true};return{done:false,value:o[i++]};},e:function e(_e){throw _e;},f:F};}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}var normalCompletion=true,didErr=false,err;return{s:function s(){it=it.call(o);},n:function n(){var step=it.next();normalCompletion=step.done;return step;},e:function e(_e2){didErr=true;err=_e2;},f:function f(){try{if(!normalCompletion&&it["return"]!=null)it["return"]();}finally{if(didErr)throw err;}}};}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i];}return arr2;}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);Object.defineProperty(Constructor,"prototype",{writable:false});return Constructor;}/**
|
|
2
|
+
* @callback AppInitializationHandler
|
|
3
|
+
* @param {Object} params
|
|
4
|
+
* @param {Function} params.dispatch Redux dispatch function
|
|
5
|
+
* @param {Function} params.getState Redux dispatch function
|
|
6
|
+
* @returns {Promise}
|
|
7
|
+
*/ /**
|
|
8
|
+
* Class to maintain handler functions that are executed before the React app initializes.
|
|
9
|
+
*
|
|
10
|
+
* Handlers are invoked before the React app initializes. They can
|
|
11
|
+
* interact with Redux via "dispatch" and "getState" and e.g. initialize states based on
|
|
12
|
+
* information which is retrieved via app commands.
|
|
13
|
+
*
|
|
14
|
+
* Since the handler execution is blocking and postpones the React app initialization, this
|
|
15
|
+
* system should be handled with care.
|
|
16
|
+
*/var AppInitialization=/*#__PURE__*/function(){/**
|
|
17
|
+
* Constructor
|
|
18
|
+
*/function AppInitialization(){_classCallCheck(this,AppInitialization);this.store=new Map();}/**
|
|
19
|
+
* Get an initialization handler
|
|
20
|
+
* @param {*} key Identifier for the handler
|
|
21
|
+
* @returns {Promise}
|
|
22
|
+
*/_createClass(AppInitialization,[{key:"get",value:function get(key){return this.store.get(key);}/**
|
|
23
|
+
* Sets an initialization handler.
|
|
24
|
+
*
|
|
25
|
+
* @param {*} key Identifier for the handler
|
|
26
|
+
* @param {AppInitializationHandler} handler The actual handler
|
|
27
|
+
* @returns {AppInitialization}
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* const handler = ({ dispatch, getState }) => {
|
|
31
|
+
* return new Promise(async (resolve) => {
|
|
32
|
+
* // Retrieve some data from the app via app command
|
|
33
|
+
* const appCommandResponse = await getAppCommandResponse();
|
|
34
|
+
* // Retrieve some data from Redux (store will be nearly empty at this point)
|
|
35
|
+
* const reduxValue = getValueFromRedux(getState());
|
|
36
|
+
* // Dispatch Redux actions to initialize a Redux state
|
|
37
|
+
* dispatch(reduxAction(reduxValue, appCommandResponse));
|
|
38
|
+
* resolve();
|
|
39
|
+
* });
|
|
40
|
+
*
|
|
41
|
+
* appInitialization.set('handler-key', handler);
|
|
42
|
+
* }
|
|
43
|
+
*/},{key:"set",value:function set(key,handler){this.store.set(key,handler);return this;}/**
|
|
44
|
+
* Invokes all registered handlers
|
|
45
|
+
* @returns {Promise<{results: [], errors: []}>}
|
|
46
|
+
*/},{key:"initialize",value:function(){var _initialize=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref){var dispatch,getState,promises,results,errors,_iterator,_step,promise;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:dispatch=_ref.dispatch,getState=_ref.getState;promises=Array.from(this.store.values()).map(function(handler){var res;// Take care that errors inside handlers don't break the app
|
|
47
|
+
try{res=handler({dispatch:dispatch,getState:getState});}catch(e){// Nothing to see here
|
|
48
|
+
}return res;}).filter(Boolean);results=[];errors=[];// eslint-disable-next-line no-restricted-syntax
|
|
49
|
+
_iterator=_createForOfIteratorHelper(promises);_context.prev=5;_iterator.s();case 7:if((_step=_iterator.n()).done){_context.next=22;break;}promise=_step.value;_context.prev=9;_context.t0=results;_context.next=13;return promise;case 13:_context.t1=_context.sent;_context.t0.push.call(_context.t0,_context.t1);_context.next=20;break;case 17:_context.prev=17;_context.t2=_context["catch"](9);errors.push(_context.t2);case 20:_context.next=7;break;case 22:_context.next=27;break;case 24:_context.prev=24;_context.t3=_context["catch"](5);_iterator.e(_context.t3);case 27:_context.prev=27;_iterator.f();return _context.finish(27);case 30:return _context.abrupt("return",{results:results,errors:errors});case 31:case"end":return _context.stop();}}},_callee,this,[[5,24,27,30],[9,17]]);}));function initialize(_x){return _initialize.apply(this,arguments);}return initialize;}()}]);return AppInitialization;}();export default new AppInitialization();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{default as appInitialization}from"./AppInitialization";export*from'@shopgate/pwa-common/collections';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export var APP_PERMISSION_STATUS_RECEIVED='APP_PERMISSION_STATUS_RECEIVED';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{INDEX_PATH,INDEX_PATH_DEEPLINK}from'@shopgate/pwa-common/constants/RoutePaths';export*from"./actionTypes";export*from"./geolocationRequest";// Core Constants
|
|
2
|
+
export*from'@shopgate/pwa-core/constants/AppEvents';export*from'@shopgate/pwa-core/constants/AppPermissions';export*from'@shopgate/pwa-core/constants/ErrorHandleTypes';export*from'@shopgate/pwa-core/constants/Pipeline';export*from'@shopgate/pwa-core/constants/ProcessTypes';export*from'@shopgate/pwa-core/constants/Scanner';export*from'@shopgate/pwa-core/constants/Trilean';// Common Constants
|
|
3
|
+
export*from'@shopgate/pwa-common/constants/ActionTypes';export*from'@shopgate/pwa-common/constants/Configuration';export*from'@shopgate/pwa-common/constants/Device';export*from'@shopgate/pwa-common/constants/DisplayOptions';export*from'@shopgate/pwa-common/constants/Pipelines';export*from'@shopgate/pwa-common/constants/Portals';// CLIENT CONSTANTS
|
|
4
|
+
export*from'@shopgate/pwa-common/constants/client';// MENU CONSTANTS
|
|
5
|
+
export*from'@shopgate/pwa-common/constants/MenuIDs';// MODAL CONSTANTS
|
|
6
|
+
export*from'@shopgate/pwa-common/constants/ModalTypes';export{INDEX_PATH,INDEX_PATH_DEEPLINK};
|
package/core/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @module core */import{getCurrentRoute as getCurrentRouteHelper,router,history,parseQueryStringToObject,parseObjectToQueryString}from'@shopgate/pwa-common/helpers/router'
|
|
1
|
+
/** @module core */import{getCurrentRoute as getCurrentRouteHelper,router,history,parseQueryStringToObject,parseObjectToQueryString}from'@shopgate/pwa-common/helpers/router';// --------------- CORE --------------- //
|
|
2
2
|
// Classes
|
|
3
3
|
// TODO: Contains circular dependency!
|
|
4
4
|
// export { default as AppCommand } from '@shopgate/pwa-core/classes/AppCommand';
|
|
@@ -6,8 +6,7 @@ export{default as GetAppPermissionsRequest}from'@shopgate/pwa-core/classes/AppPe
|
|
|
6
6
|
export{default as analyticsSetCustomValues}from'@shopgate/pwa-core/commands/analyticsSetCustomValues';export*from'@shopgate/pwa-core/commands/appPermissions';export*from'@shopgate/pwa-core/commands/brightness';export{default as broadcastEvent}from'@shopgate/pwa-core/commands/broadcastEvent';export{default as cleanTab,cleanTabCmd}from'@shopgate/pwa-core/commands/cleanTab';export{default as closeInAppBrowser}from'@shopgate/pwa-core/commands/closeInAppBrowser';export{default as flushTab}from'@shopgate/pwa-core/commands/flushTab';export{default as hideMenuBar}from'@shopgate/pwa-core/commands/hideMenuBar';export{default as hideNavigationBar}from'@shopgate/pwa-core/commands/hideNavigationBar';export{default as hideSplashScreen}from'@shopgate/pwa-core/commands/hideSplashScreen';export{default as onload}from'@shopgate/pwa-core/commands/onload';export{default as openAppSettings}from'@shopgate/pwa-core/commands/openAppSettings';export{default as openPage}from'@shopgate/pwa-core/commands/openPage';export{default as openPageExtern}from'@shopgate/pwa-core/commands/openPageExtern';export{default as performCommandsAfterDelay,performCommandsAfterDelayCmd}from'@shopgate/pwa-core/commands/performCommandsAfterDelay';export*from'@shopgate/pwa-core/commands/plotProjects';export{default as popTabToRoot,popTabToRootCmd}from'@shopgate/pwa-core/commands/popTabToRoot';export{default as registerEvents}from'@shopgate/pwa-core/commands/registerEvents';export*from'@shopgate/pwa-core/commands/scanner';export{default as setCookie}from'@shopgate/pwa-core/commands/setCookie';export{default as setDebugLoggingEnabled}from'@shopgate/pwa-core/commands/setDebugLoggingEnabled';export{default as setScrollingEnabled}from'@shopgate/pwa-core/commands/setScrollingEnabled';export{default as showNavigationBar}from'@shopgate/pwa-core/commands/showNavigationBar';export{default as showTab}from'@shopgate/pwa-core/commands/showTab';export*from'@shopgate/pwa-core/commands/unifiedTracking';// TODO: Contains circular dependency!
|
|
7
7
|
// export * from '@shopgate/pwa-core/commands/webStorage';
|
|
8
8
|
// Constants
|
|
9
|
-
export*from
|
|
10
|
-
export*from'@shopgate/pwa-common/constants/ActionTypes';export*from'@shopgate/pwa-common/constants/Configuration';export*from'@shopgate/pwa-common/constants/Device';export*from'@shopgate/pwa-common/constants/DisplayOptions';export*from'@shopgate/pwa-common/constants/Pipelines';export*from'@shopgate/pwa-common/constants/Portals';export{INDEX_PATH,INDEX_PATH_DEEPLINK};export*from"./constants/geolocationRequest";// Emitters
|
|
9
|
+
export*from"./constants";// Emitters
|
|
11
10
|
export{default as UIEvents}from'@shopgate/pwa-core/emitters/ui';// Helpers
|
|
12
11
|
export*from'@shopgate/pwa-core/helpers';export{default as logGroup}from'@shopgate/pwa-core/helpers/logGroup';export*from'@shopgate/pwa-core/helpers/version';export*from'@shopgate/pwa-common/helpers/data';export*from'@shopgate/pwa-common/helpers/date';export*from'@shopgate/pwa-common/helpers/dom';export*from'@shopgate/pwa-common/helpers/environment';export{default as decodeHTML}from'@shopgate/pwa-common/helpers/html/decodeHTML';export*from'@shopgate/pwa-common/helpers/html/handleDOM';export{default as parseHTML}from'@shopgate/pwa-common/helpers/html/parseHTML';export{default as getTranslator}from'@shopgate/pwa-common/helpers/i18n/getTranslator';export{default as getPriceFormatter}from'@shopgate/pwa-common/helpers/i18n/getPriceFormatter';export{default as getDateFormatter}from'@shopgate/pwa-common/helpers/i18n/getDateFormatter';export{default as getTimeFormatter}from'@shopgate/pwa-common/helpers/i18n/getTimeFormatter';export{default as getNumberFormatter}from'@shopgate/pwa-common/helpers/i18n/getNumberFormatter';export*from'@shopgate/pwa-common/helpers/legacy';// TODO: Can only be exported once the theme uses it. causes issues with the custom routes feature.
|
|
13
12
|
/*
|
|
@@ -16,15 +15,14 @@ export { default as routePortals } from '@shopgate/pwa-common/helpers/portals/ro
|
|
|
16
15
|
*/export*from'@shopgate/pwa-common/helpers/redux';export*from'@shopgate/pwa-common/helpers/style';export*from'@shopgate/pwa-common/helpers/tracking';export*from'@shopgate/pwa-common/helpers/validation';// STREAMS
|
|
17
16
|
export*from'@shopgate/pwa-common/streams/main';export*from'@shopgate/pwa-common/streams/error';// --------------- APP --------------- //
|
|
18
17
|
// ACTIONS
|
|
19
|
-
export{default as handleDeepLink}from'@shopgate/pwa-common/actions/app/handleDeepLink';export{default as handleUniversalLink}from'@shopgate/pwa-common/actions/app/handleUniversalLink';export{default as handleLink}from'@shopgate/pwa-common/actions/app/handleLink';export{default as handlePushNotification}from'@shopgate/pwa-common/actions/app/handlePushNotification';export{default as registerLinkEvents}from'@shopgate/pwa-common/actions/app/registerLinkEvents';export{default as updateStatusBarBackground}from"./actions/updateStatusBarBackground";export{default as grantPermissions}from"./actions/grantPermissions";export{default as grantPushPermissions}from"./actions/grantPushPermissions";export{default as grantCameraPermissions}from"./actions/grantCameraPermissions";export{default as grantGeolocationPermissions}from"./actions/grantGeolocationPermissions";export{default as getGeolocation}from"./actions/getGeolocation";// STREAMS
|
|
18
|
+
export{default as handleDeepLink}from'@shopgate/pwa-common/actions/app/handleDeepLink';export{default as handleUniversalLink}from'@shopgate/pwa-common/actions/app/handleUniversalLink';export{default as handleLink}from'@shopgate/pwa-common/actions/app/handleLink';export{default as handlePushNotification}from'@shopgate/pwa-common/actions/app/handlePushNotification';export{default as registerLinkEvents}from'@shopgate/pwa-common/actions/app/registerLinkEvents';export{default as updateStatusBarBackground}from"./actions/updateStatusBarBackground";export{default as grantPermissions}from"./actions/grantPermissions";export{default as grantPushPermissions}from"./actions/grantPushPermissions";export{default as grantCameraPermissions}from"./actions/grantCameraPermissions";export{default as grantGeolocationPermissions}from"./actions/grantGeolocationPermissions";export{default as requestAppPermission}from"./actions/requestAppPermission";export{default as requestAppPermissionStatus}from"./actions/requestAppPermissionStatus";export{default as getGeolocation}from"./actions/getGeolocation";// STREAMS
|
|
20
19
|
export*from'@shopgate/pwa-common/streams/app';// --------------- STORE --------------- //
|
|
21
20
|
export*from'@shopgate/pwa-common/store';// --------------- CLIENT --------------- //
|
|
22
21
|
// ACTIONS
|
|
23
|
-
export{default as fetchClientInformation}from'@shopgate/pwa-common/actions/client/fetchClientInformation';//
|
|
24
|
-
export*from'@shopgate/pwa-common/constants/client';// SELECTORS
|
|
22
|
+
export{default as fetchClientInformation}from'@shopgate/pwa-common/actions/client/fetchClientInformation';// SELECTORS
|
|
25
23
|
export*from'@shopgate/pwa-common/selectors/client';// STREAMS
|
|
26
24
|
export*from'@shopgate/pwa-common/streams/client';// --------------- COLLECTIONS --------------- //
|
|
27
|
-
export{default as authRoutes}from'@shopgate/pwa-common/collections/AuthRoutes';export{default as redirects}from'@shopgate/pwa-common/collections/Redirects';export{default as configuration}from'@shopgate/pwa-common/collections/Configuration';export{default as embeddedMedia}from'@shopgate/pwa-common/collections/EmbeddedMedia';export{default as persistedReducers}from'@shopgate/pwa-common/collections/PersistedReducers';export{default as Vimeo}from'@shopgate/pwa-common/collections/media-providers/Vimeo';export{default as YouTube}from'@shopgate/pwa-common/collections/media-providers/YouTube';// --------------- CONTEXTS --------------- //
|
|
25
|
+
export{default as appInitialization}from"./collections/AppInitialization";export{default as authRoutes}from'@shopgate/pwa-common/collections/AuthRoutes';export{default as redirects}from'@shopgate/pwa-common/collections/Redirects';export{default as configuration}from'@shopgate/pwa-common/collections/Configuration';export{default as embeddedMedia}from'@shopgate/pwa-common/collections/EmbeddedMedia';export{default as persistedReducers}from'@shopgate/pwa-common/collections/PersistedReducers';export{default as Vimeo}from'@shopgate/pwa-common/collections/media-providers/Vimeo';export{default as YouTube}from'@shopgate/pwa-common/collections/media-providers/YouTube';// --------------- CONTEXTS --------------- //
|
|
28
26
|
export*from'@shopgate/pwa-common/context';export{default as AppContext}from"./contexts/AppContext";// --------------- PROVIDERS --------------- //
|
|
29
27
|
export{default as LoadingProvider}from'@shopgate/pwa-common/providers/loading';export{default as LoadingContext}from'@shopgate/pwa-common/providers/loading/context';export{default as ToastProvider}from'@shopgate/pwa-common/providers/toast';export{default as ToastContext}from'@shopgate/pwa-common/providers/toast/context';export{default as AppProvider}from"./providers/AppProvider";// --------------- ROUTER --------------- //
|
|
30
28
|
// ACTIONS
|
|
@@ -36,15 +34,13 @@ export*from'@shopgate/pwa-common/streams/router';// --------------- URL --------
|
|
|
36
34
|
export{resetApp}from'@shopgate/pwa-common/action-creators/app';export*from'@shopgate/pwa-common/action-creators/url';// SELECTORS
|
|
37
35
|
export*from'@shopgate/pwa-common/selectors/url';// --------------- MENU --------------- //
|
|
38
36
|
// ACTIONS
|
|
39
|
-
export{default as fetchMenu}from'@shopgate/pwa-common/actions/menu/fetchMenu';//
|
|
40
|
-
export*from'@shopgate/pwa-common/constants/MenuIDs';// SELECTORS
|
|
37
|
+
export{default as fetchMenu}from'@shopgate/pwa-common/actions/menu/fetchMenu';// SELECTORS
|
|
41
38
|
export*from'@shopgate/pwa-common/selectors/menu';// --------------- MODAL --------------- //
|
|
42
39
|
// ACTIONS
|
|
43
|
-
export{default as closeModal}from'@shopgate/pwa-common/actions/modal/closeModal';export{default as promiseMap}from'@shopgate/pwa-common/actions/modal/promiseMap';export{default as showModal}from'@shopgate/pwa-common/actions/modal/showModal';//
|
|
44
|
-
export*from'@shopgate/pwa-common/constants/ModalTypes';// HELPERS
|
|
40
|
+
export{default as closeModal}from'@shopgate/pwa-common/actions/modal/closeModal';export{default as promiseMap}from'@shopgate/pwa-common/actions/modal/promiseMap';export{default as showModal}from'@shopgate/pwa-common/actions/modal/showModal';// HELPERS
|
|
45
41
|
export{default as withShowModal}from'@shopgate/pwa-common/helpers/modal/withShowModal';// SELECTORS
|
|
46
42
|
export*from'@shopgate/pwa-common/selectors/modal';// --------------- HOOKS --------------- //
|
|
47
43
|
export{useRoute}from"./hooks/useRoute";export{useTheme}from"./hooks/useTheme";export{useCurrentProduct}from"./hooks/useCurrentProduct";export{useNavigation}from"./hooks/useNavigation";export{usePageConfig}from"./hooks/usePageConfig";export{usePageSettings}from"./hooks/usePageSettings";export{useWidgetConfig}from"./hooks/useWidgetConfig";export{useWidgetSettings}from"./hooks/useWidgetSettings";export{useWidgetStyles}from"./hooks/useWidgetStyles";export*from"./hooks/html";// --------------- HOCs --------------- //
|
|
48
44
|
export{withTheme}from"./hocs/withTheme";export{withRoute}from"./hocs/withRoute";export{withCurrentProduct}from"./hocs/withCurrentProduct";export{withForwardedRef}from"./hocs/withForwardedRef";export{withNavigation}from"./hocs/withNavigation";export{withWidgetSettings}from"./hocs/withWidgetSettings";export{withWidgetStyles}from"./hocs/withWidgetStyles";export{withApp}from"./hocs/withApp";// --------------- CONFIG --------------- //
|
|
49
45
|
export{ThemeConfigResolver}from"./config/ThemeConfigResolver";export{isBeta}from"./config/isBeta";export{getThemeConfig}from"./config/getThemeConfig";export{getThemeSettings}from"./config/getThemeSettings";export{getThemeColors}from"./config/getThemeColors";export{getThemeAssets}from"./config/getThemeAssets";export{getPageConfig}from"./config/getPageConfig";export{getPageSettings}from"./config/getPageSettings";export{getWidgetConfig}from"./config/getWidgetConfig";export{getWidgetSettings}from"./config/getWidgetSettings";// -------------- HELPERS -------------- //
|
|
50
|
-
export{i18n}from"./helpers/i18n";export{updateLegacyNavigationBar}from"./helpers/updateLegacyNavigationBar";export{getFullImageSource}from"./helpers/getFullImageSource";
|
|
46
|
+
export{i18n}from"./helpers/i18n";export{updateLegacyNavigationBar}from"./helpers/updateLegacyNavigationBar";export{getFullImageSource}from"./helpers/getFullImageSource";export*from"./initialization";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}import{appConfig}from'@shopgate/engage';import{i18n,configureStore,fetchClientInformation}from'@shopgate/engage/core';import{appInitialization}from'@shopgate/engage/core/collections';import{appWillInit,appWillStart}from'@shopgate/pwa-common/action-creators/app';var _appConfig$locales=appConfig.locales;_appConfig$locales=_appConfig$locales===void 0?{}:_appConfig$locales;var _appConfig$locales$cu=_appConfig$locales.currency,currencyLocale=_appConfig$locales$cu===void 0?null:_appConfig$locales$cu;/**
|
|
2
|
+
*
|
|
3
|
+
* @param {Object} locales An object with locales.
|
|
4
|
+
* @param {Function} reducers The reducers from the theme.
|
|
5
|
+
* @param {Array} subscribers The subscribers to the streams middleware.
|
|
6
|
+
*/export var initialize=/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(locales,reducers,subscribers){var store;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:i18n.init({locales:locales,lang:process.env.LOCALE,currencyLocale:currencyLocale});store=configureStore(reducers,subscribers);_context.prev=2;_context.next=5;return store.dispatch(fetchClientInformation());case 5:_context.next=9;break;case 7:_context.prev=7;_context.t0=_context["catch"](2);case 9:store.dispatch(appWillInit("".concat(window.location.pathname).concat(window.location.search)));// Execute all registered handlers from the AppInitialization collection
|
|
7
|
+
_context.next=12;return appInitialization.initialize({dispatch:store.dispatch,getState:store.getState});case 12:store.dispatch(appWillStart("".concat(window.location.pathname).concat(window.location.search)));return _context.abrupt("return",{store:store});case 14:case"end":return _context.stop();}}},_callee,null,[[2,7]]);}));return function initialize(_x,_x2,_x3){return _ref.apply(this,arguments);};}();
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import{main$}from'@shopgate/pwa-common/streams/main';import{PERMISSION_ID_PUSH,PERMISSION_ID_CAMERA,PERMISSION_ID_LOCATION,PERMISSION_ID_PHONE,PERMISSION_ID_BACKGROUND_APP_REFRESH,APP_PERMISSION_STATUS_RECEIVED}from'@shopgate/engage/core/constants';/**
|
|
2
|
+
* Gets triggered when a permission status was received from the app.
|
|
3
|
+
* @type {Observable}
|
|
4
|
+
*/export var appPermissionStatusReceived$=main$.filter(function(_ref){var action=_ref.action;return action.type===APP_PERMISSION_STATUS_RECEIVED;});/**
|
|
5
|
+
* Gets triggered when a push permission status was received from the app.
|
|
6
|
+
* @type {Observable}
|
|
7
|
+
*/export var appPermissionStatusPushReceived$=appPermissionStatusReceived$.filter(function(_ref2){var action=_ref2.action;return action.permissionId===PERMISSION_ID_PUSH;});/**
|
|
8
|
+
* Gets triggered when a camera permission status was received from the app.
|
|
9
|
+
* @type {Observable}
|
|
10
|
+
*/export var appPermissionStatusCameraReceived$=appPermissionStatusReceived$.filter(function(_ref3){var action=_ref3.action;return action.permissionId===PERMISSION_ID_CAMERA;});/**
|
|
11
|
+
* Gets triggered when a location permission status was received from the app.
|
|
12
|
+
* @type {Observable}
|
|
13
|
+
*/export var appPermissionStatusLocationReceived$=appPermissionStatusReceived$.filter(function(_ref4){var action=_ref4.action;return action.permissionId===PERMISSION_ID_LOCATION;});/**
|
|
14
|
+
* Gets triggered when a phone permission status was received from the app.
|
|
15
|
+
* @type {Observable}
|
|
16
|
+
*/export var appPermissionStatusPhoneReceived$=appPermissionStatusReceived$.filter(function(_ref5){var action=_ref5.action;return action.permissionId===PERMISSION_ID_PHONE;});/**
|
|
17
|
+
* Gets triggered when a backgroundAppRefresh permission status was received from the app.
|
|
18
|
+
* @type {Observable}
|
|
19
|
+
*/export var appPermissionStatusBackgroundAppRefreshReceived$=appPermissionStatusReceived$.filter(function(_ref6){var action=_ref6.action;return action.permissionId===PERMISSION_ID_BACKGROUND_APP_REFRESH;});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"./appPermissions";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopgate/engage",
|
|
3
|
-
"version": "6.22.0-beta.
|
|
3
|
+
"version": "6.22.0-beta.4",
|
|
4
4
|
"description": "Shopgate's ENGAGE library.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Shopgate <support@shopgate.com>",
|
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
"connect"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@shopgate/pwa-common": "6.22.0-beta.
|
|
19
|
-
"@shopgate/pwa-common-commerce": "6.22.0-beta.
|
|
20
|
-
"@shopgate/pwa-core": "6.22.0-beta.
|
|
21
|
-
"@shopgate/pwa-ui-ios": "6.22.0-beta.
|
|
22
|
-
"@shopgate/pwa-ui-material": "6.22.0-beta.
|
|
23
|
-
"@shopgate/pwa-ui-shared": "6.22.0-beta.
|
|
18
|
+
"@shopgate/pwa-common": "6.22.0-beta.4",
|
|
19
|
+
"@shopgate/pwa-common-commerce": "6.22.0-beta.4",
|
|
20
|
+
"@shopgate/pwa-core": "6.22.0-beta.4",
|
|
21
|
+
"@shopgate/pwa-ui-ios": "6.22.0-beta.4",
|
|
22
|
+
"@shopgate/pwa-ui-material": "6.22.0-beta.4",
|
|
23
|
+
"@shopgate/pwa-ui-shared": "6.22.0-beta.4",
|
|
24
24
|
"@virtuous/conductor": "~2.4.0",
|
|
25
25
|
"babel-plugin-transform-es3-member-expression-literals": "^6.8.0",
|
|
26
26
|
"babel-plugin-transform-es3-property-literals": "^6.8.0",
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
2
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
3
|
+
<svg width="100%" height="100%" viewBox="0 0 1107 791" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
|
|
4
|
+
<g transform="matrix(1,0,0,1,-88.9596,-502.577)">
|
|
5
|
+
<g transform="matrix(1.28381,0,0,1.28381,-145.009,-328.293)">
|
|
6
|
+
<g>
|
|
7
|
+
<g transform="matrix(0.738616,0,0,0.7166,142.625,351.19)">
|
|
8
|
+
<path d="M1052.9,1091.68C1052.9,1062.46 1029.88,1038.73 1001.53,1038.73L244.024,1038.73C215.667,1038.73 192.646,1062.46 192.646,1091.68L192.646,1219.08C192.646,1248.3 215.667,1272.03 244.024,1272.03L1001.53,1272.03C1029.88,1272.03 1052.9,1248.3 1052.9,1219.08L1052.9,1091.68Z" style="fill:rgb(193,193,193);"/>
|
|
9
|
+
</g>
|
|
10
|
+
<g transform="matrix(0.859568,0,0,0.833947,80.1965,145.713)">
|
|
11
|
+
<path d="M1052.9,1091.68C1052.9,1062.46 1029.88,1038.73 1001.53,1038.73L244.024,1038.73C215.667,1038.73 192.646,1062.46 192.646,1091.68L192.646,1219.08C192.646,1248.3 215.667,1272.03 244.024,1272.03L1001.53,1272.03C1029.88,1272.03 1052.9,1248.3 1052.9,1219.08L1052.9,1091.68Z" style="fill:rgb(216,216,216);"/>
|
|
12
|
+
</g>
|
|
13
|
+
<g transform="matrix(1.00203,0,0,0.972164,-10.791,-90.8989)">
|
|
14
|
+
<path d="M1052.9,1091.68C1052.9,1062.46 1029.88,1038.73 1001.53,1038.73L244.024,1038.73C215.667,1038.73 192.646,1062.46 192.646,1091.68L192.646,1219.08C192.646,1248.3 215.667,1272.03 244.024,1272.03L1001.53,1272.03C1029.88,1272.03 1052.9,1248.3 1052.9,1219.08L1052.9,1091.68Z" style="fill:rgb(235,235,235);"/>
|
|
15
|
+
</g>
|
|
16
|
+
<g transform="matrix(1.00203,0,0,0.972164,-10.791,-362.62)">
|
|
17
|
+
<path d="M1052.9,1091.68C1052.9,1062.46 1029.88,1038.73 1001.53,1038.73L244.024,1038.73C215.667,1038.73 192.646,1062.46 192.646,1091.68L192.646,1219.08C192.646,1248.3 215.667,1272.03 244.024,1272.03L1001.53,1272.03C1029.88,1272.03 1052.9,1248.3 1052.9,1219.08L1052.9,1091.68Z" style="fill:rgb(235,235,235);"/>
|
|
18
|
+
</g>
|
|
19
|
+
</g>
|
|
20
|
+
<g transform="matrix(1.00052,0,0,1,-19.3912,30.3377)">
|
|
21
|
+
<path d="M953.776,1037.91C953.776,1035.43 951.762,1033.42 949.281,1033.42L424.519,1033.42C422.039,1033.42 420.025,1035.43 420.025,1037.91L420.025,1061.27C420.025,1063.75 422.039,1065.77 424.519,1065.77L949.281,1065.77C951.762,1065.77 953.776,1063.75 953.776,1061.27L953.776,1037.91Z" style="fill:rgb(187,196,198);fill-opacity:0.65;"/>
|
|
22
|
+
</g>
|
|
23
|
+
<g transform="matrix(0.823791,0,0,1,54.8392,-16.3916)">
|
|
24
|
+
<path d="M953.776,1037.91C953.776,1035.43 951.33,1033.42 948.317,1033.42L425.484,1033.42C422.471,1033.42 420.025,1035.43 420.025,1037.91L420.025,1061.27C420.025,1063.75 422.471,1065.77 425.484,1065.77L948.317,1065.77C951.33,1065.77 953.776,1063.75 953.776,1061.27L953.776,1037.91Z" style="fill:rgb(187,196,198);fill-opacity:0.65;"/>
|
|
25
|
+
</g>
|
|
26
|
+
<g transform="matrix(0.904048,0,0,1,21.129,-67.1309)">
|
|
27
|
+
<path d="M953.776,1037.91C953.776,1035.43 951.547,1033.42 948.801,1033.42L424.999,1033.42C422.254,1033.42 420.025,1035.43 420.025,1037.91L420.025,1061.27C420.025,1063.75 422.254,1065.77 424.999,1065.77L948.801,1065.77C951.547,1065.77 953.776,1063.75 953.776,1061.27L953.776,1037.91Z" style="fill:rgb(187,196,198);fill-opacity:0.65;"/>
|
|
28
|
+
</g>
|
|
29
|
+
<g transform="matrix(1.02071,0,0,1.04641,-38.8586,-763.331)">
|
|
30
|
+
<path d="M393.702,1679.71C393.702,1660.56 377.767,1645.02 358.141,1645.02L287.019,1645.02C267.393,1645.02 251.458,1660.56 251.458,1679.71L251.458,1749.29C251.458,1768.44 267.393,1783.98 287.019,1783.98L358.141,1783.98C377.767,1783.98 393.702,1768.44 393.702,1749.29L393.702,1679.71Z" style="fill:rgb(255,115,115);"/>
|
|
31
|
+
<clipPath id="_clip1">
|
|
32
|
+
<path d="M393.702,1679.71C393.702,1660.56 377.767,1645.02 358.141,1645.02L287.019,1645.02C267.393,1645.02 251.458,1660.56 251.458,1679.71L251.458,1749.29C251.458,1768.44 267.393,1783.98 287.019,1783.98L358.141,1783.98C377.767,1783.98 393.702,1768.44 393.702,1749.29L393.702,1679.71Z"/>
|
|
33
|
+
</clipPath>
|
|
34
|
+
<g clip-path="url(#_clip1)">
|
|
35
|
+
<g transform="matrix(0.76313,0,0,0.744387,148.731,1102.32)">
|
|
36
|
+
<path d="M226.411,745.537L243.421,797.888L298.467,797.888L253.934,830.243L270.944,882.594L226.411,850.239L181.879,882.594L198.889,830.243L154.356,797.888L209.402,797.888L226.411,745.537Z" style="fill:white;"/>
|
|
37
|
+
</g>
|
|
38
|
+
</g>
|
|
39
|
+
</g>
|
|
40
|
+
<g transform="matrix(0.933678,0,0,1,8.6838,-241.981)">
|
|
41
|
+
<path d="M953.776,1037.91C953.776,1035.43 951.617,1033.42 948.959,1033.42L424.841,1033.42C422.183,1033.42 420.025,1035.43 420.025,1037.91L420.025,1061.27C420.025,1063.75 422.183,1065.77 424.841,1065.77L948.959,1065.77C951.617,1065.77 953.776,1063.75 953.776,1061.27L953.776,1037.91Z" style="fill:rgb(187,196,198);fill-opacity:0.65;"/>
|
|
42
|
+
</g>
|
|
43
|
+
<g transform="matrix(1,0,0,1,-19.173,-288.71)">
|
|
44
|
+
<path d="M953.776,1037.91C953.776,1035.43 951.761,1033.42 949.279,1033.42L424.522,1033.42C422.04,1033.42 420.025,1035.43 420.025,1037.91L420.025,1061.27C420.025,1063.75 422.04,1065.77 424.522,1065.77L949.279,1065.77C951.761,1065.77 953.776,1063.75 953.776,1061.27L953.776,1037.91Z" style="fill:rgb(187,196,198);fill-opacity:0.65;"/>
|
|
45
|
+
</g>
|
|
46
|
+
<g transform="matrix(0.844941,0,0,1,45.9556,-337.889)">
|
|
47
|
+
<path d="M953.776,1037.91C953.776,1035.43 951.391,1033.42 948.453,1033.42L425.347,1033.42C422.409,1033.42 420.025,1035.43 420.025,1037.91L420.025,1061.27C420.025,1063.75 422.409,1065.77 425.347,1065.77L948.453,1065.77C951.391,1065.77 953.776,1063.75 953.776,1061.27L953.776,1037.91Z" style="fill:rgb(187,196,198);fill-opacity:0.65;"/>
|
|
48
|
+
</g>
|
|
49
|
+
<g transform="matrix(1.02071,0,0,1.04641,-38.8586,-1035.65)">
|
|
50
|
+
<path d="M393.702,1679.71C393.702,1660.56 377.767,1645.02 358.141,1645.02L287.019,1645.02C267.393,1645.02 251.458,1660.56 251.458,1679.71L251.458,1749.29C251.458,1768.44 267.393,1783.98 287.019,1783.98L358.141,1783.98C377.767,1783.98 393.702,1768.44 393.702,1749.29L393.702,1679.71Z" style="fill:rgb(255,115,115);"/>
|
|
51
|
+
<clipPath id="_clip2">
|
|
52
|
+
<path d="M393.702,1679.71C393.702,1660.56 377.767,1645.02 358.141,1645.02L287.019,1645.02C267.393,1645.02 251.458,1660.56 251.458,1679.71L251.458,1749.29C251.458,1768.44 267.393,1783.98 287.019,1783.98L358.141,1783.98C377.767,1783.98 393.702,1768.44 393.702,1749.29L393.702,1679.71Z"/>
|
|
53
|
+
</clipPath>
|
|
54
|
+
<g clip-path="url(#_clip2)">
|
|
55
|
+
<g transform="matrix(0.979712,0,0,0.955649,69.3286,762.785)">
|
|
56
|
+
<text x="193.673px" y="1041.62px" style="font-family:'HelveticaNeue-Bold', 'Helvetica Neue';font-weight:700;font-size:128px;fill:white;">%</text>
|
|
57
|
+
</g>
|
|
58
|
+
</g>
|
|
59
|
+
</g>
|
|
60
|
+
</g>
|
|
61
|
+
</g>
|
|
62
|
+
</svg>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _regeneratorRuntime from"@babel/runtime/regenerator";function
|
|
1
|
+
import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}import{appConfig}from'@shopgate/engage';import{main$,event,appDidStart$}from'@shopgate/engage/core';import{PERMISSION_ID_PUSH,PERMISSION_STATUS_NOT_DETERMINED}from'@shopgate/engage/core/constants';import{requestAppPermissionStatus}from'@shopgate/engage/core/actions';import{increaseAppStartCount,resetAppStartCount,increaseOrdersPlacedCount,resetOrdersPlacedCount,setLastPopupTimestamp,increaseRejectionCount,showPushOptInModal}from"../action-creators";import{PUSH_OPT_IN_OPT_IN_POSTPONED}from"../constants";import{getPushOptInTriggerState}from"../selectors";var DAY_IN_MS=1000*60*60*24;var increaseRejectionCount$=main$.filter(function(_ref){var action=_ref.action;return action.type===PUSH_OPT_IN_OPT_IN_POSTPONED;});/**
|
|
2
2
|
* Push opt in subscriptions
|
|
3
3
|
* @param {Function} subscribe The subscribe function
|
|
4
4
|
*/export default function pushOptIn(subscribe){/**
|
|
@@ -6,7 +6,7 @@ import _regeneratorRuntime from"@babel/runtime/regenerator";function _slicedToAr
|
|
|
6
6
|
* @param {string} configKey The "pushOptIn" key to be used
|
|
7
7
|
* @param {Function} increaseCountAction Action to increase the count in Redux for the configKey
|
|
8
8
|
* @returns {void}
|
|
9
|
-
*/var showOptInAfterChecks=/*#__PURE__*/function(){var _ref3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref2,configKey,increaseCountAction){var dispatch,getState,_appConfig$pushOptIn,appStarts,ordersPlaced,rejectionMaxCount,minDaysBetweenOptIns,
|
|
10
|
-
_context.next=4;return
|
|
9
|
+
*/var showOptInAfterChecks=/*#__PURE__*/function(){var _ref3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref2,configKey,increaseCountAction){var dispatch,getState,_appConfig$pushOptIn,appStarts,ordersPlaced,rejectionMaxCount,minDaysBetweenOptIns,pushStatus,state,configValue,resetAction,resetCountState,configCountState,mustShowModal,hasRepeats,minDaysElapsed;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:dispatch=_ref2.dispatch,getState=_ref2.getState;_appConfig$pushOptIn=appConfig.pushOptIn,appStarts=_appConfig$pushOptIn.appStarts,ordersPlaced=_appConfig$pushOptIn.ordersPlaced,rejectionMaxCount=_appConfig$pushOptIn.rejectionMaxCount,minDaysBetweenOptIns=_appConfig$pushOptIn.minDaysBetweenOptIns;// TODO add check to determine if the app supports push-opt-in (is done in CURB-3915)
|
|
10
|
+
_context.next=4;return dispatch(requestAppPermissionStatus({permissionId:PERMISSION_ID_PUSH}));case 4:pushStatus=_context.sent;if(!(pushStatus!==PERMISSION_STATUS_NOT_DETERMINED)){_context.next=7;break;}return _context.abrupt("return");case 7:dispatch(increaseCountAction());state=getPushOptInTriggerState(getState());configValue=appStarts;resetAction=resetAppStartCount;resetCountState=state.appStartResetCount;configCountState=state.appStartCount;if(configKey==='ordersPlaced'){configValue=ordersPlaced;resetAction=resetOrdersPlacedCount;resetCountState=state.ordersPlacedResetCount;configCountState=state.ordersPlacedCount;}if(!(state.rejectionCount>=rejectionMaxCount)){_context.next=16;break;}return _context.abrupt("return");case 16:mustShowModal=Number(configValue.value)>0&&configCountState>=configValue.value;hasRepeats=configValue.repeats===null||resetCountState<=configValue.repeats;minDaysElapsed=Date.now()-state.lastPopupAt>=minDaysBetweenOptIns*DAY_IN_MS;if(mustShowModal&&hasRepeats&&minDaysElapsed){dispatch(setLastPopupTimestamp());dispatch(resetAction());dispatch(showPushOptInModal());}case 20:case"end":return _context.stop();}}},_callee);}));return function showOptInAfterChecks(_x,_x2,_x3){return _ref3.apply(this,arguments);};}();// event subscriber to handle app start based push opt in
|
|
11
11
|
subscribe(appDidStart$,/*#__PURE__*/function(){var _ref5=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref4){var dispatch,getState;return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1){switch(_context2.prev=_context2.next){case 0:dispatch=_ref4.dispatch,getState=_ref4.getState;_context2.next=3;return showOptInAfterChecks({dispatch:dispatch,getState:getState},'appStarts',increaseAppStartCount);case 3:case"end":return _context2.stop();}}},_callee2);}));return function(_x4){return _ref5.apply(this,arguments);};}());// event subscriber to handle order based push opt in
|
|
12
12
|
subscribe(appDidStart$,function(_ref6){var dispatch=_ref6.dispatch,getState=_ref6.getState;event.addCallback('checkoutSuccess',/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(){return _regeneratorRuntime.wrap(function _callee3$(_context3){while(1){switch(_context3.prev=_context3.next){case 0:_context3.next=2;return showOptInAfterChecks({dispatch:dispatch,getState:getState},'ordersPlaced',increaseOrdersPlacedCount);case 2:case"end":return _context3.stop();}}},_callee3);})));});subscribe(increaseRejectionCount$,function(_ref8){var dispatch=_ref8.dispatch;dispatch(increaseRejectionCount());});}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import React from'react';import{shallow}from'enzyme';import LiveMessage from"../index";jest.mock("../../../../components",function(){return{I18n:{Text:function Translate(_ref){var string=_ref.string;return string;}}};});describe('<LiveMessage />',function(){var message='My Message';it('should render a polite simple message',function(){var ariaLive='polite';var wrapper=shallow(/*#__PURE__*/React.createElement(LiveMessage,{message:message}));expect(wrapper).toMatchSnapshot();expect(wrapper.find('div').prop('aria-live')).toBe(ariaLive);expect(wrapper.find('Translate').prop('string')).toBe(message);expect(wrapper.find('Translate').prop('params')).toEqual(null);});it('should render an assertive message with params ',function(){var ariaLive='assertive';var params={my:'param'};var wrapper=shallow(/*#__PURE__*/React.createElement(LiveMessage,{message:message,params:params,"aria-live":ariaLive}));expect(wrapper).toMatchSnapshot();expect(wrapper.find('div').prop('aria-live')).toBe(ariaLive);expect(wrapper.find('Translate').prop('string')).toBe(message);expect(wrapper.find('Translate').prop('params')).toEqual(params);});});
|
|
@@ -1 +0,0 @@
|
|
|
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{UIEvents}from"../../../../core";import{broadcastLiveMessage}from"../helpers";import{EVENT_LIVE_MESSAGE,LIVE_MESSAGE_TYPE_POLITE,LIVE_MESSAGE_TYPE_ASSERTIVE}from"../constants";jest.mock("../../../../core",function(){return{UIEvents:{emit:jest.fn()}};});jest.useFakeTimers();describe('LiveMessenger helpers',function(){beforeEach(function(){jest.clearAllMocks();});describe('broadcastLiveMessage()',function(){var message='My Message';var defaultOptions={type:LIVE_MESSAGE_TYPE_POLITE,params:null,id:null};it('should not broadcast without a message',function(){broadcastLiveMessage();jest.runAllTimers();expect(UIEvents.emit).not.toHaveBeenCalled();});it('should broadcast with default options',function(){broadcastLiveMessage(message);expect(UIEvents.emit).toHaveBeenCalledTimes(1);expect(UIEvents.emit).toHaveBeenCalledWith(EVENT_LIVE_MESSAGE,message,defaultOptions);jest.runAllTimers();expect(UIEvents.emit).toHaveBeenCalledTimes(2);expect(UIEvents.emit).toHaveBeenCalledWith(EVENT_LIVE_MESSAGE,'',defaultOptions);});it('should broadcast with some options',function(){var options={type:LIVE_MESSAGE_TYPE_ASSERTIVE,params:{some:'params'},id:'some-id'};broadcastLiveMessage(message,options);expect(UIEvents.emit).toHaveBeenCalledTimes(1);expect(UIEvents.emit).toHaveBeenCalledWith(EVENT_LIVE_MESSAGE,message,_extends({},options));jest.runAllTimers();expect(UIEvents.emit).toHaveBeenCalledTimes(2);expect(UIEvents.emit).toHaveBeenCalledWith(EVENT_LIVE_MESSAGE,'',_extends({},options));});});});
|