dockview 1.7.3 → 1.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview
3
- * @version 1.7.3
3
+ * @version 1.7.5
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -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,28 +204,50 @@ 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 {
186
249
  dispose: () => {
187
- element.removeEventListener(type, listener);
250
+ element.removeEventListener(type, listener, options);
188
251
  },
189
252
  };
190
253
  }
@@ -192,7 +255,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
192
255
  element.addEventListener(type, listener, options);
193
256
  return {
194
257
  dispose: () => {
195
- element.removeEventListener(type, listener);
258
+ element.removeEventListener(type, listener, options);
196
259
  },
197
260
  };
198
261
  }
@@ -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) {
@@ -957,12 +1019,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
957
1019
  this.saveProportions();
958
1020
  document.removeEventListener('mousemove', mousemove);
959
1021
  document.removeEventListener('mouseup', end);
960
- document.removeEventListener('mouseend', end);
961
1022
  this._onDidSashEnd.fire(undefined);
962
1023
  };
963
1024
  document.addEventListener('mousemove', mousemove);
964
1025
  document.addEventListener('mouseup', end);
965
- document.addEventListener('mouseend', end);
966
1026
  };
967
1027
  sash.addEventListener('mousedown', onStart);
968
1028
  const sashItem = {
@@ -988,7 +1048,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
988
1048
  distributeViewSizes() {
989
1049
  const flexibleViewItems = [];
990
1050
  let flexibleSize = 0;
991
- for (const item of this.views) {
1051
+ for (const item of this.viewItems) {
992
1052
  if (item.maximumSize - item.minimumSize > 0) {
993
1053
  flexibleViewItems.push(item);
994
1054
  flexibleSize += item.size;
@@ -998,17 +1058,17 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
998
1058
  for (const item of flexibleViewItems) {
999
1059
  item.size = clamp(size, item.minimumSize, item.maximumSize);
1000
1060
  }
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);
1061
+ const indexes = range(this.viewItems.length);
1062
+ const lowPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.Low);
1063
+ const highPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.High);
1004
1064
  this.relayout(lowPriorityIndexes, highPriorityIndexes);
1005
1065
  }
1006
1066
  removeView(index, sizing, skipLayout = false) {
1007
1067
  // Remove view
1008
- const viewItem = this.views.splice(index, 1)[0];
1068
+ const viewItem = this.viewItems.splice(index, 1)[0];
1009
1069
  viewItem.dispose();
1010
1070
  // Remove sash
1011
- if (this.views.length >= 1) {
1071
+ if (this.viewItems.length >= 1) {
1012
1072
  const sashIndex = Math.max(index - 1, 0);
1013
1073
  const sashItem = this.sashes.splice(sashIndex, 1)[0];
1014
1074
  sashItem.disposable();
@@ -1023,10 +1083,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1023
1083
  return viewItem.view;
1024
1084
  }
1025
1085
  getViewCachedVisibleSize(index) {
1026
- if (index < 0 || index >= this.views.length) {
1086
+ if (index < 0 || index >= this.viewItems.length) {
1027
1087
  throw new Error('Index out of bounds');
1028
1088
  }
1029
- const viewItem = this.views[index];
1089
+ const viewItem = this.viewItems[index];
1030
1090
  return viewItem.cachedVisibleSize;
1031
1091
  }
1032
1092
  moveView(from, to) {
@@ -1042,14 +1102,14 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1042
1102
  this.size = size;
1043
1103
  this.orthogonalSize = orthogonalSize;
1044
1104
  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);
1105
+ const indexes = range(this.viewItems.length);
1106
+ const lowPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.Low);
1107
+ const highPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.High);
1108
+ this.resize(this.viewItems.length - 1, size - previousSize, undefined, lowPriorityIndexes, highPriorityIndexes);
1049
1109
  }
1050
1110
  else {
1051
- for (let i = 0; i < this.views.length; i++) {
1052
- const item = this.views[i];
1111
+ for (let i = 0; i < this.viewItems.length; i++) {
1112
+ const item = this.viewItems[i];
1053
1113
  item.size = clamp(Math.round(this.proportions[i] * size), item.minimumSize, item.maximumSize);
1054
1114
  }
1055
1115
  }
@@ -1057,18 +1117,18 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1057
1117
  this.layoutViews();
1058
1118
  }
1059
1119
  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);
1120
+ const contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
1121
+ this.resize(this.viewItems.length - 1, this._size - contentSize, undefined, lowPriorityIndexes, highPriorityIndexes);
1062
1122
  this.distributeEmptySpace();
