dockview-core 6.1.1 → 6.2.2

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.1.1
3
+ * @version 6.2.2
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -11392,10 +11392,20 @@
11392
11392
  focusContainer.style.top = `${top}px`;
11393
11393
  focusContainer.style.width = `${width}px`;
11394
11394
  focusContainer.style.height = `${height}px`;
11395
- // Reveal after the first position is applied (was hidden to
11396
- // prevent a flash at 0,0 before the initial layout fires).
11397
- if (focusContainer.style.visibility === 'hidden') {
11395
+ // Sync visibility/pointer-events with the panel's current
11396
+ // visibility at paint time. visibilityChanged() may have
11397
+ // flipped to hidden between scheduling this rAF and now;
11398
+ // unconditionally clearing `visibility:hidden` here would
11399
+ // leave a hidden panel visually visible at a stale position,
11400
+ // because onDidDimensionsChange skips non-visible panels and
11401
+ // never recomputes their box on subsequent resizes.
11402
+ if (panel.api.isVisible) {
11398
11403
  focusContainer.style.visibility = '';
11404
+ focusContainer.style.pointerEvents = '';
11405
+ }
11406
+ else {
11407
+ focusContainer.style.visibility = 'hidden';
11408
+ focusContainer.style.pointerEvents = 'none';
11399
11409
  }
11400
11410
  toggleClass(focusContainer, 'dv-render-overlay-float', panel.group.api.location.type === 'floating');
11401
11411
  });
@@ -11539,6 +11549,25 @@
11539
11549
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
11540
11550
  };
11541
11551
 
