browser-commander 0.8.0 → 0.8.1

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/.prettierignore CHANGED
@@ -1,6 +1,7 @@
1
1
  node_modules
2
2
  coverage
3
3
  dist
4
+ docs-api
4
5
  *.min.js
5
6
  package-lock.json
6
7
  .eslintcache
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.8.1
4
+
5
+ ### Patch Changes
6
+
7
+ - ffc59e6: Add generated JSDoc API documentation support for the JavaScript package.
8
+
3
9
  ## 0.8.0
4
10
 
5
11
  ### Minor Changes
package/README.md CHANGED
@@ -18,6 +18,16 @@ npm install playwright
18
18
  npm install puppeteer
19
19
  ```
20
20
 
21
+ ## Documentation
22
+
23
+ Generate the JavaScript API reference locally with:
24
+
25
+ ```bash
26
+ npm run docs:api
27
+ ```
28
+
29
+ The repository Documentation workflow also combines this JSDoc output with Rust `cargo doc` output for GitHub Pages publishing from `main`.
30
+
21
31
  ## Core Concept: Page State Machine
22
32
 
23
33
  Browser Commander manages the browser as a state machine with two states:
@@ -290,6 +300,24 @@ await commander.fillTextArea({
290
300
  });
291
301
  ```
292
302
 
303
+ ### Keyboard Interactions
304
+
305
+ ```javascript
306
+ import { pressKey, typeText, keyDown, keyUp } from 'browser-commander';
307
+
308
+ // Press a single key
309
+ await pressKey({ page, engine: 'playwright', key: 'Escape' });
310
+ await pressKey({ page, engine: 'playwright', key: 'Enter' });
311
+ await pressKey({ page, engine: 'playwright', key: 'Tab' });
312
+
313
+ // Type text
314
+ await typeText({ page, engine: 'playwright', text: 'Hello World' });
315
+
316
+ // Hold and release modifier keys
317
+ await keyDown({ page, engine: 'playwright', key: 'Control' });
318
+ await keyUp({ page, engine: 'playwright', key: 'Control' });
319
+ ```
320
+
293
321
  ### commander.destroy()
294
322
 
295
323
  ```javascript
package/eslint.config.js CHANGED
@@ -118,6 +118,7 @@ export default [
118
118
  'node_modules/**',
119
119
  'coverage/**',
120
120
  'dist/**',
121
+ 'docs-api/**',
121
122
  '*.min.js',
122
123
  '.eslintcache',
123
124
  ],
package/jsdoc.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "source": {
3
+ "include": ["src"],
4
+ "includePattern": ".+\\.js$"
5
+ },
6
+ "opts": {
7
+ "destination": "docs-api",
8
+ "readme": "README.md",
9
+ "recurse": true
10
+ }
11
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browser-commander",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "Universal browser automation library that supports both Playwright and Puppeteer with a unified API",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -19,6 +19,7 @@
19
19
  "lint:fix": "eslint . --fix",
20
20
  "format": "prettier --write .",
21
21
  "format:check": "prettier --check .",
22
+ "docs:api": "jsdoc -c jsdoc.json",
22
23
  "check:duplication": "jscpd .",
23
24
  "check": "npm run lint && npm run format:check && npm run check:duplication",
24
25
  "prepare": "husky || true",
@@ -69,6 +70,7 @@
69
70
  "eslint-config-prettier": "^10.1.8",
70
71
  "eslint-plugin-prettier": "^5.5.4",
71
72
  "husky": "^9.1.7",
73
+ "jsdoc": "^4.0.4",
72
74
  "jscpd": "^4.0.5",
73
75
  "lint-staged": "^16.2.6",
74
76
  "playwright": "^1.56.1",
@@ -220,7 +220,7 @@ export async function waitForUrlStabilization(options = {}) {
220
220
  * @param {boolean} options.verify - Whether to verify the navigation (default: true)
221
221
  * @param {Function} options.verifyFn - Custom verification function (optional)
222
222
  * @param {number} options.verificationTimeout - Verification timeout in ms (default: TIMING.VERIFICATION_TIMEOUT)
223
- * @returns {Promise<{navigated: boolean, verified: boolean, actualUrl?: string, reason?: string}>}
223
+ * @returns {Promise<Object>} Navigation result.
224
224
  */
225
225
  export async function goto(options = {}) {
226
226
  const {
@@ -173,7 +173,7 @@ export async function verifyClick(options = {}) {
173
173
  * @param {boolean} options.verify - Whether to verify the click operation (default: true)
174
174
  * @param {Function} options.verifyFn - Custom verification function (optional)
175
175
  * @param {Object} options.adapter - Engine adapter (optional, will be created if not provided)
176
- * @returns {Promise<{clicked: boolean, verified: boolean, reason?: string}>}
176
+ * @returns {Promise<Object>} Click result.
177
177
  */
178
178
  export async function clickElement(options = {}) {
179
179
  const {
@@ -352,7 +352,7 @@ async function prepareElement(options = {}) {
352
352
  * @param {boolean} options.noAutoScroll - Prevent Playwright's automatic scrolling
353
353
  * @param {boolean} options.verify - Whether to verify the click operation
354
354
  * @param {Function} options.verifyFn - Custom verification function (optional)
355
- * @returns {Promise<{clicked: boolean, verified: boolean, reason?: string, navigated: boolean}>}
355
+ * @returns {Promise<Object>} Click result.
356
356
  */
357
357
  async function executeClick(options = {}) {
358
358
  const {
@@ -567,7 +567,7 @@ async function handleNavigationAfterClick(options = {}) {
567
567
  * @param {number} options.timeout - Timeout in ms (default: TIMING.DEFAULT_TIMEOUT)
568
568
  * @param {boolean} options.verify - Whether to verify the click operation (default: true)
569
569
  * @param {Function} options.verifyFn - Custom verification function (optional)
570
- * @returns {Promise<{clicked: boolean, navigated: boolean, verified: boolean, reason?: string}>}
570
+ * @returns {Promise<Object>} Click result.
571
571
  * - clicked: true if click was performed
572
572
  * - navigated: true if click caused navigation
573
573
  * - verified: true if click was verified (navigation counts as verification)
@@ -146,7 +146,7 @@ export async function checkIfElementEmpty(options = {}) {
146
146
  * @param {number} options.verificationTimeout - Verification timeout in ms (default: TIMING.VERIFICATION_TIMEOUT)
147
147
  * @param {Function} options.log - Logger instance (optional)
148
148
  * @param {Object} options.adapter - Engine adapter (optional, will be created if not provided)
149
- * @returns {Promise<{filled: boolean, verified: boolean, actualValue?: string}>}
149
+ * @returns {Promise<Object>} Fill result.
150
150
  */
151
151
  export async function performFill(options = {}) {
152
152
  const {
@@ -240,7 +240,7 @@ export async function performFill(options = {}) {
240
240
  * @param {boolean} options.verify - Whether to verify the fill operation (default: true)
241
241
  * @param {Function} options.verifyFn - Custom verification function (optional, uses defaultFillVerification if not provided)
242
242
  * @param {number} options.verificationTimeout - Verification timeout in ms (default: TIMING.VERIFICATION_TIMEOUT)
243
- * @returns {Promise<{filled: boolean, verified: boolean, skipped: boolean, actualValue?: string}>}
243
+ * @returns {Promise<Object>} Fill result.
244
244
  * - filled: true if fill operation was attempted
245
245
  * - verified: true if fill was verified successfully (only meaningful if filled is true)
246
246
  * - skipped: true if element already had content and checkEmpty was true