@@ -15,7 +15,6 @@ import { Disposable, DisposableStore, IDisposable } from '../../../base/common/l
15
15
import { FileAccess , Schemas } from '../../../base/common/network.js' ;
16
16
import { isEqual } from '../../../base/common/resources.js' ;
17
17
import { URI , UriComponents } from '../../../base/common/uri.js' ;
18
- import { localize } from '../../../nls.js' ;
19
18
import product from '../../../platform/product/common/product.js' ;
20
19
import { isFolderToOpen , isWorkspaceToOpen } from '../../../platform/window/common/window.js' ;
21
20
import * as vscode from '../../../workbench/workbench.web.main.internal.js' ;
@@ -31,6 +30,7 @@ import { extractLocalHostUriMetaDataForPortMapping, isLocalhost, TunnelPrivacyId
31
30
import { ColorScheme } from '../../../platform/theme/common/theme.js' ;
32
31
import type { TunnelOptions } from 'vscode' ;
33
32
import { importAMDNodeModule } from '../../../amdX.js' ;
33
+ import { mainWindow } from '../../../base/browser/window.js' ;
34
34
35
35
const loadingGrpc = importAMDNodeModule < typeof import ( '@improbable-eng/grpc-web' ) > ( '@improbable-eng/grpc-web' , 'dist/grpc-web-client.umd.js' ) ;
36
36
@@ -46,14 +46,14 @@ export class LocalStorageSecretStorageProvider implements ISecretStorageProvider
46
46
private async load ( ) : Promise < Record < string , string > > {
47
47
const record = this . loadAuthSessionFromElement ( ) ;
48
48
// Get the secrets from localStorage
49
- const encrypted = window . localStorage . getItem ( this . _storageKey ) ;
49
+ const encrypted = mainWindow . localStorage . getItem ( this . _storageKey ) ;
50
50
if ( encrypted ) {
51
51
try {
52
- const decrypted = JSON . parse ( window . gitpod . decrypt ( encrypted ) ) ;
52
+ const decrypted = JSON . parse ( mainWindow . gitpod . decrypt ( encrypted ) ) ;
53
53
return { ...record , ...decrypted } ;
54
54
} catch ( err ) {
55
55
console . error ( 'Failed to decrypt secrets from localStorage' , err ) ;
56
- window . localStorage . removeItem ( this . _storageKey ) ;
56
+ mainWindow . localStorage . removeItem ( this . _storageKey ) ;
57
57
}
58
58
}
59
59
@@ -62,7 +62,7 @@ export class LocalStorageSecretStorageProvider implements ISecretStorageProvider
62
62
63
63
private loadAuthSessionFromElement ( ) : Record < string , string > {
64
64
let authSessionInfo : ( AuthenticationSessionInfo & { scopes : string [ ] [ ] } ) | undefined ;
65
- const authSessionElement = document . getElementById ( 'vscode-workbench-auth-session' ) ;
65
+ const authSessionElement = mainWindow . document . getElementById ( 'vscode-workbench-auth-session' ) ;
66
66
const authSessionElementAttribute = authSessionElement ? authSessionElement . getAttribute ( 'data-settings' ) : undefined ;
67
67
if ( authSessionElementAttribute ) {
68
68
try {
@@ -114,8 +114,8 @@ export class LocalStorageSecretStorageProvider implements ISecretStorageProvider
114
114
115
115
private async save ( ) : Promise < void > {
116
116
try {
117
- const encrypted = window . gitpod . encrypt ( JSON . stringify ( await this . _secretsPromise ) ) ;
118
- window . localStorage . setItem ( this . _storageKey , encrypted ) ;
117
+ const encrypted = mainWindow . gitpod . encrypt ( JSON . stringify ( await this . _secretsPromise ) ) ;
118
+ mainWindow . localStorage . setItem ( this . _storageKey , encrypted ) ;
119
119
} catch ( err ) {
120
120
console . error ( err ) ;
121
121
}
@@ -163,13 +163,13 @@ class LocalStorageURLCallbackProvider extends Disposable implements IURLCallback
163
163
// https://github.com/microsoft/vscode/blob/159479eb5ae451a66b5dac3c12d564f32f454796/extensions/github-authentication/src/githubServer.ts#L50-L50
164
164
if ( ! ( options . authority === 'vscode.github-authentication' && options . path === '/dummy' ) ) {
165
165
const key = `vscode-web.url-callbacks[${ id } ]` ;
166
- window . localStorage . removeItem ( key ) ;
166
+ mainWindow . localStorage . removeItem ( key ) ;
167
167
168
168
this . pendingCallbacks . add ( id ) ;
169
169
this . startListening ( ) ;
170
170
}
171
171
172
- return URI . parse ( window . location . href ) . with ( { path : this . _callbackRoute , query : queryParams . join ( '&' ) } ) ;
172
+ return URI . parse ( mainWindow . location . href ) . with ( { path : this . _callbackRoute , query : queryParams . join ( '&' ) } ) ;
173
173
}
174
174
175
175
private startListening ( ) : void {
@@ -178,8 +178,8 @@ class LocalStorageURLCallbackProvider extends Disposable implements IURLCallback
178
178
}
179
179
180
180
const fn = ( ) => this . onDidChangeLocalStorage ( ) ;
181
- window . addEventListener ( 'storage' , fn ) ;
182
- this . onDidChangeLocalStorageDisposable = { dispose : ( ) => window . removeEventListener ( 'storage' , fn ) } ;
181
+ mainWindow . addEventListener ( 'storage' , fn ) ;
182
+ this . onDidChangeLocalStorageDisposable = { dispose : ( ) => mainWindow . removeEventListener ( 'storage' , fn ) } ;
183
183
}
184
184
185
185
private stopListening ( ) : void {
@@ -207,7 +207,7 @@ class LocalStorageURLCallbackProvider extends Disposable implements IURLCallback
207
207
208
208
for ( const id of this . pendingCallbacks ) {
209
209
const key = `vscode-web.url-callbacks[${ id } ]` ;
210
- const result = window . localStorage . getItem ( key ) ;
210
+ const result = mainWindow . localStorage . getItem ( key ) ;
211
211
212
212
if ( result !== null ) {
213
213
try {
@@ -218,7 +218,7 @@ class LocalStorageURLCallbackProvider extends Disposable implements IURLCallback
218
218
219
219
pendingCallbacks = pendingCallbacks ?? new Set ( this . pendingCallbacks ) ;
220
220
pendingCallbacks . delete ( id ) ;
221
- window . localStorage . removeItem ( key ) ;
221
+ mainWindow . localStorage . removeItem ( key ) ;
222
222
}
223
223
}
224
224
@@ -325,14 +325,14 @@ class WorkspaceProvider implements IWorkspaceProvider {
325
325
const targetHref = this . createTargetUrl ( workspace , options ) ;
326
326
if ( targetHref ) {
327
327
if ( options ?. reuse ) {
328
- window . location . href = targetHref ;
328
+ mainWindow . location . href = targetHref ;
329
329
return true ;
330
330
} else {
331
331
let result ;
332
332
if ( isStandalone ( ) ) {
333
- result = window . open ( targetHref , '_blank' , 'toolbar=no' ) ; // ensures to open another 'standalone' window!
333
+ result = mainWindow . open ( targetHref , '_blank' , 'toolbar=no' ) ; // ensures to open another 'standalone' window!
334
334
} else {
335
- result = window . open ( targetHref ) ;
335
+ result = mainWindow . open ( targetHref ) ;
336
336
}
337
337
338
338
return ! ! result ;
@@ -461,8 +461,8 @@ interface WorkspaceInfoResponse {
461
461
}
462
462
463
463
async function doStart ( ) : Promise < IDisposable > {
464
- let supervisorHost = window . location . host ;
465
- const infoResponse = await fetch ( window . location . protocol + '//' + supervisorHost + '/_supervisor/v1/info/workspace' , {
464
+ const supervisorHost = mainWindow . location . host ;
465
+ const infoResponse = await fetch ( mainWindow . location . protocol + '//' + supervisorHost + '/_supervisor/v1/info/workspace' , {
466
466
credentials : 'include'
467
467
} ) ;
468
468
if ( ! infoResponse . ok ) {
@@ -479,7 +479,7 @@ async function doStart(): Promise<IDisposable> {
479
479
return Disposable . None ;
480
480
}
481
481
482
- const remoteAuthority = window . location . host ;
482
+ const remoteAuthority = mainWindow . location . host ;
483
483
484
484
// To make webviews work in development, go to file src/vs/workbench/contrib/webview/browser/pre/main.js
485
485
// and update `signalReady` method to bypass hostname check
@@ -520,7 +520,7 @@ async function doStart(): Promise<IDisposable> {
520
520
const scopes = [
521
521
'function:accessCodeSyncStorage'
522
522
] ;
523
- const tokenResponse = await fetch ( window . location . protocol + '//' + supervisorHost + '/_supervisor/v1/token/gitpod/' + info . gitpodApi . host + '/' + scopes . join ( ',' ) , {
523
+ const tokenResponse = await fetch ( mainWindow . location . protocol + '//' + supervisorHost + '/_supervisor/v1/token/gitpod/' + info . gitpodApi . host + '/' + scopes . join ( ',' ) , {
524
524
credentials : 'include'
525
525
} ) ;
526
526
if ( _state as any === 'terminated' ) {
@@ -637,11 +637,12 @@ async function doStart(): Promise<IDisposable> {
637
637
if ( ! existing || existing . privacy !== tunnel . privacy ) {
638
638
existing ?. dispose ( false ) ;
639
639
tunnels . set ( status . getRemotePort ( ) , tunnel ) ;
640
- vscode . commands . executeCommand ( 'gitpod.vscode.workspace.openTunnel' , {
640
+ const openTunnelOptions : TunnelOptions = {
641
641
remoteAddress : tunnel . remoteAddress ,
642
642
localAddressPort : tunnel . remoteAddress . port ,
643
643
privacy : tunnel . privacy
644
- } as TunnelOptions ) ;
644
+ } ;
645
+ vscode . commands . executeCommand ( 'gitpod.vscode.workspace.openTunnel' , openTunnelOptions ) ;
645
646
notify = true ;
646
647
}
647
648
}
@@ -778,7 +779,7 @@ async function doStart(): Promise<IDisposable> {
778
779
if ( devMode ) {
779
780
throw new Error ( 'not supported in dev mode' ) ;
780
781
}
781
- return window . gitpod . loggedUserID ;
782
+ return mainWindow . gitpod . loggedUserID ;
782
783
}
783
784
} ;
784
785
@@ -788,7 +789,7 @@ async function doStart(): Promise<IDisposable> {
788
789
if ( ! url || url . length === 0 ) {
789
790
return ;
790
791
}
791
- return window . gitpod . openDesktopIDE ( url ) ;
792
+ return mainWindow . gitpod . openDesktopIDE ( url ) ;
792
793
}
793
794
} ;
794
795
@@ -800,7 +801,7 @@ async function doStart(): Promise<IDisposable> {
800
801
801
802
// Use another element other than window.body, workaround for ipad white bar
802
803
// https://github.com/microsoft/vscode/issues/149048
803
- const workbenchElement = document . getElementById ( 'gp-code-workbench' ) ! ;
804
+ const workbenchElement = mainWindow . document . getElementById ( 'gp-code-workbench' ) ! ;
804
805
subscriptions . add ( vscode . create ( workbenchElement , {
805
806
// subscriptions.add(vscode.create(document.body, {
806
807
remoteAuthority,
@@ -861,11 +862,6 @@ async function doStart(): Promise<IDisposable> {
861
862
uri . query . split ( '&' ) . map ( s => s . split ( / = ( .* ) / s) ) . forEach ( ( [ k , v ] ) => ! ! k && externalEndpoint . searchParams . append ( k . replaceAll ( '+' , ' ' ) , v ?. replaceAll ( '+' , ' ' ) || '' ) ) ;
862
863
return externalEndpoint ;
863
864
} ,
864
- homeIndicator : {
865
- href : info . gitpodHost ,
866
- icon : 'code' ,
867
- title : localize ( 'home' , "Home" )
868
- } ,
869
865
windowIndicator : {
870
866
onDidChange : Event . None ,
871
867
label : `$(gitpod) Gitpod` ,
@@ -934,7 +930,7 @@ async function doStart(): Promise<IDisposable> {
934
930
if ( devMode ) {
935
931
doStart ( ) ;
936
932
} else {
937
- window . gitpod . ideService = {
933
+ mainWindow . gitpod . ideService = {
938
934
get state ( ) {
939
935
return _state ;
940
936
} ,
0 commit comments