Skip to content

Commit f1c6e47

Browse files
committed
(#87) NativeAdapter API docs
1 parent d7fa9d0 commit f1c6e47

File tree

1 file changed

+43
-57
lines changed

1 file changed

+43
-57
lines changed

Diff for: lib/adapter/native.adapter.class.ts

+43-57
Original file line numberDiff line numberDiff line change
@@ -9,199 +9,185 @@ import { KeyboardAction } from "../provider/native/robotjs-keyboard-action.class
99
import { MouseAction } from "../provider/native/robotjs-mouse-action.class";
1010

1111
/**
12-
* NativeAdapter serves as an abstraction layer for all OS level interactions.
12+
* {@link NativeAdapter} serves as an abstraction layer for all OS level interactions.
1313
*
1414
* This allows to provide a high level interface for native actions,
15-
* whithout having to spread (possibly) multiple dependencies all over the code.
15+
* without having to spread (possibly) multiple dependencies all over the code.
1616
* All actions which involve the OS are bundled in this adapter.
1717
*/
1818
export class NativeAdapter {
19+
/**
20+
* {@link NativeAdapter} class constructor
21+
* @param clipboard {@link ClipboardActionProvider} instance used to interact with a systems clipboard (Default: {@link ClipboardAction})
22+
* @param keyboard {@link KeyboardActionProvider} instance used to interact with a systems keybaord (Default: {@link KeyboardAction})
23+
* @param mouse {@link MouseActionInterface} instance used to interact with a systems mouse (Default: {@link MouseAction})
24+
*/
1925
constructor(
2026
private clipboard: ClipboardActionProvider = new ClipboardAction(),
2127
private keyboard: KeyboardActionProvider = new KeyboardAction(),
2228
private mouse: MouseActionInterface = new MouseAction(),
2329
) {}
2430

2531
/**
26-
* setMouseDelay configures mouse speed for movement
32+
* {@link setMouseDelay} configures mouse speed for movement
2733
*
28-
* @param {number} delay The delay
29-
* @memberof NativeAdapter
34+
* @param delay Mouse delay in milliseconds
3035
*/
3136
public setMouseDelay(delay: number): void {
3237
this.mouse.setMouseDelay(delay);
3338
}
3439

3540
/**
36-
* setKeyboardDelay configures keyboard delay between key presses
41+
* {@link setKeyboardDelay} configures keyboard delay between key presses
3742
*
38-
* @param {number} delay The delay
39-
* @memberof NativeAdapter
43+
* @param delay The keyboard delay in milliseconds
4044
*/
4145
public setKeyboardDelay(delay: number): void {
4246
this.keyboard.setKeyboardDelay(delay);
4347
}
4448

4549
/**
46-
* setMousePosition changes the current mouse cursor position to a given point
50+
* {@link setMousePosition} changes the current mouse cursor position to a given {@link Point}
4751
*
48-
* @param {Point} p The new cursor position
49-
* @memberof NativeAdapter
52+
* @param p The new cursor position at {@link Point} p
5053
*/
5154
public setMousePosition(p: Point): Promise<void> {
5255
return this.mouse.setMousePosition(p);
5356
}
5457

5558
/**
56-
* getMousePosition returns the current mouse position
59+
* {@link currentMousePosition} returns the current mouse position
5760
*
58-
* @returns {Promise<Point>} Current cursor position
59-
* @memberof NativeAdapter
61+
* @returns Current cursor position at a certain {@link Point}
6062
*/
6163
public currentMousePosition(): Promise<Point> {
6264
return this.mouse.currentMousePosition();
6365
}
6466

6567
/**
66-
* leftClick triggers a native left-click event via OS API
67-
*
68-
* @memberof NativeAdapter
68+
* {@link leftClick} triggers a native left-click event via OS API
6969
*/
7070
public leftClick(): Promise<void> {
7171
return this.mouse.leftClick();
7272
}
7373

7474
/**
75-
* rightClick triggers a native right-click event via OS API
76-
*
77-
* @memberof NativeAdapter
75+
* {@link rightClick} triggers a native right-click event via OS API
7876
*/
7977
public rightClick(): Promise<void> {
8078
return this.mouse.rightClick();
8179
}
8280

8381
/**
84-
* middleClick triggers a native middle-click event via OS API
82+
* {@link middleClick} triggers a native middle-click event via OS API
8583
*/
8684
public middleClick(): Promise<void> {
8785
return this.mouse.middleClick();
8886
}
8987

9088
/**
91-
* pressButton presses and holds a mouse button
89+
* {@link pressButton} presses and holds a mouse {@link Button}
9290
*
93-
* @param {Button} btn The mouse button to press
94-
* @memberof NativeAdapter
91+
* @param btn The mouse {@link Button} to press
9592
*/
9693
public pressButton(btn: Button): Promise<void> {
9794
return this.mouse.pressButton(btn);
9895
}
9996

10097
/**
101-
* releaseButton releases a mouse button previously clicked via pressButton
98+
* {@link releaseButton} releases a mouse {@link Button} previously clicked via {@link pressButton}
10299
*
103-
* @param {Button} btn The mouse button to release
104-
* @memberof NativeAdapter
100+
* @param btn The mouse {@link Button} to release
105101
*/
106102
public releaseButton(btn: Button): Promise<void> {
107103
return this.mouse.releaseButton(btn);
108104
}
109105

110106
/**
111-
* type types a given string via native keyboard events
107+
* {@link type} types a given string via native keyboard events
112108
*
113-
* @param {string} input The text to type
114-
* @memberof NativeAdapter
109+
* @param input The text to type
115110
*/
116111
public type(input: string): Promise<void> {
117112
return this.keyboard.type(input);
118113
}
119114

120115
/**
121-
* click clicks a single Key via native keyboard event
116+
* {@link click} clicks a {@link Key} via native keyboard event
122117
*
123-
* @param {Key[]} keys The keys to click
124-
* @memberof NativeAdapter
118+
* @param keys Array of {@link Key}s to click
125119
*/
126120
public click(...keys: Key[]): Promise<void> {
127121
return this.keyboard.click(...keys);
128122
}
129123

130124
/**
131-
* pressKey presses and holds a given Key
125+
* {@link pressKey} presses and holds a given {@link Key}
132126
*
133-
* @param {Key[]} keys The Keys to press and hold
134-
* @memberof NativeAdapter
127+
* @param keys Array of {@link Key}s to press and hold
135128
*/
136129
public pressKey(...keys: Key[]): Promise<void> {
137130
return this.keyboard.pressKey(...keys);
138131
}
139132

140133
/**
141-
* releaseKey releases a Key previously presses via pressKey
134+
* {@link releaseKey} releases a {@link Key} previously presses via {@link pressKey}
142135
*
143-
* @param {Key[]} keys The Keys to release
144-
* @memberof NativeAdapter
136+
* @param keys Array of {@link Key}s to release
145137
*/
146138
public releaseKey(...keys: Key[]): Promise<void> {
147139
return this.keyboard.releaseKey(...keys);
148140
}
149141

150142
/**
151-
* scrollUp triggers an upwards mouse wheel scroll
143+
* {@link scrollUp} triggers an upwards mouse wheel scroll
152144
*
153-
* @param {number} amount The amount of 'ticks' to scroll
154-
* @memberof NativeAdapter
145+
* @param amount The amount of 'ticks' to scroll
155146
*/
156147
public scrollUp(amount: number): Promise<void> {
157148
return this.mouse.scrollUp(amount);
158149
}
159150

160151
/**
161-
* scrollDown triggers a downward mouse wheel scroll
152+
* {@link scrollDown} triggers a downward mouse wheel scroll
162153
*
163-
* @param {number} amount The amount of 'ticks' to scroll
164-
* @memberof NativeAdapter
154+
* @param amount The amount of 'ticks' to scroll
165155
*/
166156
public scrollDown(amount: number): Promise<void> {
167157
return this.mouse.scrollDown(amount);
168158
}
169159

170160
/**
171-
* scrollLeft triggers a left mouse scroll
161+
* {@link scrollLeft} triggers a left mouse scroll
172162
*
173-
* @param {number} amount The amount of 'ticks' to scroll
174-
* @memberof NativeAdapter
163+
* @param amount The amount of 'ticks' to scroll
175164
*/
176165
public scrollLeft(amount: number): Promise<void> {
177166
return this.mouse.scrollLeft(amount);
178167
}
179168

180169
/**
181-
* scrollRight triggers a right mouse scroll
170+
* {@link scrollRight} triggers a right mouse scroll
182171
*
183-
* @param {number} amount The amount of 'ticks' to scroll
184-
* @memberof NativeAdapter
172+
* @param amount The amount of 'ticks' to scroll
185173
*/
186174
public scrollRight(amount: number): Promise<void> {
187175
return this.mouse.scrollRight(amount);
188176
}
189177

190178
/**
191-
* copy copies a given text to the system clipboard
179+
* {@link copy} copies a given text to the system clipboard
192180
*
193-
* @param {string} text The text to copy
194-
* @memberof NativeAdapter
181+
* @param text The text to copy
195182
*/
196183
public copy(text: string): Promise<void> {
197184
return this.clipboard.copy(text);
198185
}
199186

200187
/**
201-
* paste pastes the current text on the system clipboard
188+
* {@link paste} pastes the current text on the system clipboard
202189
*
203-
* @returns {Promise<string>} The clipboard text
204-
* @memberof NativeAdapter
190+
* @returns The clipboard text
205191
*/
206192
public paste(): Promise<string> {
207193
return this.clipboard.paste();

0 commit comments

Comments
 (0)