@zhin.js/core 1.0.0 → 1.0.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.
Files changed (133) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/LICENSE +21 -0
  3. package/README.md +295 -74
  4. package/lib/adapter.d.ts +39 -0
  5. package/lib/adapter.d.ts.map +1 -0
  6. package/{dist → lib}/adapter.js +20 -2
  7. package/lib/adapter.js.map +1 -0
  8. package/lib/app.d.ts +115 -0
  9. package/lib/app.d.ts.map +1 -0
  10. package/{dist → lib}/app.js +148 -78
  11. package/lib/app.js.map +1 -0
  12. package/lib/bot.d.ts +31 -0
  13. package/lib/bot.d.ts.map +1 -0
  14. package/lib/command.d.ts +32 -0
  15. package/lib/command.d.ts.map +1 -0
  16. package/lib/command.js +46 -0
  17. package/lib/command.js.map +1 -0
  18. package/lib/component.d.ts +27 -0
  19. package/lib/component.d.ts.map +1 -0
  20. package/lib/component.js +469 -0
  21. package/lib/component.js.map +1 -0
  22. package/{dist → lib}/config.d.ts.map +1 -1
  23. package/{dist → lib}/config.js +6 -9
  24. package/lib/config.js.map +1 -0
  25. package/lib/cron.d.ts +81 -0
  26. package/lib/cron.d.ts.map +1 -0
  27. package/lib/cron.js +159 -0
  28. package/lib/cron.js.map +1 -0
  29. package/lib/errors.d.ts +165 -0
  30. package/lib/errors.d.ts.map +1 -0
  31. package/lib/errors.js +306 -0
  32. package/lib/errors.js.map +1 -0
  33. package/lib/index.d.ts +15 -0
  34. package/lib/index.d.ts.map +1 -0
  35. package/lib/index.js +17 -0
  36. package/lib/index.js.map +1 -0
  37. package/lib/jsx-runtime.d.ts +12 -0
  38. package/lib/jsx-runtime.d.ts.map +1 -0
  39. package/lib/jsx-runtime.js +11 -0
  40. package/lib/jsx-runtime.js.map +1 -0
  41. package/lib/jsx.d.ts +32 -0
  42. package/lib/jsx.d.ts.map +1 -0
  43. package/lib/jsx.js +57 -0
  44. package/lib/jsx.js.map +1 -0
  45. package/lib/message.d.ts +47 -0
  46. package/lib/message.d.ts.map +1 -0
  47. package/lib/message.js +11 -0
  48. package/lib/message.js.map +1 -0
  49. package/lib/plugin.d.ts +50 -0
  50. package/lib/plugin.d.ts.map +1 -0
  51. package/lib/plugin.js +170 -0
  52. package/lib/plugin.js.map +1 -0
  53. package/lib/prompt.d.ts +116 -0
  54. package/lib/prompt.d.ts.map +1 -0
  55. package/lib/prompt.js +240 -0
  56. package/lib/prompt.js.map +1 -0
  57. package/lib/schema.d.ts +83 -0
  58. package/lib/schema.d.ts.map +1 -0
  59. package/lib/schema.js +245 -0
  60. package/lib/schema.js.map +1 -0
  61. package/{dist → lib}/types-generator.d.ts.map +1 -1
  62. package/{dist → lib}/types-generator.js +6 -3
  63. package/lib/types-generator.js.map +1 -0
  64. package/lib/types.d.ts +121 -0
  65. package/lib/types.d.ts.map +1 -0
  66. package/lib/utils.d.ts +52 -0
  67. package/lib/utils.d.ts.map +1 -0
  68. package/lib/utils.js +340 -0
  69. package/lib/utils.js.map +1 -0
  70. package/package.json +23 -9
  71. package/src/adapter.ts +25 -9
  72. package/src/app.ts +363 -258
  73. package/src/bot.ts +29 -8
  74. package/src/command.ts +50 -0
  75. package/src/component.ts +561 -0
  76. package/src/config.ts +9 -12
  77. package/src/cron.ts +176 -0
  78. package/src/errors.ts +365 -0
  79. package/src/index.ts +16 -13
  80. package/src/jsx-runtime.ts +12 -0
  81. package/src/jsx.d.ts +52 -0
  82. package/src/jsx.ts +92 -0
  83. package/src/message.ts +47 -0
  84. package/src/plugin.ts +148 -66
  85. package/src/prompt.ts +290 -0
  86. package/src/schema.ts +273 -0
  87. package/src/types-generator.ts +7 -3
  88. package/src/types.ts +80 -31
  89. package/src/utils.ts +313 -0
  90. package/tests/adapter.test.ts +36 -22
  91. package/tests/app.test.ts +30 -0
  92. package/tests/command.test.ts +545 -0
  93. package/tests/component-new.test.ts +348 -0
  94. package/tests/config.test.ts +1 -1
  95. package/tests/errors.test.ts +311 -0
  96. package/tests/expression-evaluation.test.ts +258 -0
  97. package/tests/message.test.ts +402 -0
  98. package/tests/plugin.test.ts +284 -143
  99. package/tests/utils.test.ts +80 -0
  100. package/tsconfig.json +3 -4
  101. package/dist/adapter.d.ts +0 -22
  102. package/dist/adapter.d.ts.map +0 -1
  103. package/dist/adapter.js.map +0 -1
  104. package/dist/app.d.ts +0 -69
  105. package/dist/app.d.ts.map +0 -1
  106. package/dist/app.js.map +0 -1
  107. package/dist/bot.d.ts +0 -9
  108. package/dist/bot.d.ts.map +0 -1
  109. package/dist/config.js.map +0 -1
  110. package/dist/index.d.ts +0 -9
  111. package/dist/index.d.ts.map +0 -1
  112. package/dist/index.js +0 -12
  113. package/dist/index.js.map +0 -1
  114. package/dist/logger.d.ts +0 -3
  115. package/dist/logger.d.ts.map +0 -1
  116. package/dist/logger.js +0 -3
  117. package/dist/logger.js.map +0 -1
  118. package/dist/plugin.d.ts +0 -41
  119. package/dist/plugin.d.ts.map +0 -1
  120. package/dist/plugin.js +0 -95
  121. package/dist/plugin.js.map +0 -1
  122. package/dist/types-generator.js.map +0 -1
  123. package/dist/types.d.ts +0 -69
  124. package/dist/types.d.ts.map +0 -1
  125. package/src/logger.ts +0 -3
  126. package/tests/logger.test.ts +0 -170
  127. package/tsconfig.tsbuildinfo +0 -1
  128. /package/{dist → lib}/bot.js +0 -0
  129. /package/{dist → lib}/bot.js.map +0 -0
  130. /package/{dist → lib}/config.d.ts +0 -0
  131. /package/{dist → lib}/types-generator.d.ts +0 -0
  132. /package/{dist → lib}/types.js +0 -0
  133. /package/{dist → lib}/types.js.map +0 -0
