@ -102,7 +102,7 @@ class PhysicalSize {
* Converts the physical size to a logical one .
* Converts the physical size to a logical one .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from '@tauri-apps/ window';
* import { appWindow } from '@tauri-apps/ plugin- window';
* const factor = await appWindow . scaleFactor ( ) ;
* const factor = await appWindow . scaleFactor ( ) ;
* const size = await appWindow . innerSize ( ) ;
* const size = await appWindow . innerSize ( ) ;
* const logical = size . toLogical ( factor ) ;
* const logical = size . toLogical ( factor ) ;
@ -148,7 +148,7 @@ class PhysicalPosition {
* Converts the physical position to a logical one .
* Converts the physical position to a logical one .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from '@tauri-apps/ window';
* import { appWindow } from '@tauri-apps/ plugin- window';
* const factor = await appWindow . scaleFactor ( ) ;
* const factor = await appWindow . scaleFactor ( ) ;
* const position = await appWindow . innerPosition ( ) ;
* const position = await appWindow . innerPosition ( ) ;
* const logical = position . toLogical ( factor ) ;
* const logical = position . toLogical ( factor ) ;
@ -258,7 +258,7 @@ function getAll(): WebviewWindow[] {
new WebviewWindow ( w . label , {
new WebviewWindow ( w . label , {
// @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
// @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
skip : true ,
skip : true ,
} )
} ) ,
) ;
) ;
}
}
@ -291,7 +291,7 @@ class WebviewWindowHandle {
*
*
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from '@tauri-apps/ window';
* import { appWindow } from '@tauri-apps/ plugin- window';
* const unlisten = await appWindow . listen < string > ( 'state-changed' , ( event ) = > {
* const unlisten = await appWindow . listen < string > ( 'state-changed' , ( event ) = > {
* console . log ( ` Got error: ${ payload } ` ) ;
* console . log ( ` Got error: ${ payload } ` ) ;
* } ) ;
* } ) ;
@ -309,7 +309,7 @@ class WebviewWindowHandle {
* /
* /
async listen < T > (
async listen < T > (
event : EventName ,
event : EventName ,
handler : EventCallback < T >
handler : EventCallback < T > ,
) : Promise < UnlistenFn > {
) : Promise < UnlistenFn > {
if ( this . _handleTauriEvent ( event , handler ) ) {
if ( this . _handleTauriEvent ( event , handler ) ) {
return Promise . resolve ( ( ) = > {
return Promise . resolve ( ( ) = > {
@ -326,7 +326,7 @@ class WebviewWindowHandle {
*
*
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from '@tauri-apps/ window';
* import { appWindow } from '@tauri-apps/ plugin- window';
* const unlisten = await appWindow . once < null > ( 'initialized' , ( event ) = > {
* const unlisten = await appWindow . once < null > ( 'initialized' , ( event ) = > {
* console . log ( ` Window initialized! ` ) ;
* console . log ( ` Window initialized! ` ) ;
* } ) ;
* } ) ;
@ -357,7 +357,7 @@ class WebviewWindowHandle {
* Emits an event to the backend , tied to the webview window .
* Emits an event to the backend , tied to the webview window .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from '@tauri-apps/ window';
* import { appWindow } from '@tauri-apps/ plugin- window';
* await appWindow . emit ( 'window-loaded' , { loggedIn : true , token : 'authToken' } ) ;
* await appWindow . emit ( 'window-loaded' , { loggedIn : true , token : 'authToken' } ) ;
* ` ` `
* ` ` `
*
*
@ -403,7 +403,7 @@ class WindowManager extends WebviewWindowHandle {
* The scale factor that can be used to map physical pixels to logical pixels .
* The scale factor that can be used to map physical pixels to logical pixels .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from '@tauri-apps/ window';
* import { appWindow } from '@tauri-apps/ plugin- window';
* const factor = await appWindow . scaleFactor ( ) ;
* const factor = await appWindow . scaleFactor ( ) ;
* ` ` `
* ` ` `
*
*
@ -421,7 +421,7 @@ class WindowManager extends WebviewWindowHandle {
* The position of the top - left hand corner of the window ' s client area relative to the top - left hand corner of the desktop .
* The position of the top - left hand corner of the window ' s client area relative to the top - left hand corner of the desktop .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from '@tauri-apps/ window';
* import { appWindow } from '@tauri-apps/ plugin- window';
* const position = await appWindow . innerPosition ( ) ;
* const position = await appWindow . innerPosition ( ) ;
* ` ` `
* ` ` `
*
*
@ -435,7 +435,7 @@ class WindowManager extends WebviewWindowHandle {
"plugin:window|inner_position" ,
"plugin:window|inner_position" ,
{
{
label : this.label ,
label : this.label ,
}
} ,
)
)
. then ( ( { x , y } ) = > new PhysicalPosition ( x , y ) ) ;
. then ( ( { x , y } ) = > new PhysicalPosition ( x , y ) ) ;
}
}
@ -444,7 +444,7 @@ class WindowManager extends WebviewWindowHandle {
* The position of the top - left hand corner of the window relative to the top - left hand corner of the desktop .
* The position of the top - left hand corner of the window relative to the top - left hand corner of the desktop .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from '@tauri-apps/ window';
* import { appWindow } from '@tauri-apps/ plugin- window';
* const position = await appWindow . outerPosition ( ) ;
* const position = await appWindow . outerPosition ( ) ;
* ` ` `
* ` ` `
*
*
@ -458,7 +458,7 @@ class WindowManager extends WebviewWindowHandle {
"plugin:window|outer_position" ,
"plugin:window|outer_position" ,
{
{
label : this.label ,
label : this.label ,
}
} ,
)
)
. then ( ( { x , y } ) = > new PhysicalPosition ( x , y ) ) ;
. then ( ( { x , y } ) = > new PhysicalPosition ( x , y ) ) ;
}
}
@ -468,7 +468,7 @@ class WindowManager extends WebviewWindowHandle {
* The client area is the content of the window , excluding the title bar and borders .
* The client area is the content of the window , excluding the title bar and borders .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from '@tauri-apps/ window';
* import { appWindow } from '@tauri-apps/ plugin- window';
* const size = await appWindow . innerSize ( ) ;
* const size = await appWindow . innerSize ( ) ;
* ` ` `
* ` ` `
*
*
@ -482,7 +482,7 @@ class WindowManager extends WebviewWindowHandle {
"plugin:window|inner_size" ,
"plugin:window|inner_size" ,
{
{
label : this.label ,
label : this.label ,
}
} ,
)
)
. then ( ( { width , height } ) = > new PhysicalSize ( width , height ) ) ;
. then ( ( { width , height } ) = > new PhysicalSize ( width , height ) ) ;
}
}
@ -492,7 +492,7 @@ class WindowManager extends WebviewWindowHandle {
* These dimensions include the title bar and borders . If you don 't want that (and you usually don' t ) , use inner_size instead .
* These dimensions include the title bar and borders . If you don 't want that (and you usually don' t ) , use inner_size instead .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from '@tauri-apps/ window';
* import { appWindow } from '@tauri-apps/ plugin- window';
* const size = await appWindow . outerSize ( ) ;
* const size = await appWindow . outerSize ( ) ;
* ` ` `
* ` ` `
*
*
@ -506,7 +506,7 @@ class WindowManager extends WebviewWindowHandle {
"plugin:window|outer_size" ,
"plugin:window|outer_size" ,
{
{
label : this.label ,
label : this.label ,
}
} ,
)
)
. then ( ( { width , height } ) = > new PhysicalSize ( width , height ) ) ;
. then ( ( { width , height } ) = > new PhysicalSize ( width , height ) ) ;
}
}
@ -515,7 +515,7 @@ class WindowManager extends WebviewWindowHandle {
* Gets the window ' s current fullscreen state .
* Gets the window ' s current fullscreen state .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from '@tauri-apps/ window';
* import { appWindow } from '@tauri-apps/ plugin- window';
* const fullscreen = await appWindow . isFullscreen ( ) ;
* const fullscreen = await appWindow . isFullscreen ( ) ;
* ` ` `
* ` ` `
*
*
@ -533,7 +533,7 @@ class WindowManager extends WebviewWindowHandle {
* Gets the window ' s current minimized state .
* Gets the window ' s current minimized state .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from '@tauri-apps/ window';
* import { appWindow } from '@tauri-apps/ plugin- window';
* const minimized = await appWindow . isMinimized ( ) ;
* const minimized = await appWindow . isMinimized ( ) ;
* ` ` `
* ` ` `
*
*
@ -549,7 +549,7 @@ class WindowManager extends WebviewWindowHandle {
* Gets the window ' s current maximized state .
* Gets the window ' s current maximized state .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from '@tauri-apps/ window';
* import { appWindow } from '@tauri-apps/ plugin- window';
* const maximized = await appWindow . isMaximized ( ) ;
* const maximized = await appWindow . isMaximized ( ) ;
* ` ` `
* ` ` `
*
*
@ -585,7 +585,7 @@ class WindowManager extends WebviewWindowHandle {
* Gets the window ' s current decorated state .
* Gets the window ' s current decorated state .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from '@tauri-apps/ window';
* import { appWindow } from '@tauri-apps/ plugin- window';
* const decorated = await appWindow . isDecorated ( ) ;
* const decorated = await appWindow . isDecorated ( ) ;
* ` ` `
* ` ` `
*
*
@ -603,7 +603,7 @@ class WindowManager extends WebviewWindowHandle {
* Gets the window ' s current resizable state .
* Gets the window ' s current resizable state .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from '@tauri-apps/ window';
* import { appWindow } from '@tauri-apps/ plugin- window';
* const resizable = await appWindow . isResizable ( ) ;
* const resizable = await appWindow . isResizable ( ) ;
* ` ` `
* ` ` `
*
*
@ -684,7 +684,7 @@ class WindowManager extends WebviewWindowHandle {
* Gets the window ' s current visible state .
* Gets the window ' s current visible state .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from '@tauri-apps/ window';
* import { appWindow } from '@tauri-apps/ plugin- window';
* const visible = await appWindow . isVisible ( ) ;
* const visible = await appWindow . isVisible ( ) ;
* ` ` `
* ` ` `
*
*
@ -702,7 +702,7 @@ class WindowManager extends WebviewWindowHandle {
* Gets the window ' s current title .
* Gets the window ' s current title .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from '@tauri-apps/ window';
* import { appWindow } from '@tauri-apps/ plugin- window';
* const title = await appWindow . title ( ) ;
* const title = await appWindow . title ( ) ;
* ` ` `
* ` ` `
*
*
@ -723,7 +723,7 @@ class WindowManager extends WebviewWindowHandle {
*
*
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from '@tauri-apps/ window';
* import { appWindow } from '@tauri-apps/ plugin- window';
* const theme = await appWindow . theme ( ) ;
* const theme = await appWindow . theme ( ) ;
* ` ` `
* ` ` `
*
*
@ -743,7 +743,7 @@ class WindowManager extends WebviewWindowHandle {
* Centers the window .
* Centers the window .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from '@tauri-apps/ window';
* import { appWindow } from '@tauri-apps/ plugin- window';
* await appWindow . center ( ) ;
* await appWindow . center ( ) ;
* ` ` `
* ` ` `
*
*
@ -772,7 +772,7 @@ class WindowManager extends WebviewWindowHandle {
* - * * Linux : * * Urgency levels have the same effect .
* - * * Linux : * * Urgency levels have the same effect .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from '@tauri-apps/ window';
* import { appWindow } from '@tauri-apps/ plugin- window';
* await appWindow . requestUserAttention ( ) ;
* await appWindow . requestUserAttention ( ) ;
* ` ` `
* ` ` `
*
*
@ -782,7 +782,7 @@ class WindowManager extends WebviewWindowHandle {
* @since 2.0 . 0
* @since 2.0 . 0
* /
* /
async requestUserAttention (
async requestUserAttention (
requestType : UserAttentionType | null
requestType : UserAttentionType | null ,
) : Promise < void > {
) : Promise < void > {
let requestType_ = null ;
let requestType_ = null ;
if ( requestType ) {
if ( requestType ) {
@ -803,7 +803,7 @@ class WindowManager extends WebviewWindowHandle {
* Updates the window resizable flag .
* Updates the window resizable flag .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from '@tauri-apps/ window';
* import { appWindow } from '@tauri-apps/ plugin- window';
* await appWindow . setResizable ( false ) ;
* await appWindow . setResizable ( false ) ;
* ` ` `
* ` ` `
*
*
@ -895,7 +895,7 @@ class WindowManager extends WebviewWindowHandle {
* Sets the window title .
* Sets the window title .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from '@tauri-apps/ window';
* import { appWindow } from '@tauri-apps/ plugin- window';
* await appWindow . setTitle ( 'Tauri' ) ;
* await appWindow . setTitle ( 'Tauri' ) ;
* ` ` `
* ` ` `
*
*
@ -915,7 +915,7 @@ class WindowManager extends WebviewWindowHandle {
* Maximizes the window .
* Maximizes the window .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from '@tauri-apps/ window';
* import { appWindow } from '@tauri-apps/ plugin- window';
* await appWindow . maximize ( ) ;
* await appWindow . maximize ( ) ;
* ` ` `
* ` ` `
*
*
@ -933,7 +933,7 @@ class WindowManager extends WebviewWindowHandle {
* Unmaximizes the window .
* Unmaximizes the window .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from '@tauri-apps/ window';
* import { appWindow } from '@tauri-apps/ plugin- window';
* await appWindow . unmaximize ( ) ;
* await appWindow . unmaximize ( ) ;
* ` ` `
* ` ` `
*
*
@ -951,7 +951,7 @@ class WindowManager extends WebviewWindowHandle {
* Toggles the window maximized state .
* Toggles the window maximized state .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from '@tauri-apps/ window';
* import { appWindow } from '@tauri-apps/ plugin- window';
* await appWindow . toggleMaximize ( ) ;
* await appWindow . toggleMaximize ( ) ;
* ` ` `
* ` ` `
*
*
@ -969,7 +969,7 @@ class WindowManager extends WebviewWindowHandle {
* Minimizes the window .
* Minimizes the window .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from '@tauri-apps/ window';
* import { appWindow } from '@tauri-apps/ plugin- window';
* await appWindow . minimize ( ) ;
* await appWindow . minimize ( ) ;
* ` ` `
* ` ` `
*
*
@ -987,7 +987,7 @@ class WindowManager extends WebviewWindowHandle {
* Unminimizes the window .
* Unminimizes the window .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from '@tauri-apps/ window';
* import { appWindow } from '@tauri-apps/ plugin- window';
* await appWindow . unminimize ( ) ;
* await appWindow . unminimize ( ) ;
* ` ` `
* ` ` `
*
*
@ -1005,7 +1005,7 @@ class WindowManager extends WebviewWindowHandle {
* Sets the window visibility to true .
* Sets the window visibility to true .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from '@tauri-apps/ window';
* import { appWindow } from '@tauri-apps/ plugin- window';
* await appWindow . show ( ) ;
* await appWindow . show ( ) ;
* ` ` `
* ` ` `
*
*
@ -1023,7 +1023,7 @@ class WindowManager extends WebviewWindowHandle {
* Sets the window visibility to false .
* Sets the window visibility to false .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from '@tauri-apps/ window';
* import { appWindow } from '@tauri-apps/ plugin- window';
* await appWindow . hide ( ) ;
* await appWindow . hide ( ) ;
* ` ` `
* ` ` `
*
*
@ -1041,7 +1041,7 @@ class WindowManager extends WebviewWindowHandle {
* Closes the window .
* Closes the window .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from '@tauri-apps/ window';
* import { appWindow } from '@tauri-apps/ plugin- window';
* await appWindow . close ( ) ;
* await appWindow . close ( ) ;
* ` ` `
* ` ` `
*
*
@ -1059,7 +1059,7 @@ class WindowManager extends WebviewWindowHandle {
* Whether the window should have borders and bars .
* Whether the window should have borders and bars .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from '@tauri-apps/ window';
* import { appWindow } from '@tauri-apps/ plugin- window';
* await appWindow . setDecorations ( false ) ;
* await appWindow . setDecorations ( false ) ;
* ` ` `
* ` ` `
*
*
@ -1088,7 +1088,7 @@ class WindowManager extends WebviewWindowHandle {
*
*
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from '@tauri-apps/ window';
* import { appWindow } from '@tauri-apps/ plugin- window';
* await appWindow . setShadow ( false ) ;
* await appWindow . setShadow ( false ) ;
* ` ` `
* ` ` `
*
*
@ -1131,7 +1131,7 @@ class WindowManager extends WebviewWindowHandle {
* Whether the window should always be on top of other windows .
* Whether the window should always be on top of other windows .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from '@tauri-apps/ window';
* import { appWindow } from '@tauri-apps/ plugin- window';
* await appWindow . setAlwaysOnTop ( true ) ;
* await appWindow . setAlwaysOnTop ( true ) ;
* ` ` `
* ` ` `
*
*
@ -1151,7 +1151,7 @@ class WindowManager extends WebviewWindowHandle {
* Prevents the window contents from being captured by other apps .
* Prevents the window contents from being captured by other apps .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from '@tauri-apps/ window';
* import { appWindow } from '@tauri-apps/ plugin- window';
* await appWindow . setContentProtected ( true ) ;
* await appWindow . setContentProtected ( true ) ;
* ` ` `
* ` ` `
*
*
@ -1170,7 +1170,7 @@ class WindowManager extends WebviewWindowHandle {
* Resizes the window with a new inner size .
* Resizes the window with a new inner size .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow , LogicalSize } from '@tauri-apps/ window';
* import { appWindow , LogicalSize } from '@tauri-apps/ plugin- window';
* await appWindow . setSize ( new LogicalSize ( 600 , 500 ) ) ;
* await appWindow . setSize ( new LogicalSize ( 600 , 500 ) ) ;
* ` ` `
* ` ` `
*
*
@ -1182,7 +1182,7 @@ class WindowManager extends WebviewWindowHandle {
async setSize ( size : LogicalSize | PhysicalSize ) : Promise < void > {
async setSize ( size : LogicalSize | PhysicalSize ) : Promise < void > {
if ( ! size || ( size . type !== "Logical" && size . type !== "Physical" ) ) {
if ( ! size || ( size . type !== "Logical" && size . type !== "Physical" ) ) {
throw new Error (
throw new Error (
"the `size` argument must be either a LogicalSize or a PhysicalSize instance"
"the `size` argument must be either a LogicalSize or a PhysicalSize instance" ,
) ;
) ;
}
}
@ -1202,7 +1202,7 @@ class WindowManager extends WebviewWindowHandle {
* Sets the window minimum inner size . If the ` size ` argument is not provided , the constraint is unset .
* Sets the window minimum inner size . If the ` size ` argument is not provided , the constraint is unset .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow , PhysicalSize } from '@tauri-apps/ window';
* import { appWindow , PhysicalSize } from '@tauri-apps/ plugin- window';
* await appWindow . setMinSize ( new PhysicalSize ( 600 , 500 ) ) ;
* await appWindow . setMinSize ( new PhysicalSize ( 600 , 500 ) ) ;
* ` ` `
* ` ` `
*
*
@ -1212,11 +1212,11 @@ class WindowManager extends WebviewWindowHandle {
* @since 2.0 . 0
* @since 2.0 . 0
* /
* /
async setMinSize (
async setMinSize (
size : LogicalSize | PhysicalSize | null | undefined
size : LogicalSize | PhysicalSize | null | undefined ,
) : Promise < void > {
) : Promise < void > {
if ( size && size . type !== "Logical" && size . type !== "Physical" ) {
if ( size && size . type !== "Logical" && size . type !== "Physical" ) {
throw new Error (
throw new Error (
"the `size` argument must be either a LogicalSize or a PhysicalSize instance"
"the `size` argument must be either a LogicalSize or a PhysicalSize instance" ,
) ;
) ;
}
}
@ -1238,7 +1238,7 @@ class WindowManager extends WebviewWindowHandle {
* Sets the window maximum inner size . If the ` size ` argument is undefined , the constraint is unset .
* Sets the window maximum inner size . If the ` size ` argument is undefined , the constraint is unset .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow , LogicalSize } from '@tauri-apps/ window';
* import { appWindow , LogicalSize } from '@tauri-apps/ plugin- window';
* await appWindow . setMaxSize ( new LogicalSize ( 600 , 500 ) ) ;
* await appWindow . setMaxSize ( new LogicalSize ( 600 , 500 ) ) ;
* ` ` `
* ` ` `
*
*
@ -1248,11 +1248,11 @@ class WindowManager extends WebviewWindowHandle {
* @since 2.0 . 0
* @since 2.0 . 0
* /
* /
async setMaxSize (
async setMaxSize (
size : LogicalSize | PhysicalSize | null | undefined
size : LogicalSize | PhysicalSize | null | undefined ,
) : Promise < void > {
) : Promise < void > {
if ( size && size . type !== "Logical" && size . type !== "Physical" ) {
if ( size && size . type !== "Logical" && size . type !== "Physical" ) {
throw new Error (
throw new Error (
"the `size` argument must be either a LogicalSize or a PhysicalSize instance"
"the `size` argument must be either a LogicalSize or a PhysicalSize instance" ,
) ;
) ;
}
}
@ -1274,7 +1274,7 @@ class WindowManager extends WebviewWindowHandle {
* Sets the window outer position .
* Sets the window outer position .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow , LogicalPosition } from '@tauri-apps/ window';
* import { appWindow , LogicalPosition } from '@tauri-apps/ plugin- window';
* await appWindow . setPosition ( new LogicalPosition ( 600 , 500 ) ) ;
* await appWindow . setPosition ( new LogicalPosition ( 600 , 500 ) ) ;
* ` ` `
* ` ` `
*
*
@ -1284,14 +1284,14 @@ class WindowManager extends WebviewWindowHandle {
* @since 2.0 . 0
* @since 2.0 . 0
* /
* /
async setPosition (
async setPosition (
position : LogicalPosition | PhysicalPosition
position : LogicalPosition | PhysicalPosition ,
) : Promise < void > {
) : Promise < void > {
if (
if (
! position ||
! position ||
( position . type !== "Logical" && position . type !== "Physical" )
( position . type !== "Logical" && position . type !== "Physical" )
) {
) {
throw new Error (
throw new Error (
"the `position` argument must be either a LogicalPosition or a PhysicalPosition instance"
"the `position` argument must be either a LogicalPosition or a PhysicalPosition instance" ,
) ;
) ;
}
}
@ -1311,7 +1311,7 @@ class WindowManager extends WebviewWindowHandle {
* Sets the window fullscreen state .
* Sets the window fullscreen state .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from '@tauri-apps/ window';
* import { appWindow } from '@tauri-apps/ plugin- window';
* await appWindow . setFullscreen ( true ) ;
* await appWindow . setFullscreen ( true ) ;
* ` ` `
* ` ` `
*
*
@ -1331,7 +1331,7 @@ class WindowManager extends WebviewWindowHandle {
* Bring the window to front and focus .
* Bring the window to front and focus .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from '@tauri-apps/ window';
* import { appWindow } from '@tauri-apps/ plugin- window';
* await appWindow . setFocus ( ) ;
* await appWindow . setFocus ( ) ;
* ` ` `
* ` ` `
*
*
@ -1349,7 +1349,7 @@ class WindowManager extends WebviewWindowHandle {
* Sets the window icon .
* Sets the window icon .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from '@tauri-apps/ window';
* import { appWindow } from '@tauri-apps/ plugin- window';
* await appWindow . setIcon ( '/tauri/awesome.png' ) ;
* await appWindow . setIcon ( '/tauri/awesome.png' ) ;
* ` ` `
* ` ` `
*
*
@ -1380,7 +1380,7 @@ class WindowManager extends WebviewWindowHandle {
* - * * macOS : * * Unsupported .
* - * * macOS : * * Unsupported .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from '@tauri-apps/ window';
* import { appWindow } from '@tauri-apps/ plugin- window';
* await appWindow . setSkipTaskbar ( true ) ;
* await appWindow . setSkipTaskbar ( true ) ;
* ` ` `
* ` ` `
*
*
@ -1408,7 +1408,7 @@ class WindowManager extends WebviewWindowHandle {
* - * * macOS : * * This locks the cursor in a fixed location , which looks visually awkward .
* - * * macOS : * * This locks the cursor in a fixed location , which looks visually awkward .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from '@tauri-apps/ window';
* import { appWindow } from '@tauri-apps/ plugin- window';
* await appWindow . setCursorGrab ( true ) ;
* await appWindow . setCursorGrab ( true ) ;
* ` ` `
* ` ` `
*
*
@ -1434,7 +1434,7 @@ class WindowManager extends WebviewWindowHandle {
* outside of the window .
* outside of the window .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from '@tauri-apps/ window';
* import { appWindow } from '@tauri-apps/ plugin- window';
* await appWindow . setCursorVisible ( false ) ;
* await appWindow . setCursorVisible ( false ) ;
* ` ` `
* ` ` `
*
*
@ -1454,7 +1454,7 @@ class WindowManager extends WebviewWindowHandle {
* Modifies the cursor icon of the window .
* Modifies the cursor icon of the window .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from '@tauri-apps/ window';
* import { appWindow } from '@tauri-apps/ plugin- window';
* await appWindow . setCursorIcon ( 'help' ) ;
* await appWindow . setCursorIcon ( 'help' ) ;
* ` ` `
* ` ` `
*
*
@ -1474,7 +1474,7 @@ class WindowManager extends WebviewWindowHandle {
* Changes the position of the cursor in window coordinates .
* Changes the position of the cursor in window coordinates .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow , LogicalPosition } from '@tauri-apps/ window';
* import { appWindow , LogicalPosition } from '@tauri-apps/ plugin- window';
* await appWindow . setCursorPosition ( new LogicalPosition ( 600 , 300 ) ) ;
* await appWindow . setCursorPosition ( new LogicalPosition ( 600 , 300 ) ) ;
* ` ` `
* ` ` `
*
*
@ -1484,14 +1484,14 @@ class WindowManager extends WebviewWindowHandle {
* @since 2.0 . 0
* @since 2.0 . 0
* /
* /
async setCursorPosition (
async setCursorPosition (
position : LogicalPosition | PhysicalPosition
position : LogicalPosition | PhysicalPosition ,
) : Promise < void > {
) : Promise < void > {
if (
if (
! position ||
! position ||
( position . type !== "Logical" && position . type !== "Physical" )
( position . type !== "Logical" && position . type !== "Physical" )
) {
) {
throw new Error (
throw new Error (
"the `position` argument must be either a LogicalPosition or a PhysicalPosition instance"
"the `position` argument must be either a LogicalPosition or a PhysicalPosition instance" ,
) ;
) ;
}
}
@ -1512,7 +1512,7 @@ class WindowManager extends WebviewWindowHandle {
*
*
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from '@tauri-apps/ window';
* import { appWindow } from '@tauri-apps/ plugin- window';
* await appWindow . setIgnoreCursorEvents ( true ) ;
* await appWindow . setIgnoreCursorEvents ( true ) ;
* ` ` `
* ` ` `
*
*
@ -1532,7 +1532,7 @@ class WindowManager extends WebviewWindowHandle {
* Starts dragging the window .
* Starts dragging the window .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from '@tauri-apps/ window';
* import { appWindow } from '@tauri-apps/ plugin- window';
* await appWindow . startDragging ( ) ;
* await appWindow . startDragging ( ) ;
* ` ` `
* ` ` `
*
*
@ -1606,7 +1606,7 @@ class WindowManager extends WebviewWindowHandle {
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { appWindow } from "@tauri-apps/plugin-window" ;
* import { appWindow } from "@tauri-apps/plugin-window" ;
* import { confirm } from '@tauri-apps/ api/ dialog';
* import { confirm } from '@tauri-apps/ plugin- dialog';
* const unlisten = await appWindow . onCloseRequested ( async ( event ) = > {
* const unlisten = await appWindow . onCloseRequested ( async ( event ) = > {
* const confirmed = await confirm ( 'Are you sure?' ) ;
* const confirmed = await confirm ( 'Are you sure?' ) ;
* if ( ! confirmed ) {
* if ( ! confirmed ) {
@ -1626,7 +1626,7 @@ class WindowManager extends WebviewWindowHandle {
* /
* /
/* eslint-disable @typescript-eslint/promise-function-async */
/* eslint-disable @typescript-eslint/promise-function-async */
async onCloseRequested (
async onCloseRequested (
handler : ( event : CloseRequestedEvent ) = > void | Promise < void >
handler : ( event : CloseRequestedEvent ) = > void | Promise < void > ,
) : Promise < UnlistenFn > {
) : Promise < UnlistenFn > {
return this . listen < null > ( TauriEvent . WINDOW_CLOSE_REQUESTED , ( event ) = > {
return this . listen < null > ( TauriEvent . WINDOW_CLOSE_REQUESTED , ( event ) = > {
const evt = new CloseRequestedEvent ( event ) ;
const evt = new CloseRequestedEvent ( event ) ;
@ -1663,13 +1663,13 @@ class WindowManager extends WebviewWindowHandle {
TauriEvent . WINDOW_FOCUS ,
TauriEvent . WINDOW_FOCUS ,
( event ) = > {
( event ) = > {
handler ( { . . . event , payload : true } ) ;
handler ( { . . . event , payload : true } ) ;
}
} ,
) ;
) ;
const unlistenBlur = await this . listen < PhysicalPosition > (
const unlistenBlur = await this . listen < PhysicalPosition > (
TauriEvent . WINDOW_BLUR ,
TauriEvent . WINDOW_BLUR ,
( event ) = > {
( event ) = > {
handler ( { . . . event , payload : false } ) ;
handler ( { . . . event , payload : false } ) ;
}
} ,
) ;
) ;
return ( ) = > {
return ( ) = > {
unlistenFocus ( ) ;
unlistenFocus ( ) ;
@ -1701,11 +1701,11 @@ class WindowManager extends WebviewWindowHandle {
* @since 2.0 . 0
* @since 2.0 . 0
* /
* /
async onScaleChanged (
async onScaleChanged (
handler : EventCallback < ScaleFactorChanged >
handler : EventCallback < ScaleFactorChanged > ,
) : Promise < UnlistenFn > {
) : Promise < UnlistenFn > {
return this . listen < ScaleFactorChanged > (
return this . listen < ScaleFactorChanged > (
TauriEvent . WINDOW_SCALE_FACTOR_CHANGED ,
TauriEvent . WINDOW_SCALE_FACTOR_CHANGED ,
handler
handler ,
) ;
) ;
}
}
@ -1760,27 +1760,27 @@ class WindowManager extends WebviewWindowHandle {
* @since 2.0 . 0
* @since 2.0 . 0
* /
* /
async onFileDropEvent (
async onFileDropEvent (
handler : EventCallback < FileDropEvent >
handler : EventCallback < FileDropEvent > ,
) : Promise < UnlistenFn > {
) : Promise < UnlistenFn > {
const unlistenFileDrop = await this . listen < string [ ] > (
const unlistenFileDrop = await this . listen < string [ ] > (
TauriEvent . WINDOW_FILE_DROP ,
TauriEvent . WINDOW_FILE_DROP ,
( event ) = > {
( event ) = > {
handler ( { . . . event , payload : { type : "drop" , paths : event.payload } } ) ;
handler ( { . . . event , payload : { type : "drop" , paths : event.payload } } ) ;
}
} ,
) ;
) ;
const unlistenFileHover = await this . listen < string [ ] > (
const unlistenFileHover = await this . listen < string [ ] > (
TauriEvent . WINDOW_FILE_DROP_HOVER ,
TauriEvent . WINDOW_FILE_DROP_HOVER ,
( event ) = > {
( event ) = > {
handler ( { . . . event , payload : { type : "hover" , paths : event.payload } } ) ;
handler ( { . . . event , payload : { type : "hover" , paths : event.payload } } ) ;
}
} ,
) ;
) ;
const unlistenCancel = await this . listen < null > (
const unlistenCancel = await this . listen < null > (
TauriEvent . WINDOW_FILE_DROP_CANCELLED ,
TauriEvent . WINDOW_FILE_DROP_CANCELLED ,
( event ) = > {
( event ) = > {
handler ( { . . . event , payload : { type : "cancel" } } ) ;
handler ( { . . . event , payload : { type : "cancel" } } ) ;
}
} ,
) ;
) ;
return ( ) = > {
return ( ) = > {
@ -1879,7 +1879,7 @@ class WebviewWindow extends WindowManager {
* Creates a new WebviewWindow .
* Creates a new WebviewWindow .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { WebviewWindow } from '@tauri-apps/ window';
* import { WebviewWindow } from '@tauri-apps/ plugin- window';
* const webview = new WebviewWindow ( 'my-label' , {
* const webview = new WebviewWindow ( 'my-label' , {
* url : 'https://github.com/tauri-apps/tauri'
* url : 'https://github.com/tauri-apps/tauri'
* } ) ;
* } ) ;
@ -1916,7 +1916,7 @@ class WebviewWindow extends WindowManager {
* Gets the WebviewWindow for the webview associated with the given label .
* Gets the WebviewWindow for the webview associated with the given label .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { WebviewWindow } from '@tauri-apps/ window';
* import { WebviewWindow } from '@tauri-apps/ plugin- window';
* const mainWindow = WebviewWindow . getByLabel ( 'main' ) ;
* const mainWindow = WebviewWindow . getByLabel ( 'main' ) ;
* ` ` `
* ` ` `
*
*
@ -1963,11 +1963,11 @@ if ("__TAURI_METADATA__" in window) {
{
{
// @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
// @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
skip : true ,
skip : true ,
}
} ,
) ;
) ;
} else {
} else {
console . warn (
console . warn (
` Could not find "window.__TAURI_METADATA__". The "appWindow" value will reference the "main" window label. \ nNote that this is not an issue if running this frontend on a browser instead of a Tauri window. `
` Could not find "window.__TAURI_METADATA__". The "appWindow" value will reference the "main" window label. \ nNote that this is not an issue if running this frontend on a browser instead of a Tauri window. ` ,
) ;
) ;
appWindow = new WebviewWindow ( "main" , {
appWindow = new WebviewWindow ( "main" , {
// @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
// @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
@ -2296,7 +2296,7 @@ function mapPhysicalSize(m: PhysicalSize): PhysicalSize {
* Returns ` null ` if current monitor can ' t be detected .
* Returns ` null ` if current monitor can ' t be detected .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { currentMonitor } from '@tauri-apps/ window';
* import { currentMonitor } from '@tauri-apps/ plugin- window';
* const monitor = currentMonitor ( ) ;
* const monitor = currentMonitor ( ) ;
* ` ` `
* ` ` `
*
*
@ -2313,7 +2313,7 @@ async function currentMonitor(): Promise<Monitor | null> {
* Returns ` null ` if it can ' t identify any monitor as a primary one .
* Returns ` null ` if it can ' t identify any monitor as a primary one .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { primaryMonitor } from '@tauri-apps/ window';
* import { primaryMonitor } from '@tauri-apps/ plugin- window';
* const monitor = primaryMonitor ( ) ;
* const monitor = primaryMonitor ( ) ;
* ` ` `
* ` ` `
*
*
@ -2329,7 +2329,7 @@ async function primaryMonitor(): Promise<Monitor | null> {
* Returns the list of all the monitors available on the system .
* Returns the list of all the monitors available on the system .
* @example
* @example
* ` ` ` typescript
* ` ` ` typescript
* import { availableMonitors } from '@tauri-apps/ window';
* import { availableMonitors } from '@tauri-apps/ plugin- window';
* const monitors = availableMonitors ( ) ;
* const monitors = availableMonitors ( ) ;
* ` ` `
* ` ` `
*
*