UNPKG

node-ddk

Version:
388 lines (361 loc) 11.8 kB
export namespace NODEDDK { // @ Rectangle export type Rectangle = { x: number, y: number, width: number, height: number, } // export type OsType = "Linux" | "Windows" | "Darwin" | "Other" // @通用 export type generalFunction = () => any // @ 渲染进程启动参数 export type WindowType = { type: string, minWidth?: number, minHeight?: number, resizable?: boolean, minimizable?: boolean, minimize?: boolean, maximizable?: boolean, maximize?: boolean, transparent?: boolean, fullscreenable?: boolean, fullscreen?: boolean, alwaysOnTop?: boolean, frame?: boolean, menu?: boolean, skipTaskbar?: boolean, kiosk?: boolean, focus?: boolean, needCenter?: boolean, x?: number, y?: number, width?: number, height?: number, hide?: boolean, backgroundColor?: string, navigate?: boolean, zoomFactor?: number, hasShadow?: boolean, windowStateType?: string, devTools?: boolean, autoDevTools?: boolean, } // @ export type NewWindowInfo = { uniqueId: string, args: any, } & WindowType // @ export type WindowInfo = { webContentsId: number, appName: string, appVersion: string, devMode: boolean, } & NewWindowInfo // @ 菜单条目 export type MenuEvent = { ctrlKey: boolean, metaKey: boolean, shiftKey: boolean, altKey: boolean, triggeredByAccelerator: boolean, } export type MenuItemClick = (ev: MenuEvent) => any export type MenuItem = { type?: "normal" | "separator" | "submenu" | "checkbox" | "radio", label: string, click?: MenuItemClick, role?: string, submenu?: MenuItem[], enabled?: boolean, separator?: boolean, checked?: boolean, } // @ 打开本地文件/url export type OpenLocalFileOptions = { path: string, } export type OpenLocalFileChecker = (attrs: OpenLocalFileOptions) => Promise<boolean> export type OpenUrlOptions = { url: string, } export type OpenUrlChecker = (attrs: OpenUrlOptions) => Promise<boolean> // export type FileProtocolRealpathOptions = { path: string, } export type FileProtocolRealpath = (options: FileProtocolRealpathOptions) => Promise<string> export type FileProtocolOptions = { protocol: string, realpath: FileProtocolRealpath, } // export type FileInfo = { status: "OK" | "none" | "error", type: "file" | "directory" | "other", size: number, ctime: number, mtime: number, } // export type FindInPageOptions = { text: string, findNext?: boolean, forward?: boolean, matchCase?: boolean, } export type FindInPageResult = { matches: number, sn: number, } // @ // @interface 具体的功能模块, 请求 export type ModuleRendererRequest = { fromWindowUniqueId?: string, toWindowUniqueId?: string, sn?: string, module: string, data: any, timeout?: number, // 秒 notify?: (data: any) => any, } // @interface 具体的功能模块, 返回 export type ModuleRendererResponse = { fromWindowUniqueId?: string, toWindowUniqueId?: string, sn?: string, status?: string, data: any, } // @interface 模块处理函数 export type ModuleRendererResolve = (res: ModuleRendererResponse) => void export type ModuleRendererHandler = (req: ModuleRendererRequest) => Promise<ModuleRendererResponse> // dialog export type DialogFilter = { name: string, extensions: string[], } export type DialogOptions = { title?: string, buttonLabel?: string, filters?: DialogFilter[], showHiddenFiles?: boolean, dirGroup?: string, // 按组, 记住上次目录选择 } export type DialogOpenOptions = DialogOptions export type DialogSaveDirOptions = DialogOptions export type DialogSaveFileOptions = { filename?: string, } & DialogSaveDirOptions // export type DialogMessageBox = { message: string, title?: string, type?: "info" | "warning" | "error", buttons?: string[], defaultId?: number, detail?: string, checkboxLabel?: string, checkboxChecked?: boolean, icon?: string, cancelId?: number, minAbcCharLength?: number, } export type DialogAlertBox = { message: string, title?: string, type?: "info" | "warning" | "error", icon?: string, okLabel?: string, minAbcCharLength?: number, } } declare const _default: { app: { start: () => Promise<void>; quit: () => Promise<void>; toTray: () => void; dragSaveFiles: (filePaths: string[]) => void; openDevTools: () => void; }; ipc: { request: (sendMsg: NODEDDK.ModuleRendererRequest) => Promise<NODEDDK.ModuleRendererResponse>; registerListenModule: (name: string, handler: NODEDDK.ModuleRendererHandler) => void; registerMessageReceiver: (module: string, handler: (data: any) => any) => void; }; window: { getInfo: () => NODEDDK.WindowInfo; openModal: (attrs: { type: string; uniqueId?: string; args?: any; frameName?: string; features?: string; onClose?: Function; aboutBlankMode?: boolean; }) => Promise<Window | null>; create: (attrs: { type: string; uniqueId?: string; args?: any; }) => Promise<boolean>; close: (attrs?: { windowUniqueId?: string; }) => Promise<boolean>; forcedClose: (attrs?: { windowUniqueId?: string; }) => Promise<boolean>; hide: (attrs?: { windowUniqueId?: string; }) => Promise<boolean>; show: (attrs?: { windowUniqueId?: string; }) => Promise<boolean>; startFlash: (attrs?: { windowUniqueId?: string; }) => Promise<boolean>; stopFlash: (attrs?: { windowUniqueId?: string; }) => Promise<boolean>; setTitle: (attrs: { title: string; windowUniqueId?: string; }) => Promise<boolean>; getTitle: (attrs?: { windowUniqueId?: string; }) => Promise<string>; operateWindowStepByStep: (attrs: { windowUniqueId?: string; steps: { type: "sleep" | "show" | "hide" | "rectangle" | "position" | "size" | "center" | "maximize" | "unmaximize" | "minimize" | "fullscreen" | "unfullscreen" | "alwaysOnTop" | "unalwaysOnTop" | "setZoomFactor" | "increaseZoomFactor"; sleep?: number; x?: number; y?: number; width?: number; height?: number; factor?: number; }[]; }) => Promise<boolean>; maximize: (attrs?: { windowUniqueId?: string; }) => Promise<boolean>; unmaximize: (attrs?: { windowUniqueId?: string; }) => Promise<boolean>; maximizeSwitch: (attrs?: { windowUniqueId?: string; }) => Promise<boolean>; minimize: (attrs?: { windowUniqueId?: string; }) => Promise<boolean>; restore: (attrs?: { windowUniqueId?: string; }) => Promise<boolean>; setWindowFullscreen: (attrs?: { windowUniqueId?: string; }) => Promise<boolean>; unsetWindowFullscreen: (attrs?: { windowUniqueId?: string; }) => Promise<boolean>; setWindowAlwaysOnTop: (attrs?: { windowUniqueId?: string; }) => Promise<boolean>; unsetWindowAlwaysOnTop: (attrs?: { windowUniqueId?: string; }) => Promise<boolean>; setRectangle: (attrs: { x: number; y: number; width: number; height: number; windowUniqueId?: string; }) => Promise<boolean>; getRectangle: (attrs?: { windowUniqueId?: string; }) => Promise<NODEDDK.Rectangle | undefined>; setCenter: (attrs?: { windowUniqueId?: string; }) => Promise<boolean>; getAllWindowStatistics: () => Promise<NODEDDK.ModuleRendererResponse>; activeAndFocus: (attrs?: { windowUniqueId?: string; }) => Promise<boolean>; setZoomFactor: (attrs: { factor: number; windowUniqueId?: string; } | number) => Promise<number>; increaseZoomFactor: (attrs: { factor: number; windowUniqueId?: string; } | number) => Promise<number>; getZoomFactor: () => Promise<number>; registerBeforeunloadOnce: (cb: () => Promise<boolean | undefined | void>) => Promise<void>; registerMaximizeState: (cb: (isMaximized: boolean) => any) => Promise<void>; }; systemMenu: { show: (attrs: { afterClose?: NODEDDK.generalFunction; position?: { x: number; y: number; }; menus: NODEDDK.MenuItem[]; minAbcCharLength?: number; }) => void; }; tray: { startFlashing: (attrs?: { period?: number; speed?: number; tooltip?: string; }) => Promise<boolean>; stopFlashing: () => Promise<boolean>; setToolTip: (tooltip: { tooltip: string; } | string) => Promise<boolean>; }; systemNotification: { notify: (attrs: { title: string; body: string; silent?: boolean; }) => Promise<"click" | "cancel" | "error">; }; desktopCapturer: { screenshot: (jsWebScreenShotUmdJsUrl: string, attrs?: { hideMe?: boolean; hideCursor?: boolean; }) => Promise<string>; }; shell: { openLocalFile: (attrs: NODEDDK.OpenLocalFileOptions) => Promise<boolean>; openUrl: (attrs: NODEDDK.OpenUrlOptions) => Promise<boolean>; }; dialog: { getOneOpenFile: (options: NODEDDK.DialogOpenOptions) => Promise<string>; getOneOpenDir: (options: NODEDDK.DialogOpenOptions) => Promise<string>; getOpenFileList: (options: NODEDDK.DialogOpenOptions) => Promise<string[]>; getOpenDirList: (options: NODEDDK.DialogOpenOptions) => Promise<string[]>; getOneSaveFile: (options: NODEDDK.DialogSaveFileOptions) => Promise<string>; getOneSaveDir: (options: NODEDDK.DialogSaveDirOptions) => Promise<string>; showMessageBox: (options: NODEDDK.DialogMessageBox) => Promise<{ response: number; checkboxChecked: boolean; }>; alert: (options: NODEDDK.DialogAlertBox) => Promise<string>; }; fs: { getFileInfo: (filePath: string) => Promise<NODEDDK.FileInfo>; getFileInfoList: (filePaths: string[]) => Promise<{ [key: string]: NODEDDK.FileInfo; }>; }; findInPage: { find: (options: NODEDDK.FindInPageOptions) => Promise<NODEDDK.FindInPageResult>; stop: () => Promise<void>; }; }; export default _default;