@midwayjs/core 3.11.15 → 3.12.0-beta.2

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.
@@ -1,3 +1,4 @@
1
+ import { ModuleLoadType } from '../interface';
1
2
  export interface CreateDataSourceInstanceOptions {
2
3
  /**
3
4
  * @default false
@@ -59,6 +60,6 @@ export declare abstract class DataSourceManager<T> {
59
60
  getDefaultDataSourceName(): string;
60
61
  }
61
62
  export declare function formatGlobString(globString: string): string[];
62
- export declare function globModels(globString: string, appDir: string): any[];
63
+ export declare function globModels(globString: string, appDir: string, loadMode?: ModuleLoadType): Promise<any[]>;
63
64
  export {};
64
65
  //# sourceMappingURL=dataSourceManager.d.ts.map
@@ -11,6 +11,7 @@ const path_1 = require("path");
11
11
  const types_1 = require("../util/types");
12
12
  const constants_1 = require("../constants");
13
13
  const util_1 = require("util");
14
+ const util_2 = require("../util");
14
15
  const debug = (0, util_1.debuglog)('midway:debug');
15
16
  class DataSourceManager {
16
17
  constructor() {
@@ -36,7 +37,7 @@ class DataSourceManager {
36
37
  for (const entity of dataSourceOptions['entities']) {
37
38
  if (typeof entity === 'string') {
38
39
  // string will be glob file
39
- const models = globModels(entity, appDirOrOptions.appDir);
40
+ const models = await globModels(entity, appDirOrOptions.appDir);
40
41
  for (const model of models) {
41
42
  entities.add(model);
42
43
  this.modelMapping.set(model, dataSourceName);
@@ -153,7 +154,7 @@ function formatGlobString(globString) {
153
154
  return pattern;
154
155
  }
155
156
  exports.formatGlobString = formatGlobString;
156
- function globModels(globString, appDir) {
157
+ async function globModels(globString, appDir, loadMode) {
157
158
  const pattern = formatGlobString(globString);
158
159
  const models = [];
159
160
  // string will be glob file
@@ -162,7 +163,9 @@ function globModels(globString, appDir) {
162
163
  ignore: constants_1.IGNORE_PATTERN,
163
164
  });
164
165
  for (const file of files) {
165
- const exports = require(file);
166
+ const exports = await (0, util_2.loadModule)(file, {
167
+ loadMode,
168
+ });
166
169
  if (types_1.Types.isClass(exports)) {
167
170
  models.push(exports);
168
171
  }
@@ -2,11 +2,14 @@ import { IFileDetector, IMidwayContainer } from '../interface';
2
2
  export declare abstract class AbstractFileDetector<T> implements IFileDetector {
3
3
  options: T;
4
4
  extraDetectorOptions: T;
5
- constructor(options: any);
6
- abstract run(container: IMidwayContainer): any;
5
+ constructor(options?: T);
6
+ abstract run(container: IMidwayContainer): void | Promise<void>;
7
7
  setExtraDetectorOptions(detectorOptions: T): void;
8
8
  }
9
- export declare class DirectoryFileDetector extends AbstractFileDetector<{
9
+ /**
10
+ * CommonJS module loader
11
+ */
12
+ export declare class CommonJSFileDetector extends AbstractFileDetector<{
10
13
  loadDir?: string | string[];
11
14
  pattern?: string | string[];
12
15
  ignore?: string | string[];
@@ -14,12 +17,21 @@ export declare class DirectoryFileDetector extends AbstractFileDetector<{
14
17
  conflictCheck?: boolean;
15
18
  }> {
16
19
  private duplicateModuleCheckSet;
17
- run(container: any): void;
20
+ run(container: any): void | Promise<void>;
21
+ loadSync(container: any): void;
22
+ loadAsync(container: any): Promise<void>;
23
+ getType(): 'commonjs' | 'module';
24
+ }
25
+ /**
26
+ * ES module loader
27
+ */
28
+ export declare class ESModuleFileDetector extends CommonJSFileDetector {
29
+ getType(): 'commonjs' | 'module';
18
30
  }
19
31
  export declare class CustomModuleDetector extends AbstractFileDetector<{
20
32
  modules?: any[];
21
33
  namespace?: string;
22
34
  }> {
23
- run(container: any): void;
35
+ run(container: any): Promise<void>;
24
36
  }
25
37
  //# sourceMappingURL=fileDetector.d.ts.map
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CustomModuleDetector = exports.DirectoryFileDetector = exports.AbstractFileDetector = void 0;
3
+ exports.CustomModuleDetector = exports.ESModuleFileDetector = exports.CommonJSFileDetector = exports.AbstractFileDetector = void 0;
4
4
  const types_1 = require("../util/types");
5
5
  const glob_1 = require("@midwayjs/glob");
6
6
  const error_1 = require("../error");
7
7
  const constants_1 = require("../constants");
8
8
  const decorator_1 = require("../decorator");
9
+ const util_1 = require("../util");
9
10
  class AbstractFileDetector {
10
11
  constructor(options) {
11
12
  this.options = options;
@@ -29,15 +30,26 @@ const DEFAULT_IGNORE_PATTERN = [
29
30
  '**/**.test.js',
30
31
  '**/__test__/**',
31
32
  ].concat(constants_1.IGNORE_PATTERN);
32
- class DirectoryFileDetector extends AbstractFileDetector {
33
+ /**
34
+ * CommonJS module loader
35
+ */
36
+ class CommonJSFileDetector extends AbstractFileDetector {
33
37
  constructor() {
34
38
  super(...arguments);
35
39
  this.duplicateModuleCheckSet = new Map();
36
40
  }
37
41
  run(container) {
38
- const loadDirs = []
39
- .concat(this.options.loadDir || [])
40
- .concat(this.extraDetectorOptions.loadDir || []);
42
+ if (this.getType() === 'commonjs') {
43
+ return this.loadSync(container);
44
+ }
45
+ else {
46
+ return this.loadAsync(container);
47
+ }
48
+ }
49
+ loadSync(container) {
50
+ var _a;
51
+ this.options = this.options || {};
52
+ const loadDirs = [].concat((_a = this.options.loadDir) !== null && _a !== void 0 ? _a : container.get('baseDir'));
41
53
  for (const dir of loadDirs) {
42
54
  const fileResults = (0, glob_1.run)(DEFAULT_GLOB_PATTERN.concat(this.options.pattern || []).concat(this.extraDetectorOptions.pattern || []), {
43
55
  cwd: dir,
@@ -73,10 +85,63 @@ class DirectoryFileDetector extends AbstractFileDetector {
73
85
  // check end
74
86
  this.duplicateModuleCheckSet.clear();
75
87
  }
88
+ async loadAsync(container) {
89
+ var _a;
90
+ this.options = this.options || {};
91
+ const loadDirs = [].concat((_a = this.options.loadDir) !== null && _a !== void 0 ? _a : container.get('baseDir'));
92
+ for (const dir of loadDirs) {
93
+ const fileResults = (0, glob_1.run)(DEFAULT_GLOB_PATTERN.concat(this.options.pattern || []).concat(this.extraDetectorOptions.pattern || []), {
94
+ cwd: dir,
95
+ ignore: DEFAULT_IGNORE_PATTERN.concat(this.options.ignore || []).concat(this.extraDetectorOptions.ignore || []),
96
+ });
97
+ // 检查重复模块
98
+ const checkDuplicatedHandler = (module, options) => {
99
+ if ((this.options.conflictCheck ||
100
+ this.extraDetectorOptions.conflictCheck) &&
101
+ types_1.Types.isClass(module)) {
102
+ const name = (0, decorator_1.getProviderName)(module);
103
+ if (name) {
104
+ if (this.duplicateModuleCheckSet.has(name)) {
105
+ throw new error_1.MidwayDuplicateClassNameError(name, options.srcPath, this.duplicateModuleCheckSet.get(name));
106
+ }
107
+ else {
108
+ this.duplicateModuleCheckSet.set(name, options.srcPath);
109
+ }
110
+ }
111
+ }
112
+ };
113
+ for (const file of fileResults) {
114
+ const exports = await (0, util_1.loadModule)(file, {
115
+ loadMode: 'esm',
116
+ });
117
+ // add module to set
118
+ container.bindClass(exports, {
119
+ namespace: this.options.namespace,
120
+ srcPath: file,
121
+ createFrom: 'file',
122
+ bindHook: checkDuplicatedHandler,
123
+ });
124
+ }
125
+ }
126
+ // check end
127
+ this.duplicateModuleCheckSet.clear();
128
+ }
129
+ getType() {
130
+ return 'commonjs';
131
+ }
76
132
  }
77
- exports.DirectoryFileDetector = DirectoryFileDetector;
133
+ exports.CommonJSFileDetector = CommonJSFileDetector;
134
+ /**
135
+ * ES module loader
136
+ */
137
+ class ESModuleFileDetector extends CommonJSFileDetector {
138
+ getType() {
139
+ return 'module';
140
+ }
141
+ }
142
+ exports.ESModuleFileDetector = ESModuleFileDetector;
78
143
  class CustomModuleDetector extends AbstractFileDetector {
79
- run(container) {
144
+ async run(container) {
80
145
  for (const module of this.options.modules) {
81
146
  container.bindClass(module, {
82
147
  namespace: this.options.namespace,
@@ -13,7 +13,6 @@ export declare class MidwayContainer implements IMidwayContainer, IModuleStore {
13
13
  private fileDetector;
14
14
  private attrMap;
15
15
  private _namespaceSet;
16
- private isLoad;
17
16
  constructor(parent?: IMidwayContainer);
18
17
  protected init(): void;
19
18
  get objectCreateEventTarget(): EventEmitter;
@@ -22,8 +21,8 @@ export declare class MidwayContainer implements IMidwayContainer, IModuleStore {
22
21
  get managedResolverFactory(): ManagedResolverFactory;
23
22
  get identifierMapping(): IIdentifierRelationShip;
24
23
  get namespaceSet(): Set<string>;
25
- load(module?: any): void;
26
- protected loadDefinitions(): void;
24
+ load(module: any): void;
25
+ protected loadDefinitions(): void | Promise<void>;
27
26
  bindClass(exports: any, options?: Partial<IObjectDefinition>): void;
28
27
  bind<T>(target: T, options?: Partial<IObjectDefinition>): void;
29
28
  bind<T>(identifier: ObjectIdentifier, target: T, options?: Partial<IObjectDefinition>): void;
@@ -35,7 +34,7 @@ export declare class MidwayContainer implements IMidwayContainer, IModuleStore {
35
34
  protected getIdentifier(target: any): string;
36
35
  protected getManagedResolverFactory(): ManagedResolverFactory;
37
36
  stop(): Promise<void>;
38
- ready(): void;
37
+ ready(): void | Promise<void>;
39
38
  get<T>(identifier: {
40
39
  new (...args: any[]): T;
41
40
  }, args?: any[], objectContext?: ObjectContext): T;
@@ -14,7 +14,6 @@ const environmentService_1 = require("../service/environmentService");
14
14
  const configService_1 = require("../service/configService");
15
15
  const EventEmitter = require("events");
16
16
  const error_1 = require("../error");
17
- const extend_1 = require("../util/extend");
18
17
  const types_1 = require("../util/types");
19
18
  const util_1 = require("../util");
20
19
  const debug = util.debuglog('midway:debug');
@@ -25,7 +24,7 @@ class ContainerConfiguration {
25
24
  this.container = container;
26
25
  this.loadedMap = new WeakMap();
27
26
  this.namespaceList = [];
28
- this.detectorOptionsList = [];
27
+ this.configurationOptionsList = [];
29
28
  }
30
29
  load(module) {
31
30
  let namespace = decorator_1.MAIN_MODULE_KEY;
@@ -56,10 +55,7 @@ class ContainerConfiguration {
56
55
  namespace = configurationOptions.namespace;
57
56
  this.namespaceList.push(namespace);
58
57
  }
59
- this.detectorOptionsList.push({
60
- conflictCheck: configurationOptions.conflictCheck,
61
- ...configurationOptions.detectorOptions,
62
- });
58
+ this.configurationOptionsList.push(configurationOptions);
63
59
  debug(`[core]: load configuration in namespace="${namespace}"`);
64
60
  this.addImports(configurationOptions.imports);
65
61
  this.addImportObjects(configurationOptions.importObjects);
@@ -179,8 +175,8 @@ class ContainerConfiguration {
179
175
  getNamespaceList() {
180
176
  return this.namespaceList;
181
177
  }
182
- getDetectorOptionsList() {
183
- return this.detectorOptionsList;
178
+ getConfigurationOptionsList() {
179
+ return this.configurationOptionsList;
184
180
  }
185
181
  }
186
182
  class MidwayContainer {
@@ -194,7 +190,6 @@ class MidwayContainer {
194
190
  this.ctx = {};
195
191
  this.attrMap = new Map();
196
192
  this._namespaceSet = null;
197
- this.isLoad = false;
198
193
  this.parent = parent;
199
194
  this.init();
200
195
  }
@@ -237,30 +232,37 @@ class MidwayContainer {
237
232
  return this._namespaceSet;
238
233
  }
239
234
  load(module) {
240
- var _a;
241
- if (module) {
242
- // load configuration
243
- const configuration = new ContainerConfiguration(this);
244
- configuration.load(module);
245
- for (const ns of configuration.getNamespaceList()) {
246
- this.namespaceSet.add(ns);
247
- debug(`[core]: load configuration in namespace="${ns}" complete`);
235
+ var _a, _b, _c;
236
+ if (!Array.isArray(module)) {
237
+ module = [module];
238
+ }
239
+ // load configuration
240
+ const configuration = new ContainerConfiguration(this);
241
+ for (const mod of module) {
242
+ if (mod) {
243
+ configuration.load(mod);
248
244
  }
249
- const detectorOptionsMerged = {};
250
- for (const detectorOptions of configuration.getDetectorOptionsList()) {
251
- (0, extend_1.extend)(true, detectorOptionsMerged, detectorOptions);
252
- }
253
- (_a = this.fileDetector) === null || _a === void 0 ? void 0 : _a.setExtraDetectorOptions(detectorOptionsMerged);
254
- this.isLoad = true;
245
+ }
246
+ for (const ns of configuration.getNamespaceList()) {
247
+ this.namespaceSet.add(ns);
248
+ debug(`[core]: load configuration in namespace="${ns}" complete`);
249
+ }
250
+ const configurationOptionsList = (_a = configuration.getConfigurationOptionsList()) !== null && _a !== void 0 ? _a : [];
251
+ // find user code configuration it's without namespace
252
+ const userCodeConfiguration = (_b = configurationOptionsList.find(options => !options.namespace)) !== null && _b !== void 0 ? _b : {};
253
+ this.fileDetector = (_c = userCodeConfiguration.detector) !== null && _c !== void 0 ? _c : this.fileDetector;
254
+ if (this.fileDetector) {
255
+ this.fileDetector.setExtraDetectorOptions({
256
+ conflictCheck: userCodeConfiguration.conflictCheck,
257
+ ...userCodeConfiguration.detectorOptions,
258
+ });
255
259
  }
256
260
  }
257
261
  loadDefinitions() {
258
- var _a;
259
- if (!this.isLoad) {
260
- this.load();
261
- }
262
262
  // load project file
263
- (_a = this.fileDetector) === null || _a === void 0 ? void 0 : _a.run(this);
263
+ if (this.fileDetector) {
264
+ return this.fileDetector.run(this);
265
+ }
264
266
  }
265
267
  bindClass(exports, options) {
266
268
  if (types_1.Types.isClass(exports) || types_1.Types.isFunction(exports)) {
@@ -411,7 +413,7 @@ class MidwayContainer {
411
413
  this.registry.clearAll();
412
414
  }
413
415
  ready() {
414
- this.loadDefinitions();
416
+ return this.loadDefinitions();
415
417
  }
416
418
  get(identifier, args, objectContext) {
417
419
  var _a;
@@ -6,7 +6,7 @@ export declare class MidwayRequestContainer extends MidwayContainer {
6
6
  init(): void;
7
7
  get<T = any>(identifier: any, args?: any): T;
8
8
  getAsync<T = any>(identifier: any, args?: any): Promise<T>;
9
- ready(): void;
9
+ ready(): Promise<void>;
10
10
  getContext(): {};
11
11
  }
12
12
  //# sourceMappingURL=requestContainer.d.ts.map
@@ -67,7 +67,7 @@ class MidwayRequestContainer extends container_1.MidwayContainer {
67
67
  return this.parent.getAsync(identifier, args);
68
68
  }
69
69
  }
70
- ready() {
70
+ async ready() {
71
71
  // ignore other things
72
72
  }
73
73
  getContext() {
@@ -1,3 +1,4 @@
1
+ import { IFileDetector } from '../../interface';
1
2
  export interface IComponentInfo {
2
3
  component: any;
3
4
  enabledEnvironment?: string[];
@@ -17,6 +18,7 @@ export interface InjectionConfigurationOptions {
17
18
  }> | Record<string, any>;
18
19
  importConfigFilter?: (config: Record<string, any>) => Record<string, any>;
19
20
  namespace?: string;
21
+ detector?: IFileDetector | false;
20
22
  detectorOptions?: Record<string, any>;
21
23
  conflictCheck?: boolean;
22
24
  }
package/dist/index.d.ts CHANGED
@@ -33,7 +33,7 @@ export { AsyncContextManager, ASYNC_ROOT_CONTEXT, AsyncContext, } from './common
33
33
  export * from './decorator';
34
34
  export * from './decorator/decoratorManager';
35
35
  export * from './decorator/constant';
36
- export { safelyGet, safeRequire, delegateTargetPrototypeMethod, delegateTargetMethod, delegateTargetProperties, delegateTargetAllPrototypeMethod, deprecatedOutput, transformRequestObjectByType, pathMatching, wrapMiddleware, wrapAsync, } from './util/';
36
+ export { safelyGet, safeRequire, loadModule, delegateTargetPrototypeMethod, delegateTargetMethod, delegateTargetProperties, delegateTargetAllPrototypeMethod, deprecatedOutput, transformRequestObjectByType, pathMatching, wrapMiddleware, wrapAsync, isTypeScriptEnvironment, } from './util/';
37
37
  export { extend } from './util/extend';
38
38
  export * from './util/webRouterParam';
39
39
  export * from './util/contextUtil';
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.FORMAT = exports.FileUtils = exports.PathFileUtil = exports.Types = exports.Utils = exports.sleep = exports.retryWith = exports.retryWithAsync = exports.extend = exports.wrapAsync = exports.wrapMiddleware = exports.pathMatching = exports.transformRequestObjectByType = exports.deprecatedOutput = exports.delegateTargetAllPrototypeMethod = exports.delegateTargetProperties = exports.delegateTargetMethod = exports.delegateTargetPrototypeMethod = exports.safeRequire = exports.safelyGet = exports.ASYNC_ROOT_CONTEXT = exports.DataSourceManager = exports.WebRouterCollector = exports.MidwayServerlessFunctionService = exports.MidwayWebRouterService = exports.MidwayMockService = exports.MidwayDecoratorService = exports.MidwayMiddlewareService = exports.MidwayLifeCycleService = exports.MidwayAspectService = exports.MidwayFrameworkService = exports.MidwayLoggerService = exports.MidwayInformationService = exports.MidwayEnvironmentService = exports.MidwayConfigService = exports.FunctionalConfiguration = exports.createConfiguration = exports.BaseFramework = exports.MidwayRequestContainer = void 0;
17
+ exports.FORMAT = exports.FileUtils = exports.PathFileUtil = exports.Types = exports.Utils = exports.sleep = exports.retryWith = exports.retryWithAsync = exports.extend = exports.isTypeScriptEnvironment = exports.wrapAsync = exports.wrapMiddleware = exports.pathMatching = exports.transformRequestObjectByType = exports.deprecatedOutput = exports.delegateTargetAllPrototypeMethod = exports.delegateTargetProperties = exports.delegateTargetMethod = exports.delegateTargetPrototypeMethod = exports.loadModule = exports.safeRequire = exports.safelyGet = exports.ASYNC_ROOT_CONTEXT = exports.DataSourceManager = exports.WebRouterCollector = exports.MidwayServerlessFunctionService = exports.MidwayWebRouterService = exports.MidwayMockService = exports.MidwayDecoratorService = exports.MidwayMiddlewareService = exports.MidwayLifeCycleService = exports.MidwayAspectService = exports.MidwayFrameworkService = exports.MidwayLoggerService = exports.MidwayInformationService = exports.MidwayEnvironmentService = exports.MidwayConfigService = exports.FunctionalConfiguration = exports.createConfiguration = exports.BaseFramework = exports.MidwayRequestContainer = void 0;
18
18
  __exportStar(require("./interface"), exports);
19
19
  __exportStar(require("./context/container"), exports);
20
20
  var requestContainer_1 = require("./context/requestContainer");
@@ -74,6 +74,7 @@ __exportStar(require("./decorator/constant"), exports);
74
74
  var util_1 = require("./util/");
75
75
  Object.defineProperty(exports, "safelyGet", { enumerable: true, get: function () { return util_1.safelyGet; } });
76
76
  Object.defineProperty(exports, "safeRequire", { enumerable: true, get: function () { return util_1.safeRequire; } });
77
+ Object.defineProperty(exports, "loadModule", { enumerable: true, get: function () { return util_1.loadModule; } });
77
78
  Object.defineProperty(exports, "delegateTargetPrototypeMethod", { enumerable: true, get: function () { return util_1.delegateTargetPrototypeMethod; } });
78
79
  Object.defineProperty(exports, "delegateTargetMethod", { enumerable: true, get: function () { return util_1.delegateTargetMethod; } });
79
80
  Object.defineProperty(exports, "delegateTargetProperties", { enumerable: true, get: function () { return util_1.delegateTargetProperties; } });
@@ -83,6 +84,7 @@ Object.defineProperty(exports, "transformRequestObjectByType", { enumerable: tru
83
84
  Object.defineProperty(exports, "pathMatching", { enumerable: true, get: function () { return util_1.pathMatching; } });
84
85
  Object.defineProperty(exports, "wrapMiddleware", { enumerable: true, get: function () { return util_1.wrapMiddleware; } });
85
86
  Object.defineProperty(exports, "wrapAsync", { enumerable: true, get: function () { return util_1.wrapAsync; } });
87
+ Object.defineProperty(exports, "isTypeScriptEnvironment", { enumerable: true, get: function () { return util_1.isTypeScriptEnvironment; } });
86
88
  var extend_1 = require("./util/extend");
87
89
  Object.defineProperty(exports, "extend", { enumerable: true, get: function () { return extend_1.extend; } });
88
90
  __exportStar(require("./util/webRouterParam"), exports);
@@ -569,10 +569,10 @@ export interface IMidwayContainer extends IObjectFactory, WithFn<IObjectLifeCycl
569
569
  parent: IMidwayContainer;
570
570
  identifierMapping: IIdentifierRelationShip;
571
571
  objectCreateEventTarget: EventEmitter;
572
- ready(): any;
572
+ ready(): void | Promise<void>;
573
573
  stop(): Promise<void>;
574
574
  registerObject(identifier: ObjectIdentifier, target: any): any;
575
- load(module?: any): any;
575
+ load(module: any | any[]): any;
576
576
  hasNamespace(namespace: string): boolean;
577
577
  getNamespaceList(): string[];
578
578
  hasDefinition(identifier: ObjectIdentifier): any;
@@ -599,7 +599,7 @@ export interface IMidwayContainer extends IObjectFactory, WithFn<IObjectLifeCycl
599
599
  */
600
600
  export type IApplicationContext = IMidwayContainer;
601
601
  export interface IFileDetector {
602
- run(container: IMidwayContainer, fileDetectorOptions?: Record<string, any>): any;
602
+ run(container: IMidwayContainer, fileDetectorOptions?: Record<string, any>): void | Promise<void>;
603
603
  setExtraDetectorOptions(detectorOptions: Record<string, any>): any;
604
604
  }
605
605
  export interface IConfigService {
@@ -619,8 +619,8 @@ export interface IInformationService {
619
619
  }
620
620
  export interface IEnvironmentService {
621
621
  getCurrentEnvironment(): string;
622
- setCurrentEnvironment(environment: string): any;
623
622
  isDevelopmentEnvironment(): boolean;
623
+ getModuleLoadType(): ModuleLoadType;
624
624
  }
625
625
  export declare enum MidwayProcessTypeEnum {
626
626
  APPLICATION = "APPLICATION",
@@ -799,6 +799,7 @@ export interface IMidwayBaseApplication<CTX extends IMidwayContext> {
799
799
  getNamespace(): string;
800
800
  }
801
801
  export type IMidwayApplication<T extends IMidwayContext = IMidwayContext, FrameworkApplication = unknown> = IMidwayBaseApplication<T> & FrameworkApplication;
802
+ export type ModuleLoadType = 'commonjs' | 'esm';
802
803
  export interface IMidwayBootstrapOptions {
803
804
  [customPropertyKey: string]: any;
804
805
  baseDir?: string;
@@ -810,8 +811,12 @@ export interface IMidwayBootstrapOptions {
810
811
  */
811
812
  configurationModule?: any | any[];
812
813
  imports?: any | any[];
813
- moduleDetector?: 'file' | IFileDetector | false;
814
+ moduleLoadType?: ModuleLoadType;
815
+ moduleDetector?: IFileDetector | false;
814
816
  logger?: boolean | ILogger;
817
+ /**
818
+ * @deprecated please set it from '@Configuration' decorator
819
+ */
815
820
  ignore?: string[];
816
821
  globalConfig?: Array<{
817
822
  [environmentName: string]: Record<string, any>;
@@ -1,8 +1,11 @@
1
- import { IEnvironmentService } from '../interface';
1
+ import { IEnvironmentService, ModuleLoadType } from '../interface';
2
2
  export declare class MidwayEnvironmentService implements IEnvironmentService {
3
3
  protected environment: string;
4
+ protected moduleLoadType: ModuleLoadType;
4
5
  getCurrentEnvironment(): string;
5
6
  setCurrentEnvironment(environment: string): void;
6
7
  isDevelopmentEnvironment(): boolean;
8
+ setModuleLoadType(moduleLoadType: ModuleLoadType): void;
9
+ getModuleLoadType(): ModuleLoadType;
7
10
  }
8
11
  //# sourceMappingURL=environmentService.d.ts.map
@@ -11,6 +11,9 @@ const interface_1 = require("../interface");
11
11
  const util_1 = require("../util");
12
12
  const decorator_1 = require("../decorator");
13
13
  let MidwayEnvironmentService = class MidwayEnvironmentService {
14
+ constructor() {
15
+ this.moduleLoadType = 'commonjs';
16
+ }
14
17
  getCurrentEnvironment() {
15
18
  if (!this.environment) {
16
19
  this.environment = (0, util_1.getCurrentEnvironment)();
@@ -23,6 +26,12 @@ let MidwayEnvironmentService = class MidwayEnvironmentService {
23
26
  isDevelopmentEnvironment() {
24
27
  return (0, util_1.isDevelopmentEnvironment)(this.environment);
25
28
  }
29
+ setModuleLoadType(moduleLoadType) {
30
+ this.moduleLoadType = moduleLoadType;
31
+ }
32
+ getModuleLoadType() {
33
+ return this.moduleLoadType;
34
+ }
26
35
  };
27
36
  MidwayEnvironmentService = __decorate([
28
37
  (0, decorator_1.Provide)(),
@@ -14,13 +14,23 @@ const interface_1 = require("../interface");
14
14
  const util_1 = require("../util");
15
15
  const path_1 = require("path");
16
16
  const decorator_1 = require("../decorator");
17
+ const fs_1 = require("fs");
17
18
  let MidwayInformationService = class MidwayInformationService {
18
19
  init() {
19
20
  if (this.baseDir) {
20
21
  if (!this.appDir) {
21
22
  this.appDir = (0, path_1.dirname)(this.baseDir);
22
23
  }
23
- this.pkg = (0, util_1.safeRequire)((0, path_1.join)(this.appDir, 'package.json')) || {};
24
+ const pkgPath = (0, path_1.join)(this.appDir, 'package.json');
25
+ if ((0, fs_1.existsSync)(pkgPath)) {
26
+ const content = (0, fs_1.readFileSync)(pkgPath, {
27
+ encoding: 'utf-8',
28
+ });
29
+ this.pkg = JSON.parse(content);
30
+ }
31
+ else {
32
+ this.pkg = {};
33
+ }
24
34
  }
25
35
  else {
26
36
  this.pkg = {};
@@ -203,7 +203,7 @@ class WebRouterCollector {
203
203
  if (this.baseDir) {
204
204
  const container = new container_1.MidwayContainer();
205
205
  (0, decorator_1.bindContainer)(container);
206
- container.setFileDetector(new fileDetector_1.DirectoryFileDetector({
206
+ container.setFileDetector(new fileDetector_1.CommonJSFileDetector({
207
207
  loadDir: this.baseDir,
208
208
  }));
209
209
  await container.ready();
package/dist/setup.d.ts CHANGED
@@ -5,9 +5,14 @@ import { MidwayContainer, IMidwayBootstrapOptions, IMidwayContainer } from './';
5
5
  */
6
6
  export declare function initializeGlobalApplicationContext(globalOptions: IMidwayBootstrapOptions): Promise<IMidwayContainer>;
7
7
  export declare function destroyGlobalApplicationContext(applicationContext: IMidwayContainer): Promise<void>;
8
+ /**
9
+ * prepare applicationContext
10
+ * @param globalOptions
11
+ */
12
+ export declare function prepareGlobalApplicationContext(globalOptions: IMidwayBootstrapOptions): Promise<IMidwayContainer | MidwayContainer>;
8
13
  /**
9
14
  * prepare applicationContext, it use in egg framework.
10
15
  * @param globalOptions
11
16
  */
12
- export declare function prepareGlobalApplicationContext(globalOptions: IMidwayBootstrapOptions): IMidwayContainer | MidwayContainer;
17
+ export declare function prepareGlobalApplicationContextSync(globalOptions: IMidwayBootstrapOptions): IMidwayContainer | MidwayContainer;
13
18
  //# sourceMappingURL=setup.d.ts.map
package/dist/setup.js CHANGED
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.prepareGlobalApplicationContext = exports.destroyGlobalApplicationContext = exports.initializeGlobalApplicationContext = void 0;
3
+ exports.prepareGlobalApplicationContextSync = exports.prepareGlobalApplicationContext = exports.destroyGlobalApplicationContext = exports.initializeGlobalApplicationContext = void 0;
4
4
  const _1 = require("./");
5
5
  const config_default_1 = require("./config/config.default");
6
6
  const decorator_1 = require("./decorator");
7
7
  const util = require("util");
8
- const path_1 = require("path");
9
8
  const slsFunctionService_1 = require("./service/slsFunctionService");
9
+ const path_1 = require("path");
10
10
  const debug = util.debuglog('midway:debug');
11
11
  let stepIdx = 1;
12
12
  function printStepDebugInfo(stepInfo) {
@@ -17,7 +17,7 @@ function printStepDebugInfo(stepInfo) {
17
17
  * @param globalOptions
18
18
  */
19
19
  async function initializeGlobalApplicationContext(globalOptions) {
20
- const applicationContext = prepareGlobalApplicationContext(globalOptions);
20
+ const applicationContext = await prepareGlobalApplicationContext(globalOptions);
21
21
  printStepDebugInfo('Init logger');
22
22
  // init logger
23
23
  const loggerService = await applicationContext.getAsync(_1.MidwayLoggerService, [
@@ -67,11 +67,119 @@ async function destroyGlobalApplicationContext(applicationContext) {
67
67
  global['MIDWAY_MAIN_FRAMEWORK'] = undefined;
68
68
  }
69
69
  exports.destroyGlobalApplicationContext = destroyGlobalApplicationContext;
70
+ /**
71
+ * prepare applicationContext
72
+ * @param globalOptions
73
+ */
74
+ async function prepareGlobalApplicationContext(globalOptions) {
75
+ var _a, _b, _c, _d, _e;
76
+ printStepDebugInfo('Ready to create applicationContext');
77
+ debug('[core]: start "initializeGlobalApplicationContext"');
78
+ debug(`[core]: bootstrap options = ${util.inspect(globalOptions)}`);
79
+ const appDir = (_a = globalOptions.appDir) !== null && _a !== void 0 ? _a : '';
80
+ const baseDir = (_b = globalOptions.baseDir) !== null && _b !== void 0 ? _b : '';
81
+ // new container
82
+ const applicationContext = (_c = globalOptions.applicationContext) !== null && _c !== void 0 ? _c : new _1.MidwayContainer();
83
+ // bind container to decoratorManager
84
+ debug('[core]: delegate module map from decoratorManager');
85
+ (0, decorator_1.bindContainer)(applicationContext);
86
+ global['MIDWAY_APPLICATION_CONTEXT'] = applicationContext;
87
+ // register baseDir and appDir
88
+ applicationContext.registerObject('baseDir', baseDir);
89
+ applicationContext.registerObject('appDir', appDir);
90
+ debug('[core]: set default file detector');
91
+ if (!globalOptions.moduleLoadType) {
92
+ globalOptions.moduleLoadType = 'commonjs';
93
+ }
94
+ // set module detector
95
+ if (globalOptions.moduleDetector !== false) {
96
+ debug('[core]: set module load type = %s', globalOptions.moduleLoadType);
97
+ // set default entry file
98
+ if (!globalOptions.imports) {
99
+ globalOptions.imports = [
100
+ await (0, _1.loadModule)((0, path_1.join)(baseDir, `configuration${(0, _1.isTypeScriptEnvironment)() ? '.ts' : '.js'}`), {
101
+ loadMode: globalOptions.moduleLoadType,
102
+ safeLoad: true,
103
+ }),
104
+ ];
105
+ }
106
+ if (globalOptions.moduleDetector === undefined) {
107
+ if (globalOptions.moduleLoadType === 'esm') {
108
+ applicationContext.setFileDetector(new _1.ESModuleFileDetector({
109
+ loadDir: baseDir,
110
+ ignore: (_d = globalOptions.ignore) !== null && _d !== void 0 ? _d : [],
111
+ }));
112
+ globalOptions.moduleLoadType = 'esm';
113
+ }
114
+ else {
115
+ applicationContext.setFileDetector(new _1.CommonJSFileDetector({
116
+ loadDir: baseDir,
117
+ ignore: (_e = globalOptions.ignore) !== null && _e !== void 0 ? _e : [],
118
+ }));
119
+ }
120
+ }
121
+ }
122
+ printStepDebugInfo('Binding inner service');
123
+ // bind inner service
124
+ applicationContext.bindClass(_1.MidwayEnvironmentService);
125
+ applicationContext.bindClass(_1.MidwayInformationService);
126
+ applicationContext.bindClass(_1.MidwayAspectService);
127
+ applicationContext.bindClass(_1.MidwayDecoratorService);
128
+ applicationContext.bindClass(_1.MidwayConfigService);
129
+ applicationContext.bindClass(_1.MidwayLoggerService);
130
+ applicationContext.bindClass(_1.MidwayApplicationManager);
131
+ applicationContext.bindClass(_1.MidwayFrameworkService);
132
+ applicationContext.bindClass(_1.MidwayMiddlewareService);
133
+ applicationContext.bindClass(_1.MidwayLifeCycleService);
134
+ applicationContext.bindClass(_1.MidwayMockService);
135
+ applicationContext.bindClass(_1.MidwayWebRouterService);
136
+ applicationContext.bindClass(slsFunctionService_1.MidwayServerlessFunctionService);
137
+ printStepDebugInfo('Binding preload module');
138
+ // bind preload module
139
+ if (globalOptions.preloadModules && globalOptions.preloadModules.length) {
140
+ for (const preloadModule of globalOptions.preloadModules) {
141
+ applicationContext.bindClass(preloadModule);
142
+ }
143
+ }
144
+ printStepDebugInfo('Init MidwayConfigService, MidwayAspectService and MidwayDecoratorService');
145
+ // init default config
146
+ const configService = applicationContext.get(_1.MidwayConfigService);
147
+ configService.add([
148
+ {
149
+ default: config_default_1.default,
150
+ },
151
+ ]);
152
+ // init aop support
153
+ applicationContext.get(_1.MidwayAspectService, [applicationContext]);
154
+ // init decorator service
155
+ applicationContext.get(_1.MidwayDecoratorService, [applicationContext]);
156
+ printStepDebugInfo('Load imports(component) and user code configuration module');
157
+ applicationContext.load([].concat(globalOptions.imports).concat(globalOptions.configurationModule));
158
+ printStepDebugInfo('Run applicationContext ready method');
159
+ // bind user code module
160
+ await applicationContext.ready();
161
+ if (globalOptions.globalConfig) {
162
+ if (Array.isArray(globalOptions.globalConfig)) {
163
+ configService.add(globalOptions.globalConfig);
164
+ }
165
+ else {
166
+ configService.addObject(globalOptions.globalConfig);
167
+ }
168
+ }
169
+ printStepDebugInfo('Load config file');
170
+ // merge config
171
+ configService.load();
172
+ debug('[core]: Current config = %j', configService.getConfiguration());
173
+ // middleware support
174
+ applicationContext.get(_1.MidwayMiddlewareService, [applicationContext]);
175
+ return applicationContext;
176
+ }
177
+ exports.prepareGlobalApplicationContext = prepareGlobalApplicationContext;
70
178
  /**
71
179
  * prepare applicationContext, it use in egg framework.
72
180
  * @param globalOptions
73
181
  */
74
- function prepareGlobalApplicationContext(globalOptions) {
182
+ function prepareGlobalApplicationContextSync(globalOptions) {
75
183
  var _a, _b, _c, _d;
76
184
  printStepDebugInfo('Ready to create applicationContext');
77
185
  debug('[core]: start "initializeGlobalApplicationContext"');
@@ -89,10 +197,8 @@ function prepareGlobalApplicationContext(globalOptions) {
89
197
  applicationContext.registerObject('appDir', appDir);
90
198
  printStepDebugInfo('Ready module detector');
91
199
  if (globalOptions.moduleDetector !== false) {
92
- if (globalOptions.moduleDetector === undefined ||
93
- globalOptions.moduleDetector === 'file') {
94
- applicationContext.setFileDetector(new _1.DirectoryFileDetector({
95
- loadDir: baseDir,
200
+ if (globalOptions.moduleDetector === undefined) {
201
+ applicationContext.setFileDetector(new _1.CommonJSFileDetector({
96
202
  ignore: (_d = globalOptions.ignore) !== null && _d !== void 0 ? _d : [],
97
203
  }));
98
204
  }
@@ -123,6 +229,9 @@ function prepareGlobalApplicationContext(globalOptions) {
123
229
  }
124
230
  }
125
231
  printStepDebugInfo('Init MidwayConfigService, MidwayAspectService and MidwayDecoratorService');
232
+ // init default environment
233
+ const environmentService = applicationContext.get(_1.MidwayEnvironmentService);
234
+ environmentService.setModuleLoadType(globalOptions.moduleLoadType);
126
235
  // init default config
127
236
  const configService = applicationContext.get(_1.MidwayConfigService);
128
237
  configService.add([
@@ -140,14 +249,7 @@ function prepareGlobalApplicationContext(globalOptions) {
140
249
  (0, _1.safeRequire)((0, path_1.join)(globalOptions.baseDir, 'configuration')),
141
250
  ];
142
251
  }
143
- for (const configurationModule of []
144
- .concat(globalOptions.imports)
145
- .concat(globalOptions.configurationModule)) {
146
- // load configuration and component
147
- if (configurationModule) {
148
- applicationContext.load(configurationModule);
149
- }
150
- }
252
+ applicationContext.load([].concat(globalOptions.imports).concat(globalOptions.configurationModule));
151
253
  printStepDebugInfo('Run applicationContext ready method');
152
254
  // bind user code module
153
255
  applicationContext.ready();
@@ -167,5 +269,5 @@ function prepareGlobalApplicationContext(globalOptions) {
167
269
  applicationContext.get(_1.MidwayMiddlewareService, [applicationContext]);
168
270
  return applicationContext;
169
271
  }
170
- exports.prepareGlobalApplicationContext = prepareGlobalApplicationContext;
272
+ exports.prepareGlobalApplicationContextSync = prepareGlobalApplicationContextSync;
171
273
  //# sourceMappingURL=setup.js.map
@@ -17,6 +17,17 @@ export declare const getCurrentEnvironment: () => string;
17
17
  * @since 2.0.0
18
18
  */
19
19
  export declare const safeRequire: (p: any, enabledCache?: boolean) => any;
20
+ /**
21
+ * load module, and it can be chosen commonjs or esm mode
22
+ * @param p
23
+ * @param options
24
+ * @since 3.12.0
25
+ */
26
+ export declare const loadModule: (p: string, options?: {
27
+ enableCache?: boolean;
28
+ loadMode?: 'commonjs' | 'esm';
29
+ safeLoad?: boolean;
30
+ }) => Promise<any>;
20
31
  /**
21
32
  * @example
22
33
  * safelyGet(['a','b'],{a: {b: 2}}) // => 2
@@ -111,6 +122,7 @@ export declare function getParamNames(func: any): string[];
111
122
  export declare function generateRandomId(): string;
112
123
  export declare function merge(target: any, src: any): any;
113
124
  export declare function toAsyncFunction<T extends (...args: any[]) => any>(method: T): (...args: Parameters<T>) => Promise<ReturnType<T>>;
125
+ export declare function isTypeScriptEnvironment(): boolean;
114
126
  export declare const Utils: {
115
127
  sleep: typeof sleep;
116
128
  getParamNames: typeof getParamNames;
@@ -121,5 +133,6 @@ export declare const Utils: {
121
133
  toAsyncFunction: typeof toAsyncFunction;
122
134
  safeStringify: typeof safeStringify;
123
135
  safeParse: typeof safeParse;
136
+ isTypeScriptEnvironment: typeof isTypeScriptEnvironment;
124
137
  };
125
138
  //# sourceMappingURL=index.d.ts.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Utils = exports.toAsyncFunction = exports.merge = exports.generateRandomId = exports.getParamNames = exports.sleep = exports.wrapAsync = exports.isIncludeProperty = exports.wrapMiddleware = exports.pathMatching = exports.toPathMatch = exports.transformRequestObjectByType = exports.deprecatedOutput = exports.getCurrentDateString = exports.delegateTargetProperties = exports.delegateTargetMethod = exports.delegateTargetAllPrototypeMethod = exports.delegateTargetPrototypeMethod = exports.joinURLPath = exports.getUserHome = exports.parsePrefix = exports.safelyGet = exports.safeRequire = exports.getCurrentEnvironment = exports.isDevelopmentEnvironment = void 0;
3
+ exports.Utils = exports.isTypeScriptEnvironment = exports.toAsyncFunction = exports.merge = exports.generateRandomId = exports.getParamNames = exports.sleep = exports.wrapAsync = exports.isIncludeProperty = exports.wrapMiddleware = exports.pathMatching = exports.toPathMatch = exports.transformRequestObjectByType = exports.deprecatedOutput = exports.getCurrentDateString = exports.delegateTargetProperties = exports.delegateTargetMethod = exports.delegateTargetAllPrototypeMethod = exports.delegateTargetPrototypeMethod = exports.joinURLPath = exports.getUserHome = exports.parsePrefix = exports.safelyGet = exports.loadModule = exports.safeRequire = exports.getCurrentEnvironment = exports.isDevelopmentEnvironment = void 0;
4
4
  const path_1 = require("path");
5
5
  const fs_1 = require("fs");
6
6
  const util_1 = require("util");
@@ -54,6 +54,55 @@ const safeRequire = (p, enabledCache = true) => {
54
54
  }
55
55
  };
56
56
  exports.safeRequire = safeRequire;
57
+ /**
58
+ * load module, and it can be chosen commonjs or esm mode
59
+ * @param p
60
+ * @param options
61
+ * @since 3.12.0
62
+ */
63
+ const loadModule = async (p, options = {}) => {
64
+ var _a, _b, _c;
65
+ options.enableCache = (_a = options.enableCache) !== null && _a !== void 0 ? _a : true;
66
+ options.safeLoad = (_b = options.safeLoad) !== null && _b !== void 0 ? _b : false;
67
+ options.loadMode = (_c = options.loadMode) !== null && _c !== void 0 ? _c : 'commonjs';
68
+ if (p.startsWith(`.${path_1.sep}`) || p.startsWith(`..${path_1.sep}`)) {
69
+ p = (0, path_1.resolve)((0, path_1.dirname)(module.parent.filename), p);
70
+ }
71
+ try {
72
+ if (options.enableCache) {
73
+ if (options.loadMode === 'commonjs') {
74
+ return require(p);
75
+ }
76
+ else {
77
+ // if json file, import need add options
78
+ if (p.endsWith('.json')) {
79
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
80
+ // @ts-ignore
81
+ return (await import(p, { assert: { type: 'json' } })).default;
82
+ }
83
+ else {
84
+ return await import(p);
85
+ }
86
+ }
87
+ }
88
+ else {
89
+ const content = (0, fs_1.readFileSync)(p, {
90
+ encoding: 'utf-8',
91
+ });
92
+ return JSON.parse(content);
93
+ }
94
+ }
95
+ catch (err) {
96
+ if (!options.safeLoad) {
97
+ throw err;
98
+ }
99
+ else {
100
+ debug(`[core]: SafeLoadModule Warning\n\n${err.message}\n`);
101
+ return undefined;
102
+ }
103
+ }
104
+ };
105
+ exports.loadModule = loadModule;
57
106
  /**
58
107
  * @example
59
108
  * safelyGet(['a','b'],{a: {b: 2}}) // => 2
@@ -426,6 +475,15 @@ function toAsyncFunction(method) {
426
475
  }
427
476
  }
428
477
  exports.toAsyncFunction = toAsyncFunction;
478
+ function isTypeScriptEnvironment() {
479
+ const TS_MODE_PROCESS_FLAG = process.env.MIDWAY_TS_MODE;
480
+ if ('false' === TS_MODE_PROCESS_FLAG) {
481
+ return false;
482
+ }
483
+ // eslint-disable-next-line node/no-deprecated-api
484
+ return TS_MODE_PROCESS_FLAG === 'true' || !!require.extensions['.ts'];
485
+ }
486
+ exports.isTypeScriptEnvironment = isTypeScriptEnvironment;
429
487
  exports.Utils = {
430
488
  sleep,
431
489
  getParamNames,
@@ -436,5 +494,6 @@ exports.Utils = {
436
494
  toAsyncFunction,
437
495
  safeStringify: flatted_1.safeStringify,
438
496
  safeParse: flatted_1.safeParse,
497
+ isTypeScriptEnvironment,
439
498
  };
440
499
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/core",
3
- "version": "3.11.15",
3
+ "version": "3.12.0-beta.2",
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": "a4054247f3b9f4fc8ba51684c002606d849e0bd3"
45
+ "gitHead": "a603d2348d6141f8f723901498f03a162a037708"
46
46
  }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2013 - Now midwayjs
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.