@vkontakte/videoplayer-shared 1.0.62-dev.2bd92e6d.0 → 1.0.62-dev.4cc026f5.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/evergreen.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * @vkontakte/videoplayer-shared v1.0.62-dev.2bd92e6d.0
3
- * Tue, 17 Jun 2025 15:04:21 GMT
2
+ * @vkontakte/videoplayer-shared v1.0.62-dev.4cc026f5.0
3
+ * Mon, 23 Jun 2025 12:57:13 GMT
4
4
  * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-62/doc/
5
5
  */
6
- var Ne=Object.defineProperty;var le=(t,e)=>{for(var r in e)Ne(t,r,{get:e[r],enumerable:!0})};var Ce="1.0.62-dev.2bd92e6d.0";var d=class{constructor(){this.subscriptions=[]}unsubscribe(){let e=this.subscriptions;this.subscriptions=[],e.forEach(r=>{typeof r=="function"?r():r.unsubscribe()})}add(e){return this.subscriptions.push(e),this}};var T=t=>{throw new Error(`${t} is value of unexpected type`)},Ve=t=>{};var g=()=>{};var l=class{constructor(e){e&&(this._subscribe=e)}subscribe(e,r){let n;r?typeof r=="function"?n={next:r,error:g}:n={next:i=>r.next(i),error:i=>r.error?.(i)}:n={next:g,error:g};let o=typeof e=="function"?{next:i=>{try{let a=e(i);a instanceof Promise&&a.catch(u=>n.next(u))}catch(a){n.next(a)}},error:i=>n.next(i)}:{next:i=>e.next(i),error:i=>e.error?e.error(i):n.next(i)},s;try{s=this._subscribe(o)}catch(i){o.error?.(i)}return new d().add(()=>{switch(o.next=g,o.error=g,typeof s){case"function":s();return;case"object":s.unsubscribe();return;case"undefined":return;default:return T(s)}})}pipe(...e){return e.reduce((r,n)=>n(r),this)}_subscribe(e){}};var y=class extends l{constructor(){super();this.keyCounter=0;this.subscribers=new Map}next(r){this.subscribers.forEach(n=>n.next(r))}error(r){this.subscribers.forEach(n=>n.error?.(r))}_subscribe(r){let n=this.keyCounter++;return this.subscribers.set(n,r),new d().add(()=>this.subscribers.delete(n))}};var j=class{constructor(){this.log$=new y;this.logs=[];this.log=e=>{let r={...e,timestamp:Date.now()};this.logs.push(r),this.log$.next(r)};this.getAllLogs=()=>this.logs}createCustomLog(e){return(...r)=>{let n;try{n=e(...r)}catch{n={message:"error in `createCustomLog`",component:"Logger"}}this.log(n)}}createComponentLog(e){return this.createCustomLog(r=>({component:e,...r}))}};function Me(t,e='Assertion "value is not nullable" failed'){if(t==null)throw new Error(e)}function _e(t,e='Assertion "value is nullable" failed'){if(t!=null)throw new Error(e)}function h(t){return typeof t<"u"&&t!==null}function E(t){return t==null}function Qe(t,e){if(!t?.length)throw new Error(e)}function De(t,e){if(t?.length)throw new Error(e)}var Ue=(t,e,r)=>new Promise((n,o)=>{e.addEventListener("abort",()=>{a(),m.remove()});let s=()=>{a(),o("error")},i=()=>{a(),n()},a=()=>{u&&clearTimeout(u),m.removeEventListener("load",i),m.removeEventListener("error",s)},u;r&&(u=window.setTimeout(()=>{a(),o("timeout")},r));let m=document.createElement("script");m.addEventListener("load",i),m.addEventListener("error",s),m.src=t,document.head.appendChild(m)});var je=typeof window.performance?.now=="function"?()=>window.performance.now():()=>Date.now();var ze=(t,e)=>async(...r)=>{let n=e(...r),o=t.aborted,s;for(;!o&&!t.aborted;)try{let i=await n.next(s);o=i.done??!1,s=i.value}catch(i){await n.throw(i)}return s};var We=(t,{start:e=0,factor:r=2,max:n=1/0,min:o=e,random:s=0}={})=>{let i=e;return i*=r**t,i*=1+(Math.random()*s*2-s),i=Math.round(i),i=Math.min(i,n),i=Math.max(i,o),i};var ce={};le(ce,{clear:()=>He,get:()=>Ge,has:()=>Be,isPersistent:()=>Fe,remove:()=>qe,set:()=>Ke});var O,x,z=`vk-videoplayer-dummy-key-${Math.random()}`,w=()=>{if(x!==void 0)return x;try{localStorage.setItem(z,"test"),localStorage.removeItem(z),x=0}catch(t){if(t instanceof DOMException||t instanceof TypeError)try{sessionStorage.getItem(z),x=1}catch(e){if(e instanceof DOMException||e instanceof TypeError)x=2;else throw e}else throw t}return x===2&&(O=new Map),x},Fe=()=>w()===0,Ge=t=>{let e=w();switch(e){case 0:return localStorage.getItem(t)??void 0;case 1:return sessionStorage.getItem(t)??void 0;case 2:return O?.get(t);default:T(e)}},Ke=(t,e)=>{let r=w();switch(r){case 0:try{localStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 1:try{sessionStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 2:O?.set(t,e);return;default:T(r)}},Be=t=>{let e=w();switch(e){case 0:return t in localStorage;case 1:return t in sessionStorage;case 2:return O?.has(t)??!1;default:return T(e),!1}},qe=t=>{let e=w();switch(e){case 0:return localStorage.removeItem(t);case 1:return sessionStorage.removeItem(t);case 2:O?.delete(t);return;default:T(e)}},He=()=>{let t=w();switch(t){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return O?.clear();default:T(t)}};var $e=()=>{let t,e=[];try{t=window.self!==window.top}catch(r){r instanceof DOMException&&r.name==="SecurityError"?t=!0:(t=!1,console.error(r))}try{window.location.ancestorOrigins&&(e=[...window.location.ancestorOrigins])}catch(r){console.error(r)}try{!e.length&&document.referrer&&(e=[new URL(document.referrer).origin])}catch(r){console.error(r)}return{isEmbed:t,origins:e,topOrigin:e.at(-1),immediateOrigin:e.at(0)}};var W=(c=>(c.INVARIANT="Invariant quality",c.Q_144P="144p",c.Q_240P="240p",c.Q_360P="360p",c.Q_480P="480p",c.Q_576P="576p",c.Q_720P="720p",c.Q_1080P="1080p",c.Q_1440P="1440p",c.Q_2160P="2160p",c.Q_4320P="4320p",c))(W||{});var b={"144p":{width:256,height:144},"240p":{width:428,height:240},"360p":{width:640,height:360},"480p":{width:856,height:480},"576p":{width:1024,height:576},"720p":{width:1280,height:720},"1080p":{width:1920,height:1080},"1440p":{width:2560,height:1440},"2160p":{width:3840,height:2160},"4320p":{width:7680,height:4320}},Ye=(t,e)=>b[t].height>b[e].height,Xe=(t,e)=>b[t].height>=b[e].height,F=(t,e)=>b[t].height<b[e].height,Je=(t,e)=>b[t].height<=b[e].height,Ze=t=>t.sort((e,r)=>e===r?0:e==="Invariant quality"?1:r==="Invariant quality"?-1:F(e,r)?1:-1)[0],pe=Object.keys(b).sort((t,e)=>F(t,e)?-1:1),et=(t,e=.02)=>[...pe].find(n=>b[n].height*(1+e)>=t),tt=({width:t,height:e})=>{let r=Math.min(t,e),n=Math.max(t,e);return pe.find(o=>{let s=b[o];return s.width>=n&&s.height>=r})},rt=t=>b[t].height,G=t=>t==="Invariant quality",nt=t=>t.every(e=>!G(e));function ot(t){if(G(t))throw new Error("Expected exact quality")}var it=(t,e)=>{let r={};for(let n of Object.keys(e)){let o=e[n],s=t[n];Array.isArray(o)&&Array.isArray(s)?r[n]=s:typeof o=="object"&&typeof s=="object"?r[n]=it(s,o):r[n]=n in t?s:o}return r};var sr=t=>{let e="";return t>=3600&&(e+=Math.floor(t/3600)+"h",t=t%3600),t>=60&&(e+=Math.floor(t/60)+"m",t=t%60),t>0&&(e+=Math.floor(t)+"s"),e};function K(t,e=0,r){let n,o,s,i,a,u,m=0,ne=!1,c=!1,D=!0,oe=!e&&e!==0&&typeof window.requestAnimationFrame=="function";r&&(ne=!!r.leading,c="maxWait"in r,s=r?.maxWait?Math.max(+r?.maxWait||0,e):s,D="trailing"in r?!!r.trailing:D);function U(p){let f=n,v=o;return n=o=void 0,m=p,i=t.apply(v,f),i}function A(p,f){return oe?(a&&window.cancelAnimationFrame(a),window.requestAnimationFrame(p)):setTimeout(p,f)}function Se(p){if(oe){window.cancelAnimationFrame(p);return}clearTimeout(p)}function Ae(p){return m=p,a=A(R,e),ne?U(p):i}function Re(p){let f=p-u,v=p-m,ae=e-f;return c?Math.min(ae,s-v):ae}function ie(p){let f=p-u,v=p-m;return u===void 0||f>=e||f<0||c&&v>=s}function R(){let p=Date.now();if(ie(p))return se(p);a=A(R,Re(p))}function se(p){return a=void 0,D&&n?U(p):(n=o=void 0,i)}function ke(){a!==void 0&&Se(a),m=0,n=u=o=a=void 0}function Pe(){return a===void 0?i:se(Date.now())}function Le(){return a!==void 0}function k(...p){let f=Date.now(),v=ie(f);if(n=p,o=this,u=f,v){if(a===void 0)return Ae(u);if(c)return a=A(R,e),U(u)}return a===void 0&&(a=A(R,e)),i}return k.cancel=ke,k.flush=Pe,k.pending=Le,k}var B=(t,e=0,r)=>K(t,e,{...{leading:!0,trailing:!0},...r,maxWait:e});var P=(t,e)=>{if(t===null||typeof t!="object")return t;let r=Array.isArray(t)?[]:{};for(let n in t){if(typeof e=="function"){let o=e(t[n],n,t,r);if(o!==void 0){r[n]=o;continue}}typeof t[n]=="object"?r[n]=P(t[n],e):r[n]=t[n]}return r};var st=t=>P(t);var at=300,lt=(t,e=at)=>new l(r=>{let{width:n,height:o}=t.getBoundingClientRect();if(r.next({width:n,height:o}),!window.ResizeObserver)return;let s=new ResizeObserver(B(i=>{let a=i[0];if(!a)return;let u,m;a.contentBoxSize&&a.contentBoxSize[0]?(m=a.contentBoxSize[0].blockSize,u=a.contentBoxSize[0].inlineSize):a.contentRect&&(u=a.contentRect.width,m=a.contentRect.height),h(u)&&h(m)&&r.next({width:u,height:m})},e));return s.observe(t),()=>s.disconnect()});var L=(t,e=6,r=".")=>{let n={};for(let o in t)if(!(!t.hasOwnProperty(o)||t[o]instanceof HTMLElement||!e))if(typeof t[o]=="object"&&t[o]!==null){let s=L(t[o],e-1);for(let i in s)s.hasOwnProperty(i)&&(n[o+r+i]=s[i])}else n[o]=t[o];return n};var ct=t=>{t.removeAttribute("src"),t.load()};var vr=t=>{let e;try{e=new URL(t)}catch{return!1}return e.protocol==="https:"};var xr=t=>{try{return new URL(t)}catch{return null}};var pt=t=>e=>r=>{let n=typeof r=="object";r==null||n&&!Object.keys(r).length||t(e,n?L(r):{value:r})},N=(t={})=>{let e=n=>{let o=n;return n===void 0?o="undefined":n===null?o="null":(typeof n=="number"||typeof n=="boolean")&&(o=n.toString()),o},r={};for(let n in t)Array.isArray(t[n])?r[n]=t[n].map(e):r[n]=e(t[n]);return r};var I=class t{constructor({name:e,getParentContext:r}){this.dynamicImportTimeout=5e3;this.childTracers=[];if(t.dynamicImportStatus==="failed")return this;t.dynamicImportStatus==="not_started"&&(t.dynamicImportPromise=this.loadOpentelemetry());let n=Date.now();this.initPromise=t.dynamicImportPromise.then(()=>this.init({name:e,getParentContext:r},n))}static{this.dynamicImportStatus="not_started"}init({name:e,getParentContext:r},n){this.span=t.rootTracer.startSpan(e,{startTime:n},r?.()),this.context=t.dynamicImports.opentelemetryApi.trace.setSpan(t.dynamicImports.opentelemetryApi.context.active(),this.span)}async loadOpentelemetry(){if(t.dynamicImportStatus==="not_started"){t.dynamicImportStatus="in_progress";try{let e=new Promise((i,a)=>setTimeout(a,this.dynamicImportTimeout)),r=Promise.all([import("@opentelemetry/api"),import("@opentelemetry/sdk-trace-web"),import("@tracer/opentelemetry")]),[n,o,s]=await Promise.race([r,e]);t.dynamicImports={opentelemetryApi:n,opentelemetrySdk:o,tracer:s},t.dynamicImportStatus="completed"}catch{t.dynamicImportStatus="failed"}}}isComponentTracerNotInitialized(){return E(this.span)}log(e,r){let n=Date.now();this.initPromise.then(o=>this.span.addEvent(e,{...N(r),type:"log"},n))}error(e,r){let n=Date.now();this.initPromise.then(o=>this.span.addEvent(e,{...N(r),type:"error"},n))}critical(e,r){let n=Date.now();this.initPromise.then(o=>this.span.addEvent(e,{...N(r),type:"critical"},n))}createComponentTracer(e){let r=new t({name:e,getParentContext:()=>this.context});return this.childTracers.push(r),r}end(){this.initPromise.then(e=>{this.childTracers.forEach(r=>r.end()),this.span.end()})}};var C=class extends I{constructor(){super({name:"Root"})}init({name:e,getParentContext:r},n){let s=I.dynamicImports.tracer.initTracerOpenTelemetry({serviceName:"videoplayer-sdk-web",appToken:"L9SBoka6ZWk4xPjaK7tmfSfYvMhcge7nvGDjpdMmscb",spanLimits:{attributeCountLimit:1/0,eventCountLimit:1/0,attributePerEventCountLimit:1/0}}).getProvider(),i=new I.dynamicImports.tracer.TracerMemorySpanExporter;this.spanExporter=i,s.addSpanProcessor(new I.dynamicImports.tracer.TracerAllSpansProcessor({startedSpansExporter:i})),I.rootTracer=s.getTracer("sdk-videoplayer-tracer"),super.init({name:e,getParentContext:r},n)}getFinishedSpans(){if(!this.isComponentTracerNotInitialized())return this.spanExporter?.getJsonData()}getTraceId(){return this.isComponentTracerNotInitialized()?"":this.span.spanContext().traceId}};var V=class t{constructor(e){}log(e,r){}error(e,r){}critical(e,r){}createComponentTracer(e){return new t({name:e})}end(){}getFinishedSpans(){}getTraceId(){return this.fakeTraceId}};var q=class{static createRootTracer(e=!1){return e?new C:new V}};var M=class extends y{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){let r=super._subscribe(e);return e.next(this.value),r}};function ue(t){return new l(e=>{let r={},n=Object.keys(t).length,o=s=>i=>{s in r||n--,r[s]=i,n===0&&e.next(r)};return Object.entries(t).reduce((s,[i,a])=>s.add(a.subscribe(o(i))),new d)})}function me(...t){return new l(e=>t.reduce((r,n)=>r.add(n.subscribe(e)),new d))}var ut=t=>new l(e=>{let r=window.setTimeout(()=>{try{e.next()}catch(n){if(e.error)e.error(n);else throw n}},t);return()=>window.clearTimeout(r)});var mt=t=>new l(e=>{let r=window.setInterval(()=>e.next(),t);return()=>{r&&(window.clearInterval(r),r=void 0)}});var dt=t=>new l(e=>{t.forEach(r=>e.next(r))});var bt=(t,e)=>new l(r=>{let n=o=>r.next(o);return t.addEventListener(e,n),()=>t.removeEventListener(e,n)});var _=class extends d{remove(e){this.subscriptions=this.subscriptions.filter(r=>r!==e)}};function de(t){return e=>new l(r=>e.subscribe(new H(r,t)))}var H=class{constructor(e,r){this.destination=e;this.size=r;this.lastValues=[]}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)}};var ft={leading:!1,trailing:!0};function be(t,e=ft){return r=>new l(n=>r.subscribe(new $(n,t,e)))}var $=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,h(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(r){if(this.destination.error)this.destination.error(r);else throw r}this.timeout=void 0},this.time)}error(e){this.destination.error?.(e)}};var Tt={leading:!0,trailing:!1};function fe(t,e=Tt){return r=>new l(n=>r.subscribe(new Y(n,t,e)))}var Y=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,E(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 Te(t){return e=>new l(r=>e.subscribe(new X(r,t)))}var X=class{constructor(e,r){this.destination=e;this.predicate=r}next(e){let r;try{r=this.predicate(e)}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){this.destination.error?.(e)}};var yt=(t,e)=>{let r=(n,o)=>{let s=Object.keys(n);for(let i in o)if(!s.includes(i)||o[i]!==n[i])return!1;return!0};return r(t,e)&&r(e,t)},It=(t,e)=>t instanceof Object&&e instanceof Object?yt(t,e):t===e;function Ie(t=It){return e=>new l(r=>e.subscribe(new J(r,t)))}var ye={},J=class{constructor(e,r){this.destination=e;this.predicate=r;this.lastValue=ye}next(e){let r;try{r=this.lastValue===ye||!this.predicate(this.lastValue,e),this.lastValue=e instanceof Object?{...e}:e}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){this.destination.error?.(e)}};function Q(t){return e=>new l(r=>e.subscribe(new Z(r,t)))}var Z=class{constructor(e,r){this.destination=e;this.mapper=r}next(e){let r;try{r=this.mapper(e)}catch(n){throw this.error(n),n}this.destination.next(r)}error(e){this.destination.error?.(e)}};function ve(t){return Q(()=>t)}function ge(){return t=>new l(e=>{let r=!1,n=!1,o=t.subscribe(s=>{r||(r=!0,e.next(s)),n&&o.unsubscribe()},s=>{r=!0,e.error?.(s),n&&o.unsubscribe()});return n=!0,r&&o.unsubscribe(),o})}function xe(){return t=>new l(e=>t.subscribe(new ee(e)))}var ee=class{constructor(e){this.destination=e;this.hasLast=!1}next(e){let r=this.last;if(this.last=e,!this.hasLast){this.hasLast=!0;return}this.destination.next([r,e])}error(e){this.destination.error?.(e)}};function he(t){return e=>new l(r=>e.subscribe(new te(r,t)))}var te=class{constructor(e,r){this.destination=e;this.effect=r}next(e){try{this.effect(e)}catch(r){throw this.error(r),r}this.destination.next(e)}error(e){this.destination.error?.(e)}};function Oe(t){return e=>new l(r=>e.subscribe(new re(r,t)))}var re=class{constructor(e,r){this.destination=e;this.count=r;r<0&&this.destination.error?.(new Error("Count can not be less than zero"))}next(e){this.count===0?this.destination.next(e):this.count--}error(e){this.destination.error?.(e)}};var vt=(a=>(a.NETWORK="network",a.VIDEO_PIPELINE="video_pipeline",a.EXTERNAL_API="external_api",a.PARSER="parser",a.DOM="dom",a.WTF="wtf",a.FATAL="fatal",a))(vt||{});var gt=(c=>(c.Armenian="58",c.Azerbaijani="57",c.Belarusian="114",c.English="3",c.Kazakh="97",c.Portuguese="73",c.Russian="0",c.Spanish="4",c.Ukrainian="1",c.Uzbek="65",c.Vietnamese="75",c))(gt||{}),xt="vk.com",jo=async(t,e,r)=>{let n=new URL(`https://${xt}/js/lang-pack.js`);n.searchParams.set("format","json"),n.searchParams.set("name",e),t!==void 0&&n.searchParams.set("lang",t);let s=await(await fetch(n.toString())).json();return ht(s,r)},ht=(t,e)=>Object.fromEntries(Object.entries(t.keys).map(([r,n])=>[r.substring(`${e}_`.length),Ot(n)])),Ot=t=>Array.isArray(t)?t[0]:t;var wt=(r=>(r.RU="ru",r.EN="en",r))(wt||{});var Et={UI:"__vkVideoPlayer",CORE:"__vkVideoCore"},St=(()=>{let t=0;return()=>{let e=t;return t=(t+1)%Number.MAX_SAFE_INTEGER,e}})(),we=class{constructor(e){this.id=St();this.type=e,this.initWindowObjects()}getWindowObject(){let e=this.key();return window[e]?.[this.id]??{}}initWindowObjects(){let e=this.key();window[e]||(window[e]={}),window[e][this.id]={}}expose(e){Object.assign(this.getWindowObject(),e)}destroy(){let e=this.key();window&&window[e]&&window[e][this.id]&&(delete window[e][this.id],Object.keys(window[e]).length||delete window[e])}key(){let{type:e}=this;return Et[e]}};var Ee={};le(Ee,{create:()=>At,destroy:()=>Rt,push:()=>kt,subscribe:()=>Pt});var S=new Map,At=(t,e)=>S.set(t,e??[]),Rt=t=>S.delete(t),kt=(t,e)=>{let r=S.get(t);r&&(typeof r=="function"?r(e):r.push(e))},Pt=(t,e)=>{let r=S.get(t);if(r){if(r&&Array.isArray(r))for(let n of r)e(n);S.set(t,e)}};export{vt as ErrorCategory,wt as InterfaceLanguage,we as InternalsExposure,j as Logger,l as Observable,y as Subject,d as Subscription,_ as SubscriptionRemovable,q as TracerFactory,Ce as VERSION,gt as VKNumericLanguage,M as ValueSubject,W as VideoQuality,ze as abortable,Ue as addScript,nt as areQualitiesExact,De as assertEmptyArray,T as assertNever,Me as assertNonNullable,Qe as assertNotEmptyArray,_e as assertNullable,ot as assertQualityIsExact,de as buffer,Ve as checkNever,ct as clearVideoElement,st as cloneDeep,P as cloneDeepWith,ue as combine,xr as createURL,be as debounce,K as debounceFn,$e as detectEmbed,Ee as devNull,it as fillWithDefault,Te as filter,Ie as filterChanged,L as flattenObject,bt as fromEvent,We as getExponentialDelay,Ze as getHighestQuality,pt as getTraceSubscriptionMethod,mt as interval,Ye as isHigher,Xe as isHigherOrEqual,G as isInvariantQuality,F as isLower,Je as isLowerOrEqual,h as isNonNullable,E as isNullable,vr as isValidURL,jo as loadVKLangPack,Q as map,ve as mapTo,me as merge,g as noop,je as now,dt as observableFrom,lt as observeElementSize,ge as once,xe as pairwise,ce as safeStorage,Oe as skip,he as tap,fe as throttle,B as throttleFn,sr as timeCodeToString,ut as timeout,et as videoHeightToQuality,rt as videoQualityToHeight,tt as videoSizeToQuality};
6
+ var Ne=Object.defineProperty;var le=(t,e)=>{for(var r in e)Ne(t,r,{get:e[r],enumerable:!0})};var Ce="1.0.62-dev.4cc026f5.0";var d=class{constructor(){this.subscriptions=[]}unsubscribe(){let e=this.subscriptions;this.subscriptions=[],e.forEach(r=>{typeof r=="function"?r():r.unsubscribe()})}add(e){return this.subscriptions.push(e),this}};var T=t=>{throw new Error(`${t} is value of unexpected type`)},Ve=t=>{};var g=()=>{};var l=class{constructor(e){e&&(this._subscribe=e)}subscribe(e,r){let n;r?typeof r=="function"?n={next:r,error:g}:n={next:i=>r.next(i),error:i=>r.error?.(i)}:n={next:g,error:g};let o=typeof e=="function"?{next:i=>{try{let a=e(i);a instanceof Promise&&a.catch(u=>n.next(u))}catch(a){n.next(a)}},error:i=>n.next(i)}:{next:i=>e.next(i),error:i=>e.error?e.error(i):n.next(i)},s;try{s=this._subscribe(o)}catch(i){o.error?.(i)}return new d().add(()=>{switch(o.next=g,o.error=g,typeof s){case"function":s();return;case"object":s.unsubscribe();return;case"undefined":return;default:return T(s)}})}pipe(...e){return e.reduce((r,n)=>n(r),this)}_subscribe(e){}};var y=class extends l{constructor(){super();this.keyCounter=0;this.subscribers=new Map}next(r){this.subscribers.forEach(n=>n.next(r))}error(r){this.subscribers.forEach(n=>n.error?.(r))}_subscribe(r){let n=this.keyCounter++;return this.subscribers.set(n,r),new d().add(()=>this.subscribers.delete(n))}};var j=class{constructor(){this.log$=new y;this.logs=[];this.log=e=>{let r={...e,timestamp:Date.now()};this.logs.push(r),this.log$.next(r)};this.getAllLogs=()=>this.logs}createCustomLog(e){return(...r)=>{let n;try{n=e(...r)}catch{n={message:"error in `createCustomLog`",component:"Logger"}}this.log(n)}}createComponentLog(e){return this.createCustomLog(r=>({component:e,...r}))}};function Me(t,e='Assertion "value is not nullable" failed'){if(t==null)throw new Error(e)}function _e(t,e='Assertion "value is nullable" failed'){if(t!=null)throw new Error(e)}function h(t){return typeof t<"u"&&t!==null}function E(t){return t==null}function Qe(t,e){if(!t?.length)throw new Error(e)}function De(t,e){if(t?.length)throw new Error(e)}var Ue=(t,e,r)=>new Promise((n,o)=>{e.addEventListener("abort",()=>{a(),m.remove()});let s=()=>{a(),o("error")},i=()=>{a(),n()},a=()=>{u&&clearTimeout(u),m.removeEventListener("load",i),m.removeEventListener("error",s)},u;r&&(u=window.setTimeout(()=>{a(),o("timeout")},r));let m=document.createElement("script");m.addEventListener("load",i),m.addEventListener("error",s),m.src=t,document.head.appendChild(m)});var je=typeof window.performance?.now=="function"?()=>window.performance.now():()=>Date.now();var ze=(t,e)=>async(...r)=>{let n=e(...r),o=t.aborted,s;for(;!o&&!t.aborted;)try{let i=await n.next(s);o=i.done??!1,s=i.value}catch(i){await n.throw(i)}return s};var We=(t,{start:e=0,factor:r=2,max:n=1/0,min:o=e,random:s=0}={})=>{let i=e;return i*=r**t,i*=1+(Math.random()*s*2-s),i=Math.round(i),i=Math.min(i,n),i=Math.max(i,o),i};var ce={};le(ce,{clear:()=>He,get:()=>Ge,has:()=>Be,isPersistent:()=>Fe,remove:()=>qe,set:()=>Ke});var O,x,z=`vk-videoplayer-dummy-key-${Math.random()}`,w=()=>{if(x!==void 0)return x;try{localStorage.setItem(z,"test"),localStorage.removeItem(z),x=0}catch(t){if(t instanceof DOMException||t instanceof TypeError)try{sessionStorage.getItem(z),x=1}catch(e){if(e instanceof DOMException||e instanceof TypeError)x=2;else throw e}else throw t}return x===2&&(O=new Map),x},Fe=()=>w()===0,Ge=t=>{let e=w();switch(e){case 0:return localStorage.getItem(t)??void 0;case 1:return sessionStorage.getItem(t)??void 0;case 2:return O?.get(t);default:T(e)}},Ke=(t,e)=>{let r=w();switch(r){case 0:try{localStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 1:try{sessionStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 2:O?.set(t,e);return;default:T(r)}},Be=t=>{let e=w();switch(e){case 0:return t in localStorage;case 1:return t in sessionStorage;case 2:return O?.has(t)??!1;default:return T(e),!1}},qe=t=>{let e=w();switch(e){case 0:return localStorage.removeItem(t);case 1:return sessionStorage.removeItem(t);case 2:O?.delete(t);return;default:T(e)}},He=()=>{let t=w();switch(t){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return O?.clear();default:T(t)}};var $e=()=>{let t,e=[];try{t=window.self!==window.top}catch(r){r instanceof DOMException&&r.name==="SecurityError"?t=!0:(t=!1,console.error(r))}try{window.location.ancestorOrigins&&(e=[...window.location.ancestorOrigins])}catch(r){console.error(r)}try{!e.length&&document.referrer&&(e=[new URL(document.referrer).origin])}catch(r){console.error(r)}return{isEmbed:t,origins:e,topOrigin:e.at(-1),immediateOrigin:e.at(0)}};var W=(c=>(c.INVARIANT="Invariant quality",c.Q_144P="144p",c.Q_240P="240p",c.Q_360P="360p",c.Q_480P="480p",c.Q_576P="576p",c.Q_720P="720p",c.Q_1080P="1080p",c.Q_1440P="1440p",c.Q_2160P="2160p",c.Q_4320P="4320p",c))(W||{});var b={"144p":{width:256,height:144},"240p":{width:428,height:240},"360p":{width:640,height:360},"480p":{width:856,height:480},"576p":{width:1024,height:576},"720p":{width:1280,height:720},"1080p":{width:1920,height:1080},"1440p":{width:2560,height:1440},"2160p":{width:3840,height:2160},"4320p":{width:7680,height:4320}},Ye=(t,e)=>b[t].height>b[e].height,Xe=(t,e)=>b[t].height>=b[e].height,F=(t,e)=>b[t].height<b[e].height,Je=(t,e)=>b[t].height<=b[e].height,Ze=t=>t.sort((e,r)=>e===r?0:e==="Invariant quality"?1:r==="Invariant quality"?-1:F(e,r)?1:-1)[0],pe=Object.keys(b).sort((t,e)=>F(t,e)?-1:1),et=(t,e=.02)=>[...pe].find(n=>b[n].height*(1+e)>=t),tt=({width:t,height:e})=>{let r=Math.min(t,e),n=Math.max(t,e);return pe.find(o=>{let s=b[o];return s.width>=n&&s.height>=r})},rt=t=>b[t].height,G=t=>t==="Invariant quality",nt=t=>t.every(e=>!G(e));function ot(t){if(G(t))throw new Error("Expected exact quality")}var it=(t,e)=>{let r={};for(let n of Object.keys(e)){let o=e[n],s=t[n];Array.isArray(o)&&Array.isArray(s)?r[n]=s:typeof o=="object"&&typeof s=="object"?r[n]=it(s,o):r[n]=n in t?s:o}return r};var sr=t=>{let e="";return t>=3600&&(e+=Math.floor(t/3600)+"h",t=t%3600),t>=60&&(e+=Math.floor(t/60)+"m",t=t%60),t>0&&(e+=Math.floor(t)+"s"),e};function K(t,e=0,r){let n,o,s,i,a,u,m=0,ne=!1,c=!1,D=!0,oe=!e&&e!==0&&typeof window.requestAnimationFrame=="function";r&&(ne=!!r.leading,c="maxWait"in r,s=r?.maxWait?Math.max(+r?.maxWait||0,e):s,D="trailing"in r?!!r.trailing:D);function U(p){let f=n,v=o;return n=o=void 0,m=p,i=t.apply(v,f),i}function A(p,f){return oe?(a&&window.cancelAnimationFrame(a),window.requestAnimationFrame(p)):setTimeout(p,f)}function Se(p){if(oe){window.cancelAnimationFrame(p);return}clearTimeout(p)}function Ae(p){return m=p,a=A(R,e),ne?U(p):i}function Re(p){let f=p-u,v=p-m,ae=e-f;return c?Math.min(ae,s-v):ae}function ie(p){let f=p-u,v=p-m;return u===void 0||f>=e||f<0||c&&v>=s}function R(){let p=Date.now();if(ie(p))return se(p);a=A(R,Re(p))}function se(p){return a=void 0,D&&n?U(p):(n=o=void 0,i)}function ke(){a!==void 0&&Se(a),m=0,n=u=o=a=void 0}function Pe(){return a===void 0?i:se(Date.now())}function Le(){return a!==void 0}function k(...p){let f=Date.now(),v=ie(f);if(n=p,o=this,u=f,v){if(a===void 0)return Ae(u);if(c)return a=A(R,e),U(u)}return a===void 0&&(a=A(R,e)),i}return k.cancel=ke,k.flush=Pe,k.pending=Le,k}var B=(t,e=0,r)=>K(t,e,{...{leading:!0,trailing:!0},...r,maxWait:e});var P=(t,e)=>{if(t===null||typeof t!="object")return t;let r=Array.isArray(t)?[]:{};for(let n in t){if(typeof e=="function"){let o=e(t[n],n,t,r);if(o!==void 0){r[n]=o;continue}}typeof t[n]=="object"?r[n]=P(t[n],e):r[n]=t[n]}return r};var st=t=>P(t);var at=300,lt=(t,e=at)=>new l(r=>{let{width:n,height:o}=t.getBoundingClientRect();if(r.next({width:n,height:o}),!window.ResizeObserver)return;let s=new ResizeObserver(B(i=>{let a=i[0];if(!a)return;let u,m;a.contentBoxSize&&a.contentBoxSize[0]?(m=a.contentBoxSize[0].blockSize,u=a.contentBoxSize[0].inlineSize):a.contentRect&&(u=a.contentRect.width,m=a.contentRect.height),h(u)&&h(m)&&r.next({width:u,height:m})},e));return s.observe(t),()=>s.disconnect()});var L=(t,e=6,r=".")=>{let n={};for(let o in t)if(!(!t.hasOwnProperty(o)||t[o]instanceof HTMLElement||!e))if(typeof t[o]=="object"&&t[o]!==null){let s=L(t[o],e-1);for(let i in s)s.hasOwnProperty(i)&&(n[o+r+i]=s[i])}else n[o]=t[o];return n};var ct=t=>{t.removeAttribute("src"),t.load()};var vr=t=>{let e;try{e=new URL(t)}catch{return!1}return e.protocol==="https:"};var xr=t=>{try{return new URL(t)}catch{return null}};var pt=t=>e=>r=>{let n=typeof r=="object";r==null||n&&!Object.keys(r).length||t(e,n?L(r):{value:r})},N=(t={})=>{let e=n=>{let o=n;return n===void 0?o="undefined":n===null?o="null":(typeof n=="number"||typeof n=="boolean")&&(o=n.toString()),o},r={};for(let n in t)Array.isArray(t[n])?r[n]=t[n].map(e):r[n]=e(t[n]);return r};var I=class t{constructor({name:e,getParentContext:r}){this.dynamicImportTimeout=5e3;this.childTracers=[];if(t.dynamicImportStatus==="failed")return this;t.dynamicImportStatus==="not_started"&&(t.dynamicImportPromise=this.loadOpentelemetry());let n=Date.now();this.initPromise=t.dynamicImportPromise.then(()=>this.init({name:e,getParentContext:r},n))}static{this.dynamicImportStatus="not_started"}init({name:e,getParentContext:r},n){this.span=t.rootTracer.startSpan(e,{startTime:n},r?.()),this.context=t.dynamicImports.opentelemetryApi.trace.setSpan(t.dynamicImports.opentelemetryApi.context.active(),this.span)}async loadOpentelemetry(){if(t.dynamicImportStatus==="not_started"){t.dynamicImportStatus="in_progress";try{let e=new Promise((i,a)=>setTimeout(a,this.dynamicImportTimeout)),r=Promise.all([import("@opentelemetry/api"),import("@opentelemetry/sdk-trace-web"),import("@tracer/opentelemetry")]),[n,o,s]=await Promise.race([r,e]);t.dynamicImports={opentelemetryApi:n,opentelemetrySdk:o,tracer:s},t.dynamicImportStatus="completed"}catch{t.dynamicImportStatus="failed"}}}isComponentTracerNotInitialized(){return E(this.span)}log(e,r){let n=Date.now();this.initPromise.then(o=>this.span.addEvent(e,{...N(r),type:"log"},n))}error(e,r){let n=Date.now();this.initPromise.then(o=>this.span.addEvent(e,{...N(r),type:"error"},n))}critical(e,r){let n=Date.now();this.initPromise.then(o=>this.span.addEvent(e,{...N(r),type:"critical"},n))}createComponentTracer(e){let r=new t({name:e,getParentContext:()=>this.context});return this.childTracers.push(r),r}end(){this.initPromise.then(e=>{this.childTracers.forEach(r=>r.end()),this.span.end()})}};var C=class extends I{constructor(){super({name:"Root"})}init({name:e,getParentContext:r},n){let s=I.dynamicImports.tracer.initTracerOpenTelemetry({serviceName:"videoplayer-sdk-web",appToken:"L9SBoka6ZWk4xPjaK7tmfSfYvMhcge7nvGDjpdMmscb",spanLimits:{attributeCountLimit:1/0,eventCountLimit:1/0,attributePerEventCountLimit:1/0}}).getProvider(),i=new I.dynamicImports.tracer.TracerMemorySpanExporter;this.spanExporter=i,s.addSpanProcessor(new I.dynamicImports.tracer.TracerAllSpansProcessor({startedSpansExporter:i})),I.rootTracer=s.getTracer("sdk-videoplayer-tracer"),super.init({name:e,getParentContext:r},n)}getFinishedSpans(){if(!this.isComponentTracerNotInitialized())return this.spanExporter?.getJsonData()}getTraceId(){return this.isComponentTracerNotInitialized()?"":this.span.spanContext().traceId}};var V=class t{constructor(e){}log(e,r){}error(e,r){}critical(e,r){}createComponentTracer(e){return new t({name:e})}end(){}getFinishedSpans(){}getTraceId(){return this.fakeTraceId}};var q=class{static createRootTracer(e=!1){return e?new C:new V}};var M=class extends y{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){let r=super._subscribe(e);return e.next(this.value),r}};function ue(t){return new l(e=>{let r={},n=Object.keys(t).length,o=s=>i=>{s in r||n--,r[s]=i,n===0&&e.next(r)};return Object.entries(t).reduce((s,[i,a])=>s.add(a.subscribe(o(i))),new d)})}function me(...t){return new l(e=>t.reduce((r,n)=>r.add(n.subscribe(e)),new d))}var ut=t=>new l(e=>{let r=window.setTimeout(()=>{try{e.next()}catch(n){if(e.error)e.error(n);else throw n}},t);return()=>window.clearTimeout(r)});var mt=t=>new l(e=>{let r=window.setInterval(()=>e.next(),t);return()=>{r&&(window.clearInterval(r),r=void 0)}});var dt=t=>new l(e=>{t.forEach(r=>e.next(r))});var bt=(t,e)=>new l(r=>{let n=o=>r.next(o);return t.addEventListener(e,n),()=>t.removeEventListener(e,n)});var _=class extends d{remove(e){this.subscriptions=this.subscriptions.filter(r=>r!==e)}};function de(t){return e=>new l(r=>e.subscribe(new H(r,t)))}var H=class{constructor(e,r){this.destination=e;this.size=r;this.lastValues=[]}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)}};var ft={leading:!1,trailing:!0};function be(t,e=ft){return r=>new l(n=>r.subscribe(new $(n,t,e)))}var $=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,h(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(r){if(this.destination.error)this.destination.error(r);else throw r}this.timeout=void 0},this.time)}error(e){this.destination.error?.(e)}};var Tt={leading:!0,trailing:!1};function fe(t,e=Tt){return r=>new l(n=>r.subscribe(new Y(n,t,e)))}var Y=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,E(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 Te(t){return e=>new l(r=>e.subscribe(new X(r,t)))}var X=class{constructor(e,r){this.destination=e;this.predicate=r}next(e){let r;try{r=this.predicate(e)}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){this.destination.error?.(e)}};var yt=(t,e)=>{let r=(n,o)=>{let s=Object.keys(n);for(let i in o)if(!s.includes(i)||o[i]!==n[i])return!1;return!0};return r(t,e)&&r(e,t)},It=(t,e)=>t instanceof Object&&e instanceof Object?yt(t,e):t===e;function Ie(t=It){return e=>new l(r=>e.subscribe(new J(r,t)))}var ye={},J=class{constructor(e,r){this.destination=e;this.predicate=r;this.lastValue=ye}next(e){let r;try{r=this.lastValue===ye||!this.predicate(this.lastValue,e),this.lastValue=e instanceof Object?{...e}:e}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){this.destination.error?.(e)}};function Q(t){return e=>new l(r=>e.subscribe(new Z(r,t)))}var Z=class{constructor(e,r){this.destination=e;this.mapper=r}next(e){let r;try{r=this.mapper(e)}catch(n){throw this.error(n),n}this.destination.next(r)}error(e){this.destination.error?.(e)}};function ve(t){return Q(()=>t)}function ge(){return t=>new l(e=>{let r=!1,n=!1,o=t.subscribe(s=>{r||(r=!0,e.next(s)),n&&o.unsubscribe()},s=>{r=!0,e.error?.(s),n&&o.unsubscribe()});return n=!0,r&&o.unsubscribe(),o})}function xe(){return t=>new l(e=>t.subscribe(new ee(e)))}var ee=class{constructor(e){this.destination=e;this.hasLast=!1}next(e){let r=this.last;if(this.last=e,!this.hasLast){this.hasLast=!0;return}this.destination.next([r,e])}error(e){this.destination.error?.(e)}};function he(t){return e=>new l(r=>e.subscribe(new te(r,t)))}var te=class{constructor(e,r){this.destination=e;this.effect=r}next(e){try{this.effect(e)}catch(r){throw this.error(r),r}this.destination.next(e)}error(e){this.destination.error?.(e)}};function Oe(t){return e=>new l(r=>e.subscribe(new re(r,t)))}var re=class{constructor(e,r){this.destination=e;this.count=r;r<0&&this.destination.error?.(new Error("Count can not be less than zero"))}next(e){this.count===0?this.destination.next(e):this.count--}error(e){this.destination.error?.(e)}};var vt=(a=>(a.NETWORK="network",a.VIDEO_PIPELINE="video_pipeline",a.EXTERNAL_API="external_api",a.PARSER="parser",a.DOM="dom",a.WTF="wtf",a.FATAL="fatal",a))(vt||{});var gt=(c=>(c.Armenian="58",c.Azerbaijani="57",c.Belarusian="114",c.English="3",c.Kazakh="97",c.Portuguese="73",c.Russian="0",c.Spanish="4",c.Ukrainian="1",c.Uzbek="65",c.Vietnamese="75",c))(gt||{}),xt="vk.com",jo=async(t,e,r)=>{let n=new URL(`https://${xt}/js/lang-pack.js`);n.searchParams.set("format","json"),n.searchParams.set("name",e),t!==void 0&&n.searchParams.set("lang",t);let s=await(await fetch(n.toString())).json();return ht(s,r)},ht=(t,e)=>Object.fromEntries(Object.entries(t.keys).map(([r,n])=>[r.substring(`${e}_`.length),Ot(n)])),Ot=t=>Array.isArray(t)?t[0]:t;var wt=(r=>(r.RU="ru",r.EN="en",r))(wt||{});var Et={UI:"__vkVideoPlayer",CORE:"__vkVideoCore"},St=(()=>{let t=0;return()=>{let e=t;return t=(t+1)%Number.MAX_SAFE_INTEGER,e}})(),we=class{constructor(e){this.id=St();this.type=e,this.initWindowObjects()}getWindowObject(){let e=this.key();return window[e]?.[this.id]??{}}initWindowObjects(){let e=this.key();window[e]||(window[e]={}),window[e][this.id]={}}expose(e){Object.assign(this.getWindowObject(),e)}destroy(){let e=this.key();window&&window[e]&&window[e][this.id]&&(delete window[e][this.id],Object.keys(window[e]).length||delete window[e])}key(){let{type:e}=this;return Et[e]}};var Ee={};le(Ee,{create:()=>At,destroy:()=>Rt,push:()=>kt,subscribe:()=>Pt});var S=new Map,At=(t,e)=>S.set(t,e??[]),Rt=t=>S.delete(t),kt=(t,e)=>{let r=S.get(t);r&&(typeof r=="function"?r(e):r.push(e))},Pt=(t,e)=>{let r=S.get(t);if(r){if(r&&Array.isArray(r))for(let n of r)e(n);S.set(t,e)}};export{vt as ErrorCategory,wt as InterfaceLanguage,we as InternalsExposure,j as Logger,l as Observable,y as Subject,d as Subscription,_ as SubscriptionRemovable,q as TracerFactory,Ce as VERSION,gt as VKNumericLanguage,M as ValueSubject,W as VideoQuality,ze as abortable,Ue as addScript,nt as areQualitiesExact,De as assertEmptyArray,T as assertNever,Me as assertNonNullable,Qe as assertNotEmptyArray,_e as assertNullable,ot as assertQualityIsExact,de as buffer,Ve as checkNever,ct as clearVideoElement,st as cloneDeep,P as cloneDeepWith,ue as combine,xr as createURL,be as debounce,K as debounceFn,$e as detectEmbed,Ee as devNull,it as fillWithDefault,Te as filter,Ie as filterChanged,L as flattenObject,bt as fromEvent,We as getExponentialDelay,Ze as getHighestQuality,pt as getTraceSubscriptionMethod,mt as interval,Ye as isHigher,Xe as isHigherOrEqual,G as isInvariantQuality,F as isLower,Je as isLowerOrEqual,h as isNonNullable,E as isNullable,vr as isValidURL,jo as loadVKLangPack,Q as map,ve as mapTo,me as merge,g as noop,je as now,dt as observableFrom,lt as observeElementSize,ge as once,xe as pairwise,ce as safeStorage,Oe as skip,he as tap,fe as throttle,B as throttleFn,sr as timeCodeToString,ut as timeout,et as videoHeightToQuality,rt as videoQualityToHeight,tt as videoSizeToQuality};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vkontakte/videoplayer-shared",
3
- "version": "1.0.62-dev.2bd92e6d.0",
3
+ "version": "1.0.62-dev.4cc026f5.0",
4
4
  "author": "vk.com",
5
5
  "description": "Shared code for vk.com videoplayer",
6
6
  "homepage": "https://vk.com",