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

💄 web api

上级 ef351d15
...@@ -277,13 +277,22 @@ class WorkspaceProvider implements IWorkspaceProvider { ...@@ -277,13 +277,22 @@ class WorkspaceProvider implements IWorkspaceProvider {
(function () { (function () {
// Find config element in DOM // Find config by checking for DOM
const configElement = document.getElementById('vscode-workbench-web-configuration'); const configElement = document.getElementById('vscode-workbench-web-configuration');
const configElementAttribute = configElement ? configElement.getAttribute('data-settings') : undefined; const configElementAttribute = configElement ? configElement.getAttribute('data-settings') : undefined;
if (!configElement || !configElementAttribute) { if (!configElement || !configElementAttribute) {
throw new Error('Missing web configuration element'); 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 // Find workspace to open and payload
let foundWorkspace = false; let foundWorkspace = false;
let workspace: IWorkspace; let workspace: IWorkspace;
...@@ -319,27 +328,21 @@ class WorkspaceProvider implements IWorkspaceProvider { ...@@ -319,27 +328,21 @@ class WorkspaceProvider implements IWorkspaceProvider {
}); });
// If no workspace is provided through the URL, check for config attribute from server // 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 (!foundWorkspace) {
if (options.folderUri) { if (config.folderUri) {
workspace = { folderUri: URI.revive(options.folderUri) }; workspace = { folderUri: URI.revive(config.folderUri) };
} else if (options.workspaceUri) { } else if (config.workspaceUri) {
workspace = { workspaceUri: URI.revive(options.workspaceUri) }; workspace = { workspaceUri: URI.revive(config.workspaceUri) };
} else { } else {
workspace = undefined; 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 // 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'; ...@@ -17,32 +17,49 @@ import { Event, Emitter } from 'vs/base/common/event';
import { Disposable, IDisposable } from 'vs/base/common/lifecycle'; import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
import { IWorkspaceProvider, IWorkspace } from 'vs/workbench/services/host/browser/browserHostService'; 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 { 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. * 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. * 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. * 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. * state like settings, keybindings, UI state (e.g. opened editors) and snippets.
*/ */
userDataProvider?: IFileSystemProvider; userDataProvider?: IFileSystemProvider;
...@@ -50,56 +67,56 @@ interface IWorkbenchConstructionOptions { ...@@ -50,56 +67,56 @@ interface IWorkbenchConstructionOptions {
/** /**
* A factory for web sockets. * A factory for web sockets.
*/ */
webSocketFactory?: IWebSocketFactory; readonly webSocketFactory?: IWebSocketFactory;
/** /**
* A provider for resource URIs. * 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 domElement the container to create the workbench in
* @param options for setting up the workbench * @param options for setting up the workbench
...@@ -136,10 +153,14 @@ export { ...@@ -136,10 +153,14 @@ export {
IWebSocketFactory, IWebSocketFactory,
IWebSocket, IWebSocket,
// Resources
IResourceUriProvider,
// Credentials // Credentials
ICredentialsProvider, ICredentialsProvider,
// Static Extensions // Static Extensions
IStaticExtension,
IExtensionManifest, IExtensionManifest,
// Callbacks // Callbacks
...@@ -151,4 +172,10 @@ export { ...@@ -151,4 +172,10 @@ export {
// Updates // Updates
IUpdateProvider, IUpdateProvider,
IUpdate, IUpdate,
// Telemetry
ICommontTelemetryPropertiesResolver,
// External Uris
IExternalUriResolver
}; };
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册