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
  */
@@ -2800,7 +2800,7 @@
2800
2800
  this._bufferOnDidLayoutChange.fire();
2801
2801
  }), exports.DockviewEvent.any(this.onDidAdd, this.onDidRemove, this.onDidActiveChange)(() => {
2802
2802
  this._bufferOnDidLayoutChange.fire();
2803
- }), this._bufferOnDidLayoutChange);
2803
+ }), this._onDidMaximizedChange, this._onDidViewVisibilityChangeMicroTaskQueue, this._bufferOnDidLayoutChange);
2804
2804
  }
2805
2805
  setVisible(panel, visible) {
2806
2806
  this.gridview.setViewVisible(getGridLocation(panel.element), visible);
@@ -5401,7 +5401,7 @@
5401
5401
  group: this.groupPanel,
5402
5402
  getData: getPanelData,
5403
5403
  }));
5404
- }), this._onMove, this._onDidChange, this._onDidDrop, this._onWillDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange, this._onUnhandledDragOverEvent);
5404
+ }), this._onMove, this._onDidChange, this._onDidDrop, this._onWillDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange, this._onUnhandledDragOverEvent, this._onDidPanelTitleChange, this._onDidPanelParametersChange);
5405
5405
  }
5406
5406
  focusContent() {
5407
5407
  this.contentContainer.element.focus();
@@ -7403,6 +7403,47 @@
7403
7403
  }
7404
7404
  }
7405
7405
 
