@midwayjs/core 4.0.0-beta.7 → 4.0.0-beta.8

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.
Files changed (105) hide show
  1. package/dist/baseFramework.d.ts +6 -6
  2. package/dist/baseFramework.js +19 -6
  3. package/dist/common/applicationManager.js +1 -3
  4. package/dist/common/asyncContextManager.js +23 -0
  5. package/dist/common/dataListener.js +2 -3
  6. package/dist/common/dataSourceManager.js +10 -8
  7. package/dist/common/fileDetector.js +2 -4
  8. package/dist/common/filterManager.js +6 -8
  9. package/dist/common/loggerFactory.js +1 -3
  10. package/dist/common/middlewareManager.js +2 -2
  11. package/dist/common/performanceManager.d.ts +0 -1
  12. package/dist/common/performanceManager.js +21 -20
  13. package/dist/common/priorityManager.js +2 -4
  14. package/dist/common/serviceDiscovery/healthCheck.js +10 -2
  15. package/dist/common/serviceDiscovery/loadBalancer.js +1 -3
  16. package/dist/common/serviceDiscovery/serviceDiscovery.js +6 -3
  17. package/dist/common/serviceFactory.js +6 -6
  18. package/dist/common/typedResourceManager.js +3 -2
  19. package/dist/common/webGenerator.js +2 -0
  20. package/dist/config/config.default.js +4 -4
  21. package/dist/context/componentLoader.js +3 -2
  22. package/dist/context/container.d.ts +0 -1
  23. package/dist/context/container.js +9 -8
  24. package/dist/context/definitionRegistry.js +3 -6
  25. package/dist/context/dynamicContainer.js +3 -2
  26. package/dist/context/managedResolverFactory.js +2 -1
  27. package/dist/context/providerWrapper.js +1 -2
  28. package/dist/context/requestContainer.js +5 -2
  29. package/dist/decorator/common/aspect.js +1 -2
  30. package/dist/decorator/common/autoload.js +1 -2
  31. package/dist/decorator/common/configuration.js +1 -2
  32. package/dist/decorator/common/filter.js +2 -3
  33. package/dist/decorator/common/framework.js +8 -9
  34. package/dist/decorator/common/guard.js +2 -3
  35. package/dist/decorator/common/inject.js +4 -5
  36. package/dist/decorator/common/middleware.js +1 -2
  37. package/dist/decorator/common/mock.js +1 -2
  38. package/dist/decorator/common/objectDef.js +2 -3
  39. package/dist/decorator/common/pipe.js +1 -2
  40. package/dist/decorator/common/provide.js +1 -2
  41. package/dist/decorator/common/scope.js +2 -3
  42. package/dist/decorator/decoratorManager.js +1 -1
  43. package/dist/decorator/faas/serverlessTrigger.js +2 -3
  44. package/dist/decorator/metadataManager.js +11 -11
  45. package/dist/decorator/microservice/consumer.js +1 -2
  46. package/dist/decorator/microservice/kafkaListener.js +1 -2
  47. package/dist/decorator/microservice/provider.js +4 -4
  48. package/dist/decorator/microservice/rabbitmqListener.js +1 -2
  49. package/dist/decorator/task/queue.js +1 -2
  50. package/dist/decorator/task/schedule.js +1 -2
  51. package/dist/decorator/task/task.js +1 -2
  52. package/dist/decorator/task/taskLocal.js +1 -2
  53. package/dist/decorator/web/controller.js +1 -2
  54. package/dist/decorator/web/response.js +5 -6
  55. package/dist/decorator/ws/webSocketController.js +1 -2
  56. package/dist/decorator/ws/webSocketEvent.js +6 -6
  57. package/dist/definitions/functionDefinition.js +21 -12
  58. package/dist/definitions/objectCreator.js +2 -1
  59. package/dist/definitions/objectDefinition.js +19 -17
  60. package/dist/error/base.js +5 -2
  61. package/dist/functional/configuration.js +1 -0
  62. package/dist/functional/hooks.js +10 -11
  63. package/dist/interface.d.ts +0 -2
  64. package/dist/legacy/decorator.js +31 -32
  65. package/dist/response/base.d.ts +3 -5
  66. package/dist/response/base.js +22 -21
  67. package/dist/response/http.d.ts +4 -7
  68. package/dist/response/http.js +12 -12
  69. package/dist/response/sse.d.ts +0 -1
  70. package/dist/response/sse.js +4 -1
  71. package/dist/response/stream.d.ts +0 -1
  72. package/dist/response/stream.js +3 -1
  73. package/dist/service/aspectService.js +1 -0
  74. package/dist/service/configService.js +13 -12
  75. package/dist/service/decoratorService.js +6 -4
  76. package/dist/service/environmentService.js +2 -3
  77. package/dist/service/frameworkService.js +9 -1
  78. package/dist/service/healthService.js +5 -4
  79. package/dist/service/informationService.js +3 -0
  80. package/dist/service/lifeCycleService.js +6 -1
  81. package/dist/service/loggerService.js +6 -2
  82. package/dist/service/middlewareService.js +1 -0
  83. package/dist/service/mockService.js +17 -15
  84. package/dist/service/slsFunctionService.js +1 -0
  85. package/dist/service/webRouterService.d.ts +1 -1
  86. package/dist/service/webRouterService.js +4 -3
  87. package/dist/setup.js +4 -5
  88. package/dist/util/camelCase.js +2 -3
  89. package/dist/util/contextUtil.d.ts +3 -3
  90. package/dist/util/extend.js +1 -2
  91. package/dist/util/flatted.js +2 -3
  92. package/dist/util/fs.js +2 -2
  93. package/dist/util/httpclient.d.ts +0 -4
  94. package/dist/util/httpclient.js +3 -2
  95. package/dist/util/index.d.ts +1 -2
  96. package/dist/util/index.js +26 -36
  97. package/dist/util/pathFileUtil.d.ts +0 -1
  98. package/dist/util/pathFileUtil.js +6 -6
  99. package/dist/util/retry.js +2 -3
  100. package/dist/util/timeout.d.ts +0 -1
  101. package/dist/util/timeout.js +1 -2
  102. package/dist/util/types.d.ts +7 -7
  103. package/dist/util/types.js +17 -17
  104. package/dist/util/uuid.js +1 -2
  105. package/package.json +2 -2
