@slidevideo/cli 0.3.0 → 0.3.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/CHANGELOG.md +20 -0
- package/README.md +3 -3
- package/addons/slidevideo/geometry.ts +334 -1
- package/addons/slidevideo/global-top.vue +57 -6
- package/addons/slidevideo/preview.ts +242 -25
- package/assets/fonts/OFL-LICENSES.txt +95 -0
- package/assets/fonts/instrument-serif-latin-2.woff2 +0 -0
- package/assets/fonts/instrument-serif-latin-ext-1.woff2 +0 -0
- package/assets/fonts/jetbrains-mono-latin-4.woff2 +0 -0
- package/assets/fonts/jetbrains-mono-latin-ext-3.woff2 +0 -0
- package/assets/fonts/plus-jakarta-sans-latin-6.woff2 +0 -0
- package/assets/fonts/plus-jakarta-sans-latin-ext-5.woff2 +0 -0
- package/dist/adapters/edge.d.ts +1 -0
- package/dist/adapters/edge.js +4 -3
- package/dist/adapters/elevenlabs.d.ts +1 -0
- package/dist/adapters/elevenlabs.js +4 -3
- package/dist/adapters/powerpoint-preview.d.ts +1 -1
- package/dist/adapters/powerpoint-preview.js +13 -2
- package/dist/adapters/powerpoint.js +91 -14
- package/dist/adapters/slidev-inspection.js +7 -2
- package/dist/annotation-paint.d.ts +195 -5
- package/dist/annotation-paint.js +1188 -2
- package/dist/annotations.d.ts +26 -2
- package/dist/annotations.js +1117 -29
- package/dist/assembly.js +143 -37
- package/dist/captions.d.ts +6 -0
- package/dist/captions.js +320 -0
- package/dist/cli.js +59 -19
- package/dist/compositor.d.ts +17 -2
- package/dist/compositor.js +108 -26
- package/dist/contracts.d.ts +254 -14
- package/dist/media.js +24 -1
- package/dist/pipeline.d.ts +6 -1
- package/dist/pipeline.js +68 -20
- package/dist/preview/contracts.d.ts +15 -0
- package/dist/preview/player.js +527 -34
- package/dist/preview/server.d.ts +1 -1
- package/dist/preview/server.js +125 -4
- package/dist/preview/view.d.ts +1 -1
- package/dist/preview/view.js +26 -7
- package/dist/run.d.ts +1 -0
- package/dist/run.js +20 -0
- package/dist/speech.d.ts +13 -3
- package/dist/speech.js +164 -45
- package/dist/stamp-fonts.d.ts +17 -0
- package/dist/stamp-fonts.js +202 -0
- package/dist/storyboard.js +60 -3
- package/dist/timing.d.ts +4 -1
- package/dist/timing.js +322 -14
- package/dist/update-check-worker.js +43 -11
- package/dist/update-check.js +14 -10
- package/package.json +12 -1
- package/schemas/annotation-geometry.v1.json +111 -0
- package/schemas/schedule.v1.json +1672 -84
- package/schemas/storyboard.v1.json +3725 -85
- package/skills/slidevideo/SKILL.md +5 -5
- package/skills/slidevideo/references/decks.md +6 -4
- package/skills/slidevideo/references/production.md +12 -11
- package/skills/slidevideo/references/storyboard.md +268 -5
- package/tools/powerpoint/powerpoint.ps1 +155 -6
- package/tools/powerpoint/preview.ps1 +68 -1
|
@@ -50,7 +50,15 @@ function parseDeck(value) {
|
|
|
50
50
|
for (const shape of slide.shapes) {
|
|
51
51
|
requireCondition(object(shape), 'POWERPOINT_PROTOCOL', 'Native inspection returned an invalid shape identity', 5);
|
|
52
52
|
const bounds = shape.bounds;
|
|
53
|
-
requireCondition(Number.isInteger(shape.id) &&
|
|
53
|
+
requireCondition(Number.isInteger(shape.id) &&
|
|
54
|
+
typeof shape.name === 'string' &&
|
|
55
|
+
object(bounds) &&
|
|
56
|
+
['x', 'y', 'width', 'height'].every(key => finite(bounds[key])) &&
|
|
57
|
+
finite(shape.visible_from_click) &&
|
|
58
|
+
Array.isArray(shape.unsupported) &&
|
|
59
|
+
shape.unsupported.every(reason => typeof reason === 'string') &&
|
|
60
|
+
(shape.text === undefined || shape.text === null || typeof shape.text === 'string') &&
|
|
61
|
+
(shape.text_unsupported === undefined || (Array.isArray(shape.text_unsupported) && shape.text_unsupported.every(reason => typeof reason === 'string'))), 'POWERPOINT_PROTOCOL', 'Native inspection returned an invalid shape identity', 5);
|
|
54
62
|
}
|
|
55
63
|
for (const effect of slide.effects)
|
|
56
64
|
requireCondition(object(effect) && ['type', 'trigger', 'duration_ms', 'delay_ms', 'repeat_count', 'repeat_duration_ms', 'auto_reverse', 'exit', 'shape', 'paragraph'].every(key => finite(effect[key])), 'POWERPOINT_PROTOCOL', 'Native inspection returned an invalid effect', 5);
|
|
@@ -93,6 +101,16 @@ function validTarget(value, expected) {
|
|
|
93
101
|
case 'region': return value.units === 'normalized' && value.x === expected.x && value.y === expected.y && value.width === expected.width && value.height === expected.height;
|
|
94
102
|
case 'element': return value.selector === expected.selector;
|
|
95
103
|
case 'shape': return value.id === expected.id;
|
|
104
|
+
case 'text': {
|
|
105
|
+
const containerMatches = expected.container === undefined
|
|
106
|
+
? value.container === undefined
|
|
107
|
+
: object(value.container) && value.container.type === expected.container.type &&
|
|
108
|
+
(expected.container.type === 'shape' ? value.container.id === expected.container.id : value.container.selector === expected.container.selector);
|
|
109
|
+
const sliceMatches = expected.slice === undefined
|
|
110
|
+
? value.slice === undefined
|
|
111
|
+
: object(value.slice) && value.slice.start === expected.slice.start && value.slice.end === expected.slice.end;
|
|
112
|
+
return value.text === expected.text && value.occurrence === expected.occurrence && containerMatches && sliceMatches;
|
|
113
|
+
}
|
|
96
114
|
}
|
|
97
115
|
}
|
|
98
116
|
function requestLabel(request) {
|
|
@@ -175,7 +193,7 @@ class NativeSession {
|
|
|
175
193
|
process.once('SIGINT', this.cancel);
|
|
176
194
|
process.once('SIGTERM', this.cancel);
|
|
177
195
|
}
|
|
178
|
-
async preview(command) {
|
|
196
|
+
async preview(command, positionMs) {
|
|
179
197
|
const id = ++this.sequence;
|
|
180
198
|
let timer;
|
|
181
199
|
try {
|
|
@@ -183,7 +201,7 @@ class NativeSession {
|
|
|
183
201
|
return await new Promise((resolve, reject) => {
|
|
184
202
|
this.pending.set(id, { resolve, reject });
|
|
185
203
|
timer = setTimeout(() => { this.pending.delete(id); reject(new ProductionError('POWERPOINT_TIMEOUT', 'Native preview did not respond within 15 seconds', 5)); }, 15000);
|
|
186
|
-
this.child.stdin.write(`${JSON.stringify({ id, command })}\n`, error => { if (error) {
|
|
204
|
+
this.child.stdin.write(`${JSON.stringify({ id, command, ...(positionMs !== undefined ? { position_ms: positionMs } : {}) })}\n`, error => { if (error) {
|
|
187
205
|
this.pending.delete(id);
|
|
188
206
|
reject(error);
|
|
189
207
|
} });
|
|
@@ -359,7 +377,7 @@ export class PowerPointAdapter {
|
|
|
359
377
|
}),
|
|
360
378
|
} : {}),
|
|
361
379
|
files: [resolve(file), helper, packagePath('tools', 'powerpoint', 'Native.cs'), fileURLToPath(import.meta.url)],
|
|
362
|
-
capabilities: ['slide', 'reveal', 'play', 'highlight:region', 'highlight:shape', 'underline:region', 'underline:shape'],
|
|
380
|
+
capabilities: ['slide', 'reveal', 'play', 'highlight:region', 'highlight:shape', 'highlight:text', 'underline:region', 'underline:shape', 'underline:text', 'spotlight:region', 'spotlight:shape', 'spotlight:text', 'zoom:region', 'zoom:shape', 'zoom:text', 'laser:path', 'laser:region', 'laser:shape', 'laser:text', 'stamp:point', 'stamp:region', 'stamp:shape', 'stamp:text'],
|
|
363
381
|
...(unsupported.length ? { unsupported } : {}),
|
|
364
382
|
annotation_targets: this.targets(),
|
|
365
383
|
};
|
|
@@ -371,7 +389,18 @@ export class PowerPointAdapter {
|
|
|
371
389
|
}
|
|
372
390
|
}
|
|
373
391
|
targets() {
|
|
374
|
-
return this.deck.slides.map(slide => ({
|
|
392
|
+
return this.deck.slides.map(slide => ({
|
|
393
|
+
slide: slide.id || `slide-${slide.native_id}`,
|
|
394
|
+
clicks: slide.clicks.length,
|
|
395
|
+
targets: slide.shapes.map(shape => {
|
|
396
|
+
const textPreview = shape.text ? ` Text: ${JSON.stringify(shape.text.slice(0, 120))}` : '';
|
|
397
|
+
const textIssues = shape.text_unsupported?.length ? ` (text-range unsupported: ${shape.text_unsupported.join('; ')})` : '';
|
|
398
|
+
return {
|
|
399
|
+
identity: String(shape.id),
|
|
400
|
+
description: `Slide ${slide.index} (native ${slide.native_id}), shape ${shape.id}: ${shape.name}. ${shape.unsupported.length ? `Unsupported: ${shape.unsupported.join('; ')}` : `Stationary whole shape, visible from click ${shape.visible_from_click}`}${textPreview}${textIssues}`,
|
|
401
|
+
};
|
|
402
|
+
}),
|
|
403
|
+
}));
|
|
375
404
|
}
|
|
376
405
|
async inspectTargets(_deck, _viewport) {
|
|
377
406
|
requireCondition(this.deck, 'POWERPOINT_INSPECTION', 'Inspect the native deck before discovering annotation targets', 3);
|
|
@@ -419,18 +448,66 @@ export class PowerPointAdapter {
|
|
|
419
448
|
if (action.type === 'play')
|
|
420
449
|
requireCondition((action.rate ?? 1) === 1, 'POWERPOINT_CAPABILITY', `Video action ${action.id} requires playback rate 1 in native PowerPoint playback`, 3);
|
|
421
450
|
}
|
|
422
|
-
for (const annotation of story.annotations)
|
|
423
|
-
|
|
451
|
+
for (const annotation of story.annotations) {
|
|
452
|
+
const targets = annotation.target.type === 'path'
|
|
453
|
+
? annotation.target.points.flatMap(point => 'target' in point ? [point.target] : [])
|
|
454
|
+
: [annotation.target];
|
|
455
|
+
for (const target of targets) {
|
|
456
|
+
requireCondition(target.type !== 'element' && !(target.type === 'text' && target.container?.type === 'element'), 'ANNOTATION_TARGET', `Annotation ${annotation.id} uses a Slidev selector. PowerPoint requires an existing shape ID, text target, or normalized region.`, 3);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
424
459
|
if (schedule) {
|
|
425
460
|
this.operations(story, schedule);
|
|
426
461
|
for (const annotation of schedule.annotations) {
|
|
427
462
|
const slide = this.slide(annotation.slide);
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
463
|
+
const targets = annotation.target.type === 'path'
|
|
464
|
+
? annotation.target.points.flatMap(point => 'target' in point ? [point.target] : [])
|
|
465
|
+
: [annotation.target];
|
|
466
|
+
for (const target of targets) {
|
|
467
|
+
if (target.type === 'shape') {
|
|
468
|
+
const candidates = slide.shapes.filter(shape => shape.id === target.id);
|
|
469
|
+
requireCondition(candidates.length === 1, 'ANNOTATION_TARGET', `Annotation ${annotation.id}, slide ${annotation.slide}: shape ${target.id} is missing or ambiguous`, 3);
|
|
470
|
+
const shape = candidates[0];
|
|
471
|
+
requireCondition(shape.unsupported.length === 0 && annotation.click >= shape.visible_from_click, 'ANNOTATION_TARGET', `Annotation ${annotation.id}, slide ${annotation.slide}, shape ${shape.id} (${shape.name}): ${shape.unsupported.join('; ') || `hidden until click ${shape.visible_from_click}`}`, 3);
|
|
472
|
+
}
|
|
473
|
+
if (target.type === 'text') {
|
|
474
|
+
const needle = target.text.trim().replace(/\s+/g, ' ');
|
|
475
|
+
let shapes;
|
|
476
|
+
if (target.container) {
|
|
477
|
+
requireCondition(target.container.type === 'shape', 'ANNOTATION_TARGET', `Annotation ${annotation.id}: PowerPoint text container requires a shape ID`, 3);
|
|
478
|
+
const containerId = target.container.id;
|
|
479
|
+
const candidates = slide.shapes.filter(shape => shape.id === containerId);
|
|
480
|
+
requireCondition(candidates.length === 1, 'ANNOTATION_TARGET', `Annotation ${annotation.id}, slide ${annotation.slide}: shape ${containerId} is missing or ambiguous`, 3);
|
|
481
|
+
const shape = candidates[0];
|
|
482
|
+
const issues = [...shape.unsupported, ...(shape.text_unsupported ?? [])];
|
|
483
|
+
requireCondition(issues.length === 0 && annotation.click >= shape.visible_from_click && Boolean(shape.text), 'ANNOTATION_TARGET', `Annotation ${annotation.id}, slide ${annotation.slide}, shape ${shape.id} (${shape.name}): ${issues.join('; ') || (annotation.click < shape.visible_from_click ? `hidden until click ${shape.visible_from_click}` : 'shape contains no text')}`, 3);
|
|
484
|
+
shapes = [shape];
|
|
485
|
+
}
|
|
486
|
+
else {
|
|
487
|
+
shapes = slide.shapes.filter(shape => shape.unsupported.length === 0 && (shape.text_unsupported ?? []).length === 0 && annotation.click >= shape.visible_from_click && Boolean(shape.text));
|
|
488
|
+
}
|
|
489
|
+
const matches = [];
|
|
490
|
+
for (const shape of shapes) {
|
|
491
|
+
const text = shape.text ?? '';
|
|
492
|
+
let pos = text.indexOf(needle);
|
|
493
|
+
while (pos >= 0) {
|
|
494
|
+
matches.push({ shape, pos });
|
|
495
|
+
pos = text.indexOf(needle, pos + 1);
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
if (matches.length === 0) {
|
|
499
|
+
const unsupportedMatch = !target.container
|
|
500
|
+
? slide.shapes.find(shape => shape.unsupported.length === 0 && (shape.text_unsupported ?? []).length > 0 && annotation.click >= shape.visible_from_click && (shape.text ?? '').includes(needle))
|
|
501
|
+
: undefined;
|
|
502
|
+
const detail = unsupportedMatch
|
|
503
|
+
? `shape ${unsupportedMatch.id} (${unsupportedMatch.name}): ${(unsupportedMatch.text_unsupported ?? []).join('; ')}`
|
|
504
|
+
: `text ${JSON.stringify(needle)} not found in visible supported shapes`;
|
|
505
|
+
requireCondition(false, 'ANNOTATION_TARGET', `Annotation ${annotation.id}, slide ${annotation.slide}: ${detail}`, 3);
|
|
506
|
+
}
|
|
507
|
+
requireCondition(target.occurrence !== undefined || matches.length === 1, 'ANNOTATION_TARGET', `Annotation ${annotation.id}, slide ${annotation.slide}: text ${JSON.stringify(needle)} matched ${matches.length} times; specify container or occurrence`, 3);
|
|
508
|
+
const selected = matches[(target.occurrence ?? 1) - 1];
|
|
509
|
+
requireCondition(selected !== undefined, 'ANNOTATION_TARGET', `Annotation ${annotation.id}, slide ${annotation.slide}: text occurrence ${target.occurrence} does not exist`, 3);
|
|
510
|
+
}
|
|
434
511
|
}
|
|
435
512
|
}
|
|
436
513
|
}
|
|
@@ -499,7 +576,7 @@ export class PowerPointAdapter {
|
|
|
499
576
|
}
|
|
500
577
|
async startPreview(story, schedule, directory, _parentOrigin, viewport = defaultViewport) {
|
|
501
578
|
await this.openPlayback(story, schedule, directory, 'preview', { ...viewport, fps: defaultVideoOutput.fps }, false);
|
|
502
|
-
return nativePreview(command => this.session.preview(command));
|
|
579
|
+
return nativePreview((command, positionMs) => this.session.preview(command, positionMs));
|
|
503
580
|
}
|
|
504
581
|
async openPlayback(story, schedule, directory, mode, output, verifyTiming) {
|
|
505
582
|
requireCondition(this.deck, 'POWERPOINT_INSPECTION', 'Inspect the native deck before playback', 3);
|
|
@@ -42,7 +42,7 @@ export async function inspectSlidev(deck) {
|
|
|
42
42
|
}));
|
|
43
43
|
requireCondition(new Set(slides.map(s => s.id)).size === slides.length, 'SLIDE_ID', 'Slide names must be unique');
|
|
44
44
|
const media_ids = parsed.slides.flatMap(slide => [...slide.content.matchAll(/<(?:video|audio)\b[^>]*\bid=["']([^"']+)["']/g)].map(match => match[1]));
|
|
45
|
-
return { slides, media_ids, files: await slidevInputs(deck, parsed.headmatter, parsed.files), capabilities: ['slide', 'reveal', 'play', 'highlight:region', 'highlight:element', 'underline:region', 'underline:element'] };
|
|
45
|
+
return { slides, media_ids, files: await slidevInputs(deck, parsed.headmatter, parsed.files), capabilities: ['slide', 'reveal', 'play', 'highlight:region', 'highlight:element', 'highlight:text', 'underline:region', 'underline:element', 'underline:text', 'spotlight:region', 'spotlight:element', 'spotlight:text', 'zoom:region', 'zoom:element', 'zoom:text', 'laser:path', 'laser:region', 'laser:element', 'laser:text', 'stamp:point', 'stamp:region', 'stamp:element', 'stamp:text'] };
|
|
46
46
|
}
|
|
47
47
|
export function validateSlidev(story, inspection, options) {
|
|
48
48
|
const schedule = options?.schedule;
|
|
@@ -50,7 +50,12 @@ export function validateSlidev(story, inspection, options) {
|
|
|
50
50
|
requireCondition(inspection.slides.some(s => s.id === scene.slide), 'SLIDE_REFERENCE', `Scene ${scene.id} has unknown slide ${scene.slide}`);
|
|
51
51
|
}
|
|
52
52
|
for (const annotation of story.annotations) {
|
|
53
|
-
|
|
53
|
+
const targets = annotation.target.type === 'path'
|
|
54
|
+
? annotation.target.points.flatMap(point => 'target' in point ? [point.target] : [])
|
|
55
|
+
: [annotation.target];
|
|
56
|
+
for (const target of targets) {
|
|
57
|
+
requireCondition(target.type !== 'shape' && !(target.type === 'text' && target.container?.type === 'shape'), 'ANNOTATION_TARGET', `Annotation ${annotation.id} uses a PowerPoint shape target unsupported by Slidev`, 3, { annotation: annotation.id });
|
|
58
|
+
}
|
|
54
59
|
}
|
|
55
60
|
const actions = [...story.scenes.flatMap(s => s.actions), ...story.cues.map(c => ({ ...c.action, id: c.id }))];
|
|
56
61
|
for (const action of actions) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AnnotationGeometry, GeometryRequest, GeometryTarget, Rectangle, ResolvedAnnotation, ResolvedHighlightAnnotation, ResolvedUnderlineAnnotation, Schedule } from './contracts.js';
|
|
1
|
+
import type { AnnotationGeometry, GeometryRequest, GeometryTarget, LaserInterpolation, Rectangle, ResolvedAnnotation, ResolvedAnnotationTarget, ResolvedHighlightAnnotation, ResolvedLaserAnnotation, ResolvedSpotlightAnnotation, ResolvedStampAnnotation, ResolvedUnderlineAnnotation, ResolvedZoomAnnotation, Schedule, StampFont, StampSymbol, ZoomEasing } from './contracts.js';
|
|
2
2
|
export type BlendMode = 'source-over' | 'darken';
|
|
3
3
|
export type AnnotationPaint = {
|
|
4
4
|
rectangle: Rectangle;
|
|
@@ -31,7 +31,120 @@ export type UnderlineEffect = {
|
|
|
31
31
|
out_ms: number;
|
|
32
32
|
fragments: UnderlineFragmentPaint[];
|
|
33
33
|
};
|
|
34
|
-
export type
|
|
34
|
+
export type SpotlightAperture = {
|
|
35
|
+
shape: 'rounded-rect';
|
|
36
|
+
x: number;
|
|
37
|
+
y: number;
|
|
38
|
+
width: number;
|
|
39
|
+
height: number;
|
|
40
|
+
radius: number;
|
|
41
|
+
} | {
|
|
42
|
+
shape: 'ellipse';
|
|
43
|
+
cx: number;
|
|
44
|
+
cy: number;
|
|
45
|
+
rx: number;
|
|
46
|
+
ry: number;
|
|
47
|
+
};
|
|
48
|
+
export type SpotlightEffect = {
|
|
49
|
+
effect: 'spotlight';
|
|
50
|
+
start_ms: number;
|
|
51
|
+
end_ms: number;
|
|
52
|
+
in_ms: number;
|
|
53
|
+
out_ms: number;
|
|
54
|
+
color: string;
|
|
55
|
+
opacity: number;
|
|
56
|
+
softness_px: number;
|
|
57
|
+
slide_bounds: Rectangle;
|
|
58
|
+
apertures: SpotlightAperture[];
|
|
59
|
+
};
|
|
60
|
+
export type ZoomEffect = {
|
|
61
|
+
effect: 'zoom';
|
|
62
|
+
start_ms: number;
|
|
63
|
+
end_ms: number;
|
|
64
|
+
in_ms: number;
|
|
65
|
+
out_ms: number;
|
|
66
|
+
easing: ZoomEasing;
|
|
67
|
+
target_scale: number;
|
|
68
|
+
slide_bounds: Rectangle;
|
|
69
|
+
target_source: Rectangle;
|
|
70
|
+
};
|
|
71
|
+
export type ViewTransform = {
|
|
72
|
+
content: Rectangle;
|
|
73
|
+
source: Rectangle;
|
|
74
|
+
scale: number;
|
|
75
|
+
progress: number;
|
|
76
|
+
};
|
|
77
|
+
export type LaserPoint = {
|
|
78
|
+
x: number;
|
|
79
|
+
y: number;
|
|
80
|
+
};
|
|
81
|
+
export type LaserWaypointResolved = {
|
|
82
|
+
x: number;
|
|
83
|
+
y: number;
|
|
84
|
+
dwell_ms: number;
|
|
85
|
+
};
|
|
86
|
+
export type LaserSegment = {
|
|
87
|
+
start_ms: number;
|
|
88
|
+
end_ms: number;
|
|
89
|
+
samples: LaserPoint[];
|
|
90
|
+
cumulative: number[];
|
|
91
|
+
length: number;
|
|
92
|
+
};
|
|
93
|
+
export type LaserEffect = {
|
|
94
|
+
effect: 'laser';
|
|
95
|
+
start_ms: number;
|
|
96
|
+
end_ms: number;
|
|
97
|
+
in_ms: number;
|
|
98
|
+
out_ms: number;
|
|
99
|
+
color: string;
|
|
100
|
+
opacity: number;
|
|
101
|
+
radius_px: number;
|
|
102
|
+
glow_px: number;
|
|
103
|
+
trail_ms: number;
|
|
104
|
+
interpolation: LaserInterpolation;
|
|
105
|
+
slide_bounds: Rectangle;
|
|
106
|
+
waypoints: LaserWaypointResolved[];
|
|
107
|
+
segments: LaserSegment[];
|
|
108
|
+
total_length: number;
|
|
109
|
+
};
|
|
110
|
+
export type StampEffect = {
|
|
111
|
+
effect: 'stamp';
|
|
112
|
+
start_ms: number;
|
|
113
|
+
end_ms: number;
|
|
114
|
+
motion_type: 'none' | 'fade' | 'pop';
|
|
115
|
+
in_ms: number;
|
|
116
|
+
out_ms: number;
|
|
117
|
+
start_scale: number;
|
|
118
|
+
anchor_x: number;
|
|
119
|
+
anchor_y: number;
|
|
120
|
+
width: number;
|
|
121
|
+
height: number;
|
|
122
|
+
padding_x: number;
|
|
123
|
+
padding_y: number;
|
|
124
|
+
radius_px: number;
|
|
125
|
+
rotation_rad: number;
|
|
126
|
+
color: string;
|
|
127
|
+
opacity: number;
|
|
128
|
+
background?: string;
|
|
129
|
+
background_opacity: number;
|
|
130
|
+
border?: {
|
|
131
|
+
color: string;
|
|
132
|
+
opacity: number;
|
|
133
|
+
width_px: number;
|
|
134
|
+
};
|
|
135
|
+
font_css: string;
|
|
136
|
+
font_size_px: number;
|
|
137
|
+
line_height_px: number;
|
|
138
|
+
lines: string[];
|
|
139
|
+
align: 'left' | 'center' | 'right';
|
|
140
|
+
symbol?: StampSymbol;
|
|
141
|
+
symbol_size_px: number;
|
|
142
|
+
symbol_gap_px: number;
|
|
143
|
+
clip_content: boolean;
|
|
144
|
+
slide_bounds: Rectangle;
|
|
145
|
+
overflow_error?: string;
|
|
146
|
+
};
|
|
147
|
+
export type PaintableEffect = HighlightEffect | UnderlineEffect | SpotlightEffect | ZoomEffect | LaserEffect | StampEffect;
|
|
35
148
|
export type BlendGroup = {
|
|
36
149
|
blend: BlendMode;
|
|
37
150
|
primitives: AnnotationPaint[];
|
|
@@ -39,22 +152,96 @@ export type BlendGroup = {
|
|
|
39
152
|
export interface EffectCanvas2D<FillStyle = never, StrokeStyle = never, CompositeOp = never> {
|
|
40
153
|
save(): void;
|
|
41
154
|
restore(): void;
|
|
155
|
+
translate(x: number, y: number): void;
|
|
156
|
+
rotate(angle: number): void;
|
|
157
|
+
scale(x: number, y: number): void;
|
|
42
158
|
clearRect(x: number, y: number, width: number, height: number): void;
|
|
43
159
|
fillRect(x: number, y: number, width: number, height: number): void;
|
|
160
|
+
beginPath(): void;
|
|
161
|
+
moveTo(x: number, y: number): void;
|
|
162
|
+
lineTo(x: number, y: number): void;
|
|
163
|
+
arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void;
|
|
164
|
+
ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, counterclockwise?: boolean): void;
|
|
165
|
+
rect(x: number, y: number, width: number, height: number): void;
|
|
166
|
+
closePath(): void;
|
|
167
|
+
fill(): void;
|
|
168
|
+
stroke(): void;
|
|
169
|
+
clip(): void;
|
|
170
|
+
fillText(text: string, x: number, y: number): void;
|
|
44
171
|
fillStyle: string | FillStyle;
|
|
45
172
|
strokeStyle: string | StrokeStyle;
|
|
46
173
|
lineWidth: number;
|
|
174
|
+
lineCap: 'butt' | 'round' | 'square';
|
|
175
|
+
lineJoin: 'bevel' | 'round' | 'miter';
|
|
176
|
+
font: string;
|
|
177
|
+
textAlign: 'left' | 'right' | 'center' | 'start' | 'end';
|
|
178
|
+
textBaseline: 'top' | 'hanging' | 'middle' | 'alphabetic' | 'ideographic' | 'bottom';
|
|
47
179
|
globalAlpha: number;
|
|
48
|
-
globalCompositeOperation: BlendMode | CompositeOp;
|
|
180
|
+
globalCompositeOperation: BlendMode | 'destination-out' | CompositeOp;
|
|
49
181
|
}
|
|
182
|
+
export type SpotlightScratch<FillStyle = never, StrokeStyle = never, CompositeOp = never> = {
|
|
183
|
+
context: EffectCanvas2D<FillStyle, StrokeStyle, CompositeOp>;
|
|
184
|
+
drawTo(target: EffectCanvas2D<FillStyle, StrokeStyle, CompositeOp>, bounds: Rectangle): void;
|
|
185
|
+
};
|
|
50
186
|
export declare function targetKey(target: GeometryTarget): string;
|
|
51
187
|
export declare function annotationTargets(annotation: ResolvedAnnotation): GeometryTarget[];
|
|
52
188
|
export declare function geometryRequests(schedule: Pick<Schedule, 'annotations'>): GeometryRequest[];
|
|
53
189
|
export declare function findTargetGeometry(observations: readonly AnnotationGeometry[], annotation: Pick<ResolvedAnnotation, 'scene' | 'slide' | 'visit' | 'click' | 'start_ms' | 'end_ms'>, target: GeometryTarget): AnnotationGeometry | undefined;
|
|
54
190
|
export declare function highlightPaint(annotation: Pick<ResolvedHighlightAnnotation, 'appearance' | 'start_ms' | 'end_ms'>, { content, fragments, viewport }: Pick<AnnotationGeometry, 'content' | 'fragments' | 'viewport'>): HighlightEffect;
|
|
55
191
|
export declare function underlinePaint(annotation: Pick<ResolvedUnderlineAnnotation, 'appearance' | 'motion' | 'start_ms' | 'end_ms'>, { content, fragments, viewport }: Pick<AnnotationGeometry, 'content' | 'fragments' | 'viewport'>): UnderlineEffect;
|
|
56
|
-
export declare function
|
|
192
|
+
export declare function spotlightPaint(annotation: Pick<ResolvedSpotlightAnnotation, 'appearance' | 'motion' | 'start_ms' | 'end_ms'>, { content, fragments, viewport }: Pick<AnnotationGeometry, 'content' | 'fragments' | 'viewport'>): SpotlightEffect;
|
|
193
|
+
export declare function zoomPaint(annotation: Pick<ResolvedZoomAnnotation, 'appearance' | 'motion' | 'start_ms' | 'end_ms'>, { content, fragments, viewport }: Pick<AnnotationGeometry, 'content' | 'fragments' | 'viewport'>): ZoomEffect;
|
|
194
|
+
export declare function zoomTransformVisible(effect: Pick<ZoomEffect, 'slide_bounds' | 'target_scale'>): boolean;
|
|
195
|
+
export declare function zoomProgress(effect: Pick<ZoomEffect, 'start_ms' | 'end_ms' | 'in_ms' | 'out_ms' | 'easing'>, timeMs: number): number;
|
|
196
|
+
export declare function evaluateViewTransform(effect: ZoomEffect, timeMs: number): ViewTransform | undefined;
|
|
197
|
+
export declare function activeViewTransform(effects: readonly PaintableEffect[], timeMs: number): ViewTransform | undefined;
|
|
198
|
+
export declare function forwardTransformRect(view: ViewTransform, rect: Rectangle): Rectangle;
|
|
199
|
+
export declare function inverseTransformPoint(view: ViewTransform, px: number, py: number): {
|
|
200
|
+
x: number;
|
|
201
|
+
y: number;
|
|
202
|
+
};
|
|
203
|
+
export declare function laserPaint(annotation: Pick<ResolvedLaserAnnotation, 'target' | 'appearance' | 'motion' | 'start_ms' | 'end_ms'>, slideGeometry: Pick<AnnotationGeometry, 'content' | 'viewport'>, resolveTarget: (target: ResolvedAnnotationTarget) => readonly Rectangle[] | undefined): LaserEffect;
|
|
204
|
+
export declare function laserVisible(effect: Pick<LaserEffect, 'slide_bounds' | 'waypoints' | 'radius_px'>): boolean;
|
|
205
|
+
export declare function laserFadeFraction(effect: Pick<LaserEffect, 'start_ms' | 'end_ms' | 'in_ms' | 'out_ms'>, timeMs: number): number;
|
|
206
|
+
export declare function evaluateLaserPosition(effect: LaserEffect, timeMs: number): LaserPoint;
|
|
207
|
+
export declare function evaluateLaserTrail(effect: LaserEffect, timeMs: number): {
|
|
208
|
+
x: number;
|
|
209
|
+
y: number;
|
|
210
|
+
weight: number;
|
|
211
|
+
}[];
|
|
212
|
+
export type TextMeasureFn = (font: string, text: string) => number;
|
|
213
|
+
export declare function stampFontCss(font: StampFont, sizePx: number): string;
|
|
214
|
+
export declare function stampPaint(annotation: ResolvedStampAnnotation, geometry: Pick<AnnotationGeometry, 'viewport' | 'content' | 'fragments'>, measureText: TextMeasureFn): StampEffect;
|
|
215
|
+
export declare function stampMotionState(effect: Pick<StampEffect, 'start_ms' | 'end_ms' | 'motion_type' | 'in_ms' | 'out_ms' | 'start_scale' | 'opacity'>, timeMs: number): {
|
|
216
|
+
opacity: number;
|
|
217
|
+
scale: number;
|
|
218
|
+
};
|
|
219
|
+
export declare function stampVisible(effect: StampEffect): boolean;
|
|
220
|
+
export declare function stampDirtyBounds(effect: StampEffect, timeMs: number): Rectangle | undefined;
|
|
221
|
+
export declare function paintStamp<FillStyle, StrokeStyle, CompositeOp>(context: EffectCanvas2D<FillStyle, StrokeStyle, CompositeOp>, effect: StampEffect, timeMs: number): void;
|
|
222
|
+
export declare function hasActiveStamp(effects: readonly PaintableEffect[], timeMs: number): boolean;
|
|
223
|
+
export declare function paintStamps<FillStyle, StrokeStyle, CompositeOp>(context: EffectCanvas2D<FillStyle, StrokeStyle, CompositeOp>, effects: readonly PaintableEffect[], timeMs: number): void;
|
|
224
|
+
export declare function laserDirtyBounds(effect: LaserEffect, timeMs: number): Rectangle | undefined;
|
|
225
|
+
export declare function hasActiveLaser(effects: readonly PaintableEffect[], timeMs: number): boolean;
|
|
226
|
+
export declare function paintLaser<FillStyle, StrokeStyle, CompositeOp>(context: EffectCanvas2D<FillStyle, StrokeStyle, CompositeOp>, effect: LaserEffect, timeMs: number): void;
|
|
227
|
+
export declare function paintLasers<FillStyle, StrokeStyle, CompositeOp>(context: EffectCanvas2D<FillStyle, StrokeStyle, CompositeOp>, effects: readonly PaintableEffect[], timeMs: number): void;
|
|
228
|
+
export declare function laserDotSample(effect: LaserEffect, timeMs: number, px: number, py: number): {
|
|
229
|
+
alpha: number;
|
|
230
|
+
rgb: [number, number, number];
|
|
231
|
+
};
|
|
232
|
+
export declare function annotationPaint(annotation: Pick<ResolvedHighlightAnnotation, 'effect' | 'appearance' | 'start_ms' | 'end_ms'> | Pick<ResolvedUnderlineAnnotation, 'effect' | 'appearance' | 'motion' | 'start_ms' | 'end_ms'> | Pick<ResolvedSpotlightAnnotation, 'effect' | 'appearance' | 'motion' | 'start_ms' | 'end_ms'> | Pick<ResolvedZoomAnnotation, 'effect' | 'appearance' | 'motion' | 'start_ms' | 'end_ms'>, geometry: Pick<AnnotationGeometry, 'content' | 'fragments' | 'viewport'>): PaintableEffect;
|
|
57
233
|
export declare function underlineFragmentsVisible(effect: Pick<UnderlineEffect, 'fragments'>): boolean;
|
|
234
|
+
export declare function spotlightAperturesVisible(effect: Pick<SpotlightEffect, 'slide_bounds' | 'apertures'>): boolean;
|
|
235
|
+
export declare function spotlightApertureBounds(aperture: SpotlightAperture): Rectangle;
|
|
236
|
+
export declare function pointInExpandedAperture(aperture: SpotlightAperture, expandPx: number, px: number, py: number): boolean;
|
|
237
|
+
export declare function spotlightFadeFraction(effect: Pick<SpotlightEffect, 'start_ms' | 'end_ms' | 'in_ms' | 'out_ms'>, timeMs: number): number;
|
|
238
|
+
export declare function hasActiveSpotlight(effects: readonly PaintableEffect[], timeMs: number): boolean;
|
|
239
|
+
export declare function activeSpotlightBounds(effects: readonly PaintableEffect[], timeMs: number): Rectangle | undefined;
|
|
240
|
+
export declare function spotlightMaskSample(effects: readonly PaintableEffect[], timeMs: number, px: number, py: number): {
|
|
241
|
+
alpha: number;
|
|
242
|
+
rgb: [number, number, number];
|
|
243
|
+
};
|
|
244
|
+
export declare function paintSpotlightMask<FillStyle, StrokeStyle, CompositeOp>(context: EffectCanvas2D<FillStyle, StrokeStyle, CompositeOp>, effects: readonly PaintableEffect[], timeMs: number): Rectangle | undefined;
|
|
58
245
|
export declare function underlineWipeFractions(effect: Pick<UnderlineEffect, 'start_ms' | 'end_ms' | 'in_ms' | 'out_ms'>, timeMs: number): {
|
|
59
246
|
wipeStart: number;
|
|
60
247
|
wipeEnd: number;
|
|
@@ -70,4 +257,7 @@ export declare function effectDirtyBounds(effects: readonly PaintableEffect[], t
|
|
|
70
257
|
export declare function paintPrimitives<FillStyle, StrokeStyle, CompositeOp>(context: EffectCanvas2D<FillStyle, StrokeStyle, CompositeOp>, primitives: readonly AnnotationPaint[], options?: {
|
|
71
258
|
backdrop?: boolean;
|
|
72
259
|
}): void;
|
|
73
|
-
export declare function paintEffects<FillStyle, StrokeStyle, CompositeOp>(context: EffectCanvas2D<FillStyle, StrokeStyle, CompositeOp>, effects: readonly PaintableEffect[], timeMs: number
|
|
260
|
+
export declare function paintEffects<FillStyle, StrokeStyle, CompositeOp>(context: EffectCanvas2D<FillStyle, StrokeStyle, CompositeOp>, effects: readonly PaintableEffect[], timeMs: number, options?: {
|
|
261
|
+
backdrop?: boolean;
|
|
262
|
+
spotlightScratch?: SpotlightScratch<FillStyle, StrokeStyle, CompositeOp>;
|
|
263
|
+
}): void;
|