1063
1123
  this.layoutViews();
1064
1124
  this.saveProportions();
1065
1125
  }
1066
1126
  distributeEmptySpace(lowPriorityIndex) {
1067
- const contentSize = this.views.reduce((r, i) => r + i.size, 0);
1127
+ const contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
1068
1128
  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);
1129
+ const indexes = range(this.viewItems.length - 1, -1);
1130
+ const lowPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.Low);
1131
+ const highPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.High);
1072
1132
  for (const index of highPriorityIndexes) {
1073
1133
  pushToStart(indexes, index);
1074
1134
  }
@@ -1079,7 +1139,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1079
1139
  pushToEnd(indexes, lowPriorityIndex);
1080
1140
  }
1081
1141
  for (let i = 0; emptyDelta !== 0 && i < indexes.length; i++) {
1082
- const item = this.views[indexes[i]];
1142
+ const item = this.viewItems[indexes[i]];
1083
1143
  const size = clamp(item.size + emptyDelta, item.minimumSize, item.maximumSize);
1084
1144
  const viewDelta = size - item.size;
1085
1145
  emptyDelta -= viewDelta;
@@ -1088,16 +1148,16 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1088
1148
  }
1089
1149
  saveProportions() {
1090
1150
  if (this.proportionalLayout && this.contentSize > 0) {
1091
- this._proportions = this.views.map((i) => i.size / this.contentSize);
1151
+ this._proportions = this.viewItems.map((i) => i.size / this.contentSize);
1092
1152
  }
1093
1153
  }
