@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.
Files changed (39) hide show
  1. package/README.md +39 -5
  2. package/THIRD_PARTY_NOTICES.md +1 -1
  3. package/dist/args.js +3 -0
  4. package/dist/cli.js +32 -1
  5. package/dist/compose.d.ts +15 -1
  6. package/dist/compose.js +46 -2
  7. package/dist/idle.d.ts +2 -1
  8. package/dist/idle.js +3 -1
  9. package/dist/index.d.ts +3 -2
  10. package/dist/index.js +2 -1
  11. package/dist/marks.d.ts +2 -1
  12. package/dist/marks.js +9 -0
  13. package/dist/mcp.js +40 -2
  14. package/dist/project.d.ts +247 -11
  15. package/dist/project.js +244 -8
  16. package/dist/record.d.ts +5 -1
  17. package/dist/record.js +26 -6
  18. package/dist/render.d.ts +2 -0
  19. package/dist/render.js +35 -2
  20. package/dist/renderer/assets/{CanvasPool-PBu3bHFZ.js → CanvasPool-SkgMbnEH.js} +1 -1
  21. package/dist/renderer/assets/{CanvasRenderer-HmF-4gyW.js → CanvasRenderer-CEGuSdsG.js} +1 -1
  22. package/dist/renderer/assets/{RenderTargetSystem-Dk1U4wDJ.js → RenderTargetSystem-um8Nv1HQ.js} +1 -1
  23. package/dist/renderer/assets/{WebGLRenderer-C0v9HBel.js → WebGLRenderer-BnY2xfDL.js} +1 -1
  24. package/dist/renderer/assets/{WebGPURenderer-Ce0-U9Q1.js → WebGPURenderer-D9KI_sD9.js} +1 -1
  25. package/dist/renderer/assets/{browserAll-DhvWQ7nM.js → browserAll-vQt6iTAv.js} +1 -1
  26. package/dist/renderer/assets/{canvasUtils-KRroregW.js → canvasUtils-CZLntkW8.js} +1 -1
  27. package/dist/renderer/assets/{getTexelRangeRects-D3pwCyRt.js → getTexelRangeRects-CRAnqulP.js} +1 -1
  28. package/dist/renderer/assets/{index-CE-lli1m.js → index-41-d13J1.js} +4 -4
  29. package/dist/renderer/assets/{init-DfmWKarH.js → init-D6nA7FlC.js} +1 -1
  30. package/dist/renderer/assets/webworkerAll-BEIrFubI.js +1 -0
  31. package/dist/renderer/index.html +1 -1
  32. package/dist/scene.d.ts +132 -6
  33. package/dist/scene.js +279 -1
  34. package/dist/types.d.ts +97 -1
  35. package/dist/voice.d.ts +91 -0
  36. package/dist/voice.js +353 -0
  37. package/package.json +2 -1
  38. package/skills/demoreel/SKILL.md +9 -0
  39. package/dist/renderer/assets/webworkerAll-B41hok0-.js +0 -1
package/dist/project.d.ts CHANGED
@@ -1,7 +1,22 @@
1
- import type { ActionRecord, Caption, CursorSample, SpeedRegion, TrimRegion, ZoomRegion } from "./types.ts";
1
+ import { type StageLayout } from "./layout.ts";
2
+ import type { ActionRecord, ArrowAnnotation, ArrowDirection, BlurAnnotation, Caption, CaptionAnimation, CropRegion, CursorSample, ImageAnnotation, SpeedRegion, TrimRegion, Viewport, ZoomRegion } from "./types.ts";
2
3
  export declare const PROJECT_VERSION = 2;
3
4
  export declare const CURSOR_TELEMETRY_VERSION = 2;
4
5
  export type KeyHudPosition = "bottom-right" | "top-right" | "bottom-left" | "top-left";
6
+ export type WatermarkPosition = "bottom-right" | "top-right" | "bottom-left" | "top-left" | {
7
+ x: number;
8
+ y: number;
9
+ };
10
+ export interface WatermarkOptions {
11
+ /** Local image path (PNG/JPG/SVG/WebP, resolved relative to the scenario file) or `data:image/...` URL. */
12
+ src: string;
13
+ /** Corner preset or stage-percent coordinates (default `"bottom-right"`). */
14
+ position?: WatermarkPosition;
15
+ /** Width in percent of canvas width (default `10`). */
16
+ width?: number;
17
+ /** Height in percent of canvas height (default `8`). */
18
+ height?: number;
19
+ }
5
20
  export interface KeyHudOptions {
6
21
  /** Corner where shortcut keycap badges appear (default "bottom-right"). */
7
22
  position?: KeyHudPosition;
@@ -17,14 +32,22 @@ export interface LookOptions {
17
32
  padding: number;
18
33
  borderRadius: number;
19
34
  shadowIntensity: number;
35
+ /** Blur the wallpaper backdrop behind the rounded video frame (default `false`). */
36
+ showBlur?: boolean;
20
37
  motionBlurAmount: number;
38
+ /** Normalized crop region (`0..1`) applied to the recorded frame (default full frame `{ x: 0, y: 0, width: 1, height: 1 }`). */
39
+ crop?: CropRegion;
21
40
  /** "16:9", "9:16", "1:1", "4:3", "4:5", "16:10", "10:16" or "native". */
22
41
  aspectRatio: string;
23
42
  /** Where captions sit; "auto" (default) = bottom, unless that covers an active target. */
24
43
  captionPosition: "auto" | "bottom" | "top";
25
44
  captionFontSize: number;
45
+ /** Entrance/exit text animation for captions (`"none" | "fade" | "rise" | "pop" | "slide-left" | "typewriter" | "pulse"`). */
46
+ captionAnimation?: CaptionAnimation;
26
47
  /** Show floating keycap pills for `scene.press()` shortcuts (default false). */
27
48
  showKeys?: boolean | KeyHudOptions;
49
+ /** Persistent image/logo watermark rendered across the whole video. */
50
+ watermark?: WatermarkOptions;
28
51
  }
29
52
  export declare const DEFAULT_LOOK: LookOptions;
30
53
  /** Caption box in percent of the output canvas (OpenScreen annotation position/size). */
@@ -72,11 +95,11 @@ export declare function keycapAnnotations(actions: ActionRecord[], look?: LookOp
72
95
  };
73
96
  zIndex: number;
74
97
  }[];
