@tramvai/module-child-app 3.33.2 → 3.37.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,6 @@
1
1
  import noop from '@tinkoff/utils/function/noop';
2
- import flatten from '@tinkoff/utils/array/flatten';
3
2
  import { provide } from '@tramvai/core';
4
- import { commandLineListTokens, CHILD_APP_INTERNAL_ROOT_STATE_SUBSCRIPTION_TOKEN, CHILD_APP_INTERNAL_ACTION_TOKEN } from '@tramvai/tokens-child-app';
3
+ import { commandLineListTokens, CHILD_APP_INTERNAL_ROOT_STATE_SUBSCRIPTION_TOKEN, CHILD_APP_PAGE_SERVICE_TOKEN } from '@tramvai/tokens-child-app';
5
4
  import { CONTEXT_TOKEN, ACTION_PAGE_RUNNER_TOKEN } from '@tramvai/tokens-common';
6
5
  import { Subscription } from '@tramvai/state';
7
6
  import { ROUTER_SPA_ACTIONS_RUN_MODE_TOKEN } from '@tramvai/tokens-router';
@@ -35,30 +34,32 @@ const getChildProviders = (appDi) => {
35
34
  provide({
36
35
  provide: commandLineListTokens.clear,
37
36
  multi: true,
38
- useFactory: ({ actionRunner, actions }) => {
39
- return function childAppRunActions() {
40
- return actionRunner.runActions(flatten(actions));
37
+ useFactory: ({ actionRunner, childAppPageService }) => {
38
+ return async function childAppRunActions() {
39
+ await childAppPageService.resolveComponent();
40
+ return actionRunner.runActions(childAppPageService.getActions());
41
41
  };
42
42
  },
43
43
  deps: {
44
44
  actionRunner: ACTION_PAGE_RUNNER_TOKEN,
45
- actions: CHILD_APP_INTERNAL_ACTION_TOKEN,
45
+ childAppPageService: CHILD_APP_PAGE_SERVICE_TOKEN,
46
46
  },
47
47
  }),
48
48
  provide({
49
49
  provide: commandLineListTokens.spaTransition,
50
50
  multi: true,
51
- useFactory: ({ spaMode, actionRunner, actions }) => {
51
+ useFactory: ({ spaMode, actionRunner, childAppPageService }) => {
52
52
  if (spaMode !== 'after') {
53
- return function childAppRunActions() {
54
- return actionRunner.runActions(flatten(actions));
53
+ return async function childAppRunActions() {
54
+ await childAppPageService.resolveComponent();
55
+ return actionRunner.runActions(childAppPageService.getActions());
55
56
  };
56
57
  }
57
58
  return noop;
58
59
  },
59
60
  deps: {
60
61
  actionRunner: ACTION_PAGE_RUNNER_TOKEN,
61
- actions: CHILD_APP_INTERNAL_ACTION_TOKEN,
62
+ childAppPageService: CHILD_APP_PAGE_SERVICE_TOKEN,
62
63
  spaMode: {
63
64
  token: ROUTER_SPA_ACTIONS_RUN_MODE_TOKEN,
64
65
  optional: true,
@@ -68,17 +69,18 @@ const getChildProviders = (appDi) => {
68
69
  provide({
69
70
  provide: commandLineListTokens.afterSpaTransition,
70
71
  multi: true,
71
- useFactory: ({ spaMode, actionRunner, actions }) => {
72
+ useFactory: ({ spaMode, actionRunner, childAppPageService }) => {
72
73
  if (spaMode === 'after') {
73
- return function childAppRunActions() {
74
- return actionRunner.runActions(flatten(actions));
74
+ return async function childAppRunActions() {
75
+ await childAppPageService.resolveComponent();
76
+ return actionRunner.runActions(childAppPageService.getActions());
75
77
  };
76
78
  }
77
79
  return noop;
78
80
  },
79
81
  deps: {
80
82
  actionRunner: ACTION_PAGE_RUNNER_TOKEN,
81
- actions: CHILD_APP_INTERNAL_ACTION_TOKEN,
83
+ childAppPageService: CHILD_APP_PAGE_SERVICE_TOKEN,
82
84
  spaMode: {
83
85
  token: ROUTER_SPA_ACTIONS_RUN_MODE_TOKEN,
84
86
  optional: true,
@@ -1,7 +1,9 @@
1
+ import { CHILD_APP_PAGE_SERVICE_TOKEN } from '@tramvai/tokens-child-app';
2
+ import { optional } from '@tinkoff/dippy';
1
3
  import { ChildAppStore } from '../shared/store.browser.js';
2
4
 
3
5
  class PreloadManager {
4
- constructor({ loader, runner, resolutionConfigManager, resolveExternalConfig, store, }) {
6
+ constructor({ loader, runner, resolutionConfigManager, resolveExternalConfig, store, diManager, }) {
5
7
  this.pageHasRendered = false;
6
8
  this.pageHasLoaded = false;
7
9
  this.currentlyPreloaded = new Map();
@@ -13,8 +15,9 @@ class PreloadManager {
13
15
  this.store = store;
14
16
  this.resolutionConfigManager = resolutionConfigManager;
15
17
  this.resolveExternalConfig = resolveExternalConfig;
18
+ this.diManager = diManager;
16
19
  }
17
- async preload(request, onlyPrefetch = false) {
20
+ async preload(request, route, onlyPrefetch = false) {
18
21
  await this.init();
19
22
  const config = this.resolveExternalConfig(request);
20
23
  if (!config) {
@@ -36,6 +39,7 @@ class PreloadManager {
36
39
  const promise = (async () => {
37
40
  try {
38
41
  await this.loader.load(config);
42
+ await this.resolveComponent(config, route);
39
43
  if (!onlyPrefetch) {
40
44
  await this.run('customer', config);
41
45
  await this.run('clear', config);
@@ -52,9 +56,13 @@ class PreloadManager {
52
56
  return promise;
53
57
  }
54
58
  }
59
+ else {
60
+ // case for SPA-navigation to another page of same Child App without prefetch
61
+ await this.resolveComponent(config, route);
62
+ }
55
63
  }
56
- async prefetch(request) {
57
- return this.preload(request, true);
64
+ async prefetch(request, route) {
65
+ return this.preload(request, route, true);
58
66
  }
59
67
  isPreloaded(request) {
60
68
  const config = this.resolveExternalConfig(request);
@@ -69,6 +77,8 @@ class PreloadManager {
69
77
  this.currentlyPreloaded.forEach((config) => {
70
78
  promises.push((async () => {
71
79
  await this.loader.init(config);
80
+ // case for client initialization of Child App
81
+ await this.resolveComponent(config);
72
82
  await this.run('customer', config);
73
83
  })());
74
84
  });
@@ -119,6 +129,14 @@ class PreloadManager {
119
129
  }
120
130
  await this.runner.run('client', status, config);
121
131
  }
132
+ // preload child app page component - we need to register page actions before running all child app actions
133
+ async resolveComponent(config, route) {
134
+ const di = this.diManager.getChildDi(config);
135
+ const childAppPageService = di === null || di === void 0 ? void 0 : di.get(optional(CHILD_APP_PAGE_SERVICE_TOKEN));
136
+ if (childAppPageService) {
137
+ await childAppPageService.resolveComponent(route);
138
+ }
139
+ }
122
140
  }
123
141
 
124
142
  export { PreloadManager };
@@ -1,26 +1,29 @@
1
- import type { ChildAppCommandLineRunner, ChildAppRequestConfig, ChildAppLoader, ChildAppPreloadManager, CHILD_APP_RESOLVE_CONFIG_TOKEN, ChildAppFinalConfig, CHILD_APP_RESOLUTION_CONFIG_MANAGER_TOKEN } from '@tramvai/tokens-child-app';
1
+ import { type ChildAppCommandLineRunner, type ChildAppRequestConfig, type ChildAppLoader, type ChildAppPreloadManager, type CHILD_APP_RESOLVE_CONFIG_TOKEN, type ChildAppFinalConfig, type CHILD_APP_RESOLUTION_CONFIG_MANAGER_TOKEN, type CHILD_APP_DI_MANAGER_TOKEN } from '@tramvai/tokens-child-app';
2
2
  import type { STORE_TOKEN } from '@tramvai/tokens-common';
3
+ import type { Route } from '@tinkoff/router';
3
4
  export declare class PreloadManager implements ChildAppPreloadManager {
4
5
  private loader;
5
6
  private runner;
6
7
  private store;
7
8
  private resolutionConfigManager;
8
9
  private resolveExternalConfig;
10
+ private diManager;
9
11
  private pageHasRendered;
10
12
  private pageHasLoaded;
11
13
  private currentlyPreloaded;
12
14
  private hasPreloadBefore;
13
15
  private hasInitialized;
14
16
  private map;
15
- constructor({ loader, runner, resolutionConfigManager, resolveExternalConfig, store, }: {
17
+ constructor({ loader, runner, resolutionConfigManager, resolveExternalConfig, store, diManager, }: {
16
18
  loader: ChildAppLoader;
17
19
  runner: ChildAppCommandLineRunner;
18
20
  resolutionConfigManager: typeof CHILD_APP_RESOLUTION_CONFIG_MANAGER_TOKEN;
19
21
  resolveExternalConfig: typeof CHILD_APP_RESOLVE_CONFIG_TOKEN;
20
22
  store: typeof STORE_TOKEN;
23
+ diManager: typeof CHILD_APP_DI_MANAGER_TOKEN;
21
24
  });
22
- preload(request: ChildAppRequestConfig, onlyPrefetch?: boolean): Promise<void>;
23
- prefetch(request: ChildAppRequestConfig): Promise<void>;
25
+ preload(request: ChildAppRequestConfig, route?: Route, onlyPrefetch?: boolean): Promise<void>;
26
+ prefetch(request: ChildAppRequestConfig, route?: Route): Promise<void>;
24
27
  isPreloaded(request: ChildAppRequestConfig): boolean;
25
28
  runPreloaded(): Promise<void>;
26
29
  pageRender(): void;
@@ -29,5 +32,6 @@ export declare class PreloadManager implements ChildAppPreloadManager {
29
32
  private initServerPreloaded;
30
33
  private init;
31
34
  private run;
35
+ private resolveComponent;
32
36
  }
33
37
  //# sourceMappingURL=preload.d.ts.map
@@ -1,8 +1,8 @@
1
1
  import { Scope } from '@tinkoff/dippy';
2
2
  import { provide, commandLineListTokens } from '@tramvai/core';
3
- import { CHILD_APP_LOADER_TOKEN, CHILD_APP_PRELOAD_MANAGER_TOKEN, CHILD_APP_COMMAND_LINE_RUNNER_TOKEN, CHILD_APP_RESOLUTION_CONFIG_MANAGER_TOKEN, CHILD_APP_RESOLVE_CONFIG_TOKEN, CHILD_APP_COMMON_INITIAL_STATE_TOKEN, CHILD_APP_RENDER_MANAGER_TOKEN, CHILD_APP_DI_MANAGER_TOKEN } from '@tramvai/tokens-child-app';
3
+ import { CHILD_APP_LOADER_TOKEN, CHILD_APP_PRELOAD_MANAGER_TOKEN, CHILD_APP_COMMAND_LINE_RUNNER_TOKEN, CHILD_APP_RESOLUTION_CONFIG_MANAGER_TOKEN, CHILD_APP_RESOLVE_CONFIG_TOKEN, CHILD_APP_DI_MANAGER_TOKEN, CHILD_APP_COMMON_INITIAL_STATE_TOKEN, CHILD_APP_RENDER_MANAGER_TOKEN } from '@tramvai/tokens-child-app';
4
4
  import { LOGGER_TOKEN, STORE_TOKEN } from '@tramvai/tokens-common';
5
- import { ROUTER_TOKEN } from '@tramvai/tokens-router';
5
+ import { ROUTER_TOKEN, PAGE_SERVICE_TOKEN } from '@tramvai/tokens-router';
6
6
  import { BrowserLoader } from './loader.browser.js';
7
7
  import { PreloadManager } from './preload.browser.js';
8
8
  import { RenderManager } from './render.browser.js';
@@ -27,6 +27,7 @@ const browserProviders = [
27
27
  resolutionConfigManager: CHILD_APP_RESOLUTION_CONFIG_MANAGER_TOKEN,
28
28
  resolveExternalConfig: CHILD_APP_RESOLVE_CONFIG_TOKEN,
29
29
  store: STORE_TOKEN,
30
+ diManager: CHILD_APP_DI_MANAGER_TOKEN,
30
31
  },
31
32
  }),
32
33
  provide({
@@ -77,11 +78,13 @@ const browserProviders = [
77
78
  provide({
78
79
  provide: commandLineListTokens.spaTransition,
79
80
  multi: true,
80
- useFactory: ({ preloader, runner }) => {
81
+ useFactory: ({ preloader, runner, diManager, pageService }) => {
81
82
  return async function childAppRunPreloaded() {
82
83
  await runCommand({
83
84
  preloader,
84
85
  runner,
86
+ diManager,
87
+ pageService,
85
88
  status: 'spa',
86
89
  forcePreload: false,
87
90
  });
@@ -90,16 +93,20 @@ const browserProviders = [
90
93
  deps: {
91
94
  preloader: CHILD_APP_PRELOAD_MANAGER_TOKEN,
92
95
  runner: CHILD_APP_COMMAND_LINE_RUNNER_TOKEN,
96
+ diManager: CHILD_APP_DI_MANAGER_TOKEN,
97
+ pageService: PAGE_SERVICE_TOKEN,
93
98
  },
94
99
  }),
95
100
  provide({
96
101
  provide: commandLineListTokens.afterSpaTransition,
97
102
  multi: true,
98
- useFactory: ({ preloader, runner }) => {
103
+ useFactory: ({ preloader, runner, diManager, pageService }) => {
99
104
  return async function childAppRunPreloaded() {
100
105
  await runCommand({
101
106
  preloader,
102
107
  runner,
108
+ diManager,
109
+ pageService,
103
110
  status: 'afterSpa',
104
111
  forcePreload: true,
105
112
  });
@@ -108,6 +115,8 @@ const browserProviders = [
108
115
  deps: {
109
116
  preloader: CHILD_APP_PRELOAD_MANAGER_TOKEN,
110
117
  runner: CHILD_APP_COMMAND_LINE_RUNNER_TOKEN,
118
+ diManager: CHILD_APP_DI_MANAGER_TOKEN,
119
+ pageService: PAGE_SERVICE_TOKEN,
111
120
  },
112
121
  }),
113
122
  ];
@@ -1,9 +1,9 @@
1
- const runCommand = async ({ status, forcePreload, runner, preloader, }) => {
1
+ const runCommand = async ({ status, forcePreload, runner, preloader, diManager, pageService, }) => {
2
2
  const childApps = preloader.getPreloadedList();
3
3
  await Promise.all(childApps.map(async (config) => {
4
4
  if (forcePreload) {
5
5
  // need to wait while actual child-app is loaded in case it wasn't preloaded before
6
- await preloader.preload(config);
6
+ await preloader.preload(config, pageService.getCurrentRoute());
7
7
  }
8
8
  return runner.run('client', status, config);
9
9
  }));
@@ -1,8 +1,12 @@
1
- import type { CHILD_APP_COMMAND_LINE_RUNNER_TOKEN, CHILD_APP_PRELOAD_MANAGER_TOKEN } from '@tramvai/tokens-child-app';
2
- export declare const runCommand: ({ status, forcePreload, runner, preloader, }: {
1
+ import type { CHILD_APP_DI_MANAGER_TOKEN } from '@tramvai/tokens-child-app';
2
+ import { type CHILD_APP_COMMAND_LINE_RUNNER_TOKEN, type CHILD_APP_PRELOAD_MANAGER_TOKEN } from '@tramvai/tokens-child-app';
3
+ import type { PAGE_SERVICE_TOKEN } from '@tramvai/tokens-router';
4
+ export declare const runCommand: ({ status, forcePreload, runner, preloader, diManager, pageService, }: {
3
5
  status: string;
4
6
  forcePreload: boolean;
5
7
  runner: typeof CHILD_APP_COMMAND_LINE_RUNNER_TOKEN;
6
8
  preloader: typeof CHILD_APP_PRELOAD_MANAGER_TOKEN;
9
+ diManager: typeof CHILD_APP_DI_MANAGER_TOKEN;
10
+ pageService: typeof PAGE_SERVICE_TOKEN;
7
11
  }) => Promise<void>;
8
12
  //# sourceMappingURL=runCommand.d.ts.map
@@ -1,6 +1,5 @@
1
- import flatten from '@tinkoff/utils/array/flatten';
2
1
  import { provide } from '@tramvai/core';
3
- import { commandLineListTokens, CHILD_APP_INTERNAL_ACTION_TOKEN } from '@tramvai/tokens-child-app';
2
+ import { commandLineListTokens, CHILD_APP_PAGE_SERVICE_TOKEN } from '@tramvai/tokens-child-app';
4
3
  import { ACTION_PAGE_RUNNER_TOKEN } from '@tramvai/tokens-common';
5
4
 
6
5
  const getChildProviders = (appDi) => {
@@ -8,14 +7,15 @@ const getChildProviders = (appDi) => {
8
7
  provide({
9
8
  provide: commandLineListTokens.resolvePageDeps,
10
9
  multi: true,
11
- useFactory: ({ actionRunner, actions }) => {
12
- return function childAppRunActions() {
13
- return actionRunner.runActions(flatten(actions));
10
+ useFactory: ({ actionRunner, childAppPageService }) => {
11
+ return async function childAppRunActions() {
12
+ await childAppPageService.resolveComponent();
13
+ return actionRunner.runActions(childAppPageService.getActions());
14
14
  };
15
15
  },
16
16
  deps: {
17
17
  actionRunner: ACTION_PAGE_RUNNER_TOKEN,
18
- actions: CHILD_APP_INTERNAL_ACTION_TOKEN,
18
+ childAppPageService: CHILD_APP_PAGE_SERVICE_TOKEN,
19
19
  },
20
20
  }),
21
21
  ];
@@ -2,28 +2,24 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var flatten = require('@tinkoff/utils/array/flatten');
6
5
  var core = require('@tramvai/core');
7
6
  var tokensChildApp = require('@tramvai/tokens-child-app');
8
7
  var tokensCommon = require('@tramvai/tokens-common');
9
8
 
10
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
11
-
12
- var flatten__default = /*#__PURE__*/_interopDefaultLegacy(flatten);
13
-
14
9
  const getChildProviders = (appDi) => {
15
10
  return [
16
11
  core.provide({
17
12
  provide: tokensChildApp.commandLineListTokens.resolvePageDeps,
18
13
  multi: true,
19
- useFactory: ({ actionRunner, actions }) => {
20
- return function childAppRunActions() {
21
- return actionRunner.runActions(flatten__default["default"](actions));
14
+ useFactory: ({ actionRunner, childAppPageService }) => {
15
+ return async function childAppRunActions() {
16
+ await childAppPageService.resolveComponent();
17
+ return actionRunner.runActions(childAppPageService.getActions());
22
18
  };
23
19
  },
24
20
  deps: {
25
21
  actionRunner: tokensCommon.ACTION_PAGE_RUNNER_TOKEN,
26
- actions: tokensChildApp.CHILD_APP_INTERNAL_ACTION_TOKEN,
22
+ childAppPageService: tokensChildApp.CHILD_APP_PAGE_SERVICE_TOKEN,
27
23
  },
28
24
  }),
29
25
  ];
@@ -1,22 +1,25 @@
1
- import type { ChildAppCommandLineRunner, ChildAppRequestConfig, ChildAppLoader, ChildAppPreloadManager, ChildAppStateManager, CHILD_APP_RESOLVE_CONFIG_TOKEN, ChildAppFinalConfig, CHILD_APP_RESOLUTION_CONFIG_MANAGER_TOKEN } from '@tramvai/tokens-child-app';
1
+ import type { Route } from '@tinkoff/router';
2
+ import { type ChildAppCommandLineRunner, type ChildAppRequestConfig, type ChildAppLoader, type ChildAppPreloadManager, type ChildAppStateManager, type CHILD_APP_RESOLVE_CONFIG_TOKEN, type ChildAppFinalConfig, type CHILD_APP_RESOLUTION_CONFIG_MANAGER_TOKEN, type CHILD_APP_DI_MANAGER_TOKEN } from '@tramvai/tokens-child-app';
2
3
  export declare class PreloadManager implements ChildAppPreloadManager {
3
4
  private loader;
4
5
  private runner;
5
6
  private stateManager;
6
7
  private resolutionConfigManager;
7
8
  private readonly resolveFullConfig;
9
+ private diManager;
8
10
  private shouldRunImmediately;
9
11
  private map;
10
12
  private preloadMap;
11
- constructor({ loader, runner, stateManager, resolutionConfigManager, resolveFullConfig, }: {
13
+ constructor({ loader, runner, stateManager, resolutionConfigManager, resolveFullConfig, diManager, }: {
12
14
  loader: ChildAppLoader;
13
15
  runner: ChildAppCommandLineRunner;
14
16
  stateManager: ChildAppStateManager;
15
17
  resolutionConfigManager: typeof CHILD_APP_RESOLUTION_CONFIG_MANAGER_TOKEN;
16
18
  resolveFullConfig: typeof CHILD_APP_RESOLVE_CONFIG_TOKEN;
19
+ diManager: typeof CHILD_APP_DI_MANAGER_TOKEN;
17
20
  });
18
- preload(request: ChildAppRequestConfig): Promise<void>;
19
- prefetch(request: ChildAppRequestConfig): Promise<void>;
21
+ preload(request: ChildAppRequestConfig, route?: Route): Promise<void>;
22
+ prefetch(request: ChildAppRequestConfig, route?: Route): Promise<void>;
20
23
  isPreloaded(request: ChildAppRequestConfig): boolean;
21
24
  runPreloaded(): Promise<void>;
22
25
  pageRender(): void;
@@ -1,5 +1,8 @@
1
+ import { optional } from '@tinkoff/dippy';
2
+ import { CHILD_APP_PAGE_SERVICE_TOKEN } from '@tramvai/tokens-child-app';
3
+
1
4
  class PreloadManager {
2
- constructor({ loader, runner, stateManager, resolutionConfigManager, resolveFullConfig, }) {
5
+ constructor({ loader, runner, stateManager, resolutionConfigManager, resolveFullConfig, diManager, }) {
3
6
  this.shouldRunImmediately = false;
4
7
  this.map = new Map();
5
8
  this.preloadMap = new Map();
@@ -8,8 +11,9 @@ class PreloadManager {
8
11
  this.stateManager = stateManager;
9
12
  this.resolutionConfigManager = resolutionConfigManager;
10
13
  this.resolveFullConfig = resolveFullConfig;
14
+ this.diManager = diManager;
11
15
  }
12
- async preload(request) {
16
+ async preload(request, route) {
13
17
  await this.resolutionConfigManager.init();
14
18
  const config = this.resolveFullConfig(request);
15
19
  if (!config) {
@@ -25,7 +29,13 @@ class PreloadManager {
25
29
  .catch(() => {
26
30
  // Actual error will be logged by the internals of this.loader
27
31
  })
28
- .then(() => {
32
+ .then(async () => {
33
+ // preload child app page component - we need to register page actions before running all child app actions
34
+ const di = this.diManager.getChildDi(config);
35
+ const childAppPageService = di === null || di === void 0 ? void 0 : di.get(optional(CHILD_APP_PAGE_SERVICE_TOKEN));
36
+ if (childAppPageService) {
37
+ await childAppPageService.resolveComponent();
38
+ }
29
39
  if (this.shouldRunImmediately) {
30
40
  return this.run('customer', config);
31
41
  }
@@ -37,8 +47,8 @@ class PreloadManager {
37
47
  await promise;
38
48
  }
39
49
  }
40
- async prefetch(request) {
41
- return this.preload(request);
50
+ async prefetch(request, route) {
51
+ return this.preload(request, route);
42
52
  }
43
53
  isPreloaded(request) {
44
54
  const config = this.resolveFullConfig(request);
@@ -2,8 +2,11 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var dippy = require('@tinkoff/dippy');
6
+ var tokensChildApp = require('@tramvai/tokens-child-app');
7
+
5
8
  class PreloadManager {
6
- constructor({ loader, runner, stateManager, resolutionConfigManager, resolveFullConfig, }) {
9
+ constructor({ loader, runner, stateManager, resolutionConfigManager, resolveFullConfig, diManager, }) {
7
10
  this.shouldRunImmediately = false;
8
11
  this.map = new Map();
9
12
  this.preloadMap = new Map();
@@ -12,8 +15,9 @@ class PreloadManager {
12
15
  this.stateManager = stateManager;
13
16
  this.resolutionConfigManager = resolutionConfigManager;
14
17
  this.resolveFullConfig = resolveFullConfig;
18
+ this.diManager = diManager;
15
19
  }
16
- async preload(request) {
20
+ async preload(request, route) {
17
21
  await this.resolutionConfigManager.init();
18
22
  const config = this.resolveFullConfig(request);
19
23
  if (!config) {
@@ -29,7 +33,13 @@ class PreloadManager {
29
33
  .catch(() => {
30
34
  // Actual error will be logged by the internals of this.loader
31
35
  })
32
- .then(() => {
36
+ .then(async () => {
37
+ // preload child app page component - we need to register page actions before running all child app actions
38
+ const di = this.diManager.getChildDi(config);
39
+ const childAppPageService = di === null || di === void 0 ? void 0 : di.get(dippy.optional(tokensChildApp.CHILD_APP_PAGE_SERVICE_TOKEN));
40
+ if (childAppPageService) {
41
+ await childAppPageService.resolveComponent();
42
+ }
33
43
  if (this.shouldRunImmediately) {
34
44
  return this.run('customer', config);
35
45
  }
@@ -41,8 +51,8 @@ class PreloadManager {
41
51
  await promise;
42
52
  }
43
53
  }
44
- async prefetch(request) {
45
- return this.preload(request);
54
+ async prefetch(request, route) {
55
+ return this.preload(request, route);
46
56
  }
47
57
  isPreloaded(request) {
48
58
  const config = this.resolveFullConfig(request);
@@ -53,6 +53,7 @@ const serverProviders = [
53
53
  stateManager: CHILD_APP_STATE_MANAGER_TOKEN,
54
54
  resolutionConfigManager: CHILD_APP_RESOLUTION_CONFIG_MANAGER_TOKEN,
55
55
  resolveFullConfig: CHILD_APP_RESOLVE_CONFIG_TOKEN,
56
+ diManager: CHILD_APP_DI_MANAGER_TOKEN,
56
57
  },
57
58
  }),
58
59
  provide({
@@ -57,6 +57,7 @@ const serverProviders = [
57
57
  stateManager: tokensChildApp.CHILD_APP_STATE_MANAGER_TOKEN,
58
58
  resolutionConfigManager: tokensChildApp.CHILD_APP_RESOLUTION_CONFIG_MANAGER_TOKEN,
59
59
  resolveFullConfig: tokensChildApp.CHILD_APP_RESOLVE_CONFIG_TOKEN,
60
+ diManager: tokensChildApp.CHILD_APP_DI_MANAGER_TOKEN,
60
61
  },
61
62
  }),
62
63
  core.provide({
@@ -1,9 +1,11 @@
1
1
  import flatten from '@tinkoff/utils/array/flatten';
2
- import { provide } from '@tramvai/core';
2
+ import { provide, Scope, optional } from '@tramvai/core';
3
3
  import { ChildDispatcherContext } from '@tramvai/state';
4
- import { CHILD_APP_INTERNAL_ROOT_STATE_ALLOWED_STORE_TOKEN } from '@tramvai/tokens-child-app';
5
- import { DISPATCHER_CONTEXT_TOKEN, DISPATCHER_TOKEN, STORE_MIDDLEWARE, INITIAL_APP_STATE_TOKEN } from '@tramvai/tokens-common';
4
+ import { CHILD_APP_INTERNAL_ROOT_STATE_ALLOWED_STORE_TOKEN, CHILD_APP_PAGE_SERVICE_TOKEN, CHILD_APP_ACTIONS_REGISTRY_TOKEN, CHILD_APP_INTERNAL_CONFIG_TOKEN, CHILD_APP_PAGE_COMPONENTS_TOKEN } from '@tramvai/tokens-child-app';
5
+ import { DISPATCHER_CONTEXT_TOKEN, DISPATCHER_TOKEN, STORE_MIDDLEWARE, INITIAL_APP_STATE_TOKEN, COMPONENT_REGISTRY_TOKEN } from '@tramvai/tokens-common';
6
+ import { PAGE_SERVICE_TOKEN } from '@tramvai/tokens-router';
6
7
  import { extractorProviders } from './extractorProviders.browser.browser.js';
8
+ import { ChildAppPageService } from '../pageService.browser.js';
7
9
 
8
10
  const getChildProviders = (appDi, loadableStats) => {
9
11
  const parentDispatcherContext = appDi.get(DISPATCHER_CONTEXT_TOKEN);
@@ -32,6 +34,20 @@ const getChildProviders = (appDi, loadableStats) => {
32
34
  },
33
35
  },
34
36
  }),
37
+ provide({
38
+ provide: CHILD_APP_PAGE_SERVICE_TOKEN,
39
+ scope: Scope.REQUEST,
40
+ useFactory: (deps) => {
41
+ return new ChildAppPageService(deps);
42
+ },
43
+ deps: {
44
+ actionsRegistry: CHILD_APP_ACTIONS_REGISTRY_TOKEN,
45
+ config: CHILD_APP_INTERNAL_CONFIG_TOKEN,
46
+ componentRegistry: COMPONENT_REGISTRY_TOKEN,
47
+ pageService: PAGE_SERVICE_TOKEN,
48
+ pageComponents: optional(CHILD_APP_PAGE_COMPONENTS_TOKEN),
49
+ },
50
+ }),
35
51
  ];
36
52
  };
37
53
 
@@ -1,9 +1,11 @@
1
1
  import flatten from '@tinkoff/utils/array/flatten';
2
- import { provide } from '@tramvai/core';
2
+ import { provide, Scope, optional } from '@tramvai/core';
3
3
  import { ChildDispatcherContext } from '@tramvai/state';
4
- import { CHILD_APP_INTERNAL_ROOT_STATE_ALLOWED_STORE_TOKEN } from '@tramvai/tokens-child-app';
5
- import { DISPATCHER_CONTEXT_TOKEN, DISPATCHER_TOKEN, STORE_MIDDLEWARE, INITIAL_APP_STATE_TOKEN } from '@tramvai/tokens-common';
4
+ import { CHILD_APP_INTERNAL_ROOT_STATE_ALLOWED_STORE_TOKEN, CHILD_APP_PAGE_SERVICE_TOKEN, CHILD_APP_ACTIONS_REGISTRY_TOKEN, CHILD_APP_INTERNAL_CONFIG_TOKEN, CHILD_APP_PAGE_COMPONENTS_TOKEN } from '@tramvai/tokens-child-app';
5
+ import { DISPATCHER_CONTEXT_TOKEN, DISPATCHER_TOKEN, STORE_MIDDLEWARE, INITIAL_APP_STATE_TOKEN, COMPONENT_REGISTRY_TOKEN } from '@tramvai/tokens-common';
6
+ import { PAGE_SERVICE_TOKEN } from '@tramvai/tokens-router';
6
7
  import { extractorProviders } from './extractorProviders.es.js';
8
+ import { ChildAppPageService } from '../pageService.es.js';
7
9
 
8
10
  const getChildProviders = (appDi, loadableStats) => {
9
11
  const parentDispatcherContext = appDi.get(DISPATCHER_CONTEXT_TOKEN);
@@ -32,6 +34,20 @@ const getChildProviders = (appDi, loadableStats) => {
32
34
  },
33
35
  },
34
36
  }),
37
+ provide({
38
+ provide: CHILD_APP_PAGE_SERVICE_TOKEN,
39
+ scope: Scope.REQUEST,
40
+ useFactory: (deps) => {
41
+ return new ChildAppPageService(deps);
42
+ },
43
+ deps: {
44
+ actionsRegistry: CHILD_APP_ACTIONS_REGISTRY_TOKEN,
45
+ config: CHILD_APP_INTERNAL_CONFIG_TOKEN,
46
+ componentRegistry: COMPONENT_REGISTRY_TOKEN,
47
+ pageService: PAGE_SERVICE_TOKEN,
48
+ pageComponents: optional(CHILD_APP_PAGE_COMPONENTS_TOKEN),
49
+ },
50
+ }),
35
51
  ];
36
52
  };
37
53
 
@@ -7,7 +7,9 @@ var core = require('@tramvai/core');
7
7
  var state = require('@tramvai/state');
8
8
  var tokensChildApp = require('@tramvai/tokens-child-app');
9
9
  var tokensCommon = require('@tramvai/tokens-common');
10
+ var tokensRouter = require('@tramvai/tokens-router');
10
11
  var extractorProviders = require('./extractorProviders.js');
12
+ var pageService = require('../pageService.js');
11
13
 
12
14
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
15
 
@@ -40,6 +42,20 @@ const getChildProviders = (appDi, loadableStats) => {
40
42
  },
41
43
  },
42
44
  }),
45
+ core.provide({
46
+ provide: tokensChildApp.CHILD_APP_PAGE_SERVICE_TOKEN,
47
+ scope: core.Scope.REQUEST,
48
+ useFactory: (deps) => {
49
+ return new pageService.ChildAppPageService(deps);
50
+ },
51
+ deps: {
52
+ actionsRegistry: tokensChildApp.CHILD_APP_ACTIONS_REGISTRY_TOKEN,
53
+ config: tokensChildApp.CHILD_APP_INTERNAL_CONFIG_TOKEN,
54
+ componentRegistry: tokensCommon.COMPONENT_REGISTRY_TOKEN,
55
+ pageService: tokensRouter.PAGE_SERVICE_TOKEN,
56
+ pageComponents: core.optional(tokensChildApp.CHILD_APP_PAGE_COMPONENTS_TOKEN),
57
+ },
58
+ }),
43
59
  ];
44
60
  };
45
61
 
@@ -1,6 +1,9 @@
1
- import { provide } from '@tramvai/core';
1
+ import flatten from '@tinkoff/utils/array/flatten';
2
+ import { provide, Scope } from '@tramvai/core';
3
+ import { ActionRegistry } from '@tramvai/module-common';
2
4
  import { LOGGER_TOKEN } from '@tramvai/tokens-common';
3
5
  import { RENDER_SLOTS } from '@tramvai/tokens-render';
6
+ import { CHILD_APP_ACTIONS_REGISTRY_TOKEN, CHILD_APP_INTERNAL_ACTION_TOKEN } from '@tramvai/tokens-child-app';
4
7
  import { getChildProviders as getChildProviders$1 } from '../../browser/child/singletonProviders.browser.js';
5
8
 
6
9
  const getChildProviders = (appDi) => {
@@ -17,6 +20,16 @@ const getChildProviders = (appDi) => {
17
20
  multi: true,
18
21
  useValue: [],
19
22
  }),
23
+ provide({
24
+ provide: CHILD_APP_ACTIONS_REGISTRY_TOKEN,
25
+ scope: Scope.SINGLETON,
26
+ useFactory: ({ actionsList }) => {
27
+ return new ActionRegistry({ actionsList: flatten(actionsList) });
28
+ },
29
+ deps: {
30
+ actionsList: CHILD_APP_INTERNAL_ACTION_TOKEN,
31
+ },
32
+ }),
20
33
  ...getChildProviders$1(appDi),
21
34
  ];
22
35
  };
@@ -1,6 +1,9 @@
1
- import { provide } from '@tramvai/core';
1
+ import flatten from '@tinkoff/utils/array/flatten';
2
+ import { provide, Scope } from '@tramvai/core';
3
+ import { ActionRegistry } from '@tramvai/module-common';
2
4
  import { LOGGER_TOKEN } from '@tramvai/tokens-common';
3
5
  import { RENDER_SLOTS } from '@tramvai/tokens-render';
6
+ import { CHILD_APP_ACTIONS_REGISTRY_TOKEN, CHILD_APP_INTERNAL_ACTION_TOKEN } from '@tramvai/tokens-child-app';
4
7
  import { getChildProviders as getChildProviders$1 } from '../../server/child/singletonProviders.es.js';
5
8
 
6
9
  const getChildProviders = (appDi) => {
@@ -17,6 +20,16 @@ const getChildProviders = (appDi) => {
17
20
  multi: true,
18
21
  useValue: [],
19
22
  }),
23
+ provide({
24
+ provide: CHILD_APP_ACTIONS_REGISTRY_TOKEN,
25
+ scope: Scope.SINGLETON,
26
+ useFactory: ({ actionsList }) => {
27
+ return new ActionRegistry({ actionsList: flatten(actionsList) });
28
+ },
29
+ deps: {
30
+ actionsList: CHILD_APP_INTERNAL_ACTION_TOKEN,
31
+ },
32
+ }),
20
33
  ...getChildProviders$1(),
21
34
  ];
22
35
  };
@@ -2,11 +2,18 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var flatten = require('@tinkoff/utils/array/flatten');
5
6
  var core = require('@tramvai/core');
7
+ var moduleCommon = require('@tramvai/module-common');
6
8
  var tokensCommon = require('@tramvai/tokens-common');
7
9
  var tokensRender = require('@tramvai/tokens-render');
10
+ var tokensChildApp = require('@tramvai/tokens-child-app');
8
11
  var singletonProviders = require('../../server/child/singletonProviders.js');
9
12
 
13
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
14
+
15
+ var flatten__default = /*#__PURE__*/_interopDefaultLegacy(flatten);
16
+
10
17
  const getChildProviders = (appDi) => {
11
18
  const logger = appDi.get(tokensCommon.LOGGER_TOKEN);
12
19
  return [
@@ -21,6 +28,16 @@ const getChildProviders = (appDi) => {
21
28
  multi: true,
22
29
  useValue: [],
23
30
  }),
31
+ core.provide({
32
+ provide: tokensChildApp.CHILD_APP_ACTIONS_REGISTRY_TOKEN,
33
+ scope: core.Scope.SINGLETON,
34
+ useFactory: ({ actionsList }) => {
35
+ return new moduleCommon.ActionRegistry({ actionsList: flatten__default["default"](actionsList) });
36
+ },
37
+ deps: {
38
+ actionsList: tokensChildApp.CHILD_APP_INTERNAL_ACTION_TOKEN,
39
+ },
40
+ }),
24
41
  ...singletonProviders.getChildProviders(),
25
42
  ];
26
43
  };
@@ -11,7 +11,7 @@ const pagePreload = async ({ pageService, preloadManager, }, route) => {
11
11
  ]);
12
12
  await Promise.all(components.map(async (component) => {
13
13
  if (component === null || component === void 0 ? void 0 : component.childApps) {
14
- await Promise.all(component.childApps.map((request) => preloadManager.prefetch(request).catch(() => {
14
+ await Promise.all(component.childApps.map((request) => preloadManager.prefetch(request, route).catch(() => {
15
15
  // actual error will be logged internally
16
16
  })));
17
17
  }
@@ -11,7 +11,7 @@ const pagePreload = async ({ pageService, preloadManager, }, route) => {
11
11
  ]);
12
12
  await Promise.all(components.map(async (component) => {
13
13
  if (component === null || component === void 0 ? void 0 : component.childApps) {
14
- await Promise.all(component.childApps.map((request) => preloadManager.prefetch(request).catch(() => {
14
+ await Promise.all(component.childApps.map((request) => preloadManager.prefetch(request, route).catch(() => {
15
15
  // actual error will be logged internally
16
16
  })));
17
17
  }
@@ -15,7 +15,7 @@ const pagePreload = async ({ pageService, preloadManager, }, route) => {
15
15
  ]);
16
16
  await Promise.all(components.map(async (component) => {
17
17
  if (component === null || component === void 0 ? void 0 : component.childApps) {
18
- await Promise.all(component.childApps.map((request) => preloadManager.prefetch(request).catch(() => {
18
+ await Promise.all(component.childApps.map((request) => preloadManager.prefetch(request, route).catch(() => {
19
19
  // actual error will be logged internally
20
20
  })));
21
21
  }
@@ -0,0 +1,62 @@
1
+ import isArray from '@tinkoff/utils/is/array';
2
+ import { resolveLazyComponent } from '@tramvai/react';
3
+
4
+ class ChildAppPageService {
5
+ constructor({ actionsRegistry, config, componentRegistry, pageService, pageComponents, }) {
6
+ this.actionsRegistry = actionsRegistry;
7
+ this.config = config;
8
+ this.componentRegistry = componentRegistry;
9
+ this.pageService = pageService;
10
+ const componentsGroupName = this.getComponentsGroupName();
11
+ (pageComponents || []).forEach((record) => {
12
+ Object.keys(record).forEach((pageComponentName) => {
13
+ const pageComponent = record[pageComponentName];
14
+ if (!this.componentRegistry.get(pageComponentName, componentsGroupName)) {
15
+ this.componentRegistry.add(pageComponentName, pageComponent, componentsGroupName);
16
+ }
17
+ });
18
+ });
19
+ }
20
+ async resolveComponent(route) {
21
+ const pageComponentName = this.getPageComponentName(route);
22
+ const componentsGroupName = this.getComponentsGroupName();
23
+ if (!pageComponentName) {
24
+ return;
25
+ }
26
+ const pageComponent = this.componentRegistry.get(pageComponentName, componentsGroupName);
27
+ if (pageComponent) {
28
+ if ('load' in pageComponent) {
29
+ await resolveLazyComponent(pageComponent);
30
+ }
31
+ if ('actions' in pageComponent && isArray(pageComponent.actions)) {
32
+ this.actionsRegistry.add(pageComponentName, pageComponent.actions);
33
+ }
34
+ }
35
+ }
36
+ getComponent(route) {
37
+ const pageComponentName = this.getPageComponentName(route);
38
+ const componentsGroupName = this.getComponentsGroupName();
39
+ return this.componentRegistry.get(pageComponentName, componentsGroupName);
40
+ }
41
+ getComponentName(route) {
42
+ const pageComponentName = this.getPageComponentName(route);
43
+ return pageComponentName;
44
+ }
45
+ getActions(route) {
46
+ const pageComponentName = this.getPageComponentName(route);
47
+ return [
48
+ ...(this.actionsRegistry.getGlobal() || []),
49
+ ...(this.actionsRegistry.get(pageComponentName) || []),
50
+ ];
51
+ }
52
+ getPageComponentName(route) {
53
+ var _a;
54
+ const config = (_a = route === null || route === void 0 ? void 0 : route.config) !== null && _a !== void 0 ? _a : this.pageService.getConfig();
55
+ return config === null || config === void 0 ? void 0 : config.unstable_childAppPageComponent;
56
+ }
57
+ getComponentsGroupName() {
58
+ return `${this.config.name}@${this.config.version}`;
59
+ }
60
+ }
61
+
62
+ export { ChildAppPageService };
@@ -0,0 +1,31 @@
1
+ import type { Route } from '@tinkoff/router';
2
+ import type { ExtractDependencyType, PageAction } from '@tramvai/core';
3
+ import type { CHILD_APP_ACTIONS_REGISTRY_TOKEN, CHILD_APP_INTERNAL_CONFIG_TOKEN, CHILD_APP_PAGE_COMPONENTS_TOKEN, ChildAppPageComponent, ChildAppPageService as IChildAppPageService } from '@tramvai/tokens-child-app';
4
+ import type { COMPONENT_REGISTRY_TOKEN } from '@tramvai/tokens-common';
5
+ import type { PAGE_SERVICE_TOKEN } from '@tramvai/tokens-router';
6
+ type ActionsRegistry = ExtractDependencyType<typeof CHILD_APP_ACTIONS_REGISTRY_TOKEN>;
7
+ type Config = ExtractDependencyType<typeof CHILD_APP_INTERNAL_CONFIG_TOKEN>;
8
+ type ComponentRegistry = ExtractDependencyType<typeof COMPONENT_REGISTRY_TOKEN>;
9
+ type PageService = ExtractDependencyType<typeof PAGE_SERVICE_TOKEN>;
10
+ type PageComponents = ExtractDependencyType<typeof CHILD_APP_PAGE_COMPONENTS_TOKEN>;
11
+ export declare class ChildAppPageService implements IChildAppPageService {
12
+ private actionsRegistry;
13
+ private config;
14
+ private componentRegistry;
15
+ private pageService;
16
+ constructor({ actionsRegistry, config, componentRegistry, pageService, pageComponents, }: {
17
+ actionsRegistry: ActionsRegistry;
18
+ config: Config;
19
+ componentRegistry: ComponentRegistry;
20
+ pageService: PageService;
21
+ pageComponents: PageComponents | null;
22
+ });
23
+ resolveComponent(route?: Route): Promise<void>;
24
+ getComponent(route?: Route): ChildAppPageComponent | void;
25
+ getComponentName(route?: Route): string | void;
26
+ getActions(route?: Route): PageAction[];
27
+ private getPageComponentName;
28
+ private getComponentsGroupName;
29
+ }
30
+ export {};
31
+ //# sourceMappingURL=pageService.d.ts.map
@@ -0,0 +1,62 @@
1
+ import isArray from '@tinkoff/utils/is/array';
2
+ import { resolveLazyComponent } from '@tramvai/react';
3
+
4
+ class ChildAppPageService {
5
+ constructor({ actionsRegistry, config, componentRegistry, pageService, pageComponents, }) {
6
+ this.actionsRegistry = actionsRegistry;
7
+ this.config = config;
8
+ this.componentRegistry = componentRegistry;
9
+ this.pageService = pageService;
10
+ const componentsGroupName = this.getComponentsGroupName();
11
+ (pageComponents || []).forEach((record) => {
12
+ Object.keys(record).forEach((pageComponentName) => {
13
+ const pageComponent = record[pageComponentName];
14
+ if (!this.componentRegistry.get(pageComponentName, componentsGroupName)) {
15
+ this.componentRegistry.add(pageComponentName, pageComponent, componentsGroupName);
16
+ }
17
+ });
18
+ });
19
+ }
20
+ async resolveComponent(route) {
21
+ const pageComponentName = this.getPageComponentName(route);
22
+ const componentsGroupName = this.getComponentsGroupName();
23
+ if (!pageComponentName) {
24
+ return;
25
+ }
26
+ const pageComponent = this.componentRegistry.get(pageComponentName, componentsGroupName);
27
+ if (pageComponent) {
28
+ if ('load' in pageComponent) {
29
+ await resolveLazyComponent(pageComponent);
30
+ }
31
+ if ('actions' in pageComponent && isArray(pageComponent.actions)) {
32
+ this.actionsRegistry.add(pageComponentName, pageComponent.actions);
33
+ }
34
+ }
35
+ }
36
+ getComponent(route) {
37
+ const pageComponentName = this.getPageComponentName(route);
38
+ const componentsGroupName = this.getComponentsGroupName();
39
+ return this.componentRegistry.get(pageComponentName, componentsGroupName);
40
+ }
41
+ getComponentName(route) {
42
+ const pageComponentName = this.getPageComponentName(route);
43
+ return pageComponentName;
44
+ }
45
+ getActions(route) {
46
+ const pageComponentName = this.getPageComponentName(route);
47
+ return [
48
+ ...(this.actionsRegistry.getGlobal() || []),
49
+ ...(this.actionsRegistry.get(pageComponentName) || []),
50
+ ];
51
+ }
52
+ getPageComponentName(route) {
53
+ var _a;
54
+ const config = (_a = route === null || route === void 0 ? void 0 : route.config) !== null && _a !== void 0 ? _a : this.pageService.getConfig();
55
+ return config === null || config === void 0 ? void 0 : config.unstable_childAppPageComponent;
56
+ }
57
+ getComponentsGroupName() {
58
+ return `${this.config.name}@${this.config.version}`;
59
+ }
60
+ }
61
+
62
+ export { ChildAppPageService };
@@ -0,0 +1,70 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var isArray = require('@tinkoff/utils/is/array');
6
+ var react = require('@tramvai/react');
7
+
8
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
+
10
+ var isArray__default = /*#__PURE__*/_interopDefaultLegacy(isArray);
11
+
12
+ class ChildAppPageService {
13
+ constructor({ actionsRegistry, config, componentRegistry, pageService, pageComponents, }) {
14
+ this.actionsRegistry = actionsRegistry;
15
+ this.config = config;
16
+ this.componentRegistry = componentRegistry;
17
+ this.pageService = pageService;
18
+ const componentsGroupName = this.getComponentsGroupName();
19
+ (pageComponents || []).forEach((record) => {
20
+ Object.keys(record).forEach((pageComponentName) => {
21
+ const pageComponent = record[pageComponentName];
22
+ if (!this.componentRegistry.get(pageComponentName, componentsGroupName)) {
23
+ this.componentRegistry.add(pageComponentName, pageComponent, componentsGroupName);
24
+ }
25
+ });
26
+ });
27
+ }
28
+ async resolveComponent(route) {
29
+ const pageComponentName = this.getPageComponentName(route);
30
+ const componentsGroupName = this.getComponentsGroupName();
31
+ if (!pageComponentName) {
32
+ return;
33
+ }
34
+ const pageComponent = this.componentRegistry.get(pageComponentName, componentsGroupName);
35
+ if (pageComponent) {
36
+ if ('load' in pageComponent) {
37
+ await react.resolveLazyComponent(pageComponent);
38
+ }
39
+ if ('actions' in pageComponent && isArray__default["default"](pageComponent.actions)) {
40
+ this.actionsRegistry.add(pageComponentName, pageComponent.actions);
41
+ }
42
+ }
43
+ }
44
+ getComponent(route) {
45
+ const pageComponentName = this.getPageComponentName(route);
46
+ const componentsGroupName = this.getComponentsGroupName();
47
+ return this.componentRegistry.get(pageComponentName, componentsGroupName);
48
+ }
49
+ getComponentName(route) {
50
+ const pageComponentName = this.getPageComponentName(route);
51
+ return pageComponentName;
52
+ }
53
+ getActions(route) {
54
+ const pageComponentName = this.getPageComponentName(route);
55
+ return [
56
+ ...(this.actionsRegistry.getGlobal() || []),
57
+ ...(this.actionsRegistry.get(pageComponentName) || []),
58
+ ];
59
+ }
60
+ getPageComponentName(route) {
61
+ var _a;
62
+ const config = (_a = route === null || route === void 0 ? void 0 : route.config) !== null && _a !== void 0 ? _a : this.pageService.getConfig();
63
+ return config === null || config === void 0 ? void 0 : config.unstable_childAppPageComponent;
64
+ }
65
+ getComponentsGroupName() {
66
+ return `${this.config.name}@${this.config.version}`;
67
+ }
68
+ }
69
+
70
+ exports.ChildAppPageService = ChildAppPageService;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tramvai/module-child-app",
3
- "version": "3.33.2",
3
+ "version": "3.37.1",
4
4
  "description": "Module for child apps",
5
5
  "browser": {
6
6
  "./lib/server.js": "./lib/browser.js",
@@ -33,22 +33,23 @@
33
33
  "@tinkoff/env-validators": "0.2.1",
34
34
  "@tinkoff/module-loader-client": "0.5.1",
35
35
  "@tinkoff/module-loader-server": "0.6.3",
36
+ "@tramvai/module-common": "3.37.1",
36
37
  "@tinkoff/url": "0.9.2",
37
- "@tramvai/child-app-core": "3.33.2",
38
+ "@tramvai/child-app-core": "3.37.1",
38
39
  "@tramvai/safe-strings": "0.6.2",
39
- "@tramvai/tokens-child-app": "3.33.2"
40
+ "@tramvai/tokens-child-app": "3.37.1"
40
41
  },
41
42
  "devDependencies": {},
42
43
  "peerDependencies": {
43
44
  "@tinkoff/dippy": "0.9.2",
44
- "@tinkoff/router": "0.3.67",
45
+ "@tinkoff/router": "0.3.73",
45
46
  "@tinkoff/utils": "^2.1.2",
46
- "@tramvai/core": "3.33.2",
47
- "@tramvai/state": "3.33.2",
48
- "@tramvai/react": "3.33.2",
49
- "@tramvai/tokens-common": "3.33.2",
50
- "@tramvai/tokens-render": "3.33.2",
51
- "@tramvai/tokens-router": "3.33.2",
47
+ "@tramvai/core": "3.37.1",
48
+ "@tramvai/state": "3.37.1",
49
+ "@tramvai/react": "3.37.1",
50
+ "@tramvai/tokens-common": "3.37.1",
51
+ "@tramvai/tokens-render": "3.37.1",
52
+ "@tramvai/tokens-router": "3.37.1",
52
53
  "react": ">=16.14.0",
53
54
  "react-dom": ">=16.14.0",
54
55
  "object-assign": "^4.1.1",