@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.
- package/README.md +8 -5
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/dist/args.js +1 -1
- package/dist/cli.js +3 -3
- package/dist/compose.d.ts +9 -1
- package/dist/compose.js +38 -3
- package/dist/idle.js +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/layout.d.ts +10 -1
- package/dist/layout.js +41 -0
- package/dist/marks.d.ts +7 -12
- package/dist/marks.js +73 -43
- package/dist/mcp.js +2 -2
- package/dist/project.d.ts +261 -11
- package/dist/project.js +255 -8
- package/dist/record.js +8 -0
- 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 +93 -1
- package/dist/scene.js +177 -3
- package/dist/types.d.ts +73 -1
- package/dist/voice.d.ts +18 -6
- package/dist/voice.js +74 -6
- package/package.json +2 -2
- package/skills/demoreel/SKILL.md +6 -2
- package/dist/renderer/assets/webworkerAll-B41hok0-.js +0 -1
package/dist/project.d.ts
CHANGED
|
@@ -1,7 +1,22 @@
|
|
|
1
|
-
import
|
|
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:
|
|
102
|
+
type: "text";
|
|
80
103
|
content: string;
|
|
81
104
|
textContent: string;
|
|
82
105
|
position: {
|
|
@@ -87,6 +110,137 @@ 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 (skipping DOM-blurred elements). */
|
|
129
|
+
export declare function blurAnnotations(blurs: BlurAnnotation[], opts: {
|
|
130
|
+
viewport: Viewport;
|
|
131
|
+
layout: StageLayout;
|
|
132
|
+
durationMs: number;
|
|
133
|
+
zoomRegions?: ZoomRegion[];
|
|
134
|
+
startZIndex?: number;
|
|
135
|
+
}): {
|
|
136
|
+
id: string;
|
|
137
|
+
startMs: number;
|
|
138
|
+
endMs: number;
|
|
139
|
+
type: "blur";
|
|
140
|
+
content: string;
|
|
141
|
+
position: {
|
|
142
|
+
x: number;
|
|
143
|
+
y: number;
|
|
144
|
+
};
|
|
145
|
+
size: {
|
|
146
|
+
width: number;
|
|
147
|
+
height: number;
|
|
148
|
+
};
|
|
149
|
+
style: {
|
|
150
|
+
color: string;
|
|
151
|
+
backgroundColor: string;
|
|
152
|
+
fontSize: number;
|
|
153
|
+
fontFamily: string;
|
|
154
|
+
fontWeight: string;
|
|
155
|
+
fontStyle: string;
|
|
156
|
+
textDecoration: string;
|
|
157
|
+
textAlign: string;
|
|
158
|
+
textAnimation: string;
|
|
159
|
+
};
|
|
160
|
+
zIndex: number;
|
|
161
|
+
blurData: {
|
|
162
|
+
type: "blur" | "mosaic";
|
|
163
|
+
shape: "oval" | "rectangle";
|
|
164
|
+
color: "black" | "white";
|
|
165
|
+
intensity: number;
|
|
166
|
+
blockSize: number;
|
|
167
|
+
freehandPoints: {
|
|
168
|
+
x: number;
|
|
169
|
+
y: number;
|
|
170
|
+
}[];
|
|
171
|
+
};
|
|
172
|
+
}[];
|
|
173
|
+
/** Places a directional arrow box just outside a target rect pointing toward it. */
|
|
174
|
+
export declare function arrowRectForTarget(stage: {
|
|
175
|
+
x: number;
|
|
176
|
+
y: number;
|
|
177
|
+
w: number;
|
|
178
|
+
h: number;
|
|
179
|
+
}, dir: ArrowDirection, sizePct: number): {
|
|
180
|
+
x: number;
|
|
181
|
+
y: number;
|
|
182
|
+
width: number;
|
|
183
|
+
height: number;
|
|
184
|
+
};
|
|
185
|
+
/** Converts recorded `ArrowAnnotation`s into OpenScreen `type: "figure"` arrow regions (camera-projected). */
|
|
186
|
+
export declare function arrowAnnotations(arrows: ArrowAnnotation[], opts: {
|
|
187
|
+
viewport: Viewport;
|
|
188
|
+
layout: StageLayout;
|
|
189
|
+
zoomRegions?: ZoomRegion[];
|
|
190
|
+
startZIndex?: number;
|
|
191
|
+
}): {
|
|
192
|
+
id: string;
|
|
193
|
+
startMs: number;
|
|
194
|
+
endMs: number;
|
|
195
|
+
type: "figure";
|
|
196
|
+
content: string;
|
|
197
|
+
position: {
|
|
198
|
+
x: number;
|
|
199
|
+
y: number;
|
|
200
|
+
};
|
|
201
|
+
size: {
|
|
202
|
+
width: number;
|
|
203
|
+
height: number;
|
|
204
|
+
};
|
|
205
|
+
style: {
|
|
206
|
+
color: string;
|
|
207
|
+
backgroundColor: string;
|
|
208
|
+
fontSize: number;
|
|
209
|
+
fontFamily: string;
|
|
210
|
+
fontWeight: string;
|
|
211
|
+
fontStyle: string;
|
|
212
|
+
textDecoration: string;
|
|
213
|
+
textAlign: string;
|
|
214
|
+
textAnimation: string;
|
|
215
|
+
};
|
|
216
|
+
zIndex: number;
|
|
217
|
+
figureData: {
|
|
218
|
+
arrowDirection: ArrowDirection;
|
|
219
|
+
color: string;
|
|
220
|
+
strokeWidth: number;
|
|
221
|
+
};
|
|
222
|
+
}[];
|
|
223
|
+
/** Converts recorded `ImageAnnotation`s (and optional `look.watermark`) into OpenScreen `type: "image"` regions. */
|
|
224
|
+
export declare function imageAnnotations(images: ImageAnnotation[], opts: {
|
|
225
|
+
durationMs: number;
|
|
226
|
+
baseDir?: string;
|
|
227
|
+
watermark?: WatermarkOptions;
|
|
228
|
+
startZIndex?: number;
|
|
229
|
+
}): {
|
|
230
|
+
id: string;
|
|
231
|
+
startMs: number;
|
|
232
|
+
endMs: number;
|
|
233
|
+
type: "image";
|
|
234
|
+
content: string;
|
|
235
|
+
imageContent: string;
|
|
236
|
+
position: {
|
|
237
|
+
x: number;
|
|
238
|
+
y: number;
|
|
239
|
+
};
|
|
240
|
+
size: {
|
|
241
|
+
width: number;
|
|
242
|
+
height: number;
|
|
243
|
+
};
|
|
90
244
|
style: {
|
|
91
245
|
color: string;
|
|
92
246
|
backgroundColor: string;
|
|
@@ -104,10 +258,16 @@ export interface BuildProjectOptions {
|
|
|
104
258
|
videoPath: string;
|
|
105
259
|
zoomRegions: ZoomRegion[];
|
|
106
260
|
captions: Caption[];
|
|
261
|
+
blurs?: BlurAnnotation[];
|
|
262
|
+
arrows?: ArrowAnnotation[];
|
|
263
|
+
images?: ImageAnnotation[];
|
|
107
264
|
actions?: ActionRecord[];
|
|
108
265
|
trimRegions?: TrimRegion[];
|
|
109
266
|
speedRegions?: SpeedRegion[];
|
|
110
267
|
look?: Partial<LookOptions>;
|
|
268
|
+
viewport?: Viewport;
|
|
269
|
+
durationMs?: number;
|
|
270
|
+
baseDir?: string;
|
|
111
271
|
}
|
|
112
272
|
export type OpenScreenProject = ReturnType<typeof buildProject>;
|
|
113
273
|
export declare function buildProject(opts: BuildProjectOptions): {
|
|
@@ -125,18 +285,13 @@ export declare function buildProject(opts: BuildProjectOptions): {
|
|
|
125
285
|
motionBlurAmount: number;
|
|
126
286
|
borderRadius: number;
|
|
127
287
|
padding: number;
|
|
128
|
-
cropRegion:
|
|
129
|
-
x: number;
|
|
130
|
-
y: number;
|
|
131
|
-
width: number;
|
|
132
|
-
height: number;
|
|
133
|
-
};
|
|
288
|
+
cropRegion: CropRegion;
|
|
134
289
|
zoomRegions: ZoomRegion[];
|
|
135
290
|
autoZoomEnabled: boolean;
|
|
136
291
|
autoFocusAll: boolean;
|
|
137
292
|
trimRegions: TrimRegion[];
|
|
138
293
|
speedRegions: SpeedRegion[];
|
|
139
|
-
annotationRegions: {
|
|
294
|
+
annotationRegions: ({
|
|
140
295
|
id: string;
|
|
141
296
|
startMs: number;
|
|
142
297
|
endMs: number;
|
|
@@ -163,7 +318,102 @@ export declare function buildProject(opts: BuildProjectOptions): {
|
|
|
163
318
|
textAnimation: string;
|
|
164
319
|
};
|
|
165
320
|
zIndex: number;
|
|
166
|
-
}
|
|
321
|
+
} | {
|
|
322
|
+
id: string;
|
|
323
|
+
startMs: number;
|
|
324
|
+
endMs: number;
|
|
325
|
+
type: "blur";
|
|
326
|
+
content: string;
|
|
327
|
+
position: {
|
|
328
|
+
x: number;
|
|
329
|
+
y: number;
|
|
330
|
+
};
|
|
331
|
+
size: {
|
|
332
|
+
width: number;
|
|
333
|
+
height: number;
|
|
334
|
+
};
|
|
335
|
+
style: {
|
|
336
|
+
color: string;
|
|
337
|
+
backgroundColor: string;
|
|
338
|
+
fontSize: number;
|
|
339
|
+
fontFamily: string;
|
|
340
|
+
fontWeight: string;
|
|
341
|
+
fontStyle: string;
|
|
342
|
+
textDecoration: string;
|
|
343
|
+
textAlign: string;
|
|
344
|
+
textAnimation: string;
|
|
345
|
+
};
|
|
346
|
+
zIndex: number;
|
|
347
|
+
blurData: {
|
|
348
|
+
type: "blur" | "mosaic";
|
|
349
|
+
shape: "oval" | "rectangle";
|
|
350
|
+
color: "black" | "white";
|
|
351
|
+
intensity: number;
|
|
352
|
+
blockSize: number;
|
|
353
|
+
freehandPoints: {
|
|
354
|
+
x: number;
|
|
355
|
+
y: number;
|
|
356
|
+
}[];
|
|
357
|
+
};
|
|
358
|
+
} | {
|
|
359
|
+
id: string;
|
|
360
|
+
startMs: number;
|
|
361
|
+
endMs: number;
|
|
362
|
+
type: "figure";
|
|
363
|
+
content: string;
|
|
364
|
+
position: {
|
|
365
|
+
x: number;
|
|
366
|
+
y: number;
|
|
367
|
+
};
|
|
368
|
+
size: {
|
|
369
|
+
width: number;
|
|
370
|
+
height: number;
|
|
371
|
+
};
|
|
372
|
+
style: {
|
|
373
|
+
color: string;
|
|
374
|
+
backgroundColor: string;
|
|
375
|
+
fontSize: number;
|
|
376
|
+
fontFamily: string;
|
|
377
|
+
fontWeight: string;
|
|
378
|
+
fontStyle: string;
|
|
379
|
+
textDecoration: string;
|
|
380
|
+
textAlign: string;
|
|
381
|
+
textAnimation: string;
|
|
382
|
+
};
|
|
383
|
+
zIndex: number;
|
|
384
|
+
figureData: {
|
|
385
|
+
arrowDirection: ArrowDirection;
|
|
386
|
+
color: string;
|
|
387
|
+
strokeWidth: number;
|
|
388
|
+
};
|
|
389
|
+
} | {
|
|
390
|
+
id: string;
|
|
391
|
+
startMs: number;
|
|
392
|
+
endMs: number;
|
|
393
|
+
type: "image";
|
|
394
|
+
content: string;
|
|
395
|
+
imageContent: string;
|
|
396
|
+
position: {
|
|
397
|
+
x: number;
|
|
398
|
+
y: number;
|
|
399
|
+
};
|
|
400
|
+
size: {
|
|
401
|
+
width: number;
|
|
402
|
+
height: number;
|
|
403
|
+
};
|
|
404
|
+
style: {
|
|
405
|
+
color: string;
|
|
406
|
+
backgroundColor: string;
|
|
407
|
+
fontSize: number;
|
|
408
|
+
fontFamily: string;
|
|
409
|
+
fontWeight: string;
|
|
410
|
+
fontStyle: string;
|
|
411
|
+
textDecoration: string;
|
|
412
|
+
textAlign: string;
|
|
413
|
+
textAnimation: string;
|
|
414
|
+
};
|
|
415
|
+
zIndex: number;
|
|
416
|
+
})[];
|
|
167
417
|
aspectRatio: string;
|
|
168
418
|
webcamLayoutPreset: string;
|
|
169
419
|
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 { applyCamera, 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,261 @@ 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 (skipping DOM-blurred elements). */
|
|
187
|
+
export function blurAnnotations(blurs, opts) {
|
|
188
|
+
const z0 = opts.startZIndex ?? 1;
|
|
189
|
+
const overlayBlurs = blurs.filter((b) => b.mode !== "dom");
|
|
190
|
+
return overlayBlurs.map((b, i) => {
|
|
191
|
+
const endMs = b.endMs === "end" ? Math.max(b.startMs + 100, opts.durationMs) : b.endMs;
|
|
192
|
+
let x;
|
|
193
|
+
let y;
|
|
194
|
+
let width;
|
|
195
|
+
let height;
|
|
196
|
+
if (b.rect) {
|
|
197
|
+
({ x, y, width, height } = b.rect);
|
|
198
|
+
}
|
|
199
|
+
else if (b.box) {
|
|
200
|
+
const pad = b.padding ?? 4;
|
|
201
|
+
const padded = {
|
|
202
|
+
x: Math.max(0, b.box.x - pad),
|
|
203
|
+
y: Math.max(0, b.box.y - pad),
|
|
204
|
+
width: b.box.width + pad * 2,
|
|
205
|
+
height: b.box.height + pad * 2,
|
|
206
|
+
};
|
|
207
|
+
const rawStage = boxToStage(opts.layout, opts.viewport, padded);
|
|
208
|
+
const sampleT = Math.min(endMs, b.startMs + Math.min(350, (endMs - b.startMs) / 2));
|
|
209
|
+
const stage = opts.zoomRegions?.length ? applyCamera(rawStage, opts.zoomRegions, sampleT) : rawStage;
|
|
210
|
+
x = stage.x * 100;
|
|
211
|
+
y = stage.y * 100;
|
|
212
|
+
width = stage.w * 100;
|
|
213
|
+
height = stage.h * 100;
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
x = 25;
|
|
217
|
+
y = 25;
|
|
218
|
+
width = 20;
|
|
219
|
+
height = 10;
|
|
220
|
+
}
|
|
221
|
+
return {
|
|
222
|
+
id: `blur-${i + 1}`,
|
|
223
|
+
startMs: Math.round(b.startMs),
|
|
224
|
+
endMs: Math.round(endMs),
|
|
225
|
+
type: "blur",
|
|
226
|
+
content: "",
|
|
227
|
+
position: { x: clampPct(x), y: clampPct(y) },
|
|
228
|
+
size: { width: clampPct(width, 1, 100), height: clampPct(height, 1, 100) },
|
|
229
|
+
style: { ...DEFAULT_BASE_STYLE },
|
|
230
|
+
zIndex: z0 + i,
|
|
231
|
+
blurData: {
|
|
232
|
+
type: b.type ?? "blur",
|
|
233
|
+
shape: b.shape ?? "rectangle",
|
|
234
|
+
color: b.color ?? "black",
|
|
235
|
+
intensity: Math.min(40, Math.max(2, b.intensity ?? 14)),
|
|
236
|
+
blockSize: Math.min(48, Math.max(4, b.blockSize ?? 12)),
|
|
237
|
+
freehandPoints: DEFAULT_BLUR_FREEHAND_POINTS.map((p) => ({ ...p })),
|
|
132
238
|
},
|
|
133
|
-
zIndex: i + 1,
|
|
134
239
|
};
|
|
135
240
|
});
|
|
136
241
|
}
|
|
242
|
+
/** Places a directional arrow box just outside a target rect pointing toward it. */
|
|
243
|
+
export function arrowRectForTarget(stage, dir, sizePct) {
|
|
244
|
+
const tx = stage.x * 100;
|
|
245
|
+
const ty = stage.y * 100;
|
|
246
|
+
const tw = stage.w * 100;
|
|
247
|
+
const th = stage.h * 100;
|
|
248
|
+
const cx = tx + tw / 2;
|
|
249
|
+
const cy = ty + th / 2;
|
|
250
|
+
const gap = 1.2;
|
|
251
|
+
const w = sizePct;
|
|
252
|
+
const h = sizePct;
|
|
253
|
+
let x = cx - w / 2;
|
|
254
|
+
let y = cy - h / 2;
|
|
255
|
+
if (dir === "down")
|
|
256
|
+
y = ty - h - gap;
|
|
257
|
+
else if (dir === "up")
|
|
258
|
+
y = ty + th + gap;
|
|
259
|
+
else if (dir === "right")
|
|
260
|
+
x = tx - w - gap;
|
|
261
|
+
else if (dir === "left")
|
|
262
|
+
x = tx + tw + gap;
|
|
263
|
+
else if (dir === "down-right") {
|
|
264
|
+
x = tx - w - gap * 0.5;
|
|
265
|
+
y = ty - h - gap * 0.5;
|
|
266
|
+
}
|
|
267
|
+
else if (dir === "down-left") {
|
|
268
|
+
x = tx + tw + gap * 0.5;
|
|
269
|
+
y = ty - h - gap * 0.5;
|
|
270
|
+
}
|
|
271
|
+
else if (dir === "up-right") {
|
|
272
|
+
x = tx - w - gap * 0.5;
|
|
273
|
+
y = ty + th + gap * 0.5;
|
|
274
|
+
}
|
|
275
|
+
else if (dir === "up-left") {
|
|
276
|
+
x = tx + tw + gap * 0.5;
|
|
277
|
+
y = ty + th + gap * 0.5;
|
|
278
|
+
}
|
|
279
|
+
return { x: clampPct(x, 0, 100 - w), y: clampPct(y, 0, 100 - h), width: w, height: h };
|
|
280
|
+
}
|
|
281
|
+
/** Converts recorded `ArrowAnnotation`s into OpenScreen `type: "figure"` arrow regions (camera-projected). */
|
|
282
|
+
export function arrowAnnotations(arrows, opts) {
|
|
283
|
+
const z0 = opts.startZIndex ?? 1;
|
|
284
|
+
return arrows.map((a, i) => {
|
|
285
|
+
const sizePct = Math.min(40, Math.max(3, a.size ?? 9));
|
|
286
|
+
let rect;
|
|
287
|
+
if (a.rect) {
|
|
288
|
+
rect = a.rect;
|
|
289
|
+
}
|
|
290
|
+
else if (a.box) {
|
|
291
|
+
const rawStage = boxToStage(opts.layout, opts.viewport, a.box);
|
|
292
|
+
const sampleT = Math.min(a.endMs, a.startMs + Math.min(350, (a.endMs - a.startMs) / 2));
|
|
293
|
+
const stage = opts.zoomRegions?.length ? applyCamera(rawStage, opts.zoomRegions, sampleT) : rawStage;
|
|
294
|
+
rect = arrowRectForTarget(stage, a.direction, sizePct);
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
297
|
+
rect = { x: 45, y: 45, width: sizePct, height: sizePct };
|
|
298
|
+
}
|
|
299
|
+
return {
|
|
300
|
+
id: `arrow-${i + 1}`,
|
|
301
|
+
startMs: Math.round(a.startMs),
|
|
302
|
+
endMs: Math.round(a.endMs),
|
|
303
|
+
type: "figure",
|
|
304
|
+
content: "",
|
|
305
|
+
position: { x: clampPct(rect.x), y: clampPct(rect.y) },
|
|
306
|
+
size: { width: clampPct(rect.width, 1, 100), height: clampPct(rect.height, 1, 100) },
|
|
307
|
+
style: { ...DEFAULT_BASE_STYLE },
|
|
308
|
+
zIndex: z0 + i,
|
|
309
|
+
figureData: {
|
|
310
|
+
arrowDirection: a.direction,
|
|
311
|
+
color: a.color ?? "#ffcc00",
|
|
312
|
+
strokeWidth: a.strokeWidth ?? 4,
|
|
313
|
+
},
|
|
314
|
+
};
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
/** Converts recorded `ImageAnnotation`s (and optional `look.watermark`) into OpenScreen `type: "image"` regions. */
|
|
318
|
+
export function imageAnnotations(images, opts) {
|
|
319
|
+
const z0 = opts.startZIndex ?? 1;
|
|
320
|
+
const list = [...images];
|
|
321
|
+
if (opts.watermark) {
|
|
322
|
+
const wm = opts.watermark;
|
|
323
|
+
const w = wm.width ?? 10;
|
|
324
|
+
const h = wm.height ?? 8;
|
|
325
|
+
const pos = wm.position ?? "bottom-right";
|
|
326
|
+
let x;
|
|
327
|
+
let y;
|
|
328
|
+
if (typeof pos === "object") {
|
|
329
|
+
x = pos.x;
|
|
330
|
+
y = pos.y;
|
|
331
|
+
}
|
|
332
|
+
else {
|
|
333
|
+
x = pos.endsWith("left") ? 2.5 : 97.5 - w;
|
|
334
|
+
y = pos.startsWith("top") ? 2.5 : 97.5 - h;
|
|
335
|
+
}
|
|
336
|
+
list.push({
|
|
337
|
+
startMs: 0,
|
|
338
|
+
endMs: "end",
|
|
339
|
+
src: wm.src,
|
|
340
|
+
x,
|
|
341
|
+
y,
|
|
342
|
+
width: w,
|
|
343
|
+
height: h,
|
|
344
|
+
label: "watermark",
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
return list.map((img, i) => {
|
|
348
|
+
const dataUrl = resolveImageDataUrl(img.src, opts.baseDir);
|
|
349
|
+
const endMs = img.endMs === "end" ? Math.max(img.startMs + 100, opts.durationMs) : img.endMs;
|
|
350
|
+
return {
|
|
351
|
+
id: img.label === "watermark" ? "watermark" : `image-${i + 1}`,
|
|
352
|
+
startMs: Math.round(img.startMs),
|
|
353
|
+
endMs: Math.round(endMs),
|
|
354
|
+
type: "image",
|
|
355
|
+
content: dataUrl,
|
|
356
|
+
imageContent: dataUrl,
|
|
357
|
+
position: { x: clampPct(img.x), y: clampPct(img.y) },
|
|
358
|
+
size: { width: clampPct(img.width, 1, 100), height: clampPct(img.height, 1, 100) },
|
|
359
|
+
style: { ...DEFAULT_BASE_STYLE },
|
|
360
|
+
zIndex: z0 + i,
|
|
361
|
+
};
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
function normalizeCrop(crop) {
|
|
365
|
+
if (!crop)
|
|
366
|
+
return { x: 0, y: 0, width: 1, height: 1 };
|
|
367
|
+
const x = Math.min(0.95, Math.max(0, crop.x));
|
|
368
|
+
const y = Math.min(0.95, Math.max(0, crop.y));
|
|
369
|
+
const width = Math.min(1 - x, Math.max(0.05, crop.width));
|
|
370
|
+
const height = Math.min(1 - y, Math.max(0.05, crop.height));
|
|
371
|
+
return { x, y, width, height };
|
|
372
|
+
}
|
|
137
373
|
export function buildProject(opts) {
|
|
138
374
|
const look = { ...DEFAULT_LOOK, ...opts.look };
|
|
139
375
|
const videoPath = path.resolve(opts.videoPath);
|
|
140
|
-
const
|
|
141
|
-
const
|
|
376
|
+
const viewport = opts.viewport ?? { width: 1920, height: 1080 };
|
|
377
|
+
const layout = stageLayout(viewport, look);
|
|
378
|
+
const durationMs = opts.durationMs ?? Math.max(1000, ...opts.captions.map((c) => c.endMs), ...(opts.actions ?? []).map((a) => a.endMs));
|
|
379
|
+
let z = 1;
|
|
380
|
+
const blurs = blurAnnotations(opts.blurs ?? [], { viewport, layout, durationMs, zoomRegions: opts.zoomRegions, startZIndex: z });
|
|
381
|
+
z += blurs.length;
|
|
382
|
+
const images = imageAnnotations(opts.images ?? [], { durationMs, baseDir: opts.baseDir, watermark: look.watermark, startZIndex: z });
|
|
383
|
+
z += images.length;
|
|
384
|
+
const arrows = arrowAnnotations(opts.arrows ?? [], { viewport, layout, zoomRegions: opts.zoomRegions, startZIndex: z });
|
|
385
|
+
z += arrows.length;
|
|
386
|
+
const captions = captionAnnotations(opts.captions, look, z);
|
|
387
|
+
z += captions.length;
|
|
388
|
+
const keycaps = keycapAnnotations(opts.actions ?? [], look, z);
|
|
142
389
|
return {
|
|
143
390
|
version: PROJECT_VERSION,
|
|
144
391
|
// Legacy field: OpenScreen <= 1.2 (v1 projects) only reads `videoPath`; >= 1.3 prefers `media`.
|
|
@@ -150,18 +397,18 @@ export function buildProject(opts) {
|
|
|
150
397
|
editor: {
|
|
151
398
|
wallpaper: look.wallpaper,
|
|
152
399
|
shadowIntensity: look.shadowIntensity,
|
|
153
|
-
showBlur:
|
|
400
|
+
showBlur: Boolean(look.showBlur),
|
|
154
401
|
showTrimWaveform: true,
|
|
155
402
|
motionBlurAmount: look.motionBlurAmount,
|
|
156
403
|
borderRadius: look.borderRadius,
|
|
157
404
|
padding: look.padding,
|
|
158
|
-
cropRegion:
|
|
405
|
+
cropRegion: normalizeCrop(look.crop),
|
|
159
406
|
zoomRegions: opts.zoomRegions,
|
|
160
407
|
autoZoomEnabled: false,
|
|
161
408
|
autoFocusAll: false,
|
|
162
409
|
trimRegions: opts.trimRegions ?? [],
|
|
163
410
|
speedRegions: opts.speedRegions ?? [],
|
|
164
|
-
annotationRegions: [...captions, ...keycaps],
|
|
411
|
+
annotationRegions: [...blurs, ...images, ...arrows, ...captions, ...keycaps],
|
|
165
412
|
aspectRatio: look.aspectRatio,
|
|
166
413
|
webcamLayoutPreset: "picture-in-picture",
|
|
167
414
|
webcamMaskShape: "rectangle",
|
package/dist/record.js
CHANGED
|
@@ -126,9 +126,11 @@ export async function recordScenario(input, opts = {}) {
|
|
|
126
126
|
const frameTimes = rec.frameTimes;
|
|
127
127
|
fs.rmSync(framesDir, { recursive: true, force: true });
|
|
128
128
|
timings.recordTotalMs = Date.now() - t0;
|
|
129
|
+
const baseDir = opts.scenarioFile ? path.dirname(path.resolve(opts.scenarioFile)) : process.cwd();
|
|
129
130
|
const composed = compose({
|
|
130
131
|
name: session.scenario.name,
|
|
131
132
|
outDir,
|
|
133
|
+
baseDir,
|
|
132
134
|
videoPath,
|
|
133
135
|
durationMs,
|
|
134
136
|
frameCount,
|
|
@@ -136,6 +138,9 @@ export async function recordScenario(input, opts = {}) {
|
|
|
136
138
|
frameSize: rec.frameSize,
|
|
137
139
|
actions: scene.actions,
|
|
138
140
|
captions: scene.captions,
|
|
141
|
+
blurs: scene.blurs,
|
|
142
|
+
arrows: scene.arrows,
|
|
143
|
+
images: scene.images,
|
|
139
144
|
voiceCues: scene.voiceCues,
|
|
140
145
|
samples: scene.samples,
|
|
141
146
|
frameTimes,
|
|
@@ -154,6 +159,9 @@ export async function recordScenario(input, opts = {}) {
|
|
|
154
159
|
samples: scene.samples,
|
|
155
160
|
actions: scene.actions,
|
|
156
161
|
captions: scene.captions,
|
|
162
|
+
...(scene.blurs.length ? { blurs: scene.blurs } : {}),
|
|
163
|
+
...(scene.arrows.length ? { arrows: scene.arrows } : {}),
|
|
164
|
+
...(scene.images.length ? { images: scene.images } : {}),
|
|
157
165
|
...(scene.voiceCues.length ? { voiceCues: scene.voiceCues } : {}),
|
|
158
166
|
frameTimes,
|
|
159
167
|
frameCount,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Q as e,_t as t,ct as n,ht as r,mt as i,q as a,st as o,yt as s}from"./index-
|
|
1
|
+
import{Q as e,_t as t,ct as n,ht as r,mt as i,q as a,st as o,yt as s}from"./index-41-d13J1.js";var c=32767;function l(e,t){return(e<<17)+(t<<2)}var u=new class{constructor(t){this._buckets=new Map,this._screens=new e,this._enableFullScreen=!1,this.canvasOptions=t||{}}get enableFullScreen(){return t(s,`CanvasPool.enableFullScreen is no longer used, the pool sizes canvases to the screens registered with setScreenSize.`),this._enableFullScreen}set enableFullScreen(e){t(s,`CanvasPool.enableFullScreen is no longer used, the pool sizes canvases to the screens registered with setScreenSize.`),this._enableFullScreen=e}_createCanvasAndContext(e,t){let n=a.get().createCanvas();return n.width=e,n.height=t,{canvas:n,context:n.getContext(`2d`)}}getOptimalCanvasAndContext(e,t,r=1){let{width:i,height:a}=this.getOptimalSize(e,t,r);(i>c||a>c)&&n(`CanvasPool: ${i}x${a} is larger than the ${c}px pool key limit, canvases of this size may be pooled together`);let o=l(i,a),s=this._buckets.get(o);s||(s=[],this._buckets.set(o,s));let u=s.pop();return u||=this._createCanvasAndContext(i,a),u}getOptimalSize(e,t,n=1){let i=Math.ceil(e*n-1e-6),a=Math.ceil(t*n-1e-6),o=r(i),s=this._screens.getFittingWidth(i),c=r(a),l=this._screens.getFittingHeight(a);return{width:s===void 0?o:Math.min(s,o),height:l===void 0?c:Math.min(l,c)}}returnCanvasAndContext(e){let{width:t,height:n}=e.canvas,r=this._buckets.get(l(t,n));r&&(e.context.resetTransform(),e.context.clearRect(0,0,t,n),r.push(e))}setScreenSize(e,t,n){this._screens.set(e,t,n)&&this._pruneScreenCanvases()}removeScreen(e){this._screens.remove(e)&&this._pruneScreenCanvases()}clear(){this._buckets.clear()}_pruneScreenCanvases(){for(let[e]of this._buckets){let t=e>>>17,n=e>>>2&32767;(!i(t)&&!this._screens.hasWidth(t)||!i(n)&&!this._screens.hasHeight(n))&&this._buckets.delete(e)}}};o.register(u);export{u as t};
|