更新 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)) var utoolsLite = Object.assign({}, _.cloneDeep(utools))
// if (utools.isDev()) return utoolsLite // if (utools.isDev()) return utoolsLite
const dbBlackList = ['db', 'dbStorage', 'removeFeature', 'setFeature', 'onDbPull'] const dbBlackList = ['db', 'dbStorage', 'removeFeature', 'setFeature', 'onDbPull']
const payBlackList = ['fetchUserServerTemporaryToken', 'getUserServerTemporaryToken', 'openPayment', 'fetchUserPayments'] const payBlackList = ['fetchUserServerTemporaryToken', 'isPurchasedUser', 'openPurchase', 'getUserServerTemporaryToken', 'openPayment', 'fetchUserPayments']
const etcBlackList = ['onPluginEnter', 'onPluginOut', 'createBrowserWindow'] const etcBlackList = ['onPluginEnter', 'onPluginOut', 'onMainPush', 'createBrowserWindow']
_.concat(dbBlackList, payBlackList, etcBlackList).forEach(item => { _.concat(dbBlackList, payBlackList, etcBlackList).forEach(item => {
delete utoolsLite[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编码字符串 * @param text base64编码字符串
@ -159,10 +159,9 @@ interface UBrowser {
*/ */
scroll(x: number, y: number): this; scroll(x: number, y: number): this;
/** /**
* ubrowser *
* @param ubrowserId utools.getIdleUBrowsers()
*/ */
run(ubrowserId: number): Promise<any[]>; download(url: string, savePath?: string): this;
/** /**
* ubrowser * ubrowser
* *
@ -189,6 +188,11 @@ interface UBrowser {
enableLargerThanScreen?: boolean, enableLargerThanScreen?: boolean,
opacity?: number opacity?: number
}): Promise<any[]>; }): Promise<any[]>;
/**
* ubrowser
* @param ubrowserId 1. run(options) , ubrowser 2. utools.getIdleUBrowsers()
*/
run(ubrowserId: number): Promise<any[]>;
} }
interface Display { interface Display {
@ -225,21 +229,25 @@ interface DbReturn {
interface UToolsApi { 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; 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 * @param isRestorePreWindow true
@ -250,7 +258,7 @@ interface UToolsApi {
*/ */
showMainWindow(): boolean; showMainWindow(): boolean;
/** /**
* *
*/ */
setExpendHeight(height: number): boolean; setExpendHeight(height: number): boolean;
/** /**
@ -277,11 +285,18 @@ interface UToolsApi {
*/ */
subInputSelect(): boolean; subInputSelect(): boolean;
/** /**
* *
*/ */
subInputBlur(): 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; outPlugin(): boolean;
/** /**
@ -295,63 +310,85 @@ interface UToolsApi {
/** /**
* *
*/ */
// fetchUserServerTemporaryToken(): Promise<{ token: string, expiredAt: number }>; //fetchUserServerTemporaryToken(): Promise<{ token: string, expiredAt: number }>;
/** /**
* *
* @param callback
*/ */
// openPayment(options: { //isPurchasedUser(): boolean;
// /** // /**
// * 商品ID在 “uTools 开发者工具” 插件中创建 // * 打开付费 (软件付费)
// */ // * @param callback 购买成功触发
// goodsId: string, // */
// /** // openPurchase(options: {
// * 第三方服务生成的订单号(可选) // /**
// */ // * 商品 ID在「开发者工具」插件应用中创建
// outOrderId?: string, // */
// /** // goodsId: string,
// * 第三方服务附加数据在查询API和支付通知中原样返回可作为自定义参数使用(可选) // /**
// */ // * 第三方服务生成的订单号(可选)
// attach?: string // */
// }, callback?: () => void): void; // 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 }[]>; redirect(label: string | string[], payload: string | { type: 'text' | 'img' | 'files', data: any }): void;
/**
*
*/
// 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;
/** /**
* ubrowser * ubrowser
*/ */
@ -395,7 +432,7 @@ interface UToolsApi {
securityScopedBookmarks?: boolean securityScopedBookmarks?: boolean
}): (string) | (undefined); }): (string) | (undefined);
/** /**
* *
*/ */
findInPage(text: string, options?: { findInPage(text: string, options?: {
forward?: boolean, forward?: boolean,
@ -405,7 +442,7 @@ interface UToolsApi {
medialCapitalAsWordStart?: boolean medialCapitalAsWordStart?: boolean
}): void; }): void;
/** /**
* *
*/ */
stopFindInPage (action: 'clearSelection' | 'keepSelection' | 'activateSelection'): void; stopFindInPage (action: 'clearSelection' | 'keepSelection' | 'activateSelection'): void;
/** /**
@ -428,6 +465,10 @@ interface UToolsApi {
* *
*/ */
getAppVersion(): string; getAppVersion(): string;
/**
*
*/
getAppName(): string;
/** /**
* *
*/ */
@ -480,6 +521,22 @@ interface UToolsApi {
* *
*/ */
shellBeep(): void; 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; 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 * MacOs
*/ */
isMacOs(): boolean; isMacOS(): boolean;
/** /**
* Windows * Windows
*/ */
@ -537,104 +598,112 @@ interface UToolsApi {
*/ */
isLinux(): boolean; isLinux(): boolean;
// db: { // db: {
// /** // /**
// * 创建/更新文档 // * 创建/更新文档
// */ // */
// put(doc: DbDoc): DbReturn; // put(doc: DbDoc): DbReturn;
// /** // /**
// * 获取文档 // * 获取文档
// */ // */
// get(id: string): DbDoc | null; // get(id: string): DbDoc | null;
// /** // /**
// * 删除文档 // * 删除文档
// */ // */
// remove(doc: string | DbDoc): DbReturn; // remove(doc: string | DbDoc): DbReturn;
// /** // /**
// * 批量操作文档(新增、修改、删除) // * 批量操作文档(新增、修改、删除)
// */ // */
// bulkDocs(docs: DbDoc[]): DbReturn[]; // bulkDocs(docs: DbDoc[]): DbReturn[];
// /** // /**
// * 获取所有文档 可根据文档id前缀查找 // * 获取所有文档 可根据文档id前缀查找
// */ // */
// allDocs(key?: string): DbDoc[]; // allDocs(key?: string): DbDoc[];
// /** // /**
// * 存储附件到新文档 // * 存储附件到新文档
// * @param docId 文档ID // * @param docId 文档ID
// * @param attachment 附件 buffer // * @param attachment 附件 buffer
// * @param type 附件类型示例image/png, text/plain // * @param type 附件类型示例image/png, text/plain
// */ // */
// postAttachment(docId: string, attachment: Uint8Array, type: string): DbReturn; // postAttachment(docId: string, attachment: Uint8Array, type: string): DbReturn;
// /** // /**
// * 获取附件 // * 获取附件
// * @param docId 文档ID // * @param docId 文档ID
// */ // */
// getAttachment(docId: string): Uint8Array | null; // getAttachment(docId: string): Uint8Array | null;
// /** // /**
// * 获取附件类型 // * 获取附件类型
// * @param docId 文档ID // * @param docId 文档ID
// */ // */
// getAttachmentType(docId: string): string | null; // getAttachmentType(docId: string): string | null;
// /** // /**
// * 异步 // * 云端复制数据状态 (null: 未开启数据同步、0: 已完成复制、1复制中)
// */ // */
// promises: { // replicateStateFromCloud(): null | 0 | 1;
// /** // /**
// * 创建/更新文档 // * 异步
// */ // */
// put(doc: DbDoc): Promise<DbReturn>; // promises: {
// /** // /**
// * 获取文档 // * 创建/更新文档
// */ // */
// get(id: string): Promise<DbDoc | null>; // put(doc: DbDoc): Promise<DbReturn>;
// /** // /**
// * 删除文档 // * 获取文档
// */ // */
// remove(doc: string | DbDoc): Promise<DbReturn>; // get(id: string): Promise<DbDoc | null>;
// /** // /**
// * 批量操作文档(新增、修改、删除) // * 删除文档
// */ // */
// bulkDocs(docs: DbDoc[]): Promise<DbReturn[]>; // remove(doc: string | DbDoc): Promise<DbReturn>;
// /** // /**
// * 获取所有文档 可根据文档id前缀查找 // * 批量操作文档(新增、修改、删除)
// */ // */
// allDocs(key?: string): Promise<DbDoc[]>; // bulkDocs(docs: DbDoc[]): Promise<DbReturn[]>;
// /** // /**
// * 存储附件到新文档 // * 获取所有文档 可根据文档id前缀查找
// * @param docId 文档ID // */
// * @param attachment 附件 buffer // allDocs(key?: string): Promise<DbDoc[]>;
// * @param type 附件类型示例image/png, text/plain // /**
// */ // * 存储附件到新文档
// postAttachment(docId: string, attachment: Uint8Array, type: string): Promise<DbReturn>; // * @param docId 文档ID
// /** // * @param attachment 附件 buffer
// * 获取附件 // * @param type 附件类型示例image/png, text/plain
// * @param docId 文档ID // */
// */ // postAttachment(docId: string, attachment: Uint8Array, type: string): Promise<DbReturn>;
// getAttachment(docId: string): Promise<Uint8Array | null>; // /**
// /** // * 获取附件
// * 获取附件类型 // * @param docId 文档ID
// * @param docId 文档ID // */
// */ // getAttachment(docId: string): Promise<Uint8Array | null>;
// getAttachmentType(docId: string): Promise<string | null>; // /**
// } // * 获取附件类型
// }; // * @param docId 文档ID
// */
// getAttachmentType(docId: string): Promise<string | null>;
// /**
// * 云端复制数据状态 (null: 未开启数据同步、0: 已完成复制、1复制中)
// */
// replicateStateFromCloud(): Promise<null | 0 | 1>;
// }
// };
// dbStorage: { // dbStorage: {
// /** // /**
// * 键值对存储,如果键名存在,则更新其对应的值 // * 键值对存储,如果键名存在,则更新其对应的值
// * @param key 键名(同时为文档ID) // * @param key 键名(同时为文档ID)
// * @param value 键值 // * @param value 键值
// */ // */
// setItem (key: string, value: any): void; // setItem (key: string, value: any): void;
// /** // /**
// * 获取键名对应的值 // * 获取键名对应的值
// */ // */
// getItem (key: string): any; // getItem (key: string): any;
// /** // /**
// * 删除键值对(删除文档) // * 删除键值对(删除文档)
// */ // */
// removeItem (key: string): void; // removeItem (key: string): void;
// }; // };
ubrowser: UBrowser; ubrowser: UBrowser;
} }