@bendyline/squisq-react 1.3.2 → 1.4.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 (46) hide show
  1. package/README.md +57 -23
  2. package/dist/index.d.ts +131 -26
  3. package/dist/index.js +1475 -755
  4. package/dist/index.js.map +1 -1
  5. package/dist/squisq-player.css +1 -1
  6. package/dist/squisq-player.css.map +1 -1
  7. package/dist/squisq-player.global.js +49 -13
  8. package/dist/squisq-player.global.js.map +1 -1
  9. package/dist/standalone-source.js +1 -1
  10. package/dist/styles/index.css +2263 -0
  11. package/package.json +9 -5
  12. package/src/BlockRenderer.tsx +15 -7
  13. package/src/DocPlayer.tsx +222 -55
  14. package/src/DocPlayerWithSidebar.tsx +21 -9
  15. package/src/DocProgressBar.tsx +21 -3
  16. package/src/LinearDocView.tsx +69 -206
  17. package/src/MarkdownRenderer.tsx +182 -41
  18. package/src/MediaClipLayer.tsx +135 -0
  19. package/src/__tests__/DocPlayer.test.tsx +81 -0
  20. package/src/__tests__/DocPlayerStylesSentinel.test.tsx +41 -0
  21. package/src/__tests__/DocProgressBar.test.tsx +76 -0
  22. package/src/__tests__/LinearDocView.test.tsx +53 -1
  23. package/src/__tests__/MarkdownRenderer.test.tsx +113 -1
  24. package/src/__tests__/PathLayer.test.tsx +73 -0
  25. package/src/__tests__/fillStyle.test.tsx +112 -0
  26. package/src/__tests__/transitionStyles.test.ts +125 -0
  27. package/src/__tests__/useDocPlayback.transition.test.ts +70 -0
  28. package/src/__tests__/useJsonViewTokens.test.ts +41 -0
  29. package/src/__tests__/useSlideSwipe.test.ts +81 -0
  30. package/src/hooks/{AudioProvider.ts → AudioController.ts} +3 -3
  31. package/src/hooks/index.ts +7 -2
  32. package/src/hooks/useAudioSync.ts +19 -5
  33. package/src/hooks/useDocPlayback.ts +81 -100
  34. package/src/hooks/useMediaSchedule.ts +39 -0
  35. package/src/hooks/useSlideSwipe.ts +265 -0
  36. package/src/index.ts +8 -1
  37. package/src/jsonView/useJsonViewTokens.ts +6 -31
  38. package/src/layers/ImageLayer.tsx +11 -1
  39. package/src/layers/PathLayer.tsx +146 -0
  40. package/src/layers/ShapeLayer.tsx +27 -5
  41. package/src/layers/TextLayer.tsx +395 -22
  42. package/src/layers/VideoLayer.tsx +16 -9
  43. package/src/layers/index.ts +1 -0
  44. package/src/standalone-entry.tsx +1 -1
  45. package/src/styles/doc-animations.css +1936 -35
  46. package/src/utils/fillStyle.tsx +148 -0
package/README.md CHANGED
@@ -22,37 +22,54 @@ import { DocPlayer } from '@bendyline/squisq-react';
22
22
  import '@bendyline/squisq-react/styles';
23
23
 
24
24
  function App() {
25
- return <DocPlayer doc={myDoc} />;
25
+ return <DocPlayer markdown={'# Hello\n\nWelcome to Squisq.'} />;
26
26
  }
