@dr.pogodin/react-utils 1.49.1 → 1.50.0
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/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/bin/build.js +0 -236
- 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
|
@@ -1,45 +1,11 @@
|
|
|
1
|
-
/* global document */
|
|
2
|
-
|
|
3
|
-
import { parse } from 'cookie';
|
|
4
|
-
import clientGetInj from "../../client/getInj";
|
|
5
|
-
import { IS_CLIENT_SIDE } from "./isomorphy/environment-check";
|
|
6
|
-
import { requireWeak } from "./webpack";
|
|
7
|
-
let config;
|
|
8
|
-
|
|
9
|
-
/**
|
|
1
|
+
/* global document */import{parse}from"cookie";import clientGetInj from"../../client/getInj";import{IS_CLIENT_SIDE}from"./isomorphy/environment-check";import{requireWeak}from"./webpack";let config;/**
|
|
10
2
|
* Injects CSRF token into config (on client-side only).
|
|
11
3
|
*
|
|
12
4
|
* BEWARE: It mutates the argument, and also returns it as the result,
|
|
13
5
|
* for chaining.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (IS_CLIENT_SIDE && typeof document !== 'undefined') {
|
|
20
|
-
// eslint-disable-next-line no-param-reassign
|
|
21
|
-
cfg.CSRF = parse(document.cookie).csrfToken;
|
|
22
|
-
}
|
|
23
|
-
return cfg;
|
|
24
|
-
}
|
|
25
|
-
export function getConfig(sync) {
|
|
26
|
-
if (!config) {
|
|
27
|
-
if (IS_CLIENT_SIDE) {
|
|
28
|
-
const inj = clientGetInj();
|
|
29
|
-
config = inj instanceof Promise ? inj.then(injection => {
|
|
30
|
-
const res = injectCsrfToken(injection.CONFIG ?? {});
|
|
31
|
-
config = res;
|
|
32
|
-
return res;
|
|
33
|
-
}) : injectCsrfToken(inj.CONFIG ?? {});
|
|
34
|
-
} else {
|
|
35
|
-
const weak = requireWeak('config');
|
|
36
|
-
if (!weak) throw Error('Internal error');
|
|
37
|
-
config = weak;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
if (sync && config instanceof Promise) {
|
|
41
|
-
throw Error('The config is not available yet');
|
|
42
|
-
}
|
|
43
|
-
return config;
|
|
44
|
-
}
|
|
6
|
+
*/function injectCsrfToken(cfg){// The safeguard for "document" is necessary because in non-Node environments,
|
|
7
|
+
// like React Native, IS_CLIENT_SIDE is "true", however "document" and a bunch
|
|
8
|
+
// of other browser-world features are not available.
|
|
9
|
+
if(IS_CLIENT_SIDE&&typeof document!=="undefined"){// eslint-disable-next-line no-param-reassign
|
|
10
|
+
cfg.CSRF=parse(document.cookie).csrfToken;}return cfg;}export function getConfig(sync){if(!config){if(IS_CLIENT_SIDE){const inj=clientGetInj();config=inj instanceof Promise?inj.then(injection=>{const res=injectCsrfToken(injection.CONFIG??{});config=res;return res;}):injectCsrfToken(inj.CONFIG??{});}else{const weak=requireWeak("config");if(!weak)throw Error("Internal error");config=weak;}}if(sync&&config instanceof Promise){throw Error("The config is not available yet");}return config;}
|
|
45
11
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","names":["parse","clientGetInj","IS_CLIENT_SIDE","requireWeak","config","injectCsrfToken","cfg","document","CSRF","cookie","csrfToken","getConfig","sync","inj","Promise","then","injection","res","CONFIG","weak","Error"],"sources":["../../../../src/shared/utils/config.ts"],"sourcesContent":["/* global document */\n\nimport { parse } from 'cookie';\n\nimport clientGetInj from '../../client/getInj';\n\nimport { IS_CLIENT_SIDE } from './isomorphy/environment-check';\nimport { requireWeak } from './webpack';\n\ntype ConfigT = Record<string, unknown>;\n\nlet config: ConfigT | Promise<ConfigT> | undefined;\n\n/**\n * Injects CSRF token into config (on client-side only).\n *\n * BEWARE: It mutates the argument, and also returns it as the result,\n * for chaining.\n */\nfunction injectCsrfToken(cfg: ConfigT): ConfigT {\n // The safeguard for \"document\" is necessary because in non-Node environments,\n // like React Native, IS_CLIENT_SIDE is \"true\", however \"document\" and a bunch\n // of other browser-world features are not available.\n if (IS_CLIENT_SIDE && typeof document !== 'undefined') {\n // eslint-disable-next-line no-param-reassign\n cfg.CSRF = parse(document.cookie).csrfToken;\n }\n\n return cfg;\n}\n\nexport function getConfig<T extends ConfigT>(sync: true): T;\n\nexport function getConfig<T extends ConfigT>(sync?: boolean): Promise<T> | T;\n\nexport function getConfig<T extends ConfigT>(sync?: boolean): Promise<T> | T {\n if (!config) {\n if (IS_CLIENT_SIDE) {\n const inj = clientGetInj();\n config = inj instanceof Promise\n ? inj.then((injection) => {\n const res = injectCsrfToken(injection.CONFIG ?? {});\n config = res;\n return res;\n })\n : injectCsrfToken(inj.CONFIG ?? {});\n } else {\n const weak = requireWeak<ConfigT>('config');\n if (!weak) throw Error('Internal error');\n config = weak;\n }\n }\n\n if (sync && (config instanceof Promise)) {\n throw Error('The config is not available yet');\n }\n\n return config as T;\n}\n"],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"config.js","names":["parse","clientGetInj","IS_CLIENT_SIDE","requireWeak","config","injectCsrfToken","cfg","document","CSRF","cookie","csrfToken","getConfig","sync","inj","Promise","then","injection","res","CONFIG","weak","Error"],"sources":["../../../../src/shared/utils/config.ts"],"sourcesContent":["/* global document */\n\nimport { parse } from 'cookie';\n\nimport clientGetInj from '../../client/getInj';\n\nimport { IS_CLIENT_SIDE } from './isomorphy/environment-check';\nimport { requireWeak } from './webpack';\n\ntype ConfigT = Record<string, unknown>;\n\nlet config: ConfigT | Promise<ConfigT> | undefined;\n\n/**\n * Injects CSRF token into config (on client-side only).\n *\n * BEWARE: It mutates the argument, and also returns it as the result,\n * for chaining.\n */\nfunction injectCsrfToken(cfg: ConfigT): ConfigT {\n // The safeguard for \"document\" is necessary because in non-Node environments,\n // like React Native, IS_CLIENT_SIDE is \"true\", however \"document\" and a bunch\n // of other browser-world features are not available.\n if (IS_CLIENT_SIDE && typeof document !== 'undefined') {\n // eslint-disable-next-line no-param-reassign\n cfg.CSRF = parse(document.cookie).csrfToken;\n }\n\n return cfg;\n}\n\nexport function getConfig<T extends ConfigT>(sync: true): T;\n\nexport function getConfig<T extends ConfigT>(sync?: boolean): Promise<T> | T;\n\nexport function getConfig<T extends ConfigT>(sync?: boolean): Promise<T> | T {\n if (!config) {\n if (IS_CLIENT_SIDE) {\n const inj = clientGetInj();\n config = inj instanceof Promise\n ? inj.then((injection) => {\n const res = injectCsrfToken(injection.CONFIG ?? {});\n config = res;\n return res;\n })\n : injectCsrfToken(inj.CONFIG ?? {});\n } else {\n const weak = requireWeak<ConfigT>('config');\n if (!weak) throw Error('Internal error');\n config = weak;\n }\n }\n\n if (sync && (config instanceof Promise)) {\n throw Error('The config is not available yet');\n }\n\n return config as T;\n}\n"],"mappings":"AAAA,qBAEA,OAASA,KAAK,KAAQ,QAAQ,CAE9B,MAAO,CAAAC,YAAY,2BAEnB,OAASC,cAAc,qCACvB,OAASC,WAAW,iBAIpB,GAAI,CAAAC,MAA8C,CAElD;AACA;AACA;AACA;AACA;AACA,GACA,QAAS,CAAAC,eAAeA,CAACC,GAAY,CAAW,CAC9C;AACA;AACA;AACA,GAAIJ,cAAc,EAAI,MAAO,CAAAK,QAAQ,GAAK,WAAW,CAAE,CACrD;AACAD,GAAG,CAACE,IAAI,CAAGR,KAAK,CAACO,QAAQ,CAACE,MAAM,CAAC,CAACC,SAAS,CAC7C,CAEA,MAAO,CAAAJ,GAAG,CACZ,CAMA,MAAO,SAAS,CAAAK,SAASA,CAAoBC,IAAc,CAAkB,CAC3E,GAAI,CAACR,MAAM,CAAE,CACX,GAAIF,cAAc,CAAE,CAClB,KAAM,CAAAW,GAAG,CAAGZ,YAAY,CAAC,CAAC,CAC1BG,MAAM,CAAGS,GAAG,WAAY,CAAAC,OAAO,CAC3BD,GAAG,CAACE,IAAI,CAAEC,SAAS,EAAK,CACxB,KAAM,CAAAC,GAAG,CAAGZ,eAAe,CAACW,SAAS,CAACE,MAAM,EAAI,CAAC,CAAC,CAAC,CACnDd,MAAM,CAAGa,GAAG,CACZ,MAAO,CAAAA,GAAG,CACZ,CAAC,CAAC,CACAZ,eAAe,CAACQ,GAAG,CAACK,MAAM,EAAI,CAAC,CAAC,CAAC,CACvC,CAAC,IAAM,CACL,KAAM,CAAAC,IAAI,CAAGhB,WAAW,CAAU,QAAQ,CAAC,CAC3C,GAAI,CAACgB,IAAI,CAAE,KAAM,CAAAC,KAAK,CAAC,gBAAgB,CAAC,CACxChB,MAAM,CAAGe,IAAI,CACf,CACF,CAEA,GAAIP,IAAI,EAAKR,MAAM,WAAY,CAAAU,OAAQ,CAAE,CACvC,KAAM,CAAAM,KAAK,CAAC,iCAAiC,CAAC,CAChD,CAEA,MAAO,CAAAhB,MAAM,CACf","ignoreList":[]}
|
|
@@ -1,15 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
/** Mapping "chunkName" > array of asset paths. */
|
|
4
|
-
|
|
5
|
-
// The type of data object injected by server into generated markup.
|
|
6
|
-
|
|
1
|
+
import{withGlobalStateType}from"@dr.pogodin/react-global-state";/** Mapping "chunkName" > array of asset paths. */// The type of data object injected by server into generated markup.
|
|
7
2
|
// TODO: Not 100% sure now, whether it indeed can be replaced by type,
|
|
8
3
|
// or do we really need it to be an interface. Keeping the interface for now.
|
|
9
4
|
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
|
|
10
|
-
|
|
11
|
-
const {
|
|
12
|
-
getSsrContext
|
|
13
|
-
} = withGlobalStateType();
|
|
14
|
-
export { getSsrContext };
|
|
5
|
+
const{getSsrContext}=withGlobalStateType();export{getSsrContext};
|
|
15
6
|
//# sourceMappingURL=globalState.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globalState.js","names":["withGlobalStateType","getSsrContext"],"sources":["../../../../src/shared/utils/globalState.ts"],"sourcesContent":["import type { Request } from 'express';\n\nimport { type SsrContext, withGlobalStateType } from '@dr.pogodin/react-global-state';\n\n/** Mapping \"chunkName\" > array of asset paths. */\nexport type ChunkGroupsT = Record<string, string[]>;\n\n// The type of data object injected by server into generated markup.\nexport type InjT = {\n CHUNK_GROUPS?: ChunkGroupsT;\n CONFIG?: Record<string, unknown>;\n ISTATE?: unknown;\n};\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/consistent-type-definitions\n interface Window {\n REACT_UTILS_INJECTION?: InjT;\n }\n}\n\n// TODO: Not 100% sure now, whether it indeed can be replaced by type,\n// or do we really need it to be an interface. Keeping the interface for now.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface SsrContextT<StateT> extends SsrContext<StateT> {\n chunkGroups: ChunkGroupsT;\n chunks: string[];\n\n /** If set at the end of SSR, the rendered will trigger\n * server-side redirect to this URL (and use the status\n * code). */\n redirectTo?: string;\n\n req: Request;\n status: number;\n}\n\nconst {\n getSsrContext,\n} = withGlobalStateType<unknown, SsrContextT<unknown>>();\n\nexport {\n getSsrContext,\n};\n"],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"globalState.js","names":["withGlobalStateType","getSsrContext"],"sources":["../../../../src/shared/utils/globalState.ts"],"sourcesContent":["import type { Request } from 'express';\n\nimport { type SsrContext, withGlobalStateType } from '@dr.pogodin/react-global-state';\n\n/** Mapping \"chunkName\" > array of asset paths. */\nexport type ChunkGroupsT = Record<string, string[]>;\n\n// The type of data object injected by server into generated markup.\nexport type InjT = {\n CHUNK_GROUPS?: ChunkGroupsT;\n CONFIG?: Record<string, unknown>;\n ISTATE?: unknown;\n};\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/consistent-type-definitions\n interface Window {\n REACT_UTILS_INJECTION?: InjT;\n }\n}\n\n// TODO: Not 100% sure now, whether it indeed can be replaced by type,\n// or do we really need it to be an interface. Keeping the interface for now.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface SsrContextT<StateT> extends SsrContext<StateT> {\n chunkGroups: ChunkGroupsT;\n chunks: string[];\n\n /** If set at the end of SSR, the rendered will trigger\n * server-side redirect to this URL (and use the status\n * code). */\n redirectTo?: string;\n\n req: Request;\n status: number;\n}\n\nconst {\n getSsrContext,\n} = withGlobalStateType<unknown, SsrContextT<unknown>>();\n\nexport {\n getSsrContext,\n};\n"],"mappings":"AAEA,OAA0BA,mBAAmB,KAAQ,gCAAgC,CAErF,kDAGA;AAcA;AACA;AACA;AAcA,KAAM,CACJC,aACF,CAAC,CAAGD,mBAAmB,CAAgC,CAAC,CAExD,OACEC,aAAa","ignoreList":[]}
|
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import * as isomorphy from "./isomorphy";
|
|
3
|
-
import time from "./time";
|
|
4
|
-
import * as webpack from "./webpack";
|
|
5
|
-
export { Barrier, Cached, Emitter, Semaphore, assertEmptyObject, withRetries } from '@dr.pogodin/js-utils';
|
|
6
|
-
export { COMPOSE as THEME_COMPOSE, PRIORITY as THEME_PRIORITY, ThemeProvider, useTheme } from '@dr.pogodin/react-themes';
|
|
7
|
-
export { getSsrContext } from "./globalState";
|
|
8
|
-
export { default as splitComponent } from "./splitComponent";
|
|
9
|
-
export { getConfig, isomorphy, time, webpack };
|
|
1
|
+
import{getConfig}from"./config";import*as isomorphy from"./isomorphy";import time from"./time";import*as webpack from"./webpack";export{Barrier,Cached,Emitter,Semaphore,assertEmptyObject,withRetries}from"@dr.pogodin/js-utils";export{COMPOSE as THEME_COMPOSE,PRIORITY as THEME_PRIORITY,ThemeProvider,useTheme}from"@dr.pogodin/react-themes";export{getSsrContext}from"./globalState";export{default as splitComponent}from"./splitComponent";export{getConfig,isomorphy,time,webpack};
|
|
10
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["getConfig","isomorphy","time","webpack","Barrier","Cached","Emitter","Semaphore","assertEmptyObject","withRetries","COMPOSE","THEME_COMPOSE","PRIORITY","THEME_PRIORITY","ThemeProvider","useTheme","getSsrContext","default","splitComponent"],"sources":["../../../../src/shared/utils/index.ts"],"sourcesContent":["import { getConfig } from './config';\nimport * as isomorphy from './isomorphy';\nimport time from './time';\nimport * as webpack from './webpack';\n\nexport {\n Barrier,\n Cached,\n Emitter,\n type Listener,\n type ObjectKey,\n Semaphore,\n assertEmptyObject,\n withRetries,\n} from '@dr.pogodin/js-utils';\n\nexport {\n COMPOSE as THEME_COMPOSE,\n PRIORITY as THEME_PRIORITY,\n type Theme,\n ThemeProvider,\n useTheme,\n} from '@dr.pogodin/react-themes';\n\nexport { getSsrContext } from './globalState';\nexport { default as splitComponent } from './splitComponent';\n\nexport {\n getConfig,\n isomorphy,\n time,\n webpack,\n};\n"],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","names":["getConfig","isomorphy","time","webpack","Barrier","Cached","Emitter","Semaphore","assertEmptyObject","withRetries","COMPOSE","THEME_COMPOSE","PRIORITY","THEME_PRIORITY","ThemeProvider","useTheme","getSsrContext","default","splitComponent"],"sources":["../../../../src/shared/utils/index.ts"],"sourcesContent":["import { getConfig } from './config';\nimport * as isomorphy from './isomorphy';\nimport time from './time';\nimport * as webpack from './webpack';\n\nexport {\n Barrier,\n Cached,\n Emitter,\n type Listener,\n type ObjectKey,\n Semaphore,\n assertEmptyObject,\n withRetries,\n} from '@dr.pogodin/js-utils';\n\nexport {\n COMPOSE as THEME_COMPOSE,\n PRIORITY as THEME_PRIORITY,\n type Theme,\n ThemeProvider,\n useTheme,\n} from '@dr.pogodin/react-themes';\n\nexport { getSsrContext } from './globalState';\nexport { default as splitComponent } from './splitComponent';\n\nexport {\n getConfig,\n isomorphy,\n time,\n webpack,\n};\n"],"mappings":"AAAA,OAASA,SAAS,gBAClB,MAAO,GAAK,CAAAC,SAAS,mBACrB,MAAO,CAAAC,IAAI,cACX,MAAO,GAAK,CAAAC,OAAO,iBAEnB,OACEC,OAAO,CACPC,MAAM,CACNC,OAAO,CAGPC,SAAS,CACTC,iBAAiB,CACjBC,WAAW,KACN,sBAAsB,CAE7B,OACEC,OAAO,GAAI,CAAAC,aAAa,CACxBC,QAAQ,GAAI,CAAAC,cAAc,CAE1BC,aAAa,CACbC,QAAQ,KACH,0BAA0B,CAEjC,OAASC,aAAa,qBACtB,OAASC,OAAO,GAAI,CAAAC,cAAc,wBAElC,OACElB,SAAS,CACTC,SAAS,CACTC,IAAI,CACJC,OAAO","ignoreList":[]}
|
|
@@ -1,44 +1,23 @@
|
|
|
1
1
|
// Encapsulates access to "Build Info" data.
|
|
2
|
-
|
|
3
2
|
// BEWARE: This should match the type of build info object generated by
|
|
4
3
|
// Webpack build (see "/config/webpack/app-base.js"), and currently this
|
|
5
4
|
// match is not checked automatically.
|
|
6
|
-
|
|
7
5
|
// Depending on the build mode & environment, BUILD_INFO is either a global
|
|
8
6
|
// variable defined at the app launch, or it is replaced by the actual value
|
|
9
7
|
// by the Webpack build.
|
|
10
|
-
|
|
11
|
-
let buildInfo;
|
|
12
|
-
|
|
13
|
-
// On the client side "BUILD_INFO" should be injected by Webpack. Note, however,
|
|
8
|
+
let buildInfo;// On the client side "BUILD_INFO" should be injected by Webpack. Note, however,
|
|
14
9
|
// that in test environment we may need situations were environment is mocked as
|
|
15
10
|
// client-side, although no proper Webpack compilation is executed, thus no info
|
|
16
11
|
// injected; because of this we don't do a hard environment check here.
|
|
17
|
-
if
|
|
18
|
-
|
|
19
|
-
/**
|
|
12
|
+
if(typeof BUILD_INFO!=="undefined")buildInfo=BUILD_INFO;/**
|
|
20
13
|
* In scenarious where "BUILD_INFO" is not injected by Webpack (server-side,
|
|
21
14
|
* tests, etc.) we expect the host codebase to explicitly set it before it is
|
|
22
15
|
* ever requested. As a precaution, this function throws if build info has been
|
|
23
16
|
* set already, unless `force` flag is explicitly set.
|
|
24
17
|
* @param info
|
|
25
18
|
* @param force
|
|
26
|
-
*/
|
|
27
|
-
export function setBuildInfo(info, force = false) {
|
|
28
|
-
if (buildInfo !== undefined && !force) {
|
|
29
|
-
throw Error('"Build Info" is already initialized');
|
|
30
|
-
}
|
|
31
|
-
buildInfo = info;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
19
|
+
*/export function setBuildInfo(info,force=false){if(buildInfo!==undefined&&!force){throw Error("\"Build Info\" is already initialized");}buildInfo=info;}/**
|
|
35
20
|
* Returns "Build Info" object; throws if it has not been initialized yet.
|
|
36
21
|
* @returns
|
|
37
|
-
*/
|
|
38
|
-
export function getBuildInfo() {
|
|
39
|
-
if (buildInfo === undefined) {
|
|
40
|
-
throw Error('"Build Info" has not been initialized yet');
|
|
41
|
-
}
|
|
42
|
-
return buildInfo;
|
|
43
|
-
}
|
|
22
|
+
*/export function getBuildInfo(){if(buildInfo===undefined){throw Error("\"Build Info\" has not been initialized yet");}return buildInfo;}
|
|
44
23
|
//# sourceMappingURL=buildInfo.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildInfo.js","names":["buildInfo","BUILD_INFO","setBuildInfo","info","force","undefined","Error","getBuildInfo"],"sources":["../../../../../src/shared/utils/isomorphy/buildInfo.ts"],"sourcesContent":["// Encapsulates access to \"Build Info\" data.\n\n// BEWARE: This should match the type of build info object generated by\n// Webpack build (see \"/config/webpack/app-base.js\"), and currently this\n// match is not checked automatically.\nexport type BuildInfoT = {\n key: string;\n publicPath: string;\n timestamp: string;\n useServiceWorker: boolean;\n};\n\n// Depending on the build mode & environment, BUILD_INFO is either a global\n// variable defined at the app launch, or it is replaced by the actual value\n// by the Webpack build.\ndeclare const BUILD_INFO: BuildInfoT | undefined;\n\nlet buildInfo: BuildInfoT | undefined;\n\n// On the client side \"BUILD_INFO\" should be injected by Webpack. Note, however,\n// that in test environment we may need situations were environment is mocked as\n// client-side, although no proper Webpack compilation is executed, thus no info\n// injected; because of this we don't do a hard environment check here.\nif (typeof BUILD_INFO !== 'undefined') buildInfo = BUILD_INFO;\n\n/**\n * In scenarious where \"BUILD_INFO\" is not injected by Webpack (server-side,\n * tests, etc.) we expect the host codebase to explicitly set it before it is\n * ever requested. As a precaution, this function throws if build info has been\n * set already, unless `force` flag is explicitly set.\n * @param info\n * @param force\n */\nexport function setBuildInfo(info?: BuildInfoT, force = false): void {\n if (buildInfo !== undefined && !force) {\n throw Error('\"Build Info\" is already initialized');\n }\n buildInfo = info;\n}\n\n/**\n * Returns \"Build Info\" object; throws if it has not been initialized yet.\n * @returns\n */\nexport function getBuildInfo(): BuildInfoT {\n if (buildInfo === undefined) {\n throw Error('\"Build Info\" has not been initialized yet');\n }\n return buildInfo;\n}\n"],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"buildInfo.js","names":["buildInfo","BUILD_INFO","setBuildInfo","info","force","undefined","Error","getBuildInfo"],"sources":["../../../../../src/shared/utils/isomorphy/buildInfo.ts"],"sourcesContent":["// Encapsulates access to \"Build Info\" data.\n\n// BEWARE: This should match the type of build info object generated by\n// Webpack build (see \"/config/webpack/app-base.js\"), and currently this\n// match is not checked automatically.\nexport type BuildInfoT = {\n key: string;\n publicPath: string;\n timestamp: string;\n useServiceWorker: boolean;\n};\n\n// Depending on the build mode & environment, BUILD_INFO is either a global\n// variable defined at the app launch, or it is replaced by the actual value\n// by the Webpack build.\ndeclare const BUILD_INFO: BuildInfoT | undefined;\n\nlet buildInfo: BuildInfoT | undefined;\n\n// On the client side \"BUILD_INFO\" should be injected by Webpack. Note, however,\n// that in test environment we may need situations were environment is mocked as\n// client-side, although no proper Webpack compilation is executed, thus no info\n// injected; because of this we don't do a hard environment check here.\nif (typeof BUILD_INFO !== 'undefined') buildInfo = BUILD_INFO;\n\n/**\n * In scenarious where \"BUILD_INFO\" is not injected by Webpack (server-side,\n * tests, etc.) we expect the host codebase to explicitly set it before it is\n * ever requested. As a precaution, this function throws if build info has been\n * set already, unless `force` flag is explicitly set.\n * @param info\n * @param force\n */\nexport function setBuildInfo(info?: BuildInfoT, force = false): void {\n if (buildInfo !== undefined && !force) {\n throw Error('\"Build Info\" is already initialized');\n }\n buildInfo = info;\n}\n\n/**\n * Returns \"Build Info\" object; throws if it has not been initialized yet.\n * @returns\n */\nexport function getBuildInfo(): BuildInfoT {\n if (buildInfo === undefined) {\n throw Error('\"Build Info\" has not been initialized yet');\n }\n return buildInfo;\n}\n"],"mappings":"AAAA;AAEA;AACA;AACA;AAQA;AACA;AACA;AAGA,GAAI,CAAAA,SAAiC,CAErC;AACA;AACA;AACA;AACA,GAAI,MAAO,CAAAC,UAAU,GAAK,WAAW,CAAED,SAAS,CAAGC,UAAU,CAE7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,MAAO,SAAS,CAAAC,YAAYA,CAACC,IAAiB,CAAEC,KAAK,CAAG,KAAK,CAAQ,CACnE,GAAIJ,SAAS,GAAKK,SAAS,EAAI,CAACD,KAAK,CAAE,CACrC,KAAM,CAAAE,KAAK,CAAC,uCAAqC,CAAC,CACpD,CACAN,SAAS,CAAGG,IAAI,CAClB,CAEA;AACA;AACA;AACA,GACA,MAAO,SAAS,CAAAI,YAAYA,CAAA,CAAe,CACzC,GAAIP,SAAS,GAAKK,SAAS,CAAE,CAC3B,KAAM,CAAAC,KAAK,CAAC,6CAA2C,CAAC,CAC1D,CACA,MAAO,CAAAN,SAAS,CAClB","ignoreList":[]}
|
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
// Checks for client- vs. server-side environment detection.
|
|
2
|
-
|
|
3
2
|
/**
|
|
4
3
|
* `true` within client-side environment (browser), `false` at server-side.
|
|
5
|
-
*/
|
|
6
|
-
export const IS_CLIENT_SIDE = typeof process !== 'object'
|
|
7
|
-
// NOTE: Because in this case we assume the host environment might be partially
|
|
4
|
+
*/export const IS_CLIENT_SIDE=typeof process!=="object"// NOTE: Because in this case we assume the host environment might be partially
|
|
8
5
|
// polyfilled to emulate some Node interfaces, thus it might have global `process`
|
|
9
6
|
// object, but without `versions` sub-object inside it.
|
|
10
7
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
/**
|
|
8
|
+
||!process.versions?.node||!!global.REACT_UTILS_FORCE_CLIENT_SIDE||typeof REACT_UTILS_WEBPACK_BUNDLE!=="undefined";/**
|
|
14
9
|
* `true` within the server-side environment (node), `false` at client-side.
|
|
15
|
-
*/
|
|
16
|
-
export const IS_SERVER_SIDE = !IS_CLIENT_SIDE;
|
|
10
|
+
*/export const IS_SERVER_SIDE=!IS_CLIENT_SIDE;
|
|
17
11
|
//# sourceMappingURL=environment-check.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environment-check.js","names":["IS_CLIENT_SIDE","process","versions","node","global","REACT_UTILS_FORCE_CLIENT_SIDE","REACT_UTILS_WEBPACK_BUNDLE","IS_SERVER_SIDE"],"sources":["../../../../../src/shared/utils/isomorphy/environment-check.ts"],"sourcesContent":["// Checks for client- vs. server-side environment detection.\n\n/**\n * `true` within client-side environment (browser), `false` at server-side.\n */\nexport const IS_CLIENT_SIDE: boolean = typeof process !== 'object'\n // NOTE: Because in this case we assume the host environment might be partially\n // polyfilled to emulate some Node interfaces, thus it might have global `process`\n // object, but without `versions` sub-object inside it.\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n || !process.versions?.node\n || !!global.REACT_UTILS_FORCE_CLIENT_SIDE\n || typeof REACT_UTILS_WEBPACK_BUNDLE !== 'undefined';\n\n/**\n * `true` within the server-side environment (node), `false` at client-side.\n */\nexport const IS_SERVER_SIDE: boolean = !IS_CLIENT_SIDE;\n"],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"environment-check.js","names":["IS_CLIENT_SIDE","process","versions","node","global","REACT_UTILS_FORCE_CLIENT_SIDE","REACT_UTILS_WEBPACK_BUNDLE","IS_SERVER_SIDE"],"sources":["../../../../../src/shared/utils/isomorphy/environment-check.ts"],"sourcesContent":["// Checks for client- vs. server-side environment detection.\n\n/**\n * `true` within client-side environment (browser), `false` at server-side.\n */\nexport const IS_CLIENT_SIDE: boolean = typeof process !== 'object'\n // NOTE: Because in this case we assume the host environment might be partially\n // polyfilled to emulate some Node interfaces, thus it might have global `process`\n // object, but without `versions` sub-object inside it.\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n || !process.versions?.node\n || !!global.REACT_UTILS_FORCE_CLIENT_SIDE\n || typeof REACT_UTILS_WEBPACK_BUNDLE !== 'undefined';\n\n/**\n * `true` within the server-side environment (node), `false` at client-side.\n */\nexport const IS_SERVER_SIDE: boolean = !IS_CLIENT_SIDE;\n"],"mappings":"AAAA;AAEA;AACA;AACA,GACA,MAAO,MAAM,CAAAA,cAAuB,CAAG,MAAO,CAAAC,OAAO,GAAK,QACxD;AACA;AACA;AACA;AAAA,EACG,CAACA,OAAO,CAACC,QAAQ,EAAEC,IAAI,EACvB,CAAC,CAACC,MAAM,CAACC,6BAA6B,EACtC,MAAO,CAAAC,0BAA0B,GAAK,WAAW,CAEtD;AACA;AACA,GACA,MAAO,MAAM,CAAAC,cAAuB,CAAG,CAACP,cAAc","ignoreList":[]}
|
|
@@ -1,36 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { IS_CLIENT_SIDE, IS_SERVER_SIDE } from "./environment-check";
|
|
3
|
-
|
|
4
|
-
/**
|
|
1
|
+
import{getBuildInfo}from"./buildInfo";import{IS_CLIENT_SIDE,IS_SERVER_SIDE}from"./environment-check";/**
|
|
5
2
|
* @ignore
|
|
6
3
|
* @return {string} Code mode: "development" or "production".
|
|
7
|
-
*/
|
|
8
|
-
function getMode() {
|
|
9
|
-
return process.env.NODE_ENV;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
4
|
+
*/function getMode(){return process.env.NODE_ENV;}/**
|
|
13
5
|
* Returns `true` if development version of the code is running;
|
|
14
6
|
* `false` otherwise.
|
|
15
|
-
*/
|
|
16
|
-
export function isDevBuild() {
|
|
17
|
-
return getMode() === 'development';
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
7
|
+
*/export function isDevBuild(){return getMode()==="development";}/**
|
|
21
8
|
* Returns `true` if production build of the code is running;
|
|
22
9
|
* `false` otherwise.
|
|
23
|
-
*/
|
|
24
|
-
export function isProdBuild() {
|
|
25
|
-
return getMode() === 'production';
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
10
|
+
*/export function isProdBuild(){return getMode()==="production";}/**
|
|
29
11
|
* Returns build timestamp of the front-end JS bundle.
|
|
30
12
|
* @return ISO date/time string.
|
|
31
|
-
*/
|
|
32
|
-
export function buildTimestamp() {
|
|
33
|
-
return getBuildInfo().timestamp;
|
|
34
|
-
}
|
|
35
|
-
export { IS_CLIENT_SIDE, IS_SERVER_SIDE, getBuildInfo };
|
|
13
|
+
*/export function buildTimestamp(){return getBuildInfo().timestamp;}export{IS_CLIENT_SIDE,IS_SERVER_SIDE,getBuildInfo};
|
|
36
14
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["getBuildInfo","IS_CLIENT_SIDE","IS_SERVER_SIDE","getMode","process","env","NODE_ENV","isDevBuild","isProdBuild","buildTimestamp","timestamp"],"sources":["../../../../../src/shared/utils/isomorphy/index.ts"],"sourcesContent":["import { getBuildInfo } from './buildInfo';\nimport { IS_CLIENT_SIDE, IS_SERVER_SIDE } from './environment-check';\n\n/**\n * @ignore\n * @return {string} Code mode: \"development\" or \"production\".\n */\nfunction getMode() {\n return process.env.NODE_ENV;\n}\n\n/**\n * Returns `true` if development version of the code is running;\n * `false` otherwise.\n */\nexport function isDevBuild(): boolean {\n return getMode() === 'development';\n}\n\n/**\n * Returns `true` if production build of the code is running;\n * `false` otherwise.\n */\nexport function isProdBuild(): boolean {\n return getMode() === 'production';\n}\n\n/**\n * Returns build timestamp of the front-end JS bundle.\n * @return ISO date/time string.\n */\nexport function buildTimestamp(): string {\n return getBuildInfo().timestamp;\n}\n\nexport { IS_CLIENT_SIDE, IS_SERVER_SIDE, getBuildInfo };\n"],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","names":["getBuildInfo","IS_CLIENT_SIDE","IS_SERVER_SIDE","getMode","process","env","NODE_ENV","isDevBuild","isProdBuild","buildTimestamp","timestamp"],"sources":["../../../../../src/shared/utils/isomorphy/index.ts"],"sourcesContent":["import { getBuildInfo } from './buildInfo';\nimport { IS_CLIENT_SIDE, IS_SERVER_SIDE } from './environment-check';\n\n/**\n * @ignore\n * @return {string} Code mode: \"development\" or \"production\".\n */\nfunction getMode() {\n return process.env.NODE_ENV;\n}\n\n/**\n * Returns `true` if development version of the code is running;\n * `false` otherwise.\n */\nexport function isDevBuild(): boolean {\n return getMode() === 'development';\n}\n\n/**\n * Returns `true` if production build of the code is running;\n * `false` otherwise.\n */\nexport function isProdBuild(): boolean {\n return getMode() === 'production';\n}\n\n/**\n * Returns build timestamp of the front-end JS bundle.\n * @return ISO date/time string.\n */\nexport function buildTimestamp(): string {\n return getBuildInfo().timestamp;\n}\n\nexport { IS_CLIENT_SIDE, IS_SERVER_SIDE, getBuildInfo };\n"],"mappings":"AAAA,OAASA,YAAY,mBACrB,OAASC,cAAc,CAAEC,cAAc,2BAEvC;AACA;AACA;AACA,GACA,QAAS,CAAAC,OAAOA,CAAA,CAAG,CACjB,MAAO,CAAAC,OAAO,CAACC,GAAG,CAACC,QAAQ,CAC7B,CAEA;AACA;AACA;AACA,GACA,MAAO,SAAS,CAAAC,UAAUA,CAAA,CAAY,CACpC,MAAO,CAAAJ,OAAO,CAAC,CAAC,GAAK,aAAa,CACpC,CAEA;AACA;AACA;AACA,GACA,MAAO,SAAS,CAAAK,WAAWA,CAAA,CAAY,CACrC,MAAO,CAAAL,OAAO,CAAC,CAAC,GAAK,YAAY,CACnC,CAEA;AACA;AACA;AACA,GACA,MAAO,SAAS,CAAAM,cAAcA,CAAA,CAAW,CACvC,MAAO,CAAAT,YAAY,CAAC,CAAC,CAACU,SAAS,CACjC,CAEA,OAAST,cAAc,CAAEC,cAAc,CAAEF,YAAY","ignoreList":[]}
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import "core-js/modules/es.iterator.for-each.js";
|
|
3
|
-
import "core-js/modules/es.json.parse.js";
|
|
4
|
-
/**
|
|
1
|
+
import"core-js/modules/es.iterator.constructor.js";import"core-js/modules/es.iterator.for-each.js";import"core-js/modules/es.json.parse.js";/**
|
|
5
2
|
* Jest environment for end-to-end SSR and client-side testing. It relies on
|
|
6
3
|
* the standard react-utils mechanics to execute SSR of given scene, and also
|
|
7
4
|
* Webpack build of the code for client-side execution, it further exposes
|
|
8
5
|
* Jsdom environment for the client-side testing of the outcomes.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
// BEWARE: The module is not imported into the JU module / the main assembly of
|
|
6
|
+
*/// BEWARE: The module is not imported into the JU module / the main assembly of
|
|
12
7
|
// the library, because doing so easily breaks stuff:
|
|
13
8
|
// 1) This module depends on Node-specific modules, which would make JU
|
|
14
9
|
// incompatible with JsDom if included into JU.
|
|
@@ -16,225 +11,60 @@ import "core-js/modules/es.json.parse.js";
|
|
|
16
11
|
// it seems to randomly break tests using it for a different reason,
|
|
17
12
|
// probably some sort of a require-loop, or some issues with weak
|
|
18
13
|
// require in that scenario.
|
|
19
|
-
|
|
20
14
|
// TODO: We need to add correct typing for environment options.
|
|
21
|
-
|
|
22
15
|
// As this environment is a part of the Jest testing utils,
|
|
23
16
|
// we assume development dependencies are available when it is used.
|
|
24
|
-
/* eslint-disable import/no-extraneous-dependencies */
|
|
25
|
-
|
|
26
|
-
import path from 'node:path';
|
|
27
|
-
import JsdomEnv from 'jest-environment-jsdom';
|
|
28
|
-
import { defaults, set } from 'lodash-es';
|
|
29
|
-
import { Volume, createFsFromVolume } from 'memfs';
|
|
30
|
-
import webpack from 'webpack';
|
|
31
|
-
import register from '@babel/register/experimental-worker';
|
|
32
|
-
function noop() {
|
|
33
|
-
// NOOP
|
|
34
|
-
}
|
|
35
|
-
export default class E2eSsrEnv extends JsdomEnv {
|
|
36
|
-
/**
|
|
17
|
+
/* eslint-disable import/no-extraneous-dependencies */import path from"node:path";import JsdomEnv from"jest-environment-jsdom";import{defaults,set}from"lodash-es";import{Volume,createFsFromVolume}from"memfs";import webpack from"webpack";import register from"@babel/register/experimental-worker";function noop(){// NOOP
|
|
18
|
+
}export default class E2eSsrEnv extends JsdomEnv{/**
|
|
37
19
|
* Loads Webpack config, and exposes it to the environment via global
|
|
38
20
|
* webpackConfig object.
|
|
39
|
-
*/
|
|
40
|
-
async loadWebpackConfig() {
|
|
41
|
-
const optionsString = this.pragmas['webpack-config-options'];
|
|
42
|
-
const options = optionsString ? JSON.parse(optionsString) : {};
|
|
43
|
-
defaults(options, {
|
|
44
|
-
context: this.testFolder,
|
|
45
|
-
fs: this.global.webpackOutputFs
|
|
46
|
-
});
|
|
47
|
-
const factoryPath = this.pragmas['webpack-config-factory'];
|
|
48
|
-
let factory = await import(/* webpackChunkName: "not-a-valid-chunk" */
|
|
49
|
-
path.resolve(this.rootDir, factoryPath));
|
|
50
|
-
factory = 'default' in factory ? factory.default : factory;
|
|
51
|
-
this.global.webpackConfig = factory(options);
|
|
52
|
-
const fs = this.global.webpackOutputFs;
|
|
53
|
-
let buildInfo = `${options.context}/.build-info`;
|
|
54
|
-
if (fs.existsSync(buildInfo)) {
|
|
55
|
-
buildInfo = fs.readFileSync(buildInfo, 'utf8');
|
|
56
|
-
this.global.buildInfo = JSON.parse(buildInfo);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
21
|
+
*/async loadWebpackConfig(){const optionsString=this.pragmas["webpack-config-options"];const options=optionsString?JSON.parse(optionsString):{};defaults(options,{context:this.testFolder,fs:this.global.webpackOutputFs});const factoryPath=this.pragmas["webpack-config-factory"];let factory=await import(/* webpackChunkName: "not-a-valid-chunk" */path.resolve(this.rootDir,factoryPath));factory="default"in factory?factory.default:factory;this.global.webpackConfig=factory(options);const fs=this.global.webpackOutputFs;let buildInfo=`${options.context}/.build-info`;if(fs.existsSync(buildInfo)){buildInfo=fs.readFileSync(buildInfo,"utf8");this.global.buildInfo=JSON.parse(buildInfo);}}/**
|
|
61
22
|
* Executes Webpack build.
|
|
62
23
|
* @return {Promise}
|
|
63
|
-
*/
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const exportName = options.entryExportName || 'default';
|
|
110
|
-
if (exportName in module) {
|
|
111
|
-
options.Application = module[exportName];
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
const {
|
|
115
|
-
default: ssrFactory
|
|
116
|
-
} = await import(/* webpackChunkName: "not-a-valid-chunk" */"../../../server/renderer");
|
|
117
|
-
const renderer = ssrFactory(this.global.webpackConfig, options);
|
|
118
|
-
let status = 200; // OK
|
|
119
|
-
const markup = await new Promise((done, fail) => {
|
|
120
|
-
void renderer(this.ssrRequest,
|
|
121
|
-
// TODO: This will do for now, with the current implementation of
|
|
122
|
-
// the renderer, but it will require a rework once the renderer is
|
|
123
|
-
// updated to do streaming.
|
|
124
|
-
{
|
|
125
|
-
cookie: noop,
|
|
126
|
-
send: done,
|
|
127
|
-
set: noop,
|
|
128
|
-
status: value => {
|
|
129
|
-
status = value;
|
|
130
|
-
},
|
|
131
|
-
// This is how up-to-date Webpack stats are passed to the server in
|
|
132
|
-
// development mode, and we use this here always, instead of having
|
|
133
|
-
// to pass some information via filesystem.
|
|
134
|
-
locals: {
|
|
135
|
-
webpack: {
|
|
136
|
-
devMiddleware: {
|
|
137
|
-
stats: this.webpackStats
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}, error => {
|
|
142
|
-
// TODO: Strictly speaking, that error as Error casting is not all
|
|
143
|
-
// correct, but it works, so no need to spend time on it right now.
|
|
144
|
-
if (error) fail(error);else done('');
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
this.global.ssrMarkup = markup;
|
|
148
|
-
this.global.ssrOptions = options;
|
|
149
|
-
this.global.ssrStatus = status;
|
|
150
|
-
if (cleanup) cleanup();
|
|
151
|
-
}
|
|
152
|
-
constructor(config, context) {
|
|
153
|
-
const pragmas = context.docblockPragmas;
|
|
154
|
-
const requestString = pragmas['ssr-request'];
|
|
155
|
-
const request = requestString ? JSON.parse(requestString) : {};
|
|
156
|
-
request.url ??= '/';
|
|
157
|
-
request.csrfToken = noop;
|
|
158
|
-
|
|
159
|
-
// This ensures the initial JsDom URL matches the value we use for SSR.
|
|
160
|
-
set(config.projectConfig, 'testEnvironmentOptions.url', `http://localhost${request.url}`);
|
|
161
|
-
super(config, context);
|
|
162
|
-
this.global.dom = this.dom;
|
|
163
|
-
this.global.webpackOutputFs = createFsFromVolume(new Volume());
|
|
164
|
-
|
|
165
|
-
// Extracts necessary settings from config and context.
|
|
166
|
-
const {
|
|
167
|
-
projectConfig
|
|
168
|
-
} = config;
|
|
169
|
-
this.rootDir = projectConfig.rootDir;
|
|
170
|
-
this.testFolder = path.dirname(context.testPath);
|
|
171
|
-
this.withSsr = !pragmas['no-ssr'];
|
|
172
|
-
this.ssrRequest = request;
|
|
173
|
-
this.pragmas = pragmas;
|
|
174
|
-
|
|
175
|
-
// The usual "babel-jest" transformation setup does not apply to
|
|
176
|
-
// the environment code and imports from it, this workaround enables it.
|
|
177
|
-
const optionsString = this.pragmas['ssr-options'];
|
|
178
|
-
const options = optionsString ? JSON.parse(optionsString) : {};
|
|
179
|
-
let root;
|
|
180
|
-
switch (options.root) {
|
|
181
|
-
case 'TEST':
|
|
182
|
-
root = this.testFolder;
|
|
183
|
-
break;
|
|
184
|
-
default:
|
|
185
|
-
root = process.cwd();
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
// BEWARE: Anything imported prior to this register() call seems to be
|
|
189
|
-
// transpiled again by Babel if loaded after this call. This causes very
|
|
190
|
-
// confusing errors when testing the code dependent on some sort of contexts
|
|
191
|
-
// (because loading a module again effectively creates a new context object,
|
|
192
|
-
// which is not recognized by the code expecting another context instance).
|
|
193
|
-
// That's why below we prefer dynamic imports for some React Utils methods.
|
|
194
|
-
register({
|
|
195
|
-
envName: options.babelEnv,
|
|
196
|
-
extensions: ['.js', '.jsx', '.ts', '.tsx', '.svg'],
|
|
197
|
-
root
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
async setup() {
|
|
201
|
-
await super.setup();
|
|
202
|
-
await this.runWebpack();
|
|
203
|
-
|
|
204
|
-
// NOTE: It is possible that the Webpack run above, and the SSR run below
|
|
205
|
-
// load different versions of the same module (CommonJS, and ES), and it may
|
|
206
|
-
// cause very confusing problems (e.g. see:
|
|
207
|
-
// https://github.com/birdofpreyru/react-utils/issues/413).
|
|
208
|
-
// It seems we can't reset the cache of ES modules, and Jest's module reset
|
|
209
|
-
// does not reset modules loaded in this enviroment module, and also only
|
|
210
|
-
// replacing entire cache object by and empty {} seems to help (in contrast
|
|
211
|
-
// to deleting all entries by their keys, as it is done within .teardown()
|
|
212
|
-
// method below). Thus, for now we do this as a hotfix, and we also reset
|
|
213
|
-
// build info to undefined, because ES module version not beeing reset
|
|
214
|
-
// triggers an error on the subsequent test using the environment.
|
|
215
|
-
// TODO: Look for a cleaner solution.
|
|
216
|
-
require.cache = {};
|
|
217
|
-
const {
|
|
218
|
-
setBuildInfo
|
|
219
|
-
} = await import(/* webpackChunkName: "not-a-valid-chunk" */"../isomorphy/buildInfo");
|
|
220
|
-
setBuildInfo(undefined, true);
|
|
221
|
-
if (this.withSsr) await this.runSsr();
|
|
222
|
-
this.global.REACT_UTILS_FORCE_CLIENT_SIDE = true;
|
|
223
|
-
}
|
|
224
|
-
async teardown() {
|
|
225
|
-
delete this.global.REACT_UTILS_FORCE_CLIENT_SIDE;
|
|
226
|
-
|
|
227
|
-
// Resets module cache and @babel/register. Effectively this ensures that
|
|
228
|
-
// the next time an instance of this environment is set up, all modules are
|
|
229
|
-
// transformed by Babel from scratch, thus taking into account the latest
|
|
230
|
-
// Babel config (which may change between different environment instances,
|
|
231
|
-
// which does not seem to be taken into account by Babel / Node caches
|
|
232
|
-
// automatically).
|
|
233
|
-
Object.keys(require.cache).forEach(key => {
|
|
234
|
-
delete require.cache[key];
|
|
235
|
-
});
|
|
236
|
-
register.revert();
|
|
237
|
-
await super.teardown();
|
|
238
|
-
}
|
|
239
|
-
}
|
|
24
|
+
*/async runWebpack(){await this.loadWebpackConfig();if(!this.global.webpackConfig)throw Error("Failed to load Webpack config");const compiler=webpack(this.global.webpackConfig);// TODO: The "as typeof compiler.outputFileSystem" piece below is
|
|
25
|
+
// a workaround for the Webpack regression:
|
|
26
|
+
// https://github.com/webpack/webpack/issues/18242
|
|
27
|
+
compiler.outputFileSystem=this.global.webpackOutputFs;return new Promise((done,fail)=>{compiler.run((err,stats)=>{if(err)fail(err);if(stats?.hasErrors()){// eslint-disable-next-line no-console
|
|
28
|
+
console.error(stats.toJson().errors);fail(Error("Webpack compilation failed"));}this.global.webpackStats=stats?.toJson();// Keeps reference to the raw Webpack stats object, which should be
|
|
29
|
+
// explicitly passed to the server-side renderer alongside the request,
|
|
30
|
+
// so that it can to pick up asset paths for different named chunks.
|
|
31
|
+
this.webpackStats=stats;done();});});}async runSsr(){const optionsString=this.pragmas["ssr-options"];const options=optionsString?JSON.parse(optionsString):{};// TODO: This is temporary to shortcut the logging added to SSR.
|
|
32
|
+
options.logger??={debug:noop,info:noop,log:noop,warn:noop};options.buildInfo??=this.global.buildInfo;let cleanup;if(options.entry){const p=path.resolve(this.testFolder,options.entry);const module=await import(/* webpackChunkName: "not-a-valid-chunk" */p);if("cleanup"in module)cleanup=module.cleanup;const exportName=options.entryExportName||"default";if(exportName in module){options.Application=module[exportName];}}const{default:ssrFactory}=await import(/* webpackChunkName: "not-a-valid-chunk" */"../../../server/renderer");const renderer=ssrFactory(this.global.webpackConfig,options);let status=200;// OK
|
|
33
|
+
const markup=await new Promise((done,fail)=>{void renderer(this.ssrRequest,// TODO: This will do for now, with the current implementation of
|
|
34
|
+
// the renderer, but it will require a rework once the renderer is
|
|
35
|
+
// updated to do streaming.
|
|
36
|
+
{cookie:noop,send:done,set:noop,status:value=>{status=value;},// This is how up-to-date Webpack stats are passed to the server in
|
|
37
|
+
// development mode, and we use this here always, instead of having
|
|
38
|
+
// to pass some information via filesystem.
|
|
39
|
+
locals:{webpack:{devMiddleware:{stats:this.webpackStats}}}},error=>{// TODO: Strictly speaking, that error as Error casting is not all
|
|
40
|
+
// correct, but it works, so no need to spend time on it right now.
|
|
41
|
+
if(error)fail(error);else done("");});});this.global.ssrMarkup=markup;this.global.ssrOptions=options;this.global.ssrStatus=status;if(cleanup)cleanup();}constructor(config,context){const pragmas=context.docblockPragmas;const requestString=pragmas["ssr-request"];const request=requestString?JSON.parse(requestString):{};request.url??="/";request.csrfToken=noop;// This ensures the initial JsDom URL matches the value we use for SSR.
|
|
42
|
+
set(config.projectConfig,"testEnvironmentOptions.url",`http://localhost${request.url}`);super(config,context);this.global.dom=this.dom;this.global.webpackOutputFs=createFsFromVolume(new Volume);// Extracts necessary settings from config and context.
|
|
43
|
+
const{projectConfig}=config;this.rootDir=projectConfig.rootDir;this.testFolder=path.dirname(context.testPath);this.withSsr=!pragmas["no-ssr"];this.ssrRequest=request;this.pragmas=pragmas;// The usual "babel-jest" transformation setup does not apply to
|
|
44
|
+
// the environment code and imports from it, this workaround enables it.
|
|
45
|
+
const optionsString=this.pragmas["ssr-options"];const options=optionsString?JSON.parse(optionsString):{};let root;switch(options.root){case"TEST":root=this.testFolder;break;default:root=process.cwd();}// BEWARE: Anything imported prior to this register() call seems to be
|
|
46
|
+
// transpiled again by Babel if loaded after this call. This causes very
|
|
47
|
+
// confusing errors when testing the code dependent on some sort of contexts
|
|
48
|
+
// (because loading a module again effectively creates a new context object,
|
|
49
|
+
// which is not recognized by the code expecting another context instance).
|
|
50
|
+
// That's why below we prefer dynamic imports for some React Utils methods.
|
|
51
|
+
register({envName:options.babelEnv,extensions:[".js",".jsx",".ts",".tsx",".svg"],root});}async setup(){await super.setup();await this.runWebpack();// NOTE: It is possible that the Webpack run above, and the SSR run below
|
|
52
|
+
// load different versions of the same module (CommonJS, and ES), and it may
|
|
53
|
+
// cause very confusing problems (e.g. see:
|
|
54
|
+
// https://github.com/birdofpreyru/react-utils/issues/413).
|
|
55
|
+
// It seems we can't reset the cache of ES modules, and Jest's module reset
|
|
56
|
+
// does not reset modules loaded in this enviroment module, and also only
|
|
57
|
+
// replacing entire cache object by and empty {} seems to help (in contrast
|
|
58
|
+
// to deleting all entries by their keys, as it is done within .teardown()
|
|
59
|
+
// method below). Thus, for now we do this as a hotfix, and we also reset
|
|
60
|
+
// build info to undefined, because ES module version not beeing reset
|
|
61
|
+
// triggers an error on the subsequent test using the environment.
|
|
62
|
+
// TODO: Look for a cleaner solution.
|
|
63
|
+
require.cache={};const{setBuildInfo}=await import(/* webpackChunkName: "not-a-valid-chunk" */"../isomorphy/buildInfo");setBuildInfo(undefined,true);if(this.withSsr)await this.runSsr();this.global.REACT_UTILS_FORCE_CLIENT_SIDE=true;}async teardown(){delete this.global.REACT_UTILS_FORCE_CLIENT_SIDE;// Resets module cache and @babel/register. Effectively this ensures that
|
|
64
|
+
// the next time an instance of this environment is set up, all modules are
|
|
65
|
+
// transformed by Babel from scratch, thus taking into account the latest
|
|
66
|
+
// Babel config (which may change between different environment instances,
|
|
67
|
+
// which does not seem to be taken into account by Babel / Node caches
|
|
68
|
+
// automatically).
|
|
69
|
+
Object.keys(require.cache).forEach(key=>{delete require.cache[key];});register.revert();await super.teardown();}}
|
|
240
70
|
//# sourceMappingURL=E2eSsrEnv.js.map
|