From ee09c5b254103caebf1a2eeef2c9d57a7f74b95d Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Thu, 6 Aug 2020 23:02:59 +0200 Subject: [PATCH] Add `IWorkbenchConstructionOptions._wrapWebWorkerExtHostInIframe` --- resources/serverless/code-web.js | 15 ++++++++++----- .../extensions/browser/webWorkerExtensionHost.ts | 4 +--- src/vs/workbench/workbench.web.api.ts | 9 ++++++++- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/resources/serverless/code-web.js b/resources/serverless/code-web.js index 7d049200343..305ebeca515 100644 --- a/resources/serverless/code-web.js +++ b/resources/serverless/code-web.js @@ -28,7 +28,8 @@ const args = minimist(process.argv, { boolean: [ 'no-launch', 'help', - 'verbose' + 'verbose', + 'wrap-iframe' ], string: [ 'scheme', @@ -43,6 +44,7 @@ if (args.help) { console.log( 'yarn web [options]\n' + ' --no-launch Do not open VSCode web in the browser\n' + + ' --wrap-iframe Wrap the Web Worker Extension Host in an iframe\n' + ' --scheme Protocol (https or http)\n' + ' --host Remote host\n' + ' --port Remote/Local port\n' + @@ -293,13 +295,16 @@ async function handleRoot(req, res) { fancyLog(`${ansiColors.magenta('Additional extensions')}: ${staticExtensions.map(e => path.basename(e.extensionLocation.path)).join(', ') || 'None'}`); } - const webConfigJSON = escapeAttribute(JSON.stringify({ + const webConfigJSON = { folderUri: folderUri, - staticExtensions - })); + staticExtensions, + }; + if (args['wrap-iframe']) { + webConfigJSON._wrapWebWorkerExtHostInIframe = true; + } const data = (await readFile(WEB_MAIN)).toString() - .replace('{{WORKBENCH_WEB_CONFIGURATION}}', () => webConfigJSON) // use a replace function to avoid that regexp replace patterns ($&, $0, ...) are applied + .replace('{{WORKBENCH_WEB_CONFIGURATION}}', () => escapeAttribute(JSON.stringify(webConfigJSON))) // use a replace function to avoid that regexp replace patterns ($&, $0, ...) are applied .replace('{{WORKBENCH_BUILTIN_EXTENSIONS}}', () => escapeAttribute(JSON.stringify(builtInExtensions))) .replace('{{WEBVIEW_ENDPOINT}}', '') .replace('{{REMOTE_USER_DATA_URI}}', ''); diff --git a/src/vs/workbench/services/extensions/browser/webWorkerExtensionHost.ts b/src/vs/workbench/services/extensions/browser/webWorkerExtensionHost.ts index 08bea3cd734..6b672330aba 100644 --- a/src/vs/workbench/services/extensions/browser/webWorkerExtensionHost.ts +++ b/src/vs/workbench/services/extensions/browser/webWorkerExtensionHost.ts @@ -29,8 +29,6 @@ import { generateUuid } from 'vs/base/common/uuid'; import { canceled, onUnexpectedError } from 'vs/base/common/errors'; import { WEB_WORKER_IFRAME } from 'vs/workbench/services/extensions/common/webWorkerIframe'; -const WRAP_IN_IFRAME = true; - export interface IWebWorkerExtensionHostInitData { readonly autoStart: boolean; readonly extensions: IExtensionDescription[]; @@ -74,7 +72,7 @@ export class WebWorkerExtensionHost extends Disposable implements IExtensionHost public async start(): Promise { if (!this._protocolPromise) { - if (WRAP_IN_IFRAME && platform.isWeb) { + if (platform.isWeb && this._environmentService.options && this._environmentService.options._wrapWebWorkerExtHostInIframe) { this._protocolPromise = this._startInsideIframe(); } else { this._protocolPromise = this._startOutsideIframe(); diff --git a/src/vs/workbench/workbench.web.api.ts b/src/vs/workbench/workbench.web.api.ts index be9efca3cd8..ce168ccdd0a 100644 --- a/src/vs/workbench/workbench.web.api.ts +++ b/src/vs/workbench/workbench.web.api.ts @@ -275,11 +275,18 @@ interface IWorkbenchConstructionOptions { /** * [TEMPORARY]: This will be removed soon. - * Disable the inlined extensions. + * Enable inlined extensions. * Defaults to false on serverful and true on serverless. */ readonly _enableBuiltinExtensions?: boolean; + /** + * [TEMPORARY]: This will be removed soon. + * Enable `