@tramvai/module-child-app 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/loader.browser.js +1 -2
- package/lib/browser/preload.browser.js +1 -1
- package/lib/browser/providers.browser.js +1 -1
- package/lib/contracts/contractManager.base.browser.js +13 -16
- package/lib/contracts/contractManager.base.es.js +13 -16
- package/lib/contracts/contractManager.base.js +13 -16
- package/lib/contracts/contractManager.server.es.js +6 -7
- package/lib/contracts/contractManager.server.js +6 -7
- package/lib/server/preload.es.js +1 -1
- package/lib/server/preload.js +1 -1
- package/lib/server/render-slots.es.js +10 -9
- package/lib/server/render-slots.js +10 -9
- package/lib/server/stateManager.es.js +1 -1
- package/lib/server/stateManager.js +1 -1
- package/lib/shared/child/extractorProviders.es.js +1 -1
- package/lib/shared/child/extractorProviders.js +1 -1
- package/lib/shared/child/singletonProviders.browser.js +6 -4
- package/lib/shared/child/singletonProviders.es.js +6 -4
- package/lib/shared/child/singletonProviders.js +6 -4
- package/lib/shared/pagePreload.browser.js +1 -1
- package/lib/shared/pagePreload.es.js +1 -1
- package/lib/shared/pagePreload.js +1 -1
- package/lib/shared/pageService.browser.js +2 -3
- package/lib/shared/pageService.es.js +2 -3
- package/lib/shared/pageService.js +2 -3
- package/lib/shared/providers.browser.js +24 -7
- package/lib/shared/providers.es.js +24 -7
- package/lib/shared/providers.js +23 -6
- package/lib/shared/react/childAppErrorBoundary.browser.js +14 -0
- package/lib/shared/react/childAppErrorBoundary.d.ts +8 -0
- package/lib/shared/react/childAppErrorBoundary.es.js +14 -0
- package/lib/shared/react/childAppErrorBoundary.js +18 -0
- package/lib/shared/react/component.browser.js +3 -3
- package/lib/shared/react/component.es.js +3 -3
- package/lib/shared/react/component.js +2 -2
- package/lib/shared/resolutionConfigManager.browser.js +3 -4
- package/lib/shared/resolutionConfigManager.es.js +3 -4
- package/lib/shared/resolutionConfigManager.js +3 -4
- package/package.json +12 -12
|
@@ -36,10 +36,9 @@ class BrowserLoader extends Loader {
|
|
|
36
36
|
moduleName,
|
|
37
37
|
});
|
|
38
38
|
const promise = (async () => {
|
|
39
|
-
var _a;
|
|
40
39
|
// `resolveOnCssFailed: true` - allow to load module without server preloading on the client-side
|
|
41
40
|
await loadModule(config.client.entry, {
|
|
42
|
-
cssUrl:
|
|
41
|
+
cssUrl: config.css?.entry,
|
|
43
42
|
resolveOnCssFailed: true,
|
|
44
43
|
});
|
|
45
44
|
container = getModuleFromGlobal(config.client.entry);
|
|
@@ -182,7 +182,7 @@ class PreloadManager {
|
|
|
182
182
|
// preload child app page component - we need to register page actions before running all child app actions
|
|
183
183
|
async resolveComponent(config, route) {
|
|
184
184
|
const di = this.diManager.getChildDi(config);
|
|
185
|
-
const childAppPageService = di
|
|
185
|
+
const childAppPageService = di?.get(optional(CHILD_APP_PAGE_SERVICE_TOKEN));
|
|
186
186
|
if (childAppPageService) {
|
|
187
187
|
await childAppPageService.resolveComponent(route);
|
|
188
188
|
}
|
|
@@ -33,7 +33,7 @@ const browserProviders = [
|
|
|
33
33
|
}),
|
|
34
34
|
provide({
|
|
35
35
|
provide: CHILD_APP_COMMON_INITIAL_STATE_TOKEN,
|
|
36
|
-
useFactory: () =>
|
|
36
|
+
useFactory: () => JSON.parse(document.getElementById(GLOBAL_CHILD_STATE)?.textContent ?? '{}'),
|
|
37
37
|
}),
|
|
38
38
|
provide({
|
|
39
39
|
provide: CHILD_APP_RENDER_MANAGER_TOKEN,
|
|
@@ -7,15 +7,14 @@ import { CHILD_APP_INTERNAL_CONFIG_TOKEN, IS_CHILD_APP_CONTRACTS_COMPATIBLE_TOKE
|
|
|
7
7
|
class BaseChildAppContractManager {
|
|
8
8
|
constructor({ appDi, hostProvidedContracts, hostRequiredContracts, logger, }) {
|
|
9
9
|
this.appDi = appDi;
|
|
10
|
-
this.hostProvidedContracts = hostProvidedContracts
|
|
11
|
-
this.hostRequiredContracts = hostRequiredContracts
|
|
10
|
+
this.hostProvidedContracts = hostProvidedContracts ?? [];
|
|
11
|
+
this.hostRequiredContracts = hostRequiredContracts ?? [];
|
|
12
12
|
this.log = logger('child-app:contract-manager');
|
|
13
13
|
}
|
|
14
14
|
registerChildContracts(childDi) {
|
|
15
|
-
var _a, _b;
|
|
16
15
|
const childAppConfig = childDi.get(CHILD_APP_INTERNAL_CONFIG_TOKEN);
|
|
17
16
|
const childHasContractsSupport = childDi.get(optional(IS_CHILD_APP_CONTRACTS_COMPATIBLE_TOKEN));
|
|
18
|
-
const childRequiredContracts = flatten(
|
|
17
|
+
const childRequiredContracts = flatten(childDi.get(optional(CHILD_REQUIRED_CONTRACTS)) ?? []);
|
|
19
18
|
const hostProvidedContracts = this.getHostProvidedContracts(childAppConfig.name);
|
|
20
19
|
const hostProvidedContractsKeys = hostProvidedContracts.map((c) => c.toString());
|
|
21
20
|
// if contracts unsupported, it is a legacy child app, and we need to register all possible contracts
|
|
@@ -44,7 +43,7 @@ class BaseChildAppContractManager {
|
|
|
44
43
|
message: `Missed contracts for "${childAppConfig.name}" Child App`,
|
|
45
44
|
missedContracts,
|
|
46
45
|
});
|
|
47
|
-
const fallbacks =
|
|
46
|
+
const fallbacks = childDi.get(optional(CHILD_CONTRACTS_FALLBACK)) ?? [];
|
|
48
47
|
fallbacks.forEach((fallback) => {
|
|
49
48
|
fallback({
|
|
50
49
|
childDi,
|
|
@@ -55,7 +54,6 @@ class BaseChildAppContractManager {
|
|
|
55
54
|
}
|
|
56
55
|
}
|
|
57
56
|
validateChildProvidedContracts(childDi) {
|
|
58
|
-
var _a;
|
|
59
57
|
const childAppConfig = childDi.get(CHILD_APP_INTERNAL_CONFIG_TOKEN);
|
|
60
58
|
const hostDi = this.getRequestHostDi();
|
|
61
59
|
const childProvidedContracts = this.getChildProvidedContracts(childDi);
|
|
@@ -73,7 +71,7 @@ class BaseChildAppContractManager {
|
|
|
73
71
|
message: `Missed contracts for application, required from "${childAppConfig.name}" Child App`,
|
|
74
72
|
missedContracts,
|
|
75
73
|
});
|
|
76
|
-
const fallbacks =
|
|
74
|
+
const fallbacks = hostDi.get(optional(HOST_CONTRACTS_FALLBACK)) ?? [];
|
|
77
75
|
fallbacks.forEach((fallback) => {
|
|
78
76
|
fallback({
|
|
79
77
|
hostDi,
|
|
@@ -83,7 +81,6 @@ class BaseChildAppContractManager {
|
|
|
83
81
|
}
|
|
84
82
|
}
|
|
85
83
|
async getChildProvidedContract(childAppName, contract) {
|
|
86
|
-
var _a, _b, _c, _d;
|
|
87
84
|
try {
|
|
88
85
|
// Resolve CHILD_APP_PRELOAD_MANAGER_TOKEN from DI to prevent circular dependency error
|
|
89
86
|
const childAppPreloadManager = this.appDi.get(CHILD_APP_PRELOAD_MANAGER_TOKEN);
|
|
@@ -105,23 +102,24 @@ class BaseChildAppContractManager {
|
|
|
105
102
|
if (!childProvidedContractsKeys.includes(contract.toString())) {
|
|
106
103
|
this.log.warn(`Contract "${contract}" is not provided in the "${childAppName}" Child App`);
|
|
107
104
|
}
|
|
108
|
-
const result = (
|
|
109
|
-
|
|
110
|
-
|
|
105
|
+
const result = (childAppDi?.get(optional(contract)) ??
|
|
106
|
+
// contract can be registered in host DI in fallback
|
|
107
|
+
this.getRequestHostDi()?.get(optional(contract)) ??
|
|
108
|
+
this.appDi.get(optional(contract)) ??
|
|
109
|
+
null);
|
|
111
110
|
if (isNil(result)) {
|
|
112
111
|
this.log.warn(`Contract "${contract}" is declared but not provided in the "${childAppName}" Child App or application contracts fallback`);
|
|
113
112
|
}
|
|
114
113
|
return result;
|
|
115
114
|
}
|
|
116
115
|
getChildDi(childAppName) {
|
|
117
|
-
var _a;
|
|
118
116
|
// Resolve CHILD_APP_RESOLVE_CONFIG_TOKEN from DI to prevent scope conflict warning
|
|
119
|
-
const resolveChildAppConfig = (
|
|
117
|
+
const resolveChildAppConfig = (this.getRequestHostDi() ?? this.appDi).get(CHILD_APP_RESOLVE_CONFIG_TOKEN);
|
|
120
118
|
const childAppConfig = resolveChildAppConfig({ name: childAppName });
|
|
121
119
|
// ContractManager has Singleton scope, and we need to get Request scope Child App DI container.
|
|
122
120
|
// At server-side it will be resolved from Async Local Storage, at client-side everything is Singleton
|
|
123
121
|
const childAppDiManager = this.getRequestChildDiManager();
|
|
124
|
-
const childAppDi = childAppDiManager
|
|
122
|
+
const childAppDi = childAppDiManager?.getChildDi(childAppConfig);
|
|
125
123
|
return childAppDi;
|
|
126
124
|
}
|
|
127
125
|
/**
|
|
@@ -130,9 +128,8 @@ class BaseChildAppContractManager {
|
|
|
130
128
|
* - `string` is used in case when `getChildProvidedContract` call this method
|
|
131
129
|
*/
|
|
132
130
|
getChildProvidedContracts(childAppNameOrDi) {
|
|
133
|
-
var _a;
|
|
134
131
|
const childAppDi = typeof childAppNameOrDi === 'string' ? this.getChildDi(childAppNameOrDi) : childAppNameOrDi;
|
|
135
|
-
const childProvidedContracts = flatten(
|
|
132
|
+
const childProvidedContracts = flatten(childAppDi?.get(optional(CHILD_PROVIDED_CONTRACTS)) ?? []);
|
|
136
133
|
return childProvidedContracts;
|
|
137
134
|
}
|
|
138
135
|
getHostProvidedContracts(childAppName) {
|
|
@@ -7,15 +7,14 @@ import { CHILD_APP_INTERNAL_CONFIG_TOKEN, IS_CHILD_APP_CONTRACTS_COMPATIBLE_TOKE
|
|
|
7
7
|
class BaseChildAppContractManager {
|
|
8
8
|
constructor({ appDi, hostProvidedContracts, hostRequiredContracts, logger, }) {
|
|
9
9
|
this.appDi = appDi;
|
|
10
|
-
this.hostProvidedContracts = hostProvidedContracts
|
|
11
|
-
this.hostRequiredContracts = hostRequiredContracts
|
|
10
|
+
this.hostProvidedContracts = hostProvidedContracts ?? [];
|
|
11
|
+
this.hostRequiredContracts = hostRequiredContracts ?? [];
|
|
12
12
|
this.log = logger('child-app:contract-manager');
|
|
13
13
|
}
|
|
14
14
|
registerChildContracts(childDi) {
|
|
15
|
-
var _a, _b;
|
|
16
15
|
const childAppConfig = childDi.get(CHILD_APP_INTERNAL_CONFIG_TOKEN);
|
|
17
16
|
const childHasContractsSupport = childDi.get(optional(IS_CHILD_APP_CONTRACTS_COMPATIBLE_TOKEN));
|
|
18
|
-
const childRequiredContracts = flatten(
|
|
17
|
+
const childRequiredContracts = flatten(childDi.get(optional(CHILD_REQUIRED_CONTRACTS)) ?? []);
|
|
19
18
|
const hostProvidedContracts = this.getHostProvidedContracts(childAppConfig.name);
|
|
20
19
|
const hostProvidedContractsKeys = hostProvidedContracts.map((c) => c.toString());
|
|
21
20
|
// if contracts unsupported, it is a legacy child app, and we need to register all possible contracts
|
|
@@ -44,7 +43,7 @@ class BaseChildAppContractManager {
|
|
|
44
43
|
message: `Missed contracts for "${childAppConfig.name}" Child App`,
|
|
45
44
|
missedContracts,
|
|
46
45
|
});
|
|
47
|
-
const fallbacks =
|
|
46
|
+
const fallbacks = childDi.get(optional(CHILD_CONTRACTS_FALLBACK)) ?? [];
|
|
48
47
|
fallbacks.forEach((fallback) => {
|
|
49
48
|
fallback({
|
|
50
49
|
childDi,
|
|
@@ -55,7 +54,6 @@ class BaseChildAppContractManager {
|
|
|
55
54
|
}
|
|
56
55
|
}
|
|
57
56
|
validateChildProvidedContracts(childDi) {
|
|
58
|
-
var _a;
|
|
59
57
|
const childAppConfig = childDi.get(CHILD_APP_INTERNAL_CONFIG_TOKEN);
|
|
60
58
|
const hostDi = this.getRequestHostDi();
|
|
61
59
|
const childProvidedContracts = this.getChildProvidedContracts(childDi);
|
|
@@ -73,7 +71,7 @@ class BaseChildAppContractManager {
|
|
|
73
71
|
message: `Missed contracts for application, required from "${childAppConfig.name}" Child App`,
|
|
74
72
|
missedContracts,
|
|
75
73
|
});
|
|
76
|
-
const fallbacks =
|
|
74
|
+
const fallbacks = hostDi.get(optional(HOST_CONTRACTS_FALLBACK)) ?? [];
|
|
77
75
|
fallbacks.forEach((fallback) => {
|
|
78
76
|
fallback({
|
|
79
77
|
hostDi,
|
|
@@ -83,7 +81,6 @@ class BaseChildAppContractManager {
|
|
|
83
81
|
}
|
|
84
82
|
}
|
|
85
83
|
async getChildProvidedContract(childAppName, contract) {
|
|
86
|
-
var _a, _b, _c, _d;
|
|
87
84
|
try {
|
|
88
85
|
// Resolve CHILD_APP_PRELOAD_MANAGER_TOKEN from DI to prevent circular dependency error
|
|
89
86
|
const childAppPreloadManager = this.appDi.get(CHILD_APP_PRELOAD_MANAGER_TOKEN);
|
|
@@ -105,23 +102,24 @@ class BaseChildAppContractManager {
|
|
|
105
102
|
if (!childProvidedContractsKeys.includes(contract.toString())) {
|
|
106
103
|
this.log.warn(`Contract "${contract}" is not provided in the "${childAppName}" Child App`);
|
|
107
104
|
}
|
|
108
|
-
const result = (
|
|
109
|
-
|
|
110
|
-
|
|
105
|
+
const result = (childAppDi?.get(optional(contract)) ??
|
|
106
|
+
// contract can be registered in host DI in fallback
|
|
107
|
+
this.getRequestHostDi()?.get(optional(contract)) ??
|
|
108
|
+
this.appDi.get(optional(contract)) ??
|
|
109
|
+
null);
|
|
111
110
|
if (isNil(result)) {
|
|
112
111
|
this.log.warn(`Contract "${contract}" is declared but not provided in the "${childAppName}" Child App or application contracts fallback`);
|
|
113
112
|
}
|
|
114
113
|
return result;
|
|
115
114
|
}
|
|
116
115
|
getChildDi(childAppName) {
|
|
117
|
-
var _a;
|
|
118
116
|
// Resolve CHILD_APP_RESOLVE_CONFIG_TOKEN from DI to prevent scope conflict warning
|
|
119
|
-
const resolveChildAppConfig = (
|
|
117
|
+
const resolveChildAppConfig = (this.getRequestHostDi() ?? this.appDi).get(CHILD_APP_RESOLVE_CONFIG_TOKEN);
|
|
120
118
|
const childAppConfig = resolveChildAppConfig({ name: childAppName });
|
|
121
119
|
// ContractManager has Singleton scope, and we need to get Request scope Child App DI container.
|
|
122
120
|
// At server-side it will be resolved from Async Local Storage, at client-side everything is Singleton
|
|
123
121
|
const childAppDiManager = this.getRequestChildDiManager();
|
|
124
|
-
const childAppDi = childAppDiManager
|
|
122
|
+
const childAppDi = childAppDiManager?.getChildDi(childAppConfig);
|
|
125
123
|
return childAppDi;
|
|
126
124
|
}
|
|
127
125
|
/**
|
|
@@ -130,9 +128,8 @@ class BaseChildAppContractManager {
|
|
|
130
128
|
* - `string` is used in case when `getChildProvidedContract` call this method
|
|
131
129
|
*/
|
|
132
130
|
getChildProvidedContracts(childAppNameOrDi) {
|
|
133
|
-
var _a;
|
|
134
131
|
const childAppDi = typeof childAppNameOrDi === 'string' ? this.getChildDi(childAppNameOrDi) : childAppNameOrDi;
|
|
135
|
-
const childProvidedContracts = flatten(
|
|
132
|
+
const childProvidedContracts = flatten(childAppDi?.get(optional(CHILD_PROVIDED_CONTRACTS)) ?? []);
|
|
136
133
|
return childProvidedContracts;
|
|
137
134
|
}
|
|
138
135
|
getHostProvidedContracts(childAppName) {
|
|
@@ -16,15 +16,14 @@ var isNil__default = /*#__PURE__*/_interopDefaultLegacy(isNil);
|
|
|
16
16
|
class BaseChildAppContractManager {
|
|
17
17
|
constructor({ appDi, hostProvidedContracts, hostRequiredContracts, logger, }) {
|
|
18
18
|
this.appDi = appDi;
|
|
19
|
-
this.hostProvidedContracts = hostProvidedContracts
|
|
20
|
-
this.hostRequiredContracts = hostRequiredContracts
|
|
19
|
+
this.hostProvidedContracts = hostProvidedContracts ?? [];
|
|
20
|
+
this.hostRequiredContracts = hostRequiredContracts ?? [];
|
|
21
21
|
this.log = logger('child-app:contract-manager');
|
|
22
22
|
}
|
|
23
23
|
registerChildContracts(childDi) {
|
|
24
|
-
var _a, _b;
|
|
25
24
|
const childAppConfig = childDi.get(tokensChildApp.CHILD_APP_INTERNAL_CONFIG_TOKEN);
|
|
26
25
|
const childHasContractsSupport = childDi.get(dippy.optional(tokensChildApp.IS_CHILD_APP_CONTRACTS_COMPATIBLE_TOKEN));
|
|
27
|
-
const childRequiredContracts = flatten__default["default"](
|
|
26
|
+
const childRequiredContracts = flatten__default["default"](childDi.get(dippy.optional(tokensChildApp.CHILD_REQUIRED_CONTRACTS)) ?? []);
|
|
28
27
|
const hostProvidedContracts = this.getHostProvidedContracts(childAppConfig.name);
|
|
29
28
|
const hostProvidedContractsKeys = hostProvidedContracts.map((c) => c.toString());
|
|
30
29
|
// if contracts unsupported, it is a legacy child app, and we need to register all possible contracts
|
|
@@ -53,7 +52,7 @@ class BaseChildAppContractManager {
|
|
|
53
52
|
message: `Missed contracts for "${childAppConfig.name}" Child App`,
|
|
54
53
|
missedContracts,
|
|
55
54
|
});
|
|
56
|
-
const fallbacks =
|
|
55
|
+
const fallbacks = childDi.get(dippy.optional(tokensChildApp.CHILD_CONTRACTS_FALLBACK)) ?? [];
|
|
57
56
|
fallbacks.forEach((fallback) => {
|
|
58
57
|
fallback({
|
|
59
58
|
childDi,
|
|
@@ -64,7 +63,6 @@ class BaseChildAppContractManager {
|
|
|
64
63
|
}
|
|
65
64
|
}
|
|
66
65
|
validateChildProvidedContracts(childDi) {
|
|
67
|
-
var _a;
|
|
68
66
|
const childAppConfig = childDi.get(tokensChildApp.CHILD_APP_INTERNAL_CONFIG_TOKEN);
|
|
69
67
|
const hostDi = this.getRequestHostDi();
|
|
70
68
|
const childProvidedContracts = this.getChildProvidedContracts(childDi);
|
|
@@ -82,7 +80,7 @@ class BaseChildAppContractManager {
|
|
|
82
80
|
message: `Missed contracts for application, required from "${childAppConfig.name}" Child App`,
|
|
83
81
|
missedContracts,
|
|
84
82
|
});
|
|
85
|
-
const fallbacks =
|
|
83
|
+
const fallbacks = hostDi.get(dippy.optional(tokensChildApp.HOST_CONTRACTS_FALLBACK)) ?? [];
|
|
86
84
|
fallbacks.forEach((fallback) => {
|
|
87
85
|
fallback({
|
|
88
86
|
hostDi,
|
|
@@ -92,7 +90,6 @@ class BaseChildAppContractManager {
|
|
|
92
90
|
}
|
|
93
91
|
}
|
|
94
92
|
async getChildProvidedContract(childAppName, contract) {
|
|
95
|
-
var _a, _b, _c, _d;
|
|
96
93
|
try {
|
|
97
94
|
// Resolve CHILD_APP_PRELOAD_MANAGER_TOKEN from DI to prevent circular dependency error
|
|
98
95
|
const childAppPreloadManager = this.appDi.get(tokensChildApp.CHILD_APP_PRELOAD_MANAGER_TOKEN);
|
|
@@ -114,23 +111,24 @@ class BaseChildAppContractManager {
|
|
|
114
111
|
if (!childProvidedContractsKeys.includes(contract.toString())) {
|
|
115
112
|
this.log.warn(`Contract "${contract}" is not provided in the "${childAppName}" Child App`);
|
|
116
113
|
}
|
|
117
|
-
const result = (
|
|
118
|
-
|
|
119
|
-
|
|
114
|
+
const result = (childAppDi?.get(dippy.optional(contract)) ??
|
|
115
|
+
// contract can be registered in host DI in fallback
|
|
116
|
+
this.getRequestHostDi()?.get(dippy.optional(contract)) ??
|
|
117
|
+
this.appDi.get(dippy.optional(contract)) ??
|
|
118
|
+
null);
|
|
120
119
|
if (isNil__default["default"](result)) {
|
|
121
120
|
this.log.warn(`Contract "${contract}" is declared but not provided in the "${childAppName}" Child App or application contracts fallback`);
|
|
122
121
|
}
|
|
123
122
|
return result;
|
|
124
123
|
}
|
|
125
124
|
getChildDi(childAppName) {
|
|
126
|
-
var _a;
|
|
127
125
|
// Resolve CHILD_APP_RESOLVE_CONFIG_TOKEN from DI to prevent scope conflict warning
|
|
128
|
-
const resolveChildAppConfig = (
|
|
126
|
+
const resolveChildAppConfig = (this.getRequestHostDi() ?? this.appDi).get(tokensChildApp.CHILD_APP_RESOLVE_CONFIG_TOKEN);
|
|
129
127
|
const childAppConfig = resolveChildAppConfig({ name: childAppName });
|
|
130
128
|
// ContractManager has Singleton scope, and we need to get Request scope Child App DI container.
|
|
131
129
|
// At server-side it will be resolved from Async Local Storage, at client-side everything is Singleton
|
|
132
130
|
const childAppDiManager = this.getRequestChildDiManager();
|
|
133
|
-
const childAppDi = childAppDiManager
|
|
131
|
+
const childAppDi = childAppDiManager?.getChildDi(childAppConfig);
|
|
134
132
|
return childAppDi;
|
|
135
133
|
}
|
|
136
134
|
/**
|
|
@@ -139,9 +137,8 @@ class BaseChildAppContractManager {
|
|
|
139
137
|
* - `string` is used in case when `getChildProvidedContract` call this method
|
|
140
138
|
*/
|
|
141
139
|
getChildProvidedContracts(childAppNameOrDi) {
|
|
142
|
-
var _a;
|
|
143
140
|
const childAppDi = typeof childAppNameOrDi === 'string' ? this.getChildDi(childAppNameOrDi) : childAppNameOrDi;
|
|
144
|
-
const childProvidedContracts = flatten__default["default"](
|
|
141
|
+
const childProvidedContracts = flatten__default["default"](childAppDi?.get(dippy.optional(tokensChildApp.CHILD_PROVIDED_CONTRACTS)) ?? []);
|
|
145
142
|
return childProvidedContracts;
|
|
146
143
|
}
|
|
147
144
|
getHostProvidedContracts(childAppName) {
|
|
@@ -17,8 +17,8 @@ class ChildAppContractManager extends BaseChildAppContractManager {
|
|
|
17
17
|
childDi.register(provide({
|
|
18
18
|
provide: contract,
|
|
19
19
|
useFactory: () => {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
const value = this.asyncLocalStorage.getStore()?.tramvaiRequestDi?.get(optional(contract)) ??
|
|
21
|
+
this.appDi.get(optional(contract));
|
|
22
22
|
if (isNil(value)) {
|
|
23
23
|
const { name } = childDi.get(CHILD_APP_INTERNAL_CONFIG_TOKEN);
|
|
24
24
|
this.log.warn(`Contract "${contract}" for "${name}" Child App is declared but not provided in the application or contracts fallback`);
|
|
@@ -29,13 +29,12 @@ class ChildAppContractManager extends BaseChildAppContractManager {
|
|
|
29
29
|
}));
|
|
30
30
|
}
|
|
31
31
|
getRequestHostDi() {
|
|
32
|
-
|
|
33
|
-
return (_b = (_a = this.asyncLocalStorage.getStore()) === null || _a === void 0 ? void 0 : _a.tramvaiRequestDi) !== null && _b !== void 0 ? _b : null;
|
|
32
|
+
return this.asyncLocalStorage.getStore()?.tramvaiRequestDi ?? null;
|
|
34
33
|
}
|
|
35
34
|
getRequestChildDiManager() {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
return (this.asyncLocalStorage
|
|
36
|
+
.getStore()
|
|
37
|
+
?.tramvaiRequestDi?.get(optional(CHILD_APP_DI_MANAGER_TOKEN)) ?? null);
|
|
39
38
|
}
|
|
40
39
|
}
|
|
41
40
|
|
|
@@ -25,8 +25,8 @@ class ChildAppContractManager extends contractManager_base.BaseChildAppContractM
|
|
|
25
25
|
childDi.register(dippy.provide({
|
|
26
26
|
provide: contract,
|
|
27
27
|
useFactory: () => {
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
const value = this.asyncLocalStorage.getStore()?.tramvaiRequestDi?.get(dippy.optional(contract)) ??
|
|
29
|
+
this.appDi.get(dippy.optional(contract));
|
|
30
30
|
if (isNil__default["default"](value)) {
|
|
31
31
|
const { name } = childDi.get(tokensChildApp.CHILD_APP_INTERNAL_CONFIG_TOKEN);
|
|
32
32
|
this.log.warn(`Contract "${contract}" for "${name}" Child App is declared but not provided in the application or contracts fallback`);
|
|
@@ -37,13 +37,12 @@ class ChildAppContractManager extends contractManager_base.BaseChildAppContractM
|
|
|
37
37
|
}));
|
|
38
38
|
}
|
|
39
39
|
getRequestHostDi() {
|
|
40
|
-
|
|
41
|
-
return (_b = (_a = this.asyncLocalStorage.getStore()) === null || _a === void 0 ? void 0 : _a.tramvaiRequestDi) !== null && _b !== void 0 ? _b : null;
|
|
40
|
+
return this.asyncLocalStorage.getStore()?.tramvaiRequestDi ?? null;
|
|
42
41
|
}
|
|
43
42
|
getRequestChildDiManager() {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
return (this.asyncLocalStorage
|
|
44
|
+
.getStore()
|
|
45
|
+
?.tramvaiRequestDi?.get(dippy.optional(tokensChildApp.CHILD_APP_DI_MANAGER_TOKEN)) ?? null);
|
|
47
46
|
}
|
|
48
47
|
}
|
|
49
48
|
|
package/lib/server/preload.es.js
CHANGED
|
@@ -32,7 +32,7 @@ class PreloadManager {
|
|
|
32
32
|
.then(async () => {
|
|
33
33
|
// preload child app page component - we need to register page actions before running all child app actions
|
|
34
34
|
const di = this.diManager.getChildDi(config);
|
|
35
|
-
const childAppPageService = di
|
|
35
|
+
const childAppPageService = di?.get(optional(CHILD_APP_PAGE_SERVICE_TOKEN));
|
|
36
36
|
if (childAppPageService) {
|
|
37
37
|
await childAppPageService.resolveComponent();
|
|
38
38
|
}
|
package/lib/server/preload.js
CHANGED
|
@@ -36,7 +36,7 @@ class PreloadManager {
|
|
|
36
36
|
.then(async () => {
|
|
37
37
|
// preload child app page component - we need to register page actions before running all child app actions
|
|
38
38
|
const di = this.diManager.getChildDi(config);
|
|
39
|
-
const childAppPageService = di
|
|
39
|
+
const childAppPageService = di?.get(dippy.optional(tokensChildApp.CHILD_APP_PAGE_SERVICE_TOKEN));
|
|
40
40
|
if (childAppPageService) {
|
|
41
41
|
await childAppPageService.resolveComponent();
|
|
42
42
|
}
|
|
@@ -90,23 +90,24 @@ const registerChildAppRenderSlots = ({ logger, diManager, resolveFullConfig, pre
|
|
|
90
90
|
}
|
|
91
91
|
// eslint-disable-next-line max-statements
|
|
92
92
|
preloadedList.forEach((requestConfig) => {
|
|
93
|
-
var _a, _b, _c, _d;
|
|
94
93
|
const config = resolveFullConfig(requestConfig);
|
|
95
94
|
if (!config) {
|
|
96
95
|
return;
|
|
97
96
|
}
|
|
98
97
|
const stats = 'getStats' in loader ? loader.getStats(config) : undefined;
|
|
99
98
|
const di = diManager.getChildDi(config);
|
|
100
|
-
const loadableAssets =
|
|
99
|
+
const loadableAssets = di?.get(CHILD_APP_INTERNAL_CHUNK_EXTRACTOR)?.getMainAssets();
|
|
101
100
|
addChunk(config.client.entry, true);
|
|
102
101
|
if (config.css) {
|
|
103
102
|
addChunk(config.css.entry);
|
|
104
103
|
}
|
|
105
|
-
loadableAssets
|
|
106
|
-
|
|
104
|
+
loadableAssets
|
|
105
|
+
?.map((asset) => resolve(config.client.baseUrl, asset.filename))
|
|
106
|
+
.filter((file) => {
|
|
107
107
|
// filter entry js and css chunks
|
|
108
|
-
return config.client.entry !== file &&
|
|
109
|
-
})
|
|
108
|
+
return config.client.entry !== file && config.css?.entry !== file;
|
|
109
|
+
})
|
|
110
|
+
.forEach((file) => {
|
|
110
111
|
addChunk(file);
|
|
111
112
|
});
|
|
112
113
|
if (stats && stats.federatedModules) {
|
|
@@ -114,7 +115,7 @@ const registerChildAppRenderSlots = ({ logger, diManager, resolveFullConfig, pre
|
|
|
114
115
|
// entries are duplicated in the `exposes` field of federated stats for some reason
|
|
115
116
|
// for now there anyway should be only one exposed entry so took the first available
|
|
116
117
|
const files = new Set();
|
|
117
|
-
|
|
118
|
+
federatedModule?.exposes?.entry?.forEach((entry) => {
|
|
118
119
|
for (const key in entry) {
|
|
119
120
|
entry[key].forEach((file) => files.add(file));
|
|
120
121
|
}
|
|
@@ -123,10 +124,10 @@ const registerChildAppRenderSlots = ({ logger, diManager, resolveFullConfig, pre
|
|
|
123
124
|
addChunk(resolve(config.client.baseUrl, file));
|
|
124
125
|
}
|
|
125
126
|
for (const sharedModule of federatedModule.sharedModules) {
|
|
126
|
-
const { shareKey } =
|
|
127
|
+
const { shareKey } = sharedModule.provides?.[0];
|
|
127
128
|
const { chunks } = sharedModule;
|
|
128
129
|
const bestShared = mapSharedToChildApp.get(shareKey);
|
|
129
|
-
if (!
|
|
130
|
+
if (!bestShared?.eager && bestShared?.name === config.name) {
|
|
130
131
|
for (const chunk of chunks) {
|
|
131
132
|
addChunk(resolve(config.client.baseUrl, chunk));
|
|
132
133
|
}
|
|
@@ -98,23 +98,24 @@ const registerChildAppRenderSlots = ({ logger, diManager, resolveFullConfig, pre
|
|
|
98
98
|
}
|
|
99
99
|
// eslint-disable-next-line max-statements
|
|
100
100
|
preloadedList.forEach((requestConfig) => {
|
|
101
|
-
var _a, _b, _c, _d;
|
|
102
101
|
const config = resolveFullConfig(requestConfig);
|
|
103
102
|
if (!config) {
|
|
104
103
|
return;
|
|
105
104
|
}
|
|
106
105
|
const stats = 'getStats' in loader ? loader.getStats(config) : undefined;
|
|
107
106
|
const di = diManager.getChildDi(config);
|
|
108
|
-
const loadableAssets =
|
|
107
|
+
const loadableAssets = di?.get(tokensChildApp.CHILD_APP_INTERNAL_CHUNK_EXTRACTOR)?.getMainAssets();
|
|
109
108
|
addChunk(config.client.entry, true);
|
|
110
109
|
if (config.css) {
|
|
111
110
|
addChunk(config.css.entry);
|
|
112
111
|
}
|
|
113
|
-
loadableAssets
|
|
114
|
-
|
|
112
|
+
loadableAssets
|
|
113
|
+
?.map((asset) => url.resolve(config.client.baseUrl, asset.filename))
|
|
114
|
+
.filter((file) => {
|
|
115
115
|
// filter entry js and css chunks
|
|
116
|
-
return config.client.entry !== file &&
|
|
117
|
-
})
|
|
116
|
+
return config.client.entry !== file && config.css?.entry !== file;
|
|
117
|
+
})
|
|
118
|
+
.forEach((file) => {
|
|
118
119
|
addChunk(file);
|
|
119
120
|
});
|
|
120
121
|
if (stats && stats.federatedModules) {
|
|
@@ -122,7 +123,7 @@ const registerChildAppRenderSlots = ({ logger, diManager, resolveFullConfig, pre
|
|
|
122
123
|
// entries are duplicated in the `exposes` field of federated stats for some reason
|
|
123
124
|
// for now there anyway should be only one exposed entry so took the first available
|
|
124
125
|
const files = new Set();
|
|
125
|
-
|
|
126
|
+
federatedModule?.exposes?.entry?.forEach((entry) => {
|
|
126
127
|
for (const key in entry) {
|
|
127
128
|
entry[key].forEach((file) => files.add(file));
|
|
128
129
|
}
|
|
@@ -131,10 +132,10 @@ const registerChildAppRenderSlots = ({ logger, diManager, resolveFullConfig, pre
|
|
|
131
132
|
addChunk(url.resolve(config.client.baseUrl, file));
|
|
132
133
|
}
|
|
133
134
|
for (const sharedModule of federatedModule.sharedModules) {
|
|
134
|
-
const { shareKey } =
|
|
135
|
+
const { shareKey } = sharedModule.provides?.[0];
|
|
135
136
|
const { chunks } = sharedModule;
|
|
136
137
|
const bestShared = mapSharedToChildApp.get(shareKey);
|
|
137
|
-
if (!
|
|
138
|
+
if (!bestShared?.eager && bestShared?.name === config.name) {
|
|
138
139
|
for (const chunk of chunks) {
|
|
139
140
|
addChunk(url.resolve(config.client.baseUrl, chunk));
|
|
140
141
|
}
|
|
@@ -9,7 +9,7 @@ const executeRootStateSubscriptions = ({ store, diManager, }) => {
|
|
|
9
9
|
token: CHILD_APP_INTERNAL_ROOT_STATE_SUBSCRIPTION_TOKEN,
|
|
10
10
|
optional: true,
|
|
11
11
|
});
|
|
12
|
-
subscriptions
|
|
12
|
+
subscriptions?.forEach((sub) => {
|
|
13
13
|
sub.listener(state);
|
|
14
14
|
});
|
|
15
15
|
});
|
|
@@ -13,7 +13,7 @@ const executeRootStateSubscriptions = ({ store, diManager, }) => {
|
|
|
13
13
|
token: tokensChildApp.CHILD_APP_INTERNAL_ROOT_STATE_SUBSCRIPTION_TOKEN,
|
|
14
14
|
optional: true,
|
|
15
15
|
});
|
|
16
|
-
subscriptions
|
|
16
|
+
subscriptions?.forEach((sub) => {
|
|
17
17
|
sub.listener(state);
|
|
18
18
|
});
|
|
19
19
|
});
|
|
@@ -7,7 +7,7 @@ const extractorProviders = (loadableStats) => [
|
|
|
7
7
|
provide: CHILD_APP_INTERNAL_CHUNK_EXTRACTOR,
|
|
8
8
|
scope: Scope.REQUEST,
|
|
9
9
|
useFactory: () => {
|
|
10
|
-
return new ChunkExtractor({ stats: loadableStats
|
|
10
|
+
return new ChunkExtractor({ stats: loadableStats ?? {}, entrypoints: [] });
|
|
11
11
|
},
|
|
12
12
|
}),
|
|
13
13
|
];
|
|
@@ -11,7 +11,7 @@ const extractorProviders = (loadableStats) => [
|
|
|
11
11
|
provide: tokensChildApp.CHILD_APP_INTERNAL_CHUNK_EXTRACTOR,
|
|
12
12
|
scope: core.Scope.REQUEST,
|
|
13
13
|
useFactory: () => {
|
|
14
|
-
return new server.ChunkExtractor({ stats: loadableStats
|
|
14
|
+
return new server.ChunkExtractor({ stats: loadableStats ?? {}, entrypoints: [] });
|
|
15
15
|
},
|
|
16
16
|
}),
|
|
17
17
|
];
|
|
@@ -71,14 +71,16 @@ const getChildProviders = (appDi, loadableStats) => {
|
|
|
71
71
|
provide: DISPATCHER_CONTEXT_TOKEN,
|
|
72
72
|
scope: Scope.REQUEST,
|
|
73
73
|
useFactory: ({ dispatcher, middlewares, initialState, parentAllowedStores }) => {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
const parentDispatcherContext = appDi
|
|
75
|
+
.get(optional(ASYNC_LOCAL_STORAGE_TOKEN))
|
|
76
|
+
?.getStore()
|
|
77
|
+
?.tramvaiRequestDi?.get(DISPATCHER_CONTEXT_TOKEN) ??
|
|
78
|
+
appDi.get(DISPATCHER_CONTEXT_TOKEN);
|
|
77
79
|
return new ChildDispatcherContext({
|
|
78
80
|
dispatcher,
|
|
79
81
|
// context will be set later by the CONTEXT_TOKEN
|
|
80
82
|
context: {},
|
|
81
|
-
initialState: initialState
|
|
83
|
+
initialState: initialState ?? { stores: [] },
|
|
82
84
|
middlewares: flatten(middlewares || []),
|
|
83
85
|
parentDispatcherContext,
|
|
84
86
|
parentAllowedStores: flatten(parentAllowedStores || []),
|
|
@@ -71,14 +71,16 @@ const getChildProviders = (appDi, loadableStats) => {
|
|
|
71
71
|
provide: DISPATCHER_CONTEXT_TOKEN,
|
|
72
72
|
scope: Scope.REQUEST,
|
|
73
73
|
useFactory: ({ dispatcher, middlewares, initialState, parentAllowedStores }) => {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
const parentDispatcherContext = appDi
|
|
75
|
+
.get(optional(ASYNC_LOCAL_STORAGE_TOKEN))
|
|
76
|
+
?.getStore()
|
|
77
|
+
?.tramvaiRequestDi?.get(DISPATCHER_CONTEXT_TOKEN) ??
|
|
78
|
+
appDi.get(DISPATCHER_CONTEXT_TOKEN);
|
|
77
79
|
return new ChildDispatcherContext({
|
|
78
80
|
dispatcher,
|
|
79
81
|
// context will be set later by the CONTEXT_TOKEN
|
|
80
82
|
context: {},
|
|
81
|
-
initialState: initialState
|
|
83
|
+
initialState: initialState ?? { stores: [] },
|
|
82
84
|
middlewares: flatten(middlewares || []),
|
|
83
85
|
parentDispatcherContext,
|
|
84
86
|
parentAllowedStores: flatten(parentAllowedStores || []),
|
|
@@ -79,14 +79,16 @@ const getChildProviders = (appDi, loadableStats) => {
|
|
|
79
79
|
provide: tokensCommon.DISPATCHER_CONTEXT_TOKEN,
|
|
80
80
|
scope: core.Scope.REQUEST,
|
|
81
81
|
useFactory: ({ dispatcher, middlewares, initialState, parentAllowedStores }) => {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
const parentDispatcherContext = appDi
|
|
83
|
+
.get(core.optional(tokensCommon.ASYNC_LOCAL_STORAGE_TOKEN))
|
|
84
|
+
?.getStore()
|
|
85
|
+
?.tramvaiRequestDi?.get(tokensCommon.DISPATCHER_CONTEXT_TOKEN) ??
|
|
86
|
+
appDi.get(tokensCommon.DISPATCHER_CONTEXT_TOKEN);
|
|
85
87
|
return new state.ChildDispatcherContext({
|
|
86
88
|
dispatcher,
|
|
87
89
|
// context will be set later by the CONTEXT_TOKEN
|
|
88
90
|
context: {},
|
|
89
|
-
initialState: initialState
|
|
91
|
+
initialState: initialState ?? { stores: [] },
|
|
90
92
|
middlewares: flatten__default["default"](middlewares || []),
|
|
91
93
|
parentDispatcherContext,
|
|
92
94
|
parentAllowedStores: flatten__default["default"](parentAllowedStores || []),
|
|
@@ -10,7 +10,7 @@ const pagePreload = async ({ pageService, preloadManager, }, mode, isSpaNavigati
|
|
|
10
10
|
resolveLazyComponent(pageService.resolveComponentFromConfig('page', route)),
|
|
11
11
|
]);
|
|
12
12
|
await Promise.all(components.map(async (component) => {
|
|
13
|
-
if (component
|
|
13
|
+
if (component?.childApps) {
|
|
14
14
|
await Promise.all(component.childApps.map((request) => {
|
|
15
15
|
// for first preload on SPA-navigation, we need to prevent double action execution,
|
|
16
16
|
// and need to mark this Child App as not preloaded, to prevent running `spa` and `afterSpa` commands for it
|
|
@@ -10,7 +10,7 @@ const pagePreload = async ({ pageService, preloadManager, }, mode, isSpaNavigati
|
|
|
10
10
|
resolveLazyComponent(pageService.resolveComponentFromConfig('page', route)),
|
|
11
11
|
]);
|
|
12
12
|
await Promise.all(components.map(async (component) => {
|
|
13
|
-
if (component
|
|
13
|
+
if (component?.childApps) {
|
|
14
14
|
await Promise.all(component.childApps.map((request) => {
|
|
15
15
|
// for first preload on SPA-navigation, we need to prevent double action execution,
|
|
16
16
|
// and need to mark this Child App as not preloaded, to prevent running `spa` and `afterSpa` commands for it
|
|
@@ -14,7 +14,7 @@ const pagePreload = async ({ pageService, preloadManager, }, mode, isSpaNavigati
|
|
|
14
14
|
react.resolveLazyComponent(pageService.resolveComponentFromConfig('page', route)),
|
|
15
15
|
]);
|
|
16
16
|
await Promise.all(components.map(async (component) => {
|
|
17
|
-
if (component
|
|
17
|
+
if (component?.childApps) {
|
|
18
18
|
await Promise.all(component.childApps.map((request) => {
|
|
19
19
|
// for first preload on SPA-navigation, we need to prevent double action execution,
|
|
20
20
|
// and need to mark this Child App as not preloaded, to prevent running `spa` and `afterSpa` commands for it
|
|
@@ -50,9 +50,8 @@ class ChildAppPageService {
|
|
|
50
50
|
];
|
|
51
51
|
}
|
|
52
52
|
getPageComponentName(route) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return config === null || config === void 0 ? void 0 : config.unstable_childAppPageComponent;
|
|
53
|
+
const config = route?.config ?? this.pageService.getConfig();
|
|
54
|
+
return config?.unstable_childAppPageComponent;
|
|
56
55
|
}
|
|
57
56
|
getComponentsGroupName() {
|
|
58
57
|
return `${this.config.name}@${this.config.version}`;
|
|
@@ -50,9 +50,8 @@ class ChildAppPageService {
|
|
|
50
50
|
];
|
|
51
51
|
}
|
|
52
52
|
getPageComponentName(route) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return config === null || config === void 0 ? void 0 : config.unstable_childAppPageComponent;
|
|
53
|
+
const config = route?.config ?? this.pageService.getConfig();
|
|
54
|
+
return config?.unstable_childAppPageComponent;
|
|
56
55
|
}
|
|
57
56
|
getComponentsGroupName() {
|
|
58
57
|
return `${this.config.name}@${this.config.version}`;
|
|
@@ -58,9 +58,8 @@ class ChildAppPageService {
|
|
|
58
58
|
];
|
|
59
59
|
}
|
|
60
60
|
getPageComponentName(route) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return config === null || config === void 0 ? void 0 : config.unstable_childAppPageComponent;
|
|
61
|
+
const config = route?.config ?? this.pageService.getConfig();
|
|
62
|
+
return config?.unstable_childAppPageComponent;
|
|
64
63
|
}
|
|
65
64
|
getComponentsGroupName() {
|
|
66
65
|
return `${this.config.name}@${this.config.version}`;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Scope, DI_TOKEN, optional } from '@tinkoff/dippy';
|
|
2
2
|
import { provide, commandLineListTokens, COMMAND_LINE_RUNNER_TOKEN } from '@tramvai/core';
|
|
3
|
-
import { CHILD_APP_RESOLUTION_CONFIG_MANAGER_TOKEN, CHILD_APP_RESOLUTION_CONFIGS_TOKEN, CHILD_APP_RESOLVE_CONFIG_TOKEN, CHILD_APP_RESOLVE_BASE_URL_TOKEN, CHILD_APP_SINGLETON_DI_MANAGER_TOKEN, CHILD_APP_LOADER_TOKEN, CHILD_APP_ROOT_DI_ACCESS_MODE_TOKEN, CHILD_APP_CONTRACT_MANAGER, CHILD_APP_DI_MANAGER_TOKEN, CHILD_APP_COMMAND_LINE_RUNNER_TOKEN, CHILD_APP_PRELOAD_MANAGER_TOKEN, CHILD_APP_RENDER_MANAGER_TOKEN, HOST_PROVIDED_CONTRACTS } from '@tramvai/tokens-child-app';
|
|
3
|
+
import { CHILD_APP_RESOLUTION_CONFIG_MANAGER_TOKEN, CHILD_APP_RESOLUTION_CONFIGS_TOKEN, CHILD_APP_RESOLVE_CONFIG_TOKEN, CHILD_APP_RESOLVE_BASE_URL_TOKEN, CHILD_APP_SINGLETON_DI_MANAGER_TOKEN, CHILD_APP_LOADER_TOKEN, CHILD_APP_ROOT_DI_ACCESS_MODE_TOKEN, CHILD_APP_CONTRACT_MANAGER, CHILD_APP_DI_MANAGER_TOKEN, CHILD_APP_COMMAND_LINE_RUNNER_TOKEN, CHILD_APP_PRELOAD_MANAGER_TOKEN, CHILD_APP_RENDER_MANAGER_TOKEN, HOST_PROVIDED_CONTRACTS, CHILD_APP_ERROR_BOUNDARY_TOKEN } from '@tramvai/tokens-child-app';
|
|
4
4
|
import { COMBINE_REDUCERS, LOGGER_TOKEN, ENV_MANAGER_TOKEN, REGISTER_CLEAR_CACHE_TOKEN, CLEAR_CACHE_TOKEN, ENV_USED_TOKEN, COMPONENT_REGISTRY_TOKEN, LIMIT_ACTION_GLOBAL_TIME_RUN, ACTION_CONDITIONALS } from '@tramvai/tokens-common';
|
|
5
5
|
import { EXTEND_RENDER } from '@tramvai/tokens-render';
|
|
6
6
|
import { ROUTER_TOKEN, PAGE_SERVICE_TOKEN, LINK_PREFETCH_MANAGER_TOKEN, ROUTER_SPA_ACTIONS_RUN_MODE_TOKEN } from '@tramvai/tokens-router';
|
|
@@ -51,12 +51,11 @@ const sharedProviders = [
|
|
|
51
51
|
const rawEnv = envManager.get('CHILD_APP_DEBUG');
|
|
52
52
|
const log = logger('child-app:resolve-config');
|
|
53
53
|
const debug = new Map();
|
|
54
|
-
rawEnv
|
|
54
|
+
rawEnv?.split(';').reduce((acc, entry) => {
|
|
55
55
|
const [name, url] = entry.split('=');
|
|
56
56
|
return acc.set(name, url);
|
|
57
57
|
}, debug);
|
|
58
58
|
return (request) => {
|
|
59
|
-
var _a, _b;
|
|
60
59
|
const { name, tag = debug.has(name) ? 'debug' : 'latest' } = request;
|
|
61
60
|
const req = { name, tag, version: request.version };
|
|
62
61
|
const config = resolutionConfigManager.resolve(req);
|
|
@@ -65,7 +64,7 @@ const sharedProviders = [
|
|
|
65
64
|
return;
|
|
66
65
|
}
|
|
67
66
|
const { version, baseUrl: configBaseUrl, client, server, css, withoutCss } = config;
|
|
68
|
-
const baseUrl =
|
|
67
|
+
const baseUrl = debug.get(name) ?? configBaseUrl ?? rootBaseUrl;
|
|
69
68
|
if (!baseUrl) {
|
|
70
69
|
throw new Error('CHILD_APP_EXTERNAL_URL was not defined');
|
|
71
70
|
}
|
|
@@ -173,17 +172,16 @@ const sharedProviders = [
|
|
|
173
172
|
useFactory: ({ diManager }) => {
|
|
174
173
|
return (type) => {
|
|
175
174
|
diManager.forEachChildDi((di) => {
|
|
176
|
-
var _a;
|
|
177
175
|
const clearCache = di.get({ token: CLEAR_CACHE_TOKEN, optional: true });
|
|
178
176
|
if (clearCache) {
|
|
179
177
|
// first if child-app has its own CLEAR_CACHE_TOKEN implementation use only it
|
|
180
178
|
return clearCache(type);
|
|
181
179
|
}
|
|
182
180
|
// otherwise pick up any REGISTER_CLEAR_CACHE_TOKEN hooks and call it
|
|
183
|
-
const registeredClearCache =
|
|
181
|
+
const registeredClearCache = di.get({
|
|
184
182
|
token: REGISTER_CLEAR_CACHE_TOKEN,
|
|
185
183
|
optional: true,
|
|
186
|
-
})
|
|
184
|
+
}) ?? [];
|
|
187
185
|
return Promise.all(registeredClearCache.map((clear) => clear(type)));
|
|
188
186
|
});
|
|
189
187
|
};
|
|
@@ -226,6 +224,25 @@ const sharedProviders = [
|
|
|
226
224
|
],
|
|
227
225
|
},
|
|
228
226
|
}),
|
|
227
|
+
provide({
|
|
228
|
+
provide: CHILD_APP_ERROR_BOUNDARY_TOKEN,
|
|
229
|
+
useFactory: ({ logger }) => {
|
|
230
|
+
const log = logger('child-app:render');
|
|
231
|
+
return function logErrorBoundary(error, info, config) {
|
|
232
|
+
log.error({
|
|
233
|
+
event: 'component-did-catch',
|
|
234
|
+
message: 'An unexpected error occured during rendering',
|
|
235
|
+
error,
|
|
236
|
+
info,
|
|
237
|
+
childApp: config,
|
|
238
|
+
});
|
|
239
|
+
};
|
|
240
|
+
},
|
|
241
|
+
deps: {
|
|
242
|
+
logger: LOGGER_TOKEN,
|
|
243
|
+
},
|
|
244
|
+
multi: true,
|
|
245
|
+
}),
|
|
229
246
|
];
|
|
230
247
|
|
|
231
248
|
export { sharedProviders };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Scope, DI_TOKEN, optional } from '@tinkoff/dippy';
|
|
2
2
|
import { provide, commandLineListTokens, COMMAND_LINE_RUNNER_TOKEN } from '@tramvai/core';
|
|
3
|
-
import { CHILD_APP_RESOLUTION_CONFIG_MANAGER_TOKEN, CHILD_APP_RESOLUTION_CONFIGS_TOKEN, CHILD_APP_RESOLVE_CONFIG_TOKEN, CHILD_APP_RESOLVE_BASE_URL_TOKEN, CHILD_APP_SINGLETON_DI_MANAGER_TOKEN, CHILD_APP_LOADER_TOKEN, CHILD_APP_ROOT_DI_ACCESS_MODE_TOKEN, CHILD_APP_CONTRACT_MANAGER, CHILD_APP_DI_MANAGER_TOKEN, CHILD_APP_COMMAND_LINE_RUNNER_TOKEN, CHILD_APP_PRELOAD_MANAGER_TOKEN, CHILD_APP_RENDER_MANAGER_TOKEN, HOST_PROVIDED_CONTRACTS } from '@tramvai/tokens-child-app';
|
|
3
|
+
import { CHILD_APP_RESOLUTION_CONFIG_MANAGER_TOKEN, CHILD_APP_RESOLUTION_CONFIGS_TOKEN, CHILD_APP_RESOLVE_CONFIG_TOKEN, CHILD_APP_RESOLVE_BASE_URL_TOKEN, CHILD_APP_SINGLETON_DI_MANAGER_TOKEN, CHILD_APP_LOADER_TOKEN, CHILD_APP_ROOT_DI_ACCESS_MODE_TOKEN, CHILD_APP_CONTRACT_MANAGER, CHILD_APP_DI_MANAGER_TOKEN, CHILD_APP_COMMAND_LINE_RUNNER_TOKEN, CHILD_APP_PRELOAD_MANAGER_TOKEN, CHILD_APP_RENDER_MANAGER_TOKEN, HOST_PROVIDED_CONTRACTS, CHILD_APP_ERROR_BOUNDARY_TOKEN } from '@tramvai/tokens-child-app';
|
|
4
4
|
import { COMBINE_REDUCERS, LOGGER_TOKEN, ENV_MANAGER_TOKEN, REGISTER_CLEAR_CACHE_TOKEN, CLEAR_CACHE_TOKEN, ENV_USED_TOKEN, COMPONENT_REGISTRY_TOKEN, LIMIT_ACTION_GLOBAL_TIME_RUN, ACTION_CONDITIONALS } from '@tramvai/tokens-common';
|
|
5
5
|
import { EXTEND_RENDER } from '@tramvai/tokens-render';
|
|
6
6
|
import { ROUTER_TOKEN, PAGE_SERVICE_TOKEN, LINK_PREFETCH_MANAGER_TOKEN, ROUTER_SPA_ACTIONS_RUN_MODE_TOKEN } from '@tramvai/tokens-router';
|
|
@@ -51,12 +51,11 @@ const sharedProviders = [
|
|
|
51
51
|
const rawEnv = envManager.get('CHILD_APP_DEBUG');
|
|
52
52
|
const log = logger('child-app:resolve-config');
|
|
53
53
|
const debug = new Map();
|
|
54
|
-
rawEnv
|
|
54
|
+
rawEnv?.split(';').reduce((acc, entry) => {
|
|
55
55
|
const [name, url] = entry.split('=');
|
|
56
56
|
return acc.set(name, url);
|
|
57
57
|
}, debug);
|
|
58
58
|
return (request) => {
|
|
59
|
-
var _a, _b;
|
|
60
59
|
const { name, tag = debug.has(name) ? 'debug' : 'latest' } = request;
|
|
61
60
|
const req = { name, tag, version: request.version };
|
|
62
61
|
const config = resolutionConfigManager.resolve(req);
|
|
@@ -65,7 +64,7 @@ const sharedProviders = [
|
|
|
65
64
|
return;
|
|
66
65
|
}
|
|
67
66
|
const { version, baseUrl: configBaseUrl, client, server, css, withoutCss } = config;
|
|
68
|
-
const baseUrl =
|
|
67
|
+
const baseUrl = debug.get(name) ?? configBaseUrl ?? rootBaseUrl;
|
|
69
68
|
if (!baseUrl) {
|
|
70
69
|
throw new Error('CHILD_APP_EXTERNAL_URL was not defined');
|
|
71
70
|
}
|
|
@@ -173,17 +172,16 @@ const sharedProviders = [
|
|
|
173
172
|
useFactory: ({ diManager }) => {
|
|
174
173
|
return (type) => {
|
|
175
174
|
diManager.forEachChildDi((di) => {
|
|
176
|
-
var _a;
|
|
177
175
|
const clearCache = di.get({ token: CLEAR_CACHE_TOKEN, optional: true });
|
|
178
176
|
if (clearCache) {
|
|
179
177
|
// first if child-app has its own CLEAR_CACHE_TOKEN implementation use only it
|
|
180
178
|
return clearCache(type);
|
|
181
179
|
}
|
|
182
180
|
// otherwise pick up any REGISTER_CLEAR_CACHE_TOKEN hooks and call it
|
|
183
|
-
const registeredClearCache =
|
|
181
|
+
const registeredClearCache = di.get({
|
|
184
182
|
token: REGISTER_CLEAR_CACHE_TOKEN,
|
|
185
183
|
optional: true,
|
|
186
|
-
})
|
|
184
|
+
}) ?? [];
|
|
187
185
|
return Promise.all(registeredClearCache.map((clear) => clear(type)));
|
|
188
186
|
});
|
|
189
187
|
};
|
|
@@ -226,6 +224,25 @@ const sharedProviders = [
|
|
|
226
224
|
],
|
|
227
225
|
},
|
|
228
226
|
}),
|
|
227
|
+
provide({
|
|
228
|
+
provide: CHILD_APP_ERROR_BOUNDARY_TOKEN,
|
|
229
|
+
useFactory: ({ logger }) => {
|
|
230
|
+
const log = logger('child-app:render');
|
|
231
|
+
return function logErrorBoundary(error, info, config) {
|
|
232
|
+
log.error({
|
|
233
|
+
event: 'component-did-catch',
|
|
234
|
+
message: 'An unexpected error occured during rendering',
|
|
235
|
+
error,
|
|
236
|
+
info,
|
|
237
|
+
childApp: config,
|
|
238
|
+
});
|
|
239
|
+
};
|
|
240
|
+
},
|
|
241
|
+
deps: {
|
|
242
|
+
logger: LOGGER_TOKEN,
|
|
243
|
+
},
|
|
244
|
+
multi: true,
|
|
245
|
+
}),
|
|
229
246
|
];
|
|
230
247
|
|
|
231
248
|
export { sharedProviders };
|
package/lib/shared/providers.js
CHANGED
|
@@ -55,12 +55,11 @@ const sharedProviders = [
|
|
|
55
55
|
const rawEnv = envManager.get('CHILD_APP_DEBUG');
|
|
56
56
|
const log = logger('child-app:resolve-config');
|
|
57
57
|
const debug = new Map();
|
|
58
|
-
rawEnv
|
|
58
|
+
rawEnv?.split(';').reduce((acc, entry) => {
|
|
59
59
|
const [name, url] = entry.split('=');
|
|
60
60
|
return acc.set(name, url);
|
|
61
61
|
}, debug);
|
|
62
62
|
return (request) => {
|
|
63
|
-
var _a, _b;
|
|
64
63
|
const { name, tag = debug.has(name) ? 'debug' : 'latest' } = request;
|
|
65
64
|
const req = { name, tag, version: request.version };
|
|
66
65
|
const config = resolutionConfigManager.resolve(req);
|
|
@@ -69,7 +68,7 @@ const sharedProviders = [
|
|
|
69
68
|
return;
|
|
70
69
|
}
|
|
71
70
|
const { version, baseUrl: configBaseUrl, client, server, css, withoutCss } = config;
|
|
72
|
-
const baseUrl =
|
|
71
|
+
const baseUrl = debug.get(name) ?? configBaseUrl ?? rootBaseUrl;
|
|
73
72
|
if (!baseUrl) {
|
|
74
73
|
throw new Error('CHILD_APP_EXTERNAL_URL was not defined');
|
|
75
74
|
}
|
|
@@ -177,17 +176,16 @@ const sharedProviders = [
|
|
|
177
176
|
useFactory: ({ diManager }) => {
|
|
178
177
|
return (type) => {
|
|
179
178
|
diManager.forEachChildDi((di) => {
|
|
180
|
-
var _a;
|
|
181
179
|
const clearCache = di.get({ token: tokensCommon.CLEAR_CACHE_TOKEN, optional: true });
|
|
182
180
|
if (clearCache) {
|
|
183
181
|
// first if child-app has its own CLEAR_CACHE_TOKEN implementation use only it
|
|
184
182
|
return clearCache(type);
|
|
185
183
|
}
|
|
186
184
|
// otherwise pick up any REGISTER_CLEAR_CACHE_TOKEN hooks and call it
|
|
187
|
-
const registeredClearCache =
|
|
185
|
+
const registeredClearCache = di.get({
|
|
188
186
|
token: tokensCommon.REGISTER_CLEAR_CACHE_TOKEN,
|
|
189
187
|
optional: true,
|
|
190
|
-
})
|
|
188
|
+
}) ?? [];
|
|
191
189
|
return Promise.all(registeredClearCache.map((clear) => clear(type)));
|
|
192
190
|
});
|
|
193
191
|
};
|
|
@@ -230,6 +228,25 @@ const sharedProviders = [
|
|
|
230
228
|
],
|
|
231
229
|
},
|
|
232
230
|
}),
|
|
231
|
+
core.provide({
|
|
232
|
+
provide: tokensChildApp.CHILD_APP_ERROR_BOUNDARY_TOKEN,
|
|
233
|
+
useFactory: ({ logger }) => {
|
|
234
|
+
const log = logger('child-app:render');
|
|
235
|
+
return function logErrorBoundary(error, info, config) {
|
|
236
|
+
log.error({
|
|
237
|
+
event: 'component-did-catch',
|
|
238
|
+
message: 'An unexpected error occured during rendering',
|
|
239
|
+
error,
|
|
240
|
+
info,
|
|
241
|
+
childApp: config,
|
|
242
|
+
});
|
|
243
|
+
};
|
|
244
|
+
},
|
|
245
|
+
deps: {
|
|
246
|
+
logger: tokensCommon.LOGGER_TOKEN,
|
|
247
|
+
},
|
|
248
|
+
multi: true,
|
|
249
|
+
}),
|
|
233
250
|
];
|
|
234
251
|
|
|
235
252
|
exports.sharedProviders = sharedProviders;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { CHILD_APP_ERROR_BOUNDARY_TOKEN } from '@tramvai/tokens-child-app';
|
|
4
|
+
import { useDi, UniversalErrorBoundary } from '@tramvai/react';
|
|
5
|
+
|
|
6
|
+
const ChildAppErrorBoundary = (props) => {
|
|
7
|
+
const { children, config } = props;
|
|
8
|
+
const { fallback, name, version, tag } = config;
|
|
9
|
+
const errorHandlers = useDi({ token: CHILD_APP_ERROR_BOUNDARY_TOKEN, optional: true });
|
|
10
|
+
const decoratedErrorHandlers = useMemo(() => errorHandlers?.map((errorHandler) => (error, info) => errorHandler(error, info, { name, version, tag })), [errorHandlers, name, version, tag]);
|
|
11
|
+
return (jsx(UniversalErrorBoundary, { fallback: fallback, errorHandlers: decoratedErrorHandlers, children: children }));
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { ChildAppErrorBoundary };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PropsWithChildren } from 'react';
|
|
2
|
+
import type { ChildAppReactConfig } from '@tramvai/tokens-child-app';
|
|
3
|
+
type Props = {
|
|
4
|
+
config: ChildAppReactConfig;
|
|
5
|
+
};
|
|
6
|
+
export declare const ChildAppErrorBoundary: (props: PropsWithChildren<Props>) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=childAppErrorBoundary.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { CHILD_APP_ERROR_BOUNDARY_TOKEN } from '@tramvai/tokens-child-app';
|
|
4
|
+
import { useDi, UniversalErrorBoundary } from '@tramvai/react';
|
|
5
|
+
|
|
6
|
+
const ChildAppErrorBoundary = (props) => {
|
|
7
|
+
const { children, config } = props;
|
|
8
|
+
const { fallback, name, version, tag } = config;
|
|
9
|
+
const errorHandlers = useDi({ token: CHILD_APP_ERROR_BOUNDARY_TOKEN, optional: true });
|
|
10
|
+
const decoratedErrorHandlers = useMemo(() => errorHandlers?.map((errorHandler) => (error, info) => errorHandler(error, info, { name, version, tag })), [errorHandlers, name, version, tag]);
|
|
11
|
+
return (jsx(UniversalErrorBoundary, { fallback: fallback, errorHandlers: decoratedErrorHandlers, children: children }));
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { ChildAppErrorBoundary };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var react$1 = require('react');
|
|
7
|
+
var tokensChildApp = require('@tramvai/tokens-child-app');
|
|
8
|
+
var react = require('@tramvai/react');
|
|
9
|
+
|
|
10
|
+
const ChildAppErrorBoundary = (props) => {
|
|
11
|
+
const { children, config } = props;
|
|
12
|
+
const { fallback, name, version, tag } = config;
|
|
13
|
+
const errorHandlers = react.useDi({ token: tokensChildApp.CHILD_APP_ERROR_BOUNDARY_TOKEN, optional: true });
|
|
14
|
+
const decoratedErrorHandlers = react$1.useMemo(() => errorHandlers?.map((errorHandler) => (error, info) => errorHandler(error, info, { name, version, tag })), [errorHandlers, name, version, tag]);
|
|
15
|
+
return (jsxRuntime.jsx(react.UniversalErrorBoundary, { fallback: fallback, errorHandlers: decoratedErrorHandlers, children: children }));
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
exports.ChildAppErrorBoundary = ChildAppErrorBoundary;
|
|
@@ -3,9 +3,10 @@ import noop from '@tinkoff/utils/function/noop';
|
|
|
3
3
|
import { memo, Suspense, useContext, useMemo, useState, useEffect } from 'react';
|
|
4
4
|
import { CHILD_APP_INTERNAL_RENDER_TOKEN } from '@tramvai/tokens-child-app';
|
|
5
5
|
import { LOGGER_TOKEN } from '@tramvai/tokens-common';
|
|
6
|
-
import {
|
|
6
|
+
import { useDi } from '@tramvai/react';
|
|
7
7
|
import { RenderContext } from './render-context.browser.js';
|
|
8
8
|
import { Extractor } from './extractor.browser.browser.js';
|
|
9
|
+
import { ChildAppErrorBoundary } from './childAppErrorBoundary.browser.js';
|
|
9
10
|
|
|
10
11
|
const FailedChildAppFallback = ({ config: { name, version, tag, fallback: Fallback }, }) => {
|
|
11
12
|
const logger = useDi(LOGGER_TOKEN);
|
|
@@ -93,12 +94,11 @@ const ChildAppWrapper = ({ name, version, tag, props, fallback: Fallback, }) =>
|
|
|
93
94
|
}
|
|
94
95
|
};
|
|
95
96
|
const ChildApp = memo((config) => {
|
|
96
|
-
const { fallback } = config;
|
|
97
97
|
let result = jsx(ChildAppWrapper, { ...config });
|
|
98
98
|
if (process.env.__TRAMVAI_CONCURRENT_FEATURES) {
|
|
99
99
|
result = jsx(Suspense, { fallback: jsx(FailedChildAppFallback, { config: config }), children: result });
|
|
100
100
|
}
|
|
101
|
-
return jsx(
|
|
101
|
+
return jsx(ChildAppErrorBoundary, { config: config, children: result });
|
|
102
102
|
});
|
|
103
103
|
|
|
104
104
|
export { ChildApp };
|
|
@@ -3,9 +3,10 @@ import noop from '@tinkoff/utils/function/noop';
|
|
|
3
3
|
import { memo, Suspense, useContext, useMemo, useState, useEffect } from 'react';
|
|
4
4
|
import { CHILD_APP_INTERNAL_RENDER_TOKEN } from '@tramvai/tokens-child-app';
|
|
5
5
|
import { LOGGER_TOKEN } from '@tramvai/tokens-common';
|
|
6
|
-
import {
|
|
6
|
+
import { useDi } from '@tramvai/react';
|
|
7
7
|
import { RenderContext } from './render-context.es.js';
|
|
8
8
|
import { Extractor } from './extractor.es.js';
|
|
9
|
+
import { ChildAppErrorBoundary } from './childAppErrorBoundary.es.js';
|
|
9
10
|
|
|
10
11
|
const FailedChildAppFallback = ({ config: { name, version, tag, fallback: Fallback }, }) => {
|
|
11
12
|
const logger = useDi(LOGGER_TOKEN);
|
|
@@ -93,12 +94,11 @@ const ChildAppWrapper = ({ name, version, tag, props, fallback: Fallback, }) =>
|
|
|
93
94
|
}
|
|
94
95
|
};
|
|
95
96
|
const ChildApp = memo((config) => {
|
|
96
|
-
const { fallback } = config;
|
|
97
97
|
let result = jsx(ChildAppWrapper, { ...config });
|
|
98
98
|
if (process.env.__TRAMVAI_CONCURRENT_FEATURES) {
|
|
99
99
|
result = jsx(Suspense, { fallback: jsx(FailedChildAppFallback, { config: config }), children: result });
|
|
100
100
|
}
|
|
101
|
-
return jsx(
|
|
101
|
+
return jsx(ChildAppErrorBoundary, { config: config, children: result });
|
|
102
102
|
});
|
|
103
103
|
|
|
104
104
|
export { ChildApp };
|
|
@@ -10,6 +10,7 @@ var tokensCommon = require('@tramvai/tokens-common');
|
|
|
10
10
|
var react$1 = require('@tramvai/react');
|
|
11
11
|
var renderContext = require('./render-context.js');
|
|
12
12
|
var extractor = require('./extractor.js');
|
|
13
|
+
var childAppErrorBoundary = require('./childAppErrorBoundary.js');
|
|
13
14
|
|
|
14
15
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
15
16
|
|
|
@@ -101,12 +102,11 @@ const ChildAppWrapper = ({ name, version, tag, props, fallback: Fallback, }) =>
|
|
|
101
102
|
}
|
|
102
103
|
};
|
|
103
104
|
const ChildApp = react.memo((config) => {
|
|
104
|
-
const { fallback } = config;
|
|
105
105
|
let result = jsxRuntime.jsx(ChildAppWrapper, { ...config });
|
|
106
106
|
if (process.env.__TRAMVAI_CONCURRENT_FEATURES) {
|
|
107
107
|
result = jsxRuntime.jsx(react.Suspense, { fallback: jsxRuntime.jsx(FailedChildAppFallback, { config: config }), children: result });
|
|
108
108
|
}
|
|
109
|
-
return jsxRuntime.jsx(
|
|
109
|
+
return jsxRuntime.jsx(childAppErrorBoundary.ChildAppErrorBoundary, { config: config, children: result });
|
|
110
110
|
});
|
|
111
111
|
|
|
112
112
|
exports.ChildApp = ChildApp;
|
|
@@ -4,7 +4,7 @@ import flatten from '@tinkoff/utils/array/flatten';
|
|
|
4
4
|
class ChildAppResolutionConfigManager {
|
|
5
5
|
constructor({ configs, logger, }) {
|
|
6
6
|
this.hasInitialized = false;
|
|
7
|
-
this.rawConfigs = configs
|
|
7
|
+
this.rawConfigs = configs ?? [];
|
|
8
8
|
this.mapping = new Map();
|
|
9
9
|
this.log = logger('child-app:resolution-config');
|
|
10
10
|
}
|
|
@@ -35,7 +35,6 @@ class ChildAppResolutionConfigManager {
|
|
|
35
35
|
return this.initPromise;
|
|
36
36
|
}
|
|
37
37
|
resolve({ name, version, tag = 'latest' }) {
|
|
38
|
-
var _a;
|
|
39
38
|
const fromMapping = this.mapping.get(name);
|
|
40
39
|
if (!fromMapping) {
|
|
41
40
|
return;
|
|
@@ -49,8 +48,8 @@ class ChildAppResolutionConfigManager {
|
|
|
49
48
|
}
|
|
50
49
|
return {
|
|
51
50
|
...cfg,
|
|
52
|
-
baseUrl:
|
|
53
|
-
version: version
|
|
51
|
+
baseUrl: cfg.baseUrl ?? fromMapping.baseUrl,
|
|
52
|
+
version: version ?? cfg.version,
|
|
54
53
|
};
|
|
55
54
|
}
|
|
56
55
|
}
|
|
@@ -4,7 +4,7 @@ import flatten from '@tinkoff/utils/array/flatten';
|
|
|
4
4
|
class ChildAppResolutionConfigManager {
|
|
5
5
|
constructor({ configs, logger, }) {
|
|
6
6
|
this.hasInitialized = false;
|
|
7
|
-
this.rawConfigs = configs
|
|
7
|
+
this.rawConfigs = configs ?? [];
|
|
8
8
|
this.mapping = new Map();
|
|
9
9
|
this.log = logger('child-app:resolution-config');
|
|
10
10
|
}
|
|
@@ -35,7 +35,6 @@ class ChildAppResolutionConfigManager {
|
|
|
35
35
|
return this.initPromise;
|
|
36
36
|
}
|
|
37
37
|
resolve({ name, version, tag = 'latest' }) {
|
|
38
|
-
var _a;
|
|
39
38
|
const fromMapping = this.mapping.get(name);
|
|
40
39
|
if (!fromMapping) {
|
|
41
40
|
return;
|
|
@@ -49,8 +48,8 @@ class ChildAppResolutionConfigManager {
|
|
|
49
48
|
}
|
|
50
49
|
return {
|
|
51
50
|
...cfg,
|
|
52
|
-
baseUrl:
|
|
53
|
-
version: version
|
|
51
|
+
baseUrl: cfg.baseUrl ?? fromMapping.baseUrl,
|
|
52
|
+
version: version ?? cfg.version,
|
|
54
53
|
};
|
|
55
54
|
}
|
|
56
55
|
}
|
|
@@ -13,7 +13,7 @@ var flatten__default = /*#__PURE__*/_interopDefaultLegacy(flatten);
|
|
|
13
13
|
class ChildAppResolutionConfigManager {
|
|
14
14
|
constructor({ configs, logger, }) {
|
|
15
15
|
this.hasInitialized = false;
|
|
16
|
-
this.rawConfigs = configs
|
|
16
|
+
this.rawConfigs = configs ?? [];
|
|
17
17
|
this.mapping = new Map();
|
|
18
18
|
this.log = logger('child-app:resolution-config');
|
|
19
19
|
}
|
|
@@ -44,7 +44,6 @@ class ChildAppResolutionConfigManager {
|
|
|
44
44
|
return this.initPromise;
|
|
45
45
|
}
|
|
46
46
|
resolve({ name, version, tag = 'latest' }) {
|
|
47
|
-
var _a;
|
|
48
47
|
const fromMapping = this.mapping.get(name);
|
|
49
48
|
if (!fromMapping) {
|
|
50
49
|
return;
|
|
@@ -58,8 +57,8 @@ class ChildAppResolutionConfigManager {
|
|
|
58
57
|
}
|
|
59
58
|
return {
|
|
60
59
|
...cfg,
|
|
61
|
-
baseUrl:
|
|
62
|
-
version: version
|
|
60
|
+
baseUrl: cfg.baseUrl ?? fromMapping.baseUrl,
|
|
61
|
+
version: version ?? cfg.version,
|
|
63
62
|
};
|
|
64
63
|
}
|
|
65
64
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/module-child-app",
|
|
3
|
-
"version": "5.9
|
|
3
|
+
"version": "5.14.9",
|
|
4
4
|
"description": "Module for child apps",
|
|
5
5
|
"browser": {
|
|
6
6
|
"./lib/server.js": "./lib/browser.js",
|
|
@@ -33,23 +33,23 @@
|
|
|
33
33
|
"@tinkoff/env-validators": "0.4.2",
|
|
34
34
|
"@tinkoff/module-loader-client": "0.7.3",
|
|
35
35
|
"@tinkoff/module-loader-server": "0.8.3",
|
|
36
|
-
"@tramvai/module-common": "5.9
|
|
36
|
+
"@tramvai/module-common": "5.14.9",
|
|
37
37
|
"@tinkoff/url": "0.11.2",
|
|
38
|
-
"@tramvai/child-app-core": "5.9
|
|
39
|
-
"@tramvai/safe-strings": "0.8.
|
|
40
|
-
"@tramvai/tokens-child-app": "5.9
|
|
38
|
+
"@tramvai/child-app-core": "5.14.9",
|
|
39
|
+
"@tramvai/safe-strings": "0.8.4",
|
|
40
|
+
"@tramvai/tokens-child-app": "5.14.9"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"@tinkoff/dippy": "0.11.3",
|
|
45
|
-
"@tinkoff/router": "0.5.
|
|
45
|
+
"@tinkoff/router": "0.5.46",
|
|
46
46
|
"@tinkoff/utils": "^2.1.2",
|
|
47
|
-
"@tramvai/core": "5.9
|
|
48
|
-
"@tramvai/state": "5.9
|
|
49
|
-
"@tramvai/react": "5.9
|
|
50
|
-
"@tramvai/tokens-common": "5.9
|
|
51
|
-
"@tramvai/tokens-render": "5.9
|
|
52
|
-
"@tramvai/tokens-router": "5.9
|
|
47
|
+
"@tramvai/core": "5.14.9",
|
|
48
|
+
"@tramvai/state": "5.14.9",
|
|
49
|
+
"@tramvai/react": "5.14.9",
|
|
50
|
+
"@tramvai/tokens-common": "5.14.9",
|
|
51
|
+
"@tramvai/tokens-render": "5.14.9",
|
|
52
|
+
"@tramvai/tokens-router": "5.14.9",
|
|
53
53
|
"react": ">=16.14.0",
|
|
54
54
|
"react-dom": ">=16.14.0",
|
|
55
55
|
"object-assign": "^4.1.1",
|