UNPKG

sussudio

Version:

An unofficial VS Code Internal API

129 lines (128 loc) 5.49 kB
/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ export interface IpcRendererEvent extends Event { /** * 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; } export interface IpcRenderer { /** * 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; /** * 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; /** * 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>; } export interface WebFrame { /** * 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; } export interface ProcessMemoryInfo { /** * The amount of memory not shared by other processes, such as JS heap or HTML * content in Kilobytes. */ private: number; /** * The amount of memory currently pinned to actual physical RAM in Kilobytes. * * @platform linux,win32 */ residentSet: number; /** * The amount of memory shared between processes, typically memory consumed by the * Electron code itself in Kilobytes. */ shared: number; } /** * Additional information around a `app.on('login')` event. */ export interface AuthInfo { isProxy: boolean; scheme: string; host: string; port: number; realm: string; }