@slidevideo/cli 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/IMPRESSUM.md +13 -0
  3. package/LICENSE-TERMS.md +58 -0
  4. package/README.md +25 -0
  5. package/addons/slidevideo/geometry.ts +127 -0
  6. package/addons/slidevideo/global-top.vue +232 -0
  7. package/addons/slidevideo/package.json +1 -0
  8. package/addons/slidevideo/playback-entries.ts +14 -0
  9. package/addons/slidevideo/preview.ts +157 -0
  10. package/dist/adapters/browser-runtime.d.ts +37 -0
  11. package/dist/adapters/browser-runtime.js +1 -0
  12. package/dist/adapters/edge.d.ts +7 -0
  13. package/dist/adapters/edge.js +46 -0
  14. package/dist/adapters/elevenlabs.d.ts +7 -0
  15. package/dist/adapters/elevenlabs.js +58 -0
  16. package/dist/adapters/powerpoint-preview.d.ts +2 -0
  17. package/dist/adapters/powerpoint-preview.js +18 -0
  18. package/dist/adapters/powerpoint.d.ts +21 -0
  19. package/dist/adapters/powerpoint.js +434 -0
  20. package/dist/adapters/registry.d.ts +4 -0
  21. package/dist/adapters/registry.js +13 -0
  22. package/dist/adapters/slidev-inputs.d.ts +1 -0
  23. package/dist/adapters/slidev-inputs.js +86 -0
  24. package/dist/adapters/slidev-inspection.d.ts +3 -0
  25. package/dist/adapters/slidev-inspection.js +79 -0
  26. package/dist/adapters/slidev-server.d.ts +1 -0
  27. package/dist/adapters/slidev-server.js +48 -0
  28. package/dist/adapters/slidev.d.ts +30 -0
  29. package/dist/adapters/slidev.js +251 -0
  30. package/dist/annotation-paint.d.ts +19 -0
  31. package/dist/annotation-paint.js +13 -0
  32. package/dist/annotations.d.ts +27 -0
  33. package/dist/annotations.js +115 -0
  34. package/dist/assembly.d.ts +48 -0
  35. package/dist/assembly.js +138 -0
  36. package/dist/calibration.d.ts +24 -0
  37. package/dist/calibration.js +346 -0
  38. package/dist/cli.d.ts +2 -0
  39. package/dist/cli.js +180 -0
  40. package/dist/compositor.d.ts +18 -0
  41. package/dist/compositor.js +155 -0
  42. package/dist/contracts.d.ts +358 -0
  43. package/dist/contracts.js +1 -0
  44. package/dist/errors.d.ts +7 -0
  45. package/dist/errors.js +15 -0
  46. package/dist/executables.d.ts +23 -0
  47. package/dist/executables.js +165 -0
  48. package/dist/installation.d.ts +6 -0
  49. package/dist/installation.js +32 -0
  50. package/dist/license-key.d.ts +12 -0
  51. package/dist/license-key.js +55 -0
  52. package/dist/license-status.d.ts +16 -0
  53. package/dist/license-status.js +12 -0
  54. package/dist/media.d.ts +12 -0
  55. package/dist/media.js +57 -0
  56. package/dist/overlay-assets.d.ts +2 -0
  57. package/dist/overlay-assets.js +58 -0
  58. package/dist/pipeline.d.ts +50 -0
  59. package/dist/pipeline.js +257 -0
  60. package/dist/preview/contracts.d.ts +34 -0
  61. package/dist/preview/contracts.js +1 -0
  62. package/dist/preview/player.d.ts +1 -0
  63. package/dist/preview/player.js +129 -0
  64. package/dist/preview/server.d.ts +1 -0
  65. package/dist/preview/server.js +112 -0
  66. package/dist/preview/view.d.ts +1 -0
  67. package/dist/preview/view.js +36 -0
  68. package/dist/revoked-keys.json +1 -0
  69. package/dist/run.d.ts +12 -0
  70. package/dist/run.js +109 -0
  71. package/dist/setup-install.d.ts +7 -0
  72. package/dist/setup-install.js +98 -0
  73. package/dist/setup-license.d.ts +2 -0
  74. package/dist/setup-license.js +63 -0
  75. package/dist/setup.d.ts +34 -0
  76. package/dist/setup.js +218 -0
  77. package/dist/speech.d.ts +6 -0
  78. package/dist/speech.js +125 -0
  79. package/dist/storyboard.d.ts +6 -0
  80. package/dist/storyboard.js +86 -0
  81. package/dist/timing.d.ts +6 -0
  82. package/dist/timing.js +162 -0
  83. package/package.json +134 -0
  84. package/schemas/annotation-geometry.v1.json +130 -0
  85. package/schemas/revoked-keys.schema.json +11 -0
  86. package/schemas/run-manifest.v1.json +96 -0
  87. package/schemas/schedule.v1.json +108 -0
  88. package/schemas/schedule.v2.json +496 -0
  89. package/schemas/speech.v1.json +173 -0
  90. package/schemas/storyboard.v1.json +461 -0
  91. package/schemas/storyboard.v2.json +802 -0
  92. package/schemas/timing-evidence.v1.json +129 -0
  93. package/skills/slidevideo/SKILL.md +56 -0
  94. package/skills/slidevideo/references/production.md +76 -0
  95. package/skills/slidevideo/references/storyboard.md +272 -0
  96. package/tools/edge-tts/edge-tts.py +19 -0
  97. package/tools/edge-tts/requirements.lock +34 -0
  98. package/tools/powerpoint/Native.cs +277 -0
  99. package/tools/powerpoint/powerpoint.ps1 +714 -0
  100. package/tools/powerpoint/preview.ps1 +100 -0
  101. package/tools/powerpoint/requirements.json +11 -0
