dockview-core 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.
Files changed (35) hide show
  1. package/dist/cjs/dockview/dockviewComponent.d.ts +1 -0
  2. package/dist/cjs/dockview/dockviewComponent.js +42 -15
  3. package/dist/cjs/dockview/dockviewGroupPanelModel.js +1 -1
  4. package/dist/cjs/dockview/strictEventsSequencing.d.ts +7 -0
  5. package/dist/cjs/dockview/strictEventsSequencing.js +63 -0
  6. package/dist/cjs/gridview/baseComponentGridview.js +1 -1
  7. package/dist/dockview-core.amd.js +81 -16
  8. package/dist/dockview-core.amd.js.map +1 -1
  9. package/dist/dockview-core.amd.min.js +2 -2
  10. package/dist/dockview-core.amd.min.js.map +1 -1
  11. package/dist/dockview-core.amd.min.noStyle.js +2 -2
  12. package/dist/dockview-core.amd.min.noStyle.js.map +1 -1
  13. package/dist/dockview-core.amd.noStyle.js +81 -16
  14. package/dist/dockview-core.amd.noStyle.js.map +1 -1
  15. package/dist/dockview-core.cjs.js +81 -16
  16. package/dist/dockview-core.cjs.js.map +1 -1
  17. package/dist/dockview-core.esm.js +81 -16
  18. package/dist/dockview-core.esm.js.map +1 -1
  19. package/dist/dockview-core.esm.min.js +2 -2
  20. package/dist/dockview-core.esm.min.js.map +1 -1
  21. package/dist/dockview-core.js +81 -16
  22. package/dist/dockview-core.js.map +1 -1
  23. package/dist/dockview-core.min.js +2 -2
  24. package/dist/dockview-core.min.js.map +1 -1
  25. package/dist/dockview-core.min.noStyle.js +2 -2
  26. package/dist/dockview-core.min.noStyle.js.map +1 -1
  27. package/dist/dockview-core.noStyle.js +81 -16
  28. package/dist/dockview-core.noStyle.js.map +1 -1
  29. package/dist/esm/dockview/dockviewComponent.d.ts +1 -0
  30. package/dist/esm/dockview/dockviewComponent.js +38 -13
  31. package/dist/esm/dockview/dockviewGroupPanelModel.js +1 -1
  32. package/dist/esm/dockview/strictEventsSequencing.d.ts +7 -0
  33. package/dist/esm/dockview/strictEventsSequencing.js +41 -0
  34. package/dist/esm/gridview/baseComponentGridview.js +1 -1
  35. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview-core
3
- * @version 2.1.0
3
+ * @version 2.1.2
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -2794,7 +2794,7 @@ class BaseGrid extends Resizable {
2794
2794
  this._bufferOnDidLayoutChange.fire();
2795
2795
  }), Event.any(this.onDidAdd, this.onDidRemove, this.onDidActiveChange)(() => {
2796
2796
  this._bufferOnDidLayoutChange.fire();
2797
- }), this._bufferOnDidLayoutChange);
2797
+ }), this._onDidMaximizedChange, this._onDidViewVisibilityChangeMicroTaskQueue, this._bufferOnDidLayoutChange);
2798
2798
  }
2799
2799
  setVisible(panel, visible) {
2800
2800
  this.gridview.setViewVisible(getGridLocation(panel.element), visible);
@@ -5395,7 +5395,7 @@ class DockviewGroupPanelModel extends CompositeDisposable {
5395
5395
  group: this.groupPanel,
5396
5396
  getData: getPanelData,
5397
5397
  }));
5398
- }), this._onMove, this._onDidChange, this._onDidDrop, this._onWillDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange, this._onUnhandledDragOverEvent);
5398
+ }), this._onMove, this._onDidChange, this._onDidDrop, this._onWillDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange, this._onUnhandledDragOverEvent, this._onDidPanelTitleChange, this._onDidPanelParametersChange);
5399
5399
  }
