@dr.pogodin/react-utils 1.23.13 → 1.24.1

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.
@@ -46,7 +46,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
46
46
  \**********************/
47
47
  /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
48
48
 
49
- eval("var __dirname = \"/\";\n__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Barrier: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.Barrier; },\n/* harmony export */ BaseModal: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.BaseModal; },\n/* harmony export */ Button: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.Button; },\n/* harmony export */ Checkbox: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.Checkbox; },\n/* harmony export */ Dropdown: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.Dropdown; },\n/* harmony export */ Emitter: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.Emitter; },\n/* harmony export */ GlobalStateProvider: function() { return /* reexport safe */ _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_4__.GlobalStateProvider; },\n/* harmony export */ Input: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.Input; },\n/* harmony export */ JU: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.JU; },\n/* harmony export */ Link: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.Link; },\n/* harmony export */ MetaTags: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.MetaTags; },\n/* harmony export */ Modal: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.Modal; },\n/* harmony export */ NavLink: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.NavLink; },\n/* harmony export */ PT: function() { return /* reexport module object */ prop_types__WEBPACK_IMPORTED_MODULE_3__; },\n/* harmony export */ PageLayout: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.PageLayout; },\n/* harmony export */ ScalableRect: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.ScalableRect; },\n/* harmony export */ Semaphore: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.Semaphore; },\n/* harmony export */ ThemeProvider: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.ThemeProvider; },\n/* harmony export */ Throbber: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.Throbber; },\n/* harmony export */ WithTooltip: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.WithTooltip; },\n/* harmony export */ YouTubeVideo: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.YouTubeVideo; },\n/* harmony export */ api: function() { return /* reexport default from dynamic */ axios__WEBPACK_IMPORTED_MODULE_2___default.a; },\n/* harmony export */ client: function() { return /* binding */ client; },\n/* harmony export */ config: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.config; },\n/* harmony export */ getGlobalState: function() { return /* reexport safe */ _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_4__.getGlobalState; },\n/* harmony export */ getSsrContext: function() { return /* reexport safe */ _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_4__.getSsrContext; },\n/* harmony export */ isomorphy: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.isomorphy; },\n/* harmony export */ newBarrier: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.newBarrier; },\n/* harmony export */ server: function() { return /* binding */ server; },\n/* harmony export */ splitComponent: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.splitComponent; },\n/* harmony export */ themed: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.themed; },\n/* harmony export */ time: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.time; },\n/* harmony export */ useAsyncCollection: function() { return /* reexport safe */ _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_4__.useAsyncCollection; },\n/* harmony export */ useAsyncData: function() { return /* reexport safe */ _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_4__.useAsyncData; },\n/* harmony export */ useGlobalState: function() { return /* reexport safe */ _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_4__.useGlobalState; },\n/* harmony export */ webpack: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.webpack; },\n/* harmony export */ withRetries: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.withRetries; }\n/* harmony export */ });\n/* harmony import */ var _styles_global_scss__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./styles/global.scss */ \"./src/styles/global.scss\");\n/* harmony import */ var _shared_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shared/utils */ \"./src/shared/utils/index.js\");\n/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! axios */ \"axios\");\n/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(axios__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! prop-types */ \"prop-types\");\n/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @dr.pogodin/react-global-state */ \"@dr.pogodin/react-global-state\");\n/* harmony import */ var _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_4__);\n/* harmony import */ var _shared_components__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shared/components */ \"./src/shared/components/index.js\");\n\n\nconst server = _shared_utils__WEBPACK_IMPORTED_MODULE_1__.webpack.requireWeak('./server', __dirname);\nconst client = server ? undefined : (__webpack_require__(/*! ./client */ \"./src/client/index.jsx\")[\"default\"]);\n\n\n\n\n\n\n\n\n//# sourceURL=webpack://@dr.pogodin/react-utils/./src/index.js?");
49
+ eval("var __dirname = \"/\";\n__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Barrier: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.Barrier; },\n/* harmony export */ BaseModal: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.BaseModal; },\n/* harmony export */ Button: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.Button; },\n/* harmony export */ Checkbox: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.Checkbox; },\n/* harmony export */ Dropdown: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.Dropdown; },\n/* harmony export */ Emitter: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.Emitter; },\n/* harmony export */ GlobalStateProvider: function() { return /* reexport safe */ _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_4__.GlobalStateProvider; },\n/* harmony export */ Input: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.Input; },\n/* harmony export */ JU: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.JU; },\n/* harmony export */ Link: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.Link; },\n/* harmony export */ MetaTags: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.MetaTags; },\n/* harmony export */ Modal: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.Modal; },\n/* harmony export */ NavLink: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.NavLink; },\n/* harmony export */ PT: function() { return /* reexport module object */ prop_types__WEBPACK_IMPORTED_MODULE_3__; },\n/* harmony export */ PageLayout: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.PageLayout; },\n/* harmony export */ ScalableRect: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.ScalableRect; },\n/* harmony export */ Semaphore: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.Semaphore; },\n/* harmony export */ ThemeProvider: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.ThemeProvider; },\n/* harmony export */ Throbber: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.Throbber; },\n/* harmony export */ WithTooltip: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.WithTooltip; },\n/* harmony export */ YouTubeVideo: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.YouTubeVideo; },\n/* harmony export */ api: function() { return /* reexport default from dynamic */ axios__WEBPACK_IMPORTED_MODULE_2___default.a; },\n/* harmony export */ client: function() { return /* binding */ client; },\n/* harmony export */ config: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.config; },\n/* harmony export */ getGlobalState: function() { return /* reexport safe */ _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_4__.getGlobalState; },\n/* harmony export */ getSsrContext: function() { return /* reexport safe */ _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_4__.getSsrContext; },\n/* harmony export */ isomorphy: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.isomorphy; },\n/* harmony export */ server: function() { return /* binding */ server; },\n/* harmony export */ splitComponent: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.splitComponent; },\n/* harmony export */ themed: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.themed; },\n/* harmony export */ time: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.time; },\n/* harmony export */ useAsyncCollection: function() { return /* reexport safe */ _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_4__.useAsyncCollection; },\n/* harmony export */ useAsyncData: function() { return /* reexport safe */ _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_4__.useAsyncData; },\n/* harmony export */ useGlobalState: function() { return /* reexport safe */ _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_4__.useGlobalState; },\n/* harmony export */ webpack: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.webpack; },\n/* harmony export */ withRetries: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.withRetries; }\n/* harmony export */ });\n/* harmony import */ var _styles_global_scss__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./styles/global.scss */ \"./src/styles/global.scss\");\n/* harmony import */ var _shared_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shared/utils */ \"./src/shared/utils/index.js\");\n/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! axios */ \"axios\");\n/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(axios__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! prop-types */ \"prop-types\");\n/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @dr.pogodin/react-global-state */ \"@dr.pogodin/react-global-state\");\n/* harmony import */ var _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_4__);\n/* harmony import */ var _shared_components__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shared/components */ \"./src/shared/components/index.js\");\n\n\nconst server = _shared_utils__WEBPACK_IMPORTED_MODULE_1__.webpack.requireWeak('./server', __dirname);\nconst client = server ? undefined : (__webpack_require__(/*! ./client */ \"./src/client/index.jsx\")[\"default\"]);\n\n\n\n\n\n\n\n\n//# sourceURL=webpack://@dr.pogodin/react-utils/./src/index.js?");
50
50
 
51
51
  /***/ }),
52
52
 
@@ -70,16 +70,6 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var prop
70
70
 
71
71
  /***/ }),
72
72
 
73
- /***/ "./src/shared/components/CodeSplit/index.jsx":
74
- /*!***************************************************!*\
75
- !*** ./src/shared/components/CodeSplit/index.jsx ***!
76
- \***************************************************/
77
- /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
78
-
79
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": function() { return /* binding */ CodeSplit; }\n/* harmony export */ });\n/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! prop-types */ \"prop-types\");\n/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ \"react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @dr.pogodin/react-global-state */ \"@dr.pogodin/react-global-state\");\n/* harmony import */ var _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var _utils_Barrier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../utils/Barrier */ \"./src/shared/utils/Barrier.js\");\n/* harmony import */ var _utils_isomorphy__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../utils/isomorphy */ \"./src/shared/utils/isomorphy/index.js\");\n/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react/jsx-runtime */ \"./node_modules/react/jsx-runtime.js\");\n/* eslint-disable react/jsx-props-no-spreading */\n/* global document */\n\n\n\n\n\n\n\nlet chunkGroups;\nlet styleSheetUsageCounters;\nif (_utils_isomorphy__WEBPACK_IMPORTED_MODULE_4__.IS_CLIENT_SIDE) {\n // eslint-disable-next-line global-require\n chunkGroups = (__webpack_require__(/*! ../../../client/getInj */ \"./src/client/getInj.js\")[\"default\"])().CHUNK_GROUPS || {};\n styleSheetUsageCounters = {};\n}\nfunction CodeSplit(_ref) {\n let {\n children,\n chunkName,\n getComponent,\n placeholder,\n ...props\n } = _ref;\n const {\n current: heap\n } = (0,react__WEBPACK_IMPORTED_MODULE_1__.useRef)({\n mounted: false,\n pendingStyles: []\n });\n const {\n publicPath\n } = (0,_utils_isomorphy__WEBPACK_IMPORTED_MODULE_4__.getBuildInfo)();\n\n // TODO: Not sure whether it is fine for the inner React.lazy() mechanics\n // if we dynamically create the lazy component inside a render of another\n // component, or does it expect we only create it once on outside of any\n // component.\n const LazyComponent = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_1__.lazy)(async () => {\n const res = await getComponent();\n if (heap.pendingStyles.length) await Promise.all(heap.pendingStyles);\n return res.default ? res : {\n default: res\n };\n });\n if (_utils_isomorphy__WEBPACK_IMPORTED_MODULE_4__.IS_SERVER_SIDE) {\n const {\n chunks\n } = (0,_dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_2__.getGlobalState)().ssrContext;\n if (chunks.includes(chunkName)) {\n throw Error(`Chunk name clash for \"${chunkName}\"`);\n } else chunks.push(chunkName);\n } else if (!heap.mounted) {\n heap.mounted = true;\n chunkGroups[chunkName].forEach(asset => {\n if (!asset.endsWith('.css')) return;\n const path = `${publicPath}/${asset}`;\n let link = document.querySelector(`link[href=\"${path}\"]`);\n if (!link) {\n link = document.createElement('link');\n link.setAttribute('href', path);\n link.setAttribute('rel', 'stylesheet');\n const barrier = (0,_utils_Barrier__WEBPACK_IMPORTED_MODULE_3__.newBarrier)();\n link.onload = barrier.resolve;\n\n // Even if the style load failed, still allow to mount the component,\n // abeit with broken styling.\n link.onerror = barrier.resolve;\n heap.pendingStyles.push(barrier);\n const head = document.querySelector('head');\n head.appendChild(link);\n }\n const count = styleSheetUsageCounters[path] || 0;\n styleSheetUsageCounters[path] = count + 1;\n });\n }\n\n // This effectively fires only once, just before the component unmounts.\n (0,react__WEBPACK_IMPORTED_MODULE_1__.useEffect)(() => () => {\n heap.mounted = false;\n chunkGroups[chunkName].forEach(item => {\n if (!item.endsWith('.css')) return;\n const path = `${publicPath}/${item}`;\n if (--styleSheetUsageCounters[path] <= 0) {\n const link = document.querySelector(`link[href=\"${path}\"]`);\n const head = document.querySelector('head');\n head.removeChild(link);\n }\n });\n }, [chunkName, heap, publicPath]);\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(react__WEBPACK_IMPORTED_MODULE_1__.Suspense, {\n fallback: placeholder,\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(LazyComponent, {\n ...props,\n children: children\n })\n });\n}\nCodeSplit.propTypes = {\n children: (prop_types__WEBPACK_IMPORTED_MODULE_0___default().node),\n chunkName: (prop_types__WEBPACK_IMPORTED_MODULE_0___default().string).isRequired,\n getComponent: (prop_types__WEBPACK_IMPORTED_MODULE_0___default().func).isRequired,\n placeholder: (prop_types__WEBPACK_IMPORTED_MODULE_0___default().node)\n};\nCodeSplit.defaultProps = {\n children: undefined,\n placeholder: undefined\n};\n\n//# sourceURL=webpack://@dr.pogodin/react-utils/./src/shared/components/CodeSplit/index.jsx?");
80
-
81
- /***/ }),
82
-
83
73
  /***/ "./src/shared/components/Dropdown/index.jsx":
84
74
  /*!**************************************************!*\
85
75
  !*** ./src/shared/components/Dropdown/index.jsx ***!
@@ -220,16 +210,6 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
220
210
 
221
211
  /***/ }),
222
212
 
223
- /***/ "./src/shared/utils/Barrier.js":
224
- /*!*************************************!*\
225
- !*** ./src/shared/utils/Barrier.js ***!
226
- \*************************************/
227
- /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
228
-
229
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Barrier: function() { return /* reexport safe */ _dr_pogodin_js_utils__WEBPACK_IMPORTED_MODULE_0__.Barrier; },\n/* harmony export */ newBarrier: function() { return /* binding */ newBarrier; }\n/* harmony export */ });\n/* harmony import */ var _dr_pogodin_js_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @dr.pogodin/js-utils */ \"@dr.pogodin/js-utils\");\n/* harmony import */ var _dr_pogodin_js_utils__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_dr_pogodin_js_utils__WEBPACK_IMPORTED_MODULE_0__);\n\n\n\n/**\n * Creates a new Barrier.\n * @deprecated Prefer using `Barrier` class construction directly,\n * i.e. `new Barrier(executor)` instead of `newBarrier(executor)`.\n * @returns {Barrier}\n */\nfunction newBarrier(executor) {\n return new _dr_pogodin_js_utils__WEBPACK_IMPORTED_MODULE_0__.Barrier(executor);\n}\n\n//# sourceURL=webpack://@dr.pogodin/react-utils/./src/shared/utils/Barrier.js?");
230
-
231
- /***/ }),
232
-
233
213
  /***/ "./src/shared/utils/config.js":
234
214
  /*!************************************!*\
235
215
  !*** ./src/shared/utils/config.js ***!
@@ -246,7 +226,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _iso
246
226
  \***********************************/
247
227
  /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
248
228
 
