@dr.pogodin/react-utils 1.35.1 → 1.35.3
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/build/development/client/getInj.js +10 -0
- package/build/development/client/getInj.js.map +1 -1
- package/build/development/client/index.js +9 -2
- package/build/development/client/index.js.map +1 -1
- package/build/development/index.js +9 -1
- package/build/development/index.js.map +1 -1
- package/build/development/server/index.js.map +1 -1
- package/build/development/server/renderer.js.map +1 -1
- package/build/development/server/server.js.map +1 -1
- package/build/development/shared/components/Button/index.js +2 -1
- package/build/development/shared/components/Button/index.js.map +1 -1
- package/build/development/shared/components/MetaTags.js.map +1 -1
- package/build/development/shared/components/TextArea/index.js.map +1 -1
- package/build/development/shared/components/WithTooltip/Tooltip.js.map +1 -1
- package/build/development/shared/components/YouTubeVideo/index.js.map +1 -1
- package/build/development/shared/components/index.js +8 -1
- package/build/development/shared/components/index.js.map +1 -1
- package/build/development/shared/components/selectors/CustomDropdown/index.js.map +1 -1
- package/build/development/shared/components/selectors/Switch/index.js.map +1 -1
- package/build/development/shared/utils/index.js.map +1 -1
- package/build/development/shared/utils/jest/E2eSsrEnv.js.map +1 -1
- package/build/development/shared/utils/jest/index.js +2 -1
- package/build/development/shared/utils/jest/index.js.map +1 -1
- package/build/development/shared/utils/splitComponent.js +16 -10
- package/build/development/shared/utils/splitComponent.js.map +1 -1
- package/build/development/web.bundle.js +6 -6
- package/build/production/client/getInj.js +6 -2
- package/build/production/client/getInj.js.map +1 -1
- package/build/production/client/index.js +1 -1
- package/build/production/client/index.js.map +1 -1
- package/build/production/index.js +4 -1
- package/build/production/index.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 +2 -2
- package/build/production/shared/components/Button/index.js.map +1 -1
- package/build/production/shared/components/MetaTags.js.map +1 -1
- package/build/production/shared/components/TextArea/index.js.map +1 -1
- package/build/production/shared/components/WithTooltip/Tooltip.js.map +1 -1
- package/build/production/shared/components/YouTubeVideo/index.js.map +1 -1
- package/build/production/shared/components/index.js +1 -1
- package/build/production/shared/components/index.js.map +1 -1
- package/build/production/shared/components/selectors/CustomDropdown/index.js.map +1 -1
- package/build/production/shared/components/selectors/Switch/index.js.map +1 -1
- package/build/production/shared/utils/index.js.map +1 -1
- package/build/production/shared/utils/jest/E2eSsrEnv.js.map +1 -1
- package/build/production/shared/utils/jest/index.js +1 -1
- package/build/production/shared/utils/jest/index.js.map +1 -1
- package/build/production/shared/utils/splitComponent.js +9 -7
- package/build/production/shared/utils/splitComponent.js.map +1 -1
- package/build/production/web.bundle.js +1 -1
- package/build/production/web.bundle.js.map +1 -1
- package/build/types-code/client/getInj.d.ts +6 -0
- package/build/types-code/client/index.d.ts +2 -1
- package/build/types-code/index.d.ts +2 -2
- package/build/types-code/shared/components/Button/index.d.ts +1 -0
- package/build/types-code/shared/components/index.d.ts +1 -1
- package/build/types-code/shared/utils/index.d.ts +1 -1
- package/package.json +27 -28
- package/src/client/getInj.ts +9 -0
- package/src/client/index.tsx +3 -1
- package/src/index.ts +10 -1
- package/src/shared/components/Button/index.tsx +1 -1
- package/src/shared/components/index.ts +1 -1
- package/src/shared/utils/index.ts +1 -0
- package/src/shared/utils/jest/index.tsx +2 -1
- package/src/shared/utils/splitComponent.tsx +18 -10
- package/tsconfig.types.json +1 -3
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import 'node-forge/lib/aes';
|
|
2
2
|
import type { InjT } from '../shared/utils/globalState';
|
|
3
3
|
export default function getInj(): InjT;
|
|
4
|
+
/**
|
|
5
|
+
* Allows to set a custom injection object instance,
|
|
6
|
+
* for server-less scenarios, for example, where it is not auto-injected
|
|
7
|
+
* into generated pages from the server side.
|
|
8
|
+
*/
|
|
9
|
+
export declare function setInj(value: InjT): void;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { type ComponentType } from 'react';
|
|
2
|
+
import { setInj } from './getInj';
|
|
2
3
|
type OptionsT = {
|
|
3
4
|
dontHydrate?: boolean;
|
|
4
5
|
initialState?: any;
|
|
5
6
|
};
|
|
7
|
+
export { setInj };
|
|
6
8
|
/**
|
|
7
9
|
* Prepares and launches the app at client side.
|
|
8
10
|
* @param Application Root application component
|
|
9
11
|
* @param [options={}] Optional. Additional settings.
|
|
10
12
|
*/
|
|
11
13
|
export default function Launch(Application: ComponentType, options?: OptionsT): void;
|
|
12
|
-
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import 'styles/global.scss';
|
|
2
2
|
import type ServerT from './server';
|
|
3
3
|
declare const server: typeof ServerT | null;
|
|
4
|
-
declare
|
|
4
|
+
declare let client: any;
|
|
5
5
|
export { default as api } from 'axios';
|
|
6
6
|
export * as PT from 'prop-types';
|
|
7
7
|
export { type AsyncCollectionLoaderT, type AsyncDataEnvelopeT, type AsyncDataLoaderT, type ForceT, type UseAsyncDataOptionsT, type UseAsyncDataResT, type UseGlobalStateResT, type ValueOrInitializerT, getGlobalState, GlobalStateProvider, newAsyncDataEnvelope, useAsyncCollection, useAsyncData, useGlobalState, withGlobalStateType, } from '@dr.pogodin/react-global-state';
|
|
8
8
|
export * from './shared/components';
|
|
9
|
-
export { type Theme, config, Barrier, Emitter, isomorphy, getSsrContext, Semaphore, splitComponent, themed, ThemeProvider, time, webpack, withRetries, } from './shared/utils';
|
|
9
|
+
export { type Listener, type Theme, config, Barrier, Emitter, isomorphy, getSsrContext, Semaphore, splitComponent, themed, ThemeProvider, time, webpack, withRetries, } from './shared/utils';
|
|
10
10
|
export { client, server };
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Just an aggregation of all exported components into a single module.
|
|
3
3
|
*/
|
|
4
4
|
export * from './selectors';
|
|
5
|
-
export { default as Button } from './Button';
|
|
5
|
+
export { default as Button, BaseButton } from './Button';
|
|
6
6
|
export { default as Checkbox } from './Checkbox';
|
|
7
7
|
export { default as Input } from './Input';
|
|
8
8
|
export { default as Link } from './Link';
|
|
@@ -3,7 +3,7 @@ import config from './config';
|
|
|
3
3
|
import * as isomorphy from './isomorphy';
|
|
4
4
|
import time from './time';
|
|
5
5
|
import * as webpack from './webpack';
|
|
6
|
-
export { Barrier, Emitter, Semaphore, withRetries, } from '@dr.pogodin/js-utils';
|
|
6
|
+
export { type Listener, Barrier, Emitter, Semaphore, withRetries, } from '@dr.pogodin/js-utils';
|
|
7
7
|
export { getSsrContext } from './globalState';
|
|
8
8
|
export { default as splitComponent } from './splitComponent';
|
|
9
9
|
type ThemedT = typeof themedImpl & {
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.35.
|
|
2
|
+
"version": "1.35.3",
|
|
3
3
|
"bin": {
|
|
4
4
|
"react-utils-build": "bin/build.js",
|
|
5
5
|
"react-utils-setup": "bin/setup.js"
|
|
@@ -8,15 +8,15 @@
|
|
|
8
8
|
"url": "https://github.com/birdofpreyru/react-utils/issues"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@babel/runtime": "^7.24.
|
|
11
|
+
"@babel/runtime": "^7.24.6",
|
|
12
12
|
"@dr.pogodin/babel-plugin-react-css-modules": "^6.13.1",
|
|
13
13
|
"@dr.pogodin/csurf": "^1.13.0",
|
|
14
|
-
"@dr.pogodin/js-utils": "^0.0.
|
|
15
|
-
"@dr.pogodin/react-global-state": "^0.14.
|
|
16
|
-
"@dr.pogodin/react-themes": "^1.6.
|
|
14
|
+
"@dr.pogodin/js-utils": "^0.0.12",
|
|
15
|
+
"@dr.pogodin/react-global-state": "^0.14.2",
|
|
16
|
+
"@dr.pogodin/react-themes": "^1.6.2",
|
|
17
17
|
"@jest/environment": "^29.7.0",
|
|
18
|
-
"axios": "^1.
|
|
19
|
-
"commander": "^12.
|
|
18
|
+
"axios": "^1.7.2",
|
|
19
|
+
"commander": "^12.1.0",
|
|
20
20
|
"compression": "^1.7.4",
|
|
21
21
|
"config": "^3.3.11",
|
|
22
22
|
"cookie": "^0.6.0",
|
|
@@ -47,24 +47,23 @@
|
|
|
47
47
|
},
|
|
48
48
|
"description": "Collection of generic ReactJS components and utils",
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@babel/cli": "^7.24.
|
|
51
|
-
"@babel/core": "^7.24.
|
|
52
|
-
"@babel/eslint-parser": "^7.24.
|
|
53
|
-
"@babel/eslint-plugin": "^7.24.
|
|
54
|
-
"@babel/node": "^7.
|
|
55
|
-
"@babel/plugin-transform-runtime": "^7.24.
|
|
56
|
-
"@babel/preset-env": "^7.24.
|
|
57
|
-
"@babel/preset-react": "^7.24.
|
|
58
|
-
"@babel/preset-typescript": "^7.24.
|
|
59
|
-
"@babel/register": "^7.
|
|
50
|
+
"@babel/cli": "^7.24.6",
|
|
51
|
+
"@babel/core": "^7.24.6",
|
|
52
|
+
"@babel/eslint-parser": "^7.24.6",
|
|
53
|
+
"@babel/eslint-plugin": "^7.24.6",
|
|
54
|
+
"@babel/node": "^7.24.6",
|
|
55
|
+
"@babel/plugin-transform-runtime": "^7.24.6",
|
|
56
|
+
"@babel/preset-env": "^7.24.6",
|
|
57
|
+
"@babel/preset-react": "^7.24.6",
|
|
58
|
+
"@babel/preset-typescript": "^7.24.6",
|
|
59
|
+
"@babel/register": "^7.24.6",
|
|
60
60
|
"@dr.pogodin/babel-plugin-transform-assets": "^1.2.2",
|
|
61
61
|
"@dr.pogodin/babel-preset-svgr": "^1.8.0",
|
|
62
|
-
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.
|
|
62
|
+
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.15",
|
|
63
63
|
"@testing-library/dom": "^10.1.0",
|
|
64
|
-
"@testing-library/react": "^
|
|
64
|
+
"@testing-library/react": "^16.0.0",
|
|
65
65
|
"@testing-library/user-event": "^14.5.2",
|
|
66
66
|
"@tsconfig/recommended": "^1.0.6",
|
|
67
|
-
"@tsd/typescript": "^5.4.5",
|
|
68
67
|
"@types/compression": "^1.7.5",
|
|
69
68
|
"@types/config": "^3.3.4",
|
|
70
69
|
"@types/cookie": "^0.6.0",
|
|
@@ -72,11 +71,11 @@
|
|
|
72
71
|
"@types/csurf": "^1.11.5",
|
|
73
72
|
"@types/express": "^4.17.21",
|
|
74
73
|
"@types/jest": "^29.5.12",
|
|
75
|
-
"@types/lodash": "^4.17.
|
|
74
|
+
"@types/lodash": "^4.17.4",
|
|
76
75
|
"@types/morgan": "^1.9.9",
|
|
77
76
|
"@types/node-forge": "^1.3.11",
|
|
78
77
|
"@types/pretty": "^2.0.3",
|
|
79
|
-
"@types/react": "^18.3.
|
|
78
|
+
"@types/react": "^18.3.3",
|
|
80
79
|
"@types/react-dom": "^18.3.0",
|
|
81
80
|
"@types/react-helmet": "^6.1.11",
|
|
82
81
|
"@types/request-ip": "^0.0.41",
|
|
@@ -90,7 +89,7 @@
|
|
|
90
89
|
"babel-loader": "^9.1.3",
|
|
91
90
|
"babel-plugin-module-resolver": "^5.0.2",
|
|
92
91
|
"core-js": "^3.37.1",
|
|
93
|
-
"css-loader": "^7.1.
|
|
92
|
+
"css-loader": "^7.1.2",
|
|
94
93
|
"css-minimizer-webpack-plugin": "^7.0.0",
|
|
95
94
|
"eslint": "^8.57.0",
|
|
96
95
|
"eslint-config-airbnb": "^19.0.4",
|
|
@@ -99,7 +98,7 @@
|
|
|
99
98
|
"eslint-plugin-import": "^2.29.1",
|
|
100
99
|
"eslint-plugin-jest": "^28.5.0",
|
|
101
100
|
"eslint-plugin-jsx-a11y": "^6.8.0",
|
|
102
|
-
"eslint-plugin-react": "^7.34.
|
|
101
|
+
"eslint-plugin-react": "^7.34.2",
|
|
103
102
|
"eslint-plugin-react-hooks": "^4.6.2",
|
|
104
103
|
"identity-obj-proxy": "^3.0.0",
|
|
105
104
|
"jest": "^29.7.0",
|
|
@@ -115,16 +114,16 @@
|
|
|
115
114
|
"react-refresh": "^0.14.2",
|
|
116
115
|
"regenerator-runtime": "^0.14.1",
|
|
117
116
|
"resolve-url-loader": "^5.0.0",
|
|
118
|
-
"sass": "^1.77.
|
|
117
|
+
"sass": "^1.77.4",
|
|
119
118
|
"sass-loader": "^14.2.1",
|
|
120
|
-
"sitemap": "^
|
|
121
|
-
"stylelint": "^16.
|
|
119
|
+
"sitemap": "^8.0.0",
|
|
120
|
+
"stylelint": "^16.6.1",
|
|
122
121
|
"stylelint-config-standard-scss": "^13.1.0",
|
|
123
122
|
"supertest": "^7.0.0",
|
|
124
123
|
"tsc-alias": "^1.8.10",
|
|
125
124
|
"typed-scss-modules": "^8.0.1",
|
|
126
125
|
"typescript": "^5.4.5",
|
|
127
|
-
"typescript-eslint": "^7.
|
|
126
|
+
"typescript-eslint": "^7.12.0",
|
|
128
127
|
"webpack": "^5.91.0",
|
|
129
128
|
"webpack-dev-middleware": "^7.2.1",
|
|
130
129
|
"webpack-hot-middleware": "^2.26.1",
|
package/src/client/getInj.ts
CHANGED
|
@@ -41,3 +41,12 @@ if (metaElement) {
|
|
|
41
41
|
export default function getInj(): InjT {
|
|
42
42
|
return inj;
|
|
43
43
|
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Allows to set a custom injection object instance,
|
|
47
|
+
* for server-less scenarios, for example, where it is not auto-injected
|
|
48
|
+
* into generated pages from the server side.
|
|
49
|
+
*/
|
|
50
|
+
export function setInj(value: InjT) {
|
|
51
|
+
inj = value;
|
|
52
|
+
}
|
package/src/client/index.tsx
CHANGED
|
@@ -8,13 +8,15 @@ import { GlobalStateProvider } from '@dr.pogodin/react-global-state';
|
|
|
8
8
|
import { createRoot, hydrateRoot } from 'react-dom/client';
|
|
9
9
|
import { BrowserRouter } from 'react-router-dom';
|
|
10
10
|
|
|
11
|
-
import getInj from './getInj';
|
|
11
|
+
import getInj, { setInj } from './getInj';
|
|
12
12
|
|
|
13
13
|
type OptionsT = {
|
|
14
14
|
dontHydrate?: boolean;
|
|
15
15
|
initialState?: any;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
+
export { setInj };
|
|
19
|
+
|
|
18
20
|
/**
|
|
19
21
|
* Prepares and launches the app at client side.
|
|
20
22
|
* @param Application Root application component
|
package/src/index.ts
CHANGED
|
@@ -6,7 +6,15 @@ import type ServerT from './server';
|
|
|
6
6
|
|
|
7
7
|
const server = webpack.requireWeak('./server', __dirname) as (typeof ServerT) | null;
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
// TODO: Should be done in a cleaner way, but technically it is fine
|
|
10
|
+
// for this scenario.
|
|
11
|
+
// eslint-disable-next-line import/no-mutable-exports
|
|
12
|
+
let client = server ? undefined : require('./client');
|
|
13
|
+
|
|
14
|
+
if (client) {
|
|
15
|
+
client.default.setInj = client.setInj;
|
|
16
|
+
client = client.default;
|
|
17
|
+
}
|
|
10
18
|
|
|
11
19
|
export { default as api } from 'axios';
|
|
12
20
|
export * as PT from 'prop-types';
|
|
@@ -32,6 +40,7 @@ export {
|
|
|
32
40
|
export * from 'components';
|
|
33
41
|
|
|
34
42
|
export {
|
|
43
|
+
type Listener,
|
|
35
44
|
type Theme,
|
|
36
45
|
config,
|
|
37
46
|
Barrier,
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
export * from 'components/selectors';
|
|
6
6
|
|
|
7
|
-
export { default as Button } from 'components/Button';
|
|
7
|
+
export { default as Button, BaseButton } from 'components/Button';
|
|
8
8
|
export { default as Checkbox } from 'components/Checkbox';
|
|
9
9
|
export { default as Input } from 'components/Input';
|
|
10
10
|
export { default as Link } from 'components/Link';
|
|
@@ -107,6 +107,7 @@ export function snapshot(element: React.ReactElement) {
|
|
|
107
107
|
});
|
|
108
108
|
if (res === undefined) throw Error('Render failed');
|
|
109
109
|
|
|
110
|
-
|
|
110
|
+
const nodes = res.asFragment().childNodes;
|
|
111
|
+
expect(nodes.length > 1 ? [...nodes] : nodes[0]).toMatchSnapshot();
|
|
111
112
|
return res;
|
|
112
113
|
}
|
|
@@ -22,15 +22,23 @@ import {
|
|
|
22
22
|
getBuildInfo,
|
|
23
23
|
} from './isomorphy';
|
|
24
24
|
|
|
25
|
-
//
|
|
26
|
-
//
|
|
25
|
+
// NOTE: At the client-side we get chunk groups the first time they are needed
|
|
26
|
+
// (we used to get them eagerly when this module loaded, but it did not work well
|
|
27
|
+
// alongside custom chunk info injection in server-less scenario);
|
|
28
|
+
// at the server-side we only can get them within React render flow.
|
|
27
29
|
// Thus, we set and use the following variable at the client-side, and then when
|
|
28
30
|
// needed on the server side, we'll fetch it differently.
|
|
29
|
-
let
|
|
31
|
+
let cachedClientChunkGroups: ChunkGroupsT | undefined;
|
|
30
32
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
function getClientChunkGroups(): ChunkGroupsT {
|
|
34
|
+
if (IS_CLIENT_SIDE && !cachedClientChunkGroups) {
|
|
35
|
+
// eslint-disable-next-line global-require
|
|
36
|
+
cachedClientChunkGroups = require('client/getInj').default().CHUNK_GROUPS || {};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (!cachedClientChunkGroups) throw Error('Internal error');
|
|
40
|
+
|
|
41
|
+
return cachedClientChunkGroups;
|
|
34
42
|
}
|
|
35
43
|
|
|
36
44
|
const refCounts: { [path: string]: number } = {};
|
|
@@ -185,7 +193,7 @@ export default function splitComponent<
|
|
|
185
193
|
placeholder?: ReactNode,
|
|
186
194
|
}) {
|
|
187
195
|
// On the client side we can check right away if the chunk name is known.
|
|
188
|
-
if (IS_CLIENT_SIDE) assertChunkName(chunkName,
|
|
196
|
+
if (IS_CLIENT_SIDE) assertChunkName(chunkName, getClientChunkGroups());
|
|
189
197
|
|
|
190
198
|
// The correct usage of splitComponent() assumes a single call per chunk.
|
|
191
199
|
if (usedChunkNames.has(chunkName)) {
|
|
@@ -200,7 +208,7 @@ export default function splitComponent<
|
|
|
200
208
|
// the component (the lazy load function is executed by React one at
|
|
201
209
|
// the frist mount).
|
|
202
210
|
if (IS_CLIENT_SIDE) {
|
|
203
|
-
await bookStyleSheets(chunkName,
|
|
211
|
+
await bookStyleSheets(chunkName, getClientChunkGroups(), false);
|
|
204
212
|
}
|
|
205
213
|
|
|
206
214
|
const Wrapper = forwardRef((
|
|
@@ -218,8 +226,8 @@ export default function splitComponent<
|
|
|
218
226
|
// This takes care about stylesheets management every time an instance of
|
|
219
227
|
// this component is mounted / unmounted.
|
|
220
228
|
useInsertionEffect(() => {
|
|
221
|
-
bookStyleSheets(chunkName,
|
|
222
|
-
return () => freeStyleSheets(chunkName,
|
|
229
|
+
bookStyleSheets(chunkName, getClientChunkGroups(), true);
|
|
230
|
+
return () => freeStyleSheets(chunkName, getClientChunkGroups());
|
|
223
231
|
}, []);
|
|
224
232
|
|
|
225
233
|
return (
|
package/tsconfig.types.json
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
// TS config for ESLint, editor plugins, and other tools that look-up and use
|
|
2
2
|
// the default tsconfig.json file.
|
|
3
3
|
{
|
|
4
|
-
|
|
5
|
-
// resolution mechanics.
|
|
6
|
-
"extends": "./node_modules/@tsconfig/recommended/tsconfig.json",
|
|
4
|
+
"extends": "@tsconfig/recommended",
|
|
7
5
|
|
|
8
6
|
// Keep these in case any mocks / tests are declared within "src" code tree.
|
|
9
7
|
"exclude": [
|