@slidevideo/cli 0.3.2 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.10.0
6
+
7
+ - Extract per-slide speaker notes in `slidevideo inspect` for both Slidev and PowerPoint decks.
8
+ - Add `slidevideo init --deck <file>` to scaffold a runnable `slidevideo.yaml` directly from a Slidev or PowerPoint deck's slides, speaker notes, and reveal clicks without writing YAML by hand.
9
+
10
+ ## 0.9.0
11
+
12
+ - Add storyboard-controlled straight `arrow` annotations with normalized or explicitly anchored target endpoints, endpoint padding, solid or dashed strokes, filled or open arrowheads, and optional `fade` or `draw` motion for Slidev and PowerPoint.
13
+ - Lower the free-tier `slidevideo.io` export watermark alpha from `0.38` to `0.28` for a subtler, more transparent corner mark.
14
+
5
15
  ## 0.3.2
6
16
 
7
17
  - Render the free-tier `slidevideo.io` export watermark in bundled Plus Jakarta Sans with adaptive dark-or-light ink based on corner brightness so it stays crisp and transparent on bright and dark slides alike.
package/README.md CHANGED
@@ -18,7 +18,7 @@ slidevideo build --storyboard slidevideo.yaml
18
18
 
19
19
  A completed build writes `final.mp4` (plus `final.vtt` and `final.srt` captions for narrated decks) inside a fresh `runs/<timestamp>` directory (or the path passed to `--run`) at `1920x1080` and `30 fps` by default, and caches generated speech in `.slidevideo/speech` beside the storyboard for reuse across runs (override with `--cache-dir` or disable with `--no-cache`). Pass `--width` and `--height` together and optional `--fps` to select another resolution or frame rate, and `--captions <vtt|srt|both|none>` to control subtitle export. Use `slidevideo setup --license` to activate a key. The installed version checks its bundled revocation list offline. New exports using a revoked key include the watermark.
20
20
 
21
- To draft or edit a storyboard with a coding agent, run `slidevideo skill --install` to link the bundled skill into `~/.agents/skills/slidevideo` and `~/.claude/skills/slidevideo` when Claude Code is detected, or ask the agent to run `slidevideo skill`. For non-interactive setup, run `slidevideo setup --install --json` and see `slidevideo setup --help` and `slidevideo skill --help` for provider and project flags. Use `slidevideo inspect --deck <file> --json` to list slide names, click counts, media IDs, and highlight targets before creating `slidevideo.yaml`. The CLI includes the skill and its storyboard, deck-compatibility, and recording references.
21
+ To draft or edit a storyboard with a coding agent, run `slidevideo skill --install` to link the bundled skill into `~/.agents/skills/slidevideo` and `~/.claude/skills/slidevideo` when Claude Code is detected, or ask the agent to run `slidevideo skill`. To create a starter `slidevideo.yaml` directly from an existing `.md` or `.pptx` deck without a coding agent, run `slidevideo init --deck <file>`. For non-interactive setup, run `slidevideo setup --install --json` and see `slidevideo setup --help`, `slidevideo init --help`, and `slidevideo skill --help` for provider and project flags. Use `slidevideo inspect --deck <file> --json` to list slide names, click counts, speaker notes, media IDs, and highlight targets before creating `slidevideo.yaml`. The CLI includes the skill and its storyboard, deck-compatibility, and recording references.
22
22
 
23
23
  CLI commands check `https://slidevideo.io/release.json` (falling back to npm) in the background at most once every 24 hours and show cached update notices on later interactive calls. Stable installations use `latest`; existing alpha installations use `alpha`. Notices include an exact-version upgrade command. If you installed with `--prefix`, add the same `--prefix` option to that command so npm updates the copy on your `PATH`. Set `SLIDEVIDEO_NO_UPDATE_CHECK=1` or `DO_NOT_TRACK=1` to disable checks and notices. CI, `--version`, `--help`, `setup --manual`, read-only `skill` views, `license`, and `impressum` skip both, and `--json` and `--quiet` suppress notices.
24
24
 
@@ -2,7 +2,7 @@
2
2
  import { ref, nextTick, onMounted, onUnmounted } from 'vue'
3
3
  import { useNav } from '@slidev/client'
4
4
  import type { Schedule, ObservedEvent, ScheduledAction, AnnotationGeometry, PresentationInspection } from '../../dist/contracts.js'
5
- import { activeViewTransform, geometryRequests, groupEffectsByBlend, hasActiveLaser, hasActiveSpotlight, hasActiveStamp, paintLasers, paintPrimitives, paintSpotlightMask, paintStamps, type PaintableEffect } from '../../dist/annotation-paint.js'
5
+ import { activeViewTransform, geometryRequests, groupEffectsByBlend, hasActiveArrow, hasActiveLaser, hasActiveSpotlight, hasActiveStamp, paintArrows, paintLasers, paintPrimitives, paintSpotlightMask, paintStamps, type PaintableEffect } from '../../dist/annotation-paint.js'
6
6
  import { geometryCollector, inspectAudienceTargets } from './geometry'
7
7
  import type { createPreview } from './preview'
8
8
  import { playbackEntries } from './playback-entries'
