web - introduce browser environment service

Hello first commit from browser :)
This commit is contained in:
Benjamin Pasero 2019-06-18 16:01:39 +02:00
parent 23465510ae
commit ad41bd2674
9 changed files with 155 additions and 149 deletions

View file

@ -15,7 +15,7 @@
<!-- Window Configuration from Server -->
<script>
self.WINDOW_CONFIGURATION = {
self.WORKBENCH_WEB_CONFIGURATION = {
connectionAuthToken: '{{CONNECTION_AUTH_TOKEN}}',
folderUri: '{{FOLDER}}',
workspaceUri: '{{WORKSPACE}}',

View file

@ -24,6 +24,6 @@
require(['vs/workbench/workbench.web.api'], function () {
// @ts-ignore
// eslint-disable-next-line no-undef
monaco.workbench.create(document.body, self.WINDOW_CONFIGURATION);
monaco.workbench.create(document.body, self.WORKBENCH_WEB_CONFIGURATION);
});
})();

View file

@ -11,6 +11,6 @@ export class SignService implements ISignService {
_serviceBrand: ServiceIdentifier<ISignService>;
async sign(value: string): Promise<string> {
return Promise.resolve((<any>self).WINDOW_CONFIGURATION.connectionAuthToken);
return Promise.resolve((<any>self).WORKBENCH_WEB_CONFIGURATION.connectionAuthToken);
}
}

View file

