@zengenti/contensis-react-base 2.4.1-beta.7 → 2.5.1-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +61 -0
- package/README.md +89 -0
- package/cjs/{App-f3164dab.js → App-8f560cc5.js} +236 -22
- package/cjs/App-8f560cc5.js.map +1 -0
- package/cjs/{RouteLoader-5c44f039.js → RouteLoader-f99cd734.js} +14 -41
- package/cjs/RouteLoader-f99cd734.js.map +1 -0
- package/cjs/{ToJs-ca9bea03.js → ToJs-d72e5b10.js} +58 -2
- package/cjs/ToJs-d72e5b10.js.map +1 -0
- package/cjs/{actions-e22726ed.js → actions-e9f69947.js} +1 -1
- package/cjs/actions-e9f69947.js.map +1 -0
- package/cjs/client.js +121 -16
- package/cjs/client.js.map +1 -1
- package/cjs/contensis-react-base.js +128 -118
- package/cjs/contensis-react-base.js.map +1 -1
- package/cjs/forms.js +1 -1
- package/cjs/{login-6c0ef139.js → login-4f274c6a.js} +8 -5
- package/cjs/login-4f274c6a.js.map +1 -0
- package/cjs/reducers-cb531715.js +207 -0
- package/cjs/reducers-cb531715.js.map +1 -0
- package/cjs/redux.js +15 -16
- package/cjs/redux.js.map +1 -1
- package/cjs/routing.js +4 -5
- package/cjs/routing.js.map +1 -1
- package/cjs/search.js +6 -4
- package/cjs/search.js.map +1 -1
- package/cjs/{selectors-69c3d37c.js → selectors-1295124a.js} +9 -1
- package/cjs/selectors-1295124a.js.map +1 -0
- package/cjs/user.js +82 -27
- package/cjs/user.js.map +1 -1
- package/cjs/util.js +21 -91
- package/cjs/util.js.map +1 -1
- package/cjs/{injectors-72d5b989.js → version-3a808c12.js} +21 -6
- package/cjs/version-3a808c12.js.map +1 -0
- package/esm/{App-08311b77.js → App-d468b2a6.js} +223 -8
- package/esm/App-d468b2a6.js.map +1 -0
- package/esm/{RouteLoader-2cfdfc5c.js → RouteLoader-281d47e1.js} +14 -40
- package/esm/RouteLoader-281d47e1.js.map +1 -0
- package/esm/{ToJs-19a3244a.js → ToJs-6e7b247c.js} +47 -3
- package/esm/ToJs-6e7b247c.js.map +1 -0
- package/esm/{actions-fda5e103.js → actions-ddd9c623.js} +1 -1
- package/esm/actions-ddd9c623.js.map +1 -0
- package/esm/client.js +121 -16
- package/esm/client.js.map +1 -1
- package/esm/contensis-react-base.js +122 -112
- package/esm/contensis-react-base.js.map +1 -1
- package/esm/forms.js +1 -1
- package/esm/{login-c05fee0e.js → login-1f9ad133.js} +8 -6
- package/esm/login-1f9ad133.js.map +1 -0
- package/esm/reducers-feab84fc.js +183 -0
- package/esm/reducers-feab84fc.js.map +1 -0
- package/esm/redux.js +5 -6
- package/esm/redux.js.map +1 -1
- package/esm/routing.js +4 -5
- package/esm/routing.js.map +1 -1
- package/esm/search.js +6 -4
- package/esm/search.js.map +1 -1
- package/esm/{selectors-170581d2.js → selectors-68799788.js} +9 -1
- package/esm/selectors-68799788.js.map +1 -0
- package/esm/user.js +80 -29
- package/esm/user.js.map +1 -1
- package/esm/util.js +20 -90
- package/esm/util.js.map +1 -1
- package/esm/{injectors-3cbe3981.js → version-64906b26.js} +20 -5
- package/esm/version-64906b26.js.map +1 -0
- package/models/app/App.d.ts +4 -0
- package/models/app/pages/VersionInfo/components/VersionInfo.d.ts +40 -0
- package/models/app/pages/VersionInfo/components/VersionInfo.styled.d.ts +1 -0
- package/models/app/pages/VersionInfo/index.d.ts +2 -0
- package/models/app/pages/VersionInfo/transformations/state-to-versioninfoprops.mapper.d.ts +3 -0
- package/models/client/client.d.ts +11 -0
- package/models/client/index.d.ts +3 -0
- package/models/config.d.ts +33 -0
- package/models/forms/index.d.ts +1 -0
- package/models/index.d.ts +5 -0
- package/models/redux/actions/index.d.ts +9 -0
- package/models/redux/actions/navigation.d.ts +1 -0
- package/models/redux/actions/version.d.ts +2 -0
- package/models/redux/index.d.ts +17 -0
- package/models/redux/reducers/navigation.d.ts +3 -0
- package/models/redux/reducers/version.d.ts +3 -0
- package/models/redux/sagas/index.d.ts +1 -0
- package/models/redux/sagas/navigation.d.ts +4 -0
- package/models/redux/selectors/index.d.ts +9 -0
- package/models/redux/selectors/navigation.d.ts +3 -0
- package/models/redux/selectors/version.d.ts +3 -0
- package/models/redux/store/history.d.ts +2 -0
- package/models/redux/store/injectors.d.ts +19 -0
- package/models/redux/store/routerMiddleware.d.ts +7 -0
- package/models/redux/store/store.d.ts +3 -0
- package/models/redux/types/index.d.ts +9 -0
- package/models/redux/types/navigation.d.ts +3 -0
- package/models/redux/types/version.d.ts +2 -0
- package/models/redux/util.d.ts +1 -0
- package/models/routing/components/Loading.d.ts +5 -0
- package/models/routing/components/NotFound.d.ts +6 -0
- package/models/routing/components/RouteLoader.d.ts +3 -0
- package/models/routing/components/Status.d.ts +4 -0
- package/models/routing/index.d.ts +4 -0
- package/models/routing/redux/actions.d.ts +6 -0
- package/models/routing/redux/reducers.d.ts +4 -0
- package/models/routing/redux/sagas.d.ts +1 -0
- package/models/routing/redux/selectors.d.ts +25 -0
- package/models/routing/redux/types.d.ts +12 -0
- package/models/routing/routes.d.ts +98 -0
- package/models/routing/util/expressions.d.ts +2 -0
- package/models/routing/util/find-contenttype-mapping.d.ts +2 -0
- package/models/routing/util/queries.d.ts +2 -0
- package/models/search/containers/withListing.d.ts +4 -0
- package/models/search/containers/withSearch.d.ts +4 -0
- package/models/search/hooks/useMinilist.hook.d.ts +23 -0
- package/models/search/index.d.ts +16 -0
- package/models/search/models/Enums.d.ts +5 -0
- package/models/search/models/Queries.d.ts +43 -0
- package/models/search/models/Search.d.ts +180 -0
- package/models/search/models/SearchActions.d.ts +127 -0
- package/models/search/models/SearchProps.d.ts +45 -0
- package/models/search/models/SearchState.d.ts +83 -0
- package/models/search/models/SearchUtil.d.ts +6 -0
- package/models/search/models/index.d.ts +3 -0
- package/models/search/redux/actions.d.ts +39 -0
- package/models/search/redux/queries.d.ts +3 -0
- package/models/search/redux/reducers.d.ts +4 -0
- package/models/search/redux/sagas.d.ts +20 -0
- package/models/search/redux/schema.d.ts +9 -0
- package/models/search/redux/selectors.d.ts +112 -0
- package/models/search/redux/types.d.ts +20 -0
- package/models/search/redux/util.d.ts +25 -0
- package/models/search/search/ContensisDeliveryApi.d.ts +32 -0
- package/models/search/search/ToJs.d.ts +4 -0
- package/models/search/search/expressions.d.ts +29 -0
- package/models/search/search/performance.d.ts +1 -0
- package/models/search/search/schema.d.ts +28 -0
- package/models/search/search/util.d.ts +21 -0
- package/models/search/transformations/entry-to-filteritem.mapper.d.ts +2 -0
- package/models/search/transformations/filters-to-filterexpression.d.ts +1 -0
- package/models/search/transformations/filters-to-filterexpression.mapper.d.ts +2 -0
- package/models/search/transformations/searchresult-to-state.mapper.d.ts +6 -0
- package/models/search/transformations/state-to-queryparams.mapper.d.ts +12 -0
- package/models/search/transformations/state-to-searchuri.d.ts +14 -0
- package/models/server/features/caching/cacheDuration.schema.d.ts +7 -0
- package/models/server/features/caching/cacheHashing.d.ts +1 -0
- package/models/server/features/caching/setCachingHeaders.d.ts +6 -0
- package/models/server/features/response-handler/index.d.ts +12 -0
- package/models/server/features/response-handler/types.d.ts +5 -0
- package/models/server/features/reverse-proxy/index.d.ts +4 -0
- package/models/server/features/static-assets/index.d.ts +14 -0
- package/models/server/internalServer.d.ts +10 -0
- package/models/server/middleware/bundleManipulation.d.ts +6 -0
- package/models/server/middleware/resolveStartup.d.ts +13 -0
- package/models/server/util/bundles.d.ts +46 -0
- package/models/server/util/displayStartupConfiguration.d.ts +2 -0
- package/models/server/util/headers.d.ts +9 -0
- package/models/server/util/staticPaths.d.ts +1 -0
- package/models/server/util/stringifyAttributes.d.ts +2 -0
- package/models/server/webApp.d.ts +9 -0
- package/models/testImmer/redux/reducer.d.ts +8 -0
- package/models/testImmer/redux/selectors.d.ts +3 -0
- package/models/user/components/Login.d.ts +2 -0
- package/models/user/components/LoginForm.d.ts +16 -0
- package/models/user/components/LogoutForm.d.ts +12 -0
- package/models/user/components.styled/Login.styled.d.ts +2 -0
- package/models/user/components.styled/LoginForm.styled.d.ts +2 -0
- package/models/user/containers/ChangePassword.container.d.ts +2 -0
- package/models/user/containers/ForgotPassword.container.d.ts +2 -0
- package/models/user/containers/Login.container.d.ts +2 -0
- package/models/user/containers/Registration.container.d.ts +2 -0
- package/models/user/hocs/withLogin.d.ts +2 -0
- package/models/user/hocs/withRegistration.d.ts +2 -0
- package/models/user/hooks/useChangePassword.d.ts +9 -0
- package/models/user/hooks/useForgotPassword.d.ts +14 -0
- package/models/user/hooks/useLogin.d.ts +12 -0
- package/models/user/hooks/useRegistration.d.ts +8 -0
- package/models/user/index.d.ts +16 -0
- package/models/user/redux/actions.d.ts +6 -0
- package/models/user/redux/reducers.d.ts +4 -0
- package/models/user/redux/sagas/index.d.ts +1 -0
- package/models/user/redux/sagas/login.d.ts +36 -0
- package/models/user/redux/sagas/register.d.ts +1 -0
- package/models/user/redux/sagas/resetPassword.d.ts +1 -0
- package/models/user/redux/selectors.d.ts +27 -0
- package/models/user/redux/types.d.ts +21 -0
- package/models/user/transformations/mapClientCredentials.d.ts +2 -0
- package/models/user/util/ContensisManagementApi.d.ts +9 -0
- package/models/user/util/CookieHelper.class.d.ts +5 -0
- package/models/user/util/LoginHelper.class.d.ts +52 -0
- package/models/user/util/OidcUserManager.d.ts +18 -0
- package/models/user/util/matchGroups.d.ts +3 -0
- package/models/user/util/userHelper.d.ts +12 -0
- package/models/util/ContensisDeliveryApi.d.ts +40 -0
- package/models/util/ToJs.d.ts +1 -0
- package/models/util/fromJSLeaveImmer.d.ts +2 -0
- package/models/util/fromJSOrdered.d.ts +2 -0
- package/models/util/index.d.ts +5 -0
- package/models/util/json-mapper.d.ts +81 -0
- package/models/util/navHelper.d.ts +7 -0
- package/models/util/navigation.d.ts +4 -0
- package/models/util/performance.d.ts +1 -0
- package/models/util/pickProject.d.ts +2 -0
- package/models/{schema.d.ts → util/schema.d.ts} +0 -0
- package/models/util/stringifyStrings.d.ts +2 -0
- package/models/util/urls.d.ts +9 -0
- package/package-lock.json +7831 -7713
- package/package.json +24 -14
- package/cjs/App-f3164dab.js.map +0 -1
- package/cjs/RouteLoader-5c44f039.js.map +0 -1
- package/cjs/ToJs-ca9bea03.js.map +0 -1
- package/cjs/actions-e22726ed.js.map +0 -1
- package/cjs/injectors-72d5b989.js.map +0 -1
- package/cjs/login-6c0ef139.js.map +0 -1
- package/cjs/reducers-91e3e239.js +0 -119
- package/cjs/reducers-91e3e239.js.map +0 -1
- package/cjs/selectors-69c3d37c.js.map +0 -1
- package/cjs/version-7d8852f6.js +0 -23
- package/cjs/version-7d8852f6.js.map +0 -1
- package/esm/App-08311b77.js.map +0 -1
- package/esm/RouteLoader-2cfdfc5c.js.map +0 -1
- package/esm/ToJs-19a3244a.js.map +0 -1
- package/esm/actions-fda5e103.js.map +0 -1
- package/esm/injectors-3cbe3981.js.map +0 -1
- package/esm/login-c05fee0e.js.map +0 -1
- package/esm/reducers-f855681f.js +0 -108
- package/esm/reducers-f855681f.js.map +0 -1
- package/esm/selectors-170581d2.js.map +0 -1
- package/esm/version-937d57fb.js +0 -19
- package/esm/version-937d57fb.js.map +0 -1
package/esm/client.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import 'isomorphic-fetch';
|
|
2
|
-
import 'react-loadable';
|
|
3
|
-
import 'react';
|
|
4
|
-
import 'react-router-dom';
|
|
5
|
-
import 'react-redux';
|
|
2
|
+
import { preloadReady } from 'react-loadable';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { Router } from 'react-router-dom';
|
|
5
|
+
import { Provider } from 'react-redux';
|
|
6
6
|
import 'react-router-config';
|
|
7
7
|
import 'jsonpath-mapper';
|
|
8
8
|
import 'immutable';
|
|
@@ -11,23 +11,128 @@ import 'redux-immutable';
|
|
|
11
11
|
import 'redux-thunk';
|
|
12
12
|
import 'redux-saga';
|
|
13
13
|
import 'redux-injectors';
|
|
14
|
-
import './
|
|
15
|
-
import './actions-
|
|
16
|
-
import './reducers-
|
|
14
|
+
import { c as createStore, s as setVersionStatus } from './version-64906b26.js';
|
|
15
|
+
import { s as setCurrentProject } from './actions-ddd9c623.js';
|
|
16
|
+
import { o as fromJSOrdered } from './reducers-feab84fc.js';
|
|
17
17
|
import 'history';
|
|
18
|
-
|
|
18
|
+
import { d as deliveryApi, r as rootSaga, p as pickProject, b as browserHistory } from './App-d468b2a6.js';
|
|
19
|
+
export { A as ReactApp } from './App-d468b2a6.js';
|
|
19
20
|
import '@redux-saga/core/effects';
|
|
20
21
|
import 'contensis-delivery-api';
|
|
21
22
|
import './version-7fdbd2d5.js';
|
|
22
|
-
import 'query-string';
|
|
23
|
-
import './selectors-
|
|
23
|
+
import { parse } from 'query-string';
|
|
24
|
+
import './selectors-68799788.js';
|
|
24
25
|
import 'loglevel';
|
|
25
|
-
import './ToJs-
|
|
26
|
-
import './login-
|
|
26
|
+
import './ToJs-6e7b247c.js';
|
|
27
|
+
import './login-1f9ad133.js';
|
|
27
28
|
import 'await-to-js';
|
|
28
29
|
import 'js-cookie';
|
|
29
|
-
import 'react-hot-loader';
|
|
30
|
-
import '
|
|
31
|
-
import '
|
|
32
|
-
|
|
30
|
+
import { AppContainer } from 'react-hot-loader';
|
|
31
|
+
import './RouteLoader-281d47e1.js';
|
|
32
|
+
import { hydrate, render } from 'react-dom';
|
|
33
|
+
|
|
34
|
+
const fromJSLeaveImmer = js => {
|
|
35
|
+
// console.info(js);
|
|
36
|
+
// if (typeof js !== 'object' || js === null) return js;
|
|
37
|
+
// // console.info(`from js - here is js ${JSON.stringify(js)}`);
|
|
38
|
+
// const convertedObject = isOrdered ? OrderedMap() : fromJS({});
|
|
39
|
+
// const keys = Object.keys(js);
|
|
40
|
+
// keys.forEach(key => {
|
|
41
|
+
// if (key === 'immer') {
|
|
42
|
+
// convertedObject.set(key, js[key]);
|
|
43
|
+
// // console.info(`LOOK! - immer untouched bar root key "${key}"`);
|
|
44
|
+
// } else {
|
|
45
|
+
// // console.info(`LOOK! - normal immutable feature "${key}"`);
|
|
46
|
+
// convertedObject.set(key, isOrdered ? fromJSOrdered(js) : fromJS(js));
|
|
47
|
+
// }
|
|
48
|
+
// });
|
|
49
|
+
const immutableObj = fromJSOrdered(js);
|
|
50
|
+
|
|
51
|
+
if (immutableObj && !!immutableObj.get('immer')) {
|
|
52
|
+
immutableObj.set('immer', immutableObj.get('immer').toJS());
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return immutableObj;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
class ClientApp {
|
|
59
|
+
constructor(ReactApp, config) {
|
|
60
|
+
const documentRoot = document.getElementById('root');
|
|
61
|
+
const {
|
|
62
|
+
routes,
|
|
63
|
+
withReducers,
|
|
64
|
+
withSagas,
|
|
65
|
+
withEvents
|
|
66
|
+
} = config;
|
|
67
|
+
|
|
68
|
+
const GetClientJSX = store => {
|
|
69
|
+
const ClientJsx = /*#__PURE__*/React.createElement(AppContainer, null, /*#__PURE__*/React.createElement(Provider, {
|
|
70
|
+
store: store
|
|
71
|
+
}, /*#__PURE__*/React.createElement(Router, {
|
|
72
|
+
history: browserHistory
|
|
73
|
+
}, /*#__PURE__*/React.createElement(ReactApp, {
|
|
74
|
+
routes: routes,
|
|
75
|
+
withEvents: withEvents
|
|
76
|
+
}))));
|
|
77
|
+
return ClientJsx;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const isProduction = !(process.env.NODE_ENV !== 'production');
|
|
81
|
+
/**
|
|
82
|
+
* Webpack HMR Setup.
|
|
83
|
+
*/
|
|
84
|
+
|
|
85
|
+
const HMRRenderer = Component => {
|
|
86
|
+
preloadReady().then(() => {
|
|
87
|
+
if (isProduction) hydrate(Component, documentRoot);else render(Component, documentRoot);
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
let store = null;
|
|
92
|
+
const qs = parse(window.location.search);
|
|
93
|
+
const versionStatusFromHostname = deliveryApi.getClientSideVersionStatus();
|
|
94
|
+
|
|
95
|
+
if (window.isDynamic || window.REDUX_DATA || process.env.NODE_ENV !== 'production') {
|
|
96
|
+
store = createStore(withReducers, fromJSLeaveImmer(window.REDUX_DATA), browserHistory);
|
|
97
|
+
store.dispatch(setVersionStatus(qs.versionStatus || versionStatusFromHostname));
|
|
98
|
+
/* eslint-disable no-console */
|
|
99
|
+
|
|
100
|
+
console.log('Hydrating from inline Redux');
|
|
101
|
+
/* eslint-enable no-console */
|
|
102
|
+
|
|
103
|
+
store.runSaga(rootSaga(withSagas));
|
|
104
|
+
store.dispatch(setCurrentProject(pickProject(window.location.hostname, qs), [], window.location.hostname));
|
|
105
|
+
delete window.REDUX_DATA;
|
|
106
|
+
HMRRenderer(GetClientJSX(store));
|
|
107
|
+
} else {
|
|
108
|
+
fetch(`${window.location.pathname}?redux=true`).then(response => response.json()).then(data => {
|
|
109
|
+
/* eslint-disable no-console */
|
|
110
|
+
// console.log('Got Data Back');
|
|
111
|
+
// console.log(data);
|
|
112
|
+
|
|
113
|
+
/* eslint-enable no-console */
|
|
114
|
+
const ssRedux = JSON.parse(data);
|
|
115
|
+
store = createStore(withReducers, fromJSLeaveImmer(ssRedux), browserHistory); // store.dispatch(setVersionStatus(versionStatusFromHostname));
|
|
116
|
+
|
|
117
|
+
store.runSaga(rootSaga(withSagas));
|
|
118
|
+
store.dispatch(setCurrentProject(pickProject(window.location.hostname, parse(window.location.search)), [], window.location.hostname)); // if (typeof window != 'undefined') {
|
|
119
|
+
// store.dispatch(checkUserLoggedIn());
|
|
120
|
+
// }
|
|
121
|
+
|
|
122
|
+
HMRRenderer(GetClientJSX(store));
|
|
123
|
+
});
|
|
124
|
+
} // webpack Hot Module Replacement API
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
if (module.hot) {
|
|
128
|
+
module.hot.accept(ReactApp, () => {
|
|
129
|
+
// if you are using harmony modules ({modules:false})
|
|
130
|
+
HMRRenderer(GetClientJSX(store));
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export default ClientApp;
|
|
33
138
|
//# sourceMappingURL=client.js.map
|
package/esm/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.js","sources":["../src/util/fromJSLeaveImmer.js","../src/client/client.tsx"],"sourcesContent":["import fromJSOrdered from './fromJSOrdered';\n\nconst fromJSLeaveImmer = js => {\n // console.info(js);\n // if (typeof js !== 'object' || js === null) return js;\n // // console.info(`from js - here is js ${JSON.stringify(js)}`);\n // const convertedObject = isOrdered ? OrderedMap() : fromJS({});\n // const keys = Object.keys(js);\n // keys.forEach(key => {\n // if (key === 'immer') {\n // convertedObject.set(key, js[key]);\n // // console.info(`LOOK! - immer untouched bar root key \"${key}\"`);\n // } else {\n // // console.info(`LOOK! - normal immutable feature \"${key}\"`);\n // convertedObject.set(key, isOrdered ? fromJSOrdered(js) : fromJS(js));\n // }\n // });\n const immutableObj = fromJSOrdered(js);\n if (immutableObj && !!immutableObj.get('immer')) {\n immutableObj.set('immer', immutableObj.get('immer').toJS());\n }\n return immutableObj;\n};\nexport default fromJSLeaveImmer;\n","import 'isomorphic-fetch';\nimport React from 'react';\nimport { render, hydrate } from 'react-dom';\nimport { Router } from 'react-router-dom';\nimport { preloadReady } from 'react-loadable';\nimport { AppContainer } from 'react-hot-loader';\nimport { Provider as ReduxProvider } from 'react-redux';\nimport * as queryString from 'query-string';\n// import { fromJS } from 'immutable';\n\nimport createStore from '~/redux/store/store';\nimport { browserHistory as history } from '~/redux/store/history';\nimport rootSaga from '~/redux/sagas';\n\nimport { setVersionStatus } from '~/redux/actions/version';\nimport { deliveryApi } from '~/util/ContensisDeliveryApi';\nimport { setCurrentProject } from '~/routing/redux/actions';\nimport pickProject from '~/util/pickProject';\n// import fromJSOrdered from '~/util/fromJSOrdered';\nimport fromJSLeaveImmer from '~/util/fromJSLeaveImmer';\n\nimport { AppConfig } from '~/config';\n\ndeclare let window: typeof globalThis & {\n isDynamic;\n REDUX_DATA;\n};\n\ntype ReactAppProps = { routes: any; withEvents: any };\n\nclass ClientApp {\n constructor(ReactApp: React.ComponentType<ReactAppProps>, config: AppConfig) {\n const documentRoot = document.getElementById('root');\n\n const { routes, withReducers, withSagas, withEvents } = config;\n\n const GetClientJSX = store => {\n const ClientJsx = (\n <AppContainer>\n <ReduxProvider store={store}>\n <Router history={history}>\n <ReactApp routes={routes} withEvents={withEvents} />\n </Router>\n </ReduxProvider>\n </AppContainer>\n );\n return ClientJsx;\n };\n\n const isProduction = !(process.env.NODE_ENV !== 'production');\n\n /**\n * Webpack HMR Setup.\n */\n const HMRRenderer = Component => {\n preloadReady().then(() => {\n if (isProduction) hydrate(Component, documentRoot);\n else render(Component, documentRoot);\n });\n };\n let store: any = null;\n const qs = queryString.parse(window.location.search);\n\n const versionStatusFromHostname = deliveryApi.getClientSideVersionStatus();\n if (\n window.isDynamic ||\n window.REDUX_DATA ||\n process.env.NODE_ENV !== 'production'\n ) {\n store = createStore(\n withReducers,\n fromJSLeaveImmer(window.REDUX_DATA),\n history\n );\n store.dispatch(\n setVersionStatus(qs.versionStatus || versionStatusFromHostname)\n );\n\n /* eslint-disable no-console */\n console.log('Hydrating from inline Redux');\n /* eslint-enable no-console */\n store.runSaga(rootSaga(withSagas));\n store.dispatch(\n setCurrentProject(\n pickProject(window.location.hostname, qs),\n [],\n window.location.hostname\n )\n );\n\n delete window.REDUX_DATA;\n HMRRenderer(GetClientJSX(store));\n } else {\n fetch(`${window.location.pathname}?redux=true`)\n .then(response => response.json())\n .then(data => {\n /* eslint-disable no-console */\n // console.log('Got Data Back');\n // console.log(data);\n /* eslint-enable no-console */\n const ssRedux = JSON.parse(data);\n store = createStore(withReducers, fromJSLeaveImmer(ssRedux), history);\n // store.dispatch(setVersionStatus(versionStatusFromHostname));\n\n store.runSaga(rootSaga(withSagas));\n store.dispatch(\n setCurrentProject(\n pickProject(\n window.location.hostname,\n queryString.parse(window.location.search)\n ),\n [],\n window.location.hostname\n )\n );\n // if (typeof window != 'undefined') {\n // store.dispatch(checkUserLoggedIn());\n // }\n HMRRenderer(GetClientJSX(store));\n });\n }\n\n // webpack Hot Module Replacement API\n if (module.hot) {\n module.hot.accept(ReactApp as unknown as string, () => {\n // if you are using harmony modules ({modules:false})\n HMRRenderer(GetClientJSX(store));\n });\n }\n }\n}\n\nexport default ClientApp;\n"],"names":["fromJSLeaveImmer","js","immutableObj","fromJSOrdered","get","set","toJS","ClientApp","constructor","ReactApp","config","documentRoot","document","getElementById","routes","withReducers","withSagas","withEvents","GetClientJSX","store","ClientJsx","ReduxProvider","history","isProduction","process","env","NODE_ENV","HMRRenderer","Component","preloadReady","then","hydrate","render","qs","queryString","window","location","search","versionStatusFromHostname","deliveryApi","getClientSideVersionStatus","isDynamic","REDUX_DATA","createStore","dispatch","setVersionStatus","versionStatus","console","log","runSaga","rootSaga","setCurrentProject","pickProject","hostname","fetch","pathname","response","json","data","ssRedux","JSON","parse","module","hot","accept"],"mappings":"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"}
|
|
@@ -4,43 +4,42 @@ import Loadable from 'react-loadable';
|
|
|
4
4
|
import httpProxy from 'http-proxy';
|
|
5
5
|
import fs from 'fs';
|
|
6
6
|
import path from 'path';
|
|
7
|
+
import { path as path$1 } from 'app-root-path';
|
|
7
8
|
import React from 'react';
|
|
9
|
+
import { renderToString } from 'react-dom/server';
|
|
8
10
|
import { StaticRouter } from 'react-router-dom';
|
|
9
11
|
import { Provider } from 'react-redux';
|
|
10
|
-
import { renderToString } from 'react-dom/server';
|
|
11
12
|
import { matchRoutes } from 'react-router-config';
|
|
12
|
-
import { getBundles } from 'react-loadable/webpack';
|
|
13
|
-
import { ServerStyleSheet } from 'styled-components';
|
|
14
13
|
import Helmet from 'react-helmet';
|
|
14
|
+
import { ServerStyleSheet } from 'styled-components';
|
|
15
15
|
import serialize from 'serialize-javascript';
|
|
16
16
|
import minifyCssString from 'minify-css-string';
|
|
17
17
|
import mapJson from 'jsonpath-mapper';
|
|
18
|
+
import { ChunkExtractor, ChunkExtractorManager } from '@loadable/server';
|
|
18
19
|
import { fromJS } from 'immutable';
|
|
19
20
|
import 'redux';
|
|
20
21
|
import 'redux-immutable';
|
|
21
22
|
import 'redux-thunk';
|
|
22
23
|
import 'redux-saga';
|
|
23
24
|
import 'redux-injectors';
|
|
24
|
-
import { c as createStore } from './
|
|
25
|
-
import { s as setCurrentProject } from './actions-
|
|
26
|
-
import './reducers-
|
|
25
|
+
import { c as createStore, s as setVersionStatus, a as setVersion } from './version-64906b26.js';
|
|
26
|
+
import { s as setCurrentProject } from './actions-ddd9c623.js';
|
|
27
|
+
import './reducers-feab84fc.js';
|
|
27
28
|
import 'history';
|
|
28
|
-
import {
|
|
29
|
-
export { A as ReactApp } from './App-
|
|
30
|
-
import
|
|
29
|
+
import { h as history, d as deliveryApi, p as pickProject, r as rootSaga } from './App-d468b2a6.js';
|
|
30
|
+
export { A as ReactApp } from './App-d468b2a6.js';
|
|
31
|
+
import '@redux-saga/core/effects';
|
|
31
32
|
import 'contensis-delivery-api';
|
|
32
33
|
import './version-7fdbd2d5.js';
|
|
33
34
|
import 'query-string';
|
|
34
|
-
import { s as selectRouteEntry, a as selectCurrentProject } from './selectors-
|
|
35
|
+
import { s as selectRouteEntry, a as selectCurrentProject } from './selectors-68799788.js';
|
|
35
36
|
import 'loglevel';
|
|
36
|
-
import './ToJs-
|
|
37
|
-
import
|
|
37
|
+
import './ToJs-6e7b247c.js';
|
|
38
|
+
import './login-1f9ad133.js';
|
|
38
39
|
import 'await-to-js';
|
|
39
40
|
import 'js-cookie';
|
|
40
|
-
import { s as setVersionStatus, a as setVersion } from './version-937d57fb.js';
|
|
41
41
|
import 'react-hot-loader';
|
|
42
|
-
import '
|
|
43
|
-
import './RouteLoader-2cfdfc5c.js';
|
|
42
|
+
import './RouteLoader-281d47e1.js';
|
|
44
43
|
|
|
45
44
|
const servers = SERVERS;
|
|
46
45
|
/* global SERVERS */
|
|
@@ -67,7 +66,7 @@ const servers$1 = SERVERS;
|
|
|
67
66
|
|
|
68
67
|
const apiProxy = httpProxy.createProxyServer();
|
|
69
68
|
|
|
70
|
-
const reverseProxies = (app, reverseProxyPaths) => {
|
|
69
|
+
const reverseProxies = (app, reverseProxyPaths = []) => {
|
|
71
70
|
deliveryApiProxy(apiProxy, app);
|
|
72
71
|
app.all(reverseProxyPaths, (req, res) => {
|
|
73
72
|
const target = req.hostname.indexOf('preview-') || req.hostname.indexOf('preview.') || req.hostname === 'localhost' ? servers$1.previewIis || servers$1.iis : servers$1.iis;
|
|
@@ -114,7 +113,7 @@ const getCacheDuration = (status = 200) => {
|
|
|
114
113
|
return CacheDuration[200];
|
|
115
114
|
};
|
|
116
115
|
|
|
117
|
-
const replaceStaticPath = (
|
|
116
|
+
const replaceStaticPath = (str, staticFolderPath = 'static') => str.replace(/static\//g, `${staticFolderPath}/`);
|
|
118
117
|
|
|
119
118
|
const bundleManipulationMiddleware = ({
|
|
120
119
|
appRootPath,
|
|
@@ -174,8 +173,9 @@ const resolveStartupMiddleware = ({
|
|
|
174
173
|
}
|
|
175
174
|
};
|
|
176
175
|
|
|
176
|
+
// Serving static assets
|
|
177
177
|
const staticAssets = (app, {
|
|
178
|
-
appRootPath =
|
|
178
|
+
appRootPath = path$1,
|
|
179
179
|
scripts = {},
|
|
180
180
|
startupScriptFilename = 'startup.js',
|
|
181
181
|
staticFolderPath = 'static',
|
|
@@ -193,54 +193,108 @@ const staticAssets = (app, {
|
|
|
193
193
|
maxage: CacheDuration.static,
|
|
194
194
|
startupScriptFilename: scripts.startup || startupScriptFilename,
|
|
195
195
|
staticFolderPath
|
|
196
|
-
}),
|
|
196
|
+
}), // eslint-disable-next-line import/no-named-as-default-member
|
|
197
|
+
express.static(`dist/${staticFolderPath}`, {
|
|
197
198
|
// these maxage values are different in config but the same in runtime,
|
|
198
199
|
// this one is somehow converted and should end up being the same as CacheDuration.static
|
|
199
|
-
|
|
200
|
+
maxAge: CacheDuration.expressStatic
|
|
200
201
|
}));
|
|
201
202
|
};
|
|
202
203
|
|
|
203
|
-
/*! fromentries. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
204
|
-
var fromentries = function fromEntries (iterable) {
|
|
205
|
-
return [...iterable].reduce((obj, [key, val]) => {
|
|
206
|
-
obj[key] = val;
|
|
207
|
-
return obj
|
|
208
|
-
}, {})
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
const userSagas = [...loginSagas, ...registerSagas];
|
|
212
|
-
|
|
213
|
-
// index.js
|
|
214
|
-
function rootSaga (featureSagas = []) {
|
|
215
|
-
return function* rootSaga() {
|
|
216
|
-
const subSagas = [...routingSagas, ...navigationSagas, ...userSagas];
|
|
217
|
-
yield all([...subSagas, ...featureSagas]);
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
const ResponseMethod = {
|
|
222
|
-
send: 'send',
|
|
223
|
-
json: 'json',
|
|
224
|
-
end: 'end'
|
|
225
|
-
};
|
|
226
|
-
|
|
227
204
|
/* eslint-disable no-console */
|
|
205
|
+
|
|
228
206
|
/**
|
|
229
207
|
* Web Application Response handler, sends a prepared express js response
|
|
230
208
|
* with the supplied content sending in the specified manner
|
|
231
209
|
* @param {response} request express js request object
|
|
232
210
|
* @param {response} response express js response object
|
|
233
211
|
* @param {string | object} content the content to send in the response body
|
|
234
|
-
* @param {
|
|
212
|
+
* @param {"send" | "json" | "end"} send the response function to call e.g res.send() res.json() res.end()
|
|
235
213
|
*/
|
|
236
|
-
|
|
237
|
-
const handleResponse = (request, response, content, send = ResponseMethod.send) => {
|
|
214
|
+
const handleResponse = (request, response, content, send = 'send') => {
|
|
238
215
|
// console.log('---', response.statusCode, '---');
|
|
239
216
|
response[send](content);
|
|
240
217
|
};
|
|
241
218
|
|
|
242
219
|
var stringifyAttributes = ((attributes = {}) => Object.entries(attributes).map(([key, value], idx) => `${idx !== 0 ? ' ' : ''}${key}${value ? `="${value}"` : ''}`).join(' '));
|
|
243
220
|
|
|
221
|
+
const readFileSync = path => fs.readFileSync(path, 'utf8');
|
|
222
|
+
|
|
223
|
+
const loadableBundleData = ({
|
|
224
|
+
stats,
|
|
225
|
+
templates
|
|
226
|
+
}, staticRoutePath, build) => {
|
|
227
|
+
const bundle = {};
|
|
228
|
+
|
|
229
|
+
try {
|
|
230
|
+
bundle.stats = JSON.parse(readFileSync(stats.replace('/target', build ? `/${build}` : '')));
|
|
231
|
+
} catch (ex) {
|
|
232
|
+
// console.info(ex);
|
|
233
|
+
bundle.stats = null;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
try {
|
|
237
|
+
bundle.templates = {
|
|
238
|
+
templateHTML: replaceStaticPath(readFileSync(templates.html.replace('/target', build ? `/${build}` : '')), staticRoutePath),
|
|
239
|
+
templateHTMLStatic: replaceStaticPath(readFileSync(templates.static.replace('/target', build ? `/${build}` : '')), staticRoutePath),
|
|
240
|
+
templateHTMLFragment: replaceStaticPath(readFileSync(templates.fragment.replace('/target', build ? `/${build}` : '')), staticRoutePath)
|
|
241
|
+
};
|
|
242
|
+
} catch (ex) {
|
|
243
|
+
// console.info(ex);
|
|
244
|
+
bundle.templates = null;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
return bundle;
|
|
248
|
+
};
|
|
249
|
+
const loadableChunkExtractors = () => {
|
|
250
|
+
try {
|
|
251
|
+
const modern = new ChunkExtractor({
|
|
252
|
+
entrypoints: ['app'],
|
|
253
|
+
namespace: 'modern',
|
|
254
|
+
statsFile: path.resolve('dist/modern/loadable-stats.json')
|
|
255
|
+
});
|
|
256
|
+
const legacy = new ChunkExtractor({
|
|
257
|
+
entrypoints: ['app'],
|
|
258
|
+
namespace: 'legacy',
|
|
259
|
+
statsFile: path.resolve('dist/legacy/loadable-stats.json')
|
|
260
|
+
});
|
|
261
|
+
const commonLoadableExtractor = {
|
|
262
|
+
addChunk(chunk) {
|
|
263
|
+
modern.addChunk(chunk);
|
|
264
|
+
if (typeof legacy.stats.assetsByChunkName[chunk] !== 'undefined') legacy.addChunk(chunk);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
};
|
|
268
|
+
return {
|
|
269
|
+
commonLoadableExtractor,
|
|
270
|
+
modern,
|
|
271
|
+
legacy
|
|
272
|
+
};
|
|
273
|
+
} catch (e) {
|
|
274
|
+
console.info('@loadable/server ChunkExtractor not available');
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
const getBundleData = (config, staticRoutePath) => {
|
|
278
|
+
const bundleData = {
|
|
279
|
+
default: loadableBundleData(config, staticRoutePath),
|
|
280
|
+
legacy: loadableBundleData(config, staticRoutePath, 'legacy'),
|
|
281
|
+
modern: loadableBundleData(config, staticRoutePath, 'modern')
|
|
282
|
+
};
|
|
283
|
+
if (!bundleData.default || bundleData.default === {}) bundleData.default = bundleData.legacy || bundleData.modern;
|
|
284
|
+
return bundleData;
|
|
285
|
+
};
|
|
286
|
+
const getBundleTags = loadableExtractor => {
|
|
287
|
+
if (loadableExtractor) {
|
|
288
|
+
const legacyScriptTags = loadableExtractor === null || loadableExtractor === void 0 ? void 0 : loadableExtractor.legacy.getScriptTags({
|
|
289
|
+
noModule: true
|
|
290
|
+
});
|
|
291
|
+
const modernScriptTags = loadableExtractor === null || loadableExtractor === void 0 ? void 0 : loadableExtractor.modern.getScriptTags({
|
|
292
|
+
type: 'module'
|
|
293
|
+
});
|
|
294
|
+
return legacyScriptTags + modernScriptTags;
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
|
|
244
298
|
const addStandardHeaders = (state, response, packagejson, groups) => {
|
|
245
299
|
if (state) {
|
|
246
300
|
try {
|
|
@@ -255,7 +309,6 @@ const addStandardHeaders = (state, response, packagejson, groups) => {
|
|
|
255
309
|
}
|
|
256
310
|
}
|
|
257
311
|
};
|
|
258
|
-
|
|
259
312
|
const addVarnishAuthenticationHeaders = (state, response, groups = {}) => {
|
|
260
313
|
if (state) {
|
|
261
314
|
try {
|
|
@@ -279,35 +332,6 @@ const addVarnishAuthenticationHeaders = (state, response, groups = {}) => {
|
|
|
279
332
|
}
|
|
280
333
|
};
|
|
281
334
|
|
|
282
|
-
const readFileSync = path => fs.readFileSync(path, 'utf8');
|
|
283
|
-
|
|
284
|
-
const loadableBundleData = ({
|
|
285
|
-
stats,
|
|
286
|
-
templates
|
|
287
|
-
}, staticRoutePath, build) => {
|
|
288
|
-
const bundle = {};
|
|
289
|
-
|
|
290
|
-
try {
|
|
291
|
-
bundle.stats = JSON.parse(readFileSync(stats.replace('/target', build ? `/${build}` : '')));
|
|
292
|
-
} catch (ex) {
|
|
293
|
-
//console.info(ex);
|
|
294
|
-
bundle.stats = null;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
try {
|
|
298
|
-
bundle.templates = {
|
|
299
|
-
templateHTML: replaceStaticPath(readFileSync(templates.html.replace('/target', build ? `/${build}` : '')), staticRoutePath),
|
|
300
|
-
templateHTMLStatic: replaceStaticPath(readFileSync(templates.static.replace('/target', build ? `/${build}` : '')), staticRoutePath),
|
|
301
|
-
templateHTMLFragment: replaceStaticPath(readFileSync(templates.fragment.replace('/target', build ? `/${build}` : '')), staticRoutePath)
|
|
302
|
-
};
|
|
303
|
-
} catch (ex) {
|
|
304
|
-
//console.info(ex);
|
|
305
|
-
bundle.templates = null;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
return bundle;
|
|
309
|
-
};
|
|
310
|
-
|
|
311
335
|
const webApp = (app, ReactApp, config) => {
|
|
312
336
|
const {
|
|
313
337
|
routes,
|
|
@@ -325,12 +349,7 @@ const webApp = (app, ReactApp, config) => {
|
|
|
325
349
|
handleResponses
|
|
326
350
|
} = config;
|
|
327
351
|
const staticRoutePath = config.staticRoutePath || staticFolderPath;
|
|
328
|
-
const bundleData =
|
|
329
|
-
default: loadableBundleData(config, staticRoutePath),
|
|
330
|
-
legacy: loadableBundleData(config, staticRoutePath, 'legacy'),
|
|
331
|
-
modern: loadableBundleData(config, staticRoutePath, 'modern')
|
|
332
|
-
};
|
|
333
|
-
if (!bundleData.default || bundleData.default === {}) bundleData.default = bundleData.legacy || bundleData.modern;
|
|
352
|
+
const bundleData = getBundleData(config, staticRoutePath);
|
|
334
353
|
const attributes = stringifyAttributes(scripts.attributes);
|
|
335
354
|
scripts.startup = scripts.startup || startupScriptFilename;
|
|
336
355
|
const responseHandler = typeof handleResponses === 'function' ? handleResponses : handleResponse;
|
|
@@ -381,9 +400,9 @@ const webApp = (app, ReactApp, config) => {
|
|
|
381
400
|
const project = pickProject(request.hostname, request.query);
|
|
382
401
|
const groups = allowedGroups && allowedGroups[project];
|
|
383
402
|
store.dispatch(setCurrentProject(project, groups, request.hostname));
|
|
384
|
-
const
|
|
385
|
-
const jsx = /*#__PURE__*/React.createElement(
|
|
386
|
-
|
|
403
|
+
const loadableExtractor = loadableChunkExtractors();
|
|
404
|
+
const jsx = /*#__PURE__*/React.createElement(ChunkExtractorManager, {
|
|
405
|
+
extractor: loadableExtractor === null || loadableExtractor === void 0 ? void 0 : loadableExtractor.commonLoadableExtractor
|
|
387
406
|
}, /*#__PURE__*/React.createElement(Provider, {
|
|
388
407
|
store: store
|
|
389
408
|
}, /*#__PURE__*/React.createElement(StaticRouter, {
|
|
@@ -393,33 +412,22 @@ const webApp = (app, ReactApp, config) => {
|
|
|
393
412
|
routes: routes,
|
|
394
413
|
withEvents: withEvents
|
|
395
414
|
}))));
|
|
396
|
-
|
|
397
|
-
const buildBundleTags = bundles => {
|
|
398
|
-
// Take the bundles returned from Loadable.Capture
|
|
399
|
-
const bundleTags = bundles.filter(b => b).map(bundle => {
|
|
400
|
-
if (bundle.publicPath.includes('/modern/')) return differentialBundles ? `<script ${attributes} type="module" src="${replaceStaticPath(bundle.publicPath, staticRoutePath)}"></script>` : null;
|
|
401
|
-
return `<script ${attributes} nomodule src="${replaceStaticPath(bundle.publicPath, staticRoutePath)}"></script>`;
|
|
402
|
-
}).filter(f => f); // Add the static startup script to the bundleTags
|
|
403
|
-
|
|
404
|
-
scripts.startup && bundleTags.push(`<script ${attributes} src="/${staticRoutePath}/${scripts.startup}"></script>`);
|
|
405
|
-
return bundleTags;
|
|
406
|
-
};
|
|
407
|
-
|
|
408
415
|
const templates = bundleData.default.templates || bundleData.legacy.templates;
|
|
409
|
-
const stats = bundleData.modern.stats && bundleData.legacy.stats ? fromentries(Object.entries(bundleData.modern.stats).map(([lib, paths]) => [lib, bundleData.legacy.stats[lib] ? [...paths, ...bundleData.legacy.stats[lib]] : paths])) : bundleData.default.stats;
|
|
410
416
|
const {
|
|
411
417
|
templateHTML,
|
|
412
418
|
templateHTMLFragment,
|
|
413
419
|
templateHTMLStatic
|
|
414
|
-
} = templates; // Serve a blank HTML page with client scripts to load the app in the browser
|
|
420
|
+
} = templates || {}; // Serve a blank HTML page with client scripts to load the app in the browser
|
|
415
421
|
|
|
416
422
|
if (accessMethod.DYNAMIC) {
|
|
417
423
|
// Dynamic doesn't need sagas
|
|
418
424
|
renderToString(jsx); // Dynamic page render has only the necessary bundles to start up the app
|
|
419
425
|
// and does not include any react-loadable code-split bundles
|
|
420
426
|
|
|
421
|
-
|
|
422
|
-
|
|
427
|
+
let bundleTags = ''; // Add the static startup script to the bundleTags
|
|
428
|
+
|
|
429
|
+
if (scripts.startup) bundleTags = `<script ${attributes} src="/${staticRoutePath}/${scripts.startup}"></script>`;
|
|
430
|
+
bundleTags += getBundleTags(loadableExtractor);
|
|
423
431
|
const isDynamicHint = `<script ${attributes}>window.isDynamic = true;</script>`;
|
|
424
432
|
const responseHtmlDynamic = templateHTML.replace('{{TITLE}}', '').replace('{{SEO_CRITICAL_METADATA}}', '').replace('{{CRITICAL_CSS}}', '').replace('{{APP}}', '').replace('{{LOADABLE_CHUNKS}}', bundleTags).replace('{{REDUX_DATA}}', isDynamicHint); // Dynamic pages always return a 200 so we can run
|
|
425
433
|
// the app and serve up all errors inside the client
|
|
@@ -447,11 +455,13 @@ const webApp = (app, ReactApp, config) => {
|
|
|
447
455
|
const styleTags = sheet.getStyleTags(); // After running rootSaga there should be an additional react-loadable
|
|
448
456
|
// code-split bundle for a page component as well as core app bundles
|
|
449
457
|
|
|
450
|
-
|
|
451
|
-
|
|
458
|
+
let bundleTags = ''; // Add the static startup script to the bundleTags
|
|
459
|
+
|
|
460
|
+
if (scripts.startup) bundleTags = `<script ${attributes} src="/${staticRoutePath}/${scripts.startup}"></script>`;
|
|
461
|
+
bundleTags += getBundleTags(loadableExtractor);
|
|
452
462
|
let serialisedReduxData = '';
|
|
453
463
|
|
|
454
|
-
if (context.
|
|
464
|
+
if (context.statusCode !== 404) {
|
|
455
465
|
// For a request that returns a redux state object as a response
|
|
456
466
|
if (accessMethod.REDUX) {
|
|
457
467
|
serialisedReduxData = serialize(reduxState, {
|
|
@@ -473,13 +483,13 @@ const webApp = (app, ReactApp, config) => {
|
|
|
473
483
|
}
|
|
474
484
|
}
|
|
475
485
|
|
|
476
|
-
if (context.
|
|
486
|
+
if ((context.statusCode || 200) > 400) {
|
|
477
487
|
accessMethod.STATIC = true;
|
|
478
488
|
} // Responses
|
|
479
489
|
|
|
480
490
|
|
|
481
491
|
let responseHTML = '';
|
|
482
|
-
if (context.
|
|
492
|
+
if (context.statusCode === 404) title = '<title>404 page not found</title>'; // Static page served as a fragment
|
|
483
493
|
|
|
484
494
|
if (accessMethod.FRAGMENT && accessMethod.STATIC) {
|
|
485
495
|
responseHTML = minifyCssString(styleTags) + html;
|
|
@@ -501,7 +511,7 @@ const webApp = (app, ReactApp, config) => {
|
|
|
501
511
|
} // Set response.status from React StaticRouter
|
|
502
512
|
|
|
503
513
|
|
|
504
|
-
if (typeof context.
|
|
514
|
+
if (typeof context.statusCode === 'number') response.status(context.statusCode);
|
|
505
515
|
addStandardHeaders(reduxState, response, packagejson, {
|
|
506
516
|
allowedGroups,
|
|
507
517
|
globalGroups
|
|
@@ -536,9 +546,9 @@ const app = express();
|
|
|
536
546
|
|
|
537
547
|
const start = (ReactApp, config, ServerFeatures) => {
|
|
538
548
|
global.PACKAGE_JSON = config.packagejson;
|
|
539
|
-
global.REVERSE_PROXY_PATHS = Object(config.reverseProxyPaths);
|
|
540
|
-
global.PROXY_DELIVERY_API = config.proxyDeliveryApi;
|
|
541
549
|
global.DISABLE_SSR_REDUX = config.disableSsrRedux;
|
|
550
|
+
global.PROXY_DELIVERY_API = config.proxyDeliveryApi;
|
|
551
|
+
global.REVERSE_PROXY_PATHS = Object(config.reverseProxyPaths);
|
|
542
552
|
app.disable('x-powered-by'); // Output some information about the used build/startup configuration
|
|
543
553
|
|
|
544
554
|
DisplayStartupConfiguration(config);
|
|
@@ -550,9 +560,9 @@ const start = (ReactApp, config, ServerFeatures) => {
|
|
|
550
560
|
webApp(app, ReactApp, config);
|
|
551
561
|
app.on('ready', async () => {
|
|
552
562
|
// Configure DNS to make life easier
|
|
553
|
-
//await ConfigureLocalDNS();
|
|
563
|
+
// await ConfigureLocalDNS();
|
|
554
564
|
Loadable.preloadAll().then(() => {
|
|
555
|
-
|
|
565
|
+
const server = app.listen(3001, () => {
|
|
556
566
|
console.info(`HTTP server is listening @ port 3001`);
|
|
557
567
|
setTimeout(function () {
|
|
558
568
|
app.emit('app_started');
|