添加javascript的声明文件

This commit is contained in:
fofolee 2022-03-31 10:23:50 +08:00
parent b78f23bf0a
commit 2cda100a5d
8 changed files with 10286 additions and 0 deletions

58
package-lock.json generated
View File

@ -13,6 +13,7 @@
"monaco-editor": "^0.33.0",
"monaco-editor-webpack-plugin": "^7.0.1",
"quasar": "^2.6.0",
"raw-loader": "^4.0.2",
"vue": "^3.0.0",
"vue-router": "^4.0.0"
},
@ -8954,6 +8955,42 @@
"node": ">= 0.8"
}
},
"node_modules/raw-loader": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/raw-loader/-/raw-loader-4.0.2.tgz",
"integrity": "sha512-ZnScIV3ag9A4wPX/ZayxL/jZH+euYb6FcUinPcgiQW0+UBtEv0O6Q3lGd3cqJ+GHH+rksEv3Pj99oxJ3u3VIKA==",
"dependencies": {
"loader-utils": "^2.0.0",
"schema-utils": "^3.0.0"
},
"engines": {
"node": ">= 10.13.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/webpack"
},
"peerDependencies": {
"webpack": "^4.0.0 || ^5.0.0"
}
},
"node_modules/raw-loader/node_modules/schema-utils": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.1.1.tgz",
"integrity": "sha512-Y5PQxS4ITlC+EahLuXaY86TXfR7Dc5lw294alXOq86JAHCihAIZfqv8nNCWvaEJvaC51uN9hbLGeV0cFBdH+Fw==",
"dependencies": {
"@types/json-schema": "^7.0.8",
"ajv": "^6.12.5",
"ajv-keywords": "^3.5.2"
},
"engines": {
"node": ">= 10.13.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/webpack"
}
},
"node_modules/readable-stream": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz",
@ -17980,6 +18017,27 @@
"unpipe": "1.0.0"
}
},
"raw-loader": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/raw-loader/-/raw-loader-4.0.2.tgz",
"integrity": "sha512-ZnScIV3ag9A4wPX/ZayxL/jZH+euYb6FcUinPcgiQW0+UBtEv0O6Q3lGd3cqJ+GHH+rksEv3Pj99oxJ3u3VIKA==",
"requires": {
"loader-utils": "^2.0.0",
"schema-utils": "^3.0.0"
},
"dependencies": {
"schema-utils": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.1.1.tgz",
"integrity": "sha512-Y5PQxS4ITlC+EahLuXaY86TXfR7Dc5lw294alXOq86JAHCihAIZfqv8nNCWvaEJvaC51uN9hbLGeV0cFBdH+Fw==",
"requires": {
"@types/json-schema": "^7.0.8",
"ajv": "^6.12.5",
"ajv-keywords": "^3.5.2"
}
}
}
},
"readable-stream": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz",

View File

@ -16,6 +16,7 @@
"monaco-editor": "^0.33.0",
"monaco-editor-webpack-plugin": "^7.0.1",
"quasar": "^2.6.0",
"raw-loader": "^4.0.2",
"vue": "^3.0.0",
"vue-router": "^4.0.0"
},

View File

