Initial VS Code 1.19 source merge (#571)

* Initial 1.19 xcopy

* Fix yarn build

* Fix numerous build breaks

* Next batch of build break fixes

* More build break fixes

* Runtime breaks

* Additional post merge fixes

* Fix windows setup file

* Fix test failures.

* Update license header blocks to refer to source eula
This commit is contained in:
Karl Burtram
2018-01-28 23:37:17 -08:00
committed by GitHub
parent 9a1ac20710
commit 251ae01c3e
8009 changed files with 93378 additions and 35634 deletions

View File

@@ -26,7 +26,7 @@ import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiati
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { ILogService } from 'vs/platform/log/common/log';
import { IStorageService } from 'vs/platform/storage/node/storage';
import { IStateService } from 'vs/platform/state/common/state';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IURLService } from 'vs/platform/url/common/url';
@@ -35,10 +35,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils';
import { ITelemetryAppenderChannel, TelemetryAppenderClient } from 'vs/platform/telemetry/common/telemetryIpc';
import { TelemetryService, ITelemetryServiceConfig } from 'vs/platform/telemetry/common/telemetryService';
import { ICredentialsService } from 'vs/platform/credentials/common/credentials';
import { CredentialsService } from 'vs/platform/credentials/node/credentialsService';
import { CredentialsChannel } from 'vs/platform/credentials/node/credentialsIpc';
import { resolveCommonProperties, machineIdStorageKey, machineIdIpcChannel } from 'vs/platform/telemetry/node/commonProperties';
import { resolveCommonProperties } from 'vs/platform/telemetry/node/commonProperties';
import { getDelayedChannel } from 'vs/base/parts/ipc/common/ipc';
import product from 'vs/platform/node/product';
import pkg from 'vs/platform/node/package';
@@ -56,10 +53,12 @@ import { WorkspacesChannel } from 'vs/platform/workspaces/common/workspacesIpc';
import { IWorkspacesMainService } from 'vs/platform/workspaces/common/workspaces';
import { dirname, join } from 'path';
import { touch } from 'vs/base/node/pfs';
import { getMachineId } from 'vs/base/node/id';
export class CodeApplication {
private static APP_ICON_REFRESH_KEY = 'macOSAppIconRefresh3';
private static readonly APP_ICON_REFRESH_KEY = 'macOSAppIconRefresh3';
private static readonly MACHINE_ID_KEY = 'telemetry.machineId';
private toDispose: IDisposable[];
private windowsMainService: IWindowsMainService;
@@ -76,9 +75,9 @@ export class CodeApplication {
@ILogService private logService: ILogService,
@IEnvironmentService private environmentService: IEnvironmentService,
@ILifecycleService private lifecycleService: ILifecycleService,
@IConfigurationService private configurationService: ConfigurationService,
@IStorageService private storageService: IStorageService,
@IHistoryMainService private historyService: IHistoryMainService
@IConfigurationService configurationService: ConfigurationService,
@IStateService private stateService: IStateService,
@IHistoryMainService private historyMainService: IHistoryMainService
) {
this.toDispose = [mainIpcServer, configurationService];
@@ -110,7 +109,7 @@ export class CodeApplication {
});
app.on('will-quit', () => {
this.logService.log('App#will-quit: disposing resources');
this.logService.trace('App#will-quit: disposing resources');
this.dispose();
});
@@ -122,7 +121,7 @@ export class CodeApplication {
});
app.on('activate', (event: Event, hasVisibleWindows: boolean) => {
this.logService.log('App#activate');
this.logService.trace('App#activate');
// Mac only event: open new window when we get activated
if (!hasVisibleWindows && this.windowsMainService) {
@@ -133,7 +132,7 @@ export class CodeApplication {
const isValidWebviewSource = (source: string) =>
!source || (URI.parse(source.toLowerCase()).toString() as any).startsWith(URI.file(this.environmentService.appRoot.toLowerCase()).toString());
app.on('web-contents-created', (event, contents) => {
app.on('web-contents-created', (_event: any, contents) => {
contents.on('will-attach-webview', (event: Electron.Event, webPreferences, params) => {
delete webPreferences.preload;
webPreferences.nodeIntegration = false;
@@ -157,7 +156,7 @@ export class CodeApplication {
let macOpenFiles: string[] = [];
let runningTimeout: number = null;
app.on('open-file', (event: Event, path: string) => {
this.logService.log('App#open-file: ', path);
this.logService.trace('App#open-file: ', path);
event.preventDefault();
// Keep in array because more might come!
@@ -188,19 +187,14 @@ export class CodeApplication {
this.windowsMainService.openNewWindow(OpenContext.DESKTOP); //macOS native tab "+" button
});
ipc.on('vscode:exit', (event, code: number) => {
this.logService.log('IPC#vscode:exit', code);
ipc.on('vscode:exit', (_event: any, code: number) => {
this.logService.trace('IPC#vscode:exit', code);
this.dispose();
this.lifecycleService.kill(code);
});
ipc.on(machineIdIpcChannel, (event, machineId: string) => {
this.logService.log('IPC#vscode-machineId');
this.storageService.setItem(machineIdStorageKey, machineId);
});
ipc.on('vscode:fetchShellEnv', (event, windowId) => {
ipc.on('vscode:fetchShellEnv', (_event: any, windowId: number) => {
const { webContents } = BrowserWindow.fromId(windowId);
getShellEnvironment().then(shellEnv => {
if (!webContents.isDestroyed()) {
@@ -215,9 +209,9 @@ export class CodeApplication {
});
});
ipc.on('vscode:broadcast', (event, windowId: number, broadcast: { channel: string; payload: any; }) => {
ipc.on('vscode:broadcast', (_event: any, windowId: number, broadcast: { channel: string; payload: any; }) => {
if (this.windowsMainService && broadcast.channel && !isUndefinedOrNull(broadcast.payload)) {
this.logService.log('IPC#vscode:broadcast', broadcast.channel, broadcast.payload);
this.logService.trace('IPC#vscode:broadcast', broadcast.channel, broadcast.payload);
// Handle specific events on main side
this.onBroadcast(broadcast.channel, broadcast.payload);
@@ -241,15 +235,15 @@ export class CodeApplication {
if (event === 'vscode:changeColorTheme' && typeof payload === 'string') {
let data = JSON.parse(payload);
this.storageService.setItem(CodeWindow.themeStorageKey, data.id);
this.storageService.setItem(CodeWindow.themeBackgroundStorageKey, data.background);
this.stateService.setItem(CodeWindow.themeStorageKey, data.id);
this.stateService.setItem(CodeWindow.themeBackgroundStorageKey, data.background);
}
}
public startup(): void {
this.logService.log('Starting VS Code in verbose mode');
this.logService.log(`from: ${this.environmentService.appRoot}`);
this.logService.log('args:', this.environmentService.args);
public startup(): TPromise<void> {
this.logService.debug('Starting VS Code');
this.logService.debug(`from: ${this.environmentService.appRoot}`);
this.logService.debug('args:', this.environmentService.args);
// Make sure we associate the program with the app user model id
// This will help Windows to associate the running program with
@@ -262,46 +256,62 @@ export class CodeApplication {
// Create Electron IPC Server
this.electronIpcServer = new ElectronIPCServer();
// Spawn shared process
this.sharedProcess = new SharedProcess(this.environmentService, this.userEnv);
this.toDispose.push(this.sharedProcess);
this.sharedProcessClient = this.sharedProcess.whenReady().then(() => connect(this.environmentService.sharedIPCHandle, 'main'));
// Resolve unique machine ID
this.logService.trace('Resolving machine identifier...');
return this.resolveMachineId().then(machineId => {
this.logService.trace(`Resolved machine identifier: ${machineId}`);
// Services
const appInstantiationService = this.initServices();
// Spawn shared process
this.sharedProcess = new SharedProcess(this.environmentService, machineId, this.userEnv);
this.toDispose.push(this.sharedProcess);
this.sharedProcessClient = this.sharedProcess.whenReady().then(() => connect(this.environmentService.sharedIPCHandle, 'main'));
// Setup Auth Handler
const authHandler = appInstantiationService.createInstance(ProxyAuthHandler);
this.toDispose.push(authHandler);
// Services
const appInstantiationService = this.initServices(machineId);
// Open Windows
appInstantiationService.invokeFunction(accessor => this.openFirstWindow(accessor));
// Setup Auth Handler
const authHandler = appInstantiationService.createInstance(ProxyAuthHandler);
this.toDispose.push(authHandler);
// Post Open Windows Tasks
appInstantiationService.invokeFunction(accessor => this.afterWindowOpen(accessor));
// Open Windows
appInstantiationService.invokeFunction(accessor => this.openFirstWindow(accessor));
// Post Open Windows Tasks
appInstantiationService.invokeFunction(accessor => this.afterWindowOpen(accessor));
});
}
private initServices(): IInstantiationService {
private resolveMachineId(): TPromise<string> {
const machineId = this.stateService.getItem<string>(CodeApplication.MACHINE_ID_KEY);
if (machineId) {
return TPromise.wrap(machineId);
}
return getMachineId().then(machineId => {
// Remember in global storage
this.stateService.setItem(CodeApplication.MACHINE_ID_KEY, machineId);
return machineId;
});
}
private initServices(machineId: string): IInstantiationService {
const services = new ServiceCollection();
services.set(IUpdateService, new SyncDescriptor(UpdateService));
services.set(IWindowsMainService, new SyncDescriptor(WindowsManager));
services.set(IWindowsMainService, new SyncDescriptor(WindowsManager, machineId));
services.set(IWindowsService, new SyncDescriptor(WindowsService, this.sharedProcess));
services.set(ILaunchService, new SyncDescriptor(LaunchService));
services.set(ICredentialsService, new SyncDescriptor(CredentialsService));
// Telemtry
if (this.environmentService.isBuilt && !this.environmentService.isExtensionDevelopment && !this.environmentService.args['disable-telemetry'] && !!product.enableTelemetry) {
const channel = getDelayedChannel<ITelemetryAppenderChannel>(this.sharedProcessClient.then(c => c.getChannel('telemetryAppender')));
const appender = new TelemetryAppenderClient(channel);
const commonProperties = resolveCommonProperties(product.commit, pkg.version, this.environmentService.installSource)
// __GDPR__COMMON__ "common.machineId" : { "classification": "EndUserPseudonymizedInformation", "purpose": "FeatureInsight" }
.then(result => Object.defineProperty(result, 'common.machineId', {
get: () => this.storageService.getItem(machineIdStorageKey),
enumerable: true
}));
const commonProperties = resolveCommonProperties(product.commit, pkg.version, machineId, this.environmentService.installSourcePath);
const piiPaths = [this.environmentService.appRoot, this.environmentService.extensionsPath];
const config: ITelemetryServiceConfig = { appender, commonProperties, piiPaths };
services.set(ITelemetryService, new SyncDescriptor(TelemetryService, config));
} else {
services.set(ITelemetryService, NullTelemetryService);
@@ -346,10 +356,6 @@ export class CodeApplication {
this.electronIpcServer.registerChannel('windows', windowsChannel);
this.sharedProcessClient.done(client => client.registerChannel('windows', windowsChannel));
const credentialsService = accessor.get(ICredentialsService);
const credentialsChannel = new CredentialsChannel(credentialsService);
this.electronIpcServer.registerChannel('credentials', credentialsChannel);
// Lifecycle
this.lifecycleService.ready();
@@ -393,6 +399,7 @@ export class CodeApplication {
// Ensure Windows foreground love module
try {
// tslint:disable-next-line:no-unused-expression
<any>require.__$__nodeRequire('windows-foreground-love');
} catch (e) {
if (!this.environmentService.isBuilt) {
@@ -411,8 +418,8 @@ export class CodeApplication {
appInstantiationService.createInstance(CodeMenu);
// Jump List
this.historyService.updateWindowsJumpList();
this.historyService.onRecentlyOpenedChange(() => this.historyService.updateWindowsJumpList());
this.historyMainService.updateWindowsJumpList();
this.historyMainService.onRecentlyOpenedChange(() => this.historyMainService.updateWindowsJumpList());
// Start shared process here
this.sharedProcess.spawn();
@@ -420,8 +427,8 @@ export class CodeApplication {
// Helps application icon refresh after an update with new icon is installed (macOS)
// TODO@Ben remove after a couple of releases
if (platform.isMacintosh) {
if (!this.storageService.getItem(CodeApplication.APP_ICON_REFRESH_KEY)) {
this.storageService.setItem(CodeApplication.APP_ICON_REFRESH_KEY, true);
if (!this.stateService.getItem(CodeApplication.APP_ICON_REFRESH_KEY)) {
this.stateService.setItem(CodeApplication.APP_ICON_REFRESH_KEY, true);
// 'exe' => /Applications/Visual Studio Code - Insiders.app/Contents/MacOS/Electron
const appPath = dirname(dirname(dirname(app.getPath('exe'))));