import type { App } from '@/core/App' ; import type { BrowserWindowOpts } from '@/core/Browser' ; import Browser from '@/core/Browser' ; import type { MainEvents } from '@/common/Events' ; export default class BrowserManager { app : App ; browsers : Map < string , Browser | null > = new Map ( ) ; constructor ( app ) { this . app = app ; } param options retrieveOrInitialize ( options ) { let browser = this . browsers . get ( options . identifier ) ; if ( browser ) { return browser ; } browser = new Browser ( options , this . app ) ; this . browsers . set ( options . identifier , browser ) ; return browser ; } broadcast < T extends keyof MainEvents > ( eventName , data ? ) { this . browsers . forEach ( ( browser ) => { browser ?. dispatchEvent ( eventName , data ) ; } ) ; } }