249
- eval("var __dirname = \"/\";\n__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Barrier: function() { return /* reexport safe */ _Barrier__WEBPACK_IMPORTED_MODULE_6__.Barrier; },\n/* harmony export */ Emitter: function() { return /* reexport safe */ _dr_pogodin_js_utils__WEBPACK_IMPORTED_MODULE_5__.Emitter; },\n/* harmony export */ JU: function() { return /* binding */ JU; },\n/* harmony export */ Semaphore: function() { return /* reexport safe */ _dr_pogodin_js_utils__WEBPACK_IMPORTED_MODULE_5__.Semaphore; },\n/* harmony export */ ThemeProvider: function() { return /* reexport safe */ _dr_pogodin_react_themes__WEBPACK_IMPORTED_MODULE_0__.ThemeProvider; },\n/* harmony export */ config: function() { return /* reexport safe */ _config__WEBPACK_IMPORTED_MODULE_1__[\"default\"]; },\n/* harmony export */ isomorphy: function() { return /* reexport module object */ _isomorphy__WEBPACK_IMPORTED_MODULE_2__; },\n/* harmony export */ newBarrier: function() { return /* reexport safe */ _Barrier__WEBPACK_IMPORTED_MODULE_6__.newBarrier; },\n/* harmony export */ splitComponent: function() { return /* reexport safe */ _splitComponent__WEBPACK_IMPORTED_MODULE_7__[\"default\"]; },\n/* harmony export */ themed: function() { return /* reexport default from dynamic */ _dr_pogodin_react_themes__WEBPACK_IMPORTED_MODULE_0___default.a; },\n/* harmony export */ time: function() { return /* reexport safe */ _time__WEBPACK_IMPORTED_MODULE_3__[\"default\"]; },\n/* harmony export */ webpack: function() { return /* reexport module object */ _webpack__WEBPACK_IMPORTED_MODULE_4__; },\n/* harmony export */ withRetries: function() { return /* binding */ withRetries; }\n/* harmony export */ });\n/* harmony import */ var _dr_pogodin_react_themes__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @dr.pogodin/react-themes */ \"@dr.pogodin/react-themes\");\n/* harmony import */ var _dr_pogodin_react_themes__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_dr_pogodin_react_themes__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./config */ \"./src/shared/utils/config.js\");\n/* harmony import */ var _isomorphy__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./isomorphy */ \"./src/shared/utils/isomorphy/index.js\");\n/* harmony import */ var _time__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./time */ \"./src/shared/utils/time.js\");\n/* harmony import */ var _webpack__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webpack */ \"./src/shared/utils/webpack.js\");\n/* harmony import */ var _dr_pogodin_js_utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @dr.pogodin/js-utils */ \"@dr.pogodin/js-utils\");\n/* harmony import */ var _dr_pogodin_js_utils__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_dr_pogodin_js_utils__WEBPACK_IMPORTED_MODULE_5__);\n/* harmony import */ var _Barrier__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Barrier */ \"./src/shared/utils/Barrier.js\");\n/* harmony import */ var _splitComponent__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./splitComponent */ \"./src/shared/utils/splitComponent.js\");\n\n\n\n\n\n\n\n\n(_dr_pogodin_react_themes__WEBPACK_IMPORTED_MODULE_0___default().COMPOSE) = _dr_pogodin_react_themes__WEBPACK_IMPORTED_MODULE_0__.COMPOSE;\n(_dr_pogodin_react_themes__WEBPACK_IMPORTED_MODULE_0___default().PRIORITY) = _dr_pogodin_react_themes__WEBPACK_IMPORTED_MODULE_0__.PRIORITY;\n\n// Note: it should be done this way, as in some environments\n// \"process\" might not exist, and process.env.NODE_CONFIG_ENV\n// not injected by Webpack.\nlet NODE_CONFIG_ENV;\ntry {\n NODE_CONFIG_ENV = process.env.NODE_CONFIG_ENV;\n} catch {/* noop */}\nconst env = NODE_CONFIG_ENV || \"development\";\nconst JU = env !== 'production' && _webpack__WEBPACK_IMPORTED_MODULE_4__.requireWeak('./jest', __dirname);\n\n/**\n * @category Utilities\n * @global\n * @func withRetries\n * @desc\n * ```js\n * import { withRetries } from '@dr.pogodin/react-utils';\n * ```\n * Attempts to perform given asynchronous `action` up to `maxRetries` times,\n * with the given `interval` between attempts. If any attempt is successful,\n * the result is returned immediately, with no further attempts done;\n * otherwise, if all attempts fail, the result Promise rejects after the last\n * attempt.\n * @param {function} action\n * @param {number} [maxRetries=5] Optional. Maximum number of retries. Defaults\n * to 5 attempts.\n * @param {number} [interval=1000] Optional. Interval between retries [ms].\n * Defaults to 1 second.\n * @return {Promise} Resolves to the result of successful operation, or\n * rejects with the error from the latst failed attempt.\n * @example\n * import { withRetries } from '@dr.pogodin/react-utils';\n *\n * let firstCall = true;\n *\n * function sampleAction() {\n * if (!firstCall) return 'success';\n * firstCall = false;\n * throw Error('The first call to this method fails');\n * }\n *\n * withRetries(sampleAction).then(console.log);\n * // It will print 'success' after one second, once the second attempt\n * // is performed.\n */\nasync function withRetries(action) {\n let maxRetries = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 5;\n let interval = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1000;\n /* eslint-disable no-await-in-loop */\n for (let n = 1;; ++n) {\n try {\n return await action();\n } catch (error) {\n if (n < maxRetries) await _time__WEBPACK_IMPORTED_MODULE_3__[\"default\"].timer(interval);else throw error;\n }\n }\n /* eslint-enable no-await-in-loop */\n}\n\n\n\n//# sourceURL=webpack://@dr.pogodin/react-utils/./src/shared/utils/index.js?");
229
+ eval("var __dirname = \"/\";\n__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Barrier: function() { return /* reexport safe */ _dr_pogodin_js_utils__WEBPACK_IMPORTED_MODULE_5__.Barrier; },\n/* harmony export */ Emitter: function() { return /* reexport safe */ _dr_pogodin_js_utils__WEBPACK_IMPORTED_MODULE_5__.Emitter; },\n/* harmony export */ JU: function() { return /* binding */ JU; },\n/* harmony export */ Semaphore: function() { return /* reexport safe */ _dr_pogodin_js_utils__WEBPACK_IMPORTED_MODULE_5__.Semaphore; },\n/* harmony export */ ThemeProvider: function() { return /* reexport safe */ _dr_pogodin_react_themes__WEBPACK_IMPORTED_MODULE_0__.ThemeProvider; },\n/* harmony export */ config: function() { return /* reexport safe */ _config__WEBPACK_IMPORTED_MODULE_1__[\"default\"]; },\n/* harmony export */ isomorphy: function() { return /* reexport module object */ _isomorphy__WEBPACK_IMPORTED_MODULE_2__; },\n/* harmony export */ splitComponent: function() { return /* reexport safe */ _splitComponent__WEBPACK_IMPORTED_MODULE_6__[\"default\"]; },\n/* harmony export */ themed: function() { return /* reexport default from dynamic */ _dr_pogodin_react_themes__WEBPACK_IMPORTED_MODULE_0___default.a; },\n/* harmony export */ time: function() { return /* reexport safe */ _time__WEBPACK_IMPORTED_MODULE_3__[\"default\"]; },\n/* harmony export */ webpack: function() { return /* reexport module object */ _webpack__WEBPACK_IMPORTED_MODULE_4__; },\n/* harmony export */ withRetries: function() { return /* binding */ withRetries; }\n/* harmony export */ });\n/* harmony import */ var _dr_pogodin_react_themes__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @dr.pogodin/react-themes */ \"@dr.pogodin/react-themes\");\n/* harmony import */ var _dr_pogodin_react_themes__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_dr_pogodin_react_themes__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./config */ \"./src/shared/utils/config.js\");\n/* harmony import */ var _isomorphy__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./isomorphy */ \"./src/shared/utils/isomorphy/index.js\");\n/* harmony import */ var _time__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./time */ \"./src/shared/utils/time.js\");\n/* harmony import */ var _webpack__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webpack */ \"./src/shared/utils/webpack.js\");\n/* harmony import */ var _dr_pogodin_js_utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @dr.pogodin/js-utils */ \"@dr.pogodin/js-utils\");\n/* harmony import */ var _dr_pogodin_js_utils__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_dr_pogodin_js_utils__WEBPACK_IMPORTED_MODULE_5__);\n/* harmony import */ var _splitComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./splitComponent */ \"./src/shared/utils/splitComponent.jsx\");\n\n\n\n\n\n\n\n(_dr_pogodin_react_themes__WEBPACK_IMPORTED_MODULE_0___default().COMPOSE) = _dr_pogodin_react_themes__WEBPACK_IMPORTED_MODULE_0__.COMPOSE;\n(_dr_pogodin_react_themes__WEBPACK_IMPORTED_MODULE_0___default().PRIORITY) = _dr_pogodin_react_themes__WEBPACK_IMPORTED_MODULE_0__.PRIORITY;\n\n// Note: it should be done this way, as in some environments\n// \"process\" might not exist, and process.env.NODE_CONFIG_ENV\n// not injected by Webpack.\nlet NODE_CONFIG_ENV;\ntry {\n NODE_CONFIG_ENV = process.env.NODE_CONFIG_ENV;\n} catch {/* noop */}\nconst env = NODE_CONFIG_ENV || \"development\";\nconst JU = env !== 'production' && _webpack__WEBPACK_IMPORTED_MODULE_4__.requireWeak('./jest', __dirname);\n\n/**\n * @category Utilities\n * @global\n * @func withRetries\n * @desc\n * ```js\n * import { withRetries } from '@dr.pogodin/react-utils';\n * ```\n * Attempts to perform given asynchronous `action` up to `maxRetries` times,\n * with the given `interval` between attempts. If any attempt is successful,\n * the result is returned immediately, with no further attempts done;\n * otherwise, if all attempts fail, the result Promise rejects after the last\n * attempt.\n * @param {function} action\n * @param {number} [maxRetries=5] Optional. Maximum number of retries. Defaults\n * to 5 attempts.\n * @param {number} [interval=1000] Optional. Interval between retries [ms].\n * Defaults to 1 second.\n * @return {Promise} Resolves to the result of successful operation, or\n * rejects with the error from the latst failed attempt.\n * @example\n * import { withRetries } from '@dr.pogodin/react-utils';\n *\n * let firstCall = true;\n *\n * function sampleAction() {\n * if (!firstCall) return 'success';\n * firstCall = false;\n * throw Error('The first call to this method fails');\n * }\n *\n * withRetries(sampleAction).then(console.log);\n * // It will print 'success' after one second, once the second attempt\n * // is performed.\n */\nasync function withRetries(action) {\n let maxRetries = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 5;\n let interval = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1000;\n /* eslint-disable no-await-in-loop */\n for (let n = 1;; ++n) {\n try {\n return await action();\n } catch (error) {\n if (n < maxRetries) await _time__WEBPACK_IMPORTED_MODULE_3__[\"default\"].timer(interval);else throw error;\n }\n }\n /* eslint-enable no-await-in-loop */\n}\n\n\n\n//# sourceURL=webpack://@dr.pogodin/react-utils/./src/shared/utils/index.js?");
250
230
 
251
231
  /***/ }),
252
232
 
@@ -280,13 +260,13 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
280
260
 
281
261
  /***/ }),
282
262
 
283
- /***/ "./src/shared/utils/splitComponent.js":
284
- /*!********************************************!*\
285
- !*** ./src/shared/utils/splitComponent.js ***!
286
- \********************************************/
263
+ /***/ "./src/shared/utils/splitComponent.jsx":
264
+ /*!*********************************************!*\
265
+ !*** ./src/shared/utils/splitComponent.jsx ***!
266
+ \*********************************************/
287
267
  /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
288
268
 
