dockview-core 6.0.7 → 6.2.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-core
3
- * @version 6.0.7
3
+ * @version 6.2.1
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -72,6 +72,63 @@ function getPaneData() {
72
72
  return paneTransfer.getData(PaneTransfer.prototype)[0];
73
73
  }
74
74
 
75
+ var Disposable;
76
+ (function (Disposable) {
77
+ Disposable.NONE = {
78
+ dispose: () => {
79
+ // noop
80
+ },
81
+ };
82
+ function from(func) {
83
+ return {
84
+ dispose: () => {
85
+ func();
86
+ },
87
+ };
88
+ }
89
+ Disposable.from = from;
90
+ })(Disposable || (Disposable = {}));
91
+ class CompositeDisposable {
92
+ get isDisposed() {
93
+ return this._isDisposed;
94
+ }
95
+ constructor(...args) {
96
+ this._isDisposed = false;
97
+ this._disposables = new Set(args);
98
+ }
99
+ addDisposables(...args) {
100
+ args.forEach((arg) => this._disposables.add(arg));
101
+ }
102
+ removeDisposable(disposable) {
103
+ this._disposables.delete(disposable);
104
+ }
105
+ dispose() {
106
+ if (this._isDisposed) {
107
+ return;
108
+ }
109
+ this._isDisposed = true;
110
+ this._disposables.forEach((arg) => arg.dispose());
111
+ this._disposables.clear();
112
+ }
113
+ }
114
+ class MutableDisposable {
115
+ constructor() {
116
+ this._disposable = Disposable.NONE;
117
+ }
118
+ set value(disposable) {
119
+ if (this._disposable) {
120
+ this._disposable.dispose();
121
+ }
122
+ this._disposable = disposable;
123
+ }
124
+ dispose() {
125
+ if (this._disposable) {
126
+ this._disposable.dispose();
127
+ this._disposable = Disposable.NONE;
128
+ }
129
+ }
130
+ }
131
+
75
132
  var Event;
