@dr.pogodin/react-utils 1.47.0-alpha.1 → 1.47.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/babel.config.js +1 -1
- package/babel.module.config.js +11 -0
- package/bin/build.js +8 -4
- package/bin/setup.js +2 -3
- package/build/development/client/getInj.js +57 -44
- package/build/development/client/getInj.js.map +1 -1
- package/build/development/client/index.js +15 -21
- package/build/development/client/index.js.map +1 -1
- package/build/development/client/init.js +2 -6
- package/build/development/client/init.js.map +1 -1
- package/build/development/index.js +3 -183
- package/build/development/index.js.map +1 -1
- package/build/development/server/Cache.js +1 -8
- package/build/development/server/Cache.js.map +1 -1
- package/build/development/server/index.js +22 -50
- package/build/development/server/index.js.map +1 -1
- package/build/development/server/renderer.js +83 -92
- package/build/development/server/renderer.js.map +1 -1
- package/build/development/server/server.js +58 -62
- package/build/development/server/server.js.map +1 -1
- package/build/development/server/utils/errors.js +8 -31
- package/build/development/server/utils/errors.js.map +1 -1
- package/build/development/server/utils/index.js +2 -9
- package/build/development/server/utils/index.js.map +1 -1
- package/build/development/shared/components/Button/index.js +9 -16
- package/build/development/shared/components/Button/index.js.map +1 -1
- package/build/development/shared/components/Checkbox/index.js +6 -13
- package/build/development/shared/components/Checkbox/index.js.map +1 -1
- package/build/development/shared/components/GenericLink/index.js +4 -10
- package/build/development/shared/components/GenericLink/index.js.map +1 -1
- package/build/development/shared/components/Input/index.js +11 -18
- package/build/development/shared/components/Input/index.js.map +1 -1
- package/build/development/shared/components/Link.js +6 -13
- package/build/development/shared/components/Link.js.map +1 -1
- package/build/development/shared/components/Modal/index.js +16 -22
- package/build/development/shared/components/Modal/index.js.map +1 -1
- package/build/development/shared/components/NavLink.js +6 -13
- package/build/development/shared/components/NavLink.js.map +1 -1
- package/build/development/shared/components/PageLayout/index.js +7 -14
- package/build/development/shared/components/PageLayout/index.js.map +1 -1
- package/build/development/shared/components/TextArea/index.js +15 -22
- package/build/development/shared/components/TextArea/index.js.map +1 -1
- package/build/development/shared/components/Throbber/index.js +7 -14
- package/build/development/shared/components/Throbber/index.js.map +1 -1
- package/build/development/shared/components/WithTooltip/Tooltip.js +12 -18
- package/build/development/shared/components/WithTooltip/Tooltip.js.map +1 -1
- package/build/development/shared/components/WithTooltip/index.js +16 -23
- package/build/development/shared/components/WithTooltip/index.js.map +1 -1
- package/build/development/shared/components/YouTubeVideo/index.js +10 -17
- package/build/development/shared/components/YouTubeVideo/index.js.map +1 -1
- package/build/development/shared/components/index.js +16 -130
- package/build/development/shared/components/index.js.map +1 -1
- package/build/development/shared/components/selectors/CustomDropdown/Options/index.js +18 -19
- package/build/development/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
- package/build/development/shared/components/selectors/CustomDropdown/index.js +24 -28
- package/build/development/shared/components/selectors/CustomDropdown/index.js.map +1 -1
- package/build/development/shared/components/selectors/NativeDropdown/index.js +19 -19
- package/build/development/shared/components/selectors/NativeDropdown/index.js.map +1 -1
- package/build/development/shared/components/selectors/Switch/index.js +12 -17
- package/build/development/shared/components/selectors/Switch/index.js.map +1 -1
- package/build/development/shared/components/selectors/common.js +1 -7
- package/build/development/shared/components/selectors/common.js.map +1 -1
- package/build/development/shared/components/selectors/index.js +3 -27
- package/build/development/shared/components/selectors/index.js.map +1 -1
- package/build/development/shared/utils/config.js +40 -21
- package/build/development/shared/utils/config.js.map +1 -1
- package/build/development/shared/utils/globalState.js +3 -8
- package/build/development/shared/utils/globalState.js.map +1 -1
- package/build/development/shared/utils/index.js +12 -89
- package/build/development/shared/utils/index.js.map +1 -1
- package/build/development/shared/utils/isomorphy/buildInfo.js +2 -9
- package/build/development/shared/utils/isomorphy/buildInfo.js.map +1 -1
- package/build/development/shared/utils/isomorphy/environment-check.js +2 -8
- package/build/development/shared/utils/isomorphy/environment-check.js.map +1 -1
- package/build/development/shared/utils/isomorphy/index.js +7 -32
- package/build/development/shared/utils/isomorphy/index.js.map +1 -1
- package/build/development/shared/utils/jest/E2eSsrEnv.js +24 -31
- package/build/development/shared/utils/jest/E2eSsrEnv.js.map +1 -1
- package/build/development/shared/utils/jest/global.js +1 -7
- package/build/development/shared/utils/jest/global.js.map +1 -1
- package/build/development/shared/utils/jest/index.js +20 -44
- package/build/development/shared/utils/jest/index.js.map +1 -1
- package/build/development/shared/utils/splitComponent.js +54 -46
- package/build/development/shared/utils/splitComponent.js.map +1 -1
- package/build/development/shared/utils/time.js +22 -31
- package/build/development/shared/utils/time.js.map +1 -1
- package/build/development/shared/utils/webpack.js +17 -16
- package/build/development/shared/utils/webpack.js.map +1 -1
- package/build/production/client/getInj.js +13 -11
- package/build/production/client/getInj.js.map +1 -1
- package/build/production/client/index.js +3 -3
- package/build/production/client/index.js.map +1 -1
- package/build/production/client/init.js +2 -2
- package/build/production/client/init.js.map +1 -1
- package/build/production/index.js +2 -6
- package/build/production/index.js.map +1 -1
- package/build/production/server/Cache.js +3 -3
- package/build/production/server/Cache.js.map +1 -1
- package/build/production/server/index.js +8 -8
- package/build/production/server/index.js.map +1 -1
- package/build/production/server/renderer.js +24 -25
- package/build/production/server/renderer.js.map +1 -1
- package/build/production/server/server.js +9 -11
- package/build/production/server/server.js.map +1 -1
- package/build/production/server/utils/errors.js +9 -9
- package/build/production/server/utils/errors.js.map +1 -1
- package/build/production/server/utils/index.js +2 -1
- package/build/production/server/utils/index.js.map +1 -1
- package/build/production/shared/components/Button/index.js +4 -4
- package/build/production/shared/components/Button/index.js.map +1 -1
- package/build/production/shared/components/Checkbox/index.js +1 -1
- package/build/production/shared/components/Checkbox/index.js.map +1 -1
- package/build/production/shared/components/GenericLink/index.js +4 -4
- package/build/production/shared/components/GenericLink/index.js.map +1 -1
- package/build/production/shared/components/Input/index.js +5 -5
- package/build/production/shared/components/Input/index.js.map +1 -1
- package/build/production/shared/components/Link.js +3 -3
- package/build/production/shared/components/Link.js.map +1 -1
- package/build/production/shared/components/Modal/index.js +7 -7
- package/build/production/shared/components/Modal/index.js.map +1 -1
- package/build/production/shared/components/NavLink.js +2 -2
- package/build/production/shared/components/NavLink.js.map +1 -1
- package/build/production/shared/components/PageLayout/index.js +2 -2
- package/build/production/shared/components/PageLayout/index.js.map +1 -1
- package/build/production/shared/components/TextArea/index.js +5 -5
- package/build/production/shared/components/TextArea/index.js.map +1 -1
- package/build/production/shared/components/Throbber/index.js +2 -2
- package/build/production/shared/components/Throbber/index.js.map +1 -1
- package/build/production/shared/components/WithTooltip/Tooltip.js +4 -4
- package/build/production/shared/components/WithTooltip/Tooltip.js.map +1 -1
- package/build/production/shared/components/WithTooltip/index.js +4 -4
- package/build/production/shared/components/WithTooltip/index.js.map +1 -1
- package/build/production/shared/components/YouTubeVideo/index.js +4 -4
- package/build/production/shared/components/YouTubeVideo/index.js.map +1 -1
- package/build/production/shared/components/index.js +3 -1
- package/build/production/shared/components/index.js.map +1 -1
- package/build/production/shared/components/selectors/CustomDropdown/Options/index.js +2 -2
- package/build/production/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
- package/build/production/shared/components/selectors/CustomDropdown/index.js +2 -2
- package/build/production/shared/components/selectors/CustomDropdown/index.js.map +1 -1
- package/build/production/shared/components/selectors/NativeDropdown/index.js +4 -4
- package/build/production/shared/components/selectors/NativeDropdown/index.js.map +1 -1
- package/build/production/shared/components/selectors/Switch/index.js +1 -1
- package/build/production/shared/components/selectors/Switch/index.js.map +1 -1
- package/build/production/shared/components/selectors/common.js +2 -2
- package/build/production/shared/components/selectors/common.js.map +1 -1
- package/build/production/shared/components/selectors/index.js +1 -1
- package/build/production/shared/components/selectors/index.js.map +1 -1
- package/build/production/shared/utils/config.js +8 -6
- package/build/production/shared/utils/config.js.map +1 -1
- package/build/production/shared/utils/globalState.js +2 -2
- package/build/production/shared/utils/globalState.js.map +1 -1
- package/build/production/shared/utils/index.js +1 -1
- package/build/production/shared/utils/index.js.map +1 -1
- package/build/production/shared/utils/isomorphy/buildInfo.js +3 -3
- package/build/production/shared/utils/isomorphy/buildInfo.js.map +1 -1
- package/build/production/shared/utils/isomorphy/environment-check.js +3 -3
- package/build/production/shared/utils/isomorphy/environment-check.js.map +1 -1
- package/build/production/shared/utils/isomorphy/index.js +4 -4
- package/build/production/shared/utils/isomorphy/index.js.map +1 -1
- package/build/production/shared/utils/jest/E2eSsrEnv.js +14 -14
- package/build/production/shared/utils/jest/E2eSsrEnv.js.map +1 -1
- package/build/production/shared/utils/jest/global.js +1 -1
- package/build/production/shared/utils/jest/global.js.map +1 -1
- package/build/production/shared/utils/jest/index.js +11 -11
- package/build/production/shared/utils/jest/index.js.map +1 -1
- package/build/production/shared/utils/splitComponent.js +11 -22
- package/build/production/shared/utils/splitComponent.js.map +1 -1
- package/build/production/shared/utils/time.js +3 -3
- package/build/production/shared/utils/time.js.map +1 -1
- package/build/production/shared/utils/webpack.js +6 -6
- package/build/production/shared/utils/webpack.js.map +1 -1
- package/build/types-code/client/getInj.d.ts +1 -2
- package/build/types-code/client/index.d.ts +1 -1
- package/build/types-code/index.d.ts +1 -7
- package/build/types-code/server/index.d.ts +6 -11
- package/build/types-code/server/utils/index.d.ts +1 -1
- package/build/types-code/shared/utils/config.d.ts +4 -2
- package/build/types-code/shared/utils/index.d.ts +2 -2
- package/build/types-code/shared/utils/splitComponent.d.ts +6 -4
- package/build/web/client/getInj.js +55 -44
- package/build/web/client/getInj.js.map +1 -1
- package/build/web/client/index.js +15 -21
- package/build/web/client/index.js.map +1 -1
- package/build/web/client/init.js +2 -4
- package/build/web/client/init.js.map +1 -1
- package/build/web/index.js +1 -15
- package/build/web/index.js.map +1 -1
- package/build/web/server/index.js +12 -21
- package/build/web/server/index.js.map +1 -1
- package/build/web/server/renderer.js +34 -40
- package/build/web/server/renderer.js.map +1 -1
- package/build/web/server/server.js +14 -11
- package/build/web/server/server.js.map +1 -1
- package/build/web/server/utils/index.js +1 -1
- package/build/web/server/utils/index.js.map +1 -1
- package/build/web/shared/components/Button/index.js +1 -1
- package/build/web/shared/components/Button/index.js.map +1 -1
- package/build/web/shared/components/Checkbox/index.js +1 -1
- package/build/web/shared/components/Checkbox/index.js.map +1 -1
- package/build/web/shared/components/Input/index.js +1 -1
- package/build/web/shared/components/Input/index.js.map +1 -1
- package/build/web/shared/components/Modal/index.js +3 -3
- package/build/web/shared/components/Modal/index.js.map +1 -1
- package/build/web/shared/components/PageLayout/index.js +1 -1
- package/build/web/shared/components/PageLayout/index.js.map +1 -1
- package/build/web/shared/components/TextArea/index.js +1 -1
- package/build/web/shared/components/TextArea/index.js.map +1 -1
- package/build/web/shared/components/Throbber/index.js +1 -1
- package/build/web/shared/components/Throbber/index.js.map +1 -1
- package/build/web/shared/components/WithTooltip/index.js +1 -1
- package/build/web/shared/components/WithTooltip/index.js.map +1 -1
- package/build/web/shared/components/YouTubeVideo/index.js +1 -1
- package/build/web/shared/components/YouTubeVideo/index.js.map +1 -1
- package/build/web/shared/components/selectors/CustomDropdown/Options/index.js +3 -0
- package/build/web/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
- package/build/web/shared/components/selectors/CustomDropdown/index.js +3 -1
- package/build/web/shared/components/selectors/CustomDropdown/index.js.map +1 -1
- package/build/web/shared/components/selectors/NativeDropdown/index.js +4 -1
- package/build/web/shared/components/selectors/NativeDropdown/index.js.map +1 -1
- package/build/web/shared/components/selectors/Switch/index.js +2 -1
- package/build/web/shared/components/selectors/Switch/index.js.map +1 -1
- package/build/web/shared/utils/config.js +38 -14
- package/build/web/shared/utils/config.js.map +1 -1
- package/build/web/shared/utils/index.js +2 -2
- package/build/web/shared/utils/index.js.map +1 -1
- package/build/web/shared/utils/jest/E2eSsrEnv.js +3 -2
- package/build/web/shared/utils/jest/E2eSsrEnv.js.map +1 -1
- package/build/web/shared/utils/splitComponent.js +27 -20
- package/build/web/shared/utils/splitComponent.js.map +1 -1
- package/build/web/shared/utils/webpack.js +13 -7
- package/build/web/shared/utils/webpack.js.map +1 -1
- package/config/babel/node-ssr.js +12 -6
- package/config/babel/webpack.js +6 -1
- package/config/jest/default.js +8 -2
- package/config/jest/setup.js +8 -1
- package/config/webpack/app-base.js +23 -15
- package/config/webpack/app-development.js +2 -3
- package/config/webpack/lib-base.js +1 -2
- package/package.json +35 -25
- package/types.d.ts +1 -6
- package/node-entry.js +0 -15
- package/src/client/getInj.ts +0 -51
- package/src/client/index.tsx +0 -43
- package/src/client/init.ts +0 -52
- package/src/index.ts +0 -79
- package/src/server/Cache.ts +0 -61
- package/src/server/index.ts +0 -249
- package/src/server/renderer.tsx +0 -653
- package/src/server/server.ts +0 -332
- package/src/server/utils/errors.ts +0 -122
- package/src/server/utils/index.ts +0 -3
- package/src/shared/components/Button/index.tsx +0 -130
- package/src/shared/components/Button/style.scss +0 -54
- package/src/shared/components/Checkbox/index.tsx +0 -53
- package/src/shared/components/Checkbox/theme.scss +0 -63
- package/src/shared/components/GenericLink/index.tsx +0 -141
- package/src/shared/components/GenericLink/style.scss +0 -3
- package/src/shared/components/Input/index.tsx +0 -96
- package/src/shared/components/Input/theme.scss +0 -52
- package/src/shared/components/Link.tsx +0 -25
- package/src/shared/components/Modal/base-theme.scss +0 -38
- package/src/shared/components/Modal/index.tsx +0 -177
- package/src/shared/components/Modal/styles.scss +0 -3
- package/src/shared/components/NavLink.tsx +0 -18
- package/src/shared/components/PageLayout/base-theme.scss +0 -30
- package/src/shared/components/PageLayout/index.tsx +0 -51
- package/src/shared/components/TextArea/index.tsx +0 -139
- package/src/shared/components/TextArea/style.scss +0 -68
- package/src/shared/components/Throbber/index.tsx +0 -28
- package/src/shared/components/Throbber/theme.scss +0 -26
- package/src/shared/components/WithTooltip/Tooltip.tsx +0 -274
- package/src/shared/components/WithTooltip/default-theme.scss +0 -36
- package/src/shared/components/WithTooltip/index.tsx +0 -186
- package/src/shared/components/YouTubeVideo/base.scss +0 -15
- package/src/shared/components/YouTubeVideo/index.tsx +0 -73
- package/src/shared/components/YouTubeVideo/throbber.scss +0 -11
- package/src/shared/components/index.ts +0 -20
- package/src/shared/components/selectors/CustomDropdown/Options/index.tsx +0 -124
- package/src/shared/components/selectors/CustomDropdown/Options/style.scss +0 -6
- package/src/shared/components/selectors/CustomDropdown/index.tsx +0 -146
- package/src/shared/components/selectors/CustomDropdown/theme.scss +0 -118
- package/src/shared/components/selectors/NativeDropdown/index.tsx +0 -90
- package/src/shared/components/selectors/NativeDropdown/theme.scss +0 -81
- package/src/shared/components/selectors/Switch/index.tsx +0 -74
- package/src/shared/components/selectors/Switch/theme.scss +0 -39
- package/src/shared/components/selectors/common.ts +0 -57
- package/src/shared/components/selectors/index.ts +0 -8
- package/src/shared/utils/config.ts +0 -28
- package/src/shared/utils/globalState.ts +0 -44
- package/src/shared/utils/index.ts +0 -45
- package/src/shared/utils/isomorphy/buildInfo.ts +0 -50
- package/src/shared/utils/isomorphy/environment-check.ts +0 -18
- package/src/shared/utils/isomorphy/index.ts +0 -36
- package/src/shared/utils/jest/E2eSsrEnv.ts +0 -305
- package/src/shared/utils/jest/global.ts +0 -17
- package/src/shared/utils/jest/index.ts +0 -215
- package/src/shared/utils/splitComponent.tsx +0 -275
- package/src/shared/utils/time.ts +0 -101
- package/src/shared/utils/webpack.ts +0 -74
- package/src/styles/_global/reset.css +0 -52
- package/src/styles/_mixins/fonts.scss +0 -40
- package/src/styles/_mixins/media.scss +0 -150
- package/src/styles/_mixins/typography.scss +0 -83
- package/src/styles/global.scss +0 -11
- package/src/styles/mixins.scss +0 -6
package/babel.config.js
CHANGED
package/bin/build.js
CHANGED
|
@@ -8,9 +8,7 @@ import fs from 'node:fs';
|
|
|
8
8
|
import { createRequire } from 'node:module';
|
|
9
9
|
import path from 'node:path';
|
|
10
10
|
|
|
11
|
-
import
|
|
12
|
-
import mapValues from 'lodash/mapValues.js';
|
|
13
|
-
import merge from 'lodash/merge.js';
|
|
11
|
+
import { mapValues, merge } from 'lodash-es';
|
|
14
12
|
|
|
15
13
|
import { program } from 'commander';
|
|
16
14
|
|
|
@@ -70,6 +68,7 @@ program
|
|
|
70
68
|
.option('--no-webpack', 'opts out the Webpack (client-side code) build')
|
|
71
69
|
.option('-o, --out-dir <path>', 'output folder for the build', 'build')
|
|
72
70
|
.option('-w, --watch', 'build, watch, and rebuild on source changes')
|
|
71
|
+
.option('--babel-config <path>', 'path to the Babel config')
|
|
73
72
|
.option(
|
|
74
73
|
'--webpack-config <path>',
|
|
75
74
|
'path to the webpack config',
|
|
@@ -116,7 +115,7 @@ const require = createRequire(import.meta.url);
|
|
|
116
115
|
// eslint-disable-next-line import/no-dynamic-require
|
|
117
116
|
let webpackConfig = require(path.resolve(cwd, cmdLineArgs.webpackConfig));
|
|
118
117
|
if ('default' in webpackConfig) webpackConfig = webpackConfig.default;
|
|
119
|
-
if (
|
|
118
|
+
if (typeof webpackConfig === 'function') webpackConfig = webpackConfig(buildType);
|
|
120
119
|
|
|
121
120
|
let webpackOutDir = outDir;
|
|
122
121
|
if (!cmdLineArgs.lib) webpackOutDir += '/web-public';
|
|
@@ -195,6 +194,11 @@ let BABEL_CMD_BASE = `${cwd}/node_modules/.bin/babel`;
|
|
|
195
194
|
BABEL_CMD_BASE += ` ${inDir} --out-dir ${outDir} --source-maps`;
|
|
196
195
|
if (buildType === BUILD_TYPES.PRODUCTION) BABEL_CMD_BASE += ' --minified';
|
|
197
196
|
|
|
197
|
+
if (cmdLineArgs.babelConfig) {
|
|
198
|
+
const url = path.resolve(cwd, cmdLineArgs.babelConfig);
|
|
199
|
+
BABEL_CMD_BASE += ` --config-file ${url}`;
|
|
200
|
+
}
|
|
201
|
+
|
|
198
202
|
/* TODO: The watch is deactivated for Babel compilation because of SVG files:
|
|
199
203
|
* currently there is no way to tell Babel that SVG files should be compiled
|
|
200
204
|
* keeping their SVG extensions, while JS and JSX are compiled with extensions
|
package/bin/setup.js
CHANGED
|
@@ -7,7 +7,6 @@ import { spawnSync } from 'node:child_process';
|
|
|
7
7
|
import fs from 'node:fs';
|
|
8
8
|
import path from 'node:path';
|
|
9
9
|
|
|
10
|
-
import clone from 'lodash/clone.js';
|
|
11
10
|
import { program } from 'commander';
|
|
12
11
|
|
|
13
12
|
const NPM_COMMAND = process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
|
@@ -110,7 +109,7 @@ function adoptDevDependencies(donorData, hostData) {
|
|
|
110
109
|
if (verbose) console.log('Adopting dev dependencies...');
|
|
111
110
|
|
|
112
111
|
/* Inits deps as a map of all donor's dev dependencies. */
|
|
113
|
-
const deps =
|
|
112
|
+
const deps = { ...donorData.devDependencies };
|
|
114
113
|
|
|
115
114
|
/* Removes from the map any prod dependencies of host. */
|
|
116
115
|
Object.entries(hostData.dependencies || {})
|
|
@@ -175,7 +174,7 @@ function getPackageJson(packageName = '@dr.pogodin/react-utils') {
|
|
|
175
174
|
let url = packageName === '@dr.pogodin/react-utils' ? '..' : packageName;
|
|
176
175
|
|
|
177
176
|
// TODO: .slice(5) cuts out file:// schema in front of the URL.
|
|
178
|
-
url =
|
|
177
|
+
url = import.meta.resolve(url).slice(5);
|
|
179
178
|
|
|
180
179
|
for (;;) {
|
|
181
180
|
const files = fs.readdirSync(url);
|
|
@@ -1,54 +1,67 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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.array-buffer.detached.js";
|
|
5
|
+
import "core-js/modules/es.array-buffer.transfer.js";
|
|
6
|
+
import "core-js/modules/es.array-buffer.transfer-to-fixed-length.js";
|
|
7
|
+
import "core-js/modules/es.typed-array.to-reversed.js";
|
|
8
|
+
import "core-js/modules/es.typed-array.to-sorted.js";
|
|
9
|
+
import "core-js/modules/es.typed-array.with.js";
|
|
10
|
+
import "core-js/modules/web.dom-exception.stack.js";
|
|
11
11
|
// Encapsulates retrieval of server-side data injection into HTML template.
|
|
12
12
|
|
|
13
13
|
/* global document */
|
|
14
|
+
import { getBuildInfo } from "../shared/utils/isomorphy/buildInfo.js";
|
|
15
|
+
let inj;
|
|
16
|
+
export default function getInj() {
|
|
17
|
+
inj ??= (async () => {
|
|
18
|
+
const metaElement = typeof document === 'undefined' ? null : document.querySelector('meta[itemprop="drpruinj"]');
|
|
19
|
+
if (metaElement) {
|
|
20
|
+
metaElement.remove();
|
|
14
21
|
|
|
15
|
-
//
|
|
16
|
-
// is
|
|
22
|
+
// NOTE: Since 2025 there is Uint8Array.fromBase64(), which should be
|
|
23
|
+
// preferred, but it is not supported by older environments yet.
|
|
24
|
+
const data = atob(metaElement.content);
|
|
17
25
|
|
|
18
|
-
//
|
|
26
|
+
// TODO: Our current handling of this encryption / decryption follows
|
|
27
|
+
// a legacy approach, and can be enhanced by using Crypto features.
|
|
28
|
+
// Though, this is not strictly intended to be secure (it is more
|
|
29
|
+
// to obfurscate injected data, rather than really keeping them
|
|
30
|
+
// secure), thus it is fine like this for now.
|
|
31
|
+
const {
|
|
32
|
+
key
|
|
33
|
+
} = getBuildInfo();
|
|
34
|
+
const code = x => x.charCodeAt(0);
|
|
35
|
+
const dataBuffer = Uint8Array.from(data.slice(16), code);
|
|
36
|
+
const ivBuffer = Uint8Array.from(data.slice(0, 16), code);
|
|
37
|
+
const keyBuffer = Uint8Array.from(atob(key), code);
|
|
38
|
+
const cKey = await window.crypto.subtle.importKey('raw', keyBuffer, {
|
|
39
|
+
name: 'AES-CBC'
|
|
40
|
+
}, false, ['decrypt']);
|
|
41
|
+
const buffer = await window.crypto.subtle.decrypt({
|
|
42
|
+
iv: ivBuffer,
|
|
43
|
+
name: 'AES-CBC'
|
|
44
|
+
}, cKey, dataBuffer);
|
|
45
|
+
const decoder = new TextDecoder();
|
|
19
46
|
|
|
20
|
-
//
|
|
21
|
-
|
|
22
|
-
// environment, but there is no document.
|
|
23
|
-
let inj = {};
|
|
24
|
-
const metaElement = typeof document === 'undefined' ? null : document.querySelector('meta[itemprop="drpruinj"]');
|
|
25
|
-
if (metaElement) {
|
|
26
|
-
metaElement.remove();
|
|
27
|
-
let data = _forge.default.util.decode64(metaElement.content);
|
|
28
|
-
const {
|
|
29
|
-
key
|
|
30
|
-
} = (0, _buildInfo.getBuildInfo)();
|
|
31
|
-
const d = _forge.default.cipher.createDecipher('AES-CBC', key);
|
|
32
|
-
d.start({
|
|
33
|
-
iv: data.slice(0, key.length)
|
|
34
|
-
});
|
|
35
|
-
d.update(_forge.default.util.createBuffer(data.slice(key.length)));
|
|
36
|
-
d.finish();
|
|
37
|
-
data = _forge.default.util.decodeUtf8(d.output.data);
|
|
47
|
+
// eslint-disable-next-line no-eval
|
|
48
|
+
const res = eval(`(${decoder.decode(buffer)})`);
|
|
38
49
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
// NOTE: This is important, to be able to return the injection
|
|
51
|
+
// synchronously once it is initialized.
|
|
52
|
+
inj = res;
|
|
53
|
+
return res;
|
|
54
|
+
} else if (typeof window !== 'undefined' && window.REACT_UTILS_INJECTION) {
|
|
55
|
+
const res = window.REACT_UTILS_INJECTION;
|
|
56
|
+
delete window.REACT_UTILS_INJECTION;
|
|
57
|
+
return res;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Otherwise, a bunch of dependent stuff will easily fail in non-standard
|
|
61
|
+
// environments, where no client-side initialization is performed. Like tests,
|
|
62
|
+
// Docusaurus examples, etc.
|
|
63
|
+
return {};
|
|
64
|
+
})();
|
|
52
65
|
return inj;
|
|
53
66
|
}
|
|
54
67
|
//# sourceMappingURL=getInj.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getInj.js","names":["
|
|
1
|
+
{"version":3,"file":"getInj.js","names":["getBuildInfo","inj","getInj","metaElement","document","querySelector","remove","data","atob","content","key","code","x","charCodeAt","dataBuffer","Uint8Array","from","slice","ivBuffer","keyBuffer","cKey","window","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 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 // TODO: Our current handling of this encryption / decryption follows\n // a legacy approach, and can be enhanced by using Crypto features.\n // Though, this is not strictly intended to be secure (it is more\n // to obfurscate injected data, rather than really keeping them\n // secure), thus it is fine like this for now.\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;AAAA,SAISA,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,2BAA2B,CAAC;IAE9D,IAAIF,WAAW,EAAE;MACfA,WAAW,CAACG,MAAM,CAAC,CAAC;;MAEpB;MACA;MACA,MAAMC,IAAI,GAAGC,IAAI,CAACL,WAAW,CAACM,OAAO,CAAC;;MAEtC;MACA;MACA;MACA;MACA;MACA,MAAM;QAAEC;MAAI,CAAC,GAAGV,YAAY,CAAC,CAAC;MAE9B,MAAMW,IAAI,GAAIC,CAAS,IAAKA,CAAC,CAACC,UAAU,CAAC,CAAC,CAAC;MAC3C,MAAMC,UAAU,GAAGC,UAAU,CAACC,IAAI,CAACT,IAAI,CAACU,KAAK,CAAC,EAAE,CAAC,EAAEN,IAAI,CAAC;MACxD,MAAMO,QAAQ,GAAGH,UAAU,CAACC,IAAI,CAACT,IAAI,CAACU,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAEN,IAAI,CAAC;MACzD,MAAMQ,SAAS,GAAGJ,UAAU,CAACC,IAAI,CAACR,IAAI,CAACE,GAAG,CAAC,EAAEC,IAAI,CAAC;MAElD,MAAMS,IAAI,GAAG,MAAMC,MAAM,CAACC,MAAM,CAACC,MAAM,CAACC,SAAS,CAC/C,KAAK,EACLL,SAAS,EACT;QAAEM,IAAI,EAAE;MAAU,CAAC,EACnB,KAAK,EACL,CAAC,SAAS,CACZ,CAAC;MAED,MAAMC,MAAM,GAAG,MAAML,MAAM,CAACC,MAAM,CAACC,MAAM,CAACI,OAAO,CAAC;QAChDC,EAAE,EAAEV,QAAQ;QACZO,IAAI,EAAE;MACR,CAAC,EAAEL,IAAI,EAAEN,UAAU,CAAC;MAEpB,MAAMe,OAAO,GAAG,IAAIC,WAAW,CAAC,CAAC;;MAEjC;MACA,MAAMC,GAAG,GAAGC,IAAI,CAAC,IAAIH,OAAO,CAACI,MAAM,CAACP,MAAM,CAAC,GAAG,CAAS;;MAEvD;MACA;MACAzB,GAAG,GAAG8B,GAAG;MAET,OAAOA,GAAG;IACZ,CAAC,MAAM,IAAI,OAAOV,MAAM,KAAK,WAAW,IAAIA,MAAM,CAACa,qBAAqB,EAAE;MACxE,MAAMH,GAAG,GAAGV,MAAM,CAACa,qBAAqB;MACxC,OAAOb,MAAM,CAACa,qBAAqB;MACnC,OAAOH,GAAG;IACZ;;IAEA;IACA;IACA;IACA,OAAO,CAAC,CAAC;EACX,CAAC,EAAE,CAAC;EAEJ,OAAO9B,GAAG;AACZ","ignoreList":[]}
|
|
@@ -1,38 +1,32 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = Launch;
|
|
8
|
-
var _client = require("react-dom/client");
|
|
9
|
-
var _reactHelmet = require("@dr.pogodin/react-helmet");
|
|
10
|
-
var _reactRouter = require("react-router");
|
|
11
|
-
var _reactGlobalState = require("@dr.pogodin/react-global-state");
|
|
12
|
-
var _getInj = _interopRequireDefault(require("./getInj"));
|
|
13
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
1
|
// Initialization of client-side code.
|
|
15
2
|
/* global document */
|
|
16
3
|
|
|
4
|
+
import { createRoot, hydrateRoot } from 'react-dom/client';
|
|
5
|
+
import { HelmetProvider } from '@dr.pogodin/react-helmet';
|
|
6
|
+
import { BrowserRouter } from 'react-router';
|
|
7
|
+
import { GlobalStateProvider } from '@dr.pogodin/react-global-state';
|
|
8
|
+
import getInj from "./getInj.js";
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
10
|
/**
|
|
18
11
|
* Prepares and launches the app at client side.
|
|
19
12
|
* @param Application Root application component
|
|
20
13
|
* @param [options={}] Optional. Additional settings.
|
|
21
14
|
*/
|
|
22
|
-
function
|
|
15
|
+
export async function launchClient(Application, options = {}) {
|
|
16
|
+
const inj = await getInj();
|
|
23
17
|
const container = document.getElementById('react-view');
|
|
24
18
|
if (!container) throw Error('Failed to find container for React app');
|
|
25
|
-
const scene = /*#__PURE__*/(
|
|
26
|
-
initialState:
|
|
27
|
-
children: /*#__PURE__*/(
|
|
28
|
-
children: /*#__PURE__*/(
|
|
29
|
-
children: /*#__PURE__*/(
|
|
19
|
+
const scene = /*#__PURE__*/_jsx(GlobalStateProvider, {
|
|
20
|
+
initialState: inj.ISTATE ?? options.initialState,
|
|
21
|
+
children: /*#__PURE__*/_jsx(BrowserRouter, {
|
|
22
|
+
children: /*#__PURE__*/_jsx(HelmetProvider, {
|
|
23
|
+
children: /*#__PURE__*/_jsx(Application, {})
|
|
30
24
|
})
|
|
31
25
|
})
|
|
32
26
|
});
|
|
33
27
|
if (options.dontHydrate) {
|
|
34
|
-
const root =
|
|
28
|
+
const root = createRoot(container);
|
|
35
29
|
root.render(scene);
|
|
36
|
-
} else
|
|
30
|
+
} else hydrateRoot(container, scene);
|
|
37
31
|
}
|
|
38
32
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["createRoot","hydrateRoot","HelmetProvider","BrowserRouter","GlobalStateProvider","getInj","jsx","_jsx","launchClient","Application","options","inj","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 { HelmetProvider } from '@dr.pogodin/react-helmet';\nimport { BrowserRouter } from 'react-router';\n\nimport { GlobalStateProvider } from '@dr.pogodin/react-global-state';\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 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;;AAGA,SAASA,UAAU,EAAEC,WAAW,QAAQ,kBAAkB;AAC1D,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,aAAa,QAAQ,cAAc;AAE5C,SAASC,mBAAmB,QAAQ,gCAAgC;AAAA,OAE7DC,MAAM;AAAiB,SAAAC,GAAA,IAAAC,IAAA;AAO9B;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,YAAYA,CAChCC,WAA0B,EAC1BC,OAAiB,GAAG,CAAC,CAAC,EACP;EACf,MAAMC,GAAG,GAAG,MAAMN,MAAM,CAAC,CAAC;EAE1B,MAAMO,SAAS,GAAGC,QAAQ,CAACC,cAAc,CAAC,YAAY,CAAC;EACvD,IAAI,CAACF,SAAS,EAAE,MAAMG,KAAK,CAAC,wCAAwC,CAAC;EACrE,MAAMC,KAAK,gBACTT,IAAA,CAACH,mBAAmB;IAACa,YAAY,EAAEN,GAAG,CAACO,MAAM,IAAIR,OAAO,CAACO,YAAa;IAAAE,QAAA,eACpEZ,IAAA,CAACJ,aAAa;MAAAgB,QAAA,eACZZ,IAAA,CAACL,cAAc;QAAAiB,QAAA,eACbZ,IAAA,CAACE,WAAW,IAAE;MAAC,CACD;IAAC,CACJ;EAAC,CACG,CACtB;EAED,IAAIC,OAAO,CAACU,WAAW,EAAE;IACvB,MAAMC,IAAI,GAAGrB,UAAU,CAACY,SAAS,CAAC;IAClCS,IAAI,CAACC,MAAM,CAACN,KAAK,CAAC;EACpB,CAAC,MAAMf,WAAW,CAACW,SAAS,EAAEI,KAAK,CAAC;AACtC","ignoreList":[]}
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _buildInfo = require("../shared/utils/isomorphy/buildInfo");
|
|
4
1
|
/**
|
|
5
2
|
* Initialization of client-side environment.
|
|
6
3
|
*/
|
|
7
|
-
|
|
8
4
|
/* global window */
|
|
9
|
-
|
|
10
|
-
const buildInfo =
|
|
5
|
+
import { getBuildInfo } from "../shared/utils/isomorphy/buildInfo.js";
|
|
6
|
+
const buildInfo = getBuildInfo();
|
|
11
7
|
|
|
12
8
|
// TODO: Should be moved into buildInfo module?
|
|
13
9
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","names":["
|
|
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;;AAEhC;;AAUA,IAAIE,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;EACzC;EACAC,OAAO,CAACC,IAAI,CAAC,wDAAwD,CAAC;;EAEtE;EACAC,MAAM,CAACC,kBAAkB,GAAGC,UAAU;AACxC;;AAEA;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;UACjD;UACAV,OAAO,CAACW,GAAG,CAAC,gBAAgB,EAAEH,GAAG,CAAC;QACpC,CAAC,CAAC,OAAOI,GAAG,EAAE;UACZ;UACAZ,OAAO,CAACW,GAAG,CAAC,yBAAyB,EAAEC,GAAG,CAAC;QAC7C;MACF,CAAC,EAAE,CAAC;IACN,CAAC,CAAC;EACJ;AACF","ignoreList":[]}
|
|
@@ -1,175 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _exportNames = {
|
|
7
|
-
client: true,
|
|
8
|
-
server: true,
|
|
9
|
-
assertEmptyObject: true,
|
|
10
|
-
config: true,
|
|
11
|
-
Barrier: true,
|
|
12
|
-
Cached: true,
|
|
13
|
-
Emitter: true,
|
|
14
|
-
isomorphy: true,
|
|
15
|
-
getSsrContext: true,
|
|
16
|
-
Semaphore: true,
|
|
17
|
-
splitComponent: true,
|
|
18
|
-
themed: true,
|
|
19
|
-
ThemeProvider: true,
|
|
20
|
-
time: true,
|
|
21
|
-
webpack: true,
|
|
22
|
-
withRetries: true,
|
|
23
|
-
getGlobalState: true,
|
|
24
|
-
GlobalStateProvider: true,
|
|
25
|
-
newAsyncDataEnvelope: true,
|
|
26
|
-
useAsyncCollection: true,
|
|
27
|
-
useAsyncData: true,
|
|
28
|
-
useGlobalState: true,
|
|
29
|
-
withGlobalStateType: true
|
|
30
|
-
};
|
|
31
|
-
Object.defineProperty(exports, "Barrier", {
|
|
32
|
-
enumerable: true,
|
|
33
|
-
get: function () {
|
|
34
|
-
return _utils.Barrier;
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
Object.defineProperty(exports, "Cached", {
|
|
38
|
-
enumerable: true,
|
|
39
|
-
get: function () {
|
|
40
|
-
return _utils.Cached;
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
Object.defineProperty(exports, "Emitter", {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
get: function () {
|
|
46
|
-
return _utils.Emitter;
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
Object.defineProperty(exports, "GlobalStateProvider", {
|
|
50
|
-
enumerable: true,
|
|
51
|
-
get: function () {
|
|
52
|
-
return _reactGlobalState.GlobalStateProvider;
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
Object.defineProperty(exports, "Semaphore", {
|
|
56
|
-
enumerable: true,
|
|
57
|
-
get: function () {
|
|
58
|
-
return _utils.Semaphore;
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
Object.defineProperty(exports, "ThemeProvider", {
|
|
62
|
-
enumerable: true,
|
|
63
|
-
get: function () {
|
|
64
|
-
return _utils.ThemeProvider;
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
Object.defineProperty(exports, "assertEmptyObject", {
|
|
68
|
-
enumerable: true,
|
|
69
|
-
get: function () {
|
|
70
|
-
return _utils.assertEmptyObject;
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
exports.client = void 0;
|
|
74
|
-
Object.defineProperty(exports, "config", {
|
|
75
|
-
enumerable: true,
|
|
76
|
-
get: function () {
|
|
77
|
-
return _utils.config;
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
Object.defineProperty(exports, "getGlobalState", {
|
|
81
|
-
enumerable: true,
|
|
82
|
-
get: function () {
|
|
83
|
-
return _reactGlobalState.getGlobalState;
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
Object.defineProperty(exports, "getSsrContext", {
|
|
87
|
-
enumerable: true,
|
|
88
|
-
get: function () {
|
|
89
|
-
return _utils.getSsrContext;
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
Object.defineProperty(exports, "isomorphy", {
|
|
93
|
-
enumerable: true,
|
|
94
|
-
get: function () {
|
|
95
|
-
return _utils.isomorphy;
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
Object.defineProperty(exports, "newAsyncDataEnvelope", {
|
|
99
|
-
enumerable: true,
|
|
100
|
-
get: function () {
|
|
101
|
-
return _reactGlobalState.newAsyncDataEnvelope;
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
exports.server = void 0;
|
|
105
|
-
Object.defineProperty(exports, "splitComponent", {
|
|
106
|
-
enumerable: true,
|
|
107
|
-
get: function () {
|
|
108
|
-
return _utils.splitComponent;
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
Object.defineProperty(exports, "themed", {
|
|
112
|
-
enumerable: true,
|
|
113
|
-
get: function () {
|
|
114
|
-
return _utils.themed;
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
Object.defineProperty(exports, "time", {
|
|
118
|
-
enumerable: true,
|
|
119
|
-
get: function () {
|
|
120
|
-
return _utils.time;
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
Object.defineProperty(exports, "useAsyncCollection", {
|
|
124
|
-
enumerable: true,
|
|
125
|
-
get: function () {
|
|
126
|
-
return _reactGlobalState.useAsyncCollection;
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
Object.defineProperty(exports, "useAsyncData", {
|
|
130
|
-
enumerable: true,
|
|
131
|
-
get: function () {
|
|
132
|
-
return _reactGlobalState.useAsyncData;
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
Object.defineProperty(exports, "useGlobalState", {
|
|
136
|
-
enumerable: true,
|
|
137
|
-
get: function () {
|
|
138
|
-
return _reactGlobalState.useGlobalState;
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
Object.defineProperty(exports, "webpack", {
|
|
142
|
-
enumerable: true,
|
|
143
|
-
get: function () {
|
|
144
|
-
return _utils.webpack;
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
Object.defineProperty(exports, "withGlobalStateType", {
|
|
148
|
-
enumerable: true,
|
|
149
|
-
get: function () {
|
|
150
|
-
return _reactGlobalState.withGlobalStateType;
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
Object.defineProperty(exports, "withRetries", {
|
|
154
|
-
enumerable: true,
|
|
155
|
-
get: function () {
|
|
156
|
-
return _utils.withRetries;
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
var _utils = require("./shared/utils");
|
|
160
|
-
var _reactGlobalState = require("@dr.pogodin/react-global-state");
|
|
161
|
-
var _components = require("./shared/components");
|
|
162
|
-
Object.keys(_components).forEach(function (key) {
|
|
163
|
-
if (key === "default" || key === "__esModule") return;
|
|
164
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
165
|
-
if (key in exports && exports[key] === _components[key]) return;
|
|
166
|
-
Object.defineProperty(exports, key, {
|
|
167
|
-
enumerable: true,
|
|
168
|
-
get: function () {
|
|
169
|
-
return _components[key];
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
1
|
// It is a safeguard against multiple instances / versions of the library
|
|
174
2
|
// being loaded into environment by mistake (e.g. because of different
|
|
175
3
|
// packages pinning down different exact versions of the lib, thus preventing
|
|
@@ -177,15 +5,7 @@ Object.keys(_components).forEach(function (key) {
|
|
|
177
5
|
if (global.REACT_UTILS_LIBRARY_LOADED) {
|
|
178
6
|
throw Error('React utils library is already loaded');
|
|
179
7
|
} else global.REACT_UTILS_LIBRARY_LOADED = true;
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
// this workaround won't be needed.
|
|
184
|
-
let dirname = require('url').pathToFileURL(__filename).toString();
|
|
185
|
-
dirname = dirname.slice(5, dirname.lastIndexOf('/'));
|
|
186
|
-
const server = exports.server = _utils.webpack.requireWeak("./server", dirname);
|
|
187
|
-
const client = exports.client = server ? undefined
|
|
188
|
-
|
|
189
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
190
|
-
: require("./client").default;
|
|
8
|
+
export { getGlobalState, GlobalStateProvider, newAsyncDataEnvelope, useAsyncCollection, useAsyncData, useGlobalState, withGlobalStateType } from '@dr.pogodin/react-global-state';
|
|
9
|
+
export * from "./shared/components/index.js";
|
|
10
|
+
export { assertEmptyObject, Barrier, Cached, Emitter, getConfig, isomorphy, getSsrContext, Semaphore, splitComponent, themed, ThemeProvider, time, webpack, withRetries } from "./shared/utils/index.js";
|
|
191
11
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["global","REACT_UTILS_LIBRARY_LOADED","Error","getGlobalState","GlobalStateProvider","newAsyncDataEnvelope","useAsyncCollection","useAsyncData","useGlobalState","withGlobalStateType","assertEmptyObject","Barrier","Cached","Emitter","getConfig","isomorphy","getSsrContext","Semaphore","splitComponent","themed","ThemeProvider","time","webpack","withRetries"],"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).\nif (global.REACT_UTILS_LIBRARY_LOADED) {\n throw Error('React utils library is already loaded');\n} else global.REACT_UTILS_LIBRARY_LOADED = true;\n\nexport {\n type AsyncCollectionT,\n type AsyncCollectionLoaderT,\n type AsyncDataEnvelopeT,\n type AsyncDataLoaderT,\n type ForceT,\n type UseAsyncDataOptionsT,\n type UseAsyncDataResT,\n type UseGlobalStateResT,\n type ValueOrInitializerT,\n getGlobalState,\n GlobalStateProvider,\n newAsyncDataEnvelope,\n useAsyncCollection,\n useAsyncData,\n useGlobalState,\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 assertEmptyObject,\n Barrier,\n Cached,\n Emitter,\n getConfig,\n isomorphy,\n getSsrContext,\n type Listener,\n type ObjectKey,\n Semaphore,\n splitComponent,\n type Theme,\n themed,\n ThemeProvider,\n time,\n webpack,\n withRetries,\n} from 'utils';\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA,IAAIA,MAAM,CAACC,0BAA0B,EAAE;EACrC,MAAMC,KAAK,CAAC,uCAAuC,CAAC;AACtD,CAAC,MAAMF,MAAM,CAACC,0BAA0B,GAAG,IAAI;AAE/C,SAUEE,cAAc,EACdC,mBAAmB,EACnBC,oBAAoB,EACpBC,kBAAkB,EAClBC,YAAY,EACZC,cAAc,EACdC,mBAAmB,QACd,gCAAgC;AAAA;AAAA,SAarCC,iBAAiB,EACjBC,OAAO,EACPC,MAAM,EACNC,OAAO,EACPC,SAAS,EACTC,SAAS,EACTC,aAAa,EAGbC,SAAS,EACTC,cAAc,EAEdC,MAAM,EACNC,aAAa,EACbC,IAAI,EACJC,OAAO,EACPC,WAAW","ignoreList":[]}
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
1
|
/**
|
|
8
2
|
* Implements the static cache.
|
|
9
3
|
*/
|
|
10
|
-
class Cache {
|
|
4
|
+
export default class Cache {
|
|
11
5
|
items = {};
|
|
12
6
|
size = 0;
|
|
13
7
|
constructor(maxSize) {
|
|
@@ -57,5 +51,4 @@ class Cache {
|
|
|
57
51
|
}
|
|
58
52
|
}
|
|
59
53
|
}
|
|
60
|
-
exports.default = Cache;
|
|
61
54
|
//# sourceMappingURL=Cache.js.map
|
|
@@ -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"
|
|
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;AACA,eAAe,MAAMA,KAAK,CAAS;EACzBC,KAAK,GAAwC,CAAC,CAAC;EAE/CC,IAAI,GAAG,CAAC;EAEhBC,WAAWA,CAASC,OAAe,EAAE;IAAA,KAAjBA,OAAe,GAAfA,OAAe;EAAI;;EAEvC;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;;EAEA;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":[]}
|