Skip to content

Commit

Permalink
improve TS type jsdocs
Browse files Browse the repository at this point in the history
  • Loading branch information
bvandercar-vt committed May 3, 2024
1 parent e6da174 commit 933b715
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 7 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ Simulates a mouse click at the specified selector or element.

- **selector (optional):** CSS selector or ElementHandle to identify the target element.
- **options (optional):** Additional options for clicking.
- `hesitate (number):` Delay before initiating the click action in milliseconds.
- `waitForClick (number):` Delay after pressing the mouse button in milliseconds.
- `moveDelay (number):` Delay after moving the mouse in milliseconds.
- `hesitate (number):` Delay before initiating the click action in milliseconds. Default is `0`.
- `waitForClick (number):` Delay between mousedown and mouseup in milliseconds. Default is `0`.
- `moveDelay (number):` Delay after moving the mouse in milliseconds. Default is `2000`.

#### `move(selector: string | ElementHandle, options?: MoveOptions): Promise<void>`

Expand All @@ -96,10 +96,10 @@ Moves the mouse to the specified selector or element.
- **selector:** CSS selector or ElementHandle to identify the target element.
- **options (optional):** Additional options for moving.
- `paddingPercentage (number):` Percentage of padding to be added around the element. Default is `0`.
- `waitForSelector (number):` Time to wait for the selector to appear in milliseconds.
- `moveDelay (number):` Delay after moving the mouse in milliseconds.
- `waitForSelector (number):` Time to wait for the selector to appear in milliseconds. Default is to not wait for selector.
- `moveDelay (number):` Delay after moving the mouse in milliseconds. Default is `2000`.
- `maxTries (number):` Maximum number of attempts to mouse-over the element. Default is `10`.
- `moveSpeed (number):` Speed of mouse movement.
- `moveSpeed (number):` Speed of mouse movement. Default is random.

#### `moveTo(destination: Vector): Promise<void>`

Expand All @@ -125,7 +125,7 @@ Generates a set of points for mouse movement between two coordinates.
- **target:** Ending point of the movement.
- **optionsOrSpread (optional):** Additional options for generating the path.
- `spreadOverride (number):` Override the spread of the generated path.
- `moveSpeed (number):` Speed of mouse movement.
- `moveSpeed (number):` Speed of mouse movement. Default is random.


## How does it work
Expand Down
35 changes: 35 additions & 0 deletions src/spoof.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,58 @@ export { default as installMouseHelper } from './mouse-helper'
const log = debug('ghost-cursor')

export interface BoxOptions {
/**
* Percentage of padding to be added around the element.
* @default 0
*/
readonly paddingPercentage?: number
}

export interface MoveOptions extends BoxOptions {
/**
* Time to wait for the selector to appear in milliseconds.
* Default is to not wait for selector.
*/
readonly waitForSelector?: number
/**
* Delay after moving the mouse in milliseconds.
* @default 2000
*/
readonly moveDelay?: number
/**
* Maximum number of attempts to mouse-over the element.
* @default 10
*/
readonly maxTries?: number
/**
* Speed of mouse movement.
* Default is random.
*/
readonly moveSpeed?: number
}

export interface ClickOptions extends MoveOptions {
/**
* Delay before initiating the click action in milliseconds.
* @default 0
*/
readonly hesitate?: number
/**
* Delay between mousedown and mouseup in milliseconds.
* @default 0
*/
readonly waitForClick?: number
}

export interface PathOptions {
/**
* Override the spread of the generated path.
*/
readonly spreadOverride?: number
/**
* Speed of mouse movement.
* Default is random.
*/
readonly moveSpeed?: number
}

Expand Down

0 comments on commit 933b715

Please sign in to comment.