@phil65/demoreel 0.7.1 → 0.7.2

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 CHANGED
@@ -110,8 +110,8 @@ Each run writes into `out/<name>/`:
110
110
  | `say(text, [opts], [fn])` | voiceover narration via `@phil65/anyvoice` (free Edge TTS by default, OpenAI, ElevenLabs, Gemini, Cartesia, Deepgram); supports `say(text, async (cue) => { await cue.at("word"); ... })` + `.vtt` subtitles |
111
111
  | `zoom(target, { depth, duration, context, wait })` | explicit zoom (integer tier `1..6`: 1.25x..5x) overriding auto zooms |
112
112
  | `highlight(target, { duration, color, dim, badge, zoom })` | outline with optional spotlight dim backdrop and callout badge |
113
- | `blur(target, { type, shape, intensity, duration })` | blur or pixelate (`type: "mosaic"`) sensitive UI elements (alias `redact()`; defaults to blurring until video end) |
114
- | `arrow(target, { direction, color, duration })` | draw a crisp OpenScreen vector arrow pointing at an element |
113
+ | `blur(target, { type, shape, intensity, mode, duration })` | blur or pixelate (`type: "mosaic"`) sensitive UI elements (alias `redact()`; DOM Gaussian blurs track scroll & zoom automatically; defaults to `"end"`) |
114
+ | `arrow(target, { direction, color, duration })` | draw a crisp camera-tracked OpenScreen vector arrow pointing at an element |
115
115
  | `image(src, { x, y, width, height, duration })` | overlay a local PNG/JPG/SVG/WebP image or `data:image/...` URL on the rendered canvas |
116
116
 
117
117
  `target` is a structured accessibility-first spec (`{ role, name?, exact?, nth? }`,
package/dist/compose.js CHANGED
@@ -76,12 +76,15 @@ export function compose(input, opts = {}) {
76
76
  durationMs: input.durationMs,
77
77
  actions: input.actions,
78
78
  captions,
79
+ blurs: input.blurs,
80
+ arrows: input.arrows,
81
+ images: resolvedImages,
79
82
  voiceCues,
80
83
  zoomRegions,
81
84
  trimRegions,
82
85
  speedRegions,
83
86
  layout,
84
- look,
87
+ look: resolvedLook,
85
88
  });
86
89
  const marksPath = path.join(input.outDir, "marks.json");
87
90
  fs.writeFileSync(marksPath, JSON.stringify(marks, null, 1));
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /** demoreel: scripted product demo videos (videos as code), rendered by OpenScreen's exporter. */
2
2
  export { type DryRunError, type DryRunOptions, type DryRunResult, type RecordOptions, type RecordResult, type Scenario, type ScenarioContext, defineScenario, dryRunScenario, recordScenario, resolveStorageState, } from "./record.ts";
3
3
  export { type ActionOptions, applyZoomAnchor, type ArrowOptions, type BlurOptions, type ClickRippleOptions, DEFAULT_PACING, describeTarget, type HighlightOptions, type ImageOptions, type PacingOptions, type PressOptions, resolveTarget, type SayOptions, Scene, type SceneClock, type Target, type TargetSpec, type VoiceCueHandle, ZOOM_ATTRIBUTE, type ZoomOptions as SceneZoomOptions, } from "./scene.ts";
4
- export { buildVoiceVtt, createVoiceSynthesizer, DEFAULT_VOICE_GAP_MS, DEFAULT_VOICE_PAD_MS, findWordTiming, formatDryRunVoiceSummary, formatVoiceSummary, lintVoiceCues, muxVoiceTrack, type SayDeliveryOptions, type SynthesizedCue, type VoiceConfig, type VoiceFinding, VOICE_PROVIDERS, type VoiceProviderName, type VoiceSynthesizer, } from "./voice.ts";
4
+ export { buildVoiceVtt, chunkVoiceCaptions, createVoiceSynthesizer, DEFAULT_VOICE_GAP_MS, DEFAULT_VOICE_PAD_MS, findWordTiming, formatDryRunVoiceSummary, formatVoiceSummary, lintVoiceCues, muxVoiceTrack, type SayDeliveryOptions, type SynthesizedCue, type VoiceConfig, type VoiceFinding, VOICE_PROVIDERS, type VoiceProviderName, type VoiceSynthesizer, } from "./voice.ts";
5
5
  export { DEFAULT_ZOOM_OPTIONS, DEPTH_SCALES, deriveZoomRegions, depthForBox, normalizeDepth, type ZoomOptions } from "./zoom.ts";
6
6
  export { DEFAULT_IDLE_OPTIONS, deriveIdleRegions, idleIntervals, type IdleOptions, sourceToOutputMs } from "./idle.ts";
7
7
  export { arrowAnnotations, blurAnnotations, buildCursorData, buildProject, type BuildProjectOptions, captionAnnotations, DEFAULT_LOOK, formatKeycap, imageAnnotations, keycapAnnotations, type KeyHudOptions, type KeyHudPosition, keycapRect, type LookOptions, normalizeSamples, type OpenScreenProject, resolveImageDataUrl, type WatermarkOptions, type WatermarkPosition, writeProject, } from "./project.ts";
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /** demoreel: scripted product demo videos (videos as code), rendered by OpenScreen's exporter. */
2
2
  export { defineScenario, dryRunScenario, recordScenario, resolveStorageState, } from "./record.js";
