-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
window.ts
1251 lines (1184 loc) · 30.2 KB
/
window.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
/**
* Provides APIs to create windows, communicate with other windows and manipulate the current window.
*
* This package is also accessible with `window.__TAURI__.window` when `tauri.conf.json > build > withGlobalTauri` is set to true.
*
* The APIs must be allowlisted on `tauri.conf.json`:
* ```json
* {
* "tauri": {
* "allowlist": {
* "window": {
* "all": true, // enable all window APIs
* "create": true // enable window creation
* }
* }
* }
* }
* ```
* It is recommended to allowlist only the APIs you use for optimal bundle size and security.
*
* # Window events
*
* Events can be listened using `appWindow.listen`:
* ```typescript
* import { appWindow } from '@tauri-apps/api/window'
* appWindow.listen('tauri://move', ({ event, payload }) => {
* const { x, y } = payload // payload here is a `PhysicalPosition`
* })
* ```
*
* Window-specific events emitted by the backend:
*
* #### 'tauri://resize'
* Emitted when the size of the window has changed.
* *EventPayload*:
* ```typescript
* type ResizePayload = PhysicalSize
* ```
*
* #### 'tauri://move'
* Emitted when the position of the window has changed.
* *EventPayload*:
* ```typescript
* type MovePayload = PhysicalPosition
* ```
*
* #### 'tauri://close-requested'
* Emitted when the user requests the window to be closed.
*
* #### 'tauri://destroyed'
* Emitted after the window is closed.
*
* #### 'tauri://focus'
* Emitted when the window gains focus.
*
* #### 'tauri://blur'
* Emitted when the window loses focus.
*
* #### 'tauri://scale-change'
* Emitted when the window's scale factor has changed.
* The following user actions can cause DPI changes:
* - Changing the display's resolution.
* - Changing the display's scale factor (e.g. in Control Panel on Windows).
* - Moving the window to a display with a different scale factor.
* *Event payload*:
* ```typescript
* interface ScaleFactorChanged {
* scaleFactor: number
* size: PhysicalSize
* }
* ```
*
* #### 'tauri://menu'
* Emitted when a menu item is clicked.
* *EventPayload*:
* ```typescript
* type MenuClicked = string
* ```
*
* @module
*/
import { invokeTauriCommand } from './helpers/tauri'
import { EventName, EventCallback, UnlistenFn, listen, once } from './event'
import { emit } from './helpers/event'
/** Allows you to retrieve information about a given monitor. */
interface Monitor {
/** Human-readable name of the monitor */
name: string | null
/** The monitor's resolution. */
size: PhysicalSize
/** the Top-left corner position of the monitor relative to the larger full screen area. */
position: PhysicalPosition
/** The scale factor that can be used to map physical pixels to logical pixels. */
scaleFactor: number
}
/** A size represented in logical pixels. */
class LogicalSize {
type = 'Logical'
width: number
height: number
constructor(width: number, height: number) {
this.width = width
this.height = height
}
}
/** A size represented in physical pixels. */
class PhysicalSize {
type = 'Physical'
width: number
height: number
constructor(width: number, height: number) {
this.width = width
this.height = height
}
/** Converts the physical size to a logical one. */
toLogical(scaleFactor: number): LogicalSize {
return new LogicalSize(this.width / scaleFactor, this.height / scaleFactor)
}
}
/** A position represented in logical pixels. */
class LogicalPosition {
type = 'Logical'
x: number
y: number
constructor(x: number, y: number) {
this.x = x
this.y = y
}
}
/** A position represented in physical pixels. */
class PhysicalPosition {
type = 'Physical'
x: number
y: number
constructor(x: number, y: number) {
this.x = x
this.y = y
}
/** Converts the physical position to a logical one. */
toLogical(scaleFactor: number): LogicalPosition {
return new LogicalPosition(this.x / scaleFactor, this.y / scaleFactor)
}
}
/** @ignore */
interface WindowDef {
label: string
}
/** @ignore */
declare global {
interface Window {
__TAURI__: {
__windows: WindowDef[]
__currentWindow: WindowDef
}
}
}
/** Attention type to request on a window. */
enum UserAttentionType {
/**
* ## Platform-specific
* - **macOS:** Bounces the dock icon until the application is in focus.
* - **Windows:** Flashes both the window and the taskbar button until the application is in focus.
*/
Critical = 1,
/**
* ## Platform-specific
* - **macOS:** Bounces the dock icon once.
* - **Windows:** Flashes the taskbar button until the application is in focus.
*/
Informational
}
/**
* Get an instance of `WebviewWindow` for the current webview window.
*
* @return The current WebviewWindow.
*/
function getCurrent(): WebviewWindow {
return new WebviewWindow(window.__TAURI__.__currentWindow.label, {
// @ts-expect-error
skip: true
})
}
/**
* Gets an instance of `WebviewWindow` for all available webview windows.
*
* @return The list of WebviewWindow.
*/
function getAll(): WebviewWindow[] {
return window.__TAURI__.__windows.map(
(w) =>
new WebviewWindow(w.label, {
// @ts-expect-error
skip: true
})
)
}
/** @ignore */
// events that are emitted right here instead of by the created webview
const localTauriEvents = ['tauri://created', 'tauri://error']
/** @ignore */
export type WindowLabel = string | null | undefined
/**
* A webview window handle allows emitting and listening to events from the backend that are tied to the window.
*/
class WebviewWindowHandle {
/** Window label. */
label: WindowLabel
/** Local event listeners. */
listeners: { [key: string]: Array<EventCallback<any>> }
constructor(label: WindowLabel) {
this.label = label
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
this.listeners = Object.create(null)
}
/**
* Listen to an event emitted by the backend that is tied to the webview window.
*
* @param event Event name.
* @param handler Event handler.
* @returns A promise resolving to a function to unlisten to the event.
*/
async listen<T>(
event: EventName,
handler: EventCallback<T>
): Promise<UnlistenFn> {
if (this._handleTauriEvent(event, handler)) {
return Promise.resolve(() => {
// eslint-disable-next-line security/detect-object-injection
const listeners = this.listeners[event]
listeners.splice(listeners.indexOf(handler), 1)
})
}
return listen(event, handler)
}
/**
* Listen to an one-off event emitted by the backend that is tied to the webview window.
*
* @param event Event name.
* @param handler Event handler.
* @returns A promise resolving to a function to unlisten to the event.
*/
async once<T>(event: string, handler: EventCallback<T>): Promise<UnlistenFn> {
if (this._handleTauriEvent(event, handler)) {
return Promise.resolve(() => {
// eslint-disable-next-line security/detect-object-injection
const listeners = this.listeners[event]
listeners.splice(listeners.indexOf(handler), 1)
})
}
return once(event, handler)
}
/**
* Emits an event to the backend, tied to the webview window.
*
* @param event Event name.
* @param payload Event payload.
*/
async emit(event: string, payload?: string): Promise<void> {
if (localTauriEvents.includes(event)) {
// eslint-disable-next-line
for (const handler of this.listeners[event] || []) {
handler({ event, id: -1, payload })
}
return Promise.resolve()
}
return emit(event, this.label, payload)
}
_handleTauriEvent<T>(event: string, handler: EventCallback<T>): boolean {
if (localTauriEvents.includes(event)) {
if (!(event in this.listeners)) {
// eslint-disable-next-line
this.listeners[event] = [handler]
} else {
// eslint-disable-next-line
this.listeners[event].push(handler)
}
return true
}
return false
}
}
/**
* Manage the current window object.
*/
class WindowManager extends WebviewWindowHandle {
// Getters
/** The scale factor that can be used to map physical pixels to logical pixels. */
async scaleFactor(): Promise<number> {
return invokeTauriCommand({
__tauriModule: 'Window',
message: {
cmd: 'manage',
data: {
label: this.label,
cmd: {
type: 'scaleFactor'
}
}
}
})
}
/** The position of the top-left hand corner of the window's client area relative to the top-left hand corner of the desktop. */
async innerPosition(): Promise<PhysicalPosition> {
return invokeTauriCommand({
__tauriModule: 'Window',
message: {
cmd: 'manage',
data: {
label: this.label,
cmd: {
type: 'innerPosition'
}
}
}
})
}
/** The position of the top-left hand corner of the window relative to the top-left hand corner of the desktop. */
async outerPosition(): Promise<PhysicalPosition> {
return invokeTauriCommand({
__tauriModule: 'Window',
message: {
cmd: 'manage',
data: {
label: this.label,
cmd: {
type: 'outerPosition'
}
}
}
})
}
/**
* The physical size of the window's client area.
* The client area is the content of the window, excluding the title bar and borders.
*/
async innerSize(): Promise<PhysicalSize> {
return invokeTauriCommand({
__tauriModule: 'Window',
message: {
cmd: 'manage',
data: {
label: this.label,
cmd: {
type: 'innerSize'
}
}
}
})
}
/**
* The physical size of the entire window.
* These dimensions include the title bar and borders. If you don't want that (and you usually don't), use inner_size instead.
*/
async outerSize(): Promise<PhysicalSize> {
return invokeTauriCommand({
__tauriModule: 'Window',
message: {
cmd: 'manage',
data: {
label: this.label,
cmd: {
type: 'outerSize'
}
}
}
})
}
/** Gets the window's current fullscreen state. */
async isFullscreen(): Promise<boolean> {
return invokeTauriCommand({
__tauriModule: 'Window',
message: {
cmd: 'manage',
data: {
label: this.label,
cmd: {
type: 'isFullscreen'
}
}
}
})
}
/** Gets the window's current maximized state. */
async isMaximized(): Promise<boolean> {
return invokeTauriCommand({
__tauriModule: 'Window',
message: {
cmd: 'manage',
data: {
label: this.label,
cmd: {
type: 'isMaximized'
}
}
}
})
}
/** Gets the window's current decorated state. */
async isDecorated(): Promise<boolean> {
return invokeTauriCommand({
__tauriModule: 'Window',
message: {
cmd: 'manage',
data: {
label: this.label,
cmd: {
type: 'isDecorated'
}
}
}
})
}
/** Gets the window's current resizable state. */
async isResizable(): Promise<boolean> {
return invokeTauriCommand({
__tauriModule: 'Window',
message: {
cmd: 'manage',
data: {
label: this.label,
cmd: {
type: 'isResizable'
}
}
}
})
}
/** Gets the window's current visible state. */
async isVisible(): Promise<boolean> {
return invokeTauriCommand({
__tauriModule: 'Window',
message: {
cmd: 'manage',
data: {
label: this.label,
cmd: {
type: 'isVisible'
}
}
}
})
}
// Setters
/**
* Centers the window.
*
* @param resizable
* @returns A promise indicating the success or failure of the operation.
*/
async center(): Promise<void> {
return invokeTauriCommand({
__tauriModule: 'Window',
message: {
cmd: 'manage',
data: {
label: this.label,
cmd: {
type: 'center'
}
}
}
})
}
/**
* Requests user attention to the window, this has no effect if the application
* is already focused. How requesting for user attention manifests is platform dependent,
* see `UserAttentionType` for details.
*
* Providing `null` will unset the request for user attention. Unsetting the request for
* user attention might not be done automatically by the WM when the window receives input.
*
* ## Platform-specific
*
* - **macOS:** `null` has no effect.
*
* @param resizable
* @returns A promise indicating the success or failure of the operation.
*/
async requestUserAttention(
requestType: UserAttentionType | null
): Promise<void> {
let requestType_ = null
if (requestType) {
if (requestType === UserAttentionType.Critical) {
requestType_ = { type: 'Critical' }
} else {
requestType_ = { type: 'Informational' }
}
}
return invokeTauriCommand({
__tauriModule: 'Window',
message: {
cmd: 'manage',
data: {
label: this.label,
cmd: {
type: 'requestUserAttention',
payload: requestType_
}
}
}
})
}
/**
* Updates the window resizable flag.
*
* @param resizable
* @returns A promise indicating the success or failure of the operation.
*/
async setResizable(resizable: boolean): Promise<void> {
return invokeTauriCommand({
__tauriModule: 'Window',
message: {
cmd: 'manage',
data: {
label: this.label,
cmd: {
type: 'setResizable',
payload: resizable
}
}
}
})
}
/**
* Sets the window title.
*
* @param title The new title
* @returns A promise indicating the success or failure of the operation.
*/
async setTitle(title: string): Promise<void> {
return invokeTauriCommand({
__tauriModule: 'Window',
message: {
cmd: 'manage',
data: {
label: this.label,
cmd: {
type: 'setTitle',
payload: title
}
}
}
})
}
/**
* Maximizes the window.
*
* @returns A promise indicating the success or failure of the operation.
*/
async maximize(): Promise<void> {
return invokeTauriCommand({
__tauriModule: 'Window',
message: {
cmd: 'manage',
data: {
label: this.label,
cmd: {
type: 'maximize'
}
}
}
})
}
/**
* Unmaximizes the window.
*
* @returns A promise indicating the success or failure of the operation.
*/
async unmaximize(): Promise<void> {
return invokeTauriCommand({
__tauriModule: 'Window',
message: {
cmd: 'manage',
data: {
label: this.label,
cmd: {
type: 'unmaximize'
}
}
}
})
}
/**
* Toggles the window maximized state.
*
* @returns A promise indicating the success or failure of the operation.
*/
async toggleMaximize(): Promise<void> {
return invokeTauriCommand({
__tauriModule: 'Window',
message: {
cmd: 'manage',
data: {
label: this.label,
cmd: {
type: 'toggleMaximize'
}
}
}
})
}
/**
* Minimizes the window.
*
* @returns A promise indicating the success or failure of the operation.
*/
async minimize(): Promise<void> {
return invokeTauriCommand({
__tauriModule: 'Window',
message: {
cmd: 'manage',
data: {
label: this.label,
cmd: {
type: 'minimize'
}
}
}
})
}
/**
* Unminimizes the window.
*
* @returns A promise indicating the success or failure of the operation.
*/
async unminimize(): Promise<void> {
return invokeTauriCommand({
__tauriModule: 'Window',
message: {
cmd: 'manage',
data: {
label: this.label,
cmd: {
type: 'unminimize'
}
}
}
})
}
/**
* Sets the window visibility to true.
*
* @returns A promise indicating the success or failure of the operation.
*/
async show(): Promise<void> {
return invokeTauriCommand({
__tauriModule: 'Window',
message: {
cmd: 'manage',
data: {
label: this.label,
cmd: {
type: 'show'
}
}
}
})
}
/**
* Sets the window visibility to false.
*
* @returns A promise indicating the success or failure of the operation.
*/
async hide(): Promise<void> {
return invokeTauriCommand({
__tauriModule: 'Window',
message: {
cmd: 'manage',
data: {
label: this.label,
cmd: {
type: 'hide'
}
}
}
})
}
/**
* Closes the window.
*
* @returns A promise indicating the success or failure of the operation.
*/
async close(): Promise<void> {
return invokeTauriCommand({
__tauriModule: 'Window',
message: {
cmd: 'manage',
data: {
label: this.label,
cmd: {
type: 'close'
}
}
}
})
}
/**
* Whether the window should have borders and bars.
*
* @param decorations Whether the window should have borders and bars.
* @returns A promise indicating the success or failure of the operation.
*/
async setDecorations(decorations: boolean): Promise<void> {
return invokeTauriCommand({
__tauriModule: 'Window',
message: {
cmd: 'manage',
data: {
label: this.label,
cmd: {
type: 'setDecorations',
payload: decorations
}
}
}
})
}
/**
* Whether the window should always be on top of other windows.
*
* @param alwaysOnTop Whether the window should always be on top of other windows or not.
* @returns A promise indicating the success or failure of the operation.
*/
async setAlwaysOnTop(alwaysOnTop: boolean): Promise<void> {
return invokeTauriCommand({
__tauriModule: 'Window',
message: {
cmd: 'manage',
data: {
label: this.label,
cmd: {
type: 'setAlwaysOnTop',
payload: alwaysOnTop
}
}
}
})
}
/**
* Resizes the window.
* @example
* ```typescript
* import { appWindow, LogicalSize } from '@tauri-apps/api/window'
* await appWindow.setSize(new LogicalSize(600, 500))
* ```
*
* @param size The logical or physical size.
* @returns A promise indicating the success or failure of the operation.
*/
async setSize(size: LogicalSize | PhysicalSize): Promise<void> {
if (!size || (size.type !== 'Logical' && size.type !== 'Physical')) {
throw new Error(
'the `size` argument must be either a LogicalSize or a PhysicalSize instance'
)
}
return invokeTauriCommand({
__tauriModule: 'Window',
message: {
cmd: 'manage',
data: {
label: this.label,
cmd: {
type: 'setSize',
payload: {
type: size.type,
data: {
width: size.width,
height: size.height
}
}
}
}
}
})
}
/**
* Sets the window min size. If the `size` argument is not provided, the min size is unset.
* @example
* ```typescript
* import { appWindow, PhysicalSize } from '@tauri-apps/api/window'
* await appWindow.setMinSize(new PhysicalSize(600, 500))
* ```
*
* @param size The logical or physical size.
* @returns A promise indicating the success or failure of the operation.
*/
async setMinSize(
size: LogicalSize | PhysicalSize | undefined
): Promise<void> {
if (size && size.type !== 'Logical' && size.type !== 'Physical') {
throw new Error(
'the `size` argument must be either a LogicalSize or a PhysicalSize instance'
)
}
return invokeTauriCommand({
__tauriModule: 'Window',
message: {
cmd: 'manage',
data: {
label: this.label,
cmd: {
type: 'setMinSize',
payload: size
? {
type: size.type,
data: {
width: size.width,
height: size.height
}
}
: null
}
}
}
})
}
/**
* Sets the window max size. If the `size` argument is undefined, the max size is unset.
* @example
* ```typescript
* import { appWindow, LogicalSize } from '@tauri-apps/api/window'
* await appWindow.setMaxSize(new LogicalSize(600, 500))
* ```
*
* @param size The logical or physical size.
* @returns A promise indicating the success or failure of the operation.
*/
async setMaxSize(
size: LogicalSize | PhysicalSize | undefined
): Promise<void> {
if (size && size.type !== 'Logical' && size.type !== 'Physical') {
throw new Error(
'the `size` argument must be either a LogicalSize or a PhysicalSize instance'
)
}
return invokeTauriCommand({
__tauriModule: 'Window',
message: {
cmd: 'manage',
data: {
label: this.label,
cmd: {
type: 'setMaxSize',
payload: size
? {
type: size.type,
data: {
width: size.width,
height: size.height
}
}
: null
}
}
}
})
}
/**
* Sets the window position.
* @example
* ```typescript
* import { appWindow, LogicalPosition } from '@tauri-apps/api/window'
* await appWindow.setPosition(new LogicalPosition(600, 500))
* ```
*
* @param position The new position, in logical or physical pixels.
* @returns A promise indicating the success or failure of the operation.
*/
async setPosition(
position: LogicalPosition | PhysicalPosition
): Promise<void> {
if (
!position ||
(position.type !== 'Logical' && position.type !== 'Physical')
) {
throw new Error(
'the `position` argument must be either a LogicalPosition or a PhysicalPosition instance'
)
}
return invokeTauriCommand({
__tauriModule: 'Window',
message: {
cmd: 'manage',
data: {
label: this.label,
cmd: {
type: 'setPosition',
payload: {
type: position.type,
data: {
x: position.x,
y: position.y
}
}
}
}
}
})
}
/**
* Sets the window fullscreen state.
*
* @param fullscreen Whether the window should go to fullscreen or not.
* @returns A promise indicating the success or failure of the operation.
*/
async setFullscreen(fullscreen: boolean): Promise<void> {
return invokeTauriCommand({
__tauriModule: 'Window',
message: {
cmd: 'manage',
data: {
label: this.label,
cmd: {
type: 'setFullscreen',
payload: fullscreen
}
}
}
})
}
/**
* Bring the window to front and focus.
*
* @returns A promise indicating the success or failure of the operation.
*/
async setFocus(): Promise<void> {
return invokeTauriCommand({
__tauriModule: 'Window',
message: {
cmd: 'manage',
data: {
label: this.label,
cmd: {
type: 'setFocus'
}
}
}
})
}
/**