import type { BrowserWindowConstructorOptions, MenuItemConstructorOptions, MessageBoxOptions, NotificationConstructorOptions, WebPreferences } from '@todesktop/client-electron-types'; import type { BaseApp } from './base'; import type { CustomPlugin, DesktopAppPlugin } from './plugin'; import type { ISwitchableValue } from './toDesktop'; import type { ValidTranslationKeys, ValidTranslationLanguages } from './translation'; interface BaseAssetDetails { /** * Local path where the asset is/should be stored. This path is relative to the app directory */ relativeLocalPath: string; /** * Remote URL where the asset can be downloaded */ url: string; } export interface AppIconAssetDetails extends BaseAssetDetails { type: 'appIcon'; } export interface MenuIconAssetDetails extends BaseAssetDetails { type: 'menuIcon'; } export interface TrayMenubarIconAssetDetails extends BaseAssetDetails { type: 'trayMenubarIcon'; } export interface FileAssetDetails extends BaseAssetDetails { md5Hash: string; type: 'file'; } export type AssetDetails = AppIconAssetDetails | FileAssetDetails | MenuIconAssetDetails | TrayMenubarIconAssetDetails; /** * Custom ToDesktop Roles for Application & Tray Menus */ type todesktopRoles = 'todesktop:check-for-updates' | 'todesktop:check-for-updates' | 'todesktop:hide-window' | 'todesktop:history-back' | 'todesktop:history-forward' | 'todesktop:history-home' | 'todesktop:launch-at-startup' | 'todesktop:new-tab' | 'todesktop:new-window' | 'todesktop:quit-completely' | 'todesktop:quit' | 'todesktop:show-window' | 'todesktop:toggle-window' | 'todesktop:toggle-window0' | 'todesktop:toggle-window1' | 'todesktop:toggle-window2' | 'todesktop:toggle-window3' | 'todesktop:toggle-window4'; export interface DesktopifyMenuItemConstructorOptions extends Omit { acceleratorBehaviour?: 'custom' | 'default' | 'explicit-none' | 'none'; actionType?: 'jsEvent' | 'role'; bundledIcon?: string; event?: string; iconAssetDetails?: MenuIconAssetDetails; iconUrl?: string; platforms?: NodeJS.Platform[]; role?: MenuItemConstructorOptions['role'] | todesktopRoles; submenu?: DesktopifyMenuItemConstructorOptions[]; targetWindowId?: string; useSystemLabel?: boolean; useTemplateImage?: boolean; } /** * Toggle Window Tray Action * * @param windowId - The id of the window to toggle */ export type DesktopifyAppTrayToggleWindowAction = { role: 'toggleWindow'; windowId: string; }; /** * Toggle Menu Tray Action * * @param menu - The menu to show when action triggered */ export type DesktopifyAppTrayToggleMenuAction = { menu: DesktopifyMenuItemConstructorOptions[]; role: 'toggleMenu'; }; /** * JS Event Tray Action * * @param event - The name of the event */ export type DesktopifyAppTrayJSEventAction = { event: string; role: 'jsEvent'; }; /** * No Action Tray Action */ export type DesktopifyAppTrayNoAction = { role: 'noAction'; }; export type DesktopifyAppTrayAction = DesktopifyAppTrayJSEventAction | DesktopifyAppTrayNoAction | DesktopifyAppTrayToggleMenuAction | DesktopifyAppTrayToggleWindowAction; export interface DesktopifyAppTray { bundledIcon?: string; icon?: string; iconAssetDetails?: TrayMenubarIconAssetDetails; id: string; leftClick: DesktopifyAppTrayAction; linuxIcon?: string; linuxIconAssetDetails?: TrayMenubarIconAssetDetails; macOSIcon?: string; macOSIconAssetDetails?: TrayMenubarIconAssetDetails; objectId?: string; rightClick: DesktopifyAppTrayAction; swapClickHandlers?: boolean; useSeparateIcons?: boolean; useTemplateImage?: boolean; windowsIcon?: string; windowsIconAssetDetails?: TrayMenubarIconAssetDetails; } export type DesktopifyAppMenu = DesktopifyMenuItemConstructorOptions; /** * Whitelist of allowed DesktopifyWindow Options. * These attrs (if set) are passed to the `BrowserWindow` constructor * when the window is created */ export declare const allowedBrowserWindowConstructorOptions: Readonly<(keyof BrowserWindowConstructorOptions)[]>; export type whitelistedBrowserWindowConstructorOptions = (typeof allowedBrowserWindowConstructorOptions)[number]; /** * Whitelist of allowed DesktopifyWindow Web Preferences Options. * These attrs (if set) are passed to the webPreferences object in the `BrowserWindow` constructor * when the window is created */ export declare const allowedWebPreferencesOptions: Readonly<(keyof WebPreferences)[]>; export type whitelistedWebPreferencesOptions = (typeof allowedWebPreferencesOptions)[number]; /** * Interface for ToDesktop App Windows */ export interface DesktopifyAppWindow { /** * The window's background type */ backgroundType?: 'color' | 'normal' | 'transparent' | 'vibrant'; /** * Disables default rightClick menu */ disableContextMenu: boolean; /** * Disables the menu item for opening a link in a new app window */ disableContextMenuOpenInWindow: boolean; /** * Don't allow tabs in window (macOS only) */ disableTabs: boolean; /** * The path to the file to load if `shouldUseFileInsteadOfUrl` is `true`. */ file?: string; /** * Configuration options for find in page */ findInPageOptions?: { horizontalPlacement?: { default: FindInPagePlacement; left: FindInPagePlacement; right: FindInPagePlacement; type: 'default' | 'left' | 'right'; }; verticalPlacement?: { bottom: FindInPagePlacement; default: FindInPagePlacement; top: FindInPagePlacement; type: 'bottom' | 'default' | 'top'; }; }; /** * Does the window have a maximum height. Default is `false` */ hasMaxHeight: boolean; /** * Does the window have a maximum width. Default is `false` */ hasMaxWidth: boolean; /** * Does the window have a minimum height. Default is `false` */ hasMinHeight: boolean; /** * Does the window have a minimum width. Default is `false` */ hasMinWidth: boolean; /** * A unique window id */ id: string; /** * Allows user to `Cmd+F` or `Edit>Find` to search for text on page */ isFindInPageEnabled?: boolean; /** * Whether this is the main window. The main window handles deeplinks */ isMain: boolean; /** * If `true` prevents the native window's title from changing when the document title changes */ isTitleStatic?: boolean; /** * The window name. Only visible to developer */ name: string; /** * A *mutable* window object id */ objectId?: string; /** * BrowserWindow Constructor Options */ options: { /** * Settings of web page's features. */ webPreferences?: Pick; } & Pick; /** * By default ToDesktop remembers window width & height between sessions. * Setting to `true` disables behaviour */ shouldResetDimensions?: boolean; /** * The window should load a file instead of a URL. * The file property (below) should also be set if the value is `true`. */ shouldUseFileInsteadOfUrl?: boolean; /** * Keyboard shortcut to toggle window visibility */ toggleVisibilityKeyboardShortcut?: string; /** * The type of window */ type: 'app' | 'desktop' | 'menubar' | 'panel'; /** * The window's url */ url: string; /** * Inital visibility of window */ visibility: 'hidden' | 'show-when-contents-loaded' | 'visible'; /** * MacOS option for whether the window should be visible on all workspaces */ visibleOnAllWorkspaces: boolean; } export type AutoUpdateConfiguration = { autoCheckIntervalMins: number; autoUpdater: boolean; shouldAutoCheckInterval: boolean; shouldAutoCheckOnLaunch: boolean; updateReadyAction: { showInstallAndRestartPrompt: { mode: 'always' | 'never' | 'whenInForeground'; options: { installOnNextLaunchButton: string; restartAndInstallButton: string; } & Omit; }; showNotification: { mode: 'always' | 'never' | 'whenInBackground'; options: Omit; }; }; }; export interface DesktopifyApp2 { /** * Relaxes our "deny" policy when attempting to open a window with an `"about:blank"` URL. */ allowAboutBlankWindowOpenHandler?: boolean; /** * Used as appUserModelId on windows */ appModelId?: string; /** * Registers an app protocol. Format should be `{APP_PROTOCOL}://` e.g. `example://` */ appProtocol: ISwitchableValue; /** * Sets strings to be used in the app UI. Currently only supports English */ appStrings?: { [key in ValidTranslationKeys]?: { [lang in ValidTranslationLanguages]?: string; }; }; /** * Sets whether the window menu bar should hide itself automatically. * Once set the menu bar will only show when users press the single Alt key. */ autoHideMenuBar?: boolean; /** * Configure auto updates */ autoUpdates: AutoUpdateConfiguration; /** * The locally-bundled app icon. */ bundledIcon?: string; /** * Command line switches * Learn more {@link https://www.electronjs.org/docs/api/command-line-switches} * @example * { * 'remote-debugging-port': '8315' * } */ commandLineSwitches?: { [key: string]: string; }; /** * The name of the company that the app belongs to */ companyName?: string; /** * URL that crash reports will be POSTed to */ crashReporter?: string; /** * Metadata about plugins that were manually linked into the app */ customPlugins?: CustomPlugin[]; /** * Disable devTools on all app windows */ disableDevTools: boolean; /** * Disable error reporting (Sentry) */ disableErrorTracking?: boolean; /** * Enables NEW push notifications — uses `@cuj1559/electron-push-receiver` */ enableNewPushNotifications?: boolean; /** * Enables push notifications — uses `electron-push-receiver` */ enablePushNotifications?: boolean; /** * File assets that get bundled with the app and are available offline */ fileAssetDetailsList?: FileAssetDetails[]; /** * Opens `accounts.google.com/o/oauth` in user's default browswer not as internal url */ googleOAuthIsExternal?: boolean; /** * The app icon url */ icon?: string; /** * Details concerning how the app icon should be handled across ToDesktop services */ iconAssetDetails?: AppIconAssetDetails; /** * App identifier */ id: string; /** * Disables the same-origin policy */ insecure?: boolean; /** * Regex patterns for internal app urls */ internalUrls: ISwitchableValue; /** * By default ToDesktop uses native `window.open` to support Firebase social login. * This makes the app use electron's `window.open`. */ isNativeWindowOpenDisabled?: boolean; /** * Whether the app is secure i.e. using valid code signing certificates. * Note: This value is not persisted in firestore, and is instead written locally at build time. * @default false */ isSecure?: boolean; /** * Last todesktop builder version that was used to update the app */ lastUsedBuilderVersion?: string; /** * Last desktopify version that was used to update the app */ lastUsedDesktopifyVersion?: string; linuxIcon?: string; linuxIconAssetDetails?: AppIconAssetDetails; macOSIcon?: string; macOSIconAssetDetails?: AppIconAssetDetails; /** * The app's menus */ menus: DesktopifyAppMenu[]; /** * The name of the app */ name: string; /** * Sets whether an offline screen will be displayed if the internet is disconnected * on initial page load. The color of the re-connect button that is shown is customizable. */ offlineScreen?: { buttonBackgroundColor: string; buttonTextColor: string; enabled: boolean; }; /** * An array of plugin modules. Can work with semver specificity */ plugins?: (Plugin | string)[]; /** * Unused currently * @unused */ pollForAppUpdatesEveryXMinutes?: number; /** * Runtime environment variables */ runtimeEnvs?: { [key: string]: string; }; /** * This option is only available when `shouldMinimizeToTray` is `true`. * Always display the dock icon while the app is open. Even if there are no windows open. */ shouldAlwaysDisplayDockIcon?: boolean; /** * Whether the app should have full access to Electron APIs * @default false */ shouldHaveFullAccessToElectronAPIs?: boolean; /** * Launch App at startup */ shouldLaunchAtStartupByDefault?: boolean; /** * Open same domain links in user's default browser */ shouldMakeSameDomainAnExternalLink?: boolean; /** * Whether the app should minimize to tray when all windows are closed. Requires at least one tray. */ shouldMinimizeToTray?: boolean; /** * If `true` the app will prevent app from opening any protocols that are not * already in a maybeAllowList or allowList (see `protocolLists.ts` in desktopify). */ shouldOnlyAllowVerifiedProtocols?: boolean; /** * Disables non-essential logs */ shouldOnlySendAbsolutelyNecessaryRequests?: boolean; /** * Prevents the window contents from being captured by other apps. */ shouldProtectContent?: boolean; /** * Disables electron overrides which ensure renderer process are restarted on each navigation. * Learn more {@link https://github.com/electron/electron/issues/18397} */ shouldReuseRendererProcess?: boolean; /** * Removes electron from userAgent */ shouldUseRealUserAgent?: boolean; /** * Only allow a single instance of this app to run */ singleInstance: boolean; /** * Sets theme for Electron UI elements and css. * * See {@link https://www.electronjs.org/docs/api/native-theme#nativethemethemesource} */ themeSource?: 'dark' | 'light' | 'system'; /** * Sets theme source for only mac * * See {@link https://www.electronjs.org/docs/api/native-theme#nativethemethemesource} */ themeSourceMac?: 'dark' | 'light' | 'system'; /** * The app's trays */ trays: DesktopifyAppTray[]; /** * Specifys the app's user agent */ userAgent: ISwitchableValue; /** * Prevents a potential vulnerability in URL matching in Electron * https://linear.app/todesktop/issue/TD-1428/html-injection-due-to-regular-expression-bypass */ useSafeInternalUrlMatcher?: boolean; /** * Instead of using one icon for every platform, use a separate icon for different platforms */ useSeparateIcons?: boolean; /** * The app's windows */ windows: DesktopifyAppWindow[]; windowsIcon?: string; windowsIconAssetDetails?: AppIconAssetDetails; } export type FindInPagePlacement = { offset: number; }; export interface IApp2 extends BaseApp { desktopApp: DesktopifyApp2; desktopAppOverrides?: { linux?: Partial>; mac?: Partial>; windows?: Partial>; }; } export {};