@slidevideo/cli 0.2.0 → 0.2.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 +11 -0
- package/README.md +2 -2
- package/addons/slidevideo/geometry.ts +63 -30
- package/addons/slidevideo/global-top.vue +41 -9
- package/addons/slidevideo/playback-entries.ts +16 -5
- package/addons/slidevideo/preview.ts +26 -14
- package/dist/adapters/powerpoint.d.ts +7 -4
- package/dist/adapters/powerpoint.js +146 -40
- package/dist/adapters/slidev-inspection.d.ts +5 -2
- package/dist/adapters/slidev-inspection.js +3 -2
- package/dist/adapters/slidev.d.ts +3 -4
- package/dist/adapters/slidev.js +20 -19
- package/dist/annotation-paint.d.ts +65 -11
- package/dist/annotation-paint.js +290 -10
- package/dist/annotations.d.ts +13 -8
- package/dist/annotations.js +619 -88
- package/dist/assembly.d.ts +4 -2
- package/dist/assembly.js +23 -18
- package/dist/cli.js +102 -16
- package/dist/compositor.d.ts +10 -5
- package/dist/compositor.js +215 -128
- package/dist/contracts.d.ts +93 -30
- package/dist/contracts.js +2 -1
- package/dist/media.d.ts +5 -0
- package/dist/media.js +30 -0
- package/dist/pipeline.d.ts +37 -9
- package/dist/pipeline.js +62 -10
- package/dist/preview/contracts.d.ts +3 -3
- package/dist/preview/player.js +20 -15
- package/dist/preview/server.d.ts +2 -1
- package/dist/preview/server.js +6 -5
- package/dist/setup.d.ts +3 -0
- package/dist/setup.js +16 -1
- package/dist/skill-install.d.ts +35 -0
- package/dist/skill-install.js +132 -0
- package/dist/storyboard.js +9 -0
- package/package.json +4 -1
- package/schemas/annotation-geometry.v1.json +260 -28
- package/schemas/run-manifest.v1.json +31 -0
- package/schemas/schedule.v1.json +448 -182
- package/schemas/storyboard.v1.json +358 -174
- package/skills/slidevideo/SKILL.md +11 -9
- package/skills/slidevideo/references/decks.md +228 -0
- package/skills/slidevideo/references/production.md +14 -10
- package/skills/slidevideo/references/storyboard.md +69 -37
- package/tools/powerpoint/Native.cs +85 -1
- package/tools/powerpoint/powerpoint.ps1 +188 -101
- package/tools/powerpoint/preview.ps1 +10 -9
|
@@ -4,6 +4,8 @@ import { tmpdir } from 'node:os';
|
|
|
4
4
|
import { extname, join, resolve } from 'node:path';
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
6
|
import { nativePreview } from './powerpoint-preview.js';
|
|
7
|
+
import { defaultVideoOutput, defaultViewport } from '../contracts.js';
|
|
8
|
+
import { geometryRequests } from '../annotation-paint.js';
|
|
7
9
|
import { calibrate, estimateOrigin } from '../calibration.js';
|
|
8
10
|
import { executionSignal, hasStageDeadline, hashFile, json, probe, saveJson, videoFramePeriod } from '../media.js';
|
|
9
11
|
import { ProductionError, requireCondition } from '../errors.js';
|
|
@@ -29,10 +31,21 @@ function nativeFailure(failure) {
|
|
|
29
31
|
function object(value) { return value !== null && typeof value === 'object' && !Array.isArray(value); }
|
|
30
32
|
function finite(value) { return typeof value === 'number' && Number.isFinite(value); }
|
|
31
33
|
function rectangle(value) { return object(value) && ['x', 'y', 'width', 'height'].every(key => finite(value[key])) && Number(value.width) > 0 && Number(value.height) > 0; }
|
|
34
|
+
function effectSpanMs(effect) {
|
|
35
|
+
const cycleMs = effect.duration_ms * (effect.auto_reverse !== 0 ? 2 : 1);
|
|
36
|
+
const countSpan = effect.repeat_count > 0 ? cycleMs * effect.repeat_count : cycleMs;
|
|
37
|
+
if (effect.repeat_duration_ms > 0) {
|
|
38
|
+
return Math.max(0, effect.repeat_count > 0 ? Math.min(countSpan, effect.repeat_duration_ms) : effect.repeat_duration_ms);
|
|
39
|
+
}
|
|
40
|
+
return Math.max(0, countSpan);
|
|
41
|
+
}
|
|
42
|
+
function slideEntrySettleMs(slide) {
|
|
43
|
+
return Math.max(0, slide.transition_duration_ms) + Math.max(0, slide.entry_duration_ms);
|
|
44
|
+
}
|
|
32
45
|
function parseDeck(value) {
|
|
33
46
|
requireCondition(object(value) && value.version === 1 && value.kind === 'inspection' && typeof value.deck_sha256 === 'string' && finite(value.width) && finite(value.height) && value.width > 0 && value.height > 0 && Array.isArray(value.slides) && value.slides.length > 0 && Array.isArray(value.media) && Array.isArray(value.unsupported) && object(value.dependencies), 'POWERPOINT_PROTOCOL', 'Native inspection returned an invalid catalog', 5);
|
|
34
47
|
for (const slide of value.slides) {
|
|
35
|
-
requireCondition(object(slide) && typeof slide.id === 'string' && ['native_id', 'index', 'transition', 'auto_advance', 'hidden', 'interactive'].every(key => finite(slide[key])) && Array.isArray(slide.effects) && Array.isArray(slide.shapes), 'POWERPOINT_PROTOCOL', 'Native inspection returned an invalid slide', 5);
|
|
48
|
+
requireCondition(object(slide) && typeof slide.id === 'string' && ['native_id', 'index', 'transition', 'transition_duration_ms', 'auto_advance', 'hidden', 'interactive'].every(key => finite(slide[key])) && Array.isArray(slide.effects) && Array.isArray(slide.shapes), 'POWERPOINT_PROTOCOL', 'Native inspection returned an invalid slide', 5);
|
|
36
49
|
for (const shape of slide.shapes) {
|
|
37
50
|
requireCondition(object(shape), 'POWERPOINT_PROTOCOL', 'Native inspection returned an invalid shape identity', 5);
|
|
38
51
|
const bounds = shape.bounds;
|
|
@@ -49,6 +62,7 @@ function parseDeck(value) {
|
|
|
49
62
|
requireCondition(typeof version === 'string', 'POWERPOINT_PROTOCOL', 'Native inspection returned invalid dependency versions', 5);
|
|
50
63
|
const deck = value;
|
|
51
64
|
for (const slide of deck.slides) {
|
|
65
|
+
slide.entry_duration_ms = 0;
|
|
52
66
|
slide.clicks = [];
|
|
53
67
|
let previousStart = 0;
|
|
54
68
|
let previousEnd = 0;
|
|
@@ -58,27 +72,44 @@ function parseDeck(value) {
|
|
|
58
72
|
previousStart = 0;
|
|
59
73
|
previousEnd = 0;
|
|
60
74
|
}
|
|
61
|
-
if (!slide.clicks.length)
|
|
62
|
-
continue;
|
|
63
75
|
const start = (effect.trigger === 3 ? previousEnd : previousStart) + effect.delay_ms;
|
|
64
|
-
const end = start + effect
|
|
65
|
-
|
|
76
|
+
const end = start + effectSpanMs(effect);
|
|
77
|
+
if (slide.clicks.length)
|
|
78
|
+
slide.clicks[slide.clicks.length - 1] = Math.max(slide.clicks[slide.clicks.length - 1], end);
|
|
79
|
+
else
|
|
80
|
+
slide.entry_duration_ms = Math.max(slide.entry_duration_ms, end);
|
|
66
81
|
previousStart = start;
|
|
67
82
|
previousEnd = end;
|
|
68
83
|
}
|
|
69
84
|
}
|
|
70
85
|
return deck;
|
|
71
86
|
}
|
|
72
|
-
function
|
|
87
|
+
function validTarget(value, expected) {
|
|
88
|
+
if (!object(value) || value.type !== expected.type)
|
|
89
|
+
return false;
|
|
90
|
+
switch (expected.type) {
|
|
91
|
+
case 'slide': return true;
|
|
92
|
+
case 'region': return value.units === 'normalized' && value.x === expected.x && value.y === expected.y && value.width === expected.width && value.height === expected.height;
|
|
93
|
+
case 'element': return value.selector === expected.selector;
|
|
94
|
+
case 'shape': return value.id === expected.id;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
function requestLabel(request) {
|
|
98
|
+
return request.annotations.length === 1
|
|
99
|
+
? `Annotation ${request.annotations[0]}`
|
|
100
|
+
: `Annotations ${request.annotations.join(', ')}`;
|
|
101
|
+
}
|
|
102
|
+
function parseEvidence(value, directory, verified, requests, output) {
|
|
73
103
|
requireCondition(object(value) && value.version === 1 && value.kind === 'recording' && value.file === join(directory, 'native.mp4') && Array.isArray(value.events) && Array.isArray(value.markers) && Array.isArray(value.references) && Array.isArray(value.annotation_geometry) && object(value.dependencies), 'POWERPOINT_PROTOCOL', 'Native recording returned invalid evidence', 5);
|
|
74
|
-
requireCondition(value.annotation_geometry.length ===
|
|
75
|
-
for (const
|
|
76
|
-
const
|
|
77
|
-
|
|
104
|
+
requireCondition(value.annotation_geometry.length === requests.length, 'ANNOTATION_GEOMETRY', 'Native recording did not measure every target geometry interval', 5);
|
|
105
|
+
for (const request of requests) {
|
|
106
|
+
const label = `${requestLabel(request)} (${request.key}, ${request.slide}, visit ${request.visit})`;
|
|
107
|
+
const matches = value.annotation_geometry.filter(item => object(item) && item.key === request.key && item.scene === request.scene && item.slide === request.slide && item.visit === request.visit && item.click === request.click && item.start_ms === request.start_ms && item.end_ms === request.end_ms);
|
|
108
|
+
requireCondition(matches.length === 1, 'ANNOTATION_GEOMETRY', `${label} has missing or ambiguous native geometry`, 5);
|
|
78
109
|
const geometry = matches[0];
|
|
79
|
-
requireCondition(object(geometry) && geometry.
|
|
80
|
-
requireCondition(finite(geometry.observed_start_ms) && finite(geometry.observed_end_ms) && geometry.observed_start_ms >=
|
|
81
|
-
requireCondition(object(geometry.viewport) && geometry.viewport.width === output.width && geometry.viewport.height === output.height && rectangle(geometry.content) && geometry.content.x >= 0 && geometry.content.y >= 0 && geometry.content.x + geometry.content.width <= output.width && geometry.content.y + geometry.content.height <= output.height &&
|
|
110
|
+
requireCondition(object(geometry) && validTarget(geometry.target, request.target), 'ANNOTATION_GEOMETRY', `${label} has invalid native target metadata`, 5);
|
|
111
|
+
requireCondition(finite(geometry.observed_start_ms) && finite(geometry.observed_end_ms) && geometry.observed_start_ms >= request.start_ms && geometry.observed_start_ms < request.end_ms && geometry.observed_start_ms - request.start_ms <= 100 && geometry.observed_end_ms >= request.end_ms && geometry.observed_end_ms - request.end_ms <= 100 && Number.isInteger(geometry.samples) && Number(geometry.samples) >= 2, 'ANNOTATION_GEOMETRY', `${label} has incomplete native interval measurements`, 5);
|
|
112
|
+
requireCondition(object(geometry.viewport) && geometry.viewport.width === output.width && geometry.viewport.height === output.height && rectangle(geometry.content) && geometry.content.x >= 0 && geometry.content.y >= 0 && geometry.content.x + geometry.content.width <= output.width && geometry.content.y + geometry.content.height <= output.height && Array.isArray(geometry.fragments) && (request.target.type === 'slide' ? geometry.fragments.length === 0 : request.target.type === 'region' ? geometry.fragments.length === 1 : geometry.fragments.length >= 1) && geometry.fragments.every(bounds => rectangle(bounds) && bounds.x >= 0 && bounds.y >= 0 && bounds.x + bounds.width <= 1.000001 && bounds.y + bounds.height <= 1.000001), 'ANNOTATION_GEOMETRY', `${label} has invalid native coordinate mapping`, 5);
|
|
82
113
|
}
|
|
83
114
|
for (const event of value.events)
|
|
84
115
|
requireCondition(object(event) && typeof event.id === 'string' && typeof event.type === 'string' && finite(event.scheduled_ms) && finite(event.observed_ms) && (event.media_ms === undefined || finite(event.media_ms)), 'POWERPOINT_PROTOCOL', 'Native execution returned an invalid observed event', 5);
|
|
@@ -233,6 +264,44 @@ class NativeSession {
|
|
|
233
264
|
requireCondition(graceful && object(cleanup) && Array.isArray(cleanup.gaps) && cleanup.gaps.length === 0, 'POWERPOINT_CLEANUP', `Native cleanup could not be confirmed. Preserve the diagnostics in ${this.directory} and close only the identified private presentation if necessary.`, 5);
|
|
234
265
|
}
|
|
235
266
|
}
|
|
267
|
+
function isSupportedNativeEffect(deck, slide, effect) {
|
|
268
|
+
return [1, 2, 3].includes(effect.trigger) && effect.duration_ms >= 0 && effect.delay_ms >= 0 && effect.repeat_count >= 0 && effect.repeat_count <= 100 && effect.repeat_duration_ms >= 0 && effect.repeat_duration_ms <= 600000 && !deck.media.some(media => media.native_id === slide.native_id && media.shape === effect.shape);
|
|
269
|
+
}
|
|
270
|
+
function isSupportedNativeMedia(media) {
|
|
271
|
+
return media.duration_ms > 0 && media.start_ms === 0 && Math.abs(media.end_ms - media.duration_ms) <= 1 && media.autoplay === 0 && media.loop === 0 && media.rewind === 0 && media.fullscreen === 0;
|
|
272
|
+
}
|
|
273
|
+
function deckCapabilityIssues(deck) {
|
|
274
|
+
const issues = deck.unsupported.map(item => ({
|
|
275
|
+
...(item.slide ? { slide: item.slide } : {}),
|
|
276
|
+
reason: item.reason,
|
|
277
|
+
}));
|
|
278
|
+
const counts = new Map();
|
|
279
|
+
for (const slide of deck.slides)
|
|
280
|
+
if (slide.id)
|
|
281
|
+
counts.set(slide.id, (counts.get(slide.id) ?? 0) + 1);
|
|
282
|
+
for (const slide of deck.slides) {
|
|
283
|
+
const label = slide.id || `slide-${slide.native_id}`;
|
|
284
|
+
if (slide.id && (counts.get(slide.id) ?? 0) > 1) {
|
|
285
|
+
issues.push({ slide: label, reason: `Slide name ${slide.id} is ambiguous; use slide-${slide.native_id}` });
|
|
286
|
+
}
|
|
287
|
+
if (slide.transition_duration_ms < 0 || slide.auto_advance !== 0 || slide.hidden !== 0 || slide.interactive !== 0) {
|
|
288
|
+
issues.push({ slide: label, reason: 'Requires manual advancement, visible slides, finite transitions and no interactive animation sequences' });
|
|
289
|
+
}
|
|
290
|
+
for (const effect of slide.effects) {
|
|
291
|
+
if (!isSupportedNativeEffect(deck, slide, effect)) {
|
|
292
|
+
issues.push({ slide: label, reason: 'Contains an unsupported effect; only finite MainSequence animations without unbounded repeats, interactive triggers or video animations are supported' });
|
|
293
|
+
break;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
for (const media of deck.media) {
|
|
298
|
+
if (!isSupportedNativeMedia(media)) {
|
|
299
|
+
const owner = deck.slides.find(slide => slide.native_id === media.native_id);
|
|
300
|
+
issues.push({ slide: owner ? (owner.id || `slide-${owner.native_id}`) : `slide-${media.native_id}`, reason: `Video ${media.id} requires full-source playback with no native trim, autoplay, loop, rewind or fullscreen transform` });
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
return issues;
|
|
304
|
+
}
|
|
236
305
|
export class PowerPointAdapter {
|
|
237
306
|
id = 'powerpoint';
|
|
238
307
|
version = 'native-2';
|
|
@@ -257,7 +326,36 @@ export class PowerPointAdapter {
|
|
|
257
326
|
try {
|
|
258
327
|
this.deck = parseDeck(await session.waitFor('result.json', 120000));
|
|
259
328
|
completed = true;
|
|
260
|
-
|
|
329
|
+
const unsupported = deckCapabilityIssues(this.deck);
|
|
330
|
+
return {
|
|
331
|
+
dimensions: { width: this.deck.width, height: this.deck.height },
|
|
332
|
+
slides: this.deck.slides.map(slide => ({
|
|
333
|
+
id: slide.id || `slide-${slide.native_id}`,
|
|
334
|
+
...(slide.id ? { alias: `slide-${slide.native_id}` } : {}),
|
|
335
|
+
index: slide.index,
|
|
336
|
+
clicks: slide.clicks.length,
|
|
337
|
+
clicks_known: true,
|
|
338
|
+
...(slide.transition_duration_ms > 0 ? { transition_duration_ms: slide.transition_duration_ms } : {}),
|
|
339
|
+
...(slide.entry_duration_ms > 0 ? { entry_duration_ms: slide.entry_duration_ms } : {}),
|
|
340
|
+
...(slide.clicks.length ? { click_durations_ms: [...slide.clicks] } : {}),
|
|
341
|
+
})),
|
|
342
|
+
media_ids: [...new Set(this.deck.media.map(media => media.id))],
|
|
343
|
+
...(this.deck.media.length ? {
|
|
344
|
+
media: this.deck.media.map(media => {
|
|
345
|
+
const owner = this.deck.slides.find(slide => slide.native_id === media.native_id);
|
|
346
|
+
return {
|
|
347
|
+
id: media.id,
|
|
348
|
+
slide: owner ? (owner.id || `slide-${owner.native_id}`) : `slide-${media.native_id}`,
|
|
349
|
+
sha256: media.sha256,
|
|
350
|
+
duration_ms: media.duration_ms,
|
|
351
|
+
};
|
|
352
|
+
}),
|
|
353
|
+
} : {}),
|
|
354
|
+
files: [resolve(file), helper, packagePath('tools', 'powerpoint', 'Native.cs'), fileURLToPath(import.meta.url)],
|
|
355
|
+
capabilities: ['slide', 'reveal', 'play', 'highlight:region', 'highlight:shape', 'underline:region', 'underline:shape'],
|
|
356
|
+
...(unsupported.length ? { unsupported } : {}),
|
|
357
|
+
annotation_targets: this.targets(),
|
|
358
|
+
};
|
|
261
359
|
}
|
|
262
360
|
finally {
|
|
263
361
|
await session.close();
|
|
@@ -266,9 +364,9 @@ export class PowerPointAdapter {
|
|
|
266
364
|
}
|
|
267
365
|
}
|
|
268
366
|
targets() {
|
|
269
|
-
return this.deck.slides.map(slide => ({ slide: slide.id || `slide-${slide.native_id}`, targets: slide.shapes.map(shape => ({ identity: String(shape.id), 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}`}` })) }));
|
|
367
|
+
return this.deck.slides.map(slide => ({ slide: slide.id || `slide-${slide.native_id}`, clicks: slide.clicks.length, targets: slide.shapes.map(shape => ({ identity: String(shape.id), 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}`}` })) }));
|
|
270
368
|
}
|
|
271
|
-
async inspectTargets(
|
|
369
|
+
async inspectTargets(_deck, _viewport) {
|
|
272
370
|
requireCondition(this.deck, 'POWERPOINT_INSPECTION', 'Inspect the native deck before discovering annotation targets', 3);
|
|
273
371
|
return this.targets();
|
|
274
372
|
}
|
|
@@ -277,22 +375,19 @@ export class PowerPointAdapter {
|
|
|
277
375
|
requireCondition(slides.length === 1, 'SLIDE_REFERENCE', `Native slide ${id} is missing or ambiguous. Use a unique authored Slide.Name or slide-<SlideID>.`);
|
|
278
376
|
return slides[0];
|
|
279
377
|
}
|
|
280
|
-
async validate(story, _inspection,
|
|
378
|
+
async validate(story, _inspection, options) {
|
|
281
379
|
const deck = this.deck;
|
|
380
|
+
const schedule = options?.schedule;
|
|
282
381
|
requireCondition(deck, 'POWERPOINT_INSPECTION', 'Inspect the native deck before validation', 3);
|
|
283
|
-
requireCondition(Math.abs(story.output.width / story.output.height - deck.width / deck.height) <= 2 / story.output.height, 'POWERPOINT_CAPABILITY', 'Native output aspect ratio must match the PowerPoint slide size. Adjust storyboard output dimensions or the deck page setup.', 3);
|
|
284
382
|
requireCondition(deck.unsupported.length === 0, 'POWERPOINT_CAPABILITY', deck.unsupported.map(item => `${item.slide ? `Slide ${item.slide}: ` : ''}${item.reason}`).join('\n'), 3);
|
|
285
383
|
for (const slide of deck.slides) {
|
|
286
|
-
requireCondition(slide.
|
|
287
|
-
let clicked = false;
|
|
384
|
+
requireCondition(slide.transition_duration_ms >= 0 && slide.auto_advance === 0 && slide.hidden === 0 && slide.interactive === 0, 'POWERPOINT_CAPABILITY', `Slide ${slide.id} requires manual advancement, visible slides, finite transitions and no interactive animation sequences`, 3);
|
|
288
385
|
for (const effect of slide.effects) {
|
|
289
|
-
|
|
290
|
-
clicked = true;
|
|
291
|
-
requireCondition([1, 10].includes(effect.type) && [1, 2, 3].includes(effect.trigger) && clicked && effect.duration_ms >= 0 && effect.delay_ms >= 0 && effect.repeat_count <= 1 && effect.repeat_count >= 0 && effect.repeat_duration_ms === 0 && effect.auto_reverse === 0 && effect.exit === 0 && !deck.media.some(media => media.native_id === slide.native_id && media.shape === effect.shape), 'POWERPOINT_CAPABILITY', `Slide ${slide.id} contains an unsupported effect. Only finite click groups of entrance Appear and Fade effects are supported; automatic entry, repeats, exits, interactive triggers and video animations are unsupported.`, 3);
|
|
386
|
+
requireCondition(isSupportedNativeEffect(deck, slide, effect), 'POWERPOINT_CAPABILITY', `Slide ${slide.id} contains an unsupported effect. Only finite MainSequence animations without unbounded repeats, interactive triggers or video animations are supported.`, 3);
|
|
292
387
|
}
|
|
293
388
|
}
|
|
294
389
|
for (const media of deck.media)
|
|
295
|
-
requireCondition(
|
|
390
|
+
requireCondition(isSupportedNativeMedia(media), 'POWERPOINT_CAPABILITY', `Video ${media.id} requires full-source embedded media with no native trim, autoplay, loop, rewind or fullscreen transform`, 3);
|
|
296
391
|
for (const declaration of story.media) {
|
|
297
392
|
const candidates = deck.media.filter(media => media.id === declaration.id);
|
|
298
393
|
requireCondition(candidates.length > 0, 'MEDIA_TARGET', `The native deck has no embedded video named ${declaration.id}`, 3);
|
|
@@ -309,10 +404,13 @@ export class PowerPointAdapter {
|
|
|
309
404
|
this.slide(scene.slide);
|
|
310
405
|
const actions = [...story.scenes.flatMap(scene => scene.actions), ...story.cues.map(cue => ({ ...cue.action, id: cue.id }))];
|
|
311
406
|
for (const action of actions) {
|
|
312
|
-
if (action.type === 'slide')
|
|
313
|
-
this.slide(action.target);
|
|
407
|
+
if (action.type === 'slide') {
|
|
408
|
+
const targetSlide = this.slide(action.target);
|
|
409
|
+
const requiredSettle = slideEntrySettleMs(targetSlide);
|
|
410
|
+
requireCondition(action.duration_ms + 0.1 >= requiredSettle, 'SLIDE_TRANSITION_DURATION', `Slide action ${action.id} must reserve at least ${requiredSettle} ms for ${targetSlide.id} transition and automatic entry animations`, 3);
|
|
411
|
+
}
|
|
314
412
|
if (action.type === 'play')
|
|
315
|
-
requireCondition((action.
|
|
413
|
+
requireCondition((action.rate ?? 1) === 1, 'POWERPOINT_CAPABILITY', `Video action ${action.id} requires playback rate 1 in native PowerPoint playback`, 3);
|
|
316
414
|
}
|
|
317
415
|
for (const annotation of story.annotations)
|
|
318
416
|
requireCondition(annotation.target.type !== 'element', 'ANNOTATION_TARGET', `Annotation ${annotation.id} uses a Slidev selector. PowerPoint requires an existing shape ID or normalized region.`, 3);
|
|
@@ -357,7 +455,13 @@ export class PowerPointAdapter {
|
|
|
357
455
|
if (action.type === 'slide') {
|
|
358
456
|
slide = this.slide(action.target);
|
|
359
457
|
click = 0;
|
|
360
|
-
|
|
458
|
+
const requiredSettle = item.start_ms > 0 ? slideEntrySettleMs(slide) : slide.entry_duration_ms;
|
|
459
|
+
if (item.start_ms > 0 && !item.id.endsWith(':slide')) {
|
|
460
|
+
requireCondition(action.duration_ms + 0.1 >= requiredSettle, 'SLIDE_TRANSITION_DURATION', `Slide action ${item.id} must reserve at least ${requiredSettle} ms for ${slide.id} transition and automatic entry animations`, 3);
|
|
461
|
+
}
|
|
462
|
+
const settleMs = Math.max(action.duration_ms, requiredSettle);
|
|
463
|
+
requireCondition(item.start_ms + settleMs <= schedule.duration_ms + 0.1, 'SLIDE_TRANSITION_DURATION', `Slide ${item.id} requires ${settleMs} ms to settle on ${slide.id}, exceeding the resolved schedule duration`, 3);
|
|
464
|
+
operations.push({ id: item.id, scene: item.scene, type: 'slide', at_ms: item.start_ms, end_ms: item.start_ms + settleMs, native_id: slide.native_id, settle_ms: settleMs });
|
|
361
465
|
}
|
|
362
466
|
if (action.type === 'reveal') {
|
|
363
467
|
requireCondition(slide && action.click === click + 1 && action.click <= slide.clicks.length && action.duration_ms + 0.1 >= slide.clicks[action.click - 1], 'REVEAL_TARGET', `Reveal ${item.id} must execute the next native click and include its complete duration`, 3);
|
|
@@ -370,7 +474,9 @@ export class PowerPointAdapter {
|
|
|
370
474
|
const source = schedule.media.find(media => media.id === action.media);
|
|
371
475
|
requireCondition(candidates.length === 1 && declaration && source, 'MEDIA_TARGET', `Video ${action.media} is missing or ambiguous on the active native slide`, 3);
|
|
372
476
|
requireCondition(Math.abs(source.duration_ms - candidates[0].duration_ms) <= 100, 'MEDIA_SOURCE_MISMATCH', `Native video duration differs from source for ${action.media}`);
|
|
373
|
-
|
|
477
|
+
const trimStart = action.trim_start_ms ?? 0;
|
|
478
|
+
const trimEnd = action.trim_end_ms ?? source.duration_ms;
|
|
479
|
+
operations.push({ id: item.id, scene: item.scene, type: 'play', at_ms: item.start_ms, end_ms: item.end_ms, native_id: candidates[0].native_id, shape: candidates[0].shape, source_duration_ms: source.duration_ms, trim_start_ms: trimStart, trim_end_ms: trimEnd, frame_period_ms: 0 });
|
|
374
480
|
}
|
|
375
481
|
}
|
|
376
482
|
for (const [index, operation] of operations.entries())
|
|
@@ -380,15 +486,15 @@ export class PowerPointAdapter {
|
|
|
380
486
|
}
|
|
381
487
|
return operations;
|
|
382
488
|
}
|
|
383
|
-
async prepare(story, schedule, directory, production = { verify_timing: false }) {
|
|
384
|
-
await this.openPlayback(story, schedule, directory, 'record', production.verify_timing);
|
|
385
|
-
this.prepared = {
|
|
489
|
+
async prepare(story, schedule, directory, production = { verify_timing: false, output: defaultVideoOutput }) {
|
|
490
|
+
await this.openPlayback(story, schedule, directory, 'record', production.output, production.verify_timing);
|
|
491
|
+
this.prepared = { schedule, directory: resolve(directory), production };
|
|
386
492
|
}
|
|
387
|
-
async startPreview(story, schedule, directory) {
|
|
388
|
-
await this.openPlayback(story, schedule, directory, 'preview', false);
|
|
493
|
+
async startPreview(story, schedule, directory, _parentOrigin, viewport = defaultViewport) {
|
|
494
|
+
await this.openPlayback(story, schedule, directory, 'preview', { ...viewport, fps: defaultVideoOutput.fps }, false);
|
|
389
495
|
return nativePreview(command => this.session.preview(command));
|
|
390
496
|
}
|
|
391
|
-
async openPlayback(story, schedule, directory, mode, verifyTiming) {
|
|
497
|
+
async openPlayback(story, schedule, directory, mode, output, verifyTiming) {
|
|
392
498
|
requireCondition(this.deck, 'POWERPOINT_INSPECTION', 'Inspect the native deck before playback', 3);
|
|
393
499
|
requireCondition(!this.session, 'POWERPOINT_SESSION', 'This native adapter already owns a session', 5);
|
|
394
500
|
directory = resolve(directory);
|
|
@@ -406,20 +512,20 @@ export class PowerPointAdapter {
|
|
|
406
512
|
return source ? [{ ...clip, src: source.src }] : [];
|
|
407
513
|
});
|
|
408
514
|
const request = join(directory, 'request.json');
|
|
409
|
-
const
|
|
515
|
+
const geometry_requests = geometryRequests(schedule).map(item => ({ ...item, native_id: this.slide(item.slide).native_id }));
|
|
410
516
|
const capture = mode === 'record' ? { ffmpeg: executable('ffmpeg'), ffprobe: executable('ffprobe') } : {};
|
|
411
|
-
await saveJson(request, { version: 1, mode, directory, deck: story.deck, deck_sha256: this.deck.deck_sha256, parent_pid: process.pid, operations,
|
|
517
|
+
await saveJson(request, { version: 1, mode, directory, deck: story.deck, deck_sha256: this.deck.deck_sha256, parent_pid: process.pid, operations, geometry_requests, media, output, duration_ms: schedule.duration_ms, verify_timing: verifyTiming, ...capture });
|
|
412
518
|
this.session = new NativeSession(directory, request);
|
|
413
519
|
await this.session.waitFor('prepared.json', hasStageDeadline() ? undefined : 120000);
|
|
414
520
|
}
|
|
415
521
|
async execute(progress) {
|
|
416
522
|
requireCondition(this.session && this.prepared, 'POWERPOINT_SESSION', 'Prepare the native presentation before execution', 5);
|
|
417
|
-
const {
|
|
523
|
+
const { schedule, directory, production } = this.prepared;
|
|
418
524
|
progress?.('Recording native PowerPoint presentation');
|
|
419
525
|
await writeFile(join(directory, 'start'), 'start\n');
|
|
420
|
-
const observed = parseEvidence(await this.session.waitFor('result.json', hasStageDeadline() ? undefined : schedule.duration_ms + 90000), directory, production.verify_timing, schedule
|
|
526
|
+
const observed = parseEvidence(await this.session.waitFor('result.json', hasStageDeadline() ? undefined : schedule.duration_ms + 90000), directory, production.verify_timing, geometryRequests(schedule), production.output);
|
|
421
527
|
const properties = await probe(observed.file);
|
|
422
|
-
requireCondition(properties.width ===
|
|
528
|
+
requireCondition(properties.width === production.output.width && properties.height === production.output.height && !properties.has_audio, 'CAPTURE_DIMENSIONS', 'Native capture must contain the requested audience dimensions and no audio', 5);
|
|
423
529
|
progress?.(production.verify_timing ? 'Verifying captured timing' : 'Locating capture origin; per-cue timing verification skipped');
|
|
424
530
|
const timing = production.verify_timing ? await calibrate(observed.file, observed.markers, observed.references, schedule.duration_ms, directory) : await estimateOrigin(observed.file, observed.markers, schedule.duration_ms, directory);
|
|
425
531
|
const visual = { version: 1, file: observed.file, properties, events: observed.events, ...(observed.annotation_geometry.length ? { annotation_geometry: observed.annotation_geometry } : {}), origin: { method: production.verify_timing ? 'decoded_markers' : 'opening_markers', uncertainty_ms: timing.uncertainty_ms, mapping: timing.mapping }, timing, provenance: { adapter: this.id, version: this.version, dependencies: observed.dependencies } };
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import type { PresentationInspection, Storyboard, Schedule } from '../contracts.js';
|
|
1
|
+
import type { PresentationInspection, Storyboard, Schedule, Viewport } from '../contracts.js';
|
|
2
2
|
export declare function inspectSlidev(deck: string): Promise<PresentationInspection>;
|
|
3
|
-
export declare function validateSlidev(story: Storyboard, inspection: PresentationInspection,
|
|
3
|
+
export declare function validateSlidev(story: Storyboard, inspection: PresentationInspection, options?: {
|
|
4
|
+
viewport?: Viewport;
|
|
5
|
+
schedule?: Schedule;
|
|
6
|
+
}): void;
|
|
@@ -42,9 +42,10 @@ 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'] };
|
|
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'] };
|
|
46
46
|
}
|
|
47
|
-
export function validateSlidev(story, inspection,
|
|
47
|
+
export function validateSlidev(story, inspection, options) {
|
|
48
|
+
const schedule = options?.schedule;
|
|
48
49
|
for (const scene of story.scenes) {
|
|
49
50
|
requireCondition(inspection.slides.some(s => s.id === scene.slide), 'SLIDE_REFERENCE', `Scene ${scene.id} has unknown slide ${scene.slide}`);
|
|
50
51
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import './browser-runtime.js';
|
|
2
2
|
import { type Browser, type Page } from 'playwright';
|
|
3
3
|
import { type ChildProcess } from 'node:child_process';
|
|
4
|
-
import type
|
|
4
|
+
import { type PresentationAdapter, type Schedule, type Storyboard, type Viewport, type VisualArtifact, type ProgressReporter, type ProductionOptions, type PresentationInspection } from '../contracts.js';
|
|
5
5
|
import { inspectSlidev, validateSlidev } from './slidev-inspection.js';
|
|
6
6
|
import { type Reference } from '../calibration.js';
|
|
7
7
|
export declare class SlidevAdapter implements PresentationAdapter {
|
|
@@ -17,7 +17,6 @@ export declare class SlidevAdapter implements PresentationAdapter {
|
|
|
17
17
|
private rawCaptureFile?;
|
|
18
18
|
private captureToken?;
|
|
19
19
|
schedule: Schedule;
|
|
20
|
-
story: Storyboard;
|
|
21
20
|
directory: string;
|
|
22
21
|
references: Reference[];
|
|
23
22
|
production: ProductionOptions;
|
|
@@ -25,11 +24,11 @@ export declare class SlidevAdapter implements PresentationAdapter {
|
|
|
25
24
|
validate: typeof validateSlidev;
|
|
26
25
|
private stopServer;
|
|
27
26
|
private startServer;
|
|
28
|
-
startPreview(story: Storyboard, schedule: Schedule, directory: string, parentOrigin: string): Promise<{
|
|
27
|
+
startPreview(story: Storyboard, schedule: Schedule, directory: string, parentOrigin: string, _viewport?: Viewport): Promise<{
|
|
29
28
|
url: string;
|
|
30
29
|
}>;
|
|
31
30
|
private start;
|
|
32
|
-
inspectTargets(
|
|
31
|
+
inspectTargets(deck: string, viewport: Viewport): Promise<PresentationInspection['annotation_targets']>;
|
|
33
32
|
private stopCapture;
|
|
34
33
|
prepare(story: Storyboard, schedule: Schedule, directory: string, production?: ProductionOptions): Promise<void>;
|
|
35
34
|
execute(progress?: ProgressReporter): Promise<VisualArtifact>;
|
package/dist/adapters/slidev.js
CHANGED
|
@@ -6,6 +6,8 @@ import { createServer } from 'node:net';
|
|
|
6
6
|
import { mkdir, rename, rm, stat, writeFile } from 'node:fs/promises';
|
|
7
7
|
import { dirname, join, resolve } from 'node:path';
|
|
8
8
|
import { fileURLToPath } from 'node:url';
|
|
9
|
+
import { defaultVideoOutput } from '../contracts.js';
|
|
10
|
+
import { geometryRequests } from '../annotation-paint.js';
|
|
9
11
|
import { inspectSlidev, validateSlidev } from './slidev-inspection.js';
|
|
10
12
|
import { calibrate, estimateOrigin } from '../calibration.js';
|
|
11
13
|
import { execute, probe, saveJson, hashFile, digest, videoFramePeriod, executionSignal } from '../media.js';
|
|
@@ -34,10 +36,9 @@ export class SlidevAdapter {
|
|
|
34
36
|
rawCaptureFile;
|
|
35
37
|
captureToken;
|
|
36
38
|
schedule;
|
|
37
|
-
story;
|
|
38
39
|
directory;
|
|
39
40
|
references = [];
|
|
40
|
-
production = { verify_timing: false };
|
|
41
|
+
production = { verify_timing: false, output: defaultVideoOutput };
|
|
41
42
|
inspect = inspectSlidev;
|
|
42
43
|
validate = validateSlidev;
|
|
43
44
|
async stopServer(server) {
|
|
@@ -92,7 +93,7 @@ export class SlidevAdapter {
|
|
|
92
93
|
}
|
|
93
94
|
}
|
|
94
95
|
}
|
|
95
|
-
async startServer(
|
|
96
|
+
async startServer(deck, mode) {
|
|
96
97
|
executionSignal()?.throwIfAborted();
|
|
97
98
|
requireCondition(!this.closed, 'INTERRUPTED', 'Slidev startup aborted', 5);
|
|
98
99
|
const port = await new Promise((resolve, reject) => {
|
|
@@ -101,7 +102,7 @@ export class SlidevAdapter {
|
|
|
101
102
|
socket.listen(0, '127.0.0.1', () => { const address = socket.address(); const port = typeof address === 'object' && address ? address.port : 0; socket.close(() => resolve(port)); });
|
|
102
103
|
});
|
|
103
104
|
const server = fileURLToPath(new URL('./slidev-server.js', import.meta.url));
|
|
104
|
-
this.server = spawn(process.execPath, [server,
|
|
105
|
+
this.server = spawn(process.execPath, [server, deck, String(port), ...(mode ? [mode.kind, mode.file] : [])], { cwd: dirname(deck), stdio: ['ignore', 'pipe', 'pipe'], detached: process.platform !== 'win32', windowsHide: true });
|
|
105
106
|
this.server.stdout?.on('data', data => { this.log += data.toString(); });
|
|
106
107
|
this.server.stderr?.on('data', data => { this.log += data.toString(); });
|
|
107
108
|
if (this.closed || executionSignal()?.aborted) {
|
|
@@ -127,18 +128,18 @@ export class SlidevAdapter {
|
|
|
127
128
|
requireCondition(ready, 'SLIDEV_TIMEOUT', 'Slidev did not become ready', 5);
|
|
128
129
|
return url;
|
|
129
130
|
}
|
|
130
|
-
async startPreview(story, schedule, directory, parentOrigin) {
|
|
131
|
+
async startPreview(story, schedule, directory, parentOrigin, _viewport) {
|
|
131
132
|
this.directory = directory;
|
|
132
133
|
await mkdir(directory, { recursive: true });
|
|
133
134
|
const mediaHashes = Object.fromEntries(await Promise.all(story.media.map(async (media) => [media.id, await hashFile(media.src)])));
|
|
134
135
|
const config = resolve(directory, 'preview.json');
|
|
135
136
|
await saveJson(config, { schedule, mediaHashes, parentOrigin });
|
|
136
|
-
const url = await this.startServer(story, { kind: 'preview', file: config });
|
|
137
|
+
const url = await this.startServer(story.deck, { kind: 'preview', file: config });
|
|
137
138
|
return { url: `${url}/1?slidevideo=1&slidevideo-preview=1` };
|
|
138
139
|
}
|
|
139
|
-
async start(
|
|
140
|
+
async start(deck, viewport, mode) {
|
|
140
141
|
const executablePath = executable('browser');
|
|
141
|
-
const url = await this.startServer(
|
|
142
|
+
const url = await this.startServer(deck, mode);
|
|
142
143
|
executionSignal()?.throwIfAborted();
|
|
143
144
|
requireCondition(!this.closed, 'INTERRUPTED', 'Browser startup aborted', 5);
|
|
144
145
|
this.browser = await chromium.launch({
|
|
@@ -152,7 +153,7 @@ export class SlidevAdapter {
|
|
|
152
153
|
executionSignal()?.throwIfAborted();
|
|
153
154
|
throw new ProductionError('INTERRUPTED', 'Browser startup aborted', 5);
|
|
154
155
|
}
|
|
155
|
-
this.page = await this.browser.newPage({ viewport: { width:
|
|
156
|
+
this.page = await this.browser.newPage({ viewport: { width: viewport.width, height: viewport.height }, deviceScaleFactor: 1, acceptDownloads: false });
|
|
156
157
|
this.page.setDefaultNavigationTimeout(120000);
|
|
157
158
|
this.page.on('pageerror', error => { this.log += `\nBrowser error: ${error.message}`; });
|
|
158
159
|
await this.page.addInitScript(() => {
|
|
@@ -163,9 +164,9 @@ export class SlidevAdapter {
|
|
|
163
164
|
await this.page.waitForFunction(() => Boolean(window.__slidevideo), { timeout: 120000 });
|
|
164
165
|
return this.page;
|
|
165
166
|
}
|
|
166
|
-
async inspectTargets(
|
|
167
|
+
async inspectTargets(deck, viewport) {
|
|
167
168
|
try {
|
|
168
|
-
const page = await this.start(
|
|
169
|
+
const page = await this.start(deck, viewport);
|
|
169
170
|
return await page.evaluate(() => window.__slidevideo.inspectTargets());
|
|
170
171
|
}
|
|
171
172
|
catch (error) {
|
|
@@ -203,8 +204,7 @@ export class SlidevAdapter {
|
|
|
203
204
|
signal.removeEventListener('abort', onAbort);
|
|
204
205
|
}
|
|
205
206
|
}
|
|
206
|
-
async prepare(story, schedule, directory, production = { verify_timing: false }) {
|
|
207
|
-
this.story = story;
|
|
207
|
+
async prepare(story, schedule, directory, production = { verify_timing: false, output: defaultVideoOutput }) {
|
|
208
208
|
this.schedule = schedule;
|
|
209
209
|
this.directory = directory;
|
|
210
210
|
this.production = production;
|
|
@@ -217,7 +217,7 @@ export class SlidevAdapter {
|
|
|
217
217
|
const captureConfig = join(this.stagingDirectory, 'capture.json');
|
|
218
218
|
await writeFile(captureConfig, JSON.stringify({ file: this.rawCaptureFile, token: this.captureToken }), { mode: 0o600 });
|
|
219
219
|
try {
|
|
220
|
-
const page = await this.start(story, { kind: 'capture', file: captureConfig });
|
|
220
|
+
const page = await this.start(story.deck, production.output, { kind: 'capture', file: captureConfig });
|
|
221
221
|
const mediaHashes = Object.fromEntries(await Promise.all(story.media.map(async (media) => [media.id, await hashFile(media.src)])));
|
|
222
222
|
await page.evaluate(({ schedule, mediaHashes }) => window.__slidevideo.prepare(schedule, mediaHashes), { schedule, mediaHashes });
|
|
223
223
|
await page.addStyleTag({ content: 'body.slidevideo-capture .slidev-nav-controls, body.slidevideo-capture .slidev-nav {display:none!important}' });
|
|
@@ -378,7 +378,7 @@ export class SlidevAdapter {
|
|
|
378
378
|
return bytes;
|
|
379
379
|
},
|
|
380
380
|
};
|
|
381
|
-
}, { output:
|
|
381
|
+
}, { output: production.output, token: this.captureToken });
|
|
382
382
|
await page.waitForTimeout(500);
|
|
383
383
|
}
|
|
384
384
|
catch (error) {
|
|
@@ -409,9 +409,10 @@ export class SlidevAdapter {
|
|
|
409
409
|
if (!playbackError)
|
|
410
410
|
throw error;
|
|
411
411
|
}
|
|
412
|
+
const expectedGeometry = geometryRequests(this.schedule).length;
|
|
412
413
|
if (observed) {
|
|
413
414
|
await saveJson(join(this.directory, 'events.json'), observed);
|
|
414
|
-
if (
|
|
415
|
+
if (expectedGeometry)
|
|
415
416
|
await saveJson(join(this.directory, 'annotation-geometry.json'), { version: 1, geometry: observed.annotation_geometry ?? [], failure: observed.failure });
|
|
416
417
|
}
|
|
417
418
|
let stopError;
|
|
@@ -460,12 +461,12 @@ export class SlidevAdapter {
|
|
|
460
461
|
requireCondition(remuxedOk && Boolean(observed), 'CAPTURE_STREAM', 'Capture stream did not complete', 5);
|
|
461
462
|
progress?.(this.production.verify_timing ? 'Verifying captured timing' : 'Locating capture origin; per-cue timing verification skipped');
|
|
462
463
|
const properties = await probe(file);
|
|
463
|
-
requireCondition(properties.width === this.
|
|
464
|
-
requireCondition((observed.annotation_geometry?.length ?? 0) ===
|
|
464
|
+
requireCondition(properties.width === this.production.output.width && properties.height === this.production.output.height, 'CAPTURE_DIMENSIONS', 'Capture dimensions differ from requested full audience frame', 5);
|
|
465
|
+
requireCondition((observed.annotation_geometry?.length ?? 0) === expectedGeometry, 'ANNOTATION_GEOMETRY', 'Annotation geometry collection did not complete. See annotation-geometry.json.', 5);
|
|
465
466
|
const timing = this.production.verify_timing
|
|
466
467
|
? await calibrate(file, observed.markers, this.references, this.schedule.duration_ms, this.directory)
|
|
467
468
|
: await estimateOrigin(file, observed.markers, this.schedule.duration_ms, this.directory);
|
|
468
|
-
const visual = { version: 1, file, ...(
|
|
469
|
+
const visual = { version: 1, file, ...(expectedGeometry ? { annotation_geometry: observed.annotation_geometry ?? [] } : {}), properties, events: observed.events, origin: { method: this.production.verify_timing ? 'decoded_markers' : 'opening_markers', uncertainty_ms: timing.uncertainty_ms, mapping: timing.mapping }, timing, provenance: { adapter: this.id, version: this.version, dependencies: { chromium: this.browser.version(), slidev: '53.1.0', playwright: '1.65.1' } } };
|
|
469
470
|
await saveJson(join(this.directory, 'visual.json'), visual);
|
|
470
471
|
requireCondition(!this.production.verify_timing || timing.status === 'accepted', 'TIMING_ACCEPTANCE', 'Capture completed but decoded timing evidence failed. See calibration.json.', 6);
|
|
471
472
|
return visual;
|
|
@@ -1,19 +1,73 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AnnotationGeometry, GeometryRequest, GeometryTarget, Rectangle, ResolvedAnnotation, ResolvedHighlightAnnotation, ResolvedUnderlineAnnotation, Schedule } from './contracts.js';
|
|
2
|
+
export type BlendMode = 'source-over' | 'darken';
|
|
2
3
|
export type AnnotationPaint = {
|
|
3
4
|
rectangle: Rectangle;
|
|
4
5
|
color: string;
|
|
5
6
|
opacity: number;
|
|
6
|
-
blend:
|
|
7
|
+
blend: BlendMode;
|
|
7
8
|
};
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
export type HighlightFragmentPaint = {
|
|
10
|
+
fill: AnnotationPaint;
|
|
11
|
+
bottom_border?: AnnotationPaint;
|
|
12
|
+
};
|
|
13
|
+
export type HighlightEffect = {
|
|
14
|
+
effect: 'highlight';
|
|
15
|
+
start_ms: number;
|
|
16
|
+
end_ms: number;
|
|
17
|
+
fragments: HighlightFragmentPaint[];
|
|
18
|
+
};
|
|
19
|
+
export type UnderlineFragmentPaint = {
|
|
20
|
+
rectangle: Rectangle;
|
|
16
21
|
color: string;
|
|
17
22
|
opacity: number;
|
|
18
|
-
blend:
|
|
23
|
+
blend: BlendMode;
|
|
24
|
+
style: 'solid' | 'dashed';
|
|
25
|
+
};
|
|
26
|
+
export type UnderlineEffect = {
|
|
27
|
+
effect: 'underline';
|
|
28
|
+
start_ms: number;
|
|
29
|
+
end_ms: number;
|
|
30
|
+
in_ms: number;
|
|
31
|
+
out_ms: number;
|
|
32
|
+
fragments: UnderlineFragmentPaint[];
|
|
33
|
+
};
|
|
34
|
+
export type PaintableEffect = HighlightEffect | UnderlineEffect;
|
|
35
|
+
export type BlendGroup = {
|
|
36
|
+
blend: BlendMode;
|
|
37
|
+
primitives: AnnotationPaint[];
|
|
38
|
+
};
|
|
39
|
+
export interface EffectCanvas2D<FillStyle = never, StrokeStyle = never, CompositeOp = never> {
|
|
40
|
+
save(): void;
|
|
41
|
+
restore(): void;
|
|
42
|
+
clearRect(x: number, y: number, width: number, height: number): void;
|
|
43
|
+
fillRect(x: number, y: number, width: number, height: number): void;
|
|
44
|
+
fillStyle: string | FillStyle;
|
|
45
|
+
strokeStyle: string | StrokeStyle;
|
|
46
|
+
lineWidth: number;
|
|
47
|
+
globalAlpha: number;
|
|
48
|
+
globalCompositeOperation: BlendMode | CompositeOp;
|
|
49
|
+
}
|
|
50
|
+
export declare function targetKey(target: GeometryTarget): string;
|
|
51
|
+
export declare function annotationTargets(annotation: ResolvedAnnotation): GeometryTarget[];
|
|
52
|
+
export declare function geometryRequests(schedule: Pick<Schedule, 'annotations'>): GeometryRequest[];
|
|
53
|
+
export declare function findTargetGeometry(observations: readonly AnnotationGeometry[], annotation: Pick<ResolvedAnnotation, 'scene' | 'slide' | 'visit' | 'click' | 'start_ms' | 'end_ms'>, target: GeometryTarget): AnnotationGeometry | undefined;
|
|
54
|
+
export declare function highlightPaint(annotation: Pick<ResolvedHighlightAnnotation, 'appearance' | 'start_ms' | 'end_ms'>, { content, fragments, viewport }: Pick<AnnotationGeometry, 'content' | 'fragments' | 'viewport'>): HighlightEffect;
|
|
55
|
+
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 annotationPaint(annotation: Pick<ResolvedHighlightAnnotation, 'effect' | 'appearance' | 'start_ms' | 'end_ms'> | Pick<ResolvedUnderlineAnnotation, 'effect' | 'appearance' | 'motion' | 'start_ms' | 'end_ms'>, geometry: Pick<AnnotationGeometry, 'content' | 'fragments' | 'viewport'>): PaintableEffect;
|
|
57
|
+
export declare function underlineFragmentsVisible(effect: Pick<UnderlineEffect, 'fragments'>): boolean;
|
|
58
|
+
export declare function underlineWipeFractions(effect: Pick<UnderlineEffect, 'start_ms' | 'end_ms' | 'in_ms' | 'out_ms'>, timeMs: number): {
|
|
59
|
+
wipeStart: number;
|
|
60
|
+
wipeEnd: number;
|
|
19
61
|
};
|
|
62
|
+
export declare function underlineFragmentPrimitives(fragment: UnderlineFragmentPaint, spanLeft: number, spanRight: number): AnnotationPaint[];
|
|
63
|
+
export declare function effectPrimitives(effects: readonly PaintableEffect[], timeMs: number): AnnotationPaint[];
|
|
64
|
+
export declare function effectNeedsBaseFrames(effects: readonly PaintableEffect[], timeMs: number): boolean;
|
|
65
|
+
export declare function groupEffectsByBlend(effects: readonly PaintableEffect[], timeMs: number): BlendGroup[];
|
|
66
|
+
export declare function effectDirtyBounds(effects: readonly PaintableEffect[], timeMs: number, extraRectangles: readonly Rectangle[], viewport: {
|
|
67
|
+
width: number;
|
|
68
|
+
height: number;
|
|
69
|
+
}): Rectangle | undefined;
|
|
70
|
+
export declare function paintPrimitives<FillStyle, StrokeStyle, CompositeOp>(context: EffectCanvas2D<FillStyle, StrokeStyle, CompositeOp>, primitives: readonly AnnotationPaint[], options?: {
|
|
71
|
+
backdrop?: boolean;
|
|
72
|
+
}): void;
|
|
73
|
+
export declare function paintEffects<FillStyle, StrokeStyle, CompositeOp>(context: EffectCanvas2D<FillStyle, StrokeStyle, CompositeOp>, effects: readonly PaintableEffect[], timeMs: number): void;
|