File tree 3 files changed +42
-0
lines changed
3 files changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ /**
2
+ * {@link WindowApi } provides helper functions to handle windows
3
+ */
4
+ import { Window } from "./window.class" ;
5
+
6
+ export interface WindowApi {
7
+ windows ( ) : Promise < Window [ ] > ;
8
+ activeWindow ( ) : Promise < Window > ;
9
+ }
Original file line number Diff line number Diff line change
1
+ import { NativeAdapter } from "./adapter/native.adapter.class" ;
2
+ import { Region } from "./region.class" ;
3
+
4
+ export class Window {
5
+ constructor ( private nativeActions : NativeAdapter , private windowHandle : number ) {
6
+ }
7
+
8
+ get title ( ) : Promise < string > {
9
+ return this . nativeActions . getWindowTitle ( this . windowHandle ) ;
10
+ }
11
+
12
+ get region ( ) : Promise < Region > {
13
+ return this . nativeActions . getWindowRegion ( this . windowHandle ) ;
14
+ }
15
+ }
Original file line number Diff line number Diff line change
1
+ import { WindowApi } from "./window-api.interface" ;
2
+ import { NativeAdapter } from "./adapter/native.adapter.class" ;
3
+ import { Window } from "./window.class" ;
4
+
5
+ export const createWindowApi = ( nativeAdapter : NativeAdapter ) : WindowApi => {
6
+ return ( {
7
+ async activeWindow ( ) : Promise < Window > {
8
+ const windowHandle = await nativeAdapter . getActiveWindow ( ) ;
9
+ return new Window ( nativeAdapter , windowHandle ) ;
10
+ } ,
11
+ async windows ( ) : Promise < Window [ ] > {
12
+ const windowHandles = await nativeAdapter . getWindows ( ) ;
13
+ return windowHandles . map ( ( handle : number ) => {
14
+ return new Window ( nativeAdapter , handle ) ;
15
+ } ) ;
16
+ } ,
17
+ } ) ;
18
+ } ;
You can’t perform that action at this time.
0 commit comments