electron - save some changes that are OK with 1.7.x

This commit is contained in:
Daniel Imms 2018-04-03 03:39:25 -07:00 committed by Benjamin Pasero
parent 24d87a7eb0
commit 94f5674695
25 changed files with 57 additions and 57 deletions

View file

@ -448,7 +448,6 @@ global.getOpenUrls = function () {
return openUrls;
};
// use '<UserData>/CachedData'-directory to store
// node/v8 cached data.
let nodeCachedDataDir = getNodeCachedDataDir().then(function (value) {

View file

@ -507,7 +507,7 @@ declare namespace Electron {
* and macOS, icons depend on the application associated with file mime type.
*/
getFileIcon(path: string, callback: (error: Error, icon: NativeImage) => void): void;
getGpuFeatureStatus(): GPUFeatureStatus;
getGPUFeatureStatus(): GPUFeatureStatus;
getJumpListSettings(): JumpListSettings;
/**
* Note: When distributing your packaged app, you have to also ship the locales

View file

@ -381,7 +381,7 @@ export interface IQueuedSender {
// queue is free again to consume messages.
// On Windows we always wait for the send() method to return before sending the next message
// to workaround https://github.com/nodejs/node/issues/7657 (IPC can freeze process)
export function createQueuedSender(childProcess: cp.ChildProcess | NodeJS.Process): IQueuedSender {
export function createQueuedSender(childProcess: cp.ChildProcess): IQueuedSender {
let msgQueue: string[] = [];
let useQueue = false;

View file

@ -96,7 +96,7 @@ export function request(options: IRequestOptions): TPromise<IRequestContext> {
stream = stream.pipe(createGunzip());
}
c({ res, stream });
c({ res, stream } as IRequestContext);
}
});

View file

@ -75,7 +75,7 @@ suite('Arrays', () => {
for (let i = 1; i < array.length; i++) {
let n = array[i];
if (last > n) {
assert.fail(array.slice(i - 10, i + 10));
assert.fail(JSON.stringify(array.slice(i - 10, i + 10)));
}
}
}

View file

@ -16,9 +16,9 @@ suite('Cache', () => {
const cache = new Cache(() => TPromise.as(counter++));
return cache.get()
.then(c => assert.equal(c, 0), () => assert.fail())
.then(c => assert.equal(c, 0), () => assert.fail('Unexpected assertion error'))
.then(() => cache.get())
.then(c => assert.equal(c, 0), () => assert.fail());
.then(c => assert.equal(c, 0), () => assert.fail('Unexpected assertion error'));
});
test('simple error', () => {
@ -26,9 +26,9 @@ suite('Cache', () => {
const cache = new Cache(() => TPromise.wrapError(new Error(String(counter++))));
return cache.get()
.then(() => assert.fail(), err => assert.equal(err.message, 0))
.then(() => assert.fail('Unexpected assertion error'), err => assert.equal(err.message, 0))
.then(() => cache.get())
.then(() => assert.fail(), err => assert.equal(err.message, 0));
.then(() => assert.fail('Unexpected assertion error'), err => assert.equal(err.message, 0));
});
test('should retry cancellations', () => {

View file

@ -7,7 +7,7 @@
import * as processes from 'vs/base/node/processes';
const sender = processes.createQueuedSender(process);
const sender = processes.createQueuedSender(<any>process);
process.on('message', msg => {
sender.send(msg);

View file

@ -7,7 +7,7 @@
import * as processes from 'vs/base/node/processes';
const sender = processes.createQueuedSender(process);
const sender = processes.createQueuedSender(<any>process);
process.on('message', msg => {
sender.send(msg);

View file

@ -5,7 +5,7 @@
'use strict';
import { app, ipcMain as ipc, BrowserWindow } from 'electron';
import { app, ipcMain as ipc } from 'electron';
import * as platform from 'vs/base/common/platform';
import { WindowsManager } from 'vs/code/electron-main/windows';
import { IWindowsService, OpenContext, ActiveWindowManager } from 'vs/platform/windows/common/windows';
@ -127,7 +127,7 @@ export class CodeApplication {
return srcUri.startsWith(URI.file(this.environmentService.appRoot.toLowerCase()).toString());
};
app.on('web-contents-created', (_event: any, 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;
@ -182,15 +182,15 @@ export class CodeApplication {
this.windowsMainService.openNewWindow(OpenContext.DESKTOP); //macOS native tab "+" button
});
ipc.on('vscode:exit', (_event: any, code: number) => {
ipc.on('vscode:exit', (event: any, code: number) => {
this.logService.trace('IPC#vscode:exit', code);
this.dispose();
this.lifecycleService.kill(code);
});
ipc.on('vscode:fetchShellEnv', (_event: any, windowId: number) => {
const { webContents } = BrowserWindow.fromId(windowId);
ipc.on('vscode:fetchShellEnv', event => {
const webContents = event.sender.webContents;
getShellEnvironment().then(shellEnv => {
if (!webContents.isDestroyed()) {
webContents.send('vscode:acceptShellEnv', shellEnv);
@ -204,7 +204,7 @@ export class CodeApplication {
});
});
ipc.on('vscode:broadcast', (_event: any, 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.trace('IPC#vscode:broadcast', broadcast.channel, broadcast.payload);
@ -402,11 +402,12 @@ export class CodeApplication {
this.windowsMainService.ready(this.userEnv);
// Open our first window
const macOpenFiles = (<any>global).macOpenFiles as string[];
const context = !!process.env['VSCODE_CLI'] ? OpenContext.CLI : OpenContext.DESKTOP;
if (args['new-window'] && args._.length === 0) {
this.windowsMainService.open({ context, cli: args, forceNewWindow: true, forceEmpty: true, initialStartup: true }); // new window if "-n" was used without paths
} else if (global.macOpenFiles && global.macOpenFiles.length && (!args._ || !args._.length)) {
this.windowsMainService.open({ context: OpenContext.DOCK, cli: args, pathsToOpen: global.macOpenFiles, initialStartup: true }); // mac: open-file event received on startup
} else if (macOpenFiles && macOpenFiles.length && (!args._ || !args._.length)) {
this.windowsMainService.open({ context: OpenContext.DOCK, cli: args, pathsToOpen: macOpenFiles, initialStartup: true }); // mac: open-file event received on startup
} else {
this.windowsMainService.open({ context, cli: args, forceNewWindow: args['new-window'] || (!args._.length && args['unity-launch']), diffMode: args.diff, initialStartup: true }); // default: read paths from cli
}

View file

@ -100,7 +100,7 @@ export class CodeMenu {
this.windowsMainService.onWindowClose(() => this.updateWorkspaceMenuItems());
// Listen to extension viewlets
ipc.on('vscode:extensionViewlets', (_event: any, rawExtensionViewlets: string) => {
ipc.on('vscode:extensionViewlets', (event: any, rawExtensionViewlets: string) => {
let extensionViewlets: IExtensionViewlet[] = [];
try {
extensionViewlets = JSON.parse(rawExtensionViewlets);

View file

@ -606,7 +606,7 @@ export class CodeWindow implements ICodeWindow {
// Perf Counters
windowConfiguration.perfEntries = exportEntries();
windowConfiguration.perfStartTime = global.perfStartTime;
windowConfiguration.perfStartTime = (<any>global).perfStartTime;
windowConfiguration.perfWindowLoadTime = Date.now();
// Config (combination of process.argv and window configuration)

View file

@ -169,7 +169,7 @@ export class WindowsManager implements IWindowsMainService {
});
// React to workbench loaded events from windows
ipc.on('vscode:workbenchLoaded', (_event: any, windowId: number) => {
ipc.on('vscode:workbenchLoaded', (event: any, windowId: number) => {
this.logService.trace('IPC#vscode-workbenchLoaded');
const win = this.getWindowById(windowId);

View file

@ -192,7 +192,7 @@ export default class RenameInputField implements IContentWidget, IDisposable {
this._inputField.setSelectionRange(
parseInt(this._inputField.getAttribute('selectionStart')),
parseInt(this._inputField.getAttribute('selectionEnd')));
}, 25);
}, 100);
}
private _hide(): void {

View file

@ -109,7 +109,7 @@ suite('Editor Model - Model', () => {
let e: ModelRawContentChangedEvent = null;
thisModel.onDidChangeRawContent((_e) => {
if (e !== null) {
assert.fail();
assert.fail('Unexpected assertion error');
}
e = _e;
});
@ -128,7 +128,7 @@ suite('Editor Model - Model', () => {
let e: ModelRawContentChangedEvent = null;
thisModel.onDidChangeRawContent((_e) => {
if (e !== null) {
assert.fail();
assert.fail('Unexpected assertion error');
}
e = _e;
});
@ -205,7 +205,7 @@ suite('Editor Model - Model', () => {
let e: ModelRawContentChangedEvent = null;
thisModel.onDidChangeRawContent((_e) => {
if (e !== null) {
assert.fail();
assert.fail('Unexpected assertion error');
}
e = _e;
});
@ -224,7 +224,7 @@ suite('Editor Model - Model', () => {
let e: ModelRawContentChangedEvent = null;
thisModel.onDidChangeRawContent((_e) => {
if (e !== null) {
assert.fail();
assert.fail('Unexpected assertion error');
}
e = _e;
});
@ -243,7 +243,7 @@ suite('Editor Model - Model', () => {
let e: ModelRawContentChangedEvent = null;
thisModel.onDidChangeRawContent((_e) => {
if (e !== null) {
assert.fail();
assert.fail('Unexpected assertion error');
}
e = _e;
});
@ -263,7 +263,7 @@ suite('Editor Model - Model', () => {
let e: ModelRawContentChangedEvent = null;
thisModel.onDidChangeRawContent((_e) => {
if (e !== null) {
assert.fail();
assert.fail('Unexpected assertion error');
}
e = _e;
});
@ -314,7 +314,7 @@ suite('Editor Model - Model', () => {
let e: ModelRawContentChangedEvent = null;
thisModel.onDidChangeRawContent((_e) => {
if (e !== null) {
assert.fail();
assert.fail('Unexpected assertion error');
}
e = _e;
});

View file

@ -32,7 +32,7 @@ export class ElectronURLListener {
@IURLService private urlService: IURLService,
@IWindowsMainService private windowsService: IWindowsMainService
) {
const globalBuffer = (global.getOpenUrls() || []) as string[];
const globalBuffer = ((<any>global).getOpenUrls() || []) as string[];
const rawBuffer = [
...(typeof initial === 'string' ? [initial] : initial),
...globalBuffer

View file

@ -28,7 +28,7 @@ process.lazyEnv = new Promise(function (resolve) {
assign(process.env, shellEnv);
resolve(process.env);
});
ipc.send('vscode:fetchShellEnv', remote.getCurrentWindow().id);
ipc.send('vscode:fetchShellEnv');
});
Error.stackTraceLimit = 100; // increase number of stack frames (from 10, https://github.com/v8/v8/wiki/Stack-Trace-API)

View file

@ -131,7 +131,7 @@ export class ElectronWindow extends Themable {
});
// Support runAction event
ipc.on('vscode:runAction', (_event: any, request: IRunActionInWindowRequest) => {
ipc.on('vscode:runAction', (event: any, request: IRunActionInWindowRequest) => {
const args: any[] = [];
// If we run an action from the touchbar, we fill in the currently active resource
@ -162,7 +162,7 @@ export class ElectronWindow extends Themable {
});
// Support resolve keybindings event
ipc.on('vscode:resolveKeybindings', (_event: any, rawActionIds: string) => {
ipc.on('vscode:resolveKeybindings', (event: any, rawActionIds: string) => {
let actionIds: string[] = [];
try {
actionIds = JSON.parse(rawActionIds);
@ -178,7 +178,7 @@ export class ElectronWindow extends Themable {
}, () => errors.onUnexpectedError);
});
ipc.on('vscode:reportError', (_event: any, error: string) => {
ipc.on('vscode:reportError', (event: any, error: string) => {
if (error) {
const errorParsed = JSON.parse(error);
errorParsed.mainProcess = true;
@ -187,13 +187,13 @@ export class ElectronWindow extends Themable {
});
// Support openFiles event for existing and new files
ipc.on('vscode:openFiles', (_event: any, request: IOpenFileRequest) => this.onOpenFiles(request));
ipc.on('vscode:openFiles', (event: any, request: IOpenFileRequest) => this.onOpenFiles(request));
// Support addFolders event if we have a workspace opened
ipc.on('vscode:addFolders', (_event: any, request: IAddFoldersRequest) => this.onAddFoldersRequest(request));
ipc.on('vscode:addFolders', (event: any, request: IAddFoldersRequest) => this.onAddFoldersRequest(request));
// Message support
ipc.on('vscode:showInfoMessage', (_event: any, message: string) => {
ipc.on('vscode:showInfoMessage', (event: any, message: string) => {
this.notificationService.info(message);
});
@ -240,7 +240,7 @@ export class ElectronWindow extends Themable {
});
// keyboard layout changed event
ipc.on('vscode:accessibilitySupportChanged', (_event: any, accessibilitySupportEnabled: boolean) => {
ipc.on('vscode:accessibilitySupportChanged', (event: any, accessibilitySupportEnabled: boolean) => {
browser.setAccessibilitySupport(accessibilitySupportEnabled ? AccessibilitySupport.Enabled : AccessibilitySupport.Disabled);
});

View file

@ -28,14 +28,14 @@ import { ExtHostLogService } from 'vs/workbench/api/node/extHostLogService';
// const nativeExit = process.exit.bind(process);
function patchProcess(allowExit: boolean) {
process.exit = function (code) {
process.exit = function (code?: number) {
if (allowExit) {
exit(code);
} else {
const err = new Error('An extension called process.exit() and this was prevented.');
console.warn(err.stack);
}
};
} as (code?: number) => never;
process.crash = function () {
const err = new Error('An extension called process.crash() and this was prevented.');

View file

@ -55,12 +55,12 @@ export class NodeCachedDataManager implements IWorkbenchContribution {
}
*/
this._telemetryService.publicLog('cachedDataInfo', {
didRequestCachedData: Boolean(global.require.getConfig().nodeCachedDataDir),
didRequestCachedData: Boolean((<any>global).require.getConfig().nodeCachedDataDir),
didRejectCachedData,
didProduceCachedData
});
global.require.config({ onNodeCachedData: undefined });
(<any>global).require.config({ onNodeCachedData: undefined });
delete MonacoEnvironment.onNodeCachedData;
}
}

View file

@ -136,6 +136,6 @@ suite('Debug - Adapter', () => {
return adapter.getInitialConfigurationContent().then(content => {
assert.equal(content, expected);
}, err => assert.fail());
}, err => assert.fail(err));
});
});

