@vkontakte/videoplayer-shared 1.0.85-dev.fa4486263.0 → 1.0.85
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 +3 -3
- package/es2015.esm.js +3 -3
- package/es2018.cjs +3 -3
- package/es2018.esm.js +3 -3
- package/es2024.cjs +3 -3
- package/es2024.esm.js +3 -3
- package/esnext.cjs +3 -3
- package/esnext.esm.js +3 -3
- package/evergreen.esm.js +3 -3
- package/package.json +1 -1
- package/types/index.d.ts +0 -1
- package/types/utils/index.d.ts +1 -1
- package/types/utils/now.d.ts +2 -0
- package/types/utils/svelteInstanceofGuard.d.ts +0 -15
package/evergreen.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-shared v1.0.85
|
|
3
|
-
*
|
|
2
|
+
* @vkontakte/videoplayer-shared v1.0.85
|
|
3
|
+
* Tue, 24 Mar 2026 10:14:24 GMT
|
|
4
4
|
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-85/doc/
|
|
5
5
|
*/
|
|
6
|
-
var e=Object.defineProperty,t=e=>e;function n(e,n){this[e]=t.bind(null,n)}var r=(t,r)=>{for(var i in r)e(t,i,{get:r[i],enumerable:!0,configurable:!0,set:n.bind(r,i)})},i={};try{let e=globalThis;for(let t of[`Comment`,`Node`,`EventTarget`,`HTMLElement`,`HTMLMediaElement`,`ShadowRoot`,`Date`,`Map`,`Set`,`Error`])typeof e[t]==`function`&&(i[t]=e[t])}catch{}var a=globalThis;a.__svelte_safe_instanceof===void 0&&(a.__svelte_safe_instanceof=(e,t,n)=>{let r=t;if(typeof t!=`function`){let e=n?.split(`:`)[1];if(e&&e in i&&(r=i[e]),typeof r!=`function`&&e===`Comment`)try{r=globalThis.document.createComment(``).constructor}catch{}if(typeof r!=`function`)return!1}return e instanceof r});var o=`1.0.85-dev.fa4486263.0`;class s{subscriptions=[];unsubscribe(){let e=this.subscriptions;this.subscriptions=[],e.forEach(e=>{typeof e==`function`?e():e.unsubscribe()})}add(e){return this.subscriptions.push(e),this}}var c=e=>{throw Error(`${e} is value of unexpected type`)},l=e=>{},u=()=>{},d=e=>{throw console.error(e),e},f=e=>{console.error(e)};class p{suppressErrors=!1;constructor(e){e&&(this._subscribe=e)}setSuppressErrors(e){this.suppressErrors=e}subscribe(e,t){let n=this.suppressErrors?f:d,r;r=t?typeof t==`function`?{next:t,error:u}:{next:e=>t.next(e),error:e=>t.error?.(e)}:{next:n,error:u};let i=typeof e==`function`?{next:t=>{try{let n=e(t);n instanceof Promise&&n.catch(e=>r.next(e))}catch(e){r.next(e)}},error:e=>r.next(e)}:{next:t=>e.next(t),error:t=>e.error?e.error(t):r.next(t)},a;try{a=this._subscribe(i)}catch(e){i.error?.(e)}return new s().add(()=>{switch(i.next=u,i.error=u,typeof a){case`function`:a();return;case`object`:a.unsubscribe();return;case`undefined`:return;default:return c(a)}})}pipe(...e){return e.reduce((e,t)=>t(e),this)}_subscribe(e){}}class m extends p{keyCounter=0;subscribers=new Map;constructor(){super()}next(e){this.subscribers.forEach(t=>t.next(e))}error(e){this.subscribers.forEach(t=>t.error?.(e))}_subscribe(e){let t=this.keyCounter++;return this.subscribers.set(t,e),new s().add(()=>this.subscribers.delete(t))}}class h{log$=new m;logs=[];log=e=>{let t={...e,timestamp:Date.now()};this.logs.push(t),this.log$.next(t)};createCustomLog(e){return(...t)=>{let n;try{n=e(...t)}catch{n={message:"error in `createCustomLog`",component:`Logger`}}this.log(n)}}createComponentLog(e){return this.createCustomLog(t=>({component:e,...t}))}getAllLogs=()=>this.logs}function ee(e,t=`Assertion "value is not nullable" failed`){if(e==null)throw Error(t)}function te(e,t=`Assertion "value is nullable" failed`){if(e!=null)throw Error(t)}function g(e){return e!=null}function _(e){return e==null}var v=e=>Object.fromEntries(Object.entries(e).filter(([e,t])=>g(t)));function y(e,t){if(!e?.length)throw Error(t)}function b(e,t){if(e?.length)throw Error(t)}var x=()=>globalThis,S=(e=x())=>!!(e.window&&e.screen),C=(e,t,n)=>new Promise((r,i)=>{t.addEventListener(`abort`,()=>{s(),l.remove()});let a=()=>{s(),i(`error`)},o=()=>{s(),r()},s=()=>{c&&clearTimeout(c),l.removeEventListener(`load`,o),l.removeEventListener(`error`,a)},c;n&&(c=x().setTimeout(()=>{s(),i(`timeout`)},n));let l=document.createElement(`script`);l.addEventListener(`load`,o),l.addEventListener(`error`,a),l.src=e,document.head.appendChild(l)}),w=typeof x().performance?.now==`function`?()=>x().performance.now():()=>Date.now(),ne=(e,t)=>async(...n)=>{let r=t(...n),i=e.aborted,a;for(;!i&&!e.aborted;)try{let e=await r.next(a);i=e.done??!1,a=e.value}catch(e){await r.throw(e)}return a},re=(e,{start:t=0,factor:n=2,max:r=1/0,min:i=t,random:a=0}={})=>{let o=t;return o*=n**e,o*=1+(Math.random()*a*2-a),o=Math.round(o),o=Math.min(o,r),o=Math.max(o,i),o},T={};r(T,{set:()=>oe,remove:()=>ce,isPersistent:()=>ie,has:()=>se,get:()=>ae,clear:()=>le});var E,D,O=`vk-videoplayer-dummy-key-${Math.random()}`,k=()=>{if(D!==void 0)return D;try{localStorage.setItem(O,`test`),localStorage.removeItem(O),D=0}catch(e){if(e instanceof DOMException||e instanceof TypeError)try{sessionStorage.getItem(O),D=1}catch(e){if(e instanceof DOMException||e instanceof TypeError)D=2;else throw e}else throw e}return D===2&&(E=new Map),D},ie=()=>k()===0,ae=e=>{let t=k();switch(t){case 0:return localStorage.getItem(e)??void 0;case 1:return sessionStorage.getItem(e)??void 0;case 2:return E?.get(e);default:c(t)}},oe=(e,t)=>{let n=k();switch(n){case 0:try{localStorage.setItem(e,t)}catch(e){if(e instanceof DOMException)console.error(e);else throw e}break;case 1:try{sessionStorage.setItem(e,t)}catch(e){if(e instanceof DOMException)console.error(e);else throw e}break;case 2:E?.set(e,t);return;default:c(n)}},se=e=>{let t=k();switch(t){case 0:return e in localStorage;case 1:return e in sessionStorage;case 2:return E?.has(e)??!1;default:return c(t),!1}},ce=e=>{let t=k();switch(t){case 0:return localStorage.removeItem(e);case 1:return sessionStorage.removeItem(e);case 2:E?.delete(e);return;default:c(t)}},le=()=>{let e=k();switch(e){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return E?.clear();default:c(e)}},ue=()=>{let e,t=[],n=x();try{e=n.self!==n.top}catch(t){t instanceof DOMException&&t.name===`SecurityError`?e=!0:(e=!1,console.error(t))}try{n.location.ancestorOrigins&&(t=[...n.location.ancestorOrigins])}catch(e){console.error(e)}try{!t.length&&n.document.referrer&&(t=[new URL(n.document.referrer).origin])}catch(e){console.error(e)}return t=t.filter(e=>URL.canParse(e)),{isEmbed:e,origins:t,topOrigin:t.at(-1),immediateOrigin:t.at(0)}},A;(e=>{e.INVARIANT=`Invariant quality`,e.Q_144P=`144p`,e.Q_240P=`240p`,e.Q_360P=`360p`,e.Q_480P=`480p`,e.Q_576P=`576p`,e.Q_720P=`720p`,e.Q_1080P=`1080p`,e.Q_1440P=`1440p`,e.Q_2160P=`2160p`,e.Q_4320P=`4320p`})(A||={});var j={"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}},de=(e,t)=>j[e].height>j[t].height,fe=(e,t)=>j[e].height>=j[t].height,M=(e,t)=>j[e].height<j[t].height,pe=(e,t)=>j[e].height<=j[t].height,me=e=>e.sort((e,t)=>e===t?0:e===`Invariant quality`?1:t===`Invariant quality`?-1:M(e,t)?1:-1)[0],N=Object.keys(j).sort((e,t)=>M(e,t)?-1:1),he=(e,t=.02)=>[...N].find(n=>j[n].height*(1+t)>=e),ge=({width:e,height:t})=>{let n=Math.min(e,t),r=Math.max(e,t);return N.find(e=>{let t=j[e];return t.width>=r&&t.height>=n})},_e=e=>j[e].height,P=e=>e===`Invariant quality`,ve=e=>e.every(e=>!P(e));function ye(e){if(P(e))throw Error(`Expected exact quality`)}var be=e=>{switch(e){case`4320p`:return`8K`;case`2160p`:return`4K`;case`1440p`:return`QHD`;case`1080p`:return`FHD`;case`720p`:return`HD`;default:return``}},F=(e,t)=>{let n={};for(let r of Object.keys(t)){let i=t[r],a=e[r];Array.isArray(i)?n[r]=Array.isArray(a)?a:i:typeof i==`object`&&i?typeof a==`object`&&a&&!Array.isArray(a)?n[r]=F(a,i):n[r]=i:n[r]=r in e?a:i}return n},xe=e=>{let t=``;return e>=3600&&(t+=Math.floor(e/3600)+`h`,e%=3600),e>=60&&(t+=Math.floor(e/60)+`m`,e%=60),e>0&&(t+=Math.floor(e)+`s`),t};function I(e,t=0,n){let r,i,a,o,s,c,l=0,u=!1,d=!1,f=!0,p=!t&&t!==0&&typeof x().requestAnimationFrame==`function`;n&&(u=!!n.leading,d=`maxWait`in n,a=n?.maxWait?Math.max(+n?.maxWait||0,t):a,f=`trailing`in n?!!n.trailing:f);function m(t){let n=r,a=i;return r=i=void 0,l=t,o=e.apply(a,n),o}function h(e,t){return p?(s&&x().cancelAnimationFrame(s),x().requestAnimationFrame(e)):setTimeout(e,t)}function ee(e){if(p){x().cancelAnimationFrame(e);return}clearTimeout(e)}function te(e){return l=e,s=h(v,t),u?m(e):o}function g(e){let n=e-c,r=e-l,i=t-n;return d?Math.min(i,a-r):i}function _(e){let n=e-c,r=e-l;return c===void 0||n>=t||n<0||d&&r>=a}function v(){let e=Date.now();if(_(e))return y(e);s=h(v,g(e))}function y(e){return s=void 0,f&&r?m(e):(r=i=void 0,o)}function b(){s!==void 0&&ee(s),l=0,r=c=i=s=void 0}function S(){return s===void 0?o:y(Date.now())}function C(){return s!==void 0}function w(...e){let n=Date.now(),a=_(n);if(r=e,i=this,c=n,a){if(s===void 0)return te(c);if(d)return s=h(v,t),m(c)}return s===void 0&&(s=h(v,t)),o}return w.cancel=b,w.flush=S,w.pending=C,w}var L=(e,t=0,n)=>I(e,t,{leading:!0,trailing:!0,...n,maxWait:t}),R=(e,t)=>{if(typeof e!=`object`||!e)return e;let n=Array.isArray(e)?[]:{};for(let r in e){if(typeof t==`function`){let i=t(e[r],r,e,n);if(i!==void 0){n[r]=i;continue}}typeof e[r]==`object`?n[r]=R(e[r],t):n[r]=e[r]}return n},Se=e=>R(e);class z extends m{bufferSize;buffer=[];cursorEnd=-1;cursorStart=0;constructor(e){super(),this.bufferSize=e,this.buffer=Array(e)}next(e){this.cursorEnd+=1,this.cursorStart=this.cursorEnd>=this.bufferSize?this.cursorStart+1:0,this.buffer[this.cursorEnd%this.bufferSize]=e,this.subscribers.forEach(t=>t.next(e))}_subscribe(e){for(let t=this.cursorStart;t<=this.cursorEnd;t++)e.next(this.buffer[t%this.bufferSize]);let t=this.keyCounter++;return this.subscribers.set(t,e),new s().add(()=>this.subscribers.delete(t))}}class Ce extends m{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){let t=super._subscribe(e);return e.next(this.value),t}}function we(e){return new p(t=>{let n={},r=Object.keys(e).length,i=e=>i=>{e in n||r--,n[e]=i,r===0&&t.next(n)};return Object.entries(e).reduce((e,[t,n])=>e.add(n.subscribe(i(t))),new s)})}function Te(...e){return new p(t=>e.reduce((e,n)=>e.add(n.subscribe(t)),new s))}var Ee=e=>new p(t=>{let n=x().setTimeout(()=>{try{t.next()}catch(e){if(t.error)t.error(e);else throw e}},e);return()=>x().clearTimeout(n)}),De=e=>new p(t=>{let n=x(),r=n.setInterval(()=>t.next(),e);return()=>{r&&=(n.clearInterval(r),void 0)}}),Oe=e=>new p(t=>{e.forEach(e=>t.next(e))}),ke=(e,t)=>new p(n=>{let r=e=>n.next(e);return e.addEventListener(t,r),()=>e.removeEventListener(t,r)});class Ae extends s{remove(e){this.subscriptions=this.subscriptions.filter(t=>t!==e)}}function je(e){return t=>new p(n=>t.subscribe(new Me(n,e)))}class Me{destination;size;lastValues=[];constructor(e,t){this.destination=e,this.size=t}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 Ne={leading:!1,trailing:!0};function Pe(e,t=Ne){return n=>new p(r=>n.subscribe(new Fe(r,e,t)))}class Fe{destination;time;config;lastValue;timeout;constructor(e,t,n){this.destination=e,this.time=t,this.config=n}next(e){this.lastValue=e;let t=x();g(this.timeout)?t.clearTimeout(this.timeout):this.config.leading&&this.destination.next(e),this.timeout=t.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(e){if(this.destination.error)this.destination.error(e);else throw e}this.timeout=void 0},this.time)}error(e){this.destination.error?.(e)}}var Ie={leading:!0,trailing:!1};function Le(e,t=Ie){return n=>new p(r=>n.subscribe(new Re(r,e,t)))}class Re{destination;time;config;lastValue;timeout;constructor(e,t,n){this.destination=e,this.time=t,this.config=n}next(e){this.lastValue=e,_(this.timeout)&&(this.config.leading&&this.destination.next(e),this.timeout=x().setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(e){this.destination.error?.(e)}}function ze(e){return t=>new p(n=>t.subscribe(new Be(n,e)))}class Be{destination;predicate;constructor(e,t){this.destination=e,this.predicate=t}next(e){let t;try{t=this.predicate(e)}catch(e){throw this.error(e),e}t&&this.destination.next(e)}error(e){this.destination.error?.(e)}}var Ve=(e,t)=>{let n=(e,t)=>{let n=Object.keys(e);for(let r in t)if(!n.includes(r)||t[r]!==e[r])return!1;return!0};return n(e,t)&&n(t,e)},He=(e,t)=>e instanceof Object&&t instanceof Object?Ve(e,t):e===t;function Ue(e=He){return t=>new p(n=>t.subscribe(new We(n,e)))}var B={};class We{destination;predicate;lastValue=B;constructor(e,t){this.destination=e,this.predicate=t}next(e){let t;try{t=this.lastValue===B||!this.predicate(this.lastValue,e),this.lastValue=e instanceof Object&&!Array.isArray(e)?{...e}:e}catch(e){throw this.error(e),e}t&&this.destination.next(e)}error(e){this.destination.error?.(e)}}function V(e){return t=>new p(n=>t.subscribe(new Ge(n,e)))}class Ge{destination;mapper;constructor(e,t){this.destination=e,this.mapper=t}next(e){let t;try{t=this.mapper(e)}catch(e){throw this.error(e),e}this.destination.next(t)}error(e){this.destination.error?.(e)}}function Ke(e){return V(()=>e)}function qe(){return e=>new p(t=>{let n=!1,r=!1,i=e.subscribe(e=>{n||(n=!0,t.next(e)),r&&i.unsubscribe()},e=>{n=!0,t.error?.(e),r&&i.unsubscribe()});return r=!0,n&&i.unsubscribe(),i})}function Je(){return e=>new p(t=>e.subscribe(new Ye(t)))}class Ye{destination;last;hasLast=!1;constructor(e){this.destination=e}next(e){let t=this.last;if(this.last=e,!this.hasLast){this.hasLast=!0;return}this.destination.next([t,e])}error(e){this.destination.error?.(e)}}function Xe(e){return t=>new p(n=>t.subscribe(new Ze(n,e)))}class Ze{destination;effect;constructor(e,t){this.destination=e,this.effect=t}next(e){try{this.effect(e)}catch(e){throw this.error(e),e}this.destination.next(e)}error(e){this.destination.error?.(e)}}function Qe(e){return t=>new p(n=>t.subscribe(new $e(n,e)))}class $e{destination;count;constructor(e,t){this.destination=e,this.count=t,t<0&&this.destination.error?.(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)}}function et(e=0){return t=>{let n=0,r=new z(e),i=t.subscribe(r),a=e=>()=>{e.unsubscribe(),n--,n===0&&i.unsubscribe()};return new p(e=>(n++,a(r.subscribe(e))))}}var tt=300,nt=(e,t=tt)=>new p(n=>{let r=x(),{width:i,height:a}=e.getBoundingClientRect();if(n.next({width:i,height:a}),!S(r))return;let o=new r.ResizeObserver(L(e=>{let t=e[0];if(!t)return;let r,i;t.contentBoxSize&&t.contentBoxSize[0]?(i=t.contentBoxSize[0].blockSize,r=t.contentBoxSize[0].inlineSize):t.contentRect&&(r=t.contentRect.width,i=t.contentRect.height),g(r)&&g(i)&&n.next({width:r,height:i})},t));return o.observe(e),()=>o.disconnect()}),H=(e,t=6,n=`.`)=>{let r={};for(let i in e)if(!(!e.hasOwnProperty(i)||e[i]instanceof HTMLElement||!t))if(typeof e[i]==`object`&&e[i]!==null){let a=H(e[i],t-1);for(let e in a)a.hasOwnProperty(e)&&(r[i+n+e]=a[e])}else r[i]=e[i];return r},rt=(e,t=!1)=>{t&&(e.innerHTML=``),e.removeAttribute(`src`),e.load()},it=e=>{let t;try{t=new URL(e)}catch{return!1}return t.protocol===`https:`},at=(e,t)=>!(e.right<t.left||e.left>t.right||e.bottom<t.top||e.top>t.bottom),ot=(()=>{let e=0;return()=>{let t=e;return e=(e+1)%(2**53-1),t}})(),st=e=>e!==void 0&&e!==``?e:ot().toString();function ct(e,t,n){if(e<=t[0])return n[0];if(e>=t[t.length-1])return n[n.length-1];let r=1;for(;r<t.length&&t[r]<e;)r++;r>=t.length&&(r=t.length-1);let i=t[r-1],a=t[r],o=n[r-1],s=n[r];return e===i?o:e===a?s:o+(e-i)/(a-i)*(s-o)}function lt(e,t,n){if(e<=0||n<0)return[];let r=[],i=Math.floor((e-1)/2),a=Math.floor(e/2),o=t-i,s=t+a;o<0&&(s+=Math.abs(o),o=0),s>n&&(o-=s-n,s=n),o=Math.max(0,o),s=Math.min(n,s);for(let e=o;e<=s;e++)r.push(e);return r}var U=e=>e instanceof DOMException&&(e.name===`AbortError`||e.code===20),ut=e=>{if(!U(e))throw e},dt=e=>t=>n=>{let r=typeof n==`object`;n==null||r&&!Object.keys(n).length||e(t,r?H(n):{value:n})},W=(e={})=>{let t=e=>{let t=e;return e===void 0?t=`undefined`:e===null?t=`null`:(typeof e==`number`||typeof e==`boolean`)&&(t=e.toString()),t},n={};for(let r in e)Array.isArray(e[r])?n[r]=e[r].map(t):n[r]=t(e[r]);return n};class G{dynamicImportTimeout=5e3;span;context;childTracers=[];initPromise;static rootTracer;static dynamicImportStatus=`not_started`;static dynamicImports;static dynamicImportPromise;constructor({name:e,getParentContext:t}){G.dynamicImportStatus===`not_started`&&(G.dynamicImportPromise=this.loadOpentelemetry());let n=Date.now();this.initPromise=G.dynamicImportPromise.then(r=>{G.dynamicImportStatus===`completed`&&this.init({name:e,getParentContext:t},n)})}init({name:e,getParentContext:t},n){this.span=G.rootTracer.startSpan(e,{startTime:n},t?.()),this.context=G.dynamicImports.opentelemetryApi.trace.setSpan(G.dynamicImports.opentelemetryApi.context.active(),this.span)}async loadOpentelemetry(){if(G.dynamicImportStatus===`not_started`){G.dynamicImportStatus=`in_progress`;try{let e=new Promise((e,t)=>setTimeout(t,this.dynamicImportTimeout)),t=Promise.all([import(`@opentelemetry/api`),import(`@opentelemetry/sdk-trace-web`),import(`@apptracer/opentelemetry`)]),[n,r,i]=await Promise.race([t,e]);G.dynamicImports={opentelemetryApi:n,opentelemetrySdk:r,tracer:i},G.dynamicImportStatus=`completed`}catch{G.dynamicImportStatus=`failed`}}}isComponentTracerNotInitialized(){return _(this.span)||G.dynamicImportStatus===`failed`}log(e,t){let n=Date.now();this.initPromise.then(r=>{this.isComponentTracerNotInitialized()||this.span.addEvent(e,{...W(t),type:`log`},n)})}error(e,t){let n=Date.now();this.initPromise.then(r=>{this.isComponentTracerNotInitialized()||this.span.addEvent(e,{...W(t),type:`error`},n)})}critical(e,t){let n=Date.now();this.initPromise.then(r=>{this.isComponentTracerNotInitialized()||this.span.addEvent(e,{...W(t),type:`critical`},n)})}createComponentTracer(e){let t=new G({name:e,getParentContext:()=>this.context});return this.childTracers.push(t),t}end(){this.initPromise.then(e=>{this.isComponentTracerNotInitialized()||(this.childTracers.forEach(e=>e.end()),this.span.end())})}}class ft extends G{spanExporter;constructor(){super({name:`Root`})}init({name:e,getParentContext:t},n){let r=G.dynamicImports.tracer.initTracerOpenTelemetry({serviceName:`videoplayer-sdk-web`,appToken:`L9SBoka6ZWk4xPjaK7tmfSfYvMhcge7nvGDjpdMmscb`,spanLimits:{attributeCountLimit:1/0,eventCountLimit:1/0,attributePerEventCountLimit:1/0}}).getProvider(),i=new G.dynamicImports.tracer.TracerMemorySpanExporter;this.spanExporter=i,r.addSpanProcessor(new G.dynamicImports.tracer.TracerAllSpansProcessor({startedSpansExporter:i})),G.rootTracer=r.getTracer(`sdk-videoplayer-tracer`),super.init({name:e,getParentContext:t},n)}getFinishedSpans(){if(!this.isComponentTracerNotInitialized())return this.spanExporter?.getJsonData()}getTraceId(){return this.isComponentTracerNotInitialized()?``:this.span.spanContext().traceId}}class K{fakeTraceId;constructor(e){}log(e,t){}error(e,t){}critical(e,t){}createComponentTracer(e){return new K({name:e})}end(){}getFinishedSpans(){}getTraceId(){return this.fakeTraceId}}class pt{static createRootTracer(e=!1){return e?new ft:new K}}var q;(e=>{e.NETWORK=`network`,e.VIDEO_PIPELINE=`video_pipeline`,e.EXTERNAL_API=`external_api`,e.PARSER=`parser`,e.DOM=`dom`,e.WTF=`wtf`,e.FATAL=`fatal`})(q||={});var J;(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`})(J||={});var mt=`vk.com`,ht=async(e,t,n)=>{let r=new URL(`https://${mt}/js/lang-pack.js`);return r.searchParams.set(`format`,`json`),r.searchParams.set(`name`,t),e!==void 0&&r.searchParams.set(`lang`,e),gt(await(await fetch(r.toString())).json(),n)},gt=(e,t)=>Object.fromEntries(Object.entries(e.keys).map(([e,n])=>[e.substring(`${t}_`.length),_t(n)])),_t=e=>Array.isArray(e)?e[0]:e,Y;(e=>{e.RU=`ru`,e.EN=`en`})(Y||={});var X=`__vk_vp_internals_exposure`;class vt{playerId;type;constructor(e,t){this.playerId=t,this.type=e,this.initWindowObjects()}getWindowObject(){if(typeof window>`u`)return{};let e=this.playerId,t=this.type;return window[X]?.[e]?.[t]??{}}initWindowObjects(){if(typeof window>`u`)return;let e=this.playerId,t=this.type;window[X]||(window[X]={}),window[X][e]||(window[X][e]={}),window[X][e][t]||(window[X][e][t]={})}expose(e){typeof window>`u`||Object.assign(this.getWindowObject(),e)}destroy(){if(typeof window>`u`)return;let e=this.playerId,t=this.type;window[X]&&window[X][e]&&window[X][e][t]&&(delete window[X][e][t],Object.keys(window[X][e]).length||delete window[X][e],Object.keys(window[X]).length||delete window[X])}}var Z={};r(Z,{subscribe:()=>St,push:()=>xt,destroy:()=>bt,create:()=>yt});var Q=new Map,yt=(e,t)=>Q.set(e,t??[]),bt=e=>Q.delete(e),xt=(e,t)=>{let n=Q.get(e);n&&(typeof n==`function`?n(t):n.push(t))},St=(e,t)=>{let n=Q.get(e);if(n){if(n&&Array.isArray(n))for(let e of n)t(e);Q.set(e,t)}},Ct=`gW5EerTD5QhAnsbpF7Hd2NSMRteYIUUMjFbSyI68Pf5`,wt=e=>v({id:e.id,message:e.message,category:e.category,data:Tt(e.data),httpCode:e.httpCode,UVBackendErrorCode:e.UVBackendErrorCode});function Tt(e){switch(typeof e){case`boolean`:case`string`:case`number`:return e;case`object`:try{return JSON.stringify(e)}catch{return}default:return}}var Et=e=>{if(e.thrown instanceof Error)return e.thrown;let t=Error(e.message);return t.name=e.id,t},Dt=()=>{try{let{origin:e,pathname:t,search:n,hostname:r}=x().document.location;return r===`localhost`?void 0:{url:e+t,...new URLSearchParams(n).entries().reduce((e,[t,n])=>(e[`url.${t}`]=n,e),{})}}catch(e){console.error(e)}};class ${static tracerErrorMap=new Map;static appTracerModule=null;static loadPromise=null;dynamicImportTimeout=5e3;componentName;subscription=new s;options;envParams;context;constructor(e,t,n,r){this.componentName=e,this.options=t,this.envParams=n,this.context=r,this.options.enabled&&(this.loadModule(),this.init())}error(e,t){let{blackErrorCategoryList:n,blackErrorIdList:r,sampleRate:i,whiteErrorCategoryList:a,whiteErrorIdList:o}=this.options,{id:s,category:c}=e;n.length&&n.includes(c)||r.length&&r.includes(s)||a.length&&!a.includes(c)||o.length&&!o.includes(s)||Math.random()>=i||$.tracerErrorMap.get(this.componentName)?.error(Et(e),{severity:t?.severity??(e.traceAsLog?`debug`:void 0),keys:{...this.context,...wt(e),...Dt()}})}addSubscription(e){this.subscription.add(e)}destroy(){this.subscription.unsubscribe()}async init(){try{if(await $.loadPromise,$.tracerErrorMap.has(this.componentName)||_($.appTracerModule))return;let{appTracerModule:e}=$,{initTracerError:t,initTracerErrorUploader:n,addTracerPlugin:r,getTracerModules:i}=e,a=i(this.componentName),o=!a.error,s=a.error??t(this.componentName,{enableUnhandledErrorsListeners:!1,stringifyErrorDataObject:!0});o&&n(this.componentName,{appToken:Ct,environment:this.envParams.env,versionCode:1,versionName:this.envParams.version}),r(this.componentName,{name:`addedCategory`,errorBeforeAdd(e){let t=e.keys?.category??`wtf`;if(typeof t==`string`)return{issueKey:t}}}),$.tracerErrorMap.set(this.componentName,s)}catch{}}loadModule(){g($.loadPromise)||($.loadPromise=(async()=>{try{let e=new Promise((e,t)=>x().setTimeout(t,this.dynamicImportTimeout));$.appTracerModule=await Promise.race([e,import(`@apptracer/sdk/lite`)])}catch{$.loadPromise=null}})())}}export{v as withoutNullable,ge as videoSizeToQuality,_e as videoQualityToHeight,he as videoHeightToQuality,Ee as timeout,xe as timeCodeToString,L as throttleFn,Le as throttle,Xe as tap,ut as suppressAbort,Qe as skip,et as shareReplay,T as safeStorage,Je as pairwise,qe as once,nt as observeElementSize,Oe as observableFrom,w as now,u as noop,Te as merge,Ke as mapTo,V as map,ht as loadVKLangPack,it as isValidURL,_ as isNullable,g as isNonNullable,pe as isLowerOrEqual,M as isLower,P as isInvariantQuality,at as isIntersecting,fe as isHigherOrEqual,de as isHigher,S as isBrowserWindow,U as isAbortError,De as interval,ct as interpolate,x as getWindow,be as getVideoQualityLabel,dt as getTraceSubscriptionMethod,lt as getRangeAroundIndex,st as getPlayerId,me as getHighestQuality,re as getExponentialDelay,ke as fromEvent,H as flattenObject,Ue as filterChanged,ze as filter,F as fillWithDefault,Z as devNull,ue as detectEmbed,I as debounceFn,Pe as debounce,we as combine,R as cloneDeepWith,Se as cloneDeep,rt as clearVideoElement,l as checkNever,je as buffer,ye as assertQualityIsExact,te as assertNullable,y as assertNotEmptyArray,ee as assertNonNullable,c as assertNever,b as assertEmptyArray,ve as areQualitiesExact,C as addScript,ne as abortable,A as VideoQuality,Ce as ValueSubject,J as VKNumericLanguage,o as VERSION,pt as TracerFactory,Ae as SubscriptionRemovable,s as Subscription,m as Subject,z as ReplaySubject,p as Observable,h as Logger,vt as InternalsExposure,Y as InterfaceLanguage,X as INTERNAL_EXPOSE_GLOBAL_KEY,q as ErrorCategory,$ as AppTracer};
|
|
6
|
+
var e=Object.defineProperty,t=e=>e;function n(e,n){this[e]=t.bind(null,n)}var r=(t,r)=>{for(var i in r)e(t,i,{get:r[i],enumerable:!0,configurable:!0,set:n.bind(r,i)})},i=`1.0.85`;class a{subscriptions=[];unsubscribe(){let e=this.subscriptions;this.subscriptions=[],e.forEach(e=>{typeof e==`function`?e():e.unsubscribe()})}add(e){return this.subscriptions.push(e),this}}var o=e=>{throw Error(`${e} is value of unexpected type`)},s=e=>{},c=()=>{},l=e=>{throw console.error(e),e},u=e=>{console.error(e)};class d{suppressErrors=!1;constructor(e){e&&(this._subscribe=e)}setSuppressErrors(e){this.suppressErrors=e}subscribe(e,t){let n=this.suppressErrors?u:l,r;r=t?typeof t==`function`?{next:t,error:c}:{next:e=>t.next(e),error:e=>t.error?.(e)}:{next:n,error:c};let i=typeof e==`function`?{next:t=>{try{let n=e(t);n instanceof Promise&&n.catch(e=>r.next(e))}catch(e){r.next(e)}},error:e=>r.next(e)}:{next:t=>e.next(t),error:t=>e.error?e.error(t):r.next(t)},s;try{s=this._subscribe(i)}catch(e){i.error?.(e)}return new a().add(()=>{switch(i.next=c,i.error=c,typeof s){case`function`:s();return;case`object`:s.unsubscribe();return;case`undefined`:return;default:return o(s)}})}pipe(...e){return e.reduce((e,t)=>t(e),this)}_subscribe(e){}}class f extends d{keyCounter=0;subscribers=new Map;constructor(){super()}next(e){this.subscribers.forEach(t=>t.next(e))}error(e){this.subscribers.forEach(t=>t.error?.(e))}_subscribe(e){let t=this.keyCounter++;return this.subscribers.set(t,e),new a().add(()=>this.subscribers.delete(t))}}class p{log$=new f;logs=[];log=e=>{let t={...e,timestamp:Date.now()};this.logs.push(t),this.log$.next(t)};createCustomLog(e){return(...t)=>{let n;try{n=e(...t)}catch{n={message:"error in `createCustomLog`",component:`Logger`}}this.log(n)}}createComponentLog(e){return this.createCustomLog(t=>({component:e,...t}))}getAllLogs=()=>this.logs}function m(e,t=`Assertion "value is not nullable" failed`){if(e==null)throw Error(t)}function h(e,t=`Assertion "value is nullable" failed`){if(e!=null)throw Error(t)}function g(e){return e!=null}function _(e){return e==null}var v=e=>Object.fromEntries(Object.entries(e).filter(([e,t])=>g(t)));function y(e,t){if(!e?.length)throw Error(t)}function b(e,t){if(e?.length)throw Error(t)}var x=()=>globalThis,S=(e=x())=>!!(e.window&&e.screen),C=(e,t,n)=>new Promise((r,i)=>{t.addEventListener(`abort`,()=>{s(),l.remove()});let a=()=>{s(),i(`error`)},o=()=>{s(),r()},s=()=>{c&&clearTimeout(c),l.removeEventListener(`load`,o),l.removeEventListener(`error`,a)},c;n&&(c=x().setTimeout(()=>{s(),i(`timeout`)},n));let l=document.createElement(`script`);l.addEventListener(`load`,o),l.addEventListener(`error`,a),l.src=e,document.head.appendChild(l)}),w=typeof x().performance?.now==`function`?()=>x().performance.now():()=>Date.now(),T=()=>Math.trunc(w()),E=(e,t)=>async(...n)=>{let r=t(...n),i=e.aborted,a;for(;!i&&!e.aborted;)try{let e=await r.next(a);i=e.done??!1,a=e.value}catch(e){await r.throw(e)}return a},ee=(e,{start:t=0,factor:n=2,max:r=1/0,min:i=t,random:a=0}={})=>{let o=t;return o*=n**e,o*=1+(Math.random()*a*2-a),o=Math.round(o),o=Math.min(o,r),o=Math.max(o,i),o},D={};r(D,{set:()=>re,remove:()=>ae,isPersistent:()=>te,has:()=>ie,get:()=>ne,clear:()=>oe});var O,k,A=`vk-videoplayer-dummy-key-${Math.random()}`,j=()=>{if(k!==void 0)return k;try{localStorage.setItem(A,`test`),localStorage.removeItem(A),k=0}catch(e){if(e instanceof DOMException||e instanceof TypeError)try{sessionStorage.getItem(A),k=1}catch(e){if(e instanceof DOMException||e instanceof TypeError)k=2;else throw e}else throw e}return k===2&&(O=new Map),k},te=()=>j()===0,ne=e=>{let t=j();switch(t){case 0:return localStorage.getItem(e)??void 0;case 1:return sessionStorage.getItem(e)??void 0;case 2:return O?.get(e);default:o(t)}},re=(e,t)=>{let n=j();switch(n){case 0:try{localStorage.setItem(e,t)}catch(e){if(e instanceof DOMException)console.error(e);else throw e}break;case 1:try{sessionStorage.setItem(e,t)}catch(e){if(e instanceof DOMException)console.error(e);else throw e}break;case 2:O?.set(e,t);return;default:o(n)}},ie=e=>{let t=j();switch(t){case 0:return e in localStorage;case 1:return e in sessionStorage;case 2:return O?.has(e)??!1;default:return o(t),!1}},ae=e=>{let t=j();switch(t){case 0:return localStorage.removeItem(e);case 1:return sessionStorage.removeItem(e);case 2:O?.delete(e);return;default:o(t)}},oe=()=>{let e=j();switch(e){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return O?.clear();default:o(e)}},se=()=>{let e,t=[],n=x();try{e=n.self!==n.top}catch(t){t instanceof DOMException&&t.name===`SecurityError`?e=!0:(e=!1,console.error(t))}try{n.location?.ancestorOrigins&&(t=[...n.location.ancestorOrigins])}catch(e){console.error(e)}try{!t.length&&n.document.referrer&&(t=[new URL(n.document.referrer).origin])}catch(e){console.error(e)}return t=t.filter(e=>URL.canParse(e)),{isEmbed:e,origins:t,topOrigin:t.at(-1),immediateOrigin:t.at(0)}},ce;(e=>{e.INVARIANT=`Invariant quality`,e.Q_144P=`144p`,e.Q_240P=`240p`,e.Q_360P=`360p`,e.Q_480P=`480p`,e.Q_576P=`576p`,e.Q_720P=`720p`,e.Q_1080P=`1080p`,e.Q_1440P=`1440p`,e.Q_2160P=`2160p`,e.Q_4320P=`4320p`})(ce||={});var M={"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}},le=(e,t)=>M[e].height>M[t].height,ue=(e,t)=>M[e].height>=M[t].height,N=(e,t)=>M[e].height<M[t].height,de=(e,t)=>M[e].height<=M[t].height,fe=e=>e.sort((e,t)=>e===t?0:e===`Invariant quality`?1:t===`Invariant quality`?-1:N(e,t)?1:-1)[0],P=Object.keys(M).sort((e,t)=>N(e,t)?-1:1),pe=(e,t=.02)=>[...P].find(n=>M[n].height*(1+t)>=e),me=({width:e,height:t})=>{let n=Math.min(e,t),r=Math.max(e,t);return P.find(e=>{let t=M[e];return t.width>=r&&t.height>=n})},he=e=>M[e].height,F=e=>e===`Invariant quality`,ge=e=>e.every(e=>!F(e));function _e(e){if(F(e))throw Error(`Expected exact quality`)}var ve=e=>{switch(e){case`4320p`:return`8K`;case`2160p`:return`4K`;case`1440p`:return`QHD`;case`1080p`:return`FHD`;case`720p`:return`HD`;default:return``}},I=(e,t)=>{let n={};for(let r of Object.keys(t)){let i=t[r],a=e[r];Array.isArray(i)?n[r]=Array.isArray(a)?a:i:typeof i==`object`&&i?typeof a==`object`&&a&&!Array.isArray(a)?n[r]=I(a,i):n[r]=a??i:n[r]=r in e?a:i}return n},ye=e=>{let t=``;return e>=3600&&(t+=Math.floor(e/3600)+`h`,e%=3600),e>=60&&(t+=Math.floor(e/60)+`m`,e%=60),e>0&&(t+=Math.floor(e)+`s`),t};function L(e,t=0,n){let r,i,a,o,s,c,l=0,u=!1,d=!1,f=!0,p=!t&&t!==0&&typeof x().requestAnimationFrame==`function`;n&&(u=!!n.leading,d=`maxWait`in n,a=n?.maxWait?Math.max(+n?.maxWait||0,t):a,f=`trailing`in n?!!n.trailing:f);function m(t){let n=r,a=i;return r=i=void 0,l=t,o=e.apply(a,n),o}function h(e,t){return p?(s&&x().cancelAnimationFrame(s),x().requestAnimationFrame(e)):setTimeout(e,t)}function g(e){if(p){x().cancelAnimationFrame(e);return}clearTimeout(e)}function _(e){return l=e,s=h(b,t),u?m(e):o}function v(e){let n=e-c,r=e-l,i=t-n;return d?Math.min(i,a-r):i}function y(e){let n=e-c,r=e-l;return c===void 0||n>=t||n<0||d&&r>=a}function b(){let e=Date.now();if(y(e))return S(e);s=h(b,v(e))}function S(e){return s=void 0,f&&r?m(e):(r=i=void 0,o)}function C(){s!==void 0&&g(s),l=0,r=c=i=s=void 0}function w(){return s===void 0?o:S(Date.now())}function T(){return s!==void 0}function E(...e){let n=Date.now(),a=y(n);if(r=e,i=this,c=n,a){if(s===void 0)return _(c);if(d)return s=h(b,t),m(c)}return s===void 0&&(s=h(b,t)),o}return E.cancel=C,E.flush=w,E.pending=T,E}var R=(e,t=0,n)=>L(e,t,{leading:!0,trailing:!0,...n,maxWait:t}),z=(e,t)=>{if(typeof e!=`object`||!e)return e;let n=Array.isArray(e)?[]:{};for(let r in e){if(typeof t==`function`){let i=t(e[r],r,e,n);if(i!==void 0){n[r]=i;continue}}typeof e[r]==`object`?n[r]=z(e[r],t):n[r]=e[r]}return n},be=e=>z(e);class B extends f{bufferSize;buffer=[];cursorEnd=-1;cursorStart=0;constructor(e){super(),this.bufferSize=e,this.buffer=Array(e)}next(e){this.cursorEnd+=1,this.cursorStart=this.cursorEnd>=this.bufferSize?this.cursorStart+1:0,this.buffer[this.cursorEnd%this.bufferSize]=e,this.subscribers.forEach(t=>t.next(e))}_subscribe(e){for(let t=this.cursorStart;t<=this.cursorEnd;t++)e.next(this.buffer[t%this.bufferSize]);let t=this.keyCounter++;return this.subscribers.set(t,e),new a().add(()=>this.subscribers.delete(t))}}class xe extends f{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){let t=super._subscribe(e);return e.next(this.value),t}}function Se(e){return new d(t=>{let n={},r=Object.keys(e).length,i=e=>i=>{e in n||r--,n[e]=i,r===0&&t.next(n)};return Object.entries(e).reduce((e,[t,n])=>e.add(n.subscribe(i(t))),new a)})}function Ce(...e){return new d(t=>e.reduce((e,n)=>e.add(n.subscribe(t)),new a))}var we=e=>new d(t=>{let n=x().setTimeout(()=>{try{t.next()}catch(e){if(t.error)t.error(e);else throw e}},e);return()=>x().clearTimeout(n)}),Te=e=>new d(t=>{let n=x(),r=n.setInterval(()=>t.next(),e);return()=>{r&&=(n.clearInterval(r),void 0)}}),Ee=e=>new d(t=>{e.forEach(e=>t.next(e))}),De=(e,t)=>new d(n=>{let r=e=>n.next(e);return e.addEventListener(t,r),()=>e.removeEventListener(t,r)});class Oe extends a{remove(e){this.subscriptions=this.subscriptions.filter(t=>t!==e)}}function ke(e){return t=>new d(n=>t.subscribe(new Ae(n,e)))}class Ae{destination;size;lastValues=[];constructor(e,t){this.destination=e,this.size=t}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 je={leading:!1,trailing:!0};function Me(e,t=je){return n=>new d(r=>n.subscribe(new Ne(r,e,t)))}class Ne{destination;time;config;lastValue;timeout;constructor(e,t,n){this.destination=e,this.time=t,this.config=n}next(e){this.lastValue=e;let t=x();g(this.timeout)?t.clearTimeout(this.timeout):this.config.leading&&this.destination.next(e),this.timeout=t.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(e){if(this.destination.error)this.destination.error(e);else throw e}this.timeout=void 0},this.time)}error(e){this.destination.error?.(e)}}var Pe={leading:!0,trailing:!1};function Fe(e,t=Pe){return n=>new d(r=>n.subscribe(new Ie(r,e,t)))}class Ie{destination;time;config;lastValue;timeout;constructor(e,t,n){this.destination=e,this.time=t,this.config=n}next(e){this.lastValue=e,_(this.timeout)&&(this.config.leading&&this.destination.next(e),this.timeout=x().setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(e){this.destination.error?.(e)}}function Le(e){return t=>new d(n=>t.subscribe(new Re(n,e)))}class Re{destination;predicate;constructor(e,t){this.destination=e,this.predicate=t}next(e){let t;try{t=this.predicate(e)}catch(e){throw this.error(e),e}t&&this.destination.next(e)}error(e){this.destination.error?.(e)}}var ze=(e,t)=>{let n=(e,t)=>{let n=Object.keys(e);for(let r in t)if(!n.includes(r)||t[r]!==e[r])return!1;return!0};return n(e,t)&&n(t,e)},Be=(e,t)=>e instanceof Object&&t instanceof Object?ze(e,t):e===t;function Ve(e=Be){return t=>new d(n=>t.subscribe(new He(n,e)))}var V={};class He{destination;predicate;lastValue=V;constructor(e,t){this.destination=e,this.predicate=t}next(e){let t;try{t=this.lastValue===V||!this.predicate(this.lastValue,e),this.lastValue=e instanceof Object&&!Array.isArray(e)?{...e}:e}catch(e){throw this.error(e),e}t&&this.destination.next(e)}error(e){this.destination.error?.(e)}}function H(e){return t=>new d(n=>t.subscribe(new Ue(n,e)))}class Ue{destination;mapper;constructor(e,t){this.destination=e,this.mapper=t}next(e){let t;try{t=this.mapper(e)}catch(e){throw this.error(e),e}this.destination.next(t)}error(e){this.destination.error?.(e)}}function We(e){return H(()=>e)}function Ge(){return e=>new d(t=>{let n=!1,r=!1,i=e.subscribe(e=>{n||(n=!0,t.next(e)),r&&i.unsubscribe()},e=>{n=!0,t.error?.(e),r&&i.unsubscribe()});return r=!0,n&&i.unsubscribe(),i})}function Ke(){return e=>new d(t=>e.subscribe(new qe(t)))}class qe{destination;last;hasLast=!1;constructor(e){this.destination=e}next(e){let t=this.last;if(this.last=e,!this.hasLast){this.hasLast=!0;return}this.destination.next([t,e])}error(e){this.destination.error?.(e)}}function Je(e){return t=>new d(n=>t.subscribe(new Ye(n,e)))}class Ye{destination;effect;constructor(e,t){this.destination=e,this.effect=t}next(e){try{this.effect(e)}catch(e){throw this.error(e),e}this.destination.next(e)}error(e){this.destination.error?.(e)}}function Xe(e){return t=>new d(n=>t.subscribe(new Ze(n,e)))}class Ze{destination;count;constructor(e,t){this.destination=e,this.count=t,t<0&&this.destination.error?.(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)}}function Qe(e=0){return t=>{let n=0,r=new B(e),i=t.subscribe(r),a=e=>()=>{e.unsubscribe(),n--,n===0&&i.unsubscribe()};return new d(e=>(n++,a(r.subscribe(e))))}}var $e=300,et=(e,t=$e)=>new d(n=>{let r=x(),{width:i,height:a}=e.getBoundingClientRect();if(n.next({width:i,height:a}),!S(r))return;let o=new r.ResizeObserver(R(e=>{let t=e[0];if(!t)return;let r,i;t.contentBoxSize&&t.contentBoxSize[0]?(i=t.contentBoxSize[0].blockSize,r=t.contentBoxSize[0].inlineSize):t.contentRect&&(r=t.contentRect.width,i=t.contentRect.height),g(r)&&g(i)&&n.next({width:r,height:i})},t));return o.observe(e),()=>o.disconnect()}),U=(e,t=6,n=`.`)=>{let r={};for(let i in e)if(!(!e.hasOwnProperty(i)||e[i]instanceof HTMLElement||!t))if(typeof e[i]==`object`&&e[i]!==null){let a=U(e[i],t-1);for(let e in a)a.hasOwnProperty(e)&&(r[i+n+e]=a[e])}else r[i]=e[i];return r},tt=(e,t=!1)=>{t&&(e.innerHTML=``),e.removeAttribute(`src`),e.load()},nt=e=>{let t;try{t=new URL(e)}catch{return!1}return t.protocol===`https:`},rt=(e,t)=>!(e.right<t.left||e.left>t.right||e.bottom<t.top||e.top>t.bottom),it=(()=>{let e=0;return()=>{let t=e;return e=(e+1)%(2**53-1),t}})(),at=e=>e!==void 0&&e!==``?e:it().toString();function ot(e,t,n){if(e<=t[0])return n[0];if(e>=t[t.length-1])return n[n.length-1];let r=1;for(;r<t.length&&t[r]<e;)r++;r>=t.length&&(r=t.length-1);let i=t[r-1],a=t[r],o=n[r-1],s=n[r];return e===i?o:e===a?s:o+(e-i)/(a-i)*(s-o)}function st(e,t,n){if(e<=0||n<0)return[];let r=[],i=Math.floor((e-1)/2),a=Math.floor(e/2),o=t-i,s=t+a;o<0&&(s+=Math.abs(o),o=0),s>n&&(o-=s-n,s=n),o=Math.max(0,o),s=Math.min(n,s);for(let e=o;e<=s;e++)r.push(e);return r}var W=e=>e instanceof DOMException&&(e.name===`AbortError`||e.code===20),ct=e=>{if(!W(e))throw e},lt=e=>t=>n=>{let r=typeof n==`object`;n==null||r&&!Object.keys(n).length||e(t,r?U(n):{value:n})},G=(e={})=>{let t=e=>{let t=e;return e===void 0?t=`undefined`:e===null?t=`null`:(typeof e==`number`||typeof e==`boolean`)&&(t=e.toString()),t},n={};for(let r in e)Array.isArray(e[r])?n[r]=e[r].map(t):n[r]=t(e[r]);return n};class K{dynamicImportTimeout=5e3;span;context;childTracers=[];initPromise;static rootTracer;static dynamicImportStatus=`not_started`;static dynamicImports;static dynamicImportPromise;constructor({name:e,getParentContext:t}){K.dynamicImportStatus===`not_started`&&(K.dynamicImportPromise=this.loadOpentelemetry());let n=Date.now();this.initPromise=K.dynamicImportPromise.then(r=>{K.dynamicImportStatus===`completed`&&this.init({name:e,getParentContext:t},n)})}init({name:e,getParentContext:t},n){this.span=K.rootTracer.startSpan(e,{startTime:n},t?.()),this.context=K.dynamicImports.opentelemetryApi.trace.setSpan(K.dynamicImports.opentelemetryApi.context.active(),this.span)}async loadOpentelemetry(){if(K.dynamicImportStatus===`not_started`){K.dynamicImportStatus=`in_progress`;try{let e=new Promise((e,t)=>setTimeout(t,this.dynamicImportTimeout)),t=Promise.all([import(`@opentelemetry/api`),import(`@opentelemetry/sdk-trace-web`),import(`@apptracer/opentelemetry`)]),[n,r,i]=await Promise.race([t,e]);K.dynamicImports={opentelemetryApi:n,opentelemetrySdk:r,tracer:i},K.dynamicImportStatus=`completed`}catch{K.dynamicImportStatus=`failed`}}}isComponentTracerNotInitialized(){return _(this.span)||K.dynamicImportStatus===`failed`}log(e,t){let n=Date.now();this.initPromise.then(r=>{this.isComponentTracerNotInitialized()||this.span.addEvent(e,{...G(t),type:`log`},n)})}error(e,t){let n=Date.now();this.initPromise.then(r=>{this.isComponentTracerNotInitialized()||this.span.addEvent(e,{...G(t),type:`error`},n)})}critical(e,t){let n=Date.now();this.initPromise.then(r=>{this.isComponentTracerNotInitialized()||this.span.addEvent(e,{...G(t),type:`critical`},n)})}createComponentTracer(e){let t=new K({name:e,getParentContext:()=>this.context});return this.childTracers.push(t),t}end(){this.initPromise.then(e=>{this.isComponentTracerNotInitialized()||(this.childTracers.forEach(e=>e.end()),this.span.end())})}}class ut extends K{spanExporter;constructor(){super({name:`Root`})}init({name:e,getParentContext:t},n){let r=K.dynamicImports.tracer.initTracerOpenTelemetry({serviceName:`videoplayer-sdk-web`,appToken:`L9SBoka6ZWk4xPjaK7tmfSfYvMhcge7nvGDjpdMmscb`,spanLimits:{attributeCountLimit:1/0,eventCountLimit:1/0,attributePerEventCountLimit:1/0}}).getProvider(),i=new K.dynamicImports.tracer.TracerMemorySpanExporter;this.spanExporter=i,r.addSpanProcessor(new K.dynamicImports.tracer.TracerAllSpansProcessor({startedSpansExporter:i})),K.rootTracer=r.getTracer(`sdk-videoplayer-tracer`),super.init({name:e,getParentContext:t},n)}getFinishedSpans(){if(!this.isComponentTracerNotInitialized())return this.spanExporter?.getJsonData()}getTraceId(){return this.isComponentTracerNotInitialized()?``:this.span.spanContext().traceId}}class q{fakeTraceId;constructor(e){}log(e,t){}error(e,t){}critical(e,t){}createComponentTracer(e){return new q({name:e})}end(){}getFinishedSpans(){}getTraceId(){return this.fakeTraceId}}class dt{static createRootTracer(e=!1){return e?new ut:new q}}var J;(e=>{e.NETWORK=`network`,e.VIDEO_PIPELINE=`video_pipeline`,e.EXTERNAL_API=`external_api`,e.PARSER=`parser`,e.DOM=`dom`,e.WTF=`wtf`,e.FATAL=`fatal`})(J||={});var Y;(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`})(Y||={});var ft=`vk.com`,pt=async(e,t,n)=>{let r=new URL(`https://${ft}/js/lang-pack.js`);return r.searchParams.set(`format`,`json`),r.searchParams.set(`name`,t),e!==void 0&&r.searchParams.set(`lang`,e),mt(await(await fetch(r.toString())).json(),n)},mt=(e,t)=>Object.fromEntries(Object.entries(e.keys).map(([e,n])=>[e.substring(`${t}_`.length),ht(n)])),ht=e=>Array.isArray(e)?e[0]:e,X;(e=>{e.RU=`ru`,e.EN=`en`})(X||={});var Z=`__vk_vp_internals_exposure`;class gt{playerId;type;constructor(e,t){this.playerId=t,this.type=e,this.initWindowObjects()}getWindowObject(){if(typeof window>`u`)return{};let e=this.playerId,t=this.type;return window[Z]?.[e]?.[t]??{}}initWindowObjects(){if(typeof window>`u`)return;let e=this.playerId,t=this.type;window[Z]||(window[Z]={}),window[Z][e]||(window[Z][e]={}),window[Z][e][t]||(window[Z][e][t]={})}expose(e){typeof window>`u`||Object.assign(this.getWindowObject(),e)}destroy(){if(typeof window>`u`)return;let e=this.playerId,t=this.type;window[Z]&&window[Z][e]&&window[Z][e][t]&&(delete window[Z][e][t],Object.keys(window[Z][e]).length||delete window[Z][e],Object.keys(window[Z]).length||delete window[Z])}}var _t={};r(_t,{subscribe:()=>xt,push:()=>bt,destroy:()=>yt,create:()=>vt});var Q=new Map,vt=(e,t)=>Q.set(e,t??[]),yt=e=>Q.delete(e),bt=(e,t)=>{let n=Q.get(e);n&&(typeof n==`function`?n(t):n.push(t))},xt=(e,t)=>{let n=Q.get(e);if(n){if(n&&Array.isArray(n))for(let e of n)t(e);Q.set(e,t)}},St=`gW5EerTD5QhAnsbpF7Hd2NSMRteYIUUMjFbSyI68Pf5`,Ct=e=>v({id:e.id,message:e.message,category:e.category,data:wt(e.data),httpCode:e.httpCode,UVBackendErrorCode:e.UVBackendErrorCode});function wt(e){switch(typeof e){case`boolean`:case`string`:case`number`:return e;case`object`:try{return JSON.stringify(e)}catch{return}default:return}}var Tt=e=>{if(e.thrown instanceof Error)return e.thrown.name=e.id,e.thrown;let t=Error(e.message);return t.name=e.id,t},Et=()=>{try{let{origin:e,pathname:t,search:n,hostname:r}=x().document.location;return r===`localhost`?void 0:{url:e+t,...new URLSearchParams(n).entries().reduce((e,[t,n])=>(e[`url.${t}`]=n,e),{})}}catch(e){console.error(e)}};class ${static tracerErrorMap=new Map;static appTracerModule=null;static loadPromise=null;dynamicImportTimeout=5e3;componentName;subscription=new a;options;envParams;context;constructor(e,t,n,r){this.componentName=e,this.options=t,this.envParams=n,this.context=r,this.options.enabled&&(this.loadModule(),this.init())}error(e,t){let{blackErrorCategoryList:n,blackErrorIdList:r,sampleRate:i,whiteErrorCategoryList:a,whiteErrorIdList:o}=this.options,{id:s,category:c}=e;n.length&&n.includes(c)||r.length&&r.includes(s)||a.length&&!a.includes(c)||o.length&&!o.includes(s)||Math.random()>=i||$.tracerErrorMap.get(this.componentName)?.error(Tt(e),{severity:t?.severity??(e.traceAsLog?`debug`:void 0),keys:{...this.context,...Ct(e),...Et()}})}addSubscription(e){this.subscription.add(e)}destroy(){this.subscription.unsubscribe()}async init(){try{if(await $.loadPromise,$.tracerErrorMap.has(this.componentName)||_($.appTracerModule))return;let{appTracerModule:e}=$,{initTracerError:t,initTracerErrorUploader:n,addTracerPlugin:r,getTracerModules:i}=e,a=i(this.componentName),o=!a.error,s=a.error??t(this.componentName,{enableUnhandledErrorsListeners:!1,stringifyErrorDataObject:!0});o&&n(this.componentName,{appToken:St,environment:this.envParams.env,versionCode:1,versionName:this.envParams.version}),r(this.componentName,{name:`addedCategory`,errorBeforeAdd(e){let t=e.keys?.category??`wtf`;if(typeof t==`string`)return{issueKey:t}}}),$.tracerErrorMap.set(this.componentName,s)}catch{}}loadModule(){g($.loadPromise)||($.loadPromise=(async()=>{try{let e=new Promise((e,t)=>x().setTimeout(t,this.dynamicImportTimeout));$.appTracerModule=await Promise.race([e,import(`@apptracer/sdk/lite`)])}catch{$.loadPromise=null}})())}}export{v as withoutNullable,me as videoSizeToQuality,he as videoQualityToHeight,pe as videoHeightToQuality,we as timeout,ye as timeCodeToString,R as throttleFn,Fe as throttle,Je as tap,ct as suppressAbort,Xe as skip,Qe as shareReplay,D as safeStorage,Ke as pairwise,Ge as once,et as observeElementSize,Ee as observableFrom,T as nowInt,w as now,c as noop,Ce as merge,We as mapTo,H as map,pt as loadVKLangPack,nt as isValidURL,_ as isNullable,g as isNonNullable,de as isLowerOrEqual,N as isLower,F as isInvariantQuality,rt as isIntersecting,ue as isHigherOrEqual,le as isHigher,S as isBrowserWindow,W as isAbortError,Te as interval,ot as interpolate,x as getWindow,ve as getVideoQualityLabel,lt as getTraceSubscriptionMethod,st as getRangeAroundIndex,at as getPlayerId,fe as getHighestQuality,ee as getExponentialDelay,De as fromEvent,U as flattenObject,Ve as filterChanged,Le as filter,I as fillWithDefault,_t as devNull,se as detectEmbed,L as debounceFn,Me as debounce,Se as combine,z as cloneDeepWith,be as cloneDeep,tt as clearVideoElement,s as checkNever,ke as buffer,_e as assertQualityIsExact,h as assertNullable,y as assertNotEmptyArray,m as assertNonNullable,o as assertNever,b as assertEmptyArray,ge as areQualitiesExact,C as addScript,E as abortable,ce as VideoQuality,xe as ValueSubject,Y as VKNumericLanguage,i as VERSION,dt as TracerFactory,Oe as SubscriptionRemovable,a as Subscription,f as Subject,B as ReplaySubject,d as Observable,p as Logger,gt as InternalsExposure,X as InterfaceLanguage,Z as INTERNAL_EXPOSE_GLOBAL_KEY,J as ErrorCategory,$ as AppTracer};
|
|
7
7
|
//# sourceMappingURL=evergreen.esm.js.map
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
package/types/utils/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export type { Nullable } from "./nullable";
|
|
|
5
5
|
export { assertNotEmptyArray, assertEmptyArray } from "./empty";
|
|
6
6
|
export { addScript } from "./addScript";
|
|
7
7
|
export type { Milliseconds, bps, Byte, Seconds, Kbps, Mbps, Percentage } from "./semanticTypes";
|
|
8
|
-
export { now } from "./now";
|
|
8
|
+
export { now, nowInt } from "./now";
|
|
9
9
|
export { abortable } from "./abortable";
|
|
10
10
|
export { getExponentialDelay } from "./exponentialBackoff";
|
|
11
11
|
export type { ExponentialBackoffConfig } from "./exponentialBackoff";
|
package/types/utils/now.d.ts
CHANGED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Защита Svelte 5 runtime от перезаписи глобальных DOM-конструкторов.
|
|
3
|
-
*
|
|
4
|
-
* Проблема: на vk.com сторонний код (GraphQL operations) перезаписывает
|
|
5
|
-
* `globalThis.Comment` объектом `{ onDone: ... }`. Svelte runtime использует
|
|
6
|
-
* `value instanceof Comment` для определения типа DOM-нод, и падает с
|
|
7
|
-
* "TypeError: Illegal invocation" / "Right-hand side of instanceof is not callable".
|
|
8
|
-
*
|
|
9
|
-
* Решение: сохраняем ссылки на нативные DOM-конструкторы при загрузке модуля
|
|
10
|
-
* (до того как их перезапишут), и в `__svelte_safe_instanceof` подставляем
|
|
11
|
-
* нативный конструктор вместо перезаписанного.
|
|
12
|
-
*
|
|
13
|
-
* ВАЖНО: должен загружаться ДО любого Svelte-модуля (через shared → первый в графе зависимостей).
|
|
14
|
-
*/
|
|
15
|
-
export {};
|