提交 21ce78cf 编写于 作者: B Benjamin Pasero

web - lift product config to be proper API

上级 b4679a37
......@@ -16,9 +16,8 @@
<!-- Workbench Configuration -->
<meta id="vscode-workbench-web-configuration" data-settings="{{WORKBENCH_WEB_CONGIGURATION}}">
<!-- Workarounds/Hacks (remote user data uri, product configuration ) -->
<!-- Workarounds/Hacks (remote user data uri) -->
<meta id="vscode-remote-user-data-uri" data-settings="{{REMOTE_USER_DATA_URI}}">
<meta id="vscode-remote-product-configuration" data-settings="{{PRODUCT_CONFIGURATION}}">
<!-- Workbench Icon/CSS -->
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
......
......@@ -18,7 +18,7 @@ import { RemoteAgentService } from 'vs/workbench/services/remote/browser/remoteA
import { RemoteAuthorityResolverService } from 'vs/platform/remote/browser/remoteAuthorityResolverService';
import { IRemoteAuthorityResolverService } from 'vs/platform/remote/common/remoteAuthorityResolver';
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
import { IFileService, IFileSystemProvider } from 'vs/platform/files/common/files';
import { IFileService } from 'vs/platform/files/common/files';
import { FileService } from 'vs/platform/files/common/fileService';
import { Schemas } from 'vs/base/common/network';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
......@@ -124,7 +124,7 @@ class CodeRendererMain extends Disposable {
const logService = new BufferLogService();
serviceCollection.set(ILogService, logService);
const payload = await this.resolveWorkspaceInitializationPayload();
const payload = this.resolveWorkspaceInitializationPayload();
// Environment
const environmentService = new BrowserWorkbenchEnvironmentService({ workspaceId: payload.id, logsPath, ...this.configuration });
......@@ -149,6 +149,34 @@ class CodeRendererMain extends Disposable {
// Files
const fileService = this._register(new FileService(logService));
serviceCollection.set(IFileService, fileService);
this.registerFileSystemProviders(environmentService, fileService, remoteAgentService, logService, logsPath);
// Long running services (workspace, config, storage)
const services = await Promise.all([
this.createWorkspaceService(payload, environmentService, fileService, remoteAgentService, logService).then(service => {
// Workspace
serviceCollection.set(IWorkspaceContextService, service);
// Configuration
serviceCollection.set(IConfigurationService, service);
return service;
}),
this.createStorageService(payload, environmentService, fileService, logService).then(service => {
// Storage
serviceCollection.set(IStorageService, service);
return service;
})
]);
return { serviceCollection, logService, storageService: services[1] };
}
private registerFileSystemProviders(environmentService: IWorkbenchEnvironmentService, fileService: IFileService, remoteAgentService: IRemoteAgentService, logService: BufferLogService, logsPath: URI): void {
// Logger
const indexedDBLogProvider = new IndexedDBLogProvider(logsPath.scheme);
......@@ -169,61 +197,38 @@ class CodeRendererMain extends Disposable {
logService.logger = new MultiplexLogService([consoleLogService, fileLogService]);
})();
// User Data Provider
let userDataProvider: IFileSystemProvider | undefined = this.configuration.userDataProvider;
const connection = remoteAgentService.getConnection();
if (connection) {
// Remote file system
const channel = connection.getChannel<IChannel>(REMOTE_FILE_SYSTEM_CHANNEL_NAME);
const remoteFileSystemProvider = this._register(new RemoteExtensionsFileSystemProvider(channel, remoteAgentService.getEnvironment()));
fileService.registerProvider(Schemas.vscodeRemote, remoteFileSystemProvider);
if (!userDataProvider) {
if (!this.configuration.userDataProvider) {
const remoteUserDataUri = this.getRemoteUserDataUri();
if (remoteUserDataUri) {
userDataProvider = this._register(new FileUserDataProvider(remoteUserDataUri, joinPath(remoteUserDataUri, BACKUPS), remoteFileSystemProvider, environmentService));
this.configuration.userDataProvider = this._register(new FileUserDataProvider(remoteUserDataUri, joinPath(remoteUserDataUri, BACKUPS), remoteFileSystemProvider, environmentService));
}
}
}
if (!userDataProvider) {
userDataProvider = this._register(new InMemoryUserDataProvider());
}
fileService.registerProvider(Schemas.userData, userDataProvider);
// Long running services (workspace, config, storage)
const services = await Promise.all([
this.createWorkspaceService(payload, environmentService, fileService, remoteAgentService, logService).then(service => {
// Workspace
serviceCollection.set(IWorkspaceContextService, service);
// Configuration
serviceCollection.set(IConfigurationService, service);
return service;
}),
this.createStorageService(payload, environmentService, fileService, logService).then(service => {
// Storage
serviceCollection.set(IStorageService, service);
return service;
})
]);
return { serviceCollection, logService, storageService: services[1] };
// User data
if (!this.configuration.userDataProvider) {
this.configuration.userDataProvider = this._register(new InMemoryUserDataProvider());
}
fileService.registerProvider(Schemas.userData, this.configuration.userDataProvider);
}
private createProductService(): IProductService {
const element = document.getElementById('vscode-remote-product-configuration');
const productConfiguration: IProductConfiguration = {
...element ? JSON.parse(element.getAttribute('data-settings')!) : {
const productConfiguration = {
...this.configuration.productConfiguration ? this.configuration.productConfiguration : {
version: '1.38.0-unknown',
nameLong: 'Unknown',
extensionAllowedProposedApi: [],
}, ...{ urlProtocol: '' }
};
} as IProductConfiguration;
return { _serviceBrand: undefined, ...productConfiguration };
}
......@@ -280,6 +285,7 @@ class CodeRendererMain extends Disposable {
return joinPath(URI.revive(JSON.parse(remoteUserDataPath)), 'User');
}
}
return null;
}
}
......
......@@ -11,6 +11,7 @@ import { IWebSocketFactory } from 'vs/platform/remote/browser/browserSocketFacto
import { ICredentialsProvider } from 'vs/workbench/services/credentials/browser/credentialsService';
import { IExtensionManifest } from 'vs/platform/extensions/common/extensions';
import { IURLCallbackProvider } from 'vs/workbench/services/url/browser/urlService';
import { IProductConfiguration } from 'vs/platform/product/common/product';
export interface IWorkbenchConstructionOptions {
......@@ -71,6 +72,11 @@ export interface IWorkbenchConstructionOptions {
* Experimental: Support for URL callbacks.
*/
urlCallbackProvider?: IURLCallbackProvider;
/**
* Experimental: Support for product configuration.
*/
productConfiguration?: IProductConfiguration;
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册