mirror of
https://github.com/coder/code-server.git
synced 2026-05-09 05:47:26 +02:00
chore(vscode): update to 1.54.2
This commit is contained in:
@@ -15,7 +15,7 @@ import { ISerializableCommandAction } from 'vs/platform/actions/common/actions';
|
||||
import { IEnvironmentMainService } from 'vs/platform/environment/electron-main/environmentMainService';
|
||||
import { AddFirstParameterToFunctions } from 'vs/base/common/types';
|
||||
import { IDialogMainService } from 'vs/platform/dialogs/electron-main/dialogMainService';
|
||||
import { dirExists } from 'vs/base/node/pfs';
|
||||
import { SymlinkSupport } 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';
|
||||
@@ -47,7 +47,7 @@ export class NativeHostMainService extends Disposable implements INativeHostMain
|
||||
@IWindowsMainService private readonly windowsMainService: IWindowsMainService,
|
||||
@IDialogMainService private readonly dialogMainService: IDialogMainService,
|
||||
@ILifecycleMainService private readonly lifecycleMainService: ILifecycleMainService,
|
||||
@IEnvironmentMainService private readonly environmentService: IEnvironmentMainService,
|
||||
@IEnvironmentMainService private readonly environmentMainService: IEnvironmentMainService,
|
||||
@ITelemetryService private readonly telemetryService: ITelemetryService,
|
||||
@ILogService private readonly logService: ILogService
|
||||
) {
|
||||
@@ -76,14 +76,14 @@ export class NativeHostMainService extends Disposable implements INativeHostMain
|
||||
|
||||
//#region Events
|
||||
|
||||
readonly onDidOpenWindow = Event.map(this.windowsMainService.onWindowOpened, window => window.id);
|
||||
readonly onDidOpenWindow = Event.map(this.windowsMainService.onDidOpenWindow, window => window.id);
|
||||
|
||||
readonly onDidMaximizeWindow = Event.filter(Event.fromNodeEventEmitter(app, 'browser-window-maximize', (event, window: BrowserWindow) => window.id), windowId => !!this.windowsMainService.getWindowById(windowId));
|
||||
readonly onDidUnmaximizeWindow = Event.filter(Event.fromNodeEventEmitter(app, 'browser-window-unmaximize', (event, window: BrowserWindow) => window.id), windowId => !!this.windowsMainService.getWindowById(windowId));
|
||||
|
||||
readonly onDidBlurWindow = Event.filter(Event.fromNodeEventEmitter(app, 'browser-window-blur', (event, window: BrowserWindow) => window.id), windowId => !!this.windowsMainService.getWindowById(windowId));
|
||||
readonly onDidFocusWindow = Event.any(
|
||||
Event.map(Event.filter(Event.map(this.windowsMainService.onWindowsCountChanged, () => this.windowsMainService.getLastActiveWindow()), window => !!window), window => window!.id),
|
||||
Event.map(Event.filter(Event.map(this.windowsMainService.onDidChangeWindowsCount, () => this.windowsMainService.getLastActiveWindow()), window => !!window), window => window!.id),
|
||||
Event.filter(Event.fromNodeEventEmitter(app, 'browser-window-focus', (event, window: BrowserWindow) => window.id), windowId => !!this.windowsMainService.getWindowById(windowId))
|
||||
);
|
||||
|
||||
@@ -105,7 +105,7 @@ export class NativeHostMainService extends Disposable implements INativeHostMain
|
||||
return windows.map(window => ({
|
||||
id: window.id,
|
||||
workspace: window.openedWorkspace,
|
||||
title: window.win.getTitle(),
|
||||
title: window.win?.getTitle() ?? '',
|
||||
filename: window.getRepresentedFilename(),
|
||||
dirty: window.isDocumentEdited()
|
||||
}));
|
||||
@@ -140,7 +140,7 @@ export class NativeHostMainService extends Disposable implements INativeHostMain
|
||||
context: OpenContext.API,
|
||||
contextWindowId: windowId,
|
||||
urisToOpen: toOpen,
|
||||
cli: this.environmentService.args,
|
||||
cli: this.environmentMainService.args,
|
||||
forceNewWindow: options.forceNewWindow,
|
||||
forceReuseWindow: options.forceReuseWindow,
|
||||
preferNewWindow: options.preferNewWindow,
|
||||
@@ -176,7 +176,7 @@ export class NativeHostMainService extends Disposable implements INativeHostMain
|
||||
|
||||
async isMaximized(windowId: number | undefined): Promise<boolean> {
|
||||
const window = this.windowById(windowId);
|
||||
if (window) {
|
||||
if (window?.win) {
|
||||
return window.win.isMaximized();
|
||||
}
|
||||
|
||||
@@ -185,21 +185,21 @@ export class NativeHostMainService extends Disposable implements INativeHostMain
|
||||
|
||||
async maximizeWindow(windowId: number | undefined): Promise<void> {
|
||||
const window = this.windowById(windowId);
|
||||
if (window) {
|
||||
if (window?.win) {
|
||||
window.win.maximize();
|
||||
}
|
||||
}
|
||||
|
||||
async unmaximizeWindow(windowId: number | undefined): Promise<void> {
|
||||
const window = this.windowById(windowId);
|
||||
if (window) {
|
||||
if (window?.win) {
|
||||
window.win.unmaximize();
|
||||
}
|
||||
}
|
||||
|
||||
async minimizeWindow(windowId: number | undefined): Promise<void> {
|
||||
const window = this.windowById(windowId);
|
||||
if (window) {
|
||||
if (window?.win) {
|
||||
window.win.minimize();
|
||||
}
|
||||
}
|
||||
@@ -217,7 +217,7 @@ export class NativeHostMainService extends Disposable implements INativeHostMain
|
||||
|
||||
async setMinimumSize(windowId: number | undefined, width: number | undefined, height: number | undefined): Promise<void> {
|
||||
const window = this.windowById(windowId);
|
||||
if (window) {
|
||||
if (window?.win) {
|
||||
const [windowWidth, windowHeight] = window.win.getSize();
|
||||
const [minWindowWidth, minWindowHeight] = window.win.getMinimumSize();
|
||||
const [newMinWindowWidth, newMinWindowHeight] = [width ?? minWindowWidth, height ?? minWindowHeight];
|
||||
@@ -250,7 +250,7 @@ export class NativeHostMainService extends Disposable implements INativeHostMain
|
||||
|
||||
private toBrowserWindow(windowId: number | undefined): BrowserWindow | undefined {
|
||||
const window = this.windowById(windowId);
|
||||
if (window) {
|
||||
if (window?.win) {
|
||||
return window.win;
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@ export class NativeHostMainService extends Disposable implements INativeHostMain
|
||||
const paths = await this.dialogMainService.pickFileFolder(options);
|
||||
if (paths) {
|
||||
this.sendPickerTelemetry(paths, options.telemetryEventName || 'openFileFolder', options.telemetryExtraData);
|
||||
this.doOpenPicked(await Promise.all(paths.map(async path => (await dirExists(path)) ? { folderUri: URI.file(path) } : { fileUri: URI.file(path) })), options, windowId);
|
||||
this.doOpenPicked(await Promise.all(paths.map(async path => (await SymlinkSupport.existsDirectory(path)) ? { folderUri: URI.file(path) } : { fileUri: URI.file(path) })), options, windowId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -293,7 +293,7 @@ export class NativeHostMainService extends Disposable implements INativeHostMain
|
||||
this.windowsMainService.open({
|
||||
context: OpenContext.DIALOG,
|
||||
contextWindowId: windowId,
|
||||
cli: this.environmentService.args,
|
||||
cli: this.environmentMainService.args,
|
||||
urisToOpen: openable,
|
||||
forceNewWindow: options.forceNewWindow
|
||||
});
|
||||
@@ -386,7 +386,7 @@ export class NativeHostMainService extends Disposable implements INativeHostMain
|
||||
|
||||
const promptOptions = {
|
||||
name: product.nameLong.replace('-', ''),
|
||||
icns: (isMacintosh && this.environmentService.isBuilt) ? join(dirname(this.environmentService.appRoot), `${product.nameShort}.icns`) : undefined
|
||||
icns: (isMacintosh && this.environmentMainService.isBuilt) ? join(dirname(this.environmentMainService.appRoot), `${product.nameShort}.icns`) : undefined
|
||||
};
|
||||
|
||||
sudoPrompt.exec(sudoCommand.join(' '), promptOptions, (error: string, stdout: string, stderr: string) => {
|
||||
@@ -412,28 +412,28 @@ export class NativeHostMainService extends Disposable implements INativeHostMain
|
||||
|
||||
// Windows
|
||||
if (isWindows) {
|
||||
if (this.environmentService.isBuilt) {
|
||||
if (this.environmentMainService.isBuilt) {
|
||||
return join(dirname(process.execPath), 'bin', `${product.applicationName}.cmd`);
|
||||
}
|
||||
|
||||
return join(this.environmentService.appRoot, 'scripts', 'code-cli.bat');
|
||||
return join(this.environmentMainService.appRoot, 'scripts', 'code-cli.bat');
|
||||
}
|
||||
|
||||
// Linux
|
||||
if (isLinux) {
|
||||
if (this.environmentService.isBuilt) {
|
||||
if (this.environmentMainService.isBuilt) {
|
||||
return join(dirname(process.execPath), 'bin', `${product.applicationName}`);
|
||||
}
|
||||
|
||||
return join(this.environmentService.appRoot, 'scripts', 'code-cli.sh');
|
||||
return join(this.environmentMainService.appRoot, 'scripts', 'code-cli.sh');
|
||||
}
|
||||
|
||||
// macOS
|
||||
if (this.environmentService.isBuilt) {
|
||||
return join(this.environmentService.appRoot, 'bin', 'code');
|
||||
if (this.environmentMainService.isBuilt) {
|
||||
return join(this.environmentMainService.appRoot, 'bin', 'code');
|
||||
}
|
||||
|
||||
return join(this.environmentService.appRoot, 'scripts', 'code-cli.sh');
|
||||
return join(this.environmentMainService.appRoot, 'scripts', 'code-cli.sh');
|
||||
}
|
||||
|
||||
async getOSStatistics(): Promise<IOSStatistics> {
|
||||
@@ -505,7 +505,7 @@ export class NativeHostMainService extends Disposable implements INativeHostMain
|
||||
//#region macOS Touchbar
|
||||
|
||||
async newWindowTab(): Promise<void> {
|
||||
this.windowsMainService.open({ context: OpenContext.API, cli: this.environmentService.args, forceNewTabbedWindow: true, forceEmpty: true });
|
||||
this.windowsMainService.open({ context: OpenContext.API, cli: this.environmentMainService.args, forceNewTabbedWindow: true, forceEmpty: true });
|
||||
}
|
||||
|
||||
async showPreviousWindowTab(): Promise<void> {
|
||||
@@ -563,7 +563,7 @@ export class NativeHostMainService extends Disposable implements INativeHostMain
|
||||
|
||||
async closeWindowById(currentWindowId: number | undefined, targetWindowId?: number | undefined): Promise<void> {
|
||||
const window = this.windowById(targetWindowId);
|
||||
if (window) {
|
||||
if (window?.win) {
|
||||
return window.win.close();
|
||||
}
|
||||
}
|
||||
@@ -573,7 +573,7 @@ export class NativeHostMainService extends Disposable implements INativeHostMain
|
||||
// If the user selected to exit from an extension development host window, do not quit, but just
|
||||
// close the window unless this is the last window that is opened.
|
||||
const window = this.windowsMainService.getLastActiveWindow();
|
||||
if (window?.isExtensionDevelopmentHost && this.windowsMainService.getWindowCount() > 1) {
|
||||
if (window?.isExtensionDevelopmentHost && this.windowsMainService.getWindowCount() > 1 && window.win) {
|
||||
window.win.close();
|
||||
}
|
||||
|
||||
@@ -609,14 +609,14 @@ export class NativeHostMainService extends Disposable implements INativeHostMain
|
||||
|
||||
async openDevTools(windowId: number | undefined, options?: OpenDevToolsOptions): Promise<void> {
|
||||
const window = this.windowById(windowId);
|
||||
if (window) {
|
||||
if (window?.win) {
|
||||
window.win.webContents.openDevTools(options);
|
||||
}
|
||||
}
|
||||
|
||||
async toggleDevTools(windowId: number | undefined): Promise<void> {
|
||||
const window = this.windowById(windowId);
|
||||
if (window) {
|
||||
if (window?.win) {
|
||||
const contents = window.win.webContents;
|
||||
contents.toggleDevTools();
|
||||
}
|
||||
@@ -624,7 +624,7 @@ export class NativeHostMainService extends Disposable implements INativeHostMain
|
||||
|
||||
async sendInputEvent(windowId: number | undefined, event: MouseInputEvent): Promise<void> {
|
||||
const window = this.windowById(windowId);
|
||||
if (window && (event.type === 'mouseDown' || event.type === 'mouseUp')) {
|
||||
if (window?.win && (event.type === 'mouseDown' || event.type === 'mouseUp')) {
|
||||
window.win.webContents.sendInputEvent(event);
|
||||
}
|
||||
}
|
||||
@@ -658,7 +658,7 @@ export class NativeHostMainService extends Disposable implements INativeHostMain
|
||||
private static readonly PASSWORD_CHUNK_SIZE = NativeHostMainService.MAX_PASSWORD_LENGTH - 100;
|
||||
|
||||
async getPassword(windowId: number | undefined, service: string, account: string): Promise<string | null> {
|
||||
const keytar = await import('keytar');
|
||||
const keytar = await this.withKeytar();
|
||||
|
||||
const password = await keytar.getPassword(service, account);
|
||||
if (password) {
|
||||
@@ -686,7 +686,7 @@ export class NativeHostMainService extends Disposable implements INativeHostMain
|
||||
}
|
||||
|
||||
async setPassword(windowId: number | undefined, service: string, account: string, password: string): Promise<void> {
|
||||
const keytar = await import('keytar');
|
||||
const keytar = await this.withKeytar();
|
||||
|
||||
if (isWindows && password.length > NativeHostMainService.MAX_PASSWORD_LENGTH) {
|
||||
let index = 0;
|
||||
@@ -714,7 +714,7 @@ export class NativeHostMainService extends Disposable implements INativeHostMain
|
||||
}
|
||||
|
||||
async deletePassword(windowId: number | undefined, service: string, account: string): Promise<boolean> {
|
||||
const keytar = await import('keytar');
|
||||
const keytar = await this.withKeytar();
|
||||
|
||||
const didDelete = await keytar.deletePassword(service, account);
|
||||
if (didDelete) {
|
||||
@@ -725,17 +725,25 @@ export class NativeHostMainService extends Disposable implements INativeHostMain
|
||||
}
|
||||
|
||||
async findPassword(windowId: number | undefined, service: string): Promise<string | null> {
|
||||
const keytar = await import('keytar');
|
||||
const keytar = await this.withKeytar();
|
||||
|
||||
return keytar.findPassword(service);
|
||||
}
|
||||
|
||||
async findCredentials(windowId: number | undefined, service: string): Promise<Array<{ account: string, password: string }>> {
|
||||
const keytar = await import('keytar');
|
||||
const keytar = await this.withKeytar();
|
||||
|
||||
return keytar.findCredentials(service);
|
||||
}
|
||||
|
||||
private async withKeytar(): Promise<typeof import('keytar')> {
|
||||
if (this.environmentMainService.disableKeytar) {
|
||||
throw new Error('keytar has been disabled via --disable-keytar option');
|
||||
}
|
||||
|
||||
return await import('keytar');
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
private windowById(windowId: number | undefined): ICodeWindow | undefined {
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { INativeHostService } from 'vs/platform/native/electron-sandbox/native';
|
||||
import { IMainProcessService } from 'vs/platform/ipc/electron-sandbox/mainProcessService';
|
||||
import { createChannelSender } from 'vs/base/parts/ipc/common/ipc';
|
||||
import { IMainProcessService } from 'vs/platform/ipc/electron-sandbox/services';
|
||||
import { ProxyChannel } from 'vs/base/parts/ipc/common/ipc';
|
||||
|
||||
// @ts-ignore: interface is implemented via proxy
|
||||
export class NativeHostService implements INativeHostService {
|
||||
@@ -16,7 +16,7 @@ export class NativeHostService implements INativeHostService {
|
||||
readonly windowId: number,
|
||||
@IMainProcessService mainProcessService: IMainProcessService
|
||||
) {
|
||||
return createChannelSender<INativeHostService>(mainProcessService.getChannel('nativeHost'), {
|
||||
return ProxyChannel.toService<INativeHostService>(mainProcessService.getChannel('nativeHost'), {
|
||||
context: windowId,
|
||||
properties: (() => {
|
||||
const properties = new Map<string, unknown>();
|
||||
|
||||
Reference in New Issue
Block a user