1094
1154
  layoutViews() {
1095
- this.contentSize = this.views.reduce((r, i) => r + i.size, 0);
1155
+ this.contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
1096
1156
  let sum = 0;
1097
1157
  const x = [];
1098
1158
  this.updateSashEnablement();
1099
- for (let i = 0; i < this.views.length - 1; i++) {
1100
- sum += this.views[i].size;
1159
+ for (let i = 0; i < this.viewItems.length - 1; i++) {
1160
+ sum += this.viewItems[i].size;
1101
1161
  x.push(sum);
1102
1162
  const offset = Math.min(Math.max(0, sum - 2), this.size - 4);
1103
1163
  if (this._orientation === exports.Orientation.HORIZONTAL) {
@@ -1109,7 +1169,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1109
1169
  this.sashes[i].container.style.top = `${offset}px`;
1110
1170
  }
1111
1171
  }
1112
- this.views.forEach((view, i) => {
1172
+ this.viewItems.forEach((view, i) => {
1113
1173
  if (this._orientation === exports.Orientation.HORIZONTAL) {
1114
1174
  view.container.style.width = `${view.size}px`;
1115
1175
  view.container.style.left = i == 0 ? '0px' : `${x[i - 1]}px`;
@@ -1128,7 +1188,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1128
1188
  findFirstSnapIndex(indexes) {
1129
1189
  // visible views first
1130
1190
  for (const index of indexes) {
1131
- const viewItem = this.views[index];
1191
+ const viewItem = this.viewItems[index];
1132
1192
  if (!viewItem.visible) {
1133
1193
  continue;
1134
1194
  }
@@ -1138,7 +1198,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1138
1198
  }
1139
1199
  // then, hidden views
1140
1200
  for (const index of indexes) {
1141
- const viewItem = this.views[index];
1201
+ const viewItem = this.viewItems[index];
1142
1202
  if (viewItem.visible &&
1143
1203
  viewItem.maximumSize - viewItem.minimumSize > 0) {
1144
1204
  return undefined;
@@ -1151,10 +1211,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1151
1211
  }
1152
1212
  updateSashEnablement() {
1153
1213
  let previous = false;
1154
- const collapsesDown = this.views.map((i) => (previous = i.size - i.minimumSize > 0 || previous));
1214
+ const collapsesDown = this.viewItems.map((i) => (previous = i.size - i.minimumSize > 0 || previous));
1155
1215
  previous = false;
1156
- const expandsDown = this.views.map((i) => (previous = i.maximumSize - i.size > 0 || previous));
1157
- const reverseViews = [...this.views].reverse();
1216
+ const expandsDown = this.viewItems.map((i) => (previous = i.maximumSize - i.size > 0 || previous));
1217
+ const reverseViews = [...this.viewItems].reverse();
1158
1218
  previous = false;
1159
1219
  const collapsesUp = reverseViews
1160
1220
  .map((i) => (previous = i.size - i.minimumSize > 0 || previous))
@@ -1166,19 +1226,19 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1166
1226
  let position = 0;
1167
1227
  for (let index = 0; index < this.sashes.length; index++) {
1168
1228
  const sash = this.sashes[index];
1169
- const viewItem = this.views[index];
1229
+ const viewItem = this.viewItems[index];
1170
1230
  position += viewItem.size;
1171
1231
  const min = !(collapsesDown[index] && expandsUp[index + 1]);
1172
1232
  const max = !(expandsDown[index] && collapsesUp[index + 1]);
1173
1233
  if (min && max) {
1174
1234
  const upIndexes = range(index, -1);
1175
- const downIndexes = range(index + 1, this.views.length);
1235
+ const downIndexes = range(index + 1, this.viewItems.length);
1176
1236
  const snapBeforeIndex = this.findFirstSnapIndex(upIndexes);
1177
1237
  const snapAfterIndex = this.findFirstSnapIndex(downIndexes);
1178
1238
  const snappedBefore = typeof snapBeforeIndex === 'number' &&
1179
- !this.views[snapBeforeIndex].visible;
1239
+ !this.viewItems[snapBeforeIndex].visible;
1180
1240
  const snappedAfter = typeof snapAfterIndex === 'number' &&
1181
- !this.views[snapAfterIndex].visible;
1241
+ !this.viewItems[snapAfterIndex].visible;
1182
1242
  if (snappedBefore &&
1183
1243
  collapsesUp[index] &&
1184
1244
  (position > 0 || this.startSnappingEnabled)) {
@@ -1238,6 +1298,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1238
1298
  break;
1239
1299
  }
1240
1300
  }
1301
+ for (const viewItem of this.viewItems) {
1302
+ viewItem.dispose();
1303
+ }
1241
1304
  this.element.remove();
1242
1305
  }
1243
1306
  }
@@ -1672,7 +1735,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1672
1735
  throw new Error('Invalid index');
1673
1736
  }
1674
1737
  this.splitview.removeView(index, sizing);
1675
- this._removeChild(index);
1738
+ return this._removeChild(index);
1676
1739
  }
1677
1740
  _addChild(node, index) {
1678
1741
  this.children.splice(index, 0, node);
@@ -1694,10 +1757,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1694
1757
  });
1695
1758
  }
1696
1759
  dispose() {
1697
- super.dispose();
1698
1760
  this._childrenDisposable.dispose();
1699
- this.children.forEach((child) => child.dispose());
1700
1761
  this.splitview.dispose();
1762
+ this.children.forEach((child) => child.dispose());
1763
+ super.dispose();
1701
1764
  }
1702
1765
  }
1703
1766
 
@@ -1927,7 +1990,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1927
1990
  if (oldRoot.children.length === 1) {
1928
1991
  // can remove one level of redundant branching if there is only a single child
1929
1992
  const childReference = oldRoot.children[0];
1930
- oldRoot.removeChild(0); // remove to prevent disposal when disposing of unwanted root
1993
+ const child = oldRoot.removeChild(0); // remove to prevent disposal when disposing of unwanted root
1994
+ child.dispose();
1931
1995
  oldRoot.dispose();
1932
1996
  this._root.addChild(
1933
1997
  /**
@@ -2034,7 +2098,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2034
2098
  if (typeof newSiblingCachedVisibleSize === 'number') {
2035
2099
  newSiblingSize = exports.Sizing.Invisible(newSiblingCachedVisibleSize);
2036
2100
  }
2037
- grandParent.removeChild(parentIndex);
2101
+ const child = grandParent.removeChild(parentIndex);
2102
+ child.dispose();
2038
2103
  const newParent = new BranchNode(parent.orientation, this.proportionalLayout, this.styles, parent.size, parent.orthogonalSize);
2039
2104
  grandParent.addChild(newParent, parent.size, parentIndex);
2040
2105
  const newSibling = new LeafNode(parent.view, grandParent.orientation, parent.size);
@@ -2596,6 +2661,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2596
2661
  }
2597
2662
  dispose() {
2598
2663
  this.removeDropTarget();
2664
+ super.dispose();
2599
2665
  }
2600
2666
  toggleClasses(quadrant, width, height) {
2601
2667
  var _a, _b, _c, _d;
@@ -2773,8 +2839,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2773
2839
  if (this.panel.view) {
2774
2840
  const _onDidFocus = this.panel.view.content.onDidFocus;
2775
2841
  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()));
2842
+ const focusTracker = trackFocus(this._element);
2843
+ disposable.addDisposables(focusTracker, focusTracker.onDidFocus(() => this._onDidFocus.fire()), focusTracker.onDidBlur(() => this._onDidBlur.fire()));
2778
2844
  if (_onDidFocus) {
2779
2845
  disposable.addDisposables(_onDidFocus(() => this._onDidFocus.fire()));
2780
2846
  }
@@ -2813,24 +2879,32 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2813
2879
  constructor(el) {
2814
2880
  super();
2815
2881
  this.el = el;
2816
- this.disposable = new MutableDisposable();
2882
+ this.dataDisposable = new MutableDisposable();
2883
+ this.pointerEventsDisposable = new MutableDisposable();
2817
2884
  this._onDragStart = new Emitter();
2818
2885
  this.onDragStart = this._onDragStart.event;
2819
- this.iframes = [];
2886
+ this.addDisposables(this._onDragStart, this.dataDisposable, this.pointerEventsDisposable);
2820
2887
  this.configure();
2821
2888
  }
2822
2889
  configure() {
2823
2890
  this.addDisposables(this._onDragStart, addDisposableListener(this.el, 'dragstart', (event) => {
2824
- this.iframes = [
2891
+ const iframes = [
2825
2892
  ...getElementsByTagName('iframe'),
2826
2893
  ...getElementsByTagName('webview'),
2827
2894
  ];
2828
- for (const iframe of this.iframes) {
2895
+ this.pointerEventsDisposable.value = {
2896
+ dispose: () => {
2897
+ for (const iframe of iframes) {
2898
+ iframe.style.pointerEvents = 'auto';
2899
+ }
2900
+ },
2901
+ };
2902
+ for (const iframe of iframes) {
2829
2903
  iframe.style.pointerEvents = 'none';
2830
2904
  }
2831
2905
  this.el.classList.add('dv-dragged');
2832
2906
  setTimeout(() => this.el.classList.remove('dv-dragged'), 0);
2833
- this.disposable.value = this.getData(event.dataTransfer);
2907
+ this.dataDisposable.value = this.getData(event.dataTransfer);
2834
2908
  if (event.dataTransfer) {
2835
2909
  event.dataTransfer.effectAllowed = 'move';
2836
2910
  /**
@@ -2845,11 +2919,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2845
2919
  event.dataTransfer.setData('text/plain', '__dockview_internal_drag_event__');
2846
2920
  }
2847
2921
  }), addDisposableListener(this.el, 'dragend', () => {
2848
- for (const iframe of this.iframes) {
2849
- iframe.style.pointerEvents = 'auto';
2850
- }
2851
- this.iframes = [];
2852
- this.disposable.dispose();
2922
+ this.pointerEventsDisposable.dispose();
2923
+ this.dataDisposable.dispose();
2853
2924
  }));
2854
2925
  }
2855
2926
  }
@@ -2867,13 +2938,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2867
2938
  this.onChanged = this._onChanged.event;
2868
2939
  this._onDropped = new Emitter();
2869
2940
  this.onDrop = this._onDropped.event;
2870
- this.addDisposables(this._onChanged, this._onDropped);
2871
2941
  this._element = document.createElement('div');
2872
2942
  this._element.className = 'tab';
2873
2943
  this._element.tabIndex = 0;
2874
2944
  this._element.draggable = true;
2875
2945
  toggleClass(this.element, 'inactive-tab', true);
2876
- this.addDisposables(new (class Handler extends DragHandler {
2946
+ this.addDisposables(this._onChanged, this._onDropped, new (class Handler extends DragHandler {
2877
2947
  constructor() {
2878
2948
  super(...arguments);
2879
2949
  this.panelTransfer = LocalSelectionTransfer.getInstance();
@@ -2886,9 +2956,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2886
2956
  },
2887
2957
  };
2888
2958
  }
2889
- dispose() {
2890
- //
2891
- }
2892
2959
  })(this._element));
2893
2960
  this.addDisposables(addDisposableListener(this._element, 'mousedown', (event) => {
2894
2961
  if (event.defaultPrevented) {
@@ -2923,7 +2990,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2923
2990
  });
2924
2991
  this.addDisposables(this.droptarget.onDrop((event) => {
2925
2992
  this._onDropped.fire(event);
2926
- }));
2993
+ }), this.droptarget);
2927
2994
  }
2928
2995
  setActive(isActive) {
2929
2996
  toggleClass(this.element, 'active-tab', isActive);
@@ -2938,7 +3005,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2938
3005
  }
2939
3006
  dispose() {
2940
3007
  super.dispose();
2941
- this.droptarget.dispose();
2942
3008
  }
2943
3009
  }
2944
3010
 
@@ -2984,9 +3050,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2984
3050
  },
2985
3051
  };
2986
3052
  }
2987
- dispose() {
2988
- //
2989
- }
2990
3053
  }
2991
3054
 
2992
3055
  class VoidContainer extends CompositeDisposable {
@@ -3142,6 +3205,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3142
3205
  const tabToRemove = this.tabs.splice(index, 1)[0];
3143
3206
  const { value, disposable } = tabToRemove;
3144
3207
  disposable.dispose();
3208
+ value.dispose();
3145
3209
  value.element.remove();
3146
3210
  }
3147
3211
  setActivePanel(panel) {
@@ -3185,9 +3249,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3185
3249
  }
3186
3250
  dispose() {
3187
3251
  super.dispose();
3188
- this.tabs.forEach((tab) => {
3189
- tab.disposable.dispose();
3190
- });
3252
+ for (const { value, disposable } of this.tabs) {
3253
+ disposable.dispose();
3254
+ value.dispose();
3255
+ }
3191
3256
  this.tabs = [];
3192
3257
  }
3193
3258
  }
@@ -3285,7 +3350,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3285
3350
  container.append(this.tabsContainer.element, this.contentContainer.element);
3286
3351
  this.header.hidden = !!options.hideHeader;
3287
3352
  this.locked = !!options.locked;
3288
- this.addDisposables(this._onMove, this._onDidChange, this._onDidDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange, this.tabsContainer.onDrop((event) => {
3353
+ this.addDisposables(this.tabsContainer.onDrop((event) => {
3289
3354
  this.handleDropEvent(event.event, 'center', event.index);
3290
3355
  }), this.contentContainer.onDidFocus(() => {
3291
3356
  this.accessor.doSetGroupActive(this.groupPanel, true);
@@ -3293,7 +3358,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3293
3358
  // noop
3294
3359
  }), this.dropTarget.onDrop((event) => {
3295
3360
  this.handleDropEvent(event.nativeEvent, event.position);
3296
- }));
3361
+ }), this._onMove, this._onDidChange, this._onDidDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange);
3297
3362
  }
3298
3363
  initialize() {
3299
3364
  var _a, _b;
@@ -3727,8 +3792,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3727
3792
  this.layout(0, 0, true); // set some elements height/widths
3728
3793
  this.addDisposables(this.gridview.onDidChange(() => {
3729
3794
  this._bufferOnDidLayoutChange.fire();
3730
- }));
3731
- this.addDisposables(exports.DockviewEvent.any(this.onDidAddGroup, this.onDidRemoveGroup, this.onDidActiveGroupChange)(() => {
3795
+ }), exports.DockviewEvent.any(this.onDidAddGroup, this.onDidRemoveGroup, this.onDidActiveGroupChange)(() => {
3732
3796
  this._bufferOnDidLayoutChange.fire();
3733
3797
  }), this._bufferOnDidLayoutChange.onEvent(() => {
3734
3798
  this._onDidLayoutChange.fire();
@@ -3831,7 +3895,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3831
3895
  this.gridview.layout(width, height);
3832
3896
  }
3833
3897
  dispose() {
3834
- super.dispose();
3835
3898
  this._onDidActiveGroupChange.dispose();
3836
3899
  this._onDidAddGroup.dispose();
3837
3900
  this._onDidRemoveGroup.dispose();
@@ -3840,6 +3903,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3840
3903
  group.dispose();
3841
3904
  }
3842
3905
  this.gridview.dispose();
3906
+ super.dispose();
3843
3907
  }
3844
3908
  }
3845
3909
 
@@ -3903,7 +3967,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3903
3967
  //
3904
3968
  this._onUpdateParameters = new Emitter();
3905
3969
  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) => {
3970
+ this.addDisposables(this.onDidFocusChange((event) => {
3907
3971
  this._isFocused = event.isFocused;
3908
3972
  }), this.onDidActiveChange((event) => {
3909
3973
  this._isActive = event.isActive;
@@ -3912,14 +3976,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3912
3976
  }), this.onDidDimensionsChange((event) => {
3913
3977
  this._width = event.width;
3914
3978
  this._height = event.height;
3915
- }));
3979
+ }), this.panelUpdatesDisposable, this._onDidDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onFocusEvent, this._onActiveChange, this._onVisibilityChange, this._onUpdateParameters);
3916
3980
  }
3917
3981
  initialize(panel) {
3918
3982
  this.panelUpdatesDisposable.value = this._onUpdateParameters.event((parameters) => {
3919
3983
  panel.update({
3920
- params: {
3921
- params: parameters,
3922
- },
3984
+ params: parameters,
3923
3985
  });
3924
3986
  });
3925
3987
  }
@@ -4014,12 +4076,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4014
4076
  this._element.style.height = '100%';
4015
4077
  this._element.style.width = '100%';
4016
4078
  this._element.style.overflow = 'hidden';
4017
- const { onDidFocus, onDidBlur } = trackFocus(this._element);
4018
- this.addDisposables(this.api, onDidFocus(() => {
4079
+ const focusTracker = trackFocus(this._element);
4080
+ this.addDisposables(this.api, focusTracker.onDidFocus(() => {
4019
4081
  this.api._onDidChangeFocus.fire({ isFocused: true });
4020
- }), onDidBlur(() => {
4082
+ }), focusTracker.onDidBlur(() => {
4021
4083
  this.api._onDidChangeFocus.fire({ isFocused: false });
4022
- }));
4084
+ }), focusTracker);
4023
4085
  }
4024
4086
  focus() {
4025
4087
  this.api._onFocusEvent.fire();
@@ -4040,7 +4102,18 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4040
4102
  }
4041
4103
  update(event) {
4042
4104
  var _a, _b;
4105
+ // merge the new parameters with the existing parameters
4043
4106
  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) });
4107
+ /**
4108
+ * delete new keys that have a value of undefined,
4109
+ * allow values of null
4110
+ */
4111
+ for (const key of Object.keys(event.params)) {
4112
+ if (event.params[key] === undefined) {
4113
+ delete this._params.params[key];
4114
+ }
4115
+ }
4116
+ // update the view with the updated props
4044
4117
  (_b = this.part) === null || _b === void 0 ? void 0 : _b.update({ params: this._params.params });
4045
4118
  }
4046
4119
  toJSON() {
@@ -4054,9 +4127,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4054
4127
  }
4055
4128
  dispose() {
4056
4129
  var _a;
4057
- super.dispose();
4058
4130
  this.api.dispose();
4059
4131
  (_a = this.part) === null || _a === void 0 ? void 0 : _a.dispose();
4132
+ super.dispose();
4060
4133
  }
4061
4134
  }
4062
4135
 
@@ -4435,7 +4508,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4435
4508
  this._maximumHeight = options.maximumHeight;
4436
4509
  }
4437
4510
  this.api.initialize(this); // TODO: required to by-pass 'super before this' requirement
4438
- this.addDisposables(this._onDidChange, this.api.onVisibilityChange((event) => {
4511
+ this.addDisposables(this.api.onVisibilityChange((event) => {
4439
4512
  const { isVisible } = event;
4440
4513
  const { accessor } = this._params;
4441
4514
  accessor.setVisible(this, isVisible);
@@ -4464,7 +4537,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4464
4537
  height: event.height,
4465
4538
  width: event.width,
4466
4539
  });
4467
- }));
4540
+ }), this._onDidChange);
4468
4541
  }
