@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/cjs/client.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
require('isomorphic-fetch');
|
|
6
|
-
require('react-loadable');
|
|
7
|
-
require('react');
|
|
8
|
-
require('react-router-dom');
|
|
9
|
-
require('react-redux');
|
|
6
|
+
var Loadable = require('react-loadable');
|
|
7
|
+
var React = require('react');
|
|
8
|
+
var reactRouterDom = require('react-router-dom');
|
|
9
|
+
var reactRedux = require('react-redux');
|
|
10
10
|
require('react-router-config');
|
|
11
11
|
require('jsonpath-mapper');
|
|
12
12
|
require('immutable');
|
|
@@ -15,27 +15,132 @@ require('redux-immutable');
|
|
|
15
15
|
require('redux-thunk');
|
|
16
16
|
require('redux-saga');
|
|
17
17
|
require('redux-injectors');
|
|
18
|
-
require('./
|
|
19
|
-
require('./actions-
|
|
20
|
-
require('./reducers-
|
|
18
|
+
var version = require('./version-3a808c12.js');
|
|
19
|
+
var actions = require('./actions-e9f69947.js');
|
|
20
|
+
var reducers = require('./reducers-cb531715.js');
|
|
21
21
|
require('history');
|
|
22
|
-
var App = require('./App-
|
|
22
|
+
var App = require('./App-8f560cc5.js');
|
|
23
23
|
require('@redux-saga/core/effects');
|
|
24
24
|
require('contensis-delivery-api');
|
|
25
25
|
require('./version-2193b4a2.js');
|
|
26
|
-
require('query-string');
|
|
27
|
-
require('./selectors-
|
|
26
|
+
var queryString = require('query-string');
|
|
27
|
+
require('./selectors-1295124a.js');
|
|
28
28
|
require('loglevel');
|
|
29
|
-
require('./ToJs-
|
|
30
|
-
require('./login-
|
|
29
|
+
require('./ToJs-d72e5b10.js');
|
|
30
|
+
require('./login-4f274c6a.js');
|
|
31
31
|
require('await-to-js');
|
|
32
32
|
require('js-cookie');
|
|
33
|
-
require('react-hot-loader');
|
|
34
|
-
require('
|
|
35
|
-
require('
|
|
36
|
-
require('react-dom');
|
|
33
|
+
var reactHotLoader = require('react-hot-loader');
|
|
34
|
+
require('./RouteLoader-f99cd734.js');
|
|
35
|
+
var reactDom = require('react-dom');
|
|
37
36
|
|
|
37
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
38
38
|
|
|
39
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
40
|
+
|
|
41
|
+
const fromJSLeaveImmer = js => {
|
|
42
|
+
// console.info(js);
|
|
43
|
+
// if (typeof js !== 'object' || js === null) return js;
|
|
44
|
+
// // console.info(`from js - here is js ${JSON.stringify(js)}`);
|
|
45
|
+
// const convertedObject = isOrdered ? OrderedMap() : fromJS({});
|
|
46
|
+
// const keys = Object.keys(js);
|
|
47
|
+
// keys.forEach(key => {
|
|
48
|
+
// if (key === 'immer') {
|
|
49
|
+
// convertedObject.set(key, js[key]);
|
|
50
|
+
// // console.info(`LOOK! - immer untouched bar root key "${key}"`);
|
|
51
|
+
// } else {
|
|
52
|
+
// // console.info(`LOOK! - normal immutable feature "${key}"`);
|
|
53
|
+
// convertedObject.set(key, isOrdered ? fromJSOrdered(js) : fromJS(js));
|
|
54
|
+
// }
|
|
55
|
+
// });
|
|
56
|
+
const immutableObj = reducers.fromJSOrdered(js);
|
|
57
|
+
|
|
58
|
+
if (immutableObj && !!immutableObj.get('immer')) {
|
|
59
|
+
immutableObj.set('immer', immutableObj.get('immer').toJS());
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return immutableObj;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
class ClientApp {
|
|
66
|
+
constructor(ReactApp, config) {
|
|
67
|
+
const documentRoot = document.getElementById('root');
|
|
68
|
+
const {
|
|
69
|
+
routes,
|
|
70
|
+
withReducers,
|
|
71
|
+
withSagas,
|
|
72
|
+
withEvents
|
|
73
|
+
} = config;
|
|
74
|
+
|
|
75
|
+
const GetClientJSX = store => {
|
|
76
|
+
const ClientJsx = /*#__PURE__*/React__default['default'].createElement(reactHotLoader.AppContainer, null, /*#__PURE__*/React__default['default'].createElement(reactRedux.Provider, {
|
|
77
|
+
store: store
|
|
78
|
+
}, /*#__PURE__*/React__default['default'].createElement(reactRouterDom.Router, {
|
|
79
|
+
history: App.browserHistory
|
|
80
|
+
}, /*#__PURE__*/React__default['default'].createElement(ReactApp, {
|
|
81
|
+
routes: routes,
|
|
82
|
+
withEvents: withEvents
|
|
83
|
+
}))));
|
|
84
|
+
return ClientJsx;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const isProduction = !(process.env.NODE_ENV !== 'production');
|
|
88
|
+
/**
|
|
89
|
+
* Webpack HMR Setup.
|
|
90
|
+
*/
|
|
91
|
+
|
|
92
|
+
const HMRRenderer = Component => {
|
|
93
|
+
Loadable.preloadReady().then(() => {
|
|
94
|
+
if (isProduction) reactDom.hydrate(Component, documentRoot);else reactDom.render(Component, documentRoot);
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
let store = null;
|
|
99
|
+
const qs = queryString.parse(window.location.search);
|
|
100
|
+
const versionStatusFromHostname = App.deliveryApi.getClientSideVersionStatus();
|
|
101
|
+
|
|
102
|
+
if (window.isDynamic || window.REDUX_DATA || process.env.NODE_ENV !== 'production') {
|
|
103
|
+
store = version.createStore(withReducers, fromJSLeaveImmer(window.REDUX_DATA), App.browserHistory);
|
|
104
|
+
store.dispatch(version.setVersionStatus(qs.versionStatus || versionStatusFromHostname));
|
|
105
|
+
/* eslint-disable no-console */
|
|
106
|
+
|
|
107
|
+
console.log('Hydrating from inline Redux');
|
|
108
|
+
/* eslint-enable no-console */
|
|
109
|
+
|
|
110
|
+
store.runSaga(App.rootSaga(withSagas));
|
|
111
|
+
store.dispatch(actions.setCurrentProject(App.pickProject(window.location.hostname, qs), [], window.location.hostname));
|
|
112
|
+
delete window.REDUX_DATA;
|
|
113
|
+
HMRRenderer(GetClientJSX(store));
|
|
114
|
+
} else {
|
|
115
|
+
fetch(`${window.location.pathname}?redux=true`).then(response => response.json()).then(data => {
|
|
116
|
+
/* eslint-disable no-console */
|
|
117
|
+
// console.log('Got Data Back');
|
|
118
|
+
// console.log(data);
|
|
119
|
+
|
|
120
|
+
/* eslint-enable no-console */
|
|
121
|
+
const ssRedux = JSON.parse(data);
|
|
122
|
+
store = version.createStore(withReducers, fromJSLeaveImmer(ssRedux), App.browserHistory); // store.dispatch(setVersionStatus(versionStatusFromHostname));
|
|
123
|
+
|
|
124
|
+
store.runSaga(App.rootSaga(withSagas));
|
|
125
|
+
store.dispatch(actions.setCurrentProject(App.pickProject(window.location.hostname, queryString.parse(window.location.search)), [], window.location.hostname)); // if (typeof window != 'undefined') {
|
|
126
|
+
// store.dispatch(checkUserLoggedIn());
|
|
127
|
+
// }
|
|
128
|
+
|
|
129
|
+
HMRRenderer(GetClientJSX(store));
|
|
130
|
+
});
|
|
131
|
+
} // webpack Hot Module Replacement API
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
if (module.hot) {
|
|
135
|
+
module.hot.accept(ReactApp, () => {
|
|
136
|
+
// if you are using harmony modules ({modules:false})
|
|
137
|
+
HMRRenderer(GetClientJSX(store));
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
}
|
|
39
143
|
|
|
40
144
|
exports.ReactApp = App.AppRoot;
|
|
145
|
+
exports.default = ClientApp;
|
|
41
146
|
//# sourceMappingURL=client.js.map
|
package/cjs/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","React","AppContainer","ReduxProvider","Router","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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"}
|
|
@@ -8,42 +8,41 @@ var Loadable = require('react-loadable');
|
|
|
8
8
|
var httpProxy = require('http-proxy');
|
|
9
9
|
var fs = require('fs');
|
|
10
10
|
var path = require('path');
|
|
11
|
+
var appRootPath = require('app-root-path');
|
|
11
12
|
var React = require('react');
|
|
13
|
+
var server$1 = require('react-dom/server');
|
|
12
14
|
var reactRouterDom = require('react-router-dom');
|
|
13
15
|
var reactRedux = require('react-redux');
|
|
14
|
-
var server = require('react-dom/server');
|
|
15
16
|
var reactRouterConfig = require('react-router-config');
|
|
16
|
-
var webpack = require('react-loadable/webpack');
|
|
17
|
-
var styled = require('styled-components');
|
|
18
17
|
var Helmet = require('react-helmet');
|
|
18
|
+
var styled = require('styled-components');
|
|
19
19
|
var serialize = require('serialize-javascript');
|
|
20
20
|
var minifyCssString = require('minify-css-string');
|
|
21
21
|
var mapJson = require('jsonpath-mapper');
|
|
22
|
+
var server = require('@loadable/server');
|
|
22
23
|
var immutable = require('immutable');
|
|
23
24
|
require('redux');
|
|
24
25
|
require('redux-immutable');
|
|
25
26
|
require('redux-thunk');
|
|
26
27
|
require('redux-saga');
|
|
27
28
|
require('redux-injectors');
|
|
28
|
-
var
|
|
29
|
-
var actions = require('./actions-
|
|
30
|
-
require('./reducers-
|
|
29
|
+
var version = require('./version-3a808c12.js');
|
|
30
|
+
var actions = require('./actions-e9f69947.js');
|
|
31
|
+
require('./reducers-cb531715.js');
|
|
31
32
|
require('history');
|
|
32
|
-
var App = require('./App-
|
|
33
|
-
|
|
33
|
+
var App = require('./App-8f560cc5.js');
|
|
34
|
+
require('@redux-saga/core/effects');
|
|
34
35
|
require('contensis-delivery-api');
|
|
35
36
|
require('./version-2193b4a2.js');
|
|
36
37
|
require('query-string');
|
|
37
|
-
var selectors = require('./selectors-
|
|
38
|
+
var selectors = require('./selectors-1295124a.js');
|
|
38
39
|
require('loglevel');
|
|
39
|
-
require('./ToJs-
|
|
40
|
-
|
|
40
|
+
require('./ToJs-d72e5b10.js');
|
|
41
|
+
require('./login-4f274c6a.js');
|
|
41
42
|
require('await-to-js');
|
|
42
43
|
require('js-cookie');
|
|
43
|
-
var version = require('./version-7d8852f6.js');
|
|
44
44
|
require('react-hot-loader');
|
|
45
|
-
require('
|
|
46
|
-
require('./RouteLoader-5c44f039.js');
|
|
45
|
+
require('./RouteLoader-f99cd734.js');
|
|
47
46
|
|
|
48
47
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
49
48
|
|
|
@@ -83,7 +82,7 @@ const servers$1 = SERVERS;
|
|
|
83
82
|
|
|
84
83
|
const apiProxy = httpProxy__default['default'].createProxyServer();
|
|
85
84
|
|
|
86
|
-
const reverseProxies = (app, reverseProxyPaths) => {
|
|
85
|
+
const reverseProxies = (app, reverseProxyPaths = []) => {
|
|
87
86
|
deliveryApiProxy(apiProxy, app);
|
|
88
87
|
app.all(reverseProxyPaths, (req, res) => {
|
|
89
88
|
const target = req.hostname.indexOf('preview-') || req.hostname.indexOf('preview.') || req.hostname === 'localhost' ? servers$1.previewIis || servers$1.iis : servers$1.iis;
|
|
@@ -130,7 +129,7 @@ const getCacheDuration = (status = 200) => {
|
|
|
130
129
|
return CacheDuration[200];
|
|
131
130
|
};
|
|
132
131
|
|
|
133
|
-
const replaceStaticPath = (
|
|
132
|
+
const replaceStaticPath = (str, staticFolderPath = 'static') => str.replace(/static\//g, `${staticFolderPath}/`);
|
|
134
133
|
|
|
135
134
|
const bundleManipulationMiddleware = ({
|
|
136
135
|
appRootPath,
|
|
@@ -190,8 +189,9 @@ const resolveStartupMiddleware = ({
|
|
|
190
189
|
}
|
|
191
190
|
};
|
|
192
191
|
|
|
192
|
+
// Serving static assets
|
|
193
193
|
const staticAssets = (app, {
|
|
194
|
-
appRootPath =
|
|
194
|
+
appRootPath: appRootPath$1 = appRootPath.path,
|
|
195
195
|
scripts = {},
|
|
196
196
|
startupScriptFilename = 'startup.js',
|
|
197
197
|
staticFolderPath = 'static',
|
|
@@ -199,64 +199,118 @@ const staticAssets = (app, {
|
|
|
199
199
|
staticRoutePaths = []
|
|
200
200
|
}) => {
|
|
201
201
|
app.use([`/${staticRoutePath}`, ...staticRoutePaths.map(p => `/${p}`), `/${staticFolderPath}`], bundleManipulationMiddleware({
|
|
202
|
-
appRootPath,
|
|
202
|
+
appRootPath: appRootPath$1,
|
|
203
203
|
// these maxage values are different in config but the same in runtime,
|
|
204
204
|
// this one is the true value in seconds
|
|
205
205
|
maxage: CacheDuration.static,
|
|
206
206
|
staticRoutePath
|
|
207
207
|
}), resolveStartupMiddleware({
|
|
208
|
-
appRootPath,
|
|
208
|
+
appRootPath: appRootPath$1,
|
|
209
209
|
maxage: CacheDuration.static,
|
|
210
210
|
startupScriptFilename: scripts.startup || startupScriptFilename,
|
|
211
211
|
staticFolderPath
|
|
212
|
-
}),
|
|
212
|
+
}), // eslint-disable-next-line import/no-named-as-default-member
|
|
213
|
+
express__default['default'].static(`dist/${staticFolderPath}`, {
|
|
213
214
|
// these maxage values are different in config but the same in runtime,
|
|
214
215
|
// this one is somehow converted and should end up being the same as CacheDuration.static
|
|
215
|
-
|
|
216
|
+
maxAge: CacheDuration.expressStatic
|
|
216
217
|
}));
|
|
217
218
|
};
|
|
218
219
|
|
|
219
|
-
/*! fromentries. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
220
|
-
var fromentries = function fromEntries (iterable) {
|
|
221
|
-
return [...iterable].reduce((obj, [key, val]) => {
|
|
222
|
-
obj[key] = val;
|
|
223
|
-
return obj
|
|
224
|
-
}, {})
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
const userSagas = [...login.loginSagas, ...App.registerSagas];
|
|
228
|
-
|
|
229
|
-
// index.js
|
|
230
|
-
function rootSaga (featureSagas = []) {
|
|
231
|
-
return function* rootSaga() {
|
|
232
|
-
const subSagas = [...App.routingSagas, ...App.navigationSagas, ...userSagas];
|
|
233
|
-
yield effects.all([...subSagas, ...featureSagas]);
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
const ResponseMethod = {
|
|
238
|
-
send: 'send',
|
|
239
|
-
json: 'json',
|
|
240
|
-
end: 'end'
|
|
241
|
-
};
|
|
242
|
-
|
|
243
220
|
/* eslint-disable no-console */
|
|
221
|
+
|
|
244
222
|
/**
|
|
245
223
|
* Web Application Response handler, sends a prepared express js response
|
|
246
224
|
* with the supplied content sending in the specified manner
|
|
247
225
|
* @param {response} request express js request object
|
|
248
226
|
* @param {response} response express js response object
|
|
249
227
|
* @param {string | object} content the content to send in the response body
|
|
250
|
-
* @param {
|
|
228
|
+
* @param {"send" | "json" | "end"} send the response function to call e.g res.send() res.json() res.end()
|
|
251
229
|
*/
|
|
252
|
-
|
|
253
|
-
const handleResponse = (request, response, content, send = ResponseMethod.send) => {
|
|
230
|
+
const handleResponse = (request, response, content, send = 'send') => {
|
|
254
231
|
// console.log('---', response.statusCode, '---');
|
|
255
232
|
response[send](content);
|
|
256
233
|
};
|
|
257
234
|
|
|
258
235
|
var stringifyAttributes = ((attributes = {}) => Object.entries(attributes).map(([key, value], idx) => `${idx !== 0 ? ' ' : ''}${key}${value ? `="${value}"` : ''}`).join(' '));
|
|
259
236
|
|
|
237
|
+
const readFileSync = path => fs__default['default'].readFileSync(path, 'utf8');
|
|
238
|
+
|
|
239
|
+
const loadableBundleData = ({
|
|
240
|
+
stats,
|
|
241
|
+
templates
|
|
242
|
+
}, staticRoutePath, build) => {
|
|
243
|
+
const bundle = {};
|
|
244
|
+
|
|
245
|
+
try {
|
|
246
|
+
bundle.stats = JSON.parse(readFileSync(stats.replace('/target', build ? `/${build}` : '')));
|
|
247
|
+
} catch (ex) {
|
|
248
|
+
// console.info(ex);
|
|
249
|
+
bundle.stats = null;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
try {
|
|
253
|
+
bundle.templates = {
|
|
254
|
+
templateHTML: replaceStaticPath(readFileSync(templates.html.replace('/target', build ? `/${build}` : '')), staticRoutePath),
|
|
255
|
+
templateHTMLStatic: replaceStaticPath(readFileSync(templates.static.replace('/target', build ? `/${build}` : '')), staticRoutePath),
|
|
256
|
+
templateHTMLFragment: replaceStaticPath(readFileSync(templates.fragment.replace('/target', build ? `/${build}` : '')), staticRoutePath)
|
|
257
|
+
};
|
|
258
|
+
} catch (ex) {
|
|
259
|
+
// console.info(ex);
|
|
260
|
+
bundle.templates = null;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
return bundle;
|
|
264
|
+
};
|
|
265
|
+
const loadableChunkExtractors = () => {
|
|
266
|
+
try {
|
|
267
|
+
const modern = new server.ChunkExtractor({
|
|
268
|
+
entrypoints: ['app'],
|
|
269
|
+
namespace: 'modern',
|
|
270
|
+
statsFile: path__default['default'].resolve('dist/modern/loadable-stats.json')
|
|
271
|
+
});
|
|
272
|
+
const legacy = new server.ChunkExtractor({
|
|
273
|
+
entrypoints: ['app'],
|
|
274
|
+
namespace: 'legacy',
|
|
275
|
+
statsFile: path__default['default'].resolve('dist/legacy/loadable-stats.json')
|
|
276
|
+
});
|
|
277
|
+
const commonLoadableExtractor = {
|
|
278
|
+
addChunk(chunk) {
|
|
279
|
+
modern.addChunk(chunk);
|
|
280
|
+
if (typeof legacy.stats.assetsByChunkName[chunk] !== 'undefined') legacy.addChunk(chunk);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
};
|
|
284
|
+
return {
|
|
285
|
+
commonLoadableExtractor,
|
|
286
|
+
modern,
|
|
287
|
+
legacy
|
|
288
|
+
};
|
|
289
|
+
} catch (e) {
|
|
290
|
+
console.info('@loadable/server ChunkExtractor not available');
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
const getBundleData = (config, staticRoutePath) => {
|
|
294
|
+
const bundleData = {
|
|
295
|
+
default: loadableBundleData(config, staticRoutePath),
|
|
296
|
+
legacy: loadableBundleData(config, staticRoutePath, 'legacy'),
|
|
297
|
+
modern: loadableBundleData(config, staticRoutePath, 'modern')
|
|
298
|
+
};
|
|
299
|
+
if (!bundleData.default || bundleData.default === {}) bundleData.default = bundleData.legacy || bundleData.modern;
|
|
300
|
+
return bundleData;
|
|
301
|
+
};
|
|
302
|
+
const getBundleTags = loadableExtractor => {
|
|
303
|
+
if (loadableExtractor) {
|
|
304
|
+
const legacyScriptTags = loadableExtractor === null || loadableExtractor === void 0 ? void 0 : loadableExtractor.legacy.getScriptTags({
|
|
305
|
+
noModule: true
|
|
306
|
+
});
|
|
307
|
+
const modernScriptTags = loadableExtractor === null || loadableExtractor === void 0 ? void 0 : loadableExtractor.modern.getScriptTags({
|
|
308
|
+
type: 'module'
|
|
309
|
+
});
|
|
310
|
+
return legacyScriptTags + modernScriptTags;
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
|
|
260
314
|
const addStandardHeaders = (state, response, packagejson, groups) => {
|
|
261
315
|
if (state) {
|
|
262
316
|
try {
|
|
@@ -271,7 +325,6 @@ const addStandardHeaders = (state, response, packagejson, groups) => {
|
|
|
271
325
|
}
|
|
272
326
|
}
|
|
273
327
|
};
|
|
274
|
-
|
|
275
328
|
const addVarnishAuthenticationHeaders = (state, response, groups = {}) => {
|
|
276
329
|
if (state) {
|
|
277
330
|
try {
|
|
@@ -295,35 +348,6 @@ const addVarnishAuthenticationHeaders = (state, response, groups = {}) => {
|
|
|
295
348
|
}
|
|
296
349
|
};
|
|
297
350
|
|
|
298
|
-
const readFileSync = path => fs__default['default'].readFileSync(path, 'utf8');
|
|
299
|
-
|
|
300
|
-
const loadableBundleData = ({
|
|
301
|
-
stats,
|
|
302
|
-
templates
|
|
303
|
-
}, staticRoutePath, build) => {
|
|
304
|
-
const bundle = {};
|
|
305
|
-
|
|
306
|
-
try {
|
|
307
|
-
bundle.stats = JSON.parse(readFileSync(stats.replace('/target', build ? `/${build}` : '')));
|
|
308
|
-
} catch (ex) {
|
|
309
|
-
//console.info(ex);
|
|
310
|
-
bundle.stats = null;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
try {
|
|
314
|
-
bundle.templates = {
|
|
315
|
-
templateHTML: replaceStaticPath(readFileSync(templates.html.replace('/target', build ? `/${build}` : '')), staticRoutePath),
|
|
316
|
-
templateHTMLStatic: replaceStaticPath(readFileSync(templates.static.replace('/target', build ? `/${build}` : '')), staticRoutePath),
|
|
317
|
-
templateHTMLFragment: replaceStaticPath(readFileSync(templates.fragment.replace('/target', build ? `/${build}` : '')), staticRoutePath)
|
|
318
|
-
};
|
|
319
|
-
} catch (ex) {
|
|
320
|
-
//console.info(ex);
|
|
321
|
-
bundle.templates = null;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
return bundle;
|
|
325
|
-
};
|
|
326
|
-
|
|
327
351
|
const webApp = (app, ReactApp, config) => {
|
|
328
352
|
const {
|
|
329
353
|
routes,
|
|
@@ -341,12 +365,7 @@ const webApp = (app, ReactApp, config) => {
|
|
|
341
365
|
handleResponses
|
|
342
366
|
} = config;
|
|
343
367
|
const staticRoutePath = config.staticRoutePath || staticFolderPath;
|
|
344
|
-
const bundleData =
|
|
345
|
-
default: loadableBundleData(config, staticRoutePath),
|
|
346
|
-
legacy: loadableBundleData(config, staticRoutePath, 'legacy'),
|
|
347
|
-
modern: loadableBundleData(config, staticRoutePath, 'modern')
|
|
348
|
-
};
|
|
349
|
-
if (!bundleData.default || bundleData.default === {}) bundleData.default = bundleData.legacy || bundleData.modern;
|
|
368
|
+
const bundleData = getBundleData(config, staticRoutePath);
|
|
350
369
|
const attributes = stringifyAttributes(scripts.attributes);
|
|
351
370
|
scripts.startup = scripts.startup || startupScriptFilename;
|
|
352
371
|
const responseHandler = typeof handleResponses === 'function' ? handleResponses : handleResponse;
|
|
@@ -386,7 +405,7 @@ const webApp = (app, ReactApp, config) => {
|
|
|
386
405
|
|
|
387
406
|
response.status(200); // Create a store (with a memory history) from our current url
|
|
388
407
|
|
|
389
|
-
const store =
|
|
408
|
+
const store = version.createStore(withReducers, immutable.fromJS({}), App.history({
|
|
390
409
|
initialEntries: [url]
|
|
391
410
|
})); // dispatch any global and non-saga related actions before calling our JSX
|
|
392
411
|
|
|
@@ -397,9 +416,9 @@ const webApp = (app, ReactApp, config) => {
|
|
|
397
416
|
const project = App.pickProject(request.hostname, request.query);
|
|
398
417
|
const groups = allowedGroups && allowedGroups[project];
|
|
399
418
|
store.dispatch(actions.setCurrentProject(project, groups, request.hostname));
|
|
400
|
-
const
|
|
401
|
-
const jsx = /*#__PURE__*/React__default['default'].createElement(
|
|
402
|
-
|
|
419
|
+
const loadableExtractor = loadableChunkExtractors();
|
|
420
|
+
const jsx = /*#__PURE__*/React__default['default'].createElement(server.ChunkExtractorManager, {
|
|
421
|
+
extractor: loadableExtractor === null || loadableExtractor === void 0 ? void 0 : loadableExtractor.commonLoadableExtractor
|
|
403
422
|
}, /*#__PURE__*/React__default['default'].createElement(reactRedux.Provider, {
|
|
404
423
|
store: store
|
|
405
424
|
}, /*#__PURE__*/React__default['default'].createElement(reactRouterDom.StaticRouter, {
|
|
@@ -409,33 +428,22 @@ const webApp = (app, ReactApp, config) => {
|
|
|
409
428
|
routes: routes,
|
|
410
429
|
withEvents: withEvents
|
|
411
430
|
}))));
|
|
412
|
-
|
|
413
|
-
const buildBundleTags = bundles => {
|
|
414
|
-
// Take the bundles returned from Loadable.Capture
|
|
415
|
-
const bundleTags = bundles.filter(b => b).map(bundle => {
|
|
416
|
-
if (bundle.publicPath.includes('/modern/')) return differentialBundles ? `<script ${attributes} type="module" src="${replaceStaticPath(bundle.publicPath, staticRoutePath)}"></script>` : null;
|
|
417
|
-
return `<script ${attributes} nomodule src="${replaceStaticPath(bundle.publicPath, staticRoutePath)}"></script>`;
|
|
418
|
-
}).filter(f => f); // Add the static startup script to the bundleTags
|
|
419
|
-
|
|
420
|
-
scripts.startup && bundleTags.push(`<script ${attributes} src="/${staticRoutePath}/${scripts.startup}"></script>`);
|
|
421
|
-
return bundleTags;
|
|
422
|
-
};
|
|
423
|
-
|
|
424
431
|
const templates = bundleData.default.templates || bundleData.legacy.templates;
|
|
425
|
-
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;
|
|
426
432
|
const {
|
|
427
433
|
templateHTML,
|
|
428
434
|
templateHTMLFragment,
|
|
429
435
|
templateHTMLStatic
|
|
430
|
-
} = templates; // Serve a blank HTML page with client scripts to load the app in the browser
|
|
436
|
+
} = templates || {}; // Serve a blank HTML page with client scripts to load the app in the browser
|
|
431
437
|
|
|
432
438
|
if (accessMethod.DYNAMIC) {
|
|
433
439
|
// Dynamic doesn't need sagas
|
|
434
|
-
server.renderToString(jsx); // Dynamic page render has only the necessary bundles to start up the app
|
|
440
|
+
server$1.renderToString(jsx); // Dynamic page render has only the necessary bundles to start up the app
|
|
435
441
|
// and does not include any react-loadable code-split bundles
|
|
436
442
|
|
|
437
|
-
|
|
438
|
-
|
|
443
|
+
let bundleTags = ''; // Add the static startup script to the bundleTags
|
|
444
|
+
|
|
445
|
+
if (scripts.startup) bundleTags = `<script ${attributes} src="/${staticRoutePath}/${scripts.startup}"></script>`;
|
|
446
|
+
bundleTags += getBundleTags(loadableExtractor);
|
|
439
447
|
const isDynamicHint = `<script ${attributes}>window.isDynamic = true;</script>`;
|
|
440
448
|
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
|
|
441
449
|
// the app and serve up all errors inside the client
|
|
@@ -446,9 +454,9 @@ const webApp = (app, ReactApp, config) => {
|
|
|
446
454
|
|
|
447
455
|
|
|
448
456
|
if (!accessMethod.DYNAMIC) {
|
|
449
|
-
store.runSaga(rootSaga(withSagas)).toPromise().then(() => {
|
|
457
|
+
store.runSaga(App.rootSaga(withSagas)).toPromise().then(() => {
|
|
450
458
|
const sheet = new styled.ServerStyleSheet();
|
|
451
|
-
const html = server.renderToString(sheet.collectStyles(jsx));
|
|
459
|
+
const html = server$1.renderToString(sheet.collectStyles(jsx));
|
|
452
460
|
const helmet = Helmet__default['default'].renderStatic();
|
|
453
461
|
Helmet__default['default'].rewind();
|
|
454
462
|
const htmlAttributes = helmet.htmlAttributes.toString();
|
|
@@ -463,11 +471,13 @@ const webApp = (app, ReactApp, config) => {
|
|
|
463
471
|
const styleTags = sheet.getStyleTags(); // After running rootSaga there should be an additional react-loadable
|
|
464
472
|
// code-split bundle for a page component as well as core app bundles
|
|
465
473
|
|
|
466
|
-
|
|
467
|
-
|
|
474
|
+
let bundleTags = ''; // Add the static startup script to the bundleTags
|
|
475
|
+
|
|
476
|
+
if (scripts.startup) bundleTags = `<script ${attributes} src="/${staticRoutePath}/${scripts.startup}"></script>`;
|
|
477
|
+
bundleTags += getBundleTags(loadableExtractor);
|
|
468
478
|
let serialisedReduxData = '';
|
|
469
479
|
|
|
470
|
-
if (context.
|
|
480
|
+
if (context.statusCode !== 404) {
|
|
471
481
|
// For a request that returns a redux state object as a response
|
|
472
482
|
if (accessMethod.REDUX) {
|
|
473
483
|
serialisedReduxData = serialize__default['default'](reduxState, {
|
|
@@ -489,13 +499,13 @@ const webApp = (app, ReactApp, config) => {
|
|
|
489
499
|
}
|
|
490
500
|
}
|
|
491
501
|
|
|
492
|
-
if (context.
|
|
502
|
+
if ((context.statusCode || 200) > 400) {
|
|
493
503
|
accessMethod.STATIC = true;
|
|
494
504
|
} // Responses
|
|
495
505
|
|
|
496
506
|
|
|
497
507
|
let responseHTML = '';
|
|
498
|
-
if (context.
|
|
508
|
+
if (context.statusCode === 404) title = '<title>404 page not found</title>'; // Static page served as a fragment
|
|
499
509
|
|
|
500
510
|
if (accessMethod.FRAGMENT && accessMethod.STATIC) {
|
|
501
511
|
responseHTML = minifyCssString__default['default'](styleTags) + html;
|
|
@@ -517,7 +527,7 @@ const webApp = (app, ReactApp, config) => {
|
|
|
517
527
|
} // Set response.status from React StaticRouter
|
|
518
528
|
|
|
519
529
|
|
|
520
|
-
if (typeof context.
|
|
530
|
+
if (typeof context.statusCode === 'number') response.status(context.statusCode);
|
|
521
531
|
addStandardHeaders(reduxState, response, packagejson, {
|
|
522
532
|
allowedGroups,
|
|
523
533
|
globalGroups
|
|
@@ -542,7 +552,7 @@ const webApp = (app, ReactApp, config) => {
|
|
|
542
552
|
response.status(500);
|
|
543
553
|
responseHandler(request, response, `Error occurred: <br />${err.stack} <br />${JSON.stringify(err)}`);
|
|
544
554
|
});
|
|
545
|
-
server.renderToString(jsx);
|
|
555
|
+
server$1.renderToString(jsx);
|
|
546
556
|
store.close();
|
|
547
557
|
}
|
|
548
558
|
});
|
|
@@ -552,9 +562,9 @@ const app = express__default['default']();
|
|
|
552
562
|
|
|
553
563
|
const start = (ReactApp, config, ServerFeatures) => {
|
|
554
564
|
global.PACKAGE_JSON = config.packagejson;
|
|
555
|
-
global.REVERSE_PROXY_PATHS = Object(config.reverseProxyPaths);
|
|
556
|
-
global.PROXY_DELIVERY_API = config.proxyDeliveryApi;
|
|
557
565
|
global.DISABLE_SSR_REDUX = config.disableSsrRedux;
|
|
566
|
+
global.PROXY_DELIVERY_API = config.proxyDeliveryApi;
|
|
567
|
+
global.REVERSE_PROXY_PATHS = Object(config.reverseProxyPaths);
|
|
558
568
|
app.disable('x-powered-by'); // Output some information about the used build/startup configuration
|
|
559
569
|
|
|
560
570
|
DisplayStartupConfiguration(config);
|
|
@@ -566,9 +576,9 @@ const start = (ReactApp, config, ServerFeatures) => {
|
|
|
566
576
|
webApp(app, ReactApp, config);
|
|
567
577
|
app.on('ready', async () => {
|
|
568
578
|
// Configure DNS to make life easier
|
|
569
|
-
//await ConfigureLocalDNS();
|
|
579
|
+
// await ConfigureLocalDNS();
|
|
570
580
|
Loadable__default['default'].preloadAll().then(() => {
|
|
571
|
-
|
|
581
|
+
const server = app.listen(3001, () => {
|
|
572
582
|
console.info(`HTTP server is listening @ port 3001`);
|
|
573
583
|
setTimeout(function () {
|
|
574
584
|
app.emit('app_started');
|