@vknext/shared 1.6.6 → 1.6.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/lib/lang/Lang.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare class Lang<T extends LangMap> {
|
|
|
9
9
|
protected isDebug: boolean;
|
|
10
10
|
protected decodedKeys: T;
|
|
11
11
|
constructor(decodedKeys: T);
|
|
12
|
-
use<U extends Formatted>(key: keyof T, values?: FormatObject<U> | null | number, mode?: "raw" | "decode"): string;
|
|
12
|
+
use<U extends Formatted>(key: keyof T, values?: FormatObject<U> | null | number, mode?: "raw" | "decode", needCount?: boolean): string;
|
|
13
13
|
protected formatTemplate(template: string, values: FormatObject<Formatted>): string;
|
|
14
14
|
toggleDebug(): void;
|
|
15
15
|
}
|
package/dist/lib/lang/Lang.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{pluralFrom as e}from"../pluralFrom.js";class t{isDebug=!1;decodedKeys;constructor(e){this.decodedKeys=e}use(t,r={},o="decode"){if(!t)return"...";if(this.isDebug)return t;if(!(t in this.decodedKeys))return"";let
|
|
1
|
+
import{pluralFrom as e}from"../pluralFrom.js";class t{isDebug=!1;decodedKeys;constructor(e){this.decodedKeys=e}use(t,r={},o="decode",s=!0){if(!t)return"...";if(this.isDebug)return t;if(!(t in this.decodedKeys))return"";let i=this.decodedKeys[t];if("raw"===o)return i;if(Array.isArray(i)&&null!==r){if("number"==typeof r)return e(r,i,s);"object"==typeof r&&(i=i.map((e=>this.formatTemplate(e,r))))}return"string"==typeof i&&r&&"object"==typeof r&&(i=this.formatTemplate(i,r)),i}formatTemplate(e,t){for(const[r,o]of e.matchAll(/\{(.*?)\}/g)){const s=t[o]||"";e=String(e).replace(r,s)}return e}toggleDebug(){this.isDebug=!this.isDebug}}export{t as Lang};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getHlsInstance as e}from"./utils/getHlsInstance.js";import{sendMessage as r}from"./utils/sendMessage.js";const o=async({url:o,filename:
|
|
1
|
+
import{getHlsInstance as e}from"./utils/getHlsInstance.js";import{sendMessage as r}from"./utils/sendMessage.js";const o=async({url:o,filename:n,onProgress:t,forceHls:a})=>{if(!a)try{const e=await r({url:o,filename:n,type:"convertHlsToMp3",onProgress:t});if(e instanceof ReadableStream)return e;if(e instanceof Blob)return e.stream();if("stream"in e)return e.stream();throw new Error("Invalid response")}catch(e){console.error(e)}const s=await e();let i=null,l=null,d=!1;const f=()=>{i&&(i.stopLoad(),i.destroy())};return new ReadableStream({start(e){i=new s({maxBufferHole:.5,maxBufferLength:600,maxBufferSize:6e7,fragLoadingRetryDelay:500,fragLoadingMaxRetry:20,maxFragLookUpTolerance:.25,enableWorker:!1}),l=new Audio;let r,n=null,a=0,c=0,u=0;const E=r=>{e.error(new Error(r||"HLS Error")),f()};i.on(s.Events.MANIFEST_PARSED,((e,r)=>{const o=r.levels[0]?.details;o&&(a=o.fragments.length)})),i.on(s.Events.BUFFER_CODECS,((e,o)=>{o.audio&&"audio/mp4"!==o.audio.container||(r=o.audio)})),i.on(s.Events.BUFFER_APPENDING,((e,r)=>{n=r.data})),i.on(s.Events.ERROR,((e,r)=>{if(["bufferFullError"].includes(r.details))E(r.details);else{if(r.type===s.ErrorTypes.NETWORK_ERROR){if(r.response&&(403===r.response.code||404===r.response.code))return void E(`HTTP Error ${r.response.code} (Link expired or invalid)`);if(!navigator.onLine){if(!d){d=!0,i?.stopLoad();const e=()=>{window.removeEventListener("online",e),d=!1,i?.startLoad()};window.addEventListener("online",e)}return}return r.fatal?void i?.startLoad():void 0}if(r.type===s.ErrorTypes.MEDIA_ERROR){if("bufferStalledError"===r.details)return void i?.startLoad();if(u<2)return u++,u>1&&i?.swapAudioCodec(),void i?.recoverMediaError()}r.fatal&&E(r.details)}})),i.on(s.Events.FRAG_BUFFERED,(async(o,s)=>{if(n){const o=r?n.slice(8,n.length):n;e.enqueue(o),c++,n=null}l.currentTime=Math.max(0,s.frag.start+s.frag.duration-.25);try{t&&a>0&&t(c/a)}catch(e){console.error(e)}c>=a&&(f(),e.close())})),i.loadSource(o),i.attachMedia(l)},cancel(){f(),l&&(l.pause(),l.remove())}})};export{o as convertTrackToStream};
|