@codingame/monaco-vscode-layout-service-override 11.1.2 → 12.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/index.d.ts +130 -2
  2. package/index.js +402 -1
  3. package/package.json +27 -7
  4. package/layout.js +0 -388
package/index.d.ts CHANGED
@@ -1,2 +1,130 @@
1
- export * from 'vscode/service-override/layout';
2
- export { default } from 'vscode/service-override/layout';
1
+ import { type IEditorOverrideServices } from "vscode/vscode/vs/editor/standalone/browser/standaloneServices";
2
+ import { type PanelAlignment, Parts, Position } from "@codingame/monaco-vscode-e571cbbb-526b-5d8b-92c5-a0437d2dabb3-common/vscode/vs/workbench/services/layout/browser/layoutService";
3
+ import { IWorkbenchLayoutService } from "vscode/vscode/vs/workbench/services/layout/browser/layoutService.service";
4
+ import type { ILayoutOffsetInfo } from "vscode/vscode/vs/platform/layout/browser/layoutService";
5
+ import { ILayoutService } from "vscode/vscode/vs/platform/layout/browser/layoutService.service";
6
+ import { Event } from "vscode/vscode/vs/base/common/event";
7
+ import * as dom from "vscode/vscode/vs/base/browser/dom";
8
+ import { Part } from "@codingame/monaco-vscode-d8236b3b-b91a-522d-89f4-94d70a546f6a-common/vscode/vs/workbench/browser/part";
9
+ import type { ServicesAccessor } from "vscode/vscode/vs/platform/instantiation/common/instantiation";
10
+ import { Disposable, DisposableStore } from "vscode/vscode/vs/base/common/lifecycle";
11
+ import type { IDisposable } from "@xterm/headless";
12
+ import type { IViewSize } from "@codingame/monaco-vscode-6980eeab-47bb-5a48-8e15-32caf0785565-common/vscode/vs/base/browser/ui/grid/gridview";
13
+ import { unsupported } from "vscode/tools";
14
+ export declare class LayoutService extends Disposable implements ILayoutService, IWorkbenchLayoutService {
15
+ mainContainer: HTMLElement;
16
+ readonly _serviceBrand: undefined;
17
+ private paneCompositeService;
18
+ private editorGroupService;
19
+ private statusBarService;
20
+ private viewDescriptorService;
21
+ private configurationService;
22
+ private auxiliaryWindowService;
23
+ private hostService;
24
+ private activeContainerId;
25
+ private sideBarPosition;
26
+ private panelPosition;
27
+ constructor(mainContainer?: HTMLElement);
28
+ getSize(part: Parts): IViewSize;
29
+ setSize: typeof unsupported;
30
+ whenContainerStylesLoaded(): undefined;
31
+ onDidChangeMainEditorCenteredLayout: Event<any>;
32
+ whenActiveContainerStylesLoaded: Promise<void>;
33
+ hasMainWindowBorder(): boolean;
34
+ getMainWindowBorderRadius(): string | undefined;
35
+ isMainEditorLayoutCentered(): boolean;
36
+ centerMainEditorLayout(): void;
37
+ private readonly _onDidLayoutContainer;
38
+ readonly onDidLayoutContainer: Event<{
39
+ readonly container: HTMLElement;
40
+ readonly dimension: dom.IDimension;
41
+ }>;
42
+ private readonly _onDidAddContainer;
43
+ readonly onDidAddContainer: Event<{
44
+ readonly container: HTMLElement;
45
+ readonly disposables: DisposableStore;
46
+ }>;
47
+ private readonly _onDidRemoveContainer;
48
+ readonly onDidRemoveContainer: Event<HTMLElement>;
49
+ private readonly _onDidLayoutMainContainer;
50
+ readonly onDidLayoutMainContainer: Event<dom.IDimension>;
51
+ private readonly _onDidLayoutActiveContainer;
52
+ readonly onDidLayoutActiveContainer: Event<dom.IDimension>;
53
+ private readonly _onDidChangeActiveContainer;
54
+ readonly onDidChangeActiveContainer: Event<void>;
55
+ get activeContainer(): HTMLElement;
56
+ get containers(): Iterable<HTMLElement>;
57
+ private getContainerFromDocument;
58
+ mainContainerOffset: {
59
+ top: number;
60
+ quickPickTop: number;
61
+ };
62
+ activeContainerOffset: {
63
+ top: number;
64
+ quickPickTop: number;
65
+ };
66
+ onDidChangeFullscreen: Event<any>;
67
+ onDidChangeZenMode: Event<any>;
68
+ onDidChangeWindowMaximized: Event<any>;
69
+ onDidChangeCenteredLayout: Event<any>;
70
+ private readonly _onDidChangePanelPosition;
71
+ readonly onDidChangePanelPosition: Event<string>;
72
+ private readonly _onDidChangeSideBarPosition;
73
+ readonly onDidChangeSideBarPosition: Event<string>;
74
+ onDidChangePanelAlignment: Event<any>;
75
+ onDidChangeNotificationsVisibility: Event<any>;
76
+ openedDefaultEditors: boolean;
77
+ whenRestored: Promise<void>;
78
+ init(accessor: ServicesAccessor): void;
79
+ private handleContainerDidLayout;
80
+ private getActiveContainerId;
81
+ private onActiveWindowChanged;
82
+ private isActivityBarHidden;
83
+ focusPart(part: Parts): void;
84
+ getDimension(part: Parts): dom.Dimension | undefined;
85
+ toggleMaximizedPanel(): void;
86
+ toggleMenuBar(): void;
87
+ setPanelPosition(position: Position): void;
88
+ getPanelAlignment(): PanelAlignment;
89
+ setPanelAlignment(): void;
90
+ toggleZenMode(): void;
91
+ isEditorLayoutCentered(): boolean;
92
+ centerEditorLayout(): void;
93
+ resizePart(): void;
94
+ isWindowMaximized(): boolean;
95
+ updateWindowMaximizedState(): void;
96
+ getVisibleNeighborPart(): Parts | undefined;
97
+ getMaximumEditorDimensions(): dom.Dimension;
98
+ isPanelMaximized(): boolean;
99
+ getPanelPosition(): Position;
100
+ private readonly parts;
101
+ hasFocus(part: Parts): boolean;
102
+ getContainer(window: Window): HTMLElement;
103
+ getContainer(part: Parts): HTMLElement | undefined;
104
+ getPart(key: Parts): Part | undefined;
105
+ private hiddenParts;
106
+ private hasViews;
107
+ setPartHidden(hidden: boolean, part: Parts): void;
108
+ isVisible(part: Parts): boolean;
109
+ getSideBarPosition(): Position;
110
+ setSideBarPosition(position: Position): void;
111
+ registerPart(part: Part): IDisposable;
112
+ isRestored(): boolean;
113
+ private _onDidChangePartVisibility;
114
+ onDidChangePartVisibility: Event<void>;
115
+ readonly offset: ILayoutOffsetInfo;
116
+ private readonly _onDidLayout;
117
+ readonly onDidLayout: Event<dom.IDimension>;
118
+ private _mainContainerDimension;
119
+ get mainContainerDimension(): dom.IDimension;
120
+ get activeContainerDimension(): dom.IDimension;
121
+ layout(): void;
122
+ get hasContainer(): boolean;
123
+ focus(): void;
124
+ }
125
+ declare function getServiceOverride(): IEditorOverrideServices;
126
+ /**
127
+ * @deprecated Provide container via the services `initialize` function
128
+ */
129
+ declare function getServiceOverride(container?: HTMLElement): IEditorOverrideServices;
130
+ export default getServiceOverride;
package/index.js CHANGED
@@ -1 +1,402 @@
1
- export { LayoutService, default } from './layout.js';
1
+
2
+ import { StandaloneServices } from 'vscode/vscode/vs/editor/standalone/browser/standaloneServices';
3
+ import { LayoutSettings, Parts, positionFromString, ActivityBarPosition, positionToString } from '@codingame/monaco-vscode-e571cbbb-526b-5d8b-92c5-a0437d2dabb3-common/vscode/vs/workbench/services/layout/browser/layoutService';
4
+ import 'vscode/vscode/vs/platform/instantiation/common/instantiation';
5
+ import { ILayoutService } from 'vscode/vscode/vs/platform/layout/browser/layoutService.service';
6
+ import { Event, Emitter } from 'vscode/vscode/vs/base/common/event';
7
+ import { getActiveDocument, getWindows, isActiveDocument, getWindow, Dimension, isAncestorUsingFlowTo, getClientArea } from 'vscode/vscode/vs/base/browser/dom';
8
+ import { SyncDescriptor } from 'vscode/vscode/vs/platform/instantiation/common/descriptors';
9
+ import '@codingame/monaco-vscode-d8236b3b-b91a-522d-89f4-94d70a546f6a-common/vscode/vs/workbench/browser/part';
10
+ import { IPaneCompositePartService } from 'vscode/vscode/vs/workbench/services/panecomposite/browser/panecomposite.service';
11
+ import { ViewContainerLocation } from 'vscode/vscode/vs/workbench/common/views';
12
+ import { IViewDescriptorService } from 'vscode/vscode/vs/workbench/common/views.service';
13
+ import { isWindows, isLinux, isChrome, isFirefox, isSafari } from 'vscode/vscode/vs/base/common/platform';
14
+ import { coalesce } from 'vscode/vscode/vs/base/common/arrays';
15
+ import '@codingame/monaco-vscode-0cc5da60-f921-59b9-bd8c-a018e93c0a6f-common/vscode/vs/workbench/browser/parts/activitybar/activitybarPart';
16
+ import { IEditorGroupsService } from 'vscode/vscode/vs/workbench/services/editor/common/editorGroupsService.service';
17
+ import { IStatusbarService } from 'vscode/vscode/vs/workbench/services/statusbar/browser/statusbar.service';
18
+ import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration.service';
19
+ import { Disposable, DisposableStore, toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
20
+ import { IAuxiliaryWindowService } from 'vscode/vscode/vs/workbench/services/auxiliaryWindow/browser/auxiliaryWindowService.service';
21
+ import { StandaloneCodeEditor } from 'vscode/vscode/vs/editor/standalone/browser/standaloneCodeEditor';
22
+ import { IHostService } from 'vscode/vscode/vs/workbench/services/host/browser/host.service';
23
+ import { ICodeEditorService } from 'vscode/vscode/vs/editor/browser/services/codeEditorService';
24
+ import { getMenuBarVisibility, getTitleBarStyle } from 'vscode/vscode/vs/platform/window/common/window';
25
+ import { onRenderWorkbench } from 'vscode/lifecycle';
26
+ import { getWorkbenchContainer } from 'vscode/workbench';
27
+ import { unsupported } from 'vscode/tools';
28
+
29
+ class LayoutService extends Disposable {
30
+ constructor(mainContainer = getWorkbenchContainer()) {
31
+ super();
32
+ this.mainContainer = mainContainer;
33
+ this.setSize = unsupported;
34
+ this.onDidChangeMainEditorCenteredLayout = Event.None;
35
+ this.whenActiveContainerStylesLoaded = Promise.resolve();
36
+ this._onDidLayoutContainer = this._register(new Emitter());
37
+ this.onDidLayoutContainer = this._onDidLayoutContainer.event;
38
+ this._onDidAddContainer = this._register(new Emitter());
39
+ this.onDidAddContainer = this._onDidAddContainer.event;
40
+ this._onDidRemoveContainer = this._register(new Emitter());
41
+ this.onDidRemoveContainer = this._onDidRemoveContainer.event;
42
+ this._onDidLayoutMainContainer = this._register(new Emitter());
43
+ this.onDidLayoutMainContainer = this._onDidLayoutMainContainer.event;
44
+ this._onDidLayoutActiveContainer = this._register(new Emitter());
45
+ this.onDidLayoutActiveContainer = this._onDidLayoutActiveContainer.event;
46
+ this._onDidChangeActiveContainer = this._register(new Emitter());
47
+ this.onDidChangeActiveContainer = this._onDidChangeActiveContainer.event;
48
+ this.mainContainerOffset = { top: 0, quickPickTop: 0 };
49
+ this.activeContainerOffset = { top: 0, quickPickTop: 0 };
50
+ this.onDidChangeFullscreen = Event.None;
51
+ this.onDidChangeZenMode = Event.None;
52
+ this.onDidChangeWindowMaximized = Event.None;
53
+ this.onDidChangeCenteredLayout = Event.None;
54
+ this._onDidChangePanelPosition = this._register(new Emitter());
55
+ this.onDidChangePanelPosition = this._onDidChangePanelPosition.event;
56
+ this._onDidChangeSideBarPosition = this._register(new Emitter());
57
+ this.onDidChangeSideBarPosition = this._onDidChangeSideBarPosition.event;
58
+ this.onDidChangePanelAlignment = Event.None;
59
+ this.onDidChangeNotificationsVisibility = Event.None;
60
+ this.openedDefaultEditors = false;
61
+ this.whenRestored = Promise.resolve();
62
+ this.parts = new Map();
63
+ this.hiddenParts = new Set();
64
+ this._onDidChangePartVisibility = new Emitter();
65
+ this.onDidChangePartVisibility = this._onDidChangePartVisibility.event;
66
+ this.offset = { top: 0, quickPickTop: 0 };
67
+ this._onDidLayout = new Emitter();
68
+ this.onDidLayout = this._onDidLayout.event;
69
+ window.addEventListener('resize', () => this.layout());
70
+ this.layout();
71
+ const platformClass = isWindows ? 'windows' : isLinux ? 'linux' : 'mac';
72
+ const workbenchClasses = coalesce([
73
+ 'monaco-workbench',
74
+ platformClass,
75
+ 'web',
76
+ isChrome ? 'chromium' : isFirefox ? 'firefox' : isSafari ? 'safari' : undefined
77
+ ]);
78
+ mainContainer.classList.add(...workbenchClasses);
79
+ document.body.classList.add(platformClass);
80
+ document.body.classList.add('web');
81
+ }
82
+ getSize(part) {
83
+ return (this.getPart(part)?.dimension ?? {
84
+ height: 0,
85
+ width: 0
86
+ });
87
+ }
88
+ whenContainerStylesLoaded() {
89
+ return undefined;
90
+ }
91
+ hasMainWindowBorder() {
92
+ return false;
93
+ }
94
+ getMainWindowBorderRadius() {
95
+ return undefined;
96
+ }
97
+ isMainEditorLayoutCentered() {
98
+ return false;
99
+ }
100
+ centerMainEditorLayout() { }
101
+ get activeContainer() {
102
+ return this.getContainerFromDocument(getActiveDocument());
103
+ }
104
+ get containers() {
105
+ const containers = [];
106
+ for (const { window } of getWindows()) {
107
+ containers.push(this.getContainerFromDocument(window.document));
108
+ }
109
+ return containers;
110
+ }
111
+ getContainerFromDocument(document) {
112
+ if (document === this.mainContainer.ownerDocument) {
113
+ return this.mainContainer;
114
+ }
115
+ else {
116
+ return document.body.getElementsByClassName('monaco-workbench')[0];
117
+ }
118
+ }
119
+ init(accessor) {
120
+ this.editorGroupService = accessor.get(IEditorGroupsService);
121
+ this.paneCompositeService = accessor.get(IPaneCompositePartService);
122
+ this.statusBarService = accessor.get(IStatusbarService);
123
+ this.viewDescriptorService = accessor.get(IViewDescriptorService);
124
+ this.configurationService = accessor.get(IConfigurationService);
125
+ this.auxiliaryWindowService = accessor.get(IAuxiliaryWindowService);
126
+ this.hostService = accessor.get(IHostService);
127
+ this._register(this.configurationService.onDidChangeConfiguration((e) => {
128
+ if (e.affectsConfiguration(LayoutSettings.ACTIVITY_BAR_LOCATION)) {
129
+ this.setPartHidden(this.isActivityBarHidden(), Parts.ACTIVITYBAR_PART);
130
+ }
131
+ if (e.affectsConfiguration('workbench.statusBar.visible')) {
132
+ this.setPartHidden(!this.configurationService.getValue('workbench.statusBar.visible'), Parts.STATUSBAR_PART);
133
+ }
134
+ if (e.affectsConfiguration('workbench.sideBar.location')) {
135
+ this.setSideBarPosition(positionFromString(this.configurationService.getValue('workbench.sideBar.location') ?? 'left'));
136
+ }
137
+ if (e.affectsConfiguration('workbench.panel.defaultLocation')) {
138
+ this.setPanelPosition(positionFromString(this.configurationService.getValue('workbench.panel.defaultLocation') ?? 'bottom'));
139
+ }
140
+ }));
141
+ this.setPartHidden(this.isActivityBarHidden(), Parts.ACTIVITYBAR_PART);
142
+ this.setPartHidden(!this.configurationService.getValue('workbench.statusBar.visible'), Parts.STATUSBAR_PART);
143
+ this.sideBarPosition = positionFromString(this.configurationService.getValue('workbench.sideBar.location') ?? 'left');
144
+ this.panelPosition = positionFromString(this.configurationService.getValue('workbench.panel.defaultLocation') ??
145
+ 'bottom');
146
+ this._register(this.hostService.onDidChangeActiveWindow(() => this.onActiveWindowChanged()));
147
+ this._register(this.auxiliaryWindowService.onDidOpenAuxiliaryWindow(({ window, disposables }) => {
148
+ this._onDidAddContainer.fire({
149
+ container: window.container,
150
+ disposables: new DisposableStore()
151
+ });
152
+ disposables.add(window.onDidLayout((dimension) => this.handleContainerDidLayout(window.container, dimension)));
153
+ disposables.add(toDisposable(() => this._onDidRemoveContainer.fire(window.container)));
154
+ }));
155
+ }
156
+ handleContainerDidLayout(container, dimension) {
157
+ if (container === this.mainContainer) {
158
+ this._onDidLayoutMainContainer.fire(dimension);
159
+ }
160
+ if (isActiveDocument(container)) {
161
+ this._onDidLayoutActiveContainer.fire(dimension);
162
+ }
163
+ }
164
+ getActiveContainerId() {
165
+ const activeContainer = this.activeContainer;
166
+ return getWindow(activeContainer).vscodeWindowId;
167
+ }
168
+ onActiveWindowChanged() {
169
+ const activeContainerId = this.getActiveContainerId();
170
+ if (this.activeContainerId !== activeContainerId) {
171
+ this.activeContainerId = activeContainerId;
172
+ this._onDidChangeActiveContainer.fire();
173
+ }
174
+ }
175
+ isActivityBarHidden() {
176
+ const oldValue = this.configurationService.getValue('workbench.activityBar.visible');
177
+ if (oldValue !== undefined) {
178
+ return !oldValue;
179
+ }
180
+ return (this.configurationService.getValue(LayoutSettings.ACTIVITY_BAR_LOCATION) !==
181
+ ActivityBarPosition.DEFAULT);
182
+ }
183
+ focusPart(part) {
184
+ switch (part) {
185
+ case Parts.EDITOR_PART:
186
+ this.editorGroupService.activeGroup.focus();
187
+ break;
188
+ case Parts.PANEL_PART: {
189
+ const activePanel = this.paneCompositeService.getActivePaneComposite(ViewContainerLocation.Panel);
190
+ activePanel?.focus();
191
+ break;
192
+ }
193
+ case Parts.SIDEBAR_PART: {
194
+ const activeViewlet = this.paneCompositeService.getActivePaneComposite(ViewContainerLocation.Sidebar);
195
+ activeViewlet?.focus();
196
+ break;
197
+ }
198
+ case Parts.ACTIVITYBAR_PART:
199
+ this.getPart(Parts.ACTIVITYBAR_PART).focus();
200
+ break;
201
+ case Parts.STATUSBAR_PART:
202
+ this.statusBarService.focus();
203
+ break;
204
+ default: {
205
+ const container = this.getContainer(part);
206
+ container?.focus();
207
+ }
208
+ }
209
+ }
210
+ getDimension(part) {
211
+ return this.getPart(part)?.dimension;
212
+ }
213
+ toggleMaximizedPanel() { }
214
+ toggleMenuBar() {
215
+ let currentVisibilityValue = getMenuBarVisibility(this.configurationService);
216
+ if (typeof currentVisibilityValue !== 'string') {
217
+ currentVisibilityValue = 'classic';
218
+ }
219
+ let newVisibilityValue;
220
+ if (currentVisibilityValue === 'visible' || currentVisibilityValue === 'classic') {
221
+ newVisibilityValue =
222
+ getTitleBarStyle(this.configurationService) === 'native' ? 'toggle' : 'compact';
223
+ }
224
+ else {
225
+ newVisibilityValue = 'classic';
226
+ }
227
+ void this.configurationService.updateValue('window.menuBarVisibility', newVisibilityValue);
228
+ }
229
+ setPanelPosition(position) {
230
+ this.panelPosition = position;
231
+ const panelPart = this.getPart(Parts.PANEL_PART);
232
+ panelPart?.updateStyles();
233
+ this._onDidChangePanelPosition.fire(positionToString(position));
234
+ }
235
+ getPanelAlignment() {
236
+ return 'left';
237
+ }
238
+ setPanelAlignment() { }
239
+ toggleZenMode() { }
240
+ isEditorLayoutCentered() {
241
+ return false;
242
+ }
243
+ centerEditorLayout() { }
244
+ resizePart() { }
245
+ isWindowMaximized() {
246
+ return false;
247
+ }
248
+ updateWindowMaximizedState() { }
249
+ getVisibleNeighborPart() {
250
+ return undefined;
251
+ }
252
+ getMaximumEditorDimensions() {
253
+ return new Dimension(Infinity, Infinity);
254
+ }
255
+ isPanelMaximized() {
256
+ return false;
257
+ }
258
+ getPanelPosition() {
259
+ return this.panelPosition;
260
+ }
261
+ hasFocus(part) {
262
+ const activeElement = document.activeElement;
263
+ if (activeElement == null) {
264
+ return false;
265
+ }
266
+ const container = this.getContainer(part);
267
+ return !(container == null) && isAncestorUsingFlowTo(activeElement, container);
268
+ }
269
+ getContainer(windowOrPart) {
270
+ if (typeof windowOrPart === 'string') {
271
+ if (this.parts.get(windowOrPart) == null) {
272
+ return undefined;
273
+ }
274
+ return this.getPart(windowOrPart)?.getContainer();
275
+ }
276
+ else {
277
+ if (windowOrPart.document === this.mainContainer.ownerDocument) {
278
+ return this.mainContainer;
279
+ }
280
+ else {
281
+ return windowOrPart.document.body.getElementsByClassName('monaco-workbench')[0];
282
+ }
283
+ }
284
+ }
285
+ getPart(key) {
286
+ return this.parts.get(key);
287
+ }
288
+ hasViews(id) {
289
+ const viewContainer = this.viewDescriptorService.getViewContainerById(id);
290
+ if (viewContainer == null) {
291
+ return false;
292
+ }
293
+ const viewContainerModel = this.viewDescriptorService.getViewContainerModel(viewContainer);
294
+ if (viewContainerModel == null) {
295
+ return false;
296
+ }
297
+ return viewContainerModel.activeViewDescriptors.length >= 1;
298
+ }
299
+ setPartHidden(hidden, part) {
300
+ if (hidden) {
301
+ this.hiddenParts.add(part);
302
+ }
303
+ else {
304
+ this.hiddenParts.delete(part);
305
+ }
306
+ this._onDidChangePartVisibility.fire();
307
+ const location = {
308
+ [Parts.SIDEBAR_PART]: ViewContainerLocation.Sidebar,
309
+ [Parts.AUXILIARYBAR_PART]: ViewContainerLocation.AuxiliaryBar,
310
+ [Parts.PANEL_PART]: ViewContainerLocation.Panel
311
+ }[part];
312
+ if (location != null) {
313
+ const paneComposite = this.paneCompositeService.getActivePaneComposite(location);
314
+ if (paneComposite != null && hidden) {
315
+ this.paneCompositeService.hideActivePaneComposite(location);
316
+ }
317
+ else if (paneComposite == null && !hidden) {
318
+ let panelToOpen = this.paneCompositeService.getLastActivePaneCompositeId(location);
319
+ if (panelToOpen == null || !this.hasViews(panelToOpen)) {
320
+ panelToOpen = this.viewDescriptorService
321
+ .getViewContainersByLocation(location)
322
+ .find((viewContainer) => this.hasViews(viewContainer.id))?.id;
323
+ }
324
+ if (panelToOpen != null) {
325
+ void this.paneCompositeService.openPaneComposite(panelToOpen, location, true);
326
+ }
327
+ }
328
+ }
329
+ this.getPart(part)?.setVisible(!hidden);
330
+ }
331
+ isVisible(part) {
332
+ return !this.hiddenParts.has(part);
333
+ }
334
+ getSideBarPosition() {
335
+ return this.sideBarPosition;
336
+ }
337
+ setSideBarPosition(position) {
338
+ this.sideBarPosition = position;
339
+ const activityBar = this.getPart(Parts.ACTIVITYBAR_PART);
340
+ const sideBar = this.getPart(Parts.SIDEBAR_PART);
341
+ const auxiliaryBar = this.getPart(Parts.AUXILIARYBAR_PART);
342
+ activityBar?.updateStyles();
343
+ sideBar?.updateStyles();
344
+ auxiliaryBar?.updateStyles();
345
+ this._onDidChangeSideBarPosition.fire(positionToString(position));
346
+ }
347
+ registerPart(part) {
348
+ const id = part.getId();
349
+ this.parts.set(id, part);
350
+ return toDisposable(() => this.parts.delete(id));
351
+ }
352
+ isRestored() {
353
+ return true;
354
+ }
355
+ get mainContainerDimension() {
356
+ return this._mainContainerDimension;
357
+ }
358
+ get activeContainerDimension() {
359
+ const activeContainer = this.activeContainer;
360
+ if (activeContainer === this.mainContainer) {
361
+ return this.mainContainerDimension;
362
+ }
363
+ else {
364
+ return getClientArea(activeContainer);
365
+ }
366
+ }
367
+ layout() {
368
+ this._mainContainerDimension = getClientArea(window.document.body);
369
+ this._onDidLayout.fire(this._mainContainerDimension);
370
+ }
371
+ get hasContainer() {
372
+ return true;
373
+ }
374
+ focus() {
375
+ const activeContainer = this.activeContainer;
376
+ if (activeContainer === this.mainContainer) {
377
+ const focusedCodeEditor = StandaloneServices.get(ICodeEditorService).getFocusedCodeEditor();
378
+ if (focusedCodeEditor instanceof StandaloneCodeEditor) {
379
+ focusedCodeEditor.focus();
380
+ }
381
+ else {
382
+ this.focusPart(Parts.EDITOR_PART);
383
+ }
384
+ }
385
+ else {
386
+ this.editorGroupService.getPart(activeContainer).activeGroup.focus();
387
+ }
388
+ }
389
+ }
390
+ onRenderWorkbench((accessor) => {
391
+ const layoutService = accessor.get(ILayoutService);
392
+ if (layoutService instanceof LayoutService) {
393
+ layoutService.init(accessor);
394
+ }
395
+ });
396
+ function getServiceOverride(container) {
397
+ return {
398
+ [ILayoutService.toString()]: new SyncDescriptor(LayoutService, [container], true)
399
+ };
400
+ }
401
+
402
+ export { LayoutService, getServiceOverride as default };
package/package.json CHANGED
@@ -1,6 +1,8 @@
1
1
  {
2
2
  "name": "@codingame/monaco-vscode-layout-service-override",
3
- "version": "11.1.2",
3
+ "version": "12.0.0",
4
+ "private": false,
5
+ "description": "VSCode public API plugged on the monaco editor - layout service-override",
4
6
  "keywords": [],
5
7
  "author": {
6
8
  "name": "CodinGame",
@@ -12,8 +14,24 @@
12
14
  "url": "git+ssh://git@github.com/CodinGame/monaco-vscode-api.git"
13
15
  },
14
16
  "type": "module",
15
- "private": false,
16
- "description": "VSCode public API plugged on the monaco editor - layout service-override",
17
+ "dependencies": {
18
+ "@codingame/monaco-vscode-0cc5da60-f921-59b9-bd8c-a018e93c0a6f-common": "12.0.0",
19
+ "@codingame/monaco-vscode-d8236b3b-b91a-522d-89f4-94d70a546f6a-common": "12.0.0",
20
+ "@codingame/monaco-vscode-e571cbbb-526b-5d8b-92c5-a0437d2dabb3-common": "12.0.0",
21
+ "vscode": "npm:@codingame/monaco-vscode-api@12.0.0"
22
+ },
23
+ "peerDependencies": {
24
+ "@codingame/monaco-vscode-6980eeab-47bb-5a48-8e15-32caf0785565-common": "12.0.0",
25
+ "@xterm/headless": "12.0.0"
26
+ },
27
+ "peerDependenciesMeta": {
28
+ "@codingame/monaco-vscode-6980eeab-47bb-5a48-8e15-32caf0785565-common": {
29
+ "optional": true
30
+ },
31
+ "@xterm/headless": {
32
+ "optional": true
33
+ }
34
+ },
17
35
  "main": "index.js",
18
36
  "module": "index.js",
19
37
  "types": "index.d.ts",
@@ -22,10 +40,12 @@
22
40
  "default": "./index.js"
23
41
  },
24
42
  "./vscode/*": {
25
- "default": "./vscode/src/*.js"
43
+ "default": "./vscode/src/*.js",
44
+ "types": "./vscode/src/*.d.ts"
45
+ },
46
+ "./*": {
47
+ "default": "./*.js",
48
+ "types": "./*.d.ts"
26
49
  }
27
- },
28
- "dependencies": {
29
- "vscode": "npm:@codingame/monaco-vscode-api@11.1.2"
30
50
  }
