@codenkay/video-nsgplayer-core 3.0.2 → 4.0.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
@@ -1,5 +1,3 @@
1
- import Hls, { LoaderStats, LoaderContext, LoaderConfiguration, LoaderCallbacks } from 'hls.js';
2
-
3
1
  /** Player lifecycle states. */
4
2
  type PlayerState = "idle" | "loading" | "ready" | "playing" | "paused" | "buffering" | "renewing" | "ended" | "error" | "destroyed";
5
3
  type HlsSupportMode = "hls.js" | "native" | "unsupported";
@@ -89,6 +87,11 @@ type ControlsConfig = {
89
87
  showLive?: boolean;
90
88
  seekCueDurationMs?: number;
91
89
  keyboardShortcuts?: boolean;
90
+ /**
91
+ * When true, UI chrome persists the last quality choice (by height) in
92
+ * localStorage and restores it for later sessions.
93
+ */
94
+ persistQualityPreference?: boolean;
92
95
  };
93
96
  type ThemeConfig = {
94
97
  playIconPreset?: PlayIconPreset;
@@ -286,7 +289,7 @@ type PlayerEventMap = {
286
289
  };
287
290
 
288
291
  declare const PLAYBACK_RATES: readonly [0.5, 0.75, 1, 1.25, 1.5, 2];
289
- declare const PACKAGE_VERSION = "3.0.2";
292
+ declare const PACKAGE_VERSION = "3.0.3";
290
293
  declare const DEFAULT_PLAYER_BEHAVIOR: Required<PlayerBehaviorConfig>;
291
294
  declare const DEFAULT_CONTROLS: Required<ControlsConfig>;
292
295
  declare const DEFAULT_THEME: Required<ThemeConfig>;
@@ -449,17 +452,6 @@ type HlsEngineOptions = {
449
452
  logger: Logger;
450
453
  callbacks: HlsEngineCallbacks;
451
454
  };
452
- /**
453
- * Dual-path HLS engine: hls.js when supported, otherwise native Safari HLS.
454
- *
455
- * Signed CDN playback requires auth query params on every HLS request
456
- * (playlists, segments, and AES `enc.key` on CDN hosts).
457
- *
458
- * Optional `streaming.keyProxyUrlBuilder` (same-origin BFF) or
459
- * `streaming.getKeyAccessToken` (Bearer only after signed-query 401/403).
460
- * CDN keys prefer signed query without Authorization (no CORS preflight).
461
- * when query-signed CDN access is insufficient.
462
- */
463
455
  declare class HlsEngine {
464
456
  private readonly options;
465
457
  private hls;
@@ -474,10 +466,17 @@ declare class HlsEngine {
474
466
  private audioTracks;
475
467
  private audioTrackSelection;
476
468
  private nativeTextTrackCleanup;
469
+ private startPositionApplied;
470
+ private autoplayApplied;
477
471
  constructor(options: HlsEngineOptions);
478
472
  start(): Promise<void>;
479
473
  private startWithHlsJs;
480
474
  private handleHlsError;
475
+ /** Pin the next load to the lowest ladder rung after MSE append failures. */
476
+ private lockPlaybackToSafeLevel;
477
+ private clampStartPosition;
478
+ private applyStartPositionOnly;
479
+ private applyAutoplayOnly;
481
480
  private applyStartPositionAndAutoplay;
482
481
  private bindMediaEvents;
483
482
  updateAuthParams(): void;
@@ -654,6 +653,54 @@ declare class RefreshManager {
654
653
  private renew;
655
654
  }
656
655
 
656
+ /**
657
+ * Local loader types (structurally compatible with hls.js) so the public
658
+ * `.d.ts` does not require a value import of optional peer `hls.js`.
659
+ */
660
+ type HlsLoaderTiming = {
661
+ start: number;
662
+ first: number;
663
+ end: number;
664
+ };
665
+ type LoaderStats = {
666
+ aborted: boolean;
667
+ loaded: number;
668
+ retry: number;
669
+ total: number;
670
+ chunkCount: number;
671
+ bwEstimate: number;
672
+ loading: HlsLoaderTiming;
673
+ parsing: {
674
+ start: number;
675
+ end: number;
676
+ };
677
+ buffering: HlsLoaderTiming;
678
+ };
679
+ type LoaderContext = {
680
+ url: string;
681
+ responseType?: string;
682
+ rangeStart?: number;
683
+ rangeEnd?: number;
684
+ progressData?: boolean;
685
+ [key: string]: unknown;
686
+ };
687
+ type LoaderConfiguration = {
688
+ timeout?: number;
689
+ };
690
+ type LoaderCallbacks<TContext> = {
691
+ onSuccess: (response: {
692
+ url: string;
693
+ data: ArrayBuffer | string;
694
+ code?: number;
695
+ }, stats: LoaderStats, context: TContext, networkDetails: unknown) => void;
696
+ onError: (error: {
697
+ code: number;
698
+ text: string;
699
+ }, context: TContext, networkDetails: unknown, stats: LoaderStats) => void;
700
+ onTimeout?: (...args: unknown[]) => void;
701
+ onAbort?: (...args: unknown[]) => void;
702
+ onProgress?: (...args: unknown[]) => void;
703
+ };
657
704
  type HlsLoaderInstance = {
658
705
  stats: LoaderStats;
659
706
  context: LoaderContext | null;
@@ -663,6 +710,8 @@ type HlsLoaderInstance = {
663
710
  };
664
711
  /** Constructor shape compatible with `Hls.DefaultConfig.loader`. */
665
712
  type HlsLoaderConstructor = new (config: object) => HlsLoaderInstance;
713
+ /** Public alias — pass `hls.js` default export (typed as object at the boundary). */
714
+ type HlsModuleLike = object;
666
715
  /** Max same-origin BFF key attempts before the session circuit opens. */
667
716
  declare const KEY_PROXY_MAX_FAILURES = 2;
668
717
  type AuthParamsLoaderOptions = {
@@ -678,7 +727,7 @@ declare function isEncryptionKeyUrl(rawUrl: string, baseOrigin?: string): boolea
678
727
  * engine loaded. Never statically import `XhrLoader` — that can pull a second
679
728
  * hls.js copy into the app bundle after npm pack/publish and break key loads.
680
729
  */
681
- declare function resolveBuiltinHlsLoader(HlsClass: typeof Hls): HlsLoaderConstructor;
730
+ declare function resolveBuiltinHlsLoader(HlsModule: HlsModuleLike): HlsLoaderConstructor;
682
731
  /**
683
732
  * Rewrites an HLS request URL so signed auth query params are present.
684
733
  */
@@ -686,7 +735,7 @@ declare function rewriteHlsRequestUrl(rawUrl: string, store: AuthParamsStore, op
686
735
  /**
687
736
  * hls.js loader: auth query rewrite + enterprise AES key loading.
688
737
  */
689
- declare function createAuthParamsLoader(HlsClass: typeof Hls, store: AuthParamsStore, options?: AuthParamsLoaderOptions): HlsLoaderConstructor;
738
+ declare function createAuthParamsLoader(HlsModule: HlsModuleLike, store: AuthParamsStore, options?: AuthParamsLoaderOptions): HlsLoaderConstructor;
690
739
 
691
740
  declare function redactValue(key: string, value: unknown, seen?: WeakSet<object>, depth?: number): unknown;
692
741
  /**
@@ -695,4 +744,4 @@ declare function redactValue(key: string, value: unknown, seen?: WeakSet<object>
695
744
  */
696
745
  declare function redactObject(obj: Record<string, unknown>, seen?: WeakSet<object>, depth?: number): Record<string, unknown>;
697
746
 
698
- export { type AccessibilityConfig, type AnalyticsConfig, type AuthConfig, AuthManager, AuthParamsStore, type AuthToken, type AuthTokenProviderContext, type BufferedRange, type ControlsConfig, type CreateVideoPlayerOptions, DEFAULT_CONTROLS, DEFAULT_LIVE_EDGE_TOLERANCE_SECONDS, DEFAULT_PLAYER_BEHAVIOR, DEFAULT_PLAYER_CONFIG, DEFAULT_THEME, DEFAULT_WATERMARK, type DebugConfig, EventEmitter, type HlsQualityLevel, type HlsSupportMode, KEY_PROXY_MAX_FAILURES, type LiveMediaSnapshot, type LoggingConfig, PACKAGE_VERSION, PLAYBACK_RATES, type PlayIconPreset, type PlaybackCredentialConfig, type PlaybackRate, type PlaybackSource, type PlaybackSourceContext, PlaybackSourceManager, type PlayerAudioTrack, type PlayerBehaviorConfig, type PlayerConfig, type PlayerDiagnostics, type PlayerError, PlayerErrorCode, type PlayerEventMap, type PlayerSkipSeconds, type PlayerState, type PlayerTextTrack, type PlayerZoomLevel, type QualitySelection, RefreshManager, SECRET_SCAN_MAX_DEPTH, type SeekToLiveResult, type StreamingConfig, type TextTrackSelection, type ThemeConfig, type VideoPlayer, type WatermarkConfig, assertNoSecretsInConfig, createAuthParamsLoader, createPlayerError, createVideoPlayer, getLiveEdgeTime, isAtLiveEdge, isEncryptionKeyUrl, isPlainObject, mergePlayerConfig, redactObject, redactSensitive, redactValue, resolveBuiltinHlsLoader, rewriteHlsRequestUrl, seekToLiveEdge, themeToCssVars };
747
+ export { type AccessibilityConfig, type AnalyticsConfig, type AuthConfig, AuthManager, AuthParamsStore, type AuthToken, type AuthTokenProviderContext, type BufferedRange, type ControlsConfig, type CreateVideoPlayerOptions, DEFAULT_CONTROLS, DEFAULT_LIVE_EDGE_TOLERANCE_SECONDS, DEFAULT_PLAYER_BEHAVIOR, DEFAULT_PLAYER_CONFIG, DEFAULT_THEME, DEFAULT_WATERMARK, type DebugConfig, EventEmitter, type HlsLoaderConstructor, type HlsModuleLike, type HlsQualityLevel, type HlsSupportMode, KEY_PROXY_MAX_FAILURES, type LiveMediaSnapshot, type LoggingConfig, PACKAGE_VERSION, PLAYBACK_RATES, type PlayIconPreset, type PlaybackCredentialConfig, type PlaybackRate, type PlaybackSource, type PlaybackSourceContext, PlaybackSourceManager, type PlayerAudioTrack, type PlayerBehaviorConfig, type PlayerConfig, type PlayerDiagnostics, type PlayerError, PlayerErrorCode, type PlayerEventMap, type PlayerSkipSeconds, type PlayerState, type PlayerTextTrack, type PlayerZoomLevel, type QualitySelection, RefreshManager, SECRET_SCAN_MAX_DEPTH, type SeekToLiveResult, type StreamingConfig, type TextTrackSelection, type ThemeConfig, type VideoPlayer, type WatermarkConfig, assertNoSecretsInConfig, createAuthParamsLoader, createPlayerError, createVideoPlayer, getLiveEdgeTime, isAtLiveEdge, isEncryptionKeyUrl, isPlainObject, mergePlayerConfig, redactObject, redactSensitive, redactValue, resolveBuiltinHlsLoader, rewriteHlsRequestUrl, seekToLiveEdge, themeToCssVars };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,3 @@
1
- import Hls, { LoaderStats, LoaderContext, LoaderConfiguration, LoaderCallbacks } from 'hls.js';
2
-
3
1
  /** Player lifecycle states. */
4
2
  type PlayerState = "idle" | "loading" | "ready" | "playing" | "paused" | "buffering" | "renewing" | "ended" | "error" | "destroyed";
5
3
  type HlsSupportMode = "hls.js" | "native" | "unsupported";
@@ -89,6 +87,11 @@ type ControlsConfig = {
89
87
  showLive?: boolean;
90
88
  seekCueDurationMs?: number;
91
89
  keyboardShortcuts?: boolean;
90
+ /**
91
+ * When true, UI chrome persists the last quality choice (by height) in
92
+ * localStorage and restores it for later sessions.
93
+ */
94
+ persistQualityPreference?: boolean;
92
95
  };
93
96
  type ThemeConfig = {
94
97
  playIconPreset?: PlayIconPreset;
@@ -286,7 +289,7 @@ type PlayerEventMap = {
286
289
  };
287
290
 
288
291
  declare const PLAYBACK_RATES: readonly [0.5, 0.75, 1, 1.25, 1.5, 2];
289
- declare const PACKAGE_VERSION = "3.0.2";
292
+ declare const PACKAGE_VERSION = "3.0.3";
290
293
  declare const DEFAULT_PLAYER_BEHAVIOR: Required<PlayerBehaviorConfig>;
291
294
  declare const DEFAULT_CONTROLS: Required<ControlsConfig>;
292
295
  declare const DEFAULT_THEME: Required<ThemeConfig>;
@@ -449,17 +452,6 @@ type HlsEngineOptions = {
449
452
  logger: Logger;
450
453
  callbacks: HlsEngineCallbacks;
451
454
  };
452
- /**
453
- * Dual-path HLS engine: hls.js when supported, otherwise native Safari HLS.
454
- *
455
- * Signed CDN playback requires auth query params on every HLS request
456
- * (playlists, segments, and AES `enc.key` on CDN hosts).
457
- *
458
- * Optional `streaming.keyProxyUrlBuilder` (same-origin BFF) or
459
- * `streaming.getKeyAccessToken` (Bearer only after signed-query 401/403).
460
- * CDN keys prefer signed query without Authorization (no CORS preflight).
461
- * when query-signed CDN access is insufficient.
462
- */
463
455
  declare class HlsEngine {
464
456
  private readonly options;
465
457
  private hls;
@@ -474,10 +466,17 @@ declare class HlsEngine {
474
466
  private audioTracks;
475
467
  private audioTrackSelection;
476
468
  private nativeTextTrackCleanup;
469
+ private startPositionApplied;
470
+ private autoplayApplied;
477
471
  constructor(options: HlsEngineOptions);
478
472
  start(): Promise<void>;
479
473
  private startWithHlsJs;
480
474
  private handleHlsError;
475
+ /** Pin the next load to the lowest ladder rung after MSE append failures. */
476
+ private lockPlaybackToSafeLevel;
477
+ private clampStartPosition;
478
+ private applyStartPositionOnly;
479
+ private applyAutoplayOnly;
481
480
  private applyStartPositionAndAutoplay;
482
481
  private bindMediaEvents;
483
482
  updateAuthParams(): void;
@@ -654,6 +653,54 @@ declare class RefreshManager {
654
653
  private renew;
655
654
  }
656
655
 
656
+ /**
657
+ * Local loader types (structurally compatible with hls.js) so the public
658
+ * `.d.ts` does not require a value import of optional peer `hls.js`.
659
+ */
660
+ type HlsLoaderTiming = {
661
+ start: number;
662
+ first: number;
663
+ end: number;
664
+ };
665
+ type LoaderStats = {
666
+ aborted: boolean;
667
+ loaded: number;
668
+ retry: number;
669
+ total: number;
670
+ chunkCount: number;
671
+ bwEstimate: number;
672
+ loading: HlsLoaderTiming;
673
+ parsing: {
674
+ start: number;
675
+ end: number;
676
+ };
677
+ buffering: HlsLoaderTiming;
678
+ };
679
+ type LoaderContext = {
680
+ url: string;
681
+ responseType?: string;
682
+ rangeStart?: number;
683
+ rangeEnd?: number;
684
+ progressData?: boolean;
685
+ [key: string]: unknown;
686
+ };
687
+ type LoaderConfiguration = {
688
+ timeout?: number;
689
+ };
690
+ type LoaderCallbacks<TContext> = {
691
+ onSuccess: (response: {
692
+ url: string;
693
+ data: ArrayBuffer | string;
694
+ code?: number;
695
+ }, stats: LoaderStats, context: TContext, networkDetails: unknown) => void;
696
+ onError: (error: {
697
+ code: number;
698
+ text: string;
699
+ }, context: TContext, networkDetails: unknown, stats: LoaderStats) => void;
700
+ onTimeout?: (...args: unknown[]) => void;
701
+ onAbort?: (...args: unknown[]) => void;
702
+ onProgress?: (...args: unknown[]) => void;
703
+ };
657
704
  type HlsLoaderInstance = {
658
705
  stats: LoaderStats;
659
706
  context: LoaderContext | null;
@@ -663,6 +710,8 @@ type HlsLoaderInstance = {
663
710
  };
664
711
  /** Constructor shape compatible with `Hls.DefaultConfig.loader`. */
665
712
  type HlsLoaderConstructor = new (config: object) => HlsLoaderInstance;
713
+ /** Public alias — pass `hls.js` default export (typed as object at the boundary). */
714
+ type HlsModuleLike = object;
666
715
  /** Max same-origin BFF key attempts before the session circuit opens. */
667
716
  declare const KEY_PROXY_MAX_FAILURES = 2;
668
717
  type AuthParamsLoaderOptions = {
@@ -678,7 +727,7 @@ declare function isEncryptionKeyUrl(rawUrl: string, baseOrigin?: string): boolea
678
727
  * engine loaded. Never statically import `XhrLoader` — that can pull a second
679
728
  * hls.js copy into the app bundle after npm pack/publish and break key loads.
680
729
  */
681
- declare function resolveBuiltinHlsLoader(HlsClass: typeof Hls): HlsLoaderConstructor;
730
+ declare function resolveBuiltinHlsLoader(HlsModule: HlsModuleLike): HlsLoaderConstructor;
682
731
  /**
683
732
  * Rewrites an HLS request URL so signed auth query params are present.
684
733
  */
@@ -686,7 +735,7 @@ declare function rewriteHlsRequestUrl(rawUrl: string, store: AuthParamsStore, op
686
735
  /**
687
736
  * hls.js loader: auth query rewrite + enterprise AES key loading.
688
737
  */
689
- declare function createAuthParamsLoader(HlsClass: typeof Hls, store: AuthParamsStore, options?: AuthParamsLoaderOptions): HlsLoaderConstructor;
738
+ declare function createAuthParamsLoader(HlsModule: HlsModuleLike, store: AuthParamsStore, options?: AuthParamsLoaderOptions): HlsLoaderConstructor;
690
739
 
691
740
  declare function redactValue(key: string, value: unknown, seen?: WeakSet<object>, depth?: number): unknown;
692
741
  /**
@@ -695,4 +744,4 @@ declare function redactValue(key: string, value: unknown, seen?: WeakSet<object>
695
744
  */
696
745
  declare function redactObject(obj: Record<string, unknown>, seen?: WeakSet<object>, depth?: number): Record<string, unknown>;
697
746
 
698
- export { type AccessibilityConfig, type AnalyticsConfig, type AuthConfig, AuthManager, AuthParamsStore, type AuthToken, type AuthTokenProviderContext, type BufferedRange, type ControlsConfig, type CreateVideoPlayerOptions, DEFAULT_CONTROLS, DEFAULT_LIVE_EDGE_TOLERANCE_SECONDS, DEFAULT_PLAYER_BEHAVIOR, DEFAULT_PLAYER_CONFIG, DEFAULT_THEME, DEFAULT_WATERMARK, type DebugConfig, EventEmitter, type HlsQualityLevel, type HlsSupportMode, KEY_PROXY_MAX_FAILURES, type LiveMediaSnapshot, type LoggingConfig, PACKAGE_VERSION, PLAYBACK_RATES, type PlayIconPreset, type PlaybackCredentialConfig, type PlaybackRate, type PlaybackSource, type PlaybackSourceContext, PlaybackSourceManager, type PlayerAudioTrack, type PlayerBehaviorConfig, type PlayerConfig, type PlayerDiagnostics, type PlayerError, PlayerErrorCode, type PlayerEventMap, type PlayerSkipSeconds, type PlayerState, type PlayerTextTrack, type PlayerZoomLevel, type QualitySelection, RefreshManager, SECRET_SCAN_MAX_DEPTH, type SeekToLiveResult, type StreamingConfig, type TextTrackSelection, type ThemeConfig, type VideoPlayer, type WatermarkConfig, assertNoSecretsInConfig, createAuthParamsLoader, createPlayerError, createVideoPlayer, getLiveEdgeTime, isAtLiveEdge, isEncryptionKeyUrl, isPlainObject, mergePlayerConfig, redactObject, redactSensitive, redactValue, resolveBuiltinHlsLoader, rewriteHlsRequestUrl, seekToLiveEdge, themeToCssVars };
747
+ export { type AccessibilityConfig, type AnalyticsConfig, type AuthConfig, AuthManager, AuthParamsStore, type AuthToken, type AuthTokenProviderContext, type BufferedRange, type ControlsConfig, type CreateVideoPlayerOptions, DEFAULT_CONTROLS, DEFAULT_LIVE_EDGE_TOLERANCE_SECONDS, DEFAULT_PLAYER_BEHAVIOR, DEFAULT_PLAYER_CONFIG, DEFAULT_THEME, DEFAULT_WATERMARK, type DebugConfig, EventEmitter, type HlsLoaderConstructor, type HlsModuleLike, type HlsQualityLevel, type HlsSupportMode, KEY_PROXY_MAX_FAILURES, type LiveMediaSnapshot, type LoggingConfig, PACKAGE_VERSION, PLAYBACK_RATES, type PlayIconPreset, type PlaybackCredentialConfig, type PlaybackRate, type PlaybackSource, type PlaybackSourceContext, PlaybackSourceManager, type PlayerAudioTrack, type PlayerBehaviorConfig, type PlayerConfig, type PlayerDiagnostics, type PlayerError, PlayerErrorCode, type PlayerEventMap, type PlayerSkipSeconds, type PlayerState, type PlayerTextTrack, type PlayerZoomLevel, type QualitySelection, RefreshManager, SECRET_SCAN_MAX_DEPTH, type SeekToLiveResult, type StreamingConfig, type TextTrackSelection, type ThemeConfig, type VideoPlayer, type WatermarkConfig, assertNoSecretsInConfig, createAuthParamsLoader, createPlayerError, createVideoPlayer, getLiveEdgeTime, isAtLiveEdge, isEncryptionKeyUrl, isPlainObject, mergePlayerConfig, redactObject, redactSensitive, redactValue, resolveBuiltinHlsLoader, rewriteHlsRequestUrl, seekToLiveEdge, themeToCssVars };