@f8team/reel-core 1.0.4 → 1.1.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/index.d.cts CHANGED
@@ -132,12 +132,12 @@ interface ThumbnailsDescriptor {
132
132
  /**
133
133
  * The kind of source. `auto` lets the registry pick.
134
134
  *
135
- * - `hls` — HLS m3u8 manifest, dispatched to `hls.js` (or native on Safari).
136
- * - `mp4` — Progressive MP4/WebM, dispatched to the native engine.
137
- * - `youtube` — YouTube IFrame API.
138
- * - `dash` — MPEG-DASH (reserved for a future dash provider).
139
- * - `native` — Force the native engine even if the URL looks like HLS (G4 Safari escape).
140
- * - `auto` — Detect from the URL via `looksLikeHls` / `detectSourceType`.
135
+ * - `hls` - HLS m3u8 manifest, dispatched to `hls.js` (or native on Safari).
136
+ * - `mp4` - Progressive MP4/WebM, dispatched to the native engine.
137
+ * - `youtube` - YouTube IFrame API.
138
+ * - `dash` - MPEG-DASH (reserved for a future dash provider).
139
+ * - `native` - Force the native engine even if the URL looks like HLS (G4 Safari escape).
140
+ * - `auto` - Detect from the URL via `looksLikeHls` / `detectSourceType`.
141
141
  */
142
142
  type SourceType = "auto" | "hls" | "mp4" | "youtube" | "dash" | "native";
143
143
  /**
@@ -154,8 +154,8 @@ interface SourceDescriptor {
154
154
  /**
155
155
  * Cookie / credentials policy for HLS XHRs.
156
156
  *
157
- * - `boolean` — sent for every request.
158
- * - `(url) => boolean` — predicate (e.g. allowlist `https://api-gateway*`, see G7, G13).
157
+ * - `boolean` - sent for every request.
158
+ * - `(url) => boolean` - predicate scoped to a trusted API origin/path (see G7, G13).
159
159
  */
160
160
  withCredentials?: boolean | ((url: string) => boolean);
161
161
  /** Subtitle tracks to attach (G1, G15). */
@@ -222,9 +222,9 @@ interface SourceProvider {
222
222
  /**
223
223
  * Decide whether this provider can handle the given source.
224
224
  *
225
- * - `true` — definite match.
226
- * - `"maybe"` — handle if no `true` match exists (used by the native fallback).
227
- * - `false` — skip.
225
+ * - `true` - definite match.
226
+ * - `"maybe"` - handle if no `true` match exists (used by the native fallback).
227
+ * - `false` - skip.
228
228
  */
229
229
  canHandle(source: SourceDescriptor): boolean | "maybe";
230
230
  /** Construct a fresh loader. Called once per source attach. */
@@ -469,6 +469,13 @@ interface Player {
469
469
  dispose(): void;
470
470
  }
471
471
 
472
+ /** Synchronous source normalization hook applied before provider resolution. */
473
+ type SourceTransform = (source: SourceDescriptor) => SourceDescriptor;
474
+ /** Media element and container owned by one player attachment. */
475
+ interface PluginMediaAttachment {
476
+ video: HTMLVideoElement;
477
+ container: Element;
478
+ }
472
479
  /**
473
480
  * Command registry shared between the player and plugins. Commands are the
474
481
  * extension point for keyboard handlers, plugin contributions, and UI buttons.
@@ -505,6 +512,22 @@ interface PluginHost {
505
512
  };
506
513
  /** Shared command registry. Plugins MUST namespace their commands. */
507
514
  commands: CommandRegistry;
515
+ /**
516
+ * Register a synchronous source transform. Core applies transforms before
517
+ * the source is stored or passed to a provider, including the initial
518
+ * source supplied in `PlayerOptions`.
519
+ *
520
+ * Optional for compatibility with custom test hosts built against earlier
521
+ * versions of the contract.
522
+ */
523
+ sources?: {
524
+ transform(transform: SourceTransform): () => void;
525
+ };
526
+ /** Player-scoped media ownership and attach/detach lifecycle. */
527
+ media?: {
528
+ get(): PluginMediaAttachment | null;
529
+ subscribe(listener: (attachment: PluginMediaAttachment | null) => void): () => void;
530
+ };
508
531
  /** Read-only state. */
509
532
  store: ReadableStore<PlayerState>;
510
533
  /** Emit a custom plugin event. Use the `${plugin}:${verb}` namespace. */
@@ -775,6 +798,33 @@ interface FocusTrap {
775
798
  */
776
799
  declare function createFocusTrap(container: HTMLElement): FocusTrap;
777
800
 
801
+ /**
802
+ * Focus helpers for the auto-hiding controls chrome.
803
+ *
804
+ * The themes keep the controls bar visible while the player matches
805
+ * `:focus-within`, so keyboard users never lose the control they are on.
806
+ * A pointer click focuses that control too, which used to latch the chrome
807
+ * open forever - most visibly after tapping the fullscreen button, the only
808
+ * way into fullscreen. `shouldKeepControlsVisible` tells the auto-hide timer
809
+ * which of the two it is looking at, and `blurFocusInside` releases the
810
+ * pointer-induced focus so `:focus-within` stops matching.
811
+ */
812
+ /**
813
+ * Clears focus from any focused descendant of `container`.
814
+ *
815
+ * Used on pointer leave of the `[data-reel]` wrapper and when the auto-hide
816
+ * timer fires, so `:focus-within` does not keep the controls bar visible
817
+ * after a mouse click or tap on a control.
818
+ */
819
+ declare function blurFocusInside(container: Element): void;
820
+ /**
821
+ * `true` when the controls must stay on screen even though the idle timer
822
+ * expired: an open menu, or a control the user reached with the keyboard.
823
+ *
824
+ * Pointer focus deliberately returns `false` - a tap must not pin the chrome.
825
+ */
826
+ declare function shouldKeepControlsVisible(container: Element): boolean;
827
+
778
828
  /**
779
829
  * Time helpers shared by the seek bar, transcript markers (G8), and the
780
830
  * keyboard / commands layer.
@@ -810,9 +860,13 @@ declare function toSeconds(input: number | string): number;
810
860
 
811
861
  /**
812
862
  * URL helpers used by the source registry to dispatch a source descriptor to
813
- * the right provider. Pure string predicates — no DOM, no I/O.
863
+ * the right provider. Pure string predicates - no DOM, no I/O.
814
864
  */
815
865
 
866
+ /** Compare the descriptor fields that affect provider loading or media UI. */
867
+ declare function areSourceDescriptorsEquivalent(previous: SourceDescriptor | null, next: SourceDescriptor | null): boolean;
868
+ /** Whether a media/resource URL is safe to hand to browser media APIs. */
869
+ declare function isSafeMediaUrl(input: string | undefined | null): boolean;
816
870
  /**
817
871
  * Heuristic for HLS m3u8 URLs.
818
872
  *
@@ -843,4 +897,4 @@ declare function looksLikeProgressive(input: string | undefined | null): boolean
843
897
  */
844
898
  declare function detectSourceType(source: SourceDescriptor): SourceType;
845
899
 
846
- export { type AutoplayMode, type BufferedRange, type CommandRegistry, DEFAULT_TOKENS, type Disposer, type KeyboardScope, type MutableStore, type Player, type PlayerError, type PlayerErrorCode, type PlayerEvents, type PlayerHooks, type PlayerOptions, type PlayerState, type PlayerStatus, type PluginHost, type PluginInstance, type QualityLevel, type ReadableStore, type SourceDescriptor, type SourceLoader, type SourceProvider, type SourceType, type SubtitleTrack, THEME_PRESETS, TOKEN_TO_CSS_VAR, type ThemeName, type ThemeTokens, type ThumbnailsDescriptor, type UnauthorizedEvent, announce, applyTheme, createFocusTrap, createPlayer, definePlugin, detectSourceType, formatTime, looksLikeHls, looksLikeProgressive, looksLikeYouTube, parseTime, resolveTokens, toSeconds };
900
+ export { type AutoplayMode, type BufferedRange, type CommandRegistry, DEFAULT_TOKENS, type Disposer, type KeyboardScope, type MutableStore, type Player, type PlayerError, type PlayerErrorCode, type PlayerEvents, type PlayerHooks, type PlayerOptions, type PlayerState, type PlayerStatus, type PluginHost, type PluginInstance, type PluginMediaAttachment, type QualityLevel, type ReadableStore, type SourceDescriptor, type SourceLoader, type SourceProvider, type SourceTransform, type SourceType, type SubtitleTrack, THEME_PRESETS, TOKEN_TO_CSS_VAR, type ThemeName, type ThemeTokens, type ThumbnailsDescriptor, type UnauthorizedEvent, announce, applyTheme, areSourceDescriptorsEquivalent, blurFocusInside, createFocusTrap, createPlayer, definePlugin, detectSourceType, formatTime, isSafeMediaUrl, looksLikeHls, looksLikeProgressive, looksLikeYouTube, parseTime, resolveTokens, shouldKeepControlsVisible, toSeconds };
package/dist/index.d.ts CHANGED
@@ -132,12 +132,12 @@ interface ThumbnailsDescriptor {
132
132
  /**
133
133
  * The kind of source. `auto` lets the registry pick.
134
134
  *
135
- * - `hls` — HLS m3u8 manifest, dispatched to `hls.js` (or native on Safari).
136
- * - `mp4` — Progressive MP4/WebM, dispatched to the native engine.
137
- * - `youtube` — YouTube IFrame API.
138
- * - `dash` — MPEG-DASH (reserved for a future dash provider).
139
- * - `native` — Force the native engine even if the URL looks like HLS (G4 Safari escape).
140
- * - `auto` — Detect from the URL via `looksLikeHls` / `detectSourceType`.
135
+ * - `hls` - HLS m3u8 manifest, dispatched to `hls.js` (or native on Safari).
136
+ * - `mp4` - Progressive MP4/WebM, dispatched to the native engine.
137
+ * - `youtube` - YouTube IFrame API.
138
+ * - `dash` - MPEG-DASH (reserved for a future dash provider).
139
+ * - `native` - Force the native engine even if the URL looks like HLS (G4 Safari escape).
140
+ * - `auto` - Detect from the URL via `looksLikeHls` / `detectSourceType`.
141
141
  */
142
142
  type SourceType = "auto" | "hls" | "mp4" | "youtube" | "dash" | "native";
143
143
  /**
@@ -154,8 +154,8 @@ interface SourceDescriptor {
154
154
  /**
155
155
  * Cookie / credentials policy for HLS XHRs.
156
156
  *
157
- * - `boolean` — sent for every request.
158
- * - `(url) => boolean` — predicate (e.g. allowlist `https://api-gateway*`, see G7, G13).
157
+ * - `boolean` - sent for every request.
158
+ * - `(url) => boolean` - predicate scoped to a trusted API origin/path (see G7, G13).
159
159
  */
160
160
  withCredentials?: boolean | ((url: string) => boolean);
161
161
  /** Subtitle tracks to attach (G1, G15). */
@@ -222,9 +222,9 @@ interface SourceProvider {
222
222
  /**
223
223
  * Decide whether this provider can handle the given source.
224
224
  *
225
- * - `true` — definite match.
226
- * - `"maybe"` — handle if no `true` match exists (used by the native fallback).
227
- * - `false` — skip.
225
+ * - `true` - definite match.
226
+ * - `"maybe"` - handle if no `true` match exists (used by the native fallback).
227
+ * - `false` - skip.
228
228
  */
229
229
  canHandle(source: SourceDescriptor): boolean | "maybe";
230
230
  /** Construct a fresh loader. Called once per source attach. */
@@ -469,6 +469,13 @@ interface Player {
469
469
  dispose(): void;
470
470
  }
471
471
 
472
+ /** Synchronous source normalization hook applied before provider resolution. */
473
+ type SourceTransform = (source: SourceDescriptor) => SourceDescriptor;
474
+ /** Media element and container owned by one player attachment. */
475
+ interface PluginMediaAttachment {
476
+ video: HTMLVideoElement;
477
+ container: Element;
478
+ }
472
479
  /**
473
480
  * Command registry shared between the player and plugins. Commands are the
474
481
  * extension point for keyboard handlers, plugin contributions, and UI buttons.
@@ -505,6 +512,22 @@ interface PluginHost {
505
512
  };
506
513
  /** Shared command registry. Plugins MUST namespace their commands. */
507
514
  commands: CommandRegistry;
515
+ /**
516
+ * Register a synchronous source transform. Core applies transforms before
517
+ * the source is stored or passed to a provider, including the initial
518
+ * source supplied in `PlayerOptions`.
519
+ *
520
+ * Optional for compatibility with custom test hosts built against earlier
521
+ * versions of the contract.
522
+ */
523
+ sources?: {
524
+ transform(transform: SourceTransform): () => void;
525
+ };
526
+ /** Player-scoped media ownership and attach/detach lifecycle. */
527
+ media?: {
528
+ get(): PluginMediaAttachment | null;
529
+ subscribe(listener: (attachment: PluginMediaAttachment | null) => void): () => void;
530
+ };
508
531
  /** Read-only state. */
509
532
  store: ReadableStore<PlayerState>;
510
533
  /** Emit a custom plugin event. Use the `${plugin}:${verb}` namespace. */
@@ -775,6 +798,33 @@ interface FocusTrap {
775
798
  */
776
799
  declare function createFocusTrap(container: HTMLElement): FocusTrap;
777
800
 
801
+ /**
802
+ * Focus helpers for the auto-hiding controls chrome.
803
+ *
804
+ * The themes keep the controls bar visible while the player matches
805
+ * `:focus-within`, so keyboard users never lose the control they are on.
806
+ * A pointer click focuses that control too, which used to latch the chrome
807
+ * open forever - most visibly after tapping the fullscreen button, the only
808
+ * way into fullscreen. `shouldKeepControlsVisible` tells the auto-hide timer
809
+ * which of the two it is looking at, and `blurFocusInside` releases the
810
+ * pointer-induced focus so `:focus-within` stops matching.
811
+ */
812
+ /**
813
+ * Clears focus from any focused descendant of `container`.
814
+ *
815
+ * Used on pointer leave of the `[data-reel]` wrapper and when the auto-hide
816
+ * timer fires, so `:focus-within` does not keep the controls bar visible
817
+ * after a mouse click or tap on a control.
818
+ */
819
+ declare function blurFocusInside(container: Element): void;
820
+ /**
821
+ * `true` when the controls must stay on screen even though the idle timer
822
+ * expired: an open menu, or a control the user reached with the keyboard.
823
+ *
824
+ * Pointer focus deliberately returns `false` - a tap must not pin the chrome.
825
+ */
826
+ declare function shouldKeepControlsVisible(container: Element): boolean;
827
+
778
828
  /**
779
829
  * Time helpers shared by the seek bar, transcript markers (G8), and the
780
830
  * keyboard / commands layer.
@@ -810,9 +860,13 @@ declare function toSeconds(input: number | string): number;
810
860
 
811
861
  /**
812
862
  * URL helpers used by the source registry to dispatch a source descriptor to
813
- * the right provider. Pure string predicates — no DOM, no I/O.
863
+ * the right provider. Pure string predicates - no DOM, no I/O.
814
864
  */
815
865
 
866
+ /** Compare the descriptor fields that affect provider loading or media UI. */
867
+ declare function areSourceDescriptorsEquivalent(previous: SourceDescriptor | null, next: SourceDescriptor | null): boolean;
868
+ /** Whether a media/resource URL is safe to hand to browser media APIs. */
869
+ declare function isSafeMediaUrl(input: string | undefined | null): boolean;
816
870
  /**
817
871
  * Heuristic for HLS m3u8 URLs.
818
872
  *
@@ -843,4 +897,4 @@ declare function looksLikeProgressive(input: string | undefined | null): boolean
843
897
  */
844
898
  declare function detectSourceType(source: SourceDescriptor): SourceType;
845
899
 
846
- export { type AutoplayMode, type BufferedRange, type CommandRegistry, DEFAULT_TOKENS, type Disposer, type KeyboardScope, type MutableStore, type Player, type PlayerError, type PlayerErrorCode, type PlayerEvents, type PlayerHooks, type PlayerOptions, type PlayerState, type PlayerStatus, type PluginHost, type PluginInstance, type QualityLevel, type ReadableStore, type SourceDescriptor, type SourceLoader, type SourceProvider, type SourceType, type SubtitleTrack, THEME_PRESETS, TOKEN_TO_CSS_VAR, type ThemeName, type ThemeTokens, type ThumbnailsDescriptor, type UnauthorizedEvent, announce, applyTheme, createFocusTrap, createPlayer, definePlugin, detectSourceType, formatTime, looksLikeHls, looksLikeProgressive, looksLikeYouTube, parseTime, resolveTokens, toSeconds };
900
+ export { type AutoplayMode, type BufferedRange, type CommandRegistry, DEFAULT_TOKENS, type Disposer, type KeyboardScope, type MutableStore, type Player, type PlayerError, type PlayerErrorCode, type PlayerEvents, type PlayerHooks, type PlayerOptions, type PlayerState, type PlayerStatus, type PluginHost, type PluginInstance, type PluginMediaAttachment, type QualityLevel, type ReadableStore, type SourceDescriptor, type SourceLoader, type SourceProvider, type SourceTransform, type SourceType, type SubtitleTrack, THEME_PRESETS, TOKEN_TO_CSS_VAR, type ThemeName, type ThemeTokens, type ThumbnailsDescriptor, type UnauthorizedEvent, announce, applyTheme, areSourceDescriptorsEquivalent, blurFocusInside, createFocusTrap, createPlayer, definePlugin, detectSourceType, formatTime, isSafeMediaUrl, looksLikeHls, looksLikeProgressive, looksLikeYouTube, parseTime, resolveTokens, shouldKeepControlsVisible, toSeconds };