@dr.pogodin/react-utils 1.54.3 → 1.55.0-alpha.2

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.
Files changed (232) hide show
  1. package/__type_tests__/ts-compiler-behavior.ts +13 -0
  2. package/__type_tests__/type-exports.ts +17 -0
  3. package/babel.build.config.js +9 -0
  4. package/babel.config.js +2 -5
  5. package/babel.libweb.config.js +2 -3
  6. package/babel.scripts.config.js +5 -11
  7. package/bin/build.js +4 -21
  8. package/bin/release.sh +1 -1
  9. package/build/development/client/getInj.js +2 -9
  10. package/build/development/client/getInj.js.map +1 -1
  11. package/build/development/client/index.js.map +1 -1
  12. package/build/development/client/init.js +1 -3
  13. package/build/development/client/init.js.map +1 -1
  14. package/build/development/index.js +1 -18
  15. package/build/development/index.js.map +1 -1
  16. package/build/development/server/Cache.js.map +1 -1
  17. package/build/development/server/index.js.map +1 -1
  18. package/build/development/server/renderer.js +10 -24
  19. package/build/development/server/renderer.js.map +1 -1
  20. package/build/development/server/server.js +6 -8
  21. package/build/development/server/server.js.map +1 -1
  22. package/build/development/server/utils/errors.js +11 -11
  23. package/build/development/server/utils/errors.js.map +1 -1
  24. package/build/development/shared/components/Button/index.js.map +1 -1
  25. package/build/development/shared/components/Checkbox/index.js.map +1 -1
  26. package/build/development/shared/components/GenericLink/index.js.map +1 -1
  27. package/build/development/shared/components/Input/index.js.map +1 -1
  28. package/build/development/shared/components/Link.js.map +1 -1
  29. package/build/development/shared/components/Modal/index.js.map +1 -1
  30. package/build/development/shared/components/NavLink.js.map +1 -1
  31. package/build/development/shared/components/PageLayout/index.js.map +1 -1
  32. package/build/development/shared/components/TextArea/index.js.map +1 -1
  33. package/build/development/shared/components/Throbber/index.js.map +1 -1
  34. package/build/development/shared/components/WithTooltip/Tooltip.js.map +1 -1
  35. package/build/development/shared/components/WithTooltip/index.js.map +1 -1
  36. package/build/development/shared/components/YouTubeVideo/index.js.map +1 -1
  37. package/build/development/shared/components/index.js.map +1 -1
  38. package/build/development/shared/components/selectors/CustomDropdown/Options/index.js +2 -5
  39. package/build/development/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
  40. package/build/development/shared/components/selectors/CustomDropdown/index.js +1 -4
  41. package/build/development/shared/components/selectors/CustomDropdown/index.js.map +1 -1
  42. package/build/development/shared/components/selectors/NativeDropdown/index.js +2 -5
  43. package/build/development/shared/components/selectors/NativeDropdown/index.js.map +1 -1
  44. package/build/development/shared/components/selectors/Switch/index.js +2 -2
  45. package/build/development/shared/components/selectors/Switch/index.js.map +1 -1
  46. package/build/development/shared/components/selectors/common.js.map +1 -1
  47. package/build/development/shared/components/selectors/index.js.map +1 -1
  48. package/build/development/shared/utils/config.js.map +1 -1
  49. package/build/development/shared/utils/globalState.js.map +1 -1
  50. package/build/development/shared/utils/index.js.map +1 -1
  51. package/build/development/shared/utils/isomorphy/buildInfo.js.map +1 -1
  52. package/build/development/shared/utils/isomorphy/environment-check.js.map +1 -1
  53. package/build/development/shared/utils/isomorphy/index.js +4 -5
  54. package/build/development/shared/utils/isomorphy/index.js.map +1 -1
  55. package/build/development/shared/utils/jest/E2eSsrEnv/index.js +32 -71
  56. package/build/development/shared/utils/jest/E2eSsrEnv/index.js.map +1 -1
  57. package/build/development/shared/utils/jest/E2eSsrEnv/ssr-preload.js +23 -0
  58. package/build/development/shared/utils/jest/E2eSsrEnv/ssr-preload.js.map +1 -0
  59. package/build/development/shared/utils/jest/E2eSsrEnv/ssr.js +1 -1
  60. package/build/development/shared/utils/jest/E2eSsrEnv/ssr.js.map +1 -1
  61. package/build/development/shared/utils/jest/global.js.map +1 -1
  62. package/build/development/shared/utils/jest/index.js +3 -3
  63. package/build/development/shared/utils/jest/index.js.map +1 -1
  64. package/build/development/shared/utils/splitComponent.js +17 -40
  65. package/build/development/shared/utils/splitComponent.js.map +1 -1
  66. package/build/development/shared/utils/time.js +28 -65
  67. package/build/development/shared/utils/time.js.map +1 -1
  68. package/build/development/shared/utils/webpack.js +3 -5
  69. package/build/development/shared/utils/webpack.js.map +1 -1
  70. package/build/production/client/getInj.js +1 -1
  71. package/build/production/client/getInj.js.map +1 -1
  72. package/build/production/client/index.js.map +1 -1
  73. package/build/production/client/init.js.map +1 -1
  74. package/build/production/index.js +1 -23
  75. package/build/production/index.js.map +1 -1
  76. package/build/production/server/Cache.js.map +1 -1
  77. package/build/production/server/index.js.map +1 -1
  78. package/build/production/server/renderer.js +5 -5
  79. package/build/production/server/renderer.js.map +1 -1
  80. package/build/production/server/server.js +4 -4
  81. package/build/production/server/server.js.map +1 -1
  82. package/build/production/server/utils/errors.js +2 -2
  83. package/build/production/server/utils/errors.js.map +1 -1
  84. package/build/production/shared/components/Button/index.js.map +1 -1
  85. package/build/production/shared/components/Checkbox/index.js.map +1 -1
  86. package/build/production/shared/components/GenericLink/index.js.map +1 -1
  87. package/build/production/shared/components/Input/index.js.map +1 -1
  88. package/build/production/shared/components/Link.js.map +1 -1
  89. package/build/production/shared/components/Modal/index.js.map +1 -1
  90. package/build/production/shared/components/NavLink.js.map +1 -1
  91. package/build/production/shared/components/PageLayout/index.js.map +1 -1
  92. package/build/production/shared/components/TextArea/index.js.map +1 -1
  93. package/build/production/shared/components/Throbber/index.js.map +1 -1
  94. package/build/production/shared/components/WithTooltip/Tooltip.js.map +1 -1
  95. package/build/production/shared/components/WithTooltip/index.js.map +1 -1
  96. package/build/production/shared/components/YouTubeVideo/index.js.map +1 -1
  97. package/build/production/shared/components/index.js.map +1 -1
  98. package/build/production/shared/components/selectors/CustomDropdown/Options/index.js +1 -1
  99. package/build/production/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
  100. package/build/production/shared/components/selectors/CustomDropdown/index.js +1 -1
  101. package/build/production/shared/components/selectors/CustomDropdown/index.js.map +1 -1
  102. package/build/production/shared/components/selectors/NativeDropdown/index.js +2 -2
  103. package/build/production/shared/components/selectors/NativeDropdown/index.js.map +1 -1
  104. package/build/production/shared/components/selectors/Switch/index.js +1 -1
  105. package/build/production/shared/components/selectors/Switch/index.js.map +1 -1
  106. package/build/production/shared/components/selectors/common.js.map +1 -1
  107. package/build/production/shared/components/selectors/index.js.map +1 -1
  108. package/build/production/shared/utils/config.js.map +1 -1
  109. package/build/production/shared/utils/globalState.js.map +1 -1
  110. package/build/production/shared/utils/index.js.map +1 -1
  111. package/build/production/shared/utils/isomorphy/buildInfo.js.map +1 -1
  112. package/build/production/shared/utils/isomorphy/environment-check.js.map +1 -1
  113. package/build/production/shared/utils/isomorphy/index.js.map +1 -1
  114. package/build/production/shared/utils/jest/E2eSsrEnv/index.js +12 -37
  115. package/build/production/shared/utils/jest/E2eSsrEnv/index.js.map +1 -1
  116. package/build/production/shared/utils/jest/E2eSsrEnv/ssr-preload.js +5 -0
  117. package/build/production/shared/utils/jest/E2eSsrEnv/ssr-preload.js.map +1 -0
  118. package/build/production/shared/utils/jest/E2eSsrEnv/ssr.js +1 -1
  119. package/build/production/shared/utils/jest/E2eSsrEnv/ssr.js.map +1 -1
  120. package/build/production/shared/utils/jest/global.js.map +1 -1
  121. package/build/production/shared/utils/jest/index.js +3 -3
  122. package/build/production/shared/utils/jest/index.js.map +1 -1
  123. package/build/production/shared/utils/splitComponent.js +7 -20
  124. package/build/production/shared/utils/splitComponent.js.map +1 -1
  125. package/build/production/shared/utils/time.js +2 -2
  126. package/build/production/shared/utils/time.js.map +1 -1
  127. package/build/production/shared/utils/webpack.js +3 -3
  128. package/build/production/shared/utils/webpack.js.map +1 -1
  129. package/build/types-code/index.d.ts +7 -0
  130. package/build/types-code/shared/utils/webpack.d.ts +2 -2
  131. package/build/web/client/getInj.js +2 -2
  132. package/build/web/client/getInj.js.map +1 -1
  133. package/build/web/client/index.js +1 -1
  134. package/build/web/client/index.js.map +1 -1
  135. package/build/web/client/init.js +1 -1
  136. package/build/web/client/init.js.map +1 -1
  137. package/build/web/index.js +1 -23
  138. package/build/web/index.js.map +1 -1
  139. package/build/web/server/Cache.js.map +1 -1
  140. package/build/web/server/index.js +1 -1
  141. package/build/web/server/index.js.map +1 -1
  142. package/build/web/server/renderer.js +6 -6
  143. package/build/web/server/renderer.js.map +1 -1
  144. package/build/web/server/server.js +5 -5
  145. package/build/web/server/server.js.map +1 -1
  146. package/build/web/server/utils/errors.js +2 -2
  147. package/build/web/server/utils/errors.js.map +1 -1
  148. package/build/web/server/utils/index.js +1 -1
  149. package/build/web/server/utils/index.js.map +1 -1
  150. package/build/web/shared/components/Button/index.js +1 -1
  151. package/build/web/shared/components/Button/index.js.map +1 -1
  152. package/build/web/shared/components/Checkbox/index.js.map +1 -1
  153. package/build/web/shared/components/GenericLink/index.js.map +1 -1
  154. package/build/web/shared/components/Input/index.js.map +1 -1
  155. package/build/web/shared/components/Link.js +1 -1
  156. package/build/web/shared/components/Link.js.map +1 -1
  157. package/build/web/shared/components/Modal/index.js.map +1 -1
  158. package/build/web/shared/components/NavLink.js +1 -1
  159. package/build/web/shared/components/NavLink.js.map +1 -1
  160. package/build/web/shared/components/PageLayout/index.js.map +1 -1
  161. package/build/web/shared/components/TextArea/index.js.map +1 -1
  162. package/build/web/shared/components/Throbber/index.js.map +1 -1
  163. package/build/web/shared/components/WithTooltip/Tooltip.js.map +1 -1
  164. package/build/web/shared/components/WithTooltip/index.js +1 -1
  165. package/build/web/shared/components/WithTooltip/index.js.map +1 -1
  166. package/build/web/shared/components/YouTubeVideo/index.js +1 -1
  167. package/build/web/shared/components/YouTubeVideo/index.js.map +1 -1
  168. package/build/web/shared/components/index.js +1 -1
  169. package/build/web/shared/components/index.js.map +1 -1
  170. package/build/web/shared/components/selectors/CustomDropdown/Options/index.js +1 -1
  171. package/build/web/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
  172. package/build/web/shared/components/selectors/CustomDropdown/index.js +1 -1
  173. package/build/web/shared/components/selectors/CustomDropdown/index.js.map +1 -1
  174. package/build/web/shared/components/selectors/NativeDropdown/index.js +3 -3
  175. package/build/web/shared/components/selectors/NativeDropdown/index.js.map +1 -1
  176. package/build/web/shared/components/selectors/Switch/index.js +1 -1
  177. package/build/web/shared/components/selectors/Switch/index.js.map +1 -1
  178. package/build/web/shared/components/selectors/common.js.map +1 -1
  179. package/build/web/shared/components/selectors/index.js +1 -1
  180. package/build/web/shared/components/selectors/index.js.map +1 -1
  181. package/build/web/shared/utils/config.js +1 -1
  182. package/build/web/shared/utils/config.js.map +1 -1
  183. package/build/web/shared/utils/globalState.js.map +1 -1
  184. package/build/web/shared/utils/index.js +1 -1
  185. package/build/web/shared/utils/index.js.map +1 -1
  186. package/build/web/shared/utils/isomorphy/buildInfo.js.map +1 -1
  187. package/build/web/shared/utils/isomorphy/environment-check.js.map +1 -1
  188. package/build/web/shared/utils/isomorphy/index.js +1 -1
  189. package/build/web/shared/utils/isomorphy/index.js.map +1 -1
  190. package/build/web/shared/utils/jest/E2eSsrEnv/index.js +12 -37
  191. package/build/web/shared/utils/jest/E2eSsrEnv/index.js.map +1 -1
  192. package/build/web/shared/utils/jest/E2eSsrEnv/ssr-preload.js +5 -0
  193. package/build/web/shared/utils/jest/E2eSsrEnv/ssr-preload.js.map +1 -0
  194. package/build/web/shared/utils/jest/E2eSsrEnv/ssr.js +2 -2
  195. package/build/web/shared/utils/jest/E2eSsrEnv/ssr.js.map +1 -1
  196. package/build/web/shared/utils/jest/global.js.map +1 -1
  197. package/build/web/shared/utils/jest/index.js +4 -4
  198. package/build/web/shared/utils/jest/index.js.map +1 -1
  199. package/build/web/shared/utils/splitComponent.js +7 -20
  200. package/build/web/shared/utils/splitComponent.js.map +1 -1
  201. package/build/web/shared/utils/time.js +2 -2
  202. package/build/web/shared/utils/time.js.map +1 -1
  203. package/build/web/shared/utils/webpack.js +4 -4
  204. package/build/web/shared/utils/webpack.js.map +1 -1
  205. package/config/babel/node-ssr.d.ts +2 -3
  206. package/config/babel/node-ssr.js +15 -55
  207. package/config/babel/webpack.d.ts +7 -5
  208. package/config/babel/webpack.js +19 -24
  209. package/config/eslint/default.mjs +1 -1
  210. package/config/jest/default.js +6 -7
  211. package/config/jest/resolver.js +1 -3
  212. package/config/jest/setup.js +2 -2
  213. package/config/stylelint/default.js +1 -4
  214. package/config/webpack/app-base.js +40 -41
  215. package/config/webpack/app-development.d.ts +1 -1
  216. package/config/webpack/app-development.js +12 -18
  217. package/config/webpack/app-production.d.ts +1 -1
  218. package/config/webpack/app-production.js +10 -16
  219. package/package.json +37 -35
  220. package/patches/jest-resolve+30.4.1.patch +29 -0
  221. package/tsconfig.configs.json +6 -1
  222. package/tsconfig.json +2 -1
  223. package/tsconfig.types.json +1 -0
  224. package/tstyche.json +1 -1
  225. package/babel.module.config.js +0 -11
  226. package/build/development/shared/utils/jest/E2eSsrEnv/register.js +0 -6
  227. package/build/development/shared/utils/jest/E2eSsrEnv/register.js.map +0 -1
  228. package/build/production/shared/utils/jest/E2eSsrEnv/register.js +0 -3
  229. package/build/production/shared/utils/jest/E2eSsrEnv/register.js.map +0 -1
  230. package/build/web/shared/utils/jest/E2eSsrEnv/register.js +0 -3
  231. package/build/web/shared/utils/jest/E2eSsrEnv/register.js.map +0 -1
  232. /package/build/types-code/shared/utils/jest/E2eSsrEnv/{register.d.ts → ssr-preload.d.ts} +0 -0