4469
4542
  setVisible(isVisible) {
4470
4543
  this.api._onDidVisibilityChange.fire({ isVisible });
@@ -4621,7 +4694,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4621
4694
  this.addDisposables(this.disposable, this._onDidTitleChange, this._onDidGroupChange, this._onDidActiveGroupChange);
4622
4695
  }
4623
4696
  setTitle(title) {
4624
- this.panel.update({ params: { title } });
4697
+ this.panel.setTitle(title);
4625
4698
  }
4626
4699
  close() {
4627
4700
  this.group.model.closePanel(this.panel);
@@ -4686,12 +4759,18 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4686
4759
  }
4687
4760
  }
4688
4761
  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 });
4762
+ // merge the new parameters with the existing parameters
4763
+ this._params = Object.assign(Object.assign({}, (this._params || {})), event.params);
4764
+ /**
4765
+ * delete new keys that have a value of undefined,
4766
+ * allow values of null
4767
+ */
4768
+ for (const key of Object.keys(event.params)) {
4769
+ if (event.params[key] === undefined) {
4770
+ delete this._params[key];
4771
+ }
4694
4772
  }
4773
+ // update the view with the updated props
4695
4774
  this.view.update({
4696
4775
  params: {
4697
4776
  params: this._params,
@@ -5067,7 +5146,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5067
5146
  size: { type: 'pixels', value: 20 },
5068
5147
  },
5069
5148
  });