@@ -23,12 +23,12 @@ export declare abstract class BaseFramework<APP extends IMidwayApplication<CTX>,
23
23
  protected bootstrapOptions: IMidwayBootstrapOptions;
24
24
  protected asyncContextManager: AsyncContextManager;
25
25
  private namespace;
26
- loggerService: MidwayLoggerService;
27
- environmentService: MidwayEnvironmentService;
28
- configService: MidwayConfigService;
29
- informationService: MidwayInformationService;
30
- middlewareService: MidwayMiddlewareService<CTX, ResOrNext, Next>;
31
- mockService: MidwayMockService;
26
+ protected loggerService: MidwayLoggerService;
27
+ protected environmentService: MidwayEnvironmentService;
28
+ protected configService: MidwayConfigService;
29
+ protected informationService: MidwayInformationService;
30
+ protected middlewareService: MidwayMiddlewareService<CTX, ResOrNext, Next>;
31
+ protected mockService: MidwayMockService;
32
32
  constructor(applicationContext: IMidwayGlobalContainer);
33
33
  protected init(): Promise<this>;
34
34
  abstract configure(options?: OPT): OPT;
@@ -27,14 +27,27 @@ const asyncContextManager_1 = require("./common/asyncContextManager");
27
27
  const guardManager_1 = require("./common/guardManager");
28
28
  const debug = util.debuglog('midway:debug');