27
27
  ```
28
28
 
29
+ `DocPlayer` accepts **either** raw `markdown` (parsed and converted internally)
30
+ **or** a parsed `doc`; if you already have a `Doc`, pass `<DocPlayer doc={doc} />`.
31
+ `basePath` is optional (default `'.'`) and is the base URL for resolving relative
32
+ media paths. With neither `markdown` nor `doc`, the player renders a themed empty
33
+ state rather than crashing.
34
+
35
+ > **v1.5 breaking changes:** the old `script` prop is now `doc`, and the
36
+ > `audioProvider` prop is now `audioController` (its type `AudioProvider` was
37
+ > renamed to `AudioController`). `LinearDocView` gained the same `markdown` prop.
38
+
29
39
  ## Components
30
40
 
31
- | Component | Description |
32
- | ---------------------- | ------------------------------------------------------------------ |
33
- | `DocPlayer` | Main document player with timed playback, audio sync, and controls |
34
- | `LinearDocView` | Scroll-based linear rendering of all blocks |
35
- | `BlockRenderer` | SVG-based renderer for a single block |
36
- | `MarkdownRenderer` | Renders Squisq markdown as a visual document |
37
- | `DocPlayerWithSidebar` | DocPlayer with a sidebar navigation panel |
38
- | `CaptionOverlay` | Timed caption/subtitle overlay |
39
- | `DocProgressBar` | Playback progress indicator |
40
- | `DocControlsOverlay` | Floating playback controls |
41
- | `DocControlsBottom` | Bottom-bar playback controls |
42
- | `DocControlsSidebar` | Sidebar navigation controls |
43
- | `DocControlsSlideshow` | Slideshow-style navigation controls |
41
+ | Component | Description |
42
+ | ---------------------- | ------------------------------------------------------------------- |
43
+ | `DocPlayer` | Main document player with timed playback, audio sync, and controls |
44
+ | `LinearDocView` | Scroll-based linear rendering of all blocks |
45
+ | `BlockRenderer` | SVG-based renderer for a single block |
46
+ | `MarkdownRenderer` | Renders Squisq markdown as a visual document |
47
+ | `DocPlayerWithSidebar` | DocPlayer with a sidebar navigation panel |
48
+ | `CaptionOverlay` | Timed caption/subtitle overlay |
49
+ | `DocProgressBar` | Playback progress indicator |
50
+ | `DocControlsOverlay` | Floating playback controls |
51
+ | `DocControlsBottom` | Bottom-bar playback controls |
52
+ | `DocControlsSidebar` | Sidebar navigation controls |
53
+ | `DocControlsSlideshow` | Slideshow-style navigation controls |
54
+ | `SocialCaptionOverlay` | Large centered word-by-word (TikTok/Reels-style) captions |
55
+ | `InlineVideoPlayer` | Native `<video>` wrapper resolving `src`/`poster` via MediaContext |
56
+ | `InlineAudioPlayer` | Native `<audio>` wrapper resolving `src` via MediaContext |
57
+ | `MediaClipLayer` | Hidden `<audio>`/`<video>` elements for timed media clips |
58
+ | `JsonView` | Read-only viewer for JSON values bound to a Squisq-annotated schema |
44
59
 
45
60
  ## Layers
46
61
 
47
62
  Blocks are composed of typed layers rendered as SVG:
48
63
 
49
- | Layer | Description |
50
- | ------------ | ------------------------------------------ |
51
- | `ImageLayer` | Background and foreground images |
52
- | `TextLayer` | Styled text with positioning and animation |
53
- | `ShapeLayer` | SVG shapes (rectangles, circles, lines) |
54
- | `VideoLayer` | Embedded video with playback sync |
55
- | `MapLayer` | Tile-based map rendering |
64
+ | Layer | Description |
65
+ | ------------ | --------------------------------------------- |
66
+ | `ImageLayer` | Background and foreground images |
67
+ | `TextLayer` | Styled text with positioning and animation |
68
+ | `ShapeLayer` | SVG shapes (rectangles, circles, lines) |
69
+ | `PathLayer` | Freeform SVG path drawing |
70
+ | `VideoLayer` | Embedded video with playback sync |
71
+ | `TableLayer` | HTML table embedded via SVG `<foreignObject>` |
72
+ | `MapLayer` | Tile-based map rendering |
56
73
 
57
74
  ## Hooks
58
75
 
@@ -60,21 +77,33 @@ Blocks are composed of typed layers rendered as SVG:
60
77
  | ---------------------------------- | ------------------------------------------------------------------ |
61
78
  | `useDocPlayback` | Core playback state machine — timing, block transitions, scripting |
62
79
  | `useAudioSync` | Synchronizes audio playback with doc timeline |
80
+ | `useMediaSchedule` | Resolves which timed media clips are active at the current time |
63
81
  | `useViewportOrientation` | Tracks viewport orientation for responsive layouts |
82
+ | `useAutoSurface` | Live light/dark surface detection via `prefers-color-scheme` |
64
83
  | `useMediaProvider` / `useMediaUrl` | Media URL resolution via `MediaContext` |
65
84
 
66
85
  ## Standalone Player
67
86
 
68
- A self-contained global build is available for non-React environments:
87
+ A self-contained global build is available for non-React environments. It
88
+ exposes a `SquisqPlayer` global with `mount`, `mountStatic`, `unmount`, and
89
+ `version`:
69
90
 
70
91
  ```html
