@salesforce/pwa-kit-react-sdk 3.9.0-nightly-20241206080208 → 4.0.0-extensibility-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 +5 -6
- package/package.json +14 -9
- package/ssr/browser/main.d.ts +22 -0
- package/ssr/browser/main.d.ts.map +1 -0
- package/ssr/browser/main.js +67 -44
- package/ssr/browser/main.test.js +6 -4
- package/ssr/server/react-rendering.d.ts +9 -0
- package/ssr/server/react-rendering.d.ts.map +1 -0
- package/ssr/server/react-rendering.js +20 -8
- package/ssr/universal/compatibility.d.ts +3 -0
- package/ssr/universal/compatibility.d.ts.map +1 -0
- package/ssr/universal/components/_app/index.d.ts +20 -0
- package/ssr/universal/components/_app/index.d.ts.map +1 -0
- package/ssr/universal/components/_app/index.test.js +1 -1
- package/ssr/universal/components/_app-config/index.d.ts +60 -0
- package/ssr/universal/components/_app-config/index.d.ts.map +1 -0
- package/ssr/universal/components/_document/index.d.ts +55 -0
- package/ssr/universal/components/_document/index.d.ts.map +1 -0
- package/ssr/universal/components/_document/index.test.js +1 -1
- package/ssr/universal/components/_error/index.d.ts +32 -0
- package/ssr/universal/components/_error/index.d.ts.map +1 -0
- package/ssr/universal/components/_error/index.test.js +1 -1
- package/ssr/universal/components/app-error-boundary/index.d.ts +38 -0
- package/ssr/universal/components/app-error-boundary/index.d.ts.map +1 -0
- package/ssr/universal/components/app-error-boundary/index.test.js +3 -3
- package/ssr/universal/components/fetch-strategy/index.d.ts +13 -0
- package/ssr/universal/components/fetch-strategy/index.d.ts.map +1 -0
- package/ssr/universal/components/refresh/index.d.ts +17 -0
- package/ssr/universal/components/refresh/index.d.ts.map +1 -0
- package/ssr/universal/components/refresh/index.test.js +5 -5
- package/ssr/universal/components/route-component/index.d.ts +6 -0
- package/ssr/universal/components/route-component/index.d.ts.map +1 -0
- package/ssr/universal/components/route-component/index.js +11 -3
- package/ssr/universal/components/route-component/index.test.js +11 -11
- package/ssr/universal/components/routes/index.d.ts +3 -0
- package/ssr/universal/components/routes/index.d.ts.map +1 -0
- package/ssr/universal/components/routes/index.js +15 -0
- package/ssr/universal/components/switch/index.d.ts +22 -0
- package/ssr/universal/components/switch/index.d.ts.map +1 -0
- package/ssr/universal/components/switch/index.js +2 -2
- package/ssr/universal/components/throw-404/index.d.ts +17 -0
- package/ssr/universal/components/throw-404/index.d.ts.map +1 -0
- package/ssr/universal/components/throw-404/index.test.js +1 -1
- package/ssr/universal/components/with-correlation-id/index.d.ts +12 -0
- package/ssr/universal/components/with-correlation-id/index.d.ts.map +1 -0
- package/ssr/universal/components/with-legacy-get-props/index.d.ts +81 -0
- package/ssr/universal/components/with-legacy-get-props/index.d.ts.map +1 -0
- package/ssr/universal/components/with-legacy-get-props/index.js +1 -1
- package/ssr/universal/components/with-legacy-get-props/index.test.js +1 -1
- package/ssr/universal/components/with-react-query/index.d.ts +5 -0
- package/ssr/universal/components/with-react-query/index.d.ts.map +1 -0
- package/ssr/universal/components/with-react-query/index.test.js +3 -3
- package/ssr/universal/contexts/index.d.ts +26 -0
- package/ssr/universal/contexts/index.d.ts.map +1 -0
- package/ssr/universal/contexts/index.test.js +4 -4
- package/ssr/universal/errors.d.ts +13 -0
- package/ssr/universal/errors.d.ts.map +1 -0
- package/ssr/universal/events.d.ts +11 -0
- package/ssr/universal/events.d.ts.map +1 -0
- package/ssr/universal/hooks/index.d.ts +17 -0
- package/ssr/universal/hooks/index.d.ts.map +1 -0
- package/ssr/universal/hooks/index.js +3 -35
- package/ssr/universal/routes.d.ts +3 -0
- package/ssr/universal/routes.d.ts.map +1 -0
- package/ssr/universal/utils.client.test.js +30 -0
- package/ssr/universal/utils.d.ts +41 -0
- package/ssr/universal/utils.d.ts.map +1 -0
- package/ssr/universal/utils.js +43 -6
- package/utils/assets.d.ts +2 -0
- package/utils/assets.d.ts.map +1 -0
- package/utils/logger-instance.d.ts +3 -0
- package/utils/logger-instance.d.ts.map +1 -0
- package/utils/performance.d.ts +60 -0
- package/utils/performance.d.ts.map +1 -0
- package/utils/url.d.ts +2 -0
- package/utils/url.d.ts.map +1 -0
- package/utils/url.js +1 -3
- package/utils/uuidv4.client.d.ts +7 -0
- package/utils/uuidv4.client.d.ts.map +1 -0
- package/utils/warnings.d.ts +3 -0
- package/utils/warnings.d.ts.map +1 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export const AppErrorContext: React.Context<any>;
|
|
2
|
+
export { AppErrorBoundary as AppErrorBoundaryWithoutRouter };
|
|
3
|
+
declare const _default: any;
|
|
4
|
+
export default _default;
|
|
5
|
+
import React from "react";
|
|
6
|
+
/**
|
|
7
|
+
* @private
|
|
8
|
+
*/
|
|
9
|
+
declare class AppErrorBoundary extends React.Component<any, any, any> {
|
|
10
|
+
static getDerivedStateFromError(err: any): {
|
|
11
|
+
error: {
|
|
12
|
+
message: any;
|
|
13
|
+
stack: any;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
constructor(props: any);
|
|
17
|
+
state: {
|
|
18
|
+
error: any;
|
|
19
|
+
};
|
|
20
|
+
onGetPropsError(err: any): void;
|
|
21
|
+
componentDidMount(): void;
|
|
22
|
+
unlisten: any;
|
|
23
|
+
componentWillUnmount(): void;
|
|
24
|
+
render(): import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
}
|
|
26
|
+
declare namespace AppErrorBoundary {
|
|
27
|
+
namespace propTypes {
|
|
28
|
+
const children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
29
|
+
const error: PropTypes.Requireable<PropTypes.InferProps<{
|
|
30
|
+
message: PropTypes.Validator<string>;
|
|
31
|
+
status: PropTypes.Validator<number>;
|
|
32
|
+
}>>;
|
|
33
|
+
const correlationId: PropTypes.Requireable<string>;
|
|
34
|
+
const history: PropTypes.Requireable<object>;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
import PropTypes from "prop-types";
|
|
38
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/ssr/universal/components/app-error-boundary/index.jsx"],"names":[],"mappings":"AAaA,iDAAoD;;;;;AAIpD;;GAEG;AACH;IA8BI;;;;;MAGC;IAhCD,wBAMC;IAJG;;MAEC;IA8BL,gCAYC;IAtCD,0BAYC;IARO,cAME;IAIV,6BAIC;IAsBD,kDAeC;CACJ"}
|
|
@@ -62,7 +62,7 @@ describe('AppErrorBoundary', () => {
|
|
|
62
62
|
}) => {
|
|
63
63
|
test(`Displays errors correctly (variation: ${variation})`, () => {
|
|
64
64
|
const ref = /*#__PURE__*/_react.default.createRef();
|
|
65
|
-
(0, _react2.render)(
|
|
65
|
+
(0, _react2.render)(/*#__PURE__*/_react.default.createElement(_index.AppErrorBoundaryWithoutRouter, {
|
|
66
66
|
ref: ref
|
|
67
67
|
}, /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, content)));
|
|
68
68
|
expect(_react2.screen.getByText(content)).toBeInTheDocument();
|
|
@@ -77,7 +77,7 @@ describe('AppErrorBoundary', () => {
|
|
|
77
77
|
listen: _sinon.default.stub().returns(_sinon.default.stub())
|
|
78
78
|
};
|
|
79
79
|
const ref = /*#__PURE__*/_react.default.createRef();
|
|
80
|
-
(0, _react2.render)(
|
|
80
|
+
(0, _react2.render)(/*#__PURE__*/_react.default.createElement(_index.AppErrorBoundaryWithoutRouter, {
|
|
81
81
|
ref: ref,
|
|
82
82
|
history: history
|
|
83
83
|
}, /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, content)));
|
|
@@ -100,7 +100,7 @@ describe('AppErrorBoundary', () => {
|
|
|
100
100
|
const history = {
|
|
101
101
|
listen: jest.fn().mockReturnValue(unlisten)
|
|
102
102
|
};
|
|
103
|
-
const wrapper = (0, _react2.render)(
|
|
103
|
+
const wrapper = (0, _react2.render)(/*#__PURE__*/_react.default.createElement(_index.AppErrorBoundaryWithoutRouter, {
|
|
104
104
|
history: history
|
|
105
105
|
}, "test"));
|
|
106
106
|
wrapper.unmount();
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @private
|
|
3
|
+
*/
|
|
4
|
+
export class FetchStrategy extends React.Component<any, any, any> {
|
|
5
|
+
/**
|
|
6
|
+
* @private
|
|
7
|
+
*/
|
|
8
|
+
private static initAppState;
|
|
9
|
+
constructor(props: any);
|
|
10
|
+
constructor(props: any, context: any);
|
|
11
|
+
}
|
|
12
|
+
import React from "react";
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/ssr/universal/components/fetch-strategy/index.js"],"names":[],"mappings":"AAQA;;GAEG;AACH;IACI;;OAEG;IACH,4BAaC;IAE+3gC,wBAAgC;IAAA,sCAAmL;CADtlhC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export default Refresh;
|
|
2
|
+
/**
|
|
3
|
+
* A _private_ component to show loading spinner while refetching data on the client-side.
|
|
4
|
+
* To trigger this refetch, we do soft navigation back to the referrer.
|
|
5
|
+
* So this component is meant to be used as a route with `referrer` search param.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* const navigate = useNavigation()
|
|
9
|
+
* navigate(`/__refetch-data?referrer=${encodeURIComponent(urlOfCurrentPage)}`, 'replace')
|
|
10
|
+
*
|
|
11
|
+
* @private
|
|
12
|
+
*/
|
|
13
|
+
declare function Refresh(): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
declare namespace Refresh {
|
|
15
|
+
const displayName: string;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/ssr/universal/components/refresh/index.jsx"],"names":[],"mappings":";AAcA;;;;;;;;;;GAUG;AACH,oEAoCC"}
|
|
@@ -35,11 +35,11 @@ jest.mock('@tanstack/react-query', () => {
|
|
|
35
35
|
};
|
|
36
36
|
});
|
|
37
37
|
test('renders a loading spinner initially', () => {
|
|
38
|
-
(0, _react.render)(
|
|
38
|
+
(0, _react.render)(/*#__PURE__*/_react2.default.createElement(_index.default, null));
|
|
39
39
|
expect(_react.screen.getByTestId('loading-spinner')).toBeInTheDocument();
|
|
40
40
|
});
|
|
41
41
|
test('wait for react-query cache to be invalidated', /*#__PURE__*/_asyncToGenerator(function* () {
|
|
42
|
-
(0, _react.render)(
|
|
42
|
+
(0, _react.render)(/*#__PURE__*/_react2.default.createElement(_index.default, null));
|
|
43
43
|
yield (0, _react.waitFor)(() => {
|
|
44
44
|
expect((0, _reactQuery.useQueryClient)().invalidateQueries).toHaveBeenCalled();
|
|
45
45
|
});
|
|
@@ -49,7 +49,7 @@ test('a project not using react-query', /*#__PURE__*/_asyncToGenerator(function*
|
|
|
49
49
|
_reactQuery.useQueryClient.mockImplementationOnce(() => {
|
|
50
50
|
throw new Error();
|
|
51
51
|
});
|
|
52
|
-
(0, _react.render)(
|
|
52
|
+
(0, _react.render)(/*#__PURE__*/_react2.default.createElement(_index.default, null));
|
|
53
53
|
jest.runAllTimers();
|
|
54
54
|
yield (0, _react.waitFor)(() => {
|
|
55
55
|
// Expect to still continue despite the project not using react-query,
|
|
@@ -58,7 +58,7 @@ test('a project not using react-query', /*#__PURE__*/_asyncToGenerator(function*
|
|
|
58
58
|
});
|
|
59
59
|
}));
|
|
60
60
|
test('wait for soft navigation to the referrer', /*#__PURE__*/_asyncToGenerator(function* () {
|
|
61
|
-
(0, _react.render)(
|
|
61
|
+
(0, _react.render)(/*#__PURE__*/_react2.default.createElement(_index.default, null));
|
|
62
62
|
jest.runAllTimers();
|
|
63
63
|
yield (0, _react.waitFor)(() => {
|
|
64
64
|
expect((0, _reactRouterDom.useHistory)().replace).toHaveBeenCalledWith(referrerURL);
|
|
@@ -69,7 +69,7 @@ test('navigate to homepage if `referrer` search param cannot be found in the pag
|
|
|
69
69
|
_reactRouterDom.useLocation.mockImplementationOnce(() => ({
|
|
70
70
|
search: ''
|
|
71
71
|
}));
|
|
72
|
-
(0, _react.render)(
|
|
72
|
+
(0, _react.render)(/*#__PURE__*/_react2.default.createElement(_index.default, null));
|
|
73
73
|
jest.runAllTimers();
|
|
74
74
|
yield (0, _react.waitFor)(() => {
|
|
75
75
|
expect(console.warn).toHaveBeenCalled();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/ssr/universal/components/route-component/index.js"],"names":[],"mappings":"AAyDO;;;EAkVN;AASM,8CAwBN"}
|
|
@@ -17,8 +17,8 @@ var _withLegacyGetProps = require("../../components/with-legacy-get-props");
|
|
|
17
17
|
var _refresh = _interopRequireDefault(require("../refresh"));
|
|
18
18
|
const _excluded = ["component"];
|
|
19
19
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
20
|
-
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var
|
|
21
|
-
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.
|
|
20
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
21
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
|
|
22
22
|
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
23
23
|
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
24
24
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -388,11 +388,19 @@ const routeComponent = (Wrapped, isPage, locals) => {
|
|
|
388
388
|
* @private
|
|
389
389
|
*/
|
|
390
390
|
exports.routeComponent = routeComponent;
|
|
391
|
-
const getRoutes = locals => {
|
|
391
|
+
const getRoutes = (locals = {}) => {
|
|
392
392
|
let _routes = _routes2.default;
|
|
393
|
+
const {
|
|
394
|
+
applicationExtensions = []
|
|
395
|
+
} = locals;
|
|
393
396
|
if (typeof _routes2.default === 'function') {
|
|
394
397
|
_routes = (0, _routes2.default)();
|
|
395
398
|
}
|
|
399
|
+
|
|
400
|
+
// Call the `extendRoutes` function for all the Application Extensions.
|
|
401
|
+
applicationExtensions.forEach(applicationExtension => {
|
|
402
|
+
_routes = applicationExtension.extendRoutes(_routes);
|
|
403
|
+
});
|
|
396
404
|
const allRoutes = [
|
|
397
405
|
// NOTE: this route needs to be above _routes, in case _routes has a fallback route of `path: '*'`
|
|
398
406
|
{
|
|
@@ -94,7 +94,7 @@ describe('The routeComponent component', () => {
|
|
|
94
94
|
test('Is a higher-order component', () => {
|
|
95
95
|
const Mock = getMockComponent();
|
|
96
96
|
const Component = (0, _index.routeComponent)(Mock);
|
|
97
|
-
(0, _react2.render)(
|
|
97
|
+
(0, _react2.render)(/*#__PURE__*/_react.default.createElement(Component, {
|
|
98
98
|
isHydrating: false
|
|
99
99
|
}));
|
|
100
100
|
expect(_react2.screen.getByText(/mockComponent/i)).toBeInTheDocument();
|
|
@@ -112,7 +112,7 @@ describe('The routeComponent component', () => {
|
|
|
112
112
|
}).then(() => {
|
|
113
113
|
// Simulate the initial client-side mount (hydrating=true)
|
|
114
114
|
return new Promise(resolve => {
|
|
115
|
-
wrapper = (0, _react2.render)(
|
|
115
|
+
wrapper = (0, _react2.render)(/*#__PURE__*/_react.default.createElement(Component, {
|
|
116
116
|
history: {
|
|
117
117
|
location: {
|
|
118
118
|
pathname: '/home/'
|
|
@@ -130,7 +130,7 @@ describe('The routeComponent component', () => {
|
|
|
130
130
|
}).then(() => {
|
|
131
131
|
// Simulate visiting a different URL, which should trigger shouldMount() and getProps()
|
|
132
132
|
return new Promise(resolve => {
|
|
133
|
-
wrapper.rerender(
|
|
133
|
+
wrapper.rerender(/*#__PURE__*/_react.default.createElement(Component, {
|
|
134
134
|
history: {
|
|
135
135
|
location: {
|
|
136
136
|
pathname: '/plp/'
|
|
@@ -211,7 +211,7 @@ describe('The routeComponent component', () => {
|
|
|
211
211
|
throw error;
|
|
212
212
|
};
|
|
213
213
|
const Component = (0, _index.routeComponent)(Mock, {}, true);
|
|
214
|
-
return new Promise(resolve => (0, _react2.render)(
|
|
214
|
+
return new Promise(resolve => (0, _react2.render)(/*#__PURE__*/_react.default.createElement(Component, {
|
|
215
215
|
isHydrating: false,
|
|
216
216
|
onGetPropsError: resolve
|
|
217
217
|
}))).then(caught => expect(caught).toBe(error));
|
|
@@ -222,7 +222,7 @@ describe('The routeComponent component', () => {
|
|
|
222
222
|
Mock.shouldGetProps = trueOnceThenFalse();
|
|
223
223
|
Mock.getProps = () => delay(10).then(() => Promise.reject(errorText));
|
|
224
224
|
const Component = (0, _index.routeComponent)(Mock);
|
|
225
|
-
return new Promise(resolve => (0, _react2.render)(
|
|
225
|
+
return new Promise(resolve => (0, _react2.render)(/*#__PURE__*/_react.default.createElement(Component, {
|
|
226
226
|
isHydrating: false,
|
|
227
227
|
onGetPropsError: resolve
|
|
228
228
|
}))).then(caught => expect(caught).toBe(errorText));
|
|
@@ -239,7 +239,7 @@ describe('The routeComponent component', () => {
|
|
|
239
239
|
Mock.shouldGetProps = trueOnceThenFalse();
|
|
240
240
|
const Component = (0, _index.routeComponent)(Mock, {}, true);
|
|
241
241
|
yield new Promise(resolve => {
|
|
242
|
-
(0, _react2.render)(
|
|
242
|
+
(0, _react2.render)(/*#__PURE__*/_react.default.createElement(Component, {
|
|
243
243
|
onUpdateComplete: () => {
|
|
244
244
|
resolve();
|
|
245
245
|
}
|
|
@@ -302,7 +302,7 @@ describe('Handles race conditions for getProps', () => {
|
|
|
302
302
|
};
|
|
303
303
|
yield new Promise(resolve => {
|
|
304
304
|
resolver.push(resolve);
|
|
305
|
-
wrapper = (0, _react2.render)(
|
|
305
|
+
wrapper = (0, _react2.render)(/*#__PURE__*/_react.default.createElement(Component, {
|
|
306
306
|
onUpdateComplete: onUpdateComplete
|
|
307
307
|
}));
|
|
308
308
|
});
|
|
@@ -311,13 +311,13 @@ describe('Handles race conditions for getProps', () => {
|
|
|
311
311
|
// twice, but only the later should call `setStateAsync` causing a re-render.
|
|
312
312
|
const p1 = new Promise(resolve => {
|
|
313
313
|
resolver.push(resolve);
|
|
314
|
-
wrapper.rerender(
|
|
314
|
+
wrapper.rerender(/*#__PURE__*/_react.default.createElement(Component, {
|
|
315
315
|
onUpdateComplete: onUpdateComplete
|
|
316
316
|
}));
|
|
317
317
|
});
|
|
318
318
|
const p2 = new Promise(resolve => {
|
|
319
319
|
resolver.push(resolve);
|
|
320
|
-
wrapper.rerender(
|
|
320
|
+
wrapper.rerender(/*#__PURE__*/_react.default.createElement(Component, {
|
|
321
321
|
onUpdateComplete: onUpdateComplete
|
|
322
322
|
}));
|
|
323
323
|
});
|
|
@@ -343,7 +343,7 @@ describe('Uses preloaded props on initial clientside page load', () => {
|
|
|
343
343
|
Mock.displayName = 'MockComponent';
|
|
344
344
|
const Component = (0, _index.routeComponent)(Mock, true, {});
|
|
345
345
|
yield new Promise(resolve => {
|
|
346
|
-
const wrapper = (0, _react2.render)(
|
|
346
|
+
const wrapper = (0, _react2.render)(/*#__PURE__*/_react.default.createElement(Component, {
|
|
347
347
|
preloadedProps: preloadedProps,
|
|
348
348
|
onUpdateComplete: () => resolve(wrapper)
|
|
349
349
|
}));
|
|
@@ -366,7 +366,7 @@ describe('Uses preloaded props on initial clientside page load', () => {
|
|
|
366
366
|
Mock.displayName = 'MockComponent';
|
|
367
367
|
const Component = (0, _index.routeComponent)(Mock, true, {});
|
|
368
368
|
yield new Promise(resolve => {
|
|
369
|
-
const wrapper = (0, _react2.render)(
|
|
369
|
+
const wrapper = (0, _react2.render)(/*#__PURE__*/_react.default.createElement(Component, {
|
|
370
370
|
preloadedProps: preloadedProps,
|
|
371
371
|
onUpdateComplete: () => resolve(wrapper)
|
|
372
372
|
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/ssr/universal/components/routes/index.jsx"],"names":[],"mappings":";AAOA,4BAAiB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
/*
|
|
8
|
+
* Copyright (c) 2024, salesforce.com, inc.
|
|
9
|
+
* All rights reserved.
|
|
10
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
11
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const routes = [];
|
|
15
|
+
var _default = exports.default = routes;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export default Switch;
|
|
2
|
+
/**
|
|
3
|
+
* The Switch component packages up the bits of rendering that are shared between
|
|
4
|
+
* server and client-side. It's *mostly* a react-router Switch component, hence the
|
|
5
|
+
* name.
|
|
6
|
+
*
|
|
7
|
+
* This is for internal use only.
|
|
8
|
+
*
|
|
9
|
+
* @private
|
|
10
|
+
*/
|
|
11
|
+
declare function Switch(props: any): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
declare namespace Switch {
|
|
13
|
+
namespace propTypes {
|
|
14
|
+
const error: PropTypes.Requireable<object>;
|
|
15
|
+
const appState: PropTypes.Requireable<object>;
|
|
16
|
+
const routes: PropTypes.Requireable<any[]>;
|
|
17
|
+
const App: PropTypes.Requireable<(...args: any[]) => any>;
|
|
18
|
+
const preloadedProps: PropTypes.Requireable<object>;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
import PropTypes from "prop-types";
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/ssr/universal/components/switch/index.jsx"],"names":[],"mappings":";AAYA;;;;;;;;GAQG;AACH,6EAwBC"}
|
|
@@ -18,8 +18,8 @@ const _excluded = ["component"];
|
|
|
18
18
|
*/
|
|
19
19
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
20
20
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
21
|
-
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var
|
|
22
|
-
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.
|
|
21
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
22
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
|
|
23
23
|
/**
|
|
24
24
|
* The Switch component packages up the bits of rendering that are shared between
|
|
25
25
|
* server and client-side. It's *mostly* a react-router Switch component, hence the
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export default Throw404;
|
|
2
|
+
/**
|
|
3
|
+
* This is designed to be put into a react-router config as a fallback
|
|
4
|
+
* with path="*", simply to trigger the normal error handling code we have.
|
|
5
|
+
* As a result, this component should never be rendered – it should
|
|
6
|
+
* trigger the error page instead.
|
|
7
|
+
*
|
|
8
|
+
* @private
|
|
9
|
+
*/
|
|
10
|
+
declare class Throw404 extends React.Component<any, any, any> {
|
|
11
|
+
static getProps(): void;
|
|
12
|
+
constructor(props: any);
|
|
13
|
+
constructor(props: any, context: any);
|
|
14
|
+
render(): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
}
|
|
16
|
+
import React from "react";
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/ssr/universal/components/throw-404/index.jsx"],"names":[],"mappings":";AAUA;;;;;;;GAOG;AACH;IACI,wBAEC;IAQ82gC,wBAAgC;IAAA,sCAAmL;IAPlkhC,kDAGC;CACJ"}
|
|
@@ -16,7 +16,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
16
16
|
|
|
17
17
|
describe('Throw404', () => {
|
|
18
18
|
test('Renders correctly', () => {
|
|
19
|
-
(0, _react2.render)(
|
|
19
|
+
(0, _react2.render)(/*#__PURE__*/_react.default.createElement(_index.default, null));
|
|
20
20
|
const content = document.querySelector('body').firstElementChild.innerHTML;
|
|
21
21
|
expect(content).toBe('<div></div>');
|
|
22
22
|
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An HOC that injects the correlation id to a component
|
|
3
|
+
* @param Component
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
export function withCorrelationId(Component: any): {
|
|
7
|
+
({ ...passThroughProps }: {
|
|
8
|
+
[x: string]: any;
|
|
9
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
displayName: string;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/ssr/universal/components/with-correlation-id/index.js"],"names":[],"mappings":"AASA;;;;GAIG;AACH;;;;;EAWC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export function withLegacyGetProps(Wrapped: any): {
|
|
2
|
+
new (props: any): {
|
|
3
|
+
render(): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
context: unknown;
|
|
5
|
+
setState<K extends string | number | symbol>(state: any, callback?: (() => void) | undefined): void;
|
|
6
|
+
forceUpdate(callback?: (() => void) | undefined): void;
|
|
7
|
+
readonly props: Readonly<any>;
|
|
8
|
+
state: Readonly<any>;
|
|
9
|
+
refs: {
|
|
10
|
+
[key: string]: React.ReactInstance;
|
|
11
|
+
};
|
|
12
|
+
componentDidMount?(): void;
|
|
13
|
+
shouldComponentUpdate?(nextProps: Readonly<any>, nextState: Readonly<any>, nextContext: any): boolean;
|
|
14
|
+
componentWillUnmount?(): void;
|
|
15
|
+
componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
|
|
16
|
+
getSnapshotBeforeUpdate?(prevProps: Readonly<any>, prevState: Readonly<any>): any;
|
|
17
|
+
componentDidUpdate?(prevProps: Readonly<any>, prevState: Readonly<any>, snapshot?: any): void;
|
|
18
|
+
componentWillMount?(): void;
|
|
19
|
+
UNSAFE_componentWillMount?(): void;
|
|
20
|
+
componentWillReceiveProps?(nextProps: Readonly<any>, nextContext: any): void;
|
|
21
|
+
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<any>, nextContext: any): void;
|
|
22
|
+
componentWillUpdate?(nextProps: Readonly<any>, nextState: Readonly<any>, nextContext: any): void;
|
|
23
|
+
UNSAFE_componentWillUpdate?(nextProps: Readonly<any>, nextState: Readonly<any>, nextContext: any): void;
|
|
24
|
+
};
|
|
25
|
+
new (props: any, context: any): {
|
|
26
|
+
render(): import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
context: unknown;
|
|
28
|
+
setState<K extends string | number | symbol>(state: any, callback?: (() => void) | undefined): void;
|
|
29
|
+
forceUpdate(callback?: (() => void) | undefined): void;
|
|
30
|
+
readonly props: Readonly<any>;
|
|
31
|
+
state: Readonly<any>;
|
|
32
|
+
refs: {
|
|
33
|
+
[key: string]: React.ReactInstance;
|
|
34
|
+
};
|
|
35
|
+
componentDidMount?(): void;
|
|
36
|
+
shouldComponentUpdate?(nextProps: Readonly<any>, nextState: Readonly<any>, nextContext: any): boolean;
|
|
37
|
+
componentWillUnmount?(): void;
|
|
38
|
+
componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
|
|
39
|
+
getSnapshotBeforeUpdate?(prevProps: Readonly<any>, prevState: Readonly<any>): any;
|
|
40
|
+
componentDidUpdate?(prevProps: Readonly<any>, prevState: Readonly<any>, snapshot?: any): void;
|
|
41
|
+
componentWillMount?(): void;
|
|
42
|
+
UNSAFE_componentWillMount?(): void;
|
|
43
|
+
componentWillReceiveProps?(nextProps: Readonly<any>, nextContext: any): void;
|
|
44
|
+
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<any>, nextContext: any): void;
|
|
45
|
+
componentWillUpdate?(nextProps: Readonly<any>, nextState: Readonly<any>, nextContext: any): void;
|
|
46
|
+
UNSAFE_componentWillUpdate?(nextProps: Readonly<any>, nextState: Readonly<any>, nextContext: any): void;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* @private
|
|
50
|
+
*/
|
|
51
|
+
doInitAppState({ App, match, route, req, res, location }: {
|
|
52
|
+
App: any;
|
|
53
|
+
match: any;
|
|
54
|
+
route: any;
|
|
55
|
+
req: any;
|
|
56
|
+
res: any;
|
|
57
|
+
location: any;
|
|
58
|
+
}): Promise<{
|
|
59
|
+
appProps: any;
|
|
60
|
+
pageProps: any;
|
|
61
|
+
}>;
|
|
62
|
+
/**
|
|
63
|
+
* @private
|
|
64
|
+
*/
|
|
65
|
+
getInitializers(): any[];
|
|
66
|
+
/**
|
|
67
|
+
* @private
|
|
68
|
+
*/
|
|
69
|
+
getHOCsInUse(): any[];
|
|
70
|
+
displayName: string;
|
|
71
|
+
initAppState(args: any): Promise<{
|
|
72
|
+
error: undefined;
|
|
73
|
+
appState: any;
|
|
74
|
+
} | {
|
|
75
|
+
error: {};
|
|
76
|
+
appState: {};
|
|
77
|
+
}>;
|
|
78
|
+
contextType?: React.Context<any> | undefined;
|
|
79
|
+
};
|
|
80
|
+
import React from "react";
|
|
81
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/ssr/universal/components/with-legacy-get-props/index.js"],"names":[],"mappings":"AAWO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAYC;;OAEG;;;;;;;;;;;;IAyCH;;OAEG;;IAKH;;OAEG;;;;;;;;;;;EAiBV"}
|
|
@@ -44,7 +44,7 @@ const withLegacyGetProps = Wrapped => {
|
|
|
44
44
|
params
|
|
45
45
|
} = match;
|
|
46
46
|
const components = [App, route.component];
|
|
47
|
-
const promises = components.map(
|
|
47
|
+
const promises = components.map(c => {
|
|
48
48
|
// getTemplateName is a promise and it's intentially not awaited here
|
|
49
49
|
// to avoid blocking the execution of the getProps function to maximize performance
|
|
50
50
|
// getTemplateName should be very fast, under 0.2ms
|
|
@@ -15,7 +15,7 @@ describe('withLegacyGetProps', function () {
|
|
|
15
15
|
test('Renders correctly', () => {
|
|
16
16
|
const Wrapped = () => /*#__PURE__*/_react2.default.createElement("p", null, "Hello world");
|
|
17
17
|
const Component = (0, _index.withLegacyGetProps)(Wrapped);
|
|
18
|
-
(0, _react.render)(
|
|
18
|
+
(0, _react.render)(/*#__PURE__*/_react2.default.createElement(Component, {
|
|
19
19
|
locals: {}
|
|
20
20
|
}));
|
|
21
21
|
expect(_react.screen.getByText(/Hello world/i)).toBeInTheDocument();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/ssr/universal/components/with-react-query/index.js"],"names":[],"mappings":"AA0BO,wCANI,MAAM,YAAY;IAEF,iBAAiB,EAAjC,MAAM;IAEJ,MAAM,YAAY,CA4G9B"}
|
|
@@ -32,7 +32,7 @@ describe('withReactQuery', function () {
|
|
|
32
32
|
test('Renders correctly', () => {
|
|
33
33
|
const Wrapped = () => /*#__PURE__*/_react2.default.createElement("p", null, "Hello world");
|
|
34
34
|
const Component = (0, _index.withReactQuery)(Wrapped);
|
|
35
|
-
(0, _react.render)(
|
|
35
|
+
(0, _react.render)(/*#__PURE__*/_react2.default.createElement(Component, {
|
|
36
36
|
locals: {}
|
|
37
37
|
}));
|
|
38
38
|
expect(_react.screen.getByText(/Hello world/i)).toBeInTheDocument();
|
|
@@ -49,7 +49,7 @@ describe('withReactQuery', function () {
|
|
|
49
49
|
window.__PRELOADED_STATE__ = {
|
|
50
50
|
__reactQuery: mockPreloadedState
|
|
51
51
|
};
|
|
52
|
-
(0, _react.render)(
|
|
52
|
+
(0, _react.render)(/*#__PURE__*/_react2.default.createElement(Component, {
|
|
53
53
|
locals: {}
|
|
54
54
|
}));
|
|
55
55
|
expect(_react.screen.getByText(/Hello world/i)).toBeInTheDocument();
|
|
@@ -72,7 +72,7 @@ describe('withReactQuery', function () {
|
|
|
72
72
|
__reactQuery: mockPreloadedState
|
|
73
73
|
};
|
|
74
74
|
_loggerInstance.default.error = jest.fn();
|
|
75
|
-
(0, _react.render)(
|
|
75
|
+
(0, _react.render)(/*#__PURE__*/_react2.default.createElement(Component, {
|
|
76
76
|
locals: {}
|
|
77
77
|
}));
|
|
78
78
|
expect(_react.screen.getByText(/Hello world/i)).toBeInTheDocument();
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export const CorrelationIdContext: React.Context<any>;
|
|
2
|
+
/**
|
|
3
|
+
* This provider initializes the correlation id,
|
|
4
|
+
* and will generate a new id whenever there is a location change
|
|
5
|
+
* @private
|
|
6
|
+
* @param children
|
|
7
|
+
* @param correlationId - default correlation id
|
|
8
|
+
* @param resetOnPageChange - a boolean to indicate if it needs to generate a new id when navigating to a new page
|
|
9
|
+
*/
|
|
10
|
+
export function CorrelationIdProvider({ children, correlationId, resetOnPageChange }: {
|
|
11
|
+
children: any;
|
|
12
|
+
correlationId: any;
|
|
13
|
+
resetOnPageChange?: boolean | undefined;
|
|
14
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export namespace CorrelationIdProvider {
|
|
16
|
+
namespace propTypes {
|
|
17
|
+
const children: PropTypes.Validator<PropTypes.ReactElementLike>;
|
|
18
|
+
const resetOnPageChange: PropTypes.Requireable<boolean>;
|
|
19
|
+
const correlationId: PropTypes.Validator<NonNullable<NonNullable<string | ((...args: any[]) => any) | null | undefined>>>;
|
|
20
|
+
const location: PropTypes.Requireable<object>;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export const ServerContext: React.Context<any>;
|
|
24
|
+
import React from "react";
|
|
25
|
+
import PropTypes from "prop-types";
|
|
26
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ssr/universal/contexts/index.js"],"names":[],"mappings":"AAYA,sDAAkD;AAGlD;;;;;;;GAOG;AACH;;;;4CAiCC;;;;;;;;;AA3CD,+CAA2C"}
|
|
@@ -44,7 +44,7 @@ describe('CorrelationIdProvider', function () {
|
|
|
44
44
|
test('Renders without errors', () => {
|
|
45
45
|
const history = (0, _history.createMemoryHistory)();
|
|
46
46
|
const id = _crypto.default.randomUUID();
|
|
47
|
-
(0, _react2.render)(
|
|
47
|
+
(0, _react2.render)(/*#__PURE__*/_react.default.createElement(_reactRouterDom.Router, {
|
|
48
48
|
history: history
|
|
49
49
|
}, /*#__PURE__*/_react.default.createElement(SampleProvider, {
|
|
50
50
|
correlationId: () => id
|
|
@@ -54,7 +54,7 @@ describe('CorrelationIdProvider', function () {
|
|
|
54
54
|
test('renders when correlationId is passed as a function', () => {
|
|
55
55
|
const id = _crypto.default.randomUUID();
|
|
56
56
|
const history = (0, _history.createMemoryHistory)();
|
|
57
|
-
(0, _react2.render)(
|
|
57
|
+
(0, _react2.render)(/*#__PURE__*/_react.default.createElement(_reactRouterDom.Router, {
|
|
58
58
|
history: history
|
|
59
59
|
}, /*#__PURE__*/_react.default.createElement(SampleProvider, {
|
|
60
60
|
correlationId: () => id
|
|
@@ -64,7 +64,7 @@ describe('CorrelationIdProvider', function () {
|
|
|
64
64
|
test('renders when correlationId is passed as a string', () => {
|
|
65
65
|
const id = _crypto.default.randomUUID();
|
|
66
66
|
const history = (0, _history.createMemoryHistory)();
|
|
67
|
-
(0, _react2.render)(
|
|
67
|
+
(0, _react2.render)(/*#__PURE__*/_react.default.createElement(_reactRouterDom.Router, {
|
|
68
68
|
history: history
|
|
69
69
|
}, /*#__PURE__*/_react.default.createElement(SampleProvider, {
|
|
70
70
|
correlationId: id,
|
|
@@ -86,7 +86,7 @@ describe('CorrelationIdProvider', function () {
|
|
|
86
86
|
onClick: () => history.push('/page-1')
|
|
87
87
|
}, "Go to another page"));
|
|
88
88
|
};
|
|
89
|
-
(0, _react2.render)(
|
|
89
|
+
(0, _react2.render)(/*#__PURE__*/_react.default.createElement(_reactRouterDom.Router, {
|
|
90
90
|
history: history
|
|
91
91
|
}, /*#__PURE__*/_react.default.createElement(SampleProvider, {
|
|
92
92
|
correlationId: () => _crypto.default.randomUUID()
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export class HTTPError extends Error {
|
|
2
|
+
constructor(status: any, message: any);
|
|
3
|
+
constructor: typeof HTTPError;
|
|
4
|
+
__proto__: HTTPError;
|
|
5
|
+
message: any;
|
|
6
|
+
status: any;
|
|
7
|
+
}
|
|
8
|
+
export class HTTPNotFound extends HTTPError {
|
|
9
|
+
constructor(message: any);
|
|
10
|
+
constructor: typeof HTTPNotFound;
|
|
11
|
+
__proto__: HTTPNotFound;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/ssr/universal/errors.js"],"names":[],"mappings":"AAOA;IACI,uCAMC;IAJG,8BAA4B;IAC5B,qBAAoC;IACpC,aAAsB;IACtB,YAAoB;CAM3B;AAED;IACI,0BAIC;IAFG,iCAA+B;IAC/B,wBAAuC;CAE9C"}
|