import { Glue42 } from "@glue42/desktop"; import { ApplicationConfig, ChildWindowConfig, ExeConfig } from "@glue42/schemas"; export * from "@glue42/desktop"; export namespace Glue42Electron { const api: API; export interface Config { appDefinition?: ExeAppDefinition; env?: string; region?: string; gwURL?: string; inject?: "glue" | "fdc3" | "none"; preload?: boolean; } type ChildApp = Omit; type ChildAppDetails = Omit; type ExeApp = Omit; export interface ChildAppDefinition extends ChildApp { details?: ChildAppDetails; } export interface ExeAppDefinition extends ExeApp { details?: ExeConfig; } export interface StartingContext { // instance Id instanceId: string; // Startup context for the new application context: unknown; // Url to the GW the application should connect to gwURL: string; // GW token to be used as auth mechanism when connecting to the GW gwToken: string; // application configuration as defined in the app store applicationConfig: ExeAppDefinition; // GD env env: string; // GD region region: string; // Sticky windows options windowOptions: Partial; } export type FactoryFunc = (this: Partial, appDefinition: ChildAppDefinition, context: unknown, state: Glue42Electron.Glue42ElectronObject) => BrowserWindow; export interface BrowserWindow { setResizable(resizable: boolean): void; setSkipTaskbar(skip: boolean): void; getNativeWindowHandle(): Buffer; focus(): void; focusOnWebView(): void; blur(): void; blurWebView(): void; close(): void; on(event: 'closed', listener: (event: Event) => void): void; webContents: { id: number; focus(): void; getOSProcessId(): number; } } export interface API extends Glue42.Glue { startupOptions: Glue42Electron.StartingContext | undefined; registerStartupWindow(w: BrowserWindow, options?: Partial): Promise; registerChildWindow(w: BrowserWindow, appDefinition: ChildAppDefinition, options?: Partial): Promise; registerAppFactory(appDefinition: ChildAppDefinition, factory: FactoryFunc): Promise; } export interface Glue42ElectronObject { context: unknown; env: string; region: string; gwToken: string | undefined; gwURL: string; instanceId: string; application: string | undefined; pid: number | undefined; } export interface Buttons { allowClose: boolean; allowCollapse: boolean; allowLockUnlock: boolean; allowMaximize: boolean; allowMinimize: boolean; allowExtract: boolean; } export interface WindowOptions { hidden: boolean; state: string; mode: "flat" | "tab"; buttons: Partial; title: string; allowResize: boolean; allowMove: boolean; allowTabClose: boolean; allowChannels: boolean; channelId: string; showTaskbarIcon: boolean; isSticky: boolean; allowUnstick: boolean; frameColor: string; icon: string; maxWidth: number; minWidth: number; maxHeight: number; minHeight: number; maximizable: boolean; minimizable: boolean; bounds: { x: number; y: number; width: number; height: number; }; tabGroupId: string; tabIndex: number; tabSelected: boolean; relativeTo: string; relativeDirection: string; } } interface NodeRequire { (moduleName: '@glue42/electron'): typeof Glue42Electron.api; } export function initialize(config?: Glue42Electron.Config): Promise;