import * as Electron from 'electron'; import { Type, ObjectUtil } from '@ucap/core'; import { getBrowserWindowSettings } from './decorators/browser-window-configuration'; import { AppConfiguration } from '../app'; import { Attacher } from './attacher'; import { ElectronBrowserWindow } from './electron-browser-window'; export abstract class Builder { static build( configuration: Partial, browserWindowType: Type ): T { const _configuration = getBrowserWindowSettings( ObjectUtil.classOf(browserWindowType) ); const constructorOptions = ObjectUtil.isFunction( _configuration.constructorOptions ) ? _configuration.constructorOptions(configuration) : _configuration.constructorOptions; const _browserWindow = new Electron.BrowserWindow(constructorOptions); const browserWindow = new browserWindowType(_configuration, _browserWindow); Attacher.attach(browserWindow); return browserWindow; } static destroy(instance: T) { Attacher.dettach(instance); } }