/** * Methods for querying and manipulating elements pertaining to a native * ToDesktop window shell. * * @remarks * This package exposes a number of methods for querying and manipulating * elements pertaining to a native ToDesktop window shell. * * @experimental * @public * @packageDocumentation */ import type { BrowserWindow, BrowserWindowConstructorOptions, Rectangle, TitleBarOverlayOptions, WillResizeDetails } from "@todesktop/client-electron-types"; import { type InstanceRefObject } from "@todesktop/client-util"; import { type Ref, type RefOptions } from "./invoke.js"; import { type NamespaceEvents } from "./utils.js"; /** * @public */ /** * Creates a new BrowserWindow. * * @param options - BrowserWindow constructor options. * @returns Identifier for the newly created BrowserWindow. * @public */ export declare function create(options: BrowserWindowConstructorOptions): Promise; /** * Destroys the BrowserWindow corresponding to the `ref`. * * @param options - ref: Reference for the BrowserWindow to destroy * @public */ export declare function destroy({ ref }?: RefOptions): Promise; /** * Sets a BrowserView on the reference BrowserWindow. If there are * other BrowserViews attached, they will be removed from the window. * * @param options - ref: Reference for the BrowserWindow; viewRef: Reference for the BrowserView to set. * @public */ export declare function setBrowserView({ ref, viewRef, }: { ref?: Ref; viewRef: Ref; }): Promise; /** * Adds a BrowserView to the reference BrowserWindow. * * @param options - ref: Reference for the BrowserWindow; viewRef: Reference for the BrowserView to add. * @public */ export declare function addBrowserView({ ref, viewRef, }: { ref?: Ref; viewRef: Ref; }): Promise; /** * Removes a BrowserView from the reference BrowserWindow. * * @param options - ref: Reference for the BrowserWindow; viewRef: Reference for the BrowserView to remove. * @public */ export declare function removeBrowserView({ ref, viewRef, }: { ref?: Ref; viewRef: Ref; }): Promise; /** * Gets the width and height of the reference browser window * * @param options - ref: Reference for the BrowserWindow. * @public */ export declare function getSize({ ref }?: RefOptions): Promise; /** * Resizes the window to `width` and `height`. If `width` or `height` are below any * set minimum size constraints the window will snap to its minimum size. * * @param options - ref: Reference for the BrowserWindow * @public */ export declare function setSize({ ref }: RefOptions, ...args: Parameters): Promise; /** * Resizes and moves the window to the supplied bounds. Any properties that are not * supplied will default to their current values. * * **Note:** On macOS, the y-coordinate value cannot be smaller than the Tray * height. The tray height has changed over time and depends on the operating * system, but is between 20-40px. Passing a value lower than the tray height will * result in a window that is flush to the tray. * * @param options - ref: Reference for the BrowserWindow * @public */ export declare function setBounds({ ref }: RefOptions, ...args: Parameters): Promise; /** * Changes the title of the reference BrowserWindow. * * @param options - ref: Reference for the BrowserWindow; title: Desired title for the BrowserWindow. * @public */ export declare function setTitle({ ref, title }: { ref?: Ref; title: string; }): Promise; /** * On a Window with Window Controls Overlay already enabled, this method updates * the style of the title bar overlay. * * **Note:** This API does nothing on Mac or Linux. * * @platform win32 * @param options - ref: Reference for the BrowserWindow; options: The configuration for the title bar. * @public */ export declare function setTitleBarOverlay({ ref, options, }: { ref?: Ref; options: TitleBarOverlayOptions; }): Promise; /** * Adds a vibrancy effect to the browser window. Passing null or an empty string will remove the vibrancy effect on the window. * * **Note:** This API does nothing on Windows or Linux. * * @platform darwin */ export declare function setVibrancy({ ref }: RefOptions, ...args: Parameters): Promise; /** * Sets the opacity of the window. Out of bound number values are clamped to the [0, 1] range. * * **Note:** This API does nothing on Linux. * * @platform darwin,windows */ export declare function setOpacity({ ref }: RefOptions, ...args: Parameters): Promise; /** * Sets the background color of the window. * * @param options - ref: Reference for the BrowserWindow; * @param backgroundColor - The following string value patterns are accepted: * - Hex, for example: #ffffff (RGB) or #ffffffff (ARGB). * - RGB, for example: rgb(255, 255, 255) or rgba(255, 255, 255, 1.0). * - HSL, for example: hsl(200, 20%, 50%) or hsla(200, 20%, 50%, 0.5). * - Name, for example: red. * * @public */ export declare function setBackgroundColor({ ref }: RefOptions, ...args: Parameters): Promise; /** * Minimize the window. * * @param options - ref: Reference for the BrowserWindow to minimize * @public */ export declare function minimize({ ref }?: RefOptions): Promise; /** * Restore the window from minimized state. * * @param options - ref: Reference for the BrowserWindow to restore * @public */ export declare function restore({ ref }?: RefOptions): Promise; /** * Check if the window is minimized. * * @param options - ref: Reference for the BrowserWindow to check * @public */ export declare function isMinimized({ ref }?: RefOptions): Promise; /** * Maximize the window. * * @param options - ref: Reference for the BrowserWindow to maximize * @public */ export declare function maximize({ ref }?: RefOptions): Promise; /** * Unmaximize the window. * * @param options - ref: Reference for the BrowserWindow to unmaximize * @public */ export declare function unmaximize({ ref }?: RefOptions): Promise; /** * Check if the window is maximized. * * @param options - ref: Reference for the BrowserWindow to check * @public */ export declare function isMaximized({ ref }?: RefOptions): Promise; /** * Enter fullscreen mode. * * @param options - ref: Reference for the BrowserWindow to enter fullscreen * @public */ export declare function enterFullscreen({ ref }?: RefOptions): Promise; /** * Exit fullscreen mode. * * @param options - ref: Reference for the BrowserWindow to exit fullscreen * @public */ export declare function exitFullscreen({ ref }?: RefOptions): Promise; /** * Check if the window is in fullscreen mode. * * @param options - ref: Reference for the BrowserWindow to check * @public */ export declare function isFullscreen({ ref }?: RefOptions): Promise; /** * Returns `true` if the current window is set to always be on top of other windows. * * @param options - ref: Reference for the BrowserWindow to show * @public */ export declare function isAlwaysOnTop({ ref }?: RefOptions): Promise; /** * Causes the referenced window to be focussed on the user's desktop. * * @param options - ref: Reference for the BrowserWindow to focus * @public */ export declare function focus({ ref }?: RefOptions): Promise; /** * Removes the referenced window from focus on the user's desktop. * * @param options - ref: Reference for the BrowserWindow to blur * @public */ export declare function blur({ ref }?: RefOptions): Promise; /** * @public */ export declare function areTabsSupported(): Promise; /** * Creates a new tab and loads the pre-defined app URL. * * @public */ export declare function createNewTab(): Promise; /** * @param percent - An float between 0-1 will set the progress bar to a * certain percentage. e.g. `0.75` will show a progress bar 75% filled. * * Values above 1 will enable intermediate mode. * * Values below 0 will disable the progress bar. * @public */ export declare function setProgressBar(percent: number): Promise; /** * Returns a boolean indicating whether the window has been destroyed. * * @param options - ref: Reference for the BrowserWindow * @public */ export declare function isDestroyed({ ref }?: RefOptions): Promise; /** * Returns a boolean indicating whether the window is visible to the user. * * @param options - ref: Reference for the BrowserWindow * @public */ export declare function isVisible({ ref }?: RefOptions): Promise; /** * Hides the BrowserWindow corresponding to the `ref`. * * @param options - ref: Reference for the BrowserWindow to hide * @public */ export declare function hide({ ref }?: RefOptions): Promise; /** * Shows the BrowserWindow corresponding to the `ref`. * * @param options - ref: Reference for the BrowserWindow to show * @public */ export declare function show({ ref }?: RefOptions): Promise; /** * Shows the window corresponding to the `ref` but doesn't focus it. * * @param options - ref: Reference for the BrowserWindow to show * @public */ export declare function showInactive({ ref }?: RefOptions): Promise; /** * Close the BrowserWindow corresponding to the `ref`. * * @param options - ref: Reference for the BrowserWindow to close * @public */ export declare function close({ ref }?: RefOptions): Promise; /** * @param options - ref: Reference for the BrowserWindow to show * @returns An array of all opened browser windows. * @public */ export declare function getAllWindows(): Promise; /** * @param options - ref: Reference for the BrowserWindow * @returns `id` of the BrowserWindow. * @public */ export declare function getId({ ref }?: RefOptions): Promise; /** * * Gets the background color of the window in Hex (#RRGGBB) format. * Note: The alpha value is not returned alongside the red, green, and blue values. * * @param options - ref: Reference for the BrowserWindow; * * @public */ export declare function getBackgroundColor({ ref }: RefOptions, ...args: Parameters): Promise; /** * The title of the native window. * * @param options - ref: Reference for the BrowserWindow to show * @public */ export declare function getTitle({ ref }?: RefOptions): Promise; /** * Reloads the web page. * * @param options - ref: Reference for the BrowserWindow to show * @public */ export declare function reload({ ref }?: RefOptions): Promise; /** * Get a WebContents reference for a BrowserWindow. WebContents is responsible * for rendering and controlling a web page * * @param options - ref: Reference for the BrowserWindow to show * @public */ export declare function getWebContents({ ref }?: RefOptions): Promise; /** * Sets whether the window should show always on top of other windows. After * setting this, the window is still a normal window, not a toolbox window which * can not be focused on. * * @param options - ref: Reference for the BrowserWindow to show * @public */ export declare function setAlwaysOnTop({ ref }: RefOptions, ...args: Parameters): Promise; /** * Sets whether the window should be visible on all workspaces. * * **Note:** This API does nothing on Windows. * * @platform darwin,linux */ export declare function setVisibleOnAllWorkspaces({ ref }: RefOptions, ...args: Parameters): Promise; /** * Changes window icon. * * @see https://www.electronjs.org/docs/latest/api/browser-window#winseticonicon-windows-linux * @public */ export declare function setIcon({ ref }: RefOptions, image: InstanceRefObject): Promise; /** * Prevents the window contents from being captured by other apps. * * @param options - ref: Reference for the BrowserWindow to show * @public */ export declare function setContentProtection({ ref }: RefOptions, ...args: Parameters): Promise; /** * Moves window to `x` and `y`. * * @param options - ref: Reference for the BrowserWindow * @public */ export declare function setPosition({ ref }: RefOptions, ...args: Parameters): Promise; /** * Returns the window's current position. * * @param options - ref: Reference for the BrowserWindow * @public */ export declare function getPosition({ ref }?: RefOptions, ...args: Parameters): Promise; /** * Makes the window ignore all mouse events. * * All mouse events happened in this window will be passed to the window * below this window, but if this window has focus, it will still receive * keyboard events. * * @param options - ref: Reference for the BrowserWindow * @public */ export declare function setIgnoreMouseEvents({ ref }: RefOptions, ...args: Parameters): Promise; /** * Sets the position of the window buttons. * * @param options - ref: Reference for the BrowserWindow * @public */ export declare function setWindowButtonPosition({ ref }: RefOptions, ...args: Parameters): Promise; /** * Returns the position of the window buttons. * * @param options - ref: Reference for the BrowserWindow * @public */ export declare function getWindowButtonPosition({ ref }?: RefOptions): Promise; /** * Sets whether the window can be focused. * * @param options - ref: Reference for the BrowserWindow * @public */ export declare function setFocusable({ ref }: RefOptions, ...args: Parameters): Promise; /** * Sets whether the window can be manually closed by user. * * @param options - ref: Reference for the BrowserWindow * @param closable - Whether the window can be manually closed by the user * @platform darwin,win32 * @public */ export declare function setClosable({ ref }: RefOptions, ...args: Parameters): Promise; /** * Starts or stops flashing the window to attract user's attention. * * @remarks * On macOS, this will flash the dock icon continuously when flag is true. * On Windows, this will flash the taskbar button. * On Linux, this has no effect. * * @param options - ref: Reference for the BrowserWindow * @param flag - Whether to start or stop flashing the window * @platform darwin,win32 * @public */ export declare function flashFrame({ ref }: RefOptions, flag: boolean): Promise; /** * EVENTS */ export declare type LegacyNativeWindowEvent = "enterFullscreen" | "exitFullscreen"; /** * @public */ export declare type NativeWindowEvents = NamespaceEvents<{ "always-on-top-changed": (isAlwaysOnTop: boolean) => void; "app-command": (command: string) => void; blur: () => void; close: () => void; closed: () => void; "enter-full-screen": () => void; "enter-html-full-screen": () => void; focus: () => void; hide: () => void; "leave-full-screen": () => void; "leave-html-full-screen": () => void; maximize: () => void; minimize: () => void; move: () => void; moved: () => void; "new-window-for-tab": () => void; "page-title-updated": (title: string, explicitSet: boolean) => void; "ready-to-show": () => void; resize: () => void; resized: () => void; responsive: () => void; restore: () => void; "rotate-gesture": (rotation: number) => void; "scroll-touch-begin": () => void; "scroll-touch-edge": () => void; "scroll-touch-end": () => void; "session-end": () => void; "sheet-begin": () => void; "sheet-end": () => void; show: () => void; swipe: (direction: string) => void; unmaximize: () => void; unresponsive: () => void; "will-move": (newBounds: Rectangle) => void; "will-resize": (newBounds: Rectangle, details: WillResizeDetails) => void; }>; /** * @public */ export declare const on: (eventName: E, callback: NamespaceEvents<{ "always-on-top-changed": (isAlwaysOnTop: boolean) => void; "app-command": (command: string) => void; blur: () => void; close: () => void; closed: () => void; "enter-full-screen": () => void; "enter-html-full-screen": () => void; focus: () => void; hide: () => void; "leave-full-screen": () => void; "leave-html-full-screen": () => void; maximize: () => void; minimize: () => void; move: () => void; moved: () => void; "new-window-for-tab": () => void; "page-title-updated": (title: string, explicitSet: boolean) => void; "ready-to-show": () => void; resize: () => void; resized: () => void; responsive: () => void; restore: () => void; "rotate-gesture": (rotation: number) => void; "scroll-touch-begin": () => void; "scroll-touch-edge": () => void; "scroll-touch-end": () => void; "session-end": () => void; "sheet-begin": () => void; "sheet-end": () => void; show: () => void; swipe: (direction: string) => void; unmaximize: () => void; unresponsive: () => void; "will-move": (newBounds: Rectangle) => void; "will-resize": (newBounds: Rectangle, details: WillResizeDetails) => void; }>[E], args_0?: { ref?: InstanceRefObject; preventDefault?: boolean; }) => Promise<() => Promise>; /** * @public */ export declare const removeAllListeners: (eventName: E, args_0?: { ref?: InstanceRefObject; }) => Promise;