dockview-core 1.13.0 → 1.13.1

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 (33) hide show
  1. package/dist/cjs/dockview/dockviewComponent.js +2 -1
  2. package/dist/cjs/events.d.ts +13 -2
  3. package/dist/cjs/events.js +44 -12
  4. package/dist/cjs/gridview/baseComponentGridview.d.ts +3 -4
  5. package/dist/cjs/gridview/baseComponentGridview.js +3 -7
  6. package/dist/dockview-core.amd.js +43 -15
  7. package/dist/dockview-core.amd.js.map +1 -1
  8. package/dist/dockview-core.amd.min.js +2 -2
  9. package/dist/dockview-core.amd.min.js.map +1 -1
  10. package/dist/dockview-core.amd.min.noStyle.js +2 -2
  11. package/dist/dockview-core.amd.min.noStyle.js.map +1 -1
  12. package/dist/dockview-core.amd.noStyle.js +43 -15
  13. package/dist/dockview-core.amd.noStyle.js.map +1 -1
  14. package/dist/dockview-core.cjs.js +43 -15
  15. package/dist/dockview-core.cjs.js.map +1 -1
  16. package/dist/dockview-core.esm.js +43 -15
  17. package/dist/dockview-core.esm.js.map +1 -1
  18. package/dist/dockview-core.esm.min.js +2 -2
  19. package/dist/dockview-core.esm.min.js.map +1 -1
  20. package/dist/dockview-core.js +43 -15
  21. package/dist/dockview-core.js.map +1 -1
  22. package/dist/dockview-core.min.js +2 -2
  23. package/dist/dockview-core.min.js.map +1 -1
  24. package/dist/dockview-core.min.noStyle.js +2 -2
  25. package/dist/dockview-core.min.noStyle.js.map +1 -1
  26. package/dist/dockview-core.noStyle.js +43 -15
  27. package/dist/dockview-core.noStyle.js.map +1 -1
  28. package/dist/esm/dockview/dockviewComponent.js +2 -1
  29. package/dist/esm/events.d.ts +13 -2
  30. package/dist/esm/events.js +37 -6
  31. package/dist/esm/gridview/baseComponentGridview.d.ts +3 -4
  32. package/dist/esm/gridview/baseComponentGridview.js +4 -8
  33. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview-core
3
- * @version 1.13.0
3
+ * @version 1.13.1
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -248,18 +248,49 @@ function addDisposableListener(element, type, listener, options) {
248
248
  },
249
249
  };
250
250
  }