package/src/schema.ts ADDED
@@ -0,0 +1,273 @@
1
+ import { isEmpty } from './utils.js';
2
+
3
+ export class Schema<S = any, T = S> {
4
+ public [Symbol.toStringTag] = 'Schema';
5
+ constructor(
6
+ public meta: Schema.Meta<S, T>,
7
+ public options: Schema.Options = {},
8
+ ) {
9
+ const _this = this;
10
+ const schema = function (value?: S) {
11
+ const formatter = Schema.resolve(_this.meta.type);
12
+ if (!formatter) throw new Error(`type ${_this.meta.type} not found`);
13
+ return formatter.call(_this, value);
14
+ } as Schema<S, T>;
15
+ return new Proxy(schema, {
16
+ get(target, p: string | symbol, receiver: any): any {
17
+ return Reflect.get(_this, p, receiver);
18
+ },
19
+ set(target, p: string | symbol, value: any, receiver: any): boolean {
20
+ return Reflect.set(_this, p, value, receiver);
21
+ },
22
+ });
23
+ }
24
+ static fromJSON<S, T>(json: Schema.JSON<S, T>) {
25
+ const { object, inner, list, ...meta } = json;
26
+ const options: Schema.Options = {};
27
+ if (object)
28
+ options.object = Object.fromEntries(Object.entries(object).map(([key, value]) => [key, Schema.fromJSON(value)]));
29
+ if (inner) options.inner = Schema.fromJSON(inner);
30
+ return new Schema<S, T>(meta, options);
31
+ }
32
+ toJSON(): Record<string, any> {
33
+ return Object.fromEntries(
34
+ Object.entries({
35
+ ...this.meta,
36
+ default: typeof this.meta.default === 'function' ? this.meta.default() : this.meta.default,
37
+ inner: this.options.inner?.toJSON(),
38
+ dict: this.options.object
39
+ ? Object.fromEntries(Object.entries(this.options.object || {}).map(([key, value]) => [key, value.toJSON()]))
40
+ : undefined,
41
+ }).filter(([key, value]) => typeof value !== 'undefined'),
42
+ );
43
+ }
44
+ [Symbol.unscopables]() {
45
+ return {
46
+ options: true,
47
+ meta: true,
48
+ };
49
+ }
50
+ /** 设置是否必填 */
51
+ required(): this {
52
+ this.meta.required = true;
53
+ return this;
54
+ }
55
+ /** 是否隐藏 */
56
+ hidden(): this {
57
+ this.meta.hidden = true;
58
+ return this;
59
+ }
60
+ /** 设置描述 */
61
+ description(description: string): this {
62
+ this.meta.description = description;
63
+ return this;
64
+ }
65
+ /** 设置默认值 */
66
+ default(defaultValue: T): this {
67
+ this.meta.default = defaultValue;
68
+ return this;
69
+ }
70
+ /** 设置选项列表 */
71
+ option(list: (T | Schema.Option<T>)[]): this {
72
+ this.meta.options = Schema.formatOptionList(list);
73
+ return this;
74
+ }
75
+ /** 设置是否允许多选 */
76
+ multiple(): this {
77
+ if (this.meta.type !== 'list') throw new Error('multiple only support list type');
78
+ this.meta.multiple = true;
79
+ return this;
80
+ }
81
+ /** 声明一个数字类型 */
82
+ static number(description: string): Schema<number> {
83
+ return new Schema<number>({ type: 'number', description });
84
+ }
85
+ /** 声明一个字符串类型 */
86
+ static string(description: string): Schema<string> {
87
+ return new Schema<string>({ type: 'string', description });
88
+ }
89
+ /** 声明一个布尔类型 */
90
+ static boolean(description: string): Schema<boolean> {
91
+ return new Schema<boolean>({ type: 'boolean', description });
92
+ }
93
+ /** 声明一个正则类型 */
94
+ static regexp(description: string) {
95
+ return new Schema<RegExp | string, RegExp>({ type: 'regexp', description });
96
+ }
97
+ /** 声明一个日期类型 */
98
+ static date(description: string) {
99
+ return new Schema<Date | number, Date>({ type: 'date', description });
100
+ }
101
+ /** 声明一个字典类型 */
102
+ static dict<X extends Schema>(input: X, description: string) {
103
+ return new Schema<Record<string, Schema.Types<X>>>({ type: 'dict', description }, { inner: input });
104
+ }
105
+ static object<X extends Record<string, Schema>>(input: X, description: string = '') {
106
+ return new Schema<Schema.RecordTypes<X>>({ type: 'object', description }, { object: input });
107
+ }
108
+ /** 声明一个列表类型 */
109
+ static list<X extends Schema>(inner: X, description: string) {
110
+ return new Schema<Schema.Types<X>[]>({ type: 'list', description }, { inner });
111
+ }
112
+ /** 声明一个常量 */
113
+ static const<X extends string | number | boolean>(value: X, description: string) {
114
+ return new Schema<X>({ type: 'const', default: value as any, description });
115
+ }
116
+ static resolve<T extends string>(type: T): Schema.Formatter {
117
+ return Schema.formatters.get(type)!;
118
+ }
119
+ static extend<T extends string>(type: T, formatter: Schema.Formatter) {
120
+ Schema.formatters.set(type, formatter);
121
+ }
122
+ }
123
+ export interface Schema<S = any> {
124
+ (value?: S): S;
125
+ }
126
+ export namespace Schema {
127
+ export const formatters: Map<string, Formatter> = new Map<string, Formatter>();
128
+ export type Formatter<S = any, T = S> = (this: Schema, value: S) => T;
129
+ export type JSON<S = any, T = S> = Meta<S, T> & {
130
+ object?: Record<string, JSON>;
131
+ inner?: JSON;
132
+ list?: JSON[];
133
+ };
134
+ export interface Meta<S = any, T = S> {
135
+ hidden?: boolean;
136
+ type: string;
137
+ default?: T;
138
+ required?: boolean;
139
+ options?: Option<T>[];
140
+ multiple?: boolean;
141
+ description: string;
142
+ component?: string;
143
+ min?: number;
144
+ max?: number;
145
+ step?: number;
146
+ }
147
+ export interface Options {
148
+ object?: Record<string, Schema>;
149
+ inner?: Schema;
150
+ }
151
+ export type Types<T> = T extends Schema<infer S> ? S : never;
152
+ export type RecordTypes<T> = T extends Record<string, Schema>
153
+ ? {
154
+ [K in keyof T]?: Types<T[K]>;
155
+ }
156
+ : unknown;
157
+ export function checkDefault<T>(schema: Schema, value: T, fallback: T = value) {
158
+ if (isEmpty(value)) {
159
+ value = schema.meta.default || fallback;
160
+ }
161
+ const validateType = (schema: Schema, value: any) => {
162
+ switch (schema.meta.type) {
163
+ case 'string':
164
+ if (!['string', 'undefined'].includes(typeof value)) throw new TypeError(`value is not a string`);
165
+ break;
166
+ case 'number':
167
+ if (!['number', 'undefined'].includes(typeof value)) throw new TypeError(`value is not a number`);
168
+ break;
169
+ case 'boolean':
170
+ if (!['boolean', 'undefined'].includes(typeof value)) throw new TypeError(`value is not a boolean`);
171
+ break;
172
+ case 'regexp':
173
+ if (!['string', 'undefined'].includes(typeof value) && !(value instanceof RegExp))
174
+ throw new TypeError(`value is not a RegExp|string`);
175
+ break;
176
+ case 'date':
177
+ if (!['number', 'undefined'].includes(typeof value) && !(value instanceof Date))
178
+ throw new TypeError(`value is not a Date|number`);
179
+ if (value instanceof Date && isNaN(value.getTime())) throw new TypeError(`value is not a valid Date`);
180
+ break;
181
+ case 'dict':
182
+ if (!['object', 'undefined', 'null'].includes(typeof value)) throw new TypeError(`value is not a object`);
183
+ break;
184
+ case 'object':
185
+ if (!['object', 'undefined', 'null'].includes(typeof value)) throw new TypeError(`value is not a object`);
186
+ break;
187
+ case 'list':
188
+ if (typeof value !== 'undefined' && !Array.isArray(value)) throw new TypeError(`value is not a list`);
189
+ break;
190
+ case 'const':
191
+ if (typeof value !== 'undefined' && value !== schema.meta.default) throw new TypeError(`value is not const`);
192
+ break;
193
+ default:
194
+ throw new TypeError(`value is not a valid type`);
195
+ }
196
+ };
197
+ if (schema.meta.required && typeof value === 'undefined') throw new Error(`value is required`);
198
+ validateType(schema, value);
199
+ return value;
200
+ }
201
+ export type Option<T = any> = {
202
+ label: string;
203
+ value: T;
204
+ };
205
+ export function formatOptionList<T extends (any | Schema.Option)[]>(list: T): Schema.Option[] {
206
+ return list.map(item => {
207
+ if (typeof item === 'string') {
208
+ return {
209
+ label: `${item}`,
210
+ value: item,
211
+ } as Schema.Option;
212
+ }
213
+ return item as unknown as Schema.Option;
214
+ });
215
+ }
216
+ }
217
+ Schema.extend('number', function (this: Schema, value: any) {
218
+ value = Schema.checkDefault(this, value);
219
+ return value;
220
+ });
221
+ Schema.extend('string', function (this: Schema, value: any) {
222
+ value = Schema.checkDefault(this, value);
223
+ return value;
224
+ });
225
+ Schema.extend('boolean', function (this: Schema, value: any) {
226
+ return Schema.checkDefault(this, value);
227
+ });
228
+ Schema.extend('dict', function (this: Schema, value: any) {
229
+ value = Schema.checkDefault(this, value, {});
230
+ return Object.fromEntries(
231
+ Object.entries(value).map(([key, schema]) => {
232
+ return [key, this.options.inner!(schema)];
233
+ }),
234
+ );
235
+ });
236
+
237
+ Schema.extend('object', function (this: Schema, value: any) {
238
+ const getDefault = (schema: Schema) => {
239
+ const result = Object.create(null);
240
+ for (const key in schema.options.object) {
241
+ result[key] = getDefault(schema.options.object[key]);
242
+ }
243
+ return result;
244
+ };
245
+ value = Schema.checkDefault(this, value, getDefault(this));
246
+ return Object.fromEntries(
247
+ Object.entries(value).map(([key, schema]) => {
248
+ return [key, this.options.object![key](schema)];
249
+ }),
250
+ );
251
+ });
252
+ Schema.extend('list', function (this: Schema, value: any) {
253
+ value = Schema.checkDefault(this, value, []);
254
+ return value.map((item: any) => this.options.inner!(item));
255
+ });
256
+ Schema.extend('regexp', function (this: Schema, value: any) {
257
+ value = Schema.checkDefault(this, value);
258
+ if (typeof value === 'string') {
259
+ return new RegExp(value);
260
+ }
261
+ return value;
262
+ });
263
+ Schema.extend('date', function (this: Schema, value: any) {
264
+ value = Schema.checkDefault(this, value);
265
+ return new Date(value);
266
+ });
267
+ Schema.extend('const', function (this: Schema, value: any) {
268
+ value = Schema.checkDefault(this, value);
269
+ if (value !== this.meta.default) {
270
+ throw new Error('const value not match');
271
+ }
272
+ return value;
273
+ });
@@ -1,6 +1,8 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
- import { logger } from './logger.js';
3
+ import { getLogger } from '@zhin.js/logger';
4
+
5
+ const logger = getLogger('TypesGenerator');
4
6
 
