@midwayjs/web 3.5.1 → 3.6.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.
- package/dist/configuration.d.ts +1 -1
- package/dist/configuration.js +7 -8
- package/dist/framework/lifecycle.js +10 -12
- package/dist/framework/web.d.ts +1 -2
- package/dist/framework/web.js +3 -4
- package/dist/utils.js +7 -7
- package/package.json +4 -5
package/dist/configuration.d.ts
CHANGED
package/dist/configuration.js
CHANGED
|
@@ -10,12 +10,11 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.EggConfiguration = void 0;
|
|
13
|
-
const decorator_1 = require("@midwayjs/decorator");
|
|
14
13
|
const core_1 = require("@midwayjs/core");
|
|
15
14
|
const path_1 = require("path");
|
|
16
15
|
let EggConfiguration = class EggConfiguration {
|
|
17
16
|
init() {
|
|
18
|
-
this.decoratorService.registerParameterHandler(
|
|
17
|
+
this.decoratorService.registerParameterHandler(core_1.WEB_ROUTER_PARAM_KEY, options => {
|
|
19
18
|
return (0, core_1.extractKoaLikeValue)(options.metadata.type, options.metadata.propertyData, options.originParamType)(options.originArgs[0], options.originArgs[1]);
|
|
20
19
|
});
|
|
21
20
|
}
|
|
@@ -38,29 +37,29 @@ let EggConfiguration = class EggConfiguration {
|
|
|
38
37
|
}
|
|
39
38
|
};
|
|
40
39
|
__decorate([
|
|
41
|
-
(0,
|
|
40
|
+
(0, core_1.Inject)(),
|
|
42
41
|
__metadata("design:type", Object)
|
|
43
42
|
], EggConfiguration.prototype, "baseDir", void 0);
|
|
44
43
|
__decorate([
|
|
45
|
-
(0,
|
|
44
|
+
(0, core_1.Inject)(),
|
|
46
45
|
__metadata("design:type", Object)
|
|
47
46
|
], EggConfiguration.prototype, "appDir", void 0);
|
|
48
47
|
__decorate([
|
|
49
|
-
(0,
|
|
48
|
+
(0, core_1.App)(),
|
|
50
49
|
__metadata("design:type", Object)
|
|
51
50
|
], EggConfiguration.prototype, "app", void 0);
|
|
52
51
|
__decorate([
|
|
53
|
-
(0,
|
|
52
|
+
(0, core_1.Inject)(),
|
|
54
53
|
__metadata("design:type", core_1.MidwayDecoratorService)
|
|
55
54
|
], EggConfiguration.prototype, "decoratorService", void 0);
|
|
56
55
|
__decorate([
|
|
57
|
-
(0,
|
|
56
|
+
(0, core_1.Init)(),
|
|
58
57
|
__metadata("design:type", Function),
|
|
59
58
|
__metadata("design:paramtypes", []),
|
|
60
59
|
__metadata("design:returntype", void 0)
|
|
61
60
|
], EggConfiguration.prototype, "init", null);
|
|
62
61
|
EggConfiguration = __decorate([
|
|
63
|
-
(0,
|
|
62
|
+
(0, core_1.Configuration)({
|
|
64
63
|
namespace: 'egg',
|
|
65
64
|
importConfigs: [(0, path_1.join)(__dirname, 'config')],
|
|
66
65
|
})
|
|
@@ -11,8 +11,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.MidwayWebLifeCycleService = void 0;
|
|
13
13
|
const core_1 = require("@midwayjs/core");
|
|
14
|
-
const decorator_1 = require("@midwayjs/decorator");
|
|
15
|
-
const configuration_1 = require("@midwayjs/core/dist/functional/configuration");
|
|
16
14
|
const util_1 = require("util");
|
|
17
15
|
const debug = (0, util_1.debuglog)('midway:debug');
|
|
18
16
|
let MidwayWebLifeCycleService = class MidwayWebLifeCycleService {
|
|
@@ -22,10 +20,10 @@ let MidwayWebLifeCycleService = class MidwayWebLifeCycleService {
|
|
|
22
20
|
}
|
|
23
21
|
async init() {
|
|
24
22
|
// run lifecycle
|
|
25
|
-
const cycles = (0,
|
|
23
|
+
const cycles = (0, core_1.listModule)(core_1.CONFIGURATION_KEY);
|
|
26
24
|
debug(`[core]: Found Configuration length = ${cycles.length}`);
|
|
27
25
|
for (const cycle of cycles) {
|
|
28
|
-
if (cycle.target instanceof
|
|
26
|
+
if (cycle.target instanceof core_1.FunctionalConfiguration) {
|
|
29
27
|
// 函数式写法
|
|
30
28
|
cycle.instance = cycle.target;
|
|
31
29
|
}
|
|
@@ -69,7 +67,7 @@ let MidwayWebLifeCycleService = class MidwayWebLifeCycleService {
|
|
|
69
67
|
this.configService.clearConfigMergeOrder();
|
|
70
68
|
}
|
|
71
69
|
// some preload module init
|
|
72
|
-
const modules = (0,
|
|
70
|
+
const modules = (0, core_1.listPreloadModule)();
|
|
73
71
|
for (const module of modules) {
|
|
74
72
|
// preload init context
|
|
75
73
|
await this.applicationContext.getAsync(module);
|
|
@@ -77,10 +75,10 @@ let MidwayWebLifeCycleService = class MidwayWebLifeCycleService {
|
|
|
77
75
|
}
|
|
78
76
|
async stop() {
|
|
79
77
|
// stop lifecycle
|
|
80
|
-
const cycles = (0,
|
|
78
|
+
const cycles = (0, core_1.listModule)(core_1.CONFIGURATION_KEY);
|
|
81
79
|
for (const cycle of cycles) {
|
|
82
80
|
let inst;
|
|
83
|
-
if (cycle.target instanceof
|
|
81
|
+
if (cycle.target instanceof core_1.FunctionalConfiguration) {
|
|
84
82
|
// 函数式写法
|
|
85
83
|
inst = cycle.target;
|
|
86
84
|
}
|
|
@@ -124,22 +122,22 @@ let MidwayWebLifeCycleService = class MidwayWebLifeCycleService {
|
|
|
124
122
|
}
|
|
125
123
|
};
|
|
126
124
|
__decorate([
|
|
127
|
-
(0,
|
|
125
|
+
(0, core_1.Inject)(),
|
|
128
126
|
__metadata("design:type", core_1.MidwayFrameworkService)
|
|
129
127
|
], MidwayWebLifeCycleService.prototype, "frameworkService", void 0);
|
|
130
128
|
__decorate([
|
|
131
|
-
(0,
|
|
129
|
+
(0, core_1.Inject)(),
|
|
132
130
|
__metadata("design:type", core_1.MidwayConfigService)
|
|
133
131
|
], MidwayWebLifeCycleService.prototype, "configService", void 0);
|
|
134
132
|
__decorate([
|
|
135
|
-
(0,
|
|
133
|
+
(0, core_1.Init)(),
|
|
136
134
|
__metadata("design:type", Function),
|
|
137
135
|
__metadata("design:paramtypes", []),
|
|
138
136
|
__metadata("design:returntype", Promise)
|
|
139
137
|
], MidwayWebLifeCycleService.prototype, "init", null);
|
|
140
138
|
MidwayWebLifeCycleService = __decorate([
|
|
141
|
-
(0,
|
|
142
|
-
(0,
|
|
139
|
+
(0, core_1.Provide)(),
|
|
140
|
+
(0, core_1.Scope)(core_1.ScopeEnum.Singleton),
|
|
143
141
|
__metadata("design:paramtypes", [Object])
|
|
144
142
|
], MidwayWebLifeCycleService);
|
|
145
143
|
exports.MidwayWebLifeCycleService = MidwayWebLifeCycleService;
|
package/dist/framework/web.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { BaseFramework, IMidwayBootstrapOptions } from '@midwayjs/core';
|
|
2
|
-
import { MidwayFrameworkType } from '@midwayjs/decorator';
|
|
1
|
+
import { BaseFramework, IMidwayBootstrapOptions, MidwayFrameworkType } from '@midwayjs/core';
|
|
3
2
|
import { IMidwayWebConfigurationOptions, Application, Context } from '../interface';
|
|
4
3
|
import { EggLogger } from 'egg';
|
|
5
4
|
export declare class MidwayWebFramework extends BaseFramework<Application, Context, IMidwayWebConfigurationOptions> {
|
package/dist/framework/web.js
CHANGED
|
@@ -11,7 +11,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.MidwayWebFramework = void 0;
|
|
13
13
|
const core_1 = require("@midwayjs/core");
|
|
14
|
-
const decorator_1 = require("@midwayjs/decorator");
|
|
15
14
|
const router_1 = require("@eggjs/router");
|
|
16
15
|
const logger_1 = require("@midwayjs/logger");
|
|
17
16
|
const path_1 = require("path");
|
|
@@ -165,7 +164,7 @@ let MidwayWebFramework = class MidwayWebFramework extends core_1.BaseFramework {
|
|
|
165
164
|
debug(`[egg]: current middleware = ${this.middlewareManager.getNames()}`);
|
|
166
165
|
}
|
|
167
166
|
getFrameworkType() {
|
|
168
|
-
return
|
|
167
|
+
return core_1.MidwayFrameworkType.WEB;
|
|
169
168
|
}
|
|
170
169
|
async run() {
|
|
171
170
|
var _a;
|
|
@@ -254,11 +253,11 @@ let MidwayWebFramework = class MidwayWebFramework extends core_1.BaseFramework {
|
|
|
254
253
|
}
|
|
255
254
|
};
|
|
256
255
|
__decorate([
|
|
257
|
-
(0,
|
|
256
|
+
(0, core_1.Inject)(),
|
|
258
257
|
__metadata("design:type", Object)
|
|
259
258
|
], MidwayWebFramework.prototype, "appDir", void 0);
|
|
260
259
|
MidwayWebFramework = __decorate([
|
|
261
|
-
(0,
|
|
260
|
+
(0, core_1.Framework)()
|
|
262
261
|
], MidwayWebFramework);
|
|
263
262
|
exports.MidwayWebFramework = MidwayWebFramework;
|
|
264
263
|
//# sourceMappingURL=web.js.map
|
package/dist/utils.js
CHANGED
|
@@ -5,7 +5,7 @@ const path_1 = require("path");
|
|
|
5
5
|
const find_up_1 = require("find-up");
|
|
6
6
|
const fs_1 = require("fs");
|
|
7
7
|
const core_1 = require("@midwayjs/core");
|
|
8
|
-
const
|
|
8
|
+
const core_2 = require("@midwayjs/core");
|
|
9
9
|
const web_1 = require("./framework/web");
|
|
10
10
|
const util_1 = require("util");
|
|
11
11
|
const debug = (0, util_1.debuglog)('midway:debug');
|
|
@@ -86,9 +86,9 @@ async function initializeAgentApplicationContext(agent) {
|
|
|
86
86
|
const loggerService = (0, core_1.getCurrentApplicationContext)().get(core_1.MidwayLoggerService);
|
|
87
87
|
// framework/config/plugin/logger/app decorator support
|
|
88
88
|
// register base config hook
|
|
89
|
-
decoratorService.registerPropertyHandler(
|
|
89
|
+
decoratorService.registerPropertyHandler(core_2.CONFIG_KEY, (propertyName, meta) => {
|
|
90
90
|
var _a;
|
|
91
|
-
if (meta.identifier ===
|
|
91
|
+
if (meta.identifier === core_2.ALL) {
|
|
92
92
|
return configService.getConfiguration();
|
|
93
93
|
}
|
|
94
94
|
else {
|
|
@@ -96,19 +96,19 @@ async function initializeAgentApplicationContext(agent) {
|
|
|
96
96
|
}
|
|
97
97
|
});
|
|
98
98
|
// register @Logger decorator handler
|
|
99
|
-
decoratorService.registerPropertyHandler(
|
|
99
|
+
decoratorService.registerPropertyHandler(core_2.LOGGER_KEY, (propertyName, meta) => {
|
|
100
100
|
var _a;
|
|
101
101
|
return loggerService.getLogger((_a = meta.identifier) !== null && _a !== void 0 ? _a : propertyName);
|
|
102
102
|
});
|
|
103
|
-
decoratorService.registerPropertyHandler(
|
|
103
|
+
decoratorService.registerPropertyHandler(core_2.PIPELINE_IDENTIFIER, (key, meta, instance) => {
|
|
104
104
|
var _a, _b;
|
|
105
105
|
return new core_1.MidwayPipelineService((_b = (_a = instance[core_1.REQUEST_OBJ_CTX_KEY]) === null || _a === void 0 ? void 0 : _a.requestContext) !== null && _b !== void 0 ? _b : this.applicationContext, meta.valves);
|
|
106
106
|
});
|
|
107
107
|
// register @App decorator handler
|
|
108
|
-
decoratorService.registerPropertyHandler(
|
|
108
|
+
decoratorService.registerPropertyHandler(core_2.APPLICATION_KEY, (propertyName, mete) => {
|
|
109
109
|
return agent;
|
|
110
110
|
});
|
|
111
|
-
decoratorService.registerPropertyHandler(
|
|
111
|
+
decoratorService.registerPropertyHandler(core_2.PLUGIN_KEY, (key, target) => {
|
|
112
112
|
return agent[key];
|
|
113
113
|
});
|
|
114
114
|
// init aspect module
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/web",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0",
|
|
4
4
|
"description": "Midway Web Framework for Egg.js",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"typings": "index.d.ts",
|
|
@@ -28,9 +28,8 @@
|
|
|
28
28
|
],
|
|
29
29
|
"license": "MIT",
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@midwayjs/decorator": "^3.4.11",
|
|
32
31
|
"@midwayjs/logger": "^2.15.0",
|
|
33
|
-
"@midwayjs/mock": "^3.
|
|
32
|
+
"@midwayjs/mock": "^3.6.0",
|
|
34
33
|
"axios": "0.27.2",
|
|
35
34
|
"dayjs": "1.11.5",
|
|
36
35
|
"egg-logger": "2.9.0",
|
|
@@ -47,7 +46,7 @@
|
|
|
47
46
|
},
|
|
48
47
|
"dependencies": {
|
|
49
48
|
"@eggjs/router": "^2.0.0",
|
|
50
|
-
"@midwayjs/core": "^3.
|
|
49
|
+
"@midwayjs/core": "^3.6.0",
|
|
51
50
|
"egg": "^2.28.0",
|
|
52
51
|
"egg-cluster": "^1.27.1",
|
|
53
52
|
"find-up": "5.0.0",
|
|
@@ -61,5 +60,5 @@
|
|
|
61
60
|
"engines": {
|
|
62
61
|
"node": ">=12"
|
|
63
62
|
},
|
|
64
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "22643b0e8519766bb7c68b975930199fc136336e"
|
|
65
64
|
}
|