Skip to content

Commit ad41bd2

Browse files
author
Benjamin Pasero
committed
web - introduce browser environment service
Hello first commit from browser :)
1 parent 2346551 commit ad41bd2

9 files changed

Lines changed: 155 additions & 149 deletions

File tree

src/vs/code/browser/workbench/workbench.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
<!-- Window Configuration from Server -->
1717
<script>
18-
self.WINDOW_CONFIGURATION = {
18+
self.WORKBENCH_WEB_CONFIGURATION = {
1919
connectionAuthToken: '{{CONNECTION_AUTH_TOKEN}}',
2020
folderUri: '{{FOLDER}}',
2121
workspaceUri: '{{WORKSPACE}}',

src/vs/code/browser/workbench/workbench.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@
2424
require(['vs/workbench/workbench.web.api'], function () {
2525
// @ts-ignore
2626
// eslint-disable-next-line no-undef
27-
monaco.workbench.create(document.body, self.WINDOW_CONFIGURATION);
27+
monaco.workbench.create(document.body, self.WORKBENCH_WEB_CONFIGURATION);
2828
});
2929
})();

src/vs/platform/sign/browser/signService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ export class SignService implements ISignService {
1111
_serviceBrand: ServiceIdentifier<ISignService>;
1212

1313
async sign(value: string): Promise<string> {
14-
return Promise.resolve((<any>self).WINDOW_CONFIGURATION.connectionAuthToken);
14+
return Promise.resolve((<any>self).WORKBENCH_WEB_CONFIGURATION.connectionAuthToken);
1515
}
1616
}

src/vs/workbench/browser/web.main.ts

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import { domContentLoaded, addDisposableListener, EventType } from 'vs/base/brow
88
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
99
import { ILogService } from 'vs/platform/log/common/log';
1010
import { Disposable } from 'vs/base/common/lifecycle';
11-
import { SimpleLogService, SimpleProductService, SimpleWorkbenchEnvironmentService } from 'vs/workbench/browser/web.simpleservices';
11+
import { SimpleLogService, SimpleProductService } from 'vs/workbench/browser/web.simpleservices';
12+
import { BrowserWorkbenchEnvironmentService } from 'vs/workbench/services/environment/browser/environmentService';
1213
import { Workbench } from 'vs/workbench/browser/workbench';
1314
import { IChannel } from 'vs/base/parts/ipc/common/ipc';
1415
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';
3334
import { ISignService } from 'vs/platform/sign/common/sign';
3435
import { SignService } from 'vs/platform/sign/browser/signService';
3536
import { hash } from 'vs/base/common/hash';
36-
import { joinPath } from 'vs/base/common/resources';
3737
import { IWorkbenchConstructionOptions } from 'vs/workbench/workbench.web.api';
3838

