@zengenti/contensis-react-base 4.0.0-beta.58 → 4.0.0-beta.59

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.
@@ -28,8 +28,8 @@ import { noop, identity } from 'lodash';
28
28
  import { buildCleaner } from 'lodash-clean';
29
29
  import { a as Cookies } from './CookieHelper.class-C6rTRl_1.js';
30
30
  import cookiesMiddleware from 'universal-cookie-express';
31
- import { c as createLocaleRoutes, h as history, p as pickProject, r as rootSaga } from './App-BVdAv4vL.js';
32
- export { A as ReactApp } from './App-BVdAv4vL.js';
31
+ import { c as createLocaleRoutes, h as history, p as pickProject, r as rootSaga } from './App-CrCf7gso.js';
32
+ export { A as ReactApp } from './App-CrCf7gso.js';
33
33
  import { c as createStore } from './store-DSjRYsM2.js';
34
34
  import { s as setVersionStatus, c as setVersion } from './version-B75wA6Te.js';
35
35
  import { a6 as selectSurrogateKeys, a7 as selectSsrApiCalls, j as selectRouteEntry, f as selectCurrentProject, g as getImmutableOrJS, s as setCurrentProject, F as selectCurrentSearch } from './selectors-8ROQrTd7.js';
@@ -39,6 +39,7 @@ import { ChunkExtractor, ChunkExtractorManager } from '@loadable/server';
39
39
  import chalk from 'chalk';
40
40
  import minifyCssString from 'minify-css-string';
41
41
  import { CookiesProvider } from 'react-cookie';
42
+ import { HelmetProvider } from 'react-helmet-async';
42
43
  import { StaticRouter } from 'react-router-dom/server';
43
44
  import { S as SSRContextProvider, g as getSubsitePath } from './SSRContext-CYxBWky3.js';
44
45
  import './VersionInfo-By2ZCZOh.js';
@@ -1206,7 +1207,9 @@ const ssrJsxProducer = (ReactApp, {
1206
1207
  var _providers$styledComp;
1207
1208
  // Recast ChunkExtractorManager to avoid TS error `Property 'children' does not exist on type...`
1208
1209
  const ChunkExtractor = ChunkExtractorManager;
1209
- const jsx = /*#__PURE__*/React.createElement(ChunkExtractor, {
1210
+ const jsx = /*#__PURE__*/React.createElement(HelmetProvider, {
1211
+ context: providers.helmet
1212
+ }, /*#__PURE__*/React.createElement(ChunkExtractor, {
1210
1213
  extractor: providers.loadable.extractor
1211
1214
  }, /*#__PURE__*/React.createElement(CookiesProvider, {
1212
1215
  cookies: providers.cookies
@@ -1228,7 +1231,7 @@ const ssrJsxProducer = (ReactApp, {
1228
1231
  }, /*#__PURE__*/React.createElement(ReactApp, {
1229
1232
  routes: props.routes,
1230
1233
  withEvents: props.withEvents
1231
- })))))));
1234
+ }))))))));
1232
1235
 
1233
1236
  // Wrap the JSX in a StyleSheetManager if a ServerStyleSheet is provided
1234
1237
  return !((_providers$styledComp = providers.styledComponents) !== null && _providers$styledComp !== void 0 && _providers$styledComp.sheet) ? jsx : providers.styledComponents.sheet.collectStyles(jsx);
@@ -1348,12 +1351,17 @@ const webApp = (app, ReactApp, config) => {
1348
1351
  // and read back any context props set by the ReactApp
1349
1352
  const context = {};
1350
1353
 
1354
+ // Per-request helmet context object — populated by HelmetProvider during renderToString
1355
+ // Using a fresh object per request ensures thread safety under concurrent SSR requests
1356
+ const helmetContext = {};
1357
+
1351
1358
  // Amalgamate all props for the various Providers we wrap the ReactApp with
1352
1359
  const jsxProviderProps = {
1353
1360
  loadable: {
1354
1361
  extractor: loadableExtractor.commonLoadableExtractor
1355
1362
  },
1356
1363
  cookies: ssrCookies,
1364
+ helmet: helmetContext,
1357
1365
  redux: store,
1358
1366
  httpContext: context,
1359
1367
  router: {
@@ -1470,15 +1478,23 @@ const webApp = (app, ReactApp, config) => {
1470
1478
  const html = renderToString(styledJsx);
1471
1479
  // Helmet.renderStatic() has to be called synchronously immediately after calling renderToString()
1472
1480
  // as it is not thread-safe (or specifically scoped to only this request)
1481
+ // TODO: deprecate `react-helmet`
1473
1482
  const helmet = Helmet.renderStatic();
1474
1483
 
1484
+ // helmetContext is populated synchronously by HelmetProvider during renderToString()
1485
+ // It is scoped per-request via the helmetContext object, making this thread-safe
1486
+ // under concurrent SSR requests (unlike the previous Helmet.renderStatic() global singleton)
1487
+ const {
1488
+ helmet: helmetAsync
1489
+ } = helmetContext;
1490
+
1475
1491
  // Because we have had to call renderToString() here to reliably gather all helmet metadata
1476
1492
  // We could potentially call sheet.getStyleTags() here too and avoid piping a react-rendered
1477
1493
  // stream to a second stream to inject styled-components CSS
1478
1494
 
1479
- const htmlAttributes = helmet.htmlAttributes.toString();
1480
- let title = helmet.title.toString();
1481
- const metadata = helmet.meta.toString().concat(helmet.base.toString()).concat(helmet.link.toString()).concat(helmet.script.toString()).concat(helmet.noscript.toString());
1495
+ const htmlAttributes = helmetAsync.htmlAttributes.toString() || helmet.htmlAttributes.toString();
1496
+ let title = helmet.title.toString().includes('><') ? helmetAsync.title.toString() : helmet.title.toString();
1497
+ const metadata = helmetAsync.meta.toString().concat(helmetAsync.base.toString()).concat(helmetAsync.priority.toString()).concat(helmetAsync.link.toString()).concat(helmetAsync.script.toString()).concat(helmetAsync.noscript.toString()).concat(helmet.meta.toString()).concat(helmet.base.toString()).concat(helmet.link.toString()).concat(helmet.script.toString()).concat(helmet.noscript.toString());
1482
1498
  try {
1483
1499
  /**
1484
1500
  * Loads all page assets into the provided templateHTML