@codingame/monaco-vscode-views-service-override 11.1.1 → 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.
package/index.d.ts CHANGED
@@ -1,2 +1,34 @@
1
- export * from 'vscode/service-override/views';
2
- export { default } from 'vscode/service-override/views';
1
+ import { type IEditorOverrideServices } from "vscode/vscode/vs/editor/standalone/browser/standaloneServices";
2
+ import { SidebarPart } from "@codingame/monaco-vscode-6980eeab-47bb-5a48-8e15-32caf0785565-common/vscode/vs/workbench/browser/parts/sidebar/sidebarPart";
3
+ import { ActivityService } from "@codingame/monaco-vscode-cc2b8dc7-d125-518e-bf7e-99a1db5babd1-common/vscode/vs/workbench/services/activity/browser/activityService";
4
+ import { ActivitybarPart } from "@codingame/monaco-vscode-0cc5da60-f921-59b9-bd8c-a018e93c0a6f-common/vscode/vs/workbench/browser/parts/activitybar/activitybarPart";
5
+ import type { IDisposable, IReference } from "vscode/vscode/vs/base/common/lifecycle";
6
+ import { PanelPart } from "@codingame/monaco-vscode-6980eeab-47bb-5a48-8e15-32caf0785565-common/vscode/vs/workbench/browser/parts/panel/panelPart";
7
+ import { Part } from "@codingame/monaco-vscode-d8236b3b-b91a-522d-89f4-94d70a546f6a-common/vscode/vs/workbench/browser/part";
8
+ import { GroupOrientation } from "vscode/vscode/vs/workbench/services/editor/common/editorGroupsService";
9
+ import type { IEditorOptions } from "vscode/vscode/vs/platform/editor/common/editor";
10
+ import type { IResolvedTextEditorModel } from "vscode/vscode/vs/editor/common/services/resolverService";
11
+ import { Parts, Position } from "@codingame/monaco-vscode-e571cbbb-526b-5d8b-92c5-a0437d2dabb3-common/vscode/vs/workbench/services/layout/browser/layoutService";
12
+ import type { ILayoutInitializationState } from "@codingame/monaco-vscode-workbench-service-override/vscode/vs/workbench/browser/layout";
13
+ import { type OpenEditor } from "./service-override/tools/editor.js";
14
+ export * from "./service-override/tools/views.js";
15
+ declare function renderPart(partContainer: HTMLElement, part: Part): void;
16
+ declare function attachPart(part: Parts, container: HTMLElement): IDisposable;
17
+ declare function onPartVisibilityChange(part: Parts, listener: (visible: boolean) => void): IDisposable;
18
+ declare function renderActivitybarPar(container: HTMLElement): IDisposable;
19
+ declare function renderSidebarPart(container: HTMLElement): IDisposable;
20
+ declare function renderPanelPart(container: HTMLElement): IDisposable;
21
+ declare function renderAuxiliaryPart(container: HTMLElement): IDisposable;
22
+ declare function renderEditorPart(container: HTMLElement): IDisposable;
23
+ declare function renderStatusBarPart(container: HTMLElement): IDisposable;
24
+ declare function isEditorPartVisible(): boolean;
25
+ type InitializationStateTransformer = (state: ILayoutInitializationState) => ILayoutInitializationState;
26
+ declare function getServiceOverride(openEditorFallback?: OpenEditor, _webviewIframeAlternateDomains?: string): IEditorOverrideServices;
27
+ /**
28
+ * @deprecated Provide restoreEditors with the initializationState.editor.restoreEditors params
29
+ */
30
+ declare function getServiceOverride(openEditorFallback?: OpenEditor, _webviewIframeAlternateDomains?: string, restoreEditors?: boolean): IEditorOverrideServices;
31
+ declare function getServiceOverride(openEditorFallback?: OpenEditor, _webviewIframeAlternateDomains?: string, initializationState?: InitializationStateTransformer): IEditorOverrideServices;
32
+ export default getServiceOverride;
33
+ export { GroupOrientation, renderPart, renderSidebarPart, renderActivitybarPar, renderAuxiliaryPart, renderPanelPart, renderEditorPart, renderStatusBarPart, isEditorPartVisible, attachPart, onPartVisibilityChange, Position, ActivityService, SidebarPart, ActivitybarPart, PanelPart };
34
+ export type { ILayoutInitializationState, InitializationStateTransformer, OpenEditor, IEditorOptions, IResolvedTextEditorModel, IReference };
package/index.js CHANGED
@@ -1,18 +1,575 @@
1
- export { attachPart, default, isEditorPartVisible, onPartVisibilityChange, renderActivitybarPar, renderAuxiliaryPart, renderEditorPart, renderPanelPart, renderPart, renderSidebarPart, renderStatusBarPart } from './views.js';
2
- export { ActivityService } from 'vscode/vscode/vs/workbench/services/activity/browser/activityService';
3
- export { ActivitybarPart } from '@codingame/monaco-vscode-view-common-views-workbench-common/vscode/vs/workbench/browser/parts/activitybar/activitybarPart';
1
+
2
+ import { __decorate, __param } from 'vscode/external/tslib/tslib.es6';
3
+ import { StandaloneServices } from 'vscode/vscode/vs/editor/standalone/browser/standaloneServices';
4
+ import { SyncDescriptor } from 'vscode/vscode/vs/platform/instantiation/common/descriptors';
5
+ import { ViewContainerLocation } from 'vscode/vscode/vs/workbench/common/views';
6
+ export { ViewContainerLocation } from 'vscode/vscode/vs/workbench/common/views';
7
+ import { IViewDescriptorService } from 'vscode/vscode/vs/workbench/common/views.service';
8
+ import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
9
+ import { SidebarPart } from '@codingame/monaco-vscode-6980eeab-47bb-5a48-8e15-32caf0785565-common/vscode/vs/workbench/browser/parts/sidebar/sidebarPart';
10
+ export { SidebarPart } from '@codingame/monaco-vscode-6980eeab-47bb-5a48-8e15-32caf0785565-common/vscode/vs/workbench/browser/parts/sidebar/sidebarPart';
11
+ export { ActivityService } from '@codingame/monaco-vscode-cc2b8dc7-d125-518e-bf7e-99a1db5babd1-common/vscode/vs/workbench/services/activity/browser/activityService';
12
+ import { IPaneCompositePartService } from 'vscode/vscode/vs/workbench/services/panecomposite/browser/panecomposite.service';
13
+ export { ActivitybarPart } from '@codingame/monaco-vscode-0cc5da60-f921-59b9-bd8c-a018e93c0a6f-common/vscode/vs/workbench/browser/parts/activitybar/activitybarPart';
14
+ import { PanelPart } from '@codingame/monaco-vscode-6980eeab-47bb-5a48-8e15-32caf0785565-common/vscode/vs/workbench/browser/parts/panel/panelPart';
15
+ export { PanelPart } from '@codingame/monaco-vscode-6980eeab-47bb-5a48-8e15-32caf0785565-common/vscode/vs/workbench/browser/parts/panel/panelPart';
16
+ import { URI } from 'vscode/vscode/vs/base/common/uri';
17
+ import '@codingame/monaco-vscode-d8236b3b-b91a-522d-89f4-94d70a546f6a-common/vscode/vs/workbench/browser/part';
18
+ import '@codingame/monaco-vscode-6980eeab-47bb-5a48-8e15-32caf0785565-common/vscode/vs/workbench/browser/parts/editor/editorPart';
19
+ import { GroupsOrder } from 'vscode/vscode/vs/workbench/services/editor/common/editorGroupsService';
4
20
  export { GroupOrientation } from 'vscode/vscode/vs/workbench/services/editor/common/editorGroupsService';
