Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve TS type jsdocs #126

Merged
merged 1 commit into from
May 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading