Skip to content

Commit 7064a15

Browse files
authored
Feature/294/export provider interfaces (#295)
* (#294) Export interfaces for providers * (#294) Align naming of interfaces
1 parent a1fcc65 commit 7064a15

17 files changed

+69
-55
lines changed

Diff for: index.ts

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ export {
1919
providerRegistry
2020
}
2121

22+
export {MatchRequest} from "./lib/match-request.class";
23+
export {MatchResult} from "./lib/match-result.class";
24+
export * from "./lib/provider";
25+
2226
export {jestMatchers} from "./lib/expect/jest.matcher.function";
2327
export {sleep} from "./lib/sleep.function";
2428
export {Image} from "./lib/image.class";

Diff for: lib/provider/clipboard-provider.interface.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* A ClipboardActionProvider should allow access to the system clipboard
33
*/
4-
export interface ClipboardProvider {
4+
export interface ClipboardProviderInterface {
55
/**
66
* hasText should return whether the system clipboard currently holds text or not
77
*

Diff for: lib/provider/data-sink.interface.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/**
22
* A DataSink should provide methods to store data
33
*
4-
* @interface DataSink
4+
* @interface DataSinkInterface
55
*/
6-
export interface DataSink<PARAMETER_TYPE, RETURN_TYPE> {
6+
export interface DataSinkInterface<PARAMETER_TYPE, RETURN_TYPE> {
77
/**
88
* store will store data to disk
99
* @param parameters Required parameters

Diff for: lib/provider/data-source.interface.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/**
22
* A DataSource should provide methods to load data
33
*
4-
* @interface DataSource
4+
* @interface DataSourceInterface
55
*/
6-
export interface DataSource<PARAMETER_TYPE, RESULT_TYPE> {
6+
export interface DataSourceInterface<PARAMETER_TYPE, RESULT_TYPE> {
77
/**
88
* load will load data from disk
99
* @param parameters Required parameters

Diff for: lib/provider/image-reader.type.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {DataSource} from "./data-source.interface";
1+
import {DataSourceInterface} from "./data-source.interface";
22
import {Image} from "../image.class";
33

4-
export type ImageReader = DataSource<string, Image>;
4+
export type ImageReader = DataSourceInterface<string, Image>;

Diff for: lib/provider/image-writer.type.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import {Image} from "../image.class";
2-
import {DataSink} from "./data-sink.interface";
2+
import {DataSinkInterface} from "./data-sink.interface";
33

44
export interface ImageWriterParameters {
55
data: Image,
66
path: string
77
}
88

9-
export type ImageWriter = DataSink<ImageWriterParameters, void>;
9+
export type ImageWriter = DataSinkInterface<ImageWriterParameters, void>;

Diff for: lib/provider/index.ts

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export {ClipboardProviderInterface} from "./clipboard-provider.interface";
2+
export {DataSinkInterface} from "./data-sink.interface";
3+
export {DataSourceInterface} from "./data-source.interface";
4+
export {ImageFinderInterface} from "./image-finder.interface";
5+
export {ImageReader} from "./image-reader.type";
6+
export {ImageWriter} from "./image-writer.type";
7+
export {KeyboardProviderInterface} from "./keyboard-provider.interface";
8+
export {MouseProviderInterface} from "./mouse-provider.interface";
9+
export {ScreenProviderInterface} from "./screen-provider.interface";
10+
export {WindowProviderInterface} from "./window-provider.interface";

Diff for: lib/provider/keyboard-provider.interface.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Key } from "../key.enum";
33
/**
44
* A KeyboardActionProvider should provide access to a systems keyboard
55
*/
6-
export interface KeyboardProvider {
6+
export interface KeyboardProviderInterface {
77
/**
88
* setKeyboardDelay should allow to configure a delay between key presses
99
*

Diff for: lib/provider/mouse-provider.interface.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Point } from "../point.class";
44
/**
55
* A MouseActionProvider should provide access to a systems mouse input
66
*/
7-
export interface MouseProvider {
7+
export interface MouseProviderInterface {
88
/**
99
* setMouseDelay should allow to configure mouse movement speed
1010
*

Diff for: lib/provider/native/clipboardy-clipboard.class.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import clippy from "clipboardy";
2-
import { ClipboardProvider } from "../clipboard-provider.interface";
2+
import { ClipboardProviderInterface } from "../clipboard-provider.interface";
33

4-
export default class implements ClipboardProvider {
4+
export default class implements ClipboardProviderInterface {
55
constructor() {
66
}
77

Diff for: lib/provider/native/libnut-keyboard.class.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import libnut = require("@nut-tree/libnut");
22
import { Key } from "../../key.enum";
3-
import { KeyboardProvider } from "../keyboard-provider.interface";
3+
import { KeyboardProviderInterface } from "../keyboard-provider.interface";
44

5-
export default class KeyboardAction implements KeyboardProvider {
5+
export default class KeyboardAction implements KeyboardProviderInterface {
66

77
public static KeyLookupMap = new Map<Key, string | null>([
88
[Key.A, "a"],

Diff for: lib/provider/native/libnut-mouse.class.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import libnut = require("@nut-tree/libnut");
22
import { Button } from "../../button.enum";
33
import { Point } from "../../point.class";
4-
import { MouseProvider } from "../mouse-provider.interface";
4+
import { MouseProviderInterface } from "../mouse-provider.interface";
55

6-
export default class MouseAction implements MouseProvider {
6+
export default class MouseAction implements MouseProviderInterface {
77
public static buttonLookup(btn: Button): any {
88
return this.ButtonLookupMap.get(btn);
99
}

Diff for: lib/provider/native/libnut-screen.class.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import libnut = require("@nut-tree/libnut");
22
import { Image } from "../../image.class";
33
import { Region } from "../../region.class";
4-
import { ScreenProvider } from "../screen-provider.interface";
4+
import { ScreenProviderInterface } from "../screen-provider.interface";
55

6-
export default class ScreenAction implements ScreenProvider {
6+
export default class ScreenAction implements ScreenProviderInterface {
77

88
private static determinePixelDensity(
99
screen: Region,

Diff for: lib/provider/native/libnut-window.class.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import libnut = require("@nut-tree/libnut");
22
import { Region } from "../../region.class";
3-
import { WindowProvider } from "../window-provider.interface";
3+
import { WindowProviderInterface } from "../window-provider.interface";
44

5-
export default class WindowAction implements WindowProvider {
5+
export default class WindowAction implements WindowProviderInterface {
66
public getWindows(): Promise<number[]> {
77
return new Promise<number[]>((resolve, reject) => {
88
try {

Diff for: lib/provider/provider-registry.class.ts

+30-30
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import {ClipboardProvider} from "./clipboard-provider.interface";
1+
import {ClipboardProviderInterface} from "./clipboard-provider.interface";
22
import {ImageFinderInterface} from "./image-finder.interface";
3-
import {KeyboardProvider} from "./keyboard-provider.interface";
4-
import {MouseProvider} from "./mouse-provider.interface";
5-
import {ScreenProvider} from "./screen-provider.interface";
6-
import {WindowProvider} from "./window-provider.interface";
3+
import {KeyboardProviderInterface} from "./keyboard-provider.interface";
4+
import {MouseProviderInterface} from "./mouse-provider.interface";
5+
import {ScreenProviderInterface} from "./screen-provider.interface";
6+
import {WindowProviderInterface} from "./window-provider.interface";
77

88
import Clipboard from "./native/clipboardy-clipboard.class";
99
import Finder from "./opencv/template-matching-finder.class";
@@ -17,23 +17,23 @@ import ImageReaderImpl from "./opencv/image-reader.class";
1717
import ImageWriterImpl from "./opencv/image-writer.class";
1818

1919
export interface ProviderRegistry {
20-
getClipboard(): ClipboardProvider;
21-
registerClipboardProvider(value: ClipboardProvider): void;
20+
getClipboard(): ClipboardProviderInterface;
21+
registerClipboardProvider(value: ClipboardProviderInterface): void;
2222

2323
getImageFinder(): ImageFinderInterface;
2424
registerImageFinder(value: ImageFinderInterface): void;
2525

26-
getKeyboard(): KeyboardProvider;
27-
registerKeyboardProvider(value: KeyboardProvider): void;
26+
getKeyboard(): KeyboardProviderInterface;
27+
registerKeyboardProvider(value: KeyboardProviderInterface): void;
2828

29-
getMouse(): MouseProvider;
30-
registerMouseProvider(value: MouseProvider): void;
29+
getMouse(): MouseProviderInterface;
30+
registerMouseProvider(value: MouseProviderInterface): void;
3131

32-
getScreen(): ScreenProvider;
33-
registerScreenProvider(value: ScreenProvider): void;
32+
getScreen(): ScreenProviderInterface;
33+
registerScreenProvider(value: ScreenProviderInterface): void;
3434

35-
getWindow(): WindowProvider;
36-
registerWindowProvider(value: WindowProvider): void;
35+
getWindow(): WindowProviderInterface;
36+
registerWindowProvider(value: WindowProviderInterface): void;
3737

3838
getImageReader(): ImageReader;
3939
registerImageReader(value: ImageReader): void;
@@ -43,23 +43,23 @@ export interface ProviderRegistry {
4343
}
4444

4545
class DefaultProviderRegistry implements ProviderRegistry {
46-
private _clipboard?: ClipboardProvider;
46+
private _clipboard?: ClipboardProviderInterface;
4747
private _finder?: ImageFinderInterface;
48-
private _keyboard?: KeyboardProvider;
49-
private _mouse?: MouseProvider;
50-
private _screen?: ScreenProvider;
51-
private _window?: WindowProvider;
48+
private _keyboard?: KeyboardProviderInterface;
49+
private _mouse?: MouseProviderInterface;
50+
private _screen?: ScreenProviderInterface;
51+
private _window?: WindowProviderInterface;
5252
private _imageReader?: ImageReader;
5353
private _imageWriter?: ImageWriter;
5454

55-
getClipboard(): ClipboardProvider {
55+
getClipboard(): ClipboardProviderInterface {
5656
if (this._clipboard) {
5757
return this._clipboard;
5858
}
5959
throw new Error(`No ClipboardProvider registered`);
6060
}
6161

62-
registerClipboardProvider(value: ClipboardProvider) {
62+
registerClipboardProvider(value: ClipboardProviderInterface) {
6363
this._clipboard = value;
6464
}
6565

@@ -74,47 +74,47 @@ class DefaultProviderRegistry implements ProviderRegistry {
7474
this._finder = value;
7575
}
7676

77-
getKeyboard(): KeyboardProvider {
77+
getKeyboard(): KeyboardProviderInterface {
7878
if (this._keyboard) {
7979
return this._keyboard;
8080
}
8181
throw new Error(`No KeyboardProvider registered`);
8282
}
8383

84-
registerKeyboardProvider(value: KeyboardProvider) {
84+
registerKeyboardProvider(value: KeyboardProviderInterface) {
8585
this._keyboard = value;
8686
}
8787

88-
getMouse(): MouseProvider {
88+
getMouse(): MouseProviderInterface {
8989
if (this._mouse) {
9090
return this._mouse;
9191
}
9292
throw new Error(`No MouseProvider registered`);
9393
}
9494

95-
registerMouseProvider(value: MouseProvider) {
95+
registerMouseProvider(value: MouseProviderInterface) {
9696
this._mouse = value;
9797
}
9898

99-
getScreen(): ScreenProvider {
99+
getScreen(): ScreenProviderInterface {
100100
if (this._screen) {
101101
return this._screen;
102102
}
103103
throw new Error(`No ScreenProvider registered`);
104104
}
105105

106-
registerScreenProvider(value: ScreenProvider) {
106+
registerScreenProvider(value: ScreenProviderInterface) {
107107
this._screen = value;
108108
}
109109

110-
getWindow(): WindowProvider {
110+
getWindow(): WindowProviderInterface {
111111
if (this._window) {
112112
return this._window;
113113
}
114114
throw new Error(`No WindowProvider registered`);
115115
}
116116

117-
registerWindowProvider(value: WindowProvider) {
117+
registerWindowProvider(value: WindowProviderInterface) {
118118
this._window = value;
119119
}
120120

Diff for: lib/provider/screen-provider.interface.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import { Region } from "../region.class";
44
/**
55
* A ScreenActionProvider should provide access to a system's main screen
66
*
7-
* @interface ScreenProvider
7+
* @interface ScreenProviderInterface
88
*/
9-
export interface ScreenProvider {
9+
export interface ScreenProviderInterface {
1010
/**
1111
* grabScreen should return an {@link Image} object containing a screenshot data of a systems
1212
* main screen as well as its dimensions

Diff for: lib/provider/window-provider.interface.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import { Region } from "../region.class";
33
/**
44
* A WindowActionProvider should provide access to a system's window system
55
*
6-
* @interface WindowProvider
6+
* @interface WindowProviderInterface
77
*/
8-
export interface WindowProvider {
8+
export interface WindowProviderInterface {
99
/**
1010
* {@link getWindows} returns a list of window handles for further processing.
1111
* These window handles may serve as input to e.g. {@link getWindowTitle}

0 commit comments

Comments
 (0)