29
29
  class BaseFramework {
30
+ applicationContext;
31
+ app;
32
+ configurationOptions;
33
+ logger;
34
+ frameworkLoggerName = 'appLogger';
35
+ defaultContext = {};
36
+ middlewareManager = this.createMiddlewareManager();
37
+ filterManager = this.createFilterManager();
38
+ guardManager = this.createGuardManager();
39
+ composeMiddleware = null;
40
+ bootstrapOptions;
41
+ asyncContextManager;
42
+ namespace;
43
+ loggerService;
44
+ environmentService;
45
+ configService;
46
+ informationService;
47
+ middlewareService;
48
+ mockService;
30
49
  constructor(applicationContext) {
31
50
  this.applicationContext = applicationContext;
32
- this.frameworkLoggerName = 'appLogger';
33
- this.defaultContext = {};
34
- this.middlewareManager = this.createMiddlewareManager();
35
- this.filterManager = this.createFilterManager();
36
- this.guardManager = this.createGuardManager();
37
- this.composeMiddleware = null;
38
51
  }
39
52
  async init() {
40
53
  this.configurationOptions = this.configure() ?? {};
@@ -10,9 +10,7 @@ exports.MidwayApplicationManager = void 0;
10
10
  const interface_1 = require("../interface");
11
11
  const decorator_1 = require("../decorator");
12
12
  let MidwayApplicationManager = class MidwayApplicationManager {
13
- constructor() {
14
- this.globalFrameworkMap = new Map();
15
- }
13
+ globalFrameworkMap = new Map();
16
14
  addFramework(frameworkNameOrNamespace, framework) {
17
15
  this.globalFrameworkMap.set(frameworkNameOrNamespace, framework);
18
16
  }
@@ -18,6 +18,7 @@ exports.AsyncLocalStorageContextManager = exports.NoopContextManager = exports.A
18
18
  */
19
19
  const async_hooks_1 = require("async_hooks");
20
20
  class AsyncBaseContext {
21
+ _currentContext;
21
22
  /**
22
23
  * Construct a new context which inherits values from an optional parent context.
23
24
  *
@@ -40,6 +41,27 @@ class AsyncBaseContext {
40
41
  return context;
41
42
  };
42
43
  }
44
+ /**
45
+ * Get a value from the context.
46
+ *
47
+ * @param key key which identifies a context value
48
+ */
49
+ getValue;
50
+ /**
51
+ * Create a new context which inherits from this context and has
52
+ * the given key set to the given value.
53
+ *
54
+ * @param key context key for which to set the value
55
+ * @param value value to set for the given key
56
+ */
57
+ setValue;
58
+ /**
59
+ * Return a new context which inherits from this context but does
60
+ * not contain a value for the given key.
61
+ *
62
+ * @param key context key for which to clear a value
63
+ */
64
+ deleteValue;
43
65
  }
44
66
  /** The root context is used as the default parent context when there is no active context */
45
67
  exports.ASYNC_ROOT_CONTEXT = new AsyncBaseContext();
@@ -62,6 +84,7 @@ class NoopContextManager {
62
84
  }
63
85
  exports.NoopContextManager = NoopContextManager;
64
86
  class AsyncLocalStorageContextManager {
87
+ _asyncLocalStorage;
65
88
  constructor() {
66
89
  this._asyncLocalStorage = new async_hooks_1.AsyncLocalStorage();
67
90
  }
@@ -12,9 +12,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.DataListener = void 0;
13
13
  const decorator_1 = require("../decorator");
14
14
  class DataListener {
15
- constructor() {
16
- this.isReady = false;
17
- }
15
+ innerData;
16
+ isReady = false;
18
17
  async init() {
19
18
  if (!this.isReady) {
20
19
  this.innerData = await this.initData();
@@ -26,14 +26,16 @@ const environmentService_1 = require("../service/environmentService");
26
26
  const priorityManager_1 = require("./priorityManager");
27
27
  const debug = (0, util_1.debuglog)('midway:debug');
28
28
  class DataSourceManager {
29
- constructor() {
30
- this.dataSource = new Map();
31
- this.options = {};
32
- this.modelMapping = new WeakMap();
33
- this.dataSourcePriority = {};
34
- // for multi client with initialization
35
- this.creatingDataSources = new Map();
36
- }
29
+ dataSource = new Map();
30
+ options = {};
31
+ modelMapping = new WeakMap();
32
+ innerDefaultDataSourceName;
33
+ dataSourcePriority = {};
34
+ // for multi client with initialization
35
+ creatingDataSources = new Map();
36
+ baseDir;
37
+ environmentService;
38
+ priorityManager;
37
39
  async initDataSource(dataSourceConfig, baseDirOrOptions) {
38
40
  this.options = dataSourceConfig;
39
41
  if (!this.options.dataSource) {
@@ -10,6 +10,7 @@ const decorator_1 = require("../decorator");
10
10
  const util_2 = require("util");
11
11
  const debug = (0, util_2.debuglog)('midway:debug');
12
12
  class AbstractFileDetector {
13
+ options;
13
14
  constructor(options) {
14
15
  this.options = options;
15
16
  }
@@ -32,10 +33,7 @@ const DEFAULT_IGNORE_PATTERN = [
32
33
  * CommonJS module loader
33
34
  */
34
35
  class CommonJSFileDetector extends AbstractFileDetector {
35
- constructor() {
36
- super(...arguments);
37
- this.duplicateModuleCheckSet = new Map();
38
- }
36
+ duplicateModuleCheckSet = new Map();
39
37
  async run(container, namespace) {
40
38
  if (this.getType() === 'commonjs') {
41
39
  return this.loadSync(container, namespace);
@@ -5,14 +5,12 @@ const decorator_1 = require("../decorator");
5
5
  const util_1 = require("../util");
6
6
  const metadataManager_1 = require("../decorator/metadataManager");
7
7
  class FilterManager {
8
- constructor() {
9
- this.errFilterList = [];
10
- this.successFilterList = [];
11
- this.exceptionMap = new WeakMap();
12
- this.defaultErrFilter = undefined;
13
- this.matchFnList = [];
14
- this.protoMatchList = [];
15
- }
8
+ errFilterList = [];
9
+ successFilterList = [];
10
+ exceptionMap = new WeakMap();
11
+ defaultErrFilter = undefined;
12
+ matchFnList = [];
13
+ protoMatchList = [];
16
14
  useFilter(Filters) {
17
15
  if (!Array.isArray(Filters)) {
18
16
  Filters = [Filters];
@@ -5,9 +5,7 @@ class LoggerFactory {
5
5
  }
6
6
  exports.LoggerFactory = LoggerFactory;
7
7
  class DefaultConsoleLoggerFactory {
8
- constructor() {
9
- this.instance = new Map();
10
- }
8
+ instance = new Map();
11
9
  createLogger(name, options) {
12
10
  this.instance.set(name, console);
13
11
  return console;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createMiddleware = exports.ContextMiddlewareManager = void 0;
3
+ exports.ContextMiddlewareManager = void 0;
4
+ exports.createMiddleware = createMiddleware;
4
5
  class ContextMiddlewareManager extends Array {
5
6
  /**
6
7
  * insert a middleware or middleware array to first
@@ -210,5 +211,4 @@ function createMiddleware(middleware, options, name) {
210
211
  name,
211
212
  };
212
213
  }
213
- exports.createMiddleware = createMiddleware;
214
214
  //# sourceMappingURL=middlewareManager.js.map
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { PerformanceObserver, PerformanceObserverEntryList } from 'perf_hooks';
3
2
  export declare class MidwayPerformanceManager {
4
3
  private readonly group;
@@ -3,11 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MidwayInitializerPerformanceManager = exports.MidwayPerformanceManager = void 0;
4
4
  const perf_hooks_1 = require("perf_hooks");
5
5
  class MidwayPerformanceManager {
6
+ group;
7
+ static instances = new Map();
8
+ static DEFAULT_GROUP = {
9
+ INITIALIZE: 'MidwayInitialize',
10
+ };
11
+ observer = null;
12
+ marks = new Set();
13
+ measures = new Set();
6
14
  constructor(group) {
7
15
  this.group = group;
8
- this.observer = null;
9
- this.marks = new Set();
10
- this.measures = new Set();
11
16
  }
12
17
  static getInstance(group) {
13
18
  if (!this.instances.has(group)) {
@@ -91,11 +96,20 @@ class MidwayPerformanceManager {
91
96
  }
92
97
  }
93
98
  exports.MidwayPerformanceManager = MidwayPerformanceManager;
94
- MidwayPerformanceManager.instances = new Map();
95
- MidwayPerformanceManager.DEFAULT_GROUP = {
96
- INITIALIZE: 'MidwayInitialize',
97
- };
98
99
  class MidwayInitializerPerformanceManager {
100
+ static MEASURE_KEYS = {
101
+ INITIALIZE: 'Initialize',
102
+ METADATA_PREPARE: 'MetadataPrepare',
103
+ DETECTOR_PREPARE: 'DetectorPrepare',
104
+ DEFINITION_PREPARE: 'DefinitionPrepare',
105
+ CONFIG_LOAD: 'ConfigLoad',
106
+ LOGGER_PREPARE: 'LoggerPrepare',
107
+ FRAMEWORK_PREPARE: 'FrameworkPrepare',
108
+ FRAMEWORK_INITIALIZE: 'FrameworkInitialize',
109
+ FRAMEWORK_RUN: 'FrameworkRun',
110
+ LIFECYCLE_PREPARE: 'LifecyclePrepare',
111
+ PRELOAD_MODULE_PREPARE: 'PreloadModulePrepare',
112
+ };
99
113
  static markStart(key) {
100
114
  const manager = MidwayPerformanceManager.getInstance(MidwayPerformanceManager.DEFAULT_GROUP.INITIALIZE);
101
115
  manager.markStart(key);
@@ -124,17 +138,4 @@ class MidwayInitializerPerformanceManager {
124
138
  }
125
139
  }
126
140
  exports.MidwayInitializerPerformanceManager = MidwayInitializerPerformanceManager;
127
- MidwayInitializerPerformanceManager.MEASURE_KEYS = {
128
- INITIALIZE: 'Initialize',
129
- METADATA_PREPARE: 'MetadataPrepare',
130
- DETECTOR_PREPARE: 'DetectorPrepare',
131
- DEFINITION_PREPARE: 'DefinitionPrepare',
132
- CONFIG_LOAD: 'ConfigLoad',
133
- LOGGER_PREPARE: 'LoggerPrepare',
134
- FRAMEWORK_PREPARE: 'FrameworkPrepare',
135
- FRAMEWORK_INITIALIZE: 'FrameworkInitialize',
136
- FRAMEWORK_RUN: 'FrameworkRun',
137
- LIFECYCLE_PREPARE: 'LifecyclePrepare',
138
- PRELOAD_MODULE_PREPARE: 'PreloadModulePrepare',
139
- };
140
141
  //# sourceMappingURL=performanceManager.js.map
@@ -15,10 +15,8 @@ exports.DEFAULT_PRIORITY = {
15
15
  L3: 'Low',
16
16
  };
17
17
  let MidwayPriorityManager = class MidwayPriorityManager {
18
- constructor() {
19
- this.priorityList = exports.DEFAULT_PRIORITY;
20
- this.defaultPriority = exports.DEFAULT_PRIORITY.L2;
21
- }
18
+ priorityList = exports.DEFAULT_PRIORITY;
19
+ defaultPriority = exports.DEFAULT_PRIORITY.L2;
22
20
  getCurrentPriorityList() {
23
21
  return this.priorityList;
24
22
  }
@@ -8,9 +8,10 @@ const net = require("net");
8
8
  * 抽象健康检查类
9
9
  */
10
10
  class AbstractHealthCheck {
11
+ options;
12
+ lastCheckTime = 0;
13
+ lastCheckResult = null;
11
14
  constructor(options) {
12
- this.lastCheckTime = 0;
13
- this.lastCheckResult = null;
14
15
  // 设置默认值
15
16
  const defaultOptions = {
16
17
  interval: 10000, // 默认10秒
@@ -52,6 +53,7 @@ exports.AbstractHealthCheck = AbstractHealthCheck;
52
53
  * 用于 Redis/ETCD 等基于 TTL 的服务发现
53
54
  */
54
55
  class TTLHealthCheck extends AbstractHealthCheck {
56
+ ttl;
55
57
  constructor(options) {
56
58
  super(options);
57
59
  this.ttl = options?.ttl;
@@ -79,6 +81,9 @@ exports.TTLHealthCheck = TTLHealthCheck;
79
81
  * 用于支持 HTTP 检查的服务发现
80
82
  */
81
83
  class HTTPHealthCheck extends AbstractHealthCheck {
84
+ checkUrl;
85
+ httpClient;
86
+ httpOptions;
82
87
  constructor(options) {
83
88
  super(options);
84
89
  this.checkUrl = options.url;
@@ -131,6 +136,9 @@ exports.HTTPHealthCheck = HTTPHealthCheck;
131
136
  * 用于支持 TCP 检查的服务发现
132
137
  */
133
138
  class TCPHealthCheck extends AbstractHealthCheck {
139
+ host;
140
+ port;
141
+ tcpOptions;
134
142
  constructor(options) {
135
143
  super(options);
136
144
  this.host = options.host;
@@ -19,9 +19,7 @@ exports.RandomLoadBalance = RandomLoadBalance;
19
19
  * 轮询负载均衡策略
20
20
  */
21
21
  class RoundRobinLoadBalancer {
22
- constructor() {
23
- this.currentIndex = 0;
24
- }
22
+ currentIndex = 0;
25
23
  select(instances) {
26
24
  if (!instances.length) {
27
25
  throw new Error('No available instances');
@@ -16,11 +16,15 @@ const interface_1 = require("../../interface");
16
16
  const network_1 = require("../../util/network");
17
17
  const extend_1 = require("../../util/extend");
18
18
  class ServiceDiscoveryClient {
19
+ options;
20
+ instance;
21
+ client;
19
22
  constructor(client, serviceDiscoveryOptions) {
20
23
  this.client = client;
21
24
  this.options =
22
25
  serviceDiscoveryOptions ?? {};
23
26
  }
27
+ _defaultMeta;
24
28
  get defaultMeta() {
25
29
  if (!this._defaultMeta) {
26
30
  this._defaultMeta = this.getDefaultInstanceMeta();
@@ -54,9 +58,8 @@ exports.ServiceDiscoveryClient = ServiceDiscoveryClient;
54
58
  * 服务发现抽象类
55
59
  */
56
60
  class ServiceDiscovery {
57
- constructor() {
58
- this.serviceDiscoveryClientStore = new Set();
59
- }
61
+ serviceDiscoveryClientStore = new Set();
62
+ loadBalancer;
60
63
  createClient(options) {
61
64
  const serviceDiscoveryOption = (0, extend_1.extend)({}, options, this.getDefaultServiceDiscoveryOptions());
62
65
  const client = this.createServiceDiscoverClientImpl(serviceDiscoveryOption);
@@ -18,12 +18,12 @@ const types_1 = require("../util/types");
18
18
  * 多客户端工厂实现
19
19
  */
20
20
  class ServiceFactory {
21
- constructor() {
22
- this.clients = new Map();
23
- this.options = {};
24
- // for multi client with initialization
25
- this.creatingClients = new Map();
26
- }
21
+ clients = new Map();
22
+ clientPriority;
23
+ options = {};
24
+ priorityManager;
25
+ // for multi client with initialization
26
+ creatingClients = new Map();
27
27
  async initClients(options = {}, initOptions = {}) {
28
28
  this.options = options;
29
29
  // merge options.client to options.clients['default']
@@ -2,10 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TypedResourceManager = void 0;
4
4
  class TypedResourceManager {
5
+ typedResourceInitializerOptions;
6
+ resourceMap = new Map();
7
+ resourceBindingMap = new Map();
5
8
  constructor(typedResourceInitializerOptions) {
6
9
  this.typedResourceInitializerOptions = typedResourceInitializerOptions;
7
- this.resourceMap = new Map();
8
- this.resourceBindingMap = new Map();
9
10
  }
10
11
  async createResource(resourceName, resourceInitializeConfig) {
11
12
  const resource = await this.typedResourceInitializerOptions.resourceInitialize(resourceInitializeConfig, resourceName);
@@ -13,6 +13,8 @@ const error_1 = require("../error");
13
13
  const middlewareService_1 = require("../service/middlewareService");
14
14
  const debug = util.debuglog('midway:debug');
15
15
  class WebControllerGenerator {
16
+ app;
17
+ midwayWebRouterService;
16
18
  constructor(app, midwayWebRouterService) {
17
19
  this.app = app;
18
20
  this.midwayWebRouterService = midwayWebRouterService;
@@ -5,10 +5,10 @@ exports.default = (appInfo) => {
5
5
  const isDevelopment = (0, util_1.isDevelopmentEnvironment)((0, util_1.getCurrentEnvironment)());
6
6
  return {
7
7
  core: {
8
- healthCheckTimeout: 1000,
9
- configLoadTimeout: 10000,
10
- readyTimeout: 30000,
11
- serverReadyTimeout: 30000,
8
+ healthCheckTimeout: 1_000,
9
+ configLoadTimeout: 10_000,
10
+ readyTimeout: 30_000,
11
+ serverReadyTimeout: 30_000,
12
12
  },
13
13
  asyncContextManager: {
14
14
  enable: true,
@@ -9,10 +9,11 @@ const util = require("util");
9
9
  const util_1 = require("../util");
10
10
  const debug = util.debuglog('midway:debug');
11
11
  class ComponentConfigurationLoader {
12
+ container;
13
+ loadedMap = new WeakMap();
14
+ namespaceList = [];
12
15
  constructor(container) {
13
16
  this.container = container;
14
- this.loadedMap = new WeakMap();
15
- this.namespaceList = [];
16
17
  }
17
18
  async load(module) {
18
19
  let namespace = decorator_1.MAIN_MODULE_KEY;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { ClassType, IIdentifierRelationShip, IMidwayContainer, IMidwayGlobalContainer, IObjectDefinition, IObjectDefinitionRegistry, ObjectIdentifier, ScopeEnum } from '../interface';
3
2
  import { ManagedResolverFactory } from './managedResolverFactory';
4
3
  import { EventEmitter } from 'events';
@@ -17,18 +17,19 @@ const debug = util.debuglog('midway:debug');
17
17
  const debugBind = util.debuglog('midway:bind');
18
18
  const debugSpaceLength = 9;
19
19
  class MidwayContainer {
20
+ _resolverFactory = null;
21
+ _registry = null;
22
+ _identifierMapping = null;
23
+ _objectCreateEventTarget;
24
+ // 仅仅用于兼容 requestContainer 的 ctx
25
+ ctx = constants_1.SINGLETON_CONTAINER_CTX;
26
+ attrMap = new Map();
27
+ namespaceSet = new Set();
28
+ _id = util_1.Utils.generateRandomId();
20
29
  get id() {
21
30
  return this._id;
22
31
  }
23
32
  constructor() {
24
- this._resolverFactory = null;
25
- this._registry = null;
26
- this._identifierMapping = null;
27
- // 仅仅用于兼容 requestContainer 的 ctx
28
- this.ctx = constants_1.SINGLETON_CONTAINER_CTX;
29
- this.attrMap = new Map();
30
- this.namespaceSet = new Set();
31
- this._id = util_1.Utils.generateRandomId();
32
33
  // 防止直接从applicationContext.getAsync or get对象实例时依赖当前上下文信息出错
33
34
  // ctx is in requestContainer
34
35
  this.registerObject(constants_1.REQUEST_CTX_KEY, this.ctx);
@@ -34,12 +34,9 @@ class LegacyIdentifierRelation extends Map {
34
34
  }
35
35
  }
36
36
  class ObjectDefinitionRegistry extends Map {
37
- constructor() {
38
- super(...arguments);
39
- this.singletonIds = [];
40
- this._identifierRelation = new LegacyIdentifierRelation();
41
- this.objectCache = new Map();
42
- }
37
+ singletonIds = [];
38
+ _identifierRelation = new LegacyIdentifierRelation();
39
+ objectCache = new Map();
43
40
  get identifierRelation() {
44
41
  if (!this._identifierRelation) {
45
42
  this._identifierRelation = new LegacyIdentifierRelation();
@@ -12,10 +12,11 @@ const debug = (0, util_2.debuglog)('midway:container');
12
12
  * 尝试用于开发时动态更新的 IoC 容器
13
13
  */
14
14
  class DynamicMidwayContainer extends container_1.MidwayContainer {
15
+ moduleType;
16
+ modifyClassMapping = new Map();
17
+ idRefMapping = new Map();
15
18
  constructor() {
16
19
  super();
17
- this.modifyClassMapping = new Map();
18
- this.idRefMapping = new Map();
19
20
  this.onBeforeBind((Clzz, options) => {
20
21
  const definition = options.definition;
21
22
  if (definition) {
@@ -31,8 +31,9 @@ function formatObjectIdentifier(identifier) {
31
31
  * 解析工厂
32
32
  */
33
33
  class ManagedResolverFactory {
34
+ creating = new Map();
35
+ context;
34
36
  constructor(context) {
35
- this.creating = new Map();
36
37
  this.context = context;
37
38
  }
38
39
  /**
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.providerWrapper = void 0;
3
+ exports.providerWrapper = providerWrapper;
4
4
  const constants_1 = require("../constants");
5
5
  function providerWrapper(wrapperInfo) {
6
6
  for (const info of wrapperInfo) {
@@ -10,5 +10,4 @@ function providerWrapper(wrapperInfo) {
10
10
  });
11
11
  }
12
12
  }
13
- exports.providerWrapper = providerWrapper;
14
13
  //# sourceMappingURL=providerWrapper.js.map
@@ -4,11 +4,14 @@ exports.MidwayRequestContainer = void 0;
4
4
  const constants_1 = require("../constants");
5
5
  const definitionRegistry_1 = require("./definitionRegistry");
6
6
  class MidwayRequestContainer {
7
+ ctx;
8
+ applicationContext;
9
+ parent;
10
+ registry = new definitionRegistry_1.ObjectDefinitionRegistry();
11
+ attrMap = new Map();
7
12
  constructor(ctx, applicationContext) {
8
13
  this.ctx = ctx;
9
14
  this.applicationContext = applicationContext;
10
- this.registry = new definitionRegistry_1.ObjectDefinitionRegistry();
11
- this.attrMap = new Map();
12
15
  this.parent = applicationContext;
13
16
  // update legacy relationship
14
17
  this.registry.setIdentifierRelation(this.applicationContext.registry.getIdentifierRelation());
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Aspect = void 0;
3
+ exports.Aspect = Aspect;
4
4
  const __1 = require("../");
5
5
  const interface_1 = require("../../interface");
6
6
  const metadataManager_1 = require("../metadataManager");
@@ -19,5 +19,4 @@ function Aspect(aspectTarget, match, priority) {
19
19
  (0, __1.Provide)()(target);
20
20
  };
21
21
  }
22
- exports.Aspect = Aspect;
23
22
  //# sourceMappingURL=aspect.js.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Autoload = void 0;
3
+ exports.Autoload = Autoload;
4
4
  const decoratorManager_1 = require("../decoratorManager");
5
5
  const provide_1 = require("./provide");
6
6
  function Autoload() {
@@ -9,5 +9,4 @@ function Autoload() {
9
9
  (0, provide_1.Provide)()(target);
10
10
  };
11
11
  }
12
- exports.Autoload = Autoload;
13
12
  //# sourceMappingURL=autoload.js.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Configuration = void 0;
3
+ exports.Configuration = Configuration;
4
4
  const __1 = require("../");
5
5
  const metadataManager_1 = require("../metadataManager");
6
6
  const interface_1 = require("../../interface");
@@ -12,5 +12,4 @@ function Configuration(options = {}) {
12
12
  (0, __1.Provide)()(target);
13
13
  };
14
14
  }
15
- exports.Configuration = Configuration;
16
15
  //# sourceMappingURL=configuration.js.map
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Match = exports.Catch = void 0;
3
+ exports.Catch = Catch;
4
+ exports.Match = Match;
4
5
  const constant_1 = require("../constant");
5
6
  const provide_1 = require("./provide");
6
7
  const interface_1 = require("../../interface");
@@ -17,7 +18,6 @@ function Catch(catchTarget, options = {}) {
17
18
  (0, provide_1.Provide)()(target);
18
19
  };
19
20
  }
20
- exports.Catch = Catch;
21
21
  function Match(matchPattern = true) {
22
22
  return function (target) {
23
23
  metadataManager_1.MetadataManager.defineMetadata(constant_1.MATCH_KEY, {
@@ -27,5 +27,4 @@ function Match(matchPattern = true) {
27
27
  (0, provide_1.Provide)()(target);
28
28
  };
29
29
  }
30
- exports.Match = Match;
31
30
  //# sourceMappingURL=filter.js.map