289
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": function() { return /* binding */ splitComponent; }\n/* harmony export */ });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _components_CodeSplit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../components/CodeSplit */ \"./src/shared/components/CodeSplit/index.jsx\");\n/* eslint-disable react/jsx-props-no-spreading */\n\n\n\n\n/**\n * Wraps a regular React component into a \"code splitting\" component,\n * i.e. all code used exclusively by that component and its sub-tree\n * will go into a separate, asynchronously loaded, code chunk for\n * the client-side.\n * @param {object} options\n * @param {string} options.chunkName\n * @param {function} options.getComponent\n * @param {React.Element} [options.placeholder]\n * @return {React.ElementType}\n */\nfunction splitComponent(_ref) {\n let {\n chunkName,\n getComponent,\n placeholder\n } = _ref;\n // eslint-disable-next-line react/prop-types\n return function () {\n let {\n children,\n ...props\n } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n return /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_components_CodeSplit__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {\n ...props,\n chunkName,\n getComponent,\n placeholder\n }, children);\n };\n}\n\n//# sourceURL=webpack://@dr.pogodin/react-utils/./src/shared/utils/splitComponent.js?");
269
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ bookStyleSheets: function() { return /* binding */ bookStyleSheets; },\n/* harmony export */ \"default\": function() { return /* binding */ splitComponent; },\n/* harmony export */ freeStyleSheets: function() { return /* binding */ freeStyleSheets; }\n/* harmony export */ });\n/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! prop-types */ \"prop-types\");\n/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ \"react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _dr_pogodin_js_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @dr.pogodin/js-utils */ \"@dr.pogodin/js-utils\");\n/* harmony import */ var _dr_pogodin_js_utils__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_dr_pogodin_js_utils__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @dr.pogodin/react-global-state */ \"@dr.pogodin/react-global-state\");\n/* harmony import */ var _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var _isomorphy__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./isomorphy */ \"./src/shared/utils/isomorphy/index.js\");\n/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react/jsx-runtime */ \"./node_modules/react/jsx-runtime.js\");\n/* eslint-disable react/jsx-props-no-spreading */\n/* global document */\n\n\n\n\n\n\n\n// Note: At the client side we can get chunk groups immediately when loading\n// the module; at the server-side we only can get them within React render flow.\n// Thus, we set and use the following variable at the client-side, and then when\n// needed on the server side, we'll fetch it differently.\n\nlet clientChunkGroups;\nif (_isomorphy__WEBPACK_IMPORTED_MODULE_4__.IS_CLIENT_SIDE) {\n // eslint-disable-next-line global-require\n clientChunkGroups = (__webpack_require__(/*! ../../client/getInj */ \"./src/client/getInj.js\")[\"default\"])().CHUNK_GROUPS || {};\n}\nconst refCounts = {};\nfunction getPublicPath() {\n return (0,_isomorphy__WEBPACK_IMPORTED_MODULE_4__.getBuildInfo)().publicPath;\n}\n\n/**\n * Client-side only! Ensures the specified CSS stylesheet is loaded into\n * the document; loads if it is missing; and does simple reference counting\n * to facilitate future clean-up.\n * @param {string} name\n * @param {Set} loadedSheets\n * @param {boolean} refCount\n * @return {Promise}\n */\nfunction bookStyleSheet(name, loadedSheets, refCount) {\n let res;\n const path = `${getPublicPath()}/${name}`;\n const fullPath = `${document.location.origin}${path}`;\n if (!loadedSheets.has(fullPath)) {\n let link = document.querySelector(`link[href=\"${path}\"]`);\n if (!link) {\n link = document.createElement('link');\n link.setAttribute('rel', 'stylesheet');\n link.setAttribute('href', path);\n document.head.appendChild(link);\n }\n res = new _dr_pogodin_js_utils__WEBPACK_IMPORTED_MODULE_2__.Barrier();\n link.addEventListener('load', res.resolve);\n link.addEventListener('error', res.resolve);\n }\n if (refCount) {\n const current = refCounts[path] || 0;\n refCounts[path] = 1 + current;\n }\n return res;\n}\n\n/**\n * Generates the set of URLs for currently loaded, linked stylesheets.\n * @return {Set}\n */\nfunction getLoadedStyleSheets() {\n const res = new Set();\n const {\n styleSheets\n } = document;\n for (let i = 0; i < styleSheets.length; ++i) {\n const {\n href\n } = styleSheets[i];\n if (href) res.add(href);\n }\n return res;\n}\nfunction assertChunkName(chunkName, chunkGroups) {\n if (chunkGroups[chunkName]) return;\n throw Error(`Unknown chunk name \"${chunkName}\"`);\n}\n\n/**\n * Client-side only! Ensures all CSS stylesheets required for the specified\n * code chunk are loaded into the document; loads the missing ones; and does\n * simple reference counting to facilitate future clean-up.\n * @param {string} chunkName Chunk name.\n * @param {boolean} refCount\n * @return {Promise} Resolves once all pending stylesheets, necessary for\n * the chunk, are either loaded, or failed to load.\n */\nfunction bookStyleSheets(chunkName, chunkGroups, refCount) {\n const promises = [];\n const assets = chunkGroups[chunkName];\n const loadedSheets = getLoadedStyleSheets();\n for (let i = 0; i < assets.length; ++i) {\n const asset = assets[i];\n if (asset.endsWith('.css')) {\n const promise = bookStyleSheet(asset, loadedSheets, refCount);\n if (promise) promises.push(promise);\n }\n }\n return promises.length ? Promise.allSettled(promises) : Promise.resolve();\n}\n\n/**\n * Client-side only! Frees from the document all CSS stylesheets that are\n * required by the specified chunk, and have reference counter equal to one\n * (for chunks with larger reference counter values, it just decrements\n * the reference counter).\n * @param {string} chunkName\n */\nfunction freeStyleSheets(chunkName, chunkGroups) {\n const assets = chunkGroups[chunkName];\n for (let i = 0; i < assets.length; ++i) {\n const asset = assets[i];\n if (asset.endsWith('.css')) {\n const path = `${getPublicPath()}/${asset}`;\n if (--refCounts[path] <= 0) {\n document.head.querySelector(`link[href=\"${path}\"]`).remove();\n }\n }\n }\n}\n\n// Holds the set of chunk names already used for splitComponent() calls.\nconst usedChunkNames = new Set();\n\n/**\n * Given an async component retrieval function `getComponent()` it creates\n * a special \"code split\" component, which uses <Suspense> to asynchronously\n * load on demand the code required by `getComponent()`.\n * @param {object} options\n * @param {string} options.chunkName\n * @param {function} options.getComponent\n * @param {React.Element} [options.placeholder]\n * @return {React.ElementType}\n */\nfunction splitComponent(_ref) {\n let {\n chunkName,\n getComponent,\n placeholder\n } = _ref;\n // On the client side we can check right away if the chunk name is known.\n if (_isomorphy__WEBPACK_IMPORTED_MODULE_4__.IS_CLIENT_SIDE) assertChunkName(chunkName, clientChunkGroups);\n\n // The correct usage of splitComponent() assumes a single call per chunk.\n if (usedChunkNames.has(chunkName)) {\n throw Error(`Repeated splitComponent() call for the chunk \"${chunkName}\"`);\n } else usedChunkNames.add(chunkName);\n const LazyComponent = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_1__.lazy)(async () => {\n let Component = await getComponent();\n if (Component.default) Component = Component.default;\n\n // This pre-loads necessary stylesheets prior to the first mount of\n // the component (the lazy load function is executed by React one at\n // the frist mount).\n if (_isomorphy__WEBPACK_IMPORTED_MODULE_4__.IS_CLIENT_SIDE) {\n await bookStyleSheets(chunkName, clientChunkGroups, false);\n }\n const Wrapper = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_1__.forwardRef)((_ref2, ref) => {\n let {\n children,\n ...rest\n } = _ref2;\n // On the server side we'll assert the chunk name here,\n // and also push it to the SSR chunks array.\n if (_isomorphy__WEBPACK_IMPORTED_MODULE_4__.IS_SERVER_SIDE) {\n const {\n chunkGroups,\n chunks\n } = (0,_dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_3__.getSsrContext)();\n assertChunkName(chunkName, chunkGroups);\n if (!chunks.includes(chunkName)) chunks.push(chunkName);\n }\n\n // This takes care about stylesheets management every time an instance of\n // this component is mounted / unmounted.\n (0,react__WEBPACK_IMPORTED_MODULE_1__.useInsertionEffect)(() => {\n bookStyleSheets(chunkName, clientChunkGroups, true);\n return () => freeStyleSheets(chunkName, clientChunkGroups);\n }, []);\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(Component, {\n ref: ref,\n ...rest,\n children: children\n });\n });\n Wrapper.propTypes = {\n children: (prop_types__WEBPACK_IMPORTED_MODULE_0___default().node)\n };\n Wrapper.defaultProps = {\n children: undefined\n };\n return {\n default: Wrapper\n };\n });\n function CodeSplit(_ref3) {\n let {\n children,\n ...rest\n } = _ref3;\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(react__WEBPACK_IMPORTED_MODULE_1__.Suspense, {\n fallback: placeholder,\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(LazyComponent, {\n ...rest,\n children: children\n })\n });\n }\n CodeSplit.propTypes = {\n children: (prop_types__WEBPACK_IMPORTED_MODULE_0___default().node)\n };\n CodeSplit.defaultProps = {\n children: undefined\n };\n return CodeSplit;\n}\n\n//# sourceURL=webpack://@dr.pogodin/react-utils/./src/shared/utils/splitComponent.jsx?");
290
270
 
291
271
  /***/ }),
292
272
 
@@ -87,17 +87,21 @@ const{publicPath,path:outputPath}=webpackConfig.output;const manifestLink=_fs.de
87
87
  res.set("Cache-Control","no-cache");res.cookie("csrfToken",req.csrfToken());let cacheRef;if(cache){cacheRef=ops.staticCacheController(req);if(cacheRef){const data=cache.get(cacheRef);if(data!==null){const{buffer,status}=data;if(ops.noCsp&&isBrotliAcceptable(req)){res.set("Content-Type","text/html");res.set("Content-Encoding","br");if(status!==200)res.status(status);res.send(buffer)}else{await new Promise((done,failed)=>{(0,_zlib.brotliDecompress)(buffer,(error,html)=>{if(error)failed(error);else{let h=html.toString();if(!ops.noCsp){// TODO: Starting from Node v15 we'll be able to use string's
88
88
  // .replaceAll() method instead relying on reg. expression for
89
89
  // global matching.
90
- const regex=new RegExp(buffer.nonce,"g");h=h.replace(regex,req.nonce)}if(status!==200)res.status(status);res.send(h);done()}})})}return}}}const[{configToInject,extraScripts,initialState},{cipher,iv}]=await Promise.all([ops.beforeRender(req,sanitizedConfig),prepareCipher(buildInfo.key)]);let helmet;/* Optional server-side rendering. */let App=ops.Application;const ssrContext={req,state:(0,_lodash.cloneDeep)(initialState||{}),// Array of chunk names encountered during the rendering.
91
- chunks:[]};let stream;if(App){const ssrStart=Date.now();const renderPass=async()=>{ssrContext.chunks=[];return new Promise((resolve,reject)=>{const pipeableStream=(0,_server.renderToPipeableStream)(/*#__PURE__*/(0,_jsxRuntime.jsx)(_reactGlobalState.GlobalStateProvider,{initialState:ssrContext.state,ssrContext:ssrContext,children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_server2.StaticRouter,{location:req.url,children:/*#__PURE__*/(0,_jsxRuntime.jsx)(App,{})})}),{onAllReady:()=>resolve(pipeableStream),onError:reject})})};let ssrRound=0;let bailed=false;for(;ssrRound<ops.maxSsrRounds;++ssrRound){stream=await renderPass();// eslint-disable-line no-await-in-loop
90
+ const regex=new RegExp(buffer.nonce,"g");h=h.replace(regex,req.nonce)}if(status!==200)res.status(status);res.send(h);done()}})})}return}}}const[{configToInject,extraScripts,initialState},{cipher,iv}]=await Promise.all([ops.beforeRender(req,sanitizedConfig),prepareCipher(buildInfo.key)]);let helmet;// Gets the mapping between code chunk names and their asset files.
91
+ // These data come from the Webpack compilation, either from the stats
92
+ // attached to the request (in dev mode), or from a file output during
93
+ // the build (in prod mode).
94
+ let chunkGroups;const webpackStats=(0,_lodash.get)(res.locals,"webpack.devMiddleware.stats");if(webpackStats){chunkGroups=(0,_lodash.mapValues)(webpackStats.toJson({all:false,chunkGroups:true}).namedChunkGroups,item=>item.assets.map(({name})=>name))}else if(CHUNK_GROUPS)chunkGroups=CHUNK_GROUPS;else chunkGroups={};/* Optional server-side rendering. */let App=ops.Application;const ssrContext={req,state:(0,_lodash.cloneDeep)(initialState||{}),// Array of chunk names encountered during the rendering.
95
+ chunks:[],chunkGroups};let stream;if(App){const ssrStart=Date.now();const renderPass=async()=>{ssrContext.chunks=[];return new Promise((resolve,reject)=>{const pipeableStream=(0,_server.renderToPipeableStream)(/*#__PURE__*/(0,_jsxRuntime.jsx)(_reactGlobalState.GlobalStateProvider,{initialState:ssrContext.state,ssrContext:ssrContext,children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_server2.StaticRouter,{location:req.url,children:/*#__PURE__*/(0,_jsxRuntime.jsx)(App,{})})}),{onAllReady:()=>resolve(pipeableStream),onError:reject})})};let ssrRound=0;let bailed=false;for(;ssrRound<ops.maxSsrRounds;++ssrRound){stream=await renderPass();// eslint-disable-line no-await-in-loop
92
96
  if(!ssrContext.dirty)break;/* eslint-disable no-await-in-loop */const timeout=ops.ssrTimeout+ssrStart-Date.now();bailed=timeout<=0||!(await Promise.race([Promise.allSettled(ssrContext.pending),(0,_jsUtils.timer)(timeout).then(()=>false)]));if(bailed)break;/* eslint-enable no-await-in-loop */}let logMsg;if(ssrContext.dirty){// NOTE: In the case of incomplete SSR one more round is necessary
93
97
  // to ensure the correct hydration when some pending promises have
94
98
  // resolved and placed their data into the initial global state.
95
99
  stream=await renderPass();logMsg=bailed?`SSR timed out after ${ops.ssrTimeout} second(s)`:`SSR bailed out after ${ops.maxSsrRounds} round(s)`}else logMsg=`SSR completed in ${ssrRound+1} round(s)`;ops.logger.log(ssrContext.dirty?"warn":"info",logMsg);App="";stream.pipe(new _stream.Writable({write:(chunk,_,done)=>{App+=chunk.toString();done()}}));/* This takes care about server-side rendering of page title and meta tags
96
- * (still demands injection into HTML template, which happens below). */helmet=_reactHelmet.Helmet.renderStatic()}let chunkGroups;const webpackStats=(0,_lodash.get)(res.locals,"webpack.devMiddleware.stats");if(webpackStats){chunkGroups=(0,_lodash.mapValues)(webpackStats.toJson({all:false,chunkGroups:true}).namedChunkGroups,item=>item.assets.map(({name})=>name))}else if(CHUNK_GROUPS)chunkGroups=CHUNK_GROUPS;else chunkGroups={};/* Encrypts data to be injected into HTML.
100
+ * (still demands injection into HTML template, which happens below). */helmet=_reactHelmet.Helmet.renderStatic()}/* Encrypts data to be injected into HTML.
97
101
  * Keep in mind, that this encryption is no way secure: as the JS bundle
98
102
  * contains decryption key and is able to decode it at the client side.
99
103
  * Hovewer, for a number of reasons, encryption of injected data is still
100
- * better than injection of a plain text. */delete ssrContext.state.dr_pogodin_react_utils___split_components;const payload=(0,_serializeJavascript.default)({CHUNK_GROUPS:chunkGroups,CONFIG:configToInject||sanitizedConfig,ISTATE:ssrContext.state},{ignoreFunction:true,unsafe:true});cipher.update(_nodeForge.default.util.createBuffer(payload,"utf8"));cipher.finish();const INJ=_nodeForge.default.util.encode64(`${iv}${cipher.output.data}`);const chunkSet=new Set;// TODO: "main" chunk has to be added explicitly,
104
+ * better than injection of a plain text. */const payload=(0,_serializeJavascript.default)({CHUNK_GROUPS:chunkGroups,CONFIG:configToInject||sanitizedConfig,ISTATE:ssrContext.state},{ignoreFunction:true,unsafe:true});cipher.update(_nodeForge.default.util.createBuffer(payload,"utf8"));cipher.finish();const INJ=_nodeForge.default.util.encode64(`${iv}${cipher.output.data}`);const chunkSet=new Set;// TODO: "main" chunk has to be added explicitly,
101
105
  // because unlike all other chunks they are not managed by <CodeSplit>
102
106
  // component, thus they are not added to the ssrContext.chunks
103
107
  // automatically. Actually, names of these entry chunks should be
