@fastcar/core 0.3.3 → 0.3.5
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.
- package/README.md +2 -0
- package/annotation.d.ts +1 -0
- package/package.json +2 -2
- package/src/FastCarApplication.ts +4 -0
- package/src/annotation/Application.ts +2 -2
- package/src/annotation/bind/DemandInjection.ts +2 -2
- package/src/annotation/scan/HotterCallBack.ts +13 -0
- package/src/annotation.ts +2 -0
- package/src/constant/FastCarMetaData.ts +1 -0
- package/target/FastCarApplication.js +4 -0
- package/target/annotation/Application.js +2 -2
- package/target/annotation/bind/DemandInjection.js +2 -2
- package/target/annotation/scan/HotterCallBack.js +15 -0
- package/target/annotation.js +4 -2
- package/target/constant/FastCarMetaData.js +1 -0
- package/test/example/logs/fastcar-server.logger.log +3 -0
- package/test/example/logs/fastcar-server.sys5.log +13 -0
- package/test/example/logs/fastcar-server.sys6.log +9 -0
- package/test/example/logs/fastcar-server.sys7.log +13 -0
- package/test/example/logs/fastcar-server.sys8.log +11 -0
- package/test/example/logs/fastcar-server.sys9.log +0 -0
- package/test/example/logs/sys.log +0 -0
- package/test/example/logs/sys1.log +0 -0
package/README.md
CHANGED
package/annotation.d.ts
CHANGED
|
@@ -43,6 +43,7 @@ export function ComponentScanExclusion(...names: string[]): Ret;
|
|
|
43
43
|
export function ComponentInjection(target: any, ...names: string[]): void;
|
|
44
44
|
export function ComponentScanMust(...names: string[]): Ret;
|
|
45
45
|
export function Hotter(target: any): void;
|
|
46
|
+
export function HotterCallBack(fn: string): Ret;
|
|
46
47
|
|
|
47
48
|
/***
|
|
48
49
|
* 用于描述不同组件的作用类
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fastcar/core",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"homepage": "https://github.com/williamDazhangyu/fast-car",
|
|
5
5
|
"main": "target/index.js",
|
|
6
6
|
"author": "william_zhong",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@fastcar/core"
|
|
30
30
|
],
|
|
31
31
|
"engines": {
|
|
32
|
-
"node": ">=
|
|
32
|
+
"node": ">=18"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"reflect-metadata": "^0.2.2",
|
|
@@ -392,6 +392,10 @@ class FastCarApplication extends Events {
|
|
|
392
392
|
let beforeInstance = this.getBean(beforeKey);
|
|
393
393
|
if (!!beforeInstance) {
|
|
394
394
|
MixTool.assign(beforeInstance, classZ);
|
|
395
|
+
let cb = Reflect.getMetadata(FastCarMetaData.HotterCallback, classZ.prototype);
|
|
396
|
+
if (cb && Reflect.has(beforeInstance, cb)) {
|
|
397
|
+
Reflect.apply(Reflect.get(beforeInstance, cb), beforeInstance, []);
|
|
398
|
+
}
|
|
395
399
|
return;
|
|
396
400
|
}
|
|
397
401
|
}
|
|
@@ -5,11 +5,11 @@ import TypeUtil from "../utils/TypeUtil";
|
|
|
5
5
|
//基础服务的应用
|
|
6
6
|
export default function Application(target: any) {
|
|
7
7
|
return new Proxy(target, {
|
|
8
|
-
construct: (target: ClassConstructor<Object>, args: any) => {
|
|
8
|
+
construct: (target: ClassConstructor<Object>, args: any, newTarget?: any) => {
|
|
9
9
|
const FastCarApplication = require("../FastCarApplication").default;
|
|
10
10
|
|
|
11
11
|
let app = new FastCarApplication();
|
|
12
|
-
let appProxy =
|
|
12
|
+
let appProxy = Reflect.construct(target, args, newTarget);
|
|
13
13
|
Reflect.set(appProxy, "app", app);
|
|
14
14
|
|
|
15
15
|
let keys = ClassUtils.getProtoType(target);
|
|
@@ -4,8 +4,8 @@ import { ClassConstructor } from "../../type/ClassConstructor";
|
|
|
4
4
|
|
|
5
5
|
export default function DemandInjection(Target: ClassConstructor<any>) {
|
|
6
6
|
return new Proxy(Target, {
|
|
7
|
-
construct: (Target: ClassConstructor<any>, args: any) => {
|
|
8
|
-
let c =
|
|
7
|
+
construct: (Target: ClassConstructor<any>, args: any, newTarget?: any) => {
|
|
8
|
+
let c = Reflect.construct(Target, args, newTarget);
|
|
9
9
|
let app: any = Reflect.get(global, CommonConstant.FastcarApp);
|
|
10
10
|
|
|
11
11
|
app?.loadInjectionService(c);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
import { FastCarMetaData } from "../..";
|
|
3
|
+
import Hotter from "./Hotter";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @version 1.0 用于热更新的回调作用
|
|
7
|
+
*/
|
|
8
|
+
export default function HotterCallBack(fn: string) {
|
|
9
|
+
return function (target: any) {
|
|
10
|
+
Hotter(target);
|
|
11
|
+
Reflect.defineMetadata(FastCarMetaData.HotterCallback, fn, target.prototype);
|
|
12
|
+
};
|
|
13
|
+
}
|
package/src/annotation.ts
CHANGED
|
@@ -53,6 +53,7 @@ import ComponentScanMust from "./annotation/scan/ComponentScanMust";
|
|
|
53
53
|
import DemandInjection from "./annotation/bind/DemandInjection";
|
|
54
54
|
import Value from "./annotation/bind/Value";
|
|
55
55
|
import AppEnv from "./annotation/bind/AppEnv";
|
|
56
|
+
import HotterCallBack from "./annotation/scan/HotterCallBack";
|
|
56
57
|
|
|
57
58
|
//注解暴露出去
|
|
58
59
|
export {
|
|
@@ -67,6 +68,7 @@ export {
|
|
|
67
68
|
ComponentInjection,
|
|
68
69
|
ComponentScanMust,
|
|
69
70
|
Hotter,
|
|
71
|
+
HotterCallBack,
|
|
70
72
|
BeanName,
|
|
71
73
|
Configure,
|
|
72
74
|
Controller,
|
|
@@ -18,6 +18,7 @@ export enum FastCarMetaData {
|
|
|
18
18
|
NotNull = "valid:notNull", //不为空
|
|
19
19
|
ValidCustom = "valid:custom", //自定义校验方式
|
|
20
20
|
Hotter = "hotter", //是否支持热更
|
|
21
|
+
HotterCallback = "HotterCallback", //热更回调
|
|
21
22
|
InjectionUniqueKey = "injection_uniqueKey",
|
|
22
23
|
Alias = "alias", //别名
|
|
23
24
|
LoggerModule = "LoggerModule", //日志模块集合
|
|
@@ -345,6 +345,10 @@ let FastCarApplication = FastCarApplication_1 = class FastCarApplication extends
|
|
|
345
345
|
let beforeInstance = this.getBean(beforeKey);
|
|
346
346
|
if (!!beforeInstance) {
|
|
347
347
|
Mix_1.default.assign(beforeInstance, classZ);
|
|
348
|
+
let cb = Reflect.getMetadata(FastCarMetaData_1.FastCarMetaData.HotterCallback, classZ.prototype);
|
|
349
|
+
if (cb && Reflect.has(beforeInstance, cb)) {
|
|
350
|
+
Reflect.apply(Reflect.get(beforeInstance, cb), beforeInstance, []);
|
|
351
|
+
}
|
|
348
352
|
return;
|
|
349
353
|
}
|
|
350
354
|
}
|
|
@@ -6,10 +6,10 @@ const TypeUtil_1 = require("../utils/TypeUtil");
|
|
|
6
6
|
//基础服务的应用
|
|
7
7
|
function Application(target) {
|
|
8
8
|
return new Proxy(target, {
|
|
9
|
-
construct: (target, args) => {
|
|
9
|
+
construct: (target, args, newTarget) => {
|
|
10
10
|
const FastCarApplication = require("../FastCarApplication").default;
|
|
11
11
|
let app = new FastCarApplication();
|
|
12
|
-
let appProxy =
|
|
12
|
+
let appProxy = Reflect.construct(target, args, newTarget);
|
|
13
13
|
Reflect.set(appProxy, "app", app);
|
|
14
14
|
let keys = ClassUtils_1.default.getProtoType(target);
|
|
15
15
|
for (let key of keys) {
|
|
@@ -5,8 +5,8 @@ exports.default = DemandInjection;
|
|
|
5
5
|
const CommonConstant_1 = require("../../constant/CommonConstant");
|
|
6
6
|
function DemandInjection(Target) {
|
|
7
7
|
return new Proxy(Target, {
|
|
8
|
-
construct: (Target, args) => {
|
|
9
|
-
let c =
|
|
8
|
+
construct: (Target, args, newTarget) => {
|
|
9
|
+
let c = Reflect.construct(Target, args, newTarget);
|
|
10
10
|
let app = Reflect.get(global, CommonConstant_1.CommonConstant.FastcarApp);
|
|
11
11
|
app?.loadInjectionService(c);
|
|
12
12
|
app?.loadLoggerIOC(c);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = HotterCallBack;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const __1 = require("../..");
|
|
6
|
+
const Hotter_1 = require("./Hotter");
|
|
7
|
+
/**
|
|
8
|
+
* @version 1.0 用于热更新的回调作用
|
|
9
|
+
*/
|
|
10
|
+
function HotterCallBack(fn) {
|
|
11
|
+
return function (target) {
|
|
12
|
+
(0, Hotter_1.default)(target);
|
|
13
|
+
Reflect.defineMetadata(__1.FastCarMetaData.HotterCallback, fn, target.prototype);
|
|
14
|
+
};
|
|
15
|
+
}
|
package/target/annotation.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.ApplicationSetting = exports.BaseName = exports.BasePath = exports.BaseFilePath = exports.ENV = void 0;
|
|
3
|
+
exports.SqlSession = exports.Entity = exports.Table = exports.PrimaryKey = exports.Field = exports.DBType = exports.DSIndex = exports.DS = exports.AppEnv = exports.Value = exports.CustomType = exports.ResourcePath = exports.Rule = exports.ValidForm = exports.ValidCustom = exports.Type = exports.Size = exports.NotNull = exports.DefaultVal = exports.AddChildValid = exports.AddRequireModule = exports.Log = exports.Readonly = exports.Override = exports.NotImplemented = exports.Deprecate = exports.ExceptionMonitor = exports.AliasInjection = exports.DemandInjection = exports.CallDependency = exports.Autowired = exports.Application = exports.Injection = exports.Repository = exports.Service = exports.Controller = exports.Configure = exports.BeanName = exports.HotterCallBack = exports.Hotter = exports.ComponentScanMust = exports.ComponentInjection = exports.Component = exports.ComponentScanExclusion = exports.ComponentScan = exports.ApplicationDestory = exports.ApplicationInit = exports.ApplicationRunner = exports.ApplicationStop = exports.ApplicationStart = void 0;
|
|
4
|
+
exports.ApplicationSetting = exports.BaseName = exports.BasePath = exports.BaseFilePath = exports.ENV = exports.Transactional = void 0;
|
|
5
5
|
const Application_1 = require("./annotation/Application");
|
|
6
6
|
exports.Application = Application_1.default;
|
|
7
7
|
const Autowired_1 = require("./annotation/bind/Autowired");
|
|
@@ -112,3 +112,5 @@ const Value_1 = require("./annotation/bind/Value");
|
|
|
112
112
|
exports.Value = Value_1.default;
|
|
113
113
|
const AppEnv_1 = require("./annotation/bind/AppEnv");
|
|
114
114
|
exports.AppEnv = AppEnv_1.default;
|
|
115
|
+
const HotterCallBack_1 = require("./annotation/scan/HotterCallBack");
|
|
116
|
+
exports.HotterCallBack = HotterCallBack_1.default;
|
|
@@ -22,6 +22,7 @@ var FastCarMetaData;
|
|
|
22
22
|
FastCarMetaData["NotNull"] = "valid:notNull";
|
|
23
23
|
FastCarMetaData["ValidCustom"] = "valid:custom";
|
|
24
24
|
FastCarMetaData["Hotter"] = "hotter";
|
|
25
|
+
FastCarMetaData["HotterCallback"] = "HotterCallback";
|
|
25
26
|
FastCarMetaData["InjectionUniqueKey"] = "injection_uniqueKey";
|
|
26
27
|
FastCarMetaData["Alias"] = "alias";
|
|
27
28
|
FastCarMetaData["LoggerModule"] = "LoggerModule";
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
{"timestamp":"2024-12-10 12:19:26.805","level":"INFO","label":"fastcar-server.logger","message":"自定义的日志输出"}
|
|
2
|
+
{"timestamp":"2024-12-10 12:19:26.806","level":"WARN","label":"fastcar-server.logger","message":"自定义警告"}
|
|
3
|
+
{"timestamp":"2024-12-10 12:19:26.806","level":"ERROR","label":"fastcar-server.logger","message":"自定义报错"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{"timestamp":"2024-12-10 12:19:26.598","level":"INFO","label":"fastcar-server.sys","message":"Start scanning component"}
|
|
2
|
+
{"timestamp":"2024-12-10 12:19:26.795","level":"INFO","label":"fastcar-server.sys","message":"Complete component scan"}
|
|
3
|
+
{"timestamp":"2024-12-10 12:19:26.796","level":"INFO","label":"fastcar-server.sys","message":"Call application initialization method"}
|
|
4
|
+
{"timestamp":"2024-12-10 12:19:26.798","level":"INFO","label":"fastcar-server.sys","message":"start server app is run"}
|
|
5
|
+
{"timestamp":"2024-12-10 12:19:26.799","level":"INFO","label":"fastcar-server.sys","message":"version 1.0.0"}
|
|
6
|
+
{"timestamp":"2024-12-25 22:17:05.503","level":"INFO","label":"fastcar-server.sys","message":"Start scanning component"}
|
|
7
|
+
{"timestamp":"2024-12-25 22:17:05.827","level":"INFO","label":"fastcar-server.sys","message":"Complete component scan"}
|
|
8
|
+
{"timestamp":"2024-12-25 22:17:05.829","level":"INFO","label":"fastcar-server.sys","message":"Call application initialization method"}
|
|
9
|
+
{"timestamp":"2024-12-25 22:17:05.831","level":"INFO","label":"fastcar-server.sys","message":"start server app is run"}
|
|
10
|
+
{"timestamp":"2024-12-25 22:17:05.832","level":"INFO","label":"fastcar-server.sys","message":"version 1.0.0"}
|
|
11
|
+
{"timestamp":"2024-12-25 22:17:09.47","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
|
|
12
|
+
{"timestamp":"2024-12-25 22:17:16.221","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
|
|
13
|
+
{"timestamp":"2024-12-25 22:17:25.294","level":"ERROR","label":"fastcar-server.sys","message":"Caught exception: ⨯ Unable to compile TypeScript:\nfastcar-core/test/example/simple/service/HelloService.ts(7,2): error TS2564: Property 'hello' has no initializer and is not definitely assigned in the constructor.\r\n"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{"timestamp":"2024-12-25 22:18:03.14","level":"INFO","label":"fastcar-server.sys","message":"Start scanning component"}
|
|
2
|
+
{"timestamp":"2024-12-25 22:18:03.378","level":"INFO","label":"fastcar-server.sys","message":"Complete component scan"}
|
|
3
|
+
{"timestamp":"2024-12-25 22:18:03.380","level":"INFO","label":"fastcar-server.sys","message":"Call application initialization method"}
|
|
4
|
+
{"timestamp":"2024-12-25 22:18:03.383","level":"INFO","label":"fastcar-server.sys","message":"start server app is run"}
|
|
5
|
+
{"timestamp":"2024-12-25 22:18:03.383","level":"INFO","label":"fastcar-server.sys","message":"version 1.0.0"}
|
|
6
|
+
{"timestamp":"2024-12-25 22:18:13.857","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
|
|
7
|
+
{"timestamp":"2024-12-25 22:18:27.205","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
|
|
8
|
+
{"timestamp":"2024-12-25 22:18:47.545","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
|
|
9
|
+
{"timestamp":"2024-12-25 22:19:03.334","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{"timestamp":"2024-12-25 22:21:34.898","level":"INFO","label":"fastcar-server.sys","message":"Start scanning component"}
|
|
2
|
+
{"timestamp":"2024-12-25 22:21:35.252","level":"INFO","label":"fastcar-server.sys","message":"Complete component scan"}
|
|
3
|
+
{"timestamp":"2024-12-25 22:21:35.255","level":"INFO","label":"fastcar-server.sys","message":"Call application initialization method"}
|
|
4
|
+
{"timestamp":"2024-12-25 22:21:35.257","level":"INFO","label":"fastcar-server.sys","message":"start server app is run"}
|
|
5
|
+
{"timestamp":"2024-12-25 22:21:35.258","level":"INFO","label":"fastcar-server.sys","message":"version 1.0.0"}
|
|
6
|
+
{"timestamp":"2024-12-25 22:21:39.105","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
|
|
7
|
+
{"timestamp":"2024-12-25 22:21:46.811","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
|
|
8
|
+
{"timestamp":"2024-12-25 22:48:23.291","level":"INFO","label":"fastcar-server.sys","message":"Start scanning component"}
|
|
9
|
+
{"timestamp":"2024-12-25 22:48:23.536","level":"INFO","label":"fastcar-server.sys","message":"Complete component scan"}
|
|
10
|
+
{"timestamp":"2024-12-25 22:48:23.538","level":"INFO","label":"fastcar-server.sys","message":"Call application initialization method"}
|
|
11
|
+
{"timestamp":"2024-12-25 22:48:23.539","level":"INFO","label":"fastcar-server.sys","message":"start server app is run"}
|
|
12
|
+
{"timestamp":"2024-12-25 22:48:23.540","level":"INFO","label":"fastcar-server.sys","message":"version 1.0.0"}
|
|
13
|
+
{"timestamp":"2024-12-25 22:48:29.09","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{"timestamp":"2024-12-25 22:48:35.213","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
|
|
2
|
+
{"timestamp":"2024-12-25 22:48:41.354","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
|
|
3
|
+
{"timestamp":"2024-12-25 22:48:53.438","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
|
|
4
|
+
{"timestamp":"2024-12-25 22:49:05.829","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
|
|
5
|
+
{"timestamp":"2024-12-25 22:50:26.222","level":"INFO","label":"fastcar-server.sys","message":"Start scanning component"}
|
|
6
|
+
{"timestamp":"2024-12-25 22:50:26.701","level":"INFO","label":"fastcar-server.sys","message":"Complete component scan"}
|
|
7
|
+
{"timestamp":"2024-12-25 22:50:26.704","level":"INFO","label":"fastcar-server.sys","message":"Call application initialization method"}
|
|
8
|
+
{"timestamp":"2024-12-25 22:50:26.706","level":"INFO","label":"fastcar-server.sys","message":"start server app is run"}
|
|
9
|
+
{"timestamp":"2024-12-25 22:50:26.707","level":"INFO","label":"fastcar-server.sys","message":"version 1.0.0"}
|
|
10
|
+
{"timestamp":"2024-12-25 22:50:29.663","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
|
|
11
|
+
{"timestamp":"2024-12-25 22:50:32.698","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|