251
- class TickDelayedEvent {
251
+ /**
252
+ *
253
+ * Event Emitter that fires events from a Microtask callback, only one event will fire per event-loop cycle.
254
+ *
255
+ * It's kind of like using an `asapScheduler` in RxJs with additional logic to only fire once per event-loop cycle.
256
+ * This implementation exists to avoid external dependencies.
257
+ *
258
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/queueMicrotask
259
+ * @see https://rxjs.dev/api/index/const/asapScheduler
260
+ */
261
+ class AsapEvent {
252
262
  constructor() {
253
263
  this._onFired = new Emitter();
254
- this.onEvent = this._onFired.event;
264
+ this._currentFireCount = 0;
265
+ this._queued = false;
266
+ this.onEvent = (e) => {
267
+ /**
268
+ * when the event is first subscribed to take note of the current fire count
269
+ */
270
+ const fireCountAtTimeOfEventSubscription = this._currentFireCount;
271
+ return this._onFired.event(() => {
272
+ /**
273
+ * if the current fire count is greater than the fire count at event subscription
274
+ * then the event has been fired since we subscribed and it's ok to "on_next" the event.
275
+ *
276
+ * if the count is not greater then what we are recieving is an event from the microtask
277
+ * queue that was triggered before we actually subscribed and therfore we should ignore it.
278
+ */
279
+ if (this._currentFireCount > fireCountAtTimeOfEventSubscription) {
280
+ e();
281
+ }
282
+ });
283
+ };
255
284
  }
256
285
  fire() {
257
- if (this.timer) {
258
- clearTimeout(this.timer);
286
+ this._currentFireCount++;
287
+ if (this._queued) {
288
+ return;
259
289
  }
260
- this.timer = setTimeout(() => {
290
+ this._queued = true;
291
+ queueMicrotask(() => {
292
+ this._queued = false;
261
293
  this._onFired.fire();
262
- clearTimeout(this.timer);
263
294
  });
264
295
  }
265
296
  dispose() {
@@ -2577,15 +2608,14 @@ class BaseGrid extends Resizable {
2577
2608
  super(document.createElement('div'), options.disableAutoResizing);
2578
2609
  this._id = nextLayoutId$1.next();
2579
2610
  this._groups = new Map();
2580
- this._onDidLayoutChange = new Emitter();
2581
- this.onDidLayoutChange = this._onDidLayoutChange.event;
2582
2611
  this._onDidRemove = new Emitter();
2583
2612
  this.onDidRemove = this._onDidRemove.event;
2584
2613
  this._onDidAdd = new Emitter();
2585
2614
  this.onDidAdd = this._onDidAdd.event;
2586
2615
  this._onDidActiveChange = new Emitter();
2587
2616
  this.onDidActiveChange = this._onDidActiveChange.event;
2588
- this._bufferOnDidLayoutChange = new TickDelayedEvent();
2617
+ this._bufferOnDidLayoutChange = new AsapEvent();
2618
+ this.onDidLayoutChange = this._bufferOnDidLayoutChange.onEvent;
2589
2619
  this.element.style.height = '100%';
2590
2620
  this.element.style.width = '100%';
2591
2621
  options.parentElement.appendChild(this.element);
@@ -2600,13 +2630,11 @@ class BaseGrid extends Resizable {
2600
2630
  this._bufferOnDidLayoutChange.fire();
2601
2631
  }), Event.any(this.onDidAdd, this.onDidRemove, this.onDidActiveChange)(() => {
2602
2632
  this._bufferOnDidLayoutChange.fire();
2603
- }), this._bufferOnDidLayoutChange.onEvent(() => {
2604
- this._onDidLayoutChange.fire();
2605
2633
  }), this._bufferOnDidLayoutChange);
2606
2634
  }
2607
2635
  setVisible(panel, visible) {
2608
2636
  this.gridview.setViewVisible(getGridLocation(panel.element), visible);
2609
- this._onDidLayoutChange.fire();
2637
+ this._bufferOnDidLayoutChange.fire();
2610
2638
  }
2611
2639
  isVisible(panel) {
2612
2640
  return this.gridview.isViewVisible(getGridLocation(panel.element));
@@ -2712,7 +2740,6 @@ class BaseGrid extends Resizable {
2712
2740
  this._onDidActiveChange.dispose();
2713
2741
  this._onDidAdd.dispose();
2714
2742
  this._onDidRemove.dispose();
2715
- this._onDidLayoutChange.dispose();
2716
2743
  for (const group of this.groups) {
2717
2744
  group.dispose();
2718
2745
  }
@@ -7961,7 +7988,6 @@ class DockviewComponent extends BaseGrid {
7961
7988
  }
7962
7989
  addGroup(options) {
7963
7990
  var _a;
7964
- const group = this.createGroup(options);
7965
7991
  if (options) {
7966
7992
  let referenceGroup;
7967
7993
  if (isGroupOptionsWithPanel(options)) {
@@ -7995,6 +8021,7 @@ class DockviewComponent extends BaseGrid {
7995
8021
  const target = toTarget(options.direction || 'within');
7996
8022
  const location = getGridLocation(referenceGroup.element);
7997
8023
  const relativeLocation = getRelativeLocation(this.gridview.orientation, location, target);
8024
+ const group = this.createGroup(options);
7998
8025
  this.doAddGroup(group, relativeLocation);
7999
8026
  if (!options.skipSetActive) {
8000
8027
  this.doSetGroupAndPanelActive(group);
@@ -8002,6 +8029,7 @@ class DockviewComponent extends BaseGrid {
8002
8029
  return group;
8003
8030
  }
8004
8031
  else {
8032
+ const group = this.createGroup(options);
8005
8033
  this.doAddGroup(group);
8006
8034
  this.doSetGroupAndPanelActive(group);
8007
8035
  return group;