@yumerijs/core 1.0.34 → 1.1.0-alpha.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.
- package/dist/config.d.ts +109 -1
- package/dist/config.js +104 -2
- package/dist/config.js.map +1 -1
- package/dist/core.d.ts +13 -3
- package/dist/core.js +23 -6
- package/dist/core.js.map +1 -1
- package/dist/index.d.ts +6 -7
- package/dist/index.js +20 -13
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +0 -0
- package/dist/logger.js +0 -0
- package/dist/logger.js.map +0 -0
- package/dist/platform.d.ts +150 -2
- package/dist/platform.js +188 -0
- package/dist/platform.js.map +1 -1
- package/dist/src/command.d.ts +19 -0
- package/dist/src/command.js +28 -0
- package/dist/src/command.js.map +1 -0
- package/dist/src/config.d.ts +133 -0
- package/dist/src/config.js +205 -0
- package/dist/src/config.js.map +1 -0
- package/dist/src/core.d.ts +66 -0
- package/dist/src/core.js +363 -0
- package/dist/src/core.js.map +1 -0
- package/dist/src/index.d.ts +11 -0
- package/dist/src/index.js +28 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/logger.d.ts +15 -0
- package/dist/src/logger.js +39 -0
- package/dist/src/logger.js.map +1 -0
- package/dist/src/platform.d.ts +159 -0
- package/dist/src/platform.js +195 -0
- package/dist/src/platform.js.map +1 -0
- package/dist/src/session.d.ts +29 -0
- package/dist/src/session.js +106 -0
- package/dist/src/session.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +3 -1
package/dist/platform.js
CHANGED
|
@@ -1,7 +1,195 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Platform = void 0;
|
|
4
|
+
const session_1 = require("./session");
|
|
5
|
+
/**
|
|
6
|
+
* Platform 基类
|
|
7
|
+
* 作为平台接入的基础类,提供标准化的接口和通用能力
|
|
8
|
+
* 各平台实现类需继承此类并实现所有抽象方法
|
|
9
|
+
*/
|
|
4
10
|
class Platform {
|
|
11
|
+
/**
|
|
12
|
+
* 构造函数
|
|
13
|
+
* @param config 平台配置
|
|
14
|
+
*/
|
|
15
|
+
constructor(config) {
|
|
16
|
+
// 平台状态
|
|
17
|
+
this.status = 'idle';
|
|
18
|
+
// 平台错误信息
|
|
19
|
+
this.errorMessage = null;
|
|
20
|
+
// 平台配置
|
|
21
|
+
this.config = {};
|
|
22
|
+
// 平台实例ID
|
|
23
|
+
this.instanceId = '';
|
|
24
|
+
// 平台事件监听器
|
|
25
|
+
this.eventListeners = {};
|
|
26
|
+
if (config) {
|
|
27
|
+
this.config = { ...config };
|
|
28
|
+
}
|
|
29
|
+
this.instanceId = this.generateInstanceId();
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 生成平台实例ID
|
|
33
|
+
* @returns 实例ID字符串
|
|
34
|
+
*/
|
|
35
|
+
generateInstanceId() {
|
|
36
|
+
return `${this.getPlatformId()}-${Date.now()}-${Math.floor(Math.random() * 1000)}`;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* 重启平台
|
|
40
|
+
* @param core Core实例
|
|
41
|
+
* @returns 重启结果
|
|
42
|
+
*/
|
|
43
|
+
async restartPlatform(core) {
|
|
44
|
+
await this.stopPlatform();
|
|
45
|
+
return this.startPlatform(core);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* 设置平台配置
|
|
49
|
+
* @param key 配置键
|
|
50
|
+
* @param value 配置值
|
|
51
|
+
*/
|
|
52
|
+
setConfig(key, value) {
|
|
53
|
+
this.config[key] = value;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* 获取平台配置
|
|
57
|
+
* @param key 配置键
|
|
58
|
+
* @param defaultValue 默认值
|
|
59
|
+
* @returns 配置值
|
|
60
|
+
*/
|
|
61
|
+
getConfig(key, defaultValue) {
|
|
62
|
+
return (this.config[key] !== undefined) ? this.config[key] : defaultValue;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* 获取平台实例ID
|
|
66
|
+
* @returns 实例ID
|
|
67
|
+
*/
|
|
68
|
+
getInstanceId() {
|
|
69
|
+
return this.instanceId;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* 获取当前平台状态
|
|
73
|
+
* @returns 状态字符串
|
|
74
|
+
*/
|
|
75
|
+
getStatus() {
|
|
76
|
+
return this.status;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* 获取错误信息
|
|
80
|
+
* @returns 错误信息
|
|
81
|
+
*/
|
|
82
|
+
getErrorMessage() {
|
|
83
|
+
return this.errorMessage;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* 添加平台事件监听器
|
|
87
|
+
* @param event 事件名称
|
|
88
|
+
* @param listener 监听器函数
|
|
89
|
+
*/
|
|
90
|
+
on(event, listener) {
|
|
91
|
+
if (!this.eventListeners[event]) {
|
|
92
|
+
this.eventListeners[event] = [];
|
|
93
|
+
}
|
|
94
|
+
this.eventListeners[event].push(listener);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* 移除平台事件监听器
|
|
98
|
+
* @param event 事件名称
|
|
99
|
+
* @param listener 监听器函数
|
|
100
|
+
*/
|
|
101
|
+
off(event, listener) {
|
|
102
|
+
if (!this.eventListeners[event]) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
this.eventListeners[event] = this.eventListeners[event].filter(l => l !== listener);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* 触发平台事件
|
|
109
|
+
* @param event 事件名称
|
|
110
|
+
* @param args 事件参数
|
|
111
|
+
*/
|
|
112
|
+
emit(event, ...args) {
|
|
113
|
+
if (!this.eventListeners[event]) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
for (const listener of this.eventListeners[event]) {
|
|
117
|
+
try {
|
|
118
|
+
listener(...args);
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
console.error(`Error in platform event listener for "${event}":`, error);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* 创建会话
|
|
127
|
+
* @param ip 客户端IP
|
|
128
|
+
* @param cookie Cookie对象
|
|
129
|
+
* @param query 查询参数
|
|
130
|
+
* @returns 会话对象
|
|
131
|
+
*/
|
|
132
|
+
createSession(ip, cookie, query) {
|
|
133
|
+
return new session_1.Session(ip, cookie, this, query);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* 处理会话数据
|
|
137
|
+
* @param session 会话对象
|
|
138
|
+
* @param data 会话数据
|
|
139
|
+
* @returns 处理结果
|
|
140
|
+
*/
|
|
141
|
+
processSessionData(session, data) {
|
|
142
|
+
// 默认实现,子类可覆盖
|
|
143
|
+
return data;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* 验证会话
|
|
147
|
+
* @param session 会话对象
|
|
148
|
+
* @returns 验证结果
|
|
149
|
+
*/
|
|
150
|
+
validateSession(session) {
|
|
151
|
+
// 默认实现,子类可覆盖
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* 获取平台支持的MIME类型
|
|
156
|
+
* @returns MIME类型数组
|
|
157
|
+
*/
|
|
158
|
+
getSupportedMimeTypes() {
|
|
159
|
+
// 默认实现,子类可覆盖
|
|
160
|
+
return [
|
|
161
|
+
'text/plain',
|
|
162
|
+
'text/html',
|
|
163
|
+
'application/json',
|
|
164
|
+
'application/xml',
|
|
165
|
+
'image/png',
|
|
166
|
+
'image/jpeg',
|
|
167
|
+
'application/pdf'
|
|
168
|
+
];
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* 获取平台元数据
|
|
172
|
+
* @returns 平台元数据
|
|
173
|
+
*/
|
|
174
|
+
getMetadata() {
|
|
175
|
+
return {
|
|
176
|
+
id: this.getPlatformId(),
|
|
177
|
+
name: this.getPlatformName(),
|
|
178
|
+
version: this.getPlatformVersionCode(),
|
|
179
|
+
status: this.getStatus(),
|
|
180
|
+
instanceId: this.getInstanceId(),
|
|
181
|
+
supportedMimeTypes: this.getSupportedMimeTypes(),
|
|
182
|
+
...this.getPlatformStatus()
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* 获取平台配置模式
|
|
187
|
+
* 子类可以覆盖此方法提供自定义配置模式
|
|
188
|
+
* @returns 配置模式对象
|
|
189
|
+
*/
|
|
190
|
+
static getConfigSchema() {
|
|
191
|
+
return {};
|
|
192
|
+
}
|
|
5
193
|
}
|
|
6
194
|
exports.Platform = Platform;
|
|
7
195
|
//# sourceMappingURL=platform.js.map
|
package/dist/platform.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":";;;AAAA,uCAAmC;AAInC;;;;GAIG;AACH,MAAsB,QAAQ;IAY1B;;;OAGG;IACH,YAAY,MAA4B;QAfxC,OAAO;QACG,WAAM,GAA2D,MAAM,CAAC;QAClF,SAAS;QACC,iBAAY,GAAkB,IAAI,CAAC;QAC7C,OAAO;QACG,WAAM,GAAwB,EAAE,CAAC;QAC3C,SAAS;QACC,eAAU,GAAW,EAAE,CAAC;QAClC,UAAU;QACA,mBAAc,GAAoD,EAAE,CAAC;QAO3E,IAAI,MAAM,EAAE,CAAC;YACT,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,MAAM,EAAE,CAAC;QAChC,CAAC;QACD,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,kBAAkB,EAAE,CAAC;IAChD,CAAC;IAED;;;OAGG;IACO,kBAAkB;QACxB,OAAO,GAAG,IAAI,CAAC,aAAa,EAAE,IAAI,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAA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sBAAsB,EAAE;YACtC,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE;YACxB,UAAU,EAAE,IAAI,CAAC,aAAa,EAAE;YAChC,kBAAkB,EAAE,IAAI,CAAC,qBAAqB,EAAE;YAChD,GAAG,IAAI,CAAC,iBAAiB,EAAE;SAC9B,CAAC;IACN,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,eAAe;QACzB,OAAO,EAAE,CAAC;IACd,CAAC;CACJ;AA5PD,4BA4PC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @time: 2025/03/25 23:53
|
|
3
|
+
* @author: FireGuo
|
|
4
|
+
* WindyPear-Team All right reserved
|
|
5
|
+
**/
|
|
6
|
+
import { Core } from './core';
|
|
7
|
+
import { Session } from './session';
|
|
8
|
+
interface ActionFn {
|
|
9
|
+
(session: any, ...args: any[]): Promise<any>;
|
|
10
|
+
}
|
|
11
|
+
export declare class Command {
|
|
12
|
+
name: string;
|
|
13
|
+
actionFn: ActionFn | null;
|
|
14
|
+
core: Core;
|
|
15
|
+
constructor(core: Core, name: string);
|
|
16
|
+
action(fn: ActionFn): this;
|
|
17
|
+
execute(session: any, ...args: any[]): Promise<Session | null>;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @time: 2025/03/25 23:53
|
|
4
|
+
* @author: FireGuo
|
|
5
|
+
* WindyPear-Team All right reserved
|
|
6
|
+
**/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.Command = void 0;
|
|
9
|
+
class Command {
|
|
10
|
+
constructor(core, name) {
|
|
11
|
+
this.actionFn = null; // Corrected type: ActionFn | null
|
|
12
|
+
this.core = core; // 接收 Core 实例
|
|
13
|
+
this.name = name;
|
|
14
|
+
}
|
|
15
|
+
action(fn) {
|
|
16
|
+
this.actionFn = fn;
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
async execute(session, ...args) {
|
|
20
|
+
if (this.actionFn) {
|
|
21
|
+
await this.actionFn(session, ...args);
|
|
22
|
+
return session;
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.Command = Command;
|
|
28
|
+
//# sourceMappingURL=command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../src/command.ts"],"names":[],"mappings":";AAAA;;;;IAII;;;AASJ,MAAa,OAAO;IAKlB,YAAY,IAAU,EAAE,IAAY;QAHpC,aAAQ,GAAoB,IAAI,CAAC,CAAC,kCAAkC;QAIlE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,aAAa;QAC/B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,MAAM,CAAC,EAAY;QACjB,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;QACnB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,OAAY,EAAE,GAAG,IAAW;QACxC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;YACtC,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAtBD,0BAsBC"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @time: 2025/03/24 12:26
|
|
3
|
+
* @author: FireGuo
|
|
4
|
+
* WindyPear-Team All right reserved
|
|
5
|
+
**/
|
|
6
|
+
/**
|
|
7
|
+
* 插件配置模式定义类
|
|
8
|
+
* 用于描述插件配置项的类型、默认值、描述等信息
|
|
9
|
+
*/
|
|
10
|
+
export declare class ConfigSchema {
|
|
11
|
+
/**
|
|
12
|
+
* 配置项类型
|
|
13
|
+
*/
|
|
14
|
+
type: 'string' | 'number' | 'boolean' | 'object' | 'array';
|
|
15
|
+
/**
|
|
16
|
+
* 默认值
|
|
17
|
+
*/
|
|
18
|
+
default?: any;
|
|
19
|
+
/**
|
|
20
|
+
* 配置项描述
|
|
21
|
+
*/
|
|
22
|
+
description?: string;
|
|
23
|
+
/**
|
|
24
|
+
* 是否必需
|
|
25
|
+
*/
|
|
26
|
+
required?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* 枚举值列表(可选项)
|
|
29
|
+
*/
|
|
30
|
+
enum?: any[];
|
|
31
|
+
/**
|
|
32
|
+
* 数组项类型定义(当type为array时使用)
|
|
33
|
+
*/
|
|
34
|
+
items?: ConfigSchema;
|
|
35
|
+
/**
|
|
36
|
+
* 对象属性定义(当type为object时使用)
|
|
37
|
+
*/
|
|
38
|
+
properties?: Record<string, ConfigSchema>;
|
|
39
|
+
/**
|
|
40
|
+
* 创建配置模式对象
|
|
41
|
+
* @param type 配置项类型
|
|
42
|
+
* @param options 配置项选项
|
|
43
|
+
*/
|
|
44
|
+
constructor(type: 'string' | 'number' | 'boolean' | 'object' | 'array', options?: {
|
|
45
|
+
default?: any;
|
|
46
|
+
description?: string;
|
|
47
|
+
required?: boolean;
|
|
48
|
+
enum?: any[];
|
|
49
|
+
items?: ConfigSchema;
|
|
50
|
+
properties?: Record<string, ConfigSchema>;
|
|
51
|
+
});
|
|
52
|
+
/**
|
|
53
|
+
* 创建字符串类型配置模式
|
|
54
|
+
* @param options 配置项选项
|
|
55
|
+
* @returns 配置模式对象
|
|
56
|
+
*/
|
|
57
|
+
static string(options?: Omit<ConfigSchema, 'type' | 'items' | 'properties'>): ConfigSchema;
|
|
58
|
+
/**
|
|
59
|
+
* 创建数字类型配置模式
|
|
60
|
+
* @param options 配置项选项
|
|
61
|
+
* @returns 配置模式对象
|
|
62
|
+
*/
|
|
63
|
+
static number(options?: Omit<ConfigSchema, 'type' | 'items' | 'properties'>): ConfigSchema;
|
|
64
|
+
/**
|
|
65
|
+
* 创建布尔类型配置模式
|
|
66
|
+
* @param options 配置项选项
|
|
67
|
+
* @returns 配置模式对象
|
|
68
|
+
*/
|
|
69
|
+
static boolean(options?: Omit<ConfigSchema, 'type' | 'items' | 'properties'>): ConfigSchema;
|
|
70
|
+
/**
|
|
71
|
+
* 创建对象类型配置模式
|
|
72
|
+
* @param properties 对象属性定义
|
|
73
|
+
* @param options 配置项选项
|
|
74
|
+
* @returns 配置模式对象
|
|
75
|
+
*/
|
|
76
|
+
static object(properties: Record<string, ConfigSchema>, options?: Omit<ConfigSchema, 'type' | 'items' | 'properties'>): ConfigSchema;
|
|
77
|
+
/**
|
|
78
|
+
* 创建数组类型配置模式
|
|
79
|
+
* @param items 数组项类型定义
|
|
80
|
+
* @param options 配置项选项
|
|
81
|
+
* @returns 配置模式对象
|
|
82
|
+
*/
|
|
83
|
+
static array(items: ConfigSchema, options?: Omit<ConfigSchema, 'type' | 'items' | 'properties'>): ConfigSchema;
|
|
84
|
+
/**
|
|
85
|
+
* 验证值是否符合配置模式
|
|
86
|
+
* @param value 要验证的值
|
|
87
|
+
* @returns 验证结果,如果通过返回true,否则返回错误信息
|
|
88
|
+
*/
|
|
89
|
+
validate(value: any): true | string;
|
|
90
|
+
}
|
|
91
|
+
export declare class Config {
|
|
92
|
+
/**
|
|
93
|
+
* 配置名称
|
|
94
|
+
*/
|
|
95
|
+
name: string;
|
|
96
|
+
/**
|
|
97
|
+
* 配置内容
|
|
98
|
+
*/
|
|
99
|
+
content: {
|
|
100
|
+
[name: string]: any;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* 配置模式
|
|
104
|
+
*/
|
|
105
|
+
schema?: Record<string, ConfigSchema>;
|
|
106
|
+
/**
|
|
107
|
+
* 创建配置对象
|
|
108
|
+
* @param name 配置名称
|
|
109
|
+
* @param content 配置内容
|
|
110
|
+
* @param schema 配置模式
|
|
111
|
+
*/
|
|
112
|
+
constructor(name: string, content?: {
|
|
113
|
+
[name: string]: any;
|
|
114
|
+
}, schema?: Record<string, ConfigSchema>);
|
|
115
|
+
/**
|
|
116
|
+
* 获取配置项值
|
|
117
|
+
* @param key 配置项键名
|
|
118
|
+
* @param defaultValue 默认值
|
|
119
|
+
* @returns 配置项值
|
|
120
|
+
*/
|
|
121
|
+
get<T>(key: string, defaultValue?: T): T;
|
|
122
|
+
/**
|
|
123
|
+
* 设置配置项值
|
|
124
|
+
* @param key 配置项键名
|
|
125
|
+
* @param value 配置项值
|
|
126
|
+
*/
|
|
127
|
+
set(key: string, value: any): void;
|
|
128
|
+
/**
|
|
129
|
+
* 验证配置是否符合schema
|
|
130
|
+
* @returns 验证结果,如果通过返回true,否则返回错误信息
|
|
131
|
+
*/
|
|
132
|
+
validate(): true | string;
|
|
133
|
+
}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @time: 2025/03/24 12:26
|
|
4
|
+
* @author: FireGuo
|
|
5
|
+
* WindyPear-Team All right reserved
|
|
6
|
+
**/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.Config = exports.ConfigSchema = void 0;
|
|
9
|
+
/**
|
|
10
|
+
* 插件配置模式定义类
|
|
11
|
+
* 用于描述插件配置项的类型、默认值、描述等信息
|
|
12
|
+
*/
|
|
13
|
+
class ConfigSchema {
|
|
14
|
+
/**
|
|
15
|
+
* 创建配置模式对象
|
|
16
|
+
* @param type 配置项类型
|
|
17
|
+
* @param options 配置项选项
|
|
18
|
+
*/
|
|
19
|
+
constructor(type, options) {
|
|
20
|
+
this.type = type;
|
|
21
|
+
if (options) {
|
|
22
|
+
this.default = options.default;
|
|
23
|
+
this.description = options.description;
|
|
24
|
+
this.required = options.required;
|
|
25
|
+
this.enum = options.enum;
|
|
26
|
+
this.items = options.items;
|
|
27
|
+
this.properties = options.properties;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 创建字符串类型配置模式
|
|
32
|
+
* @param options 配置项选项
|
|
33
|
+
* @returns 配置模式对象
|
|
34
|
+
*/
|
|
35
|
+
static string(options) {
|
|
36
|
+
return new ConfigSchema('string', options);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* 创建数字类型配置模式
|
|
40
|
+
* @param options 配置项选项
|
|
41
|
+
* @returns 配置模式对象
|
|
42
|
+
*/
|
|
43
|
+
static number(options) {
|
|
44
|
+
return new ConfigSchema('number', options);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* 创建布尔类型配置模式
|
|
48
|
+
* @param options 配置项选项
|
|
49
|
+
* @returns 配置模式对象
|
|
50
|
+
*/
|
|
51
|
+
static boolean(options) {
|
|
52
|
+
return new ConfigSchema('boolean', options);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* 创建对象类型配置模式
|
|
56
|
+
* @param properties 对象属性定义
|
|
57
|
+
* @param options 配置项选项
|
|
58
|
+
* @returns 配置模式对象
|
|
59
|
+
*/
|
|
60
|
+
static object(properties, options) {
|
|
61
|
+
return new ConfigSchema('object', { ...options, properties });
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* 创建数组类型配置模式
|
|
65
|
+
* @param items 数组项类型定义
|
|
66
|
+
* @param options 配置项选项
|
|
67
|
+
* @returns 配置模式对象
|
|
68
|
+
*/
|
|
69
|
+
static array(items, options) {
|
|
70
|
+
return new ConfigSchema('array', { ...options, items });
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* 验证值是否符合配置模式
|
|
74
|
+
* @param value 要验证的值
|
|
75
|
+
* @returns 验证结果,如果通过返回true,否则返回错误信息
|
|
76
|
+
*/
|
|
77
|
+
validate(value) {
|
|
78
|
+
// 检查必需项
|
|
79
|
+
if (this.required && value === undefined) {
|
|
80
|
+
return `Missing required value`;
|
|
81
|
+
}
|
|
82
|
+
// 如果值存在,检查类型
|
|
83
|
+
if (value !== undefined) {
|
|
84
|
+
// 类型检查
|
|
85
|
+
switch (this.type) {
|
|
86
|
+
case 'string':
|
|
87
|
+
if (typeof value !== 'string') {
|
|
88
|
+
return `Value should be string`;
|
|
89
|
+
}
|
|
90
|
+
break;
|
|
91
|
+
case 'number':
|
|
92
|
+
if (typeof value !== 'number') {
|
|
93
|
+
return `Value should be number`;
|
|
94
|
+
}
|
|
95
|
+
break;
|
|
96
|
+
case 'boolean':
|
|
97
|
+
if (typeof value !== 'boolean') {
|
|
98
|
+
return `Value should be boolean`;
|
|
99
|
+
}
|
|
100
|
+
break;
|
|
101
|
+
case 'object':
|
|
102
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
103
|
+
return `Value should be object`;
|
|
104
|
+
}
|
|
105
|
+
// 如果有属性定义,检查每个属性
|
|
106
|
+
if (this.properties) {
|
|
107
|
+
for (const key in this.properties) {
|
|
108
|
+
const propSchema = this.properties[key];
|
|
109
|
+
const propValue = value[key];
|
|
110
|
+
const propResult = propSchema.validate(propValue);
|
|
111
|
+
if (propResult !== true) {
|
|
112
|
+
return `Property ${key}: ${propResult}`;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
break;
|
|
117
|
+
case 'array':
|
|
118
|
+
if (!Array.isArray(value)) {
|
|
119
|
+
return `Value should be array`;
|
|
120
|
+
}
|
|
121
|
+
// 如果有数组项定义,检查每个项
|
|
122
|
+
if (this.items) {
|
|
123
|
+
for (let i = 0; i < value.length; i++) {
|
|
124
|
+
const itemResult = this.items.validate(value[i]);
|
|
125
|
+
if (itemResult !== true) {
|
|
126
|
+
return `Item at index ${i}: ${itemResult}`;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
// 枚举值检查
|
|
133
|
+
if (this.enum && !this.enum.includes(value)) {
|
|
134
|
+
return `Value should be one of: ${this.enum.join(', ')}`;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
exports.ConfigSchema = ConfigSchema;
|
|
141
|
+
class Config {
|
|
142
|
+
/**
|
|
143
|
+
* 创建配置对象
|
|
144
|
+
* @param name 配置名称
|
|
145
|
+
* @param content 配置内容
|
|
146
|
+
* @param schema 配置模式
|
|
147
|
+
*/
|
|
148
|
+
constructor(name, content, schema) {
|
|
149
|
+
/**
|
|
150
|
+
* 配置名称
|
|
151
|
+
*/
|
|
152
|
+
this.name = '';
|
|
153
|
+
/**
|
|
154
|
+
* 配置内容
|
|
155
|
+
*/
|
|
156
|
+
this.content = {};
|
|
157
|
+
this.name = name;
|
|
158
|
+
this.content = content || {}; // 如果 content 是 undefined,则赋值为空对象
|
|
159
|
+
this.schema = schema;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* 获取配置项值
|
|
163
|
+
* @param key 配置项键名
|
|
164
|
+
* @param defaultValue 默认值
|
|
165
|
+
* @returns 配置项值
|
|
166
|
+
*/
|
|
167
|
+
get(key, defaultValue) {
|
|
168
|
+
if (this.content[key] !== undefined) {
|
|
169
|
+
return this.content[key];
|
|
170
|
+
}
|
|
171
|
+
// 如果有schema,尝试从schema中获取默认值
|
|
172
|
+
if (this.schema && this.schema[key] && this.schema[key].default !== undefined) {
|
|
173
|
+
return this.schema[key].default;
|
|
174
|
+
}
|
|
175
|
+
return defaultValue;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* 设置配置项值
|
|
179
|
+
* @param key 配置项键名
|
|
180
|
+
* @param value 配置项值
|
|
181
|
+
*/
|
|
182
|
+
set(key, value) {
|
|
183
|
+
this.content[key] = value;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* 验证配置是否符合schema
|
|
187
|
+
* @returns 验证结果,如果通过返回true,否则返回错误信息
|
|
188
|
+
*/
|
|
189
|
+
validate() {
|
|
190
|
+
if (!this.schema) {
|
|
191
|
+
return true; // 没有schema,视为验证通过
|
|
192
|
+
}
|
|
193
|
+
for (const key in this.schema) {
|
|
194
|
+
const schemaItem = this.schema[key];
|
|
195
|
+
const value = this.content[key];
|
|
196
|
+
const result = schemaItem.validate(value);
|
|
197
|
+
if (result !== true) {
|
|
198
|
+
return `Config ${key}: ${result}`;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return true;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
exports.Config = Config;
|
|
205
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":";AAAA;;;;IAII;;;AAEJ;;;GAGG;AACH,MAAa,YAAY;IAoCrB;;;;OAIG;IACH,YACE,IAA0D,EAC1D,OAOC;QAED,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QAEjB,IAAI,OAAO,EAAE,CAAC;YACZ,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;YAC/B,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;YACvC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;YACjC,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;YACzB,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;YAC3B,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACvC,CAAC;IACH,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,MAAM,CAAC,OAA6D;QAChF,OAAO,IAAI,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC7C,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,MAAM,CAAC,OAA6D;QAChF,OAAO,IAAI,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC7C,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,OAAO,CAAC,OAA6D;QACjF,OAAO,IAAI,YAAY,CAAC,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CAAC;YAEhC,MAAM,MAAM,GAAG,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YAC1C,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;gBAClB,OAAO,UAAU,GAAG,KAAK,MAAM,EAAE,CAAC;YACtC,CAAC;QACL,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AA7ED,wBA6EC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Config } from './config';
|
|
2
|
+
import { Logger } from './logger';
|
|
3
|
+
import { Command } from './command';
|
|
4
|
+
import { Session } from './session';
|
|
5
|
+
import { Platform } from './platform';
|
|
6
|
+
interface Plugin {
|
|
7
|
+
apply: (core: Core, config: Config) => Promise<void>;
|
|
8
|
+
disable: (core: Core) => Promise<void>;
|
|
9
|
+
depend: Array<string>;
|
|
10
|
+
provide: Array<string>;
|
|
11
|
+
}
|
|
12
|
+
interface PluginLoader {
|
|
13
|
+
load(pluginName: string): Promise<Plugin>;
|
|
14
|
+
unloadPlugin(pluginName: string): Promise<void>;
|
|
15
|
+
checkPluginDependencies(pluginPath: string): Promise<boolean>;
|
|
16
|
+
installPluginDependencies(pluginName: string): Promise<void>;
|
|
17
|
+
logger: Logger;
|
|
18
|
+
}
|
|
19
|
+
export declare class Core {
|
|
20
|
+
plugins: {
|
|
21
|
+
[name: string]: Plugin & {
|
|
22
|
+
depend?: string[];
|
|
23
|
+
provide?: string[];
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
config: any;
|
|
27
|
+
platforms: Platform[];
|
|
28
|
+
private eventListeners;
|
|
29
|
+
private components;
|
|
30
|
+
commands: Record<string, Command>;
|
|
31
|
+
private pluginLoader;
|
|
32
|
+
private logger;
|
|
33
|
+
private providedComponents;
|
|
34
|
+
private pluginModules;
|
|
35
|
+
constructor(pluginLoader: PluginLoader);
|
|
36
|
+
loadConfig(configPath: string): Promise<void>;
|
|
37
|
+
getPluginConfig(pluginName: string): Promise<Config>;
|
|
38
|
+
loadPlugins(): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* 监听插件目录,实现热重载
|
|
41
|
+
* @param core Core实例
|
|
42
|
+
* @param pluginsDir 插件目录
|
|
43
|
+
*/
|
|
44
|
+
watchPlugins(core: Core, pluginsDir?: string): void;
|
|
45
|
+
/**
|
|
46
|
+
* 重新加载插件
|
|
47
|
+
* @param pluginName 插件名称
|
|
48
|
+
* @param core Core实例
|
|
49
|
+
*/
|
|
50
|
+
reloadPlugin(pluginName: string, core: Core): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* 卸载插件并触发事件
|
|
53
|
+
* @param pluginName 插件名称
|
|
54
|
+
* @param core Core实例
|
|
55
|
+
*/
|
|
56
|
+
unloadPluginAndEmit(pluginName: string, core: Core): Promise<void>;
|
|
57
|
+
registerComponent(name: string, component: any): void;
|
|
58
|
+
getComponent(name: string): any;
|
|
59
|
+
unregisterComponent(name: string): void;
|
|
60
|
+
on(event: string, listener: (...args: any[]) => Promise<void>): void;
|
|
61
|
+
emit(event: string, ...args: any[]): Promise<void>;
|
|
62
|
+
command(name: string): Command;
|
|
63
|
+
executeCommand(name: string, session: any, ...args: any[]): Promise<Session | null>;
|
|
64
|
+
registerPlatform(platform: Platform): any;
|
|
65
|
+
}
|
|
66
|
+
export {};
|