@tramvai/module-common 2.109.1 → 2.111.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.
@@ -1,11 +1,11 @@
1
1
  import { __decorate } from 'tslib';
2
- import eachObj from '@tinkoff/utils/object/each';
2
+ import each from '@tinkoff/utils/object/each';
3
3
  import { Module, provide, Scope, BUNDLE_LIST_TOKEN, DI_TOKEN } from '@tramvai/core';
4
4
  import { EnvironmentModule } from '@tramvai/module-environment';
5
5
  import { CookieModule } from '@tramvai/module-cookie';
6
6
  import { LogModule } from '@tramvai/module-log';
7
7
  import { Hooks } from '@tinkoff/hook-runner';
8
- import { HOOK_TOKEN, COMPONENT_REGISTRY_TOKEN, BUNDLE_MANAGER_TOKEN, ADDITIONAL_BUNDLE_TOKEN, ACTION_REGISTRY_TOKEN, DISPATCHER_TOKEN, LOGGER_TOKEN, CONTEXT_TOKEN, PUBSUB_TOKEN, DISPATCHER_CONTEXT_TOKEN, STORE_TOKEN, EXECUTION_CONTEXT_MANAGER_TOKEN } from '@tramvai/tokens-common';
8
+ import { HOOK_TOKEN, COMPONENT_REGISTRY_TOKEN, BUNDLE_MANAGER_TOKEN, ADDITIONAL_BUNDLE_TOKEN, LOGGER_TOKEN, CONTEXT_TOKEN, PUBSUB_TOKEN, DISPATCHER_CONTEXT_TOKEN, STORE_TOKEN, EXECUTION_CONTEXT_MANAGER_TOKEN } from '@tramvai/tokens-common';
9
9
  import { BundleManager } from './bundleManager/bundleManager.browser.js';
10
10
  import { ComponentRegistry } from './componentRegistry/componentRegistry.browser.js';
11
11
  import { RequestManagerModule } from './requestManager/RequestManagerModule.browser.browser.js';