5400
5400
  focusContent() {
5401
5401
  this.contentContainer.element.focus();
@@ -7397,6 +7397,47 @@ class PopoutWindow extends CompositeDisposable {
7397
7397
  }
7398
7398
  }
7399
7399
 
7400
+ class StrictEventsSequencing extends CompositeDisposable {
7401
+ constructor(accessor) {
7402
+ super();
7403
+ this.accessor = accessor;
7404
+ this.init();
7405
+ }
7406
+ init() {
7407
+ const panels = new Set();
7408
+ const groups = new Set();
7409
+ this.addDisposables(this.accessor.onDidAddPanel((panel) => {
7410
+ if (panels.has(panel.api.id)) {
7411
+ throw new Error(`dockview: Invalid event sequence. [onDidAddPanel] called for panel ${panel.api.id} but panel already exists`);
7412
+ }
7413
+ else {
7414
+ panels.add(panel.api.id);
7415
+ }
7416
+ }), this.accessor.onDidRemovePanel((panel) => {
7417
+ if (!panels.has(panel.api.id)) {
7418
+ throw new Error(`dockview: Invalid event sequence. [onDidRemovePanel] called for panel ${panel.api.id} but panel does not exists`);
7419
+ }
7420
+ else {
7421
+ panels.delete(panel.api.id);
7422
+ }
7423
+ }), this.accessor.onDidAddGroup((group) => {
7424
+ if (groups.has(group.api.id)) {
7425
+ throw new Error(`dockview: Invalid event sequence. [onDidAddGroup] called for group ${group.api.id} but group already exists`);
7426
+ }
7427
+ else {
7428
+ groups.add(group.api.id);
7429
+ }
7430
+ }), this.accessor.onDidRemoveGroup((group) => {
7431
+ if (!groups.has(group.api.id)) {
7432
+ throw new Error(`dockview: Invalid event sequence. [onDidRemoveGroup] called for group ${group.api.id} but group does not exists`);
7433
+ }
7434
+ else {
7435
+ groups.delete(group.api.id);
7436
+ }
7437
+ }));
7438
+ }
7439
+ }
7440
+
7400
7441
  const DEFAULT_ROOT_OVERLAY_MODEL = {
7401
7442
  activationSize: { type: 'pixels', value: 10 },
7402
7443
  size: { type: 'pixels', value: 20 },
@@ -7500,7 +7541,10 @@ class DockviewComponent extends BaseGrid {
7500
7541
  this.overlayRenderContainer = new OverlayRenderContainer(this.gridview.element, this);
7501
7542
  toggleClass(this.gridview.element, 'dv-dockview', true);
7502
7543
  toggleClass(this.element, 'dv-debug', !!options.debug);
7503
- 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(() => {
7544
+ if (options.debug) {
7545
+ this.addDisposables(new StrictEventsSequencing(this));
7546
+ }
7547
+ 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(() => {
7504
7548
  this.updateWatermark();
7505
7549
  }), this.onDidAdd((event) => {
7506
7550
  if (!this._moving) {
@@ -7617,6 +7661,10 @@ class DockviewComponent extends BaseGrid {
7617
7661
  this._api = new DockviewApi(this);
7618
7662
  this.updateWatermark();
7619
7663
  }
7664
+ dispose() {
7665
+ this.clear(); // explicitly clear the layout before cleaning up
7666
+ super.dispose();
7667
+ }
7620
7668
  setVisible(panel, visible) {
7621
7669
  switch (panel.api.location.type) {
7622
7670
  case 'grid':
@@ -7675,6 +7723,7 @@ class DockviewComponent extends BaseGrid {
7675
7723
  return _window
7676
7724
  .open()
7677
7725
  .then((popoutContainer) => {
7726
+ var _a;
7678
7727
  if (_window.isDisposed) {
7679
7728
  return false;
7680
7729
  }
@@ -7707,6 +7756,7 @@ class DockviewComponent extends BaseGrid {
7707
7756
  }
7708
7757
  group.model.renderContainer = overlayRenderContainer;
7709
7758
  group.layout(_window.window.innerWidth, _window.window.innerHeight);
7759
+ let floatingBox;
7710
7760
  if (!(options === null || options === void 0 ? void 0 : options.overridePopoutGroup) && isGroupAddedToDom) {
7711
7761
  if (itemToPopout instanceof DockviewPanel) {
7712
7762
  this.movingLock(() => {
@@ -7725,6 +7775,9 @@ class DockviewComponent extends BaseGrid {
7725
7775
  break;
7726
7776
  case 'floating':
7727
7777
  case 'popout':
7778
+ floatingBox = (_a = this._floatingGroups
7779
+ .find((value) => value.group.api.id ===
7780
+ itemToPopout.api.id)) === null || _a === void 0 ? void 0 : _a.overlay.toJSON();
7728
7781
  this.removeGroup(referenceGroup);
7729
7782
  break;
7730
7783
  }
@@ -7795,17 +7848,29 @@ class DockviewComponent extends BaseGrid {
7795
7848
  }
7796
7849
  }
7797
7850
  else if (this.getPanel(group.id)) {
7798
- this.doRemoveGroup(group, {
7799
- skipDispose: true,
7800
- skipActive: true,
7801
- skipPopoutReturn: true,
7802
- });
7803
7851
  const removedGroup = group;
7804
- removedGroup.model.renderContainer =
7805
- this.overlayRenderContainer;
7806
- removedGroup.model.location = { type: 'grid' };
7807
- returnedGroup = removedGroup;
7808
- this.doAddGroup(removedGroup, [0]);
7852
+ if (floatingBox) {
7853
+ this.addFloatingGroup(removedGroup, {
7854
+ height: floatingBox.height,
7855
+ width: floatingBox.width,
7856
+ position: floatingBox,
7857
+ });
7858
+ }
7859
+ else {
7860
+ this.doRemoveGroup(removedGroup, {
7861
+ skipDispose: true,
7862
+ skipActive: true,
7863
+ skipPopoutReturn: true,
7864
+ });
7865
+ removedGroup.model.renderContainer =
7866
+ this.overlayRenderContainer;
7867
+ removedGroup.model.location = { type: 'grid' };
7868
+ returnedGroup = removedGroup;
7869
+ this.movingLock(() => {
7870
+ // suppress group add events since the group already exists
7871
+ this.doAddGroup(removedGroup, [0]);
7872
+ });
7873
+ }
7809
7874
  this.doSetGroupAndPanelActive(removedGroup);
7810
7875
  }
7811
7876
  }));
@@ -8153,6 +8218,7 @@ class DockviewComponent extends BaseGrid {
8153
8218
  locked: !!locked,
8154
8219
  hideHeader: !!hideHeader,
8155
8220
  });
8221
+ this._onDidAddGroup.fire(group);
8156
8222
  const createdPanels = [];
8157
8223
  for (const child of views) {
8158
8224
  /**
@@ -8163,7 +8229,6 @@ class DockviewComponent extends BaseGrid {
8163
8229
  const panel = this._deserializer.fromJSON(panels[child], group);
8164
8230
  createdPanels.push(panel);
8165
8231
  }
8166
- this._onDidAddGroup.fire(group);
8167
8232
  for (let i = 0; i < views.length; i++) {
8168
8233
  const panel = createdPanels[i];
8169
8234
  const isActive = typeof activeView === 'string' &&
@@ -8562,7 +8627,7 @@ class DockviewComponent extends BaseGrid {
8562
8627
  const refGroup = selectedGroup.referenceGroup
8563
8628
  ? this.getPanel(selectedGroup.referenceGroup)
8564
8629
  : undefined;
8565
- if (refGroup) {
8630
+ if (refGroup && refGroup.panels.length === 0) {
8566
8631
  this.removeGroup(refGroup);
8567
8632
  }
8568
8633
  }