dockview-core 8.3.1 → 8.4.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.
@@ -1,25 +1,60 @@
1
1
  import { CspNonceProvider } from './dom';
2
2
  import { CompositeDisposable } from './lifecycle';
3
3
  import { Box } from './types';
4
+ /**
5
+ * A popout window at a lifecycle boundary. `id` is the target name dockview
6
+ * passed to `window.open`; `window` is the live handle.
7
+ */
8
+ export interface PopoutWindowEvent {
9
+ readonly id: string;
10
+ readonly window: Window;
11
+ }
12
+ /**
13
+ * Why a popout window could not be used:
14
+ *
15
+ * - `url-refused`: the URL failed {@link getPopoutUrlError}.
16
+ * - `blocked`: `window.open` returned nothing, the browser's popup blocker
17
+ * being the usual reason.
18
+ * - `unscriptable`: a window opened, but the opener cannot reach its document,
19
+ * so panel DOM cannot be moved into it. Hosts that answer `window.open`
20
+ * themselves can do this.
21
+ * - `closed`: the window went away before it finished loading.
22
+ */
23
+ export type PopoutWindowFailureReason = 'url-refused' | 'blocked' | 'unscriptable' | 'closed';
24
+ export interface PopoutWindowFailure {
25
+ readonly reason: PopoutWindowFailureReason;
26
+ /** The refusal itself, where there was one. */
27
+ readonly error?: Error;
28
+ }
4
29
  export type PopoutWindowOptions = {
5
30
  url: string;
6
- onDidOpen?: (event: {
7
- id: string;
8
- window: Window;
9
- }) => void;
10
- onWillClose?: (event: {
11
- id: string;
12
- window: Window;
13
- }) => void;
31
+ onDidOpen?: (event: PopoutWindowEvent) => void;
32
+ onWillClose?: (event: PopoutWindowEvent) => void;
14
33
  nonce?: CspNonceProvider;
34
+ /** The root node dockview is mounted in, read when the popout loads.
35
+ * When it is a shadow root its stylesheets are copied too, since they are
36
+ * not in `document.styleSheets`. Rules that target the shadow host
37
+ * (`:host`, `::slotted`) match nothing in the popout. */
38
+ styleRoot?: () => Node;
15
39
  } & Box;
16
40
  /**
17
- * Reject popout URLs that aren't same-origin http(s). Blocks `javascript:`,
18
- * `data:`, `blob:`, `vbscript:`, and cross-origin URLs that would otherwise
19
- * execute in a context the browser still associates with the opener via
20
- * `window.opener`.
41
+ * Throwing form of {@link getPopoutUrlError}, for callers with no way to
42
+ * recover from a refused URL.
21
43
  */
22
44
  export declare function assertSameOriginPopoutUrl(url: string): void;
45
+ /**
46
+ * The reason `url` is unusable as a popout target, or `undefined` if it is
47
+ * allowed. Rejects anything that isn't same-origin with the page (scheme and
48
+ * host, so a packaged webview's own scheme such as `tauri://` qualifies), and
49
+ * the `javascript:`, `data:`, `blob:`, `vbscript:` and `file:` schemes that
50
+ * would otherwise execute in a context the browser still associates with the
51
+ * opener via `window.opener`.
52
+ *
53
+ * Callers that can recover from a refusal use this rather than catching, so it
54
+ * can be handled without a rejected promise. `page` is what the URL resolves
55
+ * against, and defaults to this page.
56
+ */
57
+ export declare function getPopoutUrlError(url: string, page?: Pick<Location, 'href' | 'protocol' | 'host'>): Error | undefined;
23
58
  export declare class PopoutWindow extends CompositeDisposable {
24
59
  private readonly target;
25
60
  private readonly className;
@@ -29,10 +64,20 @@ export declare class PopoutWindow extends CompositeDisposable {
29
64
  private readonly _onDidClose;
30
65
  readonly onDidClose: import("./events").Event<void>;
31
66
  private _window;
67
+ private _failure;
32
68
  get window(): Window | null;
69
+ /** Set when {@link open} resolved `null`, saying which way it failed. */
70
+ get failure(): PopoutWindowFailure | undefined;
33
71
  constructor(target: string, className: string, options: PopoutWindowOptions);
34
72
  dimensions(): Box | null;
35
73
  close(): void;
36
74
  open(): Promise<HTMLElement | null>;
75
+ /**
76
+ * Backstop for the `beforeunload` signal, which a window torn down without
77
+ * running its unload handlers never sends: a native shell destroying the
78
+ * webview, or a browser discarding the page. `closed` is readable on any
79
+ * handle, cross-origin included. Whichever signal arrives first wins.
80
+ */
81
+ private watchForClose;
37
82
  private createPopoutWindowContainer;
38
83
  }
@@ -8,5 +8,17 @@ export declare abstract class Resizable extends CompositeDisposable {
8
8
  get disableResizing(): boolean;
9
9
  set disableResizing(value: boolean);
10
10
  constructor(parentElement: HTMLElement, disableResizing?: boolean);
11
+ /**
12
+ * Lay out from the element's current size.
13
+ *
14
+ * The ResizeObserver above only reports asynchronously, so between
15
+ * construction and its first callback the component believes it has no
16
+ * size - and anything built in that window (panels added right after
17
+ * `createDockview`, say) resolves its sizes against zero and collapses to
18
+ * minimums. Concrete components call this once they are fully constructed
19
+ * so that work sees the real size. The same guards as the observer apply:
20
+ * a detached or hidden element has no size worth propagating.
21
+ */
22
+ protected layoutFromElement(): void;
11
23
  abstract layout(width: number, height: number): void;
12
24
  }
@@ -77,7 +77,7 @@ export declare class Splitview {
77
77
  private _orthogonalSize;
78
78
  private _contentSize;
79
79
  private _proportions;
80
- private readonly proportionalLayout;
80
+ private _proportionalLayout;
81
81
  private _startSnappingEnabled;
82
82
  private _endSnappingEnabled;
83
83
  private _disabled;
@@ -95,6 +95,8 @@ export declare class Splitview {
95
95
  set orthogonalSize(value: number);
96
96
  get length(): number;
97
97
  get proportions(): (number | undefined)[] | undefined;
98
+ get proportionalLayout(): boolean;
99
+ set proportionalLayout(value: boolean);
98
100
  get orientation(): Orientation;
99
101
  set orientation(value: Orientation);
100
102
  get minimumSize(): number;