更新 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,19 +229,23 @@ 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;
/** /**
* *
*/ */
onPluginOut(callback: () => 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: (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;
/** /**
@ -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;
/** /**
@ -297,12 +312,16 @@ interface UToolsApi {
*/ */
//fetchUserServerTemporaryToken(): Promise<{ token: string, expiredAt: number }>; //fetchUserServerTemporaryToken(): Promise<{ token: string, expiredAt: number }>;
/** /**
* *
* @param callback
*/ */
// openPayment(options: { //isPurchasedUser(): boolean;
// /** // /**
// * 商品ID在 “uTools 开发者工具” 插件中创建 // * 打开付费 (软件付费)
// * @param callback 购买成功触发
// */
// openPurchase(options: {
// /**
// * 商品 ID在「开发者工具」插件应用中创建
// */ // */
// goodsId: string, // goodsId: string,
// /** // /**
@ -314,44 +333,62 @@ interface UToolsApi {
// */ // */
// attach?: string // attach?: string
// }, callback?: () => void): void; // }, 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 }[]>; // fetchUserPayments(): Promise<{ order_id: string, total_fee: number, body: string, attach: string, goods_id: string, out_order_id: string, paid_at: string }[]>;
/** // /**
* // * 设置插件应用动态功能
*/ // */
// setFeature(feature: { // setFeature(feature: {
// code: string, // code: string,
// explain: string, // explain: string,
// platform: ('darwin' | 'win32' | 'linux') | (Array<'darwin' | 'win32' | 'linux'>), // platform: ('darwin' | 'win32' | 'linux') | (Array<'darwin' | 'win32' | 'linux'>),
// icon?: string, // icon?: string,
// cmds: string | { // cmds: (string | {
// type: 'img' | 'files' | 'regex' | 'over' | 'window', // type: 'img' | 'files' | 'regex' | 'over' | 'window',
// label: string // label: string
// }[] // })[]
// }): boolean; // }): boolean;
/** // /**
* // * 移除插件应用动态功能
*/ // */
// removeFeature(code: 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
}[]
}[];
/** /**
* *
*/ */
// getFeatures(): { redirect(label: string | string[], payload: string | { type: 'text' | 'img' | 'files', data: any }): void;
// 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
*/ */
@ -576,6 +637,10 @@ interface UToolsApi {
// */ // */
// getAttachmentType(docId: string): string | null; // getAttachmentType(docId: string): string | null;
// /** // /**
// * 云端复制数据状态 (null: 未开启数据同步、0: 已完成复制、1复制中)
// */
// replicateStateFromCloud(): null | 0 | 1;
// /**
// * 异步 // * 异步
// */ // */
// promises: { // promises: {
@ -616,6 +681,10 @@ interface UToolsApi {
// * @param docId 文档ID // * @param docId 文档ID
// */ // */
// getAttachmentType(docId: string): Promise<string | null>; // getAttachmentType(docId: string): Promise<string | null>;
// /**
// * 云端复制数据状态 (null: 未开启数据同步、0: 已完成复制、1复制中)
// */
// replicateStateFromCloud(): Promise<null | 0 | 1>;
// } // }
// }; // };