@codingame/monaco-vscode-views-service-override 2.1.3 → 2.2.0-next.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 (108) hide show
  1. package/index.d.ts +11 -9
  2. package/index.js +8 -6
  3. package/package.json +11 -11
  4. package/tools/editor.js +3 -1
  5. package/tools/views.d.ts +102 -0
  6. package/tools/views.js +253 -0
  7. package/views.d.ts +4 -99
  8. package/views.js +52 -280
  9. package/external/rollup-plugin-styles/dist/runtime/inject-css.js +0 -3
  10. package/vscode/src/vs/base/browser/ui/centered/centeredViewLayout.js +0 -180
  11. package/vscode/src/vs/base/browser/ui/grid/grid.js +0 -494
  12. package/vscode/src/vs/base/browser/ui/grid/gridview.css.js +0 -6
  13. package/vscode/src/vs/base/browser/ui/grid/gridview.js +0 -1112
  14. package/vscode/src/vs/base/common/codicons.d.ts +0 -579
  15. package/vscode/src/vs/platform/webview/common/mimeTypes.js +0 -24
  16. package/vscode/src/vs/platform/webview/common/webviewPortMapping.js +0 -64
  17. package/vscode/src/vs/workbench/api/browser/viewsExtensionPoint.js +0 -790
  18. package/vscode/src/vs/workbench/browser/actions/listCommands.js +0 -764
  19. package/vscode/src/vs/workbench/browser/layout.d.ts +0 -26
  20. package/vscode/src/vs/workbench/browser/parts/activitybar/activitybarPart.js +0 -612
  21. package/vscode/src/vs/workbench/browser/parts/activitybar/media/activityaction.css.js +0 -6
  22. package/vscode/src/vs/workbench/browser/parts/activitybar/media/activitybarpart.css.js +0 -6
  23. package/vscode/src/vs/workbench/browser/parts/auxiliarybar/auxiliaryBarPart.js +0 -150
  24. package/vscode/src/vs/workbench/browser/parts/auxiliarybar/media/auxiliaryBarPart.css.js +0 -6
  25. package/vscode/src/vs/workbench/browser/parts/compositeBar.js +0 -605
  26. package/vscode/src/vs/workbench/browser/parts/compositePart.js +0 -335
  27. package/vscode/src/vs/workbench/browser/parts/editor/auxiliaryEditorPart.js +0 -223
  28. package/vscode/src/vs/workbench/browser/parts/editor/editor.contribution.js +0 -1407
  29. package/vscode/src/vs/workbench/browser/parts/editor/editorConfiguration.js +0 -186
  30. package/vscode/src/vs/workbench/browser/parts/editor/editorDropTarget.js +0 -511
  31. package/vscode/src/vs/workbench/browser/parts/editor/editorPane.d.ts +0 -112
  32. package/vscode/src/vs/workbench/browser/parts/editor/editorPart.js +0 -1020
  33. package/vscode/src/vs/workbench/browser/parts/editor/editorParts.js +0 -391
  34. package/vscode/src/vs/workbench/browser/parts/editor/media/editordroptarget.css.js +0 -6
  35. package/vscode/src/vs/workbench/browser/parts/media/compositepart.css.js +0 -6
  36. package/vscode/src/vs/workbench/browser/parts/media/paneCompositePart.css.js +0 -6
  37. package/vscode/src/vs/workbench/browser/parts/paneCompositeBar.js +0 -645
  38. package/vscode/src/vs/workbench/browser/parts/paneCompositePart.js +0 -379
  39. package/vscode/src/vs/workbench/browser/parts/paneCompositePartService.js +0 -68
  40. package/vscode/src/vs/workbench/browser/parts/panel/panelPart.js +0 -146
  41. package/vscode/src/vs/workbench/browser/parts/sidebar/media/sidebarpart.css.js +0 -6
  42. package/vscode/src/vs/workbench/browser/parts/sidebar/sidebarPart.js +0 -222
  43. package/vscode/src/vs/workbench/contrib/callHierarchy/browser/callHierarchy.contribution.js +0 -299
  44. package/vscode/src/vs/workbench/contrib/callHierarchy/browser/callHierarchyPeek.js +0 -365
  45. package/vscode/src/vs/workbench/contrib/callHierarchy/browser/callHierarchyTree.js +0 -135
  46. package/vscode/src/vs/workbench/contrib/callHierarchy/browser/media/callHierarchy.css.js +0 -6
  47. package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditor.contribution.js +0 -17
  48. package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditorInputFactory.js +0 -145
  49. package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditors.js +0 -214
  50. package/vscode/src/vs/workbench/contrib/customEditor/browser/media/customEditor.css.js +0 -6
  51. package/vscode/src/vs/workbench/contrib/customEditor/common/contributedCustomEditors.js +0 -78
  52. package/vscode/src/vs/workbench/contrib/customEditor/common/customEditorModelManager.js +0 -63
  53. package/vscode/src/vs/workbench/contrib/customEditor/common/extensionPoint.js +0 -119
  54. package/vscode/src/vs/workbench/contrib/externalUriOpener/common/externalUriOpener.contribution.js +0 -6
  55. package/vscode/src/vs/workbench/contrib/files/browser/editors/binaryFileEditor.js +0 -79
  56. package/vscode/src/vs/workbench/contrib/files/browser/editors/fileEditorHandler.js +0 -74
  57. package/vscode/src/vs/workbench/contrib/files/browser/editors/textFileEditor.js +0 -256
  58. package/vscode/src/vs/workbench/contrib/files/browser/editors/textFileEditorTracker.js +0 -99
  59. package/vscode/src/vs/workbench/contrib/files/browser/editors/textFileSaveErrorHandler.js +0 -444
  60. package/vscode/src/vs/workbench/contrib/files/browser/explorerService.js +0 -432
  61. package/vscode/src/vs/workbench/contrib/files/browser/fileActions.contribution.js +0 -786
  62. package/vscode/src/vs/workbench/contrib/files/browser/fileCommands.js +0 -488
  63. package/vscode/src/vs/workbench/contrib/files/browser/files.contribution.js +0 -522
  64. package/vscode/src/vs/workbench/contrib/files/browser/workspaceWatcher.js +0 -152
  65. package/vscode/src/vs/workbench/contrib/files/common/dirtyFilesIndicator.js +0 -63
  66. package/vscode/src/vs/workbench/contrib/languageStatus/browser/languageStatus.contribution.js +0 -409
  67. package/vscode/src/vs/workbench/contrib/languageStatus/browser/media/languageStatus.css.js +0 -6
  68. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/commands/commands.js +0 -693
  69. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/commands/devCommands.js +0 -240
  70. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditor.contribution.js +0 -77
  71. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorSerializer.js +0 -42
  72. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/colors.js +0 -71
  73. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/conflictActions.js +0 -348
  74. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editorGutter.js +0 -98
  75. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/baseCodeEditorView.js +0 -146
  76. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/codeEditorView.js +0 -105
  77. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/inputCodeEditorView.js +0 -401
  78. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/resultCodeEditorView.js +0 -197
  79. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/fixedZoneWidget.js +0 -41
  80. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/lineAlignment.js +0 -128
  81. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/media/mergeEditor.css.js +0 -6
  82. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/mergeEditor.js +0 -612
  83. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/scrollSynchronizer.js +0 -158
  84. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/viewModel.js +0 -264
  85. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/viewZones.js +0 -173
  86. package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/media/typeHierarchy.css.js +0 -6
  87. package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/typeHierarchy.contribution.js +0 -282
  88. package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/typeHierarchyPeek.js +0 -360
  89. package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/typeHierarchyTree.js +0 -133
  90. package/vscode/src/vs/workbench/contrib/webview/browser/overlayWebview.js +0 -290
  91. package/vscode/src/vs/workbench/contrib/webview/browser/resourceLoading.js +0 -96
  92. package/vscode/src/vs/workbench/contrib/webview/browser/themeing.js +0 -88
  93. package/vscode/src/vs/workbench/contrib/webview/browser/webview.contribution.js +0 -79
  94. package/vscode/src/vs/workbench/contrib/webview/browser/webviewElement.js +0 -648
  95. package/vscode/src/vs/workbench/contrib/webview/browser/webviewFindWidget.js +0 -65
  96. package/vscode/src/vs/workbench/contrib/webview/browser/webviewService.js +0 -59
  97. package/vscode/src/vs/workbench/contrib/webviewPanel/browser/webviewCommands.js +0 -142
  98. package/vscode/src/vs/workbench/contrib/webviewPanel/browser/webviewEditorInputSerializer.js +0 -121
  99. package/vscode/src/vs/workbench/contrib/webviewPanel/browser/webviewPanel.contribution.js +0 -68
  100. package/vscode/src/vs/workbench/contrib/webviewView/browser/webviewViewPane.js +0 -235
  101. package/vscode/src/vs/workbench/services/activity/browser/activityService.js +0 -145
  102. package/vscode/src/vs/workbench/services/editor/browser/editorResolverService.js +0 -670
  103. package/vscode/src/vs/workbench/services/history/browser/historyService.js +0 -1484
  104. package/vscode/src/vs/workbench/services/progress/browser/media/progressService.css.js +0 -6
  105. package/vscode/src/vs/workbench/services/progress/browser/progressService.js +0 -523
  106. package/vscode/src/vs/workbench/services/untitled/common/untitledTextEditorHandler.js +0 -101
  107. package/vscode/src/vs/workbench/services/views/browser/viewDescriptorService.js +0 -713
  108. package/vscode/src/vs/workbench/services/views/common/viewContainerModel.js +0 -598
