@livo-tv/blocks 1.33.0 → 1.35.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/dist/video.d.cts CHANGED
@@ -386,8 +386,35 @@ declare function usePlaybackStats(statsUrl: string | null | undefined, { interva
386
386
 
387
387
  declare const CAPTION_LOCALES: readonly ["en", "es", "pt"];
388
388
  type CaptionLocale = (typeof CAPTION_LOCALES)[number];
389
+ type LiveCaptionCue = {
390
+ text: string;
391
+ receivedAt: number;
392
+ speaker?: number;
393
+ };
394
+ type CaptionScreen = {
395
+ text: string;
396
+ speaker?: number;
397
+ };
398
+ type LiveCaptionPlayout = {
399
+ screen: CaptionScreen | null;
400
+ hideAt: number;
401
+ cursor: number;
402
+ queue: CaptionScreen[];
403
+ };
404
+ declare const EMPTY_LIVE_CAPTION_PLAYOUT: LiveCaptionPlayout;
405
+ type LiveCaptionsLoad = {
406
+ ok: true;
407
+ cues: LiveCaptionCue[];
408
+ } | {
409
+ ok: false;
410
+ cues: [];
411
+ };
389
412
  declare function isCaptionLocale(value: string): value is CaptionLocale;
390
413
  declare function captionsVttUrlFromPlayback(src: string, locale: CaptionLocale): string | null;
414
+ declare function liveCaptionsUrl(base: string, locale: CaptionLocale): string;
415
+ declare function advanceLiveCaptionPlayout(state: LiveCaptionPlayout, cues: LiveCaptionCue[], now: number, lagMs: number | null, maxCharsPerLine?: number, extraLagMs?: number): LiveCaptionPlayout;
416
+ declare function mergeLiveCaptionCues(existing: LiveCaptionCue[], incoming: LiveCaptionCue[], cap?: number): LiveCaptionCue[];
417
+ declare function loadLiveCaptions(url: string): Promise<LiveCaptionsLoad>;
391
418
 
392
419
  interface VideoPlayerLabels {
393
420
  play?: string;
@@ -484,6 +511,13 @@ interface VideoPlayerProps {
484
511
  */
485
512
  declare function VideoPlayer({ src, mode, poster, autoPlay, muted, stats, labels, showQualitySelector, paused, onPlayingChange, onFirstPlay, onError, onPlaybackProgress, onRebuffer, onQualityChange, fit, className, defaultCaptionLocale, captionsEnabled, liveCaptionsBaseUrl, }: VideoPlayerProps): React.JSX.Element;
486
513
 
514
+ type CaptionOverlayProps = {
515
+ screen: CaptionScreen | null;
516
+ className?: string;
517
+ textClassName?: string;
518
+ };
519
+ declare function CaptionOverlay({ screen, className, textClassName, }: CaptionOverlayProps): React.JSX.Element | null;
520
+
487
521
  interface FeedVideoPlayerProps extends VideoPlayerProps {
488
522
  /** Stable id for exclusive playback (typically the feed post id). */
489
523
  playbackId: string;
@@ -608,4 +642,4 @@ type PlaybackBeaconClient = {
608
642
  };
609
643
  declare function createPlaybackBeaconClient({ endpoint, sessionId, surface, getContext, fetchFn, intervalMs, now, }: CreatePlaybackBeaconClientOptions): PlaybackBeaconClient;
610
644
 
611
- export { type AutoplayState, CAPTION_LOCALES, type CaptionLocale, type CreatePlaybackBeaconClientOptions, type CurtainKind, CurtainPicker, type CurtainPickerItem, type CurtainPickerLabels, type CurtainPickerOwnerType, type CurtainPickerProps, CurtainPickerSkeleton, CurtainPreview, type CurtainPreviewProps, CurtainStage, type CurtainStageLabels, type CurtainStageProps, DEFAULT_CURTAIN_PICKER_LABELS, DEFAULT_SHADER_CURTAIN_CONFIG, DEFAULT_SHADER_CURTAIN_EDITOR_LABELS, type DescribedPlaybackError, FeedVideoPlayer, type FeedVideoPlayerProps, type HlsPlayerMode, type PlaybackBeaconClient, type PlaybackBeaconEvent, type PlaybackBeaconEventType, type PlaybackBeaconSurface, type PlaybackBeaconTrackInput, type PlaybackErrorContext, type PlaybackErrorDetail, type PlaybackErrorKind, type PlaybackState, type PlaybackStats, type QualityLevel, SHADER_CURTAIN_PRESETS, ShaderCurtain, type ShaderCurtainConfig, ShaderCurtainEditor, type ShaderCurtainEditorHandle, type ShaderCurtainEditorLabels, type ShaderCurtainEditorProps, type ShaderCurtainPreset, type ShaderCurtainProps, type UseFeedExclusivePlaybackResult, type UseHlsPlaybackOptions, type UseHlsPlaybackResult, type UsePlaybackStatsOptions, VideoPlayer, type VideoPlayerLabels, type VideoPlayerProps, WaitingRoom, type WaitingRoomCurtain, type WaitingRoomProps, captionsVttUrlFromPlayback, captureShaderPoster, castHlsUrl, createLiveHlsConfig, createPlaybackBeaconClient, createVodHlsConfig, describeAvResync, describePlaybackError, isCaptionLocale, isShaderCurtainKind, loadCastSender, mergeShaderCurtainConfig, parseShaderGradientUrl, shouldRetryLiveEdge404, toShaderGradientUrl, useFeedExclusivePlayback, useHlsPlayback, usePlaybackStats };
645
+ export { type AutoplayState, CAPTION_LOCALES, type CaptionLocale, CaptionOverlay, type CaptionOverlayProps, type CaptionScreen, type CreatePlaybackBeaconClientOptions, type CurtainKind, CurtainPicker, type CurtainPickerItem, type CurtainPickerLabels, type CurtainPickerOwnerType, type CurtainPickerProps, CurtainPickerSkeleton, CurtainPreview, type CurtainPreviewProps, CurtainStage, type CurtainStageLabels, type CurtainStageProps, DEFAULT_CURTAIN_PICKER_LABELS, DEFAULT_SHADER_CURTAIN_CONFIG, DEFAULT_SHADER_CURTAIN_EDITOR_LABELS, type DescribedPlaybackError, EMPTY_LIVE_CAPTION_PLAYOUT, FeedVideoPlayer, type FeedVideoPlayerProps, type HlsPlayerMode, type LiveCaptionCue, type LiveCaptionPlayout, type PlaybackBeaconClient, type PlaybackBeaconEvent, type PlaybackBeaconEventType, type PlaybackBeaconSurface, type PlaybackBeaconTrackInput, type PlaybackErrorContext, type PlaybackErrorDetail, type PlaybackErrorKind, type PlaybackState, type PlaybackStats, type QualityLevel, SHADER_CURTAIN_PRESETS, ShaderCurtain, type ShaderCurtainConfig, ShaderCurtainEditor, type ShaderCurtainEditorHandle, type ShaderCurtainEditorLabels, type ShaderCurtainEditorProps, type ShaderCurtainPreset, type ShaderCurtainProps, type UseFeedExclusivePlaybackResult, type UseHlsPlaybackOptions, type UseHlsPlaybackResult, type UsePlaybackStatsOptions, VideoPlayer, type VideoPlayerLabels, type VideoPlayerProps, WaitingRoom, type WaitingRoomCurtain, type WaitingRoomProps, advanceLiveCaptionPlayout, captionsVttUrlFromPlayback, captureShaderPoster, castHlsUrl, createLiveHlsConfig, createPlaybackBeaconClient, createVodHlsConfig, describeAvResync, describePlaybackError, isCaptionLocale, isShaderCurtainKind, liveCaptionsUrl, loadCastSender, loadLiveCaptions, mergeLiveCaptionCues, mergeShaderCurtainConfig, parseShaderGradientUrl, shouldRetryLiveEdge404, toShaderGradientUrl, useFeedExclusivePlayback, useHlsPlayback, usePlaybackStats };
package/dist/video.d.ts CHANGED
@@ -386,8 +386,35 @@ declare function usePlaybackStats(statsUrl: string | null | undefined, { interva
386
386
 
387
387
  declare const CAPTION_LOCALES: readonly ["en", "es", "pt"];
388
388
  type CaptionLocale = (typeof CAPTION_LOCALES)[number];
389
+ type LiveCaptionCue = {
390
+ text: string;
391
+ receivedAt: number;
392
+ speaker?: number;
393
+ };
394
+ type CaptionScreen = {
395
+ text: string;
396
+ speaker?: number;
397
+ };
398
+ type LiveCaptionPlayout = {
399
+ screen: CaptionScreen | null;
400
+ hideAt: number;
401
+ cursor: number;
402
+ queue: CaptionScreen[];
403
+ };
404
+ declare const EMPTY_LIVE_CAPTION_PLAYOUT: LiveCaptionPlayout;
405
+ type LiveCaptionsLoad = {
406
+ ok: true;
407
+ cues: LiveCaptionCue[];
408
+ } | {
409
+ ok: false;
410
+ cues: [];
411
+ };
389
412
  declare function isCaptionLocale(value: string): value is CaptionLocale;
390
413
  declare function captionsVttUrlFromPlayback(src: string, locale: CaptionLocale): string | null;
414
+ declare function liveCaptionsUrl(base: string, locale: CaptionLocale): string;
415
+ declare function advanceLiveCaptionPlayout(state: LiveCaptionPlayout, cues: LiveCaptionCue[], now: number, lagMs: number | null, maxCharsPerLine?: number, extraLagMs?: number): LiveCaptionPlayout;
416
+ declare function mergeLiveCaptionCues(existing: LiveCaptionCue[], incoming: LiveCaptionCue[], cap?: number): LiveCaptionCue[];
417
+ declare function loadLiveCaptions(url: string): Promise<LiveCaptionsLoad>;
391
418
 
392
419
  interface VideoPlayerLabels {
393
420
  play?: string;
@@ -484,6 +511,13 @@ interface VideoPlayerProps {
484
511
  */
485
512
  declare function VideoPlayer({ src, mode, poster, autoPlay, muted, stats, labels, showQualitySelector, paused, onPlayingChange, onFirstPlay, onError, onPlaybackProgress, onRebuffer, onQualityChange, fit, className, defaultCaptionLocale, captionsEnabled, liveCaptionsBaseUrl, }: VideoPlayerProps): React.JSX.Element;
486
513
 
514
+ type CaptionOverlayProps = {
515
+ screen: CaptionScreen | null;
516
+ className?: string;
517
+ textClassName?: string;
518
+ };
519
+ declare function CaptionOverlay({ screen, className, textClassName, }: CaptionOverlayProps): React.JSX.Element | null;
520
+
487
521
  interface FeedVideoPlayerProps extends VideoPlayerProps {
488
522
  /** Stable id for exclusive playback (typically the feed post id). */
489
523
  playbackId: string;
@@ -608,4 +642,4 @@ type PlaybackBeaconClient = {
608
642
  };
609
643
  declare function createPlaybackBeaconClient({ endpoint, sessionId, surface, getContext, fetchFn, intervalMs, now, }: CreatePlaybackBeaconClientOptions): PlaybackBeaconClient;
610
644
 
611
- export { type AutoplayState, CAPTION_LOCALES, type CaptionLocale, type CreatePlaybackBeaconClientOptions, type CurtainKind, CurtainPicker, type CurtainPickerItem, type CurtainPickerLabels, type CurtainPickerOwnerType, type CurtainPickerProps, CurtainPickerSkeleton, CurtainPreview, type CurtainPreviewProps, CurtainStage, type CurtainStageLabels, type CurtainStageProps, DEFAULT_CURTAIN_PICKER_LABELS, DEFAULT_SHADER_CURTAIN_CONFIG, DEFAULT_SHADER_CURTAIN_EDITOR_LABELS, type DescribedPlaybackError, FeedVideoPlayer, type FeedVideoPlayerProps, type HlsPlayerMode, type PlaybackBeaconClient, type PlaybackBeaconEvent, type PlaybackBeaconEventType, type PlaybackBeaconSurface, type PlaybackBeaconTrackInput, type PlaybackErrorContext, type PlaybackErrorDetail, type PlaybackErrorKind, type PlaybackState, type PlaybackStats, type QualityLevel, SHADER_CURTAIN_PRESETS, ShaderCurtain, type ShaderCurtainConfig, ShaderCurtainEditor, type ShaderCurtainEditorHandle, type ShaderCurtainEditorLabels, type ShaderCurtainEditorProps, type ShaderCurtainPreset, type ShaderCurtainProps, type UseFeedExclusivePlaybackResult, type UseHlsPlaybackOptions, type UseHlsPlaybackResult, type UsePlaybackStatsOptions, VideoPlayer, type VideoPlayerLabels, type VideoPlayerProps, WaitingRoom, type WaitingRoomCurtain, type WaitingRoomProps, captionsVttUrlFromPlayback, captureShaderPoster, castHlsUrl, createLiveHlsConfig, createPlaybackBeaconClient, createVodHlsConfig, describeAvResync, describePlaybackError, isCaptionLocale, isShaderCurtainKind, loadCastSender, mergeShaderCurtainConfig, parseShaderGradientUrl, shouldRetryLiveEdge404, toShaderGradientUrl, useFeedExclusivePlayback, useHlsPlayback, usePlaybackStats };
645
+ export { type AutoplayState, CAPTION_LOCALES, type CaptionLocale, CaptionOverlay, type CaptionOverlayProps, type CaptionScreen, type CreatePlaybackBeaconClientOptions, type CurtainKind, CurtainPicker, type CurtainPickerItem, type CurtainPickerLabels, type CurtainPickerOwnerType, type CurtainPickerProps, CurtainPickerSkeleton, CurtainPreview, type CurtainPreviewProps, CurtainStage, type CurtainStageLabels, type CurtainStageProps, DEFAULT_CURTAIN_PICKER_LABELS, DEFAULT_SHADER_CURTAIN_CONFIG, DEFAULT_SHADER_CURTAIN_EDITOR_LABELS, type DescribedPlaybackError, EMPTY_LIVE_CAPTION_PLAYOUT, FeedVideoPlayer, type FeedVideoPlayerProps, type HlsPlayerMode, type LiveCaptionCue, type LiveCaptionPlayout, type PlaybackBeaconClient, type PlaybackBeaconEvent, type PlaybackBeaconEventType, type PlaybackBeaconSurface, type PlaybackBeaconTrackInput, type PlaybackErrorContext, type PlaybackErrorDetail, type PlaybackErrorKind, type PlaybackState, type PlaybackStats, type QualityLevel, SHADER_CURTAIN_PRESETS, ShaderCurtain, type ShaderCurtainConfig, ShaderCurtainEditor, type ShaderCurtainEditorHandle, type ShaderCurtainEditorLabels, type ShaderCurtainEditorProps, type ShaderCurtainPreset, type ShaderCurtainProps, type UseFeedExclusivePlaybackResult, type UseHlsPlaybackOptions, type UseHlsPlaybackResult, type UsePlaybackStatsOptions, VideoPlayer, type VideoPlayerLabels, type VideoPlayerProps, WaitingRoom, type WaitingRoomCurtain, type WaitingRoomProps, advanceLiveCaptionPlayout, captionsVttUrlFromPlayback, captureShaderPoster, castHlsUrl, createLiveHlsConfig, createPlaybackBeaconClient, createVodHlsConfig, describeAvResync, describePlaybackError, isCaptionLocale, isShaderCurtainKind, liveCaptionsUrl, loadCastSender, loadLiveCaptions, mergeLiveCaptionCues, mergeShaderCurtainConfig, parseShaderGradientUrl, shouldRetryLiveEdge404, toShaderGradientUrl, useFeedExclusivePlayback, useHlsPlayback, usePlaybackStats };
package/dist/video.js CHANGED
@@ -2708,13 +2708,13 @@ function captionDwellMs(text, backlog = 0) {
2708
2708
  const max = backlog > 0 ? CAPTION_RUSH_DWELL_MS : CAPTION_MAX_DWELL_MS;
2709
2709
  return Math.min(max, Math.max(CAPTION_MIN_DWELL_MS, raw));
2710
2710
  }
2711
- function advanceLiveCaptionPlayout(state, cues, now, lagMs, maxCharsPerLine = CAPTION_MAX_CHARS_PER_LINE) {
2711
+ function advanceLiveCaptionPlayout(state, cues, now, lagMs, maxCharsPerLine = CAPTION_MAX_CHARS_PER_LINE, extraLagMs = LIVE_CUE_EXTRA_LAG_MS) {
2712
2712
  let screen = state.screen;
2713
2713
  let hideAt = state.hideAt;
2714
2714
  let cursor = state.cursor;
2715
2715
  let queue = state.queue.slice();
2716
2716
  if (lagMs != null && Number.isFinite(lagMs) && lagMs >= 0) {
2717
- const threshold = lagMs + LIVE_CUE_EXTRA_LAG_MS;
2717
+ const threshold = lagMs + extraLagMs;
2718
2718
  const incoming = cues.filter(
2719
2719
  (cue) => Boolean(cue.text.trim()) && Number.isFinite(cue.receivedAt) && cue.receivedAt > cursor && now - cue.receivedAt >= threshold
2720
2720
  ).sort((left, right) => left.receivedAt - right.receivedAt);
@@ -3513,7 +3513,11 @@ function isEmbeddedWindow(win = window) {
3513
3513
  return true;
3514
3514
  }
3515
3515
  }
3516
- function CaptionOverlay({ screen }) {
3516
+ function CaptionOverlay({
3517
+ screen,
3518
+ className,
3519
+ textClassName
3520
+ }) {
3517
3521
  const lastSpeakerRef = React11.useRef(void 0);
3518
3522
  const lastSpeaker = lastSpeakerRef.current;
3519
3523
  React11.useLayoutEffect(() => {
@@ -3525,14 +3529,20 @@ function CaptionOverlay({ screen }) {
3525
3529
  return /* @__PURE__ */ jsx(
3526
3530
  "div",
3527
3531
  {
3528
- className: "pointer-events-none absolute inset-x-0 bottom-16 z-[1] flex justify-center px-4",
3532
+ className: cn(
3533
+ "pointer-events-none absolute inset-x-0 bottom-16 z-[1] flex justify-center px-4",
3534
+ className
3535
+ ),
3529
3536
  "data-slot": "video-captions",
3530
3537
  children: /* @__PURE__ */ jsx(
3531
3538
  "p",
3532
3539
  {
3533
3540
  role: "status",
3534
3541
  "aria-live": "polite",
3535
- className: "line-clamp-2 max-w-[90%] whitespace-pre-line break-words rounded-sm bg-black/70 px-3 py-1.5 text-center text-[length:clamp(10px,2.6cqh,0.875rem)] font-medium text-white shadow-sm [-webkit-text-size-adjust:100%] [text-size-adjust:100%]",
3542
+ className: cn(
3543
+ "line-clamp-2 max-w-[90%] whitespace-pre-line break-words rounded-sm bg-black/70 px-3 py-1.5 text-center text-[length:clamp(10px,2.6cqh,0.875rem)] font-medium text-white shadow-sm [-webkit-text-size-adjust:100%] [text-size-adjust:100%]",
3544
+ textClassName
3545
+ ),
3536
3546
  children: text
3537
3547
  }
3538
3548
  )
@@ -4112,16 +4122,21 @@ function VideoPlayer({
4112
4122
  if (video.paused) void video.play();
4113
4123
  else video.pause();
4114
4124
  }
4115
- function toggleMute() {
4125
+ function applyMuted(next) {
4116
4126
  const video = videoRef.current;
4117
- if (!video) return;
4118
- video.muted = !video.muted;
4127
+ isMutedRef.current = next;
4128
+ setIsMuted(next);
4129
+ if (video) video.muted = next;
4130
+ }
4131
+ function toggleMute() {
4132
+ applyMuted(!isMutedRef.current);
4119
4133
  }
4120
4134
  function changeVolume(next) {
4121
4135
  const video = videoRef.current;
4122
4136
  if (!video) return;
4123
4137
  video.volume = next;
4124
- video.muted = next === 0;
4138
+ setVolume(next);
4139
+ applyMuted(next === 0);
4125
4140
  }
4126
4141
  function seekTo(next) {
4127
4142
  const video = videoRef.current;
@@ -4383,7 +4398,7 @@ function VideoPlayer({
4383
4398
  children: /* @__PURE__ */ jsx(Play, { className: "size-8 translate-x-0.5", fill: "currentColor" })
4384
4399
  }
4385
4400
  ) }),
4386
- state === "ready" && autoplayState === "muted" && /* @__PURE__ */ jsxs(
4401
+ state === "ready" && autoplayState === "muted" && isMuted && /* @__PURE__ */ jsxs(
4387
4402
  "button",
4388
4403
  {
4389
4404
  type: "button",
@@ -5066,6 +5081,6 @@ function createPlaybackBeaconClient({
5066
5081
  };
5067
5082
  }
5068
5083
 
5069
- export { CAPTION_LOCALES, CurtainPicker, CurtainPickerSkeleton, CurtainPreview, CurtainStage, DEFAULT_CURTAIN_PICKER_LABELS, DEFAULT_SHADER_CURTAIN_CONFIG, DEFAULT_SHADER_CURTAIN_EDITOR_LABELS, FeedVideoPlayer, SHADER_CURTAIN_PRESETS, ShaderCurtain, ShaderCurtainEditor, VideoPlayer, WaitingRoom, captionsVttUrlFromPlayback, captureShaderPoster, castHlsUrl, createLiveHlsConfig, createPlaybackBeaconClient, createVodHlsConfig, describeAvResync, describePlaybackError, isCaptionLocale, isShaderCurtainKind, loadCastSender, mergeShaderCurtainConfig, parseShaderGradientUrl, shouldRetryLiveEdge404, toShaderGradientUrl, useFeedExclusivePlayback, useHlsPlayback, usePlaybackStats };
5084
+ export { CAPTION_LOCALES, CaptionOverlay, CurtainPicker, CurtainPickerSkeleton, CurtainPreview, CurtainStage, DEFAULT_CURTAIN_PICKER_LABELS, DEFAULT_SHADER_CURTAIN_CONFIG, DEFAULT_SHADER_CURTAIN_EDITOR_LABELS, EMPTY_LIVE_CAPTION_PLAYOUT, FeedVideoPlayer, SHADER_CURTAIN_PRESETS, ShaderCurtain, ShaderCurtainEditor, VideoPlayer, WaitingRoom, advanceLiveCaptionPlayout, captionsVttUrlFromPlayback, captureShaderPoster, castHlsUrl, createLiveHlsConfig, createPlaybackBeaconClient, createVodHlsConfig, describeAvResync, describePlaybackError, isCaptionLocale, isShaderCurtainKind, liveCaptionsUrl, loadCastSender, loadLiveCaptions, mergeLiveCaptionCues, mergeShaderCurtainConfig, parseShaderGradientUrl, shouldRetryLiveEdge404, toShaderGradientUrl, useFeedExclusivePlayback, useHlsPlayback, usePlaybackStats };
5070
5085
  //# sourceMappingURL=video.js.map
5071
5086
  //# sourceMappingURL=video.js.map