@amazon/vinyl 1.2.0 → 1.2.2

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 (330) hide show
  1. package/dist/index.cjs +24 -6
  2. package/dist/index.cjs.map +2 -2
  3. package/dist/index.js +33 -13
  4. package/dist/index.js.map +3 -3
  5. package/dist/test/integ.es5.js +62 -62
  6. package/dist/test/integ.js +119 -6
  7. package/dist/test/integ.js.map +2 -2
  8. package/dist/types/current/ad/AdBreakInfo.d.ts +160 -0
  9. package/dist/types/current/ad/AdBreakInfo.d.ts.map +1 -0
  10. package/dist/types/current/ad/AdBreakInfo.js +5 -0
  11. package/dist/types/current/ad/AdController.d.ts +229 -0
  12. package/dist/types/current/ad/AdController.d.ts.map +1 -0
  13. package/dist/types/current/ad/AdController.js +19 -0
  14. package/dist/types/current/ad/AdControllerImpl.d.ts +162 -0
  15. package/dist/types/current/ad/AdControllerImpl.d.ts.map +1 -0
  16. package/dist/types/current/ad/AdControllerImpl.js +741 -0
  17. package/dist/types/current/ad/AdError.d.ts +6 -0
  18. package/dist/types/current/ad/AdError.d.ts.map +1 -0
  19. package/dist/types/current/ad/AdError.js +14 -0
  20. package/dist/types/current/ad/AdsProvider.d.ts +28 -0
  21. package/dist/types/current/ad/AdsProvider.d.ts.map +1 -0
  22. package/dist/types/current/ad/AdsProvider.js +5 -0
  23. package/dist/types/current/ad/defaultAdLoadOptionsResolver.d.ts +12 -0
  24. package/dist/types/current/ad/defaultAdLoadOptionsResolver.d.ts.map +1 -0
  25. package/dist/types/current/ad/defaultAdLoadOptionsResolver.js +26 -0
  26. package/dist/types/current/ad/discoverHlsInterstitials.d.ts +22 -0
  27. package/dist/types/current/ad/discoverHlsInterstitials.d.ts.map +1 -0
  28. package/dist/types/current/ad/discoverHlsInterstitials.js +248 -0
  29. package/dist/types/current/drm/DrmControllerImpl.d.ts +6 -0
  30. package/dist/types/current/drm/DrmControllerImpl.d.ts.map +1 -1
  31. package/dist/types/current/drm/DrmControllerImpl.js +23 -1
  32. package/dist/types/current/playback/PlaybackControllerImpl.d.ts +1 -1
  33. package/dist/types/current/playback/createStallDetector.d.ts +43 -0
  34. package/dist/types/current/playback/createStallDetector.d.ts.map +1 -0
  35. package/dist/types/current/playback/createStallDetector.js +101 -0
  36. package/dist/types/current/playback/createStallMonitor.d.ts +45 -0
  37. package/dist/types/current/playback/createStallMonitor.d.ts.map +1 -0
  38. package/dist/types/current/playback/createStallMonitor.js +99 -0
  39. package/dist/types/current/streaming/AudioOptions.d.ts +66 -0
  40. package/dist/types/current/streaming/AudioOptions.d.ts.map +1 -0
  41. package/dist/types/current/streaming/AudioOptions.js +19 -0
  42. package/dist/types/current/streaming/LoadMetric.d.ts +72 -0
  43. package/dist/types/current/streaming/LoadMetric.d.ts.map +1 -0
  44. package/dist/types/current/streaming/LoadMetric.js +5 -0
  45. package/dist/types/current/streaming/ManifestControllerImpl.d.ts +43 -0
  46. package/dist/types/current/streaming/ManifestControllerImpl.d.ts.map +1 -0
  47. package/dist/types/current/streaming/ManifestControllerImpl.js +104 -0
  48. package/dist/types/current/streaming/buffering/codecDenylist.d.ts +23 -0
  49. package/dist/types/current/streaming/buffering/codecDenylist.d.ts.map +1 -0
  50. package/dist/types/current/streaming/buffering/codecDenylist.js +62 -0
  51. package/dist/types/current/streaming/createAllowedContentTypesValue.d.ts +30 -0
  52. package/dist/types/current/streaming/createAllowedContentTypesValue.d.ts.map +1 -0
  53. package/dist/types/current/streaming/createAllowedContentTypesValue.js +43 -0
  54. package/dist/types/current/streaming/createTimelineContentTypesValue.d.ts +21 -0
  55. package/dist/types/current/streaming/createTimelineContentTypesValue.d.ts.map +1 -0
  56. package/dist/types/current/streaming/createTimelineContentTypesValue.js +25 -0
  57. package/dist/types/current/streaming/mediaTimelineAccessibilityFilter.d.ts +35 -0
  58. package/dist/types/current/streaming/mediaTimelineAccessibilityFilter.d.ts.map +1 -0
  59. package/dist/types/current/streaming/mediaTimelineAccessibilityFilter.js +75 -0
  60. package/dist/types/current/text/HtmlTextTrackRenderer.d.ts +60 -0
  61. package/dist/types/current/text/HtmlTextTrackRenderer.d.ts.map +1 -0
  62. package/dist/types/current/text/HtmlTextTrackRenderer.js +231 -0
  63. package/dist/types/current/text/SidecarTextTrackController.d.ts +103 -0
  64. package/dist/types/current/text/SidecarTextTrackController.d.ts.map +1 -0
  65. package/dist/types/current/text/SidecarTextTrackController.js +250 -0
  66. package/dist/types/current/text/SidecarTextTrackLoader.d.ts +65 -0
  67. package/dist/types/current/text/SidecarTextTrackLoader.d.ts.map +1 -0
  68. package/dist/types/current/text/SidecarTextTrackLoader.js +150 -0
  69. package/dist/types/current/text/TextTrack.d.ts +179 -0
  70. package/dist/types/current/text/TextTrack.d.ts.map +1 -0
  71. package/dist/types/current/text/TextTrack.js +29 -0
  72. package/dist/types/current/text/TextTrackRenderer.d.ts +24 -0
  73. package/dist/types/current/text/TextTrackRenderer.d.ts.map +1 -0
  74. package/dist/types/current/text/TextTrackRenderer.js +5 -0
  75. package/dist/types/current/text/VttCueStyle.d.ts +41 -0
  76. package/dist/types/current/text/VttCueStyle.d.ts.map +1 -0
  77. package/dist/types/current/text/VttCueStyle.js +45 -0
  78. package/dist/types/current/text/discoverDashTextTracks.d.ts +24 -0
  79. package/dist/types/current/text/discoverDashTextTracks.d.ts.map +1 -0
  80. package/dist/types/current/text/discoverDashTextTracks.js +110 -0
  81. package/dist/types/current/text/discoverHlsTextTracks.d.ts +19 -0
  82. package/dist/types/current/text/discoverHlsTextTracks.d.ts.map +1 -0
  83. package/dist/types/current/text/discoverHlsTextTracks.js +49 -0
  84. package/dist/types/current/text/mediaTextTrackProvider.d.ts +34 -0
  85. package/dist/types/current/text/mediaTextTrackProvider.d.ts.map +1 -0
  86. package/dist/types/current/text/mediaTextTrackProvider.js +42 -0
  87. package/dist/types/current/text/parseWebVtt.d.ts +60 -0
  88. package/dist/types/current/text/parseWebVtt.d.ts.map +1 -0
  89. package/dist/types/current/text/parseWebVtt.js +249 -0
  90. package/dist/types/current/text/pickPreferredTextTrack.d.ts +15 -0
  91. package/dist/types/current/text/pickPreferredTextTrack.d.ts.map +1 -0
  92. package/dist/types/current/text/pickPreferredTextTrack.js +71 -0
  93. package/dist/types/current/track/SeekRange.d.ts +9 -0
  94. package/dist/types/current/track/SeekRange.d.ts.map +1 -0
  95. package/dist/types/current/track/SeekRange.js +5 -0
  96. package/dist/types/current/track/hls/HlsManifestData.d.ts +19 -0
  97. package/dist/types/current/track/hls/HlsManifestData.d.ts.map +1 -0
  98. package/dist/types/current/track/hls/HlsManifestData.js +5 -0
  99. package/dist/types/current/track/hls/createHlsManifestProvider.d.ts +6 -0
  100. package/dist/types/current/track/hls/createHlsManifestProvider.d.ts.map +1 -0
  101. package/dist/types/current/track/hls/createHlsManifestProvider.js +9 -0
  102. package/dist/types/current/track/inferLoadOptionsFromUri.d.ts +15 -0
  103. package/dist/types/current/track/inferLoadOptionsFromUri.d.ts.map +1 -0
  104. package/dist/types/current/track/inferLoadOptionsFromUri.js +55 -0
  105. package/dist/types/current/track/mse/MseTrack.d.ts +0 -1
  106. package/dist/types/current/track/mse/MseTrack.d.ts.map +1 -1
  107. package/dist/types/current/track/mse/MseTrack.js +4 -5
  108. package/dist/types/current/tsconfig.tsbuildinfo +1 -1
  109. package/dist/types/current/util/media/codecOverrides.d.ts +33 -0
  110. package/dist/types/current/util/media/codecOverrides.d.ts.map +1 -0
  111. package/dist/types/current/util/media/codecOverrides.js +37 -0
  112. package/dist/types/current/util/media/codecSupport.d.ts +6 -0
  113. package/dist/types/current/util/media/codecSupport.d.ts.map +1 -0
  114. package/dist/types/current/util/media/codecSupport.js +17 -0
  115. package/dist/types/current/util/media/mimeType.d.ts +8 -0
  116. package/dist/types/current/util/media/mimeType.d.ts.map +1 -0
  117. package/dist/types/current/util/media/mimeType.js +13 -0
  118. package/dist/types/ts3.7/ad/AdBreakInfo.d.ts +160 -0
  119. package/dist/types/ts3.7/ad/AdController.d.ts +243 -0
  120. package/dist/types/ts3.7/ad/AdControllerImpl.d.ts +162 -0
  121. package/dist/types/ts3.7/ad/AdError.d.ts +6 -0
  122. package/dist/types/ts3.7/ad/AdsProvider.d.ts +28 -0
  123. package/dist/types/ts3.7/ad/defaultAdLoadOptionsResolver.d.ts +12 -0
  124. package/dist/types/ts3.7/ad/discoverHlsInterstitials.d.ts +22 -0
  125. package/dist/types/ts3.7/drm/DrmControllerImpl.d.ts +6 -0
  126. package/dist/types/ts3.7/playback/PlaybackControllerImpl.d.ts +1 -1
  127. package/dist/types/ts3.7/playback/createStallDetector.d.ts +43 -0
  128. package/dist/types/ts3.7/playback/createStallMonitor.d.ts +45 -0
  129. package/dist/types/ts3.7/streaming/AudioOptions.d.ts +66 -0
  130. package/dist/types/ts3.7/streaming/LoadMetric.d.ts +72 -0
  131. package/dist/types/ts3.7/streaming/ManifestControllerImpl.d.ts +40 -0
  132. package/dist/types/ts3.7/streaming/buffering/codecDenylist.d.ts +23 -0
  133. package/dist/types/ts3.7/streaming/createAllowedContentTypesValue.d.ts +30 -0
  134. package/dist/types/ts3.7/streaming/createTimelineContentTypesValue.d.ts +21 -0
  135. package/dist/types/ts3.7/streaming/mediaTimelineAccessibilityFilter.d.ts +35 -0
  136. package/dist/types/ts3.7/text/HtmlTextTrackRenderer.d.ts +60 -0
  137. package/dist/types/ts3.7/text/SidecarTextTrackController.d.ts +103 -0
  138. package/dist/types/ts3.7/text/SidecarTextTrackLoader.d.ts +65 -0
  139. package/dist/types/ts3.7/text/TextTrack.d.ts +183 -0
  140. package/dist/types/ts3.7/text/TextTrackRenderer.d.ts +24 -0
  141. package/dist/types/ts3.7/text/VttCueStyle.d.ts +41 -0
  142. package/dist/types/ts3.7/text/discoverDashTextTracks.d.ts +24 -0
  143. package/dist/types/ts3.7/text/discoverHlsTextTracks.d.ts +19 -0
  144. package/dist/types/ts3.7/text/mediaTextTrackProvider.d.ts +34 -0
  145. package/dist/types/ts3.7/text/parseWebVtt.d.ts +60 -0
  146. package/dist/types/ts3.7/text/pickPreferredTextTrack.d.ts +15 -0
  147. package/dist/types/ts3.7/track/SeekRange.d.ts +9 -0
  148. package/dist/types/ts3.7/track/hls/HlsManifestData.d.ts +19 -0
  149. package/dist/types/ts3.7/track/hls/createHlsManifestProvider.d.ts +6 -0
  150. package/dist/types/ts3.7/track/inferLoadOptionsFromUri.d.ts +15 -0
  151. package/dist/types/ts3.7/track/mse/MseTrack.d.ts +0 -1
  152. package/dist/types/ts3.7/util/media/codecOverrides.d.ts +33 -0
  153. package/dist/types/ts3.7/util/media/codecSupport.d.ts +6 -0
  154. package/dist/types/ts3.7/util/media/mimeType.d.ts +8 -0
  155. package/dist/types/ts4.1/ad/AdBreakInfo.d.ts +160 -0
  156. package/dist/types/ts4.1/ad/AdController.d.ts +243 -0
  157. package/dist/types/ts4.1/ad/AdControllerImpl.d.ts +162 -0
  158. package/dist/types/ts4.1/ad/AdError.d.ts +6 -0
  159. package/dist/types/ts4.1/ad/AdsProvider.d.ts +28 -0
  160. package/dist/types/ts4.1/ad/defaultAdLoadOptionsResolver.d.ts +12 -0
  161. package/dist/types/ts4.1/ad/discoverHlsInterstitials.d.ts +22 -0
  162. package/dist/types/ts4.1/drm/DrmControllerImpl.d.ts +6 -0
  163. package/dist/types/ts4.1/playback/PlaybackControllerImpl.d.ts +1 -1
  164. package/dist/types/ts4.1/playback/createStallDetector.d.ts +43 -0
  165. package/dist/types/ts4.1/playback/createStallMonitor.d.ts +45 -0
  166. package/dist/types/ts4.1/streaming/AudioOptions.d.ts +66 -0
  167. package/dist/types/ts4.1/streaming/LoadMetric.d.ts +72 -0
  168. package/dist/types/ts4.1/streaming/ManifestControllerImpl.d.ts +40 -0
  169. package/dist/types/ts4.1/streaming/buffering/codecDenylist.d.ts +23 -0
  170. package/dist/types/ts4.1/streaming/createAllowedContentTypesValue.d.ts +30 -0
  171. package/dist/types/ts4.1/streaming/createTimelineContentTypesValue.d.ts +21 -0
  172. package/dist/types/ts4.1/streaming/mediaTimelineAccessibilityFilter.d.ts +35 -0
  173. package/dist/types/ts4.1/text/HtmlTextTrackRenderer.d.ts +60 -0
  174. package/dist/types/ts4.1/text/SidecarTextTrackController.d.ts +104 -0
  175. package/dist/types/ts4.1/text/SidecarTextTrackLoader.d.ts +65 -0
  176. package/dist/types/ts4.1/text/TextTrack.d.ts +183 -0
  177. package/dist/types/ts4.1/text/TextTrackRenderer.d.ts +24 -0
  178. package/dist/types/ts4.1/text/VttCueStyle.d.ts +41 -0
  179. package/dist/types/ts4.1/text/discoverDashTextTracks.d.ts +24 -0
  180. package/dist/types/ts4.1/text/discoverHlsTextTracks.d.ts +19 -0
  181. package/dist/types/ts4.1/text/mediaTextTrackProvider.d.ts +34 -0
  182. package/dist/types/ts4.1/text/parseWebVtt.d.ts +60 -0
  183. package/dist/types/ts4.1/text/pickPreferredTextTrack.d.ts +15 -0
  184. package/dist/types/ts4.1/track/SeekRange.d.ts +9 -0
  185. package/dist/types/ts4.1/track/hls/HlsManifestData.d.ts +19 -0
  186. package/dist/types/ts4.1/track/hls/createHlsManifestProvider.d.ts +6 -0
  187. package/dist/types/ts4.1/track/inferLoadOptionsFromUri.d.ts +15 -0
  188. package/dist/types/ts4.1/track/mse/MseTrack.d.ts +0 -1
  189. package/dist/types/ts4.1/util/media/codecOverrides.d.ts +33 -0
  190. package/dist/types/ts4.1/util/media/codecSupport.d.ts +6 -0
  191. package/dist/types/ts4.1/util/media/mimeType.d.ts +8 -0
  192. package/dist/types/ts4.7/ad/AdBreakInfo.d.ts +160 -0
  193. package/dist/types/ts4.7/ad/AdController.d.ts +243 -0
  194. package/dist/types/ts4.7/ad/AdControllerImpl.d.ts +162 -0
  195. package/dist/types/ts4.7/ad/AdError.d.ts +6 -0
  196. package/dist/types/ts4.7/ad/AdsProvider.d.ts +28 -0
  197. package/dist/types/ts4.7/ad/defaultAdLoadOptionsResolver.d.ts +12 -0
  198. package/dist/types/ts4.7/ad/discoverHlsInterstitials.d.ts +22 -0
  199. package/dist/types/ts4.7/drm/DrmControllerImpl.d.ts +6 -0
  200. package/dist/types/ts4.7/playback/PlaybackControllerImpl.d.ts +1 -1
  201. package/dist/types/ts4.7/playback/createStallDetector.d.ts +43 -0
  202. package/dist/types/ts4.7/playback/createStallMonitor.d.ts +45 -0
  203. package/dist/types/ts4.7/streaming/AudioOptions.d.ts +66 -0
  204. package/dist/types/ts4.7/streaming/LoadMetric.d.ts +72 -0
  205. package/dist/types/ts4.7/streaming/ManifestControllerImpl.d.ts +43 -0
  206. package/dist/types/ts4.7/streaming/buffering/codecDenylist.d.ts +23 -0
  207. package/dist/types/ts4.7/streaming/createAllowedContentTypesValue.d.ts +30 -0
  208. package/dist/types/ts4.7/streaming/createTimelineContentTypesValue.d.ts +21 -0
  209. package/dist/types/ts4.7/streaming/mediaTimelineAccessibilityFilter.d.ts +35 -0
  210. package/dist/types/ts4.7/text/HtmlTextTrackRenderer.d.ts +60 -0
  211. package/dist/types/ts4.7/text/SidecarTextTrackController.d.ts +103 -0
  212. package/dist/types/ts4.7/text/SidecarTextTrackLoader.d.ts +65 -0
  213. package/dist/types/ts4.7/text/TextTrack.d.ts +183 -0
  214. package/dist/types/ts4.7/text/TextTrackRenderer.d.ts +24 -0
  215. package/dist/types/ts4.7/text/VttCueStyle.d.ts +41 -0
  216. package/dist/types/ts4.7/text/discoverDashTextTracks.d.ts +24 -0
  217. package/dist/types/ts4.7/text/discoverHlsTextTracks.d.ts +19 -0
  218. package/dist/types/ts4.7/text/mediaTextTrackProvider.d.ts +34 -0
  219. package/dist/types/ts4.7/text/parseWebVtt.d.ts +60 -0
  220. package/dist/types/ts4.7/text/pickPreferredTextTrack.d.ts +15 -0
  221. package/dist/types/ts4.7/track/SeekRange.d.ts +9 -0
  222. package/dist/types/ts4.7/track/hls/HlsManifestData.d.ts +19 -0
  223. package/dist/types/ts4.7/track/hls/createHlsManifestProvider.d.ts +6 -0
  224. package/dist/types/ts4.7/track/inferLoadOptionsFromUri.d.ts +15 -0
  225. package/dist/types/ts4.7/track/mse/MseTrack.d.ts +0 -1
  226. package/dist/types/ts4.7/util/media/codecOverrides.d.ts +33 -0
  227. package/dist/types/ts4.7/util/media/codecSupport.d.ts +6 -0
  228. package/dist/types/ts4.7/util/media/mimeType.d.ts +8 -0
  229. package/dist/unit/types/current/ad/AdController.test.d.ts +2 -0
  230. package/dist/unit/types/current/ad/AdController.test.d.ts.map +1 -0
  231. package/dist/unit/types/current/ad/AdController.test.js +10 -0
  232. package/dist/unit/types/current/ad/AdControllerImpl.test.d.ts +2 -0
  233. package/dist/unit/types/current/ad/AdControllerImpl.test.d.ts.map +1 -0
  234. package/dist/unit/types/current/ad/AdControllerImpl.test.js +1654 -0
  235. package/dist/unit/types/current/ad/defaultAdLoadOptionsResolver.test.d.ts +2 -0
  236. package/dist/unit/types/current/ad/defaultAdLoadOptionsResolver.test.d.ts.map +1 -0
  237. package/dist/unit/types/current/ad/defaultAdLoadOptionsResolver.test.js +56 -0
  238. package/dist/unit/types/current/ad/discoverHlsInterstitials.test.d.ts +2 -0
  239. package/dist/unit/types/current/ad/discoverHlsInterstitials.test.d.ts.map +1 -0
  240. package/dist/unit/types/current/ad/discoverHlsInterstitials.test.js +757 -0
  241. package/dist/unit/types/current/drm/DrmControllerImpl.test.js +96 -2
  242. package/dist/unit/types/current/playback/createStallDetector.test.d.ts +2 -0
  243. package/dist/unit/types/current/playback/createStallDetector.test.d.ts.map +1 -0
  244. package/dist/unit/types/current/playback/createStallDetector.test.js +163 -0
  245. package/dist/unit/types/current/playback/createStallMonitor.test.d.ts +2 -0
  246. package/dist/unit/types/current/playback/createStallMonitor.test.d.ts.map +1 -0
  247. package/dist/unit/types/current/playback/createStallMonitor.test.js +163 -0
  248. package/dist/unit/types/current/streaming/ManifestControllerImpl.test.d.ts +2 -0
  249. package/dist/unit/types/current/streaming/ManifestControllerImpl.test.d.ts.map +1 -0
  250. package/dist/unit/types/current/streaming/ManifestControllerImpl.test.js +197 -0
  251. package/dist/unit/types/current/streaming/MseTrack.test.js +15 -0
  252. package/dist/unit/types/current/streaming/buffering/codecDenylist.test.d.ts +2 -0
  253. package/dist/unit/types/current/streaming/buffering/codecDenylist.test.d.ts.map +1 -0
  254. package/dist/unit/types/current/streaming/buffering/codecDenylist.test.js +56 -0
  255. package/dist/unit/types/current/streaming/createAllowedContentTypesValue.test.d.ts +2 -0
  256. package/dist/unit/types/current/streaming/createAllowedContentTypesValue.test.d.ts.map +1 -0
  257. package/dist/unit/types/current/streaming/createAllowedContentTypesValue.test.js +77 -0
  258. package/dist/unit/types/current/streaming/createTimelineContentTypesValue.test.d.ts +2 -0
  259. package/dist/unit/types/current/streaming/createTimelineContentTypesValue.test.d.ts.map +1 -0
  260. package/dist/unit/types/current/streaming/createTimelineContentTypesValue.test.js +57 -0
  261. package/dist/unit/types/current/streaming/mediaTimelineAccessibilityFilter.test.d.ts +2 -0
  262. package/dist/unit/types/current/streaming/mediaTimelineAccessibilityFilter.test.d.ts.map +1 -0
  263. package/dist/unit/types/current/streaming/mediaTimelineAccessibilityFilter.test.js +99 -0
  264. package/dist/unit/types/current/text/HtmlTextTrackRenderer.test.d.ts +2 -0
  265. package/dist/unit/types/current/text/HtmlTextTrackRenderer.test.d.ts.map +1 -0
  266. package/dist/unit/types/current/text/HtmlTextTrackRenderer.test.js +231 -0
  267. package/dist/unit/types/current/text/SidecarTextTrackController.test.d.ts +2 -0
  268. package/dist/unit/types/current/text/SidecarTextTrackController.test.d.ts.map +1 -0
  269. package/dist/unit/types/current/text/SidecarTextTrackController.test.js +686 -0
  270. package/dist/unit/types/current/text/SidecarTextTrackLoader.test.d.ts +2 -0
  271. package/dist/unit/types/current/text/SidecarTextTrackLoader.test.d.ts.map +1 -0
  272. package/dist/unit/types/current/text/SidecarTextTrackLoader.test.js +365 -0
  273. package/dist/unit/types/current/text/TextTrack.test.d.ts +2 -0
  274. package/dist/unit/types/current/text/TextTrack.test.d.ts.map +1 -0
  275. package/dist/unit/types/current/text/TextTrack.test.js +12 -0
  276. package/dist/unit/types/current/text/VttCueStyle.test.d.ts +2 -0
  277. package/dist/unit/types/current/text/VttCueStyle.test.d.ts.map +1 -0
  278. package/dist/unit/types/current/text/VttCueStyle.test.js +76 -0
  279. package/dist/unit/types/current/text/discoverDashTextTracks.test.d.ts +2 -0
  280. package/dist/unit/types/current/text/discoverDashTextTracks.test.d.ts.map +1 -0
  281. package/dist/unit/types/current/text/discoverDashTextTracks.test.js +216 -0
  282. package/dist/unit/types/current/text/discoverHlsTextTracks.test.d.ts +2 -0
  283. package/dist/unit/types/current/text/discoverHlsTextTracks.test.d.ts.map +1 -0
  284. package/dist/unit/types/current/text/discoverHlsTextTracks.test.js +177 -0
  285. package/dist/unit/types/current/text/mediaTextTrackProvider.test.d.ts +2 -0
  286. package/dist/unit/types/current/text/mediaTextTrackProvider.test.d.ts.map +1 -0
  287. package/dist/unit/types/current/text/mediaTextTrackProvider.test.js +86 -0
  288. package/dist/unit/types/current/text/parseWebVtt.test.d.ts +2 -0
  289. package/dist/unit/types/current/text/parseWebVtt.test.d.ts.map +1 -0
  290. package/dist/unit/types/current/text/parseWebVtt.test.js +419 -0
  291. package/dist/unit/types/current/text/pickPreferredTextTrack.test.d.ts +2 -0
  292. package/dist/unit/types/current/text/pickPreferredTextTrack.test.d.ts.map +1 -0
  293. package/dist/unit/types/current/text/pickPreferredTextTrack.test.js +78 -0
  294. package/dist/unit/types/current/track/inferLoadOptionsFromUri.test.d.ts +2 -0
  295. package/dist/unit/types/current/track/inferLoadOptionsFromUri.test.d.ts.map +1 -0
  296. package/dist/unit/types/current/track/inferLoadOptionsFromUri.test.js +165 -0
  297. package/dist/unit/types/current/tsconfig.tsbuildinfo +1 -1
  298. package/dist/unit/types/current/util/media/codecOverrides.test.d.ts +2 -0
  299. package/dist/unit/types/current/util/media/codecOverrides.test.d.ts.map +1 -0
  300. package/dist/unit/types/current/util/media/codecOverrides.test.js +42 -0
  301. package/dist/unit/types/current/util/media/codecSupport.test.d.ts +2 -0
  302. package/dist/unit/types/current/util/media/codecSupport.test.d.ts.map +1 -0
  303. package/dist/unit/types/current/util/media/codecSupport.test.js +26 -0
  304. package/dist/unit/types/current/util/media/mimeType.test.d.ts +2 -0
  305. package/dist/unit/types/current/util/media/mimeType.test.d.ts.map +1 -0
  306. package/dist/unit/types/current/util/media/mimeType.test.js +22 -0
  307. package/dist/unit/types/current/vinyl/VinylPlayerAdBreaks.test.d.ts +2 -0
  308. package/dist/unit/types/current/vinyl/VinylPlayerAdBreaks.test.d.ts.map +1 -0
  309. package/dist/unit/types/current/vinyl/VinylPlayerAdBreaks.test.js +142 -0
  310. package/dist/unit/types/current/vinyl/VinylPlayerTextTracks.test.d.ts +2 -0
  311. package/dist/unit/types/current/vinyl/VinylPlayerTextTracks.test.d.ts.map +1 -0
  312. package/dist/unit/types/current/vinyl/VinylPlayerTextTracks.test.js +188 -0
  313. package/dist/vinylTestUtil/types/current/mock/ad/MockAdController.d.ts +15 -0
  314. package/dist/vinylTestUtil/types/current/mock/ad/MockAdController.d.ts.map +1 -0
  315. package/dist/vinylTestUtil/types/current/mock/ad/MockAdController.js +26 -0
  316. package/dist/vinylTestUtil/types/current/mock/dash/mockDashManifest.d.ts +84 -84
  317. package/dist/vinylTestUtil/types/current/mock/text/MockTextTrackController.d.ts +10 -0
  318. package/dist/vinylTestUtil/types/current/mock/text/MockTextTrackController.d.ts.map +1 -0
  319. package/dist/vinylTestUtil/types/current/mock/text/MockTextTrackController.js +14 -0
  320. package/dist/vinylTestUtil/types/current/tsconfig.tsbuildinfo +1 -1
  321. package/dist/vinylTestUtil/types/ts3.7/mock/ad/MockAdController.d.ts +15 -0
  322. package/dist/vinylTestUtil/types/ts3.7/mock/dash/mockDashManifest.d.ts +84 -84
  323. package/dist/vinylTestUtil/types/ts3.7/mock/text/MockTextTrackController.d.ts +10 -0
  324. package/dist/vinylTestUtil/types/ts4.1/mock/ad/MockAdController.d.ts +15 -0
  325. package/dist/vinylTestUtil/types/ts4.1/mock/dash/mockDashManifest.d.ts +84 -84
  326. package/dist/vinylTestUtil/types/ts4.1/mock/text/MockTextTrackController.d.ts +10 -0
  327. package/dist/vinylTestUtil/types/ts4.7/mock/ad/MockAdController.d.ts +15 -0
  328. package/dist/vinylTestUtil/types/ts4.7/mock/dash/mockDashManifest.d.ts +84 -84
  329. package/dist/vinylTestUtil/types/ts4.7/mock/text/MockTextTrackController.d.ts +10 -0
  330. package/package.json +10 -11
