@dr.pogodin/react-utils 1.40.12 → 1.40.14

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.
@@ -7,18 +7,6 @@ import { timer } from '@dr.pogodin/js-utils';
7
7
  * then stored in the global state to be reused in all other calls), which
8
8
  * is also passed and used in the first client side render, and then updated
9
9
  * with a finite precision to avoid infinite re-rendering loops.
10
- * @param [options] Optional settings.
11
- * @param [options.globalStatePath="currentTime"] Global state path
12
- * to keep the current time value.
13
- * @param [options.precision= 5 * time.SEC_MS] Current time precision.
14
- * The hook won't update the current time stored in the global state unless it
15
- * is different from Date.now() result by this number (in milliseconds).
16
- * Default to 5 seconds.
17
- * @param [options.autorefresh=false] Set `true` to automatically
18
- * refresh time stored in the global state with the given `precision` (and
19
- * thus automatically re-rendering components dependent on this hook, or
20
- * the global state with the period equal to the `precision`.
21
- * @return Unix timestamp in milliseconds.
22
10
  */
23
11
  export declare function useCurrent({ autorefresh, globalStatePath, precision, }?: {
24
12
  autorefresh?: boolean | undefined;
@@ -33,16 +21,6 @@ export declare function useCurrent({ autorefresh, globalStatePath, precision, }?
33
21
  * via the global state. Prior to the value being known (in the very first
34
22
  * request from the user, when the cookie is still missing), zero value is used
35
23
  * as the default value.
36
- *
37
- * @param {object} [options] Optional settings.
38
- * @param {string} [options.cookieName="timezoneOffset"] Optional. The name of
39
- * cookie to use to store the timezone offset. Defaults "timezoneOffset". Set
40
- * to a falsy value to forbid using cookies altogether (in that case the hook
41
- * will always return zero value at the server-side, and in the first render
42
- * at the client-side).
43
- * @param {string} [options.timezoneOffset="timezoneOffset"] Optional.
44
- * The global state path to store the offset. Defaults "timezoneOffset".
45
- * @return {number} Timezone offset.
46
24
  */
47
25
  export declare function useTimezoneOffset({ cookieName, globalStatePath, }?: {
48
26
  cookieName?: string | undefined;
@@ -16,13 +16,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
16
16
  }) : function(o, v) {
17
17
  o["default"] = v;
18
18
  });
19
- var __importStar = (this && this.__importStar) || function (mod) {
20
- if (mod && mod.__esModule) return mod;
21
- var result = {};
22
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
- __setModuleDefault(result, mod);
24
- return result;
25
- };
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
26
36
  Object.defineProperty(exports, "__esModule", { value: true });
27
37
  exports.default = getConfig;
28
38
  const lodash_1 = require("lodash");
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.40.12",
2
+ "version": "1.40.14",
3
3
  "bin": {
4
4
  "react-utils-build": "bin/build.js",
5
5
  "react-utils-setup": "bin/setup.js"
@@ -10,27 +10,27 @@
10
10
  "dependencies": {
11
11
  "@babel/runtime": "^7.26.0",
12
12
  "@dr.pogodin/babel-plugin-react-css-modules": "^6.13.2",
13
- "@dr.pogodin/csurf": "^1.14.0",
13
+ "@dr.pogodin/csurf": "^1.14.1",
14
14
  "@dr.pogodin/js-utils": "^0.0.12",
15
- "@dr.pogodin/react-global-state": "^0.17.4",
15
+ "@dr.pogodin/react-global-state": "^0.17.5",
16
16
  "@dr.pogodin/react-themes": "^1.7.0",
17
17
  "@jest/environment": "^29.7.0",
18
- "axios": "^1.7.7",
18
+ "axios": "^1.7.9",
19
19
  "commander": "^12.1.0",
20
20
  "compression": "^1.7.5",
21
21
  "config": "^3.3.12",
22
- "cookie": "^1.0.1",
22
+ "cookie": "^1.0.2",
23
23
  "cookie-parser": "^1.4.7",
24
24
  "cross-env": "^7.0.3",
25
25
  "dayjs": "^1.11.13",
26
- "express": "^4.21.1",
26
+ "express": "^4.21.2",
27
27
  "helmet": "^8.0.0",
28
28
  "http-status-codes": "^2.3.0",
29
29
  "joi": "^17.13.3",
30
30
  "lodash": "^4.17.21",
31
31
  "morgan": "^1.10.0",
32
32
  "node-forge": "^1.3.1",
33
- "qs": "^6.13.0",
33
+ "qs": "^6.13.1",
34
34
  "raf": "^3.4.1",
35
35
  "react": "^18.3.1",
36
36
  "react-dom": "^18.3.1",
@@ -46,27 +46,27 @@
46
46
  },
47
47
  "description": "Collection of generic ReactJS components and utils",
48
48
  "devDependencies": {
49
- "@babel/cli": "^7.25.9",
49
+ "@babel/cli": "^7.26.4",
50
50
  "@babel/core": "^7.26.0",
51
51
  "@babel/eslint-parser": "^7.25.9",
52
52
  "@babel/eslint-plugin": "^7.25.9",
53
53
  "@babel/node": "^7.26.0",
54
54
  "@babel/plugin-transform-runtime": "^7.25.9",
55
55
  "@babel/preset-env": "^7.26.0",
56
- "@babel/preset-react": "^7.25.9",
56
+ "@babel/preset-react": "^7.26.3",
57
57
  "@babel/preset-typescript": "^7.26.0",
58
58
  "@babel/register": "^7.25.9",
59
59
  "@dr.pogodin/babel-plugin-transform-assets": "^1.2.2",
60
60
  "@dr.pogodin/babel-preset-svgr": "^1.8.0",
61
61
  "@pmmmwh/react-refresh-webpack-plugin": "^0.5.15",
62
62
  "@testing-library/dom": "^10.4.0",
63
- "@testing-library/react": "^16.0.1",
63
+ "@testing-library/react": "^16.1.0",
64
64
  "@testing-library/user-event": "^14.5.2",
65
65
  "@tsconfig/recommended": "^1.0.8",
66
66
  "@types/compression": "^1.7.5",
67
67
  "@types/config": "^3.3.5",
68
68
  "@types/cookie": "^0.6.0",
69
- "@types/cookie-parser": "^1.4.7",
69
+ "@types/cookie-parser": "^1.4.8",
70
70
  "@types/csurf": "^1.11.5",
71
71
  "@types/express": "^4.17.21",
72
72
  "@types/jest": "^29.5.14",
@@ -74,14 +74,13 @@
74
74
  "@types/morgan": "^1.9.9",
75
75
  "@types/node-forge": "^1.3.11",
76
76
  "@types/pretty": "^2.0.3",
77
- "@types/react": "^18.3.12",
78
- "@types/react-dom": "^18.3.1",
77
+ "@types/react": "^18.3.18",
78
+ "@types/react-dom": "^18.3.5",
79
79
  "@types/react-helmet": "^6.1.11",
80
80
  "@types/request-ip": "^0.0.41",
81
81
  "@types/serialize-javascript": "^5.0.4",
82
82
  "@types/serve-favicon": "^2.5.7",
83
83
  "@types/supertest": "^6.0.2",
84
- "@types/uuid": "^10.0.0",
85
84
  "@types/webpack": "^5.28.5",
86
85
  "autoprefixer": "^10.4.20",
87
86
  "babel-jest": "^29.7.0",
@@ -95,14 +94,14 @@
95
94
  "eslint-config-airbnb-typescript": "^18.0.0",
96
95
  "eslint-import-resolver-babel-module": "^5.3.2",
97
96
  "eslint-plugin-import": "^2.31.0",
98
- "eslint-plugin-jest": "^28.9.0",
97
+ "eslint-plugin-jest": "^28.10.0",
99
98
  "eslint-plugin-jsx-a11y": "^6.10.2",
100
99
  "eslint-plugin-react": "^7.37.2",
101
100
  "eslint-plugin-react-hooks": "^4.6.2",
102
101
  "identity-obj-proxy": "^3.0.0",
103
102
  "jest": "^29.7.0",
104
103
  "jest-environment-jsdom": "^29.7.0",
105
- "memfs": "^4.14.0",
104
+ "memfs": "^4.15.0",
106
105
  "mini-css-extract-plugin": "^2.9.2",
107
106
  "mockdate": "^3.0.5",
108
107
  "nodelist-foreach-polyfill": "^1.2.0",
@@ -113,19 +112,19 @@
113
112
  "react-refresh": "^0.14.2",
114
113
  "regenerator-runtime": "^0.14.1",
115
114
  "resolve-url-loader": "^5.0.0",
116
- "sass": "^1.80.7",
117
- "sass-loader": "^16.0.3",
115
+ "sass": "^1.83.0",
116
+ "sass-loader": "^16.0.4",
118
117
  "sitemap": "^8.0.0",
119
118
  "source-map-loader": "^5.0.0",
120
- "stylelint": "^16.10.0",
121
- "stylelint-config-standard-scss": "^13.1.0",
119
+ "stylelint": "^16.12.0",
120
+ "stylelint-config-standard-scss": "^14.0.0",
122
121
  "supertest": "^7.0.0",
123
122
  "tsc-alias": "^1.8.10",
124
- "tstyche": "^3.0.0",
123
+ "tstyche": "^3.1.1",
125
124
  "typed-scss-modules": "^8.0.1",
126
- "typescript": "^5.6.3",
127
- "typescript-eslint": "^8.14.0",
128
- "webpack": "^5.96.1",
125
+ "typescript": "^5.7.2",
126
+ "typescript-eslint": "^8.18.1",
127
+ "webpack": "^5.97.1",
129
128
  "webpack-dev-middleware": "^7.4.2",
130
129
  "webpack-hot-middleware": "^2.26.1",
131
130
  "webpack-merge": "^6.0.1",
@@ -1,6 +1,4 @@
1
- /* global document */
2
-
3
- import Cookie from 'cookie';
1
+ import { serialize } from 'cookie';
4
2
  import dayjs from 'dayjs';
5
3
  import { useEffect } from 'react';
6
4
 
@@ -24,18 +22,6 @@ import { getSsrContext } from './globalState';
24
22
  * then stored in the global state to be reused in all other calls), which
25
23
  * is also passed and used in the first client side render, and then updated
26
24
  * with a finite precision to avoid infinite re-rendering loops.
27
- * @param [options] Optional settings.
28
- * @param [options.globalStatePath="currentTime"] Global state path
29
- * to keep the current time value.
30
- * @param [options.precision= 5 * time.SEC_MS] Current time precision.
31
- * The hook won't update the current time stored in the global state unless it
32
- * is different from Date.now() result by this number (in milliseconds).
33
- * Default to 5 seconds.
34
- * @param [options.autorefresh=false] Set `true` to automatically
35
- * refresh time stored in the global state with the given `precision` (and
36
- * thus automatically re-rendering components dependent on this hook, or
37
- * the global state with the period equal to the `precision`.
38
- * @return Unix timestamp in milliseconds.
39
25
  */
40
26
  // TODO: Should we request the state type as generic parameter, to be able
41
27
  // to verify the give globalStatePath is correct?
@@ -43,7 +29,7 @@ export function useCurrent({
43
29
  autorefresh = false,
44
30
  globalStatePath = 'currentTime',
45
31
  precision = 5 * SEC_MS,
46
- } = {}) {
32
+ } = {}): number {
47
33
  const [now, setter] = useGlobalState<ForceT, number>(globalStatePath, Date.now);
48
34
  useEffect(() => {
49
35
  let timerId: NodeJS.Timeout;
@@ -70,23 +56,13 @@ export function useCurrent({
70
56
  * via the global state. Prior to the value being known (in the very first
71
57
  * request from the user, when the cookie is still missing), zero value is used
72
58
  * as the default value.
73
- *
74
- * @param {object} [options] Optional settings.
75
- * @param {string} [options.cookieName="timezoneOffset"] Optional. The name of
76
- * cookie to use to store the timezone offset. Defaults "timezoneOffset". Set
77
- * to a falsy value to forbid using cookies altogether (in that case the hook
78
- * will always return zero value at the server-side, and in the first render
79
- * at the client-side).
80
- * @param {string} [options.timezoneOffset="timezoneOffset"] Optional.
81
- * The global state path to store the offset. Defaults "timezoneOffset".
82
- * @return {number} Timezone offset.
83
59
  */
84
60
  // TODO: Should we request the state type as generic parameter, to be able
85
61
  // to verify the give globalStatePath is correct?
86
62
  export function useTimezoneOffset({
87
63
  cookieName = 'timezoneOffset',
88
64
  globalStatePath = 'timezoneOffset',
89
- } = {}) {
65
+ } = {}): number {
90
66
  const ssrContext = getSsrContext(false);
91
67
  const [offset, setOffset] = useGlobalState<ForceT, number>(globalStatePath, () => {
92
68
  const value = cookieName && ssrContext?.req?.cookies?.[cookieName];
@@ -97,7 +73,7 @@ export function useTimezoneOffset({
97
73
  const value = date.getTimezoneOffset();
98
74
  setOffset(value);
99
75
  if (cookieName) {
100
- document.cookie = Cookie.serialize(cookieName, value.toString(), { path: '/' });
76
+ document.cookie = serialize(cookieName, value.toString(), { path: '/' });
101
77
  }
102
78
  }, [cookieName, setOffset]);
103
79
  return offset;