1. API
  2. app

API

Functions

FunctionDescription
createNewWindow()Create a new window. The created window will automatically load the configured app URL.
focus(options)Show all windows associated with the current app and set focus on the last opened window.
getBadgeCount()
getCaptureSources(options)Get the capture sources available on the user's machine.
getInternalURLs()
getLaunchSettings()Get the app's current launch settings. Seee LaunchSettings.
hide()Hide all windows associated with the current app.
once(id, callback)Executes a given function just once for the entire application.
quit()Try to close all windows and quit the app.This method guarantees that all beforeunload and unload event handlers are correctly executed. It is possible that a window cancels the quitting by returning false in the beforeunload event handler.
setBadgeCount(count)Sets a numeric badge on the app icon in the user's task bar/dock.
setInternalURLs(urlRegex)Update what URLs are routed to this app. URLs that are not listed will be routed to the default browser. This will over-ride any previously set internal URLs.
setLaunchSettings(settings)Sets the app's launch settings. See LaunchSettings.
show()Show all windows associated with the current app.

createNewWindow()

Create a new window. The created window will automatically load the configured app URL.

Signature:

        import { app } from "@todesktop/client-core"
app.createNewWindow(): Promise<void>;

      

Returns:

Promise<void>

focus()

Show all windows associated with the current app and set focus on the last opened window.

Signature:

        import { app } from "@todesktop/client-core"
app.focus(options?: FocusOptions): Promise<void>;

      
Parameters
ParameterTypeDescription
optionsFocusOptions

Returns:

Promise<void>

getBadgeCount()

Signature:

        import { app } from "@todesktop/client-core"
app.getBadgeCount(): Promise<number>;

      

Returns:

Promise<number>

The current number set as the app's badge.

getCaptureSources()

Get the capture sources available on the user's machine.

Signature:

        import { app } from "@todesktop/client-core"
app.getCaptureSources(options: DesktopCapturerOptions): Promise<CaptureSource[]>;

      
Parameters
ParameterTypeDescription
optionsDesktopCapturerOptions

Returns:

Promise<CaptureSource[]>

getInternalURLs()

Signature:

        import { app } from "@todesktop/client-core"
app.getInternalURLs(): Promise<string>;

      

Returns:

Promise<string>

A list of URL patterns that this app is currently handling.

getLaunchSettings()

Get the app's current launch settings. Seee LaunchSettings.

Signature:

        import { app } from "@todesktop/client-core"
app.getLaunchSettings(): Promise<LaunchSettings>;

      

Returns:

Promise<LaunchSettings>

hide()

Hide all windows associated with the current app.

Signature:

        import { app } from "@todesktop/client-core"
app.hide(): Promise<void>;

      

Returns:

Promise<void>

once()

Executes a given function just once for the entire application.

Signature:

        import { app } from "@todesktop/client-core"
app.once<T = unknown>(id: string, callback: (reset: () => void) => T): Promise<T>;

      
Parameters
ParameterTypeDescription
idstringUnique identifier for the target function to be executed.
callback(reset: () => void) => TTarget function to be executed.

Returns:

Promise<T>

The value that the target function returns.

quit()

Try to close all windows and quit the app.

This method guarantees that all beforeunload and unload event handlers are correctly executed. It is possible that a window cancels the quitting by returning false in the beforeunload event handler.

Signature:

        import { app } from "@todesktop/client-core"
app.quit(): Promise<void>;

      

Returns:

Promise<void>

setBadgeCount()

Sets a numeric badge on the app icon in the user's task bar/dock.

Signature:

        import { app } from "@todesktop/client-core"
app.setBadgeCount(count: number): Promise<void>;

      
Parameters
ParameterTypeDescription
countnumberAn integer specifying the badge to set. A value of 0 will remove the badge.

Returns:

Promise<void>

setInternalURLs()

Update what URLs are routed to this app. URLs that are not listed will be routed to the default browser. This will over-ride any previously set internal URLs.

Signature:

        import { app } from "@todesktop/client-core"
app.setInternalURLs(urlRegex: string): Promise<void>;

      
Parameters
ParameterTypeDescription
urlRegexstringA regular expression string representing URLs for this app to handle. Example: '.(google.com).'.

Returns:

Promise<void>

setLaunchSettings()

Sets the app's launch settings. See LaunchSettings.

Signature:

        import { app } from "@todesktop/client-core"
app.setLaunchSettings(settings: LaunchSettings): Promise<void>;

      
Parameters
ParameterTypeDescription
settingsLaunchSettingsDesired launch settings for this app.

Returns:

Promise<void>

show()

Show all windows associated with the current app.

Signature:

        import { app } from "@todesktop/client-core"
app.show(): Promise<void>;

      

Returns:

Promise<void>

Interfaces

InterfaceDescription
FocusOptions
LaunchSettings

FocusOptions

Signature:

        export interface FocusOptions 

      
Properties
PropertyTypeDescription
stealbooleanMake the receiver the active app even if another app is currently active.

LaunchSettings

Signature:

        export interface LaunchSettings 

      
Properties
PropertyTypeDescription
willLaunchAtStartupbooleanWhen true, the app will launch automatically on user login.

Variables

VariableDescription
getVersionThe current version of this app.
on

getVersion

The current version of this app.

Signature:

        getVersion: () => string

      

on

Signature:

        on: (event: "*" | "openProtocolURL", callback: (...any: any[]) => void) => Promise<() => Promise<void>>

      

Type Aliases

CaptureSource

Signature:

        export declare type CaptureSource = {
    appIcon: null | string;
    display_id: string;
    id: string;
    name: string;
    thumbnail: string;
};

      

DesktopCapturerOptions

Signature:

        export declare type DesktopCapturerOptions = {
    types: string[];
    thumbnailSize?: {
        width: number;
        height: number;
    };
    fetchWindowIcons?: boolean;
};