71
92
  <script src="https://unpkg.com/@bendyline/squisq-react/dist/squisq-player.global.js"></script>
72
93
  <div id="player"></div>
73
94
  <script>
74
- SquisqPlayer.render(document.getElementById('player'), { markdown: '# Hello' });
95
+ // docJson is a Doc (e.g. produced by markdownToDoc and serialized)
96
+ SquisqPlayer.mount(document.getElementById('player'), docJson, {
97
+ mode: 'slideshow', // or 'static' for a scrollable document view
98
+ basePath: '/',
99
+ });
75
100
  </script>
76
101
  ```
77
102
 
103
+ For build-time embedding, `@bendyline/squisq-react/standalone-source` exports
104
+ the same bundle as a string constant (`PLAYER_BUNDLE`) — used by
105
+ `@bendyline/squisq-formats` and the CLI to produce single-file HTML exports.
106
+
78
107
  ## Styles
79
108
 
80
109
  Import the animation CSS for block transitions:
@@ -83,6 +112,11 @@ Import the animation CSS for block transitions:
83
112
  import '@bendyline/squisq-react/styles';
84
113
  ```
85
114
 
115
+ ## Full API Reference
116
+
117
+ See [docs/API.md](https://github.com/bendyline/squisq/blob/main/docs/API.md)
118
+ for the complete prop tables, hook signatures, and types.
119
+
86
120
  ## Related Packages
87
121
 
88
122
  | Package | Description |
package/dist/index.d.ts CHANGED
@@ -1,14 +1,14 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { Block, Doc, Theme, SurfaceScheme, CaptionTrack, ViewportConfig as ViewportConfig$1, ImageLayer as ImageLayer$1, TextLayer as TextLayer$1, ShapeLayer as ShapeLayer$1, VideoLayer as VideoLayer$1, TableLayer as TableLayer$1, MapLayer as MapLayer$1, AudioTrack, MediaProvider } from '@bendyline/squisq/schemas';
2
+ import { Block, Doc, Theme, SurfaceScheme, Transition, CaptionTrack, ViewportConfig as ViewportConfig$1, ImageLayer as ImageLayer$1, TextLayer as TextLayer$1, ShapeLayer as ShapeLayer$1, PathLayer as PathLayer$1, VideoLayer as VideoLayer$1, TableLayer as TableLayer$1, MapLayer as MapLayer$1, ScheduledClip, AudioTrack, MediaProvider } from '@bendyline/squisq/schemas';
3
3
  import { ViewportConfig, ViewportOrientation } from '@bendyline/squisq/doc';
4
4
  export { getAnimationStyle, getTransitionClass } from '@bendyline/squisq/doc';
5
- import { MarkdownBlockNode } from '@bendyline/squisq/markdown';
5
+ import { MarkdownBlockNode, HtmlPolicy } from '@bendyline/squisq/markdown';
6
6
  import * as react from 'react';
7
7
  import { RefObject } from 'react';
8
8
  import { SquisqAnnotatedSchema } from '@bendyline/squisq/jsonForm';
9
9
 
10
10
  /**
11
- * AudioProvider - Abstraction for audio playback in DocPlayer
11
+ * AudioController - Abstraction for audio playback in DocPlayer
12
12
  *
13
13
  * This module defines an interface for audio playback operations that can have
14
14
  * different implementations depending on the runtime environment:
@@ -52,7 +52,7 @@ interface AudioActions {
52
52
  /** Restart from beginning */
53
53
  restart: () => Promise<void>;
54
54
  }
55
- type AudioProvider = AudioState & AudioActions;
55
+ type AudioController = AudioState & AudioActions;
56
56
 
