dockview 1.13.1 → 1.14.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.1
3
+ * @version 1.14.1
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -129,7 +129,7 @@
129
129
  this.value = value;
130
130
  }
131
131
  print() {
132
- console.warn(this.value);
132
+ console.warn('dockview: stacktrace', this.value);
133
133
  }
134
134
  }
135
135
  class Listener {
@@ -194,7 +194,7 @@
194
194
  var _a;
195
195
  // don't check until stack of execution is completed to allow for out-of-order disposals within the same execution block
196
196
  for (const listener of this._listeners) {
197
- console.warn((_a = listener.stacktrace) === null || _a === void 0 ? void 0 : _a.print());
197
+ console.warn('dockview: stacktrace', (_a = listener.stacktrace) === null || _a === void 0 ? void 0 : _a.print());
198
198
  }
199
199
  });
200
200
  }
@@ -274,7 +274,7 @@
274
274
  }
275
275
  }
276
276
 
277
- var Disposable;
277
+ exports.DockviewDisposable = void 0;
278
278
  (function (Disposable) {
279
279
  Disposable.NONE = {
280
280
  dispose: () => {
@@ -289,7 +289,7 @@
289
289
  };
290
290
  }
291
291
  Disposable.from = from;
292
- })(Disposable || (Disposable = {}));
292
+ })(exports.DockviewDisposable || (exports.DockviewDisposable = {}));
293
293
  class CompositeDisposable {
294
294
  get isDisposed() {
295
295
  return this._isDisposed;
@@ -312,7 +312,7 @@
312
312
  }
313
313
  class MutableDisposable {
314
314
  constructor() {
315
- this._disposable = Disposable.NONE;
315
+ this._disposable = exports.DockviewDisposable.NONE;
316
316
  }
317
317
  set value(disposable) {
318
318
  if (this._disposable) {
@@ -323,7 +323,7 @@
323
323
  dispose() {
324
324
  if (this._disposable) {
325
325
  this._disposable.dispose();
326
- this._disposable = Disposable.NONE;
326
+ this._disposable = exports.DockviewDisposable.NONE;
327
327
  }
328
328
  }
329
329
  }
@@ -1750,7 +1750,7 @@
1750
1750
  this.orientation = orientation;
1751
1751
  this.proportionalLayout = proportionalLayout;
1752
1752
  this.styles = styles;
1753
- this._childrenDisposable = Disposable.NONE;
1753
+ this._childrenDisposable = exports.DockviewDisposable.NONE;
1754
1754
  this.children = [];
1755
1755
  this._onDidChange = new Emitter();
1756
1756
  this.onDidChange = this._onDidChange.event;
@@ -1898,7 +1898,7 @@
1898
1898
  this.setChildVisible(i, visible);
1899
1899
  });
1900
1900
  }
1901
- return Disposable.NONE;
1901
+ return exports.DockviewDisposable.NONE;
1902
1902
  }));
1903
1903
  }
