@vkontakte/videoplayer-statistics 1.0.44-beta.1 → 1.0.45-dev.41346c2e.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/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 +5 -0
- package/package.json +3 -3
package/esnext.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-statistics v1.0.
|
|
3
|
-
* Wed,
|
|
4
|
-
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-
|
|
2
|
+
* @vkontakte/videoplayer-statistics v1.0.45-dev.41346c2e.0
|
|
3
|
+
* Wed, 07 Feb 2024 10:07:59 GMT
|
|
4
|
+
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-45/doc/
|
|
5
5
|
*/
|
|
6
|
-
import{fillWithDefault as fe,ValueSubject as I,getExponentialDelay as ge,ErrorCategory as b,now as p,safeStorage as y,assertNever as ne,Observable as pe,Subscription as D,merge as R,fromEvent as z,filterChanged as me,map as be,filter as Y,Subject as k,isNullable as F,Logger as Se,isNonNullable as x,once as _e,combine as X,observableFrom as Ee,assertNonNullable as Ae}from"@vkontakte/videoplayer-shared/esnext.esm.js";import J from"lodash/debounce.js";import{Surface as $,VideoQuality as S,HttpConnectionType as H,VideoFormat as f,PlaybackState as Z}from"@vkontakte/videoplayer-core/esnext.esm.js";var _;(function(t){t.PROD="prod",t.VK_ALIAS="vk_alias",t.VIDEOTEST="videotest",t.TEST="test",t.AUTO="auto"})(_||(_={}));var m;(function(t){t.Q144P="mobile",t.Q240P="lowest",t.Q360P="low",t.Q480P="medium",t.Q720P="high",t.Q1080P="fullhd",t.Q1440P="quadhd",t.Q2160P="ultrahd",t.UNKNOWN="unknown"})(m||(m={}));var g;(function(t){t.MP4="mp4",t.DASH="dash",t.DASH_SEP="dash_sep",t.ONDEMAND_DASH="ondemand_dash",t.HLS="hls",t.ONDEMAND_HLS="ondemand_hls",t.WEBM="webm",t.AV1="av1",t.ONDEMAND_DASH_LIVE="ondemand_dash_live",t.ONDEMAND_HLS_LIVE="ondemand_hls_live",t.WEBRTC="webrtc",t.UNKNOWN="unknown",t.RTMP="rtmp"})(g||(g={}));var B;(function(t){t.AUTO="auto",t.MANUAL=""})(B||(B={}));var N;(function(t){t.HTTP1="http1",t.HTTP2="http2",t.HTTP3="http3"})(N||(N={}));var E;(function(t){t[t.YES=1]="YES",t[t.NO=0]="NO"})(E||(E={}));var O;(function(t){t.EXCELLENT="excellent",t.GOOD="good",t.POOR="poor"})(O||(O={}));var T;(function(t){t.PIP="pip",t.FULLSCREEN="fullscreen",t.EXTERNAL="external",t.PREFETCH="prefetch",t.AIRPLAY="airplay",t.CHROMECAST="chromecast",t.INVISIBLE="invisible"})(T||(T={}));var U;(function(t){t.SLIDER="slider",t.DOUBLE_TAP="double_tap",t.TIME_CODE="time_code",t.EPISODE="episode",t.REWIND="rewind",t.LIVE="live",t.UNKNOWN="unknown"})(U||(U={}));var ee;(function(t){t.GRAPH_SHOW="iGraphShow",t.GRAPH_HIDE="iGraphHide",t.NEXT_AREA="iNextChapterArea",t.NEXT_BUTTON="iNextChapterBtn",t.WATCH_AGAIN="iWatchAgainBtn"})(ee||(ee={}));const we={action_play:"ap",first_bytes:"fb",player_ready:"pr",first_frame:"ff",seek:"sk",watch_coverage_record:"wr",watch_coverage_live:"wl",empty_buffer:"eb",action_stop:"as",close_at_empty_buffer:"cb",content_error:"er",player_interface_click:"pc",next_movie:"nm",track_switch:"ts"},ye={vsid:"si",vid:"vi",place:"pl",quality:"qt",cdn_host:"ch",stat_type:"st",param:"pm",vk_app_id:"va",track_code:"tc",connection_type:"cnt",connection_reused:"cr",cached_data:"cd",live:"lv",muted:"mu",mode:"mo",subtitles:"sb",failover:"fo",download_speed:"ds",manual_quality:"mq",ref_domain:"rd",direct_url:"du"},ve={unknown:"un",mobile:"m",lowest:"ls",low:"l",medium:"md",high:"h",fullhd:"f",quadhd:"q",ultrahd:"u"},Pe={pip:"pi",fullscreen:"fs",external:"ex",prefetch:"pr",airplay:"ap",chromecast:"cc",invisible:"iv"},Te={apiEnv:_.VK_ALIAS,requestRetryCount:1,firstFlushTime:5e3,flushDebounceTime:1e4,flushMaxWait:6e4,storageExpiration:36*60*60*1e3,watchCoverageInterval:15e3,disabledOperations:[],disabledCustomFields:[],shorten:!0,embedUrlParams:[],useBeacon:!0,synchronizeTime:!0,debugLog:!1,backoff:{start:1e3,factor:1.5,max:5*60*1e3,random:.1}},xe=t=>fe(t,Te);function Oe(){const t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),e=new Array(36);let i=0,s,o;for(o=0;o<36;o++)o===8||o===13||o===18||o===23?e[o]="-":o===14?e[o]="4":(i<=2&&(i=33554432+Math.random()*16777216|0),s=i&15,i=i>>4,e[o]=t[o===19?s&3|8:s]);return e.join("")}const Le=t=>{const{operation:e,custom:i}=t,s=Object.fromEntries(Object.entries(i).map(([o,n])=>{const a=ye[o]??o;let l=n;return n&&(o==="mode"?l=Pe[n]??n:o==="quality"&&(l=ve[n]??n)),[a,l]}));return{...t,operation:we[e]??e,custom:s}},te="1.0.44-beta.1",$e="CIOPGQJGDIHBABABA",se={[_.PROD]:"https://api.ok.ru",[_.VK_ALIAS]:"https://api.mycdn.me",[_.VIDEOTEST]:"https://videotestapi.ok.ru/api",[_.TEST]:"https://apitest.ok.ru",[_.AUTO]:""};var P;(function(t){t[t.PARAM_SESSION_EXPIRED=102]="PARAM_SESSION_EXPIRED",t[t.PARAM_SESSION_KEY=103]="PARAM_SESSION_KEY",t[t.PARAM_SIGNATURE=104]="PARAM_SIGNATURE",t[t.AUTH_LOGIN=401]="AUTH_LOGIN"})(P||(P={}));class Ne{params;authToken;sessionKey;authorizePromise;refreshAuthTokenPromise;consequentAuthErrors=0;authorized$=new I(!1);backoffTimeoutId;constructor(e){this.params=e}async authorize(e){return this.authToken=e??await this.refreshAuthToken(),this._authorizeWithBackoff()}logBeacon(e){const i="log.externalLog",s=this.createLogParams(e),o=this.sessionKey;if(!o)return;this.params.apiTransport.sendBeacon(i,s,o)||this.logRequest(e)}async logRequest(e){const i="log.externalLog",s=this.createLogParams(e),o=this.sessionKey??await this._authorizeWithBackoff();if(!o)return;const n=async(a,l=this.params.config.requestRetryCount)=>{try{return await this.params.apiTransport.sendRequest(i,s,o)}catch(u){if(!u||!("error_code"in u)){this.params.error$.next({id:"logRequestUnknown",category:b.NETWORK,message:`Unknown ${i} error`,thrown:u});return}const h=u?.error_code;switch(h){case P.PARAM_SESSION_EXPIRED:case P.PARAM_SESSION_KEY:case P.PARAM_SIGNATURE:return this.authorized$.next(!1),this.sessionKey=await this._authorizeWithBackoff(),l>0?n(a,l-1):void 0;case P.AUTH_LOGIN:return this.authorized$.next(!1),this.authToken=await this.refreshAuthToken(),this.sessionKey=await this._authorizeWithBackoff(),l>0?n(a,l-1):void 0;default:{this.params.error$.next({id:`LogRequest#${h}`,category:b.EXTERNAL_API,message:`${i} error`,data:u});return}}}};return n(e)}destroy(){window.clearTimeout(this.backoffTimeoutId),this.backoffTimeoutId=0}async refreshAuthToken(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=this.params.refreshAuthToken().finally(()=>{this.refreshAuthTokenPromise=void 0})),this.refreshAuthTokenPromise}createLogParams(e){return{collector:"ok.mobile.apps.video",data:JSON.stringify({application:`@vkontakte/videoplayer-statistics:${te}`,platform:this.params.mobile?"M_WEB":"WEB",items:this.params.config.shorten?e.map(Le):e})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();const e=ge(this.consequentAuthErrors,this.params.config.backoff);return new Promise(i=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout(()=>{this._authorize().then(i).catch(s=>this.params.error$.next({id:"AuthorizeBackoff",category:b.NETWORK,message:"Otherwise unhandled error in authorization",thrown:s})).finally(()=>this.backoffTimeoutId=0)},e))})}async _authorize(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);const e="auth.anonymLogin",i={session_data:{version:2,device_id:this.params.uuid,client_version:te.split("-")[0],client_type:"SDK_JS"}};return this.authToken!==void 0&&(i.session_data.auth_token=this.authToken,i.session_data.version=3),this.authorizePromise=this.params.apiTransport.sendRequest(e,i).then(s=>((!s||!s.session_key)&&this.params.error$.next({id:"AuthorizeFailed",category:b.EXTERNAL_API,message:"No session key",data:s}),this.sessionKey=s?.session_key??void 0,this.sessionKey)).catch(async s=>{this.sessionKey=void 0;const o=s?.error_code;switch(o){case P.AUTH_LOGIN:return this.authToken=await this.refreshAuthToken(),this._authorizeWithBackoff()}o?this.params.error$.next({id:`Authorize#${o}`,category:b.EXTERNAL_API,message:"authorize error",data:s}):this.params.error$.next({id:"AuthorizeUnknown",category:b.NETWORK,message:"authorize error",thrown:s})}).finally(()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(this.sessionKey!==void 0)}),this.authorizePromise}}class ie{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(e,i,s){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:i,options:s})}removeEventListener(e,i){if(!(e in this.listeners))return;const s=this.listeners[e];for(let o=0,n=s.length;o<n;o++)if(s[o].callback===i){s.splice(o,1);return}}dispatchEvent(e){if(!(e.type in this.listeners))return;const s=this.listeners[e.type].slice();for(let o=0,n=s.length;o<n;o++){const a=s[o];try{a.callback.call(this,e)}catch(l){Promise.resolve().then(()=>{throw l})}a.options&&a.options.once&&this.removeEventListener(e.type,a.callback)}return!e.defaultPrevented}}class ae extends ie{constructor(){super(),this.listeners||ie.call(this),Object.defineProperty(this,"aborted",{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,"onabort",{value:null,writable:!0,configurable:!0}),Object.defineProperty(this,"reason",{value:void 0,writable:!0,configurable:!0})}toString(){return"[object AbortSignal]"}dispatchEvent(e){e.type==="abort"&&(this.aborted=!0,typeof this.onabort=="function"&&this.onabort.call(this,e)),super.dispatchEvent(e)}}class Ce{constructor(){Object.defineProperty(this,"signal",{value:new ae,writable:!0,configurable:!0})}abort(e){let i;try{i=new Event("abort")}catch{typeof document<"u"?document.createEvent?(i=document.createEvent("Event"),i.initEvent("abort",!1,!1)):(i=document.createEventObject(),i.type="abort"):i={type:"abort",bubbles:!1,cancelable:!1}}let s=e;if(s===void 0)if(typeof document>"u")s=new Error("This operation was aborted"),s.name="AbortError";else try{s=new DOMException("signal is aborted without reason")}catch{s=new Error("This operation was aborted"),s.name="AbortError"}this.signal.reason=s,this.signal.dispatchEvent(i)}toString(){return"[object AbortController]"}}typeof Symbol<"u"&&Symbol.toStringTag&&(Ce.prototype[Symbol.toStringTag]="AbortController",ae.prototype[Symbol.toStringTag]="AbortSignal");function ce(t){return t.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill"),!0):typeof t.Request=="function"&&!t.Request.prototype.hasOwnProperty("signal")||!t.AbortController}function Re(t){typeof t=="function"&&(t={fetch:t});const{fetch:e,Request:i=e.Request,AbortController:s,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o=!1}=t;if(!ce({fetch:e,Request:i,AbortController:s,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o}))return{fetch:e,Request:n};let n=i;(n&&!n.prototype.hasOwnProperty("signal")||o)&&(n=function(h,r){let c;r&&r.signal&&(c=r.signal,delete r.signal);const d=new i(h,r);return c&&Object.defineProperty(d,"signal",{writable:!1,enumerable:!1,configurable:!0,value:c}),d},n.prototype=i.prototype);const a=e;return{fetch:(u,h)=>{const r=n&&n.prototype.isPrototypeOf(u)?u.signal:h?h.signal:void 0;if(r){let c;try{c=new DOMException("Aborted","AbortError")}catch{c=new Error("Aborted"),c.name="AbortError"}if(r.aborted)return Promise.reject(c);const d=new Promise((A,v)=>{r.addEventListener("abort",()=>v(c),{once:!0})});return h&&h.signal&&delete h.signal,Promise.race([d,a(u,h)])}return a(u,h)},Request:n}}const Q=ce({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),ue=Q?Re({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,oe=Q?ue.fetch:window.fetch;Q?ue.Request:window.Request;class ke{apiKey;apiBaseUrl;apiEnv;timeSynchronisation;isApiBaseUrlFetched;params;constructor(e){this.params=e,this.apiKey=e.apiKey,this.apiEnv=e.config.apiEnv,this.apiBaseUrl=se[this.apiEnv],this.timeSynchronisation=e.timeSynchronisation,this.isApiBaseUrlFetched=!1}async resolveApiBaseUrl(){if(this.apiEnv!==_.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const e=atob("aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ="),o=(await(await oe(e,{method:"GET",mode:"cors",cache:"no-cache"})).json())?.Answer[0]?.data;if(!o)throw new Error("Wrong DNS response");return o}catch(e){return this.params.error$.next({id:"OneStat:ApiTransport:resolveApiBaseUrl",category:b.NETWORK,message:"Unhandled resolve api base url error",thrown:e}),se[_.VK_ALIAS]}finally{this.isApiBaseUrlFetched=!0}}sendBeacon(e,i,s){if(!window.Blob||!window.navigator.sendBeacon)return!1;const o=this._prepareQueryParams({method:e,queryParams:i,sessionKey:s}),n=new window.Blob([o.toString()],{type:"application/x-www-form-urlencoded"});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,n)}catch(a){this.params.error$.next({id:"OneStat:ApiTransport:sendBeacon",category:b.NETWORK,message:"Unhandled beacon error",thrown:a,data:{method:e,params:i}})}return!1}async sendRequest(e,i,s){const o=p(),n=a=>{if(a instanceof TypeError&&["Failed to fetch","NetworkError when attempting to fetch resource."].includes(a.message)){this.params.error$.next({id:"Network",category:b.NETWORK,message:"Request failed",thrown:a});return}this.params.error$.next({id:"OneStat:ApiTransport:sendRequest",category:b.NETWORK,message:"Unhandled request error",thrown:a,data:{method:e,params:i,sessionKey:s,time:p()-o}})};return this.apiBaseUrl=await this.resolveApiBaseUrl(),oe(`${this.apiBaseUrl}/fb.do`,{method:"post",headers:{"Content-type":"application/x-www-form-urlencoded"},body:this._prepareQueryParams({method:e,queryParams:i,sessionKey:s})}).then(a=>{const l=Number(a.headers.get("content-length"))===0,u=new Date(a.headers.get("date")??"").getTime(),h=p()-o;if(isFinite(u)&&this.timeSynchronisation?.addServerTime(u,h),!l)return a.json().then(r=>Object.prototype.hasOwnProperty.call(r,"error_msg")?Promise.reject(r):r,n)},n)}_prepareQueryParams(e){const i=new URLSearchParams({format:"JSON",method:e.method,application_key:this.apiKey});return e.sessionKey!==void 0&&i.append("session_key",e.sessionKey),Object.entries(e.queryParams).forEach(([s,o])=>i.append(s,typeof o=="string"?o:JSON.stringify(o))),i}}const C="onestat_events",M=t=>e=>e.timestamp+t>=p();class Ie{params;api;error$;subscription;userSalt;unsaltedStorage=[];lastVsid;isPaused=!1;firstFlush;debouncedFlush;loggerDebugLog;constructor(e){this.params=e,this.api=e.api,this.error$=e.error$,this.userSalt=e.userSalt,this.loggerDebugLog=e.debugLogger.createComponentLog("stat logger"),this.firstFlush=J(()=>this.safeFlush(),this.params.config.firstFlushTime,{maxWait:this.params.config.firstFlushTime});const i=y.isPersistent()?this.params.config.flushMaxWait:0;this.debouncedFlush=J(()=>this.safeFlush(),this.params.config.flushDebounceTime,{maxWait:i}),this.subscription=this.api.authorized$.subscribe(s=>{s&&this.debouncedFlush()}),this.housekeepStorage()}isUrgent=e=>{const{operation:i,custom:{param:s}}=e;return["action_stop","close_at_empty_buffer"].includes(i)||i==="watch_coverage_record"&&s==="0-0"};safeFlush(){try{this.flush()}catch(e){this.error$.next({id:"LoggerError",category:b.WTF,message:String(e)??"Unknown logger error",thrown:e})}}readFromStorage(){const e=y.get(C);try{return e?JSON.parse(e):{}}catch{}return{}}addToStorage(e){if(!this.userSalt){this.unsaltedStorage.push(e);return}const i=this.readFromStorage(),o=(i[this.userSalt]??[]).filter(M(this.params.config.storageExpiration));y.set(C,JSON.stringify({...i,[this.userSalt]:[...o,e]}))}getFromStorage(){return this.userSalt?(this.readFromStorage()[this.userSalt]??[]).filter(M(this.params.config.storageExpiration)):this.unsaltedStorage}markStorageSent(){if(!this.userSalt){this.unsaltedStorage=[];return}const e=this.readFromStorage();delete e[this.userSalt],y.set(C,JSON.stringify(e))}housekeepStorage(){const e=this.readFromStorage();for(const[i,s]of Object.entries(e)){const o=s.filter(M(this.params.config.storageExpiration));o.length?e[i]=o:delete e[i],this.loggerDebugLog({message:`${s.length} retrieved from storage, ${o.length} of them actual`})}y.set(C,JSON.stringify(e))}log(e){this.addToStorage(e),!this.isPaused&&(this.isUrgent(e)?this.flush():this.lastVsid!==e.custom.vsid?this.firstFlush():this.debouncedFlush(),this.lastVsid=e.custom.vsid)}flush(e=!1){const i=this.getFromStorage();i.length!==0&&(this.api.authorized$.getValue()?(e&&this.params.config.useBeacon?(this.loggerDebugLog({message:`Flushing ${i.length} events through beacon`}),this.api.logBeacon(i)):(this.loggerDebugLog({message:`Flushing ${i.length} events`}),this.api.logRequest(i)),this.markStorageSent()):this.api.authorize(),this.firstFlush.cancel(),this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}destroy(){this.subscription.unsubscribe(),this.firstFlush.cancel(),this.debouncedFlush.cancel()}}const De=()=>{let t,e;try{t=window.self!==window.top}catch(s){s instanceof DOMException&&s.name==="SecurityError"?t=!0:(t=!1,console.error(s))}try{window.location.ancestorOrigins&&(e=window.location.ancestorOrigins[window.location.ancestorOrigins.length-1])}catch(s){console.error(s)}try{!e&&document.referrer&&(e=document.referrer)}catch(s){console.error(s)}const i=e?new URL(e).hostname:void 0;return{isEmbed:t,host:i}},Fe=t=>t&&{[S.INVARIANT]:m.UNKNOWN,[S.Q_144P]:m.Q144P,[S.Q_240P]:m.Q240P,[S.Q_360P]:m.Q360P,[S.Q_480P]:m.Q480P,[S.Q_720P]:m.Q720P,[S.Q_1080P]:m.Q1080P,[S.Q_1440P]:m.Q1440P,[S.Q_2160P]:m.Q2160P,[S.Q_4320P]:m.UNKNOWN}[t],re=t=>t&&{[H.HTTP1]:N.HTTP1,[H.HTTP2]:N.HTTP2,[H.QUIC]:N.HTTP3}[t],Be=t=>{if(t!==void 0)switch(t){case f.MPEG:return g.MP4;case f.DASH:case f.DASH_LIVE:return g.DASH;case f.DASH_SEP:return g.DASH_SEP;case f.DASH_ONDEMAND:return g.ONDEMAND_DASH;case f.DASH_WEBM:case f.DASH_LIVE_WEBM:return g.WEBM;case f.DASH_WEBM_AV1:return g.AV1;case f.DASH_LIVE_CMAF:return g.ONDEMAND_DASH_LIVE;case f.HLS:case f.HLS_LIVE:return g.HLS;case f.HLS_ONDEMAND:return g.ONDEMAND_HLS;case f.HLS_LIVE_CMAF:return g.ONDEMAND_HLS_LIVE;case f.WEB_RTC_LIVE:return g.WEBRTC;default:return ne(t)}},W=t=>{if(t!==void 0)switch(t){case $.NONE:case $.INLINE:return;case $.FULLSCREEN:return T.FULLSCREEN;case $.SECOND_SCREEN:return T.CHROMECAST;case $.PIP:return T.PIP;default:return ne(t)}},Ue=t=>{switch(t){case"slow-2g":return O.POOR;case"2g":return O.POOR;case"3g":return O.GOOD;case"4g":return O.EXCELLENT}};class qe{offset=void 0;constructor(e){this.offset=e}getOffset(){return this.offset??0}setOffset(e){this.offset=e}now(){return Date.now()+(this.offset??0)}date(e=new Date){return e.setTime(e.getTime()+(this.offset??0)),e}addServerTime(e,i){const s=Date.now(),o=e-s-i/2;if(Math.abs(o)<1e3){this.offset=0;return}this.offset===void 0?this.offset=Math.round(o):this.offset=Math.round(.2*o+(1-.2)*this.offset)}}const He=()=>Math.floor(Math.random()*2**32).toString(36).padStart(8,"0"),Me=(t,e)=>new pe(i=>{const s=new D,o=R(z(window,"beforeunload"),t.events.willDestruct$),n=new I(void 0);let a;s.add(t.info.isLive$.pipe(me()).subscribe(w=>{a&&(a.unsubscribe(),n.next(void 0)),w?a=t.info.liveTime$.pipe(be(q=>q&&q/1e3)).subscribe(n):a=t.info.position$.subscribe(n),s.add(a)}));const{playing$:l,paused$:u}=t.events,h=t.events.willSeek$.pipe(Y(()=>t.info.playbackState$.getValue()===Z.PLAYING)),r=t.events.seeked$.pipe(Y(()=>t.info.playbackState$.getValue()===Z.PLAYING));let c=!1;const d=new k;s.add(h.subscribe(()=>{c||d.next(),c=!0})),s.add(r.subscribe(()=>c=!1));const A=new k,v=new k,j=R(l,r,A),G=R(u,d,o,t.events.looped$,v);let L;const he=()=>L=n.getValue(),le=()=>{const w=n.getValue();F(L)||L===w||F(w)||(i.next({from:L,to:w}),L=void 0)},de=()=>{v.next(),A.next()};if(s.add(j.subscribe(he)),s.add(G.subscribe(le)),e.forceInterval&&isFinite(e.forceInterval)){let w=0;s.add(j.subscribe(()=>w=window.setTimeout(de,e.forceInterval))),s.add(G.subscribe(()=>window.clearTimeout(w)))}return s}),We="_one-stat_",V=`${We}uuid`,K=()=>{const t=new D;return{subscription:t,subscribe:(e,i)=>{e&&t.add(e.subscribe(i))}}};class Qe{api;logger;config;subscription=new D;beforeunloadSubscription;timeSynchronisation;debugLogger=new Se;oneStatDebugLog=this.debugLogger.createComponentLog("onestat");experimental;vsid$=new I(void 0);statContext;isEmbed;embedParent;uiEvents;player;seekAction$=new I(U.UNKNOWN);uuid;constructor(e,i){this.statContext=e,this.config=xe(i.config??{}),x(i.apiEnv)&&(this.config.apiEnv=i.apiEnv),this.config.synchronizeTime&&(this.timeSynchronisation=new qe);const s=new k;this.experimental={error$:s};const o=y.get(V);o?o.startsWith('"')&&o.endsWith('"')?(this.uuid=o.replaceAll('"',""),y.set(V,this.uuid)):this.uuid=o:(this.uuid=Oe(),y.set(V,this.uuid)),this.resetViewSession();const n=new ke({apiKey:$e,config:this.config,error$:s,timeSynchronisation:this.timeSynchronisation});this.api=new Ne({config:this.config,apiTransport:n,refreshAuthToken:i.refreshAuthToken,mobile:this.statContext.mobile??!1,uuid:this.uuid,error$:s}),this.logger=new Ie({config:this.config,debugLogger:this.debugLogger,api:this.api,error$:s,userSalt:i.userSalt});const{isEmbed:a,host:l}=De();this.isEmbed=a,this.embedParent=l,this.subscribe()}updateContext(e){this.statContext={...this.statContext,...e}}attachTo(e){const i=new D,s=(r,c)=>i.add(r.subscribe(c));s(e.events.willStart$,()=>{const r=e.info.position$.getValue();this.logActionPlay({position:r}),this.statContext.projectId&&this.logActionPlayWithProjectId({position:r})}),s(e.events.looped$,()=>{this.resetViewSession(),this.logActionPlay({position:e.info.position$.getValue()})}),s(e.events.seeked$,()=>{this.logSeek({action:this.seekAction$.getValue(),time:e.info.position$.getValue()}),this.seekAction$.next(U.UNKNOWN)}),s(e.events.paused$,()=>{this.logPause({position:e.info.position$.getValue()})}),s(e.events.willResume$,()=>{this.logPlay()}),s(e.events.started$,()=>{this.statContext.clip&&this.logWatchCoverageRecord({start:0,end:0})}),s(Me(e,{forceInterval:this.config.watchCoverageInterval}),r=>{const c=e.info.isLive$.getValue(),d={start:parseFloat(r.from.toFixed(3)),end:parseFloat(r.to.toFixed(3))};c?this.logWatchCoverageLive(d):this.logWatchCoverageRecord(d)});let o;s(e.info.isStalled$,r=>{r?o=p():(x(o)&&this.logEmptyBuffer({duration:p()-o}),o=void 0)});let n=!1;i.add(e.events.fatalError$.pipe(_e()).subscribe(()=>n=!0)),s(e.events.willStop$,()=>{if(e.info.isStalled$.getValue()){const c=x(o)?p()-o:void 0;this.logCloseAtEmptyBuffer({duration:c??0}),o=void 0}else n||this.logActionStop()}),s(e.events.managedError$,({id:r})=>{this.logError({fatal:!1,errorType:r})}),s(e.events.fatalError$,({id:r})=>{this.logError({fatal:!0,errorType:r})});let a,l,u=!1;s(e.events.firstBytes$,r=>{a=p(),this.logFirstBytes({time:r})}),s(e.events.willStart$,()=>l=p()),s(e.info.currentBuffer$,r=>{!u&&r&&r.end-r.start>0&&x(a)&&(this.logPlayerReady({duration:p()-a}),u=!0)}),s(e.events.firstFrame$,()=>{x(a)&&!u&&(this.logPlayerReady({duration:p()-a}),u=!0),x(l)&&this.logFirstFrame({time:p()-l})}),s(e.info.atLiveEdge$,r=>this.updateContext({liveEdge:r})),s(X({muted:e.info.muted$,volume:e.info.volume$}),({muted:r,volume:c})=>this.updateContext({audible:!r&&c>0})),s(e.info.currentQuality$,r=>this.updateContext({quality:Fe(r)})),s(e.info.isAutoQualityEnabled$,r=>this.updateContext({autoQuality:r})),s(e.info.currentFormat$,r=>this.updateContext({contentType:Be(r)})),s(e.info.currentPlaybackRate$,r=>this.updateContext({rate:r})),s(e.info.is3DVideo$,r=>this.updateContext({is3d:r}));let h;return s(e.info.hostname$,r=>{this.updateContext({cdnHostname:r,failover:h!==void 0&&h!==r}),h=r}),s(e.info.throughputEstimation$,r=>this.updateContext({downloadSpeed:r})),s(e.info.httpConnectionType$,r=>{this.statContext.firstConnectionType||this.updateContext({firstConnectionType:re(r)}),this.updateContext({connectionType:re(r)})}),s(e.info.httpConnectionReused$,r=>{F(this.statContext.firstConnectionReused)&&this.updateContext({firstConnectionReused:r}),this.updateContext({connectionReused:r})}),s(e.info.surface$,r=>this.updateContext({mode:W(r)})),s(X({current:e.info.currentTextTrack$,available:e.info.availableTextTracks$}),({current:r,available:c})=>{const d=c.find(({id:v})=>v===r),A=d&&(d.isAuto?`${d.language}_auto`:d.language);this.updateContext({subtitles:A})}),this.player=e,this.uiEvents&&this.attachToUi(this.uiEvents),this.resubscribeBeforeunload(),this.subscription.add(i),i}attachToUi(e){this.uiEvents=e;const{subscription:i,subscribe:s}=K();return this.player&&(s(e.actionRewind$,()=>{this.player&&(this.resetViewSession(),this.logActionPlay({position:this.player.info.position$.getValue()}))}),s(e.actionSeek$,this.seekAction$),s(e.inPiP$,o=>{const n=o?T.PIP:W(this.player?.info.surface$.getValue());this.updateContext({mode:n})}),s(e.inFullscreen$,o=>{const n=o?T.FULLSCREEN:W(this.player?.info.surface$.getValue());this.updateContext({mode:n})}),s(e.actionSetSubtitle$,o=>this.updateContext({subtitles:o})),s(e.nextMovie$,o=>this.logNextMovie(o)),this.resubscribeBeforeunload(),this.subscription.add(i)),i}attachToAds(e){const{subscription:i,subscribe:s}=K();return s(e.slotRequested$,()=>this.logAdSlotRequest()),s(e.started$,o=>this.logAdStarted(o)),s(e.paused$,()=>this.logAdPaused()),s(e.resumed$,()=>this.logAdResumed()),s(e.ended$,()=>this.logAdEnded()),s(e.skipped$,()=>this.logAdSkipped()),s(e.clicked$,()=>this.logAdClicked()),this.resubscribeBeforeunload(),this.subscription.add(i),i}attachToInteractive(e){const{subscription:i,subscribe:s}=K();return s(e.click$,o=>this.logInterfaceClick(o)),s(e.nextMovie$,o=>this.logNextMovie(o)),this.resubscribeBeforeunload(),this.subscription.add(i),i}authorize(e){return this.api.authorize(e)}pause(){this.logger.pause(),this.oneStatDebugLog({message:"paused"})}resume(){this.logger.resume(),this.oneStatDebugLog({message:"resumed"})}destroy(){this.logger.flush(),this.subscription.unsubscribe(),this.api.destroy(),this.logger.destroy()}resetViewSession(){this.oneStatDebugLog({message:"VSID reset"}),this.vsid$.next(He())}getDeviceId(){return this.uuid}setFieldBlacklist(){}logInited(){}logReady(e){this.log({operation:"player_ready",param:String(e.time)})}logStarted(...e){this.logActionPlay(...e)}logPlay(){this.log({operation:"play_toggle"})}logPause(e){this.log({operation:"pause",param:String(Math.round(e.position))})}logSeek(e){this.log({operation:"seek",param:e.action,time:e.time})}logFirstBytes(e){this.log({operation:"first_bytes",param:String(e.time)})}logFirstFrame(e){this.log({operation:"first_frame",param:String(e.time)})}logError(e){this.log({operation:"content_error",param:`${e.fatal?"fatal":"recoverable"}_${e.errorType}`})}logWatchCoverageRecord(e){this.log({operation:"watch_coverage_record",param:`${e.start}-${e.end}`})}logWatchCoverageLive(e){const i=this.timeSynchronisation?.getOffset()??0,s=e.start+i,o=e.end+i;this.log({operation:"watch_coverage_live",param:`${s}-${o}`})}logEmptyBuffer(e){this.log({operation:"empty_buffer",param:String(e.duration)})}logDownloadSpeed(){}logAdSlotRequest(){this.log({operation:"adv",param:"slot_request"})}logAdStarted(e){this.log({operation:"adv",param:e})}logAdPaused(){this.log({operation:"adv",param:"pause"})}logAdResumed(){this.log({operation:"adv",param:"resume"})}logAdEnded(){this.log({operation:"adv",param:"ended"})}logAdSkipped(){this.log({operation:"adv",param:"skip"})}logAdClicked(){this.log({operation:"adv",param:"click"})}logInterfaceClick(e){this.log({operation:"player_interface_click",param:e})}logNextMovie(e){this.log({operation:"next_movie",param:String(e)})}subscribe(){this.resubscribeBeforeunload();const e=window.navigator.connection;e&&"onchange"in e&&"effectiveType"in e&&this.subscription.add(R(z(e,"change"),Ee(["init"])).subscribe(()=>this.updateContext({network:Ue(e.effectiveType)}))),this.config.debugLog&&this.debugLogger.log$.subscribe(i=>{console.debug("%c stat ","background:#fa6470;",`component: ${i.component}.`,i.message)})}resubscribeBeforeunload(){this.beforeunloadSubscription?.unsubscribe(),this.beforeunloadSubscription=z(window,"beforeunload").subscribe(()=>this.logger.flush(!0)),this.subscription.add(this.beforeunloadSubscription)}logPlayerReady(e){this.log({operation:"player_ready",param:String(Math.round(e.duration))})}logActionPlay(e){this.log({operation:"action_play",param:String(Math.round(e.position))})}logActionPlayWithProjectId(e){this.statContext.projectId&&this.log({operation:"action_play",param:String(Math.round(e.position))},{vid:this.statContext.projectId})}logCloseAtEmptyBuffer(e){this.log({operation:"close_at_empty_buffer",param:String(Math.round(e.duration))})}logActionStop(){this.log({operation:"action_stop"})}log(e,i={}){if(this.config.disabledOperations.includes(e.operation))return;this.oneStatDebugLog({message:`operation ${e.operation} ${e.param}`});const s=this.createLogItem(e,i);this.logger.log(s)}createLogItem({operation:e,param:i,time:s},o={}){const n=this.timeSynchronisation?.now()??p(),a=this.vsid$.getValue();Ae(a);const l=e==="empty_buffer"||e==="close_at_empty_buffer"?this.statContext.connectionType:this.statContext.firstConnectionType,u=this.statContext.firstConnectionReused;let h,r;if(this.isEmbed){h=this.embedParent;const d=[...new URLSearchParams(location.search).entries()].filter(([A,v])=>this.config.embedUrlParams.includes(A));r=new URLSearchParams(d).toString()}else this.statContext.place==="direct"&&(document.referrer&&(h=new URL(document.referrer).hostname),r=location.href.substring(0,1024));const c={vsid:a,vid:this.statContext.movieId,ct:this.statContext.contentType,place:this.isEmbed?"embed":this.statContext.place,quality:this.statContext.quality,cdn_host:this.statContext.cdnHostname,stat_type:this.statContext.autoplay===!0?B.AUTO:this.statContext.autoplay===!1?B.MANUAL:void 0,param:i,vk_app_id:this.statContext.vkAppId,track_code:this.statContext.trackCode,connection_type:l,connection_reused:u===!0?E.YES:u===!1?E.NO:void 0,cached_data:this.statContext.cached===!0?E.YES:this.statContext.cached===!1?E.NO:void 0,live:this.statContext.liveEdge?E.YES:void 0,muted:this.statContext.audible===!1?E.YES:void 0,mode:this.statContext.mode,subtitles:this.statContext.subtitles,download_speed:this.statContext.downloadSpeed,manual_quality:this.statContext.autoQuality?void 0:E.YES,ref_domain:h,direct_url:r,rate:this.statContext.rate===1||F(this.statContext.rate)?void 0:this.statContext.rate.toFixed(2),view_360:this.statContext.is3d?1:void 0,aid:this.statContext.albumId,vk_playlist_id:this.statContext.vkPlaylistId,...o};for(const d of this.config.disabledCustomFields)delete c[d];return{operation:e,type:1,time:s,network:this.statContext.network,timestamp:n,custom:c}}}export{_ as ApiEnv,N as ConnectionType,g as ContentType,ee as InteractiveInterfaceClick,Qe as OneStat,m as Quality,U as SeekAction,te as VERSION};
|
|
6
|
+
import{fillWithDefault as ft,ValueSubject as I,getExponentialDelay as gt,ErrorCategory as b,now as p,safeStorage as y,assertNever as nt,Observable as pt,Subscription as D,merge as R,fromEvent as z,filterChanged as mt,map as bt,filter as Y,Subject as k,isNullable as F,Logger as St,isNonNullable as x,detectEmbed as _t,once as At,combine as X,observableFrom as Et,assertNonNullable as wt}from"@vkontakte/videoplayer-shared/esnext.esm.js";import J from"lodash/debounce.js";import{Surface as N,VideoQuality as S,HttpConnectionType as M,VideoFormat as f,PlaybackState as Z}from"@vkontakte/videoplayer-core/esnext.esm.js";var _;(function(e){e.PROD="prod",e.VK_ALIAS="vk_alias",e.VIDEOTEST="videotest",e.TEST="test",e.AUTO="auto"})(_||(_={}));var m;(function(e){e.Q144P="mobile",e.Q240P="lowest",e.Q360P="low",e.Q480P="medium",e.Q720P="high",e.Q1080P="fullhd",e.Q1440P="quadhd",e.Q2160P="ultrahd",e.UNKNOWN="unknown"})(m||(m={}));var g;(function(e){e.MP4="mp4",e.DASH="dash",e.DASH_SEP="dash_sep",e.ONDEMAND_DASH="ondemand_dash",e.HLS="hls",e.ONDEMAND_HLS="ondemand_hls",e.WEBM="webm",e.AV1="av1",e.ONDEMAND_DASH_LIVE="ondemand_dash_live",e.ONDEMAND_HLS_LIVE="ondemand_hls_live",e.MULTI_DASH="multi_dash",e.MULTI_HLS="multi_hls",e.WEBRTC="webrtc",e.UNKNOWN="unknown",e.RTMP="rtmp"})(g||(g={}));var B;(function(e){e.AUTO="auto",e.MANUAL=""})(B||(B={}));var O;(function(e){e.HTTP1="http1",e.HTTP2="http2",e.HTTP3="http3"})(O||(O={}));var A;(function(e){e[e.YES=1]="YES",e[e.NO=0]="NO"})(A||(A={}));var L;(function(e){e.EXCELLENT="excellent",e.GOOD="good",e.POOR="poor"})(L||(L={}));var T;(function(e){e.PIP="pip",e.FULLSCREEN="fullscreen",e.EXTERNAL="external",e.PREFETCH="prefetch",e.AIRPLAY="airplay",e.CHROMECAST="chromecast",e.INVISIBLE="invisible"})(T||(T={}));var U;(function(e){e.SLIDER="slider",e.DOUBLE_TAP="double_tap",e.TIME_CODE="time_code",e.EPISODE="episode",e.REWIND="rewind",e.LIVE="live",e.UNKNOWN="unknown"})(U||(U={}));var tt;(function(e){e.GRAPH_SHOW="iGraphShow",e.GRAPH_HIDE="iGraphHide",e.NEXT_AREA="iNextChapterArea",e.NEXT_BUTTON="iNextChapterBtn",e.WATCH_AGAIN="iWatchAgainBtn"})(tt||(tt={}));const yt={action_play:"ap",first_bytes:"fb",player_ready:"pr",first_frame:"ff",seek:"sk",watch_coverage_record:"wr",watch_coverage_live:"wl",empty_buffer:"eb",action_stop:"as",close_at_empty_buffer:"cb",content_error:"er",player_interface_click:"pc",next_movie:"nm",track_switch:"ts"},vt={vsid:"si",vid:"vi",place:"pl",quality:"qt",cdn_host:"ch",stat_type:"st",param:"pm",vk_app_id:"va",track_code:"tc",connection_type:"cnt",connection_reused:"cr",cached_data:"cd",live:"lv",muted:"mu",mode:"mo",subtitles:"sb",failover:"fo",download_speed:"ds",manual_quality:"mq",ref_domain:"rd",direct_url:"du"},Pt={unknown:"un",mobile:"m",lowest:"ls",low:"l",medium:"md",high:"h",fullhd:"f",quadhd:"q",ultrahd:"u"},Tt={pip:"pi",fullscreen:"fs",external:"ex",prefetch:"pr",airplay:"ap",chromecast:"cc",invisible:"iv"},xt={apiEnv:_.VK_ALIAS,requestRetryCount:1,firstFlushTime:5e3,flushDebounceTime:1e4,flushMaxWait:6e4,storageExpiration:36*60*60*1e3,watchCoverageInterval:15e3,disabledOperations:[],disabledCustomFields:[],shorten:!0,maxLoops:100,embedUrlParams:[],useBeacon:!0,synchronizeTime:!0,debugLog:!1,backoff:{start:1e3,factor:1.5,max:5*60*1e3,random:.1}},Lt=e=>ft(e,xt);function $t(){const e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),t=new Array(36);let i=0,s,o;for(o=0;o<36;o++)o===8||o===13||o===18||o===23?t[o]="-":o===14?t[o]="4":(i<=2&&(i=33554432+Math.random()*16777216|0),s=i&15,i=i>>4,t[o]=e[o===19?s&3|8:s]);return t.join("")}const Nt=e=>{const{operation:t,custom:i}=e,s=Object.fromEntries(Object.entries(i).map(([o,n])=>{const a=vt[o]??o;let l=n;return n&&(o==="mode"?l=Tt[n]??n:o==="quality"&&(l=Pt[n]??n)),[a,l]}));return{...e,operation:yt[t]??t,custom:s}},et="1.0.45-dev.41346c2e.0",Ot="CIOPGQJGDIHBABABA",st={[_.PROD]:"https://api.ok.ru",[_.VK_ALIAS]:"https://api.mycdn.me",[_.VIDEOTEST]:"https://videotestapi.ok.ru/api",[_.TEST]:"https://apitest.ok.ru",[_.AUTO]:""};var P;(function(e){e[e.PARAM_SESSION_EXPIRED=102]="PARAM_SESSION_EXPIRED",e[e.PARAM_SESSION_KEY=103]="PARAM_SESSION_KEY",e[e.PARAM_SIGNATURE=104]="PARAM_SIGNATURE",e[e.AUTH_LOGIN=401]="AUTH_LOGIN"})(P||(P={}));class Ct{params;authToken;sessionKey;authorizePromise;refreshAuthTokenPromise;consequentAuthErrors=0;authorized$=new I(!1);backoffTimeoutId;constructor(t){this.params=t}async authorize(t){return this.authToken=t??await this.refreshAuthToken(),this._authorizeWithBackoff()}logBeacon(t){const i="log.externalLog",s=this.createLogParams(t),o=this.sessionKey;if(!o)return;this.params.apiTransport.sendBeacon(i,s,o)||this.logRequest(t)}async logRequest(t){const i="log.externalLog",s=this.createLogParams(t),o=this.sessionKey??await this._authorizeWithBackoff();if(!o)return;const n=async(a,l=this.params.config.requestRetryCount)=>{try{return await this.params.apiTransport.sendRequest(i,s,o)}catch(u){if(!u||!("error_code"in u)){this.params.error$.next({id:"logRequestUnknown",category:b.NETWORK,message:`Unknown ${i} error`,thrown:u});return}const h=u?.error_code;switch(h){case P.PARAM_SESSION_EXPIRED:case P.PARAM_SESSION_KEY:case P.PARAM_SIGNATURE:return this.authorized$.next(!1),this.sessionKey=await this._authorizeWithBackoff(),l>0?n(a,l-1):void 0;case P.AUTH_LOGIN:return this.authorized$.next(!1),this.authToken=await this.refreshAuthToken(),this.sessionKey=await this._authorizeWithBackoff(),l>0?n(a,l-1):void 0;default:{this.params.error$.next({id:`LogRequest#${h}`,category:b.EXTERNAL_API,message:`${i} error`,data:u});return}}}};return n(t)}destroy(){window.clearTimeout(this.backoffTimeoutId),this.backoffTimeoutId=0}async refreshAuthToken(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=this.params.refreshAuthToken().finally(()=>{this.refreshAuthTokenPromise=void 0})),this.refreshAuthTokenPromise}createLogParams(t){return{collector:"ok.mobile.apps.video",data:JSON.stringify({application:`@vkontakte/videoplayer-statistics:${et}`,platform:this.params.mobile?"M_WEB":"WEB",items:this.params.config.shorten?t.map(Nt):t})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();const t=gt(this.consequentAuthErrors,this.params.config.backoff);return new Promise(i=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout(()=>{this._authorize().then(i).catch(s=>this.params.error$.next({id:"AuthorizeBackoff",category:b.NETWORK,message:"Otherwise unhandled error in authorization",thrown:s})).finally(()=>this.backoffTimeoutId=0)},t))})}async _authorize(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);const t="auth.anonymLogin",i={session_data:{version:2,device_id:this.params.uuid,client_version:et.split("-")[0],client_type:"SDK_JS"}};return this.authToken!==void 0&&(i.session_data.auth_token=this.authToken,i.session_data.version=3),this.authorizePromise=this.params.apiTransport.sendRequest(t,i).then(s=>((!s||!s.session_key)&&this.params.error$.next({id:"AuthorizeFailed",category:b.EXTERNAL_API,message:"No session key",data:s}),this.sessionKey=s?.session_key??void 0,this.sessionKey)).catch(async s=>{this.sessionKey=void 0;const o=s?.error_code;switch(o){case P.AUTH_LOGIN:return this.authToken=await this.refreshAuthToken(),this._authorizeWithBackoff()}o?this.params.error$.next({id:`Authorize#${o}`,category:b.EXTERNAL_API,message:"authorize error",data:s}):this.params.error$.next({id:"AuthorizeUnknown",category:b.NETWORK,message:"authorize error",thrown:s})}).finally(()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(this.sessionKey!==void 0)}),this.authorizePromise}}class it{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(t,i,s){t in this.listeners||(this.listeners[t]=[]),this.listeners[t].push({callback:i,options:s})}removeEventListener(t,i){if(!(t in this.listeners))return;const s=this.listeners[t];for(let o=0,n=s.length;o<n;o++)if(s[o].callback===i){s.splice(o,1);return}}dispatchEvent(t){if(!(t.type in this.listeners))return;const s=this.listeners[t.type].slice();for(let o=0,n=s.length;o<n;o++){const a=s[o];try{a.callback.call(this,t)}catch(l){Promise.resolve().then(()=>{throw l})}a.options&&a.options.once&&this.removeEventListener(t.type,a.callback)}return!t.defaultPrevented}}class at extends it{constructor(){super(),this.listeners||it.call(this),Object.defineProperty(this,"aborted",{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,"onabort",{value:null,writable:!0,configurable:!0}),Object.defineProperty(this,"reason",{value:void 0,writable:!0,configurable:!0})}toString(){return"[object AbortSignal]"}dispatchEvent(t){t.type==="abort"&&(this.aborted=!0,typeof this.onabort=="function"&&this.onabort.call(this,t)),super.dispatchEvent(t)}}class Rt{constructor(){Object.defineProperty(this,"signal",{value:new at,writable:!0,configurable:!0})}abort(t){let i;try{i=new Event("abort")}catch{typeof document<"u"?document.createEvent?(i=document.createEvent("Event"),i.initEvent("abort",!1,!1)):(i=document.createEventObject(),i.type="abort"):i={type:"abort",bubbles:!1,cancelable:!1}}let s=t;if(s===void 0)if(typeof document>"u")s=new Error("This operation was aborted"),s.name="AbortError";else try{s=new DOMException("signal is aborted without reason")}catch{s=new Error("This operation was aborted"),s.name="AbortError"}this.signal.reason=s,this.signal.dispatchEvent(i)}toString(){return"[object AbortController]"}}typeof Symbol<"u"&&Symbol.toStringTag&&(Rt.prototype[Symbol.toStringTag]="AbortController",at.prototype[Symbol.toStringTag]="AbortSignal");function ct(e){return e.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill"),!0):typeof e.Request=="function"&&!e.Request.prototype.hasOwnProperty("signal")||!e.AbortController}function kt(e){typeof e=="function"&&(e={fetch:e});const{fetch:t,Request:i=t.Request,AbortController:s,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o=!1}=e;if(!ct({fetch:t,Request:i,AbortController:s,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o}))return{fetch:t,Request:n};let n=i;(n&&!n.prototype.hasOwnProperty("signal")||o)&&(n=function(h,r){let c;r&&r.signal&&(c=r.signal,delete r.signal);const d=new i(h,r);return c&&Object.defineProperty(d,"signal",{writable:!1,enumerable:!1,configurable:!0,value:c}),d},n.prototype=i.prototype);const a=t;return{fetch:(u,h)=>{const r=n&&n.prototype.isPrototypeOf(u)?u.signal:h?h.signal:void 0;if(r){let c;try{c=new DOMException("Aborted","AbortError")}catch{c=new Error("Aborted"),c.name="AbortError"}if(r.aborted)return Promise.reject(c);const d=new Promise((E,v)=>{r.addEventListener("abort",()=>v(c),{once:!0})});return h&&h.signal&&delete h.signal,Promise.race([d,a(u,h)])}return a(u,h)},Request:n}}const Q=ct({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),ut=Q?kt({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,ot=Q?ut.fetch:window.fetch;Q?ut.Request:window.Request;class It{apiKey;apiBaseUrl;apiEnv;timeSynchronisation;isApiBaseUrlFetched;params;constructor(t){this.params=t,this.apiKey=t.apiKey,this.apiEnv=t.config.apiEnv,this.apiBaseUrl=st[this.apiEnv],this.timeSynchronisation=t.timeSynchronisation,this.isApiBaseUrlFetched=!1}async resolveApiBaseUrl(){if(this.apiEnv!==_.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const t=atob("aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ="),o=(await(await ot(t,{method:"GET",mode:"cors",cache:"no-cache"})).json())?.Answer[0]?.data;if(!o)throw new Error("Wrong DNS response");return o}catch(t){return this.params.error$.next({id:"OneStat:ApiTransport:resolveApiBaseUrl",category:b.NETWORK,message:"Unhandled resolve api base url error",thrown:t}),st[_.VK_ALIAS]}finally{this.isApiBaseUrlFetched=!0}}sendBeacon(t,i,s){if(!window.Blob||!window.navigator.sendBeacon)return!1;const o=this._prepareQueryParams({method:t,queryParams:i,sessionKey:s}),n=new window.Blob([o.toString()],{type:"application/x-www-form-urlencoded"});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,n)}catch(a){this.params.error$.next({id:"OneStat:ApiTransport:sendBeacon",category:b.NETWORK,message:"Unhandled beacon error",thrown:a,data:{method:t,params:i}})}return!1}async sendRequest(t,i,s){const o=p(),n=a=>{if(a instanceof TypeError&&["Failed to fetch","NetworkError when attempting to fetch resource."].includes(a.message)){this.params.error$.next({id:"Network",category:b.NETWORK,message:"Request failed",thrown:a});return}this.params.error$.next({id:"OneStat:ApiTransport:sendRequest",category:b.NETWORK,message:"Unhandled request error",thrown:a,data:{method:t,params:i,sessionKey:s,time:p()-o}})};return this.apiBaseUrl=await this.resolveApiBaseUrl(),ot(`${this.apiBaseUrl}/fb.do`,{method:"post",headers:{"Content-type":"application/x-www-form-urlencoded"},body:this._prepareQueryParams({method:t,queryParams:i,sessionKey:s})}).then(a=>{const l=Number(a.headers.get("content-length"))===0,u=new Date(a.headers.get("date")??"").getTime(),h=p()-o;if(isFinite(u)&&this.timeSynchronisation?.addServerTime(u,h),!l)return a.json().then(r=>Object.prototype.hasOwnProperty.call(r,"error_msg")?Promise.reject(r):r,n)},n)}_prepareQueryParams(t){const i=new URLSearchParams({format:"JSON",method:t.method,application_key:this.apiKey});return t.sessionKey!==void 0&&i.append("session_key",t.sessionKey),Object.entries(t.queryParams).forEach(([s,o])=>i.append(s,typeof o=="string"?o:JSON.stringify(o))),i}}const C="onestat_events",q=e=>t=>t.timestamp+e>=p();class Dt{params;api;error$;subscription;userSalt;unsaltedStorage=[];lastVsid;isPaused=!1;firstFlush;debouncedFlush;loggerDebugLog;constructor(t){this.params=t,this.api=t.api,this.error$=t.error$,this.userSalt=t.userSalt,this.loggerDebugLog=t.debugLogger.createComponentLog("stat logger"),this.firstFlush=J(()=>this.safeFlush(),this.params.config.firstFlushTime,{maxWait:this.params.config.firstFlushTime});const i=y.isPersistent()?this.params.config.flushMaxWait:0;this.debouncedFlush=J(()=>this.safeFlush(),this.params.config.flushDebounceTime,{maxWait:i}),this.subscription=this.api.authorized$.subscribe(s=>{s&&this.debouncedFlush()}),this.housekeepStorage()}isUrgent=t=>{const{operation:i}=t;return["action_play","watch_coverage_record","watch_coverage_live"].includes(i)};safeFlush(){try{this.flush()}catch(t){this.error$.next({id:"LoggerError",category:b.WTF,message:String(t)??"Unknown logger error",thrown:t})}}readFromStorage(){const t=y.get(C);try{return t?JSON.parse(t):{}}catch{}return{}}addToStorage(t){if(!this.userSalt){this.unsaltedStorage.push(t);return}const i=this.readFromStorage(),o=(i[this.userSalt]??[]).filter(q(this.params.config.storageExpiration));y.set(C,JSON.stringify({...i,[this.userSalt]:[...o,t]}))}getFromStorage(){return this.userSalt?(this.readFromStorage()[this.userSalt]??[]).filter(q(this.params.config.storageExpiration)):this.unsaltedStorage}markStorageSent(){if(!this.userSalt){this.unsaltedStorage=[];return}const t=this.readFromStorage();delete t[this.userSalt],y.set(C,JSON.stringify(t))}housekeepStorage(){const t=this.readFromStorage();for(const[i,s]of Object.entries(t)){const o=s.filter(q(this.params.config.storageExpiration));o.length?t[i]=o:delete t[i],this.loggerDebugLog({message:`${s.length} retrieved from storage, ${o.length} of them actual`})}y.set(C,JSON.stringify(t))}log(t){this.addToStorage(t),!this.isPaused&&(this.isUrgent(t)?this.flush():this.lastVsid!==t.custom.vsid?this.firstFlush():this.debouncedFlush(),this.lastVsid=t.custom.vsid)}flush(t=!1){const i=this.getFromStorage();i.length!==0&&(this.api.authorized$.getValue()?(t&&this.params.config.useBeacon?(this.loggerDebugLog({message:`Flushing ${i.length} events through beacon`}),this.api.logBeacon(i)):(this.loggerDebugLog({message:`Flushing ${i.length} events`}),this.api.logRequest(i)),this.markStorageSent()):this.api.authorize(),this.firstFlush.cancel(),this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}destroy(){this.subscription.unsubscribe(),this.firstFlush.cancel(),this.debouncedFlush.cancel()}}const Ft=e=>e&&{[S.INVARIANT]:m.UNKNOWN,[S.Q_144P]:m.Q144P,[S.Q_240P]:m.Q240P,[S.Q_360P]:m.Q360P,[S.Q_480P]:m.Q480P,[S.Q_720P]:m.Q720P,[S.Q_1080P]:m.Q1080P,[S.Q_1440P]:m.Q1440P,[S.Q_2160P]:m.Q2160P,[S.Q_4320P]:m.UNKNOWN}[e],rt=e=>e&&{[M.HTTP1]:O.HTTP1,[M.HTTP2]:O.HTTP2,[M.QUIC]:O.HTTP3}[e],Bt=e=>{if(e!==void 0)switch(e){case f.MPEG:return g.MP4;case f.DASH:case f.DASH_LIVE:return g.DASH;case f.DASH_STREAMS:return g.MULTI_DASH;case f.DASH_SEP:return g.DASH_SEP;case f.DASH_ONDEMAND:return g.ONDEMAND_DASH;case f.DASH_WEBM:case f.DASH_LIVE_WEBM:return g.WEBM;case f.DASH_WEBM_AV1:return g.AV1;case f.DASH_LIVE_CMAF:return g.ONDEMAND_DASH_LIVE;case f.HLS:case f.HLS_LIVE:return g.HLS;case f.HLS_ONDEMAND:return g.ONDEMAND_HLS;case f.HLS_LIVE_CMAF:return g.ONDEMAND_HLS_LIVE;case f.WEB_RTC_LIVE:return g.WEBRTC;default:return nt(e)}},W=e=>{if(e!==void 0)switch(e){case N.NONE:case N.INLINE:return;case N.FULLSCREEN:return T.FULLSCREEN;case N.SECOND_SCREEN:return T.CHROMECAST;case N.PIP:return T.PIP;default:return nt(e)}},Ut=e=>{switch(e){case"slow-2g":return L.POOR;case"2g":return L.POOR;case"3g":return L.GOOD;case"4g":return L.EXCELLENT}};class Ht{offset=void 0;constructor(t){this.offset=t}getOffset(){return this.offset??0}setOffset(t){this.offset=t}now(){return Date.now()+(this.offset??0)}date(t=new Date){return t.setTime(t.getTime()+(this.offset??0)),t}addServerTime(t,i){const s=Date.now(),o=t-s-i/2;if(Math.abs(o)<1e3){this.offset=0;return}this.offset===void 0?this.offset=Math.round(o):this.offset=Math.round(.2*o+(1-.2)*this.offset)}}const Mt=()=>Math.floor(Math.random()*2**32).toString(36).padStart(8,"0"),qt=(e,t)=>new pt(i=>{const s=new D,o=R(z(window,"beforeunload"),e.events.willDestruct$),n=new I(void 0);let a;s.add(e.info.isLive$.pipe(mt()).subscribe(w=>{a&&(a.unsubscribe(),n.next(void 0)),w?a=e.info.liveTime$.pipe(bt(H=>H&&H/1e3)).subscribe(n):a=e.info.position$.subscribe(n),s.add(a)}));const{playing$:l,paused$:u}=e.events,h=e.events.willSeek$.pipe(Y(()=>e.info.playbackState$.getValue()===Z.PLAYING)),r=e.events.seeked$.pipe(Y(()=>e.info.playbackState$.getValue()===Z.PLAYING));let c=!1;const d=new k;s.add(h.subscribe(()=>{c||d.next(),c=!0})),s.add(r.subscribe(()=>c=!1));const E=new k,v=new k,j=R(l,r,E),G=R(u,d,o,e.events.looped$,v);let $;const ht=()=>$=n.getValue(),lt=()=>{const w=n.getValue();F($)||$===w||F(w)||(i.next({from:$,to:w}),$=void 0)},dt=()=>{v.next(),E.next()};if(s.add(j.subscribe(ht)),s.add(G.subscribe(lt)),t.forceInterval&&isFinite(t.forceInterval)){let w=0;s.add(j.subscribe(()=>w=window.setTimeout(dt,t.forceInterval))),s.add(G.subscribe(()=>window.clearTimeout(w)))}return s}),Wt="_one-stat_",V=`${Wt}uuid`,K=()=>{const e=new D;return{subscription:e,subscribe:(t,i)=>{t&&e.add(t.subscribe(i))}}};class Qt{api;logger;config;subscription=new D;beforeunloadSubscription;timeSynchronisation;debugLogger=new St;oneStatDebugLog=this.debugLogger.createComponentLog("onestat");loopCounter=0;disabled=!1;experimental;vsid$=new I(void 0);statContext;isEmbed;embedParent;uiEvents;player;seekAction$=new I(U.UNKNOWN);uuid;constructor(t,i){this.statContext=t,this.config=Lt(i.config??{}),x(i.apiEnv)&&(this.config.apiEnv=i.apiEnv),this.config.synchronizeTime&&(this.timeSynchronisation=new Ht);const s=new k;this.experimental={error$:s};const o=y.get(V);o?o.startsWith('"')&&o.endsWith('"')?(this.uuid=o.replaceAll('"',""),y.set(V,this.uuid)):this.uuid=o:(this.uuid=$t(),y.set(V,this.uuid)),this.resetViewSession();const n=new It({apiKey:Ot,config:this.config,error$:s,timeSynchronisation:this.timeSynchronisation});this.api=new Ct({config:this.config,apiTransport:n,refreshAuthToken:i.refreshAuthToken,mobile:this.statContext.mobile??!1,uuid:this.uuid,error$:s}),this.logger=new Dt({config:this.config,debugLogger:this.debugLogger,api:this.api,error$:s,userSalt:i.userSalt});const{isEmbed:a,host:l}=_t();this.isEmbed=a,this.embedParent=l,this.subscribe()}updateContext(t){this.statContext={...this.statContext,...t}}attachTo(t){const i=new D,s=(r,c)=>i.add(r.subscribe(c));s(t.events.willStart$,()=>{const r=t.info.position$.getValue();this.logActionPlay({position:r}),this.statContext.projectId&&this.logActionPlayWithProjectId({position:r})}),s(t.events.looped$,()=>{this.resetViewSession(),++this.loopCounter>this.config.maxLoops&&(this.disabled=!0),this.logActionPlay({position:t.info.position$.getValue()})}),s(t.events.seeked$,()=>{this.logSeek({action:this.seekAction$.getValue(),time:t.info.position$.getValue()}),this.seekAction$.next(U.UNKNOWN)}),s(t.events.paused$,()=>{this.logPause({position:t.info.position$.getValue()})}),s(t.events.willResume$,()=>{this.logPlay()}),s(t.events.started$,()=>{this.statContext.clip&&this.logWatchCoverageRecord({start:0,end:0})}),s(qt(t,{forceInterval:this.config.watchCoverageInterval}),r=>{const c=t.info.isLive$.getValue(),d={start:parseFloat(r.from.toFixed(3)),end:parseFloat(r.to.toFixed(3))};c?this.logWatchCoverageLive(d):this.logWatchCoverageRecord(d)});let o;s(t.info.isStalled$,r=>{r?o=p():(x(o)&&this.logEmptyBuffer({duration:p()-o}),o=void 0)});let n=!1;i.add(t.events.fatalError$.pipe(At()).subscribe(()=>n=!0)),s(t.events.willStop$,()=>{if(t.info.isStalled$.getValue()){const c=x(o)?p()-o:void 0;this.logCloseAtEmptyBuffer({duration:c??0}),o=void 0}else n||this.logActionStop()}),s(t.events.managedError$,({id:r})=>{this.logError({fatal:!1,errorType:r})}),s(t.events.fatalError$,({id:r})=>{this.logError({fatal:!0,errorType:r})});let a,l,u=!1;s(t.events.firstBytes$,r=>{a=p(),this.logFirstBytes({time:r})}),s(t.events.willStart$,()=>l=p()),s(t.info.currentBuffer$,r=>{!u&&r&&r.end-r.start>0&&x(a)&&(this.logPlayerReady({duration:p()-a}),u=!0)}),s(t.events.firstFrame$,()=>{x(a)&&!u&&(this.logPlayerReady({duration:p()-a}),u=!0),x(l)&&this.logFirstFrame({time:p()-l})}),s(t.info.atLiveEdge$,r=>this.updateContext({liveEdge:r})),s(X({muted:t.info.muted$,volume:t.info.volume$}),({muted:r,volume:c})=>this.updateContext({audible:!r&&c>0})),s(t.info.currentQuality$,r=>this.updateContext({quality:Ft(r)})),s(t.info.isAutoQualityEnabled$,r=>this.updateContext({autoQuality:r})),s(t.info.currentFormat$,r=>this.updateContext({contentType:Bt(r)})),s(t.info.currentPlaybackRate$,r=>this.updateContext({rate:r})),s(t.info.is3DVideo$,r=>this.updateContext({is3d:r}));let h;return s(t.info.hostname$,r=>{this.updateContext({cdnHostname:r,failover:h!==void 0&&h!==r}),h=r}),s(t.info.throughputEstimation$,r=>this.updateContext({downloadSpeed:r})),s(t.info.httpConnectionType$,r=>{this.statContext.firstConnectionType||this.updateContext({firstConnectionType:rt(r)}),this.updateContext({connectionType:rt(r)})}),s(t.info.httpConnectionReused$,r=>{F(this.statContext.firstConnectionReused)&&this.updateContext({firstConnectionReused:r}),this.updateContext({connectionReused:r})}),s(t.info.surface$,r=>this.updateContext({mode:W(r)})),s(X({current:t.info.currentTextTrack$,available:t.info.availableTextTracks$}),({current:r,available:c})=>{const d=c.find(({id:v})=>v===r),E=d&&(d.isAuto?`${d.language}_auto`:d.language);this.updateContext({subtitles:E})}),this.player=t,this.uiEvents&&this.attachToUi(this.uiEvents),this.resubscribeBeforeunload(),this.subscription.add(i),i}attachToUi(t){this.uiEvents=t;const{subscription:i,subscribe:s}=K();return this.player&&(s(t.actionRewind$,()=>{this.player&&(this.resetViewSession(),this.logActionPlay({position:this.player.info.position$.getValue()}))}),s(t.actionSeek$,this.seekAction$),s(t.inPiP$,o=>{const n=o?T.PIP:W(this.player?.info.surface$.getValue());this.updateContext({mode:n})}),s(t.inFullscreen$,o=>{const n=o?T.FULLSCREEN:W(this.player?.info.surface$.getValue());this.updateContext({mode:n})}),s(t.actionSetSubtitle$,o=>this.updateContext({subtitles:o})),s(t.nextMovie$,o=>this.logNextMovie(o)),this.resubscribeBeforeunload(),this.subscription.add(i)),i}attachToAds(t){const{subscription:i,subscribe:s}=K();return s(t.slotRequested$,()=>this.logAdSlotRequest()),s(t.started$,o=>this.logAdStarted(o)),s(t.paused$,()=>this.logAdPaused()),s(t.resumed$,()=>this.logAdResumed()),s(t.ended$,()=>this.logAdEnded()),s(t.skipped$,()=>this.logAdSkipped()),s(t.clicked$,()=>this.logAdClicked()),this.resubscribeBeforeunload(),this.subscription.add(i),i}attachToInteractive(t){const{subscription:i,subscribe:s}=K();return s(t.click$,o=>this.logInterfaceClick(o)),s(t.nextMovie$,o=>this.logNextMovie(o)),this.resubscribeBeforeunload(),this.subscription.add(i),i}authorize(t){return this.api.authorize(t)}pause(){this.logger.pause(),this.oneStatDebugLog({message:"paused"})}resume(){this.logger.resume(),this.oneStatDebugLog({message:"resumed"})}destroy(){this.logger.flush(),this.subscription.unsubscribe(),this.api.destroy(),this.logger.destroy()}resetViewSession(){this.oneStatDebugLog({message:"VSID reset"}),this.vsid$.next(Mt())}getDeviceId(){return this.uuid}setFieldBlacklist(){}logInited(){}logReady(t){this.log({operation:"player_ready",param:String(t.time)})}logStarted(...t){this.logActionPlay(...t)}logPlay(){this.log({operation:"play_toggle"})}logPause(t){this.log({operation:"pause",param:String(Math.round(t.position))})}logSeek(t){this.log({operation:"seek",param:t.action,time:t.time})}logFirstBytes(t){this.log({operation:"first_bytes",param:String(t.time)})}logFirstFrame(t){this.log({operation:"first_frame",param:String(t.time)})}logError(t){this.log({operation:"content_error",param:`${t.fatal?"fatal":"recoverable"}_${t.errorType}`})}logWatchCoverageRecord(t){this.log({operation:"watch_coverage_record",param:`${t.start}-${t.end}`})}logWatchCoverageLive(t){const i=this.timeSynchronisation?.getOffset()??0,s=t.start+i,o=t.end+i;this.log({operation:"watch_coverage_live",param:`${s}-${o}`})}logEmptyBuffer(t){this.log({operation:"empty_buffer",param:String(t.duration)})}logDownloadSpeed(){}logAdSlotRequest(){this.log({operation:"adv",param:"slot_request"})}logAdStarted(t){this.log({operation:"adv",param:t})}logAdPaused(){this.log({operation:"adv",param:"pause"})}logAdResumed(){this.log({operation:"adv",param:"resume"})}logAdEnded(){this.log({operation:"adv",param:"ended"})}logAdSkipped(){this.log({operation:"adv",param:"skip"})}logAdClicked(){this.log({operation:"adv",param:"click"})}logInterfaceClick(t){this.log({operation:"player_interface_click",param:t})}logNextMovie(t){this.log({operation:"next_movie",param:String(t)})}subscribe(){this.resubscribeBeforeunload();const t=window.navigator.connection;t&&"onchange"in t&&"effectiveType"in t&&this.subscription.add(R(z(t,"change"),Et(["init"])).subscribe(()=>this.updateContext({network:Ut(t.effectiveType)}))),this.config.debugLog&&this.debugLogger.log$.subscribe(i=>{console.debug("%c stat ","background:#fa6470;",`component: ${i.component}.`,i.message)})}resubscribeBeforeunload(){this.beforeunloadSubscription?.unsubscribe(),this.beforeunloadSubscription=z(window,"beforeunload").subscribe(()=>this.logger.flush(!0)),this.subscription.add(this.beforeunloadSubscription)}logPlayerReady(t){this.log({operation:"player_ready",param:String(Math.round(t.duration))})}logActionPlay(t){this.log({operation:"action_play",param:String(Math.round(t.position))})}logActionPlayWithProjectId(t){this.statContext.projectId&&this.log({operation:"action_play",param:String(Math.round(t.position))},{vid:this.statContext.projectId})}logCloseAtEmptyBuffer(t){this.log({operation:"close_at_empty_buffer",param:String(Math.round(t.duration))})}logActionStop(){this.log({operation:"action_stop"})}log(t,i={}){if(this.disabled){this.oneStatDebugLog({message:`operation ${t.operation} but statistics is disabled`});return}if(this.config.disabledOperations.includes(t.operation)){this.oneStatDebugLog({message:`operation ${t.operation} but it is disabled`});return}this.oneStatDebugLog({message:`operation ${t.operation} ${t.param}`});const s=this.createLogItem(t,i);this.logger.log(s)}createLogItem({operation:t,param:i,time:s},o={}){const n=this.timeSynchronisation?.now()??p(),a=this.vsid$.getValue();wt(a);const l=t==="empty_buffer"||t==="close_at_empty_buffer"?this.statContext.connectionType:this.statContext.firstConnectionType,u=this.statContext.firstConnectionReused;let h,r;if(this.isEmbed){h=this.embedParent;const d=[...new URLSearchParams(location.search).entries()].filter(([E,v])=>this.config.embedUrlParams.includes(E));r=new URLSearchParams(d).toString()}else this.statContext.place==="direct"&&(document.referrer&&(h=new URL(document.referrer).hostname),r=location.href.substring(0,1024));const c={vsid:a,vid:this.statContext.movieId,ct:this.statContext.contentType,place:this.isEmbed?"embed":this.statContext.place,quality:this.statContext.quality,cdn_host:this.statContext.cdnHostname,stat_type:this.statContext.autoplay===!0?B.AUTO:this.statContext.autoplay===!1?B.MANUAL:void 0,param:i,vk_app_id:this.statContext.vkAppId,track_code:this.statContext.trackCode,connection_type:l,connection_reused:u===!0?A.YES:u===!1?A.NO:void 0,cached_data:this.statContext.cached===!0?A.YES:this.statContext.cached===!1?A.NO:void 0,live:this.statContext.liveEdge?A.YES:void 0,muted:this.statContext.audible===!1?A.YES:void 0,mode:this.statContext.mode,subtitles:this.statContext.subtitles,download_speed:this.statContext.downloadSpeed,manual_quality:this.statContext.autoQuality?void 0:A.YES,ref_domain:h,direct_url:r,rate:this.statContext.rate===1||F(this.statContext.rate)?void 0:this.statContext.rate.toFixed(2),view_360:this.statContext.is3d?1:void 0,aid:this.statContext.albumId,vk_playlist_id:this.statContext.vkPlaylistId,...o};for(const d of this.config.disabledCustomFields)delete c[d];return{operation:t,type:1,time:s,network:this.statContext.network,timestamp:n,custom:c}}}export{_ as ApiEnv,O as ConnectionType,g as ContentType,tt as InteractiveInterfaceClick,Qt as OneStat,m as Quality,U as SeekAction,et as VERSION};
|
package/evergreen.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-statistics v1.0.
|
|
3
|
-
* Wed,
|
|
4
|
-
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-
|
|
2
|
+
* @vkontakte/videoplayer-statistics v1.0.45-dev.41346c2e.0
|
|
3
|
+
* Wed, 07 Feb 2024 10:07:59 GMT
|
|
4
|
+
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-45/doc/
|
|
5
5
|
*/
|
|
6
|
-
import{fillWithDefault as at,ValueSubject as R,getExponentialDelay as ct,ErrorCategory as b,now as p,safeStorage as w,assertNever as it,Observable as ht,Subscription as D,merge as O,fromEvent as z,filterChanged as ut,map as dt,filter as j,Subject as I,isNullable as B,Logger as lt,isNonNullable as y,once as ft,combine as Y,observableFrom as gt,assertNonNullable as pt}from"@vkontakte/videoplayer-shared/esnext.esm.js";import X from"lodash/debounce.js";import{Surface as k,VideoQuality as S,HttpConnectionType as W,VideoFormat as f,PlaybackState as J}from"@vkontakte/videoplayer-core/esnext.esm.js";var _;(function(e){e.PROD="prod",e.VK_ALIAS="vk_alias",e.VIDEOTEST="videotest",e.TEST="test",e.AUTO="auto"})(_||(_={}));var m;(function(e){e.Q144P="mobile",e.Q240P="lowest",e.Q360P="low",e.Q480P="medium",e.Q720P="high",e.Q1080P="fullhd",e.Q1440P="quadhd",e.Q2160P="ultrahd",e.UNKNOWN="unknown"})(m||(m={}));var g;(function(e){e.MP4="mp4",e.DASH="dash",e.DASH_SEP="dash_sep",e.ONDEMAND_DASH="ondemand_dash",e.HLS="hls",e.ONDEMAND_HLS="ondemand_hls",e.WEBM="webm",e.AV1="av1",e.ONDEMAND_DASH_LIVE="ondemand_dash_live",e.ONDEMAND_HLS_LIVE="ondemand_hls_live",e.WEBRTC="webrtc",e.UNKNOWN="unknown",e.RTMP="rtmp"})(g||(g={}));var U;(function(e){e.AUTO="auto",e.MANUAL=""})(U||(U={}));var C;(function(e){e.HTTP1="http1",e.HTTP2="http2",e.HTTP3="http3"})(C||(C={}));var A;(function(e){e[e.YES=1]="YES",e[e.NO=0]="NO"})(A||(A={}));var x;(function(e){e.EXCELLENT="excellent",e.GOOD="good",e.POOR="poor"})(x||(x={}));var T;(function(e){e.PIP="pip",e.FULLSCREEN="fullscreen",e.EXTERNAL="external",e.PREFETCH="prefetch",e.AIRPLAY="airplay",e.CHROMECAST="chromecast",e.INVISIBLE="invisible"})(T||(T={}));var F;(function(e){e.SLIDER="slider",e.DOUBLE_TAP="double_tap",e.TIME_CODE="time_code",e.EPISODE="episode",e.REWIND="rewind",e.LIVE="live",e.UNKNOWN="unknown"})(F||(F={}));var Z;(function(e){e.GRAPH_SHOW="iGraphShow",e.GRAPH_HIDE="iGraphHide",e.NEXT_AREA="iNextChapterArea",e.NEXT_BUTTON="iNextChapterBtn",e.WATCH_AGAIN="iWatchAgainBtn"})(Z||(Z={}));const mt={action_play:"ap",first_bytes:"fb",player_ready:"pr",first_frame:"ff",seek:"sk",watch_coverage_record:"wr",watch_coverage_live:"wl",empty_buffer:"eb",action_stop:"as",close_at_empty_buffer:"cb",content_error:"er",player_interface_click:"pc",next_movie:"nm",track_switch:"ts"},bt={vsid:"si",vid:"vi",place:"pl",quality:"qt",cdn_host:"ch",stat_type:"st",param:"pm",vk_app_id:"va",track_code:"tc",connection_type:"cnt",connection_reused:"cr",cached_data:"cd",live:"lv",muted:"mu",mode:"mo",subtitles:"sb",failover:"fo",download_speed:"ds",manual_quality:"mq",ref_domain:"rd",direct_url:"du"},St={unknown:"un",mobile:"m",lowest:"ls",low:"l",medium:"md",high:"h",fullhd:"f",quadhd:"q",ultrahd:"u"},_t={pip:"pi",fullscreen:"fs",external:"ex",prefetch:"pr",airplay:"ap",chromecast:"cc",invisible:"iv"},At={apiEnv:_.VK_ALIAS,requestRetryCount:1,firstFlushTime:5e3,flushDebounceTime:1e4,flushMaxWait:6e4,storageExpiration:36*60*60*1e3,watchCoverageInterval:15e3,disabledOperations:[],disabledCustomFields:[],shorten:!0,embedUrlParams:[],useBeacon:!0,synchronizeTime:!0,debugLog:!1,backoff:{start:1e3,factor:1.5,max:5*60*1e3,random:.1}},Et=e=>at(e,At);function wt(){const e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),t=new Array(36);let i=0,s,o;for(o=0;o<36;o++)o===8||o===13||o===18||o===23?t[o]="-":o===14?t[o]="4":(i<=2&&(i=33554432+Math.random()*16777216|0),s=i&15,i=i>>4,t[o]=e[o===19?s&3|8:s]);return t.join("")}const Pt=e=>{const{operation:t,custom:i}=e,s=Object.fromEntries(Object.entries(i).map(([o,r])=>{const a=bt[o]??o;let c=r;return r&&(o==="mode"?c=_t[r]??r:o==="quality"&&(c=St[r]??r)),[a,c]}));return{...e,operation:mt[t]??t,custom:s}},tt="1.0.44-beta.1",Tt="CIOPGQJGDIHBABABA",et={[_.PROD]:"https://api.ok.ru",[_.VK_ALIAS]:"https://api.mycdn.me",[_.VIDEOTEST]:"https://videotestapi.ok.ru/api",[_.TEST]:"https://apitest.ok.ru",[_.AUTO]:""};var P;(function(e){e[e.PARAM_SESSION_EXPIRED=102]="PARAM_SESSION_EXPIRED",e[e.PARAM_SESSION_KEY=103]="PARAM_SESSION_KEY",e[e.PARAM_SIGNATURE=104]="PARAM_SIGNATURE",e[e.AUTH_LOGIN=401]="AUTH_LOGIN"})(P||(P={}));class vt{params;authToken;sessionKey;authorizePromise;refreshAuthTokenPromise;consequentAuthErrors=0;authorized$=new R(!1);backoffTimeoutId;constructor(t){this.params=t}async authorize(t){return this.authToken=t??await this.refreshAuthToken(),this._authorizeWithBackoff()}logBeacon(t){const i="log.externalLog",s=this.createLogParams(t),o=this.sessionKey;if(!o)return;this.params.apiTransport.sendBeacon(i,s,o)||this.logRequest(t)}async logRequest(t){const i="log.externalLog",s=this.createLogParams(t),o=this.sessionKey??await this._authorizeWithBackoff();if(!o)return;const r=async(a,c=this.params.config.requestRetryCount)=>{try{return await this.params.apiTransport.sendRequest(i,s,o)}catch(h){if(!h||!("error_code"in h)){this.params.error$.next({id:"logRequestUnknown",category:b.NETWORK,message:`Unknown ${i} error`,thrown:h});return}const d=h?.error_code;switch(d){case P.PARAM_SESSION_EXPIRED:case P.PARAM_SESSION_KEY:case P.PARAM_SIGNATURE:return this.authorized$.next(!1),this.sessionKey=await this._authorizeWithBackoff(),c>0?r(a,c-1):void 0;case P.AUTH_LOGIN:return this.authorized$.next(!1),this.authToken=await this.refreshAuthToken(),this.sessionKey=await this._authorizeWithBackoff(),c>0?r(a,c-1):void 0;default:{this.params.error$.next({id:`LogRequest#${d}`,category:b.EXTERNAL_API,message:`${i} error`,data:h});return}}}};return r(t)}destroy(){window.clearTimeout(this.backoffTimeoutId),this.backoffTimeoutId=0}async refreshAuthToken(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=this.params.refreshAuthToken().finally(()=>{this.refreshAuthTokenPromise=void 0})),this.refreshAuthTokenPromise}createLogParams(t){return{collector:"ok.mobile.apps.video",data:JSON.stringify({application:`@vkontakte/videoplayer-statistics:${tt}`,platform:this.params.mobile?"M_WEB":"WEB",items:this.params.config.shorten?t.map(Pt):t})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();const t=ct(this.consequentAuthErrors,this.params.config.backoff);return new Promise(i=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout(()=>{this._authorize().then(i).catch(s=>this.params.error$.next({id:"AuthorizeBackoff",category:b.NETWORK,message:"Otherwise unhandled error in authorization",thrown:s})).finally(()=>this.backoffTimeoutId=0)},t))})}async _authorize(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);const t="auth.anonymLogin",i={session_data:{version:2,device_id:this.params.uuid,client_version:tt.split("-")[0],client_type:"SDK_JS"}};return this.authToken!==void 0&&(i.session_data.auth_token=this.authToken,i.session_data.version=3),this.authorizePromise=this.params.apiTransport.sendRequest(t,i).then(s=>((!s||!s.session_key)&&this.params.error$.next({id:"AuthorizeFailed",category:b.EXTERNAL_API,message:"No session key",data:s}),this.sessionKey=s?.session_key??void 0,this.sessionKey)).catch(async s=>{this.sessionKey=void 0;const o=s?.error_code;switch(o){case P.AUTH_LOGIN:return this.authToken=await this.refreshAuthToken(),this._authorizeWithBackoff()}o?this.params.error$.next({id:`Authorize#${o}`,category:b.EXTERNAL_API,message:"authorize error",data:s}):this.params.error$.next({id:"AuthorizeUnknown",category:b.NETWORK,message:"authorize error",thrown:s})}).finally(()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(this.sessionKey!==void 0)}),this.authorizePromise}}class yt{apiKey;apiBaseUrl;apiEnv;timeSynchronisation;isApiBaseUrlFetched;params;constructor(t){this.params=t,this.apiKey=t.apiKey,this.apiEnv=t.config.apiEnv,this.apiBaseUrl=et[this.apiEnv],this.timeSynchronisation=t.timeSynchronisation,this.isApiBaseUrlFetched=!1}async resolveApiBaseUrl(){if(this.apiEnv!==_.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const t=atob("aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ="),o=(await(await fetch(t,{method:"GET",mode:"cors",cache:"no-cache"})).json())?.Answer[0]?.data;if(!o)throw new Error("Wrong DNS response");return o}catch(t){return this.params.error$.next({id:"OneStat:ApiTransport:resolveApiBaseUrl",category:b.NETWORK,message:"Unhandled resolve api base url error",thrown:t}),et[_.VK_ALIAS]}finally{this.isApiBaseUrlFetched=!0}}sendBeacon(t,i,s){if(!window.Blob||!window.navigator.sendBeacon)return!1;const o=this._prepareQueryParams({method:t,queryParams:i,sessionKey:s}),r=new window.Blob([o.toString()],{type:"application/x-www-form-urlencoded"});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,r)}catch(a){this.params.error$.next({id:"OneStat:ApiTransport:sendBeacon",category:b.NETWORK,message:"Unhandled beacon error",thrown:a,data:{method:t,params:i}})}return!1}async sendRequest(t,i,s){const o=p(),r=a=>{if(a instanceof TypeError&&["Failed to fetch","NetworkError when attempting to fetch resource."].includes(a.message)){this.params.error$.next({id:"Network",category:b.NETWORK,message:"Request failed",thrown:a});return}this.params.error$.next({id:"OneStat:ApiTransport:sendRequest",category:b.NETWORK,message:"Unhandled request error",thrown:a,data:{method:t,params:i,sessionKey:s,time:p()-o}})};return this.apiBaseUrl=await this.resolveApiBaseUrl(),fetch(`${this.apiBaseUrl}/fb.do`,{method:"post",headers:{"Content-type":"application/x-www-form-urlencoded"},body:this._prepareQueryParams({method:t,queryParams:i,sessionKey:s})}).then(a=>{const c=Number(a.headers.get("content-length"))===0,h=new Date(a.headers.get("date")??"").getTime(),d=p()-o;if(isFinite(h)&&this.timeSynchronisation?.addServerTime(h,d),!c)return a.json().then(n=>Object.prototype.hasOwnProperty.call(n,"error_msg")?Promise.reject(n):n,r)},r)}_prepareQueryParams(t){const i=new URLSearchParams({format:"JSON",method:t.method,application_key:this.apiKey});return t.sessionKey!==void 0&&i.append("session_key",t.sessionKey),Object.entries(t.queryParams).forEach(([s,o])=>i.append(s,typeof o=="string"?o:JSON.stringify(o))),i}}const L="onestat_events",M=e=>t=>t.timestamp+e>=p();class xt{params;api;error$;subscription;userSalt;unsaltedStorage=[];lastVsid;isPaused=!1;firstFlush;debouncedFlush;loggerDebugLog;constructor(t){this.params=t,this.api=t.api,this.error$=t.error$,this.userSalt=t.userSalt,this.loggerDebugLog=t.debugLogger.createComponentLog("stat logger"),this.firstFlush=X(()=>this.safeFlush(),this.params.config.firstFlushTime,{maxWait:this.params.config.firstFlushTime});const i=w.isPersistent()?this.params.config.flushMaxWait:0;this.debouncedFlush=X(()=>this.safeFlush(),this.params.config.flushDebounceTime,{maxWait:i}),this.subscription=this.api.authorized$.subscribe(s=>{s&&this.debouncedFlush()}),this.housekeepStorage()}isUrgent=t=>{const{operation:i,custom:{param:s}}=t;return["action_stop","close_at_empty_buffer"].includes(i)||i==="watch_coverage_record"&&s==="0-0"};safeFlush(){try{this.flush()}catch(t){this.error$.next({id:"LoggerError",category:b.WTF,message:String(t)??"Unknown logger error",thrown:t})}}readFromStorage(){const t=w.get(L);try{return t?JSON.parse(t):{}}catch{}return{}}addToStorage(t){if(!this.userSalt){this.unsaltedStorage.push(t);return}const i=this.readFromStorage(),o=(i[this.userSalt]??[]).filter(M(this.params.config.storageExpiration));w.set(L,JSON.stringify({...i,[this.userSalt]:[...o,t]}))}getFromStorage(){return this.userSalt?(this.readFromStorage()[this.userSalt]??[]).filter(M(this.params.config.storageExpiration)):this.unsaltedStorage}markStorageSent(){if(!this.userSalt){this.unsaltedStorage=[];return}const t=this.readFromStorage();delete t[this.userSalt],w.set(L,JSON.stringify(t))}housekeepStorage(){const t=this.readFromStorage();for(const[i,s]of Object.entries(t)){const o=s.filter(M(this.params.config.storageExpiration));o.length?t[i]=o:delete t[i],this.loggerDebugLog({message:`${s.length} retrieved from storage, ${o.length} of them actual`})}w.set(L,JSON.stringify(t))}log(t){this.addToStorage(t),!this.isPaused&&(this.isUrgent(t)?this.flush():this.lastVsid!==t.custom.vsid?this.firstFlush():this.debouncedFlush(),this.lastVsid=t.custom.vsid)}flush(t=!1){const i=this.getFromStorage();i.length!==0&&(this.api.authorized$.getValue()?(t&&this.params.config.useBeacon?(this.loggerDebugLog({message:`Flushing ${i.length} events through beacon`}),this.api.logBeacon(i)):(this.loggerDebugLog({message:`Flushing ${i.length} events`}),this.api.logRequest(i)),this.markStorageSent()):this.api.authorize(),this.firstFlush.cancel(),this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}destroy(){this.subscription.unsubscribe(),this.firstFlush.cancel(),this.debouncedFlush.cancel()}}const $t=()=>{let e,t;try{e=window.self!==window.top}catch(s){s instanceof DOMException&&s.name==="SecurityError"?e=!0:(e=!1,console.error(s))}try{window.location.ancestorOrigins&&(t=window.location.ancestorOrigins[window.location.ancestorOrigins.length-1])}catch(s){console.error(s)}try{!t&&document.referrer&&(t=document.referrer)}catch(s){console.error(s)}const i=t?new URL(t).hostname:void 0;return{isEmbed:e,host:i}},Nt=e=>e&&{[S.INVARIANT]:m.UNKNOWN,[S.Q_144P]:m.Q144P,[S.Q_240P]:m.Q240P,[S.Q_360P]:m.Q360P,[S.Q_480P]:m.Q480P,[S.Q_720P]:m.Q720P,[S.Q_1080P]:m.Q1080P,[S.Q_1440P]:m.Q1440P,[S.Q_2160P]:m.Q2160P,[S.Q_4320P]:m.UNKNOWN}[e],st=e=>e&&{[W.HTTP1]:C.HTTP1,[W.HTTP2]:C.HTTP2,[W.QUIC]:C.HTTP3}[e],kt=e=>{if(e!==void 0)switch(e){case f.MPEG:return g.MP4;case f.DASH:case f.DASH_LIVE:return g.DASH;case f.DASH_SEP:return g.DASH_SEP;case f.DASH_ONDEMAND:return g.ONDEMAND_DASH;case f.DASH_WEBM:case f.DASH_LIVE_WEBM:return g.WEBM;case f.DASH_WEBM_AV1:return g.AV1;case f.DASH_LIVE_CMAF:return g.ONDEMAND_DASH_LIVE;case f.HLS:case f.HLS_LIVE:return g.HLS;case f.HLS_ONDEMAND:return g.ONDEMAND_HLS;case f.HLS_LIVE_CMAF:return g.ONDEMAND_HLS_LIVE;case f.WEB_RTC_LIVE:return g.WEBRTC;default:return it(e)}},V=e=>{if(e!==void 0)switch(e){case k.NONE:case k.INLINE:return;case k.FULLSCREEN:return T.FULLSCREEN;case k.SECOND_SCREEN:return T.CHROMECAST;case k.PIP:return T.PIP;default:return it(e)}},Ct=e=>{switch(e){case"slow-2g":return x.POOR;case"2g":return x.POOR;case"3g":return x.GOOD;case"4g":return x.EXCELLENT}};class Lt{offset=void 0;constructor(t){this.offset=t}getOffset(){return this.offset??0}setOffset(t){this.offset=t}now(){return Date.now()+(this.offset??0)}date(t=new Date){return t.setTime(t.getTime()+(this.offset??0)),t}addServerTime(t,i){const s=Date.now(),o=t-s-i/2;if(Math.abs(o)<1e3){this.offset=0;return}this.offset===void 0?this.offset=Math.round(o):this.offset=Math.round(.2*o+(1-.2)*this.offset)}}const Ot=()=>Math.floor(Math.random()*2**32).toString(36).padStart(8,"0"),It=(e,t)=>new ht(i=>{const s=new D,o=O(z(window,"beforeunload"),e.events.willDestruct$),r=new R(void 0);let a;s.add(e.info.isLive$.pipe(ut()).subscribe(E=>{a&&(a.unsubscribe(),r.next(void 0)),E?a=e.info.liveTime$.pipe(dt(H=>H&&H/1e3)).subscribe(r):a=e.info.position$.subscribe(r),s.add(a)}));const{playing$:c,paused$:h}=e.events,d=e.events.willSeek$.pipe(j(()=>e.info.playbackState$.getValue()===J.PLAYING)),n=e.events.seeked$.pipe(j(()=>e.info.playbackState$.getValue()===J.PLAYING));let u=!1;const l=new I;s.add(d.subscribe(()=>{u||l.next(),u=!0})),s.add(n.subscribe(()=>u=!1));const v=new I,$=new I,Q=O(c,n,v),G=O(h,l,o,e.events.looped$,$);let N;const ot=()=>N=r.getValue(),nt=()=>{const E=r.getValue();B(N)||N===E||B(E)||(i.next({from:N,to:E}),N=void 0)},rt=()=>{$.next(),v.next()};if(s.add(Q.subscribe(ot)),s.add(G.subscribe(nt)),t.forceInterval&&isFinite(t.forceInterval)){let E=0;s.add(Q.subscribe(()=>E=window.setTimeout(rt,t.forceInterval))),s.add(G.subscribe(()=>window.clearTimeout(E)))}return s}),Rt="_one-stat_",K=`${Rt}uuid`,q=()=>{const e=new D;return{subscription:e,subscribe:(t,i)=>{t&&e.add(t.subscribe(i))}}};class Ft{api;logger;config;subscription=new D;beforeunloadSubscription;timeSynchronisation;debugLogger=new lt;oneStatDebugLog=this.debugLogger.createComponentLog("onestat");experimental;vsid$=new R(void 0);statContext;isEmbed;embedParent;uiEvents;player;seekAction$=new R(F.UNKNOWN);uuid;constructor(t,i){this.statContext=t,this.config=Et(i.config??{}),y(i.apiEnv)&&(this.config.apiEnv=i.apiEnv),this.config.synchronizeTime&&(this.timeSynchronisation=new Lt);const s=new I;this.experimental={error$:s};const o=w.get(K);o?o.startsWith('"')&&o.endsWith('"')?(this.uuid=o.replaceAll('"',""),w.set(K,this.uuid)):this.uuid=o:(this.uuid=wt(),w.set(K,this.uuid)),this.resetViewSession();const r=new yt({apiKey:Tt,config:this.config,error$:s,timeSynchronisation:this.timeSynchronisation});this.api=new vt({config:this.config,apiTransport:r,refreshAuthToken:i.refreshAuthToken,mobile:this.statContext.mobile??!1,uuid:this.uuid,error$:s}),this.logger=new xt({config:this.config,debugLogger:this.debugLogger,api:this.api,error$:s,userSalt:i.userSalt});const{isEmbed:a,host:c}=$t();this.isEmbed=a,this.embedParent=c,this.subscribe()}updateContext(t){this.statContext={...this.statContext,...t}}attachTo(t){const i=new D,s=(n,u)=>i.add(n.subscribe(u));s(t.events.willStart$,()=>{const n=t.info.position$.getValue();this.logActionPlay({position:n}),this.statContext.projectId&&this.logActionPlayWithProjectId({position:n})}),s(t.events.looped$,()=>{this.resetViewSession(),this.logActionPlay({position:t.info.position$.getValue()})}),s(t.events.seeked$,()=>{this.logSeek({action:this.seekAction$.getValue(),time:t.info.position$.getValue()}),this.seekAction$.next(F.UNKNOWN)}),s(t.events.paused$,()=>{this.logPause({position:t.info.position$.getValue()})}),s(t.events.willResume$,()=>{this.logPlay()}),s(t.events.started$,()=>{this.statContext.clip&&this.logWatchCoverageRecord({start:0,end:0})}),s(It(t,{forceInterval:this.config.watchCoverageInterval}),n=>{const u=t.info.isLive$.getValue(),l={start:parseFloat(n.from.toFixed(3)),end:parseFloat(n.to.toFixed(3))};u?this.logWatchCoverageLive(l):this.logWatchCoverageRecord(l)});let o;s(t.info.isStalled$,n=>{n?o=p():(y(o)&&this.logEmptyBuffer({duration:p()-o}),o=void 0)});let r=!1;i.add(t.events.fatalError$.pipe(ft()).subscribe(()=>r=!0)),s(t.events.willStop$,()=>{if(t.info.isStalled$.getValue()){const u=y(o)?p()-o:void 0;this.logCloseAtEmptyBuffer({duration:u??0}),o=void 0}else r||this.logActionStop()}),s(t.events.managedError$,({id:n})=>{this.logError({fatal:!1,errorType:n})}),s(t.events.fatalError$,({id:n})=>{this.logError({fatal:!0,errorType:n})});let a,c,h=!1;s(t.events.firstBytes$,n=>{a=p(),this.logFirstBytes({time:n})}),s(t.events.willStart$,()=>c=p()),s(t.info.currentBuffer$,n=>{!h&&n&&n.end-n.start>0&&y(a)&&(this.logPlayerReady({duration:p()-a}),h=!0)}),s(t.events.firstFrame$,()=>{y(a)&&!h&&(this.logPlayerReady({duration:p()-a}),h=!0),y(c)&&this.logFirstFrame({time:p()-c})}),s(t.info.atLiveEdge$,n=>this.updateContext({liveEdge:n})),s(Y({muted:t.info.muted$,volume:t.info.volume$}),({muted:n,volume:u})=>this.updateContext({audible:!n&&u>0})),s(t.info.currentQuality$,n=>this.updateContext({quality:Nt(n)})),s(t.info.isAutoQualityEnabled$,n=>this.updateContext({autoQuality:n})),s(t.info.currentFormat$,n=>this.updateContext({contentType:kt(n)})),s(t.info.currentPlaybackRate$,n=>this.updateContext({rate:n})),s(t.info.is3DVideo$,n=>this.updateContext({is3d:n}));let d;return s(t.info.hostname$,n=>{this.updateContext({cdnHostname:n,failover:d!==void 0&&d!==n}),d=n}),s(t.info.throughputEstimation$,n=>this.updateContext({downloadSpeed:n})),s(t.info.httpConnectionType$,n=>{this.statContext.firstConnectionType||this.updateContext({firstConnectionType:st(n)}),this.updateContext({connectionType:st(n)})}),s(t.info.httpConnectionReused$,n=>{B(this.statContext.firstConnectionReused)&&this.updateContext({firstConnectionReused:n}),this.updateContext({connectionReused:n})}),s(t.info.surface$,n=>this.updateContext({mode:V(n)})),s(Y({current:t.info.currentTextTrack$,available:t.info.availableTextTracks$}),({current:n,available:u})=>{const l=u.find(({id:$})=>$===n),v=l&&(l.isAuto?`${l.language}_auto`:l.language);this.updateContext({subtitles:v})}),this.player=t,this.uiEvents&&this.attachToUi(this.uiEvents),this.resubscribeBeforeunload(),this.subscription.add(i),i}attachToUi(t){this.uiEvents=t;const{subscription:i,subscribe:s}=q();return this.player&&(s(t.actionRewind$,()=>{this.player&&(this.resetViewSession(),this.logActionPlay({position:this.player.info.position$.getValue()}))}),s(t.actionSeek$,this.seekAction$),s(t.inPiP$,o=>{const r=o?T.PIP:V(this.player?.info.surface$.getValue());this.updateContext({mode:r})}),s(t.inFullscreen$,o=>{const r=o?T.FULLSCREEN:V(this.player?.info.surface$.getValue());this.updateContext({mode:r})}),s(t.actionSetSubtitle$,o=>this.updateContext({subtitles:o})),s(t.nextMovie$,o=>this.logNextMovie(o)),this.resubscribeBeforeunload(),this.subscription.add(i)),i}attachToAds(t){const{subscription:i,subscribe:s}=q();return s(t.slotRequested$,()=>this.logAdSlotRequest()),s(t.started$,o=>this.logAdStarted(o)),s(t.paused$,()=>this.logAdPaused()),s(t.resumed$,()=>this.logAdResumed()),s(t.ended$,()=>this.logAdEnded()),s(t.skipped$,()=>this.logAdSkipped()),s(t.clicked$,()=>this.logAdClicked()),this.resubscribeBeforeunload(),this.subscription.add(i),i}attachToInteractive(t){const{subscription:i,subscribe:s}=q();return s(t.click$,o=>this.logInterfaceClick(o)),s(t.nextMovie$,o=>this.logNextMovie(o)),this.resubscribeBeforeunload(),this.subscription.add(i),i}authorize(t){return this.api.authorize(t)}pause(){this.logger.pause(),this.oneStatDebugLog({message:"paused"})}resume(){this.logger.resume(),this.oneStatDebugLog({message:"resumed"})}destroy(){this.logger.flush(),this.subscription.unsubscribe(),this.api.destroy(),this.logger.destroy()}resetViewSession(){this.oneStatDebugLog({message:"VSID reset"}),this.vsid$.next(Ot())}getDeviceId(){return this.uuid}setFieldBlacklist(){}logInited(){}logReady(t){this.log({operation:"player_ready",param:String(t.time)})}logStarted(...t){this.logActionPlay(...t)}logPlay(){this.log({operation:"play_toggle"})}logPause(t){this.log({operation:"pause",param:String(Math.round(t.position))})}logSeek(t){this.log({operation:"seek",param:t.action,time:t.time})}logFirstBytes(t){this.log({operation:"first_bytes",param:String(t.time)})}logFirstFrame(t){this.log({operation:"first_frame",param:String(t.time)})}logError(t){this.log({operation:"content_error",param:`${t.fatal?"fatal":"recoverable"}_${t.errorType}`})}logWatchCoverageRecord(t){this.log({operation:"watch_coverage_record",param:`${t.start}-${t.end}`})}logWatchCoverageLive(t){const i=this.timeSynchronisation?.getOffset()??0,s=t.start+i,o=t.end+i;this.log({operation:"watch_coverage_live",param:`${s}-${o}`})}logEmptyBuffer(t){this.log({operation:"empty_buffer",param:String(t.duration)})}logDownloadSpeed(){}logAdSlotRequest(){this.log({operation:"adv",param:"slot_request"})}logAdStarted(t){this.log({operation:"adv",param:t})}logAdPaused(){this.log({operation:"adv",param:"pause"})}logAdResumed(){this.log({operation:"adv",param:"resume"})}logAdEnded(){this.log({operation:"adv",param:"ended"})}logAdSkipped(){this.log({operation:"adv",param:"skip"})}logAdClicked(){this.log({operation:"adv",param:"click"})}logInterfaceClick(t){this.log({operation:"player_interface_click",param:t})}logNextMovie(t){this.log({operation:"next_movie",param:String(t)})}subscribe(){this.resubscribeBeforeunload();const t=window.navigator.connection;t&&"onchange"in t&&"effectiveType"in t&&this.subscription.add(O(z(t,"change"),gt(["init"])).subscribe(()=>this.updateContext({network:Ct(t.effectiveType)}))),this.config.debugLog&&this.debugLogger.log$.subscribe(i=>{console.debug("%c stat ","background:#fa6470;",`component: ${i.component}.`,i.message)})}resubscribeBeforeunload(){this.beforeunloadSubscription?.unsubscribe(),this.beforeunloadSubscription=z(window,"beforeunload").subscribe(()=>this.logger.flush(!0)),this.subscription.add(this.beforeunloadSubscription)}logPlayerReady(t){this.log({operation:"player_ready",param:String(Math.round(t.duration))})}logActionPlay(t){this.log({operation:"action_play",param:String(Math.round(t.position))})}logActionPlayWithProjectId(t){this.statContext.projectId&&this.log({operation:"action_play",param:String(Math.round(t.position))},{vid:this.statContext.projectId})}logCloseAtEmptyBuffer(t){this.log({operation:"close_at_empty_buffer",param:String(Math.round(t.duration))})}logActionStop(){this.log({operation:"action_stop"})}log(t,i={}){if(this.config.disabledOperations.includes(t.operation))return;this.oneStatDebugLog({message:`operation ${t.operation} ${t.param}`});const s=this.createLogItem(t,i);this.logger.log(s)}createLogItem({operation:t,param:i,time:s},o={}){const r=this.timeSynchronisation?.now()??p(),a=this.vsid$.getValue();pt(a);const c=t==="empty_buffer"||t==="close_at_empty_buffer"?this.statContext.connectionType:this.statContext.firstConnectionType,h=this.statContext.firstConnectionReused;let d,n;if(this.isEmbed){d=this.embedParent;const l=[...new URLSearchParams(location.search).entries()].filter(([v,$])=>this.config.embedUrlParams.includes(v));n=new URLSearchParams(l).toString()}else this.statContext.place==="direct"&&(document.referrer&&(d=new URL(document.referrer).hostname),n=location.href.substring(0,1024));const u={vsid:a,vid:this.statContext.movieId,ct:this.statContext.contentType,place:this.isEmbed?"embed":this.statContext.place,quality:this.statContext.quality,cdn_host:this.statContext.cdnHostname,stat_type:this.statContext.autoplay===!0?U.AUTO:this.statContext.autoplay===!1?U.MANUAL:void 0,param:i,vk_app_id:this.statContext.vkAppId,track_code:this.statContext.trackCode,connection_type:c,connection_reused:h===!0?A.YES:h===!1?A.NO:void 0,cached_data:this.statContext.cached===!0?A.YES:this.statContext.cached===!1?A.NO:void 0,live:this.statContext.liveEdge?A.YES:void 0,muted:this.statContext.audible===!1?A.YES:void 0,mode:this.statContext.mode,subtitles:this.statContext.subtitles,download_speed:this.statContext.downloadSpeed,manual_quality:this.statContext.autoQuality?void 0:A.YES,ref_domain:d,direct_url:n,rate:this.statContext.rate===1||B(this.statContext.rate)?void 0:this.statContext.rate.toFixed(2),view_360:this.statContext.is3d?1:void 0,aid:this.statContext.albumId,vk_playlist_id:this.statContext.vkPlaylistId,...o};for(const l of this.config.disabledCustomFields)delete u[l];return{operation:t,type:1,time:s,network:this.statContext.network,timestamp:r,custom:u}}}export{_ as ApiEnv,C as ConnectionType,g as ContentType,Z as InteractiveInterfaceClick,Ft as OneStat,m as Quality,F as SeekAction,tt as VERSION};
|
|
6
|
+
import{fillWithDefault as at,ValueSubject as R,getExponentialDelay as ht,ErrorCategory as b,now as p,safeStorage as w,assertNever as it,Observable as ut,Subscription as D,merge as I,fromEvent as z,filterChanged as ct,map as dt,filter as j,Subject as O,isNullable as B,Logger as lt,isNonNullable as x,detectEmbed as ft,once as gt,combine as Y,observableFrom as pt,assertNonNullable as mt}from"@vkontakte/videoplayer-shared/evergreen.esm.js";import X from"lodash/debounce.js";import{Surface as L,VideoQuality as S,HttpConnectionType as M,VideoFormat as d,PlaybackState as J}from"@vkontakte/videoplayer-core/evergreen.esm.js";var _;(function(e){e.PROD="prod",e.VK_ALIAS="vk_alias",e.VIDEOTEST="videotest",e.TEST="test",e.AUTO="auto"})(_||(_={}));var m;(function(e){e.Q144P="mobile",e.Q240P="lowest",e.Q360P="low",e.Q480P="medium",e.Q720P="high",e.Q1080P="fullhd",e.Q1440P="quadhd",e.Q2160P="ultrahd",e.UNKNOWN="unknown"})(m||(m={}));var g;(function(e){e.MP4="mp4",e.DASH="dash",e.DASH_SEP="dash_sep",e.ONDEMAND_DASH="ondemand_dash",e.HLS="hls",e.ONDEMAND_HLS="ondemand_hls",e.WEBM="webm",e.AV1="av1",e.ONDEMAND_DASH_LIVE="ondemand_dash_live",e.ONDEMAND_HLS_LIVE="ondemand_hls_live",e.MULTI_DASH="multi_dash",e.MULTI_HLS="multi_hls",e.WEBRTC="webrtc",e.UNKNOWN="unknown",e.RTMP="rtmp"})(g||(g={}));var U;(function(e){e.AUTO="auto",e.MANUAL=""})(U||(U={}));var k;(function(e){e.HTTP1="http1",e.HTTP2="http2",e.HTTP3="http3"})(k||(k={}));var A;(function(e){e[e.YES=1]="YES",e[e.NO=0]="NO"})(A||(A={}));var y;(function(e){e.EXCELLENT="excellent",e.GOOD="good",e.POOR="poor"})(y||(y={}));var P;(function(e){e.PIP="pip",e.FULLSCREEN="fullscreen",e.EXTERNAL="external",e.PREFETCH="prefetch",e.AIRPLAY="airplay",e.CHROMECAST="chromecast",e.INVISIBLE="invisible"})(P||(P={}));var F;(function(e){e.SLIDER="slider",e.DOUBLE_TAP="double_tap",e.TIME_CODE="time_code",e.EPISODE="episode",e.REWIND="rewind",e.LIVE="live",e.UNKNOWN="unknown"})(F||(F={}));var Z;(function(e){e.GRAPH_SHOW="iGraphShow",e.GRAPH_HIDE="iGraphHide",e.NEXT_AREA="iNextChapterArea",e.NEXT_BUTTON="iNextChapterBtn",e.WATCH_AGAIN="iWatchAgainBtn"})(Z||(Z={}));const bt={action_play:"ap",first_bytes:"fb",player_ready:"pr",first_frame:"ff",seek:"sk",watch_coverage_record:"wr",watch_coverage_live:"wl",empty_buffer:"eb",action_stop:"as",close_at_empty_buffer:"cb",content_error:"er",player_interface_click:"pc",next_movie:"nm",track_switch:"ts"},St={vsid:"si",vid:"vi",place:"pl",quality:"qt",cdn_host:"ch",stat_type:"st",param:"pm",vk_app_id:"va",track_code:"tc",connection_type:"cnt",connection_reused:"cr",cached_data:"cd",live:"lv",muted:"mu",mode:"mo",subtitles:"sb",failover:"fo",download_speed:"ds",manual_quality:"mq",ref_domain:"rd",direct_url:"du"},_t={unknown:"un",mobile:"m",lowest:"ls",low:"l",medium:"md",high:"h",fullhd:"f",quadhd:"q",ultrahd:"u"},At={pip:"pi",fullscreen:"fs",external:"ex",prefetch:"pr",airplay:"ap",chromecast:"cc",invisible:"iv"},Et={apiEnv:_.VK_ALIAS,requestRetryCount:1,firstFlushTime:5e3,flushDebounceTime:1e4,flushMaxWait:6e4,storageExpiration:36*60*60*1e3,watchCoverageInterval:15e3,disabledOperations:[],disabledCustomFields:[],shorten:!0,maxLoops:100,embedUrlParams:[],useBeacon:!0,synchronizeTime:!0,debugLog:!1,backoff:{start:1e3,factor:1.5,max:5*60*1e3,random:.1}},wt=e=>at(e,Et);function vt(){const e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),t=new Array(36);let i=0,s,o;for(o=0;o<36;o++)o===8||o===13||o===18||o===23?t[o]="-":o===14?t[o]="4":(i<=2&&(i=33554432+Math.random()*16777216|0),s=i&15,i=i>>4,t[o]=e[o===19?s&3|8:s]);return t.join("")}const Pt=e=>{const{operation:t,custom:i}=e,s=Object.fromEntries(Object.entries(i).map(([o,r])=>{const a=St[o]??o;let h=r;return r&&(o==="mode"?h=At[r]??r:o==="quality"&&(h=_t[r]??r)),[a,h]}));return{...e,operation:bt[t]??t,custom:s}},tt="1.0.45-dev.41346c2e.0",Tt="CIOPGQJGDIHBABABA",et={[_.PROD]:"https://api.ok.ru",[_.VK_ALIAS]:"https://api.mycdn.me",[_.VIDEOTEST]:"https://videotestapi.ok.ru/api",[_.TEST]:"https://apitest.ok.ru",[_.AUTO]:""};var v;(function(e){e[e.PARAM_SESSION_EXPIRED=102]="PARAM_SESSION_EXPIRED",e[e.PARAM_SESSION_KEY=103]="PARAM_SESSION_KEY",e[e.PARAM_SIGNATURE=104]="PARAM_SIGNATURE",e[e.AUTH_LOGIN=401]="AUTH_LOGIN"})(v||(v={}));class xt{params;authToken;sessionKey;authorizePromise;refreshAuthTokenPromise;consequentAuthErrors=0;authorized$=new R(!1);backoffTimeoutId;constructor(t){this.params=t}async authorize(t){return this.authToken=t??await this.refreshAuthToken(),this._authorizeWithBackoff()}logBeacon(t){const i="log.externalLog",s=this.createLogParams(t),o=this.sessionKey;if(!o)return;this.params.apiTransport.sendBeacon(i,s,o)||this.logRequest(t)}async logRequest(t){const i="log.externalLog",s=this.createLogParams(t),o=this.sessionKey??await this._authorizeWithBackoff();if(!o)return;const r=async(a,h=this.params.config.requestRetryCount)=>{try{return await this.params.apiTransport.sendRequest(i,s,o)}catch(u){if(!u||!("error_code"in u)){this.params.error$.next({id:"logRequestUnknown",category:b.NETWORK,message:`Unknown ${i} error`,thrown:u});return}const l=u?.error_code;switch(l){case v.PARAM_SESSION_EXPIRED:case v.PARAM_SESSION_KEY:case v.PARAM_SIGNATURE:return this.authorized$.next(!1),this.sessionKey=await this._authorizeWithBackoff(),h>0?r(a,h-1):void 0;case v.AUTH_LOGIN:return this.authorized$.next(!1),this.authToken=await this.refreshAuthToken(),this.sessionKey=await this._authorizeWithBackoff(),h>0?r(a,h-1):void 0;default:{this.params.error$.next({id:`LogRequest#${l}`,category:b.EXTERNAL_API,message:`${i} error`,data:u});return}}}};return r(t)}destroy(){window.clearTimeout(this.backoffTimeoutId),this.backoffTimeoutId=0}async refreshAuthToken(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=this.params.refreshAuthToken().finally(()=>{this.refreshAuthTokenPromise=void 0})),this.refreshAuthTokenPromise}createLogParams(t){return{collector:"ok.mobile.apps.video",data:JSON.stringify({application:`@vkontakte/videoplayer-statistics:${tt}`,platform:this.params.mobile?"M_WEB":"WEB",items:this.params.config.shorten?t.map(Pt):t})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();const t=ht(this.consequentAuthErrors,this.params.config.backoff);return new Promise(i=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout(()=>{this._authorize().then(i).catch(s=>this.params.error$.next({id:"AuthorizeBackoff",category:b.NETWORK,message:"Otherwise unhandled error in authorization",thrown:s})).finally(()=>this.backoffTimeoutId=0)},t))})}async _authorize(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);const t="auth.anonymLogin",i={session_data:{version:2,device_id:this.params.uuid,client_version:tt.split("-")[0],client_type:"SDK_JS"}};return this.authToken!==void 0&&(i.session_data.auth_token=this.authToken,i.session_data.version=3),this.authorizePromise=this.params.apiTransport.sendRequest(t,i).then(s=>((!s||!s.session_key)&&this.params.error$.next({id:"AuthorizeFailed",category:b.EXTERNAL_API,message:"No session key",data:s}),this.sessionKey=s?.session_key??void 0,this.sessionKey)).catch(async s=>{this.sessionKey=void 0;const o=s?.error_code;switch(o){case v.AUTH_LOGIN:return this.authToken=await this.refreshAuthToken(),this._authorizeWithBackoff()}o?this.params.error$.next({id:`Authorize#${o}`,category:b.EXTERNAL_API,message:"authorize error",data:s}):this.params.error$.next({id:"AuthorizeUnknown",category:b.NETWORK,message:"authorize error",thrown:s})}).finally(()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(this.sessionKey!==void 0)}),this.authorizePromise}}class yt{apiKey;apiBaseUrl;apiEnv;timeSynchronisation;isApiBaseUrlFetched;params;constructor(t){this.params=t,this.apiKey=t.apiKey,this.apiEnv=t.config.apiEnv,this.apiBaseUrl=et[this.apiEnv],this.timeSynchronisation=t.timeSynchronisation,this.isApiBaseUrlFetched=!1}async resolveApiBaseUrl(){if(this.apiEnv!==_.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const t=atob("aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ="),o=(await(await fetch(t,{method:"GET",mode:"cors",cache:"no-cache"})).json())?.Answer[0]?.data;if(!o)throw new Error("Wrong DNS response");return o}catch(t){return this.params.error$.next({id:"OneStat:ApiTransport:resolveApiBaseUrl",category:b.NETWORK,message:"Unhandled resolve api base url error",thrown:t}),et[_.VK_ALIAS]}finally{this.isApiBaseUrlFetched=!0}}sendBeacon(t,i,s){if(!window.Blob||!window.navigator.sendBeacon)return!1;const o=this._prepareQueryParams({method:t,queryParams:i,sessionKey:s}),r=new window.Blob([o.toString()],{type:"application/x-www-form-urlencoded"});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,r)}catch(a){this.params.error$.next({id:"OneStat:ApiTransport:sendBeacon",category:b.NETWORK,message:"Unhandled beacon error",thrown:a,data:{method:t,params:i}})}return!1}async sendRequest(t,i,s){const o=p(),r=a=>{if(a instanceof TypeError&&["Failed to fetch","NetworkError when attempting to fetch resource."].includes(a.message)){this.params.error$.next({id:"Network",category:b.NETWORK,message:"Request failed",thrown:a});return}this.params.error$.next({id:"OneStat:ApiTransport:sendRequest",category:b.NETWORK,message:"Unhandled request error",thrown:a,data:{method:t,params:i,sessionKey:s,time:p()-o}})};return this.apiBaseUrl=await this.resolveApiBaseUrl(),fetch(`${this.apiBaseUrl}/fb.do`,{method:"post",headers:{"Content-type":"application/x-www-form-urlencoded"},body:this._prepareQueryParams({method:t,queryParams:i,sessionKey:s})}).then(a=>{const h=Number(a.headers.get("content-length"))===0,u=new Date(a.headers.get("date")??"").getTime(),l=p()-o;if(isFinite(u)&&this.timeSynchronisation?.addServerTime(u,l),!h)return a.json().then(n=>Object.prototype.hasOwnProperty.call(n,"error_msg")?Promise.reject(n):n,r)},r)}_prepareQueryParams(t){const i=new URLSearchParams({format:"JSON",method:t.method,application_key:this.apiKey});return t.sessionKey!==void 0&&i.append("session_key",t.sessionKey),Object.entries(t.queryParams).forEach(([s,o])=>i.append(s,typeof o=="string"?o:JSON.stringify(o))),i}}const C="onestat_events",W=e=>t=>t.timestamp+e>=p();class $t{params;api;error$;subscription;userSalt;unsaltedStorage=[];lastVsid;isPaused=!1;firstFlush;debouncedFlush;loggerDebugLog;constructor(t){this.params=t,this.api=t.api,this.error$=t.error$,this.userSalt=t.userSalt,this.loggerDebugLog=t.debugLogger.createComponentLog("stat logger"),this.firstFlush=X(()=>this.safeFlush(),this.params.config.firstFlushTime,{maxWait:this.params.config.firstFlushTime});const i=w.isPersistent()?this.params.config.flushMaxWait:0;this.debouncedFlush=X(()=>this.safeFlush(),this.params.config.flushDebounceTime,{maxWait:i}),this.subscription=this.api.authorized$.subscribe(s=>{s&&this.debouncedFlush()}),this.housekeepStorage()}isUrgent=t=>{const{operation:i}=t;return["action_play","watch_coverage_record","watch_coverage_live"].includes(i)};safeFlush(){try{this.flush()}catch(t){this.error$.next({id:"LoggerError",category:b.WTF,message:String(t)??"Unknown logger error",thrown:t})}}readFromStorage(){const t=w.get(C);try{return t?JSON.parse(t):{}}catch{}return{}}addToStorage(t){if(!this.userSalt){this.unsaltedStorage.push(t);return}const i=this.readFromStorage(),o=(i[this.userSalt]??[]).filter(W(this.params.config.storageExpiration));w.set(C,JSON.stringify({...i,[this.userSalt]:[...o,t]}))}getFromStorage(){return this.userSalt?(this.readFromStorage()[this.userSalt]??[]).filter(W(this.params.config.storageExpiration)):this.unsaltedStorage}markStorageSent(){if(!this.userSalt){this.unsaltedStorage=[];return}const t=this.readFromStorage();delete t[this.userSalt],w.set(C,JSON.stringify(t))}housekeepStorage(){const t=this.readFromStorage();for(const[i,s]of Object.entries(t)){const o=s.filter(W(this.params.config.storageExpiration));o.length?t[i]=o:delete t[i],this.loggerDebugLog({message:`${s.length} retrieved from storage, ${o.length} of them actual`})}w.set(C,JSON.stringify(t))}log(t){this.addToStorage(t),!this.isPaused&&(this.isUrgent(t)?this.flush():this.lastVsid!==t.custom.vsid?this.firstFlush():this.debouncedFlush(),this.lastVsid=t.custom.vsid)}flush(t=!1){const i=this.getFromStorage();i.length!==0&&(this.api.authorized$.getValue()?(t&&this.params.config.useBeacon?(this.loggerDebugLog({message:`Flushing ${i.length} events through beacon`}),this.api.logBeacon(i)):(this.loggerDebugLog({message:`Flushing ${i.length} events`}),this.api.logRequest(i)),this.markStorageSent()):this.api.authorize(),this.firstFlush.cancel(),this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}destroy(){this.subscription.unsubscribe(),this.firstFlush.cancel(),this.debouncedFlush.cancel()}}const Nt=e=>e&&{[S.INVARIANT]:m.UNKNOWN,[S.Q_144P]:m.Q144P,[S.Q_240P]:m.Q240P,[S.Q_360P]:m.Q360P,[S.Q_480P]:m.Q480P,[S.Q_720P]:m.Q720P,[S.Q_1080P]:m.Q1080P,[S.Q_1440P]:m.Q1440P,[S.Q_2160P]:m.Q2160P,[S.Q_4320P]:m.UNKNOWN}[e],st=e=>e&&{[M.HTTP1]:k.HTTP1,[M.HTTP2]:k.HTTP2,[M.QUIC]:k.HTTP3}[e],Lt=e=>{if(e!==void 0)switch(e){case d.MPEG:return g.MP4;case d.DASH:case d.DASH_LIVE:return g.DASH;case d.DASH_STREAMS:return g.MULTI_DASH;case d.DASH_SEP:return g.DASH_SEP;case d.DASH_ONDEMAND:return g.ONDEMAND_DASH;case d.DASH_WEBM:case d.DASH_LIVE_WEBM:return g.WEBM;case d.DASH_WEBM_AV1:return g.AV1;case d.DASH_LIVE_CMAF:return g.ONDEMAND_DASH_LIVE;case d.HLS:case d.HLS_LIVE:return g.HLS;case d.HLS_ONDEMAND:return g.ONDEMAND_HLS;case d.HLS_LIVE_CMAF:return g.ONDEMAND_HLS_LIVE;case d.WEB_RTC_LIVE:return g.WEBRTC;default:return it(e)}},V=e=>{if(e!==void 0)switch(e){case L.NONE:case L.INLINE:return;case L.FULLSCREEN:return P.FULLSCREEN;case L.SECOND_SCREEN:return P.CHROMECAST;case L.PIP:return P.PIP;default:return it(e)}},kt=e=>{switch(e){case"slow-2g":return y.POOR;case"2g":return y.POOR;case"3g":return y.GOOD;case"4g":return y.EXCELLENT}};class Ct{offset=void 0;constructor(t){this.offset=t}getOffset(){return this.offset??0}setOffset(t){this.offset=t}now(){return Date.now()+(this.offset??0)}date(t=new Date){return t.setTime(t.getTime()+(this.offset??0)),t}addServerTime(t,i){const s=Date.now(),o=t-s-i/2;if(Math.abs(o)<1e3){this.offset=0;return}this.offset===void 0?this.offset=Math.round(o):this.offset=Math.round(.2*o+(1-.2)*this.offset)}}const It=()=>Math.floor(Math.random()*2**32).toString(36).padStart(8,"0"),Ot=(e,t)=>new ut(i=>{const s=new D,o=I(z(window,"beforeunload"),e.events.willDestruct$),r=new R(void 0);let a;s.add(e.info.isLive$.pipe(ct()).subscribe(E=>{a&&(a.unsubscribe(),r.next(void 0)),E?a=e.info.liveTime$.pipe(dt(H=>H&&H/1e3)).subscribe(r):a=e.info.position$.subscribe(r),s.add(a)}));const{playing$:h,paused$:u}=e.events,l=e.events.willSeek$.pipe(j(()=>e.info.playbackState$.getValue()===J.PLAYING)),n=e.events.seeked$.pipe(j(()=>e.info.playbackState$.getValue()===J.PLAYING));let c=!1;const f=new O;s.add(l.subscribe(()=>{c||f.next(),c=!0})),s.add(n.subscribe(()=>c=!1));const T=new O,$=new O,Q=I(h,n,T),G=I(u,f,o,e.events.looped$,$);let N;const ot=()=>N=r.getValue(),nt=()=>{const E=r.getValue();B(N)||N===E||B(E)||(i.next({from:N,to:E}),N=void 0)},rt=()=>{$.next(),T.next()};if(s.add(Q.subscribe(ot)),s.add(G.subscribe(nt)),t.forceInterval&&isFinite(t.forceInterval)){let E=0;s.add(Q.subscribe(()=>E=window.setTimeout(rt,t.forceInterval))),s.add(G.subscribe(()=>window.clearTimeout(E)))}return s}),Rt="_one-stat_",K=`${Rt}uuid`,q=()=>{const e=new D;return{subscription:e,subscribe:(t,i)=>{t&&e.add(t.subscribe(i))}}};class Ft{api;logger;config;subscription=new D;beforeunloadSubscription;timeSynchronisation;debugLogger=new lt;oneStatDebugLog=this.debugLogger.createComponentLog("onestat");loopCounter=0;disabled=!1;experimental;vsid$=new R(void 0);statContext;isEmbed;embedParent;uiEvents;player;seekAction$=new R(F.UNKNOWN);uuid;constructor(t,i){this.statContext=t,this.config=wt(i.config??{}),x(i.apiEnv)&&(this.config.apiEnv=i.apiEnv),this.config.synchronizeTime&&(this.timeSynchronisation=new Ct);const s=new O;this.experimental={error$:s};const o=w.get(K);o?o.startsWith('"')&&o.endsWith('"')?(this.uuid=o.replaceAll('"',""),w.set(K,this.uuid)):this.uuid=o:(this.uuid=vt(),w.set(K,this.uuid)),this.resetViewSession();const r=new yt({apiKey:Tt,config:this.config,error$:s,timeSynchronisation:this.timeSynchronisation});this.api=new xt({config:this.config,apiTransport:r,refreshAuthToken:i.refreshAuthToken,mobile:this.statContext.mobile??!1,uuid:this.uuid,error$:s}),this.logger=new $t({config:this.config,debugLogger:this.debugLogger,api:this.api,error$:s,userSalt:i.userSalt});const{isEmbed:a,host:h}=ft();this.isEmbed=a,this.embedParent=h,this.subscribe()}updateContext(t){this.statContext={...this.statContext,...t}}attachTo(t){const i=new D,s=(n,c)=>i.add(n.subscribe(c));s(t.events.willStart$,()=>{const n=t.info.position$.getValue();this.logActionPlay({position:n}),this.statContext.projectId&&this.logActionPlayWithProjectId({position:n})}),s(t.events.looped$,()=>{this.resetViewSession(),++this.loopCounter>this.config.maxLoops&&(this.disabled=!0),this.logActionPlay({position:t.info.position$.getValue()})}),s(t.events.seeked$,()=>{this.logSeek({action:this.seekAction$.getValue(),time:t.info.position$.getValue()}),this.seekAction$.next(F.UNKNOWN)}),s(t.events.paused$,()=>{this.logPause({position:t.info.position$.getValue()})}),s(t.events.willResume$,()=>{this.logPlay()}),s(t.events.started$,()=>{this.statContext.clip&&this.logWatchCoverageRecord({start:0,end:0})}),s(Ot(t,{forceInterval:this.config.watchCoverageInterval}),n=>{const c=t.info.isLive$.getValue(),f={start:parseFloat(n.from.toFixed(3)),end:parseFloat(n.to.toFixed(3))};c?this.logWatchCoverageLive(f):this.logWatchCoverageRecord(f)});let o;s(t.info.isStalled$,n=>{n?o=p():(x(o)&&this.logEmptyBuffer({duration:p()-o}),o=void 0)});let r=!1;i.add(t.events.fatalError$.pipe(gt()).subscribe(()=>r=!0)),s(t.events.willStop$,()=>{if(t.info.isStalled$.getValue()){const c=x(o)?p()-o:void 0;this.logCloseAtEmptyBuffer({duration:c??0}),o=void 0}else r||this.logActionStop()}),s(t.events.managedError$,({id:n})=>{this.logError({fatal:!1,errorType:n})}),s(t.events.fatalError$,({id:n})=>{this.logError({fatal:!0,errorType:n})});let a,h,u=!1;s(t.events.firstBytes$,n=>{a=p(),this.logFirstBytes({time:n})}),s(t.events.willStart$,()=>h=p()),s(t.info.currentBuffer$,n=>{!u&&n&&n.end-n.start>0&&x(a)&&(this.logPlayerReady({duration:p()-a}),u=!0)}),s(t.events.firstFrame$,()=>{x(a)&&!u&&(this.logPlayerReady({duration:p()-a}),u=!0),x(h)&&this.logFirstFrame({time:p()-h})}),s(t.info.atLiveEdge$,n=>this.updateContext({liveEdge:n})),s(Y({muted:t.info.muted$,volume:t.info.volume$}),({muted:n,volume:c})=>this.updateContext({audible:!n&&c>0})),s(t.info.currentQuality$,n=>this.updateContext({quality:Nt(n)})),s(t.info.isAutoQualityEnabled$,n=>this.updateContext({autoQuality:n})),s(t.info.currentFormat$,n=>this.updateContext({contentType:Lt(n)})),s(t.info.currentPlaybackRate$,n=>this.updateContext({rate:n})),s(t.info.is3DVideo$,n=>this.updateContext({is3d:n}));let l;return s(t.info.hostname$,n=>{this.updateContext({cdnHostname:n,failover:l!==void 0&&l!==n}),l=n}),s(t.info.throughputEstimation$,n=>this.updateContext({downloadSpeed:n})),s(t.info.httpConnectionType$,n=>{this.statContext.firstConnectionType||this.updateContext({firstConnectionType:st(n)}),this.updateContext({connectionType:st(n)})}),s(t.info.httpConnectionReused$,n=>{B(this.statContext.firstConnectionReused)&&this.updateContext({firstConnectionReused:n}),this.updateContext({connectionReused:n})}),s(t.info.surface$,n=>this.updateContext({mode:V(n)})),s(Y({current:t.info.currentTextTrack$,available:t.info.availableTextTracks$}),({current:n,available:c})=>{const f=c.find(({id:$})=>$===n),T=f&&(f.isAuto?`${f.language}_auto`:f.language);this.updateContext({subtitles:T})}),this.player=t,this.uiEvents&&this.attachToUi(this.uiEvents),this.resubscribeBeforeunload(),this.subscription.add(i),i}attachToUi(t){this.uiEvents=t;const{subscription:i,subscribe:s}=q();return this.player&&(s(t.actionRewind$,()=>{this.player&&(this.resetViewSession(),this.logActionPlay({position:this.player.info.position$.getValue()}))}),s(t.actionSeek$,this.seekAction$),s(t.inPiP$,o=>{const r=o?P.PIP:V(this.player?.info.surface$.getValue());this.updateContext({mode:r})}),s(t.inFullscreen$,o=>{const r=o?P.FULLSCREEN:V(this.player?.info.surface$.getValue());this.updateContext({mode:r})}),s(t.actionSetSubtitle$,o=>this.updateContext({subtitles:o})),s(t.nextMovie$,o=>this.logNextMovie(o)),this.resubscribeBeforeunload(),this.subscription.add(i)),i}attachToAds(t){const{subscription:i,subscribe:s}=q();return s(t.slotRequested$,()=>this.logAdSlotRequest()),s(t.started$,o=>this.logAdStarted(o)),s(t.paused$,()=>this.logAdPaused()),s(t.resumed$,()=>this.logAdResumed()),s(t.ended$,()=>this.logAdEnded()),s(t.skipped$,()=>this.logAdSkipped()),s(t.clicked$,()=>this.logAdClicked()),this.resubscribeBeforeunload(),this.subscription.add(i),i}attachToInteractive(t){const{subscription:i,subscribe:s}=q();return s(t.click$,o=>this.logInterfaceClick(o)),s(t.nextMovie$,o=>this.logNextMovie(o)),this.resubscribeBeforeunload(),this.subscription.add(i),i}authorize(t){return this.api.authorize(t)}pause(){this.logger.pause(),this.oneStatDebugLog({message:"paused"})}resume(){this.logger.resume(),this.oneStatDebugLog({message:"resumed"})}destroy(){this.logger.flush(),this.subscription.unsubscribe(),this.api.destroy(),this.logger.destroy()}resetViewSession(){this.oneStatDebugLog({message:"VSID reset"}),this.vsid$.next(It())}getDeviceId(){return this.uuid}setFieldBlacklist(){}logInited(){}logReady(t){this.log({operation:"player_ready",param:String(t.time)})}logStarted(...t){this.logActionPlay(...t)}logPlay(){this.log({operation:"play_toggle"})}logPause(t){this.log({operation:"pause",param:String(Math.round(t.position))})}logSeek(t){this.log({operation:"seek",param:t.action,time:t.time})}logFirstBytes(t){this.log({operation:"first_bytes",param:String(t.time)})}logFirstFrame(t){this.log({operation:"first_frame",param:String(t.time)})}logError(t){this.log({operation:"content_error",param:`${t.fatal?"fatal":"recoverable"}_${t.errorType}`})}logWatchCoverageRecord(t){this.log({operation:"watch_coverage_record",param:`${t.start}-${t.end}`})}logWatchCoverageLive(t){const i=this.timeSynchronisation?.getOffset()??0,s=t.start+i,o=t.end+i;this.log({operation:"watch_coverage_live",param:`${s}-${o}`})}logEmptyBuffer(t){this.log({operation:"empty_buffer",param:String(t.duration)})}logDownloadSpeed(){}logAdSlotRequest(){this.log({operation:"adv",param:"slot_request"})}logAdStarted(t){this.log({operation:"adv",param:t})}logAdPaused(){this.log({operation:"adv",param:"pause"})}logAdResumed(){this.log({operation:"adv",param:"resume"})}logAdEnded(){this.log({operation:"adv",param:"ended"})}logAdSkipped(){this.log({operation:"adv",param:"skip"})}logAdClicked(){this.log({operation:"adv",param:"click"})}logInterfaceClick(t){this.log({operation:"player_interface_click",param:t})}logNextMovie(t){this.log({operation:"next_movie",param:String(t)})}subscribe(){this.resubscribeBeforeunload();const t=window.navigator.connection;t&&"onchange"in t&&"effectiveType"in t&&this.subscription.add(I(z(t,"change"),pt(["init"])).subscribe(()=>this.updateContext({network:kt(t.effectiveType)}))),this.config.debugLog&&this.debugLogger.log$.subscribe(i=>{console.debug("%c stat ","background:#fa6470;",`component: ${i.component}.`,i.message)})}resubscribeBeforeunload(){this.beforeunloadSubscription?.unsubscribe(),this.beforeunloadSubscription=z(window,"beforeunload").subscribe(()=>this.logger.flush(!0)),this.subscription.add(this.beforeunloadSubscription)}logPlayerReady(t){this.log({operation:"player_ready",param:String(Math.round(t.duration))})}logActionPlay(t){this.log({operation:"action_play",param:String(Math.round(t.position))})}logActionPlayWithProjectId(t){this.statContext.projectId&&this.log({operation:"action_play",param:String(Math.round(t.position))},{vid:this.statContext.projectId})}logCloseAtEmptyBuffer(t){this.log({operation:"close_at_empty_buffer",param:String(Math.round(t.duration))})}logActionStop(){this.log({operation:"action_stop"})}log(t,i={}){if(this.disabled){this.oneStatDebugLog({message:`operation ${t.operation} but statistics is disabled`});return}if(this.config.disabledOperations.includes(t.operation)){this.oneStatDebugLog({message:`operation ${t.operation} but it is disabled`});return}this.oneStatDebugLog({message:`operation ${t.operation} ${t.param}`});const s=this.createLogItem(t,i);this.logger.log(s)}createLogItem({operation:t,param:i,time:s},o={}){const r=this.timeSynchronisation?.now()??p(),a=this.vsid$.getValue();mt(a);const h=t==="empty_buffer"||t==="close_at_empty_buffer"?this.statContext.connectionType:this.statContext.firstConnectionType,u=this.statContext.firstConnectionReused;let l,n;if(this.isEmbed){l=this.embedParent;const f=[...new URLSearchParams(location.search).entries()].filter(([T,$])=>this.config.embedUrlParams.includes(T));n=new URLSearchParams(f).toString()}else this.statContext.place==="direct"&&(document.referrer&&(l=new URL(document.referrer).hostname),n=location.href.substring(0,1024));const c={vsid:a,vid:this.statContext.movieId,ct:this.statContext.contentType,place:this.isEmbed?"embed":this.statContext.place,quality:this.statContext.quality,cdn_host:this.statContext.cdnHostname,stat_type:this.statContext.autoplay===!0?U.AUTO:this.statContext.autoplay===!1?U.MANUAL:void 0,param:i,vk_app_id:this.statContext.vkAppId,track_code:this.statContext.trackCode,connection_type:h,connection_reused:u===!0?A.YES:u===!1?A.NO:void 0,cached_data:this.statContext.cached===!0?A.YES:this.statContext.cached===!1?A.NO:void 0,live:this.statContext.liveEdge?A.YES:void 0,muted:this.statContext.audible===!1?A.YES:void 0,mode:this.statContext.mode,subtitles:this.statContext.subtitles,download_speed:this.statContext.downloadSpeed,manual_quality:this.statContext.autoQuality?void 0:A.YES,ref_domain:l,direct_url:n,rate:this.statContext.rate===1||B(this.statContext.rate)?void 0:this.statContext.rate.toFixed(2),view_360:this.statContext.is3d?1:void 0,aid:this.statContext.albumId,vk_playlist_id:this.statContext.vkPlaylistId,...o};for(const f of this.config.disabledCustomFields)delete c[f];return{operation:t,type:1,time:s,network:this.statContext.network,timestamp:r,custom:c}}}export{_ as ApiEnv,k as ConnectionType,g as ContentType,Z as InteractiveInterfaceClick,Ft as OneStat,m as Quality,F as SeekAction,tt as VERSION};
|
package/index.d.ts
CHANGED
|
@@ -32,6 +32,8 @@ declare enum ContentType {
|
|
|
32
32
|
AV1 = "av1",
|
|
33
33
|
ONDEMAND_DASH_LIVE = "ondemand_dash_live",
|
|
34
34
|
ONDEMAND_HLS_LIVE = "ondemand_hls_live",
|
|
35
|
+
MULTI_DASH = "multi_dash",
|
|
36
|
+
MULTI_HLS = "multi_hls",
|
|
35
37
|
WEBRTC = "webrtc",
|
|
36
38
|
UNKNOWN = "unknown",
|
|
37
39
|
/** @deprecated сдк не поддерживает RTMP, не нужно его использовать */
|
|
@@ -126,6 +128,7 @@ interface IConfig {
|
|
|
126
128
|
disabledOperations: Operation[];
|
|
127
129
|
disabledCustomFields: (keyof ILogCustomData)[];
|
|
128
130
|
shorten: boolean;
|
|
131
|
+
maxLoops: number;
|
|
129
132
|
embedUrlParams: string[];
|
|
130
133
|
useBeacon: boolean;
|
|
131
134
|
synchronizeTime: boolean;
|
|
@@ -411,6 +414,8 @@ declare class OneStat implements IOneStat {
|
|
|
411
414
|
private timeSynchronisation?;
|
|
412
415
|
private debugLogger;
|
|
413
416
|
private oneStatDebugLog;
|
|
417
|
+
private loopCounter;
|
|
418
|
+
private disabled;
|
|
414
419
|
experimental: {
|
|
415
420
|
error$: IObservable<IError>;
|
|
416
421
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vkontakte/videoplayer-statistics",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.45-dev.41346c2e.0",
|
|
4
4
|
"author": "vk.com",
|
|
5
5
|
"description": "Statistics library for vk.com videoplayer",
|
|
6
6
|
"homepage": "https://vk.com",
|
|
@@ -49,10 +49,10 @@
|
|
|
49
49
|
"**/*.d.ts"
|
|
50
50
|
],
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@vkontakte/videoplayer-shared": "1.0.
|
|
52
|
+
"@vkontakte/videoplayer-shared": "1.0.32-dev.7bf5a18e.0",
|
|
53
53
|
"lodash": "4.17.21"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@vkontakte/videoplayer-core": "2.0.
|
|
56
|
+
"@vkontakte/videoplayer-core": "2.0.98-dev.1707cd0.0"
|
|
57
57
|
}
|
|
58
58
|
}
|