webreel 0.0.0 → 0.1.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.
Files changed (60) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +191 -1
  3. package/dist/commands/__tests__/record.test.d.ts +2 -0
  4. package/dist/commands/__tests__/record.test.d.ts.map +1 -0
  5. package/dist/commands/__tests__/record.test.js +89 -0
  6. package/dist/commands/__tests__/record.test.js.map +1 -0
  7. package/dist/commands/composite.d.ts +3 -0
  8. package/dist/commands/composite.d.ts.map +1 -0
  9. package/dist/commands/composite.js +40 -0
  10. package/dist/commands/composite.js.map +1 -0
  11. package/dist/commands/init.d.ts +3 -0
  12. package/dist/commands/init.d.ts.map +1 -0
  13. package/dist/commands/init.js +50 -0
  14. package/dist/commands/init.js.map +1 -0
  15. package/dist/commands/preview.d.ts +3 -0
  16. package/dist/commands/preview.d.ts.map +1 -0
  17. package/dist/commands/preview.js +30 -0
  18. package/dist/commands/preview.js.map +1 -0
  19. package/dist/commands/record.d.ts +5 -0
  20. package/dist/commands/record.d.ts.map +1 -0
  21. package/dist/commands/record.js +147 -0
  22. package/dist/commands/record.js.map +1 -0
  23. package/dist/commands/validate.d.ts +3 -0
  24. package/dist/commands/validate.d.ts.map +1 -0
  25. package/dist/commands/validate.js +43 -0
  26. package/dist/commands/validate.js.map +1 -0
  27. package/dist/config.d.ts +20 -0
  28. package/dist/config.d.ts.map +1 -0
  29. package/dist/config.js +5 -0
  30. package/dist/config.js.map +1 -0
  31. package/dist/index.d.ts +3 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +34 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/lib/__tests__/config.test.d.ts +2 -0
  36. package/dist/lib/__tests__/config.test.d.ts.map +1 -0
  37. package/dist/lib/__tests__/config.test.js +581 -0
  38. package/dist/lib/__tests__/config.test.js.map +1 -0
  39. package/dist/lib/__tests__/examples.test.d.ts +2 -0
  40. package/dist/lib/__tests__/examples.test.d.ts.map +1 -0
  41. package/dist/lib/__tests__/examples.test.js +19 -0
  42. package/dist/lib/__tests__/examples.test.js.map +1 -0
  43. package/dist/lib/__tests__/runner.test.d.ts +2 -0
  44. package/dist/lib/__tests__/runner.test.d.ts.map +1 -0
  45. package/dist/lib/__tests__/runner.test.js +141 -0
  46. package/dist/lib/__tests__/runner.test.js.map +1 -0
  47. package/dist/lib/config.d.ts +17 -0
  48. package/dist/lib/config.d.ts.map +1 -0
  49. package/dist/lib/config.js +974 -0
  50. package/dist/lib/config.js.map +1 -0
  51. package/dist/lib/runner.d.ts +18 -0
  52. package/dist/lib/runner.d.ts.map +1 -0
  53. package/dist/lib/runner.js +387 -0
  54. package/dist/lib/runner.js.map +1 -0
  55. package/dist/lib/types.d.ts +173 -0
  56. package/dist/lib/types.d.ts.map +1 -0
  57. package/dist/lib/types.js +16 -0
  58. package/dist/lib/types.js.map +1 -0
  59. package/package.json +53 -6
  60. package/index.js +0 -2
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2025 Vercel Inc.
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,193 @@
1
1
  # webreel
2
2
 
