@codingame/monaco-vscode-view-common-service-override 4.5.0-improve-code-splitting.1

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 (114) hide show
  1. package/assets/fake.html +10 -0
  2. package/assets/index-no-csp.html +1230 -0
  3. package/assets/index.html +1231 -0
  4. package/assets/service-worker.js +457 -0
  5. package/index.d.ts +1 -0
  6. package/index.js +1 -0
  7. package/override/vs/workbench/browser/parts/editor/textEditor.js +5 -0
  8. package/override/vs/workbench/browser/parts/editor/textEditor.weak.js +11 -0
  9. package/package.json +32 -0
  10. package/tools/editorAssets.js +4 -0
  11. package/tools/url.js +10 -0
  12. package/viewCommon.d.ts +5 -0
  13. package/viewCommon.js +105 -0
  14. package/vscode/src/vs/base/browser/deviceAccess.js +61 -0
  15. package/vscode/src/vs/base/browser/ui/centered/centeredViewLayout.js +180 -0
  16. package/vscode/src/vs/base/browser/ui/grid/grid.js +494 -0
  17. package/vscode/src/vs/base/browser/ui/grid/gridview.css.js +6 -0
  18. package/vscode/src/vs/base/browser/ui/grid/gridview.js +1113 -0
  19. package/vscode/src/vs/platform/languagePacks/common/localizedStrings.js +12 -0
  20. package/vscode/src/vs/platform/webview/common/mimeTypes.js +24 -0
  21. package/vscode/src/vs/platform/webview/common/webviewPortMapping.js +64 -0
  22. package/vscode/src/vs/workbench/api/browser/viewsExtensionPoint.js +907 -0
  23. package/vscode/src/vs/workbench/browser/actions/listCommands.js +764 -0
  24. package/vscode/src/vs/workbench/browser/actions/navigationActions.js +301 -0
  25. package/vscode/src/vs/workbench/browser/media/style.css.js +6 -0
  26. package/vscode/src/vs/workbench/browser/parts/activitybar/activitybarPart.js +671 -0
  27. package/vscode/src/vs/workbench/browser/parts/activitybar/media/activityaction.css.js +6 -0
  28. package/vscode/src/vs/workbench/browser/parts/activitybar/media/activitybarpart.css.js +6 -0
  29. package/vscode/src/vs/workbench/browser/parts/auxiliarybar/auxiliaryBarPart.js +229 -0
  30. package/vscode/src/vs/workbench/browser/parts/auxiliarybar/media/auxiliaryBarPart.css.js +6 -0
  31. package/vscode/src/vs/workbench/browser/parts/compositeBar.js +606 -0
  32. package/vscode/src/vs/workbench/browser/parts/compositePart.js +346 -0
  33. package/vscode/src/vs/workbench/browser/parts/editor/auxiliaryEditorPart.js +246 -0
  34. package/vscode/src/vs/workbench/browser/parts/editor/editor.contribution.js +1403 -0
  35. package/vscode/src/vs/workbench/browser/parts/editor/editorConfiguration.js +188 -0
  36. package/vscode/src/vs/workbench/browser/parts/editor/editorDropTarget.js +523 -0
  37. package/vscode/src/vs/workbench/browser/parts/editor/editorPart.js +1030 -0
  38. package/vscode/src/vs/workbench/browser/parts/editor/editorParts.js +391 -0
  39. package/vscode/src/vs/workbench/browser/parts/editor/media/editordroptarget.css.js +6 -0
  40. package/vscode/src/vs/workbench/browser/parts/media/compositepart.css.js +6 -0
  41. package/vscode/src/vs/workbench/browser/parts/media/paneCompositePart.css.js +6 -0
  42. package/vscode/src/vs/workbench/browser/parts/paneCompositeBar.js +643 -0
  43. package/vscode/src/vs/workbench/browser/parts/paneCompositePart.js +472 -0
  44. package/vscode/src/vs/workbench/browser/parts/paneCompositePartService.js +68 -0
  45. package/vscode/src/vs/workbench/browser/parts/panel/panelPart.js +160 -0
  46. package/vscode/src/vs/workbench/browser/parts/sidebar/media/sidebarpart.css.js +6 -0
  47. package/vscode/src/vs/workbench/browser/parts/sidebar/sidebarActions.js +39 -0
  48. package/vscode/src/vs/workbench/browser/parts/sidebar/sidebarPart.js +238 -0
  49. package/vscode/src/vs/workbench/browser/style.js +54 -0
  50. package/vscode/src/vs/workbench/browser/window.js +381 -0
  51. package/vscode/src/vs/workbench/contrib/callHierarchy/browser/callHierarchy.contribution.js +300 -0
  52. package/vscode/src/vs/workbench/contrib/callHierarchy/browser/callHierarchyPeek.js +367 -0
  53. package/vscode/src/vs/workbench/contrib/callHierarchy/browser/callHierarchyTree.js +135 -0
  54. package/vscode/src/vs/workbench/contrib/callHierarchy/browser/media/callHierarchy.css.js +6 -0
  55. package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditor.contribution.js +18 -0
  56. package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditorInputFactory.js +146 -0
  57. package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditors.js +215 -0
  58. package/vscode/src/vs/workbench/contrib/customEditor/browser/media/customEditor.css.js +6 -0
  59. package/vscode/src/vs/workbench/contrib/customEditor/common/contributedCustomEditors.js +78 -0
  60. package/vscode/src/vs/workbench/contrib/customEditor/common/customEditor.js +56 -0
  61. package/vscode/src/vs/workbench/contrib/customEditor/common/customEditorModelManager.js +63 -0
  62. package/vscode/src/vs/workbench/contrib/customEditor/common/extensionPoint.js +183 -0
  63. package/vscode/src/vs/workbench/contrib/externalUriOpener/common/externalUriOpener.contribution.js +8 -0
  64. package/vscode/src/vs/workbench/contrib/languageStatus/browser/languageStatus.contribution.js +408 -0
  65. package/vscode/src/vs/workbench/contrib/languageStatus/browser/media/languageStatus.css.js +6 -0
  66. package/vscode/src/vs/workbench/contrib/limitIndicator/browser/limitIndicator.contribution.js +147 -0
  67. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/commands/commands.js +635 -0
  68. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/commands/devCommands.js +230 -0
  69. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditor.contribution.js +75 -0
  70. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorSerializer.js +42 -0
  71. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/colors.js +81 -0
  72. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/conflictActions.js +350 -0
  73. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editorGutter.js +100 -0
  74. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/baseCodeEditorView.js +148 -0
  75. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/codeEditorView.js +106 -0
  76. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/inputCodeEditorView.js +403 -0
  77. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/resultCodeEditorView.js +199 -0
  78. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/fixedZoneWidget.js +41 -0
  79. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/lineAlignment.js +128 -0
  80. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/media/mergeEditor.css.js +6 -0
  81. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/mergeEditor.js +619 -0
  82. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/scrollSynchronizer.js +161 -0
  83. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/viewModel.js +266 -0
  84. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/viewZones.js +173 -0
  85. package/vscode/src/vs/workbench/contrib/preferences/browser/keyboardLayoutPicker.js +195 -0
  86. package/vscode/src/vs/workbench/contrib/sash/browser/sash.contribution.js +38 -0
  87. package/vscode/src/vs/workbench/contrib/sash/browser/sash.js +41 -0
  88. package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/media/typeHierarchy.css.js +6 -0
  89. package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/typeHierarchy.contribution.js +283 -0
  90. package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/typeHierarchyPeek.js +362 -0
  91. package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/typeHierarchyTree.js +133 -0
  92. package/vscode/src/vs/workbench/contrib/webview/browser/overlayWebview.js +314 -0
  93. package/vscode/src/vs/workbench/contrib/webview/browser/resourceLoading.js +96 -0
  94. package/vscode/src/vs/workbench/contrib/webview/browser/themeing.js +98 -0
  95. package/vscode/src/vs/workbench/contrib/webview/browser/webviewElement.js +656 -0
  96. package/vscode/src/vs/workbench/contrib/webview/browser/webviewFindWidget.js +65 -0
  97. package/vscode/src/vs/workbench/contrib/webview/browser/webviewService.js +59 -0
  98. package/vscode/src/vs/workbench/contrib/webviewPanel/browser/webviewCommands.js +143 -0
  99. package/vscode/src/vs/workbench/contrib/webviewPanel/browser/webviewEditorInputSerializer.js +121 -0
  100. package/vscode/src/vs/workbench/contrib/webviewPanel/browser/webviewPanel.contribution.js +67 -0
  101. package/vscode/src/vs/workbench/contrib/webviewView/browser/webviewViewPane.js +234 -0
  102. package/vscode/src/vs/workbench/contrib/webviewView/browser/webviewViewService.js +45 -0
  103. package/vscode/src/vs/workbench/services/activity/browser/activityService.js +145 -0
  104. package/vscode/src/vs/workbench/services/auxiliaryWindow/browser/auxiliaryWindowService.js +341 -0
  105. package/vscode/src/vs/workbench/services/driver/browser/driver.js +186 -0
  106. package/vscode/src/vs/workbench/services/editor/browser/editorPaneService.js +13 -0
  107. package/vscode/src/vs/workbench/services/editor/browser/editorResolverService.js +676 -0
  108. package/vscode/src/vs/workbench/services/history/browser/historyService.js +1516 -0
  109. package/vscode/src/vs/workbench/services/progress/browser/media/progressService.css.js +6 -0
  110. package/vscode/src/vs/workbench/services/progress/browser/progressService.js +527 -0
  111. package/vscode/src/vs/workbench/services/untitled/common/untitledTextEditorHandler.js +102 -0
  112. package/vscode/src/vs/workbench/services/untitled/common/untitledTextEditorService.js +133 -0
  113. package/vscode/src/vs/workbench/services/views/browser/viewDescriptorService.js +711 -0
  114. package/vscode/src/vs/workbench/services/views/common/viewContainerModel.js +603 -0