76
133
  (function (Event) {
77
134
  Event.any = (...children) => {
@@ -159,6 +216,7 @@ class Emitter {
159
216
  this.options = options;
160
217
  this._listeners = [];
161
218
  this._disposed = false;
219
+ this._pauseTokens = new Set();
162
220
  }
163
221
  get event() {
164
222
  if (!this._event) {
@@ -187,6 +245,11 @@ class Emitter {
187
245
  }
188
246
  fire(e) {
189
247
  var _a;
248
+ if (this._pauseTokens.size > 0) {
249
+ // while paused, the event is dropped entirely — `_last` is not
250
+ // updated, so replay subscribers won't see values fired during a pause
251
+ return;
252
+ }
190
253
  if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.replay) {
191
254
  this._last = e;
192
255
  }
@@ -194,6 +257,11 @@ class Emitter {
194
257
  listener.callback(e);
195
258
  }
196
259
  }
260
+ pause() {
261
+ const token = {};
262
+ this._pauseTokens.add(token);
263
+ return Disposable.from(() => this._pauseTokens.delete(token));
264
+ }
197
265
  dispose() {
198
266
  if (!this._disposed) {
199
267
  this._disposed = true;
@@ -275,63 +343,6 @@ class AsapEvent {
275
343
  }
276
344
  }
277
345
 
278
- var Disposable;
279
- (function (Disposable) {
280
- Disposable.NONE = {
281
- dispose: () => {
282
- // noop
283
- },
284
- };
285
- function from(func) {
286
- return {
287
- dispose: () => {
288
- func();
289
- },
290
- };
291
- }
292
- Disposable.from = from;
293
- })(Disposable || (Disposable = {}));
294
- class CompositeDisposable {
295
- get isDisposed() {
296
- return this._isDisposed;
297
- }
298
- constructor(...args) {
299
- this._isDisposed = false;
300
- this._disposables = new Set(args);
301
- }
302
- addDisposables(...args) {
303
- args.forEach((arg) => this._disposables.add(arg));
304
- }
305
- removeDisposable(disposable) {
306
- this._disposables.delete(disposable);
307
- }
308
- dispose() {
309
- if (this._isDisposed) {
310
- return;
311
- }
312
- this._isDisposed = true;
313
- this._disposables.forEach((arg) => arg.dispose());
314
- this._disposables.clear();
315
- }
316
- }
317
- class MutableDisposable {
318
- constructor() {
319
- this._disposable = Disposable.NONE;
320
- }
321
- set value(disposable) {
322
- if (this._disposable) {
323
- this._disposable.dispose();
324
- }
325
- this._disposable = disposable;
326
- }
327
- dispose() {
328
- if (this._disposable) {
329
- this._disposable.dispose();
330
- this._disposable = Disposable.NONE;
331
- }
332
- }
333
- }
334
-
335
346
  class OverflowObserver extends CompositeDisposable {
336
347
  constructor(el) {
337
348
  super();
@@ -2407,34 +2418,45 @@ class Gridview {
2407
2418
  */
2408
2419
  maxmizedViewLocation = getGridLocation(maximizedView.element);
2409
2420
  }
2410
- if (this.hasMaximizedView()) {
2411
- /**
2412
- * the saved layout cannot be in its maxmized state otherwise all of the underlying
2413
- * view dimensions will be wrong
2414
- *
2415
- * To counteract this we temporaily remove the maximized view to compute the serialized output
2416
- * of the grid before adding back the maxmized view as to not alter the layout from the users
2417
- * perspective when `.toJSON()` is called
2418
- */
2419
- this.exitMaximizedView();
2420
- }
2421
- const root = serializeBranchNode(this.getView(), this.orientation);
2422
- const resullt = {
2423
- root,
2424
- width: this.width,
2425
- height: this.height,
2426
- orientation: this.orientation,
2427
- };
2428
- if (maxmizedViewLocation) {
2429
- resullt.maximizedNode = {
2430
- location: maxmizedViewLocation,
2421
+ /**
2422
+ * We pause the onDidMaximizedNodeChange events because this method needs to
2423
+ * call `this.exitMaximizedView()`. We don't want this to invoke any listeners
2424
+ * since we undo it before leaving this method
2425
+ */
2426
+ const pauseToken = this._onDidMaximizedNodeChange.pause();
2427
+ try {
2428
+ if (this.hasMaximizedView()) {
2429
+ /**
2430
+ * the saved layout cannot be in its maxmized state otherwise all of the underlying
2431
+ * view dimensions will be wrong
2432
+ *
2433
+ * To counteract this we temporaily remove the maximized view to compute the serialized output
2434
+ * of the grid before adding back the maxmized view as to not alter the layout from the users
2435
+ * perspective when `.toJSON()` is called
2436
+ */
2437
+ this.exitMaximizedView();
2438
+ }
2439
+ const root = serializeBranchNode(this.getView(), this.orientation);
2440
+ const result = {
2441
+ root,
2442
+ width: this.width,
2443
+ height: this.height,
2444
+ orientation: this.orientation,
2431
2445
  };
2446
+ if (maxmizedViewLocation) {
2447
+ result.maximizedNode = {
2448
+ location: maxmizedViewLocation,
2449
+ };
2450
+ }
2451
+ if (maximizedView) {
2452
+ // replace any maximzied view that was removed for serialization purposes
2453
+ this.maximizeView(maximizedView);
2454
+ }
2455
+ return result;
2432
2456
  }
2433
- if (maximizedView) {
2434
- // replace any maximzied view that was removed for serialization purposes
2435
- this.maximizeView(maximizedView);
2457
+ finally {
2458
+ pauseToken.dispose();
2436
2459
  }
2437
- return resullt;
2438
2460
  }
2439
2461
  dispose() {
2440
2462
  this.disposable.dispose();
@@ -11376,8 +11398,12 @@ class OverlayRenderContainer extends CompositeDisposable {
11376
11398
  if (panel.api.isVisible) {
11377
11399
  this.positionCache.invalidate();
11378
11400
  resize();
11401
+ focusContainer.style.pointerEvents = '';
11402
+ }
11403
+ else {
11404
+ focusContainer.style.visibility = 'hidden';
11405
+ focusContainer.style.pointerEvents = 'none';
11379
11406
  }
11380
- focusContainer.style.display = panel.api.isVisible ? '' : 'none';
11381
11407
  };
11382
11408
  const observerDisposable = new MutableDisposable();
11383
11409
  const correctLayerPosition = () => {
@@ -11413,7 +11439,7 @@ class OverlayRenderContainer extends CompositeDisposable {
11413
11439
  * the dnd events for the expect behaviours to continue to occur in terms of dnd
11414
11440
  *
11415
11441
  * the dnd observer does not need to be conditional on whether the panel is visible since
11416
- * non-visible panels are 'display: none' and in such case the dnd observer will not fire.
11442
+ * non-visible panels have 'pointer-events: none' and in such case the dnd observer will not fire.
11417
11443
  */
11418
11444
  new DragAndDropObserver(focusContainer, {
11419
11445
  onDragEnd: (e) => {
@@ -11507,6 +11533,25 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
11507
11533
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
11508
11534
  };
11509
11535
 
11536
+ /**
11537
+ * Reject popout URLs that aren't same-origin http(s). Blocks `javascript:`,
11538
+ * `data:`, `blob:`, `vbscript:`, and cross-origin URLs that would otherwise
11539
+ * execute in a context the browser still associates with the opener via
11540
+ * `window.opener`.
11541
+ */
11542
+ function assertSameOriginPopoutUrl(url) {
11543
+ let resolved;
11544
+ try {
11545
+ resolved = new URL(url, window.location.href);
11546
+ }
11547
+ catch (_a) {
11548
+ throw new Error(`dockview: invalid popout URL: ${url}`);
11549
+ }
11550
+ const protocolOk = resolved.protocol === 'http:' || resolved.protocol === 'https:';
11551
+ if (!protocolOk || resolved.origin !== window.location.origin) {
11552
+ throw new Error(`dockview: popout URL must be same-origin http(s); got: ${url}`);
11553
+ }
11554
+ }
11510
11555
  class PopoutWindow extends CompositeDisposable {
11511
11556
  get window() {
11512
11557
  var _a, _b;
@@ -11558,6 +11603,7 @@ class PopoutWindow extends CompositeDisposable {
11558
11603
  throw new Error('instance of popout window is already open');
11559
11604
  }
11560
11605
  const url = `${this.options.url}`;
11606
+ assertSameOriginPopoutUrl(url);
11561
11607
  const features = Object.entries({
11562
11608
  top: this.options.top,
11563
11609
  left: this.options.left,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dockview-core",
3
- "version": "6.0.7",
3
+ "version": "6.2.1",
4
4
  "description": "Zero dependency layout manager supporting tabs, groups, grids and splitviews for vanilla TypeScript",
5
5
  "keywords": [
6
6
  "splitview",