@tramvai/module-router 1.105.2 → 1.106.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@ import { provide, commandLineListTokens, Module, DI_TOKEN, COMMAND_LINE_RUNNER_T
2
2
  import { Provider, setLogger, NoSpaRouter, Router } from '@tinkoff/router';
3
3
  export { Link, Provider, useNavigate, useRoute, useRouter, useUrl } from '@tinkoff/router';
4
4
  import noop from '@tinkoff/utils/function/noop';
5
- import { LOGGER_TOKEN, BUNDLE_MANAGER_TOKEN, ACTION_REGISTRY_TOKEN, RESPONSE_MANAGER_TOKEN, CONTEXT_TOKEN, COMPONENT_REGISTRY_TOKEN, COMBINE_REDUCERS, STORE_TOKEN, ACTION_PAGE_RUNNER_TOKEN } from '@tramvai/tokens-common';
5
+ import { LOGGER_TOKEN, BUNDLE_MANAGER_TOKEN, ACTION_REGISTRY_TOKEN, RESPONSE_MANAGER_TOKEN, DISPATCHER_CONTEXT_TOKEN, CONTEXT_TOKEN, COMPONENT_REGISTRY_TOKEN, COMBINE_REDUCERS, STORE_TOKEN, ACTION_PAGE_RUNNER_TOKEN } from '@tramvai/tokens-common';
6
6
  import { ROUTER_GUARD_TOKEN, ROUTE_TRANSFORM_TOKEN, ROUTER_TOKEN, ROUTES_TOKEN, ROUTE_RESOLVE_TOKEN, ROUTER_SPA_ACTIONS_RUN_MODE_TOKEN, PAGE_SERVICE_TOKEN } from '@tramvai/tokens-router';
7
7
  export * from '@tramvai/tokens-router';
8
8
  import { EXTEND_RENDER, TRAMVAI_RENDER_MODE } from '@tramvai/tokens-render';
@@ -64,9 +64,10 @@ const afterUpdateCurrentHooksToken = createToken('router afterUpdateCurrentHooks
64
64
  const routeTransformToken = createToken('router finalRouteTransform');
65
65
  createToken('router bundleInfoAdditional');
66
66
 
67
- const loadBundle = ({ bundleManager, logger, actionRegistry, responseManager, }) => {
67
+ const loadBundle = ({ bundleManager, logger, actionRegistry, responseManager, dispatcherContext, }) => {
68
68
  const log = logger('route:load-bundles');
69
69
  return async ({ to }) => {
70
+ var _a;
70
71
  log.debug({
71
72
  event: 'load-bundle',
72
73
  route: to,
@@ -86,7 +87,12 @@ const loadBundle = ({ bundleManager, logger, actionRegistry, responseManager, })
86
87
  // несмотря на наличие бандла в разметке, все равно мы должны дождаться
87
88
  // его загрузки перед рендером
88
89
  try {
89
- await bundleManager.get(bundle, pageComponent);
90
+ const { components, reducers } = await bundleManager.get(bundle, pageComponent);
91
+ const component = components[pageComponent];
92
+ // pageComponent should have required fields even if it is lazy,
93
+ // thanks to `git log 9466cb32bfb71ba49144ef839d3d5bce246e213c -L90,103:packages/modules/common/src/bundleManager/bundleManager.ts`
94
+ (_a = component === null || component === void 0 ? void 0 : component.reducers) === null || _a === void 0 ? void 0 : _a.forEach((reducer) => dispatcherContext.getStore(reducer));
95
+ reducers === null || reducers === void 0 ? void 0 : reducers.forEach((reducer) => dispatcherContext.getStore(reducer));
90
96
  }
91
97
  catch (error) {
92
98
  log.error({
@@ -122,6 +128,7 @@ const commonGuards = [
122
128
  bundleManager: BUNDLE_MANAGER_TOKEN,
123
129
  actionRegistry: ACTION_REGISTRY_TOKEN,
124
130
  responseManager: RESPONSE_MANAGER_TOKEN,
131
+ dispatcherContext: DISPATCHER_CONTEXT_TOKEN,
125
132
  },
126
133
  },
127
134
  {
package/lib/index.es.js CHANGED
@@ -2,7 +2,7 @@ import { __decorate } from 'tslib';
2
2
  import { provide, commandLineListTokens, Module } from '@tramvai/core';
3
3
  import { Provider, setLogger, isWildcard, isHistoryFallback, Router } from '@tinkoff/router';
4
4
  export { Link, Provider, useNavigate, useRoute, useRouter, useUrl } from '@tinkoff/router';
5
- import { LOGGER_TOKEN, BUNDLE_MANAGER_TOKEN, ACTION_REGISTRY_TOKEN, RESPONSE_MANAGER_TOKEN, CONTEXT_TOKEN, COMPONENT_REGISTRY_TOKEN, COMBINE_REDUCERS, REQUEST_MANAGER_TOKEN, STORE_TOKEN, ACTION_PAGE_RUNNER_TOKEN } from '@tramvai/tokens-common';
5
+ import { LOGGER_TOKEN, BUNDLE_MANAGER_TOKEN, ACTION_REGISTRY_TOKEN, RESPONSE_MANAGER_TOKEN, DISPATCHER_CONTEXT_TOKEN, CONTEXT_TOKEN, COMPONENT_REGISTRY_TOKEN, COMBINE_REDUCERS, REQUEST_MANAGER_TOKEN, STORE_TOKEN, ACTION_PAGE_RUNNER_TOKEN } from '@tramvai/tokens-common';
6
6
  import { ROUTER_GUARD_TOKEN, ROUTE_TRANSFORM_TOKEN, ROUTER_TOKEN, ROUTES_TOKEN, ROUTE_RESOLVE_TOKEN, ROUTER_SPA_ACTIONS_RUN_MODE_TOKEN, PAGE_SERVICE_TOKEN } from '@tramvai/tokens-router';
7
7
  export * from '@tramvai/tokens-router';
8
8
  import flatten from '@tinkoff/utils/array/flatten';
@@ -66,9 +66,10 @@ const RouterStore = createReducer('router', initialState)
66
66
  };
67
67
  });
68
68
 
69
- const loadBundle = ({ bundleManager, logger, actionRegistry, responseManager, }) => {
69
+ const loadBundle = ({ bundleManager, logger, actionRegistry, responseManager, dispatcherContext, }) => {
70
70
  const log = logger('route:load-bundles');
71
71
  return async ({ to }) => {
72
+ var _a;
72
73
  log.debug({
73
74
  event: 'load-bundle',
74
75
  route: to,
@@ -88,7 +89,12 @@ const loadBundle = ({ bundleManager, logger, actionRegistry, responseManager, })
88
89
  // несмотря на наличие бандла в разметке, все равно мы должны дождаться
89
90
  // его загрузки перед рендером
90
91
  try {
91
- await bundleManager.get(bundle, pageComponent);
92
+ const { components, reducers } = await bundleManager.get(bundle, pageComponent);
93
+ const component = components[pageComponent];
94
+ // pageComponent should have required fields even if it is lazy,
95
+ // thanks to `git log 9466cb32bfb71ba49144ef839d3d5bce246e213c -L90,103:packages/modules/common/src/bundleManager/bundleManager.ts`
96
+ (_a = component === null || component === void 0 ? void 0 : component.reducers) === null || _a === void 0 ? void 0 : _a.forEach((reducer) => dispatcherContext.getStore(reducer));
97
+ reducers === null || reducers === void 0 ? void 0 : reducers.forEach((reducer) => dispatcherContext.getStore(reducer));
92
98
  }
93
99
  catch (error) {
94
100
  log.error({
@@ -124,6 +130,7 @@ const commonGuards = [
124
130
  bundleManager: BUNDLE_MANAGER_TOKEN,
125
131
  actionRegistry: ACTION_REGISTRY_TOKEN,
126
132
  responseManager: RESPONSE_MANAGER_TOKEN,
133
+ dispatcherContext: DISPATCHER_CONTEXT_TOKEN,
127
134
  },
128
135
  },
129
136
  {
package/lib/index.js CHANGED
@@ -77,9 +77,10 @@ const RouterStore = state.createReducer('router', initialState)
77
77
  };
78
78
  });
79
79
 
80
- const loadBundle = ({ bundleManager, logger, actionRegistry, responseManager, }) => {
80
+ const loadBundle = ({ bundleManager, logger, actionRegistry, responseManager, dispatcherContext, }) => {
81
81
  const log = logger('route:load-bundles');
82
82
  return async ({ to }) => {
83
+ var _a;
83
84
  log.debug({
84
85
  event: 'load-bundle',
85
86
  route: to,
@@ -99,7 +100,12 @@ const loadBundle = ({ bundleManager, logger, actionRegistry, responseManager, })
99
100
  // несмотря на наличие бандла в разметке, все равно мы должны дождаться
100
101
  // его загрузки перед рендером
101
102
  try {
102
- await bundleManager.get(bundle, pageComponent);
103
+ const { components, reducers } = await bundleManager.get(bundle, pageComponent);
104
+ const component = components[pageComponent];
105
+ // pageComponent should have required fields even if it is lazy,
106
+ // thanks to `git log 9466cb32bfb71ba49144ef839d3d5bce246e213c -L90,103:packages/modules/common/src/bundleManager/bundleManager.ts`
107
+ (_a = component === null || component === void 0 ? void 0 : component.reducers) === null || _a === void 0 ? void 0 : _a.forEach((reducer) => dispatcherContext.getStore(reducer));
108
+ reducers === null || reducers === void 0 ? void 0 : reducers.forEach((reducer) => dispatcherContext.getStore(reducer));
103
109
  }
104
110
  catch (error) {
105
111
  log.error({
@@ -135,6 +141,7 @@ const commonGuards = [
135
141
  bundleManager: tokensCommon.BUNDLE_MANAGER_TOKEN,
136
142
  actionRegistry: tokensCommon.ACTION_REGISTRY_TOKEN,
137
143
  responseManager: tokensCommon.RESPONSE_MANAGER_TOKEN,
144
+ dispatcherContext: tokensCommon.DISPATCHER_CONTEXT_TOKEN,
138
145
  },
139
146
  },
140
147
  {
@@ -1,8 +1,9 @@
1
1
  import type { NavigationGuard } from '@tinkoff/router';
2
- import type { BUNDLE_MANAGER_TOKEN, ACTION_REGISTRY_TOKEN, LOGGER_TOKEN, RESPONSE_MANAGER_TOKEN } from '@tramvai/tokens-common';
3
- export declare const loadBundle: ({ bundleManager, logger, actionRegistry, responseManager, }: {
2
+ import type { BUNDLE_MANAGER_TOKEN, ACTION_REGISTRY_TOKEN, LOGGER_TOKEN, RESPONSE_MANAGER_TOKEN, DISPATCHER_CONTEXT_TOKEN } from '@tramvai/tokens-common';
3
+ export declare const loadBundle: ({ bundleManager, logger, actionRegistry, responseManager, dispatcherContext, }: {
4
4
  bundleManager: typeof BUNDLE_MANAGER_TOKEN;
5
5
  logger: typeof LOGGER_TOKEN;
6
6
  actionRegistry: typeof ACTION_REGISTRY_TOKEN;
7
7
  responseManager: typeof RESPONSE_MANAGER_TOKEN;
8
+ dispatcherContext: typeof DISPATCHER_CONTEXT_TOKEN;
8
9
  }) => NavigationGuard;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tramvai/module-router",
3
- "version": "1.105.2",
3
+ "version": "1.106.0",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "browser": {
@@ -23,25 +23,25 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "@tinkoff/errors": "0.2.21",
26
- "@tinkoff/router": "0.1.75",
26
+ "@tinkoff/router": "0.1.76",
27
27
  "@tinkoff/url": "0.7.38",
28
- "@tramvai/tokens-child-app": "1.105.2",
29
- "@tramvai/tokens-render": "1.105.2",
30
- "@tramvai/tokens-router": "1.105.2",
31
- "@tramvai/tokens-server": "1.105.2",
32
- "@tramvai/experiments": "1.105.2"
28
+ "@tramvai/tokens-child-app": "1.106.0",
29
+ "@tramvai/tokens-render": "1.106.0",
30
+ "@tramvai/tokens-router": "1.106.0",
31
+ "@tramvai/tokens-server": "1.106.0",
32
+ "@tramvai/experiments": "1.106.0"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "@tinkoff/utils": "^2.1.2",
36
- "@tramvai/cli": "1.105.2",
37
- "@tramvai/core": "1.105.2",
38
- "@tramvai/module-log": "1.105.2",
39
- "@tramvai/module-server": "1.105.2",
40
- "@tramvai/papi": "1.105.2",
41
- "@tramvai/state": "1.105.2",
42
- "@tramvai/test-helpers": "1.105.2",
43
- "@tramvai/test-mocks": "1.105.2",
44
- "@tramvai/tokens-common": "1.105.2",
36
+ "@tramvai/cli": "1.106.0",
37
+ "@tramvai/core": "1.106.0",
38
+ "@tramvai/module-log": "1.106.0",
39
+ "@tramvai/module-server": "1.106.0",
40
+ "@tramvai/papi": "1.106.0",
41
+ "@tramvai/state": "1.106.0",
42
+ "@tramvai/test-helpers": "1.106.0",
43
+ "@tramvai/test-mocks": "1.106.0",
44
+ "@tramvai/tokens-common": "1.106.0",
45
45
  "@tinkoff/dippy": "0.7.41",
46
46
  "react": "*",
47
47
  "tslib": "^2.0.3"