View file

@ -24,7 +24,7 @@ var cols = process.env.PTYCOLS;
var rows = process.env.PTYROWS;
var currentTitle = '';
setupPlanB(process.env.PTYPID);
setupPlanB(Number(process.env.PTYPID));
cleanEnv();
interface IOptions {
@ -91,9 +91,9 @@ process.on('message', function (message) {
sendProcessId();
setupTitlePolling();
function getArgs() {
function getArgs(): string[] {
if (process.env['PTYSHELLCMDLINE']) {
return process.env['PTYSHELLCMDLINE'];
return [process.env['PTYSHELLCMDLINE']];
}
var args = [];
var i = 0;

View file

@ -119,7 +119,7 @@ export class CrashReporterService implements ICrashReporterService {
// Experimental crash reporting support for child processes on Mac only for now
if (this.isEnabled && isMacintosh) {
const childProcessOptions = deepClone(this.options);
childProcessOptions.extra.processName = name;
(<any>childProcessOptions.extra).processName = name;
childProcessOptions.crashesDirectory = os.tmpdir();
return childProcessOptions;

View file

@ -61,7 +61,7 @@ export class NsfwWatcherService implements IWatcherService {
ignored: request.ignored
};
process.on('uncaughtException', e => {
process.on('uncaughtException', (e: Error | string) => {
// Specially handle ENOSPC errors that can happen when
// the watcher consumes so many file descriptors that

View file

@ -29,7 +29,7 @@ const rgDiskPath = rgPath.replace(/\bnode_modules\.asar\b/, 'node_modules.asar.u
export class RipgrepEngine {
private isDone = false;
private rgProc: cp.ChildProcess;
private killRgProcFn: Function;
private killRgProcFn: (code?: number) => void;
private postProcessExclusions: glob.ParsedExpression;
private ripgrepParser: RipgrepParser;

View file

@ -109,7 +109,7 @@ suite('SearchService', () => {
assert.deepStrictEqual(value, match);
results++;
} else {
assert.fail(value);
assert.fail(JSON.stringify(value));
}
});
});
@ -131,7 +131,7 @@ suite('SearchService', () => {
});
results.push(value.length);
} else {
assert.fail(value);
assert.fail(JSON.stringify(value));
}
});
});
@ -218,7 +218,7 @@ suite('SearchService', () => {
if (Array.isArray(value)) {
results.push(...value.map(v => v.path));
} else {
assert.fail(value);
assert.fail(JSON.stringify(value));
}
});
});
@ -245,7 +245,7 @@ suite('SearchService', () => {
});
results.push(value.length);
} else {
assert.fail(value);
assert.fail(JSON.stringify(value));
}
});
});
@ -275,7 +275,7 @@ suite('SearchService', () => {
if (Array.isArray(value)) {
results.push(...value.map(v => v.path));
} else {
assert.fail(value);
assert.fail(JSON.stringify(value));
}
}).then(() => {
const results = [];
@ -291,7 +291,7 @@ suite('SearchService', () => {
if (Array.isArray(value)) {
results.push(...value.map(v => v.path));
} else {
assert.fail(value);
assert.fail(JSON.stringify(value));
}
});
}).then(() => {
@ -316,7 +316,7 @@ suite('SearchService', () => {
if (Array.isArray(value)) {
results.push(...value.map(v => v.path));
} else {
assert.fail(value);
assert.fail(JSON.stringify(value));
}
});
});