@editframe/elements 0.16.8-beta.0 → 0.18.3-beta.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.
Files changed (267) hide show
  1. package/README.md +30 -0
  2. package/dist/DecoderResetFrequency.test.d.ts +1 -0
  3. package/dist/DecoderResetRecovery.test.d.ts +1 -0
  4. package/dist/DelayedLoadingState.d.ts +48 -0
  5. package/dist/DelayedLoadingState.integration.test.d.ts +1 -0
  6. package/dist/DelayedLoadingState.js +113 -0
  7. package/dist/DelayedLoadingState.test.d.ts +1 -0
  8. package/dist/EF_FRAMEGEN.d.ts +10 -1
  9. package/dist/EF_FRAMEGEN.js +199 -179
  10. package/dist/EF_INTERACTIVE.js +2 -6
  11. package/dist/EF_RENDERING.js +1 -3
  12. package/dist/LoadingDebounce.test.d.ts +1 -0
  13. package/dist/LoadingIndicator.browsertest.d.ts +0 -0
  14. package/dist/ManualScrubTest.test.d.ts +1 -0
  15. package/dist/ScrubResolvedFlashing.test.d.ts +1 -0
  16. package/dist/ScrubTrackManager.d.ts +96 -0
  17. package/dist/ScrubTrackManager.test.d.ts +1 -0
  18. package/dist/VideoSeekFlashing.browsertest.d.ts +0 -0
  19. package/dist/VideoStuckDiagnostic.test.d.ts +1 -0
  20. package/dist/elements/CrossUpdateController.js +13 -15
  21. package/dist/elements/EFAudio.browsertest.d.ts +0 -0
  22. package/dist/elements/EFAudio.d.ts +22 -3
  23. package/dist/elements/EFAudio.js +60 -43
  24. package/dist/elements/EFCaptions.js +337 -373
  25. package/dist/elements/EFImage.d.ts +1 -0
  26. package/dist/elements/EFImage.js +73 -91
  27. package/dist/elements/EFMedia/AssetIdMediaEngine.d.ts +18 -0
  28. package/dist/elements/EFMedia/AssetIdMediaEngine.js +41 -0
  29. package/dist/elements/EFMedia/AssetIdMediaEngine.test.d.ts +1 -0
  30. package/dist/elements/EFMedia/AssetMediaEngine.d.ts +47 -0
  31. package/dist/elements/EFMedia/AssetMediaEngine.js +116 -0
  32. package/dist/elements/EFMedia/BaseMediaEngine.d.ts +55 -0
  33. package/dist/elements/EFMedia/BaseMediaEngine.js +96 -0
  34. package/dist/elements/EFMedia/BaseMediaEngine.test.d.ts +1 -0
  35. package/dist/elements/EFMedia/BufferedSeekingInput.browsertest.d.ts +1 -0
  36. package/dist/elements/EFMedia/BufferedSeekingInput.d.ts +43 -0
  37. package/dist/elements/EFMedia/BufferedSeekingInput.js +159 -0
  38. package/dist/elements/EFMedia/JitMediaEngine.browsertest.d.ts +0 -0
  39. package/dist/elements/EFMedia/JitMediaEngine.d.ts +31 -0
  40. package/dist/elements/EFMedia/JitMediaEngine.js +62 -0
  41. package/dist/elements/EFMedia/audioTasks/makeAudioBufferTask.browsertest.d.ts +9 -0
  42. package/dist/elements/EFMedia/audioTasks/makeAudioBufferTask.d.ts +16 -0
  43. package/dist/elements/EFMedia/audioTasks/makeAudioBufferTask.js +48 -0
  44. package/dist/elements/EFMedia/audioTasks/makeAudioFrequencyAnalysisTask.d.ts +3 -0
  45. package/dist/elements/EFMedia/audioTasks/makeAudioFrequencyAnalysisTask.js +138 -0
  46. package/dist/elements/EFMedia/audioTasks/makeAudioInitSegmentFetchTask.browsertest.d.ts +9 -0
  47. package/dist/elements/EFMedia/audioTasks/makeAudioInitSegmentFetchTask.d.ts +4 -0
  48. package/dist/elements/EFMedia/audioTasks/makeAudioInitSegmentFetchTask.js +16 -0
  49. package/dist/elements/EFMedia/audioTasks/makeAudioInputTask.browsertest.d.ts +9 -0
  50. package/dist/elements/EFMedia/audioTasks/makeAudioInputTask.d.ts +3 -0
  51. package/dist/elements/EFMedia/audioTasks/makeAudioInputTask.js +22 -0
  52. package/dist/elements/EFMedia/audioTasks/makeAudioSeekTask.d.ts +7 -0
  53. package/dist/elements/EFMedia/audioTasks/makeAudioSeekTask.js +24 -0
  54. package/dist/elements/EFMedia/audioTasks/makeAudioSegmentFetchTask.d.ts +4 -0
  55. package/dist/elements/EFMedia/audioTasks/makeAudioSegmentFetchTask.js +18 -0
  56. package/dist/elements/EFMedia/audioTasks/makeAudioSegmentIdTask.d.ts +4 -0
  57. package/dist/elements/EFMedia/audioTasks/makeAudioSegmentIdTask.js +16 -0
  58. package/dist/elements/EFMedia/audioTasks/makeAudioTimeDomainAnalysisTask.d.ts +3 -0
  59. package/dist/elements/EFMedia/audioTasks/makeAudioTimeDomainAnalysisTask.js +104 -0
  60. package/dist/elements/EFMedia/services/AudioElementFactory.browsertest.d.ts +1 -0
  61. package/dist/elements/EFMedia/services/AudioElementFactory.d.ts +22 -0
  62. package/dist/elements/EFMedia/services/AudioElementFactory.js +72 -0
  63. package/dist/elements/EFMedia/services/MediaSourceService.browsertest.d.ts +1 -0
  64. package/dist/elements/EFMedia/services/MediaSourceService.d.ts +47 -0
  65. package/dist/elements/EFMedia/services/MediaSourceService.js +73 -0
  66. package/dist/elements/EFMedia/shared/AudioSpanUtils.d.ts +7 -0
  67. package/dist/elements/EFMedia/shared/AudioSpanUtils.js +54 -0
  68. package/dist/elements/EFMedia/shared/BufferUtils.d.ts +70 -0
  69. package/dist/elements/EFMedia/shared/BufferUtils.js +89 -0
  70. package/dist/elements/EFMedia/shared/MediaTaskUtils.d.ts +23 -0
  71. package/dist/elements/EFMedia/shared/RenditionHelpers.browsertest.d.ts +1 -0
  72. package/dist/elements/EFMedia/shared/RenditionHelpers.d.ts +19 -0
  73. package/dist/elements/EFMedia/tasks/makeMediaEngineTask.browsertest.d.ts +1 -0
  74. package/dist/elements/EFMedia/tasks/makeMediaEngineTask.d.ts +18 -0
  75. package/dist/elements/EFMedia/tasks/makeMediaEngineTask.js +60 -0
  76. package/dist/elements/EFMedia/tasks/makeMediaEngineTask.test.d.ts +1 -0
  77. package/dist/elements/EFMedia/videoTasks/makeVideoBufferTask.browsertest.d.ts +9 -0
  78. package/dist/elements/EFMedia/videoTasks/makeVideoBufferTask.d.ts +16 -0
  79. package/dist/elements/EFMedia/videoTasks/makeVideoBufferTask.js +46 -0
  80. package/dist/elements/EFMedia/videoTasks/makeVideoInitSegmentFetchTask.browsertest.d.ts +9 -0
  81. package/dist/elements/EFMedia/videoTasks/makeVideoInitSegmentFetchTask.d.ts +4 -0
  82. package/dist/elements/EFMedia/videoTasks/makeVideoInitSegmentFetchTask.js +16 -0
  83. package/dist/elements/EFMedia/videoTasks/makeVideoInputTask.browsertest.d.ts +9 -0
  84. package/dist/elements/EFMedia/videoTasks/makeVideoInputTask.d.ts +3 -0
  85. package/dist/elements/EFMedia/videoTasks/makeVideoInputTask.js +27 -0
  86. package/dist/elements/EFMedia/videoTasks/makeVideoSeekTask.d.ts +7 -0
  87. package/dist/elements/EFMedia/videoTasks/makeVideoSeekTask.js +25 -0
  88. package/dist/elements/EFMedia/videoTasks/makeVideoSegmentFetchTask.browsertest.d.ts +9 -0
  89. package/dist/elements/EFMedia/videoTasks/makeVideoSegmentFetchTask.d.ts +4 -0
  90. package/dist/elements/EFMedia/videoTasks/makeVideoSegmentFetchTask.js +18 -0
  91. package/dist/elements/EFMedia/videoTasks/makeVideoSegmentIdTask.browsertest.d.ts +9 -0
  92. package/dist/elements/EFMedia/videoTasks/makeVideoSegmentIdTask.d.ts +4 -0
  93. package/dist/elements/EFMedia/videoTasks/makeVideoSegmentIdTask.js +16 -0
  94. package/dist/elements/EFMedia.browsertest.d.ts +1 -0
  95. package/dist/elements/EFMedia.d.ts +95 -66
  96. package/dist/elements/EFMedia.js +204 -683
  97. package/dist/elements/EFSourceMixin.js +31 -48
  98. package/dist/elements/EFTemporal.d.ts +2 -1
  99. package/dist/elements/EFTemporal.js +266 -360
  100. package/dist/elements/EFTimegroup.d.ts +14 -1
  101. package/dist/elements/EFTimegroup.js +337 -323
  102. package/dist/elements/EFVideo.browsertest.d.ts +0 -0
  103. package/dist/elements/EFVideo.d.ts +123 -4
  104. package/dist/elements/EFVideo.js +308 -111
  105. package/dist/elements/EFWaveform.js +375 -411
  106. package/dist/elements/FetchMixin.js +14 -24
  107. package/dist/elements/MediaController.d.ts +30 -0
  108. package/dist/elements/SampleBuffer.d.ts +14 -0
  109. package/dist/elements/SampleBuffer.js +52 -0
  110. package/dist/elements/TargetController.js +130 -156
  111. package/dist/elements/TimegroupController.js +17 -19
  112. package/dist/elements/durationConverter.js +15 -4
  113. package/dist/elements/parseTimeToMs.js +4 -10
  114. package/dist/elements/printTaskStatus.d.ts +2 -0
  115. package/dist/elements/updateAnimations.js +39 -59
  116. package/dist/getRenderInfo.d.ts +2 -2
  117. package/dist/getRenderInfo.js +59 -67
  118. package/dist/gui/ContextMixin.js +150 -288
  119. package/dist/gui/EFConfiguration.js +27 -43
  120. package/dist/gui/EFFilmstrip.d.ts +3 -3
  121. package/dist/gui/EFFilmstrip.js +440 -620
  122. package/dist/gui/EFFitScale.d.ts +2 -2
  123. package/dist/gui/EFFitScale.js +112 -135
  124. package/dist/gui/EFFocusOverlay.js +45 -61
  125. package/dist/gui/EFPreview.js +30 -49
  126. package/dist/gui/EFScrubber.js +78 -99
  127. package/dist/gui/EFTimeDisplay.js +49 -70
  128. package/dist/gui/EFToggleLoop.js +17 -34
  129. package/dist/gui/EFTogglePlay.js +37 -58
  130. package/dist/gui/EFWorkbench.js +66 -88
  131. package/dist/gui/TWMixin.js +2 -48
  132. package/dist/gui/TWMixin2.js +31 -0
  133. package/dist/gui/efContext.js +2 -6
  134. package/dist/gui/fetchContext.js +1 -3
  135. package/dist/gui/focusContext.js +1 -3
  136. package/dist/gui/focusedElementContext.js +2 -6
  137. package/dist/gui/playingContext.js +1 -4
  138. package/dist/gui/services/ElementConnectionManager.browsertest.d.ts +1 -0
  139. package/dist/gui/services/ElementConnectionManager.d.ts +59 -0
  140. package/dist/gui/services/ElementConnectionManager.js +128 -0
  141. package/dist/gui/services/PlaybackController.browsertest.d.ts +1 -0
  142. package/dist/gui/services/PlaybackController.d.ts +103 -0
  143. package/dist/gui/services/PlaybackController.js +290 -0
  144. package/dist/index.js +5 -30
  145. package/dist/msToTimeCode.js +11 -13
  146. package/dist/services/MediaSourceManager.d.ts +62 -0
  147. package/dist/services/MediaSourceManager.js +211 -0
  148. package/dist/style.css +2 -1
  149. package/dist/transcoding/cache/CacheManager.d.ts +73 -0
  150. package/dist/transcoding/cache/RequestDeduplicator.d.ts +29 -0
  151. package/dist/transcoding/cache/RequestDeduplicator.js +53 -0
  152. package/dist/transcoding/cache/RequestDeduplicator.test.d.ts +1 -0
  153. package/dist/transcoding/types/index.d.ts +242 -0
  154. package/dist/transcoding/utils/MediaUtils.d.ts +9 -0
  155. package/dist/transcoding/utils/UrlGenerator.d.ts +26 -0
  156. package/dist/transcoding/utils/UrlGenerator.js +45 -0
  157. package/dist/transcoding/utils/constants.d.ts +27 -0
  158. package/dist/utils/LRUCache.d.ts +34 -0
  159. package/dist/utils/LRUCache.js +115 -0
  160. package/package.json +4 -3
  161. package/src/elements/EFAudio.browsertest.ts +709 -0
  162. package/src/elements/EFAudio.ts +59 -15
  163. package/src/elements/EFCaptions.browsertest.ts +0 -1
  164. package/src/elements/EFImage.browsertest.ts +42 -1
  165. package/src/elements/EFImage.ts +23 -3
  166. package/src/elements/EFMedia/AssetIdMediaEngine.test.ts +222 -0
  167. package/src/elements/EFMedia/AssetIdMediaEngine.ts +70 -0
  168. package/src/elements/EFMedia/AssetMediaEngine.ts +210 -0
  169. package/src/elements/EFMedia/BaseMediaEngine.test.ts +164 -0
  170. package/src/elements/EFMedia/BaseMediaEngine.ts +170 -0
  171. package/src/elements/EFMedia/BufferedSeekingInput.browsertest.ts +400 -0
  172. package/src/elements/EFMedia/BufferedSeekingInput.ts +267 -0
  173. package/src/elements/EFMedia/JitMediaEngine.browsertest.ts +165 -0
  174. package/src/elements/EFMedia/JitMediaEngine.ts +110 -0
  175. package/src/elements/EFMedia/audioTasks/makeAudioBufferTask.browsertest.ts +554 -0
  176. package/src/elements/EFMedia/audioTasks/makeAudioBufferTask.ts +81 -0
  177. package/src/elements/EFMedia/audioTasks/makeAudioFrequencyAnalysisTask.ts +241 -0
  178. package/src/elements/EFMedia/audioTasks/makeAudioInitSegmentFetchTask.browsertest.ts +59 -0
  179. package/src/elements/EFMedia/audioTasks/makeAudioInitSegmentFetchTask.ts +23 -0
  180. package/src/elements/EFMedia/audioTasks/makeAudioInputTask.browsertest.ts +55 -0
  181. package/src/elements/EFMedia/audioTasks/makeAudioInputTask.ts +35 -0
  182. package/src/elements/EFMedia/audioTasks/makeAudioSeekTask.ts +42 -0
  183. package/src/elements/EFMedia/audioTasks/makeAudioSegmentFetchTask.ts +34 -0
  184. package/src/elements/EFMedia/audioTasks/makeAudioSegmentIdTask.ts +23 -0
  185. package/src/elements/EFMedia/audioTasks/makeAudioTimeDomainAnalysisTask.ts +174 -0
  186. package/src/elements/EFMedia/services/AudioElementFactory.browsertest.ts +325 -0
  187. package/src/elements/EFMedia/services/AudioElementFactory.ts +119 -0
  188. package/src/elements/EFMedia/services/MediaSourceService.browsertest.ts +257 -0
  189. package/src/elements/EFMedia/services/MediaSourceService.ts +102 -0
  190. package/src/elements/EFMedia/shared/AudioSpanUtils.ts +128 -0
  191. package/src/elements/EFMedia/shared/BufferUtils.ts +310 -0
  192. package/src/elements/EFMedia/shared/MediaTaskUtils.ts +44 -0
  193. package/src/elements/EFMedia/shared/RenditionHelpers.browsertest.ts +247 -0
  194. package/src/elements/EFMedia/shared/RenditionHelpers.ts +79 -0
  195. package/src/elements/EFMedia/tasks/makeMediaEngineTask.browsertest.ts +128 -0
  196. package/src/elements/EFMedia/tasks/makeMediaEngineTask.test.ts +233 -0
  197. package/src/elements/EFMedia/tasks/makeMediaEngineTask.ts +89 -0
  198. package/src/elements/EFMedia/videoTasks/makeVideoBufferTask.browsertest.ts +555 -0
  199. package/src/elements/EFMedia/videoTasks/makeVideoBufferTask.ts +79 -0
  200. package/src/elements/EFMedia/videoTasks/makeVideoInitSegmentFetchTask.browsertest.ts +59 -0
  201. package/src/elements/EFMedia/videoTasks/makeVideoInitSegmentFetchTask.ts +23 -0
  202. package/src/elements/EFMedia/videoTasks/makeVideoInputTask.browsertest.ts +55 -0
  203. package/src/elements/EFMedia/videoTasks/makeVideoInputTask.ts +45 -0
  204. package/src/elements/EFMedia/videoTasks/makeVideoSeekTask.ts +44 -0
  205. package/src/elements/EFMedia/videoTasks/makeVideoSegmentFetchTask.browsertest.ts +57 -0
  206. package/src/elements/EFMedia/videoTasks/makeVideoSegmentFetchTask.ts +32 -0
  207. package/src/elements/EFMedia/videoTasks/makeVideoSegmentIdTask.browsertest.ts +56 -0
  208. package/src/elements/EFMedia/videoTasks/makeVideoSegmentIdTask.ts +23 -0
  209. package/src/elements/EFMedia.browsertest.ts +696 -271
  210. package/src/elements/EFMedia.ts +218 -776
  211. package/src/elements/EFTemporal.browsertest.ts +0 -1
  212. package/src/elements/EFTemporal.ts +13 -3
  213. package/src/elements/EFTimegroup.browsertest.ts +6 -3
  214. package/src/elements/EFTimegroup.ts +221 -27
  215. package/src/elements/EFVideo.browsertest.ts +758 -0
  216. package/src/elements/EFVideo.ts +418 -68
  217. package/src/elements/EFWaveform.ts +5 -5
  218. package/src/elements/MediaController.ts +98 -0
  219. package/src/elements/SampleBuffer.ts +97 -0
  220. package/src/elements/printTaskStatus.ts +16 -0
  221. package/src/elements/updateAnimations.ts +6 -0
  222. package/src/gui/ContextMixin.ts +23 -104
  223. package/src/gui/TWMixin.ts +10 -3
  224. package/src/gui/services/ElementConnectionManager.browsertest.ts +263 -0
  225. package/src/gui/services/ElementConnectionManager.ts +224 -0
  226. package/src/gui/services/PlaybackController.browsertest.ts +437 -0
  227. package/src/gui/services/PlaybackController.ts +521 -0
  228. package/src/services/MediaSourceManager.ts +333 -0
  229. package/src/transcoding/cache/CacheManager.ts +208 -0
  230. package/src/transcoding/cache/RequestDeduplicator.test.ts +170 -0
  231. package/src/transcoding/cache/RequestDeduplicator.ts +65 -0
  232. package/src/transcoding/types/index.ts +265 -0
  233. package/src/transcoding/utils/MediaUtils.ts +63 -0
  234. package/src/transcoding/utils/UrlGenerator.ts +68 -0
  235. package/src/transcoding/utils/constants.ts +36 -0
  236. package/src/utils/LRUCache.ts +153 -0
  237. package/test/EFVideo.framegen.browsertest.ts +127 -0
  238. package/test/__cache__/GET__api_v1_transcode_audio_1_m4s_url_http_3A_2F_2Fweb_3A3000_2Fhead_moov_480p_mp4__32da3954ba60c96ad732020c65a08ebc/data.bin +0 -0
  239. package/test/__cache__/GET__api_v1_transcode_audio_1_m4s_url_http_3A_2F_2Fweb_3A3000_2Fhead_moov_480p_mp4__32da3954ba60c96ad732020c65a08ebc/metadata.json +21 -0
  240. package/test/__cache__/GET__api_v1_transcode_audio_2_m4s_url_http_3A_2F_2Fweb_3A3000_2Fhead_moov_480p_mp4__b0b2b07efcf607de8ee0f650328c32f7/data.bin +0 -0
  241. package/test/__cache__/GET__api_v1_transcode_audio_2_m4s_url_http_3A_2F_2Fweb_3A3000_2Fhead_moov_480p_mp4__b0b2b07efcf607de8ee0f650328c32f7/metadata.json +21 -0
  242. package/test/__cache__/GET__api_v1_transcode_audio_3_m4s_url_http_3A_2F_2Fweb_3A3000_2Fhead_moov_480p_mp4__a75c2252b542e0c152c780e9a8d7b154/data.bin +0 -0
  243. package/test/__cache__/GET__api_v1_transcode_audio_3_m4s_url_http_3A_2F_2Fweb_3A3000_2Fhead_moov_480p_mp4__a75c2252b542e0c152c780e9a8d7b154/metadata.json +21 -0
  244. package/test/__cache__/GET__api_v1_transcode_audio_4_m4s_url_http_3A_2F_2Fweb_3A3000_2Fhead_moov_480p_mp4__a64ff1cfb1b52cae14df4b5dfa1e222b/data.bin +0 -0
  245. package/test/__cache__/GET__api_v1_transcode_audio_4_m4s_url_http_3A_2F_2Fweb_3A3000_2Fhead_moov_480p_mp4__a64ff1cfb1b52cae14df4b5dfa1e222b/metadata.json +21 -0
  246. package/test/__cache__/GET__api_v1_transcode_audio_5_m4s_url_http_3A_2F_2Fweb_3A3000_2Fhead_moov_480p_mp4__91e8a522f950809b9f09f4173113b4b0/data.bin +0 -0
  247. package/test/__cache__/GET__api_v1_transcode_audio_5_m4s_url_http_3A_2F_2Fweb_3A3000_2Fhead_moov_480p_mp4__91e8a522f950809b9f09f4173113b4b0/metadata.json +21 -0
  248. package/test/__cache__/GET__api_v1_transcode_audio_init_m4s_url_http_3A_2F_2Fweb_3A3000_2Fhead_moov_480p_mp4__e66d2c831d951e74ad0aeaa6489795d0/data.bin +0 -0
  249. package/test/__cache__/GET__api_v1_transcode_audio_init_m4s_url_http_3A_2F_2Fweb_3A3000_2Fhead_moov_480p_mp4__e66d2c831d951e74ad0aeaa6489795d0/metadata.json +21 -0
  250. package/test/__cache__/GET__api_v1_transcode_high_1_m4s_url_http_3A_2F_2Fweb_3A3000_2Fhead_moov_480p_mp4__26197f6f7c46cacb0a71134131c3f775/data.bin +0 -0
  251. package/test/__cache__/GET__api_v1_transcode_high_1_m4s_url_http_3A_2F_2Fweb_3A3000_2Fhead_moov_480p_mp4__26197f6f7c46cacb0a71134131c3f775/metadata.json +21 -0
  252. package/test/__cache__/GET__api_v1_transcode_high_2_m4s_url_http_3A_2F_2Fweb_3A3000_2Fhead_moov_480p_mp4__4cb6774cd3650ccf59c8f8dc6678c0b9/data.bin +0 -0
  253. package/test/__cache__/GET__api_v1_transcode_high_2_m4s_url_http_3A_2F_2Fweb_3A3000_2Fhead_moov_480p_mp4__4cb6774cd3650ccf59c8f8dc6678c0b9/metadata.json +21 -0
  254. package/test/__cache__/GET__api_v1_transcode_high_3_m4s_url_http_3A_2F_2Fweb_3A3000_2Fhead_moov_480p_mp4__0b3b2b1c8933f7fcf8a9ecaa88d58b41/data.bin +0 -0
  255. package/test/__cache__/GET__api_v1_transcode_high_3_m4s_url_http_3A_2F_2Fweb_3A3000_2Fhead_moov_480p_mp4__0b3b2b1c8933f7fcf8a9ecaa88d58b41/metadata.json +21 -0
  256. package/test/__cache__/GET__api_v1_transcode_high_init_m4s_url_http_3A_2F_2Fweb_3A3000_2Fhead_moov_480p_mp4__0798c479b44aaeef850609a430f6e613/data.bin +0 -0
  257. package/test/__cache__/GET__api_v1_transcode_high_init_m4s_url_http_3A_2F_2Fweb_3A3000_2Fhead_moov_480p_mp4__0798c479b44aaeef850609a430f6e613/metadata.json +21 -0
  258. package/test/__cache__/GET__api_v1_transcode_manifest_json_url_http_3A_2F_2Fweb_3A3000_2Fhead_moov_480p_mp4__3be92a0437de726b431ed5af2369158a/data.bin +1 -0
  259. package/test/__cache__/GET__api_v1_transcode_manifest_json_url_http_3A_2F_2Fweb_3A3000_2Fhead_moov_480p_mp4__3be92a0437de726b431ed5af2369158a/metadata.json +19 -0
  260. package/test/createJitTestClips.ts +425 -0
  261. package/test/recordReplayProxyPlugin.js +302 -0
  262. package/test/useAssetMSW.ts +49 -0
  263. package/test/useMSW.ts +44 -0
  264. package/types.json +1 -1
  265. package/dist/gui/TWMixin.css.js +0 -4
  266. /package/dist/elements/{TargetController.test.d.ts → TargetController.browsertest.d.ts} +0 -0
  267. /package/src/elements/{TargetController.test.ts → TargetController.browsertest.ts} +0 -0
