@flowplayer/player 3.15.0-rc.8 → 3.15.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.
Files changed (51) hide show
  1. package/core.js +1 -1
  2. package/default.js +1 -1
  3. package/embed.js +2 -2
  4. package/index.d.ts +16 -10
  5. package/package.json +1 -1
  6. package/plugins/ads.d.ts +19 -13
  7. package/plugins/ads.js +1 -1
  8. package/plugins/airplay.d.ts +19 -13
  9. package/plugins/analytics.d.ts +16 -10
  10. package/plugins/analytics.js +1 -1
  11. package/plugins/asel.d.ts +16 -10
  12. package/plugins/audio.d.ts +16 -10
  13. package/plugins/chapters.d.ts +16 -10
  14. package/plugins/chromecast.d.ts +16 -10
  15. package/plugins/comscore.d.ts +16 -10
  16. package/plugins/consent.d.ts +16 -10
  17. package/plugins/context-menu.d.ts +17 -11
  18. package/plugins/cuepoints.d.ts +17 -11
  19. package/plugins/dash.d.ts +23 -15
  20. package/plugins/drm.d.ts +16 -10
  21. package/plugins/endscreen.d.ts +16 -10
  22. package/plugins/fas.d.ts +16 -10
  23. package/plugins/float-on-scroll.d.ts +16 -10
  24. package/plugins/ga4.d.ts +16 -10
  25. package/plugins/gemius.d.ts +16 -10
  26. package/plugins/google-analytics.d.ts +16 -10
  27. package/plugins/health.d.ts +22 -13
  28. package/plugins/health.js +1 -1
  29. package/plugins/hls.d.ts +19 -13
  30. package/plugins/id3.d.ts +16 -10
  31. package/plugins/iframe.d.ts +16 -10
  32. package/plugins/keyboard.d.ts +16 -10
  33. package/plugins/media-session.d.ts +16 -10
  34. package/plugins/message.d.ts +16 -10
  35. package/plugins/ovp.d.ts +31 -24
  36. package/plugins/ovp.js +1 -1
  37. package/plugins/playlist.d.ts +16 -10
  38. package/plugins/preview.d.ts +16 -10
  39. package/plugins/qsel.d.ts +16 -10
  40. package/plugins/qul.d.ts +16 -10
  41. package/plugins/rts.d.ts +16 -10
  42. package/plugins/share.d.ts +16 -10
  43. package/plugins/speed.d.ts +16 -10
  44. package/plugins/ssai.d.ts +16 -10
  45. package/plugins/ssai.js +1 -1
  46. package/plugins/subtitles.d.ts +19 -13
  47. package/plugins/thumbnails.d.ts +16 -10
  48. package/plugins/tizen.d.ts +16 -10
  49. package/plugins/vtsel.d.ts +16 -10
  50. package/plugins/webos.d.ts +16 -10
  51. package/util/loader.d.ts +18 -12
@@ -315,6 +315,8 @@ declare const /**
315
315
  */
316
316
  ENDED_2 = "ended";
317
317
 
318
+ declare type EnsureOnAttached<P extends Function, T extends Player> = ExtractPureAPI<T> extends _AttachedEventCheck ? P : "Loaders must implement on('<pluginname>:attached') event";
319
+
318
320
  /**
319
321
  * @public
320
322
  */
@@ -397,6 +399,8 @@ declare namespace events {
397
399
  }
398
400
  }
399
401
 
402
+ declare type ExtractPureAPI<T> = T extends PlayerWith<infer PureAPI> ? PureAPI : never;
403
+
400
404
  /**
401
405
  * @public
402
406
  */
