dockview 1.7.3 → 1.7.4

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.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview
3
- * @version 1.7.3
3
+ * @version 1.7.4
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -141,9 +141,49 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
141
141
  };
142
142
  };
143
143
  })(exports.DockviewEvent || (exports.DockviewEvent = {}));
144
- // dumb event emitter with better typings than nodes event emitter
145
- // https://github.com/microsoft/vscode/blob/master/src/vs/base/common/event.ts
144
+ class LeakageMonitor {
145
+ constructor() {
146
+ this.events = new Map();
147
+ }
148
+ get size() {
149
+ return this.events.size;
150
+ }
151
+ add(event, stacktrace) {
152
+ this.events.set(event, stacktrace);
153
+ }
154
+ delete(event) {
155
+ this.events.delete(event);
156
+ }
157
+ clear() {
158
+ this.events.clear();
159
+ }
160
+ }
161
+ class Stacktrace {
162
+ static create() {
163
+ var _a;
164
+ return new Stacktrace((_a = new Error().stack) !== null && _a !== void 0 ? _a : '');
165
+ }
166
+ constructor(value) {
167
+ this.value = value;
168
+ }
169
+ print() {
170
+ console.warn(this.value);
171
+ }
172
+ }
173
+ class Listener {
174
+ constructor(callback, stacktrace) {
175
+ this.callback = callback;
176
+ this.stacktrace = stacktrace;
177
+ }
178
+ }
179
+ // relatively simple event emitter taken from https://github.com/microsoft/vscode/blob/master/src/vs/base/common/event.ts
146
180
  class Emitter {
181
+ static setLeakageMonitorEnabled(isEnabled) {
182
+ if (isEnabled !== Emitter.ENABLE_TRACKING) {
183
+ Emitter.MEMORY_LEAK_WATCHER.clear();
184
+ }
185
+ Emitter.ENABLE_TRACKING = isEnabled;
186
+ }
147
187
  constructor(options) {
148
188
  this.options = options;
149
189
  this._listeners = [];
@@ -151,11 +191,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
151
191
  }
152
192
  get event() {
153
193
  if (!this._event) {
154
- this._event = (listener) => {
194
+ this._event = (callback) => {
155
195
  var _a;
156
196
  if (((_a = this.options) === null || _a === void 0 ? void 0 : _a.replay) && this._last !== undefined) {
157
- listener(this._last);
197
+ callback(this._last);
158
198
  }
199
+ const listener = new Listener(callback, Emitter.ENABLE_TRACKING ? Stacktrace.create() : undefined);
159
200
  this._listeners.push(listener);
160
201
  return {
161
202
  dispose: () => {
@@ -163,23 +204,45 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
163
204
  if (index > -1) {
164
205
  this._listeners.splice(index, 1);
165
206
  }
207
+ else if (Emitter.ENABLE_TRACKING) ;
166
208
  },
167
209
  };
168
210
  };
211
+ if (Emitter.ENABLE_TRACKING) {
212
+ Emitter.MEMORY_LEAK_WATCHER.add(this._event, Stacktrace.create());
213
+ }
169
214
  }
170
215
  return this._event;
171
216
  }
172
217
  fire(e) {
173
218
  this._last = e;
174
219
  for (const listener of this._listeners) {
175
- listener(e);
220
+ listener.callback(e);
176
221
  }
177
222
  }
178
223
  dispose() {
179
- this._listeners = [];
180
- this._disposed = true;
224
+ if (!this._disposed) {
225
+ this._disposed = true;
226
+ if (this._listeners.length > 0) {
227
+ if (Emitter.ENABLE_TRACKING) {
228
+ queueMicrotask(() => {
229
+ var _a;
230
+ // don't check until stack of execution is completed to allow for out-of-order disposals within the same execution block
231
+ for (const listener of this._listeners) {
232
+ console.warn((_a = listener.stacktrace) === null || _a === void 0 ? void 0 : _a.print());
233
+ }
234
+ });
235
+ }
236
+ this._listeners = [];
237
+ }
238
+ if (Emitter.ENABLE_TRACKING && this._event) {
239
+ Emitter.MEMORY_LEAK_WATCHER.delete(this._event);
240
+ }
241
+ }
181
242
  }
182
243
  }
244
+ Emitter.ENABLE_TRACKING = false;
245
+ Emitter.MEMORY_LEAK_WATCHER = new LeakageMonitor();
183
246
  function addDisposableWindowListener(element, type, listener, options) {
184
247
  element.addEventListener(type, listener, options);
185
248
  return {
@@ -232,13 +295,13 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
232
295
  }
233
296
  constructor(...args) {
234
297
  this._isDisposed = false;
235
- this.disposables = args;
298
+ this._disposables = args;
236
299
  }
237
300
  addDisposables(...args) {
238
- args.forEach((arg) => this.disposables.push(arg));
301
+ args.forEach((arg) => this._disposables.push(arg));
239
302
  }
240
303
  dispose() {
241
- this.disposables.forEach((arg) => arg.dispose());
304
+ this._disposables.forEach((arg) => arg.dispose());
242
305
  this._isDisposed = true;
243
306
  }
244
307
  }
@@ -328,6 +391,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
328
391
  this.onDidFocus = this._onDidFocus.event;
329
392
  this._onDidBlur = new Emitter();
330
393
  this.onDidBlur = this._onDidBlur.event;
394
+ this.addDisposables(this._onDidFocus, this._onDidBlur);
331
395
  let hasFocus = isAncestor(document.activeElement, element);
332
396
  let loosingFocus = false;
333
397
  const onFocus = () => {
@@ -372,11 +436,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
372
436
  refreshState() {
373
437
  this._refreshStateHandler();
374
438
  }
375
- dispose() {
376
- super.dispose();
377
- this._onDidBlur.dispose();
378
- this._onDidFocus.dispose();
379
- }
380
439
  }
381
440
 
382
441
  function createComponent(id, componentName, components = {}, frameworkComponents = {}, createFrameworkComponent, fallback) {
@@ -605,7 +664,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
605
664
  this._orthogonalSize = value;
606
665
  }
607
666
  get length() {
608
- return this.views.length;
667
+ return this.viewItems.length;
609
668
  }
610
669
  get proportions() {
611
670
  return this._proportions ? [...this._proportions] : undefined;
@@ -624,12 +683,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
624
683
  : 'vertical');
625
684
  }
626
685
  get minimumSize() {
627
- return this.views.reduce((r, item) => r + item.minimumSize, 0);
686
+ return this.viewItems.reduce((r, item) => r + item.minimumSize, 0);
628
687
  }
629
688
  get maximumSize() {
630
689
  return this.length === 0
631
690
  ? Number.POSITIVE_INFINITY
632
- : this.views.reduce((r, item) => r + item.maximumSize, 0);
691
+ : this.viewItems.reduce((r, item) => r + item.maximumSize, 0);
633
692
  }
