mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-04 15:25:47 +01:00
debt - require electron and not Electron
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { app, ipcMain as ipc, systemPreferences, shell, Event, contentTracing, protocol, powerMonitor } from 'electron';
|
||||
import { app, ipcMain as ipc, systemPreferences, shell, Event, contentTracing, protocol, powerMonitor, IpcMainEvent } from 'electron';
|
||||
import { IProcessEnvironment, isWindows, isMacintosh } from 'vs/base/common/platform';
|
||||
import { WindowsManager } from 'vs/code/electron-main/windows';
|
||||
import { IWindowsService, OpenContext, ActiveWindowManager, IURIToOpen } from 'vs/platform/windows/common/windows';
|
||||
@@ -164,8 +164,8 @@ export class CodeApplication extends Disposable {
|
||||
|
||||
event.preventDefault();
|
||||
});
|
||||
app.on('web-contents-created', (_event: Electron.Event, contents) => {
|
||||
contents.on('will-attach-webview', (event: Electron.Event, webPreferences, params) => {
|
||||
app.on('web-contents-created', (_event: Event, contents) => {
|
||||
contents.on('will-attach-webview', (event: Event, webPreferences, params) => {
|
||||
|
||||
const isValidWebviewSource = (source: string): boolean => {
|
||||
if (!source) {
|
||||
@@ -257,7 +257,7 @@ export class CodeApplication extends Disposable {
|
||||
this.lifecycleMainService.kill(code);
|
||||
});
|
||||
|
||||
ipc.on('vscode:fetchShellEnv', async (event: Electron.IpcMainEvent) => {
|
||||
ipc.on('vscode:fetchShellEnv', async (event: IpcMainEvent) => {
|
||||
const webContents = event.sender;
|
||||
|
||||
try {
|
||||
@@ -274,10 +274,10 @@ export class CodeApplication extends Disposable {
|
||||
}
|
||||
});
|
||||
|
||||
ipc.on('vscode:toggleDevTools', (event: Electron.IpcMainEvent) => event.sender.toggleDevTools());
|
||||
ipc.on('vscode:openDevTools', (event: Electron.IpcMainEvent) => event.sender.openDevTools());
|
||||
ipc.on('vscode:toggleDevTools', (event: IpcMainEvent) => event.sender.toggleDevTools());
|
||||
ipc.on('vscode:openDevTools', (event: IpcMainEvent) => event.sender.openDevTools());
|
||||
|
||||
ipc.on('vscode:reloadWindow', (event: Electron.IpcMainEvent) => event.sender.reload());
|
||||
ipc.on('vscode:reloadWindow', (event: IpcMainEvent) => event.sender.reload());
|
||||
|
||||
// Some listeners after window opened
|
||||
(async () => {
|
||||
|
||||
@@ -7,13 +7,13 @@ import { localize } from 'vs/nls';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { IWindowsMainService } from 'vs/platform/windows/electron-main/windows';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { BrowserWindow, app } from 'electron';
|
||||
import { BrowserWindow, app, AuthInfo, WebContents, Event as ElectronEvent } from 'electron';
|
||||
|
||||
type LoginEvent = {
|
||||
event: Electron.Event;
|
||||
webContents: Electron.WebContents;
|
||||
req: Electron.Request;
|
||||
authInfo: Electron.AuthInfo;
|
||||
event: ElectronEvent;
|
||||
webContents: WebContents;
|
||||
req: Request;
|
||||
authInfo: AuthInfo;
|
||||
cb: (username: string, password: string) => void;
|
||||
};
|
||||
|
||||
@@ -93,4 +93,4 @@ export class ProxyAuthHandler {
|
||||
dispose(): void {
|
||||
this.disposables = dispose(this.disposables);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ export class SharedProcess implements ISharedProcess {
|
||||
|
||||
private barrier = new Barrier();
|
||||
|
||||
private window: Electron.BrowserWindow | null = null;
|
||||
private window: BrowserWindow | null = null;
|
||||
|
||||
constructor(
|
||||
private readonly machineId: string,
|
||||
|
||||
@@ -7,7 +7,7 @@ import * as path from 'vs/base/common/path';
|
||||
import * as objects from 'vs/base/common/objects';
|
||||
import * as nls from 'vs/nls';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { screen, BrowserWindow, systemPreferences, app, TouchBar, nativeImage, Rectangle, Display } from 'electron';
|
||||
import { screen, BrowserWindow, systemPreferences, app, TouchBar, nativeImage, Rectangle, Display, TouchBarSegmentedControl, NativeImage, BrowserWindowConstructorOptions, SegmentedControlSegment } from 'electron';
|
||||
import { IEnvironmentService, ParsedArgs } from 'vs/platform/environment/common/environment';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
@@ -44,7 +44,7 @@ export const defaultWindowState = function (mode = WindowMode.Normal): IWindowSt
|
||||
};
|
||||
};
|
||||
|
||||
interface ITouchBarSegment extends Electron.SegmentedControlSegment {
|
||||
interface ITouchBarSegment extends SegmentedControlSegment {
|
||||
id: string;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
|
||||
private hiddenTitleBarStyle: boolean;
|
||||
private showTimeoutHandle: NodeJS.Timeout;
|
||||
private _id: number;
|
||||
private _win: Electron.BrowserWindow;
|
||||
private _win: BrowserWindow;
|
||||
private _lastFocusTime: number;
|
||||
private _readyState: ReadyState;
|
||||
private windowState: IWindowState;
|
||||
@@ -72,7 +72,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
|
||||
|
||||
private marketplaceHeadersPromise: Promise<object>;
|
||||
|
||||
private readonly touchBarGroups: Electron.TouchBarSegmentedControl[];
|
||||
private readonly touchBarGroups: TouchBarSegmentedControl[];
|
||||
|
||||
constructor(
|
||||
config: IWindowCreationOptions,
|
||||
@@ -116,7 +116,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
|
||||
// in case we are maximized or fullscreen, only show later after the call to maximize/fullscreen (see below)
|
||||
const isFullscreenOrMaximized = (this.windowState.mode === WindowMode.Maximized || this.windowState.mode === WindowMode.Fullscreen);
|
||||
|
||||
const options: Electron.BrowserWindowConstructorOptions = {
|
||||
const options: BrowserWindowConstructorOptions = {
|
||||
width: this.windowState.width,
|
||||
height: this.windowState.height,
|
||||
x: this.windowState.x,
|
||||
@@ -231,7 +231,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
|
||||
return this._id;
|
||||
}
|
||||
|
||||
get win(): Electron.BrowserWindow {
|
||||
get win(): BrowserWindow {
|
||||
return this._win;
|
||||
}
|
||||
|
||||
@@ -421,7 +421,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
|
||||
});
|
||||
|
||||
// Window Failed to load
|
||||
this._win.webContents.on('did-fail-load', (event: Electron.Event, errorCode: number, errorDescription: string, validatedURL: string, isMainFrame: boolean) => {
|
||||
this._win.webContents.on('did-fail-load', (event: Event, errorCode: number, errorDescription: string, validatedURL: string, isMainFrame: boolean) => {
|
||||
this.logService.warn('[electron event]: fail to load, ', errorDescription);
|
||||
});
|
||||
|
||||
@@ -653,7 +653,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
|
||||
|
||||
// only consider non-minimized window states
|
||||
if (mode === WindowMode.Normal || mode === WindowMode.Maximized) {
|
||||
let bounds: Electron.Rectangle;
|
||||
let bounds: Rectangle;
|
||||
if (mode === WindowMode.Normal) {
|
||||
bounds = this.getBounds();
|
||||
} else {
|
||||
@@ -778,7 +778,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
getBounds(): Electron.Rectangle {
|
||||
getBounds(): Rectangle {
|
||||
const pos = this._win.getPosition();
|
||||
const dimension = this._win.getSize();
|
||||
|
||||
@@ -988,7 +988,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
|
||||
this._win.setTouchBar(new TouchBar({ items: this.touchBarGroups }));
|
||||
}
|
||||
|
||||
private createTouchBarGroup(items: ISerializableCommandAction[] = []): Electron.TouchBarSegmentedControl {
|
||||
private createTouchBarGroup(items: ISerializableCommandAction[] = []): TouchBarSegmentedControl {
|
||||
|
||||
// Group Segments
|
||||
const segments = this.createTouchBarGroupSegments(items);
|
||||
@@ -1008,7 +1008,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
|
||||
|
||||
private createTouchBarGroupSegments(items: ISerializableCommandAction[] = []): ITouchBarSegment[] {
|
||||
const segments: ITouchBarSegment[] = items.map(item => {
|
||||
let icon: Electron.NativeImage | undefined;
|
||||
let icon: NativeImage | undefined;
|
||||
if (item.iconLocation && item.iconLocation.dark.scheme === 'file') {
|
||||
icon = nativeImage.createFromPath(URI.revive(item.iconLocation.dark).fsPath);
|
||||
if (icon.isEmpty()) {
|
||||
|
||||
@@ -13,7 +13,7 @@ import { IEmptyWindowBackupInfo } from 'vs/platform/backup/node/backup';
|
||||
import { IEnvironmentService, ParsedArgs } from 'vs/platform/environment/common/environment';
|
||||
import { IStateService } from 'vs/platform/state/common/state';
|
||||
import { CodeWindow, defaultWindowState } from 'vs/code/electron-main/window';
|
||||
import { ipcMain as ipc, screen, BrowserWindow, dialog, systemPreferences, FileFilter, shell, MessageBoxReturnValue, MessageBoxOptions, SaveDialogOptions, SaveDialogReturnValue, OpenDialogOptions, OpenDialogReturnValue } from 'electron';
|
||||
import { ipcMain as ipc, screen, BrowserWindow, dialog, systemPreferences, FileFilter, shell, MessageBoxReturnValue, MessageBoxOptions, SaveDialogOptions, SaveDialogReturnValue, OpenDialogOptions, OpenDialogReturnValue, Display } from 'electron';
|
||||
import { parseLineAndColumnAware } from 'vs/code/node/paths';
|
||||
import { ILifecycleMainService, UnloadReason, LifecycleMainService, LifecycleMainPhase } from 'vs/platform/lifecycle/electron-main/lifecycleMainService';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
@@ -873,7 +873,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
|
||||
message = localize('uriInvalidTitle', "URI can not be opened");
|
||||
detail = localize('uriInvalidDetail', "The URI '{0}' is not valid and can not be opened.", uri.toString());
|
||||
}
|
||||
const options: Electron.MessageBoxOptions = {
|
||||
const options: MessageBoxOptions = {
|
||||
title: product.nameLong,
|
||||
type: 'info',
|
||||
buttons: [localize('ok', "OK")],
|
||||
@@ -1474,7 +1474,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
|
||||
//
|
||||
|
||||
// We want the new window to open on the same display that the last active one is in
|
||||
let displayToUse: Electron.Display | undefined;
|
||||
let displayToUse: Display | undefined;
|
||||
const displays = screen.getAllDisplays();
|
||||
|
||||
// Single Display
|
||||
@@ -1844,15 +1844,15 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
|
||||
});
|
||||
}
|
||||
|
||||
showMessageBox(options: Electron.MessageBoxOptions, win?: ICodeWindow): Promise<MessageBoxReturnValue> {
|
||||
showMessageBox(options: MessageBoxOptions, win?: ICodeWindow): Promise<MessageBoxReturnValue> {
|
||||
return this.dialogs.showMessageBox(options, win);
|
||||
}
|
||||
|
||||
showSaveDialog(options: Electron.SaveDialogOptions, win?: ICodeWindow): Promise<SaveDialogReturnValue> {
|
||||
showSaveDialog(options: SaveDialogOptions, win?: ICodeWindow): Promise<SaveDialogReturnValue> {
|
||||
return this.dialogs.showSaveDialog(options, win);
|
||||
}
|
||||
|
||||
showOpenDialog(options: Electron.OpenDialogOptions, win?: ICodeWindow): Promise<OpenDialogReturnValue> {
|
||||
showOpenDialog(options: OpenDialogOptions, win?: ICodeWindow): Promise<OpenDialogReturnValue> {
|
||||
return this.dialogs.showOpenDialog(options, win);
|
||||
}
|
||||
|
||||
@@ -1902,7 +1902,7 @@ class Dialogs {
|
||||
async pick(options: IInternalNativeOpenDialogOptions): Promise<string[] | undefined> {
|
||||
|
||||
// Ensure dialog options
|
||||
const dialogOptions: Electron.OpenDialogOptions = {
|
||||
const dialogOptions: OpenDialogOptions = {
|
||||
title: options.title,
|
||||
buttonLabel: options.buttonLabel,
|
||||
filters: options.filters
|
||||
|
||||
Reference in New Issue
Block a user