@@ -0,0 +1,603 @@
1
+ import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
+ import { VIEWS_LOG_ID, VIEWS_LOG_NAME, Extensions, defaultViewIcon } from 'vscode/vscode/vs/workbench/common/views';
3
+ import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey.service';
4
+ import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage.service';
5
+ import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
6
+ import { Disposable, DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
7
+ import { Emitter, Event } from 'vscode/vscode/vs/base/common/event';
8
+ import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
9
+ import { URI } from 'vscode/vscode/vs/base/common/uri';
10
+ import { coalesce, move } from 'vscode/vscode/vs/base/common/arrays';
11
+ import { isUndefined, isUndefinedOrNull } from 'vscode/vscode/vs/base/common/types';
12
+ import { isEqual } from 'vscode/vscode/vs/base/common/resources';
13
+ import { ThemeIcon } from 'vscode/vscode/vs/base/common/themables';
14
+ import { ILoggerService } from 'vscode/vscode/vs/platform/log/common/log.service';
15
+ import { registerAction2, Action2 } from 'vscode/vscode/vs/platform/actions/common/actions';
16
+ import { Categories } from 'vscode/vscode/vs/platform/action/common/actionCommonCategories';
17
+ import { IOutputService } from 'vscode/vscode/vs/workbench/services/output/common/output.service';
18
+ import { CounterSet } from 'vscode/vscode/vs/base/common/map';
19
+ import { localize2WithPath } from 'vscode/vscode/vs/nls';
20
+
21
+ registerAction2(class extends Action2 {
22
+ constructor() {
23
+ super({
24
+ id: '_workbench.output.showViewsLog',
25
+ title: ( localize2WithPath(
26
+ 'vs/workbench/services/views/common/viewContainerModel',
27
+ 'showViewsLog',
28
+ "Show Views Log"
29
+ )),
30
+ category: Categories.Developer,
31
+ f1: true
32
+ });
33
+ }
34
+ async run(servicesAccessor) {
35
+ const loggerService = servicesAccessor.get(ILoggerService);
36
+ const outputService = servicesAccessor.get(IOutputService);
37
+ loggerService.setVisibility(VIEWS_LOG_ID, true);
38
+ outputService.showChannel(VIEWS_LOG_ID);
39
+ }
40
+ });
41
+ function getViewsStateStorageId(viewContainerStorageId) { return `${viewContainerStorageId}.hidden`; }
42
+ let ViewDescriptorsState = class ViewDescriptorsState extends Disposable {
43
+ constructor(viewContainerStorageId, viewContainerName, storageService, loggerService) {
44
+ super();
45
+ this.viewContainerName = viewContainerName;
46
+ this.storageService = storageService;
47
+ this._onDidChangeStoredState = this._register(( new Emitter()));
48
+ this.onDidChangeStoredState = this._onDidChangeStoredState.event;
49
+ this.logger = loggerService.createLogger(VIEWS_LOG_ID, { name: VIEWS_LOG_NAME, hidden: true });
50
+ this.globalViewsStateStorageId = getViewsStateStorageId(viewContainerStorageId);
51
+ this.workspaceViewsStateStorageId = viewContainerStorageId;
52
+ this._register(this.storageService.onDidChangeValue(0 , this.globalViewsStateStorageId, this._register(( new DisposableStore())))(() => this.onDidStorageChange()));
53
+ this.state = this.initialize();
54
+ }
55
+ set(id, state) {
56
+ this.state.set(id, state);
57
+ }
58
+ get(id) {
59
+ return this.state.get(id);
60
+ }
61
+ updateState(viewDescriptors) {
62
+ this.updateWorkspaceState(viewDescriptors);
63
+ this.updateGlobalState(viewDescriptors);
64
+ }
65
+ updateWorkspaceState(viewDescriptors) {
66
+ const storedViewsStates = this.getStoredWorkspaceState();
67
+ for (const viewDescriptor of viewDescriptors) {
68
+ const viewState = this.get(viewDescriptor.id);
69
+ if (viewState) {
70
+ storedViewsStates[viewDescriptor.id] = {
71
+ collapsed: !!viewState.collapsed,
72
+ isHidden: !viewState.visibleWorkspace,
73
+ size: viewState.size,
74
+ order: viewDescriptor.workspace && viewState ? viewState.order : undefined
75
+ };
76
+ }
77
+ }
78
+ if (( Object.keys(storedViewsStates)).length > 0) {
79
+ this.storageService.store(this.workspaceViewsStateStorageId, JSON.stringify(storedViewsStates), 1 , 1 );
80
+ }
81
+ else {
82
+ this.storageService.remove(this.workspaceViewsStateStorageId, 1 );
83
+ }
84
+ }
85
+ updateGlobalState(viewDescriptors) {
86
+ const storedGlobalState = this.getStoredGlobalState();
87
+ for (const viewDescriptor of viewDescriptors) {
88
+ const state = this.get(viewDescriptor.id);
89
+ storedGlobalState.set(viewDescriptor.id, {
90
+ id: viewDescriptor.id,
91
+ isHidden: state && viewDescriptor.canToggleVisibility ? !state.visibleGlobal : false,
92
+ order: !viewDescriptor.workspace && state ? state.order : undefined
93
+ });
94
+ }
95
+ this.setStoredGlobalState(storedGlobalState);
96
+ }
97
+ onDidStorageChange() {
98
+ if (this.globalViewsStatesValue !== this.getStoredGlobalViewsStatesValue() ) {
99
+ this._globalViewsStatesValue = undefined;
100
+ const storedViewsVisibilityStates = this.getStoredGlobalState();
101
+ const storedWorkspaceViewsStates = this.getStoredWorkspaceState();
102
+ const changedStates = [];
103
+ for (const [id, storedState] of storedViewsVisibilityStates) {
104
+ const state = this.get(id);
105
+ if (state) {
106
+ if (state.visibleGlobal !== !storedState.isHidden) {
107
+ if (!storedState.isHidden) {
108
+ this.logger.info(`View visibility state changed: ${id} is now visible`, this.viewContainerName);
109
+ }
110
+ changedStates.push({ id, visible: !storedState.isHidden });
111
+ }
112
+ }
113
+ else {
114
+ const workspaceViewState = storedWorkspaceViewsStates[id];
115
+ this.set(id, {
116
+ active: false,
117
+ visibleGlobal: !storedState.isHidden,
118
+ visibleWorkspace: isUndefined(workspaceViewState?.isHidden) ? undefined : !workspaceViewState?.isHidden,
119
+ collapsed: workspaceViewState?.collapsed,
120
+ order: workspaceViewState?.order,
121
+ size: workspaceViewState?.size,
122
+ });
123
+ }
124
+ }
125
+ if (changedStates.length) {
126
+ this._onDidChangeStoredState.fire(changedStates);
127
+ for (const changedState of changedStates) {
128
+ const state = this.get(changedState.id);
129
+ if (state) {
130
+ state.visibleGlobal = changedState.visible;
131
+ }
132
+ }
133
+ }
134
+ }
135
+ }
136
+ initialize() {
137
+ const viewStates = ( new Map());
138
+ const workspaceViewsStates = this.getStoredWorkspaceState();
139
+ for (const id of ( Object.keys(workspaceViewsStates))) {
140
+ const workspaceViewState = workspaceViewsStates[id];
141
+ viewStates.set(id, {
142
+ active: false,
143
+ visibleGlobal: undefined,
144
+ visibleWorkspace: isUndefined(workspaceViewState.isHidden) ? undefined : !workspaceViewState.isHidden,
145
+ collapsed: workspaceViewState.collapsed,
146
+ order: workspaceViewState.order,
147
+ size: workspaceViewState.size,
148
+ });
149
+ }
150
+ const value = this.storageService.get(this.globalViewsStateStorageId, 1 , '[]');
151
+ const { state: workspaceVisibilityStates } = this.parseStoredGlobalState(value);
152
+ if (workspaceVisibilityStates.size > 0) {
153
+ for (const { id, isHidden } of ( workspaceVisibilityStates.values())) {
154
+ const viewState = viewStates.get(id);
155
+ if (viewState) {
156
+ if (isUndefined(viewState.visibleWorkspace)) {
157
+ viewState.visibleWorkspace = !isHidden;
158
+ }
159
+ }
160
+ else {
161
+ viewStates.set(id, {
162
+ active: false,
163
+ collapsed: undefined,
164
+ visibleGlobal: undefined,
165
+ visibleWorkspace: !isHidden,
166
+ });
167
+ }
168
+ }
169
+ this.storageService.remove(this.globalViewsStateStorageId, 1 );
170
+ }
171
+ const { state, hasDuplicates } = this.parseStoredGlobalState(this.globalViewsStatesValue);
172
+ if (hasDuplicates) {
173
+ this.setStoredGlobalState(state);
174
+ }
175
+ for (const { id, isHidden, order } of ( state.values())) {
176
+ const viewState = viewStates.get(id);
177
+ if (viewState) {
178
+ viewState.visibleGlobal = !isHidden;
179
+ if (!isUndefined(order)) {
180
+ viewState.order = order;
181
+ }
182
+ }
183
+ else {
184
+ viewStates.set(id, {
185
+ active: false,
186
+ visibleGlobal: !isHidden,
187
+ order,
188
+ collapsed: undefined,
189
+ visibleWorkspace: undefined,
190
+ });
191
+ }
192
+ }
193
+ return viewStates;
194
+ }
195
+ getStoredWorkspaceState() {
196
+ return JSON.parse(this.storageService.get(this.workspaceViewsStateStorageId, 1 , '{}'));
197
+ }
198
+ getStoredGlobalState() {
199
+ return this.parseStoredGlobalState(this.globalViewsStatesValue).state;
200
+ }
201
+ setStoredGlobalState(storedGlobalState) {
202
+ this.globalViewsStatesValue = JSON.stringify([...( storedGlobalState.values())]);
203
+ }
204
+ parseStoredGlobalState(value) {
205
+ const storedValue = JSON.parse(value);
206
+ let hasDuplicates = false;
207
+ const state = storedValue.reduce((result, storedState) => {
208
+ if (typeof storedState === 'string' ) {
209
+ hasDuplicates = hasDuplicates || ( result.has(storedState));
210
+ result.set(storedState, { id: storedState, isHidden: true });
211
+ }
212
+ else {
213
+ hasDuplicates = hasDuplicates || ( result.has(storedState.id));
214
+ result.set(storedState.id, storedState);
215
+ }
216
+ return result;
217
+ }, ( new Map()));
218
+ return { state, hasDuplicates };
219
+ }
220
+ get globalViewsStatesValue() {
221
+ if (!this._globalViewsStatesValue) {
222
+ this._globalViewsStatesValue = this.getStoredGlobalViewsStatesValue();
223
+ }
224
+ return this._globalViewsStatesValue;
225
+ }
226
+ set globalViewsStatesValue(globalViewsStatesValue) {
227
+ if (this.globalViewsStatesValue !== globalViewsStatesValue) {
228
+ this._globalViewsStatesValue = globalViewsStatesValue;
229
+ this.setStoredGlobalViewsStatesValue(globalViewsStatesValue);
230
+ }
231
+ }
232
+ getStoredGlobalViewsStatesValue() {
233
+ return this.storageService.get(this.globalViewsStateStorageId, 0 , '[]');
234
+ }
235
+ setStoredGlobalViewsStatesValue(value) {
236
+ this.storageService.store(this.globalViewsStateStorageId, value, 0 , 0 );
237
+ }
238
+ };
239
+ ViewDescriptorsState = ( __decorate([
240
+ ( __param(2, IStorageService)),
241
+ ( __param(3, ILoggerService))
242
+ ], ViewDescriptorsState));
243
+ let ViewContainerModel = class ViewContainerModel extends Disposable {
244
+ get title() { return this._title; }
245
+ get icon() { return this._icon; }
246
+ get keybindingId() { return this._keybindingId; }
247
+ get allViewDescriptors() { return ( this.viewDescriptorItems.map(item => item.viewDescriptor)); }
248
+ get activeViewDescriptors() { return ( this.viewDescriptorItems.filter(item => item.state.active).map(item => item.viewDescriptor)); }
249
+ get visibleViewDescriptors() { return ( this.viewDescriptorItems.filter(item => this.isViewDescriptorVisible(item)).map(item => item.viewDescriptor)); }
250
+ constructor(viewContainer, instantiationService, contextKeyService, loggerService) {
251
+ super();
252
+ this.viewContainer = viewContainer;
253
+ this.contextKeyService = contextKeyService;
254
+ this.contextKeys = ( new CounterSet());
255
+ this.viewDescriptorItems = [];
256
+ this._onDidChangeContainerInfo = this._register(( new Emitter()));
257
+ this.onDidChangeContainerInfo = this._onDidChangeContainerInfo.event;
258
+ this._onDidChangeAllViewDescriptors = this._register(( new Emitter()));
259
+ this.onDidChangeAllViewDescriptors = this._onDidChangeAllViewDescriptors.event;
260
+ this._onDidChangeActiveViewDescriptors = this._register(( new Emitter()));
261
+ this.onDidChangeActiveViewDescriptors = this._onDidChangeActiveViewDescriptors.event;
262
+ this._onDidAddVisibleViewDescriptors = this._register(( new Emitter()));
263
+ this.onDidAddVisibleViewDescriptors = this._onDidAddVisibleViewDescriptors.event;
264
+ this._onDidRemoveVisibleViewDescriptors = this._register(( new Emitter()));
265
+ this.onDidRemoveVisibleViewDescriptors = this._onDidRemoveVisibleViewDescriptors.event;
266
+ this._onDidMoveVisibleViewDescriptors = this._register(( new Emitter()));
267
+ this.onDidMoveVisibleViewDescriptors = this._onDidMoveVisibleViewDescriptors.event;
268
+ this.logger = loggerService.createLogger(VIEWS_LOG_ID, { name: VIEWS_LOG_NAME, hidden: true });
269
+ this._register(Event.filter(contextKeyService.onDidChangeContext, e => e.affectsSome(this.contextKeys))(() => this.onDidChangeContext()));
270
+ this.viewDescriptorsState = this._register(instantiationService.createInstance(ViewDescriptorsState, viewContainer.storageId || `${viewContainer.id}.state`, typeof viewContainer.title === 'string' ? viewContainer.title : viewContainer.title.original));
271
+ this._register(this.viewDescriptorsState.onDidChangeStoredState(items => this.updateVisibility(items)));
272
+ this.updateContainerInfo();
273
+ }
274
+ updateContainerInfo() {
275
+ const useDefaultContainerInfo = this.viewContainer.alwaysUseContainerInfo || this.visibleViewDescriptors.length === 0 || ( this.visibleViewDescriptors.some(v => ( Registry.as(Extensions.ViewsRegistry)).getViewContainer(v.id) === this.viewContainer));
276
+ const title = useDefaultContainerInfo ? (typeof this.viewContainer.title === 'string' ? this.viewContainer.title : this.viewContainer.title.value) : this.visibleViewDescriptors[0]?.containerTitle || this.visibleViewDescriptors[0]?.name?.value || '';
277
+ let titleChanged = false;
278
+ if (this._title !== title) {
279
+ this._title = title;
280
+ titleChanged = true;
281
+ }
282
+ const icon = useDefaultContainerInfo ? this.viewContainer.icon : this.visibleViewDescriptors[0]?.containerIcon || defaultViewIcon;
283
+ let iconChanged = false;
284
+ if (!this.isEqualIcon(icon)) {
285
+ this._icon = icon;
286
+ iconChanged = true;
287
+ }
288
+ const keybindingId = this.viewContainer.openCommandActionDescriptor?.id ?? this.activeViewDescriptors.find(v => v.openCommandActionDescriptor)?.openCommandActionDescriptor?.id;
289
+ let keybindingIdChanged = false;
290
+ if (this._keybindingId !== keybindingId) {
291
+ this._keybindingId = keybindingId;
292
+ keybindingIdChanged = true;
293
+ }
294
+ if (titleChanged || iconChanged || keybindingIdChanged) {
295
+ this._onDidChangeContainerInfo.fire({ title: titleChanged, icon: iconChanged, keybindingId: keybindingIdChanged });
296
+ }
297
+ }
298
+ isEqualIcon(icon) {
299
+ if (URI.isUri(icon)) {
300
+ return URI.isUri(this._icon) && isEqual(icon, this._icon);
301
+ }
302
+ else if (ThemeIcon.isThemeIcon(icon)) {
303
+ return ThemeIcon.isThemeIcon(this._icon) && ThemeIcon.isEqual(icon, this._icon);
304
+ }
305
+ return icon === this._icon;
306
+ }
307
+ isVisible(id) {
308
+ const viewDescriptorItem = this.viewDescriptorItems.find(v => v.viewDescriptor.id === id);
309
+ if (!viewDescriptorItem) {
310
+ throw new Error(`Unknown view ${id}`);
311
+ }
312
+ return this.isViewDescriptorVisible(viewDescriptorItem);
313
+ }
314
+ setVisible(id, visible) {
315
+ this.updateVisibility([{ id, visible }]);
316
+ }
317
+ updateVisibility(viewDescriptors) {
318
+ const viewDescriptorItemsToHide = coalesce(( viewDescriptors.filter(({ visible }) => !visible)
319
+ .map(({ id }) => this.findAndIgnoreIfNotFound(id))));
320
+ const removed = [];
321
+ for (const { viewDescriptorItem, visibleIndex } of viewDescriptorItemsToHide) {
322
+ if (this.updateViewDescriptorItemVisibility(viewDescriptorItem, false)) {
323
+ removed.push({ viewDescriptor: viewDescriptorItem.viewDescriptor, index: visibleIndex });
324
+ }
325
+ }
326
+ if (removed.length) {
327
+ this.broadCastRemovedVisibleViewDescriptors(removed);
328
+ }
329
+ const added = [];
330
+ for (const { id, visible } of viewDescriptors) {
331
+ if (!visible) {
332
+ continue;
333
+ }
334
+ const foundViewDescriptor = this.findAndIgnoreIfNotFound(id);
335
+ if (!foundViewDescriptor) {
336
+ continue;
337
+ }
338
+ const { viewDescriptorItem, visibleIndex } = foundViewDescriptor;
339
+ if (this.updateViewDescriptorItemVisibility(viewDescriptorItem, true)) {
340
+ added.push({ index: visibleIndex, viewDescriptor: viewDescriptorItem.viewDescriptor, size: viewDescriptorItem.state.size, collapsed: !!viewDescriptorItem.state.collapsed });
341
+ }
342
+ }
343
+ if (added.length) {
344
+ this.broadCastAddedVisibleViewDescriptors(added);
345
+ }
346
+ }
347
+ updateViewDescriptorItemVisibility(viewDescriptorItem, visible) {
348
+ if (!viewDescriptorItem.viewDescriptor.canToggleVisibility) {
349
+ return false;
350
+ }
351
+ if (this.isViewDescriptorVisibleWhenActive(viewDescriptorItem) === visible) {
352
+ return false;
353
+ }
354
+ if (viewDescriptorItem.viewDescriptor.workspace) {
355
+ viewDescriptorItem.state.visibleWorkspace = visible;
356
+ }
357
+ else {
358
+ viewDescriptorItem.state.visibleGlobal = visible;
359
+ if (visible) {
360
+ this.logger.info(`Showing view ${viewDescriptorItem.viewDescriptor.id} in the container ${this.viewContainer.id}`);
361
+ }
362
+ }
363
+ return this.isViewDescriptorVisible(viewDescriptorItem) === visible;
364
+ }
365
+ isCollapsed(id) {
366
+ return !!this.find(id).viewDescriptorItem.state.collapsed;
367
+ }
368
+ setCollapsed(id, collapsed) {
369
+ const { viewDescriptorItem } = this.find(id);
370
+ if (viewDescriptorItem.state.collapsed !== collapsed) {
371
+ viewDescriptorItem.state.collapsed = collapsed;
372
+ }
373
+ this.viewDescriptorsState.updateState(this.allViewDescriptors);
374
+ }
375
+ getSize(id) {
376
+ return this.find(id).viewDescriptorItem.state.size;
377
+ }
378
+ setSizes(newSizes) {
379
+ for (const { id, size } of newSizes) {
380
+ const { viewDescriptorItem } = this.find(id);
381
+ if (viewDescriptorItem.state.size !== size) {
382
+ viewDescriptorItem.state.size = size;
383
+ }
384
+ }
385
+ this.viewDescriptorsState.updateState(this.allViewDescriptors);
386
+ }
387
+ move(from, to) {
388
+ const fromIndex = this.viewDescriptorItems.findIndex(v => v.viewDescriptor.id === from);
389
+ const toIndex = this.viewDescriptorItems.findIndex(v => v.viewDescriptor.id === to);
390
+ const fromViewDescriptor = this.viewDescriptorItems[fromIndex];
391
+ const toViewDescriptor = this.viewDescriptorItems[toIndex];
392
+ move(this.viewDescriptorItems, fromIndex, toIndex);
393
+ for (let index = 0; index < this.viewDescriptorItems.length; index++) {
394
+ this.viewDescriptorItems[index].state.order = index;
395
+ }
396
+ this.broadCastMovedViewDescriptors({ index: fromIndex, viewDescriptor: fromViewDescriptor.viewDescriptor }, { index: toIndex, viewDescriptor: toViewDescriptor.viewDescriptor });
397
+ }
398
+ add(addedViewDescriptorStates) {
399
+ const addedItems = [];
400
+ for (const addedViewDescriptorState of addedViewDescriptorStates) {
401
+ const viewDescriptor = addedViewDescriptorState.viewDescriptor;
402
+ if (viewDescriptor.when) {
403
+ for (const key of ( viewDescriptor.when.keys())) {
404
+ this.contextKeys.add(key);
405
+ }
406
+ }
407
+ let state = this.viewDescriptorsState.get(viewDescriptor.id);
408
+ if (state) {
409
+ if (viewDescriptor.workspace) {
410
+ state.visibleWorkspace = isUndefinedOrNull(addedViewDescriptorState.visible) ? (isUndefinedOrNull(state.visibleWorkspace) ? !viewDescriptor.hideByDefault : state.visibleWorkspace) : addedViewDescriptorState.visible;
411
+ }
412
+ else {
413
+ const isVisible = state.visibleGlobal;
414
+ state.visibleGlobal = isUndefinedOrNull(addedViewDescriptorState.visible) ? (isUndefinedOrNull(state.visibleGlobal) ? !viewDescriptor.hideByDefault : state.visibleGlobal) : addedViewDescriptorState.visible;
415
+ if (state.visibleGlobal && !isVisible) {
416
+ this.logger.info(`Added view ${viewDescriptor.id} in the container ${this.viewContainer.id} and showing it.`, `${isVisible}`, `${viewDescriptor.hideByDefault}`, `${addedViewDescriptorState.visible}`);
417
+ }
418
+ }
419
+ state.collapsed = isUndefinedOrNull(addedViewDescriptorState.collapsed) ? (isUndefinedOrNull(state.collapsed) ? !!viewDescriptor.collapsed : state.collapsed) : addedViewDescriptorState.collapsed;
420
+ }
421
+ else {
422
+ state = {
423
+ active: false,
424
+ visibleGlobal: isUndefinedOrNull(addedViewDescriptorState.visible) ? !viewDescriptor.hideByDefault : addedViewDescriptorState.visible,
425
+ visibleWorkspace: isUndefinedOrNull(addedViewDescriptorState.visible) ? !viewDescriptor.hideByDefault : addedViewDescriptorState.visible,
426
+ collapsed: isUndefinedOrNull(addedViewDescriptorState.collapsed) ? !!viewDescriptor.collapsed : addedViewDescriptorState.collapsed,
427
+ };
428
+ }
429
+ this.viewDescriptorsState.set(viewDescriptor.id, state);
430
+ state.active = this.contextKeyService.contextMatchesRules(viewDescriptor.when);
431
+ addedItems.push({ viewDescriptor, state });
432
+ }
433
+ this.viewDescriptorItems.push(...addedItems);
434
+ this.viewDescriptorItems.sort(this.compareViewDescriptors.bind(this));
435
+ this._onDidChangeAllViewDescriptors.fire({ added: ( addedItems.map(({ viewDescriptor }) => viewDescriptor)), removed: [] });
436
+ const addedActiveItems = [];
437
+ for (const viewDescriptorItem of addedItems) {
438
+ if (viewDescriptorItem.state.active) {
439
+ addedActiveItems.push({ viewDescriptorItem, visible: this.isViewDescriptorVisible(viewDescriptorItem) });
440
+ }
441
+ }
442
+ if (addedActiveItems.length) {
443
+ this._onDidChangeActiveViewDescriptors.fire(({ added: ( addedActiveItems.map(({ viewDescriptorItem }) => viewDescriptorItem.viewDescriptor)), removed: [] }));
444
+ }
445
+ const addedVisibleDescriptors = [];
446
+ for (const { viewDescriptorItem, visible } of addedActiveItems) {
447
+ if (visible && this.isViewDescriptorVisible(viewDescriptorItem)) {
448
+ const { visibleIndex } = this.find(viewDescriptorItem.viewDescriptor.id);
449
+ addedVisibleDescriptors.push({ index: visibleIndex, viewDescriptor: viewDescriptorItem.viewDescriptor, size: viewDescriptorItem.state.size, collapsed: !!viewDescriptorItem.state.collapsed });
450
+ }
451
+ }
452
+ this.broadCastAddedVisibleViewDescriptors(addedVisibleDescriptors);
453
+ }
454
+ remove(viewDescriptors) {
455
+ const removed = [];
456
+ const removedItems = [];
457
+ const removedActiveDescriptors = [];
458
+ const removedVisibleDescriptors = [];
459
+ for (const viewDescriptor of viewDescriptors) {
460
+ if (viewDescriptor.when) {
461
+ for (const key of ( viewDescriptor.when.keys())) {
462
+ this.contextKeys.delete(key);
463
+ }
464
+ }
465
+ const index = this.viewDescriptorItems.findIndex(i => i.viewDescriptor.id === viewDescriptor.id);
466
+ if (index !== -1) {
467
+ removed.push(viewDescriptor);
468
+ const viewDescriptorItem = this.viewDescriptorItems[index];
469
+ if (viewDescriptorItem.state.active) {
470
+ removedActiveDescriptors.push(viewDescriptorItem.viewDescriptor);
471
+ }
472
+ if (this.isViewDescriptorVisible(viewDescriptorItem)) {
473
+ const { visibleIndex } = this.find(viewDescriptorItem.viewDescriptor.id);
474
+ removedVisibleDescriptors.push({ index: visibleIndex, viewDescriptor: viewDescriptorItem.viewDescriptor });
475
+ }
476
+ removedItems.push(viewDescriptorItem);
477
+ }
478
+ }
479
+ removedItems.forEach(item => this.viewDescriptorItems.splice(this.viewDescriptorItems.indexOf(item), 1));
480
+ this.broadCastRemovedVisibleViewDescriptors(removedVisibleDescriptors);
481
+ if (removedActiveDescriptors.length) {
482
+ this._onDidChangeActiveViewDescriptors.fire(({ added: [], removed: removedActiveDescriptors }));
483
+ }
484
+ if (removed.length) {
485
+ this._onDidChangeAllViewDescriptors.fire({ added: [], removed });
486
+ }
487
+ }
488
+ onDidChangeContext() {
489
+ const addedActiveItems = [];
490
+ const removedActiveItems = [];
491
+ for (const item of this.viewDescriptorItems) {
492
+ const wasActive = item.state.active;
493
+ const isActive = this.contextKeyService.contextMatchesRules(item.viewDescriptor.when);
494
+ if (wasActive !== isActive) {
495
+ if (isActive) {
496
+ addedActiveItems.push({ item, visibleWhenActive: this.isViewDescriptorVisibleWhenActive(item) });
497
+ }
498
+ else {
499
+ removedActiveItems.push(item);
500
+ }
501
+ }
502
+ }
503
+ const removedVisibleDescriptors = [];
504
+ for (const item of removedActiveItems) {
505
+ if (this.isViewDescriptorVisible(item)) {
506
+ const { visibleIndex } = this.find(item.viewDescriptor.id);
507
+ removedVisibleDescriptors.push({ index: visibleIndex, viewDescriptor: item.viewDescriptor });
508
+ }
509
+ }
510
+ removedActiveItems.forEach(item => item.state.active = false);
511
+ addedActiveItems.forEach(({ item }) => item.state.active = true);
512
+ this.broadCastRemovedVisibleViewDescriptors(removedVisibleDescriptors);
513
+ if (addedActiveItems.length || removedActiveItems.length) {
514
+ this._onDidChangeActiveViewDescriptors.fire(({ added: ( addedActiveItems.map(({ item }) => item.viewDescriptor)), removed: ( removedActiveItems.map(item => item.viewDescriptor)) }));
515
+ }
516
+ const addedVisibleDescriptors = [];
517
+ for (const { item, visibleWhenActive } of addedActiveItems) {
518
+ if (visibleWhenActive && this.isViewDescriptorVisible(item)) {
519
+ const { visibleIndex } = this.find(item.viewDescriptor.id);
520
+ addedVisibleDescriptors.push({ index: visibleIndex, viewDescriptor: item.viewDescriptor, size: item.state.size, collapsed: !!item.state.collapsed });
521
+ }
522
+ }
523
+ this.broadCastAddedVisibleViewDescriptors(addedVisibleDescriptors);
524
+ }
525
+ broadCastAddedVisibleViewDescriptors(added) {
526
+ if (added.length) {
527
+ this._onDidAddVisibleViewDescriptors.fire(added.sort((a, b) => a.index - b.index));
528
+ this.updateState(`Added views:${( added.map(v => v.viewDescriptor.id)).join(',')} in ${this.viewContainer.id}`);
529
+ }
530
+ }
531
+ broadCastRemovedVisibleViewDescriptors(removed) {
532
+ if (removed.length) {
533
+ this._onDidRemoveVisibleViewDescriptors.fire(removed.sort((a, b) => b.index - a.index));
534
+ this.updateState(`Removed views:${( removed.map(v => v.viewDescriptor.id)).join(',')} from ${this.viewContainer.id}`);
535
+ }
536
+ }
537
+ broadCastMovedViewDescriptors(from, to) {
538
+ this._onDidMoveVisibleViewDescriptors.fire({ from, to });
539
+ this.updateState(`Moved view ${from.viewDescriptor.id} to ${to.viewDescriptor.id} in ${this.viewContainer.id}`);
540
+ }
541
+ updateState(reason) {
542
+ this.logger.info(reason);
543
+ this.viewDescriptorsState.updateState(this.allViewDescriptors);
544
+ this.updateContainerInfo();
545
+ }
546
+ isViewDescriptorVisible(viewDescriptorItem) {
547
+ if (!viewDescriptorItem.state.active) {
548
+ return false;
549
+ }
550
+ return this.isViewDescriptorVisibleWhenActive(viewDescriptorItem);
551
+ }
552
+ isViewDescriptorVisibleWhenActive(viewDescriptorItem) {
553
+ if (viewDescriptorItem.viewDescriptor.workspace) {
554
+ return !!viewDescriptorItem.state.visibleWorkspace;
555
+ }
556
+ return !!viewDescriptorItem.state.visibleGlobal;
557
+ }
558
+ find(id) {
559
+ const result = this.findAndIgnoreIfNotFound(id);
560
+ if (result) {
561
+ return result;
562
+ }
563
+ throw new Error(`view descriptor ${id} not found`);
564
+ }
565
+ findAndIgnoreIfNotFound(id) {
566
+ for (let i = 0, visibleIndex = 0; i < this.viewDescriptorItems.length; i++) {
567
+ const viewDescriptorItem = this.viewDescriptorItems[i];
568
+ if (viewDescriptorItem.viewDescriptor.id === id) {
569
+ return { index: i, visibleIndex, viewDescriptorItem: viewDescriptorItem };
570
+ }
571
+ if (this.isViewDescriptorVisible(viewDescriptorItem)) {
572
+ visibleIndex++;
573
+ }
574
+ }
575
+ return undefined;
576
+ }
577
+ compareViewDescriptors(a, b) {
578
+ if (a.viewDescriptor.id === b.viewDescriptor.id) {
579
+ return 0;
580
+ }
581
+ return (this.getViewOrder(a) - this.getViewOrder(b)) || this.getGroupOrderResult(a.viewDescriptor, b.viewDescriptor);
582
+ }
583
+ getViewOrder(viewDescriptorItem) {
584
+ const viewOrder = typeof viewDescriptorItem.state.order === 'number' ? viewDescriptorItem.state.order : viewDescriptorItem.viewDescriptor.order;
585
+ return typeof viewOrder === 'number' ? viewOrder : Number.MAX_VALUE;
586
+ }
587
+ getGroupOrderResult(a, b) {
588
+ if (!a.group || !b.group) {
589
+ return 0;
590
+ }
591
+ if (a.group === b.group) {
592
+ return 0;
593
+ }
594
+ return a.group < b.group ? -1 : 1;
595
+ }
596
+ };
597
+ ViewContainerModel = ( __decorate([
598
+ ( __param(1, IInstantiationService)),
599
+ ( __param(2, IContextKeyService)),
600
+ ( __param(3, ILoggerService))
601
+ ], ViewContainerModel));
602
+
603
+ export { ViewContainerModel, getViewsStateStorageId };