Skip to content

Commit b644d80

Browse files
author
Benjamin Pasero
committed
debt - extract node pieces to node layer (window)
1 parent 9f1aa3c commit b644d80

18 files changed

Lines changed: 210 additions & 130 deletions

File tree

.eslintrc.json

Lines changed: 76 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -530,21 +530,94 @@
530530
// xterm and its addons are strictly browser-only components
531531
"xterm",
532532
"xterm-addon-*",
533-
"**/vs/**"
533+
"vs/nls",
534+
"vs/css!./**/*",
535+
"**/vs/base/**/{common,browser}/**",
536+
"**/vs/platform/**/{common,browser}/**",
537+
"**/vs/editor/**",
538+
"**/vs/workbench/{common,browser}/**",
539+
"**/vs/workbench/services/**/{common,browser}/**",
540+
"!path" // node modules (except path where we have our own impl)
534541
]
535542
},
536543
{
537544
"target": "**/vs/workbench/contrib/extensions/browser/**",
538545
"restrictions": [
539546
"semver-umd",
540-
"**/vs/**"
547+
"vs/nls",
548+
"vs/css!./**/*",
549+
"**/vs/base/**/{common,browser}/**",
550+
"**/vs/platform/**/{common,browser}/**",
551+
"**/vs/editor/**",
552+
"**/vs/workbench/{common,browser}/**",
553+
"**/vs/workbench/services/**/{common,browser}/**",
554+
"!path" // node modules (except path where we have our own impl)
541555
]
542556
},
543557
{
544558
"target": "**/vs/workbench/contrib/update/browser/update.ts",
545559
"restrictions": [
546560
"semver-umd",
547-
"**/vs/**"
561+
"vs/nls",
562+
"vs/css!./**/*",
563+
"**/vs/base/**/{common,browser}/**",
564+
"**/vs/platform/**/{common,browser}/**",
565+
"**/vs/editor/**",
566+
"**/vs/workbench/{common,browser}/**",
567+
"**/vs/workbench/services/**/{common,browser}/**",
568+
"!path" // node modules (except path where we have our own impl)
569+
]
570+
},
571+
{
572+
"target": "**/vs/workbench/contrib/**/common/**",
573+
"restrictions": [
574+
"vs/nls",
575+
"vs/css!./**/*",
576+
"**/vs/base/**/common/**",
577+
"**/vs/platform/**/common/**",
578+
"**/vs/editor/**/common/**",
579+
"**/vs/workbench/common/**",
580+
"**/vs/workbench/services/**/common/**",
581+
"!path" // node modules (except path where we have our own impl)
582+
]
583+
},
584+
{
585+
"target": "**/vs/workbench/contrib/**/browser/**",
586+
"restrictions": [
587+
"vs/nls",
588+
"vs/css!./**/*",
589+
"**/vs/base/**/{common,browser}/**",
590+
"**/vs/platform/**/{common,browser}/**",
591+
"**/vs/editor/**",
592+
"**/vs/workbench/{common,browser}/**",
593+
"**/vs/workbench/services/**/{common,browser}/**",
594+
"!path" // node modules (except path where we have our own impl)
595+
]
596+
},
597+
{
598+
"target": "**/vs/workbench/contrib/**/node/**",
599+
"restrictions": [
600+
"vs/nls",
601+
"vs/css!./**/*",
602+
"**/vs/base/**/{common,node}/**",
603+
"**/vs/platform/**/{common,node}/**",
604+
"**/vs/editor/**/common/**",
605+
"**/vs/workbench/{common,node}/**",
606+
"**/vs/workbench/services/**/{common,node}/**",
607+
"!path" // node modules (except path where we have our own impl)
608+
]
609+
},
610+
{
611+
"target": "**/vs/workbench/contrib/**/electron-browser/**",
612+
"restrictions": [
613+
"vs/nls",
614+
"vs/css!./**/*",
615+
"**/vs/base/**/{common,browser,worker,node,electron-browser}/**",
616+
"**/vs/platform/**/{common,browser,node,electron-browser}/**",
617+
"**/vs/editor/**",
618+
"**/vs/workbench/{common,browser,node,electron-browser,api}/**",
619+
"**/vs/workbench/services/**/{common,browser,node,electron-browser}/**",
620+
"!path" // node modules (except path where we have our own impl)
548621
]
549622
},
550623
{

src/vs/code/electron-main/app.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
import { app, ipcMain as ipc, systemPreferences, shell, Event, contentTracing, protocol, powerMonitor, IpcMainEvent, BrowserWindow } from 'electron';
77
import { IProcessEnvironment, isWindows, isMacintosh } from 'vs/base/common/platform';
88
import { WindowsMainService } from 'vs/platform/windows/electron-main/windowsMainService';
9-
import { OpenContext, IWindowOpenable } from 'vs/platform/windows/common/windows';
9+
import { IWindowOpenable } from 'vs/platform/windows/common/windows';
10+
import { OpenContext } from 'vs/platform/windows/node/window';
1011
import { ActiveWindowManager } from 'vs/code/node/activeWindowTracker';
1112
import { ILifecycleMainService, LifecycleMainPhase } from 'vs/platform/lifecycle/electron-main/lifecycleMainService';
1213
import { getShellEnvironment } from 'vs/code/node/shellEnv';

src/vs/code/electron-main/window.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { ILogService } from 'vs/platform/log/common/log';
1515
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
1616
import { parseArgs, OPTIONS, ParsedArgs } from 'vs/platform/environment/node/argv';
1717
import product from 'vs/platform/product/common/product';
18-
import { IWindowSettings, MenuBarVisibility, ReadyState, getTitleBarStyle, getMenuBarVisibility } from 'vs/platform/windows/common/windows';
18+
import { IWindowSettings, MenuBarVisibility, getTitleBarStyle, getMenuBarVisibility } from 'vs/platform/windows/common/windows';
1919
import { Disposable, toDisposable } from 'vs/base/common/lifecycle';
2020
import { isLinux, isMacintosh, isWindows } from 'vs/base/common/platform';
2121
import { ICodeWindow, IWindowState, WindowMode } from 'vs/platform/windows/electron-main/windows';
@@ -61,6 +61,29 @@ const enum WindowError {
6161
CRASHED = 2
6262
}
6363

64+
const enum ReadyState {
65+
66+
/**
67+
* This window has not loaded any HTML yet
68+
*/
69+
NONE,
70+
71+
/**
72+
* This window is loading HTML
73+
*/
74+
LOADING,
75+
76+
/**
77+
* This window is navigating to another HTML
78+
*/
79+
NAVIGATING,
80+
81+
/**
82+
* This window is done loading HTML
83+
*/
84+
READY
85+
}
86+
6487
export class CodeWindow extends Disposable implements ICodeWindow {
6588

6689
private static readonly MIN_WIDTH = 600;

src/vs/platform/electron/electron-main/electronMainService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
import { Event } from 'vs/base/common/event';
77
import { IWindowsMainService, ICodeWindow } from 'vs/platform/windows/electron-main/windows';
88
import { MessageBoxOptions, MessageBoxReturnValue, shell, OpenDevToolsOptions, SaveDialogOptions, SaveDialogReturnValue, OpenDialogOptions, OpenDialogReturnValue, CrashReporterStartOptions, crashReporter, Menu, BrowserWindow, app } from 'electron';
9-
import { INativeOpenWindowOptions } from 'vs/platform/windows/node/window';
9+
import { INativeOpenWindowOptions, IOpenedWindow, OpenContext } from 'vs/platform/windows/node/window';
1010
import { ILifecycleMainService } from 'vs/platform/lifecycle/electron-main/lifecycleMainService';
11-
import { IOpenedWindow, OpenContext, IWindowOpenable, IOpenEmptyWindowOptions } from 'vs/platform/windows/common/windows';
11+
import { IWindowOpenable, IOpenEmptyWindowOptions } from 'vs/platform/windows/common/windows';
1212
import { INativeOpenDialogOptions } from 'vs/platform/dialogs/node/dialogs';
1313
import { isMacintosh } from 'vs/base/common/platform';
1414
import { IElectronService } from 'vs/platform/electron/node/electron';

src/vs/platform/electron/node/electron.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
import { Event } from 'vs/base/common/event';
77
import { MessageBoxOptions, MessageBoxReturnValue, OpenDevToolsOptions, SaveDialogOptions, OpenDialogOptions, OpenDialogReturnValue, SaveDialogReturnValue, CrashReporterStartOptions } from 'electron';
88
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
9-
import { IWindowOpenable, IOpenEmptyWindowOptions, IOpenedWindow } from 'vs/platform/windows/common/windows';
9+
import { IWindowOpenable, IOpenEmptyWindowOptions } from 'vs/platform/windows/common/windows';
1010
import { INativeOpenDialogOptions } from 'vs/platform/dialogs/node/dialogs';
1111
import { ISerializableCommandAction } from 'vs/platform/actions/common/actions';
12-
import { INativeOpenWindowOptions } from 'vs/platform/windows/node/window';
12+
import { INativeOpenWindowOptions, IOpenedWindow } from 'vs/platform/windows/node/window';
1313

1414
export const IElectronService = createDecorator<IElectronService>('electronService');
1515

src/vs/platform/launch/electron-main/launchMainService.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import { IProcessEnvironment, isMacintosh } from 'vs/base/common/platform';
99
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
1010
import { ParsedArgs } from 'vs/platform/environment/node/argv';
1111
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
12-
import { OpenContext, IWindowSettings } from 'vs/platform/windows/common/windows';
12+
import { IWindowSettings } from 'vs/platform/windows/common/windows';
13+
import { OpenContext } from 'vs/platform/windows/node/window';
1314
import { IWindowsMainService, ICodeWindow } from 'vs/platform/windows/electron-main/windows';
1415
import { whenDeleted } from 'vs/base/node/pfs';
1516
import { IWorkspacesMainService } from 'vs/platform/workspaces/electron-main/workspacesMainService';

src/vs/platform/lifecycle/common/lifecycleService.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { Event, Emitter } from 'vs/base/common/event';
6+
import { Emitter } from 'vs/base/common/event';
77
import { Barrier } from 'vs/base/common/async';
88
import { Disposable } from 'vs/base/common/lifecycle';
99
import { ILifecycleService, BeforeShutdownEvent, WillShutdownEvent, StartupKind, LifecyclePhase, LifecyclePhaseToString } from 'vs/platform/lifecycle/common/lifecycle';
@@ -15,21 +15,21 @@ export abstract class AbstractLifecycleService extends Disposable implements ILi
1515
_serviceBrand: undefined;
1616

1717
protected readonly _onBeforeShutdown = this._register(new Emitter<BeforeShutdownEvent>());
18-
readonly onBeforeShutdown: Event<BeforeShutdownEvent> = this._onBeforeShutdown.event;
18+
readonly onBeforeShutdown = this._onBeforeShutdown.event;
1919

2020
protected readonly _onWillShutdown = this._register(new Emitter<WillShutdownEvent>());
21-
readonly onWillShutdown: Event<WillShutdownEvent> = this._onWillShutdown.event;
21+
readonly onWillShutdown = this._onWillShutdown.event;
2222

2323
protected readonly _onShutdown = this._register(new Emitter<void>());
24-
readonly onShutdown: Event<void> = this._onShutdown.event;
24+
readonly onShutdown = this._onShutdown.event;
2525

2626
protected _startupKind: StartupKind = StartupKind.NewWindow;
2727
get startupKind(): StartupKind { return this._startupKind; }
2828

2929
private _phase: LifecyclePhase = LifecyclePhase.Starting;
3030
get phase(): LifecyclePhase { return this._phase; }
3131

32-
private phaseWhen = new Map<LifecyclePhase, Barrier>();
32+
private readonly phaseWhen = new Map<LifecyclePhase, Barrier>();
3333

3434
constructor(
3535
@ILogService protected readonly logService: ILogService

src/vs/platform/lifecycle/electron-main/lifecycleMainService.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -141,37 +141,37 @@ export class LifecycleMainService extends Disposable implements ILifecycleMainSe
141141

142142
private static readonly QUIT_FROM_RESTART_MARKER = 'quit.from.restart'; // use a marker to find out if the session was restarted
143143

144-
private windowToCloseRequest: Set<number> = new Set();
145-
private oneTimeListenerTokenGenerator = 0;
146-
private windowCounter = 0;
144+
private readonly _onBeforeShutdown = this._register(new Emitter<void>());
145+
readonly onBeforeShutdown = this._onBeforeShutdown.event;
147146

148-
private pendingQuitPromise: Promise<boolean> | null = null;
149-
private pendingQuitPromiseResolve: { (veto: boolean): void } | null = null;
147+
private readonly _onWillShutdown = this._register(new Emitter<ShutdownEvent>());
148+
readonly onWillShutdown = this._onWillShutdown.event;
150149

151-
private pendingWillShutdownPromise: Promise<void> | null = null;
150+
private readonly _onBeforeWindowClose = this._register(new Emitter<ICodeWindow>());
151+
readonly onBeforeWindowClose = this._onBeforeWindowClose.event;
152+
153+
private readonly _onBeforeWindowUnload = this._register(new Emitter<IWindowUnloadEvent>());
154+
readonly onBeforeWindowUnload = this._onBeforeWindowUnload.event;
152155

153156
private _quitRequested = false;
154157
get quitRequested(): boolean { return this._quitRequested; }
155158

156159
private _wasRestarted: boolean = false;
157160
get wasRestarted(): boolean { return this._wasRestarted; }
158161

159-
private readonly _onBeforeShutdown = this._register(new Emitter<void>());
160-
readonly onBeforeShutdown: Event<void> = this._onBeforeShutdown.event;
161-
162-
private readonly _onWillShutdown = this._register(new Emitter<ShutdownEvent>());
163-
readonly onWillShutdown: Event<ShutdownEvent> = this._onWillShutdown.event;
162+
private _phase = LifecycleMainPhase.Starting;
163+
get phase(): LifecycleMainPhase { return this._phase; }
164164

165-
private readonly _onBeforeWindowClose = this._register(new Emitter<ICodeWindow>());
166-
readonly onBeforeWindowClose: Event<ICodeWindow> = this._onBeforeWindowClose.event;
165+
private readonly windowToCloseRequest = new Set<number>();
166+
private oneTimeListenerTokenGenerator = 0;
167+
private windowCounter = 0;
167168

168-
private readonly _onBeforeWindowUnload = this._register(new Emitter<IWindowUnloadEvent>());
169-
readonly onBeforeWindowUnload: Event<IWindowUnloadEvent> = this._onBeforeWindowUnload.event;
169+
private pendingQuitPromise: Promise<boolean> | null = null;
170+
private pendingQuitPromiseResolve: { (veto: boolean): void } | null = null;
170171

171-
private _phase: LifecycleMainPhase = LifecycleMainPhase.Starting;
172-
get phase(): LifecycleMainPhase { return this._phase; }
172+
private pendingWillShutdownPromise: Promise<void> | null = null;
173173

174-
private phaseWhen = new Map<LifecycleMainPhase, Barrier>();
174+
private readonly phaseWhen = new Map<LifecycleMainPhase, Barrier>();
175175

176176
constructor(
177177
@ILogService private readonly logService: ILogService,

src/vs/platform/menubar/electron-main/menubar.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import * as nls from 'vs/nls';
77
import { isMacintosh, language } from 'vs/base/common/platform';
88
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
99
import { app, shell, Menu, MenuItem, BrowserWindow, MenuItemConstructorOptions, WebContents, Event, KeyboardEvent } from 'electron';
10-
import { OpenContext, IRunActionInWindowRequest, getTitleBarStyle, IRunKeybindingInWindowRequest, IWindowOpenable } from 'vs/platform/windows/common/windows';
10+
import { getTitleBarStyle, IWindowOpenable } from 'vs/platform/windows/common/windows';
11+
import { OpenContext, IRunActionInWindowRequest, IRunKeybindingInWindowRequest } from 'vs/platform/windows/node/window';
1112
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
1213
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
1314
import { IUpdateService, StateType } from 'vs/platform/update/common/update';

src/vs/platform/windows/common/windows.ts

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,9 @@
55

66
import { isMacintosh, isLinux, isWeb } from 'vs/base/common/platform';
77
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
8-
import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
98
import { URI, UriComponents } from 'vs/base/common/uri';
109
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
1110

12-
export interface IOpenedWindow {
13-
id: number;
14-
workspace?: IWorkspaceIdentifier;
15-
folderUri?: ISingleFolderWorkspaceIdentifier;
16-
title: string;
17-
filename?: string;
18-
dirty: boolean;
19-
}
20-
2111
export interface IBaseOpenWindowsOptions {
2212
forceReuseWindow?: boolean;
2313
}
@@ -130,66 +120,12 @@ export function getTitleBarStyle(configurationService: IConfigurationService, en
130120
return isLinux ? 'native' : 'custom'; // default to custom on all macOS and Windows
131121
}
132122

133-
export const enum OpenContext {
134-
135-
// opening when running from the command line
136-
CLI,
137-
138-
// macOS only: opening from the dock (also when opening files to a running instance from desktop)
139-
DOCK,
140-
141-
// opening from the main application window
142-
MENU,
143-
144-
// opening from a file or folder dialog
145-
DIALOG,
146-
147-
// opening from the OS's UI
148-
DESKTOP,
149-
150-
// opening through the API
151-
API
152-
}
153-
154-
export const enum ReadyState {
155-
156-
/**
157-
* This window has not loaded any HTML yet
158-
*/
159-
NONE,
160-
161-
/**
162-
* This window is loading HTML
163-
*/
164-
LOADING,
165-
166-
/**
167-
* This window is navigating to another HTML
168-
*/
169-
NAVIGATING,
170-
171-
/**
172-
* This window is done loading HTML
173-
*/
174-
READY
175-
}
176-
177123
export interface IPath extends IPathData {
178124

179125
// the file path to open within the instance
180126
fileUri?: URI;
181127
}
182128

183-
export interface IPathsToWaitFor extends IPathsToWaitForData {
184-
paths: IPath[];
185-
waitMarkerFileUri: URI;
186-
}
187-
188-
export interface IPathsToWaitForData {
189-
paths: IPathData[];
190-
waitMarkerFileUri: UriComponents;
191-
}
192-
193129
export interface IPathData {
194130

195131
// the file path to open within the instance
@@ -210,12 +146,6 @@ export interface IPathData {
210146
export interface IOpenFileRequest {
211147
filesToOpenOrCreate?: IPathData[];
212148
filesToDiff?: IPathData[];
213-
filesToWait?: IPathsToWaitForData;
214-
termProgram?: string;
215-
}
216-
217-
export interface IAddFoldersRequest {
218-
foldersToAdd: UriComponents[];
219149
}
220150

221151
export interface IWindowConfiguration {
@@ -228,13 +158,3 @@ export interface IWindowConfiguration {
228158
filesToOpenOrCreate?: IPath[];
229159
filesToDiff?: IPath[];
230160
}
231-
232-
export interface IRunActionInWindowRequest {
233-
id: string;
234-
from: 'menu' | 'touchbar' | 'mouse';
235-
args?: any[];
236-
}
237-
238-
export interface IRunKeybindingInWindowRequest {
239-
userSettingsLabel: string;
240-
}

0 commit comments

Comments
 (0)