@slidevideo/cli 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +3 -3
  3. package/addons/slidevideo/geometry.ts +334 -1
  4. package/addons/slidevideo/global-top.vue +57 -6
  5. package/addons/slidevideo/preview.ts +242 -25
  6. package/assets/fonts/OFL-LICENSES.txt +95 -0
  7. package/assets/fonts/instrument-serif-latin-2.woff2 +0 -0
  8. package/assets/fonts/instrument-serif-latin-ext-1.woff2 +0 -0
  9. package/assets/fonts/jetbrains-mono-latin-4.woff2 +0 -0
  10. package/assets/fonts/jetbrains-mono-latin-ext-3.woff2 +0 -0
  11. package/assets/fonts/plus-jakarta-sans-latin-6.woff2 +0 -0
  12. package/assets/fonts/plus-jakarta-sans-latin-ext-5.woff2 +0 -0
  13. package/dist/adapters/edge.d.ts +1 -0
  14. package/dist/adapters/edge.js +4 -3
  15. package/dist/adapters/elevenlabs.d.ts +1 -0
  16. package/dist/adapters/elevenlabs.js +4 -3
  17. package/dist/adapters/powerpoint-preview.d.ts +1 -1
  18. package/dist/adapters/powerpoint-preview.js +13 -2
  19. package/dist/adapters/powerpoint.js +91 -14
  20. package/dist/adapters/slidev-inspection.js +7 -2
  21. package/dist/annotation-paint.d.ts +195 -5
  22. package/dist/annotation-paint.js +1188 -2
  23. package/dist/annotations.d.ts +26 -2
  24. package/dist/annotations.js +1117 -29
  25. package/dist/assembly.js +143 -37
  26. package/dist/captions.d.ts +6 -0
  27. package/dist/captions.js +320 -0
  28. package/dist/cli.js +59 -19
  29. package/dist/compositor.d.ts +17 -2
  30. package/dist/compositor.js +108 -26
  31. package/dist/contracts.d.ts +254 -14
  32. package/dist/media.js +24 -1
  33. package/dist/pipeline.d.ts +6 -1
  34. package/dist/pipeline.js +68 -20
  35. package/dist/preview/contracts.d.ts +15 -0
  36. package/dist/preview/player.js +527 -34
  37. package/dist/preview/server.d.ts +1 -1
  38. package/dist/preview/server.js +125 -4
  39. package/dist/preview/view.d.ts +1 -1
  40. package/dist/preview/view.js +26 -7
  41. package/dist/run.d.ts +1 -0
  42. package/dist/run.js +20 -0
  43. package/dist/speech.d.ts +13 -3
  44. package/dist/speech.js +164 -45
  45. package/dist/stamp-fonts.d.ts +17 -0
  46. package/dist/stamp-fonts.js +202 -0
  47. package/dist/storyboard.js +60 -3
  48. package/dist/timing.d.ts +4 -1
  49. package/dist/timing.js +322 -14
  50. package/dist/update-check-worker.js +43 -11
  51. package/dist/update-check.js +14 -10
  52. package/package.json +12 -1
  53. package/schemas/annotation-geometry.v1.json +111 -0
  54. package/schemas/schedule.v1.json +1672 -84
  55. package/schemas/storyboard.v1.json +3725 -85
  56. package/skills/slidevideo/SKILL.md +5 -5
  57. package/skills/slidevideo/references/decks.md +6 -4
  58. package/skills/slidevideo/references/production.md +12 -11
  59. package/skills/slidevideo/references/storyboard.md +268 -5
  60. package/tools/powerpoint/powerpoint.ps1 +155 -6
  61. package/tools/powerpoint/preview.ps1 +68 -1
package/dist/timing.js CHANGED
@@ -1,14 +1,27 @@
1
1
  import { requireCondition } from './errors.js';
2
2
  import { probe } from './media.js';
3
3
  import { checkSpeech, retainedSpeechTiming } from './speech.js';
