@zengenti/contensis-react-base 4.0.0-beta.2 → 4.0.0-beta.20
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/LICENSE +7 -0
- package/README.md +24 -478
- package/cjs/{App-b56aca04.js → App-C_1U2j24.js} +218 -236
- package/cjs/App-C_1U2j24.js.map +1 -0
- package/cjs/{ChangePassword.container-ae35785e.js → ChangePassword.container-H4i1yRi6.js} +240 -315
- package/cjs/ChangePassword.container-H4i1yRi6.js.map +1 -0
- package/cjs/{ContensisDeliveryApi-4fcf049d.js → ContensisDeliveryApi-lcZ45Kxx.js} +125 -118
- package/cjs/ContensisDeliveryApi-lcZ45Kxx.js.map +1 -0
- package/cjs/{CookieConstants-000427db.js → CookieConstants-DfPiWCRZ.js} +3 -1
- package/cjs/CookieConstants-DfPiWCRZ.js.map +1 -0
- package/cjs/CookieHelper.class-Det3qfdU.js +462 -0
- package/cjs/CookieHelper.class-Det3qfdU.js.map +1 -0
- package/cjs/{RouteLoader-c06dccd5.js → RouteLoader-CAkG-Y5y.js} +62 -74
- package/cjs/RouteLoader-CAkG-Y5y.js.map +1 -0
- package/cjs/SSRContext-ciyKagks.js +71 -0
- package/cjs/SSRContext-ciyKagks.js.map +1 -0
- package/cjs/ToJs-BsWqWjdm.js +23 -0
- package/cjs/ToJs-BsWqWjdm.js.map +1 -0
- package/cjs/VersionInfo-D0mF1vkY.js +204 -0
- package/cjs/VersionInfo-D0mF1vkY.js.map +1 -0
- package/cjs/{_commonjsHelpers-b3309d7b.js → _commonjsHelpers-BJu3ubxk.js} +1 -1
- package/cjs/_commonjsHelpers-BJu3ubxk.js.map +1 -0
- package/cjs/client.js +47 -71
- package/cjs/client.js.map +1 -1
- package/cjs/contensis-react-base.js +645 -3303
- package/cjs/contensis-react-base.js.map +1 -1
- package/cjs/{fromJSLeaveImmer-e74c673c.js → fromJSLeaveImmer-Blvlk4t2.js} +3 -7
- package/{esm/fromJSLeaveImmer-0114ffcf.js.map → cjs/fromJSLeaveImmer-Blvlk4t2.js.map} +1 -1
- package/cjs/{ToJs-a8d8f3f0.js → matchGroups-CNt2aNoC.js} +22 -96
- package/cjs/matchGroups-CNt2aNoC.js.map +1 -0
- package/cjs/redux.js +20 -20
- package/cjs/redux.js.map +1 -1
- package/cjs/routing.js +19 -7
- package/cjs/routing.js.map +1 -1
- package/cjs/sagas-CMBI1syl.js +5835 -0
- package/cjs/sagas-CMBI1syl.js.map +1 -0
- package/cjs/search.js +119 -321
- package/cjs/search.js.map +1 -1
- package/cjs/selectors-Bp_TrwG5.js +468 -0
- package/cjs/selectors-Bp_TrwG5.js.map +1 -0
- package/cjs/{version-34d91f68.js → store-CO5xslDu.js} +44 -114
- package/cjs/store-CO5xslDu.js.map +1 -0
- package/cjs/user.js +28 -33
- package/cjs/user.js.map +1 -1
- package/cjs/util-CTvFvplw.js +148 -0
- package/cjs/util-CTvFvplw.js.map +1 -0
- package/cjs/util.js +87 -215
- package/cjs/util.js.map +1 -1
- package/cjs/version-BolvQdgT.js +20 -0
- package/cjs/version-BolvQdgT.js.map +1 -0
- package/cjs/{version-a410c88e.js → version-DabwEeLw.js} +19 -22
- package/{esm/version-9f29becb.js.map → cjs/version-DabwEeLw.js.map} +1 -1
- package/esm/{App-83107d7e.js → App-DdEKwCTJ.js} +178 -196
- package/esm/App-DdEKwCTJ.js.map +1 -0
- package/esm/{ChangePassword.container-76fd5e9b.js → ChangePassword.container-BzycNMRX.js} +193 -250
- package/esm/ChangePassword.container-BzycNMRX.js.map +1 -0
- package/esm/{ContensisDeliveryApi-fe57a037.js → ContensisDeliveryApi-BgfEEyIk.js} +124 -119
- package/esm/ContensisDeliveryApi-BgfEEyIk.js.map +1 -0
- package/esm/{CookieConstants-3d3b6531.js → CookieConstants-DEmbwzYr.js} +3 -2
- package/esm/CookieConstants-DEmbwzYr.js.map +1 -0
- package/esm/CookieHelper.class-C6rTRl_1.js +459 -0
- package/esm/CookieHelper.class-C6rTRl_1.js.map +1 -0
- package/esm/{RouteLoader-29fd689a.js → RouteLoader-Bk6e6UV-.js} +46 -58
- package/esm/RouteLoader-Bk6e6UV-.js.map +1 -0
- package/esm/SSRContext-CXRqYy6B.js +63 -0
- package/esm/SSRContext-CXRqYy6B.js.map +1 -0
- package/esm/ToJs-BnRRHk6f.js +17 -0
- package/esm/ToJs-BnRRHk6f.js.map +1 -0
- package/esm/VersionInfo-j6NR0QJR.js +193 -0
- package/esm/VersionInfo-j6NR0QJR.js.map +1 -0
- package/esm/{_commonjsHelpers-1789f0cf.js → _commonjsHelpers-BFTU3MAI.js} +1 -1
- package/esm/_commonjsHelpers-BFTU3MAI.js.map +1 -0
- package/esm/client.js +39 -62
- package/esm/client.js.map +1 -1
- package/esm/contensis-react-base.js +616 -3272
- package/esm/contensis-react-base.js.map +1 -1
- package/esm/{fromJSLeaveImmer-0114ffcf.js → fromJSLeaveImmer-C_YACmOf.js} +2 -6
- package/{cjs/fromJSLeaveImmer-e74c673c.js.map → esm/fromJSLeaveImmer-C_YACmOf.js.map} +1 -1
- package/esm/{ToJs-df57f31d.js → matchGroups-Bq8QnqFx.js} +23 -91
- package/esm/matchGroups-Bq8QnqFx.js.map +1 -0
- package/esm/redux.js +11 -9
- package/esm/redux.js.map +1 -1
- package/esm/routing.js +18 -5
- package/esm/routing.js.map +1 -1
- package/esm/sagas-BFQ4tBq_.js +5743 -0
- package/esm/sagas-BFQ4tBq_.js.map +1 -0
- package/esm/search.js +124 -323
- package/esm/search.js.map +1 -1
- package/esm/selectors-CNC7sDxg.js +404 -0
- package/esm/selectors-CNC7sDxg.js.map +1 -0
- package/esm/{version-3d9911e2.js → store-CtDx5MLq.js} +38 -85
- package/esm/store-CtDx5MLq.js.map +1 -0
- package/esm/user.js +10 -13
- package/esm/user.js.map +1 -1
- package/esm/util-BC8LWRKL.js +136 -0
- package/esm/util-BC8LWRKL.js.map +1 -0
- package/esm/util.js +69 -201
- package/esm/util.js.map +1 -1
- package/esm/version-CaL4czqJ.js +15 -0
- package/esm/version-CaL4czqJ.js.map +1 -0
- package/esm/{version-9f29becb.js → version-CfABeHJA.js} +6 -9
- package/{cjs/version-a410c88e.js.map → esm/version-CfABeHJA.js.map} +1 -1
- package/models/app/App.d.ts +1 -1
- package/models/app/pages/VersionInfo/components/VersionInfo.d.ts +4 -1
- package/models/app/pages/VersionInfo/components/VersionInfo.styled.d.ts +1 -1
- package/models/client/client.d.ts +1 -1
- package/models/index.d.ts +1 -2
- package/models/models/AppRouteProps.d.ts +11 -0
- package/models/{redux/appstate.d.ts → models/AppState.d.ts} +3 -3
- package/models/models/ContentTypeMapping.d.ts +89 -0
- package/models/models/EntryMapper.d.ts +3 -0
- package/models/models/GetRouteActionArgs.d.ts +15 -0
- package/models/models/MatchedRoute.d.ts +8 -0
- package/models/models/ReduxInjector.d.ts +5 -0
- package/models/models/RequireLogin.d.ts +6 -0
- package/models/models/RouteComponent.d.ts +3 -0
- package/models/models/RouteComponentProps.d.ts +9 -0
- package/models/models/RouteLoaderProps.d.ts +9 -0
- package/models/models/RouteNode.d.ts +5 -0
- package/models/models/SSRContext.d.ts +32 -0
- package/models/models/StaticRoute.d.ts +61 -0
- package/models/models/WithEvents.d.ts +58 -0
- package/models/models/config/AppConfig.d.ts +13 -0
- package/models/{config.d.ts → models/config/ServerConfig.d.ts} +4 -12
- package/models/models/config/StateType.d.ts +2 -0
- package/models/models/config/index.d.ts +3 -0
- package/models/models/index.d.ts +16 -0
- package/models/redux/actions/index.d.ts +2 -2
- package/models/redux/sagas/navigation.d.ts +1 -3
- package/models/redux/selectors/index.d.ts +2 -2
- package/models/redux/store/injectors.d.ts +16 -4
- package/models/redux/store/store.d.ts +10 -4
- package/models/redux/types/index.d.ts +2 -2
- package/models/redux/types/navigation.d.ts +3 -3
- package/models/redux/types/version.d.ts +2 -2
- package/models/redux/util.d.ts +1 -1
- package/models/routing/components/Redirect.d.ts +1 -1
- package/models/routing/components/RouteLoader.d.ts +3 -3
- package/models/routing/components/StaticRouteLoader.d.ts +1 -1
- package/models/routing/components/Status.d.ts +1 -1
- package/models/routing/httpContext.d.ts +0 -1
- package/models/routing/index.d.ts +1 -0
- package/models/routing/redux/actions.d.ts +3 -4
- package/models/routing/redux/selectors.d.ts +44 -4
- package/models/routing/redux/types.d.ts +11 -11
- package/models/routing/util/expressions.d.ts +1 -1
- package/models/routing/util/find-contenttype-mapping.d.ts +1 -1
- package/models/routing/util/queries.d.ts +2 -2
- package/models/search/containers/withListing.d.ts +4 -1
- package/models/search/containers/withSearch.d.ts +4 -1
- package/models/search/models/Queries.d.ts +6 -6
- package/models/search/models/Search.d.ts +13 -4
- package/models/search/models/SearchActions.d.ts +29 -12
- package/models/search/models/SearchProps.d.ts +4 -10
- package/models/search/models/SearchState.d.ts +8 -2
- package/models/search/redux/getIn.d.ts +2 -2
- package/models/search/redux/reducers.d.ts +5 -261
- package/models/search/redux/sagas.d.ts +13 -14
- package/models/search/redux/schema.d.ts +2 -2
- package/models/search/redux/selectors.d.ts +10 -10
- package/models/search/redux/util.d.ts +9 -1
- package/models/search/search/ContensisDeliveryApi.d.ts +6 -26
- package/models/search/search/expressions.d.ts +3 -3
- package/models/search/search/util.d.ts +25 -8
- package/models/search/transformations/searchresult-to-state.mapper.d.ts +1 -2
- package/models/server/features/caching/cacheDuration.schema.d.ts +1 -0
- package/models/server/features/linkdepth-api/search.d.ts +2 -2
- package/models/server/features/response-handler/render-stream.d.ts +25 -0
- package/models/server/features/static-assets/index.d.ts +3 -3
- package/models/server/internalServer.d.ts +2 -3
- package/models/server/util/bundles.d.ts +10 -10
- package/models/server/util/headers.d.ts +1 -1
- package/models/server/util/html.d.ts +23 -0
- package/models/server/util/jsx.d.ts +42 -0
- package/models/server/webApp.d.ts +1 -1
- package/models/user/components/Login.d.ts +1 -1
- package/models/user/components/LoginForm.d.ts +6 -6
- package/models/user/components/LogoutForm.d.ts +4 -4
- package/models/user/components.styled/Login.styled.d.ts +1 -1
- package/models/user/components.styled/LoginForm.styled.d.ts +1 -1
- package/models/user/hocs/withLogin.d.ts +4 -4
- package/models/user/hocs/withRegistration.d.ts +6 -3
- package/models/user/hooks/useLogin.d.ts +4 -4
- package/models/user/redux/actions.d.ts +7 -6
- package/models/user/redux/sagas/index.d.ts +1 -1
- package/models/user/redux/sagas/login.d.ts +5 -17
- package/models/user/redux/selectors.d.ts +1 -2
- package/models/user/redux/types.d.ts +21 -21
- package/models/user/state.d.ts +12 -0
- package/models/user/transformations/mapClientCredentials.d.ts +3 -1
- package/models/user/util/ContensisManagementApi.d.ts +10 -9
- package/models/user/util/CookieConstants.d.ts +1 -0
- package/models/user/util/CookieHelper.class.d.ts +8 -4
- package/models/user/util/LoginHelper.class.d.ts +25 -37
- package/models/user/util/OidcUserManager.d.ts +1 -1
- package/models/user/util/matchGroups.d.ts +1 -1
- package/models/util/CachedDeliveryApi.d.ts +19 -12
- package/models/util/ContensisDeliveryApi.d.ts +11 -9
- package/models/util/NoSSR.d.ts +6 -0
- package/models/util/SSRContext.d.ts +24 -0
- package/models/util/donotuse_useHistory.d.ts +6 -0
- package/models/util/index.d.ts +5 -1
- package/models/util/json-mapper.d.ts +4 -5
- package/models/util/useIsClient.d.ts +6 -0
- package/package.json +75 -97
- package/cjs/App-b56aca04.js.map +0 -1
- package/cjs/ChangePassword.container-ae35785e.js.map +0 -1
- package/cjs/ContensisDeliveryApi-4fcf049d.js.map +0 -1
- package/cjs/CookieConstants-000427db.js.map +0 -1
- package/cjs/RouteLoader-c06dccd5.js.map +0 -1
- package/cjs/ToJs-a8d8f3f0.js.map +0 -1
- package/cjs/_commonjsHelpers-b3309d7b.js.map +0 -1
- package/cjs/forms.js +0 -5998
- package/cjs/forms.js.map +0 -1
- package/cjs/reducers-73a03ef4.js +0 -257
- package/cjs/reducers-73a03ef4.js.map +0 -1
- package/cjs/sagas-570f23ba.js +0 -2175
- package/cjs/sagas-570f23ba.js.map +0 -1
- package/cjs/selectors-14caa813.js +0 -228
- package/cjs/selectors-14caa813.js.map +0 -1
- package/cjs/urls-6fcaf4c6.js +0 -25
- package/cjs/urls-6fcaf4c6.js.map +0 -1
- package/cjs/version-34d91f68.js.map +0 -1
- package/esm/App-83107d7e.js.map +0 -1
- package/esm/ChangePassword.container-76fd5e9b.js.map +0 -1
- package/esm/ContensisDeliveryApi-fe57a037.js.map +0 -1
- package/esm/CookieConstants-3d3b6531.js.map +0 -1
- package/esm/RouteLoader-29fd689a.js.map +0 -1
- package/esm/ToJs-df57f31d.js.map +0 -1
- package/esm/_commonjsHelpers-1789f0cf.js.map +0 -1
- package/esm/forms.js +0 -5984
- package/esm/forms.js.map +0 -1
- package/esm/reducers-aa8cef1e.js +0 -234
- package/esm/reducers-aa8cef1e.js.map +0 -1
- package/esm/sagas-07e82e18.js +0 -2083
- package/esm/sagas-07e82e18.js.map +0 -1
- package/esm/selectors-691caf02.js +0 -186
- package/esm/selectors-691caf02.js.map +0 -1
- package/esm/urls-eac9a747.js +0 -22
- package/esm/urls-eac9a747.js.map +0 -1
- package/esm/version-3d9911e2.js.map +0 -1
- package/models/forms/index.d.ts +0 -1
- package/models/routing/routes.d.ts +0 -133
- package/models/search/search/ToJs.d.ts +0 -4
|
@@ -1,25 +1,21 @@
|
|
|
1
|
-
import React, { useContext, createContext,
|
|
2
|
-
import { useCookies } from 'react-cookie';
|
|
1
|
+
import React, { useContext, createContext, useCallback, useEffect, cloneElement } from 'react';
|
|
3
2
|
import { connect } from 'react-redux';
|
|
4
3
|
import { Navigate, useRoutes, useLocation, matchRoutes } from 'react-router-dom';
|
|
5
4
|
import { createSelector } from 'reselect';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const useHttpContext = () => {
|
|
11
|
-
return useContext(HttpContext);
|
|
12
|
-
};
|
|
5
|
+
import { f as selectRouteEntryContentTypeId, h as selectRouteEntry, j as selectRouteIsError, k as selectIsNotFound, l as selectRouteLoading, m as selectMappedEntry, n as selectCurrentProject, o as selectCurrentPath, p as selectRouteStatusCode, q as selectRouteErrorMessage, u as setNavigationPath } from './selectors-CNC7sDxg.js';
|
|
6
|
+
import { d as selectUserIsAuthenticated, k as selectUserGroups, m as matchUserGroup } from './matchGroups-Bq8QnqFx.js';
|
|
7
|
+
import { t as toJS } from './ToJs-BnRRHk6f.js';
|
|
8
|
+
import { a as useSSRContext } from './SSRContext-CXRqYy6B.js';
|
|
13
9
|
|
|
14
10
|
const mergeStaticRoutes = matchedStaticRoute => {
|
|
15
11
|
let finalRoute = {};
|
|
16
|
-
|
|
17
12
|
for (const [i, route] of matchedStaticRoute.entries()) {
|
|
18
|
-
const staticRouteCopy = {
|
|
13
|
+
const staticRouteCopy = {
|
|
14
|
+
...route.route
|
|
19
15
|
};
|
|
20
|
-
|
|
21
16
|
if (i === matchedStaticRoute.length - 1) {
|
|
22
|
-
finalRoute = {
|
|
17
|
+
finalRoute = {
|
|
18
|
+
...finalRoute,
|
|
23
19
|
...staticRouteCopy,
|
|
24
20
|
fullPath: `${finalRoute.fullPath || ''}${route.route.path ? route.route.path : ''}`
|
|
25
21
|
};
|
|
@@ -30,7 +26,8 @@ const mergeStaticRoutes = matchedStaticRoute => {
|
|
|
30
26
|
delete staticRouteCopy.path;
|
|
31
27
|
delete staticRouteCopy.component;
|
|
32
28
|
delete staticRouteCopy.element;
|
|
33
|
-
finalRoute = {
|
|
29
|
+
finalRoute = {
|
|
30
|
+
...finalRoute,
|
|
34
31
|
...staticRouteCopy,
|
|
35
32
|
fullPath: `${finalRoute.fullPath || ''}${route.route.path ? route.route.path.endsWith('/') ? route.route.path : route.route.path + '/' : ''}`
|
|
36
33
|
};
|
|
@@ -38,17 +35,20 @@ const mergeStaticRoutes = matchedStaticRoute => {
|
|
|
38
35
|
}
|
|
39
36
|
};
|
|
40
37
|
|
|
38
|
+
const HttpContext = /*#__PURE__*/createContext({});
|
|
39
|
+
const useHttpContext = () => {
|
|
40
|
+
return useContext(HttpContext);
|
|
41
|
+
};
|
|
42
|
+
|
|
41
43
|
const Redirect = ({
|
|
42
44
|
code,
|
|
43
45
|
to
|
|
44
46
|
}) => {
|
|
45
47
|
const httpContext = useHttpContext();
|
|
46
|
-
|
|
47
48
|
if (httpContext) {
|
|
48
49
|
httpContext.statusCode = code;
|
|
49
50
|
httpContext.url = to;
|
|
50
51
|
}
|
|
51
|
-
|
|
52
52
|
return /*#__PURE__*/React.createElement(Navigate, {
|
|
53
53
|
to: to
|
|
54
54
|
});
|
|
@@ -59,11 +59,9 @@ const Status = ({
|
|
|
59
59
|
children
|
|
60
60
|
}) => {
|
|
61
61
|
const httpContext = useHttpContext();
|
|
62
|
-
|
|
63
62
|
if (httpContext) {
|
|
64
63
|
httpContext.statusCode = code;
|
|
65
64
|
}
|
|
66
|
-
|
|
67
65
|
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
68
66
|
};
|
|
69
67
|
|
|
@@ -88,27 +86,21 @@ const StaticRouteLoader = ({
|
|
|
88
86
|
|
|
89
87
|
const replaceDoubleSlashRecursive = path => {
|
|
90
88
|
const nextPath = path.replace(/\/\//, '/');
|
|
91
|
-
|
|
92
89
|
if (nextPath.match(/\/\//)) {
|
|
93
90
|
return replaceDoubleSlashRecursive(nextPath);
|
|
94
91
|
}
|
|
95
|
-
|
|
96
92
|
return nextPath;
|
|
97
93
|
};
|
|
98
|
-
|
|
99
94
|
const getTrimmedPath = path => {
|
|
100
95
|
if (path !== '/') {
|
|
101
96
|
const nextPath = replaceDoubleSlashRecursive(path);
|
|
102
97
|
const lastChar = nextPath[nextPath.length - 1];
|
|
103
|
-
|
|
104
98
|
if (lastChar === '/') {
|
|
105
99
|
return nextPath.substring(0, nextPath.length - 1);
|
|
106
100
|
}
|
|
107
101
|
}
|
|
108
|
-
|
|
109
102
|
return path;
|
|
110
103
|
};
|
|
111
|
-
|
|
112
104
|
const processStaticRoutes = (staticRoutes, componentProps) => {
|
|
113
105
|
const {
|
|
114
106
|
projectId,
|
|
@@ -118,9 +110,9 @@ const processStaticRoutes = (staticRoutes, componentProps) => {
|
|
|
118
110
|
isLoggedIn
|
|
119
111
|
} = componentProps;
|
|
120
112
|
return staticRoutes.map(x => {
|
|
121
|
-
const route = {
|
|
113
|
+
const route = {
|
|
114
|
+
...x
|
|
122
115
|
};
|
|
123
|
-
|
|
124
116
|
if (route.component) {
|
|
125
117
|
route.element = /*#__PURE__*/React.createElement(route.component, {
|
|
126
118
|
projectId: projectId,
|
|
@@ -131,7 +123,6 @@ const processStaticRoutes = (staticRoutes, componentProps) => {
|
|
|
131
123
|
});
|
|
132
124
|
delete route.component;
|
|
133
125
|
}
|
|
134
|
-
|
|
135
126
|
if (route.element) {
|
|
136
127
|
route.element = /*#__PURE__*/cloneElement(route.element, {
|
|
137
128
|
projectId,
|
|
@@ -141,15 +132,12 @@ const processStaticRoutes = (staticRoutes, componentProps) => {
|
|
|
141
132
|
isLoggedIn
|
|
142
133
|
});
|
|
143
134
|
}
|
|
144
|
-
|
|
145
135
|
if (route.children) {
|
|
146
136
|
route.children = processStaticRoutes(route.children, componentProps);
|
|
147
137
|
}
|
|
148
|
-
|
|
149
138
|
return route;
|
|
150
139
|
});
|
|
151
140
|
};
|
|
152
|
-
|
|
153
141
|
const RouteLoader = ({
|
|
154
142
|
contentTypeId,
|
|
155
143
|
entry,
|
|
@@ -171,40 +159,43 @@ const RouteLoader = ({
|
|
|
171
159
|
trailingSlashRedirectCode = 302
|
|
172
160
|
}) => {
|
|
173
161
|
const location = useLocation();
|
|
174
|
-
const cookies = new CookieHelper(...useCookies()); // Always ensure paths are trimmed of trailing slashes so urls are always unique
|
|
175
162
|
|
|
176
|
-
|
|
163
|
+
// In SSR pass references to things in backing sagas
|
|
164
|
+
// we cannot access in a global scope
|
|
165
|
+
const ssrContext = useSSRContext();
|
|
177
166
|
|
|
167
|
+
// Always ensure paths are trimmed of trailing slashes so urls are always unique
|
|
168
|
+
const trimmedPath = getTrimmedPath(location.pathname);
|
|
169
|
+
|
|
170
|
+
// Convert any react-router-v5 style routes to react-router-v6 style routes.
|
|
178
171
|
const staticRoutes = processStaticRoutes(routes.StaticRoutes, {
|
|
179
172
|
projectId,
|
|
180
173
|
contentTypeId,
|
|
181
174
|
entry,
|
|
182
175
|
mappedEntry,
|
|
183
176
|
isLoggedIn
|
|
184
|
-
});
|
|
177
|
+
});
|
|
185
178
|
|
|
179
|
+
// Match any Static Routes a developer has defined
|
|
186
180
|
const matchedStaticRoute = matchRoutes(staticRoutes, location);
|
|
187
|
-
const isStaticRoute = matchedStaticRoute && matchedStaticRoute.length > 0;
|
|
181
|
+
const isStaticRoute = matchedStaticRoute && matchedStaticRoute.length > 0;
|
|
188
182
|
|
|
183
|
+
// Combine custom params for all static routes, with the furthest config taking precedence.
|
|
189
184
|
if (isStaticRoute) {
|
|
190
185
|
mergeStaticRoutes(matchedStaticRoute);
|
|
191
186
|
}
|
|
192
|
-
|
|
193
187
|
const staticRoute = isStaticRoute ? matchedStaticRoute.pop() || undefined : undefined;
|
|
194
188
|
const routeRequiresLogin = staticRoute ? staticRoute.route.requireLogin : undefined;
|
|
195
189
|
const setPath = useCallback(() => {
|
|
196
190
|
// Use serverPath to control the path we send to siteview node api to resolve a route
|
|
197
191
|
let serverPath = '';
|
|
198
|
-
|
|
199
192
|
if (staticRoute && staticRoute.pathname === staticRoute.pathnameBase) {
|
|
200
193
|
var _route$path, _route$fetchNode;
|
|
201
|
-
|
|
202
194
|
const {
|
|
203
195
|
route,
|
|
204
196
|
pathname,
|
|
205
197
|
params
|
|
206
198
|
} = staticRoute;
|
|
207
|
-
|
|
208
199
|
if ((_route$path = route.path) !== null && _route$path !== void 0 && _route$path.includes('*')) {
|
|
209
200
|
// Send the whole url to api if we have matched route containing wildcard
|
|
210
201
|
serverPath = pathname;
|
|
@@ -221,46 +212,47 @@ const RouteLoader = ({
|
|
|
221
212
|
}).replace(/\/$/, '');
|
|
222
213
|
} else {
|
|
223
214
|
var _route$fullPath;
|
|
224
|
-
|
|
225
215
|
// Send all non-parameterised url parts to api
|
|
226
216
|
serverPath = (_route$fullPath = route.fullPath) === null || _route$fullPath === void 0 ? void 0 : _route$fullPath.split('/').filter(p => !p.startsWith(':')).join('/');
|
|
227
217
|
}
|
|
228
218
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
}, [setNavigationPath,
|
|
232
|
-
|
|
219
|
+
setNavigationPath(serverPath || trimmedPath, location, staticRoute, withEvents, statePath, routes, ssrContext);
|
|
220
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
221
|
+
}, [setNavigationPath,
|
|
222
|
+
// staticRoute,
|
|
223
|
+
withEvents, location, routes,
|
|
224
|
+
// statePath,
|
|
233
225
|
trimmedPath]);
|
|
234
226
|
if (typeof window == 'undefined') setPath();
|
|
235
227
|
useEffect(() => {
|
|
236
228
|
setPath();
|
|
237
|
-
}, [location, setPath]);
|
|
229
|
+
}, [location, setPath]);
|
|
238
230
|
|
|
231
|
+
// Need to redirect when url endswith a /
|
|
239
232
|
if (location.pathname.length > trimmedPath.length) {
|
|
240
233
|
return /*#__PURE__*/React.createElement(Redirect, {
|
|
241
234
|
code: trailingSlashRedirectCode || 302,
|
|
242
235
|
to: `${trimmedPath}${location.search}${location.hash}`
|
|
243
236
|
});
|
|
244
|
-
}
|
|
245
|
-
|
|
237
|
+
}
|
|
246
238
|
|
|
239
|
+
// Render any Static Routes a developer has defined
|
|
247
240
|
if (isStaticRoute && !(!isLoggedIn && routeRequiresLogin)) {
|
|
248
241
|
if (matchUserGroup(userGroups, routeRequiresLogin)) return /*#__PURE__*/React.createElement(StaticRouteLoader, {
|
|
249
242
|
staticRoutes: staticRoutes
|
|
250
243
|
});
|
|
251
|
-
}
|
|
252
|
-
// is not a static route and is in a loading state
|
|
253
|
-
|
|
244
|
+
}
|
|
254
245
|
|
|
246
|
+
// Render a supplied Loading component if the route
|
|
247
|
+
// is not a static route and is in a loading state
|
|
255
248
|
if (isLoading && !isNotFound && loadingComponent) {
|
|
256
249
|
const LoadingComponent = loadingComponent;
|
|
257
250
|
return /*#__PURE__*/React.createElement(LoadingComponent, null);
|
|
258
|
-
}
|
|
259
|
-
|
|
251
|
+
}
|
|
260
252
|
|
|
253
|
+
// Match any defined Content Type Mappings
|
|
261
254
|
if (contentTypeId && !(!isLoggedIn && routeRequiresLogin)) {
|
|
262
255
|
const MatchedComponent = routes.ContentTypeMappings.find(item => item.contentTypeID === contentTypeId);
|
|
263
|
-
|
|
264
256
|
if (MatchedComponent && !(MatchedComponent.requireLogin && !isLoggedIn)) {
|
|
265
257
|
if (matchUserGroup(userGroups, MatchedComponent.requireLogin)) return /*#__PURE__*/React.createElement(MatchedComponent.component, {
|
|
266
258
|
projectId: projectId,
|
|
@@ -271,9 +263,7 @@ const RouteLoader = ({
|
|
|
271
263
|
});
|
|
272
264
|
}
|
|
273
265
|
}
|
|
274
|
-
|
|
275
266
|
const NotFoundComponent = notFoundComponent ? notFoundComponent : NotFound;
|
|
276
|
-
|
|
277
267
|
if (isNotFound || isError) {
|
|
278
268
|
console.info(`RouteLoader rendering NotFound component: statusCode ${statusCode}, isNotFound ${isNotFound}, isError ${isError}`);
|
|
279
269
|
return /*#__PURE__*/React.createElement(Status, {
|
|
@@ -283,10 +273,8 @@ const RouteLoader = ({
|
|
|
283
273
|
statusText: statusText
|
|
284
274
|
}));
|
|
285
275
|
}
|
|
286
|
-
|
|
287
276
|
return null;
|
|
288
277
|
};
|
|
289
|
-
|
|
290
278
|
const mapStateToPropsMemoized = createSelector(selectRouteEntryContentTypeId, selectRouteEntry, selectRouteIsError, selectIsNotFound, selectRouteLoading, selectUserIsAuthenticated, selectMappedEntry, selectCurrentProject, selectCurrentPath, selectRouteStatusCode, selectRouteErrorMessage, selectUserGroups, (contentTypeId, entry, isError, isNotFound, isLoading, isLoggedIn, mappedEntry, projectId, statePath, statusCode, statusText, userGroups) => ({
|
|
291
279
|
contentTypeId,
|
|
292
280
|
entry,
|
|
@@ -306,5 +294,5 @@ const mapDispatchToProps = {
|
|
|
306
294
|
};
|
|
307
295
|
var RouteLoader$1 = connect(mapStateToPropsMemoized, mapDispatchToProps)(toJS(RouteLoader));
|
|
308
296
|
|
|
309
|
-
export { HttpContext as H,
|
|
310
|
-
//# sourceMappingURL=RouteLoader-
|
|
297
|
+
export { HttpContext as H, Redirect as R, Status as S, RouteLoader$1 as a, mergeStaticRoutes as m, useHttpContext as u };
|
|
298
|
+
//# sourceMappingURL=RouteLoader-Bk6e6UV-.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RouteLoader-Bk6e6UV-.js","sources":["../src/util/mergeStaticRoutes.ts","../src/routing/httpContext.ts","../src/routing/components/Redirect.tsx","../src/routing/components/Status.tsx","../src/routing/components/NotFound.tsx","../src/routing/components/StaticRouteLoader.tsx","../src/routing/components/RouteLoader.tsx"],"sourcesContent":["import { StaticRoute } from '../';\n\nexport const mergeStaticRoutes = matchedStaticRoute => {\n let finalRoute: StaticRoute = {};\n for (const [i, route] of matchedStaticRoute.entries()) {\n const staticRouteCopy = { ...route.route };\n if (i === matchedStaticRoute.length - 1) {\n finalRoute = {\n ...finalRoute,\n ...staticRouteCopy,\n fullPath: `${finalRoute.fullPath || ''}${\n route.route.path ? route.route.path : ''\n }`,\n };\n matchedStaticRoute[i].route = finalRoute;\n } else {\n delete staticRouteCopy.children;\n delete staticRouteCopy.index;\n delete staticRouteCopy.path;\n delete staticRouteCopy.component;\n delete staticRouteCopy.element;\n finalRoute = {\n ...finalRoute,\n ...staticRouteCopy,\n fullPath: `${finalRoute.fullPath || ''}${\n route.route.path\n ? route.route.path.endsWith('/')\n ? route.route.path\n : route.route.path + '/'\n : ''\n }`,\n };\n }\n }\n};\n","import { createContext, useContext } from 'react';\n\nexport type HttpContextValues = {\n statusCode?: number;\n url?: string;\n};\n\nexport const HttpContext = createContext<HttpContextValues>({});\nexport const useHttpContext = () => {\n return useContext(HttpContext);\n};\n","import React, { PropsWithChildren } from 'react';\nimport { Navigate } from 'react-router-dom';\nimport { useHttpContext } from '../httpContext';\n\nexport const Redirect = ({\n code,\n to,\n}: PropsWithChildren<{ code: 301 | 302; to: string }>) => {\n const httpContext = useHttpContext();\n if (httpContext) {\n httpContext.statusCode = code;\n httpContext.url = to;\n }\n return <Navigate to={to} />;\n};\n","import React, { PropsWithChildren } from 'react';\nimport { useHttpContext } from '../httpContext';\n\nexport const Status = ({\n code,\n children,\n}: PropsWithChildren<{ code: number }>) => {\n const httpContext = useHttpContext();\n if (httpContext) {\n httpContext.statusCode = code;\n }\n return <>{children}</>;\n};\n","import React from 'react';\n\nconst NotFound = ({\n statusCode,\n statusText,\n}: {\n statusCode: number;\n statusText: string;\n}) => (\n <>\n <header>\n <h1>{statusCode || '404'} Page Not Found</h1>\n {statusText && (\n <h2\n style={{\n background: '#eee',\n color: '#666',\n fontSize: '100%',\n padding: '10px',\n }}\n >\n {statusText}\n </h2>\n )}\n </header>\n </>\n);\n\nexport default NotFound;\n","import React from 'react';\nimport { RouteObject, useRoutes } from 'react-router-dom';\nimport type { StaticRoute } from '~/models';\n\nexport interface StaticRouteLoaderProps {\n staticRoutes: StaticRoute[];\n}\n\nexport const StaticRouteLoader = ({ staticRoutes }: StaticRouteLoaderProps) => {\n const staticRouteElement = useRoutes(staticRoutes as RouteObject[]);\n return <>{staticRouteElement}</>;\n};\n","import React, { useEffect, useCallback, cloneElement } from 'react';\nimport { connect } from 'react-redux';\nimport { useLocation, matchRoutes, RouteObject } from 'react-router-dom';\n\nimport { createSelector } from 'reselect';\n\nimport NotFound from './NotFound';\nimport { Status } from './Status';\n\nimport {\n selectCurrentPath,\n selectCurrentProject,\n selectIsNotFound,\n selectMappedEntry,\n selectRouteEntry,\n selectRouteEntryContentTypeId,\n selectRouteErrorMessage,\n selectRouteIsError,\n selectRouteLoading,\n selectRouteStatusCode,\n} from '../redux/selectors';\nimport { setNavigationPath } from '../redux/actions';\n\nimport {\n selectUserGroups,\n selectUserIsAuthenticated,\n} from '~/user/redux/selectors';\nimport { matchUserGroup } from '~/user/util/matchGroups';\nimport { toJS } from '~/util/ToJs';\nimport { useSSRContext } from '~/util/SSRContext';\n\nimport { mergeStaticRoutes } from '~/util/mergeStaticRoutes';\nimport { Entry } from 'contensis-delivery-api/lib/models';\nimport { AppRootProps, MatchedRoute, RouteComponentProps, RouteLoaderProps, StaticRoute } from '~/models';\nimport { StaticRouteLoader } from './StaticRouteLoader';\nimport { Redirect } from './Redirect';\n\nconst replaceDoubleSlashRecursive = (path: string) => {\n const nextPath = path.replace(/\\/\\//, '/');\n\n if (nextPath.match(/\\/\\//)) {\n return replaceDoubleSlashRecursive(nextPath);\n }\n\n return nextPath;\n};\n\nconst getTrimmedPath = path => {\n if (path !== '/') {\n const nextPath = replaceDoubleSlashRecursive(path);\n const lastChar = nextPath[nextPath.length - 1];\n if (lastChar === '/') {\n return nextPath.substring(0, nextPath.length - 1);\n }\n }\n return path;\n};\n\nconst processStaticRoutes = (\n staticRoutes: StaticRoute[],\n componentProps: Partial<IReduxProps>\n) => {\n const { projectId, contentTypeId, entry, mappedEntry, isLoggedIn } =\n componentProps;\n return staticRoutes.map(x => {\n const route = { ...x };\n if (route.component) {\n route.element = (\n <route.component\n projectId={projectId}\n contentTypeId={contentTypeId ? contentTypeId : undefined}\n entry={entry}\n mappedEntry={mappedEntry}\n isLoggedIn={isLoggedIn}\n />\n );\n delete route.component;\n }\n if (route.element) {\n route.element = cloneElement(route.element as React.ReactElement<any>, {\n projectId,\n contentTypeId,\n entry,\n mappedEntry,\n isLoggedIn,\n });\n }\n if (route.children) {\n route.children = processStaticRoutes(route.children, componentProps);\n }\n return route;\n });\n};\n\ninterface IReduxProps {\n contentTypeId: string | null;\n entry: Entry | null;\n isError: boolean;\n isNotFound: boolean;\n isLoading: boolean;\n isLoggedIn: boolean;\n mappedEntry: any;\n projectId: string;\n setNavigationPath: typeof setNavigationPath;\n statePath: string;\n statusCode: any;\n statusText: string;\n userGroups: any;\n}\n\nconst RouteLoader = ({\n contentTypeId,\n entry,\n isError,\n isLoading,\n isLoggedIn,\n isNotFound,\n loadingComponent,\n mappedEntry,\n notFoundComponent,\n projectId,\n routes,\n setNavigationPath,\n statePath,\n statusCode,\n statusText,\n userGroups,\n withEvents,\n trailingSlashRedirectCode = 302,\n}: AppRootProps & RouteLoaderProps & IReduxProps) => {\n const location = useLocation();\n\n // In SSR pass references to things in backing sagas\n // we cannot access in a global scope\n const ssrContext = useSSRContext();\n\n // Always ensure paths are trimmed of trailing slashes so urls are always unique\n const trimmedPath = getTrimmedPath(location.pathname);\n\n // Convert any react-router-v5 style routes to react-router-v6 style routes.\n const staticRoutes = processStaticRoutes(routes.StaticRoutes, {\n projectId,\n contentTypeId,\n entry,\n mappedEntry,\n isLoggedIn,\n });\n\n // Match any Static Routes a developer has defined\n const matchedStaticRoute = matchRoutes(\n staticRoutes as RouteObject[],\n location\n );\n const isStaticRoute = matchedStaticRoute && matchedStaticRoute.length > 0;\n\n // Combine custom params for all static routes, with the furthest config taking precedence.\n if (isStaticRoute) {\n mergeStaticRoutes(matchedStaticRoute);\n }\n\n const staticRoute: MatchedRoute<string, StaticRoute> | undefined =\n isStaticRoute ? matchedStaticRoute.pop() || undefined : undefined;\n\n const routeRequiresLogin = staticRoute\n ? staticRoute.route.requireLogin\n : undefined;\n\n const setPath = useCallback(() => {\n // Use serverPath to control the path we send to siteview node api to resolve a route\n let serverPath = '';\n if (staticRoute && staticRoute.pathname === staticRoute.pathnameBase) {\n const { route, pathname, params } = staticRoute;\n\n if (route.path?.includes('*')) {\n // Send the whole url to api if we have matched route containing wildcard\n serverPath = pathname;\n } else if (typeof route.fetchNodeLevel === 'number') {\n // Send all url parts to a specified level to api\n serverPath = pathname\n .split('/')\n .splice(0, route.fetchNodeLevel + 1)\n .join('/');\n } else if (\n typeof route.fetchNode === 'object' &&\n route.fetchNode?.params\n ) {\n const fetchNodeParams: string[] = route.fetchNode.params;\n const routeParams = params;\n\n const regexExp = new RegExp(\n Object.keys(routeParams)\n .map(p => `:${p}`)\n .join('|'),\n 'g'\n );\n\n serverPath = pathname\n .replace(/\\?/g, '')\n .replace(regexExp, matched => {\n const param = matched.replace(':', '');\n if (fetchNodeParams.includes(param))\n return routeParams[param] || '';\n else return '';\n })\n .replace(/\\/$/, '');\n } else {\n // Send all non-parameterised url parts to api\n serverPath = (route.fullPath as string)\n ?.split('/')\n .filter(p => !p.startsWith(':'))\n .join('/');\n }\n }\n\n setNavigationPath(\n serverPath || trimmedPath,\n location,\n staticRoute,\n withEvents,\n statePath,\n routes,\n ssrContext\n );\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n setNavigationPath,\n // staticRoute,\n withEvents,\n location,\n routes,\n // statePath,\n trimmedPath,\n ]);\n\n if (typeof window == 'undefined') setPath();\n\n useEffect(() => {\n setPath();\n }, [location, setPath]);\n\n // Need to redirect when url endswith a /\n if (location.pathname.length > trimmedPath.length) {\n return (\n <Redirect\n code={trailingSlashRedirectCode || 302}\n to={`${trimmedPath}${location.search}${location.hash}`}\n />\n );\n }\n\n // Render any Static Routes a developer has defined\n if (isStaticRoute && !(!isLoggedIn && routeRequiresLogin)) {\n if (matchUserGroup(userGroups, routeRequiresLogin))\n return <StaticRouteLoader staticRoutes={staticRoutes} />;\n }\n\n // Render a supplied Loading component if the route\n // is not a static route and is in a loading state\n if (isLoading && !isNotFound && loadingComponent) {\n const LoadingComponent = loadingComponent;\n return <LoadingComponent />;\n }\n\n // Match any defined Content Type Mappings\n if (contentTypeId && !(!isLoggedIn && routeRequiresLogin)) {\n const MatchedComponent = routes.ContentTypeMappings.find(\n item => item.contentTypeID === contentTypeId\n );\n\n if (MatchedComponent && !(MatchedComponent.requireLogin && !isLoggedIn)) {\n if (matchUserGroup(userGroups, MatchedComponent.requireLogin))\n return (\n <MatchedComponent.component\n projectId={projectId}\n contentTypeId={contentTypeId}\n entry={entry}\n mappedEntry={mappedEntry}\n isLoggedIn={isLoggedIn}\n />\n );\n }\n }\n\n const NotFoundComponent = notFoundComponent ? notFoundComponent : NotFound;\n if (isNotFound || isError) {\n console.info(\n `RouteLoader rendering NotFound component: statusCode ${statusCode}, isNotFound ${isNotFound}, isError ${isError}`\n );\n\n return (\n <Status code={statusCode}>\n <NotFoundComponent statusCode={statusCode} statusText={statusText} />\n </Status>\n );\n }\n\n return null;\n};\nconst mapStateToPropsMemoized = createSelector(\n selectRouteEntryContentTypeId,\n selectRouteEntry,\n selectRouteIsError,\n selectIsNotFound,\n selectRouteLoading,\n selectUserIsAuthenticated,\n selectMappedEntry,\n selectCurrentProject,\n selectCurrentPath,\n selectRouteStatusCode,\n selectRouteErrorMessage,\n selectUserGroups,\n (\n contentTypeId,\n entry,\n isError,\n isNotFound,\n isLoading,\n isLoggedIn,\n mappedEntry,\n projectId,\n statePath,\n statusCode,\n statusText,\n userGroups\n ) => ({\n contentTypeId,\n entry,\n isError,\n isNotFound,\n isLoading,\n isLoggedIn,\n mappedEntry,\n projectId,\n statePath,\n statusCode,\n statusText,\n userGroups,\n })\n);\n\nconst mapDispatchToProps = {\n setNavigationPath,\n};\n\nexport default connect(\n mapStateToPropsMemoized,\n mapDispatchToProps\n)(toJS(RouteLoader as any)) as unknown as (\n props: AppRootProps & RouteLoaderProps\n) => React.JSX.Element;\n"],"names":["mergeStaticRoutes","matchedStaticRoute","finalRoute","i","route","entries","staticRouteCopy","length","fullPath","path","children","index","component","element","endsWith","HttpContext","createContext","useHttpContext","useContext","Redirect","code","to","httpContext","statusCode","url","React","createElement","Navigate","Status","Fragment","NotFound","statusText","style","background","color","fontSize","padding","StaticRouteLoader","staticRoutes","staticRouteElement","useRoutes","replaceDoubleSlashRecursive","nextPath","replace","match","getTrimmedPath","lastChar","substring","processStaticRoutes","componentProps","projectId","contentTypeId","entry","mappedEntry","isLoggedIn","map","x","undefined","cloneElement","RouteLoader","isError","isLoading","isNotFound","loadingComponent","notFoundComponent","routes","setNavigationPath","statePath","userGroups","withEvents","trailingSlashRedirectCode","location","useLocation","ssrContext","useSSRContext","trimmedPath","pathname","StaticRoutes","matchRoutes","isStaticRoute","staticRoute","pop","routeRequiresLogin","requireLogin","setPath","useCallback","serverPath","pathnameBase","_route$path","_route$fetchNode","params","includes","fetchNodeLevel","split","splice","join","fetchNode","fetchNodeParams","routeParams","regexExp","RegExp","Object","keys","p","matched","param","_route$fullPath","filter","startsWith","window","useEffect","search","hash","matchUserGroup","LoadingComponent","MatchedComponent","ContentTypeMappings","find","item","contentTypeID","NotFoundComponent","console","info","mapStateToPropsMemoized","createSelector","selectRouteEntryContentTypeId","selectRouteEntry","selectRouteIsError","selectIsNotFound","selectRouteLoading","selectUserIsAuthenticated","selectMappedEntry","selectCurrentProject","selectCurrentPath","selectRouteStatusCode","selectRouteErrorMessage","selectUserGroups","mapDispatchToProps","connect","toJS"],"mappings":";;;;;;;;;AAEO,MAAMA,iBAAiB,GAAGC,kBAAkB,IAAI;EACrD,IAAIC,UAAuB,GAAG,EAAE;AAChC,EAAA,KAAK,MAAM,CAACC,CAAC,EAAEC,KAAK,CAAC,IAAIH,kBAAkB,CAACI,OAAO,EAAE,EAAE;AACrD,IAAA,MAAMC,eAAe,GAAG;AAAE,MAAA,GAAGF,KAAK,CAACA;KAAO;AAC1C,IAAA,IAAID,CAAC,KAAKF,kBAAkB,CAACM,MAAM,GAAG,CAAC,EAAE;AACvCL,MAAAA,UAAU,GAAG;AACX,QAAA,GAAGA,UAAU;AACb,QAAA,GAAGI,eAAe;QAClBE,QAAQ,EAAE,GAAGN,UAAU,CAACM,QAAQ,IAAI,EAAE,GACpCJ,KAAK,CAACA,KAAK,CAACK,IAAI,GAAGL,KAAK,CAACA,KAAK,CAACK,IAAI,GAAG,EAAE,CAAA;OAE3C;AACDR,MAAAA,kBAAkB,CAACE,CAAC,CAAC,CAACC,KAAK,GAAGF,UAAU;AAC1C,IAAA,CAAC,MAAM;MACL,OAAOI,eAAe,CAACI,QAAQ;MAC/B,OAAOJ,eAAe,CAACK,KAAK;MAC5B,OAAOL,eAAe,CAACG,IAAI;MAC3B,OAAOH,eAAe,CAACM,SAAS;MAChC,OAAON,eAAe,CAACO,OAAO;AAC9BX,M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|
|
|
1
|
+
import React, { useContext, useState, createContext } from 'react';
|
|
2
|
+
import { useCookies } from 'react-cookie';
|
|
3
|
+
import { useDispatch } from 'react-redux';
|
|
4
|
+
import { c as cachedSearchWithContext } from './ContensisDeliveryApi-BgfEEyIk.js';
|
|
5
|
+
import { C as CookieHelper } from './CookieHelper.class-C6rTRl_1.js';
|
|
6
|
+
|
|
7
|
+
const SSRContext = /*#__PURE__*/createContext(null);
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* SSRContextProvider allows us to hold and access request-scoped references
|
|
11
|
+
* throughout the component tree
|
|
12
|
+
*
|
|
13
|
+
* adding this in client side allows consumers to write universal code and use
|
|
14
|
+
* the same helpers and request-scoped refs for api, cookies and redux dispatcher
|
|
15
|
+
* as in SSR */
|
|
16
|
+
const SSRContextProvider = ({
|
|
17
|
+
accessMethod,
|
|
18
|
+
children,
|
|
19
|
+
request,
|
|
20
|
+
response
|
|
21
|
+
}) => {
|
|
22
|
+
// In SSR pass references to things in backing sagas
|
|
23
|
+
// we cannot access in a global scope
|
|
24
|
+
const dispatch = useDispatch();
|
|
25
|
+
const cookies = new CookieHelper(...useCookies());
|
|
26
|
+
const api = cachedSearchWithContext({
|
|
27
|
+
cookies,
|
|
28
|
+
dispatch,
|
|
29
|
+
request,
|
|
30
|
+
response
|
|
31
|
+
});
|
|
32
|
+
const [context] = useState({
|
|
33
|
+
accessMethod,
|
|
34
|
+
api,
|
|
35
|
+
cookies,
|
|
36
|
+
dispatch,
|
|
37
|
+
request,
|
|
38
|
+
response
|
|
39
|
+
});
|
|
40
|
+
return /*#__PURE__*/React.createElement(SSRContext.Provider, {
|
|
41
|
+
value: {
|
|
42
|
+
...context
|
|
43
|
+
}
|
|
44
|
+
}, children);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Server side usage provides access to request-scoped references throughout the component tree
|
|
49
|
+
*
|
|
50
|
+
* Client side usage allows consumers to write universal code, using the same
|
|
51
|
+
* helpers and request-scoped refs for api, cookies and redux dispatcher as in SSR
|
|
52
|
+
* @returns SSRContextType
|
|
53
|
+
*/
|
|
54
|
+
const useSSRContext = () => useContext(SSRContext);
|
|
55
|
+
const useDeliveryApi = () => {
|
|
56
|
+
const {
|
|
57
|
+
api
|
|
58
|
+
} = useSSRContext();
|
|
59
|
+
return api;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export { SSRContextProvider as S, useSSRContext as a, useDeliveryApi as u };
|
|
63
|
+
//# sourceMappingURL=SSRContext-CXRqYy6B.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SSRContext-CXRqYy6B.js","sources":["../src/util/SSRContext.tsx"],"sourcesContent":["import { Request, Response } from 'express';\nimport React, {\n PropsWithChildren,\n createContext,\n useContext,\n useState,\n} from 'react';\nimport { useCookies } from 'react-cookie';\nimport { useDispatch } from 'react-redux';\nimport {\n SSRAccessMethod,\n SSRContext as SSRContextType,\n} from '~/models';\nimport { cachedSearchWithContext } from '~/util/CachedDeliveryApi';\nimport { CookieHelper } from '~/user/util/CookieHelper.class';\n\nconst SSRContext = createContext<SSRContextType | null>(null);\n\n/**\n * SSRContextProvider allows us to hold and access request-scoped references\n * throughout the component tree\n *\n * adding this in client side allows consumers to write universal code and use\n * the same helpers and request-scoped refs for api, cookies and redux dispatcher\n * as in SSR */\nexport const SSRContextProvider = ({\n accessMethod,\n children,\n request,\n response,\n}: PropsWithChildren<{\n accessMethod?: SSRAccessMethod;\n request?: Request;\n response?: Response;\n}>) => {\n // In SSR pass references to things in backing sagas\n // we cannot access in a global scope\n const dispatch = useDispatch();\n const cookies = new CookieHelper(...useCookies());\n const api = cachedSearchWithContext({ cookies, dispatch, request, response });\n\n const [context] = useState<SSRContextType>({\n accessMethod,\n api,\n cookies,\n dispatch,\n request,\n response,\n });\n\n return (\n <SSRContext.Provider value={{ ...context }}>{children}</SSRContext.Provider>\n );\n};\n\n/**\n * Server side usage provides access to request-scoped references throughout the component tree\n *\n * Client side usage allows consumers to write universal code, using the same\n * helpers and request-scoped refs for api, cookies and redux dispatcher as in SSR\n * @returns SSRContextType\n */\nexport const useSSRContext = () => useContext(SSRContext) as SSRContextType;\n\nexport const useDeliveryApi = () => {\n const { api } = useSSRContext();\n return api;\n};\n"],"names":["SSRContext","createContext","SSRContextProvider","accessMethod","children","request","response","dispatch","useDispatch","cookies","CookieHelper","useCookies","api","cachedSearchWithContext","context","useState","React","createElement","Provider","value","useSSRContext","useContext","useDeliveryApi"],"mappings":";;;;;;AAgBA,MAAMA,UAAU,gBAAGC,aAAa,CAAwB,IAAI,CAAC;;AAE7D;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,kBAAkB,GAAGA,CAAC;EACjCC,YAAY;EACZC,QAAQ;EACRC,OAAO;AACPC,EAAAA;AAKD,CAAC,KAAK;AACL;AACA;AACA,EAAA,MAAMC,QAAQ,GAAGC,WAAW,EAAE;EAC9B,MAAMC,OAAO,GAAG,IAAIC,YAAY,CAAC,GAAGC,UAAU,EAAE,CAAC;EACjD,MAAMC,GAAG,GAAGC,uBAAuB,CAAC;IAAEJ,OAAO;IAAEF,QAAQ;IAAEF,OAAO;AAAEC,IAAAA;AAAS,GAAC,CAAC;AAE7E,EAAA,MAAM,CAACQ,OAAO,CAAC,GAAGC,QAAQ,CAAiB;IACzCZ,YAAY;IACZS,GAAG;IACHH,OAAO;IACPF,QAAQ;IACRF,OAAO;AACPC,IAAAA;AACF,GAAC,CAAC;AAEF,EAAA,oBACEU,KAAA,CAAAC,aAAA,CAACjB,UAAU,CAACkB,QAAQ,EAAA;AAACC,IAAAA,KAAK,EAAE;MAAE,GAAGL;AAAQ;AAAE,GAAA,EAAEV,QAA8B,CAAC;AAEhF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMgB,aAAa,GAAGA,MAAMC,UAAU,CAACrB,UAAU;AAEjD,MAAMsB,cAAc,GAAGA,MAAM;EAClC,MAAM;AAAEV,IAAAA;GAAK,GAAGQ,aAAa,EAAE;AAC/B,EAAA,OAAOR,GAAG;AACZ;;;;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable react/display-name */
|
|
4
|
+
const toJS = WrappedComponent => wrappedComponentProps => {
|
|
5
|
+
const KEY = 0;
|
|
6
|
+
const VALUE = 1;
|
|
7
|
+
const propsJS = Object.entries(wrappedComponentProps).reduce((newProps, wrappedComponentProp) => {
|
|
8
|
+
const propKey = wrappedComponentProp[KEY];
|
|
9
|
+
const propValue = wrappedComponentProp[VALUE];
|
|
10
|
+
newProps[propKey] = propValue && typeof propValue === 'object' && 'toJS' in propValue ? propValue.toJS() : propValue;
|
|
11
|
+
return newProps;
|
|
12
|
+
}, {});
|
|
13
|
+
return /*#__PURE__*/React.createElement(WrappedComponent, propsJS);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { toJS as t };
|
|
17
|
+
//# sourceMappingURL=ToJs-BnRRHk6f.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToJs-BnRRHk6f.js","sources":["../src/util/ToJs.tsx"],"sourcesContent":["/* eslint-disable react/display-name */\nimport React from 'react';\n\nexport const toJS =\n <Props extends { [key: string]: any }>(\n WrappedComponent: React.ComponentType<Props>\n ) =>\n (wrappedComponentProps: Props) => {\n const KEY = 0;\n const VALUE = 1;\n\n const propsJS = Object.entries(wrappedComponentProps).reduce<Props>(\n (newProps: any, wrappedComponentProp) => {\n const propKey = wrappedComponentProp[KEY];\n const propValue = wrappedComponentProp[VALUE];\n newProps[propKey] =\n propValue && typeof propValue === 'object' && 'toJS' in propValue\n ? propValue.toJS()\n : propValue;\n return newProps as Props;\n },\n {} as Props\n );\n\n return <WrappedComponent {...propsJS} />;\n };\n"],"names":["toJS","WrappedComponent","wrappedComponentProps","KEY","VALUE","propsJS","Object","entries","reduce","newProps","wrappedComponentProp","propKey","propValue","React","createElement"],"mappings":";;AAAA;MAGaA,IAAI,GAEbC,gBAA4C,IAE7CC,qBAA4B,IAAK;EAChC,MAAMC,GAAG,GAAG,CAAC;EACb,MAAMC,KAAK,GAAG,CAAC;AAEf,EAAA,MAAMC,OAAO,GAAGC,MAAM,CAACC,OAAO,CAACL,qBAAqB,CAAC,CAACM,MAAM,CAC1D,CAACC,QAAa,EAAEC,oBAAoB,KAAK;AACvC,IAAA,MAAMC,OAAO,GAAGD,oBAAoB,CAACP,GAAG,CAAC;AACzC,IAAA,MAAMS,SAAS,GAAGF,oBAAoB,CAACN,KAAK,CAAC;IAC7CK,QAAQ,CAACE,OAAO,CAAC,GACfC,SAAS,IAAI,OAAOA,SAAS,KAAK,QAAQ,IAAI,MAAM,IAAIA,SAAS,GAC7DA,SAAS,CAACZ,IAAI,EAAE,GAChBY,SAAS;AACf,IAAA,OAAOH,QAAQ;EACjB,CAAC,EACD,EACF,CAAC;AAED,EAAA,oBAAOI,KAAA,CAAAC,aAAA,CAACb,gBAAgB,EAAKI,OAAU,CAAC;AAC1C;;;;"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { g as getDefaultExportFromCjs } from './_commonjsHelpers-BFTU3MAI.js';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { connect } from 'react-redux';
|
|
4
|
+
import mapJson from 'jsonpath-mapper';
|
|
5
|
+
import { n as selectCurrentProject } from './selectors-CNC7sDxg.js';
|
|
6
|
+
import { s as selectVersionStatus, a as selectCommitRef, b as selectBuildNumber } from './version-CaL4czqJ.js';
|
|
7
|
+
import styled from 'styled-components';
|
|
8
|
+
|
|
9
|
+
const setCachingHeaders = (response, {
|
|
10
|
+
cacheControl = 'private',
|
|
11
|
+
surrogateControl = '3600'
|
|
12
|
+
}, method = 'header') => {
|
|
13
|
+
if (cacheControl) response[method]('Cache-Control', cacheControl);
|
|
14
|
+
if (surrogateControl) response[method]('Surrogate-Control', `max-age=${surrogateControl.toString()}`);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const url = (alias, project) => {
|
|
18
|
+
const projectAndAlias = project && project.toLowerCase() !== 'website' ? `${project.toLowerCase()}-${alias}` : alias;
|
|
19
|
+
return {
|
|
20
|
+
api: `https://api-${alias}.cloud.contensis.com`,
|
|
21
|
+
cms: `https://cms-${alias}.cloud.contensis.com`,
|
|
22
|
+
liveWeb: `https://live-${projectAndAlias}.cloud.contensis.com`,
|
|
23
|
+
previewWeb: `https://preview-${projectAndAlias}.cloud.contensis.com`,
|
|
24
|
+
iisWeb: `https://iis-live-${projectAndAlias}.cloud.contensis.com`,
|
|
25
|
+
iisPreviewWeb: `https://iis-preview-${projectAndAlias}.cloud.contensis.com`
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
var stringifyStrings_1;
|
|
30
|
+
var hasRequiredStringifyStrings;
|
|
31
|
+
|
|
32
|
+
function requireStringifyStrings () {
|
|
33
|
+
if (hasRequiredStringifyStrings) return stringifyStrings_1;
|
|
34
|
+
hasRequiredStringifyStrings = 1;
|
|
35
|
+
const stringifyStrings = obj => {
|
|
36
|
+
const returnObj = Array.isArray(obj) ? [] : {};
|
|
37
|
+
Object.entries(obj).forEach(([key, value]) => {
|
|
38
|
+
switch (typeof value) {
|
|
39
|
+
case 'string':
|
|
40
|
+
returnObj[key] = JSON.stringify(value);
|
|
41
|
+
break;
|
|
42
|
+
case 'object':
|
|
43
|
+
returnObj[key] = stringifyStrings(value);
|
|
44
|
+
break;
|
|
45
|
+
default:
|
|
46
|
+
returnObj[key] = value;
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
return returnObj;
|
|
51
|
+
};
|
|
52
|
+
stringifyStrings_1 = stringifyStrings;
|
|
53
|
+
return stringifyStrings_1;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
var stringifyStringsExports = requireStringifyStrings();
|
|
57
|
+
var stringifyStrings = /*@__PURE__*/getDefaultExportFromCjs(stringifyStringsExports);
|
|
58
|
+
|
|
59
|
+
const context = typeof window != 'undefined' ? window : global;
|
|
60
|
+
const isDev = process.env.NODE_ENV === 'development';
|
|
61
|
+
const pj = () => isDev ? PACKAGE_JSON /* global PACKAGE_JSON */ : context.PACKAGE_JSON || {
|
|
62
|
+
name: 'packagejson not found',
|
|
63
|
+
repository: ''
|
|
64
|
+
};
|
|
65
|
+
const versionInfoProps = {
|
|
66
|
+
packageDetail: () => {
|
|
67
|
+
const pkg = pj();
|
|
68
|
+
return {
|
|
69
|
+
name: pkg.name,
|
|
70
|
+
version: pkg.version,
|
|
71
|
+
repository: pkg.repository
|
|
72
|
+
};
|
|
73
|
+
},
|
|
74
|
+
uris: {
|
|
75
|
+
gitRepo: () => pj().repository,
|
|
76
|
+
commit: state => {
|
|
77
|
+
const commitRef = selectCommitRef(state);
|
|
78
|
+
return `${pj().repository}/commit/${commitRef ? commitRef : ''}`;
|
|
79
|
+
},
|
|
80
|
+
pipeline: state => {
|
|
81
|
+
const buildNumber = selectBuildNumber(state);
|
|
82
|
+
return `${pj().repository}/${pj().repository.includes('github.com') ? 'actions/runs' : 'pipelines'}/${buildNumber ? buildNumber : ''}`;
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
zenPackageVersions: () => [...(Object.entries(pj().devDependencies || {}).filter(([pkg]) => pkg.includes('zengenti') || pkg.includes('contensis')) || []), ...(Object.entries(pj().dependencies || {}).filter(([pkg]) => pkg.includes('zengenti') || pkg.includes('contensis')) || [])],
|
|
86
|
+
deliveryApi: () => JSON.parse(JSON.stringify(DELIVERY_API_CONFIG /* global DELIVERY_API_CONFIG */)),
|
|
87
|
+
devEnv: () => typeof DEV_ENV !== 'undefined' /* global DEV_ENV */ ? DEV_ENV : null,
|
|
88
|
+
disableSsrRedux: () => isDev ? DISABLE_SSR_REDUX /* global DISABLE_SSR_REDUX*/ : context.DISABLE_SSR_REDUX || false,
|
|
89
|
+
nodeEnv: () => process.env.NODE_ENV || 'production',
|
|
90
|
+
packagejson: () => pj() || {},
|
|
91
|
+
projects: () => isDev ? PROJECTS /* global PROJECTS */ : context.PROJECTS,
|
|
92
|
+
proxyDeliveryApi: () => isDev ? PROXY_DELIVERY_API /* global PROXY_DELIVERY_API */ : context.PROXY_DELIVERY_API || false,
|
|
93
|
+
publicUri: () => isDev ? PUBLIC_URI /* global PUBLIC_URI */ : context.PUBLIC_URI || null,
|
|
94
|
+
project: state => selectCurrentProject(state),
|
|
95
|
+
reverseProxyPaths: () => isDev ? REVERSE_PROXY_PATHS /* global REVERSE_PROXY_PATHS */ : context.REVERSE_PROXY_PATHS || {},
|
|
96
|
+
servers: () => isDev ? SERVERS /* global SERVERS */ : context.SERVERS,
|
|
97
|
+
version: {
|
|
98
|
+
buildNumber: state => selectBuildNumber(state),
|
|
99
|
+
commitRef: state => selectCommitRef(state),
|
|
100
|
+
contensisVersionStatus: state => selectVersionStatus(state)
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
const mapStateToVersionInfo = state => {
|
|
104
|
+
const mappedProps = mapJson(state, versionInfoProps);
|
|
105
|
+
return mappedProps;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const VersionInfoStyledTable = styled.table.withConfig({
|
|
109
|
+
displayName: "VersionInfostyled__VersionInfoStyledTable",
|
|
110
|
+
componentId: "sc-ogujr7-0"
|
|
111
|
+
})(["font-family:'Source Sans Pro',Helvetica,Arial,sans-serif;font-size:1.6rem;line-height:1.5rem;border-bottom:4px solid #8892bf;border-collapse:separate;margin:0 auto;width:80%;th{text-align:left;background-color:#c4c9df;border-bottom:#8892bf 2px solid;border-bottom-color:#8892bf;border-top:20px solid #fff;}td{border-bottom:1px solid #eee;}td,th{padding:0.5rem 0.75rem;vertical-align:top;}.left{width:25%;}tr th{border-right:hidden;border-spacing:0 15px;}.green{background-color:#9c9;border-bottom:1px solid #696;}.red{background-color:#c99;border-bottom:1px solid #966;}.small{font-size:100%;line-height:2.4rem;}"]);
|
|
112
|
+
|
|
113
|
+
const VersionInfo = ({
|
|
114
|
+
deliveryApi,
|
|
115
|
+
devEnv,
|
|
116
|
+
disableSsrRedux,
|
|
117
|
+
nodeEnv,
|
|
118
|
+
packageDetail,
|
|
119
|
+
project,
|
|
120
|
+
projects,
|
|
121
|
+
proxyDeliveryApi,
|
|
122
|
+
publicUri,
|
|
123
|
+
reverseProxyPaths,
|
|
124
|
+
servers,
|
|
125
|
+
uris,
|
|
126
|
+
version,
|
|
127
|
+
zenPackageVersions
|
|
128
|
+
}) => {
|
|
129
|
+
return /*#__PURE__*/React.createElement(VersionInfoStyledTable, null, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
|
|
130
|
+
colSpan: 2
|
|
131
|
+
}, /*#__PURE__*/React.createElement("h1", null, /*#__PURE__*/React.createElement("a", {
|
|
132
|
+
href: "/"
|
|
133
|
+
}, "Version Information"))))), /*#__PURE__*/React.createElement("tbody", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", {
|
|
134
|
+
colSpan: 2
|
|
135
|
+
}, "Package detail")), /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
|
|
136
|
+
className: "left"
|
|
137
|
+
}, "Name"), /*#__PURE__*/React.createElement("td", null, packageDetail.name)), /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
|
|
138
|
+
className: "left"
|
|
139
|
+
}, "Version"), /*#__PURE__*/React.createElement("td", null, packageDetail.version)), /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", {
|
|
140
|
+
colSpan: 2
|
|
141
|
+
}, "Version info (state)")), /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null, "Git repo url: "), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("a", {
|
|
142
|
+
href: packageDetail.repository,
|
|
143
|
+
target: "_blank",
|
|
144
|
+
rel: "noopener noreferrer"
|
|
145
|
+
}, packageDetail.repository))), /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null, "Pipeline: "), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("a", {
|
|
146
|
+
href: uris.pipeline,
|
|
147
|
+
target: "_blank",
|
|
148
|
+
rel: "noopener noreferrer"
|
|
149
|
+
}, version.buildNumber))), /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null, "Commit: "), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("a", {
|
|
150
|
+
href: uris.commit,
|
|
151
|
+
target: "_blank",
|
|
152
|
+
rel: "noopener noreferrer"
|
|
153
|
+
}, version.commitRef))), /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null, "Project"), /*#__PURE__*/React.createElement("td", {
|
|
154
|
+
className: project === 'unknown' ? 'red' : ''
|
|
155
|
+
}, project)), /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null, "Contensis version status: "), /*#__PURE__*/React.createElement("td", {
|
|
156
|
+
className: version.contensisVersionStatus === 'published' ? 'green' : 'red'
|
|
157
|
+
}, version.contensisVersionStatus)), /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", {
|
|
158
|
+
colSpan: 2
|
|
159
|
+
}, "Build configuration")), /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null, "Environment"), /*#__PURE__*/React.createElement("td", null, servers.alias)), /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null, "Public uri"), /*#__PURE__*/React.createElement("td", null, publicUri)), /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null, "Zengenti packages"), /*#__PURE__*/React.createElement("td", null, zenPackageVersions.map(([pkg, ver], idx) => /*#__PURE__*/React.createElement("div", {
|
|
160
|
+
key: idx
|
|
161
|
+
}, pkg, ": ", ver)))), /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null, "Servers"), /*#__PURE__*/React.createElement("td", {
|
|
162
|
+
className: "small"
|
|
163
|
+
}, /*#__PURE__*/React.createElement("div", null, "web: ", servers.web), /*#__PURE__*/React.createElement("div", null, "preview: ", servers.previewWeb), /*#__PURE__*/React.createElement("div", null, "api: ", servers.api), /*#__PURE__*/React.createElement("div", null, "cms: ", servers.cms), /*#__PURE__*/React.createElement("div", null, "iis: ", servers.iis), /*#__PURE__*/React.createElement("div", null, "iis preview: ", servers.previewIis))), /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null, "Reverse proxy paths"), /*#__PURE__*/React.createElement("td", null, Object.entries(reverseProxyPaths).map(([, path], key) => /*#__PURE__*/React.createElement("span", {
|
|
164
|
+
key: key
|
|
165
|
+
}, "[ ", path, " ] ")))), /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null, "Projects"), /*#__PURE__*/React.createElement("td", null, Object.entries(projects).map(([, project], key) => /*#__PURE__*/React.createElement("div", {
|
|
166
|
+
key: key
|
|
167
|
+
}, "[ ", project.id, ": ", project.publicUri, " ]")))), /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null, "Delivery API"), /*#__PURE__*/React.createElement("td", {
|
|
168
|
+
className: "small"
|
|
169
|
+
}, /*#__PURE__*/React.createElement("ul", {
|
|
170
|
+
style: {
|
|
171
|
+
margin: 0,
|
|
172
|
+
padding: 0
|
|
173
|
+
}
|
|
174
|
+
}, Object.entries(deliveryApi).map(([key, value], idx) => {
|
|
175
|
+
if (typeof value === 'object') return null;
|
|
176
|
+
return /*#__PURE__*/React.createElement("li", {
|
|
177
|
+
key: idx,
|
|
178
|
+
style: {
|
|
179
|
+
listStyleType: 'none'
|
|
180
|
+
}
|
|
181
|
+
}, key, ": ", /*#__PURE__*/React.createElement("span", null, value));
|
|
182
|
+
})))), /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null, "Proxy Delivery API requests"), /*#__PURE__*/React.createElement("td", {
|
|
183
|
+
className: proxyDeliveryApi ? 'green' : 'red'
|
|
184
|
+
}, proxyDeliveryApi.toString())), /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null, "Disable SSR inline-redux"), /*#__PURE__*/React.createElement("td", null, disableSsrRedux.toString())), /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null, "NODE_ENV"), /*#__PURE__*/React.createElement("td", {
|
|
185
|
+
className: nodeEnv === 'production' ? 'green' : 'red'
|
|
186
|
+
}, nodeEnv.toString())), devEnv && /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null, "process.env"), /*#__PURE__*/React.createElement("td", null, Object.entries(devEnv).map(([k, v], key) => /*#__PURE__*/React.createElement("div", {
|
|
187
|
+
key: key
|
|
188
|
+
}, "[ ", k, ": ", v, " ]"))))));
|
|
189
|
+
};
|
|
190
|
+
var VersionInfo$1 = connect(mapStateToVersionInfo)(VersionInfo);
|
|
191
|
+
|
|
192
|
+
export { VersionInfo$1 as V, stringifyStrings as a, setCachingHeaders as s, url as u };
|
|
193
|
+
//# sourceMappingURL=VersionInfo-j6NR0QJR.js.map
|