@tramvai/module-render 5.22.0 → 5.40.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.
@@ -1,2 +1,3 @@
1
- export declare function onload(next: any): () => void;
1
+ import type { JsPreloadResource } from './types';
2
+ export declare function onload(next: JsPreloadResource[]): () => void;
2
3
  //# sourceMappingURL=onload.inline.d.ts.map
@@ -6,8 +6,11 @@ function onload(next) {
6
6
  const { head } = document;
7
7
  next.forEach((entry) => {
8
8
  const link = document.createElement('link');
9
+ if (entry.integrity) {
10
+ link.integrity = entry.integrity;
11
+ }
9
12
  link.rel = 'preload';
10
- link.href = entry;
13
+ link.href = entry.url;
11
14
  link.as = 'script';
12
15
  link.charset = 'utf-8';
13
16
  link.crossOrigin = 'anonymous';
@@ -10,8 +10,11 @@ function onload(next) {
10
10
  const { head } = document;
11
11
  next.forEach((entry) => {
12
12
  const link = document.createElement('link');
13
+ if (entry.integrity) {
14
+ link.integrity = entry.integrity;
15
+ }
13
16
  link.rel = 'preload';
14
- link.href = entry;
17
+ link.href = entry.url;
15
18
  link.as = 'script';
16
19
  link.charset = 'utf-8';
17
20
  link.crossOrigin = 'anonymous';
@@ -5,16 +5,19 @@ import { PRELOAD_JS } from '../../constants/performance.es.js';
5
5
  import { onload } from './onload.inline.es.js';
6
6
 
7
7
  const addPreloadForCriticalJS = (pageResources) => {
8
- const jsUrls = [];
8
+ const jsResources = [];
9
9
  each((res) => {
10
10
  if (res.type === 'script' && path(['attrs', 'data-critical'], res)) {
11
- jsUrls.push(res.payload);
11
+ jsResources.push({
12
+ url: res.payload,
13
+ integrity: res.attrs.integrity,
14
+ });
12
15
  }
13
16
  }, pageResources);
14
17
  return {
15
18
  type: ResourceType.inlineScript,
16
19
  slot: ResourceSlot.HEAD_PERFORMANCE,
17
- payload: `window.${PRELOAD_JS}=(${onload})([${jsUrls.map((url) => `"${url}"`).join(',')}])`,
20
+ payload: `window.${PRELOAD_JS}=(${onload})(${JSON.stringify(jsResources)})`,
18
21
  };
19
22
  };
20
23
 
@@ -14,16 +14,19 @@ var each__default = /*#__PURE__*/_interopDefaultLegacy(each);
14
14
  var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
15
15
 
16
16
  const addPreloadForCriticalJS = (pageResources) => {
17
- const jsUrls = [];
17
+ const jsResources = [];
18
18
  each__default["default"]((res) => {
19
19
  if (res.type === 'script' && path__default["default"](['attrs', 'data-critical'], res)) {
20
- jsUrls.push(res.payload);
20
+ jsResources.push({
21
+ url: res.payload,
22
+ integrity: res.attrs.integrity,
23
+ });
21
24
  }
22
25
  }, pageResources);
23
26
  return {
24
27
  type: tokensRender.ResourceType.inlineScript,
25
28
  slot: tokensRender.ResourceSlot.HEAD_PERFORMANCE,
26
- payload: `window.${performance.PRELOAD_JS}=(${onload_inline.onload})([${jsUrls.map((url) => `"${url}"`).join(',')}])`,
29
+ payload: `window.${performance.PRELOAD_JS}=(${onload_inline.onload})(${JSON.stringify(jsResources)})`,
27
30
  };
28
31
  };
29
32
 
@@ -0,0 +1,5 @@
1
+ export type JsPreloadResource = {
2
+ url: string;
3
+ integrity?: string;
4
+ };
5
+ //# sourceMappingURL=types.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tramvai/module-render",
3
- "version": "5.22.0",
3
+ "version": "5.40.0",
4
4
  "description": "",
5
5
  "browser": "lib/browser.js",
6
6
  "main": "lib/server.js",
@@ -26,15 +26,15 @@
26
26
  "@tinkoff/layout-factory": "0.6.2",
27
27
  "@tinkoff/errors": "0.6.2",
28
28
  "@tinkoff/url": "0.11.2",
29
- "@tinkoff/user-agent": "0.7.65",
29
+ "@tinkoff/user-agent": "0.7.96",
30
30
  "@tinkoff/request-core": "^0.10.0",
31
31
  "@tinkoff/request-plugin-protocol-http": "^0.12.1",
32
- "@tramvai/module-client-hints": "5.22.0",
33
- "@tramvai/module-router": "5.22.0",
34
- "@tramvai/react": "5.22.0",
32
+ "@tramvai/module-client-hints": "5.40.0",
33
+ "@tramvai/module-router": "5.40.0",
34
+ "@tramvai/react": "5.40.0",
35
35
  "@tramvai/safe-strings": "0.8.4",
36
- "@tramvai/tokens-render": "5.22.0",
37
- "@tramvai/experiments": "5.22.0",
36
+ "@tramvai/tokens-render": "5.40.0",
37
+ "@tramvai/experiments": "5.40.0",
38
38
  "@types/loadable__server": "^5.12.6",
39
39
  "node-fetch": "^2.6.1"
40
40
  },
@@ -42,14 +42,14 @@
42
42
  "@tinkoff/dippy": "0.11.3",
43
43
  "@tinkoff/utils": "^2.1.2",
44
44
  "@tinkoff/react-hooks": "0.4.2",
45
- "@tramvai/cli": "5.22.0",
46
- "@tramvai/core": "5.22.0",
47
- "@tramvai/module-common": "5.22.0",
48
- "@tramvai/state": "5.22.0",
49
- "@tramvai/test-helpers": "5.22.0",
50
- "@tramvai/tokens-common": "5.22.0",
51
- "@tramvai/tokens-router": "5.22.0",
52
- "@tramvai/tokens-server-private": "5.22.0",
45
+ "@tramvai/cli": "5.40.0",
46
+ "@tramvai/core": "5.40.0",
47
+ "@tramvai/module-common": "5.40.0",
48
+ "@tramvai/state": "5.40.0",
49
+ "@tramvai/test-helpers": "5.40.0",
50
+ "@tramvai/tokens-common": "5.40.0",
51
+ "@tramvai/tokens-router": "5.40.0",
52
+ "@tramvai/tokens-server-private": "5.40.0",
53
53
  "express": "^4.17.1",
54
54
  "prop-types": "^15.6.2",
55
55
  "react": ">=16.14.0",