@@ -1,394 +1,87 @@
1
- import { CSSStyleObserver } from "@bramus/style-observer";
2
- import { Task } from "@lit/task";
3
- import { LitElement, html, css } from "lit";
4
- import { property, state, customElement } from "lit/decorators.js";
5
- import { createRef, ref } from "lit/directives/ref.js";
6
1
  import { EF_INTERACTIVE } from "../EF_INTERACTIVE.js";
7
2
  import { EF_RENDERING } from "../EF_RENDERING.js";
8
- import { TWMixin } from "../gui/TWMixin.js";
9
- import { CrossUpdateController } from "./CrossUpdateController.js";
10
3
  import { EFTemporal } from "./EFTemporal.js";
11
4
  import { TargetController } from "./TargetController.js";
12
- var __defProp = Object.defineProperty;
13
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
14
- var __decorateClass = (decorators, target, key, kind) => {
15
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
16
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
17
- if (decorator = decorators[i])
18
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
19
- if (kind && result) __defProp(target, key, result);
20
- return result;
21
- };
22
- let EFWaveform = class extends EFTemporal(TWMixin(LitElement)) {
23
- constructor() {
24
- super(...arguments);
25
- this.canvasRef = createRef();
26
- this.ctx = null;
27
- this.styleObserver = null;
28
- this.mode = "bars";
29
- this.color = "currentColor";
30
- this.target = "";
31
- this.barSpacing = 0.5;
32
- this.targetElement = null;
33
- this.lineWidth = 4;
34
- this.targetController = new TargetController(this);
35
- this.frameTask = new Task(this, {
36
- autoRun: EF_INTERACTIVE,
37
- args: () => {
38
- return [
39
- this.targetElement,
40
- this.targetElement?.frequencyDataTask.value
41
- ];
42
- },
43
- task: async () => {
44
- if (!this.targetElement) return;
45
- await this.targetElement.frequencyDataTask.taskComplete;
46
- this.ctx ||= this.initCanvas();
47
- const ctx = this.ctx;
48
- if (!ctx) return;
49
- const frequencyData = this.targetElement.frequencyDataTask.value;
50
- const byteTimeData = this.targetElement.byteTimeDomainTask.value;
51
- if (!frequencyData || !byteTimeData) return;
52
- ctx.save();
53
- if (this.color === "currentColor") {
54
- const computedStyle = getComputedStyle(this);
55
- const currentColor = computedStyle.color;
56
- ctx.strokeStyle = currentColor;
57
- ctx.fillStyle = currentColor;
58
- } else {
59
- ctx.strokeStyle = this.color;
60
- ctx.fillStyle = this.color;
61
- }
62
- switch (this.mode) {
63
- case "bars":
64
- this.drawBars(ctx, frequencyData);
65
- break;
66
- case "bricks":
67
- this.drawBricks(ctx, frequencyData);
68
- break;
69
- case "line":
70
- this.drawLine(ctx, byteTimeData);
71
- break;
72
- case "curve":
73
- this.drawCurve(ctx, byteTimeData);
74
- break;
75
- case "pixel":
76
- this.drawPixel(ctx, frequencyData);
77
- break;
78
- case "wave":
79
- this.drawWave(ctx, frequencyData);
80
- break;
81
- case "spikes":
82
- this.drawSpikes(ctx, frequencyData);
83
- break;
84
- case "roundBars":
85
- this.drawRoundBars(ctx, frequencyData);
86
- break;
87
- }
88
- ctx.restore();
89
- }
90
- });
91
- }
92
- render() {
93
- return html`<canvas ${ref(this.canvasRef)}></canvas>`;
94
- }
95
- connectedCallback() {
96
- super.connectedCallback();
97
- try {
98
- if (this.targetElement) {
99
- new CrossUpdateController(this.targetElement, this);
100
- }
101
- } catch (e) {
102
- }
103
- this.resizeObserver = new ResizeObserver(() => {
104
- this.resizeCanvas();
105
- });
106
- this.resizeObserver.observe(this);
107
- this.mutationObserver = new MutationObserver((mutationsList) => {
108
- for (const mutation of mutationsList) {
109
- if (mutation.type === "attributes") {
110
- this.frameTask.run();
111
- }
112
- }
113
- });
114
- this.mutationObserver.observe(this, { attributes: true });
115
- if (!EF_RENDERING()) {
116
- this.styleObserver = new CSSStyleObserver(["color"], () => {
117
- this.frameTask.run();
118
- });
119
- this.styleObserver.attach(this);
120
- }
121
- }
122
- disconnectedCallback() {
123
- super.disconnectedCallback();
124
- this.resizeObserver?.disconnect();
125
- this.mutationObserver?.disconnect();
126
- this.styleObserver?.detach();
127
- }
128
- resizeCanvas() {
129
- this.ctx = this.initCanvas();
130
- if (this.ctx) {
131
- this.frameTask.run();
132
- }
133
- }
134
- initCanvas() {
135
- const canvas = this.canvasRef.value;
136
- if (!canvas) return null;
137
- const rect = {
138
- width: this.offsetWidth,
139
- height: this.offsetHeight
140
- };
141
- const dpr = window.devicePixelRatio;
142
- canvas.style.width = `${rect.width}px`;
143
- canvas.style.height = `${rect.height}px`;
144
- canvas.width = rect.width * dpr;
145
- canvas.height = rect.height * dpr;
146
- const ctx = canvas.getContext("2d");
147
- if (!ctx) return null;
148
- ctx.reset();
149
- return ctx;
150
- }
151
- drawBars(ctx, frequencyData) {
152
- const canvas = ctx.canvas;
153
- const waveWidth = canvas.width;
154
- const waveHeight = canvas.height;
155
- const totalBars = frequencyData.length;
156
- const paddingInner = this.barSpacing;
157
- const paddingOuter = 0.01;
158
- const availableWidth = waveWidth;
159
- const barWidth = availableWidth / (totalBars + (totalBars - 1) * paddingInner);
160
- ctx.clearRect(0, 0, waveWidth, waveHeight);
161
- const path = new Path2D();
162
- frequencyData.forEach((value, i) => {
163
- const normalizedValue = value / 255;
164
- const barHeight = normalizedValue * waveHeight;
165
- const y = (waveHeight - barHeight) / 2;
166
- const x = waveWidth * paddingOuter + i * (barWidth * (1 + paddingInner));
167
- path.rect(x, y, barWidth, barHeight);
168
- });
169
- ctx.fill(path);
170
- }
171
- drawBricks(ctx, frequencyData) {
172
- const canvas = ctx.canvas;
173
- const waveWidth = canvas.width;
174
- const waveHeight = canvas.height;
175
- ctx.clearRect(0, 0, waveWidth, waveHeight);
176
- const path = new Path2D();
177
- const columnWidth = waveWidth / frequencyData.length;
178
- const boxSize = columnWidth * 0.9;
179
- const verticalGap = boxSize * 0.2;
180
- const maxBricks = Math.floor(waveHeight / (boxSize + verticalGap));
181
- frequencyData.forEach((value, i) => {
182
- const normalizedValue = value / 255;
183
- const brickCount = Math.floor(normalizedValue * maxBricks);
184
- for (let j = 0; j < brickCount; j++) {
185
- const x = columnWidth * i;
186
- const y = waveHeight - (j + 1) * (boxSize + verticalGap);
187
- path.rect(x, y, boxSize, boxSize);
188
- }
189
- });
190
- ctx.fill(path);
191
- }
192
- drawRoundBars(ctx, frequencyData) {
193
- const canvas = ctx.canvas;
194
- const waveWidth = canvas.width;
195
- const waveHeight = canvas.height;
196
- const totalBars = frequencyData.length;
197
- const paddingInner = this.barSpacing;
198
- const paddingOuter = 0.01;
199
- const availableWidth = waveWidth;
200
- const barWidth = availableWidth / (totalBars + (totalBars - 1) * paddingInner);
201
- ctx.clearRect(0, 0, waveWidth, waveHeight);
202
- const path = new Path2D();
203
- frequencyData.forEach((value, i) => {
204
- const normalizedValue = value / 255;
205
- const height = normalizedValue * waveHeight;
206
- const x = waveWidth * paddingOuter + i * (barWidth * (1 + paddingInner));
207
- const y = (waveHeight - height) / 2;
208
- path.roundRect(x, y, barWidth, height, barWidth / 2);
209
- });
210
- ctx.fill(path);
211
- }
212
- drawLine(ctx, frequencyData) {
213
- const canvas = ctx.canvas;
214
- const waveWidth = canvas.width;
215
- const waveHeight = canvas.height;
216
- ctx.clearRect(0, 0, waveWidth, waveHeight);
217
- const path = new Path2D();
218
- const sampleRate = 1;
219
- for (let i = 0; i < frequencyData.length; i += sampleRate) {
220
- const x = i / frequencyData.length * waveWidth;
221
- const y = (1 - (frequencyData[i] ?? 0) / 255) * waveHeight;
222
- if (i === 0) {
223
- path.moveTo(x, y);
224
- } else {
225
- path.lineTo(x, y);
226
- }
227
- }
228
- const lastX = waveWidth;
229
- const lastY = (1 - (frequencyData[frequencyData.length - 1] ?? 0) / 255) * waveHeight;
230
- path.lineTo(lastX, lastY);
231
- ctx.lineWidth = this.lineWidth;
232
- ctx.stroke(path);
233
- }
234
- drawCurve(ctx, frequencyData) {
235
- const canvas = ctx.canvas;
236
- const waveWidth = canvas.width;
237
- const waveHeight = canvas.height;
238
- ctx.clearRect(0, 0, waveWidth, waveHeight);
239
- const path = new Path2D();
240
- frequencyData.forEach((value, i) => {
241
- const x = i / frequencyData.length * waveWidth;
242
- const y = (1 - value / 255) * waveHeight;
243
- if (i === 0) {
244
- path.moveTo(x, y);
245
- } else {
246
- const prevX = (i - 1) / frequencyData.length * waveWidth;
247
- const prevY = (1 - (frequencyData[i - 1] ?? 0) / 255) * waveHeight;
248
- const xc = (prevX + x) / 2;
249
- const yc = (prevY + y) / 2;
250
- path.quadraticCurveTo(prevX, prevY, xc, yc);
251
- }
252
- });
253
- ctx.lineWidth = this.lineWidth;
254
- ctx.stroke(path);
255
- }
256
- drawPixel(ctx, frequencyData) {
257
- const canvas = ctx.canvas;
258
- const waveWidth = canvas.width;
259
- const waveHeight = canvas.height;
260
- const baseline = waveHeight / 2;
261
- const barWidth = waveWidth / frequencyData.length;
262
- ctx.clearRect(0, 0, waveWidth, waveHeight);
263
- const path = new Path2D();
264
- frequencyData.forEach((value, i) => {
265
- const normalizedValue = value / 255;
266
- const x = i * (waveWidth / frequencyData.length);
267
- const barHeight = normalizedValue * (waveHeight / 2);
268
- const y = baseline - barHeight;
269
- path.rect(x, y, barWidth, barHeight * 2);
270
- });
271
- ctx.fill(path);
272
- }
273
- drawWave(ctx, frequencyData) {
274
- const canvas = ctx.canvas;
275
- const waveWidth = canvas.width;
276
- const waveHeight = canvas.height;
277
- const paddingOuter = 0.01;
278
- const availableWidth = waveWidth * (1 - 2 * paddingOuter);
279
- const startX = waveWidth * paddingOuter;
280
- ctx.clearRect(0, 0, waveWidth, waveHeight);
281
- const path = new Path2D();
282
- const firstValue = Math.min((frequencyData[0] ?? 0) / 255 * 2, 1);
283
- const firstY = (waveHeight - firstValue * waveHeight) / 2;
284
- path.moveTo(startX, firstY);
285
- frequencyData.forEach((value, i) => {
286
- const normalizedValue = Math.min(value / 255 * 2, 1);
287
- const x = startX + i / (frequencyData.length - 1) * availableWidth;
288
- const barHeight = normalizedValue * waveHeight;
289
- const y = (waveHeight - barHeight) / 2;
290
- if (i === 0) {
291
- path.moveTo(x, y);
292
- } else {
293
- const prevX = startX + (i - 1) / (frequencyData.length - 1) * availableWidth;
294
- const prevValue = Math.min((frequencyData[i - 1] ?? 0) / 255 * 2, 1);
295
- const prevBarHeight = prevValue * waveHeight;
296
- const prevY = (waveHeight - prevBarHeight) / 2;
297
- const xc = (prevX + x) / 2;
298
- const yc = (prevY + y) / 2;
299
- path.quadraticCurveTo(prevX, prevY, xc, yc);
300
- }
301
- });
302
- for (let i = frequencyData.length - 1; i >= 0; i--) {
303
- const normalizedValue = Math.min((frequencyData[i] ?? 0) / 255 * 2, 1);
304
- const x = startX + i / (frequencyData.length - 1) * availableWidth;
305
- const barHeight = normalizedValue * waveHeight;
306
- const y = (waveHeight + barHeight) / 2;
307
- if (i === frequencyData.length - 1) {
308
- path.lineTo(x, y);
309
- } else {
310
- const nextX = startX + (i + 1) / (frequencyData.length - 1) * availableWidth;
311
- const nextValue = Math.min((frequencyData[i + 1] ?? 0) / 255 * 2, 1);
312
- const nextBarHeight = nextValue * waveHeight;
313
- const nextY = (waveHeight + nextBarHeight) / 2;
314
- const xc = (nextX + x) / 2;
315
- const yc = (nextY + y) / 2;
316
- path.quadraticCurveTo(nextX, nextY, xc, yc);
317
- }
318
- }
319
- const lastY = (waveHeight + firstValue * waveHeight) / 2;
320
- const controlX = startX;
321
- const controlY = (lastY + firstY) / 2;
322
- path.quadraticCurveTo(controlX, controlY, startX, firstY);
323
- ctx.fill(path);
324
- }
325
- drawSpikes(ctx, frequencyData) {
326
- const canvas = ctx.canvas;
327
- const waveWidth = canvas.width;
328
- const waveHeight = canvas.height;
329
- const paddingOuter = 0.01;
330
- const availableWidth = waveWidth * (1 - 2 * paddingOuter);
331
- const startX = waveWidth * paddingOuter;
332
- ctx.clearRect(0, 0, waveWidth, waveHeight);
333
- const path = new Path2D();
334
- const firstValue = (frequencyData[0] ?? 0) / 255;
335
- const firstY = (waveHeight - firstValue * waveHeight) / 2;
336
- path.moveTo(startX, firstY);
337
- frequencyData.forEach((value, i) => {
338
- const normalizedValue = Math.min(value / 255 * 2, 1);
339
- const x = startX + i / (frequencyData.length - 1) * availableWidth;
340
- const barHeight = normalizedValue * (waveHeight / 2);
341
- const y = (waveHeight - barHeight * 2) / 2;
342
- if (i === 0) {
343
- path.moveTo(x, y);
344
- } else {
345
- const prevX = startX + (i - 1) / (frequencyData.length - 1) * availableWidth;
346
- const prevValue = (frequencyData[i - 1] ?? 0) / 255;
347
- const prevBarHeight = prevValue * (waveHeight / 2);
348
- const prevY = (waveHeight - prevBarHeight * 2) / 2;
349
- const xc = (prevX + x) / 2;
350
- const yc = (prevY + y) / 2;
351
- path.quadraticCurveTo(prevX, prevY, xc, yc);
352
- }
353
- });
354
- for (let i = frequencyData.length - 1; i >= 0; i--) {
355
- const normalizedValue = Math.min((frequencyData[i] ?? 0) / 255 * 2, 1);
356
- const x = startX + i / (frequencyData.length - 1) * availableWidth;
357
- const barHeight = normalizedValue * (waveHeight / 2);
358
- const y = (waveHeight + barHeight * 2) / 2;
359
- if (i === frequencyData.length - 1) {
360
- path.lineTo(x, y);
361
- } else {
362
- const nextX = startX + (i + 1) / (frequencyData.length - 1) * availableWidth;
363
- const nextValue = (frequencyData[i + 1] ?? 0) / 255;
364
- const nextBarHeight = nextValue * (waveHeight / 2);
365
- const nextY = (waveHeight + nextBarHeight * 2) / 2;
366
- const xc = (nextX + x) / 2;
367
- const yc = (nextY + y) / 2;
368
- path.quadraticCurveTo(nextX, nextY, xc, yc);
369
- }
370
- }
371
- const lastY = (waveHeight + firstValue * waveHeight) / 2;
372
- const controlX = startX;
373
- const controlY = (lastY + firstY) / 2;
374
- path.quadraticCurveTo(controlX, controlY, startX, firstY);
375
- ctx.fill(path);
376
- }
377
- get durationMs() {
378
- if (!this.targetElement) return 0;
379
- return this.targetElement.durationMs;
380
- }
381
- updated(changedProperties) {
382
- super.updated(changedProperties);
383
- if (changedProperties.size > 0) {
384
- this.frameTask.run();
385
- }
386
- }
387
- };
388
- EFWaveform.styles = css`
5
+ import { TWMixin } from "../gui/TWMixin2.js";
6
+ import { CrossUpdateController } from "./CrossUpdateController.js";
7
+ import { Task } from "@lit/task";
8
+ import { LitElement, css, html } from "lit";
9
+ import { customElement, property, state } from "lit/decorators.js";
10
+ import _decorate from "@oxc-project/runtime/helpers/decorate";
11
+ import { createRef, ref } from "lit/directives/ref.js";
12
+ import { CSSStyleObserver } from "@bramus/style-observer";
13
+ let EFWaveform = class EFWaveform$1 extends EFTemporal(TWMixin(LitElement)) {
14
+ constructor(..._args) {
15
+ super(..._args);
16
+ this.canvasRef = createRef();
17
+ this.ctx = null;
18
+ this.styleObserver = null;
19
+ this.mode = "bars";
20
+ this.color = "currentColor";
21
+ this.target = "";
22
+ this.barSpacing = .5;
23
+ this.targetElement = null;
24
+ this.lineWidth = 4;
25
+ this.targetController = new TargetController(this);
26
+ this.frameTask = new Task(this, {
27
+ autoRun: EF_INTERACTIVE,
28
+ args: () => {
29
+ return [this.targetElement, this.targetElement?.frequencyDataTask.value];
30
+ },
31
+ task: async () => {
32
+ if (!this.targetElement) return;
33
+ await this.targetElement.frequencyDataTask.taskComplete;
34
+ this.ctx ||= this.initCanvas();
35
+ const ctx = this.ctx;
36
+ if (!ctx) return;
37
+ const frequencyData = this.targetElement.frequencyDataTask.value;
38
+ const byteTimeData = this.targetElement.byteTimeDomainTask.value;
39
+ if (!frequencyData || !byteTimeData) return;
40
+ ctx.save();
41
+ if (this.color === "currentColor") {
42
+ const computedStyle = getComputedStyle(this);
43
+ const currentColor = computedStyle.color;
44
+ ctx.strokeStyle = currentColor;
45
+ ctx.fillStyle = currentColor;
46
+ } else {
47
+ ctx.strokeStyle = this.color;
48
+ ctx.fillStyle = this.color;
49
+ }
50
+ switch (this.mode) {
51
+ case "bars":
52
+ this.drawBars(ctx, frequencyData);
53
+ break;
54
+ case "bricks":
55
+ this.drawBricks(ctx, frequencyData);
56
+ break;
57
+ case "line":
58
+ this.drawLine(ctx, byteTimeData);
59
+ break;
60
+ case "curve":
61
+ this.drawCurve(ctx, byteTimeData);
62
+ break;
63
+ case "pixel":
64
+ this.drawPixel(ctx, frequencyData);
65
+ break;
66
+ case "wave":
67
+ this.drawWave(ctx, frequencyData);
68
+ break;
69
+ case "spikes":
70
+ this.drawSpikes(ctx, frequencyData);
71
+ break;
72
+ case "roundBars":
73
+ this.drawRoundBars(ctx, frequencyData);
74
+ break;
75
+ }
76
+ ctx.restore();
77
+ }
78
+ });
79
+ }
80
+ static {
81
+ this.styles = css`
389
82
  :host {
390
- display: block;
391
83
  all: inherit;
84
+ display: block;
392
85
  position: relative;
393
86
  }