@@ -492,19 +496,19 @@ declare interface FlowplayerUMDBase {
492
496
  /**
493
497
  * @public
494
498
  */
495
- declare interface FlowplayerUMDWithPlugins<ConfigWithPlugins extends Config = Config, PluginPlayerAPIExtension extends Player = Player> extends FlowplayerUMDBase {
499
+ declare interface FlowplayerUMDWithPlugins<ConfigWithPlugins extends Config = Config, PluginPlayer extends Player = Player> extends FlowplayerUMDBase {
496
500
  /**
497
501
  * Configure flowplayer, it's attached plugins and display flowplayer it in the UI
498
502
  * @param selector - query selector of the HTML element where player will render
499
503
  * @param config - Configuration of the flowplayer and the attached plugins
500
504
  */
501
- (selector: string, config?: ConfigWithPlugins): PluginPlayerAPIExtension;
505
+ (selector: string, config?: ConfigWithPlugins): PluginPlayer;
502
506
  /**
503
507
  * Configure flowplayer, it's attached plugins and display flowplayer it in the UI
504
508
  * @param element - HTML element where player will render
505
509
  * @param config - Configuration of the flowplayer and the attached plugins
506
510
  */
507
- (element: HTMLElement, config?: ConfigWithPlugins): PluginPlayerAPIExtension;
511
+ (element: HTMLElement, config?: ConfigWithPlugins): PluginPlayer;
508
512
  }
509
513
 
510
514
  /**
@@ -656,10 +660,11 @@ declare const LOADED = "is-loaded";
656
660
 
657
661
  /**
658
662
  * @public A plugin that supports loading new media formats. Use 'class MyPlugin implements Loader\<...\>' when writing your custom Loader
659
- * @typeParam PluginPlayerAPIExtension - additional Player API that will be implemented by the loader. Loader at least must implement on(\<loader-name\>:attached, ...) event handler
663
+ * @typeParam PluginPlayer- Player API that will be implemented by the loader. Loader at least must implement on(\<loader-name\>:attached, ...) event handler
660
664
  */
661
- declare interface Loader<PluginOwnConfig extends KeyValue, PluginPlayerAPIExtension extends _AttachedEventCheck> extends Plugin_2<PluginOwnConfig, PlayerWith<PluginPlayerAPIExtension>> {
662
- onload(config: ConfigWith<PluginOwnConfig>, root: PlayerRoot, video: PlayerWith<PluginPlayerAPIExtension>, src?: SourceObj): void;
665
+ declare interface Loader<PluginOwnConfig extends KeyValue, // FIXME extends Config
666
+ PluginPlayer extends PlayerWith<_AttachedEventCheck>> extends Plugin_2<PluginOwnConfig, PluginPlayer> {
667
+ onload: EnsureOnAttached<(config: ConfigWith<PluginOwnConfig>, root: PlayerRoot, video: PlayerWith<PluginPlayer>, src: SourceObj) => void, PluginPlayer>;
663
668
  wants<S = SourceObj>(srcString: SourceStr, srcObj: S, config: ConfigWith<PluginOwnConfig>): boolean;
664
669
  wants<S = KeyValue>(srcString: SourceStr, srcObj: SourceWith<S>, config: ConfigWith<PluginOwnConfig>): boolean;
665
670
  }
@@ -1056,6 +1061,7 @@ declare type PlayerNativeEventsOverloads = {
1056
1061
 
1057
1062
  /**
1058
1063
  * @public
1064
+ * The root element of the video player. This is the immediate parent element of the video tag.
1059
1065
  */
1060
1066
  declare type PlayerRoot = HTMLElement & {
1061
1067
  /* Excluded from this release type: prevWidth */
@@ -1091,11 +1097,11 @@ PLAYING_2 = "playing";
1091
1097
  /**
1092
1098
  * @public
1093
1099
  */
1094
- declare interface Plugin_2<PluginConfig extends Config = Config, PluginPlayerAPI extends Player = Player> {
1100
+ declare interface Plugin_2<PluginConfig extends Config = Config, PluginPlayer extends Player = Player> {
1095
1101
  /**
1096
1102
  * a plugin must always implement the init method so a player instance knows how to initialize it
1097
1103
  */
1098
- init(config: PluginConfig, container: PlayerRoot, player: PluginPlayerAPI): void;
1104
+ init(config: PluginConfig, container: PlayerRoot, player: PluginPlayer): void;
1099
1105
  }
1100
1106
 
1101
1107
  /* Excluded from this release type: PLUGIN_REGISTERED */
@@ -1103,8 +1109,8 @@ declare interface Plugin_2<PluginConfig extends Config = Config, PluginPlayerAPI
1103
1109
  /**
1104
1110
  * @public
1105
1111
  */
1106
- declare interface PluginCtor<PluginConfig extends Config = Config, PluginPlayerAPI extends Player = Player> {
1107
- new (umd: FlowplayerUMD, player: PluginPlayerAPI): Plugin_2<PluginConfig, PluginPlayerAPI>;
1112
+ declare interface PluginCtor<PluginConfig extends Config = Config, PluginPlayer extends Player = Player> {
1113
+ new (umd: FlowplayerUMD, player: PluginPlayer): Plugin_2<PluginConfig, PluginPlayer>;
1108
1114
  }
1109
1115
 
1110
1116
  /* Excluded from this release type: PluginRegisteredEventDetail */
package/plugins/ga4.d.ts CHANGED
@@ -315,6 +315,8 @@ declare const /**
315
315
  */
316
316
  ENDED_2 = "ended";
317
317
 
318
+ declare type EnsureOnAttached<P extends Function, T extends Player> = ExtractPureAPI<T> extends _AttachedEventCheck ? P : "Loaders must implement on('<pluginname>:attached') event";
319
+
318
320
  /**
319
321
  * @public
320
322
  */
@@ -397,6 +399,8 @@ declare namespace events {
397
399
  }
398
400
  }
399
401
 
402
+ declare type ExtractPureAPI<T> = T extends PlayerWith<infer PureAPI> ? PureAPI : never;
403
+
400
404
  /**
401
405
  * @public
402
406
  */
@@ -474,19 +478,19 @@ declare interface FlowplayerUMDBase {
474
478
  /**
475
479
  * @public
476
480
  */
477
- declare interface FlowplayerUMDWithPlugins<ConfigWithPlugins extends Config = Config, PluginPlayerAPIExtension extends Player = Player> extends FlowplayerUMDBase {
481
+ declare interface FlowplayerUMDWithPlugins<ConfigWithPlugins extends Config = Config, PluginPlayer extends Player = Player> extends FlowplayerUMDBase {
478
482
  /**
479
483
  * Configure flowplayer, it's attached plugins and display flowplayer it in the UI
480
484
  * @param selector - query selector of the HTML element where player will render
481
485
  * @param config - Configuration of the flowplayer and the attached plugins
482
486
  */
483
- (selector: string, config?: ConfigWithPlugins): PluginPlayerAPIExtension;
487
+ (selector: string, config?: ConfigWithPlugins): PluginPlayer;
484
488
  /**
485
489
  * Configure flowplayer, it's attached plugins and display flowplayer it in the UI
486
490
  * @param element - HTML element where player will render
487
491
  * @param config - Configuration of the flowplayer and the attached plugins
488
492
  */
489
- (element: HTMLElement, config?: ConfigWithPlugins): PluginPlayerAPIExtension;
493
+ (element: HTMLElement, config?: ConfigWithPlugins): PluginPlayer;
490
494
  }
491
495
 
492
496
  /**
@@ -644,10 +648,11 @@ declare const LOADED = "is-loaded";
644
648
 
645
649
  /**
646
650
  * @public A plugin that supports loading new media formats. Use 'class MyPlugin implements Loader\<...\>' when writing your custom Loader
647
- * @typeParam PluginPlayerAPIExtension - additional Player API that will be implemented by the loader. Loader at least must implement on(\<loader-name\>:attached, ...) event handler
651
+ * @typeParam PluginPlayer- Player API that will be implemented by the loader. Loader at least must implement on(\<loader-name\>:attached, ...) event handler
648
652
  */
649
- declare interface Loader<PluginOwnConfig extends KeyValue, PluginPlayerAPIExtension extends _AttachedEventCheck> extends Plugin_2<PluginOwnConfig, PlayerWith<PluginPlayerAPIExtension>> {
650
- onload(config: ConfigWith<PluginOwnConfig>, root: PlayerRoot, video: PlayerWith<PluginPlayerAPIExtension>, src?: SourceObj): void;
653
+ declare interface Loader<PluginOwnConfig extends KeyValue, // FIXME extends Config
654
+ PluginPlayer extends PlayerWith<_AttachedEventCheck>> extends Plugin_2<PluginOwnConfig, PluginPlayer> {
655
+ onload: EnsureOnAttached<(config: ConfigWith<PluginOwnConfig>, root: PlayerRoot, video: PlayerWith<PluginPlayer>, src: SourceObj) => void, PluginPlayer>;
651
656
  wants<S = SourceObj>(srcString: SourceStr, srcObj: S, config: ConfigWith<PluginOwnConfig>): boolean;
652
657
  wants<S = KeyValue>(srcString: SourceStr, srcObj: SourceWith<S>, config: ConfigWith<PluginOwnConfig>): boolean;
653
658
  }
@@ -1044,6 +1049,7 @@ declare type PlayerNativeEventsOverloads = {
1044
1049
 
1045
1050
  /**
1046
1051
  * @public
1052
+ * The root element of the video player. This is the immediate parent element of the video tag.
1047
1053
  */
1048
1054
  declare type PlayerRoot = HTMLElement & {
1049
1055
  /* Excluded from this release type: prevWidth */
@@ -1079,11 +1085,11 @@ PLAYING_2 = "playing";
1079
1085
  /**
1080
1086
  * @public
1081
1087
  */
1082
- declare interface Plugin_2<PluginConfig extends Config = Config, PluginPlayerAPI extends Player = Player> {
1088
+ declare interface Plugin_2<PluginConfig extends Config = Config, PluginPlayer extends Player = Player> {
1083
1089
  /**
1084
1090
  * a plugin must always implement the init method so a player instance knows how to initialize it
1085
1091
  */
1086
- init(config: PluginConfig, container: PlayerRoot, player: PluginPlayerAPI): void;
1092
+ init(config: PluginConfig, container: PlayerRoot, player: PluginPlayer): void;
1087
1093
  }
1088
1094
 
1089
1095
  /* Excluded from this release type: PLUGIN_REGISTERED */
@@ -1091,8 +1097,8 @@ declare interface Plugin_2<PluginConfig extends Config = Config, PluginPlayerAPI
1091
1097
  /**
1092
1098
  * @public
1093
1099
  */
1094
- declare interface PluginCtor<PluginConfig extends Config = Config, PluginPlayerAPI extends Player = Player> {
1095
- new (umd: FlowplayerUMD, player: PluginPlayerAPI): Plugin_2<PluginConfig, PluginPlayerAPI>;
1100
+ declare interface PluginCtor<PluginConfig extends Config = Config, PluginPlayer extends Player = Player> {
1101
+ new (umd: FlowplayerUMD, player: PluginPlayer): Plugin_2<PluginConfig, PluginPlayer>;
1096
1102
  }
1097
1103
 
1098
1104
  /* Excluded from this release type: PluginRegisteredEventDetail */
@@ -315,6 +315,8 @@ declare const /**
315
315
  */
316
316
  ENDED_2 = "ended";
317
317
 
318
+ declare type EnsureOnAttached<P extends Function, T extends Player> = ExtractPureAPI<T> extends _AttachedEventCheck ? P : "Loaders must implement on('<pluginname>:attached') event";
319
+
318
320
  /**
319
321
  * @public
320
322
  */
@@ -397,6 +399,8 @@ declare namespace events {
397
399
  }
398
400
  }
399
401
 
402
+ declare type ExtractPureAPI<T> = T extends PlayerWith<infer PureAPI> ? PureAPI : never;
403
+
400
404
  /**
401
405
  * @public
402
406
  */
@@ -474,19 +478,19 @@ declare interface FlowplayerUMDBase {
474
478
  /**
475
479
  * @public
476
480
  */
477
- declare interface FlowplayerUMDWithPlugins<ConfigWithPlugins extends Config = Config, PluginPlayerAPIExtension extends Player = Player> extends FlowplayerUMDBase {
481
+ declare interface FlowplayerUMDWithPlugins<ConfigWithPlugins extends Config = Config, PluginPlayer extends Player = Player> extends FlowplayerUMDBase {
478
482
  /**
479
483
  * Configure flowplayer, it's attached plugins and display flowplayer it in the UI
480
484
  * @param selector - query selector of the HTML element where player will render
481
485
  * @param config - Configuration of the flowplayer and the attached plugins
482
486
  */
483
- (selector: string, config?: ConfigWithPlugins): PluginPlayerAPIExtension;
487
+ (selector: string, config?: ConfigWithPlugins): PluginPlayer;
484
488
  /**
485
489
  * Configure flowplayer, it's attached plugins and display flowplayer it in the UI
486
490
  * @param element - HTML element where player will render
487
491
  * @param config - Configuration of the flowplayer and the attached plugins
488
492
  */
489
- (element: HTMLElement, config?: ConfigWithPlugins): PluginPlayerAPIExtension;
493
+ (element: HTMLElement, config?: ConfigWithPlugins): PluginPlayer;
490
494
  }
491
495
 
492
496
  /**
@@ -669,10 +673,11 @@ declare const LOADED = "is-loaded";
669
673
 
670
674
  /**
671
675
  * @public A plugin that supports loading new media formats. Use 'class MyPlugin implements Loader\<...\>' when writing your custom Loader
672
- * @typeParam PluginPlayerAPIExtension - additional Player API that will be implemented by the loader. Loader at least must implement on(\<loader-name\>:attached, ...) event handler
676
+ * @typeParam PluginPlayer- Player API that will be implemented by the loader. Loader at least must implement on(\<loader-name\>:attached, ...) event handler
673
677
  */
674
- declare interface Loader<PluginOwnConfig extends KeyValue, PluginPlayerAPIExtension extends _AttachedEventCheck> extends Plugin_2<PluginOwnConfig, PlayerWith<PluginPlayerAPIExtension>> {
675
- onload(config: ConfigWith<PluginOwnConfig>, root: PlayerRoot, video: PlayerWith<PluginPlayerAPIExtension>, src?: SourceObj): void;
678
+ declare interface Loader<PluginOwnConfig extends KeyValue, // FIXME extends Config
679
+ PluginPlayer extends PlayerWith<_AttachedEventCheck>> extends Plugin_2<PluginOwnConfig, PluginPlayer> {
680
+ onload: EnsureOnAttached<(config: ConfigWith<PluginOwnConfig>, root: PlayerRoot, video: PlayerWith<PluginPlayer>, src: SourceObj) => void, PluginPlayer>;
676
681
  wants<S = SourceObj>(srcString: SourceStr, srcObj: S, config: ConfigWith<PluginOwnConfig>): boolean;
677
682
  wants<S = KeyValue>(srcString: SourceStr, srcObj: SourceWith<S>, config: ConfigWith<PluginOwnConfig>): boolean;
678
683
  }
@@ -1069,6 +1074,7 @@ declare type PlayerNativeEventsOverloads = {
1069
1074
 
1070
1075
  /**
1071
1076
  * @public
1077
+ * The root element of the video player. This is the immediate parent element of the video tag.
1072
1078
  */
1073
1079
  declare type PlayerRoot = HTMLElement & {
1074
1080
  /* Excluded from this release type: prevWidth */
@@ -1104,11 +1110,11 @@ PLAYING_2 = "playing";
1104
1110
  /**
1105
1111
  * @public
1106
1112
  */
1107
- declare interface Plugin_2<PluginConfig extends Config = Config, PluginPlayerAPI extends Player = Player> {
1113
+ declare interface Plugin_2<PluginConfig extends Config = Config, PluginPlayer extends Player = Player> {
1108
1114
  /**
1109
1115
  * a plugin must always implement the init method so a player instance knows how to initialize it
1110
1116
  */
1111
- init(config: PluginConfig, container: PlayerRoot, player: PluginPlayerAPI): void;
1117
+ init(config: PluginConfig, container: PlayerRoot, player: PluginPlayer): void;
1112
1118
  }
1113
1119
 
1114
1120
  /* Excluded from this release type: PLUGIN_REGISTERED */
@@ -1116,8 +1122,8 @@ declare interface Plugin_2<PluginConfig extends Config = Config, PluginPlayerAPI
1116
1122
  /**
1117
1123
  * @public
1118
1124
  */
1119
- declare interface PluginCtor<PluginConfig extends Config = Config, PluginPlayerAPI extends Player = Player> {
1120
- new (umd: FlowplayerUMD, player: PluginPlayerAPI): Plugin_2<PluginConfig, PluginPlayerAPI>;
1125
+ declare interface PluginCtor<PluginConfig extends Config = Config, PluginPlayer extends Player = Player> {
1126
+ new (umd: FlowplayerUMD, player: PluginPlayer): Plugin_2<PluginConfig, PluginPlayer>;
1121
1127
  }
1122
1128
 
1123
1129
  /* Excluded from this release type: PluginRegisteredEventDetail */
@@ -315,6 +315,8 @@ declare const /**
315
315
  */
316
316
  ENDED_2 = "ended";
317
317
 
318
+ declare type EnsureOnAttached<P extends Function, T extends Player> = ExtractPureAPI<T> extends _AttachedEventCheck ? P : "Loaders must implement on('<pluginname>:attached') event";
319
+
318
320
  /**
319
321
  * @public
320
322
  */
@@ -397,6 +399,8 @@ declare namespace events {
397
399
  }
398
400
  }
399
401
 
402
+ declare type ExtractPureAPI<T> = T extends PlayerWith<infer PureAPI> ? PureAPI : never;
403
+
400
404
  /**
401
405
  * @public
402
406
  */
@@ -474,19 +478,19 @@ declare interface FlowplayerUMDBase {
474
478
  /**
475
479
  * @public
476
480
  */
477
- declare interface FlowplayerUMDWithPlugins<ConfigWithPlugins extends Config = Config, PluginPlayerAPIExtension extends Player = Player> extends FlowplayerUMDBase {
481
+ declare interface FlowplayerUMDWithPlugins<ConfigWithPlugins extends Config = Config, PluginPlayer extends Player = Player> extends FlowplayerUMDBase {
478
482
  /**
479
483
  * Configure flowplayer, it's attached plugins and display flowplayer it in the UI
480
484
  * @param selector - query selector of the HTML element where player will render
481
485
  * @param config - Configuration of the flowplayer and the attached plugins
482
486
  */
483
- (selector: string, config?: ConfigWithPlugins): PluginPlayerAPIExtension;
487
+ (selector: string, config?: ConfigWithPlugins): PluginPlayer;
484
488
  /**
485
489
  * Configure flowplayer, it's attached plugins and display flowplayer it in the UI
486
490
  * @param element - HTML element where player will render
487
491
  * @param config - Configuration of the flowplayer and the attached plugins
488
492
  */
489
- (element: HTMLElement, config?: ConfigWithPlugins): PluginPlayerAPIExtension;
493
+ (element: HTMLElement, config?: ConfigWithPlugins): PluginPlayer;
490
494
  }
491
495
 
492
496
  /**
@@ -644,10 +648,11 @@ declare const LOADED = "is-loaded";
644
648
 
645
649
  /**
646
650
  * @public A plugin that supports loading new media formats. Use 'class MyPlugin implements Loader\<...\>' when writing your custom Loader
647
- * @typeParam PluginPlayerAPIExtension - additional Player API that will be implemented by the loader. Loader at least must implement on(\<loader-name\>:attached, ...) event handler
651
+ * @typeParam PluginPlayer- Player API that will be implemented by the loader. Loader at least must implement on(\<loader-name\>:attached, ...) event handler
648
652
  */
649
- declare interface Loader<PluginOwnConfig extends KeyValue, PluginPlayerAPIExtension extends _AttachedEventCheck> extends Plugin_2<PluginOwnConfig, PlayerWith<PluginPlayerAPIExtension>> {
650
- onload(config: ConfigWith<PluginOwnConfig>, root: PlayerRoot, video: PlayerWith<PluginPlayerAPIExtension>, src?: SourceObj): void;
653
+ declare interface Loader<PluginOwnConfig extends KeyValue, // FIXME extends Config
654
+ PluginPlayer extends PlayerWith<_AttachedEventCheck>> extends Plugin_2<PluginOwnConfig, PluginPlayer> {
655
+ onload: EnsureOnAttached<(config: ConfigWith<PluginOwnConfig>, root: PlayerRoot, video: PlayerWith<PluginPlayer>, src: SourceObj) => void, PluginPlayer>;
651
656
  wants<S = SourceObj>(srcString: SourceStr, srcObj: S, config: ConfigWith<PluginOwnConfig>): boolean;
652
657
  wants<S = KeyValue>(srcString: SourceStr, srcObj: SourceWith<S>, config: ConfigWith<PluginOwnConfig>): boolean;
653
658
  }
@@ -1044,6 +1049,7 @@ declare type PlayerNativeEventsOverloads = {
1044
1049
 
1045
1050
  /**
1046
1051
  * @public
1052
+ * The root element of the video player. This is the immediate parent element of the video tag.
1047
1053
  */
1048
1054
  declare type PlayerRoot = HTMLElement & {
1049
1055
  /* Excluded from this release type: prevWidth */
@@ -1079,11 +1085,11 @@ PLAYING_2 = "playing";
1079
1085
  /**
1080
1086
  * @public
1081
1087
  */
1082
- declare interface Plugin_2<PluginConfig extends Config = Config, PluginPlayerAPI extends Player = Player> {
1088
+ declare interface Plugin_2<PluginConfig extends Config = Config, PluginPlayer extends Player = Player> {
1083
1089
  /**
1084
1090
  * a plugin must always implement the init method so a player instance knows how to initialize it
1085
1091
  */
1086
- init(config: PluginConfig, container: PlayerRoot, player: PluginPlayerAPI): void;
1092
+ init(config: PluginConfig, container: PlayerRoot, player: PluginPlayer): void;
1087
1093
  }
1088
1094
 
1089
1095
  /* Excluded from this release type: PLUGIN_REGISTERED */
@@ -1091,8 +1097,8 @@ declare interface Plugin_2<PluginConfig extends Config = Config, PluginPlayerAPI
1091
1097
  /**
1092
1098
  * @public
1093
1099
  */
1094
- declare interface PluginCtor<PluginConfig extends Config = Config, PluginPlayerAPI extends Player = Player> {
1095
- new (umd: FlowplayerUMD, player: PluginPlayerAPI): Plugin_2<PluginConfig, PluginPlayerAPI>;
1100
+ declare interface PluginCtor<PluginConfig extends Config = Config, PluginPlayer extends Player = Player> {
1101
+ new (umd: FlowplayerUMD, player: PluginPlayer): Plugin_2<PluginConfig, PluginPlayer>;
1096
1102
  }
1097
1103
 
1098
1104
  /* Excluded from this release type: PluginRegisteredEventDetail */
@@ -320,6 +320,8 @@ declare const /**
320
320
  */
321
321
  ENDED_2 = "ended";
322
322
 
323
+ declare type EnsureOnAttached<P extends Function, T extends Player> = ExtractPureAPI<T> extends _AttachedEventCheck ? P : "Loaders must implement on('<pluginname>:attached') event";
324
+
323
325
  /**
324
326
  * @public
325
327
  */
@@ -409,6 +411,8 @@ declare namespace events {
409
411
  }
410
412
  }
411
413
 
414
+ declare type ExtractPureAPI<T> = T extends PlayerWith<infer PureAPI> ? PureAPI : never;
415
+
412
416
  /**
413
417
  * @public
414
418
  */
@@ -486,19 +490,19 @@ declare interface FlowplayerUMDBase {
486
490
  /**
487
491
  * @public
488
492
  */
489
- declare interface FlowplayerUMDWithPlugins<ConfigWithPlugins extends Config = Config, PluginPlayerAPIExtension extends Player = Player> extends FlowplayerUMDBase {
493
+ declare interface FlowplayerUMDWithPlugins<ConfigWithPlugins extends Config = Config, PluginPlayer extends Player = Player> extends FlowplayerUMDBase {
490
494
  /**
491
495
  * Configure flowplayer, it's attached plugins and display flowplayer it in the UI
492
496
  * @param selector - query selector of the HTML element where player will render
493
497
  * @param config - Configuration of the flowplayer and the attached plugins
494
498
  */
495
- (selector: string, config?: ConfigWithPlugins): PluginPlayerAPIExtension;
499
+ (selector: string, config?: ConfigWithPlugins): PluginPlayer;
496
500
  /**
497
501
  * Configure flowplayer, it's attached plugins and display flowplayer it in the UI
498
502
  * @param element - HTML element where player will render
499
503
  * @param config - Configuration of the flowplayer and the attached plugins
500
504
  */
501
- (element: HTMLElement, config?: ConfigWithPlugins): PluginPlayerAPIExtension;
505
+ (element: HTMLElement, config?: ConfigWithPlugins): PluginPlayer;
502
506
  }
503
507
 
504
508
  /**
@@ -577,7 +581,8 @@ declare namespace HealthEvents {
577
581
  REBUFFER,
578
582
  REBUFFER_ENDED,
579
583
  DISPLAY,
580
- TIME_TO_FIRST_FRAME
584
+ TIME_TO_FIRST_FRAME,
585
+ TIME_TO_FIRST_FRAGMENT_LOADED
581
586
  }
582
587
  }
583
588
 
@@ -679,10 +684,11 @@ declare const LOADED = "is-loaded";
679
684
 
680
685
  /**
681
686
  * @public A plugin that supports loading new media formats. Use 'class MyPlugin implements Loader\<...\>' when writing your custom Loader
682
- * @typeParam PluginPlayerAPIExtension - additional Player API that will be implemented by the loader. Loader at least must implement on(\<loader-name\>:attached, ...) event handler
687
+ * @typeParam PluginPlayer- Player API that will be implemented by the loader. Loader at least must implement on(\<loader-name\>:attached, ...) event handler
683
688
  */
684
- declare interface Loader<PluginOwnConfig extends KeyValue, PluginPlayerAPIExtension extends _AttachedEventCheck> extends Plugin_2<PluginOwnConfig, PlayerWith<PluginPlayerAPIExtension>> {
685
- onload(config: ConfigWith<PluginOwnConfig>, root: PlayerRoot, video: PlayerWith<PluginPlayerAPIExtension>, src?: SourceObj): void;
689
+ declare interface Loader<PluginOwnConfig extends KeyValue, // FIXME extends Config
690
+ PluginPlayer extends PlayerWith<_AttachedEventCheck>> extends Plugin_2<PluginOwnConfig, PluginPlayer> {
691
+ onload: EnsureOnAttached<(config: ConfigWith<PluginOwnConfig>, root: PlayerRoot, video: PlayerWith<PluginPlayer>, src: SourceObj) => void, PluginPlayer>;
686
692
  wants<S = SourceObj>(srcString: SourceStr, srcObj: S, config: ConfigWith<PluginOwnConfig>): boolean;
687
693
  wants<S = KeyValue>(srcString: SourceStr, srcObj: SourceWith<S>, config: ConfigWith<PluginOwnConfig>): boolean;
688
694
  }
@@ -1084,6 +1090,7 @@ declare type PlayerNativeEventsOverloads = {
1084
1090
 
1085
1091
  /**
1086
1092
  * @public
1093
+ * The root element of the video player. This is the immediate parent element of the video tag.
1087
1094
  */
1088
1095
  declare type PlayerRoot = HTMLElement & {
1089
1096
  /* Excluded from this release type: prevWidth */
@@ -1103,13 +1110,13 @@ declare type PlayerState = FlowplayerStates[keyof FlowplayerStates];
1103
1110
  */
1104
1111
  declare type PlayerWith<T> = T & Player;
1105
1112
 
1106
- declare type PlayerWithHealthAPI = Player & {
1113
+ declare type PlayerWithHealthAPI = PlayerWith<{
1107
1114
  health?: {
1108
1115
  media_session_id: string;
1109
1116
  session_id: string;
1110
1117
  toggle: (flag: boolean) => void;
1111
1118
  };
1112
- };
1119
+ }>;
1113
1120
 
1114
1121
  declare const PLAYING = "is-playing";
1115
1122
 
@@ -1127,11 +1134,11 @@ PLAYING_2 = "playing";
1127
1134
  /**
1128
1135
  * @public
1129
1136
  */
1130
- declare interface Plugin_2<PluginConfig extends Config = Config, PluginPlayerAPI extends Player = Player> {
1137
+ declare interface Plugin_2<PluginConfig extends Config = Config, PluginPlayer extends Player = Player> {
1131
1138
  /**
1132
1139
  * a plugin must always implement the init method so a player instance knows how to initialize it
1133
1140
  */
1134
- init(config: PluginConfig, container: PlayerRoot, player: PluginPlayerAPI): void;
1141
+ init(config: PluginConfig, container: PlayerRoot, player: PluginPlayer): void;
1135
1142
  }
1136
1143
 
1137
1144
  /* Excluded from this release type: PLUGIN_REGISTERED */
@@ -1139,8 +1146,8 @@ declare interface Plugin_2<PluginConfig extends Config = Config, PluginPlayerAPI
1139
1146
  /**
1140
1147
  * @public
1141
1148
  */
1142
- declare interface PluginCtor<PluginConfig extends Config = Config, PluginPlayerAPI extends Player = Player> {
1143
- new (umd: FlowplayerUMD, player: PluginPlayerAPI): Plugin_2<PluginConfig, PluginPlayerAPI>;
1149
+ declare interface PluginCtor<PluginConfig extends Config = Config, PluginPlayer extends Player = Player> {
1150
+ new (umd: FlowplayerUMD, player: PluginPlayer): Plugin_2<PluginConfig, PluginPlayer>;
1144
1151
  }
1145
1152
 
1146
1153
  /* Excluded from this release type: PluginRegisteredEventDetail */
@@ -1465,6 +1472,8 @@ declare namespace states {
1465
1472
  }
1466
1473
  }
1467
1474
 
1475
+ declare const TIME_TO_FIRST_FRAGMENT_LOADED = "insights:time_to_first_frag_loaded";
1476
+
1468
1477
  declare const TIME_TO_FIRST_FRAME = "insights:ttff";
1469
1478
 
1470
1479
  /**
package/plugins/health.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.health=t())}(this,(function(){"use strict";const e="rebuffer",t="rebuffer:ended",n="insights:ttff";var i=Object.freeze({__proto__:null,RECORD:"health:record",REBUFFER:e,REBUFFER_ENDED:t,DISPLAY:"display",TIME_TO_FIRST_FRAME:n});const s="content:loadstart",o="fullscreenenter",r="fullscreenexit",a="loadedmetadata",d="loadeddata",c="progress",l="loadstart",u="pause",_="playing",f="waiting",h="canplay",p="ended",y="seeked",m="seeking";function E(e){try{return!!new URL(e)}catch(e){return!1}}function g(e,t){const n=function(){try{return localStorage.getItem("flowplayer/debug")}catch(e){return""}}(),i=(i,...s)=>{try{const o=(null==t?void 0:t.debug)||n;o&&e.match(o)&&console.log(`flowplayer/${e} -- ${i}`,...s)}catch(e){console.warn(e)}};return i.log=i,i}const v=navigator;function R(e){var t,n;const i=null===(t=e.hls)||void 0===t?void 0:t.bandwidthEstimate;return i?1e-6*i:(null===(n=v.connection)||void 0===n?void 0:n.downlink)||-1}function I(e,t){return async function(e,t){try{await fetch(e,{body:t,method:"POST",mode:"no-cors"})}catch(e){}}(e,JSON.stringify({events:t}))}var O;!function(e){e[e.OFF=0]="OFF",e[e.ON=1]="ON",e[e.AUDIO_REQUIRED=2]="AUDIO_REQUIRED"}(O||(O={}));const w=e=>{switch(e){case!0:return O.ON;case!1:return O.OFF;default:return e}};function D(){try{const e=window.location!==window.parent.location?document.referrer:document.location.href;return"string"==typeof e&&e.slice(0,200)}catch(e){return!1}}const N=[],T="https://ihi.flowplayer.com/v1/health/events";function A(e){if(e.suspended)return;const t=N.slice(0);N.length=0,0!=t.length&&(e.logger.log(`:dispatch events={${t.length}}`),I(function(){try{return"undefined"==typeof window?T:window.__FLOWPLAYER_INSIGHTS_URL?window.__FLOWPLAYER_INSIGHTS_URL:T}catch(e){return T}}(),t))}async function b(e,t,n){const i=await L();N.push(Object.assign(t,i)),e.logger.log(":enqueue",t.event,t),N.length<10&&!n||A(e)}const S=()=>{var e,t;try{const n=window;return null===(t=null===(e=null==n?void 0:n.google)||void 0===e?void 0:e.ima)||void 0===t?void 0:t.VERSION}catch(e){return}},L=async()=>({client_time:Date.now()}),U=(e,t)=>Object.assign(e,{detail:t}),F=(e,{event:t,media_session_id:n,session_id:i,play_range_id:s})=>({event:t,media_session_id:n,session_id:i,play_range_id:s,device_id:e.deviceId(),version:"3.15.0-rc.8",commit:"27284a97372ed5e1b55f74dea16920465cf480d5",ima_sdk_version:S(),preload:e.opt("preload"),autoplay:w(e.opt("autoplay")),live:e.opt("live"),dvr:!!e.live_state.dvr,source:e.original_src,downlink_mbs:R(e),page_url:D(),player_id:e.opt("metadata.player_id"),media_id:e.opt("metadata.media_id"),site_id:e.opt("metadata.site_id"),category_id:e.opt("metadata.category_id"),sitegroup_id:e.opt("metadata.sitegroup_id"),token:e.token,plugins:e.plugins.map(e=>e.constructor.name).sort((e,t)=>e.localeCompare(t)),current_time:e.currentTime,external_media_id:e.opt("external_media_id")}),M=e=>({bitrate:null==e?void 0:e.bitrate,resolution:null==e?void 0:e.attrs.RESOLUTION,frame_rate:null==e?void 0:e.attrs["FRAME-RATE"]});function C(e,t,n,i){const s=F(t,e.eventInfo(n)),{before:o,after:r}=i;b(e,((e,t,n)=>Object.assign(e,{state:{before:t,after:n}}))(s,M(o),M(r)))}const k=[1e7]+""+-1e3+-4e3+-8e3+-1e11,x=()=>"undefined"==typeof crypto?"":k.replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16));var B;function P(e){switch(e){case B.MEDIA_PLAYBACK_ABORTED:return"media playback was aborted";case B.MEDIA_ERR_NETWORK:return"a network error occurred";case B.MEDIA_ERR_DECODE:return"unable to decode media content";case B.MEDIA_ERR_SRC_NOT_SUPPORTED:return"unsupported media type";case B.NO_INTERNET:return"no internet connection detected";case B.MIXED_CONTENT:return"cannot load insecure content in a secure context";default:return"an unknown error occurred"}}!function(e){e[e.UNKNOWN=-1]="UNKNOWN",e[e.MEDIA_PLAYBACK_ABORTED=1]="MEDIA_PLAYBACK_ABORTED",e[e.MEDIA_ERR_NETWORK=2]="MEDIA_ERR_NETWORK",e[e.MEDIA_ERR_DECODE=3]="MEDIA_ERR_DECODE",e[e.MEDIA_ERR_SRC_NOT_SUPPORTED=4]="MEDIA_ERR_SRC_NOT_SUPPORTED",e[e.MIXED_CONTENT=1001]="MIXED_CONTENT",e[e.NO_INTERNET=1002]="NO_INTERNET"}(B||(B={}));const H=(e,t)=>{let n=null;return(...i)=>{null!==n&&(clearTimeout(n),n=null),n=setTimeout(()=>t(...i),e)}};const W=x();class Health{constructor(e,t){let n;this.session_id=W,this.suspended=!1,this.logger=g("health",t.opts),this.media_session_id=x(),this.play_range_id=x(),this.analyticsLoop=setInterval(()=>A(this),2e3),t.on("reap",()=>clearInterval(this.analyticsLoop)),t.on(_,()=>{n!==this.media_session_id&&(n=this.media_session_id,this.first_playing_event_timestamp=Date.now()),this.play_range_id=x()});let i=Date.now()-1e3;t.on("timeupdate",e=>{if(n!==this.media_session_id)return;const s=Date.now();if(s<i)return;i=Date.now()+5e3;const o=F(t,this.eventInfo(e.type)),r=U(o,{duration:(a=t.duration,Number.isFinite(a)?a:a===1/0?-1:void 0)});var a;this.first_playing_event_timestamp&&(Object.assign(r,{ms_since_first_playing:s-this.first_playing_event_timestamp}),this.first_playing_event_timestamp=void 0),b(this,r)});const s=this;if(t.health={get media_session_id(){return s.media_session_id},set media_session_id(e){s.media_session_id=e},get session_id(){return s.session_id},set session_id(e){s.session_id=e},toggle(e){e?s.resume():s.suspend()}},!Health._UNLOAD_SUBSCRIBED){Health._UNLOAD_SUBSCRIBED=!0;const t=t=>e.instances.forEach(e=>e.emit(t.type));document.addEventListener("visibilitychange",e=>{"hidden"==document.visibilityState&&t(e)}),window.addEventListener("pagehide",t)}}eventInfo(e){return{event:e,media_session_id:this.media_session_id,session_id:this.session_id,play_range_id:this.play_range_id}}suspend(){this.suspended=!0,clearInterval(this.analyticsLoop)}resume(){this.suspended=!1,this.analyticsLoop=setInterval(()=>A(this),2e3)}init(i,g,v){if(D().toString().startsWith("data:"))return this.suspend();!function(n){n.on(f,(function(i){if(n.seeking)return;if(n.networkState!==n.NETWORK_LOADING)return;if(n.readyState===n.HAVE_NOTHING)return;const s=Date.now(),o=e=>{n.off(h,o),n.off("src",o),n.off("error",o),e.type===h&&n.emit(t,{rebuffer_duration:(Date.now()-s)/1e3})};n.on([h,"error","src"],o),n.emit(e)}))}(v),function(e){let t;[h,s].forEach(i=>{e.on(i,i=>{const o=Date.now();switch(i.type){case s:return t=o;case h:if(t)return e.emit(n,{ms_since_loading_started:o-t}),t=null}})})}(v),v.on("display",e=>{b(this,F(v,this.eventInfo(e.type)),!0)}),v.on("health:record",({detail:e})=>{const t=F(v,this.eventInfo(e.event));Object.assign(t,e.detail||{}),b(this,t)}),[l,a,d,c,f,e].forEach(e=>{v.on(e,e=>{b(this,F(v,this.eventInfo(e.type)))})}),[t,n].forEach(e=>{v.on(e,e=>{const t=F(v,this.eventInfo(e.type));b(this,Object.assign(t,e.detail))})}),[_,u,m,y,p,o,r,h,s].forEach(e=>{v.on(e,e=>{b(this,F(v,this.eventInfo(e.type)))})}),v.on("volumechange",H(800,e=>{const t=F(v,this.eventInfo(e.type));b(this,U(t,{volume:parseFloat(v.volume.toFixed(2)),muted:v.muted}))})),v.on("resize",H(800,e=>{const t=F(v,this.eventInfo(e.type));b(this,U(t,{height:g.clientHeight,width:g.clientWidth}))})),v.on("hls/failover",e=>{const t=F(v,this.eventInfo(e.type)),n=e.detail,{reason:i,from:s}=n;b(this,U(t,{reason:i,from:s}))}),v.on("qualitychange",({type:e,detail:t})=>{switch(t.kind){case"hls":return C(this,v,e,t)}}),v.addEventListener("error",e=>{const t=F(v,this.eventInfo(e.type)),n=e.error||v.error;if(!n)return b(this,t,!0);const i=n.code,s={error_message:n.message||P(i),error_code:i,error_stack:n.stack||""};return b(this,U(t,s),!0)}),v.on("src",e=>{var t;const n=null===(t=e.detail)||void 0===t?void 0:t.src;if("string"!=typeof n)return;if(!E(v.original_src))return;if(!E(n))return;if(n==v.original_src)return;this.media_session_id=x();b(this,F(v,this.eventInfo(e.type))),A(this)}),v.on("visibilitychange",e=>{b(this,F(v,this.eventInfo(e.type))),A(this)})}}return Health.events=i,Health._UNLOAD_SUBSCRIBED=!1,function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;if(null===document.currentScript)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;return"function"==typeof n?(n(t),t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t),t)}(window,Health)}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.health=t())}(this,(function(){"use strict";const e="rebuffer",t="rebuffer:ended",i="insights:ttff",n="insights:time_to_first_frag_loaded";var r=Object.freeze({__proto__:null,RECORD:"health:record",REBUFFER:e,REBUFFER_ENDED:t,DISPLAY:"display",TIME_TO_FIRST_FRAME:i,TIME_TO_FIRST_FRAGMENT_LOADED:n});const s="content:loadstart",o="fullscreenenter",a="fullscreenexit",d="loadedmetadata",l="loadeddata",c="progress",u="loadstart",_="pause",h="playing",f="waiting",p="canplay",m="ended",y="seeked",g="seeking";function E(e){try{return!!new URL(e)}catch(e){return!1}}function v(e,t){const i=function(){try{return localStorage.getItem("flowplayer/debug")}catch(e){return""}}(),n=(n,...r)=>{try{const s=(null==t?void 0:t.debug)||i;s&&e.match(s)&&console.log(`flowplayer/${e} -- ${n}`,...r)}catch(e){console.warn(e)}};return n.log=n,n}const T=navigator;function R(e){var t,i;const n=null===(t=e.hls)||void 0===t?void 0:t.bandwidthEstimate;return n?1e-6*n:(null===(i=T.connection)||void 0===i?void 0:i.downlink)||-1}function A(e,t){return async function(e,t){try{await fetch(e,{body:t,method:"POST",mode:"no-cors"})}catch(e){}}(e,JSON.stringify({events:t}))}var O;!function(e){e[e.OFF=0]="OFF",e[e.ON=1]="ON",e[e.AUDIO_REQUIRED=2]="AUDIO_REQUIRED"}(O||(O={}));const I=e=>{switch(e){case!0:return O.ON;case!1:return O.OFF;default:return e}};function w(){try{const e=window.location!==window.parent.location?document.referrer:document.location.href;return"string"==typeof e&&e.slice(0,200)}catch(e){return!1}}const S=[],D="https://ihi.flowplayer.com/v1/health/events";function N(e){if(e.suspended)return;const t=S.slice(0);S.length=0,0!=t.length&&(e.logger.log(`:dispatch events={${t.length}}`),A(function(){try{return"undefined"==typeof window?D:window.__FLOWPLAYER_INSIGHTS_URL?window.__FLOWPLAYER_INSIGHTS_URL:D}catch(e){return D}}(),t))}async function b(e,t,i){const n=await F();S.push(Object.assign(t,n)),e.logger.log(":enqueue",t.event,t),S.length<10&&!i||N(e)}const U=()=>{var e,t;try{const i=window;return null===(t=null===(e=null==i?void 0:i.google)||void 0===e?void 0:e.ima)||void 0===t?void 0:t.VERSION}catch(e){return}},F=async()=>({client_time:Date.now()}),C=(e,t)=>Object.assign(e,{detail:t}),L=(e,{event:t,media_session_id:i,session_id:n,play_range_id:r})=>({event:t,media_session_id:i,session_id:n,play_range_id:r,device_id:e.deviceId(),version:"3.15.0",commit:"180599195e7b71f289f0a4f0703819bdadea88b8",ima_sdk_version:U(),preload:e.opt("preload"),autoplay:I(e.opt("autoplay")),live:e.opt("live"),dvr:!!e.live_state.dvr,source:e.original_src,downlink_mbs:R(e),page_url:w(),player_id:e.opt("metadata.player_id"),media_id:e.opt("metadata.media_id"),site_id:e.opt("metadata.site_id"),category_id:e.opt("metadata.category_id"),sitegroup_id:e.opt("metadata.sitegroup_id"),token:e.token,plugins:e.plugins.map(e=>e.constructor.name).sort((e,t)=>e.localeCompare(t)),current_time:e.currentTime,external_media_id:e.opt("external_media_id")}),M=e=>({bitrate:null==e?void 0:e.bitrate,resolution:null==e?void 0:e.attrs.RESOLUTION,frame_rate:null==e?void 0:e.attrs["FRAME-RATE"]});function W(e,t,i,n){const r=L(t,e.eventInfo(i)),{before:s,after:o}=n;b(e,((e,t,i)=>Object.assign(e,{state:{before:t,after:i}}))(r,M(s),M(o)))}const k=[1e7]+""+-1e3+-4e3+-8e3+-1e11,x=()=>"undefined"==typeof crypto?"":k.replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16));var B;function G(e){switch(e){case B.MEDIA_PLAYBACK_ABORTED:return"media playback was aborted";case B.MEDIA_ERR_NETWORK:return"a network error occurred";case B.MEDIA_ERR_DECODE:return"unable to decode media content";case B.MEDIA_ERR_SRC_NOT_SUPPORTED:return"unsupported media type";case B.NO_INTERNET:return"no internet connection detected";case B.MIXED_CONTENT:return"cannot load insecure content in a secure context";default:return"an unknown error occurred"}}!function(e){e[e.UNKNOWN=-1]="UNKNOWN",e[e.MEDIA_PLAYBACK_ABORTED=1]="MEDIA_PLAYBACK_ABORTED",e[e.MEDIA_ERR_NETWORK=2]="MEDIA_ERR_NETWORK",e[e.MEDIA_ERR_DECODE=3]="MEDIA_ERR_DECODE",e[e.MEDIA_ERR_SRC_NOT_SUPPORTED=4]="MEDIA_ERR_SRC_NOT_SUPPORTED",e[e.MIXED_CONTENT=1001]="MIXED_CONTENT",e[e.NO_INTERNET=1002]="NO_INTERNET"}(B||(B={}));const H=(e,t)=>{let i=null;return(...n)=>{null!==i&&(clearTimeout(i),i=null),i=setTimeout(()=>t(...n),e)}};var P;!function(e){e[e.Starting=0]="Starting",e[e.ConfigFinalized=1]="ConfigFinalized",e[e.TimerStartedWithAdsAutoplay=2]="TimerStartedWithAdsAutoplay",e[e.TimerStartedWithContentAutoplay=3]="TimerStartedWithContentAutoplay",e[e.TimerStartedWithUserGesture=4]="TimerStartedWithUserGesture",e[e.MetricReported=5]="MetricReported"}(P||(P={}));class TimeToFirstFrame{constructor(e=P.Starting,t=!1,i=!1){this.state=e,this.loadedAd=t,this.requiresUserGesture=i}reset(){this.state=P.Starting,this.loadedAd=!1,this.elapsed=void 0}toJSON(){var e;return{ad_was_requested:this.loadedAd,ms_to_first_frame:Math.round((null===(e=this.elapsed)||void 0===e?void 0:e.duration)||-1)}}startTimer(e){this.state==P.ConfigFinalized&&(this.state=e,performance.mark("ttff:start"))}hasStarted(){return[P.TimerStartedWithAdsAutoplay,P.TimerStartedWithContentAutoplay,P.TimerStartedWithUserGesture].includes(this.state)}stopTimer(e){if(this.hasStarted()){performance.mark("ttff:end");const t=this.elapsed=performance.measure("ttff","ttff:start","ttff:end");this.state=P.MetricReported,e(t)}}}const j=x();class Health{constructor(e,t){let i;this.session_id=j,this.suspended=!1,this.logger=v("health",t.opts),this.media_session_id=x(),this.play_range_id=x(),this.analyticsLoop=setInterval(()=>N(this),2e3),t.on("reap",()=>clearInterval(this.analyticsLoop)),t.on(h,()=>{i!==this.media_session_id&&(i=this.media_session_id,this.first_playing_event_timestamp=Date.now()),this.play_range_id=x()});let n=Date.now()-1e3;t.on("timeupdate",e=>{if(i!==this.media_session_id)return;const r=Date.now();if(r<n)return;n=Date.now()+5e3;const s=L(t,this.eventInfo(e.type)),o=C(s,{duration:(a=t.duration,Number.isFinite(a)?a:a===1/0?-1:void 0)});var a;this.first_playing_event_timestamp&&(Object.assign(o,{ms_since_first_playing:r-this.first_playing_event_timestamp}),this.first_playing_event_timestamp=void 0),b(this,o)});const r=this;if(t.health={get media_session_id(){return r.media_session_id},set media_session_id(e){r.media_session_id=e},get session_id(){return r.session_id},set session_id(e){r.session_id=e},toggle(e){e?r.resume():r.suspend()}},!Health._UNLOAD_SUBSCRIBED){Health._UNLOAD_SUBSCRIBED=!0;const t=t=>e.instances.forEach(e=>e.emit(t.type));document.addEventListener("visibilitychange",e=>{"hidden"==document.visibilityState&&t(e)}),window.addEventListener("pagehide",t)}}eventInfo(e){return{event:e,media_session_id:this.media_session_id,session_id:this.session_id,play_range_id:this.play_range_id}}suspend(){this.suspended=!0,clearInterval(this.analyticsLoop)}resume(){this.suspended=!1,this.analyticsLoop=setInterval(()=>N(this),2e3)}init(r,v,T){if(w().toString().startsWith("data:"))return this.suspend();!function(i){i.on(f,(function(n){if(i.seeking)return;if(i.networkState!==i.NETWORK_LOADING)return;if(i.readyState===i.HAVE_NOTHING)return;const r=Date.now(),s=e=>{i.off(p,s),i.off("src",s),i.off("error",s),e.type===p&&i.emit(t,{rebuffer_duration:(Date.now()-r)/1e3})};i.on([p,"error","src"],s),i.emit(e)}))}(T),function(e){let t;[p,s].forEach(i=>{e.on(i,i=>{const r=Date.now();switch(i.type){case s:return t=r;case p:if(t)return e.emit(n,{ms_since_loading_started:r-t}),t=null}})})}(T),function(e){if(void 0===window.performance)return;const t=new TimeToFirstFrame;e.on("ovp:config:finalized",e=>{t.reset(),t.state=P.ConfigFinalized,t.requiresUserGesture=!e.detail.autoplay}),e.on(s,()=>{e.root.classList.contains("ad-hide-first-frame")&&t.startTimer(P.TimerStartedWithAdsAutoplay),e.opt("autoplay")&&t.startTimer(P.TimerStartedWithContentAutoplay)}),e.on("click",()=>{e.opt("autoplay")||t.startTimer(P.TimerStartedWithUserGesture)}),e.on("ad-requested",()=>{t.loadedAd=!0}),e.on("timeupdate",()=>{if(!(e.readyState<HTMLMediaElement.HAVE_CURRENT_DATA))switch(t.state){case P.TimerStartedWithContentAutoplay:case P.TimerStartedWithUserGesture:return t.stopTimer(()=>e.emit(i,t.toJSON()))}}),e.on("ad-started",()=>{switch(t.state){case P.TimerStartedWithAdsAutoplay:case P.TimerStartedWithUserGesture:return t.stopTimer(()=>e.emit(i,t.toJSON()))}})}(T),T.on("display",e=>{b(this,L(T,this.eventInfo(e.type)),!0)}),T.on("health:record",({detail:e})=>{const t=L(T,this.eventInfo(e.event));Object.assign(t,e.detail||{}),b(this,t)}),[u,d,l,c,f,e].forEach(e=>{T.on(e,e=>{b(this,L(T,this.eventInfo(e.type)))})}),[t,i,n].forEach(e=>{T.on(e,e=>{const t=L(T,this.eventInfo(e.type));b(this,Object.assign(t,e.detail))})}),[h,_,g,y,m,o,a,p,s].forEach(e=>{T.on(e,e=>{b(this,L(T,this.eventInfo(e.type)))})}),T.on("volumechange",H(800,e=>{const t=L(T,this.eventInfo(e.type));b(this,C(t,{volume:parseFloat(T.volume.toFixed(2)),muted:T.muted}))})),T.on("resize",H(800,e=>{const t=L(T,this.eventInfo(e.type));b(this,C(t,{height:v.clientHeight,width:v.clientWidth}))})),T.on("hls/failover",e=>{const t=L(T,this.eventInfo(e.type)),i=e.detail,{reason:n,from:r}=i;b(this,C(t,{reason:n,from:r}))}),T.on("qualitychange",({type:e,detail:t})=>{switch(t.kind){case"hls":return W(this,T,e,t)}}),T.addEventListener("error",e=>{const t=L(T,this.eventInfo(e.type)),i=e.error||T.error;if(!i)return b(this,t,!0);const n=i.code,r={error_message:i.message||G(n),error_code:n,error_stack:i.stack||""};return b(this,C(t,r),!0)}),T.on("src",e=>{var t;const i=null===(t=e.detail)||void 0===t?void 0:t.src;if("string"!=typeof i)return;if(!E(T.original_src))return;if(!E(i))return;if(i==T.original_src)return;this.media_session_id=x();b(this,L(T,this.eventInfo(e.type))),N(this)}),T.on("visibilitychange",e=>{b(this,L(T,this.eventInfo(e.type))),N(this)})}}return Health.events=r,Health._UNLOAD_SUBSCRIBED=!1,function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;if(null===document.currentScript)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const i=e.flowplayer;return"function"==typeof i?(i(t),t):(Array.isArray(i.extensions)||(i.extensions=[]),~i.extensions.indexOf(t)||i.extensions.push(t),t)}(window,Health)}));
package/plugins/hls.d.ts CHANGED
@@ -319,6 +319,8 @@ declare const /**
319
319
  */
320
320
  ENDED_2 = "ended";
321
321
 
322
+ declare type EnsureOnAttached<P extends Function, T extends Player> = ExtractPureAPI<T> extends _AttachedEventCheck ? P : "Loaders must implement on('<pluginname>:attached') event";
323
+
322
324
  /**
323
325
  * @public
324
326
  */
@@ -407,6 +409,8 @@ declare namespace events_2 {
407
409
  }
408
410
  }
409
411
 
412
+ declare type ExtractPureAPI<T> = T extends PlayerWith<infer PureAPI> ? PureAPI : never;
413
+
410
414
  /**
411
415
  * @public
412
416
  */
@@ -484,19 +488,19 @@ declare interface FlowplayerUMDBase {
484
488
  /**
485
489
  * @public
486
490
  */
487
- declare interface FlowplayerUMDWithPlugins<ConfigWithPlugins extends Config = Config, PluginPlayerAPIExtension extends Player = Player> extends FlowplayerUMDBase {
491
+ declare interface FlowplayerUMDWithPlugins<ConfigWithPlugins extends Config = Config, PluginPlayer extends Player = Player> extends FlowplayerUMDBase {
488
492
  /**
489
493
  * Configure flowplayer, it's attached plugins and display flowplayer it in the UI
490
494
  * @param selector - query selector of the HTML element where player will render
491
495
  * @param config - Configuration of the flowplayer and the attached plugins
492
496
  */
493
- (selector: string, config?: ConfigWithPlugins): PluginPlayerAPIExtension;
497
+ (selector: string, config?: ConfigWithPlugins): PluginPlayer;
494
498
  /**
495
499
  * Configure flowplayer, it's attached plugins and display flowplayer it in the UI
496
500
  * @param element - HTML element where player will render
497
501
  * @param config - Configuration of the flowplayer and the attached plugins
498
502
  */
499
- (element: HTMLElement, config?: ConfigWithPlugins): PluginPlayerAPIExtension;
503
+ (element: HTMLElement, config?: ConfigWithPlugins): PluginPlayer;
500
504
  }
501
505
 
502
506
  /**
@@ -553,7 +557,7 @@ declare const HAS_POSTER = "has-poster";
553
557
  /**
554
558
  * @public
555
559
  */
556
- declare const HLS: PluginCtor<HLSConfig, PlayerWith<HLSPlayerMixin>> & HLSAPI;
560
+ declare const HLS: PluginCtor<HLSConfig, HLSPlayer> & HLSAPI;
557
561
  export default HLS;
558
562
 
559
563
  /**
@@ -596,10 +600,10 @@ export declare type HLSEvents = typeof events;
596
600
  /**
597
601
  * @public
598
602
  */
599
- export declare type HLSPlayerMixin = {
603
+ export declare type HLSPlayer = PlayerWith<{
600
604
  /* Excluded from this release type: hls */
601
605
  on(event: typeof ATTACHED, handler: (e: HLSAttachedEvent) => void): Player;
602
- };
606
+ }>;
603
607
 
604
608
  declare const HOVERED = "is-hovered";
605
609
 
@@ -699,10 +703,11 @@ declare const LOADED = "is-loaded";
699
703
 
700
704
  /**
701
705
  * @public A plugin that supports loading new media formats. Use 'class MyPlugin implements Loader\<...\>' when writing your custom Loader
702
- * @typeParam PluginPlayerAPIExtension - additional Player API that will be implemented by the loader. Loader at least must implement on(\<loader-name\>:attached, ...) event handler
706
+ * @typeParam PluginPlayer- Player API that will be implemented by the loader. Loader at least must implement on(\<loader-name\>:attached, ...) event handler
703
707
  */
704
- declare interface Loader<PluginOwnConfig extends KeyValue, PluginPlayerAPIExtension extends _AttachedEventCheck> extends Plugin_2<PluginOwnConfig, PlayerWith<PluginPlayerAPIExtension>> {
705
- onload(config: ConfigWith<PluginOwnConfig>, root: PlayerRoot, video: PlayerWith<PluginPlayerAPIExtension>, src?: SourceObj): void;
708
+ declare interface Loader<PluginOwnConfig extends KeyValue, // FIXME extends Config
709
+ PluginPlayer extends PlayerWith<_AttachedEventCheck>> extends Plugin_2<PluginOwnConfig, PluginPlayer> {
710
+ onload: EnsureOnAttached<(config: ConfigWith<PluginOwnConfig>, root: PlayerRoot, video: PlayerWith<PluginPlayer>, src: SourceObj) => void, PluginPlayer>;
706
711
  wants<S = SourceObj>(srcString: SourceStr, srcObj: S, config: ConfigWith<PluginOwnConfig>): boolean;
707
712
  wants<S = KeyValue>(srcString: SourceStr, srcObj: SourceWith<S>, config: ConfigWith<PluginOwnConfig>): boolean;
708
713
  }
@@ -1099,6 +1104,7 @@ declare type PlayerNativeEventsOverloads = {
1099
1104
 
1100
1105
  /**
1101
1106
  * @public
1107
+ * The root element of the video player. This is the immediate parent element of the video tag.
1102
1108
  */
1103
1109
  declare type PlayerRoot = HTMLElement & {
1104
1110
  /* Excluded from this release type: prevWidth */
@@ -1134,11 +1140,11 @@ PLAYING_2 = "playing";
1134
1140
  /**
1135
1141
  * @public
1136
1142
  */
1137
- declare interface Plugin_2<PluginConfig extends Config = Config, PluginPlayerAPI extends Player = Player> {
1143
+ declare interface Plugin_2<PluginConfig extends Config = Config, PluginPlayer extends Player = Player> {
1138
1144
  /**
1139
1145
  * a plugin must always implement the init method so a player instance knows how to initialize it
1140
1146
  */
1141
- init(config: PluginConfig, container: PlayerRoot, player: PluginPlayerAPI): void;
1147
+ init(config: PluginConfig, container: PlayerRoot, player: PluginPlayer): void;
1142
1148
  }
1143
1149
 
1144
1150
  /* Excluded from this release type: PLUGIN_REGISTERED */
@@ -1146,8 +1152,8 @@ declare interface Plugin_2<PluginConfig extends Config = Config, PluginPlayerAPI
1146
1152
  /**
1147
1153
  * @public
1148
1154
  */
1149
- declare interface PluginCtor<PluginConfig extends Config = Config, PluginPlayerAPI extends Player = Player> {
1150
- new (umd: FlowplayerUMD, player: PluginPlayerAPI): Plugin_2<PluginConfig, PluginPlayerAPI>;
1155
+ declare interface PluginCtor<PluginConfig extends Config = Config, PluginPlayer extends Player = Player> {
1156
+ new (umd: FlowplayerUMD, player: PluginPlayer): Plugin_2<PluginConfig, PluginPlayer>;
1151
1157
  }
1152
1158
 
1153
1159
  /* Excluded from this release type: PluginRegisteredEventDetail */