@dr.pogodin/react-utils 1.25.5 → 1.26.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.
Files changed (294) hide show
  1. package/babel.config.js +3 -1
  2. package/bin/build.js +25 -5
  3. package/build/development/client/getInj.js +9 -8
  4. package/build/development/client/getInj.js.map +1 -1
  5. package/build/development/client/index.js +6 -3
  6. package/build/development/client/index.js.map +1 -1
  7. package/build/development/client/init.js +4 -0
  8. package/build/development/client/init.js.map +1 -1
  9. package/build/development/index.js +168 -42
  10. package/build/development/index.js.map +1 -1
  11. package/build/development/server/Cache.js +13 -13
  12. package/build/development/server/Cache.js.map +1 -1
  13. package/build/development/server/index.js +16 -24
  14. package/build/development/server/index.js.map +1 -1
  15. package/build/development/server/renderer.js +56 -44
  16. package/build/development/server/renderer.js.map +1 -1
  17. package/build/development/server/server.js +9 -5
  18. package/build/development/server/server.js.map +1 -1
  19. package/build/development/server/utils/errors.js +12 -9
  20. package/build/development/server/utils/errors.js.map +1 -1
  21. package/build/development/server/utils/index.js +2 -2
  22. package/build/development/server/utils/index.js.map +1 -1
  23. package/build/development/shared/components/Button/index.js +8 -7
  24. package/build/development/shared/components/Button/index.js.map +1 -1
  25. package/build/development/shared/components/Checkbox/index.js +25 -28
  26. package/build/development/shared/components/Checkbox/index.js.map +1 -1
  27. package/build/development/shared/components/Dropdown/index.js +25 -19
  28. package/build/development/shared/components/Dropdown/index.js.map +1 -1
  29. package/build/development/shared/components/GenericLink/index.js +44 -37
  30. package/build/development/shared/components/GenericLink/index.js.map +1 -1
  31. package/build/development/shared/components/Input/index.js +8 -9
  32. package/build/development/shared/components/Input/index.js.map +1 -1
  33. package/build/development/shared/components/Link.js +10 -9
  34. package/build/development/shared/components/Link.js.map +1 -1
  35. package/build/development/shared/components/MetaTags.js +22 -18
  36. package/build/development/shared/components/MetaTags.js.map +1 -1
  37. package/build/development/shared/components/Modal/index.js +17 -18
  38. package/build/development/shared/components/Modal/index.js.map +1 -1
  39. package/build/development/shared/components/NavLink.js +10 -9
  40. package/build/development/shared/components/NavLink.js.map +1 -1
  41. package/build/development/shared/components/PageLayout/index.js +17 -20
  42. package/build/development/shared/components/PageLayout/index.js.map +1 -1
  43. package/build/development/shared/components/ScalableRect/index.js +27 -7
  44. package/build/development/shared/components/ScalableRect/index.js.map +1 -1
  45. package/build/development/shared/components/Throbber/index.js +14 -23
  46. package/build/development/shared/components/Throbber/index.js.map +1 -1
  47. package/build/development/shared/components/WithTooltip/Tooltip.js +20 -24
  48. package/build/development/shared/components/WithTooltip/Tooltip.js.map +1 -1
  49. package/build/development/shared/components/WithTooltip/index.js +11 -11
  50. package/build/development/shared/components/WithTooltip/index.js.map +1 -1
  51. package/build/development/shared/components/YouTubeVideo/index.js +16 -15
  52. package/build/development/shared/components/YouTubeVideo/index.js.map +1 -1
  53. package/build/development/shared/components/index.js +2 -2
  54. package/build/development/shared/components/index.js.map +1 -1
  55. package/build/development/shared/utils/config.js +1 -2
  56. package/build/development/shared/utils/config.js.map +1 -1
  57. package/build/development/shared/utils/globalState.js +15 -0
  58. package/build/development/shared/utils/globalState.js.map +1 -0
  59. package/build/development/shared/utils/index.js +13 -11
  60. package/build/development/shared/utils/index.js.map +1 -1
  61. package/build/development/shared/utils/isomorphy/buildInfo.js +7 -3
  62. package/build/development/shared/utils/isomorphy/buildInfo.js.map +1 -1
  63. package/build/development/shared/utils/isomorphy/environment-check.js +2 -4
  64. package/build/development/shared/utils/isomorphy/environment-check.js.map +1 -1
  65. package/build/development/shared/utils/isomorphy/index.js.map +1 -1
  66. package/build/development/shared/utils/jest/E2eSsrEnv.js +35 -28
  67. package/build/development/shared/utils/jest/E2eSsrEnv.js.map +1 -1
  68. package/build/development/shared/utils/jest/global.js +17 -0
  69. package/build/development/shared/utils/jest/global.js.map +1 -0
  70. package/build/development/shared/utils/jest/index.js +18 -11
  71. package/build/development/shared/utils/jest/index.js.map +1 -1
  72. package/build/development/shared/utils/splitComponent.js +25 -34
  73. package/build/development/shared/utils/splitComponent.js.map +1 -1
  74. package/build/development/shared/utils/time.js +16 -13
  75. package/build/development/shared/utils/time.js.map +1 -1
  76. package/build/development/shared/utils/webpack.js +3 -3
  77. package/build/development/shared/utils/webpack.js.map +1 -1
  78. package/build/development/web.bundle.js +92 -82
  79. package/build/production/client/getInj.js +1 -1
  80. package/build/production/client/getInj.js.map +1 -1
  81. package/build/production/client/index.js +4 -4
  82. package/build/production/client/index.js.map +1 -1
  83. package/build/production/client/init.js +3 -1
  84. package/build/production/client/init.js.map +1 -1
  85. package/build/production/index.js +1 -1
  86. package/build/production/index.js.map +1 -1
  87. package/build/production/server/Cache.js +7 -8
  88. package/build/production/server/Cache.js.map +1 -1
  89. package/build/production/server/index.js +5 -4
  90. package/build/production/server/index.js.map +1 -1
  91. package/build/production/server/renderer.js +32 -30
  92. package/build/production/server/renderer.js.map +1 -1
  93. package/build/production/server/server.js +7 -5
  94. package/build/production/server/server.js.map +1 -1
  95. package/build/production/server/utils/errors.js +9 -10
  96. package/build/production/server/utils/errors.js.map +1 -1
  97. package/build/production/server/utils/index.js +1 -1
  98. package/build/production/server/utils/index.js.map +1 -1
  99. package/build/production/shared/components/Button/index.js +4 -4
  100. package/build/production/shared/components/Button/index.js.map +1 -1
  101. package/build/production/shared/components/Checkbox/index.js +12 -12
  102. package/build/production/shared/components/Checkbox/index.js.map +1 -1
  103. package/build/production/shared/components/Dropdown/index.js +11 -11
  104. package/build/production/shared/components/Dropdown/index.js.map +1 -1
  105. package/build/production/shared/components/GenericLink/index.js +25 -20
  106. package/build/production/shared/components/GenericLink/index.js.map +1 -1
  107. package/build/production/shared/components/Input/index.js +7 -7
  108. package/build/production/shared/components/Input/index.js.map +1 -1
  109. package/build/production/shared/components/Link.js +2 -2
  110. package/build/production/shared/components/Link.js.map +1 -1
  111. package/build/production/shared/components/MetaTags.js +10 -10
  112. package/build/production/shared/components/MetaTags.js.map +1 -1
  113. package/build/production/shared/components/Modal/index.js +2 -2
  114. package/build/production/shared/components/Modal/index.js.map +1 -1
  115. package/build/production/shared/components/NavLink.js +1 -1
  116. package/build/production/shared/components/NavLink.js.map +1 -1
  117. package/build/production/shared/components/PageLayout/index.js +2 -2
  118. package/build/production/shared/components/PageLayout/index.js.map +1 -1
  119. package/build/production/shared/components/ScalableRect/index.js +7 -3
  120. package/build/production/shared/components/ScalableRect/index.js.map +1 -1
  121. package/build/production/shared/components/Throbber/index.js +2 -2
  122. package/build/production/shared/components/Throbber/index.js.map +1 -1
  123. package/build/production/shared/components/WithTooltip/Tooltip.js +13 -13
  124. package/build/production/shared/components/WithTooltip/Tooltip.js.map +1 -1
  125. package/build/production/shared/components/WithTooltip/index.js +3 -3
  126. package/build/production/shared/components/WithTooltip/index.js.map +1 -1
  127. package/build/production/shared/components/YouTubeVideo/index.js +7 -7
  128. package/build/production/shared/components/YouTubeVideo/index.js.map +1 -1
  129. package/build/production/shared/components/index.js +1 -1
  130. package/build/production/shared/components/index.js.map +1 -1
  131. package/build/production/shared/utils/config.js +1 -1
  132. package/build/production/shared/utils/config.js.map +1 -1
  133. package/build/production/shared/utils/globalState.js +3 -0
  134. package/build/production/shared/utils/globalState.js.map +1 -0
  135. package/build/production/shared/utils/index.js +3 -3
  136. package/build/production/shared/utils/index.js.map +1 -1
  137. package/build/production/shared/utils/isomorphy/buildInfo.js +7 -4
  138. package/build/production/shared/utils/isomorphy/buildInfo.js.map +1 -1
  139. package/build/production/shared/utils/isomorphy/environment-check.js +2 -2
  140. package/build/production/shared/utils/isomorphy/environment-check.js.map +1 -1
  141. package/build/production/shared/utils/isomorphy/index.js.map +1 -1
  142. package/build/production/shared/utils/jest/E2eSsrEnv.js +9 -9
  143. package/build/production/shared/utils/jest/E2eSsrEnv.js.map +1 -1
  144. package/build/production/shared/utils/jest/global.js +2 -0
  145. package/build/production/shared/utils/jest/global.js.map +1 -0
  146. package/build/production/shared/utils/jest/index.js +6 -6
  147. package/build/production/shared/utils/jest/index.js.map +1 -1
  148. package/build/production/shared/utils/splitComponent.js +16 -16
  149. package/build/production/shared/utils/splitComponent.js.map +1 -1
  150. package/build/production/shared/utils/time.js +12 -8
  151. package/build/production/shared/utils/time.js.map +1 -1
  152. package/build/production/shared/utils/webpack.js +3 -3
  153. package/build/production/shared/utils/webpack.js.map +1 -1
  154. package/build/production/web.bundle.js +1 -1
  155. package/build/production/web.bundle.js.map +1 -1
  156. package/build/types-code/client/getInj.d.ts +3 -0
  157. package/build/types-code/client/index.d.ts +11 -0
  158. package/build/types-code/client/init.d.ts +9 -0
  159. package/build/types-code/index.d.ts +10 -0
  160. package/build/types-code/server/Cache.d.ts +37 -0
  161. package/build/types-code/server/index.d.ts +145 -0
  162. package/build/types-code/server/renderer.d.ts +106 -0
  163. package/build/types-code/server/server.d.ts +41 -0
  164. package/build/types-code/server/utils/errors.d.ts +104 -0
  165. package/build/types-code/server/utils/index.d.ts +1 -0
  166. package/build/types-code/shared/components/Button/index.d.ts +27 -0
  167. package/build/types-code/shared/components/Checkbox/index.d.ts +21 -0
  168. package/build/types-code/shared/components/Dropdown/index.d.ts +23 -0
  169. package/build/types-code/shared/components/GenericLink/index.d.ts +61 -0
  170. package/build/types-code/shared/components/Input/index.d.ts +11 -0
  171. package/build/types-code/shared/components/Link.d.ts +12 -0
  172. package/build/types-code/shared/components/MetaTags.d.ts +68 -0
  173. package/build/types-code/shared/components/Modal/index.d.ts +26 -0
  174. package/build/types-code/shared/components/NavLink.d.ts +5 -0
  175. package/build/types-code/shared/components/PageLayout/index.d.ts +16 -0
  176. package/build/types-code/shared/components/ScalableRect/index.d.ts +19 -0
  177. package/build/types-code/shared/components/Throbber/index.d.ts +9 -0
  178. package/build/types-code/shared/components/WithTooltip/Tooltip.d.ts +23 -0
  179. package/build/types-code/shared/components/WithTooltip/index.d.ts +17 -0
  180. package/build/types-code/shared/components/YouTubeVideo/index.d.ts +13 -0
  181. package/build/types-code/shared/components/index.d.ts +16 -0
  182. package/build/types-code/shared/utils/config.d.ts +2 -0
  183. package/build/types-code/shared/utils/globalState.d.ts +20 -0
  184. package/build/types-code/shared/utils/index.d.ts +52 -0
  185. package/build/types-code/shared/utils/isomorphy/buildInfo.d.ts +23 -0
  186. package/build/types-code/shared/utils/isomorphy/environment-check.d.ts +11 -0
  187. package/build/types-code/shared/utils/isomorphy/index.d.ts +20 -0
  188. package/build/types-code/shared/utils/jest/E2eSsrEnv.d.ts +31 -0
  189. package/build/types-code/shared/utils/jest/global.d.ts +12 -0
  190. package/build/types-code/shared/utils/jest/index.d.ts +85 -0
  191. package/build/types-code/shared/utils/splitComponent.d.ts +41 -0
  192. package/build/types-code/shared/utils/time.d.ts +62 -0
  193. package/build/types-code/shared/utils/webpack.d.ts +18 -0
  194. package/build/types-scss/__tests__/js/config/publicPath support/__assets__/style.scss.d.ts +1 -0
  195. package/build/types-scss/__tests__/js/config/stylename-generation/__assets__/MockPackageA/TestComponent/style.scss.d.ts +1 -0
  196. package/build/types-scss/__tests__/js/config/stylename-generation/__assets__/MockPackageB/TestComponent/style.scss.d.ts +1 -0
  197. package/build/types-scss/__tests__/js/config/stylename-generation/__assets__/style.scss.d.ts +1 -0
  198. package/build/types-scss/__tests__/js/shared/components/NavLink/styles.scss.d.ts +1 -0
  199. package/build/types-scss/__tests__/js/shared/utils/splitComponent/__assets__/SampleScene/ComponentA/style.scss.d.ts +1 -0
  200. package/build/types-scss/__tests__/js/shared/utils/splitComponent/__assets__/SampleScene/ComponentB/style.scss.d.ts +1 -0
  201. package/build/types-scss/__tests__/js/shared/utils/splitComponent/__assets__/SampleScene/ComponentC/style.scss.d.ts +1 -0
  202. package/build/types-scss/__tests__/js/shared/utils/splitComponent/__assets__/SampleScene/style.scss.d.ts +1 -0
  203. package/build/types-scss/__tests__/ts/config/publicPath support/__assets__/style.scss.d.ts +1 -0
  204. package/build/types-scss/__tests__/ts/config/stylename-generation/__assets__/MockPackageA/TestComponent/style.scss.d.ts +1 -0
  205. package/build/types-scss/__tests__/ts/config/stylename-generation/__assets__/MockPackageB/TestComponent/style.scss.d.ts +1 -0
  206. package/build/types-scss/__tests__/ts/config/stylename-generation/__assets__/style.scss.d.ts +1 -0
  207. package/build/types-scss/__tests__/ts/shared/components/NavLink/styles.scss.d.ts +1 -0
  208. package/build/types-scss/__tests__/ts/shared/utils/splitComponent/__assets__/SampleScene/ComponentA/style.scss.d.ts +1 -0
  209. package/build/types-scss/__tests__/ts/shared/utils/splitComponent/__assets__/SampleScene/ComponentB/style.scss.d.ts +1 -0
  210. package/build/types-scss/__tests__/ts/shared/utils/splitComponent/__assets__/SampleScene/ComponentC/style.scss.d.ts +1 -0
  211. package/build/types-scss/__tests__/ts/shared/utils/splitComponent/__assets__/SampleScene/style.scss.d.ts +1 -0
  212. package/build/types-scss/src/shared/components/Button/style.scss.d.ts +6 -0
  213. package/build/types-scss/src/shared/components/Checkbox/theme.scss.d.ts +6 -0
  214. package/build/types-scss/src/shared/components/Dropdown/theme.scss.d.ts +9 -0
  215. package/build/types-scss/src/shared/components/GenericLink/style.scss.d.ts +1 -0
  216. package/build/types-scss/src/shared/components/Input/theme.scss.d.ts +6 -0
  217. package/build/types-scss/src/shared/components/Modal/base-theme.scss.d.ts +5 -0
  218. package/build/types-scss/src/shared/components/PageLayout/base-theme.scss.d.ts +6 -0
  219. package/build/types-scss/src/shared/components/ScalableRect/style.scss.d.ts +2 -0
  220. package/build/types-scss/src/shared/components/Throbber/theme.scss.d.ts +6 -0
  221. package/build/types-scss/src/shared/components/WithTooltip/default-theme.scss.d.ts +7 -0
  222. package/build/types-scss/src/shared/components/YouTubeVideo/base.scss.d.ts +5 -0
  223. package/build/types-scss/src/shared/components/YouTubeVideo/throbber.scss.d.ts +4 -0
  224. package/config/eslint/jest.json +3 -2
  225. package/config/eslint/typescript.js +34 -0
  226. package/config/jest/default.js +3 -3
  227. package/package.json +75 -33
  228. package/src/client/getInj.ts +43 -0
  229. package/src/client/index.tsx +40 -0
  230. package/src/client/init.ts +47 -0
  231. package/src/index.ts +58 -0
  232. package/src/server/Cache.ts +68 -0
  233. package/src/server/index.ts +230 -0
  234. package/src/server/renderer.tsx +604 -0
  235. package/src/server/server.ts +309 -0
  236. package/src/server/utils/errors.ts +135 -0
  237. package/src/server/utils/index.ts +3 -0
  238. package/src/shared/components/Button/index.tsx +146 -0
  239. package/src/shared/components/Button/style.scss +53 -0
  240. package/src/shared/components/Checkbox/index.tsx +71 -0
  241. package/src/shared/components/Checkbox/theme.scss +43 -0
  242. package/src/shared/components/Dropdown/index.tsx +144 -0
  243. package/src/shared/components/Dropdown/theme.scss +63 -0
  244. package/src/shared/components/GenericLink/index.tsx +157 -0
  245. package/src/shared/components/GenericLink/style.scss +3 -0
  246. package/src/shared/components/Input/index.tsx +59 -0
  247. package/src/shared/components/Input/theme.scss +27 -0
  248. package/src/shared/components/Link.tsx +21 -0
  249. package/src/shared/components/MetaTags.tsx +170 -0
  250. package/src/shared/components/Modal/base-theme.scss +38 -0
  251. package/src/shared/components/Modal/index.tsx +144 -0
  252. package/src/shared/components/Modal/styles.scss +5 -0
  253. package/src/shared/components/NavLink.tsx +13 -0
  254. package/src/shared/components/PageLayout/base-theme.scss +30 -0
  255. package/src/shared/components/PageLayout/index.tsx +76 -0
  256. package/src/shared/components/ScalableRect/index.tsx +84 -0
  257. package/src/shared/components/ScalableRect/style.scss +10 -0
  258. package/src/shared/components/Throbber/index.tsx +43 -0
  259. package/src/shared/components/Throbber/theme.scss +26 -0
  260. package/src/shared/components/WithTooltip/Tooltip.tsx +353 -0
  261. package/src/shared/components/WithTooltip/default-theme.scss +36 -0
  262. package/src/shared/components/WithTooltip/index.tsx +204 -0
  263. package/src/shared/components/YouTubeVideo/base.scss +13 -0
  264. package/src/shared/components/YouTubeVideo/index.tsx +96 -0
  265. package/src/shared/components/YouTubeVideo/throbber.scss +11 -0
  266. package/src/shared/components/index.ts +17 -0
  267. package/src/shared/utils/config.ts +21 -0
  268. package/src/shared/utils/globalState.ts +29 -0
  269. package/src/shared/utils/index.ts +105 -0
  270. package/src/shared/utils/isomorphy/buildInfo.ts +54 -0
  271. package/src/shared/utils/isomorphy/environment-check.ts +18 -0
  272. package/src/shared/utils/isomorphy/index.ts +38 -0
  273. package/src/shared/utils/jest/E2eSsrEnv.ts +250 -0
  274. package/src/shared/utils/jest/global.ts +19 -0
  275. package/src/shared/utils/jest/index.tsx +157 -0
  276. package/src/shared/utils/splitComponent.tsx +255 -0
  277. package/src/shared/utils/time.ts +118 -0
  278. package/src/shared/utils/webpack.ts +45 -0
  279. package/src/styles/_global/reset.css +52 -0
  280. package/src/styles/global.scss +11 -0
  281. package/tsconfig.configs.json +18 -0
  282. package/tsconfig.json +27 -0
  283. package/tsconfig.types.json +53 -0
  284. package/typed-scss-modules.config.ts +9 -0
  285. package/types.d.ts +37 -0
  286. package/{webpack.config.js → webpack.config.ts} +7 -3
  287. package/config/babel/node-ssr.js +0 -85
  288. package/config/babel/webpack.js +0 -122
  289. package/config/webpack/app-base.js +0 -330
  290. package/config/webpack/app-development.js +0 -80
  291. package/config/webpack/app-production.js +0 -60
  292. package/config/webpack/lib-base.js +0 -155
  293. package/config/webpack/lib-development.js +0 -45
  294. package/config/webpack/lib-production.js +0 -44
