@@ -219,17 +219,18 @@ function getAll(): WebviewWindow[] {
219219/** @ignore */
220220// events that are emitted right here instead of by the created webview
221221const localTauriEvents = [ 'tauri://created' , 'tauri://error' ]
222-
222+ /** @ignore */
223+ export type WindowLabel = string | null | undefined
223224/**
224225 * A webview window handle allows emitting and listening to events from the backend that are tied to the window.
225226 */
226227class WebviewWindowHandle {
227228 /** Window label. */
228- label : string | null
229+ label : WindowLabel
229230 /** Local event listeners. */
230231 listeners : { [ key : string ] : Array < EventCallback < any > > }
231232
232- constructor ( label : string | null ) {
233+ constructor ( label : WindowLabel ) {
233234 this . label = label
234235 // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
235236 this . listeners = Object . create ( null )
@@ -625,6 +626,26 @@ class WindowManager extends WebviewWindowHandle {
625626 } )
626627 }
627628
629+ /**
630+ * Toggles the window maximized state.
631+ *
632+ * @returns A promise indicating the success or failure of the operation.
633+ */
634+ async toggleMaximize ( ) : Promise < void > {
635+ return invokeTauriCommand ( {
636+ __tauriModule : 'Window' ,
637+ message : {
638+ cmd : 'manage' ,
639+ data : {
640+ label : this . label ,
641+ cmd : {
642+ type : 'toggleMaximize'
643+ }
644+ }
645+ }
646+ } )
647+ }
648+
628649 /**
629650 * Minimizes the window.
630651 *
@@ -1071,7 +1092,7 @@ class WindowManager extends WebviewWindowHandle {
10711092 * ```
10721093 */
10731094class WebviewWindow extends WindowManager {
1074- constructor ( label : string | null , options : WindowOptions = { } ) {
1095+ constructor ( label : WindowLabel , options : WindowOptions = { } ) {
10751096 super ( label )
10761097 // @ts -expect-error
10771098 if ( ! options ?. skip ) {
0 commit comments