@vknext/shared 1.6.43 → 1.6.45
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
import{STANDARD_BITRATES as t}from"../../common/consts.js";import{createPromise as
|
|
1
|
+
import{STANDARD_BITRATES as t}from"../../common/consts.js";import{createPromise as a}from"../../utils/createPromise.js";import"../../utils/parseSvg.js";import{attachHlsErrorHandlers as o}from"./utils/attachHlsErrorHandlers.js";import{extractAudioFromMp4 as e}from"./utils/extractAudioFromMp4.js";import{getHlsInstance as r}from"./utils/getHlsInstance.js";import{resolveMediaSource as s}from"./utils/resolveMediaSource.js";const n=a=>{const o=t.reduce(((t,o)=>Math.abs(o-a)<Math.abs(t-a)?o:t));return Math.abs(a-o)/o<.15?o:Math.round(a)},i=async({url:t})=>{const{type:i,response:d}=await s(t);if("hls"!==i&&d){await(d.body?.cancel());const a=parseInt(d.headers.get("content-length")||"0",10),o=await new Promise(((a,o)=>{const e=new Audio,r=()=>{e.pause(),e.src="",e.load()};e.onloadedmetadata=()=>{const t=e.duration;r(),a(t)},e.onerror=()=>{r(),o(new Error("[VK Next/getTrackDetails] Failed to load audio metadata for duration calculation"))},e.src=t})),e=o>0?Math.round(8*a/o/1e3):0;return{bitrate:n(e),size:a,duration:o}}d&&await(d.body?.cancel());const{promise:l,resolve:u,reject:c}=a(),m=await r(),p=new m({maxBufferHole:2,maxBufferLength:10,maxBufferSize:5e6,fragLoadingRetryDelay:500,fragLoadingMaxRetry:3,maxFragLookUpTolerance:.2,startPosition:0,enableWorker:!1}),f=new Audio;let h,E,g=null;return p.on(m.Events.MANIFEST_PARSED,((t,a)=>{const o=a.levels[0]?.details;o&&(E=o.totalduration)})),p.on(m.Events.BUFFER_CODECS,((t,a)=>{a.audio&&"audio/mp4"!==a.audio.container||(h=a.audio)})),p.on(m.Events.BUFFER_APPENDING,((t,a)=>{g=a.data})),p.on(m.Events.FRAG_LOADED,((t,a)=>{if(g){p.detachMedia();((t,a)=>{const o=Math.round(8*t/a/1e3),e=n(o);u({bitrate:e,size:t,duration:a}),p.stopLoad(),p.destroy()})((h?e(g):g).length/a.frag.duration*E,E)}})),o({Hls:m,hlsInstance:p,onError:t=>{c(t),p.stopLoad(),p.destroy()}}),p.loadSource(t),p.attachMedia(f),await l};export{i as getTrackDetails};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{onAddTopNotifier}from"./onAddTopNotifier.js";export{onAddWall}from"./onAddWall.js";export{waitAjax}from"./waitAjax.js";export{waitAudioPlayer}from"./waitAudioPlayer.js";export{waitAudioPlayerUI}from"./waitAudioPlayerUI.js";export{waitAudioUtils}from"./waitAudioUtils.js";export{waitBoxQueue}from"./waitBoxQueue.js";export{waitCalls}from"./waitCalls.js";export{waitColorScheme}from"./waitColorScheme.js";export{waitCur}from"./waitCur.js";export{waitElementTooltip}from"./waitElementTooltip.js";export{waitGetAudioPlayer}from"./waitGetAudioPlayer.js";export{waitMECommonContext}from"./waitMECommonContext.js";export{waitMECommunityCommonContext}from"./waitMECommunityCommonContext.js";export{waitNav}from"./waitNav.js";export{waitPhotoview}from"./waitPhotoview.js";export{waitStories}from"./waitStories.js";export{waitTopNotifier}from"./waitTopNotifier.js";export{waitUIActionsMenu}from"./waitUIActionsMenu.js";export{waitVideoInitializer}from"./waitVideoInitializer.js";export{waitVK}from"./waitVK.js";export{waitVKApi}from"./waitVKApi.js";
|
|
1
|
+
export{onAddTopNotifier}from"./onAddTopNotifier.js";export{onAddWall}from"./onAddWall.js";export{waitAjax}from"./waitAjax.js";export{waitAudioPlayer}from"./waitAudioPlayer.js";export{waitAudioPlayerUI}from"./waitAudioPlayerUI.js";export{waitAudioUtils}from"./waitAudioUtils.js";export{waitBoxQueue}from"./waitBoxQueue.js";export{waitCalls}from"./waitCalls.js";export{waitColorScheme}from"./waitColorScheme.js";export{waitCur}from"./waitCur.js";export{waitElementTooltip}from"./waitElementTooltip.js";export{waitGetAudioPlayer}from"./waitGetAudioPlayer.js";export{waitMECommonContext}from"./waitMECommonContext.js";export{waitMECommunityCommonContext}from"./waitMECommunityCommonContext.js";export{waitNav}from"./waitNav.js";export{waitPhotoview}from"./waitPhotoview.js";export{waitStories}from"./waitStories.js";export{waitTopNotifier}from"./waitTopNotifier.js";export{waitUIActionsMenu}from"./waitUIActionsMenu.js";export{waitVideoInitializer}from"./waitVideoInitializer.js";export{waitVK}from"./waitVK.js";export{waitVKApi}from"./waitVKApi.js";export{onAddElementTooltip}from"./onAddElementTooltip.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ListenerRegistry as t}from"../../common/ListenerRegistry.js";import{waitElementTooltip as e}from"./waitElementTooltip.js";import{waitTopNotifier as o}from"./waitTopNotifier.js";const n=new t,r=async t=>{for(const e of n.listeners)e(t)};let i=!1;const s=t=>{const s=n.addListener(t);return e().then((t=>r(t))),i||(i=!0,(async()=>{let t=await o();Object.defineProperty(window,"ElementTooltip",{get:()=>t,set:e=>{t=e,r(e)}})})()),s};export{s as onAddElementTooltip};
|