dockview 1.7.2 → 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.2
3
+ * @version 1.7.4
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -111,9 +111,49 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
111
111
  };
112
112
  };
113
113
  })(exports.DockviewEvent || (exports.DockviewEvent = {}));
114
- // dumb event emitter with better typings than nodes event emitter
115
- // https://github.com/microsoft/vscode/blob/master/src/vs/base/common/event.ts
114
+ class LeakageMonitor {
115
+ constructor() {
116
+ this.events = new Map();
117
+ }
118
+ get size() {
119
+ return this.events.size;
120
+ }
121
+ add(event, stacktrace) {
122
+ this.events.set(event, stacktrace);
123
+ }
124
+ delete(event) {
125
+ this.events.delete(event);
126
+ }
127
+ clear() {
128
+ this.events.clear();
129
+ }
130
+ }
131
+ class Stacktrace {
132
+ static create() {
133
+ var _a;
134
+ return new Stacktrace((_a = new Error().stack) !== null && _a !== void 0 ? _a : '');
135
+ }
136
+ constructor(value) {
137
+ this.value = value;
138
+ }
139
+ print() {
140
+ console.warn(this.value);
141
+ }
142
+ }
143
+ class Listener {
144
+ constructor(callback, stacktrace) {
145
+ this.callback = callback;
146
+ this.stacktrace = stacktrace;
147
+ }
148
+ }
149
+ // relatively simple event emitter taken from https://github.com/microsoft/vscode/blob/master/src/vs/base/common/event.ts
116
150
  class Emitter {
151
+ static setLeakageMonitorEnabled(isEnabled) {
152
+ if (isEnabled !== Emitter.ENABLE_TRACKING) {
153
+ Emitter.MEMORY_LEAK_WATCHER.clear();
154
+ }
155
+ Emitter.ENABLE_TRACKING = isEnabled;
156
+ }
117
157
  constructor(options) {
118
158
  this.options = options;
119
159
  this._listeners = [];
@@ -121,11 +161,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
121
161
  }
122
162
  get event() {
123
163
  if (!this._event) {
124
- this._event = (listener) => {
164
+ this._event = (callback) => {
125
165
  var _a;
126
166
  if (((_a = this.options) === null || _a === void 0 ? void 0 : _a.replay) && this._last !== undefined) {
127
- listener(this._last);
167
+ callback(this._last);
128
168
  }
169
+ const listener = new Listener(callback, Emitter.ENABLE_TRACKING ? Stacktrace.create() : undefined);
129
170
  this._listeners.push(listener);
130
171
  return {
131
172
  dispose: () => {
@@ -133,23 +174,45 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
133
174
  if (index > -1) {
134
175
  this._listeners.splice(index, 1);
135
176
  }
177
+ else if (Emitter.ENABLE_TRACKING) ;
136
178
  },
137
179
  };
138
180
  };
181
+ if (Emitter.ENABLE_TRACKING) {
182
+ Emitter.MEMORY_LEAK_WATCHER.add(this._event, Stacktrace.create());
183
+ }
139
184
  }
140
185
  return this._event;
141
186
  }
142
187
  fire(e) {
143
188
  this._last = e;
144
189
  for (const listener of this._listeners) {
145
- listener(e);
190
+ listener.callback(e);
146
191
  }
147
192
  }
148
193
  dispose() {
149
- this._listeners = [];
150
- this._disposed = true;
194
+ if (!this._disposed) {
195
+ this._disposed = true;
196
+ if (this._listeners.length > 0) {
197
+ if (Emitter.ENABLE_TRACKING) {
198
+ queueMicrotask(() => {
199
+ var _a;
200
+ // don't check until stack of execution is completed to allow for out-of-order disposals within the same execution block
201
+ for (const listener of this._listeners) {
202
+ console.warn((_a = listener.stacktrace) === null || _a === void 0 ? void 0 : _a.print());
203
+ }
204
+ });
205
+ }
206
+ this._listeners = [];
207
+ }
208
+ if (Emitter.ENABLE_TRACKING && this._event) {
209
+ Emitter.MEMORY_LEAK_WATCHER.delete(this._event);
210
+ }
211
+ }
151
212
  }
152
213
  }
214
+ Emitter.ENABLE_TRACKING = false;
215
+ Emitter.MEMORY_LEAK_WATCHER = new LeakageMonitor();
153
216
  function addDisposableWindowListener(element, type, listener, options) {
154
217
  element.addEventListener(type, listener, options);
155
218
  return {
@@ -202,13 +265,13 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
202
265
  }
203
266
  constructor(...args) {
204
267
  this._isDisposed = false;
205
- this.disposables = args;
268
+ this._disposables = args;
206
269
  }
207
270
  addDisposables(...args) {
208
- args.forEach((arg) => this.disposables.push(arg));
271
+ args.forEach((arg) => this._disposables.push(arg));
209
272
  }
210
273
  dispose() {
211
- this.disposables.forEach((arg) => arg.dispose());
274
+ this._disposables.forEach((arg) => arg.dispose());
212
275
  this._isDisposed = true;
213
276
  }
214
277
  }
@@ -298,6 +361,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
298
361
  this.onDidFocus = this._onDidFocus.event;
299
362
  this._onDidBlur = new Emitter();
300
363
  this.onDidBlur = this._onDidBlur.event;
364
+ this.addDisposables(this._onDidFocus, this._onDidBlur);
301
365
  let hasFocus = isAncestor(document.activeElement, element);
302
366
  let loosingFocus = false;
303
367
  const onFocus = () => {
@@ -342,11 +406,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
342
406
  refreshState() {
343
407
  this._refreshStateHandler();
344
408
  }
345
- dispose() {
346
- super.dispose();
347
- this._onDidBlur.dispose();
348
- this._onDidFocus.dispose();
349
- }
350
409
  }
351
410
 
352
411
  function createComponent(id, componentName, components = {}, frameworkComponents = {}, createFrameworkComponent, fallback) {
@@ -575,7 +634,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
575
634
  this._orthogonalSize = value;
576
635
  }
577
636
  get length() {
578
- return this.views.length;
637
+ return this.viewItems.length;
579
638
  }
580
639
  get proportions() {
581
640
  return this._proportions ? [...this._proportions] : undefined;
@@ -594,12 +653,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
594
653
  : 'vertical');
595
654
  }
596
655
  get minimumSize() {
597
- return this.views.reduce((r, item) => r + item.minimumSize, 0);
656
+ return this.viewItems.reduce((r, item) => r + item.minimumSize, 0);
598
657
  }
599
658
  get maximumSize() {
600
659
  return this.length === 0
601
660
  ? Number.POSITIVE_INFINITY
602
- : this.views.reduce((r, item) => r + item.maximumSize, 0);
661
+ : this.viewItems.reduce((r, item) => r + item.maximumSize, 0);
603
662
  }
604
663
  get startSnappingEnabled() {
605
664
  return this._startSnappingEnabled;
@@ -623,7 +682,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
623
682
  }
