@tramvai/module-client-hints 3.37.5 → 3.37.8
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.
|
@@ -3,6 +3,7 @@ import { setMedia } from '../shared/stores/media.browser.js';
|
|
|
3
3
|
import { COOKIE_NAME_MEDIA_INFO } from '../shared/constants.browser.js';
|
|
4
4
|
import { mediaBreakpoints } from '../shared/mediaBreakpoints.browser.js';
|
|
5
5
|
import { getDisplayMode } from './getDisplayMode.browser.js';
|
|
6
|
+
import { requestIdleCallback } from './requestIdleCallback.browser.js';
|
|
6
7
|
|
|
7
8
|
const isTouch = !!('ontouchstart' in window ||
|
|
8
9
|
(window.DocumentTouch && document instanceof window.DocumentTouch));
|
|
@@ -22,10 +23,13 @@ const matchMediaCommand = ({ context, cookieManager, }) => {
|
|
|
22
23
|
name: COOKIE_NAME_MEDIA_INFO,
|
|
23
24
|
value: JSON.stringify(media),
|
|
24
25
|
});
|
|
25
|
-
|
|
26
|
+
// TCORE-4601 - React hydration error (421) caused when media store updated before hydration is finished,
|
|
27
|
+
// in cases when media store passed to components inside Suspense boundaries.
|
|
28
|
+
// Recipe from https://github.com/reactwg/react-18/discussions/5
|
|
29
|
+
return requestIdleCallback(() => context.dispatch(setMedia({
|
|
26
30
|
...media,
|
|
27
31
|
supposed: false,
|
|
28
|
-
}));
|
|
32
|
+
})));
|
|
29
33
|
};
|
|
30
34
|
const debouncedSetMediaInfo = debounce(300, setMediaInfo);
|
|
31
35
|
window.addEventListener('orientationchange', debouncedSetMediaInfo);
|
|
@@ -8,5 +8,5 @@ declare global {
|
|
|
8
8
|
export declare const matchMediaCommand: ({ context, cookieManager, }: {
|
|
9
9
|
context: typeof CONTEXT_TOKEN;
|
|
10
10
|
cookieManager: typeof COOKIE_MANAGER_TOKEN;
|
|
11
|
-
}) => () =>
|
|
11
|
+
}) => () => number;
|
|
12
12
|
//# sourceMappingURL=matchMedia.d.ts.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const requestIdleCallback: ((callback: IdleRequestCallback, options?: IdleRequestOptions | undefined) => number) & typeof globalThis.requestIdleCallback;
|
|
2
|
+
export declare const cancelIdleCallback: ((handle: number) => void) & typeof globalThis.cancelIdleCallback;
|
|
3
|
+
//# sourceMappingURL=requestIdleCallback.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/module-client-hints",
|
|
3
|
-
"version": "3.37.
|
|
3
|
+
"version": "3.37.8",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/server.js",
|
|
6
6
|
"module": "lib/server.es.js",
|
|
@@ -19,22 +19,22 @@
|
|
|
19
19
|
"watch": "tsc -w"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@tinkoff/user-agent": "0.5.
|
|
22
|
+
"@tinkoff/user-agent": "0.5.100",
|
|
23
23
|
"@tinkoff/utils": "^2.1.2",
|
|
24
24
|
"@tinkoff/env-validators": "0.2.1",
|
|
25
25
|
"@tramvai/safe-strings": "0.6.2",
|
|
26
|
-
"@tramvai/module-metrics": "3.37.
|
|
27
|
-
"@tramvai/tokens-child-app": "3.37.
|
|
28
|
-
"@tramvai/tokens-common": "3.37.
|
|
29
|
-
"@tramvai/tokens-cookie": "3.37.
|
|
30
|
-
"@tramvai/tokens-render": "3.37.
|
|
26
|
+
"@tramvai/module-metrics": "3.37.8",
|
|
27
|
+
"@tramvai/tokens-child-app": "3.37.8",
|
|
28
|
+
"@tramvai/tokens-common": "3.37.8",
|
|
29
|
+
"@tramvai/tokens-cookie": "3.37.8",
|
|
30
|
+
"@tramvai/tokens-render": "3.37.8",
|
|
31
31
|
"user-agent-data-types": "^0.3.1"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"@tinkoff/dippy": "0.9.2",
|
|
35
35
|
"@tinkoff/logger": "0.10.170",
|
|
36
|
-
"@tramvai/core": "3.37.
|
|
37
|
-
"@tramvai/state": "3.37.
|
|
36
|
+
"@tramvai/core": "3.37.8",
|
|
37
|
+
"@tramvai/state": "3.37.8",
|
|
38
38
|
"react": ">=16.14.0",
|
|
39
39
|
"react-dom": ">=16.14.0",
|
|
40
40
|
"tslib": "^2.4.0"
|