utools-api-types 5.2.0 → 6.1.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "utools-api-types",
3
- "version": "5.2.0",
3
+ "version": "6.1.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` 时,启动对应的 `feature` 不会弹出主面板"
127
+ "mainHide": {
128
+ "type": "boolean",
129
+ "description": "设置为 `true` 时,打开对应的 `feature` 不主动弹出搜索框面板"
154
130
  }
155
131
  }
156
132
  }
package/utools.api.d.ts CHANGED
@@ -1,5 +1,16 @@
1
1
  /// <reference path="ubw.d.ts"/>
2
2
  /// <reference path="electron.d.ts"/>
3
+
4
+ interface CookieFilter {
5
+ url ?: string;
6
+ name?: string;
7
+ domain?: string;
8
+ path?: string;
9
+ secure?: boolean;
10
+ session?: boolean;
11
+ httpOnly?: boolean;
12
+ }
13
+
3
14
  interface UBrowser {
4
15
  /**
5
16
  * 设置 User-Agent
@@ -52,12 +63,17 @@ interface UBrowser {
52
63
  /**
53
64
  * 模拟设备
54
65
  */
55
- device(arg: ('iPhone 11' | 'iPhone X' | 'iPad' | 'iPhone 6/7/8 Plus' | 'iPhone 6/7/8' | 'iPhone 5/SE' | 'HUAWEI Mate10' | 'HUAWEI Mate20' | 'HUAWEI Mate30' | 'HUAWEI Mate30 Pro') | { size: { width: number, height: number }, useragent: string }): this;
66
+ device(arg: { size: { width: number, height: number }, useragent: string }): this;
56
67
  /**
57
- * 获取 cookie
58
- * @param name 为空获取全部cookie
68
+ * 在当前 url 根据名称获取 cookie
69
+ * @param name 为空获取当前 url 全部 cookie
59
70
  */
60
71
  cookies(name?: string): this;
72
+ /**
73
+ * 根据条件获取 ubrowser cookies
74
+ * @param filter 条件过滤对象
75
+ */
76
+ cookies(filter: CookieFilter): this;
61
77
  /**
62
78
  * 设置Cookie
63
79
  */
@@ -104,7 +120,7 @@ interface UBrowser {
104
120
  */
105
121
  wait<T extends any[]>(func: (...params: T) => boolean, timeout?: number, ...params: T): this;
106
122
  /**
107
- * 当元素存在时执行直到碰到 end
123
+ * 当元素存在时执行,直到碰到 end
108
124
  * @param selector DOM元素
109
125
  */
110
126
  when(selector: string): this;
@@ -164,6 +180,10 @@ interface UBrowser {
164
180
  * 下载文件
165
181
  */
166
182
  download(url: string, savePath?: string): this;
183
+ /**
184
+ * 下载文件
185
+ */
186
+ download(func: (...params: any[]) => string, savePath: string | null, ...params: any[]): this;
167
187
  /**
168
188
  * 启动一个 ubrowser 运行
169
189
  * 当运行结束后,窗口如果为隐藏状态将自动销毁窗口
@@ -237,10 +257,6 @@ interface PluginFeature {
237
257
  type: 'img' | 'files' | 'regex' | 'over' | 'window',
238
258
  label: string
239
259
  })[]
240
- /**
241
- * @version >= 5.2.0
242
- * 设置为 `true` 时,启动对应的 `feature` 不会弹出主面板
243
- */
244
260
  mainHide?: boolean
245
261
  mainPush?: boolean
246
262
  }
@@ -251,6 +267,22 @@ type PluginEnterFrom =
251
267
  | 'hotkey'
252
268
  | 'redirect'
253
269
 
270
+ interface FfmpegRunProgress {
271
+ bitrate: string;
272
+ fps: number;
273
+ frame: number;
274
+ percent?: number;
275
+ q: number | string;
276
+ size: string;
277
+ speed: string;
278
+ time: string;
279
+ }
280
+
281
+ interface FfmpegPromise extends Promise<void> {
282
+ kill(): void;
283
+ quit(): void;
284
+ }
285
+
254
286
  interface UToolsApi {
255
287
  /**
256
288
  * 插件应用进入时触发
@@ -319,6 +351,13 @@ interface UToolsApi {
319
351
  * @param callback url 加载完成时的回调
320
352
  */
321
353
  createBrowserWindow(url: string, options: BrowserWindow.InitOptions, callback?: () => void): BrowserWindow.WindowInstance;
354
+ /**
355
+ * 发送消息到父窗口
356
+ * **仅在 `createBrowserWindow` 创建的窗口中使用有效**
357
+ * @param channel 通道名
358
+ * @param params 发送的数据
359
+ */
360
+ sendToParent(channel: string, ...params: any[]): void;
322
361
  /**
323
362
  * 隐藏插件应用到后台
324
363
  * @param {boolean|undefined} isKill 设置为 `true` 时,会将插件进程杀死
@@ -396,7 +435,7 @@ interface UToolsApi {
396
435
  * 插件应用间跳转
397
436
  * @todo 创建针对type的多个重载
398
437
  */
399
- redirect(label: string | string[], payload: string | { type: 'text' | 'img' | 'files', data: any }): void;
438
+ redirect(label: string | string[], payload: string | { type: 'text' | 'img' | 'files', data: any }): boolean;
400
439
  /**
401
440
  * 获取闲置的 ubrowser
402
441
  */
@@ -737,7 +776,53 @@ interface UToolsApi {
737
776
  removeItem(key: string): void;
738
777
  };
739
778
 
779
+ dbCryptoStorage: {
780
+ /**
781
+ * 键值对加密存储,如果键名存在,则更新其对应的值
782
+ * @param key 键名(同时为文档ID)
783
+ * @param value 键值
784
+ */
785
+ setItem(key: string, value: any): void;
786
+ /**
787
+ * 获取键名对应的值
788
+ */
789
+ getItem<T = any>(key: string): T;
790
+ /**
791
+ * 删除键值对(删除文档)
792
+ */
793
+ removeItem(key: string): void;
794
+ };
795
+
796
+ team: {
797
+ /**
798
+ * 获取团队信息
799
+ */
800
+ info(): {
801
+ teamId: string,
802
+ teamName: string,
803
+ teamLogo: string,
804
+ userId: string,
805
+ userName: string,
806
+ userAvatar: string
807
+ };
808
+ /**
809
+ * 获取团队版预设键名对应的值
810
+ */
811
+ preset<T = any>(key: string): T;
812
+ /**
813
+ * 获取团队版预设的所有数据
814
+ */
815
+ allPresets(): Promise<{ key: string, value: any }[]>;
816
+ }
817
+
740
818
  ubrowser: UBrowser;
819
+
820
+ /**
821
+ * 运行 ffmpeg
822
+ * @param args ffmpeg 命令行参数
823
+ * @param onProgress 进度回调
824
+ */
825
+ runFFmpeg(args: string[], onProgress?: () => FfmpegRunProgress): FfmpegPromise;
741
826
  }
742
827
 
743
828
  declare var utools: UToolsApi;