dockview 1.7.3 → 1.7.5

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/dist/dockview.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview
3
- * @version 1.7.3
3
+ * @version 1.7.5
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -145,9 +145,49 @@
145
145
  };
146
146
  };
147
147
  })(exports.DockviewEvent || (exports.DockviewEvent = {}));
148
- // dumb event emitter with better typings than nodes event emitter
149
- // https://github.com/microsoft/vscode/blob/master/src/vs/base/common/event.ts
148
+ class LeakageMonitor {
149
+ constructor() {
150
+ this.events = new Map();
151
+ }
152
+ get size() {
153
+ return this.events.size;
154
+ }
155
+ add(event, stacktrace) {
156
+ this.events.set(event, stacktrace);
157
+ }
158
+ delete(event) {
159
+ this.events.delete(event);
160
+ }
161
+ clear() {
162
+ this.events.clear();
163
+ }
164
+ }
165
+ class Stacktrace {
166
+ static create() {
167
+ var _a;
168
+ return new Stacktrace((_a = new Error().stack) !== null && _a !== void 0 ? _a : '');
169
+ }
170
+ constructor(value) {
171
+ this.value = value;
172
+ }
173
+ print() {
174
+ console.warn(this.value);
175
+ }
176
+ }
177
+ class Listener {
178
+ constructor(callback, stacktrace) {
179
+ this.callback = callback;
180
+ this.stacktrace = stacktrace;
181
+ }
182
+ }
183
+ // relatively simple event emitter taken from https://github.com/microsoft/vscode/blob/master/src/vs/base/common/event.ts
150
184
  class Emitter {
185
+ static setLeakageMonitorEnabled(isEnabled) {
186
+ if (isEnabled !== Emitter.ENABLE_TRACKING) {
187
+ Emitter.MEMORY_LEAK_WATCHER.clear();
188
+ }
189
+ Emitter.ENABLE_TRACKING = isEnabled;
190
+ }
151
191
  constructor(options) {
152
192
  this.options = options;
153
193
  this._listeners = [];
@@ -155,11 +195,12 @@
155
195
  }
156
196
  get event() {
157
197
  if (!this._event) {
158
- this._event = (listener) => {
198
+ this._event = (callback) => {
159
199
  var _a;
160
200
  if (((_a = this.options) === null || _a === void 0 ? void 0 : _a.replay) && this._last !== undefined) {
161
- listener(this._last);
201
+ callback(this._last);
162
202
  }
203
+ const listener = new Listener(callback, Emitter.ENABLE_TRACKING ? Stacktrace.create() : undefined);
163
204
  this._listeners.push(listener);
164
205
  return {
165
206
  dispose: () => {
@@ -167,28 +208,50 @@
167
208
  if (index > -1) {
168
209
  this._listeners.splice(index, 1);
169
210
  }
211
+ else if (Emitter.ENABLE_TRACKING) ;
170
212
  },
171
213
  };
172
214
  };
215
+ if (Emitter.ENABLE_TRACKING) {
216
+ Emitter.MEMORY_LEAK_WATCHER.add(this._event, Stacktrace.create());
217
+ }
173
218
  }
174
219
  return this._event;
175
220
  }
176
221
  fire(e) {
177
222
  this._last = e;
178
223
  for (const listener of this._listeners) {
179
- listener(e);
224
+ listener.callback(e);
180
225
  }
181
226
  }
182
227
  dispose() {
183
- this._listeners = [];
184
- this._disposed = true;
228
+ if (!this._disposed) {
229
+ this._disposed = true;
230
+ if (this._listeners.length > 0) {
231
+ if (Emitter.ENABLE_TRACKING) {
232
+ queueMicrotask(() => {
233
+ var _a;
234
+ // don't check until stack of execution is completed to allow for out-of-order disposals within the same execution block
235
+ for (const listener of this._listeners) {
236
+ console.warn((_a = listener.stacktrace) === null || _a === void 0 ? void 0 : _a.print());
237
+ }
238
+ });
239
+ }
240
+ this._listeners = [];
241
+ }
242
+ if (Emitter.ENABLE_TRACKING && this._event) {
243
+ Emitter.MEMORY_LEAK_WATCHER.delete(this._event);
244
+ }
245
+ }
185
246
  }
186
247
  }
248
+ Emitter.ENABLE_TRACKING = false;
249
+ Emitter.MEMORY_LEAK_WATCHER = new LeakageMonitor();
187
250
  function addDisposableWindowListener(element, type, listener, options) {
188
251
  element.addEventListener(type, listener, options);
189
252
  return {
190
253
  dispose: () => {
191
- element.removeEventListener(type, listener);
254
+ element.removeEventListener(type, listener, options);
192
255
  },
193
256
  };
194
257
  }
@@ -196,7 +259,7 @@
196
259
  element.addEventListener(type, listener, options);
197
260
  return {
198
261
  dispose: () => {
199
- element.removeEventListener(type, listener);
262
+ element.removeEventListener(type, listener, options);
200
263
  },
201
264
  };
202
265
  }
@@ -236,13 +299,13 @@
236
299
  }
237
300
  constructor(...args) {
238
301
  this._isDisposed = false;
239
- this.disposables = args;
302
+ this._disposables = args;
240
303
  }
241
304
  addDisposables(...args) {
242
- args.forEach((arg) => this.disposables.push(arg));
305
+ args.forEach((arg) => this._disposables.push(arg));
243
306
  }
244
307
  dispose() {
245
- this.disposables.forEach((arg) => arg.dispose());
308
+ this._disposables.forEach((arg) => arg.dispose());
246
309
  this._isDisposed = true;
247
310
  }
248
311
  }
@@ -332,6 +395,7 @@
332
395
  this.onDidFocus = this._onDidFocus.event;
333
396
  this._onDidBlur = new Emitter();
334
397
  this.onDidBlur = this._onDidBlur.event;
398
+ this.addDisposables(this._onDidFocus, this._onDidBlur);
335
399
  let hasFocus = isAncestor(document.activeElement, element);
336
400
  let loosingFocus = false;
337
401
  const onFocus = () => {
@@ -376,11 +440,6 @@
376
440
  refreshState() {
377
441
  this._refreshStateHandler();
378
442
  }
379
- dispose() {
380
- super.dispose();
381
- this._onDidBlur.dispose();
382
- this._onDidFocus.dispose();
383
- }
384
443
  }
385
444
 
386
445
  function createComponent(id, componentName, components = {}, frameworkComponents = {}, createFrameworkComponent, fallback) {
@@ -609,7 +668,7 @@
609
668
  this._orthogonalSize = value;
610
669
  }
611
670
  get length() {
612
- return this.views.length;
671
+ return this.viewItems.length;
613
672
  }
614
673
  get proportions() {
615
674
  return this._proportions ? [...this._proportions] : undefined;
@@ -628,12 +687,12 @@
628
687
  : 'vertical');
629
688
  }
630
689
  get minimumSize() {
631
- return this.views.reduce((r, item) => r + item.minimumSize, 0);
690
+ return this.viewItems.reduce((r, item) => r + item.minimumSize, 0);
632
691
  }
633
692
  get maximumSize() {
634
693
  return this.length === 0
635
694
  ? Number.POSITIVE_INFINITY
636
- : this.views.reduce((r, item) => r + item.maximumSize, 0);
695
+ : this.viewItems.reduce((r, item) => r + item.maximumSize, 0);
637
696
  }
