@salesforce/commerce-sdk-react 1.1.0-nightly-20231102080140 → 1.1.0-preview.0
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/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
## v1.1.0-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
## v1.1.0-dev (Sep 26, 2023)
|
|
1
|
+
## v1.1.0-preview.0 (Nov 02, 2023)
|
|
2
|
+
|
|
3
|
+
- Add StorefrontPreview component [#1508](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/1508)
|
|
5
4
|
- Using `login` for authentication instead of `email` in registration process [#1464](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/1464)
|
|
6
5
|
- Fix bug to remove cookies using the default attributes used when setting cookie [#1505](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/1505)
|
|
7
6
|
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import PropTypes from 'prop-types';
|
|
3
|
+
type GetToken = () => string | undefined | Promise<string | undefined>;
|
|
2
4
|
/**
|
|
3
5
|
*
|
|
4
|
-
* @param
|
|
5
|
-
* This flag only applies if storefront is
|
|
6
|
-
* @param
|
|
6
|
+
* @param enabled - flag to turn on/off Storefront Preview feature. By default, it is set to true.
|
|
7
|
+
* This flag only applies if storefront is running in a Runtime Admin iframe.
|
|
8
|
+
* @param getToken - A method that returns the access token for the current user
|
|
7
9
|
*/
|
|
8
10
|
export declare const StorefrontPreview: {
|
|
9
|
-
({ children, enabled, getToken }: {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
11
|
+
({ children, enabled, getToken }: React.PropsWithChildren<{
|
|
12
|
+
enabled?: true | undefined;
|
|
13
|
+
getToken: GetToken;
|
|
14
|
+
} | {
|
|
15
|
+
enabled: false;
|
|
16
|
+
getToken?: GetToken | undefined;
|
|
17
|
+
}>): import("react/jsx-runtime").JSX.Element;
|
|
17
18
|
propTypes: {
|
|
18
19
|
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
19
20
|
enabled: PropTypes.Requireable<boolean>;
|
|
@@ -16,18 +16,17 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
16
16
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
17
17
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
18
18
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
19
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
*/
|
|
19
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /*
|
|
20
|
+
* Copyright (c) 2023, Salesforce, Inc.
|
|
21
|
+
* All rights reserved.
|
|
22
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
23
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
24
|
+
*/
|
|
26
25
|
/**
|
|
27
26
|
*
|
|
28
|
-
* @param
|
|
29
|
-
* This flag only applies if storefront is
|
|
30
|
-
* @param
|
|
27
|
+
* @param enabled - flag to turn on/off Storefront Preview feature. By default, it is set to true.
|
|
28
|
+
* This flag only applies if storefront is running in a Runtime Admin iframe.
|
|
29
|
+
* @param getToken - A method that returns the access token for the current user
|
|
31
30
|
*/
|
|
32
31
|
const StorefrontPreview = ({
|
|
33
32
|
children,
|
|
@@ -40,7 +39,7 @@ const StorefrontPreview = ({
|
|
|
40
39
|
if (enabled && isHostTrusted) {
|
|
41
40
|
window.STOREFRONT_PREVIEW = _objectSpread(_objectSpread({}, window.STOREFRONT_PREVIEW), {}, {
|
|
42
41
|
getToken,
|
|
43
|
-
|
|
42
|
+
experimentalUnsafeNavigate: (path, action = 'push', ...args) => {
|
|
44
43
|
history[action](path, ...args);
|
|
45
44
|
}
|
|
46
45
|
});
|
|
@@ -54,16 +53,13 @@ const StorefrontPreview = ({
|
|
|
54
53
|
})), children);
|
|
55
54
|
};
|
|
56
55
|
exports.StorefrontPreview = StorefrontPreview;
|
|
57
|
-
StorefrontPreview.defaultProps = {
|
|
58
|
-
enabled: true
|
|
59
|
-
};
|
|
60
56
|
StorefrontPreview.propTypes = {
|
|
61
57
|
children: _propTypes.default.node,
|
|
62
58
|
enabled: _propTypes.default.bool,
|
|
63
59
|
// a custom prop type function to only require this prop if enabled is true.
|
|
64
60
|
getToken: function (props, propName, componentName) {
|
|
65
61
|
if (props['enabled'] === true && (props[propName] === undefined || typeof props[propName] !== 'function')) {
|
|
66
|
-
return new Error(`${propName} is a required function for ${componentName} when enabled is true`);
|
|
62
|
+
return new Error(`${String(propName)} is a required function for ${String(componentName)} when enabled is true`);
|
|
67
63
|
}
|
|
68
64
|
}
|
|
69
65
|
};
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getParentOrigin = exports.getClientScript = exports.detectStorefrontPreview = void 0;
|
|
7
|
-
// @ts-nocheck
|
|
8
7
|
/*
|
|
9
8
|
* Copyright (c) 2023, Salesforce, Inc.
|
|
10
9
|
* All rights reserved.
|
|
@@ -33,8 +32,9 @@ const getParentOrigin = () => {
|
|
|
33
32
|
};
|
|
34
33
|
exports.getParentOrigin = getParentOrigin;
|
|
35
34
|
const isParentOriginTrusted = parentOrigin => {
|
|
36
|
-
return window.location.hostname === 'localhost' ? parentOrigin === DEVELOPMENT_ORIGIN // Development
|
|
37
|
-
: TRUSTED_ORIGINS.includes(parentOrigin)
|
|
35
|
+
return Boolean(parentOrigin && (window.location.hostname === 'localhost' ? parentOrigin === DEVELOPMENT_ORIGIN // Development
|
|
36
|
+
: TRUSTED_ORIGINS.includes(parentOrigin)) // Production
|
|
37
|
+
);
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
/** Detects whether the storefront is running in an iframe as part of Storefront Preview.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/commerce-sdk-react",
|
|
3
|
-
"version": "1.1.0-
|
|
3
|
+
"version": "1.1.0-preview.0",
|
|
4
4
|
"description": "A library that provides react hooks for fetching data from Commerce Cloud",
|
|
5
5
|
"homepage": "https://github.com/SalesforceCommerceCloud/pwa-kit/tree/develop/packages/ecom-react-hooks#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -45,19 +45,21 @@
|
|
|
45
45
|
"jwt-decode": "^3.1.2"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@salesforce/pwa-kit-dev": "3.2.0-
|
|
48
|
+
"@salesforce/pwa-kit-dev": "3.2.0-preview.0",
|
|
49
49
|
"@tanstack/react-query": "^4.28.0",
|
|
50
50
|
"@testing-library/jest-dom": "^5.16.5",
|
|
51
51
|
"@testing-library/react": "^14.0.0",
|
|
52
|
-
"@types/js-cookie": "
|
|
53
|
-
"@types/jsonwebtoken": "
|
|
54
|
-
"@types/jwt-decode": "
|
|
55
|
-
"@types/node": "
|
|
56
|
-
"@types/
|
|
57
|
-
"@types/react
|
|
58
|
-
"@types/react-
|
|
52
|
+
"@types/js-cookie": "~3.0.3",
|
|
53
|
+
"@types/jsonwebtoken": "~9.0.0",
|
|
54
|
+
"@types/jwt-decode": "~3.1.0",
|
|
55
|
+
"@types/node": "~16.0.3",
|
|
56
|
+
"@types/prop-types": "~15.7.9",
|
|
57
|
+
"@types/react": "~18.2.0",
|
|
58
|
+
"@types/react-dom": "~18.2.1",
|
|
59
|
+
"@types/react-helmet": "~6.1.6",
|
|
60
|
+
"@types/react-router-dom": "~5.3.3",
|
|
59
61
|
"cross-env": "^5.2.1",
|
|
60
|
-
"internal-lib-build": "3.2.0-
|
|
62
|
+
"internal-lib-build": "3.2.0-preview.0",
|
|
61
63
|
"jsonwebtoken": "^9.0.0",
|
|
62
64
|
"nock": "^13.3.0",
|
|
63
65
|
"nodemon": "^2.0.22",
|
|
@@ -87,5 +89,5 @@
|
|
|
87
89
|
"publishConfig": {
|
|
88
90
|
"directory": "dist"
|
|
89
91
|
},
|
|
90
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "2796cec01d4462b66b9efbc2171aa921f0b7aec6"
|
|
91
93
|
}
|