dockview 2.1.0 → 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
3
- * @version 2.1.0
3
+ * @version 2.1.2
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -2796,7 +2796,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2796
2796
  this._bufferOnDidLayoutChange.fire();
2797
2797
  }), exports.DockviewEvent.any(this.onDidAdd, this.onDidRemove, this.onDidActiveChange)(() => {
2798
2798
  this._bufferOnDidLayoutChange.fire();
2799
- }), this._bufferOnDidLayoutChange);
2799
+ }), this._onDidMaximizedChange, this._onDidViewVisibilityChangeMicroTaskQueue, this._bufferOnDidLayoutChange);
2800
2800
  }
2801
2801
  setVisible(panel, visible) {
2802
2802
  this.gridview.setViewVisible(getGridLocation(panel.element), visible);
@@ -5397,7 +5397,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5397
5397
  group: this.groupPanel,
5398
5398
  getData: getPanelData,
5399
5399
  }));
5400
- }), this._onMove, this._onDidChange, this._onDidDrop, this._onWillDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange, this._onUnhandledDragOverEvent);
5400
+ }), this._onMove, this._onDidChange, this._onDidDrop, this._onWillDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange, this._onUnhandledDragOverEvent, this._onDidPanelTitleChange, this._onDidPanelParametersChange);
5401
5401
  }
5402
5402
  focusContent() {
5403
5403
  this.contentContainer.element.focus();
@@ -7376,6 +7376,47 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7376
7376
  }
7377
7377
  }
7378
7378
 
