@dr.pogodin/react-utils 1.47.0-alpha.7 → 1.47.0-alpha.9

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 (165) hide show
  1. package/build/development/client/index.js +1 -1
  2. package/build/development/client/index.js.map +1 -1
  3. package/build/development/index.js +1 -11
  4. package/build/development/index.js.map +1 -1
  5. package/build/development/server/index.js +3 -6
  6. package/build/development/server/index.js.map +1 -1
  7. package/build/development/server/utils/index.js +1 -1
  8. package/build/development/server/utils/index.js.map +1 -1
  9. package/build/development/shared/components/Button/index.js +1 -1
  10. package/build/development/shared/components/Button/index.js.map +1 -1
  11. package/build/development/shared/components/Checkbox/index.js +1 -1
  12. package/build/development/shared/components/Checkbox/index.js.map +1 -1
  13. package/build/development/shared/components/Input/index.js +1 -1
  14. package/build/development/shared/components/Input/index.js.map +1 -1
  15. package/build/development/shared/components/Modal/index.js +1 -1
  16. package/build/development/shared/components/Modal/index.js.map +1 -1
  17. package/build/development/shared/components/PageLayout/index.js +1 -1
  18. package/build/development/shared/components/PageLayout/index.js.map +1 -1
  19. package/build/development/shared/components/TextArea/index.js +1 -1
  20. package/build/development/shared/components/TextArea/index.js.map +1 -1
  21. package/build/development/shared/components/Throbber/index.js +1 -1
  22. package/build/development/shared/components/Throbber/index.js.map +1 -1
  23. package/build/development/shared/components/WithTooltip/index.js +1 -1
  24. package/build/development/shared/components/WithTooltip/index.js.map +1 -1
  25. package/build/development/shared/components/YouTubeVideo/index.js +1 -1
  26. package/build/development/shared/components/YouTubeVideo/index.js.map +1 -1
  27. package/build/development/shared/components/selectors/CustomDropdown/index.js +1 -1
  28. package/build/development/shared/components/selectors/CustomDropdown/index.js.map +1 -1
  29. package/build/development/shared/components/selectors/NativeDropdown/index.js +1 -1
  30. package/build/development/shared/components/selectors/NativeDropdown/index.js.map +1 -1
  31. package/build/development/shared/components/selectors/Switch/index.js +1 -1
  32. package/build/development/shared/components/selectors/Switch/index.js.map +1 -1
  33. package/build/production/client/index.js +1 -1
  34. package/build/production/client/index.js.map +1 -1
  35. package/build/production/index.js +2 -6
  36. package/build/production/index.js.map +1 -1
  37. package/build/production/server/index.js +3 -3
  38. package/build/production/server/index.js.map +1 -1
  39. package/build/production/server/utils/index.js +1 -1
  40. package/build/production/server/utils/index.js.map +1 -1
  41. package/build/production/shared/components/Button/index.js +1 -1
  42. package/build/production/shared/components/Button/index.js.map +1 -1
  43. package/build/production/shared/components/Checkbox/index.js +1 -1
  44. package/build/production/shared/components/Checkbox/index.js.map +1 -1
  45. package/build/production/shared/components/Input/index.js +1 -1
  46. package/build/production/shared/components/Input/index.js.map +1 -1
  47. package/build/production/shared/components/Modal/index.js +1 -1
  48. package/build/production/shared/components/Modal/index.js.map +1 -1
  49. package/build/production/shared/components/PageLayout/index.js +1 -1
  50. package/build/production/shared/components/PageLayout/index.js.map +1 -1
  51. package/build/production/shared/components/TextArea/index.js +1 -1
  52. package/build/production/shared/components/TextArea/index.js.map +1 -1
  53. package/build/production/shared/components/Throbber/index.js +1 -1
  54. package/build/production/shared/components/Throbber/index.js.map +1 -1
  55. package/build/production/shared/components/WithTooltip/index.js +1 -1
  56. package/build/production/shared/components/WithTooltip/index.js.map +1 -1
  57. package/build/production/shared/components/YouTubeVideo/index.js +1 -1
  58. package/build/production/shared/components/YouTubeVideo/index.js.map +1 -1
  59. package/build/production/shared/components/selectors/CustomDropdown/index.js +1 -1
  60. package/build/production/shared/components/selectors/CustomDropdown/index.js.map +1 -1
  61. package/build/production/shared/components/selectors/NativeDropdown/index.js +1 -1
  62. package/build/production/shared/components/selectors/NativeDropdown/index.js.map +1 -1
  63. package/build/production/shared/components/selectors/Switch/index.js +1 -1
  64. package/build/production/shared/components/selectors/Switch/index.js.map +1 -1
  65. package/build/types-code/client/index.d.ts +1 -1
  66. package/build/types-code/index.d.ts +0 -6
  67. package/build/types-code/server/index.d.ts +4 -9
  68. package/build/types-code/server/utils/index.d.ts +1 -1
  69. package/build/web/client/index.js +1 -1
  70. package/build/web/client/index.js.map +1 -1
  71. package/build/web/index.js +0 -12
  72. package/build/web/index.js.map +1 -1
  73. package/build/web/server/index.js +3 -6
  74. package/build/web/server/index.js.map +1 -1
  75. package/build/web/server/utils/index.js +1 -1
  76. package/build/web/server/utils/index.js.map +1 -1
  77. package/build/web/shared/components/Button/index.js +1 -1
  78. package/build/web/shared/components/Button/index.js.map +1 -1
  79. package/build/web/shared/components/Checkbox/index.js +1 -1
  80. package/build/web/shared/components/Checkbox/index.js.map +1 -1
  81. package/build/web/shared/components/Input/index.js +1 -1
  82. package/build/web/shared/components/Input/index.js.map +1 -1
  83. package/build/web/shared/components/Modal/index.js +1 -1
  84. package/build/web/shared/components/Modal/index.js.map +1 -1
  85. package/build/web/shared/components/PageLayout/index.js +1 -1
  86. package/build/web/shared/components/PageLayout/index.js.map +1 -1
  87. package/build/web/shared/components/TextArea/index.js +1 -1
  88. package/build/web/shared/components/TextArea/index.js.map +1 -1
  89. package/build/web/shared/components/Throbber/index.js +1 -1
  90. package/build/web/shared/components/Throbber/index.js.map +1 -1
  91. package/build/web/shared/components/WithTooltip/index.js +1 -1
  92. package/build/web/shared/components/WithTooltip/index.js.map +1 -1
  93. package/build/web/shared/components/YouTubeVideo/index.js +1 -1
  94. package/build/web/shared/components/YouTubeVideo/index.js.map +1 -1
  95. package/build/web/shared/components/selectors/CustomDropdown/index.js +1 -1
  96. package/build/web/shared/components/selectors/CustomDropdown/index.js.map +1 -1
  97. package/build/web/shared/components/selectors/NativeDropdown/index.js +1 -1
  98. package/build/web/shared/components/selectors/NativeDropdown/index.js.map +1 -1
  99. package/build/web/shared/components/selectors/Switch/index.js +1 -1
  100. package/build/web/shared/components/selectors/Switch/index.js.map +1 -1
  101. package/package.json +17 -6
  102. package/src/client/getInj.ts +0 -71
  103. package/src/client/index.tsx +0 -45
  104. package/src/client/init.ts +0 -52
  105. package/src/index.ts +0 -75
  106. package/src/server/Cache.ts +0 -61
  107. package/src/server/index.ts +0 -243
  108. package/src/server/renderer.tsx +0 -635
  109. package/src/server/server.ts +0 -330
  110. package/src/server/utils/errors.ts +0 -122
  111. package/src/server/utils/index.ts +0 -3
  112. package/src/shared/components/Button/index.tsx +0 -130
  113. package/src/shared/components/Button/style.scss +0 -54
  114. package/src/shared/components/Checkbox/index.tsx +0 -53
  115. package/src/shared/components/Checkbox/theme.scss +0 -63
  116. package/src/shared/components/GenericLink/index.tsx +0 -141
  117. package/src/shared/components/GenericLink/style.scss +0 -3
  118. package/src/shared/components/Input/index.tsx +0 -96
  119. package/src/shared/components/Input/theme.scss +0 -52
  120. package/src/shared/components/Link.tsx +0 -25
  121. package/src/shared/components/Modal/base-theme.scss +0 -38
  122. package/src/shared/components/Modal/index.tsx +0 -177
  123. package/src/shared/components/Modal/styles.scss +0 -3
  124. package/src/shared/components/NavLink.tsx +0 -18
  125. package/src/shared/components/PageLayout/base-theme.scss +0 -30
  126. package/src/shared/components/PageLayout/index.tsx +0 -51
  127. package/src/shared/components/TextArea/index.tsx +0 -139
  128. package/src/shared/components/TextArea/style.scss +0 -68
  129. package/src/shared/components/Throbber/index.tsx +0 -28
  130. package/src/shared/components/Throbber/theme.scss +0 -26
  131. package/src/shared/components/WithTooltip/Tooltip.tsx +0 -274
  132. package/src/shared/components/WithTooltip/default-theme.scss +0 -36
  133. package/src/shared/components/WithTooltip/index.tsx +0 -186
  134. package/src/shared/components/YouTubeVideo/base.scss +0 -15
  135. package/src/shared/components/YouTubeVideo/index.tsx +0 -73
  136. package/src/shared/components/YouTubeVideo/throbber.scss +0 -11
  137. package/src/shared/components/index.ts +0 -20
  138. package/src/shared/components/selectors/CustomDropdown/Options/index.tsx +0 -124
  139. package/src/shared/components/selectors/CustomDropdown/Options/style.scss +0 -6
  140. package/src/shared/components/selectors/CustomDropdown/index.tsx +0 -146
  141. package/src/shared/components/selectors/CustomDropdown/theme.scss +0 -118
  142. package/src/shared/components/selectors/NativeDropdown/index.tsx +0 -90
  143. package/src/shared/components/selectors/NativeDropdown/theme.scss +0 -81
  144. package/src/shared/components/selectors/Switch/index.tsx +0 -74
  145. package/src/shared/components/selectors/Switch/theme.scss +0 -39
  146. package/src/shared/components/selectors/common.ts +0 -57
  147. package/src/shared/components/selectors/index.ts +0 -8
  148. package/src/shared/utils/config.ts +0 -59
  149. package/src/shared/utils/globalState.ts +0 -44
  150. package/src/shared/utils/index.ts +0 -45
  151. package/src/shared/utils/isomorphy/buildInfo.ts +0 -50
  152. package/src/shared/utils/isomorphy/environment-check.ts +0 -18
  153. package/src/shared/utils/isomorphy/index.ts +0 -36
  154. package/src/shared/utils/jest/E2eSsrEnv.ts +0 -304
  155. package/src/shared/utils/jest/global.ts +0 -17
  156. package/src/shared/utils/jest/index.ts +0 -215
  157. package/src/shared/utils/splitComponent.tsx +0 -284
  158. package/src/shared/utils/time.ts +0 -101
  159. package/src/shared/utils/webpack.ts +0 -80
  160. package/src/styles/_global/reset.css +0 -52
  161. package/src/styles/_mixins/fonts.scss +0 -40
  162. package/src/styles/_mixins/media.scss +0 -150
  163. package/src/styles/_mixins/typography.scss +0 -83
  164. package/src/styles/global.scss +0 -11
  165. package/src/styles/mixins.scss +0 -6
