@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.
Files changed (47) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +2 -2
  3. package/addons/slidevideo/geometry.ts +63 -30
  4. package/addons/slidevideo/global-top.vue +41 -9
  5. package/addons/slidevideo/playback-entries.ts +16 -5
  6. package/addons/slidevideo/preview.ts +26 -14
  7. package/dist/adapters/powerpoint.d.ts +7 -4
  8. package/dist/adapters/powerpoint.js +116 -26
  9. package/dist/adapters/slidev-inspection.d.ts +5 -2
  10. package/dist/adapters/slidev-inspection.js +3 -2
  11. package/dist/adapters/slidev.d.ts +3 -4
  12. package/dist/adapters/slidev.js +20 -19
  13. package/dist/annotation-paint.d.ts +65 -11
  14. package/dist/annotation-paint.js +290 -10
  15. package/dist/annotations.d.ts +13 -8
  16. package/dist/annotations.js +619 -88
  17. package/dist/assembly.d.ts +4 -2
  18. package/dist/assembly.js +23 -18
  19. package/dist/cli.js +102 -16
  20. package/dist/compositor.d.ts +10 -5
  21. package/dist/compositor.js +215 -128
  22. package/dist/contracts.d.ts +91 -30
  23. package/dist/contracts.js +2 -1
  24. package/dist/media.d.ts +5 -0
  25. package/dist/media.js +30 -0
  26. package/dist/pipeline.d.ts +35 -9
  27. package/dist/pipeline.js +62 -10
  28. package/dist/preview/contracts.d.ts +3 -3
  29. package/dist/preview/player.js +20 -15
  30. package/dist/preview/server.d.ts +2 -1
  31. package/dist/preview/server.js +6 -5
  32. package/dist/setup.d.ts +3 -0
  33. package/dist/setup.js +16 -1
  34. package/dist/skill-install.d.ts +35 -0
  35. package/dist/skill-install.js +132 -0
  36. package/dist/storyboard.js +9 -0
  37. package/package.json +4 -1
  38. package/schemas/annotation-geometry.v1.json +260 -28
  39. package/schemas/run-manifest.v1.json +31 -0
  40. package/schemas/schedule.v1.json +448 -182
  41. package/schemas/storyboard.v1.json +358 -174
  42. package/skills/slidevideo/SKILL.md +11 -9
  43. package/skills/slidevideo/references/decks.md +228 -0
  44. package/skills/slidevideo/references/production.md +14 -10
  45. package/skills/slidevideo/references/storyboard.md +65 -33
  46. package/tools/powerpoint/powerpoint.ps1 +52 -41
  47. package/tools/powerpoint/preview.ps1 +5 -5
@@ -302,43 +302,50 @@ function Apply-Operation($operation) {
302
302
  return $player
303
303
  } else { Fail 'POWERPOINT_PROTOCOL' ('Unknown operation ' + $operation.type) }
304
304
  }
