@phil65/demoreel 0.6.0 → 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.
Files changed (37) hide show
  1. package/README.md +8 -5
  2. package/THIRD_PARTY_NOTICES.md +1 -1
  3. package/dist/args.js +1 -1
  4. package/dist/cli.js +3 -3
  5. package/dist/compose.d.ts +9 -1
  6. package/dist/compose.js +38 -3
  7. package/dist/idle.js +1 -1
  8. package/dist/index.d.ts +3 -3
  9. package/dist/index.js +2 -2
  10. package/dist/layout.d.ts +10 -1
  11. package/dist/layout.js +41 -0
  12. package/dist/marks.d.ts +7 -12
  13. package/dist/marks.js +73 -43
  14. package/dist/mcp.js +2 -2
  15. package/dist/project.d.ts +261 -11
  16. package/dist/project.js +255 -8
  17. package/dist/record.js +8 -0
  18. package/dist/renderer/assets/{CanvasPool-PBu3bHFZ.js → CanvasPool-SkgMbnEH.js} +1 -1
  19. package/dist/renderer/assets/{CanvasRenderer-HmF-4gyW.js → CanvasRenderer-CEGuSdsG.js} +1 -1
  20. package/dist/renderer/assets/{RenderTargetSystem-Dk1U4wDJ.js → RenderTargetSystem-um8Nv1HQ.js} +1 -1
  21. package/dist/renderer/assets/{WebGLRenderer-C0v9HBel.js → WebGLRenderer-BnY2xfDL.js} +1 -1
  22. package/dist/renderer/assets/{WebGPURenderer-Ce0-U9Q1.js → WebGPURenderer-D9KI_sD9.js} +1 -1
  23. package/dist/renderer/assets/{browserAll-DhvWQ7nM.js → browserAll-vQt6iTAv.js} +1 -1
  24. package/dist/renderer/assets/{canvasUtils-KRroregW.js → canvasUtils-CZLntkW8.js} +1 -1
  25. package/dist/renderer/assets/{getTexelRangeRects-D3pwCyRt.js → getTexelRangeRects-CRAnqulP.js} +1 -1
  26. package/dist/renderer/assets/{index-CE-lli1m.js → index-41-d13J1.js} +4 -4
  27. package/dist/renderer/assets/{init-DfmWKarH.js → init-D6nA7FlC.js} +1 -1
  28. package/dist/renderer/assets/webworkerAll-BEIrFubI.js +1 -0
  29. package/dist/renderer/index.html +1 -1
  30. package/dist/scene.d.ts +93 -1
  31. package/dist/scene.js +177 -3
  32. package/dist/types.d.ts +73 -1
  33. package/dist/voice.d.ts +18 -6
  34. package/dist/voice.js +74 -6
  35. package/package.json +2 -2
  36. package/skills/demoreel/SKILL.md +6 -2
  37. package/dist/renderer/assets/webworkerAll-B41hok0-.js +0 -1
@@ -1,4 +1,4 @@
1
- import{B as e,Ct as t,Dt as n,Et as r,H as i,L as a,M as o,R as s,Z as c,b as l,ct as u,dt as d,ut as f,z as p}from"./index-CE-lli1m.js";import{t as m}from"./canvasUtils-KRroregW.js";import{t as h}from"./CanvasPool-PBu3bHFZ.js";var g=new t;function _(e,t){t.clear();let n=t.matrix;for(let n=0;n<e.length;n++){let r=e[n];if(r.globalDisplayStatus<7)continue;let i=r.renderGroup??r.parentRenderGroup;t.matrix=i?.isCachedAsTexture?g.copyFrom(i.textureOffsetInverseTransform).append(r.worldTransform):i?._parentCacheAsTextureRenderGroup?g.copyFrom(i._parentCacheAsTextureRenderGroup.inverseWorldTransform).append(r.groupTransform):r.worldTransform,t.addBounds(r.bounds)}return t.matrix=n,t}var v=new f;function y(e,t,n,r,i=!1,a){let o=v;o.minX=0,o.minY=0,o.maxX=e.width/r|0,o.maxY=e.height/r|0;let s=c.getOptimalTexture({width:o.width,height:o.height,resolution:r,autoGenerateMipmaps:i,scaleMode:a});return s.source.uploadMethodId=`image`,s.source.resource=e,s.source.alphaMode=`premultiply-alpha-on-upload`,s.frame.width=t/r,s.frame.height=n/r,s.source.emit(`update`,s.source),s.updateUvs(),s}function b(e){return typeof e.getCanvasFilterString==`function`}var x=class{constructor(){this.skip=!1,this.useClip=!1,this.filters=null,this.container=null,this.bounds=new f,this.cssFilterString=``}},S=class{constructor(e){this._filterStack=[],this._filterStackIndex=0,this._savedStates=[],this._alphaMultiplier=1,this._warnedFilterTypes=new Set,this.renderer=e}push(e){let t=this._pushFilterFrame(),n=e.filterEffect.filters;if(t.skip=!1,t.useClip=!1,t.filters=n,t.container=e.container,t.cssFilterString=``,n.every(e=>!e.enabled)){t.skip=!0;return}let r=[];for(let e of n){if(!e.enabled)continue;if(!b(e)){this._warnUnsupportedFilter(e);continue}let t=e.getCanvasFilterString();t===null?this._warnUnsupportedFilter(e):t&&r.push(t)}if(r.length===0){t.skip=!0;return}t.cssFilterString=r.join(` `),this._calculateFilterArea(e,t.bounds),t.useClip=!!e.filterEffect.filterArea;let i=this.renderer.canvasContext.activeContext,a=i.filter||`none`;if(this._savedStates.push({filter:a,alphaMultiplier:this._alphaMultiplier}),t.useClip&&Number.isFinite(t.bounds.width)&&Number.isFinite(t.bounds.height)&&t.bounds.width>0&&t.bounds.height>0){let e=this.renderer.canvasContext.activeResolution||1;i.save(),i.setTransform(1,0,0,1,0,0),i.beginPath(),i.rect(t.bounds.x*e,t.bounds.y*e,t.bounds.width*e,t.bounds.height*e),i.clip()}else t.useClip=!1;t.cssFilterString&&(i.filter=a===`none`?t.cssFilterString:`${a} ${t.cssFilterString}`)}pop(){let e=this._popFilterFrame();if(e.skip)return;let t=this._savedStates.pop();if(!t)return;let n=this.renderer.canvasContext.activeContext;e.useClip?n.restore():n.filter=t.filter,this._alphaMultiplier=t.alphaMultiplier}generateFilteredTexture({texture:e,filters:t}){if(!t?.length||t.every(e=>!e.enabled))return e;let n=[];for(let e of t){if(!e.enabled)continue;if(!b(e)){this._warnUnsupportedFilter(e);continue}let t=e.getCanvasFilterString();t===null?this._warnUnsupportedFilter(e):t&&n.push(t)}if(n.length===0)return e;let r=m.getCanvasSource(e);if(!r)return e;let i=e.frame,a=e.source._resolution??e.source.resolution??1,o=i.width,s=i.height,{canvas:c,context:l}=h.getOptimalCanvasAndContext(o,s,a);l.setTransform(1,0,0,1,0,0),l.clearRect(0,0,c.width,c.height),n.length&&(l.filter=n.join(` `));let u=i.x*a,d=i.y*a,f=o*a,p=s*a;return l.drawImage(r,u,d,f,p,0,0,f,p),l.filter=`none`,l.globalAlpha=1,y(c,o,s,a)}_calculateFilterArea(e,t){if(e.renderables?_(e.renderables,t):e.filterEffect.filterArea?(t.clear(),t.addRect(e.filterEffect.filterArea),t.applyMatrix(e.container.worldTransform)):e.container.getFastGlobalBounds(!0,t),e.container){let n=(e.container.renderGroup||e.container.parentRenderGroup)?.cacheToLocalTransform;n&&t.applyMatrix(n)}}_warnUnsupportedFilter(e){let t=e?.constructor?.name||`Filter`;this._warnedFilterTypes.has(t)||(this._warnedFilterTypes.add(t),console.warn(`CanvasRenderer: filter "${t}" is not supported in Canvas2D and will be skipped.`))}get alphaMultiplier(){return this._alphaMultiplier}_pushFilterFrame(){let e=this._filterStack[this._filterStackIndex];return e||=this._filterStack[this._filterStackIndex]=new x,this._filterStackIndex++,e}_popFilterFrame(){return this._filterStackIndex<=0?this._filterStack[0]:(this._filterStackIndex--,this._filterStack[this._filterStackIndex])}destroy(){this._filterStack=null,this._savedStates=null,this._warnedFilterTypes=null,this._alphaMultiplier=1}};S.extension={type:[r.CanvasSystem],name:`filter`};var C=`in vec2 aPosition;
1
+ import{B as e,Ct as t,Dt as n,Et as r,H as i,L as a,M as o,R as s,Z as c,b as l,ct as u,dt as d,ut as f,z as p}from"./index-41-d13J1.js";import{t as m}from"./canvasUtils-CZLntkW8.js";import{t as h}from"./CanvasPool-SkgMbnEH.js";var g=new t;function _(e,t){t.clear();let n=t.matrix;for(let n=0;n<e.length;n++){let r=e[n];if(r.globalDisplayStatus<7)continue;let i=r.renderGroup??r.parentRenderGroup;t.matrix=i?.isCachedAsTexture?g.copyFrom(i.textureOffsetInverseTransform).append(r.worldTransform):i?._parentCacheAsTextureRenderGroup?g.copyFrom(i._parentCacheAsTextureRenderGroup.inverseWorldTransform).append(r.groupTransform):r.worldTransform,t.addBounds(r.bounds)}return t.matrix=n,t}var v=new f;function y(e,t,n,r,i=!1,a){let o=v;o.minX=0,o.minY=0,o.maxX=e.width/r|0,o.maxY=e.height/r|0;let s=c.getOptimalTexture({width:o.width,height:o.height,resolution:r,autoGenerateMipmaps:i,scaleMode:a});return s.source.uploadMethodId=`image`,s.source.resource=e,s.source.alphaMode=`premultiply-alpha-on-upload`,s.frame.width=t/r,s.frame.height=n/r,s.source.emit(`update`,s.source),s.updateUvs(),s}function b(e){return typeof e.getCanvasFilterString==`function`}var x=class{constructor(){this.skip=!1,this.useClip=!1,this.filters=null,this.container=null,this.bounds=new f,this.cssFilterString=``}},S=class{constructor(e){this._filterStack=[],this._filterStackIndex=0,this._savedStates=[],this._alphaMultiplier=1,this._warnedFilterTypes=new Set,this.renderer=e}push(e){let t=this._pushFilterFrame(),n=e.filterEffect.filters;if(t.skip=!1,t.useClip=!1,t.filters=n,t.container=e.container,t.cssFilterString=``,n.every(e=>!e.enabled)){t.skip=!0;return}let r=[];for(let e of n){if(!e.enabled)continue;if(!b(e)){this._warnUnsupportedFilter(e);continue}let t=e.getCanvasFilterString();t===null?this._warnUnsupportedFilter(e):t&&r.push(t)}if(r.length===0){t.skip=!0;return}t.cssFilterString=r.join(` `),this._calculateFilterArea(e,t.bounds),t.useClip=!!e.filterEffect.filterArea;let i=this.renderer.canvasContext.activeContext,a=i.filter||`none`;if(this._savedStates.push({filter:a,alphaMultiplier:this._alphaMultiplier}),t.useClip&&Number.isFinite(t.bounds.width)&&Number.isFinite(t.bounds.height)&&t.bounds.width>0&&t.bounds.height>0){let e=this.renderer.canvasContext.activeResolution||1;i.save(),i.setTransform(1,0,0,1,0,0),i.beginPath(),i.rect(t.bounds.x*e,t.bounds.y*e,t.bounds.width*e,t.bounds.height*e),i.clip()}else t.useClip=!1;t.cssFilterString&&(i.filter=a===`none`?t.cssFilterString:`${a} ${t.cssFilterString}`)}pop(){let e=this._popFilterFrame();if(e.skip)return;let t=this._savedStates.pop();if(!t)return;let n=this.renderer.canvasContext.activeContext;e.useClip?n.restore():n.filter=t.filter,this._alphaMultiplier=t.alphaMultiplier}generateFilteredTexture({texture:e,filters:t}){if(!t?.length||t.every(e=>!e.enabled))return e;let n=[];for(let e of t){if(!e.enabled)continue;if(!b(e)){this._warnUnsupportedFilter(e);continue}let t=e.getCanvasFilterString();t===null?this._warnUnsupportedFilter(e):t&&n.push(t)}if(n.length===0)return e;let r=m.getCanvasSource(e);if(!r)return e;let i=e.frame,a=e.source._resolution??e.source.resolution??1,o=i.width,s=i.height,{canvas:c,context:l}=h.getOptimalCanvasAndContext(o,s,a);l.setTransform(1,0,0,1,0,0),l.clearRect(0,0,c.width,c.height),n.length&&(l.filter=n.join(` `));let u=i.x*a,d=i.y*a,f=o*a,p=s*a;return l.drawImage(r,u,d,f,p,0,0,f,p),l.filter=`none`,l.globalAlpha=1,y(c,o,s,a)}_calculateFilterArea(e,t){if(e.renderables?_(e.renderables,t):e.filterEffect.filterArea?(t.clear(),t.addRect(e.filterEffect.filterArea),t.applyMatrix(e.container.worldTransform)):e.container.getFastGlobalBounds(!0,t),e.container){let n=(e.container.renderGroup||e.container.parentRenderGroup)?.cacheToLocalTransform;n&&t.applyMatrix(n)}}_warnUnsupportedFilter(e){let t=e?.constructor?.name||`Filter`;this._warnedFilterTypes.has(t)||(this._warnedFilterTypes.add(t),console.warn(`CanvasRenderer: filter "${t}" is not supported in Canvas2D and will be skipped.`))}get alphaMultiplier(){return this._alphaMultiplier}_pushFilterFrame(){let e=this._filterStack[this._filterStackIndex];return e||=this._filterStack[this._filterStackIndex]=new x,this._filterStackIndex++,e}_popFilterFrame(){return this._filterStackIndex<=0?this._filterStack[0]:(this._filterStackIndex--,this._filterStack[this._filterStackIndex])}destroy(){this._filterStack=null,this._savedStates=null,this._warnedFilterTypes=null,this._alphaMultiplier=1}};S.extension={type:[r.CanvasSystem],name:`filter`};var C=`in vec2 aPosition;
2
2
  out vec2 vTextureCoord;
3
3
 
4
4
  uniform vec4 uInputSize;
@@ -0,0 +1 @@
1
+ import"./index-41-d13J1.js";import"./init-D6nA7FlC.js";
@@ -1,6 +1,6 @@
1
1
  <!doctype html>
2
2
  <html>
3
- <head><meta charset="utf-8" /><title>demoreel renderer</title> <script type="module" crossorigin src="./assets/index-CE-lli1m.js"></script>
3
+ <head><meta charset="utf-8" /><title>demoreel renderer</title> <script type="module" crossorigin src="./assets/index-41-d13J1.js"></script>
4
4
  </head>
5
5
  <body style="margin:0;background:#111;color:#ddd;font:14px sans-serif">
6
6
  <div id="status">demoreel headless renderer</div>
package/dist/scene.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { Locator, Page } from "playwright";
2
2
  import { type Point } from "./motion.ts";
3
- import type { ActionRecord, Caption, CursorSample, Depth, Viewport, VoiceCue, ZoomHint } from "./types.ts";
3
+ import type { ActionRecord, ArrowAnnotation, ArrowDirection, BlurAnnotation, Caption, CaptionAnimation, CursorSample, Depth, ImageAnnotation, Viewport, VoiceCue, ZoomHint } from "./types.ts";
4
4
  import { type SayDeliveryOptions, type VoiceConfig, type VoiceSynthesizer } from "./voice.ts";
5
5
  /** Minimal recording clock (satisfied by ScreencastRecorder and dry-run clocks). */
6
6
  export interface SceneClock {
@@ -101,6 +101,61 @@ export interface HighlightOptions {
101
101
  wait?: boolean;
102
102
  label?: string;
103
103
  }
104
+ export interface BlurOptions {
105
+ /** How long the blur stays active (ms, or `"end"` to blur until the end of the video; default `"end"`). */
106
+ duration?: number | "end";
107
+ /** `"blur"` (Gaussian, default) or `"mosaic"` (pixelated blocks). */
108
+ type?: "blur" | "mosaic";
109
+ /** `"rectangle"` (default) or `"oval"`. */
110
+ shape?: "rectangle" | "oval";
111
+ /** Blur tint (`"black"` default, or `"white"`). */
112
+ color?: "black" | "white";
113
+ /** Blur intensity (`2..40`, default `14`). */
114
+ intensity?: number;
115
+ /** Mosaic block size (`4..48`, default `12`, used when `type: "mosaic"`). */
116
+ blockSize?: number;
117
+ /** Extra px padding around a DOM target box (default `4`). */
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";
125
+ /** Block until `duration` elapses (ignored when `duration === "end"`, default `false`). */
126
+ wait?: boolean;
127
+ label?: string;
128
+ }
129
+ export interface ArrowOptions {
130
+ /** Direction the arrow points (default `"down-right"`). */
131
+ direction?: ArrowDirection;
132
+ /** Stroke colour (default `"#ffcc00"`). */
133
+ color?: string;
134
+ /** Stroke thickness in px (default `4`). */
135
+ strokeWidth?: number;
136
+ /** Arrow box size in percent of canvas width/height (default `9`). */
137
+ size?: number;
138
+ /** How long the arrow stays visible (ms, default `2200`). */
139
+ duration?: number;
140
+ /** Block until the arrow disappears (default `false`). */
141
+ wait?: boolean;
142
+ label?: string;
143
+ }
144
+ export interface ImageOptions {
145
+ /** Stage-percent left coordinate (`0..100`, default `68`). */
146
+ x?: number;
147
+ /** Stage-percent top coordinate (`0..100`, default `10`). */
148
+ y?: number;
149
+ /** Stage-percent width (`1..100`, default `26`). */
150
+ width?: number;
151
+ /** Stage-percent height (`1..100`, default `26`). */
152
+ height?: number;
153
+ /** Duration in ms, or `"end"` to remain until the end of the recording (default `2600`). */
154
+ duration?: number | "end";
155
+ /** Block until `duration` elapses (default `false`). */
156
+ wait?: boolean;
157
+ label?: string;
158
+ }
104
159
  export interface PressOptions {
105
160
  label?: string;
106
161
  /** Show a keycap HUD overlay for this key press (overrides `look.showKeys`). */
@@ -139,6 +194,9 @@ export declare class Scene {
139
194
  readonly samples: CursorSample[];
140
195
  readonly actions: ActionRecord[];
141
196
  readonly captions: Caption[];
197
+ readonly blurs: BlurAnnotation[];
198
+ readonly arrows: ArrowAnnotation[];
199
+ readonly images: ImageAnnotation[];
142
200
  readonly voiceCues: VoiceCue[];
143
201
  private cursor;
144
202
  private cursorKind;
@@ -246,7 +304,41 @@ export declare class Scene {
246
304
  caption(text: string, opts?: {
247
305
  duration?: number;
248
306
  wait?: boolean;
307
+ animation?: CaptionAnimation;
249
308
  }): Promise<void>;
309
+ /**
310
+ * Blurs or pixelates (`type: "mosaic"`) a DOM element or stage-percent rect (`{ x, y, width, height }`)
311
+ * using OpenScreen's native blur annotation — ideal for redacting API keys, emails, or account IDs.
312
+ * Defaults to staying blurred until the end of the recording (`duration: "end"`).
313
+ */
314
+ blur(target: Target | {
315
+ x: number;
316
+ y: number;
317
+ width: number;
318
+ height: number;
319
+ }, opts?: BlurOptions): Promise<void>;
320
+ /** Readable alias for `scene.blur(target, opts)` (redacting sensitive UI elements). */
321
+ redact(target: Target | {
322
+ x: number;
323
+ y: number;
324
+ width: number;
325
+ height: number;
326
+ }, opts?: BlurOptions): Promise<void>;
327
+ /**
328
+ * Draws a crisp OpenScreen vector arrow pointing at a DOM element (or inside a stage-percent rect).
329
+ * Non-blocking unless `wait` is set.
330
+ */
331
+ arrow(target: Target | {
332
+ x: number;
333
+ y: number;
334
+ width: number;
335
+ height: number;
336
+ }, opts?: ArrowOptions): Promise<void>;
337
+ /**
338
+ * Overlays an image/logo (local PNG/JPG/SVG/WebP path or `data:image/...` URL) on the rendered
339
+ * canvas at stage-percent coordinates (`0..100`). Non-blocking unless `wait` is set.
340
+ */
341
+ image(src: string, opts?: ImageOptions): Promise<void>;
250
342
  private getVoiceSynthesizer;
251
343
  /**
252
344
  * Speaks a voiceover line (synthesized & cached via `@phil65/anyvoice`), automatically synced
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
  }
@@ -118,6 +118,9 @@ export class Scene {
118
118
  samples = [];
119
119
  actions = [];
120
120
  captions = [];
121
+ blurs = [];
122
+ arrows = [];
123
+ images = [];
121
124
  voiceCues = [];
122
125
  cursor;
123
126
  cursorKind = "arrow";
@@ -712,10 +715,181 @@ export class Scene {
712
715
  await this.ensureRecording();
713
716
  const duration = this.ms(opts.duration ?? 2600);
714
717
  const startMs = this.now();
715
- this.captions.push({ text, startMs, endMs: startMs + duration });
718
+ this.captions.push({
719
+ text,
720
+ startMs,
721
+ endMs: startMs + duration,
722
+ ...(opts.animation ? { animation: opts.animation } : {}),
723
+ });
716
724
  if (opts.wait && !this.fast)
717
725
  await sleep(duration);
718
726
  }
727
+ /**
728
+ * Blurs or pixelates (`type: "mosaic"`) a DOM element or stage-percent rect (`{ x, y, width, height }`)
729
+ * using OpenScreen's native blur annotation — ideal for redacting API keys, emails, or account IDs.
730
+ * Defaults to staying blurred until the end of the recording (`duration: "end"`).
731
+ */
732
+ async blur(target, opts = {}) {
733
+ await this.ensureRecording();
734
+ const startMs = this.now();
735
+ const dur = opts.duration ?? "end";
736
+ const endMs = dur === "end" ? "end" : startMs + this.ms(dur);
737
+ const isStageRect = typeof target === "object" &&
738
+ target !== null &&
739
+ !isLocator(target) &&
740
+ "x" in target &&
741
+ "y" in target &&
742
+ "width" in target &&
743
+ "height" in target;
744
+ let box;
745
+ let rect;
746
+ let label = opts.label;
747
+ const modePref = opts.mode ?? "auto";
748
+ const useDom = !isStageRect && (modePref === "dom" || (modePref === "auto" && (opts.type ?? "blur") === "blur"));
749
+ if (isStageRect) {
750
+ rect = target;
751
+ label ??= "blur rect";
752
+ }
753
+ else {
754
+ const loc = this.locate(target);
755
+ const inspected = await this.inspect(loc, target);
756
+ box = inspected.box;
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
+ }
778
+ }
779
+ this.blurs.push({
780
+ startMs,
781
+ endMs,
782
+ ...(box ? { box } : {}),
783
+ ...(rect ? { rect } : {}),
784
+ padding: opts.padding,
785
+ type: opts.type,
786
+ shape: opts.shape,
787
+ color: opts.color,
788
+ intensity: opts.intensity,
789
+ blockSize: opts.blockSize,
790
+ mode: useDom ? "dom" : "overlay",
791
+ label,
792
+ });
793
+ this.record({
794
+ kind: "blur",
795
+ startMs,
796
+ arriveMs: startMs,
797
+ endMs: typeof endMs === "number" ? endMs : startMs,
798
+ ...(box ? { box } : {}),
799
+ zoom: false,
800
+ label,
801
+ });
802
+ if (opts.wait && typeof endMs === "number" && !this.fast) {
803
+ await sleep(Math.max(0, endMs - this.now()));
804
+ }
805
+ }
806
+ /** Readable alias for `scene.blur(target, opts)` (redacting sensitive UI elements). */
807
+ async redact(target, opts = {}) {
808
+ return this.blur(target, opts);
809
+ }
810
+ /**
811
+ * Draws a crisp OpenScreen vector arrow pointing at a DOM element (or inside a stage-percent rect).
812
+ * Non-blocking unless `wait` is set.
813
+ */
814
+ async arrow(target, opts = {}) {
815
+ await this.ensureRecording();
816
+ const startMs = this.now();
817
+ const duration = this.ms(opts.duration ?? 2200);
818
+ const endMs = startMs + duration;
819
+ const isStageRect = typeof target === "object" &&
820
+ target !== null &&
821
+ !isLocator(target) &&
822
+ "x" in target &&
823
+ "y" in target &&
824
+ "width" in target &&
825
+ "height" in target;
826
+ let box;
827
+ let rect;
828
+ let label = opts.label;
829
+ if (isStageRect) {
830
+ rect = target;
831
+ label ??= "arrow";
832
+ }
833
+ else {
834
+ const inspected = await this.prepare(target);
835
+ box = inspected.box;
836
+ label ??= describeTarget(target);
837
+ }
838
+ this.arrows.push({
839
+ startMs,
840
+ endMs,
841
+ ...(box ? { box } : {}),
842
+ ...(rect ? { rect } : {}),
843
+ direction: opts.direction ?? "down-right",
844
+ color: opts.color,
845
+ strokeWidth: opts.strokeWidth,
846
+ size: opts.size,
847
+ label,
848
+ });
849
+ this.record({
850
+ kind: "arrow",
851
+ startMs,
852
+ arriveMs: startMs,
853
+ endMs,
854
+ ...(box ? { box } : {}),
855
+ zoom: false,
856
+ label,
857
+ });
858
+ if (opts.wait && !this.fast)
859
+ await sleep(duration);
860
+ }
861
+ /**
862
+ * Overlays an image/logo (local PNG/JPG/SVG/WebP path or `data:image/...` URL) on the rendered
863
+ * canvas at stage-percent coordinates (`0..100`). Non-blocking unless `wait` is set.
864
+ */
865
+ async image(src, opts = {}) {
866
+ await this.ensureRecording();
867
+ const startMs = this.now();
868
+ const dur = opts.duration ?? 2600;
869
+ const endMs = dur === "end" ? "end" : startMs + this.ms(dur);
870
+ const label = opts.label ?? (src.startsWith("data:") ? "image" : path.basename(src));
871
+ this.images.push({
872
+ startMs,
873
+ endMs,
874
+ src,
875
+ x: opts.x ?? 68,
876
+ y: opts.y ?? 10,
877
+ width: opts.width ?? 26,
878
+ height: opts.height ?? 26,
879
+ label,
880
+ });
881
+ this.record({
882
+ kind: "image",
883
+ startMs,
884
+ arriveMs: startMs,
885
+ endMs: typeof endMs === "number" ? endMs : startMs,
886
+ zoom: false,
887
+ label,
888
+ });
889
+ if (opts.wait && typeof endMs === "number" && !this.fast) {
890
+ await sleep(Math.max(0, endMs - this.now()));
891
+ }
892
+ }
719
893
  getVoiceSynthesizer() {
720
894
  if (!this.voiceSynthesizer) {
721
895
  this.voiceSynthesizer = createVoiceSynthesizer(this.voiceConfig);
@@ -785,7 +959,7 @@ export class Scene {
785
959
  this.lastVoiceEndMs = endMs;
786
960
  const captionsMode = opts.captions ?? this.voiceConfig.captions ?? "vtt";
787
961
  if (captionsMode === "burned") {
788
- this.captions.push({ text, startMs, endMs });
962
+ this.captions.push(...chunkVoiceCaptions(cue));
789
963
  }
790
964
  const padMs = opts.padMs ?? this.voiceConfig.padMs ?? DEFAULT_VOICE_PAD_MS;
791
965
  let wordCursor = 0;
package/dist/types.d.ts CHANGED
@@ -21,7 +21,7 @@ export interface CursorSample {
21
21
  interactionType?: "move" | "click" | "mouseup";
22
22
  assetId?: string | null;
23
23
  }
24
- export type ActionKind = "goto" | "click" | "select" | "drag" | "type" | "hover" | "scroll" | "pause" | "caption" | "press" | "move" | "zoom" | "highlight" | "say";
24
+ export type ActionKind = "goto" | "click" | "select" | "drag" | "type" | "hover" | "scroll" | "pause" | "caption" | "press" | "move" | "zoom" | "highlight" | "blur" | "arrow" | "image" | "say";
25
25
  /** One scripted step, as it actually happened during recording. */
26
26
  export interface ActionRecord {
27
27
  kind: ActionKind;
@@ -77,6 +77,75 @@ export interface Caption {
77
77
  endMs: number;
78
78
  /** Resolved placement (set by demoreel when the look's captionPosition is "auto"). */
79
79
  position?: "top" | "bottom";
80
+ /** Per-caption text animation override (defaults to `look.captionAnimation`). */
81
+ animation?: CaptionAnimation;
82
+ }
83
+ export type CaptionAnimation = "none" | "fade" | "rise" | "pop" | "slide-left" | "typewriter" | "pulse";
84
+ export type ArrowDirection = "up" | "down" | "left" | "right" | "up-right" | "up-left" | "down-right" | "down-left";
85
+ export interface CropRegion {
86
+ /** Normalized left offset (0..1). */
87
+ x: number;
88
+ /** Normalized top offset (0..1). */
89
+ y: number;
90
+ /** Normalized width (0..1). */
91
+ width: number;
92
+ /** Normalized height (0..1). */
93
+ height: number;
94
+ }
95
+ export interface BlurAnnotation {
96
+ startMs: number;
97
+ /** End time in ms, or `"end"` to stay blurred until the end of the recording. */
98
+ endMs: number | "end";
99
+ /** Target DOM element box in viewport CSS px (mapped through stage padding + camera). */
100
+ box?: Box;
101
+ /** Explicit stage-percent rect (`0..100`) if not targeting a DOM element. */
102
+ rect?: {
103
+ x: number;
104
+ y: number;
105
+ width: number;
106
+ height: number;
107
+ };
108
+ padding?: number;
109
+ type?: "blur" | "mosaic";
110
+ shape?: "rectangle" | "oval";
111
+ color?: "black" | "white";
112
+ intensity?: number;
113
+ blockSize?: number;
114
+ /** `"dom"` = CSS blur injected on the DOM element (tracks zoom & scroll); `"overlay"` = OpenScreen post-process region. */
115
+ mode?: "dom" | "overlay";
116
+ label?: string;
117
+ }
118
+ export interface ArrowAnnotation {
119
+ startMs: number;
120
+ endMs: number;
121
+ /** Target DOM element box in viewport CSS px to point at. */
122
+ box?: Box;
123
+ /** Explicit stage-percent rect (`0..100`) if not targeting a DOM element. */
124
+ rect?: {
125
+ x: number;
126
+ y: number;
127
+ width: number;
128
+ height: number;
129
+ };
130
+ direction: ArrowDirection;
131
+ color?: string;
132
+ strokeWidth?: number;
133
+ /** Arrow box size in percent of canvas width/height (default `9`). */
134
+ size?: number;
135
+ label?: string;
136
+ }
137
+ export interface ImageAnnotation {
138
+ startMs: number;
139
+ endMs: number | "end";
140
+ /** Data URL (`data:image/...`) or local file path (resolved & embedded when building the project). */
141
+ src: string;
142
+ /** Stage-percent position (`0..100`). */
143
+ x: number;
144
+ y: number;
145
+ /** Stage-percent size (`1..100`). */
146
+ width: number;
147
+ height: number;
148
+ label?: string;
80
149
  }
81
150
  /** OpenScreen trim region: the range is cut from the output. */
82
151
  export interface TrimRegion {
@@ -125,6 +194,9 @@ export interface RecordingResult {
125
194
  samples: CursorSample[];
126
195
  actions: ActionRecord[];
127
196
  captions: Caption[];
197
+ blurs?: BlurAnnotation[];
198
+ arrows?: ArrowAnnotation[];
199
+ images?: ImageAnnotation[];
128
200
  voiceCues?: VoiceCue[];
129
201
  /** Recording-clock times (ms) of every captured screencast frame (= a visual change). */
130
202
  frameTimes: number[];
package/dist/voice.d.ts CHANGED
@@ -1,16 +1,19 @@
1
- import type { SpeedRegion, TrimRegion, VoiceCue, WordTiming } from "./types.ts";
2
- export type VoiceProviderName = "edge" | "openai" | "elevenlabs";
1
+ import type { Caption, CaptionAnimation, SpeedRegion, TrimRegion, VoiceCue, WordTiming } from "./types.ts";
2
+ export type VoiceProviderName = "edge" | "openai" | "elevenlabs" | "gemini" | "cartesia" | "deepgram";
3
+ export declare const VOICE_PROVIDERS: readonly VoiceProviderName[];
3
4
  export interface VoiceConfig {
4
5
  /** TTS provider (default `"edge"` — free, no API key required). */
5
6
  provider?: VoiceProviderName;
6
- /** Provider voice ID (e.g. `"en-US-AndrewMultilingualNeural"`, `"nova"`). */
7
+ /** Provider voice ID (e.g. `"en-US-AndrewMultilingualNeural"`, `"nova"`, `"Kore"`, `"aura-2-thalia-en"`). */
7
8
  voice?: string;
8
- /** Provider model (e.g. `"gpt-4o-mini-tts"`, `"tts-1"`, `"eleven_flash_v2_5"`). */
9
+ /** Provider model (e.g. `"gpt-4o-mini-tts"`, `"gemini-2.5-flash-preview-tts"`, `"sonic-3"`, `"eleven_flash_v2_5"`). */
9
10
  model?: string;
10
- /** API key override (defaults to `OPENAI_API_KEY` / `ELEVENLABS_API_KEY`). */
11
+ /** API key override (defaults to provider env var: `OPENAI_API_KEY`, `ELEVENLABS_API_KEY`, `GEMINI_API_KEY`, `CARTESIA_API_KEY`, `DEEPGRAM_API_KEY`). */
11
12
  apiKey?: string;
12
- /** Custom base URL for OpenAI-compatible servers (e.g. local Kokoro/Speaches) or ElevenLabs. */
13
+ /** Custom base URL (e.g. local Kokoro/Speaches server for `openai`). */
13
14
  baseUrl?: string;
15
+ /** Optional language/locale hint (BCP-47 for `gemini` e.g. `"en-US"`, ISO-639-1 for `cartesia` e.g. `"en"`). */
16
+ language?: string;
14
17
  /** Default speech speed multiplier (`1.0` = normal). */
15
18
  speed?: number;
16
19
  /** Default pitch offset in Hz (`0` = neutral). */
@@ -65,6 +68,15 @@ export declare function findWordTiming(timings: WordTiming[], query: string | Re
65
68
  } | null;
66
69
  /** Builds a WebVTT subtitle file from voice cues, mapped onto rendered output timestamps. */
67
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[];
68
80
  /**
69
81
  * Mixes all voice cue `.wav` files into an AAC audio track at their post-trim output timestamps
70
82
  * and stream-copies the video (`-c:v copy`) so OpenScreen's H.264 output is never re-encoded.
package/dist/voice.js CHANGED
@@ -7,6 +7,14 @@ import path from "node:path";
7
7
  import { VoiceClient } from "@phil65/anyvoice";
8
8
  import { DemoreelError, ffmpegBin, run } from "./env.js";
9
9
  import { sourceToOutputMs } from "./idle.js";
10
+ export const VOICE_PROVIDERS = [
11
+ "edge",
12
+ "openai",
13
+ "elevenlabs",
14
+ "gemini",
15
+ "cartesia",
16
+ "deepgram",
17
+ ];
10
18
  export const DEFAULT_VOICE_GAP_MS = 250;
11
19
  export const DEFAULT_VOICE_PAD_MS = 220;
12
20
  /** Creates a cached `@phil65/anyvoice` synthesizer from a `VoiceConfig`. */
@@ -33,18 +41,47 @@ export function createVoiceSynthesizer(config = {}, defaultCacheDir = path.resol
33
41
  voice: config.voice,
34
42
  });
35
43
  }
44
+ else if (provider === "gemini") {
45
+ client = VoiceClient.gemini({
46
+ apiKey: config.apiKey,
47
+ baseUrl: config.baseUrl,
48
+ model: config.model,
49
+ voice: config.voice,
50
+ languageCode: config.language,
51
+ });
52
+ }
53
+ else if (provider === "cartesia") {
54
+ client = VoiceClient.cartesia({
55
+ apiKey: config.apiKey,
56
+ baseUrl: config.baseUrl,
57
+ model: config.model,
58
+ voice: config.voice,
59
+ language: config.language,
60
+ });
61
+ }
62
+ else if (provider === "deepgram") {
63
+ client = VoiceClient.deepgram({
64
+ apiKey: config.apiKey,
65
+ baseUrl: config.baseUrl,
66
+ voice: config.voice,
67
+ });
68
+ }
36
69
  else {
37
- throw new DemoreelError(`unknown voice provider: ${String(provider)}`, "use edge, openai, or elevenlabs");
70
+ throw new DemoreelError(`unknown voice provider: ${String(provider)}`, `use ${VOICE_PROVIDERS.join(", ")}`);
38
71
  }
39
72
  }
40
73
  catch (e) {
41
74
  if (e instanceof DemoreelError)
42
75
  throw e;
43
- throw new DemoreelError(`failed to initialise voice provider "${provider}": ${e.message}`, provider === "openai"
44
- ? "set OPENAI_API_KEY or switch to provider: 'edge' (free)"
45
- : provider === "elevenlabs"
46
- ? "set ELEVENLABS_API_KEY or switch to provider: 'edge' (free)"
47
- : undefined);
76
+ const envHint = {
77
+ openai: "OPENAI_API_KEY",
78
+ elevenlabs: "ELEVENLABS_API_KEY",
79
+ gemini: "GEMINI_API_KEY",
80
+ cartesia: "CARTESIA_API_KEY",
81
+ deepgram: "DEEPGRAM_API_KEY",
82
+ };
83
+ const envVar = envHint[provider];
84
+ throw new DemoreelError(`failed to initialise voice provider "${provider}": ${e.message}`, envVar ? `set ${envVar} or switch to provider: 'edge' (free)` : undefined);
48
85
  }
49
86
  const cacheDir = path.resolve(config.cacheDir ?? defaultCacheDir);
50
87
  const cached = client.withCache(cacheDir);
@@ -124,6 +161,37 @@ export function buildVoiceVtt(cues, trims = [], speeds = [], wordsPerCue = 8) {
124
161
  }
125
162
  return lines.join("\n");
126
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
+ }
127
195
  /**
128
196
  * Mixes all voice cue `.wav` files into an AAC audio track at their post-trim output timestamps
129
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.6.0",
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": [
@@ -79,7 +79,7 @@
79
79
  },
80
80
  "dependencies": {
81
81
  "@modelcontextprotocol/server": "^2.4.0",
82
- "@phil65/anyvoice": "^0.2.0",
82
+ "@phil65/anyvoice": "^0.3.0",
83
83
  "zod": "^4.6.7"
84
84
  }
85
85
  }
@@ -57,6 +57,10 @@ 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", 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
+ - `scene.image("./badge.png", { x, y, width, height })` and `look: { watermark: { src: "./logo.png", position: "bottom-right" } }` render image/logo overlays.
63
+ - `look: { captionAnimation: "fade" | "rise" | "pop" | "typewriter", showBlur: true, crop: { x, y, width, height } }` tune caption animations, blurred wallpaper backdrop, and frame crop.
60
64
  - `cursor: { size, clickBounce, smoothing, motionBlur, show }` tunes OpenScreen's rendered cursor per scenario.
61
65
  - `depth` is an **integer tier `1..6`**, not a raw zoom multiplier:
62
66
  `1 = 1.25x`, `2 = 1.5x`, `3 = 1.8x`, `4 = 2.2x`, `5 = 3x`, `6 = 5x`.
@@ -76,9 +80,9 @@ export default defineScenario({
76
80
  - **Dark UIs**: set `colorScheme: "dark"` and pair with a deep slate/indigo `look.wallpaper`
77
81
  gradient (e.g. `linear-gradient(135deg, #0b1022 0%, #1d2d5c 52%, #3a2368 100%)`) rather than
78
82
  bright default gradients.
79
- - **Voiceover narration (`scene.say`)**: backed by `@phil65/anyvoice` (defaults to free `edge` TTS with SHA-256 disk caching; also supports `openai` with `instructions` and `elevenlabs`).
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).
80
84
  - Set `voice: { provider: "edge", voice: "en-US-AndrewMultilingualNeural", speed: 1.05 }` on the scenario.
81
- - 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).
82
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.
83
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.
84
88
  - **AI / streaming apps**: mock only the LLM fetch/SSE boundary via `scene.page.evaluate(...)`
@@ -1 +0,0 @@
1
- import"./index-CE-lli1m.js";import"./init-DfmWKarH.js";