@tramvai/module-render 5.9.2 → 5.14.9
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/browser.js +1 -1
- package/lib/client/index.browser.js +1 -1
- package/lib/client/renderer.browser.js +3 -4
- package/lib/react/index.browser.js +1 -1
- package/lib/react/index.es.js +1 -1
- package/lib/react/index.js +1 -1
- package/lib/resourcesInliner/externalFilesHelper.es.js +2 -3
- package/lib/resourcesInliner/externalFilesHelper.js +2 -3
- package/lib/resourcesInliner/resourcesInliner.es.js +1 -2
- package/lib/resourcesInliner/resourcesInliner.js +1 -2
- package/lib/server/ReactRenderServer.es.js +1 -2
- package/lib/server/ReactRenderServer.js +1 -2
- package/lib/server/blocks/utils/flushFiles.es.js +2 -2
- package/lib/server/blocks/utils/flushFiles.js +2 -2
- package/lib/server.es.js +1 -2
- package/lib/server.js +1 -2
- package/package.json +16 -16
- package/tests.js +1 -2
package/lib/browser.js
CHANGED
|
@@ -23,7 +23,7 @@ let RenderModule = RenderModule_1 = class RenderModule {
|
|
|
23
23
|
if (typeof mode === 'string' || typeof useStrictMode === 'boolean') {
|
|
24
24
|
providers.push({
|
|
25
25
|
provide: USE_REACT_STRICT_MODE,
|
|
26
|
-
useValue: useStrictMode
|
|
26
|
+
useValue: useStrictMode ?? mode === 'strict',
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
return {
|
|
@@ -19,7 +19,7 @@ function rendering({ logger, consumerContext, customRender, extendRender, di, us
|
|
|
19
19
|
di,
|
|
20
20
|
});
|
|
21
21
|
const container = () => document.querySelector('.application');
|
|
22
|
-
const executeRendererCallbacks = (renderErr) => rendererCallback
|
|
22
|
+
const executeRendererCallbacks = (renderErr) => rendererCallback?.forEach((cb) => {
|
|
23
23
|
try {
|
|
24
24
|
cb(renderErr);
|
|
25
25
|
}
|
|
@@ -38,13 +38,12 @@ const renderer = ({ element, container, callback, log, renderMode }) => {
|
|
|
38
38
|
const hydrateRootFn = () => startTransition(() => {
|
|
39
39
|
hydrateRoot(container(), wrappedElement, {
|
|
40
40
|
onRecoverableError: (error, errorInfo) => {
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
const key = (_b = match === null || match === void 0 ? void 0 : match[1]) !== null && _b !== void 0 ? _b : error === null || error === void 0 ? void 0 : error.message;
|
|
41
|
+
const match = (error?.message ?? '').match(reactMinifiedErrorRegex);
|
|
42
|
+
const key = match?.[1] ?? error?.message;
|
|
44
43
|
// deduplicate by error type - too much noise otherwise
|
|
45
44
|
if (!allErrors.has(key)) {
|
|
46
45
|
// also too long stack traces are not very helpful but heavy for log collection
|
|
47
|
-
if (typeof
|
|
46
|
+
if (typeof errorInfo?.componentStack === 'string') {
|
|
48
47
|
// eslint-disable-next-line no-param-reassign
|
|
49
48
|
errorInfo.componentStack = shortenErrorStackTrace(errorInfo.componentStack);
|
|
50
49
|
}
|
|
@@ -6,7 +6,7 @@ import { Root } from './root.browser.js';
|
|
|
6
6
|
|
|
7
7
|
function renderReact({ di }, context) {
|
|
8
8
|
const initialState = di.get({ token: INITIAL_APP_STATE_TOKEN, optional: true });
|
|
9
|
-
return (jsx(Provider, { context: context, serverState: initialState
|
|
9
|
+
return (jsx(Provider, { context: context, serverState: initialState?.stores, children: jsx(DIContext.Provider, { value: di, children: jsx(Root, {}) }) }));
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export { renderReact };
|
package/lib/react/index.es.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Root } from './root.es.js';
|
|
|
6
6
|
|
|
7
7
|
function renderReact({ di }, context) {
|
|
8
8
|
const initialState = di.get({ token: INITIAL_APP_STATE_TOKEN, optional: true });
|
|
9
|
-
return (jsx(Provider, { context: context, serverState: initialState
|
|
9
|
+
return (jsx(Provider, { context: context, serverState: initialState?.stores, children: jsx(DIContext.Provider, { value: di, children: jsx(Root, {}) }) }));
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export { renderReact };
|
package/lib/react/index.js
CHANGED
|
@@ -10,7 +10,7 @@ var root = require('./root.js');
|
|
|
10
10
|
|
|
11
11
|
function renderReact({ di }, context) {
|
|
12
12
|
const initialState = di.get({ token: tokensCommon.INITIAL_APP_STATE_TOKEN, optional: true });
|
|
13
|
-
return (jsxRuntime.jsx(state.Provider, { context: context, serverState: initialState
|
|
13
|
+
return (jsxRuntime.jsx(state.Provider, { context: context, serverState: initialState?.stores, children: jsxRuntime.jsx(react.DIContext.Provider, { value: di, children: jsxRuntime.jsx(root.Root, {}) }) }));
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
exports.renderReact = renderReact;
|
|
@@ -14,7 +14,6 @@ const agent = {
|
|
|
14
14
|
const request = requestFactory([httpPlugin({ agent })]);
|
|
15
15
|
const thirtySeconds = 1000 * 30;
|
|
16
16
|
const getFileContentLength = async (url) => {
|
|
17
|
-
var _a;
|
|
18
17
|
const response = request({
|
|
19
18
|
url,
|
|
20
19
|
httpMethod: 'HEAD',
|
|
@@ -22,7 +21,7 @@ const getFileContentLength = async (url) => {
|
|
|
22
21
|
headers: { 'x-tramvai-service-name': 'RESOURCE_INLINER' },
|
|
23
22
|
});
|
|
24
23
|
await response;
|
|
25
|
-
return
|
|
24
|
+
return getHeaders(response)['content-length'] ?? undefined;
|
|
26
25
|
};
|
|
27
26
|
const getFile = async (url) => {
|
|
28
27
|
const fileResponse = await request({
|
|
@@ -30,7 +29,7 @@ const getFile = async (url) => {
|
|
|
30
29
|
timeout: thirtySeconds,
|
|
31
30
|
headers: { 'x-tramvai-service-name': 'RESOURCE_INLINER' },
|
|
32
31
|
});
|
|
33
|
-
return fileResponse
|
|
32
|
+
return fileResponse ?? undefined;
|
|
34
33
|
};
|
|
35
34
|
|
|
36
35
|
export { getFile, getFileContentLength };
|
|
@@ -25,7 +25,6 @@ const agent = {
|
|
|
25
25
|
const request = requestFactory__default["default"]([httpPlugin__default["default"]({ agent })]);
|
|
26
26
|
const thirtySeconds = 1000 * 30;
|
|
27
27
|
const getFileContentLength = async (url) => {
|
|
28
|
-
var _a;
|
|
29
28
|
const response = request({
|
|
30
29
|
url,
|
|
31
30
|
httpMethod: 'HEAD',
|
|
@@ -33,7 +32,7 @@ const getFileContentLength = async (url) => {
|
|
|
33
32
|
headers: { 'x-tramvai-service-name': 'RESOURCE_INLINER' },
|
|
34
33
|
});
|
|
35
34
|
await response;
|
|
36
|
-
return
|
|
35
|
+
return httpPlugin.getHeaders(response)['content-length'] ?? undefined;
|
|
37
36
|
};
|
|
38
37
|
const getFile = async (url) => {
|
|
39
38
|
const fileResponse = await request({
|
|
@@ -41,7 +40,7 @@ const getFile = async (url) => {
|
|
|
41
40
|
timeout: thirtySeconds,
|
|
42
41
|
headers: { 'x-tramvai-service-name': 'RESOURCE_INLINER' },
|
|
43
42
|
});
|
|
44
|
-
return fileResponse
|
|
43
|
+
return fileResponse ?? undefined;
|
|
45
44
|
};
|
|
46
45
|
|
|
47
46
|
exports.getFile = getFile;
|
|
@@ -175,8 +175,7 @@ class ResourcesInliner {
|
|
|
175
175
|
}
|
|
176
176
|
// method for filtering resources that can be inlined in HTML-page
|
|
177
177
|
canInline(resource) {
|
|
178
|
-
|
|
179
|
-
if (!(((_a = this.resourceInlineThreshold) === null || _a === void 0 ? void 0 : _a.types) || []).includes(resource.type)) {
|
|
178
|
+
if (!(this.resourceInlineThreshold?.types || []).includes(resource.type)) {
|
|
180
179
|
return false;
|
|
181
180
|
}
|
|
182
181
|
return true;
|
|
@@ -184,8 +184,7 @@ class ResourcesInliner {
|
|
|
184
184
|
}
|
|
185
185
|
// method for filtering resources that can be inlined in HTML-page
|
|
186
186
|
canInline(resource) {
|
|
187
|
-
|
|
188
|
-
if (!(((_a = this.resourceInlineThreshold) === null || _a === void 0 ? void 0 : _a.types) || []).includes(resource.type)) {
|
|
187
|
+
if (!(this.resourceInlineThreshold?.types || []).includes(resource.type)) {
|
|
189
188
|
return false;
|
|
190
189
|
}
|
|
191
190
|
return true;
|
|
@@ -78,11 +78,10 @@ class ReactRenderServer {
|
|
|
78
78
|
this.deferredActions = deferredActions;
|
|
79
79
|
}
|
|
80
80
|
render({ extractor, stats, }) {
|
|
81
|
-
var _a;
|
|
82
81
|
let renderResult = renderReact({ di: this.di }, this.context);
|
|
83
82
|
each((render) => {
|
|
84
83
|
renderResult = render(renderResult);
|
|
85
|
-
},
|
|
84
|
+
}, this.extendRender ?? []);
|
|
86
85
|
renderResult = extractor.collectChunks(renderResult);
|
|
87
86
|
if (this.customRender) {
|
|
88
87
|
return this.customRender(renderResult);
|
|
@@ -86,11 +86,10 @@ class ReactRenderServer {
|
|
|
86
86
|
this.deferredActions = deferredActions;
|
|
87
87
|
}
|
|
88
88
|
render({ extractor, stats, }) {
|
|
89
|
-
var _a;
|
|
90
89
|
let renderResult = index.renderReact({ di: this.di }, this.context);
|
|
91
90
|
each__default["default"]((render) => {
|
|
92
91
|
renderResult = render(renderResult);
|
|
93
|
-
},
|
|
92
|
+
}, this.extendRender ?? []);
|
|
94
93
|
renderResult = extractor.collectChunks(renderResult);
|
|
95
94
|
if (this.customRender) {
|
|
96
95
|
return this.customRender(renderResult);
|
|
@@ -19,7 +19,7 @@ const flushFiles = (chunks, webpackStats, { ignoreDependencies = false, } = {})
|
|
|
19
19
|
const { assetsByChunkName, namedChunkGroups, chunks: allChunks } = webpackStats;
|
|
20
20
|
const resolvedChunks = [];
|
|
21
21
|
for (const chunk of chunks) {
|
|
22
|
-
if (!ignoreDependencies &&
|
|
22
|
+
if (!ignoreDependencies && namedChunkGroups?.[chunk]) {
|
|
23
23
|
resolvedChunks.push(...namedChunkGroups[chunk].chunks);
|
|
24
24
|
}
|
|
25
25
|
else {
|
|
@@ -30,7 +30,7 @@ const flushFiles = (chunks, webpackStats, { ignoreDependencies = false, } = {})
|
|
|
30
30
|
let assetFiles = assetsByChunkName[chunk];
|
|
31
31
|
if (!assetFiles && allChunks) {
|
|
32
32
|
const chunkById = allChunks.find((c) => c.id === chunk);
|
|
33
|
-
assetFiles = chunkById
|
|
33
|
+
assetFiles = chunkById?.files;
|
|
34
34
|
}
|
|
35
35
|
return assetFiles;
|
|
36
36
|
}));
|
|
@@ -28,7 +28,7 @@ const flushFiles = (chunks, webpackStats, { ignoreDependencies = false, } = {})
|
|
|
28
28
|
const { assetsByChunkName, namedChunkGroups, chunks: allChunks } = webpackStats;
|
|
29
29
|
const resolvedChunks = [];
|
|
30
30
|
for (const chunk of chunks) {
|
|
31
|
-
if (!ignoreDependencies &&
|
|
31
|
+
if (!ignoreDependencies && namedChunkGroups?.[chunk]) {
|
|
32
32
|
resolvedChunks.push(...namedChunkGroups[chunk].chunks);
|
|
33
33
|
}
|
|
34
34
|
else {
|
|
@@ -39,7 +39,7 @@ const flushFiles = (chunks, webpackStats, { ignoreDependencies = false, } = {})
|
|
|
39
39
|
let assetFiles = assetsByChunkName[chunk];
|
|
40
40
|
if (!assetFiles && allChunks) {
|
|
41
41
|
const chunkById = allChunks.find((c) => c.id === chunk);
|
|
42
|
-
assetFiles = chunkById
|
|
42
|
+
assetFiles = chunkById?.files;
|
|
43
43
|
}
|
|
44
44
|
return assetFiles;
|
|
45
45
|
}));
|
package/lib/server.es.js
CHANGED
|
@@ -23,7 +23,6 @@ import { LayoutModule } from './shared/LayoutModule.es.js';
|
|
|
23
23
|
import { providers } from './shared/providers.es.js';
|
|
24
24
|
import { fetchWebpackStats } from './server/blocks/utils/fetchWebpackStats.es.js';
|
|
25
25
|
|
|
26
|
-
var _a;
|
|
27
26
|
var RenderModule_1;
|
|
28
27
|
const REQUEST_TTL = 5 * 60 * 1000;
|
|
29
28
|
/**
|
|
@@ -338,7 +337,7 @@ Page Error Boundary will be rendered for the client`,
|
|
|
338
337
|
}),
|
|
339
338
|
provide({
|
|
340
339
|
provide: DEFAULT_ASSETS_PREFIX_TOKEN,
|
|
341
|
-
useValue:
|
|
340
|
+
useValue: process.env.ASSETS_PREFIX ?? null,
|
|
342
341
|
}),
|
|
343
342
|
provide({
|
|
344
343
|
provide: FETCH_WEBPACK_STATS_TOKEN,
|
package/lib/server.js
CHANGED
|
@@ -24,7 +24,6 @@ var LayoutModule = require('./shared/LayoutModule.js');
|
|
|
24
24
|
var providers = require('./shared/providers.js');
|
|
25
25
|
var fetchWebpackStats = require('./server/blocks/utils/fetchWebpackStats.js');
|
|
26
26
|
|
|
27
|
-
var _a;
|
|
28
27
|
var RenderModule_1;
|
|
29
28
|
const REQUEST_TTL = 5 * 60 * 1000;
|
|
30
29
|
/**
|
|
@@ -339,7 +338,7 @@ Page Error Boundary will be rendered for the client`,
|
|
|
339
338
|
}),
|
|
340
339
|
core.provide({
|
|
341
340
|
provide: tokensRender.DEFAULT_ASSETS_PREFIX_TOKEN,
|
|
342
|
-
useValue:
|
|
341
|
+
useValue: process.env.ASSETS_PREFIX ?? null,
|
|
343
342
|
}),
|
|
344
343
|
core.provide({
|
|
345
344
|
provide: tokensRender.FETCH_WEBPACK_STATS_TOKEN,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/module-render",
|
|
3
|
-
"version": "5.9
|
|
3
|
+
"version": "5.14.9",
|
|
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.
|
|
29
|
+
"@tinkoff/user-agent": "0.7.46",
|
|
30
30
|
"@tinkoff/request-core": "^0.10.0",
|
|
31
31
|
"@tinkoff/request-plugin-protocol-http": "^0.12.1",
|
|
32
|
-
"@tramvai/module-client-hints": "5.9
|
|
33
|
-
"@tramvai/module-router": "5.9
|
|
34
|
-
"@tramvai/react": "5.9
|
|
35
|
-
"@tramvai/safe-strings": "0.8.
|
|
36
|
-
"@tramvai/tokens-render": "5.9
|
|
37
|
-
"@tramvai/experiments": "5.9
|
|
32
|
+
"@tramvai/module-client-hints": "5.14.9",
|
|
33
|
+
"@tramvai/module-router": "5.14.9",
|
|
34
|
+
"@tramvai/react": "5.14.9",
|
|
35
|
+
"@tramvai/safe-strings": "0.8.4",
|
|
36
|
+
"@tramvai/tokens-render": "5.14.9",
|
|
37
|
+
"@tramvai/experiments": "5.14.9",
|
|
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.9
|
|
46
|
-
"@tramvai/core": "5.9
|
|
47
|
-
"@tramvai/module-common": "5.9
|
|
48
|
-
"@tramvai/state": "5.9
|
|
49
|
-
"@tramvai/test-helpers": "5.9
|
|
50
|
-
"@tramvai/tokens-common": "5.9
|
|
51
|
-
"@tramvai/tokens-router": "5.9
|
|
52
|
-
"@tramvai/tokens-server-private": "5.9
|
|
45
|
+
"@tramvai/cli": "5.14.9",
|
|
46
|
+
"@tramvai/core": "5.14.9",
|
|
47
|
+
"@tramvai/module-common": "5.14.9",
|
|
48
|
+
"@tramvai/state": "5.14.9",
|
|
49
|
+
"@tramvai/test-helpers": "5.14.9",
|
|
50
|
+
"@tramvai/tokens-common": "5.14.9",
|
|
51
|
+
"@tramvai/tokens-router": "5.14.9",
|
|
52
|
+
"@tramvai/tokens-server-private": "5.14.9",
|
|
53
53
|
"express": "^4.17.1",
|
|
54
54
|
"prop-types": "^15.6.2",
|
|
55
55
|
"react": ">=16.14.0",
|
package/tests.js
CHANGED
|
@@ -157,7 +157,6 @@ const htmlPageSchemaFactory = ({ htmlAttrs, }) => {
|
|
|
157
157
|
};
|
|
158
158
|
|
|
159
159
|
const testPageResources = (options) => {
|
|
160
|
-
var _a;
|
|
161
160
|
const { modules, providers = [] } = options;
|
|
162
161
|
const { di, runLine } = testHelpers.getDiWrapper({
|
|
163
162
|
di: options.di,
|
|
@@ -209,7 +208,7 @@ const testPageResources = (options) => {
|
|
|
209
208
|
}),
|
|
210
209
|
],
|
|
211
210
|
});
|
|
212
|
-
const renderSlots = flatten__default["default"](
|
|
211
|
+
const renderSlots = flatten__default["default"](di.get({ token: tokensRender.RENDER_SLOTS, optional: true }) ?? []);
|
|
213
212
|
const resourcesRegistry = di.get(tokensRender.RESOURCES_REGISTRY);
|
|
214
213
|
const render = () => {
|
|
215
214
|
const rawHtml = htmlpagebuilder.buildPage({
|