@fastcar/core 0.2.64 → 0.3.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.
Files changed (142) hide show
  1. package/README.md +5 -2
  2. package/annotation.d.ts +3 -0
  3. package/index.d.ts +57 -50
  4. package/package.json +4 -4
  5. package/src/FastCarApplication.ts +184 -123
  6. package/src/annotation/Application.ts +3 -1
  7. package/src/annotation/bind/AddInjectionService.ts +17 -0
  8. package/src/annotation/bind/AddRequireModule.ts +1 -1
  9. package/src/annotation/bind/AliasInjection.ts +8 -15
  10. package/src/annotation/bind/Autowired.ts +1 -1
  11. package/src/annotation/bind/CallDependency.ts +7 -17
  12. package/src/annotation/bind/DemandInjection.ts +16 -0
  13. package/src/annotation/stereotype/Log.ts +13 -9
  14. package/src/annotation/stereotype/Value.ts +5 -0
  15. package/src/annotation.ts +2 -0
  16. package/src/constant/FastCarMetaData.ts +2 -0
  17. package/src/model/WinstonLogger.ts +1 -1
  18. package/src/type/ClassConstructor.ts +5 -0
  19. package/src/type/ComponentDesc.ts +13 -0
  20. package/src/type/FileHotterDesc.ts +6 -0
  21. package/src/utils/ClassLoader.ts +2 -1
  22. package/target/FastCarApplication.js +764 -708
  23. package/target/annotation/Application.js +46 -45
  24. package/target/annotation/ExceptionMonitor.js +16 -16
  25. package/target/annotation/bind/AddInjectionService.js +16 -0
  26. package/target/annotation/bind/AddRequireModule.js +21 -21
  27. package/target/annotation/bind/AliasInjection.js +19 -23
  28. package/target/annotation/bind/Autowired.js +13 -13
  29. package/target/annotation/bind/CallDependency.js +16 -23
  30. package/target/annotation/bind/DemandInjection.js +15 -0
  31. package/target/annotation/data/DBType.js +11 -11
  32. package/target/annotation/data/DS.js +54 -54
  33. package/target/annotation/data/DSIndex.js +9 -9
  34. package/target/annotation/data/Entity.js +10 -10
  35. package/target/annotation/data/Field.js +18 -18
  36. package/target/annotation/data/PrimaryKey.js +9 -9
  37. package/target/annotation/data/SqlSession.js +9 -9
  38. package/target/annotation/data/Table.js +35 -35
  39. package/target/annotation/data/Transactional.js +52 -52
  40. package/target/annotation/env/ApplicationSetting.js +25 -25
  41. package/target/annotation/env/BaseFilePath.js +14 -14
  42. package/target/annotation/env/BaseName.js +9 -9
  43. package/target/annotation/env/BasePath.js +14 -14
  44. package/target/annotation/env/ENV.js +10 -10
  45. package/target/annotation/env/ResourcePath.js +9 -9
  46. package/target/annotation/lifeCycle/AddLifeCycleItem.js +17 -18
  47. package/target/annotation/lifeCycle/ApplicationDestory.js +15 -15
  48. package/target/annotation/lifeCycle/ApplicationInit.js +15 -15
  49. package/target/annotation/lifeCycle/ApplicationRunner.js +7 -7
  50. package/target/annotation/lifeCycle/ApplicationStart.js +24 -24
  51. package/target/annotation/lifeCycle/ApplicationStop.js +20 -20
  52. package/target/annotation/property/Deprecate.js +19 -19
  53. package/target/annotation/property/NotImplemented.js +8 -8
  54. package/target/annotation/property/Override.js +7 -7
  55. package/target/annotation/property/Readonly.js +16 -16
  56. package/target/annotation/scan/ComponentInjection.js +21 -21
  57. package/target/annotation/scan/ComponentScan.js +9 -9
  58. package/target/annotation/scan/ComponentScanExclusion.js +25 -25
  59. package/target/annotation/scan/ComponentScanMust.js +25 -25
  60. package/target/annotation/scan/Hotter.js +8 -8
  61. package/target/annotation/stereotype/BeanName.js +11 -11
  62. package/target/annotation/stereotype/Component.js +8 -8
  63. package/target/annotation/stereotype/Configure.js +14 -14
  64. package/target/annotation/stereotype/Controller.js +9 -9
  65. package/target/annotation/stereotype/Injection.js +12 -12
  66. package/target/annotation/stereotype/Log.js +19 -17
  67. package/target/annotation/stereotype/Repository.js +9 -9
  68. package/target/annotation/stereotype/Service.js +9 -9
  69. package/target/annotation/stereotype/Value.js +5 -0
  70. package/target/annotation/valid/AddChildValid.js +56 -56
  71. package/target/annotation/valid/CustomType.js +11 -11
  72. package/target/annotation/valid/DefaultVal.js +10 -10
  73. package/target/annotation/valid/NotNull.js +8 -8
  74. package/target/annotation/valid/Rule.js +99 -100
  75. package/target/annotation/valid/Size.js +10 -10
  76. package/target/annotation/valid/Type.js +10 -10
  77. package/target/annotation/valid/ValidCustom.js +17 -17
  78. package/target/annotation/valid/ValidForm.js +133 -133
  79. package/target/annotation.js +110 -108
  80. package/target/config/ApplicationConfig.js +2 -2
  81. package/target/config/SysConfig.js +19 -19
  82. package/target/constant/AppStatusEnum.js +9 -9
  83. package/target/constant/BootPriority.js +11 -11
  84. package/target/constant/CommonConstant.js +18 -18
  85. package/target/constant/ComponentKind.js +11 -11
  86. package/target/constant/DataTypes.js +19 -19
  87. package/target/constant/FastCarMetaData.js +33 -31
  88. package/target/constant/LifeCycleModule.js +9 -9
  89. package/target/db.js +49 -49
  90. package/target/index.js +21 -21
  91. package/target/interface/ApplicationHook.js +2 -2
  92. package/target/interface/ApplicationInterface.js +2 -2
  93. package/target/interface/ApplicationRunnerService.js +2 -2
  94. package/target/interface/DataSourceManager.js +2 -2
  95. package/target/interface/Logger.js +5 -5
  96. package/target/model/BaseMapper.js +103 -98
  97. package/target/model/DataMap.js +87 -87
  98. package/target/model/FormRuleModel.js +2 -2
  99. package/target/model/ValidError.js +5 -5
  100. package/target/model/WinstonLogger.js +98 -96
  101. package/target/type/ClassConstructor.js +2 -0
  102. package/target/type/ComponentDesc.js +9 -2
  103. package/target/type/DesignMeta.js +15 -15
  104. package/target/type/FileHotterDesc.js +9 -2
  105. package/target/type/MapperType.js +2 -2
  106. package/target/type/ProcessType.js +2 -2
  107. package/target/type/SqlError.js +5 -5
  108. package/target/type/WinstonLoggerType.js +9 -9
  109. package/target/utils/ClassLoader.js +66 -65
  110. package/target/utils/ClassUtils.js +35 -35
  111. package/target/utils/CryptoUtil.js +86 -86
  112. package/target/utils/DataFormat.js +88 -88
  113. package/target/utils/DateUtil.js +71 -71
  114. package/target/utils/FileUtil.js +153 -153
  115. package/target/utils/FormatStr.js +14 -14
  116. package/target/utils/IPUtils.js +34 -34
  117. package/target/utils/Id.js +8 -9
  118. package/target/utils/Mix.js +62 -62
  119. package/target/utils/ReflectUtil.js +22 -22
  120. package/target/utils/TypeUtil.js +53 -53
  121. package/target/utils/ValidationUtil.js +123 -123
  122. package/target/utils.js +25 -25
  123. package/test/example/logs/fastcar-server.app.log +0 -0
  124. package/test/example/logs/fastcar-server.sys.log +10 -0
  125. package/test/example/logs/fastcar-server.sys1.log +8 -0
  126. package/test/example/logs/fastcar-server.sys2.log +11 -0
  127. package/test/example/logs/fastcar-server.sys3.log +0 -0
  128. package/test/example/logs/other-server.app.log +0 -0
  129. package/test/example/logs/other-server.sys.log +5 -0
  130. package/test/example/logs/sys.log +0 -0
  131. package/test/example/logs/sys1.log +0 -0
  132. package/test/example/resource/application.yml +2 -0
  133. package/test/example/resource/hello.yml +1 -1
  134. package/test/example/simple/app-test.ts +2 -1
  135. package/test/example/simple/app.ts +16 -16
  136. package/test/example/simple/service/CallService.ts +2 -0
  137. package/test/example/simple/service/HelloService.ts +2 -0
  138. package/test/unit/sys2.log +6 -0
  139. package/test/unit/sys3.log +6 -0
  140. package/test/unit/sys4.log +6 -0
  141. package/test/unit/sys5.log +6 -0
  142. package/test/unit/sys6.log +6 -0
