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
  */
@@ -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,28 +174,50 @@ 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 {
156
219
  dispose: () => {
157
- element.removeEventListener(type, listener);
220
+ element.removeEventListener(type, listener, options);
158
221
  },
159
222
  };
160
223
  }
@@ -162,7 +225,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
162
225
  element.addEventListener(type, listener, options);
163
226
  return {
164
227
  dispose: () => {
165
- element.removeEventListener(type, listener);
228
+ element.removeEventListener(type, listener, options);
166
229
  },
167
230
  };
168
231
  }
@@ -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) {
@@ -927,12 +989,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
927
989
  this.saveProportions();
928
990
  document.removeEventListener('mousemove', mousemove);
929
991
  document.removeEventListener('mouseup', end);
930
- document.removeEventListener('mouseend', end);
931
992
  this._onDidSashEnd.fire(undefined);
932
993
  };
933
994
  document.addEventListener('mousemove', mousemove);
934
995
  document.addEventListener('mouseup', end);
935
- document.addEventListener('mouseend', end);
936
996
  };
937
997
  sash.addEventListener('mousedown', onStart);
938
998
  const sashItem = {
@@ -958,7 +1018,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
958
1018
  distributeViewSizes() {
959
1019
  const flexibleViewItems = [];
960
1020
  let flexibleSize = 0;
961
- for (const item of this.views) {
1021
+ for (const item of this.viewItems) {
962
1022
  if (item.maximumSize - item.minimumSize > 0) {
963
1023
  flexibleViewItems.push(item);
964
1024
  flexibleSize += item.size;
@@ -968,17 +1028,17 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
968
1028
  for (const item of flexibleViewItems) {
969
1029
  item.size = clamp(size, item.minimumSize, item.maximumSize);
970
1030
  }
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);
1031
+ const indexes = range(this.viewItems.length);
1032
+ const lowPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.Low);
1033
+ const highPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.High);
974
1034
  this.relayout(lowPriorityIndexes, highPriorityIndexes);
975
1035
  }
976
1036
  removeView(index, sizing, skipLayout = false) {
977
1037
  // Remove view
978
- const viewItem = this.views.splice(index, 1)[0];
1038
+ const viewItem = this.viewItems.splice(index, 1)[0];
979
1039
  viewItem.dispose();
980
1040
  // Remove sash
981
- if (this.views.length >= 1) {
1041
+ if (this.viewItems.length >= 1) {
982
1042
  const sashIndex = Math.max(index - 1, 0);
983
1043
  const sashItem = this.sashes.splice(sashIndex, 1)[0];
984
1044
  sashItem.disposable();
@@ -993,10 +1053,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
993
1053
  return viewItem.view;
994
1054
  }
995
1055
  getViewCachedVisibleSize(index) {
996
- if (index < 0 || index >= this.views.length) {
1056
+ if (index < 0 || index >= this.viewItems.length) {
997
1057
  throw new Error('Index out of bounds');
998
1058
  }
999
- const viewItem = this.views[index];
1059
+ const viewItem = this.viewItems[index];
1000
1060
  return viewItem.cachedVisibleSize;
1001
1061
  }
1002
1062
  moveView(from, to) {
@@ -1012,14 +1072,14 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1012
1072
  this.size = size;
1013
1073
  this.orthogonalSize = orthogonalSize;
1014
1074
  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);
1075
+ const indexes = range(this.viewItems.length);
1076
+ const lowPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.Low);
1077
+ const highPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.High);
1078
+ this.resize(this.viewItems.length - 1, size - previousSize, undefined, lowPriorityIndexes, highPriorityIndexes);
1019
1079
  }
1020
1080
  else {
1021
- for (let i = 0; i < this.views.length; i++) {
1022
- const item = this.views[i];
1081
+ for (let i = 0; i < this.viewItems.length; i++) {
1082
+ const item = this.viewItems[i];
1023
1083
  item.size = clamp(Math.round(this.proportions[i] * size), item.minimumSize, item.maximumSize);
1024
1084
  }
1025
1085
  }
@@ -1027,18 +1087,18 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1027
1087
  this.layoutViews();
1028
1088
  }
1029
1089
  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);
1090
+ const contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
1091
+ this.resize(this.viewItems.length - 1, this._size - contentSize, undefined, lowPriorityIndexes, highPriorityIndexes);
1032
1092
  this.distributeEmptySpace();
1033
1093
  this.layoutViews();
1034
1094
  this.saveProportions();
1035
1095
  }
1036
1096
  distributeEmptySpace(lowPriorityIndex) {
1037
- const contentSize = this.views.reduce((r, i) => r + i.size, 0);
1097
+ const contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
1038
1098
  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);
