@tramvai/core 1.55.1 → 1.55.5
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/actions/createActions.d.ts +1 -1
- package/lib/bundles/createBundle.d.ts +1 -1
- package/lib/createApp.d.ts +1 -1
- package/lib/index.d.ts +2 -5
- package/lib/index.es.js +24 -28
- package/lib/index.js +32 -41
- package/package.json +5 -3
- package/lib/bundles/createBundle.h.d.ts +0 -20
- package/lib/command/command.h.d.ts +0 -1
- package/lib/tokens.d.ts +0 -33
- package/lib/types/action.d.ts +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ActionParameters, Action } from '
|
|
1
|
+
import type { ActionParameters, Action } from '@tramvai/tokens-core';
|
|
2
2
|
export declare function createAction<Result = any, Payload = any, Deps = any>(action: ActionParameters<Payload, Result, Deps>): Action<Payload, Result, Deps>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { BundleOptions, Bundle } from '
|
|
1
|
+
import type { BundleOptions, Bundle } from '@tramvai/tokens-core';
|
|
2
2
|
export declare function createBundle(options: BundleOptions): Bundle;
|
package/lib/createApp.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Container, Provider } from '@tinkoff/dippy';
|
|
2
|
+
import type { Bundle } from '@tramvai/tokens-core';
|
|
2
3
|
import type { ModuleType, ExtendedModule } from './modules/module.h';
|
|
3
|
-
import type { Bundle } from './bundles/createBundle.h';
|
|
4
4
|
interface AppOptions {
|
|
5
5
|
name: string;
|
|
6
6
|
modules?: (ModuleType | ExtendedModule)[];
|
package/lib/index.d.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
export { createApp, App } from './createApp';
|
|
2
2
|
export { createBundle } from './bundles/createBundle';
|
|
3
|
-
export { Bundle, BundleImport } from './bundles/createBundle.h';
|
|
4
3
|
export { createAction } from './actions/createActions';
|
|
5
|
-
export * from './types/action';
|
|
6
4
|
export { Module, deprecatedModule as module, MODULE_PARAMETERS } from './modules/module';
|
|
7
5
|
export { getModuleParameters } from './modules/getModuleParameters';
|
|
8
6
|
export { walkOfModules } from './modules/walkOfModules';
|
|
9
7
|
export { isExtendedModule } from './modules/isExtendedModule';
|
|
10
8
|
export { ModuleType, ExtendedModule } from './modules/module.h';
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export { Scope, Provider, createToken, provide } from '@tinkoff/dippy';
|
|
9
|
+
export * from '@tramvai/tokens-core';
|
|
10
|
+
export { DI_TOKEN, IS_DI_CHILD_CONTAINER_TOKEN, Scope, Provider, createToken, provide, } from '@tinkoff/dippy';
|
package/lib/index.es.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createContainer, Scope } from '@tinkoff/dippy';
|
|
2
2
|
export { DI_TOKEN, IS_DI_CHILD_CONTAINER_TOKEN, Scope, createToken, provide } from '@tinkoff/dippy';
|
|
3
|
+
import { APP_INFO_TOKEN, BUNDLE_LIST_TOKEN, ACTIONS_LIST_TOKEN, MODULES_LIST_TOKEN, COMMAND_LINE_RUNNER_TOKEN, ACTION_PARAMETERS } from '@tramvai/tokens-core';
|
|
4
|
+
export * from '@tramvai/tokens-core';
|
|
5
|
+
import { LOGGER_TOKEN } from '@tramvai/tokens-common';
|
|
3
6
|
import concat from '@tinkoff/utils/array/concat';
|
|
4
7
|
import mergeWith from '@tinkoff/utils/object/mergeWith';
|
|
5
8
|
import omit from '@tinkoff/utils/object/omit';
|
|
6
|
-
import { ACTION_PARAMETERS } from '@tramvai/types-actions-state-context';
|
|
7
|
-
export { ACTION_PARAMETERS } from '@tramvai/types-actions-state-context';
|
|
8
9
|
|
|
9
10
|
const MODULE_PARAMETERS = '_module_parameters_';
|
|
10
11
|
function Module({ providers, imports, deps = {}, }) {
|
|
@@ -25,29 +26,6 @@ function Module({ providers, imports, deps = {}, }) {
|
|
|
25
26
|
* @deprecated Используйте Module вместо module - `import { Module } from '@tramvai/core';` Иначе не будет работать hot reload
|
|
26
27
|
*/ const deprecatedModule = Module;
|
|
27
28
|
|
|
28
|
-
const BUNDLE_LIST_TOKEN = createToken('bundleList');
|
|
29
|
-
const ACTIONS_LIST_TOKEN = createToken('actionsList');
|
|
30
|
-
const MODULES_LIST_TOKEN = createToken('modulesList');
|
|
31
|
-
const APP_INFO_TOKEN = createToken('appInfo');
|
|
32
|
-
const COMMAND_LINE_RUNNER_TOKEN = createToken('commandLineRunner');
|
|
33
|
-
const COMMAND_LINES_TOKEN = createToken('commandLines');
|
|
34
|
-
const multiOptions = { multi: true };
|
|
35
|
-
const commandLineListTokens = {
|
|
36
|
-
// Блок: Создание
|
|
37
|
-
init: createToken('init', multiOptions),
|
|
38
|
-
listen: createToken('listen', multiOptions),
|
|
39
|
-
// Блок: Обработка клиентов
|
|
40
|
-
customerStart: createToken('customer_start', multiOptions),
|
|
41
|
-
resolveUserDeps: createToken('resolve_user_deps', multiOptions),
|
|
42
|
-
resolvePageDeps: createToken('resolve_page_deps', multiOptions),
|
|
43
|
-
generatePage: createToken('generate_page', multiOptions),
|
|
44
|
-
clear: createToken('clear', multiOptions),
|
|
45
|
-
// Блок: Переходы на клиенте
|
|
46
|
-
spaTransition: createToken('spa_transition', multiOptions),
|
|
47
|
-
// Блок: Закрытие сервера
|
|
48
|
-
close: createToken('close', multiOptions),
|
|
49
|
-
};
|
|
50
|
-
|
|
51
29
|
const isValidModule = (module) => {
|
|
52
30
|
// Если у нас undefined или null
|
|
53
31
|
if (Boolean(module) === false)
|
|
@@ -159,8 +137,26 @@ class App {
|
|
|
159
137
|
}
|
|
160
138
|
}
|
|
161
139
|
async initialization(env, type = 'init') {
|
|
162
|
-
const
|
|
140
|
+
const logger = this.di.get({ token: LOGGER_TOKEN, optional: true });
|
|
141
|
+
const log = logger === null || logger === void 0 ? void 0 : logger('tramvai-core');
|
|
142
|
+
const commandLineRunner = this.di.get({ token: COMMAND_LINE_RUNNER_TOKEN, optional: true });
|
|
143
|
+
if (!commandLineRunner) {
|
|
144
|
+
throw new Error('`COMMAND_LINE_RUNNER_TOKEN` is not defined, have you added `@tramvai/module-common` to your dependency list?');
|
|
145
|
+
}
|
|
146
|
+
log === null || log === void 0 ? void 0 : log.warn({
|
|
147
|
+
event: 'tramvai-app-init',
|
|
148
|
+
message: 'Initializing. Run CommandLineRunner.',
|
|
149
|
+
});
|
|
150
|
+
const di = await commandLineRunner.run(env, type);
|
|
151
|
+
log === null || log === void 0 ? void 0 : log.warn({
|
|
152
|
+
event: 'tramvai-app-init',
|
|
153
|
+
message: 'CommandLineRunner executed successfully. Resolving modules.',
|
|
154
|
+
});
|
|
163
155
|
this.resolveModules();
|
|
156
|
+
log === null || log === void 0 ? void 0 : log.warn({
|
|
157
|
+
event: 'tramvai-app-init',
|
|
158
|
+
message: 'Modules resolved successfully. Tramvai App initialized',
|
|
159
|
+
});
|
|
164
160
|
return di;
|
|
165
161
|
}
|
|
166
162
|
resolveModules() {
|
|
@@ -240,4 +236,4 @@ function createAction(action) {
|
|
|
240
236
|
return result;
|
|
241
237
|
}
|
|
242
238
|
|
|
243
|
-
export {
|
|
239
|
+
export { App, MODULE_PARAMETERS, Module, createAction, createApp, createBundle, getModuleParameters, isExtendedModule, deprecatedModule as module, walkOfModules };
|
package/lib/index.js
CHANGED
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var dippy = require('@tinkoff/dippy');
|
|
6
|
+
var tokensCore = require('@tramvai/tokens-core');
|
|
7
|
+
var tokensCommon = require('@tramvai/tokens-common');
|
|
6
8
|
var concat = require('@tinkoff/utils/array/concat');
|
|
7
9
|
var mergeWith = require('@tinkoff/utils/object/mergeWith');
|
|
8
10
|
var omit = require('@tinkoff/utils/object/omit');
|
|
9
|
-
var typesActionsStateContext = require('@tramvai/types-actions-state-context');
|
|
10
11
|
|
|
11
12
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
13
|
|
|
@@ -33,29 +34,6 @@ function Module({ providers, imports, deps = {}, }) {
|
|
|
33
34
|
* @deprecated Используйте Module вместо module - `import { Module } from '@tramvai/core';` Иначе не будет работать hot reload
|
|
34
35
|
*/ const deprecatedModule = Module;
|
|
35
36
|
|
|
36
|
-
const BUNDLE_LIST_TOKEN = dippy.createToken('bundleList');
|
|
37
|
-
const ACTIONS_LIST_TOKEN = dippy.createToken('actionsList');
|
|
38
|
-
const MODULES_LIST_TOKEN = dippy.createToken('modulesList');
|
|
39
|
-
const APP_INFO_TOKEN = dippy.createToken('appInfo');
|
|
40
|
-
const COMMAND_LINE_RUNNER_TOKEN = dippy.createToken('commandLineRunner');
|
|
41
|
-
const COMMAND_LINES_TOKEN = dippy.createToken('commandLines');
|
|
42
|
-
const multiOptions = { multi: true };
|
|
43
|
-
const commandLineListTokens = {
|
|
44
|
-
// Блок: Создание
|
|
45
|
-
init: dippy.createToken('init', multiOptions),
|
|
46
|
-
listen: dippy.createToken('listen', multiOptions),
|
|
47
|
-
// Блок: Обработка клиентов
|
|
48
|
-
customerStart: dippy.createToken('customer_start', multiOptions),
|
|
49
|
-
resolveUserDeps: dippy.createToken('resolve_user_deps', multiOptions),
|
|
50
|
-
resolvePageDeps: dippy.createToken('resolve_page_deps', multiOptions),
|
|
51
|
-
generatePage: dippy.createToken('generate_page', multiOptions),
|
|
52
|
-
clear: dippy.createToken('clear', multiOptions),
|
|
53
|
-
// Блок: Переходы на клиенте
|
|
54
|
-
spaTransition: dippy.createToken('spa_transition', multiOptions),
|
|
55
|
-
// Блок: Закрытие сервера
|
|
56
|
-
close: dippy.createToken('close', multiOptions),
|
|
57
|
-
};
|
|
58
|
-
|
|
59
37
|
const isValidModule = (module) => {
|
|
60
38
|
// Если у нас undefined или null
|
|
61
39
|
if (Boolean(module) === false)
|
|
@@ -126,7 +104,7 @@ function appProviders(name, bundles, actions, modules) {
|
|
|
126
104
|
return [
|
|
127
105
|
{
|
|
128
106
|
// Информация о приложении
|
|
129
|
-
provide: APP_INFO_TOKEN,
|
|
107
|
+
provide: tokensCore.APP_INFO_TOKEN,
|
|
130
108
|
scope: dippy.Scope.SINGLETON,
|
|
131
109
|
useValue: {
|
|
132
110
|
appName: name,
|
|
@@ -134,20 +112,20 @@ function appProviders(name, bundles, actions, modules) {
|
|
|
134
112
|
},
|
|
135
113
|
{
|
|
136
114
|
// Список бандлов
|
|
137
|
-
provide: BUNDLE_LIST_TOKEN,
|
|
115
|
+
provide: tokensCore.BUNDLE_LIST_TOKEN,
|
|
138
116
|
scope: dippy.Scope.SINGLETON,
|
|
139
117
|
useValue: bundles,
|
|
140
118
|
},
|
|
141
119
|
{
|
|
142
120
|
// Список переданных экшенов
|
|
143
|
-
provide: ACTIONS_LIST_TOKEN,
|
|
121
|
+
provide: tokensCore.ACTIONS_LIST_TOKEN,
|
|
144
122
|
scope: dippy.Scope.SINGLETON,
|
|
145
123
|
useValue: actions,
|
|
146
124
|
multi: true,
|
|
147
125
|
},
|
|
148
126
|
{
|
|
149
127
|
// Спислок переданных модулей
|
|
150
|
-
provide: MODULES_LIST_TOKEN,
|
|
128
|
+
provide: tokensCore.MODULES_LIST_TOKEN,
|
|
151
129
|
scope: dippy.Scope.SINGLETON,
|
|
152
130
|
useValue: modules,
|
|
153
131
|
},
|
|
@@ -167,8 +145,26 @@ class App {
|
|
|
167
145
|
}
|
|
168
146
|
}
|
|
169
147
|
async initialization(env, type = 'init') {
|
|
170
|
-
const
|
|
148
|
+
const logger = this.di.get({ token: tokensCommon.LOGGER_TOKEN, optional: true });
|
|
149
|
+
const log = logger === null || logger === void 0 ? void 0 : logger('tramvai-core');
|
|
150
|
+
const commandLineRunner = this.di.get({ token: tokensCore.COMMAND_LINE_RUNNER_TOKEN, optional: true });
|
|
151
|
+
if (!commandLineRunner) {
|
|
152
|
+
throw new Error('`COMMAND_LINE_RUNNER_TOKEN` is not defined, have you added `@tramvai/module-common` to your dependency list?');
|
|
153
|
+
}
|
|
154
|
+
log === null || log === void 0 ? void 0 : log.warn({
|
|
155
|
+
event: 'tramvai-app-init',
|
|
156
|
+
message: 'Initializing. Run CommandLineRunner.',
|
|
157
|
+
});
|
|
158
|
+
const di = await commandLineRunner.run(env, type);
|
|
159
|
+
log === null || log === void 0 ? void 0 : log.warn({
|
|
160
|
+
event: 'tramvai-app-init',
|
|
161
|
+
message: 'CommandLineRunner executed successfully. Resolving modules.',
|
|
162
|
+
});
|
|
171
163
|
this.resolveModules();
|
|
164
|
+
log === null || log === void 0 ? void 0 : log.warn({
|
|
165
|
+
event: 'tramvai-app-init',
|
|
166
|
+
message: 'Modules resolved successfully. Tramvai App initialized',
|
|
167
|
+
});
|
|
172
168
|
return di;
|
|
173
169
|
}
|
|
174
170
|
resolveModules() {
|
|
@@ -239,7 +235,7 @@ function createBundle(options) {
|
|
|
239
235
|
|
|
240
236
|
function createAction(action) {
|
|
241
237
|
const result = Object.assign(action.fn, {
|
|
242
|
-
[
|
|
238
|
+
[tokensCore.ACTION_PARAMETERS]: action,
|
|
243
239
|
});
|
|
244
240
|
if (!action.conditions) {
|
|
245
241
|
// eslint-disable-next-line no-param-reassign
|
|
@@ -268,20 +264,9 @@ Object.defineProperty(exports, 'provide', {
|
|
|
268
264
|
enumerable: true,
|
|
269
265
|
get: function () { return dippy.provide; }
|
|
270
266
|
});
|
|
271
|
-
Object.defineProperty(exports, 'ACTION_PARAMETERS', {
|
|
272
|
-
enumerable: true,
|
|
273
|
-
get: function () { return typesActionsStateContext.ACTION_PARAMETERS; }
|
|
274
|
-
});
|
|
275
|
-
exports.ACTIONS_LIST_TOKEN = ACTIONS_LIST_TOKEN;
|
|
276
|
-
exports.APP_INFO_TOKEN = APP_INFO_TOKEN;
|
|
277
267
|
exports.App = App;
|
|
278
|
-
exports.BUNDLE_LIST_TOKEN = BUNDLE_LIST_TOKEN;
|
|
279
|
-
exports.COMMAND_LINES_TOKEN = COMMAND_LINES_TOKEN;
|
|
280
|
-
exports.COMMAND_LINE_RUNNER_TOKEN = COMMAND_LINE_RUNNER_TOKEN;
|
|
281
|
-
exports.MODULES_LIST_TOKEN = MODULES_LIST_TOKEN;
|
|
282
268
|
exports.MODULE_PARAMETERS = MODULE_PARAMETERS;
|
|
283
269
|
exports.Module = Module;
|
|
284
|
-
exports.commandLineListTokens = commandLineListTokens;
|
|
285
270
|
exports.createAction = createAction;
|
|
286
271
|
exports.createApp = createApp;
|
|
287
272
|
exports.createBundle = createBundle;
|
|
@@ -289,3 +274,9 @@ exports.getModuleParameters = getModuleParameters;
|
|
|
289
274
|
exports.isExtendedModule = isExtendedModule;
|
|
290
275
|
exports.module = deprecatedModule;
|
|
291
276
|
exports.walkOfModules = walkOfModules;
|
|
277
|
+
Object.keys(tokensCore).forEach(function (k) {
|
|
278
|
+
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
|
|
279
|
+
enumerable: true,
|
|
280
|
+
get: function () { return tokensCore[k]; }
|
|
281
|
+
});
|
|
282
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/core",
|
|
3
|
-
"version": "1.55.
|
|
3
|
+
"version": "1.55.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -20,8 +20,10 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@tinkoff/utils": "^2.1.2",
|
|
23
|
-
"@tramvai/
|
|
24
|
-
"@
|
|
23
|
+
"@tramvai/tokens-common": "1.55.5",
|
|
24
|
+
"@tramvai/tokens-core": "1.55.5",
|
|
25
|
+
"@tramvai/types-actions-state-context": "1.55.5",
|
|
26
|
+
"@tinkoff/dippy": "0.7.38",
|
|
25
27
|
"tslib": "^2.0.3"
|
|
26
28
|
},
|
|
27
29
|
"peerDependencies": {
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { Action } from '../types/action';
|
|
2
|
-
export interface BundleOptions {
|
|
3
|
-
presets?: BundlePreset[];
|
|
4
|
-
name: string;
|
|
5
|
-
components: {
|
|
6
|
-
[key: string]: any;
|
|
7
|
-
};
|
|
8
|
-
reducers?: any[];
|
|
9
|
-
actions?: Action[];
|
|
10
|
-
}
|
|
11
|
-
export declare type BundlePreset = Partial<BundleOptions>;
|
|
12
|
-
export interface Bundle {
|
|
13
|
-
name: string;
|
|
14
|
-
components: BundleOptions['components'];
|
|
15
|
-
actions?: BundleOptions['actions'];
|
|
16
|
-
reducers?: BundleOptions['reducers'];
|
|
17
|
-
}
|
|
18
|
-
export declare type BundleImport = () => Promise<{
|
|
19
|
-
default: Bundle;
|
|
20
|
-
}>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare type Command = () => any;
|
package/lib/tokens.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { Container, Provider } from '@tinkoff/dippy';
|
|
2
|
-
import type { Command } from './command/command.h';
|
|
3
|
-
import type { Action } from './types/action';
|
|
4
|
-
export { DI_TOKEN, IS_DI_CHILD_CONTAINER_TOKEN } from '@tinkoff/dippy';
|
|
5
|
-
export declare const BUNDLE_LIST_TOKEN: any;
|
|
6
|
-
export declare const ACTIONS_LIST_TOKEN: Action<any, any, any>[];
|
|
7
|
-
export declare const MODULES_LIST_TOKEN: any;
|
|
8
|
-
export declare const APP_INFO_TOKEN: {
|
|
9
|
-
[key: string]: string;
|
|
10
|
-
appName: string;
|
|
11
|
-
};
|
|
12
|
-
export interface CommandLine {
|
|
13
|
-
lines: CommandLines;
|
|
14
|
-
run(type: keyof CommandLines, status: keyof CommandLineDescription, providers?: Provider[], customDi?: Container): Promise<Container>;
|
|
15
|
-
}
|
|
16
|
-
export declare type CommandLineDescription = Record<string, Command[]>;
|
|
17
|
-
export declare type CommandLines = {
|
|
18
|
-
server: CommandLineDescription;
|
|
19
|
-
client: CommandLineDescription;
|
|
20
|
-
};
|
|
21
|
-
export declare const COMMAND_LINE_RUNNER_TOKEN: CommandLine;
|
|
22
|
-
export declare const COMMAND_LINES_TOKEN: CommandLines;
|
|
23
|
-
export declare const commandLineListTokens: {
|
|
24
|
-
init: Command;
|
|
25
|
-
listen: Command;
|
|
26
|
-
customerStart: Command;
|
|
27
|
-
resolveUserDeps: Command;
|
|
28
|
-
resolvePageDeps: Command;
|
|
29
|
-
generatePage: Command;
|
|
30
|
-
clear: Command;
|
|
31
|
-
spaTransition: Command;
|
|
32
|
-
close: Command;
|
|
33
|
-
};
|
package/lib/types/action.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { ActionConditionsParameters, ActionParameters, Action, ActionContext, ACTION_PARAMETERS, } from '@tramvai/types-actions-state-context';
|