diff --git a/package.json b/package.json index 7f64838dee7..0a7864db4e0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "code-oss-dev", "version": "1.36.0", - "distro": "8a2c96a9296c1b8112a4d0e74c0b10063c1a8d44", + "distro": "5fc996cf23a90ee6ea8d55df47948fcccfd7b613", "author": { "name": "Microsoft Corporation" }, diff --git a/src/buildfile.js b/src/buildfile.js index a7c0376985e..62b2f30c0e4 100644 --- a/src/buildfile.js +++ b/src/buildfile.js @@ -12,7 +12,7 @@ exports.base = [{ }]; exports.workbench = require('./vs/workbench/buildfile').collectModules(['vs/workbench/workbench.main']); -exports.workbenchWeb = require('./vs/workbench/buildfile').collectModules(['vs/workbench/workbench.web.main']); +exports.workbenchWeb = require('./vs/workbench/buildfile').collectModules(['vs/workbench/workbench.web.api']); exports.code = require('./vs/code/buildfile').collectModules(); diff --git a/src/vs/code/browser/workbench/workbench.html b/src/vs/code/browser/workbench/workbench.html index 8a35fe1ee16..316826eea67 100644 --- a/src/vs/code/browser/workbench/workbench.html +++ b/src/vs/code/browser/workbench/workbench.html @@ -10,14 +10,17 @@ - + + + + diff --git a/src/vs/code/browser/workbench/workbench.js b/src/vs/code/browser/workbench/workbench.js index 17ac4fef8ad..8809f830a5a 100644 --- a/src/vs/code/browser/workbench/workbench.js +++ b/src/vs/code/browser/workbench/workbench.js @@ -8,39 +8,22 @@ (function () { - function loadScript(path, callback) { - let script = document.createElement('script'); - script.onload = callback; - script.async = true; - script.type = 'text/javascript'; - script.src = path; - document.head.appendChild(script); - } - - loadScript('./out/vs/loader.js', function () { + // @ts-ignore + require.config({ + baseUrl: `${window.location.origin}/out`, + paths: { + 'vscode-textmate': `${window.location.origin}/node_modules/vscode-textmate/release/main`, + 'onigasm-umd': `${window.location.origin}/node_modules/onigasm-umd/release/main`, + 'xterm': `${window.location.origin}/node_modules/xterm/lib/xterm.js`, + 'xterm-addon-search': `${window.location.origin}/node_modules/xterm-addon-search/lib/xterm-addon-search.js`, + 'xterm-addon-web-links': `${window.location.origin}/node_modules/xterm-addon-web-links/lib/xterm-addon-web-links.js`, + } + }); + // @ts-ignore + require(['vs/workbench/workbench.web.api'], function () { // @ts-ignore - require.config({ - baseUrl: `${window.location.origin}/out`, - paths: { - 'vscode-textmate': `${window.location.origin}/node_modules/vscode-textmate/release/main`, - 'onigasm-umd': `${window.location.origin}/node_modules/onigasm-umd/release/main`, - 'xterm': `${window.location.origin}/node_modules/xterm/lib/xterm.js`, - 'xterm-addon-search': `${window.location.origin}/node_modules/xterm-addon-search/lib/xterm-addon-search.js`, - 'xterm-addon-web-links': `${window.location.origin}/node_modules/xterm-addon-web-links/lib/xterm-addon-web-links.js`, - } - }); - - // @ts-ignore - require([ - 'vs/workbench/workbench.web.main', - 'vs/nls!vs/workbench/workbench.web.main', - 'vs/css!vs/workbench/workbench.web.main' - ], - // @ts-ignore - function () { - // @ts-ignore - require('vs/workbench/browser/web.main').main(self['WINDOW_CONFIGURATION']).then(undefined, console.error); - }); + // eslint-disable-next-line no-undef + monaco.workbench.create(document.body, self.WINDOW_CONFIGURATION); }); })(); \ No newline at end of file diff --git a/src/vs/platform/sign/browser/signService.ts b/src/vs/platform/sign/browser/signService.ts index 20ee67f6064..46447b5e923 100644 --- a/src/vs/platform/sign/browser/signService.ts +++ b/src/vs/platform/sign/browser/signService.ts @@ -4,11 +4,13 @@ *--------------------------------------------------------------------------------------------*/ import { ISignService } from 'vs/platform/sign/common/sign'; +import { ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation'; export class SignService implements ISignService { - _serviceBrand: any; + + _serviceBrand: ServiceIdentifier; async sign(value: string): Promise { - return Promise.resolve((self).CONNECTION_AUTH_TOKEN); + return Promise.resolve((self).WINDOW_CONFIGURATION.connectionAuthToken); } } \ No newline at end of file diff --git a/src/vs/workbench/browser/web.main.ts b/src/vs/workbench/browser/web.main.ts index ec54aaab3e8..4c03d31203d 100644 --- a/src/vs/workbench/browser/web.main.ts +++ b/src/vs/workbench/browser/web.main.ts @@ -24,7 +24,7 @@ import { Schemas } from 'vs/base/common/network'; import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { onUnexpectedError } from 'vs/base/common/errors'; -import { URI, UriComponents } from 'vs/base/common/uri'; +import { URI } from 'vs/base/common/uri'; import { IWorkspaceInitializationPayload } from 'vs/platform/workspaces/common/workspaces'; import { WorkspaceService } from 'vs/workbench/services/configuration/browser/configurationService'; import { ConfigurationCache } from 'vs/workbench/services/configuration/browser/configurationCache'; @@ -34,21 +34,27 @@ import { ISignService } from 'vs/platform/sign/common/sign'; import { SignService } from 'vs/platform/sign/browser/signService'; import { hash } from 'vs/base/common/hash'; import { joinPath } from 'vs/base/common/resources'; +import { IWorkbenchConstructionOptions } from 'vs/workbench/workbench.web.api'; interface IWindowConfiguration { remoteAuthority: string; userDataUri: URI; + + webviewEndpoint?: string; + folderUri?: URI; workspaceUri?: URI; - webviewEndpoint?: string; } class CodeRendererMain extends Disposable { private workbench: Workbench; - constructor(private readonly configuration: IWindowConfiguration) { + constructor( + private readonly domElement: HTMLElement, + private readonly configuration: IWindowConfiguration + ) { super(); } @@ -60,7 +66,7 @@ class CodeRendererMain extends Disposable { // Create Workbench this.workbench = new Workbench( - document.body, + this.domElement, services.serviceCollection, services.logService ); @@ -186,23 +192,16 @@ class CodeRendererMain extends Disposable { } } -export interface IWindowConfigurationContents { - authority: string; - userDataUri: UriComponents; - folderUri?: UriComponents; - workspaceUri?: UriComponents; - webviewEndpoint?: string; -} +export function main(domElement: HTMLElement, options: IWorkbenchConstructionOptions): Promise { + const renderer = new CodeRendererMain( + domElement, + { + userDataUri: URI.revive(options.userDataUri), + remoteAuthority: options.remoteAuthority, + webviewEndpoint: options.webviewEndpoint, + folderUri: options.folderUri ? URI.revive(options.folderUri) : undefined, + workspaceUri: options.workspaceUri ? URI.revive(options.workspaceUri) : undefined, + }); -export function main(windowConfigurationContents: IWindowConfigurationContents): Promise { - const windowConfiguration: IWindowConfiguration = { - userDataUri: URI.revive(windowConfigurationContents.userDataUri), - remoteAuthority: windowConfigurationContents.authority, - folderUri: windowConfigurationContents.folderUri ? URI.revive(windowConfigurationContents.folderUri) : undefined, - workspaceUri: windowConfigurationContents.workspaceUri ? URI.revive(windowConfigurationContents.workspaceUri) : undefined, - webviewEndpoint: windowConfigurationContents.webviewEndpoint - }; - - const renderer = new CodeRendererMain(windowConfiguration); return renderer.open(); } \ No newline at end of file diff --git a/src/vs/workbench/workbench.web.api.ts b/src/vs/workbench/workbench.web.api.ts new file mode 100644 index 00000000000..3085d6a4875 --- /dev/null +++ b/src/vs/workbench/workbench.web.api.ts @@ -0,0 +1,31 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import 'vs/workbench/workbench.web.main'; +import { main } from 'vs/workbench/browser/web.main'; +import { UriComponents } from 'vs/base/common/uri'; + +export interface IWorkbenchConstructionOptions { + remoteAuthority: string; + + userDataUri: UriComponents; + + webviewEndpoint?: string; + + folderUri?: UriComponents; + workspaceUri?: UriComponents; +} + +function create(domElement: HTMLElement, options: IWorkbenchConstructionOptions): Promise { + return main(domElement, options); +} + +const api: any = self; + +api.monaco = { + workbench: { + create + } +}; \ No newline at end of file diff --git a/tslint.json b/tslint.json index 2b9cbdbbb02..844f1999999 100644 --- a/tslint.json +++ b/tslint.json @@ -364,6 +364,7 @@ "**/vs/platform/*/{common,browser}/**", "**/vs/editor/{common,browser}/**", "**/vs/editor/contrib/**", // editor/contrib is equivalent to /browser/ by convention + "**/vs/workbench/workbench.web.api", "**/vs/workbench/{common,browser}/**", "**/vs/workbench/services/*/{common,browser}/**", "assert"