1099
+ const indexes = range(this.viewItems.length - 1, -1);
1100
+ const lowPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.Low);
1101
+ const highPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.High);
1042
1102
  for (const index of highPriorityIndexes) {
1043
1103
  pushToStart(indexes, index);
1044
1104
  }
@@ -1049,7 +1109,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1049
1109
  pushToEnd(indexes, lowPriorityIndex);
1050
1110
  }
1051
1111
  for (let i = 0; emptyDelta !== 0 && i < indexes.length; i++) {
1052
- const item = this.views[indexes[i]];
1112
+ const item = this.viewItems[indexes[i]];
1053
1113
  const size = clamp(item.size + emptyDelta, item.minimumSize, item.maximumSize);
1054
1114
  const viewDelta = size - item.size;
1055
1115
  emptyDelta -= viewDelta;
@@ -1058,16 +1118,16 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1058
1118
  }
1059
1119
  saveProportions() {
1060
1120
  if (this.proportionalLayout && this.contentSize > 0) {
1061
- this._proportions = this.views.map((i) => i.size / this.contentSize);
1121
+ this._proportions = this.viewItems.map((i) => i.size / this.contentSize);
1062
1122
  }
1063
1123
  }
1064
1124
  layoutViews() {
1065
- this.contentSize = this.views.reduce((r, i) => r + i.size, 0);
1125
+ this.contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
1066
1126
  let sum = 0;
1067
1127
  const x = [];
1068
1128
  this.updateSashEnablement();
1069
- for (let i = 0; i < this.views.length - 1; i++) {
1070
- sum += this.views[i].size;
1129
+ for (let i = 0; i < this.viewItems.length - 1; i++) {
1130
+ sum += this.viewItems[i].size;
1071
1131
  x.push(sum);
1072
1132
  const offset = Math.min(Math.max(0, sum - 2), this.size - 4);
1073
1133
  if (this._orientation === exports.Orientation.HORIZONTAL) {
@@ -1079,7 +1139,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1079
1139
  this.sashes[i].container.style.top = `${offset}px`;
1080
1140
  }
1081
1141
  }
1082
- this.views.forEach((view, i) => {
1142
+ this.viewItems.forEach((view, i) => {
1083
1143
  if (this._orientation === exports.Orientation.HORIZONTAL) {
1084
1144
  view.container.style.width = `${view.size}px`;
1085
1145
  view.container.style.left = i == 0 ? '0px' : `${x[i - 1]}px`;
@@ -1098,7 +1158,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1098
1158
  findFirstSnapIndex(indexes) {
1099
1159
  // visible views first
1100
1160
  for (const index of indexes) {
1101
- const viewItem = this.views[index];
1161
+ const viewItem = this.viewItems[index];
1102
1162
  if (!viewItem.visible) {
1103
1163
  continue;
1104
1164
  }
@@ -1108,7 +1168,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1108
1168
  }
1109
1169
  // then, hidden views
1110
1170
  for (const index of indexes) {
1111
- const viewItem = this.views[index];
1171
+ const viewItem = this.viewItems[index];
1112
1172
  if (viewItem.visible &&
1113
1173
  viewItem.maximumSize - viewItem.minimumSize > 0) {
1114
1174
  return undefined;
@@ -1121,10 +1181,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1121
1181
  }
1122
1182
  updateSashEnablement() {
1123
1183
  let previous = false;
1124
- const collapsesDown = this.views.map((i) => (previous = i.size - i.minimumSize > 0 || previous));
1184
+ const collapsesDown = this.viewItems.map((i) => (previous = i.size - i.minimumSize > 0 || previous));
1125
1185
  previous = false;
1126
- const expandsDown = this.views.map((i) => (previous = i.maximumSize - i.size > 0 || previous));
1127
- const reverseViews = [...this.views].reverse();
1186
+ const expandsDown = this.viewItems.map((i) => (previous = i.maximumSize - i.size > 0 || previous));
1187
+ const reverseViews = [...this.viewItems].reverse();
1128
1188
  previous = false;
1129
1189
  const collapsesUp = reverseViews
1130
1190
  .map((i) => (previous = i.size - i.minimumSize > 0 || previous))
@@ -1136,19 +1196,19 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1136
1196
  let position = 0;
1137
1197
  for (let index = 0; index < this.sashes.length; index++) {
1138
1198
  const sash = this.sashes[index];
1139
- const viewItem = this.views[index];
1199
+ const viewItem = this.viewItems[index];
1140
1200
  position += viewItem.size;
1141
1201
  const min = !(collapsesDown[index] && expandsUp[index + 1]);
1142
1202
  const max = !(expandsDown[index] && collapsesUp[index + 1]);
1143
1203
  if (min && max) {
1144
1204
  const upIndexes = range(index, -1);
1145
- const downIndexes = range(index + 1, this.views.length);
1205
+ const downIndexes = range(index + 1, this.viewItems.length);
1146
1206
  const snapBeforeIndex = this.findFirstSnapIndex(upIndexes);
1147
1207
  const snapAfterIndex = this.findFirstSnapIndex(downIndexes);
1148
1208
  const snappedBefore = typeof snapBeforeIndex === 'number' &&
1149
- !this.views[snapBeforeIndex].visible;
1209
+ !this.viewItems[snapBeforeIndex].visible;
1150
1210
  const snappedAfter = typeof snapAfterIndex === 'number' &&
1151
- !this.views[snapAfterIndex].visible;
1211
+ !this.viewItems[snapAfterIndex].visible;
1152
1212
  if (snappedBefore &&
1153
1213
  collapsesUp[index] &&
1154
1214
  (position > 0 || this.startSnappingEnabled)) {
@@ -1208,6 +1268,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1208
1268
  break;
1209
1269
  }
1210
1270
  }
1271
+ for (const viewItem of this.viewItems) {
1272
+ viewItem.dispose();
1273
+ }
1211
1274
  this.element.remove();
1212
1275
  }
1213
1276
  }
@@ -1642,7 +1705,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1642
1705
  throw new Error('Invalid index');
1643
1706
  }
1644
1707
  this.splitview.removeView(index, sizing);
1645
- this._removeChild(index);
1708
+ return this._removeChild(index);
1646
1709
  }
1647
1710
  _addChild(node, index) {
1648
1711
  this.children.splice(index, 0, node);
@@ -1664,10 +1727,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1664
1727
  });
1665
1728
  }
1666
1729
  dispose() {
1667
- super.dispose();
1668
1730
  this._childrenDisposable.dispose();
1669
- this.children.forEach((child) => child.dispose());
1670
1731
  this.splitview.dispose();
1732
+ this.children.forEach((child) => child.dispose());
1733
+ super.dispose();
1671
1734
  }
1672
1735
  }
1673
1736
 
@@ -1897,7 +1960,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1897
1960
  if (oldRoot.children.length === 1) {
1898
1961
  // can remove one level of redundant branching if there is only a single child
1899
1962
  const childReference = oldRoot.children[0];
1900
- oldRoot.removeChild(0); // remove to prevent disposal when disposing of unwanted root
1963
+ const child = oldRoot.removeChild(0); // remove to prevent disposal when disposing of unwanted root
1964
+ child.dispose();
1901
1965
  oldRoot.dispose();
1902
1966
  this._root.addChild(
1903
1967
  /**
@@ -2004,7 +2068,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2004
2068
  if (typeof newSiblingCachedVisibleSize === 'number') {
2005
2069
  newSiblingSize = exports.Sizing.Invisible(newSiblingCachedVisibleSize);
2006
2070
  }
2007
- grandParent.removeChild(parentIndex);
2071
+ const child = grandParent.removeChild(parentIndex);
2072
+ child.dispose();
2008
2073
  const newParent = new BranchNode(parent.orientation, this.proportionalLayout, this.styles, parent.size, parent.orthogonalSize);
2009
2074
  grandParent.addChild(newParent, parent.size, parentIndex);
2010
2075
  const newSibling = new LeafNode(parent.view, grandParent.orientation, parent.size);
@@ -2566,6 +2631,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2566
2631
  }
2567
2632
  dispose() {
2568
2633
  this.removeDropTarget();
2634
+ super.dispose();
2569
2635
  }
2570
2636
  toggleClasses(quadrant, width, height) {
2571
2637
  var _a, _b, _c, _d;
@@ -2743,8 +2809,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2743
2809
  if (this.panel.view) {
2744
2810
  const _onDidFocus = this.panel.view.content.onDidFocus;
2745
2811
  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()));
2812
+ const focusTracker = trackFocus(this._element);
2813
+ disposable.addDisposables(focusTracker, focusTracker.onDidFocus(() => this._onDidFocus.fire()), focusTracker.onDidBlur(() => this._onDidBlur.fire()));
2748
2814
  if (_onDidFocus) {
2749
2815
  disposable.addDisposables(_onDidFocus(() => this._onDidFocus.fire()));
2750
2816
  }
@@ -2783,24 +2849,32 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2783
2849
  constructor(el) {
2784
2850
  super();
2785
2851
  this.el = el;
2786
- this.disposable = new MutableDisposable();
2852
+ this.dataDisposable = new MutableDisposable();
2853
+ this.pointerEventsDisposable = new MutableDisposable();
2787
2854
  this._onDragStart = new Emitter();
2788
2855
  this.onDragStart = this._onDragStart.event;
2789
- this.iframes = [];
2856
+ this.addDisposables(this._onDragStart, this.dataDisposable, this.pointerEventsDisposable);
2790
2857
  this.configure();
2791
2858
  }
2792
2859
  configure() {
2793
2860
  this.addDisposables(this._onDragStart, addDisposableListener(this.el, 'dragstart', (event) => {
2794
- this.iframes = [
2861
+ const iframes = [
2795
2862
  ...getElementsByTagName('iframe'),
2796
2863
  ...getElementsByTagName('webview'),
2797
2864
  ];
2798
- for (const iframe of this.iframes) {
2865
+ this.pointerEventsDisposable.value = {
2866
+ dispose: () => {
2867
+ for (const iframe of iframes) {
2868
+ iframe.style.pointerEvents = 'auto';
2869
+ }
2870
+ },
2871
+ };
2872
+ for (const iframe of iframes) {
2799
2873
  iframe.style.pointerEvents = 'none';
2800
2874
  }
2801
2875
  this.el.classList.add('dv-dragged');
2802
2876
  setTimeout(() => this.el.classList.remove('dv-dragged'), 0);
2803
- this.disposable.value = this.getData(event.dataTransfer);
2877
+ this.dataDisposable.value = this.getData(event.dataTransfer);
2804
2878
  if (event.dataTransfer) {
2805
2879
  event.dataTransfer.effectAllowed = 'move';
2806
2880
  /**
@@ -2815,11 +2889,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2815
2889
  event.dataTransfer.setData('text/plain', '__dockview_internal_drag_event__');
2816
2890
  }
2817
2891
  }), addDisposableListener(this.el, 'dragend', () => {
2818
- for (const iframe of this.iframes) {
2819
- iframe.style.pointerEvents = 'auto';
2820
- }
2821
- this.iframes = [];
2822
- this.disposable.dispose();
2892
+ this.pointerEventsDisposable.dispose();
2893
+ this.dataDisposable.dispose();
2823
2894
  }));
2824
2895
  }
2825
2896
  }
@@ -2837,13 +2908,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2837
2908
  this.onChanged = this._onChanged.event;
2838
2909
  this._onDropped = new Emitter();
2839
2910
  this.onDrop = this._onDropped.event;
2840
- this.addDisposables(this._onChanged, this._onDropped);
2841
2911
  this._element = document.createElement('div');
2842
2912
  this._element.className = 'tab';
2843
2913
  this._element.tabIndex = 0;
2844
2914
  this._element.draggable = true;
2845
2915
  toggleClass(this.element, 'inactive-tab', true);
2846
- this.addDisposables(new (class Handler extends DragHandler {
2916
+ this.addDisposables(this._onChanged, this._onDropped, new (class Handler extends DragHandler {
2847
2917
  constructor() {
2848
2918
  super(...arguments);
2849
2919
  this.panelTransfer = LocalSelectionTransfer.getInstance();
@@ -2856,9 +2926,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2856
2926
  },
2857
2927
  };
2858
2928
  }
2859
- dispose() {
2860
- //
2861
- }
2862
2929
  })(this._element));
2863
2930
  this.addDisposables(addDisposableListener(this._element, 'mousedown', (event) => {
2864
2931
  if (event.defaultPrevented) {
@@ -2893,7 +2960,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2893
2960
  });
2894
2961
  this.addDisposables(this.droptarget.onDrop((event) => {
2895
2962
  this._onDropped.fire(event);
2896
- }));
2963
+ }), this.droptarget);
2897
2964
  }
2898
2965
  setActive(isActive) {
2899
2966
  toggleClass(this.element, 'active-tab', isActive);
@@ -2908,7 +2975,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2908
2975
  }
2909
2976
  dispose() {
2910
2977
  super.dispose();
2911
- this.droptarget.dispose();
2912
2978
  }
2913
2979
  }
2914
2980
 
@@ -2954,9 +3020,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2954
3020
  },
2955
3021
  };
2956
3022
  }
2957
- dispose() {
2958
- //
2959
- }
2960
3023
  }
2961
3024
 
2962
3025
  class VoidContainer extends CompositeDisposable {
@@ -3112,6 +3175,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3112
3175
  const tabToRemove = this.tabs.splice(index, 1)[0];
3113
3176
  const { value, disposable } = tabToRemove;
3114
3177
  disposable.dispose();
3178
+ value.dispose();
3115
3179
  value.element.remove();
3116
3180
  }
3117
3181
  setActivePanel(panel) {
@@ -3155,9 +3219,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3155
3219
  }
3156
3220
  dispose() {
3157
3221
  super.dispose();
3158
- this.tabs.forEach((tab) => {
3159
- tab.disposable.dispose();
3160
- });
3222
+ for (const { value, disposable } of this.tabs) {
3223
+ disposable.dispose();
3224
+ value.dispose();
3225
+ }
3161
3226
  this.tabs = [];
3162
3227
  }
3163
3228
  }
@@ -3255,7 +3320,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3255
3320
  container.append(this.tabsContainer.element, this.contentContainer.element);
3256
3321
  this.header.hidden = !!options.hideHeader;
3257
3322
  this.locked = !!options.locked;
3258
- this.addDisposables(this._onMove, this._onDidChange, this._onDidDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange, this.tabsContainer.onDrop((event) => {
3323
+ this.addDisposables(this.tabsContainer.onDrop((event) => {
3259
3324
  this.handleDropEvent(event.event, 'center', event.index);
3260
3325
  }), this.contentContainer.onDidFocus(() => {
3261
3326
  this.accessor.doSetGroupActive(this.groupPanel, true);
@@ -3263,7 +3328,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3263
3328
  // noop
3264
3329
  }), this.dropTarget.onDrop((event) => {
3265
3330
  this.handleDropEvent(event.nativeEvent, event.position);
3266
- }));
3331
+ }), this._onMove, this._onDidChange, this._onDidDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange);
3267
3332
  }
3268
3333
  initialize() {
3269
3334
  var _a, _b;
@@ -3697,8 +3762,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3697
3762
  this.layout(0, 0, true); // set some elements height/widths
3698
3763
  this.addDisposables(this.gridview.onDidChange(() => {
3699
3764
  this._bufferOnDidLayoutChange.fire();
3700
- }));
3701
- this.addDisposables(exports.DockviewEvent.any(this.onDidAddGroup, this.onDidRemoveGroup, this.onDidActiveGroupChange)(() => {
3765
+ }), exports.DockviewEvent.any(this.onDidAddGroup, this.onDidRemoveGroup, this.onDidActiveGroupChange)(() => {
3702
3766
  this._bufferOnDidLayoutChange.fire();
3703
3767
  }), this._bufferOnDidLayoutChange.onEvent(() => {
3704
3768
  this._onDidLayoutChange.fire();
@@ -3801,7 +3865,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3801
3865
  this.gridview.layout(width, height);
3802
3866
  }
3803
3867
  dispose() {
3804
- super.dispose();
3805
3868
  this._onDidActiveGroupChange.dispose();
3806
3869
  this._onDidAddGroup.dispose();
3807
3870
  this._onDidRemoveGroup.dispose();
@@ -3810,6 +3873,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3810
3873
  group.dispose();
3811
3874
  }
3812
3875
  this.gridview.dispose();
3876
+ super.dispose();
3813
3877
  }
3814
3878
  }
3815
3879
 
@@ -3873,7 +3937,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3873
3937
  //
3874
3938
  this._onUpdateParameters = new Emitter();
3875
3939
  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) => {
3940
+ this.addDisposables(this.onDidFocusChange((event) => {
3877
3941
  this._isFocused = event.isFocused;
3878
3942
  }), this.onDidActiveChange((event) => {
3879
3943
  this._isActive = event.isActive;
@@ -3882,14 +3946,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3882
3946
  }), this.onDidDimensionsChange((event) => {
3883
3947
  this._width = event.width;
3884
3948
  this._height = event.height;
3885
- }));
3949
+ }), this.panelUpdatesDisposable, this._onDidDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onFocusEvent, this._onActiveChange, this._onVisibilityChange, this._onUpdateParameters);
3886
3950
  }
3887
3951
  initialize(panel) {
3888
3952
  this.panelUpdatesDisposable.value = this._onUpdateParameters.event((parameters) => {
3889
3953
  panel.update({
3890
- params: {
3891
- params: parameters,
3892
- },
3954
+ params: parameters,
3893
3955
  });
3894
3956
  });
3895
3957
  }
@@ -3984,12 +4046,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3984
4046
  this._element.style.height = '100%';
3985
4047
  this._element.style.width = '100%';
3986
4048
  this._element.style.overflow = 'hidden';
3987
- const { onDidFocus, onDidBlur } = trackFocus(this._element);
3988
- this.addDisposables(this.api, onDidFocus(() => {
4049
+ const focusTracker = trackFocus(this._element);
4050
+ this.addDisposables(this.api, focusTracker.onDidFocus(() => {
3989
4051
  this.api._onDidChangeFocus.fire({ isFocused: true });
3990
- }), onDidBlur(() => {
4052
+ }), focusTracker.onDidBlur(() => {
3991
4053
  this.api._onDidChangeFocus.fire({ isFocused: false });
3992
- }));
4054
+ }), focusTracker);
3993
4055
  }
3994
4056
  focus() {
3995
4057
  this.api._onFocusEvent.fire();
@@ -4010,7 +4072,18 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4010
4072
  }
4011
4073
  update(event) {
4012
4074
  var _a, _b;
4075
+ // merge the new parameters with the existing parameters
4013
4076
  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) });
4077
+ /**
4078
+ * delete new keys that have a value of undefined,
4079
+ * allow values of null
4080
+ */
4081
+ for (const key of Object.keys(event.params)) {
4082
+ if (event.params[key] === undefined) {
4083
+ delete this._params.params[key];
4084
+ }
4085
+ }
4086
+ // update the view with the updated props
4014
4087
  (_b = this.part) === null || _b === void 0 ? void 0 : _b.update({ params: this._params.params });
4015
4088
  }
4016
4089
  toJSON() {
@@ -4024,9 +4097,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4024
4097
  }
4025
4098
  dispose() {
4026
4099
  var _a;
4027
- super.dispose();
4028
4100
  this.api.dispose();
4029
4101
  (_a = this.part) === null || _a === void 0 ? void 0 : _a.dispose();
4102
+ super.dispose();
4030
4103
  }
4031
4104
  }
4032
4105
 
@@ -4405,7 +4478,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4405
4478
  this._maximumHeight = options.maximumHeight;
4406
4479
  }
4407
4480
  this.api.initialize(this); // TODO: required to by-pass 'super before this' requirement
4408
- this.addDisposables(this._onDidChange, this.api.onVisibilityChange((event) => {
4481
+ this.addDisposables(this.api.onVisibilityChange((event) => {
4409
4482
  const { isVisible } = event;
4410
4483
  const { accessor } = this._params;
4411
4484
  accessor.setVisible(this, isVisible);
@@ -4434,7 +4507,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4434
4507
  height: event.height,
4435
4508
  width: event.width,
4436
4509
  });
4437
- }));
4510
+ }), this._onDidChange);
4438
4511
  }
