/// import { BrowserWindow, WebContents, Event as ElectronEvent } from '../../electron-shared/electron'; import { ForkOptions } from 'child_process'; import { ElectronFrontendApplicationConfig, FrontendApplicationConfig } from '@theia/application-package/lib/application-props'; import URI from '../common/uri'; import { Deferred } from '../common/promise-util'; import { MaybePromise } from '../common/types'; import { ContributionProvider } from '../common/contribution-provider'; import { ElectronSecurityTokenService } from './electron-security-token-service'; import { ElectronSecurityToken } from '../electron-common/electron-token'; import Storage = require('electron-store'); import { WindowSearchParams } from '../common/window'; import { TheiaBrowserWindowOptions, TheiaElectronWindow, TheiaElectronWindowFactory } from './theia-electron-window'; import { ElectronMainApplicationGlobals } from './electron-main-constants'; export { ElectronMainApplicationGlobals }; /** * Options passed to the main/default command handler. */ export interface ElectronMainCommandOptions { /** * By default, the first positional argument. Should be either a relative or absolute file-system path pointing to a file or a folder. */ readonly file?: string; readonly cwd: string; /** * If the app is launched for the first time, `secondInstance` is false. * If the app is already running but user relaunches it, `secondInstance` is true. */ readonly secondInstance: boolean; } /** * The default entrypoint will handle a very rudimentary CLI to open workspaces by doing `app path/to/workspace`. To override this behavior, you can extend and rebind the * `ElectronMainApplication` class and overriding the `launch` method. * A JSON-RPC communication between the Electron Main Process and the Renderer Processes is available: You can bind services using the `ElectronConnectionHandler` and * `ElectronIpcConnectionProvider` APIs, example: * * From an `electron-main` module: * * bind(ElectronConnectionHandler).toDynamicValue(context => * new RpcConnectionHandler(electronMainWindowServicePath, * () => context.container.get(ElectronMainWindowService)) * ).inSingletonScope(); * * And from the `electron-browser` module: * * bind(ElectronMainWindowService).toDynamicValue(context => * ElectronIpcConnectionProvider.createProxy(context.container, electronMainWindowServicePath) * ).inSingletonScope(); */ export declare const ElectronMainApplicationContribution: unique symbol; export interface ElectronMainApplicationContribution { /** * The application is ready and is starting. This is the time to initialize * services global to this process. * * Invoked when the electron-main process starts for the first time. */ onStart?(application: ElectronMainApplication): MaybePromise; /** * The application is stopping. Contributions must perform only synchronous operations. */ onStop?(application: ElectronMainApplication): void; } export declare class ElectronMainProcessArgv { protected get processArgvBinIndex(): number; protected get isBundledElectronApp(): boolean; protected get isElectronApp(): boolean; getProcessArgvWithoutBin(argv?: string[]): Array; getProcessArgvBin(argv?: string[]): string; } export declare namespace ElectronMainProcessArgv { interface ElectronMainProcess extends NodeJS.Process { readonly defaultApp: boolean; readonly versions: NodeJS.ProcessVersions & { readonly electron: string; }; } } export declare class ElectronMainApplication { protected readonly contributions: ContributionProvider; protected readonly globals: ElectronMainApplicationGlobals; protected processArgv: ElectronMainProcessArgv; protected electronSecurityTokenService: ElectronSecurityTokenService; protected readonly electronSecurityToken: ElectronSecurityToken; protected readonly windowFactory: TheiaElectronWindowFactory; protected isPortable: boolean; protected readonly electronStore: Storage<{ windowstate?: TheiaBrowserWindowOptions | undefined; }>; protected readonly _backendPort: Deferred; readonly backendPort: Promise; protected _config: FrontendApplicationConfig | undefined; protected useNativeWindowFrame: boolean; protected customBackgroundColor?: string; protected didUseNativeWindowFrameOnStart: Map; protected windows: Map; protected restarting: boolean; /** Used to temporarily store the reference to an early created main window */ protected initialWindow?: BrowserWindow; get config(): FrontendApplicationConfig; protected makePortable(): boolean; start(config: FrontendApplicationConfig): Promise; protected getTitleBarStyle(config: FrontendApplicationConfig): 'native' | 'custom'; setTitleBarStyle(webContents: WebContents, style: string): void; setBackgroundColor(webContents: WebContents, backgroundColor: string): void; protected saveState(webContents: Electron.WebContents): void; /** * @param id the id of the WebContents of the BrowserWindow in question * @returns 'native' or 'custom' */ getTitleBarStyleAtStartup(webContents: WebContents): 'native' | 'custom'; protected determineSplashScreenBounds(initialWindowBounds: { x: number; y: number; width: number; height: number; }): Promise<{ x: number; y: number; width: number; height: number; }>; protected isShowWindowEarly(): boolean; protected showInitialWindow(): void; protected configureAndShowSplashScreen(mainWindow: BrowserWindow): Promise; protected isShowSplashScreen(): boolean; protected getSplashScreenOptions(): ElectronFrontendApplicationConfig.SplashScreenOptions | undefined; /** * Use this rather than creating `BrowserWindow` instances from scratch, since some security parameters need to be set, this method will do it. * * @param options */ createWindow(asyncOptions?: MaybePromise): Promise; getLastWindowOptions(): Promise; protected avoidOverlap(options: TheiaBrowserWindowOptions): TheiaBrowserWindowOptions; protected getDefaultOptions(): TheiaBrowserWindowOptions; openDefaultWindow(params?: WindowSearchParams): Promise; protected openWindowWithWorkspace(workspacePath: string): Promise; protected reuseOrCreateWindow(asyncOptions: MaybePromise): Promise; /** Configures native window creation, i.e. using window.open or links with target "_blank" in the frontend. */ protected configureNativeSecondaryWindowCreation(electronWindow: BrowserWindow): void; /** * "Gently" close all windows, application will not stop if a `beforeunload` handler returns `false`. */ requestStop(): void; protected handleMainCommand(options: ElectronMainCommandOptions): Promise; protected createWindowUri(params?: WindowSearchParams): Promise; protected getDefaultTheiaWindowOptions(): TheiaBrowserWindowOptions; protected getDefaultTheiaSecondaryWindowBounds(): TheiaBrowserWindowOptions; protected getDefaultTheiaWindowBounds(): TheiaBrowserWindowOptions; /** * Save the window geometry state on every change. */ protected attachSaveWindowState(electronWindow: BrowserWindow): void; protected saveWindowState(electronWindow: BrowserWindow): void; /** * Return a string unique to the current display layout. */ protected getCurrentScreenLayout(): string; /** * Start the NodeJS backend server. * * @return Running server's port promise. */ protected startBackend(): Promise; protected getForkOptions(): Promise; protected attachElectronSecurityToken(port: number): Promise; protected hookApplicationEvents(): void; protected onWillQuit(event: ElectronEvent): void; protected onSecondInstance(event: ElectronEvent, argv: string[], cwd: string): Promise; protected onWindowAllClosed(event: ElectronEvent): void; restart(webContents: WebContents): Promise; protected startContributions(): Promise; protected stopContributions(): void; } //# sourceMappingURL=electron-main-application.d.ts.map