@@ -1,96 +1,98 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const winston = require("winston");
4
- const WinstonLoggerType_1 = require("../type/WinstonLoggerType");
5
- const path = require("path");
6
- const utils_1 = require("../utils");
7
- const util = require("util");
8
- const SPLAT = Symbol.for("splat");
9
- class WinstonLogger {
10
- constructor(config) {
11
- this.config = config;
12
- this.categoryMap = new Map();
13
- }
14
- //控制台着色
15
- colorize(str, level) {
16
- let colorStyle = Reflect.get(WinstonLoggerType_1.ColorLevelType, level);
17
- if (!colorStyle) {
18
- return str;
19
- }
20
- return `\x1B[${colorStyle[0]}m ${str} \x1B[${colorStyle[1]}m`;
21
- }
22
- //数据着色为白色
23
- colorizeData(data) {
24
- let msg = utils_1.ValidationUtil.isObject(data) ? JSON.stringify(data) : data;
25
- return `\x1B[37m ${msg} \x1B[39m`;
26
- }
27
- setConfig(config) {
28
- this.config = config;
29
- }
30
- hasLogger(category) {
31
- return winston.loggers.has(category);
32
- }
33
- getLogger(category) {
34
- return this.categoryMap.get(category);
35
- }
36
- addLogger(category) {
37
- if (this.categoryMap.has(category)) {
38
- winston.loggers.close(category);
39
- }
40
- let newLogger = winston.loggers.add(category, {
41
- format: winston.format.combine(winston.format.label({ label: category }), winston.format.printf((info) => {
42
- //debug模式等级时仅为控制台输出
43
- let level = info.level.toUpperCase();
44
- let timestamp = utils_1.DateUtil.toDateTimeMS();
45
- let content = {
46
- timestamp,
47
- level,
48
- label: info.label,
49
- message: info.message,
50
- };
51
- if (Reflect.has(info, SPLAT)) {
52
- let splat = Reflect.get(info, SPLAT);
53
- Reflect.set(content, "splat", typeof splat == "string" ? splat : JSON.stringify(splat));
54
- }
55
- if (info.stack) {
56
- Reflect.set(content, "stack", info.stack);
57
- }
58
- Reflect.set(info, "timestamp", content.timestamp);
59
- //新增打印控制台
60
- if (this.config.printConsole) {
61
- let text = this.colorize(util.format("[%s] [%s] %s - ", timestamp, level, info.label), info.level);
62
- text += this.colorizeData(content.message);
63
- if (Reflect.has(info, SPLAT)) {
64
- let splatMsg = Reflect.get(info, SPLAT);
65
- splatMsg.forEach((item) => {
66
- text += " " + this.colorizeData(item);
67
- });
68
- }
69
- if (info.stack) {
70
- text += this.colorizeData(`\nstatck: ${info.stack}`);
71
- }
72
- let fn = console.info;
73
- if (Reflect.has(console, info.level)) {
74
- fn = Reflect.get(console, info.level);
75
- }
76
- Reflect.apply(fn, console, [text]);
77
- }
78
- return util.format("%j", content);
79
- })),
80
- transports: [
81
- new winston.transports.File({
82
- level: this.config.fileLevel,
83
- filename: path.join(this.config.rootPath, `${category}.log`),
84
- maxsize: this.config.maxsize,
85
- maxFiles: this.config.maxFiles,
86
- }),
87
- ],
88
- });
89
- this.categoryMap.set(category, newLogger);
90
- return newLogger;
91
- }
92
- getLoggerList() {
93
- return [...this.categoryMap.values()];
94
- }
95
- }
96
- exports.default = WinstonLogger;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const winston = require("winston");
4
+ const WinstonLoggerType_1 = require("../type/WinstonLoggerType");
5
+ const path = require("path");
6
+ const utils_1 = require("../utils");
7
+ const util = require("util");
8
+ const SPLAT = Symbol.for("splat");
9
+ class WinstonLogger {
10
+ config;
11
+ categoryMap;
12
+ constructor(config) {
13
+ this.config = config;
14
+ this.categoryMap = new Map();
15
+ }
16
+ //控制台着色
17
+ colorize(str, level) {
18
+ let colorStyle = Reflect.get(WinstonLoggerType_1.ColorLevelType, level);
19
+ if (!colorStyle) {
20
+ return str;
21
+ }
22
+ return `\x1B[${colorStyle[0]}m ${str} \x1B[${colorStyle[1]}m`;
23
+ }
24
+ //数据着色为白色
25
+ colorizeData(data) {
26
+ let msg = utils_1.ValidationUtil.isObject(data) ? JSON.stringify(data) : data;
27
+ return `\x1B[37m ${msg} \x1B[39m`;
28
+ }
29
+ setConfig(config) {
30
+ this.config = config;
31
+ }
32
+ hasLogger(category) {
33
+ return winston.loggers.has(category);
34
+ }
35
+ getLogger(category) {
36
+ return this.categoryMap.get(category);
37
+ }
38
+ addLogger(category) {
39
+ if (this.categoryMap.has(category)) {
40
+ winston.loggers.close(category);
41
+ }
42
+ let newLogger = winston.loggers.add(category, {
43
+ format: winston.format.combine(winston.format.label({ label: category }), winston.format.printf((info) => {
44
+ //debug模式等级时仅为控制台输出
45
+ let level = info.level.toUpperCase();
46
+ let timestamp = utils_1.DateUtil.toDateTimeMS();
47
+ let content = {
48
+ timestamp,
49
+ level,
50
+ label: info.label,
51
+ message: info.message,
52
+ };
53
+ if (Reflect.has(info, SPLAT)) {
54
+ let splat = Reflect.get(info, SPLAT);
55
+ Reflect.set(content, "splat", typeof splat == "string" ? splat : JSON.stringify(splat));
56
+ }
57
+ if (info.stack) {
58
+ Reflect.set(content, "stack", info.stack);
59
+ }
60
+ Reflect.set(info, "timestamp", content.timestamp);
61
+ //新增打印控制台
62
+ if (this.config.printConsole) {
63
+ let text = this.colorize(util.format("[%s] [%s] %s - ", timestamp, level, info.label), info.level);
64
+ text += this.colorizeData(content.message);
65
+ if (Reflect.has(info, SPLAT)) {
66
+ let splatMsg = Reflect.get(info, SPLAT);
67
+ splatMsg.forEach((item) => {
68
+ text += " " + this.colorizeData(item);
69
+ });
70
+ }
71
+ if (info.stack) {
72
+ text += this.colorizeData(`\nstatck: ${info.stack}`);
73
+ }
74
+ let fn = console.info;
75
+ if (Reflect.has(console, info.level)) {
76
+ fn = Reflect.get(console, info.level);
77
+ }
78
+ Reflect.apply(fn, console, [text]);
79
+ }
80
+ return util.format("%j", content);
81
+ })),
82
+ transports: [
83
+ new winston.transports.File({
84
+ level: this.config.fileLevel,
85
+ filename: path.join(this.config.rootPath, `${category}.log`),
86
+ maxsize: this.config.maxsize,
87
+ maxFiles: this.config.maxFiles,
88
+ }),
89
+ ],
90
+ });
91
+ this.categoryMap.set(category, newLogger);
92
+ return newLogger;
93
+ }
94
+ getLoggerList() {
95
+ return [...this.categoryMap.values()];
96
+ }
97
+ }
98
+ exports.default = WinstonLogger;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InjectionType = void 0;
4
+ //注入的类型
5
+ var InjectionType;
6
+ (function (InjectionType) {
7
+ InjectionType["PROPERTYKEY"] = "PROPERTYKEY";
8
+ InjectionType["ALIAS"] = "ALIAS";
9
+ })(InjectionType || (exports.InjectionType = InjectionType = {}));
@@ -1,15 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DesignMeta = void 0;
4
- var DesignMeta;
5
- (function (DesignMeta) {
6
- DesignMeta["table"] = "db:table";
7
- DesignMeta["field"] = "db:field";
8
- DesignMeta["fieldMap"] = "db:fieldMap";
9
- DesignMeta["dbType"] = "db:dbType";
10
- DesignMeta["primaryKey"] = "db:primaryKey";
11
- DesignMeta["entity"] = "db:entity";
12
- DesignMeta["mapping"] = "db:mapping";
13
- DesignMeta["dbFields"] = "db:fields";
14
- DesignMeta["sqlSession"] = "SqlSession";
15
- })(DesignMeta = exports.DesignMeta || (exports.DesignMeta = {}));
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DesignMeta = void 0;
4
+ var DesignMeta;
5
+ (function (DesignMeta) {
6
+ DesignMeta["table"] = "db:table";
7
+ DesignMeta["field"] = "db:field";
8
+ DesignMeta["fieldMap"] = "db:fieldMap";
9
+ DesignMeta["dbType"] = "db:dbType";
10
+ DesignMeta["primaryKey"] = "db:primaryKey";
11
+ DesignMeta["entity"] = "db:entity";
12
+ DesignMeta["mapping"] = "db:mapping";
13
+ DesignMeta["dbFields"] = "db:fields";
14
+ DesignMeta["sqlSession"] = "SqlSession";
15
+ })(DesignMeta || (exports.DesignMeta = DesignMeta = {}));
@@ -1,2 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HotReloadEnum = void 0;
4
+ var HotReloadEnum;
5
+ (function (HotReloadEnum) {
6
+ HotReloadEnum["reload"] = "reload";
7
+ HotReloadEnum["sysReload"] = "sysReload";
8
+ HotReloadEnum["configReload"] = "configReload";
9
+ })(HotReloadEnum || (exports.HotReloadEnum = HotReloadEnum = {}));
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- class SqlError extends Error {
4
- }
5
- exports.default = SqlError;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class SqlError extends Error {
4
+ }
5
+ exports.default = SqlError;
@@ -1,9 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ColorLevelType = void 0;
4
- exports.ColorLevelType = {
5
- info: [32, 39],
6
- debug: [36, 39],
7
- warn: [33, 39],
8
- error: [91, 39], //red
9
- };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ColorLevelType = void 0;
4
+ exports.ColorLevelType = {
5
+ info: [32, 39], //green
6
+ debug: [36, 39], // cyan
7
+ warn: [33, 39], //yellow
8
+ error: [91, 39], //red
9
+ };
@@ -1,65 +1,66 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const TypeUtil_1 = require("./TypeUtil");
4
- const FileUtil_1 = require("./FileUtil");
5
- const fs = require("fs");
6
- const path = require("path");
7
- class ClassLoader {
8
- /***
9
- * @version 1.0 加载模块
10
- * @version 1.1 新增是否强制重载模块
11
- *
12
- */
13
- static loadModule(filePath, force = false) {
14
- //校验后缀名是否为js或者ts
15
- if (!TypeUtil_1.default.isTSORJS(filePath)) {
16
- return null;
17
- }
18
- //避免重复加载或者想要重新进行挂载
19
- if (Reflect.has(require.cache, filePath)) {
20
- if (force) {
21
- Reflect.deleteProperty(require.cache, filePath);
22
- }
23
- }
24
- //可能不止一个方法
25
- const modulesMap = new Map();
26
- //进行方法加载
27
- let moduleClass = require(filePath);
28
- let keys = Object.keys(moduleClass);
29
- let fileName = FileUtil_1.default.getFileName(filePath);
30
- keys.forEach((key) => {
31
- let instance = moduleClass[key];
32
- if (TypeUtil_1.default.isFunction(instance)) {
33
- modulesMap.set(instance.name, instance);
34
- return;
35
- }
36
- if (TypeUtil_1.default.isObject(instance)) {
37
- modulesMap.set(fileName, instance);
38
- }
39
- });
40
- return modulesMap;
41
- }
42
- /**
43
- * @version 1.0 监听某个文件或者文件夹
44
- */
45
- static watchServices(fp, context, eventName = "reload") {
46
- if (typeof context.emit != "function") {
47
- return false;
48
- }
49
- const currStats = fs.statSync(fp);
50
- let fileFlag = currStats.isFile();
51
- //添加热更方法
52
- fs.watch(fp, function (event, filename) {
53
- if (event === "change") {
54
- if (!fileFlag && filename) {
55
- context.emit(eventName, path.join(fp, filename));
56
- }
57
- else {
58
- context.emit(eventName, fp);
59
- }
60
- }
61
- });
62
- return true;
63
- }
64
- }
65
- exports.default = ClassLoader;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const TypeUtil_1 = require("./TypeUtil");
4
+ const FileUtil_1 = require("./FileUtil");
5
+ const fs = require("fs");
6
+ const path = require("path");
7
+ const FileHotterDesc_1 = require("../type/FileHotterDesc");
8
+ class ClassLoader {
9
+ /***
10
+ * @version 1.0 加载模块
11
+ * @version 1.1 新增是否强制重载模块
12
+ *
13
+ */
14
+ static loadModule(filePath, force = false) {
15
+ //校验后缀名是否为js或者ts
16
+ if (!TypeUtil_1.default.isTSORJS(filePath)) {
17
+ return null;
18
+ }
19
+ //避免重复加载或者想要重新进行挂载
20
+ if (Reflect.has(require.cache, filePath)) {
21
+ if (force) {
22
+ Reflect.deleteProperty(require.cache, filePath);
23
+ }
24
+ }
25
+ //可能不止一个方法
26
+ const modulesMap = new Map();
27
+ //进行方法加载
28
+ let moduleClass = require(filePath);
29
+ let keys = Object.keys(moduleClass);
30
+ let fileName = FileUtil_1.default.getFileName(filePath);
31
+ keys.forEach((key) => {
32
+ let instance = moduleClass[key];
33
+ if (TypeUtil_1.default.isFunction(instance)) {
34
+ modulesMap.set(instance.name, instance);
35
+ return;
36
+ }
37
+ if (TypeUtil_1.default.isObject(instance)) {
38
+ modulesMap.set(fileName, instance);
39
+ }
40
+ });
41
+ return modulesMap;
42
+ }
43
+ /**
44
+ * @version 1.0 监听某个文件或者文件夹
45
+ */
46
+ static watchServices(fp, context, eventName = FileHotterDesc_1.HotReloadEnum.reload) {
47
+ if (typeof context.emit != "function") {
48
+ return false;
49
+ }
50
+ const currStats = fs.statSync(fp);
51
+ let fileFlag = currStats.isFile();
52
+ //添加热更方法
53
+ fs.watch(fp, function (event, filename) {
54
+ if (event === "change") {
55
+ if (!fileFlag && filename) {
56
+ context.emit(eventName, path.join(fp, filename));
57
+ }
58
+ else {
59
+ context.emit(eventName, fp);
60
+ }
61
+ }
62
+ });
63
+ return true;
64
+ }
65
+ }
66
+ exports.default = ClassLoader;
@@ -1,35 +1,35 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- class ClassUtils {
4
- //获取一个类所有的proto属性 采用递归的形式
5
- static getProtoType(t) {
6
- if (!t?.prototype) {
7
- return [];
8
- }
9
- let keys = Reflect.ownKeys(t?.prototype).map((item) => {
10
- return item;
11
- });
12
- let parentObj = Reflect.getPrototypeOf(t);
13
- if (!parentObj || !Reflect.has(parentObj, "prototype")) {
14
- return keys;
15
- }
16
- let parentKeys = ClassUtils.getProtoType(parentObj);
17
- let s = new Set([...keys, ...parentKeys]);
18
- return [...s];
19
- }
20
- static getProtoDesc(t, key) {
21
- if (!t?.prototype) {
22
- return null;
23
- }
24
- let desc = Object.getOwnPropertyDescriptor(t.prototype, key);
25
- if (!!desc) {
26
- return desc;
27
- }
28
- let parentObj = Reflect.getPrototypeOf(t);
29
- if (!parentObj || !Reflect.has(parentObj, "prototype")) {
30
- return null;
31
- }
32
- return ClassUtils.getProtoDesc(parentObj, key);
33
- }
34
- }
35
- exports.default = ClassUtils;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class ClassUtils {
4
+ //获取一个类所有的proto属性 采用递归的形式
5
+ static getProtoType(t) {
6
+ if (!t?.prototype) {
7
+ return [];
8
+ }
9
+ let keys = Reflect.ownKeys(t?.prototype).map((item) => {
10
+ return item;
11
+ });
12
+ let parentObj = Reflect.getPrototypeOf(t);
13
+ if (!parentObj || !Reflect.has(parentObj, "prototype")) {
14
+ return keys;
15
+ }
16
+ let parentKeys = ClassUtils.getProtoType(parentObj);
17
+ let s = new Set([...keys, ...parentKeys]);
18
+ return [...s];
19
+ }
20
+ static getProtoDesc(t, key) {
21
+ if (!t?.prototype) {
22
+ return null;
23
+ }
24
+ let desc = Object.getOwnPropertyDescriptor(t.prototype, key);
25
+ if (!!desc) {
26
+ return desc;
27
+ }
28
+ let parentObj = Reflect.getPrototypeOf(t);
29
+ if (!parentObj || !Reflect.has(parentObj, "prototype")) {
30
+ return null;
31
+ }
32
+ return ClassUtils.getProtoDesc(parentObj, key);
33
+ }
34
+ }
35
+ exports.default = ClassUtils;