@slidevideo/cli 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -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 +116 -26
- 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 +91 -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 +35 -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 +65 -33
- package/tools/powerpoint/powerpoint.ps1 +52 -41
- package/tools/powerpoint/preview.ps1 +5 -5
|
@@ -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';
|
|
@@ -69,16 +71,32 @@ function parseDeck(value) {
|
|
|
69
71
|
}
|
|
70
72
|
return deck;
|
|
71
73
|
}
|
|
72
|
-
function
|
|
74
|
+
function validTarget(value, expected) {
|
|
75
|
+
if (!object(value) || value.type !== expected.type)
|
|
76
|
+
return false;
|
|
77
|
+
switch (expected.type) {
|
|
78
|
+
case 'slide': return true;
|
|
79
|
+
case 'region': return value.units === 'normalized' && value.x === expected.x && value.y === expected.y && value.width === expected.width && value.height === expected.height;
|
|
80
|
+
case 'element': return value.selector === expected.selector;
|
|
81
|
+
case 'shape': return value.id === expected.id;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function requestLabel(request) {
|
|
85
|
+
return request.annotations.length === 1
|
|
86
|
+
? `Annotation ${request.annotations[0]}`
|
|
87
|
+
: `Annotations ${request.annotations.join(', ')}`;
|
|
88
|
+
}
|
|
89
|
+
function parseEvidence(value, directory, verified, requests, output) {
|
|
73
90
|
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
|
-
|
|
91
|
+
requireCondition(value.annotation_geometry.length === requests.length, 'ANNOTATION_GEOMETRY', 'Native recording did not measure every target geometry interval', 5);
|
|
92
|
+
for (const request of requests) {
|
|
93
|
+
const label = `${requestLabel(request)} (${request.key}, ${request.slide}, visit ${request.visit})`;
|
|
94
|
+
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);
|
|
95
|
+
requireCondition(matches.length === 1, 'ANNOTATION_GEOMETRY', `${label} has missing or ambiguous native geometry`, 5);
|
|
78
96
|
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 &&
|
|
97
|
+
requireCondition(object(geometry) && validTarget(geometry.target, request.target), 'ANNOTATION_GEOMETRY', `${label} has invalid native target metadata`, 5);
|
|
98
|
+
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);
|
|
99
|
+
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
100
|
}
|
|
83
101
|
for (const event of value.events)
|
|
84
102
|
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 +251,47 @@ class NativeSession {
|
|
|
233
251
|
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
252
|
}
|
|
235
253
|
}
|
|
254
|
+
function isSupportedNativeEffect(deck, slide, effect, clicked) {
|
|
255
|
+
return [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);
|
|
256
|
+
}
|
|
257
|
+
function isSupportedNativeMedia(media) {
|
|
258
|
+
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;
|
|
259
|
+
}
|
|
260
|
+
function deckCapabilityIssues(deck) {
|
|
261
|
+
const issues = deck.unsupported.map(item => ({
|
|
262
|
+
...(item.slide ? { slide: item.slide } : {}),
|
|
263
|
+
reason: item.reason,
|
|
264
|
+
}));
|
|
265
|
+
const counts = new Map();
|
|
266
|
+
for (const slide of deck.slides)
|
|
267
|
+
if (slide.id)
|
|
268
|
+
counts.set(slide.id, (counts.get(slide.id) ?? 0) + 1);
|
|
269
|
+
for (const slide of deck.slides) {
|
|
270
|
+
const label = slide.id || `slide-${slide.native_id}`;
|
|
271
|
+
if (slide.id && (counts.get(slide.id) ?? 0) > 1) {
|
|
272
|
+
issues.push({ slide: label, reason: `Slide name ${slide.id} is ambiguous; use slide-${slide.native_id}` });
|
|
273
|
+
}
|
|
274
|
+
if (slide.transition !== 0 || slide.auto_advance !== 0 || slide.hidden !== 0 || slide.interactive !== 0) {
|
|
275
|
+
issues.push({ slide: label, reason: 'Requires slide cuts, manual advancement, visible slides and no interactive animation sequences' });
|
|
276
|
+
}
|
|
277
|
+
let clicked = false;
|
|
278
|
+
for (const effect of slide.effects) {
|
|
279
|
+
if (effect.trigger === 1)
|
|
280
|
+
clicked = true;
|
|
281
|
+
if (!isSupportedNativeEffect(deck, slide, effect, clicked)) {
|
|
282
|
+
issues.push({ slide: label, reason: 'Contains an unsupported effect; only finite click groups of entrance Appear and Fade effects are supported' });
|
|
283
|
+
break;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
for (const media of deck.media) {
|
|
288
|
+
if (!isSupportedNativeMedia(media)) {
|
|
289
|
+
const owner = deck.slides.find(slide => slide.native_id === media.native_id);
|
|
290
|
+
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` });
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
return issues;
|
|
294
|
+
}
|
|
236
295
|
export class PowerPointAdapter {
|
|
237
296
|
id = 'powerpoint';
|
|
238
297
|
version = 'native-2';
|
|
@@ -257,7 +316,34 @@ export class PowerPointAdapter {
|
|
|
257
316
|
try {
|
|
258
317
|
this.deck = parseDeck(await session.waitFor('result.json', 120000));
|
|
259
318
|
completed = true;
|
|
260
|
-
|
|
319
|
+
const unsupported = deckCapabilityIssues(this.deck);
|
|
320
|
+
return {
|
|
321
|
+
dimensions: { width: this.deck.width, height: this.deck.height },
|
|
322
|
+
slides: this.deck.slides.map(slide => ({
|
|
323
|
+
id: slide.id || `slide-${slide.native_id}`,
|
|
324
|
+
...(slide.id ? { alias: `slide-${slide.native_id}` } : {}),
|
|
325
|
+
index: slide.index,
|
|
326
|
+
clicks: slide.clicks.length,
|
|
327
|
+
clicks_known: true,
|
|
328
|
+
...(slide.clicks.length ? { click_durations_ms: [...slide.clicks] } : {}),
|
|
329
|
+
})),
|
|
330
|
+
media_ids: [...new Set(this.deck.media.map(media => media.id))],
|
|
331
|
+
...(this.deck.media.length ? {
|
|
332
|
+
media: this.deck.media.map(media => {
|
|
333
|
+
const owner = this.deck.slides.find(slide => slide.native_id === media.native_id);
|
|
334
|
+
return {
|
|
335
|
+
id: media.id,
|
|
336
|
+
slide: owner ? (owner.id || `slide-${owner.native_id}`) : `slide-${media.native_id}`,
|
|
337
|
+
sha256: media.sha256,
|
|
338
|
+
duration_ms: media.duration_ms,
|
|
339
|
+
};
|
|
340
|
+
}),
|
|
341
|
+
} : {}),
|
|
342
|
+
files: [resolve(file), helper, packagePath('tools', 'powerpoint', 'Native.cs'), fileURLToPath(import.meta.url)],
|
|
343
|
+
capabilities: ['slide', 'reveal', 'play', 'highlight:region', 'highlight:shape', 'underline:region', 'underline:shape'],
|
|
344
|
+
...(unsupported.length ? { unsupported } : {}),
|
|
345
|
+
annotation_targets: this.targets(),
|
|
346
|
+
};
|
|
261
347
|
}
|
|
262
348
|
finally {
|
|
263
349
|
await session.close();
|
|
@@ -266,10 +352,11 @@ export class PowerPointAdapter {
|
|
|
266
352
|
}
|
|
267
353
|
}
|
|
268
354
|
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}`}` })) }));
|
|
355
|
+
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
356
|
}
|
|
271
|
-
async inspectTargets(
|
|
357
|
+
async inspectTargets(_deck, viewport) {
|
|
272
358
|
requireCondition(this.deck, 'POWERPOINT_INSPECTION', 'Inspect the native deck before discovering annotation targets', 3);
|
|
359
|
+
requireCondition(Math.abs(viewport.width / viewport.height - this.deck.width / this.deck.height) <= 2 / viewport.height, 'POWERPOINT_CAPABILITY', 'Native output aspect ratio must match the PowerPoint slide size. Adjust --width and --height or the deck page setup.', 3);
|
|
273
360
|
return this.targets();
|
|
274
361
|
}
|
|
275
362
|
slide(id) {
|
|
@@ -277,10 +364,13 @@ export class PowerPointAdapter {
|
|
|
277
364
|
requireCondition(slides.length === 1, 'SLIDE_REFERENCE', `Native slide ${id} is missing or ambiguous. Use a unique authored Slide.Name or slide-<SlideID>.`);
|
|
278
365
|
return slides[0];
|
|
279
366
|
}
|
|
280
|
-
async validate(story, _inspection,
|
|
367
|
+
async validate(story, _inspection, options) {
|
|
281
368
|
const deck = this.deck;
|
|
369
|
+
const schedule = options?.schedule;
|
|
282
370
|
requireCondition(deck, 'POWERPOINT_INSPECTION', 'Inspect the native deck before validation', 3);
|
|
283
|
-
|
|
371
|
+
if (options?.viewport) {
|
|
372
|
+
requireCondition(Math.abs(options.viewport.width / options.viewport.height - deck.width / deck.height) <= 2 / options.viewport.height, 'POWERPOINT_CAPABILITY', 'Native output aspect ratio must match the PowerPoint slide size. Adjust --width and --height or the deck page setup.', 3);
|
|
373
|
+
}
|
|
284
374
|
requireCondition(deck.unsupported.length === 0, 'POWERPOINT_CAPABILITY', deck.unsupported.map(item => `${item.slide ? `Slide ${item.slide}: ` : ''}${item.reason}`).join('\n'), 3);
|
|
285
375
|
for (const slide of deck.slides) {
|
|
286
376
|
requireCondition(slide.transition === 0 && slide.auto_advance === 0 && slide.hidden === 0 && slide.interactive === 0, 'POWERPOINT_CAPABILITY', `Slide ${slide.id} requires slide cuts, manual advancement, visible slides and no interactive animation sequences`, 3);
|
|
@@ -288,11 +378,11 @@ export class PowerPointAdapter {
|
|
|
288
378
|
for (const effect of slide.effects) {
|
|
289
379
|
if (effect.trigger === 1)
|
|
290
380
|
clicked = true;
|
|
291
|
-
requireCondition(
|
|
381
|
+
requireCondition(isSupportedNativeEffect(deck, slide, effect, clicked), '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);
|
|
292
382
|
}
|
|
293
383
|
}
|
|
294
384
|
for (const media of deck.media)
|
|
295
|
-
requireCondition(
|
|
385
|
+
requireCondition(isSupportedNativeMedia(media), 'POWERPOINT_CAPABILITY', `Video ${media.id} requires full-source playback with no native trim, autoplay, loop, rewind or fullscreen transform`, 3);
|
|
296
386
|
for (const declaration of story.media) {
|
|
297
387
|
const candidates = deck.media.filter(media => media.id === declaration.id);
|
|
298
388
|
requireCondition(candidates.length > 0, 'MEDIA_TARGET', `The native deck has no embedded video named ${declaration.id}`, 3);
|
|
@@ -380,15 +470,15 @@ export class PowerPointAdapter {
|
|
|
380
470
|
}
|
|
381
471
|
return operations;
|
|
382
472
|
}
|
|
383
|
-
async prepare(story, schedule, directory, production = { verify_timing: false }) {
|
|
384
|
-
await this.openPlayback(story, schedule, directory, 'record', production.verify_timing);
|
|
385
|
-
this.prepared = {
|
|
473
|
+
async prepare(story, schedule, directory, production = { verify_timing: false, output: defaultVideoOutput }) {
|
|
474
|
+
await this.openPlayback(story, schedule, directory, 'record', production.output, production.verify_timing);
|
|
475
|
+
this.prepared = { schedule, directory: resolve(directory), production };
|
|
386
476
|
}
|
|
387
|
-
async startPreview(story, schedule, directory) {
|
|
388
|
-
await this.openPlayback(story, schedule, directory, 'preview', false);
|
|
477
|
+
async startPreview(story, schedule, directory, _parentOrigin, viewport = defaultViewport) {
|
|
478
|
+
await this.openPlayback(story, schedule, directory, 'preview', { ...viewport, fps: defaultVideoOutput.fps }, false);
|
|
389
479
|
return nativePreview(command => this.session.preview(command));
|
|
390
480
|
}
|
|
391
|
-
async openPlayback(story, schedule, directory, mode, verifyTiming) {
|
|
481
|
+
async openPlayback(story, schedule, directory, mode, output, verifyTiming) {
|
|
392
482
|
requireCondition(this.deck, 'POWERPOINT_INSPECTION', 'Inspect the native deck before playback', 3);
|
|
393
483
|
requireCondition(!this.session, 'POWERPOINT_SESSION', 'This native adapter already owns a session', 5);
|
|
394
484
|
directory = resolve(directory);
|
|
@@ -406,20 +496,20 @@ export class PowerPointAdapter {
|
|
|
406
496
|
return source ? [{ ...clip, src: source.src }] : [];
|
|
407
497
|
});
|
|
408
498
|
const request = join(directory, 'request.json');
|
|
409
|
-
const
|
|
499
|
+
const geometry_requests = geometryRequests(schedule).map(item => ({ ...item, native_id: this.slide(item.slide).native_id }));
|
|
410
500
|
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,
|
|
501
|
+
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
502
|
this.session = new NativeSession(directory, request);
|
|
413
503
|
await this.session.waitFor('prepared.json', hasStageDeadline() ? undefined : 120000);
|
|
414
504
|
}
|
|
415
505
|
async execute(progress) {
|
|
416
506
|
requireCondition(this.session && this.prepared, 'POWERPOINT_SESSION', 'Prepare the native presentation before execution', 5);
|
|
417
|
-
const {
|
|
507
|
+
const { schedule, directory, production } = this.prepared;
|
|
418
508
|
progress?.('Recording native PowerPoint presentation');
|
|
419
509
|
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
|
|
510
|
+
const observed = parseEvidence(await this.session.waitFor('result.json', hasStageDeadline() ? undefined : schedule.duration_ms + 90000), directory, production.verify_timing, geometryRequests(schedule), production.output);
|
|
421
511
|
const properties = await probe(observed.file);
|
|
422
|
-
requireCondition(properties.width ===
|
|
512
|
+
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
513
|
progress?.(production.verify_timing ? 'Verifying captured timing' : 'Locating capture origin; per-cue timing verification skipped');
|
|
424
514
|
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
515
|
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;
|