chore: Update to Electron 6.x (#75802)

This commit is contained in:
Robo
2019-09-13 05:53:56 -07:00
committed by Benjamin Pasero
parent 64980ea1f3
commit 029e9929ae
17 changed files with 1403 additions and 568 deletions
+4 -4
View File
@@ -258,7 +258,7 @@ export class CodeApplication extends Disposable {
this.lifecycleService.kill(code);
});
ipc.on('vscode:fetchShellEnv', async (event: Event) => {
ipc.on('vscode:fetchShellEnv', async (event: Electron.IpcMainEvent) => {
const webContents = event.sender;
try {
@@ -275,10 +275,10 @@ export class CodeApplication extends Disposable {
}
});
ipc.on('vscode:toggleDevTools', (event: Event) => event.sender.toggleDevTools());
ipc.on('vscode:openDevTools', (event: Event) => event.sender.openDevTools());
ipc.on('vscode:toggleDevTools', (event: Electron.IpcMainEvent) => event.sender.toggleDevTools());
ipc.on('vscode:openDevTools', (event: Electron.IpcMainEvent) => event.sender.openDevTools());
ipc.on('vscode:reloadWindow', (event: Event) => event.sender.reload());
ipc.on('vscode:reloadWindow', (event: Electron.IpcMainEvent) => event.sender.reload());
// Some listeners after window opened
(async () => {
+1 -2
View File
@@ -36,9 +36,8 @@ export class SharedProcess implements ISharedProcess {
backgroundColor: this.themeMainService.getBackgroundColor(),
webPreferences: {
images: false,
webaudio: false,
webgl: false,
nodeIntegration: true,
webgl: false,
disableBlinkFeatures: 'Auxclick' // do NOT change, allows us to identify this window as shared-process in the process explorer
}
});
+33 -46
View File
@@ -1955,24 +1955,21 @@ class Dialogs {
}
showMessageBox(options: Electron.MessageBoxOptions, window?: ICodeWindow): Promise<IMessageBoxResult> {
return this.getDialogQueue(window).queue(() => {
return new Promise(resolve => {
const callback = (response: number, checkboxChecked: boolean) => {
resolve({ button: response, checkboxChecked });
};
return this.getDialogQueue(window).queue(async () => {
let result: Electron.MessageBoxReturnValue;
if (window) {
result = await dialog.showMessageBox(window.win, options);
} else {
result = await dialog.showMessageBox(options);
}
if (window) {
dialog.showMessageBox(window.win, options, callback);
} else {
dialog.showMessageBox(options, callback);
}
});
return { button: result.response, checkboxChecked: result.checkboxChecked };
});
}
showSaveDialog(options: Electron.SaveDialogOptions, window?: ICodeWindow): Promise<string> {
function normalizePath(path: string): string {
function normalizePath(path: string | undefined): string | undefined {
if (path && isMacintosh) {
path = normalizeNFC(path); // normalize paths returned from the OS
}
@@ -1980,24 +1977,21 @@ class Dialogs {
return path;
}
return this.getDialogQueue(window).queue(() => {
return new Promise(resolve => {
const callback = (path: string) => {
resolve(normalizePath(path));
};
return this.getDialogQueue(window).queue(async () => {
let result: Electron.SaveDialogReturnValue;
if (window) {
result = await dialog.showSaveDialog(window.win, options);
} else {
result = await dialog.showSaveDialog(options);
}
if (window) {
dialog.showSaveDialog(window.win, options, callback);
} else {
dialog.showSaveDialog(options, callback);
}
});
return normalizePath(result.filePath);
});
}
showOpenDialog(options: Electron.OpenDialogOptions, window?: ICodeWindow): Promise<string[]> {
function normalizePaths(paths: string[]): string[] {
function normalizePaths(paths: string[] | undefined): string[] | undefined {
if (paths && paths.length > 0 && isMacintosh) {
paths = paths.map(path => normalizeNFC(path)); // normalize paths returned from the OS
}
@@ -2005,32 +1999,25 @@ class Dialogs {
return paths;
}
return this.getDialogQueue(window).queue(() => {
return new Promise(resolve => {
return this.getDialogQueue(window).queue(async () => {
// Ensure the path exists (if provided)
let validatePathPromise: Promise<void> = Promise.resolve();
if (options.defaultPath) {
validatePathPromise = exists(options.defaultPath).then(exists => {
if (!exists) {
options.defaultPath = undefined;
}
});
// Ensure the path exists (if provided)
if (options.defaultPath) {
const pathExists = await exists(options.defaultPath);
if (!pathExists) {
options.defaultPath = undefined;
}
}
// Show dialog and wrap as promise
validatePathPromise.then(() => {
const callback = (paths: string[]) => {
resolve(normalizePaths(paths));
};
// Show dialog
let result: Electron.OpenDialogReturnValue;
if (window) {
result = await dialog.showOpenDialog(window.win, options);
} else {
result = await dialog.showOpenDialog(options);
}
if (window) {
dialog.showOpenDialog(window.win, options, callback);
} else {
dialog.showOpenDialog(options, callback);
}
});
});
return normalizePaths(result.filePaths);
});
}
}