@tramvai/module-render 2.106.4 → 2.108.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.
- package/lib/resourcesInliner/resourcesInliner.d.ts +2 -0
- package/lib/resourcesInliner/resourcesInliner.es.js +9 -2
- package/lib/resourcesInliner/resourcesInliner.js +9 -2
- package/lib/resourcesRegistry/index.es.js +3 -1
- package/lib/resourcesRegistry/index.js +3 -1
- package/package.json +15 -15
- package/tests.js +6 -1
|
@@ -2,6 +2,7 @@ import type { PageResource } from '@tramvai/tokens-render';
|
|
|
2
2
|
export interface ResourcesInlinerType {
|
|
3
3
|
shouldAddResource(resource: PageResource): boolean;
|
|
4
4
|
shouldInline(resource: PageResource): boolean;
|
|
5
|
+
canInline(resource: PageResource): boolean;
|
|
5
6
|
inlineResource(resource: PageResource): PageResource[];
|
|
6
7
|
prefetchResource(resource: PageResource): Promise<void>;
|
|
7
8
|
}
|
|
@@ -21,6 +22,7 @@ export declare class ResourcesInliner implements ResourcesInlinerType {
|
|
|
21
22
|
private getFilesCache;
|
|
22
23
|
shouldAddResource(resource: PageResource): boolean;
|
|
23
24
|
shouldInline(resource: PageResource): boolean;
|
|
25
|
+
canInline(resource: PageResource): boolean;
|
|
24
26
|
inlineResource(resource: PageResource): PageResource[];
|
|
25
27
|
prefetchResource(resource: PageResource): Promise<void>;
|
|
26
28
|
}
|
|
@@ -138,8 +138,7 @@ class ResourcesInliner {
|
|
|
138
138
|
}
|
|
139
139
|
// method for check is passed resource should be inlined in HTML-page
|
|
140
140
|
shouldInline(resource) {
|
|
141
|
-
|
|
142
|
-
if (!(((_a = this.resourceInlineThreshold) === null || _a === void 0 ? void 0 : _a.types) || []).includes(resource.type)) {
|
|
141
|
+
if (!this.canInline(resource)) {
|
|
143
142
|
return false;
|
|
144
143
|
}
|
|
145
144
|
const resourceInlineThreshold = this.resourceInlineThreshold.threshold;
|
|
@@ -170,6 +169,14 @@ class ResourcesInliner {
|
|
|
170
169
|
this.scheduleFileLoad(resource, resourceInlineThreshold);
|
|
171
170
|
return false;
|
|
172
171
|
}
|
|
172
|
+
// method for filtering resources that can be inlined in HTML-page
|
|
173
|
+
canInline(resource) {
|
|
174
|
+
var _a;
|
|
175
|
+
if (!(((_a = this.resourceInlineThreshold) === null || _a === void 0 ? void 0 : _a.types) || []).includes(resource.type)) {
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
return true;
|
|
179
|
+
}
|
|
173
180
|
inlineResource(resource) {
|
|
174
181
|
const url = getResourceUrl(resource);
|
|
175
182
|
if (isUndefined(url)) {
|
|
@@ -147,8 +147,7 @@ class ResourcesInliner {
|
|
|
147
147
|
}
|
|
148
148
|
// method for check is passed resource should be inlined in HTML-page
|
|
149
149
|
shouldInline(resource) {
|
|
150
|
-
|
|
151
|
-
if (!(((_a = this.resourceInlineThreshold) === null || _a === void 0 ? void 0 : _a.types) || []).includes(resource.type)) {
|
|
150
|
+
if (!this.canInline(resource)) {
|
|
152
151
|
return false;
|
|
153
152
|
}
|
|
154
153
|
const resourceInlineThreshold = this.resourceInlineThreshold.threshold;
|
|
@@ -179,6 +178,14 @@ class ResourcesInliner {
|
|
|
179
178
|
this.scheduleFileLoad(resource, resourceInlineThreshold);
|
|
180
179
|
return false;
|
|
181
180
|
}
|
|
181
|
+
// method for filtering resources that can be inlined in HTML-page
|
|
182
|
+
canInline(resource) {
|
|
183
|
+
var _a;
|
|
184
|
+
if (!(((_a = this.resourceInlineThreshold) === null || _a === void 0 ? void 0 : _a.types) || []).includes(resource.type)) {
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
182
189
|
inlineResource(resource) {
|
|
183
190
|
const url = getResourceUrl(resource);
|
|
184
191
|
if (isUndefined__default["default"](url)) {
|
|
@@ -24,7 +24,9 @@ class ResourcesRegistry {
|
|
|
24
24
|
.filter((resource) => this.resourceInliner.shouldAddResource(resource));
|
|
25
25
|
}
|
|
26
26
|
prefetchInlinePageResources() {
|
|
27
|
-
const promises = Array.from(this.resources.values())
|
|
27
|
+
const promises = Array.from(this.resources.values())
|
|
28
|
+
.filter((resource) => this.resourceInliner.canInline(resource))
|
|
29
|
+
.map((resource) => {
|
|
28
30
|
return this.resourceInliner.prefetchResource(resource);
|
|
29
31
|
});
|
|
30
32
|
return Promise.all(promises);
|
|
@@ -32,7 +32,9 @@ class ResourcesRegistry {
|
|
|
32
32
|
.filter((resource) => this.resourceInliner.shouldAddResource(resource));
|
|
33
33
|
}
|
|
34
34
|
prefetchInlinePageResources() {
|
|
35
|
-
const promises = Array.from(this.resources.values())
|
|
35
|
+
const promises = Array.from(this.resources.values())
|
|
36
|
+
.filter((resource) => this.resourceInliner.canInline(resource))
|
|
37
|
+
.map((resource) => {
|
|
36
38
|
return this.resourceInliner.prefetchResource(resource);
|
|
37
39
|
});
|
|
38
40
|
return Promise.all(promises);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/module-render",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.108.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"browser": "lib/browser.js",
|
|
6
6
|
"main": "lib/server.js",
|
|
@@ -26,13 +26,13 @@
|
|
|
26
26
|
"@tinkoff/layout-factory": "0.3.8",
|
|
27
27
|
"@tinkoff/errors": "0.3.8",
|
|
28
28
|
"@tinkoff/url": "0.8.6",
|
|
29
|
-
"@tinkoff/user-agent": "0.4.
|
|
30
|
-
"@tramvai/module-client-hints": "2.
|
|
31
|
-
"@tramvai/module-router": "2.
|
|
32
|
-
"@tramvai/react": "2.
|
|
29
|
+
"@tinkoff/user-agent": "0.4.307",
|
|
30
|
+
"@tramvai/module-client-hints": "2.108.0",
|
|
31
|
+
"@tramvai/module-router": "2.108.0",
|
|
32
|
+
"@tramvai/react": "2.108.0",
|
|
33
33
|
"@tramvai/safe-strings": "0.5.9",
|
|
34
|
-
"@tramvai/tokens-render": "2.
|
|
35
|
-
"@tramvai/experiments": "2.
|
|
34
|
+
"@tramvai/tokens-render": "2.108.0",
|
|
35
|
+
"@tramvai/experiments": "2.108.0",
|
|
36
36
|
"@types/loadable__server": "^5.12.6",
|
|
37
37
|
"node-fetch": "^2.6.1"
|
|
38
38
|
},
|
|
@@ -40,14 +40,14 @@
|
|
|
40
40
|
"@tinkoff/dippy": "0.8.15",
|
|
41
41
|
"@tinkoff/utils": "^2.1.2",
|
|
42
42
|
"@tinkoff/react-hooks": "0.1.6",
|
|
43
|
-
"@tramvai/cli": "2.
|
|
44
|
-
"@tramvai/core": "2.
|
|
45
|
-
"@tramvai/module-common": "2.
|
|
46
|
-
"@tramvai/state": "2.
|
|
47
|
-
"@tramvai/test-helpers": "2.
|
|
48
|
-
"@tramvai/tokens-common": "2.
|
|
49
|
-
"@tramvai/tokens-router": "2.
|
|
50
|
-
"@tramvai/tokens-server-private": "2.
|
|
43
|
+
"@tramvai/cli": "2.108.0",
|
|
44
|
+
"@tramvai/core": "2.108.0",
|
|
45
|
+
"@tramvai/module-common": "2.108.0",
|
|
46
|
+
"@tramvai/state": "2.108.0",
|
|
47
|
+
"@tramvai/test-helpers": "2.108.0",
|
|
48
|
+
"@tramvai/tokens-common": "2.108.0",
|
|
49
|
+
"@tramvai/tokens-router": "2.108.0",
|
|
50
|
+
"@tramvai/tokens-server-private": "2.108.0",
|
|
51
51
|
"express": "^4.17.1",
|
|
52
52
|
"prop-types": "^15.6.2",
|
|
53
53
|
"react": ">=16.14.0",
|
package/tests.js
CHANGED
|
@@ -52,7 +52,9 @@ class ResourcesRegistry {
|
|
|
52
52
|
.filter((resource) => this.resourceInliner.shouldAddResource(resource));
|
|
53
53
|
}
|
|
54
54
|
prefetchInlinePageResources() {
|
|
55
|
-
const promises = Array.from(this.resources.values())
|
|
55
|
+
const promises = Array.from(this.resources.values())
|
|
56
|
+
.filter((resource) => this.resourceInliner.canInline(resource))
|
|
57
|
+
.map((resource) => {
|
|
56
58
|
return this.resourceInliner.prefetchResource(resource);
|
|
57
59
|
});
|
|
58
60
|
return Promise.all(promises);
|
|
@@ -172,6 +174,9 @@ const testPageResources = (options) => {
|
|
|
172
174
|
shouldInline() {
|
|
173
175
|
return false;
|
|
174
176
|
},
|
|
177
|
+
canInline() {
|
|
178
|
+
return false;
|
|
179
|
+
},
|
|
175
180
|
shouldAddResource() {
|
|
176
181
|
return true;
|
|
177
182
|
},
|