@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.
Files changed (404) hide show
  1. package/assets/audio-selector/style.scss +156 -0
  2. package/assets/audio-selector/track-selector.ejs +12 -0
  3. package/assets/big-mute-button/big-mute-button.ejs +3 -0
  4. package/assets/big-mute-button/big-mute-button.scss +57 -0
  5. package/assets/bottom-gear/bottomgear.ejs +12 -0
  6. package/assets/bottom-gear/gear-sub-menu.scss +95 -0
  7. package/assets/bottom-gear/gear.scss +79 -0
  8. package/assets/clappr-nerd-stats/button.ejs +4 -0
  9. package/assets/clappr-nerd-stats/clappr-nerd-stats.ejs +212 -0
  10. package/assets/clappr-nerd-stats/clappr-nerd-stats.scss +488 -0
  11. package/assets/clappr-nerd-stats/options-list.ejs +9 -0
  12. package/assets/clappr-nerd-stats/settings.ejs +12 -0
  13. package/assets/clappr-nerd-stats/speedtest/speedtest.worker.js +775 -0
  14. package/assets/clips/clips.scss +3 -0
  15. package/assets/context-menu/context_menu.ejs +8 -0
  16. package/assets/context-menu/context_menu.scss +31 -0
  17. package/assets/dvr-controls/dvr_controls.scss +136 -0
  18. package/assets/dvr-controls/index.ejs +2 -0
  19. package/assets/error-screen/error_screen.ejs +13 -0
  20. package/assets/error-screen/error_screen.scss +40 -0
  21. package/assets/icons/new/arrow-left.svg +5 -0
  22. package/assets/icons/new/arrow-right.svg +5 -0
  23. package/assets/icons/new/check.svg +5 -0
  24. package/assets/icons/new/close.svg +12 -0
  25. package/assets/icons/new/full.svg +8 -0
  26. package/assets/icons/new/fullscreen-off.svg +14 -0
  27. package/assets/icons/new/fullscreen-on.svg +14 -0
  28. package/assets/icons/new/gear-hd.svg +16 -0
  29. package/assets/icons/new/gear.svg +12 -0
  30. package/assets/icons/new/hd.svg +8 -0
  31. package/assets/icons/new/pause.svg +5 -0
  32. package/assets/icons/new/pip.svg +5 -0
  33. package/assets/icons/new/play.svg +10 -0
  34. package/assets/icons/new/replayleft.svg +5 -0
  35. package/assets/icons/new/replayright.svg +5 -0
  36. package/assets/icons/new/speed.svg +5 -0
  37. package/assets/icons/new/stats.svg +3 -0
  38. package/assets/icons/new/stop.svg +3 -0
  39. package/assets/icons/new/subtitles-off.svg +5 -0
  40. package/assets/icons/new/subtitles-on.svg +6 -0
  41. package/assets/icons/new/volume-max.svg +5 -0
  42. package/assets/icons/new/volume-min.svg +5 -0
  43. package/assets/icons/new/volume-off.svg +5 -0
  44. package/assets/icons/old/cardboard.svg +4 -0
  45. package/assets/icons/old/close-share.svg +13 -0
  46. package/assets/icons/old/close.svg +13 -0
  47. package/assets/icons/old/fb.svg +13 -0
  48. package/assets/icons/old/fullscreen.svg +12 -0
  49. package/assets/icons/old/language.svg +1 -0
  50. package/assets/icons/old/pause.svg +12 -0
  51. package/assets/icons/old/play.svg +12 -0
  52. package/assets/icons/old/quality-arrow.svg +13 -0
  53. package/assets/icons/old/reload.svg +4 -0
  54. package/assets/icons/old/share.svg +13 -0
  55. package/assets/icons/old/sound-off.svg +15 -0
  56. package/assets/icons/old/sound-on.svg +15 -0
  57. package/assets/icons/old/streams.svg +3 -0
  58. package/assets/icons/old/twitter.svg +13 -0
  59. package/assets/icons/old/wn.svg +15 -0
  60. package/assets/icons/standard/01-play.svg +3 -0
  61. package/assets/icons/standard/02-pause.svg +3 -0
  62. package/assets/icons/standard/03-stop.svg +3 -0
  63. package/assets/icons/standard/04-volume.svg +3 -0
  64. package/assets/icons/standard/05-mute.svg +3 -0
  65. package/assets/icons/standard/06-expand.svg +3 -0
  66. package/assets/icons/standard/07-shrink.svg +3 -0
  67. package/assets/icons/standard/08-hd.svg +3 -0
  68. package/assets/icons/standard/09-cc.svg +8 -0
  69. package/assets/icons/standard/10-reload.svg +4 -0
  70. package/assets/level-selector/button.ejs +8 -0
  71. package/assets/level-selector/list.ejs +22 -0
  72. package/assets/level-selector/style.scss +4 -0
  73. package/assets/logo/styles/logo.scss +10 -0
  74. package/assets/logo/templates/logo.ejs +3 -0
  75. package/assets/media-control/closed-hand.cur +0 -0
  76. package/assets/media-control/container.scss +57 -0
  77. package/assets/media-control/media-control.ejs +133 -0
  78. package/assets/media-control/media-control.scss +390 -0
  79. package/assets/media-control/plugins.scss +94 -0
  80. package/assets/media-control/width270.scss +50 -0
  81. package/assets/media-control/width370.scss +263 -0
  82. package/assets/multi-camera/multicamera.ejs +29 -0
  83. package/assets/multi-camera/style.scss +176 -0
  84. package/assets/picture-in-picture/button.ejs +3 -0
  85. package/assets/picture-in-picture/button.scss +11 -0
  86. package/assets/playback-rate/button.ejs +6 -0
  87. package/assets/playback-rate/list.ejs +14 -0
  88. package/assets/playback-rate/playback-rate-selector.ejs +9 -0
  89. package/assets/poster/poster.ejs +1 -0
  90. package/assets/poster/poster.scss +32 -0
  91. package/assets/seek-time/seek-time.html +2 -0
  92. package/assets/seek-time/seek-time.scss +38 -0
  93. package/assets/share/share.ejs +37 -0
  94. package/assets/share/style.scss +104 -0
  95. package/assets/skip-time/skip-time.ejs +8 -0
  96. package/assets/skip-time/style.scss +24 -0
  97. package/assets/spinner-three-bounce/spinner.ejs +3 -0
  98. package/assets/spinner-three-bounce/spinner.scss +44 -0
  99. package/assets/style/main.scss +50 -0
  100. package/assets/style/theme.scss +42 -0
  101. package/assets/style/variables.scss +7 -0
  102. package/assets/subtitles/combobox copy.ejs +16 -0
  103. package/assets/subtitles/combobox.ejs +16 -0
  104. package/assets/subtitles/string.ejs +3 -0
  105. package/assets/subtitles/style.scss +99 -0
  106. package/assets/thumbnails/scrub-thumbnails.ejs +10 -0
  107. package/assets/thumbnails/style.scss +75 -0
  108. package/assets/vast-ads/style.scss +112 -0
  109. package/assets/video360/button.ejs +1 -0
  110. package/assets/video360/style.scss +8 -0
  111. package/build/vite-raw-plugin.js +18 -0
  112. package/dist/index.js +1 -1
  113. package/dist/plugins/index.css +2164 -0
  114. package/dist/{index-C02TmVOf.js → plugins/index.js/index.plugins.js} +29283 -29567
  115. package/lib/index.core.d.ts +15 -0
  116. package/lib/index.core.d.ts.map +1 -0
  117. package/lib/index.core.js +14 -0
  118. package/lib/index.d.ts +2 -14
  119. package/lib/index.d.ts.map +1 -1
  120. package/lib/index.js +2 -14
  121. package/lib/index.plugins.d.ts +37 -0
  122. package/lib/index.plugins.d.ts.map +1 -0
  123. package/lib/index.plugins.js +39 -0
  124. package/lib/plugins/audio-selector/AudioSelector.d.ts +3 -3
  125. package/lib/plugins/audio-selector/AudioSelector.d.ts.map +1 -1
  126. package/lib/plugins/audio-selector/AudioSelector.js +6 -12
  127. package/lib/plugins/big-mute-button/BigMuteButton.d.ts +2 -2
  128. package/lib/plugins/big-mute-button/BigMuteButton.d.ts.map +1 -1
  129. package/lib/plugins/big-mute-button/BigMuteButton.js +7 -12
  130. package/lib/plugins/bottom-gear/BottomGear.d.ts +4 -3
  131. package/lib/plugins/bottom-gear/BottomGear.d.ts.map +1 -1
  132. package/lib/plugins/bottom-gear/BottomGear.js +11 -16
  133. package/lib/plugins/build.d.ts +2 -0
  134. package/lib/plugins/build.d.ts.map +1 -0
  135. package/lib/plugins/build.js +1 -0
  136. package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.d.ts +44 -0
  137. package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.d.ts.map +1 -0
  138. package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.js +294 -0
  139. package/lib/plugins/clappr-nerd-stats/formatter.d.ts +8 -0
  140. package/lib/plugins/clappr-nerd-stats/formatter.d.ts.map +1 -0
  141. package/lib/plugins/clappr-nerd-stats/formatter.js +91 -0
  142. package/lib/plugins/clappr-nerd-stats/speedtest/Speedtest.d.ts +54 -0
  143. package/lib/plugins/clappr-nerd-stats/speedtest/Speedtest.d.ts.map +1 -0
  144. package/lib/plugins/clappr-nerd-stats/speedtest/Speedtest.js +335 -0
  145. package/lib/plugins/clappr-nerd-stats/speedtest/index.d.ts +9 -0
  146. package/lib/plugins/clappr-nerd-stats/speedtest/index.d.ts.map +1 -0
  147. package/lib/plugins/clappr-nerd-stats/speedtest/index.js +154 -0
  148. package/lib/plugins/clappr-nerd-stats/speedtest/types.d.ts +6 -0
  149. package/lib/plugins/clappr-nerd-stats/speedtest/types.d.ts.map +1 -0
  150. package/lib/plugins/clappr-nerd-stats/types.d.ts +4 -0
  151. package/lib/plugins/clappr-nerd-stats/types.d.ts.map +1 -0
  152. package/lib/plugins/clappr-stats/ClapprStats.d.ts +56 -0
  153. package/lib/plugins/clappr-stats/ClapprStats.d.ts.map +1 -0
  154. package/lib/plugins/clappr-stats/ClapprStats.js +332 -0
  155. package/lib/plugins/clappr-stats/types.d.ts +50 -0
  156. package/lib/plugins/clappr-stats/types.d.ts.map +1 -0
  157. package/lib/plugins/clappr-stats/types.js +5 -0
  158. package/lib/plugins/clappr-stats/utils.d.ts +3 -0
  159. package/lib/plugins/clappr-stats/utils.d.ts.map +1 -0
  160. package/lib/plugins/clappr-stats/utils.js +40 -0
  161. package/lib/plugins/click-to-pause/ClickToPause.d.ts +2 -2
  162. package/lib/plugins/click-to-pause/ClickToPause.d.ts.map +1 -1
  163. package/lib/plugins/click-to-pause/ClickToPause.js +4 -6
  164. package/lib/plugins/clips/Clips.d.ts +23 -0
  165. package/lib/plugins/clips/Clips.d.ts.map +1 -0
  166. package/lib/plugins/clips/Clips.js +109 -0
  167. package/lib/plugins/context-menu/ContextMenu.d.ts +36 -0
  168. package/lib/plugins/context-menu/ContextMenu.d.ts.map +1 -0
  169. package/lib/plugins/context-menu/ContextMenu.js +102 -0
  170. package/lib/plugins/disable-controls/DisableControls.d.ts +1 -1
  171. package/lib/plugins/disable-controls/DisableControls.d.ts.map +1 -1
  172. package/lib/plugins/disable-controls/DisableControls.js +3 -5
  173. package/lib/plugins/dvr-controls/{DVRControls.d.ts → DvrControls.d.ts} +4 -4
  174. package/lib/plugins/dvr-controls/DvrControls.d.ts.map +1 -0
  175. package/lib/plugins/dvr-controls/{DVRControls.js → DvrControls.js} +5 -4
  176. package/lib/plugins/error-screen/ErrorScreen.d.ts +44 -0
  177. package/lib/plugins/error-screen/ErrorScreen.d.ts.map +1 -0
  178. package/lib/plugins/error-screen/ErrorScreen.js +179 -0
  179. package/lib/plugins/favicon/Favicon.d.ts +24 -0
  180. package/lib/plugins/favicon/Favicon.d.ts.map +1 -0
  181. package/lib/plugins/favicon/Favicon.js +106 -0
  182. package/lib/plugins/google-analytics/GoogleAnalytics.d.ts +30 -0
  183. package/lib/plugins/google-analytics/GoogleAnalytics.d.ts.map +1 -0
  184. package/lib/plugins/google-analytics/GoogleAnalytics.js +114 -0
  185. package/lib/plugins/index.d.ts +38 -0
  186. package/lib/plugins/index.d.ts.map +1 -0
  187. package/lib/plugins/index.js +40 -0
  188. package/lib/plugins/kibo/index.d.ts +23 -0
  189. package/lib/plugins/kibo/index.d.ts.map +1 -0
  190. package/lib/plugins/kibo/index.js +199 -0
  191. package/lib/plugins/level-selector/LevelSelector.d.ts +48 -17
  192. package/lib/plugins/level-selector/LevelSelector.d.ts.map +1 -1
  193. package/lib/plugins/level-selector/LevelSelector.js +169 -155
  194. package/lib/plugins/logo/Logo.d.ts +29 -0
  195. package/lib/plugins/logo/Logo.d.ts.map +1 -0
  196. package/lib/plugins/logo/Logo.js +181 -0
  197. package/lib/plugins/logo/utils/index.d.ts +22 -0
  198. package/lib/plugins/logo/utils/index.d.ts.map +1 -0
  199. package/lib/plugins/logo/utils/index.js +32 -0
  200. package/lib/plugins/media-control/MediaControl.d.ts +20 -25
  201. package/lib/plugins/media-control/MediaControl.d.ts.map +1 -1
  202. package/lib/plugins/media-control/MediaControl.js +136 -106
  203. package/lib/plugins/multi-camera/MultiCamera.d.ts +59 -0
  204. package/lib/plugins/multi-camera/MultiCamera.d.ts.map +1 -0
  205. package/lib/plugins/multi-camera/MultiCamera.js +353 -0
  206. package/lib/plugins/picture-in-picture/PictureInPicture.d.ts +20 -0
  207. package/lib/plugins/picture-in-picture/PictureInPicture.d.ts.map +1 -0
  208. package/lib/plugins/picture-in-picture/PictureInPicture.js +68 -0
  209. package/lib/plugins/playback-rate/PlaybackRate.d.ts +42 -0
  210. package/lib/plugins/playback-rate/PlaybackRate.d.ts.map +1 -0
  211. package/lib/plugins/playback-rate/PlaybackRate.js +205 -0
  212. package/lib/plugins/poster/Poster.d.ts +18 -17
  213. package/lib/plugins/poster/Poster.d.ts.map +1 -1
  214. package/lib/plugins/poster/Poster.js +83 -37
  215. package/lib/plugins/seek-time/SeekTime.d.ts +38 -0
  216. package/lib/plugins/seek-time/SeekTime.d.ts.map +1 -0
  217. package/lib/plugins/seek-time/SeekTime.js +153 -0
  218. package/lib/plugins/share/Share.d.ts +38 -0
  219. package/lib/plugins/share/Share.d.ts.map +1 -0
  220. package/lib/plugins/share/Share.js +122 -0
  221. package/lib/plugins/skip-time/SkipTime.d.ts +28 -0
  222. package/lib/plugins/skip-time/SkipTime.d.ts.map +1 -0
  223. package/lib/plugins/skip-time/SkipTime.js +86 -0
  224. package/lib/plugins/source-controller/SourceController.d.ts +41 -0
  225. package/lib/plugins/source-controller/SourceController.d.ts.map +1 -0
  226. package/lib/plugins/source-controller/SourceController.js +199 -0
  227. package/lib/plugins/spinner-three-bounce/SpinnerThreeBounce.d.ts +26 -0
  228. package/lib/plugins/spinner-three-bounce/SpinnerThreeBounce.d.ts.map +1 -0
  229. package/lib/plugins/spinner-three-bounce/SpinnerThreeBounce.js +117 -0
  230. package/lib/plugins/statistics/Statistics.d.ts +52 -0
  231. package/lib/plugins/statistics/Statistics.d.ts.map +1 -0
  232. package/lib/plugins/statistics/Statistics.js +130 -0
  233. package/lib/plugins/subtitles/Subtitles.d.ts +61 -0
  234. package/lib/plugins/subtitles/Subtitles.d.ts.map +1 -0
  235. package/lib/plugins/subtitles/Subtitles.js +354 -0
  236. package/lib/plugins/thumbnails/Thumbnails.d.ts +47 -0
  237. package/lib/plugins/thumbnails/Thumbnails.d.ts.map +1 -0
  238. package/lib/plugins/thumbnails/Thumbnails.js +414 -0
  239. package/lib/plugins/types.d.ts +8 -0
  240. package/lib/plugins/types.d.ts.map +1 -0
  241. package/lib/plugins/types.js +1 -0
  242. package/lib/plugins/utils.d.ts +5 -0
  243. package/lib/plugins/utils.d.ts.map +1 -0
  244. package/lib/plugins/utils.js +68 -0
  245. package/lib/plugins/vast-ads/VastAds.d.ts +72 -0
  246. package/lib/plugins/vast-ads/VastAds.d.ts.map +1 -0
  247. package/lib/plugins/vast-ads/VastAds.js +686 -0
  248. package/lib/plugins/vast-ads/loaderxml.d.ts +32 -0
  249. package/lib/plugins/vast-ads/loaderxml.d.ts.map +1 -0
  250. package/lib/plugins/vast-ads/loaderxml.js +226 -0
  251. package/lib/plugins/vast-ads/roll.d.ts +60 -0
  252. package/lib/plugins/vast-ads/roll.d.ts.map +1 -0
  253. package/lib/plugins/vast-ads/roll.js +415 -0
  254. package/lib/plugins/vast-ads/rollmanager.d.ts +62 -0
  255. package/lib/plugins/vast-ads/rollmanager.d.ts.map +1 -0
  256. package/lib/plugins/vast-ads/rollmanager.js +347 -0
  257. package/lib/plugins/vast-ads/sctemanager.d.ts +18 -0
  258. package/lib/plugins/vast-ads/sctemanager.d.ts.map +1 -0
  259. package/lib/plugins/vast-ads/sctemanager.js +116 -0
  260. package/lib/plugins/vast-ads/types.d.ts +12 -0
  261. package/lib/plugins/vast-ads/types.d.ts.map +1 -0
  262. package/lib/plugins/vast-ads/types.js +1 -0
  263. package/lib/plugins/vast-ads/urlhandler.d.ts +4 -0
  264. package/lib/plugins/vast-ads/urlhandler.d.ts.map +1 -0
  265. package/lib/plugins/vast-ads/urlhandler.js +30 -0
  266. package/lib/plugins/vast-ads/xmlhttprequest.d.ts +6 -0
  267. package/lib/plugins/vast-ads/xmlhttprequest.d.ts.map +1 -0
  268. package/lib/plugins/vast-ads/xmlhttprequest.js +39 -0
  269. package/lib/plugins/vast-ads/xmlmerge.d.ts +12 -0
  270. package/lib/plugins/vast-ads/xmlmerge.d.ts.map +1 -0
  271. package/lib/plugins/vast-ads/xmlmerge.js +82 -0
  272. package/lib/plugins/volume-fade/VolumeFade.d.ts +21 -0
  273. package/lib/plugins/volume-fade/VolumeFade.d.ts.map +1 -0
  274. package/lib/plugins/volume-fade/VolumeFade.js +90 -0
  275. package/package.json +10 -2
  276. package/rollup.config.js +32 -2
  277. package/src/index.core.ts +15 -0
  278. package/src/index.plugins.ts +41 -0
  279. package/src/index.ts +2 -15
  280. package/src/plugins/audio-selector/AudioSelector.ts +370 -0
  281. package/src/plugins/big-mute-button/BigMuteButton.ts +187 -0
  282. package/src/plugins/bottom-gear/BottomGear.ts +122 -0
  283. package/src/plugins/build.ts +1 -0
  284. package/src/plugins/clappr-nerd-stats/ClapprNerdStats.ts +369 -0
  285. package/src/plugins/clappr-nerd-stats/formatter.ts +109 -0
  286. package/src/plugins/clappr-nerd-stats/speedtest/Speedtest.ts +414 -0
  287. package/src/plugins/clappr-nerd-stats/speedtest/index.ts +183 -0
  288. package/src/plugins/clappr-nerd-stats/speedtest/types.ts +5 -0
  289. package/src/plugins/clappr-nerd-stats/types.ts +3 -0
  290. package/src/plugins/clappr-stats/ClapprStats.ts +441 -0
  291. package/src/plugins/clappr-stats/types.ts +52 -0
  292. package/src/plugins/clappr-stats/utils.ts +42 -0
  293. package/src/plugins/click-to-pause/ClickToPause.ts +93 -0
  294. package/src/plugins/clips/Clips.ts +152 -0
  295. package/src/plugins/context-menu/ContextMenu.ts +134 -0
  296. package/src/plugins/disable-controls/DisableControls.ts +81 -0
  297. package/src/plugins/dvr-controls/DvrControls.ts +131 -0
  298. package/src/plugins/error-screen/ErrorScreen.ts +241 -0
  299. package/src/plugins/favicon/Favicon.ts +137 -0
  300. package/src/plugins/ga-events/GaEvents.js +395 -0
  301. package/src/plugins/ga-events/ga-tracking.js +46 -0
  302. package/src/plugins/google-analytics/GoogleAnalytics.ts +147 -0
  303. package/src/plugins/index.ts +42 -0
  304. package/src/plugins/kibo/index.ts +244 -0
  305. package/src/plugins/level-selector/LevelSelector.ts +400 -0
  306. package/src/plugins/level-selector/__tests__/LevelSelector.test.ts +72 -0
  307. package/src/plugins/level-selector/__tests__/__snapshots__/LevelSelector.test.ts.snap +11 -0
  308. package/src/plugins/logo/Logo.ts +233 -0
  309. package/src/plugins/logo/utils/index.ts +46 -0
  310. package/src/plugins/media-control/MediaControl.ts +1383 -0
  311. package/src/plugins/multi-camera/MultiCamera copy.xts +414 -0
  312. package/src/plugins/multi-camera/MultiCamera.ts +426 -0
  313. package/src/plugins/picture-in-picture/PictureInPicture.ts +87 -0
  314. package/src/plugins/playback-rate/PlaybackRate.ts +269 -0
  315. package/src/plugins/poster/Poster.ts +298 -0
  316. package/src/plugins/seek-time/SeekTime.ts +191 -0
  317. package/src/plugins/share/Share.ts +148 -0
  318. package/src/plugins/skip-time/SkipTime.ts +109 -0
  319. package/src/plugins/source-controller/SourceController.ts +239 -0
  320. package/src/plugins/source-controller/__tests__/SourceController.test.ts +230 -0
  321. package/src/plugins/spinner-three-bounce/SpinnerThreeBounce.ts +135 -0
  322. package/src/plugins/statistics/Statistics copy.xts +296 -0
  323. package/src/plugins/statistics/Statistics.ts +207 -0
  324. package/src/plugins/subtitles/Subtitles.ts +505 -0
  325. package/src/plugins/thumbnails/Thumbnails.ts +530 -0
  326. package/src/plugins/types.ts +7 -0
  327. package/src/plugins/typings/globals.d.ts +10 -0
  328. package/src/plugins/typings/parse-srt.d.ts +14 -0
  329. package/src/plugins/typings/workers.d.ts +3 -0
  330. package/src/plugins/utils.ts +77 -0
  331. package/src/plugins/vast-ads/VastAds.ts +915 -0
  332. package/src/plugins/vast-ads/loaderxml.ts +260 -0
  333. package/src/plugins/vast-ads/roll.ts +492 -0
  334. package/src/plugins/vast-ads/rollmanager.ts +403 -0
  335. package/src/plugins/vast-ads/sctemanager.ts +134 -0
  336. package/src/plugins/vast-ads/types.ts +14 -0
  337. package/src/plugins/vast-ads/urlhandler.ts +37 -0
  338. package/src/plugins/vast-ads/xmlhttprequest.ts +44 -0
  339. package/src/plugins/vast-ads/xmlmerge.ts +96 -0
  340. package/src/plugins/video360/VRControls.js +104 -0
  341. package/src/plugins/video360/VREffect.js +422 -0
  342. package/src/plugins/video360/Video360.js +979 -0
  343. package/src/plugins/video360/orbit-oriention-controls.js +1002 -0
  344. package/src/plugins/video360/utils.js +49 -0
  345. package/src/plugins/volume-fade/VolumeFade.ts +109 -0
  346. package/tsconfig.tsbuildinfo +1 -1
  347. package/dist/HlsPlayback-D9EmONbV.js +0 -747
  348. package/dist/player.d.ts +0 -646
  349. package/lib/backend.d.ts +0 -3
  350. package/lib/backend.d.ts.map +0 -1
  351. package/lib/backend.js +0 -10
  352. package/lib/constants.d.ts +0 -1
  353. package/lib/constants.d.ts.map +0 -1
  354. package/lib/constants.js +0 -1
  355. package/lib/gcore.types.d.ts +0 -84
  356. package/lib/gcore.types.d.ts.map +0 -1
  357. package/lib/gcore.types.js +0 -9
  358. package/lib/plugins/dash-playback/DashPlayback.d.ts +0 -73
  359. package/lib/plugins/dash-playback/DashPlayback.d.ts.map +0 -1
  360. package/lib/plugins/dash-playback/DashPlayback.js +0 -455
  361. package/lib/plugins/dash-playback/types.d.ts +0 -6
  362. package/lib/plugins/dash-playback/types.d.ts.map +0 -1
  363. package/lib/plugins/dash-plugin/DashPlayback.d.ts +0 -86
  364. package/lib/plugins/dash-plugin/DashPlayback.d.ts.map +0 -1
  365. package/lib/plugins/dash-plugin/DashPlayback.js +0 -659
  366. package/lib/plugins/dvr-controls/DVRControls.d.ts.map +0 -1
  367. package/lib/plugins/hls-playback/HlsPlayback.d.ts +0 -102
  368. package/lib/plugins/hls-playback/HlsPlayback.d.ts.map +0 -1
  369. package/lib/plugins/hls-playback/HlsPlayback.js +0 -815
  370. package/lib/trace/LogTracer.d.ts +0 -12
  371. package/lib/trace/LogTracer.d.ts.map +0 -1
  372. package/lib/trace/LogTracer.js +0 -17
  373. package/lib/trace/SentryTracer.d.ts +0 -12
  374. package/lib/trace/SentryTracer.d.ts.map +0 -1
  375. package/lib/trace/SentryTracer.js +0 -23
  376. package/lib/trace/Tracer.d.ts +0 -13
  377. package/lib/trace/Tracer.d.ts.map +0 -1
  378. package/lib/trace/Tracer.js +0 -15
  379. package/lib/trace/index.d.ts +0 -18
  380. package/lib/trace/index.d.ts.map +0 -1
  381. package/lib/trace/index.js +0 -27
  382. package/lib/trace/types.d.ts +0 -8
  383. package/lib/trace/types.d.ts.map +0 -1
  384. package/lib/tsdoc-metadata.json +0 -11
  385. package/lib/utils/Logger.d.ts +0 -23
  386. package/lib/utils/Logger.d.ts.map +0 -1
  387. package/lib/utils/Logger.js +0 -81
  388. package/lib/utils/canAutoplay.d.ts +0 -6
  389. package/lib/utils/canAutoplay.d.ts.map +0 -1
  390. package/lib/utils/canAutoplay.js +0 -30
  391. package/lib/utils/queryParams.d.ts +0 -2
  392. package/lib/utils/queryParams.d.ts.map +0 -1
  393. package/lib/utils/queryParams.js +0 -4
  394. package/lib/utils/scripts-load.d.ts +0 -2
  395. package/lib/utils/scripts-load.d.ts.map +0 -1
  396. package/lib/utils/scripts-load.js +0 -20
  397. package/lib/utils/testUtils.d.ts +0 -3
  398. package/lib/utils/testUtils.d.ts.map +0 -1
  399. package/lib/utils/testUtils.js +0 -12
  400. package/lib/utils/utils.d.ts +0 -3
  401. package/lib/utils/utils.d.ts.map +0 -1
  402. package/lib/utils/utils.js +0 -31
  403. /package/lib/plugins/{dash-playback → clappr-nerd-stats/speedtest}/types.js +0 -0
  404. /package/lib/{trace → plugins/clappr-nerd-stats}/types.js +0 -0