57
57
  /**
58
58
  * Doc Player Control Types
@@ -209,10 +209,20 @@ type SquisqWindow = Window & typeof globalThis & Partial<SquisqRenderAPI>;
209
209
  declare function formatTime(seconds: number): string;
210
210
 
211
211
  interface DocPlayerProps {
212
- /** Doc script to play */
213
- script: Doc;
214
- /** Base path for resolving media URLs */
215
- basePath: string;
212
+ /**
213
+ * The Doc to play. Wins over `markdown` when both are provided.
214
+ * When neither `doc` nor `markdown` is given, the player renders a
215
+ * minimal themed empty state instead of crashing.
216
+ */
217
+ doc?: Doc;
218
+ /**
219
+ * Markdown source to play. When `doc` is absent, the markdown is parsed
220
+ * and converted to a Doc via `markdownToDoc(parseMarkdown(markdown))`.
221
+ * Ignored when `doc` is provided.
222
+ */
223
+ markdown?: string;
224
+ /** Base path for resolving media URLs (default: `'.'`) */
225
+ basePath?: string;
216
226
  /** Render mode for video capture (hides controls, exposes seekTo) */
217
227
  renderMode?: boolean;
218
228
  /** Auto-play when loaded */
@@ -221,8 +231,8 @@ interface DocPlayerProps {
221
231
  onEnded?: () => void;
222
232
  /** Callback for time updates */
223
233
  onTimeUpdate?: (time: number) => void;
224
- /** Optional audio provider (if not provided, uses default HTML5 audio) */
225
- audioProvider?: AudioProvider;
234
+ /** Optional audio controller (if not provided, uses default HTML5 audio) */
235
+ audioController?: AudioController;
226
236
  /** Show built-in controls (default: true). Set to false for custom controls. */
227
237
  showControls?: boolean;
228
238
  /** Show only the progress bar/scrubber at bottom (no other controls).
@@ -273,8 +283,21 @@ interface DocPlayerProps {
273
283
  /** Caption display style (default: 'standard').
274
284
  * 'social' shows large centered words with the active word highlighted. */
275
285
  captionStyle?: CaptionStyle;
286
+ /**
287
+ * Enable drag-to-swipe slide navigation in slideshow mode (default: true).
288
+ * When enabled, press-and-drag on a slide advances/rewinds on release past a
289
+ * threshold (or a quick flick), and snaps back otherwise. Only applies when
290
+ * `displayMode === 'slideshow'` and not in render/headless mode.
291
+ */
292
+ enableSwipe?: boolean;
276
293
  }
277
- declare function DocPlayer({ script, basePath, renderMode, autoPlay, onEnded, onTimeUpdate, audioProvider: externalAudioProvider, showControls, showScrubber, muted, captionsEnabled: captionsEnabledProp, onCaptionsToggle, onPlaybackStateChange, onControlsReady, isFullscreen, onFullscreenToggle, onBlockMarkers, forceViewport, displayMode, theme, surface, captionStyle, }: DocPlayerProps): react_jsx_runtime.JSX.Element;
294
+ /**
295
+ * Front-door component: resolves the `doc` / `markdown` props into a Doc
296
+ * and renders a themed empty state when neither is provided. The playback
297
+ * machinery lives in `DocPlayerContent` so its hook order never changes
298
+ * when a doc appears or disappears.
299
+ */
300
+ declare function DocPlayer(props: DocPlayerProps): react_jsx_runtime.JSX.Element;
278
301
 
279
302
  /** Default viewport dimensions (1080p landscape) - for backwards compatibility */
