@dr.pogodin/react-utils 1.41.17 → 1.42.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.
Files changed (230) hide show
  1. package/babel.config.js +3 -0
  2. package/bin/build.js +5 -8
  3. package/bin/setup.js +2 -1
  4. package/build/development/client/getInj.js +7 -2
  5. package/build/development/client/getInj.js.map +1 -1
  6. package/build/development/client/index.js +1 -2
  7. package/build/development/client/index.js.map +1 -1
  8. package/build/development/client/init.js +16 -13
  9. package/build/development/client/init.js.map +1 -1
  10. package/build/development/index.js +4 -1
  11. package/build/development/index.js.map +1 -1
  12. package/build/development/server/Cache.js +5 -9
  13. package/build/development/server/Cache.js.map +1 -1
  14. package/build/development/server/index.js +14 -11
  15. package/build/development/server/index.js.map +1 -1
  16. package/build/development/server/renderer.js +36 -41
  17. package/build/development/server/renderer.js.map +1 -1
  18. package/build/development/server/server.js +22 -13
  19. package/build/development/server/server.js.map +1 -1
  20. package/build/development/server/utils/errors.js.map +1 -1
  21. package/build/development/shared/components/Button/index.js +2 -3
  22. package/build/development/shared/components/Button/index.js.map +1 -1
  23. package/build/development/shared/components/Checkbox/index.js +3 -1
  24. package/build/development/shared/components/Checkbox/index.js.map +1 -1
  25. package/build/development/shared/components/GenericLink/index.js +13 -6
  26. package/build/development/shared/components/GenericLink/index.js.map +1 -1
  27. package/build/development/shared/components/Input/index.js +5 -1
  28. package/build/development/shared/components/Input/index.js.map +1 -1
  29. package/build/development/shared/components/Link.js +5 -6
  30. package/build/development/shared/components/Link.js.map +1 -1
  31. package/build/development/shared/components/MetaTags.js +31 -24
  32. package/build/development/shared/components/MetaTags.js.map +1 -1
  33. package/build/development/shared/components/Modal/index.js +13 -6
  34. package/build/development/shared/components/Modal/index.js.map +1 -1
  35. package/build/development/shared/components/NavLink.js +6 -6
  36. package/build/development/shared/components/NavLink.js.map +1 -1
  37. package/build/development/shared/components/TextArea/index.js +6 -3
  38. package/build/development/shared/components/TextArea/index.js.map +1 -1
  39. package/build/development/shared/components/WithTooltip/Tooltip.js +35 -39
  40. package/build/development/shared/components/WithTooltip/Tooltip.js.map +1 -1
  41. package/build/development/shared/components/WithTooltip/index.js +27 -21
  42. package/build/development/shared/components/WithTooltip/index.js.map +1 -1
  43. package/build/development/shared/components/YouTubeVideo/index.js +4 -3
  44. package/build/development/shared/components/YouTubeVideo/index.js.map +1 -1
  45. package/build/development/shared/components/selectors/CustomDropdown/Options/index.js +4 -5
  46. package/build/development/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
  47. package/build/development/shared/components/selectors/CustomDropdown/index.js +7 -9
  48. package/build/development/shared/components/selectors/CustomDropdown/index.js.map +1 -1
  49. package/build/development/shared/components/selectors/NativeDropdown/index.js +3 -5
  50. package/build/development/shared/components/selectors/NativeDropdown/index.js.map +1 -1
  51. package/build/development/shared/components/selectors/Switch/index.js +21 -20
  52. package/build/development/shared/components/selectors/Switch/index.js.map +1 -1
  53. package/build/development/shared/utils/config.js +6 -3
  54. package/build/development/shared/utils/config.js.map +1 -1
  55. package/build/development/shared/utils/globalState.js +6 -0
  56. package/build/development/shared/utils/globalState.js.map +1 -1
  57. package/build/development/shared/utils/isomorphy/buildInfo.js.map +1 -1
  58. package/build/development/shared/utils/isomorphy/environment-check.js +6 -1
  59. package/build/development/shared/utils/isomorphy/environment-check.js.map +1 -1
  60. package/build/development/shared/utils/isomorphy/index.js +1 -3
  61. package/build/development/shared/utils/isomorphy/index.js.map +1 -1
  62. package/build/development/shared/utils/jest/E2eSsrEnv.js +26 -17
  63. package/build/development/shared/utils/jest/E2eSsrEnv.js.map +1 -1
  64. package/build/development/shared/utils/jest/global.js +0 -7
  65. package/build/development/shared/utils/jest/global.js.map +1 -1
  66. package/build/development/shared/utils/jest/index.js +15 -4
  67. package/build/development/shared/utils/jest/index.js.map +1 -1
  68. package/build/development/shared/utils/splitComponent.js +37 -19
  69. package/build/development/shared/utils/splitComponent.js.map +1 -1
  70. package/build/development/shared/utils/time.js +3 -3
  71. package/build/development/shared/utils/time.js.map +1 -1
  72. package/build/development/shared/utils/webpack.js +11 -11
  73. package/build/development/shared/utils/webpack.js.map +1 -1
  74. package/build/development/web.bundle.js +31 -31
  75. package/build/production/client/getInj.js +4 -2
  76. package/build/production/client/getInj.js.map +1 -1
  77. package/build/production/client/index.js +2 -2
  78. package/build/production/client/index.js.map +1 -1
  79. package/build/production/client/init.js +4 -2
  80. package/build/production/client/init.js.map +1 -1
  81. package/build/production/index.js +2 -1
  82. package/build/production/index.js.map +1 -1
  83. package/build/production/server/Cache.js +1 -2
  84. package/build/production/server/Cache.js.map +1 -1
  85. package/build/production/server/index.js +9 -5
  86. package/build/production/server/index.js.map +1 -1
  87. package/build/production/server/renderer.js +24 -21
  88. package/build/production/server/renderer.js.map +1 -1
  89. package/build/production/server/server.js +14 -9
  90. package/build/production/server/server.js.map +1 -1
  91. package/build/production/server/utils/errors.js.map +1 -1
  92. package/build/production/shared/components/Button/index.js +1 -1
  93. package/build/production/shared/components/Button/index.js.map +1 -1
  94. package/build/production/shared/components/Checkbox/index.js +1 -1
  95. package/build/production/shared/components/Checkbox/index.js.map +1 -1
  96. package/build/production/shared/components/GenericLink/index.js +6 -4
  97. package/build/production/shared/components/GenericLink/index.js.map +1 -1
  98. package/build/production/shared/components/Input/index.js +3 -1
  99. package/build/production/shared/components/Input/index.js.map +1 -1
  100. package/build/production/shared/components/Link.js +3 -1
  101. package/build/production/shared/components/Link.js.map +1 -1
  102. package/build/production/shared/components/MetaTags.js +5 -2
  103. package/build/production/shared/components/MetaTags.js.map +1 -1
  104. package/build/production/shared/components/Modal/index.js +6 -2
  105. package/build/production/shared/components/Modal/index.js.map +1 -1
  106. package/build/production/shared/components/NavLink.js +4 -1
  107. package/build/production/shared/components/NavLink.js.map +1 -1
  108. package/build/production/shared/components/TextArea/index.js +4 -4
  109. package/build/production/shared/components/TextArea/index.js.map +1 -1
  110. package/build/production/shared/components/WithTooltip/Tooltip.js +37 -38
  111. package/build/production/shared/components/WithTooltip/Tooltip.js.map +1 -1
  112. package/build/production/shared/components/WithTooltip/index.js +4 -4
  113. package/build/production/shared/components/WithTooltip/index.js.map +1 -1
  114. package/build/production/shared/components/YouTubeVideo/index.js +3 -2
  115. package/build/production/shared/components/YouTubeVideo/index.js.map +1 -1
  116. package/build/production/shared/components/selectors/CustomDropdown/Options/index.js +2 -2
  117. package/build/production/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
  118. package/build/production/shared/components/selectors/CustomDropdown/index.js +2 -2
  119. package/build/production/shared/components/selectors/CustomDropdown/index.js.map +1 -1
  120. package/build/production/shared/components/selectors/NativeDropdown/index.js +2 -2
  121. package/build/production/shared/components/selectors/NativeDropdown/index.js.map +1 -1
  122. package/build/production/shared/components/selectors/Switch/index.js +1 -1
  123. package/build/production/shared/components/selectors/Switch/index.js.map +1 -1
  124. package/build/production/shared/utils/config.js +6 -4
  125. package/build/production/shared/utils/config.js.map +1 -1
  126. package/build/production/shared/utils/globalState.js +4 -1
  127. package/build/production/shared/utils/globalState.js.map +1 -1
  128. package/build/production/shared/utils/isomorphy/buildInfo.js.map +1 -1
  129. package/build/production/shared/utils/isomorphy/environment-check.js +5 -1
  130. package/build/production/shared/utils/isomorphy/environment-check.js.map +1 -1
  131. package/build/production/shared/utils/isomorphy/index.js +1 -3
  132. package/build/production/shared/utils/isomorphy/index.js.map +1 -1
  133. package/build/production/shared/utils/jest/E2eSsrEnv.js +15 -8
  134. package/build/production/shared/utils/jest/E2eSsrEnv.js.map +1 -1
  135. package/build/production/shared/utils/jest/global.js +1 -1
  136. package/build/production/shared/utils/jest/global.js.map +1 -1
  137. package/build/production/shared/utils/jest/index.js +13 -5
  138. package/build/production/shared/utils/jest/index.js.map +1 -1
  139. package/build/production/shared/utils/splitComponent.js +16 -8
  140. package/build/production/shared/utils/splitComponent.js.map +1 -1
  141. package/build/production/shared/utils/time.js +2 -2
  142. package/build/production/shared/utils/time.js.map +1 -1
  143. package/build/production/shared/utils/webpack.js +5 -2
  144. package/build/production/shared/utils/webpack.js.map +1 -1
  145. package/build/production/web.bundle.js +1 -1
  146. package/build/production/web.bundle.js.map +1 -1
  147. package/build/types-code/client/getInj.d.ts +1 -1
  148. package/build/types-code/client/index.d.ts +2 -2
  149. package/build/types-code/client/init.d.ts +1 -1
  150. package/build/types-code/index.d.ts +6 -5
  151. package/build/types-code/server/Cache.d.ts +1 -2
  152. package/build/types-code/server/index.d.ts +4 -5
  153. package/build/types-code/server/renderer.d.ts +9 -11
  154. package/build/types-code/server/server.d.ts +3 -5
  155. package/build/types-code/server/utils/errors.d.ts +1 -1
  156. package/build/types-code/shared/components/Button/index.d.ts +2 -2
  157. package/build/types-code/shared/components/TextArea/index.d.ts +3 -3
  158. package/build/types-code/shared/components/WithTooltip/Tooltip.d.ts +7 -1
  159. package/build/types-code/shared/components/index.d.ts +12 -12
  160. package/build/types-code/shared/utils/config.d.ts +1 -1
  161. package/build/types-code/shared/utils/globalState.d.ts +3 -6
  162. package/build/types-code/shared/utils/isomorphy/index.d.ts +1 -3
  163. package/build/types-code/shared/utils/jest/E2eSsrEnv.d.ts +1 -1
  164. package/build/types-code/shared/utils/jest/global.d.ts +4 -4
  165. package/build/types-code/shared/utils/jest/index.d.ts +2 -2
  166. package/build/types-code/shared/utils/webpack.d.ts +1 -1
  167. package/config/babel/node-ssr.d.ts +3 -2
  168. package/config/babel/node-ssr.js +5 -7
  169. package/config/babel/webpack.d.ts +3 -11
  170. package/config/babel/webpack.js +15 -15
  171. package/config/eslint/default.mjs +32 -0
  172. package/config/jest/default.js +10 -6
  173. package/config/jest/resolver.js +2 -0
  174. package/config/jest/setup.js +2 -2
  175. package/config/stylelint/default.js +3 -0
  176. package/config/webpack/app-base.d.ts +0 -6
  177. package/config/webpack/app-base.js +64 -70
  178. package/config/webpack/app-development.d.ts +2 -2
  179. package/config/webpack/app-development.js +8 -12
  180. package/config/webpack/app-production.js +1 -0
  181. package/config/webpack/lib-base.js +20 -18
  182. package/config/webpack/lib-development.js +1 -0
  183. package/config/webpack/lib-production.js +1 -0
  184. package/config/workbox/default.js +2 -5
  185. package/dev-styles.js +1 -0
  186. package/eslint.config.mjs +13 -0
  187. package/node-entry.js +7 -2
  188. package/null.js +1 -0
  189. package/package.json +27 -35
  190. package/prod-styles.js +1 -0
  191. package/src/client/getInj.ts +8 -3
  192. package/src/client/index.tsx +4 -4
  193. package/src/client/init.ts +18 -15
  194. package/src/index.ts +8 -3
  195. package/src/server/Cache.ts +7 -15
  196. package/src/server/index.ts +30 -21
  197. package/src/server/renderer.tsx +77 -67
  198. package/src/server/server.ts +41 -21
  199. package/src/server/utils/errors.ts +6 -3
  200. package/src/shared/components/Button/index.tsx +4 -5
  201. package/src/shared/components/Checkbox/index.tsx +10 -7
  202. package/src/shared/components/GenericLink/index.tsx +14 -7
  203. package/src/shared/components/Input/index.tsx +4 -1
  204. package/src/shared/components/Link.tsx +9 -5
  205. package/src/shared/components/MetaTags.tsx +21 -15
  206. package/src/shared/components/Modal/index.tsx +12 -11
  207. package/src/shared/components/NavLink.tsx +10 -5
  208. package/src/shared/components/TextArea/index.tsx +17 -9
  209. package/src/shared/components/WithTooltip/{Tooltip.tsx → Tooltip.ts} +35 -39
  210. package/src/shared/components/WithTooltip/index.tsx +36 -30
  211. package/src/shared/components/YouTubeVideo/index.tsx +10 -6
  212. package/src/shared/components/selectors/CustomDropdown/Options/index.tsx +5 -6
  213. package/src/shared/components/selectors/CustomDropdown/index.tsx +10 -14
  214. package/src/shared/components/selectors/NativeDropdown/index.tsx +5 -7
  215. package/src/shared/components/selectors/Switch/index.tsx +19 -17
  216. package/src/shared/utils/config.ts +12 -5
  217. package/src/shared/utils/globalState.ts +8 -5
  218. package/src/shared/utils/isomorphy/buildInfo.ts +1 -1
  219. package/src/shared/utils/isomorphy/environment-check.ts +5 -1
  220. package/src/shared/utils/isomorphy/index.ts +4 -6
  221. package/src/shared/utils/jest/E2eSsrEnv.ts +64 -39
  222. package/src/shared/utils/jest/global.ts +6 -8
  223. package/src/shared/utils/jest/{index.tsx → index.ts} +25 -12
  224. package/src/shared/utils/splitComponent.tsx +44 -25
  225. package/src/shared/utils/time.ts +16 -9
  226. package/src/shared/utils/webpack.ts +19 -14
  227. package/webpack.config.ts +36 -10
  228. package/config/eslint/default.json +0 -30
  229. package/config/eslint/jest.json +0 -19
  230. package/config/eslint/typescript.js +0 -46