@ -8,7 +8,8 @@ import { domContentLoaded, addDisposableListener, EventType } from 'vs/base/brow
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { ILogService } from 'vs/platform/log/common/log';
import { Disposable } from 'vs/base/common/lifecycle';
import { SimpleLogService, SimpleProductService, SimpleWorkbenchEnvironmentService } from 'vs/workbench/browser/web.simpleservices';
import { SimpleLogService, SimpleProductService } from 'vs/workbench/browser/web.simpleservices';
import { BrowserWorkbenchEnvironmentService } from 'vs/workbench/services/environment/browser/environmentService';
import { Workbench } from 'vs/workbench/browser/workbench';
import { IChannel } from 'vs/base/parts/ipc/common/ipc';
import { REMOTE_FILE_SYSTEM_CHANNEL_NAME, RemoteExtensionsFileSystemProvider } from 'vs/platform/remote/common/remoteAgentFileSystemChannel';
@ -33,27 +34,15 @@ import { WebResources } from 'vs/workbench/browser/web.resources';
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;
}
class CodeRendererMain extends Disposable {
private workbench: Workbench;
constructor(
private readonly domElement: HTMLElement,
private readonly configuration: IWindowConfiguration
private readonly configuration: IWorkbenchConstructionOptions
) {
super();
}
@ -97,7 +86,7 @@ class CodeRendererMain extends Disposable {
serviceCollection.set(ILogService, logService);
// Environment
const environmentService = this.createEnvironmentService();
const environmentService = new BrowserWorkbenchEnvironmentService(this.configuration);
serviceCollection.set(IWorkbenchEnvironmentService, environmentService);
// Product
@ -144,23 +133,6 @@ class CodeRendererMain extends Disposable {
return { serviceCollection, logService };
}
private createEnvironmentService(): IWorkbenchEnvironmentService {
const environmentService = new SimpleWorkbenchEnvironmentService();
environmentService.appRoot = '/web/';
environmentService.args = { _: [] };
environmentService.appSettingsHome = joinPath(this.configuration.userDataUri, 'User');
environmentService.settingsResource = joinPath(environmentService.appSettingsHome, 'settings.json');
environmentService.keybindingsResource = joinPath(environmentService.appSettingsHome, 'keybindings.json');
environmentService.logsPath = '/web/logs';
environmentService.debugExtensionHost = {
port: null,
break: false
};
environmentService.webviewEndpoint = this.configuration.webviewEndpoint;
return environmentService;
}
private async createWorkspaceService(payload: IWorkspaceInitializationPayload, environmentService: IWorkbenchEnvironmentService, fileService: FileService, remoteAgentService: IRemoteAgentService, logService: ILogService): Promise<WorkspaceService> {
const workspaceService = new WorkspaceService({ userSettingsResource: environmentService.settingsResource, remoteAuthority: this.configuration.remoteAuthority, configurationCache: new ConfigurationCache() }, new ConfigurationFileService(fileService), remoteAgentService);
@ -180,12 +152,12 @@ class CodeRendererMain extends Disposable {
// Multi-root workspace
if (this.configuration.workspaceUri) {
return { id: hash(this.configuration.workspaceUri.toString()).toString(16), configPath: this.configuration.workspaceUri };
return { id: hash(URI.revive(this.configuration.workspaceUri).toString()).toString(16), configPath: URI.revive(this.configuration.workspaceUri) };
}
// Single-folder workspace
if (this.configuration.folderUri) {
return { id: hash(this.configuration.folderUri.toString()).toString(16), folder: this.configuration.folderUri };
return { id: hash(URI.revive(this.configuration.folderUri).toString()).toString(16), folder: URI.revive(this.configuration.folderUri) };
}
return { id: 'empty-window' };

View file

@ -15,27 +15,23 @@ import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService
// tslint:disable-next-line: import-patterns no-standalone-editor
import { IDownloadService } from 'vs/platform/download/common/download';
import { CancellationToken } from 'vs/base/common/cancellation';
import { IExtensionHostDebugParams, IDebugParams } from 'vs/platform/environment/common/environment';
import { IExtensionGalleryService, IQueryOptions, IGalleryExtension, InstallOperation, StatisticType, ITranslation, IGalleryExtensionVersion, IExtensionIdentifier, IReportedExtension, IExtensionManagementService, ILocalExtension, IGalleryMetadata, IExtensionTipsService, ExtensionRecommendationReason, IExtensionRecommendation, IExtensionEnablementService, EnablementState } from 'vs/platform/extensionManagement/common/extensionManagement';
import { IPager } from 'vs/base/common/paging';
import { IExtensionManifest, ExtensionType, ExtensionIdentifier, IExtension } from 'vs/platform/extensions/common/extensions';
import { IURLHandler, IURLService } from 'vs/platform/url/common/url';
import { ITelemetryService, ITelemetryData, ITelemetryInfo } from 'vs/platform/telemetry/common/telemetry';
import { LogLevel, ConsoleLogService } from 'vs/platform/log/common/log';
import { ConsoleLogService } from 'vs/platform/log/common/log';
import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
import { IProductService } from 'vs/platform/product/common/product';
import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
import { IStorageService, IWorkspaceStorageChangeEvent, StorageScope, IWillSaveStateEvent, WillSaveStateReason } from 'vs/platform/storage/common/storage';
import { IUpdateService, State } from 'vs/platform/update/common/update';
import { IWindowConfiguration, IPath, IPathsToWaitFor, IWindowService, INativeOpenDialogOptions, IEnterWorkspaceResult, IURIToOpen, IMessageBoxResult, IWindowsService, IOpenSettings } from 'vs/platform/windows/common/windows';
import { IProcessEnvironment } from 'vs/base/common/platform';
import { IWindowService, INativeOpenDialogOptions, IEnterWorkspaceResult, IURIToOpen, IMessageBoxResult, IWindowsService, IOpenSettings } from 'vs/platform/windows/common/windows';
import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, IWorkspaceFolderCreationData, IWorkspacesService } from 'vs/platform/workspaces/common/workspaces';
import { ExportData } from 'vs/base/common/performance';
import { IRecentlyOpened, IRecent } from 'vs/platform/history/common/history';
import { ISerializableCommandAction } from 'vs/platform/actions/common/actions';
import { IWorkspaceEditingService } from 'vs/workbench/services/workspace/common/workspaceEditing';
import { ITunnelService } from 'vs/platform/remote/common/tunnel';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { IReloadSessionEvent, IExtensionHostDebugService, ICloseSessionEvent, IAttachSessionEvent, ILogToSessionEvent, ITerminateSessionEvent } from 'vs/workbench/services/extensions/common/extensionHostDebug';
import { IRemoteConsoleLog } from 'vs/base/common/console';
// tslint:disable-next-line: import-patterns
@ -169,65 +165,6 @@ export class SimpleDownloadService implements IDownloadService {
registerSingleton(IDownloadService, SimpleDownloadService, true);
//#endregion
//#region Environment
export class SimpleWorkbenchEnvironmentService implements IWorkbenchEnvironmentService {
configuration: IWindowConfiguration = new SimpleWindowConfiguration();
untitledWorkspacesHome: URI;
extensionTestsLocationURI?: URI;
_serviceBrand: any;
args: any;
execPath: string;
cliPath: string;
appRoot: string;
userHome: string;
userDataPath: string;
appNameLong: string = 'Visual Studio Code - Web';
appQuality?: string;
appSettingsHome: URI;
settingsResource: URI;
keybindingsResource: URI;
machineSettingsHome: URI;
machineSettingsResource: URI;
settingsSearchBuildId?: number;
settingsSearchUrl?: string;
globalStorageHome: string;
workspaceStorageHome: string;
backupHome: string;
backupWorkspacesPath: string;
workspacesHome: string;
isExtensionDevelopment: boolean;
disableExtensions: boolean | string[];
builtinExtensionsPath: string;
extensionsPath: string;
extensionDevelopmentLocationURI?: URI[];
extensionTestsPath?: string;
debugExtensionHost: IExtensionHostDebugParams;
debugSearch: IDebugParams;
logExtensionHostCommunication: boolean;
isBuilt: boolean;
wait: boolean;
status: boolean;
log?: string;
logsPath: string;
verbose: boolean;
skipGettingStarted: boolean;
skipReleaseNotes: boolean;
skipAddToRecentlyOpened: boolean;
mainIPCHandle: string;
sharedIPCHandle: string;
nodeCachedDataDir?: string;
installSourcePath: string;
disableUpdates: boolean;
disableCrashReporter: boolean;
driverHandle?: string;
driverVerbose: boolean;
webviewEndpoint?: string;
}
//#endregion
//#region Extension Gallery
@ -804,47 +741,6 @@ registerSingleton(IURLService, SimpleURLService);
//#region Window
export class SimpleWindowConfiguration implements IWindowConfiguration {
_: any[];
machineId: string;
windowId: number;
logLevel: LogLevel;
mainPid: number;
appRoot: string;
execPath: string;
isInitialStartup?: boolean;
userEnv: IProcessEnvironment;
nodeCachedDataDir?: string;
backupPath?: string;
workspace?: IWorkspaceIdentifier;
folderUri?: ISingleFolderWorkspaceIdentifier;
remoteAuthority: string = document.location.host;
zoomLevel?: number;
fullscreen?: boolean;
maximized?: boolean;
highContrast?: boolean;
frameless?: boolean;
accessibilitySupport?: boolean;
partsSplashPath?: string;
perfStartTime?: number;
perfAppReady?: number;
perfWindowLoadTime?: number;
perfEntries: ExportData;
filesToOpenOrCreate?: IPath[];
filesToDiff?: IPath[];
filesToWait?: IPathsToWaitFor;
termProgram?: string;
}
export class SimpleWindowService implements IWindowService {
_serviceBrand: any;

View file

@ -0,0 +1,136 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IWindowConfiguration, IPath, IPathsToWaitFor } from 'vs/platform/windows/common/windows';
import { IEnvironmentService, IExtensionHostDebugParams, IDebugParams } from 'vs/platform/environment/common/environment';
import { ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
import { URI } from 'vs/base/common/uri';
import { IProcessEnvironment } from 'vs/base/common/platform';
import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
import { ExportData } from 'vs/base/common/performance';
import { LogLevel } from 'vs/platform/log/common/log';
import { joinPath } from 'vs/base/common/resources';
import { IWorkbenchConstructionOptions } from 'vs/workbench/workbench.web.api';
export class BrowserWindowConfiguration implements IWindowConfiguration {
_: any[];
machineId: string;
windowId: number;
logLevel: LogLevel;
mainPid: number;
appRoot: string;
execPath: string;
isInitialStartup?: boolean;
userEnv: IProcessEnvironment;
nodeCachedDataDir?: string;
backupPath?: string;
workspace?: IWorkspaceIdentifier;
folderUri?: ISingleFolderWorkspaceIdentifier;
remoteAuthority: string;
zoomLevel?: number;
fullscreen?: boolean;
maximized?: boolean;
highContrast?: boolean;
frameless?: boolean;
accessibilitySupport?: boolean;
partsSplashPath?: string;
perfStartTime?: number;
perfAppReady?: number;
perfWindowLoadTime?: number;
perfEntries: ExportData;
filesToOpenOrCreate?: IPath[];
filesToDiff?: IPath[];
filesToWait?: IPathsToWaitFor;
termProgram?: string;
}
export class BrowserWorkbenchEnvironmentService implements IEnvironmentService {
_serviceBrand: ServiceIdentifier<IEnvironmentService>;
readonly configuration: IWindowConfiguration = new BrowserWindowConfiguration();
constructor(configuration: IWorkbenchConstructionOptions) {
this.args = { _: [] };
this.appRoot = '/web/';
this.appNameLong = 'Visual Studio Code - Web';
this.configuration.remoteAuthority = configuration.remoteAuthority;
this.appSettingsHome = joinPath(URI.revive(configuration.userDataUri), 'User');
this.settingsResource = joinPath(this.appSettingsHome, 'settings.json');
this.keybindingsResource = joinPath(this.appSettingsHome, 'keybindings.json');
this.logsPath = '/web/logs';
this.debugExtensionHost = {
port: null,
break: false
};
this.webviewEndpoint = configuration.webviewEndpoint;
}
untitledWorkspacesHome: URI;
extensionTestsLocationURI?: URI;
args: any;
execPath: string;
cliPath: string;
appRoot: string;
userHome: string;
userDataPath: string;
appNameLong: string;
appQuality?: string;
appSettingsHome: URI;
settingsResource: URI;
keybindingsResource: URI;
machineSettingsHome: URI;
machineSettingsResource: URI;
settingsSearchBuildId?: number;
settingsSearchUrl?: string;
globalStorageHome: string;
workspaceStorageHome: string;
backupHome: string;
backupWorkspacesPath: string;
workspacesHome: string;
isExtensionDevelopment: boolean;
disableExtensions: boolean | string[];
builtinExtensionsPath: string;
extensionsPath: string;
extensionDevelopmentLocationURI?: URI[];
extensionTestsPath?: string;
debugExtensionHost: IExtensionHostDebugParams;
debugSearch: IDebugParams;
logExtensionHostCommunication: boolean;
isBuilt: boolean;
wait: boolean;
status: boolean;
log?: string;
logsPath: string;
verbose: boolean;
skipGettingStarted: boolean;
skipReleaseNotes: boolean;
skipAddToRecentlyOpened: boolean;
mainIPCHandle: string;
sharedIPCHandle: string;
nodeCachedDataDir?: string;
installSourcePath: string;
disableUpdates: boolean;
disableCrashReporter: boolean;
driverHandle?: string;
driverVerbose: boolean;
webviewEndpoint?: string;
}

View file

@ -3,14 +3,15 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { createDecorator, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
import { IWindowConfiguration } from 'vs/platform/windows/common/windows';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
export const IWorkbenchEnvironmentService = createDecorator<IWorkbenchEnvironmentService>('environmentService');
export interface IWorkbenchEnvironmentService extends IEnvironmentService {
_serviceBrand: any;
_serviceBrand: ServiceIdentifier<IEnvironmentService>;
readonly configuration: IWindowConfiguration;
}

View file

@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { IRemoteAgentConnection } from 'vs/workbench/services/remote/common/remoteAgentService';
import { IRemoteAuthorityResolverService } from 'vs/platform/remote/common/remoteAuthorityResolver';
import { AbstractRemoteAgentService, RemoteAgentConnection } from 'vs/workbench/services/remote/common/abstractRemoteAgentService';
@ -16,14 +16,14 @@ export class RemoteAgentService extends AbstractRemoteAgentService {
private readonly _connection: IRemoteAgentConnection | null = null;
constructor(
@IEnvironmentService environmentService: IEnvironmentService,
@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,
@IProductService productService: IProductService,
@IRemoteAuthorityResolverService remoteAuthorityResolverService: IRemoteAuthorityResolverService,
@ISignService signService: ISignService
) {
super(environmentService);
const authority = document.location.host;
this._connection = this._register(new RemoteAgentConnection(authority, productService.commit, browserWebSocketFactory, environmentService, remoteAuthorityResolverService, signService));
this._connection = this._register(new RemoteAgentConnection(environmentService.configuration.remoteAuthority!, productService.commit, browserWebSocketFactory, environmentService, remoteAuthorityResolverService, signService));
}
getConnection(): IRemoteAgentConnection | null {

View file

@ -441,6 +441,7 @@
"**/vs/base/**/{common,browser}/**",
"**/vs/platform/**/{common,browser}/**",
"**/vs/editor/{common,browser}/**",
"**/vs/workbench/workbench.web.api",
"**/vs/workbench/{common,browser}/**",
"**/vs/workbench/services/**/{common,browser}/**",
"vscode-textmate",