dockview-core 1.13.0 → 1.14.0

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 (40) hide show
  1. package/dist/cjs/api/dockviewGroupPanelApi.js +4 -5
  2. package/dist/cjs/api/dockviewPanelApi.js +4 -6
  3. package/dist/cjs/dockview/dockviewComponent.js +15 -17
  4. package/dist/cjs/dockview/dockviewPanel.js +1 -10
  5. package/dist/cjs/events.d.ts +13 -2
  6. package/dist/cjs/events.js +47 -15
  7. package/dist/cjs/gridview/baseComponentGridview.d.ts +3 -4
  8. package/dist/cjs/gridview/baseComponentGridview.js +3 -7
  9. package/dist/dockview-core.amd.js +66 -53
  10. package/dist/dockview-core.amd.js.map +1 -1
  11. package/dist/dockview-core.amd.min.js +2 -2
  12. package/dist/dockview-core.amd.min.js.map +1 -1
  13. package/dist/dockview-core.amd.min.noStyle.js +2 -2
  14. package/dist/dockview-core.amd.min.noStyle.js.map +1 -1
  15. package/dist/dockview-core.amd.noStyle.js +66 -53
  16. package/dist/dockview-core.amd.noStyle.js.map +1 -1
  17. package/dist/dockview-core.cjs.js +66 -53
  18. package/dist/dockview-core.cjs.js.map +1 -1
  19. package/dist/dockview-core.esm.js +66 -53
  20. package/dist/dockview-core.esm.js.map +1 -1
  21. package/dist/dockview-core.esm.min.js +2 -2
  22. package/dist/dockview-core.esm.min.js.map +1 -1
  23. package/dist/dockview-core.js +66 -53
  24. package/dist/dockview-core.js.map +1 -1
  25. package/dist/dockview-core.min.js +2 -2
  26. package/dist/dockview-core.min.js.map +1 -1
  27. package/dist/dockview-core.min.noStyle.js +2 -2
  28. package/dist/dockview-core.min.noStyle.js.map +1 -1
  29. package/dist/dockview-core.noStyle.js +66 -53
  30. package/dist/dockview-core.noStyle.js.map +1 -1
  31. package/dist/esm/api/dockviewGroupPanelApi.js +3 -4
  32. package/dist/esm/api/dockviewPanelApi.js +4 -6
  33. package/dist/esm/dockview/components/titlebar/tabsContainer.js +1 -1
  34. package/dist/esm/dockview/dockviewComponent.js +15 -17
  35. package/dist/esm/dockview/dockviewPanel.js +1 -10
  36. package/dist/esm/events.d.ts +13 -2
  37. package/dist/esm/events.js +40 -9
  38. package/dist/esm/gridview/baseComponentGridview.d.ts +3 -4
  39. package/dist/esm/gridview/baseComponentGridview.js +4 -8
  40. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview-core