3
3
  export { applyZoomAnchor, DEFAULT_PACING, describeTarget, resolveTarget, Scene, ZOOM_ATTRIBUTE, } from "./scene.js";
4
- export { buildVoiceVtt, createVoiceSynthesizer, DEFAULT_VOICE_GAP_MS, DEFAULT_VOICE_PAD_MS, findWordTiming, formatDryRunVoiceSummary, formatVoiceSummary, lintVoiceCues, muxVoiceTrack, VOICE_PROVIDERS, } from "./voice.js";
4
+ export { buildVoiceVtt, chunkVoiceCaptions, createVoiceSynthesizer, DEFAULT_VOICE_GAP_MS, DEFAULT_VOICE_PAD_MS, findWordTiming, formatDryRunVoiceSummary, formatVoiceSummary, lintVoiceCues, muxVoiceTrack, VOICE_PROVIDERS, } from "./voice.js";
5
5
  export { DEFAULT_ZOOM_OPTIONS, DEPTH_SCALES, deriveZoomRegions, depthForBox, normalizeDepth } from "./zoom.js";
6
6
  export { DEFAULT_IDLE_OPTIONS, deriveIdleRegions, idleIntervals, sourceToOutputMs } from "./idle.js";
7
7
  export { arrowAnnotations, blurAnnotations, buildCursorData, buildProject, captionAnnotations, DEFAULT_LOOK, formatKeycap, imageAnnotations, keycapAnnotations, keycapRect, normalizeSamples, resolveImageDataUrl, writeProject, } from "./project.js";
package/dist/layout.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * compositeLayout.ts::centerRect, focusUtils.ts::clampFocusToScale and
5
5
  * zoomTransform.ts::computeZoomTransform for the no-webcam, no-crop case demoreel writes.
6
6
  */
7
- import type { Box, Depth, Viewport } from "./types.ts";
7
+ import type { Box, Depth, Viewport, ZoomRegion } from "./types.ts";
8
8
  /** OpenScreen ZOOM_DEPTH_SCALES (src/components/video-editor/types.ts). */
9
9
  export declare const DEPTH_SCALES: Record<Depth, number>;
10
10
  /** A rectangle in stage-normalised coordinates (0-1 of the output canvas). */
@@ -50,3 +50,12 @@ export declare function zoomRect(r: NormRect, depth: Depth, focus: {
50
50
  }): NormRect;
51
51
  /** Clips a rect to the unit square; null if nothing is left. */
52
52
  export declare function clipUnit(r: NormRect): NormRect | null;
53
+ /** Approximate zoom progress (0-1) of a region at recording time t. */
54
+ export declare function zoomProgress(r: ZoomRegion, t: number): number;
55
+ /** The camera at time t: the dominant zoom region and its progress. */
56
+ export declare function cameraAt(regions: ZoomRegion[], t: number): {
57
+ region: ZoomRegion;
58
+ p: number;
59
+ } | null;
60
+ /** Stage rect -> output-frame rect under the camera at time t (OpenScreen computeZoomTransform). */
61
+ export declare function applyCamera(rect: NormRect, regions: ZoomRegion[], t: number): NormRect;
package/dist/layout.js CHANGED
@@ -53,3 +53,44 @@ export function clipUnit(r) {
53
53
  return null;
54
54
  return { x: x0, y: y0, w: x1 - x0, h: y1 - y0 };
55
55
  }
56
+ const ZOOM_IN_BEFORE_MS = 1022;
57
+ const ZOOM_IN_AFTER_MS = 500;
58
+ const ZOOM_OUT_MS = 1016;
59
+ const smooth = (x) => {
60
+ const t = Math.min(1, Math.max(0, x));
61
+ return t * t * (3 - 2 * t);
62
+ };
63
+ /** Approximate zoom progress (0-1) of a region at recording time t. */
64
+ export function zoomProgress(r, t) {
65
+ const inStart = r.startMs - ZOOM_IN_BEFORE_MS;
66
+ if (t <= inStart || t >= r.endMs + ZOOM_OUT_MS)
67
+ return 0;
68
+ if (t < r.startMs + ZOOM_IN_AFTER_MS)
69
+ return smooth((t - inStart) / (ZOOM_IN_BEFORE_MS + ZOOM_IN_AFTER_MS));
70
+ if (t <= r.endMs)
71
+ return 1;
72
+ return 1 - smooth((t - r.endMs) / ZOOM_OUT_MS);
73
+ }
74
+ /** The camera at time t: the dominant zoom region and its progress. */
75
+ export function cameraAt(regions, t) {
76
+ let best = null;
77
+ for (const r of regions) {
78
+ const p = zoomProgress(r, t);
79
+ if (p > 0 && (!best || p > best.p))
80
+ best = { region: r, p };
81
+ }
82
+ return best;
83
+ }
84
+ /** Stage rect -> output-frame rect under the camera at time t (OpenScreen computeZoomTransform). */
85
+ export function applyCamera(rect, regions, t) {
86
+ const cam = cameraAt(regions, t);
87
+ if (!cam)
88
+ return rect;
89
+ const depth = Math.min(6, Math.max(1, Math.round(cam.region.depth)));
90
+ const s = DEPTH_SCALES[depth];
91
+ const f = clampFocus(cam.region.focus, s);
92
+ const scale = 1 + (s - 1) * cam.p;
93
+ const ox = (0.5 - f.cx * s) * cam.p;
94
+ const oy = (0.5 - f.cy * s) * cam.p;
95
+ return { x: rect.x * scale + ox, y: rect.y * scale + oy, w: rect.w * scale, h: rect.h * scale };
96
+ }
package/dist/marks.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { type NormRect, type StageLayout } from "./layout.ts";
1
+ import { applyCamera, cameraAt, type NormRect, type StageLayout, zoomProgress } from "./layout.ts";
2
2
  import { type LookOptions } from "./project.ts";