@@ -0,0 +1,775 @@
1
+ // data reported to main thread
2
+
3
+ // -1=not started, 0=starting, 1=download test, 2=ping+jitter test, 3=upload test, 4=finished, 5=abort
4
+ let testState = -1;
5
+ // download speed in megabit/s with 2 decimal digits
6
+ let dlStatus = 0;
7
+ // upload speed in megabit/s with 2 decimal digits
8
+ let ulStatus = '';
9
+ // ping in milliseconds with 2 decimal digits
10
+ let pingStatus = '';
11
+ // jitter in milliseconds with 2 decimal digits
12
+ let jitterStatus = '';
13
+ // client's IP address as reported by getIP.php
14
+ let clientIp = '';
15
+ let serverHostName = '';
16
+ //progress of download test 0-1
17
+ let dlProgress = 0;
18
+ //progress of upload test 0-1
19
+ let ulProgress = 0;
20
+ //progress of ping+jitter test 0-1
21
+ let pingProgress = 0;
22
+ //test ID (sent back by telemetry if used, null otherwise)
23
+ let testId = null;
24
+
25
+ let log = ''; //telemetry log
26
+
27
+ function tlog(s) {
28
+ if (settings.telemetry_level >= 2) {
29
+ log += Date.now() + ': ' + s + '\n';
30
+ }
31
+ }
32
+
33
+ function tverb(s) {
34
+ if (settings.telemetry_level >= 3) {
35
+ log += Date.now() + ': ' + s + '\n';
36
+ }
37
+ }
38
+
39
+ function twarn(s) {
40
+ if (settings.telemetry_level >= 2) {
41
+ log += Date.now() + ' WARN: ' + s + '\n';
42
+ }
43
+
44
+ console.warn(s);
45
+ }
46
+
47
+ // test settings. can be overridden by sending specific values with the start command
48
+ const settings = {
49
+ //set to true when in MPOT mode
50
+ mpot: false,
51
+ //order in which tests will be performed as a string. D=Download, U=Upload, P=Ping+Jitter, I=IP, _=1 second delay
52
+ test_order: 'P_D',
53
+ // max duration of upload test in seconds
54
+ time_ul_max: 0,
55
+ // max duration of download test in seconds
56
+ time_dl_max: 15,
57
+ // if set to true, tests will take less time on faster connections
58
+ time_auto: true,
59
+ //time to wait in seconds before actually measuring ul speed (wait for buffers to fill)
60
+ time_ulGraceTime: 3,
61
+ //time to wait in seconds before actually measuring dl speed (wait for TCP window to increase)
62
+ time_dlGraceTime: 1.5,
63
+ // number of pings to perform in ping test
64
+ count_ping: 10,
65
+ // path to a large file or garbage.php, used for download test. must be relative to this js file
66
+ url_dl: 'backend/garbage.php',
67
+ // path to an empty file, used for upload test. must be relative to this js file
68
+ url_ul: 'backend/empty.php',
69
+ // path to an empty file, used for ping test. must be relative to this js file
70
+ url_ping: 'backend/empty.php',
71
+ // path to getIP.php relative to this js file, or a similar thing that outputs the client's ip
72
+ url_getIp: 'backend/getIP.php',
73
+ // if set to true, the server will include ISP info with the IP address
74
+ getIp_ispInfo: true,
75
+ // km or mi=estimate distance from server in km/mi; set to false to disable distance estimation.
76
+ // getIp_ispInfo must be enabled in order for this to work
77
+ getIp_ispInfo_distance: false,
78
+ // number of download streams to use (can be different if enable_quirks is active)
79
+ xhr_dlMultistream: 6,
80
+ // number of upload streams to use (can be different if enable_quirks is active)
81
+ xhr_ulMultistream: 3,
82
+ // how much concurrent requests should be delayed
83
+ xhr_multistreamDelay: 300,
84
+ // 0=fail on errors, 1=attempt to restart a stream if it fails, 2=ignore all errors
85
+ xhr_ignoreErrors: 1,
86
+ // if set to true, it reduces ram usage but uses the hard drive (useful with large garbagePhp_chunkSize
87
+ // and/or high xhr_dlMultistream)
88
+ xhr_dlUseBlob: false,
89
+ // size in megabytes of the upload blobs sent in the upload test (forced to 4 on chrome mobile)
90
+ xhr_ul_blob_megabytes: 20,
91
+ // size of chunks sent by garbage.php (can be different if enable_quirks is active)
92
+ garbagePhp_chunkSize: 100,
93
+ // enable quirks for specific browsers. currently it overrides settings to optimize for specific browsers,
94
+ // unless they are already being overridden with the start command
95
+ enable_quirks: true,
96
+ // if enabled, the ping test will attempt to calculate the ping more precisely using the Performance API.
97
+ // Currently works perfectly in Chrome, badly in Edge, and not at all in Firefox.
98
+ // If Performance API is not supported or the result is obviously wrong, a fallback is provided.
99
+ ping_allowPerformanceApi: true,
100
+ // can be changed to compensatie for transport overhead. (see doc.md for some other values)
101
+ overheadCompensationFactor: 1.06,
102
+ //if set to true, speed will be reported in mebibits/s instead of megabits/s
103
+ useMebibits: false,
104
+ // 0=disabled, 1=basic (results only), 2=full (results and timing) 3=debug (results+log)
105
+ telemetry_level: 0,
106
+ // path to the script that adds telemetry data to the database
107
+ url_telemetry: 'results/telemetry.php',
108
+ //extra data that can be passed to the telemetry through the settings
109
+ telemetry_extra: ''
110
+ };
111
+
112
+ let xhr = null; // array of currently active xhr requests
113
+ let interval = null; // timer used in tests
114
+ let test_pointer = 0; //pointer to the next test to run inside settings.test_order
115
+
116
+ /*
117
+ this function is used on URLs passed in the settings to determine whether we need a ? or an & as a separator
118
+ */
119
+ function url_sep(url) {
120
+ return url.match(/\?/) ? '&' : '?';
121
+ }
122
+
123
+ /*
124
+ listener for commands from main thread to this worker.
125
+ commands:
126
+ -status: returns the current status as a JSON string containing testState,
127
+ dlStatus, ulStatus, pingStatus, clientIp, jitterStatus, dlProgress, ulProgress, pingProgress
128
+ -abort: aborts the current test
129
+ -start: starts the test. optionally, settings can be passed as JSON.
130
+ example: start {"time_ul_max":"10", "time_dl_max":"10", "count_ping":"50"}
131
+ */
132
+ self.addEventListener('message', function (e) {
133
+ const params = e.data.split(' ');
134
+
135
+ if (params[0] === 'status') {
136
+ // return status
137
+ postMessage(
138
+ {
139
+ testState: testState,
140
+ dlStatus: dlStatus,
141
+ ulStatus: ulStatus,
142
+ pingStatus: pingStatus,
143
+ clientIp: clientIp,
144
+ serverHostName: serverHostName,
145
+ jitterStatus: jitterStatus,
146
+ dlProgress: dlProgress,
147
+ ulProgress: ulProgress,
148
+ pingProgress: pingProgress,
149
+ testId: testId
150
+ }
151
+ );
152
+ }
153
+ if (params[0] === 'start' && testState === -1) {
154
+ const ua = navigator.userAgent;
155
+
156
+ // start new test
157
+ testState = 0;
158
+ try {
159
+ // parse settings, if present
160
+ let s = {};
161
+
162
+ try {
163
+ const ss = e.data.substring(5);
164
+
165
+ if (ss) {
166
+ s = JSON.parse(ss);
167
+ }
168
+ } catch (e) {
169
+ twarn('Error parsing custom settings JSON. Please check your syntax');
170
+ }
171
+ //copy custom settings
172
+ for (const key in s) {
173
+ if (typeof settings[key] !== 'undefined') {
174
+ settings[key] = s[key];
175
+ } else {
176
+ twarn('Unknown setting ignored: ' + key);
177
+ }
178
+ }
179
+ // quirks for specific browsers. apply only if not overridden. more may be added in future releases
180
+ if (settings.enable_quirks || (typeof s.enable_quirks !== 'undefined' && s.enable_quirks)) {
181
+ if (/Firefox.(\d+\.\d+)/i.test(ua)) {
182
+ if (typeof s.ping_allowPerformanceApi === 'undefined') {
183
+ // ff performance API sucks
184
+ settings.ping_allowPerformanceApi = false;
185
+ }
186
+ }
187
+ if (/Edge.(\d+\.\d+)/i.test(ua)) {
188
+ if (typeof s.xhr_dlMultistream === 'undefined') {
189
+ // edge more precise with 3 download streams
190
+ settings.xhr_dlMultistream = 3;
191
+ }
192
+ }
193
+ if (/Chrome.(\d+)/i.test(ua) && !!self.fetch) {
194
+ if (typeof s.xhr_dlMultistream === 'undefined') {
195
+ // chrome more precise with 5 streams
196
+ settings.xhr_dlMultistream = 5;
197
+ }
198
+ }
199
+ }
200
+ if (/Edge.(\d+\.\d+)/i.test(ua)) {
201
+ //Edge 15 introduced a bug that causes onprogress events to not get fired,
202
+ // we have to use the "small chunks" workaround that reduces accuracy
203
+ settings.forceIE11Workaround = true;
204
+ }
205
+ if (/PlayStation 4.(\d+\.\d+)/i.test(ua)) {
206
+ //PS4 browser has the same bug as IE11/Edge
207
+ settings.forceIE11Workaround = true;
208
+ }
209
+ if (/Chrome.(\d+)/i.test(ua) && /Android|iPhone|iPad|iPod|Windows Phone/i.test(ua)) {
210
+ // cheap af
211
+ // Chrome mobile introduced a limitation somewhere around version 65,
212
+ // we have to limit XHR upload size to 4 megabytes
213
+ settings.xhr_ul_blob_megabytes = 4;
214
+ }
215
+ if (/^((?!chrome|android|crios|fxios).)*safari/i.test(ua)) {
216
+ //Safari also needs the IE11 workaround but only for the MPOT version
217
+ settings.forceIE11Workaround = true;
218
+ }
219
+ // telemetry_level has to be parsed and not just copied
220
+ if (typeof s.telemetry_level !== 'undefined') {
221
+ const telemetryLevels = {
222
+ 'basic': 1,
223
+ 'full': 2,
224
+ 'debug': 3
225
+ };
226
+
227
+ settings.telemetry_level = telemetryLevels[s.telemetry_level] || 0;
228
+ } // telemetry level
229
+ // transform test_order to uppercase, just in case
230
+ settings.test_order = settings.test_order.toUpperCase();
231
+ } catch (e) {
232
+ twarn('Possible error in custom test settings. Some settings might not have been applied. Exception: ' + e);
233
+ }
234
+ // run the tests
235
+ tverb(JSON.stringify(settings));
236
+ test_pointer = 0;
237
+ let iRun = false,
238
+ dRun = false,
239
+ // uRun = false,
240
+ pRun = false;
241
+ // eslint-disable-next-line no-var
242
+ var runNextTest = function () {
243
+ if (testState === 5) {
244
+ return;
245
+ }
246
+ if (test_pointer >= settings.test_order.length) {
247
+ //test is finished
248
+ if (settings.telemetry_level > 0) {
249
+ sendTelemetry(function (id) {
250
+ testState = 4;
251
+ if (id !== null || id !== undefined) {
252
+ testId = id;
253
+ }
254
+ });
255
+ } else {
256
+ testState = 4;
257
+ }
258
+
259
+ return;
260
+ }
261
+ switch (settings.test_order.charAt(test_pointer)) {
262
+ case 'I': {
263
+ test_pointer++;
264
+ if (iRun) {
265
+ runNextTest();
266
+
267
+ return;
268
+ } else {
269
+ iRun = true;
270
+ }
271
+ getIp(runNextTest);
272
+ }
273
+ break;
274
+ case 'D': {
275
+ test_pointer++;
276
+ if (dRun) {
277
+ runNextTest();
278
+
279
+ return;
280
+ } else {
281
+ dRun = true;
282
+ }
283
+ testState = 1;
284
+ dlTest(runNextTest);
285
+ }
286
+ break;
287
+ case 'U': {
288
+ // test_pointer++;
289
+ // if (uRun) {
290
+ // runNextTest();
291
+ // return;
292
+ // } else uRun = true;
293
+ // testState = 3;
294
+ // ulTest(runNextTest);
295
+ }
296
+ break;
297
+ case 'P': {
298
+ test_pointer++;
299
+ if (pRun) {
300
+ runNextTest();
301
+
302
+ return;
303
+ } else {
304
+ pRun = true;
305
+ }
306
+ testState = 2;
307
+ pingTest(runNextTest);
308
+ }
309
+ break;
310
+ case '_': {
311
+ test_pointer++;
312
+ setTimeout(runNextTest, 1000);
313
+ }
314
+ break;
315
+ default:
316
+ test_pointer++;
317
+ }
318
+ };
319
+
320
+ runNextTest();
321
+ }
322
+ if (params[0] === 'abort') {
323
+ // abort command
324
+ if (testState >= 4) {
325
+ return;
326
+ }
327
+ tlog('manually aborted');
328
+ clearRequests(); // stop all xhr activity
329
+ runNextTest = null;
330
+ if (interval) {
331
+ clearInterval(interval);
332
+ } // clear timer if present
333
+ if (settings.telemetry_level > 1) {
334
+ sendTelemetry(function () {
335
+ });
336
+ }
337
+ testState = 5; //set test as aborted
338
+ dlStatus = 0;
339
+ ulStatus = '';
340
+ pingStatus = '';
341
+ jitterStatus = '';
342
+ clientIp = '';
343
+ serverHostName = '';
344
+ dlProgress = 0;
345
+ ulProgress = 0;
346
+ pingProgress = 0;
347
+ }
348
+ });
349
+
350
+ // stops all XHR activity, aggressively
351
+ function clearRequests() {
352
+ tverb('stopping pending XHRs');
353
+ if (xhr) {
354
+ for (let i = 0; i < xhr.length; i++) {
355
+ try {
356
+ xhr[i].onprogress = null;
357
+ xhr[i].onload = null;
358
+ xhr[i].onerror = null;
359
+ } catch (e) {
360
+ console.warn(e);
361
+ }
362
+ try {
363
+ xhr[i].upload.onprogress = null;
364
+ xhr[i].upload.onload = null;
365
+ xhr[i].upload.onerror = null;
366
+ } catch (e) {
367
+ console.warn(e);
368
+ }
369
+ try {
370
+ xhr[i].abort();
371
+ } catch (e) {
372
+ console.warn(e);
373
+ }
374
+ try {
375
+ delete xhr[i];
376
+ } catch (e) {
377
+ console.warn(e);
378
+ }
379
+ }
380
+ xhr = null;
381
+ }
382
+ }
383
+
384
+ // gets client's IP using url_getIp, then calls the done function
385
+ let ipCalled = false; // used to prevent multiple accidental calls to getIp
386
+ let ispInfo = ''; //used for telemetry
387
+
388
+ function getIp(done) {
389
+ tverb('getIp');
390
+ if (ipCalled) {
391
+ return;
392
+ } else {
393
+ ipCalled = true;
394
+ } // getIp already called?
395
+ const startT = new Date().getTime();
396
+
397
+ xhr = new XMLHttpRequest();
398
+ xhr.onload = function () {
399
+ tlog('IP: ' + xhr.responseText + ', took ' + (new Date().getTime() - startT) + 'ms');
400
+ try {
401
+ const data = JSON.parse(xhr.responseText);
402
+
403
+ clientIp = data.processedString;
404
+ serverHostName = data.serverHostName;
405
+ ispInfo = data.rawIspInfo;
406
+ } catch (e) {
407
+ clientIp = xhr.responseText;
408
+ ispInfo = '';
409
+ }
410
+ done();
411
+ };
412
+ xhr.onerror = function () {
413
+ tlog('getIp failed, took ' + (new Date().getTime() - startT) + 'ms');
414
+ done();
415
+ };
416
+ const queryParams = [
417
+ settings.mpot ? 'cors=true' : '',
418
+ settings.getIp_ispInfo ?
419
+ `isp=true${settings.getIp_ispInfo_distance ? '&distance=' + settings.getIp_ispInfo_distance : ''}` :
420
+ '',
421
+ 'r=' + Math.random()
422
+ ].filter(Boolean).join('&');
423
+
424
+ const url = `${settings.url_getIp}${url_sep(settings.url_getIp)}${queryParams}`;
425
+
426
+ xhr.open(
427
+ 'GET',
428
+ url,
429
+ true
430
+ );
431
+ xhr.send();
432
+ }
433
+
434
+ // download test, calls done function when it's over
435
+ let dlCalled = false; // used to prevent multiple accidental calls to dlTest
436
+
437
+ function dlTest(done) {
438
+ tverb('dlTest');
439
+ if (dlCalled) {
440
+ return;
441
+ } else {
442
+ dlCalled = true;
443
+ } // dlTest already called?
444
+ let totLoaded = 0.0, // total number of loaded bytes
445
+ startT = new Date().getTime(), // timestamp when test was started
446
+ bonusT = 0, //how many milliseconds the test has been shortened by (higher on faster connections)
447
+ graceTimeDone = false, //set to true after the grace time is past
448
+ failed = false; // set to true if a stream fails
449
+
450
+ xhr = [];
451
+ // function to create a download stream. streams are slightly delayed so that they will not end at the same time
452
+ const testStream = function (i, delay) {
453
+ setTimeout(
454
+ function () {
455
+ if (testState !== 1) {
456
+ return;
457
+ } // delayed stream ended up starting after the end of the download test
458
+ tverb('dl test stream started ' + i + ' ' + delay);
459
+ let prevLoaded = 0; // number of bytes loaded last time onprogress was called
460
+ const x = new XMLHttpRequest();
461
+
462
+ xhr[i] = x;
463
+ xhr[i].onprogress = function (event) {
464
+ tverb('dl stream progress event ' + i + ' ' + event.loaded);
465
+ if (testState !== 1) {
466
+ try {
467
+ x.abort();
468
+ } catch (e) {
469
+ console.warn(e);
470
+ }
471
+ } // just in case this XHR is still running after the download test
472
+ // progress event, add number of new loaded bytes to totLoaded
473
+ const loadDiff = event.loaded <= 0 ? 0 : event.loaded - prevLoaded;
474
+
475
+ if (isNaN(loadDiff) || !isFinite(loadDiff) || loadDiff < 0) {
476
+ return;
477
+ } // just in case
478
+ totLoaded += loadDiff;
479
+ prevLoaded = event.loaded;
480
+ }.bind(this);
481
+ xhr[i].onload = function () {
482
+ // the large file has been loaded entirely, start again
483
+ tverb('dl stream finished ' + i);
484
+ try {
485
+ xhr[i].abort();
486
+ } catch (e) {
487
+ console.warn(e);
488
+ } // reset the stream data to empty ram
489
+ testStream(i, 0);
490
+ }.bind(this);
491
+ xhr[i].onerror = function () {
492
+ // error
493
+ tverb('dl stream failed ' + i);
494
+ if (settings.xhr_ignoreErrors === 0) {
495
+ failed = true;
496
+ } //abort
497
+ try {
498
+ xhr[i].abort();
499
+ } catch (e) {
500
+ console.warn(e);
501
+ }
502
+ delete xhr[i];
503
+ if (settings.xhr_ignoreErrors === 1) {
504
+ testStream(i, 0);
505
+ } //restart stream
506
+ }.bind(this);
507
+ // send xhr
508
+ try {
509
+ if (settings.xhr_dlUseBlob) {
510
+ xhr[i].responseType = 'blob';
511
+ } else {
512
+ xhr[i].responseType = 'arraybuffer';
513
+ }
514
+ } catch (e) {
515
+ console.warn(e);
516
+ }
517
+
518
+ const queryParams = [
519
+ settings.mpot ? 'cors=true' : '',
520
+ 'r=' + Math.random(),
521
+ 'ckSize=' + settings.garbagePhp_chunkSize
522
+ ].join('&');
523
+
524
+ const url = `${settings.url_dl}${url_sep(settings.url_dl)}${queryParams}`;
525
+
526
+ // random string to prevent caching
527
+ xhr[i].open('GET', url, true);
528
+ xhr[i].send();
529
+ }.bind(this),
530
+ 1 + delay
531
+ );
532
+ }.bind(this);
533
+
534
+ // open streams
535
+ for (let i = 0; i < settings.xhr_dlMultistream; i++) {
536
+ testStream(i, settings.xhr_multistreamDelay * i);
537
+ }
538
+ // every 200ms, update dlStatus
539
+ interval = setInterval(
540
+ function () {
541
+ tverb('DL: ' + dlStatus + (graceTimeDone ? '' : ' (in grace time)'));
542
+ const t = new Date().getTime() - startT;
543
+
544
+ if (graceTimeDone) {
545
+ dlProgress = (t + bonusT) / (settings.time_dl_max * 1000);
546
+ }
547
+ if (t < 200) {
548
+ return;
549
+ }
550
+ if (!graceTimeDone) {
551
+ if (t > 1000 * settings.time_dlGraceTime) {
552
+ if (totLoaded > 0) {
553
+ // if the connection is so slow that we didn't get a single chunk yet, do not reset
554
+ startT = new Date().getTime();
555
+ bonusT = 0;
556
+ totLoaded = 0.0;
557
+ }
558
+ graceTimeDone = true;
559
+ }
560
+ } else {
561
+ const speed = totLoaded / (t / 1000.0);
562
+
563
+ if (settings.time_auto) {
564
+ //decide how much to shorten the test. Every 200ms, the test is shortened by the bonusT calculated here
565
+ const bonus = (6.4 * speed) / 100000;
566
+
567
+ bonusT += bonus > 800 ? 800 : bonus;
568
+ }
569
+ // update status
570
+ // speed is multiplied by 8 to go from bytes to bits, overhead compensation is applied,
571
+ // then everything is divided by 1048576 or 1000000 to go to megabits/mebibits
572
+ dlStatus = ((speed * 8 * settings.overheadCompensationFactor) / (settings.useMebibits ? 1048576 : 1000000));
573
+ if ((t + bonusT) / 1000.0 > settings.time_dl_max || failed) {
574
+ // test is over, stop streams and timer
575
+ if (failed || isNaN(dlStatus)) {
576
+ dlStatus = 'Fail';
577
+ }
578
+ clearRequests();
579
+ clearInterval(interval);
580
+ dlProgress = 1;
581
+ tlog('dlTest: ' + dlStatus + ', took ' + (new Date().getTime() - startT) + 'ms');
582
+ done();
583
+ }
584
+ }
585
+ }.bind(this),
586
+ 200
587
+ );
588
+ }
589
+
590
+ // ping+jitter test, function done is called when it's over
591
+ let ptCalled = false; // used to prevent multiple accidental calls to pingTest
592
+
593
+ function pingTest(done) {
594
+ tverb('pingTest');
595
+ if (ptCalled) {
596
+ return;
597
+ } else {
598
+ ptCalled = true;
599
+ } // pingTest already called?
600
+ const startT = new Date().getTime(); //when the test was started
601
+ let prevT = null; // last time a pong was received
602
+ let ping = 0.0; // current ping value
603
+ let jitter = 0.0; // current jitter value
604
+ let i = 0; // counter of pongs received
605
+ let prevInstspd = 0; // last ping time, used for jitter calculation
606
+
607
+ xhr = [];
608
+ // ping function
609
+ const doPing = function () {
610
+ tverb('ping');
611
+ pingProgress = i / settings.count_ping;
612
+ prevT = new Date().getTime();
613
+ xhr[0] = new XMLHttpRequest();
614
+ xhr[0].onload = function () {
615
+ // pong
616
+ tverb('pong');
617
+ if (i === 0) {
618
+ prevT = new Date().getTime(); // first pong
619
+ } else {
620
+ let instspd = new Date().getTime() - prevT;
621
+
622
+ if (settings.ping_allowPerformanceApi) {
623
+ try {
624
+ //try to get accurate performance timing using performance api
625
+ let p = performance.getEntries();
626
+
627
+ p = p[p.length - 1];
628
+ let d = p.responseStart - p.requestStart;
629
+
630
+ if (d <= 0) {
631
+ d = p.duration;
632
+ }
633
+ if (d > 0 && d < instspd) {
634
+ instspd = d;
635
+ }
636
+ } catch (e) {
637
+ //if not possible, keep the estimate
638
+ tverb('Performance API not supported, using estimate');
639
+ }
640
+ }
641
+ //noticed that some browsers randomly have 0ms ping
642
+ if (instspd < 1) {
643
+ instspd = prevInstspd;
644
+ }
645
+ if (instspd < 1) {
646
+ instspd = 1;
647
+ }
648
+ const instjitter = Math.abs(instspd - prevInstspd);
649
+
650
+ if (i === 1) {
651
+ ping = instspd;
652
+ }/* first ping, can't tell jitter yet*/ else {
653
+ if (instspd < ping) {
654
+ ping = instspd;
655
+ } // update ping, if the instant ping is lower
656
+ if (i === 2) {
657
+ jitter = instjitter;
658
+ } else {
659
+ //discard the first jitter measurement because it might be much higher than it should be
660
+ jitter = instjitter > jitter ? jitter * 0.3 + instjitter * 0.7 : jitter * 0.8 + instjitter * 0.2;
661
+ } // update jitter, weighted average. spikes in ping values are given more weight.
662
+ }
663
+ prevInstspd = instspd;
664
+ }
665
+ pingStatus = ping.toFixed(2);
666
+ jitterStatus = jitter.toFixed(2);
667
+ i++;
668
+ tverb('ping: ' + pingStatus + ' jitter: ' + jitterStatus);
669
+ if (i < settings.count_ping) {
670
+ doPing();
671
+ } else {
672
+ // more pings to do?
673
+ pingProgress = 1;
674
+ tlog('ping: ' + pingStatus + ' jitter: ' + jitterStatus + ', took ' + (new Date().getTime() - startT) + 'ms');
675
+ done();
676
+ }
677
+ }.bind(this);
678
+ xhr[0].onerror = function () {
679
+ // a ping failed, cancel test
680
+ tverb('ping failed');
681
+ if (settings.xhr_ignoreErrors === 0) {
682
+ //abort
683
+ pingStatus = 'Fail';
684
+ jitterStatus = 'Fail';
685
+ clearRequests();
686
+ tlog('ping test failed, took ' + (new Date().getTime() - startT) + 'ms');
687
+ pingProgress = 1;
688
+ done();
689
+ }
690
+ if (settings.xhr_ignoreErrors === 1) {
691
+ doPing();
692
+ } //retry ping
693
+ if (settings.xhr_ignoreErrors === 2) {
694
+ //ignore failed ping
695
+ i++;
696
+ if (i < settings.count_ping) {
697
+ doPing();
698
+ } else {
699
+ // more pings to do?
700
+ pingProgress = 1;
701
+ tlog('ping: ' + pingStatus + ' jitter: ' + jitterStatus + ', took ' + (new Date().getTime() - startT) + 'ms');
702
+ done();
703
+ }
704
+ }
705
+ }.bind(this);
706
+ // send xhr
707
+ const queryString = [
708
+ settings.mpot ? 'cors=true' : '',
709
+ `r=${Math.random()}`
710
+ ].filter(part => part !== '').join('&');
711
+
712
+ const url = `${settings.url_ping}${url_sep(settings.url_ping)}${queryString}`;
713
+
714
+ // random string to prevent caching
715
+ xhr[0].open('GET', url, true);
716
+ xhr[0].send();
717
+ }.bind(this);
718
+
719
+ doPing(); // start first ping
720
+ }
721
+
722
+ // telemetry
723
+ function sendTelemetry(done) {
724
+ if (settings.telemetry_level < 1) {
725
+ return;
726
+ }
727
+ xhr = new XMLHttpRequest();
728
+ xhr.onload = function () {
729
+ try {
730
+ const parts = xhr.responseText.split(' ');
731
+
732
+ if (parts[0] === 'id') {
733
+ try {
734
+ const id = parts[1];
735
+
736
+ done(id);
737
+ } catch (e) {
738
+ done(null);
739
+ }
740
+ } else {
741
+ done(null);
742
+ }
743
+ } catch (e) {
744
+ done(null);
745
+ }
746
+ };
747
+ xhr.onerror = function () {
748
+ console.warn('TELEMETRY ERROR ' + xhr.status);
749
+ done(null);
750
+ };
751
+ xhr.open('POST', settings.url_telemetry + url_sep(settings.url_telemetry) + (settings.mpot ? 'cors=true&' : '') + 'r=' + Math.random(), true);
752
+ const telemetryIspInfo = {
753
+ processedString: clientIp,
754
+ serverHostName: serverHostName,
755
+ rawIspInfo: typeof ispInfo === 'object' ? ispInfo : ''
756
+ };
757
+
758
+ try {
759
+ const fd = new FormData();
760
+
761
+ fd.append('ispinfo', JSON.stringify(telemetryIspInfo));
762
+ fd.append('dl', dlStatus);
763
+ fd.append('ul', ulStatus);
764
+ fd.append('ping', pingStatus);
765
+ fd.append('jitter', jitterStatus);
766
+ fd.append('log', settings.telemetry_level > 1 ? log : '');
767
+ fd.append('extra', settings.telemetry_extra);
768
+ xhr.send(fd);
769
+ } catch (ex) {
770
+ const postData = 'extra=' + encodeURIComponent(settings.telemetry_extra) + '&ispinfo=' + encodeURIComponent(JSON.stringify(telemetryIspInfo)) + '&dl=' + encodeURIComponent(dlStatus) + '&ul=' + encodeURIComponent(ulStatus) + '&ping=' + encodeURIComponent(pingStatus) + '&jitter=' + encodeURIComponent(jitterStatus) + '&log=' + encodeURIComponent(settings.telemetry_level > 1 ? log : '');
771
+
772
+ xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
773
+ xhr.send(postData);
774
+ }
775
+ }