@f8team/reel-core 1.0.3 → 1.0.5

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
@@ -58,7 +58,7 @@ interface CreateStoreOptions<_T> {
58
58
  * Golden cases: G13 (unauthorized HLS), every error path in G1..G16.
59
59
  */
60
60
  /** Stable error codes. The string literal IS the public contract. */
61
- type PlayerErrorCode = "source" | "network" | "decode" | "unauthorized" | "unsupported" | "internal";
61
+ type PlayerErrorCode = "source" | "network" | "decode" | "unauthorized" | "unsupported" | "hls-fragment-loop" | "internal";
62
62
  /**
63
63
  * Structured player error. Adapters render the message; plugins can inspect
64
64
  * `code`, `status`, and `retryable` to decide on retry/UI strategy.
@@ -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. */
@@ -639,7 +662,7 @@ interface PlayerOptions {
639
662
  }
640
663
 
641
664
  /**
642
- * `createPlayer(options)` — wires every piece of `@f8team/reel-core` into a
665
+ * `createPlayer(options)` - wires every piece of `@f8team/reel-core` into a
643
666
  * single `Player`. The factory is the one and only public entry point.
644
667
  *
645
668
  * Responsibilities:
@@ -658,7 +681,7 @@ interface PlayerOptions {
658
681
  * unit tests.
659
682
  */
660
683
 
661
- /** @internal — extra knobs surfaced for tests and adapters. */
684
+ /** @internal - extra knobs surfaced for tests and adapters. */
662
685
  interface CreatePlayerInternalOptions {
663
686
  /** Override the microtask scheduler for the store. Tests use this. */
664
687
  storeOptions?: CreateStoreOptions<PlayerState>;
@@ -810,9 +833,13 @@ declare function toSeconds(input: number | string): number;
810
833
 
811
834
  /**
812
835
  * 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.
836
+ * the right provider. Pure string predicates - no DOM, no I/O.
814
837
  */
815
838
 
839
+ /** Compare the descriptor fields that affect provider loading or media UI. */
840
+ declare function areSourceDescriptorsEquivalent(previous: SourceDescriptor | null, next: SourceDescriptor | null): boolean;
841
+ /** Whether a media/resource URL is safe to hand to browser media APIs. */
842
+ declare function isSafeMediaUrl(input: string | undefined | null): boolean;
816
843
  /**
817
844
  * Heuristic for HLS m3u8 URLs.
818
845
  *
@@ -843,4 +870,4 @@ declare function looksLikeProgressive(input: string | undefined | null): boolean
843
870
  */
844
871
  declare function detectSourceType(source: SourceDescriptor): SourceType;
845
872
 
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 };
873
+ 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, createFocusTrap, createPlayer, definePlugin, detectSourceType, formatTime, isSafeMediaUrl, looksLikeHls, looksLikeProgressive, looksLikeYouTube, parseTime, resolveTokens, toSeconds };
package/dist/index.d.ts CHANGED
@@ -58,7 +58,7 @@ interface CreateStoreOptions<_T> {
58
58
  * Golden cases: G13 (unauthorized HLS), every error path in G1..G16.
59
59
  */
60
60
  /** Stable error codes. The string literal IS the public contract. */
61
- type PlayerErrorCode = "source" | "network" | "decode" | "unauthorized" | "unsupported" | "internal";
61
+ type PlayerErrorCode = "source" | "network" | "decode" | "unauthorized" | "unsupported" | "hls-fragment-loop" | "internal";
62
62
  /**
63
63
  * Structured player error. Adapters render the message; plugins can inspect
64
64
  * `code`, `status`, and `retryable` to decide on retry/UI strategy.
@@ -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. */
@@ -639,7 +662,7 @@ interface PlayerOptions {
639
662
  }
640
663
 
641
664
  /**
642
- * `createPlayer(options)` — wires every piece of `@f8team/reel-core` into a
665
+ * `createPlayer(options)` - wires every piece of `@f8team/reel-core` into a
643
666
  * single `Player`. The factory is the one and only public entry point.
644
667
  *
645
668
  * Responsibilities:
@@ -658,7 +681,7 @@ interface PlayerOptions {
658
681
  * unit tests.
659
682
  */
660
683
 
661
- /** @internal — extra knobs surfaced for tests and adapters. */
684
+ /** @internal - extra knobs surfaced for tests and adapters. */
662
685
  interface CreatePlayerInternalOptions {
663
686
  /** Override the microtask scheduler for the store. Tests use this. */
664
687
  storeOptions?: CreateStoreOptions<PlayerState>;
@@ -810,9 +833,13 @@ declare function toSeconds(input: number | string): number;
810
833
 
811
834
  /**
812
835
  * 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.
836
+ * the right provider. Pure string predicates - no DOM, no I/O.
814
837
  */
815
838
 
839
+ /** Compare the descriptor fields that affect provider loading or media UI. */
840
+ declare function areSourceDescriptorsEquivalent(previous: SourceDescriptor | null, next: SourceDescriptor | null): boolean;
841
+ /** Whether a media/resource URL is safe to hand to browser media APIs. */
842
+ declare function isSafeMediaUrl(input: string | undefined | null): boolean;
816
843
  /**
817
844
  * Heuristic for HLS m3u8 URLs.
818
845
  *
@@ -843,4 +870,4 @@ declare function looksLikeProgressive(input: string | undefined | null): boolean
843
870
  */
844
871
  declare function detectSourceType(source: SourceDescriptor): SourceType;
845
872
 
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 };
873
+ 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, createFocusTrap, createPlayer, definePlugin, detectSourceType, formatTime, isSafeMediaUrl, looksLikeHls, looksLikeProgressive, looksLikeYouTube, parseTime, resolveTokens, toSeconds };