更新 4.0 utools api 声明

This commit is contained in:
fofolee 2023-08-06 21:46:05 +08:00
parent a9df2a76b1
commit 29a6b07dfe
2 changed files with 238 additions and 169 deletions

View File

@ -2,8 +2,8 @@ const getuToolsLite = () => {
var utoolsLite = Object.assign({}, _.cloneDeep(utools))
// if (utools.isDev()) return utoolsLite
const dbBlackList = ['db', 'dbStorage', 'removeFeature', 'setFeature', 'onDbPull']
const payBlackList = ['fetchUserServerTemporaryToken', 'getUserServerTemporaryToken', 'openPayment', 'fetchUserPayments']
const etcBlackList = ['onPluginEnter', 'onPluginOut', 'createBrowserWindow']
const payBlackList = ['fetchUserServerTemporaryToken', 'isPurchasedUser', 'openPurchase', 'getUserServerTemporaryToken', 'openPayment', 'fetchUserPayments']
const etcBlackList = ['onPluginEnter', 'onPluginOut', 'onMainPush', 'createBrowserWindow']
_.concat(dbBlackList, payBlackList, etcBlackList).forEach(item => {
delete utoolsLite[item]
})

View File

@ -29,7 +29,7 @@ interface UBrowser {
/**
*
*/
press(key: string, ...modifier: ('control' | 'ctrl' | 'shift' | 'meta' | 'alt' | 'command' | 'cmd')[]): this;
press(key: string, ...modifier: ('ctrl' | 'shift' | 'alt' | 'meta')[]): this;
/**
*
* @param text base64编码字符串
@ -159,10 +159,9 @@ interface UBrowser {
*/
scroll(x: number, y: number): this;
/**
* ubrowser
* @param ubrowserId utools.getIdleUBrowsers()
*
*/
run(ubrowserId: number): Promise<any[]>;
download(url: string, savePath?: string): this;
/**
* ubrowser
*
@ -189,6 +188,11 @@ interface UBrowser {
enableLargerThanScreen?: boolean,
opacity?: number
}): Promise<any[]>;
/**
* ubrowser
* @param ubrowserId 1. run(options) , ubrowser 2. utools.getIdleUBrowsers()
*/
run(ubrowserId: number): Promise<any[]>;
}
interface Display {
@ -225,21 +229,25 @@ interface DbReturn {
interface UToolsApi {
/**
*
*
*/
onPluginEnter(callback: (action: {code: string, type: string, payload: any }) => void): void;
//onPluginEnter(callback: (action: {code: string, type: string, payload: any, option: any }) => void): void;
/**
*
*
*/
//onMainPush(callback: (action: {code: string, type: string, payload: any }) => { icon?: string, text: string, title?: string }[], selectCallback: (action: {code: string, type: string, payload: any, option: { icon?: string, text: string, title?: string }}) => void): void;
/**
* 退
*/
onPluginOut(callback: () => void): void;
//onPluginOut(callback: (processExit: boolean) => void): void;
/**
*
*
*/
onPluginDetach(callback: () => void): void;
/**
*
*
*/
// onDbPull(callback: (docs: { _id: string, _rev: string }[]) => void): void;
//onDbPull(callback: (docs: { _id: string, _rev: string }[]) => void): void;
/**
*
* @param isRestorePreWindow true
@ -250,7 +258,7 @@ interface UToolsApi {
*/
showMainWindow(): boolean;
/**
*
*
*/
setExpendHeight(height: number): boolean;
/**
@ -277,11 +285,18 @@ interface UToolsApi {
*/
subInputSelect(): boolean;
/**
*
*
*/
subInputBlur(): boolean;
/**
*
*
* @param url html
* @param options https://www.electronjs.org/docs/api/browser-window#new-browserwindowoptions
* @param callback url
*/
//createBrowserWindow(url: string, options: { width?: number, height?: number }, callback?: () => void): { id: number, [key: string]: any, webContents: { id: number, [key: string]: any } };
/**
*
*/
outPlugin(): boolean;
/**
@ -295,63 +310,85 @@ interface UToolsApi {
/**
*
*/
// fetchUserServerTemporaryToken(): Promise<{ token: string, expiredAt: number }>;
//fetchUserServerTemporaryToken(): Promise<{ token: string, expiredAt: number }>;
/**
*
* @param callback
*
*/
// openPayment(options: {
// /**
// * 商品ID在 “uTools 开发者工具” 插件中创建
// */
// goodsId: string,
// /**
// * 第三方服务生成的订单号(可选)
// */
// outOrderId?: string,
// /**
// * 第三方服务附加数据在查询API和支付通知中原样返回可作为自定义参数使用(可选)
// */
// attach?: string
// }, callback?: () => void): void;
//isPurchasedUser(): boolean;
// /**
// * 打开付费 (软件付费)
// * @param callback 购买成功触发
// */
// openPurchase(options: {
// /**
// * 商品 ID在「开发者工具」插件应用中创建
// */
// goodsId: string,
// /**
// * 第三方服务生成的订单号(可选)
// */
// outOrderId?: string,
// /**
// * 第三方服务附加数据在查询API和支付通知中原样返回可作为自定义参数使用(可选)
// */
// attach?: string
// }, callback?: () => void): void;
// /**
// * 打开支付 (付费付费)
// * @param callback 支付成功触发
// */
// openPayment(options: {
// /**
// * 商品 ID在「开发者工具」插件应用中创建
// */
// goodsId: string,
// /**
// * 第三方服务生成的订单号(可选)
// */
// outOrderId?: string,
// /**
// * 第三方服务附加数据在查询API和支付通知中原样返回可作为自定义参数使用(可选)
// */
// attach?: string
// }, callback?: () => void): void;
// /**
// * 获取用户支付记录
// */
// fetchUserPayments(): Promise<{ order_id: string, total_fee: number, body: string, attach: string, goods_id: string, out_order_id: string, paid_at: string }[]>;
// /**
// * 设置插件应用动态功能
// */
// setFeature(feature: {
// code: string,
// explain: string,
// platform: ('darwin' | 'win32' | 'linux') | (Array<'darwin' | 'win32' | 'linux'>),
// icon?: string,
// cmds: (string | {
// type: 'img' | 'files' | 'regex' | 'over' | 'window',
// label: string
// })[]
// }): boolean;
// /**
// * 移除插件应用动态功能
// */
// removeFeature(code: string): boolean;
// /**
// * 获取插件应用动态功能,参数为空获取所有动态功能
// */
getFeatures(codes?: string[]): {
code: string,
explain: string,
platform: ('darwin' | 'win32' | 'linux') | (Array<'darwin' | 'win32' | 'linux'>),
icon?: string,
cmds: string | {
type: 'img' | 'files' | 'regex' | 'over' | 'window',
label: string
}[]
}[];
/**
*
*
*/
// fetchUserPayments(): Promise<{ order_id: string, total_fee: number, body: string, attach: string, goods_id: string, out_order_id: string, paid_at: string }[]>;
/**
*
*/
// setFeature(feature: {
// code: string,
// explain: string,
// platform: ('darwin' | 'win32' | 'linux') | (Array<'darwin' | 'win32' | 'linux'>),
// icon?: string,
// cmds: string | {
// type: 'img' | 'files' | 'regex' | 'over' | 'window',
// label: string
// }[]
// }): boolean;
/**
*
*/
// removeFeature(code: string): boolean;
/**
*
*/
// getFeatures(): {
// code: string,
// explain: string,
// platform: ('darwin' | 'win32' | 'linux') | (Array<'darwin' | 'win32' | 'linux'>),
// icon?: string,
// cmds: string | {
// type: 'img' | 'files' | 'regex' | 'over' | 'window',
// label: string
// }[]
// }[];
/**
*
*/
redirect(label: string, payload: string | { type: 'text' | 'img' | 'files', data: any }): void;
redirect(label: string | string[], payload: string | { type: 'text' | 'img' | 'files', data: any }): void;
/**
* ubrowser
*/
@ -395,7 +432,7 @@ interface UToolsApi {
securityScopedBookmarks?: boolean
}): (string) | (undefined);
/**
*
*
*/
findInPage(text: string, options?: {
forward?: boolean,
@ -405,7 +442,7 @@ interface UToolsApi {
medialCapitalAsWordStart?: boolean
}): void;
/**
*
*
*/
stopFindInPage (action: 'clearSelection' | 'keepSelection' | 'activateSelection'): void;
/**
@ -428,6 +465,10 @@ interface UToolsApi {
*
*/
getAppVersion(): string;
/**
*
*/
getAppName(): string;
/**
*
*/
@ -480,6 +521,22 @@ interface UToolsApi {
*
*/
shellBeep(): void;
/*
*
*/
hideMainWindowTypeString(str: string): void;
/*
*
*/
hideMainWindowPasteFile(file: string | string[]): void;
/*
*
*/
hideMainWindowPasteImage(img: string): void;
/*
*
*/
hideMainWindowPasteText(text: string): void;
/**
*
*/
@ -520,6 +577,10 @@ interface UToolsApi {
*
*/
getDisplayMatching(rect: { x: number, y: number, width: number, height: number }): Display;
/**
*
*/
desktopCaptureSources(options: { types: string[], thumbnailSize?: { width: number, height: number }, fetchWindowIcons?: boolean }):Promise<{appIcon: {}, display_id: string, id: string, name: string, thumbnail: {} }>;
/**
*
*/
@ -527,7 +588,7 @@ interface UToolsApi {
/**
* MacOs
*/
isMacOs(): boolean;
isMacOS(): boolean;
/**
* Windows
*/
@ -537,104 +598,112 @@ interface UToolsApi {
*/
isLinux(): boolean;
// db: {
// /**
// * 创建/更新文档
// */
// put(doc: DbDoc): DbReturn;
// /**
// * 获取文档
// */
// get(id: string): DbDoc | null;
// /**
// * 删除文档
// */
// remove(doc: string | DbDoc): DbReturn;
// /**
// * 批量操作文档(新增、修改、删除)
// */
// bulkDocs(docs: DbDoc[]): DbReturn[];
// /**
// * 获取所有文档 可根据文档id前缀查找
// */
// allDocs(key?: string): DbDoc[];
// /**
// * 存储附件到新文档
// * @param docId 文档ID
// * @param attachment 附件 buffer
// * @param type 附件类型示例image/png, text/plain
// */
// postAttachment(docId: string, attachment: Uint8Array, type: string): DbReturn;
// /**
// * 获取附件
// * @param docId 文档ID
// */
// getAttachment(docId: string): Uint8Array | null;
// /**
// * 获取附件类型
// * @param docId 文档ID
// */
// getAttachmentType(docId: string): string | null;
// /**
// * 异步
// */
// promises: {
// /**
// * 创建/更新文档
// */
// put(doc: DbDoc): Promise<DbReturn>;
// /**
// * 获取文档
// */
// get(id: string): Promise<DbDoc | null>;
// /**
// * 删除文档
// */
// remove(doc: string | DbDoc): Promise<DbReturn>;
// /**
// * 批量操作文档(新增、修改、删除)
// */
// bulkDocs(docs: DbDoc[]): Promise<DbReturn[]>;
// /**
// * 获取所有文档 可根据文档id前缀查找
// */
// allDocs(key?: string): Promise<DbDoc[]>;
// /**
// * 存储附件到新文档
// * @param docId 文档ID
// * @param attachment 附件 buffer
// * @param type 附件类型示例image/png, text/plain
// */
// postAttachment(docId: string, attachment: Uint8Array, type: string): Promise<DbReturn>;
// /**
// * 获取附件
// * @param docId 文档ID
// */
// getAttachment(docId: string): Promise<Uint8Array | null>;
// /**
// * 获取附件类型
// * @param docId 文档ID
// */
// getAttachmentType(docId: string): Promise<string | null>;
// }
// };
// db: {
// /**
// * 创建/更新文档
// */
// put(doc: DbDoc): DbReturn;
// /**
// * 获取文档
// */
// get(id: string): DbDoc | null;
// /**
// * 删除文档
// */
// remove(doc: string | DbDoc): DbReturn;
// /**
// * 批量操作文档(新增、修改、删除)
// */
// bulkDocs(docs: DbDoc[]): DbReturn[];
// /**
// * 获取所有文档 可根据文档id前缀查找
// */
// allDocs(key?: string): DbDoc[];
// /**
// * 存储附件到新文档
// * @param docId 文档ID
// * @param attachment 附件 buffer
// * @param type 附件类型示例image/png, text/plain
// */
// postAttachment(docId: string, attachment: Uint8Array, type: string): DbReturn;
// /**
// * 获取附件
// * @param docId 文档ID
// */
// getAttachment(docId: string): Uint8Array | null;
// /**
// * 获取附件类型
// * @param docId 文档ID
// */
// getAttachmentType(docId: string): string | null;
// /**
// * 云端复制数据状态 (null: 未开启数据同步、0: 已完成复制、1复制中)
// */
// replicateStateFromCloud(): null | 0 | 1;
// /**
// * 异步
// */
// promises: {
// /**
// * 创建/更新文档
// */
// put(doc: DbDoc): Promise<DbReturn>;
// /**
// * 获取文档
// */
// get(id: string): Promise<DbDoc | null>;
// /**
// * 删除文档
// */
// remove(doc: string | DbDoc): Promise<DbReturn>;
// /**
// * 批量操作文档(新增、修改、删除)
// */
// bulkDocs(docs: DbDoc[]): Promise<DbReturn[]>;
// /**
// * 获取所有文档 可根据文档id前缀查找
// */
// allDocs(key?: string): Promise<DbDoc[]>;
// /**
// * 存储附件到新文档
// * @param docId 文档ID
// * @param attachment 附件 buffer
// * @param type 附件类型示例image/png, text/plain
// */
// postAttachment(docId: string, attachment: Uint8Array, type: string): Promise<DbReturn>;
// /**
// * 获取附件
// * @param docId 文档ID
// */
// getAttachment(docId: string): Promise<Uint8Array | null>;
// /**
// * 获取附件类型
// * @param docId 文档ID
// */
// getAttachmentType(docId: string): Promise<string | null>;
// /**
// * 云端复制数据状态 (null: 未开启数据同步、0: 已完成复制、1复制中)
// */
// replicateStateFromCloud(): Promise<null | 0 | 1>;
// }
// };
// dbStorage: {
// /**
// * 键值对存储,如果键名存在,则更新其对应的值
// * @param key 键名(同时为文档ID)
// * @param value 键值
// */
// setItem (key: string, value: any): void;
// /**
// * 获取键名对应的值
// */
// getItem (key: string): any;
// /**
// * 删除键值对(删除文档)
// */
// removeItem (key: string): void;
// };
// dbStorage: {
// /**
// * 键值对存储,如果键名存在,则更新其对应的值
// * @param key 键名(同时为文档ID)
// * @param value 键值
// */
// setItem (key: string, value: any): void;
// /**
// * 获取键名对应的值
// */
// getItem (key: string): any;
// /**
// * 删除键值对(删除文档)
// */
// removeItem (key: string): void;
// };
ubrowser: UBrowser;
}