dockview-react 2.1.1 → 2.1.2

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-react
3
- * @version 2.1.1
3
+ * @version 2.1.2
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -2799,7 +2799,7 @@ class BaseGrid extends Resizable {
2799
2799
  this._bufferOnDidLayoutChange.fire();
2800
2800
  }), exports.DockviewEvent.any(this.onDidAdd, this.onDidRemove, this.onDidActiveChange)(() => {
2801
2801
  this._bufferOnDidLayoutChange.fire();
2802
- }), this._bufferOnDidLayoutChange);
2802
+ }), this._onDidMaximizedChange, this._onDidViewVisibilityChangeMicroTaskQueue, this._bufferOnDidLayoutChange);
2803
2803
  }
2804
2804
  setVisible(panel, visible) {
2805
2805
  this.gridview.setViewVisible(getGridLocation(panel.element), visible);
@@ -5400,7 +5400,7 @@ class DockviewGroupPanelModel extends CompositeDisposable {
5400
5400
  group: this.groupPanel,
5401
5401
  getData: getPanelData,
5402
5402
  }));
5403
- }), this._onMove, this._onDidChange, this._onDidDrop, this._onWillDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange, this._onUnhandledDragOverEvent);
5403
+ }), this._onMove, this._onDidChange, this._onDidDrop, this._onWillDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange, this._onUnhandledDragOverEvent, this._onDidPanelTitleChange, this._onDidPanelParametersChange);
5404
5404
  }
5405
5405
  focusContent() {
5406
5406
  this.contentContainer.element.focus();
@@ -7379,6 +7379,47 @@ class PopoutWindow extends CompositeDisposable {
7379
7379
  }
7380
7380
  }
7381
7381
 