5
7
  /**
6
8
  * 更新 tsconfig.json 的类型声明
@@ -48,7 +50,7 @@ export async function generateEnvTypes(cwd: string): Promise<void> {
48
50
  try {
49
51
  tsconfig = JSON.parse(fs.readFileSync(tsconfigPath, 'utf-8'));
50
52
  } catch (err) {
51
- console.error(err)
53
+ // console.error 已替换为注释
52
54
  logger.warn('⚠️ Failed to parse tsconfig.json, creating new one');
53
55
  }
54
56
  }
@@ -69,6 +71,8 @@ export async function generateEnvTypes(cwd: string): Promise<void> {
69
71
  fs.writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 2), 'utf-8');
70
72
  logger.info('✅ Updated TypeScript types configuration');
71
73
  } catch (error) {
72
- logger.warn('⚠️ Failed to update TypeScript types:', error);
74
+ logger.warn('⚠️ Failed to update TypeScript types', {
75
+ error: error instanceof Error ? error.message : String(error)
76
+ });
73
77
  }
74
78
  }
package/src/types.ts CHANGED
@@ -1,36 +1,81 @@
1
1
  import {MaybePromise}from '@zhin.js/types'
2
+ import {MessageChannel} from "./message.js";
3
+ import {Adapter} from "./adapter.js";
4
+ import {Bot,BotConfig} from "./bot.js";
5
+ import { Databases,Registry } from "@zhin.js/database";
6
+ import { MessageComponent } from "./message.js";
2
7
 
3
- export interface MessageSegment<T extends keyof Segment=keyof Segment> {
4
- type: T;
5
- data: Segment[T];
8
+ /**
9
+ * 类型定义文件:包含适配器、消息、数据库、配置等核心类型声明。
10
+ * 协作者可通过本文件了解各主要数据结构的用途与关系。
11
+ */
12
+ declare module '@zhin.js/types'{
13
+ interface GlobalContext extends RegisteredAdapters{}
6
14
  }