11552
+ /**
11553
+ * Reject popout URLs that aren't same-origin http(s). Blocks `javascript:`,
11554
+ * `data:`, `blob:`, `vbscript:`, and cross-origin URLs that would otherwise
11555
+ * execute in a context the browser still associates with the opener via
11556
+ * `window.opener`.
11557
+ */
11558
+ function assertSameOriginPopoutUrl(url) {
11559
+ let resolved;
11560
+ try {
11561
+ resolved = new URL(url, window.location.href);
11562
+ }
11563
+ catch (_a) {
11564
+ throw new Error(`dockview: invalid popout URL: ${url}`);
11565
+ }
11566
+ const protocolOk = resolved.protocol === 'http:' || resolved.protocol === 'https:';
11567
+ if (!protocolOk || resolved.origin !== window.location.origin) {
11568
+ throw new Error(`dockview: popout URL must be same-origin http(s); got: ${url}`);
11569
+ }
11570
+ }
11542
11571
  class PopoutWindow extends CompositeDisposable {
11543
11572
  get window() {
11544
11573
  var _a, _b;
@@ -11590,6 +11619,7 @@
11590
11619
  throw new Error('instance of popout window is already open');
11591
11620
  }
11592
11621
  const url = `${this.options.url}`;
11622
+ assertSameOriginPopoutUrl(url);
11593
11623
  const features = Object.entries({
11594
11624
  top: this.options.top,
11595
11625
  left: this.options.left,
@@ -124,10 +124,20 @@ export class OverlayRenderContainer extends CompositeDisposable {
124
124
  focusContainer.style.top = `${top}px`;
125
125
  focusContainer.style.width = `${width}px`;
126
126
  focusContainer.style.height = `${height}px`;
127
- // Reveal after the first position is applied (was hidden to
128
- // prevent a flash at 0,0 before the initial layout fires).
129
- if (focusContainer.style.visibility === 'hidden') {
127
+ // Sync visibility/pointer-events with the panel's current
128
+ // visibility at paint time. visibilityChanged() may have
129
+ // flipped to hidden between scheduling this rAF and now;
130
+ // unconditionally clearing `visibility:hidden` here would
131
+ // leave a hidden panel visually visible at a stale position,
132
+ // because onDidDimensionsChange skips non-visible panels and
133
+ // never recomputes their box on subsequent resizes.
134
+ if (panel.api.isVisible) {
130
135
  focusContainer.style.visibility = '';
136
+ focusContainer.style.pointerEvents = '';
137
+ }
138
+ else {
139
+ focusContainer.style.visibility = 'hidden';
140
+ focusContainer.style.pointerEvents = 'none';
131
141
  }
132
142
  toggleClass(focusContainer, 'dv-render-overlay-float', panel.group.api.location.type === 'floating');
133
143
  });
@@ -11,6 +11,13 @@ export type PopoutWindowOptions = {
11
11
  window: Window;
12
12
  }) => void;
13
13
  } & Box;
14
+ /**
15
+ * Reject popout URLs that aren't same-origin http(s). Blocks `javascript:`,
16
+ * `data:`, `blob:`, `vbscript:`, and cross-origin URLs that would otherwise
17
+ * execute in a context the browser still associates with the opener via
18
+ * `window.opener`.
19
+ */
20
+ export declare function assertSameOriginPopoutUrl(url: string): void;
14
21
  export declare class PopoutWindow extends CompositeDisposable {
15
22
  private readonly target;
16
23
  private readonly className;
@@ -10,6 +10,25 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import { addStyles } from './dom';
11
11
  import { Emitter, addDisposableListener } from './events';
12
12
  import { CompositeDisposable, Disposable } from './lifecycle';
13
+ /**
14
+ * Reject popout URLs that aren't same-origin http(s). Blocks `javascript:`,
15
+ * `data:`, `blob:`, `vbscript:`, and cross-origin URLs that would otherwise
16
+ * execute in a context the browser still associates with the opener via
17
+ * `window.opener`.
18
+ */
19
+ export function assertSameOriginPopoutUrl(url) {
20
+ let resolved;
21
+ try {
22
+ resolved = new URL(url, window.location.href);
23
+ }
24
+ catch (_a) {
25
+ throw new Error(`dockview: invalid popout URL: ${url}`);
26
+ }
27
+ const protocolOk = resolved.protocol === 'http:' || resolved.protocol === 'https:';
28
+ if (!protocolOk || resolved.origin !== window.location.origin) {
29
+ throw new Error(`dockview: popout URL must be same-origin http(s); got: ${url}`);
30
+ }
31
+ }
13
32
  export class PopoutWindow extends CompositeDisposable {
14
33
  get window() {
15
34
  var _a, _b;
@@ -61,6 +80,7 @@ export class PopoutWindow extends CompositeDisposable {
61
80
  throw new Error('instance of popout window is already open');
62
81
  }
63
82
  const url = `${this.options.url}`;
83
+ assertSameOriginPopoutUrl(url);
64
84
  const features = Object.entries({
65
85
  top: this.options.top,
66
86
  left: this.options.left,
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview-core
3
- * @version 6.1.1
3
+ * @version 6.2.2
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -11388,10 +11388,20 @@ class OverlayRenderContainer extends CompositeDisposable {
11388
11388
  focusContainer.style.top = `${top}px`;
11389
11389
  focusContainer.style.width = `${width}px`;
11390
11390
  focusContainer.style.height = `${height}px`;
11391
- // Reveal after the first position is applied (was hidden to
11392
- // prevent a flash at 0,0 before the initial layout fires).
11393
- if (focusContainer.style.visibility === 'hidden') {
11391
+ // Sync visibility/pointer-events with the panel's current
11392
+ // visibility at paint time. visibilityChanged() may have
11393
+ // flipped to hidden between scheduling this rAF and now;
11394
+ // unconditionally clearing `visibility:hidden` here would
11395
+ // leave a hidden panel visually visible at a stale position,
11396
+ // because onDidDimensionsChange skips non-visible panels and
11397
+ // never recomputes their box on subsequent resizes.
11398
+ if (panel.api.isVisible) {
11394
11399
  focusContainer.style.visibility = '';
11400
+ focusContainer.style.pointerEvents = '';
11401
+ }
11402
+ else {
11403
+ focusContainer.style.visibility = 'hidden';
11404
+ focusContainer.style.pointerEvents = 'none';
11395
11405
  }
11396
11406
  toggleClass(focusContainer, 'dv-render-overlay-float', panel.group.api.location.type === 'floating');
11397
11407
  });
@@ -11535,6 +11545,25 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
11535
11545
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
11536
11546
  };
11537
11547
 
11548
+ /**
11549
+ * Reject popout URLs that aren't same-origin http(s). Blocks `javascript:`,
11550
+ * `data:`, `blob:`, `vbscript:`, and cross-origin URLs that would otherwise
11551
+ * execute in a context the browser still associates with the opener via
11552
+ * `window.opener`.
11553
+ */
11554
+ function assertSameOriginPopoutUrl(url) {
11555
+ let resolved;
11556
+ try {
11557
+ resolved = new URL(url, window.location.href);
11558
+ }
11559
+ catch (_a) {
11560
+ throw new Error(`dockview: invalid popout URL: ${url}`);
11561
+ }
11562
+ const protocolOk = resolved.protocol === 'http:' || resolved.protocol === 'https:';
11563
+ if (!protocolOk || resolved.origin !== window.location.origin) {
11564
+ throw new Error(`dockview: popout URL must be same-origin http(s); got: ${url}`);
11565
+ }
11566
+ }
11538
11567
  class PopoutWindow extends CompositeDisposable {
11539
11568
  get window() {
11540
11569
  var _a, _b;
@@ -11586,6 +11615,7 @@ class PopoutWindow extends CompositeDisposable {
11586
11615
  throw new Error('instance of popout window is already open');
11587
11616
  }
11588
11617
  const url = `${this.options.url}`;
11618
+ assertSameOriginPopoutUrl(url);
11589
11619
  const features = Object.entries({
11590
11620
  top: this.options.top,
11591
11621
  left: this.options.left,