5070
- this.addDisposables(dropTarget, dropTarget.onDrop((event) => {
5149
+ this.addDisposables(dropTarget.onDrop((event) => {
5071
5150
  const data = getPanelData();
5072
5151
  if (data) {
5073
5152
  this.moveGroupOrPanel(this.orthogonalize(event.position), data.groupId, data.panelId || undefined, 'center');
@@ -5075,7 +5154,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5075
5154
  else {
5076
5155
  this._onDidDrop.fire(Object.assign(Object.assign({}, event), { api: this._api, group: null, getData: getPanelData }));
5077
5156
  }
5078
- }));
5157
+ }), dropTarget);
5079
5158
  this._api = new DockviewApi(this);
5080
5159
  this.updateWatermark();
5081
5160
  }
@@ -5399,31 +5478,33 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5399
5478
  }
5400
5479
  super.doRemoveGroup(group, { skipActive });
5401
5480
  }
5402
- moveGroupOrPanel(referenceGroup, groupId, itemId, target, index) {
5481
+ moveGroupOrPanel(destinationGroup, sourceGroupId, sourceItemId, destinationTarget, destinationIndex) {
5403
5482
  var _a;
5404
- const sourceGroup = groupId
5405
- ? (_a = this._groups.get(groupId)) === null || _a === void 0 ? void 0 : _a.value
5483
+ const sourceGroup = sourceGroupId
5484
+ ? (_a = this._groups.get(sourceGroupId)) === null || _a === void 0 ? void 0 : _a.value
5406
5485
  : undefined;
5407
- if (itemId === undefined) {
5486
+ if (sourceItemId === undefined) {
5408
5487
  if (sourceGroup) {
5409
- this.moveGroup(sourceGroup, referenceGroup, target);
5488
+ this.moveGroup(sourceGroup, destinationGroup, destinationTarget);
5410
5489
  }
5411
5490
  return;
5412
5491
  }
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);
5492
+ if (!destinationTarget || destinationTarget === 'center') {
5493
+ const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(sourceItemId)) ||
5494
+ this.panels.find((panel) => panel.id === sourceItemId);
5416
5495
  if (!groupItem) {
5417
- throw new Error(`No panel with id ${itemId}`);
5496
+ throw new Error(`No panel with id ${sourceItemId}`);
5418
5497
  }
5419
5498
  if ((sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.size) === 0) {
5420
5499
  this.doRemoveGroup(sourceGroup);
5421
5500
  }
5422
- referenceGroup.model.openPanel(groupItem, { index });
5501
+ destinationGroup.model.openPanel(groupItem, {
5502
+ index: destinationIndex,
5503
+ });
5423
5504
  }
5424
5505
  else {
5425
- const referenceLocation = getGridLocation(referenceGroup.element);
5426
- const targetLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
5506
+ const referenceLocation = getGridLocation(destinationGroup.element);
5507
+ const targetLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
5427
5508
  if (sourceGroup && sourceGroup.size < 2) {
5428
5509
  const [targetParentLocation, to] = tail(targetLocation);
5429
5510
  const sourceLocation = getGridLocation(sourceGroup.element);
@@ -5441,18 +5522,18 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5441
5522
  skipDispose: true,
5442
5523
  });
5443
5524
  // 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);
5525
+ const updatedReferenceLocation = getGridLocation(destinationGroup.element);
5526
+ const location = getRelativeLocation(this.gridview.orientation, updatedReferenceLocation, destinationTarget);
5446
5527
  this.doAddGroup(targetGroup, location);
5447
5528
  }