624
683
  constructor(container, options) {
625
684
  this.container = container;
626
- this.views = [];
685
+ this.viewItems = [];
627
686
  this.sashes = [];
628
687
  this._size = 0;
629
688
  this._orthogonalSize = 0;
@@ -637,12 +696,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
637
696
  this.onDidAddView = this._onDidAddView.event;
638
697
  this._onDidRemoveView = new Emitter();
639
698
  this.onDidRemoveView = this._onDidRemoveView.event;
640
- this.resize = (index, delta, sizes = this.views.map((x) => x.size), lowPriorityIndexes, highPriorityIndexes, overloadMinDelta = Number.NEGATIVE_INFINITY, overloadMaxDelta = Number.POSITIVE_INFINITY, snapBefore, snapAfter) => {
641
- if (index < 0 || index > this.views.length) {
699
+ this.resize = (index, delta, sizes = this.viewItems.map((x) => x.size), lowPriorityIndexes, highPriorityIndexes, overloadMinDelta = Number.NEGATIVE_INFINITY, overloadMaxDelta = Number.POSITIVE_INFINITY, snapBefore, snapAfter) => {
700
+ if (index < 0 || index > this.viewItems.length) {
642
701
  return 0;
643
702
  }
644
703
  const upIndexes = range(index, -1);
645
- const downIndexes = range(index + 1, this.views.length);
704
+ const downIndexes = range(index + 1, this.viewItems.length);
646
705
  //
647
706
  if (highPriorityIndexes) {
648
707
  for (const i of highPriorityIndexes) {
@@ -657,34 +716,34 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
657
716
  }
658
717
  }
659
718
  //
660
- const upItems = upIndexes.map((i) => this.views[i]);
719
+ const upItems = upIndexes.map((i) => this.viewItems[i]);
661
720
  const upSizes = upIndexes.map((i) => sizes[i]);
662
721
  //
663
- const downItems = downIndexes.map((i) => this.views[i]);
722
+ const downItems = downIndexes.map((i) => this.viewItems[i]);
664
723
  const downSizes = downIndexes.map((i) => sizes[i]);
665
724
  //
666
- const minDeltaUp = upIndexes.reduce((_, i) => _ + this.views[i].minimumSize - sizes[i], 0);
667
- const maxDeltaUp = upIndexes.reduce((_, i) => _ + this.views[i].maximumSize - sizes[i], 0);
725
+ const minDeltaUp = upIndexes.reduce((_, i) => _ + this.viewItems[i].minimumSize - sizes[i], 0);
726
+ const maxDeltaUp = upIndexes.reduce((_, i) => _ + this.viewItems[i].maximumSize - sizes[i], 0);
668
727
  //
669
728
  const maxDeltaDown = downIndexes.length === 0
670
729
  ? Number.POSITIVE_INFINITY
671
- : downIndexes.reduce((_, i) => _ + sizes[i] - this.views[i].minimumSize, 0);
730
+ : downIndexes.reduce((_, i) => _ + sizes[i] - this.viewItems[i].minimumSize, 0);
672
731
  const minDeltaDown = downIndexes.length === 0
673
732
  ? Number.NEGATIVE_INFINITY
674
- : downIndexes.reduce((_, i) => _ + sizes[i] - this.views[i].maximumSize, 0);
733
+ : downIndexes.reduce((_, i) => _ + sizes[i] - this.viewItems[i].maximumSize, 0);
675
734
  //
676
735
  const minDelta = Math.max(minDeltaUp, minDeltaDown);
677
736
  const maxDelta = Math.min(maxDeltaDown, maxDeltaUp);
678
737
  //
679
738
  let snapped = false;
680
739
  if (snapBefore) {
681
- const snapView = this.views[snapBefore.index];
740
+ const snapView = this.viewItems[snapBefore.index];
682
741
  const visible = delta >= snapBefore.limitDelta;
683
742
  snapped = visible !== snapView.visible;
684
743
  snapView.setVisible(visible, snapBefore.size);
685
744
  }
686
745
  if (!snapped && snapAfter) {
687
- const snapView = this.views[snapAfter.index];
746
+ const snapView = this.viewItems[snapAfter.index];
688
747
  const visible = delta < snapAfter.limitDelta;
689
748
  snapped = visible !== snapView.visible;
690
749
  snapView.setVisible(visible, snapAfter.size);
@@ -746,7 +805,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
746
805
  );
747
806
  });
748
807
  // Initialize content size and proportions for first layout
749
- this.contentSize = this.views.reduce((r, i) => r + i.size, 0);
808
+ this.contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
750
809
  this.saveProportions();
751
810
  }
752
811
  }
@@ -763,18 +822,18 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
763
822
  }
764
823
  }
