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
  */
@@ -2796,7 +2796,7 @@ class BaseGrid extends Resizable {
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 @@ class DockviewGroupPanelModel extends CompositeDisposable {
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();
@@ -7399,6 +7399,47 @@ class PopoutWindow extends CompositeDisposable {
7399
7399
  }
7400
7400
  }
7401
7401
 
7402
+ class StrictEventsSequencing extends CompositeDisposable {
7403
+ constructor(accessor) {
7404
+ super();
7405
+ this.accessor = accessor;
7406
+ this.init();
7407
+ }
7408
+ init() {
7409
+ const panels = new Set();
7410
+ const groups = new Set();
7411
+ this.addDisposables(this.accessor.onDidAddPanel((panel) => {
7412
+ if (panels.has(panel.api.id)) {
7413
+ throw new Error(`dockview: Invalid event sequence. [onDidAddPanel] called for panel ${panel.api.id} but panel already exists`);
7414
+ }
7415
+ else {
7416
+ panels.add(panel.api.id);
7417
+ }
7418
+ }), this.accessor.onDidRemovePanel((panel) => {
7419
+ if (!panels.has(panel.api.id)) {
7420
+ throw new Error(`dockview: Invalid event sequence. [onDidRemovePanel] called for panel ${panel.api.id} but panel does not exists`);
7421
+ }
7422
+ else {
7423
+ panels.delete(panel.api.id);
7424
+ }
7425
+ }), this.accessor.onDidAddGroup((group) => {
7426
+ if (groups.has(group.api.id)) {
7427
+ throw new Error(`dockview: Invalid event sequence. [onDidAddGroup] called for group ${group.api.id} but group already exists`);
7428
+ }
7429
+ else {
7430
+ groups.add(group.api.id);
7431
+ }
7432
+ }), this.accessor.onDidRemoveGroup((group) => {
7433
+ if (!groups.has(group.api.id)) {
7434
+ throw new Error(`dockview: Invalid event sequence. [onDidRemoveGroup] called for group ${group.api.id} but group does not exists`);
7435
+ }
7436
+ else {
7437
+ groups.delete(group.api.id);
7438
+ }
7439
+ }));
7440
+ }
7441
+ }
7442
+
7402
7443
  const DEFAULT_ROOT_OVERLAY_MODEL = {
7403
7444
  activationSize: { type: 'pixels', value: 10 },
7404
7445
  size: { type: 'pixels', value: 20 },
@@ -7502,7 +7543,10 @@ class DockviewComponent extends BaseGrid {
7502
7543
  this.overlayRenderContainer = new OverlayRenderContainer(this.gridview.element, this);
7503
7544
  toggleClass(this.gridview.element, 'dv-dockview', true);
7504
7545
  toggleClass(this.element, 'dv-debug', !!options.debug);
7505
- 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(() => {
7546
+ if (options.debug) {
7547
+ this.addDisposables(new StrictEventsSequencing(this));
7548
+ }
7549
+ 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(() => {
7506
7550
  this.updateWatermark();
7507
7551
  }), this.onDidAdd((event) => {
7508
7552
  if (!this._moving) {
@@ -7619,6 +7663,10 @@ class DockviewComponent extends BaseGrid {
7619
7663
  this._api = new DockviewApi(this);
7620
7664
  this.updateWatermark();
7621
7665
  }
7666
+ dispose() {
7667
+ this.clear(); // explicitly clear the layout before cleaning up
7668
+ super.dispose();
7669
+ }
7622
7670
  setVisible(panel, visible) {
7623
7671
  switch (panel.api.location.type) {
7624
7672
  case 'grid':
@@ -7677,6 +7725,7 @@ class DockviewComponent extends BaseGrid {
7677
7725
  return _window
7678
7726
  .open()
7679
7727
  .then((popoutContainer) => {
7728
+ var _a;
7680
7729
  if (_window.isDisposed) {
7681
7730
  return false;
7682
7731
  }
@@ -7709,6 +7758,7 @@ class DockviewComponent extends BaseGrid {
7709
7758
  }
7710
7759
  group.model.renderContainer = overlayRenderContainer;
7711
7760
  group.layout(_window.window.innerWidth, _window.window.innerHeight);
7761
+ let floatingBox;
7712
7762
  if (!(options === null || options === void 0 ? void 0 : options.overridePopoutGroup) && isGroupAddedToDom) {
7713
7763
  if (itemToPopout instanceof DockviewPanel) {
7714
7764
  this.movingLock(() => {
@@ -7727,6 +7777,9 @@ class DockviewComponent extends BaseGrid {
7727
7777
  break;
7728
7778
  case 'floating':
7729
7779
  case 'popout':
7780
+ floatingBox = (_a = this._floatingGroups
7781
+ .find((value) => value.group.api.id ===
7782
+ itemToPopout.api.id)) === null || _a === void 0 ? void 0 : _a.overlay.toJSON();
7730
7783
  this.removeGroup(referenceGroup);
7731
7784
  break;
7732
7785
  }
@@ -7797,17 +7850,29 @@ class DockviewComponent extends BaseGrid {
7797
7850
  }
7798
7851
  }
7799
7852
  else if (this.getPanel(group.id)) {
7800
- this.doRemoveGroup(group, {
7801
- skipDispose: true,
7802
- skipActive: true,
7803
- skipPopoutReturn: true,
7804
- });
7805
7853
  const removedGroup = group;
7806
- removedGroup.model.renderContainer =
7807
- this.overlayRenderContainer;
7808
- removedGroup.model.location = { type: 'grid' };
7809
- returnedGroup = removedGroup;
7810
- this.doAddGroup(removedGroup, [0]);
7854
+ if (floatingBox) {
7855
+ this.addFloatingGroup(removedGroup, {
7856
+ height: floatingBox.height,
7857
+ width: floatingBox.width,
7858
+ position: floatingBox,
7859
+ });
7860
+ }
7861
+ else {
7862
+ this.doRemoveGroup(removedGroup, {
7863
+ skipDispose: true,
7864
+ skipActive: true,
7865
+ skipPopoutReturn: true,
7866
+ });
7867
+ removedGroup.model.renderContainer =
7868
+ this.overlayRenderContainer;
7869
+ removedGroup.model.location = { type: 'grid' };
7870
+ returnedGroup = removedGroup;
7871
+ this.movingLock(() => {
7872
+ // suppress group add events since the group already exists
7873
+ this.doAddGroup(removedGroup, [0]);
7874
+ });
7875
+ }
7811
7876
  this.doSetGroupAndPanelActive(removedGroup);
7812
7877
  }
7813
7878
  }));
@@ -8155,6 +8220,7 @@ class DockviewComponent extends BaseGrid {
8155
8220
  locked: !!locked,
8156
8221
  hideHeader: !!hideHeader,
8157
8222
  });
8223
+ this._onDidAddGroup.fire(group);
8158
8224
  const createdPanels = [];
8159
8225
  for (const child of views) {
8160
8226
  /**
@@ -8165,7 +8231,6 @@ class DockviewComponent extends BaseGrid {
8165
8231
  const panel = this._deserializer.fromJSON(panels[child], group);
8166
8232
  createdPanels.push(panel);
8167
8233
  }
8168
- this._onDidAddGroup.fire(group);
8169
8234
  for (let i = 0; i < views.length; i++) {
8170
8235
  const panel = createdPanels[i];
8171
8236
  const isActive = typeof activeView === 'string' &&
@@ -8564,7 +8629,7 @@ class DockviewComponent extends BaseGrid {
8564
8629
  const refGroup = selectedGroup.referenceGroup
8565
8630
  ? this.getPanel(selectedGroup.referenceGroup)
8566
8631
  : undefined;
8567
- if (refGroup) {
8632
+ if (refGroup && refGroup.panels.length === 0) {
8568
8633
  this.removeGroup(refGroup);
8569
8634
  }
8570
8635
  }