@tramvai/module-render 2.74.0 → 2.75.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/browser.d.ts +2 -1
- package/lib/browser.js +2 -2
- package/lib/react/pageErrorBoundary.browser.js +1 -2
- package/lib/react/pageErrorBoundary.es.js +1 -2
- package/lib/react/pageErrorBoundary.js +2 -3
- package/lib/server.d.ts +2 -1
- package/lib/server.es.js +2 -2
- package/lib/server.js +12 -8
- package/lib/shared/providers.browser.js +1 -1
- package/lib/shared/providers.es.js +1 -1
- package/lib/shared/providers.js +2 -2
- package/package.json +15 -15
- package/lib/shared/pageErrorStore.browser.js +0 -19
- package/lib/shared/pageErrorStore.d.ts +0 -14
- package/lib/shared/pageErrorStore.es.js +0 -19
- package/lib/shared/pageErrorStore.js +0 -26
package/lib/browser.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { PageErrorStore, setPageErrorEvent } from '@tramvai/module-router';
|
|
1
2
|
import type { RenderModuleConfig } from './shared/types';
|
|
2
|
-
export
|
|
3
|
+
export { PageErrorStore, setPageErrorEvent };
|
|
3
4
|
export * from '@tramvai/tokens-render';
|
|
4
5
|
export declare const DEFAULT_POLYFILL_CONDITION = "";
|
|
5
6
|
export declare class RenderModule {
|
package/lib/browser.js
CHANGED
|
@@ -4,11 +4,11 @@ import { STORE_TOKEN, LOGGER_TOKEN, CONTEXT_TOKEN } from '@tramvai/tokens-common
|
|
|
4
4
|
import { RESOURCES_REGISTRY, CUSTOM_RENDER, EXTEND_RENDER, RENDERER_CALLBACK, USE_REACT_STRICT_MODE, RENDER_MODE } from '@tramvai/tokens-render';
|
|
5
5
|
export * from '@tramvai/tokens-render';
|
|
6
6
|
import { ROUTER_TOKEN } from '@tramvai/tokens-router';
|
|
7
|
+
import { PageErrorStore, setPageErrorEvent } from '@tramvai/module-router';
|
|
8
|
+
export { PageErrorStore, setPageErrorEvent } from '@tramvai/module-router';
|
|
7
9
|
import { rendering } from './client/index.browser.js';
|
|
8
10
|
import { LayoutModule } from './shared/LayoutModule.browser.js';
|
|
9
11
|
import { providers } from './shared/providers.browser.js';
|
|
10
|
-
import { PageErrorStore, setPageErrorEvent } from './shared/pageErrorStore.browser.js';
|
|
11
|
-
export { PageErrorStore, deserializeError, serializeError, setPageErrorEvent } from './shared/pageErrorStore.browser.js';
|
|
12
12
|
|
|
13
13
|
var RenderModule_1;
|
|
14
14
|
const DEFAULT_POLYFILL_CONDITION = '';
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
3
|
import { useDi, ERROR_BOUNDARY_TOKEN, ERROR_BOUNDARY_FALLBACK_COMPONENT_TOKEN, UniversalErrorBoundary } from '@tramvai/react';
|
|
4
|
-
import { useUrl } from '@tramvai/module-router';
|
|
4
|
+
import { useUrl, PageErrorStore, deserializeError } from '@tramvai/module-router';
|
|
5
5
|
import { PAGE_SERVICE_TOKEN } from '@tramvai/tokens-router';
|
|
6
6
|
import { useStore } from '@tramvai/state';
|
|
7
|
-
import { PageErrorStore, deserializeError } from '../shared/pageErrorStore.browser.js';
|
|
8
7
|
|
|
9
8
|
const PageErrorBoundary = (props) => {
|
|
10
9
|
const { children } = props;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
3
|
import { useDi, ERROR_BOUNDARY_TOKEN, ERROR_BOUNDARY_FALLBACK_COMPONENT_TOKEN, UniversalErrorBoundary } from '@tramvai/react';
|
|
4
|
-
import { useUrl } from '@tramvai/module-router';
|
|
4
|
+
import { useUrl, PageErrorStore, deserializeError } from '@tramvai/module-router';
|
|
5
5
|
import { PAGE_SERVICE_TOKEN } from '@tramvai/tokens-router';
|
|
6
6
|
import { useStore } from '@tramvai/state';
|
|
7
|
-
import { PageErrorStore, deserializeError } from '../shared/pageErrorStore.es.js';
|
|
8
7
|
|
|
9
8
|
const PageErrorBoundary = (props) => {
|
|
10
9
|
const { children } = props;
|
|
@@ -8,15 +8,14 @@ var react = require('@tramvai/react');
|
|
|
8
8
|
var moduleRouter = require('@tramvai/module-router');
|
|
9
9
|
var tokensRouter = require('@tramvai/tokens-router');
|
|
10
10
|
var state = require('@tramvai/state');
|
|
11
|
-
var pageErrorStore = require('../shared/pageErrorStore.js');
|
|
12
11
|
|
|
13
12
|
const PageErrorBoundary = (props) => {
|
|
14
13
|
const { children } = props;
|
|
15
14
|
const pageService = react.useDi(tokensRouter.PAGE_SERVICE_TOKEN);
|
|
16
15
|
const url = moduleRouter.useUrl();
|
|
17
|
-
const serializedError = state.useStore(
|
|
16
|
+
const serializedError = state.useStore(moduleRouter.PageErrorStore);
|
|
18
17
|
const error = react$1.useMemo(() => {
|
|
19
|
-
return serializedError &&
|
|
18
|
+
return serializedError && moduleRouter.deserializeError(serializedError);
|
|
20
19
|
}, [serializedError]);
|
|
21
20
|
const errorHandlers = react.useDi({ token: react.ERROR_BOUNDARY_TOKEN, optional: true });
|
|
22
21
|
const fallbackFromDi = react.useDi({ token: react.ERROR_BOUNDARY_FALLBACK_COMPONENT_TOKEN, optional: true });
|
package/lib/server.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { PageErrorStore, setPageErrorEvent } from '@tramvai/module-router';
|
|
1
2
|
import type { RenderModuleConfig } from './shared/types';
|
|
2
|
-
export
|
|
3
|
+
export { PageErrorStore, setPageErrorEvent };
|
|
3
4
|
export * from '@tramvai/tokens-render';
|
|
4
5
|
export declare const DEFAULT_POLYFILL_CONDITION = "!window.Promise.prototype.finally || !window.URL || !window.URLSearchParams || !window.AbortController || !window.IntersectionObserver || !Object.fromEntries || !window.ResizeObserver";
|
|
5
6
|
export declare class RenderModule {
|
package/lib/server.es.js
CHANGED
|
@@ -12,6 +12,8 @@ import { WEB_FASTIFY_APP_BEFORE_ERROR_TOKEN } from '@tramvai/tokens-server-priva
|
|
|
12
12
|
import { ROOT_ERROR_BOUNDARY_COMPONENT_TOKEN } from '@tramvai/react';
|
|
13
13
|
import { parse } from '@tinkoff/url';
|
|
14
14
|
import { satisfies } from '@tinkoff/user-agent';
|
|
15
|
+
import { setPageErrorEvent, PageErrorStore, deserializeError } from '@tramvai/module-router';
|
|
16
|
+
export { PageErrorStore, setPageErrorEvent } from '@tramvai/module-router';
|
|
15
17
|
import { ResourcesInliner } from './resourcesInliner/resourcesInliner.es.js';
|
|
16
18
|
import { RESOURCE_INLINER, RESOURCES_REGISTRY_CACHE } from './resourcesInliner/tokens.es.js';
|
|
17
19
|
import { ResourcesRegistry } from './resourcesRegistry/index.es.js';
|
|
@@ -21,8 +23,6 @@ import { ReactRenderServer } from './server/ReactRenderServer.es.js';
|
|
|
21
23
|
export { ReactRenderServer } from './server/ReactRenderServer.es.js';
|
|
22
24
|
import { LayoutModule } from './shared/LayoutModule.es.js';
|
|
23
25
|
import { providers } from './shared/providers.es.js';
|
|
24
|
-
import { setPageErrorEvent, PageErrorStore, deserializeError } from './shared/pageErrorStore.es.js';
|
|
25
|
-
export { PageErrorStore, deserializeError, serializeError, setPageErrorEvent } from './shared/pageErrorStore.es.js';
|
|
26
26
|
|
|
27
27
|
var RenderModule_1;
|
|
28
28
|
const REQUEST_TTL = 5 * 60 * 1000;
|
package/lib/server.js
CHANGED
|
@@ -15,6 +15,7 @@ var tokensServerPrivate = require('@tramvai/tokens-server-private');
|
|
|
15
15
|
var react$1 = require('@tramvai/react');
|
|
16
16
|
var url = require('@tinkoff/url');
|
|
17
17
|
var userAgent = require('@tinkoff/user-agent');
|
|
18
|
+
var moduleRouter = require('@tramvai/module-router');
|
|
18
19
|
var resourcesInliner = require('./resourcesInliner/resourcesInliner.js');
|
|
19
20
|
var tokens = require('./resourcesInliner/tokens.js');
|
|
20
21
|
var index = require('./resourcesRegistry/index.js');
|
|
@@ -23,7 +24,6 @@ var htmlPageSchema = require('./server/htmlPageSchema.js');
|
|
|
23
24
|
var ReactRenderServer = require('./server/ReactRenderServer.js');
|
|
24
25
|
var LayoutModule = require('./shared/LayoutModule.js');
|
|
25
26
|
var providers = require('./shared/providers.js');
|
|
26
|
-
var pageErrorStore = require('./shared/pageErrorStore.js');
|
|
27
27
|
|
|
28
28
|
var RenderModule_1;
|
|
29
29
|
const REQUEST_TTL = 5 * 60 * 1000;
|
|
@@ -92,7 +92,7 @@ exports.RenderModule = RenderModule_1 = tslib.__decorate([
|
|
|
92
92
|
// assuming that there was an error when rendering the page, try to render again with ErrorBoundary
|
|
93
93
|
try {
|
|
94
94
|
log.info({ event: 'render-page-boundary-start' });
|
|
95
|
-
context.dispatch(
|
|
95
|
+
context.dispatch(moduleRouter.setPageErrorEvent(error));
|
|
96
96
|
html = await htmlBuilder.flow();
|
|
97
97
|
log.info({ event: 'render-page-boundary-success' });
|
|
98
98
|
}
|
|
@@ -103,7 +103,7 @@ exports.RenderModule = RenderModule_1 = tslib.__decorate([
|
|
|
103
103
|
throw error;
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
-
const pageRenderError = context.getState(
|
|
106
|
+
const pageRenderError = context.getState(moduleRouter.PageErrorStore);
|
|
107
107
|
// log send-server-error only after successful Page Boundary render,
|
|
108
108
|
// otherwise this event will be logged in default error handler
|
|
109
109
|
if (pageRenderError) {
|
|
@@ -117,7 +117,7 @@ exports.RenderModule = RenderModule_1 = tslib.__decorate([
|
|
|
117
117
|
log.error({
|
|
118
118
|
event: 'send-server-error',
|
|
119
119
|
message: 'Page render error, switch to page boundary',
|
|
120
|
-
error:
|
|
120
|
+
error: moduleRouter.deserializeError(pageRenderError),
|
|
121
121
|
requestInfo,
|
|
122
122
|
});
|
|
123
123
|
}
|
|
@@ -286,11 +286,15 @@ exports.RenderModule = RenderModule_1 = tslib.__decorate([
|
|
|
286
286
|
})
|
|
287
287
|
], exports.RenderModule);
|
|
288
288
|
|
|
289
|
+
Object.defineProperty(exports, 'PageErrorStore', {
|
|
290
|
+
enumerable: true,
|
|
291
|
+
get: function () { return moduleRouter.PageErrorStore; }
|
|
292
|
+
});
|
|
293
|
+
Object.defineProperty(exports, 'setPageErrorEvent', {
|
|
294
|
+
enumerable: true,
|
|
295
|
+
get: function () { return moduleRouter.setPageErrorEvent; }
|
|
296
|
+
});
|
|
289
297
|
exports.ReactRenderServer = ReactRenderServer.ReactRenderServer;
|
|
290
|
-
exports.PageErrorStore = pageErrorStore.PageErrorStore;
|
|
291
|
-
exports.deserializeError = pageErrorStore.deserializeError;
|
|
292
|
-
exports.serializeError = pageErrorStore.serializeError;
|
|
293
|
-
exports.setPageErrorEvent = pageErrorStore.setPageErrorEvent;
|
|
294
298
|
exports.DEFAULT_POLYFILL_CONDITION = DEFAULT_POLYFILL_CONDITION;
|
|
295
299
|
Object.keys(tokensRender).forEach(function (k) {
|
|
296
300
|
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { provide } from '@tramvai/core';
|
|
2
2
|
import { COMBINE_REDUCERS } from '@tramvai/tokens-common';
|
|
3
3
|
import { TRAMVAI_RENDER_MODE } from '@tramvai/tokens-render';
|
|
4
|
-
import { PageErrorStore } from '
|
|
4
|
+
import { PageErrorStore } from '@tramvai/module-router';
|
|
5
5
|
|
|
6
6
|
const providers = [
|
|
7
7
|
provide({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { provide } from '@tramvai/core';
|
|
2
2
|
import { COMBINE_REDUCERS } from '@tramvai/tokens-common';
|
|
3
3
|
import { TRAMVAI_RENDER_MODE } from '@tramvai/tokens-render';
|
|
4
|
-
import { PageErrorStore } from '
|
|
4
|
+
import { PageErrorStore } from '@tramvai/module-router';
|
|
5
5
|
|
|
6
6
|
const providers = [
|
|
7
7
|
provide({
|
package/lib/shared/providers.js
CHANGED
|
@@ -5,13 +5,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var core = require('@tramvai/core');
|
|
6
6
|
var tokensCommon = require('@tramvai/tokens-common');
|
|
7
7
|
var tokensRender = require('@tramvai/tokens-render');
|
|
8
|
-
var
|
|
8
|
+
var moduleRouter = require('@tramvai/module-router');
|
|
9
9
|
|
|
10
10
|
const providers = [
|
|
11
11
|
core.provide({
|
|
12
12
|
provide: tokensCommon.COMBINE_REDUCERS,
|
|
13
13
|
multi: true,
|
|
14
|
-
useValue:
|
|
14
|
+
useValue: moduleRouter.PageErrorStore,
|
|
15
15
|
}),
|
|
16
16
|
core.provide({
|
|
17
17
|
provide: tokensRender.TRAMVAI_RENDER_MODE,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/module-render",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.75.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"browser": "lib/browser.js",
|
|
6
6
|
"main": "lib/server.js",
|
|
@@ -25,13 +25,13 @@
|
|
|
25
25
|
"@tinkoff/htmlpagebuilder": "0.5.6",
|
|
26
26
|
"@tinkoff/layout-factory": "0.3.7",
|
|
27
27
|
"@tinkoff/url": "0.8.5",
|
|
28
|
-
"@tinkoff/user-agent": "0.4.
|
|
29
|
-
"@tramvai/module-client-hints": "2.
|
|
30
|
-
"@tramvai/module-router": "2.
|
|
31
|
-
"@tramvai/react": "2.
|
|
28
|
+
"@tinkoff/user-agent": "0.4.187",
|
|
29
|
+
"@tramvai/module-client-hints": "2.75.0",
|
|
30
|
+
"@tramvai/module-router": "2.75.0",
|
|
31
|
+
"@tramvai/react": "2.75.0",
|
|
32
32
|
"@tramvai/safe-strings": "0.5.7",
|
|
33
|
-
"@tramvai/tokens-render": "2.
|
|
34
|
-
"@tramvai/experiments": "2.
|
|
33
|
+
"@tramvai/tokens-render": "2.75.0",
|
|
34
|
+
"@tramvai/experiments": "2.75.0",
|
|
35
35
|
"@types/loadable__server": "^5.12.6",
|
|
36
36
|
"node-fetch": "^2.6.1"
|
|
37
37
|
},
|
|
@@ -39,14 +39,14 @@
|
|
|
39
39
|
"@tinkoff/dippy": "0.8.13",
|
|
40
40
|
"@tinkoff/utils": "^2.1.2",
|
|
41
41
|
"@tinkoff/react-hooks": "0.1.5",
|
|
42
|
-
"@tramvai/cli": "2.
|
|
43
|
-
"@tramvai/core": "2.
|
|
44
|
-
"@tramvai/module-common": "2.
|
|
45
|
-
"@tramvai/state": "2.
|
|
46
|
-
"@tramvai/test-helpers": "2.
|
|
47
|
-
"@tramvai/tokens-common": "2.
|
|
48
|
-
"@tramvai/tokens-router": "2.
|
|
49
|
-
"@tramvai/tokens-server-private": "2.
|
|
42
|
+
"@tramvai/cli": "2.75.0",
|
|
43
|
+
"@tramvai/core": "2.75.0",
|
|
44
|
+
"@tramvai/module-common": "2.75.0",
|
|
45
|
+
"@tramvai/state": "2.75.0",
|
|
46
|
+
"@tramvai/test-helpers": "2.75.0",
|
|
47
|
+
"@tramvai/tokens-common": "2.75.0",
|
|
48
|
+
"@tramvai/tokens-router": "2.75.0",
|
|
49
|
+
"@tramvai/tokens-server-private": "2.75.0",
|
|
50
50
|
"express": "^4.17.1",
|
|
51
51
|
"prop-types": "^15.6.2",
|
|
52
52
|
"react": ">=16.14.0",
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { createEvent, createReducer } from '@tramvai/state';
|
|
2
|
-
|
|
3
|
-
function serializeError(error) {
|
|
4
|
-
return {
|
|
5
|
-
...error,
|
|
6
|
-
message: error.message,
|
|
7
|
-
stack: error.stack,
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
function deserializeError(serializedError) {
|
|
11
|
-
const error = new Error(serializedError.message);
|
|
12
|
-
Object.assign(error, serializedError);
|
|
13
|
-
return error;
|
|
14
|
-
}
|
|
15
|
-
const setPageErrorEvent = createEvent('setPageError');
|
|
16
|
-
const initialState = null;
|
|
17
|
-
const PageErrorStore = createReducer('pageError', initialState).on(setPageErrorEvent, (state, error) => error && serializeError(error));
|
|
18
|
-
|
|
19
|
-
export { PageErrorStore, deserializeError, serializeError, setPageErrorEvent };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
type AnyError = Error & {
|
|
2
|
-
[key: string]: any;
|
|
3
|
-
};
|
|
4
|
-
export interface SerializedError {
|
|
5
|
-
message: string;
|
|
6
|
-
stack?: string;
|
|
7
|
-
[key: string]: any;
|
|
8
|
-
}
|
|
9
|
-
export declare function serializeError(error: AnyError): SerializedError;
|
|
10
|
-
export declare function deserializeError(serializedError: SerializedError): AnyError;
|
|
11
|
-
export type IPageErrorStore = SerializedError | null;
|
|
12
|
-
export declare const setPageErrorEvent: import("@tramvai/types-actions-state-context").EventCreator1<AnyError, AnyError>;
|
|
13
|
-
export declare const PageErrorStore: import("@tramvai/state").Reducer<SerializedError, "pageError">;
|
|
14
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { createEvent, createReducer } from '@tramvai/state';
|
|
2
|
-
|
|
3
|
-
function serializeError(error) {
|
|
4
|
-
return {
|
|
5
|
-
...error,
|
|
6
|
-
message: error.message,
|
|
7
|
-
stack: error.stack,
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
function deserializeError(serializedError) {
|
|
11
|
-
const error = new Error(serializedError.message);
|
|
12
|
-
Object.assign(error, serializedError);
|
|
13
|
-
return error;
|
|
14
|
-
}
|
|
15
|
-
const setPageErrorEvent = createEvent('setPageError');
|
|
16
|
-
const initialState = null;
|
|
17
|
-
const PageErrorStore = createReducer('pageError', initialState).on(setPageErrorEvent, (state, error) => error && serializeError(error));
|
|
18
|
-
|
|
19
|
-
export { PageErrorStore, deserializeError, serializeError, setPageErrorEvent };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var state = require('@tramvai/state');
|
|
6
|
-
|
|
7
|
-
function serializeError(error) {
|
|
8
|
-
return {
|
|
9
|
-
...error,
|
|
10
|
-
message: error.message,
|
|
11
|
-
stack: error.stack,
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
function deserializeError(serializedError) {
|
|
15
|
-
const error = new Error(serializedError.message);
|
|
16
|
-
Object.assign(error, serializedError);
|
|
17
|
-
return error;
|
|
18
|
-
}
|
|
19
|
-
const setPageErrorEvent = state.createEvent('setPageError');
|
|
20
|
-
const initialState = null;
|
|
21
|
-
const PageErrorStore = state.createReducer('pageError', initialState).on(setPageErrorEvent, (state, error) => error && serializeError(error));
|
|
22
|
-
|
|
23
|
-
exports.PageErrorStore = PageErrorStore;
|
|
24
|
-
exports.deserializeError = deserializeError;
|
|
25
|
-
exports.serializeError = serializeError;
|
|
26
|
-
exports.setPageErrorEvent = setPageErrorEvent;
|