bilitoolkit-types 0.0.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 hzhilong
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.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # bilitoolkit-types
2
+
3
+ [哔哩工具姬](https://github.com/hzhilong/bilitoolkit) 类型库。
@@ -0,0 +1,559 @@
1
+ import { BiliClientConfig, BiliClient, BaseService, BaseApi, UserCard, UserInfoWithCookie, UserCookie } from '@ybgnb/bili-api';
2
+ import { FunctionKeys, BizResult, LogLevel, CommonError, Logger } from '@ybgnb/utils';
3
+
4
+ /**
5
+ * bili-api 客户端配置(用于主进程代理发起 bili-api )
6
+ */
7
+ interface BiliApiClientConfig extends Omit<BiliClientConfig, 'logging' | 'logLevel'> {
8
+ id: string;
9
+ referer: string;
10
+ }
11
+ /**
12
+ * bili-api 接口方法(用于主进程代理发起 bili-api )
13
+ */
14
+ type BiliApiMethod = {
15
+ [K in keyof BiliClient]: BiliClient[K] extends BaseService | BaseApi ? BiliClient[K][FunctionKeys<BiliClient[K]>] : never;
16
+ }[keyof BiliClient];
17
+ /**
18
+ * bili-api 的层级代理对象类型(用于主进程创建代理,保留类→方法的嵌套结构)
19
+ * 例如:const proxy: BiliApiProxy = { UserService: { getUser: ... } }
20
+ */
21
+ type BiliApiProxy = {
22
+ [K in keyof BiliClient]: BiliClient[K] extends BaseService | BaseApi ? Pick<BiliClient[K], FunctionKeys<BiliClient[K]>> : never;
23
+ };
24
+ /**
25
+ * api 代理的上下文
26
+ */
27
+ interface ApiProxyContext {
28
+ /** 由createBiliClient创建的客户端id */
29
+ clientId: string;
30
+ /** 中止信号(自己传一个唯一ID) */
31
+ abortSignalId?: AbortSignalId;
32
+ }
33
+ /**
34
+ * api 终止信号
35
+ */
36
+ type AbortSignalId = string;
37
+
38
+ /**
39
+ * bili API
40
+ */
41
+ interface ToolkitBiliApi {
42
+ /**
43
+ * 创建接口请求的客户端
44
+ * @description 用于后续主线程发起bili接口请求(可操作多用户)
45
+ */
46
+ createBiliClient(config?: Partial<Omit<BiliApiClientConfig, 'id'>>): Promise<BiliApiClientConfig>;
47
+ /**
48
+ * 调用 bili-api 方法(由主线程发起请求,所以可以操作多用户)
49
+ * @param context api 代理的上下文
50
+ * @param apiInvokePath api 调用路径(可传入服务方法 client.xxxService.xxx 或者基础请求方法 client.api.xxx,不包含'client.',
51
+ * @param args api 方法参数
52
+ * @description 建议使用 bilitoolkit-api-runtime 包装的方法 createBiliClient 创建客户端后以函数式调用接口。
53
+ * @example await api(null, c.user.getUserCards, 22)
54
+ */
55
+ invokeBiliApi<AM extends BiliApiMethod>(context: ApiProxyContext, apiInvokePath: AM, ...args: Parameters<AM>): Promise<BizResult<Awaited<ReturnType<AM>>>>;
56
+ /**
57
+ * 终止 bili-api 请求
58
+ * @param abortSignalId 终止信号 ID
59
+ */
60
+ abortBiliApi(abortSignalId: AbortSignalId): Promise<void>;
61
+ }
62
+
63
+ /**
64
+ * 数据库相关的API(当前插件所属的数据库)
65
+ */
66
+ interface ToolkitDBApi {
67
+ /**
68
+ * 获取当前环境的根目录路径
69
+ */
70
+ getRootDir(): Promise<string>;
71
+ /**
72
+ * 判断是否存在该文档
73
+ * @param id 文档id
74
+ */
75
+ has(id: string): Promise<boolean>;
76
+ /**
77
+ * 读取文档
78
+ * @param id 文档id
79
+ */
80
+ read<T extends object>(id: string): Promise<T | null>;
81
+ /**
82
+ * 初始化文档
83
+ * @param id 文档id
84
+ * @param defaultData 文档默认内容
85
+ */
86
+ init<T extends object>(id: string, defaultData?: T): Promise<T | null>;
87
+ /**
88
+ * 批量读取文档
89
+ * @param idPrefix 文档id前缀,为空则获取所有
90
+ */
91
+ bulkRead<T extends object>(idPrefix?: string): Promise<Array<T | null>>;
92
+ /**
93
+ * 写入文档
94
+ * @param id 文档id
95
+ * @param data 文档内容
96
+ */
97
+ write<T extends object>(id: string, data: T): Promise<void>;
98
+ /**
99
+ * 批量写入文档
100
+ * @param docs 文档
101
+ */
102
+ bulkWrite<T extends object>(docs: {
103
+ id: string;
104
+ data: T;
105
+ }[]): Promise<void>;
106
+ /**
107
+ * 删除文档
108
+ * @param id 文档id
109
+ */
110
+ delete(id: string): Promise<void>;
111
+ /**
112
+ * 批量删除文档
113
+ * @param idPrefix 文档id前缀,为空则删除所有
114
+ */
115
+ bulkDelete(idPrefix?: string): Promise<string[]>;
116
+ }
117
+
118
+ /**
119
+ * 应用主题模式
120
+ */
121
+ type AppThemeMode = 'light' | 'dark' | 'system';
122
+ /**
123
+ * 应用主题背景模式 默认|跟随主题色
124
+ */
125
+ type AppThemeBackgroundMode = 'default' | 'follow-primary';
126
+ /**
127
+ * 应用主题状态
128
+ */
129
+ interface AppThemeState {
130
+ primaryColorIndex: number;
131
+ primaryColor: string;
132
+ themeMode: AppThemeMode;
133
+ bgMode: AppThemeBackgroundMode;
134
+ dark: boolean;
135
+ }
136
+
137
+ /**
138
+ * 事件相关的API(单向通信)
139
+ */
140
+ interface ToolkitEventApi {
141
+ /**
142
+ * 监听窗口显示(需要首次进入监听的话,需要使用preload.js)
143
+ */
144
+ onWindowShown(listener: () => void): Promise<void>;
145
+ /**
146
+ * 监听应用主题变化
147
+ */
148
+ onUpdateAppTheme(listener: (theme: AppThemeState) => void): Promise<void>;
149
+ /**
150
+ * 监听用户退出
151
+ */
152
+ onUserLogout(listener: (user: UserCard) => void): Promise<void>;
153
+ /**
154
+ * 监听事件
155
+ */
156
+ on(eventName: string, listener: (...data: unknown[]) => void): Promise<void>;
157
+ /**
158
+ * 发射事件
159
+ */
160
+ emit(eventName: string, ...data: unknown[]): Promise<void>;
161
+ }
162
+
163
+ /**
164
+ * 文件相关的API(当前插件所属的文件夹)
165
+ */
166
+ interface ToolkitFileApi {
167
+ /**
168
+ * 获取当前环境的根目录路径
169
+ */
170
+ getRootDir(): Promise<string>;
171
+ /**
172
+ * 判断是否文件是否存在
173
+ */
174
+ exists(filePath: string): Promise<boolean>;
175
+ /**
176
+ * 读取文件
177
+ */
178
+ read(filePath: string): Promise<Uint8Array>;
179
+ /**
180
+ * 写入文件
181
+ */
182
+ write(filePath: string, content: Uint8Array): Promise<void>;
183
+ /**
184
+ * 分块写入
185
+ */
186
+ writeChunk(filePath: string, content: Uint8Array, position?: number): Promise<void>;
187
+ /**
188
+ * 删除文件,不存在会抛异常
189
+ */
190
+ delete(filePath: string): Promise<void>;
191
+ /**
192
+ * 批量删除文件
193
+ */
194
+ bulkDelete(filePaths: string[]): Promise<void>;
195
+ /**
196
+ * 打开文件,返回可用于读写操作的文件句柄。
197
+ * @param filePath - 文件的相对路径(相对于 getRootDir())
198
+ * @param flags 打开模式
199
+ */
200
+ open(filePath: string, flags?: string | number): Promise<FileHandle>;
201
+ }
202
+ /**
203
+ * 文件句柄(适合分块读写大文件)
204
+ */
205
+ interface FileHandle {
206
+ /** 将数据写入文件 */
207
+ write(data: Uint8Array): Promise<void>;
208
+ /** 将缓冲区数据强制写入磁盘 */
209
+ flush(): Promise<void>;
210
+ /** 从当前偏移量读取指定大小的数据,返回读取结果(包含数据和实际读取字节数) */
211
+ read(size?: number): Promise<FileReadResult>;
212
+ /** 移动文件读写指针到指定位置 */
213
+ seek(offset: number, whence?: FileSeekWhence): Promise<void>;
214
+ /** 获取文件状态(如大小、修改时间等) */
215
+ stat(): Promise<FileStat>;
216
+ /**
217
+ * 获取当前文件偏移量
218
+ */
219
+ tell(): Promise<number>;
220
+ /** 关闭文件句柄,释放资源 */
221
+ close(): Promise<void>;
222
+ }
223
+ type FileSeekWhence = 'start' | 'current' | 'end';
224
+ interface FileReadResult {
225
+ data: Uint8Array;
226
+ eof: boolean;
227
+ }
228
+ interface FileStat {
229
+ size: number;
230
+ createdAt?: number;
231
+ modifiedAt?: number;
232
+ isFile?: boolean;
233
+ isDirectory?: boolean;
234
+ }
235
+
236
+ /**
237
+ * 全局数据的API(同窗口)
238
+ * _get开头的是通过具体名称获取,其他get开头的都是直接获取具体的数据
239
+ */
240
+ interface ToolkitGlobalDataApi {
241
+ /**
242
+ * 获取应用全局数据
243
+ * @param name 数据名称
244
+ * @param timeout 超时处理
245
+ * @param args 参数
246
+ */
247
+ getData(name: string, timeout: boolean, ...args: any[]): Promise<unknown>;
248
+ /**
249
+ * 获取插件全局数据
250
+ * @param pluginId 插件id
251
+ * @param name 数据名称
252
+ * @param timeout 超时处理
253
+ * @param args 参数
254
+ */
255
+ getPluginData(pluginId: string, name: string, timeout: boolean, ...args: any[]): Promise<unknown>;
256
+ /**
257
+ * 注册全局数据
258
+ * @param name
259
+ * @param getFn
260
+ */
261
+ register(name: string, getFn: (...args: any[]) => Promise<BizResult<any>>): Promise<void>;
262
+ }
263
+
264
+ interface AppLog {
265
+ level: LogLevel;
266
+ data: string[];
267
+ }
268
+
269
+ /**
270
+ * 系统相关的API
271
+ */
272
+ interface ToolkitSystemApi {
273
+ /**
274
+ * ping
275
+ * 主进程返回 true
276
+ */
277
+ ping(): Promise<boolean>;
278
+ /**
279
+ * 使用系统默认浏览器浏览网页
280
+ */
281
+ browsePage(path: string): Promise<void>;
282
+ /**
283
+ * 打开资源管理器并定位到文件或者文件夹
284
+ */
285
+ showItemInFolder(path: string): Promise<void>;
286
+ /**
287
+ * 保存日志
288
+ */
289
+ saveLog(appLog: AppLog): Promise<void>;
290
+ /**
291
+ * 获取日志级别
292
+ */
293
+ getLogLevel(): Promise<LogLevel>;
294
+ /**
295
+ * 系统是否处于深色模式(系统模式,非应用设置)
296
+ */
297
+ shouldUseDarkColors(): Promise<boolean>;
298
+ /**
299
+ * 获取应用主题状态
300
+ */
301
+ getAppThemeState(): Promise<AppThemeState>;
302
+ }
303
+
304
+ /**
305
+ * 定时器类型:延迟/间隔
306
+ */
307
+ type TimerType = 'delay' | 'interval';
308
+ /**
309
+ * 定时器 ID
310
+ */
311
+ type TimerId = string;
312
+ /**
313
+ * 定时器选项
314
+ */
315
+ interface TimerOptions {
316
+ /** 定时器 ID,请自己生成ID,至少在自己环境的是唯一 */
317
+ timerId: TimerId;
318
+ /** 定时器类型 */
319
+ type: TimerType;
320
+ /** 持续时间/间隔时间 ms */
321
+ duration: number;
322
+ /** 问询的超时时间,默认 500ms */
323
+ ackTimeout?: number;
324
+ }
325
+ /**
326
+ * 定时器回调
327
+ */
328
+ interface TimerCallback {
329
+ /**
330
+ * 定时器触发监听器
331
+ * @return 是否成功确认本次触发请求。
332
+ * 返回 false 表示当前渲染进程不可继续处理该定时器,主进程应取消该定时器。
333
+ */
334
+ onTrigger: () => Promise<boolean>;
335
+ }
336
+ /**
337
+ * 定时器 API(不能保证精确时间)
338
+ */
339
+ interface ToolkitTimerApi {
340
+ /**
341
+ * 注册定时器
342
+ * @param options 定时器选项
343
+ * @param callback 定时器回调
344
+ */
345
+ register(options: TimerOptions, callback: TimerCallback): Promise<void>;
346
+ /**
347
+ * 取消定时器
348
+ * @param timerId
349
+ */
350
+ cancel(timerId: TimerId): Promise<void>;
351
+ }
352
+
353
+ /**
354
+ * 用户 API
355
+ */
356
+ interface ToolkitUserApi {
357
+ /**
358
+ * 切换用户
359
+ * @param injectCookie 切换成功后,是否往浏览器环境注入用cookie
360
+ * @default false
361
+ */
362
+ switchUser(injectCookie?: boolean): Promise<UserInfoWithCookie>;
363
+ /**
364
+ * 删除当前浏览器环境的用户cookie
365
+ */
366
+ delCurrUserCookie(): Promise<void>;
367
+ /**
368
+ * 获取用户 cookie
369
+ */
370
+ getCurrUserCookie(): Promise<string[]>;
371
+ /**
372
+ * 切换当前用户
373
+ * @description 切换成功后,会往浏览器环境注入用cookie
374
+ */
375
+ switchCurrUser(user: UserInfoWithCookie): Promise<void>;
376
+ /**
377
+ * 通过用户cookie获取用户信息,可用于检测cookie有效性
378
+ */
379
+ getMyInfoByCookie(userCookie: UserCookie): Promise<UserInfoWithCookie>;
380
+ }
381
+
382
+ /**
383
+ * 窗口相关的API
384
+ */
385
+ interface ToolkitWindowApi {
386
+ /**
387
+ * 最小化窗口
388
+ */
389
+ minimize(): Promise<void>;
390
+ /**
391
+ * 最大化窗口
392
+ * @param max 最大化/取消最大化
393
+ */
394
+ maximize(max: boolean): Promise<void>;
395
+ /**
396
+ * 关闭窗口
397
+ */
398
+ close(): Promise<void>;
399
+ }
400
+
401
+ /**
402
+ * 工具箱全局 API 定义
403
+ */
404
+ interface ToolkitApi {
405
+ /**
406
+ * 窗口管理 API
407
+ */
408
+ window: ToolkitWindowApi;
409
+ /**
410
+ * 系统级别的 API
411
+ */
412
+ system: ToolkitSystemApi;
413
+ /**
414
+ * 数据库 API
415
+ */
416
+ db: ToolkitDBApi;
417
+ /**
418
+ * 文件 API
419
+ */
420
+ file: ToolkitFileApi;
421
+ /**
422
+ * 用户 API
423
+ */
424
+ user: ToolkitUserApi;
425
+ /**
426
+ * bili API
427
+ */
428
+ bili: ToolkitBiliApi;
429
+ /**
430
+ * 事件 API
431
+ */
432
+ event: ToolkitEventApi;
433
+ /**
434
+ * 全局数据 API
435
+ */
436
+ global: ToolkitGlobalDataApi;
437
+ /**
438
+ * 定时器 API
439
+ */
440
+ timer: ToolkitTimerApi;
441
+ }
442
+
443
+ /**
444
+ * APP 业务逻辑错误(不打印调用栈)
445
+ */
446
+ declare class AppError extends CommonError {
447
+ constructor(message: string, cause?: unknown);
448
+ }
449
+ declare function convertToAppError(error: unknown, prefix?: string): AppError;
450
+
451
+ /**
452
+ * 任务配置结构定义(用于描述用户可填写的字段)
453
+ */
454
+ interface TaskConfigSchema<T extends readonly TaskConfigField[] = any> {
455
+ fields: T;
456
+ }
457
+ /**
458
+ * 单个配置字段定义
459
+ */
460
+ interface TaskConfigField<Name extends string = string> {
461
+ /** 字段唯一标识(对应 config 中的 key) */
462
+ name: Name;
463
+ /** 字段显示名称 */
464
+ label: string;
465
+ /** 字段类型 */
466
+ type: 'user' | 'users' | 'input' | 'textarea' | 'number' | 'select' | 'checkbox' | 'switch';
467
+ /** 是否必填 */
468
+ required?: boolean;
469
+ /** 默认值 */
470
+ default?: any;
471
+ /** 可选项(用于 select 等) */
472
+ options?: {
473
+ label: string;
474
+ value: any;
475
+ }[];
476
+ /** 字段描述(用于提示) */
477
+ description?: string;
478
+ /** 验证的正则 */
479
+ regex?: string;
480
+ }
481
+ /** 根据字段定义数组推导出配置对象类型(以 name 为 key 的联合类型) */
482
+ type InferConfig<T extends readonly TaskConfigField[]> = {
483
+ [K in T[number]['name']]: any;
484
+ };
485
+
486
+ /**
487
+ * 任务调度配置
488
+ */
489
+ type TaskSchedule = {
490
+ /** cron 表达式调度 */
491
+ type: 'cron';
492
+ /** cron 表达式 */
493
+ value: string;
494
+ } | {
495
+ /** 固定间隔调度 */
496
+ type: 'interval';
497
+ /** 间隔时间(秒) */
498
+ value: string;
499
+ };
500
+
501
+ type TaskPluginToolkitApi = Omit<ToolkitApi, 'window' | 'user' | 'bili'>;
502
+ /**
503
+ * 任务执行上下文
504
+ */
505
+ interface TaskContext<C = Record<string, any>> {
506
+ /** 用户填写的配置 */
507
+ config?: C;
508
+ /** 日志记录器 */
509
+ logger: Logger;
510
+ /** 工具 API */
511
+ api: TaskPluginToolkitApi;
512
+ /**
513
+ * 取消信号
514
+ */
515
+ signal?: AbortSignal;
516
+ }
517
+ /**
518
+ * 任务执行结果
519
+ */
520
+ interface TaskResult {
521
+ /** 是否执行成功 */
522
+ success: boolean;
523
+ /** 简要信息 */
524
+ message: string;
525
+ /** 详情,支持html */
526
+ details?: string;
527
+ }
528
+ /**
529
+ * 定时任务插件接口
530
+ */
531
+ interface TaskPlugin<T extends readonly TaskConfigField[] = any> {
532
+ /**
533
+ * 任务配置结构定义(已改成从plugin-meta.json读取)
534
+ */
535
+ /**
536
+ * 获取调度配置(已改成从plugin-meta.json读取)
537
+ * - 不提供则表示该任务仅支持手动执行
538
+ */
539
+ /**
540
+ * 执行任务
541
+ */
542
+ run(context: TaskContext<InferConfig<T>>): Promise<TaskResult>;
543
+ }
544
+ /**
545
+ * 任务插件元信息
546
+ */
547
+ interface TaskPluginMeta<T extends readonly TaskConfigField[] = any> {
548
+ /**
549
+ * 任务配置结构定义
550
+ */
551
+ taskConfigSchema?: TaskConfigSchema<T>;
552
+ /**
553
+ * 调度配置
554
+ * - 不提供则表示该任务仅支持手动执行
555
+ */
556
+ taskSchedule?: TaskSchedule;
557
+ }
558
+
559
+ export { type AbortSignalId, type ApiProxyContext, AppError, type AppLog, type AppThemeBackgroundMode, type AppThemeMode, type AppThemeState, type BiliApiClientConfig, type BiliApiMethod, type BiliApiProxy, type FileHandle, type FileReadResult, type FileSeekWhence, type FileStat, type InferConfig, type TaskConfigField, type TaskConfigSchema, type TaskContext, type TaskPlugin, type TaskPluginMeta, type TaskPluginToolkitApi, type TaskResult, type TaskSchedule, type TimerCallback, type TimerId, type TimerOptions, type TimerType, type ToolkitApi, type ToolkitBiliApi, type ToolkitDBApi, type ToolkitEventApi, type ToolkitFileApi, type ToolkitGlobalDataApi, type ToolkitSystemApi, type ToolkitTimerApi, type ToolkitUserApi, type ToolkitWindowApi, convertToAppError };
package/dist/index.js ADDED
@@ -0,0 +1,20 @@
1
+ // src/types/api/bili-api-invoke.ts
2
+ import "@ybgnb/bili-api";
3
+
4
+ // src/types/common/app-error.ts
5
+ import { CommonError, getErrorMessage } from "@ybgnb/utils";
6
+ var AppError = class extends CommonError {
7
+ constructor(message, cause) {
8
+ super(message, cause);
9
+ this.name = new.target.name;
10
+ Object.setPrototypeOf(this, new.target.prototype);
11
+ }
12
+ };
13
+ function convertToAppError(error, prefix) {
14
+ return new AppError(`${prefix} ${getErrorMessage(error)}`, error);
15
+ }
16
+ export {
17
+ AppError,
18
+ convertToAppError
19
+ };
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/types/api/bili-api-invoke.ts","../src/types/common/app-error.ts"],"sourcesContent":["import { BaseApi, BaseService, BiliClient, type BiliClientConfig } from '@ybgnb/bili-api'\nimport type { FunctionKeys } from '@ybgnb/utils'\n\n/**\n * bili-api 客户端配置(用于主进程代理发起 bili-api )\n */\nexport interface BiliApiClientConfig extends Omit<BiliClientConfig, 'logging' | 'logLevel'> {\n id: string\n // 请求头的 referer\n referer: string\n}\n\n/**\n * bili-api 接口方法(用于主进程代理发起 bili-api )\n */\nexport type BiliApiMethod = {\n [K in keyof BiliClient]: BiliClient[K] extends BaseService | BaseApi\n ? BiliClient[K][FunctionKeys<BiliClient[K]>]\n : never\n}[keyof BiliClient]\n\n/**\n * bili-api 的层级代理对象类型(用于主进程创建代理,保留类→方法的嵌套结构)\n * 例如:const proxy: BiliApiProxy = { UserService: { getUser: ... } }\n */\nexport type BiliApiProxy = {\n [K in keyof BiliClient]: BiliClient[K] extends BaseService | BaseApi\n ? Pick<BiliClient[K], FunctionKeys<BiliClient[K]>>\n : never\n}\n\n/**\n * api 代理的上下文\n */\nexport interface ApiProxyContext {\n /** 由createBiliClient创建的客户端id */\n clientId: string\n /** 中止信号(自己传一个唯一ID) */\n abortSignalId?: AbortSignalId\n}\n\n/**\n * api 终止信号\n */\nexport type AbortSignalId = string\n","import { CommonError, getErrorMessage } from '@ybgnb/utils'\n\n/**\n * APP 业务逻辑错误(不打印调用栈)\n */\nexport class AppError extends CommonError {\n constructor(message: string, cause?: unknown) {\n super(message, cause)\n\n this.name = new.target.name\n Object.setPrototypeOf(this, new.target.prototype)\n }\n}\n\nexport function convertToAppError(error: unknown, prefix?: string) {\n return new AppError(`${prefix} ${getErrorMessage(error)}`, error)\n}\n"],"mappings":";AAAA,OAAwE;;;ACAxE,SAAS,aAAa,uBAAuB;AAKtC,IAAM,WAAN,cAAuB,YAAY;AAAA,EACxC,YAAY,SAAiB,OAAiB;AAC5C,UAAM,SAAS,KAAK;AAEpB,SAAK,OAAO,WAAW;AACvB,WAAO,eAAe,MAAM,WAAW,SAAS;AAAA,EAClD;AACF;AAEO,SAAS,kBAAkB,OAAgB,QAAiB;AACjE,SAAO,IAAI,SAAS,GAAG,MAAM,IAAI,gBAAgB,KAAK,CAAC,IAAI,KAAK;AAClE;","names":[]}
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "bilitoolkit-types",
3
+ "version": "0.0.1",
4
+ "author": "hzhilong",
5
+ "description": "『哔哩工具姬』类型库",
6
+ "type": "module",
7
+ "types": "./dist/index.d.ts",
8
+ "module": "./dist/index.js",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "https://github.com/hzhilong/bilitoolkit-types"
21
+ },
22
+ "keywords": [
23
+ "BiliToolkit",
24
+ "哔哩工具姬"
25
+ ],
26
+ "license": "MIT",
27
+ "bugs": {
28
+ "url": "https://github.com/hzhilong/bilitoolkit-types/issues"
29
+ },
30
+ "homepage": "https://github.com/hzhilong/bilitoolkit-types#readme",
31
+ "devDependencies": {
32
+ "barrelsby": "^2.8.1",
33
+ "eslint": "^9.35.0",
34
+ "eslint-config-prettier": "^10.1.8",
35
+ "import-suffixer": "^0.0.1",
36
+ "prettier": "^3.8.1",
37
+ "tsup": "^8.5.1",
38
+ "typescript": "^5.9.3",
39
+ "typescript-eslint": "^8.43.0"
40
+ },
41
+ "peerDependencies": {
42
+ "@ybgnb/utils": "^0.2.8",
43
+ "@ybgnb/bili-api": "^0.0.3"
44
+ },
45
+ "scripts": {
46
+ "check": "tsc -p tsconfig.dev.json --noEmit && eslint .",
47
+ "lint": "eslint . --fix",
48
+ "format": "prettier --write src/",
49
+ "barrelsby": "barrelsby -c barrelsby.json && import-suffixer \"src/**/*.ts\"",
50
+ "build": "tsup",
51
+ "npm login": "npm login",
52
+ "pnpm publish": "pnpm publish --access public"
53
+ }
54
+ }