4439
4512
  setVisible(isVisible) {
4440
4513
  this.api._onDidVisibilityChange.fire({ isVisible });
@@ -4591,7 +4664,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4591
4664
  this.addDisposables(this.disposable, this._onDidTitleChange, this._onDidGroupChange, this._onDidActiveGroupChange);
4592
4665
  }
4593
4666
  setTitle(title) {
4594
- this.panel.update({ params: { title } });
4667
+ this.panel.setTitle(title);
4595
4668
  }
4596
4669
  close() {
4597
4670
  this.group.model.closePanel(this.panel);
@@ -4656,12 +4729,18 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4656
4729
  }
4657
4730
  }
4658
4731
  update(event) {
4659
- const params = event.params;
4660
- this._params = Object.assign(Object.assign({}, (this._params || {})), event.params.params);
4661
- if (params.title !== this.title) {
4662
- this._title = params.title;
4663
- this.api._onDidTitleChange.fire({ title: params.title });
4732
+ // merge the new parameters with the existing parameters
4733
+ this._params = Object.assign(Object.assign({}, (this._params || {})), event.params);
4734
+ /**
4735
+ * delete new keys that have a value of undefined,
4736
+ * allow values of null
4737
+ */
4738
+ for (const key of Object.keys(event.params)) {
4739
+ if (event.params[key] === undefined) {
4740
+ delete this._params[key];
4741
+ }
4664
4742
  }
4743
+ // update the view with the updated props
4665
4744
  this.view.update({
4666
4745
  params: {
4667
4746
  params: this._params,
@@ -5037,7 +5116,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5037
5116
  size: { type: 'pixels', value: 20 },
5038
5117
  },
5039
5118
  });
5040
- this.addDisposables(dropTarget, dropTarget.onDrop((event) => {
5119
+ this.addDisposables(dropTarget.onDrop((event) => {
5041
5120
  const data = getPanelData();
5042
5121
  if (data) {
5043
5122
  this.moveGroupOrPanel(this.orthogonalize(event.position), data.groupId, data.panelId || undefined, 'center');
@@ -5045,7 +5124,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5045
5124
  else {
5046
5125
  this._onDidDrop.fire(Object.assign(Object.assign({}, event), { api: this._api, group: null, getData: getPanelData }));
5047
5126
  }
5048
- }));
5127
+ }), dropTarget);
5049
5128
  this._api = new DockviewApi(this);
5050
5129
  this.updateWatermark();
5051
5130
  }
@@ -5369,31 +5448,33 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5369
5448
  }
5370
5449
  super.doRemoveGroup(group, { skipActive });
5371
5450
  }