@@ -24,10 +24,11 @@ function postPreviewView(view: ReturnType<typeof activeViewTransform>) {
24
24
  function renderPreview(effects: PaintableEffect[], timeMs: number) {
25
25
  postPreviewView(activeViewTransform(effects, timeMs))
26
26
  const spotlightActive = hasActiveSpotlight(effects, timeMs)
27
+ const arrowActive = hasActiveArrow(effects, timeMs)
27
28
  const stampActive = hasActiveStamp(effects, timeMs)
28
29
  const laserActive = hasActiveLaser(effects, timeMs)
29
30
  const groups = groupEffectsByBlend(effects, timeMs)
30
- const planeCount = (spotlightActive ? 1 : 0) + groups.length + (stampActive ? 1 : 0) + (laserActive ? 1 : 0)
31
+ const planeCount = (spotlightActive ? 1 : 0) + groups.length + (arrowActive ? 1 : 0) + (stampActive ? 1 : 0) + (laserActive ? 1 : 0)
31
32
  while (previewCanvases.length > planeCount) previewCanvases.pop()!.remove()
32
33
  const width = innerWidth
33
34
  const height = innerHeight
@@ -59,6 +60,11 @@ function renderPreview(effects: PaintableEffect[], timeMs: number) {
59
60
  paintPrimitives(context, group.primitives, { backdrop: false })
60
61
  }
61
62
  let topOffset = offset + groups.length
63
+ if (arrowActive) {
64
+ const context = ensurePlane(topOffset, 'normal')
65
+ paintArrows(context, effects, timeMs)
66
+ topOffset += 1
67
+ }
62
68
  if (stampActive) {
63
69
  const context = ensurePlane(topOffset, 'normal')
64
70
  paintStamps(context, effects, timeMs)
@@ -1,5 +1,5 @@
1
1
  import type { AnnotationGeometry, ResolvedAnnotation, Schedule, ScheduledAction } from '../../dist/contracts.js'
2
- import { annotationPaint, findTargetGeometry, geometryRequests, laserPaint, laserVisible, spotlightAperturesVisible, stampPaint, stampVisible, underlineFragmentsVisible, zoomTransformVisible, type PaintableEffect } from '../../dist/annotation-paint.js'
2
+ import { annotationPaint, arrowPaint, arrowVisible, findTargetGeometry, geometryRequests, laserPaint, laserVisible, spotlightAperturesVisible, stampPaint, stampVisible, underlineFragmentsVisible, zoomTransformVisible, type PaintableEffect } from '../../dist/annotation-paint.js'
3
3
  import { playbackEntries } from './playback-entries'
4
4
  import { geometryCollector } from './geometry'
5
5
 
@@ -127,6 +127,16 @@ export function createPreview(
127
127
  output.push(painted)
128
128
  break
129
129
  }
130
+ case 'arrow': {
131
+ const slideRecord = findTargetGeometry(geometry, annotation, { type: 'slide' })
132
+ if (!slideRecord) throw new Error(`Annotation ${annotation.id}: preview slide geometry is unavailable`)
133
+ const painted = arrowPaint(annotation, slideRecord, target => findTargetGeometry(geometry, annotation, target)?.fragments)
134
+ if (!arrowVisible(painted)) {
135
+ throw new Error(`Annotation ${annotation.id}: ${painted.degenerate_reason ?? 'arrow is clipped outside the slide-content rectangle'}`)
136
+ }
137
+ output.push(painted)
138
+ break
139
+ }
130
140
  }
131
141
  }
132
142
  render(output, elapsed())
@@ -4,7 +4,7 @@ import { tmpdir } from 'node:os';
4
4
  import { extname, join, resolve } from 'node:path';
5
5
  import { fileURLToPath } from 'node:url';
6
6
  import { nativePreview } from './powerpoint-preview.js';
7
- import { defaultVideoOutput, defaultViewport } from '../contracts.js';
7
+ import { defaultVideoOutput, defaultViewport, normalizeSpeakerNotes } from '../contracts.js';
8
8
  import { geometryRequests } from '../annotation-paint.js';
9
9
  import { planStaticSkips, remapCaptureTimestamps } from './capture-compression.js';
10
10
  import { calibrate, estimateOrigin } from '../calibration.js';
@@ -46,7 +46,7 @@ function slideEntrySettleMs(slide) {
46
46
  function parseDeck(value) {
47
47
  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);
48
48
  for (const slide of value.slides) {
49
- requireCondition(object(slide) && typeof slide.id === 'string' && ['native_id', 'index', 'transition', 'transition_duration_ms', 'auto_advance', 'hidden', 'interactive'].every(key => finite(slide[key])) && Array.isArray(slide.effects) && Array.isArray(slide.shapes), 'POWERPOINT_PROTOCOL', 'Native inspection returned an invalid slide', 5);
49
+ requireCondition(object(slide) && typeof slide.id === 'string' && (slide.notes === undefined || typeof slide.notes === 'string') && ['native_id', 'index', 'transition', 'transition_duration_ms', 'auto_advance', 'hidden', 'interactive'].every(key => finite(slide[key])) && Array.isArray(slide.effects) && Array.isArray(slide.shapes), 'POWERPOINT_PROTOCOL', 'Native inspection returned an invalid slide', 5);
50
50
  for (const shape of slide.shapes) {
51
51
  requireCondition(object(shape), 'POWERPOINT_PROTOCOL', 'Native inspection returned an invalid shape identity', 5);
52
52
  const bounds = shape.bounds;
@@ -354,16 +354,20 @@ export class PowerPointAdapter {
354
354
  const unsupported = deckCapabilityIssues(this.deck);
355
355
  return {
356
356
  dimensions: { width: this.deck.width, height: this.deck.height },
357
- slides: this.deck.slides.map(slide => ({
358
- id: slide.id || `slide-${slide.native_id}`,
359
- ...(slide.id ? { alias: `slide-${slide.native_id}` } : {}),
360
- index: slide.index,
361
- clicks: slide.clicks.length,
362
- clicks_known: true,
363
- ...(slide.transition_duration_ms > 0 ? { transition_duration_ms: slide.transition_duration_ms } : {}),
364
- ...(slide.entry_duration_ms > 0 ? { entry_duration_ms: slide.entry_duration_ms } : {}),
365
- ...(slide.clicks.length ? { click_durations_ms: [...slide.clicks] } : {}),
366
- })),
357
+ slides: this.deck.slides.map(slide => {
358
+ const notes = normalizeSpeakerNotes(slide.notes);
359
+ return {
360
+ id: slide.id || `slide-${slide.native_id}`,
361
+ ...(slide.id ? { alias: `slide-${slide.native_id}` } : {}),
362
+ index: slide.index,
363
+ clicks: slide.clicks.length,
364
+ clicks_known: true,
365
+ ...(slide.transition_duration_ms > 0 ? { transition_duration_ms: slide.transition_duration_ms } : {}),
366
+ ...(slide.entry_duration_ms > 0 ? { entry_duration_ms: slide.entry_duration_ms } : {}),
367
+ ...(slide.clicks.length ? { click_durations_ms: [...slide.clicks] } : {}),
368
+ ...(notes ? { notes } : {}),
369
+ };
370
+ }),
367
371
  media_ids: [...new Set(this.deck.media.map(media => media.id))],
368
372
  ...(this.deck.media.length ? {
369
373
  media: this.deck.media.map(media => {
@@ -377,7 +381,7 @@ export class PowerPointAdapter {
377
381
  }),
378
382
  } : {}),
379
383
  files: [resolve(file), helper, packagePath('tools', 'powerpoint', 'Native.cs'), fileURLToPath(import.meta.url)],
380
- capabilities: ['slide', 'reveal', 'play', 'highlight:region', 'highlight:shape', 'highlight:text', 'underline:region', 'underline:shape', 'underline:text', 'spotlight:region', 'spotlight:shape', 'spotlight:text', 'zoom:region', 'zoom:shape', 'zoom:text', 'laser:path', 'laser:region', 'laser:shape', 'laser:text', 'stamp:point', 'stamp:region', 'stamp:shape', 'stamp:text'],
384
+ capabilities: ['slide', 'reveal', 'play', 'highlight:region', 'highlight:shape', 'highlight:text', 'underline:region', 'underline:shape', 'underline:text', 'spotlight:region', 'spotlight:shape', 'spotlight:text', 'zoom:region', 'zoom:shape', 'zoom:text', 'laser:path', 'laser:region', 'laser:shape', 'laser:text', 'stamp:point', 'stamp:region', 'stamp:shape', 'stamp:text', 'arrow:connector', 'arrow:region', 'arrow:shape', 'arrow:text'],
381
385
  ...(unsupported.length ? { unsupported } : {}),
382
386
  annotation_targets: this.targets(),
383
387
  };
@@ -451,7 +455,9 @@ export class PowerPointAdapter {
451
455
  for (const annotation of story.annotations) {
452
456
  const targets = annotation.target.type === 'path'
453
457
  ? annotation.target.points.flatMap(point => 'target' in point ? [point.target] : [])
454
- : [annotation.target];
458
+ : annotation.target.type === 'connector'
459
+ ? [annotation.target.from, annotation.target.to].flatMap(ep => 'target' in ep ? [ep.target] : [])
460
+ : [annotation.target];
455
461
  for (const target of targets) {
456
462
  requireCondition(target.type !== 'element' && !(target.type === 'text' && target.container?.type === 'element'), 'ANNOTATION_TARGET', `Annotation ${annotation.id} uses a Slidev selector. PowerPoint requires an existing shape ID, text target, or normalized region.`, 3);
457
463
  }
@@ -462,7 +468,9 @@ export class PowerPointAdapter {
462
468
  const slide = this.slide(annotation.slide);
463
469
  const targets = annotation.target.type === 'path'
464
470
  ? annotation.target.points.flatMap(point => 'target' in point ? [point.target] : [])
465
- : [annotation.target];
471
+ : annotation.target.type === 'connector'
472
+ ? [annotation.target.from, annotation.target.to].flatMap(ep => 'target' in ep ? [ep.target] : [])
473
+ : [annotation.target];
466
474
  for (const target of targets) {
467
475
  if (target.type === 'shape') {
468
476
  const candidates = slide.shapes.filter(shape => shape.id === target.id);
@@ -1,4 +1,4 @@
1
- import type { PresentationInspection, Storyboard, Schedule, Viewport } from '../contracts.js';
1
+ import { type PresentationInspection, type Storyboard, type Schedule, type Viewport } from '../contracts.js';
2
2
  export declare function inspectSlidev(deck: string): Promise<PresentationInspection>;
3
3
  export declare function validateSlidev(story: Storyboard, inspection: PresentationInspection, options?: {
4
4
  viewport?: Viewport;
@@ -2,6 +2,7 @@ import { access } from 'node:fs/promises';
2
2
  import { fork } from 'node:child_process';
3
3
  import { fileURLToPath } from 'node:url';
4
4
  import { dirname } from 'node:path';
5
+ import { normalizeSpeakerNotes } from '../contracts.js';
5
6
  import { slidevInputs } from './slidev-inputs.js';
6
7
  import { requireCondition, ProductionError } from '../errors.js';
7
8
  async function loadDeck(deck) {
@@ -36,13 +37,17 @@ export async function inspectSlidev(deck) {
36
37
  }
37
38
  const parsed = await loadDeck(deck);
38
39
  requireCondition(parsed.errors.length === 0, 'DECK_SYNTAX', parsed.errors.join('\n'));
39
- const slides = parsed.slides.map((slide, index) => ({
40
- id: String(slide.frontmatter.name ?? `slide-${index + 1}`), index: index + 1,
41
- clicks: Number(slide.frontmatter.clicks ?? 0), clicks_known: slide.frontmatter.clicks != null,
42
- }));
40
+ const slides = parsed.slides.map((slide, index) => {
41
+ const notes = normalizeSpeakerNotes(slide.note);
42
+ return {
43
+ id: String(slide.frontmatter.name ?? `slide-${index + 1}`), index: index + 1,
44
+ clicks: Number(slide.frontmatter.clicks ?? 0), clicks_known: slide.frontmatter.clicks != null,
45
+ ...(notes ? { notes } : {}),
46
+ };
47
+ });
43
48
  requireCondition(new Set(slides.map(s => s.id)).size === slides.length, 'SLIDE_ID', 'Slide names must be unique');
44
49
  const media_ids = parsed.slides.flatMap(slide => [...slide.content.matchAll(/<(?:video|audio)\b[^>]*\bid=["']([^"']+)["']/g)].map(match => match[1]));
45
- return { slides, media_ids, files: await slidevInputs(deck, parsed.headmatter, parsed.files), capabilities: ['slide', 'reveal', 'play', 'highlight:region', 'highlight:element', 'highlight:text', 'underline:region', 'underline:element', 'underline:text', 'spotlight:region', 'spotlight:element', 'spotlight:text', 'zoom:region', 'zoom:element', 'zoom:text', 'laser:path', 'laser:region', 'laser:element', 'laser:text', 'stamp:point', 'stamp:region', 'stamp:element', 'stamp:text'] };
50
+ return { slides, media_ids, files: await slidevInputs(deck, parsed.headmatter, parsed.files), capabilities: ['slide', 'reveal', 'play', 'highlight:region', 'highlight:element', 'highlight:text', 'underline:region', 'underline:element', 'underline:text', 'spotlight:region', 'spotlight:element', 'spotlight:text', 'zoom:region', 'zoom:element', 'zoom:text', 'laser:path', 'laser:region', 'laser:element', 'laser:text', 'stamp:point', 'stamp:region', 'stamp:element', 'stamp:text', 'arrow:connector', 'arrow:region', 'arrow:element', 'arrow:text'] };
46
51
  }
47
52
  export function validateSlidev(story, inspection, options) {
48
53
  const schedule = options?.schedule;
@@ -52,7 +57,9 @@ export function validateSlidev(story, inspection, options) {
52
57
  for (const annotation of story.annotations) {
53
58
  const targets = annotation.target.type === 'path'
54
59
  ? annotation.target.points.flatMap(point => 'target' in point ? [point.target] : [])
55
- : [annotation.target];
60
+ : annotation.target.type === 'connector'
61
+ ? [annotation.target.from, annotation.target.to].flatMap(ep => 'target' in ep ? [ep.target] : [])
62
+ : [annotation.target];
56
63
  for (const target of targets) {
57
64
  requireCondition(target.type !== 'shape' && !(target.type === 'text' && target.container?.type === 'shape'), 'ANNOTATION_TARGET', `Annotation ${annotation.id} uses a PowerPoint shape target unsupported by Slidev`, 3, { annotation: annotation.id });
58
65
  }
@@ -17,7 +17,7 @@ if (port === 'inspect') {
17
17
  if (!process.send || !process.disconnect)
18
18
  throw new Error('Inspection requires an IPC channel');
19
19
  process.send({
20
- slides: options.data.slides.map(slide => ({ frontmatter: slide.frontmatter, content: slide.content })),
20
+ slides: options.data.slides.map(slide => ({ frontmatter: slide.frontmatter, content: slide.content, note: slide.note })),
21
21
  headmatter: options.data.headmatter,
22
22
  files: Object.keys(options.data.markdownFiles),
23
23
  errors: Object.values(options.data.markdownFiles).flatMap(file => (file.errors ?? []).map(error => `${file.filepath}:${error.row + 1}: ${error.message}`)),
@@ -1,4 +1,4 @@
1
- import type { AnnotationGeometry, GeometryRequest, GeometryTarget, LaserInterpolation, Rectangle, ResolvedAnnotation, ResolvedAnnotationTarget, ResolvedHighlightAnnotation, ResolvedLaserAnnotation, ResolvedSpotlightAnnotation, ResolvedStampAnnotation, ResolvedUnderlineAnnotation, ResolvedZoomAnnotation, Schedule, StampFont, StampSymbol, ZoomEasing } from './contracts.js';
1
+ import type { AnnotationGeometry, ArrowHead, GeometryRequest, GeometryTarget, LaserInterpolation, Rectangle, ResolvedAnnotation, ResolvedAnnotationTarget, ResolvedArrowAnnotation, ResolvedHighlightAnnotation, ResolvedLaserAnnotation, ResolvedSpotlightAnnotation, ResolvedStampAnnotation, ResolvedUnderlineAnnotation, ResolvedZoomAnnotation, Schedule, StampFont, StampSymbol, ZoomEasing } from './contracts.js';
2
2
  export type BlendMode = 'source-over' | 'darken';
3
3
  export type AnnotationPaint = {
4
4
  rectangle: Rectangle;
@@ -144,7 +144,30 @@ export type StampEffect = {
144
144
  slide_bounds: Rectangle;
145
145
  overflow_error?: string;
146
146
  };
147
- export type PaintableEffect = HighlightEffect | UnderlineEffect | SpotlightEffect | ZoomEffect | LaserEffect | StampEffect;
147
+ export type ArrowEffect = {
148
+ effect: 'arrow';
149
+ start_ms: number;
150
+ end_ms: number;
151
+ motion_type: 'none' | 'fade' | 'draw';
152
+ in_ms: number;
153
+ out_ms: number;
154
+ start_x: number;
155
+ start_y: number;
156
+ end_x: number;
157
+ end_y: number;
158
+ ux: number;
159
+ uy: number;
160
+ length_px: number;
161
+ color: string;
162
+ opacity: number;
163
+ width_px: number;
164
+ style: 'solid' | 'dashed';
165
+ head: ArrowHead;
166
+ head_size_px: number;
167
+ slide_bounds: Rectangle;
168
+ degenerate_reason?: string;
169
+ };
170
+ export type PaintableEffect = HighlightEffect | UnderlineEffect | SpotlightEffect | ZoomEffect | LaserEffect | StampEffect | ArrowEffect;
148
171
  export type BlendGroup = {
149
172
  blend: BlendMode;
150
173
  primitives: AnnotationPaint[];
@@ -221,6 +244,16 @@ export declare function stampDirtyBounds(effect: StampEffect, timeMs: number): R
221
244
  export declare function paintStamp<FillStyle, StrokeStyle, CompositeOp>(context: EffectCanvas2D<FillStyle, StrokeStyle, CompositeOp>, effect: StampEffect, timeMs: number): void;
222
245
  export declare function hasActiveStamp(effects: readonly PaintableEffect[], timeMs: number): boolean;
223
246
  export declare function paintStamps<FillStyle, StrokeStyle, CompositeOp>(context: EffectCanvas2D<FillStyle, StrokeStyle, CompositeOp>, effects: readonly PaintableEffect[], timeMs: number): void;
247
+ export declare function arrowPaint(annotation: Pick<ResolvedArrowAnnotation, 'target' | 'appearance' | 'motion' | 'start_ms' | 'end_ms'>, slideGeometry: Pick<AnnotationGeometry, 'content' | 'viewport'>, resolveTarget: (target: ResolvedAnnotationTarget) => readonly Rectangle[] | undefined): ArrowEffect;
248
+ export declare function arrowVisible(effect: Pick<ArrowEffect, 'slide_bounds' | 'length_px' | 'width_px' | 'degenerate_reason'>): boolean;
249
+ export declare function arrowMotionState(effect: Pick<ArrowEffect, 'start_ms' | 'end_ms' | 'motion_type' | 'in_ms' | 'out_ms' | 'opacity'>, timeMs: number): {
250
+ opacity: number;
251
+ progress: number;
252
+ };
253
+ export declare function arrowDirtyBounds(effect: ArrowEffect, timeMs: number): Rectangle | undefined;
254
+ export declare function hasActiveArrow(effects: readonly PaintableEffect[], timeMs: number): boolean;
255
+ export declare function paintArrow<FillStyle, StrokeStyle, CompositeOp>(context: EffectCanvas2D<FillStyle, StrokeStyle, CompositeOp>, effect: ArrowEffect, timeMs: number): void;
256
+ export declare function paintArrows<FillStyle, StrokeStyle, CompositeOp>(context: EffectCanvas2D<FillStyle, StrokeStyle, CompositeOp>, effects: readonly PaintableEffect[], timeMs: number): void;
224
257
  export declare function laserDirtyBounds(effect: LaserEffect, timeMs: number): Rectangle | undefined;
225
258
  export declare function hasActiveLaser(effects: readonly PaintableEffect[], timeMs: number): boolean;
226
259
  export declare function paintLaser<FillStyle, StrokeStyle, CompositeOp>(context: EffectCanvas2D<FillStyle, StrokeStyle, CompositeOp>, effect: LaserEffect, timeMs: number): void;
@@ -7,6 +7,10 @@ const DEFAULT_LASER_OPACITY = 0.95;
7
7
  const DEFAULT_LASER_RADIUS = 0.008;
8
8
  const DEFAULT_LASER_GLOW = 0.024;
9
9
  const DEFAULT_LASER_TRAIL_MS = 240;
10
+ const DEFAULT_ARROW_COLOR = '#ff2d2d';
11
+ const DEFAULT_ARROW_OPACITY = 0.95;
12
+ const DEFAULT_ARROW_WIDTH = 0.006;
13
+ const DEFAULT_ARROW_HEAD_SIZE = 0.024;
10
14
  export function targetKey(target) {
11
15
  switch (target.type) {
12
16
  case 'slide':
@@ -55,6 +59,23 @@ export function annotationTargets(annotation) {
55
59
  }
56
60
  return targets;
57
61
  }
62
+ case 'arrow': {
63
+ const seen = new Set();
64
+ const targets = [];
65
+ const push = (t) => {
66
+ const key = targetKey(t);
67
+ if (!seen.has(key)) {
68
+ seen.add(key);
69
+ targets.push(t);
70
+ }
71
+ };
72
+ push({ type: 'slide' });
73
+ if ('target' in annotation.target.from)
74
+ push(annotation.target.from.target);
75
+ if ('target' in annotation.target.to)
76
+ push(annotation.target.to.target);
77
+ return targets;
78
+ }
58
79
  }
59
80
  }
60
81
  export function geometryRequests(schedule) {
@@ -937,6 +958,212 @@ export function paintStamps(context, effects, timeMs) {
937
958
  paintStamp(context, effect, timeMs);
938
959
  }
939
960
  }
961
+ export function arrowPaint(annotation, slideGeometry, resolveTarget) {
962
+ const { appearance, motion } = annotation;
963
+ const { content, viewport } = slideGeometry;
964
+ const clipLeft = Math.max(0, Math.round(content.x));
965
+ const clipTop = Math.max(0, Math.round(content.y));
966
+ const clipRight = Math.min(viewport.width, Math.round(content.x + content.width));
967
+ const clipBottom = Math.min(viewport.height, Math.round(content.y + content.height));
968
+ const slide_bounds = {
969
+ x: clipLeft,
970
+ y: clipTop,
971
+ width: Math.max(0, clipRight - clipLeft),
972
+ height: Math.max(0, clipBottom - clipTop),
973
+ };
974
+ const resolveEndpoint = (endpoint, role) => {
975
+ if ('target' in endpoint) {
976
+ const fragments = resolveTarget(endpoint.target);
977
+ if (!fragments || fragments.length === 0) {
978
+ throw new Error(`Missing geometry for arrow ${role} target ${targetKey(endpoint.target)}`);
979
+ }
980
+ return anchorPoint(fragments, endpoint.anchor, slide_bounds);
981
+ }
982
+ return {
983
+ x: Math.max(slide_bounds.x, Math.min(slide_bounds.x + slide_bounds.width, slide_bounds.x + endpoint.x * slide_bounds.width)),
984
+ y: Math.max(slide_bounds.y, Math.min(slide_bounds.y + slide_bounds.height, slide_bounds.y + endpoint.y * slide_bounds.height)),
985
+ };
986
+ };
987
+ const rawFrom = resolveEndpoint(annotation.target.from, 'from');
988
+ const rawTo = resolveEndpoint(annotation.target.to, 'to');
989
+ const dx = rawTo.x - rawFrom.x;
990
+ const dy = rawTo.y - rawFrom.y;
991
+ const rawLength = Math.hypot(dx, dy);
992
+ const fromPadPx = (annotation.target.from.padding ?? 0) * slide_bounds.height;
993
+ const toPadPx = (annotation.target.to.padding ?? 0) * slide_bounds.height;
994
+ const width_px = Math.max(1, (appearance?.width ?? DEFAULT_ARROW_WIDTH) * slide_bounds.height);
995
+ const head_size_px = Math.max(2, (appearance?.head_size ?? DEFAULT_ARROW_HEAD_SIZE) * slide_bounds.height);
996
+ const base = {
997
+ effect: 'arrow',
998
+ start_ms: annotation.start_ms,
999
+ end_ms: annotation.end_ms,
1000
+ motion_type: motion ? motion.type : 'none',
1001
+ in_ms: motion?.in_ms ?? 0,
1002
+ out_ms: motion?.out_ms ?? 0,
1003
+ color: (appearance?.color ?? DEFAULT_ARROW_COLOR).toLowerCase(),
1004
+ opacity: appearance?.opacity ?? DEFAULT_ARROW_OPACITY,
1005
+ width_px,
1006
+ style: appearance?.style ?? 'solid',
1007
+ head: appearance?.head ?? 'filled',
1008
+ head_size_px,
1009
+ slide_bounds,
1010
+ };
1011
+ if (rawLength <= 1e-6) {
1012
+ return {
1013
+ ...base,
1014
+ start_x: rawFrom.x,
1015
+ start_y: rawFrom.y,
1016
+ end_x: rawTo.x,
1017
+ end_y: rawTo.y,
1018
+ ux: 1,
1019
+ uy: 0,
1020
+ length_px: 0,
1021
+ degenerate_reason: 'arrow endpoints are coincident',
1022
+ };
1023
+ }
1024
+ const length_px = rawLength - fromPadPx - toPadPx;
1025
+ const ux = dx / rawLength;
1026
+ const uy = dy / rawLength;
1027
+ if (length_px <= 1) {
1028
+ return {
1029
+ ...base,
1030
+ start_x: rawFrom.x + ux * fromPadPx,
1031
+ start_y: rawFrom.y + uy * fromPadPx,
1032
+ end_x: rawTo.x - ux * toPadPx,
1033
+ end_y: rawTo.y - uy * toPadPx,
1034
+ ux,
1035
+ uy,
1036
+ length_px: 0,
1037
+ degenerate_reason: 'arrow endpoint padding collapses the arrow to zero length',
1038
+ };
1039
+ }
1040
+ return {
1041
+ ...base,
1042
+ start_x: rawFrom.x + ux * fromPadPx,
1043
+ start_y: rawFrom.y + uy * fromPadPx,
1044
+ end_x: rawTo.x - ux * toPadPx,
1045
+ end_y: rawTo.y - uy * toPadPx,
1046
+ ux,
1047
+ uy,
1048
+ length_px,
1049
+ };
1050
+ }
1051
+ export function arrowVisible(effect) {
1052
+ return effect.slide_bounds.width > 0 && effect.slide_bounds.height > 0 && effect.length_px > 1 && effect.width_px > 0 && !effect.degenerate_reason;
1053
+ }
1054
+ export function arrowMotionState(effect, timeMs) {
1055
+ if (effect.motion_type === 'none')
1056
+ return { opacity: effect.opacity, progress: 1 };
1057
+ const inFrac = effect.in_ms > 0 ? Math.max(0, Math.min(1, (timeMs - effect.start_ms) / effect.in_ms)) : 1;
1058
+ const outFrac = effect.out_ms > 0 ? Math.max(0, Math.min(1, (effect.end_ms - timeMs) / effect.out_ms)) : 1;
1059
+ if (effect.motion_type === 'fade') {
1060
+ return { opacity: effect.opacity * Math.min(inFrac, outFrac), progress: 1 };
1061
+ }
1062
+ return { opacity: effect.opacity * outFrac, progress: inFrac };
1063
+ }
1064
+ export function arrowDirtyBounds(effect, timeMs) {
1065
+ if (!arrowVisible(effect))
1066
+ return undefined;
1067
+ const state = arrowMotionState(effect, timeMs);
1068
+ if (state.opacity <= 1e-6 || state.progress <= 1e-6)
1069
+ return undefined;
1070
+ const curLen = effect.length_px * state.progress;
1071
+ const tipX = effect.start_x + effect.ux * curLen;
1072
+ const tipY = effect.start_y + effect.uy * curLen;
1073
+ const margin = Math.max(effect.width_px, effect.head_size_px * 0.6) + 2;
1074
+ const sb = effect.slide_bounds;
1075
+ const x = Math.max(sb.x, Math.floor(Math.min(effect.start_x, tipX) - margin));
1076
+ const y = Math.max(sb.y, Math.floor(Math.min(effect.start_y, tipY) - margin));
1077
+ const right = Math.min(sb.x + sb.width, Math.ceil(Math.max(effect.start_x, tipX) + margin));
1078
+ const bottom = Math.min(sb.y + sb.height, Math.ceil(Math.max(effect.start_y, tipY) + margin));
1079
+ return right > x && bottom > y ? { x, y, width: right - x, height: bottom - y } : undefined;
1080
+ }
1081
+ export function hasActiveArrow(effects, timeMs) {
1082
+ return effects.some(effect => {
1083
+ if (effect.effect !== 'arrow' || !arrowVisible(effect))
1084
+ return false;
1085
+ const state = arrowMotionState(effect, timeMs);
1086
+ return state.opacity > 1e-6 && state.progress > 1e-6;
1087
+ });
1088
+ }
1089
+ export function paintArrow(context, effect, timeMs) {
1090
+ if (!arrowVisible(effect))
1091
+ return;
1092
+ const state = arrowMotionState(effect, timeMs);
1093
+ if (state.opacity <= 1e-6 || state.progress <= 1e-6)
1094
+ return;
1095
+ const curLen = effect.length_px * state.progress;
1096
+ if (curLen <= 0.5)
1097
+ return;
1098
+ const { start_x, start_y, ux, uy, width_px, head_size_px, slide_bounds: sb } = effect;
1099
+ const px = -uy;
1100
+ const py = ux;
1101
+ const tipX = start_x + ux * curLen;
1102
+ const tipY = start_y + uy * curLen;
1103
+ const effectiveHeadLen = Math.min(head_size_px, curLen);
1104
+ const headHalfW = effectiveHeadLen * 0.45;
1105
+ const baseX = tipX - ux * effectiveHeadLen;
1106
+ const baseY = tipY - uy * effectiveHeadLen;
1107
+ const shaftEnd = effect.head === 'filled'
1108
+ ? Math.max(0, curLen - effectiveHeadLen)
1109
+ : Math.max(0, curLen - width_px * 0.25);
1110
+ context.save();
1111
+ context.beginPath();
1112
+ context.rect(sb.x, sb.y, sb.width, sb.height);
1113
+ context.clip();
1114
+ context.globalCompositeOperation = 'source-over';
1115
+ context.globalAlpha = state.opacity;
1116
+ if (shaftEnd > 0.5) {
1117
+ context.strokeStyle = effect.color;
1118
+ context.lineWidth = width_px;
1119
+ context.lineCap = 'butt';
1120
+ context.lineJoin = 'round';
1121
+ context.beginPath();
1122
+ if (effect.style === 'solid') {
1123
+ context.moveTo(start_x, start_y);
1124
+ context.lineTo(start_x + ux * shaftEnd, start_y + uy * shaftEnd);
1125
+ }
1126
+ else {
1127
+ const dash = Math.max(6, Math.round(width_px * 3));
1128
+ const gap = Math.max(4, Math.round(width_px * 2));
1129
+ for (let pos = 0; pos < shaftEnd; pos += dash + gap) {
1130
+ const segEnd = Math.min(shaftEnd, pos + dash);
1131
+ if (segEnd > pos) {
1132
+ context.moveTo(start_x + ux * pos, start_y + uy * pos);
1133
+ context.lineTo(start_x + ux * segEnd, start_y + uy * segEnd);
1134
+ }
1135
+ }
1136
+ }
1137
+ context.stroke();
1138
+ }
1139
+ if (effect.head === 'filled') {
1140
+ context.fillStyle = effect.color;
1141
+ context.beginPath();
1142
+ context.moveTo(tipX, tipY);
1143
+ context.lineTo(baseX + px * headHalfW, baseY + py * headHalfW);
1144
+ context.lineTo(baseX - px * headHalfW, baseY - py * headHalfW);
1145
+ context.closePath();
1146
+ context.fill();
1147
+ }
1148
+ else {
1149
+ context.strokeStyle = effect.color;
1150
+ context.lineWidth = width_px;
1151
+ context.lineCap = 'round';
1152
+ context.lineJoin = 'round';
1153
+ context.beginPath();
1154
+ context.moveTo(baseX + px * headHalfW, baseY + py * headHalfW);
1155
+ context.lineTo(tipX, tipY);
1156
+ context.lineTo(baseX - px * headHalfW, baseY - py * headHalfW);
1157
+ context.stroke();
1158
+ }
1159
+ context.restore();
1160
+ }
1161
+ export function paintArrows(context, effects, timeMs) {
1162
+ for (const effect of effects) {
1163
+ if (effect.effect === 'arrow')
1164
+ paintArrow(context, effect, timeMs);
1165
+ }
1166
+ }
940
1167
  export function laserDirtyBounds(effect, timeMs) {
941
1168
  const fade = laserFadeFraction(effect, timeMs);
942
1169
  if (fade <= 1e-6 || !laserVisible(effect))
@@ -1373,6 +1600,7 @@ export function effectPrimitives(effects, timeMs) {
1373
1600
  case 'zoom':
1374
1601
  case 'laser':
1375
1602
  case 'stamp':
1603
+ case 'arrow':
1376
1604
  break;
1377
1605
  }
1378
1606
  }
@@ -1430,6 +1658,11 @@ export function effectDirtyBounds(effects, timeMs, extraRectangles, viewport) {
1430
1658
  if (bounds)
1431
1659
  expand(bounds);
1432
1660
  }
1661
+ else if (effect.effect === 'arrow') {
1662
+ const bounds = arrowDirtyBounds(effect, timeMs);
1663
+ if (bounds)
1664
+ expand(bounds);
1665
+ }
1433
1666
  }
1434
1667
  for (const rect of extraRectangles)
1435
1668
  expand(rect);
@@ -1474,6 +1707,7 @@ export function paintEffects(context, effects, timeMs, options) {
1474
1707
  }
1475
1708
  }
1476
1709
  paintPrimitives(context, effectPrimitives(effects, timeMs), { backdrop });
1710
+ paintArrows(context, effects, timeMs);
1477
1711
  paintStamps(context, effects, timeMs);
1478
1712
  paintLasers(context, effects, timeMs);
1479
1713
  }
@@ -1,5 +1,5 @@
1
1
  import type { AnnotationGeometry, Rectangle, Schedule, VideoOutput, VisualArtifact } from './contracts.js';
2
- import { type HighlightEffect, type LaserEffect, type SpotlightEffect, type StampEffect, type UnderlineEffect, type ZoomEffect } from './annotation-paint.js';
2
+ import { type ArrowEffect, type HighlightEffect, type LaserEffect, type SpotlightEffect, type StampEffect, type UnderlineEffect, type ZoomEffect } from './annotation-paint.js';
3
3
  export type { AnnotationPaint } from './annotation-paint.js';
4
4
  export type AppliedHighlightAnnotation = HighlightEffect & {
5
5
  id: string;
@@ -37,7 +37,13 @@ export type AppliedStampAnnotation = StampEffect & {
37
37
  end_frame: number;
38
38
  geometry: AnnotationGeometry;
39
39
  };
40
- export type AppliedAnnotation = AppliedHighlightAnnotation | AppliedUnderlineAnnotation | AppliedSpotlightAnnotation | AppliedZoomAnnotation | AppliedLaserAnnotation | AppliedStampAnnotation;
40
+ export type AppliedArrowAnnotation = ArrowEffect & {
41
+ id: string;
42
+ first_frame: number;
43
+ end_frame: number;
44
+ geometry: AnnotationGeometry;
45
+ };
46
+ export type AppliedAnnotation = AppliedHighlightAnnotation | AppliedUnderlineAnnotation | AppliedSpotlightAnnotation | AppliedZoomAnnotation | AppliedLaserAnnotation | AppliedStampAnnotation | AppliedArrowAnnotation;
41
47
  export declare function annotationApplications(video: VideoOutput, schedule: Schedule, visual: VisualArtifact, audioOrigin: number): AppliedAnnotation[];
42
48
  export declare function verifyAnnotations(file: string, base: string, baseFilter: string, applications: AppliedAnnotation[], video: VideoOutput, directory: string, output: string, overlayBounds?: (frame: number) => Rectangle[], sha256?: string): Promise<{
43
49
  source: string;