634
693
  get startSnappingEnabled() {
635
694
  return this._startSnappingEnabled;
@@ -653,7 +712,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
653
712
  }
654
713
  constructor(container, options) {
655
714
  this.container = container;
656
- this.views = [];
715
+ this.viewItems = [];
657
716
  this.sashes = [];
658
717
  this._size = 0;
659
718
  this._orthogonalSize = 0;
@@ -667,12 +726,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
667
726
  this.onDidAddView = this._onDidAddView.event;
668
727
  this._onDidRemoveView = new Emitter();
669
728
  this.onDidRemoveView = this._onDidRemoveView.event;
670
- this.resize = (index, delta, sizes = this.views.map((x) => x.size), lowPriorityIndexes, highPriorityIndexes, overloadMinDelta = Number.NEGATIVE_INFINITY, overloadMaxDelta = Number.POSITIVE_INFINITY, snapBefore, snapAfter) => {
671
- if (index < 0 || index > this.views.length) {
729
+ this.resize = (index, delta, sizes = this.viewItems.map((x) => x.size), lowPriorityIndexes, highPriorityIndexes, overloadMinDelta = Number.NEGATIVE_INFINITY, overloadMaxDelta = Number.POSITIVE_INFINITY, snapBefore, snapAfter) => {
730
+ if (index < 0 || index > this.viewItems.length) {
672
731
  return 0;
673
732
  }
674
733
  const upIndexes = range(index, -1);
675
- const downIndexes = range(index + 1, this.views.length);
734
+ const downIndexes = range(index + 1, this.viewItems.length);
676
735
  //
677
736
  if (highPriorityIndexes) {
678
737
  for (const i of highPriorityIndexes) {
@@ -687,34 +746,34 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
687
746
  }
688
747
  }
689
748
  //
690
- const upItems = upIndexes.map((i) => this.views[i]);
749
+ const upItems = upIndexes.map((i) => this.viewItems[i]);
691
750
  const upSizes = upIndexes.map((i) => sizes[i]);
692
751
  //
693
- const downItems = downIndexes.map((i) => this.views[i]);
752
+ const downItems = downIndexes.map((i) => this.viewItems[i]);
694
753
  const downSizes = downIndexes.map((i) => sizes[i]);
695
754
  //
696
- const minDeltaUp = upIndexes.reduce((_, i) => _ + this.views[i].minimumSize - sizes[i], 0);
697
- const maxDeltaUp = upIndexes.reduce((_, i) => _ + this.views[i].maximumSize - sizes[i], 0);
755
+ const minDeltaUp = upIndexes.reduce((_, i) => _ + this.viewItems[i].minimumSize - sizes[i], 0);
756
+ const maxDeltaUp = upIndexes.reduce((_, i) => _ + this.viewItems[i].maximumSize - sizes[i], 0);
698
757
  //
699
758
  const maxDeltaDown = downIndexes.length === 0
700
759
  ? Number.POSITIVE_INFINITY
701
- : downIndexes.reduce((_, i) => _ + sizes[i] - this.views[i].minimumSize, 0);
760
+ : downIndexes.reduce((_, i) => _ + sizes[i] - this.viewItems[i].minimumSize, 0);
702
761
  const minDeltaDown = downIndexes.length === 0
703
762
  ? Number.NEGATIVE_INFINITY
704
- : downIndexes.reduce((_, i) => _ + sizes[i] - this.views[i].maximumSize, 0);
763
+ : downIndexes.reduce((_, i) => _ + sizes[i] - this.viewItems[i].maximumSize, 0);
705
764
  //
706
765
  const minDelta = Math.max(minDeltaUp, minDeltaDown);
707
766
  const maxDelta = Math.min(maxDeltaDown, maxDeltaUp);
708
767
  //
709
768
  let snapped = false;
710
769
  if (snapBefore) {
711
- const snapView = this.views[snapBefore.index];
770
+ const snapView = this.viewItems[snapBefore.index];
712
771
  const visible = delta >= snapBefore.limitDelta;
713
772
  snapped = visible !== snapView.visible;
714
773
  snapView.setVisible(visible, snapBefore.size);
715
774
  }
716
775
  if (!snapped && snapAfter) {
717
- const snapView = this.views[snapAfter.index];
776
+ const snapView = this.viewItems[snapAfter.index];
718
777
  const visible = delta < snapAfter.limitDelta;
719
778
  snapped = visible !== snapView.visible;
720
779
  snapView.setVisible(visible, snapAfter.size);
@@ -776,7 +835,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
776
835
  );
777
836
  });
778
837
  // Initialize content size and proportions for first layout
779
- this.contentSize = this.views.reduce((r, i) => r + i.size, 0);
838
+ this.contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
780
839
  this.saveProportions();
781
840
  }
782
841
  }
@@ -793,18 +852,18 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
793
852
  }
794
853
  }