package/babel.config.js CHANGED
@@ -1,5 +1,7 @@
1
1
  module.exports = {
2
2
  presets: [
3
- './config/babel/node-ssr',
3
+ ['./config/babel/node-ssr', {
4
+ typescript: true,
5
+ }],
4
6
  ],
5
7
  };
package/bin/build.js CHANGED
@@ -8,9 +8,18 @@ const path = require('path');
8
8
 
9
9
  const { isFunction, mapValues, merge } = require('lodash');
10
10
  const { program } = require('commander');
11
- const rimraf = require('rimraf');
11
+
12
+ // TODO: Disabled, because ESLint still does not support "exports" declarations
13
+ // in "package.json", and "rimraf" does not declare fallback entrance.
14
+ // See: https://github.com/import-js/eslint-plugin-import/issues/1810
15
+ // and update, once that issue is resolved.
16
+ // eslint-disable-next-line import/no-unresolved
17
+ const { rimraf } = require('rimraf');
12
18
 
13
19
  /* eslint-disable import/no-extraneous-dependencies */
20
+ // To support TS configs for Webpack.
21
+ const register = require('@babel/register/experimental-worker');
22
+
14
23
  const webpack = require('webpack');
15
24
  /* eslint-enable import/no-extraneous-dependencies */
16
25
 
