66import { assign } from 'vs/base/common/objects' ;
77import { memoize } from 'vs/base/common/decorators' ;
88import { IEnvironmentService } from 'vs/platform/environment/common/environment' ;
9- import { BrowserWindow , ipcMain } from 'electron' ;
9+ import { BrowserWindow , ipcMain , WebContents , Event as ElectronEvent } from 'electron' ;
1010import { ISharedProcess } from 'vs/platform/ipc/electron-main/sharedProcessMainService' ;
1111import { Barrier } from 'vs/base/common/async' ;
1212import { ILogService } from 'vs/platform/log/common/log' ;
1313import { ILifecycleMainService } from 'vs/platform/lifecycle/electron-main/lifecycleMainService' ;
1414import { IThemeMainService } from 'vs/platform/theme/electron-main/themeMainService' ;
1515import { toDisposable , DisposableStore } from 'vs/base/common/lifecycle' ;
16+ import { Event } from 'vs/base/common/event' ;
1617
1718export class SharedProcess implements ISharedProcess {
1819
@@ -53,7 +54,7 @@ export class SharedProcess implements ISharedProcess {
5354 this . window . loadURL ( url ) ;
5455
5556 // Prevent the window from dying
56- const onClose = ( e : Event ) => {
57+ const onClose = ( e : ElectronEvent ) => {
5758 this . logService . trace ( 'SharedProcess#close prevented' ) ;
5859
5960 // We never allow to close the shared process unless we get explicitly disposed()
@@ -97,7 +98,8 @@ export class SharedProcess implements ISharedProcess {
9798 } ) ;
9899
99100 return new Promise < void > ( c => {
100- ipcMain . once ( 'handshake:hello' , ( { sender } : { sender : any } ) => {
101+ const onHello = Event . once ( Event . fromNodeEventEmitter ( ipcMain , 'handshake:hello' , ( { sender } : { sender : WebContents } ) => sender ) ) ;
102+ disposables . add ( onHello ( sender => {
101103 sender . send ( 'handshake:hey there' , {
102104 sharedIPCHandle : this . environmentService . sharedIPCHandle ,
103105 args : this . environmentService . args ,
@@ -106,7 +108,7 @@ export class SharedProcess implements ISharedProcess {
106108
107109 disposables . add ( toDisposable ( ( ) => sender . send ( 'handshake:goodbye' ) ) ) ;
108110 ipcMain . once ( 'handshake:im ready' , ( ) => c ( undefined ) ) ;
109- } ) ;
111+ } ) ) ;
110112 } ) ;
111113 }
112114
0 commit comments