5372
- moveGroupOrPanel(referenceGroup, groupId, itemId, target, index) {
5451
+ moveGroupOrPanel(destinationGroup, sourceGroupId, sourceItemId, destinationTarget, destinationIndex) {
5373
5452
  var _a;
5374
- const sourceGroup = groupId
5375
- ? (_a = this._groups.get(groupId)) === null || _a === void 0 ? void 0 : _a.value
5453
+ const sourceGroup = sourceGroupId
5454
+ ? (_a = this._groups.get(sourceGroupId)) === null || _a === void 0 ? void 0 : _a.value
5376
5455
  : undefined;
5377
- if (itemId === undefined) {
5456
+ if (sourceItemId === undefined) {
5378
5457
  if (sourceGroup) {
5379
- this.moveGroup(sourceGroup, referenceGroup, target);
5458
+ this.moveGroup(sourceGroup, destinationGroup, destinationTarget);
5380
5459
  }
5381
5460
  return;
5382
5461
  }
5383
- if (!target || target === 'center') {
5384
- const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(itemId)) ||
5385
- this.panels.find((panel) => panel.id === itemId);
5462
+ if (!destinationTarget || destinationTarget === 'center') {
5463
+ const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(sourceItemId)) ||
5464
+ this.panels.find((panel) => panel.id === sourceItemId);
5386
5465
  if (!groupItem) {
5387
- throw new Error(`No panel with id ${itemId}`);
5466
+ throw new Error(`No panel with id ${sourceItemId}`);
5388
5467
  }
5389
5468
  if ((sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.size) === 0) {
5390
5469
  this.doRemoveGroup(sourceGroup);
5391
5470
  }
5392
- referenceGroup.model.openPanel(groupItem, { index });
5471
+ destinationGroup.model.openPanel(groupItem, {
5472
+ index: destinationIndex,
5473
+ });
5393
5474
  }
5394
5475
  else {
5395
- const referenceLocation = getGridLocation(referenceGroup.element);
5396
- const targetLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
5476
+ const referenceLocation = getGridLocation(destinationGroup.element);
5477
+ const targetLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
5397
5478
  if (sourceGroup && sourceGroup.size < 2) {
5398
5479
  const [targetParentLocation, to] = tail(targetLocation);
5399
5480
  const sourceLocation = getGridLocation(sourceGroup.element);
@@ -5411,18 +5492,18 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5411
5492
  skipDispose: true,
5412
5493
  });
5413
5494
  // after deleting the group we need to re-evaulate the ref location
5414
- const updatedReferenceLocation = getGridLocation(referenceGroup.element);
5415
- const location = getRelativeLocation(this.gridview.orientation, updatedReferenceLocation, target);
5495
+ const updatedReferenceLocation = getGridLocation(destinationGroup.element);
5496
+ const location = getRelativeLocation(this.gridview.orientation, updatedReferenceLocation, destinationTarget);
5416
5497
  this.doAddGroup(targetGroup, location);
5417
5498
  }
5418
5499
  }