5448
5529
  }
5449
5530
  else {
5450
- const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(itemId)) ||
5451
- this.panels.find((panel) => panel.id === itemId);
5531
+ const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(sourceItemId)) ||
5532
+ this.panels.find((panel) => panel.id === sourceItemId);
5452
5533
  if (!groupItem) {
5453
- throw new Error(`No panel with id ${itemId}`);
5534
+ throw new Error(`No panel with id ${sourceItemId}`);
5454
5535
  }
5455
- const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
5536
+ const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
5456
5537
  const group = this.createGroupAtLocation(dropLocation);
5457
5538
  group.model.openPanel(groupItem);
5458
5539
  }
@@ -5546,11 +5627,11 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5546
5627
  return (_a = Array.from(this._groups.values()).find((group) => group.value.model.containsPanel(panel))) === null || _a === void 0 ? void 0 : _a.value;
5547
5628
  }
5548
5629
  dispose() {
5549
- super.dispose();
5550
5630
  this._onDidActivePanelChange.dispose();
5551
5631
  this._onDidAddPanel.dispose();
5552
5632
  this._onDidRemovePanel.dispose();
5553
5633
  this._onDidLayoutFromJSON.dispose();
5634
+ super.dispose();
5554
5635
  }
5555
5636
  }
5556
5637
 
