@humanjs/playwright 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +109 -2
- package/dist/index.cjs +554 -207
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +164 -2
- package/dist/index.d.ts +164 -2
- package/dist/index.js +554 -207
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,81 @@
|
|
|
1
|
-
import { ReadKind, PersonalityConfig, HumanPlugin,
|
|
1
|
+
import { Point, ReadKind, PersonalityConfig, HumanPlugin, Personality } from '@humanjs/core';
|
|
2
2
|
export { ActionResult, ActionType, BezierPathOptions, ComputeReadingDwellOptions, DwellProfile, HumanAction, HumanPlugin, HumanizePathOptions, Keystroke, KnownActionType, MouseProfile, Personality, PersonalityConfig, PersonalityExtension, PlanTypingOptions, PluginContext, Point, PresetName, ReadKind, ReadingProfile, Rng, ScrollProfile, ScrollSegment, TypingProfile, applyMicroJitter, applyVelocityProfile, bezierPath, blend, careful, computeReadingDwellMs, countWords, createRng, distracted, fast, humanizePath, planScroll, planTypeKeystrokes, precise, resolvePersonality, sleep } from '@humanjs/core';
|
|
3
3
|
import { Locator, BrowserContext, Page } from 'playwright';
|
|
4
4
|
export { Browser, BrowserContext, BrowserContextOptions, ElementHandle, LaunchOptions, Locator, Page, chromium, firefox, webkit } from 'playwright';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Modifier tokens accepted in a `human.press()` chord. `Mod` and `CmdOrCtrl` /
|
|
8
|
+
* `CommandOrControl` are the magic auto-mapping tokens (Meta on Mac,
|
|
9
|
+
* Control elsewhere). The rest are literal — they always resolve to the
|
|
10
|
+
* keycode they name, on every platform.
|
|
11
|
+
*
|
|
12
|
+
* Canonical-case names are listed here for IntelliSense; the runtime
|
|
13
|
+
* parser is case-insensitive, so `'cmd+s'` and `'CMD+S'` work too — they
|
|
14
|
+
* just won't autocomplete.
|
|
15
|
+
*/
|
|
16
|
+
type KeyModifier = 'Mod' | 'CmdOrCtrl' | 'CommandOrControl' | 'Cmd' | 'Command' | 'Meta' | 'Win' | 'Super' | 'Ctrl' | 'Control' | 'Alt' | 'Option' | 'Opt' | 'Shift';
|
|
17
|
+
/**
|
|
18
|
+
* The canonical key names that autocomplete in a `KeyOrChord`. Mirrors
|
|
19
|
+
* Playwright's accepted key vocabulary, plus a few common synonyms.
|
|
20
|
+
* CamelCase names (`ArrowDown`, `PageUp`) are listed in their canonical
|
|
21
|
+
* form — `normalizeKey` preserves case from the input, so what you type is
|
|
22
|
+
* what gets dispatched.
|
|
23
|
+
*
|
|
24
|
+
* Not exhaustive: every other Playwright key (less-common Numpad keys,
|
|
25
|
+
* `BracketLeft`, locale-specific keys, etc.) is outside the typed union
|
|
26
|
+
* and needs a cast at the call site (`'BracketLeft' as KeyOrChord`). The
|
|
27
|
+
* runtime parser handles them — the type just doesn't enumerate them,
|
|
28
|
+
* because adding a `(string & {})` escape hatch would collapse TypeScript's
|
|
29
|
+
* template-literal IntelliSense for the chord autocompletes.
|
|
30
|
+
*/
|
|
31
|
+
type KeyName = 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z' | '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | 'F1' | 'F2' | 'F3' | 'F4' | 'F5' | 'F6' | 'F7' | 'F8' | 'F9' | 'F10' | 'F11' | 'F12' | 'ArrowUp' | 'ArrowDown' | 'ArrowLeft' | 'ArrowRight' | 'PageUp' | 'PageDown' | 'Home' | 'End' | 'Enter' | 'Tab' | 'Escape' | 'Space' | 'Backspace' | 'Delete' | 'Insert' | 'CapsLock' | 'NumLock' | 'ScrollLock' | 'PrintScreen' | 'Pause';
|
|
32
|
+
/**
|
|
33
|
+
* Strings accepted by `human.press(key)`:
|
|
34
|
+
*
|
|
35
|
+
* - A bare known key: `'Enter'`, `'F4'`, `'ArrowDown'`, `'S'`, …
|
|
36
|
+
* - One known modifier + a known key: `'Mod+S'`, `'Shift+ArrowDown'`, …
|
|
37
|
+
* - Two known modifiers + a known key: `'Mod+Shift+P'`, `'Ctrl+Alt+Tab'`, …
|
|
38
|
+
*
|
|
39
|
+
* Every member of the union is a fully-enumerated literal, which is what
|
|
40
|
+
* makes IDE autocomplete work — type `'Shift+'` and you get every
|
|
41
|
+
* `Shift+<key>` combination as a completion. Adding a `(string & {})`
|
|
42
|
+
* escape hatch anywhere would collapse that down to a single wide
|
|
43
|
+
* template member, killing the completion list.
|
|
44
|
+
*
|
|
45
|
+
* Modifier typos (`'Mosd+S'`) and uncommon-key typos (`'Mod+BraketLeft'`)
|
|
46
|
+
* are both TS errors at the call site — the closed sets on both sides
|
|
47
|
+
* give you compile-time protection that Playwright's plain `string` key
|
|
48
|
+
* type can't.
|
|
49
|
+
*
|
|
50
|
+
* **Escape hatch for uncommon keys.** Less-common Playwright keys
|
|
51
|
+
* (`'BracketLeft'`, `'NumpadAdd'`, locale-specific keys, …) and 3+
|
|
52
|
+
* modifier chords (`'Ctrl+Shift+Alt+K'`) aren't in the union and need a
|
|
53
|
+
* cast at the call site:
|
|
54
|
+
*
|
|
55
|
+
* ```ts
|
|
56
|
+
* await human.press('Mod+BracketLeft' as KeyOrChord);
|
|
57
|
+
* await human.press('Ctrl+Shift+Alt+K' as KeyOrChord);
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* The runtime parser handles these fine — the cast just acknowledges
|
|
61
|
+
* "I'm using a key outside the autocomplete vocabulary." If you find
|
|
62
|
+
* yourself casting often for a specific key, propose adding it to
|
|
63
|
+
* `KeyName` in a PR.
|
|
64
|
+
*
|
|
65
|
+
* Lowercase modifiers (`'mod+s'`) also don't typecheck even though the
|
|
66
|
+
* runtime accepts them — TS-strict steers users toward the canonical
|
|
67
|
+
* casing, which keeps key strings consistent across a codebase.
|
|
68
|
+
*/
|
|
69
|
+
type KeyOrChord = KeyName | `${KeyModifier}+${KeyName}` | `${KeyModifier}+${KeyModifier}+${KeyName}`;
|
|
70
|
+
/** Result of a `press` action. */
|
|
71
|
+
interface PressResult {
|
|
72
|
+
/** The exact chord that was dispatched (after Mod-resolution). */
|
|
73
|
+
readonly dispatched: string;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Anything that can resolve to a click/move point. */
|
|
77
|
+
type MouseTarget = Locator | string | Point;
|
|
78
|
+
|
|
6
79
|
/**
|
|
7
80
|
* What to read:
|
|
8
81
|
* - `string`: a Playwright-compatible selector (matches `click()` / `type()`).
|
|
@@ -393,6 +466,53 @@ interface Human {
|
|
|
393
466
|
* native `locator.click()` is used directly.
|
|
394
467
|
*/
|
|
395
468
|
click(target: Locator | string): Promise<void>;
|
|
469
|
+
/**
|
|
470
|
+
* Right-click `target` — opens a native context menu. Same Bezier-path
|
|
471
|
+
* motion and hover dwell as `click()`; only the dispatched button differs.
|
|
472
|
+
*
|
|
473
|
+
* In `speed: 'instant'`, falls back to `locator.click({ button: 'right' })`.
|
|
474
|
+
*/
|
|
475
|
+
rightClick(target: Locator | string): Promise<void>;
|
|
476
|
+
/**
|
|
477
|
+
* Move the cursor to `target` along a humanized Bezier path and settle
|
|
478
|
+
* on it — no click is dispatched. Useful for hover-triggered UI
|
|
479
|
+
* (tooltips, dropdowns), for positioning the cursor before a non-target
|
|
480
|
+
* action, or for visible demos where the cursor should pause on
|
|
481
|
+
* something noteworthy.
|
|
482
|
+
*
|
|
483
|
+
* In `speed: 'instant'`, dispatches one `mouse.move()` to the element's
|
|
484
|
+
* center.
|
|
485
|
+
*/
|
|
486
|
+
hover(target: Locator | string): Promise<void>;
|
|
487
|
+
/**
|
|
488
|
+
* Move the cursor to `target` along a humanized Bezier path. Pure
|
|
489
|
+
* positioning — no settle dwell, no element interaction. `target` accepts
|
|
490
|
+
* a CSS selector, a `Locator`, or a literal `Point`; the `Point` form
|
|
491
|
+
* lets you position the cursor anywhere (canvas, SVG, dead space) without
|
|
492
|
+
* a DOM element to anchor on.
|
|
493
|
+
*
|
|
494
|
+
* Distinct from `hover()`: `hover` is element-bound and includes a settle
|
|
495
|
+
* dwell to let hover-state UI fire (tooltips, dropdowns). `move` is
|
|
496
|
+
* positional only — use it when you want the cursor placed somewhere
|
|
497
|
+
* without implying interaction with what's under it (pre-press
|
|
498
|
+
* placement, canvas painting, cinematic beats).
|
|
499
|
+
*
|
|
500
|
+
* In `speed: 'instant'`, dispatches one `mouse.move()` at the resolved
|
|
501
|
+
* coordinates.
|
|
502
|
+
*/
|
|
503
|
+
move(target: MouseTarget): Promise<void>;
|
|
504
|
+
/**
|
|
505
|
+
* Drag from `from` to `to`. Each endpoint accepts a CSS selector, a
|
|
506
|
+
* `Locator`, or a literal `Point` — the last form matters for canvas /
|
|
507
|
+
* SVG / slider drags where the destination isn't a DOM element.
|
|
508
|
+
*
|
|
509
|
+
* The motion is two humanized paths back-to-back: cursor → source,
|
|
510
|
+
* then source → destination with the left button held throughout.
|
|
511
|
+
*
|
|
512
|
+
* In `speed: 'instant'`, dispatches `mouse.down → move → up` at the
|
|
513
|
+
* resolved coordinates without humanized motion.
|
|
514
|
+
*/
|
|
515
|
+
drag(from: MouseTarget, to: MouseTarget): Promise<void>;
|
|
396
516
|
/**
|
|
397
517
|
* Type `value` into `target` with humanized per-key timing, optional typo
|
|
398
518
|
* injection (with backspace recovery), and occasional think-pauses.
|
|
@@ -404,6 +524,48 @@ interface Human {
|
|
|
404
524
|
* zero inter-key delay — events still fire, but humanization is skipped.
|
|
405
525
|
*/
|
|
406
526
|
type(target: Locator | string, value: string): Promise<void>;
|
|
527
|
+
/**
|
|
528
|
+
* Insert `value` into `target` in one shot — the Cmd-V semantic. No
|
|
529
|
+
* per-character timing. Like `type()`, drives an implicit click to focus
|
|
530
|
+
* the field first; unlike `type()`, dispatches the whole value via
|
|
531
|
+
* `keyboard.insertText` rather than per-key presses.
|
|
532
|
+
*
|
|
533
|
+
* Use this for long strings (code blocks, multi-line content, secrets)
|
|
534
|
+
* where the typing simulation would be slow and unnecessary. If you need
|
|
535
|
+
* the page's `paste` event handler to fire, call `human.press('Mod+V')`
|
|
536
|
+
* after setting clipboard contents yourself.
|
|
537
|
+
*
|
|
538
|
+
* In `speed: 'instant'`, behaves identically — paste is already instant
|
|
539
|
+
* by nature.
|
|
540
|
+
*/
|
|
541
|
+
paste(target: Locator | string, value: string): Promise<void>;
|
|
542
|
+
/**
|
|
543
|
+
* Press a single key (`'Tab'`, `'Enter'`, `'Escape'`, `'ArrowDown'`, …)
|
|
544
|
+
* or a keyboard chord (`'Mod+S'`, `'Cmd+Shift+P'`, `'Ctrl+C'`, …).
|
|
545
|
+
*
|
|
546
|
+
* Modifier rules:
|
|
547
|
+
*
|
|
548
|
+
* - `Mod` / `CmdOrCtrl` / `CommandOrControl` — magic: `Meta` on Mac,
|
|
549
|
+
* `Control` elsewhere. Use for cross-platform app shortcuts. The three
|
|
550
|
+
* are aliases; `Mod` is shortest.
|
|
551
|
+
* - `Cmd`, `Command`, `Meta`, `Win`, `Super` — literal `Meta` keycode
|
|
552
|
+
* (Command on Mac, Windows key on Windows, Super on Linux).
|
|
553
|
+
* - `Ctrl`, `Control` — literal Control. Stays Control on every OS.
|
|
554
|
+
* - `Alt`, `Option`, `Opt` — literal Alt.
|
|
555
|
+
* - `Shift` — literal Shift.
|
|
556
|
+
*
|
|
557
|
+
* Case-insensitive. Throws on unknown modifiers. The `KeyOrChord` type
|
|
558
|
+
* is a template-literal union of every modifier × key combination (up to
|
|
559
|
+
* two literal modifiers + a key), so IDEs autocomplete common bare keys
|
|
560
|
+
* and chords as you type. Less common keys (`BracketLeft`, `NumpadAdd`,
|
|
561
|
+
* locale-specific keys) still typecheck through the union's string
|
|
562
|
+
* escape hatch — they just don't autocomplete.
|
|
563
|
+
*
|
|
564
|
+
* Does **not** move the cursor — keyboard input dispatches against
|
|
565
|
+
* focus, not cursor position. Compose with `click` / `hover` / `move`
|
|
566
|
+
* when you need both.
|
|
567
|
+
*/
|
|
568
|
+
press(key: KeyOrChord): Promise<void>;
|
|
407
569
|
/**
|
|
408
570
|
* Dwell as if reading `target` — the third pillar of humanization after
|
|
409
571
|
* the cursor and the keyboard. Real users pause to read; HumanJS models
|
|
@@ -545,4 +707,4 @@ interface HumanRecordOptions {
|
|
|
545
707
|
*/
|
|
546
708
|
declare function createHuman(page: Page, options?: CreateHumanOptions): Promise<Human>;
|
|
547
709
|
|
|
548
|
-
export { type CreateHumanOptions, type FfmpegPreset, type FfmpegTune, type Human, type HumanRecordOptions, type InstallMouseHelperOptions, type ReadOptions, type ReadResult, type ReadTarget, Recording, type RecordingQuality, type ScrollOptions, type ScrollResult, type ScrollTarget, type Speed, type Timeline, type TimelineEvent, type ToGifOptions, type ToVideoOptions, createHuman, installMouseHelper };
|
|
710
|
+
export { type CreateHumanOptions, type FfmpegPreset, type FfmpegTune, type Human, type HumanRecordOptions, type InstallMouseHelperOptions, type KeyModifier, type KeyName, type KeyOrChord, type MouseTarget, type PressResult, type ReadOptions, type ReadResult, type ReadTarget, Recording, type RecordingQuality, type ScrollOptions, type ScrollResult, type ScrollTarget, type Speed, type Timeline, type TimelineEvent, type ToGifOptions, type ToVideoOptions, createHuman, installMouseHelper };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,81 @@
|
|
|
1
|
-
import { ReadKind, PersonalityConfig, HumanPlugin,
|
|
1
|
+
import { Point, ReadKind, PersonalityConfig, HumanPlugin, Personality } from '@humanjs/core';
|
|
2
2
|
export { ActionResult, ActionType, BezierPathOptions, ComputeReadingDwellOptions, DwellProfile, HumanAction, HumanPlugin, HumanizePathOptions, Keystroke, KnownActionType, MouseProfile, Personality, PersonalityConfig, PersonalityExtension, PlanTypingOptions, PluginContext, Point, PresetName, ReadKind, ReadingProfile, Rng, ScrollProfile, ScrollSegment, TypingProfile, applyMicroJitter, applyVelocityProfile, bezierPath, blend, careful, computeReadingDwellMs, countWords, createRng, distracted, fast, humanizePath, planScroll, planTypeKeystrokes, precise, resolvePersonality, sleep } from '@humanjs/core';
|
|
3
3
|
import { Locator, BrowserContext, Page } from 'playwright';
|
|
4
4
|
export { Browser, BrowserContext, BrowserContextOptions, ElementHandle, LaunchOptions, Locator, Page, chromium, firefox, webkit } from 'playwright';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Modifier tokens accepted in a `human.press()` chord. `Mod` and `CmdOrCtrl` /
|
|
8
|
+
* `CommandOrControl` are the magic auto-mapping tokens (Meta on Mac,
|
|
9
|
+
* Control elsewhere). The rest are literal — they always resolve to the
|
|
10
|
+
* keycode they name, on every platform.
|
|
11
|
+
*
|
|
12
|
+
* Canonical-case names are listed here for IntelliSense; the runtime
|
|
13
|
+
* parser is case-insensitive, so `'cmd+s'` and `'CMD+S'` work too — they
|
|
14
|
+
* just won't autocomplete.
|
|
15
|
+
*/
|
|
16
|
+
type KeyModifier = 'Mod' | 'CmdOrCtrl' | 'CommandOrControl' | 'Cmd' | 'Command' | 'Meta' | 'Win' | 'Super' | 'Ctrl' | 'Control' | 'Alt' | 'Option' | 'Opt' | 'Shift';
|
|
17
|
+
/**
|
|
18
|
+
* The canonical key names that autocomplete in a `KeyOrChord`. Mirrors
|
|
19
|
+
* Playwright's accepted key vocabulary, plus a few common synonyms.
|
|
20
|
+
* CamelCase names (`ArrowDown`, `PageUp`) are listed in their canonical
|
|
21
|
+
* form — `normalizeKey` preserves case from the input, so what you type is
|
|
22
|
+
* what gets dispatched.
|
|
23
|
+
*
|
|
24
|
+
* Not exhaustive: every other Playwright key (less-common Numpad keys,
|
|
25
|
+
* `BracketLeft`, locale-specific keys, etc.) is outside the typed union
|
|
26
|
+
* and needs a cast at the call site (`'BracketLeft' as KeyOrChord`). The
|
|
27
|
+
* runtime parser handles them — the type just doesn't enumerate them,
|
|
28
|
+
* because adding a `(string & {})` escape hatch would collapse TypeScript's
|
|
29
|
+
* template-literal IntelliSense for the chord autocompletes.
|
|
30
|
+
*/
|
|
31
|
+
type KeyName = 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z' | '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | 'F1' | 'F2' | 'F3' | 'F4' | 'F5' | 'F6' | 'F7' | 'F8' | 'F9' | 'F10' | 'F11' | 'F12' | 'ArrowUp' | 'ArrowDown' | 'ArrowLeft' | 'ArrowRight' | 'PageUp' | 'PageDown' | 'Home' | 'End' | 'Enter' | 'Tab' | 'Escape' | 'Space' | 'Backspace' | 'Delete' | 'Insert' | 'CapsLock' | 'NumLock' | 'ScrollLock' | 'PrintScreen' | 'Pause';
|
|
32
|
+
/**
|
|
33
|
+
* Strings accepted by `human.press(key)`:
|
|
34
|
+
*
|
|
35
|
+
* - A bare known key: `'Enter'`, `'F4'`, `'ArrowDown'`, `'S'`, …
|
|
36
|
+
* - One known modifier + a known key: `'Mod+S'`, `'Shift+ArrowDown'`, …
|
|
37
|
+
* - Two known modifiers + a known key: `'Mod+Shift+P'`, `'Ctrl+Alt+Tab'`, …
|
|
38
|
+
*
|
|
39
|
+
* Every member of the union is a fully-enumerated literal, which is what
|
|
40
|
+
* makes IDE autocomplete work — type `'Shift+'` and you get every
|
|
41
|
+
* `Shift+<key>` combination as a completion. Adding a `(string & {})`
|
|
42
|
+
* escape hatch anywhere would collapse that down to a single wide
|
|
43
|
+
* template member, killing the completion list.
|
|
44
|
+
*
|
|
45
|
+
* Modifier typos (`'Mosd+S'`) and uncommon-key typos (`'Mod+BraketLeft'`)
|
|
46
|
+
* are both TS errors at the call site — the closed sets on both sides
|
|
47
|
+
* give you compile-time protection that Playwright's plain `string` key
|
|
48
|
+
* type can't.
|
|
49
|
+
*
|
|
50
|
+
* **Escape hatch for uncommon keys.** Less-common Playwright keys
|
|
51
|
+
* (`'BracketLeft'`, `'NumpadAdd'`, locale-specific keys, …) and 3+
|
|
52
|
+
* modifier chords (`'Ctrl+Shift+Alt+K'`) aren't in the union and need a
|
|
53
|
+
* cast at the call site:
|
|
54
|
+
*
|
|
55
|
+
* ```ts
|
|
56
|
+
* await human.press('Mod+BracketLeft' as KeyOrChord);
|
|
57
|
+
* await human.press('Ctrl+Shift+Alt+K' as KeyOrChord);
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* The runtime parser handles these fine — the cast just acknowledges
|
|
61
|
+
* "I'm using a key outside the autocomplete vocabulary." If you find
|
|
62
|
+
* yourself casting often for a specific key, propose adding it to
|
|
63
|
+
* `KeyName` in a PR.
|
|
64
|
+
*
|
|
65
|
+
* Lowercase modifiers (`'mod+s'`) also don't typecheck even though the
|
|
66
|
+
* runtime accepts them — TS-strict steers users toward the canonical
|
|
67
|
+
* casing, which keeps key strings consistent across a codebase.
|
|
68
|
+
*/
|
|
69
|
+
type KeyOrChord = KeyName | `${KeyModifier}+${KeyName}` | `${KeyModifier}+${KeyModifier}+${KeyName}`;
|
|
70
|
+
/** Result of a `press` action. */
|
|
71
|
+
interface PressResult {
|
|
72
|
+
/** The exact chord that was dispatched (after Mod-resolution). */
|
|
73
|
+
readonly dispatched: string;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Anything that can resolve to a click/move point. */
|
|
77
|
+
type MouseTarget = Locator | string | Point;
|
|
78
|
+
|
|
6
79
|
/**
|
|
7
80
|
* What to read:
|
|
8
81
|
* - `string`: a Playwright-compatible selector (matches `click()` / `type()`).
|
|
@@ -393,6 +466,53 @@ interface Human {
|
|
|
393
466
|
* native `locator.click()` is used directly.
|
|
394
467
|
*/
|
|
395
468
|
click(target: Locator | string): Promise<void>;
|
|
469
|
+
/**
|
|
470
|
+
* Right-click `target` — opens a native context menu. Same Bezier-path
|
|
471
|
+
* motion and hover dwell as `click()`; only the dispatched button differs.
|
|
472
|
+
*
|
|
473
|
+
* In `speed: 'instant'`, falls back to `locator.click({ button: 'right' })`.
|
|
474
|
+
*/
|
|
475
|
+
rightClick(target: Locator | string): Promise<void>;
|
|
476
|
+
/**
|
|
477
|
+
* Move the cursor to `target` along a humanized Bezier path and settle
|
|
478
|
+
* on it — no click is dispatched. Useful for hover-triggered UI
|
|
479
|
+
* (tooltips, dropdowns), for positioning the cursor before a non-target
|
|
480
|
+
* action, or for visible demos where the cursor should pause on
|
|
481
|
+
* something noteworthy.
|
|
482
|
+
*
|
|
483
|
+
* In `speed: 'instant'`, dispatches one `mouse.move()` to the element's
|
|
484
|
+
* center.
|
|
485
|
+
*/
|
|
486
|
+
hover(target: Locator | string): Promise<void>;
|
|
487
|
+
/**
|
|
488
|
+
* Move the cursor to `target` along a humanized Bezier path. Pure
|
|
489
|
+
* positioning — no settle dwell, no element interaction. `target` accepts
|
|
490
|
+
* a CSS selector, a `Locator`, or a literal `Point`; the `Point` form
|
|
491
|
+
* lets you position the cursor anywhere (canvas, SVG, dead space) without
|
|
492
|
+
* a DOM element to anchor on.
|
|
493
|
+
*
|
|
494
|
+
* Distinct from `hover()`: `hover` is element-bound and includes a settle
|
|
495
|
+
* dwell to let hover-state UI fire (tooltips, dropdowns). `move` is
|
|
496
|
+
* positional only — use it when you want the cursor placed somewhere
|
|
497
|
+
* without implying interaction with what's under it (pre-press
|
|
498
|
+
* placement, canvas painting, cinematic beats).
|
|
499
|
+
*
|
|
500
|
+
* In `speed: 'instant'`, dispatches one `mouse.move()` at the resolved
|
|
501
|
+
* coordinates.
|
|
502
|
+
*/
|
|
503
|
+
move(target: MouseTarget): Promise<void>;
|
|
504
|
+
/**
|
|
505
|
+
* Drag from `from` to `to`. Each endpoint accepts a CSS selector, a
|
|
506
|
+
* `Locator`, or a literal `Point` — the last form matters for canvas /
|
|
507
|
+
* SVG / slider drags where the destination isn't a DOM element.
|
|
508
|
+
*
|
|
509
|
+
* The motion is two humanized paths back-to-back: cursor → source,
|
|
510
|
+
* then source → destination with the left button held throughout.
|
|
511
|
+
*
|
|
512
|
+
* In `speed: 'instant'`, dispatches `mouse.down → move → up` at the
|
|
513
|
+
* resolved coordinates without humanized motion.
|
|
514
|
+
*/
|
|
515
|
+
drag(from: MouseTarget, to: MouseTarget): Promise<void>;
|
|
396
516
|
/**
|
|
397
517
|
* Type `value` into `target` with humanized per-key timing, optional typo
|
|
398
518
|
* injection (with backspace recovery), and occasional think-pauses.
|
|
@@ -404,6 +524,48 @@ interface Human {
|
|
|
404
524
|
* zero inter-key delay — events still fire, but humanization is skipped.
|
|
405
525
|
*/
|
|
406
526
|
type(target: Locator | string, value: string): Promise<void>;
|
|
527
|
+
/**
|
|
528
|
+
* Insert `value` into `target` in one shot — the Cmd-V semantic. No
|
|
529
|
+
* per-character timing. Like `type()`, drives an implicit click to focus
|
|
530
|
+
* the field first; unlike `type()`, dispatches the whole value via
|
|
531
|
+
* `keyboard.insertText` rather than per-key presses.
|
|
532
|
+
*
|
|
533
|
+
* Use this for long strings (code blocks, multi-line content, secrets)
|
|
534
|
+
* where the typing simulation would be slow and unnecessary. If you need
|
|
535
|
+
* the page's `paste` event handler to fire, call `human.press('Mod+V')`
|
|
536
|
+
* after setting clipboard contents yourself.
|
|
537
|
+
*
|
|
538
|
+
* In `speed: 'instant'`, behaves identically — paste is already instant
|
|
539
|
+
* by nature.
|
|
540
|
+
*/
|
|
541
|
+
paste(target: Locator | string, value: string): Promise<void>;
|
|
542
|
+
/**
|
|
543
|
+
* Press a single key (`'Tab'`, `'Enter'`, `'Escape'`, `'ArrowDown'`, …)
|
|
544
|
+
* or a keyboard chord (`'Mod+S'`, `'Cmd+Shift+P'`, `'Ctrl+C'`, …).
|
|
545
|
+
*
|
|
546
|
+
* Modifier rules:
|
|
547
|
+
*
|
|
548
|
+
* - `Mod` / `CmdOrCtrl` / `CommandOrControl` — magic: `Meta` on Mac,
|
|
549
|
+
* `Control` elsewhere. Use for cross-platform app shortcuts. The three
|
|
550
|
+
* are aliases; `Mod` is shortest.
|
|
551
|
+
* - `Cmd`, `Command`, `Meta`, `Win`, `Super` — literal `Meta` keycode
|
|
552
|
+
* (Command on Mac, Windows key on Windows, Super on Linux).
|
|
553
|
+
* - `Ctrl`, `Control` — literal Control. Stays Control on every OS.
|
|
554
|
+
* - `Alt`, `Option`, `Opt` — literal Alt.
|
|
555
|
+
* - `Shift` — literal Shift.
|
|
556
|
+
*
|
|
557
|
+
* Case-insensitive. Throws on unknown modifiers. The `KeyOrChord` type
|
|
558
|
+
* is a template-literal union of every modifier × key combination (up to
|
|
559
|
+
* two literal modifiers + a key), so IDEs autocomplete common bare keys
|
|
560
|
+
* and chords as you type. Less common keys (`BracketLeft`, `NumpadAdd`,
|
|
561
|
+
* locale-specific keys) still typecheck through the union's string
|
|
562
|
+
* escape hatch — they just don't autocomplete.
|
|
563
|
+
*
|
|
564
|
+
* Does **not** move the cursor — keyboard input dispatches against
|
|
565
|
+
* focus, not cursor position. Compose with `click` / `hover` / `move`
|
|
566
|
+
* when you need both.
|
|
567
|
+
*/
|
|
568
|
+
press(key: KeyOrChord): Promise<void>;
|
|
407
569
|
/**
|
|
408
570
|
* Dwell as if reading `target` — the third pillar of humanization after
|
|
409
571
|
* the cursor and the keyboard. Real users pause to read; HumanJS models
|
|
@@ -545,4 +707,4 @@ interface HumanRecordOptions {
|
|
|
545
707
|
*/
|
|
546
708
|
declare function createHuman(page: Page, options?: CreateHumanOptions): Promise<Human>;
|
|
547
709
|
|
|
548
|
-
export { type CreateHumanOptions, type FfmpegPreset, type FfmpegTune, type Human, type HumanRecordOptions, type InstallMouseHelperOptions, type ReadOptions, type ReadResult, type ReadTarget, Recording, type RecordingQuality, type ScrollOptions, type ScrollResult, type ScrollTarget, type Speed, type Timeline, type TimelineEvent, type ToGifOptions, type ToVideoOptions, createHuman, installMouseHelper };
|
|
710
|
+
export { type CreateHumanOptions, type FfmpegPreset, type FfmpegTune, type Human, type HumanRecordOptions, type InstallMouseHelperOptions, type KeyModifier, type KeyName, type KeyOrChord, type MouseTarget, type PressResult, type ReadOptions, type ReadResult, type ReadTarget, Recording, type RecordingQuality, type ScrollOptions, type ScrollResult, type ScrollTarget, type Speed, type Timeline, type TimelineEvent, type ToGifOptions, type ToVideoOptions, createHuman, installMouseHelper };
|