5419
5500
  else {
5420
- const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(itemId)) ||
5421
- this.panels.find((panel) => panel.id === itemId);
5501
+ const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(sourceItemId)) ||
5502
+ this.panels.find((panel) => panel.id === sourceItemId);
5422
5503
  if (!groupItem) {
5423
- throw new Error(`No panel with id ${itemId}`);
5504
+ throw new Error(`No panel with id ${sourceItemId}`);
5424
5505
  }
5425
- const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
5506
+ const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
5426
5507
  const group = this.createGroupAtLocation(dropLocation);
5427
5508
  group.model.openPanel(groupItem);
5428
5509
  }
@@ -5516,11 +5597,11 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5516
5597
  return (_a = Array.from(this._groups.values()).find((group) => group.value.model.containsPanel(panel))) === null || _a === void 0 ? void 0 : _a.value;
5517
5598
  }
5518
5599
  dispose() {
5519
- super.dispose();
5520
5600
  this._onDidActivePanelChange.dispose();
5521
5601
  this._onDidAddPanel.dispose();
5522
5602
  this._onDidRemovePanel.dispose();
5523
5603
  this._onDidLayoutFromJSON.dispose();
5604
+ super.dispose();
5524
5605
  }
5525
5606
  }
5526
5607
 
@@ -5778,7 +5859,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5778
5859
  }