31
51
  }
package/layout.js DELETED
@@ -1,388 +0,0 @@
1
- import { StandaloneServices } from 'vscode/vscode/vs/editor/standalone/browser/standaloneServices';
2
- import { positionFromString, positionToString } from 'vscode/vscode/vs/workbench/services/layout/browser/layoutService';
3
- import { ILayoutService } from 'vscode/vscode/vs/platform/layout/browser/layoutService.service';
4
- import { Event, Emitter } from 'vscode/vscode/vs/base/common/event';
5
- import { getActiveDocument, getWindows, isActiveDocument, getWindow, Dimension, isAncestorUsingFlowTo, getClientArea } from 'vscode/vscode/vs/base/browser/dom';
6
- import { SyncDescriptor } from 'vscode/vscode/vs/platform/instantiation/common/descriptors';
7
- import { IPaneCompositePartService } from 'vscode/vscode/vs/workbench/services/panecomposite/browser/panecomposite.service';
8
- import { IViewDescriptorService } from 'vscode/vscode/vs/workbench/common/views.service';
9
- import { isWindows, isLinux, isChrome, isFirefox, isSafari } from 'vscode/vscode/vs/base/common/platform';
10
- import { coalesce } from 'vscode/vscode/vs/base/common/arrays';
11
- import { IEditorGroupsService } from 'vscode/vscode/vs/workbench/services/editor/common/editorGroupsService.service';
12
- import { IStatusbarService } from 'vscode/vscode/vs/workbench/services/statusbar/browser/statusbar.service';
13
- import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration.service';
14
- import { Disposable, DisposableStore, toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
15
- import { IAuxiliaryWindowService } from 'vscode/vscode/vs/workbench/services/auxiliaryWindow/browser/auxiliaryWindowService.service';
16
- import { StandaloneCodeEditor } from 'vscode/vscode/vs/editor/standalone/browser/standaloneCodeEditor';
17
- import { IHostService } from 'vscode/vscode/vs/workbench/services/host/browser/host.service';
18
- import { ICodeEditorService } from 'vscode/vscode/vs/editor/browser/services/codeEditorService';
19
- import { getMenuBarVisibility, getTitleBarStyle } from 'vscode/vscode/vs/platform/window/common/window';
20
- import { onRenderWorkbench } from 'vscode/lifecycle';
21
- import { getWorkbenchContainer } from 'vscode/workbench';
22
-
23
- class LayoutService extends Disposable {
24
- constructor(mainContainer = getWorkbenchContainer()) {
25
- super();
26
- this.mainContainer = mainContainer;
27
- this.onDidChangeMainEditorCenteredLayout = Event.None;
28
- this.whenActiveContainerStylesLoaded = Promise.resolve();
29
- this._onDidLayoutContainer = this._register(new Emitter());
30
- this.onDidLayoutContainer = this._onDidLayoutContainer.event;
31
- this._onDidAddContainer = this._register(new Emitter());
32
- this.onDidAddContainer = this._onDidAddContainer.event;
33
- this._onDidRemoveContainer = this._register(new Emitter());
34
- this.onDidRemoveContainer = this._onDidRemoveContainer.event;
35
- this._onDidLayoutMainContainer = this._register(new Emitter());
36
- this.onDidLayoutMainContainer = this._onDidLayoutMainContainer.event;
37
- this._onDidLayoutActiveContainer = this._register(new Emitter());
38
- this.onDidLayoutActiveContainer = this._onDidLayoutActiveContainer.event;
39
- this._onDidChangeActiveContainer = this._register(new Emitter());
40
- this.onDidChangeActiveContainer = this._onDidChangeActiveContainer.event;
41
- this.mainContainerOffset = { top: 0, quickPickTop: 0 };
42
- this.activeContainerOffset = { top: 0, quickPickTop: 0 };
43
- this.onDidChangeFullscreen = Event.None;
44
- this.onDidChangeZenMode = Event.None;
45
- this.onDidChangeWindowMaximized = Event.None;
46
- this.onDidChangeCenteredLayout = Event.None;
47
- this._onDidChangePanelPosition = this._register(new Emitter());
48
- this.onDidChangePanelPosition = this._onDidChangePanelPosition.event;
49
- this._onDidChangeSideBarPosition = this._register(new Emitter());
50
- this.onDidChangeSideBarPosition = this._onDidChangeSideBarPosition.event;
51
- this.onDidChangePanelAlignment = Event.None;
52
- this.onDidChangeNotificationsVisibility = Event.None;
53
- this.openedDefaultEditors = false;
54
- this.whenRestored = Promise.resolve();
55
- this.parts = new Map();
56
- this.hiddenParts = new Set();
57
- this._onDidChangePartVisibility = new Emitter();
58
- this.onDidChangePartVisibility = this._onDidChangePartVisibility.event;
59
- this.offset = { top: 0, quickPickTop: 0 };
60
- this._onDidLayout = new Emitter();
61
- this.onDidLayout = this._onDidLayout.event;
62
- window.addEventListener('resize', () => this.layout());
63
- this.layout();
64
- const platformClass = isWindows ? 'windows' : isLinux ? 'linux' : 'mac';
65
- const workbenchClasses = coalesce([
66
- 'monaco-workbench',
67
- platformClass,
68
- 'web',
69
- isChrome ? 'chromium' : isFirefox ? 'firefox' : isSafari ? 'safari' : undefined
70
- ]);
71
- mainContainer.classList.add(...workbenchClasses);
72
- document.body.classList.add(platformClass);
73
- document.body.classList.add('web');
74
- }
75
- whenContainerStylesLoaded() {
76
- return undefined;
77
- }
78
- hasMainWindowBorder() {
79
- return false;
80
- }
81
- getMainWindowBorderRadius() {
82
- return undefined;
83
- }
84
- isMainEditorLayoutCentered() {
85
- return false;
86
- }
87
- centerMainEditorLayout() { }
88
- get activeContainer() {
89
- return this.getContainerFromDocument(getActiveDocument());
90
- }
91
- get containers() {
92
- const containers = [];
93
- for (const { window } of getWindows()) {
94
- containers.push(this.getContainerFromDocument(window.document));
95
- }
96
- return containers;
97
- }
98
- getContainerFromDocument(document) {
99
- if (document === this.mainContainer.ownerDocument) {
100
- return this.mainContainer;
101
- }
102
- else {
103
- return document.body.getElementsByClassName('monaco-workbench')[0];
104
- }
105
- }
106
- init(accessor) {
107
- this.editorGroupService = accessor.get(IEditorGroupsService);
108
- this.paneCompositeService = accessor.get(IPaneCompositePartService);
109
- this.statusBarService = accessor.get(IStatusbarService);
110
- this.viewDescriptorService = accessor.get(IViewDescriptorService);
111
- this.configurationService = accessor.get(IConfigurationService);
112
- this.auxiliaryWindowService = accessor.get(IAuxiliaryWindowService);
113
- this.hostService = accessor.get(IHostService);
114
- this._register(this.configurationService.onDidChangeConfiguration((e) => {
115
- if (e.affectsConfiguration("workbench.activityBar.location" )) {
116
- this.setPartHidden(this.isActivityBarHidden(), "workbench.parts.activitybar" );
117
- }
118
- if (e.affectsConfiguration('workbench.statusBar.visible')) {
119
- this.setPartHidden(!this.configurationService.getValue('workbench.statusBar.visible'), "workbench.parts.statusbar" );
120
- }
121
- if (e.affectsConfiguration('workbench.sideBar.location')) {
122
- this.setSideBarPosition(positionFromString(this.configurationService.getValue('workbench.sideBar.location') ?? 'left'));
123
- }
124
- if (e.affectsConfiguration('workbench.panel.defaultLocation')) {
125
- this.setPanelPosition(positionFromString(this.configurationService.getValue('workbench.panel.defaultLocation') ?? 'bottom'));
126
- }
127
- }));
128
- this.setPartHidden(this.isActivityBarHidden(), "workbench.parts.activitybar" );
129
- this.setPartHidden(!this.configurationService.getValue('workbench.statusBar.visible'), "workbench.parts.statusbar" );
130
- this.sideBarPosition = positionFromString(this.configurationService.getValue('workbench.sideBar.location') ?? 'left');
131
- this.panelPosition = positionFromString(this.configurationService.getValue('workbench.panel.defaultLocation') ??
132
- 'bottom');
133
- this._register(this.hostService.onDidChangeActiveWindow(() => this.onActiveWindowChanged()));
134
- this._register(this.auxiliaryWindowService.onDidOpenAuxiliaryWindow(({ window, disposables }) => {
135
- this._onDidAddContainer.fire({
136
- container: window.container,
137
- disposables: new DisposableStore()
138
- });
139
- disposables.add(window.onDidLayout((dimension) => this.handleContainerDidLayout(window.container, dimension)));
140
- disposables.add(toDisposable(() => this._onDidRemoveContainer.fire(window.container)));
141
- }));
142
- }
143
- handleContainerDidLayout(container, dimension) {
144
- if (container === this.mainContainer) {
145
- this._onDidLayoutMainContainer.fire(dimension);
146
- }
147
- if (isActiveDocument(container)) {
148
- this._onDidLayoutActiveContainer.fire(dimension);
149
- }
150
- }
151
- getActiveContainerId() {
152
- const activeContainer = this.activeContainer;
153
- return getWindow(activeContainer).vscodeWindowId;
154
- }
155
- onActiveWindowChanged() {
156
- const activeContainerId = this.getActiveContainerId();
157
- if (this.activeContainerId !== activeContainerId) {
158
- this.activeContainerId = activeContainerId;
159
- this._onDidChangeActiveContainer.fire();
160
- }
161
- }
162
- isActivityBarHidden() {
163
- const oldValue = this.configurationService.getValue('workbench.activityBar.visible');
164
- if (oldValue !== undefined) {
165
- return !oldValue;
166
- }
167
- return (this.configurationService.getValue("workbench.activityBar.location" ) !== "default") ;
168
- }
169
- focusPart(part) {
170
- switch (part) {
171
- case "workbench.parts.editor" :
172
- this.editorGroupService.activeGroup.focus();
173
- break;
174
- case "workbench.parts.panel" : {
175
- const activePanel = this.paneCompositeService.getActivePaneComposite(1 );
176
- activePanel?.focus();
177
- break;
178
- }
179
- case "workbench.parts.sidebar" : {
180
- const activeViewlet = this.paneCompositeService.getActivePaneComposite(0 );
181
- activeViewlet?.focus();
182
- break;
183
- }
184
- case "workbench.parts.activitybar" :
185
- this.getPart("workbench.parts.activitybar" ).focus();
186
- break;
187
- case "workbench.parts.statusbar" :
188
- this.statusBarService.focus();
189
- break;
190
- default: {
191
- const container = this.getContainer(part);
192
- container?.focus();
193
- }
194
- }
195
- }
196
- getDimension(part) {
197
- return this.getPart(part)?.dimension;
198
- }
199
- toggleMaximizedPanel() { }
200
- toggleMenuBar() {
201
- let currentVisibilityValue = getMenuBarVisibility(this.configurationService);
202
- if (typeof currentVisibilityValue !== 'string') {
203
- currentVisibilityValue = 'classic';
204
- }
205
- let newVisibilityValue;
206
- if (currentVisibilityValue === 'visible' || currentVisibilityValue === 'classic') {
207
- newVisibilityValue =
208
- getTitleBarStyle(this.configurationService) === 'native' ? 'toggle' : 'compact';
209
- }
210
- else {
211
- newVisibilityValue = 'classic';
212
- }
213
- void this.configurationService.updateValue('window.menuBarVisibility', newVisibilityValue);
214
- }
215
- setPanelPosition(position) {
216
- this.panelPosition = position;
217
- const panelPart = this.getPart("workbench.parts.panel" );
218
- panelPart?.updateStyles();
219
- this._onDidChangePanelPosition.fire(positionToString(position));
220
- }
221
- getPanelAlignment() {
222
- return 'left';
223
- }
224
- setPanelAlignment() { }
225
- toggleZenMode() { }
226
- isEditorLayoutCentered() {
227
- return false;
228
- }
229
- centerEditorLayout() { }
230
- resizePart() { }
231
- isWindowMaximized() {
232
- return false;
233
- }
234
- updateWindowMaximizedState() { }
235
- getVisibleNeighborPart() {
236
- return undefined;
237
- }
238
- getMaximumEditorDimensions() {
239
- return new Dimension(Infinity, Infinity);
240
- }
241
- isPanelMaximized() {
242
- return false;
243
- }
244
- getPanelPosition() {
245
- return this.panelPosition;
246
- }
247
- hasFocus(part) {
248
- const activeElement = document.activeElement;
249
- if (activeElement == null) {
250
- return false;
251
- }
252
- const container = this.getContainer(part);
253
- return !(container == null) && isAncestorUsingFlowTo(activeElement, container);
254
- }
255
- getContainer(windowOrPart) {
256
- if (typeof windowOrPart === 'string') {
257
- if (this.parts.get(windowOrPart) == null) {
258
- return undefined;
259
- }
260
- return this.getPart(windowOrPart)?.getContainer();
261
- }
262
- else {
263
- if (windowOrPart.document === this.mainContainer.ownerDocument) {
264
- return this.mainContainer;
265
- }
266
- else {
267
- return windowOrPart.document.body.getElementsByClassName('monaco-workbench')[0];
268
- }
269
- }
270
- }
271
- getPart(key) {
272
- return this.parts.get(key);
273
- }
274
- hasViews(id) {
275
- const viewContainer = this.viewDescriptorService.getViewContainerById(id);
276
- if (viewContainer == null) {
277
- return false;
278
- }
279
- const viewContainerModel = this.viewDescriptorService.getViewContainerModel(viewContainer);
280
- if (viewContainerModel == null) {
281
- return false;
282
- }
283
- return viewContainerModel.activeViewDescriptors.length >= 1;
284
- }
285
- setPartHidden(hidden, part) {
286
- if (hidden) {
287
- this.hiddenParts.add(part);
288
- }
289
- else {
290
- this.hiddenParts.delete(part);
291
- }
292
- this._onDidChangePartVisibility.fire();
293
- const location = {
294
- ["workbench.parts.sidebar" ]: 0 ,
295
- ["workbench.parts.auxiliarybar" ]: 2 ,
296
- ["workbench.parts.panel" ]: 1
297
- }[part];
298
- if (location != null) {
299
- const paneComposite = this.paneCompositeService.getActivePaneComposite(location);
300
- if (paneComposite != null && hidden) {
301
- this.paneCompositeService.hideActivePaneComposite(location);
302
- }
303
- else if (paneComposite == null && !hidden) {
304
- let panelToOpen = this.paneCompositeService.getLastActivePaneCompositeId(location);
305
- if (panelToOpen == null || !this.hasViews(panelToOpen)) {
306
- panelToOpen = this.viewDescriptorService
307
- .getViewContainersByLocation(location)
308
- .find((viewContainer) => this.hasViews(viewContainer.id))?.id;
309
- }
310
- if (panelToOpen != null) {
311
- void this.paneCompositeService.openPaneComposite(panelToOpen, location, true);
312
- }
313
- }
314
- }
315
- this.getPart(part)?.setVisible(!hidden);
316
- }
317
- isVisible(part) {
318
- return !( this.hiddenParts.has(part));
319
- }
320
- getSideBarPosition() {
321
- return this.sideBarPosition;
322
- }
323
- setSideBarPosition(position) {
324
- this.sideBarPosition = position;
325
- const activityBar = this.getPart("workbench.parts.activitybar" );
326
- const sideBar = this.getPart("workbench.parts.sidebar" );
327
- const auxiliaryBar = this.getPart("workbench.parts.auxiliarybar" );
328
- activityBar?.updateStyles();
329
- sideBar?.updateStyles();
330
- auxiliaryBar?.updateStyles();
331
- this._onDidChangeSideBarPosition.fire(positionToString(position));
332
- }
333
- registerPart(part) {
334
- const id = part.getId();
335
- this.parts.set(id, part);
336
- return toDisposable(() => this.parts.delete(id));
337
- }
338
- isRestored() {
339
- return true;
340
- }
341
- get mainContainerDimension() {
342
- return this._mainContainerDimension;
343
- }
344
- get activeContainerDimension() {
345
- const activeContainer = this.activeContainer;
346
- if (activeContainer === this.mainContainer) {
347
- return this.mainContainerDimension;
348
- }
349
- else {
350
- return getClientArea(activeContainer);
351
- }
352
- }
353
- layout() {
354
- this._mainContainerDimension = getClientArea(window.document.body);
355
- this._onDidLayout.fire(this._mainContainerDimension);
356
- }
357
- get hasContainer() {
358
- return true;
359
- }
360
- focus() {
361
- const activeContainer = this.activeContainer;
362
- if (activeContainer === this.mainContainer) {
363
- const focusedCodeEditor = StandaloneServices.get(ICodeEditorService).getFocusedCodeEditor();
364
- if (focusedCodeEditor instanceof StandaloneCodeEditor) {
365
- focusedCodeEditor.focus();
366
- }
367
- else {
368
- this.focusPart("workbench.parts.editor" );
369
- }
370
- }
371
- else {
372
- this.editorGroupService.getPart(activeContainer).activeGroup.focus();
373
- }
374
- }
375
- }
376
- onRenderWorkbench((accessor) => {
377
- const layoutService = accessor.get(ILayoutService);
378
- if (layoutService instanceof LayoutService) {
379
- layoutService.init(accessor);
380
- }
381
- });
382
- function getServiceOverride(container) {
383
- return {
384
- [( ILayoutService.toString())]: new SyncDescriptor(LayoutService, [container], true)
385
- };
386
- }
387
-
388
- export { LayoutService, getServiceOverride as default };