@gnawbit/tabretake 0.4.0 → 0.4.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 +7 -1
- package/README.md +66 -31
- package/README.zh-CN.md +69 -30
- package/SKILL.md +12 -8
- package/package.json +4 -3
- package/references/rendering.md +5 -0
- package/schemas/story.schema.json +6 -0
- package/scripts/cli.mjs +1 -0
- package/scripts/init.mjs +74 -2
- package/scripts/lib/options.mjs +2 -0
- package/scripts/plan.mjs +134 -113
- package/scripts/render.mjs +29 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 0.4.1 — 2026-11-24
|
|
4
|
+
|
|
5
|
+
- Add `init --auto` to automatically scan target web pages and generate runnable interactive steps.
|
|
6
|
+
- Fit landscape recordings to their source aspect ratio and place captions below the content so captions never occlude UI interactions.
|
|
7
|
+
- Add `vertical.zoom` and `--vertical-zoom` to enlarge portrait focus targets independently of landscape output.
|
|
8
|
+
- Use the published npm package as the primary CLI installation route.
|
|
9
|
+
- Add adoption measurement baseline and trial feedback issue template.
|
|
4
10
|
|
|
5
11
|
## 0.4.0 — 2026-11-23
|
|
6
12
|
|
package/README.md
CHANGED
|
@@ -8,29 +8,48 @@ English · [简体中文](README.zh-CN.md)
|
|
|
8
8
|
[](SKILL.md)
|
|
9
9
|
[](https://github.com/gnawbit/tabretake/stargazers)
|
|
10
10
|
|
|
11
|
-
**
|
|
11
|
+
**Automate your web app demos. Never manually record and edit a screen again.**
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Turn editable JSON steps or AI Agent instructions into crisp **16:9 README GIFs** and **9:16 portrait launch videos** — complete with smooth click zooms, cursor ripples, and unoccluded bottom captions. When your UI changes, re-run with one command.
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
<img src="docs/hero.gif" alt="TabRetake recording Vikunja: creating a task, dragging it across a Kanban board, and zooming into the result" width="100%">
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
the
|
|
20
|
-
|
|
17
|
+
*Recorded on [Vikunja v2.8.0](https://github.com/go-vikunja/vikunja) (15k★ open-source Kanban): Type a task, drag it into Doing on a live board, and automatically focus on the result. Generates 16:9 MP4, README GIF and 9:16 portrait video in seconds.*
|
|
18
|
+
|
|
19
|
+
[Project page](https://gnawbit.github.io/tabretake/) · [Watch the demo](docs/hero.mp4) · [Install](#install) · [How it works](#how-it-works) · [Real Showcase](#-real-world-showcase-proven-on-production-open-source-apps) · [Roadmap](#roadmap)
|
|
20
|
+
|
|
21
|
+
### ⚡ Why TabRetake vs Traditional Screen Recording?
|
|
22
|
+
|
|
23
|
+
| Challenge | Traditional Screen Recording | TabRetake Automated Workflow |
|
|
24
|
+
|---|---|---|
|
|
25
|
+
| **UI Changes** | Re-record manually, re-edit, re-export (2+ hours) | Edit 1 line of JSON or ask your agent (`tabretake render`, 10s) |
|
|
26
|
+
| **Mobile (9:16)** | Clunky manual cropping or separate recording | Simultaneous 16:9 + 9:16 export with independent focus zoom |
|
|
27
|
+
| **Captions** | Text overlays obstructing interactive UI elements | Dedicated bottom caption band fitted to source aspect ratio |
|
|
28
|
+
| **Automation** | Purely manual busywork | Headless Playwright CLI + AI Coding Agents (Claude Code, Cursor, Codex) |
|
|
21
29
|
|
|
22
30
|
Keep the story with your code and re-run it when the UI changes.
|
|
23
31
|
Already have a screen recording? Supply timestamp marks to
|
|
24
32
|
[render the same outputs without browser automation](#use-an-existing-screen-recording).
|
|
25
33
|
|
|
26
|
-
|
|
27
|
-
|
|
34
|
+
### 🚀 Quick Taste (30 Seconds)
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm install --global @gnawbit/tabretake@0.4.1
|
|
38
|
+
tabretake setup
|
|
39
|
+
tabretake demo
|
|
40
|
+
```
|
|
28
41
|
|
|
29
|
-
|
|
30
|
-
visibility, Skill selection and successful output; they are not adoption metrics.
|
|
42
|
+
### 🎯 Real-World Showcase: Proven on Production Open-Source Apps
|
|
31
43
|
|
|
32
|
-
|
|
33
|
-
|
|
44
|
+
No synthetic AI mockups. TabRetake is verified against real-world, complex DOMs and interactive components:
|
|
45
|
+
|
|
46
|
+
| 📋 [Vikunja](https://gnawbit.github.io/tabretake/vikunja/) (15k★ Kanban) | ✍️ [Memos](https://gnawbit.github.io/tabretake/memos/) (35k★ Notes) | 📝 [TodoMVC](https://gnawbit.github.io/tabretake/todomvc/) (Web Benchmark) |
|
|
47
|
+
|:---:|:---:|:---:|
|
|
48
|
+
| <a href="https://gnawbit.github.io/tabretake/vikunja/"><img src="docs/poster.png" alt="Vikunja Kanban" width="100%"></a> | <a href="https://gnawbit.github.io/tabretake/memos/"><img src="docs/examples/memos.png" alt="Memos Note-Taking" width="100%"></a> | <a href="https://gnawbit.github.io/tabretake/todomvc/"><img src="docs/examples/todomvc.png" alt="TodoMVC Benchmark" width="100%"></a> |
|
|
49
|
+
| **Kanban Drag & Drop**<br>Card movement & destination focus | **Rich Text & Search**<br>Live contenteditable & tag search | **Standard Task Filtering**<br>Clean ES6 multi-state walkthrough |
|
|
50
|
+
| [Story JSON](site/vikunja/story.json) · [Recipe](https://gnawbit.github.io/tabretake/vikunja/) | [Story JSON](site/memos/story.json) · [Recipe](https://gnawbit.github.io/tabretake/memos/) | [Story JSON](site/todomvc/story.json) · [Recipe](https://gnawbit.github.io/tabretake/todomvc/) |
|
|
51
|
+
|
|
52
|
+
> Works locally on Windows, macOS and Linux. Supports Claude Code, Codex, Cursor and any agent that supports [Agent Skills](https://agentskills.io).
|
|
34
53
|
|
|
35
54
|
---
|
|
36
55
|
|
|
@@ -66,20 +85,20 @@ edit and run again after a release.
|
|
|
66
85
|
|
|
67
86
|
## Install
|
|
68
87
|
|
|
69
|
-
Install the CLI from
|
|
88
|
+
Install the CLI from npm.
|
|
70
89
|
|
|
71
90
|
```bash
|
|
72
|
-
npm install --global
|
|
91
|
+
npm install --global @gnawbit/tabretake@0.4.1
|
|
73
92
|
tabretake setup
|
|
74
93
|
tabretake demo
|
|
75
94
|
```
|
|
76
95
|
|
|
77
|
-
Requires Node 20.9
|
|
96
|
+
Requires Node 20.9+. Run `tabretake` from your working directory;
|
|
78
97
|
the bundled demo writes its output to `./demo`. On Linux, use
|
|
79
98
|
`tabretake setup --with-deps` if browser system libraries are missing.
|
|
80
99
|
ffmpeg and ffprobe are included as dependencies.
|
|
81
100
|
|
|
82
|
-
|
|
101
|
+
The npm package is [`@gnawbit/tabretake`](https://www.npmjs.com/package/@gnawbit/tabretake). If you installed
|
|
83
102
|
`v0.3.3` or earlier, that release still uses `demo-reel` for the command and
|
|
84
103
|
Skill. Existing JSON stories work with `tabretake`.
|
|
85
104
|
|
|
@@ -99,7 +118,7 @@ replace `node bin/tabretake.mjs` with `tabretake`.
|
|
|
99
118
|
To add the agent workflow after setting up the CLI:
|
|
100
119
|
|
|
101
120
|
```bash
|
|
102
|
-
npx skills@1.9.0 add "https://github.com/gnawbit/tabretake.git#v0.4.
|
|
121
|
+
npx skills@1.9.0 add "https://github.com/gnawbit/tabretake.git#v0.4.1" --skill tabretake
|
|
103
122
|
```
|
|
104
123
|
|
|
105
124
|
Run this in the target project; add `--agent codex`, `--agent claude-code` or
|
|
@@ -110,7 +129,7 @@ or a source checkout. Install the CLI and Skill from the same revision.
|
|
|
110
129
|
Claude Code users can install the plugin instead (CLI 2.1.292+):
|
|
111
130
|
|
|
112
131
|
```bash
|
|
113
|
-
claude plugin install tabretake --marketplace "gnawbit/tabretake#v0.4.
|
|
132
|
+
claude plugin install tabretake --marketplace "gnawbit/tabretake#v0.4.1"
|
|
114
133
|
```
|
|
115
134
|
|
|
116
135
|
Install the workflow through one of these routes; the plugin still needs the
|
|
@@ -135,14 +154,14 @@ node bin/tabretake.mjs doctor
|
|
|
135
154
|
# 2. See it work on the bundled demo app
|
|
136
155
|
node bin/tabretake.mjs demo
|
|
137
156
|
|
|
138
|
-
# 3. Use it on your own app
|
|
139
|
-
|
|
140
|
-
|
|
157
|
+
# 3. Use it on your own app (Auto-detect interactive steps)
|
|
158
|
+
tabretake init --url https://your-app.com --auto
|
|
159
|
+
tabretake record --config demo.json
|
|
160
|
+
tabretake render --config demo/record.json --vertical
|
|
141
161
|
```
|
|
142
162
|
|
|
143
|
-
|
|
144
|
-
`
|
|
145
|
-
overwrite an existing story. Use `--out stories/demo.json` for another path.
|
|
163
|
+
`init --auto` scans your target page, detects visible inputs and buttons, and generates a runnable multi-step story with captions.
|
|
164
|
+
Without `--auto`, `init` creates a minimal starter waiting on the page. Use `plan --url <url>` to inventory all available DOM controls.
|
|
146
165
|
|
|
147
166
|
From v0.3.3, plans include a `label` from ARIA references or
|
|
148
167
|
HTML labels and native select `options` with `label`, `value` and `disabled`.
|
|
@@ -293,6 +312,13 @@ flow, inspect with `plan --viewport 390x844`, then record at the same viewport.
|
|
|
293
312
|
Render with `--vertical --zoom 1` to keep the full page in view; larger zooms
|
|
294
313
|
crop around focus points. Wide desktop recordings may still have small text.
|
|
295
314
|
|
|
315
|
+
From v0.4.1, landscape output fits the
|
|
316
|
+
source aspect ratio and reserves space below the recording for captions.
|
|
317
|
+
Use `--vertical --zoom 1 --vertical-zoom 1.8` to keep landscape overview while
|
|
318
|
+
enlarging portrait focus targets. Set `vertical.zoom` in the story to save that
|
|
319
|
+
portrait setting; the CLI flag takes precedence. Steps with `zoom: false`
|
|
320
|
+
still show the full view. Review the result for cropped context.
|
|
321
|
+
|
|
296
322
|
## Commands
|
|
297
323
|
|
|
298
324
|
| Command | What it does |
|
|
@@ -301,7 +327,7 @@ crop around focus points. Wide desktop recordings may still have small text.
|
|
|
301
327
|
| `tabretake capabilities --json` | List supported commands, flags and JSON support |
|
|
302
328
|
| `tabretake doctor [--json]` | Check Node, Chromium, ffmpeg, fonts |
|
|
303
329
|
| `tabretake setup` | Install the Chromium version used by this CLI |
|
|
304
|
-
| `tabretake init --url <url
|
|
330
|
+
| `tabretake init --url <url> [--auto]` | Create an editable story file (add `--auto` to scan page and generate interactive steps) |
|
|
305
331
|
| `tabretake validate --config demo.json [--json]` | Validate a story, marks or recorded timeline without recording |
|
|
306
332
|
| `tabretake plan --url <url>` | Screenshot + list interactive elements |
|
|
307
333
|
| `tabretake record --config demo.json` | Record the story |
|
|
@@ -310,6 +336,14 @@ crop around focus points. Wide desktop recordings may still have small text.
|
|
|
310
336
|
| `tabretake serve` | Serve the bundled demo app |
|
|
311
337
|
| `tabretake demo` | Record + render the bundled demo |
|
|
312
338
|
|
|
339
|
+
### 🏷️ Project Badge
|
|
340
|
+
|
|
341
|
+
If your repository uses TabRetake to generate its release walkthroughs or README GIFs, you can add our badge:
|
|
342
|
+
|
|
343
|
+
```markdown
|
|
344
|
+
[](https://github.com/gnawbit/tabretake)
|
|
345
|
+
```
|
|
346
|
+
|
|
313
347
|
For agents, `capabilities --json` and `doctor --json` emit one JSON object on
|
|
314
348
|
stdout with `schemaVersion: 1` and the installed version. Diagnostic checks have
|
|
315
349
|
stable `id`, `required`, `status` and recovery `hint` fields on failure. Exit code
|
|
@@ -412,12 +446,13 @@ Run **Actions → Regenerate TodoMVC demo → Run workflow** in your fork.
|
|
|
412
446
|
For your own app, replace its checkout/start command, readiness URL and story.
|
|
413
447
|
Keep demo data disposable. Review the generated assets before publishing them.
|
|
414
448
|
|
|
415
|
-
| Example | Story | Output |
|
|
416
|
-
|
|
417
|
-
|
|
|
449
|
+
| Real-World Example | Upstream Project | Story | Output |
|
|
450
|
+
|---|---|---|---|
|
|
451
|
+
| Vikunja Kanban (Hero) | [go-vikunja/vikunja](https://github.com/go-vikunja/vikunja) (15k★) | [site/vikunja/story.json](site/vikunja/story.json) | [16:9 MP4](docs/hero.mp4) · [9:16 MP4](docs/hero-9x16.mp4) · [GIF](docs/hero.gif) |
|
|
452
|
+
| Memos Knowledge Base | [usememos/memos](https://github.com/usememos/memos) (35k★) | [site/memos/story.json](site/memos/story.json) | [GIF](docs/examples/memos.gif) · [Poster](docs/examples/memos.png) |
|
|
453
|
+
| TodoMVC Benchmark | [tastejs/todomvc](https://github.com/tastejs/todomvc) (ES6) | [site/todomvc/story.json](site/todomvc/story.json) | [GIF](docs/examples/todomvc.gif) · [Poster](docs/examples/todomvc.png) |
|
|
418
454
|
|
|
419
|
-
|
|
420
|
-
for a README GIF, first-project onboarding and repeatable release assets.
|
|
455
|
+
For zero-dependency local testing without installing upstream apps, TabRetake also includes three bundled demo presets (readme, onboarding, release):
|
|
421
456
|
Run a preset from the source checkout (or use the installed `tabretake` command):
|
|
422
457
|
|
|
423
458
|
```bash
|
package/README.zh-CN.md
CHANGED
|
@@ -6,28 +6,49 @@
|
|
|
6
6
|
[](package.json)
|
|
7
7
|
[](https://github.com/gnawbit/tabretake/releases/latest)
|
|
8
8
|
[](SKILL.md)
|
|
9
|
+
[](https://github.com/gnawbit/tabretake/stargazers)
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
**自动化生成 Web 应用演示。从此告别手动录屏与繁琐剪辑。**
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
把可编辑的 JSON 步骤或 AI 编程助手的指令,直接转化为丝滑的 **16:9 README 动图 (GIF)** 与 **9:16 竖屏发布视频 (MP4)** —— 自带点击自动平滑放大、光标波纹和**不遮挡页面内容的底部字幕区**。界面改版后,一行命令全自动重拍重渲染。
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
<img src="docs/hero.gif" alt="TabRetake 录制 Vikunja 看板:创建任务、跨列拖拽并聚焦结果" width="100%">
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
*实测录制于 [Vikunja v2.8.0](https://github.com/go-vikunja/vikunja)(15k★ 开源看板):输入任务、在真实看板上将卡片拖入 Doing、自动将镜头推进聚焦到结果。单次录制同时生成 16:9 MP4、README 动图与 9:16 竖屏短片。*
|
|
18
|
+
|
|
19
|
+
[项目页](https://gnawbit.github.io/tabretake/) · [观看演示](docs/hero.mp4) · [安装](#安装) · [工作原理](#工作原理) · [真实实测展台](#-真实开源项目实测展台-real-world-showcase) · [路线图](#路线图)
|
|
20
|
+
|
|
21
|
+
### ⚡ 为什么选择 TabRetake?
|
|
22
|
+
|
|
23
|
+
| 常见痛点 | 传统手动录屏与剪辑 | TabRetake 自动化工作流 |
|
|
24
|
+
|---|---|---|
|
|
25
|
+
| **界面改版重录** | 手工重新操作、重新剪辑、补字幕(耗费 2 小时+) | 修改 1 行 JSON 或让 Agent 重跑(`tabretake render`,10秒搞定) |
|
|
26
|
+
| **竖屏发布 (9:16)** | 画面裁切变形或需重新单独录制 | 单次录制同时导出 16:9 与 9:16,支持竖屏独立放大倍率 |
|
|
27
|
+
| **字幕遮挡操作** | 悬浮字幕遮挡输入框或按钮 | 自动按源比例适配留白,字幕固定居于内容下方 |
|
|
28
|
+
| **多端与自动化** | 纯人工操作,无法纳入自动化流程 | 本地 Playwright CLI + AI 编程助手(Claude Code / Cursor / Codex) |
|
|
19
29
|
|
|
20
30
|
故事文件与代码一起保存,界面更新后即可重新生成演示。
|
|
21
31
|
已有录屏也可配合时间标记渲染相同产物,无需浏览器自动化;详见[用已有录屏](#用已有录屏)。
|
|
22
32
|
|
|
23
|
-
|
|
24
|
-
|
|
33
|
+
### 🚀 30秒极速体验
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npm install --global @gnawbit/tabretake@0.4.1
|
|
37
|
+
tabretake setup
|
|
38
|
+
tabretake demo
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### 🎯 真实开源项目实测展台 (Real-World Showcase)
|
|
42
|
+
|
|
43
|
+
拒绝虚假的 AI 蓝紫色假模版。TabRetake 在具有复杂 DOM 与真实交互的前端项目中深度验证:
|
|
25
44
|
|
|
26
|
-
[
|
|
27
|
-
|
|
45
|
+
| 📋 [Vikunja](https://gnawbit.github.io/tabretake/vikunja/) (15k★ 看板协作) | ✍️ [Memos](https://gnawbit.github.io/tabretake/memos/) (35k★ 知识笔记) | 📝 [TodoMVC](https://gnawbit.github.io/tabretake/todomvc/) (前端通用标准) |
|
|
46
|
+
|:---:|:---:|:---:|
|
|
47
|
+
| <a href="https://gnawbit.github.io/tabretake/vikunja/"><img src="docs/poster.png" alt="Vikunja 看板拖拽" width="100%"></a> | <a href="https://gnawbit.github.io/tabretake/memos/"><img src="docs/examples/memos.png" alt="Memos 富文本与搜索" width="100%"></a> | <a href="https://gnawbit.github.io/tabretake/todomvc/"><img src="docs/examples/todomvc.png" alt="TodoMVC 任务过滤" width="100%"></a> |
|
|
48
|
+
| **真实看板跨列拖拽**<br>复杂交互与目标卡片聚焦 | **富文本录入与检索**<br>真实 contenteditable 与标签联动 | **标准任务状态流**<br>经典 ES6 实现与完成项筛选 |
|
|
49
|
+
| [故事 JSON](site/vikunja/story.json) · [完整复现教程](https://gnawbit.github.io/tabretake/vikunja/) | [故事 JSON](site/memos/story.json) · [完整复现教程](https://gnawbit.github.io/tabretake/memos/) | [故事 JSON](site/todomvc/story.json) · [完整复现教程](https://gnawbit.github.io/tabretake/todomvc/) |
|
|
28
50
|
|
|
29
|
-
>
|
|
30
|
-
> [Agent Skills](https://agentskills.io) 的 agent。
|
|
51
|
+
> 本地原生运行于 Windows、macOS 与 Linux。支持 Claude Code、Codex、Cursor,以及任何支持 [Agent Skills](https://agentskills.io) 的 agent。
|
|
31
52
|
|
|
32
53
|
---
|
|
33
54
|
|
|
@@ -62,19 +83,19 @@ TabRetake 是在本地生成可重复网页演示的 CLI 和 Agent Skill。用
|
|
|
62
83
|
|
|
63
84
|
## 安装
|
|
64
85
|
|
|
65
|
-
|
|
86
|
+
从 npm 安装 CLI。
|
|
66
87
|
|
|
67
88
|
```bash
|
|
68
|
-
npm install --global
|
|
89
|
+
npm install --global @gnawbit/tabretake@0.4.1
|
|
69
90
|
tabretake setup
|
|
70
91
|
tabretake demo
|
|
71
92
|
```
|
|
72
93
|
|
|
73
|
-
要求 Node 20.9
|
|
94
|
+
要求 Node 20.9+。可以在工作目录运行 `tabretake`,内置示例会将结果写入
|
|
74
95
|
`./demo`。Linux 若缺少浏览器系统依赖,可用 `tabretake setup --with-deps`。
|
|
75
96
|
ffmpeg/ffprobe 随依赖安装。
|
|
76
97
|
|
|
77
|
-
包名为 `@gnawbit/tabretake
|
|
98
|
+
包名为 [`@gnawbit/tabretake`](https://www.npmjs.com/package/@gnawbit/tabretake),已在 npm 发布。
|
|
78
99
|
`v0.3.3` 及更早版本的命令和 Skill 仍叫 `demo-reel`。
|
|
79
100
|
安装新版后,现有 JSON 故事可以直接用 `tabretake` 运行。
|
|
80
101
|
|
|
@@ -93,7 +114,7 @@ node bin/tabretake.mjs doctor
|
|
|
93
114
|
CLI 环境就绪后,可安装 agent 工作流:
|
|
94
115
|
|
|
95
116
|
```bash
|
|
96
|
-
npx skills@1.9.0 add "https://github.com/gnawbit/tabretake.git#v0.4.
|
|
117
|
+
npx skills@1.9.0 add "https://github.com/gnawbit/tabretake.git#v0.4.1" --skill tabretake
|
|
97
118
|
```
|
|
98
119
|
|
|
99
120
|
在目标项目中运行,可加 `--agent codex`、`--agent claude-code` 或 `--agent cursor`
|
|
@@ -103,7 +124,7 @@ npx skills@1.9.0 add "https://github.com/gnawbit/tabretake.git#v0.4.0" --skill t
|
|
|
103
124
|
Claude Code 也可以通过插件安装(命令行版本需 2.1.292+):
|
|
104
125
|
|
|
105
126
|
```bash
|
|
106
|
-
claude plugin install tabretake --marketplace "gnawbit/tabretake#v0.4.
|
|
127
|
+
claude plugin install tabretake --marketplace "gnawbit/tabretake#v0.4.1"
|
|
107
128
|
```
|
|
108
129
|
|
|
109
130
|
两种工作流安装方式任选其一;插件仍需先安装上述 TabRetake 运行环境。
|
|
@@ -126,14 +147,15 @@ node bin/tabretake.mjs doctor
|
|
|
126
147
|
# 2. 跑一遍内置 demo
|
|
127
148
|
node bin/tabretake.mjs demo
|
|
128
149
|
|
|
129
|
-
# 3.
|
|
130
|
-
|
|
131
|
-
|
|
150
|
+
# 3. 录你自己的产品(支持 --auto 自动识别交互控件并生成步骤)
|
|
151
|
+
tabretake init --url https://your-app.com --auto
|
|
152
|
+
tabretake record --config demo.json
|
|
153
|
+
tabretake render --config demo/record.json --vertical
|
|
132
154
|
```
|
|
133
155
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
可用 `--out stories/demo.json`
|
|
156
|
+
`init --auto` 会自动扫描目标网页,识别可见的输入框与按钮,直接生成一段包含输入、点击和字幕的多步骤演示故事。
|
|
157
|
+
若不加 `--auto` 则生成初始占位模板。也可用 `tabretake plan --url <url>` 查看完整的 DOM 控件清单。
|
|
158
|
+
可用 `--out stories/demo.json` 指定其他保存路径。不会覆盖已有故事文件。
|
|
137
159
|
|
|
138
160
|
v0.3.3 起,`label` 来自 ARIA 引用或 HTML 标签;原生下拉框的 `options`
|
|
139
161
|
包含 `label`、`value` 和 `disabled`,方便识别控件与选项。`name` 仍是 HTML 属性,
|
|
@@ -274,6 +296,14 @@ v0.3.2 起,竖屏卡片按源视频比例适配。移动端流程可先用
|
|
|
274
296
|
渲染时加 `--vertical --zoom 1` 保留完整视口;更大的缩放会围绕焦点裁切。
|
|
275
297
|
宽屏桌面录屏中的细字仍可能偏小。
|
|
276
298
|
|
|
299
|
+
从 v0.4.1 起,横屏输出会按源视频比例自适应,并在录屏下方留出字幕区。
|
|
300
|
+
使用 `--vertical --zoom 1 --vertical-zoom 1.8` 可保持横屏全景,单独放大竖屏焦点。
|
|
301
|
+
故事中的 `vertical.zoom` 可保存竖屏倍率,命令行参数优先;`zoom: false` 的步骤
|
|
302
|
+
仍显示全景。放大后需检查是否裁掉必要上下文。
|
|
303
|
+
|
|
304
|
+
首次在自己的项目试用后,可[反馈首次演示结果](https://github.com/gnawbit/tabretake/issues/new?template=first-demo.yml),
|
|
305
|
+
失败同样有用。[试用与记录说明](docs/adoption.md)区分首次成功、重复使用和外部采用。
|
|
306
|
+
|
|
277
307
|
## 命令
|
|
278
308
|
|
|
279
309
|
| 命令 | 作用 |
|
|
@@ -282,7 +312,7 @@ v0.3.2 起,竖屏卡片按源视频比例适配。移动端流程可先用
|
|
|
282
312
|
| `tabretake capabilities --json` | 查询支持的命令、参数及 JSON 输出 |
|
|
283
313
|
| `tabretake doctor [--json]` | 检查 Node、Chromium、ffmpeg、字体 |
|
|
284
314
|
| `tabretake setup` | 安装与当前 CLI 匹配的 Chromium |
|
|
285
|
-
| `tabretake init --url <url
|
|
315
|
+
| `tabretake init --url <url> [--auto]` | 创建可编辑的故事文件(加 `--auto` 自动扫描并生成交互步骤) |
|
|
286
316
|
| `tabretake validate --config demo.json [--json]` | 预检故事、录屏标记或录制时间线 |
|
|
287
317
|
| `tabretake plan --url <url>` | 截图 + 列出可交互元素 |
|
|
288
318
|
| `tabretake record --config demo.json` | 录制故事 |
|
|
@@ -291,6 +321,14 @@ v0.3.2 起,竖屏卡片按源视频比例适配。移动端流程可先用
|
|
|
291
321
|
| `tabretake serve` | 启动内置 demo 站点 |
|
|
292
322
|
| `tabretake demo` | 录制 + 渲染内置 demo |
|
|
293
323
|
|
|
324
|
+
### 🏷️ 徽标接入 (Project Badge)
|
|
325
|
+
|
|
326
|
+
如果你的开源项目已使用 TabRetake 制作发布演示或 README 动图,欢迎在 README 中嵌入徽标:
|
|
327
|
+
|
|
328
|
+
```markdown
|
|
329
|
+
[](https://github.com/gnawbit/tabretake)
|
|
330
|
+
```
|
|
331
|
+
|
|
294
332
|
Agent 可用 `capabilities --json` 和 `doctor --json` 获取标准输出上的单个 JSON
|
|
295
333
|
对象,包含 `schemaVersion: 1` 和已安装版本。诊断包含稳定的 `id`、`required`、
|
|
296
334
|
`status`,失败时提供修复提示 `hint`。必需检查失败返回退出码 `1`;缺少字体仅警告,
|
|
@@ -382,12 +420,13 @@ node bin/tabretake.mjs record --config demo.json --storage-state auth.json
|
|
|
382
420
|
接入自己的应用时,替换应用检出与启动命令、就绪检测地址和故事文件。
|
|
383
421
|
使用可重置的演示数据,并在发布前检查成片。
|
|
384
422
|
|
|
385
|
-
|
|
|
386
|
-
|
|
387
|
-
|
|
|
423
|
+
| 真实开源案例 | 上游项目 | 故事脚本 | 输出产物 |
|
|
424
|
+
|---|---|---|---|
|
|
425
|
+
| Vikunja 看板 (Hero) | [go-vikunja/vikunja](https://github.com/go-vikunja/vikunja) (15k★) | [site/vikunja/story.json](site/vikunja/story.json) | [16:9 MP4](docs/hero.mp4) · [9:16 MP4](docs/hero-9x16.mp4) · [GIF](docs/hero.gif) |
|
|
426
|
+
| Memos 知识库 | [usememos/memos](https://github.com/usememos/memos) (35k★) | [site/memos/story.json](site/memos/story.json) | [GIF](docs/examples/memos.gif) · [封面](docs/examples/memos.png) |
|
|
427
|
+
| TodoMVC 经典标准 | [tastejs/todomvc](https://github.com/tastejs/todomvc) (ES6) | [site/todomvc/story.json](site/todomvc/story.json) | [GIF](docs/examples/todomvc.gif) · [封面](docs/examples/todomvc.png) |
|
|
388
428
|
|
|
389
|
-
|
|
390
|
-
README 动图、首次创建项目,以及重复生成发布素材。从源码目录运行(全局安装可将前缀替换为 `tabretake`):
|
|
429
|
+
如需在不下载任何上游项目的前提下快速体验,TabRetake 也内置了三个虚构应用预设(readme、onboarding、release),执行 `tabretake demo` 即可体验。从源码目录运行(全局安装可将前缀替换为 `tabretake`):
|
|
391
430
|
|
|
392
431
|
```bash
|
|
393
432
|
node bin/tabretake.mjs demo --story readme --port 0 --out demo-readme
|
package/SKILL.md
CHANGED
|
@@ -4,7 +4,7 @@ description: Create repeatable product demo videos and README GIFs from a web ap
|
|
|
4
4
|
license: MIT
|
|
5
5
|
metadata:
|
|
6
6
|
author: gnawbit
|
|
7
|
-
version: "0.4.
|
|
7
|
+
version: "0.4.1"
|
|
8
8
|
repository: https://github.com/gnawbit/tabretake
|
|
9
9
|
compatibility: Node.js 20.9+, Chromium via tabretake setup, Windows/macOS/Linux. Target app access is required. Rendering is local; dependency installation needs network access.
|
|
10
10
|
---
|
|
@@ -28,9 +28,9 @@ Use an installed `tabretake` CLI when available. The commands below assume it is
|
|
|
28
28
|
on PATH. For a source checkout, replace `tabretake` with
|
|
29
29
|
`node /absolute/path/to/tabretake/bin/tabretake.mjs`; paths with spaces need quoting.
|
|
30
30
|
A copied Skill does not prove its runtime dependencies are installed. If needed,
|
|
31
|
-
|
|
31
|
+
run `npm install --global @gnawbit/tabretake@0.4.1` and `tabretake setup`, or follow the
|
|
32
32
|
[CLI installation instructions](https://github.com/gnawbit/tabretake#install).
|
|
33
|
-
The renamed CLI and Skill are available together
|
|
33
|
+
The renamed CLI and Skill are available together from v0.4.0. Releases through
|
|
34
34
|
`v0.3.3` use the command and Skill name `demo-reel`.
|
|
35
35
|
|
|
36
36
|
```bash
|
|
@@ -68,13 +68,13 @@ state changes are usually enough for a short launch clip.
|
|
|
68
68
|
|
|
69
69
|
```bash
|
|
70
70
|
tabretake plan --url https://your-app.com --out plan.json --json
|
|
71
|
-
tabretake init --url https://your-app.com --out demo.json --json
|
|
71
|
+
tabretake init --url https://your-app.com --out demo.json --auto --json
|
|
72
72
|
```
|
|
73
73
|
|
|
74
|
-
2. Read the plan file from its returned artifact path.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
74
|
+
2. Read the plan file from its returned artifact path. If `--auto` was used, inspect
|
|
75
|
+
the generated steps; otherwise replace the starter's wait-only steps with the
|
|
76
|
+
requested flow. For actions, locator choices and timing units, read
|
|
77
|
+
[story authoring](references/story.md). `init` will not overwrite an existing story.
|
|
78
78
|
From v0.3.3, use `label` to identify form controls and native select `options`
|
|
79
79
|
to inspect their labels, values and disabled states. Older versions omit these
|
|
80
80
|
fields; use the plan screenshot and existing control metadata instead.
|
|
@@ -101,6 +101,10 @@ state changes are usually enough for a short launch clip.
|
|
|
101
101
|
From v0.3.2, portrait cards fit the source aspect ratio. For a mobile flow,
|
|
102
102
|
inspect and record at a narrow viewport (for example `390x844`); use
|
|
103
103
|
`--zoom 1` to preserve the full viewport. Wide desktop text may still be small.
|
|
104
|
+
From v0.4.1, `vertical-zoom` is supported: use
|
|
105
|
+
`--vertical --zoom 1 --vertical-zoom 1.8` for portrait focus magnification
|
|
106
|
+
while retaining landscape overview. `vertical.zoom` saves the portrait
|
|
107
|
+
setting in config; the flag overrides it. `zoom: false` remains overview.
|
|
104
108
|
|
|
105
109
|
4. Inspect the poster and video, then return links to the actual generated
|
|
106
110
|
artifacts. Re-record after flow changes; re-render the saved timeline after
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gnawbit/tabretake",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.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": {
|
|
7
|
-
"tabretake": "
|
|
7
|
+
"tabretake": "bin/tabretake.mjs"
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
10
|
"bin/",
|
|
@@ -58,6 +58,7 @@
|
|
|
58
58
|
"sharp": "^0.35.5"
|
|
59
59
|
},
|
|
60
60
|
"publishConfig": {
|
|
61
|
-
"access": "public"
|
|
61
|
+
"access": "public",
|
|
62
|
+
"registry": "https://registry.npmjs.org"
|
|
62
63
|
}
|
|
63
64
|
}
|
package/references/rendering.md
CHANGED
|
@@ -38,6 +38,9 @@ story will not update a saved timeline. Re-record for changed browser actions.
|
|
|
38
38
|
## Camera, posters and portrait branding
|
|
39
39
|
|
|
40
40
|
- `--zoom 1.28` sets focus magnification.
|
|
41
|
+
- From v0.4.1, `vertical.zoom` or `--vertical-zoom 1.8` sets portrait
|
|
42
|
+
focus magnification independently (1–10). The flag overrides config; when
|
|
43
|
+
neither is set it follows `--zoom`. Check capabilities before using the flag.
|
|
41
44
|
- `zoomDuration` or `--zoom-duration 0.5` sets transition seconds; `0` uses cuts.
|
|
42
45
|
- `posterAt` or `--poster-at 4.5` selects an output time strictly before the end.
|
|
43
46
|
Without it, the poster is chosen near the end.
|
|
@@ -45,6 +48,8 @@ story will not update a saved timeline. Re-record for changed browser actions.
|
|
|
45
48
|
suppresses captions and font-based portrait text.
|
|
46
49
|
|
|
47
50
|
Portrait cards fit the source video's aspect ratio between the title and captions.
|
|
51
|
+
From v0.4.1, landscape recordings also fit their source aspect ratio,
|
|
52
|
+
with captions below the content. Zooming still intentionally crops the source.
|
|
48
53
|
For a responsive mobile UI, record with a narrow viewport such as `390x844`;
|
|
49
54
|
inspect the page with `plan --viewport 390x844` before recording at that size.
|
|
50
55
|
Use `--zoom 1` to retain the full viewport. Larger zoom values intentionally crop
|
|
@@ -35,6 +35,12 @@
|
|
|
35
35
|
"vertical": {
|
|
36
36
|
"type": "object",
|
|
37
37
|
"properties": {
|
|
38
|
+
"zoom": {
|
|
39
|
+
"type": "number",
|
|
40
|
+
"minimum": 1,
|
|
41
|
+
"maximum": 10,
|
|
42
|
+
"description": "Portrait focus magnification; --vertical-zoom overrides this value."
|
|
43
|
+
},
|
|
38
44
|
"badge": {
|
|
39
45
|
"type": "string"
|
|
40
46
|
},
|
package/scripts/cli.mjs
CHANGED
|
@@ -33,6 +33,7 @@ Options:
|
|
|
33
33
|
--viewport Viewport, e.g. 1440x810 (default from config)
|
|
34
34
|
--headed Watch the recording happen (default false)
|
|
35
35
|
--vertical Also render a 9:16 vertical video + GIF.
|
|
36
|
+
--vertical-zoom Override portrait focus zoom (1–10; otherwise uses --zoom).
|
|
36
37
|
--video Use an existing screen recording; the config needs "marks".
|
|
37
38
|
--no-gif Skip GIF export.
|
|
38
39
|
--poster-at Choose the poster time in output seconds, e.g. 4.5.
|
package/scripts/init.mjs
CHANGED
|
@@ -2,6 +2,64 @@ import { mkdir, writeFile } from "node:fs/promises";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { parseCommand } from "./lib/options.mjs";
|
|
4
4
|
import { createReporter } from "./lib/report.mjs";
|
|
5
|
+
import { extractPlan } from "./plan.mjs";
|
|
6
|
+
|
|
7
|
+
export function buildAutoSteps(elements) {
|
|
8
|
+
const steps = [{ action: "wait", ms: 600 }];
|
|
9
|
+
const interactive = (elements || []).filter((el) => {
|
|
10
|
+
if (el.type === "password" || el.type === "hidden") return false;
|
|
11
|
+
return Boolean(el.selector && (el.text || el.label || el.placeholder || el.name));
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const inputs = interactive.filter((el) => el.tag === "input" || el.tag === "textarea" || el.role === "textbox");
|
|
15
|
+
const buttons = interactive.filter((el) => el.tag === "button" || el.tag === "a" || el.role === "button" || el.role === "link");
|
|
16
|
+
|
|
17
|
+
const chosen = [];
|
|
18
|
+
if (inputs.length > 0) {
|
|
19
|
+
chosen.push(inputs[0]);
|
|
20
|
+
}
|
|
21
|
+
for (const btn of buttons) {
|
|
22
|
+
if (chosen.length >= 3) break;
|
|
23
|
+
if (!chosen.some((c) => c.selector === btn.selector)) {
|
|
24
|
+
chosen.push(btn);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
for (const el of interactive) {
|
|
28
|
+
if (chosen.length >= 3) break;
|
|
29
|
+
if (!chosen.some((c) => c.selector === el.selector)) {
|
|
30
|
+
chosen.push(el);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
for (const el of chosen) {
|
|
35
|
+
if (el.tag === "input" || el.tag === "textarea" || el.role === "textbox") {
|
|
36
|
+
const caption = el.label || el.placeholder || (el.name ? `Enter ${el.name}` : "Input demo text");
|
|
37
|
+
steps.push({
|
|
38
|
+
action: "type",
|
|
39
|
+
selector: el.selector,
|
|
40
|
+
value: "Test drive",
|
|
41
|
+
pause: 400,
|
|
42
|
+
caption: `Input: ${caption}`,
|
|
43
|
+
});
|
|
44
|
+
} else {
|
|
45
|
+
const caption = el.text || el.label || (el.role ? `${el.role}` : "Click target");
|
|
46
|
+
steps.push({
|
|
47
|
+
action: "click",
|
|
48
|
+
selector: el.selector,
|
|
49
|
+
pause: 600,
|
|
50
|
+
caption: `Click: ${caption}`,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
steps.push({ action: "wait", ms: 600 });
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (steps.length === 1) {
|
|
57
|
+
steps.push({ action: "wait", ms: 1500 });
|
|
58
|
+
} else {
|
|
59
|
+
steps.push({ action: "wait", ms: 1200 });
|
|
60
|
+
}
|
|
61
|
+
return steps;
|
|
62
|
+
}
|
|
5
63
|
|
|
6
64
|
export async function init(argv) {
|
|
7
65
|
const { values } = parseCommand("init", argv);
|
|
@@ -18,6 +76,18 @@ export async function init(argv) {
|
|
|
18
76
|
throw new Error("Use a complete http:// or https:// URL");
|
|
19
77
|
}
|
|
20
78
|
|
|
79
|
+
let steps = [{ action: "wait", ms: 1500 }];
|
|
80
|
+
if (values.auto) {
|
|
81
|
+
reporter.log("Scanning page to generate interactive steps (--auto)...");
|
|
82
|
+
try {
|
|
83
|
+
const { elements } = await extractPlan(url.href);
|
|
84
|
+
steps = buildAutoSteps(elements);
|
|
85
|
+
reporter.log(`Generated ${steps.length} step(s) from discovered interactive controls.`);
|
|
86
|
+
} catch (err) {
|
|
87
|
+
reporter.warn(`Could not scan page for --auto (${err.message}); falling back to starter.`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
21
91
|
const story = {
|
|
22
92
|
url: url.href,
|
|
23
93
|
displayUrl: url.host,
|
|
@@ -25,7 +95,7 @@ export async function init(argv) {
|
|
|
25
95
|
initialWait: 700,
|
|
26
96
|
tail: 1200,
|
|
27
97
|
brand: { background: "#070a12", accent: "#6c5ce7" },
|
|
28
|
-
steps
|
|
98
|
+
steps,
|
|
29
99
|
};
|
|
30
100
|
const outPath = path.resolve(values.out);
|
|
31
101
|
await mkdir(path.dirname(outPath), { recursive: true });
|
|
@@ -39,7 +109,9 @@ export async function init(argv) {
|
|
|
39
109
|
}
|
|
40
110
|
|
|
41
111
|
reporter.log(`Created story: ${outPath}`);
|
|
42
|
-
|
|
112
|
+
if (!values.auto) {
|
|
113
|
+
reporter.log("The starter records a static page. Use plan to find controls, then add click/type steps.");
|
|
114
|
+
}
|
|
43
115
|
reporter.log("Run record with this config, then render the resulting record.json.");
|
|
44
116
|
await reporter.success({ artifacts: [{ kind: "story", path: outPath }] });
|
|
45
117
|
return outPath;
|
package/scripts/lib/options.mjs
CHANGED
|
@@ -6,6 +6,7 @@ export const commandOptions = {
|
|
|
6
6
|
json: { type: "boolean", default: false },
|
|
7
7
|
url: { type: "string" },
|
|
8
8
|
out: { type: "string", default: "demo.json" },
|
|
9
|
+
auto: { type: "boolean", default: false },
|
|
9
10
|
},
|
|
10
11
|
plan: {
|
|
11
12
|
json: { type: "boolean", default: false },
|
|
@@ -38,6 +39,7 @@ export const commandOptions = {
|
|
|
38
39
|
"no-captions": { type: "boolean", default: false },
|
|
39
40
|
vertical: { type: "boolean", default: false },
|
|
40
41
|
zoom: { type: "string", default: "1.28" },
|
|
42
|
+
"vertical-zoom": { type: "string" },
|
|
41
43
|
"zoom-duration": { type: "string" },
|
|
42
44
|
"poster-at": { type: "string" },
|
|
43
45
|
},
|
package/scripts/plan.mjs
CHANGED
|
@@ -12,6 +12,139 @@ function parseViewport(value) {
|
|
|
12
12
|
return { width: w || 1440, height: h || 810 };
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
export async function collectElements(page) {
|
|
16
|
+
return page.evaluate(() => {
|
|
17
|
+
function cssPath(el) {
|
|
18
|
+
if (!el || el.nodeType !== 1) return "";
|
|
19
|
+
if (el.id) return `#${CSS.escape(el.id)}`;
|
|
20
|
+
const parts = [];
|
|
21
|
+
let node = el;
|
|
22
|
+
while (node && node.nodeType === 1 && parts.length < 5) {
|
|
23
|
+
let part = node.tagName.toLowerCase();
|
|
24
|
+
if (node.classList && node.classList.length) {
|
|
25
|
+
part +=
|
|
26
|
+
"." +
|
|
27
|
+
[...node.classList]
|
|
28
|
+
.slice(0, 2)
|
|
29
|
+
.map((c) => CSS.escape(c))
|
|
30
|
+
.join(".");
|
|
31
|
+
}
|
|
32
|
+
const parent = node.parentElement;
|
|
33
|
+
if (parent) {
|
|
34
|
+
const siblings = [...parent.children].filter(
|
|
35
|
+
(c) => c.tagName === node.tagName,
|
|
36
|
+
);
|
|
37
|
+
if (siblings.length > 1) {
|
|
38
|
+
part += `:nth-of-type(${siblings.indexOf(node) + 1})`;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
parts.unshift(part);
|
|
42
|
+
if (node.id) {
|
|
43
|
+
parts[0] = `#${CSS.escape(node.id)}`;
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
node = parent;
|
|
47
|
+
}
|
|
48
|
+
return parts.join(" > ");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function normalizeText(value) {
|
|
52
|
+
return (value || "").replace(/\s+/g, " ").trim();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function labelText(node) {
|
|
56
|
+
if (!node) return "";
|
|
57
|
+
const copy = node.cloneNode(true);
|
|
58
|
+
copy.querySelectorAll("input, textarea, select, button, script, style")
|
|
59
|
+
.forEach((control) => control.remove());
|
|
60
|
+
return normalizeText(copy.textContent);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function controlLabel(el) {
|
|
64
|
+
const referenced = (el.getAttribute("aria-labelledby") || "")
|
|
65
|
+
.split(/\s+/).filter(Boolean)
|
|
66
|
+
.map((id) => labelText(document.getElementById(id))).filter(Boolean)
|
|
67
|
+
.join(" ");
|
|
68
|
+
return referenced || normalizeText(el.getAttribute("aria-label")) ||
|
|
69
|
+
[...(el.labels || [])].map(labelText).filter(Boolean).join(" ");
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const nodes = [
|
|
73
|
+
...document.querySelectorAll(
|
|
74
|
+
'a, button, input, textarea, select, [role=button], [role=link], [role=tab], [role=textbox], [contenteditable="true"], [contenteditable=""], [contenteditable="plaintext-only"]',
|
|
75
|
+
),
|
|
76
|
+
];
|
|
77
|
+
|
|
78
|
+
return nodes
|
|
79
|
+
.map((el) => {
|
|
80
|
+
const rect = el.getBoundingClientRect();
|
|
81
|
+
const style = getComputedStyle(el);
|
|
82
|
+
const visible =
|
|
83
|
+
rect.width > 2 &&
|
|
84
|
+
rect.height > 2 &&
|
|
85
|
+
style.visibility !== "hidden" &&
|
|
86
|
+
style.display !== "none" &&
|
|
87
|
+
Number(style.opacity || 1) > 0.05;
|
|
88
|
+
|
|
89
|
+
const label = controlLabel(el);
|
|
90
|
+
const text = (
|
|
91
|
+
label || el.innerText ||
|
|
92
|
+
(el.type === "password" ? "" : el.value) ||
|
|
93
|
+
el.getAttribute("aria-label") ||
|
|
94
|
+
el.getAttribute("placeholder") ||
|
|
95
|
+
el.getAttribute("title") ||
|
|
96
|
+
""
|
|
97
|
+
)
|
|
98
|
+
.replace(/\s+/g, " ")
|
|
99
|
+
.trim()
|
|
100
|
+
.slice(0, 140);
|
|
101
|
+
|
|
102
|
+
return {
|
|
103
|
+
tag: el.tagName.toLowerCase(),
|
|
104
|
+
type: el.getAttribute("type") || "",
|
|
105
|
+
role: el.getAttribute("role") || "",
|
|
106
|
+
text,
|
|
107
|
+
label,
|
|
108
|
+
name: el.getAttribute("name") || "",
|
|
109
|
+
placeholder: el.getAttribute("placeholder") || "",
|
|
110
|
+
...(el.tagName === "SELECT" ? {
|
|
111
|
+
options: [...el.options].map((option) => ({
|
|
112
|
+
label: normalizeText(option.label),
|
|
113
|
+
value: option.value,
|
|
114
|
+
disabled: el.matches(":disabled") || option.disabled ||
|
|
115
|
+
Boolean(option.closest("optgroup")?.disabled),
|
|
116
|
+
})),
|
|
117
|
+
} : {}),
|
|
118
|
+
x: Math.round(rect.x),
|
|
119
|
+
y: Math.round(rect.y),
|
|
120
|
+
width: Math.round(rect.width),
|
|
121
|
+
height: Math.round(rect.height),
|
|
122
|
+
selector: cssPath(el),
|
|
123
|
+
visible,
|
|
124
|
+
};
|
|
125
|
+
})
|
|
126
|
+
.filter((el) => el.visible)
|
|
127
|
+
.slice(0, 300);
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export async function extractPlan(url, { viewport = { width: 1440, height: 810 }, proxy, storageState, headless = true } = {}) {
|
|
132
|
+
const browser = await launchBrowser({ headless, proxy });
|
|
133
|
+
try {
|
|
134
|
+
const context = await newContext(browser, { viewport, storageState });
|
|
135
|
+
const page = await context.newPage();
|
|
136
|
+
await navigate(page, url);
|
|
137
|
+
await page.waitForLoadState("networkidle", { timeout: 15000 }).catch(() => {});
|
|
138
|
+
await page.waitForTimeout(800);
|
|
139
|
+
const title = await page.title();
|
|
140
|
+
const elements = await collectElements(page);
|
|
141
|
+
await context.close();
|
|
142
|
+
return { title, elements };
|
|
143
|
+
} finally {
|
|
144
|
+
await browser.close();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
15
148
|
export async function plan(argv) {
|
|
16
149
|
const { values } = parseCommand("plan", argv);
|
|
17
150
|
requireInteractiveLogin(values);
|
|
@@ -48,119 +181,7 @@ export async function plan(argv) {
|
|
|
48
181
|
await page.screenshot({ path: screenshotPath });
|
|
49
182
|
|
|
50
183
|
const title = await page.title();
|
|
51
|
-
const elements = await page
|
|
52
|
-
function cssPath(el) {
|
|
53
|
-
if (!el || el.nodeType !== 1) return "";
|
|
54
|
-
if (el.id) return `#${CSS.escape(el.id)}`;
|
|
55
|
-
const parts = [];
|
|
56
|
-
let node = el;
|
|
57
|
-
while (node && node.nodeType === 1 && parts.length < 5) {
|
|
58
|
-
let part = node.tagName.toLowerCase();
|
|
59
|
-
if (node.classList && node.classList.length) {
|
|
60
|
-
part +=
|
|
61
|
-
"." +
|
|
62
|
-
[...node.classList]
|
|
63
|
-
.slice(0, 2)
|
|
64
|
-
.map((c) => CSS.escape(c))
|
|
65
|
-
.join(".");
|
|
66
|
-
}
|
|
67
|
-
const parent = node.parentElement;
|
|
68
|
-
if (parent) {
|
|
69
|
-
const siblings = [...parent.children].filter(
|
|
70
|
-
(c) => c.tagName === node.tagName,
|
|
71
|
-
);
|
|
72
|
-
if (siblings.length > 1) {
|
|
73
|
-
part += `:nth-of-type(${siblings.indexOf(node) + 1})`;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
parts.unshift(part);
|
|
77
|
-
if (node.id) {
|
|
78
|
-
parts[0] = `#${CSS.escape(node.id)}`;
|
|
79
|
-
break;
|
|
80
|
-
}
|
|
81
|
-
node = parent;
|
|
82
|
-
}
|
|
83
|
-
return parts.join(" > ");
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function normalizeText(value) {
|
|
87
|
-
return (value || "").replace(/\s+/g, " ").trim();
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function labelText(node) {
|
|
91
|
-
if (!node) return "";
|
|
92
|
-
const copy = node.cloneNode(true);
|
|
93
|
-
copy.querySelectorAll("input, textarea, select, button, script, style")
|
|
94
|
-
.forEach((control) => control.remove());
|
|
95
|
-
return normalizeText(copy.textContent);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function controlLabel(el) {
|
|
99
|
-
const referenced = (el.getAttribute("aria-labelledby") || "")
|
|
100
|
-
.split(/\s+/).filter(Boolean)
|
|
101
|
-
.map((id) => labelText(document.getElementById(id))).filter(Boolean)
|
|
102
|
-
.join(" ");
|
|
103
|
-
return referenced || normalizeText(el.getAttribute("aria-label")) ||
|
|
104
|
-
[...(el.labels || [])].map(labelText).filter(Boolean).join(" ");
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const nodes = [
|
|
108
|
-
...document.querySelectorAll(
|
|
109
|
-
'a, button, input, textarea, select, [role=button], [role=link], [role=tab], [role=textbox], [contenteditable="true"], [contenteditable=""], [contenteditable="plaintext-only"]',
|
|
110
|
-
),
|
|
111
|
-
];
|
|
112
|
-
|
|
113
|
-
return nodes
|
|
114
|
-
.map((el) => {
|
|
115
|
-
const rect = el.getBoundingClientRect();
|
|
116
|
-
const style = getComputedStyle(el);
|
|
117
|
-
const visible =
|
|
118
|
-
rect.width > 2 &&
|
|
119
|
-
rect.height > 2 &&
|
|
120
|
-
style.visibility !== "hidden" &&
|
|
121
|
-
style.display !== "none" &&
|
|
122
|
-
Number(style.opacity || 1) > 0.05;
|
|
123
|
-
|
|
124
|
-
const label = controlLabel(el);
|
|
125
|
-
const text = (
|
|
126
|
-
label || el.innerText ||
|
|
127
|
-
(el.type === "password" ? "" : el.value) ||
|
|
128
|
-
el.getAttribute("aria-label") ||
|
|
129
|
-
el.getAttribute("placeholder") ||
|
|
130
|
-
el.getAttribute("title") ||
|
|
131
|
-
""
|
|
132
|
-
)
|
|
133
|
-
.replace(/\s+/g, " ")
|
|
134
|
-
.trim()
|
|
135
|
-
.slice(0, 140);
|
|
136
|
-
|
|
137
|
-
return {
|
|
138
|
-
tag: el.tagName.toLowerCase(),
|
|
139
|
-
type: el.getAttribute("type") || "",
|
|
140
|
-
role: el.getAttribute("role") || "",
|
|
141
|
-
text,
|
|
142
|
-
label,
|
|
143
|
-
name: el.getAttribute("name") || "",
|
|
144
|
-
placeholder: el.getAttribute("placeholder") || "",
|
|
145
|
-
...(el.tagName === "SELECT" ? {
|
|
146
|
-
options: [...el.options].map((option) => ({
|
|
147
|
-
label: normalizeText(option.label),
|
|
148
|
-
value: option.value,
|
|
149
|
-
disabled: el.matches(":disabled") || option.disabled ||
|
|
150
|
-
Boolean(option.closest("optgroup")?.disabled),
|
|
151
|
-
})),
|
|
152
|
-
} : {}),
|
|
153
|
-
x: Math.round(rect.x),
|
|
154
|
-
y: Math.round(rect.y),
|
|
155
|
-
width: Math.round(rect.width),
|
|
156
|
-
height: Math.round(rect.height),
|
|
157
|
-
selector: cssPath(el),
|
|
158
|
-
visible,
|
|
159
|
-
};
|
|
160
|
-
})
|
|
161
|
-
.filter((el) => el.visible)
|
|
162
|
-
.slice(0, 300);
|
|
163
|
-
});
|
|
184
|
+
const elements = await collectElements(page);
|
|
164
185
|
|
|
165
186
|
const result = {
|
|
166
187
|
url: values.url,
|
package/scripts/render.mjs
CHANGED
|
@@ -42,6 +42,21 @@ const LAYOUTS = {
|
|
|
42
42
|
},
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
+
function landscapeLayout(videoW, videoH) {
|
|
46
|
+
const layout = LAYOUTS.landscape;
|
|
47
|
+
// Reserve a separate caption band and retain the full source at overview.
|
|
48
|
+
const fit = Math.min(layout.content.w / videoW, 760 / videoH);
|
|
49
|
+
const w = Math.max(2, Math.floor(videoW * fit / 2) * 2);
|
|
50
|
+
const h = Math.max(2, Math.floor(videoH * fit / 2) * 2);
|
|
51
|
+
const x = (layout.width - w) / 2;
|
|
52
|
+
const y = 122 + (760 - h) / 2;
|
|
53
|
+
return {
|
|
54
|
+
...layout,
|
|
55
|
+
content: { x, y, w, h },
|
|
56
|
+
frame: { ...layout.frame, x: x - 16, y: y - 52, w: w + 32, h: h + 52 },
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
45
60
|
function verticalLayout(videoW, videoH) {
|
|
46
61
|
const layout = LAYOUTS.vertical;
|
|
47
62
|
// Fit the source between branding and captions instead of cropping a phone
|
|
@@ -142,6 +157,11 @@ async function makeBrowserFrame(file, hostname, layout) {
|
|
|
142
157
|
const url = escapeXml(hostname || "your-app.com");
|
|
143
158
|
const { x, y, w, h } = layout.frame;
|
|
144
159
|
const bar = layout.content.y - y;
|
|
160
|
+
const addressWidth = Math.max(0, Math.min(560, w - 128));
|
|
161
|
+
const address = addressWidth >= 120 ? `
|
|
162
|
+
<clipPath id="address-clip"><rect x="${x + 114}" y="${y + 13}" width="${addressWidth - 20}" height="26"/></clipPath>
|
|
163
|
+
<rect x="${x + 104}" y="${y + 13}" width="${addressWidth}" height="26" rx="13" fill="#161B23" stroke="#262D3A"/>
|
|
164
|
+
<text clip-path="url(#address-clip)" x="${x + 122}" y="${y + 30}" font-family="Arial, Segoe UI, sans-serif" font-size="12.5" fill="#8A93A6">${url}</text>` : "";
|
|
145
165
|
|
|
146
166
|
const svg = `
|
|
147
167
|
<svg xmlns="http://www.w3.org/2000/svg" width="${layout.width}" height="${layout.height}">
|
|
@@ -162,8 +182,7 @@ async function makeBrowserFrame(file, hostname, layout) {
|
|
|
162
182
|
<circle cx="${x + 32}" cy="${y + bar / 2}" r="5.5" fill="#FF5F57"/>
|
|
163
183
|
<circle cx="${x + 54}" cy="${y + bar / 2}" r="5.5" fill="#FEBC2E"/>
|
|
164
184
|
<circle cx="${x + 76}" cy="${y + bar / 2}" r="5.5" fill="#28C840"/>
|
|
165
|
-
|
|
166
|
-
<text x="${x + 122}" y="${y + 30}" font-family="Arial, Segoe UI, sans-serif" font-size="12.5" fill="#8A93A6">${url}</text>
|
|
185
|
+
${address}
|
|
167
186
|
<rect x="${x + 1}" y="${y + 1}" width="${w - 2}" height="${h - 2}" rx="17" fill="none" stroke="#ffffff" stroke-opacity="0.04"/>
|
|
168
187
|
</g>
|
|
169
188
|
</svg>`;
|
|
@@ -511,6 +530,12 @@ export async function render(argv) {
|
|
|
511
530
|
if (!Number.isFinite(zoom) || zoom < 1 || zoom > 10) {
|
|
512
531
|
throw new Error("--zoom must be a number between 1 and 10");
|
|
513
532
|
}
|
|
533
|
+
const verticalZoom = values["vertical-zoom"] === undefined
|
|
534
|
+
? (record.config?.vertical?.zoom ?? zoom)
|
|
535
|
+
: Number(values["vertical-zoom"]);
|
|
536
|
+
if (!Number.isFinite(verticalZoom) || verticalZoom < 1 || verticalZoom > 10) {
|
|
537
|
+
throw new Error("vertical.zoom / --vertical-zoom must be a number between 1 and 10");
|
|
538
|
+
}
|
|
514
539
|
const zoomDuration = values["zoom-duration"] === undefined
|
|
515
540
|
? (record.config?.zoomDuration ?? 0.35)
|
|
516
541
|
: (values["zoom-duration"].trim() === "" ? NaN : Number(values["zoom-duration"]));
|
|
@@ -526,7 +551,7 @@ export async function render(argv) {
|
|
|
526
551
|
console.warn("No CJK font found; Chinese captions may render as boxes.");
|
|
527
552
|
}
|
|
528
553
|
|
|
529
|
-
const layouts = [
|
|
554
|
+
const layouts = [landscapeLayout(videoW, videoH)];
|
|
530
555
|
if (values.vertical) layouts.push(verticalLayout(videoW, videoH));
|
|
531
556
|
|
|
532
557
|
let last = null;
|
|
@@ -541,7 +566,7 @@ export async function render(argv) {
|
|
|
541
566
|
videoH,
|
|
542
567
|
durationSec,
|
|
543
568
|
videoOffset,
|
|
544
|
-
zoom,
|
|
569
|
+
zoom: layout.key === "vertical" ? verticalZoom : zoom,
|
|
545
570
|
zoomDuration,
|
|
546
571
|
font,
|
|
547
572
|
cjkFont,
|