5779
5860
  set splitview(value) {
5780
5861
  this._splitview = value;
5781
- this._disposable.value = new CompositeDisposable(this._splitview.onDidSashEnd(() => {
5862
+ this._splitviewChangeDisposable.value = new CompositeDisposable(this._splitview.onDidSashEnd(() => {
5782
5863
  this._onDidLayoutChange.fire(undefined);
5783
5864
  }), this._splitview.onDidAddView((e) => this._onDidAddView.fire(e)), this._splitview.onDidRemoveView((e) => this._onDidRemoveView.fire(e)));
5784
5865
  }
@@ -5800,7 +5881,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5800
5881
  }
5801
5882
  constructor(options) {
5802
5883
  super(options.parentElement);
5803
- this._disposable = new MutableDisposable();
5884
+ this._splitviewChangeDisposable = new MutableDisposable();
5804
5885
  this._panels = new Map();
5805
5886
  this._onDidLayoutfromJSON = new Emitter();
5806
5887
  this.onDidLayoutFromJSON = this._onDidLayoutfromJSON.event;
@@ -5818,7 +5899,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5818
5899
  options.frameworkComponents = {};
5819
5900
  }
5820
5901
  this.splitview = new Splitview(this.element, options);
5821
- this.addDisposables(this._disposable, this._onDidAddView, this._onDidLayoutfromJSON, this._onDidRemoveView, this._onDidLayoutChange);
5902
+ this.addDisposables(this._onDidAddView, this._onDidLayoutfromJSON, this._onDidRemoveView, this._onDidLayoutChange);
5822
5903
  }
5823
5904
  updateOptions(options) {
5824
5905
  const hasOrientationChanged = typeof options.orientation === 'string' &&
@@ -5856,15 +5937,15 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5856
5937
  }
5857
5938
  }