@@ -1,1112 +0,0 @@
1
- import { $ } from 'vscode/vscode/vs/base/browser/dom';
2
- import { Sizing, SplitView } from 'vscode/vscode/vs/base/browser/ui/splitview/splitview';
3
- export { Sizing } from 'vscode/vscode/vs/base/browser/ui/splitview/splitview';
4
- import { tail2, equals } from 'vscode/vscode/vs/base/common/arrays';
5
- import { Color } from 'vscode/vscode/vs/base/common/color';
6
- import { Event, Relay, Emitter } from 'vscode/vscode/vs/base/common/event';
7
- import { Disposable, DisposableStore, toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
8
- import { rot } from 'vscode/vscode/vs/base/common/numbers';
9
- import { isUndefined } from 'vscode/vscode/vs/base/common/types';
10
- import './gridview.css.js';
11
-
12
- const defaultStyles = {
13
- separatorBorder: Color.transparent
14
- };
15
- function orthogonal(orientation) {
16
- return orientation === 0 ? 1 : 0 ;
17
- }
18
- class LayoutController {
19
- constructor(isLayoutEnabled) {
20
- this.isLayoutEnabled = isLayoutEnabled;
21
- }
22
- }
23
- function toAbsoluteBoundarySashes(sashes, orientation) {
24
- if (orientation === 1 ) {
25
- return { left: sashes.start, right: sashes.end, top: sashes.orthogonalStart, bottom: sashes.orthogonalEnd };
26
- }
27
- else {
28
- return { top: sashes.start, bottom: sashes.end, left: sashes.orthogonalStart, right: sashes.orthogonalEnd };
29
- }
30
- }
31
- function fromAbsoluteBoundarySashes(sashes, orientation) {
32
- if (orientation === 1 ) {
33
- return { start: sashes.left, end: sashes.right, orthogonalStart: sashes.top, orthogonalEnd: sashes.bottom };
34
- }
35
- else {
36
- return { start: sashes.top, end: sashes.bottom, orthogonalStart: sashes.left, orthogonalEnd: sashes.right };
37
- }
38
- }
39
- function validateIndex(index, numChildren) {
40
- if (Math.abs(index) > numChildren) {
41
- throw new Error('Invalid index');
42
- }
43
- return rot(index, numChildren + 1);
44
- }
45
- class BranchNode {
46
- get size() { return this._size; }
47
- get orthogonalSize() { return this._orthogonalSize; }
48
- get absoluteOffset() { return this._absoluteOffset; }
49
- get absoluteOrthogonalOffset() { return this._absoluteOrthogonalOffset; }
50
- get styles() { return this._styles; }
51
- get width() {
52
- return this.orientation === 1 ? this.size : this.orthogonalSize;
53
- }
54
- get height() {
55
- return this.orientation === 1 ? this.orthogonalSize : this.size;
56
- }
57
- get top() {
58
- return this.orientation === 1 ? this._absoluteOffset : this._absoluteOrthogonalOffset;
59
- }
60
- get left() {
61
- return this.orientation === 1 ? this._absoluteOrthogonalOffset : this._absoluteOffset;
62
- }
63
- get minimumSize() {
64
- return this.children.length === 0 ? 0 : Math.max(...( this.children.map(
65
- (c, index) => this.splitview.isViewVisible(index) ? c.minimumOrthogonalSize : 0
66
- )));
67
- }
68
- get maximumSize() {
69
- return Math.min(...( this.children.map(
70
- (c, index) => this.splitview.isViewVisible(index) ? c.maximumOrthogonalSize : Number.POSITIVE_INFINITY
71
- )));
72
- }
73
- get priority() {
74
- if (this.children.length === 0) {
75
- return 0 ;
76
- }
77
- const priorities = ( this.children.map(
78
- c => typeof c.priority === 'undefined' ? 0 : c.priority
79
- ));
80
- if (( priorities.some(p => p === 2 ))) {
81
- return 2 ;
82
- }
83
- else if (( priorities.some(p => p === 1 ))) {
84
- return 1 ;
85
- }
86
- return 0 ;
87
- }
88
- get proportionalLayout() {
89
- if (this.children.length === 0) {
90
- return true;
91
- }
92
- return this.children.every(c => c.proportionalLayout);
93
- }
94
- get minimumOrthogonalSize() {
95
- return this.splitview.minimumSize;
96
- }
97
- get maximumOrthogonalSize() {
98
- return this.splitview.maximumSize;
99
- }
100
- get minimumWidth() {
101
- return this.orientation === 1 ? this.minimumOrthogonalSize : this.minimumSize;
102
- }
103
- get minimumHeight() {
104
- return this.orientation === 1 ? this.minimumSize : this.minimumOrthogonalSize;
105
- }
106
- get maximumWidth() {
107
- return this.orientation === 1 ? this.maximumOrthogonalSize : this.maximumSize;
108
- }
109
- get maximumHeight() {
110
- return this.orientation === 1 ? this.maximumSize : this.maximumOrthogonalSize;
111
- }
112
- get boundarySashes() { return this._boundarySashes; }
113
- set boundarySashes(boundarySashes) {
114
- if (this._boundarySashes.start === boundarySashes.start
115
- && this._boundarySashes.end === boundarySashes.end
116
- && this._boundarySashes.orthogonalStart === boundarySashes.orthogonalStart
117
- && this._boundarySashes.orthogonalEnd === boundarySashes.orthogonalEnd) {
118
- return;
119
- }
120
- this._boundarySashes = boundarySashes;
121
- this.splitview.orthogonalStartSash = boundarySashes.orthogonalStart;
122
- this.splitview.orthogonalEndSash = boundarySashes.orthogonalEnd;
123
- for (let index = 0; index < this.children.length; index++) {
124
- const child = this.children[index];
125
- const first = index === 0;
126
- const last = index === this.children.length - 1;
127
- child.boundarySashes = {
128
- start: boundarySashes.orthogonalStart,
129
- end: boundarySashes.orthogonalEnd,
130
- orthogonalStart: first ? boundarySashes.start : child.boundarySashes.orthogonalStart,
131
- orthogonalEnd: last ? boundarySashes.end : child.boundarySashes.orthogonalEnd,
132
- };
133
- }
134
- }
135
- get edgeSnapping() { return this._edgeSnapping; }
136
- set edgeSnapping(edgeSnapping) {
137
- if (this._edgeSnapping === edgeSnapping) {
138
- return;
139
- }
140
- this._edgeSnapping = edgeSnapping;
141
- for (const child of this.children) {
142
- if (child instanceof BranchNode) {
143
- child.edgeSnapping = edgeSnapping;
144
- }
145
- }
146
- this.updateSplitviewEdgeSnappingEnablement();
147
- }
148
- constructor(orientation, layoutController, styles, splitviewProportionalLayout, size = 0, orthogonalSize = 0, edgeSnapping = false, childDescriptors) {
149
- this.orientation = orientation;
150
- this.layoutController = layoutController;
151
- this.splitviewProportionalLayout = splitviewProportionalLayout;
152
- this.children = [];
153
- this._absoluteOffset = 0;
154
- this._absoluteOrthogonalOffset = 0;
155
- this.absoluteOrthogonalSize = 0;
156
- this._onDidChange = ( new Emitter());
157
- this.onDidChange = this._onDidChange.event;
158
- this._onDidVisibilityChange = ( new Emitter());
159
- this.onDidVisibilityChange = this._onDidVisibilityChange.event;
160
- this.childrenVisibilityChangeDisposable = ( new DisposableStore());
161
- this._onDidScroll = ( new Emitter());
162
- this.onDidScrollDisposable = Disposable.None;
163
- this.onDidScroll = this._onDidScroll.event;
164
- this.childrenChangeDisposable = Disposable.None;
165
- this._onDidSashReset = ( new Emitter());
166
- this.onDidSashReset = this._onDidSashReset.event;
167
- this.splitviewSashResetDisposable = Disposable.None;
168
- this.childrenSashResetDisposable = Disposable.None;
169
- this._boundarySashes = {};
170
- this._edgeSnapping = false;
171
- this._styles = styles;
172
- this._size = size;
173
- this._orthogonalSize = orthogonalSize;
174
- this.element = $('.monaco-grid-branch-node');
175
- if (!childDescriptors) {
176
- this.splitview = ( new SplitView(
177
- this.element,
178
- { orientation, styles, proportionalLayout: splitviewProportionalLayout }
179
- ));
180
- this.splitview.layout(size, { orthogonalSize, absoluteOffset: 0, absoluteOrthogonalOffset: 0, absoluteSize: size, absoluteOrthogonalSize: orthogonalSize });
181
- }
182
- else {
183
- const descriptor = {
184
- views: ( childDescriptors.map(childDescriptor => {
185
- return {
186
- view: childDescriptor.node,
187
- size: childDescriptor.node.size,
188
- visible: childDescriptor.visible !== false
189
- };
190
- })),
191
- size: this.orthogonalSize
192
- };
193
- const options = { proportionalLayout: splitviewProportionalLayout, orientation, styles };
194
- this.children = ( childDescriptors.map(c => c.node));
195
- this.splitview = ( new SplitView(this.element, { ...options, descriptor }));
196
- this.children.forEach((node, index) => {
197
- const first = index === 0;
198
- const last = index === this.children.length;
199
- node.boundarySashes = {
200
- start: this.boundarySashes.orthogonalStart,
201
- end: this.boundarySashes.orthogonalEnd,
202
- orthogonalStart: first ? this.boundarySashes.start : this.splitview.sashes[index - 1],
203
- orthogonalEnd: last ? this.boundarySashes.end : this.splitview.sashes[index],
204
- };
205
- });
206
- }
207
- const onDidSashReset = ( Event.map(this.splitview.onDidSashReset, i => [i]));
208
- this.splitviewSashResetDisposable = onDidSashReset(this._onDidSashReset.fire, this._onDidSashReset);
209
- this.updateChildrenEvents();
210
- }
211
- style(styles) {
212
- this._styles = styles;
213
- this.splitview.style(styles);
214
- for (const child of this.children) {
215
- if (child instanceof BranchNode) {
216
- child.style(styles);
217
- }
218
- }
219
- }
220
- layout(size, offset, ctx) {
221
- if (!this.layoutController.isLayoutEnabled) {
222
- return;
223
- }
224
- if (typeof ctx === 'undefined') {
225
- throw new Error('Invalid state');
226
- }
227
- this._size = ctx.orthogonalSize;
228
- this._orthogonalSize = size;
229
- this._absoluteOffset = ctx.absoluteOffset + offset;
230
- this._absoluteOrthogonalOffset = ctx.absoluteOrthogonalOffset;
231
- this.absoluteOrthogonalSize = ctx.absoluteOrthogonalSize;
232
- this.splitview.layout(ctx.orthogonalSize, {
233
- orthogonalSize: size,
234
- absoluteOffset: this._absoluteOrthogonalOffset,
235
- absoluteOrthogonalOffset: this._absoluteOffset,
236
- absoluteSize: ctx.absoluteOrthogonalSize,
237
- absoluteOrthogonalSize: ctx.absoluteSize
238
- });
239
- this.updateSplitviewEdgeSnappingEnablement();
240
- }
241
- setVisible(visible) {
242
- for (const child of this.children) {
243
- child.setVisible(visible);
244
- }
245
- }
246
- addChild(node, size, index, skipLayout) {
247
- index = validateIndex(index, this.children.length);
248
- this.splitview.addView(node, size, index, skipLayout);
249
- this.children.splice(index, 0, node);
250
- this.updateBoundarySashes();
251
- this.onDidChildrenChange();
252
- }
253
- removeChild(index, sizing) {
254
- index = validateIndex(index, this.children.length);
255
- const result = this.splitview.removeView(index, sizing);
256
- this.children.splice(index, 1);
257
- this.updateBoundarySashes();
258
- this.onDidChildrenChange();
259
- return result;
260
- }
261
- removeAllChildren() {
262
- const result = this.splitview.removeAllViews();
263
- this.children.splice(0, this.children.length);
264
- this.updateBoundarySashes();
265
- this.onDidChildrenChange();
266
- return result;
267
- }
268
- moveChild(from, to) {
269
- from = validateIndex(from, this.children.length);
270
- to = validateIndex(to, this.children.length);
271
- if (from === to) {
272
- return;
273
- }
274
- if (from < to) {
275
- to -= 1;
276
- }
277
- this.splitview.moveView(from, to);
278
- this.children.splice(to, 0, this.children.splice(from, 1)[0]);
279
- this.updateBoundarySashes();
280
- this.onDidChildrenChange();
281
- }
282
- swapChildren(from, to) {
283
- from = validateIndex(from, this.children.length);
284
- to = validateIndex(to, this.children.length);
285
- if (from === to) {
286
- return;
287
- }
288
- this.splitview.swapViews(from, to);
289
- [this.children[from].boundarySashes, this.children[to].boundarySashes]
290
- = [this.children[from].boundarySashes, this.children[to].boundarySashes];
291
- [this.children[from], this.children[to]] = [this.children[to], this.children[from]];
292
- this.onDidChildrenChange();
293
- }
294
- resizeChild(index, size) {
295
- index = validateIndex(index, this.children.length);
296
- this.splitview.resizeView(index, size);
297
- }
298
- isChildExpanded(index) {
299
- return this.splitview.isViewExpanded(index);
300
- }
301
- distributeViewSizes(recursive = false) {
302
- this.splitview.distributeViewSizes();
303
- if (recursive) {
304
- for (const child of this.children) {
305
- if (child instanceof BranchNode) {
306
- child.distributeViewSizes(true);
307
- }
308
- }
309
- }
310
- }
311
- getChildSize(index) {
312
- index = validateIndex(index, this.children.length);
313
- return this.splitview.getViewSize(index);
314
- }
315
- isChildVisible(index) {
316
- index = validateIndex(index, this.children.length);
317
- return this.splitview.isViewVisible(index);
318
- }
319
- setChildVisible(index, visible) {
320
- index = validateIndex(index, this.children.length);
321
- if (this.splitview.isViewVisible(index) === visible) {
322
- return;
323
- }
324
- const wereAllChildrenHidden = this.splitview.contentSize === 0;
325
- this.splitview.setViewVisible(index, visible);
326
- const areAllChildrenHidden = this.splitview.contentSize === 0;
327
- if ((visible && wereAllChildrenHidden) || (!visible && areAllChildrenHidden)) {
328
- this._onDidVisibilityChange.fire(visible);
329
- }
330
- }
331
- getChildCachedVisibleSize(index) {
332
- index = validateIndex(index, this.children.length);
333
- return this.splitview.getViewCachedVisibleSize(index);
334
- }
335
- updateBoundarySashes() {
336
- for (let i = 0; i < this.children.length; i++) {
337
- this.children[i].boundarySashes = {
338
- start: this.boundarySashes.orthogonalStart,
339
- end: this.boundarySashes.orthogonalEnd,
340
- orthogonalStart: i === 0 ? this.boundarySashes.start : this.splitview.sashes[i - 1],
341
- orthogonalEnd: i === this.children.length - 1 ? this.boundarySashes.end : this.splitview.sashes[i],
342
- };
343
- }
344
- }
345
- onDidChildrenChange() {
346
- this.updateChildrenEvents();
347
- this._onDidChange.fire(undefined);
348
- }
349
- updateChildrenEvents() {
350
- const onDidChildrenChange = ( Event.map(Event.any(...( this.children.map(c => c.onDidChange))), () => undefined));
351
- this.childrenChangeDisposable.dispose();
352
- this.childrenChangeDisposable = onDidChildrenChange(this._onDidChange.fire, this._onDidChange);
353
- const onDidChildrenSashReset = Event.any(...( this.children.map((c, i) => ( Event.map(c.onDidSashReset, location => [i, ...location])))));
354
- this.childrenSashResetDisposable.dispose();
355
- this.childrenSashResetDisposable = onDidChildrenSashReset(this._onDidSashReset.fire, this._onDidSashReset);
356
- const onDidScroll = Event.any(Event.signal(this.splitview.onDidScroll), ...( this.children.map(c => c.onDidScroll)));
357
- this.onDidScrollDisposable.dispose();
358
- this.onDidScrollDisposable = onDidScroll(this._onDidScroll.fire, this._onDidScroll);
359
- this.childrenVisibilityChangeDisposable.clear();
360
- this.children.forEach((child, index) => {
361
- if (child instanceof BranchNode) {
362
- this.childrenVisibilityChangeDisposable.add(child.onDidVisibilityChange((visible) => {
363
- this.setChildVisible(index, visible);
364
- }));
365
- }
366
- });
367
- }
368
- trySet2x2(other) {
369
- if (this.children.length !== 2 || other.children.length !== 2) {
370
- return Disposable.None;
371
- }
372
- if (this.getChildSize(0) !== other.getChildSize(0)) {
373
- return Disposable.None;
374
- }
375
- const [firstChild, secondChild] = this.children;
376
- const [otherFirstChild, otherSecondChild] = other.children;
377
- if (!(firstChild instanceof LeafNode) || !(secondChild instanceof LeafNode)) {
378
- return Disposable.None;
379
- }
380
- if (!(otherFirstChild instanceof LeafNode) || !(otherSecondChild instanceof LeafNode)) {
381
- return Disposable.None;
382
- }
383
- if (this.orientation === 0 ) {
384
- secondChild.linkedWidthNode = otherFirstChild.linkedHeightNode = firstChild;
385
- firstChild.linkedWidthNode = otherSecondChild.linkedHeightNode = secondChild;
386
- otherSecondChild.linkedWidthNode = firstChild.linkedHeightNode = otherFirstChild;
387
- otherFirstChild.linkedWidthNode = secondChild.linkedHeightNode = otherSecondChild;
388
- }
389
- else {
390
- otherFirstChild.linkedWidthNode = secondChild.linkedHeightNode = firstChild;
391
- otherSecondChild.linkedWidthNode = firstChild.linkedHeightNode = secondChild;
392
- firstChild.linkedWidthNode = otherSecondChild.linkedHeightNode = otherFirstChild;
393
- secondChild.linkedWidthNode = otherFirstChild.linkedHeightNode = otherSecondChild;
394
- }
395
- const mySash = this.splitview.sashes[0];
396
- const otherSash = other.splitview.sashes[0];
397
- mySash.linkedSash = otherSash;
398
- otherSash.linkedSash = mySash;
399
- this._onDidChange.fire(undefined);
400
- other._onDidChange.fire(undefined);
401
- return toDisposable(() => {
402
- mySash.linkedSash = otherSash.linkedSash = undefined;
403
- firstChild.linkedHeightNode = firstChild.linkedWidthNode = undefined;
404
- secondChild.linkedHeightNode = secondChild.linkedWidthNode = undefined;
405
- otherFirstChild.linkedHeightNode = otherFirstChild.linkedWidthNode = undefined;
406
- otherSecondChild.linkedHeightNode = otherSecondChild.linkedWidthNode = undefined;
407
- });
408
- }
409
- updateSplitviewEdgeSnappingEnablement() {
410
- this.splitview.startSnappingEnabled = this._edgeSnapping || this._absoluteOrthogonalOffset > 0;
411
- this.splitview.endSnappingEnabled = this._edgeSnapping || this._absoluteOrthogonalOffset + this._size < this.absoluteOrthogonalSize;
412
- }
413
- dispose() {
414
- for (const child of this.children) {
415
- child.dispose();
416
- }
417
- this._onDidChange.dispose();
418
- this._onDidSashReset.dispose();
419
- this._onDidVisibilityChange.dispose();
420
- this.childrenVisibilityChangeDisposable.dispose();
421
- this.splitviewSashResetDisposable.dispose();
422
- this.childrenSashResetDisposable.dispose();
423
- this.childrenChangeDisposable.dispose();
424
- this.onDidScrollDisposable.dispose();
425
- this.splitview.dispose();
426
- }
427
- }
428
- function createLatchedOnDidChangeViewEvent(view) {
429
- const [onDidChangeViewConstraints, onDidSetViewSize] = Event.split(view.onDidChange, isUndefined);
430
- return Event.any(onDidSetViewSize, ( Event.map(Event.latch(( Event.map(
431
- onDidChangeViewConstraints,
432
- _ => ([view.minimumWidth, view.maximumWidth, view.minimumHeight, view.maximumHeight])
433
- )), equals), _ => undefined)));
434
- }
435
- class LeafNode {
436
- get size() { return this._size; }
437
- get orthogonalSize() { return this._orthogonalSize; }
438
- get linkedWidthNode() { return this._linkedWidthNode; }
439
- set linkedWidthNode(node) {
440
- this._onDidLinkedWidthNodeChange.input = node ? node._onDidViewChange : Event.None;
441
- this._linkedWidthNode = node;
442
- this._onDidSetLinkedNode.fire(undefined);
443
- }
444
- get linkedHeightNode() { return this._linkedHeightNode; }
445
- set linkedHeightNode(node) {
446
- this._onDidLinkedHeightNodeChange.input = node ? node._onDidViewChange : Event.None;
447
- this._linkedHeightNode = node;
448
- this._onDidSetLinkedNode.fire(undefined);
449
- }
450
- constructor(view, orientation, layoutController, orthogonalSize, size = 0) {
451
- this.view = view;
452
- this.orientation = orientation;
453
- this.layoutController = layoutController;
454
- this._size = 0;
455
- this.absoluteOffset = 0;
456
- this.absoluteOrthogonalOffset = 0;
457
- this.onDidScroll = Event.None;
458
- this.onDidSashReset = Event.None;
459
- this._onDidLinkedWidthNodeChange = ( new Relay());
460
- this._linkedWidthNode = undefined;
461
- this._onDidLinkedHeightNodeChange = ( new Relay());
462
- this._linkedHeightNode = undefined;
463
- this._onDidSetLinkedNode = ( new Emitter());
464
- this.disposables = ( new DisposableStore());
465
- this._boundarySashes = {};
466
- this.cachedWidth = 0;
467
- this.cachedHeight = 0;
468
- this.cachedTop = 0;
469
- this.cachedLeft = 0;
470
- this._orthogonalSize = orthogonalSize;
471
- this._size = size;
472
- const onDidChange = createLatchedOnDidChangeViewEvent(view);
473
- this._onDidViewChange = ( Event.map(
474
- onDidChange,
475
- e => e && (this.orientation === 0 ? e.width : e.height),
476
- this.disposables
477
- ));
478
- this.onDidChange = Event.any(this._onDidViewChange, this._onDidSetLinkedNode.event, this._onDidLinkedWidthNodeChange.event, this._onDidLinkedHeightNodeChange.event);
479
- }
480
- get width() {
481
- return this.orientation === 1 ? this.orthogonalSize : this.size;
482
- }
483
- get height() {
484
- return this.orientation === 1 ? this.size : this.orthogonalSize;
485
- }
486
- get top() {
487
- return this.orientation === 1 ? this.absoluteOffset : this.absoluteOrthogonalOffset;
488
- }
489
- get left() {
490
- return this.orientation === 1 ? this.absoluteOrthogonalOffset : this.absoluteOffset;
491
- }
492
- get element() {
493
- return this.view.element;
494
- }
495
- get minimumWidth() {
496
- return this.linkedWidthNode ? Math.max(this.linkedWidthNode.view.minimumWidth, this.view.minimumWidth) : this.view.minimumWidth;
497
- }
498
- get maximumWidth() {
499
- return this.linkedWidthNode ? Math.min(this.linkedWidthNode.view.maximumWidth, this.view.maximumWidth) : this.view.maximumWidth;
500
- }
501
- get minimumHeight() {
502
- return this.linkedHeightNode ? Math.max(this.linkedHeightNode.view.minimumHeight, this.view.minimumHeight) : this.view.minimumHeight;
503
- }
504
- get maximumHeight() {
505
- return this.linkedHeightNode ? Math.min(this.linkedHeightNode.view.maximumHeight, this.view.maximumHeight) : this.view.maximumHeight;
506
- }
507
- get minimumSize() {
508
- return this.orientation === 1 ? this.minimumHeight : this.minimumWidth;
509
- }
510
- get maximumSize() {
511
- return this.orientation === 1 ? this.maximumHeight : this.maximumWidth;
512
- }
513
- get priority() {
514
- return this.view.priority;
515
- }
516
- get proportionalLayout() {
517
- return this.view.proportionalLayout ?? true;
518
- }
519
- get snap() {
520
- return this.view.snap;
521
- }
522
- get minimumOrthogonalSize() {
523
- return this.orientation === 1 ? this.minimumWidth : this.minimumHeight;
524
- }
525
- get maximumOrthogonalSize() {
526
- return this.orientation === 1 ? this.maximumWidth : this.maximumHeight;
527
- }
528
- get boundarySashes() { return this._boundarySashes; }
529
- set boundarySashes(boundarySashes) {
530
- this._boundarySashes = boundarySashes;
531
- this.view.setBoundarySashes?.(toAbsoluteBoundarySashes(boundarySashes, this.orientation));
532
- }
533
- layout(size, offset, ctx) {
534
- if (!this.layoutController.isLayoutEnabled) {
535
- return;
536
- }
537
- if (typeof ctx === 'undefined') {
538
- throw new Error('Invalid state');
539
- }
540
- this._size = size;
541
- this._orthogonalSize = ctx.orthogonalSize;
542
- this.absoluteOffset = ctx.absoluteOffset + offset;
543
- this.absoluteOrthogonalOffset = ctx.absoluteOrthogonalOffset;
544
- this._layout(this.width, this.height, this.top, this.left);
545
- }
546
- _layout(width, height, top, left) {
547
- if (this.cachedWidth === width && this.cachedHeight === height && this.cachedTop === top && this.cachedLeft === left) {
548
- return;
549
- }
550
- this.cachedWidth = width;
551
- this.cachedHeight = height;
552
- this.cachedTop = top;
553
- this.cachedLeft = left;
554
- this.view.layout(width, height, top, left);
555
- }
556
- setVisible(visible) {
557
- this.view.setVisible?.(visible);
558
- }
559
- dispose() {
560
- this.disposables.dispose();
561
- }
562
- }
563
- function flipNode(node, size, orthogonalSize) {
564
- if (node instanceof BranchNode) {
565
- const result = ( new BranchNode(
566
- orthogonal(node.orientation),
567
- node.layoutController,
568
- node.styles,
569
- node.splitviewProportionalLayout,
570
- size,
571
- orthogonalSize,
572
- node.edgeSnapping
573
- ));
574
- let totalSize = 0;
575
- for (let i = node.children.length - 1; i >= 0; i--) {
576
- const child = node.children[i];
577
- const childSize = child instanceof BranchNode ? child.orthogonalSize : child.size;
578
- let newSize = node.size === 0 ? 0 : Math.round((size * childSize) / node.size);
579
- totalSize += newSize;
580
- if (i === 0) {
581
- newSize += size - totalSize;
582
- }
583
- result.addChild(flipNode(child, orthogonalSize, newSize), newSize, 0, true);
584
- }
585
- node.dispose();
586
- return result;
587
- }
588
- else {
589
- const result = ( new LeafNode(
590
- node.view,
591
- orthogonal(node.orientation),
592
- node.layoutController,
593
- orthogonalSize
594
- ));
595
- node.dispose();
596
- return result;
597
- }
598
- }
599
- class GridView {
600
- get root() { return this._root; }
601
- set root(root) {
602
- const oldRoot = this._root;
603
- if (oldRoot) {
604
- this.element.removeChild(oldRoot.element);
605
- oldRoot.dispose();
606
- }
607
- this._root = root;
608
- this.element.appendChild(root.element);
609
- this.onDidSashResetRelay.input = root.onDidSashReset;
610
- this._onDidChange.input = ( Event.map(root.onDidChange, () => undefined));
611
- this._onDidScroll.input = root.onDidScroll;
612
- }
613
- get width() { return this.root.width; }
614
- get height() { return this.root.height; }
615
- get minimumWidth() { return this.root.minimumWidth; }
616
- get minimumHeight() { return this.root.minimumHeight; }
617
- get maximumWidth() { return this.root.maximumHeight; }
618
- get maximumHeight() { return this.root.maximumHeight; }
619
- get orientation() { return this._root.orientation; }
620
- get boundarySashes() { return this._boundarySashes; }
621
- set orientation(orientation) {
622
- if (this._root.orientation === orientation) {
623
- return;
624
- }
625
- const { size, orthogonalSize, absoluteOffset, absoluteOrthogonalOffset } = this._root;
626
- this.root = flipNode(this._root, orthogonalSize, size);
627
- this.root.layout(size, 0, { orthogonalSize, absoluteOffset: absoluteOrthogonalOffset, absoluteOrthogonalOffset: absoluteOffset, absoluteSize: size, absoluteOrthogonalSize: orthogonalSize });
628
- this.boundarySashes = this.boundarySashes;
629
- }
630
- set boundarySashes(boundarySashes) {
631
- this._boundarySashes = boundarySashes;
632
- this.root.boundarySashes = fromAbsoluteBoundarySashes(boundarySashes, this.orientation);
633
- }
634
- set edgeSnapping(edgeSnapping) {
635
- this.root.edgeSnapping = edgeSnapping;
636
- }
637
- constructor(options = {}) {
638
- this.onDidSashResetRelay = ( new Relay());
639
- this._onDidScroll = ( new Relay());
640
- this._onDidChange = ( new Relay());
641
- this._boundarySashes = {};
642
- this.disposable2x2 = Disposable.None;
643
- this.onDidSashReset = this.onDidSashResetRelay.event;
644
- this.onDidScroll = this._onDidScroll.event;
645
- this.onDidChange = this._onDidChange.event;
646
- this.maximizedNode = undefined;
647
- this._onDidChangeViewMaximized = ( new Emitter());
648
- this.onDidChangeViewMaximized = this._onDidChangeViewMaximized.event;
649
- this.element = $('.monaco-grid-view');
650
- this.styles = options.styles || defaultStyles;
651
- this.proportionalLayout = typeof options.proportionalLayout !== 'undefined' ? !!options.proportionalLayout : true;
652
- this.layoutController = ( new LayoutController(false));
653
- this.root = ( new BranchNode(
654
- 0 ,
655
- this.layoutController,
656
- this.styles,
657
- this.proportionalLayout
658
- ));
659
- }
660
- style(styles) {
661
- this.styles = styles;
662
- this.root.style(styles);
663
- }
664
- layout(width, height, top = 0, left = 0) {
665
- this.layoutController.isLayoutEnabled = true;
666
- const [size, orthogonalSize, offset, orthogonalOffset] = this.root.orientation === 1 ? [height, width, top, left] : [width, height, left, top];
667
- this.root.layout(size, 0, { orthogonalSize, absoluteOffset: offset, absoluteOrthogonalOffset: orthogonalOffset, absoluteSize: size, absoluteOrthogonalSize: orthogonalSize });
668
- }
669
- addView(view, size, location) {
670
- if (this.hasMaximizedView()) {
671
- this.exitMaximizedView();
672
- }
673
- this.disposable2x2.dispose();
674
- this.disposable2x2 = Disposable.None;
675
- const [rest, index] = tail2(location);
676
- const [pathToParent, parent] = this.getNode(rest);
677
- if (parent instanceof BranchNode) {
678
- const node = ( new LeafNode(
679
- view,
680
- orthogonal(parent.orientation),
681
- this.layoutController,
682
- parent.orthogonalSize
683
- ));
684
- try {
685
- parent.addChild(node, size, index);
686
- }
687
- catch (err) {
688
- node.dispose();
689
- throw err;
690
- }
691
- }
692
- else {
693
- const [, grandParent] = tail2(pathToParent);
694
- const [, parentIndex] = tail2(rest);
695
- let newSiblingSize = 0;
696
- const newSiblingCachedVisibleSize = grandParent.getChildCachedVisibleSize(parentIndex);
697
- if (typeof newSiblingCachedVisibleSize === 'number') {
698
- newSiblingSize = Sizing.Invisible(newSiblingCachedVisibleSize);
699
- }
700
- const oldChild = grandParent.removeChild(parentIndex);
701
- oldChild.dispose();
702
- const newParent = ( new BranchNode(
703
- parent.orientation,
704
- parent.layoutController,
705
- this.styles,
706
- this.proportionalLayout,
707
- parent.size,
708
- parent.orthogonalSize,
709
- grandParent.edgeSnapping
710
- ));
711
- grandParent.addChild(newParent, parent.size, parentIndex);
712
- const newSibling = ( new LeafNode(parent.view, grandParent.orientation, this.layoutController, parent.size));
713
- newParent.addChild(newSibling, newSiblingSize, 0);
714
- if (typeof size !== 'number' && size.type === 'split') {
715
- size = Sizing.Split(0);
716
- }
717
- const node = ( new LeafNode(view, grandParent.orientation, this.layoutController, parent.size));
718
- newParent.addChild(node, size, index);
719
- }
720
- this.trySet2x2();
721
- }
722
- removeView(location, sizing) {
723
- if (this.hasMaximizedView()) {
724
- this.exitMaximizedView();
725
- }
726
- this.disposable2x2.dispose();
727
- this.disposable2x2 = Disposable.None;
728
- const [rest, index] = tail2(location);
729
- const [pathToParent, parent] = this.getNode(rest);
730
- if (!(parent instanceof BranchNode)) {
731
- throw new Error('Invalid location');
732
- }
733
- const node = parent.children[index];
734
- if (!(node instanceof LeafNode)) {
735
- throw new Error('Invalid location');
736
- }
737
- parent.removeChild(index, sizing);
738
- node.dispose();
739
- if (parent.children.length === 0) {
740
- throw new Error('Invalid grid state');
741
- }
742
- if (parent.children.length > 1) {
743
- this.trySet2x2();
744
- return node.view;
745
- }
746
- if (pathToParent.length === 0) {
747
- const sibling = parent.children[0];
748
- if (sibling instanceof LeafNode) {
749
- return node.view;
750
- }
751
- parent.removeChild(0);
752
- parent.dispose();
753
- this.root = sibling;
754
- this.boundarySashes = this.boundarySashes;
755
- this.trySet2x2();
756
- return node.view;
757
- }
758
- const [, grandParent] = tail2(pathToParent);
759
- const [, parentIndex] = tail2(rest);
760
- const isSiblingVisible = parent.isChildVisible(0);
761
- const sibling = parent.removeChild(0);
762
- const sizes = ( grandParent.children.map((_, i) => grandParent.getChildSize(i)));
763
- grandParent.removeChild(parentIndex, sizing);
764
- parent.dispose();
765
- if (sibling instanceof BranchNode) {
766
- sizes.splice(parentIndex, 1, ...( sibling.children.map(c => c.size)));
767
- const siblingChildren = sibling.removeAllChildren();
768
- for (let i = 0; i < siblingChildren.length; i++) {
769
- grandParent.addChild(siblingChildren[i], siblingChildren[i].size, parentIndex + i);
770
- }
771
- }
772
- else {
773
- const newSibling = ( new LeafNode(
774
- sibling.view,
775
- orthogonal(sibling.orientation),
776
- this.layoutController,
777
- sibling.size
778
- ));
779
- const sizing = isSiblingVisible ? sibling.orthogonalSize : Sizing.Invisible(sibling.orthogonalSize);
780
- grandParent.addChild(newSibling, sizing, parentIndex);
781
- }
782
- sibling.dispose();
783
- for (let i = 0; i < sizes.length; i++) {
784
- grandParent.resizeChild(i, sizes[i]);
785
- }
786
- this.trySet2x2();
787
- return node.view;
788
- }
789
- moveView(parentLocation, from, to) {
790
- if (this.hasMaximizedView()) {
791
- this.exitMaximizedView();
792
- }
793
- const [, parent] = this.getNode(parentLocation);
794
- if (!(parent instanceof BranchNode)) {
795
- throw new Error('Invalid location');
796
- }
797
- parent.moveChild(from, to);
798
- this.trySet2x2();
799
- }
800
- swapViews(from, to) {
801
- if (this.hasMaximizedView()) {
802
- this.exitMaximizedView();
803
- }
804
- const [fromRest, fromIndex] = tail2(from);
805
- const [, fromParent] = this.getNode(fromRest);
806
- if (!(fromParent instanceof BranchNode)) {
807
- throw new Error('Invalid from location');
808
- }
809
- const fromSize = fromParent.getChildSize(fromIndex);
810
- const fromNode = fromParent.children[fromIndex];
811
- if (!(fromNode instanceof LeafNode)) {
812
- throw new Error('Invalid from location');
813
- }
814
- const [toRest, toIndex] = tail2(to);
815
- const [, toParent] = this.getNode(toRest);
816
- if (!(toParent instanceof BranchNode)) {
817
- throw new Error('Invalid to location');
818
- }
819
- const toSize = toParent.getChildSize(toIndex);
820
- const toNode = toParent.children[toIndex];
821
- if (!(toNode instanceof LeafNode)) {
822
- throw new Error('Invalid to location');
823
- }
824
- if (fromParent === toParent) {
825
- fromParent.swapChildren(fromIndex, toIndex);
826
- }
827
- else {
828
- fromParent.removeChild(fromIndex);
829
- toParent.removeChild(toIndex);
830
- fromParent.addChild(toNode, fromSize, fromIndex);
831
- toParent.addChild(fromNode, toSize, toIndex);
832
- }
833
- this.trySet2x2();
834
- }
835
- resizeView(location, size) {
836
- if (this.hasMaximizedView()) {
837
- this.exitMaximizedView();
838
- }
839
- const [rest, index] = tail2(location);
840
- const [pathToParent, parent] = this.getNode(rest);
841
- if (!(parent instanceof BranchNode)) {
842
- throw new Error('Invalid location');
843
- }
844
- if (!size.width && !size.height) {
845
- return;
846
- }
847
- const [parentSize, grandParentSize] = parent.orientation === 1 ? [size.width, size.height] : [size.height, size.width];
848
- if (typeof grandParentSize === 'number' && pathToParent.length > 0) {
849
- const [, grandParent] = tail2(pathToParent);
850
- const [, parentIndex] = tail2(rest);
851
- grandParent.resizeChild(parentIndex, grandParentSize);
852
- }
853
- if (typeof parentSize === 'number') {
854
- parent.resizeChild(index, parentSize);
855
- }
856
- this.trySet2x2();
857
- }
858
- getViewSize(location) {
859
- if (!location) {
860
- return { width: this.root.width, height: this.root.height };
861
- }
862
- const [, node] = this.getNode(location);
863
- return { width: node.width, height: node.height };
864
- }
865
- getViewCachedVisibleSize(location) {
866
- const [rest, index] = tail2(location);
867
- const [, parent] = this.getNode(rest);
868
- if (!(parent instanceof BranchNode)) {
869
- throw new Error('Invalid location');
870
- }
871
- return parent.getChildCachedVisibleSize(index);
872
- }
873
- expandView(location) {
874
- if (this.hasMaximizedView()) {
875
- this.exitMaximizedView();
876
- }
877
- const [ancestors, node] = this.getNode(location);
878
- if (!(node instanceof LeafNode)) {
879
- throw new Error('Invalid location');
880
- }
881
- for (let i = 0; i < ancestors.length; i++) {
882
- ancestors[i].resizeChild(location[i], Number.POSITIVE_INFINITY);
883
- }
884
- }
885
- isViewExpanded(location) {
886
- if (this.hasMaximizedView()) {
887
- return false;
888
- }
889
- const [ancestors, node] = this.getNode(location);
890
- if (!(node instanceof LeafNode)) {
891
- throw new Error('Invalid location');
892
- }
893
- for (let i = 0; i < ancestors.length; i++) {
894
- if (!ancestors[i].isChildExpanded(location[i])) {
895
- return false;
896
- }
897
- }
898
- return true;
899
- }
900
- maximizeView(location) {
901
- const [, nodeToMaximize] = this.getNode(location);
902
- if (!(nodeToMaximize instanceof LeafNode)) {
903
- throw new Error('Location is not a LeafNode');
904
- }
905
- if (this.maximizedNode === nodeToMaximize) {
906
- return;
907
- }
908
- if (this.hasMaximizedView()) {
909
- this.exitMaximizedView();
910
- }
911
- function hideAllViewsBut(parent, exclude) {
912
- for (let i = 0; i < parent.children.length; i++) {
913
- const child = parent.children[i];
914
- if (child instanceof LeafNode) {
915
- if (child !== exclude) {
916
- parent.setChildVisible(i, false);
917
- }
918
- }
919
- else {
920
- hideAllViewsBut(child, exclude);
921
- }
922
- }
923
- }
924
- hideAllViewsBut(this.root, nodeToMaximize);
925
- this.maximizedNode = nodeToMaximize;
926
- this._onDidChangeViewMaximized.fire(true);
927
- }
928
- exitMaximizedView() {
929
- if (!this.maximizedNode) {
930
- return;
931
- }
932
- this.maximizedNode = undefined;
933
- function showViewsInReverseOrder(parent) {
934
- for (let index = parent.children.length - 1; index >= 0; index--) {
935
- const child = parent.children[index];
936
- if (child instanceof LeafNode) {
937
- parent.setChildVisible(index, true);
938
- }
939
- else {
940
- showViewsInReverseOrder(child);
941
- }
942
- }
943
- }
944
- showViewsInReverseOrder(this.root);
945
- this._onDidChangeViewMaximized.fire(false);
946
- }
947
- hasMaximizedView() {
948
- return this.maximizedNode !== undefined;
949
- }
950
- isViewMaximized(location) {
951
- const [, node] = this.getNode(location);
952
- if (!(node instanceof LeafNode)) {
953
- throw new Error('Location is not a LeafNode');
954
- }
955
- return node === this.maximizedNode;
956
- }
957
- distributeViewSizes(location) {
958
- if (this.hasMaximizedView()) {
959
- this.exitMaximizedView();
960
- }
961
- if (!location) {
962
- this.root.distributeViewSizes(true);
963
- return;
964
- }
965
- const [, node] = this.getNode(location);
966
- if (!(node instanceof BranchNode)) {
967
- throw new Error('Invalid location');
968
- }
969
- node.distributeViewSizes();
970
- this.trySet2x2();
971
- }
972
- isViewVisible(location) {
973
- const [rest, index] = tail2(location);
974
- const [, parent] = this.getNode(rest);
975
- if (!(parent instanceof BranchNode)) {
976
- throw new Error('Invalid from location');
977
- }
978
- return parent.isChildVisible(index);
979
- }
980
- setViewVisible(location, visible) {
981
- if (this.hasMaximizedView()) {
982
- this.exitMaximizedView();
983
- return;
984
- }
985
- const [rest, index] = tail2(location);
986
- const [, parent] = this.getNode(rest);
987
- if (!(parent instanceof BranchNode)) {
988
- throw new Error('Invalid from location');
989
- }
990
- parent.setChildVisible(index, visible);
991
- }
992
- getView(location) {
993
- const node = location ? this.getNode(location)[1] : this._root;
994
- return this._getViews(node, this.orientation);
995
- }
996
- static deserialize(json, deserializer, options = {}) {
997
- if (typeof json.orientation !== 'number') {
998
- throw new Error('Invalid JSON: \'orientation\' property must be a number.');
999
- }
1000
- else if (typeof json.width !== 'number') {
1001
- throw new Error('Invalid JSON: \'width\' property must be a number.');
1002
- }
1003
- else if (typeof json.height !== 'number') {
1004
- throw new Error('Invalid JSON: \'height\' property must be a number.');
1005
- }
1006
- else if (json.root?.type !== 'branch') {
1007
- throw new Error('Invalid JSON: \'root\' property must have \'type\' value of branch.');
1008
- }
1009
- const orientation = json.orientation;
1010
- const height = json.height;
1011
- const result = ( new GridView(options));
1012
- result._deserialize(json.root, orientation, deserializer, height);
1013
- return result;
1014
- }
1015
- _deserialize(root, orientation, deserializer, orthogonalSize) {
1016
- this.root = this._deserializeNode(root, orientation, deserializer, orthogonalSize);
1017
- }
1018
- _deserializeNode(node, orientation, deserializer, orthogonalSize) {
1019
- let result;
1020
- if (node.type === 'branch') {
1021
- const serializedChildren = node.data;
1022
- const children = ( serializedChildren.map(serializedChild => {
1023
- return {
1024
- node: this._deserializeNode(serializedChild, orthogonal(orientation), deserializer, node.size),
1025
- visible: serializedChild.visible
1026
- };
1027
- }));
1028
- result = ( new BranchNode(
1029
- orientation,
1030
- this.layoutController,
1031
- this.styles,
1032
- this.proportionalLayout,
1033
- node.size,
1034
- orthogonalSize,
1035
- undefined,
1036
- children
1037
- ));
1038
- }
1039
- else {
1040
- result = ( new LeafNode(
1041
- deserializer.fromJSON(node.data),
1042
- orientation,
1043
- this.layoutController,
1044
- orthogonalSize,
1045
- node.size
1046
- ));
1047
- if (node.maximized && !this.maximizedNode) {
1048
- this.maximizedNode = result;
1049
- this._onDidChangeViewMaximized.fire(true);
1050
- }
1051
- }
1052
- return result;
1053
- }
1054
- _getViews(node, orientation, cachedVisibleSize) {
1055
- const box = { top: node.top, left: node.left, width: node.width, height: node.height };
1056
- if (node instanceof LeafNode) {
1057
- return { view: node.view, box, cachedVisibleSize, maximized: this.maximizedNode === node };
1058
- }
1059
- const children = [];
1060
- for (let i = 0; i < node.children.length; i++) {
1061
- const child = node.children[i];
1062
- const cachedVisibleSize = node.getChildCachedVisibleSize(i);
1063
- children.push(this._getViews(child, orthogonal(orientation), cachedVisibleSize));
1064
- }
1065
- return { children, box };
1066
- }
1067
- getNode(location, node = this.root, path = []) {
1068
- if (location.length === 0) {
1069
- return [path, node];
1070
- }
1071
- if (!(node instanceof BranchNode)) {
1072
- throw new Error('Invalid location');
1073
- }
1074
- const [index, ...rest] = location;
1075
- if (index < 0 || index >= node.children.length) {
1076
- throw new Error('Invalid location');
1077
- }
1078
- const child = node.children[index];
1079
- path.push(node);
1080
- return this.getNode(rest, child, path);
1081
- }
1082
- trySet2x2() {
1083
- this.disposable2x2.dispose();
1084
- this.disposable2x2 = Disposable.None;
1085
- if (this.root.children.length !== 2) {
1086
- return;
1087
- }
1088
- const [first, second] = this.root.children;
1089
- if (!(first instanceof BranchNode) || !(second instanceof BranchNode)) {
1090
- return;
1091
- }
1092
- this.disposable2x2 = first.trySet2x2(second);
1093
- }
1094
- getViewMap(map, node) {
1095
- if (!node) {
1096
- node = this.root;
1097
- }
1098
- if (node instanceof BranchNode) {
1099
- node.children.forEach(child => this.getViewMap(map, child));
1100
- }
1101
- else {
1102
- map.set(node.view, node.element);
1103
- }
1104
- }
1105
- dispose() {
1106
- this.onDidSashResetRelay.dispose();
1107
- this.root.dispose();
1108
- this.element.parentElement?.removeChild(this.element);
1109
- }
1110
- }
1111
-
1112
- export { GridView, orthogonal };