4
- export async function resolveTiming(story, speech) {
4
+ export async function resolveTiming(story, speech, verified) {
5
5
  for (const asset of speech.assets)
6
- await checkSpeech(asset);
6
+ await checkSpeech(asset, verified);
7
7
  return resolveSchedule(story, speech.assets);
8
8
  }
9
+ function approximateAlignment(text, durationMs) {
10
+ if (text.length === 0)
11
+ return null;
12
+ const units = Array.from({ length: text.length }, (_, index) => ({
13
+ text: text[index],
14
+ start: index,
15
+ end: index + 1,
16
+ start_ms: (index / text.length) * durationMs,
17
+ end_ms: ((index + 1) / text.length) * durationMs,
18
+ }));
19
+ return { form: 'original', granularity: 'character', text, units };
20
+ }
9
21
  export async function resolvePreviewTiming(story, adapters, cache) {
10
22
  const assets = [];
11
23
  const approximate = [];
24
+ const audio = new Map();
12
25
  for (const segment of story.narration) {
13
26
  const voice = segment.voice ?? story.voice;
14
27
  requireCondition(voice, 'VOICE_REQUIRED', `Narration ${segment.id} needs a voice`);
@@ -16,15 +29,48 @@ export async function resolvePreviewTiming(story, adapters, cache) {
16
29
  requireCondition(adapter, 'TTS_ADAPTER', `Unsupported TTS provider ${voice.provider}`, 3);
17
30
  adapter.validate(voice);
18
31
  const retained = await retainedSpeechTiming(segment, voice, adapter, cache);
19
- if (retained)
20
- assets.push(retained);
32
+ if (retained) {
33
+ assets.push(retained.timing);
34
+ if (retained.audio)
35
+ audio.set(segment.id, retained.audio);
36
+ }
21
37
  else {
22
38
  approximate.push(segment.id);
23
39
  const words = segment.text.trim().split(/\s+/).filter(Boolean).length;
24
- assets.push({ id: segment.id, duration_ms: Math.max(1000, words * 60000 / 150), transcript: { original: segment.text, normalized: segment.text }, alignment: null });
40
+ const durationMs = Math.max(1000, words * 60000 / 150);
41
+ assets.push({
42
+ id: segment.id,
43
+ duration_ms: durationMs,
44
+ transcript: { original: segment.text, normalized: segment.text },
45
+ alignment: approximateAlignment(segment.text, durationMs),
46
+ });
47
+ }
48
+ }
49
+ const schedule = await resolveSchedule(story, assets);
50
+ const approximateSet = new Set(approximate);
51
+ const seenCues = new Set();
52
+ const approximateCues = [];
53
+ const recordCue = (id) => {
54
+ if (!seenCues.has(id)) {
55
+ seenCues.add(id);
56
+ approximateCues.push(id);
57
+ }
58
+ };
59
+ for (const item of schedule.actions) {
60
+ if (item.cue_span && approximateSet.has(item.cue_span.segment))
61
+ recordCue(item.id);
62
+ }
63
+ for (const annotation of schedule.annotations) {
64
+ if (annotation.cue_span && approximateSet.has(annotation.cue_span.segment))
65
+ recordCue(annotation.source_id ?? annotation.id);
66
+ }
67
+ for (const overlay of story.overlays ?? []) {
68
+ if (overlay.visible?.some(interval => (typeof interval.start !== 'number' && approximateSet.has(interval.start.segment))
69
+ || (typeof interval.end !== 'number' && approximateSet.has(interval.end.segment)))) {
70
+ recordCue(overlay.id);
25
71
  }
26
72
  }
27
- return { schedule: await resolveSchedule(story, assets), approximate };
73
+ return { schedule, approximate, approximateCues, audio };
28
74
  }
29
75
  async function resolveSchedule(story, speech) {
30
76
  const media = await Promise.all(story.media.map(async (item) => ({ ...item, ...await probe(item.src) })));
@@ -117,20 +163,282 @@ async function resolveSchedule(story, speech) {
117
163
  requireCondition(other.start_ms >= item.end_ms, 'MEDIA_NAVIGATION', `Slide ${other.id} interrupts media ${item.id}`);
118
164
  }
119
165
  }
120
- const annotations = story.annotations.map(annotation => {
121
- const { time, segment, context, cue_span } = phrase(annotation, annotation.target);
122
- const end = time + annotation.duration_ms;
166
+ const visuals = actions.filter(item => item.action.type === 'slide' || item.action.type === 'reveal');
167
+ const usedIds = new Set([
168
+ ...story.scenes.map(s => s.id),
169
+ ...story.narration.map(n => n.id),
170
+ ...story.media.map(m => m.id),
171
+ ...story.cues.map(c => c.id),
172
+ ...(story.overlays ?? []).map(o => o.id),
173
+ ...story.scenes.flatMap(s => s.actions.map(a => a.id)),
174
+ ]);
175
+ const normalizeSpaces = (value) => value.trim().replace(/\s+/g, ' ');
176
+ const wordPattern = /[\p{L}\p{N}]+(?:['’\-/.,][\p{L}\p{N}]+)*/gu;
177
+ const tokenizeWords = (value) => [...value.matchAll(wordPattern)].map(match => ({
178
+ text: match[0],
179
+ start: match.index,
180
+ end: match.index + match[0].length,
181
+ }));
182
+ const canonicalWord = (value) => value.normalize('NFC').replace(/’/g, "'").toLowerCase();
183
+ function findExactMatch(haystack, needle, occurrence, codes, label, context) {
184
+ const matches = [];
185
+ let pos = haystack.indexOf(needle);
186
+ while (pos >= 0) {
187
+ matches.push(pos);
188
+ pos = haystack.indexOf(needle, pos + 1);
189
+ }
190
+ requireCondition(matches.length > 0, codes.missing, `${label}: ${JSON.stringify(needle)} not found`, 2, context);
191
+ requireCondition(occurrence !== undefined || matches.length === 1, codes.ambiguous, `${label}: specify occurrence for repeated ${JSON.stringify(needle)}`, 2, context);
192
+ const start = matches[(occurrence ?? 1) - 1];
193
+ requireCondition(start !== undefined, codes.occurrence, `${label}: occurrence ${occurrence} does not exist`, 2, context);
194
+ return start;
195
+ }
196
+ function buildResolvedAnnotation(annotation, resolvedId, sourceId, target, segmentScene, time, end, cue_span, context) {
197
+ requireCondition(!usedIds.has(resolvedId), 'DUPLICATE_ID', `Duplicate resolved annotation ID ${resolvedId}`, 2, context);
198
+ usedIds.add(resolvedId);
199
+ requireCondition(end > time, 'ANNOTATION_DURATION', `Annotation ${resolvedId}: interval must have positive duration`, 2, context);
123
200
  const range = sceneRanges.get(annotation.scene);
124
- requireCondition(segment.scene === annotation.scene && time >= range.start && end <= range.end, 'ANNOTATION_RANGE', `Annotation ${annotation.id}: interval must fit its narration scene ${annotation.scene}`, 2, context);
125
- const visuals = actions.filter(item => item.action.type === 'slide' || item.action.type === 'reveal');
201
+ requireCondition(segmentScene === annotation.scene && time >= range.start && end <= range.end, 'ANNOTATION_RANGE', `Annotation ${resolvedId}: interval must fit its narration scene ${annotation.scene}`, 2, context);
126
202
  const preceding = visuals.filter(item => item.start_ms <= time);
127
203
  const slide = preceding.findLast(item => item.action.type === 'slide');
128
204
  const state = preceding.at(-1);
129
- requireCondition(time >= state.end_ms && !visuals.some(item => item.start_ms > time && item.start_ms < end), 'ANNOTATION_STATE', `Annotation ${annotation.id}: interval must fit one settled slide visit and reveal state`, 2, context);
205
+ requireCondition(time >= state.end_ms && !visuals.some(item => item.start_ms > time && item.start_ms < end), 'ANNOTATION_STATE', `Annotation ${resolvedId}: interval must fit one settled slide visit and reveal state`, 2, context);
130
206
  const click = state.action.type === 'reveal' ? state.action.click : 0;
131
- requireCondition(slide.action.type === 'slide', 'ANNOTATION_STATE', `Annotation ${annotation.id}: no active slide`, 2, context);
132
- return { ...annotation, start_ms: time, end_ms: end, slide: slide.action.target, visit: slide.id, click, cue_span };
207
+ requireCondition(slide.action.type === 'slide', 'ANNOTATION_STATE', `Annotation ${resolvedId}: no active slide`, 2, context);
208
+ const windowFields = {
209
+ start_ms: time,
210
+ end_ms: end,
211
+ slide: slide.action.target,
212
+ visit: slide.id,
213
+ click,
214
+ ...(cue_span ? { cue_span } : {}),
215
+ ...(sourceId ? { source_id: sourceId } : {}),
216
+ };
217
+ if (annotation.effect === 'laser') {
218
+ const pathTarget = target;
219
+ const totalDwell = pathTarget.points.reduce((sum, pt) => sum + (pt.dwell_ms ?? 0), 0);
220
+ const validDwell = pathTarget.points.length >= 2 ? totalDwell < end - time : totalDwell <= end - time;
221
+ requireCondition(validDwell, 'ANNOTATION_MOTION', `Annotation ${resolvedId}: laser waypoint dwell (${Math.round(totalDwell)} ms) leaves no traversal time within resolved duration (${Math.round(end - time)} ms)`, 2, context);
222
+ if (annotation.motion) {
223
+ const inMs = annotation.motion.in_ms ?? 0;
224
+ const outMs = annotation.motion.out_ms ?? 0;
225
+ requireCondition(inMs + outMs <= end - time, 'ANNOTATION_MOTION', `Annotation ${resolvedId}: fade motion exceeds resolved duration (${Math.round(end - time)} ms)`, 2, context);
226
+ }
227
+ return {
228
+ id: resolvedId,
229
+ scene: annotation.scene,
230
+ effect: 'laser',
231
+ target: pathTarget,
232
+ ...(annotation.appearance ? { appearance: annotation.appearance } : {}),
233
+ ...(annotation.motion ? { motion: annotation.motion } : {}),
234
+ ...windowFields,
235
+ };
236
+ }
237
+ if (annotation.effect === 'stamp') {
238
+ if (annotation.motion) {
239
+ const inMs = annotation.motion.in_ms ?? 0;
240
+ const outMs = annotation.motion.out_ms ?? 0;
241
+ requireCondition(inMs + outMs <= end - time, 'ANNOTATION_MOTION', `Annotation ${resolvedId}: ${annotation.motion.type} motion exceeds resolved duration (${Math.round(end - time)} ms)`, 2, context);
242
+ }
243
+ return {
244
+ id: resolvedId,
245
+ scene: annotation.scene,
246
+ effect: 'stamp',
247
+ target: target,
248
+ appearance: annotation.appearance,
249
+ ...(annotation.motion ? { motion: annotation.motion } : {}),
250
+ ...windowFields,
251
+ };
252
+ }
253
+ const singleTarget = target;
254
+ if (annotation.effect === 'underline') {
255
+ if (annotation.motion) {
256
+ const inMs = annotation.motion.in_ms ?? 0;
257
+ const outMs = annotation.motion.out_ms ?? 0;
258
+ requireCondition(inMs + outMs <= end - time, 'ANNOTATION_MOTION', `Annotation ${resolvedId}: wipe motion exceeds resolved duration (${Math.round(end - time)} ms)`, 2, context);
259
+ }
260
+ return {
261
+ id: resolvedId,
262
+ scene: annotation.scene,
263
+ effect: 'underline',
264
+ target: singleTarget,
265
+ appearance: annotation.appearance,
266
+ ...(annotation.motion ? { motion: annotation.motion } : {}),
267
+ ...windowFields,
268
+ };
269
+ }
270
+ if (annotation.effect === 'spotlight') {
271
+ if (annotation.motion) {
272
+ const inMs = annotation.motion.in_ms ?? 0;
273
+ const outMs = annotation.motion.out_ms ?? 0;
274
+ requireCondition(inMs + outMs <= end - time, 'ANNOTATION_MOTION', `Annotation ${resolvedId}: fade motion exceeds resolved duration (${Math.round(end - time)} ms)`, 2, context);
275
+ }
276
+ return {
277
+ id: resolvedId,
278
+ scene: annotation.scene,
279
+ effect: 'spotlight',
280
+ target: singleTarget,
281
+ appearance: annotation.appearance,
282
+ ...(annotation.motion ? { motion: annotation.motion } : {}),
283
+ ...windowFields,
284
+ };
285
+ }
286
+ if (annotation.effect === 'zoom') {
287
+ if (annotation.motion) {
288
+ const inMs = annotation.motion.in_ms ?? 0;
289
+ const outMs = annotation.motion.out_ms ?? 0;
290
+ requireCondition(inMs + outMs <= end - time, 'ANNOTATION_MOTION', `Annotation ${resolvedId}: ease motion exceeds resolved duration (${Math.round(end - time)} ms)`, 2, context);
291
+ }
292
+ return {
293
+ id: resolvedId,
294
+ scene: annotation.scene,
295
+ effect: 'zoom',
296
+ target: singleTarget,
297
+ ...(annotation.appearance ? { appearance: annotation.appearance } : {}),
298
+ ...(annotation.motion ? { motion: annotation.motion } : {}),
299
+ ...windowFields,
300
+ };
301
+ }
302
+ return {
303
+ id: resolvedId,
304
+ scene: annotation.scene,
305
+ effect: 'highlight',
306
+ target: singleTarget,
307
+ appearance: annotation.appearance,
308
+ ...windowFields,
309
+ };
310
+ }
311
+ const annotations = story.annotations.flatMap((annotation) => {
312
+ const normalizeTarget = (t) => {
313
+ if (t.type === 'path') {
314
+ return {
315
+ ...t,
316
+ points: t.points.map(pt => 'target' in pt && pt.target.type === 'text'
317
+ ? { ...pt, target: { ...pt.target, text: normalizeSpaces(pt.target.text) } }
318
+ : pt),
319
+ };
320
+ }
321
+ return t.type === 'text' ? { ...t, text: normalizeSpaces(t.text) } : t;
322
+ };
323
+ const normalizedTarget = normalizeTarget(annotation.target);
324
+ if ('at' in annotation && annotation.at !== undefined) {
325
+ if (typeof annotation.at === 'number') {
326
+ const range = sceneRanges.get(annotation.scene);
327
+ const time = range.start + annotation.at;
328
+ const context = { annotation: annotation.id, scene: annotation.scene, target: normalizedTarget };
329
+ return [buildResolvedAnnotation(annotation, annotation.id, undefined, normalizedTarget, annotation.scene, time, time + annotation.duration_ms, undefined, context)];
330
+ }
331
+ const { time, segment, context, cue_span } = phrase({ id: annotation.id, at: annotation.at }, normalizedTarget);
332
+ return [buildResolvedAnnotation(annotation, annotation.id, undefined, normalizedTarget, segment.scene, time, time + annotation.duration_ms, cue_span, context)];
333
+ }
334
+ const follow = annotation.follow;
335
+ const segment = segments.get(follow.segment);
336
+ const asset = assets.get(follow.segment);
337
+ const alignment = asset.alignment;
338
+ const context = { annotation: annotation.id, segment: follow.segment, target: normalizedTarget };
339
+ requireCondition(alignment && alignment.units.length > 0, 'CUE_ALIGNMENT_REQUIRED', `Annotation ${annotation.id} requires alignment for ${follow.segment}`, 2, context);
340
+ const offsetMs = follow.offset_ms ?? 0;
341
+ const lingerMs = follow.linger_ms ?? 180;
342
+ const extendWithLinger = (startMs, rawEndMs) => {
343
+ if (lingerMs <= 0)
344
+ return rawEndMs;
345
+ const range = sceneRanges.get(annotation.scene);
346
+ if (!range || rawEndMs > range.end)
347
+ return rawEndMs;
348
+ const nextVisual = visuals.find(item => item.start_ms > startMs);
349
+ if (nextVisual && rawEndMs > nextVisual.start_ms)
350
+ return rawEndMs;
351
+ let ceiling = Math.min(range.end, nextVisual ? nextVisual.start_ms : Infinity);
352
+ if (rawEndMs <= cursor - 70)
353
+ ceiling = Math.min(ceiling, cursor - 70);
354
+ return Math.max(rawEndMs, Math.min(rawEndMs + lingerMs, ceiling));
355
+ };
356
+ const windowStart = follow.phrase !== undefined
357
+ ? findExactMatch(alignment.text, follow.phrase, follow.occurrence, { missing: 'CUE_PHRASE_MISSING', ambiguous: 'CUE_AMBIGUOUS', occurrence: 'CUE_OCCURRENCE' }, `Annotation ${annotation.id}`, context)
358
+ : 0;
359
+ const windowEnd = follow.phrase !== undefined ? windowStart + follow.phrase.length : alignment.text.length;
360
+ requireCondition(windowEnd > windowStart, 'CUE_PHRASE_MISSING', `Annotation ${annotation.id}: empty spoken transcript`, 2, context);
361
+ const spanTiming = (spanStart, spanEnd, label) => {
362
+ const first = alignment.units.find(unit => unit.start === spanStart);
363
+ const last = alignment.units.find(unit => unit.end === spanEnd);
364
+ requireCondition(first && last, 'CUE_BOUNDARY', `Annotation ${annotation.id}: exact aligned boundaries unavailable for ${label}`, 2, context);
365
+ const start_ms = segment.start_ms + first.start_ms + offsetMs;
366
+ const end_ms = segment.start_ms + last.end_ms + offsetMs;
367
+ requireCondition(end_ms > start_ms, 'ANNOTATION_DURATION', `Annotation ${annotation.id}: aligned interval for ${label} has zero or negative duration`, 2, context);
368
+ return { start_ms, end_ms, cue_span: { segment: follow.segment, start: spanStart, end: spanEnd, form: alignment.form } };
369
+ };
370
+ const mode = follow.mode ?? 'words';
371
+ if (mode === 'phrase') {
372
+ const phraseStart = follow.phrase !== undefined ? windowStart : alignment.units[0].start;
373
+ const phraseEnd = follow.phrase !== undefined ? windowEnd : alignment.units.at(-1).end;
374
+ const timing = spanTiming(phraseStart, phraseEnd, follow.phrase ? JSON.stringify(follow.phrase) : follow.segment);
375
+ const endMs = extendWithLinger(timing.start_ms, timing.end_ms);
376
+ return [buildResolvedAnnotation(annotation, annotation.id, annotation.id, normalizedTarget, segment.scene, timing.start_ms, endMs, timing.cue_span, context)];
377
+ }
378
+ requireCondition(normalizedTarget.type === 'text', 'ANNOTATION_FOLLOW', `Annotation ${annotation.id}: word-following mode requires a text target`, 2, context);
379
+ const spokenWindow = alignment.text.slice(windowStart, windowEnd);
380
+ const intervals = [];
381
+ if (follow.tokens) {
382
+ let prevSpokenEnd = -1;
383
+ for (const [idx, token] of follow.tokens.entries()) {
384
+ const dispNeedle = normalizeSpaces(token.text);
385
+ const dispStart = findExactMatch(normalizedTarget.text, dispNeedle, token.occurrence, { missing: 'FOLLOW_TEXT_MISSING', ambiguous: 'FOLLOW_AMBIGUOUS', occurrence: 'FOLLOW_OCCURRENCE' }, `Annotation ${annotation.id} token ${idx + 1} text`, context);
386
+ const relSpoken = findExactMatch(spokenWindow, token.phrase, token.phrase_occurrence, { missing: 'CUE_PHRASE_MISSING', ambiguous: 'CUE_AMBIGUOUS', occurrence: 'CUE_OCCURRENCE' }, `Annotation ${annotation.id} token ${idx + 1} phrase`, context);
387
+ const absStart = windowStart + relSpoken;
388
+ const absEnd = absStart + token.phrase.length;
389
+ requireCondition(absStart >= prevSpokenEnd, 'ANNOTATION_ORDER', `Annotation ${annotation.id}: follow tokens must advance monotonically in speech`, 2, context);
390
+ prevSpokenEnd = absEnd;
391
+ const timing = spanTiming(absStart, absEnd, JSON.stringify(token.phrase));
392
+ intervals.push({ slice: { start: dispStart, end: dispStart + dispNeedle.length }, ...timing });
393
+ }
394
+ }
395
+ else {
396
+ const displayWords = tokenizeWords(normalizedTarget.text);
397
+ const spokenWords = tokenizeWords(spokenWindow);
398
+ requireCondition(displayWords.length > 0 && spokenWords.length > 0, 'ANNOTATION_FOLLOW', `Annotation ${annotation.id}: target text and spoken phrase must contain words`, 2, context);
399
+ requireCondition(displayWords.length === spokenWords.length, 'FOLLOW_TEXT_MISMATCH', `Annotation ${annotation.id}: display text has ${displayWords.length} words but spoken phrase has ${spokenWords.length} words; supply follow.tokens for editorial differences`, 2, context);
400
+ for (let i = 0; i < displayWords.length; i++) {
401
+ requireCondition(canonicalWord(displayWords[i].text) === canonicalWord(spokenWords[i].text), 'FOLLOW_TEXT_MISMATCH', `Annotation ${annotation.id}: word ${i + 1} differs between display (${JSON.stringify(displayWords[i].text)}) and speech (${JSON.stringify(spokenWords[i].text)}); supply follow.tokens for editorial differences`, 2, context);
402
+ const timing = spanTiming(windowStart + spokenWords[i].start, windowStart + spokenWords[i].end, JSON.stringify(spokenWords[i].text));
403
+ intervals.push({ slice: { start: displayWords[i].start, end: displayWords[i].end }, ...timing });
404
+ }
405
+ }
406
+ for (let i = 0; i < intervals.length - 1; i++) {
407
+ const cur = intervals[i];
408
+ const next = intervals[i + 1];
409
+ requireCondition(next.start_ms > cur.start_ms, 'ANNOTATION_ORDER', `Annotation ${annotation.id}: aligned word intervals must strictly advance in start time`, 2, context);
410
+ if (cur.end_ms > next.start_ms) {
411
+ cur.end_ms = next.start_ms;
412
+ requireCondition(cur.end_ms > cur.start_ms, 'ANNOTATION_DURATION', `Annotation ${annotation.id}: overlapping word boundaries collapsed word ${i + 1} to zero duration`, 2, context);
413
+ }
414
+ }
415
+ if (lingerMs > 0) {
416
+ for (let i = 0; i < intervals.length; i++) {
417
+ const cur = intervals[i];
418
+ let targetEnd = extendWithLinger(cur.start_ms, cur.end_ms);
419
+ if (i < intervals.length - 1) {
420
+ const next = intervals[i + 1];
421
+ targetEnd = Math.min(targetEnd, next.start_ms);
422
+ const range = sceneRanges.get(annotation.scene);
423
+ const nextVisual = visuals.find(item => item.start_ms > cur.start_ms);
424
+ const ceiling = Math.min(range?.end ?? Infinity, nextVisual ? nextVisual.start_ms : Infinity);
425
+ if (next.start_ms <= ceiling && next.start_ms > targetEnd && next.start_ms - targetEnd < 75) {
426
+ targetEnd = next.start_ms;
427
+ }
428
+ }
429
+ cur.end_ms = targetEnd;
430
+ }
431
+ }
432
+ return intervals.map((item, idx) => buildResolvedAnnotation(annotation, `${annotation.id}:${idx + 1}`, annotation.id, { ...normalizedTarget, slice: item.slice }, segment.scene, item.start_ms, item.end_ms, item.cue_span, context));
133
433
  });
434
+ const zooms = annotations
435
+ .filter(item => item.effect === 'zoom')
436
+ .sort((a, b) => a.start_ms - b.start_ms || a.end_ms - b.end_ms);
437
+ for (let i = 1; i < zooms.length; i++) {
438
+ const prev = zooms[i - 1];
439
+ const cur = zooms[i];
440
+ requireCondition(cur.start_ms >= prev.end_ms, 'ANNOTATION_ZOOM_OVERLAP', `Zoom annotations ${prev.id} (${Math.round(prev.start_ms)}..${Math.round(prev.end_ms)} ms) and ${cur.id} (${Math.round(cur.start_ms)}..${Math.round(cur.end_ms)} ms) overlap`, 2, { annotations: [prev.id, cur.id] });
441
+ }
134
442
  requireCondition(cursor > 0, 'EMPTY_PRODUCTION', 'Production needs a positive duration');
135
443
  const overlays = (story.overlays ?? []).map(overlay => {
136
444
  const { id, src, box, opacity } = overlay;
@@ -1,23 +1,55 @@
1
- import { renameSync, writeFileSync } from 'node:fs';
1
+ import { mkdirSync, renameSync, writeFileSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
+ import { gt, valid } from 'semver';
3
4
  import { userDataDirectory } from './installation.js';
4
5
  import { updateVersion } from './update-check.js';
5
6
  const channel = process.argv[2];
6
- if (channel === 'latest' || channel === 'alpha') {
7
- const deadline = setTimeout(() => process.exit(0), 5000);
7
+ const rawInstalled = process.argv[3];
8
+ const installed = typeof rawInstalled === 'string' && valid(rawInstalled) ? rawInstalled : '0.0.0';
9
+ const userAgent = `slidevideo-cli/${installed} (${process.platform}; ${process.arch})`;
10
+ async function fetchReleaseVersion(targetChannel) {
11
+ let siteVersion;
8
12
  try {
9
- const response = await fetch(`https://registry.npmjs.org/@slidevideo%2fcli/${channel}`, {
13
+ const url = targetChannel === 'alpha'
14
+ ? 'https://slidevideo.io/release.json?channel=alpha'
15
+ : 'https://slidevideo.io/release.json';
16
+ const response = await fetch(url, {
17
+ headers: { 'user-agent': userAgent, accept: 'application/json' },
10
18
  signal: AbortSignal.timeout(3000),
11
19
  });
12
20
  if (response.ok) {
13
21
  const result = await response.json();
14
- const version = updateVersion(result?.version, channel);
15
- if (version) {
16
- const directory = join(userDataDirectory(), 'updates');
17
- const pending = join(directory, `${channel}.${process.pid}.tmp`);
18
- writeFileSync(pending, JSON.stringify(version), { mode: 0o600 });
19
- renameSync(pending, join(directory, `${channel}.json`));
20
- }
22
+ siteVersion = updateVersion(result?.version, targetChannel);
23
+ if (siteVersion && gt(siteVersion, installed))
24
+ return siteVersion;
25
+ }
26
+ }
27
+ catch { }
28
+ try {
29
+ const fallback = await fetch(`https://registry.npmjs.org/@slidevideo%2fcli/${targetChannel}`, {
30
+ headers: { 'user-agent': userAgent, accept: 'application/json' },
31
+ signal: AbortSignal.timeout(3000),
32
+ });
33
+ if (fallback.ok) {
34
+ const result = await fallback.json();
35
+ const npmVersion = updateVersion(result?.version, targetChannel);
36
+ if (npmVersion)
37
+ return siteVersion && gt(siteVersion, npmVersion) ? siteVersion : npmVersion;
38
+ }
39
+ }
40
+ catch { }
41
+ return siteVersion;
42
+ }
43
+ if (channel === 'latest' || channel === 'alpha') {
44
+ const deadline = setTimeout(() => process.exit(0), 6500);
45
+ try {
46
+ const version = await fetchReleaseVersion(channel);
47
+ if (version) {
48
+ const directory = join(userDataDirectory(), 'updates');
49
+ mkdirSync(directory, { recursive: true });
50
+ const pending = join(directory, `${channel}.${process.pid}.tmp`);
51
+ writeFileSync(pending, JSON.stringify(version), { mode: 0o600 });
52
+ renameSync(pending, join(directory, `${channel}.json`));
21
53
  }
22
54
  }
23
55
  catch { }
@@ -21,11 +21,13 @@ export function updateVersion(value, channel) {
21
21
  return version && updateChannel(version) === channel ? version : undefined;
22
22
  }
23
23
  export function notifyUpdate(json, quiet) {
24
- if (json || quiet || process.env.SLIDEVIDEO_NO_UPDATE_CHECK === '1'
24
+ if (process.env.SLIDEVIDEO_NO_UPDATE_CHECK === '1'
25
+ || process.env.DO_NOT_TRACK === '1'
25
26
  || (process.env.CI && process.env.CI !== 'false')
26
27
  || process.env.GITHUB_ACTIONS || process.env.TF_BUILD || process.env.BUILD_NUMBER
27
- || !process.stdin.isTTY || !process.stdout.isTTY || !process.stderr.isTTY)
28
+ || process.env.NODE_TEST_CONTEXT)
28
29
  return;
30
+ const interactive = !json && !quiet && Boolean(process.stdin.isTTY && process.stdout.isTTY && process.stderr.isTTY);
29
31
  try {
30
32
  const { version: installed } = JSON.parse(readFileSync(packagePath('package.json'), 'utf8'));
31
33
  if (typeof installed !== 'string')
@@ -34,13 +36,15 @@ export function notifyUpdate(json, quiet) {
34
36
  if (!channel)
35
37
  return;
36
38
  const directory = join(userDataDirectory(), 'updates');
37
- let available;
38
- try {
39
- available = updateVersion(JSON.parse(readFileSync(join(directory, `${channel}.json`), 'utf8')), channel);
40
- }
41
- catch { }
42
- if (available && gt(available, installed)) {
43
- process.stderr.write(`[slidevideo] Update available: ${installed} → ${available}\nRun npm install -g @slidevideo/cli@${available}\nFor a custom install prefix, add the original --prefix option to this command.\n`);
39
+ if (interactive) {
40
+ let available;
41
+ try {
42
+ available = updateVersion(JSON.parse(readFileSync(join(directory, `${channel}.json`), 'utf8')), channel);
43
+ }
44
+ catch { }
45
+ if (available && gt(available, installed)) {
46
+ process.stderr.write(`[slidevideo] Update available: ${installed} → ${available}\nRun npm install -g @slidevideo/cli@${available}\nFor a custom install prefix, add the original --prefix option to this command.\n`);
47
+ }
44
48
  }
45
49
  mkdirSync(directory, { recursive: true });
46
50
  const attempt = join(directory, 'attempt.json');
@@ -69,7 +73,7 @@ export function notifyUpdate(json, quiet) {
69
73
  release();
70
74
  }
71
75
  }
72
- const child = spawn(process.execPath, [fileURLToPath(new URL('./update-check-worker.js', import.meta.url)), channel], {
76
+ const child = spawn(process.execPath, [fileURLToPath(new URL('./update-check-worker.js', import.meta.url)), channel, installed], {
73
77
  detached: true, stdio: 'ignore', windowsHide: true,
74
78
  });
75
79
  child.on('error', () => { });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slidevideo/cli",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Turn a slide deck into a narrated video.",
5
5
  "license": "SEE LICENSE IN LICENSE-TERMS.md",
6
6
  "type": "module",
@@ -31,6 +31,13 @@
31
31
  "addons/slidevideo/package.json",
32
32
  "addons/slidevideo/playback-entries.ts",
33
33
  "addons/slidevideo/preview.ts",
34
+ "assets/fonts/OFL-LICENSES.txt",
35
+ "assets/fonts/instrument-serif-latin-2.woff2",
36
+ "assets/fonts/instrument-serif-latin-ext-1.woff2",
37
+ "assets/fonts/jetbrains-mono-latin-4.woff2",
38
+ "assets/fonts/jetbrains-mono-latin-ext-3.woff2",
39
+ "assets/fonts/plus-jakarta-sans-latin-6.woff2",
40
+ "assets/fonts/plus-jakarta-sans-latin-ext-5.woff2",
34
41
  "dist/adapters/browser-runtime.d.ts",
35
42
  "dist/adapters/browser-runtime.js",
36
43
  "dist/adapters/capture-compression.d.ts",
@@ -61,6 +68,8 @@
61
68
  "dist/assembly.js",
62
69
  "dist/calibration.d.ts",
63
70
  "dist/calibration.js",
71
+ "dist/captions.d.ts",
72
+ "dist/captions.js",
64
73
  "dist/cli.d.ts",
65
74
  "dist/cli.js",
66
75
  "dist/compositor.d.ts",
@@ -104,6 +113,8 @@
104
113
  "dist/skill-install.js",
105
114
  "dist/speech.d.ts",
106
115
  "dist/speech.js",
116
+ "dist/stamp-fonts.d.ts",
117
+ "dist/stamp-fonts.js",
107
118
  "dist/storyboard.d.ts",
108
119
  "dist/storyboard.js",
109
120
  "dist/timing.d.ts",
@@ -356,6 +356,117 @@
356
356
  "minItems": 1
357
357
  }
358
358
  }
359
+ },
360
+ {
361
+ "properties": {
362
+ "target": {
363
+ "type": "object",
364
+ "properties": {
365
+ "type": {
366
+ "const": "text"
367
+ },
368
+ "container": {
369
+ "oneOf": [
370
+ {
371
+ "type": "object",
372
+ "additionalProperties": false,
373
+ "properties": {
374
+ "type": {
375
+ "const": "element"
376
+ },
377
+ "selector": {
378
+ "type": "string",
379
+ "minLength": 1
380
+ }
381
+ },
382
+ "required": [
383
+ "type",
384
+ "selector"
385
+ ]
386
+ },
387
+ {
388
+ "type": "object",
389
+ "additionalProperties": false,
390
+ "properties": {
391
+ "type": {
392
+ "const": "shape"
393
+ },
394
+ "id": {
395
+ "type": "integer",
396
+ "minimum": 1
397
+ }
398
+ },
399
+ "required": [
400
+ "type",
401
+ "id"
402
+ ]
403
+ }
404
+ ]
405
+ },
406
+ "text": {
407
+ "type": "string",
408
+ "minLength": 1
409
+ },
410
+ "occurrence": {
411
+ "type": "integer",
412
+ "minimum": 1
413
+ },
414
+ "slice": {
415
+ "type": "object",
416
+ "properties": {
417
+ "start": {
418
+ "type": "integer",
419
+ "minimum": 0
420
+ },
421
+ "end": {
422
+ "type": "integer",
423
+ "minimum": 1
424
+ }
425
+ },
426
+ "required": [
427
+ "start",
428
+ "end"
429
+ ],
430
+ "additionalProperties": false
431
+ }
432
+ },
433
+ "required": [
434
+ "type",
435
+ "text"
436
+ ],
437
+ "additionalProperties": false
438
+ },
439
+ "fragments": {
440
+ "type": "array",
441
+ "items": {
442
+ "type": "object",
443
+ "properties": {
444
+ "x": {
445
+ "type": "number"
446
+ },
447
+ "y": {
448
+ "type": "number"
449
+ },
450
+ "width": {
451
+ "type": "number",
452
+ "exclusiveMinimum": 0
453
+ },
454
+ "height": {
455
+ "type": "number",
456
+ "exclusiveMinimum": 0
457
+ }
458
+ },
459
+ "required": [
460
+ "x",
461
+ "y",
462
+ "width",
463
+ "height"
464
+ ],
465
+ "additionalProperties": false
466
+ },
467
+ "minItems": 1
468
+ }
469
+ }
359
470
  }
360
471
  ]
361
472
  }