Skip to content

Commit 720dea6

Browse files
authored
Feature/445/config interfaces (#446)
* (#445) Extracted config interfaces for keyboard, mouse and screen * (#445) Export config interfaces
1 parent 6600df5 commit 720dea6

File tree

4 files changed

+63
-40
lines changed

4 files changed

+63
-40
lines changed

index.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { AssertClass } from "./lib/assert.class";
22
import { ClipboardClass } from "./lib/clipboard.class";
3-
import { KeyboardClass } from "./lib/keyboard.class";
4-
import { MouseClass } from "./lib/mouse.class";
3+
import { KeyboardClass, KeyboardConfig } from "./lib/keyboard.class";
4+
import { MouseClass, MouseConfig } from "./lib/mouse.class";
55
import { createMovementApi } from "./lib/movement.function";
6-
import { ScreenClass } from "./lib/screen.class";
6+
import { ScreenClass, ScreenConfig } from "./lib/screen.class";
77
import { LineHelper } from "./lib/util/linehelper.class";
88
import { createWindowApi } from "./lib/window.function";
99
import providerRegistry from "./lib/provider/provider-registry.class";
@@ -13,8 +13,11 @@ export {
1313
AssertClass,
1414
ClipboardClass,
1515
KeyboardClass,
16+
KeyboardConfig,
1617
MouseClass,
18+
MouseConfig,
1719
ScreenClass,
20+
ScreenConfig,
1821
providerRegistry,
1922
};
2023

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)