5858
5939
  removePanel(panel, sizing) {
5859
- const disposable = this._panels.get(panel.id);
5860
- if (!disposable) {
5940
+ const item = this._panels.get(panel.id);
5941
+ if (!item) {
5861
5942
  throw new Error(`unknown splitview panel ${panel.id}`);
5862
5943
  }
5863
- disposable.disposable.dispose();
5864
- disposable.value.dispose();
5944
+ item.dispose();
5865
5945
  this._panels.delete(panel.id);
5866
5946
  const index = this.panels.findIndex((_) => _ === panel);
5867
- this.splitview.removeView(index, sizing);
5947
+ const removedView = this.splitview.removeView(index, sizing);
5948
+ removedView.dispose();
5868
5949
  const panels = this.panels;
5869
5950
  if (panels.length > 0) {
5870
5951
  this.setActive(panels[panels.length - 1]);
@@ -5911,7 +5992,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5911
5992
  }
5912
5993
  this.setActive(view, true);
5913
5994
  });
5914
- this._panels.set(view.id, { disposable, value: view });
5995
+ this._panels.set(view.id, disposable);
5915
5996
  }
5916
5997
  toJSON() {
5917
5998
  var _a;
@@ -5984,20 +6065,26 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5984
6065
  this._onDidLayoutfromJSON.fire();
5985
6066
  }
5986
6067
  clear() {
5987
- for (const [_, value] of this._panels.entries()) {
5988
- value.disposable.dispose();
5989
- value.value.dispose();
6068
+ for (const disposable of this._panels.values()) {
6069
+ disposable.dispose();
5990
6070
  }
5991
6071
  this._panels.clear();
5992
- this.splitview.dispose();
6072
+ while (this.splitview.length > 0) {
6073
+ const view = this.splitview.removeView(0, exports.Sizing.Distribute, true);
6074
+ view.dispose();
6075
+ }
5993
6076
  }
5994
6077
  dispose() {
5995
- for (const [_, value] of this._panels.entries()) {
5996
- value.disposable.dispose();
5997
- value.value.dispose();
6078
+ for (const disposable of this._panels.values()) {
6079
+ disposable.dispose();
5998
6080
  }
5999
6081
  this._panels.clear();
6082
+ const views = this.splitview.getViews();
6083
+ this._splitviewChangeDisposable.dispose();
6000
6084
  this.splitview.dispose();
6085
+ for (const view of views) {
6086
+ view.dispose();
6087
+ }
6001
6088
  super.dispose();
6002
6089
  }
6003
6090
  }