1. API
  2. views

API

Functions

Function Description
create(options) Creates a new BrowserView.
getWebContents({ ref }) Retrieves a BrowserView's WebContents.
setAutoResize({ ref, dimensions, }) Resizes the BrowserView when its parent BrowserWindow dimensions change.
setBounds({ ref, bounds, }) Resizes and moves the BrowserView to the supplied bounds relative to the window.

create()

Creates a new BrowserView.

Signature:

        import { views } from "@todesktop/client-core"
views.create(options: BrowserViewConstructorOptions): Promise<Ref>;

      
Parameters
Parameter Type Description
options BrowserViewConstructorOptions BrowserView constructor options.

Returns:

Promise<Ref>

Identifier for the newly created BrowserView.

getWebContents()

Retrieves a BrowserView's WebContents.

Signature:

        import { views } from "@todesktop/client-core"
views.getWebContents({ ref }?: {
    ref?: Ref;
}): Promise<Electron.WebContents>;

      
Parameters
Parameter Type Description
{ ref } { ref?: Ref; }

Returns:

Promise<Electron.WebContents>

Identifier for the BrowserView's WebContents.

setAutoResize()

Resizes the BrowserView when its parent BrowserWindow dimensions change.

Signature:

        import { views } from "@todesktop/client-core"
views.setAutoResize({ ref, dimensions, }: {
    ref?: Ref;
    dimensions: SetAutoResizeOptions;
}): Promise<void>;

      
Parameters
Parameter Type Description
{ ref, dimensions, } { ref?: Ref; dimensions: SetAutoResizeOptions; }

Returns:

Promise<void>

setBounds()

Resizes and moves the BrowserView to the supplied bounds relative to the window.

Signature:

        import { views } from "@todesktop/client-core"
views.setBounds({ ref, bounds, }: {
    ref?: Ref;
    bounds: Rectangle;
}): Promise<void>;

      
Parameters
Parameter Type Description
{ ref, bounds, } { ref?: Ref; bounds: Rectangle; }

Returns:

Promise<void>

Type Aliases

SetAutoResizeOptions

Signature:

        export declare type SetAutoResizeOptions = {
    width: boolean;
    height: boolean;
    horizontal: boolean;
    vertical: boolean;
};

      
Type Alias Description
SetAutoResizeOptions