dockview 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.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview
3
- * @version 1.13.0
3
+ * @version 1.13.1
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -224,18 +224,49 @@
224
224
  },
225
225
  };
226
226
  }
227
- class TickDelayedEvent {
227
+ /**
228
+ *
229
+ * Event Emitter that fires events from a Microtask callback, only one event will fire per event-loop cycle.
230
+ *
231
+ * It's kind of like using an `asapScheduler` in RxJs with additional logic to only fire once per event-loop cycle.
232
+ * This implementation exists to avoid external dependencies.
233
+ *
234
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/queueMicrotask
235
+ * @see https://rxjs.dev/api/index/const/asapScheduler
236
+ */
237
+ class AsapEvent {
228
238
  constructor() {
229
239
  this._onFired = new Emitter();
230
- this.onEvent = this._onFired.event;
240
+ this._currentFireCount = 0;
241
+ this._queued = false;
242
+ this.onEvent = (e) => {
243
+ /**
244
+ * when the event is first subscribed to take note of the current fire count
245
+ */
246
+ const fireCountAtTimeOfEventSubscription = this._currentFireCount;
247
+ return this._onFired.event(() => {
248
+ /**
249
+ * if the current fire count is greater than the fire count at event subscription
250
+ * then the event has been fired since we subscribed and it's ok to "on_next" the event.
251
+ *
252
+ * if the count is not greater then what we are recieving is an event from the microtask
253
+ * queue that was triggered before we actually subscribed and therfore we should ignore it.
254
+ */
255
+ if (this._currentFireCount > fireCountAtTimeOfEventSubscription) {
256
+ e();
257
+ }
258
+ });
259
+ };
231
260
  }
232
261
  fire() {
233
- if (this.timer) {
234
- clearTimeout(this.timer);
262
+ this._currentFireCount++;
263
+ if (this._queued) {
264
+ return;
235
265
  }
236
- this.timer = setTimeout(() => {
266
+ this._queued = true;
267
+ queueMicrotask(() => {
268
+ this._queued = false;
237
269
  this._onFired.fire();
238
- clearTimeout(this.timer);
239
270
  });
240
271
  }
241
272
  dispose() {
@@ -2553,15 +2584,14 @@
2553
2584
  super(document.createElement('div'), options.disableAutoResizing);
2554
2585
  this._id = nextLayoutId$1.next();
2555
2586
  this._groups = new Map();
2556
- this._onDidLayoutChange = new Emitter();
2557
- this.onDidLayoutChange = this._onDidLayoutChange.event;
2558
2587
  this._onDidRemove = new Emitter();
2559
2588
  this.onDidRemove = this._onDidRemove.event;
2560
2589
  this._onDidAdd = new Emitter();
2561
2590
  this.onDidAdd = this._onDidAdd.event;
2562
2591
  this._onDidActiveChange = new Emitter();
2563
2592
  this.onDidActiveChange = this._onDidActiveChange.event;
2564
- this._bufferOnDidLayoutChange = new TickDelayedEvent();
2593
+ this._bufferOnDidLayoutChange = new AsapEvent();
2594
+ this.onDidLayoutChange = this._bufferOnDidLayoutChange.onEvent;
2565
2595
  this.element.style.height = '100%';
2566
2596
  this.element.style.width = '100%';
2567
2597
  options.parentElement.appendChild(this.element);
@@ -2576,13 +2606,11 @@
2576
2606
  this._bufferOnDidLayoutChange.fire();
2577
2607
  }), exports.DockviewEvent.any(this.onDidAdd, this.onDidRemove, this.onDidActiveChange)(() => {
2578
2608
  this._bufferOnDidLayoutChange.fire();
2579
- }), this._bufferOnDidLayoutChange.onEvent(() => {
2580
- this._onDidLayoutChange.fire();
2581
2609
  }), this._bufferOnDidLayoutChange);
2582
2610
  }
2583
2611
  setVisible(panel, visible) {
2584
2612
  this.gridview.setViewVisible(getGridLocation(panel.element), visible);
2585
- this._onDidLayoutChange.fire();
2613
+ this._bufferOnDidLayoutChange.fire();
2586
2614
  }
2587
2615
  isVisible(panel) {
2588
2616
  return this.gridview.isViewVisible(getGridLocation(panel.element));
@@ -2688,7 +2716,6 @@
2688
2716
  this._onDidActiveChange.dispose();
2689
2717
  this._onDidAdd.dispose();
2690
2718
  this._onDidRemove.dispose();
2691
- this._onDidLayoutChange.dispose();
2692
2719
  for (const group of this.groups) {
2693
2720
  group.dispose();
2694
2721
  }
@@ -7914,7 +7941,6 @@
7914
7941
  }
7915
7942
  addGroup(options) {
7916
7943
  var _a;
7917
- const group = this.createGroup(options);
7918
7944
  if (options) {
7919
7945
  let referenceGroup;
7920
7946
  if (isGroupOptionsWithPanel(options)) {
@@ -7948,6 +7974,7 @@
7948
7974
  const target = toTarget(options.direction || 'within');
7949
7975
  const location = getGridLocation(referenceGroup.element);
7950
7976
  const relativeLocation = getRelativeLocation(this.gridview.orientation, location, target);
7977
+ const group = this.createGroup(options);
7951
7978
  this.doAddGroup(group, relativeLocation);
7952
7979
  if (!options.skipSetActive) {
7953
7980
  this.doSetGroupAndPanelActive(group);
@@ -7955,6 +7982,7 @@
7955
7982
  return group;
7956
7983
  }
7957
7984
  else {
7985
+ const group = this.createGroup(options);
7958
7986
  this.doAddGroup(group);
7959
7987
  this.doSetGroupAndPanelActive(group);
7960
7988
  return group;