@browserless/cli 10.10.3 → 10.11.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/README.md CHANGED
@@ -30,6 +30,7 @@ This package provides a **command-line interface** for interacting with browserl
30
30
  The `@browserless/cli` package allows you to:
31
31
 
32
32
  - **Take screenshots** from URLs with gradient backgrounds, browser overlays, and device emulation
33
+ - **Record captures** as video/audio using the `tabCapture` extension flow
33
34
  - **Generate PDFs** from web pages
34
35
  - **Extract content** as HTML or plain text
35
36
  - **Run Lighthouse audits** for performance analysis
@@ -40,6 +41,7 @@ The `@browserless/cli` package allows you to:
40
41
 
41
42
  | Command | Description |
42
43
  |---------|-------------|
44
+ | `capture <url>` | Record a page and return video buffer (use `--path` to save file) |
43
45
  | `screenshot <url>` | Capture a screenshot with optional overlay and background |
44
46
  | `pdf <url>` | Generate a PDF document from a web page |
45
47
  | `html <url>` | Serialize the page content to HTML |
@@ -50,6 +52,16 @@ The `@browserless/cli` package allows you to:
50
52
  | `status <url>` | Get the HTTP status code |
51
53
  | `goto <url>` | Navigate to a URL and return page/response info |
52
54
 
55
+ ### Capture examples
56
+
57
+ ```sh
58
+ # webm (default)
59
+ browserless capture https://example.com --path=./capture.webm
60
+
61
+ # mp4 using friendly output type
62
+ browserless capture https://example.com --type=mp4 --path=./capture.mp4
63
+ ```
64
+
53
65
  > **Note:** The `lighthouse` command requires an extra installation.
54
66
  >
55
67
  > Please make sure to install the standalone package by running:<br>
@@ -60,6 +72,7 @@ This package depends on:
60
72
 
61
73
  | Dependency | Purpose |
62
74
  |---------------------------|---------------------------------------------------------|
75
+ | @browserless/capture | Extension-based tab capture for CLI video recording |
63
76
  | browserless | Core API for all browser automation operations |
64
77
  | @browserless/lighthouse | Lighthouse audit integration (used by lighthouse command) |
65
78
 
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@browserless/cli",
3
3
  "description": "Command-line interface for headless browser automation. Take screenshots, generate PDFs, and extract content from websites.",
4
4
  "homepage": "https://browserless.js.org",
5
- "version": "10.10.3",
5
+ "version": "10.11.1",
6
6
  "bin": {
7
7
  "browserless": "src/index.js"
8
8
  },
@@ -20,22 +20,23 @@
20
20
  "url": "https://github.com/microlinkhq/browserless/issues"
21
21
  },
22
22
  "keywords": [
23
+ "automation",
23
24
  "browserless",
25
+ "chrome",
24
26
  "cli",
25
27
  "command-line",
26
28
  "headless",
27
- "chrome",
29
+ "pdf",
28
30
  "puppeteer",
29
31
  "screenshot",
30
- "pdf",
31
- "automation",
32
- "web-scraping",
33
32
  "terminal",
34
- "tool"
33
+ "tool",
34
+ "web-scraping"
35
35
  ],
36
36
  "dependencies": {
37
+ "@browserless/capture": "^10.11.1",
37
38
  "beauty-error": "~1.2.21",
38
- "browserless": "^10.10.3",
39
+ "browserless": "^10.11.1",
39
40
  "dark-mode": "~3.0.0",
40
41
  "dset": "~3.1.4",
41
42
  "mri": "~1.2.0",
@@ -59,5 +60,5 @@
59
60
  "test": "exit 0"
60
61
  },
61
62
  "license": "MIT",
62
- "gitHead": "4d2b893e8215a91d830f4471f51c567a53cd6bbb"
63
+ "gitHead": "2a4bbeeadfb7f010d57a8806f706de2bc48f936e"
63
64
  }
@@ -0,0 +1,24 @@
1
+ 'use strict'
2
+
3
+ const prettyBytes = require('pretty-bytes')
4
+
5
+ module.exports = async ({ url, browserless, opts }) => {
6
+ const { path: outputPath, ...captureOpts } = opts
7
+
8
+ const type = captureOpts.type && String(captureOpts.type).toLowerCase()
9
+
10
+ const suggestedType =
11
+ { matroska: 'mkv', mkv: 'mkv', mp4: 'mp4', webm: 'webm' }[type] ||
12
+ (captureOpts.mimeType && captureOpts.mimeType.includes('mp4') ? 'mp4' : 'webm')
13
+
14
+ const video = await browserless.capture(url, {
15
+ ...captureOpts,
16
+ path: outputPath
17
+ })
18
+
19
+ const preview = outputPath
20
+ ? `saved at ${process.cwd()}/${outputPath}`
21
+ : `captured ${prettyBytes(video.length)} (use --path=./capture.${suggestedType} to persist)`
22
+
23
+ return [video, preview]
24
+ }
package/src/index.js CHANGED
@@ -63,7 +63,13 @@ const run = async () => {
63
63
  const [command, rawUrl] = cli.input
64
64
  const url = new URL(rawUrl).toString()
65
65
  const fn = require(`./commands/${command}`)
66
- const browser = createBrowser({ headless })
66
+ const launchOpts = { headless }
67
+
68
+ if (command === 'capture') {
69
+ launchOpts.headless = headless === false ? false : 'new'
70
+ }
71
+
72
+ const browser = createBrowser(launchOpts)
67
73
  onExit(browser.close)
68
74
  const browserless = await browser.createContext()
69
75
  return fn({ url, browserless, opts: nestie(opts), isPageReady })