21
+ import { IEditorGroupsService } from 'vscode/vscode/vs/workbench/services/editor/common/editorGroupsService.service';
22
+ import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService.service';
23
+ import { pathsToEditors, isResourceEditorInput } from 'vscode/vscode/vs/workbench/common/editor';
5
24
  export { EditorInputCapabilities } from 'vscode/vscode/vs/workbench/common/editor';
6
- export { Parts, Position } from 'vscode/vscode/vs/workbench/services/layout/browser/layoutService';
7
- export { EditorPane, SimpleEditorInput, SimpleEditorPane, getPanelPosition, getSideBarPosition, isPartVisibile, onDidChangePanelPosition, onDidChangeSideBarPosition, registerCustomView, registerEditor, registerEditorPane, registerEditorSerializer, setPartVisibility, viewContainerRegistry, viewRegistry } from './tools/views.js';
8
- export { ViewContainerLocation } from 'vscode/vscode/vs/workbench/common/views';
9
- export { ViewPaneContainer } from 'vscode/vscode/vs/workbench/browser/parts/views/viewPaneContainer';
10
- export { ConfirmResult } from 'vscode/vscode/vs/platform/dialogs/common/dialogs';
25
+ import { Parts, Position, positionToString } from '@codingame/monaco-vscode-e571cbbb-526b-5d8b-92c5-a0437d2dabb3-common/vscode/vs/workbench/services/layout/browser/layoutService';
26
+ export { Parts, Position } from '@codingame/monaco-vscode-e571cbbb-526b-5d8b-92c5-a0437d2dabb3-common/vscode/vs/workbench/services/layout/browser/layoutService';
27
+ import { StorageScope } from 'vscode/vscode/vs/platform/storage/common/storage';
28
+ import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage.service';
29
+ import { IFileService } from 'vscode/vscode/vs/platform/files/common/files.service';
30
+ import { ILayoutService } from 'vscode/vscode/vs/platform/layout/browser/layoutService.service';
31
+ import { StartupKind } from 'vscode/vscode/vs/workbench/services/lifecycle/common/lifecycle';
32
+ import { ILifecycleService } from 'vscode/vscode/vs/workbench/services/lifecycle/common/lifecycle.service';
33
+ import { AuxiliaryBarPart } from '@codingame/monaco-vscode-6980eeab-47bb-5a48-8e15-32caf0785565-common/vscode/vs/workbench/browser/parts/auxiliarybar/auxiliaryBarPart';
34
+ import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
35
+ import { mark } from 'vscode/vscode/vs/base/common/performance';
36
+ import { IExtensionService } from 'vscode/vscode/vs/workbench/services/extensions/common/extensions.service';
37
+ import { Promises } from 'vscode/vscode/vs/base/common/async';
38
+ import { isWeb } from 'vscode/vscode/vs/base/common/platform';
39
+ import { IEnvironmentService } from 'vscode/vscode/vs/platform/environment/common/environment.service';
40
+ import { isTemporaryWorkspace, WorkbenchState } from 'vscode/vscode/vs/platform/workspace/common/workspace';
41
+ import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace.service';
42
+ import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration.service';
43
+ import { coalesce } from 'vscode/vscode/vs/base/common/arrays';
44
+ import { IWorkingCopyBackupService } from 'vscode/vscode/vs/workbench/services/workingCopy/common/workingCopyBackup.service';
45
+ import { EditorParts } from '@codingame/monaco-vscode-6980eeab-47bb-5a48-8e15-32caf0785565-common/vscode/vs/workbench/browser/parts/editor/editorParts';
46
+ import { MonacoDelegateEditorGroupsService, MonacoEditorService } from '@codingame/monaco-vscode-e97d19fd-ad95-5915-8104-6f1a86c7b652-common/service-override/tools/editor';
47
+ import '@codingame/monaco-vscode-layout-service-override';
48
+ import getServiceOverride$2 from '@codingame/monaco-vscode-quickaccess-service-override';
49
+ import getServiceOverride$3 from '@codingame/monaco-vscode-keybindings-service-override';
50
+ import getServiceOverride$1 from '@codingame/monaco-vscode-view-common-service-override';
51
+ import { onRenderWorkbench } from 'vscode/lifecycle';
52
+ import 'vscode/monaco';
53
+ export { EditorPane, SimpleEditorInput, SimpleEditorPane, getPanelPosition, getSideBarPosition, isPartVisibile, onDidChangePanelPosition, onDidChangeSideBarPosition, registerCustomView, registerEditor, registerEditorPane, registerEditorSerializer, setPartVisibility, viewContainerRegistry, viewRegistry } from '@codingame/monaco-vscode-0ccdeafc-77d6-5aa8-b465-b7d03b8fb10f-common/service-override/tools/views';
54
+ export { ViewPaneContainer } from '@codingame/monaco-vscode-9e888134-1a6f-58d9-b0e6-0fc047448366-common/vscode/vs/workbench/browser/parts/views/viewPaneContainer';
55
+ export { ConfirmResult } from '@codingame/monaco-vscode-d6e33d82-c101-549d-a885-0807ab3e0cfb-common/vscode/vs/platform/dialogs/common/dialogs';
11
56
  export { RegisteredEditorPriority } from 'vscode/vscode/vs/workbench/services/editor/common/editorResolverService';