@@ -85,7 +94,14 @@ fs.mkdirSync(outDir, { recursive: true });
85
94
  /* ************************************************************************** */
86
95
  /* Webpack compilation of isomorphic library bundle. */
87
96
 
97
+ register({
98
+ envName: 'production',
99
+ extensions: ['.js', '.jsx', '.ts', '.tsx', '.svg'],
100
+ root: process.cwd(),
101
+ });
102
+
88
103
  let webpackConfig = require(path.resolve(cwd, cmdLineArgs.webpackConfig));
104
+ if ('default' in webpackConfig) webpackConfig = webpackConfig.default;
89
105
  if (isFunction(webpackConfig)) webpackConfig = webpackConfig(buildType);
90
106
 
91
107
  let webpackOutDir = outDir;
@@ -152,13 +168,16 @@ if (cmdLineArgs.watch) {
152
168
  /* ************************************************************************** */
153
169
  /* Babel compilation of JS, JSX, and SVG files. */
154
170
 
171
+ // TODO: It needs an option to build TS project, and use TypeScript in that case
172
+ // to do TypeScript build with "tsc".
173
+
155
174
  const BABEL_EXEC_OPTIONS = {
156
175
  env: { ...process.env, BABEL_ENV: buildType },
157
176
  };
158
177
 
159
- let BABEL_CMD_JS = `${cwd}/node_modules/.bin/babel`;
160
- BABEL_CMD_JS += ` ${inDir} --out-dir ${outDir} --source-maps`;
161
- if (buildType === BUILD_TYPES.PRODUCTION) BABEL_CMD_JS += ' --minified';
178
+ let BABEL_CMD_BASE = `${cwd}/node_modules/.bin/babel`;
179
+ BABEL_CMD_BASE += ` ${inDir} --out-dir ${outDir} --source-maps`;
180
+ if (buildType === BUILD_TYPES.PRODUCTION) BABEL_CMD_BASE += ' --minified';
162
181
 
163
182
  /* TODO: The watch is deactivated for Babel compilation because of SVG files:
164
183
  * currently there is no way to tell Babel that SVG files should be compiled
@@ -171,7 +190,8 @@ if (buildType === BUILD_TYPES.PRODUCTION) BABEL_CMD_JS += ' --minified';
171
190
  if (cmdLineArgs.watch) BABEL_CMD_JS += ' --watch';
172
191
  */
173
192
 
174
- const BABEL_CMD_SVG = `${BABEL_CMD_JS} --extensions ".svg" --keep-file-extension`;
193
+ const BABEL_CMD_JS = `${BABEL_CMD_BASE} -x .js,.jsx,.ts,.tsx`;
194
+ const BABEL_CMD_SVG = `${BABEL_CMD_BASE} --extensions ".svg" --keep-file-extension`;
175
195
 
176
196
  async function babelBuild() {
177
197
  await exec(BABEL_CMD_JS, BABEL_EXEC_OPTIONS);
@@ -18,21 +18,22 @@ var _buildInfo = require("../shared/utils/isomorphy/buildInfo");
18
18
  // Safeguard is needed here, because the server-side version of Docusaurus docs
19
19
  // is compiled (at least now) with settings suggesting it is a client-side
20
20
  // environment, but there is no document.
21
- let inj = typeof document !== 'undefined' && document.querySelector('meta[itemprop="drpruinj"]');
22
- if (inj) {
23
- inj.remove();
21
+ let inj = {};
22
+ const metaElement = typeof document !== 'undefined' ? document.querySelector('meta[itemprop="drpruinj"]') : null;
23
+ if (metaElement) {
24
+ metaElement.remove();
25
+ let data = _forge.default.util.decode64(metaElement.content);
24
26
  const {
25
27
  key
26
28
  } = (0, _buildInfo.getBuildInfo)();
27
- inj = _forge.default.util.decode64(inj.content);
28
29
  const d = _forge.default.cipher.createDecipher('AES-CBC', key);
29
30
  d.start({
30
- iv: inj.slice(0, key.length)
31
+ iv: data.slice(0, key.length)
31
32
  });
32
- d.update(_forge.default.util.createBuffer(inj.slice(key.length)));
33
+ d.update(_forge.default.util.createBuffer(data.slice(key.length)));
33
34
  d.finish();
34
- inj = _forge.default.util.decodeUtf8(d.output.data);
35
- inj = eval(`(${inj})`); // eslint-disable-line no-eval
35
+ data = _forge.default.util.decodeUtf8(d.output.data);
36
+ inj = eval(`(${data})`); // eslint-disable-line no-eval
36
37
  } else {
37
38
  // Otherwise, a bunch of dependent stuff will easily fail in non-standard
38
39
  // environments, where no client-side initialization is performed. Like tests,
@@ -1 +1 @@
1
- {"version":3,"file":"getInj.js","names":["_forge","_interopRequireDefault","require","_buildInfo","inj","document","querySelector","remove","key","getBuildInfo","forge","util","decode64","content","d","cipher","createDecipher","start","iv","slice","length","update","createBuffer","finish","decodeUtf8","output","data","eval","getInj"],"sources":["../../../src/client/getInj.js"],"sourcesContent":["// Encapsulates retrieval of server-side data injection into HTML template.\n\n/* global document */\n\n// Note: this way, only required part of \"node-forge\": AES, and some utils,\n// is bundled into client-side code.\nimport forge from 'node-forge/lib/forge';\nimport 'node-forge/lib/aes';\n\nimport { getBuildInfo } from 'utils/isomorphy/buildInfo';\n\n// Safeguard is needed here, because the server-side version of Docusaurus docs\n// is compiled (at least now) with settings suggesting it is a client-side\n// environment, but there is no document.\nlet inj = typeof document !== 'undefined'\n && document.querySelector('meta[itemprop=\"drpruinj\"]');\n\nif (inj) {\n inj.remove();\n const { key } = getBuildInfo();\n inj = forge.util.decode64(inj.content);\n const d = forge.cipher.createDecipher('AES-CBC', key);\n d.start({ iv: inj.slice(0, key.length) });\n d.update(forge.util.createBuffer(inj.slice(key.length)));\n d.finish();\n inj = forge.util.decodeUtf8(d.output.data);\n inj = eval(`(${inj})`); // eslint-disable-line no-eval\n} else {\n // Otherwise, a bunch of dependent stuff will easily fail in non-standard\n // environments, where no client-side initialization is performed. Like tests,\n // Docusaurus examples, etc.\n inj = {};\n}\n\nexport default function getInj() {\n return inj;\n}\n"],"mappings":";;;;;;;AAMA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACAA,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AATA;;AAEA;;AAEA;AACA;;AAMA;AACA;AACA;AACA,IAAIE,GAAG,GAAG,OAAOC,QAAQ,KAAK,WAAW,IACpCA,QAAQ,CAACC,aAAa,CAAC,2BAA2B,CAAC;AAExD,IAAIF,GAAG,EAAE;EACPA,GAAG,CAACG,MAAM,CAAC,CAAC;EACZ,MAAM;IAAEC;EAAI,CAAC,GAAG,IAAAC,uBAAY,EAAC,CAAC;EAC9BL,GAAG,GAAGM,cAAK,CAACC,IAAI,CAACC,QAAQ,CAACR,GAAG,CAACS,OAAO,CAAC;EACtC,MAAMC,CAAC,GAAGJ,cAAK,CAACK,MAAM,CAACC,cAAc,CAAC,SAAS,EAAER,GAAG,CAAC;EACrDM,CAAC,CAACG,KAAK,CAAC;IAAEC,EAAE,EAAEd,GAAG,CAACe,KAAK,CAAC,CAAC,EAAEX,GAAG,CAACY,MAAM;EAAE,CAAC,CAAC;EACzCN,CAAC,CAACO,MAAM,CAACX,cAAK,CAACC,IAAI,CAACW,YAAY,CAAClB,GAAG,CAACe,KAAK,CAACX,GAAG,CAACY,MAAM,CAAC,CAAC,CAAC;EACxDN,CAAC,CAACS,MAAM,CAAC,CAAC;EACVnB,GAAG,GAAGM,cAAK,CAACC,IAAI,CAACa,UAAU,CAACV,CAAC,CAACW,MAAM,CAACC,IAAI,CAAC;EAC1CtB,GAAG,GAAGuB,IAAI,CAAE,IAAGvB,GAAI,GAAE,CAAC,CAAC,CAAC;AAC1B,CAAC,MAAM;EACL;EACA;EACA;EACAA,GAAG,GAAG,CAAC,CAAC;AACV;AAEe,SAASwB,MAAMA,CAAA,EAAG;EAC/B,OAAOxB,GAAG;AACZ"}
1
+ {"version":3,"file":"getInj.js","names":["_forge","_interopRequireDefault","require","_buildInfo","inj","metaElement","document","querySelector","remove","data","forge","util","decode64","content","key","getBuildInfo","d","cipher","createDecipher","start","iv","slice","length","update","createBuffer","finish","decodeUtf8","output","eval","getInj"],"sources":["../../../src/client/getInj.ts"],"sourcesContent":["// Encapsulates retrieval of server-side data injection into HTML template.\n\n/* global document */\n\n// Note: this way, only required part of \"node-forge\": AES, and some utils,\n// is bundled into client-side code.\nimport forge from 'node-forge/lib/forge';\nimport 'node-forge/lib/aes';\n\nimport type { InjT } from 'utils/globalState';\n\nimport { getBuildInfo } from 'utils/isomorphy/buildInfo';\n\n// Safeguard is needed here, because the server-side version of Docusaurus docs\n// is compiled (at least now) with settings suggesting it is a client-side\n// environment, but there is no document.\nlet inj: InjT = {};\n\nconst metaElement: HTMLMetaElement | null = typeof document !== 'undefined'\n ? document.querySelector('meta[itemprop=\"drpruinj\"]') : null;\n\nif (metaElement) {\n metaElement.remove();\n let data = forge.util.decode64(metaElement.content);\n\n const { key } = getBuildInfo();\n const d = forge.cipher.createDecipher('AES-CBC', key);\n d.start({ iv: data.slice(0, key.length) });\n d.update(forge.util.createBuffer(data.slice(key.length)));\n d.finish();\n\n data = forge.util.decodeUtf8(d.output.data);\n inj = eval(`(${data})`); // eslint-disable-line no-eval\n} else {\n // Otherwise, a bunch of dependent stuff will easily fail in non-standard\n // environments, where no client-side initialization is performed. Like tests,\n // Docusaurus examples, etc.\n inj = {};\n}\n\nexport default function getInj(): InjT {\n return inj;\n}\n"],"mappings":";;;;;;;AAMA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACAA,OAAA;AAIA,IAAAC,UAAA,GAAAD,OAAA;AAXA;;AAEA;;AAEA;AACA;;AAQA;AACA;AACA;AACA,IAAIE,GAAS,GAAG,CAAC,CAAC;AAElB,MAAMC,WAAmC,GAAG,OAAOC,QAAQ,KAAK,WAAW,GACvEA,QAAQ,CAACC,aAAa,CAAC,2BAA2B,CAAC,GAAG,IAAI;AAE9D,IAAIF,WAAW,EAAE;EACfA,WAAW,CAACG,MAAM,CAAC,CAAC;EACpB,IAAIC,IAAI,GAAGC,cAAK,CAACC,IAAI,CAACC,QAAQ,CAACP,WAAW,CAACQ,OAAO,CAAC;EAEnD,MAAM;IAAEC;EAAI,CAAC,GAAG,IAAAC,uBAAY,EAAC,CAAC;EAC9B,MAAMC,CAAC,GAAGN,cAAK,CAACO,MAAM,CAACC,cAAc,CAAC,SAAS,EAAEJ,GAAG,CAAC;EACrDE,CAAC,CAACG,KAAK,CAAC;IAAEC,EAAE,EAAEX,IAAI,CAACY,KAAK,CAAC,CAAC,EAAEP,GAAG,CAACQ,MAAM;EAAE,CAAC,CAAC;EAC1CN,CAAC,CAACO,MAAM,CAACb,cAAK,CAACC,IAAI,CAACa,YAAY,CAACf,IAAI,CAACY,KAAK,CAACP,GAAG,CAACQ,MAAM,CAAC,CAAC,CAAC;EACzDN,CAAC,CAACS,MAAM,CAAC,CAAC;EAEVhB,IAAI,GAAGC,cAAK,CAACC,IAAI,CAACe,UAAU,CAACV,CAAC,CAACW,MAAM,CAAClB,IAAI,CAAC;EAC3CL,GAAG,GAAGwB,IAAI,CAAE,IAAGnB,IAAK,GAAE,CAAC,CAAC,CAAC;AAC3B,CAAC,MAAM;EACL;EACA;EACA;EACAL,GAAG,GAAG,CAAC,CAAC;AACV;AAEe,SAASyB,MAAMA,CAAA,EAAS;EACrC,OAAOzB,GAAG;AACZ"}
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = Launch;
8
+ require("react");
8
9
  var _reactGlobalState = require("@dr.pogodin/react-global-state");
9
10
  var _client = require("react-dom/client");
10
11
  var _reactRouterDom = require("react-router-dom");
@@ -15,11 +16,13 @@ var _jsxRuntime = require("react/jsx-runtime");
15
16
 
16
17
  /**
17
18
  * Prepares and launches the app at client side.
18
- * @param {object} Application Root application component
19
- * @param {object} [options={}] Optional. Additional settings.
20
- */function Launch(Application) {
19
+ * @param Application Root application component
20
+ * @param [options={}] Optional. Additional settings.
21
+ */
22
+ function Launch(Application) {
21
23
  let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
22
24
  const container = document.getElementById('react-view');
25
+ if (!container) throw Error('Failed to find container for React app');
23
26
  const scene = /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactGlobalState.GlobalStateProvider, {
24
27
  initialState: (0, _getInj.default)().ISTATE,
25
28
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouterDom.BrowserRouter, {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_reactGlobalState","require","_client","_reactRouterDom","_getInj","_interopRequireDefault","_jsxRuntime","Launch","Application","options","arguments","length","undefined","container","document","getElementById","scene","jsx","GlobalStateProvider","initialState","getInj","ISTATE","children","BrowserRouter","dontHydrate","root","createRoot","render","hydrateRoot"],"sources":["../../../src/client/index.jsx"],"sourcesContent":["// Initialization of client-side code.\n/* global document */\n\nimport { GlobalStateProvider } from '@dr.pogodin/react-global-state';\n\nimport { createRoot, hydrateRoot } from 'react-dom/client';\nimport { BrowserRouter } from 'react-router-dom';\n\nimport getInj from './getInj';\n\n/**\n * Prepares and launches the app at client side.\n * @param {object} Application Root application component\n * @param {object} [options={}] Optional. Additional settings.\n */\nexport default function Launch(Application, options = {}) {\n const container = document.getElementById('react-view');\n const scene = (\n <GlobalStateProvider initialState={getInj().ISTATE}>\n <BrowserRouter>\n <Application />\n </BrowserRouter>\n </GlobalStateProvider>\n );\n\n if (options.dontHydrate) {\n const root = createRoot(container);\n root.render(scene);\n } else hydrateRoot(container, scene);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,iBAAA,GAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AAEA,IAAAG,OAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAA8B,IAAAK,WAAA,GAAAL,OAAA;AAR9B;AACA;;AASA;AACA;AACA;AACA;AACA,GACe,SAASM,MAAMA,CAACC,WAAW,EAAgB;EAAA,IAAdC,OAAO,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EACtD,MAAMG,SAAS,GAAGC,QAAQ,CAACC,cAAc,CAAC,YAAY,CAAC;EACvD,MAAMC,KAAK,gBACT,IAAAV,WAAA,CAAAW,GAAA,EAACjB,iBAAA,CAAAkB,mBAAmB;IAACC,YAAY,EAAE,IAAAC,eAAM,EAAC,CAAC,CAACC,MAAO;IAAAC,QAAA,eACjD,IAAAhB,WAAA,CAAAW,GAAA,EAACd,eAAA,CAAAoB,aAAa;MAAAD,QAAA,eACZ,IAAAhB,WAAA,CAAAW,GAAA,EAACT,WAAW,IAAE;IAAC,CACF;EAAC,CACG,CACtB;EAED,IAAIC,OAAO,CAACe,WAAW,EAAE;IACvB,MAAMC,IAAI,GAAG,IAAAC,kBAAU,EAACb,SAAS,CAAC;IAClCY,IAAI,CAACE,MAAM,CAACX,KAAK,CAAC;EACpB,CAAC,MAAM,IAAAY,mBAAW,EAACf,SAAS,EAAEG,KAAK,CAAC;AACtC"}
1
+ {"version":3,"file":"index.js","names":["require","_reactGlobalState","_client","_reactRouterDom","_getInj","_interopRequireDefault","_jsxRuntime","Launch","Application","options","arguments","length","undefined","container","document","getElementById","Error","scene","jsx","GlobalStateProvider","initialState","getInj","ISTATE","children","BrowserRouter","dontHydrate","root","createRoot","render","hydrateRoot"],"sources":["../../../src/client/index.tsx"],"sourcesContent":["// Initialization of client-side code.\n/* global document */\n\nimport { type ComponentType } from 'react';\n\nimport { GlobalStateProvider } from '@dr.pogodin/react-global-state';\n\nimport { createRoot, hydrateRoot } from 'react-dom/client';\nimport { BrowserRouter } from 'react-router-dom';\n\nimport getInj from './getInj';\n\ntype OptionsT = {\n dontHydrate?: boolean;\n};\n\n/**\n * Prepares and launches the app at client side.\n * @param Application Root application component\n * @param [options={}] Optional. Additional settings.\n */\nexport default function Launch(\n Application: ComponentType,\n options: OptionsT = {},\n) {\n const container = document.getElementById('react-view');\n if (!container) throw Error('Failed to find container for React app');\n const scene = (\n <GlobalStateProvider initialState={getInj().ISTATE}>\n <BrowserRouter>\n <Application />\n </BrowserRouter>\n </GlobalStateProvider>\n );\n\n if (options.dontHydrate) {\n const root = createRoot(container);\n root.render(scene);\n } else hydrateRoot(container, scene);\n}\n"],"mappings":";;;;;;;AAGAA,OAAA;AAEA,IAAAC,iBAAA,GAAAD,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAEA,IAAAI,OAAA,GAAAC,sBAAA,CAAAL,OAAA;AAA8B,IAAAM,WAAA,GAAAN,OAAA;AAV9B;AACA;;AAeA;AACA;AACA;AACA;AACA;AACe,SAASO,MAAMA,CAC5BC,WAA0B,EAE1B;EAAA,IADAC,OAAiB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAEtB,MAAMG,SAAS,GAAGC,QAAQ,CAACC,cAAc,CAAC,YAAY,CAAC;EACvD,IAAI,CAACF,SAAS,EAAE,MAAMG,KAAK,CAAC,wCAAwC,CAAC;EACrE,MAAMC,KAAK,gBACT,IAAAX,WAAA,CAAAY,GAAA,EAACjB,iBAAA,CAAAkB,mBAAmB;IAACC,YAAY,EAAE,IAAAC,eAAM,EAAC,CAAC,CAACC,MAAO;IAAAC,QAAA,eACjD,IAAAjB,WAAA,CAAAY,GAAA,EAACf,eAAA,CAAAqB,aAAa;MAAAD,QAAA,eACZ,IAAAjB,WAAA,CAAAY,GAAA,EAACV,WAAW,IAAE;IAAC,CACF;EAAC,CACG,CACtB;EAED,IAAIC,OAAO,CAACgB,WAAW,EAAE;IACvB,MAAMC,IAAI,GAAG,IAAAC,kBAAU,EAACd,SAAS,CAAC;IAClCa,IAAI,CAACE,MAAM,CAACX,KAAK,CAAC;EACpB,CAAC,MAAM,IAAAY,mBAAW,EAAChB,SAAS,EAAEI,KAAK,CAAC;AACtC"}
@@ -8,7 +8,11 @@ var _buildInfo = require("../shared/utils/isomorphy/buildInfo");
8
8
  /* global BUILD_INFO, window */
9
9
 
10
10
  const buildInfo = (0, _buildInfo.getBuildInfo)();
11
+
12
+ // TODO: Should be moved into buildInfo module?
13
+
11
14
  if (process.env.NODE_ENV !== 'production') {
15
+ // eslint-disable-next-line no-console
12
16
  console.warn('Dev mode: "BUILD_INFO" attached to the global "window"');
13
17
  // eslint-disable-next-line no-underscore-dangle
14
18
  window.__DEV_BUILD_INFO__ = BUILD_INFO;
@@ -1 +1 @@
1
- {"version":3,"file":"init.js","names":["_buildInfo","require","buildInfo","getBuildInfo","process","env","NODE_ENV","console","warn","window","__DEV_BUILD_INFO__","BUILD_INFO","useServiceWorker","navigator","addEventListener","reg","serviceWorker","register","log","err"],"sources":["../../../src/client/init.js"],"sourcesContent":["/**\n * Initialization of client-side environment.\n */\n\n/* global BUILD_INFO, window */\n\nimport { getBuildInfo } from 'utils/isomorphy/buildInfo';\n\nconst buildInfo = getBuildInfo();\n\nif (process.env.NODE_ENV !== 'production') {\n console.warn('Dev mode: \"BUILD_INFO\" attached to the global \"window\"');\n // eslint-disable-next-line no-underscore-dangle\n window.__DEV_BUILD_INFO__ = BUILD_INFO;\n}\n\n/* TODO: A proper logger should be moved to `@dr.pogodin/react-utils`. */\n/* eslint-disable no-console */\nconst { useServiceWorker } = buildInfo;\nif (useServiceWorker) {\n const { navigator } = window;\n if ('serviceWorker' in navigator) {\n window.addEventListener('load', async () => {\n try {\n // Note: no matter the \"publicPath\", we want to serve the service worker\n // from the web app root, to allow it control any and all pages of the\n // web app (otherwise, it will be restricted to the scope of its path).\n // The server takes it into account.\n const reg = await navigator\n .serviceWorker.register('/__service-worker.js');\n console.log('SW registered:', reg);\n } catch (err) {\n console.log('SW registration failed:', err);\n }\n });\n }\n}\n/* eslint-enable no-console */\n"],"mappings":";;AAMA,IAAAA,UAAA,GAAAC,OAAA;AANA;AACA;AACA;;AAEA;;AAIA,MAAMC,SAAS,GAAG,IAAAC,uBAAY,EAAC,CAAC;AAEhC,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;EACzCC,OAAO,CAACC,IAAI,CAAC,wDAAwD,CAAC;EACtE;EACAC,MAAM,CAACC,kBAAkB,GAAGC,UAAU;AACxC;;AAEA;AACA;AACA,MAAM;EAAEC;AAAiB,CAAC,GAAGV,SAAS;AACtC,IAAIU,gBAAgB,EAAE;EACpB,MAAM;IAAEC;EAAU,CAAC,GAAGJ,MAAM;EAC5B,IAAI,eAAe,IAAII,SAAS,EAAE;IAChCJ,MAAM,CAACK,gBAAgB,CAAC,MAAM,EAAE,YAAY;MAC1C,IAAI;QACF;QACA;QACA;QACA;QACA,MAAMC,GAAG,GAAG,MAAMF,SAAS,CACxBG,aAAa,CAACC,QAAQ,CAAC,sBAAsB,CAAC;QACjDV,OAAO,CAACW,GAAG,CAAC,gBAAgB,EAAEH,GAAG,CAAC;MACpC,CAAC,CAAC,OAAOI,GAAG,EAAE;QACZZ,OAAO,CAACW,GAAG,CAAC,yBAAyB,EAAEC,GAAG,CAAC;MAC7C;IACF,CAAC,CAAC;EACJ;AACF;AACA"}
1
+ {"version":3,"file":"init.js","names":["_buildInfo","require","buildInfo","getBuildInfo","process","env","NODE_ENV","console","warn","window","__DEV_BUILD_INFO__","BUILD_INFO","useServiceWorker","navigator","addEventListener","reg","serviceWorker","register","log","err"],"sources":["../../../src/client/init.ts"],"sourcesContent":["/**\n * Initialization of client-side environment.\n */\n\n/* global BUILD_INFO, window */\n\nimport { type BuildInfoT, getBuildInfo } from 'utils/isomorphy/buildInfo';\n\nconst buildInfo = getBuildInfo();\n\n// TODO: Should be moved into buildInfo module?\ndeclare global {\n interface Window {\n // eslint-disable-next-line @typescript-eslint/naming-convention, no-underscore-dangle\n __DEV_BUILD_INFO__: BuildInfoT | undefined;\n }\n}\n\nif (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.warn('Dev mode: \"BUILD_INFO\" attached to the global \"window\"');\n // eslint-disable-next-line no-underscore-dangle\n window.__DEV_BUILD_INFO__ = BUILD_INFO;\n}\n\n/* TODO: A proper logger should be moved to `@dr.pogodin/react-utils`. */\n/* eslint-disable no-console */\nconst { useServiceWorker } = buildInfo;\nif (useServiceWorker) {\n const { navigator } = window;\n if ('serviceWorker' in navigator) {\n window.addEventListener('load', async () => {\n try {\n // Note: no matter the \"publicPath\", we want to serve the service worker\n // from the web app root, to allow it control any and all pages of the\n // web app (otherwise, it will be restricted to the scope of its path).\n // The server takes it into account.\n const reg = await navigator\n .serviceWorker.register('/__service-worker.js');\n console.log('SW registered:', reg);\n } catch (err) {\n console.log('SW registration failed:', err);\n }\n });\n }\n}\n/* eslint-enable no-console */\n"],"mappings":";;AAMA,IAAAA,UAAA,GAAAC,OAAA;AANA;AACA;AACA;;AAEA;;AAIA,MAAMC,SAAS,GAAG,IAAAC,uBAAY,EAAC,CAAC;;AAEhC;;AAQA,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;EACzC;EACAC,OAAO,CAACC,IAAI,CAAC,wDAAwD,CAAC;EACtE;EACAC,MAAM,CAACC,kBAAkB,GAAGC,UAAU;AACxC;;AAEA;AACA;AACA,MAAM;EAAEC;AAAiB,CAAC,GAAGV,SAAS;AACtC,IAAIU,gBAAgB,EAAE;EACpB,MAAM;IAAEC;EAAU,CAAC,GAAGJ,MAAM;EAC5B,IAAI,eAAe,IAAII,SAAS,EAAE;IAChCJ,MAAM,CAACK,gBAAgB,CAAC,MAAM,EAAE,YAAY;MAC1C,IAAI;QACF;QACA;QACA;QACA;QACA,MAAMC,GAAG,GAAG,MAAMF,SAAS,CACxBG,aAAa,CAACC,QAAQ,CAAC,sBAAsB,CAAC;QACjDV,OAAO,CAACW,GAAG,CAAC,gBAAgB,EAAEH,GAAG,CAAC;MACpC,CAAC,CAAC,OAAOI,GAAG,EAAE;QACZZ,OAAO,CAACW,GAAG,CAAC,yBAAyB,EAAEC,GAAG,CAAC;MAC7C;IACF,CAAC,CAAC;EACJ;AACF;AACA"}
@@ -4,25 +4,133 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- var _exportNames = {
8
- client: true,
9
- server: true,
10
- api: true,
11
- PT: true,
12
- getGlobalState: true,
13
- getSsrContext: true,
14
- GlobalStateProvider: true,
15
- useAsyncCollection: true,
16
- useAsyncData: true,
17
- useGlobalState: true
18
- };
7
+ Object.defineProperty(exports, "Barrier", {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _utils.Barrier;
11
+ }
12
+ });
13
+ Object.defineProperty(exports, "BaseModal", {
14
+ enumerable: true,
15
+ get: function () {
16
+ return _components.BaseModal;
17
+ }
18
+ });
19
+ Object.defineProperty(exports, "Button", {
20
+ enumerable: true,
21
+ get: function () {
22
+ return _components.Button;
23
+ }
24
+ });
25
+ Object.defineProperty(exports, "Checkbox", {
26
+ enumerable: true,
27
+ get: function () {
28
+ return _components.Checkbox;
29
+ }
30
+ });
31
+ Object.defineProperty(exports, "Dropdown", {
32
+ enumerable: true,
33
+ get: function () {
34
+ return _components.Dropdown;
35
+ }
36
+ });
37
+ Object.defineProperty(exports, "Emitter", {
38
+ enumerable: true,
39
+ get: function () {
40
+ return _utils.Emitter;
41
+ }
42
+ });
19
43
  Object.defineProperty(exports, "GlobalStateProvider", {
20
44
  enumerable: true,
21
45
  get: function () {
22
46
  return _reactGlobalState.GlobalStateProvider;
23
47
  }
24
48
  });
49
+ Object.defineProperty(exports, "Input", {
50
+ enumerable: true,
51
+ get: function () {
52
+ return _components.Input;
53
+ }
54
+ });
55
+ Object.defineProperty(exports, "JU", {
56
+ enumerable: true,
57
+ get: function () {
58
+ return _utils.JU;
59
+ }
60
+ });
61
+ Object.defineProperty(exports, "Link", {
62
+ enumerable: true,
63
+ get: function () {
64
+ return _components.Link;
65
+ }
66
+ });
67
+ Object.defineProperty(exports, "MetaTags", {
68
+ enumerable: true,
69
+ get: function () {
70
+ return _components.MetaTags;
71
+ }
72
+ });
73
+ Object.defineProperty(exports, "Modal", {
74
+ enumerable: true,
75
+ get: function () {
76
+ return _components.Modal;
77
+ }
78
+ });
79
+ Object.defineProperty(exports, "NavLink", {
80
+ enumerable: true,
81
+ get: function () {
82
+ return _components.NavLink;
83
+ }
84
+ });
25
85
  exports.PT = void 0;
86
+ Object.defineProperty(exports, "PageLayout", {
87
+ enumerable: true,
88
+ get: function () {
89
+ return _components.PageLayout;
90
+ }
91
+ });
92
+ Object.defineProperty(exports, "Rgs", {
93
+ enumerable: true,
94
+ get: function () {
95
+ return _reactGlobalState.default;
96
+ }
97
+ });
98
+ Object.defineProperty(exports, "ScalableRect", {
99
+ enumerable: true,
100
+ get: function () {
101
+ return _components.ScalableRect;
102
+ }
103
+ });
104
+ Object.defineProperty(exports, "Semaphore", {
105
+ enumerable: true,
106
+ get: function () {
107
+ return _utils.Semaphore;
108
+ }
109
+ });
110
+ Object.defineProperty(exports, "ThemeProvider", {
111
+ enumerable: true,
112
+ get: function () {
113
+ return _utils.ThemeProvider;
114
+ }
115
+ });
116
+ Object.defineProperty(exports, "Throbber", {
117
+ enumerable: true,
118
+ get: function () {
119
+ return _components.Throbber;
120
+ }
121
+ });
122
+ Object.defineProperty(exports, "WithTooltip", {
123
+ enumerable: true,
124
+ get: function () {
125
+ return _components.WithTooltip;
126
+ }
127
+ });
128
+ Object.defineProperty(exports, "YouTubeVideo", {
129
+ enumerable: true,
130
+ get: function () {
131
+ return _components.YouTubeVideo;
132
+ }
133
+ });
26
134
  Object.defineProperty(exports, "api", {
27
135
  enumerable: true,
28
136
  get: function () {
@@ -30,6 +138,12 @@ Object.defineProperty(exports, "api", {
30
138
  }
31
139
  });
32
140
  exports.client = void 0;
141
+ Object.defineProperty(exports, "config", {
142
+ enumerable: true,
143
+ get: function () {
144
+ return _utils.config;
145
+ }
146
+ });
33
147
  Object.defineProperty(exports, "getGlobalState", {
34
148
  enumerable: true,
35
149
  get: function () {
@@ -39,10 +153,34 @@ Object.defineProperty(exports, "getGlobalState", {
39
153
  Object.defineProperty(exports, "getSsrContext", {
40
154
  enumerable: true,
41
155
  get: function () {
42
- return _reactGlobalState.getSsrContext;
156
+ return _utils.getSsrContext;
157
+ }
158
+ });
159
+ Object.defineProperty(exports, "isomorphy", {
160
+ enumerable: true,
161
+ get: function () {
162
+ return _utils.isomorphy;
43
163
  }
44
164
  });
45
165
  exports.server = void 0;
166
+ Object.defineProperty(exports, "splitComponent", {
167
+ enumerable: true,
168
+ get: function () {
169
+ return _utils.splitComponent;
170
+ }
171
+ });
172
+ Object.defineProperty(exports, "themed", {
173
+ enumerable: true,
174
+ get: function () {
175
+ return _utils.themed;
176
+ }
177
+ });
178
+ Object.defineProperty(exports, "time", {
179
+ enumerable: true,
180
+ get: function () {
181
+ return _utils.time;
182
+ }
183
+ });
46
184
  Object.defineProperty(exports, "useAsyncCollection", {
47
185
  enumerable: true,
48
186
  get: function () {
@@ -61,38 +199,26 @@ Object.defineProperty(exports, "useGlobalState", {
61
199
  return _reactGlobalState.useGlobalState;
62
200
  }
63
201
  });
64
- var _utils = require("./shared/utils");
65
- Object.keys(_utils).forEach(function (key) {
66
- if (key === "default" || key === "__esModule") return;
67
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
68
- if (key in exports && exports[key] === _utils[key]) return;
69
- Object.defineProperty(exports, key, {
70
- enumerable: true,
71
- get: function () {
72
- return _utils[key];
73
- }
74
- });
202
+ Object.defineProperty(exports, "webpack", {
203
+ enumerable: true,
204
+ get: function () {
205
+ return _utils.webpack;
206
+ }
207
+ });
208
+ Object.defineProperty(exports, "withRetries", {
209
+ enumerable: true,
210
+ get: function () {
211
+ return _utils.withRetries;
212
+ }
75
213
  });
214
+ var _utils = require("./shared/utils");
76
215
  var _axios = _interopRequireDefault(require("axios"));
77
216
  var _PT = _interopRequireWildcard(require("prop-types"));
78
217
  exports.PT = _PT;
79
- var _reactGlobalState = require("@dr.pogodin/react-global-state");
218
+ var _reactGlobalState = _interopRequireWildcard(require("@dr.pogodin/react-global-state"));
80
219
  var _components = require("./shared/components");
81
- Object.keys(_components).forEach(function (key) {
82
- if (key === "default" || key === "__esModule") return;
83
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
84
- if (key in exports && exports[key] === _components[key]) return;
85
- Object.defineProperty(exports, key, {
86
- enumerable: true,
87
- get: function () {
88
- return _components[key];
89
- }
90
- });
91
- });
92
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
93
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
94
- const server = _utils.webpack.requireWeak("./server", __dirname);
95
- exports.server = server;
96
- const client = server ? undefined : require("./client").default;
97
- exports.client = client;
220
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
221
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
222
+ const server = exports.server = _utils.webpack.requireWeak("./server", __dirname);
223
+ const client = exports.client = server ? undefined : require("./client").default;
98
224
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_utils","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_axios","_interopRequireDefault","_PT","_interopRequireWildcard","PT","_reactGlobalState","_components","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","newObj","hasPropertyDescriptor","getOwnPropertyDescriptor","desc","set","server","webpack","requireWeak","__dirname","client","undefined"],"sources":["../../src/index.js"],"sourcesContent":["import 'styles/global.scss';\n\nimport { webpack } from 'utils';\n\nconst server = webpack.requireWeak('./server', __dirname);\n\nconst client = server ? undefined : require('./client').default;\n\nexport { default as api } from 'axios';\nexport * as PT from 'prop-types';\n\nexport {\n getGlobalState,\n getSsrContext,\n GlobalStateProvider,\n useAsyncCollection,\n useAsyncData,\n useGlobalState,\n} from '@dr.pogodin/react-global-state';\n\nexport * from 'components';\nexport * from 'utils';\n\nexport { client, server };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAAA,MAAA,GAAAC,OAAA;AAmBAC,MAAA,CAAAC,IAAA,CAAAH,MAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAL,MAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAb,MAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AAbA,IAAAS,MAAA,GAAAC,sBAAA,CAAAd,OAAA;AAAuC,IAAAe,GAAA,GAAAC,uBAAA,CAAAhB,OAAA;AAAAS,OAAA,CAAAQ,EAAA,GAAAF,GAAA;AAGvC,IAAAG,iBAAA,GAAAlB,OAAA;AASA,IAAAmB,WAAA,GAAAnB,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAiB,WAAA,EAAAhB,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAe,WAAA,CAAAf,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAO,WAAA,CAAAf,GAAA;IAAA;EAAA;AAAA;AAA2B,SAAAgB,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAL,wBAAAS,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAhB,GAAA,CAAAa,GAAA,SAAAK,MAAA,WAAAC,qBAAA,GAAA9B,MAAA,CAAAS,cAAA,IAAAT,MAAA,CAAA+B,wBAAA,WAAA5B,GAAA,IAAAqB,GAAA,QAAArB,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAkB,GAAA,EAAArB,GAAA,SAAA6B,IAAA,GAAAF,qBAAA,GAAA9B,MAAA,CAAA+B,wBAAA,CAAAP,GAAA,EAAArB,GAAA,cAAA6B,IAAA,KAAAA,IAAA,CAAArB,GAAA,IAAAqB,IAAA,CAAAC,GAAA,KAAAjC,MAAA,CAAAS,cAAA,CAAAoB,MAAA,EAAA1B,GAAA,EAAA6B,IAAA,YAAAH,MAAA,CAAA1B,GAAA,IAAAqB,GAAA,CAAArB,GAAA,SAAA0B,MAAA,CAAAH,OAAA,GAAAF,GAAA,MAAAG,KAAA,IAAAA,KAAA,CAAAM,GAAA,CAAAT,GAAA,EAAAK,MAAA,YAAAA,MAAA;AAhB3B,MAAMK,MAAM,GAAGC,cAAO,CAACC,WAAW,aAAaC,SAAS,CAAC;AAAC7B,OAAA,CAAA0B,MAAA,GAAAA,MAAA;AAE1D,MAAMI,MAAM,GAAGJ,MAAM,GAAGK,SAAS,GAAGxC,OAAO,WAAW,CAAC,CAAC2B,OAAO;AAAClB,OAAA,CAAA8B,MAAA,GAAAA,MAAA"}
1
+ {"version":3,"file":"index.js","names":["_utils","require","_axios","_interopRequireDefault","_PT","_interopRequireWildcard","exports","PT","_reactGlobalState","_components","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","server","webpack","requireWeak","__dirname","client","undefined"],"sources":["../../src/index.ts"],"sourcesContent":["import 'styles/global.scss';\n\nimport { webpack } from 'utils';\n\nimport type ServerT from './server';\n\nconst server = webpack.requireWeak('./server', __dirname) as (typeof ServerT) | null;\n\nconst client = server ? undefined : require('./client').default;\n\nexport { default as api } from 'axios';\nexport * as PT from 'prop-types';\n\nexport {\n default as Rgs,\n type API as RgsApi,\n getGlobalState,\n GlobalStateProvider,\n useAsyncCollection,\n useAsyncData,\n useGlobalState,\n} from '@dr.pogodin/react-global-state';\n\nexport {\n BaseModal,\n Button,\n Checkbox,\n Dropdown,\n Input,\n Link,\n PageLayout,\n MetaTags,\n Modal,\n NavLink,\n ScalableRect,\n Throbber,\n WithTooltip,\n YouTubeVideo,\n} from 'components';\n\nexport {\n type Theme,\n config,\n Barrier,\n Emitter,\n isomorphy,\n getSsrContext,\n JU,\n Semaphore,\n splitComponent,\n themed,\n ThemeProvider,\n time,\n webpack,\n withRetries,\n} from 'utils';\n\nexport { client, server };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAAA,MAAA,GAAAC,OAAA;AAQA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAuC,IAAAG,GAAA,GAAAC,uBAAA,CAAAJ,OAAA;AAAAK,OAAA,CAAAC,EAAA,GAAAH,GAAA;AAGvC,IAAAI,iBAAA,GAAAH,uBAAA,CAAAJ,OAAA;AAUA,IAAAQ,WAAA,GAAAR,OAAA;AAeoB,SAAAS,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAN,wBAAAM,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAjB,CAAA,EAAAc,CAAA,SAAAI,CAAA,GAAAR,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAI,CAAA,KAAAA,CAAA,CAAAX,GAAA,IAAAW,CAAA,CAAAC,GAAA,IAAAR,MAAA,CAAAC,cAAA,CAAAJ,CAAA,EAAAM,CAAA,EAAAI,CAAA,IAAAV,CAAA,CAAAM,CAAA,IAAAd,CAAA,CAAAc,CAAA,YAAAN,CAAA,CAAAH,OAAA,GAAAL,CAAA,EAAAG,CAAA,IAAAA,CAAA,CAAAgB,GAAA,CAAAnB,CAAA,EAAAQ,CAAA,GAAAA,CAAA;AAhCpB,MAAMY,MAAM,GAAAzB,OAAA,CAAAyB,MAAA,GAAGC,cAAO,CAACC,WAAW,aAAaC,SAAS,CAA4B;AAEpF,MAAMC,MAAM,GAAA7B,OAAA,CAAA6B,MAAA,GAAGJ,MAAM,GAAGK,SAAS,GAAGnC,OAAO,WAAW,CAAC,CAACe,OAAO"}
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  /**
8
8
  * Implements the static cache.
9
- * @ignore
10
9
  */
11
10
  class Cache {
12
11
  constructor(maxSize) {
@@ -19,11 +18,10 @@ class Cache {
19
18
 
20
19
  /**
21
20
  * Cache lookup.
22
- * @ignore
23
- * @param {string} key Item key to look for.
24
- * @param {number} [maxage=Number.MAX_VALUE] Optional. The maximum age of
21
+ * @param key Item key to look for.
22
+ * @param [maxage=Number.MAX_VALUE] Optional. The maximum age of
25
23
  * cached item to serve. Default to infinite.
26
- * @returns {string} Cached item, or null if the item is absent in cache,
24
+ * @returns Cached item, or null if the item is absent in cache,
27
25
  * or stale.
28
26
  */
29
27
  get({
@@ -37,25 +35,27 @@ class Cache {
37
35
  /**
38
36
  * Adds item to cache.
39
37
  * @ignore
40
- * @param {string} data Item to add.
41
- * @param {string} key Key to store the item at.
38
+ * @param data Item to add.
39
+ * @param key Key to store the item at.
40
+ * @param size Byte size of the item.
42
41
  */
43
- add(data, key) {
42
+ add(data, key, size) {
44
43
  const p = this.private;
45
44
  const old = p.items[key];
46
- if (old) p.size -= old.data.length;
45
+ if (old) p.size -= old.size;
47
46
  p.items[key] = {
48
47
  data,
48
+ size,
49
49
  timestamp: Date.now()
50
50
  };
51
- p.size += data.length;
51
+ p.size += size;
52
52
  if (p.size > p.maxSize) {
53
53
  const items = Object.entries(p.items);
54
54
  items.sort((a, b) => a[1].timestamp - b[1].timestamp);
55
55
  for (let i = 0; i < items.length; ++i) {
56
- const item = items[i];
57
- delete p.items[item[0]];
58
- p.size -= item[1].data.length;
56
+ const [itemKey, item] = items[i];
57
+ delete p.items[itemKey];
58
+ p.size -= item.size;
59
59
  if (p.size < p.maxSize / 2) break;
60
60
  }
61
61
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Cache.js","names":["Cache","constructor","maxSize","private","items","size","get","key","maxage","Number","MAX_VALUE","item","Date","now","timestamp","data","add","p","old","length","Object","entries","sort","a","b","i","exports","default"],"sources":["../../../src/server/Cache.js"],"sourcesContent":["/**\n * Implements the static cache.\n * @ignore\n */\nexport default class Cache {\n constructor(maxSize) {\n this.private = {\n items: {},\n maxSize,\n size: 0,\n };\n }\n\n /**\n * Cache lookup.\n * @ignore\n * @param {string} key Item key to look for.\n * @param {number} [maxage=Number.MAX_VALUE] Optional. The maximum age of\n * cached item to serve. Default to infinite.\n * @returns {string} Cached item, or null if the item is absent in cache,\n * or stale.\n */\n get({ key, maxage = Number.MAX_VALUE }) {\n const item = this.private.items[key];\n return item && Date.now() - item.timestamp < maxage ? item.data : null;\n }\n\n /**\n * Adds item to cache.\n * @ignore\n * @param {string} data Item to add.\n * @param {string} key Key to store the item at.\n */\n add(data, key) {\n const p = this.private;\n const old = p.items[key];\n if (old) p.size -= old.data.length;\n p.items[key] = { data, timestamp: Date.now() };\n p.size += data.length;\n if (p.size > p.maxSize) {\n const items = Object.entries(p.items);\n items.sort((a, b) => a[1].timestamp - b[1].timestamp);\n for (let i = 0; i < items.length; ++i) {\n const item = items[i];\n delete p.items[item[0]];\n p.size -= item[1].data.length;\n if (p.size < p.maxSize / 2) break;\n }\n }\n }\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACe,MAAMA,KAAK,CAAC;EACzBC,WAAWA,CAACC,OAAO,EAAE;IACnB,IAAI,CAACC,OAAO,GAAG;MACbC,KAAK,EAAE,CAAC,CAAC;MACTF,OAAO;MACPG,IAAI,EAAE;IACR,CAAC;EACH;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,GAAGA,CAAC;IAAEC,GAAG;IAAEC,MAAM,GAAGC,MAAM,CAACC;EAAU,CAAC,EAAE;IACtC,MAAMC,IAAI,GAAG,IAAI,CAACR,OAAO,CAACC,KAAK,CAACG,GAAG,CAAC;IACpC,OAAOI,IAAI,IAAIC,IAAI,CAACC,GAAG,CAAC,CAAC,GAAGF,IAAI,CAACG,SAAS,GAAGN,MAAM,GAAGG,IAAI,CAACI,IAAI,GAAG,IAAI;EACxE;;EAEA;AACF;AACA;AACA;AACA;AACA;EACEC,GAAGA,CAACD,IAAI,EAAER,GAAG,EAAE;IACb,MAAMU,CAAC,GAAG,IAAI,CAACd,OAAO;IACtB,MAAMe,GAAG,GAAGD,CAAC,CAACb,KAAK,CAACG,GAAG,CAAC;IACxB,IAAIW,GAAG,EAAED,CAAC,CAACZ,IAAI,IAAIa,GAAG,CAACH,IAAI,CAACI,MAAM;IAClCF,CAAC,CAACb,KAAK,CAACG,GAAG,CAAC,GAAG;MAAEQ,IAAI;MAAED,SAAS,EAAEF,IAAI,CAACC,GAAG,CAAC;IAAE,CAAC;IAC9CI,CAAC,CAACZ,IAAI,IAAIU,IAAI,CAACI,MAAM;IACrB,IAAIF,CAAC,CAACZ,IAAI,GAAGY,CAAC,CAACf,OAAO,EAAE;MACtB,MAAME,KAAK,GAAGgB,MAAM,CAACC,OAAO,CAACJ,CAAC,CAACb,KAAK,CAAC;MACrCA,KAAK,CAACkB,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAAC,CAAC,CAAC,CAACT,SAAS,GAAGU,CAAC,CAAC,CAAC,CAAC,CAACV,SAAS,CAAC;MACrD,KAAK,IAAIW,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGrB,KAAK,CAACe,MAAM,EAAE,EAAEM,CAAC,EAAE;QACrC,MAAMd,IAAI,GAAGP,KAAK,CAACqB,CAAC,CAAC;QACrB,OAAOR,CAAC,CAACb,KAAK,CAACO,IAAI,CAAC,CAAC,CAAC,CAAC;QACvBM,CAAC,CAACZ,IAAI,IAAIM,IAAI,CAAC,CAAC,CAAC,CAACI,IAAI,CAACI,MAAM;QAC7B,IAAIF,CAAC,CAACZ,IAAI,GAAGY,CAAC,CAACf,OAAO,GAAG,CAAC,EAAE;MAC9B;IACF;EACF;AACF;AAACwB,OAAA,CAAAC,OAAA,GAAA3B,KAAA"}
1
+ {"version":3,"file":"Cache.js","names":["Cache","constructor","maxSize","private","items","size","get","key","maxage","Number","MAX_VALUE","item","Date","now","timestamp","data","add","p","old","Object","entries","sort","a","b","i","length","itemKey","exports","default"],"sources":["../../../src/server/Cache.ts"],"sourcesContent":["/**\n * Implements the static cache.\n */\nexport default class Cache<DatumT> {\n private: {\n items: {\n [key: string]: {\n data: DatumT;\n size: number;\n timestamp: number;\n }\n };\n maxSize: number;\n size: number;\n };\n\n constructor(maxSize: number) {\n this.private = {\n items: {},\n maxSize,\n size: 0,\n };\n }\n\n /**\n * Cache lookup.\n * @param key Item key to look for.\n * @param [maxage=Number.MAX_VALUE] Optional. The maximum age of\n * cached item to serve. Default to infinite.\n * @returns Cached item, or null if the item is absent in cache,\n * or stale.\n */\n get({\n key,\n maxage = Number.MAX_VALUE,\n }: {\n key: string;\n maxage?: number;\n }): DatumT | null {\n const item = this.private.items[key];\n return item && Date.now() - item.timestamp < maxage ? item.data : null;\n }\n\n /**\n * Adds item to cache.\n * @ignore\n * @param data Item to add.\n * @param key Key to store the item at.\n * @param size Byte size of the item.\n */\n add(data: DatumT, key: string, size: number) {\n const p = this.private;\n const old = p.items[key];\n if (old) p.size -= old.size;\n p.items[key] = { data, size, timestamp: Date.now() };\n p.size += size;\n if (p.size > p.maxSize) {\n const items = Object.entries(p.items);\n items.sort((a, b) => a[1].timestamp - b[1].timestamp);\n for (let i = 0; i < items.length; ++i) {\n const [itemKey, item] = items[i];\n delete p.items[itemKey];\n p.size -= item.size;\n if (p.size < p.maxSize / 2) break;\n }\n }\n }\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACe,MAAMA,KAAK,CAAS;EAajCC,WAAWA,CAACC,OAAe,EAAE;IAC3B,IAAI,CAACC,OAAO,GAAG;MACbC,KAAK,EAAE,CAAC,CAAC;MACTF,OAAO;MACPG,IAAI,EAAE;IACR,CAAC;EACH;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,GAAGA,CAAC;IACFC,GAAG;IACHC,MAAM,GAAGC,MAAM,CAACC;EAIlB,CAAC,EAAiB;IAChB,MAAMC,IAAI,GAAG,IAAI,CAACR,OAAO,CAACC,KAAK,CAACG,GAAG,CAAC;IACpC,OAAOI,IAAI,IAAIC,IAAI,CAACC,GAAG,CAAC,CAAC,GAAGF,IAAI,CAACG,SAAS,GAAGN,MAAM,GAAGG,IAAI,CAACI,IAAI,GAAG,IAAI;EACxE;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACEC,GAAGA,CAACD,IAAY,EAAER,GAAW,EAAEF,IAAY,EAAE;IAC3C,MAAMY,CAAC,GAAG,IAAI,CAACd,OAAO;IACtB,MAAMe,GAAG,GAAGD,CAAC,CAACb,KAAK,CAACG,GAAG,CAAC;IACxB,IAAIW,GAAG,EAAED,CAAC,CAACZ,IAAI,IAAIa,GAAG,CAACb,IAAI;IAC3BY,CAAC,CAACb,KAAK,CAACG,GAAG,CAAC,GAAG;MAAEQ,IAAI;MAAEV,IAAI;MAAES,SAAS,EAAEF,IAAI,CAACC,GAAG,CAAC;IAAE,CAAC;IACpDI,CAAC,CAACZ,IAAI,IAAIA,IAAI;IACd,IAAIY,CAAC,CAACZ,IAAI,GAAGY,CAAC,CAACf,OAAO,EAAE;MACtB,MAAME,KAAK,GAAGe,MAAM,CAACC,OAAO,CAACH,CAAC,CAACb,KAAK,CAAC;MACrCA,KAAK,CAACiB,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAAC,CAAC,CAAC,CAACR,SAAS,GAAGS,CAAC,CAAC,CAAC,CAAC,CAACT,SAAS,CAAC;MACrD,KAAK,IAAIU,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGpB,KAAK,CAACqB,MAAM,EAAE,EAAED,CAAC,EAAE;QACrC,MAAM,CAACE,OAAO,EAAEf,IAAI,CAAC,GAAGP,KAAK,CAACoB,CAAC,CAAC;QAChC,OAAOP,CAAC,CAACb,KAAK,CAACsB,OAAO,CAAC;QACvBT,CAAC,CAACZ,IAAI,IAAIM,IAAI,CAACN,IAAI;QACnB,IAAIY,CAAC,CAACZ,IAAI,GAAGY,CAAC,CAACf,OAAO,GAAG,CAAC,EAAE;MAC9B;IACF;EACF;AACF;AAACyB,OAAA,CAAAC,OAAA,GAAA5B,KAAA"}