@@ -1 +1 @@
1
- {"version":3,"file":"renderer.js","names":["_stream","require","_reactGlobalState","_jsUtils","_lodash","_config","_interopRequireDefault","_nodeForge","_fs","_path","_zlib","_server","_reactHelmet","_server2","_serializeJavascript","_buildInfo","_winston","_Cache","_jsxRuntime","sanitizedConfig","omit","config","SCRIPT_LOCATIONS","BODY_OPEN","DEFAULT","HEAD_OPEN","exports","getBuildInfo","context","url","path","resolve","JSON","parse","fs","readFileSync","readChunkGroupsJson","buildDir","res","err","prepareCipher","key","Promise","reject","forge","random","getBytes","iv","cipher","createCipher","start","isBrotliAcceptable","req","acceptable","get","ops","split","i","length","type","priority","trim","parseFloat","groupExtraScripts","scripts","script","isString","code","location","undefined","Error","newDefaultLogger","defaultLogLevel","format","transports","winston","createLogger","level","combine","splat","timestamp","colorize","printf","message","stack","rest","Object","keys","stringify","Console","factory","webpackConfig","options","defaults","clone","beforeRender","maxSsrRounds","ssrTimeout","staticCacheSize","logger","defaultLoggerLogLevel","buildInfo","setBuildInfo","publicPath","outputPath","output","manifestLink","existsSync","cache","staticCacheController","Cache","CHUNK_GROUPS","next","set","cookie","csrfToken","cacheRef","data","buffer","status","noCsp","send","done","failed","brotliDecompress","error","html","h","toString","regex","RegExp","nonce","replace","configToInject","extraScripts","initialState","all","helmet","App","Application","ssrContext","state","cloneDeep","chunks","stream","ssrStart","Date","now","renderPass","pipeableStream","renderToPipeableStream","jsx","GlobalStateProvider","children","StaticRouter","onAllReady","onError","ssrRound","bailed","dirty","timeout","race","allSettled","pending","timer","then","logMsg","log","pipe","Writable","write","chunk","_","Helmet","renderStatic","chunkGroups","webpackStats","locals","mapValues","toJson","namedChunkGroups","item","assets","map","name","dr_pogodin_react_utils___split_components","payload","serializeJs","CONFIG","ISTATE","ignoreFunction","unsafe","update","util","createBuffer","finish","INJ","encode64","chunkSet","Set","forEach","asset","add","styleChunkString","scriptChunkString","endsWith","grouppedExtraScripts","faviconLink","favicon","title","meta","brotliCompress"],"sources":["../../../src/server/renderer.jsx"],"sourcesContent":["/**\n * ExpressJS middleware for server-side rendering of a ReactJS app.\n */\n\nimport { Writable } from 'stream';\n\nimport { GlobalStateProvider } from '@dr.pogodin/react-global-state';\nimport { timer } from '@dr.pogodin/js-utils';\n\nimport {\n clone,\n cloneDeep,\n defaults,\n isString,\n get,\n mapValues,\n omit,\n} from 'lodash';\n\nimport config from 'config';\nimport forge from 'node-forge';\nimport fs from 'fs';\nimport path from 'path';\nimport { brotliCompress, brotliDecompress } from 'zlib';\n\nimport { renderToPipeableStream } from 'react-dom/server';\nimport { Helmet } from 'react-helmet';\nimport { StaticRouter } from 'react-router-dom/server';\nimport serializeJs from 'serialize-javascript';\nimport { setBuildInfo } from 'utils/isomorphy/buildInfo';\nimport winston from 'winston';\n\nimport Cache from './Cache';\n\nconst sanitizedConfig = omit(config, 'SECRET');\n\nexport const SCRIPT_LOCATIONS = {\n BODY_OPEN: 'BODY_OPEN',\n DEFAULT: 'DEFAULT',\n HEAD_OPEN: 'HEAD_OPEN',\n};\n\n/**\n * Reads build-time information about the app. This information is generated\n * by our standard Webpack config for apps, and it is written into\n * \".build-info\" file in the context folder specified in Webpack config.\n * At the moment, that file contains build timestamp and a random 32-bit key,\n * suitable for cryptographical use.\n * @ignore\n * @param {String} context Webpack context path used during the build.\n * @return {Object} Resolves to the build-time information.\n */\nfunction getBuildInfo(context) {\n const url = path.resolve(context, '.build-info');\n return JSON.parse(fs.readFileSync(url));\n}\n\n/**\n * Attempts to read from disk the named chunk groups mapping generated\n * by Webpack during the compilation.\n * It will not work for development builds, where these stats should be captured\n * via compilator callback.\n * @ignore\n * @param {string} buildDir\n * @return {object}\n */\nfunction readChunkGroupsJson(buildDir) {\n const url = path.resolve(buildDir, '__chunk_groups__.json');\n let res;\n try {\n res = JSON.parse(fs.readFileSync(url));\n } catch (err) {\n res = null;\n }\n return res;\n}\n\n/**\n * Prepares a new Cipher for data encryption.\n * @ignore\n * @param {String} key Encryption key (32-bit random key is expected, see\n * node-forge documentation, in case of doubts).\n * @return {Promise} Resolves to the object with two fields:\n * 1. cipher - a new Cipher, ready for encryption;\n * 2. iv - initial vector used by the cipher.\n */\nfunction prepareCipher(key) {\n return new Promise((resolve, reject) => {\n forge.random.getBytes(32, (err, iv) => {\n if (err) reject(err);\n else {\n const cipher = forge.cipher.createCipher('AES-CBC', key);\n cipher.start({ iv });\n resolve({ cipher, iv });\n }\n });\n });\n}\n\n/**\n * Given an incoming HTTP requests, it deduces whether Brotli-encoded responses\n * are acceptable to the caller.\n * @param {object} req\n * @return {boolean}\n * @ignore\n */\nexport function isBrotliAcceptable(req) {\n const acceptable = req.get('accept-encoding');\n if (acceptable) {\n const ops = acceptable.split(',');\n for (let i = 0; i < ops.length; ++i) {\n const [type, priority] = ops[i].trim().split(';q=');\n if ((type === '*' || type === 'br')\n && (!priority || parseFloat(priority) > 0)) {\n return true;\n }\n }\n }\n return false;\n}\n\n/**\n * Given an array of extra script strings / objects, it returns an object with\n * arrays of scripts to inject in different HTML template locations. During\n * the script groupping it also filters out any empty scripts.\n * @param {({\n * code: string;\n * location: string;\n * }|string)[]} [scripts=[]]\n * @return {{\n * BODY_OPEN: string[];\n * DEFAULT: string[];\n * HEAD_OPEN: string[];\n * }}\n */\nfunction groupExtraScripts(scripts = []) {\n const res = {\n [SCRIPT_LOCATIONS.BODY_OPEN]: '',\n [SCRIPT_LOCATIONS.DEFAULT]: '',\n [SCRIPT_LOCATIONS.HEAD_OPEN]: '',\n };\n for (let i = 0; i < scripts.length; ++i) {\n const script = scripts[i];\n if (isString(script)) {\n if (script) res[SCRIPT_LOCATIONS.DEFAULT] += script;\n } else if (script.code) {\n if (res[script.location] !== undefined) {\n res[script.location] += script.code;\n } else throw Error(`Invalid location \"${script.location}\"`);\n }\n }\n return res;\n}\n\n/**\n * Creates a new default (Winston) logger.\n * @param {object} [options={}]\n * @param {string} [options.defaultLogLevel='info']\n * @return {object}\n */\nexport function newDefaultLogger({\n defaultLogLevel = 'info',\n} = {}) {\n const { format, transports } = winston;\n return winston.createLogger({\n level: defaultLogLevel,\n format: format.combine(\n format.splat(),\n format.timestamp(),\n format.colorize(),\n format.printf(\n ({\n level,\n message,\n timestamp,\n stack,\n ...rest\n }) => {\n let res = `${level}\\t(at ${timestamp}):\\t${message}`;\n if (Object.keys(rest).length) {\n res += `\\n${JSON.stringify(rest, null, 2)}`;\n }\n if (stack) res += `\\n${stack}`;\n return res;\n },\n ),\n ),\n transports: [new transports.Console()],\n });\n}\n\n/**\n * Creates the middleware.\n * @param {object} webpackConfig\n * @param {object} options Additional options:\n * @param {Component} [options.Application] The root ReactJS component of\n * the app to use for the server-side rendering. When not provided\n * the server-side rendering is disabled.\n * @param {object} [options.buildInfo] \"Build info\" object to use. If provided,\n * it will be used, instead of trying to load from the filesystem the one\n * generated by the Webpack build. It is intended for test environments,\n * where passing this stuff via file system is no bueno.\n * @param {boolean} [options.favicon] `true` will include favicon\n * link into the rendered HTML templates.\n * @param {boolean} [options.noCsp] `true` means that no\n * Content-Security-Policy (CSP) is used by server, thus the renderer\n * may cut a few corners.\n * @param {number} [options.maxSsrRounds=10] Maximum number of SSR rounds.\n * @param {number} [options.ssrTimeout=1000] SSR timeout in milliseconds,\n * defaults to 1 second.\n * @param {number} [options.staticCacheSize=1.e7] The maximum\n * static cache size in bytes. Defaults to ~10 MB.\n * @param {function} [options.staticCacheController] When given, it activates,\n * and controls the static caching of generated HTML markup. When this function\n * is provided, on each incoming request it is triggered with the request\n * passed in as the argument. To attempt to serve the response from the cache\n * it should return the object with the following fields:\n * - `key: string` &ndash; the cache key for the response;\n * - `maxage?: number` &ndash; the maximum age of cached result in ms.\n * If undefined - infinite age is assumed.\n * @return {function} Created middleware.\n */\nexport default function factory(webpackConfig, options) {\n const ops = defaults(clone(options), {\n beforeRender: () => Promise.resolve({}),\n maxSsrRounds: 10,\n ssrTimeout: 1000,\n staticCacheSize: 1.e7,\n });\n\n // Note: in normal use the default logger is created and set in the root\n // server function, and this initialization is for testing uses, where\n // renderer is imported directly.\n if (ops.logger === undefined) {\n ops.logger = newDefaultLogger({\n defaultLogLevel: ops.defaultLoggerLogLevel,\n });\n }\n\n const buildInfo = ops.buildInfo || getBuildInfo(webpackConfig.context);\n setBuildInfo(buildInfo);\n\n // publicPath from webpack.output has a trailing slash at the end.\n const { publicPath, path: outputPath } = webpackConfig.output;\n\n const manifestLink = fs.existsSync(`${outputPath}/manifest.json`)\n ? `<link rel=\"manifest\" href=\"${publicPath}manifest.json\">` : '';\n\n const cache = ops.staticCacheController\n ? new Cache(ops.staticCacheSize) : null;\n\n const CHUNK_GROUPS = readChunkGroupsJson(outputPath);\n\n return async (req, res, next) => {\n try {\n // Ensures any caches always revalidate HTML markup before reuse.\n res.set('Cache-Control', 'no-cache');\n\n res.cookie('csrfToken', req.csrfToken());\n\n let cacheRef;\n if (cache) {\n cacheRef = ops.staticCacheController(req);\n if (cacheRef) {\n const data = cache.get(cacheRef);\n if (data !== null) {\n const { buffer, status } = data;\n if (ops.noCsp && isBrotliAcceptable(req)) {\n res.set('Content-Type', 'text/html');\n res.set('Content-Encoding', 'br');\n if (status !== 200) res.status(status);\n res.send(buffer);\n } else {\n await new Promise((done, failed) => {\n brotliDecompress(buffer, (error, html) => {\n if (error) failed(error);\n else {\n let h = html.toString();\n if (!ops.noCsp) {\n // TODO: Starting from Node v15 we'll be able to use string's\n // .replaceAll() method instead relying on reg. expression for\n // global matching.\n const regex = new RegExp(buffer.nonce, 'g');\n h = h.replace(regex, req.nonce);\n }\n if (status !== 200) res.status(status);\n res.send(h);\n done();\n }\n });\n });\n }\n return;\n }\n }\n }\n\n const [{\n configToInject,\n extraScripts,\n initialState,\n }, {\n cipher,\n iv,\n }] = await Promise.all([\n ops.beforeRender(req, sanitizedConfig),\n prepareCipher(buildInfo.key),\n ]);\n\n let helmet;\n\n /* Optional server-side rendering. */\n let App = ops.Application;\n const ssrContext = {\n req,\n state: cloneDeep(initialState || {}),\n\n // Array of chunk names encountered during the rendering.\n chunks: [],\n };\n let stream;\n if (App) {\n const ssrStart = Date.now();\n\n const renderPass = async () => {\n ssrContext.chunks = [];\n return new Promise((resolve, reject) => {\n const pipeableStream = renderToPipeableStream(\n <GlobalStateProvider\n initialState={ssrContext.state}\n ssrContext={ssrContext}\n >\n <StaticRouter location={req.url}>\n <App />\n </StaticRouter>\n </GlobalStateProvider>,\n {\n onAllReady: () => resolve(pipeableStream),\n onError: reject,\n },\n );\n });\n };\n\n let ssrRound = 0;\n let bailed = false;\n for (; ssrRound < ops.maxSsrRounds; ++ssrRound) {\n stream = await renderPass(); // eslint-disable-line no-await-in-loop\n\n if (!ssrContext.dirty) break;\n\n /* eslint-disable no-await-in-loop */\n const timeout = ops.ssrTimeout + ssrStart - Date.now();\n bailed = timeout <= 0 || !await Promise.race([\n Promise.allSettled(ssrContext.pending),\n timer(timeout).then(() => false),\n ]);\n if (bailed) break;\n /* eslint-enable no-await-in-loop */\n }\n\n let logMsg;\n if (ssrContext.dirty) {\n // NOTE: In the case of incomplete SSR one more round is necessary\n // to ensure the correct hydration when some pending promises have\n // resolved and placed their data into the initial global state.\n stream = await renderPass();\n\n logMsg = bailed ? `SSR timed out after ${ops.ssrTimeout} second(s)`\n : `SSR bailed out after ${ops.maxSsrRounds} round(s)`;\n } else logMsg = `SSR completed in ${ssrRound + 1} round(s)`;\n\n ops.logger.log(ssrContext.dirty ? 'warn' : 'info', logMsg);\n\n App = '';\n stream.pipe(new Writable({\n write: (chunk, _, done) => {\n App += chunk.toString();\n done();\n },\n }));\n\n /* This takes care about server-side rendering of page title and meta tags\n * (still demands injection into HTML template, which happens below). */\n helmet = Helmet.renderStatic();\n }\n\n let chunkGroups;\n const webpackStats = get(res.locals, 'webpack.devMiddleware.stats');\n if (webpackStats) {\n chunkGroups = mapValues(\n webpackStats.toJson({\n all: false,\n chunkGroups: true,\n }).namedChunkGroups,\n (item) => item.assets.map(({ name }) => name),\n );\n } else if (CHUNK_GROUPS) chunkGroups = CHUNK_GROUPS;\n else chunkGroups = {};\n\n /* Encrypts data to be injected into HTML.\n * Keep in mind, that this encryption is no way secure: as the JS bundle\n * contains decryption key and is able to decode it at the client side.\n * Hovewer, for a number of reasons, encryption of injected data is still\n * better than injection of a plain text. */\n delete ssrContext.state.dr_pogodin_react_utils___split_components;\n\n const payload = serializeJs({\n CHUNK_GROUPS: chunkGroups,\n CONFIG: configToInject || sanitizedConfig,\n ISTATE: ssrContext.state,\n }, {\n ignoreFunction: true,\n unsafe: true,\n });\n cipher.update(forge.util.createBuffer(payload, 'utf8'));\n cipher.finish();\n const INJ = forge.util.encode64(`${iv}${cipher.output.data}`);\n\n const chunkSet = new Set();\n\n // TODO: \"main\" chunk has to be added explicitly,\n // because unlike all other chunks they are not managed by <CodeSplit>\n // component, thus they are not added to the ssrContext.chunks\n // automatically. Actually, names of these entry chunks should be\n // read from Wepback config, as the end user may customize them,\n // remove or add other entry points, but it requires additional\n // efforts to figure out how to automatically order them right,\n // thus for now this handles the default config.\n [\n 'main',\n ...ssrContext.chunks,\n ].forEach((chunk) => {\n const assets = chunkGroups[chunk];\n if (assets) assets.forEach((asset) => chunkSet.add(asset));\n });\n\n let styleChunkString = '';\n let scriptChunkString = '';\n chunkSet.forEach((chunk) => {\n if (chunk.endsWith('.css')) {\n styleChunkString += `<link href=\"${publicPath}${chunk}\" rel=\"stylesheet\">`;\n } else if (\n chunk.endsWith('.js')\n // In dev mode HMR adds JS updates into asset arrays,\n // and they (updates) should be ignored.\n && !chunk.endsWith('.hot-update.js')\n ) {\n scriptChunkString += `<script src=\"${publicPath}${chunk}\" type=\"application/javascript\"></script>`;\n }\n });\n\n const grouppedExtraScripts = groupExtraScripts(extraScripts);\n\n const faviconLink = ops.favicon ? (\n '<link rel=\"shortcut icon\" href=\"/favicon.ico\">'\n ) : '';\n\n const html = `<!DOCTYPE html>\n <html lang=\"en\">\n <head>\n ${grouppedExtraScripts[SCRIPT_LOCATIONS.HEAD_OPEN]}\n ${helmet ? helmet.title.toString() : ''}\n ${helmet ? helmet.meta.toString() : ''}\n <meta name=\"theme-color\" content=\"#FFFFFF\">\n ${manifestLink}\n ${styleChunkString}\n ${faviconLink}\n <meta charset=\"utf-8\">\n <meta\n content=\"width=device-width,initial-scale=1.0\"\n name=\"viewport\"\n >\n <meta itemprop=\"drpruinj\" content=\"${INJ}\">\n </head>\n <body>\n ${grouppedExtraScripts[SCRIPT_LOCATIONS.BODY_OPEN]}\n <div id=\"react-view\">${App || ''}</div>\n ${scriptChunkString}\n ${grouppedExtraScripts[SCRIPT_LOCATIONS.DEFAULT]}\n </body>\n </html>`;\n\n const status = ssrContext.status || 200;\n if (status !== 200) res.status(status);\n\n if (cacheRef && status < 500) {\n // Note: waiting for the caching to complete is not strictly necessary,\n // but it greately simplifies testing, and error reporting.\n await new Promise((done, failed) => {\n brotliCompress(html, (error, buffer) => {\n if (error) failed(error);\n else {\n buffer.nonce = req.nonce; // eslint-disable-line no-param-reassign\n cache.add({ buffer, status }, cacheRef.key);\n done();\n }\n });\n });\n }\n\n // Note: as caching code above may throw in some cases, sending response\n // before it completes will likely hide the error, making it difficult\n // to debug. Thus, at least for now, lets send response after it.\n res.send(html);\n } catch (error) {\n next(error);\n }\n };\n}\n"],"mappings":"ySAIA,IAAAA,OAAA,CAAAC,OAAA,WAEA,IAAAC,iBAAA,CAAAD,OAAA,mCACA,IAAAE,QAAA,CAAAF,OAAA,yBAEA,IAAAG,O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1B;AACA;AACA;AACA;AACA;AACA,iDAAiDX,GAAI;AACrD;AACA;AACA,cAAcU,oBAAoB,CAACxL,gBAAgB,CAACC,SAAS,CAAE;AAC/D,mCAAmCmH,GAAG,EAAI,EAAG;AAC7C,cAAckE,iBAAkB;AAChC,cAAcE,oBAAoB,CAACxL,gBAAgB,CAACE,OAAO,CAAE;AAC7D;AACA,gBAAgB,CAEV,KAAM,CAAA+F,MAAM,CAAGqB,UAAU,CAACrB,MAAM,EAAI,GAAG,CACvC,GAAIA,MAAM,GAAK,GAAG,CAAEjF,GAAG,CAACiF,MAAM,CAACA,MAAM,CAAC,CAEtC,GAAIH,QAAQ,EAAIG,MAAM,CAAG,GAAG,CAAE,CAC5B;AACA;AACA,KAAM,IAAI,CAAA7E,OAAO,CAAC,CAACgF,IAAI,CAAEC,MAAM,GAAK,CAClC,GAAAwF,oBAAc,EAACrF,IAAI,CAAE,CAACD,KAAK,CAAEP,MAAM,GAAK,CACtC,GAAIO,KAAK,CAAEF,MAAM,CAACE,KAAK,CAAC,CAAC,IACpB,CACHP,MAAM,CAACa,KAAK,CAAG/E,GAAG,CAAC+E,KAAK,CAAE;AAC1BvB,KAAK,CAAC8F,GAAG,CAAC,CAAEpF,MAAM,CAAEC,MAAO,CAAC,CAAEH,QAAQ,CAAC3E,GAAG,CAAC,CAC3CiF,IAAI,CAAC,CACP,CACF,CAAC,CACH,CAAC,CACH,CAEA;AACA;AACA;AACApF,GAAG,CAACmF,IAAI,CAACK,IAAI,CACf,CAAE,MAAOD,KAAK,CAAE,CACdb,IAAI,CAACa,KAAK,CACZ,CACF,CACF"}
1
+ {"version":3,"file":"renderer.js","names":["_stream","require","_reactGlobalState","_jsUtils","_lodash","_config","_interopRequireDefault","_nodeForge","_fs","_path","_zlib","_server","_reactHelmet","_server2","_serializeJavascript","_buildInfo","_winston","_Cache","_jsxRuntime","sanitizedConfig","omit","config","SCRIPT_LOCATIONS","BODY_OPEN","DEFAULT","HEAD_OPEN","exports","getBuildInfo","context","url","path","resolve","JSON","parse","fs","readFileSync","readChunkGroupsJson","buildDir","res","err","prepareCipher","key","Promise","reject","forge","random","getBytes","iv","cipher","createCipher","start","isBrotliAcceptable","req","acceptable","get","ops","split","i","length","type","priority","trim","parseFloat","groupExtraScripts","scripts","script","isString","code","location","undefined","Error","newDefaultLogger","defaultLogLevel","format","transports","winston","createLogger","level","combine","splat","timestamp","colorize","printf","message","stack","rest","Object","keys","stringify","Console","factory","webpackConfig","options","defaults","clone","beforeRender","maxSsrRounds","ssrTimeout","staticCacheSize","logger","defaultLoggerLogLevel","buildInfo","setBuildInfo","publicPath","outputPath","output","manifestLink","existsSync","cache","staticCacheController","Cache","CHUNK_GROUPS","next","set","cookie","csrfToken","cacheRef","data","buffer","status","noCsp","send","done","failed","brotliDecompress","error","html","h","toString","regex","RegExp","nonce","replace","configToInject","extraScripts","initialState","all","helmet","chunkGroups","webpackStats","locals","mapValues","toJson","namedChunkGroups","item","assets","map","name","App","Application","ssrContext","state","cloneDeep","chunks","stream","ssrStart","Date","now","renderPass","pipeableStream","renderToPipeableStream","jsx","GlobalStateProvider","children","StaticRouter","onAllReady","onError","ssrRound","bailed","dirty","timeout","race","allSettled","pending","timer","then","logMsg","log","pipe","Writable","write","chunk","_","Helmet","renderStatic","payload","serializeJs","CONFIG","ISTATE","ignoreFunction","unsafe","update","util","createBuffer","finish","INJ","encode64","chunkSet","Set","forEach","asset","add","styleChunkString","scriptChunkString","endsWith","grouppedExtraScripts","faviconLink","favicon","title","meta","brotliCompress"],"sources":["../../../src/server/renderer.jsx"],"sourcesContent":["/**\n * ExpressJS middleware for server-side rendering of a ReactJS app.\n */\n\nimport { Writable } from 'stream';\n\nimport { GlobalStateProvider } from '@dr.pogodin/react-global-state';\nimport { timer } from '@dr.pogodin/js-utils';\n\nimport {\n clone,\n cloneDeep,\n defaults,\n isString,\n get,\n mapValues,\n omit,\n} from 'lodash';\n\nimport config from 'config';\nimport forge from 'node-forge';\nimport fs from 'fs';\nimport path from 'path';\nimport { brotliCompress, brotliDecompress } from 'zlib';\n\nimport { renderToPipeableStream } from 'react-dom/server';\nimport { Helmet } from 'react-helmet';\nimport { StaticRouter } from 'react-router-dom/server';\nimport serializeJs from 'serialize-javascript';\nimport { setBuildInfo } from 'utils/isomorphy/buildInfo';\nimport winston from 'winston';\n\nimport Cache from './Cache';\n\nconst sanitizedConfig = omit(config, 'SECRET');\n\nexport const SCRIPT_LOCATIONS = {\n BODY_OPEN: 'BODY_OPEN',\n DEFAULT: 'DEFAULT',\n HEAD_OPEN: 'HEAD_OPEN',\n};\n\n/**\n * Reads build-time information about the app. This information is generated\n * by our standard Webpack config for apps, and it is written into\n * \".build-info\" file in the context folder specified in Webpack config.\n * At the moment, that file contains build timestamp and a random 32-bit key,\n * suitable for cryptographical use.\n * @ignore\n * @param {String} context Webpack context path used during the build.\n * @return {Object} Resolves to the build-time information.\n */\nfunction getBuildInfo(context) {\n const url = path.resolve(context, '.build-info');\n return JSON.parse(fs.readFileSync(url));\n}\n\n/**\n * Attempts to read from disk the named chunk groups mapping generated\n * by Webpack during the compilation.\n * It will not work for development builds, where these stats should be captured\n * via compilator callback.\n * @ignore\n * @param {string} buildDir\n * @return {object}\n */\nfunction readChunkGroupsJson(buildDir) {\n const url = path.resolve(buildDir, '__chunk_groups__.json');\n let res;\n try {\n res = JSON.parse(fs.readFileSync(url));\n } catch (err) {\n res = null;\n }\n return res;\n}\n\n/**\n * Prepares a new Cipher for data encryption.\n * @ignore\n * @param {String} key Encryption key (32-bit random key is expected, see\n * node-forge documentation, in case of doubts).\n * @return {Promise} Resolves to the object with two fields:\n * 1. cipher - a new Cipher, ready for encryption;\n * 2. iv - initial vector used by the cipher.\n */\nfunction prepareCipher(key) {\n return new Promise((resolve, reject) => {\n forge.random.getBytes(32, (err, iv) => {\n if (err) reject(err);\n else {\n const cipher = forge.cipher.createCipher('AES-CBC', key);\n cipher.start({ iv });\n resolve({ cipher, iv });\n }\n });\n });\n}\n\n/**\n * Given an incoming HTTP requests, it deduces whether Brotli-encoded responses\n * are acceptable to the caller.\n * @param {object} req\n * @return {boolean}\n * @ignore\n */\nexport function isBrotliAcceptable(req) {\n const acceptable = req.get('accept-encoding');\n if (acceptable) {\n const ops = acceptable.split(',');\n for (let i = 0; i < ops.length; ++i) {\n const [type, priority] = ops[i].trim().split(';q=');\n if ((type === '*' || type === 'br')\n && (!priority || parseFloat(priority) > 0)) {\n return true;\n }\n }\n }\n return false;\n}\n\n/**\n * Given an array of extra script strings / objects, it returns an object with\n * arrays of scripts to inject in different HTML template locations. During\n * the script groupping it also filters out any empty scripts.\n * @param {({\n * code: string;\n * location: string;\n * }|string)[]} [scripts=[]]\n * @return {{\n * BODY_OPEN: string[];\n * DEFAULT: string[];\n * HEAD_OPEN: string[];\n * }}\n */\nfunction groupExtraScripts(scripts = []) {\n const res = {\n [SCRIPT_LOCATIONS.BODY_OPEN]: '',\n [SCRIPT_LOCATIONS.DEFAULT]: '',\n [SCRIPT_LOCATIONS.HEAD_OPEN]: '',\n };\n for (let i = 0; i < scripts.length; ++i) {\n const script = scripts[i];\n if (isString(script)) {\n if (script) res[SCRIPT_LOCATIONS.DEFAULT] += script;\n } else if (script.code) {\n if (res[script.location] !== undefined) {\n res[script.location] += script.code;\n } else throw Error(`Invalid location \"${script.location}\"`);\n }\n }\n return res;\n}\n\n/**\n * Creates a new default (Winston) logger.\n * @param {object} [options={}]\n * @param {string} [options.defaultLogLevel='info']\n * @return {object}\n */\nexport function newDefaultLogger({\n defaultLogLevel = 'info',\n} = {}) {\n const { format, transports } = winston;\n return winston.createLogger({\n level: defaultLogLevel,\n format: format.combine(\n format.splat(),\n format.timestamp(),\n format.colorize(),\n format.printf(\n ({\n level,\n message,\n timestamp,\n stack,\n ...rest\n }) => {\n let res = `${level}\\t(at ${timestamp}):\\t${message}`;\n if (Object.keys(rest).length) {\n res += `\\n${JSON.stringify(rest, null, 2)}`;\n }\n if (stack) res += `\\n${stack}`;\n return res;\n },\n ),\n ),\n transports: [new transports.Console()],\n });\n}\n\n/**\n * Creates the middleware.\n * @param {object} webpackConfig\n * @param {object} options Additional options:\n * @param {Component} [options.Application] The root ReactJS component of\n * the app to use for the server-side rendering. When not provided\n * the server-side rendering is disabled.\n * @param {object} [options.buildInfo] \"Build info\" object to use. If provided,\n * it will be used, instead of trying to load from the filesystem the one\n * generated by the Webpack build. It is intended for test environments,\n * where passing this stuff via file system is no bueno.\n * @param {boolean} [options.favicon] `true` will include favicon\n * link into the rendered HTML templates.\n * @param {boolean} [options.noCsp] `true` means that no\n * Content-Security-Policy (CSP) is used by server, thus the renderer\n * may cut a few corners.\n * @param {number} [options.maxSsrRounds=10] Maximum number of SSR rounds.\n * @param {number} [options.ssrTimeout=1000] SSR timeout in milliseconds,\n * defaults to 1 second.\n * @param {number} [options.staticCacheSize=1.e7] The maximum\n * static cache size in bytes. Defaults to ~10 MB.\n * @param {function} [options.staticCacheController] When given, it activates,\n * and controls the static caching of generated HTML markup. When this function\n * is provided, on each incoming request it is triggered with the request\n * passed in as the argument. To attempt to serve the response from the cache\n * it should return the object with the following fields:\n * - `key: string` &ndash; the cache key for the response;\n * - `maxage?: number` &ndash; the maximum age of cached result in ms.\n * If undefined - infinite age is assumed.\n * @return {function} Created middleware.\n */\nexport default function factory(webpackConfig, options) {\n const ops = defaults(clone(options), {\n beforeRender: () => Promise.resolve({}),\n maxSsrRounds: 10,\n ssrTimeout: 1000,\n staticCacheSize: 1.e7,\n });\n\n // Note: in normal use the default logger is created and set in the root\n // server function, and this initialization is for testing uses, where\n // renderer is imported directly.\n if (ops.logger === undefined) {\n ops.logger = newDefaultLogger({\n defaultLogLevel: ops.defaultLoggerLogLevel,\n });\n }\n\n const buildInfo = ops.buildInfo || getBuildInfo(webpackConfig.context);\n setBuildInfo(buildInfo);\n\n // publicPath from webpack.output has a trailing slash at the end.\n const { publicPath, path: outputPath } = webpackConfig.output;\n\n const manifestLink = fs.existsSync(`${outputPath}/manifest.json`)\n ? `<link rel=\"manifest\" href=\"${publicPath}manifest.json\">` : '';\n\n const cache = ops.staticCacheController\n ? new Cache(ops.staticCacheSize) : null;\n\n const CHUNK_GROUPS = readChunkGroupsJson(outputPath);\n\n return async (req, res, next) => {\n try {\n // Ensures any caches always revalidate HTML markup before reuse.\n res.set('Cache-Control', 'no-cache');\n\n res.cookie('csrfToken', req.csrfToken());\n\n let cacheRef;\n if (cache) {\n cacheRef = ops.staticCacheController(req);\n if (cacheRef) {\n const data = cache.get(cacheRef);\n if (data !== null) {\n const { buffer, status } = data;\n if (ops.noCsp && isBrotliAcceptable(req)) {\n res.set('Content-Type', 'text/html');\n res.set('Content-Encoding', 'br');\n if (status !== 200) res.status(status);\n res.send(buffer);\n } else {\n await new Promise((done, failed) => {\n brotliDecompress(buffer, (error, html) => {\n if (error) failed(error);\n else {\n let h = html.toString();\n if (!ops.noCsp) {\n // TODO: Starting from Node v15 we'll be able to use string's\n // .replaceAll() method instead relying on reg. expression for\n // global matching.\n const regex = new RegExp(buffer.nonce, 'g');\n h = h.replace(regex, req.nonce);\n }\n if (status !== 200) res.status(status);\n res.send(h);\n done();\n }\n });\n });\n }\n return;\n }\n }\n }\n\n const [{\n configToInject,\n extraScripts,\n initialState,\n }, {\n cipher,\n iv,\n }] = await Promise.all([\n ops.beforeRender(req, sanitizedConfig),\n prepareCipher(buildInfo.key),\n ]);\n\n let helmet;\n\n // Gets the mapping between code chunk names and their asset files.\n // These data come from the Webpack compilation, either from the stats\n // attached to the request (in dev mode), or from a file output during\n // the build (in prod mode).\n let chunkGroups;\n const webpackStats = get(res.locals, 'webpack.devMiddleware.stats');\n if (webpackStats) {\n chunkGroups = mapValues(\n webpackStats.toJson({\n all: false,\n chunkGroups: true,\n }).namedChunkGroups,\n (item) => item.assets.map(({ name }) => name),\n );\n } else if (CHUNK_GROUPS) chunkGroups = CHUNK_GROUPS;\n else chunkGroups = {};\n\n /* Optional server-side rendering. */\n let App = ops.Application;\n const ssrContext = {\n req,\n state: cloneDeep(initialState || {}),\n\n // Array of chunk names encountered during the rendering.\n chunks: [],\n\n chunkGroups,\n };\n let stream;\n if (App) {\n const ssrStart = Date.now();\n\n const renderPass = async () => {\n ssrContext.chunks = [];\n return new Promise((resolve, reject) => {\n const pipeableStream = renderToPipeableStream(\n <GlobalStateProvider\n initialState={ssrContext.state}\n ssrContext={ssrContext}\n >\n <StaticRouter location={req.url}>\n <App />\n </StaticRouter>\n </GlobalStateProvider>,\n {\n onAllReady: () => resolve(pipeableStream),\n onError: reject,\n },\n );\n });\n };\n\n let ssrRound = 0;\n let bailed = false;\n for (; ssrRound < ops.maxSsrRounds; ++ssrRound) {\n stream = await renderPass(); // eslint-disable-line no-await-in-loop\n\n if (!ssrContext.dirty) break;\n\n /* eslint-disable no-await-in-loop */\n const timeout = ops.ssrTimeout + ssrStart - Date.now();\n bailed = timeout <= 0 || !await Promise.race([\n Promise.allSettled(ssrContext.pending),\n timer(timeout).then(() => false),\n ]);\n if (bailed) break;\n /* eslint-enable no-await-in-loop */\n }\n\n let logMsg;\n if (ssrContext.dirty) {\n // NOTE: In the case of incomplete SSR one more round is necessary\n // to ensure the correct hydration when some pending promises have\n // resolved and placed their data into the initial global state.\n stream = await renderPass();\n\n logMsg = bailed ? `SSR timed out after ${ops.ssrTimeout} second(s)`\n : `SSR bailed out after ${ops.maxSsrRounds} round(s)`;\n } else logMsg = `SSR completed in ${ssrRound + 1} round(s)`;\n\n ops.logger.log(ssrContext.dirty ? 'warn' : 'info', logMsg);\n\n App = '';\n stream.pipe(new Writable({\n write: (chunk, _, done) => {\n App += chunk.toString();\n done();\n },\n }));\n\n /* This takes care about server-side rendering of page title and meta tags\n * (still demands injection into HTML template, which happens below). */\n helmet = Helmet.renderStatic();\n }\n\n /* Encrypts data to be injected into HTML.\n * Keep in mind, that this encryption is no way secure: as the JS bundle\n * contains decryption key and is able to decode it at the client side.\n * Hovewer, for a number of reasons, encryption of injected data is still\n * better than injection of a plain text. */\n const payload = serializeJs({\n CHUNK_GROUPS: chunkGroups,\n CONFIG: configToInject || sanitizedConfig,\n ISTATE: ssrContext.state,\n }, {\n ignoreFunction: true,\n unsafe: true,\n });\n cipher.update(forge.util.createBuffer(payload, 'utf8'));\n cipher.finish();\n const INJ = forge.util.encode64(`${iv}${cipher.output.data}`);\n\n const chunkSet = new Set();\n\n // TODO: \"main\" chunk has to be added explicitly,\n // because unlike all other chunks they are not managed by <CodeSplit>\n // component, thus they are not added to the ssrContext.chunks\n // automatically. Actually, names of these entry chunks should be\n // read from Wepback config, as the end user may customize them,\n // remove or add other entry points, but it requires additional\n // efforts to figure out how to automatically order them right,\n // thus for now this handles the default config.\n [\n 'main',\n ...ssrContext.chunks,\n ].forEach((chunk) => {\n const assets = chunkGroups[chunk];\n if (assets) assets.forEach((asset) => chunkSet.add(asset));\n });\n\n let styleChunkString = '';\n let scriptChunkString = '';\n chunkSet.forEach((chunk) => {\n if (chunk.endsWith('.css')) {\n styleChunkString += `<link href=\"${publicPath}${chunk}\" rel=\"stylesheet\">`;\n } else if (\n chunk.endsWith('.js')\n // In dev mode HMR adds JS updates into asset arrays,\n // and they (updates) should be ignored.\n && !chunk.endsWith('.hot-update.js')\n ) {\n scriptChunkString += `<script src=\"${publicPath}${chunk}\" type=\"application/javascript\"></script>`;\n }\n });\n\n const grouppedExtraScripts = groupExtraScripts(extraScripts);\n\n const faviconLink = ops.favicon ? (\n '<link rel=\"shortcut icon\" href=\"/favicon.ico\">'\n ) : '';\n\n const html = `<!DOCTYPE html>\n <html lang=\"en\">\n <head>\n ${grouppedExtraScripts[SCRIPT_LOCATIONS.HEAD_OPEN]}\n ${helmet ? helmet.title.toString() : ''}\n ${helmet ? helmet.meta.toString() : ''}\n <meta name=\"theme-color\" content=\"#FFFFFF\">\n ${manifestLink}\n ${styleChunkString}\n ${faviconLink}\n <meta charset=\"utf-8\">\n <meta\n content=\"width=device-width,initial-scale=1.0\"\n name=\"viewport\"\n >\n <meta itemprop=\"drpruinj\" content=\"${INJ}\">\n </head>\n <body>\n ${grouppedExtraScripts[SCRIPT_LOCATIONS.BODY_OPEN]}\n <div id=\"react-view\">${App || ''}</div>\n ${scriptChunkString}\n ${grouppedExtraScripts[SCRIPT_LOCATIONS.DEFAULT]}\n </body>\n </html>`;\n\n const status = ssrContext.status || 200;\n if (status !== 200) res.status(status);\n\n if (cacheRef && status < 500) {\n // Note: waiting for the caching to complete is not strictly necessary,\n // but it greately simplifies testing, and error reporting.\n await new Promise((done, failed) => {\n brotliCompress(html, (error, buffer) => {\n if (error) failed(error);\n else {\n buffer.nonce = req.nonce; // eslint-disable-line no-param-reassign\n cache.add({ buffer, status }, cacheRef.key);\n done();\n }\n });\n });\n }\n\n // Note: as caching code above may throw in some cases, sending response\n // before it completes will likely hide the error, making it difficult\n // to debug. Thus, at least for now, lets send response after it.\n res.send(html);\n } catch (error) {\n next(error);\n }\n };\n}\n"],"mappings":"ySAIA,IAAAA,OAAA,CAAAC,OAAA,WAEA,IAAAC,iBAAA,CAAAD,OAAA,mCACA,IAAAE,QAAA,CAAAF,OAAA,yBAEA,IAAAG,OAAA,CAAAH,OAAA,WAUA,IAAAI,OAAA,CAAAC,sBAAA,CAAAL,OAAA,YACA,IAAAM,UAAA,CAAAD,sBAAA,CAAAL,OAAA,gBACA,IAAAO,GAAA,CAAAF,sBAAA,CAAAL,OAAA,QACA,IAAAQ,KAAA,CAAAH,sBAAA,CAAAL,OAAA,UACA,IAAAS,KAAA,CAAAT,OAAA,SAEA,IAAAU,OAAA,CAAAV,OAAA,qBACA,IAAAW,YAAA,CAAAX,OAAA,iBACA,IAAAY,QAAA,CAAAZ,OAAA,4BACA,IAAAa,oBAAA,CAAAR,sBAAA,CAAAL,OAAA,0BACA,IAAAc,UAAA,CAAAd,OAAA,wCACA,IAAAe,QAAA,CAAAV,sBAAA,CAAAL,OAAA,aAEA,IAAAgB,MAAA,CAAAX,sBAAA,CAAAL,OAAA,aAA4B,IAAAiB,WAAA,CAAAjB,OAAA,sBAhC5B;AACA;AACA,GAgCA,KAAM,CAAAkB,eAAe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KAAK,CAAEF,MAAM,CAACE,KAAK,CAAC,CAAC,IACpB,CACHP,MAAM,CAACa,KAAK,CAAG/E,GAAG,CAAC+E,KAAK,CAAE;AAC1BvB,KAAK,CAAC6F,GAAG,CAAC,CAAEnF,MAAM,CAAEC,MAAO,CAAC,CAAEH,QAAQ,CAAC3E,GAAG,CAAC,CAC3CiF,IAAI,CAAC,CACP,CACF,CAAC,CACH,CAAC,CACH,CAEA;AACA;AACA;AACApF,GAAG,CAACmF,IAAI,CAACK,IAAI,CACf,CAAE,MAAOD,KAAK,CAAE,CACdb,IAAI,CAACa,KAAK,CACZ,CACF,CACF"}
@@ -1,4 +1,4 @@
1
- "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});var _exportNames={withRetries:true,JU:true,themed:true,ThemeProvider:true,config:true,isomorphy:true,time:true,webpack:true,Emitter:true,Semaphore:true,splitComponent:true};Object.defineProperty(exports,"Emitter",{enumerable:true,get:function(){return _jsUtils.Emitter}});exports.JU=void 0;Object.defineProperty(exports,"Semaphore",{enumerable:true,get:function(){return _jsUtils.Semaphore}});Object.defineProperty(exports,"ThemeProvider",{enumerable:true,get:function(){return _reactThemes.ThemeProvider}});Object.defineProperty(exports,"config",{enumerable:true,get:function(){return _config.default}});exports.isomorphy=void 0;Object.defineProperty(exports,"splitComponent",{enumerable:true,get:function(){return _splitComponent.default}});Object.defineProperty(exports,"themed",{enumerable:true,get:function(){return _reactThemes.default}});Object.defineProperty(exports,"time",{enumerable:true,get:function(){return _time.default}});exports.webpack=void 0;exports.withRetries=withRetries;var _reactThemes=_interopRequireWildcard(require("@dr.pogodin/react-themes"));var _config=_interopRequireDefault(require("./config"));var isomorphy=_interopRequireWildcard(require("./isomorphy"));exports.isomorphy=isomorphy;var _time=_interopRequireDefault(require("./time"));var webpack=_interopRequireWildcard(require("./webpack"));exports.webpack=webpack;var _jsUtils=require("@dr.pogodin/js-utils");var _Barrier=require("./Barrier");Object.keys(_Barrier).forEach(function(key){if(key==="default"||key==="__esModule")return;if(Object.prototype.hasOwnProperty.call(_exportNames,key))return;if(key in exports&&exports[key]===_Barrier[key])return;Object.defineProperty(exports,key,{enumerable:true,get:function(){return _Barrier[key]}})});var _splitComponent=_interopRequireDefault(require("./splitComponent"));function _getRequireWildcardCache(nodeInterop){if(typeof WeakMap!=="function")return null;var cacheBabelInterop=new WeakMap;var cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule){return obj}if(obj===null||typeof obj!=="object"&&typeof obj!=="function"){return{default:obj}}var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj)){return cache.get(obj)}var newObj={};var hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj){if(key!=="default"&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;if(desc&&(desc.get||desc.set)){Object.defineProperty(newObj,key,desc)}else{newObj[key]=obj[key]}}}newObj.default=obj;if(cache){cache.set(obj,newObj)}return newObj}_reactThemes.default.COMPOSE=_reactThemes.COMPOSE;_reactThemes.default.PRIORITY=_reactThemes.PRIORITY;// Note: it should be done this way, as in some environments
1
+ "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"Barrier",{enumerable:true,get:function(){return _jsUtils.Barrier}});Object.defineProperty(exports,"Emitter",{enumerable:true,get:function(){return _jsUtils.Emitter}});exports.JU=void 0;Object.defineProperty(exports,"Semaphore",{enumerable:true,get:function(){return _jsUtils.Semaphore}});Object.defineProperty(exports,"ThemeProvider",{enumerable:true,get:function(){return _reactThemes.ThemeProvider}});Object.defineProperty(exports,"config",{enumerable:true,get:function(){return _config.default}});exports.isomorphy=void 0;Object.defineProperty(exports,"splitComponent",{enumerable:true,get:function(){return _splitComponent.default}});Object.defineProperty(exports,"themed",{enumerable:true,get:function(){return _reactThemes.default}});Object.defineProperty(exports,"time",{enumerable:true,get:function(){return _time.default}});exports.webpack=void 0;exports.withRetries=withRetries;var _reactThemes=_interopRequireWildcard(require("@dr.pogodin/react-themes"));var _config=_interopRequireDefault(require("./config"));var isomorphy=_interopRequireWildcard(require("./isomorphy"));exports.isomorphy=isomorphy;var _time=_interopRequireDefault(require("./time"));var webpack=_interopRequireWildcard(require("./webpack"));exports.webpack=webpack;var _jsUtils=require("@dr.pogodin/js-utils");var _splitComponent=_interopRequireDefault(require("./splitComponent"));function _getRequireWildcardCache(nodeInterop){if(typeof WeakMap!=="function")return null;var cacheBabelInterop=new WeakMap;var cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule){return obj}if(obj===null||typeof obj!=="object"&&typeof obj!=="function"){return{default:obj}}var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj)){return cache.get(obj)}var newObj={};var hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj){if(key!=="default"&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;if(desc&&(desc.get||desc.set)){Object.defineProperty(newObj,key,desc)}else{newObj[key]=obj[key]}}}newObj.default=obj;if(cache){cache.set(obj,newObj)}return newObj}_reactThemes.default.COMPOSE=_reactThemes.COMPOSE;_reactThemes.default.PRIORITY=_reactThemes.PRIORITY;// Note: it should be done this way, as in some environments
2
2
  // "process" might not exist, and process.env.NODE_CONFIG_ENV