@@ -0,0 +1,434 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { readFileSync } from 'node:fs';
3
+ import { access, mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises';
4
+ import { tmpdir } from 'node:os';
5
+ import { extname, join, resolve } from 'node:path';
6
+ import { fileURLToPath } from 'node:url';
7
+ import { nativePreview } from './powerpoint-preview.js';
8
+ import { calibrate, estimateOrigin } from '../calibration.js';
9
+ import { digest, executionScope, hashFile, json, probe, saveJson, videoFramePeriod } from '../media.js';
10
+ import { ProductionError, requireCondition } from '../errors.js';
11
+ import { packagePath } from '../installation.js';
12
+ import { executable } from '../executables.js';
13
+ const helper = packagePath('tools', 'powerpoint', 'powerpoint.ps1');
14
+ const powershell = 'powershell.exe';
15
+ const pause = (ms) => new Promise(resolve => setTimeout(resolve, ms));
16
+ async function waitBounded(completion, ms) {
17
+ let timer;
18
+ try {
19
+ await Promise.race([completion, new Promise(resolve => { timer = setTimeout(resolve, ms); })]);
20
+ }
21
+ finally {
22
+ clearTimeout(timer);
23
+ }
24
+ }
25
+ function nativeFailure(failure) {
26
+ const input = ['MEDIA_SOURCE_MISMATCH', 'POWERPOINT_SOURCE_CHANGED'];
27
+ const dependency = ['POWERPOINT_DEPENDENCY', 'POWERPOINT_BUSY', 'POWERPOINT_PACKAGE'];
28
+ return new ProductionError(failure.code, failure.message, input.includes(failure.code) ? 2 : dependency.includes(failure.code) ? 3 : failure.code === 'INTERRUPTED' ? 130 : 5);
29
+ }
30
+ function object(value) { return value !== null && typeof value === 'object' && !Array.isArray(value); }
31
+ function finite(value) { return typeof value === 'number' && Number.isFinite(value); }
32
+ function rectangle(value) { return object(value) && ['x', 'y', 'width', 'height'].every(key => finite(value[key])) && Number(value.width) > 0 && Number(value.height) > 0; }
33
+ function parseDeck(value) {
34
+ 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);
35
+ for (const slide of value.slides) {
36
+ 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);
37
+ for (const shape of slide.shapes) {
38
+ requireCondition(object(shape), 'POWERPOINT_PROTOCOL', 'Native inspection returned an invalid shape identity', 5);
39
+ const bounds = shape.bounds;
40
+ requireCondition(Number.isInteger(shape.id) && typeof shape.name === 'string' && object(bounds) && ['x', 'y', 'width', 'height'].every(key => finite(bounds[key])) && finite(shape.visible_from_click) && Array.isArray(shape.unsupported) && shape.unsupported.every(reason => typeof reason === 'string'), 'POWERPOINT_PROTOCOL', 'Native inspection returned an invalid shape identity', 5);
41
+ }
42
+ for (const effect of slide.effects)
43
+ 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);
44
+ }
45
+ for (const media of value.media)
46
+ requireCondition(object(media) && typeof media.id === 'string' && typeof media.sha256 === 'string' && /^[a-f0-9]{64}$/.test(media.sha256) && typeof media.part === 'string' && ['native_id', 'shape', 'duration_ms', 'start_ms', 'end_ms', 'autoplay', 'loop', 'rewind', 'fullscreen', 'left', 'top', 'right', 'bottom'].every(key => finite(media[key])), 'POWERPOINT_PROTOCOL', 'Native inspection could not identify a complete embedded video. Linked, online or grouped media are unsupported.', 3);
47
+ for (const item of value.unsupported)
48
+ requireCondition(object(item) && typeof item.reason === 'string', 'POWERPOINT_PROTOCOL', 'Native inspection returned an invalid capability diagnostic', 5);
49
+ for (const version of Object.values(value.dependencies))
50
+ requireCondition(typeof version === 'string', 'POWERPOINT_PROTOCOL', 'Native inspection returned invalid dependency versions', 5);
51
+ const deck = value;
52
+ for (const slide of deck.slides) {
53
+ slide.clicks = [];
54
+ let previousStart = 0;
55
+ let previousEnd = 0;
56
+ for (const effect of slide.effects) {
57
+ if (effect.trigger === 1) {
58
+ slide.clicks.push(0);
59
+ previousStart = 0;
60
+ previousEnd = 0;
61
+ }
62
+ if (!slide.clicks.length)
63
+ continue;
64
+ const start = (effect.trigger === 3 ? previousEnd : previousStart) + effect.delay_ms;
65
+ const end = start + effect.duration_ms;
66
+ slide.clicks[slide.clicks.length - 1] = Math.max(slide.clicks[slide.clicks.length - 1], end);
67
+ previousStart = start;
68
+ previousEnd = end;
69
+ }
70
+ }
71
+ return deck;
72
+ }
73
+ function parseEvidence(value, directory, verified, annotations, output) {
74
+ 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);
75
+ requireCondition(value.annotation_geometry.length === annotations.length, 'ANNOTATION_GEOMETRY', 'Native recording did not measure every annotation interval', 5);
76
+ for (const annotation of annotations) {
77
+ const matches = value.annotation_geometry.filter(item => object(item) && item.id === annotation.id);
78
+ requireCondition(matches.length === 1, 'ANNOTATION_GEOMETRY', `Annotation ${annotation.id} has missing or ambiguous native geometry`, 5);
79
+ const geometry = matches[0];
80
+ requireCondition(object(geometry) && geometry.id === annotation.id && geometry.scene === annotation.scene && geometry.slide === annotation.slide && geometry.visit === annotation.visit && geometry.click === annotation.click && geometry.start_ms === annotation.start_ms && geometry.end_ms === annotation.end_ms, 'ANNOTATION_GEOMETRY', `Annotation ${annotation.id} has invalid native playback state`, 5);
81
+ requireCondition(finite(geometry.observed_start_ms) && finite(geometry.observed_end_ms) && geometry.observed_start_ms >= annotation.start_ms && geometry.observed_start_ms < annotation.end_ms && geometry.observed_start_ms - annotation.start_ms <= 100 && geometry.observed_end_ms >= annotation.end_ms && geometry.observed_end_ms - annotation.end_ms <= 100 && Number.isInteger(geometry.samples) && Number(geometry.samples) >= 2, 'ANNOTATION_GEOMETRY', `Annotation ${annotation.id} has incomplete native interval measurements`, 5);
82
+ 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 && rectangle(geometry.bounds) && geometry.bounds.x >= 0 && geometry.bounds.y >= 0 && geometry.bounds.x + geometry.bounds.width <= 1.000001 && geometry.bounds.y + geometry.bounds.height <= 1.000001, 'ANNOTATION_GEOMETRY', `Annotation ${annotation.id} has invalid native coordinate mapping`, 5);
83
+ }
84
+ for (const event of value.events)
85
+ 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);
86
+ const colors = verified ? ['#ff00ff', '#00ffff', '#ffff00', '#00ff00', '#ff0000', '#0000ff'] : ['#ff00ff', '#ffff00'];
87
+ requireCondition(value.markers.length === colors.length, 'POWERPOINT_PROTOCOL', 'Native recording returned an incomplete marker sequence', 6);
88
+ for (const [index, marker] of value.markers.entries())
89
+ requireCondition(object(marker) && marker.color === colors[index] && finite(marker.observed_ms) && finite(marker.rendered_by_ms) && finite(marker.paint_interval_ms) && marker.rendered_by_ms >= marker.observed_ms && marker.paint_interval_ms >= 0, 'POWERPOINT_PROTOCOL', 'Native marker has no measured paint interval', 6);
90
+ for (const reference of value.references)
91
+ requireCondition(object(reference) && typeof reference.id === 'string' && finite(reference.expected_ms) && typeof reference.before === 'string' && typeof reference.after === 'string' && ['transition', 'sample'].includes(String(reference.mode)) && finite(reference.frame_period_ms), 'POWERPOINT_PROTOCOL', 'Native verification returned an invalid reference', 6);
92
+ for (const version of Object.values(value.dependencies))
93
+ requireCondition(typeof version === 'string', 'POWERPOINT_PROTOCOL', 'Native recording returned invalid dependency versions', 5);
94
+ return value;
95
+ }
96
+ class NativeSession {
97
+ directory;
98
+ child;
99
+ completion;
100
+ closePromise;
101
+ log = '';
102
+ exited = false;
103
+ spawnError;
104
+ sequence = 0;
105
+ pending = new Map();
106
+ cancel = () => { void this.close().catch(() => { }); };
107
+ constructor(directory, request) {
108
+ this.directory = directory;
109
+ this.child = spawn(powershell, ['-NoLogo', '-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-File', helper, '-Request', request], { windowsHide: true, stdio: ['pipe', 'pipe', 'pipe'] });
110
+ this.child.stdout?.setEncoding('utf8');
111
+ let output = '';
112
+ this.child.stdout?.on('data', data => {
113
+ output += data.toString();
114
+ let newline;
115
+ while ((newline = output.indexOf('\n')) >= 0) {
116
+ const line = output.slice(0, newline).trimEnd();
117
+ output = output.slice(newline + 1);
118
+ if (!line.startsWith('SLIDEVIDEO_PREVIEW ')) {
119
+ this.log += `${line}\n`;
120
+ continue;
121
+ }
122
+ try {
123
+ const message = JSON.parse(line.slice('SLIDEVIDEO_PREVIEW '.length));
124
+ this.pending.get(message.id)?.resolve(message.state);
125
+ this.pending.delete(message.id);
126
+ }
127
+ catch {
128
+ this.log += 'Invalid native preview response\n';
129
+ }
130
+ }
131
+ });
132
+ this.child.stderr?.on('data', data => { this.log += data.toString(); });
133
+ this.completion = new Promise(resolve => {
134
+ this.child.once('error', error => { this.spawnError = error; this.exited = true; resolve(); });
135
+ this.child.once('close', () => { this.exited = true; for (const request of this.pending.values())
136
+ request.reject(new ProductionError('POWERPOINT_NATIVE', 'The native preview worker exited. Close the preview and inspect its diagnostics.', 5)); this.pending.clear(); resolve(); });
137
+ });
138
+ process.once('SIGINT', this.cancel);
139
+ process.once('SIGTERM', this.cancel);
140
+ }
141
+ async preview(command) {
142
+ const id = ++this.sequence;
143
+ let timer;
144
+ try {
145
+ requireCondition(!this.exited && this.child.stdin?.writable, 'POWERPOINT_SESSION', 'The native preview is closed', 5);
146
+ return await new Promise((resolve, reject) => {
147
+ this.pending.set(id, { resolve, reject });
148
+ timer = setTimeout(() => { this.pending.delete(id); reject(new ProductionError('POWERPOINT_TIMEOUT', 'Native preview did not respond within 15 seconds', 5)); }, 15000);
149
+ this.child.stdin.write(`${JSON.stringify({ id, command })}\n`, error => { if (error) {
150
+ this.pending.delete(id);
151
+ reject(error);
152
+ } });
153
+ });
154
+ }
155
+ catch (error) {
156
+ let failure;
157
+ try {
158
+ failure = await json(join(this.directory, 'failure.json'));
159
+ }
160
+ catch {
161
+ throw error;
162
+ }
163
+ throw nativeFailure({ ...failure, message: `${failure.message} Diagnostics: ${this.directory}` });
164
+ }
165
+ finally {
166
+ clearTimeout(timer);
167
+ }
168
+ }
169
+ async waitFor(name, timeout) {
170
+ const deadline = Date.now() + timeout;
171
+ while (Date.now() < deadline) {
172
+ executionScope.getStore()?.throwIfAborted();
173
+ try {
174
+ return await json(join(this.directory, name));
175
+ }
176
+ catch (error) {
177
+ if (error.code !== 'ENOENT')
178
+ throw error;
179
+ }
180
+ try {
181
+ const failure = await json(join(this.directory, 'failure.json'));
182
+ failure.message += ` Diagnostics: ${this.directory}`;
183
+ throw nativeFailure(failure);
184
+ }
185
+ catch (error) {
186
+ if (error.code !== 'ENOENT')
187
+ throw error;
188
+ }
189
+ requireCondition(!this.spawnError, 'POWERPOINT_DEPENDENCY', `Cannot start Windows PowerShell 5.1: ${this.spawnError?.message}`, 3);
190
+ requireCondition(!this.exited, 'POWERPOINT_NATIVE', `Native helper exited before ${name}. See ${join(this.directory, 'powerpoint.log')}`, 5);
191
+ await pause(25);
192
+ }
193
+ throw new ProductionError('POWERPOINT_TIMEOUT', `Native helper did not produce ${name} within ${timeout} ms. Diagnostics remain in ${this.directory}`, 5);
194
+ }
195
+ close() {
196
+ return this.closePromise ??= this.closeOnce();
197
+ }
198
+ async closeOnce() {
199
+ process.removeListener('SIGINT', this.cancel);
200
+ process.removeListener('SIGTERM', this.cancel);
201
+ await writeFile(join(this.directory, 'cancel'), 'cancel\n');
202
+ await waitBounded(this.completion, 15000);
203
+ const graceful = this.exited;
204
+ if (!graceful) {
205
+ let recorder;
206
+ try {
207
+ recorder = await json(join(this.directory, 'recorder.json'));
208
+ }
209
+ catch { }
210
+ if (recorder && Number.isInteger(recorder.pid) && /^\d+$/.test(recorder.started_ticks) && recorder.process_name) {
211
+ const request = join(this.directory, 'stop-recorder.json');
212
+ await saveJson(request, { version: 1, mode: 'stop-recorder', directory: this.directory, recorder_pid: recorder.pid, recorder_started_ticks: recorder.started_ticks, recorder_process_name: recorder.process_name });
213
+ const stop = spawn(powershell, ['-NoLogo', '-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-File', helper, '-Request', request], { windowsHide: true, stdio: 'ignore' });
214
+ const finished = new Promise(resolve => { stop.once('error', () => resolve()); stop.once('close', () => resolve()); });
215
+ await waitBounded(finished, 10000);
216
+ if (stop.exitCode === null)
217
+ stop.kill();
218
+ }
219
+ this.child.kill();
220
+ await waitBounded(this.completion, 5000);
221
+ await saveJson(join(this.directory, 'cleanup-timeout.json'), { version: 1, gaps: ['The native worker did not respond to bounded cancellation. Fallback shutdown targeted only its owned helper and identity-checked recorder. PowerPoint was preserved because presentation-scoped cleanup could not be confirmed. Close the private slidevideo presentation manually if it remains open.'] });
222
+ }
223
+ await writeFile(join(this.directory, 'powerpoint.log'), this.log);
224
+ if (this.spawnError)
225
+ return;
226
+ let cleanup;
227
+ try {
228
+ cleanup = await json(join(this.directory, 'cleanup.json'));
229
+ }
230
+ catch (error) {
231
+ if (error.code !== 'ENOENT')
232
+ throw error;
233
+ }
234
+ 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);
235
+ }
236
+ }
237
+ export class PowerPointAdapter {
238
+ id = 'powerpoint';
239
+ version = 'native-2';
240
+ deck;
241
+ session;
242
+ cleanupPromise;
243
+ prepared;
244
+ async inspect(file) {
245
+ requireCondition(process.platform === 'win32', 'POWERPOINT_PLATFORM', 'PowerPoint .pptx playback requires Windows with installed desktop Microsoft PowerPoint. Run this storyboard locally on that Windows machine.', 3);
246
+ requireCondition(extname(file).toLowerCase() === '.pptx', 'PRESENTATION_ADAPTER', `Unsupported presentation format ${extname(file)}`, 3);
247
+ try {
248
+ await access(file);
249
+ }
250
+ catch {
251
+ throw new ProductionError('MISSING_DECK', `Cannot read deck ${file}`);
252
+ }
253
+ const directory = await mkdtemp(join(tmpdir(), 'slidevideo-powerpoint-'));
254
+ const request = join(directory, 'request.json');
255
+ await saveJson(request, { version: 1, mode: 'inspect', directory, deck: resolve(file), deck_sha256: await hashFile(file), parent_pid: process.pid });
256
+ const session = new NativeSession(directory, request);
257
+ let completed = false;
258
+ try {
259
+ this.deck = parseDeck(await session.waitFor('result.json', 120000));
260
+ completed = true;
261
+ return { slides: this.deck.slides.map(slide => ({ id: slide.id || `slide-${slide.native_id}`, index: slide.index, clicks: slide.clicks.length, clicks_known: true })), media_ids: [...new Set(this.deck.media.map(media => media.id))], files: [resolve(file), helper, packagePath('tools', 'powerpoint', 'Native.cs'), fileURLToPath(import.meta.url)], capabilities: ['slide', 'reveal', 'play', 'highlight:region', 'highlight:shape'], annotation_targets: this.targets() };
262
+ }
263
+ finally {
264
+ await session.close();
265
+ if (completed)
266
+ await rm(directory, { recursive: true, force: true });
267
+ }
268
+ }
269
+ targets() {
270
+ 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}`}` })) }));
271
+ }
272
+ async inspectTargets(_story) {
273
+ requireCondition(this.deck, 'POWERPOINT_INSPECTION', 'Inspect the native deck before discovering annotation targets', 3);
274
+ return this.targets();
275
+ }
276
+ slide(id) {
277
+ const slides = this.deck.slides.filter(slide => slide.id === id || `slide-${slide.native_id}` === id);
278
+ requireCondition(slides.length === 1, 'SLIDE_REFERENCE', `Native slide ${id} is missing or ambiguous. Use a unique authored Slide.Name or slide-<SlideID>.`);
279
+ return slides[0];
280
+ }
281
+ validate(story, _inspection, schedule) {
282
+ const deck = this.deck;
283
+ requireCondition(deck, 'POWERPOINT_INSPECTION', 'Inspect the native deck before validation', 3);
284
+ 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);
285
+ requireCondition(deck.unsupported.length === 0, 'POWERPOINT_CAPABILITY', deck.unsupported.map(item => `${item.slide ? `Slide ${item.slide}: ` : ''}${item.reason}`).join('\n'), 3);
286
+ for (const slide of deck.slides) {
287
+ 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
+ let clicked = false;
289
+ for (const effect of slide.effects) {
290
+ if (effect.trigger === 1)
291
+ clicked = true;
292
+ 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);
293
+ }
294
+ }
295
+ for (const media of deck.media)
296
+ requireCondition(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, 'POWERPOINT_CAPABILITY', `Video ${media.id} requires full-source playback with no native trim, autoplay, loop, rewind or fullscreen transform`, 3);
297
+ for (const declaration of story.media) {
298
+ const candidates = deck.media.filter(media => media.id === declaration.id);
299
+ requireCondition(candidates.length > 0, 'MEDIA_TARGET', `The native deck has no embedded video named ${declaration.id}`, 3);
300
+ let hash;
301
+ try {
302
+ hash = digest(readFileSync(declaration.src));
303
+ }
304
+ catch {
305
+ throw new ProductionError('MISSING_MEDIA', `Cannot read media ${declaration.src}`);
306
+ }
307
+ requireCondition(candidates.every(media => media.sha256 === hash), 'MEDIA_SOURCE_MISMATCH', `Storyboard media ${declaration.id} does not match the exact embedded video bytes in the deck`);
308
+ }
309
+ for (const scene of story.scenes)
310
+ this.slide(scene.slide);
311
+ const actions = [...story.scenes.flatMap(scene => scene.actions), ...story.cues.map(cue => ({ ...cue.action, id: cue.id }))];
312
+ for (const action of actions) {
313
+ if (action.type === 'slide')
314
+ this.slide(action.target);
315
+ if (action.type === 'play')
316
+ requireCondition((action.trim_start_ms ?? 0) === 0 && action.trim_end_ms === undefined && (action.rate ?? 1) === 1, 'POWERPOINT_CAPABILITY', `Video action ${action.id} requires full-source playback at rate 1 without storyboard trims`, 3);
317
+ }
318
+ for (const annotation of story.annotations ?? [])
319
+ requireCondition(annotation.target.type !== 'element', 'ANNOTATION_TARGET', `Annotation ${annotation.id} uses a Slidev selector. PowerPoint requires an existing shape ID or normalized region.`, 3);
320
+ if (schedule) {
321
+ this.operations(story, schedule);
322
+ for (const annotation of schedule.annotations ?? []) {
323
+ const slide = this.slide(annotation.slide);
324
+ if (annotation.target.type === 'shape') {
325
+ const target = annotation.target;
326
+ const candidates = slide.shapes.filter(shape => shape.id === target.id);
327
+ requireCondition(candidates.length === 1, 'ANNOTATION_TARGET', `Annotation ${annotation.id}, slide ${annotation.slide}: shape ${annotation.target.id} is missing or ambiguous`, 3);
328
+ const shape = candidates[0];
329
+ 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);
330
+ }
331
+ }
332
+ }
333
+ else if (!story.cues.some(cue => cue.action.type === 'slide' || cue.action.type === 'reveal')) {
334
+ for (const scene of story.scenes) {
335
+ let slide = this.slide(scene.slide);
336
+ let click = 0;
337
+ for (const action of scene.actions) {
338
+ if (action.type === 'slide') {
339
+ slide = this.slide(action.target);
340
+ click = 0;
341
+ }
342
+ if (action.type === 'reveal') {
343
+ requireCondition(action.click === click + 1 && action.click <= slide.clicks.length && action.duration_ms + 0.1 >= slide.clicks[action.click - 1], 'REVEAL_TARGET', `Reveal ${action.id} must execute the next native click on ${slide.id} and include its complete duration`, 3);
344
+ click = action.click;
345
+ }
346
+ if (action.type === 'play')
347
+ requireCondition(deck.media.filter(media => media.native_id === slide.native_id && media.id === action.media).length === 1, 'MEDIA_TARGET', `Video ${action.media} is missing or ambiguous on slide ${slide.id}`, 3);
348
+ }
349
+ }
350
+ }
351
+ }
352
+ operations(story, schedule) {
353
+ const operations = [];
354
+ let slide;
355
+ let click = 0;
356
+ for (const item of schedule.actions) {
357
+ const action = item.action;
358
+ if (action.type === 'slide') {
359
+ slide = this.slide(action.target);
360
+ click = 0;
361
+ operations.push({ id: item.id, scene: item.scene, type: 'slide', at_ms: item.start_ms, end_ms: item.end_ms, native_id: slide.native_id, settle_ms: action.duration_ms });
362
+ }
363
+ if (action.type === 'reveal') {
364
+ 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);
365
+ operations.push({ id: item.id, scene: item.scene, type: 'reveal', at_ms: item.start_ms, end_ms: item.end_ms, native_id: slide.native_id, click: action.click, settle_ms: action.duration_ms });
366
+ click = action.click;
367
+ }
368
+ if (action.type === 'play') {
369
+ const candidates = this.deck.media.filter(media => media.id === action.media && media.native_id === slide?.native_id);
370
+ const declaration = story.media.find(media => media.id === action.media);
371
+ const source = schedule.media.find(media => media.id === action.media);
372
+ requireCondition(candidates.length === 1 && declaration && source, 'MEDIA_TARGET', `Video ${action.media} is missing or ambiguous on the active native slide`, 3);
373
+ requireCondition(Math.abs(source.duration_ms - candidates[0].duration_ms) <= 100, 'MEDIA_SOURCE_MISMATCH', `Native video duration differs from source for ${action.media}`);
374
+ 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, frame_period_ms: 0 });
375
+ }
376
+ }
377
+ for (const [index, operation] of operations.entries())
378
+ for (const next of operations.slice(index + 1)) {
379
+ const overlaps = operation.type === 'play' ? next.type === 'slide' || next.type === 'play' : next.type !== 'play';
380
+ requireCondition(!overlaps || next.at_ms >= operation.end_ms, 'ACTION_CONFLICT', `Native operations ${operation.id} and ${next.id} overlap`);
381
+ }
382
+ return operations;
383
+ }
384
+ async prepare(story, schedule, directory, production = { verify_timing: false }) {
385
+ await this.openPlayback(story, schedule, directory, 'record', production.verify_timing);
386
+ this.prepared = { story, schedule, directory: resolve(directory), production };
387
+ }
388
+ async startPreview(story, schedule, directory) {
389
+ await this.openPlayback(story, schedule, directory, 'preview', false);
390
+ return nativePreview(command => this.session.preview(command));
391
+ }
392
+ async openPlayback(story, schedule, directory, mode, verifyTiming) {
393
+ requireCondition(this.deck, 'POWERPOINT_INSPECTION', 'Inspect the native deck before playback', 3);
394
+ requireCondition(!this.session, 'POWERPOINT_SESSION', 'This native adapter already owns a session', 5);
395
+ directory = resolve(directory);
396
+ await mkdir(directory, { recursive: true });
397
+ const operations = this.operations(story, schedule);
398
+ if (verifyTiming)
399
+ for (const operation of operations)
400
+ if (operation.type === 'play') {
401
+ const clip = this.deck.media.find(media => media.native_id === operation.native_id && media.shape === operation.shape);
402
+ operation.frame_period_ms = await videoFramePeriod(story.media.find(media => media.id === clip.id).src);
403
+ requireCondition(operation.frame_period_ms > 0 && operation.frame_period_ms <= 100, 'SOURCE_FRAME_TIMING', `Cannot bound native video source frame timing for ${clip.id}`, 3);
404
+ }
405
+ const media = this.deck.media.flatMap(clip => {
406
+ const source = story.media.find(media => media.id === clip.id);
407
+ return source ? [{ ...clip, src: source.src }] : [];
408
+ });
409
+ const request = join(directory, 'request.json');
410
+ const annotations = (schedule.annotations ?? []).map(annotation => ({ ...annotation, native_id: this.slide(annotation.slide).native_id }));
411
+ const capture = mode === 'record' ? { ffmpeg: executable('ffmpeg'), ffprobe: executable('ffprobe') } : {};
412
+ await saveJson(request, { version: 1, mode, directory, deck: story.deck, deck_sha256: this.deck.deck_sha256, parent_pid: process.pid, operations, annotations, media, output: story.output, duration_ms: schedule.duration_ms, verify_timing: verifyTiming, ...capture });
413
+ this.session = new NativeSession(directory, request);
414
+ await this.session.waitFor('prepared.json', 120000);
415
+ }
416
+ async execute(progress) {
417
+ requireCondition(this.session && this.prepared, 'POWERPOINT_SESSION', 'Prepare the native presentation before execution', 5);
418
+ const { story, schedule, directory, production } = this.prepared;
419
+ progress?.('Recording native PowerPoint presentation');
420
+ await writeFile(join(directory, 'start'), 'start\n');
421
+ const observed = parseEvidence(await this.session.waitFor('result.json', schedule.duration_ms + 90000), directory, production.verify_timing, schedule.annotations ?? [], story.output);
422
+ const properties = await probe(observed.file);
423
+ requireCondition(properties.width === story.output.width && properties.height === story.output.height && !properties.has_audio, 'CAPTURE_DIMENSIONS', 'Native capture must contain the requested audience dimensions and no audio', 5);
424
+ progress?.(production.verify_timing ? 'Verifying captured timing' : 'Locating capture origin; per-cue timing verification skipped');
425
+ 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);
426
+ 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 } };
427
+ await saveJson(join(directory, 'visual.json'), visual);
428
+ requireCondition(!production.verify_timing || timing.status === 'accepted', 'TIMING_ACCEPTANCE', 'Native capture completed but decoded timing evidence failed. See calibration.json.', 6);
429
+ return visual;
430
+ }
431
+ cleanup() {
432
+ return this.cleanupPromise ??= this.session?.close() ?? Promise.resolve();
433
+ }
434
+ }
@@ -0,0 +1,4 @@
1
+ import type { PresentationAdapter, TtsAdapter } from '../contracts.js';
2
+ export declare const ttsAdapters: Map<string, TtsAdapter>;
3
+ export declare const presentationAdapters: Map<string, () => PresentationAdapter>;
4
+ export declare function presentationAdapter(deck: string): PresentationAdapter;
@@ -0,0 +1,13 @@
1
+ import { ElevenLabsAdapter } from './elevenlabs.js';
2
+ import { EdgeAdapter } from './edge.js';
3
+ import { SlidevAdapter } from './slidev.js';
4
+ import { PowerPointAdapter } from './powerpoint.js';
5
+ import { requireCondition } from '../errors.js';
6
+ import { extname } from 'node:path';
7
+ export const ttsAdapters = new Map([['edge-tts', new EdgeAdapter()], ['elevenlabs', new ElevenLabsAdapter()]]);
8
+ export const presentationAdapters = new Map([['.md', () => new SlidevAdapter()], ['.pptx', () => new PowerPointAdapter()]]);
9
+ export function presentationAdapter(deck) {
10
+ const factory = presentationAdapters.get(extname(deck).toLowerCase());
11
+ requireCondition(factory, 'PRESENTATION_ADAPTER', `Unsupported presentation ${extname(deck)}`, 3);
12
+ return factory();
13
+ }
@@ -0,0 +1 @@
1
+ export declare function slidevInputs(deck: string, headmatter: Record<string, unknown>, markdownFiles?: string[]): Promise<string[]>;
@@ -0,0 +1,86 @@
1
+ import { readFile, readdir, stat, realpath } from 'node:fs/promises';
2
+ import { basename, dirname, extname, join, resolve } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ import { ProductionError, requireCondition } from '../errors.js';
5
+ import { packagePath } from '../installation.js';
6
+ const code = new Set(['.vue', '.js', '.ts', '.mjs', '.mts', '.cjs', '.cts', '.jsx', '.tsx', '.html', '.css', '.scss', '.sass', '.less', '.styl']);
7
+ const moduleExtensions = ['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json', '.vue', '.css'];
8
+ const metadata = new Set(['package.json', 'package-lock.json', 'npm-shrinkwrap.json', 'yarn.lock', 'pnpm-lock.yaml', 'tsconfig.json', 'jsconfig.json']);
9
+ const runtimeDirectories = new Set(['components', 'layouts', 'setup', 'styles', 'public', 'assets']);
10
+ export async function slidevInputs(deck, headmatter, markdownFiles = []) {
11
+ const root = dirname(deck);
12
+ const files = new Set([deck, ...markdownFiles]);
13
+ const visiting = new Set();
14
+ async function collect(directory, recursive = false) {
15
+ const canonical = await realpath(directory);
16
+ requireCondition(!visiting.has(canonical), 'PRESENTATION_INPUT_CYCLE', `Cyclic rendering directory: ${directory}`);
17
+ visiting.add(canonical);
18
+ try {
19
+ for (const entry of await readdir(directory, { withFileTypes: true })) {
20
+ if (entry.name.startsWith('.') || ['node_modules', 'runs', 'dist'].includes(entry.name))
21
+ continue;
22
+ const path = join(directory, entry.name);
23
+ if (entry.isSymbolicLink() && !recursive && !runtimeDirectories.has(entry.name) && !code.has(extname(path)) && !metadata.has(entry.name))
24
+ continue;
25
+ const type = entry.isSymbolicLink() ? await stat(path).catch(() => {
26
+ throw new ProductionError('PRESENTATION_INPUT', `Cannot resolve rendering input: ${path}`);
27
+ }) : entry;
28
+ if (type.isDirectory() && (recursive || runtimeDirectories.has(entry.name)))
29
+ await collect(path, true);
30
+ else if (type.isFile() && (recursive ? !['.mdx', '.rst', '.log'].includes(extname(path)) : code.has(extname(path)) || metadata.has(entry.name)))
31
+ files.add(path);
32
+ }
33
+ }
34
+ finally {
35
+ visiting.delete(canonical);
36
+ }
37
+ }
38
+ await collect(root);
39
+ await collect(packagePath('addons', 'slidevideo'));
40
+ files.add(fileURLToPath(new URL('./slidev-server.js', import.meta.url)));
41
+ for (const location of [headmatter.theme, ...Array.isArray(headmatter.addons) ? headmatter.addons : []]) {
42
+ if (typeof location !== 'string' || !/^(?:\.{1,2}\/|@\/)/.test(location))
43
+ continue;
44
+ await collect(resolve(root, location.startsWith('@/') ? location.slice(2) : location));
45
+ }
46
+ for (const file of files) {
47
+ if (['package.json', 'package-lock.json', 'npm-shrinkwrap.json'].includes(basename(file)))
48
+ continue;
49
+ if (!code.has(extname(file)) && !['.md', '.mdx', '.json', '.yaml', '.yml'].includes(extname(file)))
50
+ continue;
51
+ const source = await readFile(file, 'utf8');
52
+ const references = [
53
+ ...Array.from(source.matchAll(/["'`]([^"'`\r\n]+)["'`]/g), match => match[1]),
54
+ ...Array.from(source.matchAll(/(?:^|\n)\s*(?:src|background|image):\s*([^\s"'#][^\s#]*)/g), match => match[1]),
55
+ ...Array.from(source.matchAll(/!?\[[^\]]*\]\(([^\s)]+)/g), match => match[1]),
56
+ ...Array.from(source.matchAll(/(?:url\(|<<<\s*)([^\s)'"#]+)/g), match => match[1]),
57
+ ];
58
+ for (const reference of references) {
59
+ if (/^(?:[a-z][a-z\d+.-]*:|\/\/|#)/i.test(reference) || reference.includes('${'))
60
+ continue;
61
+ const path = reference.split(/[?#]/)[0];
62
+ if (!path || !/^(?:\.{1,2}\/|@\/|\/)/.test(path) && !/\.[a-z][a-z\d]*$/i.test(path))
63
+ continue;
64
+ const bases = path.startsWith('@/') ? [resolve(root, path.slice(2))] : path.startsWith('/') ? [resolve(root, 'public', path.slice(1)), resolve(root, path.slice(1))] : [resolve(dirname(file), path)];
65
+ let found = false;
66
+ for (const base of bases) {
67
+ for (const candidate of [base, ...moduleExtensions.map(extension => `${base}${extension}`), ...moduleExtensions.map(extension => join(base, `index${extension}`))]) {
68
+ try {
69
+ if ((await stat(candidate)).isFile()) {
70
+ files.add(candidate);
71
+ found = true;
72
+ break;
73
+ }
74
+ }
75
+ catch (error) {
76
+ if (!['ENOENT', 'ENOTDIR'].includes(error.code ?? ''))
77
+ throw error;
78
+ }
79
+ }
80
+ if (found)
81
+ break;
82
+ }
83
+ }
84
+ }
85
+ return [...files].sort();
86
+ }
@@ -0,0 +1,3 @@
1
+ import type { PresentationInspection, Storyboard, Schedule } from '../contracts.js';
2
+ export declare function inspectSlidev(deck: string): Promise<PresentationInspection>;
3
+ export declare function validateSlidev(story: Storyboard, inspection: PresentationInspection, schedule?: Schedule): void;
@@ -0,0 +1,79 @@
1
+ import { access } from 'node:fs/promises';
2
+ import { fork } from 'node:child_process';
3
+ import { fileURLToPath } from 'node:url';
4
+ import { dirname, extname } from 'node:path';
5
+ import { slidevInputs } from './slidev-inputs.js';
6
+ import { requireCondition, ProductionError } from '../errors.js';
7
+ async function loadDeck(deck) {
8
+ const child = fork(fileURLToPath(new URL('./slidev-server.js', import.meta.url)), [deck, 'inspect'], { cwd: dirname(deck), stdio: ['ignore', 'ignore', 'pipe', 'ipc'], execArgv: [] });
9
+ let diagnostics = '';
10
+ child.stderr.on('data', data => { diagnostics = (diagnostics + data.toString()).slice(-4000); });
11
+ const stop = () => { child.kill('SIGKILL'); };
12
+ process.once('SIGINT', stop);
13
+ process.once('SIGTERM', stop);
14
+ const timer = setTimeout(stop, 120000);
15
+ try {
16
+ return await new Promise((resolve, reject) => {
17
+ child.once('message', (data) => resolve(data));
18
+ child.once('error', error => reject(new ProductionError('DECK_SYNTAX', `Cannot load Slidev deck ${deck}: ${error.message}`)));
19
+ child.once('exit', (code, signal) => reject(new ProductionError('DECK_SYNTAX', `Cannot load Slidev deck ${deck}: ${diagnostics || `loader exited ${code ?? signal}`}`)));
20
+ });
21
+ }
22
+ finally {
23
+ clearTimeout(timer);
24
+ process.removeListener('SIGINT', stop);
25
+ process.removeListener('SIGTERM', stop);
26
+ if (child.exitCode === null)
27
+ stop();
28
+ }
29
+ }
30
+ export async function inspectSlidev(deck) {
31
+ requireCondition(extname(deck) === '.md', 'PRESENTATION_ADAPTER', `Unsupported presentation format ${extname(deck)}`, 3);
32
+ try {
33
+ await access(deck);
34
+ }
35
+ catch {
36
+ throw new ProductionError('MISSING_DECK', `Cannot read deck ${deck}`);
37
+ }
38
+ const parsed = await loadDeck(deck);
39
+ requireCondition(parsed.errors.length === 0, 'DECK_SYNTAX', parsed.errors.join('\n'));
40
+ const slides = parsed.slides.map((slide, index) => ({
41
+ id: String(slide.frontmatter.name ?? `slide-${index + 1}`), index: index + 1,
42
+ clicks: Number(slide.frontmatter.clicks ?? 0), clicks_known: slide.frontmatter.clicks != null,
43
+ }));
44
+ requireCondition(new Set(slides.map(s => s.id)).size === slides.length, 'SLIDE_ID', 'Slide names must be unique');
45
+ const media_ids = parsed.slides.flatMap(slide => [...slide.content.matchAll(/<(?:video|audio)\b[^>]*\bid=["']([^"']+)["']/g)].map(match => match[1]));
46
+ return { slides, media_ids, files: await slidevInputs(deck, parsed.headmatter, parsed.files), capabilities: ['slide', 'reveal', 'play', 'highlight:region', 'highlight:element'] };
47
+ }
48
+ export function validateSlidev(story, inspection, schedule) {
49
+ for (const scene of story.scenes) {
50
+ requireCondition(inspection.slides.some(s => s.id === scene.slide), 'SLIDE_REFERENCE', `Scene ${scene.id} has unknown slide ${scene.slide}`);
51
+ }
52
+ for (const annotation of story.annotations ?? []) {
53
+ requireCondition(story.scenes.some(scene => scene.id === annotation.scene), 'ANNOTATION_SCENE', `Annotation ${annotation.id} has unknown scene ${annotation.scene}`);
54
+ requireCondition(annotation.target.type !== 'shape', 'ANNOTATION_TARGET', `Annotation ${annotation.id} uses a PowerPoint shape target unsupported by Slidev`, 3, { annotation: annotation.id });
55
+ }
56
+ const actions = [...story.scenes.flatMap(s => s.actions), ...story.cues.map(c => ({ ...c.action, id: c.id }))];
57
+ for (const action of actions) {
58
+ if (action.type === 'slide')
59
+ requireCondition(inspection.slides.some(s => s.id === action.target), 'SLIDE_REFERENCE', `Unknown slide ${action.target}`);
60
+ if (action.type === 'play')
61
+ requireCondition(inspection.media_ids.includes(action.media), 'MEDIA_TARGET', `Deck has no media element ${action.media}`, 3);
62
+ }
63
+ const slides = new Map(inspection.slides.map(slide => [slide.id, slide]));
64
+ const sequence = schedule ? schedule.actions.map(item => item.action) : story.scenes.flatMap(scene => [{ id: `${scene.id}:slide`, type: 'slide', target: scene.slide, duration_ms: 0 }, ...scene.actions]);
65
+ let active;
66
+ let click = 0;
67
+ const pendingNavigation = !schedule && story.cues.some(cue => cue.action.type === 'slide');
68
+ for (const action of sequence) {
69
+ if (action.type === 'slide') {
70
+ active = action.target;
71
+ click = 0;
72
+ }
73
+ if (action.type === 'reveal' && !pendingNavigation) {
74
+ const slide = active ? slides.get(active) : undefined;
75
+ requireCondition(slide && (slide.clicks_known === false || action.click <= slide.clicks) && action.click > click, 'REVEAL_TARGET', `Reveal ${action.id} has unsupported click ${action.click} on slide ${active}`, 3, { action: action.id });
76
+ click = action.click;
77
+ }
78
+ }
79
+ }
@@ -0,0 +1 @@
1
+ export {};