@@ -0,0 +1,13 @@
1
+ // Checks assumptions about TypeScript compiler behavior.
2
+
3
+ import { expect, test } from 'tstyche';
4
+
5
+ test('array element types', () => {
6
+ const array: number[] = [1];
7
+ expect(array[1]).type.toBe<number | undefined>();
8
+ });
9
+
10
+ test('object field types', () => {
11
+ const object: Record<string, string> = {};
12
+ expect(object.field).type.toBe<string | undefined>();
13
+ });
@@ -0,0 +1,17 @@
1
+ import { expect, test } from 'tstyche';
2
+
3
+ import type {
4
+ BeforeRenderResT,
5
+ BeforeRenderT,
6
+ ConfigT,
7
+ ServerSsrContext,
8
+ ServerT,
9
+ } from '../src';
10
+
11
+ test('type exports', () => {
12
+ expect<BeforeRenderResT>().type.toBe<BeforeRenderResT>();
13
+ expect<BeforeRenderT>().type.toBe<BeforeRenderT>();
14
+ expect<ConfigT>().type.toBe<ConfigT>();
15
+ expect<ServerSsrContext<unknown>>().type.toBe<ServerSsrContext<unknown>>();
16
+ expect<ServerT>().type.toBe<ServerT>();
17
+ });
@@ -0,0 +1,9 @@
1
+ export default {
2
+ presets: [
3
+ ['./config/babel/node-ssr', {
4
+ addImportExtensions: true,
5
+ typescript: true,
6
+ }],
7
+ ],
8
+ targets: 'maintained node versions',
9
+ };
package/babel.config.js CHANGED
@@ -1,11 +1,8 @@
1
- /* eslint-disable import/no-commonjs */
2
- /* global module */
3
-
4
- module.exports = {
5
- plugins: [['babel-plugin-transform-import-meta', { module: 'ES6' }]],
1
+ export default {
6
2
  presets: [
7
3
  ['./config/babel/node-ssr', {
8
4
  typescript: true,
9
5
  }],
10
6
  ],
7
+ targets: 'maintained node versions',
11
8
  };
@@ -3,11 +3,10 @@
3
3
  // Module resolver to replace aliased paths. The rest of the bundling will be
4
4
  // performed by Webpack build of the host code.
5
5
 
6
- /* global module */
7
-
8
- module.exports = {
6
+ export default {
9
7
  presets: [
10
8
  ['./config/babel/webpack', {
9
+ addImportExtensions: true,
11
10
  noRR: true,
12
11
  noStyling: true,
13
12
  typescript: true,
@@ -1,19 +1,13 @@
1
1
  // Babel config for compilation of helper scripts (bin-ts-src > bin).
2
2
 
3
- /* global module */
4
-
5
- module.exports = {
3
+ export default {
6
4
  plugins: [
7
- ['@babel/transform-runtime', { useESModules: true }],
5
+ '@babel/transform-runtime',
6
+ ['polyfill-corejs3', { method: 'usage-pure', version: '3.49' }],
8
7
  ],
9
8
  presets: [
10
- ['@babel/env', {
11
- bugfixes: true,
12
- corejs: '3.49',
13
- modules: false,
14
- targets: 'maintained node versions',
15
- useBuiltIns: 'usage',
16
- }],
9
+ ['@babel/env', { modules: false }],
17
10
  '@babel/typescript',
18
11
  ],
12
+ targets: 'maintained node versions',
19
13
  };
package/bin/build.js CHANGED
@@ -2,25 +2,14 @@
2
2
 
3
3
  /* eslint-disable no-console, import/no-extraneous-dependencies */
4
4
  //* global console, process */
5
- import "core-js/modules/es.iterator.for-each.js";
6
- import "core-js/modules/es.iterator.map.js";
7
5
  import childProcess from 'node:child_process';
8
6
  import fs from 'node:fs';
9
7
  import { createRequire } from 'node:module';
10
8
  import path from 'node:path';
11
9
  import { mapValues, merge } from 'lodash-es';
12
-
13
- // TODO: Disabled, because ESLint still does not support "exports" declarations
14
- // in "package.json", and "rimraf" does not declare fallback entrance.
15
- // See: https://github.com/import-js/eslint-plugin-import/issues/1810
16
- // and update, once that issue is resolved.
17
10
  import { rimraf } from 'rimraf';
18
11
  import withWebpackBuild from 'webpack';
19
-
20
- // TODO: Double-check, do we need it still? Can we do something better?
21
- // To support TS configs for Webpack.
22
- // @ts-expect-error "No types for this module exist yet"
23
- import register from '@babel/register/experimental-worker.js';
12
+ import register from '@babel/register';
24
13
  import { program } from '@commander-js/extra-typings';
25
14
  const validBuildTypes = ['app-development', 'app-production', 'library'];
26
15
  /**
@@ -105,14 +94,8 @@ const webpackOutDir = `${buildDir}/web-public`;
105
94
  function newWebpackCompiler() {
106
95
  if (!isRequireUpgraded) {
107
96
  isRequireUpgraded = true;
108
-
109
- // TODO: We don't have types for this function, see a related comment
110
- // earlier.
111
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call
112
97
  register({
113
- envName: 'production',
114
- extensions: ['.js', '.jsx', '.ts', '.tsx', '.svg'],
115
- root: process.cwd()
98
+ extensions: ['.js', '.jsx', '.ts', '.tsx', '.svg']
116
99
  });
117
100
  }
118
101
  const require = createRequire(import.meta.url);
@@ -314,13 +297,13 @@ void (async () => {
314
297
  await buildLibIntermediates();
315
298
  await buildWithBabelForServerSide({
316
299
  buildType: 'development',
317
- configPath: 'babel.module.config.js',
300
+ configPath: 'babel.build.config.js',
318
301
  outDir: `${buildDir}/development`,
319
302
  srcDir: `${buildDir}/web`
320
303
  });
321
304
  await buildWithBabelForServerSide({
322
305
  buildType: 'production',
323
- configPath: 'babel.module.config.js',
306
+ configPath: 'babel.build.config.js',
324
307
  outDir: `${buildDir}/production`,
325
308
  srcDir: `${buildDir}/web`
326
309
  });
package/bin/release.sh CHANGED
@@ -23,4 +23,4 @@ gsutil -m rsync -d -r docs/build gs://docs.pogodin.studio/react-utils
23
23
 
24
24
  # Library package release.
25
25
  export NPM_ID_TOKEN=$(circleci run oidc get --claims '{"aud": "npm:registry.npmjs.org"}')
26
- npm publish --access public
26
+ npm publish --access public --tag alpha
@@ -1,12 +1,5 @@
1
- import "core-js/modules/es.array-buffer.detached.js";
2
- import "core-js/modules/es.array-buffer.transfer.js";
3
- import "core-js/modules/es.array-buffer.transfer-to-fixed-length.js";
4
- import "core-js/modules/es.typed-array.to-reversed.js";
5
- import "core-js/modules/es.typed-array.to-sorted.js";
6
- import "core-js/modules/es.typed-array.with.js";
7
- import "core-js/modules/web.dom-exception.stack.js"; // Encapsulates retrieval of server-side data injection into HTML template.
8
- /* global document */
9
- import { SEC_MS, timer } from "@dr.pogodin/js-utils";
1
+ // Encapsulates retrieval of server-side data injection into HTML template.
2
+ /* global document */import { SEC_MS, timer } from "@dr.pogodin/js-utils";
10
3
  import { getBuildInfo } from "../shared/utils/isomorphy/buildInfo.js";
11
4
  let inj;
12
5
  export default function getInj() {
@@ -1 +1 @@
1
- {"version":3,"file":"getInj.js","names":["SEC_MS","timer","getBuildInfo","inj","getInj","metaElement","document","querySelector","remove","data","atob","content","window","isSecureContext","location","protocol","Error","target","href","replace","key","code","x","charCodeAt","dataBuffer","Uint8Array","from","slice","ivBuffer","keyBuffer","cKey","crypto","subtle","importKey","name","buffer","decrypt","iv","decoder","TextDecoder","res","eval","decode","REACT_UTILS_INJECTION"],"sources":["../../../src/client/getInj.ts"],"sourcesContent":["// Encapsulates retrieval of server-side data injection into HTML template.\n\n/* global document */\n\nimport { SEC_MS, timer } from '@dr.pogodin/js-utils';\n\nimport type { InjT } from 'utils/globalState';\n\nimport { getBuildInfo } from 'utils/isomorphy/buildInfo';\n\nlet inj: InjT | Promise<InjT> | undefined;\n\nexport default function getInj(): InjT | Promise<InjT> {\n inj ??= (async () => {\n const metaElement: HTMLMetaElement | null = typeof document === 'undefined'\n ? null : document.querySelector('meta[itemprop=\"drpruinj\"]');\n\n if (metaElement) {\n metaElement.remove();\n\n // NOTE: Since 2025 there is Uint8Array.fromBase64(), which should be\n // preferred, but it is not supported by older environments yet.\n const data = atob(metaElement.content);\n\n if (!window.isSecureContext) {\n if (window.location.protocol === 'https:') {\n throw Error('Loaded via HTTPS, but it is not considered a secure context');\n } else if (window.location.protocol !== 'http:') {\n throw Error('Unexpected protocol');\n }\n\n const target = window.location.href.replace(/^http:/, 'https:');\n window.location.replace(target);\n\n await timer(3 * SEC_MS);\n throw Error('Failed to move into secure context');\n }\n\n const { key } = getBuildInfo();\n\n const code = (x: string) => x.charCodeAt(0);\n const dataBuffer = Uint8Array.from(data.slice(16), code);\n const ivBuffer = Uint8Array.from(data.slice(0, 16), code);\n const keyBuffer = Uint8Array.from(atob(key), code);\n\n const cKey = await window.crypto.subtle.importKey(\n 'raw',\n keyBuffer,\n { name: 'AES-CBC' },\n false,\n ['decrypt'],\n );\n\n const buffer = await window.crypto.subtle.decrypt({\n iv: ivBuffer,\n name: 'AES-CBC',\n }, cKey, dataBuffer);\n\n const decoder = new TextDecoder();\n\n // eslint-disable-next-line no-eval\n const res = eval(`(${decoder.decode(buffer)})`) as InjT;\n\n // NOTE: This is important, to be able to return the injection\n // synchronously once it is initialized.\n inj = res;\n\n return res;\n } else if (typeof window !== 'undefined' && window.REACT_UTILS_INJECTION) {\n const res = window.REACT_UTILS_INJECTION;\n delete window.REACT_UTILS_INJECTION;\n return res;\n }\n\n // Otherwise, a bunch of dependent stuff will easily fail in non-standard\n // environments, where no client-side initialization is performed. Like tests,\n // Docusaurus examples, etc.\n return {};\n })();\n\n return inj;\n}\n"],"mappings":";;;;;;oDAAA;AAEA;AAEA,SAASA,MAAM,EAAEC,KAAK,QAAQ,sBAAsB;AAIpD,SAASC,YAAY;AAErB,IAAIC,GAAqC;AAEzC,eAAe,SAASC,MAAMA,CAAA,EAAyB;EACrDD,GAAG,KAAK,CAAC,YAAY;IACnB,MAAME,WAAmC,GAAG,OAAOC,QAAQ,KAAK,WAAW,GACvE,IAAI,GAAGA,QAAQ,CAACC,aAAa,CAAC,6BAA2B,CAAC;IAE9D,IAAIF,WAAW,EAAE;MACfA,WAAW,CAACG,MAAM,CAAC,CAAC,CAEpB;MACA;MACA,MAAMC,IAAI,GAAGC,IAAI,CAACL,WAAW,CAACM,OAAO,CAAC;MAEtC,IAAI,CAACC,MAAM,CAACC,eAAe,EAAE;QAC3B,IAAID,MAAM,CAACE,QAAQ,CAACC,QAAQ,KAAK,QAAQ,EAAE;UACzC,MAAMC,KAAK,CAAC,6DAA6D,CAAC;QAC5E,CAAC,MAAM,IAAIJ,MAAM,CAACE,QAAQ,CAACC,QAAQ,KAAK,OAAO,EAAE;UAC/C,MAAMC,KAAK,CAAC,qBAAqB,CAAC;QACpC;QAEA,MAAMC,MAAM,GAAGL,MAAM,CAACE,QAAQ,CAACI,IAAI,CAACC,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC;QAC/DP,MAAM,CAACE,QAAQ,CAACK,OAAO,CAACF,MAAM,CAAC;QAE/B,MAAMhB,KAAK,CAAC,CAAC,GAAGD,MAAM,CAAC;QACvB,MAAMgB,KAAK,CAAC,oCAAoC,CAAC;MACnD;MAEA,MAAM;QAAEI;MAAI,CAAC,GAAGlB,YAAY,CAAC,CAAC;MAE9B,MAAMmB,IAAI,GAAIC,CAAS,IAAKA,CAAC,CAACC,UAAU,CAAC,CAAC,CAAC;MAC3C,MAAMC,UAAU,GAAGC,UAAU,CAACC,IAAI,CAACjB,IAAI,CAACkB,KAAK,CAAC,EAAE,CAAC,EAAEN,IAAI,CAAC;MACxD,MAAMO,QAAQ,GAAGH,UAAU,CAACC,IAAI,CAACjB,IAAI,CAACkB,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAEN,IAAI,CAAC;MACzD,MAAMQ,SAAS,GAAGJ,UAAU,CAACC,IAAI,CAAChB,IAAI,CAACU,GAAG,CAAC,EAAEC,IAAI,CAAC;MAElD,MAAMS,IAAI,GAAG,MAAMlB,MAAM,CAACmB,MAAM,CAACC,MAAM,CAACC,SAAS,CAC/C,KAAK,EACLJ,SAAS,EACT;QAAEK,IAAI,EAAE;MAAU,CAAC,EACnB,KAAK,EACL,CAAC,SAAS,CACZ,CAAC;MAED,MAAMC,MAAM,GAAG,MAAMvB,MAAM,CAACmB,MAAM,CAACC,MAAM,CAACI,OAAO,CAAC;QAChDC,EAAE,EAAET,QAAQ;QACZM,IAAI,EAAE;MACR,CAAC,EAAEJ,IAAI,EAAEN,UAAU,CAAC;MAEpB,MAAMc,OAAO,GAAG,IAAIC,WAAa,CAAb,CAAa,CAEjC;MACA,MAAMC,GAAG,GAAGC,IAAI,CAAC,IAAIH,OAAO,CAACI,MAAM,CAACP,MAAM,CAAC,GAAG,CAAS,CAEvD;MACA;MACAhC,GAAG,GAAGqC,GAAG;MAET,OAAOA,GAAG;IACZ,CAAC,MAAM,IAAI,OAAO5B,MAAM,KAAK,WAAW,IAAIA,MAAM,CAAC+B,qBAAqB,EAAE;MACxE,MAAMH,GAAG,GAAG5B,MAAM,CAAC+B,qBAAqB;MACxC,OAAO/B,MAAM,CAAC+B,qBAAqB;MACnC,OAAOH,GAAG;IACZ,CAEA;IACA;IACA;IACA,OAAO,CAAC,CAAC;EACX,CAAC,EAAE,CAAC;EAEJ,OAAOrC,GAAG;AACZ","ignoreList":[]}
1
+ {"version":3,"file":"getInj.js","names":[],"sources":["../../../src/client/getInj.ts"],"sourcesContent":["// Encapsulates retrieval of server-side data injection into HTML template.\n\n/* global document */\n\nimport { SEC_MS, timer } from '@dr.pogodin/js-utils';\n\nimport type { InjT } from 'utils/globalState';\n\nimport { getBuildInfo } from 'utils/isomorphy/buildInfo';\n\nlet inj: InjT | Promise<InjT> | undefined;\n\nexport default function getInj(): InjT | Promise<InjT> {\n inj ??= (async () => {\n const metaElement: HTMLMetaElement | null = typeof document === 'undefined'\n ? null : document.querySelector('meta[itemprop=\"drpruinj\"]');\n\n if (metaElement) {\n metaElement.remove();\n\n // NOTE: Since 2025 there is Uint8Array.fromBase64(), which should be\n // preferred, but it is not supported by older environments yet.\n const data = atob(metaElement.content);\n\n if (!window.isSecureContext) {\n if (window.location.protocol === 'https:') {\n throw Error('Loaded via HTTPS, but it is not considered a secure context');\n } else if (window.location.protocol !== 'http:') {\n throw Error('Unexpected protocol');\n }\n\n const target = window.location.href.replace(/^http:/, 'https:');\n window.location.replace(target);\n\n await timer(3 * SEC_MS);\n throw Error('Failed to move into secure context');\n }\n\n const { key } = getBuildInfo();\n\n const code = (x: string) => x.charCodeAt(0);\n const dataBuffer = Uint8Array.from(data.slice(16), code);\n const ivBuffer = Uint8Array.from(data.slice(0, 16), code);\n const keyBuffer = Uint8Array.from(atob(key), code);\n\n const cKey = await window.crypto.subtle.importKey(\n 'raw',\n keyBuffer,\n { name: 'AES-CBC' },\n false,\n ['decrypt'],\n );\n\n const buffer = await window.crypto.subtle.decrypt({\n iv: ivBuffer,\n name: 'AES-CBC',\n }, cKey, dataBuffer);\n\n const decoder = new TextDecoder();\n\n // eslint-disable-next-line no-eval\n const res = eval(`(${decoder.decode(buffer)})`) as InjT;\n\n // NOTE: This is important, to be able to return the injection\n // synchronously once it is initialized.\n inj = res;\n\n return res;\n } else if (typeof window !== 'undefined' && window.REACT_UTILS_INJECTION) {\n const res = window.REACT_UTILS_INJECTION;\n delete window.REACT_UTILS_INJECTION;\n return res;\n }\n\n // Otherwise, a bunch of dependent stuff will easily fail in non-standard\n // environments, where no client-side initialization is performed. Like tests,\n // Docusaurus examples, etc.\n return {};\n })();\n\n return inj;\n}\n"],"mappings":"AAAA;AAEA,qBAEA,SAAS,MAAM,EAAE,KAAK,QAAQ,sBAAsB;AAAC,SAI5C,YAAY;AAErB,IAAI,GAAqC;AAEzC,eAAe,SAAS,MAAM,GAAyB;EACrD,GAAG,KAAK,CAAC,YAAY;IACnB,MAAM,WAAmC,GAAG,OAAO,QAAQ,KAAK,WAAW,GACvE,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,6BAA2B,CAAC;IAE9D,IAAI,WAAW,EAAE;MACf,WAAW,CAAC,MAAM,CAAC,CAAC,CAEpB;MACA;MACA,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC;MAEtC,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE;QAC3B,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,KAAK,QAAQ,EAAE;UACzC,MAAM,KAAK,CAAC,6DAA6D,CAAC;QAC5E,CAAC,MAAM,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,KAAK,OAAO,EAAE;UAC/C,MAAM,KAAK,CAAC,qBAAqB,CAAC;QACpC;QAEA,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC;QAC/D,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC;QAE/B,MAAM,KAAK,CAAC,CAAC,GAAG,MAAM,CAAC;QACvB,MAAM,KAAK,CAAC,oCAAoC,CAAC;MACnD;MAEA,MAAM;QAAE;MAAI,CAAC,GAAG,YAAY,CAAC,CAAC;MAE9B,MAAM,IAAI,GAAI,CAAS,IAAK,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;MAC3C,MAAM,UAAU,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC;MACxD,MAAM,QAAQ,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC;MACzD,MAAM,SAAS,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC;MAElD,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAC/C,KAAK,EACL,SAAS,EACT;QAAE,IAAI,EAAE;MAAU,CAAC,EACnB,KAAK,EACL,CAAC,SAAS,CACZ,CAAC;MAED,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;QAChD,EAAE,EAAE,QAAQ;QACZ,IAAI,EAAE;MACR,CAAC,EAAE,IAAI,EAAE,UAAU,CAAC;MAEpB,MAAM,OAAO,GAAG,IAAI,WAAa,CAAb,CAAa,CAEjC;MACA,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAS,CAEvD;MACA;MACA,GAAG,GAAG,GAAG;MAET,OAAO,GAAG;IACZ,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,qBAAqB,EAAE;MACxE,MAAM,GAAG,GAAG,MAAM,CAAC,qBAAqB;MACxC,OAAO,MAAM,CAAC,qBAAqB;MACnC,OAAO,GAAG;IACZ,CAEA;IACA;IACA;IACA,OAAO,CAAC,CAAC;EACX,CAAC,EAAE,CAAC;EAEJ,OAAO,GAAG;AACZ","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["createRoot","hydrateRoot","BrowserRouter","GlobalStateProvider","HelmetProvider","setClientChunkGroups","getInj","jsx","_jsx","launchClient","Application","options","inj","CHUNK_GROUPS","container","document","getElementById","Error","scene","initialState","ISTATE","children","dontHydrate","root","render"],"sources":["../../../src/client/index.tsx"],"sourcesContent":["// Initialization of client-side code.\n/* global document */\n\nimport type { ComponentType } from 'react';\nimport { createRoot, hydrateRoot } from 'react-dom/client';\nimport { BrowserRouter } from 'react-router';\n\nimport { GlobalStateProvider } from '@dr.pogodin/react-global-state';\nimport { HelmetProvider } from '@dr.pogodin/react-helmet';\n\nimport { setClientChunkGroups } from 'utils/splitComponent';\n\nimport getInj from './getInj';\n\ntype OptionsT = {\n dontHydrate?: boolean;\n initialState?: unknown;\n};\n\n/**\n * Prepares and launches the app at client side.\n * @param Application Root application component\n * @param [options={}] Optional. Additional settings.\n */\nexport async function launchClient(\n Application: ComponentType,\n options: OptionsT = {},\n): Promise<void> {\n const inj = await getInj();\n\n setClientChunkGroups(inj.CHUNK_GROUPS ?? {});\n\n const container = document.getElementById('react-view');\n if (!container) throw Error('Failed to find container for React app');\n const scene = (\n <GlobalStateProvider initialState={inj.ISTATE ?? options.initialState}>\n <BrowserRouter>\n <HelmetProvider>\n <Application />\n </HelmetProvider>\n </BrowserRouter>\n </GlobalStateProvider>\n );\n\n if (options.dontHydrate) {\n const root = createRoot(container);\n root.render(scene);\n } else hydrateRoot(container, scene);\n}\n"],"mappings":"AAAA;AACA,qBAGA,SAASA,UAAU,EAAEC,WAAW,QAAQ,kBAAkB;AAC1D,SAASC,aAAa,QAAQ,cAAc;AAE5C,SAASC,mBAAmB,QAAQ,gCAAgC;AACpE,SAASC,cAAc,QAAQ,0BAA0B;AAEzD,SAASC,oBAAoB;AAAA,OAEtBC,MAAM;AAAiB,SAAAC,GAAA,IAAAC,IAAA,4BAO9B;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,YAAYA,CAChCC,WAA0B,EAC1BC,OAAiB,GAAG,CAAC,CAAC,EACP;EACf,MAAMC,GAAG,GAAG,MAAMN,MAAM,CAAC,CAAC;EAE1BD,oBAAoB,CAACO,GAAG,CAACC,YAAY,IAAI,CAAC,CAAC,CAAC;EAE5C,MAAMC,SAAS,GAAGC,QAAQ,CAACC,cAAc,CAAC,YAAY,CAAC;EACvD,IAAI,CAACF,SAAS,EAAE,MAAMG,KAAK,CAAC,wCAAwC,CAAC;EACrE,MAAMC,KAAK,gBACTV,IAAA,CAACL,mBAAmB;IAACgB,YAAY,EAAEP,GAAG,CAACQ,MAAM,IAAIT,OAAO,CAACQ,YAAa;IAAAE,QAAA,eACpEb,IAAA,CAACN,aAAa;MAAAmB,QAAA,eACZb,IAAA,CAACJ,cAAc;QAAAiB,QAAA,eACbb,IAAA,CAACE,WAAW,IAAE;MAAC,CACD;IAAC,CACJ;EAAC,CACG,CACtB;EAED,IAAIC,OAAO,CAACW,WAAW,EAAE;IACvB,MAAMC,IAAI,GAAGvB,UAAU,CAACc,SAAS,CAAC;IAClCS,IAAI,CAACC,MAAM,CAACN,KAAK,CAAC;EACpB,CAAC,MAAMjB,WAAW,CAACa,SAAS,EAAEI,KAAK,CAAC;AACtC","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/client/index.tsx"],"sourcesContent":["// Initialization of client-side code.\n/* global document */\n\nimport type { ComponentType } from 'react';\nimport { createRoot, hydrateRoot } from 'react-dom/client';\nimport { BrowserRouter } from 'react-router';\n\nimport { GlobalStateProvider } from '@dr.pogodin/react-global-state';\nimport { HelmetProvider } from '@dr.pogodin/react-helmet';\n\nimport { setClientChunkGroups } from 'utils/splitComponent';\n\nimport getInj from './getInj';\n\ntype OptionsT = {\n dontHydrate?: boolean;\n initialState?: unknown;\n};\n\n/**\n * Prepares and launches the app at client side.\n * @param Application Root application component\n * @param [options={}] Optional. Additional settings.\n */\nexport async function launchClient(\n Application: ComponentType,\n options: OptionsT = {},\n): Promise<void> {\n const inj = await getInj();\n\n setClientChunkGroups(inj.CHUNK_GROUPS ?? {});\n\n const container = document.getElementById('react-view');\n if (!container) throw Error('Failed to find container for React app');\n const scene = (\n <GlobalStateProvider initialState={inj.ISTATE ?? options.initialState}>\n <BrowserRouter>\n <HelmetProvider>\n <Application />\n </HelmetProvider>\n </BrowserRouter>\n </GlobalStateProvider>\n );\n\n if (options.dontHydrate) {\n const root = createRoot(container);\n root.render(scene);\n } else hydrateRoot(container, scene);\n}\n"],"mappings":"AAAA;AACA,qBAGA,SAAS,UAAU,EAAE,WAAW,QAAQ,kBAAkB;AAC1D,SAAS,aAAa,QAAQ,cAAc;AAE5C,SAAS,mBAAmB,QAAQ,gCAAgC;AACpE,SAAS,cAAc,QAAQ,0BAA0B;AAAC,SAEjD,oBAAoB;AAAA,OAEtB,MAAM;AAAA,gDAOb;AACA;AACA;AACA;AACA;AACA,OAAO,eAAe,YAAY,CAChC,WAA0B,EAC1B,OAAiB,GAAG,CAAC,CAAC,EACP;EACf,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,CAAC;EAE1B,oBAAoB,CAAC,GAAG,CAAC,YAAY,IAAI,CAAC,CAAC,CAAC;EAE5C,MAAM,SAAS,GAAG,QAAQ,CAAC,cAAc,CAAC,YAAY,CAAC;EACvD,IAAI,CAAC,SAAS,EAAE,MAAM,KAAK,CAAC,wCAAwC,CAAC;EACrE,MAAM,KAAK,gBACT,KAAC,mBAAmB;IAAC,YAAY,EAAE,GAAG,CAAC,MAAM,IAAI,OAAO,CAAC,YAAa;IAAA,uBACpE,KAAC,aAAa;MAAA,uBACZ,KAAC,cAAc;QAAA,uBACb,KAAC,WAAW,IAAE;MAAC,CACD;IAAC,CACJ;EAAC,CACG,CACtB;EAED,IAAI,OAAO,CAAC,WAAW,EAAE;IACvB,MAAM,IAAI,GAAG,UAAU,CAAC,SAAS,CAAC;IAClC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;EACpB,CAAC,MAAM,WAAW,CAAC,SAAS,EAAE,KAAK,CAAC;AACtC","ignoreList":[]}
@@ -1,8 +1,6 @@
1
1
  /**
2
2
  * Initialization of client-side environment.
3
- */
4
- /* global window */
5
- import { getBuildInfo } from "../shared/utils/isomorphy/buildInfo.js";
3
+ */ /* global window */import { getBuildInfo } from "../shared/utils/isomorphy/buildInfo.js";
6
4
  const buildInfo = getBuildInfo(); // TODO: Should be moved into buildInfo module?
7
5
  if (process.env.NODE_ENV !== "production") {
8
6
  // eslint-disable-next-line no-console
@@ -1 +1 @@
1
- {"version":3,"file":"init.js","names":["getBuildInfo","buildInfo","process","env","NODE_ENV","console","warn","window","__DEV_BUILD_INFO__","BUILD_INFO","useServiceWorker","navigator","addEventListener","reg","serviceWorker","register","log","err"],"sources":["../../../src/client/init.ts"],"sourcesContent":["/**\n * Initialization of client-side environment.\n */\n\n/* global window */\n\nimport { type BuildInfoT, getBuildInfo } from 'utils/isomorphy/buildInfo';\n\nconst buildInfo = getBuildInfo();\n\n// TODO: Should be moved into buildInfo module?\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/consistent-type-definitions\n interface Window {\n __DEV_BUILD_INFO__: BuildInfoT | undefined;\n }\n}\n\ndeclare const BUILD_INFO: BuildInfoT | undefined;\n\nif (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.warn('Dev mode: \"BUILD_INFO\" attached to the global \"window\"');\n\n // eslint-disable-next-line no-underscore-dangle\n window.__DEV_BUILD_INFO__ = BUILD_INFO;\n}\n\n/* TODO: A proper logger should be moved to `@dr.pogodin/react-utils`. */\nconst { useServiceWorker } = buildInfo;\nif (useServiceWorker) {\n const { navigator } = window;\n if ('serviceWorker' in navigator) {\n window.addEventListener('load', () => {\n void (async () => {\n try {\n // Note: no matter the \"publicPath\", we want to serve the service worker\n // from the web app root, to allow it control any and all pages of the\n // web app (otherwise, it will be restricted to the scope of its path).\n // The server takes it into account.\n const reg = await navigator\n .serviceWorker.register('/__service-worker.js');\n // eslint-disable-next-line no-console\n console.log('SW registered:', reg);\n } catch (err) {\n // eslint-disable-next-line no-console\n console.log('SW registration failed:', err);\n }\n })();\n });\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AAEA;AAAA,SAE0BA,YAAY;AAEtC,MAAMC,SAAS,GAAGD,YAAY,CAAC,CAAC,CAEhC;AAUA,IAAIE,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;EACzC;EACAC,OAAO,CAACC,IAAI,CAAC,4DAAwD,CAAC,CAEtE;EACAC,MAAM,CAACC,kBAAkB,GAAGC,UAAU;AACxC,CAEA;AACA,MAAM;EAAEC;AAAiB,CAAC,GAAGT,SAAS;AACtC,IAAIS,gBAAgB,EAAE;EACpB,MAAM;IAAEC;EAAU,CAAC,GAAGJ,MAAM;EAC5B,IAAI,eAAe,IAAII,SAAS,EAAE;IAChCJ,MAAM,CAACK,gBAAgB,CAAC,MAAM,EAAE,MAAM;MACpC,KAAK,CAAC,YAAY;QAChB,IAAI;UACF;UACA;UACA;UACA;UACA,MAAMC,GAAG,GAAG,MAAMF,SAAS,CACxBG,aAAa,CAACC,QAAQ,CAAC,sBAAsB,CAAC,CACjD;UACAV,OAAO,CAACW,GAAG,CAAC,gBAAgB,EAAEH,GAAG,CAAC;QACpC,CAAE,QAAOI,GAAG,EAAE;UACZ;UACAZ,OAAO,CAACW,GAAG,CAAC,yBAAyB,EAAEC,GAAG,CAAC;QAC7C;MACF,CAAC,EAAE,CAAC;IACN,CAAC,CAAC;EACJ;AACF","ignoreList":[]}
1
+ {"version":3,"file":"init.js","names":[],"sources":["../../../src/client/init.ts"],"sourcesContent":["/**\n * Initialization of client-side environment.\n */\n\n/* global window */\n\nimport { type BuildInfoT, getBuildInfo } from 'utils/isomorphy/buildInfo';\n\nconst buildInfo = getBuildInfo();\n\n// TODO: Should be moved into buildInfo module?\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/consistent-type-definitions\n interface Window {\n __DEV_BUILD_INFO__: BuildInfoT | undefined;\n }\n}\n\ndeclare const BUILD_INFO: BuildInfoT | undefined;\n\nif (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.warn('Dev mode: \"BUILD_INFO\" attached to the global \"window\"');\n\n // eslint-disable-next-line no-underscore-dangle\n window.__DEV_BUILD_INFO__ = BUILD_INFO;\n}\n\n/* TODO: A proper logger should be moved to `@dr.pogodin/react-utils`. */\nconst { useServiceWorker } = buildInfo;\nif (useServiceWorker) {\n const { navigator } = window;\n if ('serviceWorker' in navigator) {\n window.addEventListener('load', () => {\n void (async () => {\n try {\n // Note: no matter the \"publicPath\", we want to serve the service worker\n // from the web app root, to allow it control any and all pages of the\n // web app (otherwise, it will be restricted to the scope of its path).\n // The server takes it into account.\n const reg = await navigator\n .serviceWorker.register('/__service-worker.js');\n // eslint-disable-next-line no-console\n console.log('SW registered:', reg);\n } catch (err) {\n // eslint-disable-next-line no-console\n console.log('SW registration failed:', err);\n }\n })();\n });\n }\n}\n"],"mappings":"AAAA;AACA;AACA,GAFA,CAIA,4BAE0B,YAAY;AAEtC,MAAM,SAAS,GAAG,YAAY,CAAC,CAAC,CAEhC;AAUA,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;EACzC;EACA,OAAO,CAAC,IAAI,CAAC,4DAAwD,CAAC,CAEtE;EACA,MAAM,CAAC,kBAAkB,GAAG,UAAU;AACxC,CAEA;AACA,MAAM;EAAE;AAAiB,CAAC,GAAG,SAAS;AACtC,IAAI,gBAAgB,EAAE;EACpB,MAAM;IAAE;EAAU,CAAC,GAAG,MAAM;EAC5B,IAAI,eAAe,IAAI,SAAS,EAAE;IAChC,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM;MACpC,KAAK,CAAC,YAAY;QAChB,IAAI;UACF;UACA;UACA;UACA;UACA,MAAM,GAAG,GAAG,MAAM,SAAS,CACxB,aAAa,CAAC,QAAQ,CAAC,sBAAsB,CAAC,CACjD;UACA,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,GAAG,CAAC;QACpC,CAAE,QAAO,GAAG,EAAE;UACZ;UACA,OAAO,CAAC,GAAG,CAAC,yBAAyB,EAAE,GAAG,CAAC;QAC7C;MACF,CAAC,EAAE,CAAC;IACN,CAAC,CAAC;EACJ;AACF","ignoreList":[]}
@@ -1,10 +1,3 @@
1
- // TODO: For now I commented out this safeguard check, as I am not sure how
2
- // to easily make it work: it should not be triggered in HMR mode, but if I
3
- // add the code relying on import.meta, it fails in Jest environment, because
4
- // Jest does not support ES modules yet, and import.meta is not support in
5
- // CommonJS modules, and the "babel-plugin-transform-import-meta" plugin
6
- // we use to workaround this issue for import.meta.dirname, etc. does not
7
- // transform import.meta.webpackHot
8
1
  // It is a safeguard against multiple instances / versions of the library
9
2
  // being loaded into environment by mistake (e.g. because of different
10
3
  // packages pinning down different exact versions of the lib, thus preventing
@@ -12,22 +5,12 @@
12
5
  // if (global.REACT_UTILS_LIBRARY_LOADED) {
13
6
  // throw Error('React utils library is already loaded');
14
7
  // } else global.REACT_UTILS_LIBRARY_LOADED = true;
15
- /*
16
- declare global {
17
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions
18
- interface ImportMeta {
19
- webpackHot?: {
20
- dispose(cb: () => void): void;
21
- };
22
- }
23
- }
24
-
25
8
  if (import.meta.webpackHot) {
26
9
  import.meta.webpackHot.dispose(() => {
27
10
  delete global.REACT_UTILS_LIBRARY_LOADED;
28
11
  });
29
12
  }
30
- */export { GlobalStateProvider, newAsyncDataEnvelope, useAsyncCollection, useAsyncData, useGlobalState, useGlobalStateObject, withGlobalStateType } from "@dr.pogodin/react-global-state";
13
+ export { GlobalStateProvider, newAsyncDataEnvelope, useAsyncCollection, useAsyncData, useGlobalState, useGlobalStateObject, withGlobalStateType } from "@dr.pogodin/react-global-state";
31
14
  export * from "./shared/components/index.js";
32
15
  export { Barrier, Cached, Emitter, Semaphore, THEME_COMPOSE, THEME_PRIORITY, ThemeProvider, assertEmptyObject, getConfig, setClientChunkGroups, splitComponent, time, useSsrContext, useTheme, webpack, withRetries } from "./shared/utils/index.js";
33
16
  export * from "./shared/utils/isomorphy/index.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["GlobalStateProvider","newAsyncDataEnvelope","useAsyncCollection","useAsyncData","useGlobalState","useGlobalStateObject","withGlobalStateType","Barrier","Cached","Emitter","Semaphore","THEME_COMPOSE","THEME_PRIORITY","ThemeProvider","assertEmptyObject","getConfig","setClientChunkGroups","splitComponent","time","useSsrContext","useTheme","webpack","withRetries"],"sources":["../../src/index.ts"],"sourcesContent":["// TODO: For now I commented out this safeguard check, as I am not sure how\n// to easily make it work: it should not be triggered in HMR mode, but if I\n// add the code relying on import.meta, it fails in Jest environment, because\n// Jest does not support ES modules yet, and import.meta is not support in\n// CommonJS modules, and the \"babel-plugin-transform-import-meta\" plugin\n// we use to workaround this issue for import.meta.dirname, etc. does not\n// transform import.meta.webpackHot\n\n// It is a safeguard against multiple instances / versions of the library\n// being loaded into environment by mistake (e.g. because of different\n// packages pinning down different exact versions of the lib, thus preventing\n// a proper dedupe and using a single common library version).\n// if (global.REACT_UTILS_LIBRARY_LOADED) {\n// throw Error('React utils library is already loaded');\n// } else global.REACT_UTILS_LIBRARY_LOADED = true;\n\n/*\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/consistent-type-definitions\n interface ImportMeta {\n webpackHot?: {\n dispose(cb: () => void): void;\n };\n }\n}\n\nif (import.meta.webpackHot) {\n import.meta.webpackHot.dispose(() => {\n delete global.REACT_UTILS_LIBRARY_LOADED;\n });\n}\n*/\n\nexport {\n type AsyncCollectionLoaderT,\n type AsyncCollectionT,\n type AsyncDataEnvelopeT,\n type AsyncDataLoaderT,\n type ForceT,\n GlobalStateProvider,\n type UseAsyncDataOptionsT,\n type UseAsyncDataResT,\n type UseGlobalStateResT,\n type ValueOrInitializerT,\n newAsyncDataEnvelope,\n useAsyncCollection,\n useAsyncData,\n useGlobalState,\n useGlobalStateObject,\n withGlobalStateType,\n} from '@dr.pogodin/react-global-state';\n\nexport * from 'components';\n\nexport {\n type BeforeRenderResT,\n type BeforeRenderT,\n type ConfigT,\n type ServerSsrContext,\n type ServerT,\n} from './server';\n\nexport {\n Barrier,\n Cached,\n Emitter,\n type Listener,\n type ObjectKey,\n Semaphore,\n THEME_COMPOSE,\n THEME_PRIORITY,\n type Theme,\n ThemeProvider,\n assertEmptyObject,\n getConfig,\n setClientChunkGroups,\n splitComponent,\n time,\n useSsrContext,\n useTheme,\n webpack,\n withRetries,\n} from 'utils';\n\nexport * from 'utils/isomorphy';\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAEA,SAMEA,mBAAmB,EAKnBC,oBAAoB,EACpBC,kBAAkB,EAClBC,YAAY,EACZC,cAAc,EACdC,oBAAoB,EACpBC,mBAAmB,QACd,gCAAgC;AAEvC;AAAA,SAWEC,OAAO,EACPC,MAAM,EACNC,OAAO,EAGPC,SAAS,EACTC,aAAa,EACbC,cAAc,EAEdC,aAAa,EACbC,iBAAiB,EACjBC,SAAS,EACTC,oBAAoB,EACpBC,cAAc,EACdC,IAAI,EACJC,aAAa,EACbC,QAAQ,EACRC,OAAO,EACPC,WAAW;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["// It is a safeguard against multiple instances / versions of the library\n// being loaded into environment by mistake (e.g. because of different\n// packages pinning down different exact versions of the lib, thus preventing\n// a proper dedupe and using a single common library version).\n// if (global.REACT_UTILS_LIBRARY_LOADED) {\n// throw Error('React utils library is already loaded');\n// } else global.REACT_UTILS_LIBRARY_LOADED = true;\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/consistent-type-definitions\n interface ImportMeta {\n webpackHot?: {\n dispose(cb: () => void): void;\n };\n }\n}\n\nif (import.meta.webpackHot) {\n import.meta.webpackHot.dispose(() => {\n delete global.REACT_UTILS_LIBRARY_LOADED;\n });\n}\n\nexport {\n type AsyncCollectionLoaderT,\n type AsyncCollectionT,\n type AsyncDataEnvelopeT,\n type AsyncDataLoaderT,\n type ForceT,\n GlobalStateProvider,\n type UseAsyncDataOptionsT,\n type UseAsyncDataResT,\n type UseGlobalStateResT,\n type ValueOrInitializerT,\n newAsyncDataEnvelope,\n useAsyncCollection,\n useAsyncData,\n useGlobalState,\n useGlobalStateObject,\n withGlobalStateType,\n} from '@dr.pogodin/react-global-state';\n\nexport * from 'components';\n\nexport {\n type BeforeRenderResT,\n type BeforeRenderT,\n type ConfigT,\n type ServerSsrContext,\n type ServerT,\n} from './server';\n\nexport {\n Barrier,\n Cached,\n Emitter,\n type Listener,\n type ObjectKey,\n Semaphore,\n THEME_COMPOSE,\n THEME_PRIORITY,\n type Theme,\n ThemeProvider,\n assertEmptyObject,\n getConfig,\n setClientChunkGroups,\n splitComponent,\n time,\n useSsrContext,\n useTheme,\n webpack,\n withRetries,\n} from 'utils';\n\nexport * from 'utils/isomorphy';\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAWA,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE;EAC1B,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM;IACnC,OAAO,MAAM,CAAC,0BAA0B;EAC1C,CAAC,CAAC;AACJ;AAEA,SAME,mBAAmB,EAKnB,oBAAoB,EACpB,kBAAkB,EAClB,YAAY,EACZ,cAAc,EACd,oBAAoB,EACpB,mBAAmB,QACd,gCAAgC;AAAC;AAAA,SAatC,OAAO,EACP,MAAM,EACN,OAAO,EAGP,SAAS,EACT,aAAa,EACb,cAAc,EAEd,aAAa,EACb,iBAAiB,EACjB,SAAS,EACT,oBAAoB,EACpB,cAAc,EACd,IAAI,EACJ,aAAa,EACb,QAAQ,EACR,OAAO,EACP,WAAW;AAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"Cache.js","names":["Cache","items","size","constructor","maxSize","get","key","maxage","Number","MAX_VALUE","item","Date","now","timestamp","data","add","cached","entries","Object","sort","a","b","entry","itemKey"],"sources":["../../../src/server/Cache.ts"],"sourcesContent":["type CachedItemT<DatumT> = {\n data: DatumT;\n size: number;\n timestamp: number;\n};\n\n/**\n * Implements the static cache.\n */\nexport default class Cache<DatumT> {\n private items: Record<string, CachedItemT<DatumT>> = {};\n\n private size = 0;\n\n constructor(private maxSize: number) { }\n\n /**\n * Cache lookup.\n * @param key Item key to look for.\n * @param [maxage=Number.MAX_VALUE] Optional. The maximum age of\n * cached item to serve. Default to infinite.\n * @returns Cached item, or null if the item is absent in cache,\n * or stale.\n */\n get({\n key,\n maxage = Number.MAX_VALUE,\n }: {\n key: string;\n maxage?: number;\n }): DatumT | null {\n const item = this.items[key];\n return item && Date.now() - item.timestamp < maxage ? item.data : null;\n }\n\n /**\n * Adds item to cache.\n * @param data Item to add.\n * @param key Key to store the item at.\n * @param size Byte size of the item.\n */\n add(data: DatumT, key: string, size: number): void {\n const cached = this.items[key];\n if (cached) this.size -= cached.size;\n\n this.items[key] = { data, size, timestamp: Date.now() };\n this.size += size;\n\n if (this.size > this.maxSize) {\n const entries = Object.entries(this.items);\n entries.sort((a, b) => a[1].timestamp - b[1].timestamp);\n\n for (const entry of entries) {\n const [itemKey, item] = entry;\n delete this.items[itemKey];\n this.size -= item.size;\n if (this.size < this.maxSize / 2) break;\n }\n }\n }\n}\n"],"mappings":"AAMA;AACA;AACA,GACA,eAAe,MAAMA,KAAc;EACzBC,KAAK,GAAwC,CAAC,CAAC;EAE/CC,IAAI,GAAG,CAAC;EAEhBC,WAAWA,CAASC,OAAe,EAAE;IAAA,KAAjBA,OAAe,GAAfA,OAAmB;EAAA,CAEvC;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,GAAGA,CAAC;IACFC,GAAG;IACHC,MAAM,GAAGC,MAAM,CAACC;EAIlB,CAAC,EAAiB;IAChB,MAAMC,IAAI,GAAG,IAAI,CAACT,KAAK,CAACK,GAAG,CAAC;IAC5B,OAAOI,IAAI,IAAIC,IAAI,CAACC,GAAG,CAAC,CAAC,GAAGF,IAAI,CAACG,SAAS,GAAGN,MAAM,GAAGG,IAAI,CAACI,IAAI,GAAG,IAAI;EACxE,CAEA;AACF;AACA;AACA;AACA;AACA;EACEC,GAAGA,CAACD,IAAY,EAAER,GAAW,EAAEJ,IAAY,EAAQ;IACjD,MAAMc,MAAM,GAAG,IAAI,CAACf,KAAK,CAACK,GAAG,CAAC;IAC9B,IAAIU,MAAM,EAAE,IAAI,CAACd,IAAI,IAAIc,MAAM,CAACd,IAAI;IAEpC,IAAI,CAACD,KAAK,CAACK,GAAG,CAAC,GAAG;MAAEQ,IAAI;MAAEZ,IAAI;MAAEW,SAAS,EAAEF,IAAI,CAACC,GAAG,CAAC;IAAE,CAAC;IACvD,IAAI,CAACV,IAAI,IAAIA,IAAI;IAEjB,IAAI,IAAI,CAACA,IAAI,GAAG,IAAI,CAACE,OAAO,EAAE;MAC5B,MAAMa,OAAO,GAAGC,MAAM,CAACD,OAAO,CAAC,IAAI,CAAChB,KAAK,CAAC;MAC1CgB,OAAO,CAACE,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAAC,CAAC,CAAC,CAACP,SAAS,GAAGQ,CAAC,CAAC,CAAC,CAAC,CAACR,SAAS,CAAC;MAEvD,KAAK,MAAMS,KAAK,IAAIL,OAAO,EAAE;QAC3B,MAAM,CAACM,OAAO,EAAEb,IAAI,CAAC,GAAGY,KAAK;QAC7B,OAAO,IAAI,CAACrB,KAAK,CAACsB,OAAO,CAAC;QAC1B,IAAI,CAACrB,IAAI,IAAIQ,IAAI,CAACR,IAAI;QACtB,IAAI,IAAI,CAACA,IAAI,GAAG,IAAI,CAACE,OAAO,GAAG,CAAC,EAAE;MACpC;IACF;EACF;AACF","ignoreList":[]}
1
+ {"version":3,"file":"Cache.js","names":[],"sources":["../../../src/server/Cache.ts"],"sourcesContent":["type CachedItemT<DatumT> = {\n data: DatumT;\n size: number;\n timestamp: number;\n};\n\n/**\n * Implements the static cache.\n */\nexport default class Cache<DatumT> {\n private items: Record<string, CachedItemT<DatumT>> = {};\n\n private size = 0;\n\n constructor(private maxSize: number) { }\n\n /**\n * Cache lookup.\n * @param key Item key to look for.\n * @param [maxage=Number.MAX_VALUE] Optional. The maximum age of\n * cached item to serve. Default to infinite.\n * @returns Cached item, or null if the item is absent in cache,\n * or stale.\n */\n get({\n key,\n maxage = Number.MAX_VALUE,\n }: {\n key: string;\n maxage?: number;\n }): DatumT | null {\n const item = this.items[key];\n return item && Date.now() - item.timestamp < maxage ? item.data : null;\n }\n\n /**\n * Adds item to cache.\n * @param data Item to add.\n * @param key Key to store the item at.\n * @param size Byte size of the item.\n */\n add(data: DatumT, key: string, size: number): void {\n const cached = this.items[key];\n if (cached) this.size -= cached.size;\n\n this.items[key] = { data, size, timestamp: Date.now() };\n this.size += size;\n\n if (this.size > this.maxSize) {\n const entries = Object.entries(this.items);\n entries.sort((a, b) => a[1].timestamp - b[1].timestamp);\n\n for (const entry of entries) {\n const [itemKey, item] = entry;\n delete this.items[itemKey];\n this.size -= item.size;\n if (this.size < this.maxSize / 2) break;\n }\n }\n }\n}\n"],"mappings":"AAMA;AACA;AACA,GACA,eAAe,MAAM,KAAc;EACzB,KAAK,GAAwC,CAAC,CAAC;EAE/C,IAAI,GAAG,CAAC;EAEhB,WAAW,CAAS,OAAe,EAAE;IAAA,KAAjB,OAAe,GAAf,OAAmB;EAAA,CAEvC;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACE,GAAG,CAAC;IACF,GAAG;IACH,MAAM,GAAG,MAAM,CAAC;EAIlB,CAAC,EAAiB;IAChB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC;IAC5B,OAAO,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,SAAS,GAAG,MAAM,GAAG,IAAI,CAAC,IAAI,GAAG,IAAI;EACxE,CAEA;AACF;AACA;AACA;AACA;AACA;EACE,GAAG,CAAC,IAAY,EAAE,GAAW,EAAE,IAAY,EAAQ;IACjD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC;IAC9B,IAAI,MAAM,EAAE,IAAI,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI;IAEpC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG;MAAE,IAAI;MAAE,IAAI;MAAE,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC;IAAE,CAAC;IACvD,IAAI,CAAC,IAAI,IAAI,IAAI;IAEjB,IAAI,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE;MAC5B,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC;MAC1C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;MAEvD,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE;QAC3B,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,KAAK;QAC7B,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;QAC1B,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI;QACtB,IAAI,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,GAAG,CAAC,EAAE;MACpC;IACF;EACF;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["http","https","cloneDeep","defaults","SCRIPT_LOCATIONS","newDefaultLogger","serverFactory","getDefaultCspSettings","normalizePort","value","port","parseInt","Number","isFinite","launchServer","webpackConfig","options","ops","process","env","PORT","httpsRedirect","logger","defaultLogLevel","defaultLoggerLogLevel","expressServer","httpServer","createServer","cert","key","on","error","syscall","bind","code","exit","undefined","addr","address","info","NODE_ENV","listen"],"sources":["../../../src/server/index.ts"],"sourcesContent":["// eslint-disable-next-line import/no-unassigned-import\nimport 'source-map-support/register.js';\n\nimport http from 'node:http';\nimport https from 'node:https';\n\nimport { cloneDeep, defaults } from 'lodash-es';\n\n// Polyfill required by ReactJS.\n// TODO: Double-check, if it is still required by React v19?\n// eslint-disable-next-line import/no-unassigned-import\nimport 'raf/polyfill.js';\n\nimport type { Configuration } from 'webpack';\n\nimport { SCRIPT_LOCATIONS, newDefaultLogger } from './renderer';\n\nimport serverFactory, {\n type OptionsT as ServerOptionsT,\n type ServerT,\n getDefaultCspSettings,\n} from './server';\n\nexport * from './utils';\n\nexport type {\n BeforeRenderResT,\n BeforeRenderT,\n ConfigT,\n ServerSsrContext,\n} from './renderer';\n\nexport {\n SCRIPT_LOCATIONS,\n type ServerT,\n getDefaultCspSettings,\n};\n\n/**\n * Normalizes a port into a number, string, or false.\n * TODO: Drop this function?\n * @param value Port name or number.\n * @return Port number (Number), name (String).\n */\nfunction normalizePort(value: number | string) {\n const port = typeof value === 'string' ? parseInt(value) : value;\n if (Number.isFinite(port)) return port; /* port number */\n return value; /* named pipe */\n}\n\ntype OptionsT = ServerOptionsT & {\n https?: {\n cert: string;\n key: string;\n };\n\n // TODO: Should we limit it to number | string, and throw if it is different value?\n port?: false | number | string;\n};\n\n/**\n * Creates and launches web-server for ReactJS application. Allows zero\n * or detailed configuration, supports server-side rendering,\n * and development tools, including Hot Module Reloading (HMR).\n *\n * NOTE: Many of options defined below are passed down to the server and\n * renderer factories, and their declared default values are set in those\n * factories, rather than here.\n *\n * @param {object} webpackConfig Webpack configuration used to build\n * the frontend bundle. In production mode the server will read out of it\n * `context`, `publicPath`, and a few other parameters, necessary to locate\n * and serve the app bundle. In development mode the server will use entire\n * provided config to build the app bundle in memory, and further watch and\n * update it via HMR.\n * @param {object} [options] Additional parameters.\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 {function} [options.beforeExpressJsError] Asynchronous callback\n * (`(server) => Promise<boolean>`) to be executed just before the default error\n * handler is added to ExpressJS server. If the callback is provided and its\n * result resolves to a truthy value, `react-utils` won't attach the default\n * error handler.\n * @param {function} [options.beforeExpressJsSetup] Asynchronous callback\n * (`(server) => Promise) to be executed right after ExpressJS server creation,\n * before any configuration is performed.\n * @param {BeforeRenderHook} [options.beforeRender] The hook to run just before\n * the server-side rendering. For each incoming request, it will be executed\n * just before the HTML markup is generated at the server. It allows to load\n * and provide the data necessary for server-side rendering, and also to inject\n * additional configuration and scripts into the generated HTML code.\n * @param {boolean} [options.noCsp] Set `true` to disable\n * Content-Security-Policy (CSP) headers altogether.\n * @param {function} [options.cspSettingsHook] A hook allowing\n * to customize [CSP](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP)\n * settings for [helmet](https://github.com/helmetjs/helmet)'s\n * `contentSecurityPolicy` middleware on per-request basis.\n *\n * If provided it should be a with signature: \\\n * `(defaultSettings: object, req: object)` &rArr; `object` \\\n * which gets the default settings (also used without the hook),\n * and the incoming request object. The hook response will be passed\n * as options to the helmet `contentSecurityPolicy` middleware.\n *\n * Currently, the default settings is the following object in production\n * environment:\n * ```js\n * {\n * directives: {\n * defaultSrc: [\"'self'\"],\n * baseUri: [\"'self'\"],\n * blockAllMixedContent: [],\n * fontSrc: [\"'self'\", 'https:', 'data:'],\n * frameAncestors: [\"'self'\"],\n * frameSrc: [\"'self'\", 'https://*.youtube.com'],\n * imgSrc: [\"'self'\", 'data:'],\n * objectSrc: [\"'none'\"],\n * scriptSrc: [\"'self'\", \"'unsafe-eval'\", `'nonce-UNIQUE_NONCE_VALUE'`],\n * scriptSrcAttr: [\"'none'\"],\n * styleSrc: [\"'self'\", 'https:', \"'unsafe-inline'\"],\n * upgradeInsecureRequests: [] // Removed in dev mode.\n * }\n * }\n * ```\n * It matches the default value used by Helmet with a few updates:\n * - YouTube host is whitelisted in the `frameSrc` directive to ensure\n * the {@link YouTubeVideo} component works.\n * - An unique per-request nonce is added to `scriptSrc` directive to\n * whitelist auxiliary scripts injected by react-utils. The actual nonce\n * value can be fetched by host code via `.nonce` field of `req` argument\n * of `.beforeRender` hook.\n * - `upgradeInsecureRequests` directive is removed in development mode,\n * to simplify local testing with http requests.\n * @param {string} [options.defaultLoggerLogLevel='info'] Log level for\n * the default logger, which is created if no `logger` option provided.\n * @param {boolean} [options.devMode] Pass in `true` to start the server in\n * development mode.\n * @param {string} [options.favicon] Path to the favicon to use by the server.\n * By default no favicon is used.\n * @param {object} [options.https] If provided, HTTPS server will be started,\n * instead of HTTP otherwise. The object should provide SSL certificate and key\n * via two string fields: `cert`, and `key`.\n * @param {string} [options.https.cert] SSL Certificate.\n * @param {string} [options.https.key] SSL key.\n * @param {boolean} [options.httpsRedirect=true] Pass in `true` to enable\n * automatic redirection of all incoming HTTP requests to HTTPS.\n *\n * To smoothly use it at `localhost` you need to run the server in HTTPS mode,\n * and also properly create and install a self-signed SSL sertificate on your\n * system. This article is helpful:\n * [How to get HTTPS working on your local development environment in 5 minutes](https://medium.freecodecamp.org/how-to-get-https-working-on-your-local-development-environment-in-5-minutes-7af615770eec)\n * @param {Logger} [options.logger] The logger to use at server side.\n * By default [`winston`](https://www.npmjs.com/package/winston) logger\n * with console transport is used. The logger you provide, or the default\n * `winston` logger otherwise, will be attached to the created ExpressJS server\n * object.\n * @param {function} [options.onExpressJsSetup] An async callback\n * (`(server) => Promise`) to be triggered when most of the server\n * configuration is completed, just before the server-side renderer,\n * and the default error handler are attached. You can use it to mount\n * custom API routes. The server-side logger can be accessed as `server.logger`.\n * @param {number|string} [options.port=3000] The port to start the server on.\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 * @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 * @return Resolves to an object with created Express and HTTP servers.\n */\nexport async function launchServer(\n webpackConfig: Configuration,\n options: OptionsT = {},\n): Promise<{\n expressServer: ServerT;\n httpServer: http.Server;\n}> {\n /* Options normalization. */\n const ops = cloneDeep(options);\n\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n ops.port = normalizePort(ops.port || process.env.PORT || 3000);\n defaults(ops, { httpsRedirect: true });\n\n // TODO: Need a separate type for normalized options, which guarantees\n // the logger is set!\n ops.logger ??= newDefaultLogger({\n defaultLogLevel: ops.defaultLoggerLogLevel,\n });\n\n /* Creates servers, resolves and sets the port. */\n const expressServer = await serverFactory(webpackConfig, ops);\n\n let httpServer: http.Server;\n if (ops.https) {\n httpServer = https.createServer({\n cert: ops.https.cert,\n key: ops.https.key,\n }, expressServer as unknown as () => void);\n } else httpServer = http.createServer(expressServer as unknown as () => void);\n\n /* Sets error handler for HTTP(S) server. */\n httpServer.on('error', (error: Error) => {\n if ((error as { syscall?: string }).syscall !== 'listen') throw error;\n const bind = typeof ops.port === 'string' ? `Pipe ${ops.port}` : `Port ${ops.port}`;\n\n /* Human-readable message for some specific listen errors. */\n switch ((error as { code?: string }).code) {\n case 'EACCES':\n ops.logger!.error(`${bind} requires elevated privileges`);\n return process.exit(1);\n case 'EADDRINUSE':\n ops.logger!.error(`${bind} is already in use`);\n return process.exit(1);\n case undefined:\n default:\n throw error;\n }\n });\n\n /* Listening event handler for HTTP(S) server. */\n httpServer.on('listening', () => {\n const addr = httpServer.address()!;\n const bind = typeof addr === 'string' ? `pipe ${addr}` : `port ${addr.port}`;\n ops.logger!.info(`Server listening on ${bind} in ${\n process.env.NODE_ENV} mode`);\n });\n\n httpServer.listen(ops.port);\n\n return {\n expressServer,\n httpServer,\n };\n}\n"],"mappings":"AAAA;AACA,OAAO,gCAAgC;AAEvC,OAAOA,IAAI,MAAM,WAAW;AAC5B,OAAOC,KAAK,MAAM,YAAY;AAE9B,SAASC,SAAS,EAAEC,QAAQ,QAAQ,WAAW,CAE/C;AACA;AACA;AACA,OAAO,iBAAiB;AAIxB,SAASC,gBAAgB,EAAEC,gBAAgB;AAAA,OAEpCC,aAAa,IAGlBC,qBAAqB;AAAA;AAYvB,SACEH,gBAAgB,EAEhBG,qBAAqB,GAGvB;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,aAAaA,CAACC,KAAsB,EAAE;EAC7C,MAAMC,IAAI,GAAG,OAAOD,KAAK,KAAK,QAAQ,GAAGE,QAAQ,CAACF,KAAK,CAAC,GAAGA,KAAK;EAChE,IAAIG,MAAM,CAACC,QAAQ,CAACH,IAAI,CAAC,EAAE,OAAOA,IAAI,CAAE;EACxC,OAAOD,KAAK,CAAE;AAChB,CAYA;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;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;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeK,YAAYA,CAChCC,aAA4B,EAC5BC,OAAiB,GAAG,CAAC,CAAC,EAIrB;EACD,4BACA,MAAMC,GAAG,GAAGf,SAAS,CAACc,OAAO,CAAC,CAE9B;EACAC,GAAG,CAACP,IAAI,GAAGF,aAAa,CAACS,GAAG,CAACP,IAAI,IAAIQ,OAAO,CAACC,GAAG,CAACC,IAAI,IAAI,IAAI,CAAC;EAC9DjB,QAAQ,CAACc,GAAG,EAAE;IAAEI,aAAa,EAAE;EAAK,CAAC,CAAC,CAEtC;EACA;EACAJ,GAAG,CAACK,MAAM,KAAKjB,gBAAgB,CAAC;IAC9BkB,eAAe,EAAEN,GAAG,CAACO;EACvB,CAAC,CAAC,CAEF;EACA,MAAMC,aAAa,GAAG,MAAMnB,aAAa,CAACS,aAAa,EAAEE,GAAG,CAAC;EAE7D,IAAIS,UAAuB;EAC3B,IAAIT,GAAG,CAAChB,KAAK,EAAE;IACbyB,UAAU,GAAGzB,KAAK,CAAC0B,YAAY,CAAC;MAC9BC,IAAI,EAAEX,GAAG,CAAChB,KAAK,CAAC2B,IAAI;MACpBC,GAAG,EAAEZ,GAAG,CAAChB,KAAK,CAAC4B;IACjB,CAAC,EAAEJ,aAAsC,CAAC;EAC5C,CAAC,MAAMC,UAAU,GAAG1B,IAAI,CAAC2B,YAAY,CAACF,aAAsC,CAAC,CAE7E;EACAC,UAAU,CAACI,EAAE,CAAC,OAAO,EAAGC,KAAY,IAAK;IACvC,IAAKA,KAAK,CAA0BC,OAAO,KAAK,QAAQ,EAAE,MAAMD,KAAK;IACrE,MAAME,IAAI,GAAG,OAAOhB,GAAG,CAACP,IAAI,KAAK,QAAQ,GAAG,QAAQO,GAAG,CAACP,IAAI,EAAE,GAAG,QAAQO,GAAG,CAACP,IAAI,EAAE,CAEnF;IACA,QAASqB,KAAK,CAAuBG,IAAI;MACvC,KAAK,QAAQ;QACXjB,GAAG,CAACK,MAAM,CAAES,KAAK,CAAC,GAAGE,IAAI,+BAA+B,CAAC;QACzD,OAAOf,OAAO,CAACiB,IAAI,CAAC,CAAC,CAAC;MACxB,KAAK,YAAY;QACflB,GAAG,CAACK,MAAM,CAAES,KAAK,CAAC,GAAGE,IAAI,oBAAoB,CAAC;QAC9C,OAAOf,OAAO,CAACiB,IAAI,CAAC,CAAC,CAAC;MACxB,KAAKC,SAAS;MACd;QACE,MAAML,KAAK;IACf;EACF,CAAC,CAAC,CAEF;EACAL,UAAU,CAACI,EAAE,CAAC,WAAW,EAAE,MAAM;IAC/B,MAAMO,IAAI,GAAGX,UAAU,CAACY,OAAO,CAAC,CAAE;IAClC,MAAML,IAAI,GAAG,OAAOI,IAAI,KAAK,QAAQ,GAAG,QAAQA,IAAI,EAAE,GAAG,QAAQA,IAAI,CAAC3B,IAAI,EAAE;IAC5EO,GAAG,CAACK,MAAM,CAAEiB,IAAI,CAAC,uBAAuBN,IAAI,OAC1Cf,OAAO,CAACC,GAAG,CAACqB,QAAQ,OAAO,CAAC;EAChC,CAAC,CAAC;EAEFd,UAAU,CAACe,MAAM,CAACxB,GAAG,CAACP,IAAI,CAAC;EAE3B,OAAO;IACLe,aAAa;IACbC;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/server/index.ts"],"sourcesContent":["// eslint-disable-next-line import/no-unassigned-import\nimport 'source-map-support/register.js';\n\nimport http from 'node:http';\nimport https from 'node:https';\n\nimport { cloneDeep, defaults } from 'lodash-es';\n\n// Polyfill required by ReactJS.\n// TODO: Double-check, if it is still required by React v19?\n// eslint-disable-next-line import/no-unassigned-import\nimport 'raf/polyfill.js';\n\nimport type { Configuration } from 'webpack';\n\nimport { SCRIPT_LOCATIONS, newDefaultLogger } from './renderer';\n\nimport serverFactory, {\n type OptionsT as ServerOptionsT,\n type ServerT,\n getDefaultCspSettings,\n} from './server';\n\nexport * from './utils';\n\nexport type {\n BeforeRenderResT,\n BeforeRenderT,\n ConfigT,\n ServerSsrContext,\n} from './renderer';\n\nexport {\n SCRIPT_LOCATIONS,\n type ServerT,\n getDefaultCspSettings,\n};\n\n/**\n * Normalizes a port into a number, string, or false.\n * TODO: Drop this function?\n * @param value Port name or number.\n * @return Port number (Number), name (String).\n */\nfunction normalizePort(value: number | string) {\n const port = typeof value === 'string' ? parseInt(value) : value;\n if (Number.isFinite(port)) return port; /* port number */\n return value; /* named pipe */\n}\n\ntype OptionsT = ServerOptionsT & {\n https?: {\n cert: string;\n key: string;\n };\n\n // TODO: Should we limit it to number | string, and throw if it is different value?\n port?: false | number | string;\n};\n\n/**\n * Creates and launches web-server for ReactJS application. Allows zero\n * or detailed configuration, supports server-side rendering,\n * and development tools, including Hot Module Reloading (HMR).\n *\n * NOTE: Many of options defined below are passed down to the server and\n * renderer factories, and their declared default values are set in those\n * factories, rather than here.\n *\n * @param {object} webpackConfig Webpack configuration used to build\n * the frontend bundle. In production mode the server will read out of it\n * `context`, `publicPath`, and a few other parameters, necessary to locate\n * and serve the app bundle. In development mode the server will use entire\n * provided config to build the app bundle in memory, and further watch and\n * update it via HMR.\n * @param {object} [options] Additional parameters.\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 {function} [options.beforeExpressJsError] Asynchronous callback\n * (`(server) => Promise<boolean>`) to be executed just before the default error\n * handler is added to ExpressJS server. If the callback is provided and its\n * result resolves to a truthy value, `react-utils` won't attach the default\n * error handler.\n * @param {function} [options.beforeExpressJsSetup] Asynchronous callback\n * (`(server) => Promise) to be executed right after ExpressJS server creation,\n * before any configuration is performed.\n * @param {BeforeRenderHook} [options.beforeRender] The hook to run just before\n * the server-side rendering. For each incoming request, it will be executed\n * just before the HTML markup is generated at the server. It allows to load\n * and provide the data necessary for server-side rendering, and also to inject\n * additional configuration and scripts into the generated HTML code.\n * @param {boolean} [options.noCsp] Set `true` to disable\n * Content-Security-Policy (CSP) headers altogether.\n * @param {function} [options.cspSettingsHook] A hook allowing\n * to customize [CSP](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP)\n * settings for [helmet](https://github.com/helmetjs/helmet)'s\n * `contentSecurityPolicy` middleware on per-request basis.\n *\n * If provided it should be a with signature: \\\n * `(defaultSettings: object, req: object)` &rArr; `object` \\\n * which gets the default settings (also used without the hook),\n * and the incoming request object. The hook response will be passed\n * as options to the helmet `contentSecurityPolicy` middleware.\n *\n * Currently, the default settings is the following object in production\n * environment:\n * ```js\n * {\n * directives: {\n * defaultSrc: [\"'self'\"],\n * baseUri: [\"'self'\"],\n * blockAllMixedContent: [],\n * fontSrc: [\"'self'\", 'https:', 'data:'],\n * frameAncestors: [\"'self'\"],\n * frameSrc: [\"'self'\", 'https://*.youtube.com'],\n * imgSrc: [\"'self'\", 'data:'],\n * objectSrc: [\"'none'\"],\n * scriptSrc: [\"'self'\", \"'unsafe-eval'\", `'nonce-UNIQUE_NONCE_VALUE'`],\n * scriptSrcAttr: [\"'none'\"],\n * styleSrc: [\"'self'\", 'https:', \"'unsafe-inline'\"],\n * upgradeInsecureRequests: [] // Removed in dev mode.\n * }\n * }\n * ```\n * It matches the default value used by Helmet with a few updates:\n * - YouTube host is whitelisted in the `frameSrc` directive to ensure\n * the {@link YouTubeVideo} component works.\n * - An unique per-request nonce is added to `scriptSrc` directive to\n * whitelist auxiliary scripts injected by react-utils. The actual nonce\n * value can be fetched by host code via `.nonce` field of `req` argument\n * of `.beforeRender` hook.\n * - `upgradeInsecureRequests` directive is removed in development mode,\n * to simplify local testing with http requests.\n * @param {string} [options.defaultLoggerLogLevel='info'] Log level for\n * the default logger, which is created if no `logger` option provided.\n * @param {boolean} [options.devMode] Pass in `true` to start the server in\n * development mode.\n * @param {string} [options.favicon] Path to the favicon to use by the server.\n * By default no favicon is used.\n * @param {object} [options.https] If provided, HTTPS server will be started,\n * instead of HTTP otherwise. The object should provide SSL certificate and key\n * via two string fields: `cert`, and `key`.\n * @param {string} [options.https.cert] SSL Certificate.\n * @param {string} [options.https.key] SSL key.\n * @param {boolean} [options.httpsRedirect=true] Pass in `true` to enable\n * automatic redirection of all incoming HTTP requests to HTTPS.\n *\n * To smoothly use it at `localhost` you need to run the server in HTTPS mode,\n * and also properly create and install a self-signed SSL sertificate on your\n * system. This article is helpful:\n * [How to get HTTPS working on your local development environment in 5 minutes](https://medium.freecodecamp.org/how-to-get-https-working-on-your-local-development-environment-in-5-minutes-7af615770eec)\n * @param {Logger} [options.logger] The logger to use at server side.\n * By default [`winston`](https://www.npmjs.com/package/winston) logger\n * with console transport is used. The logger you provide, or the default\n * `winston` logger otherwise, will be attached to the created ExpressJS server\n * object.\n * @param {function} [options.onExpressJsSetup] An async callback\n * (`(server) => Promise`) to be triggered when most of the server\n * configuration is completed, just before the server-side renderer,\n * and the default error handler are attached. You can use it to mount\n * custom API routes. The server-side logger can be accessed as `server.logger`.\n * @param {number|string} [options.port=3000] The port to start the server on.\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 * @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 * @return Resolves to an object with created Express and HTTP servers.\n */\nexport async function launchServer(\n webpackConfig: Configuration,\n options: OptionsT = {},\n): Promise<{\n expressServer: ServerT;\n httpServer: http.Server;\n}> {\n /* Options normalization. */\n const ops = cloneDeep(options);\n\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n ops.port = normalizePort(ops.port || process.env.PORT || 3000);\n defaults(ops, { httpsRedirect: true });\n\n // TODO: Need a separate type for normalized options, which guarantees\n // the logger is set!\n ops.logger ??= newDefaultLogger({\n defaultLogLevel: ops.defaultLoggerLogLevel,\n });\n\n /* Creates servers, resolves and sets the port. */\n const expressServer = await serverFactory(webpackConfig, ops);\n\n let httpServer: http.Server;\n if (ops.https) {\n httpServer = https.createServer({\n cert: ops.https.cert,\n key: ops.https.key,\n }, expressServer as unknown as () => void);\n } else httpServer = http.createServer(expressServer as unknown as () => void);\n\n /* Sets error handler for HTTP(S) server. */\n httpServer.on('error', (error: Error) => {\n if ((error as { syscall?: string }).syscall !== 'listen') throw error;\n const bind = typeof ops.port === 'string' ? `Pipe ${ops.port}` : `Port ${ops.port}`;\n\n /* Human-readable message for some specific listen errors. */\n switch ((error as { code?: string }).code) {\n case 'EACCES':\n ops.logger!.error(`${bind} requires elevated privileges`);\n return process.exit(1);\n case 'EADDRINUSE':\n ops.logger!.error(`${bind} is already in use`);\n return process.exit(1);\n case undefined:\n default:\n throw error;\n }\n });\n\n /* Listening event handler for HTTP(S) server. */\n httpServer.on('listening', () => {\n const addr = httpServer.address()!;\n const bind = typeof addr === 'string' ? `pipe ${addr}` : `port ${addr.port}`;\n ops.logger!.info(`Server listening on ${bind} in ${\n process.env.NODE_ENV} mode`);\n });\n\n httpServer.listen(ops.port);\n\n return {\n expressServer,\n httpServer,\n };\n}\n"],"mappings":"AAAA;AACA,OAAO,gCAAgC;AAEvC,OAAO,IAAI,MAAM,WAAW;AAC5B,OAAO,KAAK,MAAM,YAAY;AAE9B,SAAS,SAAS,EAAE,QAAQ,QAAQ,WAAW,CAE/C;AACA;AACA;AACA,OAAO,iBAAiB;AAAC,SAIhB,gBAAgB,EAAE,gBAAgB;AAAA,OAEpC,aAAa,IAGlB,qBAAqB;AAAA;AAYvB,SACE,gBAAgB,EAEhB,qBAAqB,GAGvB;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,aAAa,CAAC,KAAsB,EAAE;EAC7C,MAAM,IAAI,GAAG,OAAO,KAAK,KAAK,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,KAAK;EAChE,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,IAAI,CAAE;EACxC,OAAO,KAAK,CAAE;AAChB,CAYA;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;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;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAe,YAAY,CAChC,aAA4B,EAC5B,OAAiB,GAAG,CAAC,CAAC,EAIrB;EACD,4BACA,MAAM,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC,CAE9B;EACA,GAAG,CAAC,IAAI,GAAG,aAAa,CAAC,GAAG,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,IAAI,CAAC;EAC9D,QAAQ,CAAC,GAAG,EAAE;IAAE,aAAa,EAAE;EAAK,CAAC,CAAC,CAEtC;EACA;EACA,GAAG,CAAC,MAAM,KAAK,gBAAgB,CAAC;IAC9B,eAAe,EAAE,GAAG,CAAC;EACvB,CAAC,CAAC,CAEF;EACA,MAAM,aAAa,GAAG,MAAM,aAAa,CAAC,aAAa,EAAE,GAAG,CAAC;EAE7D,IAAI,UAAuB;EAC3B,IAAI,GAAG,CAAC,KAAK,EAAE;IACb,UAAU,GAAG,KAAK,CAAC,YAAY,CAAC;MAC9B,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,IAAI;MACpB,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC;IACjB,CAAC,EAAE,aAAsC,CAAC;EAC5C,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC,YAAY,CAAC,aAAsC,CAAC,CAE7E;EACA,UAAU,CAAC,EAAE,CAAC,OAAO,EAAG,KAAY,IAAK;IACvC,IAAK,KAAK,CAA0B,OAAO,KAAK,QAAQ,EAAE,MAAM,KAAK;IACrE,MAAM,IAAI,GAAG,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ,GAAG,QAAQ,GAAG,CAAC,IAAI,EAAE,GAAG,QAAQ,GAAG,CAAC,IAAI,EAAE,CAEnF;IACA,QAAS,KAAK,CAAuB,IAAI;MACvC,KAAK,QAAQ;QACX,GAAG,CAAC,MAAM,CAAE,KAAK,CAAC,GAAG,IAAI,+BAA+B,CAAC;QACzD,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;MACxB,KAAK,YAAY;QACf,GAAG,CAAC,MAAM,CAAE,KAAK,CAAC,GAAG,IAAI,oBAAoB,CAAC;QAC9C,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;MACxB,KAAK,SAAS;MACd;QACE,MAAM,KAAK;IACf;EACF,CAAC,CAAC,CAEF;EACA,UAAU,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM;IAC/B,MAAM,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC,CAAE;IAClC,MAAM,IAAI,GAAG,OAAO,IAAI,KAAK,QAAQ,GAAG,QAAQ,IAAI,EAAE,GAAG,QAAQ,IAAI,CAAC,IAAI,EAAE;IAC5E,GAAG,CAAC,MAAM,CAAE,IAAI,CAAC,uBAAuB,IAAI,OAC1C,OAAO,CAAC,GAAG,CAAC,QAAQ,OAAO,CAAC;EAChC,CAAC,CAAC;EAEF,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC;EAE3B,OAAO;IACL,aAAa;IACb;EACF,CAAC;AACH","ignoreList":[]}
@@ -1,24 +1,7 @@
1
- import "core-js/modules/es.iterator.for-each.js";
2
- import "core-js/modules/es.iterator.map.js";
3
- import "core-js/modules/es.set.difference.v2.js";
4
- import "core-js/modules/es.set.intersection.v2.js";
5
- import "core-js/modules/es.set.is-disjoint-from.v2.js";
6
- import "core-js/modules/es.set.is-subset-of.v2.js";
7
- import "core-js/modules/es.set.is-superset-of.v2.js";
8
- import "core-js/modules/es.iterator.constructor.js";
9
- import "core-js/modules/es.iterator.for-each.js";
10
- import "core-js/modules/es.iterator.map.js";
11
- import "core-js/modules/es.json.parse.js";
12
- import "core-js/modules/es.json.stringify.js";
13
- import "core-js/modules/es.set.difference.v2.js";
14
- import "core-js/modules/es.set.intersection.v2.js";
15
- import "core-js/modules/es.set.is-disjoint-from.v2.js";
16
- import "core-js/modules/es.set.is-subset-of.v2.js";
17
- import "core-js/modules/es.set.is-superset-of.v2.js";
18
- import "core-js/modules/es.set.symmetric-difference.v2.js";
19
- import "core-js/modules/es.set.union.v2.js"; /**
20
- * ExpressJS middleware for server-side rendering of a ReactJS app.
21
- */
1
+ import _JSON$parse from "core-js-pure/stable/json/parse.js";
2
+ import _JSON$stringify from "core-js-pure/stable/json/stringify.js"; /**
3
+ * ExpressJS middleware for server-side rendering of a ReactJS app.
4
+ */
22
5
  import { Buffer } from "node:buffer";
23
6
  import { createCipheriv, randomBytes } from "node:crypto";
24
7
  import fs from "node:fs";
@@ -54,7 +37,10 @@ export let SCRIPT_LOCATIONS = /*#__PURE__*/function (SCRIPT_LOCATIONS) {
54
37
  return SCRIPT_LOCATIONS;
55
38
  }({});
56
39
  export class ServerSsrContext extends SsrContext {
40
+ chunkGroups;
57
41
  chunks = [];
42
+ redirectTo;
43
+ req;
58
44
  status = 200;
59
45
  constructor(req, chunkGroups, initialState) {
60
46
  super(cloneDeep(initialState) ?? {});
@@ -72,7 +58,7 @@ export class ServerSsrContext extends SsrContext {
72
58
  */
73
59
  function getBuildInfo(context) {
74
60
  const url = path.resolve(context, ".build-info");
75
- return JSON.parse(fs.readFileSync(url, "utf8"));
61
+ return _JSON$parse(fs.readFileSync(url, "utf8"));
76
62
  } /**
77
63
  * Attempts to read from disk the named chunk groups mapping generated
78
64
  * by Webpack during the compilation.
@@ -85,7 +71,7 @@ function readChunkGroupsJson(buildDir) {
85
71
  const url = path.resolve(buildDir, "__chunk_groups__.json");
86
72
  let res;
87
73
  try {
88
- res = JSON.parse(fs.readFileSync(url, "utf8"));
74
+ res = _JSON$parse(fs.readFileSync(url, "utf8"));
89
75
  } catch {
90
76
  // TODO: Should we message the error here somehow?
91
77
  res = null;
@@ -170,7 +156,7 @@ export function newDefaultLogger({
170
156
  }) => {
171
157
  let res = `${level}\t(at ${timestamp}):\t${message}`;
172
158
  if (Object.keys(rest).length) {
173
- res += `\n${JSON.stringify(rest, null, 2)}`;
159
+ res += `\n${_JSON$stringify(rest, null, 2)}`;
174
160
  }
175
161
  if (stack) res += `\n${stack}`;
176
162
  return res;