39-
interface IWindowConfiguration {
40-
remoteAuthority: string;
41-
42-
userDataUri: URI;
43-
44-
webviewEndpoint?: string;
45-
46-
folderUri?: URI;
47-
workspaceUri?: URI;
48-
}
49-
5039
class CodeRendererMain extends Disposable {
5140

5241
private workbench: Workbench;
5342

5443
constructor(
5544
private readonly domElement: HTMLElement,
56-
private readonly configuration: IWindowConfiguration
45+
private readonly configuration: IWorkbenchConstructionOptions
5746
) {
5847
super();
5948
}
@@ -97,7 +86,7 @@ class CodeRendererMain extends Disposable {
9786
serviceCollection.set(ILogService, logService);
9887

9988
// Environment
100-
const environmentService = this.createEnvironmentService();
89+
const environmentService = new BrowserWorkbenchEnvironmentService(this.configuration);
10190
serviceCollection.set(IWorkbenchEnvironmentService, environmentService);
10291

10392
// Product
@@ -144,23 +133,6 @@ class CodeRendererMain extends Disposable {
144133
return { serviceCollection, logService };
145134
}
146135

147-
private createEnvironmentService(): IWorkbenchEnvironmentService {
148-
const environmentService = new SimpleWorkbenchEnvironmentService();
149-
environmentService.appRoot = '/web/';
150-
environmentService.args = { _: [] };
151-
environmentService.appSettingsHome = joinPath(this.configuration.userDataUri, 'User');
152-
environmentService.settingsResource = joinPath(environmentService.appSettingsHome, 'settings.json');
153-
environmentService.keybindingsResource = joinPath(environmentService.appSettingsHome, 'keybindings.json');
154-
environmentService.logsPath = '/web/logs';
155-
environmentService.debugExtensionHost = {
156-
port: null,
157-
break: false
158-
};
159-
environmentService.webviewEndpoint = this.configuration.webviewEndpoint;
160-
161-
return environmentService;
162-
}
163-
164136
private async createWorkspaceService(payload: IWorkspaceInitializationPayload, environmentService: IWorkbenchEnvironmentService, fileService: FileService, remoteAgentService: IRemoteAgentService, logService: ILogService): Promise<WorkspaceService> {
165137
const workspaceService = new WorkspaceService({ userSettingsResource: environmentService.settingsResource, remoteAuthority: this.configuration.remoteAuthority, configurationCache: new ConfigurationCache() }, new ConfigurationFileService(fileService), remoteAgentService);
166138

@@ -180,12 +152,12 @@ class CodeRendererMain extends Disposable {
180152

181153
// Multi-root workspace
182154
if (this.configuration.workspaceUri) {
183-
return { id: hash(this.configuration.workspaceUri.toString()).toString(16), configPath: this.configuration.workspaceUri };
155+
return { id: hash(URI.revive(this.configuration.workspaceUri).toString()).toString(16), configPath: URI.revive(this.configuration.workspaceUri) };
184156
}
185157

186158
// Single-folder workspace
187159
if (this.configuration.folderUri) {
188-
return { id: hash(this.configuration.folderUri.toString()).toString(16), folder: this.configuration.folderUri };
160+
return { id: hash(URI.revive(this.configuration.folderUri).toString()).toString(16), folder: URI.revive(this.configuration.folderUri) };
189161
}
190162

191163
return { id: 'empty-window' };

src/vs/workbench/browser/web.simpleservices.ts

Lines changed: 2 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,23 @@ import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService
1515
// tslint:disable-next-line: import-patterns no-standalone-editor
1616
import { IDownloadService } from 'vs/platform/download/common/download';
1717
import { CancellationToken } from 'vs/base/common/cancellation';
18-
import { IExtensionHostDebugParams, IDebugParams } from 'vs/platform/environment/common/environment';
1918
import { IExtensionGalleryService, IQueryOptions, IGalleryExtension, InstallOperation, StatisticType, ITranslation, IGalleryExtensionVersion, IExtensionIdentifier, IReportedExtension, IExtensionManagementService, ILocalExtension, IGalleryMetadata, IExtensionTipsService, ExtensionRecommendationReason, IExtensionRecommendation, IExtensionEnablementService, EnablementState } from 'vs/platform/extensionManagement/common/extensionManagement';
2019
import { IPager } from 'vs/base/common/paging';
2120
import { IExtensionManifest, ExtensionType, ExtensionIdentifier, IExtension } from 'vs/platform/extensions/common/extensions';
2221
import { IURLHandler, IURLService } from 'vs/platform/url/common/url';
2322
import { ITelemetryService, ITelemetryData, ITelemetryInfo } from 'vs/platform/telemetry/common/telemetry';
24-
import { LogLevel, ConsoleLogService } from 'vs/platform/log/common/log';
23+
import { ConsoleLogService } from 'vs/platform/log/common/log';
2524
import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
2625
import { IProductService } from 'vs/platform/product/common/product';
2726
import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
2827
import { IStorageService, IWorkspaceStorageChangeEvent, StorageScope, IWillSaveStateEvent, WillSaveStateReason } from 'vs/platform/storage/common/storage';
2928
import { IUpdateService, State } from 'vs/platform/update/common/update';
30-
import { IWindowConfiguration, IPath, IPathsToWaitFor, IWindowService, INativeOpenDialogOptions, IEnterWorkspaceResult, IURIToOpen, IMessageBoxResult, IWindowsService, IOpenSettings } from 'vs/platform/windows/common/windows';
31-
import { IProcessEnvironment } from 'vs/base/common/platform';
29+
import { IWindowService, INativeOpenDialogOptions, IEnterWorkspaceResult, IURIToOpen, IMessageBoxResult, IWindowsService, IOpenSettings } from 'vs/platform/windows/common/windows';
3230
import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, IWorkspaceFolderCreationData, IWorkspacesService } from 'vs/platform/workspaces/common/workspaces';
33-
import { ExportData } from 'vs/base/common/performance';
3431
import { IRecentlyOpened, IRecent } from 'vs/platform/history/common/history';
3532
import { ISerializableCommandAction } from 'vs/platform/actions/common/actions';
3633
import { IWorkspaceEditingService } from 'vs/workbench/services/workspace/common/workspaceEditing';
3734
import { ITunnelService } from 'vs/platform/remote/common/tunnel';
38-
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
3935
import { IReloadSessionEvent, IExtensionHostDebugService, ICloseSessionEvent, IAttachSessionEvent, ILogToSessionEvent, ITerminateSessionEvent } from 'vs/workbench/services/extensions/common/extensionHostDebug';
4036
import { IRemoteConsoleLog } from 'vs/base/common/console';
4137
// tslint:disable-next-line: import-patterns
@@ -169,65 +165,6 @@ export class SimpleDownloadService implements IDownloadService {
169165

170166
registerSingleton(IDownloadService, SimpleDownloadService, true);
171167

172-
//#endregion
173-
174-
//#region Environment
175-
176-
export class SimpleWorkbenchEnvironmentService implements IWorkbenchEnvironmentService {
177-
configuration: IWindowConfiguration = new SimpleWindowConfiguration();
178-
untitledWorkspacesHome: URI;
179-
extensionTestsLocationURI?: URI;
180-
_serviceBrand: any;
181-
args: any;
182-
execPath: string;
183-
cliPath: string;
184-
appRoot: string;
185-
userHome: string;
186-
userDataPath: string;
187-
appNameLong: string = 'Visual Studio Code - Web';
188-
appQuality?: string;
189-
appSettingsHome: URI;
190-
settingsResource: URI;
191-
keybindingsResource: URI;
192-
machineSettingsHome: URI;
193-
machineSettingsResource: URI;
194-
settingsSearchBuildId?: number;
195-
settingsSearchUrl?: string;
196-
globalStorageHome: string;
197-
workspaceStorageHome: string;
198-
backupHome: string;
199-
backupWorkspacesPath: string;
200-
workspacesHome: string;
201-
isExtensionDevelopment: boolean;
202-
disableExtensions: boolean | string[];
203-
builtinExtensionsPath: string;
204-
extensionsPath: string;
205-
extensionDevelopmentLocationURI?: URI[];
206-
extensionTestsPath?: string;
207-
debugExtensionHost: IExtensionHostDebugParams;
208-
debugSearch: IDebugParams;
209-
logExtensionHostCommunication: boolean;
210-
isBuilt: boolean;
211-
wait: boolean;
212-
status: boolean;
213-
log?: string;
214-
logsPath: string;
215-
verbose: boolean;
216-
skipGettingStarted: boolean;
217-
skipReleaseNotes: boolean;
218-
skipAddToRecentlyOpened: boolean;
219-
mainIPCHandle: string;
220-
sharedIPCHandle: string;
221-
nodeCachedDataDir?: string;
222-
installSourcePath: string;
223-
disableUpdates: boolean;
224-
disableCrashReporter: boolean;
225-
driverHandle?: string;
226-
driverVerbose: boolean;
227-
webviewEndpoint?: string;
228-
}
229-
230-
231168
//#endregion
232169

233170
//#region Extension Gallery
@@ -804,47 +741,6 @@ registerSingleton(IURLService, SimpleURLService);
804741

805742
//#region Window
806743

807-
export class SimpleWindowConfiguration implements IWindowConfiguration {
808-
_: any[];
809-
machineId: string;
810-
windowId: number;
811-
logLevel: LogLevel;
812-
813-
mainPid: number;
814-
815-
appRoot: string;
816-
execPath: string;
817-
isInitialStartup?: boolean;
818-
819-
userEnv: IProcessEnvironment;
820-
nodeCachedDataDir?: string;
821-
822-
backupPath?: string;
823-
824-
workspace?: IWorkspaceIdentifier;
825-
folderUri?: ISingleFolderWorkspaceIdentifier;
826-
827-
remoteAuthority: string = document.location.host;
828-
829-
zoomLevel?: number;
830-
fullscreen?: boolean;
831-
maximized?: boolean;
832-
highContrast?: boolean;
833-
frameless?: boolean;
834-
accessibilitySupport?: boolean;
835-
partsSplashPath?: string;
836-
837-
perfStartTime?: number;
838-
perfAppReady?: number;
839-
perfWindowLoadTime?: number;
840-
perfEntries: ExportData;
841-
842-
filesToOpenOrCreate?: IPath[];
843-
filesToDiff?: IPath[];
844-
filesToWait?: IPathsToWaitFor;
845-
termProgram?: string;
846-
}
847-
848744
export class SimpleWindowService implements IWindowService {
849745

850746
_serviceBrand: any;
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import { IWindowConfiguration, IPath, IPathsToWaitFor } from 'vs/platform/windows/common/windows';
7+
import { IEnvironmentService, IExtensionHostDebugParams, IDebugParams } from 'vs/platform/environment/common/environment';
8+
import { ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
9+
import { URI } from 'vs/base/common/uri';
10+
import { IProcessEnvironment } from 'vs/base/common/platform';
11+
import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
12+
import { ExportData } from 'vs/base/common/performance';
13+
import { LogLevel } from 'vs/platform/log/common/log';
14+
import { joinPath } from 'vs/base/common/resources';
15+
import { IWorkbenchConstructionOptions } from 'vs/workbench/workbench.web.api';
16+
17+
export class BrowserWindowConfiguration implements IWindowConfiguration {
18+
19+
_: any[];
20+
21+
machineId: string;
22+
windowId: number;
23+
logLevel: LogLevel;
24+
25+
mainPid: number;
26+
27+
appRoot: string;
28+
execPath: string;
29+
isInitialStartup?: boolean;
30+
31+
userEnv: IProcessEnvironment;
32+
nodeCachedDataDir?: string;
33+
34+
backupPath?: string;
35+
36+
workspace?: IWorkspaceIdentifier;
37+
folderUri?: ISingleFolderWorkspaceIdentifier;
38+
39+
remoteAuthority: string;
40+
41+
zoomLevel?: number;
42+
fullscreen?: boolean;
43+
maximized?: boolean;
44+
highContrast?: boolean;
45+
frameless?: boolean;
46+
accessibilitySupport?: boolean;
47+
partsSplashPath?: string;
48+
49+
perfStartTime?: number;
50+
perfAppReady?: number;
51+
perfWindowLoadTime?: number;
52+
perfEntries: ExportData;
53+
54+
filesToOpenOrCreate?: IPath[];
55+
filesToDiff?: IPath[];
56+
filesToWait?: IPathsToWaitFor;
57+
termProgram?: string;
58+
}
59+
60+
export class BrowserWorkbenchEnvironmentService implements IEnvironmentService {
61+
62+
_serviceBrand: ServiceIdentifier<IEnvironmentService>;
63+
64+
readonly configuration: IWindowConfiguration = new BrowserWindowConfiguration();
65+
66+
constructor(configuration: IWorkbenchConstructionOptions) {
67+
this.args = { _: [] };
68+
this.appRoot = '/web/';
69+
this.appNameLong = 'Visual Studio Code - Web';
70+
71+
this.configuration.remoteAuthority = configuration.remoteAuthority;
72+
73+
this.appSettingsHome = joinPath(URI.revive(configuration.userDataUri), 'User');
74+
this.settingsResource = joinPath(this.appSettingsHome, 'settings.json');
75+
this.keybindingsResource = joinPath(this.appSettingsHome, 'keybindings.json');
76+
77+
this.logsPath = '/web/logs';
78+
79+
this.debugExtensionHost = {
80+
port: null,
81+
break: false
82+
};
83+
84+
this.webviewEndpoint = configuration.webviewEndpoint;
85+
}
86+
87+
untitledWorkspacesHome: URI;
88+
extensionTestsLocationURI?: URI;
89+
args: any;
90+
execPath: string;
91+
cliPath: string;
92+
appRoot: string;
93+
userHome: string;
94+
userDataPath: string;
95+
appNameLong: string;
96+
appQuality?: string;
97+
appSettingsHome: URI;
98+
settingsResource: URI;
99+
keybindingsResource: URI;
100+
machineSettingsHome: URI;
101+
machineSettingsResource: URI;
102+
settingsSearchBuildId?: number;
103+
settingsSearchUrl?: string;
104+
globalStorageHome: string;
105+
workspaceStorageHome: string;
106+
backupHome: string;
107+
backupWorkspacesPath: string;
108+
workspacesHome: string;
109+
isExtensionDevelopment: boolean;
110+
disableExtensions: boolean | string[];
111+
builtinExtensionsPath: string;
112+
extensionsPath: string;
113+
extensionDevelopmentLocationURI?: URI[];
114+
extensionTestsPath?: string;
115+
debugExtensionHost: IExtensionHostDebugParams;
116+
debugSearch: IDebugParams;
117+
logExtensionHostCommunication: boolean;
118+
isBuilt: boolean;
119+
wait: boolean;
120+
status: boolean;
121+
log?: string;
122+
logsPath: string;
123+
verbose: boolean;
124+
skipGettingStarted: boolean;
125+
skipReleaseNotes: boolean;
126+
skipAddToRecentlyOpened: boolean;
127+
mainIPCHandle: string;
128+
sharedIPCHandle: string;
129+
nodeCachedDataDir?: string;
130+
installSourcePath: string;
131+
disableUpdates: boolean;
132+
disableCrashReporter: boolean;
133+
driverHandle?: string;
134+
driverVerbose: boolean;
135+
webviewEndpoint?: string;
136+
}

0 commit comments

Comments
 (0)