765
824
  isViewVisible(index) {
766
- if (index < 0 || index >= this.views.length) {
825
+ if (index < 0 || index >= this.viewItems.length) {
767
826
  throw new Error('Index out of bounds');
768
827
  }
769
- const viewItem = this.views[index];
828
+ const viewItem = this.viewItems[index];
770
829
  return viewItem.visible;
771
830
  }
772
831
  setViewVisible(index, visible) {
773
- if (index < 0 || index >= this.views.length) {
832
+ if (index < 0 || index >= this.viewItems.length) {
774
833
  throw new Error('Index out of bounds');
775
834
  }
776
835
  toggleClass(this.container, 'visible', visible);
777
- const viewItem = this.views[index];
836
+ const viewItem = this.viewItems[index];
778
837
  toggleClass(this.container, 'visible', visible);
779
838
  viewItem.setVisible(visible, viewItem.size);
780
839
  this.distributeEmptySpace(index);
@@ -782,33 +841,33 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
782
841
  this.saveProportions();
783
842
  }
784
843
  getViewSize(index) {
785
- if (index < 0 || index >= this.views.length) {
844
+ if (index < 0 || index >= this.viewItems.length) {
786
845
  return -1;
787
846
  }
788
- return this.views[index].size;
847
+ return this.viewItems[index].size;
789
848
  }
790
849
  resizeView(index, size) {
791
- if (index < 0 || index >= this.views.length) {
850
+ if (index < 0 || index >= this.viewItems.length) {
792
851
  return;
793
852
  }
794
- const indexes = range(this.views.length).filter((i) => i !== index);
853
+ const indexes = range(this.viewItems.length).filter((i) => i !== index);
795
854
  const lowPriorityIndexes = [
796
- ...indexes.filter((i) => this.views[i].priority === exports.LayoutPriority.Low),
855
+ ...indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.Low),
797
856
  index,
798
857
  ];
799
- const highPriorityIndexes = indexes.filter((i) => this.views[i].priority === exports.LayoutPriority.High);
800
- const item = this.views[index];
858
+ const highPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.High);
859
+ const item = this.viewItems[index];
801
860
  size = Math.round(size);
802
861
  size = clamp(size, item.minimumSize, Math.min(item.maximumSize, this._size));
803
862
  item.size = size;
804
863
  this.relayout(lowPriorityIndexes, highPriorityIndexes);
805
864
  }
806
865
  getViews() {
807
- return this.views.map((x) => x.view);
866
+ return this.viewItems.map((x) => x.view);
808
867
  }
809
868
  onDidChange(item, size) {
810
- const index = this.views.indexOf(item);
811
- if (index < 0 || index >= this.views.length) {
869
+ const index = this.viewItems.indexOf(item);
870
+ if (index < 0 || index >= this.viewItems.length) {
812
871
  return;
813
872
  }
814
873
  size = typeof size === 'number' ? size : item.size;
@@ -816,7 +875,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
816
875
  item.size = size;
817
876
  this.relayout([index]);
818
877
  }
819
- addView(view, size = { type: 'distribute' }, index = this.views.length, skipLayout) {
878
+ addView(view, size = { type: 'distribute' }, index = this.viewItems.length, skipLayout) {
820
879
  const container = document.createElement('div');
821
880
  container.className = 'view';
822
881
  container.appendChild(view.element);
@@ -834,24 +893,25 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
834
893
  viewSize = view.minimumSize;
835
894
  }
836
895
  const disposable = view.onDidChange((newSize) => this.onDidChange(viewItem, newSize.size));
837
- const dispose = () => {
838
- disposable === null || disposable === void 0 ? void 0 : disposable.dispose();
839
- this.viewContainer.removeChild(container);
840
- };
841
- const viewItem = new ViewItem(container, view, viewSize, { dispose });
842
- if (index === this.views.length) {
896
+ const viewItem = new ViewItem(container, view, viewSize, {
897
+ dispose: () => {
898
+ disposable.dispose();
899
+ this.viewContainer.removeChild(container);
900
+ },
901
+ });
902
+ if (index === this.viewItems.length) {
843
903
  this.viewContainer.appendChild(container);
844
904
  }
845
905
  else {
846
906
  this.viewContainer.insertBefore(container, this.viewContainer.children.item(index));
847
907
  }
848
- this.views.splice(index, 0, viewItem);
849
- if (this.views.length > 1) {
908
+ this.viewItems.splice(index, 0, viewItem);
909
+ if (this.viewItems.length > 1) {
850
910
  //add sash
851
911
  const sash = document.createElement('div');
852
912
  sash.className = 'sash';
853
913
  const onStart = (event) => {
854
- for (const item of this.views) {
914
+ for (const item of this.viewItems) {
855
915
  item.enabled = false;
856
916
  }
857
917
  const iframes = [
@@ -866,27 +926,29 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
866
926
  : event.clientY;
867
927
  const sashIndex = firstIndex(this.sashes, (s) => s.container === sash);
868
928
  //
869
- const sizes = this.views.map((x) => x.size);
929
+ const sizes = this.viewItems.map((x) => x.size);
870
930
  //
871
931
  let snapBefore;
872
932
  let snapAfter;
873
933
  const upIndexes = range(sashIndex, -1);
874
- const downIndexes = range(sashIndex + 1, this.views.length);
875
- const minDeltaUp = upIndexes.reduce((r, i) => r + (this.views[i].minimumSize - sizes[i]), 0);
876
- const maxDeltaUp = upIndexes.reduce((r, i) => r + (this.views[i].viewMaximumSize - sizes[i]), 0);
934
+ const downIndexes = range(sashIndex + 1, this.viewItems.length);
935
+ const minDeltaUp = upIndexes.reduce((r, i) => r + (this.viewItems[i].minimumSize - sizes[i]), 0);
936
+ const maxDeltaUp = upIndexes.reduce((r, i) => r + (this.viewItems[i].viewMaximumSize - sizes[i]), 0);
877
937
  const maxDeltaDown = downIndexes.length === 0
878
938
  ? Number.POSITIVE_INFINITY
879
- : downIndexes.reduce((r, i) => r + (sizes[i] - this.views[i].minimumSize), 0);
939
+ : downIndexes.reduce((r, i) => r +
940
+ (sizes[i] - this.viewItems[i].minimumSize), 0);
880
941
  const minDeltaDown = downIndexes.length === 0
881
942
  ? Number.NEGATIVE_INFINITY
882
943
  : downIndexes.reduce((r, i) => r +
883
- (sizes[i] - this.views[i].viewMaximumSize), 0);
944
+ (sizes[i] -
945
+ this.viewItems[i].viewMaximumSize), 0);
884
946
  const minDelta = Math.max(minDeltaUp, minDeltaDown);
885
947
  const maxDelta = Math.min(maxDeltaDown, maxDeltaUp);
886
948
  const snapBeforeIndex = this.findFirstSnapIndex(upIndexes);
887
949
  const snapAfterIndex = this.findFirstSnapIndex(downIndexes);
888
950
  if (typeof snapBeforeIndex === 'number') {
889
- const snappedViewItem = this.views[snapBeforeIndex];
951
+ const snappedViewItem = this.viewItems[snapBeforeIndex];
890
952
  const halfSize = Math.floor(snappedViewItem.viewMinimumSize / 2);
891
953
  snapBefore = {
892
954
  index: snapBeforeIndex,
@@ -897,7 +959,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
897
959
  };
898
960
  }
899
961
  if (typeof snapAfterIndex === 'number') {
900
- const snappedViewItem = this.views[snapAfterIndex];
962
+ const snappedViewItem = this.viewItems[snapAfterIndex];
901
963
  const halfSize = Math.floor(snappedViewItem.viewMinimumSize / 2);
902
964
  snapAfter = {
903
965
  index: snapAfterIndex,
@@ -918,7 +980,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
918
980
  this.layoutViews();
919
981
  };
920
982
  const end = () => {
921
- for (const item of this.views) {
983
+ for (const item of this.viewItems) {
922
984
  item.enabled = true;
923
985
  }
924
986
  for (const iframe of iframes) {
@@ -958,7 +1020,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
958
1020
  distributeViewSizes() {
959
1021
  const flexibleViewItems = [];
960
1022
  let flexibleSize = 0;
961
- for (const item of this.views) {
1023
+ for (const item of this.viewItems) {
962
1024
  if (item.maximumSize - item.minimumSize > 0) {
963
1025
  flexibleViewItems.push(item);
964
1026
  flexibleSize += item.size;
@@ -968,17 +1030,17 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
968
1030
  for (const item of flexibleViewItems) {
969
1031
  item.size = clamp(size, item.minimumSize, item.maximumSize);
970
1032
  }
971
- const indexes = range(this.views.length);
972
- const lowPriorityIndexes = indexes.filter((i) => this.views[i].priority === exports.LayoutPriority.Low);
973
- const highPriorityIndexes = indexes.filter((i) => this.views[i].priority === exports.LayoutPriority.High);
1033
+ const indexes = range(this.viewItems.length);
1034
+ const lowPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.Low);
1035
+ const highPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.High);
974
1036
  this.relayout(lowPriorityIndexes, highPriorityIndexes);
975
1037
  }
976
1038
  removeView(index, sizing, skipLayout = false) {
977
1039
  // Remove view
978
- const viewItem = this.views.splice(index, 1)[0];
1040
+ const viewItem = this.viewItems.splice(index, 1)[0];
979
1041
  viewItem.dispose();
980
1042
  // Remove sash
981
- if (this.views.length >= 1) {
1043
+ if (this.viewItems.length >= 1) {
982
1044
  const sashIndex = Math.max(index - 1, 0);
983
1045
  const sashItem = this.sashes.splice(sashIndex, 1)[0];
984
1046
  sashItem.disposable();
@@ -993,10 +1055,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
993
1055
  return viewItem.view;
994
1056
  }
995
1057
  getViewCachedVisibleSize(index) {
996
- if (index < 0 || index >= this.views.length) {
1058
+ if (index < 0 || index >= this.viewItems.length) {
997
1059
  throw new Error('Index out of bounds');
998
1060
  }
999
- const viewItem = this.views[index];
1061
+ const viewItem = this.viewItems[index];
1000
1062
  return viewItem.cachedVisibleSize;
1001
1063
  }
1002
1064
  moveView(from, to) {
@@ -1012,14 +1074,14 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1012
1074
  this.size = size;
1013
1075
  this.orthogonalSize = orthogonalSize;
1014
1076
  if (!this.proportions) {
1015
- const indexes = range(this.views.length);
1016
- const lowPriorityIndexes = indexes.filter((i) => this.views[i].priority === exports.LayoutPriority.Low);
1017
- const highPriorityIndexes = indexes.filter((i) => this.views[i].priority === exports.LayoutPriority.High);
1018
- this.resize(this.views.length - 1, size - previousSize, undefined, lowPriorityIndexes, highPriorityIndexes);
1077
+ const indexes = range(this.viewItems.length);
1078
+ const lowPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.Low);
1079
+ const highPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.High);
1080
+ this.resize(this.viewItems.length - 1, size - previousSize, undefined, lowPriorityIndexes, highPriorityIndexes);
1019
1081
  }
1020
1082
  else {
1021
- for (let i = 0; i < this.views.length; i++) {
1022
- const item = this.views[i];
1083
+ for (let i = 0; i < this.viewItems.length; i++) {
1084
+ const item = this.viewItems[i];
1023
1085
  item.size = clamp(Math.round(this.proportions[i] * size), item.minimumSize, item.maximumSize);
1024
1086
  }
1025
1087
  }
@@ -1027,18 +1089,18 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1027
1089
  this.layoutViews();
1028
1090
  }
1029
1091
  relayout(lowPriorityIndexes, highPriorityIndexes) {
1030
- const contentSize = this.views.reduce((r, i) => r + i.size, 0);
1031
- this.resize(this.views.length - 1, this._size - contentSize, undefined, lowPriorityIndexes, highPriorityIndexes);
1092
+ const contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
1093
+ this.resize(this.viewItems.length - 1, this._size - contentSize, undefined, lowPriorityIndexes, highPriorityIndexes);
1032
1094
  this.distributeEmptySpace();
1033
1095
  this.layoutViews();
1034
1096
  this.saveProportions();
1035
1097
  }
1036
1098
  distributeEmptySpace(lowPriorityIndex) {
1037
- const contentSize = this.views.reduce((r, i) => r + i.size, 0);
1099
+ const contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
1038
1100
  let emptyDelta = this.size - contentSize;
1039
- const indexes = range(this.views.length - 1, -1);
1040
- const lowPriorityIndexes = indexes.filter((i) => this.views[i].priority === exports.LayoutPriority.Low);
1041
- const highPriorityIndexes = indexes.filter((i) => this.views[i].priority === exports.LayoutPriority.High);
1101
+ const indexes = range(this.viewItems.length - 1, -1);
1102
+ const lowPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.Low);
1103
+ const highPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.High);
1042
1104
  for (const index of highPriorityIndexes) {
1043
1105
  pushToStart(indexes, index);
1044
1106
  }
@@ -1049,7 +1111,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1049
1111
  pushToEnd(indexes, lowPriorityIndex);
1050
1112
  }
1051
1113
  for (let i = 0; emptyDelta !== 0 && i < indexes.length; i++) {
1052
- const item = this.views[indexes[i]];
1114
+ const item = this.viewItems[indexes[i]];
1053
1115
  const size = clamp(item.size + emptyDelta, item.minimumSize, item.maximumSize);
1054
1116
  const viewDelta = size - item.size;
1055
1117
  emptyDelta -= viewDelta;
@@ -1058,16 +1120,16 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1058
1120
  }
1059
1121
  saveProportions() {
1060
1122
  if (this.proportionalLayout && this.contentSize > 0) {
1061
- this._proportions = this.views.map((i) => i.size / this.contentSize);
1123
+ this._proportions = this.viewItems.map((i) => i.size / this.contentSize);
1062
1124
  }
1063
1125
  }
1064
1126
  layoutViews() {
1065
- this.contentSize = this.views.reduce((r, i) => r + i.size, 0);
1127
+ this.contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
1066
1128
  let sum = 0;
1067
1129
  const x = [];
1068
1130
  this.updateSashEnablement();
1069
- for (let i = 0; i < this.views.length - 1; i++) {
1070
- sum += this.views[i].size;
1131
+ for (let i = 0; i < this.viewItems.length - 1; i++) {
1132
+ sum += this.viewItems[i].size;
1071
1133
  x.push(sum);
1072
1134
  const offset = Math.min(Math.max(0, sum - 2), this.size - 4);
1073
1135
  if (this._orientation === exports.Orientation.HORIZONTAL) {
@@ -1079,7 +1141,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1079
1141
  this.sashes[i].container.style.top = `${offset}px`;
1080
1142
  }
1081
1143
  }
1082
- this.views.forEach((view, i) => {
1144
+ this.viewItems.forEach((view, i) => {
1083
1145
  if (this._orientation === exports.Orientation.HORIZONTAL) {
1084
1146
  view.container.style.width = `${view.size}px`;
1085
1147
  view.container.style.left = i == 0 ? '0px' : `${x[i - 1]}px`;
@@ -1098,7 +1160,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1098
1160
  findFirstSnapIndex(indexes) {
1099
1161
  // visible views first
1100
1162
  for (const index of indexes) {
1101
- const viewItem = this.views[index];
1163
+ const viewItem = this.viewItems[index];
1102
1164
  if (!viewItem.visible) {
1103
1165
  continue;
1104
1166
  }
@@ -1108,7 +1170,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1108
1170
  }
1109
1171
  // then, hidden views
1110
1172
  for (const index of indexes) {
1111
- const viewItem = this.views[index];
1173
+ const viewItem = this.viewItems[index];
1112
1174
  if (viewItem.visible &&
1113
1175
  viewItem.maximumSize - viewItem.minimumSize > 0) {
1114
1176
  return undefined;
@@ -1121,10 +1183,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1121
1183
  }
1122
1184
  updateSashEnablement() {
1123
1185
  let previous = false;
1124
- const collapsesDown = this.views.map((i) => (previous = i.size - i.minimumSize > 0 || previous));
1186
+ const collapsesDown = this.viewItems.map((i) => (previous = i.size - i.minimumSize > 0 || previous));
1125
1187
  previous = false;
1126
- const expandsDown = this.views.map((i) => (previous = i.maximumSize - i.size > 0 || previous));
1127
- const reverseViews = [...this.views].reverse();
1188
+ const expandsDown = this.viewItems.map((i) => (previous = i.maximumSize - i.size > 0 || previous));
1189
+ const reverseViews = [...this.viewItems].reverse();
1128
1190
  previous = false;
1129
1191
  const collapsesUp = reverseViews
1130
1192
  .map((i) => (previous = i.size - i.minimumSize > 0 || previous))
@@ -1136,19 +1198,19 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1136
1198
  let position = 0;
1137
1199
  for (let index = 0; index < this.sashes.length; index++) {
1138
1200
  const sash = this.sashes[index];
1139
- const viewItem = this.views[index];
1201
+ const viewItem = this.viewItems[index];
1140
1202
  position += viewItem.size;
1141
1203
  const min = !(collapsesDown[index] && expandsUp[index + 1]);
1142
1204
  const max = !(expandsDown[index] && collapsesUp[index + 1]);
1143
1205
  if (min && max) {
1144
1206
  const upIndexes = range(index, -1);
1145
- const downIndexes = range(index + 1, this.views.length);
1207
+ const downIndexes = range(index + 1, this.viewItems.length);
1146
1208
  const snapBeforeIndex = this.findFirstSnapIndex(upIndexes);
1147
1209
  const snapAfterIndex = this.findFirstSnapIndex(downIndexes);
1148
1210
  const snappedBefore = typeof snapBeforeIndex === 'number' &&
1149
- !this.views[snapBeforeIndex].visible;
1211
+ !this.viewItems[snapBeforeIndex].visible;
1150
1212
  const snappedAfter = typeof snapAfterIndex === 'number' &&
1151
- !this.views[snapAfterIndex].visible;
1213
+ !this.viewItems[snapAfterIndex].visible;
1152
1214
  if (snappedBefore &&
1153
1215
  collapsesUp[index] &&
1154
1216
  (position > 0 || this.startSnappingEnabled)) {
@@ -1208,6 +1270,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1208
1270
  break;
1209
1271
  }
1210
1272
  }
1273
+ for (const viewItem of this.viewItems) {
1274
+ viewItem.dispose();
1275
+ }
1211
1276
  this.element.remove();
1212
1277
  }
1213
1278
  }
@@ -1642,7 +1707,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1642
1707
  throw new Error('Invalid index');
1643
1708
  }
1644
1709
  this.splitview.removeView(index, sizing);
1645
- this._removeChild(index);
1710
+ return this._removeChild(index);
1646
1711
  }
1647
1712
  _addChild(node, index) {
1648
1713
  this.children.splice(index, 0, node);
@@ -1664,10 +1729,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1664
1729
  });
1665
1730
  }
1666
1731
  dispose() {
1667
- super.dispose();
1668
1732
  this._childrenDisposable.dispose();
1669
- this.children.forEach((child) => child.dispose());
1670
1733
  this.splitview.dispose();
1734
+ this.children.forEach((child) => child.dispose());
1735
+ super.dispose();
1671
1736
  }
1672
1737
  }
1673
1738
 
@@ -1897,7 +1962,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1897
1962
  if (oldRoot.children.length === 1) {
1898
1963
  // can remove one level of redundant branching if there is only a single child
1899
1964
  const childReference = oldRoot.children[0];
1900
- oldRoot.removeChild(0); // remove to prevent disposal when disposing of unwanted root
1965
+ const child = oldRoot.removeChild(0); // remove to prevent disposal when disposing of unwanted root
1966
+ child.dispose();
1901
1967
  oldRoot.dispose();
1902
1968
  this._root.addChild(
1903
1969
  /**
@@ -2004,7 +2070,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2004
2070
  if (typeof newSiblingCachedVisibleSize === 'number') {
2005
2071
  newSiblingSize = exports.Sizing.Invisible(newSiblingCachedVisibleSize);
2006
2072
  }
2007
- grandParent.removeChild(parentIndex);
2073
+ const child = grandParent.removeChild(parentIndex);
2074
+ child.dispose();
2008
2075
  const newParent = new BranchNode(parent.orientation, this.proportionalLayout, this.styles, parent.size, parent.orthogonalSize);
2009
2076
  grandParent.addChild(newParent, parent.size, parentIndex);
2010
2077
  const newSibling = new LeafNode(parent.view, grandParent.orientation, parent.size);
@@ -2030,30 +2097,36 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2030
2097
  if (!(node instanceof LeafNode)) {
2031
2098
  throw new Error('Invalid location');
2032
2099
  }
2033
- parent.removeChild(index, sizing);
2100
+ const view = node.view;
2101
+ node.dispose(); // dispose of node
2102
+ const child = parent.removeChild(index, sizing);
2103
+ child.dispose();
2034
2104
  if (parent.children.length === 0) {
2035
- return node.view;
2105
+ return view;
2036
2106
  }
2037
2107
  if (parent.children.length > 1) {
2038
- return node.view;
2108
+ return view;
2039
2109
  }
2040
2110
  const sibling = parent.children[0];
2041
2111
  if (pathToParent.length === 0) {
2042
2112
  // parent is root
2043
2113
  if (sibling instanceof LeafNode) {
2044
- return node.view;
2114
+ return view;
2045
2115
  }
2046
2116
  // we must promote sibling to be the new root
2047
- parent.removeChild(0, sizing);
2117
+ const child = parent.removeChild(0, sizing);
2118
+ child.dispose();
2048
2119
  this.root = sibling;
2049
- return node.view;
2120
+ return view;
2050
2121
  }
2051
2122
  const [grandParent, ..._] = [...pathToParent].reverse();
2052
2123
  const [parentIndex, ...__] = [...rest].reverse();
2053
2124
  const isSiblingVisible = parent.isChildVisible(0);
2054
- parent.removeChild(0, sizing);
2125
+ const childNode = parent.removeChild(0, sizing);
2126
+ childNode.dispose();
2055
2127
  const sizes = grandParent.children.map((_size, i) => grandParent.getChildSize(i));
2056
- grandParent.removeChild(parentIndex, sizing);
2128
+ const parentNode = grandParent.removeChild(parentIndex, sizing);
2129
+ parentNode.dispose();
2057
2130
  if (sibling instanceof BranchNode) {
2058
2131
  sizes.splice(parentIndex, 1, ...sibling.children.map((c) => c.size));
2059
2132
  for (let i = 0; i < sibling.children.length; i++) {
@@ -2071,7 +2144,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2071
2144
  for (let i = 0; i < sizes.length; i++) {
2072
2145
  grandParent.resizeChild(i, sizes[i]);
2073
2146
  }
2074
- return node.view;
2147
+ return view;
2075
2148
  }
2076
2149
  layout(width, height) {
2077
2150
  const [size, orthogonalSize] = this.root.orientation === exports.Orientation.HORIZONTAL
@@ -2566,6 +2639,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2566
2639
  }
2567
2640
  dispose() {
2568
2641
  this.removeDropTarget();
2642
+ super.dispose();
2569
2643
  }
2570
2644
  toggleClasses(quadrant, width, height) {
2571
2645
  var _a, _b, _c, _d;
@@ -2743,8 +2817,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2743
2817
  if (this.panel.view) {
2744
2818
  const _onDidFocus = this.panel.view.content.onDidFocus;
2745
2819
  const _onDidBlur = this.panel.view.content.onDidBlur;
2746
- const { onDidFocus, onDidBlur } = trackFocus(this._element);
2747
- disposable.addDisposables(onDidFocus(() => this._onDidFocus.fire()), onDidBlur(() => this._onDidBlur.fire()));
2820
+ const focusTracker = trackFocus(this._element);
2821
+ disposable.addDisposables(focusTracker, focusTracker.onDidFocus(() => this._onDidFocus.fire()), focusTracker.onDidBlur(() => this._onDidBlur.fire()));
2748
2822
  if (_onDidFocus) {
2749
2823
  disposable.addDisposables(_onDidFocus(() => this._onDidFocus.fire()));
2750
2824
  }
@@ -2787,6 +2861,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2787
2861
  this._onDragStart = new Emitter();
2788
2862
  this.onDragStart = this._onDragStart.event;
2789
2863
  this.iframes = [];
2864
+ this.addDisposables(this._onDragStart);
2790
2865
  this.configure();
2791
2866
  }
2792
2867
  configure() {
@@ -2837,13 +2912,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2837
2912
  this.onChanged = this._onChanged.event;
2838
2913
  this._onDropped = new Emitter();
2839
2914
  this.onDrop = this._onDropped.event;
2840
- this.addDisposables(this._onChanged, this._onDropped);
2841
2915
  this._element = document.createElement('div');
2842
2916
  this._element.className = 'tab';
2843
2917
  this._element.tabIndex = 0;
2844
2918
  this._element.draggable = true;
2845
2919
  toggleClass(this.element, 'inactive-tab', true);
2846
- this.addDisposables(new (class Handler extends DragHandler {
2920
+ this.addDisposables(this._onChanged, this._onDropped, new (class Handler extends DragHandler {
2847
2921
  constructor() {
2848
2922
  super(...arguments);
2849
2923
  this.panelTransfer = LocalSelectionTransfer.getInstance();
@@ -2856,9 +2930,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2856
2930
  },
2857
2931
  };
2858
2932
  }
2859
- dispose() {
2860
- //
2861
- }
2862
2933
  })(this._element));
2863
2934
  this.addDisposables(addDisposableListener(this._element, 'mousedown', (event) => {
2864
2935
  if (event.defaultPrevented) {
@@ -2893,7 +2964,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2893
2964
  });
2894
2965
  this.addDisposables(this.droptarget.onDrop((event) => {
2895
2966
  this._onDropped.fire(event);
2896
- }));
2967
+ }), this.droptarget);
2897
2968
  }
2898
2969
  setActive(isActive) {
2899
2970
  toggleClass(this.element, 'active-tab', isActive);
@@ -2908,7 +2979,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2908
2979
  }
2909
2980
  dispose() {
2910
2981
  super.dispose();
2911
- this.droptarget.dispose();
2912
2982
  }
2913
2983
  }
2914
2984
 
@@ -2954,9 +3024,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2954
3024
  },
2955
3025
  };
2956
3026
  }
2957
- dispose() {
2958
- //
2959
- }
2960
3027
  }
2961
3028
 
2962
3029
  class VoidContainer extends CompositeDisposable {
@@ -3112,6 +3179,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3112
3179
  const tabToRemove = this.tabs.splice(index, 1)[0];
3113
3180
  const { value, disposable } = tabToRemove;
3114
3181
  disposable.dispose();
3182
+ value.dispose();
3115
3183
  value.element.remove();
3116
3184
  }
3117
3185
  setActivePanel(panel) {
@@ -3155,9 +3223,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3155
3223
  }
3156
3224
  dispose() {
3157
3225
  super.dispose();
3158
- this.tabs.forEach((tab) => {
3159
- tab.disposable.dispose();
3160
- });
3226
+ for (const { value, disposable } of this.tabs) {
3227
+ disposable.dispose();
3228
+ value.dispose();
3229
+ }
3161
3230
  this.tabs = [];
3162
3231
  }
3163
3232
  }
@@ -3255,7 +3324,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3255
3324
  container.append(this.tabsContainer.element, this.contentContainer.element);
3256
3325
  this.header.hidden = !!options.hideHeader;
3257
3326
  this.locked = !!options.locked;
3258
- this.addDisposables(this._onMove, this._onDidChange, this._onDidDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange, this.tabsContainer.onDrop((event) => {
3327
+ this.addDisposables(this.tabsContainer.onDrop((event) => {
3259
3328
  this.handleDropEvent(event.event, 'center', event.index);
3260
3329
  }), this.contentContainer.onDidFocus(() => {
3261
3330
  this.accessor.doSetGroupActive(this.groupPanel, true);
@@ -3263,7 +3332,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3263
3332
  // noop
3264
3333
  }), this.dropTarget.onDrop((event) => {
3265
3334
  this.handleDropEvent(event.nativeEvent, event.position);
3266
- }));
3335
+ }), this._onMove, this._onDidChange, this._onDidDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange);
3267
3336
  }
3268
3337
  initialize() {
3269
3338
  var _a, _b;
@@ -3697,8 +3766,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3697
3766
  this.layout(0, 0, true); // set some elements height/widths
3698
3767
  this.addDisposables(this.gridview.onDidChange(() => {
3699
3768
  this._bufferOnDidLayoutChange.fire();
3700
- }));
3701
- this.addDisposables(exports.DockviewEvent.any(this.onDidAddGroup, this.onDidRemoveGroup, this.onDidActiveGroupChange)(() => {
3769
+ }), exports.DockviewEvent.any(this.onDidAddGroup, this.onDidRemoveGroup, this.onDidActiveGroupChange)(() => {
3702
3770
  this._bufferOnDidLayoutChange.fire();
3703
3771
  }), this._bufferOnDidLayoutChange.onEvent(() => {
3704
3772
  this._onDidLayoutChange.fire();
@@ -3801,7 +3869,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3801
3869
  this.gridview.layout(width, height);
3802
3870
  }
3803
3871
  dispose() {
3804
- super.dispose();
3805
3872
  this._onDidActiveGroupChange.dispose();
3806
3873
  this._onDidAddGroup.dispose();
3807
3874
  this._onDidRemoveGroup.dispose();
@@ -3810,6 +3877,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3810
3877
  group.dispose();
3811
3878
  }
3812
3879
  this.gridview.dispose();
3880
+ super.dispose();
3813
3881
  }
3814
3882
  }
3815
3883
 
@@ -3873,7 +3941,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3873
3941
  //
3874
3942
  this._onUpdateParameters = new Emitter();
3875
3943
  this.onUpdateParameters = this._onUpdateParameters.event;
3876
- this.addDisposables(this.panelUpdatesDisposable, this._onDidDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onFocusEvent, this._onActiveChange, this._onVisibilityChange, this._onUpdateParameters, this.onDidFocusChange((event) => {
3944
+ this.addDisposables(this.onDidFocusChange((event) => {
3877
3945
  this._isFocused = event.isFocused;
3878
3946
  }), this.onDidActiveChange((event) => {
3879
3947
  this._isActive = event.isActive;
@@ -3882,14 +3950,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3882
3950
  }), this.onDidDimensionsChange((event) => {
3883
3951
  this._width = event.width;
3884
3952
  this._height = event.height;
3885
- }));
3953
+ }), this.panelUpdatesDisposable, this._onDidDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onFocusEvent, this._onActiveChange, this._onVisibilityChange, this._onUpdateParameters);
3886
3954
  }
3887
3955
  initialize(panel) {
3888
3956
  this.panelUpdatesDisposable.value = this._onUpdateParameters.event((parameters) => {
3889
3957
  panel.update({
3890
- params: {
3891
- params: parameters,
3892
- },
3958
+ params: parameters,
3893
3959
  });
3894
3960
  });
3895
3961
  }
@@ -3984,12 +4050,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3984
4050
  this._element.style.height = '100%';
3985
4051
  this._element.style.width = '100%';
3986
4052
  this._element.style.overflow = 'hidden';
3987
- const { onDidFocus, onDidBlur } = trackFocus(this._element);
3988
- this.addDisposables(this.api, onDidFocus(() => {
4053
+ const focusTracker = trackFocus(this._element);
4054
+ this.addDisposables(this.api, focusTracker.onDidFocus(() => {
3989
4055
  this.api._onDidChangeFocus.fire({ isFocused: true });
3990
- }), onDidBlur(() => {
4056
+ }), focusTracker.onDidBlur(() => {
3991
4057
  this.api._onDidChangeFocus.fire({ isFocused: false });
3992
- }));
4058
+ }), focusTracker);
3993
4059
  }
3994
4060
  focus() {
3995
4061
  this.api._onFocusEvent.fire();
@@ -4010,7 +4076,18 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4010
4076
  }
4011
4077
  update(event) {
4012
4078
  var _a, _b;
4079
+ // merge the new parameters with the existing parameters
4013
4080
  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) });
4081
+ /**
4082
+ * delete new keys that have a value of undefined,
4083
+ * allow values of null
4084
+ */
4085
+ for (const key of Object.keys(event.params)) {
4086
+ if (event.params[key] === undefined) {
4087
+ delete this._params.params[key];
4088
+ }
4089
+ }
4090
+ // update the view with the updated props
4014
4091
  (_b = this.part) === null || _b === void 0 ? void 0 : _b.update({ params: this._params.params });
4015
4092
  }
4016
4093
  toJSON() {
@@ -4024,9 +4101,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4024
4101
  }
4025
4102
  dispose() {
4026
4103
  var _a;
4027
- super.dispose();
4028
4104
  this.api.dispose();
4029
4105
  (_a = this.part) === null || _a === void 0 ? void 0 : _a.dispose();
4106
+ super.dispose();
4030
4107
  }
4031
4108
  }
4032
4109
 
@@ -4405,7 +4482,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4405
4482
  this._maximumHeight = options.maximumHeight;
4406
4483
  }
4407
4484
  this.api.initialize(this); // TODO: required to by-pass 'super before this' requirement
4408
- this.addDisposables(this._onDidChange, this.api.onVisibilityChange((event) => {
4485
+ this.addDisposables(this.api.onVisibilityChange((event) => {
4409
4486
  const { isVisible } = event;
4410
4487
  const { accessor } = this._params;
4411
4488
  accessor.setVisible(this, isVisible);
@@ -4434,7 +4511,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4434
4511
  height: event.height,
4435
4512
  width: event.width,
4436
4513
  });
4437
- }));
4514
+ }), this._onDidChange);
4438
4515
  }
4439
4516
  setVisible(isVisible) {
4440
4517
  this.api._onDidVisibilityChange.fire({ isVisible });
@@ -4591,7 +4668,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4591
4668
  this.addDisposables(this.disposable, this._onDidTitleChange, this._onDidGroupChange, this._onDidActiveGroupChange);
4592
4669
  }
4593
4670
  setTitle(title) {
4594
- this.panel.update({ params: { title } });
4671
+ this.panel.setTitle(title);
4595
4672
  }
4596
4673
  close() {
4597
4674
  this.group.model.closePanel(this.panel);
@@ -4613,7 +4690,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4613
4690
  this.id = id;
4614
4691
  this.containerApi = containerApi;
4615
4692
  this.view = view;
4616
- this._title = '';
4617
4693
  this._group = group;
4618
4694
  this.api = new DockviewPanelApiImpl(this, this._group);
4619
4695
  this.addDisposables(this.api.onActiveChange(() => {
@@ -4626,8 +4702,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4626
4702
  }
4627
4703
  init(params) {
4628
4704
  this._params = params.params;
4629
- this.setTitle(params.title);
4630
4705
  this.view.init(Object.assign(Object.assign({}, params), { api: this.api, containerApi: this.containerApi }));
4706
+ this.setTitle(params.title);
4631
4707
  }
4632
4708
  focus() {
4633
4709
  this.api._onFocusEvent.fire();
@@ -4644,11 +4720,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4644
4720
  };
4645
4721
  }
4646
4722
  setTitle(title) {
4647
- var _a, _b;
4648
- const didTitleChange = title !== ((_a = this._params) === null || _a === void 0 ? void 0 : _a.title);
4723
+ const didTitleChange = title !== this.title;
4649
4724
  if (didTitleChange) {
4650
4725
  this._title = title;
4651
- (_b = this.view) === null || _b === void 0 ? void 0 : _b.update({
4726
+ this.view.update({
4652
4727
  params: {
4653
4728
  params: this._params,
4654
4729
  title: this.title,
@@ -4658,14 +4733,19 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4658
4733
  }
4659
4734
  }
4660
4735
  update(event) {
4661
- var _a;
4662
- const params = event.params;
4663
- this._params = Object.assign(Object.assign({}, (this._params || {})), event.params.params);
4664
- if (params.title !== this.title) {
4665
- this._title = params.title;
4666
- this.api._onDidTitleChange.fire({ title: this.title });
4736
+ // merge the new parameters with the existing parameters
4737
+ this._params = Object.assign(Object.assign({}, (this._params || {})), event.params);
4738
+ /**
4739
+ * delete new keys that have a value of undefined,
4740
+ * allow values of null
4741
+ */
4742
+ for (const key of Object.keys(event.params)) {
4743
+ if (event.params[key] === undefined) {
4744
+ delete this._params[key];
4745
+ }
4667
4746
  }
4668
- (_a = this.view) === null || _a === void 0 ? void 0 : _a.update({
4747
+ // update the view with the updated props
4748
+ this.view.update({
4669
4749
  params: {
4670
4750
  params: this._params,
4671
4751
  title: this.title,
@@ -5040,7 +5120,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5040
5120
  size: { type: 'pixels', value: 20 },
5041
5121
  },
5042
5122
  });
5043
- this.addDisposables(dropTarget, dropTarget.onDrop((event) => {
5123
+ this.addDisposables(dropTarget.onDrop((event) => {
5044
5124
  const data = getPanelData();
5045
5125
  if (data) {
5046
5126
  this.moveGroupOrPanel(this.orthogonalize(event.position), data.groupId, data.panelId || undefined, 'center');
@@ -5048,7 +5128,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5048
5128
  else {
5049
5129
  this._onDidDrop.fire(Object.assign(Object.assign({}, event), { api: this._api, group: null, getData: getPanelData }));
5050
5130
  }
5051
- }));
5131
+ }), dropTarget);
5052
5132
  this._api = new DockviewApi(this);
5053
5133
  this.updateWatermark();
5054
5134
  }
@@ -5372,31 +5452,33 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5372
5452
  }
5373
5453
  super.doRemoveGroup(group, { skipActive });
5374
5454
  }
5375
- moveGroupOrPanel(referenceGroup, groupId, itemId, target, index) {
5455
+ moveGroupOrPanel(destinationGroup, sourceGroupId, sourceItemId, destinationTarget, destinationIndex) {
5376
5456
  var _a;
5377
- const sourceGroup = groupId
5378
- ? (_a = this._groups.get(groupId)) === null || _a === void 0 ? void 0 : _a.value
5457
+ const sourceGroup = sourceGroupId
5458
+ ? (_a = this._groups.get(sourceGroupId)) === null || _a === void 0 ? void 0 : _a.value
5379
5459
  : undefined;
5380
- if (itemId === undefined) {
5460
+ if (sourceItemId === undefined) {
5381
5461
  if (sourceGroup) {
5382
- this.moveGroup(sourceGroup, referenceGroup, target);
5462
+ this.moveGroup(sourceGroup, destinationGroup, destinationTarget);
5383
5463
  }
5384
5464
  return;
5385
5465
  }
5386
- if (!target || target === 'center') {
5387
- const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(itemId)) ||
5388
- this.panels.find((panel) => panel.id === itemId);
5466
+ if (!destinationTarget || destinationTarget === 'center') {
5467
+ const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(sourceItemId)) ||
5468
+ this.panels.find((panel) => panel.id === sourceItemId);
5389
5469
  if (!groupItem) {
5390
- throw new Error(`No panel with id ${itemId}`);
5470
+ throw new Error(`No panel with id ${sourceItemId}`);
5391
5471
  }
5392
5472
  if ((sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.size) === 0) {
5393
5473
  this.doRemoveGroup(sourceGroup);
5394
5474
  }
5395
- referenceGroup.model.openPanel(groupItem, { index });
5475
+ destinationGroup.model.openPanel(groupItem, {
5476
+ index: destinationIndex,
5477
+ });
5396
5478
  }
5397
5479
  else {
5398
- const referenceLocation = getGridLocation(referenceGroup.element);
5399
- const targetLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
5480
+ const referenceLocation = getGridLocation(destinationGroup.element);
5481
+ const targetLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
5400
5482
  if (sourceGroup && sourceGroup.size < 2) {
5401
5483
  const [targetParentLocation, to] = tail(targetLocation);
5402
5484
  const sourceLocation = getGridLocation(sourceGroup.element);
@@ -5414,18 +5496,18 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5414
5496
  skipDispose: true,
5415
5497
  });
5416
5498
  // after deleting the group we need to re-evaulate the ref location
5417
- const updatedReferenceLocation = getGridLocation(referenceGroup.element);
5418
- const location = getRelativeLocation(this.gridview.orientation, updatedReferenceLocation, target);
5499
+ const updatedReferenceLocation = getGridLocation(destinationGroup.element);
5500
+ const location = getRelativeLocation(this.gridview.orientation, updatedReferenceLocation, destinationTarget);
5419
5501
  this.doAddGroup(targetGroup, location);
5420
5502
  }
5421
5503
  }
5422
5504
  else {
5423
- const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(itemId)) ||
5424
- this.panels.find((panel) => panel.id === itemId);
5505
+ const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(sourceItemId)) ||
5506
+ this.panels.find((panel) => panel.id === sourceItemId);
5425
5507
  if (!groupItem) {
5426
- throw new Error(`No panel with id ${itemId}`);
5508
+ throw new Error(`No panel with id ${sourceItemId}`);
5427
5509
  }
5428
- const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
5510
+ const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
5429
5511
  const group = this.createGroupAtLocation(dropLocation);
5430
5512
  group.model.openPanel(groupItem);
5431
5513
  }
@@ -5519,11 +5601,11 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5519
5601
  return (_a = Array.from(this._groups.values()).find((group) => group.value.model.containsPanel(panel))) === null || _a === void 0 ? void 0 : _a.value;
5520
5602
  }
5521
5603
  dispose() {
5522
- super.dispose();
5523
5604
  this._onDidActivePanelChange.dispose();
5524
5605
  this._onDidAddPanel.dispose();
5525
5606
  this._onDidRemovePanel.dispose();
5526
5607
  this._onDidLayoutFromJSON.dispose();
5608
+ super.dispose();
5527
5609
  }
5528
5610
  }
5529
5611
 
@@ -5781,7 +5863,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5781
5863
  }
5782
5864
  set splitview(value) {
5783
5865
  this._splitview = value;
5784
- this._disposable.value = new CompositeDisposable(this._splitview.onDidSashEnd(() => {
5866
+ this._splitviewChangeDisposable.value = new CompositeDisposable(this._splitview.onDidSashEnd(() => {
5785
5867
  this._onDidLayoutChange.fire(undefined);
5786
5868
  }), this._splitview.onDidAddView((e) => this._onDidAddView.fire(e)), this._splitview.onDidRemoveView((e) => this._onDidRemoveView.fire(e)));
5787
5869
  }
@@ -5803,7 +5885,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5803
5885
  }
5804
5886
  constructor(options) {
5805
5887
  super(options.parentElement);
5806
- this._disposable = new MutableDisposable();
5888
+ this._splitviewChangeDisposable = new MutableDisposable();
5807
5889
  this._panels = new Map();
5808
5890
  this._onDidLayoutfromJSON = new Emitter();
5809
5891
  this.onDidLayoutFromJSON = this._onDidLayoutfromJSON.event;
@@ -5821,7 +5903,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5821
5903
  options.frameworkComponents = {};
5822
5904
  }
5823
5905
  this.splitview = new Splitview(this.element, options);
5824
- this.addDisposables(this._disposable, this._onDidAddView, this._onDidLayoutfromJSON, this._onDidRemoveView, this._onDidLayoutChange);
5906
+ this.addDisposables(this._onDidAddView, this._onDidLayoutfromJSON, this._onDidRemoveView, this._onDidLayoutChange);
5825
5907
  }
5826
5908
  updateOptions(options) {
5827
5909
  const hasOrientationChanged = typeof options.orientation === 'string' &&
@@ -5859,15 +5941,15 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5859
5941
  }
5860
5942
  }
5861
5943
  removePanel(panel, sizing) {
5862
- const disposable = this._panels.get(panel.id);
5863
- if (!disposable) {
5944
+ const item = this._panels.get(panel.id);
5945
+ if (!item) {
5864
5946
  throw new Error(`unknown splitview panel ${panel.id}`);
5865
5947
  }
5866
- disposable.disposable.dispose();
5867
- disposable.value.dispose();
5948
+ item.dispose();
5868
5949
  this._panels.delete(panel.id);
5869
5950
  const index = this.panels.findIndex((_) => _ === panel);
5870
- this.splitview.removeView(index, sizing);
5951
+ const removedView = this.splitview.removeView(index, sizing);
5952
+ removedView.dispose();
5871
5953
  const panels = this.panels;
5872
5954
  if (panels.length > 0) {
5873
5955
  this.setActive(panels[panels.length - 1]);
@@ -5914,7 +5996,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5914
5996
  }
5915
5997
  this.setActive(view, true);
5916
5998
  });
5917
- this._panels.set(view.id, { disposable, value: view });
5999
+ this._panels.set(view.id, disposable);
5918
6000
  }
5919
6001
  toJSON() {
5920
6002
  var _a;
@@ -5987,20 +6069,26 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5987
6069
  this._onDidLayoutfromJSON.fire();
5988
6070
  }
5989
6071
  clear() {
5990
- for (const [_, value] of this._panels.entries()) {
5991
- value.disposable.dispose();
5992
- value.value.dispose();
6072
+ for (const disposable of this._panels.values()) {
6073
+ disposable.dispose();
5993
6074
  }
5994
6075
  this._panels.clear();
5995
- this.splitview.dispose();
6076
+ while (this.splitview.length > 0) {
6077
+ const view = this.splitview.removeView(0, exports.Sizing.Distribute, true);
6078
+ view.dispose();
6079
+ }
5996
6080
  }
5997
6081
  dispose() {
5998
- for (const [_, value] of this._panels.entries()) {
5999
- value.disposable.dispose();
6000
- value.value.dispose();
6082
+ for (const disposable of this._panels.values()) {
6083
+ disposable.dispose();
6001
6084
  }
6002
6085
  this._panels.clear();
6086
+ const views = this.splitview.getViews();
6087
+ this._splitviewChangeDisposable.dispose();
6003
6088
  this.splitview.dispose();
6089
+ for (const view of views) {
6090
+ view.dispose();
6091
+ }
6004
6092
  super.dispose();
6005
6093
  }
6006
6094
  }