@@ -1,284 +0,0 @@
1
- /* global document */
2
-
3
- import {
4
- type ComponentType,
5
- type FunctionComponent,
6
- type ReactNode,
7
- type RefObject,
8
- Suspense,
9
- lazy,
10
- useInsertionEffect,
11
- } from 'react';
12
-
13
- import { Barrier } from '@dr.pogodin/js-utils';
14
-
15
- import { type ChunkGroupsT, getSsrContext } from './globalState';
16
-
17
- import {
18
- IS_CLIENT_SIDE,
19
- IS_SERVER_SIDE,
20
- getBuildInfo,
21
- } from './isomorphy';
22
-
23
- function getClientChunkGroups(): Promise<ChunkGroupsT> | undefined {
24
- if (!IS_CLIENT_SIDE) return undefined;
25
-
26
- return (async () => {
27
- const { default: getInj } = await import(/* webpackChunkName: "react-utils-client-side-code" */ '../../client/getInj');
28
-
29
- const inj = await getInj();
30
- return inj.CHUNK_GROUPS ?? {};
31
- })();
32
- }
33
-
34
- const refCounts: Record<string, number> = {};
35
-
36
- function getPublicPath() {
37
- return getBuildInfo().publicPath;
38
- }
39
-
40
- /**
41
- * Client-side only! Ensures the specified CSS stylesheet is loaded into
42
- * the document; loads if it is missing; and does simple reference counting
43
- * to facilitate future clean-up.
44
- * @param name
45
- * @param loadedSheets
46
- * @param refCount
47
- * @return
48
- */
49
- function bookStyleSheet(
50
- name: string,
51
- loadedSheets: Set<string>,
52
- refCount: boolean,
53
- ): Promise<void> | undefined {
54
- let res: Barrier<void> | undefined;
55
- const path = `${getPublicPath()}/${name}`;
56
- const fullPath = `${document.location.origin}${path}`;
57
-
58
- if (!loadedSheets.has(fullPath)) {
59
- let link = document.querySelector(`link[href="${path}"]`);
60
-
61
- if (!link) {
62
- link = document.createElement('link');
63
- link.setAttribute('rel', 'stylesheet');
64
- link.setAttribute('href', path);
65
- document.head.appendChild(link);
66
- }
67
-
68
- res = new Barrier<void>();
69
- link.addEventListener('load', () => {
70
- if (!res) throw Error('Internal error');
71
- void res.resolve();
72
- });
73
- link.addEventListener('error', () => {
74
- if (!res) throw Error('Internal error');
75
- void res.resolve();
76
- });
77
- }
78
-
79
- if (refCount) {
80
- const current = refCounts[path] ?? 0;
81
- refCounts[path] = 1 + current;
82
- }
83
-
84
- return res;
85
- }
86
-
87
- /**
88
- * Generates the set of URLs for currently loaded, linked stylesheets.
89
- * @return
90
- */
91
- function getLoadedStyleSheets(): Set<string> {
92
- const res = new Set<string>();
93
- const { styleSheets } = document;
94
- for (const { href } of styleSheets) {
95
- if (href) res.add(href);
96
- }
97
- return res;
98
- }
99
-
100
- function assertChunkName(
101
- chunkName: string,
102
- chunkGroups: ChunkGroupsT,
103
- ) {
104
- if (chunkGroups[chunkName]) return;
105
- throw Error(`Unknown chunk name "${chunkName}"`);
106
- }
107
-
108
- /**
109
- * Client-side only! Ensures all CSS stylesheets required for the specified
110
- * code chunk are loaded into the document; loads the missing ones; and does
111
- * simple reference counting to facilitate future clean-up.
112
- * @param chunkName Chunk name.
113
- * @param refCount
114
- * @return Resolves once all pending stylesheets, necessary for
115
- * the chunk, are either loaded, or failed to load.
116
- */
117
- export async function bookStyleSheets(
118
- chunkName: string,
119
- chunkGroups: ChunkGroupsT,
120
- refCount: boolean,
121
- ): Promise<void> {
122
- const promises = [];
123
- const assets = chunkGroups[chunkName];
124
- if (!assets) return Promise.resolve();
125
-
126
- const loadedSheets = getLoadedStyleSheets();
127
-
128
- for (const asset of assets) {
129
- if (asset.endsWith('.css')) {
130
- const promise = bookStyleSheet(asset, loadedSheets, refCount);
131
- if (promise) promises.push(promise);
132
- }
133
- }
134
-
135
- return promises.length
136
- ? Promise.allSettled(promises).then()
137
- : Promise.resolve();
138
- }
139
-
140
- /**
141
- * Client-side only! Frees from the document all CSS stylesheets that are
142
- * required by the specified chunk, and have reference counter equal to one
143
- * (for chunks with larger reference counter values, it just decrements
144
- * the reference counter).
145
- * @param {string} chunkName
146
- */
147
- export function freeStyleSheets(
148
- chunkName: string,
149
- chunkGroups: ChunkGroupsT,
150
- ): void {
151
- const assets = chunkGroups[chunkName];
152
- if (!assets) return;
153
-
154
- for (const asset of assets) {
155
- if (asset.endsWith('.css')) {
156
- const path = `${getPublicPath()}/${asset}`;
157
-
158
- const pathRefCount = refCounts[path];
159
- if (pathRefCount) {
160
- if (pathRefCount <= 1) {
161
- document.head.querySelector(`link[href="${path}"]`)!.remove();
162
- delete refCounts[path];
163
- } else refCounts[path] = pathRefCount - 1;
164
- }
165
- }
166
- }
167
- }
168
-
169
- // Holds the set of chunk names already used for splitComponent() calls.
170
- const usedChunkNames = new Set();
171
-
172
- type ComponentOrModule<PropsT> = ComponentType<PropsT> | {
173
- default: ComponentType<PropsT>;
174
- };
175
-
176
- type GenericComponentPropsT = {
177
- children?: ReactNode;
178
- ref?: RefObject<unknown>;
179
-
180
- // NOTE: This is necessary, as without it this type (with only optional
181
- // fields) will be conisdered as "weak" by TypeScript, and it will be
182
- // a error to assign to it any type that does not use "children", or "ref".
183
- [propName: string]: unknown;
184
- };
185
-
186
- /**
187
- * Given an async component retrieval function `getComponent()` it creates
188
- * a special "code split" component, which uses <Suspense> to asynchronously
189
- * load on demand the code required by `getComponent()`.
190
- * @param options
191
- * @param options.chunkName
192
- * @param {function} options.getComponent
193
- * @param {React.Element} [options.placeholder]
194
- * @return {React.ElementType}
195
- */
196
- export default function splitComponent<
197
- ComponentPropsT extends GenericComponentPropsT,
198
- >({
199
- chunkName,
200
- getComponent,
201
- placeholder,
202
- }: {
203
- chunkName: string;
204
- getComponent: () => Promise<ComponentOrModule<ComponentPropsT>>;
205
- placeholder?: ReactNode;
206
- }): FunctionComponent<ComponentPropsT> {
207
- // The correct usage of splitComponent() assumes a single call per chunk.
208
- if (usedChunkNames.has(chunkName)) {
209
- throw Error(`Repeated splitComponent() call for the chunk "${chunkName}"`);
210
- } else usedChunkNames.add(chunkName);
211
-
212
- const LazyComponent = lazy(async () => {
213
- const clientChunkGroups = await getClientChunkGroups();
214
-
215
- // On the client side we can check right away if the chunk name is known.
216
- if (IS_CLIENT_SIDE) {
217
- if (!clientChunkGroups) throw Error('Internal error');
218
- assertChunkName(chunkName, clientChunkGroups);
219
- }
220
-
221
- const resolved = await getComponent();
222
- const Component = 'default' in resolved ? resolved.default : resolved;
223
-
224
- // This pre-loads necessary stylesheets prior to the first mount of
225
- // the component (the lazy load function is executed by React one at
226
- // the frist mount).
227
- if (IS_CLIENT_SIDE) {
228
- if (!clientChunkGroups) throw Error('Internal error');
229
- await bookStyleSheets(chunkName, clientChunkGroups, false);
230
- }
231
-
232
- const Wrapper: FunctionComponent<ComponentPropsT> = ({
233
- children,
234
- ref,
235
- ...rest
236
- }) => {
237
- // On the server side we'll assert the chunk name here,
238
- // and also push it to the SSR chunks array.
239
- if (IS_SERVER_SIDE) {
240
- const { chunkGroups, chunks } = getSsrContext()!;
241
- assertChunkName(chunkName, chunkGroups);
242
- if (!chunks.includes(chunkName)) chunks.push(chunkName);
243
- }
244
-
245
- // This takes care about stylesheets management every time an instance of
246
- // this component is mounted / unmounted.
247
- useInsertionEffect(() => {
248
- if (!clientChunkGroups) throw Error('Internal error');
249
- void bookStyleSheets(chunkName, clientChunkGroups, true);
250
- return () => {
251
- freeStyleSheets(chunkName, clientChunkGroups);
252
- };
253
- }, []);
254
-
255
- return (
256
- <Component
257
- // eslint-disable-next-line react/jsx-props-no-spreading
258
- {...(rest as unknown as ComponentPropsT)}
259
- ref={ref}
260
- >
261
- {children}
262
- </Component>
263
- );
264
- };
265
-
266
- return { default: Wrapper };
267
- });
268
-
269
- const CodeSplit: React.FunctionComponent<ComponentPropsT> = ({
270
- children,
271
- ...rest
272
- }: ComponentPropsT) => (
273
- <Suspense fallback={placeholder}>
274
- <LazyComponent
275
- // eslint-disable-next-line react/jsx-props-no-spreading
276
- {...rest as Parameters<typeof LazyComponent>[0]}
277
- >
278
- {children}
279
- </LazyComponent>
280
- </Suspense>
281
- );
282
-
283
- return CodeSplit;
284
- }
@@ -1,101 +0,0 @@
1
- import { serialize } from 'cookie';
2
- import { useEffect } from 'react';
3
- import dayjs from 'dayjs';
4
-
5
- import {
6
- DAY_MS,
7
- HOUR_MS,
8
- MIN_MS,
9
- SEC_MS,
10
- YEAR_MS,
11
- timer,
12
- } from '@dr.pogodin/js-utils';
13
-
14
- import { type ForceT, useGlobalState } from '@dr.pogodin/react-global-state';
15
-
16
- import { getSsrContext } from './globalState';
17
-
18
- /**
19
- * This react hook wraps Date.now() function in a SSR friendly way,
20
- * ensuring that all calls to useCurrent() within the same render return
21
- * exactly the same time (which is retrieved from Date.now() first, and
22
- * then stored in the global state to be reused in all other calls), which
23
- * is also passed and used in the first client side render, and then updated
24
- * with a finite precision to avoid infinite re-rendering loops.
25
- */
26
- // TODO: Should we request the state type as generic parameter, to be able
27
- // to verify the give globalStatePath is correct?
28
- export function useCurrent({
29
- autorefresh = false,
30
- globalStatePath = 'currentTime',
31
- precision = 5 * SEC_MS,
32
- } = {}): number {
33
- const [now, setter] = useGlobalState<ForceT, number>(
34
- globalStatePath,
35
- Date.now,
36
- );
37
- useEffect(() => {
38
- let timerId: NodeJS.Timeout | undefined;
39
- const update = (): void => {
40
- setter((old) => {
41
- const neu = Date.now();
42
- return Math.abs(neu - old) > precision ? neu : old;
43
- });
44
- if (autorefresh) timerId = setTimeout(update, precision);
45
- };
46
- update();
47
- return (): void => {
48
- if (timerId) clearTimeout(timerId);
49
- };
50
- }, [autorefresh, precision, setter]);
51
- return now;
52
- }
53
-
54
- /**
55
- * Wraps the standard Date.getTimezoneOffset() method in a SSR-friendly way.
56
- * This hook retrieves the offset value at the client side and uses a cookie
57
- * to pass it to the server in subsequent requests from that user. At the server
58
- * side the value from cookie is used in renders and passed back to the client
59
- * via the global state. Prior to the value being known (in the very first
60
- * request from the user, when the cookie is still missing), zero value is used
61
- * as the default value.
62
- */
63
- // TODO: Should we request the state type as generic parameter, to be able
64
- // to verify the give globalStatePath is correct?
65
- export function useTimezoneOffset({
66
- cookieName = 'timezoneOffset',
67
- globalStatePath = 'timezoneOffset',
68
- } = {}): number {
69
- const ssrContext = getSsrContext(false);
70
- const [offset, setOffset] = useGlobalState<ForceT, number>(
71
- globalStatePath,
72
- () => {
73
- const value = cookieName
74
- && ssrContext?.req.cookies[cookieName] as string;
75
- return value ? parseInt(value) : 0;
76
- },
77
- );
78
- useEffect(() => {
79
- const date = new Date();
80
- const value = date.getTimezoneOffset();
81
- setOffset(value);
82
- if (cookieName) {
83
- document.cookie = serialize(cookieName, value.toString(), { path: '/' });
84
- }
85
- }, [cookieName, setOffset]);
86
- return offset;
87
- }
88
-
89
- const time = {
90
- DAY_MS,
91
- HOUR_MS,
92
- MIN_MS,
93
- SEC_MS,
94
- YEAR_MS,
95
- now: Date.now,
96
- timer,
97
- useCurrent,
98
- useTimezoneOffset,
99
- };
100
-
101
- export default Object.assign(dayjs, time);
@@ -1,80 +0,0 @@
1
- import type PathNS from 'node:path';
2
-
3
- // eslint-disable-next-line import/enforce-node-protocol-usage
4
- import { createRequire } from 'module';
5
-
6
- import { IS_CLIENT_SIDE, IS_SERVER_SIDE } from './isomorphy';
7
-
8
- type RequireWeakOptionsT = {
9
- basePath?: string;
10
- };
11
-
12
- type RequireWeakResT<T> = T extends { default: infer D }
13
- ? (D extends null | undefined ? T : D & Omit<T, 'default'>)
14
- : T;
15
-
16
- let require: ((url: string) => unknown) | undefined;
17
-
18
- if (IS_SERVER_SIDE) require = createRequire(import.meta.url);
19
-
20
- /**
21
- * Requires the specified module without including it into the bundle during
22
- * Webpack build.
23
- * @param modulePath
24
- * @param [basePath]
25
- * @return Required module.
26
- */
27
- export function requireWeak<T extends object>(
28
- modulePath: string,
29
-
30
- // TODO: For now `basePath` can be provided directly as a string here,
31
- // for backward compatibility. Deprecate it in future, if any other
32
- // breaking changes are done for requireWeak().
33
- basePathOrOptions?: string | RequireWeakOptionsT,
34
- ): RequireWeakResT<T> | null {
35
- if (IS_CLIENT_SIDE) return null;
36
-
37
- let basePath: string | undefined;
38
- let ops: RequireWeakOptionsT;
39
- if (typeof basePathOrOptions === 'string') {
40
- basePath = basePathOrOptions;
41
- } else {
42
- ops = basePathOrOptions ?? {};
43
- ({ basePath } = ops);
44
- }
45
-
46
- // eslint-disable-next-line @typescript-eslint/unbound-method
47
- const { resolve } = require!('node:path') as typeof PathNS;
48
-
49
- const path = basePath ? resolve(basePath, modulePath) : modulePath;
50
-
51
- const module = require!(path) as T;
52
-
53
- if (!('default' in module) || !module.default) return module as RequireWeakResT<T>;
54
-
55
- const { default: def, ...named } = module;
56
-
57
- const res = def as RequireWeakResT<T>;
58
-
59
- Object.entries(named).forEach(([name, value]) => {
60
- const assigned = res[name as keyof RequireWeakResT<T>];
61
- if (assigned === undefined) {
62
- (res[name as keyof RequireWeakResT<T>] as unknown) = value;
63
- } else if (assigned !== value) {
64
- throw Error('Conflict between default and named exports');
65
- }
66
- });
67
- return res;
68
- }
69
-
70
- /**
71
- * Resolves specified module path with help of Babel's module resolver.
72
- * Yes, the function itself just returns its argument to the caller, but Babel
73
- * is configured to resolve the first argument of resolveWeak(..) function, thus
74
- * the result will be the resolved path.
75
- * @param {string} modulePath
76
- * @return {string} Absolute or relative path to the module.
77
- */
78
- export function resolveWeak(modulePath: string): string {
79
- return modulePath;
80
- }
@@ -1,52 +0,0 @@
1
- /* Eric Meyer's "Reset CSS" 2.0 */
2
-
3
- /* http://meyerweb.com/eric/tools/css/reset/
4
- v2.0 | 20110126
5
- License: none (public domain)
6
- */
7
-
8
- /* Having all selectors at individual lines is unreadable in the case of this
9
- * style reset sheet. */
10
- /* stylelint-disable selector-list-comma-newline-after */
11
- a, abbr, acronym, address, applet, article, aside, audio, b, big, blockquote,
12
- body, canvas, caption, center, cite, code, dd, del, details, dfn, div, dl, dt,
13
- em, embed, fieldset, figcaption, figure, footer, form, h1, h2, h3, h4, h5, h6,
14
- header, hgroup, html, i, iframe, img, ins, kbd, label, legend, li, mark, menu,
15
- nav, object, ol, output, p, pre, q, ruby, s, samp, section, small, span,
16
- strike, strong,sub, summary, sup, table, tbody, td, tfoot, th, thead, time, tr,
17
- tt, u, ul, var, video {
18
- margin: 0;
19
- padding: 0;
20
- border: 0;
21
- font: inherit;
22
- font-size: 100%;
23
- vertical-align: baseline;
24
- }
25
-
26
- /* HTML5 display-role reset for older browsers */
27
- article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav,
28
- section {
29
- display: block;
30
- }
31
-
32
- body {
33
- line-height: 1;
34
- }
35
-
36
- ol, ul {
37
- list-style: none;
38
- }
39
-
40
- blockquote, q {
41
- quotes: none;
42
- }
43
-
44
- blockquote::before, blockquote::after, q::before, q::after {
45
- content: "";
46
- content: none;
47
- }
48
-
49
- table {
50
- border-collapse: collapse;
51
- border-spacing: 0;
52
- }
@@ -1,40 +0,0 @@
1
- /* Auxiliary mixins for fonts inclusion. */
2
-
3
- /**
4
- * Includes a font, provided as a set of alternative files in EOT, WOFF, TTF,
5
- * SVG formats into the app.
6
- * $font-name {String}
7
- * $font-weight {Number}
8
- * $font-style {String}
9
- * $font-url {String} Path to the font file, without the filename itself.
10
- * $font-file {String} Font filename, without extension (should be the same for
11
- * each version of the font in different formats.
12
- */
13
- @mixin font-family($font-name, $font-weight, $font-style, $font-url, $font-file) {
14
- @font-face {
15
- font-family: "#{$font-name}";
16
- font-display: block;
17
- font-weight: $font-weight;
18
- font-style: $font-style;
19
- src: url("#{$font-url}#{$font-file}.eot");
20
- src: url("#{$font-url}#{$font-file}.eot?#iefix") format("embedded-opentype"), url("#{$font-url}#{$font-file}.woff") format("woff"), url("#{$font-url}#{$font-file}.ttf") format("truetype");
21
- }
22
- }
23
-
24
- /**
25
- * Includes a font, provided in the TTF format only.
26
- * $font-name {String}
27
- * $font-weight {Number}
28
- * $font-style {String}
29
- * $font-url {String}
30
- */
31
- @mixin font-family-ttf(
32
- $font-name, $font-weight, $font-style, $font-url) {
33
- @font-face {
34
- font-family: $font-name;
35
- font-display: block;
36
- font-style: $font-style;
37
- font-weight: $font-weight;
38
- src: url("#{$font-url}.ttf") format("truetype");
39
- }
40
- }
@@ -1,150 +0,0 @@
1
- /**
2
- * Mixins for different layout sizes: xs, sm, md, lg.
3
- * Breaking points are defined in _variables.scss
4
- * The range mixins A-to-B all means "for the sizes from A to B, both
5
- * inclusive", in particular it means that mixin A-to-lg is equivalent to
6
- * all sizes from A (inclusive) and larger.
7
- *
8
- * NOTE: For convenience, these mixins are sorted not alphabetically, but,
9
- * first, by increase of the first size; second, by increase of the second size.
10
- */
11
-
12
- /* Break points. */
13
-
14
- $screen-xs: 320px !default;
15
- $screen-sm: 495px !default;
16
- $screen-mm: 768px !default;
17
- $screen-md: 1024px !default;
18
- $screen-lg: 1280px !default;
19
-
20
- /* XS */
21
-
22
- @mixin xs {
23
- @media (max-width: #{$screen-xs}) {
24
- @content;
25
- }
26
- }
27
-
28
- @mixin xs-to-sm {
29
- @media (max-width: #{$screen-sm}) {
30
- @content;
31
- }
32
- }
33
-
34
- @mixin xs-to-mm {
35
- @media (max-width: #{$screen-mm}) {
36
- @content;
37
- }
38
- }
39
-
40
- @mixin xs-to-md {
41
- @media (max-width: #{$screen-md}) {
42
- @content;
43
- }
44
- }
45
-
46
- @mixin xs-to-lg {
47
- @media (max-width: #{$screen-lg}) {
48
- @content;
49
- }
50
- }
51
-
52
- /* SM */
53
-
54
- @mixin sm {
55
- @media (min-width: #{$screen-xs + 1px}) and (max-width: #{$screen-sm}) {
56
- @content;
57
- }
58
- }
59
-
60
- @mixin sm-to-mm {
61
- @media (min-width: #{$screen-xs + 1px}) and (max-width: #{$screen-mm}) {
62
- @content;
63
- }
64
- }
65
-
66
- @mixin sm-to-md {
67
- @media (min-width: #{$screen-xs + 1px}) and (max-width: #{$screen-md}) {
68
- @content;
69
- }
70
- }
71
-
72
- @mixin sm-to-lg {
73
- @media (min-width: #{$screen-xs + 1px}) and (max-width: #{$screen-lg}) {
74
- @content;
75
- }
76
- }
77
-
78
- @mixin sm-to-xl {
79
- @media (min-width: #{$screen-xs + 1px}) {
80
- @content;
81
- }
82
- }
83
-
84
- /* MM */
85
-
86
- @mixin mm {
87
- @media (min-width: #{$screen-sm + 1px}) and (max-width: #{$screen-mm}) {
88
- @content;
89
- }
90
- }
91
-
92
- @mixin mm-to-md {
93
- @media (min-width: #{$screen-sm + 1px}) and (max-width: #{$screen-md}) {
94
- @content;
95
- }
96
- }
97
-
98
- @mixin mm-to-lg {
99
- @media (min-width: #{$screen-sm + 1px}) and (max-width: #{$screen-lg}) {
100
- @content;
101
- }
102
- }
103
-
104
- @mixin mm-to-xl {
105
- @media (min-width: #{$screen-sm + 1px}) {
106
- @content;
107
- }
108
- }
109
-
110
- /* MD */
111
-
112
- @mixin md {
113
- @media (min-width: #{$screen-mm + 1px}) and (max-width: #{$screen-md}) {
114
- @content;
115
- }
116
- }
117
-
118
- @mixin md-to-lg {
119
- @media (min-width: #{$screen-mm + 1px}) and (max-width: #{$screen-lg}) {
120
- @content;
121
- }
122
- }
123
-
124
- @mixin md-to-xl {
125
- @media (min-width: #{$screen-mm + 1px}) {
126
- @content;
127
- }
128
- }
129
-
130
- /* LG */
131
-
132
- @mixin lg {
133
- @media (min-width: #{$screen-md + 1px}) and (max-width: #{$screen-lg}) {
134
- @content;
135
- }
136
- }
137
-
138
- @mixin lg-to-xl {
139
- @media (min-width: #{$screen-md + 1px}) {
140
- @content;
141
- }
142
- }
143
-
144
- /* XL */
145
-
146
- @mixin xl {
147
- @media (min-width: #{$screen-lg + 1px}) {
148
- @content;
149
- }
150
- }