utools-api-types 2.0.5 → 2.6.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/utools.api.d.ts +54 -29
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "utools-api-types",
3
- "version": "2.0.5",
3
+ "version": "2.6.0",
4
4
  "description": "TypeScript definitions for uTools API",
5
5
  "repository": {
6
6
  "type": "git",
package/utools.api.d.ts CHANGED
@@ -5,12 +5,11 @@ interface UBrowser {
5
5
  useragent(userAgent: string): this;
6
6
  /**
7
7
  * 前往
8
+ * @param url 链接地址,支持 http 或 file 协议
9
+ * @param headers 请求头参数
10
+ * @param timeout 加载超时,默认 60000 ms(60秒)
8
11
  */
9
- goto(url: string, headers?: { Referer: string, userAgent: string }): this;
10
- /**
11
- * 显示Markdown
12
- */
13
- goto(mdText: string, title?: string): this;
12
+ goto(url: string, headers?: { Referer: string, userAgent: string }, timeout?: number): this;
14
13
  /**
15
14
  * 页面大小
16
15
  */
@@ -92,13 +91,13 @@ interface UBrowser {
92
91
  /**
93
92
  * 等待元素出现
94
93
  * @param selector DOM元素
95
- * @param timeout 超时 默认10000 ms(10秒)
94
+ * @param timeout 超时 默认60000 ms(60秒)
96
95
  */
97
96
  wait(selector: string, timeout?: number): this;
98
97
  /**
99
98
  * 等待 JS函数 执行返回 true
100
99
  * @param func 执行的JS函数
101
- * @param timeout 超时 默认10000 ms(10秒)
100
+ * @param timeout 超时 默认60000 ms(60秒)
102
101
  * @param params 传到 func 中的参数
103
102
  */
104
103
  wait(func: (...params: any[]) => boolean, timeout?: number, ...params: any[]): this;
@@ -166,6 +165,7 @@ interface UBrowser {
166
165
  run(ubrowserId: number): Promise<any[]>;
167
166
  /**
168
167
  * 启动一个 ubrowser 运行
168
+ * 当运行结束后,窗口如果为隐藏状态将自动销毁窗口
169
169
  * @param options
170
170
  */
171
171
  run(options: {
@@ -224,14 +224,10 @@ interface DbReturn {
224
224
  }
225
225
 
226
226
  interface UToolsApi {
227
- /**
228
- * 插件装配初始化完成触发
229
- */
230
- onPluginReady(callback: () => void): void;
231
227
  /**
232
228
  * 插件进入时触发
233
229
  */
234
- onPluginEnter(callback: (action: {code: string, type: string, payload: any, optional: { type: string, payload: any }[] }) => void): void;
230
+ onPluginEnter(callback: (action: {code: string, type: string, payload: any }) => void): void;
235
231
  /**
236
232
  * 插件隐藏时触发
237
233
  */
@@ -405,23 +401,6 @@ interface UToolsApi {
405
401
  properties?: Array<'showHiddenFiles' | 'createDirectory' | 'treatPackageAsDirectory' | 'showOverwriteConfirmation' | 'dontAddToRecent'>,
406
402
  securityScopedBookmarks?: boolean
407
403
  }): (string) | (undefined);
408
- /**
409
- * 弹出消息框
410
- */
411
- showMessageBox(options: {
412
- type?: string,
413
- buttons?: string[],
414
- defaultId?: number,
415
- title?: string,
416
- message: string,
417
- detail?: string,
418
- checkboxLabel?: string,
419
- checkboxChecked?: boolean,
420
- icon?: string,
421
- cancelId?: number,
422
- noLink?: boolean,
423
- normalizeAccessKeys?: boolean
424
- }): number;
425
404
  /**
426
405
  * 插件页面中查找
427
406
  */
@@ -548,6 +527,10 @@ interface UToolsApi {
548
527
  * 获取矩形所在的显示器
549
528
  */
550
529
  getDisplayMatching(rect: { x: number, y: number, width: number, height: number }): Display;
530
+ /**
531
+ * 是否开发中
532
+ */
533
+ isDev(): boolean;
551
534
  /**
552
535
  * 是否 MacOs 操作系统
553
536
  */
@@ -599,6 +582,48 @@ interface UToolsApi {
599
582
  * @param docId 文档ID
600
583
  */
601
584
  getAttachmentType(docId: string): string | null;
585
+ /**
586
+ * 异步
587
+ */
588
+ promises: {
589
+ /**
590
+ * 创建/更新文档
591
+ */
592
+ put(doc: DbDoc): Promise<DbReturn>;
593
+ /**
594
+ * 获取文档
595
+ */
596
+ get(id: string): Promise<DbDoc | null>;
597
+ /**
598
+ * 删除文档
599
+ */
600
+ remove(doc: string | DbDoc): Promise<DbReturn>;
601
+ /**
602
+ * 批量操作文档(新增、修改、删除)
603
+ */
604
+ bulkDocs(docs: DbDoc[]): Promise<DbReturn[]>;
605
+ /**
606
+ * 获取所有文档 可根据文档id前缀查找
607
+ */
608
+ allDocs(key?: string): Promise<DbDoc[]>;
609
+ /**
610
+ * 存储附件到新文档
611
+ * @param docId 文档ID
612
+ * @param attachment 附件 buffer
613
+ * @param type 附件类型,示例:image/png, text/plain
614
+ */
615
+ postAttachment(docId: string, attachment: Uint8Array, type: string): Promise<DbReturn>;
616
+ /**
617
+ * 获取附件
618
+ * @param docId 文档ID
619
+ */
620
+ getAttachment(docId: string): Promise<Uint8Array | null>;
621
+ /**
622
+ * 获取附件类型
623
+ * @param docId 文档ID
624
+ */
625
+ getAttachmentType(docId: string): Promise<string | null>;
626
+ }
602
627
  };
603
628
 
604
629
  dbStorage: {