@tramvai/module-render 1.89.1 → 1.90.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.
@@ -7,11 +7,13 @@ export interface ResourcesInlinerType {
7
7
  export declare class ResourcesInliner implements ResourcesInlinerType {
8
8
  private resourceInlineThreshold?;
9
9
  private resourcesRegistryCache;
10
+ private log;
10
11
  private scheduleFileLoad;
11
12
  private scheduleFileSizeLoad;
12
- constructor({ resourcesRegistryCache, resourceInlineThreshold }: {
13
+ constructor({ resourcesRegistryCache, resourceInlineThreshold, logger }: {
13
14
  resourcesRegistryCache: any;
14
15
  resourceInlineThreshold: any;
16
+ logger: any;
15
17
  });
16
18
  shouldAddResource(resource: PageResource): boolean;
17
19
  shouldInline(resource: PageResource): boolean;
package/lib/server.es.js CHANGED
@@ -94,7 +94,7 @@ const getResourceUrl = (resource) => {
94
94
  : resource.payload;
95
95
  };
96
96
  class ResourcesInliner {
97
- constructor({ resourcesRegistryCache, resourceInlineThreshold }) {
97
+ constructor({ resourcesRegistryCache, resourceInlineThreshold, logger }) {
98
98
  this.scheduleFileLoad = (resource, resourceInlineThreshold) => {
99
99
  const url = getResourceUrl(resource);
100
100
  const requestKey = `file${url}`;
@@ -116,6 +116,13 @@ class ResourcesInliner {
116
116
  this.resourcesRegistryCache.filesCache.set(url, processFile(resource, file));
117
117
  }
118
118
  this.resourcesRegistryCache.sizeCache.set(url, size);
119
+ })
120
+ .catch((error) => {
121
+ this.log.warn({
122
+ event: 'file-load-failed',
123
+ url,
124
+ error,
125
+ });
119
126
  })
120
127
  .finally(() => {
121
128
  this.resourcesRegistryCache.requestsCache.set(requestKey, undefined);
@@ -140,6 +147,13 @@ class ResourcesInliner {
140
147
  if (size < resourceInlineThreshold) {
141
148
  this.scheduleFileLoad(resource, resourceInlineThreshold);
142
149
  }
150
+ })
151
+ .catch((error) => {
152
+ this.log.warn({
153
+ event: 'file-content-length-load-failed',
154
+ url,
155
+ error,
156
+ });
143
157
  })
144
158
  .finally(() => {
145
159
  this.resourcesRegistryCache.requestsCache.set(requestKey, undefined);
@@ -149,6 +163,7 @@ class ResourcesInliner {
149
163
  };
150
164
  this.resourcesRegistryCache = resourcesRegistryCache;
151
165
  this.resourceInlineThreshold = resourceInlineThreshold;
166
+ this.log = logger('resources-inliner');
152
167
  }
153
168
  // Метод проверки, стоит ли добавлять preload-ресурс
154
169
  shouldAddResource(resource) {
@@ -770,6 +785,7 @@ RenderModule = RenderModule_1 = __decorate([
770
785
  deps: {
771
786
  resourcesRegistryCache: RESOURCES_REGISTRY_CACHE,
772
787
  resourceInlineThreshold: { token: RESOURCE_INLINE_OPTIONS, optional: true },
788
+ logger: LOGGER_TOKEN,
773
789
  },
774
790
  }),
775
791
  provide({
package/lib/server.js CHANGED
@@ -130,7 +130,7 @@ const getResourceUrl = (resource) => {
130
130
  : resource.payload;
131
131
  };
132
132
  class ResourcesInliner {
133
- constructor({ resourcesRegistryCache, resourceInlineThreshold }) {
133
+ constructor({ resourcesRegistryCache, resourceInlineThreshold, logger }) {
134
134
  this.scheduleFileLoad = (resource, resourceInlineThreshold) => {
135
135
  const url = getResourceUrl(resource);
136
136
  const requestKey = `file${url}`;
@@ -152,6 +152,13 @@ class ResourcesInliner {
152
152
  this.resourcesRegistryCache.filesCache.set(url, processFile(resource, file));
153
153
  }
154
154
  this.resourcesRegistryCache.sizeCache.set(url, size);
155
+ })
156
+ .catch((error) => {
157
+ this.log.warn({
158
+ event: 'file-load-failed',
159
+ url,
160
+ error,
161
+ });
155
162
  })
156
163
  .finally(() => {
157
164
  this.resourcesRegistryCache.requestsCache.set(requestKey, undefined);
@@ -176,6 +183,13 @@ class ResourcesInliner {
176
183
  if (size < resourceInlineThreshold) {
177
184
  this.scheduleFileLoad(resource, resourceInlineThreshold);
178
185
  }
186
+ })
187
+ .catch((error) => {
188
+ this.log.warn({
189
+ event: 'file-content-length-load-failed',
190
+ url,
191
+ error,
192
+ });
179
193
  })
180
194
  .finally(() => {
181
195
  this.resourcesRegistryCache.requestsCache.set(requestKey, undefined);
@@ -185,6 +199,7 @@ class ResourcesInliner {
185
199
  };
186
200
  this.resourcesRegistryCache = resourcesRegistryCache;
187
201
  this.resourceInlineThreshold = resourceInlineThreshold;
202
+ this.log = logger('resources-inliner');
188
203
  }
189
204
  // Метод проверки, стоит ли добавлять preload-ресурс
190
205
  shouldAddResource(resource) {
@@ -806,6 +821,7 @@ exports.RenderModule = RenderModule_1 = tslib.__decorate([
806
821
  deps: {
807
822
  resourcesRegistryCache: RESOURCES_REGISTRY_CACHE,
808
823
  resourceInlineThreshold: { token: tokensRender.RESOURCE_INLINE_OPTIONS, optional: true },
824
+ logger: moduleCommon.LOGGER_TOKEN,
809
825
  },
810
826
  }),
811
827
  core.provide({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tramvai/module-render",
3
- "version": "1.89.1",
3
+ "version": "1.90.1",
4
4
  "description": "",
5
5
  "browser": "lib/browser.js",
6
6
  "main": "lib/server.js",
@@ -24,13 +24,13 @@
24
24
  "@tinkoff/htmlpagebuilder": "0.4.22",
25
25
  "@tinkoff/layout-factory": "0.2.28",
26
26
  "@tinkoff/url": "0.7.37",
27
- "@tinkoff/user-agent": "0.3.300",
28
- "@tramvai/module-client-hints": "1.89.1",
29
- "@tramvai/module-router": "1.89.1",
30
- "@tramvai/react": "1.89.1",
27
+ "@tinkoff/user-agent": "0.3.302",
28
+ "@tramvai/module-client-hints": "1.90.1",
29
+ "@tramvai/module-router": "1.90.1",
30
+ "@tramvai/react": "1.90.1",
31
31
  "@tramvai/safe-strings": "0.4.3",
32
- "@tramvai/tokens-render": "1.89.1",
33
- "@tramvai/experiments": "1.89.1",
32
+ "@tramvai/tokens-render": "1.90.1",
33
+ "@tramvai/experiments": "1.90.1",
34
34
  "@types/loadable__server": "^5.12.6",
35
35
  "node-fetch": "^2.6.1"
36
36
  },
@@ -38,14 +38,14 @@
38
38
  "@tinkoff/dippy": "0.7.39",
39
39
  "@tinkoff/utils": "^2.1.2",
40
40
  "@tinkoff/react-hooks": "0.0.24",
41
- "@tramvai/cli": "1.89.1",
42
- "@tramvai/core": "1.89.1",
43
- "@tramvai/module-common": "1.89.1",
44
- "@tramvai/state": "1.89.1",
45
- "@tramvai/test-helpers": "1.89.1",
46
- "@tramvai/tokens-common": "1.89.1",
47
- "@tramvai/tokens-router": "1.89.1",
48
- "@tramvai/tokens-server-private": "1.89.1",
41
+ "@tramvai/cli": "1.90.1",
42
+ "@tramvai/core": "1.90.1",
43
+ "@tramvai/module-common": "1.90.1",
44
+ "@tramvai/state": "1.90.1",
45
+ "@tramvai/test-helpers": "1.90.1",
46
+ "@tramvai/tokens-common": "1.90.1",
47
+ "@tramvai/tokens-router": "1.90.1",
48
+ "@tramvai/tokens-server-private": "1.90.1",
49
49
  "express": "^4.17.1",
50
50
  "prop-types": "^15.6.2",
51
51
  "react": ">=16.8.0",