7
- export interface Segment{
8
- [key:string]:Record<string, any>
9
- any:Record<string, any>
15
+ /**
16
+ * 所有已注册适配器的类型映射(key为适配器名,value为Adapter实例)
17
+ */
18
+ export interface RegisteredAdapters extends Record<string, Adapter>{}
19
+ /**
20
+ * 数据库配置类型,支持多种数据库驱动
21
+ */
22
+ export type DatabaseConfig<T extends keyof Databases=keyof Databases>={
23
+ dialect:T
24
+ } & Registry.Config<Databases[T]>
25
+ /**
26
+ * 获取对象所有value类型
27
+ */
28
+ export type ObjectItem<T extends object>=T[keyof T]
29
+ /**
30
+ * 已注册适配器名类型
31
+ */
32
+ export type RegisteredAdapter=keyof RegisteredAdapters
33
+ /**
34
+ * 指定适配器的消息类型
35
+ */
36
+ export type AdapterMessage<T extends keyof RegisteredAdapters=keyof RegisteredAdapters>=RegisteredAdapters[T] extends Adapter<infer R>?BotMessage<R>:{}
37
+ /**
38
+ * 指定适配器的配置类型
39
+ */
40
+ export type AdapterConfig<T extends keyof RegisteredAdapters=keyof RegisteredAdapters>=RegisteredAdapters[T] extends Adapter<infer R>?PlatformConfig<R>:BotConfig
41
+ /**
42
+ * Bot实例的配置类型
43
+ */
44
+ export type PlatformConfig<T>=T extends Bot<infer L,infer R>?R:BotConfig
45
+ /**
46
+ * Bot实例的消息类型
47
+ */
48
+ export type BotMessage<T extends Bot>=T extends Bot<infer R>?R:{}
49
+ /**
50
+ * 消息段结构,支持 text/image/at/face 等类型
51
+ */
52
+ export interface MessageSegment {
53
+ type: string;
54
+ data: Record<string, any>;
10
55
  }
56
+ export type MessageElement=MessageSegment|MessageComponent<any>
57
+ /**
58
+ * 单个或数组类型
59
+ */
11
60
  export type MaybeArray<T>=T|T[]
12
- export type SendContent=MaybeArray<string|MessageSegment>
61
+ /**
62
+ * 消息发送内容类型
63
+ */
64
+ export type SendContent=MaybeArray<string|MessageElement>
65
+ /**
66
+ * 消息发送者信息
67
+ */
13
68
  export interface MessageSender{
14
69
  id: string;
15
70
  name?: string;
16
71
  }
17
- export type MessageComponent<T extends object>=(props:T&{children:SendContent})=>MaybePromise<SendContent>
18
- export interface MessageChannel{
19
- id: string;
20
- type: 'group' | 'private' | 'channel';
21
- }
22
- export interface Message {
23
- id: string;
24
- adapter:string
25
- bot:string
26
- content: MessageSegment[];
27
- sender: MessageSender;
28
- reply(content:SendContent,quote?:boolean|string):Promise<void>
29
- channel: MessageChannel;
30
- timestamp: number;
31
- raw: string;
32
- }
33
-
72
+ /**
73
+ * 通用字典类型
74
+ */
75
+ export type Dict<V=any,K extends string|symbol=string>=Record<K, V>;
76
+ /**
77
+ * 用户信息结构
78
+ */
34
79
  export interface User {
35
80
  user_id: string;
36
81
  nickname: string;
@@ -38,23 +83,24 @@ export interface User {
38
83
  role?: string;
39
84
  }
40
85
 
86
+ /**
87
+ * 群组信息结构
88
+ */
41
89
  export interface Group {
42
90
  group_id: string;
43
91
  group_name: string;
44
92
  member_count: number;
45
93
  }
46
94
 
47
- export interface BotConfig {
48
- name: string;
49
- context: string;
50
- [key: string]: any;
51
- }
52
-
53
-
54
95
 
96
+ /**
97
+ * App配置类型,涵盖机器人、数据库、插件、调试等
98
+ */
55
99
  export interface AppConfig {
56
100
  /** 机器人配置列表 */
57
101
  bots?: BotConfig[];
102
+ /** 数据库配置列表 */
103
+ database?: DatabaseConfig;
58
104
  /** 插件目录列表,默认为 ['./plugins', 'node_modules'] */
59
105
  plugin_dirs?: string[];
60
106
  /** 需要加载的插件列表 */
@@ -64,6 +110,9 @@ export interface AppConfig {
64
110
  /** 是否启用调试模式 */
65
111
  debug?: boolean;
66
112
  }
113
+ /**
114
+ * defineConfig辅助类型,支持函数式/对象式配置
115
+ */
67
116
  export type DefineConfig<T> = T | ((env:Record<string,string>)=>MaybePromise<T>);
68
117
 
69
118
  export interface SendOptions extends MessageChannel{