@tramvai/module-client-hints 2.149.1 → 2.150.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -0
- package/lib/browser/loadUserAgent.d.ts +1 -0
- package/lib/browser/matchMedia.d.ts +1 -0
- package/lib/browser.d.ts +2 -1
- package/lib/modules/child-app/module.d.ts +1 -0
- package/lib/modules/csr/browser.d.ts +2 -1
- package/lib/modules/csr/server.d.ts +2 -1
- package/lib/server/parseUserAgentWithCache.d.ts +1 -0
- package/lib/server/readMedia.d.ts +1 -0
- package/lib/server/userAgent.d.ts +1 -0
- package/lib/server/userAgent.es.js +4 -19
- package/lib/server/userAgent.js +3 -18
- package/lib/server.d.ts +2 -1
- package/lib/shared/constants.d.ts +1 -0
- package/lib/shared/mediaBreakpoints.d.ts +1 -0
- package/lib/shared/providers.browser.d.ts +1 -0
- package/lib/shared/providers.d.ts +1 -0
- package/lib/shared/providers.server.d.ts +1 -0
- package/lib/shared/stores/media.d.ts +2 -1
- package/lib/shared/stores/mediaCheckers.d.ts +1 -0
- package/lib/shared/stores/mediaSelectors.d.ts +1 -0
- package/lib/shared/stores/userAgent.d.ts +2 -1
- package/lib/tokens.d.ts +1 -0
- package/lib/types.d.ts +1 -0
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -214,3 +214,15 @@ const App = () => {
|
|
|
214
214
|
### USER_AGENT_TOKEN
|
|
215
215
|
|
|
216
216
|
Object as a result of parsing user-agent string with [@tinkoff/user-agent](../libs/user-agent.md). Parsing happens only on server-side and parsed info is reused on client-side.
|
|
217
|
+
|
|
218
|
+
## Env variables
|
|
219
|
+
|
|
220
|
+
### TRAMVAI_USER_AGENT_CACHE_MAX
|
|
221
|
+
|
|
222
|
+
Size of User-Agent header parsing cache (in-memory LRU cache), default value is `200`.
|
|
223
|
+
|
|
224
|
+
You can increase it for better cache hit rate and server performance.
|
|
225
|
+
|
|
226
|
+
## Metrics
|
|
227
|
+
|
|
228
|
+
- `user_agent_cache_gets` counter - User-Agent header parsing count, with labels `hit` and `miss`
|
package/lib/browser.d.ts
CHANGED
|
@@ -6,5 +6,6 @@ export * from './shared/stores/userAgent';
|
|
|
6
6
|
export { ClientHintsChildAppModule } from './modules/child-app/module';
|
|
7
7
|
export { ClientHintsCSRModule } from './modules/csr/browser';
|
|
8
8
|
export declare const ClientHintsModule: import("@tinkoff/dippy/lib/modules/module.h").ModuleClass & Partial<import("@tinkoff/dippy/lib/modules/module.h").ModuleSecretParameters> & {
|
|
9
|
-
[x: string]: (...args: any[]) => import("@tramvai/core").ModuleType
|
|
9
|
+
[x: string]: (...args: any[]) => import("@tramvai/core").ModuleType;
|
|
10
10
|
};
|
|
11
|
+
//# sourceMappingURL=browser.d.ts.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export declare const ClientHintsCSRModule: import("@tinkoff/dippy/lib/modules/module.h").ModuleClass & Partial<import("@tinkoff/dippy/lib/modules/module.h").ModuleSecretParameters> & {
|
|
2
|
-
[x: string]: (...args: any[]) => import("@tinkoff/dippy").ModuleType
|
|
2
|
+
[x: string]: (...args: any[]) => import("@tinkoff/dippy").ModuleType;
|
|
3
3
|
};
|
|
4
|
+
//# sourceMappingURL=browser.d.ts.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export declare const ClientHintsCSRModule: import("@tinkoff/dippy/lib/modules/module.h").ModuleClass & Partial<import("@tinkoff/dippy/lib/modules/module.h").ModuleSecretParameters> & {
|
|
2
|
-
[x: string]: (...args: any[]) => import("@tinkoff/dippy").ModuleType
|
|
2
|
+
[x: string]: (...args: any[]) => import("@tinkoff/dippy").ModuleType;
|
|
3
3
|
};
|
|
4
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { provide, Scope, commandLineListTokens } from '@tramvai/core';
|
|
2
|
-
import {
|
|
2
|
+
import { ENV_USED_TOKEN, CREATE_CACHE_TOKEN, ENV_MANAGER_TOKEN, RESPONSE_MANAGER_TOKEN, REQUEST_MANAGER_TOKEN, STORE_TOKEN } from '@tramvai/tokens-common';
|
|
3
3
|
import { METRICS_MODULE_TOKEN } from '@tramvai/module-metrics';
|
|
4
4
|
import { parseClientHints } from '@tinkoff/user-agent';
|
|
5
5
|
import noop from '@tinkoff/utils/function/noop';
|
|
@@ -9,26 +9,12 @@ import { setUserAgent } from '../shared/stores/userAgent.es.js';
|
|
|
9
9
|
import { parseUserAgentWithCache } from './parseUserAgentWithCache.es.js';
|
|
10
10
|
|
|
11
11
|
const serverUserAgentProviders = [
|
|
12
|
-
provide({
|
|
13
|
-
provide: 'userAgentCacheType',
|
|
14
|
-
useFactory: ({ envManager }) => envManager.get('TRAMVAI_USER_AGENT_CACHE_TYPE'),
|
|
15
|
-
deps: {
|
|
16
|
-
envManager: ENV_MANAGER_TOKEN,
|
|
17
|
-
},
|
|
18
|
-
}),
|
|
19
12
|
provide({
|
|
20
13
|
provide: ENV_USED_TOKEN,
|
|
21
14
|
useValue: [
|
|
22
|
-
{
|
|
23
|
-
key: 'TRAMVAI_USER_AGENT_CACHE_TYPE',
|
|
24
|
-
value: 'memory',
|
|
25
|
-
optional: true,
|
|
26
|
-
validator: (value) => value === 'memory' || value === 'memory-lfu',
|
|
27
|
-
dehydrate: false,
|
|
28
|
-
},
|
|
29
15
|
{
|
|
30
16
|
key: 'TRAMVAI_USER_AGENT_CACHE_MAX',
|
|
31
|
-
value: '
|
|
17
|
+
value: '200',
|
|
32
18
|
optional: true,
|
|
33
19
|
validator: isNumber,
|
|
34
20
|
dehydrate: false,
|
|
@@ -38,15 +24,14 @@ const serverUserAgentProviders = [
|
|
|
38
24
|
provide({
|
|
39
25
|
provide: 'userAgentMemoryCache',
|
|
40
26
|
scope: Scope.SINGLETON,
|
|
41
|
-
useFactory: ({ createCache, envManager
|
|
42
|
-
return createCache(
|
|
27
|
+
useFactory: ({ createCache, envManager }) => {
|
|
28
|
+
return createCache('memory', {
|
|
43
29
|
max: Number(envManager.get('TRAMVAI_USER_AGENT_CACHE_MAX')),
|
|
44
30
|
});
|
|
45
31
|
},
|
|
46
32
|
deps: {
|
|
47
33
|
createCache: CREATE_CACHE_TOKEN,
|
|
48
34
|
envManager: ENV_MANAGER_TOKEN,
|
|
49
|
-
cacheType: 'userAgentCacheType',
|
|
50
35
|
},
|
|
51
36
|
}),
|
|
52
37
|
provide({
|
package/lib/server/userAgent.js
CHANGED
|
@@ -17,26 +17,12 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
17
17
|
var noop__default = /*#__PURE__*/_interopDefaultLegacy(noop);
|
|
18
18
|
|
|
19
19
|
const serverUserAgentProviders = [
|
|
20
|
-
core.provide({
|
|
21
|
-
provide: 'userAgentCacheType',
|
|
22
|
-
useFactory: ({ envManager }) => envManager.get('TRAMVAI_USER_AGENT_CACHE_TYPE'),
|
|
23
|
-
deps: {
|
|
24
|
-
envManager: tokensCommon.ENV_MANAGER_TOKEN,
|
|
25
|
-
},
|
|
26
|
-
}),
|
|
27
20
|
core.provide({
|
|
28
21
|
provide: tokensCommon.ENV_USED_TOKEN,
|
|
29
22
|
useValue: [
|
|
30
|
-
{
|
|
31
|
-
key: 'TRAMVAI_USER_AGENT_CACHE_TYPE',
|
|
32
|
-
value: 'memory',
|
|
33
|
-
optional: true,
|
|
34
|
-
validator: (value) => value === 'memory' || value === 'memory-lfu',
|
|
35
|
-
dehydrate: false,
|
|
36
|
-
},
|
|
37
23
|
{
|
|
38
24
|
key: 'TRAMVAI_USER_AGENT_CACHE_MAX',
|
|
39
|
-
value: '
|
|
25
|
+
value: '200',
|
|
40
26
|
optional: true,
|
|
41
27
|
validator: envValidators.isNumber,
|
|
42
28
|
dehydrate: false,
|
|
@@ -46,15 +32,14 @@ const serverUserAgentProviders = [
|
|
|
46
32
|
core.provide({
|
|
47
33
|
provide: 'userAgentMemoryCache',
|
|
48
34
|
scope: core.Scope.SINGLETON,
|
|
49
|
-
useFactory: ({ createCache, envManager
|
|
50
|
-
return createCache(
|
|
35
|
+
useFactory: ({ createCache, envManager }) => {
|
|
36
|
+
return createCache('memory', {
|
|
51
37
|
max: Number(envManager.get('TRAMVAI_USER_AGENT_CACHE_MAX')),
|
|
52
38
|
});
|
|
53
39
|
},
|
|
54
40
|
deps: {
|
|
55
41
|
createCache: tokensCommon.CREATE_CACHE_TOKEN,
|
|
56
42
|
envManager: tokensCommon.ENV_MANAGER_TOKEN,
|
|
57
|
-
cacheType: 'userAgentCacheType',
|
|
58
43
|
},
|
|
59
44
|
}),
|
|
60
45
|
core.provide({
|
package/lib/server.d.ts
CHANGED
|
@@ -6,5 +6,6 @@ export * from './shared/stores/userAgent';
|
|
|
6
6
|
export { ClientHintsChildAppModule } from './modules/child-app/module';
|
|
7
7
|
export { ClientHintsCSRModule } from './modules/csr/server';
|
|
8
8
|
export declare const ClientHintsModule: import("@tinkoff/dippy/lib/modules/module.h").ModuleClass & Partial<import("@tinkoff/dippy/lib/modules/module.h").ModuleSecretParameters> & {
|
|
9
|
-
[x: string]: (...args: any[]) => import("@tramvai/core").ModuleType
|
|
9
|
+
[x: string]: (...args: any[]) => import("@tramvai/core").ModuleType;
|
|
10
10
|
};
|
|
11
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -3,5 +3,6 @@ export interface Media extends MediaInfo {
|
|
|
3
3
|
supposed?: boolean;
|
|
4
4
|
synchronized?: boolean;
|
|
5
5
|
}
|
|
6
|
-
export declare const setMedia: import("@tramvai/types-actions-state-context").EventCreator1<Media
|
|
6
|
+
export declare const setMedia: import("@tramvai/types-actions-state-context").EventCreator1<Media>;
|
|
7
7
|
export declare const MediaStore: import("@tramvai/state").Reducer<Media, "media", never>;
|
|
8
|
+
//# sourceMappingURL=media.d.ts.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { UserAgent } from '@tinkoff/user-agent';
|
|
2
|
-
export declare const setUserAgent: import("@tramvai/types-actions-state-context").EventCreator1<UserAgent
|
|
2
|
+
export declare const setUserAgent: import("@tramvai/types-actions-state-context").EventCreator1<UserAgent>;
|
|
3
3
|
export declare const UserAgentStore: import("@tramvai/state").Reducer<UserAgent, "userAgent", never>;
|
|
4
|
+
//# sourceMappingURL=userAgent.d.ts.map
|
package/lib/tokens.d.ts
CHANGED
package/lib/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/module-client-hints",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.150.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/server.js",
|
|
6
6
|
"module": "lib/server.es.js",
|
|
@@ -19,21 +19,21 @@
|
|
|
19
19
|
"watch": "tsc -w"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@tinkoff/user-agent": "0.4.
|
|
22
|
+
"@tinkoff/user-agent": "0.4.435",
|
|
23
23
|
"@tinkoff/utils": "^2.1.2",
|
|
24
24
|
"@tinkoff/env-validators": "0.1.6",
|
|
25
25
|
"@tramvai/safe-strings": "0.5.12",
|
|
26
|
-
"@tramvai/module-metrics": "2.
|
|
27
|
-
"@tramvai/tokens-child-app": "2.
|
|
28
|
-
"@tramvai/tokens-common": "2.
|
|
29
|
-
"@tramvai/tokens-cookie": "2.
|
|
26
|
+
"@tramvai/module-metrics": "2.150.1",
|
|
27
|
+
"@tramvai/tokens-child-app": "2.150.1",
|
|
28
|
+
"@tramvai/tokens-common": "2.150.1",
|
|
29
|
+
"@tramvai/tokens-cookie": "2.150.1",
|
|
30
30
|
"user-agent-data-types": "^0.3.1"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"@tinkoff/dippy": "0.8.16",
|
|
34
34
|
"@tinkoff/logger": "0.10.67",
|
|
35
|
-
"@tramvai/core": "2.
|
|
36
|
-
"@tramvai/state": "2.
|
|
35
|
+
"@tramvai/core": "2.150.1",
|
|
36
|
+
"@tramvai/state": "2.150.1",
|
|
37
37
|
"react": ">=16.14.0",
|
|
38
38
|
"react-dom": ">=16.14.0",
|
|
39
39
|
"tslib": "^2.4.0"
|