638
697
  get startSnappingEnabled() {
639
698
  return this._startSnappingEnabled;
@@ -657,7 +716,7 @@
657
716
  }
658
717
  constructor(container, options) {
659
718
  this.container = container;
660
- this.views = [];
719
+ this.viewItems = [];
661
720
  this.sashes = [];
662
721
  this._size = 0;
663
722
  this._orthogonalSize = 0;
@@ -671,12 +730,12 @@
671
730
  this.onDidAddView = this._onDidAddView.event;
672
731
  this._onDidRemoveView = new Emitter();
673
732
  this.onDidRemoveView = this._onDidRemoveView.event;
674
- this.resize = (index, delta, sizes = this.views.map((x) => x.size), lowPriorityIndexes, highPriorityIndexes, overloadMinDelta = Number.NEGATIVE_INFINITY, overloadMaxDelta = Number.POSITIVE_INFINITY, snapBefore, snapAfter) => {
675
- if (index < 0 || index > this.views.length) {
733
+ this.resize = (index, delta, sizes = this.viewItems.map((x) => x.size), lowPriorityIndexes, highPriorityIndexes, overloadMinDelta = Number.NEGATIVE_INFINITY, overloadMaxDelta = Number.POSITIVE_INFINITY, snapBefore, snapAfter) => {
734
+ if (index < 0 || index > this.viewItems.length) {
676
735
  return 0;
677
736
  }
678
737
  const upIndexes = range(index, -1);
679
- const downIndexes = range(index + 1, this.views.length);
738
+ const downIndexes = range(index + 1, this.viewItems.length);
680
739
  //
681
740
  if (highPriorityIndexes) {
682
741
  for (const i of highPriorityIndexes) {
@@ -691,34 +750,34 @@
691
750
  }
692
751
  }
693
752
  //
694
- const upItems = upIndexes.map((i) => this.views[i]);
753
+ const upItems = upIndexes.map((i) => this.viewItems[i]);
695
754
  const upSizes = upIndexes.map((i) => sizes[i]);
696
755
  //
697
- const downItems = downIndexes.map((i) => this.views[i]);
756
+ const downItems = downIndexes.map((i) => this.viewItems[i]);
698
757
  const downSizes = downIndexes.map((i) => sizes[i]);
699
758
  //
700
- const minDeltaUp = upIndexes.reduce((_, i) => _ + this.views[i].minimumSize - sizes[i], 0);
701
- const maxDeltaUp = upIndexes.reduce((_, i) => _ + this.views[i].maximumSize - sizes[i], 0);
759
+ const minDeltaUp = upIndexes.reduce((_, i) => _ + this.viewItems[i].minimumSize - sizes[i], 0);
760
+ const maxDeltaUp = upIndexes.reduce((_, i) => _ + this.viewItems[i].maximumSize - sizes[i], 0);
702
761
  //
703
762
  const maxDeltaDown = downIndexes.length === 0
704
763
  ? Number.POSITIVE_INFINITY
705
- : downIndexes.reduce((_, i) => _ + sizes[i] - this.views[i].minimumSize, 0);
764
+ : downIndexes.reduce((_, i) => _ + sizes[i] - this.viewItems[i].minimumSize, 0);
706
765
  const minDeltaDown = downIndexes.length === 0
707
766
  ? Number.NEGATIVE_INFINITY
708
- : downIndexes.reduce((_, i) => _ + sizes[i] - this.views[i].maximumSize, 0);
767
+ : downIndexes.reduce((_, i) => _ + sizes[i] - this.viewItems[i].maximumSize, 0);
709
768
  //
710
769
  const minDelta = Math.max(minDeltaUp, minDeltaDown);
711
770
  const maxDelta = Math.min(maxDeltaDown, maxDeltaUp);
712
771
  //
713
772
  let snapped = false;
714
773
  if (snapBefore) {
715
- const snapView = this.views[snapBefore.index];
774
+ const snapView = this.viewItems[snapBefore.index];
716
775
  const visible = delta >= snapBefore.limitDelta;
717
776
  snapped = visible !== snapView.visible;
718
777
  snapView.setVisible(visible, snapBefore.size);
719
778
  }
720
779
  if (!snapped && snapAfter) {
721
- const snapView = this.views[snapAfter.index];
780
+ const snapView = this.viewItems[snapAfter.index];
722
781
  const visible = delta < snapAfter.limitDelta;
723
782
  snapped = visible !== snapView.visible;
724
783
  snapView.setVisible(visible, snapAfter.size);
@@ -780,7 +839,7 @@
780
839
  );
781
840
  });
782
841
  // Initialize content size and proportions for first layout
783
- this.contentSize = this.views.reduce((r, i) => r + i.size, 0);
842
+ this.contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
784
843
  this.saveProportions();
785
844
  }
786
845
  }
@@ -797,18 +856,18 @@
797
856
  }
798
857
  }