3
3
  // not injected by Webpack.
4
4
  let NODE_CONFIG_ENV;try{NODE_CONFIG_ENV=process.env.NODE_CONFIG_ENV}catch{/* noop */}const env=NODE_CONFIG_ENV||process.env.NODE_ENV;const JU=env!=="production"&&webpack.requireWeak("./jest",__dirname);/**
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_reactThemes","_interopRequireWildcard","require","_config","_interopRequireDefault","isomorphy","exports","_time","webpack","_jsUtils","_Barrier","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","defineProperty","enumerable","get","_splitComponent","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","newObj","hasPropertyDescriptor","getOwnPropertyDescriptor","desc","set","themed","COMPOSE","PRIORITY","NODE_CONFIG_ENV","process","env","NODE_ENV","JU","requireWeak","__dirname","withRetries","action","maxRetries","interval","n","error","time","timer"],"sources":["../../../../src/shared/utils/index.js"],"sourcesContent":["import themed, {\n COMPOSE,\n PRIORITY,\n ThemeProvider,\n} from '@dr.pogodin/react-themes';\n\nimport config from './config';\nimport * as isomorphy from './isomorphy';\nimport time from './time';\nimport * as webpack from './webpack';\n\nexport { Emitter, Semaphore } from '@dr.pogodin/js-utils';\n\nexport * from './Barrier';\nexport { default as splitComponent } from './splitComponent';\n\nthemed.COMPOSE = COMPOSE;\nthemed.PRIORITY = PRIORITY;\n\n// Note: it should be done this way, as in some environments\n// \"process\" might not exist, and process.env.NODE_CONFIG_ENV\n// not injected by Webpack.\nlet NODE_CONFIG_ENV;\ntry {\n NODE_CONFIG_ENV = process.env.NODE_CONFIG_ENV;\n} catch { /* noop */ }\n\nconst env = NODE_CONFIG_ENV || process.env.NODE_ENV;\nconst JU = env !== 'production' && webpack.requireWeak('./jest', __dirname);\n\n/**\n * @category Utilities\n * @global\n * @func withRetries\n * @desc\n * ```js\n * import { withRetries } from '@dr.pogodin/react-utils';\n * ```\n * Attempts to perform given asynchronous `action` up to `maxRetries` times,\n * with the given `interval` between attempts. If any attempt is successful,\n * the result is returned immediately, with no further attempts done;\n * otherwise, if all attempts fail, the result Promise rejects after the last\n * attempt.\n * @param {function} action\n * @param {number} [maxRetries=5] Optional. Maximum number of retries. Defaults\n * to 5 attempts.\n * @param {number} [interval=1000] Optional. Interval between retries [ms].\n * Defaults to 1 second.\n * @return {Promise} Resolves to the result of successful operation, or\n * rejects with the error from the latst failed attempt.\n * @example\n * import { withRetries } from '@dr.pogodin/react-utils';\n *\n * let firstCall = true;\n *\n * function sampleAction() {\n * if (!firstCall) return 'success';\n * firstCall = false;\n * throw Error('The first call to this method fails');\n * }\n *\n * withRetries(sampleAction).then(console.log);\n * // It will print 'success' after one second, once the second attempt\n * // is performed.\n */\nexport async function withRetries(action, maxRetries = 5, interval = 1000) {\n /* eslint-disable no-await-in-loop */\n for (let n = 1; ; ++n) {\n try {\n return await action();\n } catch (error) {\n if (n < maxRetries) await time.timer(interval);\n else throw error;\n }\n }\n /* eslint-enable no-await-in-loop */\n}\n\nexport {\n config,\n isomorphy,\n JU,\n themed,\n ThemeProvider,\n time,\n webpack,\n};\n"],"mappings":"0nCAAA,IAAAA,YAAA,CAAAC,uBAAA,CAAAC,OAAA,8BAMA,IAAAC,OAAA,CAAAC,sBAAA,CAAAF,OAAA,cACA,IAAAG,SAAA,CAAAJ,uBAAA,CAAAC,OAAA,iBAAyCI,OAAA,CAAAD,SAAA,CAAAA,SAAA,CACzC,IAAAE,KAAA,CAAAH,sBAAA,CAAAF,OAAA,YACA,IAAAM,OAAA,CAAAP,uBAAA,CAAAC,OAAA,eAAqCI,OAAA,CAAAE,OAAA,CAAAA,OAAA,CAErC,IAAAC,QAAA,CAAAP,OAAA,yBAEA,IAAAQ,QAAA,CAAAR,OAAA,cAAAS,MAAA,CAAAC,IAAA,CAAAF,QAAA,EAAAG,OAAA,UAAAC,GAAA,KAAAA,GAAA,cAAAA,GAAA,0BAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,CAAAJ,GAAA,YAAAA,GAAA,IAAAR,OAAA,EAAAA,OAAA,CAAAQ,GAAA,IAAAJ,QAAA,CAAA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AM,GAAA,CAAAT,GAAA,CAAAK,MAAA,SAAAA,MAAA,CAE7DK,oBAAM,CAACC,OAAO,CAAGA,oBAAO,CACxBD,oBAAM,CAACE,QAAQ,CAAGA,qBAAQ,CAE1B;AACA;AACA;AACA,GAAI,CAAAC,eAAe,CACnB,GAAI,CACFA,eAAe,CAAGC,OAAO,CAACC,GAAG,CAACF,eAChC,CAAE,KAAM,CAAE,WAEV,KAAM,CAAAE,GAAG,CAAGF,eAAe,EAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,CACnD,KAAM,CAAAC,EAAE,CAAGF,GAAG,GAAK,YAAY,EAAInC,OAAO,CAACsC,WAAW,UAAWC,SAAS,CAAC,CAE3E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAlCAzC,OAAA,CAAAuC,EAAA,CAAAA,EAAA,CAmCO,cAAe,CAAAG,WAAWA,CAACC,MAAM,CAAEC,UAAU,CAAG,CAAC,CAAEC,QAAQ,CAAG,IAAI,CAAE,CACzE,qCACA,IAAK,GAAI,CAAAC,CAAC,CAAG,CAAC,EAAI,EAAEA,CAAC,CAAE,CACrB,GAAI,CACF,MAAO,MAAM,CAAAH,MAAM,CAAC,CACtB,CAAE,MAAOI,KAAK,CAAE,CACd,GAAID,CAAC,CAAGF,UAAU,CAAE,KAAM,CAAAI,aAAI,CAACC,KAAK,CAACJ,QAAQ,CAAC,CAAC,IAC1C,MAAM,CAAAE,KACb,CACF,CACA,oCACF"}
1
+ {"version":3,"file":"index.js","names":["_reactThemes","_interopRequireWildcard","require","_config","_interopRequireDefault","isomorphy","exports","_time","webpack","_jsUtils","_splitComponent","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","themed","COMPOSE","PRIORITY","NODE_CONFIG_ENV","process","env","NODE_ENV","JU","requireWeak","__dirname","withRetries","action","maxRetries","interval","n","error","time","timer"],"sources":["../../../../src/shared/utils/index.js"],"sourcesContent":["import themed, {\n COMPOSE,\n PRIORITY,\n ThemeProvider,\n} from '@dr.pogodin/react-themes';\n\nimport config from './config';\nimport * as isomorphy from './isomorphy';\nimport time from './time';\nimport * as webpack from './webpack';\n\nexport { Barrier, Emitter, Semaphore } from '@dr.pogodin/js-utils';\n\nexport { default as splitComponent } from './splitComponent';\n\nthemed.COMPOSE = COMPOSE;\nthemed.PRIORITY = PRIORITY;\n\n// Note: it should be done this way, as in some environments\n// \"process\" might not exist, and process.env.NODE_CONFIG_ENV\n// not injected by Webpack.\nlet NODE_CONFIG_ENV;\ntry {\n NODE_CONFIG_ENV = process.env.NODE_CONFIG_ENV;\n} catch { /* noop */ }\n\nconst env = NODE_CONFIG_ENV || process.env.NODE_ENV;\nconst JU = env !== 'production' && webpack.requireWeak('./jest', __dirname);\n\n/**\n * @category Utilities\n * @global\n * @func withRetries\n * @desc\n * ```js\n * import { withRetries } from '@dr.pogodin/react-utils';\n * ```\n * Attempts to perform given asynchronous `action` up to `maxRetries` times,\n * with the given `interval` between attempts. If any attempt is successful,\n * the result is returned immediately, with no further attempts done;\n * otherwise, if all attempts fail, the result Promise rejects after the last\n * attempt.\n * @param {function} action\n * @param {number} [maxRetries=5] Optional. Maximum number of retries. Defaults\n * to 5 attempts.\n * @param {number} [interval=1000] Optional. Interval between retries [ms].\n * Defaults to 1 second.\n * @return {Promise} Resolves to the result of successful operation, or\n * rejects with the error from the latst failed attempt.\n * @example\n * import { withRetries } from '@dr.pogodin/react-utils';\n *\n * let firstCall = true;\n *\n * function sampleAction() {\n * if (!firstCall) return 'success';\n * firstCall = false;\n * throw Error('The first call to this method fails');\n * }\n *\n * withRetries(sampleAction).then(console.log);\n * // It will print 'success' after one second, once the second attempt\n * // is performed.\n */\nexport async function withRetries(action, maxRetries = 5, interval = 1000) {\n /* eslint-disable no-await-in-loop */\n for (let n = 1; ; ++n) {\n try {\n return await action();\n } catch (error) {\n if (n < maxRetries) await time.timer(interval);\n else throw error;\n }\n }\n /* eslint-enable no-await-in-loop */\n}\n\nexport {\n config,\n isomorphy,\n JU,\n themed,\n ThemeProvider,\n time,\n webpack,\n};\n"],"mappings":"gjCAAA,IAAAA,YAAA,CAAAC,uBAAA,CAAAC,OAAA,8BAMA,IAAAC,OAAA,CAAAC,sBAAA,CAAAF,OAAA,cACA,IAAAG,SAAA,CAAAJ,uBAAA,CAAAC,OAAA,iBAAyCI,OAAA,CAAAD,SAAA,CAAAA,SAAA,CACzC,IAAAE,KAAA,CAAAH,sBAAA,CAAAF,OAAA,YACA,IAAAM,OAAA,CAAAP,uBAAA,CAAAC,OAAA,eAAqCI,OAAA,CAAAE,OAAA,CAAAA,OAAA,CAErC,IAAAC,QAAA,CAAAP,OAAA,yBAEA,IAAAQ,eAAA,CAAAN,sBAAA,CAAAF,OAAA,sBAA6D,SAAAS,yBAAAC,WAAA,YAAAC,OAAA,8BAAAC,iBAAA,KAAAD,OAAA,KAAAE,gBAAA,KAAAF,OAAA,QAAAF,wBAAA,SAAAA,CAAAC,WAAA,SAAAA,WAAA,CAAAG,gBAAA,CAAAD,iBAAA,GAAAF,WAAA,WAAAX,wBAAAe,GAAA,CAAAJ,WAAA,MAAAA,WAAA,EAAAI,GAAA,EAAAA,GAAA,CAAAC,UAAA,SAAAD,GAAA,IAAAA,GAAA,gBAAAA,GAAA,oBAAAA,GAAA,sBAAAE,OAAA,CAAAF,GAAA,MAAAG,KAAA,CAAAR,wBAAA,CAAAC,WAAA,KAAAO,KAAA,EAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,UAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,MAAAM,MAAA,QAAAC,qBAAA,CAAAC,MAAA,CAAAC,cAAA,EAAAD,MA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K,GAAI,CAAAC,CAAC,CAAG,CAAC,EAAI,EAAEA,CAAC,CAAE,CACrB,GAAI,CACF,MAAO,MAAM,CAAAH,MAAM,CAAC,CACtB,CAAE,MAAOI,KAAK,CAAE,CACd,GAAID,CAAC,CAAGF,UAAU,CAAE,KAAM,CAAAI,aAAI,CAACC,KAAK,CAACJ,QAAQ,CAAC,CAAC,IAC1C,MAAM,CAAAE,KACb,CACF,CACA,oCACF"}
@@ -1,13 +1,51 @@
1
- "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=splitComponent;var _react=require("react");var _CodeSplit=_interopRequireDefault(require("../components/CodeSplit"));/* eslint-disable react/jsx-props-no-spreading */ /**
2
- * Wraps a regular React component into a "code splitting" component,
3
- * i.e. all code used exclusively by that component and its sub-tree
4
- * will go into a separate, asynchronously loaded, code chunk for
5
- * the client-side.
1
+ "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.bookStyleSheets=bookStyleSheets;exports.default=splitComponent;exports.freeStyleSheets=freeStyleSheets;var _propTypes=_interopRequireDefault(require("prop-types"));var _react=require("react");var _jsUtils=require("@dr.pogodin/js-utils");var _reactGlobalState=require("@dr.pogodin/react-global-state");var _isomorphy=require("./isomorphy");var _jsxRuntime=require("react/jsx-runtime");/* eslint-disable react/jsx-props-no-spreading */ /* global document */ // Note: At the client side we can get chunk groups immediately when loading
2
+ // the module; at the server-side we only can get them within React render flow.
3
+ // Thus, we set and use the following variable at the client-side, and then when
4
+ // needed on the server side, we'll fetch it differently.
5
+ let clientChunkGroups;if(_isomorphy.IS_CLIENT_SIDE){// eslint-disable-next-line global-require
6
+ clientChunkGroups=require("../../client/getInj").default().CHUNK_GROUPS||{}}const refCounts={};function getPublicPath(){return(0,_isomorphy.getBuildInfo)().publicPath}/**
7
+ * Client-side only! Ensures the specified CSS stylesheet is loaded into
8
+ * the document; loads if it is missing; and does simple reference counting
9
+ * to facilitate future clean-up.
10
+ * @param {string} name
11
+ * @param {Set} loadedSheets
12
+ * @param {boolean} refCount
13
+ * @return {Promise}
14
+ */function bookStyleSheet(name,loadedSheets,refCount){let res;const path=`${getPublicPath()}/${name}`;const fullPath=`${document.location.origin}${path}`;if(!loadedSheets.has(fullPath)){let link=document.querySelector(`link[href="${path}"]`);if(!link){link=document.createElement("link");link.setAttribute("rel","stylesheet");link.setAttribute("href",path);document.head.appendChild(link)}res=new _jsUtils.Barrier;link.addEventListener("load",res.resolve);link.addEventListener("error",res.resolve)}if(refCount){const current=refCounts[path]||0;refCounts[path]=1+current}return res}/**
15
+ * Generates the set of URLs for currently loaded, linked stylesheets.
16
+ * @return {Set}
17
+ */function getLoadedStyleSheets(){const res=new Set;const{styleSheets}=document;for(let i=0;i<styleSheets.length;++i){const{href}=styleSheets[i];if(href)res.add(href)}return res}function assertChunkName(chunkName,chunkGroups){if(chunkGroups[chunkName])return;throw Error(`Unknown chunk name "${chunkName}"`)}/**
18
+ * Client-side only! Ensures all CSS stylesheets required for the specified
19
+ * code chunk are loaded into the document; loads the missing ones; and does
20
+ * simple reference counting to facilitate future clean-up.
21
+ * @param {string} chunkName Chunk name.
22
+ * @param {boolean} refCount
23
+ * @return {Promise} Resolves once all pending stylesheets, necessary for
24
+ * the chunk, are either loaded, or failed to load.
25
+ */function bookStyleSheets(chunkName,chunkGroups,refCount){const promises=[];const assets=chunkGroups[chunkName];const loadedSheets=getLoadedStyleSheets();for(let i=0;i<assets.length;++i){const asset=assets[i];if(asset.endsWith(".css")){const promise=bookStyleSheet(asset,loadedSheets,refCount);if(promise)promises.push(promise)}}return promises.length?Promise.allSettled(promises):Promise.resolve()}/**
26
+ * Client-side only! Frees from the document all CSS stylesheets that are
27
+ * required by the specified chunk, and have reference counter equal to one
28
+ * (for chunks with larger reference counter values, it just decrements
29
+ * the reference counter).
30
+ * @param {string} chunkName
31
+ */function freeStyleSheets(chunkName,chunkGroups){const assets=chunkGroups[chunkName];for(let i=0;i<assets.length;++i){const asset=assets[i];if(asset.endsWith(".css")){const path=`${getPublicPath()}/${asset}`;if(--refCounts[path]<=0){document.head.querySelector(`link[href="${path}"]`).remove()}}}}// Holds the set of chunk names already used for splitComponent() calls.
32
+ const usedChunkNames=new Set;/**
33
+ * Given an async component retrieval function `getComponent()` it creates
34
+ * a special "code split" component, which uses <Suspense> to asynchronously
35
+ * load on demand the code required by `getComponent()`.
6
36
  * @param {object} options
7
37
  * @param {string} options.chunkName
8
38
  * @param {function} options.getComponent
9
39
  * @param {React.Element} [options.placeholder]
10
40
  * @return {React.ElementType}
11
- */function splitComponent({chunkName,getComponent,placeholder}){// eslint-disable-next-line react/prop-types
12
- return({children,...props}={})=>/*#__PURE__*/(0,_react.createElement)(_CodeSplit.default,{...props,chunkName,getComponent,placeholder},children)}
41
+ */function splitComponent({chunkName,getComponent,placeholder}){// On the client side we can check right away if the chunk name is known.
42
+ if(_isomorphy.IS_CLIENT_SIDE)assertChunkName(chunkName,clientChunkGroups);// The correct usage of splitComponent() assumes a single call per chunk.
43
+ if(usedChunkNames.has(chunkName)){throw Error(`Repeated splitComponent() call for the chunk "${chunkName}"`)}else usedChunkNames.add(chunkName);const LazyComponent=/*#__PURE__*/(0,_react.lazy)(async()=>{let Component=await getComponent();if(Component.default)Component=Component.default;// This pre-loads necessary stylesheets prior to the first mount of
44
+ // the component (the lazy load function is executed by React one at
45
+ // the frist mount).
46
+ if(_isomorphy.IS_CLIENT_SIDE){await bookStyleSheets(chunkName,clientChunkGroups,false)}const Wrapper=/*#__PURE__*/(0,_react.forwardRef)(({children,...rest},ref)=>{// On the server side we'll assert the chunk name here,
47
+ // and also push it to the SSR chunks array.
48
+ if(_isomorphy.IS_SERVER_SIDE){const{chunkGroups,chunks}=(0,_reactGlobalState.getSsrContext)();assertChunkName(chunkName,chunkGroups);if(!chunks.includes(chunkName))chunks.push(chunkName)}// This takes care about stylesheets management every time an instance of
49
+ // this component is mounted / unmounted.
50
+ (0,_react.useInsertionEffect)(()=>{bookStyleSheets(chunkName,clientChunkGroups,true);return()=>freeStyleSheets(chunkName,clientChunkGroups)},[]);return/*#__PURE__*/(0,_jsxRuntime.jsx)(Component,{ref:ref,...rest,children:children})});Wrapper.propTypes={children:_propTypes.default.node};Wrapper.defaultProps={children:undefined};return{default:Wrapper}});function CodeSplit({children,...rest}){return/*#__PURE__*/(0,_jsxRuntime.jsx)(_react.Suspense,{fallback:placeholder,children:/*#__PURE__*/(0,_jsxRuntime.jsx)(LazyComponent,{...rest,children:children})})}CodeSplit.propTypes={children:_propTypes.default.node};CodeSplit.defaultProps={children:undefined};return CodeSplit}
13
51
  //# sourceMappingURL=splitComponent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"splitComponent.js","names":["_react","require","_CodeSplit","_interopRequireDefault","splitComponent","chunkName","getComponent","placeholder","children","props","createElement","CodeSplit"],"sources":["../../../../src/shared/utils/splitComponent.js"],"sourcesContent":["/* eslint-disable react/jsx-props-no-spreading */\n\nimport { createElement } from 'react';\n\nimport CodeSplit from 'components/CodeSplit';\n\n/**\n * Wraps a regular React component into a \"code splitting\" component,\n * i.e. all code used exclusively by that component and its sub-tree\n * will go into a separate, asynchronously loaded, code chunk for\n * the client-side.\n * @param {object} options\n * @param {string} options.chunkName\n * @param {function} options.getComponent\n * @param {React.Element} [options.placeholder]\n * @return {React.ElementType}\n */\nexport default function splitComponent({\n chunkName,\n getComponent,\n placeholder,\n}) {\n // eslint-disable-next-line react/prop-types\n return ({ children, ...props } = {}) => createElement(\n CodeSplit,\n {\n ...props,\n chunkName,\n getComponent,\n placeholder,\n },\n children,\n );\n}\n"],"mappings":"wLAEA,IAAAA,MAAA,CAAAC,OAAA,UAEA,IAAAC,UAAA,CAAAC,sBAAA,CAAAF,OAAA,6BAJA,kDAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACe,QAAS,CAAAG,cAAcA,CAAC,CACrCC,SAAS,CACTC,YAAY,CACZC,WACF,CAAC,CAAE,CACD;AACA,MAAO,CAAC,CAAEC,QAAQ,CAAE,GAAGC,KAAM,CAAC,CAAG,CAAC,CAAC,gBAAK,GAAAC,oBAAa,EACnDC,kBAAS,CACT,CACE,GAAGF,KAAK,CACRJ,SAAS,CACTC,YAAY,CACZC,WACF,CAAC,CACDC,QACF,CACF"}
