web - first cut API
This commit is contained in:
parent
770c8d50ef
commit
c255f9efba
8 changed files with 79 additions and 60 deletions
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "code-oss-dev",
|
||||
"version": "1.36.0",
|
||||
"distro": "8a2c96a9296c1b8112a4d0e74c0b10063c1a8d44",
|
||||
"distro": "5fc996cf23a90ee6ea8d55df47948fcccfd7b613",
|
||||
"author": {
|
||||
"name": "Microsoft Corporation"
|
||||
},
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -10,14 +10,17 @@
|
|||
<body class="vs-dark" aria-label="">
|
||||
</body>
|
||||
|
||||
<!-- Startup via workbench.js -->
|
||||
<!-- Require our AMD loader -->
|
||||
<script src="./out/vs/loader.js"></script>
|
||||
|
||||
<!-- Window Configuration from Server -->
|
||||
<script>
|
||||
self.CONNECTION_AUTH_TOKEN = '{{CONNECTION_AUTH_TOKEN}}';
|
||||
self.WINDOW_CONFIGURATION = {
|
||||
connectionAuthToken: '{{CONNECTION_AUTH_TOKEN}}',
|
||||
folderUri: '{{FOLDER}}',
|
||||
workspaceUri: '{{WORKSPACE}}',
|
||||
userDataUri: '{{USER_DATA}}',
|
||||
authority: '{{AUTHORITY}}',
|
||||
remoteAuthority: '{{AUTHORITY}}',
|
||||
webviewEndpoint: '{{WEBVIEW_ENDPOINT}}'
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -8,17 +8,6 @@
|
|||
|
||||
(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`,
|
||||
|
@ -32,15 +21,9 @@
|
|||
});
|
||||
|
||||
// @ts-ignore
|
||||
require([
|
||||
'vs/workbench/workbench.web.main',
|
||||
'vs/nls!vs/workbench/workbench.web.main',
|
||||
'vs/css!vs/workbench/workbench.web.main'
|
||||
],
|
||||
require(['vs/workbench/workbench.web.api'], function () {
|
||||
// @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);
|
||||
});
|
||||
})();
|
|
@ -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<ISignService>;
|
||||
|
||||
async sign(value: string): Promise<string> {
|
||||
return Promise.resolve((<any>self).CONNECTION_AUTH_TOKEN);
|
||||
return Promise.resolve((<any>self).WINDOW_CONFIGURATION.connectionAuthToken);
|
||||
}
|
||||
}
|
|
@ -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<void> {
|
||||
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<void> {
|
||||
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();
|
||||
}
|
31
src/vs/workbench/workbench.web.api.ts
Normal file
31
src/vs/workbench/workbench.web.api.ts
Normal file
|
@ -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<void> {
|
||||
return main(domElement, options);
|
||||
}
|
||||
|
||||
const api: any = self;
|
||||
|
||||
api.monaco = {
|
||||
workbench: {
|
||||
create
|
||||
}
|
||||
};
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue