@zengenti/contensis-react-base 3.0.1-beta.9 → 3.0.2-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/README.md +21 -0
- package/cjs/contensis-react-base.js +63 -35
- package/cjs/contensis-react-base.js.map +1 -1
- package/cjs/{sagas-03b7a270.js → sagas-7c19ce8e.js} +15 -13
- package/cjs/sagas-7c19ce8e.js.map +1 -0
- package/cjs/search.js +12 -4
- package/cjs/search.js.map +1 -1
- package/esm/contensis-react-base.js +52 -26
- package/esm/contensis-react-base.js.map +1 -1
- package/esm/{sagas-a7f7ded0.js → sagas-8d8945e6.js} +15 -13
- package/esm/sagas-8d8945e6.js.map +1 -0
- package/esm/search.js +13 -5
- package/esm/search.js.map +1 -1
- package/models/config.d.ts +1 -0
- package/models/search/models/Queries.d.ts +2 -1
- package/models/search/models/Search.d.ts +2 -0
- package/models/search/search/expressions.d.ts +2 -2
- package/models/server/internalServer.d.ts +4 -1
- package/models/server/util/handleExceptions.d.ts +1 -0
- package/package.json +4 -2
- package/cjs/sagas-03b7a270.js.map +0 -1
- package/esm/sagas-a7f7ded0.js.map +0 -1
- package/models/util/navHelper.d.ts +0 -7
package/README.md
CHANGED
|
@@ -126,6 +126,27 @@ https://www.conventionalcommits.org/en/v1.0.0/#summary
|
|
|
126
126
|
|
|
127
127
|
# Changelog
|
|
128
128
|
|
|
129
|
+
#### 3.0.1 (2023-01-27)
|
|
130
|
+
|
|
131
|
+
##### Bug Fixes
|
|
132
|
+
|
|
133
|
+
- search package update supporting 'fuzzy' search (67bf14f3)
|
|
134
|
+
- revert package `chalk@4` as v5 requires total ESM environment which is incompatible with the Node.js app server today (4dcd478d)
|
|
135
|
+
- node process terminating on unhandled exception / promise rejection when running on node.js 15+, implement default behaviour as in <15 with the option to turn this off. Export express `server` for package consumers who need to access server methods in app handlers (677cd00a)
|
|
136
|
+
- search package null errors when replacing entire search state with a fresh config, remove redundant nav code (b74a526b)
|
|
137
|
+
- state-to-searchuri - fix crash when app state is immutable (f4e265eb)
|
|
138
|
+
- search package issue with APPLY_CONFIG after immer conversion (a827d075)
|
|
139
|
+
- Update from Search Package to use ?pageIndex over /pageIndex by default (99e42b90)
|
|
140
|
+
- search package fix resolving customApi response in ssr causes thread to hang (c4bed5e8)
|
|
141
|
+
- always use `api-` uri for delivery api proxy requests (6887e440)
|
|
142
|
+
- useMinilist hook, handle undefined arguments. (12d906d7)
|
|
143
|
+
- ContensisDeliveryApi.js -Add null check in LruCache.remove method (95cb63bf)
|
|
144
|
+
|
|
145
|
+
##### Refactors
|
|
146
|
+
|
|
147
|
+
- convert some files to typescript (5c3b74e2)
|
|
148
|
+
- Split deliveryApi and asset proxy servers into separate instances (7ae1e007)
|
|
149
|
+
|
|
129
150
|
#### 3.0.0 (2022-10-06)
|
|
130
151
|
|
|
131
152
|
##### New Features
|
|
@@ -6,7 +6,7 @@ var App = require('./App-ee485b92.js');
|
|
|
6
6
|
var contensisDeliveryApi = require('contensis-delivery-api');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var reactRedux = require('react-redux');
|
|
9
|
-
var sagas = require('./sagas-
|
|
9
|
+
var sagas = require('./sagas-7c19ce8e.js');
|
|
10
10
|
var mapJson = require('jsonpath-mapper');
|
|
11
11
|
require('reselect');
|
|
12
12
|
require('deepmerge');
|
|
@@ -17,24 +17,26 @@ var contensisCoreApi = require('contensis-core-api');
|
|
|
17
17
|
var urls = require('./urls-6fcaf4c6.js');
|
|
18
18
|
require('isomorphic-fetch');
|
|
19
19
|
var express = require('express');
|
|
20
|
+
var http = require('http');
|
|
20
21
|
var httpProxy = require('http-proxy');
|
|
21
22
|
var fs = require('fs');
|
|
22
23
|
var path = require('path');
|
|
23
24
|
var appRootPath = require('app-root-path');
|
|
24
|
-
var server$
|
|
25
|
+
var server$2 = require('react-dom/server');
|
|
25
26
|
var reactRouterDom = require('react-router-dom');
|
|
26
27
|
var reactRouterConfig = require('react-router-config');
|
|
27
28
|
var reactHelmet = require('react-helmet');
|
|
28
29
|
var styled = require('styled-components');
|
|
29
30
|
var serialize$1 = require('serialize-javascript');
|
|
30
31
|
var minifyCssString = require('minify-css-string');
|
|
31
|
-
var server = require('@loadable/server');
|
|
32
|
+
var server$1 = require('@loadable/server');
|
|
32
33
|
var lodash = require('lodash');
|
|
33
34
|
var lodashClean = require('lodash-clean');
|
|
34
35
|
var reactCookie = require('react-cookie');
|
|
35
36
|
var version = require('./version-78dfc3bd.js');
|
|
36
37
|
var actions = require('./actions-8dc9e8de.js');
|
|
37
38
|
var selectors = require('./selectors-656da4b7.js');
|
|
39
|
+
var chalk = require('chalk');
|
|
38
40
|
require('history');
|
|
39
41
|
require('@redux-saga/core/effects');
|
|
40
42
|
require('loglevel');
|
|
@@ -56,11 +58,13 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
56
58
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
57
59
|
var mapJson__default = /*#__PURE__*/_interopDefaultLegacy(mapJson);
|
|
58
60
|
var express__default = /*#__PURE__*/_interopDefaultLegacy(express);
|
|
61
|
+
var http__default = /*#__PURE__*/_interopDefaultLegacy(http);
|
|
59
62
|
var httpProxy__default = /*#__PURE__*/_interopDefaultLegacy(httpProxy);
|
|
60
63
|
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
61
64
|
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
62
65
|
var serialize__default = /*#__PURE__*/_interopDefaultLegacy(serialize$1);
|
|
63
66
|
var minifyCssString__default = /*#__PURE__*/_interopDefaultLegacy(minifyCssString);
|
|
67
|
+
var chalk__default = /*#__PURE__*/_interopDefaultLegacy(chalk);
|
|
64
68
|
|
|
65
69
|
/**
|
|
66
70
|
* Util class holds our search results helper boilerplate methods
|
|
@@ -679,27 +683,6 @@ const makeLinkDepthMiddleware = ({
|
|
|
679
683
|
const servers$1 = SERVERS;
|
|
680
684
|
/* global SERVERS */
|
|
681
685
|
|
|
682
|
-
const projects = PROJECTS;
|
|
683
|
-
/* global PROJECTS */
|
|
684
|
-
|
|
685
|
-
const DisplayStartupConfiguration = config => {
|
|
686
|
-
/* eslint-disable no-console */
|
|
687
|
-
console.log();
|
|
688
|
-
console.log(`Configured servers:
|
|
689
|
-
`, JSON.stringify(servers$1, null, 2));
|
|
690
|
-
console.log();
|
|
691
|
-
console.log(`Configured projects:
|
|
692
|
-
`, JSON.stringify(projects, null, 2));
|
|
693
|
-
console.log();
|
|
694
|
-
console.log('Reverse proxy paths: ', JSON.stringify(config.reverseProxyPaths, null, 2));
|
|
695
|
-
console.log();
|
|
696
|
-
if (config.staticFolderPath) console.log(`Serving static assets from: "/dist/${config.staticFolderPath}/"`);
|
|
697
|
-
/* eslint-enable no-console */
|
|
698
|
-
};
|
|
699
|
-
|
|
700
|
-
const servers = SERVERS;
|
|
701
|
-
/* global SERVERS */
|
|
702
|
-
|
|
703
686
|
const project = PROJECT;
|
|
704
687
|
/* global PROJECT */
|
|
705
688
|
|
|
@@ -713,7 +696,7 @@ const deliveryProxy = httpProxy__default["default"].createProxyServer();
|
|
|
713
696
|
const reverseProxies = (app, reverseProxyPaths = []) => {
|
|
714
697
|
deliveryApiProxy(deliveryProxy, app);
|
|
715
698
|
app.all(reverseProxyPaths, (req, res) => {
|
|
716
|
-
const target = req.hostname.indexOf('preview-') || req.hostname.indexOf('preview.') || req.hostname === 'localhost' ? servers.previewIis || servers.iis : servers.iis;
|
|
699
|
+
const target = req.hostname.indexOf('preview-') || req.hostname.indexOf('preview.') || req.hostname === 'localhost' ? servers$1.previewIis || servers$1.iis : servers$1.iis;
|
|
717
700
|
assetProxy.web(req, res, {
|
|
718
701
|
target,
|
|
719
702
|
changeOrigin: true
|
|
@@ -730,7 +713,7 @@ const deliveryApiProxy = (apiProxy, app) => {
|
|
|
730
713
|
// This is just here to stop cors requests on localhost. In Production this is mapped using varnish.
|
|
731
714
|
app.all(['/api/delivery/*', '/api/image/*'], (req, res) => {
|
|
732
715
|
/* eslint-disable no-console */
|
|
733
|
-
console.log(`Proxying api request to ${servers.alias}`);
|
|
716
|
+
console.log(`Proxying api request to ${servers$1.alias}`);
|
|
734
717
|
apiProxy.web(req, res, {
|
|
735
718
|
target: deliveryApiHostname,
|
|
736
719
|
changeOrigin: true
|
|
@@ -855,6 +838,27 @@ const staticAssets = (app, {
|
|
|
855
838
|
}));
|
|
856
839
|
};
|
|
857
840
|
|
|
841
|
+
const servers = SERVERS;
|
|
842
|
+
/* global SERVERS */
|
|
843
|
+
|
|
844
|
+
const projects = PROJECTS;
|
|
845
|
+
/* global PROJECTS */
|
|
846
|
+
|
|
847
|
+
const DisplayStartupConfiguration = config => {
|
|
848
|
+
/* eslint-disable no-console */
|
|
849
|
+
console.log();
|
|
850
|
+
console.log(`Configured servers:
|
|
851
|
+
`, JSON.stringify(servers, null, 2));
|
|
852
|
+
console.log();
|
|
853
|
+
console.log(`Configured projects:
|
|
854
|
+
`, JSON.stringify(projects, null, 2));
|
|
855
|
+
console.log();
|
|
856
|
+
console.log('Reverse proxy paths: ', JSON.stringify(config.reverseProxyPaths, null, 2));
|
|
857
|
+
console.log();
|
|
858
|
+
if (config.staticFolderPath) console.log(`Serving static assets from: "/dist/${config.staticFolderPath}/"`);
|
|
859
|
+
/* eslint-enable no-console */
|
|
860
|
+
};
|
|
861
|
+
|
|
858
862
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
859
863
|
|
|
860
864
|
/**
|
|
@@ -4011,7 +4015,7 @@ const loadableBundleData = ({
|
|
|
4011
4015
|
return bundle;
|
|
4012
4016
|
};
|
|
4013
4017
|
const loadableChunkExtractors = () => {
|
|
4014
|
-
const commonLoadableExtractor = new server.ChunkExtractor({
|
|
4018
|
+
const commonLoadableExtractor = new server$1.ChunkExtractor({
|
|
4015
4019
|
stats: {}
|
|
4016
4020
|
});
|
|
4017
4021
|
|
|
@@ -4020,7 +4024,7 @@ const loadableChunkExtractors = () => {
|
|
|
4020
4024
|
let legacy;
|
|
4021
4025
|
|
|
4022
4026
|
try {
|
|
4023
|
-
modern = new server.ChunkExtractor({
|
|
4027
|
+
modern = new server$1.ChunkExtractor({
|
|
4024
4028
|
entrypoints: ['app'],
|
|
4025
4029
|
namespace: 'modern',
|
|
4026
4030
|
statsFile: path__default["default"].resolve('dist/modern/loadable-stats.json')
|
|
@@ -4030,7 +4034,7 @@ const loadableChunkExtractors = () => {
|
|
|
4030
4034
|
}
|
|
4031
4035
|
|
|
4032
4036
|
try {
|
|
4033
|
-
legacy = new server.ChunkExtractor({
|
|
4037
|
+
legacy = new server$1.ChunkExtractor({
|
|
4034
4038
|
entrypoints: ['app'],
|
|
4035
4039
|
namespace: 'legacy',
|
|
4036
4040
|
statsFile: path__default["default"].resolve('dist/legacy/loadable-stats.json')
|
|
@@ -4163,6 +4167,25 @@ const getVersionInfo = staticFolderPath => {
|
|
|
4163
4167
|
}
|
|
4164
4168
|
};
|
|
4165
4169
|
|
|
4170
|
+
/* eslint-disable no-console */
|
|
4171
|
+
const unhandledExceptionHandler = (handleExceptions = true) => {
|
|
4172
|
+
const exceptionTypes = handleExceptions === true ? ['uncaughtException', 'unhandledRejection', 'SIGTERM', 'SIGINT'] // Default exception types to add event listeners for
|
|
4173
|
+
: Array.isArray(handleExceptions) // In future we could accept an array of specific exception types to handle for a specific application?
|
|
4174
|
+
? handleExceptions : [];
|
|
4175
|
+
|
|
4176
|
+
for (const type of exceptionTypes) {
|
|
4177
|
+
process.on(type, err => {
|
|
4178
|
+
if (err && err instanceof Error) {
|
|
4179
|
+
// Print a message to inform admins and developers the error should not be ignored
|
|
4180
|
+
console.log(`${`[contensis-react-base] ❌ ${chalk__default["default"].red.bold(`${type} - ${err.message}`)}`}`);
|
|
4181
|
+
console.log(chalk__default["default"].gray` - you are seeing this because we have tried to prevent the app from completely crashing - you should not ignore this problem`); // Log the error to server console
|
|
4182
|
+
|
|
4183
|
+
console.error(err);
|
|
4184
|
+
}
|
|
4185
|
+
});
|
|
4186
|
+
}
|
|
4187
|
+
};
|
|
4188
|
+
|
|
4166
4189
|
const webApp = (app, ReactApp, config) => {
|
|
4167
4190
|
const {
|
|
4168
4191
|
stateType = 'immutable',
|
|
@@ -4177,13 +4200,16 @@ const webApp = (app, ReactApp, config) => {
|
|
|
4177
4200
|
allowedGroups,
|
|
4178
4201
|
globalGroups,
|
|
4179
4202
|
disableSsrRedux,
|
|
4180
|
-
handleResponses
|
|
4203
|
+
handleResponses,
|
|
4204
|
+
handleExceptions = true
|
|
4181
4205
|
} = config;
|
|
4182
4206
|
const staticRoutePath = config.staticRoutePath || staticFolderPath;
|
|
4183
4207
|
const bundleData = getBundleData(config, staticRoutePath);
|
|
4184
4208
|
const attributes = stringifyAttributes(scripts.attributes);
|
|
4185
4209
|
scripts.startup = scripts.startup || startupScriptFilename;
|
|
4186
4210
|
const responseHandler = typeof handleResponses === 'function' ? handleResponses : handleResponse;
|
|
4211
|
+
if (handleExceptions !== false) unhandledExceptionHandler(); // Create `process.on` event handlers for unhandled exceptions (Node v15+)
|
|
4212
|
+
|
|
4187
4213
|
const versionInfo = getVersionInfo(staticFolderPath);
|
|
4188
4214
|
app.get('/*', async (request, response) => {
|
|
4189
4215
|
const {
|
|
@@ -4233,7 +4259,7 @@ const webApp = (app, ReactApp, config) => {
|
|
|
4233
4259
|
const groups = allowedGroups && allowedGroups[project];
|
|
4234
4260
|
store.dispatch(actions.setCurrentProject(project, groups, request.hostname));
|
|
4235
4261
|
const loadableExtractor = loadableChunkExtractors();
|
|
4236
|
-
const jsx = /*#__PURE__*/React__default["default"].createElement(server.ChunkExtractorManager, {
|
|
4262
|
+
const jsx = /*#__PURE__*/React__default["default"].createElement(server$1.ChunkExtractorManager, {
|
|
4237
4263
|
extractor: loadableExtractor.commonLoadableExtractor
|
|
4238
4264
|
}, /*#__PURE__*/React__default["default"].createElement(reactCookie.CookiesProvider, {
|
|
4239
4265
|
cookies: cookies
|
|
@@ -4254,7 +4280,7 @@ const webApp = (app, ReactApp, config) => {
|
|
|
4254
4280
|
|
|
4255
4281
|
if (accessMethod.DYNAMIC) {
|
|
4256
4282
|
// Dynamic doesn't need sagas
|
|
4257
|
-
server$
|
|
4283
|
+
server$2.renderToString(jsx); // Dynamic page render has only the necessary bundles to start up the app
|
|
4258
4284
|
// and does not include any react-loadable code-split bundles
|
|
4259
4285
|
|
|
4260
4286
|
const bundleTags = getBundleTags(loadableExtractor, scripts, staticRoutePath);
|
|
@@ -4270,7 +4296,7 @@ const webApp = (app, ReactApp, config) => {
|
|
|
4270
4296
|
if (!accessMethod.DYNAMIC) {
|
|
4271
4297
|
store.runSaga(App.rootSaga(withSagas)).toPromise().then(() => {
|
|
4272
4298
|
const sheet = new styled.ServerStyleSheet();
|
|
4273
|
-
const html = server$
|
|
4299
|
+
const html = server$2.renderToString(sheet.collectStyles(jsx));
|
|
4274
4300
|
const helmet = reactHelmet.Helmet.renderStatic();
|
|
4275
4301
|
reactHelmet.Helmet.rewind();
|
|
4276
4302
|
const htmlAttributes = helmet.htmlAttributes.toString();
|
|
@@ -4369,13 +4395,14 @@ const webApp = (app, ReactApp, config) => {
|
|
|
4369
4395
|
response.status(500);
|
|
4370
4396
|
responseHandler(request, response, `Error occurred: <br />${err.stack} <br />${JSON.stringify(err)}`);
|
|
4371
4397
|
});
|
|
4372
|
-
server$
|
|
4398
|
+
server$2.renderToString(jsx);
|
|
4373
4399
|
store.close();
|
|
4374
4400
|
}
|
|
4375
4401
|
});
|
|
4376
4402
|
};
|
|
4377
4403
|
|
|
4378
4404
|
const app = express__default["default"]();
|
|
4405
|
+
const server = http__default["default"].createServer(app);
|
|
4379
4406
|
|
|
4380
4407
|
const start = (ReactApp, config, ServerFeatures) => {
|
|
4381
4408
|
global.PACKAGE_JSON = config.packagejson;
|
|
@@ -4392,7 +4419,7 @@ const start = (ReactApp, config, ServerFeatures) => {
|
|
|
4392
4419
|
staticAssets(app, config);
|
|
4393
4420
|
webApp(app, ReactApp, config);
|
|
4394
4421
|
app.on('ready', async () => {
|
|
4395
|
-
|
|
4422
|
+
server.listen(3001, () => {
|
|
4396
4423
|
console.info(`HTTP server is listening @ port 3001`);
|
|
4397
4424
|
setTimeout(function () {
|
|
4398
4425
|
app.emit('app_started');
|
|
@@ -4409,6 +4436,7 @@ const start = (ReactApp, config, ServerFeatures) => {
|
|
|
4409
4436
|
var internalServer = {
|
|
4410
4437
|
app,
|
|
4411
4438
|
apiProxy: deliveryProxy,
|
|
4439
|
+
server,
|
|
4412
4440
|
start
|
|
4413
4441
|
};
|
|
4414
4442
|
|