799
858
  isViewVisible(index) {
800
- if (index < 0 || index >= this.views.length) {
859
+ if (index < 0 || index >= this.viewItems.length) {
801
860
  throw new Error('Index out of bounds');
802
861
  }
803
- const viewItem = this.views[index];
862
+ const viewItem = this.viewItems[index];
804
863
  return viewItem.visible;
805
864
  }
806
865
  setViewVisible(index, visible) {
807
- if (index < 0 || index >= this.views.length) {
866
+ if (index < 0 || index >= this.viewItems.length) {
808
867
  throw new Error('Index out of bounds');
809
868
  }
810
869
  toggleClass(this.container, 'visible', visible);
811
- const viewItem = this.views[index];
870
+ const viewItem = this.viewItems[index];
812
871
  toggleClass(this.container, 'visible', visible);
813
872
  viewItem.setVisible(visible, viewItem.size);
814
873
  this.distributeEmptySpace(index);
@@ -816,33 +875,33 @@
816
875
  this.saveProportions();
817
876
  }
818
877
  getViewSize(index) {
819
- if (index < 0 || index >= this.views.length) {
878
+ if (index < 0 || index >= this.viewItems.length) {
820
879
  return -1;
821
880
  }
822
- return this.views[index].size;
881
+ return this.viewItems[index].size;
823
882
  }
824
883
  resizeView(index, size) {
825
- if (index < 0 || index >= this.views.length) {
884
+ if (index < 0 || index >= this.viewItems.length) {
826
885
  return;
827
886
  }
828
- const indexes = range(this.views.length).filter((i) => i !== index);
887
+ const indexes = range(this.viewItems.length).filter((i) => i !== index);
829
888
  const lowPriorityIndexes = [
830
- ...indexes.filter((i) => this.views[i].priority === exports.LayoutPriority.Low),
889
+ ...indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.Low),
831
890
  index,
832
891
  ];
833
- const highPriorityIndexes = indexes.filter((i) => this.views[i].priority === exports.LayoutPriority.High);
834
- const item = this.views[index];
892
+ const highPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.High);
893
+ const item = this.viewItems[index];
835
894
  size = Math.round(size);
836
895
  size = clamp(size, item.minimumSize, Math.min(item.maximumSize, this._size));
837
896
  item.size = size;
838
897
  this.relayout(lowPriorityIndexes, highPriorityIndexes);
839
898
  }
840
899
  getViews() {
841
- return this.views.map((x) => x.view);
900
+ return this.viewItems.map((x) => x.view);
842
901
  }
843
902
  onDidChange(item, size) {
844
- const index = this.views.indexOf(item);
845
- if (index < 0 || index >= this.views.length) {
903
+ const index = this.viewItems.indexOf(item);
904
+ if (index < 0 || index >= this.viewItems.length) {
846
905
  return;
847
906
  }
848
907
  size = typeof size === 'number' ? size : item.size;
@@ -850,7 +909,7 @@
850
909
  item.size = size;
851
910
  this.relayout([index]);
852
911
  }
853
- addView(view, size = { type: 'distribute' }, index = this.views.length, skipLayout) {
912
+ addView(view, size = { type: 'distribute' }, index = this.viewItems.length, skipLayout) {
854
913
  const container = document.createElement('div');
855
914
  container.className = 'view';
856
915
  container.appendChild(view.element);
@@ -868,24 +927,25 @@
868
927
  viewSize = view.minimumSize;
869
928
  }
870
929
  const disposable = view.onDidChange((newSize) => this.onDidChange(viewItem, newSize.size));
871
- const dispose = () => {
872
- disposable === null || disposable === void 0 ? void 0 : disposable.dispose();
873
- this.viewContainer.removeChild(container);
874
- };
875
- const viewItem = new ViewItem(container, view, viewSize, { dispose });
876
- if (index === this.views.length) {
930
+ const viewItem = new ViewItem(container, view, viewSize, {
931
+ dispose: () => {
932
+ disposable.dispose();
933
+ this.viewContainer.removeChild(container);
934
+ },
935
+ });
936
+ if (index === this.viewItems.length) {
877
937
  this.viewContainer.appendChild(container);
878
938
  }
879
939
  else {
880
940
  this.viewContainer.insertBefore(container, this.viewContainer.children.item(index));
881
941
  }
882
- this.views.splice(index, 0, viewItem);
883
- if (this.views.length > 1) {
942
+ this.viewItems.splice(index, 0, viewItem);
943
+ if (this.viewItems.length > 1) {
884
944
  //add sash
885
945
  const sash = document.createElement('div');
886
946
  sash.className = 'sash';
887
947
  const onStart = (event) => {
888
- for (const item of this.views) {
948
+ for (const item of this.viewItems) {
889
949
  item.enabled = false;
890
950
  }
891
951
  const iframes = [
@@ -900,27 +960,29 @@
900
960
  : event.clientY;
901
961
  const sashIndex = firstIndex(this.sashes, (s) => s.container === sash);
902
962
  //
903
- const sizes = this.views.map((x) => x.size);
963
+ const sizes = this.viewItems.map((x) => x.size);
904
964
  //
905
965
  let snapBefore;
906
966
  let snapAfter;
907
967
  const upIndexes = range(sashIndex, -1);
908
- const downIndexes = range(sashIndex + 1, this.views.length);
909
- const minDeltaUp = upIndexes.reduce((r, i) => r + (this.views[i].minimumSize - sizes[i]), 0);
910
- const maxDeltaUp = upIndexes.reduce((r, i) => r + (this.views[i].viewMaximumSize - sizes[i]), 0);
968
+ const downIndexes = range(sashIndex + 1, this.viewItems.length);
969
+ const minDeltaUp = upIndexes.reduce((r, i) => r + (this.viewItems[i].minimumSize - sizes[i]), 0);
970
+ const maxDeltaUp = upIndexes.reduce((r, i) => r + (this.viewItems[i].viewMaximumSize - sizes[i]), 0);
911
971
  const maxDeltaDown = downIndexes.length === 0
912
972
  ? Number.POSITIVE_INFINITY
913
- : downIndexes.reduce((r, i) => r + (sizes[i] - this.views[i].minimumSize), 0);
973
+ : downIndexes.reduce((r, i) => r +
974
+ (sizes[i] - this.viewItems[i].minimumSize), 0);
914
975
  const minDeltaDown = downIndexes.length === 0
915
976
  ? Number.NEGATIVE_INFINITY
916
977
  : downIndexes.reduce((r, i) => r +
917
- (sizes[i] - this.views[i].viewMaximumSize), 0);
978
+ (sizes[i] -
979
+ this.viewItems[i].viewMaximumSize), 0);
918
980
  const minDelta = Math.max(minDeltaUp, minDeltaDown);
919
981
  const maxDelta = Math.min(maxDeltaDown, maxDeltaUp);
920
982
  const snapBeforeIndex = this.findFirstSnapIndex(upIndexes);
921
983
  const snapAfterIndex = this.findFirstSnapIndex(downIndexes);
922
984
  if (typeof snapBeforeIndex === 'number') {
923
- const snappedViewItem = this.views[snapBeforeIndex];
985
+ const snappedViewItem = this.viewItems[snapBeforeIndex];
924
986
  const halfSize = Math.floor(snappedViewItem.viewMinimumSize / 2);
925
987
  snapBefore = {
926
988
  index: snapBeforeIndex,
@@ -931,7 +993,7 @@
931
993
  };
932
994
  }
933
995
  if (typeof snapAfterIndex === 'number') {
934
- const snappedViewItem = this.views[snapAfterIndex];
996
+ const snappedViewItem = this.viewItems[snapAfterIndex];
935
997
  const halfSize = Math.floor(snappedViewItem.viewMinimumSize / 2);
936
998
  snapAfter = {
937
999
  index: snapAfterIndex,
@@ -952,7 +1014,7 @@
952
1014
  this.layoutViews();
953
1015
  };
954
1016
  const end = () => {
955
- for (const item of this.views) {
1017
+ for (const item of this.viewItems) {
956
1018
  item.enabled = true;
957
1019
  }
958
1020
  for (const iframe of iframes) {
@@ -961,12 +1023,10 @@
961
1023
  this.saveProportions();
962
1024
  document.removeEventListener('mousemove', mousemove);
963
1025
  document.removeEventListener('mouseup', end);
964
- document.removeEventListener('mouseend', end);
965
1026
  this._onDidSashEnd.fire(undefined);
966
1027
  };
967
1028
  document.addEventListener('mousemove', mousemove);
968
1029
  document.addEventListener('mouseup', end);
969
- document.addEventListener('mouseend', end);
970
1030
  };
971
1031
  sash.addEventListener('mousedown', onStart);
972
1032
  const sashItem = {
@@ -992,7 +1052,7 @@
992
1052
  distributeViewSizes() {
993
1053
  const flexibleViewItems = [];
994
1054
  let flexibleSize = 0;
995
- for (const item of this.views) {
1055
+ for (const item of this.viewItems) {
996
1056
  if (item.maximumSize - item.minimumSize > 0) {
997
1057
  flexibleViewItems.push(item);
998
1058
  flexibleSize += item.size;
@@ -1002,17 +1062,17 @@
1002
1062
  for (const item of flexibleViewItems) {
1003
1063
  item.size = clamp(size, item.minimumSize, item.maximumSize);
1004
1064
  }
1005
- const indexes = range(this.views.length);
1006
- const lowPriorityIndexes = indexes.filter((i) => this.views[i].priority === exports.LayoutPriority.Low);
1007
- const highPriorityIndexes = indexes.filter((i) => this.views[i].priority === exports.LayoutPriority.High);
1065
+ const indexes = range(this.viewItems.length);
1066
+ const lowPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.Low);
1067
+ const highPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.High);
1008
1068
  this.relayout(lowPriorityIndexes, highPriorityIndexes);
1009
1069
  }
1010
1070
  removeView(index, sizing, skipLayout = false) {
1011
1071
  // Remove view
1012
- const viewItem = this.views.splice(index, 1)[0];
1072
+ const viewItem = this.viewItems.splice(index, 1)[0];
1013
1073
  viewItem.dispose();
1014
1074
  // Remove sash
1015
- if (this.views.length >= 1) {
1075
+ if (this.viewItems.length >= 1) {
1016
1076
  const sashIndex = Math.max(index - 1, 0);
1017
1077
  const sashItem = this.sashes.splice(sashIndex, 1)[0];
1018
1078
  sashItem.disposable();
@@ -1027,10 +1087,10 @@
1027
1087
  return viewItem.view;
1028
1088
  }
1029
1089
  getViewCachedVisibleSize(index) {
1030
- if (index < 0 || index >= this.views.length) {
1090
+ if (index < 0 || index >= this.viewItems.length) {
1031
1091
  throw new Error('Index out of bounds');
1032
1092
  }
1033
- const viewItem = this.views[index];
1093
+ const viewItem = this.viewItems[index];
1034
1094
  return viewItem.cachedVisibleSize;
1035
1095
  }
1036
1096
  moveView(from, to) {
@@ -1046,14 +1106,14 @@
1046
1106
  this.size = size;
1047
1107
  this.orthogonalSize = orthogonalSize;
1048
1108
  if (!this.proportions) {
1049
- const indexes = range(this.views.length);
1050
- const lowPriorityIndexes = indexes.filter((i) => this.views[i].priority === exports.LayoutPriority.Low);
1051
- const highPriorityIndexes = indexes.filter((i) => this.views[i].priority === exports.LayoutPriority.High);
1052
- this.resize(this.views.length - 1, size - previousSize, undefined, lowPriorityIndexes, highPriorityIndexes);
1109
+ const indexes = range(this.viewItems.length);
1110
+ const lowPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.Low);
1111
+ const highPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.High);
1112
+ this.resize(this.viewItems.length - 1, size - previousSize, undefined, lowPriorityIndexes, highPriorityIndexes);
1053
1113
  }
1054
1114
  else {
1055
- for (let i = 0; i < this.views.length; i++) {
1056
- const item = this.views[i];
1115
+ for (let i = 0; i < this.viewItems.length; i++) {
1116
+ const item = this.viewItems[i];
1057
1117
  item.size = clamp(Math.round(this.proportions[i] * size), item.minimumSize, item.maximumSize);
1058
1118
  }
1059
1119
  }
@@ -1061,18 +1121,18 @@
1061
1121
  this.layoutViews();
1062
1122
  }
1063
1123
  relayout(lowPriorityIndexes, highPriorityIndexes) {
1064
- const contentSize = this.views.reduce((r, i) => r + i.size, 0);
1065
- this.resize(this.views.length - 1, this._size - contentSize, undefined, lowPriorityIndexes, highPriorityIndexes);
1124
+ const contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
1125
+ this.resize(this.viewItems.length - 1, this._size - contentSize, undefined, lowPriorityIndexes, highPriorityIndexes);
1066
1126
  this.distributeEmptySpace();
1067
1127
  this.layoutViews();
1068
1128
  this.saveProportions();
1069
1129
  }
1070
1130
  distributeEmptySpace(lowPriorityIndex) {
1071
- const contentSize = this.views.reduce((r, i) => r + i.size, 0);
1131
+ const contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
1072
1132
  let emptyDelta = this.size - contentSize;
1073
- const indexes = range(this.views.length - 1, -1);
1074
- const lowPriorityIndexes = indexes.filter((i) => this.views[i].priority === exports.LayoutPriority.Low);
1075
- const highPriorityIndexes = indexes.filter((i) => this.views[i].priority === exports.LayoutPriority.High);
1133
+ const indexes = range(this.viewItems.length - 1, -1);
1134
+ const lowPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.Low);
1135
+ const highPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.High);
1076
1136
  for (const index of highPriorityIndexes) {
1077
1137
  pushToStart(indexes, index);
1078
1138
  }
@@ -1083,7 +1143,7 @@
1083
1143
  pushToEnd(indexes, lowPriorityIndex);
1084
1144
  }
1085
1145
  for (let i = 0; emptyDelta !== 0 && i < indexes.length; i++) {
1086
- const item = this.views[indexes[i]];
1146
+ const item = this.viewItems[indexes[i]];
1087
1147
  const size = clamp(item.size + emptyDelta, item.minimumSize, item.maximumSize);
1088
1148
  const viewDelta = size - item.size;
1089
1149
  emptyDelta -= viewDelta;
@@ -1092,16 +1152,16 @@
1092
1152
  }
1093
1153
  saveProportions() {
1094
1154
  if (this.proportionalLayout && this.contentSize > 0) {
1095
- this._proportions = this.views.map((i) => i.size / this.contentSize);
1155
+ this._proportions = this.viewItems.map((i) => i.size / this.contentSize);
1096
1156
  }
1097
1157
  }
1098
1158
  layoutViews() {
1099
- this.contentSize = this.views.reduce((r, i) => r + i.size, 0);
1159
+ this.contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
1100
1160
  let sum = 0;
1101
1161
  const x = [];
1102
1162
  this.updateSashEnablement();
1103
- for (let i = 0; i < this.views.length - 1; i++) {
1104
- sum += this.views[i].size;
1163
+ for (let i = 0; i < this.viewItems.length - 1; i++) {
1164
+ sum += this.viewItems[i].size;
1105
1165
  x.push(sum);
1106
1166
  const offset = Math.min(Math.max(0, sum - 2), this.size - 4);
1107
1167
  if (this._orientation === exports.Orientation.HORIZONTAL) {
@@ -1113,7 +1173,7 @@
1113
1173
  this.sashes[i].container.style.top = `${offset}px`;
1114
1174
  }
1115
1175
  }
1116
- this.views.forEach((view, i) => {
1176
+ this.viewItems.forEach((view, i) => {
1117
1177
  if (this._orientation === exports.Orientation.HORIZONTAL) {
1118
1178
  view.container.style.width = `${view.size}px`;
1119
1179
  view.container.style.left = i == 0 ? '0px' : `${x[i - 1]}px`;
@@ -1132,7 +1192,7 @@
1132
1192
  findFirstSnapIndex(indexes) {
1133
1193
  // visible views first
1134
1194
  for (const index of indexes) {
1135
- const viewItem = this.views[index];
1195
+ const viewItem = this.viewItems[index];
1136
1196
  if (!viewItem.visible) {
1137
1197
  continue;
1138
1198
  }
@@ -1142,7 +1202,7 @@
1142
1202
  }
1143
1203
  // then, hidden views
1144
1204
  for (const index of indexes) {
1145
- const viewItem = this.views[index];
1205
+ const viewItem = this.viewItems[index];
1146
1206
  if (viewItem.visible &&
1147
1207
  viewItem.maximumSize - viewItem.minimumSize > 0) {
1148
1208
  return undefined;
@@ -1155,10 +1215,10 @@
1155
1215
  }
1156
1216
  updateSashEnablement() {
1157
1217
  let previous = false;
1158
- const collapsesDown = this.views.map((i) => (previous = i.size - i.minimumSize > 0 || previous));
1218
+ const collapsesDown = this.viewItems.map((i) => (previous = i.size - i.minimumSize > 0 || previous));
1159
1219
  previous = false;
1160
- const expandsDown = this.views.map((i) => (previous = i.maximumSize - i.size > 0 || previous));
1161
- const reverseViews = [...this.views].reverse();
1220
+ const expandsDown = this.viewItems.map((i) => (previous = i.maximumSize - i.size > 0 || previous));
1221
+ const reverseViews = [...this.viewItems].reverse();
1162
1222
  previous = false;
1163
1223
  const collapsesUp = reverseViews
1164
1224
  .map((i) => (previous = i.size - i.minimumSize > 0 || previous))
@@ -1170,19 +1230,19 @@
1170
1230
  let position = 0;
1171
1231
  for (let index = 0; index < this.sashes.length; index++) {
1172
1232
  const sash = this.sashes[index];
1173
- const viewItem = this.views[index];
1233
+ const viewItem = this.viewItems[index];
1174
1234
  position += viewItem.size;
1175
1235
  const min = !(collapsesDown[index] && expandsUp[index + 1]);
1176
1236
  const max = !(expandsDown[index] && collapsesUp[index + 1]);
1177
1237
  if (min && max) {
1178
1238
  const upIndexes = range(index, -1);
1179
- const downIndexes = range(index + 1, this.views.length);
1239
+ const downIndexes = range(index + 1, this.viewItems.length);
1180
1240
  const snapBeforeIndex = this.findFirstSnapIndex(upIndexes);
1181
1241
  const snapAfterIndex = this.findFirstSnapIndex(downIndexes);
1182
1242
  const snappedBefore = typeof snapBeforeIndex === 'number' &&
1183
- !this.views[snapBeforeIndex].visible;
1243
+ !this.viewItems[snapBeforeIndex].visible;
1184
1244
  const snappedAfter = typeof snapAfterIndex === 'number' &&
1185
- !this.views[snapAfterIndex].visible;
1245
+ !this.viewItems[snapAfterIndex].visible;
1186
1246
  if (snappedBefore &&
1187
1247
  collapsesUp[index] &&
1188
1248
  (position > 0 || this.startSnappingEnabled)) {
@@ -1242,6 +1302,9 @@
1242
1302
  break;
1243
1303
  }
1244
1304
  }
1305
+ for (const viewItem of this.viewItems) {
1306
+ viewItem.dispose();
1307
+ }
1245
1308
  this.element.remove();
1246
1309
  }
1247
1310
  }
@@ -1676,7 +1739,7 @@
1676
1739
  throw new Error('Invalid index');
1677
1740
  }
1678
1741
  this.splitview.removeView(index, sizing);
1679
- this._removeChild(index);
1742
+ return this._removeChild(index);
1680
1743
  }
1681
1744
  _addChild(node, index) {
1682
1745
  this.children.splice(index, 0, node);
@@ -1698,10 +1761,10 @@
1698
1761
  });
1699
1762
  }
1700
1763
  dispose() {
1701
- super.dispose();
1702
1764
  this._childrenDisposable.dispose();
1703
- this.children.forEach((child) => child.dispose());
1704
1765
  this.splitview.dispose();
1766
+ this.children.forEach((child) => child.dispose());
1767
+ super.dispose();
1705
1768
  }
1706
1769
  }
1707
1770
 
@@ -1931,7 +1994,8 @@
1931
1994
  if (oldRoot.children.length === 1) {
1932
1995
  // can remove one level of redundant branching if there is only a single child
1933
1996
  const childReference = oldRoot.children[0];
1934
- oldRoot.removeChild(0); // remove to prevent disposal when disposing of unwanted root
1997
+ const child = oldRoot.removeChild(0); // remove to prevent disposal when disposing of unwanted root
1998
+ child.dispose();
1935
1999
  oldRoot.dispose();
1936
2000
  this._root.addChild(
1937
2001
  /**
@@ -2038,7 +2102,8 @@
2038
2102
  if (typeof newSiblingCachedVisibleSize === 'number') {
2039
2103
  newSiblingSize = exports.Sizing.Invisible(newSiblingCachedVisibleSize);
2040
2104
  }
2041
- grandParent.removeChild(parentIndex);
2105
+ const child = grandParent.removeChild(parentIndex);
2106
+ child.dispose();
2042
2107
  const newParent = new BranchNode(parent.orientation, this.proportionalLayout, this.styles, parent.size, parent.orthogonalSize);
2043
2108
  grandParent.addChild(newParent, parent.size, parentIndex);
2044
2109
  const newSibling = new LeafNode(parent.view, grandParent.orientation, parent.size);
@@ -2600,6 +2665,7 @@
2600
2665
  }
2601
2666
  dispose() {
2602
2667
  this.removeDropTarget();
2668
+ super.dispose();
2603
2669
  }
2604
2670
  toggleClasses(quadrant, width, height) {
2605
2671
  var _a, _b, _c, _d;
@@ -2777,8 +2843,8 @@
2777
2843
  if (this.panel.view) {
2778
2844
  const _onDidFocus = this.panel.view.content.onDidFocus;
2779
2845
  const _onDidBlur = this.panel.view.content.onDidBlur;
2780
- const { onDidFocus, onDidBlur } = trackFocus(this._element);
2781
- disposable.addDisposables(onDidFocus(() => this._onDidFocus.fire()), onDidBlur(() => this._onDidBlur.fire()));
2846
+ const focusTracker = trackFocus(this._element);
2847
+ disposable.addDisposables(focusTracker, focusTracker.onDidFocus(() => this._onDidFocus.fire()), focusTracker.onDidBlur(() => this._onDidBlur.fire()));
2782
2848
  if (_onDidFocus) {
2783
2849
  disposable.addDisposables(_onDidFocus(() => this._onDidFocus.fire()));
2784
2850
  }
@@ -2817,24 +2883,32 @@
2817
2883
  constructor(el) {
2818
2884
  super();
2819
2885
  this.el = el;
2820
- this.disposable = new MutableDisposable();
2886
+ this.dataDisposable = new MutableDisposable();
2887
+ this.pointerEventsDisposable = new MutableDisposable();
2821
2888
  this._onDragStart = new Emitter();
2822
2889
  this.onDragStart = this._onDragStart.event;
2823
- this.iframes = [];
2890
+ this.addDisposables(this._onDragStart, this.dataDisposable, this.pointerEventsDisposable);
2824
2891
  this.configure();
2825
2892
  }
2826
2893
  configure() {
2827
2894
  this.addDisposables(this._onDragStart, addDisposableListener(this.el, 'dragstart', (event) => {
2828
- this.iframes = [
2895
+ const iframes = [
2829
2896
  ...getElementsByTagName('iframe'),
2830
2897
  ...getElementsByTagName('webview'),
2831
2898
  ];
2832
- for (const iframe of this.iframes) {
2899
+ this.pointerEventsDisposable.value = {
2900
+ dispose: () => {
2901
+ for (const iframe of iframes) {
2902
+ iframe.style.pointerEvents = 'auto';
2903
+ }
2904
+ },
2905
+ };
2906
+ for (const iframe of iframes) {
2833
2907
  iframe.style.pointerEvents = 'none';
2834
2908
  }
2835
2909
  this.el.classList.add('dv-dragged');
2836
2910
  setTimeout(() => this.el.classList.remove('dv-dragged'), 0);
2837
- this.disposable.value = this.getData(event.dataTransfer);
2911
+ this.dataDisposable.value = this.getData(event.dataTransfer);
2838
2912
  if (event.dataTransfer) {
2839
2913
  event.dataTransfer.effectAllowed = 'move';
2840
2914
  /**
@@ -2849,11 +2923,8 @@
2849
2923
  event.dataTransfer.setData('text/plain', '__dockview_internal_drag_event__');
2850
2924
  }
2851
2925
  }), addDisposableListener(this.el, 'dragend', () => {
2852
- for (const iframe of this.iframes) {
2853
- iframe.style.pointerEvents = 'auto';
2854
- }
2855
- this.iframes = [];
2856
- this.disposable.dispose();
2926
+ this.pointerEventsDisposable.dispose();
2927
+ this.dataDisposable.dispose();
2857
2928
  }));
2858
2929
  }
2859
2930
  }
@@ -2871,13 +2942,12 @@
2871
2942
  this.onChanged = this._onChanged.event;
2872
2943
  this._onDropped = new Emitter();
2873
2944
  this.onDrop = this._onDropped.event;
2874
- this.addDisposables(this._onChanged, this._onDropped);
2875
2945
  this._element = document.createElement('div');
2876
2946
  this._element.className = 'tab';
2877
2947
  this._element.tabIndex = 0;
2878
2948
  this._element.draggable = true;
2879
2949
  toggleClass(this.element, 'inactive-tab', true);
2880
- this.addDisposables(new (class Handler extends DragHandler {
2950
+ this.addDisposables(this._onChanged, this._onDropped, new (class Handler extends DragHandler {
2881
2951
  constructor() {
2882
2952
  super(...arguments);
2883
2953
  this.panelTransfer = LocalSelectionTransfer.getInstance();
@@ -2890,9 +2960,6 @@
2890
2960
  },
2891
2961
  };
2892
2962
  }
2893
- dispose() {
2894
- //
2895
- }
2896
2963
  })(this._element));
2897
2964
  this.addDisposables(addDisposableListener(this._element, 'mousedown', (event) => {
2898
2965
  if (event.defaultPrevented) {
@@ -2927,7 +2994,7 @@
2927
2994
  });
2928
2995
  this.addDisposables(this.droptarget.onDrop((event) => {
2929
2996
  this._onDropped.fire(event);
2930
- }));
2997
+ }), this.droptarget);
2931
2998
  }
2932
2999
  setActive(isActive) {
2933
3000
  toggleClass(this.element, 'active-tab', isActive);
@@ -2942,7 +3009,6 @@
2942
3009
  }
2943
3010
  dispose() {
2944
3011
  super.dispose();
2945
- this.droptarget.dispose();
2946
3012
  }
2947
3013
  }
2948
3014
 
@@ -2988,9 +3054,6 @@
2988
3054
  },
2989
3055
  };
2990
3056
  }
2991
- dispose() {
2992
- //
2993
- }
2994
3057
  }
2995
3058
 
2996
3059
  class VoidContainer extends CompositeDisposable {
@@ -3146,6 +3209,7 @@
3146
3209
  const tabToRemove = this.tabs.splice(index, 1)[0];
3147
3210
  const { value, disposable } = tabToRemove;
3148
3211
  disposable.dispose();
3212
+ value.dispose();
3149
3213
  value.element.remove();
3150
3214
  }
3151
3215
  setActivePanel(panel) {
@@ -3189,9 +3253,10 @@
3189
3253
  }
3190
3254
  dispose() {
3191
3255
  super.dispose();
3192
- this.tabs.forEach((tab) => {
3193
- tab.disposable.dispose();
3194
- });
3256
+ for (const { value, disposable } of this.tabs) {
3257
+ disposable.dispose();
3258
+ value.dispose();
3259
+ }
3195
3260
  this.tabs = [];
3196
3261
  }
3197
3262
  }
@@ -3289,7 +3354,7 @@
3289
3354
  container.append(this.tabsContainer.element, this.contentContainer.element);
3290
3355
  this.header.hidden = !!options.hideHeader;
3291
3356
  this.locked = !!options.locked;
3292
- this.addDisposables(this._onMove, this._onDidChange, this._onDidDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange, this.tabsContainer.onDrop((event) => {
3357
+ this.addDisposables(this.tabsContainer.onDrop((event) => {
3293
3358
  this.handleDropEvent(event.event, 'center', event.index);
3294
3359
  }), this.contentContainer.onDidFocus(() => {
3295
3360
  this.accessor.doSetGroupActive(this.groupPanel, true);
@@ -3297,7 +3362,7 @@
3297
3362
  // noop
3298
3363
  }), this.dropTarget.onDrop((event) => {
3299
3364
  this.handleDropEvent(event.nativeEvent, event.position);
3300
- }));
3365
+ }), this._onMove, this._onDidChange, this._onDidDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange);
3301
3366
  }
3302
3367
  initialize() {
3303
3368
  var _a, _b;
@@ -3731,8 +3796,7 @@
3731
3796
  this.layout(0, 0, true); // set some elements height/widths
3732
3797
  this.addDisposables(this.gridview.onDidChange(() => {
3733
3798
  this._bufferOnDidLayoutChange.fire();
3734
- }));
3735
- this.addDisposables(exports.DockviewEvent.any(this.onDidAddGroup, this.onDidRemoveGroup, this.onDidActiveGroupChange)(() => {
3799
+ }), exports.DockviewEvent.any(this.onDidAddGroup, this.onDidRemoveGroup, this.onDidActiveGroupChange)(() => {
3736
3800
  this._bufferOnDidLayoutChange.fire();
3737
3801
  }), this._bufferOnDidLayoutChange.onEvent(() => {
3738
3802
  this._onDidLayoutChange.fire();
@@ -3835,7 +3899,6 @@
3835
3899
  this.gridview.layout(width, height);
3836
3900
  }
3837
3901
  dispose() {
3838
- super.dispose();
3839
3902
  this._onDidActiveGroupChange.dispose();
3840
3903
  this._onDidAddGroup.dispose();
3841
3904
  this._onDidRemoveGroup.dispose();
@@ -3844,6 +3907,7 @@
3844
3907
  group.dispose();
3845
3908
  }
3846
3909
  this.gridview.dispose();
3910
+ super.dispose();
3847
3911
  }
3848
3912
  }
3849
3913
 
@@ -3907,7 +3971,7 @@
3907
3971
  //
3908
3972
  this._onUpdateParameters = new Emitter();
3909
3973
  this.onUpdateParameters = this._onUpdateParameters.event;
3910
- this.addDisposables(this.panelUpdatesDisposable, this._onDidDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onFocusEvent, this._onActiveChange, this._onVisibilityChange, this._onUpdateParameters, this.onDidFocusChange((event) => {
3974
+ this.addDisposables(this.onDidFocusChange((event) => {
3911
3975
  this._isFocused = event.isFocused;
3912
3976
  }), this.onDidActiveChange((event) => {
3913
3977
  this._isActive = event.isActive;
@@ -3916,14 +3980,12 @@
3916
3980
  }), this.onDidDimensionsChange((event) => {
3917
3981
  this._width = event.width;
3918
3982
  this._height = event.height;
3919
- }));
3983
+ }), this.panelUpdatesDisposable, this._onDidDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onFocusEvent, this._onActiveChange, this._onVisibilityChange, this._onUpdateParameters);
3920
3984
  }
3921
3985
  initialize(panel) {
3922
3986
  this.panelUpdatesDisposable.value = this._onUpdateParameters.event((parameters) => {
3923
3987
  panel.update({
3924
- params: {
3925
- params: parameters,
3926
- },
3988
+ params: parameters,
3927
3989
  });
3928
3990
  });
3929
3991
  }
@@ -4018,12 +4080,12 @@
4018
4080
  this._element.style.height = '100%';
4019
4081
  this._element.style.width = '100%';
4020
4082
  this._element.style.overflow = 'hidden';
4021
- const { onDidFocus, onDidBlur } = trackFocus(this._element);
4022
- this.addDisposables(this.api, onDidFocus(() => {
4083
+ const focusTracker = trackFocus(this._element);
4084
+ this.addDisposables(this.api, focusTracker.onDidFocus(() => {
4023
4085
  this.api._onDidChangeFocus.fire({ isFocused: true });
4024
- }), onDidBlur(() => {
4086
+ }), focusTracker.onDidBlur(() => {
4025
4087
  this.api._onDidChangeFocus.fire({ isFocused: false });
4026
- }));
4088
+ }), focusTracker);
4027
4089
  }
4028
4090
  focus() {
4029
4091
  this.api._onFocusEvent.fire();
@@ -4044,7 +4106,18 @@
4044
4106
  }
4045
4107
  update(event) {
4046
4108
  var _a, _b;
4109
+ // merge the new parameters with the existing parameters
4047
4110
  this._params = Object.assign(Object.assign({}, this._params), { params: Object.assign(Object.assign({}, (_a = this._params) === null || _a === void 0 ? void 0 : _a.params), event.params) });
4111
+ /**
4112
+ * delete new keys that have a value of undefined,
4113
+ * allow values of null
4114
+ */
4115
+ for (const key of Object.keys(event.params)) {
4116
+ if (event.params[key] === undefined) {
4117
+ delete this._params.params[key];
4118
+ }
4119
+ }
4120
+ // update the view with the updated props
4048
4121
  (_b = this.part) === null || _b === void 0 ? void 0 : _b.update({ params: this._params.params });
4049
4122
  }
4050
4123
  toJSON() {
@@ -4058,9 +4131,9 @@
4058
4131
  }
4059
4132
  dispose() {
4060
4133
  var _a;
4061
- super.dispose();
4062
4134
  this.api.dispose();
4063
4135
  (_a = this.part) === null || _a === void 0 ? void 0 : _a.dispose();
4136
+ super.dispose();
4064
4137
  }
4065
4138
  }
4066
4139
 
@@ -4439,7 +4512,7 @@
4439
4512
  this._maximumHeight = options.maximumHeight;
4440
4513
  }
4441
4514
  this.api.initialize(this); // TODO: required to by-pass 'super before this' requirement
4442
- this.addDisposables(this._onDidChange, this.api.onVisibilityChange((event) => {
4515
+ this.addDisposables(this.api.onVisibilityChange((event) => {
4443
4516
  const { isVisible } = event;
4444
4517
  const { accessor } = this._params;
4445
4518
  accessor.setVisible(this, isVisible);
@@ -4468,7 +4541,7 @@
4468
4541
  height: event.height,
4469
4542
  width: event.width,
4470
4543
  });
4471
- }));
4544
+ }), this._onDidChange);
4472
4545
  }
4473
4546
  setVisible(isVisible) {
4474
4547
  this.api._onDidVisibilityChange.fire({ isVisible });
@@ -4625,7 +4698,7 @@
4625
4698
  this.addDisposables(this.disposable, this._onDidTitleChange, this._onDidGroupChange, this._onDidActiveGroupChange);
4626
4699
  }
4627
4700
  setTitle(title) {
4628
- this.panel.update({ params: { title } });
4701
+ this.panel.setTitle(title);
4629
4702
  }
4630
4703
  close() {
4631
4704
  this.group.model.closePanel(this.panel);
@@ -4690,12 +4763,18 @@
4690
4763
  }
4691
4764
  }
4692
4765
  update(event) {
4693
- const params = event.params;
4694
- this._params = Object.assign(Object.assign({}, (this._params || {})), event.params.params);
4695
- if (params.title !== this.title) {
4696
- this._title = params.title;
4697
- this.api._onDidTitleChange.fire({ title: params.title });
4766
+ // merge the new parameters with the existing parameters
4767
+ this._params = Object.assign(Object.assign({}, (this._params || {})), event.params);
4768
+ /**
4769
+ * delete new keys that have a value of undefined,
4770
+ * allow values of null
4771
+ */
4772
+ for (const key of Object.keys(event.params)) {
4773
+ if (event.params[key] === undefined) {
4774
+ delete this._params[key];
4775
+ }
4698
4776
  }
4777
+ // update the view with the updated props
4699
4778
  this.view.update({
4700
4779
  params: {
4701
4780
  params: this._params,
@@ -5071,7 +5150,7 @@
5071
5150
  size: { type: 'pixels', value: 20 },
5072
5151
  },
5073
5152
  });
5074
- this.addDisposables(dropTarget, dropTarget.onDrop((event) => {
5153
+ this.addDisposables(dropTarget.onDrop((event) => {
5075
5154
  const data = getPanelData();
5076
5155
  if (data) {
5077
5156
  this.moveGroupOrPanel(this.orthogonalize(event.position), data.groupId, data.panelId || undefined, 'center');
@@ -5079,7 +5158,7 @@
5079
5158
  else {
5080
5159
  this._onDidDrop.fire(Object.assign(Object.assign({}, event), { api: this._api, group: null, getData: getPanelData }));
5081
5160
  }
5082
- }));
5161
+ }), dropTarget);
5083
5162
  this._api = new DockviewApi(this);
5084
5163
  this.updateWatermark();
5085
5164
  }
@@ -5403,31 +5482,33 @@
5403
5482
  }
5404
5483
  super.doRemoveGroup(group, { skipActive });
5405
5484
  }
5406
- moveGroupOrPanel(referenceGroup, groupId, itemId, target, index) {
5485
+ moveGroupOrPanel(destinationGroup, sourceGroupId, sourceItemId, destinationTarget, destinationIndex) {
5407
5486
  var _a;
5408
- const sourceGroup = groupId
5409
- ? (_a = this._groups.get(groupId)) === null || _a === void 0 ? void 0 : _a.value
5487
+ const sourceGroup = sourceGroupId
5488
+ ? (_a = this._groups.get(sourceGroupId)) === null || _a === void 0 ? void 0 : _a.value
5410
5489
  : undefined;
5411
- if (itemId === undefined) {
5490
+ if (sourceItemId === undefined) {
5412
5491
  if (sourceGroup) {
5413
- this.moveGroup(sourceGroup, referenceGroup, target);
5492
+ this.moveGroup(sourceGroup, destinationGroup, destinationTarget);
5414
5493
  }
5415
5494
  return;
5416
5495
  }
5417
- if (!target || target === 'center') {
5418
- const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(itemId)) ||
5419
- this.panels.find((panel) => panel.id === itemId);
5496
+ if (!destinationTarget || destinationTarget === 'center') {
5497
+ const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(sourceItemId)) ||
5498
+ this.panels.find((panel) => panel.id === sourceItemId);
5420
5499
  if (!groupItem) {
5421
- throw new Error(`No panel with id ${itemId}`);
5500
+ throw new Error(`No panel with id ${sourceItemId}`);
5422
5501
  }
5423
5502
  if ((sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.size) === 0) {
5424
5503
  this.doRemoveGroup(sourceGroup);
5425
5504
  }
5426
- referenceGroup.model.openPanel(groupItem, { index });
5505
+ destinationGroup.model.openPanel(groupItem, {
5506
+ index: destinationIndex,
5507
+ });
5427
5508
  }
5428
5509
  else {
5429
- const referenceLocation = getGridLocation(referenceGroup.element);
5430
- const targetLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
5510
+ const referenceLocation = getGridLocation(destinationGroup.element);
5511
+ const targetLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
5431
5512
  if (sourceGroup && sourceGroup.size < 2) {
5432
5513
  const [targetParentLocation, to] = tail(targetLocation);
5433
5514
  const sourceLocation = getGridLocation(sourceGroup.element);
@@ -5445,18 +5526,18 @@
5445
5526
  skipDispose: true,
5446
5527
  });
5447
5528
  // after deleting the group we need to re-evaulate the ref location
5448
- const updatedReferenceLocation = getGridLocation(referenceGroup.element);
5449
- const location = getRelativeLocation(this.gridview.orientation, updatedReferenceLocation, target);
5529
+ const updatedReferenceLocation = getGridLocation(destinationGroup.element);
5530
+ const location = getRelativeLocation(this.gridview.orientation, updatedReferenceLocation, destinationTarget);
5450
5531
  this.doAddGroup(targetGroup, location);
5451
5532
  }
5452
5533
  }
5453
5534
  else {
5454
- const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(itemId)) ||
5455
- this.panels.find((panel) => panel.id === itemId);
5535
+ const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(sourceItemId)) ||
5536
+ this.panels.find((panel) => panel.id === sourceItemId);
5456
5537
  if (!groupItem) {
5457
- throw new Error(`No panel with id ${itemId}`);
5538
+ throw new Error(`No panel with id ${sourceItemId}`);
5458
5539
  }
5459
- const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
5540
+ const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
5460
5541
  const group = this.createGroupAtLocation(dropLocation);
5461
5542
  group.model.openPanel(groupItem);
5462
5543
  }
@@ -5550,11 +5631,11 @@
5550
5631
  return (_a = Array.from(this._groups.values()).find((group) => group.value.model.containsPanel(panel))) === null || _a === void 0 ? void 0 : _a.value;
5551
5632
  }
5552
5633
  dispose() {
5553
- super.dispose();
5554
5634
  this._onDidActivePanelChange.dispose();
5555
5635
  this._onDidAddPanel.dispose();
5556
5636
  this._onDidRemovePanel.dispose();
5557
5637
  this._onDidLayoutFromJSON.dispose();
5638
+ super.dispose();
5558
5639
  }
5559
5640
  }
5560
5641
 
@@ -5812,7 +5893,7 @@
5812
5893
  }
5813
5894
  set splitview(value) {
5814
5895
  this._splitview = value;
5815
- this._disposable.value = new CompositeDisposable(this._splitview.onDidSashEnd(() => {
5896
+ this._splitviewChangeDisposable.value = new CompositeDisposable(this._splitview.onDidSashEnd(() => {
5816
5897
  this._onDidLayoutChange.fire(undefined);
5817
5898
  }), this._splitview.onDidAddView((e) => this._onDidAddView.fire(e)), this._splitview.onDidRemoveView((e) => this._onDidRemoveView.fire(e)));
5818
5899
  }
@@ -5834,7 +5915,7 @@
5834
5915
  }
5835
5916
  constructor(options) {
5836
5917
  super(options.parentElement);
5837
- this._disposable = new MutableDisposable();
5918
+ this._splitviewChangeDisposable = new MutableDisposable();
5838
5919
  this._panels = new Map();
5839
5920
  this._onDidLayoutfromJSON = new Emitter();
5840
5921
  this.onDidLayoutFromJSON = this._onDidLayoutfromJSON.event;
@@ -5852,7 +5933,7 @@
5852
5933
  options.frameworkComponents = {};
5853
5934
  }
5854
5935
  this.splitview = new Splitview(this.element, options);
5855
- this.addDisposables(this._disposable, this._onDidAddView, this._onDidLayoutfromJSON, this._onDidRemoveView, this._onDidLayoutChange);
5936
+ this.addDisposables(this._onDidAddView, this._onDidLayoutfromJSON, this._onDidRemoveView, this._onDidLayoutChange);
5856
5937
  }
5857
5938
  updateOptions(options) {
5858
5939
  const hasOrientationChanged = typeof options.orientation === 'string' &&
@@ -5890,15 +5971,15 @@
5890
5971
  }
5891
5972
  }
5892
5973
  removePanel(panel, sizing) {
5893
- const disposable = this._panels.get(panel.id);
5894
- if (!disposable) {
5974
+ const item = this._panels.get(panel.id);
5975
+ if (!item) {
5895
5976
  throw new Error(`unknown splitview panel ${panel.id}`);
5896
5977
  }
5897
- disposable.disposable.dispose();
5898
- disposable.value.dispose();
5978
+ item.dispose();
5899
5979
  this._panels.delete(panel.id);
5900
5980
  const index = this.panels.findIndex((_) => _ === panel);
5901
- this.splitview.removeView(index, sizing);
5981
+ const removedView = this.splitview.removeView(index, sizing);
5982
+ removedView.dispose();
5902
5983
  const panels = this.panels;
5903
5984
  if (panels.length > 0) {
5904
5985
  this.setActive(panels[panels.length - 1]);
@@ -5945,7 +6026,7 @@
5945
6026
  }
5946
6027
  this.setActive(view, true);
5947
6028
  });
5948
- this._panels.set(view.id, { disposable, value: view });
6029
+ this._panels.set(view.id, disposable);
5949
6030
  }
5950
6031
  toJSON() {
5951
6032
  var _a;
@@ -6018,20 +6099,26 @@
6018
6099
  this._onDidLayoutfromJSON.fire();
6019
6100
  }
6020
6101
  clear() {
6021
- for (const [_, value] of this._panels.entries()) {
6022
- value.disposable.dispose();
6023
- value.value.dispose();
6102
+ for (const disposable of this._panels.values()) {
6103
+ disposable.dispose();
6024
6104
  }
6025
6105
  this._panels.clear();
6026
- this.splitview.dispose();
6106
+ while (this.splitview.length > 0) {
6107
+ const view = this.splitview.removeView(0, exports.Sizing.Distribute, true);
6108
+ view.dispose();
6109
+ }
6027
6110
  }
6028
6111
  dispose() {
6029
- for (const [_, value] of this._panels.entries()) {
6030
- value.disposable.dispose();
6031
- value.value.dispose();
6112
+ for (const disposable of this._panels.values()) {
6113
+ disposable.dispose();
6032
6114
  }
6033
6115
  this._panels.clear();
6116
+ const views = this.splitview.getViews();
6117
+ this._splitviewChangeDisposable.dispose();
6034
6118
  this.splitview.dispose();
6119
+ for (const view of views) {
6120
+ view.dispose();
6121
+ }
6035
6122
  super.dispose();
6036
6123
  }
6037
6124
  }