@@ -1,3 +1,3 @@
1
1
  import 'node-forge/lib/aes';
2
- import type { InjT } from '../shared/utils/globalState';
2
+ import type { InjT } from 'utils/globalState';
3
3
  export default function getInj(): InjT;
@@ -1,7 +1,7 @@
1
- import { type ComponentType } from 'react';
1
+ import type { ComponentType } from 'react';
2
2
  type OptionsT = {
3
3
  dontHydrate?: boolean;
4
- initialState?: any;
4
+ initialState?: unknown;
5
5
  };
6
6
  /**
7
7
  * Prepares and launches the app at client side.
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Initialization of client-side environment.
3
3
  */
4
- import { type BuildInfoT } from '../shared/utils/isomorphy/buildInfo';
4
+ import { type BuildInfoT } from 'utils/isomorphy/buildInfo';
5
5
  declare global {
6
6
  interface Window {
7
7
  __DEV_BUILD_INFO__: BuildInfoT | undefined;
@@ -1,9 +1,10 @@
1
1
  import 'styles/global.scss';
2
- import type ServerFactoryT from './server';
3
- declare const server: (typeof ServerFactoryT) | null;
4
- declare const client: any;
2
+ import type * as ClientM from './client';
3
+ import type * as ServerFactoryM from './server';
4
+ declare const server: typeof ServerFactoryM | null;
5
+ declare const client: typeof ClientM.default | undefined;
5
6
  export { type AsyncCollectionT, 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';
6
- export * from './shared/components';
7
+ export * from 'components';
7
8
  export { type BeforeRenderResT, type BeforeRenderT, type ConfigT, type ServerSsrContext, type ServerT, } from './server';
8
- export { type Listener, 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 'utils';
9
10
  export { client, server };
@@ -2,8 +2,8 @@
2
2
  * Implements the static cache.
3
3
  */
4
4
  export default class Cache<DatumT> {
5
- private items;
6
5
  private maxSize;
6
+ private items;
7
7
  private size;
8
8
  constructor(maxSize: number);
9
9
  /**
@@ -20,7 +20,6 @@ export default class Cache<DatumT> {
20
20
  }): DatumT | null;
21
21
  /**
22
22
  * Adds item to cache.
23
- * @ignore
24
23
  * @param data Item to add.
25
24
  * @param key Key to store the item at.
26
25
  * @param size Byte size of the item.
@@ -1,10 +1,10 @@
1
1
  import 'source-map-support/register';
2
2
  import http from 'http';
3
3
  import 'raf/polyfill';
4
- import { type Configuration } from 'webpack';
4
+ import type { Configuration } from 'webpack';
5
5
  import { type OptionsT as ServerOptionsT, type ServerT, getDefaultCspSettings } from './server';
6
6
  import { errors } from './utils';
7
- export { type BeforeRenderResT, type BeforeRenderT, type ConfigT, type ServerSsrContext, } from './renderer';
7
+ export type { BeforeRenderResT, BeforeRenderT, ConfigT, ServerSsrContext, } from './renderer';
8
8
  export { errors, getDefaultCspSettings, type ServerT };
9
9
  type OptionsT = ServerOptionsT & {
10
10
  https?: {
@@ -129,10 +129,9 @@ type OptionsT = ServerOptionsT & {
129
129
  * @param {number} [options.maxSsrRounds=10] Maximum number of SSR rounds.
130
130
  * @param {number} [options.ssrTimeout=1000] SSR timeout in milliseconds,
131
131
  * defaults to 1 second.
132
- * @return {Promise<{ expressServer: object, httpServer: object }>} Resolves to
133
- * an object with created Express and HTTP servers.
132
+ * @return Resolves to an object with created Express and HTTP servers.
134
133
  */
135
- declare function launchServer(webpackConfig: Configuration, options: OptionsT): Promise<{
134
+ declare function launchServer(webpackConfig: Configuration, options?: OptionsT): Promise<{
136
135
  expressServer: ServerT;
137
136
  httpServer: http.Server;
138
137
  }>;
@@ -1,18 +1,18 @@
1
1
  /**
2
2
  * ExpressJS middleware for server-side rendering of a ReactJS app.
3
3
  */
4
- import { type Request, type RequestHandler } from 'express';
5
- import { type ComponentType } from 'react';
4
+ import type { Request, RequestHandler } from 'express';
5
+ import type { ComponentType } from 'react';
6
6
  import winston from 'winston';
7
7
  import { SsrContext } from '@dr.pogodin/react-global-state';
8
- import { type BuildInfoT } from '../shared/utils/isomorphy/buildInfo';
9
- import { type ChunkGroupsT, type SsrContextT } from '../shared/utils/globalState';
10
- import { type Configuration } from 'webpack';
8
+ import { type BuildInfoT } from 'utils/isomorphy/buildInfo';
9
+ import type { ChunkGroupsT, SsrContextT } from 'utils/globalState';
10
+ import type { Configuration } from 'webpack';
11
11
  interface LogMethodI {
12
- (level: string, message: string, ...meta: any[]): void;
12
+ (level: string, message: string, ...meta: unknown[]): void;
13
13
  }
14
14
  interface LeveledLogMethodI {
15
- (message: string, ...meta: any[]): void;
15
+ (message: string, ...meta: unknown[]): void;
16
16
  }
17
17
  export interface LoggerI {
18
18
  debug: LeveledLogMethodI;
@@ -40,9 +40,7 @@ type ScriptT = {
40
40
  /**
41
41
  * Given an incoming HTTP requests, it deduces whether Brotli-encoded responses
42
42
  * are acceptable to the caller.
43
- * @param {object} req
44
- * @return {boolean}
45
- * @ignore
43
+ * @param req
46
44
  */
47
45
  export declare function isBrotliAcceptable(req: Request): boolean;
48
46
  /**
@@ -60,7 +58,7 @@ export type ConfigT = {
60
58
  export type BeforeRenderResT = {
61
59
  configToInject?: ConfigT;
62
60
  extraScripts?: Array<ScriptT | string>;
63
- initialState?: any;
61
+ initialState?: unknown;
64
62
  };
65
63
  export type BeforeRenderT = (req: Request, config: ConfigT) => BeforeRenderResT | Promise<BeforeRenderResT>;
66
64
  type CacheRefT = {
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import { type Express, type Request } from 'express';
5
5
  import { type HelmetOptions } from 'helmet';
6
- import { type Configuration } from 'webpack';
6
+ import type { Configuration } from 'webpack';
7
7
  import { type LoggerI, type OptionsT as RendererOptionsT } from './renderer';
8
8
  export type CspOptionsT = Exclude<HelmetOptions['contentSecurityPolicy'], boolean | undefined>;
9
9
  /**
@@ -22,15 +22,13 @@ export type CspOptionsT = Exclude<HelmetOptions['contentSecurityPolicy'], boolea
22
22
  * which is added dynamically for each request.
23
23
  */
24
24
  export declare function getDefaultCspSettings(): {
25
- directives: {
26
- [x: string]: string[];
27
- };
25
+ directives: Record<string, string[]>;
28
26
  };
29
27
  export type ServerT = Express & {
30
28
  logger: LoggerI;
31
29
  };
32
30
  export type OptionsT = RendererOptionsT & {
33
- beforeExpressJsError?: (server: ServerT) => boolean | Promise<boolean | void> | void;
31
+ beforeExpressJsError?: (server: ServerT) => boolean | Promise<boolean>;
34
32
  beforeExpressJsSetup?: (server: ServerT) => Promise<void> | void;
35
33
  cspSettingsHook?: (defaultOptions: CspOptionsT, req: Request) => CspOptionsT;
36
34
  devMode?: boolean;
@@ -94,4 +94,4 @@ export declare function fail(message: string, statusCode?: CODES): Error;
94
94
  * @param [statusCode=500] HTTP status code. Defaults to 400 (Bad
95
95
  * Request).
96
96
  */
97
- export declare function assert(value: any, schema: joi.AnySchema, message?: string, statusCode?: CODES): void;
97
+ export declare function assert(value: unknown, schema: joi.AnySchema, message?: string, statusCode?: CODES): void;
@@ -1,4 +1,4 @@
1
- import type { PointerEventHandler, ReactNode } from 'react';
1
+ import type { FunctionComponent, PointerEventHandler, ReactNode } from 'react';
2
2
  import { type Theme } from '@dr.pogodin/react-themes';
3
3
  type PropsT = {
4
4
  active?: boolean;
@@ -14,7 +14,7 @@ type PropsT = {
14
14
  theme: Theme<'active' | 'button' | 'disabled'>;
15
15
  to?: object | string;
16
16
  };
17
- export declare const BaseButton: React.FunctionComponent<PropsT>;
17
+ export declare const BaseButton: FunctionComponent<PropsT>;
18
18
  /**
19
19
  * Button component theme: a map of CSS
20
20
  * class names to append to button elements:
@@ -1,11 +1,11 @@
1
- import { type FocusEventHandler } from 'react';
1
+ import { type ChangeEventHandler, type FocusEventHandler, type KeyboardEventHandler } from 'react';
2
2
  import { type Theme } from '@dr.pogodin/react-themes';
3
3
  type ThemeKeyT = 'container' | 'hidden' | 'textarea';
4
4
  type Props = {
5
5
  disabled?: boolean;
6
6
  onBlur?: FocusEventHandler<HTMLTextAreaElement>;
7
- onChange?: React.ChangeEventHandler<HTMLTextAreaElement>;
8
- onKeyDown?: React.KeyboardEventHandler<HTMLTextAreaElement>;
7
+ onChange?: ChangeEventHandler<HTMLTextAreaElement>;
8
+ onKeyDown?: KeyboardEventHandler<HTMLTextAreaElement>;
9
9
  placeholder?: string;
10
10
  theme: Theme<ThemeKeyT>;
11
11
  value?: string;
@@ -4,6 +4,11 @@
4
4
  * performance during animation.
5
5
  */
6
6
  import { type FunctionComponent, type ReactNode, type RefObject } from 'react';
7
+ import type { Theme } from '@dr.pogodin/react-themes';
8
+ /**
9
+ * Valid placements of the rendered tooltip. They will be overriden when
10
+ * necessary to fit the tooltip within the viewport.
11
+ */
7
12
  export declare enum PLACEMENTS {
8
13
  ABOVE_CURSOR = "ABOVE_CURSOR",
9
14
  ABOVE_ELEMENT = "ABOVE_ELEMENT",
@@ -11,9 +16,10 @@ export declare enum PLACEMENTS {
11
16
  BELOW_ELEMENT = "BELOW_ELEMENT"
12
17
  }
13
18
  export type ThemeKeysT = 'appearance' | 'arrow' | 'content' | 'container';
19
+ type TooltipThemeT = Theme<ThemeKeysT>;
14
20
  declare const Tooltip: FunctionComponent<{
15
21
  children?: ReactNode;
16
22
  ref?: RefObject<unknown>;
17
- theme: any;
23
+ theme: TooltipThemeT;
18
24
  }>;
19
25
  export default Tooltip;
@@ -1,16 +1,16 @@
1
1
  /**
2
2
  * Just an aggregation of all exported components into a single module.
3
3
  */
4
- export * from './selectors';
5
- export { default as Button, BaseButton } from './Button';
6
- export { default as Checkbox } from './Checkbox';
7
- export { default as Input } from './Input';
8
- export { default as Link } from './Link';
9
- export { default as PageLayout } from './PageLayout';
10
- export { default as MetaTags } from './MetaTags';
11
- export { default as Modal, BaseModal } from './Modal';
12
- export { default as NavLink } from './NavLink';
13
- export { default as Throbber } from './Throbber';
14
- export { default as WithTooltip } from './WithTooltip';
15
- export { default as YouTubeVideo } from './YouTubeVideo';
4
+ export * from 'components/selectors';
5
+ export { default as Button, BaseButton } from 'components/Button';
6
+ export { default as Checkbox } from 'components/Checkbox';
7
+ export { default as Input } from 'components/Input';
8
+ export { default as Link } from 'components/Link';
9
+ export { default as PageLayout } from 'components/PageLayout';
10
+ export { default as MetaTags } from 'components/MetaTags';
11
+ export { default as Modal, BaseModal } from 'components/Modal';
12
+ export { default as NavLink } from 'components/NavLink';
13
+ export { default as Throbber } from 'components/Throbber';
14
+ export { default as WithTooltip } from 'components/WithTooltip';
15
+ export { default as YouTubeVideo } from 'components/YouTubeVideo';
16
16
  export { default as TextArea } from './TextArea';
@@ -1,2 +1,2 @@
1
- declare const config: any;
1
+ declare const config: Record<string, unknown>;
2
2
  export default config;
@@ -1,13 +1,10 @@
1
1
  import type { Request } from 'express';
2
2
  import { type SsrContext } from '@dr.pogodin/react-global-state';
3
- export type ChunkGroupsT = {
4
- [chunkName: string]: string[];
5
- };
3
+ /** Mapping "chunkName" > array of asset paths. */
4
+ export type ChunkGroupsT = Record<string, string[]>;
6
5
  export type InjT = {
7
6
  CHUNK_GROUPS?: ChunkGroupsT;
8
- CONFIG?: {
9
- [key: string]: any;
10
- };
7
+ CONFIG?: Record<string, unknown>;
11
8
  ISTATE?: unknown;
12
9
  };
13
10
  declare global {
@@ -3,18 +3,16 @@ import { IS_CLIENT_SIDE, IS_SERVER_SIDE } from './environment-check';
3
3
  /**
4
4
  * Returns `true` if development version of the code is running;
5
5
  * `false` otherwise.
6
- * @return {boolean}
7
6
  */
8
7
  export declare function isDevBuild(): boolean;
9
8
  /**
10
9
  * Returns `true` if production build of the code is running;
11
10
  * `false` otherwise.
12
- * @return {boolean}
13
11
  */
14
12
  export declare function isProdBuild(): boolean;
15
13
  /**
16
14
  * Returns build timestamp of the front-end JS bundle.
17
- * @return {string} ISO date/time string.
15
+ * @return ISO date/time string.
18
16
  */
19
17
  export declare function buildTimestamp(): string;
20
18
  export { IS_CLIENT_SIDE, IS_SERVER_SIDE, getBuildInfo };
@@ -18,7 +18,7 @@ export default class E2eSsrEnv extends JsdomEnv {
18
18
  * Loads Webpack config, and exposes it to the environment via global
19
19
  * webpackConfig object.
20
20
  */
21
- loadWebpackConfig(): void;
21
+ private loadWebpackConfig;
22
22
  /**
23
23
  * Executes Webpack build.
24
24
  * @return {Promise}
@@ -1,12 +1,12 @@
1
- import { type IFs } from 'memfs';
2
- import webpack from 'webpack';
1
+ import type { IFs } from 'memfs';
2
+ import type { Configuration, StatsCompilation } from 'webpack';
3
3
  declare global {
4
4
  interface Window {
5
5
  ssrMarkup: string | undefined;
6
6
  ssrStatus: number | undefined;
7
- webpackConfig: webpack.Configuration | undefined;
7
+ webpackConfig: Configuration | undefined;
8
8
  webpackOutputFs: IFs;
9
- webpackStats?: webpack.StatsCompilation;
9
+ webpackStats?: StatsCompilation;
10
10
  }
11
11
  }
12
12
  export default function getGlobal(): Window;
@@ -1,4 +1,4 @@
1
- import type { AxiosRequestConfig, AxiosResponse } from 'axios';
1
+ import type { AxiosRequestConfig, AxiosResponse, AxiosStatic } from 'axios';
2
2
  import { type ReactNode, act } from 'react';
3
3
  import { type RenderResult } from '@testing-library/react';
4
4
  /**
@@ -24,7 +24,7 @@ export declare function unmockClientSide(): void;
24
24
  */
25
25
  export declare function getMockUuid(seed?: number): string;
26
26
  export type AxiosRequestHandlerT = (config: AxiosRequestConfig) => Partial<AxiosResponse> | null | undefined;
27
- export declare function mockAxios(handlers: AxiosRequestHandlerT[]): any;
27
+ export declare function mockAxios(handlers: AxiosRequestHandlerT[]): AxiosStatic;
28
28
  /**
29
29
  * Advances mock timers, and mock date by the specified time.
30
30
  * @param {number} time Time step [ms].
@@ -5,7 +5,7 @@
5
5
  * @param [basePath]
6
6
  * @return Required module.
7
7
  */
8
- export declare function requireWeak<Module extends NodeJS.Module>(modulePath: string, basePath?: string): Module | null;
8
+ export declare function requireWeak<T extends object>(modulePath: string, basePath?: string): T | null;
9
9
  /**
10
10
  * Resolves specified module path with help of Babel's module resolver.
11
11
  * Yes, the function itself just returns its argument to the caller, but Babel
@@ -1,4 +1,5 @@
1
- import { type BabelCompilerI, type ConfigT, type OptionsT as WebpackConfigOptionsT } from './webpack';
1
+ import type { TransformOptions } from '@babel/core';
2
+ import { type BabelCompilerI, type OptionsT as WebpackConfigOptionsT } from './webpack';
2
3
  type OptionsT = WebpackConfigOptionsT & {
3
4
  baseAssetsOutputPath?: string;
4
5
  };
@@ -13,5 +14,5 @@ type OptionsT = WebpackConfigOptionsT & {
13
14
  * assets.
14
15
  * @return Generated config.
15
16
  */
16
- export default function getConfig(babel: BabelCompilerI, ops?: OptionsT): ConfigT;
17
+ export default function getConfig(babel: BabelCompilerI, ops?: OptionsT): TransformOptions;
17
18
  export {};
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- /* eslint-disable import/no-extraneous-dependencies */
3
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
3
  if (k2 === undefined) k2 = k;
5
4
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -48,13 +47,14 @@ const webpack_1 = __importStar(require("./webpack"));
48
47
  * @return Created config object.
49
48
  */
50
49
  function newBase(babel, options = {}) {
50
+ var _a;
51
51
  const config = (0, webpack_1.default)(babel, Object.assign({ modules: 'cjs', targets: 'current node' }, options));
52
- const baseAssetsOutputPath = options.baseAssetsOutputPath || '';
52
+ const baseAssetsOutputPath = (_a = options.baseAssetsOutputPath) !== null && _a !== void 0 ? _a : '';
53
53
  config.plugins.push(['@dr.pogodin/transform-assets', {
54
54
  extensions: ['gif', 'jpeg', 'jpg', 'png'],
55
55
  name: `${baseAssetsOutputPath}/images/[md4:hash:20].[ext]`,
56
56
  }]);
57
- const moduleResolverPluginOps = (config.plugins.find((x) => x[0] === 'module-resolver'))[1];
57
+ const moduleResolverPluginOps = config.plugins.find((x) => Array.isArray(x) && x[0] === 'module-resolver')[1];
58
58
  moduleResolverPluginOps.transformFunctions = [
59
59
  'requireWeak',
60
60
  'resolveWeak',
@@ -71,12 +71,10 @@ function newBase(babel, options = {}) {
71
71
  *
72
72
  * **Beware:** It mutates `config`.
73
73
  *
74
- * @param {object} config
75
- * @return {object} Returns mutated config for chaining.
76
- * @ignore
74
+ * @param config
77
75
  */
78
76
  function addStyling(config) {
79
- const cssModulesOps = config.plugins.find(([name]) => name === '@dr.pogodin/react-css-modules')[1];
77
+ const cssModulesOps = config.plugins.find((item) => Array.isArray(item) && item[0] === '@dr.pogodin/react-css-modules')[1];
80
78
  cssModulesOps.replaceImport = true;
81
79
  return config;
82
80
  }
@@ -1,3 +1,4 @@
1
+ import type { TransformOptions } from '@babel/core';
1
2
  export interface BabelCompilerI {
2
3
  env: () => string;
3
4
  }
@@ -9,21 +10,12 @@ export declare enum ENVIRONMENTS {
9
10
  PROD = "production",
10
11
  TEST = "test"
11
12
  }
12
- export interface PresetOrPluginOptionsI {
13
- }
14
- type PresetOrPluginT = string | [string, PresetOrPluginOptionsI];
15
- export type ConfigT = {
16
- presets: PresetOrPluginT[];
17
- plugins: PresetOrPluginT[];
18
- };
19
13
  type ModuleT = 'amd' | 'auto' | 'cjs' | 'commonjs' | 'systemjs' | 'umd' | false;
20
14
  export type OptionsT = {
21
15
  modules?: ModuleT;
22
16
  noRR?: boolean;
23
17
  noStyling?: boolean;
24
- targets?: string | string[] | {
25
- [key: string]: string;
26
- };
18
+ targets?: string | string[] | Record<string, string>;
27
19
  typescript?: boolean;
28
20
  };
29
21
  /**
@@ -38,5 +30,5 @@ export type OptionsT = {
38
30
  * `@babel/preset-env`.
39
31
  * @return Generated config.
40
32
  */
41
- export default function getPreset(babel: BabelCompilerI, ops?: OptionsT): ConfigT;
33
+ export default function getPreset(babel: BabelCompilerI, ops?: OptionsT): TransformOptions;
42
34
  export {};
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ENVIRONMENTS = void 0;
4
4
  exports.default = getPreset;
5
- const { generateScopedNameFactory, } = require('@dr.pogodin/babel-plugin-react-css-modules/utils');
6
- const generateScopedNameDev = generateScopedNameFactory('[package]___[path][name]___[local]___[hash:base64:6]');
7
- const generateScopedNameProd = generateScopedNameFactory('[hash:base64:6]');
5
+ const utils_1 = require("@dr.pogodin/babel-plugin-react-css-modules/utils");
6
+ const generateScopedNameDev = (0, utils_1.generateScopedNameFactory)('[package]___[path][name]___[local]___[hash:base64:6]');
7
+ const generateScopedNameProd = (0, utils_1.generateScopedNameFactory)('[hash:base64:6]');
8
8
  /**
9
9
  * Supported Babel environments.
10
10
  */
@@ -20,14 +20,24 @@ var ENVIRONMENTS;
20
20
  * @return Generated config.
21
21
  */
22
22
  function newBaseConfig(options) {
23
- var _a;
23
+ var _a, _b;
24
24
  return {
25
+ plugins: [
26
+ ['module-resolver', {
27
+ extensions: ['.js', '.jsx', '.ts', '.tsx'],
28
+ root: [
29
+ './src/shared',
30
+ './src',
31
+ ],
32
+ }],
33
+ '@babel/transform-runtime',
34
+ ],
25
35
  presets: [
26
36
  ['@babel/env', {
27
37
  // Leaves it to the Webpack to deal with modules.
28
38
  modules: (_a = options.modules) !== null && _a !== void 0 ? _a : false,
29
39
  // Chrome 69 is the browser/WebView for Android 9 (API level 28).
30
- targets: options.targets || 'defaults or chrome >= 69',
40
+ targets: (_b = options.targets) !== null && _b !== void 0 ? _b : 'defaults or chrome >= 69',
31
41
  }],
32
42
  // TODO: Starting from Babel 8, "automatic" will be the default runtime,
33
43
  // thus once upgraded to Babel 8, runtime should be removed from
@@ -35,16 +45,6 @@ function newBaseConfig(options) {
35
45
  ['@babel/react', { runtime: 'automatic' }],
36
46
  '@dr.pogodin/babel-preset-svgr',
37
47
  ],
38
- plugins: [
39
- ['module-resolver', {
40
- extensions: ['.js', '.jsx', '.ts', '.tsx'],
41
- root: [
42
- './src/shared',
43
- './src',
44
- ],
45
- }],
46
- '@babel/transform-runtime',
47
- ],
48
48
  };
49
49
  }
50
50
  /**
@@ -0,0 +1,32 @@
1
+ /* eslint-disable import/no-extraneous-dependencies */
2
+ import { defineConfig } from 'eslint/config';
3
+
4
+ import eslintConfigs from '@dr.pogodin/eslint-configs';
5
+
6
+ export default defineConfig([{
7
+ ignores: [
8
+ '*.d.ts',
9
+ '__coverage__',
10
+ 'build/',
11
+ 'docs/build/',
12
+ ],
13
+ }, {
14
+ name: '@dr.pogodin/react-utils/common',
15
+
16
+ extends: [
17
+ eslintConfigs.configs.javascript,
18
+ eslintConfigs.configs.typescript,
19
+ eslintConfigs.configs.react,
20
+ ],
21
+ ignores: ['__tests__/**'],
22
+ }, {
23
+ name: '@dr.pogodin/react-utils/tests',
24
+
25
+ extends: [
26
+ eslintConfigs.configs.javascript,
27
+ eslintConfigs.configs.typescript,
28
+ eslintConfigs.configs.react,
29
+ eslintConfigs.configs.jest,
30
+ ],
31
+ files: ['__tests__/**'],
32
+ }]);
@@ -1,3 +1,6 @@
1
+ /* eslint-disable import/no-commonjs */
2
+ /* global __dirname, module, process, require */
3
+
1
4
  const path = require('path');
2
5
 
3
6
  const globalLibDir = path.resolve(process.execPath, '../../lib/node_modules');
@@ -18,21 +21,22 @@ module.exports = {
18
21
  modulePathIgnorePatterns: ['<rootDir>/build/'],
19
22
  resolver: `${__dirname}/resolver.js`,
20
23
  rootDir: '../..',
24
+ setupFilesAfterEnv: [
25
+ '<rootDir>/config/jest/setup.js',
26
+ ],
27
+ testEnvironmentOptions: {
28
+ url: 'http://localhost',
29
+ },
21
30
  testMatch: ['**/__tests__/**/*.(j|t)s?(x)'],
22
31
  testPathIgnorePatterns: [
23
32
  '/__assets__/',
24
33
  '/node_modules/',
25
34
  ],
26
- testEnvironmentOptions: {
27
- url: 'http://localhost',
28
- },
29
35
  transform: {
30
36
  '\\.((j|t)sx?|svg)$': 'babel-jest',
31
37
  },
32
38
  transformIgnorePatterns: [
33
39
  '/node_modules/(?!@dr.pogodin/react-utils)',
34
40
  ],
35
- setupFilesAfterEnv: [
36
- '<rootDir>/config/jest/setup.js',
37
- ],
41
+
38
42
  };
@@ -1,3 +1,5 @@
1
+ /* global module */
2
+
1
3
  module.exports = (path, options) => {
2
4
  const ops = { ...options };
3
5
 
@@ -1,6 +1,6 @@
1
- /* eslint-disable global-require, import/no-extraneous-dependencies */
2
- /* global globalThis */
1
+ /* global globalThis, require */
3
2
 
3
+ // eslint-disable-next-line import/no-unassigned-import
4
4
  import 'raf/polyfill';
5
5
 
6
6
  // TODO: This is a temporary polyfill necessary for react-router,
@@ -1,3 +1,5 @@
1
+ /* global module */
2
+
1
3
  const camelCaseRegex = /^[a-z][a-zA-Z0-9]+$/;
2
4
  const kebabCase = /^([a-z][a-z0-9]*)(-[a-z0-9]+)*$/;
3
5
 
@@ -5,6 +7,7 @@ const namePattern = new RegExp(
5
7
  `(${camelCaseRegex.source})|(${kebabCase.source})`,
6
8
  );
7
9
 
10
+ // eslint-disable-next-line import/no-commonjs
8
11
  module.exports = {
9
12
  extends: 'stylelint-config-standard-scss',
10
13
  rules: {
@@ -1,9 +1,3 @@
1
- /**
2
- * @category Configs
3
- * @module webpack/app-base
4
- * @desc
5
- * Base [Webpack](https://webpack.js.org/) configuration for apps.
6
- */
7
1
  import nodeFs from 'fs';
8
2
  import { type Configuration, type RuleSetRule } from 'webpack';
9
3
  export type BuildInfoT = {