@amazon/vinyl 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +11 -2
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +15 -4
- package/dist/index.js.map +3 -3
- package/dist/test/integ.es5.js +43 -43
- package/dist/test/integ.js +70 -2
- package/dist/test/integ.js.map +2 -2
- package/dist/types/current/ad/AdBreakInfo.d.ts +160 -0
- package/dist/types/current/ad/AdBreakInfo.d.ts.map +1 -0
- package/dist/types/current/ad/AdBreakInfo.js +5 -0
- package/dist/types/current/ad/AdController.d.ts +229 -0
- package/dist/types/current/ad/AdController.d.ts.map +1 -0
- package/dist/types/current/ad/AdController.js +19 -0
- package/dist/types/current/ad/AdControllerImpl.d.ts +146 -0
- package/dist/types/current/ad/AdControllerImpl.d.ts.map +1 -0
- package/dist/types/current/ad/AdControllerImpl.js +705 -0
- package/dist/types/current/ad/AdError.d.ts +6 -0
- package/dist/types/current/ad/AdError.d.ts.map +1 -0
- package/dist/types/current/ad/AdError.js +14 -0
- package/dist/types/current/ad/AdsProvider.d.ts +28 -0
- package/dist/types/current/ad/AdsProvider.d.ts.map +1 -0
- package/dist/types/current/ad/AdsProvider.js +5 -0
- package/dist/types/current/ad/defaultAdLoadOptionsResolver.d.ts +12 -0
- package/dist/types/current/ad/defaultAdLoadOptionsResolver.d.ts.map +1 -0
- package/dist/types/current/ad/defaultAdLoadOptionsResolver.js +26 -0
- package/dist/types/current/ad/discoverHlsInterstitials.d.ts +22 -0
- package/dist/types/current/ad/discoverHlsInterstitials.d.ts.map +1 -0
- package/dist/types/current/ad/discoverHlsInterstitials.js +246 -0
- package/dist/types/current/drm/DrmControllerImpl.d.ts.map +1 -1
- package/dist/types/current/drm/DrmControllerImpl.js +11 -1
- package/dist/types/current/playback/PlaybackControllerImpl.d.ts +1 -1
- package/dist/types/current/streaming/AudioOptions.d.ts +39 -0
- package/dist/types/current/streaming/AudioOptions.d.ts.map +1 -0
- package/dist/types/current/streaming/AudioOptions.js +15 -0
- package/dist/types/current/streaming/LoadMetric.d.ts +58 -0
- package/dist/types/current/streaming/LoadMetric.d.ts.map +1 -0
- package/dist/types/current/streaming/LoadMetric.js +5 -0
- package/dist/types/current/streaming/ManifestControllerImpl.d.ts +43 -0
- package/dist/types/current/streaming/ManifestControllerImpl.d.ts.map +1 -0
- package/dist/types/current/streaming/ManifestControllerImpl.js +104 -0
- package/dist/types/current/streaming/buffering/codecDenylist.d.ts +23 -0
- package/dist/types/current/streaming/buffering/codecDenylist.d.ts.map +1 -0
- package/dist/types/current/streaming/buffering/codecDenylist.js +62 -0
- package/dist/types/current/streaming/createAllowedContentTypesValue.d.ts +30 -0
- package/dist/types/current/streaming/createAllowedContentTypesValue.d.ts.map +1 -0
- package/dist/types/current/streaming/createAllowedContentTypesValue.js +43 -0
- package/dist/types/current/streaming/mediaTimelineAccessibilityFilter.d.ts +35 -0
- package/dist/types/current/streaming/mediaTimelineAccessibilityFilter.d.ts.map +1 -0
- package/dist/types/current/streaming/mediaTimelineAccessibilityFilter.js +75 -0
- package/dist/types/current/text/HtmlTextTrackRenderer.d.ts +60 -0
- package/dist/types/current/text/HtmlTextTrackRenderer.d.ts.map +1 -0
- package/dist/types/current/text/HtmlTextTrackRenderer.js +231 -0
- package/dist/types/current/text/SidecarTextTrackController.d.ts +103 -0
- package/dist/types/current/text/SidecarTextTrackController.d.ts.map +1 -0
- package/dist/types/current/text/SidecarTextTrackController.js +250 -0
- package/dist/types/current/text/SidecarTextTrackLoader.d.ts +65 -0
- package/dist/types/current/text/SidecarTextTrackLoader.d.ts.map +1 -0
- package/dist/types/current/text/SidecarTextTrackLoader.js +150 -0
- package/dist/types/current/text/TextTrack.d.ts +179 -0
- package/dist/types/current/text/TextTrack.d.ts.map +1 -0
- package/dist/types/current/text/TextTrack.js +29 -0
- package/dist/types/current/text/TextTrackRenderer.d.ts +24 -0
- package/dist/types/current/text/TextTrackRenderer.d.ts.map +1 -0
- package/dist/types/current/text/TextTrackRenderer.js +5 -0
- package/dist/types/current/text/VttCueStyle.d.ts +41 -0
- package/dist/types/current/text/VttCueStyle.d.ts.map +1 -0
- package/dist/types/current/text/VttCueStyle.js +45 -0
- package/dist/types/current/text/discoverDashTextTracks.d.ts +24 -0
- package/dist/types/current/text/discoverDashTextTracks.d.ts.map +1 -0
- package/dist/types/current/text/discoverDashTextTracks.js +109 -0
- package/dist/types/current/text/discoverHlsTextTracks.d.ts +19 -0
- package/dist/types/current/text/discoverHlsTextTracks.d.ts.map +1 -0
- package/dist/types/current/text/discoverHlsTextTracks.js +49 -0
- package/dist/types/current/text/mediaTextTrackProvider.d.ts +34 -0
- package/dist/types/current/text/mediaTextTrackProvider.d.ts.map +1 -0
- package/dist/types/current/text/mediaTextTrackProvider.js +42 -0
- package/dist/types/current/text/parseWebVtt.d.ts +60 -0
- package/dist/types/current/text/parseWebVtt.d.ts.map +1 -0
- package/dist/types/current/text/parseWebVtt.js +248 -0
- package/dist/types/current/text/pickPreferredTextTrack.d.ts +15 -0
- package/dist/types/current/text/pickPreferredTextTrack.d.ts.map +1 -0
- package/dist/types/current/text/pickPreferredTextTrack.js +71 -0
- package/dist/types/current/track/SeekRange.d.ts +9 -0
- package/dist/types/current/track/SeekRange.d.ts.map +1 -0
- package/dist/types/current/track/SeekRange.js +5 -0
- package/dist/types/current/track/hls/HlsManifestData.d.ts +19 -0
- package/dist/types/current/track/hls/HlsManifestData.d.ts.map +1 -0
- package/dist/types/current/track/hls/HlsManifestData.js +5 -0
- package/dist/types/current/track/hls/createHlsManifestProvider.d.ts +6 -0
- package/dist/types/current/track/hls/createHlsManifestProvider.d.ts.map +1 -0
- package/dist/types/current/track/hls/createHlsManifestProvider.js +9 -0
- package/dist/types/current/track/inferLoadOptionsFromUri.d.ts +15 -0
- package/dist/types/current/track/inferLoadOptionsFromUri.d.ts.map +1 -0
- package/dist/types/current/track/inferLoadOptionsFromUri.js +55 -0
- package/dist/types/current/tsconfig.tsbuildinfo +1 -1
- package/dist/types/current/util/media/codecOverrides.d.ts +33 -0
- package/dist/types/current/util/media/codecOverrides.d.ts.map +1 -0
- package/dist/types/current/util/media/codecOverrides.js +37 -0
- package/dist/types/current/util/media/codecSupport.d.ts +6 -0
- package/dist/types/current/util/media/codecSupport.d.ts.map +1 -0
- package/dist/types/current/util/media/codecSupport.js +17 -0
- package/dist/types/current/util/media/mimeType.d.ts +8 -0
- package/dist/types/current/util/media/mimeType.d.ts.map +1 -0
- package/dist/types/current/util/media/mimeType.js +13 -0
- package/dist/types/ts3.7/ad/AdBreakInfo.d.ts +160 -0
- package/dist/types/ts3.7/ad/AdController.d.ts +243 -0
- package/dist/types/ts3.7/ad/AdControllerImpl.d.ts +146 -0
- package/dist/types/ts3.7/ad/AdError.d.ts +6 -0
- package/dist/types/ts3.7/ad/AdsProvider.d.ts +28 -0
- package/dist/types/ts3.7/ad/defaultAdLoadOptionsResolver.d.ts +12 -0
- package/dist/types/ts3.7/ad/discoverHlsInterstitials.d.ts +22 -0
- package/dist/types/ts3.7/playback/PlaybackControllerImpl.d.ts +1 -1
- package/dist/types/ts3.7/streaming/AudioOptions.d.ts +39 -0
- package/dist/types/ts3.7/streaming/LoadMetric.d.ts +58 -0
- package/dist/types/ts3.7/streaming/ManifestControllerImpl.d.ts +40 -0
- package/dist/types/ts3.7/streaming/buffering/codecDenylist.d.ts +23 -0
- package/dist/types/ts3.7/streaming/createAllowedContentTypesValue.d.ts +30 -0
- package/dist/types/ts3.7/streaming/mediaTimelineAccessibilityFilter.d.ts +35 -0
- package/dist/types/ts3.7/text/HtmlTextTrackRenderer.d.ts +60 -0
- package/dist/types/ts3.7/text/SidecarTextTrackController.d.ts +103 -0
- package/dist/types/ts3.7/text/SidecarTextTrackLoader.d.ts +65 -0
- package/dist/types/ts3.7/text/TextTrack.d.ts +183 -0
- package/dist/types/ts3.7/text/TextTrackRenderer.d.ts +24 -0
- package/dist/types/ts3.7/text/VttCueStyle.d.ts +41 -0
- package/dist/types/ts3.7/text/discoverDashTextTracks.d.ts +24 -0
- package/dist/types/ts3.7/text/discoverHlsTextTracks.d.ts +19 -0
- package/dist/types/ts3.7/text/mediaTextTrackProvider.d.ts +34 -0
- package/dist/types/ts3.7/text/parseWebVtt.d.ts +60 -0
- package/dist/types/ts3.7/text/pickPreferredTextTrack.d.ts +15 -0
- package/dist/types/ts3.7/track/SeekRange.d.ts +9 -0
- package/dist/types/ts3.7/track/hls/HlsManifestData.d.ts +19 -0
- package/dist/types/ts3.7/track/hls/createHlsManifestProvider.d.ts +6 -0
- package/dist/types/ts3.7/track/inferLoadOptionsFromUri.d.ts +15 -0
- package/dist/types/ts3.7/util/media/codecOverrides.d.ts +33 -0
- package/dist/types/ts3.7/util/media/codecSupport.d.ts +6 -0
- package/dist/types/ts3.7/util/media/mimeType.d.ts +8 -0
- package/dist/types/ts4.1/ad/AdBreakInfo.d.ts +160 -0
- package/dist/types/ts4.1/ad/AdController.d.ts +243 -0
- package/dist/types/ts4.1/ad/AdControllerImpl.d.ts +146 -0
- package/dist/types/ts4.1/ad/AdError.d.ts +6 -0
- package/dist/types/ts4.1/ad/AdsProvider.d.ts +28 -0
- package/dist/types/ts4.1/ad/defaultAdLoadOptionsResolver.d.ts +12 -0
- package/dist/types/ts4.1/ad/discoverHlsInterstitials.d.ts +22 -0
- package/dist/types/ts4.1/playback/PlaybackControllerImpl.d.ts +1 -1
- package/dist/types/ts4.1/streaming/AudioOptions.d.ts +39 -0
- package/dist/types/ts4.1/streaming/LoadMetric.d.ts +58 -0
- package/dist/types/ts4.1/streaming/ManifestControllerImpl.d.ts +40 -0
- package/dist/types/ts4.1/streaming/buffering/codecDenylist.d.ts +23 -0
- package/dist/types/ts4.1/streaming/createAllowedContentTypesValue.d.ts +30 -0
- package/dist/types/ts4.1/streaming/mediaTimelineAccessibilityFilter.d.ts +35 -0
- package/dist/types/ts4.1/text/HtmlTextTrackRenderer.d.ts +60 -0
- package/dist/types/ts4.1/text/SidecarTextTrackController.d.ts +104 -0
- package/dist/types/ts4.1/text/SidecarTextTrackLoader.d.ts +65 -0
- package/dist/types/ts4.1/text/TextTrack.d.ts +183 -0
- package/dist/types/ts4.1/text/TextTrackRenderer.d.ts +24 -0
- package/dist/types/ts4.1/text/VttCueStyle.d.ts +41 -0
- package/dist/types/ts4.1/text/discoverDashTextTracks.d.ts +24 -0
- package/dist/types/ts4.1/text/discoverHlsTextTracks.d.ts +19 -0
- package/dist/types/ts4.1/text/mediaTextTrackProvider.d.ts +34 -0
- package/dist/types/ts4.1/text/parseWebVtt.d.ts +60 -0
- package/dist/types/ts4.1/text/pickPreferredTextTrack.d.ts +15 -0
- package/dist/types/ts4.1/track/SeekRange.d.ts +9 -0
- package/dist/types/ts4.1/track/hls/HlsManifestData.d.ts +19 -0
- package/dist/types/ts4.1/track/hls/createHlsManifestProvider.d.ts +6 -0
- package/dist/types/ts4.1/track/inferLoadOptionsFromUri.d.ts +15 -0
- package/dist/types/ts4.1/util/media/codecOverrides.d.ts +33 -0
- package/dist/types/ts4.1/util/media/codecSupport.d.ts +6 -0
- package/dist/types/ts4.1/util/media/mimeType.d.ts +8 -0
- package/dist/types/ts4.7/ad/AdBreakInfo.d.ts +160 -0
- package/dist/types/ts4.7/ad/AdController.d.ts +243 -0
- package/dist/types/ts4.7/ad/AdControllerImpl.d.ts +146 -0
- package/dist/types/ts4.7/ad/AdError.d.ts +6 -0
- package/dist/types/ts4.7/ad/AdsProvider.d.ts +28 -0
- package/dist/types/ts4.7/ad/defaultAdLoadOptionsResolver.d.ts +12 -0
- package/dist/types/ts4.7/ad/discoverHlsInterstitials.d.ts +22 -0
- package/dist/types/ts4.7/playback/PlaybackControllerImpl.d.ts +1 -1
- package/dist/types/ts4.7/streaming/AudioOptions.d.ts +39 -0
- package/dist/types/ts4.7/streaming/LoadMetric.d.ts +58 -0
- package/dist/types/ts4.7/streaming/ManifestControllerImpl.d.ts +43 -0
- package/dist/types/ts4.7/streaming/buffering/codecDenylist.d.ts +23 -0
- package/dist/types/ts4.7/streaming/createAllowedContentTypesValue.d.ts +30 -0
- package/dist/types/ts4.7/streaming/mediaTimelineAccessibilityFilter.d.ts +35 -0
- package/dist/types/ts4.7/text/HtmlTextTrackRenderer.d.ts +60 -0
- package/dist/types/ts4.7/text/SidecarTextTrackController.d.ts +103 -0
- package/dist/types/ts4.7/text/SidecarTextTrackLoader.d.ts +65 -0
- package/dist/types/ts4.7/text/TextTrack.d.ts +183 -0
- package/dist/types/ts4.7/text/TextTrackRenderer.d.ts +24 -0
- package/dist/types/ts4.7/text/VttCueStyle.d.ts +41 -0
- package/dist/types/ts4.7/text/discoverDashTextTracks.d.ts +24 -0
- package/dist/types/ts4.7/text/discoverHlsTextTracks.d.ts +19 -0
- package/dist/types/ts4.7/text/mediaTextTrackProvider.d.ts +34 -0
- package/dist/types/ts4.7/text/parseWebVtt.d.ts +60 -0
- package/dist/types/ts4.7/text/pickPreferredTextTrack.d.ts +15 -0
- package/dist/types/ts4.7/track/SeekRange.d.ts +9 -0
- package/dist/types/ts4.7/track/hls/HlsManifestData.d.ts +19 -0
- package/dist/types/ts4.7/track/hls/createHlsManifestProvider.d.ts +6 -0
- package/dist/types/ts4.7/track/inferLoadOptionsFromUri.d.ts +15 -0
- package/dist/types/ts4.7/util/media/codecOverrides.d.ts +33 -0
- package/dist/types/ts4.7/util/media/codecSupport.d.ts +6 -0
- package/dist/types/ts4.7/util/media/mimeType.d.ts +8 -0
- package/dist/unit/types/current/ad/AdController.test.d.ts +2 -0
- package/dist/unit/types/current/ad/AdController.test.d.ts.map +1 -0
- package/dist/unit/types/current/ad/AdController.test.js +10 -0
- package/dist/unit/types/current/ad/AdControllerImpl.test.d.ts +2 -0
- package/dist/unit/types/current/ad/AdControllerImpl.test.d.ts.map +1 -0
- package/dist/unit/types/current/ad/AdControllerImpl.test.js +1456 -0
- package/dist/unit/types/current/ad/defaultAdLoadOptionsResolver.test.d.ts +2 -0
- package/dist/unit/types/current/ad/defaultAdLoadOptionsResolver.test.d.ts.map +1 -0
- package/dist/unit/types/current/ad/defaultAdLoadOptionsResolver.test.js +56 -0
- package/dist/unit/types/current/ad/discoverHlsInterstitials.test.d.ts +2 -0
- package/dist/unit/types/current/ad/discoverHlsInterstitials.test.d.ts.map +1 -0
- package/dist/unit/types/current/ad/discoverHlsInterstitials.test.js +756 -0
- package/dist/unit/types/current/drm/DrmControllerImpl.test.js +66 -1
- package/dist/unit/types/current/streaming/ManifestControllerImpl.test.d.ts +2 -0
- package/dist/unit/types/current/streaming/ManifestControllerImpl.test.d.ts.map +1 -0
- package/dist/unit/types/current/streaming/ManifestControllerImpl.test.js +197 -0
- package/dist/unit/types/current/streaming/buffering/codecDenylist.test.d.ts +2 -0
- package/dist/unit/types/current/streaming/buffering/codecDenylist.test.d.ts.map +1 -0
- package/dist/unit/types/current/streaming/buffering/codecDenylist.test.js +56 -0
- package/dist/unit/types/current/streaming/createAllowedContentTypesValue.test.d.ts +2 -0
- package/dist/unit/types/current/streaming/createAllowedContentTypesValue.test.d.ts.map +1 -0
- package/dist/unit/types/current/streaming/createAllowedContentTypesValue.test.js +77 -0
- package/dist/unit/types/current/streaming/mediaTimelineAccessibilityFilter.test.d.ts +2 -0
- package/dist/unit/types/current/streaming/mediaTimelineAccessibilityFilter.test.d.ts.map +1 -0
- package/dist/unit/types/current/streaming/mediaTimelineAccessibilityFilter.test.js +99 -0
- package/dist/unit/types/current/text/HtmlTextTrackRenderer.test.d.ts +2 -0
- package/dist/unit/types/current/text/HtmlTextTrackRenderer.test.d.ts.map +1 -0
- package/dist/unit/types/current/text/HtmlTextTrackRenderer.test.js +231 -0
- package/dist/unit/types/current/text/SidecarTextTrackController.test.d.ts +2 -0
- package/dist/unit/types/current/text/SidecarTextTrackController.test.d.ts.map +1 -0
- package/dist/unit/types/current/text/SidecarTextTrackController.test.js +686 -0
- package/dist/unit/types/current/text/SidecarTextTrackLoader.test.d.ts +2 -0
- package/dist/unit/types/current/text/SidecarTextTrackLoader.test.d.ts.map +1 -0
- package/dist/unit/types/current/text/SidecarTextTrackLoader.test.js +365 -0
- package/dist/unit/types/current/text/VttCueStyle.test.d.ts +2 -0
- package/dist/unit/types/current/text/VttCueStyle.test.d.ts.map +1 -0
- package/dist/unit/types/current/text/VttCueStyle.test.js +76 -0
- package/dist/unit/types/current/text/discoverDashTextTracks.test.d.ts +2 -0
- package/dist/unit/types/current/text/discoverDashTextTracks.test.d.ts.map +1 -0
- package/dist/unit/types/current/text/discoverDashTextTracks.test.js +199 -0
- package/dist/unit/types/current/text/discoverHlsTextTracks.test.d.ts +2 -0
- package/dist/unit/types/current/text/discoverHlsTextTracks.test.d.ts.map +1 -0
- package/dist/unit/types/current/text/discoverHlsTextTracks.test.js +177 -0
- package/dist/unit/types/current/text/mediaTextTrackProvider.test.d.ts +2 -0
- package/dist/unit/types/current/text/mediaTextTrackProvider.test.d.ts.map +1 -0
- package/dist/unit/types/current/text/mediaTextTrackProvider.test.js +86 -0
- package/dist/unit/types/current/text/parseWebVtt.test.d.ts +2 -0
- package/dist/unit/types/current/text/parseWebVtt.test.d.ts.map +1 -0
- package/dist/unit/types/current/text/parseWebVtt.test.js +393 -0
- package/dist/unit/types/current/text/pickPreferredTextTrack.test.d.ts +2 -0
- package/dist/unit/types/current/text/pickPreferredTextTrack.test.d.ts.map +1 -0
- package/dist/unit/types/current/text/pickPreferredTextTrack.test.js +78 -0
- package/dist/unit/types/current/track/inferLoadOptionsFromUri.test.d.ts +2 -0
- package/dist/unit/types/current/track/inferLoadOptionsFromUri.test.d.ts.map +1 -0
- package/dist/unit/types/current/track/inferLoadOptionsFromUri.test.js +165 -0
- package/dist/unit/types/current/tsconfig.tsbuildinfo +1 -1
- package/dist/unit/types/current/util/media/codecOverrides.test.d.ts +2 -0
- package/dist/unit/types/current/util/media/codecOverrides.test.d.ts.map +1 -0
- package/dist/unit/types/current/util/media/codecOverrides.test.js +42 -0
- package/dist/unit/types/current/util/media/codecSupport.test.d.ts +2 -0
- package/dist/unit/types/current/util/media/codecSupport.test.d.ts.map +1 -0
- package/dist/unit/types/current/util/media/codecSupport.test.js +26 -0
- package/dist/unit/types/current/util/media/mimeType.test.d.ts +2 -0
- package/dist/unit/types/current/util/media/mimeType.test.d.ts.map +1 -0
- package/dist/unit/types/current/util/media/mimeType.test.js +22 -0
- package/dist/unit/types/current/vinyl/VinylPlayerAdBreaks.test.d.ts +2 -0
- package/dist/unit/types/current/vinyl/VinylPlayerAdBreaks.test.d.ts.map +1 -0
- package/dist/unit/types/current/vinyl/VinylPlayerAdBreaks.test.js +142 -0
- package/dist/unit/types/current/vinyl/VinylPlayerTextTracks.test.d.ts +2 -0
- package/dist/unit/types/current/vinyl/VinylPlayerTextTracks.test.d.ts.map +1 -0
- package/dist/unit/types/current/vinyl/VinylPlayerTextTracks.test.js +188 -0
- package/dist/vinylTestUtil/types/current/mock/ad/MockAdController.d.ts +15 -0
- package/dist/vinylTestUtil/types/current/mock/ad/MockAdController.d.ts.map +1 -0
- package/dist/vinylTestUtil/types/current/mock/ad/MockAdController.js +26 -0
- package/dist/vinylTestUtil/types/current/mock/dash/mockDashManifest.d.ts +84 -84
- package/dist/vinylTestUtil/types/current/mock/text/MockTextTrackController.d.ts +10 -0
- package/dist/vinylTestUtil/types/current/mock/text/MockTextTrackController.d.ts.map +1 -0
- package/dist/vinylTestUtil/types/current/mock/text/MockTextTrackController.js +14 -0
- package/dist/vinylTestUtil/types/current/tsconfig.tsbuildinfo +1 -1
- package/dist/vinylTestUtil/types/ts3.7/mock/ad/MockAdController.d.ts +15 -0
- package/dist/vinylTestUtil/types/ts3.7/mock/dash/mockDashManifest.d.ts +84 -84
- package/dist/vinylTestUtil/types/ts3.7/mock/text/MockTextTrackController.d.ts +10 -0
- package/dist/vinylTestUtil/types/ts4.1/mock/ad/MockAdController.d.ts +15 -0
- package/dist/vinylTestUtil/types/ts4.1/mock/dash/mockDashManifest.d.ts +84 -84
- package/dist/vinylTestUtil/types/ts4.1/mock/text/MockTextTrackController.d.ts +10 -0
- package/dist/vinylTestUtil/types/ts4.7/mock/ad/MockAdController.d.ts +15 -0
- package/dist/vinylTestUtil/types/ts4.7/mock/dash/mockDashManifest.d.ts +84 -84
- package/dist/vinylTestUtil/types/ts4.7/mock/text/MockTextTrackController.d.ts +10 -0
- package/package.json +10 -11
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { discoverHlsTextTracks } from '@amazon/vinyl';
|
|
6
|
+
describe('discoverHlsTextTracks', () => {
|
|
7
|
+
function makePlaylist(overrides = {}) {
|
|
8
|
+
return {
|
|
9
|
+
variants: [],
|
|
10
|
+
alternativeRenditions: [],
|
|
11
|
+
sessionData: [],
|
|
12
|
+
...overrides,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
it('returns empty when no renditions exist', () => {
|
|
16
|
+
expect(discoverHlsTextTracks(makePlaylist(), 'https://x/main.m3u8')).toEqual([]);
|
|
17
|
+
});
|
|
18
|
+
it('discovers a SUBTITLES rendition with a uri', () => {
|
|
19
|
+
const playlist = makePlaylist({
|
|
20
|
+
alternativeRenditions: [
|
|
21
|
+
{
|
|
22
|
+
type: 'SUBTITLES',
|
|
23
|
+
groupId: 'subs',
|
|
24
|
+
name: 'English',
|
|
25
|
+
language: 'en',
|
|
26
|
+
uri: 'subs/en.vtt',
|
|
27
|
+
default: true,
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
});
|
|
31
|
+
const result = discoverHlsTextTracks(playlist, 'https://example.com/path/main.m3u8');
|
|
32
|
+
expect(result.length).toBe(1);
|
|
33
|
+
expect(result[0]).toEqual(jasmine.objectContaining({
|
|
34
|
+
kind: 'subtitles',
|
|
35
|
+
language: 'en',
|
|
36
|
+
label: 'English',
|
|
37
|
+
default: true,
|
|
38
|
+
uri: 'https://example.com/path/subs/en.vtt',
|
|
39
|
+
mimeType: 'text/vtt',
|
|
40
|
+
}));
|
|
41
|
+
});
|
|
42
|
+
it('surfaces forced and characteristics from the rendition', () => {
|
|
43
|
+
const playlist = makePlaylist({
|
|
44
|
+
alternativeRenditions: [
|
|
45
|
+
{
|
|
46
|
+
type: 'SUBTITLES',
|
|
47
|
+
groupId: 'subs',
|
|
48
|
+
name: 'English (Forced)',
|
|
49
|
+
language: 'en',
|
|
50
|
+
uri: 'subs/en-forced.vtt',
|
|
51
|
+
forced: true,
|
|
52
|
+
characteristics: [
|
|
53
|
+
'public.accessibility.transcribes-spoken-dialog',
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
});
|
|
58
|
+
const result = discoverHlsTextTracks(playlist, 'https://x/main.m3u8');
|
|
59
|
+
expect(result[0].forced).toBeTrue();
|
|
60
|
+
expect(result[0].characteristics).toEqual([
|
|
61
|
+
'public.accessibility.transcribes-spoken-dialog',
|
|
62
|
+
]);
|
|
63
|
+
});
|
|
64
|
+
it('defaults forced to false and characteristics to empty when absent', () => {
|
|
65
|
+
const playlist = makePlaylist({
|
|
66
|
+
alternativeRenditions: [
|
|
67
|
+
{
|
|
68
|
+
type: 'SUBTITLES',
|
|
69
|
+
groupId: 'subs',
|
|
70
|
+
name: 'English',
|
|
71
|
+
language: 'en',
|
|
72
|
+
uri: 'subs/en.vtt',
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
});
|
|
76
|
+
const result = discoverHlsTextTracks(playlist, 'https://x/main.m3u8');
|
|
77
|
+
expect(result[0].forced).toBeFalse();
|
|
78
|
+
expect(result[0].characteristics).toEqual([]);
|
|
79
|
+
});
|
|
80
|
+
it('skips SUBTITLES renditions without a uri', () => {
|
|
81
|
+
const playlist = makePlaylist({
|
|
82
|
+
alternativeRenditions: [
|
|
83
|
+
{
|
|
84
|
+
type: 'SUBTITLES',
|
|
85
|
+
groupId: 'subs',
|
|
86
|
+
name: 'English',
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
});
|
|
90
|
+
expect(discoverHlsTextTracks(playlist, 'https://x/main.m3u8')).toEqual([]);
|
|
91
|
+
});
|
|
92
|
+
it('ignores non-SUBTITLES renditions', () => {
|
|
93
|
+
const playlist = makePlaylist({
|
|
94
|
+
alternativeRenditions: [
|
|
95
|
+
{
|
|
96
|
+
type: 'AUDIO',
|
|
97
|
+
groupId: 'aud',
|
|
98
|
+
name: 'English',
|
|
99
|
+
uri: 'aud/en.m3u8',
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
type: 'CLOSED-CAPTIONS',
|
|
103
|
+
groupId: 'cc',
|
|
104
|
+
name: 'English',
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
});
|
|
108
|
+
expect(discoverHlsTextTracks(playlist, 'https://x/main.m3u8')).toEqual([]);
|
|
109
|
+
});
|
|
110
|
+
it('defaults language to null and default to false when absent', () => {
|
|
111
|
+
const playlist = makePlaylist({
|
|
112
|
+
alternativeRenditions: [
|
|
113
|
+
{
|
|
114
|
+
type: 'SUBTITLES',
|
|
115
|
+
groupId: 'subs',
|
|
116
|
+
name: 'Track',
|
|
117
|
+
uri: 'subs.vtt',
|
|
118
|
+
},
|
|
119
|
+
],
|
|
120
|
+
});
|
|
121
|
+
const result = discoverHlsTextTracks(playlist, 'https://x/main.m3u8');
|
|
122
|
+
expect(result[0].language).toBeNull();
|
|
123
|
+
expect(result[0].default).toBeFalse();
|
|
124
|
+
});
|
|
125
|
+
it('emits stable, unique ids for multiple subtitle tracks', () => {
|
|
126
|
+
const playlist = makePlaylist({
|
|
127
|
+
alternativeRenditions: [
|
|
128
|
+
{
|
|
129
|
+
type: 'SUBTITLES',
|
|
130
|
+
groupId: 'subs',
|
|
131
|
+
name: 'English',
|
|
132
|
+
uri: 'en.vtt',
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
type: 'SUBTITLES',
|
|
136
|
+
groupId: 'subs',
|
|
137
|
+
name: 'Spanish',
|
|
138
|
+
uri: 'es.vtt',
|
|
139
|
+
},
|
|
140
|
+
],
|
|
141
|
+
});
|
|
142
|
+
const ids = discoverHlsTextTracks(playlist, 'https://x/main.m3u8').map((t) => t.id);
|
|
143
|
+
expect(new Set(ids).size).toBe(ids.length);
|
|
144
|
+
});
|
|
145
|
+
it('attaches parent EXT-X-DEFINE variables when present', () => {
|
|
146
|
+
const playlist = makePlaylist({
|
|
147
|
+
alternativeRenditions: [
|
|
148
|
+
{
|
|
149
|
+
type: 'SUBTITLES',
|
|
150
|
+
groupId: 'subs',
|
|
151
|
+
name: 'English',
|
|
152
|
+
uri: 'subs/en.m3u8',
|
|
153
|
+
},
|
|
154
|
+
],
|
|
155
|
+
defines: { prefix: 'https://cdn.example.com/' },
|
|
156
|
+
});
|
|
157
|
+
const result = discoverHlsTextTracks(playlist, 'https://x/main.m3u8');
|
|
158
|
+
expect(result[0].variables).toEqual({
|
|
159
|
+
prefix: 'https://cdn.example.com/',
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
it('omits variables when the parent has an empty defines map', () => {
|
|
163
|
+
const playlist = makePlaylist({
|
|
164
|
+
alternativeRenditions: [
|
|
165
|
+
{
|
|
166
|
+
type: 'SUBTITLES',
|
|
167
|
+
groupId: 'subs',
|
|
168
|
+
name: 'English',
|
|
169
|
+
uri: 'subs/en.m3u8',
|
|
170
|
+
},
|
|
171
|
+
],
|
|
172
|
+
defines: {},
|
|
173
|
+
});
|
|
174
|
+
const result = discoverHlsTextTracks(playlist, 'https://x/main.m3u8');
|
|
175
|
+
expect(result[0].variables).toBeUndefined();
|
|
176
|
+
});
|
|
177
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mediaTextTrackProvider.test.d.ts","sourceRoot":"","sources":["../../../../../test/unit/text/mediaTextTrackProvider.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { createMediaTextTrackProvider } from '@amazon/vinyl';
|
|
6
|
+
/** Minimal media element: a live `textTracks` list and a spied `addTextTrack`. */
|
|
7
|
+
class FakeMediaElement {
|
|
8
|
+
tracks = [];
|
|
9
|
+
addTextTrack = jasmine
|
|
10
|
+
.createSpy('addTextTrack')
|
|
11
|
+
.and.callFake((kind, label, language) => {
|
|
12
|
+
const track = {
|
|
13
|
+
kind,
|
|
14
|
+
label,
|
|
15
|
+
language,
|
|
16
|
+
mode: 'disabled',
|
|
17
|
+
cues: [],
|
|
18
|
+
addCue(cue) {
|
|
19
|
+
this.cues.push(cue);
|
|
20
|
+
},
|
|
21
|
+
removeCue(cue) {
|
|
22
|
+
const i = this.cues.indexOf(cue);
|
|
23
|
+
if (i >= 0)
|
|
24
|
+
this.cues.splice(i, 1);
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
this.tracks.push(track);
|
|
28
|
+
return track;
|
|
29
|
+
});
|
|
30
|
+
// ArrayLike view over the live tracks (what `isAttached` scans).
|
|
31
|
+
get textTracks() {
|
|
32
|
+
return this.tracks;
|
|
33
|
+
}
|
|
34
|
+
asMedia() {
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
cue() {
|
|
38
|
+
return { id: '' };
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
describe('createMediaTextTrackProvider', () => {
|
|
42
|
+
let media;
|
|
43
|
+
let provider;
|
|
44
|
+
beforeEach(() => {
|
|
45
|
+
media = new FakeMediaElement();
|
|
46
|
+
provider = createMediaTextTrackProvider({ media: media.asMedia() });
|
|
47
|
+
});
|
|
48
|
+
it('creates a track from the given kind/label/language', () => {
|
|
49
|
+
const ref = provider.getOrCreate('subtitles', 'English', 'en');
|
|
50
|
+
expect(media.addTextTrack).toHaveBeenCalledOnceWith('subtitles', 'English', 'en');
|
|
51
|
+
expect(media.tracks).toContain(ref.track);
|
|
52
|
+
});
|
|
53
|
+
it('memoizes by (kind,label,language) — same key returns the same track', () => {
|
|
54
|
+
const a = provider.getOrCreate('subtitles', 'English', 'en');
|
|
55
|
+
const b = provider.getOrCreate('subtitles', 'English', 'en');
|
|
56
|
+
expect(b).toBe(a);
|
|
57
|
+
expect(media.addTextTrack).toHaveBeenCalledTimes(1);
|
|
58
|
+
});
|
|
59
|
+
it('creates a distinct track per key', () => {
|
|
60
|
+
provider.getOrCreate('subtitles', 'English', 'en');
|
|
61
|
+
provider.getOrCreate('subtitles', 'Espanol', 'es');
|
|
62
|
+
expect(media.addTextTrack).toHaveBeenCalledTimes(2);
|
|
63
|
+
});
|
|
64
|
+
it('recreates a track that was detached from the media element', () => {
|
|
65
|
+
const first = provider.getOrCreate('subtitles', 'English', 'en');
|
|
66
|
+
// Simulate a media-source reset dropping added tracks.
|
|
67
|
+
media.tracks.length = 0;
|
|
68
|
+
const second = provider.getOrCreate('subtitles', 'English', 'en');
|
|
69
|
+
expect(second).not.toBe(first);
|
|
70
|
+
expect(media.addTextTrack).toHaveBeenCalledTimes(2);
|
|
71
|
+
expect(media.tracks).toContain(second.track);
|
|
72
|
+
});
|
|
73
|
+
it('clear() removes all cues from the track', () => {
|
|
74
|
+
const ref = provider.getOrCreate('subtitles', 'English', 'en');
|
|
75
|
+
ref.track.addCue(media.cue());
|
|
76
|
+
ref.track.addCue(media.cue());
|
|
77
|
+
expect(ref.track.cues?.length).toBe(2);
|
|
78
|
+
ref.clear();
|
|
79
|
+
expect(ref.track.cues?.length).toBe(0);
|
|
80
|
+
});
|
|
81
|
+
it('clear() is a no-op when the track has no cues (cues null)', () => {
|
|
82
|
+
const ref = provider.getOrCreate('subtitles', 'English', 'en');
|
|
83
|
+
ref.track.cues = null;
|
|
84
|
+
expect(() => ref.clear()).not.toThrow();
|
|
85
|
+
});
|
|
86
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseWebVtt.test.d.ts","sourceRoot":"","sources":["../../../../../test/unit/text/parseWebVtt.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,393 @@
|
|
|
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('handles trailing identifier without timing line', () => {
|
|
386
|
+
// Identifier with no following timing line - cue is dropped, parser
|
|
387
|
+
// breaks out cleanly without throwing.
|
|
388
|
+
const text = `WEBVTT
|
|
389
|
+
|
|
390
|
+
trailing-id`;
|
|
391
|
+
expect(parseWebVtt(text).cues).toEqual([]);
|
|
392
|
+
});
|
|
393
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pickPreferredTextTrack.test.d.ts","sourceRoot":"","sources":["../../../../../test/unit/text/pickPreferredTextTrack.test.ts"],"names":[],"mappings":""}
|