@gcorevideo/player 2.18.3 → 2.19.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/assets/audio-selector/style.scss +156 -0
- package/assets/audio-selector/track-selector.ejs +12 -0
- package/assets/big-mute-button/big-mute-button.ejs +3 -0
- package/assets/big-mute-button/big-mute-button.scss +57 -0
- package/assets/bottom-gear/bottomgear.ejs +12 -0
- package/assets/bottom-gear/gear-sub-menu.scss +95 -0
- package/assets/bottom-gear/gear.scss +79 -0
- package/assets/clappr-nerd-stats/button.ejs +4 -0
- package/assets/clappr-nerd-stats/clappr-nerd-stats.ejs +212 -0
- package/assets/clappr-nerd-stats/clappr-nerd-stats.scss +488 -0
- package/assets/clappr-nerd-stats/options-list.ejs +9 -0
- package/assets/clappr-nerd-stats/settings.ejs +12 -0
- package/assets/clappr-nerd-stats/speedtest/speedtest.worker.js +775 -0
- package/assets/clips/clips.scss +3 -0
- package/assets/context-menu/context_menu.ejs +8 -0
- package/assets/context-menu/context_menu.scss +31 -0
- package/assets/dvr-controls/dvr_controls.scss +136 -0
- package/assets/dvr-controls/index.ejs +2 -0
- package/assets/error-screen/error_screen.ejs +13 -0
- package/assets/error-screen/error_screen.scss +40 -0
- package/assets/icons/new/arrow-left.svg +5 -0
- package/assets/icons/new/arrow-right.svg +5 -0
- package/assets/icons/new/check.svg +5 -0
- package/assets/icons/new/close.svg +12 -0
- package/assets/icons/new/full.svg +8 -0
- package/assets/icons/new/fullscreen-off.svg +14 -0
- package/assets/icons/new/fullscreen-on.svg +14 -0
- package/assets/icons/new/gear-hd.svg +16 -0
- package/assets/icons/new/gear.svg +12 -0
- package/assets/icons/new/hd.svg +8 -0
- package/assets/icons/new/pause.svg +5 -0
- package/assets/icons/new/pip.svg +5 -0
- package/assets/icons/new/play.svg +10 -0
- package/assets/icons/new/replayleft.svg +5 -0
- package/assets/icons/new/replayright.svg +5 -0
- package/assets/icons/new/speed.svg +5 -0
- package/assets/icons/new/stats.svg +3 -0
- package/assets/icons/new/stop.svg +3 -0
- package/assets/icons/new/subtitles-off.svg +5 -0
- package/assets/icons/new/subtitles-on.svg +6 -0
- package/assets/icons/new/volume-max.svg +5 -0
- package/assets/icons/new/volume-min.svg +5 -0
- package/assets/icons/new/volume-off.svg +5 -0
- package/assets/icons/old/cardboard.svg +4 -0
- package/assets/icons/old/close-share.svg +13 -0
- package/assets/icons/old/close.svg +13 -0
- package/assets/icons/old/fb.svg +13 -0
- package/assets/icons/old/fullscreen.svg +12 -0
- package/assets/icons/old/language.svg +1 -0
- package/assets/icons/old/pause.svg +12 -0
- package/assets/icons/old/play.svg +12 -0
- package/assets/icons/old/quality-arrow.svg +13 -0
- package/assets/icons/old/reload.svg +4 -0
- package/assets/icons/old/share.svg +13 -0
- package/assets/icons/old/sound-off.svg +15 -0
- package/assets/icons/old/sound-on.svg +15 -0
- package/assets/icons/old/streams.svg +3 -0
- package/assets/icons/old/twitter.svg +13 -0
- package/assets/icons/old/wn.svg +15 -0
- package/assets/icons/standard/01-play.svg +3 -0
- package/assets/icons/standard/02-pause.svg +3 -0
- package/assets/icons/standard/03-stop.svg +3 -0
- package/assets/icons/standard/04-volume.svg +3 -0
- package/assets/icons/standard/05-mute.svg +3 -0
- package/assets/icons/standard/06-expand.svg +3 -0
- package/assets/icons/standard/07-shrink.svg +3 -0
- package/assets/icons/standard/08-hd.svg +3 -0
- package/assets/icons/standard/09-cc.svg +8 -0
- package/assets/icons/standard/10-reload.svg +4 -0
- package/assets/level-selector/button.ejs +8 -0
- package/assets/level-selector/list.ejs +22 -0
- package/assets/level-selector/style.scss +4 -0
- package/assets/logo/styles/logo.scss +10 -0
- package/assets/logo/templates/logo.ejs +3 -0
- package/assets/media-control/closed-hand.cur +0 -0
- package/assets/media-control/container.scss +57 -0
- package/assets/media-control/media-control.ejs +133 -0
- package/assets/media-control/media-control.scss +390 -0
- package/assets/media-control/plugins.scss +94 -0
- package/assets/media-control/width270.scss +50 -0
- package/assets/media-control/width370.scss +263 -0
- package/assets/multi-camera/multicamera.ejs +29 -0
- package/assets/multi-camera/style.scss +176 -0
- package/assets/picture-in-picture/button.ejs +3 -0
- package/assets/picture-in-picture/button.scss +11 -0
- package/assets/playback-rate/button.ejs +6 -0
- package/assets/playback-rate/list.ejs +14 -0
- package/assets/playback-rate/playback-rate-selector.ejs +9 -0
- package/assets/poster/poster.ejs +1 -0
- package/assets/poster/poster.scss +32 -0
- package/assets/seek-time/seek-time.html +2 -0
- package/assets/seek-time/seek-time.scss +38 -0
- package/assets/share/share.ejs +37 -0
- package/assets/share/style.scss +104 -0
- package/assets/skip-time/skip-time.ejs +8 -0
- package/assets/skip-time/style.scss +24 -0
- package/assets/spinner-three-bounce/spinner.ejs +3 -0
- package/assets/spinner-three-bounce/spinner.scss +44 -0
- package/assets/style/main.scss +50 -0
- package/assets/style/theme.scss +42 -0
- package/assets/style/variables.scss +7 -0
- package/assets/subtitles/combobox copy.ejs +16 -0
- package/assets/subtitles/combobox.ejs +16 -0
- package/assets/subtitles/string.ejs +3 -0
- package/assets/subtitles/style.scss +99 -0
- package/assets/thumbnails/scrub-thumbnails.ejs +10 -0
- package/assets/thumbnails/style.scss +75 -0
- package/assets/vast-ads/style.scss +112 -0
- package/assets/video360/button.ejs +1 -0
- package/assets/video360/style.scss +8 -0
- package/build/vite-raw-plugin.js +18 -0
- package/dist/index.js +1 -1
- package/dist/plugins/index.css +2164 -0
- package/dist/{index-C02TmVOf.js → plugins/index.js/index.plugins.js} +29283 -29567
- package/lib/index.core.d.ts +15 -0
- package/lib/index.core.d.ts.map +1 -0
- package/lib/index.core.js +14 -0
- package/lib/index.d.ts +2 -14
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -14
- package/lib/index.plugins.d.ts +37 -0
- package/lib/index.plugins.d.ts.map +1 -0
- package/lib/index.plugins.js +39 -0
- package/lib/plugins/audio-selector/AudioSelector.d.ts +3 -3
- package/lib/plugins/audio-selector/AudioSelector.d.ts.map +1 -1
- package/lib/plugins/audio-selector/AudioSelector.js +6 -12
- package/lib/plugins/big-mute-button/BigMuteButton.d.ts +2 -2
- package/lib/plugins/big-mute-button/BigMuteButton.d.ts.map +1 -1
- package/lib/plugins/big-mute-button/BigMuteButton.js +7 -12
- package/lib/plugins/bottom-gear/BottomGear.d.ts +4 -3
- package/lib/plugins/bottom-gear/BottomGear.d.ts.map +1 -1
- package/lib/plugins/bottom-gear/BottomGear.js +11 -16
- package/lib/plugins/build.d.ts +2 -0
- package/lib/plugins/build.d.ts.map +1 -0
- package/lib/plugins/build.js +1 -0
- package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.d.ts +44 -0
- package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.d.ts.map +1 -0
- package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.js +294 -0
- package/lib/plugins/clappr-nerd-stats/formatter.d.ts +8 -0
- package/lib/plugins/clappr-nerd-stats/formatter.d.ts.map +1 -0
- package/lib/plugins/clappr-nerd-stats/formatter.js +91 -0
- package/lib/plugins/clappr-nerd-stats/speedtest/Speedtest.d.ts +54 -0
- package/lib/plugins/clappr-nerd-stats/speedtest/Speedtest.d.ts.map +1 -0
- package/lib/plugins/clappr-nerd-stats/speedtest/Speedtest.js +335 -0
- package/lib/plugins/clappr-nerd-stats/speedtest/index.d.ts +9 -0
- package/lib/plugins/clappr-nerd-stats/speedtest/index.d.ts.map +1 -0
- package/lib/plugins/clappr-nerd-stats/speedtest/index.js +154 -0
- package/lib/plugins/clappr-nerd-stats/speedtest/types.d.ts +6 -0
- package/lib/plugins/clappr-nerd-stats/speedtest/types.d.ts.map +1 -0
- package/lib/plugins/clappr-nerd-stats/types.d.ts +4 -0
- package/lib/plugins/clappr-nerd-stats/types.d.ts.map +1 -0
- package/lib/plugins/clappr-stats/ClapprStats.d.ts +56 -0
- package/lib/plugins/clappr-stats/ClapprStats.d.ts.map +1 -0
- package/lib/plugins/clappr-stats/ClapprStats.js +332 -0
- package/lib/plugins/clappr-stats/types.d.ts +50 -0
- package/lib/plugins/clappr-stats/types.d.ts.map +1 -0
- package/lib/plugins/clappr-stats/types.js +5 -0
- package/lib/plugins/clappr-stats/utils.d.ts +3 -0
- package/lib/plugins/clappr-stats/utils.d.ts.map +1 -0
- package/lib/plugins/clappr-stats/utils.js +40 -0
- package/lib/plugins/click-to-pause/ClickToPause.d.ts +2 -2
- package/lib/plugins/click-to-pause/ClickToPause.d.ts.map +1 -1
- package/lib/plugins/click-to-pause/ClickToPause.js +4 -6
- package/lib/plugins/clips/Clips.d.ts +23 -0
- package/lib/plugins/clips/Clips.d.ts.map +1 -0
- package/lib/plugins/clips/Clips.js +109 -0
- package/lib/plugins/context-menu/ContextMenu.d.ts +36 -0
- package/lib/plugins/context-menu/ContextMenu.d.ts.map +1 -0
- package/lib/plugins/context-menu/ContextMenu.js +102 -0
- package/lib/plugins/disable-controls/DisableControls.d.ts +1 -1
- package/lib/plugins/disable-controls/DisableControls.d.ts.map +1 -1
- package/lib/plugins/disable-controls/DisableControls.js +3 -5
- package/lib/plugins/dvr-controls/{DVRControls.d.ts → DvrControls.d.ts} +4 -4
- package/lib/plugins/dvr-controls/DvrControls.d.ts.map +1 -0
- package/lib/plugins/dvr-controls/{DVRControls.js → DvrControls.js} +5 -4
- package/lib/plugins/error-screen/ErrorScreen.d.ts +44 -0
- package/lib/plugins/error-screen/ErrorScreen.d.ts.map +1 -0
- package/lib/plugins/error-screen/ErrorScreen.js +179 -0
- package/lib/plugins/favicon/Favicon.d.ts +24 -0
- package/lib/plugins/favicon/Favicon.d.ts.map +1 -0
- package/lib/plugins/favicon/Favicon.js +106 -0
- package/lib/plugins/google-analytics/GoogleAnalytics.d.ts +30 -0
- package/lib/plugins/google-analytics/GoogleAnalytics.d.ts.map +1 -0
- package/lib/plugins/google-analytics/GoogleAnalytics.js +114 -0
- package/lib/plugins/index.d.ts +38 -0
- package/lib/plugins/index.d.ts.map +1 -0
- package/lib/plugins/index.js +40 -0
- package/lib/plugins/kibo/index.d.ts +23 -0
- package/lib/plugins/kibo/index.d.ts.map +1 -0
- package/lib/plugins/kibo/index.js +199 -0
- package/lib/plugins/level-selector/LevelSelector.d.ts +48 -17
- package/lib/plugins/level-selector/LevelSelector.d.ts.map +1 -1
- package/lib/plugins/level-selector/LevelSelector.js +169 -155
- package/lib/plugins/logo/Logo.d.ts +29 -0
- package/lib/plugins/logo/Logo.d.ts.map +1 -0
- package/lib/plugins/logo/Logo.js +181 -0
- package/lib/plugins/logo/utils/index.d.ts +22 -0
- package/lib/plugins/logo/utils/index.d.ts.map +1 -0
- package/lib/plugins/logo/utils/index.js +32 -0
- package/lib/plugins/media-control/MediaControl.d.ts +20 -25
- package/lib/plugins/media-control/MediaControl.d.ts.map +1 -1
- package/lib/plugins/media-control/MediaControl.js +136 -106
- package/lib/plugins/multi-camera/MultiCamera.d.ts +59 -0
- package/lib/plugins/multi-camera/MultiCamera.d.ts.map +1 -0
- package/lib/plugins/multi-camera/MultiCamera.js +353 -0
- package/lib/plugins/picture-in-picture/PictureInPicture.d.ts +20 -0
- package/lib/plugins/picture-in-picture/PictureInPicture.d.ts.map +1 -0
- package/lib/plugins/picture-in-picture/PictureInPicture.js +68 -0
- package/lib/plugins/playback-rate/PlaybackRate.d.ts +42 -0
- package/lib/plugins/playback-rate/PlaybackRate.d.ts.map +1 -0
- package/lib/plugins/playback-rate/PlaybackRate.js +205 -0
- package/lib/plugins/poster/Poster.d.ts +18 -17
- package/lib/plugins/poster/Poster.d.ts.map +1 -1
- package/lib/plugins/poster/Poster.js +83 -37
- package/lib/plugins/seek-time/SeekTime.d.ts +38 -0
- package/lib/plugins/seek-time/SeekTime.d.ts.map +1 -0
- package/lib/plugins/seek-time/SeekTime.js +153 -0
- package/lib/plugins/share/Share.d.ts +38 -0
- package/lib/plugins/share/Share.d.ts.map +1 -0
- package/lib/plugins/share/Share.js +122 -0
- package/lib/plugins/skip-time/SkipTime.d.ts +28 -0
- package/lib/plugins/skip-time/SkipTime.d.ts.map +1 -0
- package/lib/plugins/skip-time/SkipTime.js +86 -0
- package/lib/plugins/source-controller/SourceController.d.ts +41 -0
- package/lib/plugins/source-controller/SourceController.d.ts.map +1 -0
- package/lib/plugins/source-controller/SourceController.js +199 -0
- package/lib/plugins/spinner-three-bounce/SpinnerThreeBounce.d.ts +26 -0
- package/lib/plugins/spinner-three-bounce/SpinnerThreeBounce.d.ts.map +1 -0
- package/lib/plugins/spinner-three-bounce/SpinnerThreeBounce.js +117 -0
- package/lib/plugins/statistics/Statistics.d.ts +52 -0
- package/lib/plugins/statistics/Statistics.d.ts.map +1 -0
- package/lib/plugins/statistics/Statistics.js +130 -0
- package/lib/plugins/subtitles/Subtitles.d.ts +61 -0
- package/lib/plugins/subtitles/Subtitles.d.ts.map +1 -0
- package/lib/plugins/subtitles/Subtitles.js +354 -0
- package/lib/plugins/thumbnails/Thumbnails.d.ts +47 -0
- package/lib/plugins/thumbnails/Thumbnails.d.ts.map +1 -0
- package/lib/plugins/thumbnails/Thumbnails.js +414 -0
- package/lib/plugins/types.d.ts +8 -0
- package/lib/plugins/types.d.ts.map +1 -0
- package/lib/plugins/types.js +1 -0
- package/lib/plugins/utils.d.ts +5 -0
- package/lib/plugins/utils.d.ts.map +1 -0
- package/lib/plugins/utils.js +68 -0
- package/lib/plugins/vast-ads/VastAds.d.ts +72 -0
- package/lib/plugins/vast-ads/VastAds.d.ts.map +1 -0
- package/lib/plugins/vast-ads/VastAds.js +686 -0
- package/lib/plugins/vast-ads/loaderxml.d.ts +32 -0
- package/lib/plugins/vast-ads/loaderxml.d.ts.map +1 -0
- package/lib/plugins/vast-ads/loaderxml.js +226 -0
- package/lib/plugins/vast-ads/roll.d.ts +60 -0
- package/lib/plugins/vast-ads/roll.d.ts.map +1 -0
- package/lib/plugins/vast-ads/roll.js +415 -0
- package/lib/plugins/vast-ads/rollmanager.d.ts +62 -0
- package/lib/plugins/vast-ads/rollmanager.d.ts.map +1 -0
- package/lib/plugins/vast-ads/rollmanager.js +347 -0
- package/lib/plugins/vast-ads/sctemanager.d.ts +18 -0
- package/lib/plugins/vast-ads/sctemanager.d.ts.map +1 -0
- package/lib/plugins/vast-ads/sctemanager.js +116 -0
- package/lib/plugins/vast-ads/types.d.ts +12 -0
- package/lib/plugins/vast-ads/types.d.ts.map +1 -0
- package/lib/plugins/vast-ads/types.js +1 -0
- package/lib/plugins/vast-ads/urlhandler.d.ts +4 -0
- package/lib/plugins/vast-ads/urlhandler.d.ts.map +1 -0
- package/lib/plugins/vast-ads/urlhandler.js +30 -0
- package/lib/plugins/vast-ads/xmlhttprequest.d.ts +6 -0
- package/lib/plugins/vast-ads/xmlhttprequest.d.ts.map +1 -0
- package/lib/plugins/vast-ads/xmlhttprequest.js +39 -0
- package/lib/plugins/vast-ads/xmlmerge.d.ts +12 -0
- package/lib/plugins/vast-ads/xmlmerge.d.ts.map +1 -0
- package/lib/plugins/vast-ads/xmlmerge.js +82 -0
- package/lib/plugins/volume-fade/VolumeFade.d.ts +21 -0
- package/lib/plugins/volume-fade/VolumeFade.d.ts.map +1 -0
- package/lib/plugins/volume-fade/VolumeFade.js +90 -0
- package/package.json +10 -2
- package/rollup.config.js +32 -2
- package/src/index.core.ts +15 -0
- package/src/index.plugins.ts +41 -0
- package/src/index.ts +2 -15
- package/src/plugins/audio-selector/AudioSelector.ts +370 -0
- package/src/plugins/big-mute-button/BigMuteButton.ts +187 -0
- package/src/plugins/bottom-gear/BottomGear.ts +122 -0
- package/src/plugins/build.ts +1 -0
- package/src/plugins/clappr-nerd-stats/ClapprNerdStats.ts +369 -0
- package/src/plugins/clappr-nerd-stats/formatter.ts +109 -0
- package/src/plugins/clappr-nerd-stats/speedtest/Speedtest.ts +414 -0
- package/src/plugins/clappr-nerd-stats/speedtest/index.ts +183 -0
- package/src/plugins/clappr-nerd-stats/speedtest/types.ts +5 -0
- package/src/plugins/clappr-nerd-stats/types.ts +3 -0
- package/src/plugins/clappr-stats/ClapprStats.ts +441 -0
- package/src/plugins/clappr-stats/types.ts +52 -0
- package/src/plugins/clappr-stats/utils.ts +42 -0
- package/src/plugins/click-to-pause/ClickToPause.ts +93 -0
- package/src/plugins/clips/Clips.ts +152 -0
- package/src/plugins/context-menu/ContextMenu.ts +134 -0
- package/src/plugins/disable-controls/DisableControls.ts +81 -0
- package/src/plugins/dvr-controls/DvrControls.ts +131 -0
- package/src/plugins/error-screen/ErrorScreen.ts +241 -0
- package/src/plugins/favicon/Favicon.ts +137 -0
- package/src/plugins/ga-events/GaEvents.js +395 -0
- package/src/plugins/ga-events/ga-tracking.js +46 -0
- package/src/plugins/google-analytics/GoogleAnalytics.ts +147 -0
- package/src/plugins/index.ts +42 -0
- package/src/plugins/kibo/index.ts +244 -0
- package/src/plugins/level-selector/LevelSelector.ts +400 -0
- package/src/plugins/level-selector/__tests__/LevelSelector.test.ts +72 -0
- package/src/plugins/level-selector/__tests__/__snapshots__/LevelSelector.test.ts.snap +11 -0
- package/src/plugins/logo/Logo.ts +233 -0
- package/src/plugins/logo/utils/index.ts +46 -0
- package/src/plugins/media-control/MediaControl.ts +1383 -0
- package/src/plugins/multi-camera/MultiCamera copy.xts +414 -0
- package/src/plugins/multi-camera/MultiCamera.ts +426 -0
- package/src/plugins/picture-in-picture/PictureInPicture.ts +87 -0
- package/src/plugins/playback-rate/PlaybackRate.ts +269 -0
- package/src/plugins/poster/Poster.ts +298 -0
- package/src/plugins/seek-time/SeekTime.ts +191 -0
- package/src/plugins/share/Share.ts +148 -0
- package/src/plugins/skip-time/SkipTime.ts +109 -0
- package/src/plugins/source-controller/SourceController.ts +239 -0
- package/src/plugins/source-controller/__tests__/SourceController.test.ts +230 -0
- package/src/plugins/spinner-three-bounce/SpinnerThreeBounce.ts +135 -0
- package/src/plugins/statistics/Statistics copy.xts +296 -0
- package/src/plugins/statistics/Statistics.ts +207 -0
- package/src/plugins/subtitles/Subtitles.ts +505 -0
- package/src/plugins/thumbnails/Thumbnails.ts +530 -0
- package/src/plugins/types.ts +7 -0
- package/src/plugins/typings/globals.d.ts +10 -0
- package/src/plugins/typings/parse-srt.d.ts +14 -0
- package/src/plugins/typings/workers.d.ts +3 -0
- package/src/plugins/utils.ts +77 -0
- package/src/plugins/vast-ads/VastAds.ts +915 -0
- package/src/plugins/vast-ads/loaderxml.ts +260 -0
- package/src/plugins/vast-ads/roll.ts +492 -0
- package/src/plugins/vast-ads/rollmanager.ts +403 -0
- package/src/plugins/vast-ads/sctemanager.ts +134 -0
- package/src/plugins/vast-ads/types.ts +14 -0
- package/src/plugins/vast-ads/urlhandler.ts +37 -0
- package/src/plugins/vast-ads/xmlhttprequest.ts +44 -0
- package/src/plugins/vast-ads/xmlmerge.ts +96 -0
- package/src/plugins/video360/VRControls.js +104 -0
- package/src/plugins/video360/VREffect.js +422 -0
- package/src/plugins/video360/Video360.js +979 -0
- package/src/plugins/video360/orbit-oriention-controls.js +1002 -0
- package/src/plugins/video360/utils.js +49 -0
- package/src/plugins/volume-fade/VolumeFade.ts +109 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/HlsPlayback-D9EmONbV.js +0 -747
- package/dist/player.d.ts +0 -646
- package/lib/backend.d.ts +0 -3
- package/lib/backend.d.ts.map +0 -1
- package/lib/backend.js +0 -10
- package/lib/constants.d.ts +0 -1
- package/lib/constants.d.ts.map +0 -1
- package/lib/constants.js +0 -1
- package/lib/gcore.types.d.ts +0 -84
- package/lib/gcore.types.d.ts.map +0 -1
- package/lib/gcore.types.js +0 -9
- package/lib/plugins/dash-playback/DashPlayback.d.ts +0 -73
- package/lib/plugins/dash-playback/DashPlayback.d.ts.map +0 -1
- package/lib/plugins/dash-playback/DashPlayback.js +0 -455
- package/lib/plugins/dash-playback/types.d.ts +0 -6
- package/lib/plugins/dash-playback/types.d.ts.map +0 -1
- package/lib/plugins/dash-plugin/DashPlayback.d.ts +0 -86
- package/lib/plugins/dash-plugin/DashPlayback.d.ts.map +0 -1
- package/lib/plugins/dash-plugin/DashPlayback.js +0 -659
- package/lib/plugins/dvr-controls/DVRControls.d.ts.map +0 -1
- package/lib/plugins/hls-playback/HlsPlayback.d.ts +0 -102
- package/lib/plugins/hls-playback/HlsPlayback.d.ts.map +0 -1
- package/lib/plugins/hls-playback/HlsPlayback.js +0 -815
- package/lib/trace/LogTracer.d.ts +0 -12
- package/lib/trace/LogTracer.d.ts.map +0 -1
- package/lib/trace/LogTracer.js +0 -17
- package/lib/trace/SentryTracer.d.ts +0 -12
- package/lib/trace/SentryTracer.d.ts.map +0 -1
- package/lib/trace/SentryTracer.js +0 -23
- package/lib/trace/Tracer.d.ts +0 -13
- package/lib/trace/Tracer.d.ts.map +0 -1
- package/lib/trace/Tracer.js +0 -15
- package/lib/trace/index.d.ts +0 -18
- package/lib/trace/index.d.ts.map +0 -1
- package/lib/trace/index.js +0 -27
- package/lib/trace/types.d.ts +0 -8
- package/lib/trace/types.d.ts.map +0 -1
- package/lib/tsdoc-metadata.json +0 -11
- package/lib/utils/Logger.d.ts +0 -23
- package/lib/utils/Logger.d.ts.map +0 -1
- package/lib/utils/Logger.js +0 -81
- package/lib/utils/canAutoplay.d.ts +0 -6
- package/lib/utils/canAutoplay.d.ts.map +0 -1
- package/lib/utils/canAutoplay.js +0 -30
- package/lib/utils/queryParams.d.ts +0 -2
- package/lib/utils/queryParams.d.ts.map +0 -1
- package/lib/utils/queryParams.js +0 -4
- package/lib/utils/scripts-load.d.ts +0 -2
- package/lib/utils/scripts-load.d.ts.map +0 -1
- package/lib/utils/scripts-load.js +0 -20
- package/lib/utils/testUtils.d.ts +0 -3
- package/lib/utils/testUtils.d.ts.map +0 -1
- package/lib/utils/testUtils.js +0 -12
- package/lib/utils/utils.d.ts +0 -3
- package/lib/utils/utils.d.ts.map +0 -1
- package/lib/utils/utils.js +0 -31
- /package/lib/plugins/{dash-playback → clappr-nerd-stats/speedtest}/types.js +0 -0
- /package/lib/{trace → plugins/clappr-nerd-stats}/types.js +0 -0
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
import { reportError } from '@gcorevideo/utils';
|
|
2
|
+
|
|
3
|
+
import SpeedtestWorkerModule from '../../../../assets/clappr-nerd-stats/speedtest/speedtest.worker.js';
|
|
4
|
+
|
|
5
|
+
import { TimerId } from '../../types.js';
|
|
6
|
+
|
|
7
|
+
export type Server = {
|
|
8
|
+
id: number;
|
|
9
|
+
country: string;
|
|
10
|
+
name: string;
|
|
11
|
+
server: string;
|
|
12
|
+
dlURL: string;
|
|
13
|
+
ulURL: string;
|
|
14
|
+
pingT: number;
|
|
15
|
+
pingURL: string;
|
|
16
|
+
getIpURL: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
type PerformanceCallback = (t: number) => void;
|
|
20
|
+
|
|
21
|
+
type EndHandler = (success: boolean) => void;
|
|
22
|
+
|
|
23
|
+
export type TestStatusInfo = {
|
|
24
|
+
testState: -1 | 0 | 1 | 2 | 3 | 4 | 5;
|
|
25
|
+
dlStatus: number | 'Fail'; // Mbps/Mibps
|
|
26
|
+
ulStatus: number;
|
|
27
|
+
pingStatus: string;
|
|
28
|
+
clientIp: string;
|
|
29
|
+
serverHostName: string;
|
|
30
|
+
jitterStatus: string;
|
|
31
|
+
dlProgress: 0 | 1;
|
|
32
|
+
ulProgress: 0 | 1;
|
|
33
|
+
pingProgress: 0 | 1;
|
|
34
|
+
testId: string | null;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
type UpdateHandler = (data: TestStatusInfo) => void;
|
|
38
|
+
|
|
39
|
+
type SelectCallback = (server: Server | null) => void;
|
|
40
|
+
|
|
41
|
+
// const T = 'plugins.clappr_nerd_stats.speedtest.Speedtest';
|
|
42
|
+
|
|
43
|
+
export class Speedtest {
|
|
44
|
+
private worker: Worker | null = null;
|
|
45
|
+
|
|
46
|
+
private workerUrl: string | null = null;
|
|
47
|
+
|
|
48
|
+
private _selectServerCalled = false;
|
|
49
|
+
|
|
50
|
+
private _selectedServer: Server | null = null;
|
|
51
|
+
|
|
52
|
+
private _serverList: Server[] = [];
|
|
53
|
+
|
|
54
|
+
private _settings: any = {};
|
|
55
|
+
|
|
56
|
+
private _state = 0;
|
|
57
|
+
|
|
58
|
+
private updater: TimerId | null = null;
|
|
59
|
+
|
|
60
|
+
private _prevData: TestStatusInfo | null = null;
|
|
61
|
+
|
|
62
|
+
private _originalExtra: any; // TODO
|
|
63
|
+
|
|
64
|
+
onend: EndHandler | null = null;
|
|
65
|
+
|
|
66
|
+
onupdate: UpdateHandler | null = null;
|
|
67
|
+
|
|
68
|
+
getState() {
|
|
69
|
+
return this._state;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
setParameter(parameter: string, value: unknown) {
|
|
73
|
+
if (this._state !== 0) {
|
|
74
|
+
throw new Error('You cannot change the test settings after adding server or starting the test');
|
|
75
|
+
}
|
|
76
|
+
this._settings[parameter] = value;
|
|
77
|
+
if (parameter === 'temeletry_extra') {
|
|
78
|
+
this._originalExtra = this._settings.telemetry_extra;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
_checkServerDefinition(server: Server) {
|
|
83
|
+
try {
|
|
84
|
+
if (typeof server.name !== 'string') {
|
|
85
|
+
throw 'Name string missing from server definition (name)';
|
|
86
|
+
}
|
|
87
|
+
if (typeof server.server !== 'string') {
|
|
88
|
+
throw 'Server address string missing from server definition (server)';
|
|
89
|
+
}
|
|
90
|
+
if (server.server.charAt(server.server.length - 1) !== '/') {
|
|
91
|
+
server.server += '/';
|
|
92
|
+
}
|
|
93
|
+
if (server.server.indexOf('//') === 0) {
|
|
94
|
+
server.server = location.protocol + server.server;
|
|
95
|
+
}
|
|
96
|
+
if (typeof server.dlURL !== 'string') {
|
|
97
|
+
throw 'Download URL string missing from server definition (dlURL)';
|
|
98
|
+
}
|
|
99
|
+
if (typeof server.ulURL !== 'string') {
|
|
100
|
+
throw 'Upload URL string missing from server definition (ulURL)';
|
|
101
|
+
}
|
|
102
|
+
if (typeof server.pingURL !== 'string') {
|
|
103
|
+
throw 'Ping URL string missing from server definition (pingURL)';
|
|
104
|
+
}
|
|
105
|
+
if (typeof server.getIpURL !== 'string') {
|
|
106
|
+
throw 'GetIP URL string missing from server definition (getIpURL)';
|
|
107
|
+
}
|
|
108
|
+
} catch (error) {
|
|
109
|
+
// LogManager.exception(error);
|
|
110
|
+
reportError(error);
|
|
111
|
+
throw 'Invalid server definition';
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
addTestPoint(server: Server) {
|
|
116
|
+
this._checkServerDefinition(server);
|
|
117
|
+
if (this._state === 0) {
|
|
118
|
+
this._state = 1;
|
|
119
|
+
}
|
|
120
|
+
if (this._state !== 1) {
|
|
121
|
+
throw 'You can\'t add a server after server selection';
|
|
122
|
+
}
|
|
123
|
+
this._settings.mpot = true;
|
|
124
|
+
this._serverList.push(server);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
addTestPoints(list: Server[]) {
|
|
128
|
+
for (const server of list) {
|
|
129
|
+
this.addTestPoint(server);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
getSelectedServer() {
|
|
134
|
+
if (this._state < 2 || this._selectedServer === null) {
|
|
135
|
+
throw 'No server is selected';
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return this._selectedServer;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
setSelectedServer(server: Server) {
|
|
142
|
+
this._checkServerDefinition(server);
|
|
143
|
+
if (this._state === 3) {
|
|
144
|
+
throw 'You can\'t select a server while the test is running';
|
|
145
|
+
}
|
|
146
|
+
this._selectedServer = server;
|
|
147
|
+
this._state = 2;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
selectServer(result: SelectCallback) {
|
|
151
|
+
if (this._state !== 1) {
|
|
152
|
+
if (this._state === 0) {
|
|
153
|
+
throw 'No test points added';
|
|
154
|
+
}
|
|
155
|
+
if (this._state === 2) {
|
|
156
|
+
throw 'Server already selected';
|
|
157
|
+
}
|
|
158
|
+
if (this._state >= 3) {
|
|
159
|
+
throw 'You can\'t select a server while the test is running';
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (this._selectServerCalled) {
|
|
163
|
+
throw 'selectServer already called';
|
|
164
|
+
} else {
|
|
165
|
+
this._selectServerCalled = true;
|
|
166
|
+
}
|
|
167
|
+
/*this function goes through a list of servers. For each server, the ping is measured, then the server with the function result is called with the best server, or null if all the servers were down.
|
|
168
|
+
*/
|
|
169
|
+
const select = (serverList: Server[], result: SelectCallback) => {
|
|
170
|
+
//pings the specified URL, then calls the function result. Result will receive a parameter which is either the time it took to ping the URL, or -1 if something went wrong.
|
|
171
|
+
const PING_TIMEOUT = 2000;
|
|
172
|
+
let USE_PING_TIMEOUT = true; //will be disabled on unsupported browsers
|
|
173
|
+
|
|
174
|
+
if (/MSIE.(\d+\.\d+)/i.test(navigator.userAgent)) {
|
|
175
|
+
//IE11 doesn't support XHR timeout
|
|
176
|
+
USE_PING_TIMEOUT = false;
|
|
177
|
+
}
|
|
178
|
+
const ping = function (url: string, result: PerformanceCallback) {
|
|
179
|
+
url += (url.match(/\?/) ? '&' : '?') + 'cors=true';
|
|
180
|
+
const xhr = new XMLHttpRequest();
|
|
181
|
+
const t = new Date().getTime();
|
|
182
|
+
|
|
183
|
+
xhr.onload = function () {
|
|
184
|
+
if (xhr.responseText.length === 0) {
|
|
185
|
+
//we expect an empty response
|
|
186
|
+
let instspd = new Date().getTime() - t; //rough timing estimate
|
|
187
|
+
|
|
188
|
+
try {
|
|
189
|
+
//try to get more accurate timing using performance API
|
|
190
|
+
const pl: PerformanceEntryList = performance.getEntriesByName(url);
|
|
191
|
+
|
|
192
|
+
const pe: PerformanceResourceTiming = pl[pl.length - 1] as PerformanceResourceTiming;
|
|
193
|
+
let d = pe.responseStart - pe.requestStart;
|
|
194
|
+
|
|
195
|
+
if (d <= 0) {
|
|
196
|
+
d = pe.duration;
|
|
197
|
+
}
|
|
198
|
+
if (d > 0 && d < instspd) {
|
|
199
|
+
instspd = d;
|
|
200
|
+
}
|
|
201
|
+
} catch (error) {
|
|
202
|
+
// LogManager.exception(error);
|
|
203
|
+
reportError(error);
|
|
204
|
+
}
|
|
205
|
+
result(instspd);
|
|
206
|
+
} else {
|
|
207
|
+
result(-1);
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
xhr.onerror = function () {
|
|
211
|
+
result(-1);
|
|
212
|
+
};
|
|
213
|
+
xhr.open('GET', url);
|
|
214
|
+
if (USE_PING_TIMEOUT) {
|
|
215
|
+
try {
|
|
216
|
+
xhr.timeout = PING_TIMEOUT;
|
|
217
|
+
xhr.ontimeout = xhr.onerror;
|
|
218
|
+
} catch (error) {
|
|
219
|
+
// LogManager.exception(error);
|
|
220
|
+
reportError(error);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
xhr.send();
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
//this function repeatedly pings a server to get a good estimate of the ping. When it's done, it calls the done function without parameters. At the end of the execution, the server will have a new parameter called pingT, which is either the best ping we got from the server or -1 if something went wrong.
|
|
227
|
+
const PINGS = 3, //up to 3 pings are performed, unless the server is down...
|
|
228
|
+
SLOW_THRESHOLD = 500; //...or one of the pings is above this threshold
|
|
229
|
+
const checkServer = function (server: Server, done: () => void) {
|
|
230
|
+
let i = 0;
|
|
231
|
+
|
|
232
|
+
server.pingT = -1;
|
|
233
|
+
if (server.server.indexOf(location.protocol) === -1) {
|
|
234
|
+
done();
|
|
235
|
+
} else {
|
|
236
|
+
const nextPing = function () {
|
|
237
|
+
if (i++ === PINGS) {
|
|
238
|
+
done();
|
|
239
|
+
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
ping(
|
|
243
|
+
server.server + server.pingURL,
|
|
244
|
+
function (t) {
|
|
245
|
+
if (t >= 0) {
|
|
246
|
+
if (t < server.pingT || server.pingT === -1) {
|
|
247
|
+
server.pingT = t;
|
|
248
|
+
}
|
|
249
|
+
if (t < SLOW_THRESHOLD) {
|
|
250
|
+
nextPing();
|
|
251
|
+
} else {
|
|
252
|
+
done();
|
|
253
|
+
}
|
|
254
|
+
} else {
|
|
255
|
+
done();
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
);
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
nextPing();
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
//check servers in list, one by one
|
|
265
|
+
const i = 0;
|
|
266
|
+
const done = function () {
|
|
267
|
+
let bestServer = null;
|
|
268
|
+
|
|
269
|
+
for (let i = 0; i < serverList.length; i++) {
|
|
270
|
+
if (
|
|
271
|
+
serverList[i].pingT !== -1 &&
|
|
272
|
+
(bestServer === null || serverList[i].pingT < bestServer.pingT)
|
|
273
|
+
) {
|
|
274
|
+
bestServer = serverList[i];
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
result(bestServer);
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
serverList.forEach(server => {
|
|
281
|
+
checkServer(server, done);
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
if (i === serverList.length) {
|
|
285
|
+
done();
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
//parallel server selection
|
|
290
|
+
const CONCURRENCY = 6;
|
|
291
|
+
const serverLists: Array<Server[]> = [];
|
|
292
|
+
|
|
293
|
+
for (let i = 0; i < CONCURRENCY; i++) {
|
|
294
|
+
serverLists[i] = [];
|
|
295
|
+
}
|
|
296
|
+
for (let i = 0; i < this._serverList.length; i++) {
|
|
297
|
+
serverLists[i % CONCURRENCY].push(this._serverList[i]);
|
|
298
|
+
}
|
|
299
|
+
let completed = 0;
|
|
300
|
+
let bestServer: Server | null = null;
|
|
301
|
+
|
|
302
|
+
for (let i = 0; i < CONCURRENCY; i++) {
|
|
303
|
+
select(
|
|
304
|
+
serverLists[i],
|
|
305
|
+
(server: Server | null) => {
|
|
306
|
+
if (server !== null) {
|
|
307
|
+
if (bestServer === null || server.pingT < bestServer.pingT) {
|
|
308
|
+
bestServer = server;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
completed++;
|
|
312
|
+
if (completed === CONCURRENCY) {
|
|
313
|
+
this._selectedServer = bestServer;
|
|
314
|
+
this._state = 2;
|
|
315
|
+
if (result) {
|
|
316
|
+
result(bestServer);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
start() {
|
|
325
|
+
if (this._state === 3) {
|
|
326
|
+
throw 'Test already running';
|
|
327
|
+
}
|
|
328
|
+
this.worker = this.initWorker();
|
|
329
|
+
|
|
330
|
+
this.worker.onmessage = (e: MessageEvent) => {
|
|
331
|
+
if (e.data === this._prevData) {
|
|
332
|
+
return;
|
|
333
|
+
} else {
|
|
334
|
+
this._prevData = e.data;
|
|
335
|
+
}
|
|
336
|
+
const data = e.data;
|
|
337
|
+
|
|
338
|
+
try {
|
|
339
|
+
if (this.onupdate) {
|
|
340
|
+
this.onupdate(data);
|
|
341
|
+
}
|
|
342
|
+
} catch (error) {
|
|
343
|
+
// LogManager.message('Speedtest onupdate event threw exception: ' + error, SentryLogLevel.ERROR);
|
|
344
|
+
reportError(error);
|
|
345
|
+
}
|
|
346
|
+
if (data.testState >= 4) {
|
|
347
|
+
try {
|
|
348
|
+
if (this.onend) {
|
|
349
|
+
this.onend(data.testState === 5);
|
|
350
|
+
}
|
|
351
|
+
} catch (error) {
|
|
352
|
+
// LogManager.message('Speedtest onend event threw exception: ' + error, SentryLogLevel.ERROR);
|
|
353
|
+
reportError(error);
|
|
354
|
+
}
|
|
355
|
+
if (this.updater !== null) {
|
|
356
|
+
clearInterval(this.updater);
|
|
357
|
+
this.updater = null;
|
|
358
|
+
}
|
|
359
|
+
this._state = 4;
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
this.updater = setInterval(
|
|
363
|
+
() => {
|
|
364
|
+
this.worker?.postMessage('status');
|
|
365
|
+
},
|
|
366
|
+
300
|
|
367
|
+
);
|
|
368
|
+
if (this._state === 1) {
|
|
369
|
+
throw 'When using multiple points of test, you must call selectServer before starting the test';
|
|
370
|
+
}
|
|
371
|
+
if (this._state === 2 && this._selectedServer) {
|
|
372
|
+
this._settings.url_dl =
|
|
373
|
+
this._selectedServer.server + this._selectedServer.dlURL;
|
|
374
|
+
this._settings.url_ul =
|
|
375
|
+
this._selectedServer.server + this._selectedServer.ulURL;
|
|
376
|
+
this._settings.url_ping =
|
|
377
|
+
this._selectedServer.server + this._selectedServer.pingURL;
|
|
378
|
+
this._settings.url_getIp =
|
|
379
|
+
this._selectedServer.server + this._selectedServer.getIpURL;
|
|
380
|
+
if (typeof this._originalExtra !== 'undefined') {
|
|
381
|
+
this._settings.telemetry_extra = JSON.stringify({
|
|
382
|
+
server: this._selectedServer.name,
|
|
383
|
+
extra: this._originalExtra
|
|
384
|
+
});
|
|
385
|
+
} else {
|
|
386
|
+
this._settings.telemetry_extra = JSON.stringify({
|
|
387
|
+
server: this._selectedServer.name
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
this._state = 3;
|
|
392
|
+
this.worker.postMessage('start ' + JSON.stringify(this._settings));
|
|
393
|
+
|
|
394
|
+
// ... [rest of the logic remains unchanged] ...
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
abort() {
|
|
398
|
+
if (this._state < 3) {
|
|
399
|
+
throw new Error('You cannot abort a test that\'s not started yet');
|
|
400
|
+
}
|
|
401
|
+
if (this._state < 4) {
|
|
402
|
+
this.worker?.postMessage('abort');
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
private initWorker(): Worker {
|
|
407
|
+
if (this.workerUrl) {
|
|
408
|
+
// TODO in destructor as well
|
|
409
|
+
URL.revokeObjectURL(this.workerUrl);
|
|
410
|
+
}
|
|
411
|
+
this.workerUrl = URL.createObjectURL(new Blob([SpeedtestWorkerModule], { type: 'application/javascript' }));
|
|
412
|
+
return new Worker(this.workerUrl);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { type Server, type TestStatusInfo, Speedtest } from './Speedtest.js';
|
|
2
|
+
import { CustomMetrics } from './types.js';
|
|
3
|
+
|
|
4
|
+
const DIGITS_THRESHOLD = 99999;
|
|
5
|
+
const DEFAULT_DOWNLOAD_SPEED = '0.00';
|
|
6
|
+
|
|
7
|
+
const DRAW_SIZE = 5;
|
|
8
|
+
|
|
9
|
+
// const T = 'plugins.clappr_nerd_stats.speedtest';
|
|
10
|
+
|
|
11
|
+
function limitDigits(value: number): string {
|
|
12
|
+
return value > DIGITS_THRESHOLD ? '> ' + DIGITS_THRESHOLD : value.toFixed(2);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function getElementById(id: string): Element | null {
|
|
16
|
+
return document.getElementById(id);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const speedTest = new Speedtest();
|
|
20
|
+
|
|
21
|
+
const speedtestResults: number[] = [];
|
|
22
|
+
|
|
23
|
+
const serversList: Server[] = [];
|
|
24
|
+
|
|
25
|
+
const getColor = (speedValue: number): string => {
|
|
26
|
+
if (speedValue < 3) {
|
|
27
|
+
return '#df564d';
|
|
28
|
+
} else if (speedValue < 7) {
|
|
29
|
+
return '#df934d';
|
|
30
|
+
} else if (speedValue < 13) {
|
|
31
|
+
return '#dfd04d';
|
|
32
|
+
} else if (speedValue < 25) {
|
|
33
|
+
return '#c2df4d';
|
|
34
|
+
} else {
|
|
35
|
+
return '#73df4d';
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export function drawSpeedTestResults() {
|
|
40
|
+
const canvas = document.getElementById('speedTestCanvas');
|
|
41
|
+
if (!canvas) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const ctx = (canvas as HTMLCanvasElement).getContext('2d');
|
|
45
|
+
if (!ctx) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
ctx.clearRect(0, 0, (canvas as HTMLCanvasElement).width, (canvas as HTMLCanvasElement).height);
|
|
49
|
+
|
|
50
|
+
const barWidth = (canvas as HTMLCanvasElement).width / DRAW_SIZE;
|
|
51
|
+
|
|
52
|
+
for (let i = 0; i < speedtestResults.length; i++) {
|
|
53
|
+
const height = (speedtestResults[i] / 100) * (canvas as HTMLCanvasElement).height; // assuming max speed is 100 for 100% height
|
|
54
|
+
|
|
55
|
+
ctx.fillStyle = getColor(speedtestResults[i]);
|
|
56
|
+
ctx.fillRect(i * barWidth, (canvas as HTMLCanvasElement).height - height, barWidth, height);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
let inited: Promise<void> | null = null;
|
|
61
|
+
|
|
62
|
+
export const initSpeedTest = (customMetrics: CustomMetrics): Promise<void> => {
|
|
63
|
+
if (inited !== null) {
|
|
64
|
+
return inited;
|
|
65
|
+
}
|
|
66
|
+
inited = (async () => {
|
|
67
|
+
// TODO: fix server selection
|
|
68
|
+
// const response = await fetch('https://iam.gcdn.co/info/json');
|
|
69
|
+
// const data = await response.json();
|
|
70
|
+
|
|
71
|
+
// SPEEDTEST_SERVERS[0].server = `http://${data.Server}.fe.gc.onl/speedtest/`;
|
|
72
|
+
|
|
73
|
+
speedTest.onupdate = function (data: TestStatusInfo) { //callback to update data in UI
|
|
74
|
+
if (![0, 1].includes(data.testState) && typeof data.dlStatus === 'number') {
|
|
75
|
+
const dlSpeed = limitDigits(data.dlStatus);
|
|
76
|
+
const el = getElementById('dlText');
|
|
77
|
+
if (el) {
|
|
78
|
+
el.textContent = dlSpeed;
|
|
79
|
+
}
|
|
80
|
+
customMetrics.connectionSpeed = rankConnectionSpeed(data.dlStatus);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const pingStatus = parseFloat(data.pingStatus);
|
|
84
|
+
if (pingStatus > 0) {
|
|
85
|
+
const el = getElementById('pingText');
|
|
86
|
+
if (el) {
|
|
87
|
+
el.textContent = data.pingStatus;
|
|
88
|
+
}
|
|
89
|
+
customMetrics.ping = pingStatus;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const jitterStatus = parseFloat(data.jitterStatus);
|
|
93
|
+
if (jitterStatus > 0) {
|
|
94
|
+
const el = getElementById('jitterText');
|
|
95
|
+
if (el) {
|
|
96
|
+
el.textContent = data.jitterStatus;
|
|
97
|
+
}
|
|
98
|
+
customMetrics.jitter = jitterStatus;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (data.dlStatus === 0) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (typeof data.dlStatus === 'number') {
|
|
105
|
+
speedtestResults.push(data.dlStatus);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Keep only the last 10 results
|
|
109
|
+
if (speedtestResults.length > DRAW_SIZE) {
|
|
110
|
+
speedtestResults.shift();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
drawSpeedTestResults();
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
speedTest.onend = function (aborted: boolean) { //callback for test ended/aborted
|
|
117
|
+
if (aborted) { //if the test was aborted, clear the UI and prepare for new test
|
|
118
|
+
// TODO: fix
|
|
119
|
+
const el = getElementById('dlText');
|
|
120
|
+
if (el) {
|
|
121
|
+
el.textContent = DEFAULT_DOWNLOAD_SPEED;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
// getElementById('dlText').textContent = DEFAULT_DOWNLOAD_SPEED;
|
|
126
|
+
|
|
127
|
+
await fetch('https://iam.gcdn.co/info/json')
|
|
128
|
+
.then(r => r.json())
|
|
129
|
+
.then(data => {
|
|
130
|
+
const country = data['Server Country code'].toLowerCase();
|
|
131
|
+
const server = serversList.find(s => s.country === country) || serversList[0];
|
|
132
|
+
if (!server) {
|
|
133
|
+
throw new Error('Failed to select a server');
|
|
134
|
+
}
|
|
135
|
+
speedTest.addTestPoint(server);
|
|
136
|
+
speedTest.setSelectedServer(server);
|
|
137
|
+
});
|
|
138
|
+
})();
|
|
139
|
+
|
|
140
|
+
return inited;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export const stopSpeedtest = () => {
|
|
144
|
+
if (speedTest.getState() === 3) {
|
|
145
|
+
speedTest.abort();
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export const startSpeedtest = () => {
|
|
150
|
+
if (speedTest.getState() !== 3) {
|
|
151
|
+
speedTest.start();
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export const clearSpeedTestResults = () => {
|
|
156
|
+
speedtestResults.splice(0, speedtestResults.length);
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
export function configureSpeedTest(servers: Server[]) {
|
|
160
|
+
// speedTest.addTestPoints(servers);
|
|
161
|
+
serversList.push(...servers);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
type ConnectionSpeed = 0 | 1 | 2 | 3 | 4 | 5;
|
|
165
|
+
|
|
166
|
+
function rankConnectionSpeed(dlSpeed: number): ConnectionSpeed {
|
|
167
|
+
if (dlSpeed >= 100) {
|
|
168
|
+
return 5;
|
|
169
|
+
}
|
|
170
|
+
if (dlSpeed >= 25) {
|
|
171
|
+
return 4;
|
|
172
|
+
}
|
|
173
|
+
if (dlSpeed >= 10) {
|
|
174
|
+
return 3;
|
|
175
|
+
}
|
|
176
|
+
if (dlSpeed >= 2) {
|
|
177
|
+
return 2;
|
|
178
|
+
}
|
|
179
|
+
if (dlSpeed >= 0.5) {
|
|
180
|
+
return 1;
|
|
181
|
+
}
|
|
182
|
+
return 0;
|
|
183
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export type MetricsKind = 'general' | 'timers' | 'extra';
|
|
2
|
+
export type MetricsType = 'volume' | 'startup' | 'watch' | 'pause' | 'buffering' | 'session' | 'latency' | 'buffersize' | 'duration' | 'currentTime' | 'bitrateWeightedMean' | 'bitrateMostUsed' | 'bandwidth' | 'watchedPercentage' | 'bufferingPercentage';
|
|
3
|
+
export type MetricsValue = number;
|