12
- export { AbstractResourceEditorInput } from 'vscode/vscode/vs/workbench/common/editor/resourceEditorInput';
13
- export { AbstractTextResourceEditorInput } from 'vscode/vscode/vs/workbench/common/editor/textResourceEditorInput';
57
+ export { AbstractResourceEditorInput } from '@codingame/monaco-vscode-0139c6af-2375-559c-af57-b738f2fd6d8e-common/vscode/vs/workbench/common/editor/resourceEditorInput';
58
+ export { AbstractTextResourceEditorInput } from '@codingame/monaco-vscode-0139c6af-2375-559c-af57-b738f2fd6d8e-common/vscode/vs/workbench/common/editor/textResourceEditorInput';
14
59
  export { EditorInput } from 'vscode/vscode/vs/workbench/common/editor/editorInput';
15
60
  export { SplitView } from 'vscode/vscode/vs/base/browser/ui/splitview/splitview';
16
61
  export { DomScrollableElement } from 'vscode/vscode/vs/base/browser/ui/scrollbar/scrollableElement';
17
- export { PanelPart } from '@codingame/monaco-vscode-view-common-views-workbench-common/vscode/vs/workbench/browser/parts/panel/panelPart';
18
- export { SidebarPart } from '@codingame/monaco-vscode-view-common-views-workbench-common/vscode/vs/workbench/browser/parts/sidebar/sidebarPart';
62
+
63
+ function createPart(id, role, classes) {
64
+ const part = document.createElement(role === 'status' ? 'footer' : 'div');
65
+ part.classList.add('part', 'monaco-workbench-part', ...classes);
66
+ part.id = id;
67
+ part.setAttribute('role', role);
68
+ if (role === 'status') {
69
+ part.setAttribute('aria-live', 'off');
70
+ }
71
+ return part;
72
+ }
73
+ function layoutPart(part) {
74
+ const parent = part.getContainer()?.parentNode;
75
+ if (parent == null) {
76
+ return;
77
+ }
78
+ part.layout(Math.max(part.minimumWidth, Math.min(part.maximumWidth, parent.offsetWidth)), Math.max(part.minimumHeight, Math.min(part.maximumHeight, parent.offsetHeight)), parent.offsetTop, parent.offsetLeft);
79
+ }
80
+ function renderPart(partContainer, part) {
81
+ partContainer.oncontextmenu = () => false;
82
+ function layout() {
83
+ layoutPart(part);
84
+ }
85
+ part.onDidVisibilityChange((visible) => {
86
+ if (visible) {
87
+ layout();
88
+ }
89
+ });
90
+ layout();
91
+ }
92
+ function getPart(part) {
93
+ return StandaloneServices.get(ILayoutService).getPart(part);
94
+ }
95
+ function _attachPart(part, container) {
96
+ container.append(part.getContainer());
97
+ const observer = new ResizeObserver(() => layoutPart(part));
98
+ observer.observe(container);
99
+ return {
100
+ dispose() {
101
+ return observer.disconnect();
102
+ }
103
+ };
104
+ }
105
+ function attachPart(part, container) {
106
+ const _part = getPart(part);
107
+ if (_part == null) {
108
+ throw new Error('Part not found');
109
+ }
110
+ return _attachPart(_part, container);
111
+ }
112
+ function onPartVisibilityChange(part, listener) {
113
+ const _part = getPart(part);
114
+ if (_part == null) {
115
+ throw new Error('Part not found');
116
+ }
117
+ return _part.onDidVisibilityChange(listener);
118
+ }
119
+ function renderActivitybarPar(container) {
120
+ return attachPart(Parts.ACTIVITYBAR_PART, container);
121
+ }
122
+ function renderSidebarPart(container) {
123
+ return attachPart(Parts.SIDEBAR_PART, container);
124
+ }
125
+ function renderPanelPart(container) {
126
+ return attachPart(Parts.PANEL_PART, container);
127
+ }
128
+ function renderAuxiliaryPart(container) {
129
+ return attachPart(Parts.AUXILIARYBAR_PART, container);
130
+ }
131
+ function renderEditorPart(container) {
132
+ return attachPart(Parts.EDITOR_PART, container);
133
+ }
134
+ function renderStatusBarPart(container) {
135
+ return attachPart(Parts.STATUSBAR_PART, container);
136
+ }
137
+ function isElementVisible(el) {
138
+ if (!el.isConnected) {
139
+ return false;
140
+ }
141
+ if (el.checkVisibility != null) {
142
+ return el.checkVisibility({
143
+ checkOpacity: true,
144
+ checkVisibilityCSS: true
145
+ });
146
+ }
147
+ return el.offsetHeight > 0 && el.offsetWidth > 0;
148
+ }
149
+ function isEditorPartVisible() {
150
+ const container = StandaloneServices.get(IEditorGroupsService).mainPart.getContainer();
151
+ return container != null && isElementVisible(container);
152
+ }
153
+ let MonacoEditorParts = class MonacoEditorParts extends MonacoDelegateEditorGroupsService {
154
+ constructor(instantiationService) {
155
+ super(instantiationService.createInstance(EditorParts), false, instantiationService);
156
+ this.restoreGroup = (...args) => {
157
+ return this.delegate.restoreGroup(...args);
158
+ };
159
+ }
160
+ getId() {
161
+ return 'standalone';
162
+ }
163
+ updateStyles() { }
164
+ registerPart(part) {
165
+ return this.delegate.registerPart(part);
166
+ }
167
+ bind(contextKey, group) {
168
+ return this.delegate.bind(contextKey, group);
169
+ }
170
+ get activePart() {
171
+ return this.delegate.activePart;
172
+ }
173
+ };
174
+ MonacoEditorParts = __decorate([
175
+ __param(0, IInstantiationService)
176
+ ], MonacoEditorParts);
177
+ let transformInitializationState = (state) => state;
178
+ onRenderWorkbench(async (accessor) => {
179
+ const paneCompositePartService = accessor.get(IPaneCompositePartService);
180
+ const viewDescriptorService = accessor.get(IViewDescriptorService);
181
+ const lifecycleService = accessor.get(ILifecycleService);
182
+ const storageService = accessor.get(IStorageService);
183
+ const editorGroupService = accessor.get(IEditorGroupsService);
184
+ const editorService = accessor.get(IEditorService);
185
+ const logService = accessor.get(ILogService);
186
+ const extensionService = accessor.get(IExtensionService);
187
+ const environmentService = accessor.get(IEnvironmentService);
188
+ const contextService = accessor.get(IWorkspaceContextService);
189
+ const configurationService = accessor.get(IConfigurationService);
190
+ const fileService = accessor.get(IFileService);
191
+ const workingCopyBackupService = accessor.get(IWorkingCopyBackupService);
192
+ const layoutService = accessor.get(ILayoutService);
193
+ function getInitialEditorsState() {
194
+ const defaultLayout = environmentService.options?.defaultLayout;
195
+ if (((defaultLayout?.editors != null && defaultLayout.editors.length > 0) ||
196
+ defaultLayout?.layout?.editors != null) &&
197
+ ((defaultLayout.force ?? false) || storageService.isNew(StorageScope.WORKSPACE))) {
198
+ return {
199
+ layout: defaultLayout.layout?.editors,
200
+ filesToOpenOrCreate: defaultLayout.editors?.map((editor) => {
201
+ return {
202
+ viewColumn: editor.viewColumn,
203
+ fileUri: URI.revive(editor.uri),
204
+ openOnlyIfExists: editor.openOnlyIfExists,
205
+ options: editor.options
206
+ };
207
+ })
208
+ };
209
+ }
210
+ const { filesToOpenOrCreate, filesToDiff, filesToMerge } = environmentService;
211
+ if (filesToOpenOrCreate != null || filesToDiff != null || filesToMerge != null) {
212
+ return { filesToOpenOrCreate, filesToDiff, filesToMerge };
213
+ }
214
+ return undefined;
215
+ }
216
+ function getDefaultLayoutViews(environmentService, storageService) {
217
+ const defaultLayout = environmentService.options?.defaultLayout;
218
+ if (defaultLayout == null) {
219
+ return undefined;
220
+ }
221
+ if (!(defaultLayout.force ?? false) && !storageService.isNew(StorageScope.WORKSPACE)) {
222
+ return undefined;
223
+ }
224
+ const { views } = defaultLayout;
225
+ if (views != null && views.length > 0) {
226
+ return views.map((view) => view.id);
227
+ }
228
+ return undefined;
229
+ }
230
+ function shouldRestoreEditors(contextService, initialEditorsState) {
231
+ if (isTemporaryWorkspace(contextService.getWorkspace())) {
232
+ return false;
233
+ }
234
+ const forceRestoreEditors = configurationService.getValue('window.restoreWindows') === 'preserve';
235
+ return !!forceRestoreEditors || initialEditorsState === undefined;
236
+ }
237
+ async function resolveEditorsToOpen(fileService, initialEditorsState) {
238
+ if (initialEditorsState != null) {
239
+ const filesToMerge = coalesce(await pathsToEditors(initialEditorsState.filesToMerge, fileService, logService));
240
+ if (filesToMerge.length === 4 &&
241
+ isResourceEditorInput(filesToMerge[0]) &&
242
+ isResourceEditorInput(filesToMerge[1]) &&
243
+ isResourceEditorInput(filesToMerge[2]) &&
244
+ isResourceEditorInput(filesToMerge[3])) {
245
+ return [
246
+ {
247
+ editor: {
248
+ input1: { resource: filesToMerge[0].resource },
249
+ input2: { resource: filesToMerge[1].resource },
250
+ base: { resource: filesToMerge[2].resource },
251
+ result: { resource: filesToMerge[3].resource },
252
+ options: { pinned: true }
253
+ }
254
+ }
255
+ ];
256
+ }
257
+ const filesToDiff = coalesce(await pathsToEditors(initialEditorsState.filesToDiff, fileService, logService));
258
+ if (filesToDiff.length === 2) {
259
+ return [
260
+ {
261
+ editor: {
262
+ original: { resource: filesToDiff[0].resource },
263
+ modified: { resource: filesToDiff[1].resource },
264
+ options: { pinned: true }
265
+ }
266
+ }
267
+ ];
268
+ }
269
+ const filesToOpenOrCreate = [];
270
+ const resolvedFilesToOpenOrCreate = await pathsToEditors(initialEditorsState.filesToOpenOrCreate, fileService, logService);
271
+ for (let i = 0; i < resolvedFilesToOpenOrCreate.length; i++) {
272
+ const resolvedFileToOpenOrCreate = resolvedFilesToOpenOrCreate[i];
273
+ if (resolvedFileToOpenOrCreate != null) {
274
+ filesToOpenOrCreate.push({
275
+ editor: resolvedFileToOpenOrCreate,
276
+ viewColumn: initialEditorsState.filesToOpenOrCreate?.[i].viewColumn
277
+ });
278
+ }
279
+ }
280
+ return filesToOpenOrCreate;
281
+ }
282
+ else if (contextService.getWorkbenchState() === WorkbenchState.EMPTY &&
283
+ configurationService.getValue('workbench.startupEditor') === 'newUntitledFile') {
284
+ if (editorGroupService.mainPart.hasRestorableState) {
285
+ return [];
286
+ }
287
+ const hasBackups = await workingCopyBackupService.hasBackups();
288
+ if (hasBackups) {
289
+ return [];
290
+ }
291
+ return [
292
+ {
293
+ editor: { resource: undefined }
294
+ }
295
+ ];
296
+ }
297
+ return [];
298
+ }
299
+ const initialEditorsState = getInitialEditorsState();
300
+ if (initialEditorsState != null) {
301
+ logService.info('Initial editor state', initialEditorsState);
302
+ }
303
+ let initialLayoutState = {
304
+ layout: {
305
+ editors: initialEditorsState?.layout
306
+ },
307
+ editor: {
308
+ restoreEditors: shouldRestoreEditors(contextService, initialEditorsState),
309
+ editorsToOpen: resolveEditorsToOpen(fileService, initialEditorsState)
310
+ },
311
+ views: {
312
+ defaults: getDefaultLayoutViews(environmentService, storageService),
313
+ containerToRestore: {}
314
+ }
315
+ };
316
+ function getDefaultViewContainer(location) {
317
+ return (viewDescriptorService.getDefaultViewContainer(location) ??
318
+ viewDescriptorService.getViewContainersByLocation(location)[0]);
319
+ }
320
+ function initLayoutState() {
321
+ if (layoutService.isVisible(Parts.SIDEBAR_PART)) {
322
+ let viewContainerToRestore;
323
+ if (!environmentService.isBuilt ||
324
+ lifecycleService.startupKind === StartupKind.ReloadedWindow ||
325
+ isWeb) {
326
+ viewContainerToRestore = storageService.get(SidebarPart.activeViewletSettingsKey, StorageScope.WORKSPACE, getDefaultViewContainer(ViewContainerLocation.Sidebar)?.id);
327
+ }
328
+ else {
329
+ viewContainerToRestore = getDefaultViewContainer(ViewContainerLocation.Sidebar)?.id;
330
+ }
331
+ initialLayoutState.views.containerToRestore.sideBar = viewContainerToRestore;
332
+ }
333
+ if (layoutService.isVisible(Parts.PANEL_PART)) {
334
+ const viewContainerToRestore = storageService.get(PanelPart.activePanelSettingsKey, StorageScope.WORKSPACE, getDefaultViewContainer(ViewContainerLocation.Panel)?.id);
335
+ initialLayoutState.views.containerToRestore.panel = viewContainerToRestore;
336
+ }
337
+ if (layoutService.isVisible(Parts.AUXILIARYBAR_PART)) {
338
+ const viewContainerToRestore = storageService.get(AuxiliaryBarPart.activePanelSettingsKey, StorageScope.WORKSPACE, getDefaultViewContainer(ViewContainerLocation.AuxiliaryBar)?.id);
339
+ initialLayoutState.views.containerToRestore.auxiliaryBar = viewContainerToRestore;
340
+ }
341
+ }
342
+ initLayoutState();
343
+ initialLayoutState = transformInitializationState(initialLayoutState);
344
+ if (initialLayoutState.views.containerToRestore.sideBar == null) {
345
+ layoutService.setPartHidden(true, Parts.SIDEBAR_PART);
346
+ }
347
+ if (initialLayoutState.views.containerToRestore.panel == null) {
348
+ layoutService.setPartHidden(true, Parts.PANEL_PART);
349
+ }
350
+ if (initialLayoutState.views.containerToRestore.auxiliaryBar == null) {
351
+ layoutService.setPartHidden(true, Parts.AUXILIARYBAR_PART);
352
+ }
353
+ const invisibleContainer = document.createElement('div');
354
+ invisibleContainer.style.display = 'none';
355
+ document.body.append(invisibleContainer);
356
+ for (const { id, role, classes, options, getPosition, onDidChangePosition } of [
357
+ { id: Parts.TITLEBAR_PART, role: 'none', classes: ['titlebar'] },
358
+ { id: Parts.BANNER_PART, role: 'banner', classes: ['banner'] },
359
+ {
360
+ id: Parts.ACTIVITYBAR_PART,
361
+ role: 'none',
362
+ classes: ['activitybar'],
363
+ getPosition: () => layoutService.getSideBarPosition(),
364
+ onDidChangePosition: layoutService.onDidChangeSideBarPosition
365
+ },
366
+ {
367
+ id: Parts.SIDEBAR_PART,
368
+ role: 'none',
369
+ classes: ['sidebar'],
370
+ getPosition: () => layoutService.getSideBarPosition(),
371
+ onDidChangePosition: layoutService.onDidChangeSideBarPosition
372
+ },
373
+ {
374
+ id: Parts.EDITOR_PART,
375
+ role: 'main',
376
+ classes: ['editor'],
377
+ options: { restorePreviousState: initialLayoutState.editor.restoreEditors }
378
+ },
379
+ {
380
+ id: Parts.PANEL_PART,
381
+ role: 'none',
382
+ classes: ['panel', 'basepanel'],
383
+ getPosition: () => layoutService.getPanelPosition(),
384
+ onDidChangePosition: layoutService.onDidChangePanelPosition
385
+ },
386
+ {
387
+ id: Parts.AUXILIARYBAR_PART,
388
+ role: 'none',
389
+ classes: ['auxiliarybar', 'basepanel'],
390
+ getPosition: () => layoutService.getSideBarPosition() === Position.LEFT ? Position.RIGHT : Position.LEFT,
391
+ onDidChangePosition: layoutService.onDidChangeSideBarPosition
392
+ },
393
+ { id: Parts.STATUSBAR_PART, role: 'status', classes: ['statusbar'] }
394
+ ]) {
395
+ const part = layoutService.getPart(id);
396
+ if (part != null) {
397
+ const partContainer = createPart(id, role, classes);
398
+ part.create(partContainer, options);
399
+ renderPart(partContainer, part);
400
+ part.layout(9999, 9999, 0, 0);
401
+ invisibleContainer.append(partContainer);
402
+ if (getPosition != null) {
403
+ let position = getPosition();
404
+ part.element.classList.add(positionToString(position));
405
+ onDidChangePosition?.(() => {
406
+ part.element.classList.remove(positionToString(position));
407
+ position = getPosition();
408
+ part.element.classList.add(positionToString(position));
409
+ });
410
+ }
411
+ }
412
+ }
413
+ const layoutReadyPromises = [];
414
+ const layoutRestoredPromises = [];
415
+ layoutReadyPromises.push((async () => {
416
+ mark('code/willRestoreEditors');
417
+ await editorGroupService.mainPart.whenReady;
418
+ mark('code/restoreEditors/editorGroupsReady');
419
+ if (initialLayoutState.layout?.editors != null) {
420
+ editorGroupService.applyLayout(initialLayoutState.layout.editors);
421
+ }
422
+ const editors = await initialLayoutState.editor.editorsToOpen;
423
+ mark('code/restoreEditors/editorsToOpenResolved');
424
+ let openEditorsPromise;
425
+ if (editors.length > 0) {
426
+ const editorGroupsInVisualOrder = editorGroupService.getGroups(GroupsOrder.GRID_APPEARANCE);
427
+ const mapEditorsToGroup = new Map();
428
+ for (const editor of editors) {
429
+ const group = editorGroupsInVisualOrder[(editor.viewColumn ?? 1) - 1];
430
+ let editorsByGroup = mapEditorsToGroup.get(group.id);
431
+ if (editorsByGroup == null) {
432
+ editorsByGroup = new Set();
433
+ mapEditorsToGroup.set(group.id, editorsByGroup);
434
+ }
435
+ editorsByGroup.add(editor.editor);
436
+ }
437
+ openEditorsPromise = Promise.all(Array.from(mapEditorsToGroup).map(async ([groupId, editors]) => {
438
+ try {
439
+ await editorService.openEditors(Array.from(editors), groupId, { validateTrust: true });
440
+ }
441
+ catch (error) {
442
+ logService.error(error);
443
+ }
444
+ }));
445
+ }
446
+ layoutRestoredPromises.push(Promise.all([
447
+ openEditorsPromise?.finally(() => mark('code/restoreEditors/editorsOpened')),
448
+ editorGroupService.mainPart.whenRestored.finally(() => mark('code/restoreEditors/editorGroupsRestored'))
449
+ ]).finally(() => {
450
+ mark('code/didRestoreEditors');
451
+ }));
452
+ })());
453
+ const restoreDefaultViewsPromise = (async () => {
454
+ if (initialLayoutState.views.defaults != null && initialLayoutState.views.defaults.length > 0) {
455
+ mark('code/willOpenDefaultViews');
456
+ const locationsRestored = [];
457
+ const tryOpenView = (view) => {
458
+ const location = viewDescriptorService.getViewLocationById(view.id);
459
+ if (location !== null) {
460
+ const container = viewDescriptorService.getViewContainerByViewId(view.id);
461
+ if (container != null) {
462
+ if (view.order >= (locationsRestored[location]?.order ?? 0)) {
463
+ locationsRestored[location] = { id: container.id, order: view.order };
464
+ }
465
+ const containerModel = viewDescriptorService.getViewContainerModel(container);
466
+ containerModel.setCollapsed(view.id, false);
467
+ containerModel.setVisible(view.id, true);
468
+ return true;
469
+ }
470
+ }
471
+ return false;
472
+ };
473
+ const defaultViews = [...initialLayoutState.views.defaults]
474
+ .reverse()
475
+ .map((v, index) => ({ id: v, order: index }));
476
+ let i = defaultViews.length;
477
+ while (i > 0) {
478
+ i--;
479
+ if (tryOpenView(defaultViews[i])) {
480
+ defaultViews.splice(i, 1);
481
+ }
482
+ }
483
+ if (defaultViews.length > 0) {
484
+ await extensionService.whenInstalledExtensionsRegistered();
485
+ let i = defaultViews.length;
486
+ while (i > 0) {
487
+ i--;
488
+ if (tryOpenView(defaultViews[i])) {
489
+ defaultViews.splice(i, 1);
490
+ }
491
+ }
492
+ }
493
+ if (locationsRestored[ViewContainerLocation.Sidebar] != null) {
494
+ initialLayoutState.views.containerToRestore.sideBar =
495
+ locationsRestored[ViewContainerLocation.Sidebar].id;
496
+ }
497
+ if (locationsRestored[ViewContainerLocation.Panel] != null) {
498
+ initialLayoutState.views.containerToRestore.panel =
499
+ locationsRestored[ViewContainerLocation.Panel].id;
500
+ }
501
+ if (locationsRestored[ViewContainerLocation.AuxiliaryBar] != null) {
502
+ initialLayoutState.views.containerToRestore.auxiliaryBar =
503
+ locationsRestored[ViewContainerLocation.AuxiliaryBar].id;
504
+ }
505
+ mark('code/didOpenDefaultViews');
506
+ }
507
+ })();
508
+ layoutReadyPromises.push(restoreDefaultViewsPromise);
509
+ layoutReadyPromises.push((async () => {
510
+ await restoreDefaultViewsPromise;
511
+ if (initialLayoutState.views.containerToRestore.sideBar == null) {
512
+ return;
513
+ }
514
+ mark('code/willRestoreViewlet');
515
+ const viewlet = await paneCompositePartService.openPaneComposite(initialLayoutState.views.containerToRestore.sideBar, ViewContainerLocation.Sidebar);
516
+ if (viewlet == null) {
517
+ await paneCompositePartService.openPaneComposite(getDefaultViewContainer(ViewContainerLocation.Sidebar)?.id, ViewContainerLocation.Sidebar);
518
+ }
519
+ mark('code/didRestoreViewlet');
520
+ })());
521
+ layoutReadyPromises.push((async () => {
522
+ await restoreDefaultViewsPromise;
523
+ if (initialLayoutState.views.containerToRestore.panel == null) {
524
+ return;
525
+ }
526
+ mark('code/willRestorePanel');
527
+ const panel = await paneCompositePartService.openPaneComposite(initialLayoutState.views.containerToRestore.panel, ViewContainerLocation.Panel);
528
+ if (panel == null) {
529
+ await paneCompositePartService.openPaneComposite(getDefaultViewContainer(ViewContainerLocation.Panel)?.id, ViewContainerLocation.Panel);
530
+ }
531
+ mark('code/didRestorePanel');
532
+ })());
533
+ layoutReadyPromises.push((async () => {
534
+ await restoreDefaultViewsPromise;
535
+ if (initialLayoutState.views.containerToRestore.auxiliaryBar == null) {
536
+ return;
537
+ }
538
+ mark('code/willRestoreAuxiliaryBar');
539
+ const panel = await paneCompositePartService.openPaneComposite(initialLayoutState.views.containerToRestore.auxiliaryBar, ViewContainerLocation.AuxiliaryBar);
540
+ if (panel == null) {
541
+ await paneCompositePartService.openPaneComposite(getDefaultViewContainer(ViewContainerLocation.AuxiliaryBar)?.id, ViewContainerLocation.AuxiliaryBar);
542
+ }
543
+ mark('code/didRestoreAuxiliaryBar');
544
+ })());
545
+ await Promises.settled(layoutReadyPromises);
546
+ await Promises.settled(layoutRestoredPromises);
547
+ });
548
+ function getServiceOverride(openEditorFallback, _webviewIframeAlternateDomains, initializationStateOrRestoreEditors) {
549
+ if (initializationStateOrRestoreEditors != null) {
550
+ transformInitializationState =
551
+ typeof initializationStateOrRestoreEditors === 'boolean'
552
+ ? (state) => ({
553
+ ...state,
554
+ editor: {
555
+ ...state.editor,
556
+ restoreEditors: initializationStateOrRestoreEditors
557
+ }
558
+ })
559
+ : initializationStateOrRestoreEditors;
560
+ }
561
+ return {
562
+ ...getServiceOverride$1(_webviewIframeAlternateDomains),
563
+ ...getServiceOverride$2({
564
+ isKeybindingConfigurationVisible: isEditorPartVisible,
565
+ shouldUseGlobalPicker: isEditorPartVisible
566
+ }),
567
+ ...getServiceOverride$3({
568
+ shouldUseGlobalKeybindings: isEditorPartVisible
569
+ }),
570
+ [IEditorGroupsService.toString()]: new SyncDescriptor(MonacoEditorParts, [], false),
571
+ [IEditorService.toString()]: new SyncDescriptor(MonacoEditorService, [openEditorFallback, isEditorPartVisible], false)
572
+ };
573
+ }
574
+
575
+ export { attachPart, getServiceOverride as default, isEditorPartVisible, onPartVisibilityChange, renderActivitybarPar, renderAuxiliaryPart, renderEditorPart, renderPanelPart, renderPart, renderSidebarPart, renderStatusBarPart };