@shopgate/pwa-common 7.30.0 → 7.30.1-beta.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,5 @@
1
1
  import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
2
- import URLSearchParams from 'url-search-params';
2
+ import "core-js/modules/web.url-search-params.js";
3
3
  import MediaProvider from "./MediaProvider";
4
4
 
5
5
  /* eslint-disable class-methods-use-this */
@@ -1,4 +1,4 @@
1
- import React, { Fragment, memo } from 'react';
1
+ import React, { memo } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { i18n } from '@shopgate/engage/core/helpers/i18n';
4
4
 
@@ -8,14 +8,13 @@ import { EVENT_KEYBOARD_WILL_CHANGE } from '@shopgate/pwa-core/constants/AppEven
8
8
  * Keyboard state consumer.
9
9
  */
10
10
  let KeyboardConsumer = /*#__PURE__*/function (_PureComponent) {
11
- function KeyboardConsumer(...args) {
11
+ /**
12
+ * Initializes the component state.
13
+ * @param {Object} props The components props.
14
+ */
15
+ function KeyboardConsumer(props) {
12
16
  var _this;
13
- _this = _PureComponent.call.apply(_PureComponent, [this].concat(args)) || this;
14
- _this.state = {
15
- open: false,
16
- overlap: 0,
17
- duration: 0
18
- };
17
+ _this = _PureComponent.call(this, props) || this;
19
18
  /**
20
19
  * Stores current keyboard state.
21
20
  */
@@ -30,13 +29,19 @@ let KeyboardConsumer = /*#__PURE__*/function (_PureComponent) {
30
29
  duration
31
30
  });
32
31
  };
32
+ _this.state = {
33
+ open: false,
34
+ overlap: 0,
35
+ duration: 0
36
+ };
33
37
  return _this;
34
38
  }
35
- _inheritsLoose(KeyboardConsumer, _PureComponent);
36
- var _proto = KeyboardConsumer.prototype;
39
+
37
40
  /**
38
41
  * Listen to keyboard changes as soon as the component mounts.
39
42
  */
43
+ _inheritsLoose(KeyboardConsumer, _PureComponent);
44
+ var _proto = KeyboardConsumer.prototype;
40
45
  _proto.componentDidMount = function componentDidMount() {
41
46
  Event.addCallback(EVENT_KEYBOARD_WILL_CHANGE, this.handleKeyboardChange);
42
47
  }
@@ -1,6 +1,6 @@
1
1
  import "core-js/modules/es.array.reduce.js";
2
+ import "core-js/modules/web.url-search-params.js";
2
3
  import { createBrowserHistory } from 'history';
3
- import URLSearchParams from 'url-search-params';
4
4
  import { router } from '@virtuous/conductor';
5
5
  const match = /^(.*)index.html/.exec(window.location.pathname);
