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
  */
@@ -254,18 +254,49 @@
254
254
  },
255
255
  };
256
256
  }
257
- class TickDelayedEvent {
257
+ /**
258
+ *
259
+ * Event Emitter that fires events from a Microtask callback, only one event will fire per event-loop cycle.
260
+ *
261
+ * It's kind of like using an `asapScheduler` in RxJs with additional logic to only fire once per event-loop cycle.
262
+ * This implementation exists to avoid external dependencies.
263
+ *
264
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/queueMicrotask
265
+ * @see https://rxjs.dev/api/index/const/asapScheduler
266
+ */
267
+ class AsapEvent {
258
268
  constructor() {
259
269
  this._onFired = new Emitter();
260
- this.onEvent = this._onFired.event;
270
+ this._currentFireCount = 0;
271
+ this._queued = false;
272
+ this.onEvent = (e) => {
273
+ /**
274
+ * when the event is first subscribed to take note of the current fire count
275
+ */
276
+ const fireCountAtTimeOfEventSubscription = this._currentFireCount;
277
+ return this._onFired.event(() => {
278
+ /**
279
+ * if the current fire count is greater than the fire count at event subscription
280
+ * then the event has been fired since we subscribed and it's ok to "on_next" the event.
281
+ *
282
+ * if the count is not greater then what we are recieving is an event from the microtask
283
+ * queue that was triggered before we actually subscribed and therfore we should ignore it.
284
+ */
285
+ if (this._currentFireCount > fireCountAtTimeOfEventSubscription) {
286
+ e();
287
+ }
288
+ });
289
+ };
261
290
  }
262
291
  fire() {
263
- if (this.timer) {
264
- clearTimeout(this.timer);
292
+ this._currentFireCount++;
293
+ if (this._queued) {
294
+ return;
265
295
  }
266
- this.timer = setTimeout(() => {
296
+ this._queued = true;
297
+ queueMicrotask(() => {
298
+ this._queued = false;
267
299
  this._onFired.fire();
268
- clearTimeout(this.timer);
269
300
  });
270
301
  }
271
302
  dispose() {
@@ -2583,15 +2614,14 @@
2583
2614
  super(document.createElement('div'), options.disableAutoResizing);
2584
2615
  this._id = nextLayoutId$1.next();
2585
2616
  this._groups = new Map();
2586
- this._onDidLayoutChange = new Emitter();
2587
- this.onDidLayoutChange = this._onDidLayoutChange.event;
2588
2617
  this._onDidRemove = new Emitter();
2589
2618
  this.onDidRemove = this._onDidRemove.event;
2590
2619
  this._onDidAdd = new Emitter();
2591
2620
  this.onDidAdd = this._onDidAdd.event;
2592
2621
  this._onDidActiveChange = new Emitter();
2593
2622
  this.onDidActiveChange = this._onDidActiveChange.event;
2594
- this._bufferOnDidLayoutChange = new TickDelayedEvent();
2623
+ this._bufferOnDidLayoutChange = new AsapEvent();
2624
+ this.onDidLayoutChange = this._bufferOnDidLayoutChange.onEvent;
2595
2625
  this.element.style.height = '100%';
2596
2626
  this.element.style.width = '100%';
2597
2627
  options.parentElement.appendChild(this.element);
@@ -2606,13 +2636,11 @@
2606
2636
  this._bufferOnDidLayoutChange.fire();
2607
2637
  }), exports.DockviewEvent.any(this.onDidAdd, this.onDidRemove, this.onDidActiveChange)(() => {
2608
2638
  this._bufferOnDidLayoutChange.fire();
2609
- }), this._bufferOnDidLayoutChange.onEvent(() => {
2610
- this._onDidLayoutChange.fire();
2611
2639
  }), this._bufferOnDidLayoutChange);
2612
2640
  }
2613
2641
  setVisible(panel, visible) {
2614
2642
  this.gridview.setViewVisible(getGridLocation(panel.element), visible);
2615
- this._onDidLayoutChange.fire();
2643
+ this._bufferOnDidLayoutChange.fire();
2616
2644
  }
2617
2645
  isVisible(panel) {
2618
2646
  return this.gridview.isViewVisible(getGridLocation(panel.element));
@@ -2718,7 +2746,6 @@
2718
2746
  this._onDidActiveChange.dispose();
2719
2747
  this._onDidAdd.dispose();
2720
2748
  this._onDidRemove.dispose();
2721
- this._onDidLayoutChange.dispose();
2722
2749
  for (const group of this.groups) {
2723
2750
  group.dispose();
2724
2751
  }
@@ -7967,7 +7994,6 @@
7967
7994
  }
7968
7995
  addGroup(options) {
7969
7996
  var _a;
7970
- const group = this.createGroup(options);
7971
7997
  if (options) {
7972
7998
  let referenceGroup;
7973
7999
  if (isGroupOptionsWithPanel(options)) {
@@ -8001,6 +8027,7 @@
8001
8027
  const target = toTarget(options.direction || 'within');
8002
8028
  const location = getGridLocation(referenceGroup.element);
8003
8029
  const relativeLocation = getRelativeLocation(this.gridview.orientation, location, target);
8030
+ const group = this.createGroup(options);
8004
8031
  this.doAddGroup(group, relativeLocation);
8005
8032
  if (!options.skipSetActive) {
8006
8033
  this.doSetGroupAndPanelActive(group);
@@ -8008,6 +8035,7 @@
8008
8035
  return group;
8009
8036
  }
8010
8037
  else {
8038
+ const group = this.createGroup(options);
8011
8039
  this.doAddGroup(group);
8012
8040
  this.doSetGroupAndPanelActive(group);
8013
8041
  return group;