@shopgate/pwa-common 6.23.1 → 6.23.2

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.
@@ -1,5 +1,15 @@
1
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{ACTION_REPLACE}from'@virtuous/conductor';import{navigate}from"../../action-creators/router";import{mutable}from"../../helpers/redux";/**
2
2
  * @mixes {MutableFunction}
3
3
  * @param {Object} params The history params.
4
+ * @param {Object} [options={}] Additional options for the action
5
+ * @param {boolean} [options.remountRoute=true] When set to "true", the target route will be forced
6
+ * to remount.
4
7
  * @return {Function} The dispatched action.
5
- */export var historyReplace=mutable(function(params){return function(dispatch){dispatch(navigate(_extends({},params,{action:ACTION_REPLACE})));};});
8
+ */export var historyReplace=mutable(function(params){var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};return function(dispatch){dispatch(navigate(_extends({},params,(options===null||options===void 0?void 0:options.remountRoute)!==false&&{state:_extends({},params.state,{/**
9
+ * When a route is "replaced" the router doesn't assign a new route id to the old route
10
+ * stack entry. This can cause issues when a route is replaced by itself, since the content
11
+ * will not remount out of the box.
12
+ *
13
+ * When the "replaceRouteId" state prop is injected, the Route component performs logic
14
+ * to enforce re-remounting routes which where replaced by itself.
15
+ */replaceRouteId:Math.random().toString(36).substring(2,7)})},{action:ACTION_REPLACE})));};});
@@ -1 +1 @@
1
- import{connect}from'react-redux';import{historyPush as _historyPush,historyReplace as _historyReplace}from"../../actions/router";var mapDispatchToProps={historyPush:function historyPush(params){return _historyPush(params);},historyReplace:function historyReplace(params){return _historyReplace(params);}};export default connect(null,mapDispatchToProps);
1
+ import{connect}from'react-redux';import{historyPush,historyReplace}from"../../actions/router";var mapDispatchToProps={historyPush:historyPush,historyReplace:historyReplace};export default connect(null,mapDispatchToProps);
@@ -9,4 +9,11 @@ function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeo
9
9
  */},{key:"render",value:function render(){var _this2=this;var _this$props=this.props,cache=_this$props.cache,Component=_this$props.component,pattern=_this$props.pattern;var matches=[];// If the current pattern does not match the whitelist but matches the current route
10
10
  // then add the current route as the only match.
11
11
  if(!cache&&pattern===this.currentRoute.pattern){matches=[[this.currentRoute.id,this.currentRoute]];}else if(cache){var subset=this.context.slice(0,router.routeIndex+1);// Find matching patterns.
12
- matches=subset.filter(function(_ref){var _ref2=_slicedToArray(_ref,2),route=_ref2[1];return route.pattern===pattern;});}if(!matches.length){return null;}return matches.map(function(_ref3){var _ref4=_slicedToArray(_ref3,2),route=_ref4[1];var setPattern=route.setPattern,context=_objectWithoutProperties(route,_excluded);context.open=true;context.visible=route.id===_this2.currentRoute.id;return/*#__PURE__*/React.createElement(ErrorBoundary,{key:"error.".concat(route.id)},/*#__PURE__*/React.createElement(RouteContext.Provider,{key:route.id,value:context},/*#__PURE__*/React.createElement(Suspense,{fallback:/*#__PURE__*/React.createElement(Loading,null)},/*#__PURE__*/React.createElement(Component,null))));});}}]);return Route;}(React.Component);_defineProperty(Route,"contextType",RouterContext);_defineProperty(Route,"defaultProps",{cache:false,transform:null});export default Route;
12
+ matches=subset.filter(function(_ref){var _ref2=_slicedToArray(_ref,2),route=_ref2[1];return route.pattern===pattern;});}if(!matches.length){return null;}return matches.map(function(_ref3){var _context$state;var _ref4=_slicedToArray(_ref3,2),route=_ref4[1];var setPattern=route.setPattern,context=_objectWithoutProperties(route,_excluded);context.open=true;context.visible=route.id===_this2.currentRoute.id;/**
13
+ * When a route is "replaced" the router doesn't assign a new route id to the old route
14
+ * stack entry. This can cause issues when a route is replaced by itself, since the content
15
+ * will not remount out of the box.
16
+ *
17
+ * The "replaceRouteId" state prop is injected by the "historyReplace" action. It's used
18
+ * to enforce re-remounting routes which where replaced by itself.
19
+ */var replaceRouteId=(context===null||context===void 0?void 0:(_context$state=context.state)===null||_context$state===void 0?void 0:_context$state.replaceRouteId)||'';return/*#__PURE__*/React.createElement(ErrorBoundary,{key:"error.".concat(route.id,"_").concat(replaceRouteId)},/*#__PURE__*/React.createElement(RouteContext.Provider,{key:"".concat(route.id,"_").concat(replaceRouteId),value:context},/*#__PURE__*/React.createElement(Suspense,{fallback:/*#__PURE__*/React.createElement(Loading,null)},/*#__PURE__*/React.createElement(Component,null))));});}}]);return Route;}(React.Component);_defineProperty(Route,"contextType",RouterContext);_defineProperty(Route,"defaultProps",{cache:false,transform:null});export default Route;
@@ -22,8 +22,9 @@ import noop from'lodash/noop';import{isObject}from"../validation";/**
22
22
  * @type {{next: Function, stop: Function, skipRest: Function}}
23
23
  */export var mutableActions={next:next,skipRest:skipRest,stop:stop};/**
24
24
  * Takes a function and makes it mutable.
25
- * @param {Function} func Original function to convert to a mutable
26
- * @returns {Function}
25
+ * @template {Function} T
26
+ * @param {T} func Original function to convert to a mutable
27
+ * @returns {T}
27
28
  */export var mutable=function mutable(func){var original=func;var current=func;var steps=[];/**
28
29
  * Takes the pre-processing steps and calls all step functions, as well as the mutable function
29
30
  * afterwards. Each step can transform the arguments, that are passed in to the next step in the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopgate/pwa-common",
3
- "version": "6.23.1",
3
+ "version": "6.23.2",
4
4
  "description": "Common library for the Shopgate Connect PWA.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Shopgate <support@shopgate.com>",
@@ -16,7 +16,7 @@
16
16
  ],
17
17
  "dependencies": {
18
18
  "@sentry/browser": "^4.6.3",
19
- "@shopgate/pwa-benchmark": "6.23.1",
19
+ "@shopgate/pwa-benchmark": "6.23.2",
20
20
  "@virtuous/conductor": "~2.4.0",
21
21
  "@virtuous/react-conductor": "~2.4.0",
22
22
  "@virtuous/redux-persister": "1.1.0-beta.7",
@@ -44,7 +44,7 @@
44
44
  "url-search-params": "^0.10.0"
45
45
  },
46
46
  "devDependencies": {
47
- "@shopgate/pwa-core": "6.23.1",
47
+ "@shopgate/pwa-core": "6.23.2",
48
48
  "lodash": "^4.17.4",
49
49
  "prop-types": "~15.7.2",
50
50
  "react": "~16.12.0",