7379
+ class StrictEventsSequencing extends CompositeDisposable {
7380
+ constructor(accessor) {
7381
+ super();
7382
+ this.accessor = accessor;
7383
+ this.init();
7384
+ }
7385
+ init() {
7386
+ const panels = new Set();
7387
+ const groups = new Set();
7388
+ this.addDisposables(this.accessor.onDidAddPanel((panel) => {
7389
+ if (panels.has(panel.api.id)) {
7390
+ throw new Error(`dockview: Invalid event sequence. [onDidAddPanel] called for panel ${panel.api.id} but panel already exists`);
7391
+ }
7392
+ else {
7393
+ panels.add(panel.api.id);
7394
+ }
7395
+ }), this.accessor.onDidRemovePanel((panel) => {
7396
+ if (!panels.has(panel.api.id)) {
7397
+ throw new Error(`dockview: Invalid event sequence. [onDidRemovePanel] called for panel ${panel.api.id} but panel does not exists`);
7398
+ }
7399
+ else {
7400
+ panels.delete(panel.api.id);
7401
+ }
7402
+ }), this.accessor.onDidAddGroup((group) => {
7403
+ if (groups.has(group.api.id)) {
7404
+ throw new Error(`dockview: Invalid event sequence. [onDidAddGroup] called for group ${group.api.id} but group already exists`);
7405
+ }
7406
+ else {
7407
+ groups.add(group.api.id);
7408
+ }
7409
+ }), this.accessor.onDidRemoveGroup((group) => {
7410
+ if (!groups.has(group.api.id)) {
7411
+ throw new Error(`dockview: Invalid event sequence. [onDidRemoveGroup] called for group ${group.api.id} but group does not exists`);
7412
+ }
7413
+ else {
7414
+ groups.delete(group.api.id);
7415
+ }
7416
+ }));
7417
+ }
7418
+ }
7419
+
7379
7420
  const DEFAULT_ROOT_OVERLAY_MODEL = {
7380
7421
  activationSize: { type: 'pixels', value: 10 },
7381
7422
  size: { type: 'pixels', value: 20 },
@@ -7479,7 +7520,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7479
7520
  this.overlayRenderContainer = new OverlayRenderContainer(this.gridview.element, this);
7480
7521
  toggleClass(this.gridview.element, 'dv-dockview', true);
7481
7522
  toggleClass(this.element, 'dv-debug', !!options.debug);
7482
- 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(() => {
7523
+ if (options.debug) {
7524
+ this.addDisposables(new StrictEventsSequencing(this));
7525
+ }
7526
+ 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(() => {
7483
7527
  this.updateWatermark();
7484
7528
  }), this.onDidAdd((event) => {
7485
7529
  if (!this._moving) {
@@ -7596,6 +7640,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7596
7640
  this._api = new DockviewApi(this);
7597
7641
  this.updateWatermark();
7598
7642
  }
7643
+ dispose() {
7644
+ this.clear(); // explicitly clear the layout before cleaning up
7645
+ super.dispose();
7646
+ }
7599
7647
  setVisible(panel, visible) {
7600
7648
  switch (panel.api.location.type) {
7601
7649
  case 'grid':
@@ -7654,6 +7702,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7654
7702
  return _window
7655
7703
  .open()
7656
7704
  .then((popoutContainer) => {
7705
+ var _a;
7657
7706
  if (_window.isDisposed) {
7658
7707
  return false;
7659
7708
  }
@@ -7686,6 +7735,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7686
7735
  }
7687
7736
  group.model.renderContainer = overlayRenderContainer;
7688
7737
  group.layout(_window.window.innerWidth, _window.window.innerHeight);
7738
+ let floatingBox;
7689
7739
  if (!(options === null || options === void 0 ? void 0 : options.overridePopoutGroup) && isGroupAddedToDom) {
7690
7740
  if (itemToPopout instanceof DockviewPanel) {
7691
7741
  this.movingLock(() => {
@@ -7704,6 +7754,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7704
7754
  break;
7705
7755
  case 'floating':
7706
7756
  case 'popout':
7757
+ floatingBox = (_a = this._floatingGroups
7758
+ .find((value) => value.group.api.id ===
7759
+ itemToPopout.api.id)) === null || _a === void 0 ? void 0 : _a.overlay.toJSON();
7707
7760
  this.removeGroup(referenceGroup);
7708
7761
  break;
7709
7762
  }
@@ -7774,17 +7827,29 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7774
7827
  }
7775
7828
  }
7776
7829
  else if (this.getPanel(group.id)) {
7777
- this.doRemoveGroup(group, {
7778
- skipDispose: true,
7779
- skipActive: true,
7780
- skipPopoutReturn: true,
7781
- });
7782
7830
  const removedGroup = group;
7783
- removedGroup.model.renderContainer =
7784
- this.overlayRenderContainer;
7785
- removedGroup.model.location = { type: 'grid' };
7786
- returnedGroup = removedGroup;
7787
- this.doAddGroup(removedGroup, [0]);
7831
+ if (floatingBox) {
7832
+ this.addFloatingGroup(removedGroup, {
7833
+ height: floatingBox.height,
7834
+ width: floatingBox.width,
7835
+ position: floatingBox,
7836
+ });
7837
+ }
7838
+ else {
7839
+ this.doRemoveGroup(removedGroup, {
7840
+ skipDispose: true,
7841
+ skipActive: true,
7842
+ skipPopoutReturn: true,
7843
+ });
7844
+ removedGroup.model.renderContainer =
7845
+ this.overlayRenderContainer;
7846
+ removedGroup.model.location = { type: 'grid' };
7847
+ returnedGroup = removedGroup;
7848
+ this.movingLock(() => {
7849
+ // suppress group add events since the group already exists
7850
+ this.doAddGroup(removedGroup, [0]);
7851
+ });
7852
+ }
7788
7853
  this.doSetGroupAndPanelActive(removedGroup);
7789
7854
  }
7790
7855
  }));
@@ -8132,6 +8197,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8132
8197
  locked: !!locked,
8133
8198
  hideHeader: !!hideHeader,
8134
8199
  });
8200
+ this._onDidAddGroup.fire(group);
8135
8201
  const createdPanels = [];
8136
8202
  for (const child of views) {
8137
8203
  /**
@@ -8142,7 +8208,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8142
8208
  const panel = this._deserializer.fromJSON(panels[child], group);
8143
8209
  createdPanels.push(panel);
8144
8210
  }
8145
- this._onDidAddGroup.fire(group);
8146
8211
  for (let i = 0; i < views.length; i++) {
8147
8212
  const panel = createdPanels[i];
8148
8213
  const isActive = typeof activeView === 'string' &&
@@ -8541,7 +8606,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8541
8606
  const refGroup = selectedGroup.referenceGroup
8542
8607
  ? this.getPanel(selectedGroup.referenceGroup)
8543
8608
  : undefined;
8544
- if (refGroup) {
8609
+ if (refGroup && refGroup.panels.length === 0) {
8545
8610
  this.removeGroup(refGroup);
8546
8611
  }
8547
8612
  }