305
+ function Request-Context($request, [bool]$includeClick = $false) {
306
+ $ids = @($request.annotations)
307
+ $prefix = $(if ($ids.Count -eq 1) { 'Annotation ' + $ids[0] } else { 'Annotations ' + ($ids -join ', ') })
308
+ $suffix = $(if ($includeClick) { ', click ' + $request.click } else { '' })
309
+ return ($prefix + ' (' + $request.key + '), slide ' + $request.slide + ', visit ' + $request.visit + $suffix)
310
+ }
305
311
  function Prepare-Annotations($catalog) {
306
- foreach ($annotation in $job.annotations) {
307
- $context = 'Annotation ' + $annotation.id + ', slide ' + $annotation.slide + ', visit ' + $annotation.visit
308
- $visits = @($job.operations | Where-Object { $_.type -eq 'slide' -and $_.id -eq $annotation.visit -and $_.native_id -eq $annotation.native_id -and $_.scene -eq $annotation.scene })
312
+ foreach ($request in $job.geometry_requests) {
313
+ $context = Request-Context $request
314
+ $visits = @($job.operations | Where-Object { $_.type -eq 'slide' -and $_.id -eq $request.visit -and $_.native_id -eq $request.native_id -and $_.scene -eq $request.scene })
309
315
  if ($visits.Count -ne 1) { Fail 'ANNOTATION_STATE' ($context + ': no unique scheduled slide visit.') }
310
- if ($annotation.start_ms -lt $visits[0].at_ms + $visits[0].settle_ms -or $annotation.end_ms -le $annotation.start_ms -or $annotation.end_ms -gt $job.duration_ms) { Fail 'ANNOTATION_INTERVAL' ($context + ': interval is outside settled playback.') }
316
+ if ($request.start_ms -lt $visits[0].at_ms + $visits[0].settle_ms -or $request.end_ms -le $request.start_ms -or $request.end_ms -gt $job.duration_ms) { Fail 'ANNOTATION_INTERVAL' ($context + ': interval is outside settled playback.') }
311
317
  $click = 0
312
318
  foreach ($operation in $job.operations) {
313
319
  if ($operation.type -notin @('slide', 'reveal')) { continue }
314
- if ($operation.at_ms -le $annotation.start_ms) {
320
+ if ($operation.at_ms -le $request.start_ms) {
315
321
  if ($operation.type -eq 'slide') { $visit = [string]$operation.id; $click = 0 }
316
322
  else { $click = [int]$operation.click }
317
- if ($operation.at_ms + $operation.settle_ms -gt $annotation.start_ms) { Fail 'ANNOTATION_INTERVAL' ($context + ': interval starts before a native action settles.') }
318
- } elseif ($operation.at_ms -lt $annotation.end_ms) { Fail 'ANNOTATION_INTERVAL' ($context + ': interval crosses a native slide or reveal action.') }
323
+ if ($operation.at_ms + $operation.settle_ms -gt $request.start_ms) { Fail 'ANNOTATION_INTERVAL' ($context + ': interval starts before a native action settles.') }
324
+ } elseif ($operation.at_ms -lt $request.end_ms) { Fail 'ANNOTATION_INTERVAL' ($context + ': interval crosses a native slide or reveal action.') }
319
325
  }
320
- if ($visit -ne $annotation.visit -or $click -ne $annotation.click) { Fail 'ANNOTATION_STATE' ($context + ': resolved click or visit does not match native operations.') }
321
- if ($annotation.target.type -eq 'element') { Fail 'ANNOTATION_TARGET' ($context + ': use an existing native shape ID or normalized region; selectors are unsupported.') }
322
- if ($annotation.target.type -eq 'shape') {
323
- $slides = @($catalog.slides | Where-Object { $_.native_id -eq $annotation.native_id })
324
- $matches = @($slides[0].shapes | Where-Object { $_.id -eq $annotation.target.id })
325
- if ($matches.Count -ne 1) { Fail 'ANNOTATION_TARGET' ($context + ', shape ' + $annotation.target.id + ': identity is missing or ambiguous.') }
326
- if ($matches[0].unsupported.Count -gt 0 -or $annotation.click -lt $matches[0].visible_from_click) { Fail 'ANNOTATION_TARGET' ($context + ', shape ' + $annotation.target.id + ' (' + $matches[0].name + '): unsupported or hidden target. ' + ($matches[0].unsupported -join '; ')) }
326
+ if ($visit -ne $request.visit -or $click -ne $request.click) { Fail 'ANNOTATION_STATE' ($context + ': resolved click or visit does not match native operations.') }
327
+ if ($request.target.type -eq 'element') { Fail 'ANNOTATION_TARGET' ($context + ': use an existing native shape ID or normalized region; selectors are unsupported.') }
328
+ if ($request.target.type -eq 'shape') {
329
+ $slides = @($catalog.slides | Where-Object { $_.native_id -eq $request.native_id })
330
+ $matches = @($slides[0].shapes | Where-Object { $_.id -eq $request.target.id })
331
+ if ($matches.Count -ne 1) { Fail 'ANNOTATION_TARGET' ($context + ', shape ' + $request.target.id + ': identity is missing or ambiguous.') }
332
+ if ($matches[0].unsupported.Count -gt 0 -or $request.click -lt $matches[0].visible_from_click) { Fail 'ANNOTATION_TARGET' ($context + ', shape ' + $request.target.id + ' (' + $matches[0].name + '): unsupported or hidden target. ' + ($matches[0].unsupported -join '; ')) }
327
333
  }
328
- $annotationMonitors.Add(@{ annotation = $annotation; geometry = $null; next_sample_ms = [double]$annotation.start_ms; complete = $false })
334
+ $annotationMonitors.Add(@{ request = $request; geometry = $null; next_sample_ms = [double]$request.start_ms; complete = $false })
329
335
  }
330
336
  }
331
- function Measure-Annotation($annotation, [bool]$allowPaused = $false) {
332
- $context = 'Annotation ' + $annotation.id + ', slide ' + $annotation.slide + ', visit ' + $annotation.visit + ', click ' + $annotation.click
337
+ function Measure-Annotation($request, [bool]$allowPaused = $false) {
338
+ $context = Request-Context $request $true
333
339
  [SlideVideo.Native]::EnsureGeometry($window, $geometry)
334
- if ($activeVisit -ne $annotation.visit -or $activeScene -ne $annotation.scene -or [int]$show.View.Slide.SlideID -ne $annotation.native_id -or [int]$show.View.GetClickIndex() -ne $annotation.click -or ([int]$show.View.State -ne 1 -and !($allowPaused -and [int]$show.View.State -eq 2))) { Fail 'ANNOTATION_STATE' ($context + ': actual slideshow state changed.') }
335
- if ($annotation.target.type -eq 'region') {
336
- $bounds = @{ x = [double]$annotation.target.x; y = [double]$annotation.target.y; width = [double]$annotation.target.width; height = [double]$annotation.target.height }
340
+ if ($activeVisit -ne $request.visit -or $activeScene -ne $request.scene -or [int]$show.View.Slide.SlideID -ne $request.native_id -or [int]$show.View.GetClickIndex() -ne $request.click -or ([int]$show.View.State -ne 1 -and !($allowPaused -and [int]$show.View.State -eq 2))) { Fail 'ANNOTATION_STATE' ($context + ': actual slideshow state changed.') }
341
+ if ($request.target.type -eq 'slide') { return }
342
+ if ($request.target.type -eq 'region') {
343
+ $bounds = @{ x = [double]$request.target.x; y = [double]$request.target.y; width = [double]$request.target.width; height = [double]$request.target.height }
337
344
  } else {
338
- $matches = @($show.View.Slide.Shapes | Where-Object { $_.Id -eq $annotation.target.id })
339
- if ($matches.Count -ne 1) { Fail 'ANNOTATION_TARGET' ($context + ', shape ' + $annotation.target.id + ': actual shape is missing or ambiguous.') }
345
+ $matches = @($show.View.Slide.Shapes | Where-Object { $_.Id -eq $request.target.id })
346
+ if ($matches.Count -ne 1) { Fail 'ANNOTATION_TARGET' ($context + ', shape ' + $request.target.id + ': actual shape is missing or ambiguous.') }
340
347
  $shape = $matches[0]
341
- if ([int]$shape.Visible -ne -1 -or [int]$shape.Type -eq 6 -or [Math]::Abs([double]$shape.Rotation % 360) -gt 0.001 -or [int]$shape.ThreeD.Visible -ne 0 -or [int]$shape.HorizontalFlip -ne 0 -or [int]$shape.VerticalFlip -ne 0) { Fail 'ANNOTATION_TARGET' ($context + ', shape ' + $annotation.target.id + ': actual target is hidden, grouped or transformed.') }
348
+ if ([int]$shape.Visible -ne -1 -or [int]$shape.Type -eq 6 -or [Math]::Abs([double]$shape.Rotation % 360) -gt 0.001 -or [int]$shape.ThreeD.Visible -ne 0 -or [int]$shape.HorizontalFlip -ne 0 -or [int]$shape.VerticalFlip -ne 0) { Fail 'ANNOTATION_TARGET' ($context + ', shape ' + $request.target.id + ': actual target is hidden, grouped or transformed.') }
342
349
  $bounds = @{ x = [double]$shape.Left / $presentation.PageSetup.SlideWidth; y = [double]$shape.Top / $presentation.PageSetup.SlideHeight; width = [double]$shape.Width / $presentation.PageSetup.SlideWidth; height = [double]$shape.Height / $presentation.PageSetup.SlideHeight }
343
350
  }
344
351
  foreach ($value in $bounds.Values) { if ([double]::IsNaN($value) -or [double]::IsInfinity($value)) { Fail 'ANNOTATION_GEOMETRY' ($context + ': nonfinite bounds.') } }
@@ -348,29 +355,33 @@ function Measure-Annotation($annotation, [bool]$allowPaused = $false) {
348
355
  function Check-Annotations {
349
356
  foreach ($monitor in $annotationMonitors) {
350
357
  if ($monitor.complete) { continue }
351
- $annotation = $monitor.annotation
352
- if ($null -eq $monitor.geometry -and $annotation.start_ms -ge $annotationStartBeforeMs) { continue }
358
+ $request = $monitor.request
359
+ $context = Request-Context $request $true
360
+ if ($null -eq $monitor.geometry -and $request.start_ms -ge $annotationStartBeforeMs) { continue }
353
361
  $now = $clock.Elapsed.TotalMilliseconds - $origin
354
- if ($now -lt $monitor.next_sample_ms -and $now -lt $annotation.end_ms) { continue }
355
- if ($null -eq $monitor.geometry -and $now -ge $annotation.end_ms) { Fail 'ANNOTATION_INTERVAL' ('Annotation ' + $annotation.id + ': native playback missed the entire interval.') }
356
- $bounds = Measure-Annotation $annotation
362
+ if ($now -lt $monitor.next_sample_ms -and $now -lt $request.end_ms) { continue }
363
+ if ($null -eq $monitor.geometry -and $now -ge $request.end_ms) { Fail 'ANNOTATION_INTERVAL' ($context + ': native playback missed the entire interval.') }
364
+ $fragments = @(Measure-Annotation $request)
357
365
  $observed = $clock.Elapsed.TotalMilliseconds - $origin
358
366
  if ($null -eq $monitor.geometry) {
359
- if ($observed -ge $annotation.end_ms) { Fail 'ANNOTATION_INTERVAL' ('Annotation ' + $annotation.id + ': initial measurement completed after the interval.') }
360
- if ($observed - $annotation.start_ms -gt 100) { Fail 'ANNOTATION_INTERVAL' ('Annotation ' + $annotation.id + ': initial native measurement exceeded the interval boundary by 100 ms.') }
361
- $monitor.geometry = @{ id = $annotation.id; scene = $annotation.scene; slide = $annotation.slide; visit = $annotation.visit; click = $annotation.click; start_ms = $annotation.start_ms; end_ms = $annotation.end_ms; observed_start_ms = $observed; observed_end_ms = $observed; viewport = @{ width = [int]$job.output.width; height = [int]$job.output.height }; content = @{ x = $outputContent.x; y = $outputContent.y; width = $outputContent.width; height = $outputContent.height }; bounds = $bounds; samples = 1 }
367
+ if ($observed -ge $request.end_ms) { Fail 'ANNOTATION_INTERVAL' ($context + ': initial measurement completed after the interval.') }
368
+ if ($observed - $request.start_ms -gt 100) { Fail 'ANNOTATION_INTERVAL' ($context + ': initial native measurement exceeded the interval boundary by 100 ms.') }
369
+ $monitor.geometry = @{ key = [string]$request.key; target = $request.target; scene = [string]$request.scene; slide = [string]$request.slide; visit = [string]$request.visit; click = [int]$request.click; start_ms = $request.start_ms; end_ms = $request.end_ms; observed_start_ms = $observed; observed_end_ms = $observed; viewport = @{ width = [int]$job.output.width; height = [int]$job.output.height }; content = @{ x = $outputContent.x; y = $outputContent.y; width = $outputContent.width; height = $outputContent.height }; fragments = @($fragments); samples = 1 }
362
370
  $annotationGeometry.Add($monitor.geometry)
363
371
  } else {
364
- foreach ($key in @('x', 'y', 'width', 'height')) {
365
- $pixels = $(if ($key -in @('x', 'width')) { $outputContent.width } else { $outputContent.height })
366
- if ([Math]::Abs($bounds[$key] - $monitor.geometry.bounds[$key]) * $pixels -gt 0.5) { Fail 'ANNOTATION_MOVING_TARGET' ('Annotation ' + $annotation.id + ': target moved during its native interval.') }
372
+ if ($fragments.Count -ne $monitor.geometry.fragments.Count) { Fail 'ANNOTATION_MOVING_TARGET' ($context + ': fragment count changed during its native interval.') }
373
+ for ($fragmentIndex = 0; $fragmentIndex -lt $fragments.Count; $fragmentIndex++) {
374
+ foreach ($coord in @('x', 'y', 'width', 'height')) {
375
+ $pixels = $(if ($coord -in @('x', 'width')) { $outputContent.width } else { $outputContent.height })
376
+ if ([Math]::Abs($fragments[$fragmentIndex][$coord] - $monitor.geometry.fragments[$fragmentIndex][$coord]) * $pixels -gt 0.5) { Fail 'ANNOTATION_MOVING_TARGET' ($context + ': target moved during its native interval.') }
377
+ }
367
378
  }
368
379
  $monitor.geometry.samples++
369
380
  $monitor.geometry.observed_end_ms = $observed
370
381
  }
371
- $monitor.next_sample_ms = [Math]::Min($observed + 50, [double]$annotation.end_ms)
372
- if ($now -ge $annotation.end_ms) {
373
- if ($observed - $annotation.end_ms -gt 100) { Fail 'ANNOTATION_INTERVAL' ('Annotation ' + $annotation.id + ': final native measurement exceeded the interval boundary by 100 ms.') }
382
+ $monitor.next_sample_ms = [Math]::Min($observed + 50, [double]$request.end_ms)
383
+ if ($now -ge $request.end_ms) {
384
+ if ($observed - $request.end_ms -gt 100) { Fail 'ANNOTATION_INTERVAL' ($context + ': final native measurement exceeded the interval boundary by 100 ms.') }
374
385
  $monitor.complete = $true
375
386
  }
376
387
  }
@@ -521,7 +532,7 @@ try {
521
532
  if ((File-Hash $job.deck) -ne $job.deck_sha256) { Fail 'POWERPOINT_SOURCE_CHANGED' 'The source presentation changed while PowerPoint opened its private copy.' }
522
533
  if ($job.mode -eq 'inspect') { $result = Inspect-Native $package }
523
534
  else {
524
- if ($job.annotations.Count -gt 0) { Prepare-Annotations (Inspect-Native $package) }
535
+ if ($job.geometry_requests.Count -gt 0) { Prepare-Annotations (Inspect-Native $package) }
525
536
  foreach ($media in $job.media) {
526
537
  $matches = @($package.media | Where-Object { $_.native_id -eq $media.native_id -and $_.shape -eq $media.shape -and $_.id -eq $media.id -and $_.sha256 -eq $media.sha256 })
527
538
  if ($matches.Count -ne 1 -or (File-Hash $media.src) -ne $media.sha256) { Fail 'MEDIA_SOURCE_MISMATCH' ('Native video bytes no longer match ' + $media.id) }
@@ -574,7 +585,7 @@ try {
574
585
  } while ($null -eq $geometry)
575
586
  $scaleFilter = ('scale=' + $job.output.width + ':' + $job.output.height + ':force_original_aspect_ratio=decrease:flags=bicubic,pad=' + $job.output.width + ':' + $job.output.height + ':(ow-iw)/2:(oh-ih)/2,setsar=1')
576
587
  $outputContent = [SlideVideo.Native]::OutputContent($geometry, [int]$job.output.width, [int]$job.output.height)
577
- if ($job.annotations.Count -gt 0) { $scaleFilter = ('scale=' + $outputContent.width + ':' + $outputContent.height + ':flags=bicubic,format=rgb24,pad=' + $job.output.width + ':' + $job.output.height + ':' + $outputContent.x + ':' + $outputContent.y + ',setsar=1') }
588
+ if ($job.geometry_requests.Count -gt 0) { $scaleFilter = ('scale=' + $outputContent.width + ':' + $outputContent.height + ':flags=bicubic,format=rgb24,pad=' + $job.output.width + ':' + $job.output.height + ':' + $outputContent.x + ':' + $outputContent.y + ',setsar=1') }
578
589
  $captureFilter = ('crop=' + $geometry.width + ':' + $geometry.height + ':' + $geometry.left + ':' + $geometry.top + ':exact=1,' + $scaleFilter)
579
590
  Write-Json 'geometry.json' @{ version = 1; hwnd = $window.ToString(); rectangle = $geometry; deck_aspect = $deckAspect; requested = $job.output; filter = $captureFilter }
580
591
  if ($job.verify_timing) { Rehearse }
@@ -645,7 +656,7 @@ try {
645
656
  foreach ($marker in $markers) { $marker.observed_ms -= $origin; $marker.rendered_by_ms -= $origin }
646
657
  $script:activeVisit = [string]$firstOperation.id
647
658
  $script:activeScene = [string]$firstOperation.scene
648
- $script:collectAnnotations = $job.annotations.Count -gt 0
659
+ $script:collectAnnotations = $job.geometry_requests.Count -gt 0
649
660
  $initial = $true
650
661
  for ($operationIndex = 0; $operationIndex -lt $job.operations.Count; $operationIndex++) {
651
662
  $operation = $job.operations[$operationIndex]
@@ -704,7 +715,7 @@ try {
704
715
  try { [void][Runtime.InteropServices.Marshal]::FinalReleaseComObject($app) } catch { $cleanup.Add('The COM application reference did not release.') }
705
716
  }
706
717
  try { Write-Json 'events.json' @{ version = 1; events = @($events.ToArray()); markers = @($markers.ToArray()); failure = $failure } } catch {}
707
- try { Write-Json 'annotation-geometry.json' @{ version = 1; geometry = @($annotationGeometry.ToArray()); intervals = @($annotationMonitors | ForEach-Object { @{ id = $_.annotation.id; complete = $_.complete } }); failure = $failure } } catch {}
718
+ try { Write-Json 'annotation-geometry.json' @{ version = 1; geometry = @($annotationGeometry.ToArray()); intervals = @($annotationMonitors | ForEach-Object { @{ key = $_.request.key; annotations = @($_.request.annotations); start_ms = $_.request.start_ms; end_ms = $_.request.end_ms; complete = $_.complete } }); failure = $failure } } catch {}
708
719
  try { Write-Json 'cleanup.json' @{ version = 1; gaps = @($cleanup.ToArray()); application_created = $createdApplication } } catch {}
709
720
  if ($locked) { $mutex.ReleaseMutex() }
710
721
  if ($null -ne $mutex) { $mutex.Dispose() }
@@ -85,14 +85,14 @@ function Run-Preview {
85
85
  $status = 'ended'
86
86
  }
87
87
  if ($null -eq $line) { Start-Sleep -Milliseconds 10; continue }
88
- $annotations = @(
89
- foreach ($annotation in $job.annotations) {
90
- if ($position -ge $annotation.start_ms -and $position -lt $annotation.end_ms) {
91
- @{ id = $annotation.id; bounds = (Measure-Annotation $annotation $true) }
88
+ $targets = @(
89
+ foreach ($request in $job.geometry_requests) {
90
+ if ($position -ge $request.start_ms -and $position -lt $request.end_ms) {
91
+ @{ key = [string]$request.key; fragments = @(Measure-Annotation $request $true) }
92
92
  }
93
93
  }
94
94
  )
95
- $state = @{ position_ms = $position; status = $status; duration_ms = $job.duration_ms; annotations = $annotations; viewport = @{ width = $previewWidth; height = $previewHeight }; content = @{ x = 0; y = 0; width = $previewWidth; height = $previewHeight } }
95
+ $state = @{ position_ms = $position; status = $status; duration_ms = $job.duration_ms; targets = @($targets); viewport = @{ width = $previewWidth; height = $previewHeight }; content = @{ x = 0; y = 0; width = $previewWidth; height = $previewHeight } }
96
96
  if ($action -eq 'frame') { $state.image = [SlideVideo.Native]::PreviewJpeg($window, $geometry, $previewWidth, $previewHeight) }
97
97
  [Console]::WriteLine('SLIDEVIDEO_PREVIEW ' + (ConvertTo-Json -InputObject @{ id = $command.id; state = $state } -Depth 30 -Compress))
98
98
  [Console]::Out.Flush()