@@ -5808,7 +5889,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5808
5889
  }
5809
5890
  set splitview(value) {
5810
5891
  this._splitview = value;
5811
- this._disposable.value = new CompositeDisposable(this._splitview.onDidSashEnd(() => {
5892
+ this._splitviewChangeDisposable.value = new CompositeDisposable(this._splitview.onDidSashEnd(() => {
5812
5893
  this._onDidLayoutChange.fire(undefined);
5813
5894
  }), this._splitview.onDidAddView((e) => this._onDidAddView.fire(e)), this._splitview.onDidRemoveView((e) => this._onDidRemoveView.fire(e)));
5814
5895
  }
@@ -5830,7 +5911,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5830
5911
  }
5831
5912
  constructor(options) {
5832
5913
  super(options.parentElement);
5833
- this._disposable = new MutableDisposable();
5914
+ this._splitviewChangeDisposable = new MutableDisposable();
5834
5915
  this._panels = new Map();
5835
5916
  this._onDidLayoutfromJSON = new Emitter();
5836
5917
  this.onDidLayoutFromJSON = this._onDidLayoutfromJSON.event;
@@ -5848,7 +5929,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5848
5929
  options.frameworkComponents = {};
5849
5930
  }
5850
5931
  this.splitview = new Splitview(this.element, options);
5851
- this.addDisposables(this._disposable, this._onDidAddView, this._onDidLayoutfromJSON, this._onDidRemoveView, this._onDidLayoutChange);
5932
+ this.addDisposables(this._onDidAddView, this._onDidLayoutfromJSON, this._onDidRemoveView, this._onDidLayoutChange);
5852
5933
  }
5853
5934
  updateOptions(options) {
5854
5935
  const hasOrientationChanged = typeof options.orientation === 'string' &&
@@ -5886,15 +5967,15 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5886
5967
  }
5887
5968
  }
