@vkontakte/videoplayer-shared 1.0.30 → 1.0.31-dev.0e8d526.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.
- package/es2015.cjs.js +4 -4
- package/es2015.esm.js +4 -4
- package/es2015.umd.js +2928 -0
- package/es2018.cjs.js +4 -4
- package/es2018.esm.js +4 -4
- package/esnext.cjs.js +4 -4
- package/esnext.esm.js +4 -4
- package/evergreen.esm.js +4 -4
- package/index.d.ts +4 -1
- package/package.json +5 -3
package/evergreen.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-shared v1.0.
|
|
3
|
-
*
|
|
4
|
-
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-
|
|
2
|
+
* @vkontakte/videoplayer-shared v1.0.31-dev.0e8d526.0
|
|
3
|
+
* Tue, 12 Dec 2023 11:25:06 GMT
|
|
4
|
+
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-31/doc/
|
|
5
5
|
*/
|
|
6
|
-
const re="1.0.30";class x{subscriptions=[];unsubscribe(){const t=this.subscriptions;this.subscriptions=[],t.forEach(s=>typeof s=="function"?s():s.unsubscribe())}add(t){return this.subscriptions.push(t),this}}const w=e=>{throw new Error(`${e} is value of unexpected type`)},oe=e=>{},S=()=>{};class u{constructor(t){t&&(this._subscribe=t)}subscribe(t,s){let n;s?typeof s=="function"?n={next:s,error:S}:n={next:r=>s.next(r),error:r=>s.error?.(r)}:n={next:S,error:S};const o=typeof t=="function"?{next:r=>{try{t(r)}catch(f){n.next(f)}},error:r=>n.next(r)}:{next:r=>t.next(r),error:r=>t.error?t.error(r):n.next(r)};let i;try{i=this._subscribe(o)}catch(r){o.error?.(r)}return new x().add(()=>{switch(o.next=S,o.error=S,typeof i){case"function":i();return;case"object":i.unsubscribe();return;case"undefined":return;default:return w(i)}})}pipe(...t){return t.reduce((s,n)=>n(s),this)}_subscribe(t){}}class I extends u{keyCounter=0;subscribers=new Map;constructor(){super()}next(t){this.subscribers.forEach(s=>s.next(t))}error(t){this.subscribers.forEach(s=>s.error?.(t))}_subscribe(t){const s=this.keyCounter++;return this.subscribers.set(s,t),new x().add(()=>this.subscribers.delete(s))}}class ae{log$=new I;logs=[];log=t=>{const s={...t,timestamp:Date.now()};this.logs.push(s),this.log$.next(s)};createCustomLog(t){return(...s)=>{let n;try{n=t(...s)}catch{n={message:"error in `createCustomLog`",component:"Logger"}}this.log(n)}}createComponentLog(t){return this.createCustomLog(s=>({component:t,...s}))}getAllLogs=()=>this.logs}function ce(e,t='Assertion "value is not nullable" failed'){if(e==null)throw new Error(t)}function ue(e,t='Assertion "value is nullable" failed'){if(e!=null)throw new Error(t)}function U(e){return typeof e<"u"&&e!==null}function j(e){return e==null}const he=(e,t,s)=>new Promise((n,o)=>{t.addEventListener("abort",()=>{f(),b.remove()});const i=()=>{f(),o()},r=()=>{f(),n()},f=()=>{E&&clearTimeout(E),b.removeEventListener("load",r),b.removeEventListener("error",i)};let E;s&&(E=window.setTimeout(i,s));const b=document.createElement("script");b.addEventListener("load",r),b.addEventListener("error",i),b.src=e,document.head.appendChild(b)}),de=typeof window.performance?.now=="function"?()=>window.performance.now():()=>Date.now(),le=(e,t)=>async(...s)=>{const n=t(...s);let o=e.aborted,i;for(;!o&&!e.aborted;){const r=await n.next(i);o=r.done??!1,i=r.value}return i};var l;(function(e){e.Unknown="Unknown",e.Yandex="Yandex",e.Chrome="Chrome",e.Chromium="Chromium",e.Firefox="Firefox",e.Safari="Safari",e.Opera="Opera",e.Edge="Edge",e.Rest="Rest"})(l||(l={}));var c;(function(e){e.Unknown="Unknown",e.Android="Android",e.iPhone="iPhone",e.iPad="iPad",e.iPod="iPod",e.RestMobile="RestMobile",e.Mac="Mac",e.Desktop="Desktop"})(c||(c={}));const T=()=>{const{userAgent:e}=window.navigator,t=/yabrowser/i.test(e)?l.Yandex:void 0,s=/chrome|crios/i.test(e)?l.Chrome:void 0,n=/chromium/i.test(e)?l.Chromium:void 0,o=/firefox|fxios/i.test(e)?l.Firefox:void 0,i=/webkit|safari|khtml/i.test(e)?l.Safari:void 0,r=/opr\//i.test(e)?l.Opera:void 0,f=/edg/i.test(e)?l.Edge:void 0,E=/android/i.test(e)?c.Android:void 0,b=/iphone/i.test(e)?c.iPhone:void 0,L=/ipad/i.test(e)?c.iPad:void 0,N=/ipod/i.test(e)?c.iPod:void 0,k=/mac/i.test(e)?c.Mac:void 0,Q=/webOS|BlackBerry|IEMobile|Opera Mini/i.test(e)?c.RestMobile:void 0;return{browser:t||o||r||f||s||n||i||l.Rest,device:E||b||L||N||Q||k||c.Desktop}},fe=(e=!1)=>{const s=[c.iPhone,c.iPad,c.iPod].includes(T().device);if(!e)return s;const{userAgent:n,maxTouchPoints:o}=window.navigator;return!!(s||/macintosh/i.test(n)&&o>0)},be=()=>{const{userAgent:e}=window.navigator,t=e.match(/Version\/(\d+(\.\d+)?)/i);if(!t)return null;const s=t[1],n=parseFloat(s);return isNaN(n)?null:n},me=()=>[c.Mac,c.iPhone,c.iPad,c.iPod].includes(T().device),we=(e,{start:t=0,factor:s=2,max:n=1/0,min:o=t,random:i=0}={})=>{let r=t;return r*=s**e,r*=1+(Math.random()*i*2-i),r=Math.round(r),r=Math.min(r,n),r=Math.max(r,o),r};var a;(function(e){e[e.LOCAL_STORAGE=0]="LOCAL_STORAGE",e[e.SESSION_STORAGE=1]="SESSION_STORAGE",e[e.RUNTIME=2]="RUNTIME"})(a||(a={}));let p,m;const O=`vk-videoplayer-dummy-key-${Math.random()}`,g=()=>{if(m!==void 0)return m;try{localStorage.setItem(O,"test"),localStorage.removeItem(O),m=a.LOCAL_STORAGE}catch(e){if(e instanceof DOMException||e instanceof TypeError)try{sessionStorage.getItem(O),m=a.SESSION_STORAGE}catch(t){if(t instanceof DOMException||t instanceof TypeError)m=a.RUNTIME;else throw t}else throw e}return m===a.RUNTIME&&(p=new Map),m},G=()=>g()===a.LOCAL_STORAGE,V=e=>{const t=g();switch(t){case a.LOCAL_STORAGE:return localStorage.getItem(e)??void 0;case a.SESSION_STORAGE:return sessionStorage.getItem(e)??void 0;case a.RUNTIME:return p?.get(e);default:w(t)}},D=(e,t)=>{const s=g();switch(s){case a.LOCAL_STORAGE:try{localStorage.setItem(e,t)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case a.SESSION_STORAGE:try{sessionStorage.setItem(e,t)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case a.RUNTIME:return void p?.set(e,t);default:w(s)}},F=e=>{const t=g();switch(t){case a.LOCAL_STORAGE:return e in localStorage;case a.SESSION_STORAGE:return e in sessionStorage;case a.RUNTIME:return p?.has(e)??!1;default:return w(t),!1}},z=e=>{const t=g();switch(t){case a.LOCAL_STORAGE:return localStorage.removeItem(e);case a.SESSION_STORAGE:return sessionStorage.removeItem(e);case a.RUNTIME:return void p?.delete(e);default:w(t)}},$=()=>{const e=g();switch(e){case a.LOCAL_STORAGE:return localStorage.clear();case a.SESSION_STORAGE:return sessionStorage.clear();case a.RUNTIME:return p?.clear();default:w(e)}};var pe=Object.freeze({__proto__:null,clear:$,get:V,has:F,isPersistent:G,remove:z,set:D}),h;(function(e){e.INVARIANT="Invariant quality",e.Q_144P="144p",e.Q_240P="240p",e.Q_360P="360p",e.Q_480P="480p",e.Q_720P="720p",e.Q_1080P="1080p",e.Q_1440P="1440p",e.Q_2160P="2160p",e.Q_4320P="4320p"})(h||(h={}));const d={[h.Q_144P]:{width:256,height:144},[h.Q_240P]:{width:428,height:240},[h.Q_360P]:{width:640,height:360},[h.Q_480P]:{width:856,height:480},[h.Q_720P]:{width:1280,height:720},[h.Q_1080P]:{width:1920,height:1080},[h.Q_1440P]:{width:2560,height:1440},[h.Q_2160P]:{width:3840,height:2160},[h.Q_4320P]:{width:7680,height:4320}},ge=(e,t)=>d[e].height>d[t].height,Ee=(e,t)=>d[e].height>=d[t].height,R=(e,t)=>d[e].height<d[t].height,Se=(e,t)=>d[e].height<=d[t].height,xe=e=>e.sort((t,s)=>t===s?0:t===h.INVARIANT?1:s===h.INVARIANT?-1:R(t,s)?1:-1)[0],y=Object.keys(d).sort((e,t)=>R(e,t)?-1:1),Oe=(e,t=.02)=>[...y].find(n=>d[n].height*(1+t)>=e),Ae=({width:e,height:t})=>{const s=Math.min(e,t),n=Math.max(e,t);return y.find(o=>{const i=d[o];return i.width>=n&&i.height>=s})},_e=e=>d[e].height,M=e=>e===h.INVARIANT,ve=e=>e.every(t=>!M(t));function Pe(e){if(M(e))throw new Error("Expected exact quality")}const q=(e,t)=>{const s={};for(const n of Object.keys(t)){const o=t[n],i=e[n];Array.isArray(o)&&Array.isArray(i)?s[n]=i:typeof o=="object"&&typeof i=="object"?s[n]=q(i,o):s[n]=n in e?i:o}return s};class Ie extends I{value;constructor(t){super(),this.value=t}next(t){super.next(this.value=t)}error(t){super.error(this.value=t)}getValue(){return this.value}_subscribe(t){const s=super._subscribe(t);return t.next(this.value),s}}function Te(e){return new u(t=>{const s={};let n=Object.keys(e).length;const o=i=>r=>{i in s||n--,s[i]=r,n===0&&t.next(s)};return Object.entries(e).reduce((i,[r,f])=>i.add(f.subscribe(o(r))),new x)})}function Re(...e){return new u(t=>e.reduce((s,n)=>s.add(n.subscribe(t)),new x))}var ye=e=>new u(t=>{const s=window.setTimeout(()=>{try{t.next()}catch(n){if(t.error)t.error(n);else throw n}},e);return()=>window.clearTimeout(s)}),Me=e=>new u(t=>{const s=window.setInterval(()=>t.next(),e);return()=>window.clearInterval(s)}),Le=e=>new u(t=>{e.forEach(s=>t.next(s))}),Ne=(e,t)=>new u(s=>{const n=o=>s.next(o);return e.addEventListener(t,n),()=>e.removeEventListener(t,n)});function ke(e){return t=>new u(s=>t.subscribe(new H(s,e)))}class H{destination;size;lastValues=[];constructor(t,s){this.destination=t,this.size=s}next(t){this.lastValues.length===this.size&&this.lastValues.shift(),this.lastValues.push(t),this.destination.next(this.lastValues)}error(t){this.destination.error?.(t)}}const Y={leading:!1,trailing:!0};function Qe(e,t=Y){return s=>new u(n=>s.subscribe(new W(n,e,t)))}class W{destination;time;config;lastValue;timeout;constructor(t,s,n){this.destination=t,this.time=s,this.config=n}next(t){this.lastValue=t,U(this.timeout)?window.clearTimeout(this.timeout):this.config.leading&&this.destination.next(t),this.timeout=window.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(s){if(this.destination.error)this.destination.error(s);else throw s}this.timeout=void 0},this.time)}error(t){this.destination.error?.(t)}}const X={leading:!0,trailing:!1};function Ue(e,t=X){return s=>new u(n=>s.subscribe(new C(n,e,t)))}class C{destination;time;config;lastValue;timeout;constructor(t,s,n){this.destination=t,this.time=s,this.config=n}next(t){this.lastValue=t,j(this.timeout)&&(this.config.leading&&this.destination.next(t),this.timeout=window.setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(t){this.destination.error?.(t)}}function je(e){return t=>new u(s=>t.subscribe(new J(s,e)))}class J{destination;predicate;constructor(t,s){this.destination=t,this.predicate=s}next(t){let s;try{s=this.predicate(t)}catch(n){throw this.error(n),n}s&&this.destination.next(t)}error(t){this.destination.error?.(t)}}function Ge(e=(t,s)=>t===s){return t=>new u(s=>t.subscribe(new Z(s,e)))}const A={};class Z{destination;predicate;lastValue=A;constructor(t,s){this.destination=t,this.predicate=s}next(t){let s;try{s=this.lastValue===A||!this.predicate(this.lastValue,t),this.lastValue=t}catch(n){throw this.error(n),n}s&&this.destination.next(t)}error(t){this.destination.error?.(t)}}function B(e){return t=>new u(s=>t.subscribe(new K(s,e)))}let K=class{destination;mapper;constructor(t,s){this.destination=t,this.mapper=s}next(t){let s;try{s=this.mapper(t)}catch(n){throw this.error(n),n}this.destination.next(s)}error(t){this.destination.error?.(t)}};function De(e){return B(()=>e)}function Fe(){return e=>new u(t=>{let s=!1,n=!1;const o=e.subscribe(i=>{s||(s=!0,t.next(i)),n&&o.unsubscribe()},i=>{s=!0,t.error?.(i),n&&o.unsubscribe()});return n=!0,s&&o.unsubscribe(),o})}function ze(){return e=>new u(t=>e.subscribe(new ee(t)))}class ee{destination;last;hasLast=!1;constructor(t){this.destination=t}next(t){const s=this.last;if(this.last=t,!this.hasLast){this.hasLast=!0;return}this.destination.next([s,t])}error(t){this.destination.error?.(t)}}function $e(e){return t=>new u(s=>t.subscribe(new te(s,e)))}class te{destination;effect;constructor(t,s){this.destination=t,this.effect=s}next(t){try{this.effect(t)}catch(s){throw this.error(s),s}this.destination.next(t)}error(t){this.destination.error?.(t)}}var _;(function(e){e.NETWORK="network",e.VIDEO_PIPELINE="video_pipeline",e.EXTERNAL_API="external_api",e.PARSER="parser",e.DOM="dom",e.WTF="wtf"})(_||(_={}));var v;(function(e){e.Armenian="58",e.Azerbaijani="57",e.Belarusian="114",e.English="3",e.Kazakh="97",e.Portuguese="73",e.Russian="0",e.Spanish="4",e.Ukrainian="1",e.Uzbek="65",e.Vietnamese="75"})(v||(v={}));const se="vk.com",qe=async(e,t,s)=>{const n=new URL(`https://${se}/js/lang-pack.js`);n.searchParams.set("format","json"),n.searchParams.set("name",t),e!==void 0&&n.searchParams.set("lang",e);const i=await(await fetch(n.toString())).json();return ne(i,s)},ne=(e,t)=>Object.fromEntries(Object.entries(e.keys).map(([s,n])=>[s.substring(`${t}_`.length),ie(n)])),ie=e=>Array.isArray(e)?e[0]:e;var P;(function(e){e.RU="ru",e.EN="en"})(P||(P={}));export{l as CurrentClientBrowser,c as CurrentClientDevice,_ as ErrorCategory,P as InterfaceLanguage,ae as Logger,u as Observable,I as Subject,x as Subscription,re as VERSION,v as VKNumericLanguage,Ie as ValueSubject,h as VideoQuality,le as abortable,he as addScript,ve as areQualitiesExact,w as assertNever,ce as assertNonNullable,ue as assertNullable,Pe as assertQualityIsExact,ke as buffer,oe as checkNever,Te as combine,Qe as debounce,q as fillWithDefault,je as filter,Ge as filterChanged,Ne as fromEvent,T as getCurrentBrowser,we as getExponentialDelay,xe as getHighestQuality,be as getIOSVersion,Me as interval,ge as isHigher,Ee as isHigherOrEqual,fe as isIOS,M as isInvariantQuality,R as isLower,Se as isLowerOrEqual,me as isMacLike,U as isNonNullable,j as isNullable,qe as loadVKLangPack,B as map,De as mapTo,Re as merge,S as noop,de as now,Le as observableFrom,Fe as once,ze as pairwise,pe as safeStorage,$e as tap,Ue as throttle,ye as timeout,Oe as videoHeightToQuality,_e as videoQualityToHeight,Ae as videoSizeToQuality};
|
|
6
|
+
const rt="1.0.31-dev.0e8d526.0";class x{subscriptions=[];unsubscribe(){const e=this.subscriptions;this.subscriptions=[],e.forEach(s=>typeof s=="function"?s():s.unsubscribe())}add(e){return this.subscriptions.push(e),this}}const m=t=>{throw new Error(`${t} is value of unexpected type`)},ot=t=>{},S=()=>{};class u{constructor(e){e&&(this._subscribe=e)}subscribe(e,s){let n;s?typeof s=="function"?n={next:s,error:S}:n={next:r=>s.next(r),error:r=>s.error?.(r)}:n={next:S,error:S};const o=typeof e=="function"?{next:r=>{try{e(r)}catch(f){n.next(f)}},error:r=>n.next(r)}:{next:r=>e.next(r),error:r=>e.error?e.error(r):n.next(r)};let i;try{i=this._subscribe(o)}catch(r){o.error?.(r)}return new x().add(()=>{switch(o.next=S,o.error=S,typeof i){case"function":i();return;case"object":i.unsubscribe();return;case"undefined":return;default:return m(i)}})}pipe(...e){return e.reduce((s,n)=>n(s),this)}_subscribe(e){}}class I extends u{keyCounter=0;subscribers=new Map;constructor(){super()}next(e){this.subscribers.forEach(s=>s.next(e))}error(e){this.subscribers.forEach(s=>s.error?.(e))}_subscribe(e){const s=this.keyCounter++;return this.subscribers.set(s,e),new x().add(()=>this.subscribers.delete(s))}}class at{log$=new I;logs=[];log=e=>{const s={...e,timestamp:Date.now()};this.logs.push(s),this.log$.next(s)};createCustomLog(e){return(...s)=>{let n;try{n=e(...s)}catch{n={message:"error in `createCustomLog`",component:"Logger"}}this.log(n)}}createComponentLog(e){return this.createCustomLog(s=>({component:e,...s}))}getAllLogs=()=>this.logs}function ct(t,e='Assertion "value is not nullable" failed'){if(t==null)throw new Error(e)}function ut(t,e='Assertion "value is nullable" failed'){if(t!=null)throw new Error(e)}function U(t){return typeof t<"u"&&t!==null}function j(t){return t==null}function ht(t,e){if(!t?.length)throw new Error(e)}function dt(t,e){if(t?.length)throw new Error(e)}const lt=(t,e,s)=>new Promise((n,o)=>{e.addEventListener("abort",()=>{f(),b.remove()});const i=()=>{f(),o()},r=()=>{f(),n()},f=()=>{E&&clearTimeout(E),b.removeEventListener("load",r),b.removeEventListener("error",i)};let E;s&&(E=window.setTimeout(i,s));const b=document.createElement("script");b.addEventListener("load",r),b.addEventListener("error",i),b.src=t,document.head.appendChild(b)}),ft=typeof window.performance?.now=="function"?()=>window.performance.now():()=>Date.now(),bt=(t,e)=>async(...s)=>{const n=e(...s);let o=t.aborted,i;for(;!o&&!t.aborted;){const r=await n.next(i);o=r.done??!1,i=r.value}return i};var l;(function(t){t.Unknown="Unknown",t.Yandex="Yandex",t.Chrome="Chrome",t.Chromium="Chromium",t.Firefox="Firefox",t.Safari="Safari",t.Opera="Opera",t.Edge="Edge",t.Rest="Rest"})(l||(l={}));var c;(function(t){t.Unknown="Unknown",t.Android="Android",t.iPhone="iPhone",t.iPad="iPad",t.iPod="iPod",t.RestMobile="RestMobile",t.Mac="Mac",t.Desktop="Desktop"})(c||(c={}));const T=()=>{const{userAgent:t}=window.navigator,e=/yabrowser/i.test(t)?l.Yandex:void 0,s=/chrome|crios/i.test(t)?l.Chrome:void 0,n=/chromium/i.test(t)?l.Chromium:void 0,o=/firefox|fxios/i.test(t)?l.Firefox:void 0,i=/webkit|safari|khtml/i.test(t)?l.Safari:void 0,r=/opr\//i.test(t)?l.Opera:void 0,f=/edg/i.test(t)?l.Edge:void 0,E=/android/i.test(t)?c.Android:void 0,b=/iphone/i.test(t)?c.iPhone:void 0,L=/ipad/i.test(t)?c.iPad:void 0,N=/ipod/i.test(t)?c.iPod:void 0,k=/mac/i.test(t)?c.Mac:void 0,Q=/webOS|BlackBerry|IEMobile|Opera Mini/i.test(t)?c.RestMobile:void 0;return{browser:e||o||r||f||s||n||i||l.Rest,device:E||b||L||N||Q||k||c.Desktop}},wt=(t=!1)=>{const s=[c.iPhone,c.iPad,c.iPod].includes(T().device);if(!t)return s;const{userAgent:n,maxTouchPoints:o}=window.navigator;return!!(s||/macintosh/i.test(n)&&o>0)},mt=()=>{const{userAgent:t}=window.navigator,e=t.match(/Version\/(\d+(\.\d+)?)/i);if(!e)return null;const s=e[1],n=parseFloat(s);return isNaN(n)?null:n},pt=()=>[c.Mac,c.iPhone,c.iPad,c.iPod].includes(T().device),gt=(t,{start:e=0,factor:s=2,max:n=1/0,min:o=e,random:i=0}={})=>{let r=e;return r*=s**t,r*=1+(Math.random()*i*2-i),r=Math.round(r),r=Math.min(r,n),r=Math.max(r,o),r};var a;(function(t){t[t.LOCAL_STORAGE=0]="LOCAL_STORAGE",t[t.SESSION_STORAGE=1]="SESSION_STORAGE",t[t.RUNTIME=2]="RUNTIME"})(a||(a={}));let p,w;const O=`vk-videoplayer-dummy-key-${Math.random()}`,g=()=>{if(w!==void 0)return w;try{localStorage.setItem(O,"test"),localStorage.removeItem(O),w=a.LOCAL_STORAGE}catch(t){if(t instanceof DOMException||t instanceof TypeError)try{sessionStorage.getItem(O),w=a.SESSION_STORAGE}catch(e){if(e instanceof DOMException||e instanceof TypeError)w=a.RUNTIME;else throw e}else throw t}return w===a.RUNTIME&&(p=new Map),w},G=()=>g()===a.LOCAL_STORAGE,V=t=>{const e=g();switch(e){case a.LOCAL_STORAGE:return localStorage.getItem(t)??void 0;case a.SESSION_STORAGE:return sessionStorage.getItem(t)??void 0;case a.RUNTIME:return p?.get(t);default:m(e)}},D=(t,e)=>{const s=g();switch(s){case a.LOCAL_STORAGE:try{localStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case a.SESSION_STORAGE:try{sessionStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case a.RUNTIME:return void p?.set(t,e);default:m(s)}},F=t=>{const e=g();switch(e){case a.LOCAL_STORAGE:return t in localStorage;case a.SESSION_STORAGE:return t in sessionStorage;case a.RUNTIME:return p?.has(t)??!1;default:return m(e),!1}},z=t=>{const e=g();switch(e){case a.LOCAL_STORAGE:return localStorage.removeItem(t);case a.SESSION_STORAGE:return sessionStorage.removeItem(t);case a.RUNTIME:return void p?.delete(t);default:m(e)}},$=()=>{const t=g();switch(t){case a.LOCAL_STORAGE:return localStorage.clear();case a.SESSION_STORAGE:return sessionStorage.clear();case a.RUNTIME:return p?.clear();default:m(t)}};var Et=Object.freeze({__proto__:null,clear:$,get:V,has:F,isPersistent:G,remove:z,set:D}),h;(function(t){t.INVARIANT="Invariant quality",t.Q_144P="144p",t.Q_240P="240p",t.Q_360P="360p",t.Q_480P="480p",t.Q_720P="720p",t.Q_1080P="1080p",t.Q_1440P="1440p",t.Q_2160P="2160p",t.Q_4320P="4320p"})(h||(h={}));const d={[h.Q_144P]:{width:256,height:144},[h.Q_240P]:{width:428,height:240},[h.Q_360P]:{width:640,height:360},[h.Q_480P]:{width:856,height:480},[h.Q_720P]:{width:1280,height:720},[h.Q_1080P]:{width:1920,height:1080},[h.Q_1440P]:{width:2560,height:1440},[h.Q_2160P]:{width:3840,height:2160},[h.Q_4320P]:{width:7680,height:4320}},St=(t,e)=>d[t].height>d[e].height,xt=(t,e)=>d[t].height>=d[e].height,R=(t,e)=>d[t].height<d[e].height,Ot=(t,e)=>d[t].height<=d[e].height,At=t=>t.sort((e,s)=>e===s?0:e===h.INVARIANT?1:s===h.INVARIANT?-1:R(e,s)?1:-1)[0],y=Object.keys(d).sort((t,e)=>R(t,e)?-1:1),vt=(t,e=.02)=>[...y].find(n=>d[n].height*(1+e)>=t),_t=({width:t,height:e})=>{const s=Math.min(t,e),n=Math.max(t,e);return y.find(o=>{const i=d[o];return i.width>=n&&i.height>=s})},Pt=t=>d[t].height,M=t=>t===h.INVARIANT,It=t=>t.every(e=>!M(e));function Tt(t){if(M(t))throw new Error("Expected exact quality")}const q=(t,e)=>{const s={};for(const n of Object.keys(e)){const o=e[n],i=t[n];Array.isArray(o)&&Array.isArray(i)?s[n]=i:typeof o=="object"&&typeof i=="object"?s[n]=q(i,o):s[n]=n in t?i:o}return s};class Rt extends I{value;constructor(e){super(),this.value=e}next(e){super.next(this.value=e)}error(e){super.error(this.value=e)}getValue(){return this.value}_subscribe(e){const s=super._subscribe(e);return e.next(this.value),s}}function yt(t){return new u(e=>{const s={};let n=Object.keys(t).length;const o=i=>r=>{i in s||n--,s[i]=r,n===0&&e.next(s)};return Object.entries(t).reduce((i,[r,f])=>i.add(f.subscribe(o(r))),new x)})}function Mt(...t){return new u(e=>t.reduce((s,n)=>s.add(n.subscribe(e)),new x))}var Lt=t=>new u(e=>{const s=window.setTimeout(()=>{try{e.next()}catch(n){if(e.error)e.error(n);else throw n}},t);return()=>window.clearTimeout(s)}),Nt=t=>new u(e=>{const s=window.setInterval(()=>e.next(),t);return()=>window.clearInterval(s)}),kt=t=>new u(e=>{t.forEach(s=>e.next(s))}),Qt=(t,e)=>new u(s=>{const n=o=>s.next(o);return t.addEventListener(e,n),()=>t.removeEventListener(e,n)});function Ut(t){return e=>new u(s=>e.subscribe(new H(s,t)))}class H{destination;size;lastValues=[];constructor(e,s){this.destination=e,this.size=s}next(e){this.lastValues.length===this.size&&this.lastValues.shift(),this.lastValues.push(e),this.destination.next(this.lastValues)}error(e){this.destination.error?.(e)}}const Y={leading:!1,trailing:!0};function jt(t,e=Y){return s=>new u(n=>s.subscribe(new W(n,t,e)))}class W{destination;time;config;lastValue;timeout;constructor(e,s,n){this.destination=e,this.time=s,this.config=n}next(e){this.lastValue=e,U(this.timeout)?window.clearTimeout(this.timeout):this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(s){if(this.destination.error)this.destination.error(s);else throw s}this.timeout=void 0},this.time)}error(e){this.destination.error?.(e)}}const X={leading:!0,trailing:!1};function Gt(t,e=X){return s=>new u(n=>s.subscribe(new C(n,t,e)))}class C{destination;time;config;lastValue;timeout;constructor(e,s,n){this.destination=e,this.time=s,this.config=n}next(e){this.lastValue=e,j(this.timeout)&&(this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(e){this.destination.error?.(e)}}function Vt(t){return e=>new u(s=>e.subscribe(new J(s,t)))}class J{destination;predicate;constructor(e,s){this.destination=e,this.predicate=s}next(e){let s;try{s=this.predicate(e)}catch(n){throw this.error(n),n}s&&this.destination.next(e)}error(e){this.destination.error?.(e)}}function Dt(t=(e,s)=>e===s){return e=>new u(s=>e.subscribe(new Z(s,t)))}const A={};class Z{destination;predicate;lastValue=A;constructor(e,s){this.destination=e,this.predicate=s}next(e){let s;try{s=this.lastValue===A||!this.predicate(this.lastValue,e),this.lastValue=e}catch(n){throw this.error(n),n}s&&this.destination.next(e)}error(e){this.destination.error?.(e)}}function B(t){return e=>new u(s=>e.subscribe(new K(s,t)))}let K=class{destination;mapper;constructor(e,s){this.destination=e,this.mapper=s}next(e){let s;try{s=this.mapper(e)}catch(n){throw this.error(n),n}this.destination.next(s)}error(e){this.destination.error?.(e)}};function zt(t){return B(()=>t)}function $t(){return t=>new u(e=>{let s=!1,n=!1;const o=t.subscribe(i=>{s||(s=!0,e.next(i)),n&&o.unsubscribe()},i=>{s=!0,e.error?.(i),n&&o.unsubscribe()});return n=!0,s&&o.unsubscribe(),o})}function qt(){return t=>new u(e=>t.subscribe(new tt(e)))}class tt{destination;last;hasLast=!1;constructor(e){this.destination=e}next(e){const s=this.last;if(this.last=e,!this.hasLast){this.hasLast=!0;return}this.destination.next([s,e])}error(e){this.destination.error?.(e)}}function Ht(t){return e=>new u(s=>e.subscribe(new et(s,t)))}class et{destination;effect;constructor(e,s){this.destination=e,this.effect=s}next(e){try{this.effect(e)}catch(s){throw this.error(s),s}this.destination.next(e)}error(e){this.destination.error?.(e)}}var v;(function(t){t.NETWORK="network",t.VIDEO_PIPELINE="video_pipeline",t.EXTERNAL_API="external_api",t.PARSER="parser",t.DOM="dom",t.WTF="wtf"})(v||(v={}));var _;(function(t){t.Armenian="58",t.Azerbaijani="57",t.Belarusian="114",t.English="3",t.Kazakh="97",t.Portuguese="73",t.Russian="0",t.Spanish="4",t.Ukrainian="1",t.Uzbek="65",t.Vietnamese="75"})(_||(_={}));const st="vk.com",Yt=async(t,e,s)=>{const n=new URL(`https://${st}/js/lang-pack.js`);n.searchParams.set("format","json"),n.searchParams.set("name",e),t!==void 0&&n.searchParams.set("lang",t);const i=await(await fetch(n.toString())).json();return nt(i,s)},nt=(t,e)=>Object.fromEntries(Object.entries(t.keys).map(([s,n])=>[s.substring(`${e}_`.length),it(n)])),it=t=>Array.isArray(t)?t[0]:t;var P;(function(t){t.RU="ru",t.EN="en"})(P||(P={}));export{l as CurrentClientBrowser,c as CurrentClientDevice,v as ErrorCategory,P as InterfaceLanguage,at as Logger,u as Observable,I as Subject,x as Subscription,rt as VERSION,_ as VKNumericLanguage,Rt as ValueSubject,h as VideoQuality,bt as abortable,lt as addScript,It as areQualitiesExact,dt as assertEmptyArray,m as assertNever,ct as assertNonNullable,ht as assertNotEmptyArray,ut as assertNullable,Tt as assertQualityIsExact,Ut as buffer,ot as checkNever,yt as combine,jt as debounce,q as fillWithDefault,Vt as filter,Dt as filterChanged,Qt as fromEvent,T as getCurrentBrowser,gt as getExponentialDelay,At as getHighestQuality,mt as getIOSVersion,Nt as interval,St as isHigher,xt as isHigherOrEqual,wt as isIOS,M as isInvariantQuality,R as isLower,Ot as isLowerOrEqual,pt as isMacLike,U as isNonNullable,j as isNullable,Yt as loadVKLangPack,B as map,zt as mapTo,Mt as merge,S as noop,ft as now,kt as observableFrom,$t as once,qt as pairwise,Et as safeStorage,Ht as tap,Gt as throttle,Lt as timeout,vt as videoHeightToQuality,Pt as videoQualityToHeight,_t as videoSizeToQuality};
|
package/index.d.ts
CHANGED
|
@@ -95,6 +95,9 @@ declare function isNonNullable<T>(value: T): value is NonNullable<T>;
|
|
|
95
95
|
declare function isNullable<T extends INullable = INullable>(value: unknown): value is T;
|
|
96
96
|
type INullable = null | undefined;
|
|
97
97
|
|
|
98
|
+
declare function assertNotEmptyArray<T extends Array<unknown>>(value: T, failMessage: string): void;
|
|
99
|
+
declare function assertEmptyArray<T extends Array<unknown>>(value: T, failMessage: string): void;
|
|
100
|
+
|
|
98
101
|
declare const addScript: (scriptSrc: string, abortSignal: AbortSignal, timeout?: number) => Promise<void>;
|
|
99
102
|
|
|
100
103
|
type Seconds = number;
|
|
@@ -373,4 +376,4 @@ declare enum VKNumericLanguage {
|
|
|
373
376
|
type VKLanguage = VKNumericLanguage | string;
|
|
374
377
|
declare const loadVKLangPack: <T extends StringRecord>(language: VKLanguage, packName: string, packPrefix: string) => Promise<T>;
|
|
375
378
|
|
|
376
|
-
export { Byte, CurrentClientBrowser, CurrentClientDevice, ErrorCategory, ExactVideoQuality, ExponentialBackoffConfig, IComponentLogEntry, IComponentLogger, ICurrentBrowserInfo, IEmitter, IError, IListener, ILogEntry, ILogInputEntry, ILogger, IObservable, IOperator, IRange, IRectangle, ISubject, ISubscription, IUnsubscriber, IValue, IValueObservable, IValueSubject, IWarning, InterfaceLanguage, Kbps, Logger, Mbps, Milliseconds, Observable, Percentage, QualityLimits, RecursivePartial, Seconds, StringRecord, Subject, Subscription, VERSION, VKLanguage, VKNumericLanguage, ValueSubject, VideoQuality, abortable, addScript, areQualitiesExact, assertNever, assertNonNullable, assertNullable, assertQualityIsExact, bps, buffer, checkNever, combine, debounce, fillWithDefault, filter, filterChanged, _default as fromEvent, getCurrentBrowser, getExponentialDelay, getHighestQuality, getIOSVersion, _default$2 as interval, isHigher, isHigherOrEqual, isIOS, isInvariantQuality, isLower, isLowerOrEqual, isMacLike, isNonNullable, isNullable, loadVKLangPack, map, mapTo, merge, noop, now, _default$1 as observableFrom, once, pairwise, iframeSafeStorage_d as safeStorage, tap, throttle, _default$3 as timeout, videoHeightToQuality, videoQualityToHeight, videoSizeToQuality };
|
|
379
|
+
export { Byte, CurrentClientBrowser, CurrentClientDevice, ErrorCategory, ExactVideoQuality, ExponentialBackoffConfig, IComponentLogEntry, IComponentLogger, ICurrentBrowserInfo, IEmitter, IError, IListener, ILogEntry, ILogInputEntry, ILogger, IObservable, IOperator, IRange, IRectangle, ISubject, ISubscription, IUnsubscriber, IValue, IValueObservable, IValueSubject, IWarning, InterfaceLanguage, Kbps, Logger, Mbps, Milliseconds, Observable, Percentage, QualityLimits, RecursivePartial, Seconds, StringRecord, Subject, Subscription, VERSION, VKLanguage, VKNumericLanguage, ValueSubject, VideoQuality, abortable, addScript, areQualitiesExact, assertEmptyArray, assertNever, assertNonNullable, assertNotEmptyArray, assertNullable, assertQualityIsExact, bps, buffer, checkNever, combine, debounce, fillWithDefault, filter, filterChanged, _default as fromEvent, getCurrentBrowser, getExponentialDelay, getHighestQuality, getIOSVersion, _default$2 as interval, isHigher, isHigherOrEqual, isIOS, isInvariantQuality, isLower, isLowerOrEqual, isMacLike, isNonNullable, isNullable, loadVKLangPack, map, mapTo, merge, noop, now, _default$1 as observableFrom, once, pairwise, iframeSafeStorage_d as safeStorage, tap, throttle, _default$3 as timeout, videoHeightToQuality, videoQualityToHeight, videoSizeToQuality };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vkontakte/videoplayer-shared",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.31-dev.0e8d526.0",
|
|
4
4
|
"author": "vk.com",
|
|
5
5
|
"description": "Shared code for vk.com videoplayer",
|
|
6
6
|
"homepage": "https://vk.com",
|
|
@@ -41,12 +41,14 @@
|
|
|
41
41
|
"./es2018.esm.js": "./es2018.esm.js",
|
|
42
42
|
"./es2018.cjs.js": "./es2018.cjs.js",
|
|
43
43
|
"./es2015.esm.js": "./es2015.esm.js",
|
|
44
|
-
"./es2015.cjs.js": "./es2015.cjs.js"
|
|
44
|
+
"./es2015.cjs.js": "./es2015.cjs.js",
|
|
45
|
+
"./es2015.umd.js": "./es2015.umd.js"
|
|
45
46
|
},
|
|
46
47
|
"files": [
|
|
47
48
|
"*.cjs.js",
|
|
48
49
|
"*.esm.js",
|
|
49
|
-
"**/*.d.ts"
|
|
50
|
+
"**/*.d.ts",
|
|
51
|
+
"*.umd.js"
|
|
50
52
|
],
|
|
51
53
|
"dependencies": {}
|
|
52
54
|
}
|