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
  */
@@ -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
  }
@@ -7937,7 +7964,6 @@
7937
7964
  }
7938
7965
  addGroup(options) {
7939
7966
  var _a;
7940
- const group = this.createGroup(options);
7941
7967
  if (options) {
7942
7968
  let referenceGroup;
7943
7969
  if (isGroupOptionsWithPanel(options)) {
@@ -7971,6 +7997,7 @@
7971
7997
  const target = toTarget(options.direction || 'within');
7972
7998
  const location = getGridLocation(referenceGroup.element);
7973
7999
  const relativeLocation = getRelativeLocation(this.gridview.orientation, location, target);
8000
+ const group = this.createGroup(options);
7974
8001
  this.doAddGroup(group, relativeLocation);
7975
8002
  if (!options.skipSetActive) {
7976
8003
  this.doSetGroupAndPanelActive(group);
@@ -7978,6 +8005,7 @@
7978
8005
  return group;
7979
8006
  }
7980
8007
  else {
8008
+ const group = this.createGroup(options);
7981
8009
  this.doAddGroup(group);
7982
8010
  this.doSetGroupAndPanelActive(group);
7983
8011
  return group;