playwright-recast 0.3.0 → 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/README.md +74 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -187,6 +187,8 @@ Every stage is optional and composable:
|
|
|
187
187
|
| `.subtitles(textFn)` | Generate subtitles from trace actions |
|
|
188
188
|
| `.subtitlesFromSrt(path)` | Load subtitles from an external SRT file |
|
|
189
189
|
| `.subtitlesFromTrace()` | Auto-generate subtitles from BDD step titles in trace |
|
|
190
|
+
| `.autoZoom(config)` | Auto-zoom to user interaction targets detected from trace |
|
|
191
|
+
| `.enrichZoomFromReport(steps)` | Apply zoom coordinates from external report data |
|
|
190
192
|
| `.voiceover(provider)` | Generate TTS audio from subtitle text |
|
|
191
193
|
| `.render(config)` | Render final video (format, resolution, fps, styled subtitle burn-in) |
|
|
192
194
|
| `.toFile(path)` | Execute pipeline and write output |
|
|
@@ -258,6 +260,77 @@ Requires `ELEVENLABS_API_KEY` environment variable or `apiKey` option.
|
|
|
258
260
|
|
|
259
261
|
---
|
|
260
262
|
|
|
263
|
+
## Zoom
|
|
264
|
+
|
|
265
|
+
Zoom into specific areas of the video during steps — focus the viewer's attention on the relevant UI element.
|
|
266
|
+
|
|
267
|
+
### Auto-zoom from trace
|
|
268
|
+
|
|
269
|
+
Automatically zoom into user interaction targets (clicks, fills) detected from the trace:
|
|
270
|
+
|
|
271
|
+
```typescript
|
|
272
|
+
await Recast
|
|
273
|
+
.from('./traces')
|
|
274
|
+
.parse()
|
|
275
|
+
.subtitlesFromSrt('./narration.srt')
|
|
276
|
+
.autoZoom({ actionLevel: 1.5 }) // 1.5x zoom on detected actions
|
|
277
|
+
.render({ format: 'mp4' })
|
|
278
|
+
.toFile('demo.mp4')
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
`autoZoom()` finds click/fill/type actions in the trace, extracts their cursor coordinates, and applies crop-and-scale zoom during the matching subtitle's time window.
|
|
282
|
+
|
|
283
|
+
### Zoom from report data
|
|
284
|
+
|
|
285
|
+
Apply zoom coordinates from an external source (e.g., a demo report with per-step zoom data):
|
|
286
|
+
|
|
287
|
+
```typescript
|
|
288
|
+
const reportSteps = [
|
|
289
|
+
{ zoom: null }, // Step 1: no zoom
|
|
290
|
+
{ zoom: { x: 0.5, y: 0.8, level: 1.4 } }, // Step 2: zoom to input area
|
|
291
|
+
{ zoom: null }, // Step 3: no zoom
|
|
292
|
+
{ zoom: { x: 0.78, y: 0.45, level: 1.3 }}, // Step 4: zoom to sidebar
|
|
293
|
+
]
|
|
294
|
+
|
|
295
|
+
await Recast
|
|
296
|
+
.from('./traces')
|
|
297
|
+
.parse()
|
|
298
|
+
.subtitlesFromSrt('./narration.srt')
|
|
299
|
+
.enrichZoomFromReport(reportSteps)
|
|
300
|
+
.render({ format: 'mp4' })
|
|
301
|
+
.toFile('demo.mp4')
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### Zoom from step helpers
|
|
305
|
+
|
|
306
|
+
Capture zoom coordinates during Playwright test execution using the `zoom()` helper:
|
|
307
|
+
|
|
308
|
+
```typescript
|
|
309
|
+
import { zoom } from 'playwright-recast'
|
|
310
|
+
|
|
311
|
+
When('the user opens the sidebar', async ({ page }) => {
|
|
312
|
+
const sidebar = page.locator('.sidebar-panel')
|
|
313
|
+
await zoom(sidebar, 1.3) // Record zoom target for this step
|
|
314
|
+
await sidebar.click()
|
|
315
|
+
})
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
The helper captures the element's bounding box as a Playwright annotation. Use `enrichZoomFromReport()` to apply these coordinates during video generation.
|
|
319
|
+
|
|
320
|
+
### Zoom coordinates
|
|
321
|
+
|
|
322
|
+
All zoom coordinates use viewport-relative fractions (0.0–1.0):
|
|
323
|
+
|
|
324
|
+
| Field | Description | Default |
|
|
325
|
+
|-------|-------------|---------|
|
|
326
|
+
| `x` | Center X (0 = left, 1 = right) | 0.5 |
|
|
327
|
+
| `y` | Center Y (0 = top, 1 = bottom) | 0.5 |
|
|
328
|
+
| `level` | Zoom level (1.0 = no zoom, 2.0 = 2x) | 1.0 |
|
|
329
|
+
|
|
330
|
+
The renderer applies zoom by cropping the video to `(width/level × height/level)` centered at `(x, y)`, then scaling back to the output resolution.
|
|
331
|
+
|
|
332
|
+
---
|
|
333
|
+
|
|
261
334
|
## Speed Processing
|
|
262
335
|
|
|
263
336
|
The speed processor classifies every moment of the trace:
|
|
@@ -308,8 +381,7 @@ await base.subtitlesFromSrt('./cs.srt').render({ burnSubtitles: true }).toFile('
|
|
|
308
381
|
|
|
309
382
|
## Roadmap
|
|
310
383
|
|
|
311
|
-
- [
|
|
312
|
-
- [ ] **Smooth zoom transitions** — Animated crop-and-zoom on elements during specific steps
|
|
384
|
+
- [ ] **Smooth zoom transitions** — Animated easing between zoom states (currently hard-cut)
|
|
313
385
|
- [ ] **Edge TTS provider** — Free TTS without API key using Microsoft Edge's online voices
|
|
314
386
|
- [ ] **Playwright Reporter plugin** — Auto-generate demo videos as part of your test run
|
|
315
387
|
- [ ] **Multi-language support** — Generate video variants from the same trace with different SRT/voiceover per language
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "playwright-recast",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Fluent pipeline library for processing Playwright traces into polished demo videos — TTS voiceover, subtitles, speed control, and zoom.",
|
|
6
6
|
"license": "MIT",
|