5888
5969
  removePanel(panel, sizing) {
5889
- const disposable = this._panels.get(panel.id);
5890
- if (!disposable) {
5970
+ const item = this._panels.get(panel.id);
5971
+ if (!item) {
5891
5972
  throw new Error(`unknown splitview panel ${panel.id}`);
5892
5973
  }
5893
- disposable.disposable.dispose();
5894
- disposable.value.dispose();
5974
+ item.dispose();
5895
5975
  this._panels.delete(panel.id);
5896
5976
  const index = this.panels.findIndex((_) => _ === panel);
5897
- this.splitview.removeView(index, sizing);
5977
+ const removedView = this.splitview.removeView(index, sizing);
5978
+ removedView.dispose();
5898
5979
  const panels = this.panels;
5899
5980
  if (panels.length > 0) {
5900
5981
  this.setActive(panels[panels.length - 1]);
@@ -5941,7 +6022,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5941
6022
  }
5942
6023
  this.setActive(view, true);
5943
6024
  });
5944
- this._panels.set(view.id, { disposable, value: view });
6025
+ this._panels.set(view.id, disposable);
5945
6026
  }
5946
6027
  toJSON() {
5947
6028
  var _a;
@@ -6014,20 +6095,26 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6014
6095
  this._onDidLayoutfromJSON.fire();
6015
6096
  }
6016
6097
  clear() {
6017
- for (const [_, value] of this._panels.entries()) {
6018
- value.disposable.dispose();
6019
- value.value.dispose();
6098
+ for (const disposable of this._panels.values()) {
6099
+ disposable.dispose();
6020
6100
  }
6021
6101
  this._panels.clear();
6022
- this.splitview.dispose();
6102
+ while (this.splitview.length > 0) {
6103
+ const view = this.splitview.removeView(0, exports.Sizing.Distribute, true);
6104
+ view.dispose();
6105
+ }
6023
6106
  }
6024
6107
  dispose() {
6025
- for (const [_, value] of this._panels.entries()) {
6026
- value.disposable.dispose();
6027
- value.value.dispose();
6108
+ for (const disposable of this._panels.values()) {
6109
+ disposable.dispose();
6028
6110
  }
6029
6111
  this._panels.clear();
6112
+ const views = this.splitview.getViews();
6113
+ this._splitviewChangeDisposable.dispose();
6030
6114
  this.splitview.dispose();
6115
+ for (const view of views) {
6116
+ view.dispose();
6117
+ }
6031
6118
  super.dispose();
6032
6119
  }
6033
6120
  }