@@ -21,17 +21,21 @@ export class SharedProcess implements ISharedProcess {
21
21
22
22
private window : BrowserWindow | null = null ;
23
23
24
+ private readonly _whenReady : Promise < void > ;
25
+
24
26
constructor (
25
27
private readonly machineId : string ,
26
28
private userEnv : NodeJS . ProcessEnv ,
27
29
@IEnvironmentService private readonly environmentService : IEnvironmentService ,
28
30
@ILifecycleMainService private readonly lifecycleMainService : ILifecycleMainService ,
29
31
@ILogService private readonly logService : ILogService ,
30
32
@IThemeMainService private readonly themeMainService : IThemeMainService
31
- ) { }
33
+ ) {
34
+ this . _whenReady = new Promise < void > ( c => ipcMain . once ( 'handshake:sharedprocess-init-ready' , ( ) => c ( undefined ) ) ) ;
35
+ }
32
36
33
37
@memoize
34
- private get _whenReady ( ) : Promise < void > {
38
+ private get _whenIpcReady ( ) : Promise < void > {
35
39
this . window = new BrowserWindow ( {
36
40
show : false ,
37
41
backgroundColor : this . themeMainService . getBackgroundColor ( ) ,
@@ -98,16 +102,16 @@ export class SharedProcess implements ISharedProcess {
98
102
} ) ;
99
103
100
104
return new Promise < void > ( c => {
101
- const onHello = Event . once ( Event . fromNodeEventEmitter ( ipcMain , 'handshake:hello' , ( { sender } : { sender : WebContents } ) => sender ) ) ;
105
+ const onHello = Event . once ( Event . fromNodeEventEmitter ( ipcMain , 'handshake:sharedprocess- hello' , ( { sender } : { sender : WebContents } ) => sender ) ) ;
102
106
disposables . add ( onHello ( sender => {
103
- sender . send ( 'handshake:hey there ' , {
107
+ sender . send ( 'handshake:main-payload ' , {
104
108
sharedIPCHandle : this . environmentService . sharedIPCHandle ,
105
109
args : this . environmentService . args ,
106
110
logLevel : this . logService . getLevel ( )
107
111
} ) ;
108
112
109
- disposables . add ( toDisposable ( ( ) => sender . send ( 'handshake:goodbye' ) ) ) ;
110
- ipcMain . once ( 'handshake:im ready' , ( ) => c ( undefined ) ) ;
113
+ disposables . add ( toDisposable ( ( ) => sender . send ( 'handshake:mainprocess- goodbye' ) ) ) ;
114
+ ipcMain . once ( 'handshake:sharedprocess-ipc- ready' , ( ) => c ( undefined ) ) ;
111
115
} ) ) ;
112
116
} ) ;
113
117
}
@@ -122,6 +126,11 @@ export class SharedProcess implements ISharedProcess {
122
126
await this . _whenReady ;
123
127
}
124
128
129
+ async whenIpcReady ( ) : Promise < void > {
130
+ await this . barrier . wait ( ) ;
131
+ await this . _whenIpcReady ;
132
+ }
133
+
125
134
toggle ( ) : void {
126
135
if ( ! this . window || this . window . isVisible ( ) ) {
127
136
this . hide ( ) ;
0 commit comments