@dr.pogodin/react-utils 1.29.2 → 1.30.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.
@@ -4,7 +4,7 @@ import * as isomorphy from './isomorphy';
4
4
  import time from './time';
5
5
  import * as webpack from './webpack';
6
6
  import type * as JuT from './jest';
7
- export { Barrier, Emitter, Semaphore } from '@dr.pogodin/js-utils';
7
+ export { Barrier, Emitter, Semaphore, withRetries, } from '@dr.pogodin/js-utils';
8
8
  export { getSsrContext } from './globalState';
9
9
  export { default as splitComponent } from './splitComponent';
10
10
  type ThemedT = typeof themedImpl & {
@@ -13,40 +13,4 @@ type ThemedT = typeof themedImpl & {
13
13
  };
14
14
  declare const themed: ThemedT;
15
15
  declare const JU: typeof JuT | null;
16
- /**
17
- * @category Utilities
18
- * @global
19
- * @func withRetries
20
- * @desc
21
- * ```js
22
- * import { withRetries } from '@dr.pogodin/react-utils';
23
- * ```
24
- * Attempts to perform given asynchronous `action` up to `maxRetries` times,
25
- * with the given `interval` between attempts. If any attempt is successful,
26
- * the result is returned immediately, with no further attempts done;
27
- * otherwise, if all attempts fail, the result Promise rejects after the last
28
- * attempt.
29
- * @param {function} action
30
- * @param {number} [maxRetries=5] Optional. Maximum number of retries. Defaults
31
- * to 5 attempts.
32
- * @param {number} [interval=1000] Optional. Interval between retries [ms].
33
- * Defaults to 1 second.
34
- * @return {Promise} Resolves to the result of successful operation, or
35
- * rejects with the error from the latst failed attempt.
36
- * @example
37
- * import { withRetries } from '@dr.pogodin/react-utils';
38
- *
39
- * let firstCall = true;
40
- *
41
- * function sampleAction() {
42
- * if (!firstCall) return 'success';
43
- * firstCall = false;
44
- * throw Error('The first call to this method fails');
45
- * }
46
- *
47
- * withRetries(sampleAction).then(console.log);
48
- * // It will print 'success' after one second, once the second attempt
49
- * // is performed.
50
- */
51
- export declare function withRetries(action: () => Promise<unknown>, maxRetries?: number, interval?: number): Promise<unknown>;
52
16
  export { type Theme, config, isomorphy, JU, themed, ThemeProvider, time, webpack, };
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.29.2",
2
+ "version": "1.30.1",
3
3
  "bin": {
4
4
  "react-utils-build": "bin/build.js",
5
5
  "react-utils-setup": "bin/setup.js"
@@ -11,12 +11,12 @@
11
11
  "@babel/runtime": "^7.23.9",
12
12
  "@dr.pogodin/babel-plugin-react-css-modules": "^6.12.0",
13
13
  "@dr.pogodin/csurf": "^1.13.0",
14
- "@dr.pogodin/js-utils": "^0.0.7",
14
+ "@dr.pogodin/js-utils": "^0.0.9",
15
15
  "@dr.pogodin/react-global-state": "^0.12.0",
16
16
  "@dr.pogodin/react-themes": "^1.6.0",
17
17
  "@jest/environment": "^29.7.0",
18
18
  "axios": "^1.6.7",
19
- "commander": "^11.1.0",
19
+ "commander": "^12.0.0",
20
20
  "compression": "^1.7.4",
21
21
  "config": "^3.3.11",
22
22
  "cookie": "^0.6.0",
@@ -36,7 +36,7 @@
36
36
  "react": "^18.2.0",
37
37
  "react-dom": "^18.2.0",
38
38
  "react-helmet": "^6.1.0",
39
- "react-router-dom": "^6.22.0",
39
+ "react-router-dom": "^6.22.1",
40
40
  "request-ip": "^3.3.0",
41
41
  "rimraf": "^5.0.5",
42
42
  "serialize-javascript": "^6.0.2",
@@ -73,8 +73,8 @@
73
73
  "@types/morgan": "^1.9.9",
74
74
  "@types/node-forge": "^1.3.11",
75
75
  "@types/pretty": "^2.0.3",
76
- "@types/react": "^18.2.51",
77
- "@types/react-dom": "^18.2.18",
76
+ "@types/react": "^18.2.57",
77
+ "@types/react-dom": "^18.2.19",
78
78
  "@types/react-helmet": "^6.1.11",
79
79
  "@types/react-test-renderer": "^18.0.7",
80
80
  "@types/request-ip": "^0.0.41",
@@ -83,13 +83,11 @@
83
83
  "@types/supertest": "^6.0.2",
84
84
  "@types/uuid": "^9.0.8",
85
85
  "@types/webpack": "^5.28.5",
86
- "@typescript-eslint/eslint-plugin": "^6.20.0",
87
- "@typescript-eslint/parser": "^6.20.0",
88
86
  "autoprefixer": "^10.4.17",
89
87
  "babel-jest": "^29.7.0",
90
88
  "babel-loader": "^9.1.3",
91
89
  "babel-plugin-module-resolver": "^5.0.0",
92
- "core-js": "^3.35.1",
90
+ "core-js": "^3.36.0",
93
91
  "css-loader": "^6.10.0",
94
92
  "css-minimizer-webpack-plugin": "^6.0.0",
95
93
  "eslint": "^8.56.0",
@@ -97,18 +95,18 @@
97
95
  "eslint-config-airbnb-typescript": "^17.1.0",
98
96
  "eslint-import-resolver-babel-module": "^5.3.2",
99
97
  "eslint-plugin-import": "^2.29.1",
100
- "eslint-plugin-jest": "^27.6.3",
98
+ "eslint-plugin-jest": "^27.9.0",
101
99
  "eslint-plugin-jsx-a11y": "^6.8.0",
102
100
  "eslint-plugin-react": "^7.33.2",
103
101
  "eslint-plugin-react-hooks": "^4.6.0",
104
102
  "identity-obj-proxy": "^3.0.0",
105
103
  "jest": "^29.7.0",
106
104
  "jest-environment-jsdom": "^29.7.0",
107
- "memfs": "^4.6.0",
105
+ "memfs": "^4.7.6",
108
106
  "mini-css-extract-plugin": "^2.8.0",
109
107
  "mockdate": "^3.0.5",
110
108
  "nodelist-foreach-polyfill": "^1.2.0",
111
- "postcss": "^8.4.33",
109
+ "postcss": "^8.4.35",
112
110
  "postcss-loader": "^8.1.0",
113
111
  "postcss-scss": "^4.0.9",
114
112
  "pretty": "^2.0.0",
@@ -116,8 +114,8 @@
116
114
  "react-test-renderer": "^18.2.0",
117
115
  "regenerator-runtime": "^0.14.1",
118
116
  "resolve-url-loader": "^5.0.0",
119
- "sass": "^1.70.0",
120
- "sass-loader": "^14.1.0",
117
+ "sass": "^1.71.0",
118
+ "sass-loader": "^14.1.1",
121
119
  "sitemap": "^7.1.1",
122
120
  "stylelint": "^16.2.1",
123
121
  "stylelint-config-standard-scss": "^13.0.0",
@@ -125,7 +123,8 @@
125
123
  "tsc-alias": "^1.8.8",
126
124
  "typed-scss-modules": "^8.0.0",
127
125
  "typescript": "^5.3.3",
128
- "webpack": "^5.90.1",
126
+ "typescript-eslint": "^7.0.2",
127
+ "webpack": "^5.90.3",
129
128
  "webpack-dev-middleware": "^7.0.0",
130
129
  "webpack-hot-middleware": "^2.26.1",
131
130
  "webpack-merge": "^5.10.0",
@@ -12,7 +12,12 @@ import * as webpack from './webpack';
12
12
 
13
13
  import type * as JuT from './jest';
14
14
 
15
- export { Barrier, Emitter, Semaphore } from '@dr.pogodin/js-utils';
15
+ export {
16
+ Barrier,
17
+ Emitter,
18
+ Semaphore,
19
+ withRetries,
20
+ } from '@dr.pogodin/js-utils';
16
21
 
17
22
  export { getSsrContext } from './globalState';
18
23
  export { default as splitComponent } from './splitComponent';
@@ -41,58 +46,6 @@ const JU: typeof JuT | null = env !== 'production'
41
46
  ? webpack.requireWeak('./jest', __dirname) as typeof JuT | null
42
47
  : null;
43
48
 
44
- /**
45
- * @category Utilities
46
- * @global
47
- * @func withRetries
48
- * @desc
49
- * ```js
50
- * import { withRetries } from '@dr.pogodin/react-utils';
51
- * ```
52
- * Attempts to perform given asynchronous `action` up to `maxRetries` times,
53
- * with the given `interval` between attempts. If any attempt is successful,
54
- * the result is returned immediately, with no further attempts done;
55
- * otherwise, if all attempts fail, the result Promise rejects after the last
56
- * attempt.
57
- * @param {function} action
58
- * @param {number} [maxRetries=5] Optional. Maximum number of retries. Defaults
59
- * to 5 attempts.
60
- * @param {number} [interval=1000] Optional. Interval between retries [ms].
61
- * Defaults to 1 second.
62
- * @return {Promise} Resolves to the result of successful operation, or
63
- * rejects with the error from the latst failed attempt.
64
- * @example
65
- * import { withRetries } from '@dr.pogodin/react-utils';
66
- *
67
- * let firstCall = true;
68
- *
69
- * function sampleAction() {
70
- * if (!firstCall) return 'success';
71
- * firstCall = false;
72
- * throw Error('The first call to this method fails');
73
- * }
74
- *
75
- * withRetries(sampleAction).then(console.log);
76
- * // It will print 'success' after one second, once the second attempt
77
- * // is performed.
78
- */
79
- export async function withRetries(
80
- action: () => Promise<unknown>,
81
- maxRetries = 5,
82
- interval = 1000,
83
- ) {
84
- /* eslint-disable no-await-in-loop */
85
- for (let n = 1; ; ++n) {
86
- try {
87
- return await action();
88
- } catch (error) {
89
- if (n < maxRetries) await time.timer(interval);
90
- else throw error;
91
- }
92
- }
93
- /* eslint-enable no-await-in-loop */
94
- }
95
-
96
49
  export {
97
50
  type Theme,
98
51
  config,