提交 a5d47335 编写于 作者: B Benjamin Pasero

💄 web api

上级 ef351d15
......@@ -277,13 +277,22 @@ class WorkspaceProvider implements IWorkspaceProvider {
(function () {
// Find config element in DOM
// Find config by checking for DOM
const configElement = document.getElementById('vscode-workbench-web-configuration');
const configElementAttribute = configElement ? configElement.getAttribute('data-settings') : undefined;
if (!configElement || !configElementAttribute) {
throw new Error('Missing web configuration element');
}
const config: IWorkbenchConstructionOptions & { folderUri?: UriComponents, workspaceUri?: UriComponents } = JSON.parse(configElementAttribute);
// Revive static extension locations
if (Array.isArray(config.staticExtensions)) {
config.staticExtensions.forEach(extension => {
extension.extensionLocation = URI.revive(extension.extensionLocation);
});
}
// Find workspace to open and payload
let foundWorkspace = false;
let workspace: IWorkspace;
......@@ -319,27 +328,21 @@ class WorkspaceProvider implements IWorkspaceProvider {
});
// If no workspace is provided through the URL, check for config attribute from server
const options: IWorkbenchConstructionOptions & { folderUri?: UriComponents, workspaceUri?: UriComponents } = JSON.parse(configElementAttribute);
if (!foundWorkspace) {
if (options.folderUri) {
workspace = { folderUri: URI.revive(options.folderUri) };
} else if (options.workspaceUri) {
workspace = { workspaceUri: URI.revive(options.workspaceUri) };
if (config.folderUri) {
workspace = { folderUri: URI.revive(config.folderUri) };
} else if (config.workspaceUri) {
workspace = { workspaceUri: URI.revive(config.workspaceUri) };
} else {
workspace = undefined;
}
}
options.workspaceProvider = new WorkspaceProvider(workspace, payload);
options.urlCallbackProvider = new PollingURLCallbackProvider();
options.credentialsProvider = new LocalStorageCredentialsProvider();
if (Array.isArray(options.staticExtensions)) {
options.staticExtensions.forEach(extension => {
extension.extensionLocation = URI.revive(extension.extensionLocation);
});
}
// Finally create workbench
create(document.body, options);
create(document.body, {
...config,
workspaceProvider: new WorkspaceProvider(workspace, payload),
urlCallbackProvider: new PollingURLCallbackProvider(),
credentialsProvider: new LocalStorageCredentialsProvider()
});
})();
......@@ -17,32 +17,49 @@ import { Event, Emitter } from 'vs/base/common/event';
import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
import { IWorkspaceProvider, IWorkspace } from 'vs/workbench/services/host/browser/browserHostService';
interface IResourceUriProvider {
(uri: URI): URI;
}
interface IStaticExtension {
packageJSON: IExtensionManifest;
extensionLocation: URI;
}
interface ICommontTelemetryPropertiesResolver {
(): { [key: string]: any };
}
interface IExternalUriResolver {
(uri: URI): Promise<URI>;
}
interface IWorkbenchConstructionOptions {
/**
* Experimental: the remote authority is the IP:PORT from where the workbench is served
* The remote authority is the IP:PORT from where the workbench is served
* from. It is for example being used for the websocket connections as address.
*/
remoteAuthority?: string;
readonly remoteAuthority?: string;
/**
* The connection token to send to the server.
*/
connectionToken?: string;
readonly connectionToken?: string;
/**
* Experimental: An endpoint to serve iframe content ("webview") from. This is required
* An endpoint to serve iframe content ("webview") from. This is required
* to provide full security isolation from the workbench host.
*/
webviewEndpoint?: string;
readonly webviewEndpoint?: string;
/**
* Experimental: a handler for opening workspaces and providing the initial workspace.
* A handler for opening workspaces and providing the initial workspace.
*/
workspaceProvider?: IWorkspaceProvider;
readonly workspaceProvider?: IWorkspaceProvider;
/**
* Experimental: The userDataProvider is used to handle user specific application
* The user data provider is used to handle user specific application
* state like settings, keybindings, UI state (e.g. opened editors) and snippets.
*/
userDataProvider?: IFileSystemProvider;
......@@ -50,56 +67,56 @@ interface IWorkbenchConstructionOptions {
/**
* A factory for web sockets.
*/
webSocketFactory?: IWebSocketFactory;
readonly webSocketFactory?: IWebSocketFactory;
/**
* A provider for resource URIs.
*/
resourceUriProvider?: (uri: URI) => URI;
readonly resourceUriProvider?: IResourceUriProvider;
/**
* Experimental: Whether to enable the smoke test driver.
* The credentials provider to store and retrieve secrets.
*/
driver?: boolean;
readonly credentialsProvider?: ICredentialsProvider;
/**
* Experimental: The credentials provider to store and retrieve secrets.
* Add static extensions that cannot be uninstalled but only be disabled.
*/
credentialsProvider?: ICredentialsProvider;
readonly staticExtensions?: ReadonlyArray<IStaticExtension>;
/**
* Experimental: Add static extensions that cannot be uninstalled but only be disabled.
* Support for URL callbacks.
*/
staticExtensions?: { packageJSON: IExtensionManifest, extensionLocation: URI }[];
readonly urlCallbackProvider?: IURLCallbackProvider;
/**
* Experimental: Support for URL callbacks.
* Support for update reporting.
*/
urlCallbackProvider?: IURLCallbackProvider;
readonly updateProvider?: IUpdateProvider;
/**
* Current logging level. Default is `LogLevel.Info`.
* Support adding additional properties to telemetry.
*/
logLevel?: LogLevel;
readonly resolveCommonTelemetryProperties?: ICommontTelemetryPropertiesResolver;
/**
* Experimental: Support for update reporting.
* Resolves an external uri before it is opened.
*/
updateProvider?: IUpdateProvider;
readonly resolveExternalUri?: IExternalUriResolver;
/**
* Experimental: Support adding additional properties to telemetry.
* Current logging level. Default is `LogLevel.Info`.
*/
resolveCommonTelemetryProperties?: () => { [key: string]: any };
readonly logLevel?: LogLevel;
/**
* Experimental: Resolves an external uri before it is opened.
* Whether to enable the smoke test driver.
*/
readonly resolveExternalUri?: (uri: URI) => Promise<URI>;
readonly driver?: boolean;
}
/**
* Experimental: Creates the workbench with the provided options in the provided container.
* Creates the workbench with the provided options in the provided container.
*
* @param domElement the container to create the workbench in
* @param options for setting up the workbench
......@@ -136,10 +153,14 @@ export {
IWebSocketFactory,
IWebSocket,
// Resources
IResourceUriProvider,
// Credentials
ICredentialsProvider,
// Static Extensions
IStaticExtension,
IExtensionManifest,
// Callbacks
......@@ -151,4 +172,10 @@ export {
// Updates
IUpdateProvider,
IUpdate,
// Telemetry
ICommontTelemetryPropertiesResolver,
// External Uris
IExternalUriResolver
};
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册