|
1 | 1 | import { NativeAdapter } from "./adapter/native.adapter.class"; |
2 | 2 | import { Button } from "./button.enum"; |
3 | | -import { MovementType } from "./movementtype.class"; |
| 3 | +import { linear } from "./movementtype.function"; |
4 | 4 | import { Point } from "./point.class"; |
5 | 5 | import { sleep } from "./sleep.function"; |
6 | 6 |
|
@@ -29,12 +29,13 @@ export class Mouse { |
29 | 29 | return this.native.currentMousePosition(); |
30 | 30 | } |
31 | 31 |
|
32 | | - public async move(path: Point[], movementType = MovementType.linear): Promise<Mouse> { |
| 32 | + public async move(path: Point[] | Promise<Point[]>, movementType = linear): Promise<Mouse> { |
33 | 33 | return new Promise<Mouse>(async (resolve, reject) => { |
34 | 34 | try { |
35 | | - const timeSteps = movementType(path.length, this.config.mouseSpeed); |
36 | | - for (let idx = 0; idx < path.length; ++idx) { |
37 | | - const node = path[idx]; |
| 35 | + const pathSteps = await path; |
| 36 | + const timeSteps = movementType(pathSteps.length, this.config.mouseSpeed); |
| 37 | + for (let idx = 0; idx < pathSteps.length; ++idx) { |
| 38 | + const node = pathSteps[idx]; |
38 | 39 | const minTime = timeSteps[idx]; |
39 | 40 | await sleep(minTime); |
40 | 41 | await this.native.setMousePosition(node); |
@@ -114,7 +115,7 @@ export class Mouse { |
114 | 115 | }); |
115 | 116 | } |
116 | 117 |
|
117 | | - public async drag(path: Point[]): Promise<Mouse> { |
| 118 | + public async drag(path: Point[] | Promise<Point[]>): Promise<Mouse> { |
118 | 119 | return new Promise<Mouse>(async (resolve, reject) => { |
119 | 120 | try { |
120 | 121 | await sleep(this.config.autoDelayMs); |
|
0 commit comments