diff --git a/build/lib/layersChecker.js b/build/lib/layersChecker.js index f3cc2252b5e..864c47f6ca3 100644 --- a/build/lib/layersChecker.js +++ b/build/lib/layersChecker.js @@ -53,6 +53,13 @@ const CORE_TYPES = [ 'trimLeft', 'trimRight' ]; +// Types that are defined in a common layer but are known to be only +// available in native environments should not be allowed in browser +const NATIVE_TYPES = [ + 'NativeParsedArgs', + 'INativeEnvironmentService', + 'INativeWindowConfiguration' +]; const RULES = [ // Tests: skip { @@ -68,6 +75,37 @@ const RULES = [ 'MessageEvent', 'data' ], + disallowedTypes: NATIVE_TYPES, + disallowedDefinitions: [ + 'lib.dom.d.ts', + '@types/node' // no node.js + ] + }, + // Common: vs/platform/environment/common/argv.ts + { + target: '**/vs/platform/environment/common/argv.ts', + disallowedTypes: [ /* Ignore native types that are defined from here */], + allowedTypes: CORE_TYPES, + disallowedDefinitions: [ + 'lib.dom.d.ts', + '@types/node' // no node.js + ] + }, + // Common: vs/platform/environment/common/environment.ts + { + target: '**/vs/platform/environment/common/environment.ts', + disallowedTypes: [ /* Ignore native types that are defined from here */], + allowedTypes: CORE_TYPES, + disallowedDefinitions: [ + 'lib.dom.d.ts', + '@types/node' // no node.js + ] + }, + // Common: vs/platform/windows/common/windows.ts + { + target: '**/vs/platform/windows/common/windows.ts', + disallowedTypes: [ /* Ignore native types that are defined from here */], + allowedTypes: CORE_TYPES, disallowedDefinitions: [ 'lib.dom.d.ts', '@types/node' // no node.js @@ -81,6 +119,7 @@ const RULES = [ // Safe access to global 'global' ], + disallowedTypes: NATIVE_TYPES, disallowedDefinitions: [ 'lib.dom.d.ts', '@types/node' // no node.js @@ -90,6 +129,7 @@ const RULES = [ { target: '**/vs/**/common/**', allowedTypes: CORE_TYPES, + disallowedTypes: NATIVE_TYPES, disallowedDefinitions: [ 'lib.dom.d.ts', '@types/node' // no node.js @@ -99,6 +139,7 @@ const RULES = [ { target: '**/vs/**/browser/**', allowedTypes: CORE_TYPES, + disallowedTypes: NATIVE_TYPES, disallowedDefinitions: [ '@types/node' // no node.js ] @@ -107,6 +148,7 @@ const RULES = [ { target: '**/src/vs/editor/contrib/**', allowedTypes: CORE_TYPES, + disallowedTypes: NATIVE_TYPES, disallowedDefinitions: [ '@types/node' // no node.js ] @@ -162,7 +204,7 @@ let hasErrors = false; function checkFile(program, sourceFile, rule) { checkNode(sourceFile); function checkNode(node) { - var _a; + var _a, _b; if (node.kind !== ts.SyntaxKind.Identifier) { return ts.forEachChild(node, checkNode); // recurse down } @@ -170,6 +212,12 @@ function checkFile(program, sourceFile, rule) { if ((_a = rule.allowedTypes) === null || _a === void 0 ? void 0 : _a.some(allowed => allowed === text)) { return; // override } + if ((_b = rule.disallowedTypes) === null || _b === void 0 ? void 0 : _b.some(disallowed => disallowed === text)) { + const { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart()); + console.log(`[build/lib/layersChecker.ts]: Reference to '${text}' violates layer '${rule.target}' (${sourceFile.fileName} (${line + 1},${character + 1})`); + hasErrors = true; + return; + } const checker = program.getTypeChecker(); const symbol = checker.getSymbolAtLocation(node); if (symbol) { diff --git a/build/lib/layersChecker.ts b/build/lib/layersChecker.ts index 508d2b986e9..5d620c79db0 100644 --- a/build/lib/layersChecker.ts +++ b/build/lib/layersChecker.ts @@ -55,6 +55,14 @@ const CORE_TYPES = [ 'trimRight' ]; +// Types that are defined in a common layer but are known to be only +// available in native environments should not be allowed in browser +const NATIVE_TYPES = [ + 'NativeParsedArgs', + 'INativeEnvironmentService', + 'INativeWindowConfiguration' +]; + const RULES = [ // Tests: skip @@ -73,6 +81,40 @@ const RULES = [ 'MessageEvent', 'data' ], + disallowedTypes: NATIVE_TYPES, + disallowedDefinitions: [ + 'lib.dom.d.ts', // no DOM + '@types/node' // no node.js + ] + }, + + // Common: vs/platform/environment/common/argv.ts + { + target: '**/vs/platform/environment/common/argv.ts', + disallowedTypes: [/* Ignore native types that are defined from here */], + allowedTypes: CORE_TYPES, + disallowedDefinitions: [ + 'lib.dom.d.ts', // no DOM + '@types/node' // no node.js + ] + }, + + // Common: vs/platform/environment/common/environment.ts + { + target: '**/vs/platform/environment/common/environment.ts', + disallowedTypes: [/* Ignore native types that are defined from here */], + allowedTypes: CORE_TYPES, + disallowedDefinitions: [ + 'lib.dom.d.ts', // no DOM + '@types/node' // no node.js + ] + }, + + // Common: vs/platform/windows/common/windows.ts + { + target: '**/vs/platform/windows/common/windows.ts', + disallowedTypes: [/* Ignore native types that are defined from here */], + allowedTypes: CORE_TYPES, disallowedDefinitions: [ 'lib.dom.d.ts', // no DOM '@types/node' // no node.js @@ -88,6 +130,7 @@ const RULES = [ // Safe access to global 'global' ], + disallowedTypes: NATIVE_TYPES, disallowedDefinitions: [ 'lib.dom.d.ts', // no DOM '@types/node' // no node.js @@ -98,6 +141,7 @@ const RULES = [ { target: '**/vs/**/common/**', allowedTypes: CORE_TYPES, + disallowedTypes: NATIVE_TYPES, disallowedDefinitions: [ 'lib.dom.d.ts', // no DOM '@types/node' // no node.js @@ -108,6 +152,7 @@ const RULES = [ { target: '**/vs/**/browser/**', allowedTypes: CORE_TYPES, + disallowedTypes: NATIVE_TYPES, disallowedDefinitions: [ '@types/node' // no node.js ] @@ -117,6 +162,7 @@ const RULES = [ { target: '**/src/vs/editor/contrib/**', allowedTypes: CORE_TYPES, + disallowedTypes: NATIVE_TYPES, disallowedDefinitions: [ '@types/node' // no node.js ] @@ -181,6 +227,7 @@ interface IRule { skip?: boolean; allowedTypes?: string[]; disallowedDefinitions?: string[]; + disallowedTypes?: string[]; } let hasErrors = false; @@ -199,6 +246,14 @@ function checkFile(program: ts.Program, sourceFile: ts.SourceFile, rule: IRule) return; // override } + if (rule.disallowedTypes?.some(disallowed => disallowed === text)) { + const { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart()); + console.log(`[build/lib/layersChecker.ts]: Reference to '${text}' violates layer '${rule.target}' (${sourceFile.fileName} (${line + 1},${character + 1})`); + + hasErrors = true; + return; + } + const checker = program.getTypeChecker(); const symbol = checker.getSymbolAtLocation(node); if (symbol) { diff --git a/src/main.js b/src/main.js index e4662daa6b4..322fae7aca4 100644 --- a/src/main.js +++ b/src/main.js @@ -200,9 +200,9 @@ async function onReady() { } /** - * @typedef {{ [arg: string]: any; '--'?: string[]; _: string[]; }} ParsedArgs + * @typedef {{ [arg: string]: any; '--'?: string[]; _: string[]; }} NativeParsedArgs * - * @param {ParsedArgs} cliArgs + * @param {NativeParsedArgs} cliArgs */ function configureCommandlineSwitchesSync(cliArgs) { const SUPPORTED_ELECTRON_SWITCHES = [ @@ -355,7 +355,7 @@ function getArgvConfigPath() { } /** - * @param {ParsedArgs} cliArgs + * @param {NativeParsedArgs} cliArgs * @returns {string} */ function getJSFlags(cliArgs) { @@ -375,7 +375,7 @@ function getJSFlags(cliArgs) { } /** - * @param {ParsedArgs} cliArgs + * @param {NativeParsedArgs} cliArgs * * @returns {string} */ @@ -388,7 +388,7 @@ function getUserDataPath(cliArgs) { } /** - * @returns {ParsedArgs} + * @returns {NativeParsedArgs} */ function parseCLIArgs() { const minimist = require('minimist'); diff --git a/src/vs/base/parts/sandbox/electron-browser/preload.js b/src/vs/base/parts/sandbox/electron-browser/preload.js index d6bea974701..18fb9d62422 100644 --- a/src/vs/base/parts/sandbox/electron-browser/preload.js +++ b/src/vs/base/parts/sandbox/electron-browser/preload.js @@ -93,6 +93,7 @@ process: { platform: process.platform, env: process.env, + versions: process.versions, _whenEnvResolved: undefined, get whenEnvResolved() { if (!this._whenEnvResolved) { diff --git a/src/vs/base/parts/sandbox/electron-sandbox/globals.ts b/src/vs/base/parts/sandbox/electron-sandbox/globals.ts index a305df1c8a3..0c77d5dc453 100644 --- a/src/vs/base/parts/sandbox/electron-sandbox/globals.ts +++ b/src/vs/base/parts/sandbox/electron-sandbox/globals.ts @@ -94,6 +94,11 @@ export const process = (window as any).vscode.process as { * A listener on the process. Only a small subset of listener types are allowed. */ on: (type: string, callback: Function) => void; + + /** + * A list of versions for the current node.js/electron configuration. + */ + versions: { [key: string]: string | undefined }; }; export const context = (window as any).vscode.context as { diff --git a/src/vs/code/electron-browser/sharedProcess/contrib/languagePackCachedDataCleaner.ts b/src/vs/code/electron-browser/sharedProcess/contrib/languagePackCachedDataCleaner.ts index a1fbdef709f..38ee201e341 100644 --- a/src/vs/code/electron-browser/sharedProcess/contrib/languagePackCachedDataCleaner.ts +++ b/src/vs/code/electron-browser/sharedProcess/contrib/languagePackCachedDataCleaner.ts @@ -10,8 +10,7 @@ import product from 'vs/platform/product/common/product'; import { Disposable, toDisposable } from 'vs/base/common/lifecycle'; import { onUnexpectedError } from 'vs/base/common/errors'; import { ILogService } from 'vs/platform/log/common/log'; -import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; +import { IEnvironmentService, INativeEnvironmentService } from 'vs/platform/environment/common/environment'; interface ExtensionEntry { version: string; diff --git a/src/vs/code/electron-browser/sharedProcess/contrib/nodeCachedDataCleaner.ts b/src/vs/code/electron-browser/sharedProcess/contrib/nodeCachedDataCleaner.ts index a3d77fb7921..f115dbab0a6 100644 --- a/src/vs/code/electron-browser/sharedProcess/contrib/nodeCachedDataCleaner.ts +++ b/src/vs/code/electron-browser/sharedProcess/contrib/nodeCachedDataCleaner.ts @@ -7,8 +7,7 @@ import { basename, dirname, join } from 'vs/base/common/path'; import { onUnexpectedError } from 'vs/base/common/errors'; import { toDisposable, DisposableStore } from 'vs/base/common/lifecycle'; import { readdir, rimraf, stat } from 'vs/base/node/pfs'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; -import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService'; +import { IEnvironmentService, INativeEnvironmentService } from 'vs/platform/environment/common/environment'; import product from 'vs/platform/product/common/product'; export class NodeCachedDataCleaner { diff --git a/src/vs/code/electron-browser/sharedProcess/contrib/storageDataCleaner.ts b/src/vs/code/electron-browser/sharedProcess/contrib/storageDataCleaner.ts index 44dfe650c6f..e15f9b08aa8 100644 --- a/src/vs/code/electron-browser/sharedProcess/contrib/storageDataCleaner.ts +++ b/src/vs/code/electron-browser/sharedProcess/contrib/storageDataCleaner.ts @@ -3,8 +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 { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService'; +import { IEnvironmentService, INativeEnvironmentService } from 'vs/platform/environment/common/environment'; import { join } from 'vs/base/common/path'; import { readdir, readFile, rimraf } from 'vs/base/node/pfs'; import { onUnexpectedError } from 'vs/base/common/errors'; diff --git a/src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts b/src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts index 1e8351687cf..3d67e73ef30 100644 --- a/src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts +++ b/src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts @@ -11,7 +11,7 @@ import { ServiceCollection } from 'vs/platform/instantiation/common/serviceColle import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors'; import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; -import { ParsedArgs } from 'vs/platform/environment/node/argv'; +import { NativeParsedArgs } from 'vs/platform/environment/common/argv'; import { EnvironmentService } from 'vs/platform/environment/node/environmentService'; import { ExtensionManagementChannel, ExtensionTipsChannel } from 'vs/platform/extensionManagement/common/extensionManagementIpc'; import { IExtensionManagementService, IExtensionGalleryService, IGlobalExtensionEnablementService, IExtensionTipsService } from 'vs/platform/extensionManagement/common/extensionManagement'; @@ -81,7 +81,7 @@ export function startup(configuration: ISharedProcessConfiguration) { interface ISharedProcessInitData { sharedIPCHandle: string; - args: ParsedArgs; + args: NativeParsedArgs; logLevel: LogLevel; } @@ -116,7 +116,7 @@ async function main(server: Server, initData: ISharedProcessInitData, configurat disposables.add(server); - const environmentService = new EnvironmentService(initData.args, process.execPath); + const environmentService = new EnvironmentService(initData.args); const mainRouter = new StaticRouter(ctx => ctx === 'main'); const loggerClient = new LoggerChannelClient(server.getChannel('logger', mainRouter)); diff --git a/src/vs/code/electron-main/app.ts b/src/vs/code/electron-main/app.ts index f807ca49def..8fd9ded27b6 100644 --- a/src/vs/code/electron-main/app.ts +++ b/src/vs/code/electron-main/app.ts @@ -22,7 +22,7 @@ import { ServiceCollection } from 'vs/platform/instantiation/common/serviceColle import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors'; import { ILogService } from 'vs/platform/log/common/log'; import { IStateService } from 'vs/platform/state/node/state'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; +import { IEnvironmentService, INativeEnvironmentService } from 'vs/platform/environment/common/environment'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IURLService } from 'vs/platform/url/common/url'; import { URLHandlerChannelClient, URLHandlerRouter } from 'vs/platform/url/common/urlIpc'; @@ -76,7 +76,6 @@ import { withNullAsUndefined } from 'vs/base/common/types'; import { coalesce } from 'vs/base/common/arrays'; import { IStorageKeysSyncRegistryService } from 'vs/platform/userDataSync/common/storageKeys'; import { StorageKeysSyncRegistryChannel } from 'vs/platform/userDataSync/common/userDataSyncIpc'; -import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService'; import { mnemonicButtonLabel, getPathLabel } from 'vs/base/common/labels'; import { WebviewMainService } from 'vs/platform/webview/electron-main/webviewMainService'; import { IWebviewManagerService } from 'vs/platform/webview/common/webviewManagerService'; diff --git a/src/vs/code/electron-main/main.ts b/src/vs/code/electron-main/main.ts index 6eff9997fbe..66f1cd08c3e 100644 --- a/src/vs/code/electron-main/main.ts +++ b/src/vs/code/electron-main/main.ts @@ -5,12 +5,12 @@ import 'vs/platform/update/common/update.config.contribution'; import { app, dialog } from 'electron'; -import { isWindows, IProcessEnvironment } from 'vs/base/common/platform'; +import * as fs from 'fs'; +import { isWindows, IProcessEnvironment, isMacintosh } from 'vs/base/common/platform'; import product from 'vs/platform/product/common/product'; import { parseMainProcessArgv, addArg } from 'vs/platform/environment/node/argvHelper'; import { createWaitMarkerFile } from 'vs/platform/environment/node/waitMarkerFile'; import { mkdirp } from 'vs/base/node/pfs'; -import { validatePaths } from 'vs/code/node/paths'; import { LifecycleMainService, ILifecycleMainService } from 'vs/platform/lifecycle/electron-main/lifecycleMainService'; import { Server, serve, connect } from 'vs/base/parts/ipc/node/ipc.net'; import { createChannelSender } from 'vs/base/parts/ipc/common/ipc'; @@ -22,14 +22,13 @@ import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors'; import { ILogService, ConsoleLogMainService, MultiplexLogService, getLogLevel } from 'vs/platform/log/common/log'; import { StateService } from 'vs/platform/state/node/stateService'; import { IStateService } from 'vs/platform/state/node/state'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; -import { ParsedArgs } from 'vs/platform/environment/node/argv'; -import { EnvironmentService, xdgRuntimeDir, INativeEnvironmentService } from 'vs/platform/environment/node/environmentService'; +import { IEnvironmentService, INativeEnvironmentService } from 'vs/platform/environment/common/environment'; +import { NativeParsedArgs } from 'vs/platform/environment/common/argv'; +import { EnvironmentService, xdgRuntimeDir } from 'vs/platform/environment/node/environmentService'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { ConfigurationService } from 'vs/platform/configuration/common/configurationService'; import { IRequestService } from 'vs/platform/request/common/request'; import { RequestMainService } from 'vs/platform/request/electron-main/requestMainService'; -import * as fs from 'fs'; import { CodeApplication } from 'vs/code/electron-main/app'; import { localize } from 'vs/nls'; import { mnemonicButtonLabel } from 'vs/base/common/labels'; @@ -50,6 +49,11 @@ import { IStorageKeysSyncRegistryService, StorageKeysSyncRegistryService } from import { ITunnelService } from 'vs/platform/remote/common/tunnel'; import { TunnelService } from 'vs/platform/remote/node/tunnelService'; import { IProductService } from 'vs/platform/product/common/productService'; +import { IPathWithLineAndColumn, isValidBasename, parseLineAndColumnAware, sanitizeFilePath } from 'vs/base/common/extpath'; +import { isNumber } from 'vs/base/common/types'; +import { rtrim, trim } from 'vs/base/common/strings'; +import { basename, resolve } from 'vs/base/common/path'; +import { coalesce, distinct } from 'vs/base/common/arrays'; class ExpectedError extends Error { readonly isExpected = true; @@ -64,10 +68,10 @@ class CodeMain { setUnexpectedErrorHandler(err => console.error(err)); // Parse arguments - let args: ParsedArgs; + let args: NativeParsedArgs; try { args = parseMainProcessArgv(process.argv); - args = validatePaths(args); + args = this.validatePaths(args); } catch (err) { console.error(err.message); app.exit(1); @@ -94,7 +98,7 @@ class CodeMain { this.startup(args); } - private async startup(args: ParsedArgs): Promise { + private async startup(args: NativeParsedArgs): Promise { // We need to buffer the spdlog logs until we are sure // we are the only instance running, otherwise we'll have concurrent @@ -142,10 +146,10 @@ class CodeMain { } } - private createServices(args: ParsedArgs, bufferLogService: BufferLogService): [IInstantiationService, IProcessEnvironment, INativeEnvironmentService] { + private createServices(args: NativeParsedArgs, bufferLogService: BufferLogService): [IInstantiationService, IProcessEnvironment, INativeEnvironmentService] { const services = new ServiceCollection(); - const environmentService = new EnvironmentService(args, process.execPath); + const environmentService = new EnvironmentService(args); const instanceEnvironment = this.patchEnvironment(environmentService); // Patch `process.env` with the instance's environment services.set(IEnvironmentService, environmentService); @@ -209,7 +213,7 @@ class CodeMain { return instanceEnvironment; } - private async doStartup(args: ParsedArgs, logService: ILogService, environmentService: INativeEnvironmentService, lifecycleMainService: ILifecycleMainService, instantiationService: IInstantiationService, retry: boolean): Promise { + private async doStartup(args: NativeParsedArgs, logService: ILogService, environmentService: INativeEnvironmentService, lifecycleMainService: ILifecycleMainService, instantiationService: IInstantiationService, retry: boolean): Promise { // Try to setup a server for running. If that succeeds it means // we are the first instance to startup. Otherwise it is likely @@ -409,6 +413,100 @@ class CodeMain { lifecycleMainService.kill(exitCode); } + + //#region Helpers + + private validatePaths(args: NativeParsedArgs): NativeParsedArgs { + + // Track URLs if they're going to be used + if (args['open-url']) { + args._urls = args._; + args._ = []; + } + + // Normalize paths and watch out for goto line mode + if (!args['remote']) { + const paths = this.doValidatePaths(args._, args.goto); + args._ = paths; + } + + return args; + } + + private doValidatePaths(args: string[], gotoLineMode?: boolean): string[] { + const cwd = process.env['VSCODE_CWD'] || process.cwd(); + const result = args.map(arg => { + let pathCandidate = String(arg); + + let parsedPath: IPathWithLineAndColumn | undefined = undefined; + if (gotoLineMode) { + parsedPath = parseLineAndColumnAware(pathCandidate); + pathCandidate = parsedPath.path; + } + + if (pathCandidate) { + pathCandidate = this.preparePath(cwd, pathCandidate); + } + + const sanitizedFilePath = sanitizeFilePath(pathCandidate, cwd); + + const filePathBasename = basename(sanitizedFilePath); + if (filePathBasename /* can be empty if code is opened on root */ && !isValidBasename(filePathBasename)) { + return null; // do not allow invalid file names + } + + if (gotoLineMode && parsedPath) { + parsedPath.path = sanitizedFilePath; + + return this.toPath(parsedPath); + } + + return sanitizedFilePath; + }); + + const caseInsensitive = isWindows || isMacintosh; + const distinctPaths = distinct(result, path => path && caseInsensitive ? path.toLowerCase() : (path || '')); + + return coalesce(distinctPaths); + } + + private preparePath(cwd: string, path: string): string { + + // Trim trailing quotes + if (isWindows) { + path = rtrim(path, '"'); // https://github.com/Microsoft/vscode/issues/1498 + } + + // Trim whitespaces + path = trim(trim(path, ' '), '\t'); + + if (isWindows) { + + // Resolve the path against cwd if it is relative + path = resolve(cwd, path); + + // Trim trailing '.' chars on Windows to prevent invalid file names + path = rtrim(path, '.'); + } + + return path; + } + + private toPath(pathWithLineAndCol: IPathWithLineAndColumn): string { + const segments = [pathWithLineAndCol.path]; + + if (isNumber(pathWithLineAndCol.line)) { + segments.push(String(pathWithLineAndCol.line)); + } + + if (isNumber(pathWithLineAndCol.column)) { + segments.push(String(pathWithLineAndCol.column)); + } + + return segments.join(':'); + } + + //#endregion } // Main Startup diff --git a/src/vs/code/electron-main/sharedProcess.ts b/src/vs/code/electron-main/sharedProcess.ts index d225e6eb31d..a6ef6be6ce1 100644 --- a/src/vs/code/electron-main/sharedProcess.ts +++ b/src/vs/code/electron-main/sharedProcess.ts @@ -5,7 +5,7 @@ import { URI } from 'vs/base/common/uri'; import { memoize } from 'vs/base/common/decorators'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; +import { IEnvironmentService, INativeEnvironmentService } from 'vs/platform/environment/common/environment'; import { BrowserWindow, ipcMain, WebContents, Event as ElectronEvent } from 'electron'; import { ISharedProcess } from 'vs/platform/ipc/electron-main/sharedProcessMainService'; import { Barrier } from 'vs/base/common/async'; @@ -14,7 +14,6 @@ import { ILifecycleMainService } from 'vs/platform/lifecycle/electron-main/lifec import { IThemeMainService } from 'vs/platform/theme/electron-main/themeMainService'; import { toDisposable, DisposableStore } from 'vs/base/common/lifecycle'; import { Event } from 'vs/base/common/event'; -import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService'; export class SharedProcess implements ISharedProcess { diff --git a/src/vs/code/electron-main/window.ts b/src/vs/code/electron-main/window.ts index 420715ff1fe..c95d26feb5f 100644 --- a/src/vs/code/electron-main/window.ts +++ b/src/vs/code/electron-main/window.ts @@ -9,17 +9,16 @@ import * as nls from 'vs/nls'; import { Emitter } from 'vs/base/common/event'; import { URI } from 'vs/base/common/uri'; import { screen, BrowserWindow, systemPreferences, app, TouchBar, nativeImage, Rectangle, Display, TouchBarSegmentedControl, NativeImage, BrowserWindowConstructorOptions, SegmentedControlSegment, nativeTheme, Event, Details } from 'electron'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; -import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService'; +import { IEnvironmentService, INativeEnvironmentService } from 'vs/platform/environment/common/environment'; import { ILogService } from 'vs/platform/log/common/log'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; -import { parseArgs, OPTIONS, ParsedArgs } from 'vs/platform/environment/node/argv'; +import { parseArgs, OPTIONS } from 'vs/platform/environment/node/argv'; +import { NativeParsedArgs } from 'vs/platform/environment/common/argv'; import product from 'vs/platform/product/common/product'; -import { IWindowSettings, MenuBarVisibility, getTitleBarStyle, getMenuBarVisibility, zoomLevelToZoomFactor } from 'vs/platform/windows/common/windows'; +import { IWindowSettings, MenuBarVisibility, getTitleBarStyle, getMenuBarVisibility, zoomLevelToZoomFactor, INativeWindowConfiguration } from 'vs/platform/windows/common/windows'; import { Disposable, toDisposable } from 'vs/base/common/lifecycle'; import { isLinux, isMacintosh, isWindows } from 'vs/base/common/platform'; import { ICodeWindow, IWindowState, WindowMode } from 'vs/platform/windows/electron-main/windows'; -import { INativeWindowConfiguration } from 'vs/platform/windows/node/window'; import { IWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces'; import { IWorkspacesMainService } from 'vs/platform/workspaces/electron-main/workspacesMainService'; import { IBackupMainService } from 'vs/platform/backup/electron-main/backup'; @@ -740,7 +739,7 @@ export class CodeWindow extends Disposable implements ICodeWindow { this._onLoad.fire(); } - reload(configurationIn?: INativeWindowConfiguration, cli?: ParsedArgs): void { + reload(configurationIn?: INativeWindowConfiguration, cli?: NativeParsedArgs): void { // If config is not provided, copy our current one const configuration = configurationIn ? configurationIn : objects.mixin({}, this.currentConfig); diff --git a/src/vs/code/node/cli.ts b/src/vs/code/node/cli.ts index 69f2f37b3df..5f2d74a1c68 100644 --- a/src/vs/code/node/cli.ts +++ b/src/vs/code/node/cli.ts @@ -6,7 +6,8 @@ import * as os from 'os'; import * as fs from 'fs'; import { spawn, ChildProcess, SpawnOptions } from 'child_process'; -import { buildHelpMessage, buildVersionMessage, OPTIONS, ParsedArgs } from 'vs/platform/environment/node/argv'; +import { buildHelpMessage, buildVersionMessage, OPTIONS } from 'vs/platform/environment/node/argv'; +import { NativeParsedArgs } from 'vs/platform/environment/common/argv'; import { parseCLIProcessArgv, addArg } from 'vs/platform/environment/node/argvHelper'; import { createWaitMarkerFile } from 'vs/platform/environment/node/waitMarkerFile'; import product from 'vs/platform/product/common/product'; @@ -18,7 +19,7 @@ import type { ProfilingSession, Target } from 'v8-inspect-profiler'; import { isString } from 'vs/base/common/types'; import { hasStdinWithoutTty, stdinDataListener, getStdinFilePath, readFromStdin } from 'vs/platform/environment/node/stdin'; -function shouldSpawnCliProcess(argv: ParsedArgs): boolean { +function shouldSpawnCliProcess(argv: NativeParsedArgs): boolean { return !!argv['install-source'] || !!argv['list-extensions'] || !!argv['install-extension'] @@ -28,11 +29,11 @@ function shouldSpawnCliProcess(argv: ParsedArgs): boolean { } interface IMainCli { - main: (argv: ParsedArgs) => Promise; + main: (argv: NativeParsedArgs) => Promise; } export async function main(argv: string[]): Promise { - let args: ParsedArgs; + let args: NativeParsedArgs; try { args = parseCLIProcessArgv(argv); diff --git a/src/vs/code/node/cliProcessMain.ts b/src/vs/code/node/cliProcessMain.ts index b528f7dd343..a3928092c23 100644 --- a/src/vs/code/node/cliProcessMain.ts +++ b/src/vs/code/node/cliProcessMain.ts @@ -11,9 +11,9 @@ import { ServiceCollection } from 'vs/platform/instantiation/common/serviceColle import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; -import { ParsedArgs } from 'vs/platform/environment/node/argv'; -import { EnvironmentService, INativeEnvironmentService } from 'vs/platform/environment/node/environmentService'; +import { IEnvironmentService, INativeEnvironmentService } from 'vs/platform/environment/common/environment'; +import { NativeParsedArgs } from 'vs/platform/environment/common/argv'; +import { EnvironmentService } from 'vs/platform/environment/node/environmentService'; import { IExtensionManagementService, IExtensionGalleryService, IGalleryExtension, ILocalExtension } from 'vs/platform/extensionManagement/common/extensionManagement'; import { ExtensionManagementService } from 'vs/platform/extensionManagement/node/extensionManagementService'; import { ExtensionGalleryService } from 'vs/platform/extensionManagement/common/extensionGalleryService'; @@ -79,7 +79,7 @@ export class Main { @IExtensionGalleryService private readonly extensionGalleryService: IExtensionGalleryService ) { } - async run(argv: ParsedArgs): Promise { + async run(argv: NativeParsedArgs): Promise { if (argv['install-source']) { await this.setInstallSource(argv['install-source']); } else if (argv['list-extensions']) { @@ -295,11 +295,11 @@ export class Main { const eventPrefix = 'monacoworkbench'; -export async function main(argv: ParsedArgs): Promise { +export async function main(argv: NativeParsedArgs): Promise { const services = new ServiceCollection(); const disposables = new DisposableStore(); - const environmentService = new EnvironmentService(argv, process.execPath); + const environmentService = new EnvironmentService(argv); const logService: ILogService = new SpdLogService('cli', environmentService.logsPath, getLogLevel(environmentService)); process.once('exit', () => logService.dispose()); logService.info('main', argv); diff --git a/src/vs/code/node/paths.ts b/src/vs/code/node/paths.ts deleted file mode 100644 index b2912383c3c..00000000000 --- a/src/vs/code/node/paths.ts +++ /dev/null @@ -1,102 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -import * as path from 'vs/base/common/path'; -import * as arrays from 'vs/base/common/arrays'; -import * as strings from 'vs/base/common/strings'; -import * as extpath from 'vs/base/common/extpath'; -import * as platform from 'vs/base/common/platform'; -import * as types from 'vs/base/common/types'; -import { ParsedArgs } from 'vs/platform/environment/node/argv'; - -export function validatePaths(args: ParsedArgs): ParsedArgs { - - // Track URLs if they're going to be used - if (args['open-url']) { - args._urls = args._; - args._ = []; - } - - // Normalize paths and watch out for goto line mode - if (!args['remote']) { - const paths = doValidatePaths(args._, args.goto); - args._ = paths; - } - - return args; -} - -function doValidatePaths(args: string[], gotoLineMode?: boolean): string[] { - const cwd = process.env['VSCODE_CWD'] || process.cwd(); - const result = args.map(arg => { - let pathCandidate = String(arg); - - let parsedPath: extpath.IPathWithLineAndColumn | undefined = undefined; - if (gotoLineMode) { - parsedPath = extpath.parseLineAndColumnAware(pathCandidate); - pathCandidate = parsedPath.path; - } - - if (pathCandidate) { - pathCandidate = preparePath(cwd, pathCandidate); - } - - const sanitizedFilePath = extpath.sanitizeFilePath(pathCandidate, cwd); - - const basename = path.basename(sanitizedFilePath); - if (basename /* can be empty if code is opened on root */ && !extpath.isValidBasename(basename)) { - return null; // do not allow invalid file names - } - - if (gotoLineMode && parsedPath) { - parsedPath.path = sanitizedFilePath; - - return toPath(parsedPath); - } - - return sanitizedFilePath; - }); - - const caseInsensitive = platform.isWindows || platform.isMacintosh; - const distinct = arrays.distinct(result, e => e && caseInsensitive ? e.toLowerCase() : (e || '')); - - return arrays.coalesce(distinct); -} - -function preparePath(cwd: string, p: string): string { - - // Trim trailing quotes - if (platform.isWindows) { - p = strings.rtrim(p, '"'); // https://github.com/Microsoft/vscode/issues/1498 - } - - // Trim whitespaces - p = strings.trim(strings.trim(p, ' '), '\t'); - - if (platform.isWindows) { - - // Resolve the path against cwd if it is relative - p = path.resolve(cwd, p); - - // Trim trailing '.' chars on Windows to prevent invalid file names - p = strings.rtrim(p, '.'); - } - - return p; -} - -function toPath(p: extpath.IPathWithLineAndColumn): string { - const segments = [p.path]; - - if (types.isNumber(p.line)) { - segments.push(String(p.line)); - } - - if (types.isNumber(p.column)) { - segments.push(String(p.column)); - } - - return segments.join(':'); -} diff --git a/src/vs/code/node/shellEnv.ts b/src/vs/code/node/shellEnv.ts index 0383550627a..a089ffe4f84 100644 --- a/src/vs/code/node/shellEnv.ts +++ b/src/vs/code/node/shellEnv.ts @@ -7,7 +7,7 @@ import { spawn } from 'child_process'; import { generateUuid } from 'vs/base/common/uuid'; import { isWindows } from 'vs/base/common/platform'; import { ILogService } from 'vs/platform/log/common/log'; -import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService'; +import { INativeEnvironmentService } from 'vs/platform/environment/common/environment'; function getUnixShellEnvironment(logService: ILogService): Promise { const promise = new Promise((resolve, reject) => { diff --git a/src/vs/platform/backup/electron-main/backupMainService.ts b/src/vs/platform/backup/electron-main/backupMainService.ts index 8b797cf0fb6..b323b460034 100644 --- a/src/vs/platform/backup/electron-main/backupMainService.ts +++ b/src/vs/platform/backup/electron-main/backupMainService.ts @@ -10,8 +10,7 @@ import * as platform from 'vs/base/common/platform'; import { writeFileSync, writeFile, readFile, readdir, exists, rimraf, rename, RimRafMode } from 'vs/base/node/pfs'; import { IBackupMainService, IWorkspaceBackupInfo, isWorkspaceBackupInfo } from 'vs/platform/backup/electron-main/backup'; import { IBackupWorkspacesFormat, IEmptyWindowBackupInfo } from 'vs/platform/backup/node/backup'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; -import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService'; +import { IEnvironmentService, INativeEnvironmentService } from 'vs/platform/environment/common/environment'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IFilesConfiguration, HotExitConfiguration } from 'vs/platform/files/common/files'; import { ILogService } from 'vs/platform/log/common/log'; diff --git a/src/vs/platform/backup/test/electron-main/backupMainService.test.ts b/src/vs/platform/backup/test/electron-main/backupMainService.test.ts index 14d6bf48f10..c03aba9ede0 100644 --- a/src/vs/platform/backup/test/electron-main/backupMainService.test.ts +++ b/src/vs/platform/backup/test/electron-main/backupMainService.test.ts @@ -34,7 +34,7 @@ suite('BackupMainService', () => { const backupHome = path.join(parentDir, 'Backups'); const backupWorkspacesPath = path.join(backupHome, 'workspaces.json'); - const environmentService = new EnvironmentService(parseArgs(process.argv, OPTIONS), process.execPath); + const environmentService = new EnvironmentService(parseArgs(process.argv, OPTIONS)); class TestBackupMainService extends BackupMainService { diff --git a/src/vs/platform/dialogs/electron-browser/dialogIpc.ts b/src/vs/platform/dialogs/electron-browser/dialogIpc.ts deleted file mode 100644 index d3d57643920..00000000000 --- a/src/vs/platform/dialogs/electron-browser/dialogIpc.ts +++ /dev/null @@ -1,26 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -import { IServerChannel } from 'vs/base/parts/ipc/common/ipc'; -import { IDialogService } from 'vs/platform/dialogs/common/dialogs'; -import { Event } from 'vs/base/common/event'; - -export class DialogChannel implements IServerChannel { - - constructor(@IDialogService private readonly dialogService: IDialogService) { } - - listen(_: unknown, event: string): Event { - throw new Error(`Event not found: ${event}`); - } - - call(_: unknown, command: string, args?: any[]): Promise { - switch (command) { - case 'show': return this.dialogService.show(args![0], args![1], args![2]); - case 'confirm': return this.dialogService.confirm(args![0]); - case 'about': return this.dialogService.about(); - } - return Promise.reject(new Error('invalid command')); - } -} diff --git a/src/vs/platform/driver/electron-main/driver.ts b/src/vs/platform/driver/electron-main/driver.ts index b8b703f05ff..0cfe2f7732a 100644 --- a/src/vs/platform/driver/electron-main/driver.ts +++ b/src/vs/platform/driver/electron-main/driver.ts @@ -13,7 +13,7 @@ import { SimpleKeybinding, KeyCode } from 'vs/base/common/keyCodes'; import { USLayoutResolvedKeybinding } from 'vs/platform/keybinding/common/usLayoutResolvedKeybinding'; import { OS } from 'vs/base/common/platform'; import { Emitter, Event } from 'vs/base/common/event'; -import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService'; +import { INativeEnvironmentService } from 'vs/platform/environment/common/environment'; import { ScanCodeBinding } from 'vs/base/common/scanCode'; import { KeybindingParser } from 'vs/base/common/keybindingParser'; import { timeout } from 'vs/base/common/async'; diff --git a/src/vs/platform/electron/common/electron.ts b/src/vs/platform/electron/common/electron.ts index 1061d20d16f..cd4c3502b69 100644 --- a/src/vs/platform/electron/common/electron.ts +++ b/src/vs/platform/electron/common/electron.ts @@ -9,6 +9,13 @@ import { IOpenedWindow, IWindowOpenable, IOpenEmptyWindowOptions, IOpenWindowOpt import { INativeOpenDialogOptions } from 'vs/platform/dialogs/common/dialogs'; import { ISerializableCommandAction } from 'vs/platform/actions/common/actions'; +export interface IOSProperties { + type: string; + release: string; + arch: string; + platform: string; +} + export interface ICommonElectronService { readonly _serviceBrand: undefined; @@ -73,6 +80,7 @@ export interface ICommonElectronService { moveItemToTrash(fullPath: string, deleteOnFail?: boolean): Promise; isAdmin(): Promise; getTotalMem(): Promise; + getOS(): Promise; // Process killProcess(pid: number, code: string): Promise; diff --git a/src/vs/platform/electron/electron-main/electronMainService.ts b/src/vs/platform/electron/electron-main/electronMainService.ts index 91693f0be75..deedb70ea3a 100644 --- a/src/vs/platform/electron/electron-main/electronMainService.ts +++ b/src/vs/platform/electron/electron-main/electronMainService.ts @@ -11,18 +11,17 @@ import { ILifecycleMainService } from 'vs/platform/lifecycle/electron-main/lifec import { IOpenedWindow, IOpenWindowOptions, IWindowOpenable, IOpenEmptyWindowOptions } from 'vs/platform/windows/common/windows'; import { INativeOpenDialogOptions } from 'vs/platform/dialogs/common/dialogs'; import { isMacintosh, isWindows, isRootUser } from 'vs/base/common/platform'; -import { ICommonElectronService } from 'vs/platform/electron/common/electron'; +import { ICommonElectronService, IOSProperties } from 'vs/platform/electron/common/electron'; import { ISerializableCommandAction } from 'vs/platform/actions/common/actions'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; +import { IEnvironmentService, INativeEnvironmentService } from 'vs/platform/environment/common/environment'; import { AddFirstParameterToFunctions } from 'vs/base/common/types'; import { IDialogMainService } from 'vs/platform/dialogs/electron-main/dialogs'; import { dirExists } from 'vs/base/node/pfs'; import { URI } from 'vs/base/common/uri'; import { ITelemetryData, ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; -import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService'; import { MouseInputEvent } from 'vs/base/parts/sandbox/common/electronTypes'; -import { totalmem } from 'os'; +import { arch, totalmem, release, platform, type } from 'os'; export interface IElectronMainService extends AddFirstParameterToFunctions /* only methods, not events */, number | undefined /* window ID */> { } @@ -316,6 +315,15 @@ export class ElectronMainService implements IElectronMainService { return totalmem(); } + async getOS(): Promise { + return { + arch: arch(), + platform: platform(), + release: release(), + type: type() + }; + } + //#endregion diff --git a/src/vs/platform/environment/common/argv.ts b/src/vs/platform/environment/common/argv.ts new file mode 100644 index 00000000000..db19acb10c7 --- /dev/null +++ b/src/vs/platform/environment/common/argv.ts @@ -0,0 +1,96 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +/** + * A list of command line arguments we support natively. + */ +export interface NativeParsedArgs { + _: string[]; + 'folder-uri'?: string[]; // undefined or array of 1 or more + 'file-uri'?: string[]; // undefined or array of 1 or more + _urls?: string[]; + help?: boolean; + version?: boolean; + telemetry?: boolean; + status?: boolean; + wait?: boolean; + waitMarkerFilePath?: string; + diff?: boolean; + add?: boolean; + goto?: boolean; + 'new-window'?: boolean; + 'unity-launch'?: boolean; // Always open a new window, except if opening the first window or opening a file or folder as part of the launch. + 'reuse-window'?: boolean; + locale?: string; + 'user-data-dir'?: string; + 'prof-startup'?: boolean; + 'prof-startup-prefix'?: string; + 'prof-append-timers'?: string; + verbose?: boolean; + trace?: boolean; + 'trace-category-filter'?: string; + 'trace-options'?: string; + 'open-devtools'?: boolean; + log?: string; + logExtensionHostCommunication?: boolean; + 'extensions-dir'?: string; + 'extensions-download-dir'?: string; + 'builtin-extensions-dir'?: string; + extensionDevelopmentPath?: string[]; // // undefined or array of 1 or more local paths or URIs + extensionTestsPath?: string; // either a local path or a URI + 'inspect-extensions'?: string; + 'inspect-brk-extensions'?: string; + debugId?: string; + 'inspect-search'?: string; + 'inspect-brk-search'?: string; + 'disable-extensions'?: boolean; + 'disable-extension'?: string[]; // undefined or array of 1 or more + 'list-extensions'?: boolean; + 'show-versions'?: boolean; + 'category'?: string; + 'install-extension'?: string[]; // undefined or array of 1 or more + 'uninstall-extension'?: string[]; // undefined or array of 1 or more + 'locate-extension'?: string[]; // undefined or array of 1 or more + 'enable-proposed-api'?: string[]; // undefined or array of 1 or more + 'open-url'?: boolean; + 'skip-release-notes'?: boolean; + 'disable-restore-windows'?: boolean; + 'disable-telemetry'?: boolean; + 'export-default-configuration'?: string; + 'install-source'?: string; + 'disable-updates'?: boolean; + 'disable-crash-reporter'?: boolean; + 'crash-reporter-directory'?: string; + 'crash-reporter-id'?: string; + 'skip-add-to-recently-opened'?: boolean; + 'max-memory'?: string; + 'file-write'?: boolean; + 'file-chmod'?: boolean; + 'driver'?: string; + 'driver-verbose'?: boolean; + 'remote'?: string; + 'disable-user-env-probe'?: boolean; + 'force'?: boolean; + 'do-not-sync'?: boolean; + 'force-user-env'?: boolean; + 'sync'?: 'on' | 'off'; + '__sandbox'?: boolean; + + // chromium command line args: https://electronjs.org/docs/all#supported-chrome-command-line-switches + 'no-proxy-server'?: boolean; + 'proxy-server'?: string; + 'proxy-bypass-list'?: string; + 'proxy-pac-url'?: string; + 'inspect'?: string; + 'inspect-brk'?: string; + 'js-flags'?: string; + 'disable-gpu'?: boolean; + 'nolazy'?: boolean; + 'force-device-scale-factor'?: string; + 'force-renderer-accessibility'?: boolean; + 'ignore-certificate-errors'?: boolean; + 'allow-insecure-localhost'?: boolean; + 'log-net-log'?: string; +} diff --git a/src/vs/platform/environment/common/environment.ts b/src/vs/platform/environment/common/environment.ts index 6ff81a44fd2..acd11a3d65d 100644 --- a/src/vs/platform/environment/common/environment.ts +++ b/src/vs/platform/environment/common/environment.ts @@ -5,6 +5,7 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; import { URI } from 'vs/base/common/uri'; +import { NativeParsedArgs } from 'vs/platform/environment/common/argv'; export const IEnvironmentService = createDecorator('environmentService'); @@ -19,12 +20,18 @@ export interface IExtensionHostDebugParams extends IDebugParams { export const BACKUPS = 'Backups'; +/** + * A basic environment service that can be used in various processes, + * such as main, renderer and shared process. Use subclasses of this + * service for specific environment. + */ export interface IEnvironmentService { - // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - // NOTE: DO NOT ADD ANY OTHER PROPERTY INTO THE COLLECTION HERE - // UNLESS THIS PROPERTY IS SUPPORTED BOTH IN WEB AND NATIVE!!!! - // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + // NOTE: KEEP THIS INTERFACE AS SMALL AS POSSIBLE. AS SUCH: + // - PUT NON-WEB PROPERTIES INTO NATIVE ENV SERVICE + // - PUT WORKBENCH ONLY PROPERTIES INTO WB ENV SERVICE + // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! readonly _serviceBrand: undefined; @@ -55,8 +62,6 @@ export interface IEnvironmentService { disableExtensions: boolean | string[]; extensionDevelopmentLocationURI?: URI[]; extensionTestsLocationURI?: URI; - extensionEnabledProposedApi?: string[]; - logExtensionHostCommunication?: boolean; // --- logging logsPath: string; @@ -68,8 +73,56 @@ export interface IEnvironmentService { disableTelemetry: boolean; serviceMachineIdResource: URI; - // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - // NOTE: DO NOT ADD ANY OTHER PROPERTY INTO THE COLLECTION HERE - // UNLESS THIS PROPERTY IS SUPPORTED BOTH IN WEB AND NATIVE!!!! - // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + // NOTE: KEEP THIS INTERFACE AS SMALL AS POSSIBLE. AS SUCH: + // - PUT NON-WEB PROPERTIES INTO NATIVE ENV SERVICE + // - PUT WORKBENCH ONLY PROPERTIES INTO WB ENV SERVICE + // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +} + +/** + * A subclass of the `IEnvironmentService` to be used only in native + * environments (Windows, Linux, macOS) but not e.g. web. + */ +export interface INativeEnvironmentService extends IEnvironmentService { + + // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + // NOTE: KEEP THIS INTERFACE AS SMALL AS POSSIBLE. AS SUCH: + // - PUT WORKBENCH ONLY PROPERTIES INTO WB ENV SERVICE + // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + + // --- CLI Arguments + args: NativeParsedArgs; + + // --- paths + appRoot: string; + userHome: URI; + appSettingsHome: URI; + userDataPath: string; + machineSettingsResource: URI; + backupWorkspacesPath: string; + nodeCachedDataDir?: string; + installSourcePath: string; + + // --- IPC Handles + mainIPCHandle: string; + sharedIPCHandle: string; + + // --- Extensions + extensionsPath?: string; + extensionsDownloadPath: string; + builtinExtensionsPath: string; + + // --- Smoke test support + driverHandle?: string; + driverVerbose: boolean; + + // --- Misc. config + disableUpdates: boolean; + sandbox: boolean; + + // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + // NOTE: KEEP THIS INTERFACE AS SMALL AS POSSIBLE. AS SUCH: + // - PUT WORKBENCH ONLY PROPERTIES INTO WB ENV SERVICE + // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! } diff --git a/src/vs/platform/environment/node/argv.ts b/src/vs/platform/environment/node/argv.ts index 92dd2bcf87d..506d03750b5 100644 --- a/src/vs/platform/environment/node/argv.ts +++ b/src/vs/platform/environment/node/argv.ts @@ -6,95 +6,7 @@ import * as minimist from 'minimist'; import { localize } from 'vs/nls'; import { isWindows } from 'vs/base/common/platform'; - -export interface ParsedArgs { - _: string[]; - 'folder-uri'?: string[]; // undefined or array of 1 or more - 'file-uri'?: string[]; // undefined or array of 1 or more - _urls?: string[]; - help?: boolean; - version?: boolean; - telemetry?: boolean; - status?: boolean; - wait?: boolean; - waitMarkerFilePath?: string; - diff?: boolean; - add?: boolean; - goto?: boolean; - 'new-window'?: boolean; - 'unity-launch'?: boolean; // Always open a new window, except if opening the first window or opening a file or folder as part of the launch. - 'reuse-window'?: boolean; - locale?: string; - 'user-data-dir'?: string; - 'prof-startup'?: boolean; - 'prof-startup-prefix'?: string; - 'prof-append-timers'?: string; - verbose?: boolean; - trace?: boolean; - 'trace-category-filter'?: string; - 'trace-options'?: string; - 'open-devtools'?: boolean; - log?: string; - logExtensionHostCommunication?: boolean; - 'extensions-dir'?: string; - 'extensions-download-dir'?: string; - 'builtin-extensions-dir'?: string; - extensionDevelopmentPath?: string[]; // // undefined or array of 1 or more local paths or URIs - extensionTestsPath?: string; // either a local path or a URI - 'inspect-extensions'?: string; - 'inspect-brk-extensions'?: string; - debugId?: string; - 'inspect-search'?: string; - 'inspect-brk-search'?: string; - 'disable-extensions'?: boolean; - 'disable-extension'?: string[]; // undefined or array of 1 or more - 'list-extensions'?: boolean; - 'show-versions'?: boolean; - 'category'?: string; - 'install-extension'?: string[]; // undefined or array of 1 or more - 'uninstall-extension'?: string[]; // undefined or array of 1 or more - 'locate-extension'?: string[]; // undefined or array of 1 or more - 'enable-proposed-api'?: string[]; // undefined or array of 1 or more - 'open-url'?: boolean; - 'skip-release-notes'?: boolean; - 'disable-restore-windows'?: boolean; - 'disable-telemetry'?: boolean; - 'export-default-configuration'?: string; - 'install-source'?: string; - 'disable-updates'?: boolean; - 'disable-crash-reporter'?: boolean; - 'crash-reporter-directory'?: string; - 'crash-reporter-id'?: string; - 'skip-add-to-recently-opened'?: boolean; - 'max-memory'?: string; - 'file-write'?: boolean; - 'file-chmod'?: boolean; - 'driver'?: string; - 'driver-verbose'?: boolean; - 'remote'?: string; - 'disable-user-env-probe'?: boolean; - 'force'?: boolean; - 'do-not-sync'?: boolean; - 'force-user-env'?: boolean; - 'sync'?: 'on' | 'off'; - '__sandbox'?: boolean; - - // chromium command line args: https://electronjs.org/docs/all#supported-chrome-command-line-switches - 'no-proxy-server'?: boolean; - 'proxy-server'?: string; - 'proxy-bypass-list'?: string; - 'proxy-pac-url'?: string; - 'inspect'?: string; - 'inspect-brk'?: string; - 'js-flags'?: string; - 'disable-gpu'?: boolean; - 'nolazy'?: boolean; - 'force-device-scale-factor'?: string; - 'force-renderer-accessibility'?: boolean; - 'ignore-certificate-errors'?: boolean; - 'allow-insecure-localhost'?: boolean; - 'log-net-log'?: string; -} +import { NativeParsedArgs } from 'vs/platform/environment/common/argv'; /** * This code is also used by standalone cli's. Avoid adding any other dependencies. @@ -125,7 +37,7 @@ type OptionTypeName = T extends undefined ? 'undefined' : 'unknown'; -export const OPTIONS: OptionDescriptions> = { +export const OPTIONS: OptionDescriptions> = { 'diff': { type: 'boolean', cat: 'o', alias: 'd', args: ['file', 'file'], description: localize('diff', "Compare two files with each other.") }, 'add': { type: 'boolean', cat: 'o', alias: 'a', args: 'folder', description: localize('add', "Add folder(s) to the last active window.") }, 'goto': { type: 'boolean', cat: 'o', alias: 'g', args: 'file:line[:character]', description: localize('goto', "Open a file at the path on the specified line and character position.") }, diff --git a/src/vs/platform/environment/node/argvHelper.ts b/src/vs/platform/environment/node/argvHelper.ts index eda11907549..42afdee3f95 100644 --- a/src/vs/platform/environment/node/argvHelper.ts +++ b/src/vs/platform/environment/node/argvHelper.ts @@ -7,9 +7,10 @@ import * as assert from 'assert'; import { firstIndex } from 'vs/base/common/arrays'; import { localize } from 'vs/nls'; import { MIN_MAX_MEMORY_SIZE_MB } from 'vs/platform/files/common/files'; -import { parseArgs, ErrorReporter, OPTIONS, ParsedArgs } from 'vs/platform/environment/node/argv'; +import { parseArgs, ErrorReporter, OPTIONS } from 'vs/platform/environment/node/argv'; +import { NativeParsedArgs } from 'vs/platform/environment/common/argv'; -function parseAndValidate(cmdLineArgs: string[], reportWarnings: boolean): ParsedArgs { +function parseAndValidate(cmdLineArgs: string[], reportWarnings: boolean): NativeParsedArgs { const errorReporter: ErrorReporter = { onUnknownOption: (id) => { console.warn(localize('unknownOption', "Warning: '{0}' is not in the list of known options, but still passed to Electron/Chromium.", id)); @@ -43,7 +44,7 @@ function stripAppPath(argv: string[]): string[] | undefined { /** * Use this to parse raw code process.argv such as: `Electron . --verbose --wait` */ -export function parseMainProcessArgv(processArgv: string[]): ParsedArgs { +export function parseMainProcessArgv(processArgv: string[]): NativeParsedArgs { let [, ...args] = processArgv; // If dev, remove the first non-option argument: it's the app location @@ -59,7 +60,7 @@ export function parseMainProcessArgv(processArgv: string[]): ParsedArgs { /** * Use this to parse raw code CLI process.argv such as: `Electron cli.js . --verbose --wait` */ -export function parseCLIProcessArgv(processArgv: string[]): ParsedArgs { +export function parseCLIProcessArgv(processArgv: string[]): NativeParsedArgs { let [, , ...args] = processArgv; if (process.env['VSCODE_DEV']) { diff --git a/src/vs/platform/environment/node/environmentService.ts b/src/vs/platform/environment/node/environmentService.ts index 45d5ec2cc02..ef8dc5d2dd5 100644 --- a/src/vs/platform/environment/node/environmentService.ts +++ b/src/vs/platform/environment/node/environmentService.ts @@ -3,8 +3,8 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { IEnvironmentService, IDebugParams, IExtensionHostDebugParams, BACKUPS } from 'vs/platform/environment/common/environment'; -import { ParsedArgs } from 'vs/platform/environment/node/argv'; +import { IDebugParams, IExtensionHostDebugParams, BACKUPS, INativeEnvironmentService } from 'vs/platform/environment/common/environment'; +import { NativeParsedArgs } from 'vs/platform/environment/common/argv'; import * as crypto from 'crypto'; import * as paths from 'vs/base/node/paths'; import * as os from 'os'; @@ -13,54 +13,19 @@ import * as resources from 'vs/base/common/resources'; import { memoize } from 'vs/base/common/decorators'; import product from 'vs/platform/product/common/product'; import { toLocalISOString } from 'vs/base/common/date'; -import { isWindows, isLinux, Platform, platform } from 'vs/base/common/platform'; +import { isWindows, Platform, platform } from 'vs/base/common/platform'; import { getPathFromAmdModule } from 'vs/base/common/amd'; import { URI } from 'vs/base/common/uri'; -export interface INativeEnvironmentService extends IEnvironmentService { - args: ParsedArgs; - - appRoot: string; - execPath: string; - - appSettingsHome: URI; - userDataPath: string; - userHome: URI; - machineSettingsResource: URI; - backupWorkspacesPath: string; - nodeCachedDataDir?: string; - - mainIPCHandle: string; - sharedIPCHandle: string; - - installSourcePath: string; - - extensionsPath?: string; - extensionsDownloadPath: string; - builtinExtensionsPath: string; - - driverHandle?: string; - driverVerbose: boolean; - - disableUpdates: boolean; - - sandbox: boolean; -} - export class EnvironmentService implements INativeEnvironmentService { declare readonly _serviceBrand: undefined; - get args(): ParsedArgs { return this._args; } + get args(): NativeParsedArgs { return this._args; } @memoize get appRoot(): string { return path.dirname(getPathFromAmdModule(require, '')); } - get execPath(): string { return this._execPath; } - - @memoize - get cliPath(): string { return getCLIPath(this.execPath, this.appRoot, this.isBuilt); } - readonly logsPath: string; @memoize @@ -222,22 +187,8 @@ export class EnvironmentService implements INativeEnvironmentService { return false; } - get extensionEnabledProposedApi(): string[] | undefined { - if (Array.isArray(this.args['enable-proposed-api'])) { - return this.args['enable-proposed-api']; - } - - if ('enable-proposed-api' in this.args) { - return []; - } - - return undefined; - } - @memoize get debugExtensionHost(): IExtensionHostDebugParams { return parseExtensionHostPort(this._args, this.isBuilt); } - @memoize - get logExtensionHostCommunication(): boolean { return !!this.args.logExtensionHostCommunication; } get isBuilt(): boolean { return !process.env['VSCODE_DEV']; } get verbose(): boolean { return !!this._args.verbose; } @@ -266,7 +217,7 @@ export class EnvironmentService implements INativeEnvironmentService { get sandbox(): boolean { return !!this._args['__sandbox']; } - constructor(private _args: ParsedArgs, private _execPath: string) { + constructor(private _args: NativeParsedArgs) { if (!process.env['VSCODE_LOGS']) { const key = toLocalISOString(new Date()).replace(/-|:|\.\d+Z$/g, ''); process.env['VSCODE_LOGS'] = path.join(this.userDataPath, 'logs', key); @@ -321,39 +272,11 @@ function getIPCHandle(userDataPath: string, type: string): string { return getNixIPCHandle(userDataPath, type); } -function getCLIPath(execPath: string, appRoot: string, isBuilt: boolean): string { - - // Windows - if (isWindows) { - if (isBuilt) { - return path.join(path.dirname(execPath), 'bin', `${product.applicationName}.cmd`); - } - - return path.join(appRoot, 'scripts', 'code-cli.bat'); - } - - // Linux - if (isLinux) { - if (isBuilt) { - return path.join(path.dirname(execPath), 'bin', `${product.applicationName}`); - } - - return path.join(appRoot, 'scripts', 'code-cli.sh'); - } - - // macOS - if (isBuilt) { - return path.join(appRoot, 'bin', 'code'); - } - - return path.join(appRoot, 'scripts', 'code-cli.sh'); -} - -export function parseExtensionHostPort(args: ParsedArgs, isBuild: boolean): IExtensionHostDebugParams { +export function parseExtensionHostPort(args: NativeParsedArgs, isBuild: boolean): IExtensionHostDebugParams { return parseDebugPort(args['inspect-extensions'], args['inspect-brk-extensions'], 5870, isBuild, args.debugId); } -export function parseSearchPort(args: ParsedArgs, isBuild: boolean): IDebugParams { +export function parseSearchPort(args: NativeParsedArgs, isBuild: boolean): IDebugParams { return parseDebugPort(args['inspect-search'], args['inspect-brk-search'], 5876, isBuild); } @@ -381,6 +304,6 @@ export function parsePathArg(arg: string | undefined, process: NodeJS.Process): return path.resolve(process.env['VSCODE_CWD'] || process.cwd(), arg); } -export function parseUserDataDir(args: ParsedArgs, process: NodeJS.Process): string { +export function parseUserDataDir(args: NativeParsedArgs, process: NodeJS.Process): string { return parsePathArg(args['user-data-dir'], process) || path.resolve(paths.getDefaultUserDataPath(process.platform)); } diff --git a/src/vs/platform/extensionManagement/node/extensionDownloader.ts b/src/vs/platform/extensionManagement/node/extensionDownloader.ts index 62f1a290444..88f7afdd7ab 100644 --- a/src/vs/platform/extensionManagement/node/extensionDownloader.ts +++ b/src/vs/platform/extensionManagement/node/extensionDownloader.ts @@ -6,9 +6,8 @@ import { Disposable } from 'vs/base/common/lifecycle'; import { IFileService, IFileStatWithMetadata } from 'vs/platform/files/common/files'; import { IExtensionGalleryService, IGalleryExtension, InstallOperation } from 'vs/platform/extensionManagement/common/extensionManagement'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; +import { IEnvironmentService, INativeEnvironmentService } from 'vs/platform/environment/common/environment'; import { URI } from 'vs/base/common/uri'; -import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService'; import { joinPath } from 'vs/base/common/resources'; import { ExtensionIdentifierWithVersion, groupByExtension } from 'vs/platform/extensionManagement/common/extensionManagementUtil'; import { ILogService } from 'vs/platform/log/common/log'; diff --git a/src/vs/platform/extensionManagement/node/extensionLifecycle.ts b/src/vs/platform/extensionManagement/node/extensionLifecycle.ts index 4a9e5f8d4af..3f687bb590e 100644 --- a/src/vs/platform/extensionManagement/node/extensionLifecycle.ts +++ b/src/vs/platform/extensionManagement/node/extensionLifecycle.ts @@ -12,7 +12,6 @@ import { join } from 'vs/base/common/path'; import { Limiter } from 'vs/base/common/async'; import { Event } from 'vs/base/common/event'; import { Schemas } from 'vs/base/common/network'; -import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService'; import { rimraf } from 'vs/base/node/pfs'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; @@ -21,7 +20,7 @@ export class ExtensionsLifecycle extends Disposable { private processesLimiter: Limiter = new Limiter(5); // Run max 5 processes in parallel constructor( - @IEnvironmentService private environmentService: INativeEnvironmentService, + @IEnvironmentService private environmentService: IEnvironmentService, @ILogService private readonly logService: ILogService ) { super(); diff --git a/src/vs/platform/extensionManagement/node/extensionManagementService.ts b/src/vs/platform/extensionManagement/node/extensionManagementService.ts index 31e8d71a154..b26cf4129b2 100644 --- a/src/vs/platform/extensionManagement/node/extensionManagementService.ts +++ b/src/vs/platform/extensionManagement/node/extensionManagementService.ts @@ -23,8 +23,7 @@ import { ExtensionManagementError } from 'vs/platform/extensionManagement/common/extensionManagement'; import { areSameExtensions, getGalleryExtensionId, getMaliciousExtensionsSet, getGalleryExtensionTelemetryData, getLocalExtensionTelemetryData, ExtensionIdentifierWithVersion } from 'vs/platform/extensionManagement/common/extensionManagementUtil'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; -import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService'; +import { IEnvironmentService, INativeEnvironmentService } from 'vs/platform/environment/common/environment'; import { createCancelablePromise, CancelablePromise } from 'vs/base/common/async'; import { Event, Emitter } from 'vs/base/common/event'; import * as semver from 'semver-umd'; diff --git a/src/vs/platform/extensionManagement/node/extensionTipsService.ts b/src/vs/platform/extensionManagement/node/extensionTipsService.ts index 3dd401c785b..654ec69b7ea 100644 --- a/src/vs/platform/extensionManagement/node/extensionTipsService.ts +++ b/src/vs/platform/extensionManagement/node/extensionTipsService.ts @@ -6,9 +6,8 @@ import { URI } from 'vs/base/common/uri'; import { join, } from 'vs/base/common/path'; import { IProductService } from 'vs/platform/product/common/productService'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; +import { IEnvironmentService, INativeEnvironmentService } from 'vs/platform/environment/common/environment'; import { env as processEnv } from 'vs/base/common/process'; -import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService'; import { IFileService } from 'vs/platform/files/common/files'; import { isWindows } from 'vs/base/common/platform'; import { isNonEmptyArray } from 'vs/base/common/arrays'; diff --git a/src/vs/platform/extensionManagement/node/extensionsManifestCache.ts b/src/vs/platform/extensionManagement/node/extensionsManifestCache.ts index 328cfe122fc..72c23e36789 100644 --- a/src/vs/platform/extensionManagement/node/extensionsManifestCache.ts +++ b/src/vs/platform/extensionManagement/node/extensionsManifestCache.ts @@ -5,7 +5,7 @@ import { Disposable } from 'vs/base/common/lifecycle'; import { join } from 'vs/base/common/path'; -import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService'; +import { INativeEnvironmentService } from 'vs/platform/environment/common/environment'; import { IExtensionManagementService, DidInstallExtensionEvent, DidUninstallExtensionEvent } from 'vs/platform/extensionManagement/common/extensionManagement'; import { MANIFEST_CACHE_FOLDER, USER_MANIFEST_CACHE_FILE } from 'vs/platform/extensions/common/extensions'; import * as pfs from 'vs/base/node/pfs'; diff --git a/src/vs/platform/extensionManagement/node/extensionsScanner.ts b/src/vs/platform/extensionManagement/node/extensionsScanner.ts index 575b2aafc38..ef3ba9f7ace 100644 --- a/src/vs/platform/extensionManagement/node/extensionsScanner.ts +++ b/src/vs/platform/extensionManagement/node/extensionsScanner.ts @@ -13,8 +13,7 @@ import { ExtensionType, IExtensionManifest, IExtensionIdentifier } from 'vs/plat import { areSameExtensions, ExtensionIdentifierWithVersion, groupByExtension, getGalleryExtensionId } from 'vs/platform/extensionManagement/common/extensionManagementUtil'; import { Limiter, Queue } from 'vs/base/common/async'; import { URI } from 'vs/base/common/uri'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; -import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService'; +import { IEnvironmentService, INativeEnvironmentService } from 'vs/platform/environment/common/environment'; import { getPathFromAmdModule } from 'vs/base/common/amd'; import { localizeManifest } from 'vs/platform/extensionManagement/common/extensionNls'; import { localize } from 'vs/nls'; diff --git a/src/vs/platform/extensionManagement/test/node/extensionGalleryService.test.ts b/src/vs/platform/extensionManagement/test/node/extensionGalleryService.test.ts index 377a92abbe9..964913233d0 100644 --- a/src/vs/platform/extensionManagement/test/node/extensionGalleryService.test.ts +++ b/src/vs/platform/extensionManagement/test/node/extensionGalleryService.test.ts @@ -53,7 +53,7 @@ suite('Extension Gallery Service', () => { test('marketplace machine id', () => { const args = ['--user-data-dir', marketplaceHome]; - const environmentService = new EnvironmentService(parseArgs(args, OPTIONS), process.execPath); + const environmentService = new EnvironmentService(parseArgs(args, OPTIONS)); const storageService: IStorageService = new TestStorageService(); return resolveMarketplaceHeaders(product.version, environmentService, fileService, storageService).then(headers => { diff --git a/src/vs/platform/issue/electron-main/issueMainService.ts b/src/vs/platform/issue/electron-main/issueMainService.ts index 48fae538c08..31e3888364e 100644 --- a/src/vs/platform/issue/electron-main/issueMainService.ts +++ b/src/vs/platform/issue/electron-main/issueMainService.ts @@ -13,8 +13,7 @@ import { BrowserWindow, ipcMain, screen, IpcMainEvent, Display, shell } from 'el import { ILaunchMainService } from 'vs/platform/launch/electron-main/launchMainService'; import { PerformanceInfo, isRemoteDiagnosticError } from 'vs/platform/diagnostics/common/diagnostics'; import { IDiagnosticsService } from 'vs/platform/diagnostics/node/diagnosticsService'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; -import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService'; +import { IEnvironmentService, INativeEnvironmentService } from 'vs/platform/environment/common/environment'; import { isMacintosh, IProcessEnvironment } from 'vs/base/common/platform'; import { ILogService } from 'vs/platform/log/common/log'; import { IWindowState } from 'vs/platform/windows/electron-main/windows'; diff --git a/src/vs/platform/launch/electron-main/launchMainService.ts b/src/vs/platform/launch/electron-main/launchMainService.ts index f1b54f87e9d..7ebd8132de1 100644 --- a/src/vs/platform/launch/electron-main/launchMainService.ts +++ b/src/vs/platform/launch/electron-main/launchMainService.ts @@ -6,7 +6,7 @@ import { ILogService } from 'vs/platform/log/common/log'; import { IURLService } from 'vs/platform/url/common/url'; import { IProcessEnvironment, isMacintosh } from 'vs/base/common/platform'; -import { ParsedArgs } from 'vs/platform/environment/node/argv'; +import { NativeParsedArgs } from 'vs/platform/environment/common/argv'; import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; import { IWindowSettings } from 'vs/platform/windows/common/windows'; import { OpenContext } from 'vs/platform/windows/node/window'; @@ -24,7 +24,7 @@ export const ID = 'launchMainService'; export const ILaunchMainService = createDecorator(ID); export interface IStartArguments { - args: ParsedArgs; + args: NativeParsedArgs; userEnv: IProcessEnvironment; } @@ -33,7 +33,7 @@ export interface IRemoteDiagnosticOptions { includeWorkspaceMetadata?: boolean; } -function parseOpenUrl(args: ParsedArgs): URI[] { +function parseOpenUrl(args: NativeParsedArgs): URI[] { if (args['open-url'] && args._urls && args._urls.length > 0) { // --open-url must contain -- followed by the url(s) // process.argv is used over args._ as args._ are resolved to file paths at this point @@ -52,7 +52,7 @@ function parseOpenUrl(args: ParsedArgs): URI[] { export interface ILaunchMainService { readonly _serviceBrand: undefined; - start(args: ParsedArgs, userEnv: IProcessEnvironment): Promise; + start(args: NativeParsedArgs, userEnv: IProcessEnvironment): Promise; getMainProcessId(): Promise; getMainProcessInfo(): Promise; getRemoteDiagnostics(options: IRemoteDiagnosticOptions): Promise<(IRemoteDiagnosticInfo | IRemoteDiagnosticError)[]>; @@ -70,7 +70,7 @@ export class LaunchMainService implements ILaunchMainService { @IConfigurationService private readonly configurationService: IConfigurationService ) { } - async start(args: ParsedArgs, userEnv: IProcessEnvironment): Promise { + async start(args: NativeParsedArgs, userEnv: IProcessEnvironment): Promise { this.logService.trace('Received data from other instance: ', args, userEnv); // Since we now start to open a window, make sure the app has focus. @@ -103,7 +103,7 @@ export class LaunchMainService implements ILaunchMainService { } } - private startOpenWindow(args: ParsedArgs, userEnv: IProcessEnvironment): Promise { + private startOpenWindow(args: NativeParsedArgs, userEnv: IProcessEnvironment): Promise { const context = !!userEnv['VSCODE_CLI'] ? OpenContext.CLI : OpenContext.DESKTOP; let usedWindows: ICodeWindow[] = []; diff --git a/src/vs/platform/lifecycle/electron-main/lifecycleMainService.ts b/src/vs/platform/lifecycle/electron-main/lifecycleMainService.ts index 1b8e3852c50..f1008af8846 100644 --- a/src/vs/platform/lifecycle/electron-main/lifecycleMainService.ts +++ b/src/vs/platform/lifecycle/electron-main/lifecycleMainService.ts @@ -13,7 +13,7 @@ import { handleVetos } from 'vs/platform/lifecycle/common/lifecycle'; import { isMacintosh, isWindows } from 'vs/base/common/platform'; import { Disposable } from 'vs/base/common/lifecycle'; import { Barrier, timeout } from 'vs/base/common/async'; -import { ParsedArgs } from 'vs/platform/environment/node/argv'; +import { NativeParsedArgs } from 'vs/platform/environment/common/argv'; export const ILifecycleMainService = createDecorator('lifecycleMainService'); @@ -86,7 +86,7 @@ export interface ILifecycleMainService { /** * Reload a window. All lifecycle event handlers are triggered. */ - reload(window: ICodeWindow, cli?: ParsedArgs): Promise; + reload(window: ICodeWindow, cli?: NativeParsedArgs): Promise; /** * Unload a window for the provided reason. All lifecycle event handlers are triggered. @@ -366,7 +366,7 @@ export class LifecycleMainService extends Disposable implements ILifecycleMainSe }); } - async reload(window: ICodeWindow, cli?: ParsedArgs): Promise { + async reload(window: ICodeWindow, cli?: NativeParsedArgs): Promise { // Only reload when the window has not vetoed this const veto = await this.unload(window, UnloadReason.RELOAD); diff --git a/src/vs/platform/localizations/node/localizations.ts b/src/vs/platform/localizations/node/localizations.ts index ea3d80192f1..d42b7909d65 100644 --- a/src/vs/platform/localizations/node/localizations.ts +++ b/src/vs/platform/localizations/node/localizations.ts @@ -7,8 +7,7 @@ import * as pfs from 'vs/base/node/pfs'; import { createHash } from 'crypto'; import { IExtensionManagementService, ILocalExtension, IExtensionIdentifier } from 'vs/platform/extensionManagement/common/extensionManagement'; import { Disposable } from 'vs/base/common/lifecycle'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; -import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService'; +import { IEnvironmentService, INativeEnvironmentService } from 'vs/platform/environment/common/environment'; import { Queue } from 'vs/base/common/async'; import { areSameExtensions } from 'vs/platform/extensionManagement/common/extensionManagementUtil'; import { ILogService } from 'vs/platform/log/common/log'; diff --git a/src/vs/platform/menubar/electron-main/menubar.ts b/src/vs/platform/menubar/electron-main/menubar.ts index bf78261135d..f285182942b 100644 --- a/src/vs/platform/menubar/electron-main/menubar.ts +++ b/src/vs/platform/menubar/electron-main/menubar.ts @@ -5,7 +5,7 @@ import * as nls from 'vs/nls'; import { isMacintosh, language } from 'vs/base/common/platform'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; +import { IEnvironmentService, INativeEnvironmentService } from 'vs/platform/environment/common/environment'; import { app, shell, Menu, MenuItem, BrowserWindow, MenuItemConstructorOptions, WebContents, Event, KeyboardEvent } from 'electron'; import { getTitleBarStyle, INativeRunActionInWindowRequest, INativeRunKeybindingInWindowRequest, IWindowOpenable } from 'vs/platform/windows/common/windows'; import { OpenContext } from 'vs/platform/windows/node/window'; @@ -24,7 +24,6 @@ import { IStateService } from 'vs/platform/state/node/state'; import { ILifecycleMainService } from 'vs/platform/lifecycle/electron-main/lifecycleMainService'; import { WorkbenchActionExecutedEvent, WorkbenchActionExecutedClassification } from 'vs/base/common/actions'; import { IElectronMainService } from 'vs/platform/electron/electron-main/electronMainService'; -import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService'; const telemetryFrom = 'menu'; diff --git a/src/vs/platform/state/node/stateService.ts b/src/vs/platform/state/node/stateService.ts index a30d0c6d8e6..a11d2fc6981 100644 --- a/src/vs/platform/state/node/stateService.ts +++ b/src/vs/platform/state/node/stateService.ts @@ -5,8 +5,7 @@ import * as path from 'vs/base/common/path'; import * as fs from 'fs'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; -import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService'; +import { IEnvironmentService, INativeEnvironmentService } from 'vs/platform/environment/common/environment'; import { writeFileSync, readFile } from 'vs/base/node/pfs'; import { isUndefined, isUndefinedOrNull } from 'vs/base/common/types'; import { IStateService } from 'vs/platform/state/node/state'; diff --git a/src/vs/platform/storage/node/storageMainService.ts b/src/vs/platform/storage/node/storageMainService.ts index 9ba93bb462a..0d25d4e6554 100644 --- a/src/vs/platform/storage/node/storageMainService.ts +++ b/src/vs/platform/storage/node/storageMainService.ts @@ -8,7 +8,6 @@ import { Event, Emitter } from 'vs/base/common/event'; import { Disposable } from 'vs/base/common/lifecycle'; import { ILogService, LogLevel } from 'vs/platform/log/common/log'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; -import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService'; import { SQLiteStorageDatabase, ISQLiteStorageDatabaseLoggingOptions } from 'vs/base/parts/storage/node/storage'; import { Storage, IStorage, InMemoryStorageDatabase } from 'vs/base/parts/storage/common/storage'; import { join } from 'vs/base/common/path'; @@ -105,7 +104,7 @@ export class StorageMainService extends Disposable implements IStorageMainServic constructor( @ILogService private readonly logService: ILogService, - @IEnvironmentService private readonly environmentService: INativeEnvironmentService + @IEnvironmentService private readonly environmentService: IEnvironmentService ) { super(); diff --git a/src/vs/platform/storage/node/storageService.ts b/src/vs/platform/storage/node/storageService.ts index ac657056aa6..096b9e23493 100644 --- a/src/vs/platform/storage/node/storageService.ts +++ b/src/vs/platform/storage/node/storageService.ts @@ -13,7 +13,6 @@ import { mark } from 'vs/base/common/performance'; import { join } from 'vs/base/common/path'; import { copy, exists, mkdirp, writeFile } from 'vs/base/node/pfs'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; -import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService'; import { IWorkspaceInitializationPayload, isWorkspaceIdentifier, isSingleFolderWorkspaceInitializationPayload } from 'vs/platform/workspaces/common/workspaces'; import { assertIsDefined } from 'vs/base/common/types'; import { RunOnceScheduler, runWhenIdle } from 'vs/base/common/async'; @@ -45,7 +44,7 @@ export class NativeStorageService extends Disposable implements IStorageService constructor( private globalStorageDatabase: IStorageDatabase, @ILogService private readonly logService: ILogService, - @IEnvironmentService private readonly environmentService: INativeEnvironmentService + @IEnvironmentService private readonly environmentService: IEnvironmentService ) { super(); diff --git a/src/vs/platform/storage/test/node/storageService.test.ts b/src/vs/platform/storage/test/node/storageService.test.ts index 454f34f01ef..db37af25774 100644 --- a/src/vs/platform/storage/test/node/storageService.test.ts +++ b/src/vs/platform/storage/test/node/storageService.test.ts @@ -87,7 +87,7 @@ suite('StorageService', () => { class StorageTestEnvironmentService extends EnvironmentService { constructor(private workspaceStorageFolderPath: URI, private _extensionsPath: string) { - super(parseArgs(process.argv, OPTIONS), process.execPath); + super(parseArgs(process.argv, OPTIONS)); } get workspaceStorageHome(): URI { diff --git a/src/vs/platform/update/electron-main/abstractUpdateService.ts b/src/vs/platform/update/electron-main/abstractUpdateService.ts index dd67aaf2070..8677fb052a7 100644 --- a/src/vs/platform/update/electron-main/abstractUpdateService.ts +++ b/src/vs/platform/update/electron-main/abstractUpdateService.ts @@ -9,8 +9,7 @@ import { IConfigurationService, getMigratedSettingValue } from 'vs/platform/conf import { ILifecycleMainService } from 'vs/platform/lifecycle/electron-main/lifecycleMainService'; import product from 'vs/platform/product/common/product'; import { IUpdateService, State, StateType, AvailableForDownload, UpdateType } from 'vs/platform/update/common/update'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; -import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService'; +import { IEnvironmentService, INativeEnvironmentService } from 'vs/platform/environment/common/environment'; import { ILogService } from 'vs/platform/log/common/log'; import { IRequestService } from 'vs/platform/request/common/request'; import { CancellationToken } from 'vs/base/common/cancellation'; diff --git a/src/vs/platform/update/electron-main/updateService.darwin.ts b/src/vs/platform/update/electron-main/updateService.darwin.ts index ff83e9c23a1..e0e02c3f344 100644 --- a/src/vs/platform/update/electron-main/updateService.darwin.ts +++ b/src/vs/platform/update/electron-main/updateService.darwin.ts @@ -11,8 +11,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur import { ILifecycleMainService } from 'vs/platform/lifecycle/electron-main/lifecycleMainService'; import { State, IUpdate, StateType, UpdateType } from 'vs/platform/update/common/update'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; -import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService'; +import { IEnvironmentService, INativeEnvironmentService } from 'vs/platform/environment/common/environment'; import { ILogService } from 'vs/platform/log/common/log'; import { AbstractUpdateService, createUpdateURL, UpdateNotAvailableClassification } from 'vs/platform/update/electron-main/abstractUpdateService'; import { IRequestService } from 'vs/platform/request/common/request'; diff --git a/src/vs/platform/update/electron-main/updateService.linux.ts b/src/vs/platform/update/electron-main/updateService.linux.ts index 243b64b686c..c03e1fbecc9 100644 --- a/src/vs/platform/update/electron-main/updateService.linux.ts +++ b/src/vs/platform/update/electron-main/updateService.linux.ts @@ -8,8 +8,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur import { ILifecycleMainService } from 'vs/platform/lifecycle/electron-main/lifecycleMainService'; import { State, IUpdate, AvailableForDownload, UpdateType } from 'vs/platform/update/common/update'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; -import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService'; +import { IEnvironmentService, INativeEnvironmentService } from 'vs/platform/environment/common/environment'; import { ILogService } from 'vs/platform/log/common/log'; import { createUpdateURL, AbstractUpdateService, UpdateNotAvailableClassification } from 'vs/platform/update/electron-main/abstractUpdateService'; import { IRequestService, asJson } from 'vs/platform/request/common/request'; diff --git a/src/vs/platform/update/electron-main/updateService.snap.ts b/src/vs/platform/update/electron-main/updateService.snap.ts index 9e36e24aefa..38a3c80baae 100644 --- a/src/vs/platform/update/electron-main/updateService.snap.ts +++ b/src/vs/platform/update/electron-main/updateService.snap.ts @@ -7,8 +7,7 @@ import { Event, Emitter } from 'vs/base/common/event'; import { timeout } from 'vs/base/common/async'; import { ILifecycleMainService } from 'vs/platform/lifecycle/electron-main/lifecycleMainService'; import { IUpdateService, State, StateType, AvailableForDownload, UpdateType } from 'vs/platform/update/common/update'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; -import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService'; +import { IEnvironmentService, INativeEnvironmentService } from 'vs/platform/environment/common/environment'; import { ILogService } from 'vs/platform/log/common/log'; import * as path from 'vs/base/common/path'; import { realpath, watch } from 'fs'; diff --git a/src/vs/platform/update/electron-main/updateService.win32.ts b/src/vs/platform/update/electron-main/updateService.win32.ts index 5ff2be09f91..3505dc06e68 100644 --- a/src/vs/platform/update/electron-main/updateService.win32.ts +++ b/src/vs/platform/update/electron-main/updateService.win32.ts @@ -12,8 +12,7 @@ import { ILifecycleMainService } from 'vs/platform/lifecycle/electron-main/lifec import product from 'vs/platform/product/common/product'; import { State, IUpdate, StateType, AvailableForDownload, UpdateType } from 'vs/platform/update/common/update'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; -import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService'; +import { IEnvironmentService, INativeEnvironmentService } from 'vs/platform/environment/common/environment'; import { ILogService } from 'vs/platform/log/common/log'; import { createUpdateURL, AbstractUpdateService, UpdateNotAvailableClassification } from 'vs/platform/update/electron-main/abstractUpdateService'; import { IRequestService, asJson } from 'vs/platform/request/common/request'; diff --git a/src/vs/platform/url/electron-main/electronUrlListener.ts b/src/vs/platform/url/electron-main/electronUrlListener.ts index ed42aa66ca9..22db37fc51e 100644 --- a/src/vs/platform/url/electron-main/electronUrlListener.ts +++ b/src/vs/platform/url/electron-main/electronUrlListener.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { Event } from 'vs/base/common/event'; -import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService'; +import { INativeEnvironmentService } from 'vs/platform/environment/common/environment'; import { IURLService } from 'vs/platform/url/common/url'; import product from 'vs/platform/product/common/product'; import { app, Event as ElectronEvent } from 'electron'; diff --git a/src/vs/platform/windows/common/windows.ts b/src/vs/platform/windows/common/windows.ts index 5accb83f2ba..53c6c70334a 100644 --- a/src/vs/platform/windows/common/windows.ts +++ b/src/vs/platform/windows/common/windows.ts @@ -3,11 +3,14 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { isMacintosh, isLinux, isWeb } from 'vs/base/common/platform'; +import { isMacintosh, isLinux, isWeb, IProcessEnvironment } from 'vs/base/common/platform'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { URI, UriComponents } from 'vs/base/common/uri'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces'; +import { NativeParsedArgs } from 'vs/platform/environment/common/argv'; +import { LogLevel } from 'vs/platform/log/common/log'; +import { ExportData } from 'vs/base/common/performance'; export interface IBaseOpenWindowsOptions { forceReuseWindow?: boolean; @@ -215,6 +218,34 @@ export interface IWindowConfiguration { filesToDiff?: IPath[]; } +export interface INativeWindowConfiguration extends IWindowConfiguration, NativeParsedArgs { + mainPid: number; + + windowId: number; + machineId: string; + + appRoot: string; + execPath: string; + backupPath?: string; + + nodeCachedDataDir?: string; + partsSplashPath: string; + + workspace?: IWorkspaceIdentifier; + folderUri?: ISingleFolderWorkspaceIdentifier; + + isInitialStartup?: boolean; + logLevel: LogLevel; + zoomLevel?: number; + fullscreen?: boolean; + maximized?: boolean; + accessibilitySupport?: boolean; + perfEntries: ExportData; + + userEnv: IProcessEnvironment; + filesToWait?: IPathsToWaitFor; +} + /** * According to Electron docs: `scale := 1.2 ^ level`. * https://github.com/electron/electron/blob/master/docs/api/web-contents.md#contentssetzoomlevellevel diff --git a/src/vs/platform/windows/electron-main/windows.ts b/src/vs/platform/windows/electron-main/windows.ts index e73561154ab..7c4340170ca 100644 --- a/src/vs/platform/windows/electron-main/windows.ts +++ b/src/vs/platform/windows/electron-main/windows.ts @@ -3,9 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { IWindowOpenable, IOpenEmptyWindowOptions } from 'vs/platform/windows/common/windows'; -import { INativeWindowConfiguration, OpenContext } from 'vs/platform/windows/node/window'; -import { ParsedArgs } from 'vs/platform/environment/node/argv'; +import { IWindowOpenable, IOpenEmptyWindowOptions, INativeWindowConfiguration } from 'vs/platform/windows/common/windows'; +import { OpenContext } from 'vs/platform/windows/node/window'; +import { NativeParsedArgs } from 'vs/platform/environment/common/argv'; import { Event } from 'vs/base/common/event'; import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; import { IProcessEnvironment } from 'vs/base/common/platform'; @@ -59,7 +59,7 @@ export interface ICodeWindow extends IDisposable { addTabbedWindow(window: ICodeWindow): void; load(config: INativeWindowConfiguration, isReload?: boolean): void; - reload(configuration?: INativeWindowConfiguration, cli?: ParsedArgs): void; + reload(configuration?: INativeWindowConfiguration, cli?: NativeParsedArgs): void; focus(options?: { force: boolean }): void; close(): void; @@ -121,7 +121,7 @@ export interface IBaseOpenConfiguration { } export interface IOpenConfiguration extends IBaseOpenConfiguration { - readonly cli: ParsedArgs; + readonly cli: NativeParsedArgs; readonly userEnv?: IProcessEnvironment; readonly urisToOpen?: IWindowOpenable[]; readonly waitMarkerFileURI?: URI; diff --git a/src/vs/platform/windows/electron-main/windowsMainService.ts b/src/vs/platform/windows/electron-main/windowsMainService.ts index 9181bf457f4..a4a28cd8cd6 100644 --- a/src/vs/platform/windows/electron-main/windowsMainService.ts +++ b/src/vs/platform/windows/electron-main/windowsMainService.ts @@ -10,17 +10,16 @@ import * as arrays from 'vs/base/common/arrays'; import { mixin } from 'vs/base/common/objects'; import { IBackupMainService } from 'vs/platform/backup/electron-main/backup'; import { IEmptyWindowBackupInfo } from 'vs/platform/backup/node/backup'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; -import { ParsedArgs } from 'vs/platform/environment/node/argv'; -import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService'; +import { IEnvironmentService, INativeEnvironmentService } from 'vs/platform/environment/common/environment'; +import { NativeParsedArgs } from 'vs/platform/environment/common/argv'; import { IStateService } from 'vs/platform/state/node/state'; import { CodeWindow, defaultWindowState } from 'vs/code/electron-main/window'; import { screen, BrowserWindow, MessageBoxOptions, Display, app, nativeTheme } from 'electron'; import { ILifecycleMainService, UnloadReason, LifecycleMainService, LifecycleMainPhase } from 'vs/platform/lifecycle/electron-main/lifecycleMainService'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { ILogService } from 'vs/platform/log/common/log'; -import { IWindowSettings, IPath, isFileToOpen, isWorkspaceToOpen, isFolderToOpen, IWindowOpenable, IOpenEmptyWindowOptions, IAddFoldersRequest, IPathsToWaitFor } from 'vs/platform/windows/common/windows'; -import { getLastActiveWindow, findBestWindowOrFolderForFile, findWindowOnWorkspace, findWindowOnExtensionDevelopmentPath, findWindowOnWorkspaceOrFolderUri, INativeWindowConfiguration, OpenContext } from 'vs/platform/windows/node/window'; +import { IWindowSettings, IPath, isFileToOpen, isWorkspaceToOpen, isFolderToOpen, IWindowOpenable, IOpenEmptyWindowOptions, IAddFoldersRequest, IPathsToWaitFor, INativeWindowConfiguration } from 'vs/platform/windows/common/windows'; +import { getLastActiveWindow, findBestWindowOrFolderForFile, findWindowOnWorkspace, findWindowOnExtensionDevelopmentPath, findWindowOnWorkspaceOrFolderUri, OpenContext } from 'vs/platform/windows/node/window'; import { Emitter } from 'vs/base/common/event'; import product from 'vs/platform/product/common/product'; import { IWindowsMainService, IOpenConfiguration, IWindowsCountChangedEvent, ICodeWindow, IWindowState as ISingleWindowState, WindowMode, IOpenEmptyConfiguration } from 'vs/platform/windows/electron-main/windows'; @@ -64,7 +63,7 @@ type RestoreWindowsSetting = 'all' | 'folders' | 'one' | 'none'; interface IOpenBrowserWindowOptions { userEnv?: IProcessEnvironment; - cli?: ParsedArgs; + cli?: NativeParsedArgs; workspace?: IWorkspaceIdentifier; folderUri?: URI; @@ -899,7 +898,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic return pathsToOpen; } - private doExtractPathsFromCLI(cli: ParsedArgs): IPath[] { + private doExtractPathsFromCLI(cli: NativeParsedArgs): IPath[] { const pathsToOpen: IPathToOpen[] = []; const parseOptions: IPathParseOptions = { ignoreFileNotFound: true, gotoLineMode: cli.goto, remoteAuthority: cli.remote || undefined }; diff --git a/src/vs/platform/windows/node/window.ts b/src/vs/platform/windows/node/window.ts index 9adc39431df..6859b36ab9f 100644 --- a/src/vs/platform/windows/node/window.ts +++ b/src/vs/platform/windows/node/window.ts @@ -3,15 +3,11 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { IWindowConfiguration, IPathsToWaitFor } from 'vs/platform/windows/common/windows'; import { URI } from 'vs/base/common/uri'; import * as platform from 'vs/base/common/platform'; import * as extpath from 'vs/base/common/extpath'; import { IWorkspaceIdentifier, IResolvedWorkspace, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, isWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces'; import { extUriBiasedIgnorePathCase } from 'vs/base/common/resources'; -import { LogLevel } from 'vs/platform/log/common/log'; -import { ExportData } from 'vs/base/common/performance'; -import { ParsedArgs } from 'vs/platform/environment/node/argv'; export const enum OpenContext { @@ -34,34 +30,6 @@ export const enum OpenContext { API } -export interface INativeWindowConfiguration extends IWindowConfiguration, ParsedArgs { - mainPid: number; - - windowId: number; - machineId: string; - - appRoot: string; - execPath: string; - backupPath?: string; - - nodeCachedDataDir?: string; - partsSplashPath: string; - - workspace?: IWorkspaceIdentifier; - folderUri?: ISingleFolderWorkspaceIdentifier; - - isInitialStartup?: boolean; - logLevel: LogLevel; - zoomLevel?: number; - fullscreen?: boolean; - maximized?: boolean; - accessibilitySupport?: boolean; - perfEntries: ExportData; - - userEnv: platform.IProcessEnvironment; - filesToWait?: IPathsToWaitFor; -} - export interface IWindowContext { openedWorkspace?: IWorkspaceIdentifier; openedFolderUri?: URI; @@ -75,7 +43,6 @@ export interface IBestWindowOrFolderOptions { newWindow: boolean; context: OpenContext; fileUri?: URI; - userHome?: string; codeSettingsFolder?: string; localWorkspaceResolver: (workspace: IWorkspaceIdentifier) => IResolvedWorkspace | null; } diff --git a/src/vs/platform/workspaces/electron-main/workspacesHistoryMainService.ts b/src/vs/platform/workspaces/electron-main/workspacesHistoryMainService.ts index d0c4ea932b3..c618ba30af6 100644 --- a/src/vs/platform/workspaces/electron-main/workspacesHistoryMainService.ts +++ b/src/vs/platform/workspaces/electron-main/workspacesHistoryMainService.ts @@ -17,8 +17,7 @@ import { ThrottledDelayer } from 'vs/base/common/async'; import { isEqual, dirname, originalFSPath, basename, extUriBiasedIgnorePathCase } from 'vs/base/common/resources'; import { URI } from 'vs/base/common/uri'; import { Schemas } from 'vs/base/common/network'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; -import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService'; +import { IEnvironmentService, INativeEnvironmentService } from 'vs/platform/environment/common/environment'; import { exists } from 'vs/base/node/pfs'; import { ILifecycleMainService, LifecycleMainPhase } from 'vs/platform/lifecycle/electron-main/lifecycleMainService'; import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; diff --git a/src/vs/platform/workspaces/electron-main/workspacesMainService.ts b/src/vs/platform/workspaces/electron-main/workspacesMainService.ts index 18151ec9c96..72411c7dc69 100644 --- a/src/vs/platform/workspaces/electron-main/workspacesMainService.ts +++ b/src/vs/platform/workspaces/electron-main/workspacesMainService.ts @@ -4,8 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { IWorkspaceIdentifier, hasWorkspaceFileExtension, UNTITLED_WORKSPACE_NAME, IResolvedWorkspace, IStoredWorkspaceFolder, isStoredWorkspaceFolder, IWorkspaceFolderCreationData, IUntitledWorkspaceInfo, getStoredWorkspaceFolder, IEnterWorkspaceResult, isUntitledWorkspace } from 'vs/platform/workspaces/common/workspaces'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; -import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService'; +import { IEnvironmentService, INativeEnvironmentService } from 'vs/platform/environment/common/environment'; import { join, dirname } from 'vs/base/common/path'; import { mkdirp, writeFile, rimrafSync, readdirSync, writeFileSync } from 'vs/base/node/pfs'; import { readFileSync, existsSync, mkdirSync } from 'fs'; diff --git a/src/vs/platform/workspaces/test/electron-main/workspacesMainService.test.ts b/src/vs/platform/workspaces/test/electron-main/workspacesMainService.test.ts index ba4ea5b5268..1bea8eaa1ce 100644 --- a/src/vs/platform/workspaces/test/electron-main/workspacesMainService.test.ts +++ b/src/vs/platform/workspaces/test/electron-main/workspacesMainService.test.ts @@ -138,7 +138,7 @@ suite('WorkspacesMainService', () => { return service.createUntitledWorkspaceSync(folders.map((folder, index) => ({ uri: URI.file(folder), name: names ? names[index] : undefined } as IWorkspaceFolderCreationData))); } - const environmentService = new TestEnvironmentService(parseArgs(process.argv, OPTIONS), process.execPath); + const environmentService = new TestEnvironmentService(parseArgs(process.argv, OPTIONS)); const logService = new NullLogService(); let service: WorkspacesMainService; diff --git a/src/vs/workbench/contrib/configExporter/electron-browser/configurationExportHelper.contribution.ts b/src/vs/workbench/contrib/configExporter/electron-browser/configurationExportHelper.contribution.ts index 5a989bee849..3a823e02962 100644 --- a/src/vs/workbench/contrib/configExporter/electron-browser/configurationExportHelper.contribution.ts +++ b/src/vs/workbench/contrib/configExporter/electron-browser/configurationExportHelper.contribution.ts @@ -8,8 +8,8 @@ import { Registry } from 'vs/platform/registry/common/platform'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; +import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService'; import { DefaultConfigurationExportHelper } from 'vs/workbench/contrib/configExporter/electron-browser/configurationExportHelper'; -import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService'; export class ExtensionPoints implements IWorkbenchContribution { diff --git a/src/vs/workbench/contrib/configExporter/electron-browser/configurationExportHelper.ts b/src/vs/workbench/contrib/configExporter/electron-browser/configurationExportHelper.ts index 1fcc461ca7d..00f9df83c50 100644 --- a/src/vs/workbench/contrib/configExporter/electron-browser/configurationExportHelper.ts +++ b/src/vs/workbench/contrib/configExporter/electron-browser/configurationExportHelper.ts @@ -5,8 +5,8 @@ import { writeFile } from 'vs/base/node/pfs'; import product from 'vs/platform/product/common/product'; -import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; +import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService'; import { Registry } from 'vs/platform/registry/common/platform'; import { IConfigurationNode, IConfigurationRegistry, Extensions, IConfigurationPropertySchema } from 'vs/platform/configuration/common/configurationRegistry'; import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions'; diff --git a/src/vs/workbench/contrib/debug/browser/extensionHostDebugService.ts b/src/vs/workbench/contrib/debug/browser/extensionHostDebugService.ts index ee999b258b5..0e829c48a3f 100644 --- a/src/vs/workbench/contrib/debug/browser/extensionHostDebugService.ts +++ b/src/vs/workbench/contrib/debug/browser/extensionHostDebugService.ts @@ -109,7 +109,7 @@ class BrowserExtensionHostDebugService extends ExtensionHostDebugChannelClient i environment.set('inspect-extensions', inspectExtensions); } - // Open debug window as new window. Pass ParsedArgs over. + // Open debug window as new window. Pass arguments over. await this.workspaceProvider.open(debugWorkspace, { reuse: false, // debugging always requires a new window payload: Array.from(environment.entries()) // mandatory properties to enable debugging diff --git a/src/vs/workbench/contrib/extensions/browser/extensionsViewlet.ts b/src/vs/workbench/contrib/extensions/browser/extensionsViewlet.ts index 33ab9f5a25e..a5221aff5e8 100644 --- a/src/vs/workbench/contrib/extensions/browser/extensionsViewlet.ts +++ b/src/vs/workbench/contrib/extensions/browser/extensionsViewlet.ts @@ -49,7 +49,6 @@ import { Query } from 'vs/workbench/contrib/extensions/common/extensionQuery'; import { SuggestEnabledInput, attachSuggestEnabledInputBoxStyler } from 'vs/workbench/contrib/codeEditor/browser/suggestEnabledInput/suggestEnabledInput'; import { alert } from 'vs/base/browser/ui/aria/aria'; import { createErrorWithActions } from 'vs/base/common/errorsWithActions'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { ExtensionType, EXTENSION_CATEGORIES } from 'vs/platform/extensions/common/extensions'; import { Registry } from 'vs/platform/registry/common/platform'; import { ILabelService } from 'vs/platform/label/common/label'; @@ -750,7 +749,7 @@ export class MaliciousExtensionChecker implements IWorkbenchContribution { @IHostService private readonly hostService: IHostService, @ILogService private readonly logService: ILogService, @INotificationService private readonly notificationService: INotificationService, - @IEnvironmentService private readonly environmentService: IEnvironmentService + @IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService ) { if (!this.environmentService.disableExtensions) { this.loopCheckForMaliciousExtensions(); diff --git a/src/vs/workbench/contrib/extensions/electron-browser/extensions.contribution.ts b/src/vs/workbench/contrib/extensions/electron-browser/extensions.contribution.ts index 4a098ffd88f..24315638575 100644 --- a/src/vs/workbench/contrib/extensions/electron-browser/extensions.contribution.ts +++ b/src/vs/workbench/contrib/extensions/electron-browser/extensions.contribution.ts @@ -21,8 +21,8 @@ import { RuntimeExtensionsInput } from 'vs/workbench/contrib/extensions/electron import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; import { ExtensionsAutoProfiler } from 'vs/workbench/contrib/extensions/electron-browser/extensionsAutoProfiler'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; -import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService'; -import { OpenExtensionsFolderAction } from 'vs/workbench/contrib/extensions/electron-browser/extensionsActions'; +import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService'; +import { OpenExtensionsFolderAction } from 'vs/workbench/contrib/extensions/electron-sandbox/extensionsActions'; import { ExtensionsLabel } from 'vs/platform/extensionManagement/common/extensionManagement'; import { ExtensionsWorkbenchService } from 'vs/workbench/contrib/extensions/browser/extensionsWorkbenchService'; import { IExtensionsWorkbenchService } from 'vs/workbench/contrib/extensions/common/extensions'; diff --git a/src/vs/workbench/contrib/extensions/electron-browser/runtimeExtensionsEditor.ts b/src/vs/workbench/contrib/extensions/electron-browser/runtimeExtensionsEditor.ts index 3c8acc5587d..56276cdec45 100644 --- a/src/vs/workbench/contrib/extensions/electron-browser/runtimeExtensionsEditor.ts +++ b/src/vs/workbench/contrib/extensions/electron-browser/runtimeExtensionsEditor.ts @@ -26,7 +26,6 @@ import { EnablementState } from 'vs/workbench/services/extensionManagement/commo import { IContextMenuService } from 'vs/platform/contextview/browser/contextView'; import { IElectronService } from 'vs/platform/electron/electron-sandbox/electron'; import { writeFile } from 'vs/base/node/pfs'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { memoize } from 'vs/base/common/decorators'; import { isNonEmptyArray } from 'vs/base/common/arrays'; import { Event } from 'vs/base/common/event'; @@ -664,7 +663,7 @@ export class SaveExtensionHostProfileAction extends Action { constructor( id: string = SaveExtensionHostProfileAction.ID, label: string = SaveExtensionHostProfileAction.LABEL, @IElectronService private readonly _electronService: IElectronService, - @IEnvironmentService private readonly _environmentService: IEnvironmentService, + @IWorkbenchEnvironmentService private readonly _environmentService: IWorkbenchEnvironmentService, @IExtensionHostProfileService private readonly _extensionHostProfileService: IExtensionHostProfileService, ) { super(id, label, undefined, false); diff --git a/src/vs/workbench/contrib/extensions/electron-browser/extensionsActions.ts b/src/vs/workbench/contrib/extensions/electron-sandbox/extensionsActions.ts similarity index 96% rename from src/vs/workbench/contrib/extensions/electron-browser/extensionsActions.ts rename to src/vs/workbench/contrib/extensions/electron-sandbox/extensionsActions.ts index 4289877aade..2df5b00fd45 100644 --- a/src/vs/workbench/contrib/extensions/electron-browser/extensionsActions.ts +++ b/src/vs/workbench/contrib/extensions/electron-sandbox/extensionsActions.ts @@ -8,7 +8,7 @@ import { Action } from 'vs/base/common/actions'; import { IFileService } from 'vs/platform/files/common/files'; import { URI } from 'vs/base/common/uri'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; -import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService'; +import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService'; import { IElectronService } from 'vs/platform/electron/electron-sandbox/electron'; import { Schemas } from 'vs/base/common/network'; diff --git a/src/vs/workbench/contrib/issue/electron-browser/issueService.ts b/src/vs/workbench/contrib/issue/electron-browser/issueService.ts index 92dd4581ccc..9719d83ec8d 100644 --- a/src/vs/workbench/contrib/issue/electron-browser/issueService.ts +++ b/src/vs/workbench/contrib/issue/electron-browser/issueService.ts @@ -13,7 +13,7 @@ import { IWorkbenchExtensionEnablementService } from 'vs/workbench/services/exte import { getZoomLevel } from 'vs/base/browser/browser'; import { IWorkbenchIssueService } from 'vs/workbench/contrib/issue/electron-browser/issue'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; -import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService'; +import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService'; import { ExtensionType } from 'vs/platform/extensions/common/extensions'; import { platform } from 'process'; import { IProductService } from 'vs/platform/product/common/productService'; diff --git a/src/vs/workbench/contrib/logs/electron-browser/logs.contribution.ts b/src/vs/workbench/contrib/logs/electron-sandbox/logs.contribution.ts similarity index 95% rename from src/vs/workbench/contrib/logs/electron-browser/logs.contribution.ts rename to src/vs/workbench/contrib/logs/electron-sandbox/logs.contribution.ts index 8196c1feabb..2985d0c6bd9 100644 --- a/src/vs/workbench/contrib/logs/electron-browser/logs.contribution.ts +++ b/src/vs/workbench/contrib/logs/electron-sandbox/logs.contribution.ts @@ -7,7 +7,7 @@ import * as nls from 'vs/nls'; import { Registry } from 'vs/platform/registry/common/platform'; import { IWorkbenchActionRegistry, Extensions as WorkbenchActionExtensions } from 'vs/workbench/common/actions'; import { SyncActionDescriptor } from 'vs/platform/actions/common/actions'; -import { OpenLogsFolderAction, OpenExtensionLogsFolderAction } from 'vs/workbench/contrib/logs/electron-browser/logsActions'; +import { OpenLogsFolderAction, OpenExtensionLogsFolderAction } from 'vs/workbench/contrib/logs/electron-sandbox/logsActions'; const workbenchActionsRegistry = Registry.as(WorkbenchActionExtensions.WorkbenchActions); const devCategory = nls.localize({ key: 'developer', comment: ['A developer on Code itself or someone diagnosing issues in Code'] }, "Developer"); diff --git a/src/vs/workbench/contrib/logs/electron-browser/logsActions.ts b/src/vs/workbench/contrib/logs/electron-sandbox/logsActions.ts similarity index 90% rename from src/vs/workbench/contrib/logs/electron-browser/logsActions.ts rename to src/vs/workbench/contrib/logs/electron-sandbox/logsActions.ts index 3109475f950..f27b568eaab 100644 --- a/src/vs/workbench/contrib/logs/electron-browser/logsActions.ts +++ b/src/vs/workbench/contrib/logs/electron-sandbox/logsActions.ts @@ -8,10 +8,9 @@ import { join } from 'vs/base/common/path'; import { URI } from 'vs/base/common/uri'; import * as nls from 'vs/nls'; import { IElectronService } from 'vs/platform/electron/electron-sandbox/electron'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; +import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService'; import { IFileService } from 'vs/platform/files/common/files'; -import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService'; export class OpenLogsFolderAction extends Action { @@ -19,7 +18,7 @@ export class OpenLogsFolderAction extends Action { static readonly LABEL = nls.localize('openLogsFolder', "Open Logs Folder"); constructor(id: string, label: string, - @IEnvironmentService private readonly environmentService: IEnvironmentService, + @IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService, @IElectronService private readonly electronService: IElectronService, ) { super(id, label); diff --git a/src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.ts b/src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.ts index dd573e8b111..f10ef127e49 100644 --- a/src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.ts +++ b/src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.ts @@ -11,7 +11,6 @@ import * as path from 'vs/base/common/path'; import { isWeb } from 'vs/base/common/platform'; import { URI } from 'vs/base/common/uri'; import * as UUID from 'vs/base/common/uuid'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { IOpenerService, matchesScheme } from 'vs/platform/opener/common/opener'; import { CELL_MARGIN, CELL_RUN_GUTTER, CODE_CELL_LEFT_MARGIN, CELL_OUTPUT_PADDING } from 'vs/workbench/contrib/notebook/browser/constants'; import { INotebookEditor } from 'vs/workbench/contrib/notebook/browser/notebookBrowser'; @@ -242,9 +241,8 @@ export class BackLayerWebView extends Disposable { @IWebviewService readonly webviewService: IWebviewService, @IOpenerService readonly openerService: IOpenerService, @INotebookService private readonly notebookService: INotebookService, - @IEnvironmentService private readonly environmentService: IEnvironmentService, @IWorkspaceContextService private readonly contextService: IWorkspaceContextService, - @IWorkbenchEnvironmentService private readonly workbenchEnvironmentService: IWorkbenchEnvironmentService, + @IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService, @IFileDialogService private readonly fileDialogService: IFileDialogService, @IFileService private readonly fileService: IFileService, ) { @@ -358,7 +356,7 @@ export class BackLayerWebView extends Disposable { async createWebview(): Promise { const pathsPath = getPathFromAmdModule(require, 'vs/loader.js'); - const loader = asWebviewUri(this.workbenchEnvironmentService, this.id, URI.file(pathsPath)); + const loader = asWebviewUri(this.environmentService, this.id, URI.file(pathsPath)); let coreDependencies = ''; let resolveFunc: () => void; @@ -367,7 +365,7 @@ export class BackLayerWebView extends Disposable { resolveFunc = resolve; }); - const baseUrl = asWebviewUri(this.workbenchEnvironmentService, this.id, dirname(this.documentUri)); + const baseUrl = asWebviewUri(this.environmentService, this.id, dirname(this.documentUri)); if (!isWeb) { coreDependencies = ``; @@ -797,7 +795,7 @@ ${loaderJs} if (this.environmentService.isExtensionDevelopment && (preload.scheme === 'http' || preload.scheme === 'https')) { return preload; } - return asWebviewUri(this.workbenchEnvironmentService, this.id, preload); + return asWebviewUri(this.environmentService, this.id, preload); }); preloads.forEach(e => { @@ -827,7 +825,7 @@ ${loaderJs} const extensionLocations: URI[] = []; for (const rendererInfo of renderers) { const preloads = [rendererInfo.entrypoint, ...rendererInfo.preloads] - .map(preload => asWebviewUri(this.workbenchEnvironmentService, this.id, preload)); + .map(preload => asWebviewUri(this.environmentService, this.id, preload)); extensionLocations.push(rendererInfo.extensionLocation); preloads.forEach(e => { diff --git a/src/vs/workbench/contrib/performance/electron-browser/startupProfiler.ts b/src/vs/workbench/contrib/performance/electron-browser/startupProfiler.ts index 9bc3cc13ee0..2e0f791450a 100644 --- a/src/vs/workbench/contrib/performance/electron-browser/startupProfiler.ts +++ b/src/vs/workbench/contrib/performance/electron-browser/startupProfiler.ts @@ -8,8 +8,8 @@ import { exists, readdir, readFile, rimraf } from 'vs/base/node/pfs'; import { ITextModelService } from 'vs/editor/common/services/resolverService'; import { localize } from 'vs/nls'; import { IDialogService } from 'vs/platform/dialogs/common/dialogs'; -import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; +import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService'; import { ILifecycleService, LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle'; import { IWorkbenchContribution } from 'vs/workbench/common/contributions'; import { PerfviewInput } from 'vs/workbench/contrib/performance/browser/perfviewEditor'; diff --git a/src/vs/workbench/contrib/performance/electron-browser/startupTimings.ts b/src/vs/workbench/contrib/performance/electron-browser/startupTimings.ts index d9497593fbb..2b3024c77c9 100644 --- a/src/vs/workbench/contrib/performance/electron-browser/startupTimings.ts +++ b/src/vs/workbench/contrib/performance/electron-browser/startupTimings.ts @@ -9,7 +9,7 @@ import { promisify } from 'util'; import { onUnexpectedError } from 'vs/base/common/errors'; import { isCodeEditor } from 'vs/editor/browser/editorBrowser'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; -import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService'; +import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService'; import { ILifecycleService, StartupKind, StartupKindToString } from 'vs/platform/lifecycle/common/lifecycle'; import { IProductService } from 'vs/platform/product/common/productService'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; diff --git a/src/vs/workbench/contrib/remote/electron-browser/remote.contribution.ts b/src/vs/workbench/contrib/remote/electron-browser/remote.contribution.ts index bf829f2aaed..365ae95ec0e 100644 --- a/src/vs/workbench/contrib/remote/electron-browser/remote.contribution.ts +++ b/src/vs/workbench/contrib/remote/electron-browser/remote.contribution.ts @@ -17,13 +17,12 @@ import { ICommandService } from 'vs/platform/commands/common/commands'; import { REMOTE_HOST_SCHEME } from 'vs/platform/remote/common/remoteHosts'; import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions'; import { ILogService } from 'vs/platform/log/common/log'; -import { IDialogService } from 'vs/platform/dialogs/common/dialogs'; -import { DialogChannel } from 'vs/platform/dialogs/electron-browser/dialogIpc'; import { DownloadServiceChannel } from 'vs/platform/download/common/downloadIpc'; import { LoggerChannel } from 'vs/platform/log/common/logIpc'; import { ipcRenderer } from 'vs/base/parts/sandbox/electron-sandbox/globals'; import { IDiagnosticInfoOptions, IRemoteDiagnosticInfo } from 'vs/platform/diagnostics/common/diagnostics'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; +import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService'; import { PersistentConnectionEventType } from 'vs/platform/remote/common/remoteAgentConnection'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from 'vs/platform/configuration/common/configurationRegistry'; @@ -31,19 +30,16 @@ import { IRemoteAuthorityResolverService } from 'vs/platform/remote/common/remot import { RemoteFileDialogContext } from 'vs/workbench/browser/contextkeys'; import { IDownloadService } from 'vs/platform/download/common/download'; import { OpenLocalFileFolderCommand, OpenLocalFileCommand, OpenLocalFolderCommand, SaveLocalFileCommand } from 'vs/workbench/services/dialogs/browser/simpleFileDialog'; -import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService'; class RemoteChannelsContribution implements IWorkbenchContribution { constructor( @ILogService logService: ILogService, @IRemoteAgentService remoteAgentService: IRemoteAgentService, - @IDialogService dialogService: IDialogService, @IDownloadService downloadService: IDownloadService ) { const connection = remoteAgentService.getConnection(); if (connection) { - connection.registerChannel('dialog', new DialogChannel(dialogService)); connection.registerChannel('download', new DownloadServiceChannel(downloadService)); connection.registerChannel('logger', new LoggerChannel(logService)); } diff --git a/src/vs/workbench/contrib/splash/electron-browser/partsSplash.contribution.ts b/src/vs/workbench/contrib/splash/electron-browser/partsSplash.contribution.ts index 8bf519fd308..b2176a69a59 100644 --- a/src/vs/workbench/contrib/splash/electron-browser/partsSplash.contribution.ts +++ b/src/vs/workbench/contrib/splash/electron-browser/partsSplash.contribution.ts @@ -19,12 +19,12 @@ import { Extensions, IWorkbenchContributionsRegistry } from 'vs/workbench/common import * as themes from 'vs/workbench/common/theme'; import { IWorkbenchLayoutService, Parts, Position } from 'vs/workbench/services/layout/browser/layoutService'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; +import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService'; import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; import { URI } from 'vs/base/common/uri'; import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import * as perf from 'vs/base/common/performance'; -import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService'; import { assertIsDefined } from 'vs/base/common/types'; import { IElectronService } from 'vs/platform/electron/electron-sandbox/electron'; diff --git a/src/vs/workbench/contrib/tags/electron-browser/workspaceTagsService.ts b/src/vs/workbench/contrib/tags/electron-browser/workspaceTagsService.ts index 9e046ee92b2..3bfe56b5d5e 100644 --- a/src/vs/workbench/contrib/tags/electron-browser/workspaceTagsService.ts +++ b/src/vs/workbench/contrib/tags/electron-browser/workspaceTagsService.ts @@ -6,7 +6,7 @@ import * as crypto from 'crypto'; import { IFileService, IResolveFileResult, IFileStat } from 'vs/platform/files/common/files'; import { IWorkspaceContextService, WorkbenchState, IWorkspace } from 'vs/platform/workspace/common/workspace'; -import { IWorkbenchEnvironmentService, IEnvironmentConfiguration } from 'vs/workbench/services/environment/common/environmentService'; +import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; import { IHostService } from 'vs/workbench/services/host/browser/host'; import { INotificationService, NeverShowAgainScope, INeverShowAgainOptions } from 'vs/platform/notification/common/notification'; import { IQuickInputService, IQuickPickItem } from 'vs/platform/quickinput/common/quickInput'; @@ -139,7 +139,7 @@ export class WorkspaceTagsService implements IWorkspaceTagsService { async getTags(): Promise { if (!this._tags) { - this._tags = await this.resolveWorkspaceTags(this.environmentService.configuration, rootFiles => this.handleWorkspaceFiles(rootFiles)); + this._tags = await this.resolveWorkspaceTags(rootFiles => this.handleWorkspaceFiles(rootFiles)); } return this._tags; @@ -297,7 +297,7 @@ export class WorkspaceTagsService implements IWorkspaceTagsService { "workspace.py.playwright" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true } } */ - private resolveWorkspaceTags(configuration: IEnvironmentConfiguration, participant?: (rootFiles: string[]) => void): Promise { + private resolveWorkspaceTags(participant?: (rootFiles: string[]) => void): Promise { const tags: Tags = Object.create(null); const state = this.contextService.getWorkbenchState(); @@ -305,7 +305,7 @@ export class WorkspaceTagsService implements IWorkspaceTagsService { tags['workspace.id'] = this.getTelemetryWorkspaceId(workspace, state); - const { filesToOpenOrCreate, filesToDiff } = configuration; + const { filesToOpenOrCreate, filesToDiff } = this.environmentService.configuration; tags['workbench.filesToOpenOrCreate'] = filesToOpenOrCreate && filesToOpenOrCreate.length || 0; tags['workbench.filesToDiff'] = filesToDiff && filesToDiff.length || 0; @@ -313,7 +313,7 @@ export class WorkspaceTagsService implements IWorkspaceTagsService { tags['workspace.roots'] = isEmpty ? 0 : workspace.folders.length; tags['workspace.empty'] = isEmpty; - const folders = !isEmpty ? workspace.folders.map(folder => folder.uri) : this.productService.quality !== 'stable' && this.findFolders(configuration); + const folders = !isEmpty ? workspace.folders.map(folder => folder.uri) : this.productService.quality !== 'stable' && this.findFolders(); if (!folders || !folders.length || !this.fileService) { return Promise.resolve(tags); } @@ -524,12 +524,13 @@ export class WorkspaceTagsService implements IWorkspaceTagsService { } } - private findFolders(configuration: IEnvironmentConfiguration): URI[] | undefined { - const folder = this.findFolder(configuration); + private findFolders(): URI[] | undefined { + const folder = this.findFolder(); return folder && [folder]; } - private findFolder({ filesToOpenOrCreate, filesToDiff }: IEnvironmentConfiguration): URI | undefined { + private findFolder(): URI | undefined { + const { filesToOpenOrCreate, filesToDiff } = this.environmentService.configuration; if (filesToOpenOrCreate && filesToOpenOrCreate.length) { return this.parentURI(filesToOpenOrCreate[0].fileUri); } else if (filesToDiff && filesToDiff.length) { diff --git a/src/vs/workbench/contrib/webview/browser/baseWebviewElement.ts b/src/vs/workbench/contrib/webview/browser/baseWebviewElement.ts index b9dcaf3f964..4423555621a 100644 --- a/src/vs/workbench/contrib/webview/browser/baseWebviewElement.ts +++ b/src/vs/workbench/contrib/webview/browser/baseWebviewElement.ts @@ -9,7 +9,6 @@ import { Emitter } from 'vs/base/common/event'; import { Disposable, IDisposable } from 'vs/base/common/lifecycle'; import { URI } from 'vs/base/common/uri'; import { localize } from 'vs/nls'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions'; import { ILogService } from 'vs/platform/log/common/log'; import { INotificationService } from 'vs/platform/notification/common/notification'; @@ -89,8 +88,7 @@ export abstract class BaseWebview extends Disposable { @INotificationService notificationService: INotificationService, @ILogService private readonly _logService: ILogService, @ITelemetryService private readonly _telemetryService: ITelemetryService, - @IEnvironmentService private readonly _environmentService: IEnvironmentService, - @IWorkbenchEnvironmentService protected readonly workbenchEnvironmentService: IWorkbenchEnvironmentService, + @IWorkbenchEnvironmentService protected readonly environmentService: IWorkbenchEnvironmentService ) { super(); @@ -233,7 +231,7 @@ export abstract class BaseWebview extends Disposable { this._hasAlertedAboutMissingCsp = true; if (this.extension && this.extension.id) { - if (this._environmentService.isExtensionDevelopment) { + if (this.environmentService.isExtensionDevelopment) { this._onMissingCsp.fire(this.extension.id); } diff --git a/src/vs/workbench/contrib/webview/browser/webviewElement.ts b/src/vs/workbench/contrib/webview/browser/webviewElement.ts index 70cd75dcf42..0fca575f589 100644 --- a/src/vs/workbench/contrib/webview/browser/webviewElement.ts +++ b/src/vs/workbench/contrib/webview/browser/webviewElement.ts @@ -8,7 +8,6 @@ import { streamToBuffer } from 'vs/base/common/buffer'; import { IDisposable } from 'vs/base/common/lifecycle'; import { Schemas } from 'vs/base/common/network'; import { URI } from 'vs/base/common/uri'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { IFileService } from 'vs/platform/files/common/files'; import { ILogService } from 'vs/platform/log/common/log'; import { INotificationService } from 'vs/platform/notification/common/notification'; @@ -38,12 +37,11 @@ export class IFrameWebview extends BaseWebview implements Web @IFileService private readonly fileService: IFileService, @IRequestService private readonly requestService: IRequestService, @ITelemetryService telemetryService: ITelemetryService, - @IEnvironmentService environmentService: IEnvironmentService, - @IWorkbenchEnvironmentService private readonly _workbenchEnvironmentService: IWorkbenchEnvironmentService, + @IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService, @IRemoteAuthorityResolverService private readonly _remoteAuthorityResolverService: IRemoteAuthorityResolverService, @ILogService logService: ILogService, ) { - super(id, options, contentOptions, extension, webviewThemeDataProvider, notificationService, logService, telemetryService, environmentService, _workbenchEnvironmentService); + super(id, options, contentOptions, extension, webviewThemeDataProvider, notificationService, logService, telemetryService, environmentService); this._portMappingManager = this._register(new WebviewPortMappingManager( () => this.extension?.location, @@ -83,7 +81,7 @@ export class IFrameWebview extends BaseWebview implements Web } private get externalEndpoint(): string { - const endpoint = this.workbenchEnvironmentService.webviewExternalEndpoint!.replace('{{uuid}}', this.id); + const endpoint = this.environmentService.webviewExternalEndpoint!.replace('{{uuid}}', this.id); if (endpoint[endpoint.length - 1] === '/') { return endpoint.slice(0, endpoint.length - 1); } @@ -142,7 +140,7 @@ export class IFrameWebview extends BaseWebview implements Web private async loadResource(requestPath: string, uri: URI) { try { - const remoteAuthority = this._workbenchEnvironmentService.configuration.remoteAuthority; + const remoteAuthority = this.environmentService.configuration.remoteAuthority; const remoteConnectionData = remoteAuthority ? this._remoteAuthorityResolverService.getConnectionData(remoteAuthority) : null; const extensionLocation = this.extension?.location; @@ -193,7 +191,7 @@ export class IFrameWebview extends BaseWebview implements Web } private async localLocalhost(origin: string) { - const authority = this._workbenchEnvironmentService.configuration.remoteAuthority; + const authority = this.environmentService.configuration.remoteAuthority; const resolveAuthority = authority ? await this._remoteAuthorityResolverService.resolveAuthority(authority) : undefined; const redirect = resolveAuthority ? await this._portMappingManager.getRedirect(resolveAuthority.authority, origin) : undefined; return this._send('did-load-localhost', { diff --git a/src/vs/workbench/contrib/webview/electron-browser/iframeWebviewElement.ts b/src/vs/workbench/contrib/webview/electron-browser/iframeWebviewElement.ts index 9e776c2122d..6ab914983ed 100644 --- a/src/vs/workbench/contrib/webview/electron-browser/iframeWebviewElement.ts +++ b/src/vs/workbench/contrib/webview/electron-browser/iframeWebviewElement.ts @@ -6,7 +6,6 @@ import { ThrottledDelayer } from 'vs/base/common/async'; import { Schemas } from 'vs/base/common/network'; import { URI } from 'vs/base/common/uri'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { IFileService } from 'vs/platform/files/common/files'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { ILogService } from 'vs/platform/log/common/log'; @@ -42,15 +41,14 @@ export class ElectronIframeWebview extends IFrameWebview { @IFileService fileService: IFileService, @IRequestService requestService: IRequestService, @ITelemetryService telemetryService: ITelemetryService, - @IEnvironmentService environmentService: IEnvironmentService, - @IWorkbenchEnvironmentService _workbenchEnvironmentService: IWorkbenchEnvironmentService, + @IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService, @IRemoteAuthorityResolverService _remoteAuthorityResolverService: IRemoteAuthorityResolverService, @ILogService logService: ILogService, @IInstantiationService instantiationService: IInstantiationService, @INotificationService noficationService: INotificationService, ) { super(id, options, contentOptions, extension, webviewThemeDataProvider, - noficationService, tunnelService, fileService, requestService, telemetryService, environmentService, _workbenchEnvironmentService, _remoteAuthorityResolverService, logService); + noficationService, tunnelService, fileService, requestService, telemetryService, environmentService, _remoteAuthorityResolverService, logService); this._resourceRequestManager = this._register(instantiationService.createInstance(WebviewResourceRequestManager, id, extension, this.content.options)); } diff --git a/src/vs/workbench/contrib/webview/electron-browser/webviewElement.ts b/src/vs/workbench/contrib/webview/electron-browser/webviewElement.ts index 0bf81242f3b..22c9c43f7d8 100644 --- a/src/vs/workbench/contrib/webview/electron-browser/webviewElement.ts +++ b/src/vs/workbench/contrib/webview/electron-browser/webviewElement.ts @@ -14,7 +14,6 @@ import { isMacintosh } from 'vs/base/common/platform'; import { URI } from 'vs/base/common/uri'; import { createChannelSender } from 'vs/base/parts/ipc/common/ipc'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IMainProcessService } from 'vs/platform/ipc/electron-sandbox/mainProcessService'; import { ILogService } from 'vs/platform/log/common/log'; @@ -121,13 +120,12 @@ export class ElectronWebviewBasedWebview extends BaseWebview impleme @ILogService private readonly _myLogService: ILogService, @IInstantiationService instantiationService: IInstantiationService, @ITelemetryService telemetryService: ITelemetryService, - @IEnvironmentService environmentService: IEnvironmentService, - @IWorkbenchEnvironmentService workbenchEnvironmentService: IWorkbenchEnvironmentService, + @IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService, @IConfigurationService configurationService: IConfigurationService, @IMainProcessService mainProcessService: IMainProcessService, @INotificationService noficationService: INotificationService, ) { - super(id, options, contentOptions, extension, _webviewThemeDataProvider, noficationService, _myLogService, telemetryService, environmentService, workbenchEnvironmentService); + super(id, options, contentOptions, extension, _webviewThemeDataProvider, noficationService, _myLogService, telemetryService, environmentService); /* __GDPR__ "webview.createWebview" : { diff --git a/src/vs/workbench/electron-browser/desktop.main.ts b/src/vs/workbench/electron-browser/desktop.main.ts index 20a22c30d0a..47e1fdcf5d5 100644 --- a/src/vs/workbench/electron-browser/desktop.main.ts +++ b/src/vs/workbench/electron-browser/desktop.main.ts @@ -8,7 +8,7 @@ import * as gracefulFs from 'graceful-fs'; import { zoomLevelToZoomFactor } from 'vs/platform/windows/common/windows'; import { importEntries, mark } from 'vs/base/common/performance'; import { Workbench } from 'vs/workbench/browser/workbench'; -import { NativeWindow } from 'vs/workbench/electron-browser/window'; +import { NativeWindow } from 'vs/workbench/electron-sandbox/window'; import { setZoomLevel, setZoomFactor, setFullscreen } from 'vs/base/browser/browser'; import { domContentLoaded, addDisposableListener, EventType, scheduleAtNextAnimationFrame } from 'vs/base/browser/dom'; import { onUnexpectedError } from 'vs/base/common/errors'; @@ -16,8 +16,8 @@ import { URI } from 'vs/base/common/uri'; import { WorkspaceService } from 'vs/workbench/services/configuration/browser/configurationService'; import { NativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; +import { INativeWorkbenchConfiguration } from 'vs/workbench/services/environment/electron-sandbox/environmentService'; import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; -import { INativeWindowConfiguration } from 'vs/platform/windows/node/window'; import { ISingleFolderWorkspaceIdentifier, IWorkspaceInitializationPayload, ISingleFolderWorkspaceInitializationPayload, reviveWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces'; import { ILogService } from 'vs/platform/log/common/log'; import { NativeStorageService } from 'vs/platform/storage/node/storageService'; @@ -38,7 +38,7 @@ import { FileService } from 'vs/platform/files/common/fileService'; import { IFileService } from 'vs/platform/files/common/files'; import { DiskFileSystemProvider } from 'vs/platform/files/electron-browser/diskFileSystemProvider'; import { RemoteFileSystemProvider } from 'vs/workbench/services/remote/common/remoteAgentFileSystemChannel'; -import { ConfigurationCache } from 'vs/workbench/services/configuration/node/configurationCache'; +import { ConfigurationCache } from 'vs/workbench/services/configuration/electron-browser/configurationCache'; import { SignService } from 'vs/platform/sign/node/signService'; import { ISignService } from 'vs/platform/sign/common/sign'; import { FileUserDataProvider } from 'vs/workbench/services/userData/common/fileUserDataProvider'; @@ -52,9 +52,9 @@ import { IElectronService, ElectronService } from 'vs/platform/electron/electron class DesktopMain extends Disposable { - private readonly environmentService = new NativeWorkbenchEnvironmentService(this.configuration, this.configuration.execPath); + private readonly environmentService = new NativeWorkbenchEnvironmentService(this.configuration); - constructor(private configuration: INativeWindowConfiguration) { + constructor(private configuration: INativeWorkbenchConfiguration) { super(); this.init(); @@ -319,7 +319,7 @@ class DesktopMain extends Disposable { } -export function main(configuration: INativeWindowConfiguration): Promise { +export function main(configuration: INativeWorkbenchConfiguration): Promise { const workbench = new DesktopMain(configuration); return workbench.open(); diff --git a/src/vs/workbench/electron-sandbox/desktop.main.ts b/src/vs/workbench/electron-sandbox/desktop.main.ts index 9b4c13f9441..11a57edd768 100644 --- a/src/vs/workbench/electron-sandbox/desktop.main.ts +++ b/src/vs/workbench/electron-sandbox/desktop.main.ts @@ -6,11 +6,13 @@ import { zoomLevelToZoomFactor } from 'vs/platform/windows/common/windows'; import { importEntries, mark } from 'vs/base/common/performance'; import { Workbench } from 'vs/workbench/browser/workbench'; +import { NativeWindow } from 'vs/workbench/electron-sandbox/window'; import { setZoomLevel, setZoomFactor, setFullscreen } from 'vs/base/browser/browser'; import { domContentLoaded, addDisposableListener, EventType, scheduleAtNextAnimationFrame } from 'vs/base/browser/dom'; import { URI } from 'vs/base/common/uri'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; +import { reviveWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces'; import { ILogService } from 'vs/platform/log/common/log'; import { Schemas } from 'vs/base/common/network'; import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; @@ -29,17 +31,14 @@ import { IProductService } from 'vs/platform/product/common/productService'; import product from 'vs/platform/product/common/product'; import { IResourceIdentityService } from 'vs/platform/resource/common/resourceIdentityService'; import { IElectronService, ElectronService } from 'vs/platform/electron/electron-sandbox/electron'; -import { SimpleConfigurationService, simpleFileSystemProvider, SimpleLogService, SimpleRemoteAgentService, SimpleRemoteAuthorityResolverService, SimpleResourceIdentityService, SimpleSignService, SimpleStorageService, SimpleWorkspaceService } from 'vs/workbench/electron-sandbox/sandbox.simpleservices'; -import { BrowserWorkbenchEnvironmentService } from 'vs/workbench/services/environment/browser/environmentService'; +import { SimpleConfigurationService, simpleFileSystemProvider, SimpleLogService, SimpleRemoteAgentService, SimpleRemoteAuthorityResolverService, SimpleResourceIdentityService, SimpleSignService, SimpleStorageService, SimpleWorkbenchEnvironmentService, SimpleWorkspaceService } from 'vs/workbench/electron-sandbox/sandbox.simpleservices'; +import { INativeWorkbenchConfiguration } from 'vs/workbench/services/environment/electron-sandbox/environmentService'; class DesktopMain extends Disposable { - private readonly environmentService = new BrowserWorkbenchEnvironmentService({ - logsPath: URI.file('logs-path'), - workspaceId: '' - }); + private readonly environmentService = new SimpleWorkbenchEnvironmentService(this.configuration); - constructor(private configuration: any /*INativeWindowConfiguration*/) { + constructor(private configuration: INativeWorkbenchConfiguration) { super(); this.init(); @@ -47,14 +46,43 @@ class DesktopMain extends Disposable { private init(): void { + // Massage configuration file URIs + this.reviveUris(); + // Setup perf - importEntries(this.configuration.perfEntries); + importEntries(this.environmentService.configuration.perfEntries); // Browser config const zoomLevel = this.configuration.zoomLevel || 0; setZoomFactor(zoomLevelToZoomFactor(zoomLevel)); setZoomLevel(zoomLevel, true /* isTrusted */); - setFullscreen(!!this.configuration.fullscreen); + setFullscreen(!!this.environmentService.configuration.fullscreen); + } + + private reviveUris() { + if (this.environmentService.configuration.folderUri) { + this.environmentService.configuration.folderUri = URI.revive(this.environmentService.configuration.folderUri); + } + + if (this.environmentService.configuration.workspace) { + this.environmentService.configuration.workspace = reviveWorkspaceIdentifier(this.environmentService.configuration.workspace); + } + + const filesToWait = this.environmentService.configuration.filesToWait; + const filesToWaitPaths = filesToWait?.paths; + [filesToWaitPaths, this.environmentService.configuration.filesToOpenOrCreate, this.environmentService.configuration.filesToDiff].forEach(paths => { + if (Array.isArray(paths)) { + paths.forEach(path => { + if (path.fileUri) { + path.fileUri = URI.revive(path.fileUri); + } + }); + } + }); + + if (filesToWait) { + filesToWait.waitMarkerFileUri = URI.revive(filesToWait.waitMarkerFileUri); + } } async open(): Promise { @@ -70,7 +98,10 @@ class DesktopMain extends Disposable { this.registerListeners(workbench, services.storageService); // Startup - workbench.startup(); + const instantiationService = workbench.startup(); + + // Window + this._register(instantiationService.createInstance(NativeWindow)); // Logging services.logService.trace('workbench configuration', JSON.stringify(this.environmentService.configuration)); @@ -194,7 +225,7 @@ class DesktopMain extends Disposable { } } -export function main(configuration: any /*INativeWindowConfiguration*/): Promise { +export function main(configuration: INativeWorkbenchConfiguration): Promise { const workbench = new DesktopMain(configuration); return workbench.open(); diff --git a/src/vs/workbench/electron-sandbox/sandbox.simpleservices.ts b/src/vs/workbench/electron-sandbox/sandbox.simpleservices.ts index 596d7b2a8a9..8dbebb9eef7 100644 --- a/src/vs/workbench/electron-sandbox/sandbox.simpleservices.ts +++ b/src/vs/workbench/electron-sandbox/sandbox.simpleservices.ts @@ -35,25 +35,19 @@ import { IKeyboardMapper } from 'vs/workbench/services/keybinding/common/keyboar import { ChordKeybinding, ResolvedKeybinding, SimpleKeybinding } from 'vs/base/common/keyCodes'; import { ScanCodeBinding } from 'vs/base/common/scanCode'; import { USLayoutResolvedKeybinding } from 'vs/platform/keybinding/common/usLayoutResolvedKeybinding'; -import { isWindows, OperatingSystem, OS } from 'vs/base/common/platform'; -import { IPathService } from 'vs/workbench/services/path/common/pathService'; -import { posix, win32 } from 'vs/base/common/path'; -import { IConfirmation, IConfirmationResult, IDialogOptions, IDialogService, IShowResult } from 'vs/platform/dialogs/common/dialogs'; -import Severity from 'vs/base/common/severity'; +import { isWindows, OS } from 'vs/base/common/platform'; import { IWebviewService, WebviewContentOptions, WebviewElement, WebviewExtensionDescription, WebviewIcons, WebviewOptions, WebviewOverlay } from 'vs/workbench/contrib/webview/browser/webview'; import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; import { AbstractTextFileService } from 'vs/workbench/services/textfile/browser/textFileService'; import { EnablementState, ExtensionRecommendationReason, IExtensionManagementServer, IExtensionManagementServerService, IExtensionRecommendation } from 'vs/workbench/services/extensionManagement/common/extensionManagement'; import { LanguageId, TokenizationRegistry } from 'vs/editor/common/modes'; import { IGrammar, ITextMateService } from 'vs/workbench/services/textMate/common/textMateService'; -import { AccessibilitySupport, IAccessibilityService } from 'vs/platform/accessibility/common/accessibility'; import { ITunnelProvider, ITunnelService, RemoteTunnel } from 'vs/platform/remote/common/tunnel'; import { Disposable, IDisposable } from 'vs/base/common/lifecycle'; import { IManualSyncTask, IResourcePreview, ISyncResourceHandle, ISyncTask, IUserDataAutoSyncService, IUserDataSyncService, IUserDataSyncStore, IUserDataSyncStoreManagementService, SyncResource, SyncStatus, UserDataSyncStoreType } from 'vs/platform/userDataSync/common/userDataSync'; import { IUserDataSyncAccount, IUserDataSyncAccountService } from 'vs/platform/userDataSync/common/userDataSyncAccount'; import { AbstractTimerService, IStartupMetrics, ITimerService, Writeable } from 'vs/workbench/services/timer/browser/timerService'; -import { IWorkspaceEditingService } from 'vs/workbench/services/workspaces/common/workspaceEditing'; -import { ISingleFolderWorkspaceIdentifier, IWorkspaceFolderCreationData, IWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces'; +import { ISingleFolderWorkspaceIdentifier, IWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces'; import { ITaskProvider, ITaskService, ITaskSummary, ProblemMatcherRunOptions, Task, TaskFilter, TaskTerminateResponse, WorkspaceFolderTaskResult } from 'vs/workbench/contrib/tasks/common/taskService'; import { Action } from 'vs/base/common/actions'; import { LinkedMap } from 'vs/base/common/map'; @@ -67,6 +61,96 @@ import { Color, RGBA } from 'vs/base/common/color'; import { joinPath } from 'vs/base/common/resources'; import { VSBuffer } from 'vs/base/common/buffer'; import { IExtensionsWorkbenchService } from 'vs/workbench/contrib/extensions/common/extensions'; +import { IIntegrityService, IntegrityTestResult } from 'vs/workbench/services/integrity/common/integrity'; +import { INativeWorkbenchConfiguration, INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService'; +import { NativeParsedArgs } from 'vs/platform/environment/common/argv'; +import { IExtensionHostDebugParams } from 'vs/platform/environment/common/environment'; +import { IWorkbenchConstructionOptions } from 'vs/workbench/workbench.web.api'; +import { Schemas } from 'vs/base/common/network'; + + +//#region Environment + +export class SimpleWorkbenchEnvironmentService implements INativeWorkbenchEnvironmentService { + + declare readonly _serviceBrand: undefined; + + constructor( + readonly configuration: INativeWorkbenchConfiguration + ) { } + + get userRoamingDataHome(): URI { return URI.file('/sandbox-user-data-dir').with({ scheme: Schemas.userData }); } + get settingsResource(): URI { return joinPath(this.userRoamingDataHome, 'settings.json'); } + get argvResource(): URI { return joinPath(this.userRoamingDataHome, 'argv.json'); } + get snippetsHome(): URI { return joinPath(this.userRoamingDataHome, 'snippets'); } + get globalStorageHome(): URI { return URI.joinPath(this.userRoamingDataHome, 'globalStorage'); } + get workspaceStorageHome(): URI { return URI.joinPath(this.userRoamingDataHome, 'workspaceStorage'); } + get keybindingsResource(): URI { return joinPath(this.userRoamingDataHome, 'keybindings.json'); } + get logFile(): URI { return joinPath(this.userRoamingDataHome, 'window.log'); } + get untitledWorkspacesHome(): URI { return joinPath(this.userRoamingDataHome, 'Workspaces'); } + get serviceMachineIdResource(): URI { return joinPath(this.userRoamingDataHome, 'machineid'); } + get userDataSyncLogResource(): URI { return joinPath(this.userRoamingDataHome, 'syncLog'); } + get userDataSyncHome(): URI { return joinPath(this.userRoamingDataHome, 'syncHome'); } + get backupHome(): URI { return joinPath(this.userRoamingDataHome, 'backupsHome'); } + + options?: IWorkbenchConstructionOptions | undefined; + logExtensionHostCommunication?: boolean | undefined; + extensionEnabledProposedApi?: string[] | undefined; + webviewExternalEndpoint: string = undefined!; + webviewResourceRoot: string = undefined!; + webviewCspSource: string = undefined!; + skipReleaseNotes: boolean = undefined!; + keyboardLayoutResource: URI = undefined!; + sync: 'on' | 'off' | undefined; + enableSyncByDefault: boolean = false; + debugExtensionHost: IExtensionHostDebugParams = undefined!; + isExtensionDevelopment: boolean = false; + disableExtensions: boolean | string[] = []; + extensionDevelopmentLocationURI?: URI[] | undefined; + extensionTestsLocationURI?: URI | undefined; + logsPath: string = undefined!; + logLevel?: string | undefined; + + args: NativeParsedArgs = Object.create(null); + + execPath: string = undefined!; + cliPath: string = undefined!; + appRoot: string = undefined!; + userHome: URI = undefined!; + appSettingsHome: URI = undefined!; + userDataPath: string = undefined!; + machineSettingsResource: URI = undefined!; + backupWorkspacesPath: string = undefined!; + + log?: string | undefined; + extHostLogsPath: URI = undefined!; + + installSourcePath: string = undefined!; + + mainIPCHandle: string = undefined!; + sharedIPCHandle: string = undefined!; + + extensionsPath?: string | undefined; + extensionsDownloadPath: string = undefined!; + builtinExtensionsPath: string = undefined!; + + driverHandle?: string | undefined; + driverVerbose = false; + + crashReporterDirectory?: string | undefined; + crashReporterId?: string | undefined; + + nodeCachedDataDir?: string | undefined; + + disableUpdates = false; + sandbox = true; + verbose = false; + isBuilt = false; + disableTelemetry = false; +} + +//#endregion + //#region Workspace @@ -509,40 +593,6 @@ registerSingleton(IKeymapService, SimpleKeymapService); //#endregion -//#region Path - -class SimplePathService implements IPathService { - - declare readonly _serviceBrand: undefined; - - readonly resolvedUserHome = URI.file('user-home'); - readonly path = Promise.resolve(OS === OperatingSystem.Windows ? win32 : posix); - - async fileURI(path: string): Promise { return URI.file(path); } - async userHome(options?: { preferLocal: boolean; }): Promise { return this.resolvedUserHome; } -} - -registerSingleton(IPathService, SimplePathService); - -//#endregion - - -//#region Dialog - -class SimpleDialogService implements IDialogService { - - declare readonly _serviceBrand: undefined; - - async confirm(confirmation: IConfirmation): Promise { return { confirmed: false }; } - async show(severity: Severity, message: string, buttons: string[], options?: IDialogOptions): Promise { return { choice: 1 }; } - async about(): Promise { } -} - -registerSingleton(IDialogService, SimpleDialogService); - -//#endregion - - //#region Webview class SimpleWebviewService implements IWebviewService { @@ -606,25 +656,6 @@ registerSingleton(ITextMateService, SimpleTextMateService); //#endregion -//#region Accessibility - -class SimpleAccessibilityService implements IAccessibilityService { - - declare readonly _serviceBrand: undefined; - - onDidChangeScreenReaderOptimized = Event.None; - - isScreenReaderOptimized(): boolean { return false; } - async alwaysUnderlineAccessKeys(): Promise { return false; } - setAccessibilitySupport(accessibilitySupport: AccessibilitySupport): void { } - getAccessibilitySupport(): AccessibilitySupport { return AccessibilitySupport.Unknown; } -} - -registerSingleton(IAccessibilityService, SimpleAccessibilityService); - -//#endregion - - //#region Tunnel class SimpleTunnelService implements ITunnelService { @@ -758,27 +789,6 @@ registerSingleton(ITimerService, SimpleTimerService); //#endregion -//#region Workspace Editing - -class SimpleWorkspaceEditingService implements IWorkspaceEditingService { - - declare readonly _serviceBrand: undefined; - - async addFolders(folders: IWorkspaceFolderCreationData[], donotNotifyError?: boolean): Promise { } - async removeFolders(folders: URI[], donotNotifyError?: boolean): Promise { } - async updateFolders(index: number, deleteCount?: number, foldersToAdd?: IWorkspaceFolderCreationData[], donotNotifyError?: boolean): Promise { } - async enterWorkspace(path: URI): Promise { } - async createAndEnterWorkspace(folders: IWorkspaceFolderCreationData[], path?: URI): Promise { } - async saveAndEnterWorkspace(path: URI): Promise { } - async copyWorkspaceSettings(toWorkspace: IWorkspaceIdentifier): Promise { } - async pickNewWorkspacePath(): Promise { return undefined!; } -} - -registerSingleton(IWorkspaceEditingService, SimpleWorkspaceEditingService); - -//#endregion - - //#region Task class SimpleTaskService implements ITaskService { @@ -905,3 +915,19 @@ class SimpleOutputChannelModelService extends AsbtractOutputChannelModelService registerSingleton(IOutputChannelModelService, SimpleOutputChannelModelService); //#endregion + + +//#region Integrity + +class SimpleIntegrityService implements IIntegrityService { + + declare readonly _serviceBrand: undefined; + + async isPure(): Promise { + return { isPure: true, proof: [] }; + } +} + +registerSingleton(IIntegrityService, SimpleIntegrityService); + +//#endregion diff --git a/src/vs/workbench/electron-browser/window.ts b/src/vs/workbench/electron-sandbox/window.ts similarity index 99% rename from src/vs/workbench/electron-browser/window.ts rename to src/vs/workbench/electron-sandbox/window.ts index 4094d919e43..05291244456 100644 --- a/src/vs/workbench/electron-browser/window.ts +++ b/src/vs/workbench/electron-sandbox/window.ts @@ -35,6 +35,7 @@ import { IProductService } from 'vs/platform/product/common/productService'; import { INotificationService } from 'vs/platform/notification/common/notification'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; +import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService'; import { IAccessibilityService, AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility'; import { WorkbenchState, IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; import { coalesce } from 'vs/base/common/arrays'; @@ -59,7 +60,6 @@ import { IHostService } from 'vs/workbench/services/host/browser/host'; import { IWorkingCopyService, WorkingCopyCapabilities } from 'vs/workbench/services/workingCopy/common/workingCopyService'; import { AutoSaveMode, IFilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService'; import { Event } from 'vs/base/common/event'; -import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService'; import { clearAllFontInfos } from 'vs/editor/browser/config/configuration'; import { IRemoteAuthorityResolverService } from 'vs/platform/remote/common/remoteAuthorityResolver'; import { IAddressProvider, IAddress } from 'vs/platform/remote/common/remoteAgentConnection'; diff --git a/src/vs/workbench/services/accessibility/electron-browser/accessibilityService.ts b/src/vs/workbench/services/accessibility/electron-sandbox/accessibilityService.ts similarity index 95% rename from src/vs/workbench/services/accessibility/electron-browser/accessibilityService.ts rename to src/vs/workbench/services/accessibility/electron-sandbox/accessibilityService.ts index 166a53e48e1..e6f6419e512 100644 --- a/src/vs/workbench/services/accessibility/electron-browser/accessibilityService.ts +++ b/src/vs/workbench/services/accessibility/electron-sandbox/accessibilityService.ts @@ -6,6 +6,7 @@ import { IAccessibilityService, AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility'; import { isWindows, isLinux } from 'vs/base/common/platform'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; +import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { Registry } from 'vs/platform/registry/common/platform'; @@ -15,8 +16,6 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IJSONEditingService } from 'vs/workbench/services/configuration/common/jsonEditing'; import { IWorkbenchContribution, IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions'; import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; -import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService'; interface AccessibilityMetrics { enabled: boolean; @@ -75,7 +74,7 @@ class LinuxAccessibilityContribution implements IWorkbenchContribution { constructor( @IJSONEditingService jsonEditingService: IJSONEditingService, @IAccessibilityService accessibilityService: AccessibilityService, - @IEnvironmentService environmentService: IEnvironmentService + @IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService ) { const forceRendererAccessibility = () => { if (accessibilityService.isScreenReaderOptimized()) { diff --git a/src/vs/workbench/services/backup/electron-browser/backup.ts b/src/vs/workbench/services/backup/electron-sandbox/backup.ts similarity index 77% rename from src/vs/workbench/services/backup/electron-browser/backup.ts rename to src/vs/workbench/services/backup/electron-sandbox/backup.ts index 0057b918a0b..4e1c308b73b 100644 --- a/src/vs/workbench/services/backup/electron-browser/backup.ts +++ b/src/vs/workbench/services/backup/electron-sandbox/backup.ts @@ -4,9 +4,9 @@ *--------------------------------------------------------------------------------------------*/ import { URI } from 'vs/base/common/uri'; -import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService'; +import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService'; import { joinPath, relativePath } from 'vs/base/common/resources'; -export function toBackupWorkspaceResource(backupWorkspacePath: string, environmentService: INativeEnvironmentService): URI { +export function toBackupWorkspaceResource(backupWorkspacePath: string, environmentService: INativeWorkbenchEnvironmentService): URI { return joinPath(environmentService.userRoamingDataHome, relativePath(URI.file(environmentService.userDataPath), URI.file(backupWorkspacePath))!); } diff --git a/src/vs/workbench/services/backup/test/electron-browser/backupFileService.test.ts b/src/vs/workbench/services/backup/test/electron-browser/backupFileService.test.ts index 6adec355e0e..94dfd77136f 100644 --- a/src/vs/workbench/services/backup/test/electron-browser/backupFileService.test.ts +++ b/src/vs/workbench/services/backup/test/electron-browser/backupFileService.test.ts @@ -27,7 +27,7 @@ import { hashPath, BackupFileService } from 'vs/workbench/services/backup/node/b import { BACKUPS } from 'vs/platform/environment/common/environment'; import { FileUserDataProvider } from 'vs/workbench/services/userData/common/fileUserDataProvider'; import { VSBuffer } from 'vs/base/common/buffer'; -import { TestWindowConfiguration } from 'vs/workbench/test/electron-browser/workbenchTestServices'; +import { TestWorkbenchConfiguration } from 'vs/workbench/test/electron-browser/workbenchTestServices'; const userdataDir = getRandomTestPath(os.tmpdir(), 'vsctests', 'backupfileservice'); const appSettingsHome = path.join(userdataDir, 'User'); @@ -46,10 +46,10 @@ const fooBackupPath = path.join(workspaceBackupPath, 'file', hashPath(fooFile)); const barBackupPath = path.join(workspaceBackupPath, 'file', hashPath(barFile)); const untitledBackupPath = path.join(workspaceBackupPath, 'untitled', hashPath(untitledFile)); -class TestBackupEnvironmentService extends NativeWorkbenchEnvironmentService { +class TestWorkbenchEnvironmentService extends NativeWorkbenchEnvironmentService { constructor(backupPath: string) { - super({ ...TestWindowConfiguration, backupPath, 'user-data-dir': userdataDir }, TestWindowConfiguration.execPath); + super({ ...TestWorkbenchConfiguration, backupPath, 'user-data-dir': userdataDir }); } } @@ -62,7 +62,7 @@ export class NodeTestBackupFileService extends BackupFileService { discardedBackups: URI[]; constructor(workspaceBackupPath: string) { - const environmentService = new TestBackupEnvironmentService(workspaceBackupPath); + const environmentService = new TestWorkbenchEnvironmentService(workspaceBackupPath); const logService = new NullLogService(); const fileService = new FileService(logService); const diskFileSystemProvider = new DiskFileSystemProvider(logService); diff --git a/src/vs/workbench/services/configuration/node/configurationCache.ts b/src/vs/workbench/services/configuration/electron-browser/configurationCache.ts similarity index 90% rename from src/vs/workbench/services/configuration/node/configurationCache.ts rename to src/vs/workbench/services/configuration/electron-browser/configurationCache.ts index 03f50c76630..779f7470177 100644 --- a/src/vs/workbench/services/configuration/node/configurationCache.ts +++ b/src/vs/workbench/services/configuration/electron-browser/configurationCache.ts @@ -5,14 +5,14 @@ import * as pfs from 'vs/base/node/pfs'; import { join } from 'vs/base/common/path'; -import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService'; +import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService'; import { IConfigurationCache, ConfigurationKey } from 'vs/workbench/services/configuration/common/configuration'; export class ConfigurationCache implements IConfigurationCache { private readonly cachedConfigurations: Map = new Map(); - constructor(private readonly environmentService: INativeEnvironmentService) { + constructor(private readonly environmentService: INativeWorkbenchEnvironmentService) { } read(key: ConfigurationKey): Promise { @@ -47,7 +47,7 @@ class CachedConfiguration { constructor( { type, key }: ConfigurationKey, - environmentService: INativeEnvironmentService + environmentService: INativeWorkbenchEnvironmentService ) { this.cachedConfigurationFolderPath = join(environmentService.userDataPath, 'CachedConfigurations', type, key); this.cachedConfigurationFilePath = join(this.cachedConfigurationFolderPath, type === 'workspaces' ? 'workspace.json' : 'configuration.json'); diff --git a/src/vs/workbench/services/configuration/test/electron-browser/configurationEditingService.test.ts b/src/vs/workbench/services/configuration/test/electron-browser/configurationEditingService.test.ts index e474f8503c7..0e651c0bee7 100644 --- a/src/vs/workbench/services/configuration/test/electron-browser/configurationEditingService.test.ts +++ b/src/vs/workbench/services/configuration/test/electron-browser/configurationEditingService.test.ts @@ -13,7 +13,7 @@ import { Registry } from 'vs/platform/registry/common/platform'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; import { workbenchInstantiationService } from 'vs/workbench/test/browser/workbenchTestServices'; -import { TestWindowConfiguration, TestTextFileService } from 'vs/workbench/test/electron-browser/workbenchTestServices'; +import { TestWorkbenchConfiguration, TestTextFileService } from 'vs/workbench/test/electron-browser/workbenchTestServices'; import * as uuid from 'vs/base/common/uuid'; import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from 'vs/platform/configuration/common/configurationRegistry'; import { WorkspaceService } from 'vs/workbench/services/configuration/browser/configurationService'; @@ -37,15 +37,15 @@ import { NullLogService } from 'vs/platform/log/common/log'; import { Schemas } from 'vs/base/common/network'; import { DiskFileSystemProvider } from 'vs/platform/files/node/diskFileSystemProvider'; import { IFileService } from 'vs/platform/files/common/files'; -import { ConfigurationCache } from 'vs/workbench/services/configuration/node/configurationCache'; +import { ConfigurationCache } from 'vs/workbench/services/configuration/electron-browser/configurationCache'; import { KeybindingsEditingService, IKeybindingEditingService } from 'vs/workbench/services/keybinding/common/keybindingEditing'; import { NativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService'; import { FileUserDataProvider } from 'vs/workbench/services/userData/common/fileUserDataProvider'; -class TestEnvironmentService extends NativeWorkbenchEnvironmentService { +class TestWorkbenchEnvironmentService extends NativeWorkbenchEnvironmentService { constructor(private _appSettingsHome: URI) { - super(TestWindowConfiguration, TestWindowConfiguration.execPath); + super(TestWorkbenchConfiguration); } get appSettingsHome() { return this._appSettingsHome; } @@ -104,7 +104,7 @@ suite('ConfigurationEditingService', () => { clearServices(); instantiationService = workbenchInstantiationService(); - const environmentService = new TestEnvironmentService(URI.file(workspaceDir)); + const environmentService = new TestWorkbenchEnvironmentService(URI.file(workspaceDir)); instantiationService.stub(IEnvironmentService, environmentService); const remoteAgentService = instantiationService.createInstance(RemoteAgentService); const fileService = new FileService(new NullLogService()); diff --git a/src/vs/workbench/services/configuration/test/electron-browser/configurationService.test.ts b/src/vs/workbench/services/configuration/test/electron-browser/configurationService.test.ts index 6d2f43ace73..290cd1de055 100644 --- a/src/vs/workbench/services/configuration/test/electron-browser/configurationService.test.ts +++ b/src/vs/workbench/services/configuration/test/electron-browser/configurationService.test.ts @@ -21,7 +21,7 @@ import { IFileService } from 'vs/platform/files/common/files'; import { IWorkspaceContextService, WorkbenchState, IWorkspaceFoldersChangeEvent } from 'vs/platform/workspace/common/workspace'; import { ConfigurationTarget, IConfigurationService, IConfigurationChangeEvent } from 'vs/platform/configuration/common/configuration'; import { workbenchInstantiationService, RemoteFileSystemProvider } from 'vs/workbench/test/browser/workbenchTestServices'; -import { TestWindowConfiguration, TestTextFileService } from 'vs/workbench/test/electron-browser/workbenchTestServices'; +import { TestWorkbenchConfiguration, TestTextFileService } from 'vs/workbench/test/electron-browser/workbenchTestServices'; import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock'; import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; import { ITextModelService } from 'vs/editor/common/services/resolverService'; @@ -38,7 +38,7 @@ import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteA import { FileService } from 'vs/platform/files/common/fileService'; import { NullLogService } from 'vs/platform/log/common/log'; import { DiskFileSystemProvider } from 'vs/platform/files/node/diskFileSystemProvider'; -import { ConfigurationCache } from 'vs/workbench/services/configuration/node/configurationCache'; +import { ConfigurationCache } from 'vs/workbench/services/configuration/electron-browser/configurationCache'; import { ConfigurationCache as BrowserConfigurationCache } from 'vs/workbench/services/configuration/browser/configurationCache'; import { IRemoteAgentEnvironment } from 'vs/platform/remote/common/remoteAgentEnvironment'; import { IConfigurationCache } from 'vs/workbench/services/configuration/common/configuration'; @@ -53,10 +53,10 @@ import { DisposableStore } from 'vs/base/common/lifecycle'; import product from 'vs/platform/product/common/product'; import { BrowserWorkbenchEnvironmentService } from 'vs/workbench/services/environment/browser/environmentService'; -class TestEnvironmentService extends NativeWorkbenchEnvironmentService { +class TestWorkbenchEnvironmentService extends NativeWorkbenchEnvironmentService { constructor(private _appSettingsHome: URI) { - super(TestWindowConfiguration, TestWindowConfiguration.execPath); + super(TestWorkbenchConfiguration); } get appSettingsHome() { return this._appSettingsHome; } @@ -109,7 +109,7 @@ suite('WorkspaceContextService - Folder', () => { .then(({ parentDir, folderDir }) => { parentResource = parentDir; workspaceResource = folderDir; - const environmentService = new TestEnvironmentService(URI.file(parentDir)); + const environmentService = new TestWorkbenchEnvironmentService(URI.file(parentDir)); const fileService = new FileService(new NullLogService()); const diskFileSystemProvider = new DiskFileSystemProvider(new NullLogService()); fileService.registerProvider(Schemas.file, diskFileSystemProvider); @@ -173,7 +173,7 @@ suite('WorkspaceContextService - Workspace', () => { parentResource = parentDir; instantiationService = workbenchInstantiationService(); - const environmentService = new TestEnvironmentService(URI.file(parentDir)); + const environmentService = new TestWorkbenchEnvironmentService(URI.file(parentDir)); const remoteAgentService = instantiationService.createInstance(RemoteAgentService); instantiationService.stub(IRemoteAgentService, remoteAgentService); const fileService = new FileService(new NullLogService()); @@ -233,7 +233,7 @@ suite('WorkspaceContextService - Workspace Editing', () => { parentResource = parentDir; instantiationService = workbenchInstantiationService(); - const environmentService = new TestEnvironmentService(URI.file(parentDir)); + const environmentService = new TestWorkbenchEnvironmentService(URI.file(parentDir)); const remoteAgentService = instantiationService.createInstance(RemoteAgentService); instantiationService.stub(IRemoteAgentService, remoteAgentService); const fileService = new FileService(new NullLogService()); @@ -494,7 +494,7 @@ suite('WorkspaceService - Initialization', () => { globalSettingsFile = path.join(parentDir, 'settings.json'); const instantiationService = workbenchInstantiationService(); - const environmentService = new TestEnvironmentService(URI.file(parentDir)); + const environmentService = new TestWorkbenchEnvironmentService(URI.file(parentDir)); const remoteAgentService = instantiationService.createInstance(RemoteAgentService); instantiationService.stub(IRemoteAgentService, remoteAgentService); const fileService = new FileService(new NullLogService()); @@ -771,7 +771,7 @@ suite('WorkspaceConfigurationService - Folder', () => { globalTasksFile = path.join(parentDir, 'tasks.json'); const instantiationService = workbenchInstantiationService(); - const environmentService = new TestEnvironmentService(URI.file(parentDir)); + const environmentService = new TestWorkbenchEnvironmentService(URI.file(parentDir)); const remoteAgentService = instantiationService.createInstance(RemoteAgentService); instantiationService.stub(IRemoteAgentService, remoteAgentService); fileService = new FileService(new NullLogService()); @@ -1280,7 +1280,7 @@ suite('WorkspaceConfigurationService-Multiroot', () => { globalSettingsFile = path.join(parentDir, 'settings.json'); const instantiationService = workbenchInstantiationService(); - const environmentService = new TestEnvironmentService(URI.file(parentDir)); + const environmentService = new TestWorkbenchEnvironmentService(URI.file(parentDir)); const remoteAgentService = instantiationService.createInstance(RemoteAgentService); instantiationService.stub(IRemoteAgentService, remoteAgentService); const fileService = new FileService(new NullLogService()); @@ -1883,7 +1883,7 @@ suite('WorkspaceConfigurationService - Remote Folder', () => { remoteSettingsResource = URI.file(remoteSettingsFile).with({ scheme: Schemas.vscodeRemote, authority: remoteAuthority }); instantiationService = workbenchInstantiationService(); - const environmentService = new TestEnvironmentService(URI.file(parentDir)); + const environmentService = new TestWorkbenchEnvironmentService(URI.file(parentDir)); const remoteEnvironmentPromise = new Promise>(c => resolveRemoteEnvironment = () => c({ settingsPath: remoteSettingsResource })); const remoteAgentService = instantiationService.stub(IRemoteAgentService, >{ getEnvironment: () => remoteEnvironmentPromise }); const fileService = new FileService(new NullLogService()); diff --git a/src/vs/workbench/services/configurationResolver/electron-browser/configurationResolverService.ts b/src/vs/workbench/services/configurationResolver/electron-sandbox/configurationResolverService.ts similarity index 94% rename from src/vs/workbench/services/configurationResolver/electron-browser/configurationResolverService.ts rename to src/vs/workbench/services/configurationResolver/electron-sandbox/configurationResolverService.ts index be61dbdff44..3d48987346a 100644 --- a/src/vs/workbench/services/configurationResolver/electron-browser/configurationResolverService.ts +++ b/src/vs/workbench/services/configurationResolver/electron-sandbox/configurationResolverService.ts @@ -4,6 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; +import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { ICommandService } from 'vs/platform/commands/common/commands'; import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; @@ -13,7 +14,7 @@ import { IConfigurationResolverService } from 'vs/workbench/services/configurati import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; import { IProcessEnvironment } from 'vs/base/common/platform'; import { BaseConfigurationResolverService } from 'vs/workbench/services/configurationResolver/browser/configurationResolverService'; -import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService'; +import { process } from 'vs/base/parts/sandbox/electron-sandbox/globals'; export class ConfigurationResolverService extends BaseConfigurationResolverService { diff --git a/src/vs/workbench/services/configurationResolver/test/electron-browser/configurationResolverService.test.ts b/src/vs/workbench/services/configurationResolver/test/electron-browser/configurationResolverService.test.ts index eeea87956ad..596eae837df 100644 --- a/src/vs/workbench/services/configurationResolver/test/electron-browser/configurationResolverService.test.ts +++ b/src/vs/workbench/services/configurationResolver/test/electron-browser/configurationResolverService.test.ts @@ -13,7 +13,7 @@ import { IConfigurationResolverService } from 'vs/workbench/services/configurati import { BaseConfigurationResolverService } from 'vs/workbench/services/configurationResolver/browser/configurationResolverService'; import { Workspace, IWorkspaceFolder } from 'vs/platform/workspace/common/workspace'; import { TestEditorService } from 'vs/workbench/test/browser/workbenchTestServices'; -import { TestWindowConfiguration } from 'vs/workbench/test/electron-browser/workbenchTestServices'; +import { TestWorkbenchConfiguration } from 'vs/workbench/test/electron-browser/workbenchTestServices'; import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService'; import { Disposable } from 'vs/base/common/lifecycle'; import { IQuickInputService, IQuickPickItem, QuickPickInput, IPickOptions, Omit, IInputOptions, IQuickInputButton, IQuickPick, IInputBox, IQuickNavigateConfiguration } from 'vs/platform/quickinput/common/quickInput'; @@ -691,6 +691,6 @@ class MockInputsConfigurationService extends TestConfigurationService { class MockWorkbenchEnvironmentService extends NativeWorkbenchEnvironmentService { constructor(public userEnv: platform.IProcessEnvironment) { - super({ ...TestWindowConfiguration, userEnv }, TestWindowConfiguration.execPath); + super({ ...TestWorkbenchConfiguration, userEnv }); } } diff --git a/src/vs/workbench/services/dialogs/electron-browser/dialogService.ts b/src/vs/workbench/services/dialogs/electron-sandbox/dialogService.ts similarity index 93% rename from src/vs/workbench/services/dialogs/electron-browser/dialogService.ts rename to src/vs/workbench/services/dialogs/electron-sandbox/dialogService.ts index 1bb0e9959c2..27556f15a6d 100644 --- a/src/vs/workbench/services/dialogs/electron-browser/dialogService.ts +++ b/src/vs/workbench/services/dialogs/electron-sandbox/dialogService.ts @@ -4,7 +4,6 @@ *--------------------------------------------------------------------------------------------*/ import * as nls from 'vs/nls'; -import * as os from 'os'; import Severity from 'vs/base/common/severity'; import { isLinux, isWindows } from 'vs/base/common/platform'; import { mnemonicButtonLabel } from 'vs/base/common/labels'; @@ -12,8 +11,6 @@ import { IDialogService, IConfirmation, IConfirmationResult, IDialogOptions, ISh import { DialogService as HTMLDialogService } from 'vs/workbench/services/dialogs/browser/dialogService'; import { ILogService } from 'vs/platform/log/common/log'; import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; -import { ISharedProcessService } from 'vs/platform/ipc/electron-browser/sharedProcessService'; -import { DialogChannel } from 'vs/platform/dialogs/electron-browser/dialogIpc'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { ILayoutService } from 'vs/platform/layout/browser/layoutService'; import { IThemeService } from 'vs/platform/theme/common/themeService'; @@ -23,6 +20,7 @@ import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService import { IElectronService } from 'vs/platform/electron/electron-sandbox/electron'; import { MessageBoxOptions } from 'vs/base/parts/sandbox/common/electronTypes'; import { fromNow } from 'vs/base/common/date'; +import { process } from 'vs/base/parts/sandbox/electron-sandbox/globals'; interface IMassagedMessageBoxOptions { @@ -51,14 +49,13 @@ export class DialogService implements IDialogService { @ILogService logService: ILogService, @ILayoutService layoutService: ILayoutService, @IThemeService themeService: IThemeService, - @ISharedProcessService sharedProcessService: ISharedProcessService, @IKeybindingService keybindingService: IKeybindingService, @IProductService productService: IProductService, @IClipboardService clipboardService: IClipboardService, @IElectronService electronService: IElectronService ) { this.customImpl = new HTMLDialogService(logService, layoutService, themeService, keybindingService, productService, clipboardService); - this.nativeImpl = new NativeDialogService(logService, sharedProcessService, electronService, productService, clipboardService); + this.nativeImpl = new NativeDialogService(logService, electronService, productService, clipboardService); } private get useCustomDialog(): boolean { @@ -92,12 +89,10 @@ class NativeDialogService implements IDialogService { constructor( @ILogService private readonly logService: ILogService, - @ISharedProcessService sharedProcessService: ISharedProcessService, @IElectronService private readonly electronService: IElectronService, @IProductService private readonly productService: IProductService, @IClipboardService private readonly clipboardService: IClipboardService ) { - sharedProcessService.registerChannel('dialog', new DialogChannel(this)); } async confirm(confirmation: IConfirmation): Promise { @@ -217,6 +212,7 @@ class NativeDialogService implements IDialogService { } const isSnap = process.platform === 'linux' && process.env.SNAP && process.env.SNAP_REVISION; + const os = await this.electronService.getOS(); const detailString = (useAgo: boolean): string => { return nls.localize('aboutDetail', @@ -228,7 +224,7 @@ class NativeDialogService implements IDialogService { process.versions['chrome'], process.versions['node'], process.versions['v8'], - `${os.type()} ${os.arch()} ${os.release()}${isSnap ? ' snap' : ''}` + `${os.type} ${os.arch} ${os.release}${isSnap ? ' snap' : ''}` ); }; diff --git a/src/vs/workbench/services/environment/browser/environmentService.ts b/src/vs/workbench/services/environment/browser/environmentService.ts index 819607be0c1..e93d8fefadc 100644 --- a/src/vs/workbench/services/environment/browser/environmentService.ts +++ b/src/vs/workbench/services/environment/browser/environmentService.ts @@ -9,17 +9,17 @@ import { URI } from 'vs/base/common/uri'; import { generateUuid } from 'vs/base/common/uuid'; import { BACKUPS, IExtensionHostDebugParams } from 'vs/platform/environment/common/environment'; import { IPath } from 'vs/platform/windows/common/windows'; -import { IWorkbenchEnvironmentService, IEnvironmentConfiguration } from 'vs/workbench/services/environment/common/environmentService'; -import { IWorkbenchConstructionOptions } from 'vs/workbench/workbench.web.api'; +import { IWorkbenchEnvironmentService, IWorkbenchConfiguration } from 'vs/workbench/services/environment/common/environmentService'; +import { IWorkbenchConstructionOptions as IWorkbenchOptions } from 'vs/workbench/workbench.web.api'; import product from 'vs/platform/product/common/product'; import { memoize } from 'vs/base/common/decorators'; import { onUnexpectedError } from 'vs/base/common/errors'; import { parseLineAndColumnAware } from 'vs/base/common/extpath'; -export class BrowserEnvironmentConfiguration implements IEnvironmentConfiguration { +class BrowserWorkbenchConfiguration implements IWorkbenchConfiguration { constructor( - private readonly options: IBrowserWorkbenchEnvironmentConstructionOptions, + private readonly options: IBrowserWorkbenchOptions, private readonly payload: Map | undefined, private readonly backupHome: URI ) { } @@ -79,7 +79,7 @@ export class BrowserEnvironmentConfiguration implements IEnvironmentConfiguratio } } -interface IBrowserWorkbenchEnvironmentConstructionOptions extends IWorkbenchConstructionOptions { +interface IBrowserWorkbenchOptions extends IWorkbenchOptions { workspaceId: string; logsPath: URI; } @@ -96,10 +96,10 @@ export class BrowserWorkbenchEnvironmentService implements IWorkbenchEnvironment declare readonly _serviceBrand: undefined; - private _configuration: IEnvironmentConfiguration | undefined = undefined; - get configuration(): IEnvironmentConfiguration { + private _configuration: IWorkbenchConfiguration | undefined = undefined; + get configuration(): IWorkbenchConfiguration { if (!this._configuration) { - this._configuration = new BrowserEnvironmentConfiguration(this.options, this.payload, this.backupHome); + this._configuration = new BrowserWorkbenchConfiguration(this.options, this.payload, this.backupHome); } return this._configuration; @@ -237,7 +237,7 @@ export class BrowserWorkbenchEnvironmentService implements IWorkbenchEnvironment private payload: Map | undefined; - constructor(readonly options: IBrowserWorkbenchEnvironmentConstructionOptions) { + constructor(readonly options: IBrowserWorkbenchOptions) { if (options.workspaceProvider && Array.isArray(options.workspaceProvider.payload)) { try { this.payload = new Map(options.workspaceProvider.payload); diff --git a/src/vs/workbench/services/environment/common/environmentService.ts b/src/vs/workbench/services/environment/common/environmentService.ts index 7d9a374ff8a..159b5c5aeef 100644 --- a/src/vs/workbench/services/environment/common/environmentService.ts +++ b/src/vs/workbench/services/environment/common/environmentService.ts @@ -6,12 +6,12 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; import { IWindowConfiguration } from 'vs/platform/windows/common/windows'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; -import { IWorkbenchConstructionOptions } from 'vs/workbench/workbench.web.api'; +import type { IWorkbenchConstructionOptions as IWorkbenchOptions } from 'vs/workbench/workbench.web.api'; import { URI } from 'vs/base/common/uri'; export const IWorkbenchEnvironmentService = createDecorator('environmentService'); -export interface IEnvironmentConfiguration extends IWindowConfiguration { +export interface IWorkbenchConfiguration extends IWindowConfiguration { backupWorkspaceResource?: URI; } @@ -19,12 +19,15 @@ export interface IWorkbenchEnvironmentService extends IEnvironmentService { readonly _serviceBrand: undefined; - readonly configuration: IEnvironmentConfiguration; + readonly configuration: IWorkbenchConfiguration; - readonly options?: IWorkbenchConstructionOptions; + readonly options?: IWorkbenchOptions; readonly logFile: URI; + readonly logExtensionHostCommunication?: boolean; + readonly extensionEnabledProposedApi?: string[]; + readonly webviewExternalEndpoint: string; readonly webviewResourceRoot: string; readonly webviewCspSource: string; diff --git a/src/vs/workbench/services/environment/electron-browser/environmentService.ts b/src/vs/workbench/services/environment/electron-browser/environmentService.ts index 46f084aff4c..c48430e0f9b 100644 --- a/src/vs/workbench/services/environment/electron-browser/environmentService.ts +++ b/src/vs/workbench/services/environment/electron-browser/environmentService.ts @@ -3,30 +3,15 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { EnvironmentService, INativeEnvironmentService } from 'vs/platform/environment/node/environmentService'; -import { IWorkbenchEnvironmentService, IEnvironmentConfiguration } from 'vs/workbench/services/environment/common/environmentService'; +import { EnvironmentService } from 'vs/platform/environment/node/environmentService'; +import { INativeWorkbenchConfiguration, INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService'; import { memoize } from 'vs/base/common/decorators'; import { URI } from 'vs/base/common/uri'; import { Schemas } from 'vs/base/common/network'; -import { toBackupWorkspaceResource } from 'vs/workbench/services/backup/electron-browser/backup'; -import { join } from 'vs/base/common/path'; +import { toBackupWorkspaceResource } from 'vs/workbench/services/backup/electron-sandbox/backup'; +import { dirname, join } from 'vs/base/common/path'; import product from 'vs/platform/product/common/product'; -import { INativeWindowConfiguration } from 'vs/platform/windows/node/window'; - -export interface INativeWorkbenchEnvironmentService extends IWorkbenchEnvironmentService, INativeEnvironmentService { - - readonly configuration: INativeEnvironmentConfiguration; - - readonly crashReporterDirectory?: string; - readonly crashReporterId?: string; - - readonly cliPath: string; - - readonly log?: string; - readonly extHostLogsPath: URI; -} - -export interface INativeEnvironmentConfiguration extends IEnvironmentConfiguration, INativeWindowConfiguration { } +import { isLinux, isWindows } from 'vs/base/common/platform'; export class NativeWorkbenchEnvironmentService extends EnvironmentService implements INativeWorkbenchEnvironmentService { @@ -57,12 +42,59 @@ export class NativeWorkbenchEnvironmentService extends EnvironmentService implem @memoize get skipReleaseNotes(): boolean { return !!this.args['skip-release-notes']; } + @memoize + get logExtensionHostCommunication(): boolean { return !!this.args.logExtensionHostCommunication; } + + get extensionEnabledProposedApi(): string[] | undefined { + if (Array.isArray(this.args['enable-proposed-api'])) { + return this.args['enable-proposed-api']; + } + + if ('enable-proposed-api' in this.args) { + return []; + } + + return undefined; + } + + @memoize + get cliPath(): string { return this.doGetCLIPath(); } + + readonly execPath = this.configuration.execPath; + constructor( - readonly configuration: INativeEnvironmentConfiguration, - execPath: string + readonly configuration: INativeWorkbenchConfiguration ) { - super(configuration, execPath); + super(configuration); this.configuration.backupWorkspaceResource = this.configuration.backupPath ? toBackupWorkspaceResource(this.configuration.backupPath, this) : undefined; } + + private doGetCLIPath(): string { + + // Windows + if (isWindows) { + if (this.isBuilt) { + return join(dirname(this.execPath), 'bin', `${product.applicationName}.cmd`); + } + + return join(this.appRoot, 'scripts', 'code-cli.bat'); + } + + // Linux + if (isLinux) { + if (this.isBuilt) { + return join(dirname(this.execPath), 'bin', `${product.applicationName}`); + } + + return join(this.appRoot, 'scripts', 'code-cli.sh'); + } + + // macOS + if (this.isBuilt) { + return join(this.appRoot, 'bin', 'code'); + } + + return join(this.appRoot, 'scripts', 'code-cli.sh'); + } } diff --git a/src/vs/workbench/services/environment/electron-sandbox/environmentService.ts b/src/vs/workbench/services/environment/electron-sandbox/environmentService.ts new file mode 100644 index 00000000000..bde5abaeb38 --- /dev/null +++ b/src/vs/workbench/services/environment/electron-sandbox/environmentService.ts @@ -0,0 +1,25 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import { IWorkbenchConfiguration, IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; +import { INativeWindowConfiguration } from 'vs/platform/windows/common/windows'; +import { INativeEnvironmentService } from 'vs/platform/environment/common/environment'; +import { URI } from 'vs/base/common/uri'; + +export interface INativeWorkbenchConfiguration extends IWorkbenchConfiguration, INativeWindowConfiguration { } + +export interface INativeWorkbenchEnvironmentService extends IWorkbenchEnvironmentService, INativeEnvironmentService { + + readonly configuration: INativeWorkbenchConfiguration; + + readonly crashReporterDirectory?: string; + readonly crashReporterId?: string; + + readonly execPath: string; + readonly cliPath: string; + + readonly log?: string; + readonly extHostLogsPath: URI; +} diff --git a/src/vs/workbench/services/extensionManagement/common/webExtensionsScannerService.ts b/src/vs/workbench/services/extensionManagement/common/webExtensionsScannerService.ts index 2a071bc7223..b8c68ec3fa5 100644 --- a/src/vs/workbench/services/extensionManagement/common/webExtensionsScannerService.ts +++ b/src/vs/workbench/services/extensionManagement/common/webExtensionsScannerService.ts @@ -19,7 +19,7 @@ import { CancellationToken } from 'vs/base/common/cancellation'; import { IGalleryExtension, INSTALL_ERROR_NOT_SUPPORTED } from 'vs/platform/extensionManagement/common/extensionManagement'; import { groupByExtension, areSameExtensions, getGalleryExtensionId } from 'vs/platform/extensionManagement/common/extensionManagementUtil'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; -import { IStaticExtension } from 'vs/workbench/workbench.web.api'; +import type { IStaticExtension } from 'vs/workbench/workbench.web.api'; import { Disposable } from 'vs/base/common/lifecycle'; import { Event } from 'vs/base/common/event'; import { localizeManifest } from 'vs/platform/extensionManagement/common/extensionNls'; diff --git a/src/vs/workbench/services/extensions/electron-browser/cachedExtensionScanner.ts b/src/vs/workbench/services/extensions/electron-browser/cachedExtensionScanner.ts index c8234ff6bce..13561811cd6 100644 --- a/src/vs/workbench/services/extensions/electron-browser/cachedExtensionScanner.ts +++ b/src/vs/workbench/services/extensions/electron-browser/cachedExtensionScanner.ts @@ -14,8 +14,8 @@ import * as platform from 'vs/base/common/platform'; import { originalFSPath } from 'vs/base/common/resources'; import { URI } from 'vs/base/common/uri'; import * as pfs from 'vs/base/node/pfs'; -import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; +import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService'; import { IWorkbenchExtensionEnablementService } from 'vs/workbench/services/extensionManagement/common/extensionManagement'; import { BUILTIN_MANIFEST_CACHE_FILE, MANIFEST_CACHE_FOLDER, USER_MANIFEST_CACHE_FILE, ExtensionIdentifier, IExtensionDescription } from 'vs/platform/extensions/common/extensions'; import { IProductService } from 'vs/platform/product/common/productService'; diff --git a/src/vs/workbench/services/extensions/electron-browser/extensionService.ts b/src/vs/workbench/services/extensions/electron-browser/extensionService.ts index 5a631364a8a..4e8ba098202 100644 --- a/src/vs/workbench/services/extensions/electron-browser/extensionService.ts +++ b/src/vs/workbench/services/extensions/electron-browser/extensionService.ts @@ -32,7 +32,6 @@ import { IProductService } from 'vs/platform/product/common/productService'; import { Logger } from 'vs/workbench/services/extensions/common/extensionPoints'; import { flatten } from 'vs/base/common/arrays'; import { IElectronService } from 'vs/platform/electron/electron-sandbox/electron'; -import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService'; import { IRemoteExplorerService } from 'vs/workbench/services/remote/common/remoteExplorerService'; import { Action2, registerAction2 } from 'vs/platform/actions/common/actions'; import { getRemoteName } from 'vs/platform/remote/common/remoteHosts'; @@ -61,7 +60,7 @@ export class ExtensionService extends AbstractExtensionService implements IExten constructor( @IInstantiationService instantiationService: IInstantiationService, @INotificationService notificationService: INotificationService, - @IWorkbenchEnvironmentService protected readonly _environmentService: INativeWorkbenchEnvironmentService, + @IWorkbenchEnvironmentService protected readonly _environmentService: IWorkbenchEnvironmentService, @ITelemetryService telemetryService: ITelemetryService, @IWorkbenchExtensionEnablementService extensionEnablementService: IWorkbenchExtensionEnablementService, @IFileService fileService: IFileService, diff --git a/src/vs/workbench/services/extensions/electron-browser/localProcessExtensionHost.ts b/src/vs/workbench/services/extensions/electron-browser/localProcessExtensionHost.ts index e4cf1f4ab35..eb28be32c1f 100644 --- a/src/vs/workbench/services/extensions/electron-browser/localProcessExtensionHost.ts +++ b/src/vs/workbench/services/extensions/electron-browser/localProcessExtensionHost.ts @@ -22,6 +22,7 @@ import { IMessagePassingProtocol } from 'vs/base/parts/ipc/common/ipc'; import { PersistentProtocol } from 'vs/base/parts/ipc/common/ipc.net'; import { generateRandomPipeName, NodeSocket } from 'vs/base/parts/ipc/node/ipc.net'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; +import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService'; import { ILabelService } from 'vs/platform/label/common/label'; import { ILifecycleService, WillShutdownEvent } from 'vs/platform/lifecycle/common/lifecycle'; import { ILogService } from 'vs/platform/log/common/log'; @@ -43,7 +44,6 @@ import { IHostService } from 'vs/workbench/services/host/browser/host'; import { joinPath } from 'vs/base/common/resources'; import { Registry } from 'vs/platform/registry/common/platform'; import { IOutputChannelRegistry, Extensions } from 'vs/workbench/services/output/common/output'; -import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService'; import { isUUID } from 'vs/base/common/uuid'; import { join } from 'vs/base/common/path'; diff --git a/src/vs/workbench/services/keybinding/test/electron-browser/keybindingEditing.test.ts b/src/vs/workbench/services/keybinding/test/electron-browser/keybindingEditing.test.ts index 0c947d33730..f4e8a645899 100644 --- a/src/vs/workbench/services/keybinding/test/electron-browser/keybindingEditing.test.ts +++ b/src/vs/workbench/services/keybinding/test/electron-browser/keybindingEditing.test.ts @@ -47,7 +47,7 @@ import { FileUserDataProvider } from 'vs/workbench/services/userData/common/file import { NativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService'; import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService'; import { IWorkingCopyService } from 'vs/workbench/services/workingCopy/common/workingCopyService'; -import { TestWindowConfiguration, TestTextFileService } from 'vs/workbench/test/electron-browser/workbenchTestServices'; +import { TestWorkbenchConfiguration, TestTextFileService } from 'vs/workbench/test/electron-browser/workbenchTestServices'; import { ILabelService } from 'vs/platform/label/common/label'; import { LabelService } from 'vs/workbench/services/label/common/labelService'; import { IFilesConfigurationService, FilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService'; @@ -61,10 +61,10 @@ import { IPathService } from 'vs/workbench/services/path/common/pathService'; import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity'; import { UriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentityService'; -class TestEnvironmentService extends NativeWorkbenchEnvironmentService { +class TestWorkbenchEnvironmentService extends NativeWorkbenchEnvironmentService { constructor(private _appSettingsHome: URI) { - super(TestWindowConfiguration, TestWindowConfiguration.execPath); + super(TestWorkbenchConfiguration); } get appSettingsHome() { return this._appSettingsHome; } @@ -90,7 +90,7 @@ suite('KeybindingsEditing', () => { instantiationService = new TestInstantiationService(); - const environmentService = new TestEnvironmentService(URI.file(testDir)); + const environmentService = new TestWorkbenchEnvironmentService(URI.file(testDir)); const configService = new TestConfigurationService(); configService.setUserConfiguration('files', { 'eol': '\n' }); diff --git a/src/vs/workbench/services/output/electron-browser/outputChannelModelService.ts b/src/vs/workbench/services/output/electron-browser/outputChannelModelService.ts index 17cb19f487c..be7708a7185 100644 --- a/src/vs/workbench/services/output/electron-browser/outputChannelModelService.ts +++ b/src/vs/workbench/services/output/electron-browser/outputChannelModelService.ts @@ -21,7 +21,6 @@ import { toLocalISOString } from 'vs/base/common/date'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; import { Emitter, Event } from 'vs/base/common/event'; -import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService'; import { IElectronService } from 'vs/platform/electron/electron-sandbox/electron'; class OutputChannelBackedByFile extends AbstractFileOutputChannelModel implements IOutputChannelModel { @@ -204,7 +203,7 @@ export class OutputChannelModelService extends AsbtractOutputChannelModelService constructor( @IInstantiationService instantiationService: IInstantiationService, - @IWorkbenchEnvironmentService private readonly environmentService: INativeWorkbenchEnvironmentService, + @IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService, @IFileService private readonly fileService: IFileService, @IElectronService private readonly electronService: IElectronService ) { diff --git a/src/vs/workbench/services/path/electron-browser/pathService.ts b/src/vs/workbench/services/path/electron-sandbox/pathService.ts similarity index 95% rename from src/vs/workbench/services/path/electron-browser/pathService.ts rename to src/vs/workbench/services/path/electron-sandbox/pathService.ts index 8dbe77e0b38..22b2105b70d 100644 --- a/src/vs/workbench/services/path/electron-browser/pathService.ts +++ b/src/vs/workbench/services/path/electron-sandbox/pathService.ts @@ -6,8 +6,8 @@ import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; +import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService'; import { IPathService, AbstractPathService } from 'vs/workbench/services/path/common/pathService'; -import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService'; export class NativePathService extends AbstractPathService { diff --git a/src/vs/workbench/services/search/node/searchService.ts b/src/vs/workbench/services/search/electron-browser/searchService.ts similarity index 92% rename from src/vs/workbench/services/search/node/searchService.ts rename to src/vs/workbench/services/search/electron-browser/searchService.ts index 8997acabba8..cdf3110cbf7 100644 --- a/src/vs/workbench/services/search/node/searchService.ts +++ b/src/vs/workbench/services/search/electron-browser/searchService.ts @@ -12,12 +12,14 @@ import { URI as uri } from 'vs/base/common/uri'; import { getNextTickChannel } from 'vs/base/parts/ipc/common/ipc'; import { Client, IIPCOptions } from 'vs/base/parts/ipc/node/ipc.cp'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; -import { IDebugParams, IEnvironmentService } from 'vs/platform/environment/common/environment'; -import { parseSearchPort, INativeEnvironmentService } from 'vs/platform/environment/node/environmentService'; +import { IDebugParams } from 'vs/platform/environment/common/environment'; +import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; +import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService'; +import { parseSearchPort } from 'vs/platform/environment/node/environmentService'; import { IFileService } from 'vs/platform/files/common/files'; import { ILogService } from 'vs/platform/log/common/log'; import { FileMatch, IFileMatch, IFileQuery, IProgressMessage, IRawSearchService, ISearchComplete, ISearchConfiguration, ISearchProgressItem, ISearchResultProvider, ISerializedFileMatch, ISerializedSearchComplete, ISerializedSearchProgressItem, isSerializedSearchComplete, isSerializedSearchSuccess, ITextQuery, ISearchService, isFileMatch } from 'vs/workbench/services/search/common/search'; -import { SearchChannelClient } from './searchIpc'; +import { SearchChannelClient } from 'vs/workbench/services/search/node/searchIpc'; import { SearchService } from 'vs/workbench/services/search/common/searchService'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IModelService } from 'vs/editor/common/services/modelService'; @@ -34,7 +36,7 @@ export class LocalSearchService extends SearchService { @ILogService logService: ILogService, @IExtensionService extensionService: IExtensionService, @IFileService fileService: IFileService, - @IEnvironmentService readonly environmentService: INativeEnvironmentService, + @IWorkbenchEnvironmentService readonly environmentService: INativeWorkbenchEnvironmentService, @IInstantiationService readonly instantiationService: IInstantiationService ) { super(modelService, editorService, telemetryService, logService, extensionService, fileService); diff --git a/src/vs/workbench/services/search/test/node/rawSearchService.test.ts b/src/vs/workbench/services/search/test/electron-browser/rawSearchService.test.ts similarity index 98% rename from src/vs/workbench/services/search/test/node/rawSearchService.test.ts rename to src/vs/workbench/services/search/test/electron-browser/rawSearchService.test.ts index 1626179ccab..1be58f5451d 100644 --- a/src/vs/workbench/services/search/test/node/rawSearchService.test.ts +++ b/src/vs/workbench/services/search/test/electron-browser/rawSearchService.test.ts @@ -11,13 +11,13 @@ import * as path from 'vs/base/common/path'; import { URI } from 'vs/base/common/uri'; import { IFileQuery, IFileSearchStats, IFolderQuery, IProgressMessage, IRawFileMatch, ISearchEngine, ISearchEngineStats, ISearchEngineSuccess, ISearchProgressItem, ISerializedFileMatch, ISerializedSearchComplete, ISerializedSearchProgressItem, ISerializedSearchSuccess, isFileMatch, QueryType } from 'vs/workbench/services/search/common/search'; import { IProgressCallback, SearchService as RawSearchService } from 'vs/workbench/services/search/node/rawSearchService'; -import { DiskSearch } from 'vs/workbench/services/search/node/searchService'; +import { DiskSearch } from 'vs/workbench/services/search/electron-browser/searchService'; const TEST_FOLDER_QUERIES = [ { folder: URI.file(path.normalize('/some/where')) } ]; -const TEST_FIXTURES = path.normalize(getPathFromAmdModule(require, './fixtures')); +const TEST_FIXTURES = path.normalize(getPathFromAmdModule(require, '../node/fixtures')); const MULTIROOT_QUERIES: IFolderQuery[] = [ { folder: URI.file(path.join(TEST_FIXTURES, 'examples')) }, { folder: URI.file(path.join(TEST_FIXTURES, 'more')) } diff --git a/src/vs/workbench/services/sharedProcess/electron-browser/sharedProcessService.ts b/src/vs/workbench/services/sharedProcess/electron-browser/sharedProcessService.ts index 2fb053da89a..5b41e11b697 100644 --- a/src/vs/workbench/services/sharedProcess/electron-browser/sharedProcessService.ts +++ b/src/vs/workbench/services/sharedProcess/electron-browser/sharedProcessService.ts @@ -10,7 +10,7 @@ import { IMainProcessService } from 'vs/platform/ipc/electron-sandbox/mainProces import { ISharedProcessService } from 'vs/platform/ipc/electron-browser/sharedProcessService'; import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; -import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService'; +import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService'; import { IElectronService } from 'vs/platform/electron/electron-sandbox/electron'; export class SharedProcessService implements ISharedProcessService { diff --git a/src/vs/workbench/services/telemetry/electron-browser/telemetryService.ts b/src/vs/workbench/services/telemetry/electron-browser/telemetryService.ts index 99d36e3fa46..aaac4670c7b 100644 --- a/src/vs/workbench/services/telemetry/electron-browser/telemetryService.ts +++ b/src/vs/workbench/services/telemetry/electron-browser/telemetryService.ts @@ -8,6 +8,7 @@ import { NullTelemetryService, combinedAppender, LogAppender } from 'vs/platform import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { Disposable } from 'vs/base/common/lifecycle'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; +import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService'; import { IProductService } from 'vs/platform/product/common/productService'; import { ISharedProcessService } from 'vs/platform/ipc/electron-browser/sharedProcessService'; import { TelemetryAppenderClient } from 'vs/platform/telemetry/node/telemetryIpc'; @@ -17,7 +18,6 @@ import { resolveWorkbenchCommonProperties } from 'vs/platform/telemetry/node/wor import { TelemetryService as BaseTelemetryService, ITelemetryServiceConfig } from 'vs/platform/telemetry/common/telemetryService'; import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; import { ClassifiedEvent, StrictPropertyCheck, GDPRClassification } from 'vs/platform/telemetry/common/gdprTypings'; -import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService'; export class TelemetryService extends Disposable implements ITelemetryService { diff --git a/src/vs/workbench/services/textfile/browser/textFileService.ts b/src/vs/workbench/services/textfile/browser/textFileService.ts index bf0805bb0c1..5beb1b11933 100644 --- a/src/vs/workbench/services/textfile/browser/textFileService.ts +++ b/src/vs/workbench/services/textfile/browser/textFileService.ts @@ -34,7 +34,6 @@ import { IWorkingCopyFileService } from 'vs/workbench/services/workingCopy/commo import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity'; import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; import { WORKSPACE_EXTENSION } from 'vs/platform/workspaces/common/workspaces'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { UTF8, UTF8_with_bom, UTF16be, UTF16le, encodingExists, UTF8_BOM, detectEncodingByBOMFromBuffer, toEncodeReadable, toDecodeStream, IDecodeStreamResult } from 'vs/workbench/services/textfile/common/encoding'; import { consumeStream } from 'vs/base/common/stream'; import { IModeService } from 'vs/editor/common/services/modeService'; @@ -529,7 +528,7 @@ export class EncodingOracle extends Disposable implements IResourceEncodings { constructor( @ITextResourceConfigurationService private textResourceConfigurationService: ITextResourceConfigurationService, - @IEnvironmentService private environmentService: IEnvironmentService, + @IWorkbenchEnvironmentService private environmentService: IWorkbenchEnvironmentService, @IWorkspaceContextService private contextService: IWorkspaceContextService, @IFileService private fileService: IFileService, @IUriIdentityService private readonly uriIdentityService: IUriIdentityService diff --git a/src/vs/workbench/services/textfile/electron-browser/nativeTextFileService.ts b/src/vs/workbench/services/textfile/electron-browser/nativeTextFileService.ts index 19add1a54b2..b0801d00af7 100644 --- a/src/vs/workbench/services/textfile/electron-browser/nativeTextFileService.ts +++ b/src/vs/workbench/services/textfile/electron-browser/nativeTextFileService.ts @@ -22,13 +22,13 @@ import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IModelService } from 'vs/editor/common/services/modelService'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; +import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService'; import { IDialogService, IFileDialogService } from 'vs/platform/dialogs/common/dialogs'; import { IFilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService'; import { ITextModelService } from 'vs/editor/common/services/resolverService'; import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService'; import { IPathService } from 'vs/workbench/services/path/common/pathService'; import { IWorkingCopyFileService } from 'vs/workbench/services/workingCopy/common/workingCopyFileService'; -import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService'; import { ILogService } from 'vs/platform/log/common/log'; import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity'; import { IModeService } from 'vs/editor/common/services/modeService'; diff --git a/src/vs/workbench/services/timer/electron-browser/timerService.ts b/src/vs/workbench/services/timer/electron-browser/timerService.ts index c786aeae1c7..9803c10996d 100644 --- a/src/vs/workbench/services/timer/electron-browser/timerService.ts +++ b/src/vs/workbench/services/timer/electron-browser/timerService.ts @@ -7,6 +7,7 @@ import { virtualMachineHint } from 'vs/base/node/id'; import * as os from 'os'; import { IElectronService } from 'vs/platform/electron/electron-sandbox/electron'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; +import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService'; import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions'; import { IUpdateService } from 'vs/platform/update/common/update'; @@ -15,7 +16,6 @@ import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet'; import { IPanelService } from 'vs/workbench/services/panel/common/panelService'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility'; -import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService'; import { IStartupMetrics, AbstractTimerService, Writeable } from 'vs/workbench/services/timer/browser/timerService'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; diff --git a/src/vs/workbench/services/workspaces/electron-browser/workspaceEditingService.ts b/src/vs/workbench/services/workspaces/electron-sandbox/workspaceEditingService.ts similarity index 98% rename from src/vs/workbench/services/workspaces/electron-browser/workspaceEditingService.ts rename to src/vs/workbench/services/workspaces/electron-sandbox/workspaceEditingService.ts index 68e1931a4ac..61b87ae61ef 100644 --- a/src/vs/workbench/services/workspaces/electron-browser/workspaceEditingService.ts +++ b/src/vs/workbench/services/workspaces/electron-sandbox/workspaceEditingService.ts @@ -13,12 +13,13 @@ import { WorkspaceService } from 'vs/workbench/services/configuration/browser/co import { IStorageService } from 'vs/platform/storage/common/storage'; import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions'; import { IBackupFileService } from 'vs/workbench/services/backup/common/backup'; -import { toBackupWorkspaceResource } from 'vs/workbench/services/backup/electron-browser/backup'; +import { toBackupWorkspaceResource } from 'vs/workbench/services/backup/electron-sandbox/backup'; import { ICommandService } from 'vs/platform/commands/common/commands'; import { basename } from 'vs/base/common/resources'; import { INotificationService, Severity } from 'vs/platform/notification/common/notification'; import { IFileService } from 'vs/platform/files/common/files'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; +import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService'; import { ILifecycleService, ShutdownReason } from 'vs/platform/lifecycle/common/lifecycle'; import { IFileDialogService, IDialogService } from 'vs/platform/dialogs/common/dialogs'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; @@ -31,7 +32,6 @@ import { IElectronService } from 'vs/platform/electron/electron-sandbox/electron import { isMacintosh } from 'vs/base/common/platform'; import { mnemonicButtonLabel } from 'vs/base/common/labels'; import { BackupFileService } from 'vs/workbench/services/backup/common/backupFileService'; -import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService'; import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity'; export class NativeWorkspaceEditingService extends AbstractWorkspaceEditingService { diff --git a/src/vs/workbench/test/electron-browser/textsearch.perf.integrationTest.ts b/src/vs/workbench/test/electron-browser/textsearch.perf.integrationTest.ts index ed378fb9496..8a199b024d7 100644 --- a/src/vs/workbench/test/electron-browser/textsearch.perf.integrationTest.ts +++ b/src/vs/workbench/test/electron-browser/textsearch.perf.integrationTest.ts @@ -15,7 +15,7 @@ import { IUntitledTextEditorService, UntitledTextEditorService } from 'vs/workbe import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import * as minimist from 'minimist'; import * as path from 'vs/base/common/path'; -import { LocalSearchService } from 'vs/workbench/services/search/node/searchService'; +import { LocalSearchService } from 'vs/workbench/services/search/electron-browser/searchService'; import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; import { TestEditorService, TestEditorGroupsService } from 'vs/workbench/test/browser/workbenchTestServices'; import { TestEnvironmentService } from 'vs/workbench/test/electron-browser/workbenchTestServices'; diff --git a/src/vs/workbench/test/electron-browser/workbenchTestServices.ts b/src/vs/workbench/test/electron-browser/workbenchTestServices.ts index e2211240cd0..8eb9b107477 100644 --- a/src/vs/workbench/test/electron-browser/workbenchTestServices.ts +++ b/src/vs/workbench/test/electron-browser/workbenchTestServices.ts @@ -6,7 +6,7 @@ import { workbenchInstantiationService as browserWorkbenchInstantiationService, ITestInstantiationService, TestLifecycleService, TestFilesConfigurationService, TestFileService, TestFileDialogService, TestPathService, TestEncodingOracle } from 'vs/workbench/test/browser/workbenchTestServices'; import { Event } from 'vs/base/common/event'; import { ISharedProcessService } from 'vs/platform/ipc/electron-browser/sharedProcessService'; -import { NativeWorkbenchEnvironmentService, INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService'; +import { NativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService'; import { NativeTextFileService, } from 'vs/workbench/services/textfile/electron-browser/nativeTextFileService'; import { IElectronService } from 'vs/platform/electron/electron-sandbox/electron'; import { FileOperationError, IFileService } from 'vs/platform/files/common/files'; @@ -15,6 +15,7 @@ import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IModelService } from 'vs/editor/common/services/modelService'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; +import { INativeWorkbenchConfiguration, INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService'; import { IDialogService, IFileDialogService, INativeOpenDialogOptions } from 'vs/platform/dialogs/common/dialogs'; import { ITextResourceConfigurationService } from 'vs/editor/common/services/textResourceConfigurationService'; import { IProductService } from 'vs/platform/product/common/productService'; @@ -35,13 +36,13 @@ import { IBackupFileService } from 'vs/workbench/services/backup/common/backup'; import { NodeTestBackupFileService } from 'vs/workbench/services/backup/test/electron-browser/backupFileService.test'; import { IWorkingCopyService } from 'vs/workbench/services/workingCopy/common/workingCopyService'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; -import { INativeWindowConfiguration } from 'vs/platform/windows/node/window'; import { TestContextService } from 'vs/workbench/test/common/workbenchTestServices'; import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity'; import { MouseInputEvent } from 'vs/base/parts/sandbox/common/electronTypes'; import { IModeService } from 'vs/editor/common/services/modeService'; +import { IOSProperties } from 'vs/platform/electron/common/electron'; -export const TestWindowConfiguration: INativeWindowConfiguration = { +export const TestWorkbenchConfiguration: INativeWorkbenchConfiguration = { windowId: 0, machineId: 'testMachineId', sessionId: 'testSessionId', @@ -55,7 +56,7 @@ export const TestWindowConfiguration: INativeWindowConfiguration = { ...parseArgs(process.argv, OPTIONS) }; -export const TestEnvironmentService = new NativeWorkbenchEnvironmentService(TestWindowConfiguration, process.execPath); +export const TestEnvironmentService = new NativeWorkbenchEnvironmentService(TestWorkbenchConfiguration); export class TestTextFileService extends NativeTextFileService { private resolveTextContentError!: FileOperationError | null; @@ -195,6 +196,7 @@ export class TestElectronService implements IElectronService { async setRepresentedFilename(path: string): Promise { } async isAdmin(): Promise { return false; } async getTotalMem(): Promise { return 0; } + async getOS(): Promise { return Object.create(null); } async killProcess(): Promise { } async setDocumentEdited(edited: boolean): Promise { } async openExternal(url: string): Promise { return false; } diff --git a/src/vs/workbench/workbench.desktop.main.ts b/src/vs/workbench/workbench.desktop.main.ts index c9eec9b1ae1..b8786e5ef79 100644 --- a/src/vs/workbench/workbench.desktop.main.ts +++ b/src/vs/workbench/workbench.desktop.main.ts @@ -36,21 +36,17 @@ import 'vs/workbench/electron-browser/desktop.main'; import 'vs/workbench/services/integrity/node/integrityService'; import 'vs/workbench/services/textMate/electron-browser/textMateService'; -import 'vs/workbench/services/search/node/searchService'; +import 'vs/workbench/services/search/electron-browser/searchService'; import 'vs/workbench/services/output/electron-browser/outputChannelModelService'; import 'vs/workbench/services/textfile/electron-browser/nativeTextFileService'; -import 'vs/workbench/services/dialogs/electron-browser/dialogService'; import 'vs/workbench/services/keybinding/electron-browser/nativeKeymapService'; import 'vs/workbench/services/extensions/electron-browser/extensionService'; import 'vs/workbench/services/extensionManagement/electron-browser/extensionManagementServerService'; import 'vs/workbench/services/extensionManagement/electron-browser/extensionTipsService'; import 'vs/workbench/services/remote/electron-browser/remoteAgentServiceImpl'; import 'vs/workbench/services/telemetry/electron-browser/telemetryService'; -import 'vs/workbench/services/configurationResolver/electron-browser/configurationResolverService'; import 'vs/workbench/services/extensionManagement/node/extensionManagementService'; -import 'vs/workbench/services/accessibility/electron-browser/accessibilityService'; import 'vs/workbench/services/backup/node/backupFileService'; -import 'vs/workbench/services/workspaces/electron-browser/workspaceEditingService'; import 'vs/workbench/services/userDataSync/electron-browser/userDataSyncMachinesService'; import 'vs/workbench/services/userDataSync/electron-browser/userDataSyncService'; import 'vs/workbench/services/userDataSync/electron-browser/userDataSyncAccountService'; @@ -58,7 +54,6 @@ import 'vs/workbench/services/userDataSync/electron-browser/userDataSyncStoreMan import 'vs/workbench/services/userDataSync/electron-browser/userDataAutoSyncService'; import 'vs/workbench/services/sharedProcess/electron-browser/sharedProcessService'; import 'vs/workbench/services/localizations/electron-browser/localizationsService'; -import 'vs/workbench/services/path/electron-browser/pathService'; import 'vs/workbench/services/experiment/electron-browser/experimentService'; import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; @@ -80,9 +75,6 @@ registerSingleton(IUserDataInitializationService, UserDataInitializationService) //#region --- workbench contributions -// Logs -import 'vs/workbench/contrib/logs/electron-browser/logs.contribution'; - // Tags import 'vs/workbench/contrib/tags/electron-browser/workspaceTagsService'; import 'vs/workbench/contrib/tags/electron-browser/tags.contribution'; diff --git a/src/vs/workbench/workbench.sandbox.main.ts b/src/vs/workbench/workbench.sandbox.main.ts index 038fcb6f660..d0ec888aac6 100644 --- a/src/vs/workbench/workbench.sandbox.main.ts +++ b/src/vs/workbench/workbench.sandbox.main.ts @@ -23,6 +23,7 @@ import 'vs/workbench/services/dialogs/electron-sandbox/fileDialogService'; import 'vs/workbench/services/workspaces/electron-sandbox/workspacesService'; import 'vs/workbench/services/userDataSync/electron-sandbox/storageKeysSyncRegistryService'; import 'vs/workbench/services/menubar/electron-sandbox/menubarService'; +import 'vs/workbench/services/dialogs/electron-sandbox/dialogService'; import 'vs/workbench/services/issue/electron-sandbox/issueService'; import 'vs/workbench/services/update/electron-sandbox/updateService'; import 'vs/workbench/services/url/electron-sandbox/urlService'; @@ -33,12 +34,19 @@ import 'vs/workbench/services/request/electron-sandbox/requestService'; import 'vs/workbench/services/extensionResourceLoader/electron-sandbox/extensionResourceLoaderService'; import 'vs/workbench/services/clipboard/electron-sandbox/clipboardService'; import 'vs/workbench/services/contextmenu/electron-sandbox/contextmenuService'; +import 'vs/workbench/services/workspaces/electron-sandbox/workspaceEditingService'; +import 'vs/workbench/services/configurationResolver/electron-sandbox/configurationResolverService'; +import 'vs/workbench/services/accessibility/electron-sandbox/accessibilityService'; +import 'vs/workbench/services/path/electron-sandbox/pathService'; //#endregion //#region --- workbench contributions +// Logs +import 'vs/workbench/contrib/logs/electron-sandbox/logs.contribution'; + // Localizations import 'vs/workbench/contrib/localizations/browser/localizations.contribution';