66import { addClass , addDisposableListener } from 'vs/base/browser/dom' ;
77import { Emitter } from 'vs/base/common/event' ;
88import { Disposable } from 'vs/base/common/lifecycle' ;
9+ import { isWeb } from 'vs/base/common/platform' ;
910import { URI } from 'vs/base/common/uri' ;
1011import { IConfigurationService } from 'vs/platform/configuration/common/configuration' ;
1112import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions' ;
1213import { IFileService } from 'vs/platform/files/common/files' ;
13- import { IProductService } from 'vs/platform/product/common/productService' ;
1414import { ITunnelService } from 'vs/platform/remote/common/tunnel' ;
1515import { ITheme , IThemeService } from 'vs/platform/theme/common/themeService' ;
1616import { Webview , WebviewContentOptions , WebviewOptions } from 'vs/workbench/contrib/webview/browser/webview' ;
@@ -19,7 +19,6 @@ import { WebviewPortMappingManager } from 'vs/workbench/contrib/webview/common/p
1919import { loadLocalResource } from 'vs/workbench/contrib/webview/common/resourceLoader' ;
2020import { getWebviewThemeData } from 'vs/workbench/contrib/webview/common/themeing' ;
2121import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService' ;
22- import { isWeb } from 'vs/base/common/platform' ;
2322
2423interface WebviewContent {
2524 readonly html : string ;
@@ -46,11 +45,10 @@ export class IFrameWebview extends Disposable implements Webview {
4645 @IWorkbenchEnvironmentService private readonly environmentService : IWorkbenchEnvironmentService ,
4746 @IFileService private readonly fileService : IFileService ,
4847 @IConfigurationService private readonly _configurationService : IConfigurationService ,
49- @IProductService private readonly _productService : IProductService
5048 ) {
5149 super ( ) ;
52- if ( ! this . useExternalEndpoint && ( ! environmentService . options || typeof environmentService . options . webviewEndpoint !== 'string' ) ) {
53- throw new Error ( 'To use iframe based webviews, you must configure `environmentService.webviewEndpoint `' ) ;
50+ if ( ! this . useExternalEndpoint && ( ! environmentService . options || typeof environmentService . webviewExternalEndpoint !== 'string' ) ) {
51+ throw new Error ( 'To use iframe based webviews, you must configure `environmentService.webviewExternalEndpoint `' ) ;
5452 }
5553
5654 this . _portMappingManager = this . _register ( new WebviewPortMappingManager (
@@ -67,7 +65,7 @@ export class IFrameWebview extends Disposable implements Webview {
6765
6866 this . element = document . createElement ( 'iframe' ) ;
6967 this . element . sandbox . add ( 'allow-scripts' , 'allow-same-origin' ) ;
70- this . element . setAttribute ( 'src' , `${ this . endpoint } /index.html?id=${ this . id } ` ) ;
68+ this . element . setAttribute ( 'src' , `${ this . externalEndpoint } /index.html?id=${ this . id } ` ) ;
7169 this . element . style . border = 'none' ;
7270 this . element . style . width = '100%' ;
7371 this . element . style . height = '100%' ;
@@ -145,24 +143,14 @@ export class IFrameWebview extends Disposable implements Webview {
145143 this . _register ( themeService . onThemeChange ( this . style , this ) ) ;
146144 }
147145
148- private get endpoint ( ) : string {
149- const baseEndpoint = this . externalEndpoint || this . environmentService . options ! . webviewEndpoint ! ;
150- const endpoint = baseEndpoint . replace ( '{{uuid}}' , this . id ) ;
146+ private get externalEndpoint ( ) : string {
147+ const endpoint = this . environmentService . webviewExternalEndpoint ! . replace ( '{{uuid}}' , this . id ) ;
151148 if ( endpoint [ endpoint . length - 1 ] === '/' ) {
152149 return endpoint . slice ( 0 , endpoint . length - 1 ) ;
153150 }
154151 return endpoint ;
155152 }
156153
157- private get externalEndpoint ( ) : string | undefined {
158- const useExternalEndpoint = this . useExternalEndpoint ;
159- if ( ! useExternalEndpoint ) {
160- return undefined ;
161- }
162- const commit = this . _productService . quality && this . _productService . commit ? this . _productService . commit : '211fa02efe8c041fd7baa8ec3dce199d5185aa44' ;
163- return `https://{{uuid}}.vscode-webview-test.com/${ commit } ` ;
164- }
165-
166154 private get useExternalEndpoint ( ) : boolean {
167155 return isWeb || this . _configurationService . getValue < boolean > ( 'webview.experimental.useExternalEndpoint' ) ;
168156 }
@@ -197,7 +185,7 @@ export class IFrameWebview extends Disposable implements Webview {
197185
198186 private preprocessHtml ( value : string ) : string {
199187 return value . replace ( / ( [ " ' ] ) v s c o d e - r e s o u r c e : ( [ ^ \s ' " ] + ?) ( [ " ' ] ) / gi, ( _ , startQuote , path , endQuote ) =>
200- `${ startQuote } ${ this . endpoint } /vscode-resource${ path } ${ endQuote } ` ) ;
188+ `${ startQuote } ${ this . externalEndpoint } /vscode-resource${ path } ${ endQuote } ` ) ;
201189 }
202190
203191 public update ( html : string , options : WebviewContentOptions , retainContextWhenHidden : boolean ) {
@@ -217,7 +205,7 @@ export class IFrameWebview extends Disposable implements Webview {
217205 contents : this . content . html ,
218206 options : this . content . options ,
219207 state : this . content . state ,
220- endpoint : this . endpoint ,
208+ endpoint : this . externalEndpoint ,
221209 } ) ;
222210 }
223211
0 commit comments