@@ -57,7 +57,7 @@ CommonModule = __decorate([
57
57
  scope: Scope.SINGLETON,
58
58
  useFactory: ({ additionalBundleList, ...bundleManagerDeps }) => {
59
59
  additionalBundleList === null || additionalBundleList === void 0 ? void 0 : additionalBundleList.forEach((bundles) => {
60
- eachObj((bundle, name) => {
60
+ each((bundle, name) => {
61
61
  const bundleAlreadyExists = name in bundleManagerDeps.bundleList;
62
62
  if (!bundleAlreadyExists) {
63
63
  // eslint-disable-next-line no-param-reassign
@@ -71,8 +71,6 @@ CommonModule = __decorate([
71
71
  bundleList: BUNDLE_LIST_TOKEN,
72
72
  additionalBundleList: { token: ADDITIONAL_BUNDLE_TOKEN, optional: true },
73
73
  componentRegistry: COMPONENT_REGISTRY_TOKEN,
74
- actionRegistry: ACTION_REGISTRY_TOKEN,
75
- dispatcher: DISPATCHER_TOKEN,
76
74
  logger: LOGGER_TOKEN,
77
75
  },
78
76
  }),
@@ -1,11 +1,11 @@
1
1
  import { __decorate } from 'tslib';
2
- import eachObj from '@tinkoff/utils/object/each';
2
+ import each from '@tinkoff/utils/object/each';
3
3
  import { Module, provide, Scope, BUNDLE_LIST_TOKEN, DI_TOKEN } from '@tramvai/core';
4
4
  import { EnvironmentModule } from '@tramvai/module-environment';
5
5
  import { CookieModule } from '@tramvai/module-cookie';
6
6
  import { LogModule } from '@tramvai/module-log';
7
7
  import { Hooks } from '@tinkoff/hook-runner';
8
- import { HOOK_TOKEN, COMPONENT_REGISTRY_TOKEN, BUNDLE_MANAGER_TOKEN, ADDITIONAL_BUNDLE_TOKEN, ACTION_REGISTRY_TOKEN, DISPATCHER_TOKEN, LOGGER_TOKEN, CONTEXT_TOKEN, PUBSUB_TOKEN, DISPATCHER_CONTEXT_TOKEN, STORE_TOKEN, EXECUTION_CONTEXT_MANAGER_TOKEN } from '@tramvai/tokens-common';
8
+ import { HOOK_TOKEN, COMPONENT_REGISTRY_TOKEN, BUNDLE_MANAGER_TOKEN, ADDITIONAL_BUNDLE_TOKEN, LOGGER_TOKEN, CONTEXT_TOKEN, PUBSUB_TOKEN, DISPATCHER_CONTEXT_TOKEN, STORE_TOKEN, EXECUTION_CONTEXT_MANAGER_TOKEN } from '@tramvai/tokens-common';
9
9
  import { BundleManager } from './bundleManager/bundleManager.es.js';
10
10
  import { ComponentRegistry } from './componentRegistry/componentRegistry.es.js';
11
11
  import { RequestManagerModule } from './requestManager/RequestManagerModule.es.js';
@@ -57,7 +57,7 @@ CommonModule = __decorate([
57
57
  scope: Scope.SINGLETON,
58
58
  useFactory: ({ additionalBundleList, ...bundleManagerDeps }) => {
59
59
  additionalBundleList === null || additionalBundleList === void 0 ? void 0 : additionalBundleList.forEach((bundles) => {
60
- eachObj((bundle, name) => {
60
+ each((bundle, name) => {
61
61
  const bundleAlreadyExists = name in bundleManagerDeps.bundleList;
62
62
  if (!bundleAlreadyExists) {
63
63
  // eslint-disable-next-line no-param-reassign
@@ -71,8 +71,6 @@ CommonModule = __decorate([
71
71
  bundleList: BUNDLE_LIST_TOKEN,
72
72
  additionalBundleList: { token: ADDITIONAL_BUNDLE_TOKEN, optional: true },
73
73
  componentRegistry: COMPONENT_REGISTRY_TOKEN,
74
- actionRegistry: ACTION_REGISTRY_TOKEN,
75
- dispatcher: DISPATCHER_TOKEN,
76
74
  logger: LOGGER_TOKEN,
77
75
  },
78
76
  }),
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var tslib = require('tslib');
6
- var eachObj = require('@tinkoff/utils/object/each');
6
+ var each = require('@tinkoff/utils/object/each');
7
7
  var core = require('@tramvai/core');
8
8
  var moduleEnvironment = require('@tramvai/module-environment');
9
9
  var moduleCookie = require('@tramvai/module-cookie');
@@ -25,7 +25,7 @@ var executionContextManager = require('./executionContext/executionContextManage
25
25
 
26
26
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
27
27
 
28
- var eachObj__default = /*#__PURE__*/_interopDefaultLegacy(eachObj);
28
+ var each__default = /*#__PURE__*/_interopDefaultLegacy(each);
29
29
 
30
30
  exports.CommonModule = class CommonModule {
31
31
  };
@@ -65,7 +65,7 @@ exports.CommonModule = tslib.__decorate([
65
65
  scope: core.Scope.SINGLETON,
66
66
  useFactory: ({ additionalBundleList, ...bundleManagerDeps }) => {
67
67
  additionalBundleList === null || additionalBundleList === void 0 ? void 0 : additionalBundleList.forEach((bundles) => {
68
- eachObj__default["default"]((bundle, name) => {
68
+ each__default["default"]((bundle, name) => {
69
69
  const bundleAlreadyExists = name in bundleManagerDeps.bundleList;
70
70
  if (!bundleAlreadyExists) {
71
71
  // eslint-disable-next-line no-param-reassign
@@ -79,8 +79,6 @@ exports.CommonModule = tslib.__decorate([
79
79
  bundleList: core.BUNDLE_LIST_TOKEN,
80
80
  additionalBundleList: { token: tokensCommon.ADDITIONAL_BUNDLE_TOKEN, optional: true },
81
81
  componentRegistry: tokensCommon.COMPONENT_REGISTRY_TOKEN,
82
- actionRegistry: tokensCommon.ACTION_REGISTRY_TOKEN,
83
- dispatcher: tokensCommon.DISPATCHER_TOKEN,
84
82
  logger: tokensCommon.LOGGER_TOKEN,
85
83
  },
86
84
  }),
@@ -1,18 +1,13 @@
1
- import eachObj from '@tinkoff/utils/object/each';
2
- import isObject from '@tinkoff/utils/is/object';
3
- import isArray from '@tinkoff/utils/is/array';
4
1
  import identity from '@tinkoff/utils/function/identity';
5
2
  import { createBundle } from '@tramvai/core';
6
- import { resolveLazyComponent, __lazyErrorHandler } from '@tramvai/react';
3
+ import { __lazyErrorHandler } from '@tramvai/react';
7
4
  import { fileSystemPagesEnabled, getAllFileSystemPages, getAllFileSystemLayouts, getAllFileSystemErrorBoundaries, getAllFileSystemWildcards, isFileSystemPageComponent, fileSystemPageToLayoutKey, fileSystemPageToErrorBoundaryKey } from '@tramvai/experiments';
8
5
 
9
6
  const FS_PAGES_DEFAULT_BUNDLE = '__default';
10
7
  class BundleManager {
11
- constructor({ bundleList, componentRegistry, actionRegistry, dispatcher, logger }) {
8
+ constructor({ bundleList, componentRegistry, logger }) {
12
9
  this.bundles = bundleList;
13
10
  this.componentRegistry = componentRegistry;
14
- this.actionRegistry = actionRegistry;
15
- this.dispatcher = dispatcher;
16
11
  if (fileSystemPagesEnabled()) {
17
12
  const log = logger('file-system-pages:bundle-manager');
18
13
  const components = getAllFileSystemPages();
@@ -59,7 +54,7 @@ class BundleManager {
59
54
  // eslint-disable-next-line no-param-reassign
60
55
  name = FS_PAGES_DEFAULT_BUNDLE;
61
56
  }
62
- return this.loadBundle(name, pageComponent).then((bundle) => this.resolve(bundle.default, pageComponent));
57
+ return this.loadBundle(name, pageComponent).then((bundle) => bundle.default);
63
58
  }
64
59
  has(name, pageComponent) {
65
60
  // use fake bundle with file-system pages
@@ -69,42 +64,6 @@ class BundleManager {
69
64
  }
70
65
  return !!this.bundles[name];
71
66
  }
72
- async resolve(bundle, pageComponent) {
73
- // preload `lazy` components then register actions and reducers
74
- if (pageComponent && bundle.components[pageComponent]) {
75
- const componentOrLoader = bundle.components[pageComponent];
76
- const component = await resolveLazyComponent(componentOrLoader);
77
- if (!component) {
78
- return;
79
- }
80
- // allow page components to register any other components
81
- if ('components' in component && isObject(component.components)) {
82
- eachObj((cmp, name) => {
83
- this.componentRegistry.add(name, cmp, pageComponent);
84
- }, component.components);
85
- }
86
- if ('actions' in component && isArray(component.actions)) {
87
- this.actionRegistry.add(pageComponent, component.actions);
88
- }
89
- if ('reducers' in component && isArray(component.reducers)) {
90
- component.reducers.forEach((reducer) => {
91
- this.dispatcher.registerStore(reducer);
92
- });
93
- }
94
- }
95
- eachObj((component, name) => {
96
- this.componentRegistry.add(name, component, bundle.name);
97
- }, bundle.components);
98
- if (bundle.actions) {
99
- this.actionRegistry.add(bundle.name, bundle.actions);
100
- }
101
- if (bundle.reducers) {
102
- bundle.reducers.forEach((reducer) => {
103
- this.dispatcher.registerStore(reducer);
104
- });
105
- }
106
- return bundle;
107
- }
108
67
  loadBundle(name, pageComponent) {
109
68
  if (!this.has(name, pageComponent)) {
110
69
  return Promise.reject(new Error(`Bundle "${name}" not found`));
@@ -1,4 +1,4 @@
1
- import type { BUNDLE_MANAGER_TOKEN, DISPATCHER_TOKEN, ActionsRegistry, LOGGER_TOKEN } from '@tramvai/tokens-common';
1
+ import type { BUNDLE_MANAGER_TOKEN, LOGGER_TOKEN } from '@tramvai/tokens-common';
2
2
  import type { Bundle, ExtractDependencyType } from '@tramvai/core';
3
3
  import type { ComponentRegistry } from '../componentRegistry/componentRegistry';
4
4
  type Interface = typeof BUNDLE_MANAGER_TOKEN;
@@ -7,19 +7,14 @@ type Deps = {
7
7
  default: Bundle;
8
8
  }>>;
9
9
  componentRegistry: ComponentRegistry;
10
- actionRegistry: ActionsRegistry;
11
- dispatcher: ExtractDependencyType<typeof DISPATCHER_TOKEN>;
12
10
  logger: ExtractDependencyType<typeof LOGGER_TOKEN>;
13
11
  };
14
12
  export declare class BundleManager implements Interface {
15
13
  bundles: Deps['bundleList'];
16
- actionRegistry: Deps['actionRegistry'];
17
14
  componentRegistry: Deps['componentRegistry'];
18
- dispatcher: Deps['dispatcher'];
19
- constructor({ bundleList, componentRegistry, actionRegistry, dispatcher, logger }: Deps);
20
- get(name: string, pageComponent: string): Promise<Bundle | undefined>;
15
+ constructor({ bundleList, componentRegistry, logger }: Deps);
16
+ get(name: string, pageComponent: string): Promise<Bundle>;
21
17
  has(name: string, pageComponent: string): boolean;
22
- private resolve;
23
18
  private loadBundle;
24
19
  }
25
20
  export {};
@@ -1,18 +1,13 @@
1
- import eachObj from '@tinkoff/utils/object/each';
2
- import isObject from '@tinkoff/utils/is/object';
3
- import isArray from '@tinkoff/utils/is/array';
4
1
  import identity from '@tinkoff/utils/function/identity';
5
2
  import { createBundle } from '@tramvai/core';
6
- import { resolveLazyComponent, __lazyErrorHandler } from '@tramvai/react';
3
+ import { __lazyErrorHandler } from '@tramvai/react';
7
4
  import { fileSystemPagesEnabled, getAllFileSystemPages, getAllFileSystemLayouts, getAllFileSystemErrorBoundaries, getAllFileSystemWildcards, isFileSystemPageComponent, fileSystemPageToLayoutKey, fileSystemPageToErrorBoundaryKey } from '@tramvai/experiments';
8
5
 
9
6
  const FS_PAGES_DEFAULT_BUNDLE = '__default';
10
7
  class BundleManager {
11
- constructor({ bundleList, componentRegistry, actionRegistry, dispatcher, logger }) {
8
+ constructor({ bundleList, componentRegistry, logger }) {
12
9
  this.bundles = bundleList;
13
10
  this.componentRegistry = componentRegistry;
14
- this.actionRegistry = actionRegistry;
15
- this.dispatcher = dispatcher;
16
11
  if (fileSystemPagesEnabled()) {
17
12
  const log = logger('file-system-pages:bundle-manager');
18
13
  const components = getAllFileSystemPages();
@@ -59,7 +54,7 @@ class BundleManager {
59
54
  // eslint-disable-next-line no-param-reassign
60
55
  name = FS_PAGES_DEFAULT_BUNDLE;
61
56
  }
62
- return this.loadBundle(name, pageComponent).then((bundle) => this.resolve(bundle.default, pageComponent));
57
+ return this.loadBundle(name, pageComponent).then((bundle) => bundle.default);
63
58
  }
64
59
  has(name, pageComponent) {
65
60
  // use fake bundle with file-system pages
@@ -69,42 +64,6 @@ class BundleManager {
69
64
  }
70
65
  return !!this.bundles[name];
71
66
  }
72
- async resolve(bundle, pageComponent) {
73
- // preload `lazy` components then register actions and reducers
74
- if (pageComponent && bundle.components[pageComponent]) {
75
- const componentOrLoader = bundle.components[pageComponent];
76
- const component = await resolveLazyComponent(componentOrLoader);
77
- if (!component) {
78
- return;
79
- }
80
- // allow page components to register any other components
81
- if ('components' in component && isObject(component.components)) {
82
- eachObj((cmp, name) => {
83
- this.componentRegistry.add(name, cmp, pageComponent);
84
- }, component.components);
85
- }
86
- if ('actions' in component && isArray(component.actions)) {
87
- this.actionRegistry.add(pageComponent, component.actions);
88
- }
89
- if ('reducers' in component && isArray(component.reducers)) {
90
- component.reducers.forEach((reducer) => {
91
- this.dispatcher.registerStore(reducer);
92
- });
93
- }
94
- }
95
- eachObj((component, name) => {
96
- this.componentRegistry.add(name, component, bundle.name);
97
- }, bundle.components);
98
- if (bundle.actions) {
99
- this.actionRegistry.add(bundle.name, bundle.actions);
100
- }
101
- if (bundle.reducers) {
102
- bundle.reducers.forEach((reducer) => {
103
- this.dispatcher.registerStore(reducer);
104
- });
105
- }
106
- return bundle;
107
- }
108
67
  loadBundle(name, pageComponent) {
109
68
  if (!this.has(name, pageComponent)) {
110
69
  return Promise.reject(new Error(`Bundle "${name}" not found`));
@@ -2,9 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var eachObj = require('@tinkoff/utils/object/each');
6
- var isObject = require('@tinkoff/utils/is/object');
7
- var isArray = require('@tinkoff/utils/is/array');
8
5
  var identity = require('@tinkoff/utils/function/identity');
9
6
  var core = require('@tramvai/core');
10
7
  var react = require('@tramvai/react');
@@ -12,18 +9,13 @@ var experiments = require('@tramvai/experiments');
12
9
 
13
10
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
14
11
 
15
- var eachObj__default = /*#__PURE__*/_interopDefaultLegacy(eachObj);
16
- var isObject__default = /*#__PURE__*/_interopDefaultLegacy(isObject);
17
- var isArray__default = /*#__PURE__*/_interopDefaultLegacy(isArray);
18
12
  var identity__default = /*#__PURE__*/_interopDefaultLegacy(identity);
19
13
 
20
14
  const FS_PAGES_DEFAULT_BUNDLE = '__default';
21
15
  class BundleManager {
22
- constructor({ bundleList, componentRegistry, actionRegistry, dispatcher, logger }) {
16
+ constructor({ bundleList, componentRegistry, logger }) {
23
17
  this.bundles = bundleList;
24
18
  this.componentRegistry = componentRegistry;
25
- this.actionRegistry = actionRegistry;
26
- this.dispatcher = dispatcher;
27
19
  if (experiments.fileSystemPagesEnabled()) {
28
20
  const log = logger('file-system-pages:bundle-manager');
29
21
  const components = experiments.getAllFileSystemPages();
@@ -70,7 +62,7 @@ class BundleManager {
70
62
  // eslint-disable-next-line no-param-reassign
71
63
  name = FS_PAGES_DEFAULT_BUNDLE;
72
64
  }
73
- return this.loadBundle(name, pageComponent).then((bundle) => this.resolve(bundle.default, pageComponent));
65
+ return this.loadBundle(name, pageComponent).then((bundle) => bundle.default);
74
66
  }
75
67
  has(name, pageComponent) {
76
68
  // use fake bundle with file-system pages
@@ -80,42 +72,6 @@ class BundleManager {
80
72
  }
81
73
  return !!this.bundles[name];
82
74
  }
83
- async resolve(bundle, pageComponent) {
84
- // preload `lazy` components then register actions and reducers
85
- if (pageComponent && bundle.components[pageComponent]) {
86
- const componentOrLoader = bundle.components[pageComponent];
87
- const component = await react.resolveLazyComponent(componentOrLoader);
88
- if (!component) {
89
- return;
90
- }
91
- // allow page components to register any other components
92
- if ('components' in component && isObject__default["default"](component.components)) {
93
- eachObj__default["default"]((cmp, name) => {
94
- this.componentRegistry.add(name, cmp, pageComponent);
95
- }, component.components);
96
- }
97
- if ('actions' in component && isArray__default["default"](component.actions)) {
98
- this.actionRegistry.add(pageComponent, component.actions);
99
- }
100
- if ('reducers' in component && isArray__default["default"](component.reducers)) {
101
- component.reducers.forEach((reducer) => {
102
- this.dispatcher.registerStore(reducer);
103
- });
104
- }
105
- }
106
- eachObj__default["default"]((component, name) => {
107
- this.componentRegistry.add(name, component, bundle.name);
108
- }, bundle.components);
109
- if (bundle.actions) {
110
- this.actionRegistry.add(bundle.name, bundle.actions);
111
- }
112
- if (bundle.reducers) {
113
- bundle.reducers.forEach((reducer) => {
114
- this.dispatcher.registerStore(reducer);
115
- });
116
- }
117
- return bundle;
118
- }
119
75
  loadBundle(name, pageComponent) {
120
76
  if (!this.has(name, pageComponent)) {
121
77
  return Promise.reject(new Error(`Bundle "${name}" not found`));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tramvai/module-common",
3
- "version": "2.109.1",
3
+ "version": "2.111.0",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -32,28 +32,28 @@
32
32
  "@tinkoff/lru-cache-nano": "^7.8.1",
33
33
  "@tinkoff/pubsub": "0.5.7",
34
34
  "@tinkoff/url": "0.8.6",
35
- "@tramvai/experiments": "2.109.1",
36
- "@tramvai/module-cookie": "2.109.1",
37
- "@tramvai/module-environment": "2.109.1",
38
- "@tramvai/module-log": "2.109.1",
39
- "@tramvai/tokens-child-app": "2.109.1",
40
- "@tramvai/tokens-core-private": "2.109.1",
41
- "@tramvai/tokens-common": "2.109.1",
42
- "@tramvai/tokens-render": "2.109.1",
43
- "@tramvai/tokens-server-private": "2.109.1",
44
- "@tramvai/types-actions-state-context": "2.109.1",
35
+ "@tramvai/experiments": "2.111.0",
36
+ "@tramvai/module-cookie": "2.111.0",
37
+ "@tramvai/module-environment": "2.111.0",
38
+ "@tramvai/module-log": "2.111.0",
39
+ "@tramvai/tokens-child-app": "2.111.0",
40
+ "@tramvai/tokens-core-private": "2.111.0",
41
+ "@tramvai/tokens-common": "2.111.0",
42
+ "@tramvai/tokens-render": "2.111.0",
43
+ "@tramvai/tokens-server-private": "2.111.0",
44
+ "@tramvai/types-actions-state-context": "2.111.0",
45
45
  "hoist-non-react-statics": "^3.3.1",
46
46
  "node-abort-controller": "^3.0.1"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "@tinkoff/dippy": "0.8.15",
50
50
  "@tinkoff/utils": "^2.1.2",
51
- "@tramvai/cli": "2.109.1",
52
- "@tramvai/core": "2.109.1",
53
- "@tramvai/papi": "2.109.1",
54
- "@tramvai/react": "2.109.1",
55
- "@tramvai/state": "2.109.1",
56
- "@tramvai/tokens-server": "2.109.1",
51
+ "@tramvai/cli": "2.111.0",
52
+ "@tramvai/core": "2.111.0",
53
+ "@tramvai/papi": "2.111.0",
54
+ "@tramvai/react": "2.111.0",
55
+ "@tramvai/state": "2.111.0",
56
+ "@tramvai/tokens-server": "2.111.0",
57
57
  "react": ">=16.14.0",
58
58
  "tslib": "^2.4.0"
59
59
  },