1
+ {"version":3,"file":"splitComponent.js","names":["_propTypes","_interopRequireDefault","require","_react","_jsUtils","_reactGlobalState","_isomorphy","_jsxRuntime","clientChunkGroups","IS_CLIENT_SIDE","default","CHUNK_GROUPS","refCounts","getPublicPath","getBuildInfo","publicPath","bookStyleSheet","name","loadedSheets","refCount","res","path","fullPath","document","location","origin","has","link","querySelector","createElement","setAttribute","head","appendChild","Barrier","addEventListener","resolve","current","getLoadedStyleSheets","Set","styleSheets","i","length","href","add","assertChunkName","chunkName","chunkGroups","Error","bookStyleSheets","promises","assets","asset","endsWith","promise","push","Promise","allSettled","freeStyleSheets","remove","usedChunkNames","splitComponent","getComponent","placeholder","LazyComponent","lazy","Component","Wrapper","forwardRef","children","rest","ref","IS_SERVER_SIDE","chunks","getSsrContext","includes","useInsertionEffect","jsx","propTypes","PT","node","defaultProps","undefined","CodeSplit","Suspense","fallback"],"sources":["../../../../src/shared/utils/splitComponent.jsx"],"sourcesContent":["/* eslint-disable react/jsx-props-no-spreading */\n/* global document */\n\nimport PT from 'prop-types';\n\nimport {\n forwardRef,\n lazy,\n Suspense,\n useInsertionEffect,\n} from 'react';\n\nimport { Barrier } from '@dr.pogodin/js-utils';\nimport { getSsrContext } from '@dr.pogodin/react-global-state';\n\nimport {\n IS_CLIENT_SIDE,\n IS_SERVER_SIDE,\n getBuildInfo,\n} from 'utils/isomorphy';\n\n// Note: At the client side we can get chunk groups immediately when loading\n// the module; at the server-side we only can get them within React render flow.\n// Thus, we set and use the following variable at the client-side, and then when\n// needed on the server side, we'll fetch it differently.\nlet clientChunkGroups;\nif (IS_CLIENT_SIDE) {\n // eslint-disable-next-line global-require\n clientChunkGroups = require('client/getInj').default().CHUNK_GROUPS || {};\n}\n\nconst refCounts = {};\n\nfunction getPublicPath() {\n return getBuildInfo().publicPath;\n}\n\n/**\n * Client-side only! Ensures the specified CSS stylesheet is loaded into\n * the document; loads if it is missing; and does simple reference counting\n * to facilitate future clean-up.\n * @param {string} name\n * @param {Set} loadedSheets\n * @param {boolean} refCount\n * @return {Promise}\n */\nfunction bookStyleSheet(name, loadedSheets, refCount) {\n let res;\n const path = `${getPublicPath()}/${name}`;\n const fullPath = `${document.location.origin}${path}`;\n\n if (!loadedSheets.has(fullPath)) {\n let link = document.querySelector(`link[href=\"${path}\"]`);\n\n if (!link) {\n link = document.createElement('link');\n link.setAttribute('rel', 'stylesheet');\n link.setAttribute('href', path);\n document.head.appendChild(link);\n }\n\n res = new Barrier();\n link.addEventListener('load', res.resolve);\n link.addEventListener('error', res.resolve);\n }\n\n if (refCount) {\n const current = refCounts[path] || 0;\n refCounts[path] = 1 + current;\n }\n\n return res;\n}\n\n/**\n * Generates the set of URLs for currently loaded, linked stylesheets.\n * @return {Set}\n */\nfunction getLoadedStyleSheets() {\n const res = new Set();\n const { styleSheets } = document;\n for (let i = 0; i < styleSheets.length; ++i) {\n const { href } = styleSheets[i];\n if (href) res.add(href);\n }\n return res;\n}\n\nfunction assertChunkName(chunkName, chunkGroups) {\n if (chunkGroups[chunkName]) return;\n throw Error(`Unknown chunk name \"${chunkName}\"`);\n}\n\n/**\n * Client-side only! Ensures all CSS stylesheets required for the specified\n * code chunk are loaded into the document; loads the missing ones; and does\n * simple reference counting to facilitate future clean-up.\n * @param {string} chunkName Chunk name.\n * @param {boolean} refCount\n * @return {Promise} Resolves once all pending stylesheets, necessary for\n * the chunk, are either loaded, or failed to load.\n */\nexport function bookStyleSheets(chunkName, chunkGroups, refCount) {\n const promises = [];\n const assets = chunkGroups[chunkName];\n const loadedSheets = getLoadedStyleSheets();\n\n for (let i = 0; i < assets.length; ++i) {\n const asset = assets[i];\n if (asset.endsWith('.css')) {\n const promise = bookStyleSheet(asset, loadedSheets, refCount);\n if (promise) promises.push(promise);\n }\n }\n\n return promises.length ? Promise.allSettled(promises) : Promise.resolve();\n}\n\n/**\n * Client-side only! Frees from the document all CSS stylesheets that are\n * required by the specified chunk, and have reference counter equal to one\n * (for chunks with larger reference counter values, it just decrements\n * the reference counter).\n * @param {string} chunkName\n */\nexport function freeStyleSheets(chunkName, chunkGroups) {\n const assets = chunkGroups[chunkName];\n for (let i = 0; i < assets.length; ++i) {\n const asset = assets[i];\n if (asset.endsWith('.css')) {\n const path = `${getPublicPath()}/${asset}`;\n if (--refCounts[path] <= 0) {\n document.head.querySelector(`link[href=\"${path}\"]`).remove();\n }\n }\n }\n}\n\n// Holds the set of chunk names already used for splitComponent() calls.\nconst usedChunkNames = new Set();\n\n/**\n * Given an async component retrieval function `getComponent()` it creates\n * a special \"code split\" component, which uses <Suspense> to asynchronously\n * load on demand the code required by `getComponent()`.\n * @param {object} options\n * @param {string} options.chunkName\n * @param {function} options.getComponent\n * @param {React.Element} [options.placeholder]\n * @return {React.ElementType}\n */\nexport default function splitComponent({\n chunkName,\n getComponent,\n placeholder,\n}) {\n // On the client side we can check right away if the chunk name is known.\n if (IS_CLIENT_SIDE) assertChunkName(chunkName, clientChunkGroups);\n\n // The correct usage of splitComponent() assumes a single call per chunk.\n if (usedChunkNames.has(chunkName)) {\n throw Error(`Repeated splitComponent() call for the chunk \"${chunkName}\"`);\n } else usedChunkNames.add(chunkName);\n\n const LazyComponent = lazy(async () => {\n let Component = await getComponent();\n if (Component.default) Component = Component.default;\n\n // This pre-loads necessary stylesheets prior to the first mount of\n // the component (the lazy load function is executed by React one at\n // the frist mount).\n if (IS_CLIENT_SIDE) {\n await bookStyleSheets(chunkName, clientChunkGroups, false);\n }\n\n const Wrapper = forwardRef(({ children, ...rest }, ref) => {\n // On the server side we'll assert the chunk name here,\n // and also push it to the SSR chunks array.\n if (IS_SERVER_SIDE) {\n const { chunkGroups, chunks } = getSsrContext();\n assertChunkName(chunkName, chunkGroups);\n if (!chunks.includes(chunkName)) chunks.push(chunkName);\n }\n\n // This takes care about stylesheets management every time an instance of\n // this component is mounted / unmounted.\n useInsertionEffect(() => {\n bookStyleSheets(chunkName, clientChunkGroups, true);\n return () => freeStyleSheets(chunkName, clientChunkGroups);\n }, []);\n\n return <Component ref={ref} {...rest}>{children}</Component>;\n });\n\n Wrapper.propTypes = {\n children: PT.node,\n };\n\n Wrapper.defaultProps = {\n children: undefined,\n };\n\n return { default: Wrapper };\n });\n\n function CodeSplit({ children, ...rest }) {\n return (\n <Suspense fallback={placeholder}>\n <LazyComponent {...rest}>\n {children}\n </LazyComponent>\n </Suspense>\n );\n }\n\n CodeSplit.propTypes = {\n children: PT.node,\n };\n\n CodeSplit.defaultProps = {\n children: undefined,\n };\n\n return CodeSplit;\n}\n"],"mappings":"wQAGA,IAAAA,UAAA,CAAAC,sBAAA,CAAAC,OAAA,gBAEA,IAAAC,MAAA,CAAAD,OAAA,UAOA,IAAAE,QAAA,CAAAF,OAAA,yBACA,IAAAG,iBAAA,CAAAH,OAAA,mCAEA,IAAAI,UAAA,CAAAJ,OAAA,gBAIyB,IAAAK,WAAA,CAAAL,OAAA,sBAnBzB,kDACA,sBAoBA;AACA;AACA;AACA;AACA,GAAI,CAAAM,iBAAiB,CACrB,GAAIC,yBAAc,CAAE,CAClB;AACAD,iBAAiB,CAAGN,OAAO,sBAAgB,CAAC,CAACQ,OAAO,CAAC,CAAC,CAACC,YAAY,EAAI,CAAC,CAC1E,CAEA,KAAM,CAAAC,SAAS,CAAG,CAAC,CAAC,CAEpB,QAAS,CAAAC,aAAaA,CAAA,CAAG,CACvB,MAAO,GAAAC,uBAAY,EAAC,CAAC,CAACC,UACxB,CAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,QAAS,CAAAC,cAAcA,CAACC,IAAI,CAAEC,YAAY,CAAEC,QAAQ,CAAE,CACpD,GAAI,CAAAC,GAAG,CACP,KAAM,CAAAC,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