@midwayjs/core 3.11.0 → 3.11.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.
|
@@ -7,6 +7,7 @@ const constant_1 = require("./constant");
|
|
|
7
7
|
const types_1 = require("../util/types");
|
|
8
8
|
const camelCase_1 = require("../util/camelCase");
|
|
9
9
|
const util_1 = require("../util");
|
|
10
|
+
const pathFileUtil_1 = require("../util/pathFileUtil");
|
|
10
11
|
const debug = require('util').debuglog('midway:core');
|
|
11
12
|
exports.PRELOAD_MODULE_KEY = 'INJECTION_PRELOAD_MODULE_KEY';
|
|
12
13
|
exports.INJECT_CLASS_KEY_PREFIX = 'INJECTION_CLASS_META_DATA';
|
|
@@ -249,6 +250,13 @@ let manager = new DecoratorManager();
|
|
|
249
250
|
if (typeof global === 'object') {
|
|
250
251
|
if (global['MIDWAY_GLOBAL_DECORATOR_MANAGER']) {
|
|
251
252
|
console.warn('DecoratorManager not singleton and please check @midwayjs/core version by "npm ls @midwayjs/core"');
|
|
253
|
+
const coreModulePathList = (0, pathFileUtil_1.getModuleRequirePathList)('@midwayjs/core');
|
|
254
|
+
if (coreModulePathList.length) {
|
|
255
|
+
console.info('The module may be located in:');
|
|
256
|
+
coreModulePathList.forEach((path, index) => {
|
|
257
|
+
console.info(`${index + 1}. ${path}`);
|
|
258
|
+
});
|
|
259
|
+
}
|
|
252
260
|
manager = global['MIDWAY_GLOBAL_DECORATOR_MANAGER'];
|
|
253
261
|
}
|
|
254
262
|
else {
|
package/dist/interface.d.ts
CHANGED
|
@@ -78,6 +78,7 @@ let MidwayAspectService = class MidwayAspectService {
|
|
|
78
78
|
target: this,
|
|
79
79
|
args: args,
|
|
80
80
|
proceed: newProceed,
|
|
81
|
+
proceedIsAsyncFunction: true,
|
|
81
82
|
};
|
|
82
83
|
if (typeof aspectObject === 'function') {
|
|
83
84
|
aspectObject = aspectObject();
|
|
@@ -122,6 +123,7 @@ let MidwayAspectService = class MidwayAspectService {
|
|
|
122
123
|
target: this,
|
|
123
124
|
args: args,
|
|
124
125
|
proceed: newProceed,
|
|
126
|
+
proceedIsAsyncFunction: false,
|
|
125
127
|
};
|
|
126
128
|
if (typeof aspectObject === 'function') {
|
|
127
129
|
aspectObject = aspectObject();
|
|
@@ -15,6 +15,8 @@ const interface_1 = require("../interface");
|
|
|
15
15
|
const error_1 = require("../error");
|
|
16
16
|
const util_1 = require("../util");
|
|
17
17
|
const types_1 = require("../util/types");
|
|
18
|
+
const util_2 = require("util");
|
|
19
|
+
const debug = (0, util_2.debuglog)('midway:debug');
|
|
18
20
|
let MidwayMiddlewareService = class MidwayMiddlewareService {
|
|
19
21
|
constructor(applicationContext) {
|
|
20
22
|
this.applicationContext = applicationContext;
|
|
@@ -89,6 +91,9 @@ let MidwayMiddlewareService = class MidwayMiddlewareService {
|
|
|
89
91
|
fn = next;
|
|
90
92
|
if (!fn)
|
|
91
93
|
return Promise.resolve();
|
|
94
|
+
const middlewareName = `${name ? `${name}.` : ''}${index} ${fn._name || fn.name || 'anonymous'}`;
|
|
95
|
+
const startTime = Date.now();
|
|
96
|
+
debug(`[middleware]: in ${middlewareName} +0`);
|
|
92
97
|
try {
|
|
93
98
|
if (supportBody) {
|
|
94
99
|
return Promise.resolve(fn(context, dispatch.bind(null, i + 1), {
|
|
@@ -105,16 +110,21 @@ let MidwayMiddlewareService = class MidwayMiddlewareService {
|
|
|
105
110
|
else if (context['body'] !== undefined) {
|
|
106
111
|
result = context['body'];
|
|
107
112
|
}
|
|
113
|
+
debug(`[middleware]: out ${middlewareName} +${Date.now() - startTime} with body`);
|
|
108
114
|
return result;
|
|
109
115
|
});
|
|
110
116
|
}
|
|
111
117
|
else {
|
|
112
118
|
return Promise.resolve(fn(context, dispatch.bind(null, i + 1), {
|
|
113
119
|
index,
|
|
114
|
-
}))
|
|
120
|
+
})).then(result => {
|
|
121
|
+
debug(`[middleware]: out ${middlewareName} +${Date.now() - startTime}`);
|
|
122
|
+
return result;
|
|
123
|
+
});
|
|
115
124
|
}
|
|
116
125
|
}
|
|
117
126
|
catch (err) {
|
|
127
|
+
debug(`[middleware]: out ${middlewareName} +${Date.now() - startTime} with err ${err.message}`);
|
|
118
128
|
return Promise.reject(err);
|
|
119
129
|
}
|
|
120
130
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PathFileUtil = exports.getFileContentSync = exports.isPathEqual = exports.isPath = void 0;
|
|
3
|
+
exports.getModuleRequirePathList = exports.PathFileUtil = exports.getFileContentSync = exports.isPathEqual = exports.isPath = void 0;
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
const fs_1 = require("fs");
|
|
6
6
|
function isPath(p) {
|
|
@@ -32,4 +32,31 @@ exports.PathFileUtil = {
|
|
|
32
32
|
isPathEqual,
|
|
33
33
|
getFileContentSync,
|
|
34
34
|
};
|
|
35
|
+
function getModuleRequirePathList(moduleName) {
|
|
36
|
+
const moduleNameList = [moduleName, moduleName.replace(/\//g, '_')];
|
|
37
|
+
let moduleNameMap = {};
|
|
38
|
+
const modulePathList = [];
|
|
39
|
+
Object.keys(require.cache || {}).forEach(moduleName => {
|
|
40
|
+
let moduleIndex = -1;
|
|
41
|
+
for (const moduleName of moduleNameList) {
|
|
42
|
+
const index = moduleName.indexOf(moduleName);
|
|
43
|
+
if (index !== -1) {
|
|
44
|
+
moduleIndex = index;
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (moduleIndex === -1) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const modulePath = moduleName.slice(0, moduleIndex);
|
|
52
|
+
if (moduleNameMap[modulePath]) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
moduleNameMap[modulePath] = true;
|
|
56
|
+
modulePathList.push(modulePath);
|
|
57
|
+
});
|
|
58
|
+
moduleNameMap = undefined;
|
|
59
|
+
return modulePathList;
|
|
60
|
+
}
|
|
61
|
+
exports.getModuleRequirePathList = getModuleRequirePathList;
|
|
35
62
|
//# sourceMappingURL=pathFileUtil.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/core",
|
|
3
|
-
"version": "3.11.
|
|
3
|
+
"version": "3.11.1",
|
|
4
4
|
"description": "midway core",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"engines": {
|
|
43
43
|
"node": ">=12"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "bd9375874eb8cfaa49fbcfaa0497021cea06a394"
|
|
46
46
|
}
|