@salesforce/pwa-kit-react-sdk 3.9.0-nightly-20241209080219 → 4.0.0-extensibility-preview.1
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 +6 -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
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
##
|
|
2
|
-
##
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
-
|
|
6
|
-
-
|
|
1
|
+
## v4.0.0-extensibility-preview.1 (Dec 09, 2024)
|
|
2
|
+
## v4.0.0-extensibility-preview.0 (Nov 28, 2024)
|
|
3
|
+
- Integrate Application Extensions Project. (#2099)[https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2099]
|
|
4
|
+
- Add new `getStaticAssetUrl` utility to access assets specifically in the `/static` folder. (#2040)[https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2040]
|
|
5
|
+
- Update Application Extensions import in `react-rendering.js` and `main.js` (#2004)[https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2004]
|
|
6
|
+
- Define interface of the app extension's config [#2010](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2010)
|
|
7
7
|
|
|
8
8
|
## v3.7.0 (Aug 07, 2024)
|
|
9
9
|
- Add `beforeHydrate` option to withReactQuery component [#1912](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/1912)
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/pwa-kit-react-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-extensibility-preview.1",
|
|
4
4
|
"description": "A library that supports the isomorphic React rendering pipeline for Commerce Cloud Managed Runtime apps",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
5
6
|
"homepage": "https://github.com/SalesforceCommerceCloud/pwa-kit/tree/develop/packages/pwa-kit-react-sdk#readme",
|
|
6
7
|
"bugs": {
|
|
7
8
|
"url": "https://github.com/SalesforceCommerceCloud/pwa-kit/issues"
|
|
@@ -21,12 +22,12 @@
|
|
|
21
22
|
"storefront-preview"
|
|
22
23
|
],
|
|
23
24
|
"scripts": {
|
|
24
|
-
"build": "cross-env NODE_ENV=production internal-lib-build build",
|
|
25
|
-
"build:watch": "nodemon --watch 'src/**' --exec 'npm run build'",
|
|
26
|
-
"format": "internal-lib-build format \"**/*.{js,jsx}\"",
|
|
25
|
+
"build": "cross-env NODE_ENV=production internal-lib-build build && tsc",
|
|
26
|
+
"build:watch": "nodemon --watch 'src/**' --ext 'js,jsx,ts,tsx' --exec 'npm run build'",
|
|
27
|
+
"format": "internal-lib-build format \"**/*.{js,jsx,ts,tsx}\"",
|
|
27
28
|
"lint": "npm run lint:js",
|
|
28
29
|
"lint:fix": "npm run lint:js -- --fix",
|
|
29
|
-
"lint:js": "pwa-kit-dev lint \"**/*.{js,jsx}\"",
|
|
30
|
+
"lint:js": "pwa-kit-dev lint \"**/*.{js,jsx,ts,tsx}\"",
|
|
30
31
|
"prepare": "npm run build",
|
|
31
32
|
"test": "pwa-kit-dev test",
|
|
32
33
|
"test:inspect": "node --inspect-brk jest --runInBand",
|
|
@@ -37,7 +38,8 @@
|
|
|
37
38
|
"@loadable/babel-plugin": "^5.15.3",
|
|
38
39
|
"@loadable/server": "^5.15.3",
|
|
39
40
|
"@loadable/webpack-plugin": "^5.15.2",
|
|
40
|
-
"@salesforce/pwa-kit-
|
|
41
|
+
"@salesforce/pwa-kit-extension-sdk": "4.0.0-extensibility-preview.1",
|
|
42
|
+
"@salesforce/pwa-kit-runtime": "4.0.0-extensibility-preview.1",
|
|
41
43
|
"@tanstack/react-query": "^4.28.0",
|
|
42
44
|
"cross-env": "^5.2.1",
|
|
43
45
|
"event-emitter": "^0.3.5",
|
|
@@ -50,11 +52,14 @@
|
|
|
50
52
|
},
|
|
51
53
|
"devDependencies": {
|
|
52
54
|
"@loadable/component": "^5.15.3",
|
|
53
|
-
"@salesforce/pwa-kit-dev": "
|
|
55
|
+
"@salesforce/pwa-kit-dev": "4.0.0-extensibility-preview.1",
|
|
54
56
|
"@testing-library/jest-dom": "^5.16.5",
|
|
55
57
|
"@testing-library/react": "^14.0.0",
|
|
56
58
|
"@testing-library/user-event": "^14.4.3",
|
|
57
|
-
"
|
|
59
|
+
"@types/hoist-non-react-statics": "~3.3.5",
|
|
60
|
+
"@types/react": "~18.2.0",
|
|
61
|
+
"@types/react-dom": "~18.2.1",
|
|
62
|
+
"internal-lib-build": "4.0.0-extensibility-preview.1",
|
|
58
63
|
"node-html-parser": "^3.3.6",
|
|
59
64
|
"nodemon": "^2.0.22",
|
|
60
65
|
"react": "^18.2.0",
|
|
@@ -79,5 +84,5 @@
|
|
|
79
84
|
"publishConfig": {
|
|
80
85
|
"directory": "dist"
|
|
81
86
|
},
|
|
82
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "5728f89cb53ab1b0c89418578f3e90c755efb0f8"
|
|
83
88
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export function registerServiceWorker(url: any): Promise<void | undefined>;
|
|
2
|
+
export function OuterApp({ routes, error, extensions, WrappedApp, locals, onHydrate }: {
|
|
3
|
+
routes: any;
|
|
4
|
+
error: any;
|
|
5
|
+
extensions: any;
|
|
6
|
+
WrappedApp: any;
|
|
7
|
+
locals: any;
|
|
8
|
+
onHydrate: any;
|
|
9
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export namespace OuterApp {
|
|
11
|
+
namespace propTypes {
|
|
12
|
+
const routes: PropTypes.Validator<any[]>;
|
|
13
|
+
const error: PropTypes.Requireable<object>;
|
|
14
|
+
const extensions: PropTypes.Requireable<any[]>;
|
|
15
|
+
const WrappedApp: PropTypes.Validator<(...args: any[]) => any>;
|
|
16
|
+
const locals: PropTypes.Requireable<object>;
|
|
17
|
+
const onHydrate: PropTypes.Requireable<(...args: any[]) => any>;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export function start(): Promise<void>;
|
|
21
|
+
import PropTypes from "prop-types";
|
|
22
|
+
//# sourceMappingURL=main.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/ssr/browser/main.jsx"],"names":[],"mappings":"AA0BO,2EAoBN;AAEM;;;;;;;4CAmCN;;;;;;;;;;;AAWM,uCA6DN"}
|
package/ssr/browser/main.js
CHANGED
|
@@ -6,20 +6,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.start = exports.registerServiceWorker = exports.OuterApp = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _client = require("react-dom/client");
|
|
9
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
10
|
var _reactRouterDom = require("react-router-dom");
|
|
11
|
+
var _component = require("@loadable/component");
|
|
12
|
+
var _react2 = require("@salesforce/pwa-kit-extension-sdk/react");
|
|
10
13
|
var _contexts = require("../universal/contexts");
|
|
11
14
|
var _app = _interopRequireDefault(require("../universal/components/_app"));
|
|
12
15
|
var _compatibility = require("../universal/compatibility");
|
|
13
16
|
var _switch = _interopRequireDefault(require("../universal/components/switch"));
|
|
14
17
|
var _routeComponent = require("../universal/components/route-component");
|
|
15
|
-
var _component = require("@loadable/component");
|
|
16
18
|
var _uuidv = require("../../utils/uuidv4.client");
|
|
17
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
18
19
|
var _loggerInstance = _interopRequireDefault(require("../../utils/logger-instance"));
|
|
19
20
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
20
21
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
21
22
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
22
|
-
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); }
|
|
23
|
+
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); }
|
|
24
|
+
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); }
|
|
25
|
+
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); }); }; } /*
|
|
23
26
|
* Copyright (c) 2021, salesforce.com, inc.
|
|
24
27
|
* All rights reserved.
|
|
25
28
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -44,12 +47,19 @@ exports.registerServiceWorker = registerServiceWorker;
|
|
|
44
47
|
const OuterApp = ({
|
|
45
48
|
routes,
|
|
46
49
|
error,
|
|
50
|
+
extensions,
|
|
47
51
|
WrappedApp,
|
|
48
52
|
locals,
|
|
49
53
|
onHydrate
|
|
50
54
|
}) => {
|
|
51
55
|
const AppConfig = (0, _compatibility.getAppConfig)();
|
|
52
56
|
const isInitialPageRef = (0, _react.useRef)(true);
|
|
57
|
+
|
|
58
|
+
// Invoke the Application Extensions 'beforeRouteMatch' hook. This hook accepts ALL the routes for the current
|
|
59
|
+
// application including all routes added from the configured extensions.
|
|
60
|
+
extensions.forEach(applicationExtension => {
|
|
61
|
+
routes = applicationExtension.beforeRouteMatch(routes);
|
|
62
|
+
});
|
|
53
63
|
return /*#__PURE__*/_react.default.createElement(_contexts.ServerContext.Provider, {
|
|
54
64
|
value: {}
|
|
55
65
|
}, /*#__PURE__*/_react.default.createElement(_reactRouterDom.BrowserRouter, {
|
|
@@ -76,55 +86,68 @@ exports.OuterApp = OuterApp;
|
|
|
76
86
|
OuterApp.propTypes = {
|
|
77
87
|
routes: _propTypes.default.array.isRequired,
|
|
78
88
|
error: _propTypes.default.object,
|
|
89
|
+
extensions: _propTypes.default.array,
|
|
79
90
|
WrappedApp: _propTypes.default.func.isRequired,
|
|
80
91
|
locals: _propTypes.default.object,
|
|
81
92
|
onHydrate: _propTypes.default.func
|
|
82
93
|
};
|
|
83
94
|
/* istanbul ignore next */
|
|
84
|
-
const start = ()
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
95
|
+
const start = exports.start = /*#__PURE__*/function () {
|
|
96
|
+
var _ref = _asyncToGenerator(function* () {
|
|
97
|
+
const AppConfig = (0, _compatibility.getAppConfig)();
|
|
98
|
+
const rootEl = document.getElementsByClassName('react-target')[0];
|
|
99
|
+
const data = JSON.parse(document.getElementById('mobify-data').innerHTML);
|
|
88
100
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
101
|
+
// Set all globals sent from the server on the window object.
|
|
102
|
+
Object.entries(data).forEach(([key, value]) => {
|
|
103
|
+
window[key] = value;
|
|
104
|
+
});
|
|
93
105
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
106
|
+
// Tell webpack how to find javascript files
|
|
107
|
+
Object.defineProperty(__webpack_require__, 'p', {
|
|
108
|
+
get: () => window.Progressive.buildOrigin
|
|
109
|
+
});
|
|
98
110
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
111
|
+
// On the browser we don't have request.locals, so we just provide an empty
|
|
112
|
+
// object that exists for the lifetime of the app. AppConfig components can use
|
|
113
|
+
// this to set up, eg. Redux stores.
|
|
114
|
+
const locals = {};
|
|
103
115
|
|
|
104
|
-
|
|
105
|
-
|
|
116
|
+
// AppConfig.restore *must* come before getRoutes()
|
|
117
|
+
AppConfig.restore(locals, window.__PRELOADED_STATE__.__STATE_MANAGEMENT_LIBRARY);
|
|
106
118
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
119
|
+
// We need to tell the routeComponent HOC when the app is hydrating in order to
|
|
120
|
+
// prevent pages from re-fetching data on the first client-side render. The
|
|
121
|
+
// reason we do this is that we expect a render to have taken place
|
|
122
|
+
// on the server already. That server-side render already called getProps()
|
|
123
|
+
// and froze the application state as a JSON blob on the page.
|
|
124
|
+
//
|
|
125
|
+
// This is VERY fiddly – don't go crazy with window.__HYDRATING__. You have
|
|
126
|
+
// been warned.
|
|
127
|
+
window.__HYDRATING__ = true;
|
|
128
|
+
|
|
129
|
+
// Load all the configured Application Extensions and provide them to the
|
|
130
|
+
const applicationExtensions = yield (0, _react2.getApplicationExtensions)();
|
|
131
|
+
const WrappedApp = (0, _react2.withApplicationExtensions)((0, _routeComponent.routeComponent)(_app.default, false, locals), {
|
|
132
|
+
applicationExtensions,
|
|
133
|
+
locals
|
|
134
|
+
});
|
|
135
|
+
const props = {
|
|
136
|
+
error: window.__ERROR__,
|
|
137
|
+
locals: locals,
|
|
138
|
+
routes: (0, _routeComponent.getRoutes)(locals),
|
|
139
|
+
extensions: applicationExtensions,
|
|
140
|
+
WrappedApp
|
|
141
|
+
};
|
|
142
|
+
return Promise.resolve().then(() => new Promise(resolve => (0, _component.loadableReady)(resolve))).then(() => {
|
|
143
|
+
(0, _client.hydrateRoot)(rootEl, /*#__PURE__*/_react.default.createElement(OuterApp, _extends({}, props, {
|
|
144
|
+
onHydrate: () => {
|
|
145
|
+
window.__HYDRATING__ = false;
|
|
146
|
+
}
|
|
147
|
+
})));
|
|
148
|
+
});
|
|
128
149
|
});
|
|
129
|
-
|
|
130
|
-
|
|
150
|
+
return function start() {
|
|
151
|
+
return _ref.apply(this, arguments);
|
|
152
|
+
};
|
|
153
|
+
}();
|
package/ssr/browser/main.test.js
CHANGED
|
@@ -30,9 +30,10 @@ describe('main', function () {
|
|
|
30
30
|
error: undefined,
|
|
31
31
|
locals,
|
|
32
32
|
routes: (0, _routeComponent.getRoutes)(locals),
|
|
33
|
-
WrappedApp: (0, _routeComponent.routeComponent)(App, false, locals)
|
|
33
|
+
WrappedApp: (0, _routeComponent.routeComponent)(App, false, locals),
|
|
34
|
+
extensions: []
|
|
34
35
|
};
|
|
35
|
-
(0, _react2.render)(
|
|
36
|
+
(0, _react2.render)(/*#__PURE__*/_react.default.createElement(_main.OuterApp, props));
|
|
36
37
|
expect(_react2.screen.getByText('App')).toBeInTheDocument();
|
|
37
38
|
window.__PRELOADED_STATE__ = oldPreloadedState;
|
|
38
39
|
});
|
|
@@ -45,9 +46,10 @@ describe('main', function () {
|
|
|
45
46
|
error: window.__ERROR__,
|
|
46
47
|
locals,
|
|
47
48
|
routes: (0, _routeComponent.getRoutes)(locals),
|
|
48
|
-
WrappedApp: (0, _routeComponent.routeComponent)(App, false, locals)
|
|
49
|
+
WrappedApp: (0, _routeComponent.routeComponent)(App, false, locals),
|
|
50
|
+
extensions: []
|
|
49
51
|
};
|
|
50
|
-
(0, _react2.render)(
|
|
52
|
+
(0, _react2.render)(/*#__PURE__*/_react.default.createElement(_main.OuterApp, props));
|
|
51
53
|
expect(_react2.screen.getByText('Error Status: 404')).toBeInTheDocument();
|
|
52
54
|
window.__ERROR__ = oldWindowError;
|
|
53
55
|
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const ALLOWLISTED_INLINE_SCRIPTS: any[];
|
|
2
|
+
export function getLocationSearch(req: any, opts?: {}): string;
|
|
3
|
+
export function render(req: any, res: any, next: any): Promise<any>;
|
|
4
|
+
export default serverRenderer;
|
|
5
|
+
declare function serverRenderer({ clientStats, serverStats }: {
|
|
6
|
+
clientStats: any;
|
|
7
|
+
serverStats: any;
|
|
8
|
+
}): (req: any, res: any, next: any) => Promise<any>;
|
|
9
|
+
//# sourceMappingURL=react-rendering.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-rendering.d.ts","sourceRoot":"","sources":["../../../src/ssr/server/react-rendering.js"],"names":[],"mappings":"AAyDA,+CAA4C;AAyBrC,+DA4BN;AAYM,oEA0IN;;AAiKD;;;oDAIK"}
|
|
@@ -16,10 +16,11 @@ var _sprite = _interopRequireDefault(require("svg-sprite-loader/runtime/sprite.b
|
|
|
16
16
|
var _ssrServer = require("@salesforce/pwa-kit-runtime/utils/ssr-server");
|
|
17
17
|
var _ssrShared = require("@salesforce/pwa-kit-runtime/utils/ssr-shared");
|
|
18
18
|
var _ssrConfig = require("@salesforce/pwa-kit-runtime/utils/ssr-config");
|
|
19
|
+
var _react2 = require("@salesforce/pwa-kit-extension-sdk/react");
|
|
19
20
|
var _utils = require("../universal/utils");
|
|
20
21
|
var _contexts = require("../universal/contexts");
|
|
21
|
-
var _document = _interopRequireDefault(require("../universal/components/_document"));
|
|
22
22
|
var _app = _interopRequireDefault(require("../universal/components/_app"));
|
|
23
|
+
var _document = _interopRequireDefault(require("../universal/components/_document"));
|
|
23
24
|
var _throw2 = _interopRequireDefault(require("../universal/components/throw-404"));
|
|
24
25
|
var _compatibility = require("../universal/compatibility");
|
|
25
26
|
var _switch = _interopRequireDefault(require("../universal/components/switch"));
|
|
@@ -86,7 +87,7 @@ const getLocationSearch = (req, opts = {}) => {
|
|
|
86
87
|
const {
|
|
87
88
|
interpretPlusSignAsSpace = false
|
|
88
89
|
} = opts;
|
|
89
|
-
const [
|
|
90
|
+
const [, search] = req.originalUrl.split('?');
|
|
90
91
|
const params = new URLSearchParams(search);
|
|
91
92
|
const newParams = new URLSearchParams();
|
|
92
93
|
const orderedKeys = [...new Set(params.keys())];
|
|
@@ -122,7 +123,7 @@ exports.getLocationSearch = getLocationSearch;
|
|
|
122
123
|
const render = exports.render = /*#__PURE__*/function () {
|
|
123
124
|
var _ref = _asyncToGenerator(function* (req, res, next) {
|
|
124
125
|
var _config$app, _config$app$url;
|
|
125
|
-
const includeServerTimingHeader =
|
|
126
|
+
const includeServerTimingHeader = '__server_timing' in req.query;
|
|
126
127
|
const shouldTrackPerformance = includeServerTimingHeader || process.env.SERVER_TIMING;
|
|
127
128
|
res.__performanceTimer = new _performance.default({
|
|
128
129
|
enabled: shouldTrackPerformance
|
|
@@ -132,8 +133,14 @@ const render = exports.render = /*#__PURE__*/function () {
|
|
|
132
133
|
// Get the application config which should have been stored at this point.
|
|
133
134
|
const config = (0, _ssrConfig.getConfig)();
|
|
134
135
|
AppConfig.restore(res.locals);
|
|
135
|
-
|
|
136
|
-
|
|
136
|
+
|
|
137
|
+
// Use locals to thread the application extensions through the rendering pipeline.
|
|
138
|
+
const applicationExtensions = yield (0, _react2.getApplicationExtensions)();
|
|
139
|
+
const WrappedApp = (0, _react2.withApplicationExtensions)((0, _routeComponent.routeComponent)(_app.default, false, res.locals), {
|
|
140
|
+
applicationExtensions,
|
|
141
|
+
locals: res.locals
|
|
142
|
+
});
|
|
143
|
+
let routes = (0, _routeComponent.getRoutes)(res.locals);
|
|
137
144
|
const [pathname] = req.originalUrl.split('?');
|
|
138
145
|
const location = {
|
|
139
146
|
pathname,
|
|
@@ -143,6 +150,11 @@ const render = exports.render = /*#__PURE__*/function () {
|
|
|
143
150
|
};
|
|
144
151
|
|
|
145
152
|
// Step 1 - Find the match.
|
|
153
|
+
|
|
154
|
+
// Call `beforeRouteMatch` application extension hook.
|
|
155
|
+
applicationExtensions.forEach(applicationExtension => {
|
|
156
|
+
routes = applicationExtension.beforeRouteMatch(routes);
|
|
157
|
+
});
|
|
146
158
|
res.__performanceTimer.mark(_performance.PERFORMANCE_MARKS.routeMatching, 'start');
|
|
147
159
|
let route;
|
|
148
160
|
let match;
|
|
@@ -315,7 +327,7 @@ const renderApp = args => {
|
|
|
315
327
|
|
|
316
328
|
try {
|
|
317
329
|
routerContext = {};
|
|
318
|
-
appHtml = renderToString(
|
|
330
|
+
appHtml = renderToString(/*#__PURE__*/_react.default.cloneElement(appJSX, {
|
|
319
331
|
routerContext
|
|
320
332
|
}), extractor);
|
|
321
333
|
} catch (e) {
|
|
@@ -323,7 +335,7 @@ const renderApp = args => {
|
|
|
323
335
|
// to the AppErrorBoundary component, and renders the error page.
|
|
324
336
|
routerContext = {};
|
|
325
337
|
renderError = logAndFormatError(e);
|
|
326
|
-
appHtml = renderToString(
|
|
338
|
+
appHtml = renderToString(/*#__PURE__*/_react.default.cloneElement(appJSX, {
|
|
327
339
|
routerContext,
|
|
328
340
|
error: renderError
|
|
329
341
|
}), extractor);
|
|
@@ -384,7 +396,7 @@ const renderApp = args => {
|
|
|
384
396
|
}
|
|
385
397
|
})];
|
|
386
398
|
const helmetHeadTags = VALID_TAG_NAMES.map(tag => helmet[tag] && helmet[tag].toComponent()).filter(tag => tag);
|
|
387
|
-
const html = _server.default.renderToString(
|
|
399
|
+
const html = _server.default.renderToString(/*#__PURE__*/_react.default.createElement(_document.default, {
|
|
388
400
|
head: [...helmetHeadTags],
|
|
389
401
|
html: appHtml,
|
|
390
402
|
afterBodyStart: svgs,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compatibility.d.ts","sourceRoot":"","sources":["../../../src/ssr/universal/compatibility.js"],"names":[],"mappings":"AAiBO,iDAKN"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export default App;
|
|
2
|
+
/**
|
|
3
|
+
* @module progressive-web-sdk/ssr/universal/components/_app
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* The PWAApp is a special component that will be overridden in your project. Its
|
|
7
|
+
* main purpose is to provide the layout for your application as well as set up any
|
|
8
|
+
* global actions and data fetching via the `getProps` method. Typically this is
|
|
9
|
+
* where you will set up components like your application header, footer and
|
|
10
|
+
* navigation. The contents of this component are project specific, but the rule
|
|
11
|
+
* of thumb is that anything outside of your pages will be added here.
|
|
12
|
+
*/
|
|
13
|
+
declare function App(props: any): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
declare namespace App {
|
|
15
|
+
namespace propTypes {
|
|
16
|
+
const children: PropTypes.Validator<PropTypes.ReactElementLike>;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
import PropTypes from "prop-types";
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/ssr/universal/components/_app/index.jsx"],"names":[],"mappings":";AASA;;GAEG;AAEH;;;;;;;GAOG;AACH,0EAA2D"}
|
|
@@ -14,7 +14,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
14
14
|
describe('App', () => {
|
|
15
15
|
test('Renders correctly', () => {
|
|
16
16
|
const body = /*#__PURE__*/_react.default.createElement("p", null, "Hello world");
|
|
17
|
-
(0, _react2.render)(
|
|
17
|
+
(0, _react2.render)(/*#__PURE__*/_react.default.createElement(_index.default, null, body));
|
|
18
18
|
expect(_react2.screen.getByText(/hello world/i)).toBeInTheDocument();
|
|
19
19
|
});
|
|
20
20
|
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export default AppConfig;
|
|
2
|
+
/**
|
|
3
|
+
* This is a special component that can be overridden in a project. It supports
|
|
4
|
+
* two things:
|
|
5
|
+
*
|
|
6
|
+
* 1) Working with state management libraries such as Redux that need to set
|
|
7
|
+
* up <Provider> instances at the root of an application.
|
|
8
|
+
*
|
|
9
|
+
* 2) Injecting properties (such as Redux stores, API clients) into getProps()
|
|
10
|
+
* methods across an application. We can't use React's context to do this
|
|
11
|
+
* because getProps() and co. need to be static methods.
|
|
12
|
+
*/
|
|
13
|
+
declare class AppConfig extends React.Component<any, any, any> {
|
|
14
|
+
/**
|
|
15
|
+
* Restore a state management backend from frozen state that was embedded
|
|
16
|
+
* into the page HTML.
|
|
17
|
+
*
|
|
18
|
+
* You can also use this to initialize a state-management library, and should
|
|
19
|
+
* save the instance onto `locals`.
|
|
20
|
+
*
|
|
21
|
+
* @param locals - res.locals on the server, an empty object as a substitute on
|
|
22
|
+
* the client.
|
|
23
|
+
* @param frozen - the application state, restored from JSON in the HTML.
|
|
24
|
+
*/
|
|
25
|
+
static restore(locals: any, frozen?: {}): void;
|
|
26
|
+
/**
|
|
27
|
+
* Freeze a state management backend for embedding into the page HTML.
|
|
28
|
+
*
|
|
29
|
+
* @param locals - res.locals on the server, an empty object as a substitute on
|
|
30
|
+
* the client.
|
|
31
|
+
* @return {Object} - the application state as an object, which will be
|
|
32
|
+
* serialized into JSON and embedded in the page HTML.
|
|
33
|
+
*/
|
|
34
|
+
static freeze(locals: any): Object;
|
|
35
|
+
/**
|
|
36
|
+
* Return any extra arguments to be injected into `getProps` methods across
|
|
37
|
+
* the entire app, such as a Redux store.
|
|
38
|
+
*
|
|
39
|
+
* @param locals - res.locals on the server, an empty object as a substitute on
|
|
40
|
+
* the client.
|
|
41
|
+
* @return {Object}
|
|
42
|
+
*/
|
|
43
|
+
static extraGetPropsArgs(locals: any): Object;
|
|
44
|
+
constructor(props: any);
|
|
45
|
+
constructor(props: any, context: any);
|
|
46
|
+
/**
|
|
47
|
+
* This class is a React Component in order to provide this hook, which lets
|
|
48
|
+
* you set up context Providers for a state-management library such as Redux.
|
|
49
|
+
*/
|
|
50
|
+
render(): import("react/jsx-runtime").JSX.Element;
|
|
51
|
+
}
|
|
52
|
+
declare namespace AppConfig {
|
|
53
|
+
namespace propTypes {
|
|
54
|
+
const children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
55
|
+
const locals: PropTypes.Requireable<object>;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
import React from "react";
|
|
59
|
+
import PropTypes from "prop-types";
|
|
60
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/ssr/universal/components/_app-config/index.jsx"],"names":[],"mappings":";AAcA;;;;;;;;;;GAUG;AACH;IACI;;;;;;;;;;OAUG;IAEH,+CAEC;IAED;;;;;;;OAOG;IAEH,4BAJY,MAAM,CAMjB;IAED;;;;;;;OAOG;IAEH,uCAHY,MAAM,CAKjB;IAiBi88B,wBAAgC;IAAA,sCAAmL;IAfrp9B;;;OAGG;IACH,kDAEC;CACJ"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export default Document;
|
|
2
|
+
/**
|
|
3
|
+
* The Document is a special component that can be overridden in a project, it
|
|
4
|
+
* provides the default document foundation for your PWA. This includes
|
|
5
|
+
* defaults for lang, charset, viewport, theme-color, script locations, etc.
|
|
6
|
+
* We do not recommend overriding this component, but if you do require fine grained control of
|
|
7
|
+
* your application we recommend using this implementation as a starting point to ensure
|
|
8
|
+
* the correct functionality of your PWA.
|
|
9
|
+
*
|
|
10
|
+
* The properties for this component will be set in the server-side rendering pipeline.
|
|
11
|
+
* Failure to use all these properties will most likely result in a non-functioning
|
|
12
|
+
* PWA.
|
|
13
|
+
*
|
|
14
|
+
* @param {Array.<Object>} props.beforeBodyEnd - The renderable elements to be placed directly before
|
|
15
|
+
* the end of the body tag.
|
|
16
|
+
* @param {object} [props.bodyAttributes] - The attributes to be applied to the documents body tag.
|
|
17
|
+
* <br/>
|
|
18
|
+
* <br/>
|
|
19
|
+
* <i>These are set by using `react-helmet`. Please refer to their {@link https://github.com/nfl/react-helmet/tree/5.2.0#readme|docs}
|
|
20
|
+
* for its usage.</i>
|
|
21
|
+
* @param {Array.<Object>} props.head - The elements to be placed inside the documents head tag.
|
|
22
|
+
* @param {string} [props.html] - The HTML to be rendered in your documents html tag.
|
|
23
|
+
* @param {object} [props.htmlAttributes] - The attributes to be applied to the documents html tag.
|
|
24
|
+
* <br/>
|
|
25
|
+
* <br/>
|
|
26
|
+
* <i>These are set by using `react-helmet`. Please refer to their {@link https://github.com/nfl/react-helmet/tree/5.2.0#readme|docs}
|
|
27
|
+
* for its usage.</i>
|
|
28
|
+
*/
|
|
29
|
+
declare function Document(props: any): import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
declare namespace Document {
|
|
31
|
+
namespace propTypes {
|
|
32
|
+
const afterBodyStart: PropTypes.Validator<PropTypes.ReactNodeLike[]>;
|
|
33
|
+
const beforeBodyEnd: PropTypes.Validator<PropTypes.ReactNodeLike[]>;
|
|
34
|
+
const head: PropTypes.Validator<PropTypes.ReactNodeLike[]>;
|
|
35
|
+
const html: PropTypes.Validator<string>;
|
|
36
|
+
const htmlAttributes: PropTypes.Requireable<object>;
|
|
37
|
+
const bodyAttributes: PropTypes.Requireable<object>;
|
|
38
|
+
}
|
|
39
|
+
namespace defaultProps {
|
|
40
|
+
const afterBodyStart_1: never[];
|
|
41
|
+
export { afterBodyStart_1 as afterBodyStart };
|
|
42
|
+
const beforeBodyEnd_1: never[];
|
|
43
|
+
export { beforeBodyEnd_1 as beforeBodyEnd };
|
|
44
|
+
const head_1: never[];
|
|
45
|
+
export { head_1 as head };
|
|
46
|
+
const html_1: string;
|
|
47
|
+
export { html_1 as html };
|
|
48
|
+
const htmlAttributes_1: {};
|
|
49
|
+
export { htmlAttributes_1 as htmlAttributes };
|
|
50
|
+
const bodyAttributes_1: {};
|
|
51
|
+
export { bodyAttributes_1 as bodyAttributes };
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
import PropTypes from "prop-types";
|
|
55
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/ssr/universal/components/_document/index.jsx"],"names":[],"mappings":";AAcA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,+EAwBC"}
|
|
@@ -32,7 +32,7 @@ describe('Document', () => {
|
|
|
32
32
|
const htmlAttributes = {
|
|
33
33
|
lang: 'en'
|
|
34
34
|
};
|
|
35
|
-
(0, _react2.render)(
|
|
35
|
+
(0, _react2.render)(/*#__PURE__*/_react.default.createElement(_index.default, {
|
|
36
36
|
head: [style],
|
|
37
37
|
html: html,
|
|
38
38
|
afterBodyStart: [sprite],
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export default Error;
|
|
2
|
+
/**
|
|
3
|
+
* This is a special component that can be overridden in a project. We recommend
|
|
4
|
+
* doing this in your project in order to cutomize its behaviour. You can accomplish
|
|
5
|
+
* things such as, making the error page brand specific, redirecting when errors
|
|
6
|
+
* occur, or adding reporting.
|
|
7
|
+
*
|
|
8
|
+
* The default Error component provides a basic layout for displaying errors
|
|
9
|
+
* that have occured during server-side rendering or client-side execution.
|
|
10
|
+
*
|
|
11
|
+
* @param {string} props.message - The errors message.
|
|
12
|
+
* @param {string} props.stack - The errors stack trace.
|
|
13
|
+
* <br/>
|
|
14
|
+
* <br/>
|
|
15
|
+
* <i>This property is only defined in non-production environments.</i>
|
|
16
|
+
* @param {number} props.status - The errors HTTP status code.
|
|
17
|
+
* <br/>
|
|
18
|
+
* <br/>
|
|
19
|
+
* <i>This property is typically used to distinguish 404 errors from other types.</i>
|
|
20
|
+
* @param {string} props.correlationId
|
|
21
|
+
*/
|
|
22
|
+
declare function Error({ message, stack, status, correlationId }: string): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
declare namespace Error {
|
|
24
|
+
namespace propTypes {
|
|
25
|
+
const message: PropTypes.Validator<string>;
|
|
26
|
+
const status: PropTypes.Validator<number>;
|
|
27
|
+
const stack: PropTypes.Requireable<string>;
|
|
28
|
+
const correlationId: PropTypes.Requireable<string>;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
import PropTypes from "prop-types";
|
|
32
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/ssr/universal/components/_error/index.jsx"],"names":[],"mappings":";AAcA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,kEAXW,MAAM,2CAoBhB"}
|
|
@@ -16,7 +16,7 @@ describe('Error Page', () => {
|
|
|
16
16
|
const status = 500;
|
|
17
17
|
const message = 'Error message';
|
|
18
18
|
test('Renders correctly', () => {
|
|
19
|
-
(0, _react2.render)(
|
|
19
|
+
(0, _react2.render)(/*#__PURE__*/_react.default.createElement(_index.default, {
|
|
20
20
|
message: message,
|
|
21
21
|
stack: stack,
|
|
22
22
|
status: status
|