@dr.pogodin/react-utils 1.49.1 → 1.50.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/babel.scripts.config.js +19 -0
- package/bin/build.js +274 -164
- package/build/development/client/getInj.js +18 -29
- package/build/development/client/getInj.js.map +1 -1
- package/build/development/client/index.js +11 -14
- package/build/development/client/index.js.map +1 -1
- package/build/development/client/init.js +9 -17
- package/build/development/client/init.js.map +1 -1
- package/build/development/index.js +26 -4
- package/build/development/index.js.map +1 -1
- package/build/development/server/Cache.js +15 -20
- package/build/development/server/Cache.js.map +1 -1
- package/build/development/server/index.js +142 -160
- package/build/development/server/index.js.map +1 -1
- package/build/development/server/renderer.js +150 -197
- package/build/development/server/renderer.js.map +1 -1
- package/build/development/server/server.js +63 -86
- package/build/development/server/server.js.map +1 -1
- package/build/development/server/utils/errors.js +72 -87
- package/build/development/server/utils/errors.js.map +1 -1
- package/build/development/shared/components/Button/index.js +8 -17
- package/build/development/shared/components/Button/index.js.map +1 -1
- package/build/development/shared/components/Checkbox/index.js +4 -4
- package/build/development/shared/components/Checkbox/index.js.map +1 -1
- package/build/development/shared/components/GenericLink/index.js +54 -58
- package/build/development/shared/components/GenericLink/index.js.map +1 -1
- package/build/development/shared/components/Input/index.js +16 -24
- package/build/development/shared/components/Input/index.js.map +1 -1
- package/build/development/shared/components/Link.js +2 -5
- package/build/development/shared/components/Link.js.map +1 -1
- package/build/development/shared/components/Modal/index.js +28 -41
- package/build/development/shared/components/Modal/index.js.map +1 -1
- package/build/development/shared/components/NavLink.js +2 -3
- package/build/development/shared/components/NavLink.js.map +1 -1
- package/build/development/shared/components/PageLayout/index.js +19 -20
- package/build/development/shared/components/PageLayout/index.js.map +1 -1
- package/build/development/shared/components/TextArea/index.js +12 -28
- package/build/development/shared/components/TextArea/index.js.map +1 -1
- package/build/development/shared/components/Throbber/index.js +11 -12
- package/build/development/shared/components/Throbber/index.js.map +1 -1
- package/build/development/shared/components/WithTooltip/Tooltip.js +46 -68
- package/build/development/shared/components/WithTooltip/Tooltip.js.map +1 -1
- package/build/development/shared/components/WithTooltip/index.js +21 -28
- package/build/development/shared/components/WithTooltip/index.js.map +1 -1
- package/build/development/shared/components/YouTubeVideo/index.js +21 -25
- package/build/development/shared/components/YouTubeVideo/index.js.map +1 -1
- package/build/development/shared/components/index.js +1 -3
- package/build/development/shared/components/index.js.map +1 -1
- package/build/development/shared/components/selectors/CustomDropdown/Options/index.js +6 -7
- package/build/development/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
- package/build/development/shared/components/selectors/CustomDropdown/index.js +7 -9
- package/build/development/shared/components/selectors/CustomDropdown/index.js.map +1 -1
- package/build/development/shared/components/selectors/NativeDropdown/index.js +23 -27
- package/build/development/shared/components/selectors/NativeDropdown/index.js.map +1 -1
- package/build/development/shared/components/selectors/Switch/index.js +4 -4
- package/build/development/shared/components/selectors/Switch/index.js.map +1 -1
- package/build/development/shared/components/selectors/common.js +2 -5
- package/build/development/shared/components/selectors/common.js.map +1 -1
- package/build/development/shared/utils/config.js +11 -15
- package/build/development/shared/utils/config.js.map +1 -1
- package/build/development/shared/utils/globalState.js +1 -7
- package/build/development/shared/utils/globalState.js.map +1 -1
- package/build/development/shared/utils/index.js +2 -2
- package/build/development/shared/utils/index.js.map +1 -1
- package/build/development/shared/utils/isomorphy/buildInfo.js +15 -24
- package/build/development/shared/utils/isomorphy/buildInfo.js.map +1 -1
- package/build/development/shared/utils/isomorphy/environment-check.js +4 -9
- package/build/development/shared/utils/isomorphy/environment-check.js.map +1 -1
- package/build/development/shared/utils/isomorphy/index.js +17 -23
- package/build/development/shared/utils/isomorphy/index.js.map +1 -1
- package/build/development/shared/utils/jest/E2eSsrEnv.js +48 -77
- package/build/development/shared/utils/jest/E2eSsrEnv.js.map +1 -1
- package/build/development/shared/utils/jest/index.js +48 -72
- package/build/development/shared/utils/jest/index.js.map +1 -1
- package/build/development/shared/utils/splitComponent.js +67 -74
- package/build/development/shared/utils/splitComponent.js.map +1 -1
- package/build/development/shared/utils/time.js +25 -28
- package/build/development/shared/utils/time.js.map +1 -1
- package/build/development/shared/utils/webpack.js +22 -29
- package/build/development/shared/utils/webpack.js.map +1 -1
- package/build/production/client/getInj.js.map +1 -1
- package/build/production/client/index.js.map +1 -1
- package/build/production/index.js +26 -1
- package/build/production/index.js.map +1 -1
- package/build/production/server/Cache.js.map +1 -1
- package/build/production/server/index.js.map +1 -1
- package/build/production/server/renderer.js.map +1 -1
- package/build/production/server/server.js.map +1 -1
- package/build/production/shared/components/Button/index.js.map +1 -1
- package/build/production/shared/components/Checkbox/index.js.map +1 -1
- package/build/production/shared/components/GenericLink/index.js +2 -2
- package/build/production/shared/components/GenericLink/index.js.map +1 -1
- package/build/production/shared/components/Input/index.js.map +1 -1
- package/build/production/shared/components/Link.js.map +1 -1
- package/build/production/shared/components/Modal/index.js.map +1 -1
- package/build/production/shared/components/NavLink.js.map +1 -1
- package/build/production/shared/components/PageLayout/index.js.map +1 -1
- package/build/production/shared/components/TextArea/index.js.map +1 -1
- package/build/production/shared/components/Throbber/index.js.map +1 -1
- package/build/production/shared/components/WithTooltip/index.js.map +1 -1
- package/build/production/shared/components/YouTubeVideo/index.js.map +1 -1
- package/build/production/shared/components/index.js.map +1 -1
- package/build/production/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
- package/build/production/shared/components/selectors/CustomDropdown/index.js.map +1 -1
- package/build/production/shared/components/selectors/NativeDropdown/index.js.map +1 -1
- package/build/production/shared/components/selectors/Switch/index.js.map +1 -1
- package/build/production/shared/utils/config.js.map +1 -1
- package/build/production/shared/utils/index.js.map +1 -1
- package/build/production/shared/utils/jest/index.js.map +1 -1
- package/build/production/shared/utils/splitComponent.js +20 -3
- package/build/production/shared/utils/splitComponent.js.map +1 -1
- package/build/production/shared/utils/time.js.map +1 -1
- package/build/production/shared/utils/webpack.js.map +1 -1
- package/build/types-code/shared/components/GenericLink/index.d.ts +0 -1
- package/build/web/client/getInj.js +10 -70
- package/build/web/client/getInj.js.map +1 -1
- package/build/web/client/index.js +2 -27
- package/build/web/client/index.js.map +1 -1
- package/build/web/client/init.js +10 -44
- package/build/web/client/init.js.map +1 -1
- package/build/web/index.js +26 -6
- package/build/web/index.js.map +1 -1
- package/build/web/server/Cache.js +3 -41
- package/build/web/server/Cache.js.map +1 -1
- package/build/web/server/index.js +7 -78
- package/build/web/server/index.js.map +1 -1
- package/build/web/server/renderer.js +61 -420
- package/build/web/server/renderer.js.map +1 -1
- package/build/web/server/server.js +38 -212
- package/build/web/server/server.js.map +1 -1
- package/build/web/server/utils/errors.js +9 -48
- package/build/web/server/utils/errors.js.map +1 -1
- package/build/web/server/utils/index.js +1 -2
- package/build/web/server/utils/index.js.map +1 -1
- package/build/web/shared/components/Button/index.js +12 -101
- package/build/web/shared/components/Button/index.js.map +1 -1
- package/build/web/shared/components/Checkbox/index.js +1 -40
- package/build/web/shared/components/Checkbox/index.js.map +1 -1
- package/build/web/shared/components/Checkbox/theme.scss +1 -0
- package/build/web/shared/components/GenericLink/index.js +12 -65
- package/build/web/shared/components/GenericLink/index.js.map +1 -1
- package/build/web/shared/components/GenericLink/style.scss +1 -0
- package/build/web/shared/components/Input/index.js +11 -69
- package/build/web/shared/components/Input/index.js.map +1 -1
- package/build/web/shared/components/Link.js +2 -12
- package/build/web/shared/components/Link.js.map +1 -1
- package/build/web/shared/components/Modal/index.js +10 -130
- package/build/web/shared/components/Modal/index.js.map +1 -1
- package/build/web/shared/components/NavLink.js +2 -10
- package/build/web/shared/components/NavLink.js.map +1 -1
- package/build/web/shared/components/PageLayout/index.js +2 -27
- package/build/web/shared/components/PageLayout/index.js.map +1 -1
- package/build/web/shared/components/TextArea/index.js +21 -106
- package/build/web/shared/components/TextArea/index.js.map +1 -1
- package/build/web/shared/components/Throbber/index.js +2 -24
- package/build/web/shared/components/Throbber/index.js.map +1 -1
- package/build/web/shared/components/WithTooltip/Tooltip.js +16 -145
- package/build/web/shared/components/WithTooltip/Tooltip.js.map +1 -1
- package/build/web/shared/components/WithTooltip/index.js +12 -104
- package/build/web/shared/components/WithTooltip/index.js.map +1 -1
- package/build/web/shared/components/YouTubeVideo/index.js +5 -43
- package/build/web/shared/components/YouTubeVideo/index.js.map +1 -1
- package/build/web/shared/components/index.js +1 -15
- package/build/web/shared/components/index.js.map +1 -1
- package/build/web/shared/components/selectors/CustomDropdown/Options/index.js +6 -81
- package/build/web/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
- package/build/web/shared/components/selectors/CustomDropdown/index.js +7 -122
- package/build/web/shared/components/selectors/CustomDropdown/index.js.map +1 -1
- package/build/web/shared/components/selectors/NativeDropdown/index.js +7 -68
- package/build/web/shared/components/selectors/NativeDropdown/index.js.map +1 -1
- package/build/web/shared/components/selectors/Switch/index.js +1 -49
- package/build/web/shared/components/selectors/Switch/index.js.map +1 -1
- package/build/web/shared/components/selectors/common.js +1 -10
- package/build/web/shared/components/selectors/common.js.map +1 -1
- package/build/web/shared/components/selectors/index.js +1 -3
- package/build/web/shared/components/selectors/index.js.map +1 -1
- package/build/web/shared/utils/config.js +6 -40
- package/build/web/shared/utils/config.js.map +1 -1
- package/build/web/shared/utils/globalState.js +2 -11
- package/build/web/shared/utils/globalState.js.map +1 -1
- package/build/web/shared/utils/index.js +1 -9
- package/build/web/shared/utils/index.js.map +1 -1
- package/build/web/shared/utils/isomorphy/buildInfo.js +4 -25
- package/build/web/shared/utils/isomorphy/buildInfo.js.map +1 -1
- package/build/web/shared/utils/isomorphy/environment-check.js +3 -9
- package/build/web/shared/utils/isomorphy/environment-check.js.map +1 -1
- package/build/web/shared/utils/isomorphy/index.js +5 -27
- package/build/web/shared/utils/isomorphy/index.js.map +1 -1
- package/build/web/shared/utils/jest/E2eSsrEnv.js +51 -221
- package/build/web/shared/utils/jest/E2eSsrEnv.js.map +1 -1
- package/build/web/shared/utils/jest/global.js +1 -3
- package/build/web/shared/utils/jest/global.js.map +1 -1
- package/build/web/shared/utils/jest/index.js +27 -146
- package/build/web/shared/utils/jest/index.js.map +1 -1
- package/build/web/shared/utils/splitComponent.js +34 -197
- package/build/web/shared/utils/splitComponent.js.map +1 -1
- package/build/web/shared/utils/time.js +5 -69
- package/build/web/shared/utils/time.js.map +1 -1
- package/build/web/shared/utils/webpack.js +6 -53
- package/build/web/shared/utils/webpack.js.map +1 -1
- package/config/babel/webpack.js +1 -1
- package/eslint.config.mjs +1 -0
- package/package.json +5 -8
- package/config/webpack/lib-base.d.ts +0 -22
- package/config/webpack/lib-base.js +0 -167
- package/config/webpack/lib-development.d.ts +0 -5
- package/config/webpack/lib-development.js +0 -35
- package/config/webpack/lib-production.d.ts +0 -5
- package/config/webpack/lib-production.js +0 -42
- package/webpack.config.ts +0 -49
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Babel config for compilation of helper scripts (bin-ts-src > bin).
|
|
2
|
+
|
|
3
|
+
/* global module */
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
plugins: [
|
|
7
|
+
['@babel/transform-runtime', { useESModules: true }],
|
|
8
|
+
],
|
|
9
|
+
presets: [
|
|
10
|
+
['@babel/env', {
|
|
11
|
+
bugfixes: true,
|
|
12
|
+
corejs: '3.49',
|
|
13
|
+
modules: false,
|
|
14
|
+
targets: 'maintained node versions',
|
|
15
|
+
useBuiltIns: 'usage',
|
|
16
|
+
}],
|
|
17
|
+
'@babel/typescript',
|
|
18
|
+
],
|
|
19
|
+
};
|
package/bin/build.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
/* eslint-disable no-console, import/no-extraneous-dependencies */
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
//* global console, process */
|
|
5
|
+
import "core-js/modules/es.iterator.constructor.js";
|
|
6
|
+
import "core-js/modules/es.iterator.for-each.js";
|
|
7
|
+
import "core-js/modules/es.iterator.map.js";
|
|
8
|
+
import "core-js/modules/es.json.stringify.js";
|
|
6
9
|
import childProcess from 'node:child_process';
|
|
7
10
|
import fs from 'node:fs';
|
|
8
11
|
import { createRequire } from 'node:module';
|
|
9
12
|
import path from 'node:path';
|
|
10
|
-
|
|
11
|
-
import { program } from 'commander';
|
|
12
13
|
import { mapValues, merge } from 'lodash-es';
|
|
13
14
|
|
|
14
15
|
// TODO: Disabled, because ESLint still does not support "exports" declarations
|
|
@@ -16,221 +17,330 @@ import { mapValues, merge } from 'lodash-es';
|
|
|
16
17
|
// See: https://github.com/import-js/eslint-plugin-import/issues/1810
|
|
17
18
|
// and update, once that issue is resolved.
|
|
18
19
|
import { rimraf } from 'rimraf';
|
|
20
|
+
import withWebpackBuild from 'webpack';
|
|
19
21
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
// TODO: Double-check, do we need it still? Can we do something better?
|
|
22
23
|
// To support TS configs for Webpack.
|
|
24
|
+
// @ts-expect-error "No types for this module exist yet"
|
|
23
25
|
import register from '@babel/register/experimental-worker.js';
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
DEVELOPMENT: 'development',
|
|
27
|
-
PRODUCTION: 'production',
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const VALID_BUILD_TYPES = Object.values(BUILD_TYPES);
|
|
31
|
-
|
|
26
|
+
import { program } from '@commander-js/extra-typings';
|
|
27
|
+
const validBuildTypes = ['app-development', 'app-production', 'library'];
|
|
32
28
|
/**
|
|
33
29
|
* Auxiliary wrapper around the command execution in a child process.
|
|
34
30
|
*
|
|
35
31
|
* TODO: Move to a server-side unitility module.
|
|
36
32
|
* TODO: The same code is duplicated in one of the tests.
|
|
37
|
-
*
|
|
38
|
-
* @param
|
|
39
|
-
* @param
|
|
40
|
-
* @return
|
|
33
|
+
*
|
|
34
|
+
* @param command - Command to execute;
|
|
35
|
+
* @param options - See https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback
|
|
36
|
+
* @return Resolves to { error, stdout, stderr }.
|
|
41
37
|
*/
|
|
42
38
|
async function exec(command, options = {}) {
|
|
43
|
-
return await new Promise(
|
|
44
|
-
const child = childProcess.exec(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
39
|
+
return await new Promise(resolve => {
|
|
40
|
+
const child = childProcess.exec(command, options, (error, stdout, stderr) => {
|
|
41
|
+
resolve({
|
|
42
|
+
error,
|
|
43
|
+
stderr,
|
|
44
|
+
stdout
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
child.stderr?.pipe(process.stderr);
|
|
48
|
+
child.stdout?.pipe(process.stdout);
|
|
51
49
|
});
|
|
52
50
|
}
|
|
53
51
|
|
|
54
52
|
/* Command-line config. */
|
|
55
|
-
program
|
|
56
|
-
.description('Library build script')
|
|
57
|
-
.option(
|
|
58
|
-
'-t, --build-type <type>',
|
|
59
|
-
`build type: ${VALID_BUILD_TYPES.join(', ')}`,
|
|
60
|
-
)
|
|
61
|
-
.option('-c, --copy-files <regex>', 'copy files matching the pattern into the build folder')
|
|
62
|
-
.option('-i, --in-dir <path>', 'input folder for the build', 'src')
|
|
63
|
-
.option('--lib', 'library build', false)
|
|
64
|
-
.option('--no-babel', 'opts out the Babel (server-side code) build')
|
|
65
|
-
.option('--no-webpack', 'opts out the Webpack (client-side code) build')
|
|
66
|
-
.option('-o, --out-dir <path>', 'output folder for the build', 'build')
|
|
67
|
-
.option('-w, --watch', 'build, watch, and rebuild on source changes')
|
|
68
|
-
.option('--babel-config <path>', 'path to the Babel config')
|
|
69
|
-
.option(
|
|
70
|
-
'--webpack-config <path>',
|
|
71
|
-
'path to the webpack config',
|
|
72
|
-
'webpack.config.js',
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
program.parse(process.argv);
|
|
76
|
-
const cmdLineArgs = program.opts();
|
|
77
|
-
|
|
78
|
-
const { buildType } = cmdLineArgs;
|
|
79
|
-
|
|
53
|
+
const args = program.description('Application / library build script').requiredOption('-t, --build-type <type>', `build type: ${validBuildTypes.map(type => `"${type}"`).join(', ')}`).option('-c, --copy-files <regex>', 'copy files matching the pattern into the build folder').option('-i, --in-dir <path>', 'input folder for the build', 'src').option('-o, --out-dir <path>', 'output folder for the build', 'build').option('-w, --watch', 'build, watch, and rebuild on source changes').option('--webpack-config <path>', 'path to the webpack config', 'webpack.config.ts').parse(process.argv).opts();
|
|
80
54
|
if (program.args.length) {
|
|
81
|
-
const details = program.args.map(
|
|
55
|
+
const details = program.args.map(x => `\t${x}`).join('\n');
|
|
82
56
|
program.error(`Unrecognized arguments:\n${details}`);
|
|
83
57
|
}
|
|
84
58
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
59
|
+
/**
|
|
60
|
+
* Asserts the given string is a valid build type.
|
|
61
|
+
*/
|
|
62
|
+
function assertBuildType(buildType) {
|
|
63
|
+
if (!validBuildTypes.includes(buildType)) {
|
|
64
|
+
throw Error('Unknown build type');
|
|
65
|
+
}
|
|
88
66
|
}
|
|
89
67
|
|
|
90
68
|
/* Resolves the target build directory. */
|
|
91
69
|
const cwd = process.cwd();
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
let outDir = path.resolve(cwd, cmdLineArgs.outDir);
|
|
95
|
-
if (cmdLineArgs.lib) outDir += `/${buildType}`;
|
|
70
|
+
const buildDir = path.resolve(cwd, args.outDir);
|
|
71
|
+
const sourceDir = path.resolve(cwd, args.inDir);
|
|
96
72
|
|
|
97
73
|
/* Prepares output directory: cleans existing files, creates the folders. */
|
|
98
|
-
rimraf.sync(
|
|
99
|
-
fs.mkdirSync(
|
|
100
|
-
|
|
101
|
-
/* ************************************************************************** */
|
|
102
|
-
/* Webpack compilation of isomorphic library bundle. */
|
|
103
|
-
|
|
104
|
-
register({
|
|
105
|
-
envName: 'production',
|
|
106
|
-
extensions: ['.js', '.jsx', '.ts', '.tsx', '.svg'],
|
|
107
|
-
root: process.cwd(),
|
|
74
|
+
rimraf.sync(buildDir);
|
|
75
|
+
fs.mkdirSync(buildDir, {
|
|
76
|
+
recursive: true
|
|
108
77
|
});
|
|
109
78
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
79
|
+
/**
|
|
80
|
+
* The build of TypeScript types for TS code modules.
|
|
81
|
+
*
|
|
82
|
+
* For now, it relies on the standard names of configuration files.
|
|
83
|
+
*/
|
|
84
|
+
async function buildCodeTypes() {
|
|
85
|
+
console.log('Building code types...');
|
|
86
|
+
await exec(`${cwd}/node_modules/.bin/tsc --project tsconfig.types.json`);
|
|
87
|
+
await exec(`${cwd}/node_modules/.bin/tsc-alias -p tsconfig.types.json`);
|
|
88
|
+
}
|
|
116
89
|
|
|
117
|
-
|
|
118
|
-
|
|
90
|
+
/**
|
|
91
|
+
* The build of TypeScript types for SCSS modules.
|
|
92
|
+
*
|
|
93
|
+
* As of now, all configuration comes from the "typed-scss-modules.config.ts"
|
|
94
|
+
* file, and we just assume it exists, and has a valid config, matching other
|
|
95
|
+
* configurations passed into this script, or selected automatically.
|
|
96
|
+
*/
|
|
97
|
+
async function buildScssTypes() {
|
|
98
|
+
console.log('Building SCSS types...');
|
|
99
|
+
await exec(`${cwd}/node_modules/.bin/typed-scss-modules .`);
|
|
100
|
+
}
|
|
101
|
+
let isRequireUpgraded = false;
|
|
102
|
+
const webpackOutDir = `${buildDir}/web-public`;
|
|
119
103
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
104
|
+
/**
|
|
105
|
+
* Creates a new Webpack compiler.
|
|
106
|
+
*/
|
|
107
|
+
function newWebpackCompiler() {
|
|
108
|
+
if (!isRequireUpgraded) {
|
|
109
|
+
isRequireUpgraded = true;
|
|
110
|
+
|
|
111
|
+
// TODO: We don't have types for this function, see a related comment
|
|
112
|
+
// earlier.
|
|
113
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
114
|
+
register({
|
|
115
|
+
envName: 'production',
|
|
116
|
+
extensions: ['.js', '.jsx', '.ts', '.tsx', '.svg'],
|
|
117
|
+
root: process.cwd()
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
const require = createRequire(import.meta.url);
|
|
121
|
+
|
|
122
|
+
// TODO: Search harder, perhaps such types are already declared by Webpack?
|
|
123
|
+
|
|
124
|
+
// TODO: Can we actually assert the input is a correct Webpack configuration?
|
|
125
|
+
// eslint-disable-next-line import/no-dynamic-require
|
|
126
|
+
const configFile = require(path.resolve(cwd, args.webpackConfig));
|
|
127
|
+
const configOrFactory = 'default' in configFile ? configFile.default : configFile;
|
|
128
|
+
if (!args.buildType) throw Error('Build type must be specified for Webpack build');
|
|
129
|
+
assertBuildType(args.buildType);
|
|
130
|
+
let webpackEnv;
|
|
131
|
+
switch (args.buildType) {
|
|
132
|
+
case 'app-development':
|
|
133
|
+
webpackEnv = 'development';
|
|
134
|
+
break;
|
|
135
|
+
case 'app-production':
|
|
136
|
+
webpackEnv = 'production';
|
|
137
|
+
break;
|
|
138
|
+
case 'library':
|
|
139
|
+
default:
|
|
140
|
+
throw Error('Unexpected build type');
|
|
141
|
+
}
|
|
142
|
+
const config = typeof configOrFactory === 'function' ? configOrFactory(webpackEnv) : configOrFactory;
|
|
143
|
+
merge(config, {
|
|
144
|
+
output: {
|
|
145
|
+
path: webpackOutDir
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
const webpackCompiler = withWebpackBuild(config);
|
|
123
149
|
|
|
124
|
-
|
|
150
|
+
// TODO: Do we need to connect it some other way to
|
|
151
|
+
// output progress with Webpack@5?
|
|
152
|
+
// webpackCompiler.apply(new webpack.ProgressPlugin());
|
|
125
153
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
// webpackCompiler.apply(new webpack.ProgressPlugin());
|
|
154
|
+
return webpackCompiler;
|
|
155
|
+
}
|
|
129
156
|
|
|
130
157
|
/**
|
|
131
158
|
* The handler of Webpack compilation results, written according to Webpack docs
|
|
132
159
|
* https://webpack.js.org/api/node/#error-handling
|
|
133
|
-
* @
|
|
134
|
-
* @param
|
|
135
|
-
* @param {Object} stats
|
|
160
|
+
* @param error
|
|
161
|
+
* @param stats
|
|
136
162
|
*/
|
|
137
163
|
function handleWebpackCompilationResults(error, stats) {
|
|
164
|
+
assertBuildType(args.buildType);
|
|
138
165
|
if (error) {
|
|
139
|
-
console.error(error.stack
|
|
140
|
-
if (error.
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
166
|
+
console.error(error.stack ?? error);
|
|
167
|
+
if (error.message) console.error(error.message);
|
|
168
|
+
process.exitCode = 1;
|
|
169
|
+
return;
|
|
145
170
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
process.exitCode = 1;
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
171
|
+
const info = stats?.toJson();
|
|
172
|
+
if (stats?.hasErrors()) {
|
|
173
|
+
console.error('Error defailts:', info?.errors);
|
|
174
|
+
process.exitCode = 1;
|
|
175
|
+
return;
|
|
154
176
|
}
|
|
155
|
-
if (stats
|
|
156
|
-
|
|
157
|
-
|
|
177
|
+
if (stats?.hasWarnings()) console.warn(info?.warnings);
|
|
178
|
+
console.log(stats?.toString({
|
|
179
|
+
colors: true
|
|
180
|
+
}));
|
|
158
181
|
|
|
159
182
|
// Here we emit the mapping of named chunk groups, needed at runtime
|
|
160
183
|
// for SSR and code-splitting.
|
|
161
|
-
const chunks = mapValues(
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
)
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
);
|
|
184
|
+
const chunks = mapValues(stats?.toJson({
|
|
185
|
+
all: false,
|
|
186
|
+
chunkGroups: true
|
|
187
|
+
}).namedChunkGroups, item => item.assets?.map(({
|
|
188
|
+
name
|
|
189
|
+
}) => name));
|
|
190
|
+
fs.writeFileSync(`${webpackOutDir}/__chunk_groups__.json`, JSON.stringify(chunks, null, 2));
|
|
169
191
|
}
|
|
170
192
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
193
|
+
/**
|
|
194
|
+
* Builds the app bundle for web.
|
|
195
|
+
*/
|
|
196
|
+
function buildWebBundle() {
|
|
197
|
+
const webpackCompiler = newWebpackCompiler();
|
|
198
|
+
webpackCompiler.run(handleWebpackCompilationResults);
|
|
199
|
+
webpackCompiler.close(() => undefined);
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Runs Babel compilation.
|
|
203
|
+
* @param buildType - Build type; one of the BUILD_TYPES values.
|
|
204
|
+
* @param configPath - Optional. Path to the config file.
|
|
205
|
+
* If relative, it will be resolved relative to the current working directory.
|
|
206
|
+
* If absent, Babel will try to locate the default config file its usual way.
|
|
207
|
+
* @param extensions - Optional. Array of extensions
|
|
208
|
+
* to transform, each starting with the leading dot (e.g. '.ts'). If absent,
|
|
209
|
+
* Babel will use its default set of extensions.
|
|
210
|
+
* @param keepFileExtensions - Optional. If set, Babel will
|
|
211
|
+
* keep the original extensions for the transformed files; otherwise the will
|
|
212
|
+
* be turned into '.js' files.
|
|
213
|
+
* @param outDir - Output folder.
|
|
214
|
+
* @param srcDir - Source folder.
|
|
215
|
+
* @param watch - Optional. If set, Babel will be run in watch
|
|
216
|
+
* mode.
|
|
217
|
+
*/
|
|
218
|
+
async function runBabel({
|
|
219
|
+
buildType,
|
|
220
|
+
configPath,
|
|
221
|
+
copyFiles,
|
|
222
|
+
extensions,
|
|
223
|
+
keepFileExtensions,
|
|
224
|
+
outDir,
|
|
225
|
+
srcDir,
|
|
226
|
+
watch
|
|
227
|
+
}) {
|
|
228
|
+
let command = `${cwd}/node_modules/.bin/babel ${srcDir} --out-dir ${outDir} --source-maps`;
|
|
229
|
+
if (buildType === 'production') command += ' --minified';
|
|
230
|
+
if (configPath) {
|
|
231
|
+
const url = path.resolve(cwd, configPath);
|
|
232
|
+
command += ` --config-file ${url}`;
|
|
177
233
|
}
|
|
234
|
+
if (copyFiles) command += ' --copy-files';
|
|
235
|
+
command += ` -x ${extensions.join(',')}`;
|
|
236
|
+
if (keepFileExtensions) command += ' --keep-file-extension';
|
|
237
|
+
if (watch) command += ' --watch';
|
|
238
|
+
await exec(command, {
|
|
239
|
+
env: {
|
|
240
|
+
...process.env,
|
|
241
|
+
BABEL_ENV: buildType
|
|
242
|
+
}
|
|
243
|
+
});
|
|
178
244
|
}
|
|
179
245
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
246
|
+
/**
|
|
247
|
+
* Builds the "intermediate" library code with Babel. Essentially, it compiles
|
|
248
|
+
* out TypeScript, and produces JavaScript code which should be further compiled
|
|
249
|
+
* with Babel for server-side use, or bundled with Webpack for client-side
|
|
250
|
+
* execution. Any non-TS assets in the source are copied over to the build
|
|
251
|
+
* folder, conserving their location relative to the source / build folder root.
|
|
252
|
+
* @param watch
|
|
253
|
+
*/
|
|
254
|
+
async function buildLibIntermediates(watch) {
|
|
255
|
+
if (!watch) console.log('Building library intermediates...');
|
|
256
|
+
await runBabel({
|
|
257
|
+
buildType: 'production',
|
|
258
|
+
configPath: './babel.libweb.config.js',
|
|
259
|
+
copyFiles: true,
|
|
260
|
+
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
|
261
|
+
outDir: `${buildDir}/web`,
|
|
262
|
+
srcDir: sourceDir,
|
|
263
|
+
watch
|
|
264
|
+
});
|
|
197
265
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
await
|
|
266
|
+
/**
|
|
267
|
+
* Builds with Babel the library code for server-side environment.
|
|
268
|
+
*/
|
|
269
|
+
async function buildWithBabelForServerSide({
|
|
270
|
+
buildType,
|
|
271
|
+
configPath,
|
|
272
|
+
outDir,
|
|
273
|
+
srcDir
|
|
274
|
+
}) {
|
|
275
|
+
console.log(`Building with Babel for server-side environment in "${buildType}" mode...`);
|
|
276
|
+
await runBabel({
|
|
277
|
+
buildType,
|
|
278
|
+
configPath,
|
|
279
|
+
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
|
280
|
+
outDir,
|
|
281
|
+
srcDir
|
|
282
|
+
});
|
|
283
|
+
await runBabel({
|
|
284
|
+
buildType,
|
|
285
|
+
configPath,
|
|
286
|
+
extensions: ['.svg'],
|
|
287
|
+
keepFileExtensions: true,
|
|
288
|
+
outDir,
|
|
289
|
+
srcDir
|
|
290
|
+
});
|
|
216
291
|
}
|
|
217
292
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
293
|
+
/**
|
|
294
|
+
* Copies the files matching the pattern into the build folder.
|
|
295
|
+
*/
|
|
222
296
|
function copyFromFolder(from, to, regex) {
|
|
223
|
-
|
|
297
|
+
console.log('Copying files...');
|
|
298
|
+
fs.readdirSync(from, {
|
|
299
|
+
withFileTypes: true
|
|
300
|
+
}).forEach(item => {
|
|
224
301
|
if (item.isDirectory()) {
|
|
225
302
|
copyFromFolder(`${from}/${item.name}`, `${to}/${item.name}`, regex);
|
|
226
303
|
} else if (item.isFile() && item.name.match(regex)) {
|
|
227
|
-
fs.mkdirSync(to, {
|
|
304
|
+
fs.mkdirSync(to, {
|
|
305
|
+
recursive: true
|
|
306
|
+
});
|
|
228
307
|
fs.copyFileSync(`${from}/${item.name}`, `${to}/${item.name}`);
|
|
229
308
|
}
|
|
230
309
|
});
|
|
231
310
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
311
|
+
void (async () => {
|
|
312
|
+
assertBuildType(args.buildType);
|
|
313
|
+
await buildScssTypes();
|
|
314
|
+
if (args.buildType === 'library') {
|
|
315
|
+
await buildCodeTypes();
|
|
316
|
+
await buildLibIntermediates();
|
|
317
|
+
await buildWithBabelForServerSide({
|
|
318
|
+
buildType: 'development',
|
|
319
|
+
configPath: 'babel.module.config.js',
|
|
320
|
+
outDir: `${buildDir}/development`,
|
|
321
|
+
srcDir: `${buildDir}/web`
|
|
322
|
+
});
|
|
323
|
+
await buildWithBabelForServerSide({
|
|
324
|
+
buildType: 'production',
|
|
325
|
+
configPath: 'babel.module.config.js',
|
|
326
|
+
outDir: `${buildDir}/production`,
|
|
327
|
+
srcDir: `${buildDir}/web`
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
if (args.buildType === 'app-development' || args.buildType === 'app-production') {
|
|
331
|
+
await buildWithBabelForServerSide({
|
|
332
|
+
buildType: 'development',
|
|
333
|
+
outDir: buildDir,
|
|
334
|
+
srcDir: sourceDir
|
|
335
|
+
});
|
|
336
|
+
buildWebBundle();
|
|
337
|
+
}
|
|
338
|
+
if (args.copyFiles) {
|
|
339
|
+
const regex = new RegExp(args.copyFiles);
|
|
340
|
+
copyFromFolder(sourceDir, buildDir, regex);
|
|
341
|
+
}
|
|
342
|
+
if (args.watch) {
|
|
343
|
+
console.log('Enabling the watch mode...');
|
|
344
|
+
if (args.buildType === 'library') await buildLibIntermediates(true);
|
|
345
|
+
}
|
|
346
|
+
})();
|
|
@@ -4,33 +4,28 @@ import "core-js/modules/es.array-buffer.transfer-to-fixed-length.js";
|
|
|
4
4
|
import "core-js/modules/es.typed-array.to-reversed.js";
|
|
5
5
|
import "core-js/modules/es.typed-array.to-sorted.js";
|
|
6
6
|
import "core-js/modules/es.typed-array.with.js";
|
|
7
|
-
import "core-js/modules/web.dom-exception.stack.js";
|
|
8
|
-
// Encapsulates retrieval of server-side data injection into HTML template.
|
|
9
|
-
|
|
7
|
+
import "core-js/modules/web.dom-exception.stack.js"; // Encapsulates retrieval of server-side data injection into HTML template.
|
|
10
8
|
/* global document */
|
|
11
|
-
|
|
12
|
-
import { SEC_MS, timer } from '@dr.pogodin/js-utils';
|
|
9
|
+
import { SEC_MS, timer } from "@dr.pogodin/js-utils";
|
|
13
10
|
import { getBuildInfo } from "../shared/utils/isomorphy/buildInfo.js";
|
|
14
11
|
let inj;
|
|
15
12
|
export default function getInj() {
|
|
16
13
|
inj ??= (async () => {
|
|
17
|
-
const metaElement = typeof document ===
|
|
14
|
+
const metaElement = typeof document === "undefined" ? null : document.querySelector("meta[itemprop=\"drpruinj\"]");
|
|
18
15
|
if (metaElement) {
|
|
19
|
-
metaElement.remove();
|
|
20
|
-
|
|
21
|
-
// NOTE: Since 2025 there is Uint8Array.fromBase64(), which should be
|
|
16
|
+
metaElement.remove(); // NOTE: Since 2025 there is Uint8Array.fromBase64(), which should be
|
|
22
17
|
// preferred, but it is not supported by older environments yet.
|
|
23
18
|
const data = atob(metaElement.content);
|
|
24
19
|
if (!window.isSecureContext) {
|
|
25
|
-
if (window.location.protocol ===
|
|
26
|
-
throw Error(
|
|
27
|
-
} else if (window.location.protocol !==
|
|
28
|
-
throw Error(
|
|
20
|
+
if (window.location.protocol === "https:") {
|
|
21
|
+
throw Error("Loaded via HTTPS, but it is not considered a secure context");
|
|
22
|
+
} else if (window.location.protocol !== "http:") {
|
|
23
|
+
throw Error("Unexpected protocol");
|
|
29
24
|
}
|
|
30
|
-
const target = window.location.href.replace(/^http:/,
|
|
25
|
+
const target = window.location.href.replace(/^http:/, "https:");
|
|
31
26
|
window.location.replace(target);
|
|
32
27
|
await timer(3 * SEC_MS);
|
|
33
|
-
throw Error(
|
|
28
|
+
throw Error("Failed to move into secure context");
|
|
34
29
|
}
|
|
35
30
|
const {
|
|
36
31
|
key
|
|
@@ -39,29 +34,23 @@ export default function getInj() {
|
|
|
39
34
|
const dataBuffer = Uint8Array.from(data.slice(16), code);
|
|
40
35
|
const ivBuffer = Uint8Array.from(data.slice(0, 16), code);
|
|
41
36
|
const keyBuffer = Uint8Array.from(atob(key), code);
|
|
42
|
-
const cKey = await window.crypto.subtle.importKey(
|
|
43
|
-
name:
|
|
44
|
-
}, false, [
|
|
37
|
+
const cKey = await window.crypto.subtle.importKey("raw", keyBuffer, {
|
|
38
|
+
name: "AES-CBC"
|
|
39
|
+
}, false, ["decrypt"]);
|
|
45
40
|
const buffer = await window.crypto.subtle.decrypt({
|
|
46
41
|
iv: ivBuffer,
|
|
47
|
-
name:
|
|
42
|
+
name: "AES-CBC"
|
|
48
43
|
}, cKey, dataBuffer);
|
|
49
|
-
const decoder = new TextDecoder();
|
|
50
|
-
|
|
51
|
-
// eslint-disable-next-line no-eval
|
|
52
|
-
const res = eval(`(${decoder.decode(buffer)})`);
|
|
53
|
-
|
|
54
|
-
// NOTE: This is important, to be able to return the injection
|
|
44
|
+
const decoder = new TextDecoder(); // eslint-disable-next-line no-eval
|
|
45
|
+
const res = eval(`(${decoder.decode(buffer)})`); // NOTE: This is important, to be able to return the injection
|
|
55
46
|
// synchronously once it is initialized.
|
|
56
47
|
inj = res;
|
|
57
48
|
return res;
|
|
58
|
-
} else if (typeof window !==
|
|
49
|
+
} else if (typeof window !== "undefined" && window.REACT_UTILS_INJECTION) {
|
|
59
50
|
const res = window.REACT_UTILS_INJECTION;
|
|
60
51
|
delete window.REACT_UTILS_INJECTION;
|
|
61
52
|
return res;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// Otherwise, a bunch of dependent stuff will easily fail in non-standard
|
|
53
|
+
} // Otherwise, a bunch of dependent stuff will easily fail in non-standard
|
|
65
54
|
// environments, where no client-side initialization is performed. Like tests,
|
|
66
55
|
// Docusaurus examples, etc.
|
|
67
56
|
return {};
|
|
@@ -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":"
|
|
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":[]}
|