@midwayjs/core 3.3.0 → 3.3.4

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.
@@ -272,7 +272,7 @@ class BaseFramework {
272
272
  return this.informationService.getProjectName();
273
273
  }
274
274
  getFrameworkName() {
275
- return '';
275
+ return this.constructor.name;
276
276
  }
277
277
  useMiddleware(middleware) {
278
278
  this.middlewareManager.insertLast(middleware);
@@ -29,7 +29,7 @@ let MidwayFrameworkService = class MidwayFrameworkService {
29
29
  this.globalFrameworkList = [];
30
30
  }
31
31
  async init() {
32
- var _a;
32
+ var _a, _b;
33
33
  // register base config hook
34
34
  this.decoratorService.registerPropertyHandler(decorator_1.CONFIG_KEY, (propertyName, meta) => {
35
35
  var _a;
@@ -49,12 +49,32 @@ let MidwayFrameworkService = class MidwayFrameworkService {
49
49
  var _a, _b;
50
50
  return new pipelineService_1.MidwayPipelineService((_b = (_a = instance[interface_1.REQUEST_OBJ_CTX_KEY]) === null || _a === void 0 ? void 0 : _a.requestContext) !== null && _b !== void 0 ? _b : this.applicationContext, meta.valves);
51
51
  });
52
+ // register @App decorator handler
53
+ this.decoratorService.registerPropertyHandler(decorator_1.APPLICATION_KEY, (propertyName, mete) => {
54
+ if (mete.type) {
55
+ const framework = this.applicationManager.getApplication(mete.type);
56
+ if (!framework) {
57
+ throw new error_1.MidwayCommonError(`Framework ${mete.type} not Found`);
58
+ }
59
+ return framework;
60
+ }
61
+ else {
62
+ return this.getMainApp();
63
+ }
64
+ });
65
+ this.decoratorService.registerPropertyHandler(decorator_1.PLUGIN_KEY, (key, target) => {
66
+ return this.getMainApp()[key];
67
+ });
52
68
  let frameworks = (0, decorator_1.listModule)(decorator_1.FRAMEWORK_KEY);
53
69
  // filter proto
54
70
  frameworks = filterProtoFramework(frameworks);
55
71
  debug(`[core]: Found Framework length = ${frameworks.length}`);
56
72
  if (frameworks.length) {
57
73
  for (const frameworkClz of frameworks) {
74
+ if (!this.applicationContext.hasDefinition((0, decorator_1.getProviderUUId)(frameworkClz))) {
75
+ debug(`[core]: Found Framework "${frameworkClz.name}" but missing definition, skip initialize.`);
76
+ continue;
77
+ }
58
78
  const frameworkInstance = await this.applicationContext.getAsync(frameworkClz, [this.applicationContext]);
59
79
  // if enable, just init framework
60
80
  if (frameworkInstance.isEnable()) {
@@ -73,24 +93,13 @@ let MidwayFrameworkService = class MidwayFrameworkService {
73
93
  this.applicationManager.addFramework((_a = definition === null || definition === void 0 ? void 0 : definition.namespace) !== null && _a !== void 0 ? _a : frameworkInstance.getFrameworkName(), frameworkInstance);
74
94
  this.globalFrameworkList.push(frameworkInstance);
75
95
  }
76
- // register @App decorator handler
77
- this.decoratorService.registerPropertyHandler(decorator_1.APPLICATION_KEY, (propertyName, mete) => {
78
- if (mete.type) {
79
- const framework = this.applicationManager.getApplication(mete.type);
80
- if (!framework) {
81
- throw new error_1.MidwayCommonError(`Framework ${mete.type} not Found`);
82
- }
83
- return framework;
84
- }
85
- else {
86
- return this.getMainApp();
87
- }
88
- });
89
- this.decoratorService.registerPropertyHandler(decorator_1.PLUGIN_KEY, (key, target) => {
90
- return this.getMainApp()[key];
91
- });
96
+ const nsSet = this.applicationContext['namespaceSet'];
97
+ let mainNs;
98
+ if (nsSet.size > 0) {
99
+ [mainNs] = nsSet;
100
+ }
92
101
  global['MIDWAY_MAIN_FRAMEWORK'] = this.mainFramework =
93
- this.globalFrameworkList[0];
102
+ (_b = this.applicationManager.getFramework(mainNs)) !== null && _b !== void 0 ? _b : this.globalFrameworkList[0];
94
103
  }
95
104
  // init aspect module
96
105
  await this.aspectService.loadAspect();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/core",
3
- "version": "3.3.0",
3
+ "version": "3.3.4",
4
4
  "description": "midway core",
5
5
  "main": "dist/index",
6
6
  "typings": "dist/index.d.ts",
@@ -21,12 +21,12 @@
21
21
  ],
22
22
  "license": "MIT",
23
23
  "devDependencies": {
24
- "@midwayjs/decorator": "^3.1.6",
24
+ "@midwayjs/decorator": "^3.3.4",
25
25
  "koa": "2.13.4",
26
26
  "midway-test-component": "*",
27
27
  "mm": "3.2.0",
28
28
  "raw-body": "2.5.1",
29
- "sinon": "13.0.1"
29
+ "sinon": "13.0.2"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "@midwayjs/decorator": "*"
@@ -45,5 +45,5 @@
45
45
  "engines": {
46
46
  "node": ">=12"
47
47
  },
48
- "gitHead": "b12b41188879296f9863265baa5bbdb4158bddc5"
48
+ "gitHead": "0c2785a87217f57a184a661c71b1d9562af02242"
49
49
  }