@gnawbit/tabretake 0.5.0 → 0.5.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.1 — 2026-11-27
4
+
5
+ - Move the Chinese README to `docs/README.zh-CN.md` and remove it from `package.json` `files` so npm displays the English `README.md`.
6
+ - Classify missing system/Playwright browsers (`BROWSER_MISSING` and `BROWSER_DEPS_MISSING`) with actionable `Hint:` recovery lines in CLI error output, and warn during `tabretake init --auto` when no browser is detected.
7
+ - Reuse saved login state in `tabretake capture --login --run` without repeating manual login, preserve existing story fields (such as `brand` and `controls`) when updating via `tabretake mark`, and remove the unused `bin/demo-reel.mjs` alias.
8
+
3
9
  ## 0.5.0 — 2026-11-26
4
10
 
5
11
  - Add `tabretake capture` interactive recorder so users can click, type, select, and pin `focus` steps directly in a browser window to generate an editable `story.json` (with automatic password field skipping).
package/README.md CHANGED
@@ -1,12 +1,13 @@
1
1
  # TabRetake — repeatable web app demo videos
2
2
 
3
- English · [简体中文](README.zh-CN.md)
3
+ English · [简体中文](docs/README.zh-CN.md)
4
4
 
5
5
  [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
6
6
  [![Node](https://img.shields.io/badge/node-%3E%3D20.9-339933?logo=node.js&logoColor=white)](package.json)
7
7
  [![Latest release](https://img.shields.io/github/v/release/gnawbit/tabretake?label=latest%20release&color=6c5ce7)](https://github.com/gnawbit/tabretake/releases/latest)
8
8
  [![Agent skill](https://img.shields.io/badge/agent%20skill-Claude%20Code%20%7C%20Codex%20%7C%20Cursor-6c5ce7)](SKILL.md)
9
9
  [![GitHub stars](https://img.shields.io/github/stars/gnawbit/tabretake?style=social)](https://github.com/gnawbit/tabretake/stargazers)
10
+ [![Listed in Awesome Agent Skills](https://sagargupta.online/awesome-skills/badge.svg)](https://github.com/Sagargupta16/awesome-skills)
10
11
 
11
12
  **Automate your web app demos. Never manually record and edit a screen again.**
12
13
 
@@ -45,7 +46,7 @@ Already have a screen recording? Supply timestamp marks to
45
46
  ### 🚀 Quick Taste (Zero-Wait with Local Chrome/Edge)
46
47
 
47
48
  ```bash
48
- npm install --global @gnawbit/tabretake@0.5.0
49
+ npm install --global @gnawbit/tabretake@0.5.1
49
50
  tabretake demo --preset daylight
50
51
  ```
51
52
 
@@ -100,7 +101,7 @@ edit and run again after a release.
100
101
  Install the CLI from npm.
101
102
 
102
103
  ```bash
103
- npm install --global @gnawbit/tabretake@0.5.0
104
+ npm install --global @gnawbit/tabretake@0.5.1
104
105
  tabretake demo
105
106
  ```
106
107
 
@@ -128,7 +129,7 @@ replace `node bin/tabretake.mjs` with `tabretake`.
128
129
  To add the agent workflow after setting up the CLI:
129
130
 
130
131
  ```bash
131
- npx skills@1.9.0 add "https://github.com/gnawbit/tabretake.git#v0.5.0" --skill tabretake
132
+ npx skills@1.9.0 add "https://github.com/gnawbit/tabretake.git#v0.5.1" --skill tabretake
132
133
  ```
133
134
 
134
135
  Run this in the target project; add `--agent codex`, `--agent claude-code` or
@@ -139,7 +140,7 @@ or a source checkout. Install the CLI and Skill from the same revision.
139
140
  Claude Code users can install the plugin instead (CLI 2.1.292+):
140
141
 
141
142
  ```bash
142
- claude plugin install tabretake --marketplace "gnawbit/tabretake#v0.5.0"
143
+ claude plugin install tabretake --marketplace "gnawbit/tabretake#v0.5.1"
143
144
  ```
144
145
 
145
146
  Install the workflow through one of these routes; the plugin still needs the
@@ -263,7 +264,6 @@ An explicit `selector` is tried first. Label matching tries exact buttons/links,
263
264
  then partial buttons/links, then plain text (exact before partial). An explicit
264
265
  `role` restricts matching to that role, with exact names first. Each candidate
265
266
  keeps the first visible match; use a scoped selector when labels repeat or overlap.
266
- See [compatibility](docs/compatibility.md) for legacy matching behavior.
267
267
 
268
268
  Tips:
269
269
 
@@ -368,7 +368,6 @@ to your config.
368
368
  Navigation failures return `PAGE_UNREACHABLE` or `PAGE_HTTP_ERROR` without echoing sensitive URLs;
369
369
  captions start when an action completes and hold during its `pause`.
370
370
  Run manual `--login` in an interactive terminal without `--json`, then reuse `--storage-state` in automation.
371
- See [compatibility](docs/compatibility.md) for legacy version behavior (`v0.4.0` and earlier).
372
371
 
373
372
  ```bash
374
373
  --browser auto # auto (bundled Chromium or local Chrome/Edge), chromium, chrome, msedge
@@ -540,8 +539,9 @@ are yours or licensed.
540
539
  - [x] 9:16 vertical export
541
540
  - [x] Screen-recording input (`--video` + `marks`)
542
541
  - [x] Brand presets (`midnight`, `daylight`, `paper`, `slate`)
542
+ - [x] Interactive capture (`capture`), visual marker studio (`mark`), and lightweight frames (`browser`, `phone`)
543
+ - [ ] Full device bezels (iPhone, Android, macOS)
543
544
  - [ ] Voiceover (TTS)
544
- - [ ] Device frames (iPhone, Android, macOS)
545
545
  - [ ] Cloud rendering
546
546
 
547
547
  ## Contributing
package/SKILL.md CHANGED
@@ -4,7 +4,7 @@ description: Create repeatable product demo videos, screen recording walkthrough
4
4
  license: MIT
5
5
  metadata:
6
6
  author: gnawbit
7
- version: "0.5.0"
7
+ version: "0.5.1"
8
8
  repository: https://github.com/gnawbit/tabretake
9
9
  compatibility: Node.js 20.9+, local Chrome/Edge or Chromium via tabretake setup, Windows/macOS/Linux. Target app access is required. Rendering is local.
10
10
  ---
@@ -21,13 +21,14 @@ Create a repeatable product walkthrough from a web URL, or render an existing
21
21
  screen recording with supplied timestamps. Canonical project:
22
22
  https://github.com/gnawbit/tabretake.
23
23
  Outputs are local MP4, GIF and PNG posters in landscape (16:9) and optional portrait (9:16).
24
- For legacy release notes (`v0.4.0` and earlier / `demo-reel`), see [compatibility](docs/compatibility.md).
24
+ For legacy release notes (v0.4.0 and earlier / `demo-reel`), see
25
+ [compatibility](https://github.com/gnawbit/tabretake/blob/main/docs/compatibility.md).
25
26
 
26
27
  ## Locate and check the CLI
27
28
 
28
29
  Use an installed `tabretake` CLI when available. For a source checkout, replace
29
30
  `tabretake` with `node /absolute/path/to/tabretake/bin/tabretake.mjs` (quote paths with spaces).
30
- If missing, install with `npm install --global @gnawbit/tabretake@0.5.0`.
31
+ If missing, install with `npm install --global @gnawbit/tabretake@0.5.1`.
31
32
  When Playwright Chromium is absent, TabRetake automatically falls back to local
32
33
  Chrome or Edge (`--browser auto`), or you can install pinned Chromium via `tabretake setup`.
33
34
 
@@ -109,24 +110,21 @@ partial files. `schemaVersion` identifies the response format, not the CLI relea
109
110
  - `TARGET_NOT_FOUND`, `STEP_TIMEOUT`, `STEP_FAILED`: inspect `error.step.path`
110
111
  and its zero-based index. Re-run `plan` with the same login state, update the
111
112
  target or wait condition and retry. Do not repeat an unchanged failing command.
112
- From v0.3.3, `click` also waits for an enabled, unobstructed
113
- target using step `timeout` (milliseconds; default 20,000). v0.3.2 and earlier
114
- do not reliably wait for clickable targets; inspect the resulting page.
113
+ `click` waits for an enabled, unobstructed target using step `timeout`
114
+ (milliseconds; default 20,000).
115
115
  - `PAGE_UNREACHABLE`: check the URL, local app server and browser network/proxy
116
116
  access. `PAGE_HTTP_ERROR`: inspect `error.status`; fix the route/server or use
117
- authorized login state for 401/403. These codes are available in v0.3.1 or newer;
118
- older versions may return `COMMAND_FAILED`. Dependency checks do not prove
119
- page access, and an HTTP error page is not a completed demo.
117
+ authorized login state for 401/403. Dependency checks do not prove page access,
118
+ and an HTTP error page is not a completed demo.
120
119
  - Missing runtime or fonts: inspect `doctor --json` and its recovery hints.
121
120
  - Captcha, anti-bot block, iframe-only or canvas-only flow: use a user-provided
122
121
  recording with marks instead of trying to bypass the restriction.
123
122
 
124
123
  ## Protected pages and privacy
125
124
 
126
- Manual login needs an interactive terminal without `--json`:
127
-
128
- From v0.3.2, login navigation errors also omit the target URL. HTTP 401/403
129
- pages stay open for sign-in; other HTTP errors stop the command.
125
+ Manual login needs an interactive terminal without `--json`. Login navigation
126
+ errors omit the target URL; HTTP 401/403 pages stay open for sign-in while other
127
+ HTTP errors stop the command.
130
128
 
131
129
  ```bash
132
130
  tabretake plan --url https://your-app.com --login
package/bin/tabretake.mjs CHANGED
@@ -7,6 +7,11 @@ main(process.argv.slice(2)).catch((err) => {
7
7
  const [command, ...args] = process.argv.slice(2);
8
8
  if (commandOptions[command]?.json && args.includes("--json")) {
9
9
  console.log(JSON.stringify(errorReport(command, err)));
10
- } else console.error(err?.stack || err?.message || String(err));
10
+ } else if (err?.code) {
11
+ console.error(`Error: ${err.message || String(err)}`);
12
+ if (err.hint) console.error(`Hint: ${err.hint}`);
13
+ } else {
14
+ console.error(err?.stack || err?.message || String(err));
15
+ }
11
16
  process.exitCode = 1;
12
17
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gnawbit/tabretake",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Create repeatable web app demos, README GIFs and 9:16 videos from editable JSON steps or existing screen recordings. Local CLI and Agent Skill for Claude Code, Codex and Cursor.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -17,11 +17,10 @@
17
17
  "examples/story.json",
18
18
  "examples/story-video.json",
19
19
  "SKILL.md",
20
- "README.zh-CN.md",
21
20
  "CHANGELOG.md"
22
21
  ],
23
22
  "scripts": {
24
- "test": "node --test",
23
+ "test": "node tools/test.mjs",
25
24
  "doctor": "node bin/tabretake.mjs doctor",
26
25
  "serve": "node bin/tabretake.mjs serve",
27
26
  "demo": "node bin/tabretake.mjs demo"
@@ -41,9 +41,9 @@ story will not update a saved timeline. Re-record for changed browser actions.
41
41
  ## Camera, posters and portrait branding
42
42
 
43
43
  - `--zoom 1.28` sets focus magnification.
44
- - From v0.4.1, `vertical.zoom` or `--vertical-zoom 1.8` sets portrait
45
- focus magnification independently (1–10). The flag overrides config; when
46
- neither is set it follows `--zoom`. Check capabilities before using the flag.
44
+ - `vertical.zoom` or `--vertical-zoom 1.8` sets portrait focus magnification
45
+ independently (1–10). The flag overrides config; when neither is set it
46
+ follows `--zoom`. Check capabilities before using the flag.
47
47
  - `zoomDuration` or `--zoom-duration 0.5` sets transition seconds; `0` uses cuts.
48
48
  - `posterAt` or `--poster-at 4.5` selects an output time strictly before the end.
49
49
  Without it, the poster is chosen near the end.
@@ -51,8 +51,8 @@ story will not update a saved timeline. Re-record for changed browser actions.
51
51
  suppresses captions and font-based portrait text.
52
52
 
53
53
  Portrait cards fit the source video's aspect ratio between the title and captions.
54
- From v0.4.1, landscape recordings also fit their source aspect ratio,
55
- with captions below the content. Zooming still intentionally crops the source.
54
+ Landscape recordings also fit their source aspect ratio, with captions below the
55
+ content. Zooming still intentionally crops the source.
56
56
  For a responsive mobile UI, record with a narrow viewport such as `390x844`;
57
57
  inspect the page with `plan --viewport 390x844` before recording at that size.
58
58
  Use `--zoom 1` to retain the full viewport. Larger zoom values intentionally crop
@@ -1,10 +1,9 @@
1
1
  # Story authoring
2
2
 
3
- Use `plan` output to select controls for the requested flow. From v0.3.3, `label`
4
- resolves ARIA references and HTML labels; native select `options` provide labels,
5
- values and disabled states. Older versions omit these fields; use the plan
6
- screenshot and existing control metadata instead. The plan's `name` remains the
7
- HTML attribute, not a computed accessible name. This DOM inventory is not a complete accessibility
3
+ Use `plan` output to select controls for the requested flow. `label` resolves
4
+ ARIA references and HTML labels; native select `options` provide labels, values
5
+ and disabled states. The plan's `name` remains the HTML attribute, not a
6
+ computed accessible name. This DOM inventory is not a complete accessibility
8
7
  tree. Use the supplied `selector` when the intended locator is uncertain.
9
8
 
10
9
  An editable story:
@@ -44,34 +43,29 @@ An editable story:
44
43
  | `screenshot` | `file`, relative to the output directory |
45
44
 
46
45
  Locator fields are `selector`, `role` + `name` (or `text`), `name`, or `text`.
47
- An explicit selector is tried first. From v0.4.0, a supplied
48
- role restricts name matching to that role, exact before partial. Without a role,
49
- try exact button/link candidates, partial button/link candidates, then plain text
50
- (exact before partial). This keeps noninteractive headings behind controls. Each candidate
46
+ An explicit selector is tried first. A supplied `role` restricts name matching
47
+ to that role, exact before partial. Without a role, try exact button/link
48
+ candidates, partial button/link candidates, then plain text (exact before
49
+ partial). This keeps noninteractive headings behind controls. Each candidate
51
50
  selects its first visible match; hidden exact matches do not block a visible
52
51
  partial match. Use a scoped selector when labels repeat or overlap.
53
- On v0.3.3 and earlier, partial buttons may beat exact links: use a selector such
54
- as `a[href='#/completed']` for “Completed” beside a “Clear completed” button.
55
52
  Story steps do not have a dedicated iframe locator. `type` clears the field
56
53
  before typing.
57
54
 
58
- From v0.3.3, `click` waits for an enabled, unobstructed target;
59
- its optional `timeout` is in milliseconds (default 20,000). Persistent blocking
60
- returns `STEP_TIMEOUT`. v0.3.2 and earlier do not reliably wait for clickable
61
- targets. A successful click does not prove the app finished processing it;
62
- continue to use `waitFor` for the expected result.
55
+ `click` waits for an enabled, unobstructed target; its optional `timeout` is in
56
+ milliseconds (default 20,000). Persistent blocking returns `STEP_TIMEOUT`.
57
+ A successful click does not prove the app finished processing it; continue to
58
+ use `waitFor` for the expected result.
63
59
 
64
60
  Use `waitFor` for a visible result before the next interaction. Give captions
65
61
  and focus targets explicit pauses. `focus` frames the target without clicking it;
66
62
  add another focus step after the layout changes. Use `preview --config story.json`
67
63
  to execute steps before recording. Preview performs actual app changes, so reset
68
64
  demo data before a retake. It preserves recordings and writes explicit screenshots.
69
- Use rendered output to check camera framing. Give captions
70
- time to be read; they begin after the interaction and replace the previous
71
- caption. In v0.3.1 or newer, an action's `pause` provides reading time
72
- after its caption starts. With older releases, set `pause: 0` and add a separate
73
- `wait` step to avoid delaying the caption. Re-record older stories to get the
74
- new timing; saved timelines keep their original timestamps.
65
+ Use rendered output to check camera framing. Give captions time to be read; they
66
+ begin after the interaction and replace the previous caption. An action's `pause`
67
+ provides reading time after its caption starts; saved timelines keep their
68
+ original timestamps.
75
69
  Set `zoom: false` when the result is elsewhere on screen. Avoid
76
70
  recording a blank initial load or ending on an unfinished dialog.
77
71
 
@@ -1,6 +1,6 @@
1
1
  import { access, mkdir, writeFile } from "node:fs/promises";
2
2
  import path from "node:path";
3
- import { parseCommand, parseViewport } from "./lib/options.mjs";
3
+ import { parseCommand, parseHttpUrl, parseScale, parseViewport } from "./lib/options.mjs";
4
4
  import { launchBrowser, loginAndSave, newContext } from "./lib/browser.mjs";
5
5
  import { assertConfig } from "./lib/config.mjs";
6
6
  import { navigate } from "./lib/navigation.mjs";
@@ -54,7 +54,7 @@ function toStep(event, pause) {
54
54
  return step;
55
55
  }
56
56
 
57
- export function pushCapturedEvent(merged, item) {
57
+ function pushCapturedEvent(merged, item) {
58
58
  if (!item || !item.action) return merged;
59
59
  const prev = merged.at(-1);
60
60
  const currKey = targetKey(item);
@@ -524,16 +524,7 @@ export async function capture(argv) {
524
524
  requireInteractiveLogin(values);
525
525
  const reporter = createReporter("capture", values.json);
526
526
 
527
- if (!values.url) throw new Error("Provide --url https://your-app.com");
528
- let parsedUrl;
529
- try {
530
- parsedUrl = new URL(values.url);
531
- } catch {
532
- throw new Error("Use a complete http:// or https:// URL");
533
- }
534
- if (!["http:", "https:"].includes(parsedUrl.protocol)) {
535
- throw new Error("Use a complete http:// or https:// URL");
536
- }
527
+ const parsedUrl = parseHttpUrl(values.url);
537
528
 
538
529
  const outPath = path.resolve(values.out);
539
530
  if (!values.force) {
@@ -546,12 +537,7 @@ export async function capture(argv) {
546
537
  }
547
538
 
548
539
  const viewport = parseViewport(values.viewport);
549
- const scaleInput = values.scale === undefined ? 1 : (values.scale.trim() === "" ? NaN : Number(values.scale));
550
- if (scaleInput !== 1 && scaleInput !== 2) {
551
- throw commandError("INVALID_CONFIG", "scale / --scale must be 1 or 2", {
552
- hint: "Choose 1 (standard) or 2 (HiDPI Retina).",
553
- });
554
- }
540
+ const scaleInput = parseScale(values.scale, 1);
555
541
  if (values.preset) resolveTheme({}, values.preset);
556
542
 
557
543
  let storageState = values["storage-state"];
@@ -592,6 +578,8 @@ export async function capture(argv) {
592
578
  if (values.run) {
593
579
  const runResult = await runPipeline({
594
580
  ...values,
581
+ login: false,
582
+ "storage-state": storageState,
595
583
  config: outPath,
596
584
  out: values["media-out"] || "demo",
597
585
  }, { reporter });
package/scripts/cli.mjs CHANGED
@@ -28,7 +28,7 @@ Examples:
28
28
  tabretake record --config examples/story.json --out demo
29
29
 
30
30
  Options:
31
- --json Machine-readable results for init, plan, record, render, run, capture and mark.
31
+ --json Machine-readable results (init, capture, plan, record, preview, render, run, mark, validate, doctor, capabilities).
32
32
  --login Open a visible browser so you can log in once.
33
33
  --storage-state Reuse a saved Playwright storage state (cookies/localStorage).
34
34
  --proxy Proxy server, e.g. http://127.0.0.1:10808
@@ -36,9 +36,11 @@ Options:
36
36
  --scale Device pixel scale for crisp zoom: 1 (default) or 2 (HiDPI Retina)
37
37
  --headed Watch the recording happen (default false)
38
38
  --vertical Also render a 9:16 vertical video + GIF.
39
+ --zoom Landscape focus magnification (1–10; default 1.28).
39
40
  --vertical-zoom Override portrait focus zoom (1–10; otherwise uses --zoom).
40
41
  --video Use an existing screen recording; the config needs "marks".
41
42
  --no-gif Skip GIF export.
43
+ --no-captions Suppress captions and portrait text overlays.
42
44
  --browser Browser channel: auto (default), chromium, chrome or msedge.
43
45
  --preset Brand theme preset: midnight, daylight, paper or slate.
44
46
  --poster-at Choose the poster time in output seconds, e.g. 4.5.
package/scripts/init.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { mkdir, writeFile } from "node:fs/promises";
2
2
  import path from "node:path";
3
- import { parseCommand } from "./lib/options.mjs";
3
+ import { parseCommand, parseHttpUrl } from "./lib/options.mjs";
4
4
  import { createReporter } from "./lib/report.mjs";
5
5
  import { resolveTheme } from "./lib/themes.mjs";
6
6
  import { extractPlan } from "./plan.mjs";
@@ -23,7 +23,7 @@ function scoreElement(el) {
23
23
  return score;
24
24
  }
25
25
 
26
- export function buildAutoSteps(elements) {
26
+ function buildAutoSteps(elements) {
27
27
  const steps = [{ action: "wait", ms: 600 }];
28
28
  const interactive = (elements || [])
29
29
  .filter((el) => {
@@ -112,16 +112,7 @@ export async function init(argv) {
112
112
  const { values } = parseCommand("init", argv);
113
113
  const reporter = createReporter("init", values.json);
114
114
 
115
- if (!values.url) throw new Error("Provide --url https://your-app.com");
116
- let url;
117
- try {
118
- url = new URL(values.url);
119
- } catch {
120
- throw new Error("Use a complete http:// or https:// URL");
121
- }
122
- if (!["http:", "https:"].includes(url.protocol)) {
123
- throw new Error("Use a complete http:// or https:// URL");
124
- }
115
+ const url = parseHttpUrl(values.url);
125
116
 
126
117
  let steps = [{ action: "wait", ms: 1500 }];
127
118
  if (values.auto) {
@@ -131,7 +122,7 @@ export async function init(argv) {
131
122
  steps = buildAutoSteps(elements);
132
123
  reporter.log(`Generated ${steps.length} step(s) from discovered interactive controls.`);
133
124
  } catch (err) {
134
- reporter.warn(`Could not scan page for --auto (${err.message}); falling back to starter.`);
125
+ reporter.warn(`Could not scan page for --auto (${err.message}); falling back to starter.${err.hint ? ` ${err.hint}` : ""}`);
135
126
  }
136
127
  }
137
128
 
@@ -4,11 +4,39 @@ import path from "node:path";
4
4
  import { chromium, errors } from "playwright";
5
5
  import { FFMPEG } from "./ffmpeg.mjs";
6
6
  import { navigate } from "./navigation.mjs";
7
+ import { commandError } from "./report.mjs";
7
8
  import { VALID_BROWSERS, findSystemBrowser } from "./system-browser.mjs";
9
+ import { hexToRgb } from "./themes.mjs";
8
10
  import { waitForEnter } from "./tty.mjs";
9
11
 
10
12
  export { VALID_BROWSERS, findSystemBrowser };
11
13
 
14
+ function classifyBrowserError(error, mode) {
15
+ const text = String(error?.message || error || "");
16
+ if (/Host system is missing dependencies|error while loading shared libraries|lib[a-z0-9_.-]+\.so/i.test(text)) {
17
+ return commandError("BROWSER_DEPS_MISSING", "Browser failed to start because required system libraries are missing.", {
18
+ hint: "Run tabretake setup --with-deps to install required browser system libraries.",
19
+ });
20
+ }
21
+ if (/Executable doesn't exist|Chromium distribution .* is not found|cannot find .*(?:chrome|msedge|chromium)/i.test(text)) {
22
+ if (mode === "chrome" || mode === "msedge") {
23
+ const label = mode === "chrome" ? "Google Chrome" : "Microsoft Edge";
24
+ return commandError("BROWSER_MISSING", `${label} is not installed or could not be found.`, {
25
+ hint: `Install ${label}, or omit --browser ${mode} to use automatic browser detection / tabretake setup.`,
26
+ });
27
+ }
28
+ if (mode === "chromium") {
29
+ return commandError("BROWSER_MISSING", "Playwright Chromium is not installed.", {
30
+ hint: "Run tabretake setup (or tabretake setup --with-deps on Linux) to install Chromium.",
31
+ });
32
+ }
33
+ return commandError("BROWSER_MISSING", "No usable browser found (Playwright Chromium, Google Chrome, or Microsoft Edge).", {
34
+ hint: "Run tabretake setup (or tabretake setup --with-deps on Linux) to install Chromium, or install Chrome/Edge.",
35
+ });
36
+ }
37
+ return error;
38
+ }
39
+
12
40
  export async function launchBrowser({
13
41
  headless = true,
14
42
  proxy,
@@ -33,23 +61,38 @@ export async function launchBrowser({
33
61
  args,
34
62
  };
35
63
 
64
+ const runLaunch = async (opts, errorMode) => {
65
+ try {
66
+ return await launch(opts);
67
+ } catch (error) {
68
+ throw classifyBrowserError(error, errorMode);
69
+ }
70
+ };
71
+
36
72
  if (mode === "chrome" || mode === "msedge") {
37
- return launch({ ...base, channel: mode });
73
+ return runLaunch({ ...base, channel: mode }, mode);
38
74
  }
39
75
 
40
76
  if (mode === "chromium" || hasBundledChromium()) {
41
- return launch(base);
77
+ return runLaunch(base, mode);
42
78
  }
43
79
 
80
+ let depsError = null;
81
+ let fallbackError = null;
44
82
  for (const channel of ["chrome", "msedge"]) {
45
83
  try {
46
- return await launch({ ...base, channel });
47
- } catch {
48
- // Continue trying next installed system browser channel.
84
+ return await runLaunch({ ...base, channel }, mode);
85
+ } catch (error) {
86
+ if (error.code === "BROWSER_DEPS_MISSING") depsError ||= error;
87
+ else if (error.code !== "BROWSER_MISSING") fallbackError ||= error;
49
88
  }
50
89
  }
51
90
 
52
- return launch(base);
91
+ if (depsError) throw depsError;
92
+ if (fallbackError) throw fallbackError;
93
+ throw commandError("BROWSER_MISSING", "No usable browser found (Playwright Chromium, Google Chrome, or Microsoft Edge).", {
94
+ hint: "Run tabretake setup (or tabretake setup --with-deps on Linux) to install Chromium, or install Chrome/Edge.",
95
+ });
53
96
  }
54
97
 
55
98
  export async function newContext(browser, options) {
@@ -106,11 +149,8 @@ export async function openRecordedPage(
106
149
  }
107
150
 
108
151
  function accentRgba(hex, alpha) {
109
- const clean = String(hex || "#6c5ce7").replace("#", "");
110
- const full = clean.length === 3 ? clean.split("").map((c) => c + c).join("") : clean;
111
- const n = Number.parseInt(full, 16);
112
- if (!Number.isFinite(n)) return `rgba(108,92,231,${alpha})`;
113
- return `rgba(${(n >> 16) & 255},${(n >> 8) & 255},${n & 255},${alpha})`;
152
+ const { r, g, b } = hexToRgb(hex, "#6c5ce7");
153
+ return `rgba(${r},${g},${b},${alpha})`;
114
154
  }
115
155
 
116
156
  /**
@@ -2,7 +2,7 @@ import { readFile } from "node:fs/promises";
2
2
  import { readFileSync } from "node:fs";
3
3
  import Ajv from "ajv";
4
4
 
5
- export const configSchema = JSON.parse(readFileSync(new URL("../../schemas/story.schema.json", import.meta.url), "utf8"));
5
+ const configSchema = JSON.parse(readFileSync(new URL("../../schemas/story.schema.json", import.meta.url), "utf8"));
6
6
  const ajv = new Ajv({ allErrors: true, strictRequired: false });
7
7
  ajv.addFormat("uri", (value) => {
8
8
  try { new URL(value); return true; } catch { return false; }
@@ -3,7 +3,7 @@ import ffmpegInstaller from "@ffmpeg-installer/ffmpeg";
3
3
  import ffprobeInstaller from "@ffprobe-installer/ffprobe";
4
4
 
5
5
  export const FFMPEG = ffmpegInstaller.path;
6
- export const FFPROBE = ffprobeInstaller.path;
6
+ const FFPROBE = ffprobeInstaller.path;
7
7
 
8
8
  export function run(bin, args, { capture = false } = {}) {
9
9
  return new Promise((resolve, reject) => {
@@ -44,17 +44,14 @@ export async function probe(file) {
44
44
  return JSON.parse(stdout);
45
45
  }
46
46
 
47
- export async function duration(file) {
48
- const info = await probe(file);
49
- return Number(info.format?.duration || 0);
50
- }
51
-
52
- export async function videoSize(file) {
47
+ export async function probeVideoMeta(file) {
53
48
  const info = await probe(file);
54
49
  const stream = (info.streams || []).find((s) => s.codec_type === "video");
55
- return {
56
- width: Number(stream?.width || 0),
57
- height: Number(stream?.height || 0),
58
- duration: Number(info.format?.duration || 0),
59
- };
50
+ const width = Number(stream?.width || 0);
51
+ const height = Number(stream?.height || 0);
52
+ const duration = Number(info.format?.duration || 0);
53
+ if (!width || !height || !duration) {
54
+ throw new Error(`Could not read video metadata: ${file}`);
55
+ }
56
+ return { width, height, duration };
60
57
  }