@phil65/demoreel 0.0.0-stage → 0.3.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/LICENSE +21 -0
- package/README.md +207 -2
- package/THIRD_PARTY_NOTICES.md +31 -0
- package/dist/args.d.ts +41 -0
- package/dist/args.js +252 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +468 -0
- package/dist/compose.d.ts +73 -0
- package/dist/compose.js +144 -0
- package/dist/env.d.ts +38 -0
- package/dist/env.js +182 -0
- package/dist/idle.d.ts +48 -0
- package/dist/idle.js +99 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +13 -0
- package/dist/init.d.ts +19 -0
- package/dist/init.js +92 -0
- package/dist/layout.d.ts +52 -0
- package/dist/layout.js +55 -0
- package/dist/load.d.ts +2 -0
- package/dist/load.js +76 -0
- package/dist/marks.d.ts +69 -0
- package/dist/marks.js +153 -0
- package/dist/motion.d.ts +15 -0
- package/dist/motion.js +49 -0
- package/dist/openscreen/project.js +793 -0
- package/dist/openscreen.d.ts +14 -0
- package/dist/openscreen.js +41 -0
- package/dist/project.d.ts +143 -0
- package/dist/project.js +144 -0
- package/dist/record.d.ts +90 -0
- package/dist/record.js +189 -0
- package/dist/recorder.d.ts +41 -0
- package/dist/recorder.js +149 -0
- package/dist/render.d.ts +58 -0
- package/dist/render.js +139 -0
- package/dist/renderer/assets/CanvasPool-CHSHS1-v.js +23 -0
- package/dist/renderer/assets/Cursor_App-Starting-zEGhqPJj.svg +8 -0
- package/dist/renderer/assets/Cursor_Cross-BuZZnB_U.svg +5 -0
- package/dist/renderer/assets/Cursor_Default-DkmrqhKh.svg +5 -0
- package/dist/renderer/assets/Cursor_Hand-(Grabbing)-B-Qy-RsV.svg +5 -0
- package/dist/renderer/assets/Cursor_Hand-(Open)-DGrW1tFF.svg +5 -0
- package/dist/renderer/assets/Cursor_Hand-(Pointing)-Byy2KbtA.svg +5 -0
- package/dist/renderer/assets/Cursor_Help-D5NcyFpT.svg +8 -0
- package/dist/renderer/assets/Cursor_Move-CerM5f-0.svg +5 -0
- package/dist/renderer/assets/Cursor_Not-Allowed-3rttFVa5.svg +7 -0
- package/dist/renderer/assets/Cursor_Resize-North-East-South-West-CBd4tbCA.svg +5 -0
- package/dist/renderer/assets/Cursor_Resize-North-South-DOxgUIwF.svg +5 -0
- package/dist/renderer/assets/Cursor_Resize-North-West-South-East-hzXJFJ2_.svg +5 -0
- package/dist/renderer/assets/Cursor_Resize-West-East-rDJgc6AZ.svg +5 -0
- package/dist/renderer/assets/Cursor_Text-Cursor-Cn9rFLjY.svg +5 -0
- package/dist/renderer/assets/Cursor_Up-Arrow-CYyEN-dA.svg +4 -0
- package/dist/renderer/assets/Cursor_Wait-CK8tq-9y.svg +6 -0
- package/dist/renderer/assets/RenderTargetSystem-EAUH9iQk.js +404 -0
- package/dist/renderer/assets/browserAll-aHn2isHo.js +14 -0
- package/dist/renderer/assets/canvasUtils-n5g2f3_X.js +1 -0
- package/dist/renderer/assets/getTexelRangeRects-yD6MQ0xy.js +195 -0
- package/dist/renderer/assets/getTextureBatchBindGroup-Bwvgbco6.js +1 -0
- package/dist/renderer/assets/gif.worker-CjkyQP34.js +3 -0
- package/dist/renderer/assets/index-BwP6rH7I.js +556 -0
- package/dist/renderer/assets/init-C2Za5NQh.js +83 -0
- package/dist/renderer/assets/webworkerAll-JSSmbaR2.js +1 -0
- package/dist/renderer/index.html +13 -0
- package/dist/renderer/wallpapers/wallpaper1.jpg +0 -0
- package/dist/renderer/wallpapers/wallpaper12.jpg +0 -0
- package/dist/renderer/wallpapers/wallpaper5.jpg +0 -0
- package/dist/renderer/wasm/web-demuxer.wasm +0 -0
- package/dist/scene.d.ts +203 -0
- package/dist/scene.js +634 -0
- package/dist/server.d.ts +12 -0
- package/dist/server.js +116 -0
- package/dist/sheet.d.ts +37 -0
- package/dist/sheet.js +98 -0
- package/dist/types.d.ts +103 -0
- package/dist/types.js +2 -0
- package/dist/zoom.d.ts +57 -0
- package/dist/zoom.js +178 -0
- package/examples/demo-app/index.html +99 -0
- package/examples/local-demo.ts +21 -0
- package/licenses/colord.txt +21 -0
- package/licenses/earcut.txt +15 -0
- package/licenses/eventemitter3.txt +21 -0
- package/licenses/gif.js.txt +1 -0
- package/licenses/ismobilejs.txt +21 -0
- package/licenses/mediabunny.txt +373 -0
- package/licenses/motion-dom.txt +21 -0
- package/licenses/motion-utils.txt +21 -0
- package/licenses/openscreen.txt +21 -0
- package/licenses/parse-svg-path.txt +23 -0
- package/licenses/pixi-filters.txt +21 -0
- package/licenses/pixi.js.txt +21 -0
- package/licenses/web-demuxer.txt +21 -0
- package/package.json +74 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Philipp Temminghoff
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,208 @@
|
|
|
1
|
-
#
|
|
1
|
+
# demoreel
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Scripted product demo videos ("videos as code"). Write a short Playwright scenario, and
|
|
4
|
+
demoreel records it in headless Chromium, adds a smooth cursor and automatic zoom onto
|
|
5
|
+
whatever you click or type into, and renders an MP4 with
|
|
6
|
+
[OpenScreen](https://github.com/siddharthvaddem/openscreen)'s own exporter. No screen
|
|
7
|
+
recorder, no editing timeline: change the script, run it again.
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
[MP4 (960px)](docs/assets/local-demo.mp4) · contact sheet with marks (made by
|
|
12
|
+
[framesheet](https://github.com/phil65/framesheet) from `marks.json`):
|
|
13
|
+
|
|
14
|
+

|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import { defineScenario } from "@phil65/demoreel";
|
|
18
|
+
|
|
19
|
+
export default defineScenario({
|
|
20
|
+
name: "add-task",
|
|
21
|
+
serve: "./demo-app", // or skip this and scene.goto("https://your.app")
|
|
22
|
+
viewport: { width: 1920, height: 1080 },
|
|
23
|
+
cssZoom: 1.5,
|
|
24
|
+
async run(scene, { baseUrl }) {
|
|
25
|
+
await scene.goto(`${baseUrl}/`);
|
|
26
|
+
await scene.caption("Add a task in seconds", { duration: 3000 });
|
|
27
|
+
await scene.type("#title", "Ship the demo video");
|
|
28
|
+
await scene.click("#add", { label: "add task" });
|
|
29
|
+
await scene.highlight("#count");
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npx demoreel run add-task.scenario.ts
|
|
36
|
+
# out/add-task/add-task.mp4, .openscreen project, timeline.json, marks.json, contact sheet
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Install
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm install -D @phil65/demoreel playwright
|
|
43
|
+
npx playwright install chromium # Linux CI: npx playwright install --with-deps chromium
|
|
44
|
+
# ffmpeg with libx264 on PATH (or DEMOREEL_FFMPEG=/path/to/ffmpeg):
|
|
45
|
+
sudo apt install ffmpeg # macOS: brew install ffmpeg
|
|
46
|
+
npx demoreel doctor # checks Chromium, ffmpeg, GPU, framesheet
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
- Node >= 20.11 or Bun. TypeScript scenarios run natively on Bun and Node >= 22.18
|
|
50
|
+
(type stripping; erasable syntax only). On older Node install `tsx` or `jiti` next to
|
|
51
|
+
the scenario (demoreel picks them up) or write the scenario as `.mjs`. In a package
|
|
52
|
+
without `"type": "module"`, name TypeScript scenarios `*.mts`.
|
|
53
|
+
- `playwright` (or `playwright-core`) is a peer dependency; demoreel uses its Chromium.
|
|
54
|
+
- **GPU recommended.** Rendering runs OpenScreen's WebGL (Pixi) + WebCodecs pipeline in
|
|
55
|
+
headless Chromium. demoreel probes for a hardware GL backend (Vulkan / GL on Linux, Metal
|
|
56
|
+
on macOS, D3D11 on Windows) and falls back to SwiftShader with a warning. Rough numbers
|
|
57
|
+
for a 17 s demo: 1080p30 (default) about 77 s on an integrated AMD GPU, 1080p60 about 130 s, 720p30 about 35 s; software
|
|
58
|
+
rendering is 10-20x slower (fine for 640x360 drafts and CI, slow for 1080p).
|
|
59
|
+
|
|
60
|
+
## CLI
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
demoreel run <scenario.ts|js> record, write project, render MP4, contact sheet
|
|
64
|
+
--out DIR --no-render --dry-run --state FILE --fps 30 --quality medium|good|source
|
|
65
|
+
--[no-]gpu --trim-idle --speed 1.5 --viewport 1280x720 --headed -n 12 --framesheet auto|off
|
|
66
|
+
demoreel inspect <url|scenario> ARIA snapshot (+ optional --screenshot) of a page or scenario end state
|
|
67
|
+
--screenshot FILE --state FILE --viewport 1280x800 --headed
|
|
68
|
+
demoreel login <url> sign in in headed Chromium and save storageState (default .demoreel/auth.json)
|
|
69
|
+
--state FILE --viewport 1280x800
|
|
70
|
+
demoreel render <project.openscreen> [--out FILE.mp4 --fps --quality --[no-]gpu]
|
|
71
|
+
demoreel rezoom <outdir> re-derive zooms / idle cuts / marks from timeline.json
|
|
72
|
+
--max-depth 4 --lead 350 --hold 800 --no-auto-zoom --options JSON
|
|
73
|
+
--trim-idle --idle-options '{"minMs":1500,"keepMs":600,"mode":"speed"}' --render
|
|
74
|
+
demoreel validate <project> OpenScreen's validateProjectData / normalizeProjectEditor
|
|
75
|
+
demoreel sheet <video|outdir> framesheet inspect --marks marks.json, else ffmpeg tiles
|
|
76
|
+
demoreel init [dir] [--url URL] [--js] scaffold a scenario (+ a demo app to record)
|
|
77
|
+
demoreel doctor environment check
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Each run writes into `out/<name>/`:
|
|
81
|
+
|
|
82
|
+
| file | what |
|
|
83
|
+
| --- | --- |
|
|
84
|
+
| `<name>.mp4` | the rendered video |
|
|
85
|
+
| `<name>.openscreen` | OpenScreen v2 project: open it in the OpenScreen app to tweak by hand, then `demoreel render` |
|
|
86
|
+
| `recording.mp4` + `.cursor.json` | raw CFR recording and cursor telemetry (OpenScreen's sidecar format) |
|
|
87
|
+
| `timeline.json` | what happened when: actions with target boxes, zoom / trim regions, captions, timings |
|
|
88
|
+
| `marks.json` | the same in [framesheet's marks format](https://github.com/phil65/framesheet/blob/main/schema/marks.schema.json), in rendered-video coordinates |
|
|
89
|
+
| `framesheet/` or `<name>.sheet.png` | contact sheet for review |
|
|
90
|
+
|
|
91
|
+
## Scene API
|
|
92
|
+
|
|
93
|
+
| method | does |
|
|
94
|
+
| --- | --- |
|
|
95
|
+
| `goto(url)` | navigate (the first call starts the recording) |
|
|
96
|
+
| `click(target, { zoom, label, navigates })` | eased cursor travel, aim, click; zooms by default |
|
|
97
|
+
| `type(target, text, { clear, zoom })` | click into a field and type with human-ish timing |
|
|
98
|
+
| `hover(target, { dwell, zoom })` | move there and rest (no zoom unless asked) |
|
|
99
|
+
| `moveTo(target \| {x, y})` | move the cursor, nothing else |
|
|
100
|
+
| `scroll(target \| { by: px })` | smooth scroll (the page's or the target's scroll container) |
|
|
101
|
+
| `press(key)` | keyboard shortcut, Playwright syntax |
|
|
102
|
+
| `pause(ms)` | wait |
|
|
103
|
+
| `caption(text, { duration, wait })` | caption overlay (an OpenScreen text annotation, sharp at any zoom) |
|
|
104
|
+
| `zoom(target, { depth, duration, context, wait })` | explicit zoom that overrides automatic ones in its window |
|
|
105
|
+
| `highlight(target, { duration, color, zoom })` | outline drawn into the page around an element |
|
|
106
|
+
|
|
107
|
+
`target` is a structured accessibility-first spec (`{ role, name?, exact?, nth? }`,
|
|
108
|
+
`{ label, exact?, nth? }`, `{ placeholder, exact?, nth? }`, `{ text, exact?, nth? }`,
|
|
109
|
+
`{ testId, nth? }`, `{ css, nth? }`), a CSS / Playwright selector string, or a `Locator` — e.g.
|
|
110
|
+
`scene.click({ role: "button", name: "Save" })`. The first visible match (or `nth` visible match
|
|
111
|
+
when given) is used and scrolled into view if needed; structured targets also produce readable
|
|
112
|
+
default labels in `timeline.json` and `marks.json`. `scene.page` is the raw Playwright page.
|
|
113
|
+
|
|
114
|
+
Scenario options: `viewport`, `cssZoom` (crisper text: lay out at a smaller size and scale
|
|
115
|
+
up), `serve` (static dir served at `ctx.baseUrl`), `storageState` (Playwright storageState
|
|
116
|
+
JSON, relative to the scenario file), `colorScheme`, `seed`, `pacing`
|
|
117
|
+
(`speed`, `beforeAction`, `afterClick`, `typeDelay`, ...), `zoom` (see below), `look`
|
|
118
|
+
(`wallpaper`, `padding`, `borderRadius`, `shadowIntensity`, `aspectRatio`,
|
|
119
|
+
`captionPosition`), `trimIdle`.
|
|
120
|
+
|
|
121
|
+
Library: `recordScenario`, `dryRunScenario`, `resolveStorageState`, `deriveZoomRegions`,
|
|
122
|
+
`deriveIdleRegions`, `buildProject`, `buildCursorData`, `buildMarks`, `renderProject`,
|
|
123
|
+
`validateProject`, `rezoom`, `reviewSheet`, all typed (`dist/index.d.ts`).
|
|
124
|
+
|
|
125
|
+
### Inspect before you script
|
|
126
|
+
|
|
127
|
+
Before recording, inspect a URL to see its ARIA tree (and optionally save a PNG) so you can
|
|
128
|
+
pick exact role/name or text targets without guessing:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
npx demoreel inspect https://your.app --screenshot page.png
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Then validate a scenario with a fast dry run (no sleeps, no cursor animation, no ffmpeg, no
|
|
135
|
+
output files):
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
npx demoreel inspect demo.scenario.ts --screenshot end.png # dry-run + end-state ARIA snapshot
|
|
139
|
+
npx demoreel run demo.scenario.ts --dry-run # dry-run with per-action summary
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
If a step fails, `demoreel inspect` reports which action failed and still prints the ARIA
|
|
143
|
+
snapshot (and writes `--screenshot`) at the moment of failure.
|
|
144
|
+
|
|
145
|
+
### Logged-in apps
|
|
146
|
+
|
|
147
|
+
Save a Playwright `storageState` once in a headed browser, then reuse it across inspections
|
|
148
|
+
and recordings:
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
npx demoreel login https://your.app # saves .demoreel/auth.json
|
|
152
|
+
npx demoreel inspect https://your.app --state .demoreel/auth.json
|
|
153
|
+
npx demoreel run demo.scenario.ts --state .demoreel/auth.json
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Or set `storageState: ".demoreel/auth.json"` in `defineScenario({ ... })` (resolved relative
|
|
157
|
+
to the scenario file; `--state` overrides it relative to cwd). Add `.demoreel/` to
|
|
158
|
+
`.gitignore` — it holds session cookies.
|
|
159
|
+
|
|
160
|
+
## How cursor and zoom are derived
|
|
161
|
+
|
|
162
|
+
- **Cursor**: every Scene action moves the real mouse along an eased, slightly arced Bezier
|
|
163
|
+
path (duration from Fitts' law, seeded jitter, so re-runs look the same). Positions are
|
|
164
|
+
sampled at ~60 Hz on the recording clock (CDP screencast frame timestamps) with cursor type
|
|
165
|
+
(arrow / pointer / text from the element's CSS) and click events, and written as OpenScreen
|
|
166
|
+
cursor telemetry. OpenScreen draws the cursor in the export (smoothing, click bounce,
|
|
167
|
+
motion blur), so it stays sharp under zoom.
|
|
168
|
+
- **Zoom**: each click / type (and hover with `zoom: true`) records the target's bounding box.
|
|
169
|
+
The depth is the deepest of OpenScreen's six levels (1.25x to 5x) at which the box still
|
|
170
|
+
fits 80% of the view width and 50% of its height (capped by `zoom.maxDepth`, default 3).
|
|
171
|
+
Regions start `leadMs` before the cursor arrives (OpenScreen eases in over ~1.5 s), hold
|
|
172
|
+
`holdMs` after the action, merge with the next action when the union still zooms, and
|
|
173
|
+
otherwise chain so OpenScreen pans instead of zooming out and in. Scrolls and navigation end
|
|
174
|
+
a zoom. The focus is converted to OpenScreen's stage coordinates (padding included) and
|
|
175
|
+
clamped so a zoomed view never shows wallpaper.
|
|
176
|
+
- **Anchors**: put `data-demoreel-zoom` on a container to zoom onto the container whenever an
|
|
177
|
+
action targets something inside it (`="2"` forces depth 2, `="off"` disables zoom there).
|
|
178
|
+
- **Trim idle** (`trimIdle: true` or `--trim-idle`): stretches with no action, cursor motion,
|
|
179
|
+
caption, zoom transition or visual change are cut to `keepMs` with OpenScreen trim regions
|
|
180
|
+
(or sped up with `mode: "speed"`). `timeline.json` keeps recording times; `marks.json`
|
|
181
|
+
uses output times.
|
|
182
|
+
- **Captions** sit at the bottom unless that would cover a target active at the time; then
|
|
183
|
+
they move to the top (`look.captionPosition: "auto"`, or force `"top"` / `"bottom"`).
|
|
184
|
+
|
|
185
|
+
## Agent loop
|
|
186
|
+
|
|
187
|
+
`timeline.json` + `marks.json` make the output checkable without watching the video:
|
|
188
|
+
`demoreel sheet out/<name>` runs `framesheet inspect <video> --marks marks.json` (framesheet
|
|
189
|
+
on PATH, in `node_modules`, or via `uvx framesheet`) which draws clicks, targets, zooms and
|
|
190
|
+
captions onto the tiles and flags e.g. captions covering a target. Iterate with
|
|
191
|
+
`demoreel rezoom` (no re-recording) and `demoreel render`. A Claude Code skill for this loop
|
|
192
|
+
is in [docs/skill.md](docs/skill.md).
|
|
193
|
+
|
|
194
|
+
## Limitations
|
|
195
|
+
|
|
196
|
+
- **No HiDPI capture**: Chromium's screencast delivers frames in CSS pixels and ignores
|
|
197
|
+
`deviceScaleFactor`. Use `cssZoom` (pages you control) or a larger viewport for crisp text.
|
|
198
|
+
- **Real-time recording**: a scenario takes as long as the video (plus encode and render).
|
|
199
|
+
- **GPU recommended** for rendering (see above).
|
|
200
|
+
- On Linux the OpenScreen GUI's preview does not show the cursor overlay for imported projects;
|
|
201
|
+
the export (and demoreel's render) does.
|
|
202
|
+
- Audio, webcam overlays and multi-tab recordings are not supported.
|
|
203
|
+
|
|
204
|
+
## License
|
|
205
|
+
|
|
206
|
+
MIT. The prebuilt renderer bundles unmodified [OpenScreen](https://github.com/siddharthvaddem/openscreen)
|
|
207
|
+
code (MIT) and npm packages listed in [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md)
|
|
208
|
+
(licence texts in `licenses/`).
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
demoreel's prebuilt renderer (`dist/renderer/`) and `dist/openscreen/project.js` are bundled
|
|
4
|
+
from third-party code. Generated by `scripts/build-renderer.ts`.
|
|
5
|
+
|
|
6
|
+
## OpenScreen
|
|
7
|
+
|
|
8
|
+
Unmodified source files from [OpenScreen](https://github.com/siddharthvaddem/openscreen)
|
|
9
|
+
(commit `ca8104c279da0d4b4481ec992ff103949e22c772`, MIT License, Copyright (c) 2025 Siddharth Vaddem), including its
|
|
10
|
+
cursor and wallpaper assets: [licenses/openscreen.txt](licenses/openscreen.txt). The exact files
|
|
11
|
+
are listed in `vendor/openscreen/VENDORED.md` in the demoreel repository.
|
|
12
|
+
|
|
13
|
+
## npm packages bundled into dist/
|
|
14
|
+
|
|
15
|
+
| package | version | license | text | source |
|
|
16
|
+
| --- | --- | --- | --- | --- |
|
|
17
|
+
| colord | 2.14.0 | MIT | [licenses/colord.txt](licenses/colord.txt) | https://github.com/omgovich/colord |
|
|
18
|
+
| earcut | 3.2.4 | ISC | [licenses/earcut.txt](licenses/earcut.txt) | git://github.com/mapbox/earcut |
|
|
19
|
+
| eventemitter3 | 5.0.4 | MIT | [licenses/eventemitter3.txt](licenses/eventemitter3.txt) | git://github.com/primus/eventemitter3 |
|
|
20
|
+
| gif.js | 0.2.0 | MIT | [licenses/gif.js.txt](licenses/gif.js.txt) | https://github.com/jnordberg/gif.js |
|
|
21
|
+
| ismobilejs | 1.1.1 | MIT | [licenses/ismobilejs.txt](licenses/ismobilejs.txt) | https://github.com/kaimallea/isMobile |
|
|
22
|
+
| mediabunny | 1.66.2 | MPL-2.0 | [licenses/mediabunny.txt](licenses/mediabunny.txt) | https://github.com/Vanilagy/mediabunny |
|
|
23
|
+
| motion-dom | 12.43.0 | MIT | [licenses/motion-dom.txt](licenses/motion-dom.txt) | https://github.com/motiondivision/motion |
|
|
24
|
+
| motion-utils | 12.39.0 | MIT | [licenses/motion-utils.txt](licenses/motion-utils.txt) | https://github.com/motiondivision/motion |
|
|
25
|
+
| parse-svg-path | 0.2.0 | MIT | [licenses/parse-svg-path.txt](licenses/parse-svg-path.txt) | git://github.com/jkroso/parse-svg-path |
|
|
26
|
+
| pixi-filters | 6.1.5 | MIT | [licenses/pixi-filters.txt](licenses/pixi-filters.txt) | https://github.com/pixijs/filters |
|
|
27
|
+
| pixi.js | 8.23.0 | MIT | [licenses/pixi.js.txt](licenses/pixi.js.txt) | https://github.com/pixijs/pixijs |
|
|
28
|
+
| web-demuxer | 4.0.0 | MIT | [licenses/web-demuxer.txt](licenses/web-demuxer.txt) | https://github.com/ForeverSc/web-demuxer |
|
|
29
|
+
|
|
30
|
+
MPL-2.0 code (mediabunny) is included unmodified; its source is available from the
|
|
31
|
+
repository linked above and from the npm package of the listed version.
|
package/dist/args.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** CLI argument parsing (no dependencies; Node 20 compatible). */
|
|
2
|
+
export type FlagType = "boolean" | "string" | "number";
|
|
3
|
+
export interface FlagSpec {
|
|
4
|
+
type: FlagType;
|
|
5
|
+
alias?: string;
|
|
6
|
+
description: string;
|
|
7
|
+
/** Shown in help, e.g. "DIR". */
|
|
8
|
+
value?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface CommandSpec {
|
|
11
|
+
usage: string;
|
|
12
|
+
description: string;
|
|
13
|
+
/** Required positional count. */
|
|
14
|
+
positionals: {
|
|
15
|
+
min: number;
|
|
16
|
+
max: number;
|
|
17
|
+
};
|
|
18
|
+
flags: Record<string, FlagSpec>;
|
|
19
|
+
}
|
|
20
|
+
export declare const COMMANDS: Record<string, CommandSpec>;
|
|
21
|
+
export type FlagValue = string | number | boolean;
|
|
22
|
+
export interface ParsedArgs {
|
|
23
|
+
command: string | null;
|
|
24
|
+
positionals: string[];
|
|
25
|
+
flags: Record<string, FlagValue>;
|
|
26
|
+
help: boolean;
|
|
27
|
+
version: boolean;
|
|
28
|
+
}
|
|
29
|
+
export declare class UsageError extends Error {
|
|
30
|
+
constructor(message: string);
|
|
31
|
+
}
|
|
32
|
+
export declare function parseArgs(argv: string[]): ParsedArgs;
|
|
33
|
+
/** "1280x720" -> { width, height }. */
|
|
34
|
+
export declare function parseSize(s: string): {
|
|
35
|
+
width: number;
|
|
36
|
+
height: number;
|
|
37
|
+
};
|
|
38
|
+
/** Tri-state GPU flag: true / false / "auto" when absent. */
|
|
39
|
+
export declare function gpuMode(flags: Record<string, FlagValue>): boolean | "auto";
|
|
40
|
+
export declare function parseJsonFlag(name: string, raw: FlagValue | undefined): Record<string, unknown>;
|
|
41
|
+
export declare function helpText(command?: string | null): string;
|
package/dist/args.js
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
/** CLI argument parsing (no dependencies; Node 20 compatible). */
|
|
2
|
+
const gpu = { type: "boolean", description: "force GPU on/off (default: auto-detect, fall back to software)" };
|
|
3
|
+
const fps = { type: "number", value: "N", description: "output frame rate (default 30)" };
|
|
4
|
+
const quality = { type: "string", value: "Q", description: "medium (720p) | good (1080p, default) | source" };
|
|
5
|
+
const verbose = { type: "boolean", alias: "v", description: "print browser console output" };
|
|
6
|
+
const frames = { type: "number", alias: "n", value: "N", description: "contact sheet tiles (default 12)" };
|
|
7
|
+
const framesheet = { type: "string", value: "MODE", description: "auto (default: use framesheet if found) | off" };
|
|
8
|
+
const trimIdle = { type: "boolean", description: "cut idle stretches (OpenScreen trim regions)" };
|
|
9
|
+
export const COMMANDS = {
|
|
10
|
+
run: {
|
|
11
|
+
usage: "run <scenario.ts|js>",
|
|
12
|
+
description: "record a scenario, write the OpenScreen project, render the MP4 and a contact sheet",
|
|
13
|
+
positionals: { min: 1, max: 1 },
|
|
14
|
+
flags: {
|
|
15
|
+
out: { type: "string", alias: "o", value: "DIR", description: "output directory (default out/<name>)" },
|
|
16
|
+
render: { type: "boolean", description: "render the MP4 (default; --no-render to only record)" },
|
|
17
|
+
sheet: { type: "boolean", description: "write a contact sheet after rendering (default)" },
|
|
18
|
+
gpu,
|
|
19
|
+
fps,
|
|
20
|
+
quality,
|
|
21
|
+
"trim-idle": trimIdle,
|
|
22
|
+
speed: { type: "number", value: "X", description: "pacing speed multiplier (2 = twice as fast)" },
|
|
23
|
+
viewport: { type: "string", value: "WxH", description: "override the scenario viewport, e.g. 1280x720" },
|
|
24
|
+
state: { type: "string", value: "FILE", description: "Playwright storageState JSON (overrides scenario.storageState)" },
|
|
25
|
+
"dry-run": { type: "boolean", description: "run the scenario fast without ffmpeg, recording, or writing files" },
|
|
26
|
+
headed: { type: "boolean", description: "show the browser while recording" },
|
|
27
|
+
frames,
|
|
28
|
+
framesheet,
|
|
29
|
+
verbose,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
render: {
|
|
33
|
+
usage: "render <project.openscreen>",
|
|
34
|
+
description: "render an OpenScreen project to MP4 with OpenScreen's exporter (headless)",
|
|
35
|
+
positionals: { min: 1, max: 1 },
|
|
36
|
+
flags: {
|
|
37
|
+
out: { type: "string", alias: "o", value: "FILE", description: "output MP4 (default: next to the project)" },
|
|
38
|
+
gpu,
|
|
39
|
+
fps,
|
|
40
|
+
quality,
|
|
41
|
+
verbose,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
rezoom: {
|
|
45
|
+
usage: "rezoom <outdir>",
|
|
46
|
+
description: "re-derive zoom / idle regions, project and marks from timeline.json (no re-recording)",
|
|
47
|
+
positionals: { min: 1, max: 1 },
|
|
48
|
+
flags: {
|
|
49
|
+
options: { type: "string", value: "JSON", description: 'zoom options, e.g. \'{"maxDepth":4,"holdMs":1200}\'' },
|
|
50
|
+
"max-depth": { type: "number", value: "D", description: "deepest automatic zoom (1-6)" },
|
|
51
|
+
lead: { type: "number", value: "MS", description: "zoom-in lead before the cursor arrives" },
|
|
52
|
+
hold: { type: "number", value: "MS", description: "stay zoomed after an action" },
|
|
53
|
+
"auto-zoom": { type: "boolean", description: "automatic zooms (--no-auto-zoom: only scene.zoom())" },
|
|
54
|
+
"trim-idle": trimIdle,
|
|
55
|
+
"idle-options": { type: "string", value: "JSON", description: 'e.g. \'{"minMs":1500,"keepMs":800,"mode":"speed"}\'' },
|
|
56
|
+
render: { type: "boolean", description: "render the MP4 afterwards" },
|
|
57
|
+
gpu,
|
|
58
|
+
fps,
|
|
59
|
+
quality,
|
|
60
|
+
verbose,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
validate: {
|
|
64
|
+
usage: "validate <project.openscreen>",
|
|
65
|
+
description: "run OpenScreen's validateProjectData / normalizeProjectEditor on a project",
|
|
66
|
+
positionals: { min: 1, max: 1 },
|
|
67
|
+
flags: { json: { type: "boolean", description: "print the full result as JSON" } },
|
|
68
|
+
},
|
|
69
|
+
sheet: {
|
|
70
|
+
usage: "sheet <video.mp4|outdir>",
|
|
71
|
+
description: "contact sheet via framesheet (with marks.json) or ffmpeg",
|
|
72
|
+
positionals: { min: 1, max: 1 },
|
|
73
|
+
flags: {
|
|
74
|
+
out: { type: "string", alias: "o", value: "DIR", description: "output directory (default: next to the video)" },
|
|
75
|
+
marks: { type: "string", value: "FILE", description: "framesheet marks (default: marks.json next to the video)" },
|
|
76
|
+
frames,
|
|
77
|
+
framesheet,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
inspect: {
|
|
81
|
+
usage: "inspect <url|scenario.ts|js>",
|
|
82
|
+
description: "print a page's ARIA snapshot (or dry-run a scenario and inspect its end state)",
|
|
83
|
+
positionals: { min: 1, max: 1 },
|
|
84
|
+
flags: {
|
|
85
|
+
screenshot: { type: "string", value: "FILE", description: "also write a PNG screenshot of the page" },
|
|
86
|
+
state: { type: "string", value: "FILE", description: "Playwright storageState JSON (from `demoreel login`)" },
|
|
87
|
+
viewport: { type: "string", value: "WxH", description: "viewport (default 1280x800 for URLs, scenario viewport otherwise)" },
|
|
88
|
+
headed: { type: "boolean", description: "show the browser while inspecting" },
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
login: {
|
|
92
|
+
usage: "login <url>",
|
|
93
|
+
description: "open a headed browser to sign in and save cookies/storageState for scenarios",
|
|
94
|
+
positionals: { min: 1, max: 1 },
|
|
95
|
+
flags: {
|
|
96
|
+
state: { type: "string", value: "FILE", description: "output storageState path (default .demoreel/auth.json)" },
|
|
97
|
+
viewport: { type: "string", value: "WxH", description: "browser viewport (default 1280x800)" },
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
init: {
|
|
101
|
+
usage: "init [dir]",
|
|
102
|
+
description: "scaffold an example scenario (and a copy of the demo app)",
|
|
103
|
+
positionals: { min: 0, max: 1 },
|
|
104
|
+
flags: {
|
|
105
|
+
name: { type: "string", value: "NAME", description: 'scenario name (default "demo")' },
|
|
106
|
+
url: { type: "string", value: "URL", description: "record this URL instead of the bundled demo app" },
|
|
107
|
+
js: { type: "boolean", description: "write a .mjs scenario instead of .ts" },
|
|
108
|
+
force: { type: "boolean", description: "overwrite existing files" },
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
doctor: {
|
|
112
|
+
usage: "doctor",
|
|
113
|
+
description: "check Chromium, ffmpeg, GPU and framesheet",
|
|
114
|
+
positionals: { min: 0, max: 0 },
|
|
115
|
+
flags: {},
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
export class UsageError extends Error {
|
|
119
|
+
constructor(message) {
|
|
120
|
+
super(message);
|
|
121
|
+
this.name = "UsageError";
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
export function parseArgs(argv) {
|
|
125
|
+
const res = { command: null, positionals: [], flags: {}, help: false, version: false };
|
|
126
|
+
let i = 0;
|
|
127
|
+
while (i < argv.length && argv[i].startsWith("-")) {
|
|
128
|
+
const a = argv[i++];
|
|
129
|
+
if (a === "--help" || a === "-h")
|
|
130
|
+
res.help = true;
|
|
131
|
+
else if (a === "--version" || a === "-V")
|
|
132
|
+
res.version = true;
|
|
133
|
+
else
|
|
134
|
+
throw new UsageError(`unknown option ${a}`);
|
|
135
|
+
}
|
|
136
|
+
if (i >= argv.length)
|
|
137
|
+
return res;
|
|
138
|
+
const command = argv[i++];
|
|
139
|
+
const spec = COMMANDS[command];
|
|
140
|
+
if (!spec)
|
|
141
|
+
throw new UsageError(`unknown command "${command}" (try --help)`);
|
|
142
|
+
res.command = command;
|
|
143
|
+
const aliases = new Map(Object.entries(spec.flags).flatMap(([k, f]) => (f.alias ? [[f.alias, k]] : [])));
|
|
144
|
+
let onlyPositionals = false;
|
|
145
|
+
for (; i < argv.length; i++) {
|
|
146
|
+
const a = argv[i];
|
|
147
|
+
if (onlyPositionals || !a.startsWith("-") || a === "-") {
|
|
148
|
+
res.positionals.push(a);
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
if (a === "--") {
|
|
152
|
+
onlyPositionals = true;
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
if (a === "--help" || a === "-h") {
|
|
156
|
+
res.help = true;
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
let name;
|
|
160
|
+
let inline;
|
|
161
|
+
if (a.startsWith("--")) {
|
|
162
|
+
const eq = a.indexOf("=");
|
|
163
|
+
name = eq > 0 ? a.slice(2, eq) : a.slice(2);
|
|
164
|
+
inline = eq > 0 ? a.slice(eq + 1) : undefined;
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
const alias = aliases.get(a.slice(1));
|
|
168
|
+
if (!alias)
|
|
169
|
+
throw new UsageError(`unknown option ${a} for "${command}"`);
|
|
170
|
+
name = alias;
|
|
171
|
+
}
|
|
172
|
+
let negated = false;
|
|
173
|
+
if (!spec.flags[name] && name.startsWith("no-") && spec.flags[name.slice(3)]?.type === "boolean") {
|
|
174
|
+
name = name.slice(3);
|
|
175
|
+
negated = true;
|
|
176
|
+
}
|
|
177
|
+
const f = spec.flags[name];
|
|
178
|
+
if (!f)
|
|
179
|
+
throw new UsageError(`unknown option --${name} for "${command}"`);
|
|
180
|
+
if (f.type === "boolean") {
|
|
181
|
+
if (inline !== undefined) {
|
|
182
|
+
if (!/^(true|false|1|0)$/.test(inline))
|
|
183
|
+
throw new UsageError(`--${name} expects true/false`);
|
|
184
|
+
res.flags[name] = /^(true|1)$/.test(inline) !== negated;
|
|
185
|
+
}
|
|
186
|
+
else
|
|
187
|
+
res.flags[name] = !negated;
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
if (negated)
|
|
191
|
+
throw new UsageError(`--no-${name} is not valid`);
|
|
192
|
+
const raw = inline ?? argv[++i];
|
|
193
|
+
if (raw === undefined)
|
|
194
|
+
throw new UsageError(`--${name} needs a value`);
|
|
195
|
+
if (f.type === "number") {
|
|
196
|
+
const n = Number(raw);
|
|
197
|
+
if (!Number.isFinite(n))
|
|
198
|
+
throw new UsageError(`--${name} expects a number, got "${raw}"`);
|
|
199
|
+
res.flags[name] = n;
|
|
200
|
+
}
|
|
201
|
+
else
|
|
202
|
+
res.flags[name] = raw;
|
|
203
|
+
}
|
|
204
|
+
if (!res.help) {
|
|
205
|
+
const { min, max } = spec.positionals;
|
|
206
|
+
if (res.positionals.length < min)
|
|
207
|
+
throw new UsageError(`usage: demoreel ${spec.usage}`);
|
|
208
|
+
if (res.positionals.length > max)
|
|
209
|
+
throw new UsageError(`too many arguments; usage: demoreel ${spec.usage}`);
|
|
210
|
+
}
|
|
211
|
+
return res;
|
|
212
|
+
}
|
|
213
|
+
/** "1280x720" -> { width, height }. */
|
|
214
|
+
export function parseSize(s) {
|
|
215
|
+
const m = /^(\d+)\s*[x:*]\s*(\d+)$/i.exec(s.trim());
|
|
216
|
+
if (!m)
|
|
217
|
+
throw new UsageError(`expected WxH like 1280x720, got "${s}"`);
|
|
218
|
+
return { width: Number(m[1]), height: Number(m[2]) };
|
|
219
|
+
}
|
|
220
|
+
/** Tri-state GPU flag: true / false / "auto" when absent. */
|
|
221
|
+
export function gpuMode(flags) {
|
|
222
|
+
return flags.gpu === undefined ? "auto" : Boolean(flags.gpu);
|
|
223
|
+
}
|
|
224
|
+
export function parseJsonFlag(name, raw) {
|
|
225
|
+
if (raw === undefined)
|
|
226
|
+
return {};
|
|
227
|
+
try {
|
|
228
|
+
const v = JSON.parse(String(raw));
|
|
229
|
+
if (!v || typeof v !== "object" || Array.isArray(v))
|
|
230
|
+
throw new Error("not an object");
|
|
231
|
+
return v;
|
|
232
|
+
}
|
|
233
|
+
catch (e) {
|
|
234
|
+
throw new UsageError(`--${name} expects a JSON object: ${e.message}`);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
export function helpText(command) {
|
|
238
|
+
const fmtFlags = (flags) => Object.entries(flags)
|
|
239
|
+
.map(([k, f]) => {
|
|
240
|
+
const left = `${f.alias ? `-${f.alias}, ` : " "}--${f.type === "boolean" ? `[no-]${k}` : k}${f.value ? ` ${f.value}` : ""}`;
|
|
241
|
+
return ` ${left.padEnd(30)} ${f.description}`;
|
|
242
|
+
})
|
|
243
|
+
.join("\n");
|
|
244
|
+
if (command && COMMANDS[command]) {
|
|
245
|
+
const c = COMMANDS[command];
|
|
246
|
+
return `demoreel ${c.usage}\n\n${c.description}\n${Object.keys(c.flags).length ? `\noptions:\n${fmtFlags(c.flags)}\n` : ""}`;
|
|
247
|
+
}
|
|
248
|
+
const list = Object.values(COMMANDS)
|
|
249
|
+
.map((c) => ` ${c.usage.padEnd(32)} ${c.description}`)
|
|
250
|
+
.join("\n");
|
|
251
|
+
return `demoreel: scripted product demo videos (auto cursor + auto zoom, rendered by OpenScreen)\n\nusage: demoreel <command> [options]\n\ncommands:\n${list}\n\nrun \`demoreel <command> --help\` for options.\n`;
|
|
252
|
+
}
|
package/dist/cli.d.ts
ADDED