@vknext/shared 1.6.32 → 1.6.33

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{createPromise as t}from"../../utils/createPromise.js";import"../../utils/parseSvg.js";import{attachHlsErrorHandlers as e}from"./utils/attachHlsErrorHandlers.js";import{getHlsInstance as r}from"./utils/getHlsInstance.js";const o=async({url:o})=>{const{promise:a,resolve:n,reject:s}=t(),i=await r(),l=new i({maxBufferHole:2,maxBufferLength:10,maxBufferSize:5e6,fragLoadingRetryDelay:500,fragLoadingMaxRetry:3,maxFragLookUpTolerance:.2,startPosition:0,enableWorker:!1}),u=new Audio;let d;return l.on(i.Events.MANIFEST_PARSED,((t,e)=>{const r=e.levels[0]?.details;r&&(d=r.totalduration)})),l.on(i.Events.FRAG_LOADED,((t,{frag:e,payload:r})=>{if("initSegment"===e.sn)return;const o=e.duration;if(o<=0)return;if(!d){const t=l.levels[e.level];t&&t.details&&(d=t.details.totalduration)}const a=d||o;((t,e,r)=>{const o=t/e*r,a=Math.round(8*o/r/1e3);n({bitrate:a,size:Math.round(o),duration:r}),l.stopLoad(),l.destroy()})((t=>{const e=new DataView(t);let r=0;for(;r+8<=t.byteLength;){const o=e.getUint32(r),a=e.getUint32(r+4);if(o<8)break;if(1835295092===a)return Math.min(o,t.byteLength-r)-8;r+=o}return t.byteLength})(r),o,a)})),e({Hls:i,hlsInstance:l,onError:t=>{s(t),l.stopLoad(),l.destroy()}}),l.loadSource(o),l.attachMedia(u),await a};export{o as getTrackDetails};
1
+ import{createPromise as t}from"../../utils/createPromise.js";import"../../utils/parseSvg.js";import{attachHlsErrorHandlers as e}from"./utils/attachHlsErrorHandlers.js";import{getHlsInstance as o}from"./utils/getHlsInstance.js";const r=[32,40,48,56,64,80,96,112,128,160,192,224,256,320],n=[0,32,40,48,56,64,80,96,112,128,160,192,224,256,320,0],a=[0,8,16,24,32,40,48,56,64,80,96,112,128,144,160,0],i=async({url:i})=>{const{promise:s,resolve:l,reject:u}=t(),c=await o(),f=new c({maxBufferHole:2,maxBufferLength:10,maxBufferSize:5e6,fragLoadingRetryDelay:500,fragLoadingMaxRetry:3,maxFragLookUpTolerance:.2,startPosition:0,enableWorker:!1}),d=new Audio;let m;return f.on(c.Events.MANIFEST_PARSED,((t,e)=>{const o=e.levels[0]?.details;o&&(m=o.totalduration)})),f.on(c.Events.FRAG_LOADED,((t,{frag:e,payload:o})=>{if("initSegment"===e.sn)return;let i=(t=>{const e=Math.min(Math.max(0,t.length-4),102400);for(let o=0;o<e;o++){if(255!==t[o])continue;const e=t[o+1],r=t[o+2];if(void 0===e||void 0===r)continue;if(224&~e)continue;const i=(24&e)>>3;if(1===i)continue;if(1!=(6&e)>>1)continue;const s=(240&r)>>4;if(0===s||15===s)continue;const l=(3===i?n:a)[s];if(l&&l>0)return l}return null})(new Uint8Array(o));if(!i)if(e.bitrate){i=(t=>{const e=r.reduce(((e,o)=>Math.abs(o-t)<Math.abs(e-t)?o:e));return Math.abs(t-e)/e<.15?e:Math.round(t)})(e.bitrate/1e3)}else i=0;const s=m||e.duration,u=1e3*i*s/8;l({bitrate:i,size:Math.round(u),duration:s}),f.stopLoad(),f.destroy()})),e({Hls:c,hlsInstance:f,onError:t=>{u(t),f.stopLoad(),f.destroy()}}),f.loadSource(i),f.attachMedia(d),await s};export{i as getTrackDetails};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vknext/shared",
3
- "version": "1.6.32",
3
+ "version": "1.6.33",
4
4
  "description": "vk next shared",
5
5
  "type": "module",
6
6
  "files": [