Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
467
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Generated by typings
  2. // Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/0e9b30d821df52555eb2fdc9dfc8807ee21763eb/github-electron/github-electron.d.ts
  3. // Type definitions for Electron v1.2.1
  4. // Project: http://electron.atom.io/
  5. // Definitions by: jedmao <https://github.com/jedmao/>, rhysd <https://rhysd.github.io>, Milan Burda <https://github.com/miniak/>
  6. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  7.  
  8.  
  9. declare namespace Electron {
  10.  
  11.     class EventEmitter implements NodeJS.EventEmitter {
  12.         addListener(event: string, listener: Function): this;
  13.         on(event: string, listener: Function): this;
  14.         once(event: string, listener: Function): this;
  15.         removeListener(event: string, listener: Function): this;
  16.         removeAllListeners(event?: string): this;
  17.         setMaxListeners(n: number): this;
  18.         getMaxListeners(): number;
  19.         listeners(event: string): Function[];
  20.         emit(event: string, ...args: any[]): boolean;
  21.         listenerCount(type: string): number;
  22.     }
  23.  
  24.     interface Event {
  25.         preventDefault: Function;
  26.         sender: EventEmitter;
  27.     }
  28.  
  29.     // https://github.com/electron/electron/blob/master/docs/api/app.md
  30.  
  31.     /**
  32.      * The app module is responsible for controlling the application's lifecycle.
  33.      */
  34.     interface App extends NodeJS.EventEmitter {
  35.         /**
  36.          * Emitted when the application has finished basic startup.
  37.          * On Windows and Linux, the will-finish-launching event
  38.          * is the same as the ready event; on OS X, this event represents
  39.          * the applicationWillFinishLaunching notification of NSApplication.
  40.          * You would usually set up listeners for the open-file and open-url events here,
  41.          * and start the crash reporter and auto updater.
  42.          *
  43.          * In most cases, you should just do everything in the ready event handler.
  44.          */
  45.         on(event: 'will-finish-launching', listener: Function): this;
  46.         /**
  47.          * Emitted when Electron has finished initialization.
  48.          */
  49.         on(event: 'ready', listener: Function): this;
  50.         /**
  51.          * Emitted when all windows have been closed.
  52.          *
  53.          * If you do not subscribe to this event and all windows are closed,
  54.          * the default behavior is to quit the app; however, if you subscribe,
  55.          * you control whether the app quits or not.
  56.          * If the user pressed Cmd + Q, or the developer called app.quit(),
  57.          * Electron will first try to close all the windows and then emit the will-quit event,
  58.          * and in this case the window-all-closed event would not be emitted.
  59.          */
  60.         on(event: 'window-all-closed', listener: Function): this;
  61.         /**
  62.          * Emitted before the application starts closing its windows.
  63.          * Calling event.preventDefault() will prevent the default behaviour, which is terminating the application.
  64.          */
  65.         on(event: 'before-quit', listener: (event: Event) => void): this;
  66.         /**
  67.          * Emitted when all windows have been closed and the application will quit.
  68.          * Calling event.preventDefault() will prevent the default behaviour, which is terminating the application.
  69.          */
  70.         on(event: 'will-quit', listener: (event: Event) => void): this;
  71.         /**
  72.          * Emitted when the application is quitting.
  73.          */
  74.         on(event: 'quit', listener: (event: Event, exitCode: number) => void): this;
  75.         /**
  76.          * Emitted when the user wants to open a file with the application.
  77.          * The open-file event is usually emitted when the application is already open
  78.          * and the OS wants to reuse the application to open the file.
  79.          * open-file is also emitted when a file is dropped onto the dock and the application
  80.          * is not yet running. Make sure to listen for the open-file event very early
  81.          * in your application startup to handle this case (even before the ready event is emitted).
  82.          *
  83.          * You should call event.preventDefault() if you want to handle this event.
  84.          *
  85.          * Note: This is only implemented on OS X.
  86.          */
  87.         on(event: 'open-file', listener: (event: Event, url: string) => void): this;
  88.         /**
  89.          * Emitted when the user wants to open a URL with the application.
  90.          * The URL scheme must be registered to be opened by your application.
  91.          *
  92.          * You should call event.preventDefault() if you want to handle this event.
  93.          *
  94.          * Note: This is only implemented on OS X.
  95.          */
  96.         on(event: 'open-url', listener: (event: Event, url: string) => void): this;
  97.         /**
  98.          * Emitted when the application is activated, which usually happens when clicks on the applications’s dock icon.
  99.          * Note: This is only implemented on OS X.
  100.          */
  101.         on(event: 'activate', listener: Function): this;
  102.         /**
  103.          * Emitted during Handoff when an activity from a different device wants to be resumed.
  104.          * You should call event.preventDefault() if you want to handle this event.
  105.          */
  106.         on(event: 'continue-activity', listener: (event: Event, type: string, userInfo: Object) => void): this;
  107.         /**
  108.          * Emitted when a browserWindow gets blurred.
  109.          */
  110.         on(event: 'browser-window-blur', listener: (event: Event, browserWindow: BrowserWindow) => void): this;
  111.         /**
  112.          * Emitted when a browserWindow gets focused.
  113.          */
  114.         on(event: 'browser-window-focus', listener: (event: Event, browserWindow: BrowserWindow) => void): this;
  115.         /**
  116.          * Emitted when a new browserWindow is created.
  117.          */
  118.         on(event: 'browser-window-created', listener: (event: Event, browserWindow: BrowserWindow) => void): this;
  119.         /**
  120.          * Emitted when failed to verify the certificate for url, to trust the certificate
  121.          * you should prevent the default behavior with event.preventDefault() and call callback(true).
  122.          */
  123.         on(event: 'certificate-error', listener: (event: Event,
  124.             webContents: WebContents,
  125.             url: string,
  126.             error: string,
  127.             certificate: Certificate,
  128.             callback: (trust: boolean) => void
  129.         ) => void): this;
  130.         /**
  131.          * Emitted when a client certificate is requested.
  132.          *
  133.          * The url corresponds to the navigation entry requesting the client certificate
  134.          * and callback needs to be called with an entry filtered from the list.
  135.          * Using event.preventDefault() prevents the application from using the first certificate from the store.
  136.          */
  137.         on(event: 'select-client-certificate', listener: (event: Event,
  138.             webContents: WebContents,
  139.             url: string,
  140.             certificateList: Certificate[],
  141.             callback: (certificate: Certificate) => void
  142.         ) => void): this;
  143.         /**
  144.          * Emitted when webContents wants to do basic auth.
  145.          *
  146.          * The default behavior is to cancel all authentications, to override this
  147.          * you should prevent the default behavior with event.preventDefault()
  148.          * and call callback(username, password) with the credentials.
  149.          */
  150.         on(event: 'login', listener: (event: Event,
  151.             webContents: WebContents,
  152.             request: LoginRequest,
  153.             authInfo: LoginAuthInfo,
  154.             callback: (username: string, password: string) => void
  155.         ) => void): this;
  156.         /**
  157.          * Emitted when the gpu process crashes.
  158.          */
  159.         on(event: 'gpu-process-crashed', listener: Function): this;
  160.         on(event: string, listener: Function): this;
  161.         /**
  162.          * Try to close all windows. The before-quit event will first be emitted.
  163.          * If all windows are successfully closed, the will-quit event will be emitted
  164.          * and by default the application would be terminated.
  165.          *
  166.          * This method guarantees all beforeunload and unload handlers are correctly
  167.          * executed. It is possible that a window cancels the quitting by returning
  168.          * false in beforeunload handler.
  169.          */
  170.         quit(): void;
  171.         /**
  172.          * Exits immediately with exitCode.
  173.          * All windows will be closed immediately without asking user
  174.          * and the before-quit and will-quit events will not be emitted.
  175.          */
  176.         exit(exitCode: number): void;
  177.         /**
  178.          * On Linux, focuses on the first visible window.
  179.          * On OS X, makes the application the active app.
  180.          * On Windows, focuses on the application’s first window.
  181.          */
  182.         focus(): void;
  183.         /**
  184.          * Hides all application windows without minimizing them.
  185.          * Note: This is only implemented on OS X.
  186.          */
  187.         hide(): void;
  188.         /**
  189.          * Shows application windows after they were hidden. Does not automatically focus them.
  190.          * Note: This is only implemented on OS X.
  191.          */
  192.         show(): void;
  193.         /**
  194.          * Returns the current application directory.
  195.          */
  196.         getAppPath(): string;
  197.         /**
  198.          * @returns The path to a special directory or file associated with name.
  199.          * On failure an Error would throw.
  200.          */
  201.         getPath(name: AppPathName): string;
  202.         /**
  203.          * Overrides the path to a special directory or file associated with name.
  204.          * If the path specifies a directory that does not exist, the directory will
  205.          * be created by this method. On failure an Error would throw.
  206.          *
  207.          * You can only override paths of names defined in app.getPath.
  208.          *
  209.          * By default web pages' cookies and caches will be stored under userData
  210.          * directory, if you want to change this location, you have to override the
  211.          * userData path before the ready event of app module gets emitted.
  212.          */
  213.         setPath(name: AppPathName, path: string): void;
  214.         /**
  215.          * @returns The version of loaded application, if no version is found in
  216.          * application's package.json, the version of current bundle or executable.
  217.          */
  218.         getVersion(): string;
  219.         /**
  220.          * @returns The current application's name, the name in package.json would be used.
  221.          * Usually the name field of package.json is a short lowercased name, according to
  222.          * the spec of npm modules. So usually you should also specify a productName field,
  223.          * which is your application's full capitalized name, and it will be preferred over
  224.          * name by Electron.
  225.          */
  226.         getName(): string;
  227.         /**
  228.          * Overrides the current application's name.
  229.          */
  230.         setName(name: string): void;
  231.         /**
  232.           * @returns The current application locale.
  233.           */
  234.         getLocale(): string;
  235.         /**
  236.          * Adds path to recent documents list.
  237.          *
  238.          * This list is managed by the system, on Windows you can visit the list from
  239.          * task bar, and on Mac you can visit it from dock menu.
  240.          *
  241.          * Note: This is only implemented on OS X and Windows.
  242.          */
  243.         addRecentDocument(path: string): void;
  244.         /**
  245.          * Clears the recent documents list.
  246.          *
  247.          * Note: This is only implemented on OS X and Windows.
  248.          */
  249.         clearRecentDocuments(): void;
  250.         /**
  251.          * Sets the current executable as the default handler for a protocol (aka URI scheme).
  252.          * Once registered, all links with your-protocol:// will be openend with the current executable.
  253.          * The whole link, including protocol, will be passed to your application as a parameter.
  254.          *
  255.          * Note: This is only implemented on OS X and Windows.
  256.          *       On OS X, you can only register protocols that have been added to your app's info.plist.
  257.          */
  258.         setAsDefaultProtocolClient(protocol: string): void;
  259.         /**
  260.          * Removes the current executable as the default handler for a protocol (aka URI scheme).
  261.          *
  262.          * Note: This is only implemented on OS X and Windows.
  263.          */
  264.         removeAsDefaultProtocolClient(protocol: string): void;
  265.         /**
  266.          * @returns Whether the current executable is the default handler for a protocol (aka URI scheme).
  267.          *
  268.          * Note: This is only implemented on OS X and Windows.
  269.          */
  270.         isDefaultProtocolClient(protocol: string): boolean;
  271.         /**
  272.          * Adds tasks to the Tasks category of JumpList on Windows.
  273.          *
  274.          * Note: This API is only available on Windows.
  275.          */
  276.         setUserTasks(tasks: Task[]): void;
  277.         /**
  278.          * This method makes your application a Single Instance Application instead of allowing
  279.          * multiple instances of your app to run, this will ensure that only a single instance
  280.          * of your app is running, and other instances signal this instance and exit.
  281.          */
  282.         makeSingleInstance(callback: (args: string[], workingDirectory: string) => void): boolean;
  283.         /**
  284.          * Releases all locks that were created by makeSingleInstance. This will allow
  285.          * multiple instances of the application to once again run side by side.
  286.          */
  287.         releaseSingleInstance(): void;
  288.         /**
  289.          * Creates an NSUserActivity and sets it as the current activity.
  290.          * The activity is eligible for Handoff to another device afterward.
  291.          *
  292.          * @param type Uniquely identifies the activity. Maps to NSUserActivity.activityType.
  293.          * @param userInfo App-specific state to store for use by another device.
  294.          * @param webpageURL The webpage to load in a browser if no suitable app is
  295.          *                   installed on the resuming device. The scheme must be http or https.
  296.          *
  297.          * Note: This API is only available on Mac.
  298.          */
  299.         setUserActivity(type: string, userInfo: Object, webpageURL?: string): void;
  300.         /**
  301.          * @returns The type of the currently running activity.
  302.          *
  303.          * Note: This API is only available on Mac.
  304.          */
  305.         getCurrentActivityType(): string;
  306.         /**
  307.          * Changes the Application User Model ID to id.
  308.          */
  309.         setAppUserModelId(id: string): void;
  310.         /**
  311.          * Imports the certificate in pkcs12 format into the platform certificate store.
  312.          * @param callback Called with the result of import operation, a value of 0 indicates success
  313.          * while any other value indicates failure according to chromium net_error_list.
  314.          *
  315.          * Note: This API is only available on Linux.
  316.          */
  317.         importCertificate(options: ImportCertificateOptions, callback: (result: number) => void): void;
  318.         commandLine: CommandLine;
  319.         /**
  320.          * Note: This API is only available on Mac.
  321.          */
  322.         dock: Dock;
  323.     }
  324.  
  325.     type AppPathName = 'home'|'appData'|'userData'|'temp'|'exe'|'module'|'desktop'|'documents'|'downloads'|'music'|'pictures'|'videos';
  326.  
  327.     interface ImportCertificateOptions {
  328.         /**
  329.          * Path for the pkcs12 file.
  330.          */
  331.         certificate: string;
  332.         /**
  333.          * Passphrase for the certificate.
  334.          */
  335.         password: string;
  336.     }
  337.  
  338.     interface CommandLine {
  339.         /**
  340.          * Append a switch [with optional value] to Chromium's command line.
  341.          *
  342.          * Note: This will not affect process.argv, and is mainly used by developers
  343.          * to control some low-level Chromium behaviors.
  344.          */
  345.         appendSwitch(_switch: string, value?: string|number): void;
  346.         /**
  347.          * Append an argument to Chromium's command line. The argument will quoted properly.
  348.          *
  349.          * Note: This will not affect process.argv.
  350.          */
  351.         appendArgument(value: string): void;
  352.     }
  353.  
  354.     interface Dock {
  355.         /**
  356.          * When critical is passed, the dock icon will bounce until either the
  357.          * application becomes active or the request is canceled.
  358.          *
  359.          * When informational is passed, the dock icon will bounce for one second.
  360.          * However, the request remains active until either the application becomes
  361.          * active or the request is canceled.
  362.          *
  363.          * @param type The default is informational.
  364.          * @returns An ID representing the request.
  365.          */
  366.         bounce(type?: 'critical' | 'informational'): number;
  367.         /**
  368.          * Cancel the bounce of id.
  369.          *
  370.          * Note: This API is only available on Mac.
  371.          */
  372.         cancelBounce(id: number): void;
  373.         /**
  374.          * Bounces the Downloads stack if the filePath is inside the Downloads folder.
  375.          *
  376.          * Note: This API is only available on Mac.
  377.          */
  378.         downloadFinished(filePath: string): void;
  379.         /**
  380.          * Sets the string to be displayed in the dock’s badging area.
  381.          *
  382.          * Note: This API is only available on Mac.
  383.          */
  384.         setBadge(text: string): void;
  385.         /**
  386.          * Returns the badge string of the dock.
  387.          *
  388.          * Note: This API is only available on Mac.
  389.          */
  390.         getBadge(): string;
  391.         /**
  392.          * Hides the dock icon.
  393.          *
  394.          * Note: This API is only available on Mac.
  395.          */
  396.         hide(): void;
  397.         /**
  398.          * Shows the dock icon.
  399.          *
  400.          * Note: This API is only available on Mac.
  401.          */
  402.         show(): void;
  403.         /**
  404.          * Sets the application dock menu.
  405.          *
  406.          * Note: This API is only available on Mac.
  407.          */
  408.         setMenu(menu: Menu): void;
  409.         /**
  410.          * Sets the image associated with this dock icon.
  411.          *
  412.          * Note: This API is only available on Mac.
  413.          */
  414.         setIcon(icon: NativeImage | string): void;
  415.     }
  416.  
  417.     interface Task {
  418.         /**
  419.          * Path of the program to execute, usually you should specify process.execPath
  420.          * which opens current program.
  421.          */
  422.         program: string;
  423.         /**
  424.          * The arguments of command line when program is executed.
  425.          */
  426.         arguments: string;
  427.         /**
  428.          * The string to be displayed in a JumpList.
  429.          */
  430.         title: string;
  431.         /**
  432.          * Description of this task.
  433.          */
  434.         description?: string;
  435.         /**
  436.          * The absolute path to an icon to be displayed in a JumpList, it can be
  437.          * arbitrary resource file that contains an icon, usually you can specify
  438.          * process.execPath to show the icon of the program.
  439.          */
  440.         iconPath: string;
  441.         /**
  442.          * The icon index in the icon file. If an icon file consists of two or more
  443.          * icons, set this value to identify the icon. If an icon file consists of
  444.          * one icon, this value is 0.
  445.          */
  446.         iconIndex?: number;
  447.     }
  448.  
  449.     // https://github.com/electron/electron/blob/master/docs/api/auto-updater.md
  450.  
  451.     /**
  452.      * This module provides an interface for the Squirrel auto-updater framework.
  453.      */
  454.     interface AutoUpdater extends NodeJS.EventEmitter {
  455.         /**
  456.          * Emitted when there is an error while updating.
  457.          */
  458.         on(event: 'error', listener: (error: Error) => void): this;
  459.         /**
  460.          * Emitted when checking if an update has started.
  461.          */
  462.         on(event: 'checking-for-update', listener: Function): this;
  463.         /**
  464.          * Emitted when there is an available update. The update is downloaded automatically.
  465.          */
  466.         on(event: 'update-available', listener: Function): this;
  467.         /**
  468.          * Emitted when there is no available update.
  469.          */
  470.         on(event: 'update-not-available', listener: Function): this;
  471.         /**
  472.          * Emitted when an update has been downloaded.
  473.          * Note: On Windows only releaseName is available.
  474.          */
  475.         on(event: 'update-downloaded', listener: (event: Event, releaseNotes: string, releaseName: string, releaseDate: Date, updateURL: string) => void): this;
  476.         on(event: string, listener: Function): this;
  477.         /**
  478.          * Set the url and initialize the auto updater.
  479.          * The url cannot be changed once it is set.
  480.          */
  481.         setFeedURL(url: string): void;
  482.         /**
  483.          * Ask the server whether there is an update, you have to call setFeedURL
  484.          * before using this API
  485.          */
  486.         checkForUpdates(): void;
  487.         /**
  488.          * Restarts the app and installs the update after it has been downloaded.
  489.          * It should only be called after update-downloaded has been emitted.
  490.          */
  491.         quitAndInstall(): void;
  492.     }
  493.  
  494.     // https://github.com/electron/electron/blob/master/docs/api/browser-window.md
  495.  
  496.     /**
  497.      * The BrowserWindow class gives you ability to create a browser window.
  498.      * You can also create a window without chrome by using Frameless Window API.
  499.      */
  500.     class BrowserWindow extends EventEmitter {
  501.         /**
  502.          * Emitted when the document changed its title,
  503.          * calling event.preventDefault() would prevent the native window’s title to change.
  504.          */
  505.         on(event: 'page-title-updated', listener: (event: Event) => void): this;
  506.         /**
  507.          * Emitted when the window is going to be closed. It’s emitted before the beforeunload
  508.          * and unload event of the DOM. Calling event.preventDefault() will cancel the close.
  509.          */
  510.         on(event: 'close', listener: (event: Event) => void): this;
  511.         /**
  512.          * Emitted when the window is closed. After you have received this event
  513.          * you should remove the reference to the window and avoid using it anymore.
  514.          */
  515.         on(event: 'closed', listener: Function): this;
  516.         /**
  517.          * Emitted when the web page becomes unresponsive.
  518.          */
  519.         on(event: 'unresponsive', listener: Function): this;
  520.         /**
  521.          * Emitted when the unresponsive web page becomes responsive again.
  522.          */
  523.         on(event: 'responsive', listener: Function): this;
  524.         /**
  525.          * Emitted when the window loses focus.
  526.          */
  527.         on(event: 'blur', listener: Function): this;
  528.         /**
  529.          * Emitted when the window gains focus.
  530.          */
  531.         on(event: 'focus', listener: Function): this;
  532.         /**
  533.          * Emitted when the window is shown.
  534.          */
  535.         on(event: 'show', listener: Function): this;
  536.         /**
  537.          * Emitted when the window is hidden.
  538.          */
  539.         on(event: 'hide', listener: Function): this;
  540.         /**
  541.          * Emitted when window is maximized.
  542.          */
  543.         on(event: 'maximize', listener: Function): this;
  544.         /**
  545.          * Emitted when the window exits from maximized state.
  546.          */
  547.         on(event: 'unmaximize', listener: Function): this;
  548.         /**
  549.          * Emitted when the window is minimized.
  550.          */
  551.         on(event: 'minimize', listener: Function): this;
  552.         /**
  553.          * Emitted when the window is restored from minimized state.
  554.          */
  555.         on(event: 'restore', listener: Function): this;
  556.         /**
  557.          * Emitted when the window is getting resized.
  558.          */
  559.         on(event: 'resize', listener: Function): this;
  560.         /**
  561.          * Emitted when the window is getting moved to a new position.
  562.          */
  563.         on(event: 'move', listener: Function): this;
  564.         /**
  565.          * Emitted when the window enters full screen state.
  566.          */
  567.         on(event: 'enter-full-screen', listener: Function): this;
  568.         /**
  569.          * Emitted when the window leaves full screen state.
  570.          */
  571.         on(event: 'leave-full-screen', listener: Function): this;
  572.         /**
  573.          * Emitted when the window enters full screen state triggered by HTML API.
  574.          */
  575.         on(event: 'enter-html-full-screen', listener: Function): this;
  576.         /**
  577.          * Emitted when the window leaves full screen state triggered by HTML API.
  578.          */
  579.         on(event: 'leave-html-full-screen', listener: Function): this;
  580.         /**
  581.          * Emitted when an App Command is invoked. These are typically related
  582.          * to keyboard media keys or browser commands, as well as the "Back" /
  583.          * "Forward" buttons built into some mice on Windows.
  584.          * Note: This is only implemented on Windows.
  585.          */
  586.         on(event: 'app-command', listener: (event: Event, command: string) => void): this;
  587.         /**
  588.          * Emitted when scroll wheel event phase has begun.
  589.          * Note: This is only implemented on OS X.
  590.          */
  591.         on(event: 'scroll-touch-begin', listener: Function): this;
  592.         /**
  593.          * Emitted when scroll wheel event phase has ended.
  594.          * Note: This is only implemented on OS X.
  595.          */
  596.         on(event: 'scroll-touch-end', listener: Function): this;
  597.         /**
  598.          * Emitted on 3-finger swipe.
  599.          * Note: This is only implemented on OS X.
  600.          */
  601.         on(event: 'swipe', listener: (event: Event, direction: SwipeDirection) => void): this;
  602.         on(event: string, listener: Function): this;
  603.         constructor(options?: BrowserWindowOptions);
  604.         /**
  605.          * @returns All opened browser windows.
  606.          */
  607.         static getAllWindows(): BrowserWindow[];
  608.         /**
  609.          * @returns The window that is focused in this application.
  610.          */
  611.         static getFocusedWindow(): BrowserWindow;
  612.         /**
  613.          * Find a window according to the webContents it owns.
  614.          */
  615.         static fromWebContents(webContents: WebContents): BrowserWindow;
  616.         /**
  617.          * Find a window according to its ID.
  618.          */
  619.         static fromId(id: number): BrowserWindow;
  620.         /**
  621.          * Adds devtools extension located at path. The extension will be remembered
  622.          * so you only need to call this API once, this API is not for programming use.
  623.          * @returns The extension's name.
  624.          */
  625.         static addDevToolsExtension(path: string): string;
  626.         /**
  627.          * Remove a devtools extension.
  628.          * @param name The name of the devtools extension to remove.
  629.          */
  630.         static removeDevToolsExtension(name: string): void;
  631.         /**
  632.          * The WebContents object this window owns, all web page related events and
  633.          * operations would be done via it.
  634.          * Note: Users should never store this object because it may become null when
  635.          * the renderer process (web page) has crashed.
  636.          */
  637.         webContents: WebContents;
  638.         /**
  639.          * Get the unique ID of this window.
  640.          */
  641.         id: number;
  642.         /**
  643.          * Force closing the window, the unload and beforeunload event won't be emitted
  644.          * for the web page, and close event would also not be emitted for this window,
  645.          * but it would guarantee the closed event to be emitted.
  646.          * You should only use this method when the renderer process (web page) has crashed.
  647.          */
  648.         destroy(): void;
  649.         /**
  650.          * Try to close the window, this has the same effect with user manually clicking
  651.          * the close button of the window. The web page may cancel the close though,
  652.          * see the close event.
  653.          */
  654.         close(): void;
  655.         /**
  656.          * Focus on the window.
  657.          */
  658.         focus(): void;
  659.         /**
  660.          * Remove focus on the window.
  661.          */
  662.         blur(): void;
  663.         /**
  664.          * @returns Whether the window is focused.
  665.          */
  666.         isFocused(): boolean;
  667.         /**
  668.          * Shows and gives focus to the window.
  669.          */
  670.         show(): void;
  671.         /**
  672.          * Shows the window but doesn't focus on it.
  673.          */
  674.         showInactive(): void;
  675.         /**
  676.          * Hides the window.
  677.          */
  678.         hide(): void;
  679.         /**
  680.          * @returns Whether the window is visible to the user.
  681.          */
  682.         isVisible(): boolean;
  683.         /**
  684.          * Maximizes the window.
  685.          */
  686.         maximize(): void;
  687.         /**
  688.          * Unmaximizes the window.
  689.          */
  690.         unmaximize(): void;
  691.         /**
  692.          * @returns Whether the window is maximized.
  693.          */
  694.         isMaximized(): boolean;
  695.         /**
  696.          * Minimizes the window. On some platforms the minimized window will be
  697.          * shown in the Dock.
  698.          */
  699.         minimize(): void;
  700.         /**
  701.          * Restores the window from minimized state to its previous state.
  702.          */
  703.         restore(): void;
  704.         /**
  705.          * @returns Whether the window is minimized.
  706.          */
  707.         isMinimized(): boolean;
  708.         /**
  709.          * Sets whether the window should be in fullscreen mode.
  710.          */
  711.         setFullScreen(flag: boolean): void;
  712.         /**
  713.          * @returns Whether the window is in fullscreen mode.
  714.          */
  715.         isFullScreen(): boolean;
  716.         /**
  717.          * This will have a window maintain an aspect ratio.
  718.          * The extra size allows a developer to have space, specified in pixels,
  719.          * not included within the aspect ratio calculations.
  720.          * This API already takes into account the difference between a window’s size and its content size.
  721.          *
  722.          * Note: This API is available only on OS X.
  723.          */
  724.         setAspectRatio(aspectRatio: number, extraSize?: Dimension): void;
  725.         /**
  726.          * Resizes and moves the window to width, height, x, y.
  727.          */
  728.         setBounds(options: Rectangle, animate?: boolean): void;
  729.         /**
  730.          * @returns The window's width, height, x and y values.
  731.          */
  732.         getBounds(): Rectangle;
  733.         /**
  734.          * Resizes the window to width and height.
  735.          */
  736.         setSize(width: number, height: number, animate?: boolean): void;
  737.         /**
  738.          * @returns The window's width and height.
  739.          */
  740.         getSize(): number[];
  741.         /**
  742.          * Resizes the window's client area (e.g. the web page) to width and height.
  743.          */
  744.         setContentSize(width: number, height: number, animate?: boolean): void;
  745.         /**
  746.          * @returns The window's client area's width and height.
  747.          */
  748.         getContentSize(): number[];
  749.         /**
  750.          * Sets the minimum size of window to width and height.
  751.          */
  752.         setMinimumSize(width: number, height: number): void;
  753.         /**
  754.          * @returns The window's minimum width and height.
  755.          */
  756.         getMinimumSize(): number[];
  757.         /**
  758.          * Sets the maximum size of window to width and height.
  759.          */
  760.         setMaximumSize(width: number, height: number): void;
  761.         /**
  762.          * @returns The window's maximum width and height.
  763.          */
  764.         getMaximumSize(): number[];
  765.         /**
  766.          * Sets whether the window can be manually resized by user.
  767.          */
  768.         setResizable(resizable: boolean): void;
  769.         /**
  770.          * @returns Whether the window can be manually resized by user.
  771.          */
  772.         isResizable(): boolean;
  773.         /**
  774.          * Sets whether the window can be moved by user. On Linux does nothing.
  775.          * Note: This API is available only on OS X and Windows.
  776.          */
  777.         setMovable(movable: boolean): void;
  778.         /**
  779.          * Note: This API is available only on OS X and Windows.
  780.          * @returns Whether the window can be moved by user. On Linux always returns true.
  781.          */
  782.         isMovable(): boolean;
  783.         /**
  784.          * Sets whether the window can be manually minimized by user. On Linux does nothing.
  785.          * Note: This API is available only on OS X and Windows.
  786.          */
  787.         setMinimizable(minimizable: boolean): void;
  788.         /**
  789.          * Note: This API is available only on OS X and Windows.
  790.          * @returns Whether the window can be manually minimized by user. On Linux always returns true.
  791.          */
  792.         isMinimizable(): boolean;
  793.         /**
  794.          * Sets whether the window can be manually maximized by user. On Linux does nothing.
  795.          * Note: This API is available only on OS X and Windows.
  796.          */
  797.         setMaximizable(maximizable: boolean): void;
  798.         /**
  799.          * Note: This API is available only on OS X and Windows.
  800.          * @returns Whether the window can be manually maximized by user. On Linux always returns true.
  801.          */
  802.         isMaximizable(): boolean;
  803.         /**
  804.          * Sets whether the maximize/zoom window button toggles fullscreen mode or maximizes the window.
  805.          */
  806.         setFullScreenable(fullscreenable: boolean): void;
  807.         /**
  808.          * @returns Whether the maximize/zoom window button toggles fullscreen mode or maximizes the window.
  809.          */
  810.         isFullScreenable(): boolean;
  811.         /**
  812.          * Sets whether the window can be manually closed by user. On Linux does nothing.
  813.          * Note: This API is available only on OS X and Windows.
  814.          */
  815.         setClosable(closable: boolean): void;
  816.         /**
  817.          * Note: This API is available only on OS X and Windows.
  818.          * @returns Whether the window can be manually closed by user. On Linux always returns true.
  819.          */
  820.         isClosable(): boolean;
  821.         /**
  822.          * Sets whether the window should show always on top of other windows. After
  823.          * setting this, the window is still a normal window, not a toolbox window
  824.          * which can not be focused on.
  825.          */
  826.         setAlwaysOnTop(flag: boolean): void;
  827.         /**
  828.          * @returns Whether the window is always on top of other windows.
  829.          */
  830.         isAlwaysOnTop(): boolean;
  831.         /**
  832.          * Moves window to the center of the screen.
  833.          */
  834.         center(): void;
  835.         /**
  836.          * Moves window to x and y.
  837.          */
  838.         setPosition(x: number, y: number, animate?: boolean): void;
  839.         /**
  840.          * @returns The window's current position.
  841.          */
  842.         getPosition(): number[];
  843.         /**
  844.          * Changes the title of native window to title.
  845.          */
  846.         setTitle(title: string): void;
  847.         /**
  848.          * Note: The title of web page can be different from the title of the native window.
  849.          * @returns The title of the native window.
  850.          */
  851.         getTitle(): string;
  852.         /**
  853.          * Changes the attachment point for sheets on Mac OS X.
  854.          * Note: This API is available only on OS X.
  855.          */
  856.         setSheetOffset(offsetY: number, offsetX?: number): void;
  857.         /**
  858.          * Starts or stops flashing the window to attract user's attention.
  859.          */
  860.         flashFrame(flag: boolean): void;
  861.         /**
  862.          * Makes the window do not show in Taskbar.
  863.          */
  864.         setSkipTaskbar(skip: boolean): void;
  865.         /**
  866.          * Enters or leaves the kiosk mode.
  867.          */
  868.         setKiosk(flag: boolean): void;
  869.         /**
  870.          * @returns Whether the window is in kiosk mode.
  871.          */
  872.         isKiosk(): boolean;
  873.         /**
  874.          * The native type of the handle is HWND on Windows, NSView* on OS X,
  875.          * and Window (unsigned long) on Linux.
  876.          * @returns The platform-specific handle of the window as Buffer.
  877.          */
  878.         getNativeWindowHandle(): Buffer;
  879.         /**
  880.          * Hooks a windows message. The callback is called when the message is received in the WndProc.
  881.          * Note: This API is available only on Windows.
  882.          */
  883.         hookWindowMessage(message: number, callback: Function): void;
  884.         /**
  885.          * @returns Whether the message is hooked.
  886.          */
  887.         isWindowMessageHooked(message: number): boolean;
  888.         /**
  889.          * Unhook the window message.
  890.          */
  891.         unhookWindowMessage(message: number): void;
  892.         /**
  893.          * Unhooks all of the window messages.
  894.          */
  895.         unhookAllWindowMessages(): void;
  896.         /**
  897.          * Sets the pathname of the file the window represents, and the icon of the
  898.          * file will show in window's title bar.
  899.          * Note: This API is available only on OS X.
  900.          */
  901.         setRepresentedFilename(filename: string): void;
  902.         /**
  903.          * Note: This API is available only on OS X.
  904.          * @returns The pathname of the file the window represents.
  905.          */
  906.         getRepresentedFilename(): string;
  907.         /**
  908.          * Specifies whether the window’s document has been edited, and the icon in
  909.          * title bar will become grey when set to true.
  910.          * Note: This API is available only on OS X.
  911.          */
  912.         setDocumentEdited(edited: boolean): void;
  913.         /**
  914.          * Note: This API is available only on OS X.
  915.          * @returns Whether the window's document has been edited.
  916.          */
  917.         isDocumentEdited(): boolean;
  918.         focusOnWebView(): void;
  919.         blurWebView(): void;
  920.         /**
  921.          * Captures the snapshot of page within rect, upon completion the callback
  922.          * will be called. Omitting the rect would capture the whole visible page.
  923.          * Note: Be sure to read documents on remote buffer in remote if you are going
  924.          * to use this API in renderer process.
  925.          * @param callback Supplies the image that stores data of the snapshot.
  926.          */
  927.         capturePage(rect: Rectangle, callback: (image: NativeImage) => void): void;
  928.         capturePage(callback: (image: NativeImage) => void): void;
  929.         /**
  930.          * Same as webContents.loadURL(url).
  931.          */
  932.         loadURL(url: string, options?: LoadURLOptions): void;
  933.         /**
  934.          * Same as webContents.reload.
  935.          */
  936.         reload(): void;
  937.         /**
  938.          * Sets the menu as the window top menu.
  939.          * Note: This API is not available on OS X.
  940.          */
  941.         setMenu(menu: Menu): void;
  942.         /**
  943.          * Sets the progress value in the progress bar.
  944.          * On Linux platform, only supports Unity desktop environment, you need to
  945.          * specify the *.desktop file name to desktopName field in package.json.
  946.          * By default, it will assume app.getName().desktop.
  947.          * @param progress Valid range is [0, 1.0]. If < 0, the progress bar is removed.
  948.          * If greater than 0, it becomes indeterminate.
  949.          */
  950.         setProgressBar(progress: number): void;
  951.         /**
  952.          * Sets a 16px overlay onto the current Taskbar icon, usually used to convey
  953.          * some sort of application status or to passively notify the user.
  954.          * Note: This API is only available on Windows 7 or above.
  955.          * @param overlay The icon to display on the bottom right corner of the Taskbar
  956.          * icon. If this parameter is null, the overlay is cleared
  957.          * @param description Provided to Accessibility screen readers.
  958.          */
  959.         setOverlayIcon(overlay: NativeImage, description: string): void;
  960.         /**
  961.          * Sets whether the window should have a shadow. On Windows and Linux does nothing.
  962.          * Note: This API is available only on OS X.
  963.          */
  964.         setHasShadow(hasShadow: boolean): void;
  965.         /**
  966.          * Note: This API is available only on OS X.
  967.          * @returns whether the window has a shadow. On Windows and Linux always returns true.
  968.          */
  969.         hasShadow(): boolean;
  970.         /**
  971.          * Add a thumbnail toolbar with a specified set of buttons to the thumbnail image
  972.          * of a window in a taskbar button layout.
  973.          * @returns Whether the thumbnail has been added successfully.
  974.          */
  975.         setThumbarButtons(buttons: ThumbarButton[]): boolean;
  976.         /**
  977.          * Shows pop-up dictionary that searches the selected word on the page.
  978.          * Note: This API is available only on OS X.
  979.          */
  980.         showDefinitionForSelection(): void;
  981.         /**
  982.          * Changes window icon.
  983.          * Note: This API is not available on OS X.
  984.          */
  985.         setIcon(icon: NativeImage): void;
  986.         /**
  987.          * Sets whether the window menu bar should hide itself automatically. Once set
  988.          * the menu bar will only show when users press the single Alt key.
  989.          * If the menu bar is already visible, calling setAutoHideMenuBar(true) won't
  990.          * hide it immediately.
  991.          */
  992.         setAutoHideMenuBar(hide: boolean): void;
  993.         /**
  994.          * @returns Whether menu bar automatically hides itself.
  995.          */
  996.         isMenuBarAutoHide(): boolean;
  997.         /**
  998.          * Sets whether the menu bar should be visible. If the menu bar is auto-hide,
  999.          * users can still bring up the menu bar by pressing the single Alt key.
  1000.          */
  1001.         setMenuBarVisibility(visibile: boolean): void;
  1002.         /**
  1003.          * @returns Whether the menu bar is visible.
  1004.          */
  1005.         isMenuBarVisible(): boolean;
  1006.         /**
  1007.          * Sets whether the window should be visible on all workspaces.
  1008.          * Note: This API does nothing on Windows.
  1009.          */
  1010.         setVisibleOnAllWorkspaces(visible: boolean): void;
  1011.         /**
  1012.          * Note: This API always returns false on Windows.
  1013.          * @returns Whether the window is visible on all workspaces.
  1014.          */
  1015.         isVisibleOnAllWorkspaces(): boolean;
  1016.         /**
  1017.          * Ignore all moused events that happened in the window.
  1018.          * Note: This API is available only on OS X.
  1019.          */
  1020.         setIgnoreMouseEvents(ignore: boolean): void;
  1021.     }
  1022.  
  1023.     type SwipeDirection = 'up' | 'right' | 'down' | 'left';
  1024.  
  1025.     type ThumbarButtonFlags = 'enabled' | 'disabled' | 'dismissonclick' | 'nobackground' | 'hidden' | 'noninteractive';
  1026.  
  1027.     interface ThumbarButton {
  1028.         icon: NativeImage | string;
  1029.         click: Function;
  1030.         tooltip?: string;
  1031.         flags?: ThumbarButtonFlags[];
  1032.     }
  1033.  
  1034.     interface WebPreferences {
  1035.         /**
  1036.          * Whether node integration is enabled.
  1037.          * Default: true.
  1038.          */
  1039.         nodeIntegration?: boolean;
  1040.         /**
  1041.          * Specifies a script that will be loaded before other scripts run in the page.
  1042.          * This script will always have access to node APIs no matter whether node integration is turned on or off.
  1043.          * The value should be the absolute file path to the script.
  1044.          * When node integration is turned off, the preload script can reintroduce
  1045.          * Node global symbols back to the global scope.
  1046.          */
  1047.         preload?: string;
  1048.         /**
  1049.          * Sets the session used by the page. Instead of passing the Session object directly,
  1050.          * you can also choose to use the partition option instead, which accepts a partition string.
  1051.          * When both session and partition are provided, session would be preferred.
  1052.          * Default: the default session.
  1053.          */
  1054.         session?: Session;
  1055.         /**
  1056.          * Sets the session used by the page according to the session’s partition string.
  1057.          * If partition starts with persist:, the page will use a persistent session available
  1058.          * to all pages in the app with the same partition. if there is no persist: prefix,
  1059.          * the page will use an in-memory session. By assigning the same partition,
  1060.          * multiple pages can share the same session.
  1061.          * Default: the default session.
  1062.          */
  1063.         partition?: string;
  1064.         /**
  1065.          * The default zoom factor of the page, 3.0 represents 300%.
  1066.          * Default: 1.0.
  1067.          */
  1068.         zoomFactor?: number;
  1069.         /**
  1070.          * Enables JavaScript support.
  1071.          * Default: true.
  1072.          */
  1073.         javascript?: boolean;
  1074.         /**
  1075.          * When setting false, it will disable the same-origin policy (Usually using testing
  1076.          * websites by people), and set allowDisplayingInsecureContent and allowRunningInsecureContent
  1077.          * to true if these two options are not set by user.
  1078.          * Default: true.
  1079.          */
  1080.         webSecurity?: boolean;
  1081.         /**
  1082.          * Allow an https page to display content like images from http URLs.
  1083.          * Default: false.
  1084.          */
  1085.         allowDisplayingInsecureContent?: boolean;
  1086.         /**
  1087.          * Allow a https page to run JavaScript, CSS or plugins from http URLs.
  1088.          * Default: false.
  1089.          */
  1090.         allowRunningInsecureContent?: boolean;
  1091.         /**
  1092.          * Enables image support.
  1093.          * Default: true.
  1094.          */
  1095.         images?: boolean;
  1096.         /**
  1097.          * Make TextArea elements resizable.
  1098.          * Default: true.
  1099.          */
  1100.         textAreasAreResizable?: boolean;
  1101.         /**
  1102.          * Enables WebGL support.
  1103.          * Default: true.
  1104.          */
  1105.         webgl?: boolean;
  1106.         /**
  1107.          * Enables WebAudio support.
  1108.          * Default: true.
  1109.          */
  1110.         webaudio?: boolean;
  1111.         /**
  1112.          * Whether plugins should be enabled.
  1113.          * Default: false.
  1114.          */
  1115.         plugins?: boolean;
  1116.         /**
  1117.          * Enables Chromium’s experimental features.
  1118.          * Default: false.
  1119.          */
  1120.         experimentalFeatures?: boolean;
  1121.         /**
  1122.          * Enables Chromium’s experimental canvas features.
  1123.          * Default: false.
  1124.          */
  1125.         experimentalCanvasFeatures?: boolean;
  1126.         /**
  1127.          * Enables DirectWrite font rendering system on Windows.
  1128.          * Default: true.
  1129.          */
  1130.         directWrite?: boolean;
  1131.         /**
  1132.          * Enables scroll bounce (rubber banding) effect on OS X.
  1133.          * Default: false.
  1134.          */
  1135.         scrollBounce?: boolean;
  1136.         /**
  1137.          * A list of feature strings separated by ",".
  1138.          */
  1139.         blinkFeatures?: string;
  1140.         /**
  1141.          * Sets the default font for the font-family.
  1142.          */
  1143.         defaultFontFamily?: {
  1144.             /**
  1145.              * Default: Times New Roman.
  1146.              */
  1147.             standard?: string;
  1148.             /**
  1149.              * Default: Times New Roman.
  1150.              */
  1151.             serif?: string;
  1152.             /**
  1153.              * Default: Arial.
  1154.              */
  1155.             sansSerif?: string;
  1156.             /**
  1157.              * Default: Courier New.
  1158.              */
  1159.             monospace?: string;
  1160.         };
  1161.         /**
  1162.          * Default: 16.
  1163.          */
  1164.         defaultFontSize?: number;
  1165.         /**
  1166.          * Default: 13.
  1167.          */
  1168.         defaultMonospaceFontSize?: number;
  1169.         /**
  1170.          * Default: 0.
  1171.          */
  1172.         minimumFontSize?: number;
  1173.         /**
  1174.          * Default: ISO-8859-1.
  1175.          */
  1176.         defaultEncoding?: string;
  1177.         /**
  1178.          * Whether to throttle animations and timers when the page becomes background.
  1179.          * Default: true
  1180.          */
  1181.         backgroundThrottling?: boolean;
  1182.     }
  1183.  
  1184.     interface BrowserWindowOptions extends Rectangle {
  1185.         /**
  1186.          * Window’s width in pixels.
  1187.          * Default: 800.
  1188.          */
  1189.         width?: number;
  1190.         /**
  1191.          * Window’s height in pixels.
  1192.          * Default: 600.
  1193.          */
  1194.         height?: number;
  1195.         /**
  1196.          * Window’s left offset from screen.
  1197.          * Default: center the window.
  1198.          */
  1199.         x?: number;
  1200.         /**
  1201.          * Window’s top offset from screen.
  1202.          * Default: center the window.
  1203.          */
  1204.         y?: number;
  1205.         /**
  1206.          * The width and height would be used as web page’s size, which means
  1207.          * the actual window’s size will include window frame’s size and be slightly larger.
  1208.          * Default: false.
  1209.          */
  1210.         useContentSize?: boolean;
  1211.         /**
  1212.          * Show window in the center of the screen.
  1213.          * Default: true
  1214.          */
  1215.         center?: boolean;
  1216.         /**
  1217.          * Window’s minimum width.
  1218.          * Default: 0.
  1219.          */
  1220.         minWidth?: number;
  1221.         /**
  1222.          * Window’s minimum height.
  1223.          * Default: 0.
  1224.          */
  1225.         minHeight?: number;
  1226.         /**
  1227.          * Window’s maximum width.
  1228.          * Default: no limit.
  1229.          */
  1230.         maxWidth?: number;
  1231.         /**
  1232.          * Window’s maximum height.
  1233.          * Default: no limit.
  1234.          */
  1235.         maxHeight?: number;
  1236.         /**
  1237.          * Whether window is resizable.
  1238.          * Default: true.
  1239.          */
  1240.         resizable?: boolean;
  1241.         /**
  1242.          * Whether window is movable.
  1243.          * Note: This is not implemented on Linux.
  1244.          * Default: true.
  1245.          */
  1246.         movable?: boolean;
  1247.         /**
  1248.          * Whether window is minimizable.
  1249.          * Note: This is not implemented on Linux.
  1250.          * Default: true.
  1251.          */
  1252.         minimizable?: boolean;
  1253.         /**
  1254.          * Whether window is maximizable.
  1255.          * Note: This is not implemented on Linux.
  1256.          * Default: true.
  1257.          */
  1258.         maximizable?: boolean;
  1259.         /**
  1260.          * Whether window is closable.
  1261.          * Note: This is not implemented on Linux.
  1262.          * Default: true.
  1263.          */
  1264.         closable?: boolean;
  1265.         /**
  1266.          * Whether the window should always stay on top of other windows.
  1267.          * Default: false.
  1268.          */
  1269.         alwaysOnTop?: boolean;
  1270.         /**
  1271.          * Whether the window should show in fullscreen.
  1272.          * When explicitly set to false the fullscreen button will be hidden or disabled on OS X.
  1273.          * Default: false.
  1274.          */
  1275.         fullscreen?: boolean;
  1276.         /**
  1277.          * Whether the window can be put into fullscreen mode.
  1278.          * On OS X, also whether the maximize/zoom button should toggle full screen mode or maximize window.
  1279.          * Default: true.
  1280.          */
  1281.         fullscreenable?: boolean;
  1282.         /**
  1283.          * Whether to show the window in taskbar.
  1284.          * Default: false.
  1285.          */
  1286.         skipTaskbar?: boolean;
  1287.         /**
  1288.          * The kiosk mode.
  1289.          * Default: false.
  1290.          */
  1291.         kiosk?: boolean;
  1292.         /**
  1293.          * Default window title.
  1294.          * Default: "Electron".
  1295.          */
  1296.         title?: string;
  1297.         /**
  1298.          * The window icon, when omitted on Windows the executable’s icon would be used as window icon.
  1299.          */
  1300.         icon?: NativeImage|string;
  1301.         /**
  1302.          * Whether window should be shown when created.
  1303.          * Default: true.
  1304.          */
  1305.         show?: boolean;
  1306.         /**
  1307.          * Specify false to create a Frameless Window.
  1308.          * Default: true.
  1309.          */
  1310.         frame?: boolean;
  1311.         /**
  1312.          * Whether the web view accepts a single mouse-down event that simultaneously activates the window.
  1313.          * Default: false.
  1314.          */
  1315.         acceptFirstMouse?: boolean;
  1316.         /**
  1317.          * Whether to hide cursor when typing.
  1318.          * Default: false.
  1319.          */
  1320.         disableAutoHideCursor?: boolean;
  1321.         /**
  1322.          * Auto hide the menu bar unless the Alt key is pressed.
  1323.          * Default: true.
  1324.          */
  1325.         autoHideMenuBar?: boolean;
  1326.         /**
  1327.          * Enable the window to be resized larger than screen.
  1328.          * Default: false.
  1329.          */
  1330.         enableLargerThanScreen?: boolean;
  1331.         /**
  1332.          * Window’s background color as Hexadecimal value, like #66CD00 or #FFF or #80FFFFFF (alpha is supported).
  1333.          * Default: #FFF (white).
  1334.          */
  1335.         backgroundColor?: string;
  1336.         /**
  1337.          * Whether window should have a shadow.
  1338.          * Note: This is only implemented on OS X.
  1339.          * Default: true.
  1340.          */
  1341.         hasShadow?: boolean;
  1342.         /**
  1343.          * Forces using dark theme for the window.
  1344.          * Note: Only works on some GTK+3 desktop environments.
  1345.          * Default: false.
  1346.          */
  1347.         darkTheme?: boolean;
  1348.         /**
  1349.          * Makes the window transparent.
  1350.          * Default: false.
  1351.          */
  1352.         transparent?: boolean;
  1353.         /**
  1354.          * The type of window, default is normal window.
  1355.          */
  1356.         type?: BrowserWindowType;
  1357.         /**
  1358.          * The style of window title bar.
  1359.          */
  1360.         titleBarStyle?: 'default' | 'hidden' | 'hidden-inset';
  1361.         /**
  1362.          * Settings of web page’s features.
  1363.          */
  1364.         webPreferences?: WebPreferences;
  1365.     }
  1366.  
  1367.     type BrowserWindowType = BrowserWindowTypeLinux | BrowserWindowTypeMac;
  1368.     type BrowserWindowTypeLinux = 'desktop' | 'dock' | 'toolbar' | 'splash' | 'notification';
  1369.     type BrowserWindowTypeMac = 'desktop' | 'textured';
  1370.  
  1371.     interface Rectangle {
  1372.         x?: number;
  1373.         y?: number;
  1374.         width?: number;
  1375.         height?: number;
  1376.     }
  1377.  
  1378.     // https://github.com/electron/electron/blob/master/docs/api/clipboard.md
  1379.  
  1380.     /**
  1381.      * The clipboard module provides methods to perform copy and paste operations.
  1382.      */
  1383.     interface Clipboard {
  1384.         /**
  1385.          * @returns The contents of the clipboard as plain text.
  1386.          */
  1387.         readText(type?: ClipboardType): string;
  1388.         /**
  1389.          * Writes the text into the clipboard as plain text.
  1390.          */
  1391.         writeText(text: string, type?: ClipboardType): void;
  1392.         /**
  1393.          * @returns The contents of the clipboard as markup.
  1394.          */
  1395.         readHTML(type?: ClipboardType): string;
  1396.         /**
  1397.          * Writes markup to the clipboard.
  1398.          */
  1399.         writeHTML(markup: string, type?: ClipboardType): void;
  1400.         /**
  1401.          * @returns The contents of the clipboard as a NativeImage.
  1402.          */
  1403.         readImage(type?: ClipboardType): NativeImage;
  1404.         /**
  1405.          * Writes the image into the clipboard.
  1406.          */
  1407.         writeImage(image: NativeImage, type?: ClipboardType): void;
  1408.         /**
  1409.          * @returns The contents of the clipboard as RTF.
  1410.          */
  1411.         readRTF(type?: ClipboardType): string;
  1412.         /**
  1413.          * Writes the text into the clipboard in RTF.
  1414.          */
  1415.         writeRTF(text: string, type?: ClipboardType): void;
  1416.         /**
  1417.          * Clears everything in clipboard.
  1418.          */
  1419.         clear(type?: ClipboardType): void;
  1420.         /**
  1421.          * @returns Array available formats for the clipboard type.
  1422.          */
  1423.         availableFormats(type?: ClipboardType): string[];
  1424.         /**
  1425.          * Returns whether the clipboard supports the format of specified data.
  1426.          * Note: This API is experimental and could be removed in future.
  1427.          * @returns Whether the clipboard has data in the specified format.
  1428.          */
  1429.         has(format: string, type?: ClipboardType): boolean;
  1430.         /**
  1431.          * Reads the data in the clipboard of the specified format.
  1432.          * Note: This API is experimental and could be removed in future.
  1433.          */
  1434.         read(format: string, type?: ClipboardType): string | NativeImage;
  1435.         /**
  1436.          * Writes data to the clipboard.
  1437.          */
  1438.         write(data: {
  1439.             text?: string;
  1440.             rtf?: string;
  1441.             html?: string;
  1442.             image?: NativeImage;
  1443.         }, type?: ClipboardType): void;
  1444.     }
  1445.  
  1446.     type ClipboardType = '' | 'selection';
  1447.  
  1448.     // https://github.com/electron/electron/blob/master/docs/api/content-tracing.md
  1449.  
  1450.     /**
  1451.      * The content-tracing module is used to collect tracing data generated by the underlying Chromium content module.
  1452.      * This module does not include a web interface so you need to open chrome://tracing/
  1453.      * in a Chrome browser and load the generated file to view the result.
  1454.      */
  1455.     interface ContentTracing {
  1456.         /**
  1457.          * Get a set of category groups. The category groups can change as new code paths are reached.
  1458.          *
  1459.          * @param callback Called once all child processes have acknowledged the getCategories request.
  1460.          */
  1461.         getCategories(callback: (categoryGroups: string[]) => void): void;
  1462.         /**
  1463.          * Start recording on all processes. Recording begins immediately locally and asynchronously
  1464.          * on child processes as soon as they receive the EnableRecording request.
  1465.          *
  1466.          * @param callback Called once all child processes have acknowledged the startRecording request.
  1467.          */
  1468.         startRecording(options: ContentTracingOptions, callback: Function): void;
  1469.         /**
  1470.          * Stop recording on all processes. Child processes typically are caching trace data and
  1471.          * only rarely flush and send trace data back to the main process. That is because it may
  1472.          * be an expensive operation to send the trace data over IPC, and we would like to avoid
  1473.          * much runtime overhead of tracing. So, to end tracing, we must asynchronously ask all
  1474.          * child processes to flush any pending trace data.
  1475.          *
  1476.          * @param resultFilePath Trace data will be written into this file if it is not empty,
  1477.          * or into a temporary file.
  1478.          * @param callback Called once all child processes have acknowledged the stopRecording request.
  1479.          */
  1480.         stopRecording(resultFilePath: string, callback: (filePath: string) => void): void;
  1481.         /**
  1482.          * Start monitoring on all processes. Monitoring begins immediately locally and asynchronously
  1483.          * on child processes as soon as they receive the startMonitoring request.
  1484.          *
  1485.          * @param callback Called once all child processes have acked to the startMonitoring request.
  1486.          */
  1487.         startMonitoring(options: ContentTracingOptions, callback: Function): void;
  1488.         /**
  1489.          * Stop monitoring on all processes.
  1490.          *
  1491.          * @param callback Called once all child processes have acknowledged the stopMonitoring request.
  1492.          */
  1493.         stopMonitoring(callback: Function): void;
  1494.         /**
  1495.          * Get the current monitoring traced data. Child processes typically are caching trace data
  1496.          * and only rarely flush and send trace data back to the main process. That is because it may
  1497.          * be an expensive operation to send the trace data over IPC, and we would like to avoid much
  1498.          * runtime overhead of tracing. So, to end tracing, we must asynchronously ask all child
  1499.          * processes to flush any pending trace data.
  1500.          *
  1501.          * @param callback Called once all child processes have acknowledged the captureMonitoringSnapshot request.
  1502.          */
  1503.         captureMonitoringSnapshot(resultFilePath: string, callback: (filePath: string) => void): void;
  1504.         /**
  1505.          * Get the maximum usage across processes of trace buffer as a percentage of the full state.
  1506.          *
  1507.          * @param callback Called when the TraceBufferUsage value is determined.
  1508.          */
  1509.         getTraceBufferUsage(callback: Function): void;
  1510.         /**
  1511.          * @param callback Called every time the given event occurs on any process.
  1512.          */
  1513.         setWatchEvent(categoryName: string, eventName: string, callback: Function): void;
  1514.         /**
  1515.          * Cancel the watch event. This may lead to a race condition with the watch event callback if tracing is enabled.
  1516.          */
  1517.         cancelWatchEvent(): void;
  1518.     }
  1519.  
  1520.     interface ContentTracingOptions {
  1521.         /**
  1522.          * Filter to control what category groups should be traced.
  1523.          * A filter can have an optional - prefix to exclude category groups
  1524.          * that contain a matching category. Having both included and excluded
  1525.          * category patterns in the same list is not supported.
  1526.          *
  1527.          * Examples:
  1528.          *   test_MyTest*
  1529.          *   test_MyTest*,test_OtherStuff
  1530.          *   -excluded_category1,-excluded_category2
  1531.          */
  1532.         categoryFilter: string;
  1533.         /**
  1534.          * Controls what kind of tracing is enabled, it is a comma-delimited list.
  1535.          *
  1536.          * Possible options are:
  1537.          *   record-until-full
  1538.          *   record-continuously
  1539.          *   trace-to-console
  1540.          *   enable-sampling
  1541.          *   enable-systrace
  1542.          *
  1543.          * The first 3 options are trace recoding modes and hence mutually exclusive.
  1544.          * If more than one trace recording modes appear in the traceOptions string,
  1545.          * the last one takes precedence. If none of the trace recording modes are specified,
  1546.          * recording mode is record-until-full.
  1547.          *
  1548.          * The trace option will first be reset to the default option (record_mode set
  1549.          * to record-until-full, enable_sampling and enable_systrace set to false)
  1550.          * before options parsed from traceOptions are applied on it.
  1551.          */
  1552.         traceOptions: string;
  1553.     }
  1554.  
  1555.     // https://github.com/electron/electron/blob/master/docs/api/crash-reporter.md
  1556.  
  1557.     /**
  1558.      * The crash-reporter module enables sending your app's crash reports.
  1559.      */
  1560.     interface CrashReporter {
  1561.         /**
  1562.          * You are required to call this method before using other crashReporter APIs.
  1563.          *
  1564.          * Note: On OS X, Electron uses a new crashpad client, which is different from breakpad
  1565.          * on Windows and Linux. To enable the crash collection feature, you are required to call
  1566.          * the crashReporter.start API to initialize crashpad in the main process and in each
  1567.          * renderer process from which you wish to collect crash reports.
  1568.          */
  1569.         start(options: CrashReporterStartOptions): void;
  1570.         /**
  1571.          * @returns The crash report. When there was no crash report
  1572.          * sent or the crash reporter is not started, null will be returned.
  1573.          */
  1574.         getLastCrashReport(): CrashReport;
  1575.         /**
  1576.          * @returns All uploaded crash reports.
  1577.          */
  1578.         getUploadedReports(): CrashReport[];
  1579.     }
  1580.  
  1581.     interface CrashReporterStartOptions {
  1582.         /**
  1583.          * Default: Electron
  1584.          */
  1585.         productName?: string;
  1586.         companyName: string;
  1587.         /**
  1588.          * URL that crash reports would be sent to as POST.
  1589.          */
  1590.         submitURL: string;
  1591.         /**
  1592.          * Send the crash report without user interaction.
  1593.          * Default: true.
  1594.          */
  1595.         autoSubmit?: boolean;
  1596.         /**
  1597.          * Default: false.
  1598.          */
  1599.         ignoreSystemCrashHandler?: boolean;
  1600.         /**
  1601.          * An object you can define that will be sent along with the report.
  1602.          * Only string properties are sent correctly, nested objects are not supported.
  1603.          */
  1604.         extra?: {[prop: string]: string};
  1605.     }
  1606.  
  1607.     interface CrashReport {
  1608.         id: string;
  1609.         date: Date;
  1610.     }
  1611.  
  1612.     // https://github.com/electron/electron/blob/master/docs/api/desktop-capturer.md
  1613.  
  1614.     /**
  1615.      * The desktopCapturer module can be used to get available sources
  1616.      * that can be used to be captured with getUserMedia.
  1617.      */
  1618.     interface DesktopCapturer {
  1619.         /**
  1620.          * Starts a request to get all desktop sources.
  1621.          *
  1622.          * Note: There is no guarantee that the size of source.thumbnail is always
  1623.          * the same as the thumnbailSize in options. It also depends on the scale of the screen or window.
  1624.          */
  1625.         getSources(options: DesktopCapturerOptions, callback: (error: Error, sources: DesktopCapturerSource[]) => any): void;
  1626.     }
  1627.  
  1628.     interface DesktopCapturerOptions {
  1629.         /**
  1630.          * The types of desktop sources to be captured.
  1631.          */
  1632.         types?: ('screen' | 'window')[];
  1633.         /**
  1634.          * The suggested size that thumbnail should be scaled.
  1635.          * Default: {width: 150, height: 150}
  1636.          */
  1637.         thumbnailSize?: Dimension;
  1638.     }
  1639.  
  1640.     interface DesktopCapturerSource {
  1641.         /**
  1642.          * The id of the captured window or screen used in navigator.webkitGetUserMedia.
  1643.          * The format looks like window:XX or screen:XX where XX is a random generated number.
  1644.          */
  1645.         id: string;
  1646.         /**
  1647.          * The described name of the capturing screen or window.
  1648.          * If the source is a screen, the name will be Entire Screen or Screen <index>;
  1649.          * if it is a window, the name will be the window’s title.
  1650.          */
  1651.         name: string;
  1652.         /**
  1653.          * A thumbnail image.
  1654.          */
  1655.         thumbnail: NativeImage;
  1656.     }
  1657.  
  1658.     // https://github.com/electron/electron/blob/master/docs/api/dialog.md
  1659.  
  1660.     /**
  1661.      * The dialog module provides APIs to show native system dialogs, such as opening files or alerting,
  1662.      * so web applications can deliver the same user experience as native applications.
  1663.      */
  1664.     interface Dialog {
  1665.         /**
  1666.          * Note: On Windows and Linux an open dialog can not be both a file selector and a directory selector,
  1667.          * so if you set properties to ['openFile', 'openDirectory'] on these platforms, a directory selector will be shown.
  1668.          *
  1669.          * @param callback If supplied, the API call will be asynchronous.
  1670.          * @returns On success, returns an array of file paths chosen by the user,
  1671.          * otherwise returns undefined.
  1672.          */
  1673.         showOpenDialog(browserWindow: BrowserWindow, options: OpenDialogOptions, callback?: (fileNames: string[]) => void): string[];
  1674.         /**
  1675.          * Note: On Windows and Linux an open dialog can not be both a file selector and a directory selector,
  1676.          * so if you set properties to ['openFile', 'openDirectory'] on these platforms, a directory selector will be shown.
  1677.          *
  1678.          * @param callback If supplied, the API call will be asynchronous.
  1679.          * @returns On success, returns an array of file paths chosen by the user,
  1680.          * otherwise returns undefined.
  1681.          */
  1682.         showOpenDialog(options: OpenDialogOptions, callback?: (fileNames: string[]) => void): string[];
  1683.         /**
  1684.          * @param callback If supplied, the API call will be asynchronous.
  1685.          * @returns On success, returns the path of file chosen by the user, otherwise
  1686.          * returns undefined.
  1687.          */
  1688.         showSaveDialog(browserWindow: BrowserWindow, options: SaveDialogOptions, callback?: (fileName: string) => void): string;
  1689.         /**
  1690.          * @param callback If supplied, the API call will be asynchronous.
  1691.          * @returns On success, returns the path of file chosen by the user, otherwise
  1692.          * returns undefined.
  1693.          */
  1694.         showSaveDialog(options: SaveDialogOptions, callback?: (fileName: string) => void): string;
  1695.         /**
  1696.          * Shows a message box. It will block until the message box is closed.
  1697.          * @param callback If supplied, the API call will be asynchronous.
  1698.          * @returns The index of the clicked button.
  1699.          */
  1700.         showMessageBox(browserWindow: BrowserWindow, options: ShowMessageBoxOptions, callback?: (response: number) => void): number;
  1701.         /**
  1702.          * Shows a message box. It will block until the message box is closed.
  1703.          * @param callback If supplied, the API call will be asynchronous.
  1704.          * @returns The index of the clicked button.
  1705.          */
  1706.         showMessageBox(options: ShowMessageBoxOptions, callback?: (response: number) => void): number;
  1707.         /**
  1708.          * Displays a modal dialog that shows an error message.
  1709.          *
  1710.          * This API can be called safely before the ready event the app module emits,
  1711.          * it is usually used to report errors in early stage of startup.
  1712.          * If called before the app readyevent on Linux, the message will be emitted to stderr,
  1713.          * and no GUI dialog will appear.
  1714.          */
  1715.         showErrorBox(title: string, content: string): void;
  1716.     }
  1717.  
  1718.     interface OpenDialogOptions {
  1719.         title?: string;
  1720.         defaultPath?: string;
  1721.         /**
  1722.          * Custom label for the confirmation button, when left empty the default label will be used.
  1723.          */
  1724.         buttonLabel?: string;
  1725.         /**
  1726.          * File types that can be displayed or selected.
  1727.          */
  1728.         filters?: {
  1729.             name: string;
  1730.             /**
  1731.              * Extensions without wildcards or dots (e.g. 'png' is good but '.png' and '*.png' are bad).
  1732.              * To show all files, use the '*' wildcard (no other wildcard is supported).
  1733.              */
  1734.             extensions: string[];
  1735.         }[];
  1736.         /**
  1737.          * Contains which features the dialog should use.
  1738.          */
  1739.         properties?: ('openFile' | 'openDirectory' | 'multiSelections' | 'createDirectory')[];
  1740.     }
  1741.  
  1742.     interface SaveDialogOptions {
  1743.         title?: string;
  1744.         defaultPath?: string;
  1745.         /**
  1746.          * Custom label for the confirmation button, when left empty the default label will be used.
  1747.          */
  1748.         buttonLabel?: string;
  1749.         /**
  1750.          * File types that can be displayed, see dialog.showOpenDialog for an example.
  1751.          */
  1752.         filters?: {
  1753.             name: string;
  1754.             extensions: string[];
  1755.         }[];
  1756.     }
  1757.  
  1758.     interface ShowMessageBoxOptions {
  1759.         /**
  1760.          * On Windows, "question" displays the same icon as "info", unless you set an icon using the "icon" option.
  1761.          */
  1762.         type?: 'none' | 'info' | 'error' | 'question' | 'warning';
  1763.         /**
  1764.          * Texts for buttons. On Windows, an empty array will result in one button labeled "OK".
  1765.          */
  1766.         buttons?: string[];
  1767.         /**
  1768.          * Index of the button in the buttons array which will be selected by default when the message box opens.
  1769.          */
  1770.         defaultId?: number;
  1771.         /**
  1772.          * Title of the message box (some platforms will not show it).
  1773.          */
  1774.         title?: string;
  1775.         /**
  1776.          * Contents of the message box.
  1777.          */
  1778.         message?: string;
  1779.         /**
  1780.          * Extra information of the message.
  1781.          */
  1782.         detail?: string;
  1783.         icon?: NativeImage;
  1784.         /**
  1785.          * The value will be returned when user cancels the dialog instead of clicking the buttons of the dialog.
  1786.          * By default it is the index of the buttons that have "cancel" or "no" as label,
  1787.          * or 0 if there is no such buttons. On OS X and Windows the index of "Cancel" button
  1788.          * will always be used as cancelId, not matter whether it is already specified.
  1789.          */
  1790.         cancelId?: number;
  1791.         /**
  1792.          * On Windows Electron will try to figure out which one of the buttons are common buttons
  1793.          * (like "Cancel" or "Yes"), and show the others as command links in the dialog.
  1794.          * This can make the dialog appear in the style of modern Windows apps.
  1795.          * If you don’t like this behavior, you can set noLink to true.
  1796.          */
  1797.         noLink?: boolean;
  1798.     }
  1799.  
  1800.     // https://github.com/electron/electron/blob/master/docs/api/download-item.md
  1801.  
  1802.     /**
  1803.      * DownloadItem represents a download item in Electron.
  1804.      */
  1805.     interface DownloadItem extends NodeJS.EventEmitter {
  1806.         /**
  1807.          * Emits when the downloadItem gets updated.
  1808.          */
  1809.         on(event: 'updated', listener: Function): this;
  1810.         /**
  1811.          * Emits when the download is in a terminal state. This includes a completed download,
  1812.          * a cancelled download (via downloadItem.cancel()), and interrupted download that can’t be resumed.
  1813.          */
  1814.         on(event: 'done', listener: (event: Event, state: 'completed' | 'cancelled' | 'interrupted') => void): this;
  1815.         on(event: string, listener: Function): this;
  1816.         /**
  1817.          * Set the save file path of the download item.
  1818.          * Note: The API is only available in session’s will-download callback function.
  1819.          * If user doesn’t set the save path via the API, Electron will use the original
  1820.          * routine to determine the save path (Usually prompts a save dialog).
  1821.          */
  1822.         setSavePath(path: string): void;
  1823.         /**
  1824.          * Pauses the download.
  1825.          */
  1826.         pause(): void;
  1827.         /**
  1828.          * Resumes the download that has been paused.
  1829.          */
  1830.         resume(): void;
  1831.         /**
  1832.          * Cancels the download operation.
  1833.          */
  1834.         cancel(): void;
  1835.         /**
  1836.          * @returns The origin url where the item is downloaded from.
  1837.          */
  1838.         getURL(): string;
  1839.         /**
  1840.          * @returns The mime type.
  1841.          */
  1842.         getMimeType(): string;
  1843.         /**
  1844.          * @returns Whether the download has user gesture.
  1845.          */
  1846.         hasUserGesture(): boolean;
  1847.         /**
  1848.          * @returns The file name of the download item.
  1849.          * Note: The file name is not always the same as the actual one saved in local disk.
  1850.          * If user changes the file name in a prompted download saving dialog,
  1851.          * the actual name of saved file will be different.
  1852.          */
  1853.         getFilename(): string;
  1854.         /**
  1855.          * @returns The total size in bytes of the download item. If the size is unknown, it returns 0.
  1856.          */
  1857.         getTotalBytes(): number;
  1858.         /**
  1859.          * @returns The received bytes of the download item.
  1860.          */
  1861.         getReceivedBytes(): number;
  1862.         /**
  1863.          * @returns The Content-Disposition field from the response header.
  1864.          */
  1865.         getContentDisposition(): string;
  1866.     }
  1867.  
  1868.     // https://github.com/electron/electron/blob/master/docs/api/global-shortcut.md
  1869.  
  1870.     /**
  1871.      * The globalShortcut module can register/unregister a global keyboard shortcut
  1872.      * with the operating system so that you can customize the operations for various shortcuts.
  1873.      * Note: The shortcut is global; it will work even if the app does not have the keyboard focus.
  1874.      * You should not use this module until the ready event of the app module is emitted.
  1875.      */
  1876.     interface GlobalShortcut {
  1877.         /**
  1878.          * Registers a global shortcut of accelerator.
  1879.          * @param accelerator Represents a keyboard shortcut. It can contain modifiers
  1880.          * and key codes, combined by the "+" character.
  1881.          * @param callback Called when the registered shortcut is pressed by the user.
  1882.          */
  1883.         register(accelerator: string, callback: Function): void;
  1884.         /**
  1885.          * @param accelerator Represents a keyboard shortcut. It can contain modifiers
  1886.          * and key codes, combined by the "+" character.
  1887.          * @returns Whether the accelerator is registered.
  1888.          */
  1889.         isRegistered(accelerator: string): boolean;
  1890.         /**
  1891.          * Unregisters the global shortcut of keycode.
  1892.          * @param accelerator Represents a keyboard shortcut. It can contain modifiers
  1893.          * and key codes, combined by the "+" character.
  1894.          */
  1895.         unregister(accelerator: string): void;
  1896.         /**
  1897.          * Unregisters all the global shortcuts.
  1898.          */
  1899.         unregisterAll(): void;
  1900.     }
  1901.  
  1902.     // https://github.com/electron/electron/blob/master/docs/api/ipc-main.md
  1903.  
  1904.     /**
  1905.      * The ipcMain module handles asynchronous and synchronous messages
  1906.      * sent from a renderer process (web page).
  1907.      * Messages sent from a renderer will be emitted to this module.
  1908.      */
  1909.     interface IpcMain extends NodeJS.EventEmitter {
  1910.         addListener(channel: string, listener: IpcMainEventListener): this;
  1911.         on(channel: string, listener: IpcMainEventListener): this;
  1912.         once(channel: string, listener: IpcMainEventListener): this;
  1913.         removeListener(channel: string, listener: IpcMainEventListener): this;
  1914.         removeAllListeners(channel?: string): this;
  1915.     }
  1916.  
  1917.     type IpcMainEventListener = (event: IpcMainEvent, ...args: any[]) => void;
  1918.  
  1919.     interface IpcMainEvent {
  1920.         /**
  1921.          * Set this to the value to be returned in a synchronous message.
  1922.          */
  1923.         returnValue?: any;
  1924.         /**
  1925.          * Returns the webContents that sent the message, you can call sender.send
  1926.          * to reply to the asynchronous message.
  1927.          */
  1928.         sender: WebContents;
  1929.     }
  1930.  
  1931.     // https://github.com/electron/electron/blob/master/docs/api/ipc-renderer.md
  1932.  
  1933.     /**
  1934.      * The ipcRenderer module provides a few methods so you can send synchronous
  1935.      * and asynchronous messages from the render process (web page) to the main process.
  1936.      * You can also receive replies from the main process.
  1937.      */
  1938.     interface IpcRenderer extends NodeJS.EventEmitter {
  1939.         addListener(channel: string, listener: IpcRendererEventListener): this;
  1940.         on(channel: string, listener: IpcRendererEventListener): this;
  1941.         once(channel: string, listener: IpcRendererEventListener): this;
  1942.         removeListener(channel: string, listener: IpcRendererEventListener): this;
  1943.         removeAllListeners(channel?: string): this;
  1944.         /**
  1945.          * Send ...args to the renderer via channel in asynchronous message, the main
  1946.          * process can handle it by listening to the channel event of ipc module.
  1947.          */
  1948.         send(channel: string, ...args: any[]): void;
  1949.         /**
  1950.          * Send ...args to the renderer via channel in synchronous message, and returns
  1951.          * the result sent from main process. The main process can handle it by listening
  1952.          * to the channel event of ipc module, and returns by setting event.returnValue.
  1953.          * Note: Usually developers should never use this API, since sending synchronous
  1954.          * message would block the whole renderer process.
  1955.          * @returns The result sent from the main process.
  1956.          */
  1957.         sendSync(channel: string, ...args: any[]): any;
  1958.         /**
  1959.          * Like ipc.send but the message will be sent to the host page instead of the main process.
  1960.          * This is mainly used by the page in <webview> to communicate with host page.
  1961.          */
  1962.         sendToHost(channel: string, ...args: any[]): void;
  1963.     }
  1964.  
  1965.     type IpcRendererEventListener = (event: IpcRendererEvent, ...args: any[]) => void;
  1966.  
  1967.     interface IpcRendererEvent {
  1968.         /**
  1969.          * You can call sender.send to reply to the asynchronous message.
  1970.          */
  1971.         sender: IpcRenderer;
  1972.     }
  1973.  
  1974.     // https://github.com/electron/electron/blob/master/docs/api/menu-item.md
  1975.     // https://github.com/electron/electron/blob/master/docs/api/accelerator.md
  1976.  
  1977.     /**
  1978.      * The MenuItem allows you to add items to an application or context menu.
  1979.      */
  1980.     class MenuItem {
  1981.         /**
  1982.          * Create a new menu item.
  1983.          */
  1984.         constructor(options: MenuItemOptions);
  1985.  
  1986.         click: (menuItem: MenuItem, browserWindow: BrowserWindow) => void;
  1987.         /**
  1988.          * Read-only property.
  1989.          */
  1990.         type: MenuItemType;
  1991.         /**
  1992.          * Read-only property.
  1993.          */
  1994.         role: MenuItemRole | MenuItemRoleMac;
  1995.         /**
  1996.          * Read-only property.
  1997.          */
  1998.         accelerator: string;
  1999.         /**
  2000.          * Read-only property.
  2001.          */
  2002.         icon: NativeImage | string;
  2003.         /**
  2004.          * Read-only property.
  2005.          */
  2006.         submenu: Menu | MenuItemOptions[];
  2007.  
  2008.         label: string;
  2009.         sublabel: string;
  2010.         enabled: boolean;
  2011.         visible: boolean;
  2012.         checked: boolean;
  2013.     }
  2014.  
  2015.     type MenuItemType = 'normal' | 'separator' | 'submenu' | 'checkbox' | 'radio';
  2016.     type MenuItemRole = 'undo' | 'redo' | 'cut' | 'copy' | 'paste' | 'selectall' | 'minimize' | 'close';
  2017.     type MenuItemRoleMac = 'about' | 'hide' | 'hideothers' | 'unhide' | 'front' | 'window' | 'help' | 'services';
  2018.  
  2019.     interface MenuItemOptions {
  2020.         /**
  2021.          * Callback when the menu item is clicked.
  2022.          */
  2023.         click?: (menuItem: MenuItem, browserWindow: BrowserWindow) => void;
  2024.         /**
  2025.          * Can be normal, separator, submenu, checkbox or radio.
  2026.          */
  2027.         type?: MenuItemType;
  2028.         label?: string;
  2029.         sublabel?: string;
  2030.         /**
  2031.          * An accelerator is string that represents a keyboard shortcut, it can contain
  2032.          * multiple modifiers and key codes, combined by the + character.
  2033.          *
  2034.          * Examples:
  2035.          *   CommandOrControl+A
  2036.          *   CommandOrControl+Shift+Z
  2037.          *
  2038.          * Platform notice:
  2039.          *   On Linux and Windows, the Command key would not have any effect,
  2040.          *   you can use CommandOrControl which represents Command on OS X and Control on
  2041.          *   Linux and Windows to define some accelerators.
  2042.          *
  2043.          *   Use Alt instead of Option. The Option key only exists on OS X, whereas
  2044.          *   the Alt key is available on all platforms.
  2045.          *
  2046.          *   The Super key is mapped to the Windows key on Windows and Linux and Cmd on OS X.
  2047.          *
  2048.          * Available modifiers:
  2049.          *   Command (or Cmd for short)
  2050.          *   Control (or Ctrl for short)
  2051.          *   CommandOrControl (or CmdOrCtrl for short)
  2052.          *   Alt
  2053.          *   Option
  2054.          *   AltGr
  2055.          *   Shift
  2056.          *   Super
  2057.          *
  2058.          * Available key codes:
  2059.          *   0 to 9
  2060.          *   A to Z
  2061.          *   F1 to F24
  2062.          *   Punctuations like ~, !, @, #, $, etc.
  2063.          *   Plus
  2064.          *   Space
  2065.          *   Tab
  2066.          *   Backspace
  2067.          *   Delete
  2068.          *   Insert
  2069.          *   Return (or Enter as alias)
  2070.          *   Up, Down, Left and Right
  2071.          *   Home and End
  2072.          *   PageUp and PageDown
  2073.          *   Escape (or Esc for short)
  2074.          *   VolumeUp, VolumeDown and VolumeMute
  2075.          *   MediaNextTrack, MediaPreviousTrack, MediaStop and MediaPlayPause
  2076.          *   PrintScreen
  2077.          */
  2078.         accelerator?: string;
  2079.         /**
  2080.          * In Electron for the APIs that take images, you can pass either file paths
  2081.          * or NativeImage instances. When passing null, an empty image will be used.
  2082.          */
  2083.         icon?: NativeImage|string;
  2084.         /**
  2085.          * If false, the menu item will be greyed out and unclickable.
  2086.          */
  2087.         enabled?: boolean;
  2088.         /**
  2089.          * If false, the menu item will be entirely hidden.
  2090.          */
  2091.         visible?: boolean;
  2092.         /**
  2093.          * Should only be specified for 'checkbox' or 'radio' type menu items.
  2094.          */
  2095.         checked?: boolean;
  2096.         /**
  2097.          * Should be specified for submenu type menu item, when it's specified the
  2098.          * type: 'submenu' can be omitted for the menu item
  2099.          */
  2100.         submenu?: Menu|MenuItemOptions[];
  2101.         /**
  2102.          * Unique within a single menu. If defined then it can be used as a reference
  2103.          * to this item by the position attribute.
  2104.          */
  2105.         id?: string;
  2106.         /**
  2107.          * This field allows fine-grained definition of the specific location within
  2108.          * a given menu.
  2109.          */
  2110.         position?: string;
  2111.         /**
  2112.          * Define the action of the menu item, when specified the click property will be ignored
  2113.          */
  2114.         role?: MenuItemRole | MenuItemRoleMac;
  2115.     }
  2116.  
  2117.     // https://github.com/electron/electron/blob/master/docs/api/menu.md
  2118.  
  2119.     /**
  2120.      * The Menu class is used to create native menus that can be used as application
  2121.      * menus and context menus. This module is a main process module which can be used
  2122.      * in a render process via the remote module.
  2123.      *
  2124.      * Each menu consists of multiple menu items, and each menu item can have a submenu.
  2125.      */
  2126.     class Menu extends EventEmitter {
  2127.         /**
  2128.          * Creates a new menu.
  2129.          */
  2130.         constructor();
  2131.         /**
  2132.          * Sets menu as the application menu on OS X. On Windows and Linux, the menu
  2133.          * will be set as each window's top menu.
  2134.          */
  2135.         static setApplicationMenu(menu: Menu): void;
  2136.         /**
  2137.          * Sends the action to the first responder of application.
  2138.          * This is used for emulating default Cocoa menu behaviors,
  2139.          * usually you would just use the role property of MenuItem.
  2140.          *
  2141.          * Note: This method is OS X only.
  2142.          */
  2143.         static sendActionToFirstResponder(action: string): void;
  2144.         /**
  2145.          * @param template Generally, just an array of options for constructing MenuItem.
  2146.          * You can also attach other fields to element of the template, and they will
  2147.          * become properties of the constructed menu items.
  2148.          */
  2149.         static buildFromTemplate(template: MenuItemOptions[]): Menu;
  2150.         /**
  2151.          * Popups this menu as a context menu in the browserWindow. You can optionally
  2152.          * provide a (x,y) coordinate to place the menu at, otherwise it will be placed
  2153.          * at the current mouse cursor position.
  2154.          * @param x Horizontal coordinate where the menu will be placed.
  2155.          * @param y Vertical coordinate where the menu will be placed.
  2156.          */
  2157.         popup(browserWindow?: BrowserWindow, x?: number, y?: number): void;
  2158.         /**
  2159.          * Appends the menuItem to the menu.
  2160.          */
  2161.         append(menuItem: MenuItem): void;
  2162.         /**
  2163.          * Inserts the menuItem to the pos position of the menu.
  2164.          */
  2165.         insert(position: number, menuItem: MenuItem): void;
  2166.         /**
  2167.          * @returns an array containing the menu’s items.
  2168.          */
  2169.         items: MenuItem[];
  2170.     }
  2171.  
  2172.     // https://github.com/electron/electron/blob/master/docs/api/native-image.md
  2173.  
  2174.     /**
  2175.      * This class is used to represent an image.
  2176.      */
  2177.     class NativeImage {
  2178.         /**
  2179.          * Creates an empty NativeImage instance.
  2180.          */
  2181.         static createEmpty(): NativeImage;
  2182.         /**
  2183.          * Creates a new NativeImage instance from file located at path.
  2184.          */
  2185.         static createFromPath(path: string): NativeImage;
  2186.         /**
  2187.          * Creates a new NativeImage instance from buffer.
  2188.          * @param scaleFactor 1.0 by default.
  2189.          */
  2190.         static createFromBuffer(buffer: Buffer, scaleFactor?: number): NativeImage;
  2191.         /**
  2192.          * Creates a new NativeImage instance from dataURL
  2193.          */
  2194.         static createFromDataURL(dataURL: string): NativeImage;
  2195.         /**
  2196.          * @returns Buffer Contains the image's PNG encoded data.
  2197.          */
  2198.         toPng(): Buffer;
  2199.         /**
  2200.          * @returns Buffer Contains the image's JPEG encoded data.
  2201.          */
  2202.         toJpeg(quality: number): Buffer;
  2203.         /**
  2204.          * @returns string The data URL of the image.
  2205.          */
  2206.         toDataURL(): string;
  2207.         /**
  2208.          * The native type of the handle is NSImage* on OS X.
  2209.          * Note: This is only implemented on OS X.
  2210.          * @returns The platform-specific handle of the image as Buffer.
  2211.          */
  2212.         getNativeHandle(): Buffer;
  2213.         /**
  2214.          * @returns boolean Whether the image is empty.
  2215.          */
  2216.         isEmpty(): boolean;
  2217.         /**
  2218.          * @returns {} The size of the image.
  2219.          */
  2220.         getSize(): Dimension;
  2221.         /**
  2222.          * Marks the image as template image.
  2223.          */
  2224.         setTemplateImage(option: boolean): void;
  2225.         /**
  2226.          * Returns a boolean whether the image is a template image.
  2227.          */
  2228.         isTemplateImage(): boolean;
  2229.     }
  2230.  
  2231.     // https://github.com/electron/electron/blob/master/docs/api/power-monitor.md
  2232.  
  2233.     /**
  2234.      * The power-monitor module is used to monitor power state changes.
  2235.      * You should not use this module until the ready event of the app module is emitted.
  2236.      */
  2237.     interface PowerMonitor extends NodeJS.EventEmitter {
  2238.         /**
  2239.          * Emitted when the system is suspending.
  2240.          */
  2241.         on(event: 'suspend', listener: Function): this;
  2242.         /**
  2243.          * Emitted when system is resuming.
  2244.          */
  2245.         on(event: 'resume', listener: Function): this;
  2246.         /**
  2247.          * Emitted when the system changes to AC power.
  2248.          */
  2249.         on(event: 'on-ac', listener: Function): this;
  2250.         /**
  2251.          * Emitted when system changes to battery power.
  2252.          */
  2253.         on(event: 'on-battery', listener: Function): this;
  2254.         on(event: string, listener: Function): this;
  2255.     }
  2256.  
  2257.     // https://github.com/electron/electron/blob/master/docs/api/power-save-blocker.md
  2258.  
  2259.     /**
  2260.      * The powerSaveBlocker module is used to block the system from entering
  2261.      * low-power (sleep) mode and thus allowing the app to keep the system and screen active.
  2262.      */
  2263.     interface PowerSaveBlocker {
  2264.         /**
  2265.          * Starts preventing the system from entering lower-power mode.
  2266.          * @returns an integer identifying the power save blocker.
  2267.          * Note: prevent-display-sleep has higher has precedence over prevent-app-suspension.
  2268.          */
  2269.         start(type: 'prevent-app-suspension' | 'prevent-display-sleep'): number;
  2270.         /**
  2271.          * @param id The power save blocker id returned by powerSaveBlocker.start.
  2272.          * Stops the specified power save blocker.
  2273.          */
  2274.         stop(id: number): void;
  2275.         /**
  2276.          * @param id The power save blocker id returned by powerSaveBlocker.start.
  2277.          * @returns a boolean whether the corresponding powerSaveBlocker has started.
  2278.          */
  2279.         isStarted(id: number): boolean;
  2280.     }
  2281.  
  2282.     // https://github.com/electron/electron/blob/master/docs/api/protocol.md
  2283.  
  2284.     /**
  2285.      * The protocol module can register a custom protocol or intercept an existing protocol.
  2286.      */
  2287.     interface Protocol {
  2288.         /**
  2289.          * Registers custom schemes as standard schemes.
  2290.          */
  2291.         registerStandardSchemes(schemes: string[]): void;
  2292.         /**
  2293.          * Registers custom schemes to handle service workers.
  2294.          */
  2295.         registerServiceWorkerSchemes(schemes: string[]): void;
  2296.         /**
  2297.          * Registers a protocol of scheme that will send the file as a response.
  2298.          */
  2299.         registerFileProtocol(scheme: string, handler: FileProtocolHandler, completion?: (error: Error) => void): void;
  2300.         /**
  2301.          * Registers a protocol of scheme that will send a Buffer as a response.
  2302.          */
  2303.         registerBufferProtocol(scheme: string, handler: BufferProtocolHandler, completion?: (error: Error) => void): void;
  2304.         /**
  2305.          * Registers a protocol of scheme that will send a String as a response.
  2306.          */
  2307.         registerStringProtocol(scheme: string, handler: StringProtocolHandler, completion?: (error: Error) => void): void;
  2308.         /**
  2309.          * Registers a protocol of scheme that will send an HTTP request as a response.
  2310.          */
  2311.         registerHttpProtocol(scheme: string, handler: HttpProtocolHandler, completion?: (error: Error) => void): void;
  2312.         /**
  2313.          * Unregisters the custom protocol of scheme.
  2314.          */
  2315.         unregisterProtocol(scheme: string, completion?: (error: Error) => void): void;
  2316.         /**
  2317.          * The callback will be called with a boolean that indicates whether there is already a handler for scheme.
  2318.          */
  2319.         isProtocolHandled(scheme: string, callback: (handled: boolean) => void): void;
  2320.         /**
  2321.          * Intercepts scheme protocol and uses handler as the protocol’s new handler which sends a file as a response.
  2322.          */
  2323.         interceptFileProtocol(scheme: string, handler: FileProtocolHandler, completion?: (error: Error) => void): void;
  2324.         /**
  2325.          * Intercepts scheme protocol and uses handler as the protocol’s new handler which sends a Buffer as a response.
  2326.          */
  2327.         interceptBufferProtocol(scheme: string, handler: BufferProtocolHandler, completion?: (error: Error) => void): void;
  2328.         /**
  2329.          * Intercepts scheme protocol and uses handler as the protocol’s new handler which sends a String as a response.
  2330.          */
  2331.         interceptStringProtocol(scheme: string, handler: StringProtocolHandler, completion?: (error: Error) => void): void;
  2332.         /**
  2333.          * Intercepts scheme protocol and uses handler as the protocol’s new handler which sends a new HTTP request as a response.
  2334.          */
  2335.         interceptHttpProtocol(scheme: string, handler: HttpProtocolHandler, completion?: (error: Error) => void): void;
  2336.         /**
  2337.          * Remove the interceptor installed for scheme and restore its original handler.
  2338.          */
  2339.         uninterceptProtocol(scheme: string, completion?: (error: Error) => void): void;
  2340.     }
  2341.  
  2342.     type FileProtocolHandler = (request: ProtocolRequest, callback: FileProtocolCallback) => void;
  2343.     type BufferProtocolHandler = (request: ProtocolRequest, callback: BufferProtocolCallback) => void;
  2344.     type StringProtocolHandler = (request: ProtocolRequest, callback: StringProtocolCallback) => void;
  2345.     type HttpProtocolHandler = (request: ProtocolRequest, callback: HttpProtocolCallback) => void;
  2346.  
  2347.     interface ProtocolRequest {
  2348.         url: string;
  2349.         referrer: string;
  2350.         method: string;
  2351.         uploadData?: {
  2352.             bytes: Buffer,
  2353.             file: string
  2354.         }[];
  2355.     }
  2356.  
  2357.     interface ProtocolCallback {
  2358.         (error: number): void;
  2359.         (obj: {
  2360.             error: number
  2361.         }): void;
  2362.         (): void;
  2363.     }
  2364.  
  2365.     interface FileProtocolCallback extends ProtocolCallback {
  2366.         (filePath: string): void;
  2367.         (obj: {
  2368.             path: string
  2369.         }): void;
  2370.     }
  2371.  
  2372.     interface BufferProtocolCallback extends ProtocolCallback {
  2373.         (buffer: Buffer): void;
  2374.         (obj: {
  2375.             data: Buffer,
  2376.             mimeType: string,
  2377.             charset?: string
  2378.         }): void;
  2379.     }
  2380.  
  2381.     interface StringProtocolCallback extends ProtocolCallback {
  2382.         (str: string): void;
  2383.         (obj: {
  2384.             data: Buffer,
  2385.             mimeType: string,
  2386.             charset?: string
  2387.         }): void;
  2388.     }
  2389.  
  2390.     interface HttpProtocolCallback extends ProtocolCallback {
  2391.         (redirectRequest: {
  2392.             url: string;
  2393.             method: string;
  2394.             session?: Object;
  2395.             uploadData?: {
  2396.                 contentType: string;
  2397.                 data: string;
  2398.             };
  2399.         }): void;
  2400.     }
  2401.  
  2402.     // https://github.com/electron/electron/blob/master/docs/api/remote.md
  2403.  
  2404.     /**
  2405.      * The remote module provides a simple way to do inter-process communication (IPC)
  2406.      * between the renderer process (web page) and the main process.
  2407.      */
  2408.     interface Remote extends CommonElectron {
  2409.         /**
  2410.          * @returns The object returned by require(module) in the main process.
  2411.          */
  2412.         require(module: string): any;
  2413.         /**
  2414.          * @returns The BrowserWindow object which this web page belongs to.
  2415.          */
  2416.         getCurrentWindow(): BrowserWindow;
  2417.         /**
  2418.          * @returns The WebContents object of this web page.
  2419.          */
  2420.         getCurrentWebContents(): WebContents;
  2421.         /**
  2422.          * @returns The global variable of name (e.g. global[name]) in the main process.
  2423.          */
  2424.         getGlobal(name: string): any;
  2425.         /**
  2426.          * Returns the process object in the main process. This is the same as
  2427.          * remote.getGlobal('process'), but gets cached.
  2428.          */
  2429.         process: NodeJS.Process;
  2430.     }
  2431.  
  2432.     // https://github.com/electron/electron/blob/master/docs/api/screen.md
  2433.  
  2434.     /**
  2435.      * The Display object represents a physical display connected to the system.
  2436.      * A fake Display may exist on a headless system, or a Display may correspond to a remote, virtual display.
  2437.      */
  2438.     interface Display {
  2439.         /**
  2440.          * Unique identifier associated with the display.
  2441.          */
  2442.         id: number;
  2443.         bounds: Bounds;
  2444.         workArea: Bounds;
  2445.         size: Dimension;
  2446.         workAreaSize: Dimension;
  2447.         /**
  2448.          * Output device’s pixel scale factor.
  2449.          */
  2450.         scaleFactor: number;
  2451.         /**
  2452.          * Can be 0, 90, 180, 270, represents screen rotation in clock-wise degrees.
  2453.          */
  2454.         rotation: number;
  2455.         touchSupport: 'available' | 'unavailable' | 'unknown';
  2456.     }
  2457.  
  2458.     type Bounds = {
  2459.         x: number;
  2460.         y: number;
  2461.         width: number;
  2462.         height: number;
  2463.     }
  2464.  
  2465.     type Dimension = {
  2466.         width: number;
  2467.         height: number;
  2468.     }
  2469.  
  2470.     type Point = {
  2471.         x: number;
  2472.         y: number;
  2473.     }
  2474.  
  2475.     type DisplayMetrics = 'bounds' | 'workArea' | 'scaleFactor' | 'rotation';
  2476.  
  2477.     /**
  2478.      * The screen module retrieves information about screen size, displays, cursor position, etc.
  2479.      * You can not use this module until the ready event of the app module is emitted.
  2480.      */
  2481.     interface Screen extends NodeJS.EventEmitter {
  2482.         /**
  2483.          * Emitted when newDisplay has been added.
  2484.          */
  2485.         on(event: 'display-added', listener: (event: Event, newDisplay: Display) => void): this;
  2486.         /**
  2487.          * Emitted when oldDisplay has been removed.
  2488.          */
  2489.         on(event: 'display-removed', listener: (event: Event, oldDisplay: Display) => void): this;
  2490.         /**
  2491.          * Emitted when one or more metrics change in a display.
  2492.          */
  2493.         on(event: 'display-metrics-changed', listener: (event: Event, display: Display, changedMetrics: DisplayMetrics[]) => void): this;
  2494.         on(event: string, listener: Function): this;
  2495.         /**
  2496.          * @returns The current absolute position of the mouse pointer.
  2497.          */
  2498.         getCursorScreenPoint(): Point;
  2499.         /**
  2500.          * @returns The primary display.
  2501.          */
  2502.         getPrimaryDisplay(): Display;
  2503.         /**
  2504.          * @returns An array of displays that are currently available.
  2505.          */
  2506.         getAllDisplays(): Display[];
  2507.         /**
  2508.          * @returns The display nearest the specified point.
  2509.          */
  2510.         getDisplayNearestPoint(point: Point): Display;
  2511.         /**
  2512.          * @returns The display that most closely intersects the provided bounds.
  2513.          */
  2514.         getDisplayMatching(rect: Bounds): Display;
  2515.     }
  2516.  
  2517.     // https://github.com/electron/electron/blob/master/docs/api/session.md
  2518.  
  2519.     /**
  2520.      * The session module can be used to create new Session objects.
  2521.      * You can also access the session of existing pages by using
  2522.      * the session property of webContents which is a property of BrowserWindow.
  2523.      */
  2524.     class Session extends EventEmitter {
  2525.         /**
  2526.          * @returns a new Session instance from partition string.
  2527.          */
  2528.         static fromPartition(partition: string): Session;
  2529.         /**
  2530.          * @returns the default session object of the app.
  2531.          */
  2532.         static defaultSession: Session;
  2533.         /**
  2534.          * Emitted when Electron is about to download item in webContents.
  2535.          * Calling event.preventDefault() will cancel the download
  2536.          * and item will not be available from next tick of the process.
  2537.          */
  2538.         on(event: 'will-download', listener: (event: Event, item: DownloadItem, webContents: WebContents) => void): this;
  2539.         on(event: string, listener: Function): this;
  2540.         /**
  2541.          * The cookies gives you ability to query and modify cookies.
  2542.          */
  2543.         cookies: SessionCookies;
  2544.         /**
  2545.          * @returns the session’s current cache size.
  2546.          */
  2547.         getCacheSize(callback: (size: number) => void): void;
  2548.         /**
  2549.          * Clears the session’s HTTP cache.
  2550.          */
  2551.         clearCache(callback: Function): void;
  2552.         /**
  2553.          * Clears the data of web storages.
  2554.          */
  2555.         clearStorageData(callback: Function): void;
  2556.         /**
  2557.          * Clears the data of web storages.
  2558.          */
  2559.         clearStorageData(options: ClearStorageDataOptions, callback: Function): void;
  2560.         /**
  2561.          * Writes any unwritten DOMStorage data to disk.
  2562.          */
  2563.         flushStorageData(): void;
  2564.         /**
  2565.          * Sets the proxy settings.
  2566.          */
  2567.         setProxy(config: string, callback: Function): void;
  2568.         /**
  2569.          * Resolves the proxy information for url.
  2570.          */
  2571.         resolveProxy(url: URL, callback: (proxy: string) => void): void;
  2572.         /**
  2573.          * Sets download saving directory.
  2574.          * By default, the download directory will be the Downloads under the respective app folder.
  2575.          */
  2576.         setDownloadPath(path: string): void;
  2577.         /**
  2578.          * Emulates network with the given configuration for the session.
  2579.          */
  2580.         enableNetworkEmulation(options: NetworkEmulationOptions): void;
  2581.         /**
  2582.          * Disables any network emulation already active for the session.
  2583.          * Resets to the original network configuration.
  2584.          */
  2585.         disableNetworkEmulation(): void;
  2586.         /**
  2587.          * Sets the certificate verify proc for session, the proc will be called
  2588.          * whenever a server certificate verification is requested.
  2589.          *
  2590.          * Calling setCertificateVerifyProc(null) will revert back to default certificate verify proc.
  2591.          */
  2592.         setCertificateVerifyProc(proc: (hostname: string, cert: Certificate, callback: (accepted: boolean) => void) => void): void;
  2593.         /**
  2594.          * Sets the handler which can be used to respond to permission requests for the session.
  2595.          */
  2596.         setPermissionRequestHandler(handler: (webContents: WebContents, permission: Permission, callback: (allow: boolean) => void) => void): void;
  2597.         /**
  2598.          * Clears the host resolver cache.
  2599.          */
  2600.         clearHostResolverCache(callback: Function): void;
  2601.         /**
  2602.          * Dynamically sets whether to always send credentials for HTTP NTLM or Negotiate authentication.
  2603.          * @param domains Comma-seperated list of servers for which integrated authentication is enabled.
  2604.          */
  2605.         allowNTLMCredentialsForDomains(domains: string): void;
  2606.         /**
  2607.          * The webRequest API set allows to intercept and modify contents of a request at various stages of its lifetime.
  2608.          */
  2609.         webRequest: WebRequest;
  2610.     }
  2611.  
  2612.     type Permission = 'media' | 'geolocation' | 'notifications' | 'midiSysex' | 'pointerLock' | 'fullscreen' | 'openExternal';
  2613.  
  2614.     interface ClearStorageDataOptions {
  2615.         /**
  2616.          * Should follow window.location.origin’s representation scheme://host:port.
  2617.          */
  2618.         origin?: string;
  2619.         /**
  2620.          *  The types of storages to clear.
  2621.          */
  2622.         storages?: ('appcache' | 'cookies' | 'filesystem' | 'indexdb' | 'localstorage' | 'shadercache' | 'websql' | 'serviceworkers')[];
  2623.         /**
  2624.          * The types of quotas to clear.
  2625.          */
  2626.         quotas?: ('temporary' | 'persistent' | 'syncable')[];
  2627.     }
  2628.  
  2629.     interface NetworkEmulationOptions {
  2630.         /**
  2631.          * Whether to emulate network outage.
  2632.          */
  2633.         offline?: boolean;
  2634.         /**
  2635.          * RTT in ms.
  2636.          */
  2637.         latency?: number;
  2638.         /**
  2639.          * Download rate in Bps.
  2640.          */
  2641.         downloadThroughput?: number;
  2642.         /**
  2643.          * Upload rate in Bps.
  2644.          */
  2645.         uploadThroughput?: number;
  2646.     }
  2647.  
  2648.     interface CookieFilter {
  2649.         /**
  2650.          * Retrieves cookies which are associated with url. Empty implies retrieving cookies of all urls.
  2651.          */
  2652.         url?: string;
  2653.         /**
  2654.          * Filters cookies by name.
  2655.          */
  2656.         name?: string;
  2657.         /**
  2658.          * Retrieves cookies whose domains match or are subdomains of domains.
  2659.          */
  2660.         domain?: string;
  2661.         /**
  2662.          * Retrieves cookies whose path matches path.
  2663.          */
  2664.         path?: string;
  2665.         /**
  2666.          * Filters cookies by their Secure property.
  2667.          */
  2668.         secure?: boolean;
  2669.         /**
  2670.          * Filters out session or persistent cookies.
  2671.          */
  2672.         session?: boolean;
  2673.     }
  2674.  
  2675.     interface Cookie {
  2676.         /**
  2677.          * The name of the cookie.
  2678.          */
  2679.         name: string;
  2680.         /**
  2681.          * The value of the cookie.
  2682.          */
  2683.         value: string;
  2684.         /**
  2685.          * The domain of the cookie.
  2686.          */
  2687.         domain: string;
  2688.         /**
  2689.          * Whether the cookie is a host-only cookie.
  2690.          */
  2691.         hostOnly: string;
  2692.         /**
  2693.          * The path of the cookie.
  2694.          */
  2695.         path: string;
  2696.         /**
  2697.          * Whether the cookie is marked as secure.
  2698.          */
  2699.         secure: boolean;
  2700.         /**
  2701.          * Whether the cookie is marked as HTTP only.
  2702.          */
  2703.         httpOnly: boolean;
  2704.         /**
  2705.          * Whether the cookie is a session cookie or a persistent cookie with an expiration date.
  2706.          */
  2707.         session: boolean;
  2708.         /**
  2709.          * The expiration date of the cookie as the number of seconds since the UNIX epoch.
  2710.          * Not provided for session cookies.
  2711.          */
  2712.         expirationDate?: number;
  2713.     }
  2714.  
  2715.     interface CookieDetails {
  2716.         /**
  2717.          * The URL associated with the cookie.
  2718.          */
  2719.         url: string;
  2720.         /**
  2721.          * The name of the cookie.
  2722.          * Default: empty.
  2723.          */
  2724.         name?: string;
  2725.         /**
  2726.          * The value of the cookie.
  2727.          * Default: empty.
  2728.          */
  2729.         value?: string;
  2730.         /**
  2731.          * The domain of the cookie.
  2732.          * Default: empty.
  2733.          */
  2734.         domain?: string;
  2735.         /**
  2736.          * The path of the cookie.
  2737.          * Default: empty.
  2738.          */
  2739.         path?: string;
  2740.         /**
  2741.          * Whether the cookie should be marked as secure.
  2742.          * Default: false.
  2743.          */
  2744.         secure?: boolean;
  2745.         /**
  2746.          * Whether the cookie should be marked as HTTP only.
  2747.          * Default: false.
  2748.          */
  2749.         httpOnly?: boolean;
  2750.         /**
  2751.          * The expiration date of the cookie as the number of seconds since the UNIX epoch.
  2752.          * If omitted, the cookie becomes a session cookie.
  2753.          */
  2754.         expirationDate?: number;
  2755.     }
  2756.  
  2757.     interface SessionCookies {
  2758.         /**
  2759.          * Sends a request to get all cookies matching filter.
  2760.          */
  2761.         get(filter: CookieFilter, callback: (error: Error, cookies: Cookie[]) => void): void;
  2762.         /**
  2763.          * Sets the cookie with details.
  2764.          */
  2765.         set(details: CookieDetails, callback: (error: Error) => void): void;
  2766.         /**
  2767.          * Removes the cookies matching url and name.
  2768.          */
  2769.         remove(url: string, name: string, callback: (error: Error) => void): void;
  2770.     }
  2771.  
  2772.     /**
  2773.      * Each API accepts an optional filter and a listener, the listener will be called when the API's event has happened.
  2774.      * Passing null as listener will unsubscribe from the event.
  2775.      *
  2776.      * The filter will be used to filter out the requests that do not match the URL patterns.
  2777.      * If the filter is omitted then all requests will be matched.
  2778.      *
  2779.      * For certain events the listener is passed with a callback,
  2780.      * which should be called with an response object when listener has done its work.
  2781.      */
  2782.     interface WebRequest {
  2783.         /**
  2784.          * The listener will be called when a request is about to occur.
  2785.          */
  2786.         onBeforeRequest(listener: (details: WebRequest.BeforeRequestDetails, callback: WebRequest.BeforeRequestCallback) => void): void;
  2787.         /**
  2788.          * The listener will be called when a request is about to occur.
  2789.          */
  2790.         onBeforeRequest(filter: WebRequest.Filter, listener: (details: WebRequest.BeforeRequestDetails, callback: WebRequest.BeforeRequestCallback) => void): void;
  2791.         /**
  2792.          * The listener will be called before sending an HTTP request, once the request headers are available.
  2793.          * This may occur after a TCP connection is made to the server, but before any http data is sent.
  2794.          */
  2795.         onBeforeSendHeaders(listener: (details: WebRequest.BeforeSendHeadersDetails, callback: WebRequest.BeforeSendHeadersCallback) => void): void;
  2796.         /**
  2797.          * The listener will be called before sending an HTTP request, once the request headers are available.
  2798.          * This may occur after a TCP connection is made to the server, but before any http data is sent.
  2799.          */
  2800.         onBeforeSendHeaders(filter: WebRequest.Filter, listener: (details: WebRequest.BeforeSendHeadersDetails, callback: WebRequest.BeforeSendHeadersCallback) => void): void;
  2801.         /**
  2802.          * The listener will be called just before a request is going to be sent to the server,
  2803.          * modifications of previous onBeforeSendHeaders response are visible by the time this listener is fired.
  2804.          */
  2805.         onSendHeaders(listener: (details: WebRequest.SendHeadersDetails) => void): void;
  2806.         /**
  2807.          * The listener will be called just before a request is going to be sent to the server,
  2808.          * modifications of previous onBeforeSendHeaders response are visible by the time this listener is fired.
  2809.          */
  2810.         onSendHeaders(filter: WebRequest.Filter, listener: (details: WebRequest.SendHeadersDetails) => void): void;
  2811.         /**
  2812.          * The listener will be called when HTTP response headers of a request have been received.
  2813.          */
  2814.         onHeadersReceived(listener: (details: WebRequest.HeadersReceivedDetails, callback: WebRequest.HeadersReceivedCallback) => void): void;
  2815.         /**
  2816.          * The listener will be called when HTTP response headers of a request have been received.
  2817.          */
  2818.         onHeadersReceived(filter: WebRequest.Filter, listener: (details: WebRequest.HeadersReceivedDetails, callback: WebRequest.HeadersReceivedCallback) => void): void;
  2819.         /**
  2820.          * The listener will be called when first byte of the response body is received.
  2821.          * For HTTP requests, this means that the status line and response headers are available.
  2822.          */
  2823.         onResponseStarted(listener: (details: WebRequest.ResponseStartedDetails) => void): void;
  2824.         /**
  2825.          * The listener will be called when first byte of the response body is received.
  2826.          * For HTTP requests, this means that the status line and response headers are available.
  2827.          */
  2828.         onResponseStarted(filter: WebRequest.Filter, listener: (details: WebRequest.ResponseStartedDetails) => void): void;
  2829.         /**
  2830.          * The listener will be called when a server initiated redirect is about to occur.
  2831.          */
  2832.         onBeforeRedirect(listener: (details: WebRequest.BeforeRedirectDetails) => void): void;
  2833.         /**
  2834.          * The listener will be called when a server initiated redirect is about to occur.
  2835.          */
  2836.         onBeforeRedirect(filter: WebRequest.Filter, listener: (details: WebRequest.BeforeRedirectDetails) => void): void;
  2837.         /**
  2838.          * The listener will be called when a request is completed.
  2839.          */
  2840.         onCompleted(listener: (details: WebRequest.CompletedDetails) => void): void;
  2841.         /**
  2842.          * The listener will be called when a request is completed.
  2843.          */
  2844.         onCompleted(filter: WebRequest.Filter, listener: (details: WebRequest.CompletedDetails) => void): void;
  2845.         /**
  2846.          * The listener will be called when an error occurs.
  2847.          */
  2848.         onErrorOccurred(listener: (details: WebRequest.ErrorOccurredDetails) => void): void;
  2849.         /**
  2850.          * The listener will be called when an error occurs.
  2851.          */
  2852.         onErrorOccurred(filter: WebRequest.Filter, listener: (details: WebRequest.ErrorOccurredDetails) => void): void;
  2853.     }
  2854.  
  2855.     namespace WebRequest {
  2856.         interface Filter {
  2857.             urls: string[];
  2858.         }
  2859.  
  2860.         interface Details {
  2861.             id: number;
  2862.             url: string;
  2863.             method: string;
  2864.             resourceType: string;
  2865.             timestamp: number;
  2866.         }
  2867.  
  2868.         interface UploadData {
  2869.             /**
  2870.              * Content being sent.
  2871.              */
  2872.             bytes: Buffer;
  2873.             /**
  2874.              * Path of file being uploaded.
  2875.              */
  2876.             file: string;
  2877.         }
  2878.  
  2879.         interface BeforeRequestDetails extends Details {
  2880.             uploadData?: UploadData[];
  2881.         }
  2882.  
  2883.         type BeforeRequestCallback = (response: {
  2884.             cancel?: boolean;
  2885.             /**
  2886.              * The original request is prevented from being sent or completed, and is instead redirected to the given URL.
  2887.              */
  2888.             redirectURL?: string;
  2889.         }) => void;
  2890.  
  2891.         interface BeforeSendHeadersDetails extends Details {
  2892.             requestHeaders: Headers;
  2893.         }
  2894.  
  2895.         type BeforeSendHeadersCallback = (response: {
  2896.             cancel?: boolean;
  2897.             /**
  2898.              * When provided, request will be made with these headers.
  2899.              */
  2900.             requestHeaders?: Headers;
  2901.         }) => void;
  2902.  
  2903.         interface SendHeadersDetails extends Details {
  2904.             requestHeaders: Headers;
  2905.         }
  2906.  
  2907.         interface HeadersReceivedDetails extends Details {
  2908.             statusLine: string;
  2909.             statusCode: number;
  2910.             responseHeaders: Headers;
  2911.         }
  2912.  
  2913.         type HeadersReceivedCallback = (response: {
  2914.             cancel?: boolean;
  2915.             /**
  2916.              * When provided, the server is assumed to have responded with these headers.
  2917.              */
  2918.             responseHeaders?: Headers;
  2919.             /**
  2920.              * Should be provided when overriding responseHeaders to change header status
  2921.              * otherwise original response header's status will be used.
  2922.              */
  2923.             statusLine?: string;
  2924.         }) => void;
  2925.  
  2926.         interface ResponseStartedDetails extends Details {
  2927.             responseHeaders: Headers;
  2928.             fromCache: boolean;
  2929.             statusCode: number;
  2930.             statusLine: string;
  2931.         }
  2932.  
  2933.         interface BeforeRedirectDetails extends Details {
  2934.             redirectURL: string;
  2935.             statusCode: number;
  2936.             ip?: string;
  2937.             fromCache: boolean;
  2938.             responseHeaders: Headers;
  2939.         }
  2940.  
  2941.         interface CompletedDetails extends Details {
  2942.             responseHeaders: Headers;
  2943.             fromCache: boolean;
  2944.             statusCode: number;
  2945.             statusLine: string;
  2946.         }
  2947.  
  2948.         interface ErrorOccurredDetails extends Details {
  2949.             fromCache: boolean;
  2950.             error: string;
  2951.         }
  2952.     }
  2953.  
  2954.     // https://github.com/electron/electron/blob/master/docs/api/shell.md
  2955.  
  2956.     /**
  2957.      * The shell module provides functions related to desktop integration.
  2958.      */
  2959.     interface Shell {
  2960.         /**
  2961.          * Show the given file in a file manager. If possible, select the file.
  2962.          */
  2963.         showItemInFolder(fullPath: string): void;
  2964.         /**
  2965.          * Open the given file in the desktop's default manner.
  2966.          */
  2967.         openItem(fullPath: string): void;
  2968.         /**
  2969.          * Open the given external protocol URL in the desktop's default manner
  2970.          * (e.g., mailto: URLs in the default mail user agent).
  2971.          * @returns true if an application was available to open the URL, false otherwise.
  2972.          */
  2973.         openExternal(url: string, options?: {
  2974.             /**
  2975.              * Bring the opened application to the foreground.
  2976.              * Default: true.
  2977.              */
  2978.             activate: boolean;
  2979.         }): boolean;
  2980.         /**
  2981.          * Move the given file to trash.
  2982.          * @returns boolean status for the operation.
  2983.          */
  2984.         moveItemToTrash(fullPath: string): boolean;
  2985.         /**
  2986.          * Play the beep sound.
  2987.          */
  2988.         beep(): void;
  2989.     }
  2990.  
  2991.     // https://github.com/electron/electron/blob/master/docs/api/system-preferences.md
  2992.  
  2993.     /**
  2994.      * Get system preferences.
  2995.      */
  2996.     interface SystemPreferences {
  2997.         /**
  2998.          * @returns If the system is in Dark Mode.
  2999.          *
  3000.          * Note: This is only implemented on OS X.
  3001.          */
  3002.         isDarkMode(): boolean;
  3003.         /**
  3004.          * Subscribes to native notifications of OS X, callback will be called when the corresponding event happens.
  3005.          * The id of the subscriber is returned, which can be used to unsubscribe the event.
  3006.          *
  3007.          * Note: This is only implemented on OS X.
  3008.          */
  3009.         subscribeNotification(event: string, callback: (event: Event, userInfo: Object) => void): number;
  3010.         /**
  3011.          * Removes the subscriber with id.
  3012.          *
  3013.          * Note: This is only implemented on OS X.
  3014.          */
  3015.         unsubscribeNotification(id: number): void;
  3016.         /**
  3017.          * Get the value of key in system preferences.
  3018.          *
  3019.          * Note: This is only implemented on OS X.
  3020.          */
  3021.         getUserDefault(key: string, type: 'string' | 'boolean' | 'integer' | 'float' | 'double' | 'url'): any;
  3022.         /**
  3023.          * This method returns true if DWM composition (Aero Glass) is enabled,
  3024.          * and false otherwise. You can use it to determine if you should create
  3025.          * a transparent window or not (transparent windows won’t work correctly when DWM composition is disabled).
  3026.          *
  3027.          * Note: This is only implemented on Windows.
  3028.          */
  3029.         isAeroGlassEnabled(): boolean;
  3030.     }
  3031.  
  3032.     // https://github.com/electron/electron/blob/master/docs/api/tray.md
  3033.  
  3034.     /**
  3035.      * A Tray represents an icon in an operating system's notification area.
  3036.      */
  3037.     interface Tray extends NodeJS.EventEmitter {
  3038.         /**
  3039.          * Emitted when the tray icon is clicked.
  3040.          * Note: The bounds payload is only implemented on OS X and Windows.
  3041.          */
  3042.         on(event: 'click', listener: (modifiers: Modifiers, bounds: Bounds) => void): this;
  3043.         /**
  3044.          * Emitted when the tray icon is right clicked.
  3045.          * Note: This is only implemented on OS X and Windows.
  3046.          */
  3047.         on(event: 'right-click', listener: (modifiers: Modifiers, bounds: Bounds) => void): this;
  3048.         /**
  3049.          * Emitted when the tray icon is double clicked.
  3050.          * Note: This is only implemented on OS X and Windows.
  3051.          */
  3052.         on(event: 'double-click', listener: (modifiers: Modifiers, bounds: Bounds) => void): this;
  3053.         /**
  3054.          * Emitted when the tray balloon shows.
  3055.          * Note: This is only implemented on Windows.
  3056.          */
  3057.         on(event: 'balloon-show', listener: Function): this;
  3058.         /**
  3059.          * Emitted when the tray balloon is clicked.
  3060.          * Note: This is only implemented on Windows.
  3061.          */
  3062.         on(event: 'balloon-click', listener: Function): this;
  3063.         /**
  3064.          * Emitted when the tray balloon is closed because of timeout or user manually closes it.
  3065.          * Note: This is only implemented on Windows.
  3066.          */
  3067.         on(event: 'balloon-closed', listener: Function): this;
  3068.         /**
  3069.          * Emitted when any dragged items are dropped on the tray icon.
  3070.          * Note: This is only implemented on OS X.
  3071.          */
  3072.         on(event: 'drop', listener: Function): this;
  3073.         /**
  3074.          * Emitted when dragged files are dropped in the tray icon.
  3075.          * Note: This is only implemented on OS X
  3076.          */
  3077.         on(event: 'drop-files', listener: (event: Event, files: string[]) => void): this;
  3078.         /**
  3079.          * Emitted when a drag operation enters the tray icon.
  3080.          * Note: This is only implemented on OS X
  3081.          */
  3082.         on(event: 'drag-enter', listener: Function): this;
  3083.         /**
  3084.          * Emitted when a drag operation exits the tray icon.
  3085.          * Note: This is only implemented on OS X
  3086.          */
  3087.         on(event: 'drag-leave', listener: Function): this;
  3088.         /**
  3089.          * Emitted when a drag operation ends on the tray or ends at another location.
  3090.          * Note: This is only implemented on OS X
  3091.          */
  3092.         on(event: 'drag-end', listener: Function): this;
  3093.         on(event: string, listener: Function): this;
  3094.         /**
  3095.          * Creates a new tray icon associated with the image.
  3096.          */
  3097.         new(image: NativeImage|string): Tray;
  3098.         /**
  3099.          * Destroys the tray icon immediately.
  3100.          */
  3101.         destroy(): void;
  3102.         /**
  3103.          * Sets the image associated with this tray icon.
  3104.          */
  3105.         setImage(image: NativeImage|string): void;
  3106.         /**
  3107.          * Sets the image associated with this tray icon when pressed.
  3108.          */
  3109.         setPressedImage(image: NativeImage): void;
  3110.         /**
  3111.          * Sets the hover text for this tray icon.
  3112.          */
  3113.         setToolTip(toolTip: string): void;
  3114.         /**
  3115.          * Sets the title displayed aside of the tray icon in the status bar.
  3116.          * Note: This is only implemented on OS X.
  3117.          */
  3118.         setTitle(title: string): void;
  3119.         /**
  3120.          * Sets whether the tray icon is highlighted when it is clicked.
  3121.          * Note: This is only implemented on OS X.
  3122.          */
  3123.         setHighlightMode(highlight: boolean): void;
  3124.         /**
  3125.          * Displays a tray balloon.
  3126.          * Note: This is only implemented on Windows.
  3127.          */
  3128.         displayBalloon(options?: {
  3129.             icon?: NativeImage;
  3130.             title?: string;
  3131.             content?: string;
  3132.         }): void;
  3133.         /**
  3134.          * Popups the context menu of tray icon. When menu is passed,
  3135.          * the menu will showed instead of the tray's context menu.
  3136.          * The position is only available on Windows, and it is (0, 0) by default.
  3137.          * Note: This is only implemented on OS X and Windows.
  3138.          */
  3139.         popUpContextMenu(menu?: Menu, position?: Point): void;
  3140.         /**
  3141.          * Sets the context menu for this icon.
  3142.          */
  3143.         setContextMenu(menu: Menu): void;
  3144.     }
  3145.  
  3146.     interface Modifiers {
  3147.         altKey: boolean;
  3148.         shiftKey: boolean;
  3149.         ctrlKey: boolean;
  3150.         metaKey: boolean;
  3151.     }
  3152.  
  3153.     // https://github.com/electron/electron/blob/master/docs/api/web-contents.md
  3154.  
  3155.     /**
  3156.      * A WebContents is responsible for rendering and controlling a web page.
  3157.      */
  3158.     interface WebContents extends NodeJS.EventEmitter {
  3159.         /**
  3160.          * Emitted when the navigation is done, i.e. the spinner of the tab has stopped spinning,
  3161.          * and the onload event was dispatched.
  3162.          */
  3163.         on(event: 'did-finish-load', listener: Function): this;
  3164.         /**
  3165.          * This event is like did-finish-load but emitted when the load failed or was cancelled,
  3166.          * e.g. window.stop() is invoked.
  3167.          */
  3168.         on(event: 'did-fail-load', listener: (event: Event, errorCode: number, errorDescription: string, validatedURL: string, isMainFrame: boolean) => void): this;
  3169.         /**
  3170.          * Emitted when a frame has done navigation.
  3171.          */
  3172.         on(event: 'did-frame-finish-load', listener: (event: Event, isMainFrame: boolean) => void): this;
  3173.         /**
  3174.          * Corresponds to the points in time when the spinner of the tab started spinning.
  3175.          */
  3176.         on(event: 'did-start-loading', listener: Function): this;
  3177.         /**
  3178.          * Corresponds to the points in time when the spinner of the tab stopped spinning.
  3179.          */
  3180.         on(event: 'did-stop-loading', listener: Function): this;
  3181.         /**
  3182.          * Emitted when details regarding a requested resource are available.
  3183.          * status indicates the socket connection to download the resource.
  3184.          */
  3185.         on(event: 'did-get-response-details', listener: (event: Event,
  3186.             status: boolean,
  3187.             newURL: string,
  3188.             originalURL: string,
  3189.             httpResponseCode: number,
  3190.             requestMethod: string,
  3191.             referrer: string,
  3192.             headers: Headers,
  3193.             resourceType: string
  3194.         ) => void): this;
  3195.         /**
  3196.          * Emitted when a redirect is received while requesting a resource.
  3197.          */
  3198.         on(event: 'did-get-redirect-request', listener: (event: Event,
  3199.             oldURL: string,
  3200.             newURL: string,
  3201.             isMainFrame: boolean,
  3202.             httpResponseCode: number,
  3203.             requestMethod: string,
  3204.             referrer: string,
  3205.             headers: Headers
  3206.         ) => void): this;
  3207.         /**
  3208.          * Emitted when the document in the given frame is loaded.
  3209.          */
  3210.         on(event: 'dom-ready', listener: (event: Event) => void): this;
  3211.         /**
  3212.          * Emitted when page receives favicon URLs.
  3213.          */
  3214.         on(event: 'page-favicon-updated', listener: (event: Event, favicons: string[]) => void): this;
  3215.         /**
  3216.          * Emitted when the page requests to open a new window for a url.
  3217.          * It could be requested by window.open or an external link like <a target='_blank'>.
  3218.          *
  3219.          * By default a new BrowserWindow will be created for the url.
  3220.          *
  3221.          * Calling event.preventDefault() will prevent creating new windows.
  3222.          */
  3223.         on(event: 'new-window', listener: (event: Event,
  3224.             url: string,
  3225.             frameName: string,
  3226.             disposition: NewWindowDisposition,
  3227.             options: BrowserWindowOptions
  3228.         ) => void): this;
  3229.         /**
  3230.          * Emitted when a user or the page wants to start navigation.
  3231.          * It can happen when the window.location object is changed or a user clicks a link in the page.
  3232.          *
  3233.          * This event will not emit when the navigation is started programmatically with APIs like
  3234.          * webContents.loadURL and webContents.back.
  3235.          *
  3236.          * It is also not emitted for in-page navigations, such as clicking anchor links
  3237.          * or updating the window.location.hash. Use did-navigate-in-page event for this purpose.
  3238.          *
  3239.          * Calling event.preventDefault() will prevent the navigation.
  3240.          */
  3241.         on(event: 'will-navigate', listener: (event: Event, url: string) => void): this;
  3242.         /**
  3243.          * Emitted when a navigation is done.
  3244.          *
  3245.          * This event is not emitted for in-page navigations, such as clicking anchor links
  3246.          * or updating the window.location.hash. Use did-navigate-in-page event for this purpose.
  3247.          */
  3248.         on(event: 'did-navigate', listener: (event: Event, url: string) => void): this;
  3249.         /**
  3250.          * Emitted when an in-page navigation happened.
  3251.          *
  3252.          * When in-page navigation happens, the page URL changes but does not cause
  3253.          * navigation outside of the page. Examples of this occurring are when anchor links
  3254.          * are clicked or when the DOM hashchange event is triggered.
  3255.          */
  3256.         on(event: 'did-navigate-in-page', listener: (event: Event, url: string) => void): this;
  3257.         /**
  3258.          * Emitted when the renderer process has crashed.
  3259.          */
  3260.         on(event: 'crashed', listener: Function): this;
  3261.         /**
  3262.          * Emitted when a plugin process has crashed.
  3263.          */
  3264.         on(event: 'plugin-crashed', listener: (event: Event, name: string, version: string) => void): this;
  3265.         /**
  3266.          * Emitted when webContents is destroyed.
  3267.          */
  3268.         on(event: 'destroyed', listener: Function): this;
  3269.         /**
  3270.          * Emitted when DevTools is opened.
  3271.          */
  3272.         on(event: 'devtools-opened', listener: Function): this;
  3273.         /**
  3274.          * Emitted when DevTools is closed.
  3275.          */
  3276.         on(event: 'devtools-closed', listener: Function): this;
  3277.         /**
  3278.          * Emitted when DevTools is focused / opened.
  3279.          */
  3280.         on(event: 'devtools-focused', listener: Function): this;
  3281.         /**
  3282.          * Emitted when failed to verify the certificate for url.
  3283.          * The usage is the same with the "certificate-error" event of app.
  3284.          */
  3285.         on(event: 'certificate-error', listener: (event: Event,
  3286.             url: string,
  3287.             error: string,
  3288.             certificate: Certificate,
  3289.             callback: (trust: boolean) => void
  3290.         ) => void): this;
  3291.         /**
  3292.          * Emitted when a client certificate is requested.
  3293.          * The usage is the same with the "select-client-certificate" event of app.
  3294.          */
  3295.         on(event: 'select-client-certificate', listener: (event: Event,
  3296.             url: string,
  3297.             certificateList: Certificate[],
  3298.             callback: (certificate: Certificate) => void
  3299.         ) => void): this;
  3300.         /**
  3301.          * Emitted when webContents wants to do basic auth.
  3302.          * The usage is the same with the "login" event of app.
  3303.          */
  3304.         on(event: 'login', listener: (event: Event,
  3305.             request: LoginRequest,
  3306.             authInfo: LoginAuthInfo,
  3307.             callback: (username: string, password: string) => void
  3308.         ) => void): this;
  3309.         /**
  3310.          * Emitted when a result is available for webContents.findInPage request.
  3311.          */
  3312.         on(event: 'found-in-page', listener: (event: Event, result: FoundInPageResult) => void): this;
  3313.         /**
  3314.          * Emitted when media starts playing.
  3315.          */
  3316.         on(event: 'media-started-playing', listener: Function): this;
  3317.         /**
  3318.          * Emitted when media is paused or done playing.
  3319.          */
  3320.         on(event: 'media-paused', listener: Function): this;
  3321.         /**
  3322.          * Emitted when a page’s theme color changes. This is usually due to encountering a meta tag:
  3323.          * <meta name='theme-color' content='#ff0000'>
  3324.          */
  3325.         on(event: 'did-change-theme-color', listener: Function): this;
  3326.         /**
  3327.          * Emitted when the cursor’s type changes.
  3328.          * If the type parameter is custom, the image parameter will hold the custom cursor image
  3329.          * in a NativeImage, and the scale will hold scaling information for the image.
  3330.          */
  3331.         on(event: 'cursor-changed', listener: (event: Event, type: CursorType, image?: NativeImage, scale?: number) => void): this;
  3332.         /**
  3333.          * Emitted when there is a new context menu that needs to be handled.
  3334.          */
  3335.         on(event: 'context-menu', listener: (event: Event, params: ContextMenuParams) => void): this;
  3336.         /**
  3337.          * Emitted when bluetooth device needs to be selected on call to navigator.bluetooth.requestDevice.
  3338.          * To use navigator.bluetooth api webBluetooth should be enabled.
  3339.          * If event.preventDefault is not called, first available device will be selected.
  3340.          * callback should be called with deviceId to be selected,
  3341.          * passing empty string to callback will cancel the request.
  3342.          */
  3343.         on(event: 'select-bluetooth-device', listener: (event: Event, deviceList: BluetoothDevice[], callback: (deviceId: string) => void) => void): this;
  3344.         on(event: string, listener: Function): this;
  3345.         /**
  3346.          * Loads the url in the window.
  3347.          * @param url Must contain the protocol prefix (e.g., the http:// or file://).
  3348.          */
  3349.         loadURL(url: string, options?: LoadURLOptions): void;
  3350.         /**
  3351.          * Initiates a download of the resource at url without navigating.
  3352.          * The will-download event of session will be triggered.
  3353.          */
  3354.         downloadURL(url: string): void;
  3355.         /**
  3356.          * @returns The URL of current web page.
  3357.          */
  3358.         getURL(): string;
  3359.         /**
  3360.          * @returns The title of web page.
  3361.          */
  3362.         getTitle(): string;
  3363.         /**
  3364.          * @returns The favicon of the web page.
  3365.          */
  3366.         getFavicon(): NativeImage;
  3367.         /**
  3368.          * @returns Whether web page is still loading resources.
  3369.          */
  3370.         isLoading(): boolean;
  3371.         /**
  3372.          * @returns Whether the main frame (and not just iframes or frames within it) is still loading.
  3373.          */
  3374.         isLoadingMainFrame(): boolean;
  3375.         /**
  3376.          * @returns Whether web page is waiting for a first-response for the main
  3377.          * resource of the page.
  3378.          */
  3379.         isWaitingForResponse(): boolean;
  3380.         /**
  3381.          * Stops any pending navigation.
  3382.          */
  3383.         stop(): void;
  3384.         /**
  3385.          * Reloads current page.
  3386.          */
  3387.         reload(): void;
  3388.         /**
  3389.          * Reloads current page and ignores cache.
  3390.          */
  3391.         reloadIgnoringCache(): void;
  3392.         /**
  3393.          * @returns Whether the web page can go back.
  3394.          */
  3395.         canGoBack(): boolean;
  3396.         /**
  3397.          * @returns Whether the web page can go forward.
  3398.          */
  3399.         canGoForward(): boolean;
  3400.         /**
  3401.          * @returns Whether the web page can go to offset.
  3402.          */
  3403.         canGoToOffset(offset: number): boolean;
  3404.         /**
  3405.          * Clears the navigation history.
  3406.          */
  3407.         clearHistory(): void;
  3408.         /**
  3409.          * Makes the web page go back.
  3410.          */
  3411.         goBack(): void;
  3412.         /**
  3413.          * Makes the web page go forward.
  3414.          */
  3415.         goForward(): void;
  3416.         /**
  3417.          * Navigates to the specified absolute index.
  3418.          */
  3419.         goToIndex(index: number): void;
  3420.         /**
  3421.          * Navigates to the specified offset from the "current entry".
  3422.          */
  3423.         goToOffset(offset: number): void;
  3424.         /**
  3425.          * @returns Whether the renderer process has crashed.
  3426.          */
  3427.         isCrashed(): boolean;
  3428.         /**
  3429.          * Overrides the user agent for this page.
  3430.          */
  3431.         setUserAgent(userAgent: string): void;
  3432.         /**
  3433.          * @returns The user agent for this web page.
  3434.          */
  3435.         getUserAgent(): string;
  3436.         /**
  3437.          * Injects CSS into this page.
  3438.          */
  3439.         insertCSS(css: string): void;
  3440.         /**
  3441.          * Evaluates code in page.
  3442.          * @param code Code to evaluate.
  3443.          */
  3444.         executeJavaScript(code: string, userGesture?: boolean, callback?: (result: any) => void): void;
  3445.         /**
  3446.          * Mute the audio on the current web page.
  3447.          */
  3448.         setAudioMuted(muted: boolean): void;
  3449.         /**
  3450.          * @returns Whether this page has been muted.
  3451.          */
  3452.         isAudioMuted(): boolean;
  3453.         /**
  3454.          * Executes Edit -> Undo command in page.
  3455.          */
  3456.         undo(): void;
  3457.         /**
  3458.          * Executes Edit -> Redo command in page.
  3459.          */
  3460.         redo(): void;
  3461.         /**
  3462.          * Executes Edit -> Cut command in page.
  3463.          */
  3464.         cut(): void;
  3465.         /**
  3466.          * Executes Edit -> Copy command in page.
  3467.          */
  3468.         copy(): void;
  3469.         /**
  3470.          * Executes Edit -> Paste command in page.
  3471.          */
  3472.         paste(): void;
  3473.         /**
  3474.          * Executes Edit -> Paste and Match Style in page.
  3475.          */
  3476.         pasteAndMatchStyle(): void;
  3477.         /**
  3478.          * Executes Edit -> Delete command in page.
  3479.          */
  3480.         delete(): void;
  3481.         /**
  3482.          * Executes Edit -> Select All command in page.
  3483.          */
  3484.         selectAll(): void;
  3485.         /**
  3486.          * Executes Edit -> Unselect command in page.
  3487.          */
  3488.         unselect(): void;
  3489.         /**
  3490.          * Executes Edit -> Replace command in page.
  3491.          */
  3492.         replace(text: string): void;
  3493.         /**
  3494.          * Executes Edit -> Replace Misspelling command in page.
  3495.          */
  3496.         replaceMisspelling(text: string): void;
  3497.         /**
  3498.          * Inserts text to the focused element.
  3499.          */
  3500.         insertText(text: string): void;
  3501.         /**
  3502.          * Starts a request to find all matches for the text in the web page.
  3503.          * The result of the request can be obtained by subscribing to found-in-page event.
  3504.          * @returns The request id used for the request.
  3505.          */
  3506.         findInPage(text: string, options?: FindInPageOptions): number;
  3507.         /**
  3508.          * Stops any findInPage request for the webContents with the provided action.
  3509.          */
  3510.         stopFindInPage(action: StopFindInPageAtion): void;
  3511.         /**
  3512.          * Checks if any serviceworker is registered.
  3513.          */
  3514.         hasServiceWorker(callback: (hasServiceWorker: boolean) => void): void;
  3515.         /**
  3516.          * Unregisters any serviceworker if present.
  3517.          */
  3518.         unregisterServiceWorker(callback: (isFulfilled: boolean) => void): void;
  3519.         /**
  3520.          * Prints window's web page. When silent is set to false, Electron will pick up system's default printer and default settings for printing.
  3521.          * Calling window.print() in web page is equivalent to call WebContents.print({silent: false, printBackground: false}).
  3522.          * Note: On Windows, the print API relies on pdf.dll. If your application doesn't need print feature, you can safely remove pdf.dll in saving binary size.
  3523.          */
  3524.         print(options?: PrintOptions): void;
  3525.         /**
  3526.          * Prints windows' web page as PDF with Chromium's preview printing custom settings.
  3527.          */
  3528.         printToPDF(options: PrintToPDFOptions, callback: (error: Error, data: Buffer) => void): void;
  3529.         /**
  3530.          * Adds the specified path to DevTools workspace.
  3531.          */
  3532.         addWorkSpace(path: string): void;
  3533.         /**
  3534.          * Removes the specified path from DevTools workspace.
  3535.          */
  3536.         removeWorkSpace(path: string): void;
  3537.         /**
  3538.          * Opens the developer tools.
  3539.          */
  3540.         openDevTools(options?: {
  3541.             /**
  3542.              * Opens the devtools with specified dock state. Defaults to last used dock state.
  3543.              */
  3544.             mode?: 'right' | 'bottom' | 'undocked' | 'detach'
  3545.         }): void;
  3546.         /**
  3547.          * Closes the developer tools.
  3548.          */
  3549.         closeDevTools(): void;
  3550.         /**
  3551.          * Returns whether the developer tools are opened.
  3552.          */
  3553.         isDevToolsOpened(): boolean;
  3554.         /**
  3555.          * Returns whether the developer tools are focussed.
  3556.          */
  3557.         isDevToolsFocused(): boolean;
  3558.         /**
  3559.          * Toggle the developer tools.
  3560.          */
  3561.         toggleDevTools(): void;
  3562.         /**
  3563.          * Starts inspecting element at position (x, y).
  3564.          */
  3565.         inspectElement(x: number, y: number): void;
  3566.         /**
  3567.          * Opens the developer tools for the service worker context.
  3568.          */
  3569.         inspectServiceWorker(): void;
  3570.         /**
  3571.          * Send args.. to the web page via channel in asynchronous message, the web page
  3572.          * can handle it by listening to the channel event of ipc module.
  3573.          * Note:
  3574.          *   1. The IPC message handler in web pages do not have a event parameter,
  3575.          *      which is different from the handlers on the main process.
  3576.          *   2. There is no way to send synchronous messages from the main process
  3577.          *      to a renderer process, because it would be very easy to cause dead locks.
  3578.          */
  3579.         send(channel: string, ...args: any[]): void;
  3580.         /**
  3581.          * Enable device emulation with the given parameters.
  3582.          */
  3583.         enableDeviceEmulation(parameters: DeviceEmulationParameters): void;
  3584.         /**
  3585.          * Disable device emulation.
  3586.          */
  3587.         disableDeviceEmulation(): void;
  3588.         /**
  3589.          * Sends an input event to the page.
  3590.          */
  3591.         sendInputEvent(event: SendInputEvent): void;
  3592.         /**
  3593.          * Begin subscribing for presentation events and captured frames,
  3594.          * The callback will be called when there is a presentation event.
  3595.          */
  3596.         beginFrameSubscription(callback: (
  3597.             /**
  3598.              * The frameBuffer is a Buffer that contains raw pixel data.
  3599.              * On most machines, the pixel data is effectively stored in 32bit BGRA format,
  3600.              * but the actual representation depends on the endianness of the processor
  3601.              * (most modern processors are little-endian, on machines with big-endian
  3602.              * processors the data is in 32bit ARGB format).
  3603.              */
  3604.             frameBuffer: Buffer
  3605.         ) => void): void;
  3606.         /**
  3607.          * End subscribing for frame presentation events.
  3608.          */
  3609.         endFrameSubscription(): void;
  3610.         /**
  3611.          * @returns If the process of saving page has been initiated successfully.
  3612.          */
  3613.         savePage(fullPath: string, saveType: 'HTMLOnly' | 'HTMLComplete' | 'MHTML', callback?: (eror: Error) => void): boolean;
  3614.         /**
  3615.          * @returns The unique ID of this WebContents.
  3616.          */
  3617.         id: number;
  3618.         /**
  3619.          * @returns The session object used by this webContents.
  3620.          */
  3621.         session: Session;
  3622.         /**
  3623.          * @returns The WebContents that might own this WebContents.
  3624.          */
  3625.         hostWebContents: WebContents;
  3626.         /**
  3627.          * @returns The WebContents of DevTools for this WebContents.
  3628.          * Note: Users should never store this object because it may become null
  3629.          * when the DevTools has been closed.
  3630.          */
  3631.         devToolsWebContents: WebContents;
  3632.         /**
  3633.          * @returns Debugger API
  3634.          */
  3635.         debugger: Debugger;
  3636.     }
  3637.  
  3638.     interface ContextMenuParams {
  3639.         /**
  3640.          * x coodinate
  3641.          */
  3642.         x: number;
  3643.         /**
  3644.          * y coodinate
  3645.          */
  3646.         y: number;
  3647.         /**
  3648.          * URL of the link that encloses the node the context menu was invoked on.
  3649.          */
  3650.         linkURL: string;
  3651.         /**
  3652.          * Text associated with the link. May be an empty string if the contents of the link are an image.
  3653.          */
  3654.         linkText: string;
  3655.         /**
  3656.          * URL of the top level page that the context menu was invoked on.
  3657.          */
  3658.         pageURL: string;
  3659.         /**
  3660.          * URL of the subframe that the context menu was invoked on.
  3661.          */
  3662.         frameURL: string;
  3663.         /**
  3664.          * Source URL for the element that the context menu was invoked on.
  3665.          * Elements with source URLs are images, audio and video.
  3666.          */
  3667.         srcURL: string;
  3668.         /**
  3669.          * Type of the node the context menu was invoked on.
  3670.          */
  3671.         mediaType: 'none' | 'image' | 'audio' | 'video' | 'canvas' | 'file' | 'plugin';
  3672.         /**
  3673.          * Parameters for the media element the context menu was invoked on.
  3674.          */
  3675.         mediaFlags: {
  3676.             /**
  3677.              * Wether the media element has crashed.
  3678.              */
  3679.             inError: boolean;
  3680.             /**
  3681.              * Wether the media element is paused.
  3682.              */
  3683.             isPaused: boolean;
  3684.             /**
  3685.              * Wether the media element is muted.
  3686.              */
  3687.             isMuted: boolean;
  3688.             /**
  3689.              * Wether the media element has audio.
  3690.              */
  3691.             hasAudio: boolean;
  3692.             /**
  3693.              * Wether the media element is looping.
  3694.              */
  3695.             isLooping: boolean;
  3696.             /**
  3697.              * Wether the media element's controls are visible.
  3698.              */
  3699.             isControlsVisible: boolean;
  3700.             /**
  3701.              * Wether the media element's controls are toggleable.
  3702.              */
  3703.             canToggleControls: boolean;
  3704.             /**
  3705.              * Wether the media element can be rotated.
  3706.              */
  3707.             canRotate: boolean;
  3708.         }
  3709.         /**
  3710.          * Wether the context menu was invoked on an image which has non-empty contents.
  3711.          */
  3712.         hasImageContents: boolean;
  3713.         /**
  3714.          * Wether the context is editable.
  3715.          */
  3716.         isEditable: boolean;
  3717.         /**
  3718.          * These flags indicate wether the renderer believes it is able to perform the corresponding action.
  3719.          */
  3720.         editFlags: {
  3721.             /**
  3722.              * Wether the renderer believes it can undo.
  3723.              */
  3724.             canUndo: boolean;
  3725.             /**
  3726.              * Wether the renderer believes it can redo.
  3727.              */
  3728.             canRedo: boolean;
  3729.             /**
  3730.              * Wether the renderer believes it can cut.
  3731.              */
  3732.             canCut: boolean;
  3733.             /**
  3734.              * Wether the renderer believes it can copy
  3735.              */
  3736.             canCopy: boolean;
  3737.             /**
  3738.              * Wether the renderer believes it can paste.
  3739.              */
  3740.             canPaste: boolean;
  3741.             /**
  3742.              * Wether the renderer believes it can delete.
  3743.              */
  3744.             canDelete: boolean;
  3745.             /**
  3746.              * Wether the renderer believes it can select all.
  3747.              */
  3748.             canSelectAll: boolean;
  3749.         }
  3750.         /**
  3751.          * Text of the selection that the context menu was invoked on.
  3752.          */
  3753.         selectionText: string;
  3754.         /**
  3755.          * Title or alt text of the selection that the context was invoked on.
  3756.          */
  3757.         titleText: string;
  3758.         /**
  3759.          * The misspelled word under the cursor, if any.
  3760.          */
  3761.         misspelledWord: string;
  3762.         /**
  3763.          * The character encoding of the frame on which the menu was invoked.
  3764.          */
  3765.         frameCharset: string;
  3766.         /**
  3767.          * If the context menu was invoked on an input field, the type of that field.
  3768.          */
  3769.         inputFieldType: 'none' | 'plainText' | 'password' | 'other';
  3770.         /**
  3771.          * Input source that invoked the context menu.
  3772.          */
  3773.         menuSourceType: 'none' | 'mouse' | 'keyboard' | 'touch' | 'touchMenu';
  3774.     }
  3775.  
  3776.     interface BluetoothDevice {
  3777.         deviceName: string;
  3778.         deviceId: string;
  3779.     }
  3780.  
  3781.     interface Headers {
  3782.         [key: string]: string;
  3783.     }
  3784.  
  3785.     type NewWindowDisposition = 'default' | 'foreground-tab' | 'background-tab' | 'new-window' | 'other';
  3786.  
  3787.     /**
  3788.      * Specifies the action to take place when ending webContents.findInPage request.
  3789.      * 'clearSelection' - Clear the selection.
  3790.      * 'keepSelection' - Translate the selection into a normal selection.
  3791.      * 'activateSelection' - Focus and click the selection node.
  3792.      */
  3793.     type StopFindInPageAtion = 'clearSelection' | 'keepSelection' | 'activateSelection';
  3794.  
  3795.     type CursorType = 'default' | 'crosshair' | 'pointer' | 'text' | 'wait' | 'help' | 'e-resize' | 'n-resize' | 'ne-resize' | 'nw-resize' | 's-resize' | 'se-resize' | 'sw-resize' | 'w-resize' | 'ns-resize' | 'ew-resize' | 'nesw-resize' | 'nwse-resize' | 'col-resize' | 'row-resize' | 'm-panning' | 'e-panning' | 'n-panning' | 'ne-panning' | 'nw-panning' | 's-panning' | 'se-panning' |'sw-panning' | 'w-panning' | 'move' | 'vertical-text' | 'cell' | 'context-menu' | 'alias' | 'progress' | 'nodrop' | 'copy' | 'none' | 'not-allowed' | 'zoom-in' | 'zoom-out' | 'grab' | 'grabbing' | 'custom';
  3796.  
  3797.     interface LoadURLOptions {
  3798.         /**
  3799.          * HTTP Referrer URL.
  3800.          */
  3801.         httpReferrer?: string;
  3802.         /**
  3803.          * User agent originating the request.
  3804.          */
  3805.         userAgent?: string;
  3806.         /**
  3807.          * Extra headers separated by "\n"
  3808.          */
  3809.         extraHeaders?: string;
  3810.     }
  3811.  
  3812.     interface PrintOptions {
  3813.         /**
  3814.          * Don't ask user for print settings.
  3815.          * Defaults: false.
  3816.          */
  3817.         silent?: boolean;
  3818.         /**
  3819.          * Also prints the background color and image of the web page.
  3820.          * Defaults: false.
  3821.          */
  3822.         printBackground?: boolean;
  3823.     }
  3824.  
  3825.     interface PrintToPDFOptions {
  3826.         /**
  3827.          * Specify the type of margins to use.
  3828.          *   0 - default
  3829.          *   1 - none
  3830.          *   2 - minimum
  3831.          * Default: 0
  3832.          */
  3833.         marginsType?: number;
  3834.         /**
  3835.          * Specify page size of the generated PDF.
  3836.          * Default: A4.
  3837.          */
  3838.         pageSize?: 'A3' | 'A4' | 'A5' | 'Legal' | 'Letter' | 'Tabloid' | Dimension;
  3839.         /**
  3840.          * Whether to print CSS backgrounds.
  3841.          * Default: false.
  3842.          */
  3843.         printBackground?: boolean;
  3844.         /**
  3845.          * Whether to print selection only.
  3846.          * Default: false.
  3847.          */
  3848.         printSelectionOnly?: boolean;
  3849.         /**
  3850.          * true for landscape, false for portrait.
  3851.          * Default: false.
  3852.          */
  3853.         landscape?: boolean;
  3854.     }
  3855.  
  3856.     interface Certificate {
  3857.         /**
  3858.          * PEM encoded data
  3859.          */
  3860.         data: Buffer;
  3861.         issuerName: string;
  3862.     }
  3863.  
  3864.     interface LoginRequest {
  3865.         method: string;
  3866.         url: string;
  3867.         referrer: string;
  3868.     }
  3869.  
  3870.     interface LoginAuthInfo {
  3871.         isProxy: boolean;
  3872.         scheme: string;
  3873.         host: string;
  3874.         port: number;
  3875.         realm: string;
  3876.     }
  3877.  
  3878.     interface FindInPageOptions {
  3879.         /**
  3880.          * Whether to search forward or backward, defaults to true
  3881.          */
  3882.         forward?: boolean;
  3883.         /**
  3884.          * Whether the operation is first request or a follow up, defaults to false.
  3885.          */
  3886.         findNext?: boolean;
  3887.         /**
  3888.          * Whether search should be case-sensitive, defaults to false.
  3889.          */
  3890.         matchCase?: boolean;
  3891.         /**
  3892.          * Whether to look only at the start of words. defaults to false.
  3893.          */
  3894.         wordStart?: boolean;
  3895.         /**
  3896.          * When combined with wordStart, accepts a match in the middle of a word
  3897.          * if the match begins with an uppercase letter followed by a lowercase
  3898.          * or non-letter. Accepts several other intra-word matches, defaults to false.
  3899.          */
  3900.         medialCapitalAsWordStart?: boolean;
  3901.     }
  3902.  
  3903.     interface FoundInPageResult {
  3904.         requestId: number;
  3905.         /**
  3906.          * Indicates if more responses are to follow.
  3907.          */
  3908.         finalUpdate: boolean;
  3909.         /**
  3910.          * Position of the active match.
  3911.          */
  3912.         activeMatchOrdinal?: number;
  3913.         /**
  3914.          * Number of Matches.
  3915.          */
  3916.         matches?: number;
  3917.         /**
  3918.          * Coordinates of first match region.
  3919.          */
  3920.         selectionArea?: Bounds;
  3921.     }
  3922.  
  3923.     interface DeviceEmulationParameters {
  3924.         /**
  3925.          * Specify the screen type to emulated
  3926.          * Default: desktop
  3927.          */
  3928.         screenPosition?: 'desktop' | 'mobile';
  3929.         /**
  3930.          * Set the emulated screen size (screenPosition == mobile)
  3931.          */
  3932.         screenSize?: Dimension;
  3933.         /**
  3934.          * Position the view on the screen (screenPosition == mobile)
  3935.          * Default: {x: 0, y: 0}
  3936.          */
  3937.         viewPosition?: Point;
  3938.         /**
  3939.          * Set the device scale factor (if zero defaults to original device scale factor)
  3940.          * Default: 0
  3941.          */
  3942.         deviceScaleFactor: number;
  3943.         /**
  3944.          * Set the emulated view size (empty means no override).
  3945.          */
  3946.         viewSize?: Dimension;
  3947.         /**
  3948.          * Whether emulated view should be scaled down if necessary to fit into available space
  3949.          * Default: false
  3950.          */
  3951.         fitToView?: boolean;
  3952.         /**
  3953.          * Offset of the emulated view inside available space (not in fit to view mode)
  3954.          * Default: {x: 0, y: 0}
  3955.          */
  3956.         offset?: Point;
  3957.         /**
  3958.          * Scale of emulated view inside available space (not in fit to view mode)
  3959.          * Default: 1
  3960.          */
  3961.         scale: number;
  3962.     }
  3963.  
  3964.     interface SendInputEvent {
  3965.         type: 'mouseDown' | 'mouseUp' | 'mouseEnter' | 'mouseLeave' | 'contextMenu' | 'mouseWheel' | 'mouseMove' | 'keyDown' | 'keyUp' | 'char';
  3966.         modifiers: ('shift' | 'control' | 'alt' | 'meta' | 'isKeypad' | 'isAutoRepeat' | 'leftButtonDown' | 'middleButtonDown' | 'rightButtonDown' | 'capsLock' | 'numLock' | 'left' | 'right')[];
  3967.     }
  3968.  
  3969.     interface SendInputKeyboardEvent extends SendInputEvent {
  3970.         keyCode: string;
  3971.     }
  3972.  
  3973.     interface SendInputMouseEvent extends SendInputEvent {
  3974.         x: number;
  3975.         y: number;
  3976.         button?: 'left' | 'middle' | 'right';
  3977.         globalX?: number;
  3978.         globalY?: number;
  3979.         movementX?: number;
  3980.         movementY?: number;
  3981.         clickCount?: number;
  3982.     }
  3983.  
  3984.     interface SendInputMouseWheelEvent extends SendInputEvent {
  3985.         deltaX?: number;
  3986.         deltaY?: number;
  3987.         wheelTicksX?: number;
  3988.         wheelTicksY?: number;
  3989.         accelerationRatioX?: number;
  3990.         accelerationRatioY?: number;
  3991.         hasPreciseScrollingDeltas?: number;
  3992.         canScroll?: boolean;
  3993.     }
  3994.  
  3995.     /**
  3996.      * Debugger API serves as an alternate transport for remote debugging protocol.
  3997.      */
  3998.     interface Debugger extends NodeJS.EventEmitter {
  3999.         /**
  4000.          * Attaches the debugger to the webContents.
  4001.          * @param protocolVersion Requested debugging protocol version.
  4002.          */
  4003.         attach(protocolVersion?: string): void;
  4004.         /**
  4005.          * @returns Whether a debugger is attached to the webContents.
  4006.          */
  4007.         isAttached(): boolean;
  4008.         /**
  4009.          * Detaches the debugger from the webContents.
  4010.          */
  4011.         detach(): void;
  4012.         /**
  4013.          * Send given command to the debugging target.
  4014.          * @param method Method name, should be one of the methods defined by the remote debugging protocol.
  4015.          * @param commandParams JSON object with request parameters.
  4016.          * @param callback Response defined by the ‘returns’ attribute of the command description in the remote debugging protocol.
  4017.          */
  4018.         sendCommand(method: string, commandParams?: any, callback?: (error: Error, result: any) => void): void;
  4019.         /**
  4020.          * Emitted when debugging session is terminated. This happens either when
  4021.          * webContents is closed or devtools is invoked for the attached webContents.
  4022.          */
  4023.         on(event: 'detach', listener: (event: Event, reason: string) => void): this;
  4024.         /**
  4025.          * Emitted whenever debugging target issues instrumentation event.
  4026.          * Event parameters defined by the ‘parameters’ attribute in the remote debugging protocol.
  4027.          */
  4028.         on(event: 'message', listener: (event: Event, method: string, params: any) => void): this;
  4029.         on(event: string, listener: Function): this;
  4030.     }
  4031.  
  4032.     // https://github.com/electron/electron/blob/master/docs/api/web-frame.md
  4033.  
  4034.     /**
  4035.      * The web-frame module allows you to customize the rendering of the current web page.
  4036.      */
  4037.     interface WebFrame {
  4038.         /**
  4039.          * Changes the zoom factor to the specified factor, zoom factor is
  4040.          * zoom percent / 100, so 300% = 3.0.
  4041.          */
  4042.         setZoomFactor(factor: number): void;
  4043.         /**
  4044.          * @returns The current zoom factor.
  4045.          */
  4046.         getZoomFactor(): number;
  4047.         /**
  4048.          * Changes the zoom level to the specified level, 0 is "original size", and each
  4049.          * increment above or below represents zooming 20% larger or smaller to default
  4050.          * limits of 300% and 50% of original size, respectively.
  4051.          */
  4052.         setZoomLevel(level: number): void;
  4053.         /**
  4054.          * @returns The current zoom level.
  4055.          */
  4056.         getZoomLevel(): number;
  4057.         /**
  4058.          * Sets the maximum and minimum zoom level.
  4059.          */
  4060.         setZoomLevelLimits(minimumLevel: number, maximumLevel: number): void;
  4061.         /**
  4062.          * Sets a provider for spell checking in input fields and text areas.
  4063.          */
  4064.         setSpellCheckProvider(language: string, autoCorrectWord: boolean, provider: {
  4065.             /**
  4066.              * @returns Whether the word passed is correctly spelled.
  4067.              */
  4068.             spellCheck: (text: string) => boolean;
  4069.         }): void;
  4070.         /**
  4071.          * Sets the scheme as secure scheme. Secure schemes do not trigger mixed content
  4072.          * warnings. For example, https and data are secure schemes because they cannot be
  4073.          * corrupted by active network attackers.
  4074.          */
  4075.         registerURLSchemeAsSecure(scheme: string): void;
  4076.         /**
  4077.          * Resources will be loaded from this scheme regardless of the current page’s Content Security Policy.
  4078.          */
  4079.         registerURLSchemeAsBypassingCSP(scheme: string): void;
  4080.         /**
  4081.          * Registers the scheme as secure, bypasses content security policy for resources,
  4082.          * allows registering ServiceWorker and supports fetch API.
  4083.          */
  4084.         registerURLSchemeAsPrivileged(scheme: string): void;
  4085.         /**
  4086.          * Inserts text to the focused element.
  4087.          */
  4088.         insertText(text: string): void;
  4089.         /**
  4090.          * Evaluates `code` in page.
  4091.          * In the browser window some HTML APIs like `requestFullScreen` can only be
  4092.          * invoked by a gesture from the user. Setting `userGesture` to `true` will remove
  4093.          * this limitation.
  4094.          */
  4095.         executeJavaScript(code: string, userGesture?: boolean, callback?: (result: any) => void): void;
  4096.         /**
  4097.          * @returns Object describing usage information of Blink’s internal memory caches.
  4098.          */
  4099.         getResourceUsage(): ResourceUsages;
  4100.         /**
  4101.          * Attempts to free memory that is no longer being used (like images from a previous navigation).
  4102.          */
  4103.         clearCache(): void;
  4104.     }
  4105.  
  4106.     interface ResourceUsages {
  4107.         fonts: ResourceUsage;
  4108.         images: ResourceUsage;
  4109.         cssStyleSheets: ResourceUsage;
  4110.         xslStyleSheets: ResourceUsage;
  4111.         scripts: ResourceUsage;
  4112.         other: ResourceUsage;
  4113.     }
  4114.  
  4115.     interface ResourceUsage {
  4116.         count: number;
  4117.         decodedSize: number;
  4118.         liveSize: number;
  4119.         purgeableSize: number;
  4120.         purgedSize: number;
  4121.         size: number;
  4122.     }
  4123.  
  4124.     // https://github.com/electron/electron/blob/master/docs/api/web-view-tag.md
  4125.  
  4126.     /**
  4127.      * Use the webview tag to embed 'guest' content (such as web pages) in your Electron app.
  4128.      * The guest content is contained within the webview container.
  4129.      * An embedded page within your app controls how the guest content is laid out and rendered.
  4130.      *
  4131.      * Unlike an iframe, the webview runs in a separate process than your app.
  4132.      * It doesn't have the same permissions as your web page and all interactions between your app
  4133.      * and embedded content will be asynchronous. This keeps your app safe from the embedded content.
  4134.      */
  4135.     interface WebViewElement extends HTMLElement {
  4136.         /**
  4137.          * Returns the visible URL. Writing to this attribute initiates top-level navigation.
  4138.          * Assigning src its own value will reload the current page.
  4139.          * The src attribute can also accept data URLs, such as data:text/plain,Hello, world!.
  4140.          */
  4141.         src: string;
  4142.         /**
  4143.          * If "on", the webview container will automatically resize within the bounds specified
  4144.          * by the attributes minwidth, minheight, maxwidth, and maxheight.
  4145.          * These constraints do not impact the webview unless autosize is enabled.
  4146.          * When autosize is enabled, the webview container size cannot be less than
  4147.          * the minimum values or greater than the maximum.
  4148.          */
  4149.         autosize: string;
  4150.         /**
  4151.          * If "on", the guest page in webview will have node integration and can use node APIs
  4152.          * like require and process to access low level system resources.
  4153.          */
  4154.         nodeintegration: string;
  4155.         /**
  4156.          * If "on", the guest page in webview will be able to use browser plugins.
  4157.          */
  4158.         plugins: string;
  4159.         /**
  4160.          * Specifies a script that will be loaded before other scripts run in the guest page.
  4161.          * The protocol of script's URL must be either file: or asar:,
  4162.          * because it will be loaded by require in guest page under the hood.
  4163.          *
  4164.          * When the guest page doesn't have node integration this script will still have access to all Node APIs,
  4165.          * but global objects injected by Node will be deleted after this script has finished executing.
  4166.          */
  4167.         preload: string;
  4168.         /**
  4169.          * Sets the referrer URL for the guest page.
  4170.          */
  4171.         httpreferrer: string;
  4172.         /**
  4173.          * Sets the user agent for the guest page before the page is navigated to.
  4174.          * Once the page is loaded, use the setUserAgent method to change the user agent.
  4175.          */
  4176.         useragent: string;
  4177.         /**
  4178.          * If "on", the guest page will have web security disabled.
  4179.          */
  4180.         disablewebsecurity: string;
  4181.         /**
  4182.          * Sets the session used by the page. If partition starts with persist:,
  4183.          * the page will use a persistent session available to all pages in the app with the same partition.
  4184.          * If there is no persist: prefix, the page will use an in-memory session.
  4185.          * By assigning the same partition, multiple pages can share the same session.
  4186.          * If the partition is unset then default session of the app will be used.
  4187.          *
  4188.          * This value can only be modified before the first navigation,
  4189.          * since the session of an active renderer process cannot change.
  4190.          * Subsequent attempts to modify the value will fail with a DOM exception.
  4191.          */
  4192.         partition: string;
  4193.         /**
  4194.          * If "on", the guest page will be allowed to open new windows.
  4195.          */
  4196.         allowpopups: string;
  4197.         /**
  4198.          * A list of strings which specifies the blink features to be enabled separated by ,.
  4199.          */
  4200.         blinkfeatures: string;
  4201.         /**
  4202.          * Loads the url in the webview, the url must contain the protocol prefix, e.g. the http:// or file://.
  4203.          */
  4204.         loadURL(url: string, options?: LoadURLOptions): void;
  4205.         /**
  4206.          * @returns URL of guest page.
  4207.          */
  4208.         getURL(): string;
  4209.         /**
  4210.          * @returns The title of guest page.
  4211.          */
  4212.         getTitle(): string;
  4213.         /**
  4214.          * @returns Whether guest page is still loading resources.
  4215.          */
  4216.         isLoading(): boolean;
  4217.         /**
  4218.          * Returns a boolean whether the guest page is waiting for a first-response for the main resource of the page.
  4219.          */
  4220.         isWaitingForResponse(): boolean;
  4221.         /**
  4222.          * Stops any pending navigation.
  4223.          */
  4224.         stop(): void;
  4225.         /**
  4226.          * Reloads the guest page.
  4227.          */
  4228.         reload(): void;
  4229.         /**
  4230.          * Reloads the guest page and ignores cache.
  4231.          */
  4232.         reloadIgnoringCache(): void;
  4233.         /**
  4234.          * @returns Whether the guest page can go back.
  4235.          */
  4236.         canGoBack(): boolean;
  4237.         /**
  4238.          * @returns Whether the guest page can go forward.
  4239.          */
  4240.         canGoForward(): boolean;
  4241.         /**
  4242.          * @returns Whether the guest page can go to offset.
  4243.          */
  4244.         canGoToOffset(offset: number): boolean;
  4245.         /**
  4246.          * Clears the navigation history.
  4247.          */
  4248.         clearHistory(): void;
  4249.         /**
  4250.          * Makes the guest page go back.
  4251.          */
  4252.         goBack(): void;
  4253.         /**
  4254.          * Makes the guest page go forward.
  4255.          */
  4256.         goForward(): void;
  4257.         /**
  4258.          * Navigates to the specified absolute index.
  4259.          */
  4260.         goToIndex(index: number): void;
  4261.         /**
  4262.          * Navigates to the specified offset from the "current entry".
  4263.          */
  4264.         goToOffset(offset: boolean): void;
  4265.         /**
  4266.          * @returns Whether the renderer process has crashed.
  4267.          */
  4268.         isCrashed(): boolean;
  4269.         /**
  4270.          * Overrides the user agent for the guest page.
  4271.          */
  4272.         setUserAgent(userAgent: string): void;
  4273.         /**
  4274.          * @returns The user agent for guest page.
  4275.          */
  4276.         getUserAgent(): string;
  4277.         /**
  4278.          * Injects CSS into the guest page.
  4279.          */
  4280.         insertCSS(css: string): void;
  4281.         /**
  4282.          * Evaluates code in page. If userGesture is set, it will create the user gesture context in the page.
  4283.          * HTML APIs like requestFullScreen, which require user action, can take advantage of this option for automation.
  4284.          */
  4285.         executeJavaScript(code: string, userGesture?: boolean, callback?: (result: any) => void): void;
  4286.         /**
  4287.          * Opens a DevTools window for guest page.
  4288.          */
  4289.         openDevTools(): void;
  4290.         /**
  4291.          * Closes the DevTools window of guest page.
  4292.          */
  4293.         closeDevTools(): void;
  4294.         /**
  4295.          * @returns Whether guest page has a DevTools window attached.
  4296.          */
  4297.         isDevToolsOpened(): boolean;
  4298.         /**
  4299.          * @returns Whether DevTools window of guest page is focused.
  4300.          */
  4301.         isDevToolsFocused(): boolean;
  4302.         /**
  4303.          * Starts inspecting element at position (x, y) of guest page.
  4304.          */
  4305.         inspectElement(x: number, y: number): void;
  4306.         /**
  4307.          * Opens the DevTools for the service worker context present in the guest page.
  4308.          */
  4309.         inspectServiceWorker(): void;
  4310.         /**
  4311.          * Set guest page muted.
  4312.          */
  4313.         setAudioMuted(muted: boolean): void;
  4314.         /**
  4315.          * @returns Whether guest page has been muted.
  4316.          */
  4317.         isAudioMuted(): boolean;
  4318.         /**
  4319.          * Executes editing command undo in page.
  4320.          */
  4321.         undo(): void;
  4322.         /**
  4323.          * Executes editing command redo in page.
  4324.          */
  4325.         redo(): void;
  4326.         /**
  4327.          * Executes editing command cut in page.
  4328.          */
  4329.         cut(): void;
  4330.         /**
  4331.          * Executes editing command copy in page.
  4332.          */
  4333.         copy(): void;
  4334.         /**
  4335.          * Executes editing command paste in page.
  4336.          */
  4337.         paste(): void;
  4338.         /**
  4339.          * Executes editing command pasteAndMatchStyle in page.
  4340.          */
  4341.         pasteAndMatchStyle(): void;
  4342.         /**
  4343.          * Executes editing command delete in page.
  4344.          */
  4345.         delete(): void;
  4346.         /**
  4347.          * Executes editing command selectAll in page.
  4348.          */
  4349.         selectAll(): void;
  4350.         /**
  4351.          * Executes editing command unselect in page.
  4352.          */
  4353.         unselect(): void;
  4354.         /**
  4355.          * Executes editing command replace in page.
  4356.          */
  4357.         replace(text: string): void;
  4358.         /**
  4359.          * Executes editing command replaceMisspelling in page.
  4360.          */
  4361.         replaceMisspelling(text: string): void;
  4362.         /**
  4363.          * Inserts text to the focused element.
  4364.          */
  4365.         insertText(text: string): void;
  4366.         /**
  4367.          * Starts a request to find all matches for the text in the web page.
  4368.          * The result of the request can be obtained by subscribing to found-in-page event.
  4369.          * @returns The request id used for the request.
  4370.          */
  4371.         findInPage(text: string, options?: FindInPageOptions): number;
  4372.         /**
  4373.          * Stops any findInPage request for the webview with the provided action.
  4374.          */
  4375.         stopFindInPage(action: StopFindInPageAtion): void;
  4376.         /**
  4377.          * Prints webview's web page. Same with webContents.print([options]).
  4378.          */
  4379.         print(options?: PrintOptions): void;
  4380.         /**
  4381.          * Prints webview's web page as PDF, Same with webContents.printToPDF(options, callback)
  4382.          */
  4383.         printToPDF(options: PrintToPDFOptions, callback: (error: Error, data: Buffer) => void): void;
  4384.         /**
  4385.          * Send an asynchronous message to renderer process via channel, you can also send arbitrary arguments.
  4386.          * The renderer process can handle the message by listening to the channel event with the ipcRenderer module.
  4387.          * See webContents.send for examples.
  4388.          */
  4389.         send(channel: string, ...args: any[]): void;
  4390.         /**
  4391.          * Sends an input event to the page.
  4392.          * See webContents.sendInputEvent for detailed description of event object.
  4393.          */
  4394.         sendInputEvent(event: SendInputEvent): void
  4395.         /**
  4396.          * @returns The WebContents associated with this webview.
  4397.          */
  4398.         getWebContents(): WebContents;
  4399.         /**
  4400.          * Fired when a load has committed. This includes navigation within the current document
  4401.          * as well as subframe document-level loads, but does not include asynchronous resource loads.
  4402.          */
  4403.         addEventListener(type: 'load-commit', listener: (event: WebViewElement.LoadCommitEvent) => void, useCapture?: boolean): void;
  4404.         /**
  4405.          * Fired when the navigation is done, i.e. the spinner of the tab will stop spinning, and the onload event is dispatched.
  4406.          */
  4407.         addEventListener(type: 'did-finish-load', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void;
  4408.         /**
  4409.          * This event is like did-finish-load, but fired when the load failed or was cancelled, e.g. window.stop() is invoked.
  4410.          */
  4411.         addEventListener(type: 'did-fail-load', listener: (event: WebViewElement.DidFailLoadEvent) => void, useCapture?: boolean): void;
  4412.         /**
  4413.          * Fired when a frame has done navigation.
  4414.          */
  4415.         addEventListener(type: 'did-frame-finish-load', listener: (event: WebViewElement.DidFrameFinishLoadEvent) => void, useCapture?: boolean): void;
  4416.         /**
  4417.          * Corresponds to the points in time when the spinner of the tab starts spinning.
  4418.          */
  4419.         addEventListener(type: 'did-start-loading', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void;
  4420.         /**
  4421.          * Corresponds to the points in time when the spinner of the tab stops spinning.
  4422.          */
  4423.         addEventListener(type: 'did-stop-loading', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void;
  4424.         /**
  4425.          * Fired when details regarding a requested resource is available.
  4426.          * status indicates socket connection to download the resource.
  4427.          */
  4428.         addEventListener(type: 'did-get-response-details', listener: (event: WebViewElement.DidGetResponseDetails) => void, useCapture?: boolean): void;
  4429.         /**
  4430.          * Fired when a redirect was received while requesting a resource.
  4431.          */
  4432.         addEventListener(type: 'did-get-redirect-request', listener: (event: WebViewElement.DidGetRedirectRequestEvent) => void, useCapture?: boolean): void;
  4433.         /**
  4434.          * Fired when document in the given frame is loaded.
  4435.          */
  4436.         addEventListener(type: 'dom-ready', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void;
  4437.         /**
  4438.          * Fired when page title is set during navigation. explicitSet is false when title is synthesized from file URL.
  4439.          */
  4440.         addEventListener(type: 'page-title-updated', listener: (event: WebViewElement.PageTitleUpdatedEvent) => void, useCapture?: boolean): void;
  4441.         /**
  4442.          * Fired when page receives favicon URLs.
  4443.          */
  4444.         addEventListener(type: 'page-favicon-updated', listener: (event: WebViewElement.PageFaviconUpdatedEvent) => void, useCapture?: boolean): void;
  4445.         /**
  4446.          * Fired when page enters fullscreen triggered by HTML API.
  4447.          */
  4448.         addEventListener(type: 'enter-html-full-screen', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void;
  4449.         /**
  4450.          * Fired when page leaves fullscreen triggered by HTML API.
  4451.          */
  4452.         addEventListener(type: 'leave-html-full-screen', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void;
  4453.         /**
  4454.          * Fired when the guest window logs a console message.
  4455.          */
  4456.         addEventListener(type: 'console-message', listener: (event: WebViewElement.ConsoleMessageEvent) => void, useCapture?: boolean): void;
  4457.         /**
  4458.          * Fired when a result is available for webview.findInPage request.
  4459.          */
  4460.         addEventListener(type: 'found-in-page', listener: (event: WebViewElement.FoundInPageEvent) => void, useCapture?: boolean): void;
  4461.         /**
  4462.          * Fired when the guest page attempts to open a new browser window.
  4463.          */
  4464.         addEventListener(type: 'new-window', listener: (event: WebViewElement.NewWindowEvent) => void, useCapture?: boolean): void;
  4465.         /**
  4466.          * Emitted when a user or the page wants to start navigation.
  4467.          * It can happen when the window.location object is changed or a user clicks a link in the page.
  4468.          *
  4469.          * This event will not emit when the navigation is started programmatically with APIs
  4470.          * like <webview>.loadURL and <webview>.back.
  4471.          *
  4472.          * It is also not emitted during in-page navigation, such as clicking anchor links
  4473.          * or updating the window.location.hash. Use did-navigate-in-page event for this purpose.
  4474.          *
  4475.          * Calling event.preventDefault() does NOT have any effect.
  4476.          */
  4477.         addEventListener(type: 'will-navigate', listener: (event: WebViewElement.NavigateEvent) => void, useCapture?: boolean): void;
  4478.         /**
  4479.          * Emitted when a navigation is done.
  4480.          *
  4481.          * This event is not emitted for in-page navigations, such as clicking anchor links
  4482.          * or updating the window.location.hash. Use did-navigate-in-page event for this purpose.
  4483.          */
  4484.         addEventListener(type: 'did-navigate', listener: (event: WebViewElement.NavigateEvent) => void, useCapture?: boolean): void;
  4485.         /**
  4486.          * Emitted when an in-page navigation happened.
  4487.          *
  4488.          * When in-page navigation happens, the page URL changes but does not cause
  4489.          * navigation outside of the page. Examples of this occurring are when anchor links
  4490.          * are clicked or when the DOM hashchange event is triggered.
  4491.          */
  4492.         addEventListener(type: 'did-navigate-in-page', listener: (event: WebViewElement.NavigateEvent) => void, useCapture?: boolean): void;
  4493.         /**
  4494.          * Fired when the guest page attempts to close itself.
  4495.          */
  4496.         addEventListener(type: 'close', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void;
  4497.         /**
  4498.          * Fired when the guest page has sent an asynchronous message to embedder page.
  4499.          */
  4500.         addEventListener(type: 'ipc-message', listener: (event: WebViewElement.IpcMessageEvent) => void, useCapture?: boolean): void;
  4501.         /**
  4502.          * Fired when the renderer process is crashed.
  4503.          */
  4504.         addEventListener(type: 'crashed', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void;
  4505.         /**
  4506.          * Fired when the gpu process is crashed.
  4507.          */
  4508.         addEventListener(type: 'gpu-crashed', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void;
  4509.         /**
  4510.          * Fired when a plugin process is crashed.
  4511.          */
  4512.         addEventListener(type: 'plugin-crashed', listener: (event: WebViewElement.PluginCrashedEvent) => void, useCapture?: boolean): void;
  4513.         /**
  4514.          * Fired when the WebContents is destroyed.
  4515.          */
  4516.         addEventListener(type: 'destroyed', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void;
  4517.         /**
  4518.          * Emitted when media starts playing.
  4519.          */
  4520.         addEventListener(type: 'media-started-playing', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void;
  4521.         /**
  4522.          * Emitted when media is paused or done playing.
  4523.          */
  4524.         addEventListener(type: 'media-paused', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void;
  4525.         /**
  4526.          * Emitted when a page's theme color changes. This is usually due to encountering a meta tag:
  4527.          * <meta name='theme-color' content='#ff0000'>
  4528.          */
  4529.         addEventListener(type: 'did-change-theme-color', listener: (event: WebViewElement.DidChangeThemeColorEvent) => void, useCapture?: boolean): void;
  4530.         /**
  4531.          * Emitted when DevTools is opened.
  4532.          */
  4533.         addEventListener(type: 'devtools-opened', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void;
  4534.         /**
  4535.          * Emitted when DevTools is closed.
  4536.          */
  4537.         addEventListener(type: 'devtools-closed', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void;
  4538.         /**
  4539.          * Emitted when DevTools is focused / opened.
  4540.          */
  4541.         addEventListener(type: 'devtools-focused', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void;
  4542.         addEventListener(type: string, listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void;
  4543.     }
  4544.  
  4545.     namespace WebViewElement {
  4546.         type Event = ElectronPrivate.GlobalEvent;
  4547.  
  4548.         interface LoadCommitEvent extends Event  {
  4549.             url: string;
  4550.             isMainFrame: boolean;
  4551.         }
  4552.  
  4553.         interface DidFailLoadEvent extends Event  {
  4554.             errorCode: number;
  4555.             errorDescription: string;
  4556.             validatedURL: string;
  4557.             isMainFrame: boolean;
  4558.         }
  4559.  
  4560.         interface DidFrameFinishLoadEvent extends Event  {
  4561.             isMainFrame: boolean;
  4562.         }
  4563.  
  4564.         interface DidGetResponseDetails extends Event  {
  4565.             status: boolean;
  4566.             newURL: string;
  4567.             originalURL: string;
  4568.             httpResponseCode: number;
  4569.             requestMethod: string;
  4570.             referrer: string;
  4571.             headers: Headers;
  4572.             resourceType: string;
  4573.         }
  4574.  
  4575.         interface DidGetRedirectRequestEvent extends Event {
  4576.             oldURL: string;
  4577.             newURL: string;
  4578.             isMainFrame: boolean;
  4579.             httpResponseCode: number;
  4580.             requestMethod: string;
  4581.             referrer: string;
  4582.             headers: Headers;
  4583.         }
  4584.  
  4585.         interface PageTitleUpdatedEvent extends Event {
  4586.             title: string;
  4587.             explicitSet: string;
  4588.         }
  4589.  
  4590.         interface PageFaviconUpdatedEvent extends Event {
  4591.             favicons: string[];
  4592.         }
  4593.  
  4594.         interface ConsoleMessageEvent extends Event {
  4595.             level: number;
  4596.             message: string;
  4597.             line: number;
  4598.             sourceId: string;
  4599.         }
  4600.  
  4601.         interface FoundInPageEvent extends Event {
  4602.             result: FoundInPageResult;
  4603.         }
  4604.  
  4605.         interface NewWindowEvent extends Event {
  4606.             url: string;
  4607.             frameName: string;
  4608.             disposition: NewWindowDisposition;
  4609.             options: BrowserWindowOptions;
  4610.         }
  4611.  
  4612.         interface NavigateEvent extends Event {
  4613.             url: string;
  4614.         }
  4615.  
  4616.         interface IpcMessageEvent extends Event {
  4617.             channel: string;
  4618.             args: any[];
  4619.         }
  4620.  
  4621.         interface PluginCrashedEvent extends Event {
  4622.             name: string;
  4623.             version: string;
  4624.         }
  4625.  
  4626.         interface DidChangeThemeColorEvent extends Event {
  4627.             themeColor: string;
  4628.         }
  4629.     }
  4630.  
  4631.     /**
  4632.      * The BrowserWindowProxy object is returned from window.open and provides limited functionality with the child window.
  4633.      */
  4634.     interface BrowserWindowProxy {
  4635.         /**
  4636.          * Removes focus from the child window.
  4637.          */
  4638.         blur(): void;
  4639.         /**
  4640.          * Forcefully closes the child window without calling its unload event.
  4641.          */
  4642.         close(): void;
  4643.         /**
  4644.          * Set to true after the child window gets closed.
  4645.          */
  4646.         closed: boolean;
  4647.         /**
  4648.          * Evaluates the code in the child window.
  4649.          */
  4650.         eval(code: string): void;
  4651.         /**
  4652.          * Focuses the child window (brings the window to front).
  4653.          */
  4654.         focus(): void;
  4655.         /**
  4656.          * Sends a message to the child window with the specified origin or * for no origin preference.
  4657.          * In addition to these methods, the child window implements window.opener object with no
  4658.          * properties and a single method.
  4659.          */
  4660.         postMessage(message: string, targetOrigin: string): void;
  4661.         /**
  4662.          * Invokes the print dialog on the child window.
  4663.          */
  4664.         print(): void;
  4665.     }
  4666.  
  4667.     // https://github.com/electron/electron/blob/master/docs/api/synopsis.md
  4668.  
  4669.     interface CommonElectron {
  4670.         clipboard: Electron.Clipboard;
  4671.         crashReporter: Electron.CrashReporter;
  4672.         nativeImage: typeof Electron.NativeImage;
  4673.         shell: Electron.Shell;
  4674.  
  4675.         app: Electron.App;
  4676.         autoUpdater: Electron.AutoUpdater;
  4677.         BrowserWindow: typeof Electron.BrowserWindow;
  4678.         contentTracing: Electron.ContentTracing;
  4679.         dialog: Electron.Dialog;
  4680.         ipcMain: Electron.IpcMain;
  4681.         globalShortcut: Electron.GlobalShortcut;
  4682.         Menu: typeof Electron.Menu;
  4683.         MenuItem: typeof Electron.MenuItem;
  4684.         powerMonitor: Electron.PowerMonitor;
  4685.         powerSaveBlocker: Electron.PowerSaveBlocker;
  4686.         protocol: Electron.Protocol;
  4687.         screen: Electron.Screen;
  4688.         session: typeof Electron.Session;
  4689.         systemPreferences: Electron.SystemPreferences;
  4690.         Tray: Electron.Tray;
  4691.         hideInternalModules(): void;
  4692.     }
  4693.  
  4694.     interface ElectronMainAndRenderer extends CommonElectron {
  4695.         desktopCapturer: Electron.DesktopCapturer;
  4696.         ipcRenderer: Electron.IpcRenderer;
  4697.         remote: Electron.Remote;
  4698.         webFrame: Electron.WebFrame;
  4699.     }
  4700. }
  4701.  
  4702. declare namespace ElectronPrivate {
  4703.     type GlobalEvent = Event;
  4704. }
  4705.  
  4706. interface Document {
  4707.     createElement(tagName: 'webview'): Electron.WebViewElement;
  4708. }
  4709.  
  4710. // https://github.com/electron/electron/blob/master/docs/api/window-open.md
  4711.  
  4712. interface Window {
  4713.     /**
  4714.      * Creates a new window.
  4715.      */
  4716.     open(url: string, frameName?: string, features?: string): Electron.BrowserWindowProxy;
  4717. }
  4718.  
  4719. // https://github.com/electron/electron/blob/master/docs/api/file-object.md
  4720.  
  4721. interface File {
  4722.     /**
  4723.      * Exposes the real path of the filesystem.
  4724.      */
  4725.     path: string;
  4726. }
  4727.  
  4728. // https://github.com/electron/electron/blob/master/docs/api/process.md
  4729.  
  4730. declare namespace NodeJS {
  4731.     interface Process {
  4732.         /**
  4733.          * Setting this to true can disable the support for asar archives in Node's built-in modules.
  4734.          */
  4735.         noAsar?: boolean;
  4736.         /**
  4737.          * Process's type
  4738.          */
  4739.         type: 'browser' | 'renderer';
  4740.         /**
  4741.          * Path to JavaScript source code.
  4742.          */
  4743.         resourcesPath: string;
  4744.         /**
  4745.          * For Mac App Store build, this value is true, for other builds it is undefined.
  4746.          */
  4747.         mas?: boolean;
  4748.         /**
  4749.          * If the app is running as a Windows Store app (appx), this value is true, for other builds it is undefined.
  4750.          */
  4751.         windowsStore?: boolean;
  4752.         /**
  4753.          * When app is started by being passed as parameter to the default app,
  4754.          * this value is true in the main process, otherwise it is undefined.
  4755.          */
  4756.         defaultApp?: boolean;
  4757.         /**
  4758.          * Emitted when Electron has loaded its internal initialization script
  4759.          * and is beginning to load the web page or the main script.
  4760.          */
  4761.         on(event: 'loaded', listener: Function): this;
  4762.         on(event: string, listener: Function): this;
  4763.         /**
  4764.          * Causes the main thread of the current process crash;
  4765.          */
  4766.         crash(): void;
  4767.         /**
  4768.          * Causes the main thread of the current process hang.
  4769.          */
  4770.         hang(): void;
  4771.         /**
  4772.          * Sets the file descriptor soft limit to maxDescriptors or the OS hard limit,
  4773.          * whichever is lower for the current process.
  4774.          *
  4775.          * Note: This API is only available on Mac and Linux.
  4776.          */
  4777.         setFdLimit(maxDescriptors: number): void;
  4778.         /**
  4779.          * @returns Object giving memory usage statistics about the current process.
  4780.          * Note: All statistics are reported in Kilobytes.
  4781.          */
  4782.         getProcessMemoryInfo(): ProcessMemoryInfo;
  4783.         /**
  4784.          * @returns Object giving memory usage statistics about the entire system.
  4785.          * Note: All statistics are reported in Kilobytes.
  4786.          */
  4787.         getSystemMemoryInfo(): SystemMemoryInfo;
  4788.     }
  4789.  
  4790.     interface ProcessMemoryInfo {
  4791.         /**
  4792.          * The amount of memory currently pinned to actual physical RAM.
  4793.          */
  4794.         workingSetSize: number;
  4795.         /**
  4796.          * The maximum amount of memory that has ever been pinned to actual physical RAM.
  4797.          */
  4798.         peakWorkingSetSize: number;
  4799.         /**
  4800.          * The amount of memory not shared by other processes, such as JS heap or HTML content.
  4801.          */
  4802.         privateBytes: number;
  4803.         /**
  4804.          * The amount of memory shared between processes, typically memory consumed by the Electron code itself.
  4805.          */
  4806.         sharedBytes: number;
  4807.     }
  4808.  
  4809.     interface SystemMemoryInfo {
  4810.         /**
  4811.          * The total amount of physical memory available to the system.
  4812.          */
  4813.         total: number;
  4814.         /**
  4815.          * The total amount of memory not being used by applications or disk cache.
  4816.          */
  4817.         free: number;
  4818.         /**
  4819.          * The total amount of swap memory available to the system.
  4820.          */
  4821.         swapTotal: number;
  4822.         /**
  4823.          * The free amount of swap memory available to the system.
  4824.          */
  4825.         swapFree: number;
  4826.     }
  4827. }
  4828.  
  4829. declare module 'electron' {
  4830.     var electron: Electron.ElectronMainAndRenderer;
  4831.     export = electron;
  4832. }
  4833.  
  4834. interface NodeRequireFunction {
  4835.     (moduleName: 'electron'): Electron.ElectronMainAndRenderer;
  4836. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement