@phil65/demoreel 0.5.1 → 0.7.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 +39 -5
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/dist/args.js +3 -0
- package/dist/cli.js +32 -1
- package/dist/compose.d.ts +15 -1
- package/dist/compose.js +46 -2
- package/dist/idle.d.ts +2 -1
- package/dist/idle.js +3 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/dist/marks.d.ts +2 -1
- package/dist/marks.js +9 -0
- package/dist/mcp.js +40 -2
- package/dist/project.d.ts +247 -11
- package/dist/project.js +244 -8
- package/dist/record.d.ts +5 -1
- package/dist/record.js +26 -6
- package/dist/render.d.ts +2 -0
- package/dist/render.js +35 -2
- package/dist/renderer/assets/{CanvasPool-PBu3bHFZ.js → CanvasPool-SkgMbnEH.js} +1 -1
- package/dist/renderer/assets/{CanvasRenderer-HmF-4gyW.js → CanvasRenderer-CEGuSdsG.js} +1 -1
- package/dist/renderer/assets/{RenderTargetSystem-Dk1U4wDJ.js → RenderTargetSystem-um8Nv1HQ.js} +1 -1
- package/dist/renderer/assets/{WebGLRenderer-C0v9HBel.js → WebGLRenderer-BnY2xfDL.js} +1 -1
- package/dist/renderer/assets/{WebGPURenderer-Ce0-U9Q1.js → WebGPURenderer-D9KI_sD9.js} +1 -1
- package/dist/renderer/assets/{browserAll-DhvWQ7nM.js → browserAll-vQt6iTAv.js} +1 -1
- package/dist/renderer/assets/{canvasUtils-KRroregW.js → canvasUtils-CZLntkW8.js} +1 -1
- package/dist/renderer/assets/{getTexelRangeRects-D3pwCyRt.js → getTexelRangeRects-CRAnqulP.js} +1 -1
- package/dist/renderer/assets/{index-CE-lli1m.js → index-41-d13J1.js} +4 -4
- package/dist/renderer/assets/{init-DfmWKarH.js → init-D6nA7FlC.js} +1 -1
- package/dist/renderer/assets/webworkerAll-BEIrFubI.js +1 -0
- package/dist/renderer/index.html +1 -1
- package/dist/scene.d.ts +132 -6
- package/dist/scene.js +279 -1
- package/dist/types.d.ts +97 -1
- package/dist/voice.d.ts +91 -0
- package/dist/voice.js +353 -0
- package/package.json +2 -1
- package/skills/demoreel/SKILL.md +9 -0
- 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-
|
|
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";
|
package/dist/renderer/index.html
CHANGED
|
@@ -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-
|
|
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,11 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Scenario API on top of Playwright. Every method drives the real page and records what happened
|
|
3
|
-
* (cursor samples on the recording clock, action boxes) so zoom regions and the cursor overlay can
|
|
4
|
-
* be derived afterwards.
|
|
5
|
-
*/
|
|
6
1
|
import type { Locator, Page } from "playwright";
|
|
7
2
|
import { type Point } from "./motion.ts";
|
|
8
|
-
import type { ActionRecord, Caption, CursorSample, Depth, Viewport, ZoomHint } from "./types.ts";
|
|
3
|
+
import type { ActionRecord, ArrowAnnotation, ArrowDirection, BlurAnnotation, Caption, CaptionAnimation, CursorSample, Depth, ImageAnnotation, Viewport, VoiceCue, ZoomHint } from "./types.ts";
|
|
4
|
+
import { type SayDeliveryOptions, type VoiceConfig, type VoiceSynthesizer } from "./voice.ts";
|
|
9
5
|
/** Minimal recording clock (satisfied by ScreencastRecorder and dry-run clocks). */
|
|
10
6
|
export interface SceneClock {
|
|
11
7
|
now(): number;
|
|
@@ -105,6 +101,55 @@ export interface HighlightOptions {
|
|
|
105
101
|
wait?: boolean;
|
|
106
102
|
label?: string;
|
|
107
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
|
+
/** Block until `duration` elapses (ignored when `duration === "end"`, default `false`). */
|
|
120
|
+
wait?: boolean;
|
|
121
|
+
label?: string;
|
|
122
|
+
}
|
|
123
|
+
export interface ArrowOptions {
|
|
124
|
+
/** Direction the arrow points (default `"down-right"`). */
|
|
125
|
+
direction?: ArrowDirection;
|
|
126
|
+
/** Stroke colour (default `"#ffcc00"`). */
|
|
127
|
+
color?: string;
|
|
128
|
+
/** Stroke thickness in px (default `4`). */
|
|
129
|
+
strokeWidth?: number;
|
|
130
|
+
/** Arrow box size in percent of canvas width/height (default `9`). */
|
|
131
|
+
size?: number;
|
|
132
|
+
/** How long the arrow stays visible (ms, default `2200`). */
|
|
133
|
+
duration?: number;
|
|
134
|
+
/** Block until the arrow disappears (default `false`). */
|
|
135
|
+
wait?: boolean;
|
|
136
|
+
label?: string;
|
|
137
|
+
}
|
|
138
|
+
export interface ImageOptions {
|
|
139
|
+
/** Stage-percent left coordinate (`0..100`, default `68`). */
|
|
140
|
+
x?: number;
|
|
141
|
+
/** Stage-percent top coordinate (`0..100`, default `10`). */
|
|
142
|
+
y?: number;
|
|
143
|
+
/** Stage-percent width (`1..100`, default `26`). */
|
|
144
|
+
width?: number;
|
|
145
|
+
/** Stage-percent height (`1..100`, default `26`). */
|
|
146
|
+
height?: number;
|
|
147
|
+
/** Duration in ms, or `"end"` to remain until the end of the recording (default `2600`). */
|
|
148
|
+
duration?: number | "end";
|
|
149
|
+
/** Block until `duration` elapses (default `false`). */
|
|
150
|
+
wait?: boolean;
|
|
151
|
+
label?: string;
|
|
152
|
+
}
|
|
108
153
|
export interface PressOptions {
|
|
109
154
|
label?: string;
|
|
110
155
|
/** Show a keycap HUD overlay for this key press (overrides `look.showKeys`). */
|
|
@@ -112,6 +157,29 @@ export interface PressOptions {
|
|
|
112
157
|
/** How long the keycap HUD stays visible (ms). */
|
|
113
158
|
duration?: number;
|
|
114
159
|
}
|
|
160
|
+
export interface SayOptions extends SayDeliveryOptions {
|
|
161
|
+
/** Wait for the cue to finish speaking before returning (default `true`; always awaited when a callback `fn` is passed). */
|
|
162
|
+
wait?: boolean;
|
|
163
|
+
/** Extra hold after speech finishes (ms, overrides `voice.padMs`, default `220`). */
|
|
164
|
+
padMs?: number;
|
|
165
|
+
/** Minimum breath gap after any previous cue finishes (ms, overrides `voice.gapMs`, default `250`). */
|
|
166
|
+
gapMs?: number;
|
|
167
|
+
/** Override caption mode for this cue (`"vtt" | "burned" | "off"`). */
|
|
168
|
+
captions?: "vtt" | "burned" | "off";
|
|
169
|
+
/** Shown in timeline.json / marks.json (default: truncated spoken text). */
|
|
170
|
+
label?: string;
|
|
171
|
+
}
|
|
172
|
+
export interface VoiceCueHandle {
|
|
173
|
+
readonly cue: VoiceCue;
|
|
174
|
+
/** Waits until this cue's speech (+ padMs) has finished. */
|
|
175
|
+
done(): Promise<void>;
|
|
176
|
+
/**
|
|
177
|
+
* Waits until the narrator reaches `word` (case-insensitive word match, optionally shifted by
|
|
178
|
+
* `offsetMs`, e.g. `-150` to begin moving the cursor just before the word is spoken).
|
|
179
|
+
* Returns immediately if the clock is already past that timestamp or during dry-runs.
|
|
180
|
+
*/
|
|
181
|
+
at(word: string | RegExp, offsetMs?: number): Promise<void>;
|
|
182
|
+
}
|
|
115
183
|
/** Applies a `data-demoreel-zoom` value to an action's zoom setting. */
|
|
116
184
|
export declare function applyZoomAnchor(zoom: boolean | ZoomHint, anchor: {
|
|
117
185
|
value: string;
|
|
@@ -120,6 +188,10 @@ export declare class Scene {
|
|
|
120
188
|
readonly samples: CursorSample[];
|
|
121
189
|
readonly actions: ActionRecord[];
|
|
122
190
|
readonly captions: Caption[];
|
|
191
|
+
readonly blurs: BlurAnnotation[];
|
|
192
|
+
readonly arrows: ArrowAnnotation[];
|
|
193
|
+
readonly images: ImageAnnotation[];
|
|
194
|
+
readonly voiceCues: VoiceCue[];
|
|
123
195
|
private cursor;
|
|
124
196
|
private cursorKind;
|
|
125
197
|
private cursorBox;
|
|
@@ -128,6 +200,10 @@ export declare class Scene {
|
|
|
128
200
|
private startRecording;
|
|
129
201
|
private fast;
|
|
130
202
|
private clickRipple;
|
|
203
|
+
private voiceConfig;
|
|
204
|
+
private voiceSynthesizer;
|
|
205
|
+
private voiceOutDir;
|
|
206
|
+
private lastVoiceEndMs;
|
|
131
207
|
pacing: PacingOptions;
|
|
132
208
|
/** The underlying Playwright page, for anything the Scene API does not cover. */
|
|
133
209
|
readonly page: Page;
|
|
@@ -136,6 +212,9 @@ export declare class Scene {
|
|
|
136
212
|
seed?: number;
|
|
137
213
|
pacing?: Partial<PacingOptions>;
|
|
138
214
|
clickRipple?: boolean | ClickRippleOptions;
|
|
215
|
+
voice?: VoiceConfig;
|
|
216
|
+
voiceSynthesizer?: VoiceSynthesizer;
|
|
217
|
+
voiceOutDir?: string;
|
|
139
218
|
fast?: boolean;
|
|
140
219
|
});
|
|
141
220
|
private ensureRecording;
|
|
@@ -219,5 +298,52 @@ export declare class Scene {
|
|
|
219
298
|
caption(text: string, opts?: {
|
|
220
299
|
duration?: number;
|
|
221
300
|
wait?: boolean;
|
|
301
|
+
animation?: CaptionAnimation;
|
|
222
302
|
}): Promise<void>;
|
|
303
|
+
/**
|
|
304
|
+
* Blurs or pixelates (`type: "mosaic"`) a DOM element or stage-percent rect (`{ x, y, width, height }`)
|
|
305
|
+
* using OpenScreen's native blur annotation — ideal for redacting API keys, emails, or account IDs.
|
|
306
|
+
* Defaults to staying blurred until the end of the recording (`duration: "end"`).
|
|
307
|
+
*/
|
|
308
|
+
blur(target: Target | {
|
|
309
|
+
x: number;
|
|
310
|
+
y: number;
|
|
311
|
+
width: number;
|
|
312
|
+
height: number;
|
|
313
|
+
}, opts?: BlurOptions): Promise<void>;
|
|
314
|
+
/** Readable alias for `scene.blur(target, opts)` (redacting sensitive UI elements). */
|
|
315
|
+
redact(target: Target | {
|
|
316
|
+
x: number;
|
|
317
|
+
y: number;
|
|
318
|
+
width: number;
|
|
319
|
+
height: number;
|
|
320
|
+
}, opts?: BlurOptions): Promise<void>;
|
|
321
|
+
/**
|
|
322
|
+
* Draws a crisp OpenScreen vector arrow pointing at a DOM element (or inside a stage-percent rect).
|
|
323
|
+
* Non-blocking unless `wait` is set.
|
|
324
|
+
*/
|
|
325
|
+
arrow(target: Target | {
|
|
326
|
+
x: number;
|
|
327
|
+
y: number;
|
|
328
|
+
width: number;
|
|
329
|
+
height: number;
|
|
330
|
+
}, opts?: ArrowOptions): Promise<void>;
|
|
331
|
+
/**
|
|
332
|
+
* Overlays an image/logo (local PNG/JPG/SVG/WebP path or `data:image/...` URL) on the rendered
|
|
333
|
+
* canvas at stage-percent coordinates (`0..100`). Non-blocking unless `wait` is set.
|
|
334
|
+
*/
|
|
335
|
+
image(src: string, opts?: ImageOptions): Promise<void>;
|
|
336
|
+
private getVoiceSynthesizer;
|
|
337
|
+
/**
|
|
338
|
+
* Speaks a voiceover line (synthesized & cached via `@phil65/anyvoice`), automatically synced
|
|
339
|
+
* to the recording timeline and muxed into the rendered MP4 (+ `.vtt` subtitles).
|
|
340
|
+
*
|
|
341
|
+
* Three ways to synchronize speech and UI actions:
|
|
342
|
+
* - Standalone beat: `await scene.say("Welcome to FormCAD.")` (holds for speech duration)
|
|
343
|
+
* - Narrate while acting: `await scene.say("Pick Bracket.", async (cue) => { await scene.click(...); })`
|
|
344
|
+
* - Non-blocking: `const cue = await scene.say("...", { wait: false }); ...; await cue.done();`
|
|
345
|
+
*/
|
|
346
|
+
say(text: string): Promise<VoiceCueHandle>;
|
|
347
|
+
say(text: string, fn: (cue: VoiceCueHandle) => Promise<void> | void): Promise<VoiceCueHandle>;
|
|
348
|
+
say(text: string, opts: SayOptions, fn?: (cue: VoiceCueHandle) => Promise<void> | void): Promise<VoiceCueHandle>;
|
|
223
349
|
}
|
package/dist/scene.js
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scenario API on top of Playwright. Every method drives the real page and records what happened
|
|
3
|
+
* (cursor samples on the recording clock, action boxes) so zoom regions and the cursor overlay can
|
|
4
|
+
* be derived afterwards.
|
|
5
|
+
*/
|
|
6
|
+
import fs from "node:fs";
|
|
7
|
+
import path from "node:path";
|
|
1
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";
|
|
2
10
|
function isLocator(target) {
|
|
3
11
|
return typeof target === "object" && target !== null && typeof target.filter === "function";
|
|
4
12
|
}
|
|
@@ -110,6 +118,10 @@ export class Scene {
|
|
|
110
118
|
samples = [];
|
|
111
119
|
actions = [];
|
|
112
120
|
captions = [];
|
|
121
|
+
blurs = [];
|
|
122
|
+
arrows = [];
|
|
123
|
+
images = [];
|
|
124
|
+
voiceCues = [];
|
|
113
125
|
cursor;
|
|
114
126
|
cursorKind = "arrow";
|
|
115
127
|
cursorBox = null;
|
|
@@ -118,6 +130,10 @@ export class Scene {
|
|
|
118
130
|
startRecording;
|
|
119
131
|
fast;
|
|
120
132
|
clickRipple;
|
|
133
|
+
voiceConfig;
|
|
134
|
+
voiceSynthesizer;
|
|
135
|
+
voiceOutDir;
|
|
136
|
+
lastVoiceEndMs = 0;
|
|
121
137
|
pacing;
|
|
122
138
|
/** The underlying Playwright page, for anything the Scene API does not cover. */
|
|
123
139
|
page;
|
|
@@ -130,6 +146,9 @@ export class Scene {
|
|
|
130
146
|
this.rand = mulberry32(opts.seed ?? 42);
|
|
131
147
|
this.pacing = { ...DEFAULT_PACING, ...opts.pacing };
|
|
132
148
|
this.cursor = { x: viewport.width * 0.62, y: viewport.height * 0.72 };
|
|
149
|
+
this.voiceConfig = opts.voice ?? {};
|
|
150
|
+
this.voiceSynthesizer = opts.voiceSynthesizer ?? null;
|
|
151
|
+
this.voiceOutDir = opts.voiceOutDir ?? null;
|
|
133
152
|
this.clickRipple = opts.clickRipple
|
|
134
153
|
? {
|
|
135
154
|
color: (typeof opts.clickRipple === "object" ? opts.clickRipple.color : undefined) ?? "rgba(96, 165, 250, 0.9)",
|
|
@@ -696,8 +715,267 @@ export class Scene {
|
|
|
696
715
|
await this.ensureRecording();
|
|
697
716
|
const duration = this.ms(opts.duration ?? 2600);
|
|
698
717
|
const startMs = this.now();
|
|
699
|
-
this.captions.push({
|
|
718
|
+
this.captions.push({
|
|
719
|
+
text,
|
|
720
|
+
startMs,
|
|
721
|
+
endMs: startMs + duration,
|
|
722
|
+
...(opts.animation ? { animation: opts.animation } : {}),
|
|
723
|
+
});
|
|
700
724
|
if (opts.wait && !this.fast)
|
|
701
725
|
await sleep(duration);
|
|
702
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
|
+
if (isStageRect) {
|
|
748
|
+
rect = target;
|
|
749
|
+
label ??= "blur rect";
|
|
750
|
+
}
|
|
751
|
+
else {
|
|
752
|
+
const inspected = await this.inspect(this.locate(target), target);
|
|
753
|
+
box = inspected.box;
|
|
754
|
+
label ??= describeTarget(target);
|
|
755
|
+
}
|
|
756
|
+
this.blurs.push({
|
|
757
|
+
startMs,
|
|
758
|
+
endMs,
|
|
759
|
+
...(box ? { box } : {}),
|
|
760
|
+
...(rect ? { rect } : {}),
|
|
761
|
+
padding: opts.padding,
|
|
762
|
+
type: opts.type,
|
|
763
|
+
shape: opts.shape,
|
|
764
|
+
color: opts.color,
|
|
765
|
+
intensity: opts.intensity,
|
|
766
|
+
blockSize: opts.blockSize,
|
|
767
|
+
label,
|
|
768
|
+
});
|
|
769
|
+
this.record({
|
|
770
|
+
kind: "blur",
|
|
771
|
+
startMs,
|
|
772
|
+
arriveMs: startMs,
|
|
773
|
+
endMs: typeof endMs === "number" ? endMs : startMs,
|
|
774
|
+
...(box ? { box } : {}),
|
|
775
|
+
zoom: false,
|
|
776
|
+
label,
|
|
777
|
+
});
|
|
778
|
+
if (opts.wait && typeof endMs === "number" && !this.fast) {
|
|
779
|
+
await sleep(Math.max(0, endMs - this.now()));
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
/** Readable alias for `scene.blur(target, opts)` (redacting sensitive UI elements). */
|
|
783
|
+
async redact(target, opts = {}) {
|
|
784
|
+
return this.blur(target, opts);
|
|
785
|
+
}
|
|
786
|
+
/**
|
|
787
|
+
* Draws a crisp OpenScreen vector arrow pointing at a DOM element (or inside a stage-percent rect).
|
|
788
|
+
* Non-blocking unless `wait` is set.
|
|
789
|
+
*/
|
|
790
|
+
async arrow(target, opts = {}) {
|
|
791
|
+
await this.ensureRecording();
|
|
792
|
+
const startMs = this.now();
|
|
793
|
+
const duration = this.ms(opts.duration ?? 2200);
|
|
794
|
+
const endMs = startMs + duration;
|
|
795
|
+
const isStageRect = typeof target === "object" &&
|
|
796
|
+
target !== null &&
|
|
797
|
+
!isLocator(target) &&
|
|
798
|
+
"x" in target &&
|
|
799
|
+
"y" in target &&
|
|
800
|
+
"width" in target &&
|
|
801
|
+
"height" in target;
|
|
802
|
+
let box;
|
|
803
|
+
let rect;
|
|
804
|
+
let label = opts.label;
|
|
805
|
+
if (isStageRect) {
|
|
806
|
+
rect = target;
|
|
807
|
+
label ??= "arrow";
|
|
808
|
+
}
|
|
809
|
+
else {
|
|
810
|
+
const inspected = await this.prepare(target);
|
|
811
|
+
box = inspected.box;
|
|
812
|
+
label ??= describeTarget(target);
|
|
813
|
+
}
|
|
814
|
+
this.arrows.push({
|
|
815
|
+
startMs,
|
|
816
|
+
endMs,
|
|
817
|
+
...(box ? { box } : {}),
|
|
818
|
+
...(rect ? { rect } : {}),
|
|
819
|
+
direction: opts.direction ?? "down-right",
|
|
820
|
+
color: opts.color,
|
|
821
|
+
strokeWidth: opts.strokeWidth,
|
|
822
|
+
size: opts.size,
|
|
823
|
+
label,
|
|
824
|
+
});
|
|
825
|
+
this.record({
|
|
826
|
+
kind: "arrow",
|
|
827
|
+
startMs,
|
|
828
|
+
arriveMs: startMs,
|
|
829
|
+
endMs,
|
|
830
|
+
...(box ? { box } : {}),
|
|
831
|
+
zoom: false,
|
|
832
|
+
label,
|
|
833
|
+
});
|
|
834
|
+
if (opts.wait && !this.fast)
|
|
835
|
+
await sleep(duration);
|
|
836
|
+
}
|
|
837
|
+
/**
|
|
838
|
+
* Overlays an image/logo (local PNG/JPG/SVG/WebP path or `data:image/...` URL) on the rendered
|
|
839
|
+
* canvas at stage-percent coordinates (`0..100`). Non-blocking unless `wait` is set.
|
|
840
|
+
*/
|
|
841
|
+
async image(src, opts = {}) {
|
|
842
|
+
await this.ensureRecording();
|
|
843
|
+
const startMs = this.now();
|
|
844
|
+
const dur = opts.duration ?? 2600;
|
|
845
|
+
const endMs = dur === "end" ? "end" : startMs + this.ms(dur);
|
|
846
|
+
const label = opts.label ?? (src.startsWith("data:") ? "image" : path.basename(src));
|
|
847
|
+
this.images.push({
|
|
848
|
+
startMs,
|
|
849
|
+
endMs,
|
|
850
|
+
src,
|
|
851
|
+
x: opts.x ?? 68,
|
|
852
|
+
y: opts.y ?? 10,
|
|
853
|
+
width: opts.width ?? 26,
|
|
854
|
+
height: opts.height ?? 26,
|
|
855
|
+
label,
|
|
856
|
+
});
|
|
857
|
+
this.record({
|
|
858
|
+
kind: "image",
|
|
859
|
+
startMs,
|
|
860
|
+
arriveMs: startMs,
|
|
861
|
+
endMs: typeof endMs === "number" ? endMs : startMs,
|
|
862
|
+
zoom: false,
|
|
863
|
+
label,
|
|
864
|
+
});
|
|
865
|
+
if (opts.wait && typeof endMs === "number" && !this.fast) {
|
|
866
|
+
await sleep(Math.max(0, endMs - this.now()));
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
getVoiceSynthesizer() {
|
|
870
|
+
if (!this.voiceSynthesizer) {
|
|
871
|
+
this.voiceSynthesizer = createVoiceSynthesizer(this.voiceConfig);
|
|
872
|
+
}
|
|
873
|
+
return this.voiceSynthesizer;
|
|
874
|
+
}
|
|
875
|
+
async say(text, optsOrFn, maybeFn) {
|
|
876
|
+
const opts = typeof optsOrFn === "function" ? {} : (optsOrFn ?? {});
|
|
877
|
+
const fn = typeof optsOrFn === "function" ? optsOrFn : maybeFn;
|
|
878
|
+
await this.ensureRecording();
|
|
879
|
+
if (this.voiceConfig.enabled === false) {
|
|
880
|
+
const now = this.now();
|
|
881
|
+
const cue = {
|
|
882
|
+
id: `cue-${String(this.voiceCues.length + 1).padStart(2, "0")}`,
|
|
883
|
+
text,
|
|
884
|
+
startMs: Math.round(now),
|
|
885
|
+
endMs: Math.round(now),
|
|
886
|
+
durationMs: 0,
|
|
887
|
+
audioFile: "",
|
|
888
|
+
timings: [],
|
|
889
|
+
};
|
|
890
|
+
const noop = {
|
|
891
|
+
cue,
|
|
892
|
+
done: async () => { },
|
|
893
|
+
at: async () => { },
|
|
894
|
+
};
|
|
895
|
+
if (fn)
|
|
896
|
+
await fn(noop);
|
|
897
|
+
return noop;
|
|
898
|
+
}
|
|
899
|
+
const synth = this.getVoiceSynthesizer();
|
|
900
|
+
const audio = await synth.synthesize(text, {
|
|
901
|
+
voice: opts.voice,
|
|
902
|
+
speed: opts.speed,
|
|
903
|
+
pitch: opts.pitch,
|
|
904
|
+
volume: opts.volume,
|
|
905
|
+
instructions: opts.instructions,
|
|
906
|
+
});
|
|
907
|
+
// Anti-overlap: wait for any previous still-speaking cue (+ breath gap) before starting.
|
|
908
|
+
const gapMs = opts.gapMs ?? this.voiceConfig.gapMs ?? DEFAULT_VOICE_GAP_MS;
|
|
909
|
+
if (!this.fast && this.lastVoiceEndMs > 0) {
|
|
910
|
+
const waitUntil = this.lastVoiceEndMs + gapMs;
|
|
911
|
+
const remaining = waitUntil - this.now();
|
|
912
|
+
if (remaining > 0)
|
|
913
|
+
await sleep(remaining);
|
|
914
|
+
}
|
|
915
|
+
const startMs = this.now();
|
|
916
|
+
const endMs = startMs + audio.durationMs;
|
|
917
|
+
const id = `cue-${String(this.voiceCues.length + 1).padStart(2, "0")}`;
|
|
918
|
+
let audioFile = "";
|
|
919
|
+
if (this.voiceOutDir) {
|
|
920
|
+
fs.mkdirSync(this.voiceOutDir, { recursive: true });
|
|
921
|
+
const rel = path.join("voice", `${id}.wav`);
|
|
922
|
+
fs.writeFileSync(path.join(this.voiceOutDir, `${id}.wav`), audio.wav);
|
|
923
|
+
audioFile = rel;
|
|
924
|
+
}
|
|
925
|
+
const cue = {
|
|
926
|
+
id,
|
|
927
|
+
text,
|
|
928
|
+
startMs: Math.round(startMs),
|
|
929
|
+
endMs: Math.round(endMs),
|
|
930
|
+
durationMs: Math.round(audio.durationMs),
|
|
931
|
+
audioFile,
|
|
932
|
+
timings: audio.timings,
|
|
933
|
+
};
|
|
934
|
+
this.voiceCues.push(cue);
|
|
935
|
+
this.lastVoiceEndMs = endMs;
|
|
936
|
+
const captionsMode = opts.captions ?? this.voiceConfig.captions ?? "vtt";
|
|
937
|
+
if (captionsMode === "burned") {
|
|
938
|
+
this.captions.push({ text, startMs, endMs });
|
|
939
|
+
}
|
|
940
|
+
const padMs = opts.padMs ?? this.voiceConfig.padMs ?? DEFAULT_VOICE_PAD_MS;
|
|
941
|
+
let wordCursor = 0;
|
|
942
|
+
const handle = {
|
|
943
|
+
cue,
|
|
944
|
+
done: async () => {
|
|
945
|
+
if (this.fast)
|
|
946
|
+
return;
|
|
947
|
+
const remaining = endMs + padMs - this.now();
|
|
948
|
+
if (remaining > 0)
|
|
949
|
+
await sleep(remaining);
|
|
950
|
+
},
|
|
951
|
+
at: async (word, offsetMs = 0) => {
|
|
952
|
+
if (this.fast)
|
|
953
|
+
return;
|
|
954
|
+
const hit = findWordTiming(cue.timings, word, wordCursor);
|
|
955
|
+
if (!hit)
|
|
956
|
+
return;
|
|
957
|
+
wordCursor = hit.index + 1;
|
|
958
|
+
const targetMs = startMs + hit.timing.offsetMs + offsetMs;
|
|
959
|
+
const remaining = targetMs - this.now();
|
|
960
|
+
if (remaining > 0)
|
|
961
|
+
await sleep(remaining);
|
|
962
|
+
},
|
|
963
|
+
};
|
|
964
|
+
const label = opts.label ?? (text.length > 52 ? `${text.slice(0, 49)}...` : text);
|
|
965
|
+
if (fn) {
|
|
966
|
+
const tAct = this.now();
|
|
967
|
+
await fn(handle);
|
|
968
|
+
cue.actionDurationMs = Math.round(this.now() - tAct);
|
|
969
|
+
await handle.done();
|
|
970
|
+
this.record({ kind: "say", startMs, arriveMs: startMs, endMs: Math.max(endMs, this.now()), text, label });
|
|
971
|
+
}
|
|
972
|
+
else if (opts.wait !== false) {
|
|
973
|
+
await handle.done();
|
|
974
|
+
this.record({ kind: "say", startMs, arriveMs: startMs, endMs: Math.max(endMs, this.now()), text, label });
|
|
975
|
+
}
|
|
976
|
+
else {
|
|
977
|
+
this.record({ kind: "say", startMs, arriveMs: startMs, endMs, text, label });
|
|
978
|
+
}
|
|
979
|
+
return handle;
|
|
980
|
+
}
|
|
703
981
|
}
|
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";
|
|
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,73 @@ 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
|
+
label?: string;
|
|
115
|
+
}
|
|
116
|
+
export interface ArrowAnnotation {
|
|
117
|
+
startMs: number;
|
|
118
|
+
endMs: number;
|
|
119
|
+
/** Target DOM element box in viewport CSS px to point at. */
|
|
120
|
+
box?: Box;
|
|
121
|
+
/** Explicit stage-percent rect (`0..100`) if not targeting a DOM element. */
|
|
122
|
+
rect?: {
|
|
123
|
+
x: number;
|
|
124
|
+
y: number;
|
|
125
|
+
width: number;
|
|
126
|
+
height: number;
|
|
127
|
+
};
|
|
128
|
+
direction: ArrowDirection;
|
|
129
|
+
color?: string;
|
|
130
|
+
strokeWidth?: number;
|
|
131
|
+
/** Arrow box size in percent of canvas width/height (default `9`). */
|
|
132
|
+
size?: number;
|
|
133
|
+
label?: string;
|
|
134
|
+
}
|
|
135
|
+
export interface ImageAnnotation {
|
|
136
|
+
startMs: number;
|
|
137
|
+
endMs: number | "end";
|
|
138
|
+
/** Data URL (`data:image/...`) or local file path (resolved & embedded when building the project). */
|
|
139
|
+
src: string;
|
|
140
|
+
/** Stage-percent position (`0..100`). */
|
|
141
|
+
x: number;
|
|
142
|
+
y: number;
|
|
143
|
+
/** Stage-percent size (`1..100`). */
|
|
144
|
+
width: number;
|
|
145
|
+
height: number;
|
|
146
|
+
label?: string;
|
|
80
147
|
}
|
|
81
148
|
/** OpenScreen trim region: the range is cut from the output. */
|
|
82
149
|
export interface TrimRegion {
|
|
@@ -91,6 +158,31 @@ export interface SpeedRegion {
|
|
|
91
158
|
endMs: number;
|
|
92
159
|
speed: number;
|
|
93
160
|
}
|
|
161
|
+
export interface WordTiming {
|
|
162
|
+
text: string;
|
|
163
|
+
/** Start offset relative to the beginning of this voice cue (ms). */
|
|
164
|
+
offsetMs: number;
|
|
165
|
+
/** Word duration (ms). */
|
|
166
|
+
durationMs: number;
|
|
167
|
+
/** True when estimated proportionally rather than reported natively by the TTS engine. */
|
|
168
|
+
estimated: boolean;
|
|
169
|
+
}
|
|
170
|
+
export interface VoiceCue {
|
|
171
|
+
id: string;
|
|
172
|
+
text: string;
|
|
173
|
+
/** Recording-clock start time (ms). */
|
|
174
|
+
startMs: number;
|
|
175
|
+
/** Recording-clock end time (ms, `startMs + durationMs`). */
|
|
176
|
+
endMs: number;
|
|
177
|
+
/** Exact synthesized audio duration (ms). */
|
|
178
|
+
durationMs: number;
|
|
179
|
+
/** Relative path to the `.wav` clip inside the output directory (e.g. `voice/cue-01.wav`). */
|
|
180
|
+
audioFile: string;
|
|
181
|
+
/** Word-level timestamps relative to `startMs`. */
|
|
182
|
+
timings: WordTiming[];
|
|
183
|
+
/** Duration of the paired action callback in `scene.say(text, fn)` (ms), if any. */
|
|
184
|
+
actionDurationMs?: number;
|
|
185
|
+
}
|
|
94
186
|
export interface RecordingResult {
|
|
95
187
|
videoPath: string;
|
|
96
188
|
durationMs: number;
|
|
@@ -100,6 +192,10 @@ export interface RecordingResult {
|
|
|
100
192
|
samples: CursorSample[];
|
|
101
193
|
actions: ActionRecord[];
|
|
102
194
|
captions: Caption[];
|
|
195
|
+
blurs?: BlurAnnotation[];
|
|
196
|
+
arrows?: ArrowAnnotation[];
|
|
197
|
+
images?: ImageAnnotation[];
|
|
198
|
+
voiceCues?: VoiceCue[];
|
|
103
199
|
/** Recording-clock times (ms) of every captured screencast frame (= a visual change). */
|
|
104
200
|
frameTimes: number[];
|
|
105
201
|
frameCount: number;
|