795
854
  isViewVisible(index) {
796
- if (index < 0 || index >= this.views.length) {
855
+ if (index < 0 || index >= this.viewItems.length) {
797
856
  throw new Error('Index out of bounds');
798
857
  }
799
- const viewItem = this.views[index];
858
+ const viewItem = this.viewItems[index];
800
859
  return viewItem.visible;
801
860
  }
802
861
  setViewVisible(index, visible) {
803
- if (index < 0 || index >= this.views.length) {
862
+ if (index < 0 || index >= this.viewItems.length) {
804
863
  throw new Error('Index out of bounds');
805
864
  }
806
865
  toggleClass(this.container, 'visible', visible);
807
- const viewItem = this.views[index];
866
+ const viewItem = this.viewItems[index];
808
867
  toggleClass(this.container, 'visible', visible);
809
868
  viewItem.setVisible(visible, viewItem.size);
810
869
  this.distributeEmptySpace(index);
@@ -812,33 +871,33 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
812
871
  this.saveProportions();
813
872
  }
814
873
  getViewSize(index) {
815
- if (index < 0 || index >= this.views.length) {
874
+ if (index < 0 || index >= this.viewItems.length) {
816
875
  return -1;
817
876
  }
818
- return this.views[index].size;
877
+ return this.viewItems[index].size;
819
878
  }
820
879
  resizeView(index, size) {
821
- if (index < 0 || index >= this.views.length) {
880
+ if (index < 0 || index >= this.viewItems.length) {
822
881
  return;
823
882
  }
824
- const indexes = range(this.views.length).filter((i) => i !== index);
883
+ const indexes = range(this.viewItems.length).filter((i) => i !== index);
825
884
  const lowPriorityIndexes = [
826
- ...indexes.filter((i) => this.views[i].priority === exports.LayoutPriority.Low),
885
+ ...indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.Low),
827
886
  index,
828
887
  ];
829
- const highPriorityIndexes = indexes.filter((i) => this.views[i].priority === exports.LayoutPriority.High);
830
- const item = this.views[index];
888
+ const highPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.High);
889
+ const item = this.viewItems[index];
831
890
  size = Math.round(size);
832
891
  size = clamp(size, item.minimumSize, Math.min(item.maximumSize, this._size));
833
892
  item.size = size;
834
893
  this.relayout(lowPriorityIndexes, highPriorityIndexes);
835
894
  }
836
895
  getViews() {
837
- return this.views.map((x) => x.view);
896
+ return this.viewItems.map((x) => x.view);
838
897
  }
839
898
  onDidChange(item, size) {
840
- const index = this.views.indexOf(item);
841
- if (index < 0 || index >= this.views.length) {
899
+ const index = this.viewItems.indexOf(item);
900
+ if (index < 0 || index >= this.viewItems.length) {
842
901
  return;
843
902
  }
844
903
  size = typeof size === 'number' ? size : item.size;
@@ -846,7 +905,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
846
905
  item.size = size;
847
906
  this.relayout([index]);
848
907
  }
849
- addView(view, size = { type: 'distribute' }, index = this.views.length, skipLayout) {
908
+ addView(view, size = { type: 'distribute' }, index = this.viewItems.length, skipLayout) {
850
909
  const container = document.createElement('div');
851
910
  container.className = 'view';
852
911
  container.appendChild(view.element);
@@ -864,24 +923,25 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
864
923
  viewSize = view.minimumSize;
865
924
  }
866
925
  const disposable = view.onDidChange((newSize) => this.onDidChange(viewItem, newSize.size));
867
- const dispose = () => {
868
- disposable === null || disposable === void 0 ? void 0 : disposable.dispose();
869
- this.viewContainer.removeChild(container);
870
- };
871
- const viewItem = new ViewItem(container, view, viewSize, { dispose });
872
- if (index === this.views.length) {
926
+ const viewItem = new ViewItem(container, view, viewSize, {
927
+ dispose: () => {
928
+ disposable.dispose();
929
+ this.viewContainer.removeChild(container);
930
+ },
931
+ });
932
+ if (index === this.viewItems.length) {
873
933
  this.viewContainer.appendChild(container);
874
934
  }
875
935
  else {
876
936
  this.viewContainer.insertBefore(container, this.viewContainer.children.item(index));
877
937
  }
878
- this.views.splice(index, 0, viewItem);
879
- if (this.views.length > 1) {
938
+ this.viewItems.splice(index, 0, viewItem);
939
+ if (this.viewItems.length > 1) {
880
940
  //add sash
881
941
  const sash = document.createElement('div');
882
942
  sash.className = 'sash';
883
943
  const onStart = (event) => {
884
- for (const item of this.views) {
944
+ for (const item of this.viewItems) {
885
945
  item.enabled = false;
886
946
  }
887
947
  const iframes = [
@@ -896,27 +956,29 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
896
956
  : event.clientY;
897
957
  const sashIndex = firstIndex(this.sashes, (s) => s.container === sash);
898
958
  //
899
- const sizes = this.views.map((x) => x.size);
959
+ const sizes = this.viewItems.map((x) => x.size);
900
960
  //
901
961
  let snapBefore;
902
962
  let snapAfter;
903
963
  const upIndexes = range(sashIndex, -1);
904
- const downIndexes = range(sashIndex + 1, this.views.length);
905
- const minDeltaUp = upIndexes.reduce((r, i) => r + (this.views[i].minimumSize - sizes[i]), 0);
906
- const maxDeltaUp = upIndexes.reduce((r, i) => r + (this.views[i].viewMaximumSize - sizes[i]), 0);
964
+ const downIndexes = range(sashIndex + 1, this.viewItems.length);
965
+ const minDeltaUp = upIndexes.reduce((r, i) => r + (this.viewItems[i].minimumSize - sizes[i]), 0);
966
+ const maxDeltaUp = upIndexes.reduce((r, i) => r + (this.viewItems[i].viewMaximumSize - sizes[i]), 0);
907
967
  const maxDeltaDown = downIndexes.length === 0
908
968
  ? Number.POSITIVE_INFINITY
909
- : downIndexes.reduce((r, i) => r + (sizes[i] - this.views[i].minimumSize), 0);
969
+ : downIndexes.reduce((r, i) => r +
970
+ (sizes[i] - this.viewItems[i].minimumSize), 0);
910
971
  const minDeltaDown = downIndexes.length === 0
911
972
  ? Number.NEGATIVE_INFINITY
912
973
  : downIndexes.reduce((r, i) => r +
913
- (sizes[i] - this.views[i].viewMaximumSize), 0);
974
+ (sizes[i] -
975
+ this.viewItems[i].viewMaximumSize), 0);
914
976
  const minDelta = Math.max(minDeltaUp, minDeltaDown);
915
977
  const maxDelta = Math.min(maxDeltaDown, maxDeltaUp);
916
978
  const snapBeforeIndex = this.findFirstSnapIndex(upIndexes);
917
979
  const snapAfterIndex = this.findFirstSnapIndex(downIndexes);
918
980
  if (typeof snapBeforeIndex === 'number') {
919
- const snappedViewItem = this.views[snapBeforeIndex];
981
+ const snappedViewItem = this.viewItems[snapBeforeIndex];
920
982
  const halfSize = Math.floor(snappedViewItem.viewMinimumSize / 2);
921
983
  snapBefore = {
922
984
  index: snapBeforeIndex,
@@ -927,7 +989,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
927
989
  };
928
990
  }
929
991
  if (typeof snapAfterIndex === 'number') {
930
- const snappedViewItem = this.views[snapAfterIndex];
992
+ const snappedViewItem = this.viewItems[snapAfterIndex];
931
993
  const halfSize = Math.floor(snappedViewItem.viewMinimumSize / 2);
932
994
  snapAfter = {
933
995
  index: snapAfterIndex,
@@ -948,7 +1010,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
948
1010
  this.layoutViews();
949
1011
  };
950
1012
  const end = () => {
951
- for (const item of this.views) {
1013
+ for (const item of this.viewItems) {
952
1014
  item.enabled = true;
953
1015
  }
954
1016
  for (const iframe of iframes) {
@@ -988,7 +1050,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
988
1050
  distributeViewSizes() {
989
1051
  const flexibleViewItems = [];
990
1052
  let flexibleSize = 0;
991
- for (const item of this.views) {
1053
+ for (const item of this.viewItems) {
992
1054
  if (item.maximumSize - item.minimumSize > 0) {
993
1055
  flexibleViewItems.push(item);
994
1056
  flexibleSize += item.size;
@@ -998,17 +1060,17 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
998
1060
  for (const item of flexibleViewItems) {
999
1061
  item.size = clamp(size, item.minimumSize, item.maximumSize);
1000
1062
  }
1001
- const indexes = range(this.views.length);
1002
- const lowPriorityIndexes = indexes.filter((i) => this.views[i].priority === exports.LayoutPriority.Low);
1003
- const highPriorityIndexes = indexes.filter((i) => this.views[i].priority === exports.LayoutPriority.High);
1063
+ const indexes = range(this.viewItems.length);
1064
+ const lowPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.Low);
1065
+ const highPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.High);
1004
1066
  this.relayout(lowPriorityIndexes, highPriorityIndexes);
1005
1067
  }
1006
1068
  removeView(index, sizing, skipLayout = false) {
1007
1069
  // Remove view
1008
- const viewItem = this.views.splice(index, 1)[0];
1070
+ const viewItem = this.viewItems.splice(index, 1)[0];
1009
1071
  viewItem.dispose();
1010
1072
  // Remove sash
1011
- if (this.views.length >= 1) {
1073
+ if (this.viewItems.length >= 1) {
1012
1074
  const sashIndex = Math.max(index - 1, 0);
1013
1075
  const sashItem = this.sashes.splice(sashIndex, 1)[0];
1014
1076
  sashItem.disposable();
@@ -1023,10 +1085,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1023
1085
  return viewItem.view;
1024
1086
  }
1025
1087
  getViewCachedVisibleSize(index) {
1026
- if (index < 0 || index >= this.views.length) {
1088
+ if (index < 0 || index >= this.viewItems.length) {
1027
1089
  throw new Error('Index out of bounds');
1028
1090
  }
1029
- const viewItem = this.views[index];
1091
+ const viewItem = this.viewItems[index];
1030
1092
  return viewItem.cachedVisibleSize;
1031
1093
  }
1032
1094
  moveView(from, to) {
@@ -1042,14 +1104,14 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1042
1104
  this.size = size;
1043
1105
  this.orthogonalSize = orthogonalSize;
1044
1106
  if (!this.proportions) {
1045
- const indexes = range(this.views.length);
1046
- const lowPriorityIndexes = indexes.filter((i) => this.views[i].priority === exports.LayoutPriority.Low);
1047
- const highPriorityIndexes = indexes.filter((i) => this.views[i].priority === exports.LayoutPriority.High);
1048
- this.resize(this.views.length - 1, size - previousSize, undefined, lowPriorityIndexes, highPriorityIndexes);
1107
+ const indexes = range(this.viewItems.length);
1108
+ const lowPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.Low);
1109
+ const highPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.High);
1110
+ this.resize(this.viewItems.length - 1, size - previousSize, undefined, lowPriorityIndexes, highPriorityIndexes);
1049
1111
  }
1050
1112
  else {
1051
- for (let i = 0; i < this.views.length; i++) {
1052
- const item = this.views[i];
1113
+ for (let i = 0; i < this.viewItems.length; i++) {
1114
+ const item = this.viewItems[i];
1053
1115
  item.size = clamp(Math.round(this.proportions[i] * size), item.minimumSize, item.maximumSize);
1054
1116
  }
1055
1117
  }
@@ -1057,18 +1119,18 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1057
1119
  this.layoutViews();
1058
1120
  }
1059
1121
  relayout(lowPriorityIndexes, highPriorityIndexes) {
1060
- const contentSize = this.views.reduce((r, i) => r + i.size, 0);
1061
- this.resize(this.views.length - 1, this._size - contentSize, undefined, lowPriorityIndexes, highPriorityIndexes);
1122
+ const contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
1123
+ this.resize(this.viewItems.length - 1, this._size - contentSize, undefined, lowPriorityIndexes, highPriorityIndexes);
1062
1124
  this.distributeEmptySpace();
1063
1125
  this.layoutViews();
1064
1126
  this.saveProportions();
1065
1127
  }
1066
1128
  distributeEmptySpace(lowPriorityIndex) {
1067
- const contentSize = this.views.reduce((r, i) => r + i.size, 0);
1129
+ const contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
1068
1130
  let emptyDelta = this.size - contentSize;
1069
- const indexes = range(this.views.length - 1, -1);
1070
- const lowPriorityIndexes = indexes.filter((i) => this.views[i].priority === exports.LayoutPriority.Low);
1071
- const highPriorityIndexes = indexes.filter((i) => this.views[i].priority === exports.LayoutPriority.High);
1131
+ const indexes = range(this.viewItems.length - 1, -1);
1132
+ const lowPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.Low);
1133
+ const highPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.High);
1072
1134
  for (const index of highPriorityIndexes) {
1073
1135
  pushToStart(indexes, index);
1074
1136
  }
@@ -1079,7 +1141,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1079
1141
  pushToEnd(indexes, lowPriorityIndex);
1080
1142
  }
1081
1143
  for (let i = 0; emptyDelta !== 0 && i < indexes.length; i++) {
1082
- const item = this.views[indexes[i]];
1144
+ const item = this.viewItems[indexes[i]];
1083
1145
  const size = clamp(item.size + emptyDelta, item.minimumSize, item.maximumSize);
1084
1146
  const viewDelta = size - item.size;
1085
1147
  emptyDelta -= viewDelta;
@@ -1088,16 +1150,16 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1088
1150
  }
1089
1151
  saveProportions() {
1090
1152
  if (this.proportionalLayout && this.contentSize > 0) {
1091
- this._proportions = this.views.map((i) => i.size / this.contentSize);
1153
+ this._proportions = this.viewItems.map((i) => i.size / this.contentSize);
1092
1154
  }
1093
1155
  }
1094
1156
  layoutViews() {
1095
- this.contentSize = this.views.reduce((r, i) => r + i.size, 0);
1157
+ this.contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
1096
1158
  let sum = 0;
1097
1159
  const x = [];
1098
1160
  this.updateSashEnablement();
1099
- for (let i = 0; i < this.views.length - 1; i++) {
1100
- sum += this.views[i].size;
1161
+ for (let i = 0; i < this.viewItems.length - 1; i++) {
1162
+ sum += this.viewItems[i].size;
1101
1163
  x.push(sum);
1102
1164
  const offset = Math.min(Math.max(0, sum - 2), this.size - 4);
1103
1165
  if (this._orientation === exports.Orientation.HORIZONTAL) {
@@ -1109,7 +1171,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1109
1171
  this.sashes[i].container.style.top = `${offset}px`;
1110
1172
  }
1111
1173
  }
1112
- this.views.forEach((view, i) => {
1174
+ this.viewItems.forEach((view, i) => {
1113
1175
  if (this._orientation === exports.Orientation.HORIZONTAL) {
1114
1176
  view.container.style.width = `${view.size}px`;
1115
1177
  view.container.style.left = i == 0 ? '0px' : `${x[i - 1]}px`;
@@ -1128,7 +1190,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1128
1190
  findFirstSnapIndex(indexes) {
1129
1191
  // visible views first
1130
1192
  for (const index of indexes) {
1131
- const viewItem = this.views[index];
1193
+ const viewItem = this.viewItems[index];
1132
1194
  if (!viewItem.visible) {
1133
1195
  continue;
1134
1196
  }
@@ -1138,7 +1200,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1138
1200
  }
1139
1201
  // then, hidden views
1140
1202
  for (const index of indexes) {
1141
- const viewItem = this.views[index];
1203
+ const viewItem = this.viewItems[index];
1142
1204
  if (viewItem.visible &&
1143
1205
  viewItem.maximumSize - viewItem.minimumSize > 0) {
1144
1206
  return undefined;
@@ -1151,10 +1213,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1151
1213
  }
1152
1214
  updateSashEnablement() {
1153
1215
  let previous = false;
1154
- const collapsesDown = this.views.map((i) => (previous = i.size - i.minimumSize > 0 || previous));
1216
+ const collapsesDown = this.viewItems.map((i) => (previous = i.size - i.minimumSize > 0 || previous));
1155
1217
  previous = false;
1156
- const expandsDown = this.views.map((i) => (previous = i.maximumSize - i.size > 0 || previous));
1157
- const reverseViews = [...this.views].reverse();
1218
+ const expandsDown = this.viewItems.map((i) => (previous = i.maximumSize - i.size > 0 || previous));
1219
+ const reverseViews = [...this.viewItems].reverse();
1158
1220
  previous = false;
1159
1221
  const collapsesUp = reverseViews
1160
1222
  .map((i) => (previous = i.size - i.minimumSize > 0 || previous))
@@ -1166,19 +1228,19 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1166
1228
  let position = 0;
1167
1229
  for (let index = 0; index < this.sashes.length; index++) {
1168
1230
  const sash = this.sashes[index];
1169
- const viewItem = this.views[index];
1231
+ const viewItem = this.viewItems[index];
1170
1232
  position += viewItem.size;
1171
1233
  const min = !(collapsesDown[index] && expandsUp[index + 1]);
1172
1234
  const max = !(expandsDown[index] && collapsesUp[index + 1]);
1173
1235
  if (min && max) {
1174
1236
  const upIndexes = range(index, -1);
1175
- const downIndexes = range(index + 1, this.views.length);
1237
+ const downIndexes = range(index + 1, this.viewItems.length);
1176
1238
  const snapBeforeIndex = this.findFirstSnapIndex(upIndexes);
1177
1239
  const snapAfterIndex = this.findFirstSnapIndex(downIndexes);
1178
1240
  const snappedBefore = typeof snapBeforeIndex === 'number' &&
1179
- !this.views[snapBeforeIndex].visible;
1241
+ !this.viewItems[snapBeforeIndex].visible;
1180
1242
  const snappedAfter = typeof snapAfterIndex === 'number' &&
1181
- !this.views[snapAfterIndex].visible;
1243
+ !this.viewItems[snapAfterIndex].visible;
1182
1244
  if (snappedBefore &&
1183
1245
  collapsesUp[index] &&
1184
1246
  (position > 0 || this.startSnappingEnabled)) {
@@ -1238,6 +1300,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1238
1300
  break;
1239
1301
  }
1240
1302
  }
1303
+ for (const viewItem of this.viewItems) {
1304
+ viewItem.dispose();
1305
+ }
1241
1306
  this.element.remove();
1242
1307
  }
1243
1308
  }
@@ -1672,7 +1737,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1672
1737
  throw new Error('Invalid index');
1673
1738
  }
1674
1739
  this.splitview.removeView(index, sizing);
1675
- this._removeChild(index);
1740
+ return this._removeChild(index);
1676
1741
  }
1677
1742
  _addChild(node, index) {
1678
1743
  this.children.splice(index, 0, node);
@@ -1694,10 +1759,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1694
1759
  });
1695
1760
  }
1696
1761
  dispose() {
1697
- super.dispose();
1698
1762
  this._childrenDisposable.dispose();
1699
- this.children.forEach((child) => child.dispose());
1700
1763
  this.splitview.dispose();
1764
+ this.children.forEach((child) => child.dispose());
1765
+ super.dispose();
1701
1766
  }
1702
1767
  }
1703
1768
 
@@ -1927,7 +1992,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1927
1992
  if (oldRoot.children.length === 1) {
1928
1993
  // can remove one level of redundant branching if there is only a single child
1929
1994
  const childReference = oldRoot.children[0];
1930
- oldRoot.removeChild(0); // remove to prevent disposal when disposing of unwanted root
1995
+ const child = oldRoot.removeChild(0); // remove to prevent disposal when disposing of unwanted root
1996
+ child.dispose();
1931
1997
  oldRoot.dispose();
1932
1998
  this._root.addChild(
1933
1999
  /**
@@ -2034,7 +2100,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2034
2100
  if (typeof newSiblingCachedVisibleSize === 'number') {
2035
2101
  newSiblingSize = exports.Sizing.Invisible(newSiblingCachedVisibleSize);
2036
2102
  }
2037
- grandParent.removeChild(parentIndex);
2103
+ const child = grandParent.removeChild(parentIndex);
2104
+ child.dispose();
2038
2105
  const newParent = new BranchNode(parent.orientation, this.proportionalLayout, this.styles, parent.size, parent.orthogonalSize);
2039
2106
  grandParent.addChild(newParent, parent.size, parentIndex);
2040
2107
  const newSibling = new LeafNode(parent.view, grandParent.orientation, parent.size);
@@ -2060,30 +2127,36 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2060
2127
  if (!(node instanceof LeafNode)) {
2061
2128
  throw new Error('Invalid location');
2062
2129
  }
2063
- parent.removeChild(index, sizing);
2130
+ const view = node.view;
2131
+ node.dispose(); // dispose of node
2132
+ const child = parent.removeChild(index, sizing);
2133
+ child.dispose();
2064
2134
  if (parent.children.length === 0) {
2065
- return node.view;
2135
+ return view;
2066
2136
  }
2067
2137
  if (parent.children.length > 1) {
2068
- return node.view;
2138
+ return view;
2069
2139
  }
2070
2140
  const sibling = parent.children[0];
2071
2141
  if (pathToParent.length === 0) {
2072
2142
  // parent is root
2073
2143
  if (sibling instanceof LeafNode) {
2074
- return node.view;
2144
+ return view;
2075
2145
  }
2076
2146
  // we must promote sibling to be the new root
2077
- parent.removeChild(0, sizing);
2147
+ const child = parent.removeChild(0, sizing);
2148
+ child.dispose();
2078
2149
  this.root = sibling;
2079
- return node.view;
2150
+ return view;
2080
2151
  }
2081
2152
  const [grandParent, ..._] = [...pathToParent].reverse();
2082
2153
  const [parentIndex, ...__] = [...rest].reverse();
2083
2154
  const isSiblingVisible = parent.isChildVisible(0);
2084
- parent.removeChild(0, sizing);
2155
+ const childNode = parent.removeChild(0, sizing);
2156
+ childNode.dispose();
2085
2157
  const sizes = grandParent.children.map((_size, i) => grandParent.getChildSize(i));
2086
- grandParent.removeChild(parentIndex, sizing);
2158
+ const parentNode = grandParent.removeChild(parentIndex, sizing);
2159
+ parentNode.dispose();
2087
2160
  if (sibling instanceof BranchNode) {
2088
2161
  sizes.splice(parentIndex, 1, ...sibling.children.map((c) => c.size));
2089
2162
  for (let i = 0; i < sibling.children.length; i++) {
@@ -2101,7 +2174,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2101
2174
  for (let i = 0; i < sizes.length; i++) {
2102
2175
  grandParent.resizeChild(i, sizes[i]);
2103
2176
  }
2104
- return node.view;
2177
+ return view;
2105
2178
  }
2106
2179
  layout(width, height) {
2107
2180
  const [size, orthogonalSize] = this.root.orientation === exports.Orientation.HORIZONTAL
@@ -2596,6 +2669,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2596
2669
  }
2597
2670
  dispose() {
2598
2671
  this.removeDropTarget();
2672
+ super.dispose();
2599
2673
  }
2600
2674
  toggleClasses(quadrant, width, height) {
2601
2675
  var _a, _b, _c, _d;
@@ -2773,8 +2847,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2773
2847
  if (this.panel.view) {
2774
2848
  const _onDidFocus = this.panel.view.content.onDidFocus;
2775
2849
  const _onDidBlur = this.panel.view.content.onDidBlur;
2776
- const { onDidFocus, onDidBlur } = trackFocus(this._element);
2777
- disposable.addDisposables(onDidFocus(() => this._onDidFocus.fire()), onDidBlur(() => this._onDidBlur.fire()));
2850
+ const focusTracker = trackFocus(this._element);
2851
+ disposable.addDisposables(focusTracker, focusTracker.onDidFocus(() => this._onDidFocus.fire()), focusTracker.onDidBlur(() => this._onDidBlur.fire()));
2778
2852
  if (_onDidFocus) {
2779
2853
  disposable.addDisposables(_onDidFocus(() => this._onDidFocus.fire()));
2780
2854
  }
@@ -2817,6 +2891,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2817
2891
  this._onDragStart = new Emitter();
2818
2892
  this.onDragStart = this._onDragStart.event;
2819
2893
  this.iframes = [];
2894
+ this.addDisposables(this._onDragStart);
2820
2895
  this.configure();
2821
2896
  }
2822
2897
  configure() {
@@ -2867,13 +2942,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2867
2942
  this.onChanged = this._onChanged.event;
2868
2943
  this._onDropped = new Emitter();
2869
2944
  this.onDrop = this._onDropped.event;
2870
- this.addDisposables(this._onChanged, this._onDropped);
2871
2945
  this._element = document.createElement('div');
2872
2946
  this._element.className = 'tab';
2873
2947
  this._element.tabIndex = 0;
2874
2948
  this._element.draggable = true;
2875
2949
  toggleClass(this.element, 'inactive-tab', true);
2876
- this.addDisposables(new (class Handler extends DragHandler {
2950
+ this.addDisposables(this._onChanged, this._onDropped, new (class Handler extends DragHandler {
2877
2951
  constructor() {
2878
2952
  super(...arguments);
2879
2953
  this.panelTransfer = LocalSelectionTransfer.getInstance();
@@ -2886,9 +2960,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2886
2960
  },
2887
2961
  };
2888
2962
  }
2889
- dispose() {
2890
- //
2891
- }
2892
2963
  })(this._element));
2893
2964
  this.addDisposables(addDisposableListener(this._element, 'mousedown', (event) => {
2894
2965
  if (event.defaultPrevented) {
@@ -2923,7 +2994,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2923
2994
  });
2924
2995
  this.addDisposables(this.droptarget.onDrop((event) => {
2925
2996
  this._onDropped.fire(event);
2926
- }));
2997
+ }), this.droptarget);
2927
2998
  }
2928
2999
  setActive(isActive) {
2929
3000
  toggleClass(this.element, 'active-tab', isActive);
@@ -2938,7 +3009,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2938
3009
  }
2939
3010
  dispose() {
2940
3011
  super.dispose();
2941
- this.droptarget.dispose();
2942
3012
  }
2943
3013
  }
2944
3014
 
@@ -2984,9 +3054,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2984
3054
  },
2985
3055
  };
2986
3056
  }
2987
- dispose() {
2988
- //
2989
- }
2990
3057
  }
2991
3058
 
2992
3059
  class VoidContainer extends CompositeDisposable {
@@ -3142,6 +3209,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3142
3209
  const tabToRemove = this.tabs.splice(index, 1)[0];
3143
3210
  const { value, disposable } = tabToRemove;
3144
3211
  disposable.dispose();
3212
+ value.dispose();
3145
3213
  value.element.remove();
3146
3214
  }
3147
3215
  setActivePanel(panel) {
@@ -3185,9 +3253,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3185
3253
  }
3186
3254
  dispose() {
3187
3255
  super.dispose();
3188
- this.tabs.forEach((tab) => {
3189
- tab.disposable.dispose();
3190
- });
3256
+ for (const { value, disposable } of this.tabs) {
3257
+ disposable.dispose();
3258
+ value.dispose();
3259
+ }
3191
3260
  this.tabs = [];
3192
3261
  }
3193
3262
  }
@@ -3285,7 +3354,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3285
3354
  container.append(this.tabsContainer.element, this.contentContainer.element);
3286
3355
  this.header.hidden = !!options.hideHeader;
3287
3356
  this.locked = !!options.locked;
3288
- 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) => {
3289
3358
  this.handleDropEvent(event.event, 'center', event.index);
3290
3359
  }), this.contentContainer.onDidFocus(() => {
3291
3360
  this.accessor.doSetGroupActive(this.groupPanel, true);
@@ -3293,7 +3362,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3293
3362
  // noop
3294
3363
  }), this.dropTarget.onDrop((event) => {
3295
3364
  this.handleDropEvent(event.nativeEvent, event.position);
3296
- }));
3365
+ }), this._onMove, this._onDidChange, this._onDidDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange);
3297
3366
  }
3298
3367
  initialize() {
3299
3368
  var _a, _b;
@@ -3727,8 +3796,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3727
3796
  this.layout(0, 0, true); // set some elements height/widths
3728
3797
  this.addDisposables(this.gridview.onDidChange(() => {
3729
3798
  this._bufferOnDidLayoutChange.fire();
3730
- }));
3731
- this.addDisposables(exports.DockviewEvent.any(this.onDidAddGroup, this.onDidRemoveGroup, this.onDidActiveGroupChange)(() => {
3799
+ }), exports.DockviewEvent.any(this.onDidAddGroup, this.onDidRemoveGroup, this.onDidActiveGroupChange)(() => {
3732
3800
  this._bufferOnDidLayoutChange.fire();
3733
3801
  }), this._bufferOnDidLayoutChange.onEvent(() => {
3734
3802
  this._onDidLayoutChange.fire();
@@ -3831,7 +3899,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3831
3899
  this.gridview.layout(width, height);
3832
3900
  }
3833
3901
  dispose() {
3834
- super.dispose();
3835
3902
  this._onDidActiveGroupChange.dispose();
3836
3903
  this._onDidAddGroup.dispose();
3837
3904
  this._onDidRemoveGroup.dispose();
@@ -3840,6 +3907,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3840
3907
  group.dispose();
3841
3908
  }
3842
3909
  this.gridview.dispose();
3910
+ super.dispose();
3843
3911
  }
3844
3912
  }
3845
3913
 
@@ -3903,7 +3971,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3903
3971
  //
3904
3972
  this._onUpdateParameters = new Emitter();
3905
3973
  this.onUpdateParameters = this._onUpdateParameters.event;
3906
- 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) => {
3907
3975
  this._isFocused = event.isFocused;
3908
3976
  }), this.onDidActiveChange((event) => {
3909
3977
  this._isActive = event.isActive;
@@ -3912,14 +3980,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3912
3980
  }), this.onDidDimensionsChange((event) => {
3913
3981
  this._width = event.width;
3914
3982
  this._height = event.height;
3915
- }));
3983
+ }), this.panelUpdatesDisposable, this._onDidDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onFocusEvent, this._onActiveChange, this._onVisibilityChange, this._onUpdateParameters);
3916
3984
  }
3917
3985
  initialize(panel) {
3918
3986
  this.panelUpdatesDisposable.value = this._onUpdateParameters.event((parameters) => {
3919
3987
  panel.update({
3920
- params: {
3921
- params: parameters,
3922
- },
3988
+ params: parameters,
3923
3989
  });
3924
3990
  });
3925
3991
  }
@@ -4014,12 +4080,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4014
4080
  this._element.style.height = '100%';
4015
4081
  this._element.style.width = '100%';
4016
4082
  this._element.style.overflow = 'hidden';
4017
- const { onDidFocus, onDidBlur } = trackFocus(this._element);
4018
- this.addDisposables(this.api, onDidFocus(() => {
4083
+ const focusTracker = trackFocus(this._element);
4084
+ this.addDisposables(this.api, focusTracker.onDidFocus(() => {
4019
4085
  this.api._onDidChangeFocus.fire({ isFocused: true });
4020
- }), onDidBlur(() => {
4086
+ }), focusTracker.onDidBlur(() => {
4021
4087
  this.api._onDidChangeFocus.fire({ isFocused: false });
4022
- }));
4088
+ }), focusTracker);
4023
4089
  }
4024
4090
  focus() {
4025
4091
  this.api._onFocusEvent.fire();
@@ -4040,7 +4106,18 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4040
4106
  }
4041
4107
  update(event) {
4042
4108
  var _a, _b;
4109
+ // merge the new parameters with the existing parameters
4043
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
4044
4121
  (_b = this.part) === null || _b === void 0 ? void 0 : _b.update({ params: this._params.params });
4045
4122
  }
4046
4123
  toJSON() {
@@ -4054,9 +4131,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4054
4131
  }
4055
4132
  dispose() {
4056
4133
  var _a;
4057
- super.dispose();
4058
4134
  this.api.dispose();
4059
4135
  (_a = this.part) === null || _a === void 0 ? void 0 : _a.dispose();
4136
+ super.dispose();
4060
4137
  }
4061
4138
  }
4062
4139
 
@@ -4435,7 +4512,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4435
4512
  this._maximumHeight = options.maximumHeight;
4436
4513
  }
4437
4514
  this.api.initialize(this); // TODO: required to by-pass 'super before this' requirement
4438
- this.addDisposables(this._onDidChange, this.api.onVisibilityChange((event) => {
4515
+ this.addDisposables(this.api.onVisibilityChange((event) => {
4439
4516
  const { isVisible } = event;
4440
4517
  const { accessor } = this._params;
4441
4518
  accessor.setVisible(this, isVisible);
@@ -4464,7 +4541,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4464
4541
  height: event.height,
4465
4542
  width: event.width,
4466
4543
  });
4467
- }));
4544
+ }), this._onDidChange);
4468
4545
  }
4469
4546
  setVisible(isVisible) {
4470
4547
  this.api._onDidVisibilityChange.fire({ isVisible });
@@ -4621,7 +4698,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4621
4698
  this.addDisposables(this.disposable, this._onDidTitleChange, this._onDidGroupChange, this._onDidActiveGroupChange);
4622
4699
  }
4623
4700
  setTitle(title) {
4624
- this.panel.update({ params: { title } });
4701
+ this.panel.setTitle(title);
4625
4702
  }
4626
4703
  close() {
4627
4704
  this.group.model.closePanel(this.panel);
@@ -4686,12 +4763,18 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4686
4763
  }
4687
4764
  }
4688
4765
  update(event) {
4689
- const params = event.params;
4690
- this._params = Object.assign(Object.assign({}, (this._params || {})), event.params.params);
4691
- if (params.title !== this.title) {
4692
- this._title = params.title;
4693
- 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
+ }
4694
4776
  }
4777
+ // update the view with the updated props
4695
4778
  this.view.update({
4696
4779
  params: {
4697
4780
  params: this._params,
@@ -5067,7 +5150,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5067
5150
  size: { type: 'pixels', value: 20 },
5068
5151
  },
5069
5152
  });
5070
- this.addDisposables(dropTarget, dropTarget.onDrop((event) => {
5153
+ this.addDisposables(dropTarget.onDrop((event) => {
5071
5154
  const data = getPanelData();
5072
5155
  if (data) {
5073
5156
  this.moveGroupOrPanel(this.orthogonalize(event.position), data.groupId, data.panelId || undefined, 'center');
@@ -5075,7 +5158,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5075
5158
  else {
5076
5159
  this._onDidDrop.fire(Object.assign(Object.assign({}, event), { api: this._api, group: null, getData: getPanelData }));
5077
5160
  }
5078
- }));
5161
+ }), dropTarget);
5079
5162
  this._api = new DockviewApi(this);
5080
5163
  this.updateWatermark();
5081
5164
  }
@@ -5399,31 +5482,33 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5399
5482
  }
5400
5483
  super.doRemoveGroup(group, { skipActive });
5401
5484
  }
5402
- moveGroupOrPanel(referenceGroup, groupId, itemId, target, index) {
5485
+ moveGroupOrPanel(destinationGroup, sourceGroupId, sourceItemId, destinationTarget, destinationIndex) {
5403
5486
  var _a;
5404
- const sourceGroup = groupId
5405
- ? (_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
5406
5489
  : undefined;
5407
- if (itemId === undefined) {
5490
+ if (sourceItemId === undefined) {
5408
5491
  if (sourceGroup) {
5409
- this.moveGroup(sourceGroup, referenceGroup, target);
5492
+ this.moveGroup(sourceGroup, destinationGroup, destinationTarget);
5410
5493
  }
5411
5494
  return;
5412
5495
  }
5413
- if (!target || target === 'center') {
5414
- const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(itemId)) ||
5415
- 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);
5416
5499
  if (!groupItem) {
5417
- throw new Error(`No panel with id ${itemId}`);
5500
+ throw new Error(`No panel with id ${sourceItemId}`);
5418
5501
  }
5419
5502
  if ((sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.size) === 0) {
5420
5503
  this.doRemoveGroup(sourceGroup);
5421
5504
  }
5422
- referenceGroup.model.openPanel(groupItem, { index });
5505
+ destinationGroup.model.openPanel(groupItem, {
5506
+ index: destinationIndex,
5507
+ });
5423
5508
  }
5424
5509
  else {
5425
- const referenceLocation = getGridLocation(referenceGroup.element);
5426
- const targetLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
5510
+ const referenceLocation = getGridLocation(destinationGroup.element);
5511
+ const targetLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
5427
5512
  if (sourceGroup && sourceGroup.size < 2) {
5428
5513
  const [targetParentLocation, to] = tail(targetLocation);
5429
5514
  const sourceLocation = getGridLocation(sourceGroup.element);
@@ -5441,18 +5526,18 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5441
5526
  skipDispose: true,
5442
5527
  });
5443
5528
  // after deleting the group we need to re-evaulate the ref location
5444
- const updatedReferenceLocation = getGridLocation(referenceGroup.element);
5445
- const location = getRelativeLocation(this.gridview.orientation, updatedReferenceLocation, target);
5529
+ const updatedReferenceLocation = getGridLocation(destinationGroup.element);
5530
+ const location = getRelativeLocation(this.gridview.orientation, updatedReferenceLocation, destinationTarget);
5446
5531
  this.doAddGroup(targetGroup, location);
5447
5532
  }
5448
5533
  }
5449
5534
  else {
5450
- const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(itemId)) ||
5451
- 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);
5452
5537
  if (!groupItem) {
5453
- throw new Error(`No panel with id ${itemId}`);
5538
+ throw new Error(`No panel with id ${sourceItemId}`);
5454
5539
  }
5455
- const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
5540
+ const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
5456
5541
  const group = this.createGroupAtLocation(dropLocation);
5457
5542
  group.model.openPanel(groupItem);
5458
5543
  }
@@ -5546,11 +5631,11 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5546
5631
  return (_a = Array.from(this._groups.values()).find((group) => group.value.model.containsPanel(panel))) === null || _a === void 0 ? void 0 : _a.value;
5547
5632
  }
5548
5633
  dispose() {
5549
- super.dispose();
5550
5634
  this._onDidActivePanelChange.dispose();
5551
5635
  this._onDidAddPanel.dispose();
5552
5636
  this._onDidRemovePanel.dispose();
5553
5637
  this._onDidLayoutFromJSON.dispose();
5638
+ super.dispose();
5554
5639
  }
5555
5640
  }
5556
5641
 
@@ -5808,7 +5893,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5808
5893
  }
5809
5894
  set splitview(value) {
5810
5895
  this._splitview = value;
5811
- this._disposable.value = new CompositeDisposable(this._splitview.onDidSashEnd(() => {
5896
+ this._splitviewChangeDisposable.value = new CompositeDisposable(this._splitview.onDidSashEnd(() => {
5812
5897
  this._onDidLayoutChange.fire(undefined);
5813
5898
  }), this._splitview.onDidAddView((e) => this._onDidAddView.fire(e)), this._splitview.onDidRemoveView((e) => this._onDidRemoveView.fire(e)));
5814
5899
  }
@@ -5830,7 +5915,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5830
5915
  }
5831
5916
  constructor(options) {
5832
5917
  super(options.parentElement);
5833
- this._disposable = new MutableDisposable();
5918
+ this._splitviewChangeDisposable = new MutableDisposable();
5834
5919
  this._panels = new Map();
5835
5920
  this._onDidLayoutfromJSON = new Emitter();
5836
5921
  this.onDidLayoutFromJSON = this._onDidLayoutfromJSON.event;
@@ -5848,7 +5933,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5848
5933
  options.frameworkComponents = {};
5849
5934
  }
5850
5935
  this.splitview = new Splitview(this.element, options);
5851
- this.addDisposables(this._disposable, this._onDidAddView, this._onDidLayoutfromJSON, this._onDidRemoveView, this._onDidLayoutChange);
5936
+ this.addDisposables(this._onDidAddView, this._onDidLayoutfromJSON, this._onDidRemoveView, this._onDidLayoutChange);
5852
5937
  }
5853
5938
  updateOptions(options) {
5854
5939
  const hasOrientationChanged = typeof options.orientation === 'string' &&
@@ -5886,15 +5971,15 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5886
5971
  }
5887
5972
  }
5888
5973
  removePanel(panel, sizing) {
5889
- const disposable = this._panels.get(panel.id);
5890
- if (!disposable) {
5974
+ const item = this._panels.get(panel.id);
5975
+ if (!item) {
5891
5976
  throw new Error(`unknown splitview panel ${panel.id}`);
5892
5977
  }
5893
- disposable.disposable.dispose();
5894
- disposable.value.dispose();
5978
+ item.dispose();
5895
5979
  this._panels.delete(panel.id);
5896
5980
  const index = this.panels.findIndex((_) => _ === panel);
5897
- this.splitview.removeView(index, sizing);
5981
+ const removedView = this.splitview.removeView(index, sizing);
5982
+ removedView.dispose();
5898
5983
  const panels = this.panels;
5899
5984
  if (panels.length > 0) {
5900
5985
  this.setActive(panels[panels.length - 1]);
@@ -5941,7 +6026,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5941
6026
  }
5942
6027
  this.setActive(view, true);
5943
6028
  });
5944
- this._panels.set(view.id, { disposable, value: view });
6029
+ this._panels.set(view.id, disposable);
5945
6030
  }
5946
6031
  toJSON() {
5947
6032
  var _a;
@@ -6014,20 +6099,26 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6014
6099
  this._onDidLayoutfromJSON.fire();
6015
6100
  }
6016
6101
  clear() {
6017
- for (const [_, value] of this._panels.entries()) {
6018
- value.disposable.dispose();
6019
- value.value.dispose();
6102
+ for (const disposable of this._panels.values()) {
6103
+ disposable.dispose();
6020
6104
  }
6021
6105
  this._panels.clear();
6022
- this.splitview.dispose();
6106
+ while (this.splitview.length > 0) {
6107
+ const view = this.splitview.removeView(0, exports.Sizing.Distribute, true);
6108
+ view.dispose();
6109
+ }
6023
6110
  }
6024
6111
  dispose() {
6025
- for (const [_, value] of this._panels.entries()) {
6026
- value.disposable.dispose();
6027
- value.value.dispose();
6112
+ for (const disposable of this._panels.values()) {
6113
+ disposable.dispose();
6028
6114
  }
6029
6115
  this._panels.clear();
6116
+ const views = this.splitview.getViews();
6117
+ this._splitviewChangeDisposable.dispose();
6030
6118
  this.splitview.dispose();
6119
+ for (const view of views) {
6120
+ view.dispose();
6121
+ }
6031
6122
  super.dispose();
6032
6123
  }
6033
6124
  }