7406
+ class StrictEventsSequencing extends CompositeDisposable {
7407
+ constructor(accessor) {
7408
+ super();
7409
+ this.accessor = accessor;
7410
+ this.init();
7411
+ }
7412
+ init() {
7413
+ const panels = new Set();
7414
+ const groups = new Set();
7415
+ this.addDisposables(this.accessor.onDidAddPanel((panel) => {
7416
+ if (panels.has(panel.api.id)) {
7417
+ throw new Error(`dockview: Invalid event sequence. [onDidAddPanel] called for panel ${panel.api.id} but panel already exists`);
7418
+ }
7419
+ else {
7420
+ panels.add(panel.api.id);
7421
+ }
7422
+ }), this.accessor.onDidRemovePanel((panel) => {
7423
+ if (!panels.has(panel.api.id)) {
7424
+ throw new Error(`dockview: Invalid event sequence. [onDidRemovePanel] called for panel ${panel.api.id} but panel does not exists`);
7425
+ }
7426
+ else {
7427
+ panels.delete(panel.api.id);
7428
+ }
7429
+ }), this.accessor.onDidAddGroup((group) => {
7430
+ if (groups.has(group.api.id)) {
7431
+ throw new Error(`dockview: Invalid event sequence. [onDidAddGroup] called for group ${group.api.id} but group already exists`);
7432
+ }
7433
+ else {
7434
+ groups.add(group.api.id);
7435
+ }
7436
+ }), this.accessor.onDidRemoveGroup((group) => {
7437
+ if (!groups.has(group.api.id)) {
7438
+ throw new Error(`dockview: Invalid event sequence. [onDidRemoveGroup] called for group ${group.api.id} but group does not exists`);
7439
+ }
7440
+ else {
7441
+ groups.delete(group.api.id);
7442
+ }
7443
+ }));
7444
+ }
7445
+ }
7446
+
7406
7447
  const DEFAULT_ROOT_OVERLAY_MODEL = {
7407
7448
  activationSize: { type: 'pixels', value: 10 },
7408
7449
  size: { type: 'pixels', value: 20 },
@@ -7506,7 +7547,10 @@
7506
7547
  this.overlayRenderContainer = new OverlayRenderContainer(this.gridview.element, this);
7507
7548
  toggleClass(this.gridview.element, 'dv-dockview', true);
7508
7549
  toggleClass(this.element, 'dv-debug', !!options.debug);
7509
- 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(() => {
7550
+ if (options.debug) {
7551
+ this.addDisposables(new StrictEventsSequencing(this));
7552
+ }
7553
+ 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(() => {
7510
7554
  this.updateWatermark();
7511
7555
  }), this.onDidAdd((event) => {
7512
7556
  if (!this._moving) {
@@ -7623,6 +7667,10 @@
7623
7667
  this._api = new DockviewApi(this);
7624
7668
  this.updateWatermark();
7625
7669
  }
7670
+ dispose() {
7671
+ this.clear(); // explicitly clear the layout before cleaning up
7672
+ super.dispose();
7673
+ }
7626
7674
  setVisible(panel, visible) {
7627
7675
  switch (panel.api.location.type) {
7628
7676
  case 'grid':
@@ -7681,6 +7729,7 @@
7681
7729
  return _window
7682
7730
  .open()
7683
7731
  .then((popoutContainer) => {
7732
+ var _a;
7684
7733
  if (_window.isDisposed) {
7685
7734
  return false;
7686
7735
  }
@@ -7713,6 +7762,7 @@
7713
7762
  }
7714
7763
  group.model.renderContainer = overlayRenderContainer;
7715
7764
  group.layout(_window.window.innerWidth, _window.window.innerHeight);
7765
+ let floatingBox;
7716
7766
  if (!(options === null || options === void 0 ? void 0 : options.overridePopoutGroup) && isGroupAddedToDom) {
7717
7767
  if (itemToPopout instanceof DockviewPanel) {
7718
7768
  this.movingLock(() => {
@@ -7731,6 +7781,9 @@
7731
7781
  break;
7732
7782
  case 'floating':
7733
7783
  case 'popout':
7784
+ floatingBox = (_a = this._floatingGroups
7785
+ .find((value) => value.group.api.id ===
7786
+ itemToPopout.api.id)) === null || _a === void 0 ? void 0 : _a.overlay.toJSON();
7734
7787
  this.removeGroup(referenceGroup);
7735
7788
  break;
7736
7789
  }
@@ -7801,17 +7854,29 @@
7801
7854
  }
7802
7855
  }
7803
7856
  else if (this.getPanel(group.id)) {
7804
- this.doRemoveGroup(group, {
7805
- skipDispose: true,
7806
- skipActive: true,
7807
- skipPopoutReturn: true,
7808
- });
7809
7857
  const removedGroup = group;
7810
- removedGroup.model.renderContainer =
7811
- this.overlayRenderContainer;
7812
- removedGroup.model.location = { type: 'grid' };
7813
- returnedGroup = removedGroup;
7814
- this.doAddGroup(removedGroup, [0]);
7858
+ if (floatingBox) {
7859
+ this.addFloatingGroup(removedGroup, {
7860
+ height: floatingBox.height,
7861
+ width: floatingBox.width,
7862
+ position: floatingBox,
7863
+ });
7864
+ }
7865
+ else {
7866
+ this.doRemoveGroup(removedGroup, {
7867
+ skipDispose: true,
7868
+ skipActive: true,
7869
+ skipPopoutReturn: true,
7870
+ });
7871
+ removedGroup.model.renderContainer =
7872
+ this.overlayRenderContainer;
7873
+ removedGroup.model.location = { type: 'grid' };
7874
+ returnedGroup = removedGroup;
7875
+ this.movingLock(() => {
7876
+ // suppress group add events since the group already exists
7877
+ this.doAddGroup(removedGroup, [0]);
7878
+ });
7879
+ }
7815
7880
  this.doSetGroupAndPanelActive(removedGroup);
7816
7881
  }
7817
7882
  }));
@@ -8159,6 +8224,7 @@
8159
8224
  locked: !!locked,
8160
8225
  hideHeader: !!hideHeader,
8161
8226
  });
8227
+ this._onDidAddGroup.fire(group);
8162
8228
  const createdPanels = [];
8163
8229
  for (const child of views) {
8164
8230
  /**
@@ -8169,7 +8235,6 @@
8169
8235
  const panel = this._deserializer.fromJSON(panels[child], group);
8170
8236
  createdPanels.push(panel);
8171
8237
  }
8172
- this._onDidAddGroup.fire(group);
8173
8238
  for (let i = 0; i < views.length; i++) {
8174
8239
  const panel = createdPanels[i];
8175
8240
  const isActive = typeof activeView === 'string' &&
@@ -8568,7 +8633,7 @@
8568
8633
  const refGroup = selectedGroup.referenceGroup
8569
8634
  ? this.getPanel(selectedGroup.referenceGroup)
8570
8635
  : undefined;
8571
- if (refGroup) {
8636
+ if (refGroup && refGroup.panels.length === 0) {
8572
8637
  this.removeGroup(refGroup);
8573
8638
  }
8574
8639
  }