7382
+ class StrictEventsSequencing extends CompositeDisposable {
7383
+ constructor(accessor) {
7384
+ super();
7385
+ this.accessor = accessor;
7386
+ this.init();
7387
+ }
7388
+ init() {
7389
+ const panels = new Set();
7390
+ const groups = new Set();
7391
+ this.addDisposables(this.accessor.onDidAddPanel((panel) => {
7392
+ if (panels.has(panel.api.id)) {
7393
+ throw new Error(`dockview: Invalid event sequence. [onDidAddPanel] called for panel ${panel.api.id} but panel already exists`);
7394
+ }
7395
+ else {
7396
+ panels.add(panel.api.id);
7397
+ }
7398
+ }), this.accessor.onDidRemovePanel((panel) => {
7399
+ if (!panels.has(panel.api.id)) {
7400
+ throw new Error(`dockview: Invalid event sequence. [onDidRemovePanel] called for panel ${panel.api.id} but panel does not exists`);
7401
+ }
7402
+ else {
7403
+ panels.delete(panel.api.id);
7404
+ }
7405
+ }), this.accessor.onDidAddGroup((group) => {
7406
+ if (groups.has(group.api.id)) {
7407
+ throw new Error(`dockview: Invalid event sequence. [onDidAddGroup] called for group ${group.api.id} but group already exists`);
7408
+ }
7409
+ else {
7410
+ groups.add(group.api.id);
7411
+ }
7412
+ }), this.accessor.onDidRemoveGroup((group) => {
7413
+ if (!groups.has(group.api.id)) {
7414
+ throw new Error(`dockview: Invalid event sequence. [onDidRemoveGroup] called for group ${group.api.id} but group does not exists`);
7415
+ }
7416
+ else {
7417
+ groups.delete(group.api.id);
7418
+ }
7419
+ }));
7420
+ }
7421
+ }
7422
+
7382
7423
  const DEFAULT_ROOT_OVERLAY_MODEL = {
7383
7424
  activationSize: { type: 'pixels', value: 10 },
7384
7425
  size: { type: 'pixels', value: 20 },
@@ -7482,7 +7523,10 @@ class DockviewComponent extends BaseGrid {
7482
7523
  this.overlayRenderContainer = new OverlayRenderContainer(this.gridview.element, this);
7483
7524
  toggleClass(this.gridview.element, 'dv-dockview', true);
7484
7525
  toggleClass(this.element, 'dv-debug', !!options.debug);
7485
- this.addDisposables(this.overlayRenderContainer, this._onWillDragPanel, this._onWillDragGroup, this._onWillShowOverlay, this._onDidActivePanelChange, this._onDidAddPanel, this._onDidRemovePanel, this._onDidLayoutFromJSON, this._onDidDrop, this._onWillDrop, this._onDidMovePanel, this._onDidAddGroup, this._onDidRemoveGroup, this._onDidActiveGroupChange, this._onUnhandledDragOverEvent, this.onDidViewVisibilityChangeMicroTaskQueue(() => {
7526
+ if (options.debug) {
7527
+ this.addDisposables(new StrictEventsSequencing(this));
7528
+ }
7529
+ this.addDisposables(this.overlayRenderContainer, this._onWillDragPanel, this._onWillDragGroup, this._onWillShowOverlay, this._onDidActivePanelChange, this._onDidAddPanel, this._onDidRemovePanel, this._onDidLayoutFromJSON, this._onDidDrop, this._onWillDrop, this._onDidMovePanel, this._onDidAddGroup, this._onDidRemoveGroup, this._onDidActiveGroupChange, this._onUnhandledDragOverEvent, this._onDidMaximizedGroupChange, this.onDidViewVisibilityChangeMicroTaskQueue(() => {
7486
7530
  this.updateWatermark();
7487
7531
  }), this.onDidAdd((event) => {
7488
7532
  if (!this._moving) {
@@ -7599,6 +7643,10 @@ class DockviewComponent extends BaseGrid {
7599
7643
  this._api = new DockviewApi(this);
7600
7644
  this.updateWatermark();
7601
7645
  }
7646
+ dispose() {
7647
+ this.clear(); // explicitly clear the layout before cleaning up
7648
+ super.dispose();
7649
+ }
7602
7650
  setVisible(panel, visible) {
7603
7651
  switch (panel.api.location.type) {
7604
7652
  case 'grid':
@@ -7657,6 +7705,7 @@ class DockviewComponent extends BaseGrid {
7657
7705
  return _window
7658
7706
  .open()
7659
7707
  .then((popoutContainer) => {
7708
+ var _a;
7660
7709
  if (_window.isDisposed) {
7661
7710
  return false;
7662
7711
  }
@@ -7689,6 +7738,7 @@ class DockviewComponent extends BaseGrid {
7689
7738
  }
7690
7739
  group.model.renderContainer = overlayRenderContainer;
7691
7740
  group.layout(_window.window.innerWidth, _window.window.innerHeight);
7741
+ let floatingBox;
7692
7742
  if (!(options === null || options === void 0 ? void 0 : options.overridePopoutGroup) && isGroupAddedToDom) {
7693
7743
  if (itemToPopout instanceof DockviewPanel) {
7694
7744
  this.movingLock(() => {
@@ -7707,6 +7757,9 @@ class DockviewComponent extends BaseGrid {
7707
7757
  break;
7708
7758
  case 'floating':
7709
7759
  case 'popout':
7760
+ floatingBox = (_a = this._floatingGroups
7761
+ .find((value) => value.group.api.id ===
7762
+ itemToPopout.api.id)) === null || _a === void 0 ? void 0 : _a.overlay.toJSON();
7710
7763
  this.removeGroup(referenceGroup);
7711
7764
  break;
7712
7765
  }
@@ -7777,17 +7830,29 @@ class DockviewComponent extends BaseGrid {
7777
7830
  }
7778
7831
  }
7779
7832
  else if (this.getPanel(group.id)) {
7780
- this.doRemoveGroup(group, {
7781
- skipDispose: true,
7782
- skipActive: true,
7783
- skipPopoutReturn: true,
7784
- });
7785
7833
  const removedGroup = group;
7786
- removedGroup.model.renderContainer =
7787
- this.overlayRenderContainer;
7788
- removedGroup.model.location = { type: 'grid' };
7789
- returnedGroup = removedGroup;
7790
- this.doAddGroup(removedGroup, [0]);
7834
+ if (floatingBox) {
7835
+ this.addFloatingGroup(removedGroup, {
7836
+ height: floatingBox.height,
7837
+ width: floatingBox.width,
7838
+ position: floatingBox,
7839
+ });
7840
+ }
7841
+ else {
7842
+ this.doRemoveGroup(removedGroup, {
7843
+ skipDispose: true,
7844
+ skipActive: true,
7845
+ skipPopoutReturn: true,
7846
+ });
7847
+ removedGroup.model.renderContainer =
7848
+ this.overlayRenderContainer;
7849
+ removedGroup.model.location = { type: 'grid' };
7850
+ returnedGroup = removedGroup;
7851
+ this.movingLock(() => {
7852
+ // suppress group add events since the group already exists
7853
+ this.doAddGroup(removedGroup, [0]);
7854
+ });
7855
+ }
7791
7856
  this.doSetGroupAndPanelActive(removedGroup);
7792
7857
  }
7793
7858
  }));
@@ -8135,6 +8200,7 @@ class DockviewComponent extends BaseGrid {
8135
8200
  locked: !!locked,
8136
8201
  hideHeader: !!hideHeader,
8137
8202
  });
8203
+ this._onDidAddGroup.fire(group);
8138
8204
  const createdPanels = [];
8139
8205
  for (const child of views) {
8140
8206
  /**
@@ -8145,7 +8211,6 @@ class DockviewComponent extends BaseGrid {
8145
8211
  const panel = this._deserializer.fromJSON(panels[child], group);
8146
8212
  createdPanels.push(panel);
8147
8213
  }
8148
- this._onDidAddGroup.fire(group);
8149
8214
  for (let i = 0; i < views.length; i++) {
8150
8215
  const panel = createdPanels[i];
8151
8216
  const isActive = typeof activeView === 'string' &&