394
87
 
@@ -400,30 +93,301 @@ EFWaveform.styles = css`
400
93
  height: 100%;
401
94
  }
402
95
  `;
403
- __decorateClass([
404
- property({
405
- type: String,
406
- attribute: "mode"
407
- })
408
- ], EFWaveform.prototype, "mode", 2);
409
- __decorateClass([
410
- property({ type: String })
411
- ], EFWaveform.prototype, "color", 2);
412
- __decorateClass([
413
- property({ type: String, reflect: true })
414
- ], EFWaveform.prototype, "target", 2);
415
- __decorateClass([
416
- property({ type: Number, attribute: "bar-spacing" })
417
- ], EFWaveform.prototype, "barSpacing", 2);
418
- __decorateClass([
419
- state()
420
- ], EFWaveform.prototype, "targetElement", 2);
421
- __decorateClass([
422
- property({ type: Number, attribute: "line-width" })
423
- ], EFWaveform.prototype, "lineWidth", 2);
424
- EFWaveform = __decorateClass([
425
- customElement("ef-waveform")
426
- ], EFWaveform);
427
- export {
428
- EFWaveform
96
+ }
97
+ render() {
98
+ return html`<canvas ${ref(this.canvasRef)}></canvas><div class="text-5xl inline-block bg-red-500">`;
99
+ }
100
+ connectedCallback() {
101
+ super.connectedCallback();
102
+ try {
103
+ if (this.targetElement) new CrossUpdateController(this.targetElement, this);
104
+ } catch (_error) {}
105
+ this.resizeObserver = new ResizeObserver(() => {
106
+ this.resizeCanvas();
107
+ });
108
+ this.resizeObserver.observe(this);
109
+ this.mutationObserver = new MutationObserver((mutationsList) => {
110
+ for (const mutation of mutationsList) if (mutation.type === "attributes") this.frameTask.run();
111
+ });
112
+ this.mutationObserver.observe(this, { attributes: true });
113
+ if (!EF_RENDERING()) {
114
+ this.styleObserver = new CSSStyleObserver(["color"], () => {
115
+ this.frameTask.run();
116
+ });
117
+ this.styleObserver.attach(this);
118
+ }
119
+ }
120
+ disconnectedCallback() {
121
+ super.disconnectedCallback();
122
+ this.resizeObserver?.disconnect();
123
+ this.mutationObserver?.disconnect();
124
+ this.styleObserver?.detach();
125
+ }
126
+ resizeCanvas() {
127
+ this.ctx = this.initCanvas();
128
+ if (this.ctx) this.frameTask.run();
129
+ }
130
+ initCanvas() {
131
+ const canvas = this.canvasRef.value;
132
+ if (!canvas) return null;
133
+ const rect = {
134
+ width: this.offsetWidth,
135
+ height: this.offsetHeight
136
+ };
137
+ const dpr = window.devicePixelRatio;
138
+ canvas.style.width = `${rect.width}px`;
139
+ canvas.style.height = `${rect.height}px`;
140
+ canvas.width = rect.width * dpr;
141
+ canvas.height = rect.height * dpr;
142
+ const ctx = canvas.getContext("2d");
143
+ if (!ctx) return null;
144
+ ctx.reset();
145
+ return ctx;
146
+ }
147
+ drawBars(ctx, frequencyData) {
148
+ const canvas = ctx.canvas;
149
+ const waveWidth = canvas.width;
150
+ const waveHeight = canvas.height;
151
+ const totalBars = frequencyData.length;
152
+ const paddingInner = this.barSpacing;
153
+ const paddingOuter = .01;
154
+ const availableWidth = waveWidth;
155
+ const barWidth = availableWidth / (totalBars + (totalBars - 1) * paddingInner);
156
+ ctx.clearRect(0, 0, waveWidth, waveHeight);
157
+ const path = new Path2D();
158
+ frequencyData.forEach((value, i) => {
159
+ const normalizedValue = value / 255;
160
+ const barHeight = normalizedValue * waveHeight;
161
+ const y = (waveHeight - barHeight) / 2;
162
+ const x = waveWidth * paddingOuter + i * (barWidth * (1 + paddingInner));
163
+ path.rect(x, y, barWidth, barHeight);
164
+ });
165
+ ctx.fill(path);
166
+ }
167
+ drawBricks(ctx, frequencyData) {
168
+ const canvas = ctx.canvas;
169
+ const waveWidth = canvas.width;
170
+ const waveHeight = canvas.height;
171
+ ctx.clearRect(0, 0, waveWidth, waveHeight);
172
+ const path = new Path2D();
173
+ const columnWidth = waveWidth / frequencyData.length;
174
+ const boxSize = columnWidth * .9;
175
+ const verticalGap = boxSize * .2;
176
+ const maxBricks = Math.floor(waveHeight / (boxSize + verticalGap));
177
+ frequencyData.forEach((value, i) => {
178
+ const normalizedValue = value / 255;
179
+ const brickCount = Math.floor(normalizedValue * maxBricks);
180
+ for (let j = 0; j < brickCount; j++) {
181
+ const x = columnWidth * i;
182
+ const y = waveHeight - (j + 1) * (boxSize + verticalGap);
183
+ path.rect(x, y, boxSize, boxSize);
184
+ }
185
+ });
186
+ ctx.fill(path);
187
+ }
188
+ drawRoundBars(ctx, frequencyData) {
189
+ const canvas = ctx.canvas;
190
+ const waveWidth = canvas.width;
191
+ const waveHeight = canvas.height;
192
+ const totalBars = frequencyData.length;
193
+ const paddingInner = this.barSpacing;
194
+ const paddingOuter = .01;
195
+ const availableWidth = waveWidth;
196
+ const barWidth = availableWidth / (totalBars + (totalBars - 1) * paddingInner);
197
+ ctx.clearRect(0, 0, waveWidth, waveHeight);
198
+ const path = new Path2D();
199
+ frequencyData.forEach((value, i) => {
200
+ const normalizedValue = value / 255;
201
+ const height = normalizedValue * waveHeight;
202
+ const x = waveWidth * paddingOuter + i * (barWidth * (1 + paddingInner));
203
+ const y = (waveHeight - height) / 2;
204
+ path.roundRect(x, y, barWidth, height, barWidth / 2);
205
+ });
206
+ ctx.fill(path);
207
+ }
208
+ drawLine(ctx, frequencyData) {
209
+ const canvas = ctx.canvas;
210
+ const waveWidth = canvas.width;
211
+ const waveHeight = canvas.height;
212
+ ctx.clearRect(0, 0, waveWidth, waveHeight);
213
+ const path = new Path2D();
214
+ const sampleRate = 1;
215
+ for (let i = 0; i < frequencyData.length; i += sampleRate) {
216
+ const x = i / frequencyData.length * waveWidth;
217
+ const y = (1 - (frequencyData[i] ?? 0) / 255) * waveHeight;
218
+ if (i === 0) path.moveTo(x, y);
219
+ else path.lineTo(x, y);
220
+ }
221
+ const lastX = waveWidth;
222
+ const lastY = (1 - (frequencyData[frequencyData.length - 1] ?? 0) / 255) * waveHeight;
223
+ path.lineTo(lastX, lastY);
224
+ ctx.lineWidth = this.lineWidth;
225
+ ctx.stroke(path);
226
+ }
227
+ drawCurve(ctx, frequencyData) {
228
+ const canvas = ctx.canvas;
229
+ const waveWidth = canvas.width;
230
+ const waveHeight = canvas.height;
231
+ ctx.clearRect(0, 0, waveWidth, waveHeight);
232
+ const path = new Path2D();
233
+ frequencyData.forEach((value, i) => {
234
+ const x = i / frequencyData.length * waveWidth;
235
+ const y = (1 - value / 255) * waveHeight;
236
+ if (i === 0) path.moveTo(x, y);
237
+ else {
238
+ const prevX = (i - 1) / frequencyData.length * waveWidth;
239
+ const prevY = (1 - (frequencyData[i - 1] ?? 0) / 255) * waveHeight;
240
+ const xc = (prevX + x) / 2;
241
+ const yc = (prevY + y) / 2;
242
+ path.quadraticCurveTo(prevX, prevY, xc, yc);
243
+ }
244
+ });
245
+ ctx.lineWidth = this.lineWidth;
246
+ ctx.stroke(path);
247
+ }
248
+ drawPixel(ctx, frequencyData) {
249
+ const canvas = ctx.canvas;
250
+ const waveWidth = canvas.width;
251
+ const waveHeight = canvas.height;
252
+ const baseline = waveHeight / 2;
253
+ const barWidth = waveWidth / frequencyData.length;
254
+ ctx.clearRect(0, 0, waveWidth, waveHeight);
255
+ const path = new Path2D();
256
+ frequencyData.forEach((value, i) => {
257
+ const normalizedValue = value / 255;
258
+ const x = i * (waveWidth / frequencyData.length);
259
+ const barHeight = normalizedValue * (waveHeight / 2);
260
+ const y = baseline - barHeight;
261
+ path.rect(x, y, barWidth, barHeight * 2);
262
+ });
263
+ ctx.fill(path);
264
+ }
265
+ drawWave(ctx, frequencyData) {
266
+ const canvas = ctx.canvas;
267
+ const waveWidth = canvas.width;
268
+ const waveHeight = canvas.height;
269
+ const paddingOuter = .01;
270
+ const availableWidth = waveWidth * (1 - 2 * paddingOuter);
271
+ const startX = waveWidth * paddingOuter;
272
+ ctx.clearRect(0, 0, waveWidth, waveHeight);
273
+ const path = new Path2D();
274
+ const firstValue = Math.min((frequencyData[0] ?? 0) / 255 * 2, 1);
275
+ const firstY = (waveHeight - firstValue * waveHeight) / 2;
276
+ path.moveTo(startX, firstY);
277
+ frequencyData.forEach((value, i) => {
278
+ const normalizedValue = Math.min(value / 255 * 2, 1);
279
+ const x = startX + i / (frequencyData.length - 1) * availableWidth;
280
+ const barHeight = normalizedValue * waveHeight;
281
+ const y = (waveHeight - barHeight) / 2;
282
+ if (i === 0) path.moveTo(x, y);
283
+ else {
284
+ const prevX = startX + (i - 1) / (frequencyData.length - 1) * availableWidth;
285
+ const prevValue = Math.min((frequencyData[i - 1] ?? 0) / 255 * 2, 1);
286
+ const prevBarHeight = prevValue * waveHeight;
287
+ const prevY = (waveHeight - prevBarHeight) / 2;
288
+ const xc = (prevX + x) / 2;
289
+ const yc = (prevY + y) / 2;
290
+ path.quadraticCurveTo(prevX, prevY, xc, yc);
291
+ }
292
+ });
293
+ for (let i = frequencyData.length - 1; i >= 0; i--) {
294
+ const normalizedValue = Math.min((frequencyData[i] ?? 0) / 255 * 2, 1);
295
+ const x = startX + i / (frequencyData.length - 1) * availableWidth;
296
+ const barHeight = normalizedValue * waveHeight;
297
+ const y = (waveHeight + barHeight) / 2;
298
+ if (i === frequencyData.length - 1) path.lineTo(x, y);
299
+ else {
300
+ const nextX = startX + (i + 1) / (frequencyData.length - 1) * availableWidth;
301
+ const nextValue = Math.min((frequencyData[i + 1] ?? 0) / 255 * 2, 1);
302
+ const nextBarHeight = nextValue * waveHeight;
303
+ const nextY = (waveHeight + nextBarHeight) / 2;
304
+ const xc = (nextX + x) / 2;
305
+ const yc = (nextY + y) / 2;
306
+ path.quadraticCurveTo(nextX, nextY, xc, yc);
307
+ }
308
+ }
309
+ const lastY = (waveHeight + firstValue * waveHeight) / 2;
310
+ const controlX = startX;
311
+ const controlY = (lastY + firstY) / 2;
312
+ path.quadraticCurveTo(controlX, controlY, startX, firstY);
313
+ ctx.fill(path);
314
+ }
315
+ drawSpikes(ctx, frequencyData) {
316
+ const canvas = ctx.canvas;
317
+ const waveWidth = canvas.width;
318
+ const waveHeight = canvas.height;
319
+ const paddingOuter = .01;
320
+ const availableWidth = waveWidth * (1 - 2 * paddingOuter);
321
+ const startX = waveWidth * paddingOuter;
322
+ ctx.clearRect(0, 0, waveWidth, waveHeight);
323
+ const path = new Path2D();
324
+ const firstValue = (frequencyData[0] ?? 0) / 255;
325
+ const firstY = (waveHeight - firstValue * waveHeight) / 2;
326
+ path.moveTo(startX, firstY);
327
+ frequencyData.forEach((value, i) => {
328
+ const normalizedValue = Math.min(value / 255 * 2, 1);
329
+ const x = startX + i / (frequencyData.length - 1) * availableWidth;
330
+ const barHeight = normalizedValue * (waveHeight / 2);
331
+ const y = (waveHeight - barHeight * 2) / 2;
332
+ if (i === 0) path.moveTo(x, y);
333
+ else {
334
+ const prevX = startX + (i - 1) / (frequencyData.length - 1) * availableWidth;
335
+ const prevValue = (frequencyData[i - 1] ?? 0) / 255;
336
+ const prevBarHeight = prevValue * (waveHeight / 2);
337
+ const prevY = (waveHeight - prevBarHeight * 2) / 2;
338
+ const xc = (prevX + x) / 2;
339
+ const yc = (prevY + y) / 2;
340
+ path.quadraticCurveTo(prevX, prevY, xc, yc);
341
+ }
342
+ });
343
+ for (let i = frequencyData.length - 1; i >= 0; i--) {
344
+ const normalizedValue = Math.min((frequencyData[i] ?? 0) / 255 * 2, 1);
345
+ const x = startX + i / (frequencyData.length - 1) * availableWidth;
346
+ const barHeight = normalizedValue * (waveHeight / 2);
347
+ const y = (waveHeight + barHeight * 2) / 2;
348
+ if (i === frequencyData.length - 1) path.lineTo(x, y);
349
+ else {
350
+ const nextX = startX + (i + 1) / (frequencyData.length - 1) * availableWidth;
351
+ const nextValue = (frequencyData[i + 1] ?? 0) / 255;
352
+ const nextBarHeight = nextValue * (waveHeight / 2);
353
+ const nextY = (waveHeight + nextBarHeight * 2) / 2;
354
+ const xc = (nextX + x) / 2;
355
+ const yc = (nextY + y) / 2;
356
+ path.quadraticCurveTo(nextX, nextY, xc, yc);
357
+ }
358
+ }
359
+ const lastY = (waveHeight + firstValue * waveHeight) / 2;
360
+ const controlX = startX;
361
+ const controlY = (lastY + firstY) / 2;
362
+ path.quadraticCurveTo(controlX, controlY, startX, firstY);
363
+ ctx.fill(path);
364
+ }
365
+ get durationMs() {
366
+ if (!this.targetElement) return 0;
367
+ return this.targetElement.durationMs;
368
+ }
369
+ updated(changedProperties) {
370
+ super.updated(changedProperties);
371
+ if (changedProperties.size > 0) this.frameTask.run();
372
+ }
429
373
  };
374
+ _decorate([property({
375
+ type: String,
376
+ attribute: "mode"
377
+ })], EFWaveform.prototype, "mode", void 0);
378
+ _decorate([property({ type: String })], EFWaveform.prototype, "color", void 0);
379
+ _decorate([property({
380
+ type: String,
381
+ reflect: true
382
+ })], EFWaveform.prototype, "target", void 0);
383
+ _decorate([property({
384
+ type: Number,
385
+ attribute: "bar-spacing"
386
+ })], EFWaveform.prototype, "barSpacing", void 0);
387
+ _decorate([state()], EFWaveform.prototype, "targetElement", void 0);
388
+ _decorate([property({
389
+ type: Number,
390
+ attribute: "line-width"
391
+ })], EFWaveform.prototype, "lineWidth", void 0);
392
+ EFWaveform = _decorate([customElement("ef-waveform")], EFWaveform);
393
+ export { EFWaveform };