3
- import type { ActionRecord, Caption, SpeedRegion, TrimRegion, Viewport, VoiceCue, ZoomRegion } from "./types.ts";
3
+ import type { ActionRecord, ArrowAnnotation, BlurAnnotation, Caption, ImageAnnotation, SpeedRegion, TrimRegion, Viewport, VoiceCue, ZoomRegion } from "./types.ts";
4
+ export { applyCamera, cameraAt, zoomProgress };
4
5
  export interface MarkPoint {
5
6
  t: number;
6
7
  x: number;
@@ -36,12 +37,15 @@ export interface MarksInput {
36
37
  durationMs: number;
37
38
  actions: ActionRecord[];
38
39
  captions: Caption[];
40
+ blurs?: BlurAnnotation[];
41
+ arrows?: ArrowAnnotation[];
42
+ images?: ImageAnnotation[];
39
43
  voiceCues?: VoiceCue[];
40
44
  zoomRegions: ZoomRegion[];
41
45
  trimRegions?: TrimRegion[];
42
46
  speedRegions?: SpeedRegion[];
43
47
  layout: StageLayout;
44
- look: Pick<LookOptions, "captionPosition">;
48
+ look: Pick<LookOptions, "captionPosition" | "watermark">;
45
49
  }
46
50
  export interface TargetRect {
47
51
  action: ActionRecord;
@@ -58,13 +62,4 @@ export declare function targetRects(input: Pick<MarksInput, "actions" | "viewpor
58
62
  * while it is shown (with 400 ms slack); then top, if that overlaps less.
59
63
  */
60
64
  export declare function placeCaptions(captions: Caption[], targets: TargetRect[], position: LookOptions["captionPosition"]): Caption[];
61
- /** Approximate zoom progress (0-1) of a region at recording time t. */
62
- export declare function zoomProgress(r: ZoomRegion, t: number): number;
63
- /** The camera at time t: the dominant zoom region and its progress. */
64
- export declare function cameraAt(regions: ZoomRegion[], t: number): {
65
- region: ZoomRegion;
66
- p: number;
67
- } | null;
68
- /** Stage rect -> output-frame rect under the camera at time t (OpenScreen computeZoomTransform). */
69
- export declare function applyCamera(rect: NormRect, regions: ZoomRegion[], t: number): NormRect;
70
65
  export declare function buildMarks(input: MarksInput): Marks;
package/dist/marks.js CHANGED
@@ -6,14 +6,15 @@
6
6
  * so `framesheet inspect out.mp4 --marks marks.json` draws them where they appear.
7
7
  */
8
8
  import { sourceToOutputMs } from "./idle.js";
9
- import { clipUnit, DEPTH_SCALES, boxToStage, clampFocus, toStage } from "./layout.js";
10
- import { captionRect } from "./project.js";
9
+ import { applyCamera, boxToStage, cameraAt, clipUnit, DEPTH_SCALES, toStage, zoomProgress, } from "./layout.js";
10
+ import { arrowRectForTarget, captionRect } from "./project.js";
11
11
  import { normalizeDepth } from "./zoom.js";
12
+ export { applyCamera, cameraAt, zoomProgress };
12
13
  /** Action target boxes in output-frame coordinates (padding + zoom camera applied). */
13
14
  export function targetRects(input) {
14
15
  const out = [];
15
16
  for (const a of input.actions) {
16
- if (!a.box || a.kind === "zoom")
17
+ if (!a.box || a.kind === "zoom" || a.kind === "blur" || a.kind === "arrow" || a.kind === "image")
17
18
  continue;
18
19
  // Sample the camera once the cursor has landed (zoom is then (nearly) complete).
19
20
  const t = Math.min(a.endMs, a.arriveMs + 300);
@@ -42,46 +43,6 @@ export function placeCaptions(captions, targets, position) {
42
43
  return { ...c, position: bottom > 0 && cost("top") < bottom ? "top" : "bottom" };
43
44
  });
44
45
  }
45
- const ZOOM_IN_BEFORE_MS = 1022;
46
- const ZOOM_IN_AFTER_MS = 500;
47
- const ZOOM_OUT_MS = 1016;
48
- const smooth = (x) => {
49
- const t = Math.min(1, Math.max(0, x));
50
- return t * t * (3 - 2 * t);
51
- };
52
- /** Approximate zoom progress (0-1) of a region at recording time t. */
53
- export function zoomProgress(r, t) {
54
- const inStart = r.startMs - ZOOM_IN_BEFORE_MS;
55
- if (t <= inStart || t >= r.endMs + ZOOM_OUT_MS)
56
- return 0;
57
- if (t < r.startMs + ZOOM_IN_AFTER_MS)
58
- return smooth((t - inStart) / (ZOOM_IN_BEFORE_MS + ZOOM_IN_AFTER_MS));
59
- if (t <= r.endMs)
60
- return 1;
61
- return 1 - smooth((t - r.endMs) / ZOOM_OUT_MS);
62
- }
63
- /** The camera at time t: the dominant zoom region and its progress. */
64
- export function cameraAt(regions, t) {
65
- let best = null;
66
- for (const r of regions) {
67
- const p = zoomProgress(r, t);
68
- if (p > 0 && (!best || p > best.p))
69
- best = { region: r, p };
70
- }
71
- return best;
72
- }
73
- /** Stage rect -> output-frame rect under the camera at time t (OpenScreen computeZoomTransform). */
74
- export function applyCamera(rect, regions, t) {
75
- const cam = cameraAt(regions, t);
76
- if (!cam)
77
- return rect;
78
- const s = DEPTH_SCALES[normalizeDepth(cam.region.depth)];
79
- const f = clampFocus(cam.region.focus, s);
80
- const scale = 1 + (s - 1) * cam.p;
81
- const ox = (0.5 - f.cx * s) * cam.p;
82
- const oy = (0.5 - f.cy * s) * cam.p;
83
- return { x: rect.x * scale + ox, y: rect.y * scale + oy, w: rect.w * scale, h: rect.h * scale };
84
- }
85
46
  const r4 = (v) => Math.round(v * 10000) / 10000;
86
47
  const r3 = (v) => Math.round(v * 1000) / 1000;
87
48
  function describe(a) {
@@ -141,6 +102,75 @@ export function buildMarks(input) {
141
102
  kind: "voice",
142
103
  });
143
104
  }
105
+ for (const b of input.blurs ?? []) {
106
+ const bEndMs = b.endMs === "end" ? input.durationMs : b.endMs;
107
+ const start = out(b.startMs);
108
+ const sampleT = Math.min(bEndMs, b.startMs + Math.min(350, (bEndMs - b.startMs) / 2));
109
+ let rect = null;
110
+ if (b.rect) {
111
+ rect = clipUnit({ x: b.rect.x / 100, y: b.rect.y / 100, w: b.rect.width / 100, h: b.rect.height / 100 });
112
+ }
113
+ else if (b.box) {
114
+ const pad = b.padding ?? 4;
115
+ const padded = {
116
+ x: Math.max(0, b.box.x - pad),
117
+ y: Math.max(0, b.box.y - pad),
118
+ width: b.box.width + pad * 2,
119
+ height: b.box.height + pad * 2,
120
+ };
121
+ rect = clipUnit(applyCamera(boxToStage(layout, vp, padded), zr, sampleT));
122
+ }
123
+ marks.regions.push({
124
+ start,
125
+ end: Math.max(start, Math.min(endS, out(bEndMs))),
126
+ ...(box(rect) ?? {}),
127
+ label: b.label ?? "blur",
128
+ kind: "blur",
129
+ });
130
+ }
131
+ for (const a of input.arrows ?? []) {
132
+ const start = out(a.startMs);
133
+ const sizePct = Math.min(40, Math.max(3, a.size ?? 9));
134
+ let rect = null;
135
+ if (a.rect) {
136
+ rect = clipUnit({ x: a.rect.x / 100, y: a.rect.y / 100, w: a.rect.width / 100, h: a.rect.height / 100 });
137
+ }
138
+ else if (a.box) {
139
+ const sampleT = Math.min(a.endMs, a.startMs + Math.min(350, (a.endMs - a.startMs) / 2));
140
+ const stage = applyCamera(boxToStage(layout, vp, a.box), zr, sampleT);
141
+ const r = arrowRectForTarget(stage, a.direction, sizePct);
142
+ rect = clipUnit({ x: r.x / 100, y: r.y / 100, w: r.width / 100, h: r.height / 100 });
143
+ }
144
+ marks.regions.push({
145
+ start,
146
+ end: Math.max(start, Math.min(endS, out(a.endMs))),
147
+ ...(box(rect) ?? {}),
148
+ label: a.label ?? `arrow ${a.direction}`,
149
+ kind: "arrow",
150
+ });
151
+ }
152
+ const imageList = [...(input.images ?? [])];
153
+ if (input.look.watermark) {
154
+ const wm = input.look.watermark;
155
+ const w = wm.width ?? 10;
156
+ const h = wm.height ?? 8;
157
+ const pos = wm.position ?? "bottom-right";
158
+ const x = typeof pos === "object" ? pos.x : pos.endsWith("left") ? 2.5 : 97.5 - w;
159
+ const y = typeof pos === "object" ? pos.y : pos.startsWith("top") ? 2.5 : 97.5 - h;
160
+ imageList.push({ startMs: 0, endMs: "end", src: wm.src, x, y, width: w, height: h, label: "watermark" });
161
+ }
162
+ for (const img of imageList) {
163
+ const imgEndMs = img.endMs === "end" ? input.durationMs : img.endMs;
164
+ const start = out(img.startMs);
165
+ const rect = clipUnit({ x: img.x / 100, y: img.y / 100, w: img.width / 100, h: img.height / 100 });
166
+ marks.regions.push({
167
+ start,
168
+ end: Math.max(start, Math.min(endS, out(imgEndMs))),
169
+ ...(box(rect) ?? {}),
170
+ label: img.label ?? "image",
171
+ kind: "image",
172
+ });
173
+ }
144
174
  for (const cap of input.captions) {
145
175
  const c = captionRect(cap.position ?? input.look.captionPosition);
146
176
  const start = out(cap.startMs);
package/dist/project.d.ts CHANGED
@@ -125,11 +125,12 @@ export declare function captionAnnotations(captions: Caption[], look?: LookOptio
125
125
  }[];
126
126
  /** Resolves a `data:image/...` URL or reads a local image file and encodes it as a data URL. */
127
127
  export declare function resolveImageDataUrl(src: string, baseDir?: string): string;
128
- /** Converts recorded `BlurAnnotation`s into OpenScreen `type: "blur"` regions. */
128
+ /** Converts recorded `BlurAnnotation`s into OpenScreen `type: "blur"` regions (skipping DOM-blurred elements). */
129
129
  export declare function blurAnnotations(blurs: BlurAnnotation[], opts: {
130
130
  viewport: Viewport;
131
131
  layout: StageLayout;
132
132
  durationMs: number;
133
+ zoomRegions?: ZoomRegion[];
133
134
  startZIndex?: number;
134
135
  }): {
135
136
  id: string;
@@ -169,10 +170,23 @@ export declare function blurAnnotations(blurs: BlurAnnotation[], opts: {
169
170
  }[];
170
171
  };
171
172
  }[];
172
- /** Converts recorded `ArrowAnnotation`s into OpenScreen `type: "figure"` arrow regions. */
173
+ /** Places a directional arrow box just outside a target rect pointing toward it. */
174
+ export declare function arrowRectForTarget(stage: {
175
+ x: number;
176
+ y: number;
177
+ w: number;
178
+ h: number;
179
+ }, dir: ArrowDirection, sizePct: number): {
180
+ x: number;
181
+ y: number;
182
+ width: number;
183
+ height: number;
184
+ };
185
+ /** Converts recorded `ArrowAnnotation`s into OpenScreen `type: "figure"` arrow regions (camera-projected). */
173
186
  export declare function arrowAnnotations(arrows: ArrowAnnotation[], opts: {
174
187
  viewport: Viewport;
175
188
  layout: StageLayout;
189
+ zoomRegions?: ZoomRegion[];
176
190
  startZIndex?: number;
177
191
  }): {
178
192
  id: string;
package/dist/project.js CHANGED
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import fs from "node:fs";
7
7
  import path from "node:path";
8
- import { boxToStage, stageLayout } from "./layout.js";
8
+ import { applyCamera, boxToStage, stageLayout } from "./layout.js";
9
9
  export const PROJECT_VERSION = 2;
10
10
  export const CURSOR_TELEMETRY_VERSION = 2;
11
11
  export const DEFAULT_LOOK = {
@@ -183,10 +183,12 @@ const DEFAULT_BLUR_FREEHAND_POINTS = [
183
183
  { x: 22, y: 84 },
184
184
  { x: 8, y: 58 },
185
185
  ];
186
- /** Converts recorded `BlurAnnotation`s into OpenScreen `type: "blur"` regions. */
186
+ /** Converts recorded `BlurAnnotation`s into OpenScreen `type: "blur"` regions (skipping DOM-blurred elements). */
187
187
  export function blurAnnotations(blurs, opts) {
188
188
  const z0 = opts.startZIndex ?? 1;
189
- return blurs.map((b, i) => {
189
+ const overlayBlurs = blurs.filter((b) => b.mode !== "dom");
190
+ return overlayBlurs.map((b, i) => {
191
+ const endMs = b.endMs === "end" ? Math.max(b.startMs + 100, opts.durationMs) : b.endMs;
190
192
  let x;
191
193
  let y;
192
194
  let width;
@@ -202,7 +204,9 @@ export function blurAnnotations(blurs, opts) {
202
204
  width: b.box.width + pad * 2,
203
205
  height: b.box.height + pad * 2,
204
206
  };
205
- const stage = boxToStage(opts.layout, opts.viewport, padded);
207
+ const rawStage = boxToStage(opts.layout, opts.viewport, padded);
208
+ const sampleT = Math.min(endMs, b.startMs + Math.min(350, (endMs - b.startMs) / 2));
209
+ const stage = opts.zoomRegions?.length ? applyCamera(rawStage, opts.zoomRegions, sampleT) : rawStage;
206
210
  x = stage.x * 100;
207
211
  y = stage.y * 100;
208
212
  width = stage.w * 100;
@@ -214,7 +218,6 @@ export function blurAnnotations(blurs, opts) {
214
218
  width = 20;
215
219
  height = 10;
216
220
  }
217
- const endMs = b.endMs === "end" ? Math.max(b.startMs + 100, opts.durationMs) : b.endMs;
218
221
  return {
219
222
  id: `blur-${i + 1}`,
220
223
  startMs: Math.round(b.startMs),
@@ -237,7 +240,7 @@ export function blurAnnotations(blurs, opts) {
237
240
  });
238
241
  }
239
242
  /** Places a directional arrow box just outside a target rect pointing toward it. */
240
- function arrowRectForTarget(stage, dir, sizePct) {
243
+ export function arrowRectForTarget(stage, dir, sizePct) {
241
244
  const tx = stage.x * 100;
242
245
  const ty = stage.y * 100;
243
246
  const tw = stage.w * 100;
@@ -275,16 +278,24 @@ function arrowRectForTarget(stage, dir, sizePct) {
275
278
  }
276
279
  return { x: clampPct(x, 0, 100 - w), y: clampPct(y, 0, 100 - h), width: w, height: h };
277
280
  }
278
- /** Converts recorded `ArrowAnnotation`s into OpenScreen `type: "figure"` arrow regions. */
281
+ /** Converts recorded `ArrowAnnotation`s into OpenScreen `type: "figure"` arrow regions (camera-projected). */
279
282
  export function arrowAnnotations(arrows, opts) {
280
283
  const z0 = opts.startZIndex ?? 1;
281
284
  return arrows.map((a, i) => {
282
285
  const sizePct = Math.min(40, Math.max(3, a.size ?? 9));
283
- const rect = a.rect
284
- ? a.rect
285
- : a.box
286
- ? arrowRectForTarget(boxToStage(opts.layout, opts.viewport, a.box), a.direction, sizePct)
287
- : { x: 45, y: 45, width: sizePct, height: sizePct };
286
+ let rect;
287
+ if (a.rect) {
288
+ rect = a.rect;
289
+ }
290
+ else if (a.box) {
291
+ const rawStage = boxToStage(opts.layout, opts.viewport, a.box);
292
+ const sampleT = Math.min(a.endMs, a.startMs + Math.min(350, (a.endMs - a.startMs) / 2));
293
+ const stage = opts.zoomRegions?.length ? applyCamera(rawStage, opts.zoomRegions, sampleT) : rawStage;
294
+ rect = arrowRectForTarget(stage, a.direction, sizePct);
295
+ }
296
+ else {
297
+ rect = { x: 45, y: 45, width: sizePct, height: sizePct };
298
+ }
288
299
  return {
289
300
  id: `arrow-${i + 1}`,
290
301
  startMs: Math.round(a.startMs),
@@ -366,11 +377,11 @@ export function buildProject(opts) {
366
377
  const layout = stageLayout(viewport, look);
367
378
  const durationMs = opts.durationMs ?? Math.max(1000, ...opts.captions.map((c) => c.endMs), ...(opts.actions ?? []).map((a) => a.endMs));
368
379
  let z = 1;
369
- const blurs = blurAnnotations(opts.blurs ?? [], { viewport, layout, durationMs, startZIndex: z });
380
+ const blurs = blurAnnotations(opts.blurs ?? [], { viewport, layout, durationMs, zoomRegions: opts.zoomRegions, startZIndex: z });
370
381
  z += blurs.length;
371
382
  const images = imageAnnotations(opts.images ?? [], { durationMs, baseDir: opts.baseDir, watermark: look.watermark, startZIndex: z });
372
383
  z += images.length;
373
- const arrows = arrowAnnotations(opts.arrows ?? [], { viewport, layout, startZIndex: z });
384
+ const arrows = arrowAnnotations(opts.arrows ?? [], { viewport, layout, zoomRegions: opts.zoomRegions, startZIndex: z });
374
385
  z += arrows.length;
375
386
  const captions = captionAnnotations(opts.captions, look, z);
376
387
  z += captions.length;
package/dist/scene.d.ts CHANGED
@@ -116,6 +116,12 @@ export interface BlurOptions {
116
116
  blockSize?: number;
117
117
  /** Extra px padding around a DOM target box (default `4`). */
118
118
  padding?: number;
119
+ /**
120
+ * `"auto"` (default): CSS `filter: blur(...)` on DOM elements for Gaussian blur (stays locked
121
+ * through scrolling & camera zooms), OpenScreen post-process overlay for `"mosaic"` or stage rects.
122
+ * Pass `"dom"` or `"overlay"` to force one explicitly.
123
+ */
124
+ mode?: "auto" | "dom" | "overlay";
119
125
  /** Block until `duration` elapses (ignored when `duration === "end"`, default `false`). */
120
126
  wait?: boolean;
121
127
  label?: string;
package/dist/scene.js CHANGED
@@ -6,7 +6,7 @@
6
6
  import fs from "node:fs";
7
7
  import path from "node:path";
8
8
  import { easeAimed, makePath, mulberry32, sleep, travelDuration } from "./motion.js";
9
- import { createVoiceSynthesizer, DEFAULT_VOICE_GAP_MS, DEFAULT_VOICE_PAD_MS, findWordTiming, } from "./voice.js";
9
+ import { chunkVoiceCaptions, createVoiceSynthesizer, DEFAULT_VOICE_GAP_MS, DEFAULT_VOICE_PAD_MS, findWordTiming, } from "./voice.js";
10
10
  function isLocator(target) {
11
11
  return typeof target === "object" && target !== null && typeof target.filter === "function";
12
12
  }
@@ -744,14 +744,37 @@ export class Scene {
744
744
  let box;
745
745
  let rect;
746
746
  let label = opts.label;
747
+ const modePref = opts.mode ?? "auto";
748
+ const useDom = !isStageRect && (modePref === "dom" || (modePref === "auto" && (opts.type ?? "blur") === "blur"));
747
749
  if (isStageRect) {
748
750
  rect = target;
749
751
  label ??= "blur rect";
750
752
  }
751
753
  else {
752
- const inspected = await this.inspect(this.locate(target), target);
754
+ const loc = this.locate(target);
755
+ const inspected = await this.inspect(loc, target);
753
756
  box = inspected.box;
754
757
  label ??= describeTarget(target);
758
+ if (useDom) {
759
+ const intensity = Math.min(40, Math.max(2, opts.intensity ?? 14));
760
+ const blurPx = Math.max(2, Math.round(intensity * 0.65));
761
+ const restoreAfterMs = typeof endMs === "number" ? Math.max(0, endMs - startMs) : null;
762
+ await loc.evaluate((el, o) => {
763
+ const h = el;
764
+ const prevFilter = h.style.filter;
765
+ const prevSelect = h.style.userSelect;
766
+ h.setAttribute("data-demoreel-blur", "");
767
+ h.style.filter = prevFilter ? `${prevFilter} blur(${o.blurPx}px)` : `blur(${o.blurPx}px)`;
768
+ h.style.userSelect = "none";
769
+ if (o.restoreAfterMs !== null) {
770
+ setTimeout(() => {
771
+ h.style.filter = prevFilter;
772
+ h.style.userSelect = prevSelect;
773
+ h.removeAttribute("data-demoreel-blur");
774
+ }, o.restoreAfterMs);
775
+ }
776
+ }, { blurPx, restoreAfterMs });
777
+ }
755
778
  }
756
779
  this.blurs.push({
757
780
  startMs,
@@ -764,6 +787,7 @@ export class Scene {
764
787
  color: opts.color,
765
788
  intensity: opts.intensity,
766
789
  blockSize: opts.blockSize,
790
+ mode: useDom ? "dom" : "overlay",
767
791
  label,
768
792
  });
769
793
  this.record({
@@ -935,7 +959,7 @@ export class Scene {
935
959
  this.lastVoiceEndMs = endMs;
936
960
  const captionsMode = opts.captions ?? this.voiceConfig.captions ?? "vtt";
937
961
  if (captionsMode === "burned") {
938
- this.captions.push({ text, startMs, endMs });
962
+ this.captions.push(...chunkVoiceCaptions(cue));
939
963
  }
940
964
  const padMs = opts.padMs ?? this.voiceConfig.padMs ?? DEFAULT_VOICE_PAD_MS;
941
965
  let wordCursor = 0;
package/dist/types.d.ts CHANGED
@@ -111,6 +111,8 @@ export interface BlurAnnotation {
111
111
  color?: "black" | "white";
112
112
  intensity?: number;
113
113
  blockSize?: number;
114
+ /** `"dom"` = CSS blur injected on the DOM element (tracks zoom & scroll); `"overlay"` = OpenScreen post-process region. */
115
+ mode?: "dom" | "overlay";
114
116
  label?: string;
115
117
  }
116
118
  export interface ArrowAnnotation {
package/dist/voice.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { SpeedRegion, TrimRegion, VoiceCue, WordTiming } from "./types.ts";
1
+ import type { Caption, CaptionAnimation, SpeedRegion, TrimRegion, VoiceCue, WordTiming } from "./types.ts";
2
2
  export type VoiceProviderName = "edge" | "openai" | "elevenlabs" | "gemini" | "cartesia" | "deepgram";
3
3
  export declare const VOICE_PROVIDERS: readonly VoiceProviderName[];
4
4
  export interface VoiceConfig {
@@ -68,6 +68,15 @@ export declare function findWordTiming(timings: WordTiming[], query: string | Re
68
68
  } | null;
69
69
  /** Builds a WebVTT subtitle file from voice cues, mapped onto rendered output timestamps. */
70
70
  export declare function buildVoiceVtt(cues: VoiceCue[], trims?: TrimRegion[], speeds?: SpeedRegion[], wordsPerCue?: number): string;
71
+ /**
72
+ * Splits a spoken `VoiceCue` into balanced, word-timed burned-in `Caption` chunks
73
+ * so longer narrations never overflow or wrap awkwardly on screen. Short cues
74
+ * (`<= maxWords` words or without word timings) stay as a single caption.
75
+ */
76
+ export declare function chunkVoiceCaptions(cue: VoiceCue, opts?: {
77
+ maxWords?: number;
78
+ animation?: CaptionAnimation;
79
+ }): Caption[];
71
80
  /**
72
81
  * Mixes all voice cue `.wav` files into an AAC audio track at their post-trim output timestamps
73
82
  * and stream-copies the video (`-c:v copy`) so OpenScreen's H.264 output is never re-encoded.
package/dist/voice.js CHANGED
@@ -161,6 +161,37 @@ export function buildVoiceVtt(cues, trims = [], speeds = [], wordsPerCue = 8) {
161
161
  }
162
162
  return lines.join("\n");
163
163
  }
164
+ /**
165
+ * Splits a spoken `VoiceCue` into balanced, word-timed burned-in `Caption` chunks
166
+ * so longer narrations never overflow or wrap awkwardly on screen. Short cues
167
+ * (`<= maxWords` words or without word timings) stay as a single caption.
168
+ */
169
+ export function chunkVoiceCaptions(cue, opts = {}) {
170
+ const maxWords = Math.max(1, opts.maxWords ?? 7);
171
+ const anim = opts.animation ? { animation: opts.animation } : {};
172
+ const text = cue.text.trim();
173
+ if (!text)
174
+ return [];
175
+ if (cue.timings.length <= maxWords || cue.timings.length === 0) {
176
+ return [{ text, startMs: cue.startMs, endMs: cue.endMs, ...anim }];
177
+ }
178
+ const numChunks = Math.ceil(cue.timings.length / maxWords);
179
+ const perChunk = Math.ceil(cue.timings.length / numChunks);
180
+ const out = [];
181
+ for (let i = 0; i < cue.timings.length; i += perChunk) {
182
+ const group = cue.timings.slice(i, i + perChunk);
183
+ const nextGroup = cue.timings[i + perChunk];
184
+ const first = group[0];
185
+ const last = group[group.length - 1];
186
+ const startMs = Math.round(cue.startMs + first.offsetMs);
187
+ const naturalEnd = Math.round(cue.startMs + last.offsetMs + last.durationMs);
188
+ const endMs = nextGroup
189
+ ? Math.max(startMs + 200, Math.min(cue.endMs, Math.round(cue.startMs + nextGroup.offsetMs)))
190
+ : Math.max(startMs + 200, cue.endMs, naturalEnd);
191
+ out.push({ text: group.map((w) => w.text).join(" "), startMs, endMs, ...anim });
192
+ }
193
+ return out;
194
+ }
164
195
  /**
165
196
  * Mixes all voice cue `.wav` files into an AAC audio track at their post-trim output timestamps
166
197
  * and stream-copies the video (`-c:v copy`) so OpenScreen's H.264 output is never re-encoded.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@phil65/demoreel",
3
3
  "mcpName": "io.github.phil65/demoreel",
4
- "version": "0.7.1",
4
+ "version": "0.7.2",
5
5
  "private": false,
6
6
  "description": "Scripted product demo videos (videos as code): Playwright scenarios with auto cursor + auto zoom, rendered headless by OpenScreen's exporter.",
7
7
  "keywords": [
@@ -57,8 +57,8 @@ export default defineScenario({
57
57
  renders crisp shortcut keycap pills (`Ctrl + K`, `Esc`) as OpenScreen annotations (also toggleable via `demoreel rezoom --show-keys`).
58
58
  - `clickRipple: true` (or `{ color, size, durationMs }`) adds an expanding translucent ring at each click.
59
59
  - `scene.highlight(target, { dim: true, badge: "..." })` adds a spotlight backdrop dim and optional callout pill.
60
- - `scene.blur(target, { type: "blur" | "mosaic" })` (alias `scene.redact()`) blurs sensitive API keys, emails, or account IDs on the rendered video (defaults to staying blurred until video end).
61
- - `scene.arrow(target, { direction: "down-right", color: "#ffcc00" })` draws a crisp vector arrow pointing at an element.
60
+ - `scene.blur(target, { type: "blur" | "mosaic", mode?: "auto" | "dom" | "overlay" })` (alias `scene.redact()`) blurs sensitive API keys, emails, or account IDs (DOM Gaussian blurs stay locked through scrolling & zooms; defaults to `"end"`).
61
+ - `scene.arrow(target, { direction: "down-right", color: "#ffcc00" })` draws a crisp camera-projected vector arrow pointing at an element.
62
62
  - `scene.image("./badge.png", { x, y, width, height })` and `look: { watermark: { src: "./logo.png", position: "bottom-right" } }` render image/logo overlays.
63
63
  - `look: { captionAnimation: "fade" | "rise" | "pop" | "typewriter", showBlur: true, crop: { x, y, width, height } }` tune caption animations, blurred wallpaper backdrop, and frame crop.
64
64
  - `cursor: { size, clickBounce, smoothing, motionBlur, show }` tunes OpenScreen's rendered cursor per scenario.
@@ -82,7 +82,7 @@ export default defineScenario({
82
82
  bright default gradients.
83
83
  - **Voiceover narration (`scene.say`)**: backed by `@phil65/anyvoice` (defaults to free `edge` TTS with SHA-256 disk caching; also supports `openai` and `gemini` with delivery `instructions`, `cartesia` and `elevenlabs` with native word timestamps, and `deepgram` Aura-2).
84
84
  - Set `voice: { provider: "edge", voice: "en-US-AndrewMultilingualNeural", speed: 1.05 }` on the scenario.
85
- - Chain short beats (`await scene.say("Welcome.")`) or narrate *while* acting (`await scene.say("Pick Bracket and orbit.", async (cue) => { await scene.click(...); await cue.at("orbit", -150); await scene.drag(...); })`) — `demoreel` automatically holds if actions finish faster than speech, prevents overlapping cues, protects voice cues from `trimIdle`, muxes AAC audio into the rendered MP4, and writes `<name>.vtt` subtitles (opt-in `captions: "burned"` to also draw on-video).
85
+ - Chain short beats (`await scene.say("Welcome.")`) or narrate *while* acting (`await scene.say("Pick Bracket and orbit.", async (cue) => { await scene.click(...); await cue.at("orbit", -150); await scene.drag(...); })`) — `demoreel` automatically holds if actions finish faster than speech, prevents overlapping cues, protects voice cues from `trimIdle`, muxes AAC audio into the rendered MP4, and writes `<name>.vtt` subtitles (opt-in `captions: "burned"` draws balanced word-chunked captions on-video).
86
86
  - Always run `--dry-run` first so the SHA-256 voice cache is warmed (<1ms hits during real recording), and check the printed **voice lint** findings (`voice-overlap`, `voice-clipped-end`, `voice-longer-than-action`, `voice-long-cue`) alongside `framesheet` — that's how you verify audio pacing without listening to the MP4.
87
87
  - Override on the CLI/MCP without editing the scenario: `--voice-provider openai --voice nova` for studio final cuts, or `--no-voice` to test visuals silently.
88
88
  - **AI / streaming apps**: mock only the LLM fetch/SSE boundary via `scene.page.evaluate(...)`