6
6
  const {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopgate/pwa-common",
3
- "version": "7.30.0",
3
+ "version": "7.30.1-beta.2",
4
4
  "description": "Common library for the Shopgate Connect PWA.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Shopgate <support@shopgate.com>",
@@ -17,33 +17,32 @@
17
17
  "dependencies": {
18
18
  "@redux-devtools/extension": "^3.3.0",
19
19
  "@sentry/browser": "6.0.1",
20
- "@shopgate/pwa-benchmark": "7.30.0",
20
+ "@shopgate/pwa-benchmark": "7.30.1-beta.2",
21
21
  "@virtuous/conductor": "~2.5.0",
22
22
  "@virtuous/react-conductor": "~2.5.0",
23
23
  "@virtuous/redux-persister": "1.1.0-beta.7",
24
24
  "classnames": "2.5.1",
25
25
  "crypto-js": "3.1.9-1",
26
26
  "glamor": "^2.20.40",
27
- "gsap": "^3.6.0",
27
+ "gsap": "^3.14.2",
28
28
  "history": "^4.9.0",
29
- "intl-messageformat": "^7.8.3",
29
+ "intl-messageformat": "^11.1.2",
30
30
  "path-match": "^1.2.4",
31
- "react-dotdotdot": "~1.3.0",
31
+ "react-dotdotdot": "~1.3.1",
32
32
  "react-helmet": "^6.1.0",
33
33
  "react-portal": "^3.1.0",
34
34
  "react-redux": "^8.1.3",
35
- "redux": "^4.2.1",
35
+ "redux": "^5.0.1",
36
36
  "redux-logger": "^3.0.6",
37
- "redux-thunk": "^2.4.2",
37
+ "redux-thunk": "^3.1.0",
38
38
  "reselect": "^4.1.8",
39
39
  "rxjs": "~5.5.12",
40
- "swiper": "11.2.2",
41
- "url-search-params": "^0.10.0"
40
+ "swiper": "12.1.0"
42
41
  },
43
42
  "devDependencies": {
44
- "@shopgate/pwa-core": "7.30.0",
43
+ "@shopgate/pwa-core": "7.30.1-beta.2",
45
44
  "@types/react-portal": "^3.0.9",
46
- "lodash": "^4.17.21",
45
+ "lodash": "^4.17.23",
47
46
  "prop-types": "~15.8.1",
48
47
  "react": "^17.0.2",
49
48
  "react-dom": "^17.0.2"
@@ -12,7 +12,7 @@ const defaultState = {
12
12
  * @param {Object} action The action object.
13
13
  * @return {Object} The new state.
14
14
  */
15
- export default function clientConnectivityReducer(state = defaultState, action) {
15
+ export default function clientConnectivityReducer(state = defaultState, action = {}) {
16
16
  switch (action.type) {
17
17
  case RECEIVE_CLIENT_CONNECTIVITY:
18
18
  return {
@@ -7,7 +7,7 @@ const defaultState = {};
7
7
  * @param {Object} action The action object.
8
8
  * @return {Object} The new state.
9
9
  */
10
- export default function clientInformationReducer(state = defaultState, action) {
10
+ export default function clientInformationReducer(state = defaultState, action = {}) {
11
11
  switch (action.type) {
12
12
  case REQUEST_CLIENT_INFORMATION:
13
13
  return {
@@ -6,7 +6,7 @@ import { REQUEST_MENU, RECEIVE_MENU, ERROR_MENU } from "../../constants/ActionTy
6
6
  * @param {Object} action The action object.
7
7
  * @return {Object} The new state.
8
8
  */
9
- export default function menusByIdReducer(state = {}, action) {
9
+ export default function menusByIdReducer(state = {}, action = {}) {
10
10
  switch (action.type) {
11
11
  case REQUEST_MENU:
12
12
  {
@@ -18,7 +18,7 @@ const enrichWidgets = action => action.config.widgets.map((widget, index) => ({
18
18
  * @param {Object} action The action object.
19
19
  * @return {Object} The store data.
20
20
  */
21
- export default function pageReducer(state = {}, action) {
21
+ export default function pageReducer(state = {}, action = {}) {
22
22
  switch (action.type) {
23
23
  case REQUEST_PAGE_CONFIG:
24
24
  return {
@@ -11,7 +11,7 @@ const defaultState = {
11
11
  * @param {Object} action The action object.
12
12
  * @returns {Object}
13
13
  */
14
- export default function router(state = defaultState, action) {
14
+ export default function router(state = defaultState, action = {}) {
15
15
  switch (action.type) {
16
16
  case ROUTE_WILL_LEAVE:
17
17
  case ROUTE_DID_LEAVE:
@@ -9,7 +9,7 @@ const defaultState = {};
9
9
  * @param {Object} action The action object.
10
10
  * @return {Object} The new state.
11
11
  */
12
- export default function urlReducer(state = defaultState, action) {
12
+ export default function urlReducer(state = defaultState, action = {}) {
13
13
  switch (action.type) {
14
14
  case REQUEST_URL:
15
15
  return {
@@ -6,7 +6,7 @@ import { REQUEST_USER, RECEIVE_USER, ERROR_USER, SUCCESS_LOGOUT } from "../../co
6
6
  * @param {Object} action The action object.
7
7
  * @return {Object} The new state.
8
8
  */
9
- export default function userDataReducer(state = {}, action) {
9
+ export default function userDataReducer(state = {}, action = {}) {
10
10
  switch (action.type) {
11
11
  case REQUEST_USER:
12
12
  return {
@@ -14,7 +14,7 @@ const defaultState = {
14
14
  * @param {Object} action The action object.
15
15
  * @return {Object} The new state.
16
16
  */
17
- export default function userLoginReducer(state = defaultState, action) {
17
+ export default function userLoginReducer(state = defaultState, action = {}) {
18
18
  switch (action.type) {
19
19
  case APP_DID_START:
20
20
  return {
@@ -98,24 +98,62 @@ export const getDeviceModel = createSelector(getDeviceInformation, deviceInforma
98
98
  return model;
99
99
  });
100
100
 
101
+ /**
102
+ * Selector to check if the PWA is currently running inside the Android app.
103
+ * Unlike the `getIsAndroid` selector, this selector will return false if the PWA
104
+ * is running in a web browser on an Android device.
105
+ * @param {Object} state The application state.
106
+ * @return {boolean}
107
+ */
108
+ export const getIsAndroidApp = createSelector(getPlatform, platform => {
109
+ if (hasWebBridge()) {
110
+ return false;
111
+ }
112
+ return platform === OS_ANDROID;
113
+ });
114
+
101
115
  /**
102
116
  * Check if the platform is Android.
103
117
  * @param {Object} state The application state.
104
118
  * @return {boolean}
105
119
  */
106
- export const isAndroid = createSelector(getPlatform, platform => {
120
+ export const getIsAndroid = createSelector(getPlatform, platform => {
107
121
  if (hasWebBridge()) {
108
122
  return md.os() === 'AndroidOS';
109
123
  }
110
124
  return platform === OS_ANDROID;
111
125
  });
112
126
 
127
+ /**
128
+ * @deprecated Use `getIsAndroid` instead.
129
+ */
130
+ export const isAndroid = getIsAndroid;
131
+
132
+ /**
133
+ * Selector to check if the PWA is currently running inside the iOS app.
134
+ * Unlike the `getIsIos` selector, this selector will return false if the PWA
135
+ * is running in a web browser on an iOS device.
136
+ * @param {Object} state The application state.
137
+ * @return {boolean}
138
+ */
139
+ export const getIsIosApp = createSelector(getPlatform, platform => {
140
+ if (hasWebBridge()) {
141
+ return false;
142
+ }
143
+ return platform === OS_IOS;
144
+ });
145
+
113
146
  /**
114
147
  * Check if the platform is iOS.
115
148
  * @param {Object} state The application state.
116
149
  * @return {boolean}
117
150
  */
118
- export const isIos = createSelector(getPlatform, platform => platform === OS_IOS);
151
+ export const getIsIos = createSelector(getPlatform, platform => platform === OS_IOS);
152
+
153
+ /**
154
+ * @deprecated Use `getIsIos` instead.
155
+ */
156
+ export const isIos = getIsIos;
119
157
 
120
158
  /**
121
159
  * Checks if the currently stored lib version is one that supports the scanner.
@@ -1,6 +1,8 @@
1
1
  import { createSelector } from 'reselect';
2
2
  import { isObject } from "../helpers/validation";
3
3
  import authRoutes from "../collections/AuthRoutes";
4
+ const EMPTY_OBJECT = {};
5
+ const EMPTY_ARRAY = [];
4
6
 
5
7
  /**
6
8
  * @param {Object} state The application state.
@@ -12,13 +14,13 @@ export const getRouterState = state => state.router;
12
14
  * @param {Object} state The application state.
13
15
  * @return {Array}
14
16
  */
15
- export const getRouterStack = createSelector(getRouterState, state => state && state.stack ? state.stack : []);
17
+ export const getRouterStack = createSelector(getRouterState, state => state && state.stack ? state.stack : EMPTY_ARRAY);
16
18
 
17
19
  /**
18
20
  * @param {Object} state The application state.
19
21
  * @returns {Object|null}
20
22
  */
21
- export const getCurrentRoute = createSelector(getRouterState, getRouterStack, (state, props = {}) => props.routeId, (router, stack, routeId) => {
23
+ export const getCurrentRoute = createSelector(getRouterState, getRouterStack, (state, props = EMPTY_OBJECT) => props.routeId, (router, stack, routeId) => {
22
24
  if (!router || !router.currentRoute) {
23
25
  return null;
24
26
  }
@@ -89,7 +91,7 @@ export const getCurrentState = createSelector(getCurrentRoute, route => {
89
91
  * @returns {Function}
90
92
  */
91
93
  export function makeIsLastStackEntry() {
92
- return createSelector((state, props = {}) => props.routeId, getRouterStack, (routeId, stack) => {
94
+ return createSelector((state, props = EMPTY_OBJECT) => props.routeId, getRouterStack, (routeId, stack) => {
93
95
  const index = stack.findIndex(entry => entry.id === routeId);
94
96
  return index >= 0 && index === stack.length - 1;
95
97
  });
@@ -100,7 +102,7 @@ export function makeIsLastStackEntry() {
100
102
  * @returns {Function}
101
103
  */
102
104
  export function makeGetPrevRoute() {
103
- return createSelector((state, props = {}) => props.routeId, getRouterStack, (routeId, stack) => {
105
+ return createSelector((state, props = EMPTY_OBJECT) => props.routeId, getRouterStack, (routeId, stack) => {
104
106
  const routeIndex = stack.findIndex(entry => entry.id === routeId);
105
107
  if (routeIndex <= 0) {
106
108
  return null;
package/store/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import "core-js/modules/es.string.replace.js";
2
2
  import { createStore, applyMiddleware } from 'redux';
3
- import thunk from 'redux-thunk';
3
+ import { thunk } from 'redux-thunk';
4
4
  import { composeWithDevTools } from '@redux-devtools/extension';
5
5
  import { persistState } from '@virtuous/redux-persister';
6
6
  import benchmarkMiddleware from '@shopgate/pwa-benchmark/profilers/redux';