@gcorevideo/player 2.18.3 → 2.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/plugins/index.js/index.plugins.js +40837 -0
- package/dist/plugins/index.plugins.js +40837 -0
- 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 +38 -0
- package/lib/index.plugins.d.ts.map +1 -0
- package/lib/index.plugins.js +40 -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/speedtest/types.js +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-nerd-stats/types.js +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 +4 -4
- package/lib/plugins/dvr-controls/DVRControls.d.ts.map +1 -1
- package/lib/plugins/dvr-controls/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 +42 -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
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
import { reportError } from '@gcorevideo/utils';
|
|
2
|
+
import SpeedtestWorkerModule from '../../../../assets/clappr-nerd-stats/speedtest/speedtest.worker.js';
|
|
3
|
+
// const T = 'plugins.clappr_nerd_stats.speedtest.Speedtest';
|
|
4
|
+
export class Speedtest {
|
|
5
|
+
worker = null;
|
|
6
|
+
workerUrl = null;
|
|
7
|
+
_selectServerCalled = false;
|
|
8
|
+
_selectedServer = null;
|
|
9
|
+
_serverList = [];
|
|
10
|
+
_settings = {};
|
|
11
|
+
_state = 0;
|
|
12
|
+
updater = null;
|
|
13
|
+
_prevData = null;
|
|
14
|
+
_originalExtra; // TODO
|
|
15
|
+
onend = null;
|
|
16
|
+
onupdate = null;
|
|
17
|
+
getState() {
|
|
18
|
+
return this._state;
|
|
19
|
+
}
|
|
20
|
+
setParameter(parameter, value) {
|
|
21
|
+
if (this._state !== 0) {
|
|
22
|
+
throw new Error('You cannot change the test settings after adding server or starting the test');
|
|
23
|
+
}
|
|
24
|
+
this._settings[parameter] = value;
|
|
25
|
+
if (parameter === 'temeletry_extra') {
|
|
26
|
+
this._originalExtra = this._settings.telemetry_extra;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
_checkServerDefinition(server) {
|
|
30
|
+
try {
|
|
31
|
+
if (typeof server.name !== 'string') {
|
|
32
|
+
throw 'Name string missing from server definition (name)';
|
|
33
|
+
}
|
|
34
|
+
if (typeof server.server !== 'string') {
|
|
35
|
+
throw 'Server address string missing from server definition (server)';
|
|
36
|
+
}
|
|
37
|
+
if (server.server.charAt(server.server.length - 1) !== '/') {
|
|
38
|
+
server.server += '/';
|
|
39
|
+
}
|
|
40
|
+
if (server.server.indexOf('//') === 0) {
|
|
41
|
+
server.server = location.protocol + server.server;
|
|
42
|
+
}
|
|
43
|
+
if (typeof server.dlURL !== 'string') {
|
|
44
|
+
throw 'Download URL string missing from server definition (dlURL)';
|
|
45
|
+
}
|
|
46
|
+
if (typeof server.ulURL !== 'string') {
|
|
47
|
+
throw 'Upload URL string missing from server definition (ulURL)';
|
|
48
|
+
}
|
|
49
|
+
if (typeof server.pingURL !== 'string') {
|
|
50
|
+
throw 'Ping URL string missing from server definition (pingURL)';
|
|
51
|
+
}
|
|
52
|
+
if (typeof server.getIpURL !== 'string') {
|
|
53
|
+
throw 'GetIP URL string missing from server definition (getIpURL)';
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
// LogManager.exception(error);
|
|
58
|
+
reportError(error);
|
|
59
|
+
throw 'Invalid server definition';
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
addTestPoint(server) {
|
|
63
|
+
this._checkServerDefinition(server);
|
|
64
|
+
if (this._state === 0) {
|
|
65
|
+
this._state = 1;
|
|
66
|
+
}
|
|
67
|
+
if (this._state !== 1) {
|
|
68
|
+
throw 'You can\'t add a server after server selection';
|
|
69
|
+
}
|
|
70
|
+
this._settings.mpot = true;
|
|
71
|
+
this._serverList.push(server);
|
|
72
|
+
}
|
|
73
|
+
addTestPoints(list) {
|
|
74
|
+
for (const server of list) {
|
|
75
|
+
this.addTestPoint(server);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
getSelectedServer() {
|
|
79
|
+
if (this._state < 2 || this._selectedServer === null) {
|
|
80
|
+
throw 'No server is selected';
|
|
81
|
+
}
|
|
82
|
+
return this._selectedServer;
|
|
83
|
+
}
|
|
84
|
+
setSelectedServer(server) {
|
|
85
|
+
this._checkServerDefinition(server);
|
|
86
|
+
if (this._state === 3) {
|
|
87
|
+
throw 'You can\'t select a server while the test is running';
|
|
88
|
+
}
|
|
89
|
+
this._selectedServer = server;
|
|
90
|
+
this._state = 2;
|
|
91
|
+
}
|
|
92
|
+
selectServer(result) {
|
|
93
|
+
if (this._state !== 1) {
|
|
94
|
+
if (this._state === 0) {
|
|
95
|
+
throw 'No test points added';
|
|
96
|
+
}
|
|
97
|
+
if (this._state === 2) {
|
|
98
|
+
throw 'Server already selected';
|
|
99
|
+
}
|
|
100
|
+
if (this._state >= 3) {
|
|
101
|
+
throw 'You can\'t select a server while the test is running';
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (this._selectServerCalled) {
|
|
105
|
+
throw 'selectServer already called';
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
this._selectServerCalled = true;
|
|
109
|
+
}
|
|
110
|
+
/*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.
|
|
111
|
+
*/
|
|
112
|
+
const select = (serverList, result) => {
|
|
113
|
+
//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.
|
|
114
|
+
const PING_TIMEOUT = 2000;
|
|
115
|
+
let USE_PING_TIMEOUT = true; //will be disabled on unsupported browsers
|
|
116
|
+
if (/MSIE.(\d+\.\d+)/i.test(navigator.userAgent)) {
|
|
117
|
+
//IE11 doesn't support XHR timeout
|
|
118
|
+
USE_PING_TIMEOUT = false;
|
|
119
|
+
}
|
|
120
|
+
const ping = function (url, result) {
|
|
121
|
+
url += (url.match(/\?/) ? '&' : '?') + 'cors=true';
|
|
122
|
+
const xhr = new XMLHttpRequest();
|
|
123
|
+
const t = new Date().getTime();
|
|
124
|
+
xhr.onload = function () {
|
|
125
|
+
if (xhr.responseText.length === 0) {
|
|
126
|
+
//we expect an empty response
|
|
127
|
+
let instspd = new Date().getTime() - t; //rough timing estimate
|
|
128
|
+
try {
|
|
129
|
+
//try to get more accurate timing using performance API
|
|
130
|
+
const pl = performance.getEntriesByName(url);
|
|
131
|
+
const pe = pl[pl.length - 1];
|
|
132
|
+
let d = pe.responseStart - pe.requestStart;
|
|
133
|
+
if (d <= 0) {
|
|
134
|
+
d = pe.duration;
|
|
135
|
+
}
|
|
136
|
+
if (d > 0 && d < instspd) {
|
|
137
|
+
instspd = d;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
// LogManager.exception(error);
|
|
142
|
+
reportError(error);
|
|
143
|
+
}
|
|
144
|
+
result(instspd);
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
result(-1);
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
xhr.onerror = function () {
|
|
151
|
+
result(-1);
|
|
152
|
+
};
|
|
153
|
+
xhr.open('GET', url);
|
|
154
|
+
if (USE_PING_TIMEOUT) {
|
|
155
|
+
try {
|
|
156
|
+
xhr.timeout = PING_TIMEOUT;
|
|
157
|
+
xhr.ontimeout = xhr.onerror;
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
// LogManager.exception(error);
|
|
161
|
+
reportError(error);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
xhr.send();
|
|
165
|
+
};
|
|
166
|
+
//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.
|
|
167
|
+
const PINGS = 3, //up to 3 pings are performed, unless the server is down...
|
|
168
|
+
SLOW_THRESHOLD = 500; //...or one of the pings is above this threshold
|
|
169
|
+
const checkServer = function (server, done) {
|
|
170
|
+
let i = 0;
|
|
171
|
+
server.pingT = -1;
|
|
172
|
+
if (server.server.indexOf(location.protocol) === -1) {
|
|
173
|
+
done();
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
const nextPing = function () {
|
|
177
|
+
if (i++ === PINGS) {
|
|
178
|
+
done();
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
ping(server.server + server.pingURL, function (t) {
|
|
182
|
+
if (t >= 0) {
|
|
183
|
+
if (t < server.pingT || server.pingT === -1) {
|
|
184
|
+
server.pingT = t;
|
|
185
|
+
}
|
|
186
|
+
if (t < SLOW_THRESHOLD) {
|
|
187
|
+
nextPing();
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
done();
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
done();
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
};
|
|
198
|
+
nextPing();
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
//check servers in list, one by one
|
|
202
|
+
const i = 0;
|
|
203
|
+
const done = function () {
|
|
204
|
+
let bestServer = null;
|
|
205
|
+
for (let i = 0; i < serverList.length; i++) {
|
|
206
|
+
if (serverList[i].pingT !== -1 &&
|
|
207
|
+
(bestServer === null || serverList[i].pingT < bestServer.pingT)) {
|
|
208
|
+
bestServer = serverList[i];
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
result(bestServer);
|
|
212
|
+
};
|
|
213
|
+
serverList.forEach(server => {
|
|
214
|
+
checkServer(server, done);
|
|
215
|
+
});
|
|
216
|
+
if (i === serverList.length) {
|
|
217
|
+
done();
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
//parallel server selection
|
|
221
|
+
const CONCURRENCY = 6;
|
|
222
|
+
const serverLists = [];
|
|
223
|
+
for (let i = 0; i < CONCURRENCY; i++) {
|
|
224
|
+
serverLists[i] = [];
|
|
225
|
+
}
|
|
226
|
+
for (let i = 0; i < this._serverList.length; i++) {
|
|
227
|
+
serverLists[i % CONCURRENCY].push(this._serverList[i]);
|
|
228
|
+
}
|
|
229
|
+
let completed = 0;
|
|
230
|
+
let bestServer = null;
|
|
231
|
+
for (let i = 0; i < CONCURRENCY; i++) {
|
|
232
|
+
select(serverLists[i], (server) => {
|
|
233
|
+
if (server !== null) {
|
|
234
|
+
if (bestServer === null || server.pingT < bestServer.pingT) {
|
|
235
|
+
bestServer = server;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
completed++;
|
|
239
|
+
if (completed === CONCURRENCY) {
|
|
240
|
+
this._selectedServer = bestServer;
|
|
241
|
+
this._state = 2;
|
|
242
|
+
if (result) {
|
|
243
|
+
result(bestServer);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
start() {
|
|
250
|
+
if (this._state === 3) {
|
|
251
|
+
throw 'Test already running';
|
|
252
|
+
}
|
|
253
|
+
this.worker = this.initWorker();
|
|
254
|
+
this.worker.onmessage = (e) => {
|
|
255
|
+
if (e.data === this._prevData) {
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
this._prevData = e.data;
|
|
260
|
+
}
|
|
261
|
+
const data = e.data;
|
|
262
|
+
try {
|
|
263
|
+
if (this.onupdate) {
|
|
264
|
+
this.onupdate(data);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
catch (error) {
|
|
268
|
+
// LogManager.message('Speedtest onupdate event threw exception: ' + error, SentryLogLevel.ERROR);
|
|
269
|
+
reportError(error);
|
|
270
|
+
}
|
|
271
|
+
if (data.testState >= 4) {
|
|
272
|
+
try {
|
|
273
|
+
if (this.onend) {
|
|
274
|
+
this.onend(data.testState === 5);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
catch (error) {
|
|
278
|
+
// LogManager.message('Speedtest onend event threw exception: ' + error, SentryLogLevel.ERROR);
|
|
279
|
+
reportError(error);
|
|
280
|
+
}
|
|
281
|
+
if (this.updater !== null) {
|
|
282
|
+
clearInterval(this.updater);
|
|
283
|
+
this.updater = null;
|
|
284
|
+
}
|
|
285
|
+
this._state = 4;
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
this.updater = setInterval(() => {
|
|
289
|
+
this.worker?.postMessage('status');
|
|
290
|
+
}, 300);
|
|
291
|
+
if (this._state === 1) {
|
|
292
|
+
throw 'When using multiple points of test, you must call selectServer before starting the test';
|
|
293
|
+
}
|
|
294
|
+
if (this._state === 2 && this._selectedServer) {
|
|
295
|
+
this._settings.url_dl =
|
|
296
|
+
this._selectedServer.server + this._selectedServer.dlURL;
|
|
297
|
+
this._settings.url_ul =
|
|
298
|
+
this._selectedServer.server + this._selectedServer.ulURL;
|
|
299
|
+
this._settings.url_ping =
|
|
300
|
+
this._selectedServer.server + this._selectedServer.pingURL;
|
|
301
|
+
this._settings.url_getIp =
|
|
302
|
+
this._selectedServer.server + this._selectedServer.getIpURL;
|
|
303
|
+
if (typeof this._originalExtra !== 'undefined') {
|
|
304
|
+
this._settings.telemetry_extra = JSON.stringify({
|
|
305
|
+
server: this._selectedServer.name,
|
|
306
|
+
extra: this._originalExtra
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
this._settings.telemetry_extra = JSON.stringify({
|
|
311
|
+
server: this._selectedServer.name
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
this._state = 3;
|
|
316
|
+
this.worker.postMessage('start ' + JSON.stringify(this._settings));
|
|
317
|
+
// ... [rest of the logic remains unchanged] ...
|
|
318
|
+
}
|
|
319
|
+
abort() {
|
|
320
|
+
if (this._state < 3) {
|
|
321
|
+
throw new Error('You cannot abort a test that\'s not started yet');
|
|
322
|
+
}
|
|
323
|
+
if (this._state < 4) {
|
|
324
|
+
this.worker?.postMessage('abort');
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
initWorker() {
|
|
328
|
+
if (this.workerUrl) {
|
|
329
|
+
// TODO in destructor as well
|
|
330
|
+
URL.revokeObjectURL(this.workerUrl);
|
|
331
|
+
}
|
|
332
|
+
this.workerUrl = URL.createObjectURL(new Blob([SpeedtestWorkerModule], { type: 'application/javascript' }));
|
|
333
|
+
return new Worker(this.workerUrl);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Server } from './Speedtest.js';
|
|
2
|
+
import { CustomMetrics } from './types.js';
|
|
3
|
+
export declare function drawSpeedTestResults(): void;
|
|
4
|
+
export declare const initSpeedTest: (customMetrics: CustomMetrics) => Promise<void>;
|
|
5
|
+
export declare const stopSpeedtest: () => void;
|
|
6
|
+
export declare const startSpeedtest: () => void;
|
|
7
|
+
export declare const clearSpeedTestResults: () => void;
|
|
8
|
+
export declare function configureSpeedTest(servers: Server[]): void;
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/clappr-nerd-stats/speedtest/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAkC,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAqC3C,wBAAgB,oBAAoB,SAmBnC;AAID,eAAO,MAAM,aAAa,kBAAmB,aAAa,KAAG,OAAO,CAAC,IAAI,CA+ExE,CAAC;AAEF,eAAO,MAAM,aAAa,YAIzB,CAAC;AAEF,eAAO,MAAM,cAAc,YAI1B,CAAC;AAEF,eAAO,MAAM,qBAAqB,YAEjC,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,QAGnD"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { Speedtest } from './Speedtest.js';
|
|
2
|
+
const DIGITS_THRESHOLD = 99999;
|
|
3
|
+
const DEFAULT_DOWNLOAD_SPEED = '0.00';
|
|
4
|
+
const DRAW_SIZE = 5;
|
|
5
|
+
// const T = 'plugins.clappr_nerd_stats.speedtest';
|
|
6
|
+
function limitDigits(value) {
|
|
7
|
+
return value > DIGITS_THRESHOLD ? '> ' + DIGITS_THRESHOLD : value.toFixed(2);
|
|
8
|
+
}
|
|
9
|
+
function getElementById(id) {
|
|
10
|
+
return document.getElementById(id);
|
|
11
|
+
}
|
|
12
|
+
const speedTest = new Speedtest();
|
|
13
|
+
const speedtestResults = [];
|
|
14
|
+
const serversList = [];
|
|
15
|
+
const getColor = (speedValue) => {
|
|
16
|
+
if (speedValue < 3) {
|
|
17
|
+
return '#df564d';
|
|
18
|
+
}
|
|
19
|
+
else if (speedValue < 7) {
|
|
20
|
+
return '#df934d';
|
|
21
|
+
}
|
|
22
|
+
else if (speedValue < 13) {
|
|
23
|
+
return '#dfd04d';
|
|
24
|
+
}
|
|
25
|
+
else if (speedValue < 25) {
|
|
26
|
+
return '#c2df4d';
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
return '#73df4d';
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
export function drawSpeedTestResults() {
|
|
33
|
+
const canvas = document.getElementById('speedTestCanvas');
|
|
34
|
+
if (!canvas) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const ctx = canvas.getContext('2d');
|
|
38
|
+
if (!ctx) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
42
|
+
const barWidth = canvas.width / DRAW_SIZE;
|
|
43
|
+
for (let i = 0; i < speedtestResults.length; i++) {
|
|
44
|
+
const height = (speedtestResults[i] / 100) * canvas.height; // assuming max speed is 100 for 100% height
|
|
45
|
+
ctx.fillStyle = getColor(speedtestResults[i]);
|
|
46
|
+
ctx.fillRect(i * barWidth, canvas.height - height, barWidth, height);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
let inited = null;
|
|
50
|
+
export const initSpeedTest = (customMetrics) => {
|
|
51
|
+
if (inited !== null) {
|
|
52
|
+
return inited;
|
|
53
|
+
}
|
|
54
|
+
inited = (async () => {
|
|
55
|
+
// TODO: fix server selection
|
|
56
|
+
// const response = await fetch('https://iam.gcdn.co/info/json');
|
|
57
|
+
// const data = await response.json();
|
|
58
|
+
// SPEEDTEST_SERVERS[0].server = `http://${data.Server}.fe.gc.onl/speedtest/`;
|
|
59
|
+
speedTest.onupdate = function (data) {
|
|
60
|
+
if (![0, 1].includes(data.testState) && typeof data.dlStatus === 'number') {
|
|
61
|
+
const dlSpeed = limitDigits(data.dlStatus);
|
|
62
|
+
const el = getElementById('dlText');
|
|
63
|
+
if (el) {
|
|
64
|
+
el.textContent = dlSpeed;
|
|
65
|
+
}
|
|
66
|
+
customMetrics.connectionSpeed = rankConnectionSpeed(data.dlStatus);
|
|
67
|
+
}
|
|
68
|
+
const pingStatus = parseFloat(data.pingStatus);
|
|
69
|
+
if (pingStatus > 0) {
|
|
70
|
+
const el = getElementById('pingText');
|
|
71
|
+
if (el) {
|
|
72
|
+
el.textContent = data.pingStatus;
|
|
73
|
+
}
|
|
74
|
+
customMetrics.ping = pingStatus;
|
|
75
|
+
}
|
|
76
|
+
const jitterStatus = parseFloat(data.jitterStatus);
|
|
77
|
+
if (jitterStatus > 0) {
|
|
78
|
+
const el = getElementById('jitterText');
|
|
79
|
+
if (el) {
|
|
80
|
+
el.textContent = data.jitterStatus;
|
|
81
|
+
}
|
|
82
|
+
customMetrics.jitter = jitterStatus;
|
|
83
|
+
}
|
|
84
|
+
if (data.dlStatus === 0) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (typeof data.dlStatus === 'number') {
|
|
88
|
+
speedtestResults.push(data.dlStatus);
|
|
89
|
+
}
|
|
90
|
+
// Keep only the last 10 results
|
|
91
|
+
if (speedtestResults.length > DRAW_SIZE) {
|
|
92
|
+
speedtestResults.shift();
|
|
93
|
+
}
|
|
94
|
+
drawSpeedTestResults();
|
|
95
|
+
};
|
|
96
|
+
speedTest.onend = function (aborted) {
|
|
97
|
+
if (aborted) { //if the test was aborted, clear the UI and prepare for new test
|
|
98
|
+
// TODO: fix
|
|
99
|
+
const el = getElementById('dlText');
|
|
100
|
+
if (el) {
|
|
101
|
+
el.textContent = DEFAULT_DOWNLOAD_SPEED;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
// getElementById('dlText').textContent = DEFAULT_DOWNLOAD_SPEED;
|
|
106
|
+
await fetch('https://iam.gcdn.co/info/json')
|
|
107
|
+
.then(r => r.json())
|
|
108
|
+
.then(data => {
|
|
109
|
+
const country = data['Server Country code'].toLowerCase();
|
|
110
|
+
const server = serversList.find(s => s.country === country) || serversList[0];
|
|
111
|
+
if (!server) {
|
|
112
|
+
throw new Error('Failed to select a server');
|
|
113
|
+
}
|
|
114
|
+
speedTest.addTestPoint(server);
|
|
115
|
+
speedTest.setSelectedServer(server);
|
|
116
|
+
});
|
|
117
|
+
})();
|
|
118
|
+
return inited;
|
|
119
|
+
};
|
|
120
|
+
export const stopSpeedtest = () => {
|
|
121
|
+
if (speedTest.getState() === 3) {
|
|
122
|
+
speedTest.abort();
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
export const startSpeedtest = () => {
|
|
126
|
+
if (speedTest.getState() !== 3) {
|
|
127
|
+
speedTest.start();
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
export const clearSpeedTestResults = () => {
|
|
131
|
+
speedtestResults.splice(0, speedtestResults.length);
|
|
132
|
+
};
|
|
133
|
+
export function configureSpeedTest(servers) {
|
|
134
|
+
// speedTest.addTestPoints(servers);
|
|
135
|
+
serversList.push(...servers);
|
|
136
|
+
}
|
|
137
|
+
function rankConnectionSpeed(dlSpeed) {
|
|
138
|
+
if (dlSpeed >= 100) {
|
|
139
|
+
return 5;
|
|
140
|
+
}
|
|
141
|
+
if (dlSpeed >= 25) {
|
|
142
|
+
return 4;
|
|
143
|
+
}
|
|
144
|
+
if (dlSpeed >= 10) {
|
|
145
|
+
return 3;
|
|
146
|
+
}
|
|
147
|
+
if (dlSpeed >= 2) {
|
|
148
|
+
return 2;
|
|
149
|
+
}
|
|
150
|
+
if (dlSpeed >= 0.5) {
|
|
151
|
+
return 1;
|
|
152
|
+
}
|
|
153
|
+
return 0;
|
|
154
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/plugins/clappr-nerd-stats/speedtest/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;CACzB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
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;
|
|
4
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/plugins/clappr-nerd-stats/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAC;AACzD,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,GAAG,WAAW,GAAG,SAAS,GAAG,SAAS,GAAG,YAAY,GAAG,UAAU,GAAG,aAAa,GAAG,qBAAqB,GAAG,iBAAiB,GAAG,WAAW,GAAG,mBAAmB,GAAG,qBAAqB,CAAC;AAC7P,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Container, ContainerPlugin } from '@clappr/core';
|
|
2
|
+
import type { QualityLevel } from '../../../src/playback.types';
|
|
3
|
+
import type { Metrics, MetricsUpdateFn } from './types.js';
|
|
4
|
+
export declare class ClapprStats extends ContainerPlugin {
|
|
5
|
+
private bwMeasureCount;
|
|
6
|
+
private intervalId;
|
|
7
|
+
private lastDecodedFramesCount;
|
|
8
|
+
private metrics;
|
|
9
|
+
private completion;
|
|
10
|
+
private _onReport;
|
|
11
|
+
private runBandwidthTestEvery;
|
|
12
|
+
private runEach;
|
|
13
|
+
private timers;
|
|
14
|
+
private updateFn;
|
|
15
|
+
private urisToMeasureBandwidth;
|
|
16
|
+
private uriToMeasureLatency;
|
|
17
|
+
get name(): string;
|
|
18
|
+
get supportedVersion(): {
|
|
19
|
+
min: string;
|
|
20
|
+
};
|
|
21
|
+
get _playbackName(): string;
|
|
22
|
+
get _playbackType(): any;
|
|
23
|
+
private _now;
|
|
24
|
+
private _inc;
|
|
25
|
+
private start;
|
|
26
|
+
private _stop;
|
|
27
|
+
setUpdateMetrics(updateMetricsFn: MetricsUpdateFn): void;
|
|
28
|
+
_defaultReport(metrics: Metrics): void;
|
|
29
|
+
constructor(container: Container);
|
|
30
|
+
bindEvents(): void;
|
|
31
|
+
destroy(): void;
|
|
32
|
+
exportMetrics(): Metrics;
|
|
33
|
+
onBitrate(newBitrate: QualityLevel): void;
|
|
34
|
+
stopReporting(): void;
|
|
35
|
+
startTimers(): void;
|
|
36
|
+
onFirstPlaying(): void;
|
|
37
|
+
playAfterPause(): void;
|
|
38
|
+
private onPlay;
|
|
39
|
+
private onPause;
|
|
40
|
+
private onSeek;
|
|
41
|
+
private onTimeUpdate;
|
|
42
|
+
private onContainerUpdateWhilePlaying;
|
|
43
|
+
private onBuffering;
|
|
44
|
+
private onBufferfull;
|
|
45
|
+
private onProgress;
|
|
46
|
+
private _newMetrics;
|
|
47
|
+
private _onCompletion;
|
|
48
|
+
_buildReport(): void;
|
|
49
|
+
private _fetchFPS;
|
|
50
|
+
private _calculateBitrates;
|
|
51
|
+
private _calculatePercentages;
|
|
52
|
+
private _html5FetchFPS;
|
|
53
|
+
private _measureLatency;
|
|
54
|
+
private _measureBandwidth;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=ClapprStats.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClapprStats.d.ts","sourceRoot":"","sources":["../../../src/plugins/clappr-stats/ClapprStats.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,EAA6B,MAAM,cAAc,CAAC;AACrF,OAAO,KAAK,EAAE,YAAY,EAA8B,MAAM,6BAA6B,CAAC;AAK5F,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAkB3D,qBAAa,WAAY,SAAQ,eAAe;IAC9C,OAAO,CAAC,cAAc,CAAK;IAE3B,OAAO,CAAC,UAAU,CAAwB;IAE1C,OAAO,CAAC,sBAAsB,CAAK;IAEnC,OAAO,CAAC,OAAO,CAAyB;IAExC,OAAO,CAAC,UAAU,CAGhB;IAEF,OAAO,CAAC,SAAS,CAA6B;IAE9C,OAAO,CAAC,qBAAqB,CAAS;IAEtC,OAAO,CAAC,OAAO,CAAS;IAExB,OAAO,CAAC,MAAM,CAOZ;IAEF,OAAO,CAAC,QAAQ,CAAkC;IAElD,OAAO,CAAC,sBAAsB,CAA0B;IAExD,OAAO,CAAC,mBAAmB,CAAqB;IAEhD,IAAI,IAAI,WAEP;IAED,IAAI,gBAAgB;;MAEnB;IAED,IAAI,aAAa,WAEhB;IAED,IAAI,aAAa,QAEhB;IAED,OAAO,CAAC,IAAI;IAMZ,OAAO,CAAC,IAAI;IAQZ,OAAO,CAAC,KAAK;IAKb,OAAO,CAAC,KAAK;IAKb,gBAAgB,CAAC,eAAe,EAAE,eAAe;IAIjD,cAAc,CAAC,OAAO,EAAE,OAAO;gBAInB,SAAS,EAAE,SAAS;IAcvB,UAAU;IAmBV,OAAO;IAKhB,aAAa;IAIb,SAAS,CAAC,UAAU,EAAE,YAAY;IAgBlC,aAAa;IAcb,WAAW;IAMX,cAAc;IAOd,cAAc;IAMd,OAAO,CAAC,MAAM;IAId,OAAO,CAAC,OAAO;IAQf,OAAO,CAAC,MAAM;IAKd,OAAO,CAAC,YAAY;IA0BpB,OAAO,CAAC,6BAA6B;IAOrC,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,aAAa;IAYrB,YAAY;IAiBZ,OAAO,CAAC,SAAS;IAcjB,OAAO,CAAC,kBAAkB;IAsB1B,OAAO,CAAC,qBAAqB;IAM7B,OAAO,CAAC,cAAc;IAqBtB,OAAO,CAAC,eAAe;IA2BvB,OAAO,CAAC,iBAAiB;CAmD1B"}
|