import { BrowserWindow } from 'electron'; import { Observable } from 'rxjs'; import * as t from '../../types'; export * from '../../types'; /** * General context accompanying a screen. */ export type IScreenContext = { readonly log: t.ILog; readonly settings: t.ISettingsClient; readonly ipc: t.IpcClient; readonly windows: t.IWindows; }; /** * A factory for screens of any type. */ export type IScreenFactory< M extends t.IpcMessage = any, S extends t.SettingsJson = any > = IScreenContext & { readonly events$: Observable; readonly change$: Observable; readonly created$: Observable; readonly closed$: Observable; readonly instances: t.IScreen[]; instance(uid: string): IScreen | undefined; exists(uid: string): boolean; create(args: { type: string; url: string; uid?: string; isStateful?: boolean; window?: Electron.BrowserWindowConstructorOptions; bounds?: Partial; // Explicit bounds to use that override state and/or the default bounds in the `window` options. }): IScreen; type(args: { type: string; url: string; isStateful?: boolean; window?: Electron.BrowserWindowConstructorOptions; }): IScreenTypeFactory; }; /** * A factory for screens of a single type. */ export type IScreenTypeFactory< M extends t.IpcMessage = any, S extends t.SettingsJson = any > = IScreenContext & { readonly type: string; readonly events$: Observable; readonly change$: Observable; readonly created$: Observable; readonly closed$: Observable; readonly instances: t.IScreen[]; instance(uid: string): IScreen | undefined; exists(uid: string): boolean; create(args?: { uid?: string; isStateful?: boolean; window?: Electron.BrowserWindowConstructorOptions; bounds?: Partial; // Explicit bounds to use that override state and/or the default bounds in the `window` options. }): IScreen; }; /** * A screen instance. */ export type IScreen = IScreenContext< M, S > & { readonly uid: string; readonly type: string; readonly window: BrowserWindow; readonly tags: t.IWindowTag[]; readonly dispose$: Observable; readonly events$: Observable; readonly change$: Observable; readonly closed$: Observable; }; /** * [Events] */ export type ScreenEvent = IScreenChangeEvent; export type IScreenChangeEvent = { type: '@platform/SCREEN/window/change'; payload: IScreenChange; }; export type IScreenChange = t.IWindowChange & { screen: string };