1904
1904
  dispose() {
@@ -2599,7 +2599,7 @@
2599
2599
  this.gridview.locked = !!options.locked;
2600
2600
  this.element.appendChild(this.gridview.element);
2601
2601
  this.layout(0, 0, true); // set some elements height/widths
2602
- this.addDisposables(Disposable.from(() => {
2602
+ this.addDisposables(exports.DockviewDisposable.from(() => {
2603
2603
  var _a;
2604
2604
  (_a = this.element.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(this.element);
2605
2605
  }), this.gridview.onDidChange(() => {
@@ -5744,8 +5744,7 @@
5744
5744
  }
5745
5745
  }
5746
5746
 
5747
- // TODO find a better way to initialize and avoid needing null checks
5748
- const NOT_INITIALIZED_MESSAGE = 'DockviewGroupPanelApiImpl not initialized';
5747
+ const NOT_INITIALIZED_MESSAGE = 'dockview: DockviewGroupPanelApiImpl not initialized';
5749
5748
  class DockviewGroupPanelApiImpl extends GridviewPanelApiImpl {
5750
5749
  get location() {
5751
5750
  if (!this._group) {
@@ -5818,14 +5817,14 @@
5818
5817
  }
5819
5818
  }
5820
5819
  initialize(group) {
5821
- this._group = group;
5822
5820
  /**
5823
- * TODO: Annoying initialization order caveat
5821
+ * TODO: Annoying initialization order caveat, find a better way to initialize and avoid needing null checks
5824
5822
  *
5825
5823
  * Due to the order on initialization we know that the model isn't defined until later in the same stack-frame of setup.
5826
5824
  * By queuing a microtask we can ensure the setup is completed within the same stack-frame, but after everything else has
5827
5825
  * finished ensuring the `model` is defined.
5828
5826
  */
5827
+ this._group = group;
5829
5828
  queueMicrotask(() => {
5830
5829
  this._mutableDisposable.value =
5831
5830
  this._group.model.onDidActivePanelChange((event) => {
@@ -5979,12 +5978,10 @@
5979
5978
  var _a;
5980
5979
  let _trackGroupActive = (_a = previousGroup === null || previousGroup === void 0 ? void 0 : previousGroup.isActive) !== null && _a !== void 0 ? _a : false; // prevent duplicate events with same state
5981
5980
  this.groupEventsDisposable.value = new CompositeDisposable(this.group.api.onDidVisibilityChange((event) => {
5982
- if (!event.isVisible && this.isVisible) {
5983
- this._onDidVisibilityChange.fire(event);
5984
- }
5985
- else if (event.isVisible &&
5986
- !this.isVisible &&
5987
- this.group.model.isPanelActive(this.panel)) {
5981
+ const hasBecomeHidden = !event.isVisible && this.isVisible;
5982
+ const hasBecomeVisible = event.isVisible && !this.isVisible;
5983
+ const isActivePanel = this.group.model.isPanelActive(this.panel);
5984
+ if (hasBecomeHidden || (hasBecomeVisible && isActivePanel)) {
5988
5985
  this._onDidVisibilityChange.fire(event);
5989
5986
  }
5990
5987
  }), this.group.api.onDidLocationChange((event) => {
@@ -6070,12 +6067,6 @@
6070
6067
  const didTitleChange = title !== this.title;
6071
6068
  if (didTitleChange) {
6072
6069
  this._title = title;
6073
- this.view.update({
6074
- params: {
6075
- params: this._params,
6076
- title: this.title,
6077
- },
6078
- });
6079
6070
  this.api._onDidTitleChange.fire({ title });
6080
6071
  }
6081
6072
  }
@@ -6103,10 +6094,7 @@
6103
6094
  }
6104
6095
  // update the view with the updated props
6105
6096
  this.view.update({
6106
- params: {
6107
- params: this._params,
6108
- title: this.title,
6109
- },
6097
+ params: this._params,
6110
6098
  });
6111
6099
  }
6112
6100
  updateParentGroup(group, options) {
@@ -6719,7 +6707,7 @@
6719
6707
  this.element = element;
6720
6708
  this.map = {};
6721
6709
  this._disposed = false;
6722
- this.addDisposables(Disposable.from(() => {
6710
+ this.addDisposables(exports.DockviewDisposable.from(() => {
6723
6711
  for (const value of Object.values(this.map)) {
6724
6712
  value.disposable.dispose();
6725
6713
  value.destroy.dispose();
@@ -6744,8 +6732,8 @@
6744
6732
  element.className = 'dv-render-overlay';
6745
6733
  this.map[panel.api.id] = {
6746
6734
  panel,
6747
- disposable: Disposable.NONE,
6748
- destroy: Disposable.NONE,
6735
+ disposable: exports.DockviewDisposable.NONE,
6736
+ destroy: exports.DockviewDisposable.NONE,
6749
6737
  element,
6750
6738
  };
6751
6739
  }
@@ -6809,7 +6797,7 @@
6809
6797
  }
6810
6798
  resize();
6811
6799
  }));
6812
- this.map[panel.api.id].destroy = Disposable.from(() => {
6800
+ this.map[panel.api.id].destroy = exports.DockviewDisposable.from(() => {
6813
6801
  var _a;
6814
6802
  if (panel.view.content.element.parentElement === focusContainer) {
6815
6803
  focusContainer.removeChild(panel.view.content.element);
@@ -7106,7 +7094,7 @@
7106
7094
  this.updateWatermark();
7107
7095
  }), exports.DockviewEvent.any(this.onDidAddPanel, this.onDidRemovePanel, this.onDidActivePanelChange)(() => {
7108
7096
  this._bufferOnDidLayoutChange.fire();
7109
- }), Disposable.from(() => {
7097
+ }), exports.DockviewDisposable.from(() => {
7110
7098
  // iterate over a copy of the array since .dispose() mutates the original array
7111
7099
  for (const group of [...this._floatingGroups]) {
7112
7100
  group.dispose();
@@ -7221,7 +7209,7 @@
7221
7209
  return element.getBoundingClientRect();
7222
7210
  }
7223
7211
  const box = getBox();
7224
- 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;
7212
+ 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();
7225
7213
  if (itemToPopout.api.location.type === 'grid') {
7226
7214
  itemToPopout.api.setVisible(false);
7227
7215
  }
@@ -7322,7 +7310,7 @@
7322
7310
  */
7323
7311
  addDisposableWindowListener(_window.window, 'resize', () => {
7324
7312
  group.layout(window.innerWidth, window.innerHeight);
7325
- }), overlayRenderContainer, Disposable.from(() => {
7313
+ }), overlayRenderContainer, exports.DockviewDisposable.from(() => {
7326
7314
  if (this.getPanel(referenceGroup.id)) {
7327
7315
  this.movingLock(() => moveGroupWithoutDestroying({
7328
7316
  from: group,
@@ -7337,24 +7325,22 @@
7337
7325
  });
7338
7326
  }
7339
7327
  }
7340
- else {
7341
- if (this.getPanel(group.id)) {
7342
- const removedGroup = this.doRemoveGroup(group, {
7343
- skipDispose: true,
7344
- skipActive: true,
7345
- });
7346
- removedGroup.model.renderContainer =
7347
- this.overlayRenderContainer;
7348
- removedGroup.model.location = { type: 'grid' };
7349
- returnedGroup = removedGroup;
7350
- }
7328
+ else if (this.getPanel(group.id)) {
7329
+ const removedGroup = this.doRemoveGroup(group, {
7330
+ skipDispose: true,
7331
+ skipActive: true,
7332
+ });
7333
+ removedGroup.model.renderContainer =
7334
+ this.overlayRenderContainer;
7335
+ removedGroup.model.location = { type: 'grid' };
7336
+ returnedGroup = removedGroup;
7351
7337
  }
7352
7338
  }));
7353
7339
  this._popoutGroups.push(value);
7354
7340
  this.updateWatermark();
7355
7341
  })
7356
7342
  .catch((err) => {
7357
- console.error(err);
7343
+ console.error('dockview: failed to create popout window', err);
7358
7344
  });
7359
7345
  }
7360
7346
  addFloatingGroup(item, coord, options) {
@@ -7397,7 +7383,7 @@
7397
7383
  this.doRemoveGroup(item, {
7398
7384
  skipDispose: true,
7399
7385
  skipPopoutReturn: true,
7400
- skipPopoutAssociated: !!popoutReferenceGroup,
7386
+ skipPopoutAssociated: false,
7401
7387
  });
7402
7388
  }
7403
7389
  }
@@ -7757,7 +7743,6 @@
7757
7743
  clear() {
7758
7744
  const groups = Array.from(this._groups.values()).map((_) => _.value);
7759
7745
  const hasActiveGroup = !!this.activeGroup;
7760
- !!this.activePanel;
7761
7746
  for (const group of groups) {
7762
7747
  // remove the group will automatically remove the panels
7763
7748
  this.removeGroup(group, { skipActive: true });
@@ -8263,7 +8248,7 @@
8263
8248
  }
8264
8249
  let id = options === null || options === void 0 ? void 0 : options.id;
8265
8250
  if (id && this._groups.has(options.id)) {
8266
- console.warn(`Duplicate group id ${options === null || options === void 0 ? void 0 : options.id}. reassigning group id to avoid errors`);
8251
+ console.warn(`dockview: Duplicate group id ${options === null || options === void 0 ? void 0 : options.id}. reassigning group id to avoid errors`);
8267
8252
  id = undefined;
8268
8253
  }
8269
8254
  if (!id) {
@@ -9430,15 +9415,13 @@
9430
9415
  const addPortal = React.useCallback((portal) => {
9431
9416
  setPortals((existingPortals) => [...existingPortals, portal]);
9432
9417
  let disposed = false;
9433
- return {
9434
- dispose: () => {
9435
- if (disposed) {
9436
- throw new Error('invalid operation: resource already disposed');
9437
- }
9438
- disposed = true;
9439
- setPortals((existingPortals) => existingPortals.filter((p) => p !== portal));
9440
- },
9441
- };
9418
+ return exports.DockviewDisposable.from(() => {
9419
+ if (disposed) {
9420
+ throw new Error('invalid operation: resource already disposed');
9421
+ }
9422
+ disposed = true;
9423
+ setPortals((existingPortals) => existingPortals.filter((p) => p !== portal));
9424
+ });
9442
9425
  }, []);
9443
9426
  return [portals, addPortal];
9444
9427
  };
@@ -9480,7 +9463,7 @@
9480
9463
  }
9481
9464
  update(event) {
9482
9465
  var _a;
9483
- (_a = this.part) === null || _a === void 0 ? void 0 : _a.update(event.params);
9466
+ (_a = this.part) === null || _a === void 0 ? void 0 : _a.update({ params: event.params });
9484
9467
  }
9485
9468
  layout(_width, _height) {
9486
9469
  // noop
@@ -9518,7 +9501,7 @@
9518
9501
  }
9519
9502
  update(event) {
9520
9503
  var _a;
9521
- (_a = this.part) === null || _a === void 0 ? void 0 : _a.update(event.params);
9504
+ (_a = this.part) === null || _a === void 0 ? void 0 : _a.update({ params: event.params });
9522
9505
  }
9523
9506
  layout(_width, _height) {
9524
9507
  // noop - retrieval from api