280
303
  declare const VIEWPORT: {
@@ -297,12 +320,14 @@ interface BlockRendererProps {
297
320
  isEntering?: boolean;
298
321
  /** Whether this block is exiting (for transition) */
299
322
  isExiting?: boolean;
323
+ /** Transition to apply. Defaults to block.transition. */
324
+ transition?: Transition;
300
325
  /** Viewport dimensions (defaults to 1920x1080 landscape) */
301
326
  viewport?: ViewportDimensions;
302
327
  /** Whether the doc is currently playing (controls video playback) */
303
328
  isPlaying?: boolean;
304
329
  }
305
- declare function BlockRenderer({ block, blockTime, basePath, isEntering, isExiting, viewport, isPlaying, }: BlockRendererProps): react_jsx_runtime.JSX.Element;
330
+ declare function BlockRenderer({ block, blockTime, basePath, isEntering, isExiting, transition, viewport, isPlaying, }: BlockRendererProps): react_jsx_runtime.JSX.Element;
306
331
 
307
332
  interface CaptionOverlayProps {
308
333
  /** Caption track with timestamped phrases */
@@ -362,12 +387,15 @@ interface DocControlsSlideshowProps {
362
387
  declare function DocControlsSlideshow({ state, slideNav }: DocControlsSlideshowProps): react_jsx_runtime.JSX.Element;
363
388
 
364
389
  interface DocPlayerWithSidebarProps {
365
- script: Doc;
366
- basePath: string;
390
+ /** The Doc to play */
391
+ doc: Doc;
392
+ /** Base path for resolving media URLs (default: `'.'`) */
393
+ basePath?: string;
367
394
  autoPlay?: boolean;
368
395
  onEnded?: () => void;
369
396
  onTimeUpdate?: (time: number) => void;
370
- audioProvider?: AudioProvider;
397
+ /** Optional audio controller (if not provided, uses default HTML5 audio) */
398
+ audioController?: AudioController;
371
399
  muted?: boolean;
372
400
  captionsEnabled?: boolean;
373
401
  isFullscreen?: boolean;
@@ -376,8 +404,15 @@ interface DocPlayerWithSidebarProps {
376
404
  forceViewport?: ViewportConfig$1;
377
405
  /** Called when playing state changes */
378
406
  onPlayingChange?: (isPlaying: boolean) => void;
407
+ /**
408
+ * Theme for rendering. Forwarded to the inner DocPlayer so the sidebar
409
+ * (portrait) layout matches the default (landscape) layout — without it the
410
+ * inner player falls back to DEFAULT_THEME, whose dark text is unreadable
411
+ * over a hero cover image.
412
+ */
413
+ theme?: Theme;
379
414
  }
380
- declare function DocPlayerWithSidebar({ script, basePath, autoPlay, onEnded, onTimeUpdate, audioProvider, muted, captionsEnabled, isFullscreen, onFullscreenToggle, forceViewport, onPlayingChange, }: DocPlayerWithSidebarProps): react_jsx_runtime.JSX.Element;
415
+ declare function DocPlayerWithSidebar({ doc, basePath, autoPlay, onEnded, onTimeUpdate, audioController, muted, captionsEnabled, isFullscreen, onFullscreenToggle, forceViewport, onPlayingChange, theme, }: DocPlayerWithSidebarProps): react_jsx_runtime.JSX.Element;
381
416
 
382
417
  interface DocProgressBarProps {
383
418
  state: PlaybackState$1;
@@ -395,6 +430,17 @@ interface MarkdownRendererProps {
395
430
  nodes: MarkdownBlockNode[];
396
431
  /** Optional CSS class for the wrapper element */
397
432
  className?: string;
433
+ /**
434
+ * Raw HTML policy. Defaults to `sanitize`, which removes unsafe tags,
435
+ * event handlers, and executable URL schemes before rendering.
436
+ */
437
+ htmlPolicy?: HtmlPolicy;
438
+ /**
439
+ * Extra URL schemes to allow on links (e.g. a host app's internal
440
+ * navigation scheme it intercepts on click). Executable schemes are
441
+ * never allowed regardless. See {@link SanitizeUrlOptions}.
442
+ */
443
+ linkSchemes?: readonly string[];
398
444
  }
399
445
  /**
400
446
  * Renders MarkdownBlockNode[] AST as React HTML elements.
@@ -404,11 +450,20 @@ interface MarkdownRendererProps {
404
450
  * <MarkdownRenderer nodes={block.contents} />
405
451
  * ```
406
452
  */
407
- declare function MarkdownRenderer({ nodes, className }: MarkdownRendererProps): react_jsx_runtime.JSX.Element | null;
453
+ declare function MarkdownRenderer({ nodes, className, htmlPolicy, linkSchemes, }: MarkdownRendererProps): react_jsx_runtime.JSX.Element | null;
408
454
 
409
455
  interface LinearDocViewProps {
410
- /** The Doc to render */
411
- doc: Doc;
456
+ /**
457
+ * The Doc to render. Wins over `markdown` when both are provided.
458
+ * When neither `doc` nor `markdown` is given, an empty container renders.
459
+ */
460
+ doc?: Doc;
461
+ /**
462
+ * Markdown source to render. When `doc` is absent, the markdown is parsed
463
+ * and converted to a Doc via `markdownToDoc(parseMarkdown(markdown))`.
464
+ * Ignored when `doc` is provided.
465
+ */
466
+ markdown?: string;
412
467
  /** Base path for resolving media URLs (images, etc.) */
413
468
  basePath?: string;
414
469
  /** Viewport config for SVG card rendering (default: landscape) */
@@ -456,7 +511,7 @@ type ImageDisplayMode = 'inline' | 'thumbnail';
456
511
  * <LinearDocView doc={doc} basePath="/media/" />
457
512
  * ```
458
513
  */
459
- declare function LinearDocView({ doc, basePath, viewport, className, theme, surface, thinMargins, imageDisplayMode, }: LinearDocViewProps): react_jsx_runtime.JSX.Element;
514
+ declare function LinearDocView({ doc, markdown, basePath, viewport, className, theme, surface, thinMargins, imageDisplayMode, }: LinearDocViewProps): react_jsx_runtime.JSX.Element;
460
515
 
461
516
  interface InlineVideoPlayerProps {
462
517
  /** Source path — resolved through MediaContext when relative. */
@@ -516,7 +571,11 @@ interface TextLayerProps {
516
571
  /** Current time relative to block start */
517
572
  blockTime: number;
518
573
  }
519
- declare function TextLayer({ layer, viewport, blockTime }: TextLayerProps): react_jsx_runtime.JSX.Element;
574
+ /**
575
+ * Dispatch between the plain SVG-text renderer and the rich HTML renderer
576
+ * based on whether the layer carries `content.html`.
577
+ */
578
+ declare function TextLayer(props: TextLayerProps): react_jsx_runtime.JSX.Element;
520
579
 
521
580
  interface ShapeLayerProps {
522
581
  layer: ShapeLayer$1;
@@ -530,6 +589,18 @@ interface ShapeLayerProps {
530
589
  }
531
590
  declare function ShapeLayer({ layer, viewport, blockTime }: ShapeLayerProps): react_jsx_runtime.JSX.Element;
532
591
 
592
+ interface PathLayerProps {
593
+ layer: PathLayer$1;
594
+ /** Viewport dimensions — used to resolve `%` positions for named shapes. */
595
+ viewport: {
596
+ width: number;
597
+ height: number;
598
+ };
599
+ /** Current time relative to block start. */
600
+ blockTime: number;
601
+ }
602
+ declare function PathLayer({ layer, viewport, blockTime }: PathLayerProps): react_jsx_runtime.JSX.Element;
603
+
533
604
  interface VideoLayerProps {
534
605
  layer: VideoLayer$1;
535
606
  /** Base path for resolving relative video URLs */
@@ -544,7 +615,7 @@ interface VideoLayerProps {
544
615
  /** Whether the doc is currently playing */
545
616
  isPlaying?: boolean;
546
617
  }
547
- declare function VideoLayer({ layer, basePath, viewport, blockTime: _blockTime, isPlaying, }: VideoLayerProps): react_jsx_runtime.JSX.Element;
618
+ declare function VideoLayer({ layer, basePath, viewport, blockTime, isPlaying }: VideoLayerProps): react_jsx_runtime.JSX.Element;
548
619
 
549
620
  interface TableLayerProps {
550
621
  layer: TableLayer$1;
@@ -572,6 +643,15 @@ interface MapLayerProps {
572
643
  }
573
644
  declare function MapLayer({ layer, basePath, viewport, blockTime }: MapLayerProps): react_jsx_runtime.JSX.Element;
574
645
 
646
+ interface MediaClipLayerProps {
647
+ schedule: ScheduledClip[];
648
+ currentTime: number;
649
+ isPlaying: boolean;
650
+ basePath: string;
651
+ renderMode?: boolean;
652
+ }
653
+ declare function MediaClipLayer({ schedule, currentTime, isPlaying, basePath, renderMode, }: MediaClipLayerProps): react_jsx_runtime.JSX.Element | null;
654
+
575
655
  /**
576
656
  * useAudioSync Hook
577
657
  *
@@ -581,11 +661,36 @@ declare function MapLayer({ layer, basePath, viewport, blockTime }: MapLayerProp
581
661
  * Handles multiple audio segments (MP3 files) by tracking which segment
582
662
  * is currently playing and calculating the overall timeline position.
583
663
  *
584
- * This is the HTML5 Audio implementation of the AudioProvider interface.
585
- * For EFB/MSFS environments, use useCompanionAudioSync instead.
664
+ * This is the HTML5 Audio implementation of the AudioController interface.
665
+ * Hosts that drive audio through an external player (e.g. a native shell)
666
+ * can supply their own AudioController to DocPlayer instead of this hook.
667
+ */
668
+
669
+ declare function useAudioSync(audioRef: RefObject<HTMLAudioElement>, audioTrack: AudioTrack | undefined, basePath?: string): AudioController;
670
+
671
+ /**
672
+ * useMediaSchedule
673
+ *
674
+ * Pure follower of the playback clock for the media-clip model. Given the
675
+ * resolved {@link ScheduledClip}s and the current time, it returns the clips
676
+ * the player should mount and which of them are active right now.
677
+ * {@link MediaClipLayer} consumes this to drive one hidden `<audio>` /
678
+ * full-bleed `<video>` element per clip. (Annotation-authored clips all render
679
+ * at the player level; template-produced `VideoLayer`s are a separate path and
680
+ * are not part of the schedule.)
681
+ *
682
+ * It owns no clock: `currentTime`/`isPlaying` come from the existing
683
+ * `useAudioSync` provider via `DocPlayer`. With an empty schedule it returns
684
+ * empty lists, so documents without the new media model are unaffected.
586
685
  */
587
686
 
588
- declare function useAudioSync(audioRef: RefObject<HTMLAudioElement>, audioTrack: AudioTrack | undefined, basePath?: string): AudioProvider;
687
+ interface MediaScheduleController {
688
+ /** Clips the player mounts (every scheduled clip). */
689
+ renderClips: ScheduledClip[];
690
+ /** Ids of clips whose [absoluteStart, absoluteEnd) contains currentTime. */
691
+ activeIds: Set<string>;
692
+ }
693
+ declare function useMediaSchedule(schedule: ScheduledClip[], currentTime: number): MediaScheduleController;
589
694
 
590
695
  /**
591
696
  * useDocPlayback Hook
@@ -707,4 +812,4 @@ interface JsonViewProps {
707
812
  }
708
813
  declare function JsonView(props: JsonViewProps): react_jsx_runtime.JSX.Element;
709
814
 
710
- export { type AudioActions, type AudioProvider, type AudioState, type BlockMarker, BlockRenderer, type CaptionMode, CaptionOverlay, type CaptionStyle, type ControlsLayout, type DisplayMode, DocControlsBottom, DocControlsOverlay, DocControlsSidebar, DocControlsSlideshow, DocPlayer, DocPlayerWithSidebar, DocProgressBar, type ImageDisplayMode, ImageLayer, InlineAudioPlayer, type InlineAudioPlayerProps, InlineVideoPlayer, type InlineVideoPlayerProps, JsonView, type JsonViewProps, LinearDocView, type LinearDocViewProps, MapLayer, MarkdownRenderer, MediaContext, type PlaybackActions$1 as PlaybackActions, type PlaybackState$1 as PlaybackState, type RenderAudioSegmentInfo, type RenderBlockInfo, type RenderCaptionInfo, type RenderChapterInfo, ShapeLayer, type SlideNavActions, SocialCaptionOverlay, type SquisqRenderAPI, type SquisqWindow, TableLayer, TextLayer, VIEWPORT, VideoLayer, formatTime, useAudioSync, useAutoSurface, useDocPlayback, useMediaProvider, useMediaUrl, useViewportOrientation };
815
+ export { type AudioActions, type AudioController, type AudioState, type BlockMarker, BlockRenderer, type CaptionMode, CaptionOverlay, type CaptionStyle, type ControlsLayout, type DisplayMode, DocControlsBottom, DocControlsOverlay, DocControlsSidebar, DocControlsSlideshow, DocPlayer, DocPlayerWithSidebar, DocProgressBar, type ImageDisplayMode, ImageLayer, InlineAudioPlayer, type InlineAudioPlayerProps, InlineVideoPlayer, type InlineVideoPlayerProps, JsonView, type JsonViewProps, LinearDocView, type LinearDocViewProps, MapLayer, MarkdownRenderer, MediaClipLayer, type MediaClipLayerProps, MediaContext, type MediaScheduleController, PathLayer, type PlaybackActions$1 as PlaybackActions, type PlaybackState$1 as PlaybackState, type RenderAudioSegmentInfo, type RenderBlockInfo, type RenderCaptionInfo, type RenderChapterInfo, ShapeLayer, type SlideNavActions, SocialCaptionOverlay, type SquisqRenderAPI, type SquisqWindow, TableLayer, TextLayer, VIEWPORT, VideoLayer, formatTime, useAudioSync, useAutoSurface, useDocPlayback, useMediaProvider, useMediaSchedule, useMediaUrl, useViewportOrientation };