@@ -2035,6 +2035,17 @@ interface WindowOptions {
20352035 theme ?: Theme
20362036}
20372037
2038+ function mapMonitor ( m : Monitor | null ) : Monitor | null {
2039+ return m === null
2040+ ? null
2041+ : {
2042+ name : m . name ,
2043+ scaleFactor : m . scaleFactor ,
2044+ position : new PhysicalPosition ( m . position . x , m . position . y ) ,
2045+ size : new PhysicalSize ( m . size . width , m . size . height )
2046+ }
2047+ }
2048+
20382049/**
20392050 * Returns the monitor on which the window currently resides.
20402051 * Returns `null` if current monitor can't be detected.
@@ -2047,7 +2058,7 @@ interface WindowOptions {
20472058 * @since 1.0.0
20482059 */
20492060async function currentMonitor ( ) : Promise < Monitor | null > {
2050- return invokeTauriCommand ( {
2061+ return invokeTauriCommand < Monitor | null > ( {
20512062 __tauriModule : 'Window' ,
20522063 message : {
20532064 cmd : 'manage' ,
@@ -2057,7 +2068,7 @@ async function currentMonitor(): Promise<Monitor | null> {
20572068 }
20582069 }
20592070 }
2060- } )
2071+ } ) . then ( mapMonitor )
20612072}
20622073
20632074/**
@@ -2072,7 +2083,7 @@ async function currentMonitor(): Promise<Monitor | null> {
20722083 * @since 1.0.0
20732084 */
20742085async function primaryMonitor ( ) : Promise < Monitor | null > {
2075- return invokeTauriCommand ( {
2086+ return invokeTauriCommand < Monitor | null > ( {
20762087 __tauriModule : 'Window' ,
20772088 message : {
20782089 cmd : 'manage' ,
@@ -2082,7 +2093,7 @@ async function primaryMonitor(): Promise<Monitor | null> {
20822093 }
20832094 }
20842095 }
2085- } )
2096+ } ) . then ( mapMonitor )
20862097}
20872098
20882099/**
@@ -2096,7 +2107,7 @@ async function primaryMonitor(): Promise<Monitor | null> {
20962107 * @since 1.0.0
20972108 */
20982109async function availableMonitors ( ) : Promise < Monitor [ ] > {
2099- return invokeTauriCommand ( {
2110+ return invokeTauriCommand < Monitor [ ] > ( {
21002111 __tauriModule : 'Window' ,
21012112 message : {
21022113 cmd : 'manage' ,
@@ -2106,7 +2117,7 @@ async function availableMonitors(): Promise<Monitor[]> {
21062117 }
21072118 }
21082119 }
2109- } )
2120+ } ) . then ( ( ms ) => ms . map ( mapMonitor ) as Monitor [ ] )
21102121}
21112122
21122123export {
0 commit comments