@@ -0,0 +1,419 @@
1
+ /*
2
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ import { parseWebVtt } from '@amazon/vinyl';
6
+ import { ValidationError } from '@amazon/vinyl-util';
7
+ describe('parseWebVtt', () => {
8
+ it('parses a minimal cue', () => {
9
+ const text = `WEBVTT
10
+
11
+ 00:00:01.000 --> 00:00:02.500
12
+ Hello world`;
13
+ const doc = parseWebVtt(text);
14
+ expect(doc.cues).toEqual([
15
+ {
16
+ id: null,
17
+ startTime: 1,
18
+ endTime: 2.5,
19
+ text: 'Hello world',
20
+ },
21
+ ]);
22
+ });
23
+ it('parses a cue identifier', () => {
24
+ const text = `WEBVTT
25
+
26
+ cue-1
27
+ 00:00:01.000 --> 00:00:02.000
28
+ text payload`;
29
+ expect(parseWebVtt(text).cues).toEqual([
30
+ {
31
+ id: 'cue-1',
32
+ startTime: 1,
33
+ endTime: 2,
34
+ text: 'text payload',
35
+ },
36
+ ]);
37
+ });
38
+ it('parses multiple cues with multi-line text', () => {
39
+ const text = `WEBVTT
40
+
41
+ 00:00:00.500 --> 00:00:01.000
42
+ line one
43
+ line two
44
+
45
+ 00:00:01.000 --> 00:00:02.000
46
+ second cue`;
47
+ expect(parseWebVtt(text).cues).toEqual([
48
+ {
49
+ id: null,
50
+ startTime: 0.5,
51
+ endTime: 1,
52
+ text: 'line one\nline two',
53
+ },
54
+ {
55
+ id: null,
56
+ startTime: 1,
57
+ endTime: 2,
58
+ text: 'second cue',
59
+ },
60
+ ]);
61
+ });
62
+ it('parses MM:SS.mmm timestamps without an hours field', () => {
63
+ const text = `WEBVTT
64
+
65
+ 10:30.500 --> 11:45.250
66
+ brief`;
67
+ const cue = parseWebVtt(text).cues[0];
68
+ expect(cue.startTime).toBeCloseTo(630.5, 6);
69
+ expect(cue.endTime).toBeCloseTo(705.25, 6);
70
+ });
71
+ it('parses HH:MM:SS.mmm timestamps', () => {
72
+ const text = `WEBVTT
73
+
74
+ 01:02:03.400 --> 01:02:04.500
75
+ deep`;
76
+ const cue = parseWebVtt(text).cues[0];
77
+ expect(cue.startTime).toBeCloseTo(3723.4, 6);
78
+ expect(cue.endTime).toBeCloseTo(3724.5, 6);
79
+ });
80
+ it('strips a UTF-8 BOM', () => {
81
+ const text = 'WEBVTT\n\n00:00:01.000 --> 00:00:02.000\nx';
82
+ expect(parseWebVtt(text).cues.length).toBe(1);
83
+ });
84
+ it('accepts CRLF line endings', () => {
85
+ const text = `WEBVTT\r\n\r\n00:00:01.000 --> 00:00:02.000\r\ncrlf`;
86
+ expect(parseWebVtt(text).cues[0].text).toBe('crlf');
87
+ });
88
+ it('skips NOTE blocks', () => {
89
+ const text = `WEBVTT
90
+
91
+ NOTE this is a comment
92
+ that spans multiple lines
93
+
94
+ 00:00:01.000 --> 00:00:02.000
95
+ hello`;
96
+ const doc = parseWebVtt(text);
97
+ expect(doc.cues.length).toBe(1);
98
+ expect(doc.cues[0].text).toBe('hello');
99
+ });
100
+ it('skips standalone NOTE block', () => {
101
+ const text = `WEBVTT
102
+
103
+ NOTE
104
+ single line note
105
+
106
+ 00:00:01.000 --> 00:00:02.000
107
+ ok`;
108
+ const doc = parseWebVtt(text);
109
+ expect(doc.cues.length).toBe(1);
110
+ });
111
+ it('captures STYLE block CSS while still parsing cues', () => {
112
+ const text = `WEBVTT
113
+
114
+ STYLE
115
+ ::cue(.loud) { font-weight: bold }
116
+
117
+ STYLE
118
+ ::cue { color: red }
119
+
120
+ 00:00:01.000 --> 00:00:02.000
121
+ styled`;
122
+ const doc = parseWebVtt(text);
123
+ expect(doc.cues.length).toBe(1);
124
+ expect(doc.styles).toEqual([
125
+ '::cue(.loud) { font-weight: bold }',
126
+ '::cue { color: red }',
127
+ ]);
128
+ });
129
+ it('reports no styles when there are no STYLE blocks', () => {
130
+ const text = `WEBVTT
131
+
132
+ 00:00:01.000 --> 00:00:02.000
133
+ x`;
134
+ expect(parseWebVtt(text).styles).toEqual([]);
135
+ });
136
+ it('skips REGION blocks', () => {
137
+ const text = `WEBVTT
138
+
139
+ REGION
140
+ id:fred
141
+ width:40%
142
+
143
+ 00:00:01.000 --> 00:00:02.000
144
+ regional`;
145
+ const doc = parseWebVtt(text);
146
+ expect(doc.cues.length).toBe(1);
147
+ expect(doc.styles).toEqual([]);
148
+ });
149
+ it('parses cue settings on the timing line', () => {
150
+ const text = `WEBVTT
151
+
152
+ 00:00:01.000 --> 00:00:02.000 line:50% align:start
153
+ positioned`;
154
+ const cue = parseWebVtt(text).cues[0];
155
+ expect(cue.text).toBe('positioned');
156
+ expect(cue.settings).toEqual({
157
+ line: 50,
158
+ snapToLines: false,
159
+ align: 'start',
160
+ });
161
+ });
162
+ it('parses integer/negative lines as snap-to-lines, with lineAlign', () => {
163
+ const text = `WEBVTT
164
+
165
+ 00:00:01.000 --> 00:00:02.000 line:-3,end
166
+ a
167
+
168
+ 00:00:03.000 --> 00:00:04.000 line:5
169
+ b`;
170
+ const [a, b] = parseWebVtt(text).cues;
171
+ expect(a.settings).toEqual({
172
+ line: -3,
173
+ snapToLines: true,
174
+ lineAlign: 'end',
175
+ });
176
+ expect(b.settings).toEqual({ line: 5, snapToLines: true });
177
+ });
178
+ it("maps the legacy 'middle' keyword to 'center'", () => {
179
+ const text = `WEBVTT
180
+
181
+ 00:00:01.000 --> 00:00:02.000 align:middle line:85%,middle position:50%,middle
182
+ a`;
183
+ expect(parseWebVtt(text).cues[0].settings).toEqual({
184
+ align: 'center',
185
+ line: 85,
186
+ snapToLines: false,
187
+ lineAlign: 'center',
188
+ position: 50,
189
+ positionAlign: 'center',
190
+ });
191
+ });
192
+ it('parses position (with align), size and vertical', () => {
193
+ const text = `WEBVTT
194
+
195
+ 00:00:01.000 --> 00:00:02.000 position:20%,line-left size:80% vertical:rl
196
+ a`;
197
+ expect(parseWebVtt(text).cues[0].settings).toEqual({
198
+ position: 20,
199
+ positionAlign: 'line-left',
200
+ size: 80,
201
+ vertical: 'rl',
202
+ });
203
+ });
204
+ it('omits settings and skips malformed/unknown tokens', () => {
205
+ const text = `WEBVTT
206
+
207
+ 00:00:01.000 --> 00:00:02.000
208
+ plain
209
+
210
+ 00:00:03.000 --> 00:00:04.000 align:bogus size:oops region:foo bareword
211
+ b`;
212
+ const [plain, b] = parseWebVtt(text).cues;
213
+ expect(plain.settings).toBeUndefined();
214
+ // align invalid, size not a %, unknown key, and a colon-less token.
215
+ expect(b.settings).toBeUndefined();
216
+ });
217
+ it('skips malformed line/position/percent values and invalid aligns', () => {
218
+ const text = `WEBVTT
219
+
220
+ 00:00:01.000 --> 00:00:02.000 line:x% size:y%
221
+ a
222
+
223
+ 00:00:03.000 --> 00:00:04.000 line:1.5 position:bad
224
+ b
225
+
226
+ 00:00:05.000 --> 00:00:06.000 line:5,bogus position:20%,nope
227
+ c`;
228
+ const [a, b, c] = parseWebVtt(text).cues;
229
+ expect(a.settings).toBeUndefined(); // non-numeric percentages → dropped
230
+ expect(b.settings).toBeUndefined(); // non-integer line, non-% position
231
+ // Valid values kept; invalid *Align keywords dropped.
232
+ expect(c.settings).toEqual({
233
+ line: 5,
234
+ snapToLines: true,
235
+ position: 20,
236
+ });
237
+ });
238
+ it('skips a malformed cue and continues', () => {
239
+ const text = `WEBVTT
240
+
241
+ 00:00:01.000 --> NOT-A-TIME
242
+ broken cue
243
+ should be skipped
244
+
245
+ 00:00:02.000 --> 00:00:03.000
246
+ good`;
247
+ const cues = parseWebVtt(text).cues;
248
+ expect(cues.length).toBe(1);
249
+ expect(cues[0].text).toBe('good');
250
+ });
251
+ it('skips a line with --> but an invalid start timestamp', () => {
252
+ const text = `WEBVTT
253
+
254
+ BForced --> 00:00:02.000
255
+ skipped
256
+
257
+ 00:00:02.000 --> 00:00:03.000
258
+ good`;
259
+ const cues = parseWebVtt(text).cues;
260
+ expect(cues.length).toBe(1);
261
+ expect(cues[0].text).toBe('good');
262
+ });
263
+ it('ignores unparseable text glued after the end timestamp', () => {
264
+ // Per the spec, timestamp collection stops after the milliseconds; any
265
+ // trailing text is parsed as (here, invalid, ignored) cue settings.
266
+ const cue = parseWebVtt('WEBVTT\n\n00:00:01.000 --> 00:00:02.000x\ntext').cues[0];
267
+ expect(cue.endTime).toBe(2);
268
+ expect(cue.settings).toBeUndefined();
269
+ expect(cue.text).toBe('text');
270
+ });
271
+ it('parses multi-digit hours (spec allows two or more)', () => {
272
+ const cues = parseWebVtt('WEBVTT\n\n100:00:01.000 --> 100:00:02.500\nhi').cues;
273
+ expect(cues.length).toBe(1);
274
+ expect(cues[0].startTime).toBe(360001);
275
+ expect(cues[0].endTime).toBe(360002.5);
276
+ });
277
+ it('treats consecutive blank lines between cues as separators', () => {
278
+ const text = 'WEBVTT\n\n00:00:01.000 --> 00:00:02.000\none\n\n\n' +
279
+ '00:00:03.000 --> 00:00:04.000\ntwo';
280
+ expect(parseWebVtt(text).cues.map((c) => c.text)).toEqual([
281
+ 'one',
282
+ 'two',
283
+ ]);
284
+ });
285
+ // Each line exercises a distinct timestamp-parser rejection branch; all are
286
+ // treated as a (dropped) identifier so only the trailing valid cue survives.
287
+ for (const timing of [
288
+ '12 --> 00:00:02.000', // two digits then no ':'
289
+ '7 --> 00:00:02.000', // one digit then no second digit
290
+ '00:00:01.000 00:00:02.000', // no --> ⇒ treated as an identifier
291
+ '5:30.000 --> 00:00:02.000', // MM:SS minutes not two digits
292
+ '75:30.000 --> 00:00:02.000', // MM:SS minutes > 59
293
+ '12:34 --> 00:00:02.000', // seconds not terminated by '.'
294
+ '00:99:00.000 --> 00:00:02.000', // HH:MM:SS minutes > 59
295
+ '00:00:99.000 --> 00:00:02.000', // HH:MM:SS seconds > 59
296
+ '00:00:0.400 --> 00:00:02.000', // HH:MM:SS seconds not two digits
297
+ '12:3:45.000 --> 00:00:02.000', // minutes not two digits before ':'
298
+ '00:00:00 --> 00:00:02.000', // HH:MM:SS missing .mmm
299
+ '00:00:00.00 --> 00:00:02.000', // milliseconds only two digits
300
+ '00:00.0 --> 00:00:02.000', // milliseconds only one digit
301
+ '00:00. --> 00:00:02.000', // milliseconds missing
302
+ '12:ab --> 00:00:02.000', // non-digit minute/second
303
+ '00:00:01.0', // truncated timestamp at end of input
304
+ ]) {
305
+ it(`skips a line with an invalid timestamp: "${timing}"`, () => {
306
+ const text = `WEBVTT\n\n${timing}\nfiller\n\n00:00:05.000 --> 00:00:06.000\nok`;
307
+ expect(parseWebVtt(text).cues.map((c) => c.text)).toEqual(['ok']);
308
+ });
309
+ }
310
+ // Keyword prefixes (NOTES/REGIONAL/STYLES) are ordinary cue identifiers, not
311
+ // NOTE/REGION/STYLE blocks — this also exercises each keyword's fall-through.
312
+ for (const identifier of ['NOTES', 'REGIONAL', 'STYLES']) {
313
+ it(`treats keyword prefix "${identifier}" as an identifier`, () => {
314
+ const cues = parseWebVtt(`WEBVTT\n\n${identifier}\n00:00:01.000 --> 00:00:02.000\nhi`).cues;
315
+ expect(cues.length).toBe(1);
316
+ expect(cues[0].id).toBe(identifier);
317
+ });
318
+ }
319
+ it('normalizes CRLF line endings and splits CRLF-separated cues', () => {
320
+ const text = 'WEBVTT\r\n\r\n00:00:01.000 --> 00:00:02.000\r\nline one\r\nline two' +
321
+ '\r\n\r\n00:00:03.000 --> 00:00:04.000\r\nsecond';
322
+ expect(parseWebVtt(text).cues.map((c) => c.text)).toEqual([
323
+ 'line one\nline two',
324
+ 'second',
325
+ ]);
326
+ });
327
+ it('accepts a NOTE block at end of input', () => {
328
+ expect(parseWebVtt('WEBVTT\n\nNOTE').cues).toEqual([]);
329
+ });
330
+ it('handles input that ends mid-timestamp', () => {
331
+ expect(parseWebVtt('WEBVTT\n\n00:00:00.000 --> 00:00:0').cues).toEqual([]);
332
+ });
333
+ it('returns empty cues on header-only input', () => {
334
+ expect(parseWebVtt('WEBVTT\n').cues).toEqual([]);
335
+ });
336
+ it('throws on missing header', () => {
337
+ expect(() => parseWebVtt('not a vtt file')).toThrowMatching((e) => {
338
+ return e instanceof ValidationError;
339
+ });
340
+ });
341
+ it('throws on non-string input', () => {
342
+ expect(() => parseWebVtt(undefined)).toThrowMatching((e) => e instanceof ValidationError);
343
+ });
344
+ it('accepts header followed by extra description', () => {
345
+ const text = `WEBVTT - English subtitles
346
+
347
+ 00:00:01.000 --> 00:00:02.000
348
+ hi`;
349
+ expect(parseWebVtt(text).cues.length).toBe(1);
350
+ });
351
+ it('accepts header followed by tab', () => {
352
+ const text = `WEBVTT\t\n\n00:00:01.000 --> 00:00:02.000\nhi`;
353
+ expect(parseWebVtt(text).cues.length).toBe(1);
354
+ });
355
+ it('skips an HLS X-TIMESTAMP-MAP header line', () => {
356
+ // HLS captions place `X-TIMESTAMP-MAP=...` in the WebVTT header (per
357
+ // RFC 8216 §3.5). Without recognizing this as part of the header, the
358
+ // first cue in every segment gets consumed as a malformed identifier.
359
+ const text = `WEBVTT
360
+ X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
361
+
362
+ 00:00:00.250 --> 00:00:00.879
363
+ Welcome,
364
+
365
+ 00:00:01.000 --> 00:00:02.000
366
+ hi`;
367
+ const cues = parseWebVtt(text).cues;
368
+ expect(cues.length).toBe(2);
369
+ expect(cues[0].text).toBe('Welcome,');
370
+ expect(cues[1].text).toBe('hi');
371
+ });
372
+ it('skips WebVTT metadata header lines', () => {
373
+ // Metadata headers of the form `Name: value` between the signature
374
+ // and the first blank line are part of the file header.
375
+ const text = `WEBVTT
376
+ Kind: captions
377
+ Language: en
378
+
379
+ 00:00:01.000 --> 00:00:02.000
380
+ hi`;
381
+ const cues = parseWebVtt(text).cues;
382
+ expect(cues.length).toBe(1);
383
+ expect(cues[0].text).toBe('hi');
384
+ });
385
+ it('parses a cue that follows the signature with no blank line', () => {
386
+ // The header block ends at a timing line as well as at a blank line
387
+ // (WebVTT file parsing breaks out of the header loop on `-->`), so a
388
+ // document omitting the blank line still yields its cues.
389
+ const text = `WEBVTT
390
+ 00:00:01.000 --> 00:00:02.000
391
+ hi
392
+
393
+ 00:00:03.000 --> 00:00:04.000
394
+ there`;
395
+ const cues = parseWebVtt(text).cues;
396
+ expect(cues.length).toBe(2);
397
+ expect(cues[0].startTime).toBe(1);
398
+ expect(cues[0].text).toBe('hi');
399
+ expect(cues[1].text).toBe('there');
400
+ });
401
+ it('keeps header lines as header when a cue follows with no blank line', () => {
402
+ const text = `WEBVTT
403
+ Kind: captions
404
+ 00:00:01.000 --> 00:00:02.000
405
+ hi`;
406
+ const cues = parseWebVtt(text).cues;
407
+ expect(cues.length).toBe(1);
408
+ expect(cues[0].id).toBeNull();
409
+ expect(cues[0].text).toBe('hi');
410
+ });
411
+ it('handles trailing identifier without timing line', () => {
412
+ // Identifier with no following timing line - cue is dropped, parser
413
+ // breaks out cleanly without throwing.
414
+ const text = `WEBVTT
415
+
416
+ trailing-id`;
417
+ expect(parseWebVtt(text).cues).toEqual([]);
418
+ });
419
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=pickPreferredTextTrack.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pickPreferredTextTrack.test.d.ts","sourceRoot":"","sources":["../../../../../test/unit/text/pickPreferredTextTrack.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,78 @@
1
+ /*
2
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ import { pickPreferredTextTrack } from '@amazon/vinyl';
6
+ import { setMockNavigator, spyOnPropertySafe, } from '@amazon/vinyl-util/testUtil';
7
+ let nextId = 0;
8
+ function track(overrides = {}) {
9
+ return {
10
+ id: `t${nextId++}`,
11
+ kind: 'subtitles',
12
+ language: 'en',
13
+ label: '',
14
+ default: false,
15
+ forced: false,
16
+ characteristics: [],
17
+ uri: 'x.vtt',
18
+ mimeType: null,
19
+ ...overrides,
20
+ };
21
+ }
22
+ describe('pickPreferredTextTrack', () => {
23
+ it('falls back to navigator.languages when the preference is null', () => {
24
+ setMockNavigator().languages = ['en'];
25
+ const en = track({ id: 'en', language: 'en' });
26
+ expect(pickPreferredTextTrack([en], null)).toBe(en);
27
+ });
28
+ it('returns null when no track relates to navigator.languages', () => {
29
+ setMockNavigator().languages = ['en'];
30
+ expect(pickPreferredTextTrack([track({ language: 'ja' })], null)).toBeNull();
31
+ });
32
+ it('returns null for a null preference when navigator is unavailable', () => {
33
+ spyOnPropertySafe(global, 'navigator').and.returnValue(undefined);
34
+ expect(pickPreferredTextTrack([track()], null)).toBeNull();
35
+ });
36
+ it('returns null when there are no tracks', () => {
37
+ expect(pickPreferredTextTrack([], 'en')).toBeNull();
38
+ });
39
+ it('selects the track matching the preferred language', () => {
40
+ const en = track({ id: 'en', language: 'en' });
41
+ const es = track({ id: 'es', language: 'es' });
42
+ expect(pickPreferredTextTrack([es, en], 'en')).toBe(en);
43
+ });
44
+ it('returns null when no track relates to the preference', () => {
45
+ expect(pickPreferredTextTrack([track({ language: 'es' })], 'ja')).toBeNull();
46
+ });
47
+ it('ignores tracks without a language tag', () => {
48
+ expect(pickPreferredTextTrack([track({ language: null })], 'en')).toBeNull();
49
+ });
50
+ it('prefers a full track over a forced-only track of the same language', () => {
51
+ const forced = track({ id: 'forced', language: 'en', forced: true });
52
+ const full = track({ id: 'full', language: 'en', forced: false });
53
+ expect(pickPreferredTextTrack([forced, full], 'en')).toBe(full);
54
+ });
55
+ it('breaks a remaining tie by the manifest-default flag', () => {
56
+ const a = track({ id: 'a', language: 'en', default: false });
57
+ const b = track({ id: 'b', language: 'en', default: true });
58
+ expect(pickPreferredTextTrack([a, b], 'en')).toBe(b);
59
+ });
60
+ it('honors preference order, earlier entries winning', () => {
61
+ const en = track({ id: 'en', language: 'en' });
62
+ const fr = track({ id: 'fr', language: 'fr' });
63
+ expect(pickPreferredTextTrack([en, fr], ['fr', 'en'])).toBe(fr);
64
+ expect(pickPreferredTextTrack([en, fr], ['en', 'fr'])).toBe(en);
65
+ });
66
+ it('matches a related language when no exact match exists', () => {
67
+ const enUs = track({ id: 'en-US', language: 'en-US' });
68
+ const es = track({ id: 'es', language: 'es' });
69
+ // 'en' is the parent of 'en-US' — related, so it should be chosen.
70
+ expect(pickPreferredTextTrack([es, enUs], 'en')).toBe(enUs);
71
+ });
72
+ it('prefers a closer language match over a more distant one', () => {
73
+ const enUs = track({ id: 'en-US', language: 'en-US' });
74
+ const enGb = track({ id: 'en-GB', language: 'en-GB' });
75
+ // Exact 'en-US' (relatedness 4) beats sibling 'en-GB' (relatedness 2).
76
+ expect(pickPreferredTextTrack([enGb, enUs], 'en-US')).toBe(enUs);
77
+ });
78
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=inferLoadOptionsFromUri.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inferLoadOptionsFromUri.test.d.ts","sourceRoot":"","sources":["../../../../../test/unit/track/inferLoadOptionsFromUri.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,165 @@
1
+ /*
2
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ import { createTrackLoadOptionsFromUrl, inferTrackTypeFromUrl, inferTrackTypeFromUrlPath, } from '@amazon/vinyl';
6
+ import { requesterWithRetryRef } from '@amazon/vinyl-util';
7
+ import { MockRequester, overrideGlobalInit } from '@amazon/vinyl-util/testUtil';
8
+ describe('inferTrackTypeFromUrlPath', () => {
9
+ it('returns hls for .m3u8 extension', () => {
10
+ expect(inferTrackTypeFromUrlPath('https://example.com/stream.m3u8')).toBe('hls');
11
+ });
12
+ it('returns hls for .m3u8 with query params', () => {
13
+ expect(inferTrackTypeFromUrlPath('https://example.com/stream.m3u8?token=abc')).toBe('hls');
14
+ });
15
+ it('returns dash for .mpd extension', () => {
16
+ expect(inferTrackTypeFromUrlPath('https://example.com/manifest.mpd')).toBe('dash');
17
+ });
18
+ it('returns dash for .mpd with query params', () => {
19
+ expect(inferTrackTypeFromUrlPath('https://example.com/manifest.mpd?v=1')).toBe('dash');
20
+ });
21
+ it('returns src for common media extensions', () => {
22
+ expect(inferTrackTypeFromUrlPath('https://example.com/audio.mp3')).toBe('src');
23
+ expect(inferTrackTypeFromUrlPath('https://example.com/video.mp4')).toBe('src');
24
+ expect(inferTrackTypeFromUrlPath('https://example.com/audio.aac')).toBe('src');
25
+ expect(inferTrackTypeFromUrlPath('https://example.com/video.webm')).toBe('src');
26
+ expect(inferTrackTypeFromUrlPath('https://example.com/audio.ogg')).toBe('src');
27
+ expect(inferTrackTypeFromUrlPath('https://example.com/audio.wav')).toBe('src');
28
+ expect(inferTrackTypeFromUrlPath('https://example.com/audio.m4a')).toBe('src');
29
+ expect(inferTrackTypeFromUrlPath('https://example.com/video.m4v')).toBe('src');
30
+ expect(inferTrackTypeFromUrlPath('https://example.com/audio.opus')).toBe('src');
31
+ });
32
+ it('returns src for media extensions with query params', () => {
33
+ expect(inferTrackTypeFromUrlPath('https://example.com/video.mp4?quality=high')).toBe('src');
34
+ });
35
+ it('returns null for unrecognized URIs', () => {
36
+ expect(inferTrackTypeFromUrlPath('https://example.com/api/stream')).toBeNull();
37
+ expect(inferTrackTypeFromUrlPath('https://example.com/data.json')).toBeNull();
38
+ });
39
+ });
40
+ /**
41
+ * Builds a minimal `fetch` Response stand-in that satisfies `requestWithRetry`
42
+ * (which reads `ok`/`status`/`headers` and rejects on non-ok responses).
43
+ */
44
+ function contentTypeResponse(contentType) {
45
+ return {
46
+ ok: true,
47
+ status: 200,
48
+ headers: {
49
+ get: (header) => header === 'content-type' ? contentType : null,
50
+ },
51
+ };
52
+ }
53
+ function notFoundResponse() {
54
+ return {
55
+ ok: false,
56
+ status: 404,
57
+ headers: { get: () => null },
58
+ };
59
+ }
60
+ describe('inferTrackTypeFromUrl', () => {
61
+ it('resolves from the extension without a network request', async () => {
62
+ const origFetch = globalThis.fetch;
63
+ const fetchSpy = jasmine.createSpy('fetch');
64
+ globalThis.fetch = fetchSpy;
65
+ try {
66
+ expect(await inferTrackTypeFromUrl('https://example.com/a.m3u8')).toBe('hls');
67
+ expect(fetchSpy).not.toHaveBeenCalled();
68
+ }
69
+ finally {
70
+ globalThis.fetch = origFetch;
71
+ }
72
+ });
73
+ it('falls through to a HEAD probe for extension-less URLs', async () => {
74
+ const origFetch = globalThis.fetch;
75
+ const fetchSpy = jasmine
76
+ .createSpy('fetch')
77
+ .and.resolveTo(contentTypeResponse('video/mp4'));
78
+ globalThis.fetch = fetchSpy;
79
+ try {
80
+ expect(await inferTrackTypeFromUrl('https://example.com/probe-fallthru')).toBe('src');
81
+ expect(fetchSpy).toHaveBeenCalledTimes(1);
82
+ expect(fetchSpy.calls.argsFor(0)[1]).toEqual(jasmine.objectContaining({ method: 'HEAD' }));
83
+ }
84
+ finally {
85
+ globalThis.fetch = origFetch;
86
+ }
87
+ });
88
+ });
89
+ describe('probeType (via inferTrackTypeFromUrl)', () => {
90
+ // Each spec uses a DISTINCT URL because probeType is memoized by URL, so a
91
+ // shared URL would leak a cached result into later specs.
92
+ async function probe(url, response) {
93
+ const origFetch = globalThis.fetch;
94
+ globalThis.fetch = jasmine.createSpy('fetch').and.resolveTo(response);
95
+ try {
96
+ return await inferTrackTypeFromUrl(url);
97
+ }
98
+ finally {
99
+ globalThis.fetch = origFetch;
100
+ }
101
+ }
102
+ it('maps application/dash+xml to dash', async () => {
103
+ expect(await probe('https://example.com/probe-dash', contentTypeResponse('application/dash+xml'))).toBe('dash');
104
+ });
105
+ it('maps an mpegurl content-type to hls', async () => {
106
+ expect(await probe('https://example.com/probe-hls', contentTypeResponse('application/vnd.apple.mpegurl'))).toBe('hls');
107
+ });
108
+ it('maps video/* content-types to src', async () => {
109
+ expect(await probe('https://example.com/probe-video', contentTypeResponse('video/mp4'))).toBe('src');
110
+ });
111
+ it('maps audio/* content-types to src', async () => {
112
+ expect(await probe('https://example.com/probe-audio', contentTypeResponse('audio/mpeg'))).toBe('src');
113
+ });
114
+ it('returns null for an unrecognized content-type', async () => {
115
+ expect(await probe('https://example.com/probe-unknown', contentTypeResponse('application/json'))).toBeNull();
116
+ });
117
+ it('returns null when the content-type header is missing', async () => {
118
+ expect(await probe('https://example.com/probe-no-content-type', contentTypeResponse(null))).toBeNull();
119
+ });
120
+ it('returns null for a non-ok response', async () => {
121
+ expect(await probe('https://example.com/probe-not-found', notFoundResponse())).toBeNull();
122
+ });
123
+ it('returns null when the request throws', async () => {
124
+ const origFetch = globalThis.fetch;
125
+ globalThis.fetch = jasmine
126
+ .createSpy('fetch')
127
+ .and.rejectWith(new Error('network down'));
128
+ try {
129
+ expect(await inferTrackTypeFromUrl('https://example.com/probe-throws')).toBeNull();
130
+ }
131
+ finally {
132
+ globalThis.fetch = origFetch;
133
+ }
134
+ });
135
+ });
136
+ describe('probeType (non-ok resolved response)', () => {
137
+ // The real requester rejects non-ok responses, so it can never resolve one
138
+ // to probeType. Override it with a mock that resolves a non-ok Response to
139
+ // exercise probeType's `!res.ok` guard.
140
+ const mockRequesterRef = overrideGlobalInit(requesterWithRetryRef, () => new MockRequester());
141
+ it('returns null when the request resolves a non-ok response', async () => {
142
+ mockRequesterRef.value.request.and.resolveTo(new Response(null, { status: 404 }));
143
+ expect(await inferTrackTypeFromUrl('https://example.com/probe-resolved-not-ok')).toBeNull();
144
+ });
145
+ });
146
+ describe('createTrackLoadOptionsFromUrl', () => {
147
+ it('returns uri and type for a typeable URL', async () => {
148
+ expect(await createTrackLoadOptionsFromUrl('https://example.com/create.m3u8')).toEqual({ uri: 'https://example.com/create.m3u8', type: 'hls' });
149
+ });
150
+ it('returns null for an empty string', async () => {
151
+ expect(await createTrackLoadOptionsFromUrl('')).toBeNull();
152
+ });
153
+ it('returns null for an untypeable URL', async () => {
154
+ const origFetch = globalThis.fetch;
155
+ globalThis.fetch = jasmine
156
+ .createSpy('fetch')
157
+ .and.resolveTo(contentTypeResponse('application/json'));
158
+ try {
159
+ expect(await createTrackLoadOptionsFromUrl('https://example.com/create-untypeable')).toBeNull();
160
+ }
161
+ finally {
162
+ globalThis.fetch = origFetch;
163
+ }
164
+ });
165
+ });