3
- * @version 1.13.0
3
+ * @version 1.14.0
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -125,7 +125,7 @@ define(['exports'], (function (exports) { 'use strict';
125
125
  this.value = value;
126
126
  }
127
127
  print() {
128
- console.warn(this.value);
128
+ console.warn('dockview: stacktrace', this.value);
129
129
  }
130
130
  }
131
131
  class Listener {
@@ -190,7 +190,7 @@ define(['exports'], (function (exports) { 'use strict';
190
190
  var _a;
191
191
  // don't check until stack of execution is completed to allow for out-of-order disposals within the same execution block
192
192
  for (const listener of this._listeners) {
193
- console.warn((_a = listener.stacktrace) === null || _a === void 0 ? void 0 : _a.print());
193
+ console.warn('dockview: stacktrace', (_a = listener.stacktrace) === null || _a === void 0 ? void 0 : _a.print());
194
194
  }
195
195
  });
196
196
  }
@@ -220,18 +220,49 @@ define(['exports'], (function (exports) { 'use strict';
220
220
  },
221
221
  };
222
222
  }
223
- class TickDelayedEvent {
223
+ /**
224
+ *
225
+ * Event Emitter that fires events from a Microtask callback, only one event will fire per event-loop cycle.
226
+ *
227
+ * It's kind of like using an `asapScheduler` in RxJs with additional logic to only fire once per event-loop cycle.
228
+ * This implementation exists to avoid external dependencies.
229
+ *
230
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/queueMicrotask
231
+ * @see https://rxjs.dev/api/index/const/asapScheduler
232
+ */
233
+ class AsapEvent {
224
234
  constructor() {
225
235
  this._onFired = new Emitter();
226
- this.onEvent = this._onFired.event;
236
+ this._currentFireCount = 0;
237
+ this._queued = false;
238
+ this.onEvent = (e) => {
239
+ /**
240
+ * when the event is first subscribed to take note of the current fire count
241
+ */
242
+ const fireCountAtTimeOfEventSubscription = this._currentFireCount;
243
+ return this._onFired.event(() => {
244
+ /**
245
+ * if the current fire count is greater than the fire count at event subscription
246
+ * then the event has been fired since we subscribed and it's ok to "on_next" the event.
247
+ *
248
+ * if the count is not greater then what we are recieving is an event from the microtask
249
+ * queue that was triggered before we actually subscribed and therfore we should ignore it.
250
+ */
251
+ if (this._currentFireCount > fireCountAtTimeOfEventSubscription) {
252
+ e();
253
+ }
254
+ });
255
+ };
227
256
  }
228
257
  fire() {
229
- if (this.timer) {
230
- clearTimeout(this.timer);
258
+ this._currentFireCount++;
259
+ if (this._queued) {
260
+ return;
231
261
  }
232
- this.timer = setTimeout(() => {
262
+ this._queued = true;
263
+ queueMicrotask(() => {
264
+ this._queued = false;
233
265
  this._onFired.fire();
234
- clearTimeout(this.timer);
235
266
  });
236
267
  }
237
268
  dispose() {
@@ -2549,15 +2580,14 @@ define(['exports'], (function (exports) { 'use strict';
2549
2580
  super(document.createElement('div'), options.disableAutoResizing);
2550
2581
  this._id = nextLayoutId$1.next();
2551
2582
  this._groups = new Map();
2552
- this._onDidLayoutChange = new Emitter();
2553
- this.onDidLayoutChange = this._onDidLayoutChange.event;
2554
2583
  this._onDidRemove = new Emitter();
2555
2584
  this.onDidRemove = this._onDidRemove.event;
2556
2585
  this._onDidAdd = new Emitter();
2557
2586
  this.onDidAdd = this._onDidAdd.event;
2558
2587
  this._onDidActiveChange = new Emitter();
2559
2588
  this.onDidActiveChange = this._onDidActiveChange.event;
2560
- this._bufferOnDidLayoutChange = new TickDelayedEvent();
2589
+ this._bufferOnDidLayoutChange = new AsapEvent();
2590
+ this.onDidLayoutChange = this._bufferOnDidLayoutChange.onEvent;
2561
2591
  this.element.style.height = '100%';
2562
2592
  this.element.style.width = '100%';
2563
2593
  options.parentElement.appendChild(this.element);
@@ -2572,13 +2602,11 @@ define(['exports'], (function (exports) { 'use strict';
2572
2602
  this._bufferOnDidLayoutChange.fire();
2573
2603
  }), exports.DockviewEvent.any(this.onDidAdd, this.onDidRemove, this.onDidActiveChange)(() => {
2574
2604
  this._bufferOnDidLayoutChange.fire();
2575
- }), this._bufferOnDidLayoutChange.onEvent(() => {
2576
- this._onDidLayoutChange.fire();
2577
2605
  }), this._bufferOnDidLayoutChange);
2578
2606
  }
2579
2607
  setVisible(panel, visible) {
2580
2608
  this.gridview.setViewVisible(getGridLocation(panel.element), visible);
2581
- this._onDidLayoutChange.fire();
2609
+ this._bufferOnDidLayoutChange.fire();
2582
2610
  }
2583
2611
  isVisible(panel) {
2584
2612
  return this.gridview.isViewVisible(getGridLocation(panel.element));
@@ -2684,7 +2712,6 @@ define(['exports'], (function (exports) { 'use strict';
2684
2712
  this._onDidActiveChange.dispose();
2685
2713
  this._onDidAdd.dispose();
2686
2714
  this._onDidRemove.dispose();
2687
- this._onDidLayoutChange.dispose();
2688
2715
  for (const group of this.groups) {
2689
2716
  group.dispose();
2690
2717
  }
@@ -5713,8 +5740,7 @@ define(['exports'], (function (exports) { 'use strict';
5713
5740
  }
5714
5741
  }
5715
5742
 
5716
- // TODO find a better way to initialize and avoid needing null checks
5717
- const NOT_INITIALIZED_MESSAGE = 'DockviewGroupPanelApiImpl not initialized';
5743
+ const NOT_INITIALIZED_MESSAGE = 'dockview: DockviewGroupPanelApiImpl not initialized';
5718
5744
  class DockviewGroupPanelApiImpl extends GridviewPanelApiImpl {
5719
5745
  get location() {
5720
5746
  if (!this._group) {
@@ -5787,14 +5813,14 @@ define(['exports'], (function (exports) { 'use strict';
5787
5813
  }
5788
5814
  }
5789
5815
  initialize(group) {
5790
- this._group = group;
5791
5816
  /**
5792
- * TODO: Annoying initialization order caveat
5817
+ * TODO: Annoying initialization order caveat, find a better way to initialize and avoid needing null checks
5793
5818
  *
5794
5819
  * Due to the order on initialization we know that the model isn't defined until later in the same stack-frame of setup.
5795
5820
  * By queuing a microtask we can ensure the setup is completed within the same stack-frame, but after everything else has
5796
5821
  * finished ensuring the `model` is defined.
5797
5822
  */
5823
+ this._group = group;
5798
5824
  queueMicrotask(() => {
5799
5825
  this._mutableDisposable.value =
5800
5826
  this._group.model.onDidActivePanelChange((event) => {
@@ -5948,12 +5974,10 @@ define(['exports'], (function (exports) { 'use strict';
5948
5974
  var _a;
5949
5975
  let _trackGroupActive = (_a = previousGroup === null || previousGroup === void 0 ? void 0 : previousGroup.isActive) !== null && _a !== void 0 ? _a : false; // prevent duplicate events with same state
5950
5976
  this.groupEventsDisposable.value = new CompositeDisposable(this.group.api.onDidVisibilityChange((event) => {
5951
- if (!event.isVisible && this.isVisible) {
5952
- this._onDidVisibilityChange.fire(event);
5953
- }
5954
- else if (event.isVisible &&
5955
- !this.isVisible &&
5956
- this.group.model.isPanelActive(this.panel)) {
5977
+ const hasBecomeHidden = !event.isVisible && this.isVisible;
5978
+ const hasBecomeVisible = event.isVisible && !this.isVisible;
5979
+ const isActivePanel = this.group.model.isPanelActive(this.panel);
5980
+ if (hasBecomeHidden || (hasBecomeVisible && isActivePanel)) {
5957
5981
  this._onDidVisibilityChange.fire(event);
5958
5982
  }
5959
5983
  }), this.group.api.onDidLocationChange((event) => {
@@ -6039,12 +6063,6 @@ define(['exports'], (function (exports) { 'use strict';
6039
6063
  const didTitleChange = title !== this.title;
6040
6064
  if (didTitleChange) {
6041
6065
  this._title = title;
6042
- this.view.update({
6043
- params: {
6044
- params: this._params,
6045
- title: this.title,
6046
- },
6047
- });
6048
6066
  this.api._onDidTitleChange.fire({ title });
6049
6067
  }
6050
6068
  }
@@ -6072,10 +6090,7 @@ define(['exports'], (function (exports) { 'use strict';
6072
6090
  }
6073
6091
  // update the view with the updated props
6074
6092
  this.view.update({
6075
- params: {
6076
- params: this._params,
6077
- title: this.title,
6078
- },
6093
+ params: this._params,
6079
6094
  });
6080
6095
  }
6081
6096
  updateParentGroup(group, options) {
@@ -7213,7 +7228,7 @@ define(['exports'], (function (exports) { 'use strict';
7213
7228
  return element.getBoundingClientRect();
7214
7229
  }
7215
7230
  const box = getBox();
7216
- const groupId = (_b = (_a = options === null || options === void 0 ? void 0 : options.overridePopoutGroup) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : this.getNextGroupId(); //item.id;
7231
+ const groupId = (_b = (_a = options === null || options === void 0 ? void 0 : options.overridePopoutGroup) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : this.getNextGroupId();
7217
7232
  if (itemToPopout.api.location.type === 'grid') {
7218
7233
  itemToPopout.api.setVisible(false);
7219
7234
  }
@@ -7329,24 +7344,22 @@ define(['exports'], (function (exports) { 'use strict';
7329
7344
  });
7330
7345
  }
7331
7346
  }
7332
- else {
7333
- if (this.getPanel(group.id)) {
7334
- const removedGroup = this.doRemoveGroup(group, {
7335
- skipDispose: true,
7336
- skipActive: true,
7337
- });
7338
- removedGroup.model.renderContainer =
7339
- this.overlayRenderContainer;
7340
- removedGroup.model.location = { type: 'grid' };
7341
- returnedGroup = removedGroup;
7342
- }
7347
+ else if (this.getPanel(group.id)) {
7348
+ const removedGroup = this.doRemoveGroup(group, {
7349
+ skipDispose: true,
7350
+ skipActive: true,
7351
+ });
7352
+ removedGroup.model.renderContainer =
7353
+ this.overlayRenderContainer;
7354
+ removedGroup.model.location = { type: 'grid' };
7355
+ returnedGroup = removedGroup;
7343
7356
  }
7344
7357
  }));
7345
7358
  this._popoutGroups.push(value);
7346
7359
  this.updateWatermark();
7347
7360
  })
7348
7361
  .catch((err) => {
7349
- console.error(err);
7362
+ console.error('dockview: failed to create popout window', err);
7350
7363
  });
7351
7364
  }
7352
7365
  addFloatingGroup(item, coord, options) {
@@ -7389,7 +7402,7 @@ define(['exports'], (function (exports) { 'use strict';
7389
7402
  this.doRemoveGroup(item, {
7390
7403
  skipDispose: true,
7391
7404
  skipPopoutReturn: true,
7392
- skipPopoutAssociated: !!popoutReferenceGroup,
7405
+ skipPopoutAssociated: false,
7393
7406
  });
7394
7407
  }
7395
7408
  }
@@ -7749,7 +7762,6 @@ define(['exports'], (function (exports) { 'use strict';
7749
7762
  clear() {
7750
7763
  const groups = Array.from(this._groups.values()).map((_) => _.value);
7751
7764
  const hasActiveGroup = !!this.activeGroup;
7752
- !!this.activePanel;
7753
7765
  for (const group of groups) {
7754
7766
  // remove the group will automatically remove the panels
7755
7767
  this.removeGroup(group, { skipActive: true });
@@ -7933,7 +7945,6 @@ define(['exports'], (function (exports) { 'use strict';
7933
7945
  }
7934
7946
  addGroup(options) {
7935
7947
  var _a;
7936
- const group = this.createGroup(options);
7937
7948
  if (options) {
7938
7949
  let referenceGroup;
7939
7950
  if (isGroupOptionsWithPanel(options)) {
@@ -7967,6 +7978,7 @@ define(['exports'], (function (exports) { 'use strict';
7967
7978
  const target = toTarget(options.direction || 'within');
7968
7979
  const location = getGridLocation(referenceGroup.element);
7969
7980
  const relativeLocation = getRelativeLocation(this.gridview.orientation, location, target);
7981
+ const group = this.createGroup(options);
7970
7982
  this.doAddGroup(group, relativeLocation);
7971
7983
  if (!options.skipSetActive) {
7972
7984
  this.doSetGroupAndPanelActive(group);
@@ -7974,6 +7986,7 @@ define(['exports'], (function (exports) { 'use strict';
7974
7986
  return group;
7975
7987
  }
7976
7988
  else {
7989
+ const group = this.createGroup(options);
7977
7990
  this.doAddGroup(group);
7978
7991
  this.doSetGroupAndPanelActive(group);
7979
7992
  return group;
@@ -8254,7 +8267,7 @@ define(['exports'], (function (exports) { 'use strict';
8254
8267
  }
8255
8268
  let id = options === null || options === void 0 ? void 0 : options.id;
8256
8269
  if (id && this._groups.has(options.id)) {
8257
- console.warn(`Duplicate group id ${options === null || options === void 0 ? void 0 : options.id}. reassigning group id to avoid errors`);
8270
+ console.warn(`dockview: Duplicate group id ${options === null || options === void 0 ? void 0 : options.id}. reassigning group id to avoid errors`);
8258
8271
  id = undefined;
8259
8272
  }
8260
8273
  if (!id) {