utools-api-types 6.0.0 → 7.0.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.
- package/package.json +2 -1
- package/resource/utools.schema.json +3 -27
- package/utools.api.d.ts +151 -24
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "utools-api-types",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "TypeScript definitions for uTools API",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"url": "https://github.com/uTools-Labs/utools-api-types/issues"
|
|
16
16
|
},
|
|
17
17
|
"homepage": "https://github.com/uTools-Labs/utools-api-types#readme",
|
|
18
|
+
"readme": "./README.md",
|
|
18
19
|
"exports": {
|
|
19
20
|
"default": {
|
|
20
21
|
"types": "./utools.api.d.ts"
|
|
@@ -17,18 +17,6 @@
|
|
|
17
17
|
"type": "string",
|
|
18
18
|
"description": "插件图标,支持png,jpg格式"
|
|
19
19
|
},
|
|
20
|
-
"platform": {
|
|
21
|
-
"type": "array",
|
|
22
|
-
"description": "插件支持的平台,默认为所有平台。",
|
|
23
|
-
"items": {
|
|
24
|
-
"type": "string",
|
|
25
|
-
"enum": [
|
|
26
|
-
"win32",
|
|
27
|
-
"darwin",
|
|
28
|
-
"linux"
|
|
29
|
-
]
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
20
|
"development": {
|
|
33
21
|
"type": "object",
|
|
34
22
|
"properties": {
|
|
@@ -72,18 +60,6 @@
|
|
|
72
60
|
"mainPush": {
|
|
73
61
|
"type": "boolean"
|
|
74
62
|
},
|
|
75
|
-
"platform": {
|
|
76
|
-
"type": "array",
|
|
77
|
-
"description": "此功能的支持平台,默认为所有平台。",
|
|
78
|
-
"items": {
|
|
79
|
-
"type": "string",
|
|
80
|
-
"enum": [
|
|
81
|
-
"win32",
|
|
82
|
-
"darwin",
|
|
83
|
-
"linux"
|
|
84
|
-
]
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
63
|
"cmds": {
|
|
88
64
|
"type": "array",
|
|
89
65
|
"description": "该功能下可响应的命令集,支持 6 种类型,由 cmds 的类型或 cmds.type 决定。",
|
|
@@ -148,9 +124,9 @@
|
|
|
148
124
|
}
|
|
149
125
|
}
|
|
150
126
|
},
|
|
151
|
-
"mainHide":{
|
|
152
|
-
"type":"boolean",
|
|
153
|
-
"description": "设置为 `true`
|
|
127
|
+
"mainHide": {
|
|
128
|
+
"type": "boolean",
|
|
129
|
+
"description": "设置为 `true` 时,打开对应的 `feature` 不主动弹出搜索框面板"
|
|
154
130
|
}
|
|
155
131
|
}
|
|
156
132
|
}
|
package/utools.api.d.ts
CHANGED
|
@@ -1,5 +1,52 @@
|
|
|
1
1
|
/// <reference path="ubw.d.ts"/>
|
|
2
2
|
/// <reference path="electron.d.ts"/>
|
|
3
|
+
|
|
4
|
+
interface UtoolsAiModel {
|
|
5
|
+
id: string;
|
|
6
|
+
label: string;
|
|
7
|
+
description: string;
|
|
8
|
+
icon: string;
|
|
9
|
+
cost: number;
|
|
10
|
+
}
|
|
11
|
+
interface UtoolsAiResult<T> extends Promise<T> {
|
|
12
|
+
abort(): void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface UtoolsAiMessage {
|
|
16
|
+
role: "system" | "user" | "assistant";
|
|
17
|
+
content?: string;
|
|
18
|
+
reasoning_content?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface UtoolsAiTool {
|
|
22
|
+
type: "function";
|
|
23
|
+
function?: {
|
|
24
|
+
name: string;
|
|
25
|
+
description: string;
|
|
26
|
+
parameters: {
|
|
27
|
+
type: "object";
|
|
28
|
+
properties: Record<string, any>;
|
|
29
|
+
};
|
|
30
|
+
required?: string[];
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface UtoolsAiOption {
|
|
35
|
+
model?: string;
|
|
36
|
+
messages: UtoolsAiMessage[];
|
|
37
|
+
tools?: UtoolsAiTool[];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
interface CookieFilter {
|
|
41
|
+
url?: string;
|
|
42
|
+
name?: string;
|
|
43
|
+
domain?: string;
|
|
44
|
+
path?: string;
|
|
45
|
+
secure?: boolean;
|
|
46
|
+
session?: boolean;
|
|
47
|
+
httpOnly?: boolean;
|
|
48
|
+
}
|
|
49
|
+
|
|
3
50
|
interface UBrowser {
|
|
4
51
|
/**
|
|
5
52
|
* 设置 User-Agent
|
|
@@ -43,6 +90,11 @@ interface UBrowser {
|
|
|
43
90
|
* @param savePath 截图保存路径,可以是文件夹 或 .png文件完全路径, 默认保存临时目录
|
|
44
91
|
*/
|
|
45
92
|
screenshot(arg: string | { x: number, y: number, width: number, height: number }, savePath?: string): this;
|
|
93
|
+
/**
|
|
94
|
+
* 转为 markdown 文本
|
|
95
|
+
* @param selector css 选择器或者XPATH
|
|
96
|
+
*/
|
|
97
|
+
markdown(selector?: string): this;
|
|
46
98
|
/**
|
|
47
99
|
* 保存为PDF
|
|
48
100
|
* @param options 选项
|
|
@@ -54,10 +106,15 @@ interface UBrowser {
|
|
|
54
106
|
*/
|
|
55
107
|
device(arg: { size: { width: number, height: number }, useragent: string }): this;
|
|
56
108
|
/**
|
|
57
|
-
*
|
|
58
|
-
* @param name
|
|
109
|
+
* 在当前 url 根据名称获取 cookie
|
|
110
|
+
* @param name 为空获取当前 url 全部 cookie
|
|
59
111
|
*/
|
|
60
112
|
cookies(name?: string): this;
|
|
113
|
+
/**
|
|
114
|
+
* 根据条件获取 ubrowser cookies
|
|
115
|
+
* @param filter 条件过滤对象
|
|
116
|
+
*/
|
|
117
|
+
cookies(filter: CookieFilter): this;
|
|
61
118
|
/**
|
|
62
119
|
* 设置Cookie
|
|
63
120
|
*/
|
|
@@ -174,25 +231,34 @@ interface UBrowser {
|
|
|
174
231
|
* @param options
|
|
175
232
|
*/
|
|
176
233
|
run<T extends any = any[]>(options: {
|
|
177
|
-
show?: boolean
|
|
178
|
-
width?: number
|
|
179
|
-
height?: number
|
|
180
|
-
x?: number
|
|
181
|
-
y?: number
|
|
182
|
-
center?: boolean
|
|
183
|
-
minWidth?: number
|
|
184
|
-
minHeight?: number
|
|
185
|
-
maxWidth?: number
|
|
186
|
-
maxHeight?: number
|
|
187
|
-
resizable?: boolean
|
|
188
|
-
movable?: boolean
|
|
189
|
-
minimizable?: boolean
|
|
190
|
-
maximizable?: boolean
|
|
191
|
-
alwaysOnTop?: boolean
|
|
192
|
-
fullscreen?: boolean
|
|
193
|
-
fullscreenable?: boolean
|
|
194
|
-
enableLargerThanScreen?: boolean
|
|
195
|
-
opacity?: number
|
|
234
|
+
show?: boolean;
|
|
235
|
+
width?: number;
|
|
236
|
+
height?: number;
|
|
237
|
+
x?: number;
|
|
238
|
+
y?: number;
|
|
239
|
+
center?: boolean;
|
|
240
|
+
minWidth?: number;
|
|
241
|
+
minHeight?: number;
|
|
242
|
+
maxWidth?: number;
|
|
243
|
+
maxHeight?: number;
|
|
244
|
+
resizable?: boolean;
|
|
245
|
+
movable?: boolean;
|
|
246
|
+
minimizable?: boolean;
|
|
247
|
+
maximizable?: boolean;
|
|
248
|
+
alwaysOnTop?: boolean;
|
|
249
|
+
fullscreen?: boolean;
|
|
250
|
+
fullscreenable?: boolean;
|
|
251
|
+
enableLargerThanScreen?: boolean;
|
|
252
|
+
opacity?: number;
|
|
253
|
+
frame?: boolean;
|
|
254
|
+
closable?: boolean;
|
|
255
|
+
focusable?: boolean;
|
|
256
|
+
skipTaskbar?: boolean;
|
|
257
|
+
backgroundColor?: string;
|
|
258
|
+
hasShadow?: boolean;
|
|
259
|
+
transparent?: boolean;
|
|
260
|
+
titleBarStyle?: string;
|
|
261
|
+
thickFrame?: boolean;
|
|
196
262
|
}): Promise<T>;
|
|
197
263
|
/**
|
|
198
264
|
* 运行在闲置的 ubrowser 上
|
|
@@ -251,6 +317,30 @@ type PluginEnterFrom =
|
|
|
251
317
|
| 'hotkey'
|
|
252
318
|
| 'redirect'
|
|
253
319
|
|
|
320
|
+
interface FfmpegRunProgress {
|
|
321
|
+
bitrate: string;
|
|
322
|
+
fps: number;
|
|
323
|
+
frame: number;
|
|
324
|
+
percent?: number;
|
|
325
|
+
q: number | string;
|
|
326
|
+
size: string;
|
|
327
|
+
speed: string;
|
|
328
|
+
time: string;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
interface FfmpegPromise extends Promise<void> {
|
|
332
|
+
kill(): void;
|
|
333
|
+
quit(): void;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
interface MainPushResult {
|
|
337
|
+
icon?: string,
|
|
338
|
+
text: string,
|
|
339
|
+
title?: string
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
type MainPushResultList = MainPushResult[] | Promise<MainPushResult[]>
|
|
343
|
+
|
|
254
344
|
interface UToolsApi {
|
|
255
345
|
/**
|
|
256
346
|
* 插件应用进入时触发
|
|
@@ -259,7 +349,7 @@ interface UToolsApi {
|
|
|
259
349
|
/**
|
|
260
350
|
* 向搜索面板推送消息
|
|
261
351
|
*/
|
|
262
|
-
onMainPush<T = any>(callback: (action: { code: string, type: string, payload: T }) =>
|
|
352
|
+
onMainPush<T = any>(callback: (action: { code: string, type: string, payload: T }) => MainPushResultList, selectCallback: (action: { code: string, type: string, payload: any, option: MainPushResult }) => void): void;
|
|
263
353
|
/**
|
|
264
354
|
* 插件应用隐藏后台或完全退出时触发
|
|
265
355
|
*/
|
|
@@ -319,6 +409,13 @@ interface UToolsApi {
|
|
|
319
409
|
* @param callback url 加载完成时的回调
|
|
320
410
|
*/
|
|
321
411
|
createBrowserWindow(url: string, options: BrowserWindow.InitOptions, callback?: () => void): BrowserWindow.WindowInstance;
|
|
412
|
+
/**
|
|
413
|
+
* 发送消息到父窗口
|
|
414
|
+
* **仅在 `createBrowserWindow` 创建的窗口中使用有效**
|
|
415
|
+
* @param channel 通道名
|
|
416
|
+
* @param params 发送的数据
|
|
417
|
+
*/
|
|
418
|
+
sendToParent(channel: string, ...params: any[]): void;
|
|
322
419
|
/**
|
|
323
420
|
* 隐藏插件应用到后台
|
|
324
421
|
* @param {boolean|undefined} isKill 设置为 `true` 时,会将插件进程杀死
|
|
@@ -396,7 +493,7 @@ interface UToolsApi {
|
|
|
396
493
|
* 插件应用间跳转
|
|
397
494
|
* @todo 创建针对type的多个重载
|
|
398
495
|
*/
|
|
399
|
-
redirect(label: string | string[], payload: string | { type: 'text' | 'img' | 'files', data: any }):
|
|
496
|
+
redirect(label: string | string[], payload: string | { type: 'text' | 'img' | 'files', data: any }): boolean;
|
|
400
497
|
/**
|
|
401
498
|
* 获取闲置的 ubrowser
|
|
402
499
|
*/
|
|
@@ -756,7 +853,7 @@ interface UToolsApi {
|
|
|
756
853
|
|
|
757
854
|
team: {
|
|
758
855
|
/**
|
|
759
|
-
* 获取团队信息
|
|
856
|
+
* 获取团队信息
|
|
760
857
|
*/
|
|
761
858
|
info(): {
|
|
762
859
|
teamId: string,
|
|
@@ -777,6 +874,36 @@ interface UToolsApi {
|
|
|
777
874
|
}
|
|
778
875
|
|
|
779
876
|
ubrowser: UBrowser;
|
|
877
|
+
|
|
878
|
+
/**
|
|
879
|
+
* 运行 ffmpeg
|
|
880
|
+
* @param args ffmpeg 命令行参数
|
|
881
|
+
* @param onProgress 进度回调
|
|
882
|
+
*/
|
|
883
|
+
runFFmpeg(args: string[], onProgress?: (progress: FfmpegRunProgress) => void): FfmpegPromise;
|
|
884
|
+
|
|
885
|
+
/**
|
|
886
|
+
* 流式调用 AI
|
|
887
|
+
* @param option 选项参数
|
|
888
|
+
* @param option.model 模型
|
|
889
|
+
* @param option.messages 消息
|
|
890
|
+
* @param option.tools 工具集合,使用 function calling 配置
|
|
891
|
+
* @param streamCallback 流式回调
|
|
892
|
+
*/
|
|
893
|
+
ai(
|
|
894
|
+
option: UtoolsAiOption,
|
|
895
|
+
streamCallback: (chunk: UtoolsAiMessage) => void
|
|
896
|
+
): UtoolsAiResult<void>
|
|
897
|
+
/**
|
|
898
|
+
* 非流式调用 AI
|
|
899
|
+
* @param option 选项参数
|
|
900
|
+
*/
|
|
901
|
+
ai(option: UtoolsAiOption): UtoolsAiResult<UtoolsAiMessage>
|
|
902
|
+
|
|
903
|
+
/**
|
|
904
|
+
* 获取所有 AI 模型
|
|
905
|
+
*/
|
|
906
|
+
allAiModels(): Promise<UtoolsAiModel[]>;
|
|
780
907
|
}
|
|
781
908
|
|
|
782
909
|
declare var utools: UToolsApi;
|