mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-04 15:25:47 +01:00
electron-main renames 💄
This commit is contained in:
@@ -92,7 +92,7 @@ export class CodeApplication extends Disposable {
|
||||
@IInstantiationService private readonly instantiationService: IInstantiationService,
|
||||
@ILogService private readonly logService: ILogService,
|
||||
@IEnvironmentService private readonly environmentService: IEnvironmentService,
|
||||
@ILifecycleMainService private readonly lifecycleService: ILifecycleMainService,
|
||||
@ILifecycleMainService private readonly lifecycleMainService: ILifecycleMainService,
|
||||
@IConfigurationService private readonly configurationService: IConfigurationService,
|
||||
@IStateService private readonly stateService: IStateService
|
||||
) {
|
||||
@@ -109,7 +109,7 @@ export class CodeApplication extends Disposable {
|
||||
process.on('unhandledRejection', (reason: unknown) => onUnexpectedError(reason));
|
||||
|
||||
// Dispose on shutdown
|
||||
this.lifecycleService.onWillShutdown(() => this.dispose());
|
||||
this.lifecycleMainService.onWillShutdown(() => this.dispose());
|
||||
|
||||
// Contextmenu via IPC support
|
||||
registerContextMenuListener();
|
||||
@@ -255,7 +255,7 @@ export class CodeApplication extends Disposable {
|
||||
this.logService.trace('IPC#vscode:exit', code);
|
||||
|
||||
this.dispose();
|
||||
this.lifecycleService.kill(code);
|
||||
this.lifecycleMainService.kill(code);
|
||||
});
|
||||
|
||||
ipc.on('vscode:fetchShellEnv', async (event: Electron.IpcMainEvent) => {
|
||||
@@ -282,7 +282,7 @@ export class CodeApplication extends Disposable {
|
||||
|
||||
// Some listeners after window opened
|
||||
(async () => {
|
||||
await this.lifecycleService.when(LifecycleMainPhase.AfterWindowOpen);
|
||||
await this.lifecycleMainService.when(LifecycleMainPhase.AfterWindowOpen);
|
||||
|
||||
// After waking up from sleep (after window opened)
|
||||
powerMonitor.on('resume', () => {
|
||||
@@ -361,7 +361,7 @@ export class CodeApplication extends Disposable {
|
||||
// Spawn shared process after the first window has opened and 3s have passed
|
||||
const sharedProcess = this.instantiationService.createInstance(SharedProcess, machineId, this.userEnv);
|
||||
const sharedProcessClient = sharedProcess.whenReady().then(() => connect(this.environmentService.sharedIPCHandle, 'main'));
|
||||
this.lifecycleService.when(LifecycleMainPhase.AfterWindowOpen).then(() => {
|
||||
this.lifecycleMainService.when(LifecycleMainPhase.AfterWindowOpen).then(() => {
|
||||
this._register(new RunOnceScheduler(async () => {
|
||||
const userEnv = await getShellEnvironment(this.logService, this.environmentService);
|
||||
|
||||
@@ -461,7 +461,7 @@ export class CodeApplication extends Disposable {
|
||||
|
||||
const storageMainService = new StorageMainService(this.logService, this.environmentService);
|
||||
services.set(IStorageMainService, storageMainService);
|
||||
this.lifecycleService.onWillShutdown(e => e.join(storageMainService.close()));
|
||||
this.lifecycleMainService.onWillShutdown(e => e.join(storageMainService.close()));
|
||||
|
||||
const backupMainService = new BackupMainService(this.environmentService, this.configurationService, this.logService);
|
||||
services.set(IBackupMainService, backupMainService);
|
||||
@@ -529,8 +529,8 @@ export class CodeApplication extends Disposable {
|
||||
private openFirstWindow(accessor: ServicesAccessor, electronIpcServer: ElectronIPCServer, sharedProcessClient: Promise<Client<string>>): ICodeWindow[] {
|
||||
|
||||
// Register more Main IPC services
|
||||
const launchService = accessor.get(ILaunchMainService);
|
||||
const launchChannel = new LaunchChannel(launchService);
|
||||
const launchMainService = accessor.get(ILaunchMainService);
|
||||
const launchChannel = new LaunchChannel(launchMainService);
|
||||
this.mainIpcServer.registerChannel('launch', launchChannel);
|
||||
|
||||
// Register more Electron IPC services
|
||||
@@ -546,8 +546,8 @@ export class CodeApplication extends Disposable {
|
||||
const electronChannel = new ElectronChannel(electronService);
|
||||
electronIpcServer.registerChannel('electron', electronChannel);
|
||||
|
||||
const workspacesService = accessor.get(IWorkspacesMainService);
|
||||
const workspacesChannel = new WorkspacesChannel(workspacesService);
|
||||
const workspacesMainService = accessor.get(IWorkspacesMainService);
|
||||
const workspacesChannel = new WorkspacesChannel(workspacesMainService);
|
||||
electronIpcServer.registerChannel('workspaces', workspacesChannel);
|
||||
|
||||
const windowsService = accessor.get(IWindowsService);
|
||||
@@ -575,7 +575,7 @@ export class CodeApplication extends Disposable {
|
||||
electronIpcServer.registerChannel(ExtensionHostDebugBroadcastChannel.ChannelName, new ExtensionHostDebugBroadcastChannel());
|
||||
|
||||
// Signal phase: ready (services set)
|
||||
this.lifecycleService.phase = LifecycleMainPhase.Ready;
|
||||
this.lifecycleMainService.phase = LifecycleMainPhase.Ready;
|
||||
|
||||
// Propagate to clients
|
||||
const windowsMainService = this.windowsMainService = accessor.get(IWindowsMainService);
|
||||
@@ -685,7 +685,7 @@ export class CodeApplication extends Disposable {
|
||||
private afterWindowOpen(): void {
|
||||
|
||||
// Signal phase: after window open
|
||||
this.lifecycleService.phase = LifecycleMainPhase.AfterWindowOpen;
|
||||
this.lifecycleMainService.phase = LifecycleMainPhase.AfterWindowOpen;
|
||||
|
||||
// Remote Authorities
|
||||
this.handleRemoteAuthorities();
|
||||
|
||||
@@ -116,13 +116,13 @@ class CodeMain {
|
||||
await instantiationService.invokeFunction(async accessor => {
|
||||
const environmentService = accessor.get(IEnvironmentService);
|
||||
const logService = accessor.get(ILogService);
|
||||
const lifecycleService = accessor.get(ILifecycleMainService);
|
||||
const lifecycleMainService = accessor.get(ILifecycleMainService);
|
||||
const configurationService = accessor.get(IConfigurationService);
|
||||
|
||||
const mainIpcServer = await this.doStartup(logService, environmentService, lifecycleService, instantiationService, true);
|
||||
const mainIpcServer = await this.doStartup(logService, environmentService, lifecycleMainService, instantiationService, true);
|
||||
|
||||
bufferLogService.logger = new SpdLogService('main', environmentService.logsPath, bufferLogService.getLevel());
|
||||
once(lifecycleService.onWillShutdown)(() => (configurationService as ConfigurationService).dispose());
|
||||
once(lifecycleMainService.onWillShutdown)(() => (configurationService as ConfigurationService).dispose());
|
||||
|
||||
return instantiationService.createInstance(CodeApplication, mainIpcServer, instanceEnvironment).startup();
|
||||
});
|
||||
@@ -189,7 +189,7 @@ class CodeMain {
|
||||
return instanceEnvironment;
|
||||
}
|
||||
|
||||
private async doStartup(logService: ILogService, environmentService: IEnvironmentService, lifecycleService: ILifecycleMainService, instantiationService: IInstantiationService, retry: boolean): Promise<Server> {
|
||||
private async doStartup(logService: ILogService, environmentService: IEnvironmentService, lifecycleMainService: ILifecycleMainService, instantiationService: IInstantiationService, retry: boolean): Promise<Server> {
|
||||
|
||||
// Try to setup a server for running. If that succeeds it means
|
||||
// we are the first instance to startup. Otherwise it is likely
|
||||
@@ -197,7 +197,7 @@ class CodeMain {
|
||||
let server: Server;
|
||||
try {
|
||||
server = await serve(environmentService.mainIPCHandle);
|
||||
once(lifecycleService.onWillShutdown)(() => server.dispose());
|
||||
once(lifecycleMainService.onWillShutdown)(() => server.dispose());
|
||||
} catch (error) {
|
||||
|
||||
// Handle unexpected errors (the only expected error is EADDRINUSE that
|
||||
@@ -245,7 +245,7 @@ class CodeMain {
|
||||
throw error;
|
||||
}
|
||||
|
||||
return this.doStartup(logService, environmentService, lifecycleService, instantiationService, false);
|
||||
return this.doStartup(logService, environmentService, lifecycleMainService, instantiationService, false);
|
||||
}
|
||||
|
||||
// Tests from CLI require to be the only instance currently
|
||||
@@ -374,7 +374,7 @@ class CodeMain {
|
||||
|
||||
private quit(accessor: ServicesAccessor, reason?: ExpectedError | Error): void {
|
||||
const logService = accessor.get(ILogService);
|
||||
const lifecycleService = accessor.get(ILifecycleMainService);
|
||||
const lifecycleMainService = accessor.get(ILifecycleMainService);
|
||||
|
||||
let exitCode = 0;
|
||||
|
||||
@@ -394,7 +394,7 @@ class CodeMain {
|
||||
}
|
||||
}
|
||||
|
||||
lifecycleService.kill(exitCode);
|
||||
lifecycleMainService.kill(exitCode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ export class SharedProcess implements ISharedProcess {
|
||||
private readonly machineId: string,
|
||||
private userEnv: NodeJS.ProcessEnv,
|
||||
@IEnvironmentService private readonly environmentService: IEnvironmentService,
|
||||
@ILifecycleMainService private readonly lifecycleService: ILifecycleMainService,
|
||||
@ILifecycleMainService private readonly lifecycleMainService: ILifecycleMainService,
|
||||
@ILogService private readonly logService: ILogService,
|
||||
@IThemeMainService private readonly themeMainService: IThemeMainService
|
||||
) { }
|
||||
@@ -68,7 +68,7 @@ export class SharedProcess implements ISharedProcess {
|
||||
|
||||
const disposables = new DisposableStore();
|
||||
|
||||
this.lifecycleService.onWillShutdown(() => {
|
||||
this.lifecycleMainService.onWillShutdown(() => {
|
||||
disposables.dispose();
|
||||
|
||||
// Shut the shared process down when we are quitting
|
||||
|
||||
@@ -188,7 +188,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
|
||||
@ILogService private readonly logService: ILogService,
|
||||
@IStateService private readonly stateService: IStateService,
|
||||
@IEnvironmentService private readonly environmentService: IEnvironmentService,
|
||||
@ILifecycleMainService private readonly lifecycleService: ILifecycleMainService,
|
||||
@ILifecycleMainService private readonly lifecycleMainService: ILifecycleMainService,
|
||||
@IBackupMainService private readonly backupMainService: IBackupMainService,
|
||||
@ITelemetryService private readonly telemetryService: ITelemetryService,
|
||||
@IConfigurationService private readonly configurationService: IConfigurationService,
|
||||
@@ -207,8 +207,8 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
|
||||
this.dialogs = new Dialogs(stateService, this);
|
||||
this.workspacesManager = new WorkspacesManager(workspacesMainService, backupMainService, this);
|
||||
|
||||
this.lifecycleService.when(LifecycleMainPhase.Ready).then(() => this.registerListeners());
|
||||
this.lifecycleService.when(LifecycleMainPhase.AfterWindowOpen).then(() => this.installWindowsMutex());
|
||||
this.lifecycleMainService.when(LifecycleMainPhase.Ready).then(() => this.registerListeners());
|
||||
this.lifecycleMainService.when(LifecycleMainPhase.AfterWindowOpen).then(() => this.installWindowsMutex());
|
||||
}
|
||||
|
||||
private installWindowsMutex(): void {
|
||||
@@ -217,7 +217,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
|
||||
try {
|
||||
const WindowsMutex = (require.__$__nodeRequire('windows-mutex') as typeof import('windows-mutex')).Mutex;
|
||||
const mutex = new WindowsMutex(win32MutexName);
|
||||
once(this.lifecycleService.onWillShutdown)(() => mutex.release());
|
||||
once(this.lifecycleMainService.onWillShutdown)(() => mutex.release());
|
||||
} catch (e) {
|
||||
this.logService.error(e);
|
||||
}
|
||||
@@ -251,8 +251,8 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
|
||||
}
|
||||
|
||||
// Handle various lifecycle events around windows
|
||||
this.lifecycleService.onBeforeWindowClose(window => this.onBeforeWindowClose(window));
|
||||
this.lifecycleService.onBeforeShutdown(() => this.onBeforeShutdown());
|
||||
this.lifecycleMainService.onBeforeWindowClose(window => this.onBeforeWindowClose(window));
|
||||
this.lifecycleMainService.onBeforeShutdown(() => this.onBeforeShutdown());
|
||||
this.onWindowsCountChanged(e => {
|
||||
if (e.newCount - e.oldCount > 0) {
|
||||
// clear last closed window state when a new window opens. this helps on macOS where
|
||||
@@ -340,7 +340,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
|
||||
|
||||
// See note on #onBeforeShutdown() for details how these events are flowing
|
||||
private onBeforeWindowClose(win: ICodeWindow): void {
|
||||
if (this.lifecycleService.quitRequested) {
|
||||
if (this.lifecycleMainService.quitRequested) {
|
||||
return; // during quit, many windows close in parallel so let it be handled in the before-quit handler
|
||||
}
|
||||
|
||||
@@ -985,7 +985,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
|
||||
|
||||
private getRestoreWindowsSetting(): RestoreWindowsSetting {
|
||||
let restoreWindows: RestoreWindowsSetting;
|
||||
if (this.lifecycleService.wasRestarted) {
|
||||
if (this.lifecycleMainService.wasRestarted) {
|
||||
restoreWindows = 'all'; // always reopen all windows when an update was applied
|
||||
} else {
|
||||
const windowConfig = this.configurationService.getValue<IWindowSettings>('window');
|
||||
@@ -1328,7 +1328,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
|
||||
|
||||
// Window state is from a previous session: only allow fullscreen when we got updated or user wants to restore
|
||||
else {
|
||||
allowFullscreen = this.lifecycleService.wasRestarted || (windowConfig && windowConfig.restoreFullscreen);
|
||||
allowFullscreen = this.lifecycleMainService.wasRestarted || (windowConfig && windowConfig.restoreFullscreen);
|
||||
}
|
||||
|
||||
if (state.mode === WindowMode.Fullscreen && !allowFullscreen) {
|
||||
@@ -1364,7 +1364,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
|
||||
window.win.on('closed', () => this.onWindowClosed(window!));
|
||||
|
||||
// Lifecycle
|
||||
(this.lifecycleService as LifecycleMainService).registerWindow(window);
|
||||
(this.lifecycleMainService as LifecycleMainService).registerWindow(window);
|
||||
}
|
||||
|
||||
// Existing window
|
||||
@@ -1387,7 +1387,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
|
||||
// first and only load the new configuration if that was
|
||||
// not vetoed
|
||||
if (window.isReady) {
|
||||
this.lifecycleService.unload(window, UnloadReason.LOAD).then(veto => {
|
||||
this.lifecycleMainService.unload(window, UnloadReason.LOAD).then(veto => {
|
||||
if (!veto) {
|
||||
this.doOpenInBrowserWindow(window!, configuration, options);
|
||||
}
|
||||
@@ -1554,7 +1554,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
|
||||
async reload(win: ICodeWindow, cli?: ParsedArgs): Promise<void> {
|
||||
|
||||
// Only reload when the window has not vetoed this
|
||||
const veto = await this.lifecycleService.unload(win, UnloadReason.RELOAD);
|
||||
const veto = await this.lifecycleMainService.unload(win, UnloadReason.RELOAD);
|
||||
if (!veto) {
|
||||
win.reload(undefined, cli);
|
||||
}
|
||||
@@ -1866,7 +1866,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
|
||||
// Otherwise: normal quit
|
||||
else {
|
||||
setTimeout(() => {
|
||||
this.lifecycleService.quit();
|
||||
this.lifecycleMainService.quit();
|
||||
}, 10 /* delay to unwind callback stack (IPC) */);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user