@ -130,6 +130,11 @@
import globalVars from "components/GlobalVars";
import * as monaco from "monaco-editor";
import { toRaw } from "vue";
import utoolsApi from "!raw-loader!../types/utools.api.d.ts";
import quickcommandApi from "!raw-loader!../types/quickcommand.api.d.ts";
import electronApi from "!raw-loader!../types/electron.d.ts";
import nodeApi from "!raw-loader!../types/node.api.d.ts";
import commonApi from "!raw-loader!../types/common.d.ts";
export default {
data() {
@ -181,6 +186,20 @@ export default {
that.runCurrentCommand();
}
);
monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({
noSemanticValidation: true,
noSyntaxValidation: false,
});
monaco.languages.typescript.javascriptDefaults.setCompilerOptions({
target: monaco.languages.typescript.ScriptTarget.ES6,
allowNonTsExtensions: true,
allowJs: true,
lib: [],
});
monaco.languages.typescript.javascriptDefaults.addExtraLib(
quickcommandApi + utoolsApi + electronApi + nodeApi + commonApi,
"api.d.ts"
);
},
getEditorValue() {
return toRaw(this.editor).getValue();

103
src/types/common.d.ts vendored Normal file
View File

@ -0,0 +1,103 @@
// Axios
interface AxiosRequestConfig<D = any> {
url?: string;
method?: Method;
baseURL?: string;
transformRequest?: AxiosRequestTransformer | AxiosRequestTransformer[];
transformResponse?: AxiosResponseTransformer | AxiosResponseTransformer[];
headers?: AxiosRequestHeaders;
params?: any;
paramsSerializer?: (params: any) => string;
data?: D;
timeout?: number;
timeoutErrorMessage?: string;
withCredentials?: boolean;
adapter?: AxiosAdapter;
auth?: AxiosBasicCredentials;
responseType?: ResponseType;
xsrfCookieName?: string;
xsrfHeaderName?: string;
onUploadProgress?: (progressEvent: any) => void;
onDownloadProgress?: (progressEvent: any) => void;
maxContentLength?: number;
validateStatus?: ((status: number) => boolean) | null;
maxBodyLength?: number;
maxRedirects?: number;
socketPath?: string | null;
httpAgent?: any;
httpsAgent?: any;
proxy?: AxiosProxyConfig | false;
cancelToken?: CancelToken;
decompress?: boolean;
transitional?: TransitionalOptions;
signal?: AbortSignal;
insecureHTTPParser?: boolean;
}
interface Axios {
constructor(config?: AxiosRequestConfig);
defaults: AxiosDefaults;
interceptors: {
request: AxiosInterceptorManager<AxiosRequestConfig>;
response: AxiosInterceptorManager<AxiosResponse>;
};
getUri(config?: AxiosRequestConfig): string;
request<T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>;
get<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
delete<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
head<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
options<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
post<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;
put<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;
patch<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;
}
declare var axios: Axios;
// Audio
declare var Audio: {
new(src?: string): HTMLAudioElement;
};
// fetch
interface RequestInit {
// whatwg/fetch standard options
body?: BodyInit | undefined;
headers?: HeadersInit | undefined;
method?: string | undefined;
redirect?: RequestRedirect | undefined;
signal?: AbortSignal | null | undefined;
// node-fetch extensions
agent?: RequestOptions['agent'] | ((parsedUrl: URL) => RequestOptions['agent']); // =null http.Agent instance, allows custom proxy, certificate etc.
compress?: boolean | undefined; // =true support gzip/deflate content encoding. false to disable
follow?: number | undefined; // =20 maximum redirect count. 0 to not follow redirect
size?: number | undefined; // =0 maximum response body size in bytes. 0 to disable
timeout?: number | undefined; // =0 req/res timeout in ms, it resets on redirect. 0 to disable (OS limit applies)
// node-fetch does not support mode, cache or credentials options
}
declare function fetch(
url: RequestInfo,
init?: RequestInit
): Promise<Response>;
// console
declare var console: {
log(message?: any, ...optionalParams: any[]): void,
error(message?: any, ...optionalParams: any[]): void
}
// process
declare var process: {
argv: any[];
title: string;
version: string;
versions: object;
arch: string;
platform: string;
env: object;
pid: number;
features: object
}

762
src/types/electron.d.ts vendored Normal file
View File

@ -0,0 +1,762 @@
interface Clipboard {
// Docs: https://electronjs.org/docs/api/clipboard
/**
* An array of supported formats for the clipboard `type`.
*/
availableFormats(type?: 'selection' | 'clipboard'): string[];
/**
* Clears the clipboard content.
*/
clear(type?: 'selection' | 'clipboard'): void;
/**
* Whether the clipboard supports the specified `format`.
*
* @experimental
*/
has(format: string, type?: 'selection' | 'clipboard'): boolean;
/**
* Reads `format` type from the clipboard.
*
* `format` should contain valid ASCII characters and have `/` separator. `a/c`,
* `a/bc` are valid formats while `/abc`, `abc/`, `a/`, `/a`, `a` are not valid.
*
* @experimental
*/
read(format: string): string;
/**
* * `title` string
* * `url` string
*
* Returns an Object containing `title` and `url` keys representing the bookmark in
* the clipboard. The `title` and `url` values will be empty strings when the
* bookmark is unavailable. The `title` value will always be empty on Windows.
*
* @platform darwin,win32
*/
readBookmark(): ReadBookmark;
/**
* Reads `format` type from the clipboard.
*
* @experimental
*/
readBuffer(format: string): Buffer;
/**
* The text on the find pasteboard, which is the pasteboard that holds information
* about the current state of the active applications find panel.
*
* This method uses synchronous IPC when called from the renderer process. The
* cached value is reread from the find pasteboard whenever the application is
* activated.
*
* @platform darwin
*/
readFindText(): string;
/**
* The content in the clipboard as markup.
*/
readHTML(type?: 'selection' | 'clipboard'): string;
/**
* The image content in the clipboard.
*/
readImage(type?: 'selection' | 'clipboard'): NativeImage;
/**
* The content in the clipboard as RTF.
*/
readRTF(type?: 'selection' | 'clipboard'): string;
/**
* The content in the clipboard as plain text.
*/
readText(type?: 'selection' | 'clipboard'): string;
/**
* Writes `data` to the clipboard.
*/
write(data: Data, type?: 'selection' | 'clipboard'): void;
/**
* Writes the `title` (macOS only) and `url` into the clipboard as a bookmark.
*
* **Note:** Most apps on Windows don't support pasting bookmarks into them so you
* can use `clipboard.write` to write both a bookmark and fallback text to the
* clipboard.
*
* @platform darwin,win32
*/
writeBookmark(title: string, url: string, type?: 'selection' | 'clipboard'): void;
/**
* Writes the `buffer` into the clipboard as `format`.
*
* @experimental
*/
writeBuffer(format: string, buffer: Buffer, type?: 'selection' | 'clipboard'): void;
/**
* Writes the `text` into the find pasteboard (the pasteboard that holds
* information about the current state of the active applications find panel) as
* plain text. This method uses synchronous IPC when called from the renderer
* process.
*
* @platform darwin
*/
writeFindText(text: string): void;
/**
* Writes `markup` to the clipboard.
*/
writeHTML(markup: string, type?: 'selection' | 'clipboard'): void;
/**
* Writes `image` to the clipboard.
*/
writeImage(image: NativeImage, type?: 'selection' | 'clipboard'): void;
/**
* Writes the `text` into the clipboard in RTF.
*/
writeRTF(text: string, type?: 'selection' | 'clipboard'): void;
/**
* Writes the `text` into the clipboard as plain text.
*/
writeText(text: string, type?: 'selection' | 'clipboard'): void;
}
interface ContextBridge {
// Docs: https://electronjs.org/docs/api/context-bridge
exposeInMainWorld(apiKey: string, api: any): void;
}
interface CrashReporter {
// Docs: https://electronjs.org/docs/api/crash-reporter
/**
* Set an extra parameter to be sent with the crash report. The values specified
* here will be sent in addition to any values set via the `extra` option when
* `start` was called.
*
* Parameters added in this fashion (or via the `extra` parameter to
* `crashReporter.start`) are specific to the calling process. Adding extra
* parameters in the main process will not cause those parameters to be sent along
* with crashes from renderer or other child processes. Similarly, adding extra
* parameters in a renderer process will not result in those parameters being sent
* with crashes that occur in other renderer processes or in the main process.
*
* **Note:** Parameters have limits on the length of the keys and values. Key names
* must be no longer than 39 bytes, and values must be no longer than 20320 bytes.
* Keys with names longer than the maximum will be silently ignored. Key values
* longer than the maximum length will be truncated.
*/
addExtraParameter(key: string, value: string): void;
/**
* The date and ID of the last crash report. Only crash reports that have been
* uploaded will be returned; even if a crash report is present on disk it will not
* be returned until it is uploaded. In the case that there are no uploaded
* reports, `null` is returned.
*
* **Note:** This method is only available in the main process.
*/
getLastCrashReport(): CrashReport;
/**
* The current 'extra' parameters of the crash reporter.
*/
getParameters(): Record<string, string>;
/**
* Returns all uploaded crash reports. Each report contains the date and uploaded
* ID.
*
* **Note:** This method is only available in the main process.
*/
getUploadedReports(): CrashReport[];
/**
* Whether reports should be submitted to the server. Set through the `start`
* method or `setUploadToServer`.
*
* **Note:** This method is only available in the main process.
*/
getUploadToServer(): boolean;
/**
* Remove an extra parameter from the current set of parameters. Future crashes
* will not include this parameter.
*/
removeExtraParameter(key: string): void;
/**
* This would normally be controlled by user preferences. This has no effect if
* called before `start` is called.
*
* **Note:** This method is only available in the main process.
*/
setUploadToServer(uploadToServer: boolean): void;
/**
* This method must be called before using any other `crashReporter` APIs. Once
* initialized this way, the crashpad handler collects crashes from all
* subsequently created processes. The crash reporter cannot be disabled once
* started.
*
* This method should be called as early as possible in app startup, preferably
* before `app.on('ready')`. If the crash reporter is not initialized at the time a
* renderer process is created, then that renderer process will not be monitored by
* the crash reporter.
*
* **Note:** You can test out the crash reporter by generating a crash using
* `process.crash()`.
*
* **Note:** If you need to send additional/updated `extra` parameters after your
* first call `start` you can call `addExtraParameter`.
*
* **Note:** Parameters passed in `extra`, `globalExtra` or set with
* `addExtraParameter` have limits on the length of the keys and values. Key names
* must be at most 39 bytes long, and values must be no longer than 127 bytes. Keys
* with names longer than the maximum will be silently ignored. Key values longer
* than the maximum length will be truncated.
*
* **Note:** This method is only available in the main process.
*/
start(options: CrashReporterStartOptions): void;
}
interface IpcRenderer extends NodeJS.EventEmitter {
// Docs: https://electronjs.org/docs/api/ipc-renderer
/**
* Resolves with the response from the main process.
*
* Send a message to the main process via `channel` and expect a result
* asynchronously. Arguments will be serialized with the Structured Clone
* Algorithm, just like `window.postMessage`, so prototype chains will not be
* included. Sending Functions, Promises, Symbols, WeakMaps, or WeakSets will throw
* an exception.
*
* > **NOTE:** Sending non-standard JavaScript types such as DOM objects or special
* Electron objects will throw an exception.
*
* Since the main process does not have support for DOM objects such as
* `ImageBitmap`, `File`, `DOMMatrix` and so on, such objects cannot be sent over
* Electron's IPC to the main process, as the main process would have no way to
* decode them. Attempting to send such objects over IPC will result in an error.
*
* The main process should listen for `channel` with `ipcMain.handle()`.
*
* For example:
*
* If you need to transfer a `MessagePort` to the main process, use
* `ipcRenderer.postMessage`.
*
* If you do not need a response to the message, consider using `ipcRenderer.send`.
*/
invoke(channel: string, ...args: any[]): Promise<any>;
/**
* Listens to `channel`, when a new message arrives `listener` would be called with
* `listener(event, args...)`.
*/
on(channel: string, listener: (event: IpcRendererEvent, ...args: any[]) => void): this;
/**
* Adds a one time `listener` function for the event. This `listener` is invoked
* only the next time a message is sent to `channel`, after which it is removed.
*/
once(channel: string, listener: (event: IpcRendererEvent, ...args: any[]) => void): this;
/**
* Send a message to the main process, optionally transferring ownership of zero or
* more `MessagePort` objects.
*
* The transferred `MessagePort` objects will be available in the main process as
* `MessagePortMain` objects by accessing the `ports` property of the emitted
* event.
*
* For example:
*
* For more information on using `MessagePort` and `MessageChannel`, see the MDN
* documentation.
*/
postMessage(channel: string, message: any, transfer?: MessagePort[]): void;
/**
* Removes all listeners, or those of the specified `channel`.
*/
removeAllListeners(channel: string): this;
/**
* Removes the specified `listener` from the listener array for the specified
* `channel`.
*/
removeListener(channel: string, listener: (...args: any[]) => void): this;
/**
* Send an asynchronous message to the main process via `channel`, along with
* arguments. Arguments will be serialized with the Structured Clone Algorithm,
* just like `window.postMessage`, so prototype chains will not be included.
* Sending Functions, Promises, Symbols, WeakMaps, or WeakSets will throw an
* exception.
*
* > **NOTE:** Sending non-standard JavaScript types such as DOM objects or special
* Electron objects will throw an exception.
*
* Since the main process does not have support for DOM objects such as
* `ImageBitmap`, `File`, `DOMMatrix` and so on, such objects cannot be sent over
* Electron's IPC to the main process, as the main process would have no way to
* decode them. Attempting to send such objects over IPC will result in an error.
*
* The main process handles it by listening for `channel` with the `ipcMain`
* module.
*
* If you need to transfer a `MessagePort` to the main process, use
* `ipcRenderer.postMessage`.
*
* If you want to receive a single response from the main process, like the result
* of a method call, consider using `ipcRenderer.invoke`.
*/
send(channel: string, ...args: any[]): void;
/**
* The value sent back by the `ipcMain` handler.
*
* Send a message to the main process via `channel` and expect a result
* synchronously. Arguments will be serialized with the Structured Clone Algorithm,
* just like `window.postMessage`, so prototype chains will not be included.
* Sending Functions, Promises, Symbols, WeakMaps, or WeakSets will throw an
* exception.
*
* > **NOTE:** Sending non-standard JavaScript types such as DOM objects or special
* Electron objects will throw an exception.
*
* Since the main process does not have support for DOM objects such as
* `ImageBitmap`, `File`, `DOMMatrix` and so on, such objects cannot be sent over
* Electron's IPC to the main process, as the main process would have no way to
* decode them. Attempting to send such objects over IPC will result in an error.
*
* The main process handles it by listening for `channel` with `ipcMain` module,
* and replies by setting `event.returnValue`.
*
* > :warning: **WARNING**: Sending a synchronous message will block the whole
* renderer process until the reply is received, so use this method only as a last
* resort. It's much better to use the asynchronous version, `invoke()`.
*/
sendSync(channel: string, ...args: any[]): any;
/**
* Sends a message to a window with `webContentsId` via `channel`.
*/
sendTo(webContentsId: number, channel: string, ...args: any[]): void;
/**
* Like `ipcRenderer.send` but the event will be sent to the `<webview>` element in
* the host page instead of the main process.
*/
sendToHost(channel: string, ...args: any[]): void;
}
interface IpcRendererEvent extends Event {
// Docs: https://electronjs.org/docs/api/structures/ipc-renderer-event
/**
* A list of MessagePorts that were transferred with this message
*/
ports: MessagePort[];
/**
* The `IpcRenderer` instance that emitted the event originally
*/
sender: IpcRenderer;
/**
* The `webContents.id` that sent the message, you can call
* `event.sender.sendTo(event.senderId, ...)` to reply to the message, see
* ipcRenderer.sendTo for more information. This only applies to messages sent from
* a different renderer. Messages sent directly from the main process set
* `event.senderId` to `0`.
*/
senderId: number;
}
class NativeImage {
// Docs: https://electronjs.org/docs/api/native-image
/**
* Creates an empty `NativeImage` instance.
*/
static createEmpty(): NativeImage;
/**
* Creates a new `NativeImage` instance from `buffer` that contains the raw bitmap
* pixel data returned by `toBitmap()`. The specific format is platform-dependent.
*/
static createFromBitmap(buffer: Buffer, options: CreateFromBitmapOptions): NativeImage;
/**
* Creates a new `NativeImage` instance from `buffer`. Tries to decode as PNG or
* JPEG first.
*/
static createFromBuffer(buffer: Buffer, options?: CreateFromBufferOptions): NativeImage;
/**
* Creates a new `NativeImage` instance from `dataURL`.
*/
static createFromDataURL(dataURL: string): NativeImage;
/**
* Creates a new `NativeImage` instance from the NSImage that maps to the given
* image name. See `System Icons` for a list of possible values.
*
* The `hslShift` is applied to the image with the following rules:
*
* * `hsl_shift[0]` (hue): The absolute hue value for the image - 0 and 1 map to 0
* and 360 on the hue color wheel (red).
* * `hsl_shift[1]` (saturation): A saturation shift for the image, with the
* following key values: 0 = remove all color. 0.5 = leave unchanged. 1 = fully
* saturate the image.
* * `hsl_shift[2]` (lightness): A lightness shift for the image, with the
* following key values: 0 = remove all lightness (make all pixels black). 0.5 =
* leave unchanged. 1 = full lightness (make all pixels white).
*
* This means that `[-1, 0, 1]` will make the image completely white and `[-1, 1,
* 0]` will make the image completely black.
*
* In some cases, the `NSImageName` doesn't match its string representation; one
* example of this is `NSFolderImageName`, whose string representation would
* actually be `NSFolder`. Therefore, you'll need to determine the correct string
* representation for your image before passing it in. This can be done with the
* following:
*
* `echo -e '#import <Cocoa/Cocoa.h>\nint main() { NSLog(@"%@", SYSTEM_IMAGE_NAME);
* }' | clang -otest -x objective-c -framework Cocoa - && ./test`
*
* where `SYSTEM_IMAGE_NAME` should be replaced with any value from this list.
*
* @platform darwin
*/
static createFromNamedImage(imageName: string, hslShift?: number[]): NativeImage;
/**
* Creates a new `NativeImage` instance from a file located at `path`. This method
* returns an empty image if the `path` does not exist, cannot be read, or is not a
* valid image.
*/
static createFromPath(path: string): NativeImage;
/**
* fulfilled with the file's thumbnail preview image, which is a NativeImage.
*
* @platform darwin,win32
*/
static createThumbnailFromPath(path: string, maxSize: Size): Promise<Electron.NativeImage>;
/**
* Add an image representation for a specific scale factor. This can be used to
* explicitly add different scale factor representations to an image. This can be
* called on empty images.
*/
addRepresentation(options: AddRepresentationOptions): void;
/**
* The cropped image.
*/
crop(rect: Rectangle): NativeImage;
/**
* The image's aspect ratio.
*
* If `scaleFactor` is passed, this will return the aspect ratio corresponding to
* the image representation most closely matching the passed value.
*/
getAspectRatio(scaleFactor?: number): number;
/**
* A Buffer that contains the image's raw bitmap pixel data.
*
* The difference between `getBitmap()` and `toBitmap()` is that `getBitmap()` does
* not copy the bitmap data, so you have to use the returned Buffer immediately in
* current event loop tick; otherwise the data might be changed or destroyed.
*/
getBitmap(options?: BitmapOptions): Buffer;
/**
* A Buffer that stores C pointer to underlying native handle of the image. On
* macOS, a pointer to `NSImage` instance would be returned.
*
* Notice that the returned pointer is a weak pointer to the underlying native
* image instead of a copy, so you _must_ ensure that the associated `nativeImage`
* instance is kept around.
*
* @platform darwin
*/
getNativeHandle(): Buffer;
/**
* An array of all scale factors corresponding to representations for a given
* nativeImage.
*/
getScaleFactors(): number[];
/**
* If `scaleFactor` is passed, this will return the size corresponding to the image
* representation most closely matching the passed value.
*/
getSize(scaleFactor?: number): Size;
/**
* Whether the image is empty.
*/
isEmpty(): boolean;
/**
* Whether the image is a template image.
*/
isTemplateImage(): boolean;
/**
* The resized image.
*
* If only the `height` or the `width` are specified then the current aspect ratio
* will be preserved in the resized image.
*/
resize(options: ResizeOptions): NativeImage;
/**
* Marks the image as a template image.
*/
setTemplateImage(option: boolean): void;
/**
* A Buffer that contains a copy of the image's raw bitmap pixel data.
*/
toBitmap(options?: ToBitmapOptions): Buffer;
/**
* The data URL of the image.
*/
toDataURL(options?: ToDataURLOptions): string;
/**
* A Buffer that contains the image's `JPEG` encoded data.
*/
toJPEG(quality: number): Buffer;
/**
* A Buffer that contains the image's `PNG` encoded data.
*/
toPNG(options?: ToPNGOptions): Buffer;
/**
* A `boolean` property that determines whether the image is considered a template
* image.
*
* Please note that this property only has an effect on macOS.
*
* @platform darwin
*/
isMacTemplateImage: boolean;
}
interface Shell {
// Docs: https://electronjs.org/docs/api/shell
/**
* Play the beep sound.
*/
beep(): void;
/**
* Open the given external protocol URL in the desktop's default manner. (For
* example, mailto: URLs in the user's default mail agent).
*/
openExternal(url: string, options?: OpenExternalOptions): Promise<void>;
/**
* Resolves with a string containing the error message corresponding to the failure
* if a failure occurred, otherwise "".
*
* Open the given file in the desktop's default manner.
*/
openPath(path: string): Promise<string>;
/**
* Resolves the shortcut link at `shortcutPath`.
*
* An exception will be thrown when any error happens.
*
* @platform win32
*/
readShortcutLink(shortcutPath: string): ShortcutDetails;
/**
* Show the given file in a file manager. If possible, select the file.
*/
showItemInFolder(fullPath: string): void;
/**
* Resolves when the operation has been completed. Rejects if there was an error
* while deleting the requested item.
*
* This moves a path to the OS-specific trash location (Trash on macOS, Recycle Bin
* on Windows, and a desktop-environment-specific location on Linux).
*/
trashItem(path: string): Promise<void>;
/**
* Whether the shortcut was created successfully.
*
* Creates or updates a shortcut link at `shortcutPath`.
*
* @platform win32
*/
writeShortcutLink(shortcutPath: string, operation: 'create' | 'update' | 'replace', options: ShortcutDetails): boolean;
/**
* Whether the shortcut was created successfully.
*
* Creates or updates a shortcut link at `shortcutPath`.
*
* @platform win32
*/
writeShortcutLink(shortcutPath: string, options: ShortcutDetails): boolean;
}
interface WebFrame extends NodeJS.EventEmitter {
// Docs: https://electronjs.org/docs/api/web-frame
/**
* Attempts to free memory that is no longer being used (like images from a
* previous navigation).
*
* Note that blindly calling this method probably makes Electron slower since it
* will have to refill these emptied caches, you should only call it if an event in
* your app has occurred that makes you think your page is actually using less
* memory (i.e. you have navigated from a super heavy page to a mostly empty one,
* and intend to stay there).
*/
clearCache(): void;
/**
* A promise that resolves with the result of the executed code or is rejected if
* execution throws or results in a rejected promise.
*
* Evaluates `code` in page.
*
* In the browser window some HTML APIs like `requestFullScreen` can only be
* invoked by a gesture from the user. Setting `userGesture` to `true` will remove
* this limitation.
*/
executeJavaScript(code: string, userGesture?: boolean, callback?: (result: any, error: Error) => void): Promise<any>;
/**
* A promise that resolves with the result of the executed code or is rejected if
* execution could not start.
*
* Works like `executeJavaScript` but evaluates `scripts` in an isolated context.
*
* Note that when the execution of script fails, the returned promise will not
* reject and the `result` would be `undefined`. This is because Chromium does not
* dispatch errors of isolated worlds to foreign worlds.
*/
executeJavaScriptInIsolatedWorld(worldId: number, scripts: WebSource[], userGesture?: boolean, callback?: (result: any, error: Error) => void): Promise<any>;
/**
* A child of `webFrame` with the supplied `name`, `null` would be returned if
* there's no such frame or if the frame is not in the current renderer process.
*/
findFrameByName(name: string): WebFrame;
/**
* that has the supplied `routingId`, `null` if not found.
*/
findFrameByRoutingId(routingId: number): WebFrame;
/**
* The frame element in `webFrame's` document selected by `selector`, `null` would
* be returned if `selector` does not select a frame or if the frame is not in the
* current renderer process.
*/
getFrameForSelector(selector: string): WebFrame;
/**
* * `images` MemoryUsageDetails
* * `scripts` MemoryUsageDetails
* * `cssStyleSheets` MemoryUsageDetails
* * `xslStyleSheets` MemoryUsageDetails
* * `fonts` MemoryUsageDetails
* * `other` MemoryUsageDetails
*
* Returns an object describing usage information of Blink's internal memory
* caches.
*
* This will generate:
*/
getResourceUsage(): ResourceUsage;
/**
* A list of suggested words for a given word. If the word is spelled correctly,
* the result will be empty.
*/
getWordSuggestions(word: string): string[];
/**
* The current zoom factor.
*/
getZoomFactor(): number;
/**
* The current zoom level.
*/
getZoomLevel(): number;
/**
* A key for the inserted CSS that can later be used to remove the CSS via
* `webFrame.removeInsertedCSS(key)`.
*
* Injects CSS into the current web page and returns a unique key for the inserted
* stylesheet.
*/
insertCSS(css: string, options?: InsertCSSOptions): string;
/**
* Inserts `text` to the focused element.
*/
insertText(text: string): void;
/**
* True if the word is misspelled according to the built in spellchecker, false
* otherwise. If no dictionary is loaded, always return false.
*/
isWordMisspelled(word: string): boolean;
/**
* Removes the inserted CSS from the current web page. The stylesheet is identified
* by its key, which is returned from `webFrame.insertCSS(css)`.
*/
removeInsertedCSS(key: string): void;
/**
* Set the security origin, content security policy and name of the isolated world.
* Note: If the `csp` is specified, then the `securityOrigin` also has to be
* specified.
*/
setIsolatedWorldInfo(worldId: number, info: Info): void;
setSpellCheckProvider(language: string, provider: Provider): void;
/**
* Sets the maximum and minimum pinch-to-zoom level.
*
* > **NOTE**: Visual zoom is disabled by default in Electron. To re-enable it,
* call:
*
* > **NOTE**: Visual zoom only applies to pinch-to-zoom behavior. Cmd+/-/0 zoom
* shortcuts are controlled by the 'zoomIn', 'zoomOut', and 'resetZoom' MenuItem
* roles in the application Menu. To disable shortcuts, manually define the Menu
* and omit zoom roles from the definition.
*/
setVisualZoomLevelLimits(minimumLevel: number, maximumLevel: number): void;
/**
* Changes the zoom factor to the specified factor. Zoom factor is zoom percent
* divided by 100, so 300% = 3.0.
*
* The factor must be greater than 0.0.
*/
setZoomFactor(factor: number): void;
/**
* Changes the zoom level to the specified level. The original size is 0 and each
* increment above or below represents zooming 20% larger or smaller to default
* limits of 300% and 50% of original size, respectively.
*
* > **NOTE**: The zoom policy at the Chromium level is same-origin, meaning that
* the zoom level for a specific domain propagates across all instances of windows
* with the same domain. Differentiating the window URLs will make zoom work
* per-window.
*/
setZoomLevel(level: number): void;
/**
* A `WebFrame | null` representing the first child frame of `webFrame`, the
* property would be `null` if `webFrame` has no children or if first child is not
* in the current renderer process.
*
*/
readonly firstChild: (WebFrame) | (null);
/**
* A `WebFrame | null` representing next sibling frame, the property would be
* `null` if `webFrame` is the last frame in its parent or if the next sibling is
* not in the current renderer process.
*
*/
readonly nextSibling: (WebFrame) | (null);
/**
* A `WebFrame | null` representing the frame which opened `webFrame`, the property
* would be `null` if there's no opener or opener is not in the current renderer
* process.
*
*/
readonly opener: (WebFrame) | (null);
/**
* A `WebFrame | null` representing parent frame of `webFrame`, the property would
* be `null` if `webFrame` is top or parent is not in the current renderer process.
*
*/
readonly parent: (WebFrame) | (null);
/**
* An `Integer` representing the unique frame id in the current renderer process.
* Distinct WebFrame instances that refer to the same underlying frame will have
* the same `routingId`.
*
*/
readonly routingId: number;
/**
* A `WebFrame | null` representing top frame in frame hierarchy to which
* `webFrame` belongs, the property would be `null` if top frame is not in the
* current renderer process.
*
*/
readonly top: (WebFrame) | (null);
}
declare var electron: {
clipboard: Clipboard
contextBridge: ContextBridge
crashReporter: CrashReporter
ipcRenderer: IpcRenderer
nativeImage: NativeImage
shell: Shell
webFrame: WebFrame
}

8420
src/types/node.api.d.ts vendored Normal file

File diff suppressed because it is too large Load Diff

274
src/types/quickcommand.api.d.ts vendored Normal file
View File

@ -0,0 +1,274 @@
interface quickcommandApi {
/**
*
*
* ```js
* quickcommand.showButtonBox(["按钮1", "按钮2", "按钮3"]).then(({ id, text }) => {
* console.log(`选择了第${id+1}个按钮`)
* console.log(`按钮的文本为${text}`)
* })
* ```
*
* @param buttons
* @param title
*/
showButtonBox(buttons: array, title?: string): Promise<{ id: number, text: string }>;
/**
*
*
* ```js
* quickcommand.showInputBox(["输入框1", "输入框2", "输入框3"]).then(values => {
* console.log(`输入的内容分别为${values}`)
* })
* ```
*
* @param labels
* @param title
*/
showInputBox(labels: array, title?: string): Promise<array>;
/**
*
*
* ```js
* // plaintext
* var opt = []
* for (var i = 0; i < 15; i++) {
* // 每一个选项为文本格式
* opt.push(`选项` + i)
* }
* quickcommand.showSelectList(opt).then(choise => {
* console.log(`选择的选项为${choise.text}`)
* })
*
* // json
* var opt = []
* for (var i = 0; i < 15; i++) {
* // 每一个选项为 json 格式
* opt.push({title: `选项${i}`, description: `选项${i}的描述`, abcd: `选项${i}的自定义属性`})
* }
* quickcommand.showSelectList(opt, {optionType: 'json'}).then(choise => {
* console.log(`选择的选项为${choise.title}`)
* })
*
* // html
* var opt = []
* for (var i = 0; i < 15; i++) {
* // 每一个选项为 html 格式
* opt.push(`<div style="color: red">选项${i}</div>`)
* }
* quickcommand.showSelectList(opt, {optionType: 'html'}).then(choise => {
* console.log(`选择的选项为${quickcommand.htmlParse(choise.text).body.innerText}`)
* })
* ```
*
* @param selects
* @param options placeholder: 搜索框占位符,optionType: 选项的格式plaintext
*/
showSelectList(selects: array, options?: { placeholder: string, optionType: 'plaintext' | 'html' | 'json' }): Promise<{ id: number, text: string }>;
/**
*
*
* ```js
* // 初始状态只有 1、2、3 三个选项
* quickcommand.showSelectList(['1','2','3']).then(x=>{
* console.log(x)
* })
*
* // 1s 后追加一个选项
* quickcommand.setTimeout(()=>{
* quickcommand.updateSelectList('4')
* }, 1000)
*
* // 2s 后更新第二个选项的值
* quickcommand.setTimeout(()=>{
* quickcommand.updateSelectList('updated', 1)
* }, 2000)
* ```
*
* @param opt
* @param id
*/
updateSelectList(opt: string, id?: number): void;
/**
*
*
* ```js
* quickcommand.showTextAera("请输入文本").then(text=>{
* console.log(`输入的文本为${text}`)
* })
* ```
*
* @param placeholder
* @param value
*/
showTextAera(placeholder?: string, value?: string): Promise<string>;
/**
*
*
* ```js
* quickcommand.showMessageBox("这是一段3s后自动消失的成功提示")
* ```
* @param message
* @param icon success
* @param time 3000
*/
showMessageBox(message: string, icon?: 'success' | 'error' | 'warning' | 'info' | 'question', time?: number): void;
/**
*
*
* ```js
* quickcommand.showConfirmBox().then(confirmed => {
* confirmed && console.log('点击了确定')
* })
* ```
* @param title
*/
showConfirmBox(title?: string): Promise<boolean>;
/**
*
* @param ms
*/
sleep(ms: number): void;
/**
*
*
* ```js
* quickcommand.setTimeout(()=>{
* console.log('2000毫秒后执行')
* }, 2000)
* ```
*
* @param ms
*/
setTimeout(callback: () => void, ms)
/**
* html字符串解析为 DOM
*
* ```js
* var html = `<a href="https://u.tools/">uTools</a>`
* var href = quickcommand.htmlParse(html).querySelector('a').href
* console.log(`解析出来的a标签地址为${href}`)
* ```
*
* @param html html
*/
htmlParse(html: string): object
/**
* Buffer
*
* ```js
* // 下载文件到D:/
* quickcommand.downloadFile('https://res.u-tools.cn/currentversion/uTools-1.1.3.exe', 'D:/')
*
* // 下载文件,并弹出对话框询问保存路径
* quickcommand.downloadFile('https://res.u-tools.cn/currentversion/uTools-1.1.3.exe')
* ```
*
* @param url
* @param file
*
* Object时 options utools.showSaveDialog options一致
*/
downloadFile(url, file?: string | object): Promise<Buffer>
/**
*
*
* ```js
* // 上传图片到图床
* quickcommand.uploadFile("https://imgkr.com/api/v2/files/upload", "C:\\test.jpg").then(res=>{
* console.log('上传成功,图片地址为:' + res.data.data)
* })
*
* // 包含额外表单数据
* quickcommand.uploadFile("https://catbox.moe/user/api.php", "C:\\test.jpg", 'fileToUpload', {
* "reqtype": "fileupload"
* }).then(res=>{
* console.log('上传成功,图片地址为:' + res.data)
* })
* ```
*
* @param url
* @param file
*
* Object时 options utools.showOpenDialog options一致
*
* @param name file
* @param formData
*/
uploadFile(url: string, file?: string | object, name?: string, formData?: object): Promise<object>
/**
* export
*
* ```js
* let remote = 'https://cdn.jsdelivr.net/npm/sweetalert2@9'
* quickcommand.loadRemoteScript(remote).then(swal => {
* swal.fire('已加载 sweetalert2 并成功弹窗')
* })
* ```
*
* @param url
*/
loadRemoteScript(url: string): Promise<object>
/**
* signal pid , process.kill
* @param pid ID
* @param signal SIGTERM
*/
kill(pid: number, signal?: number | string): void
/**
* windows VBS
*
* ```js
* quickcommand.runVbs(`CreateObject("SAPI.SpVoice").Speak"Hello"`)
* ```
*
* @param script VBS
*/
runVbs(script: string): Promise<string>
/**
* utools.onPluginEnter code type payload
*
* code: 唯一标识
*
* type: text | img | files | regex | over | window
*
* payload: 当匹配模式为关键字时
*
* ```js
* if (quickcommand.enterData.type == 'regex'){
* var text = quickcommand.enterData.payload
* console.log(`主输入框匹配的文本为${text}`)
* }
* ```
*
*/
enterData: { code: string, type: string, payload: any }
/**
*
*/
simulateCopy()
/**
*
*/
simulatePaste()
}
declare var quickcommand: quickcommandApi;

649
src/types/utools.api.d.ts vendored Normal file
View File

@ -0,0 +1,649 @@
interface UBrowser {
/**
* User-Agent
*/
useragent(userAgent: string): this;
/**
*
* @param url , http file
* @param headers
* @param timeout , 60000 ms(60)
*/
goto(url: string, headers?: { Referer: string, userAgent: string }, timeout?: number): this;
/**
*
*/
viewport(width: number, height: number): this;
/**
* ubrowser
*/
hide(): this;
/**
* ubrowser
*/
show(): this;
/**
*
*/
css(css: string): this;
/**
*
*/
press(key: string, ...modifier: ('control' | 'ctrl' | 'shift' | 'meta' | 'alt' | 'command' | 'cmd')[]): this;
/**
*
* @param text base64编码字符串
*/
paste(text?: string): this;
/**
*
* @param arg 1. - DOM元素 2. - 3. -
* @param savePath .png文件完全路径,
*/
screenshot(arg: string | { x: number, y: number, width: number, height: number }, savePath?: string): this;
/**
* PDF
* @param options
* @param savePath PDF保存路径 .pdf文件完全路径,
*/
pdf(options?: { marginsType: 0 | 1 | 2, pageSize: ('A3' | 'A4' | 'A5' | 'Legal' | 'Letter' | 'Tabloid') | ({ width: number, height: number }) }, savePath?: string): this;
/**
*
*/
device(arg: ('iPhone 11' | 'iPhone X' | 'iPad' | 'iPhone 6/7/8 Plus' | 'iPhone 6/7/8' | 'iPhone 5/SE' | 'HUAWEI Mate10' | 'HUAWEI Mate20' | 'HUAWEI Mate30' | 'HUAWEI Mate30 Pro') | { size: { width: number, height: number }, useragent: string }): this;
/**
* cookie
* @param name cookie
*/
cookies(name?: string): this;
/**
* Cookie
*/
setCookies(name: string, value: string): this;
/**
* Cookie
*/
setCookies(cookies: { name: string, value: string }[]): this;
/**
* cookie
*/
removeCookies(name: string): this;
/**
* cookie
* @param url "goto" url参数必需
*/
clearCookies(url?: string): this;
/**
*
*/
devTools(mode?: 'right' | 'bottom' | 'undocked' | 'detach'): this;
/**
* JS计算
* @param func
* @param params func
*/
evaluate(func: (...params: any[]) => any, ...params: any[]): this;
/**
*
* @param ms
*/
wait(ms: number): this;
/**
*
* @param selector DOM元素
* @param timeout 60000 ms(60)
*/
wait(selector: string, timeout?: number): this;
/**
* JS函数 true
* @param func JS函数
* @param timeout 60000 ms(60)
* @param params func
*/
wait(func: (...params: any[]) => boolean, timeout?: number, ...params: any[]): this;
/**
* end
* @param selector DOM元素
*/
when(selector: string): this;
/**
* JS函数执行返回 true end
* @param func JS函数
* @param params func
*/
when(func: (...params: any[]) => boolean, ...params: any[]): this;
/**
* when 使
*/
end(): this;
/**
*
*/
click(selector: string): this;
/**
*
*/
mousedown(selector: string): this;
/**
*
*/
mouseup(selector: string): this;
/**
* file input
* @param selector <input type='file' />
* @param payload 1. string - base64编码2. string[] - 3. Uint8Array[]
*/
file(selector: string, payload: string | string[] | Uint8Array): this;
/**
* input textarea select input change事件
*/
value(selector: string, value: string): this;
/**
* checkbox radio
*/
check(selector: string, checked: boolean): this;
/**
*
*/
focus(selector: string): this;
/**
*
*/
scroll(selector: string): this;
/**
* Y轴滚动
*/
scroll(y: number): this;
/**
* X轴和Y轴滚动
*/
scroll(x: number, y: number): this;
/**
* ubrowser
* @param ubrowserId utools.getIdleUBrowsers()
*/
run(ubrowserId: number): Promise<any[]>;
/**
* ubrowser
*
* @param options
*/
run(options: {
show?: boolean,
width?: number,
height?: number,
x?: number,
y?: number,
center?: boolean,
minWidth?: number,
minHeight?: number,
maxWidth?: number,
maxHeight?: number,
resizable?: boolean,
movable?: boolean,
minimizable?: boolean,
maximizable?: boolean,
alwaysOnTop?: boolean,
fullscreen?: boolean,
fullscreenable?: boolean,
enableLargerThanScreen?: boolean,
opacity?: number
}): Promise<any[]>;
}
interface Display {
accelerometerSupport: ('available' | 'unavailable' | 'unknown');
bounds: { x: number, y: number, width: number, height: number };
colorDepth: number;
colorSpace: string;
depthPerComponent: number;
id: number;
internal: boolean;
monochrome: boolean;
rotation: number;
scaleFactor: number;
size: { width: number, height: number };
touchSupport: ('available' | 'unavailable' | 'unknown');
workArea: { x: number, y: number, width: number, height: number };
workAreaSize: { width: number, height: number };
}
interface DbDoc {
_id: string,
_rev?: string,
[key: string]: any
}
interface DbReturn {
id: string,
rev?: string,
ok?: boolean,
error?: boolean,
name?: string,
message?: string
}
interface UToolsApi {
/**
*
*/
onPluginEnter(callback: (action: {code: string, type: string, payload: any }) => void): void;
/**
*
*/
onPluginOut(callback: () => void): void;
/**
*
*/
onPluginDetach(callback: () => void): void;
/**
*
*/
onDbPull(callback: (docs: { _id: string, _rev: string }[]) => void): void;
/**
*
* @param isRestorePreWindow true
*/
hideMainWindow(isRestorePreWindow?: boolean): boolean;
/**
*
*/
showMainWindow(): boolean;
/**
*
*/
setExpendHeight(height: number): boolean;
/**
*
* @param onChange
* @param placeholder
* @param isFocus true
*/
setSubInput(onChange: (text: string) => void, placeholder?: string, isFocus?: boolean): boolean;
/**
*
*/
removeSubInput(): boolean;
/**
*
*/
setSubInputValue(value: string): boolean;
/**
*
*/
subInputFocus(): boolean;
/**
*
*/
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;
/**
*
*/
isDarkColors(): boolean;
/**
*
*/
getUser(): { avatar: string, nickname: string, type: string } | null;
/**
*
*/
fetchUserServerTemporaryToken(): Promise<{ token: string, expiredAt: number }>;
/**
*
* @param callback
*/
openPayment(options: {
/**
* ID uTools
*/
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(): {
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
*/
getIdleUBrowsers(): { id: number, title: string, url: string}[];
/**
* ubrowser https://www.electronjs.org/docs/api/session#sessetproxyconfig
*/
setUBrowserProxy(config: {pacScript?: string, proxyRules?: string, proxyBypassRules?: string}): boolean;
/**
* ubrowser
*/
clearUBrowserCache(): boolean;
/**
*
*/
showNotification(body: string): void;
/**
*
*/
showOpenDialog(options: {
title?: string,
defaultPath?: string,
buttonLabel?: string,
filters?: { name: string, extensions: string[] }[],
properties?: Array<'openFile' | 'openDirectory' | 'multiSelections' | 'showHiddenFiles' | 'createDirectory' | 'promptToCreate' | 'noResolveAliases' | 'treatPackageAsDirectory' | 'dontAddToRecent'>,
message?: string,
securityScopedBookmarks?: boolean
}): (string[]) | (undefined);
/**
*
*/
showSaveDialog(options: {
title?: string,
defaultPath?: string,
buttonLabel?: string,
filters?: { name: string, extensions: string[] }[],
message?: string,
nameFieldLabel?: string,
showsTagField?: string,
properties?: Array<'showHiddenFiles' | 'createDirectory' | 'treatPackageAsDirectory' | 'showOverwriteConfirmation' | 'dontAddToRecent'>,
securityScopedBookmarks?: boolean
}): (string) | (undefined);
/**
*
*/
findInPage(text: string, options?: {
forward?: boolean,
findNext?: boolean,
matchCase?: boolean,
wordStart?: boolean,
medialCapitalAsWordStart?: boolean
}): void;
/**
*
*/
stopFindInPage (action: 'clearSelection' | 'keepSelection' | 'activateSelection'): void;
/**
*
*/
startDrag(file: string | string[]): void;
/**
*
*/
screenColorPick(callback: (color: { hex: string, rgb: string }) => void): void;
/**
*
*/
screenCapture(callback: (imgBase64: string) => void): void;
/**
* ID
*/
getNativeId(): string;
/**
*
*/
getAppVersion(): string;
/**
*
*/
getPath(name: 'home' | 'appData' | 'userData' | 'cache' | 'temp' | 'exe' | 'module' | 'desktop' | 'documents' | 'downloads' | 'music' | 'pictures' | 'videos' | 'logs' | 'pepperFlashSystemPlugin'): string;
/**
*
*/
getFileIcon(filePath: string): string;
/**
*
*/
copyFile(file: string | string[]): boolean;
/**
*
* @param img base64buffer
*/
copyImage(img: string | Uint8Array): boolean;
/**
*
*/
copyText(text: string): boolean;
/**
*
*/
getCopyedFiles(): { isFile: boolean, isDirectory: boolean, name: string, path: string }[];
/**
* (linux )
*/
readCurrentFolderPath(): Promise<string>;
/**
* URL(linux )
* MacOs SafariChromeOperaVivaldiBrave
* Windows ChromeFirefoxEdgeIEOperaBrave
* Linux
*/
readCurrentBrowserUrl(): Promise<string>;
/**
*
*/
shellOpenPath(fullPath: string): void;
/**
*
*/
shellShowItemInFolder(fullPath: string): void;
/**
* URL
*/
shellOpenExternal(url: string): void;
/**
*
*/
shellBeep(): void;
/**
*
*/
simulateKeyboardTap(key: string, ...modifier: ('control' | 'ctrl' | 'shift' | 'option' | 'alt' | 'command' | 'super')[]): void;
/**
*
*/
simulateMouseClick(x?: number, y?: number): void;
/**
*
*/
simulateMouseRightClick(x?: number, y?: number): void;
/**
*
*/
simulateMouseDoubleClick(x?: number, y?: number): void;
/**
*
*/
simulateMouseMove(x: number, y: number): void;
/**
*
*/
getCursorScreenPoint(): { x: number, y: number };
/**
*
*/
getPrimaryDisplay(): Display;
/**
*
*/
getAllDisplays(): Display[];
/**
*
*/
getDisplayNearestPoint(point: { x: number, y: number }): Display;
/**
*
*/
getDisplayMatching(rect: { x: number, y: number, width: number, height: number }): Display;
/**
*
*/
isDev(): boolean;
/**
* MacOs
*/
isMacOs(): boolean;
/**
* Windows
*/
isWindows(): boolean;
/**
* Linux
*/
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>;
}
};
dbStorage: {
/**
*
* @param key (ID)
* @param value
*/
setItem (key: string, value: any): void;
/**
*
*/
getItem (key: string): any;
/**
* ()
*/
removeItem (key: string): void;
};
ubrowser: UBrowser;
}
declare var utools: UToolsApi;