3
- Coming soon.
3
+ CLI that records scripted browser videos as MP4, GIF, or WebM files from JSON configs.
4
+
5
+ Define steps (clicks, key presses, drags, pauses) and webreel drives a headless Chrome instance, captures screenshots at ~60fps, adds cursor animation, keystroke overlays, and sound effects, and encodes the result with ffmpeg.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install webreel
11
+ ```
12
+
13
+ ## Quick Start
14
+
15
+ ```bash
16
+ npx webreel init --name my-video --url https://example.com
17
+ npx webreel record
18
+ ```
19
+
20
+ ## Examples
21
+
22
+ <!-- EXAMPLES:START -->
23
+
24
+ **[custom-theme](../../examples/custom-theme)** - Demonstrates fully customizing the cursor overlay and keystroke HUD appearance using a code editor page.
25
+
26
+ <video src="../../examples/custom-theme/videos/custom-theme.mp4" controls muted width="100%"></video>
27
+
28
+ **[drag-and-drop](../../examples/drag-and-drop)** - Demonstrates dragging elements between positions on a kanban board.
29
+
30
+ <video src="../../examples/drag-and-drop/videos/drag-and-drop.mp4" controls muted width="100%"></video>
31
+
32
+ **[form-filling](../../examples/form-filling)** - Demonstrates typing into form fields and clicking a submit button, simulating a login flow.
33
+
34
+ <video src="../../examples/form-filling/videos/form-filling.mp4" controls muted width="100%"></video>
35
+
36
+ **[gif-output](../../examples/gif-output)** - Demonstrates outputting the recording as an animated GIF instead of the default MP4.
37
+
38
+ <video src="../../examples/gif-output/videos/gif-output.gif" controls muted width="100%"></video>
39
+
40
+ **[hello-world](../../examples/hello-world)** - The simplest possible webreel example. Opens a landing page and clicks the call-to-action button.
41
+
42
+ <video src="../../examples/hello-world/videos/hello-world.mp4" controls muted width="100%"></video>
43
+
44
+ **[keyboard-shortcuts](../../examples/keyboard-shortcuts)** - Demonstrates pressing key combos and displaying them in the keystroke HUD overlay. Uses a code editor page as the target.
45
+
46
+ <video src="../../examples/keyboard-shortcuts/videos/keyboard-shortcuts.mp4" controls muted width="100%"></video>
47
+
48
+ **[mobile-viewport](../../examples/mobile-viewport)** - Demonstrates recording at mobile device dimensions using a finance app interface.
49
+
50
+ <video src="../../examples/mobile-viewport/videos/mobile-viewport.mp4" controls muted width="100%"></video>
51
+
52
+ **[modifier-clicks](../../examples/modifier-clicks)** - Demonstrates clicking elements with modifier keys held down, simulating multi-select in a file manager.
53
+
54
+ <video src="../../examples/modifier-clicks/videos/modifier-clicks.mp4" controls muted width="100%"></video>
55
+
56
+ **[multi-demo](../../examples/multi-demo)** - Demonstrates defining multiple videos in a single config file, each producing its own output from the same page.
57
+
58
+ <video src="../../examples/multi-demo/videos/homepage.mp4" controls muted width="100%"></video>
59
+
60
+ **[page-scrolling](../../examples/page-scrolling)** - Demonstrates scrolling the page and scrolling within a specific container element on a blog post layout.
61
+
62
+ <video src="../../examples/page-scrolling/videos/page-scrolling.mp4" controls muted width="100%"></video>
63
+
64
+ **[screenshots](../../examples/screenshots)** - Demonstrates capturing PNG screenshots at specific points during a recording. Useful for generating static marketing assets or documentation images alongside videos.
65
+
66
+ <video src="../../examples/screenshots/videos/screenshots.mp4" controls muted width="100%"></video>
67
+
68
+ **[shared-steps](../../examples/shared-steps)** - Demonstrates using `include` to share common setup steps across videos. The shared steps dismiss a cookie consent banner before the main video steps run.
69
+
70
+ <video src="../../examples/shared-steps/shared-steps.mp4" controls muted width="100%"></video>
71
+
72
+ **[webm-output](../../examples/webm-output)** - Demonstrates outputting the recording as a WebM video using VP9 encoding.
73
+
74
+ <video src="../../examples/webm-output/webm-output.webm" controls muted width="100%"></video>
75
+
76
+ <!-- EXAMPLES:END -->
77
+
78
+ ## Commands
79
+
80
+ ### `webreel init`
81
+
82
+ Scaffold a new config file.
83
+
84
+ ```bash
85
+ webreel init
86
+ webreel init --name login-flow --url https://myapp.com
87
+ webreel init --name hero -o hero.config.json
88
+ ```
89
+
90
+ | Option | Default | Description |
91
+ | --------------------- | --------------------- | ---------------- |
92
+ | `--name <name>` | `my-video` | Video name |
93
+ | `--url <url>` | `https://example.com` | Starting URL |
94
+ | `-o, --output <file>` | `<name>.json` | Output file path |
95
+
96
+ ### `webreel record`
97
+
98
+ Record videos.
99
+
100
+ ```bash
101
+ webreel record
102
+ webreel record hero login
103
+ webreel record -c custom.config.json
104
+ ```
105
+
106
+ When run without arguments, webreel reads `webreel.config.json` from the current directory and records all videos. Provide video names to record specific videos only.
107
+
108
+ ### `webreel preview`
109
+
110
+ Run a video in a visible browser window without recording.
111
+
112
+ ```bash
113
+ webreel preview
114
+ webreel preview hero
115
+ ```
116
+
117
+ ### `webreel validate`
118
+
119
+ Check config files for errors without running them.
120
+
121
+ ```bash
122
+ webreel validate
123
+ webreel validate -c custom.config.json
124
+ ```
125
+
126
+ ### `webreel composite`
127
+
128
+ Re-composite videos from stored raw recordings and timelines without re-recording.
129
+
130
+ ```bash
131
+ webreel composite
132
+ webreel composite hero login
133
+ ```
134
+
135
+ Raw video and timeline data are saved in `.webreel/raw/` and `.webreel/timelines/` during `webreel record`. Use `composite` to re-apply cursor overlays, HUD, and sound effects without re-running the browser.
136
+
137
+ ## Config format
138
+
139
+ ```json
140
+ {
141
+ "$schema": "https://webreel.dev/schema/v1.json",
142
+ "videos": {
143
+ "my-video": {
144
+ "url": "https://example.com",
145
+ "viewport": { "width": 1080, "height": 1080 },
146
+ "defaultDelay": 500,
147
+ "steps": [
148
+ { "action": "pause", "ms": 500 },
149
+ { "action": "click", "text": "Get Started" },
150
+ { "action": "key", "key": "cmd+a", "delay": 1000 }
151
+ ]
152
+ }
153
+ }
154
+ }
155
+ ```
156
+
157
+ ### Config options
158
+
159
+ | Field | Default | Description |
160
+ | -------------- | ------------- | --------------------------------------------------------- |
161
+ | `url` | required | URL to navigate to |
162
+ | `baseUrl` | `""` | Prepended to relative URLs |
163
+ | `viewport` | 1080x1080 | Browser viewport dimensions |
164
+ | `zoom` | - | CSS zoom level applied to the page |
165
+ | `waitFor` | - | CSS selector to wait for before starting |
166
+ | `output` | `<name>.mp4` | Output file path (`.mp4`, `.gif`, or `.webm`) |
167
+ | `thumbnail` | `{ time: 0 }` | Object with `time` (seconds) or `enabled: false` |
168
+ | `theme` | - | Overlay theme (`cursor: { image, size, hotspot }`, `hud`) |
169
+ | `include` | - | Array of JSON file paths whose steps are prepended |
170
+ | `defaultDelay` | - | Default delay (ms) after each step |
171
+
172
+ ### Actions
173
+
174
+ | Action | Fields | Description |
175
+ | ------------ | ------------------------------------------------------ | ------------------------------------- |
176
+ | `pause` | `ms` | Wait for a duration |
177
+ | `click` | `text` or `selector`, optional `within`, `modifiers` | Move cursor to an element and click |
178
+ | `key` | `key` (e.g. `"cmd+z"`), optional `label`, `target` | Press a key or key combo |
179
+ | `type` | `text`, optional `target`, `charDelay` | Type text character by character |
180
+ | `drag` | `from` and `to` (each with `text`/`selector`/`within`) | Drag from one element to another |
181
+ | `scroll` | optional `x`, `y`, `selector` | Scroll the page or a container |
182
+ | `wait` | `selector` or `text`, optional `timeout` | Wait for an element or text to appear |
183
+ | `moveTo` | `text` or `selector`, optional `within` | Move cursor to an element |
184
+ | `screenshot` | `output` | Save a PNG screenshot |
185
+ | `navigate` | `url` | Navigate to a new URL mid-video |
186
+ | `hover` | `text` or `selector`, optional `within` | Hover over an element (triggers CSS) |
187
+ | `select` | `selector`, `value` | Select a value in a dropdown |
188
+
189
+ All steps (except `pause`) accept an optional `delay` field (ms to wait after the step). Use `defaultDelay` at the top-level or per-video to set a default.
190
+
191
+ ## License
192
+
193
+ Apache-2.0
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=record.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record.test.d.ts","sourceRoot":"","sources":["../../../src/commands/__tests__/record.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,89 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { resolve, dirname } from "node:path";
3
+ import { collectIncludePaths } from "../record.js";
4
+ describe("collectIncludePaths", () => {
5
+ const configPath = "/project/webreel.config.json";
6
+ const configDir = dirname(configPath);
7
+ function makeConfig(overrides = {}) {
8
+ return {
9
+ videos: [
10
+ {
11
+ name: "test",
12
+ url: "https://example.com",
13
+ steps: [],
14
+ },
15
+ ],
16
+ ...overrides,
17
+ };
18
+ }
19
+ it("returns empty array when no includes exist", () => {
20
+ const config = makeConfig();
21
+ expect(collectIncludePaths(config, configPath)).toEqual([]);
22
+ });
23
+ it("resolves top-level include paths relative to config dir", () => {
24
+ const config = makeConfig({ include: ["steps/setup.json"] });
25
+ const result = collectIncludePaths(config, configPath);
26
+ expect(result).toEqual([resolve(configDir, "steps/setup.json")]);
27
+ });
28
+ it("resolves per-video include paths", () => {
29
+ const config = makeConfig({
30
+ videos: [
31
+ {
32
+ name: "v1",
33
+ url: "https://example.com",
34
+ steps: [],
35
+ include: ["steps/v1-setup.json"],
36
+ },
37
+ ],
38
+ });
39
+ const result = collectIncludePaths(config, configPath);
40
+ expect(result).toEqual([resolve(configDir, "steps/v1-setup.json")]);
41
+ });
42
+ it("combines top-level and per-video includes", () => {
43
+ const config = makeConfig({
44
+ include: ["steps/shared.json"],
45
+ videos: [
46
+ {
47
+ name: "v1",
48
+ url: "https://example.com",
49
+ steps: [],
50
+ include: ["steps/v1.json"],
51
+ },
52
+ {
53
+ name: "v2",
54
+ url: "https://example.com",
55
+ steps: [],
56
+ include: ["steps/v2.json"],
57
+ },
58
+ ],
59
+ });
60
+ const result = collectIncludePaths(config, configPath);
61
+ expect(result).toEqual([
62
+ resolve(configDir, "steps/shared.json"),
63
+ resolve(configDir, "steps/v1.json"),
64
+ resolve(configDir, "steps/v2.json"),
65
+ ]);
66
+ });
67
+ it("deduplicates identical paths", () => {
68
+ const config = makeConfig({
69
+ include: ["steps/setup.json"],
70
+ videos: [
71
+ {
72
+ name: "v1",
73
+ url: "https://example.com",
74
+ steps: [],
75
+ include: ["steps/setup.json"],
76
+ },
77
+ {
78
+ name: "v2",
79
+ url: "https://example.com",
80
+ steps: [],
81
+ include: ["steps/setup.json"],
82
+ },
83
+ ],
84
+ });
85
+ const result = collectIncludePaths(config, configPath);
86
+ expect(result).toEqual([resolve(configDir, "steps/setup.json")]);
87
+ });
88
+ });
89
+ //# sourceMappingURL=record.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record.test.js","sourceRoot":"","sources":["../../../src/commands/__tests__/record.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGnD,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACnC,MAAM,UAAU,GAAG,8BAA8B,CAAC;IAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAEtC,SAAS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AkB,CAAC,CAAC,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Command } from "commander";
2
+ export declare const compositeCommand: Command;
3
+ //# sourceMappingURL=composite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"composite.d.ts","sourceRoot":"","sources":["../../src/commands/composite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAYpC,eAAO,MAAM,gBAAgB,SA6CzB,CAAC"}
@@ -0,0 +1,40 @@
1
+ import { Command } from "commander";
2
+ import { readFileSync, existsSync, mkdirSync } from "node:fs";
3
+ import { resolve, dirname } from "node:path";
4
+ import { compose } from "@webreel/core";
5
+ import { loadWebreelConfig, resolveConfigPath, getConfigDir, filterVideosByName, } from "../lib/config.js";
6
+ import { extractThumbnailIfConfigured } from "../lib/runner.js";
7
+ export const compositeCommand = new Command("composite")
8
+ .description("Re-composite videos from stored raw recordings and timelines")
9
+ .argument("[videos...]", "Video names to composite (default: all)")
10
+ .option("-c, --config <path>", "Path to config file (default: webreel.config.json)")
11
+ .action(async (videoNames, opts) => {
12
+ const configPath = resolveConfigPath(opts.config);
13
+ const configDir = getConfigDir(configPath);
14
+ const webreelConfig = await loadWebreelConfig(configPath);
15
+ const videos = filterVideosByName(webreelConfig.videos, videoNames);
16
+ for (const video of videos) {
17
+ const rawPath = resolve(configDir, ".webreel", "raw", `${video.name}.mp4`);
18
+ const timelinePath = resolve(configDir, ".webreel", "timelines", `${video.name}.timeline.json`);
19
+ if (!existsSync(rawPath)) {
20
+ throw new Error(`Raw video not found: ${rawPath}. Run "webreel record" first.`);
21
+ }
22
+ if (!existsSync(timelinePath)) {
23
+ throw new Error(`Timeline not found: ${timelinePath}. Run "webreel record" first.`);
24
+ }
25
+ let timelineData;
26
+ try {
27
+ timelineData = JSON.parse(readFileSync(timelinePath, "utf-8"));
28
+ }
29
+ catch (err) {
30
+ throw new Error(`Invalid timeline file: ${timelinePath}`, { cause: err });
31
+ }
32
+ const outputPath = video.output ?? resolve(configDir, "videos", `${video.name}.mp4`);
33
+ mkdirSync(dirname(outputPath), { recursive: true });
34
+ console.log(`Compositing: ${video.name}`);
35
+ await compose(rawPath, timelineData, outputPath, { sfx: video.sfx });
36
+ await extractThumbnailIfConfigured(video, outputPath);
37
+ console.log(`Done: ${outputPath}`);
38
+ }
39
+ });
40
+ //# sourceMappingURL=composite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"composite.js","sourceRoot":"","sources":["../../src/commands/composite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAqB,MAAM,eAAe,CAAC;AAC3D,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACZ,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AAEhE,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,OAAO,CAAC,WAAW,CAAC;KACrD,WAAW,CAAC,8DAA8D,CAAC;KAC3E,QAAQ,CAAC,aAAa,EAAE,yCAAyC,CAAC;KAClE,MAAM,CAAC,qBAAqB,EAAE,oDAAoD,CAAC;KACnF,MAAM,CAAC,KAAK,EAAE,UAAoB,EAAE,IAAyB,EAAE,EAAE;IAChE,MAAM,UAAU,GAAG,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAClD,MAAM,SAAS,GAAG,YAAY,CAAC,UAAU,CAAC,CAAC;IAC3C,MAAM,aAAa,GAAG,MAAM,iBAAiB,CAAC,UAAU,CAAC,CAAC;IAC1D,MAAM,MAAM,GAAG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EAAE,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;QAErE,MAAM,4BAA4B,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;QAEtD,OAAO,CAAC,GAAG,CAAC,SAAS,UAAU,EAAE,CAAC,CAAC;IACrC,CAAC;AACH,CAAC,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Command } from "commander";
2
+ export declare const initCommand: Command;
3
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAoCpC,eAAO,MAAM,WAAW,SAoBpB,CAAC"}
@@ -0,0 +1,50 @@
1
+ import { Command } from "commander";
2
+ import { writeFileSync, existsSync } from "node:fs";
3
+ import { resolve } from "node:path";
4
+ import { DEFAULT_CONFIG_FILE } from "../lib/config.js";
5
+ const INIT_TEMPLATE = `{
6
+ // JSON Schema for IDE autocompletion (VS Code, Cursor, JetBrains).
7
+ // Full docs: https://webreel.dev/configuration
8
+ "$schema": "https://webreel.dev/schema/v1.json",
9
+
10
+ // Output directory for recorded videos (relative to this file).
11
+ "outDir": "./videos",
12
+
13
+ // Default delay (ms) after each step. Override per-step with "delay".
14
+ "defaultDelay": 500,
15
+
16
+ "videos": {
17
+ "VIDEO_NAME": {
18
+ "url": "VIDEO_URL",
19
+ "viewport": { "width": 1920, "height": 1080 },
20
+
21
+ // Optional: wait for an element before starting.
22
+ // "waitFor": "[data-ready]",
23
+
24
+ // Steps are executed in order. Each step is an action.
25
+ // Use "pause" for explicit waits; use "delay" on any step for post-step waits.
26
+ "steps": [
27
+ { "action": "pause", "ms": 500 },
28
+ { "action": "click", "text": "Get Started" },
29
+ { "action": "key", "key": "mod+a", "delay": 1000 }
30
+ ]
31
+ }
32
+ }
33
+ }
34
+ `;
35
+ export const initCommand = new Command("init")
36
+ .description("Scaffold a new webreel config file")
37
+ .option("--name <name>", "video name", "my-video")
38
+ .option("--url <url>", "starting URL", "https://example.com")
39
+ .option("-o, --output <file>", "output file path")
40
+ .action((opts) => {
41
+ const fileName = opts.output ?? DEFAULT_CONFIG_FILE;
42
+ const filePath = resolve(process.cwd(), fileName);
43
+ if (existsSync(filePath)) {
44
+ throw new Error(`File already exists: ${fileName}`);
45
+ }
46
+ const content = INIT_TEMPLATE.replace("VIDEO_NAME", opts.name).replace("VIDEO_URL", opts.url);
47
+ writeFileSync(filePath, content);
48
+ console.log(`Created ${fileName}`);
49
+ });
50
+ //# sourceMappingURL=init.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BrB,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;KAC3C,WAAW,CAAC,oCAAoC,CAAC;KACjD,MAAM,CAAC,eAAe,EAAE,YAAY,EAAE,UAAU,CAAC;KACjD,MAAM,CAAC,aAAa,EAAE,cAAc,EAAE,qBAAqB,CAAC;KAC5D,MAAM,CAAC,qBAAqB,EAAE,kBAAkB,CAAC;KACjD,MAAM,CAAC,CAAC,IAAoD,EAAE,EAAE;IAC/D,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,IAAI,mBAAmB,CAAC;IACpD,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,QAAQ,CAAC,CAAC;IAElD,IAAI,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,wBAAwB,QAAQ,EAAE,CAAC,CAAC;IACtD,CAAC;IAED,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,CAAC,YAAY,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CACpE,WAAW,EACX,IAAI,CAAC,GAAG,CACT,CAAC;IAEF,aAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACjC,OAAO,CAAC,GAAG,CAAC,WAAW,QAAQ,EAAE,CAAC,CAAC;AACrC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Command } from "commander";
2
+ export declare const previewCommand: Command;
3
+ //# sourceMappingURL=preview.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../src/commands/preview.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,eAAO,MAAM,cAAc,SAkCxB,CAAC"}