Skip to content

Commit 5791dcf

Browse files
committed
(#445) Extracted config interfaces for keyboard, mouse and screen
1 parent bc5e99c commit 5791dcf

File tree

3 files changed

+57
-37
lines changed

3 files changed

+57
-37
lines changed

lib/keyboard.class.ts

+11-4
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,24 @@ const inputIsString = (input: (string | Key)[]): input is string[] => {
88
return input.every((elem: string | Key) => typeof elem === "string");
99
};
1010

11+
/**
12+
* Config object for {@link KeyboardClass} class
13+
*/
14+
export interface KeyboardConfig {
15+
/**
16+
* Configures the delay between single key events
17+
*/
18+
autoDelayMs: number;
19+
}
20+
1121
/**
1222
* {@link KeyboardClass} class provides methods to emulate keyboard input
1323
*/
1424
export class KeyboardClass {
1525
/**
1626
* Config object for {@link KeyboardClass} class
1727
*/
18-
public config = {
19-
/**
20-
* Configures the delay between single key events
21-
*/
28+
public config: KeyboardConfig = {
2229
autoDelayMs: 300,
2330
};
2431

lib/mouse.class.ts

+16-11
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,26 @@ import {
99
import { ProviderRegistry } from "./provider/provider-registry.class";
1010

1111
/**
12-
* {@link MouseClass} class provides methods to emulate mouse input
12+
* Config object for {@link MouseClass} class
1313
*/
14-
export class MouseClass {
14+
export interface MouseConfig {
1515
/**
16-
* Config object for {@link MouseClass} class
16+
* Configures the delay between single mouse events
1717
*/
18-
public config = {
19-
/**
20-
* Configures the delay between single mouse events
21-
*/
22-
autoDelayMs: 100,
18+
autoDelayMs: number;
19+
20+
/**
21+
* Configures the speed in pixels/second for mouse movement
22+
*/
23+
mouseSpeed: number;
24+
}
2325

24-
/**
25-
* Configures the speed in pixels/second for mouse movement
26-
*/
26+
/**
27+
* {@link MouseClass} class provides methods to emulate mouse input
28+
*/
29+
export class MouseClass {
30+
public config: MouseConfig = {
31+
autoDelayMs: 100,
2732
mouseSpeed: 1000,
2833
};
2934

lib/screen.class.ts

+30-22
Original file line numberDiff line numberDiff line change
@@ -46,35 +46,43 @@ function validateSearchRegion(search: Region, screen: Region) {
4646
}
4747

4848
/**
49-
* {@link ScreenClass} class provides methods to access screen content of a systems main display
49+
* Config object for {@link ScreenClass} class
5050
*/
51-
export class ScreenClass {
51+
export interface ScreenConfig {
5252
/**
53-
* Config object for {@link ScreenClass} class
53+
* Configures the required matching percentage for template images to be declared as a match
5454
*/
55-
public config = {
56-
/**
57-
* Configures the required matching percentage for template images to be declared as a match
58-
*/
59-
confidence: 0.99,
55+
confidence: number;
56+
57+
/**
58+
* Configure whether to auto highlight all search results or not
59+
*/
60+
autoHighlight: boolean;
61+
/**
62+
* Configure highlighting duration
63+
*/
64+
highlightDurationMs: number;
65+
66+
/**
67+
* Configure opacity of highlight window
68+
*/
69+
highlightOpacity: number;
6070

61-
/**
62-
* Configure whether to auto highlight all search results or not
63-
*/
71+
/**
72+
* Configures the path from which template images are loaded from
73+
*/
74+
resourceDirectory: string;
75+
}
76+
77+
/**
78+
* {@link ScreenClass} class provides methods to access screen content of a systems main display
79+
*/
80+
export class ScreenClass {
81+
public config: ScreenConfig = {
82+
confidence: 0.99,
6483
autoHighlight: false,
65-
/**
66-
* Configure highlighting duration
67-
*/
6884
highlightDurationMs: 500,
69-
70-
/**
71-
* Configure opacity of highlight window
72-
*/
7385
highlightOpacity: 0.25,
74-
75-
/**
76-
* Configures the path from which template images are loaded from
77-
*/
7886
resourceDirectory: cwd(),
7987
};
8088

0 commit comments

Comments
 (0)