@codenkay/video-nsgplayer-core 3.0.2 → 3.0.4

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>;
@@ -654,6 +657,54 @@ declare class RefreshManager {
654
657
  private renew;
655
658
  }
656
659
 
660
+ /**
661
+ * Local loader types (structurally compatible with hls.js) so the public
662
+ * `.d.ts` does not require a value import of optional peer `hls.js`.
663
+ */
664
+ type HlsLoaderTiming = {
665
+ start: number;
666
+ first: number;
667
+ end: number;
668
+ };
669
+ type LoaderStats = {
670
+ aborted: boolean;
671
+ loaded: number;
672
+ retry: number;
673
+ total: number;
674
+ chunkCount: number;
675
+ bwEstimate: number;
676
+ loading: HlsLoaderTiming;
677
+ parsing: {
678
+ start: number;
679
+ end: number;
680
+ };
681
+ buffering: HlsLoaderTiming;
682
+ };
683
+ type LoaderContext = {
684
+ url: string;
685
+ responseType?: string;
686
+ rangeStart?: number;
687
+ rangeEnd?: number;
688
+ progressData?: boolean;
689
+ [key: string]: unknown;
690
+ };
691
+ type LoaderConfiguration = {
692
+ timeout?: number;
693
+ };
694
+ type LoaderCallbacks<TContext> = {
695
+ onSuccess: (response: {
696
+ url: string;
697
+ data: ArrayBuffer | string;
698
+ code?: number;
699
+ }, stats: LoaderStats, context: TContext, networkDetails: unknown) => void;
700
+ onError: (error: {
701
+ code: number;
702
+ text: string;
703
+ }, context: TContext, networkDetails: unknown, stats: LoaderStats) => void;
704
+ onTimeout?: (...args: unknown[]) => void;
705
+ onAbort?: (...args: unknown[]) => void;
706
+ onProgress?: (...args: unknown[]) => void;
707
+ };
657
708
  type HlsLoaderInstance = {
658
709
  stats: LoaderStats;
659
710
  context: LoaderContext | null;
@@ -663,6 +714,8 @@ type HlsLoaderInstance = {
663
714
  };
664
715
  /** Constructor shape compatible with `Hls.DefaultConfig.loader`. */
665
716
  type HlsLoaderConstructor = new (config: object) => HlsLoaderInstance;
717
+ /** Public alias — pass `hls.js` default export (typed as object at the boundary). */
718
+ type HlsModuleLike = object;
666
719
  /** Max same-origin BFF key attempts before the session circuit opens. */
667
720
  declare const KEY_PROXY_MAX_FAILURES = 2;
668
721
  type AuthParamsLoaderOptions = {
@@ -678,7 +731,7 @@ declare function isEncryptionKeyUrl(rawUrl: string, baseOrigin?: string): boolea
678
731
  * engine loaded. Never statically import `XhrLoader` — that can pull a second
679
732
  * hls.js copy into the app bundle after npm pack/publish and break key loads.
680
733
  */
681
- declare function resolveBuiltinHlsLoader(HlsClass: typeof Hls): HlsLoaderConstructor;
734
+ declare function resolveBuiltinHlsLoader(HlsModule: HlsModuleLike): HlsLoaderConstructor;
682
735
  /**
683
736
  * Rewrites an HLS request URL so signed auth query params are present.
684
737
  */
@@ -686,7 +739,7 @@ declare function rewriteHlsRequestUrl(rawUrl: string, store: AuthParamsStore, op
686
739
  /**
687
740
  * hls.js loader: auth query rewrite + enterprise AES key loading.
688
741
  */
689
- declare function createAuthParamsLoader(HlsClass: typeof Hls, store: AuthParamsStore, options?: AuthParamsLoaderOptions): HlsLoaderConstructor;
742
+ declare function createAuthParamsLoader(HlsModule: HlsModuleLike, store: AuthParamsStore, options?: AuthParamsLoaderOptions): HlsLoaderConstructor;
690
743
 
691
744
  declare function redactValue(key: string, value: unknown, seen?: WeakSet<object>, depth?: number): unknown;
692
745
  /**
@@ -695,4 +748,4 @@ declare function redactValue(key: string, value: unknown, seen?: WeakSet<object>
695
748
  */
696
749
  declare function redactObject(obj: Record<string, unknown>, seen?: WeakSet<object>, depth?: number): Record<string, unknown>;
697
750
 
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 };
751
+ 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>;
@@ -654,6 +657,54 @@ declare class RefreshManager {
654
657
  private renew;
655
658
  }
656
659
 
660
+ /**
661
+ * Local loader types (structurally compatible with hls.js) so the public
662
+ * `.d.ts` does not require a value import of optional peer `hls.js`.
663
+ */
664
+ type HlsLoaderTiming = {
665
+ start: number;
666
+ first: number;
667
+ end: number;
668
+ };
669
+ type LoaderStats = {
670
+ aborted: boolean;
671
+ loaded: number;
672
+ retry: number;
673
+ total: number;
674
+ chunkCount: number;
675
+ bwEstimate: number;
676
+ loading: HlsLoaderTiming;
677
+ parsing: {
678
+ start: number;
679
+ end: number;
680
+ };
681
+ buffering: HlsLoaderTiming;
682
+ };
683
+ type LoaderContext = {
684
+ url: string;
685
+ responseType?: string;
686
+ rangeStart?: number;
687
+ rangeEnd?: number;
688
+ progressData?: boolean;
689
+ [key: string]: unknown;
690
+ };
691
+ type LoaderConfiguration = {
692
+ timeout?: number;
693
+ };
694
+ type LoaderCallbacks<TContext> = {
695
+ onSuccess: (response: {
696
+ url: string;
697
+ data: ArrayBuffer | string;
698
+ code?: number;
699
+ }, stats: LoaderStats, context: TContext, networkDetails: unknown) => void;
700
+ onError: (error: {
701
+ code: number;
702
+ text: string;
703
+ }, context: TContext, networkDetails: unknown, stats: LoaderStats) => void;
704
+ onTimeout?: (...args: unknown[]) => void;
705
+ onAbort?: (...args: unknown[]) => void;
706
+ onProgress?: (...args: unknown[]) => void;
707
+ };
657
708
  type HlsLoaderInstance = {
658
709
  stats: LoaderStats;
659
710
  context: LoaderContext | null;
@@ -663,6 +714,8 @@ type HlsLoaderInstance = {
663
714
  };
664
715
  /** Constructor shape compatible with `Hls.DefaultConfig.loader`. */
665
716
  type HlsLoaderConstructor = new (config: object) => HlsLoaderInstance;
717
+ /** Public alias — pass `hls.js` default export (typed as object at the boundary). */
718
+ type HlsModuleLike = object;
666
719
  /** Max same-origin BFF key attempts before the session circuit opens. */
667
720
  declare const KEY_PROXY_MAX_FAILURES = 2;
668
721
  type AuthParamsLoaderOptions = {
@@ -678,7 +731,7 @@ declare function isEncryptionKeyUrl(rawUrl: string, baseOrigin?: string): boolea
678
731
  * engine loaded. Never statically import `XhrLoader` — that can pull a second
679
732
  * hls.js copy into the app bundle after npm pack/publish and break key loads.
680
733
  */
681
- declare function resolveBuiltinHlsLoader(HlsClass: typeof Hls): HlsLoaderConstructor;
734
+ declare function resolveBuiltinHlsLoader(HlsModule: HlsModuleLike): HlsLoaderConstructor;
682
735
  /**
683
736
  * Rewrites an HLS request URL so signed auth query params are present.
684
737
  */
@@ -686,7 +739,7 @@ declare function rewriteHlsRequestUrl(rawUrl: string, store: AuthParamsStore, op
686
739
  /**
687
740
  * hls.js loader: auth query rewrite + enterprise AES key loading.
688
741
  */
689
- declare function createAuthParamsLoader(HlsClass: typeof Hls, store: AuthParamsStore, options?: AuthParamsLoaderOptions): HlsLoaderConstructor;
742
+ declare function createAuthParamsLoader(HlsModule: HlsModuleLike, store: AuthParamsStore, options?: AuthParamsLoaderOptions): HlsLoaderConstructor;
690
743
 
691
744
  declare function redactValue(key: string, value: unknown, seen?: WeakSet<object>, depth?: number): unknown;
692
745
  /**
@@ -695,4 +748,4 @@ declare function redactValue(key: string, value: unknown, seen?: WeakSet<object>
695
748
  */
696
749
  declare function redactObject(obj: Record<string, unknown>, seen?: WeakSet<object>, depth?: number): Record<string, unknown>;
697
750
 
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 };
751
+ 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.js CHANGED
@@ -146,7 +146,7 @@ var AuthManager = class {
146
146
 
147
147
  // src/config/defaults.ts
148
148
  var PLAYBACK_RATES = [0.5, 0.75, 1, 1.25, 1.5, 2];
149
- var PACKAGE_VERSION = "3.0.2";
149
+ var PACKAGE_VERSION = "3.0.3";
150
150
  var DEFAULT_PLAYER_BEHAVIOR = {
151
151
  autoplay: true,
152
152
  startMuted: true,
@@ -170,7 +170,8 @@ var DEFAULT_CONTROLS = {
170
170
  showSkip: true,
171
171
  showLive: true,
172
172
  seekCueDurationMs: 720,
173
- keyboardShortcuts: true
173
+ keyboardShortcuts: true,
174
+ persistQualityPreference: false
174
175
  };
175
176
  var DEFAULT_THEME = {
176
177
  playIconPreset: "triangle",
@@ -792,7 +793,8 @@ function rememberBuiltin(HlsClass, loader) {
792
793
  function getStashedBuiltinLoader(loader) {
793
794
  return loader[BUILTIN_LOADER_REF];
794
795
  }
795
- function resolveBuiltinHlsLoader(HlsClass) {
796
+ function resolveBuiltinHlsLoader(HlsModule) {
797
+ const HlsClass = HlsModule;
796
798
  const cached = builtinLoaderByHls.get(HlsClass);
797
799
  if (cached) return cached;
798
800
  const start = HlsClass.DefaultConfig.loader;
@@ -1023,7 +1025,9 @@ async function loadEncryptionKeyEnterprise(context, callbacks, plan, signal, sta
1023
1025
  );
1024
1026
  return "ok";
1025
1027
  }
1026
- const needsBearer = Boolean(plan.accessToken) && (queryResult.status === 401 || queryResult.status === 403);
1028
+ const needsBearer = Boolean(plan.accessToken) && (queryResult.status === 401 || queryResult.status === 403 || // Browser-direct: opaque CORS/network on unsigned GET — try Bearer once
1029
+ // Appextech allows ACAO + Authorization (AUTH_MODE=browser, no BFF).
1030
+ queryResult.cors || queryResult.status === 0);
1027
1031
  if (needsBearer && plan.accessToken) {
1028
1032
  const bearerResult = await fetchEncryptionKeyBytes(
1029
1033
  plan.signedKeyUrl,
@@ -1038,7 +1042,7 @@ async function loadEncryptionKeyEnterprise(context, callbacks, plan, signal, sta
1038
1042
  );
1039
1043
  return "ok";
1040
1044
  }
1041
- if (bearerResult.cors) {
1045
+ if (bearerResult.cors || bearerResult.status === 0) {
1042
1046
  return "try_xhr";
1043
1047
  }
1044
1048
  callbacks.onError(
@@ -1066,7 +1070,8 @@ async function loadEncryptionKeyEnterprise(context, callbacks, plan, signal, sta
1066
1070
  );
1067
1071
  return "ok";
1068
1072
  }
1069
- function createAuthParamsLoader(HlsClass, store, options = {}) {
1073
+ function createAuthParamsLoader(HlsModule, store, options = {}) {
1074
+ const HlsClass = HlsModule;
1070
1075
  const BaseLoader = resolveBuiltinHlsLoader(HlsClass);
1071
1076
  rememberBuiltin(HlsClass, BaseLoader);
1072
1077
  const maxProxyFailures = typeof options.keyProxyMaxFailures === "number" && options.keyProxyMaxFailures >= 0 ? options.keyProxyMaxFailures : KEY_PROXY_MAX_FAILURES;
@@ -1276,7 +1281,7 @@ var HlsEngine = class {
1276
1281
  if (!data.fatal) return;
1277
1282
  } else if (!data.fatal) {
1278
1283
  callbacks.onFatalError?.(
1279
- status ? `Encryption key load failed (HTTP ${status}).` : "Encryption key load failed (network/CORS). Ensure signed query params are applied, or use keyProxyUrlBuilder / getKeyAccessToken when the key host requires API Bearer."
1284
+ status ? `Encryption key load failed (HTTP ${status}).` : "Encryption key load failed (network/CORS). For browser-direct mode the key host must allow CORS (and Authorization if Bearer is required). Otherwise use keyProxyUrlBuilder (same-origin BFF) when the server IP can reach Appextech."
1280
1285
  );
1281
1286
  return;
1282
1287
  }