75
- export declare function captionAnnotations(captions: Caption[], look?: LookOptions): {
98
+ export declare function captionAnnotations(captions: Caption[], look?: LookOptions, startZIndex?: number): {
76
99
  id: string;
77
100
  startMs: number;
78
101
  endMs: number;
79
- type: string;
102
+ type: "text";
80
103
  content: string;
81
104
  textContent: string;
82
105
  position: {
@@ -87,6 +110,123 @@ export declare function captionAnnotations(captions: Caption[], look?: LookOptio
87
110
  width: number;
88
111
  height: number;
89
112
  };
113
+ style: {
114
+ color: string;
115
+ backgroundColor: string;
116
+ fontSize: number;
117
+ fontFamily: string;
118
+ fontWeight: string;
119
+ fontStyle: string;
120
+ textDecoration: string;
121
+ textAlign: string;
122
+ textAnimation: CaptionAnimation;
123
+ };
124
+ zIndex: number;
125
+ }[];
126
+ /** Resolves a `data:image/...` URL or reads a local image file and encodes it as a data URL. */
127
+ export declare function resolveImageDataUrl(src: string, baseDir?: string): string;
128
+ /** Converts recorded `BlurAnnotation`s into OpenScreen `type: "blur"` regions. */
129
+ export declare function blurAnnotations(blurs: BlurAnnotation[], opts: {
130
+ viewport: Viewport;
131
+ layout: StageLayout;
132
+ durationMs: number;
133
+ startZIndex?: number;
134
+ }): {
135
+ id: string;
136
+ startMs: number;
137
+ endMs: number;
138
+ type: "blur";
139
+ content: string;
140
+ position: {
141
+ x: number;
142
+ y: number;
143
+ };
144
+ size: {
145
+ width: number;
146
+ height: number;
147
+ };
148
+ style: {
149
+ color: string;
150
+ backgroundColor: string;
151
+ fontSize: number;
152
+ fontFamily: string;
153
+ fontWeight: string;
154
+ fontStyle: string;
155
+ textDecoration: string;
156
+ textAlign: string;
157
+ textAnimation: string;
158
+ };
159
+ zIndex: number;
160
+ blurData: {
161
+ type: "blur" | "mosaic";
162
+ shape: "oval" | "rectangle";
163
+ color: "black" | "white";
164
+ intensity: number;
165
+ blockSize: number;
166
+ freehandPoints: {
167
+ x: number;
168
+ y: number;
169
+ }[];
170
+ };
171
+ }[];
172
+ /** Converts recorded `ArrowAnnotation`s into OpenScreen `type: "figure"` arrow regions. */
173
+ export declare function arrowAnnotations(arrows: ArrowAnnotation[], opts: {
174
+ viewport: Viewport;
175
+ layout: StageLayout;
176
+ startZIndex?: number;
177
+ }): {
178
+ id: string;
179
+ startMs: number;
180
+ endMs: number;
181
+ type: "figure";
182
+ content: string;
183
+ position: {
184
+ x: number;
185
+ y: number;
186
+ };
187
+ size: {
188
+ width: number;
189
+ height: number;
190
+ };
191
+ style: {
192
+ color: string;
193
+ backgroundColor: string;
194
+ fontSize: number;
195
+ fontFamily: string;
196
+ fontWeight: string;
197
+ fontStyle: string;
198
+ textDecoration: string;
199
+ textAlign: string;
200
+ textAnimation: string;
201
+ };
202
+ zIndex: number;
203
+ figureData: {
204
+ arrowDirection: ArrowDirection;
205
+ color: string;
206
+ strokeWidth: number;
207
+ };
208
+ }[];
209
+ /** Converts recorded `ImageAnnotation`s (and optional `look.watermark`) into OpenScreen `type: "image"` regions. */
210
+ export declare function imageAnnotations(images: ImageAnnotation[], opts: {
211
+ durationMs: number;
212
+ baseDir?: string;
213
+ watermark?: WatermarkOptions;
214
+ startZIndex?: number;
215
+ }): {
216
+ id: string;
217
+ startMs: number;
218
+ endMs: number;
219
+ type: "image";
220
+ content: string;
221
+ imageContent: string;
222
+ position: {
223
+ x: number;
224
+ y: number;
225
+ };
226
+ size: {
227
+ width: number;
228
+ height: number;
229
+ };
90
230
  style: {
91
231
  color: string;
92
232
  backgroundColor: string;
@@ -104,10 +244,16 @@ export interface BuildProjectOptions {
104
244
  videoPath: string;
105
245
  zoomRegions: ZoomRegion[];
106
246
  captions: Caption[];
247
+ blurs?: BlurAnnotation[];
248
+ arrows?: ArrowAnnotation[];
249
+ images?: ImageAnnotation[];
107
250
  actions?: ActionRecord[];
108
251
  trimRegions?: TrimRegion[];
109
252
  speedRegions?: SpeedRegion[];
110
253
  look?: Partial<LookOptions>;
254
+ viewport?: Viewport;
255
+ durationMs?: number;
256
+ baseDir?: string;
111
257
  }
112
258
  export type OpenScreenProject = ReturnType<typeof buildProject>;
113
259
  export declare function buildProject(opts: BuildProjectOptions): {
@@ -125,18 +271,13 @@ export declare function buildProject(opts: BuildProjectOptions): {
125
271
  motionBlurAmount: number;
126
272
  borderRadius: number;
127
273
  padding: number;
128
- cropRegion: {
129
- x: number;
130
- y: number;
131
- width: number;
132
- height: number;
133
- };
274
+ cropRegion: CropRegion;
134
275
  zoomRegions: ZoomRegion[];
135
276
  autoZoomEnabled: boolean;
136
277
  autoFocusAll: boolean;
137
278
  trimRegions: TrimRegion[];
138
279
  speedRegions: SpeedRegion[];
139
- annotationRegions: {
280
+ annotationRegions: ({
140
281
  id: string;
141
282
  startMs: number;
142
283
  endMs: number;
@@ -163,7 +304,102 @@ export declare function buildProject(opts: BuildProjectOptions): {
163
304
  textAnimation: string;
164
305
  };
165
306
  zIndex: number;
166
- }[];
307
+ } | {
308
+ id: string;
309
+ startMs: number;
310
+ endMs: number;
311
+ type: "blur";
312
+ content: string;
313
+ position: {
314
+ x: number;
315
+ y: number;
316
+ };
317
+ size: {
318
+ width: number;
319
+ height: number;
320
+ };
321
+ style: {
322
+ color: string;
323
+ backgroundColor: string;
324
+ fontSize: number;
325
+ fontFamily: string;
326
+ fontWeight: string;
327
+ fontStyle: string;
328
+ textDecoration: string;
329
+ textAlign: string;
330
+ textAnimation: string;
331
+ };
332
+ zIndex: number;
333
+ blurData: {
334
+ type: "blur" | "mosaic";
335
+ shape: "oval" | "rectangle";
336
+ color: "black" | "white";
337
+ intensity: number;
338
+ blockSize: number;
339
+ freehandPoints: {
340
+ x: number;
341
+ y: number;
342
+ }[];
343
+ };
344
+ } | {
345
+ id: string;
346
+ startMs: number;
347
+ endMs: number;
348
+ type: "figure";
349
+ content: string;
350
+ position: {
351
+ x: number;
352
+ y: number;
353
+ };
354
+ size: {
355
+ width: number;
356
+ height: number;
357
+ };
358
+ style: {
359
+ color: string;
360
+ backgroundColor: string;
361
+ fontSize: number;
362
+ fontFamily: string;
363
+ fontWeight: string;
364
+ fontStyle: string;
365
+ textDecoration: string;
366
+ textAlign: string;
367
+ textAnimation: string;
368
+ };
369
+ zIndex: number;
370
+ figureData: {
371
+ arrowDirection: ArrowDirection;
372
+ color: string;
373
+ strokeWidth: number;
374
+ };
375
+ } | {
376
+ id: string;
377
+ startMs: number;
378
+ endMs: number;
379
+ type: "image";
380
+ content: string;
381
+ imageContent: string;
382
+ position: {
383
+ x: number;
384
+ y: number;
385
+ };
386
+ size: {
387
+ width: number;
388
+ height: number;
389
+ };
390
+ style: {
391
+ color: string;
392
+ backgroundColor: string;
393
+ fontSize: number;
394
+ fontFamily: string;
395
+ fontWeight: string;
396
+ fontStyle: string;
397
+ textDecoration: string;
398
+ textAlign: string;
399
+ textAnimation: string;
400
+ };
401
+ zIndex: number;
402
+ })[];
167
403
  aspectRatio: string;
168
404
  webcamLayoutPreset: string;
169
405
  webcamMaskShape: string;
package/dist/project.js CHANGED
@@ -5,6 +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
9
  export const PROJECT_VERSION = 2;
9
10
  export const CURSOR_TELEMETRY_VERSION = 2;
10
11
  export const DEFAULT_LOOK = {
@@ -12,10 +13,12 @@ export const DEFAULT_LOOK = {
12
13
  padding: 40,
13
14
  borderRadius: 14,
14
15
  shadowIntensity: 0.6,
16
+ showBlur: false,
15
17
  motionBlurAmount: 0.2,
16
18
  aspectRatio: "16:9",
17
19
  captionPosition: "auto",
18
20
  captionFontSize: 30,
21
+ captionAnimation: "none",
19
22
  showKeys: false,
20
23
  };
21
24
  /** Caption box in percent of the output canvas (OpenScreen annotation position/size). */
@@ -107,7 +110,7 @@ export function keycapAnnotations(actions, look = DEFAULT_LOOK, startZIndex = 1)
107
110
  };
108
111
  });
109
112
  }
110
- export function captionAnnotations(captions, look = DEFAULT_LOOK) {
113
+ export function captionAnnotations(captions, look = DEFAULT_LOOK, startZIndex = 1) {
111
114
  return captions.map((c, i) => {
112
115
  const r = captionRect(c.position ?? look.captionPosition);
113
116
  return {
@@ -128,17 +131,250 @@ export function captionAnnotations(captions, look = DEFAULT_LOOK) {
128
131
  fontStyle: "normal",
129
132
  textDecoration: "none",
130
133
  textAlign: "center",
131
- textAnimation: "none",
134
+ textAnimation: c.animation ?? look.captionAnimation ?? "none",
135
+ },
136
+ zIndex: startZIndex + i,
137
+ };
138
+ });
139
+ }
140
+ const DEFAULT_BASE_STYLE = {
141
+ color: "#ffffff",
142
+ backgroundColor: "transparent",
143
+ fontSize: 32,
144
+ fontFamily: "Inter",
145
+ fontWeight: "bold",
146
+ fontStyle: "normal",
147
+ textDecoration: "none",
148
+ textAlign: "left",
149
+ textAnimation: "none",
150
+ };
151
+ const MIME_BY_EXT = {
152
+ ".png": "image/png",
153
+ ".jpg": "image/jpeg",
154
+ ".jpeg": "image/jpeg",
155
+ ".webp": "image/webp",
156
+ ".svg": "image/svg+xml",
157
+ ".gif": "image/gif",
158
+ };
159
+ /** Resolves a `data:image/...` URL or reads a local image file and encodes it as a data URL. */
160
+ export function resolveImageDataUrl(src, baseDir) {
161
+ if (src.startsWith("data:image/"))
162
+ return src;
163
+ const resolved = path.isAbsolute(src) ? src : path.resolve(baseDir ?? process.cwd(), src);
164
+ if (!fs.existsSync(resolved)) {
165
+ throw new Error(`image annotation not found: ${resolved}`);
166
+ }
167
+ const ext = path.extname(resolved).toLowerCase();
168
+ const mime = MIME_BY_EXT[ext] ?? "image/png";
169
+ const b64 = fs.readFileSync(resolved).toString("base64");
170
+ return `data:${mime};base64,${b64}`;
171
+ }
172
+ function clampPct(v, min = 0, max = 100) {
173
+ return Math.round(Math.min(max, Math.max(min, v)) * 100) / 100;
174
+ }
175
+ const DEFAULT_BLUR_FREEHAND_POINTS = [
176
+ { x: 10, y: 30 },
177
+ { x: 25, y: 10 },
178
+ { x: 55, y: 8 },
179
+ { x: 82, y: 20 },
180
+ { x: 90, y: 45 },
181
+ { x: 78, y: 72 },
182
+ { x: 52, y: 90 },
183
+ { x: 22, y: 84 },
184
+ { x: 8, y: 58 },
185
+ ];
186
+ /** Converts recorded `BlurAnnotation`s into OpenScreen `type: "blur"` regions. */
187
+ export function blurAnnotations(blurs, opts) {
188
+ const z0 = opts.startZIndex ?? 1;
189
+ return blurs.map((b, i) => {
190
+ let x;
191
+ let y;
192
+ let width;
193
+ let height;
194
+ if (b.rect) {
195
+ ({ x, y, width, height } = b.rect);
196
+ }
197
+ else if (b.box) {
198
+ const pad = b.padding ?? 4;
199
+ const padded = {
200
+ x: Math.max(0, b.box.x - pad),
201
+ y: Math.max(0, b.box.y - pad),
202
+ width: b.box.width + pad * 2,
203
+ height: b.box.height + pad * 2,
204
+ };
205
+ const stage = boxToStage(opts.layout, opts.viewport, padded);
206
+ x = stage.x * 100;
207
+ y = stage.y * 100;
208
+ width = stage.w * 100;
209
+ height = stage.h * 100;
210
+ }
211
+ else {
212
+ x = 25;
213
+ y = 25;
214
+ width = 20;
215
+ height = 10;
216
+ }
217
+ const endMs = b.endMs === "end" ? Math.max(b.startMs + 100, opts.durationMs) : b.endMs;
218
+ return {
219
+ id: `blur-${i + 1}`,
220
+ startMs: Math.round(b.startMs),
221
+ endMs: Math.round(endMs),
222
+ type: "blur",
223
+ content: "",
224
+ position: { x: clampPct(x), y: clampPct(y) },
225
+ size: { width: clampPct(width, 1, 100), height: clampPct(height, 1, 100) },
226
+ style: { ...DEFAULT_BASE_STYLE },
227
+ zIndex: z0 + i,
228
+ blurData: {
229
+ type: b.type ?? "blur",
230
+ shape: b.shape ?? "rectangle",
231
+ color: b.color ?? "black",
232
+ intensity: Math.min(40, Math.max(2, b.intensity ?? 14)),
233
+ blockSize: Math.min(48, Math.max(4, b.blockSize ?? 12)),
234
+ freehandPoints: DEFAULT_BLUR_FREEHAND_POINTS.map((p) => ({ ...p })),
235
+ },
236
+ };
237
+ });
238
+ }
239
+ /** Places a directional arrow box just outside a target rect pointing toward it. */
240
+ function arrowRectForTarget(stage, dir, sizePct) {
241
+ const tx = stage.x * 100;
242
+ const ty = stage.y * 100;
243
+ const tw = stage.w * 100;
244
+ const th = stage.h * 100;
245
+ const cx = tx + tw / 2;
246
+ const cy = ty + th / 2;
247
+ const gap = 1.2;
248
+ const w = sizePct;
249
+ const h = sizePct;
250
+ let x = cx - w / 2;
251
+ let y = cy - h / 2;
252
+ if (dir === "down")
253
+ y = ty - h - gap;
254
+ else if (dir === "up")
255
+ y = ty + th + gap;
256
+ else if (dir === "right")
257
+ x = tx - w - gap;
258
+ else if (dir === "left")
259
+ x = tx + tw + gap;
260
+ else if (dir === "down-right") {
261
+ x = tx - w - gap * 0.5;
262
+ y = ty - h - gap * 0.5;
263
+ }
264
+ else if (dir === "down-left") {
265
+ x = tx + tw + gap * 0.5;
266
+ y = ty - h - gap * 0.5;
267
+ }
268
+ else if (dir === "up-right") {
269
+ x = tx - w - gap * 0.5;
270
+ y = ty + th + gap * 0.5;
271
+ }
272
+ else if (dir === "up-left") {
273
+ x = tx + tw + gap * 0.5;
274
+ y = ty + th + gap * 0.5;
275
+ }
276
+ return { x: clampPct(x, 0, 100 - w), y: clampPct(y, 0, 100 - h), width: w, height: h };
277
+ }
278
+ /** Converts recorded `ArrowAnnotation`s into OpenScreen `type: "figure"` arrow regions. */
279
+ export function arrowAnnotations(arrows, opts) {
280
+ const z0 = opts.startZIndex ?? 1;
281
+ return arrows.map((a, i) => {
282
+ 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 };
288
+ return {
289
+ id: `arrow-${i + 1}`,
290
+ startMs: Math.round(a.startMs),
291
+ endMs: Math.round(a.endMs),
292
+ type: "figure",
293
+ content: "",
294
+ position: { x: clampPct(rect.x), y: clampPct(rect.y) },
295
+ size: { width: clampPct(rect.width, 1, 100), height: clampPct(rect.height, 1, 100) },
296
+ style: { ...DEFAULT_BASE_STYLE },
297
+ zIndex: z0 + i,
298
+ figureData: {
299
+ arrowDirection: a.direction,
300
+ color: a.color ?? "#ffcc00",
301
+ strokeWidth: a.strokeWidth ?? 4,
132
302
  },
133
- zIndex: i + 1,
134
303
  };
135
304
  });
136
305
  }
306
+ /** Converts recorded `ImageAnnotation`s (and optional `look.watermark`) into OpenScreen `type: "image"` regions. */
307
+ export function imageAnnotations(images, opts) {
308
+ const z0 = opts.startZIndex ?? 1;
309
+ const list = [...images];
310
+ if (opts.watermark) {
311
+ const wm = opts.watermark;
312
+ const w = wm.width ?? 10;
313
+ const h = wm.height ?? 8;
314
+ const pos = wm.position ?? "bottom-right";
315
+ let x;
316
+ let y;
317
+ if (typeof pos === "object") {
318
+ x = pos.x;
319
+ y = pos.y;
320
+ }
321
+ else {
322
+ x = pos.endsWith("left") ? 2.5 : 97.5 - w;
323
+ y = pos.startsWith("top") ? 2.5 : 97.5 - h;
324
+ }
325
+ list.push({
326
+ startMs: 0,
327
+ endMs: "end",
328
+ src: wm.src,
329
+ x,
330
+ y,
331
+ width: w,
332
+ height: h,
333
+ label: "watermark",
334
+ });
335
+ }
336
+ return list.map((img, i) => {
337
+ const dataUrl = resolveImageDataUrl(img.src, opts.baseDir);
338
+ const endMs = img.endMs === "end" ? Math.max(img.startMs + 100, opts.durationMs) : img.endMs;
339
+ return {
340
+ id: img.label === "watermark" ? "watermark" : `image-${i + 1}`,
341
+ startMs: Math.round(img.startMs),
342
+ endMs: Math.round(endMs),
343
+ type: "image",
344
+ content: dataUrl,
345
+ imageContent: dataUrl,
346
+ position: { x: clampPct(img.x), y: clampPct(img.y) },
347
+ size: { width: clampPct(img.width, 1, 100), height: clampPct(img.height, 1, 100) },
348
+ style: { ...DEFAULT_BASE_STYLE },
349
+ zIndex: z0 + i,
350
+ };
351
+ });
352
+ }
353
+ function normalizeCrop(crop) {
354
+ if (!crop)
355
+ return { x: 0, y: 0, width: 1, height: 1 };
356
+ const x = Math.min(0.95, Math.max(0, crop.x));
357
+ const y = Math.min(0.95, Math.max(0, crop.y));
358
+ const width = Math.min(1 - x, Math.max(0.05, crop.width));
359
+ const height = Math.min(1 - y, Math.max(0.05, crop.height));
360
+ return { x, y, width, height };
361
+ }
137
362
  export function buildProject(opts) {
138
363
  const look = { ...DEFAULT_LOOK, ...opts.look };
139
364
  const videoPath = path.resolve(opts.videoPath);
140
- const captions = captionAnnotations(opts.captions, look);
141
- const keycaps = keycapAnnotations(opts.actions ?? [], look, captions.length + 1);
365
+ const viewport = opts.viewport ?? { width: 1920, height: 1080 };
366
+ const layout = stageLayout(viewport, look);
367
+ const durationMs = opts.durationMs ?? Math.max(1000, ...opts.captions.map((c) => c.endMs), ...(opts.actions ?? []).map((a) => a.endMs));
368
+ let z = 1;
369
+ const blurs = blurAnnotations(opts.blurs ?? [], { viewport, layout, durationMs, startZIndex: z });
370
+ z += blurs.length;
371
+ const images = imageAnnotations(opts.images ?? [], { durationMs, baseDir: opts.baseDir, watermark: look.watermark, startZIndex: z });
372
+ z += images.length;
373
+ const arrows = arrowAnnotations(opts.arrows ?? [], { viewport, layout, startZIndex: z });
374
+ z += arrows.length;
375
+ const captions = captionAnnotations(opts.captions, look, z);
376
+ z += captions.length;
377
+ const keycaps = keycapAnnotations(opts.actions ?? [], look, z);
142
378
  return {
143
379
  version: PROJECT_VERSION,
144
380
  // Legacy field: OpenScreen <= 1.2 (v1 projects) only reads `videoPath`; >= 1.3 prefers `media`.
@@ -150,18 +386,18 @@ export function buildProject(opts) {
150
386
  editor: {
151
387
  wallpaper: look.wallpaper,
152
388
  shadowIntensity: look.shadowIntensity,
153
- showBlur: false,
389
+ showBlur: Boolean(look.showBlur),
154
390
  showTrimWaveform: true,
155
391
  motionBlurAmount: look.motionBlurAmount,
156
392
  borderRadius: look.borderRadius,
157
393
  padding: look.padding,
158
- cropRegion: { x: 0, y: 0, width: 1, height: 1 },
394
+ cropRegion: normalizeCrop(look.crop),
159
395
  zoomRegions: opts.zoomRegions,
160
396
  autoZoomEnabled: false,
161
397
  autoFocusAll: false,
162
398
  trimRegions: opts.trimRegions ?? [],
163
399
  speedRegions: opts.speedRegions ?? [],
164
- annotationRegions: [...captions, ...keycaps],
400
+ annotationRegions: [...blurs, ...images, ...arrows, ...captions, ...keycaps],
165
401
  aspectRatio: look.aspectRatio,
166
402
  webcamLayoutPreset: "picture-in-picture",
167
403
  webcamMaskShape: "rectangle",
package/dist/record.d.ts CHANGED
@@ -4,7 +4,8 @@ import type { IdleOptions } from "./idle.ts";
4
4
  import type { LookOptions } from "./project.ts";
5
5
  import type { CursorStyle } from "./render.ts";
6
6
  import { type ClickRippleOptions, type PacingOptions, Scene } from "./scene.ts";
7
- import type { ActionRecord, RecordingResult, Viewport } from "./types.ts";
7
+ import type { ActionRecord, RecordingResult, Viewport, VoiceCue } from "./types.ts";
8
+ import type { VoiceConfig } from "./voice.ts";
8
9
  import type { ZoomOptions } from "./zoom.ts";
9
10
  export interface ScenarioContext {
10
11
  /** URL of the scenario's `serve` directory ("" if none). */
@@ -38,6 +39,8 @@ export interface Scenario {
38
39
  clickRipple?: boolean | ClickRippleOptions;
39
40
  /** Cut (or speed up) idle stretches with OpenScreen trim/speed regions. */
40
41
  trimIdle?: boolean | Partial<IdleOptions>;
42
+ /** Voiceover TTS configuration for `scene.say()` (defaults to free Microsoft Edge TTS). */
43
+ voice?: VoiceConfig;
41
44
  run(scene: Scene, ctx: ScenarioContext): Promise<void>;
42
45
  }
43
46
  /** Identity helper that gives scenario files type checking and editor completion. */
@@ -82,6 +85,7 @@ export interface DryRunOptions {
82
85
  export interface DryRunResult {
83
86
  ok: boolean;
84
87
  actions: ActionRecord[];
88
+ voiceCues: VoiceCue[];
85
89
  durationMs: number;
86
90
  error?: DryRunError;
87
91
  }