@vkontakte/videoplayer-shared 1.0.83-dev.b507ef65.0 → 1.0.83-dev.c0f690bfb.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/es2018.cjs +3 -3
- package/es2018.esm.js +3 -3
- package/es2024.cjs +3 -3
- package/es2024.esm.js +3 -3
- package/esnext.cjs +3 -3
- package/esnext.esm.js +3 -3
- package/evergreen.esm.js +3 -3
- package/package.json +1 -1
- package/types/AppTracer/AppTracer.d.ts +23 -23
- package/types/AppTracer/index.d.ts +2 -2
- package/types/AppTracer/types.d.ts +14 -14
- package/types/AppTracer/utils.d.ts +2 -2
- package/types/InternalsExposure/index.d.ts +18 -18
- package/types/Logger/Logger.d.ts +8 -8
- package/types/Logger/index.d.ts +2 -2
- package/types/Logger/types.d.ts +21 -22
- package/types/Tracer/FakeTracer.d.ts +11 -11
- package/types/Tracer/RootTracer.d.ts +8 -8
- package/types/Tracer/Tracer.d.ts +23 -22
- package/types/Tracer/TracerFactory.d.ts +2 -2
- package/types/Tracer/index.d.ts +3 -3
- package/types/Tracer/types.d.ts +24 -24
- package/types/Tracer/utils.d.ts +2 -2
- package/types/devNull.d.ts +4 -4
- package/types/index.d.ts +11 -11
- package/types/reactive/Observable.d.ts +12 -12
- package/types/reactive/ReplaySubject.d.ts +10 -9
- package/types/reactive/Subject.d.ts +8 -8
- package/types/reactive/Subscription.d.ts +4 -4
- package/types/reactive/SubscriptionRemovable.d.ts +3 -3
- package/types/reactive/ValueSubject.d.ts +8 -8
- package/types/reactive/combine.d.ts +5 -8
- package/types/reactive/fromEvent.d.ts +3 -3
- package/types/reactive/index.d.ts +25 -25
- package/types/reactive/interval.d.ts +2 -2
- package/types/reactive/merge.d.ts +81 -11
- package/types/reactive/observableFrom.d.ts +1 -1
- package/types/reactive/operators/buffer.d.ts +1 -1
- package/types/reactive/operators/debounce.d.ts +7 -6
- package/types/reactive/operators/filter.d.ts +5 -2
- package/types/reactive/operators/filterChanged.d.ts +3 -3
- package/types/reactive/operators/map.d.ts +5 -2
- package/types/reactive/operators/mapTo.d.ts +5 -2
- package/types/reactive/operators/once.d.ts +3 -3
- package/types/reactive/operators/pairwise.d.ts +1 -2
- package/types/reactive/operators/shareReplay.d.ts +1 -1
- package/types/reactive/operators/skip.d.ts +4 -4
- package/types/reactive/operators/tap.d.ts +1 -1
- package/types/reactive/operators/throttle.d.ts +6 -5
- package/types/reactive/timeout.d.ts +2 -2
- package/types/reactive/types.d.ts +36 -18
- package/types/translation/index.d.ts +2 -2
- package/types/translation/loadVKLangPack.d.ts +12 -12
- package/types/translation/types.d.ts +2 -2
- package/types/types/index.d.ts +57 -58
- package/types/utils/abortable.d.ts +4 -1
- package/types/utils/config.d.ts +1 -1
- package/types/utils/debounceFn.d.ts +7 -7
- package/types/utils/detectEmbed.d.ts +4 -4
- package/types/utils/exponentialBackoff.d.ts +6 -6
- package/types/utils/flattenObject.d.ts +7 -7
- package/types/utils/getRangeAroundIndex.d.ts +5 -5
- package/types/utils/index.d.ts +34 -29
- package/types/utils/interpolate.d.ts +9 -9
- package/types/utils/isIntersecting.d.ts +3 -3
- package/types/utils/now.d.ts +1 -1
- package/types/utils/observeElementSize.d.ts +3 -3
- package/types/utils/quality/index.d.ts +7 -7
- package/types/utils/quality/types.d.ts +16 -16
- package/types/utils/throttleFn.d.ts +4 -3
- package/es2015.cjs +0 -6
- package/es2015.esm.js +0 -6
package/evergreen.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-shared v1.0.83-dev.
|
|
3
|
-
*
|
|
2
|
+
* @vkontakte/videoplayer-shared v1.0.83-dev.c0f690bfb.0
|
|
3
|
+
* Wed, 11 Mar 2026 16:59:28 GMT
|
|
4
4
|
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-83/doc/
|
|
5
5
|
*/
|
|
6
|
-
var Ke=Object.defineProperty;var de=(t,e)=>{for(var r in e)Ke(t,r,{get:e[r],enumerable:!0})};var Be="1.0.83-dev.b507ef65.0";var b=class{constructor(){this.subscriptions=[]}unsubscribe(){let e=this.subscriptions;this.subscriptions=[],e.forEach(r=>{typeof r=="function"?r():r.unsubscribe()})}add(e){return this.subscriptions.push(e),this}};var g=t=>{throw new Error(`${t} is value of unexpected type`)},Ge=t=>{};var S=()=>{};var He=t=>{throw console.error(t),t},qe=t=>{console.error(t)},c=class{constructor(e){this.suppressErrors=!1;e&&(this._subscribe=e)}setSuppressErrors(e){this.suppressErrors=e}subscribe(e,r){let o=this.suppressErrors?qe:He,n;r?typeof r=="function"?n={next:r,error:S}:n={next:a=>r.next(a),error:a=>r.error?.(a)}:n={next:o,error:S};let s=typeof e=="function"?{next:a=>{try{let p=e(a);p instanceof Promise&&p.catch(m=>n.next(m))}catch(p){n.next(p)}},error:a=>n.next(a)}:{next:a=>e.next(a),error:a=>e.error?e.error(a):n.next(a)},i;try{i=this._subscribe(s)}catch(a){s.error?.(a)}return new b().add(()=>{switch(s.next=S,s.error=S,typeof i){case"function":i();return;case"object":i.unsubscribe();return;case"undefined":return;default:return g(i)}})}pipe(...e){return e.reduce((r,o)=>o(r),this)}_subscribe(e){}};var h=class extends c{constructor(){super();this.keyCounter=0;this.subscribers=new Map}next(r){this.subscribers.forEach(o=>o.next(r))}error(r){this.subscribers.forEach(o=>o.error?.(r))}_subscribe(r){let o=this.keyCounter++;return this.subscribers.set(o,r),new b().add(()=>this.subscribers.delete(o))}};var K=class{constructor(){this.log$=new h;this.logs=[];this.log=e=>{let r={...e,timestamp:Date.now()};this.logs.push(r),this.log$.next(r)};this.getAllLogs=()=>this.logs}createCustomLog(e){return(...r)=>{let o;try{o=e(...r)}catch{o={message:"error in `createCustomLog`",component:"Logger"}}this.log(o)}}createComponentLog(e){return this.createCustomLog(r=>({component:e,...r}))}};function $e(t,e='Assertion "value is not nullable" failed'){if(t==null)throw new Error(e)}function Ye(t,e='Assertion "value is nullable" failed'){if(t!=null)throw new Error(e)}function v(t){return typeof t<"u"&&t!==null}function O(t){return t==null}var B=t=>Object.fromEntries(Object.entries(t).filter(([e,r])=>v(r)));function Xe(t,e){if(!t?.length)throw new Error(e)}function Je(t,e){if(t?.length)throw new Error(e)}var u=()=>globalThis,be=(t=u())=>!!(t.window&&t.screen);var Ze=(t,e,r)=>new Promise((o,n)=>{e.addEventListener("abort",()=>{a(),m.remove()});let s=()=>{a(),n("error")},i=()=>{a(),o()},a=()=>{p&&clearTimeout(p),m.removeEventListener("load",i),m.removeEventListener("error",s)},p;r&&(p=u().setTimeout(()=>{a(),n("timeout")},r));let m=document.createElement("script");m.addEventListener("load",i),m.addEventListener("error",s),m.src=t,document.head.appendChild(m)});var et=typeof u().performance?.now=="function"?()=>u().performance.now():()=>Date.now();var tt=(t,e)=>async(...r)=>{let o=e(...r),n=t.aborted,s;for(;!n&&!t.aborted;)try{let i=await o.next(s);n=i.done??!1,s=i.value}catch(i){await o.throw(i)}return s};var rt=(t,{start:e=0,factor:r=2,max:o=1/0,min:n=e,random:s=0}={})=>{let i=e;return i*=r**t,i*=1+(Math.random()*s*2-s),i=Math.round(i),i=Math.min(i,o),i=Math.max(i,n),i};var fe={};de(fe,{clear:()=>ct,get:()=>nt,has:()=>st,isPersistent:()=>ot,remove:()=>at,set:()=>it});var A,w,G=`vk-videoplayer-dummy-key-${Math.random()}`,P=()=>{if(w!==void 0)return w;try{localStorage.setItem(G,"test"),localStorage.removeItem(G),w=0}catch(t){if(t instanceof DOMException||t instanceof TypeError)try{sessionStorage.getItem(G),w=1}catch(e){if(e instanceof DOMException||e instanceof TypeError)w=2;else throw e}else throw t}return w===2&&(A=new Map),w},ot=()=>P()===0,nt=t=>{let e=P();switch(e){case 0:return localStorage.getItem(t)??void 0;case 1:return sessionStorage.getItem(t)??void 0;case 2:return A?.get(t);default:g(e)}},it=(t,e)=>{let r=P();switch(r){case 0:try{localStorage.setItem(t,e)}catch(o){if(o instanceof DOMException)console.error(o);else throw o}break;case 1:try{sessionStorage.setItem(t,e)}catch(o){if(o instanceof DOMException)console.error(o);else throw o}break;case 2:A?.set(t,e);return;default:g(r)}},st=t=>{let e=P();switch(e){case 0:return t in localStorage;case 1:return t in sessionStorage;case 2:return A?.has(t)??!1;default:return g(e),!1}},at=t=>{let e=P();switch(e){case 0:return localStorage.removeItem(t);case 1:return sessionStorage.removeItem(t);case 2:A?.delete(t);return;default:g(e)}},ct=()=>{let t=P();switch(t){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return A?.clear();default:g(t)}};var pt=()=>{let t,e=[],r=u();try{t=r.self!==r.top}catch(o){o instanceof DOMException&&o.name==="SecurityError"?t=!0:(t=!1,console.error(o))}try{r.location.ancestorOrigins&&(e=[...r.location.ancestorOrigins])}catch(o){console.error(o)}try{!e.length&&r.document.referrer&&(e=[new URL(r.document.referrer).origin])}catch(o){console.error(o)}return e=e.filter(o=>URL.canParse(o)),{isEmbed:t,origins:e,topOrigin:e.at(-1),immediateOrigin:e.at(0)}};var H=(l=>(l.INVARIANT="Invariant quality",l.Q_144P="144p",l.Q_240P="240p",l.Q_360P="360p",l.Q_480P="480p",l.Q_576P="576p",l.Q_720P="720p",l.Q_1080P="1080p",l.Q_1440P="1440p",l.Q_2160P="2160p",l.Q_4320P="4320p",l))(H||{});var T={"144p":{width:256,height:144},"240p":{width:428,height:240},"360p":{width:640,height:360},"480p":{width:856,height:480},"576p":{width:1024,height:576},"720p":{width:1280,height:720},"1080p":{width:1920,height:1080},"1440p":{width:2560,height:1440},"2160p":{width:3840,height:2160},"4320p":{width:7680,height:4320}},lt=(t,e)=>T[t].height>T[e].height,ut=(t,e)=>T[t].height>=T[e].height,q=(t,e)=>T[t].height<T[e].height,mt=(t,e)=>T[t].height<=T[e].height,dt=t=>t.sort((e,r)=>e===r?0:e==="Invariant quality"?1:r==="Invariant quality"?-1:q(e,r)?1:-1)[0],Te=Object.keys(T).sort((t,e)=>q(t,e)?-1:1),bt=(t,e=.02)=>[...Te].find(o=>T[o].height*(1+e)>=t),ft=({width:t,height:e})=>{let r=Math.min(t,e),o=Math.max(t,e);return Te.find(n=>{let s=T[n];return s.width>=o&&s.height>=r})},Tt=t=>T[t].height,$=t=>t==="Invariant quality",yt=t=>t.every(e=>!$(e));function It(t){if($(t))throw new Error("Expected exact quality")}var ht=t=>{switch(t){case"4320p":return"8K";case"2160p":return"4K";case"1440p":return"QHD";case"1080p":return"FHD";case"720p":return"HD";default:return""}};var gt=(t,e)=>{let r={};for(let o of Object.keys(e)){let n=e[o],s=t[o];Array.isArray(n)&&Array.isArray(s)?r[o]=s:typeof n=="object"&&typeof s=="object"?r[o]=gt(s,n):r[o]=o in t?s:n}return r};var kr=t=>{let e="";return t>=3600&&(e+=Math.floor(t/3600)+"h",t=t%3600),t>=60&&(e+=Math.floor(t/60)+"m",t=t%60),t>0&&(e+=Math.floor(t)+"s"),e};function Y(t,e=0,r){let o,n,s,i,a,p,m=0,y=!1,l=!1,z=!0,pe=!e&&e!==0&&typeof u().requestAnimationFrame=="function";r&&(y=!!r.leading,l="maxWait"in r,s=r?.maxWait?Math.max(+r?.maxWait||0,e):s,z="trailing"in r?!!r.trailing:z);function F(d){let I=o,E=n;return o=n=void 0,m=d,i=t.apply(E,I),i}function R(d,I){return pe?(a&&u().cancelAnimationFrame(a),u().requestAnimationFrame(d)):setTimeout(d,I)}function De(d){if(pe){u().cancelAnimationFrame(d);return}clearTimeout(d)}function Ue(d){return m=d,a=R(L,e),y?F(d):i}function je(d){let I=d-p,E=d-m,me=e-I;return l?Math.min(me,s-E):me}function le(d){let I=d-p,E=d-m;return p===void 0||I>=e||I<0||l&&E>=s}function L(){let d=Date.now();if(le(d))return ue(d);a=R(L,je(d))}function ue(d){return a=void 0,z&&o?F(d):(o=n=void 0,i)}function We(){a!==void 0&&De(a),m=0,o=p=n=a=void 0}function ze(){return a===void 0?i:ue(Date.now())}function Fe(){return a!==void 0}function C(...d){let I=Date.now(),E=le(I);if(o=d,n=this,p=I,E){if(a===void 0)return Ue(p);if(l)return a=R(L,e),F(p)}return a===void 0&&(a=R(L,e)),i}return C.cancel=We,C.flush=ze,C.pending=Fe,C}var X=(t,e=0,r)=>Y(t,e,{...{leading:!0,trailing:!0},...r,maxWait:e});var M=(t,e)=>{if(t===null||typeof t!="object")return t;let r=Array.isArray(t)?[]:{};for(let o in t){if(typeof e=="function"){let n=e(t[o],o,t,r);if(n!==void 0){r[o]=n;continue}}typeof t[o]=="object"?r[o]=M(t[o],e):r[o]=t[o]}return r};var vt=t=>M(t);var k=class extends h{constructor(r){super();this.buffer=[];this.cursorEnd=-1;this.cursorStart=0;this.bufferSize=r,this.buffer=Array(r)}next(r){this.cursorEnd+=1,this.cursorStart=this.cursorEnd>=this.bufferSize?this.cursorStart+1:0,this.buffer[this.cursorEnd%this.bufferSize]=r,this.subscribers.forEach(o=>o.next(r))}_subscribe(r){for(let n=this.cursorStart;n<=this.cursorEnd;n++)r.next(this.buffer[n%this.bufferSize]);let o=this.keyCounter++;return this.subscribers.set(o,r),new b().add(()=>this.subscribers.delete(o))}};var V=class extends h{constructor(e){super(),this.value=e}next(e){super.next(this.value=e)}error(e){super.error(this.value=e)}getValue(){return this.value}_subscribe(e){let r=super._subscribe(e);return e.next(this.value),r}};function ye(t){return new c(e=>{let r={},o=Object.keys(t).length,n=s=>i=>{s in r||o--,r[s]=i,o===0&&e.next(r)};return Object.entries(t).reduce((s,[i,a])=>s.add(a.subscribe(n(i))),new b)})}function Ie(...t){return new c(e=>t.reduce((r,o)=>r.add(o.subscribe(e)),new b))}var xt=t=>new c(e=>{let r=u().setTimeout(()=>{try{e.next()}catch(o){if(e.error)e.error(o);else throw o}},t);return()=>u().clearTimeout(r)});var Et=t=>new c(e=>{let r=u(),o=r.setInterval(()=>e.next(),t);return()=>{o&&(r.clearInterval(o),o=void 0)}});var Ot=t=>new c(e=>{t.forEach(r=>e.next(r))});var wt=(t,e)=>new c(r=>{let o=n=>r.next(n);return t.addEventListener(e,o),()=>t.removeEventListener(e,o)});var Q=class extends b{remove(e){this.subscriptions=this.subscriptions.filter(r=>r!==e)}};function he(t){return e=>new c(r=>e.subscribe(new J(r,t)))}var J=class{constructor(e,r){this.destination=e;this.size=r;this.lastValues=[]}next(e){this.lastValues.length===this.size&&this.lastValues.shift(),this.lastValues.push(e),this.destination.next(this.lastValues)}error(e){this.destination.error?.(e)}};var St={leading:!1,trailing:!0};function ge(t,e=St){return r=>new c(o=>r.subscribe(new Z(o,t,e)))}var Z=class{constructor(e,r,o){this.destination=e;this.time=r;this.config=o}next(e){this.lastValue=e;let r=u();v(this.timeout)?r.clearTimeout(this.timeout):this.config.leading&&this.destination.next(e),this.timeout=r.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(o){if(this.destination.error)this.destination.error(o);else throw o}this.timeout=void 0},this.time)}error(e){this.destination.error?.(e)}};var At={leading:!0,trailing:!1};function ve(t,e=At){return r=>new c(o=>r.subscribe(new ee(o,t,e)))}var ee=class{constructor(e,r,o){this.destination=e;this.time=r;this.config=o}next(e){this.lastValue=e,O(this.timeout)&&(this.config.leading&&this.destination.next(e),this.timeout=u().setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(e){this.destination.error?.(e)}};function xe(t){return e=>new c(r=>e.subscribe(new te(r,t)))}var te=class{constructor(e,r){this.destination=e;this.predicate=r}next(e){let r;try{r=this.predicate(e)}catch(o){throw this.error(o),o}r&&this.destination.next(e)}error(e){this.destination.error?.(e)}};var Pt=(t,e)=>{let r=(o,n)=>{let s=Object.keys(o);for(let i in n)if(!s.includes(i)||n[i]!==o[i])return!1;return!0};return r(t,e)&&r(e,t)},kt=(t,e)=>t instanceof Object&&e instanceof Object?Pt(t,e):t===e;function Oe(t=kt){return e=>new c(r=>e.subscribe(new re(r,t)))}var Ee={},re=class{constructor(e,r){this.destination=e;this.predicate=r;this.lastValue=Ee}next(e){let r;try{r=this.lastValue===Ee||!this.predicate(this.lastValue,e),this.lastValue=e instanceof Object&&!Array.isArray(e)?{...e}:e}catch(o){throw this.error(o),o}r&&this.destination.next(e)}error(e){this.destination.error?.(e)}};function _(t){return e=>new c(r=>e.subscribe(new oe(r,t)))}var oe=class{constructor(e,r){this.destination=e;this.mapper=r}next(e){let r;try{r=this.mapper(e)}catch(o){throw this.error(o),o}this.destination.next(r)}error(e){this.destination.error?.(e)}};function we(t){return _(()=>t)}function Se(){return t=>new c(e=>{let r=!1,o=!1,n=t.subscribe(s=>{r||(r=!0,e.next(s)),o&&n.unsubscribe()},s=>{r=!0,e.error?.(s),o&&n.unsubscribe()});return o=!0,r&&n.unsubscribe(),n})}function Ae(){return t=>new c(e=>t.subscribe(new ne(e)))}var ne=class{constructor(e){this.destination=e;this.hasLast=!1}next(e){let r=this.last;if(this.last=e,!this.hasLast){this.hasLast=!0;return}this.destination.next([r,e])}error(e){this.destination.error?.(e)}};function Pe(t){return e=>new c(r=>e.subscribe(new ie(r,t)))}var ie=class{constructor(e,r){this.destination=e;this.effect=r}next(e){try{this.effect(e)}catch(r){throw this.error(r),r}this.destination.next(e)}error(e){this.destination.error?.(e)}};function ke(t){return e=>new c(r=>e.subscribe(new se(r,t)))}var se=class{constructor(e,r){this.destination=e;this.count=r;r<0&&this.destination.error?.(new Error("Count can not be less than zero"))}next(e){this.count===0?this.destination.next(e):this.count--}error(e){this.destination.error?.(e)}};function Ne(t=0){return e=>{let r=0,o=new k(t),n=e.subscribe(o),s=i=>()=>{i.unsubscribe(),r--,r===0&&n.unsubscribe()};return new c(i=>(r++,s(o.subscribe(i))))}}var Nt=300,Rt=(t,e=Nt)=>new c(r=>{let o=u(),{width:n,height:s}=t.getBoundingClientRect();if(r.next({width:n,height:s}),!be(o))return;let i=new o.ResizeObserver(X(a=>{let p=a[0];if(!p)return;let m,y;p.contentBoxSize&&p.contentBoxSize[0]?(y=p.contentBoxSize[0].blockSize,m=p.contentBoxSize[0].inlineSize):p.contentRect&&(m=p.contentRect.width,y=p.contentRect.height),v(m)&&v(y)&&r.next({width:m,height:y})},e));return i.observe(t),()=>i.disconnect()});var D=(t,e=6,r=".")=>{let o={};for(let n in t)if(!(!t.hasOwnProperty(n)||t[n]instanceof HTMLElement||!e))if(typeof t[n]=="object"&&t[n]!==null){let s=D(t[n],e-1);for(let i in s)s.hasOwnProperty(i)&&(o[n+r+i]=s[i])}else o[n]=t[n];return o};var Lt=(t,e=!1)=>{e&&(t.innerHTML=""),t.removeAttribute("src"),t.load()};var gn=t=>{let e;try{e=new URL(t)}catch{return!1}return e.protocol==="https:"};var Ct=(t,e)=>!(t.right<e.left||t.left>e.right||t.bottom<e.top||t.top>e.bottom);var Mt=(()=>{let t=0;return()=>{let e=t;return t=(t+1)%Number.MAX_SAFE_INTEGER,e}})(),Vt=t=>t!==void 0&&t!==""?t:Mt().toString();function Qt(t,e,r){if(t<=e[0])return r[0];if(t>=e[e.length-1])return r[r.length-1];let o=1;for(;o<e.length&&e[o]<t;)o++;o>=e.length&&(o=e.length-1);let n=e[o-1],s=e[o],i=r[o-1],a=r[o];if(t===n)return i;if(t===s)return a;let p=(t-n)/(s-n);return i+p*(a-i)}function _t(t,e,r){if(t<=0||r<0)return[];let o=[],n=Math.floor((t-1)/2),s=Math.floor(t/2),i=e-n,a=e+s;i<0&&(a+=Math.abs(i),i=0),a>r&&(i-=a-r,a=r),i=Math.max(0,i),a=Math.min(r,a);for(let p=i;p<=a;p++)o.push(p);return o}var Re=t=>t instanceof DOMException&&(t.name==="AbortError"||t.code===20),Dt=t=>{if(!Re(t))throw t};var Ut=t=>e=>r=>{let o=typeof r=="object";r==null||o&&!Object.keys(r).length||t(e,o?D(r):{value:r})},U=(t={})=>{let e=o=>{let n=o;return o===void 0?n="undefined":o===null?n="null":(typeof o=="number"||typeof o=="boolean")&&(n=o.toString()),n},r={};for(let o in t)Array.isArray(t[o])?r[o]=t[o].map(e):r[o]=e(t[o]);return r};var x=class t{constructor({name:e,getParentContext:r}){this.dynamicImportTimeout=5e3;this.childTracers=[];t.dynamicImportStatus==="not_started"&&(t.dynamicImportPromise=this.loadOpentelemetry());let o=Date.now();this.initPromise=t.dynamicImportPromise.then(n=>{t.dynamicImportStatus==="completed"&&this.init({name:e,getParentContext:r},o)})}static{this.dynamicImportStatus="not_started"}init({name:e,getParentContext:r},o){this.span=t.rootTracer.startSpan(e,{startTime:o},r?.()),this.context=t.dynamicImports.opentelemetryApi.trace.setSpan(t.dynamicImports.opentelemetryApi.context.active(),this.span)}async loadOpentelemetry(){if(t.dynamicImportStatus==="not_started"){t.dynamicImportStatus="in_progress";try{let e=new Promise((i,a)=>setTimeout(a,this.dynamicImportTimeout)),r=Promise.all([import("@opentelemetry/api"),import("@opentelemetry/sdk-trace-web"),import("@apptracer/opentelemetry")]),[o,n,s]=await Promise.race([r,e]);t.dynamicImports={opentelemetryApi:o,opentelemetrySdk:n,tracer:s},t.dynamicImportStatus="completed"}catch{t.dynamicImportStatus="failed"}}}isComponentTracerNotInitialized(){return O(this.span)||t.dynamicImportStatus==="failed"}log(e,r){let o=Date.now();this.initPromise.then(n=>{this.isComponentTracerNotInitialized()||this.span.addEvent(e,{...U(r),type:"log"},o)})}error(e,r){let o=Date.now();this.initPromise.then(n=>{this.isComponentTracerNotInitialized()||this.span.addEvent(e,{...U(r),type:"error"},o)})}critical(e,r){let o=Date.now();this.initPromise.then(n=>{this.isComponentTracerNotInitialized()||this.span.addEvent(e,{...U(r),type:"critical"},o)})}createComponentTracer(e){let r=new t({name:e,getParentContext:()=>this.context});return this.childTracers.push(r),r}end(){this.initPromise.then(e=>{this.isComponentTracerNotInitialized()||(this.childTracers.forEach(r=>r.end()),this.span.end())})}};var j=class extends x{constructor(){super({name:"Root"})}init({name:e,getParentContext:r},o){let s=x.dynamicImports.tracer.initTracerOpenTelemetry({serviceName:"videoplayer-sdk-web",appToken:"L9SBoka6ZWk4xPjaK7tmfSfYvMhcge7nvGDjpdMmscb",spanLimits:{attributeCountLimit:1/0,eventCountLimit:1/0,attributePerEventCountLimit:1/0}}).getProvider(),i=new x.dynamicImports.tracer.TracerMemorySpanExporter;this.spanExporter=i,s.addSpanProcessor(new x.dynamicImports.tracer.TracerAllSpansProcessor({startedSpansExporter:i})),x.rootTracer=s.getTracer("sdk-videoplayer-tracer"),super.init({name:e,getParentContext:r},o)}getFinishedSpans(){if(!this.isComponentTracerNotInitialized())return this.spanExporter?.getJsonData()}getTraceId(){return this.isComponentTracerNotInitialized()?"":this.span.spanContext().traceId}};var W=class t{constructor(e){}log(e,r){}error(e,r){}critical(e,r){}createComponentTracer(e){return new t({name:e})}end(){}getFinishedSpans(){}getTraceId(){return this.fakeTraceId}};var ae=class{static createRootTracer(e=!1){return e?new j:new W}};var Le=(a=>(a.NETWORK="network",a.VIDEO_PIPELINE="video_pipeline",a.EXTERNAL_API="external_api",a.PARSER="parser",a.DOM="dom",a.WTF="wtf",a.FATAL="fatal",a))(Le||{});var jt=(l=>(l.Armenian="58",l.Azerbaijani="57",l.Belarusian="114",l.English="3",l.Kazakh="97",l.Portuguese="73",l.Russian="0",l.Spanish="4",l.Ukrainian="1",l.Uzbek="65",l.Vietnamese="75",l))(jt||{}),Wt="vk.com",Vi=async(t,e,r)=>{let o=new URL(`https://${Wt}/js/lang-pack.js`);o.searchParams.set("format","json"),o.searchParams.set("name",e),t!==void 0&&o.searchParams.set("lang",t);let s=await(await fetch(o.toString())).json();return zt(s,r)},zt=(t,e)=>Object.fromEntries(Object.entries(t.keys).map(([r,o])=>[r.substring(`${e}_`.length),Ft(o)])),Ft=t=>Array.isArray(t)?t[0]:t;var Kt=(r=>(r.RU="ru",r.EN="en",r))(Kt||{});var f="__vk_vp_internals_exposure",Ce=class{constructor(e,r){this.playerId=r,this.type=e,this.initWindowObjects()}getWindowObject(){if(typeof window>"u")return{};let e=this.playerId,r=this.type;return window[f]?.[e]?.[r]??{}}initWindowObjects(){if(typeof window>"u")return;let e=this.playerId,r=this.type;window[f]||(window[f]={}),window[f][e]||(window[f][e]={}),window[f][e][r]||(window[f][e][r]={})}expose(e){typeof window>"u"||Object.assign(this.getWindowObject(),e)}destroy(){if(typeof window>"u")return;let e=this.playerId,r=this.type;window[f]&&window[f][e]&&window[f][e][r]&&(delete window[f][e][r],Object.keys(window[f][e]).length||delete window[f][e],Object.keys(window[f]).length||delete window[f])}};var Me={};de(Me,{create:()=>Bt,destroy:()=>Gt,push:()=>Ht,subscribe:()=>qt});var N=new Map,Bt=(t,e)=>N.set(t,e??[]),Gt=t=>N.delete(t),Ht=(t,e)=>{let r=N.get(t);r&&(typeof r=="function"?r(e):r.push(e))},qt=(t,e)=>{let r=N.get(t);if(r){if(r&&Array.isArray(r))for(let o of r)e(o);N.set(t,e)}};var Ve="gW5EerTD5QhAnsbpF7Hd2NSMRteYIUUMjFbSyI68Pf5";var Qe=t=>{let e={id:t.id,message:t.message,category:t.category,data:$t(t.data),httpCode:t.httpCode,UVBackendErrorCode:t.UVBackendErrorCode};return B(e)};function $t(t){switch(typeof t){case"boolean":case"string":case"number":return t;case"object":try{return JSON.stringify(t)}catch{return}default:return}}var _e=t=>{let e=t.thrown instanceof Error?t.thrown:new Error(t.message);return e.name=t.id,e};var ce=class t{constructor(e,r,o,n){this.dynamicImportTimeout=5e3;this.subscription=new b;this.componentName=e,this.options=r,this.envParams=o,this.context=n,this.options.enabled&&(this.loadModule(),this.init())}static{this.tracerErrorMap=new Map}static{this.appTracerModule=null}static{this.loadPromise=null}error(e,r){let{blackErrorCategoryList:o,blackErrorIdList:n,sampleRate:s,whiteErrorCategoryList:i,whiteErrorIdList:a}=this.options,{id:p,category:m}=e;if(o.length&&o.includes(m)||n.length&&n.includes(p)||i.length&&!i.includes(m)||a.length&&!a.includes(p)||Math.random()>=s)return;t.tracerErrorMap.get(this.componentName)?.error(_e(e),{severity:r?.severity??(e.traceAsLog?"debug":void 0),keys:{...this.context,...Qe(e)}})}addSubscription(e){this.subscription.add(e)}destroy(){this.subscription.unsubscribe()}async init(){try{if(await t.loadPromise,t.tracerErrorMap.has(this.componentName)||O(t.appTracerModule))return;let{appTracerModule:e}=t,{initTracerError:r,initTracerErrorUploader:o,addTracerPlugin:n,getTracerModules:s}=e,i=s(this.componentName),a=!i.error,p=i.error??r(this.componentName,{enableUnhandledErrorsListeners:!1,stringifyErrorDataObject:!0});a&&o(this.componentName,{appToken:Ve,environment:this.envParams.env,versionCode:1,versionName:this.envParams.version}),n(this.componentName,{name:"addedCategory",errorBeforeAdd(m){let y=m.keys?.category??"wtf";if(typeof y=="string")return{issueKey:y}}}),t.tracerErrorMap.set(this.componentName,p)}catch{}}loadModule(){if(v(t.loadPromise))return;let e=async()=>{try{let r=new Promise((n,s)=>u().setTimeout(s,this.dynamicImportTimeout)),o=await Promise.race([r,import("@apptracer/sdk/lite")]);t.appTracerModule=o}catch{t.loadPromise=null}};t.loadPromise=e()}};export{ce as AppTracer,Le as ErrorCategory,f as INTERNAL_EXPOSE_GLOBAL_KEY,Kt as InterfaceLanguage,Ce as InternalsExposure,K as Logger,c as Observable,k as ReplaySubject,h as Subject,b as Subscription,Q as SubscriptionRemovable,ae as TracerFactory,Be as VERSION,jt as VKNumericLanguage,V as ValueSubject,H as VideoQuality,tt as abortable,Ze as addScript,yt as areQualitiesExact,Je as assertEmptyArray,g as assertNever,$e as assertNonNullable,Xe as assertNotEmptyArray,Ye as assertNullable,It as assertQualityIsExact,he as buffer,Ge as checkNever,Lt as clearVideoElement,vt as cloneDeep,M as cloneDeepWith,ye as combine,ge as debounce,Y as debounceFn,pt as detectEmbed,Me as devNull,gt as fillWithDefault,xe as filter,Oe as filterChanged,D as flattenObject,wt as fromEvent,rt as getExponentialDelay,dt as getHighestQuality,Vt as getPlayerId,_t as getRangeAroundIndex,Ut as getTraceSubscriptionMethod,ht as getVideoQualityLabel,u as getWindow,Qt as interpolate,Et as interval,Re as isAbortError,be as isBrowserWindow,lt as isHigher,ut as isHigherOrEqual,Ct as isIntersecting,$ as isInvariantQuality,q as isLower,mt as isLowerOrEqual,v as isNonNullable,O as isNullable,gn as isValidURL,Vi as loadVKLangPack,_ as map,we as mapTo,Ie as merge,S as noop,et as now,Ot as observableFrom,Rt as observeElementSize,Se as once,Ae as pairwise,fe as safeStorage,Ne as shareReplay,ke as skip,Dt as suppressAbort,Pe as tap,ve as throttle,X as throttleFn,kr as timeCodeToString,xt as timeout,bt as videoHeightToQuality,Tt as videoQualityToHeight,ft as videoSizeToQuality,B as withoutNullable};
|
|
6
|
+
var e=Object.defineProperty,t=e=>e;function n(e,n){this[e]=t.bind(null,n)}var r=(t,r)=>{for(var i in r)e(t,i,{get:r[i],enumerable:!0,configurable:!0,set:n.bind(r,i)})},i=`1.0.83-dev.c0f690bfb.0`;class a{subscriptions=[];unsubscribe(){let e=this.subscriptions;this.subscriptions=[],e.forEach(e=>{typeof e==`function`?e():e.unsubscribe()})}add(e){return this.subscriptions.push(e),this}}var o=e=>{throw Error(`${e} is value of unexpected type`)},s=e=>{},c=()=>{},l=e=>{throw console.error(e),e},u=e=>{console.error(e)};class d{suppressErrors=!1;constructor(e){e&&(this._subscribe=e)}setSuppressErrors(e){this.suppressErrors=e}subscribe(e,t){let n=this.suppressErrors?u:l,r;r=t?typeof t==`function`?{next:t,error:c}:{next:e=>t.next(e),error:e=>t.error?.(e)}:{next:n,error:c};let i=typeof e==`function`?{next:t=>{try{let n=e(t);n instanceof Promise&&n.catch(e=>r.next(e))}catch(e){r.next(e)}},error:e=>r.next(e)}:{next:t=>e.next(t),error:t=>e.error?e.error(t):r.next(t)},s;try{s=this._subscribe(i)}catch(e){i.error?.(e)}return new a().add(()=>{switch(i.next=c,i.error=c,typeof s){case`function`:s();return;case`object`:s.unsubscribe();return;case`undefined`:return;default:return o(s)}})}pipe(...e){return e.reduce((e,t)=>t(e),this)}_subscribe(e){}}class f extends d{keyCounter=0;subscribers=new Map;constructor(){super()}next(e){this.subscribers.forEach(t=>t.next(e))}error(e){this.subscribers.forEach(t=>t.error?.(e))}_subscribe(e){let t=this.keyCounter++;return this.subscribers.set(t,e),new a().add(()=>this.subscribers.delete(t))}}class p{log$=new f;logs=[];log=e=>{let t={...e,timestamp:Date.now()};this.logs.push(t),this.log$.next(t)};createCustomLog(e){return(...t)=>{let n;try{n=e(...t)}catch{n={message:"error in `createCustomLog`",component:`Logger`}}this.log(n)}}createComponentLog(e){return this.createCustomLog(t=>({component:e,...t}))}getAllLogs=()=>this.logs}function m(e,t=`Assertion "value is not nullable" failed`){if(e==null)throw Error(t)}function h(e,t=`Assertion "value is nullable" failed`){if(e!=null)throw Error(t)}function g(e){return e!=null}function _(e){return e==null}var v=e=>Object.fromEntries(Object.entries(e).filter(([e,t])=>g(t)));function y(e,t){if(!e?.length)throw Error(t)}function b(e,t){if(e?.length)throw Error(t)}var x=()=>globalThis,S=(e=x())=>!!(e.window&&e.screen),ee=(e,t,n)=>new Promise((r,i)=>{t.addEventListener(`abort`,()=>{s(),l.remove()});let a=()=>{s(),i(`error`)},o=()=>{s(),r()},s=()=>{c&&clearTimeout(c),l.removeEventListener(`load`,o),l.removeEventListener(`error`,a)},c;n&&(c=x().setTimeout(()=>{s(),i(`timeout`)},n));let l=document.createElement(`script`);l.addEventListener(`load`,o),l.addEventListener(`error`,a),l.src=e,document.head.appendChild(l)}),te=typeof x().performance?.now==`function`?()=>x().performance.now():()=>Date.now(),C=(e,t)=>async(...n)=>{let r=t(...n),i=e.aborted,a;for(;!i&&!e.aborted;)try{let e=await r.next(a);i=e.done??!1,a=e.value}catch(e){await r.throw(e)}return a},w=(e,{start:t=0,factor:n=2,max:r=1/0,min:i=t,random:a=0}={})=>{let o=t;return o*=n**e,o*=1+(Math.random()*a*2-a),o=Math.round(o),o=Math.min(o,r),o=Math.max(o,i),o},T={};r(T,{set:()=>ie,remove:()=>oe,isPersistent:()=>ne,has:()=>ae,get:()=>re,clear:()=>se});var E,D,O=`vk-videoplayer-dummy-key-${Math.random()}`,k=()=>{if(D!==void 0)return D;try{localStorage.setItem(O,`test`),localStorage.removeItem(O),D=0}catch(e){if(e instanceof DOMException||e instanceof TypeError)try{sessionStorage.getItem(O),D=1}catch(e){if(e instanceof DOMException||e instanceof TypeError)D=2;else throw e}else throw e}return D===2&&(E=new Map),D},ne=()=>k()===0,re=e=>{let t=k();switch(t){case 0:return localStorage.getItem(e)??void 0;case 1:return sessionStorage.getItem(e)??void 0;case 2:return E?.get(e);default:o(t)}},ie=(e,t)=>{let n=k();switch(n){case 0:try{localStorage.setItem(e,t)}catch(e){if(e instanceof DOMException)console.error(e);else throw e}break;case 1:try{sessionStorage.setItem(e,t)}catch(e){if(e instanceof DOMException)console.error(e);else throw e}break;case 2:E?.set(e,t);return;default:o(n)}},ae=e=>{let t=k();switch(t){case 0:return e in localStorage;case 1:return e in sessionStorage;case 2:return E?.has(e)??!1;default:return o(t),!1}},oe=e=>{let t=k();switch(t){case 0:return localStorage.removeItem(e);case 1:return sessionStorage.removeItem(e);case 2:E?.delete(e);return;default:o(t)}},se=()=>{let e=k();switch(e){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return E?.clear();default:o(e)}},ce=()=>{let e,t=[],n=x();try{e=n.self!==n.top}catch(t){t instanceof DOMException&&t.name===`SecurityError`?e=!0:(e=!1,console.error(t))}try{n.location.ancestorOrigins&&(t=[...n.location.ancestorOrigins])}catch(e){console.error(e)}try{!t.length&&n.document.referrer&&(t=[new URL(n.document.referrer).origin])}catch(e){console.error(e)}return t=t.filter(e=>URL.canParse(e)),{isEmbed:e,origins:t,topOrigin:t.at(-1),immediateOrigin:t.at(0)}},A;(e=>{e.INVARIANT=`Invariant quality`,e.Q_144P=`144p`,e.Q_240P=`240p`,e.Q_360P=`360p`,e.Q_480P=`480p`,e.Q_576P=`576p`,e.Q_720P=`720p`,e.Q_1080P=`1080p`,e.Q_1440P=`1440p`,e.Q_2160P=`2160p`,e.Q_4320P=`4320p`})(A||={});var j={"144p":{width:256,height:144},"240p":{width:428,height:240},"360p":{width:640,height:360},"480p":{width:856,height:480},"576p":{width:1024,height:576},"720p":{width:1280,height:720},"1080p":{width:1920,height:1080},"1440p":{width:2560,height:1440},"2160p":{width:3840,height:2160},"4320p":{width:7680,height:4320}},le=(e,t)=>j[e].height>j[t].height,ue=(e,t)=>j[e].height>=j[t].height,M=(e,t)=>j[e].height<j[t].height,de=(e,t)=>j[e].height<=j[t].height,fe=e=>e.sort((e,t)=>e===t?0:e===`Invariant quality`?1:t===`Invariant quality`?-1:M(e,t)?1:-1)[0],N=Object.keys(j).sort((e,t)=>M(e,t)?-1:1),pe=(e,t=.02)=>[...N].find(n=>j[n].height*(1+t)>=e),me=({width:e,height:t})=>{let n=Math.min(e,t),r=Math.max(e,t);return N.find(e=>{let t=j[e];return t.width>=r&&t.height>=n})},he=e=>j[e].height,P=e=>e===`Invariant quality`,ge=e=>e.every(e=>!P(e));function _e(e){if(P(e))throw Error(`Expected exact quality`)}var ve=e=>{switch(e){case`4320p`:return`8K`;case`2160p`:return`4K`;case`1440p`:return`QHD`;case`1080p`:return`FHD`;case`720p`:return`HD`;default:return``}},F=(e,t)=>{let n={};for(let r of Object.keys(t)){let i=t[r],a=e[r];Array.isArray(i)?n[r]=Array.isArray(a)?a:i:typeof i==`object`&&i?typeof a==`object`&&a&&!Array.isArray(a)?n[r]=F(a,i):n[r]=i:n[r]=r in e?a:i}return n},ye=e=>{let t=``;return e>=3600&&(t+=Math.floor(e/3600)+`h`,e%=3600),e>=60&&(t+=Math.floor(e/60)+`m`,e%=60),e>0&&(t+=Math.floor(e)+`s`),t};function I(e,t=0,n){let r,i,a,o,s,c,l=0,u=!1,d=!1,f=!0,p=!t&&t!==0&&typeof x().requestAnimationFrame==`function`;n&&(u=!!n.leading,d=`maxWait`in n,a=n?.maxWait?Math.max(+n?.maxWait||0,t):a,f=`trailing`in n?!!n.trailing:f);function m(t){let n=r,a=i;return r=i=void 0,l=t,o=e.apply(a,n),o}function h(e,t){return p?(s&&x().cancelAnimationFrame(s),x().requestAnimationFrame(e)):setTimeout(e,t)}function g(e){if(p){x().cancelAnimationFrame(e);return}clearTimeout(e)}function _(e){return l=e,s=h(b,t),u?m(e):o}function v(e){let n=e-c,r=e-l,i=t-n;return d?Math.min(i,a-r):i}function y(e){let n=e-c,r=e-l;return c===void 0||n>=t||n<0||d&&r>=a}function b(){let e=Date.now();if(y(e))return S(e);s=h(b,v(e))}function S(e){return s=void 0,f&&r?m(e):(r=i=void 0,o)}function ee(){s!==void 0&&g(s),l=0,r=c=i=s=void 0}function te(){return s===void 0?o:S(Date.now())}function C(){return s!==void 0}function w(...e){let n=Date.now(),a=y(n);if(r=e,i=this,c=n,a){if(s===void 0)return _(c);if(d)return s=h(b,t),m(c)}return s===void 0&&(s=h(b,t)),o}return w.cancel=ee,w.flush=te,w.pending=C,w}var L=(e,t=0,n)=>I(e,t,{leading:!0,trailing:!0,...n,maxWait:t}),R=(e,t)=>{if(typeof e!=`object`||!e)return e;let n=Array.isArray(e)?[]:{};for(let r in e){if(typeof t==`function`){let i=t(e[r],r,e,n);if(i!==void 0){n[r]=i;continue}}typeof e[r]==`object`?n[r]=R(e[r],t):n[r]=e[r]}return n},be=e=>R(e);class z extends f{bufferSize;buffer=[];cursorEnd=-1;cursorStart=0;constructor(e){super(),this.bufferSize=e,this.buffer=Array(e)}next(e){this.cursorEnd+=1,this.cursorStart=this.cursorEnd>=this.bufferSize?this.cursorStart+1:0,this.buffer[this.cursorEnd%this.bufferSize]=e,this.subscribers.forEach(t=>t.next(e))}_subscribe(e){for(let t=this.cursorStart;t<=this.cursorEnd;t++)e.next(this.buffer[t%this.bufferSize]);let t=this.keyCounter++;return this.subscribers.set(t,e),new a().add(()=>this.subscribers.delete(t))}}class xe extends f{value;constructor(e){super(),this.value=e}next(e){super.next(this.value=e)}error(e){super.error(this.value=e)}getValue(){return this.value}_subscribe(e){let t=super._subscribe(e);return e.next(this.value),t}}function Se(e){return new d(t=>{let n={},r=Object.keys(e).length,i=e=>i=>{e in n||r--,n[e]=i,r===0&&t.next(n)};return Object.entries(e).reduce((e,[t,n])=>e.add(n.subscribe(i(t))),new a)})}function Ce(...e){return new d(t=>e.reduce((e,n)=>e.add(n.subscribe(t)),new a))}var we=e=>new d(t=>{let n=x().setTimeout(()=>{try{t.next()}catch(e){if(t.error)t.error(e);else throw e}},e);return()=>x().clearTimeout(n)}),Te=e=>new d(t=>{let n=x(),r=n.setInterval(()=>t.next(),e);return()=>{r&&=(n.clearInterval(r),void 0)}}),Ee=e=>new d(t=>{e.forEach(e=>t.next(e))}),De=(e,t)=>new d(n=>{let r=e=>n.next(e);return e.addEventListener(t,r),()=>e.removeEventListener(t,r)});class Oe extends a{remove(e){this.subscriptions=this.subscriptions.filter(t=>t!==e)}}function ke(e){return t=>new d(n=>t.subscribe(new Ae(n,e)))}class Ae{destination;size;lastValues=[];constructor(e,t){this.destination=e,this.size=t}next(e){this.lastValues.length===this.size&&this.lastValues.shift(),this.lastValues.push(e),this.destination.next(this.lastValues)}error(e){this.destination.error?.(e)}}var je={leading:!1,trailing:!0};function Me(e,t=je){return n=>new d(r=>n.subscribe(new Ne(r,e,t)))}class Ne{destination;time;config;lastValue;timeout;constructor(e,t,n){this.destination=e,this.time=t,this.config=n}next(e){this.lastValue=e;let t=x();g(this.timeout)?t.clearTimeout(this.timeout):this.config.leading&&this.destination.next(e),this.timeout=t.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(e){if(this.destination.error)this.destination.error(e);else throw e}this.timeout=void 0},this.time)}error(e){this.destination.error?.(e)}}var Pe={leading:!0,trailing:!1};function Fe(e,t=Pe){return n=>new d(r=>n.subscribe(new Ie(r,e,t)))}class Ie{destination;time;config;lastValue;timeout;constructor(e,t,n){this.destination=e,this.time=t,this.config=n}next(e){this.lastValue=e,_(this.timeout)&&(this.config.leading&&this.destination.next(e),this.timeout=x().setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(e){this.destination.error?.(e)}}function Le(e){return t=>new d(n=>t.subscribe(new Re(n,e)))}class Re{destination;predicate;constructor(e,t){this.destination=e,this.predicate=t}next(e){let t;try{t=this.predicate(e)}catch(e){throw this.error(e),e}t&&this.destination.next(e)}error(e){this.destination.error?.(e)}}var ze=(e,t)=>{let n=(e,t)=>{let n=Object.keys(e);for(let r in t)if(!n.includes(r)||t[r]!==e[r])return!1;return!0};return n(e,t)&&n(t,e)},Be=(e,t)=>e instanceof Object&&t instanceof Object?ze(e,t):e===t;function Ve(e=Be){return t=>new d(n=>t.subscribe(new He(n,e)))}var B={};class He{destination;predicate;lastValue=B;constructor(e,t){this.destination=e,this.predicate=t}next(e){let t;try{t=this.lastValue===B||!this.predicate(this.lastValue,e),this.lastValue=e instanceof Object&&!Array.isArray(e)?{...e}:e}catch(e){throw this.error(e),e}t&&this.destination.next(e)}error(e){this.destination.error?.(e)}}function V(e){return t=>new d(n=>t.subscribe(new Ue(n,e)))}class Ue{destination;mapper;constructor(e,t){this.destination=e,this.mapper=t}next(e){let t;try{t=this.mapper(e)}catch(e){throw this.error(e),e}this.destination.next(t)}error(e){this.destination.error?.(e)}}function We(e){return V(()=>e)}function Ge(){return e=>new d(t=>{let n=!1,r=!1,i=e.subscribe(e=>{n||(n=!0,t.next(e)),r&&i.unsubscribe()},e=>{n=!0,t.error?.(e),r&&i.unsubscribe()});return r=!0,n&&i.unsubscribe(),i})}function Ke(){return e=>new d(t=>e.subscribe(new qe(t)))}class qe{destination;last;hasLast=!1;constructor(e){this.destination=e}next(e){let t=this.last;if(this.last=e,!this.hasLast){this.hasLast=!0;return}this.destination.next([t,e])}error(e){this.destination.error?.(e)}}function Je(e){return t=>new d(n=>t.subscribe(new Ye(n,e)))}class Ye{destination;effect;constructor(e,t){this.destination=e,this.effect=t}next(e){try{this.effect(e)}catch(e){throw this.error(e),e}this.destination.next(e)}error(e){this.destination.error?.(e)}}function Xe(e){return t=>new d(n=>t.subscribe(new Ze(n,e)))}class Ze{destination;count;constructor(e,t){this.destination=e,this.count=t,t<0&&this.destination.error?.(Error(`Count can not be less than zero`))}next(e){this.count===0?this.destination.next(e):this.count--}error(e){this.destination.error?.(e)}}function Qe(e=0){return t=>{let n=0,r=new z(e),i=t.subscribe(r),a=e=>()=>{e.unsubscribe(),n--,n===0&&i.unsubscribe()};return new d(e=>(n++,a(r.subscribe(e))))}}var $e=300,et=(e,t=$e)=>new d(n=>{let r=x(),{width:i,height:a}=e.getBoundingClientRect();if(n.next({width:i,height:a}),!S(r))return;let o=new r.ResizeObserver(L(e=>{let t=e[0];if(!t)return;let r,i;t.contentBoxSize&&t.contentBoxSize[0]?(i=t.contentBoxSize[0].blockSize,r=t.contentBoxSize[0].inlineSize):t.contentRect&&(r=t.contentRect.width,i=t.contentRect.height),g(r)&&g(i)&&n.next({width:r,height:i})},t));return o.observe(e),()=>o.disconnect()}),H=(e,t=6,n=`.`)=>{let r={};for(let i in e)if(!(!e.hasOwnProperty(i)||e[i]instanceof HTMLElement||!t))if(typeof e[i]==`object`&&e[i]!==null){let a=H(e[i],t-1);for(let e in a)a.hasOwnProperty(e)&&(r[i+n+e]=a[e])}else r[i]=e[i];return r},tt=(e,t=!1)=>{t&&(e.innerHTML=``),e.removeAttribute(`src`),e.load()},nt=e=>{let t;try{t=new URL(e)}catch{return!1}return t.protocol===`https:`},rt=(e,t)=>!(e.right<t.left||e.left>t.right||e.bottom<t.top||e.top>t.bottom),it=(()=>{let e=0;return()=>{let t=e;return e=(e+1)%(2**53-1),t}})(),at=e=>e!==void 0&&e!==``?e:it().toString();function ot(e,t,n){if(e<=t[0])return n[0];if(e>=t[t.length-1])return n[n.length-1];let r=1;for(;r<t.length&&t[r]<e;)r++;r>=t.length&&(r=t.length-1);let i=t[r-1],a=t[r],o=n[r-1],s=n[r];return e===i?o:e===a?s:o+(e-i)/(a-i)*(s-o)}function st(e,t,n){if(e<=0||n<0)return[];let r=[],i=Math.floor((e-1)/2),a=Math.floor(e/2),o=t-i,s=t+a;o<0&&(s+=Math.abs(o),o=0),s>n&&(o-=s-n,s=n),o=Math.max(0,o),s=Math.min(n,s);for(let e=o;e<=s;e++)r.push(e);return r}var U=e=>e instanceof DOMException&&(e.name===`AbortError`||e.code===20),ct=e=>{if(!U(e))throw e},lt=e=>t=>n=>{let r=typeof n==`object`;n==null||r&&!Object.keys(n).length||e(t,r?H(n):{value:n})},W=(e={})=>{let t=e=>{let t=e;return e===void 0?t=`undefined`:e===null?t=`null`:(typeof e==`number`||typeof e==`boolean`)&&(t=e.toString()),t},n={};for(let r in e)Array.isArray(e[r])?n[r]=e[r].map(t):n[r]=t(e[r]);return n};class G{dynamicImportTimeout=5e3;span;context;childTracers=[];initPromise;static rootTracer;static dynamicImportStatus=`not_started`;static dynamicImports;static dynamicImportPromise;constructor({name:e,getParentContext:t}){G.dynamicImportStatus===`not_started`&&(G.dynamicImportPromise=this.loadOpentelemetry());let n=Date.now();this.initPromise=G.dynamicImportPromise.then(r=>{G.dynamicImportStatus===`completed`&&this.init({name:e,getParentContext:t},n)})}init({name:e,getParentContext:t},n){this.span=G.rootTracer.startSpan(e,{startTime:n},t?.()),this.context=G.dynamicImports.opentelemetryApi.trace.setSpan(G.dynamicImports.opentelemetryApi.context.active(),this.span)}async loadOpentelemetry(){if(G.dynamicImportStatus===`not_started`){G.dynamicImportStatus=`in_progress`;try{let e=new Promise((e,t)=>setTimeout(t,this.dynamicImportTimeout)),t=Promise.all([import(`@opentelemetry/api`),import(`@opentelemetry/sdk-trace-web`),import(`@apptracer/opentelemetry`)]),[n,r,i]=await Promise.race([t,e]);G.dynamicImports={opentelemetryApi:n,opentelemetrySdk:r,tracer:i},G.dynamicImportStatus=`completed`}catch{G.dynamicImportStatus=`failed`}}}isComponentTracerNotInitialized(){return _(this.span)||G.dynamicImportStatus===`failed`}log(e,t){let n=Date.now();this.initPromise.then(r=>{this.isComponentTracerNotInitialized()||this.span.addEvent(e,{...W(t),type:`log`},n)})}error(e,t){let n=Date.now();this.initPromise.then(r=>{this.isComponentTracerNotInitialized()||this.span.addEvent(e,{...W(t),type:`error`},n)})}critical(e,t){let n=Date.now();this.initPromise.then(r=>{this.isComponentTracerNotInitialized()||this.span.addEvent(e,{...W(t),type:`critical`},n)})}createComponentTracer(e){let t=new G({name:e,getParentContext:()=>this.context});return this.childTracers.push(t),t}end(){this.initPromise.then(e=>{this.isComponentTracerNotInitialized()||(this.childTracers.forEach(e=>e.end()),this.span.end())})}}class ut extends G{spanExporter;constructor(){super({name:`Root`})}init({name:e,getParentContext:t},n){let r=G.dynamicImports.tracer.initTracerOpenTelemetry({serviceName:`videoplayer-sdk-web`,appToken:`L9SBoka6ZWk4xPjaK7tmfSfYvMhcge7nvGDjpdMmscb`,spanLimits:{attributeCountLimit:1/0,eventCountLimit:1/0,attributePerEventCountLimit:1/0}}).getProvider(),i=new G.dynamicImports.tracer.TracerMemorySpanExporter;this.spanExporter=i,r.addSpanProcessor(new G.dynamicImports.tracer.TracerAllSpansProcessor({startedSpansExporter:i})),G.rootTracer=r.getTracer(`sdk-videoplayer-tracer`),super.init({name:e,getParentContext:t},n)}getFinishedSpans(){if(!this.isComponentTracerNotInitialized())return this.spanExporter?.getJsonData()}getTraceId(){return this.isComponentTracerNotInitialized()?``:this.span.spanContext().traceId}}class K{fakeTraceId;constructor(e){}log(e,t){}error(e,t){}critical(e,t){}createComponentTracer(e){return new K({name:e})}end(){}getFinishedSpans(){}getTraceId(){return this.fakeTraceId}}class dt{static createRootTracer(e=!1){return e?new ut:new K}}var q;(e=>{e.NETWORK=`network`,e.VIDEO_PIPELINE=`video_pipeline`,e.EXTERNAL_API=`external_api`,e.PARSER=`parser`,e.DOM=`dom`,e.WTF=`wtf`,e.FATAL=`fatal`})(q||={});var J;(e=>{e.Armenian=`58`,e.Azerbaijani=`57`,e.Belarusian=`114`,e.English=`3`,e.Kazakh=`97`,e.Portuguese=`73`,e.Russian=`0`,e.Spanish=`4`,e.Ukrainian=`1`,e.Uzbek=`65`,e.Vietnamese=`75`})(J||={});var ft=`vk.com`,pt=async(e,t,n)=>{let r=new URL(`https://${ft}/js/lang-pack.js`);return r.searchParams.set(`format`,`json`),r.searchParams.set(`name`,t),e!==void 0&&r.searchParams.set(`lang`,e),mt(await(await fetch(r.toString())).json(),n)},mt=(e,t)=>Object.fromEntries(Object.entries(e.keys).map(([e,n])=>[e.substring(`${t}_`.length),ht(n)])),ht=e=>Array.isArray(e)?e[0]:e,Y;(e=>{e.RU=`ru`,e.EN=`en`})(Y||={});var X=`__vk_vp_internals_exposure`;class gt{playerId;type;constructor(e,t){this.playerId=t,this.type=e,this.initWindowObjects()}getWindowObject(){if(typeof window>`u`)return{};let e=this.playerId,t=this.type;return window[X]?.[e]?.[t]??{}}initWindowObjects(){if(typeof window>`u`)return;let e=this.playerId,t=this.type;window[X]||(window[X]={}),window[X][e]||(window[X][e]={}),window[X][e][t]||(window[X][e][t]={})}expose(e){typeof window>`u`||Object.assign(this.getWindowObject(),e)}destroy(){if(typeof window>`u`)return;let e=this.playerId,t=this.type;window[X]&&window[X][e]&&window[X][e][t]&&(delete window[X][e][t],Object.keys(window[X][e]).length||delete window[X][e],Object.keys(window[X]).length||delete window[X])}}var Z={};r(Z,{subscribe:()=>bt,push:()=>yt,destroy:()=>vt,create:()=>_t});var Q=new Map,_t=(e,t)=>Q.set(e,t??[]),vt=e=>Q.delete(e),yt=(e,t)=>{let n=Q.get(e);n&&(typeof n==`function`?n(t):n.push(t))},bt=(e,t)=>{let n=Q.get(e);if(n){if(n&&Array.isArray(n))for(let e of n)t(e);Q.set(e,t)}},xt=`gW5EerTD5QhAnsbpF7Hd2NSMRteYIUUMjFbSyI68Pf5`,St=e=>v({id:e.id,message:e.message,category:e.category,data:Ct(e.data),httpCode:e.httpCode,UVBackendErrorCode:e.UVBackendErrorCode});function Ct(e){switch(typeof e){case`boolean`:case`string`:case`number`:return e;case`object`:try{return JSON.stringify(e)}catch{return}default:return}}var wt=e=>{let t=e.thrown instanceof Error?e.thrown:Error(e.message);return t.name=e.id,t};class ${static tracerErrorMap=new Map;static appTracerModule=null;static loadPromise=null;dynamicImportTimeout=5e3;componentName;subscription=new a;options;envParams;context;constructor(e,t,n,r){this.componentName=e,this.options=t,this.envParams=n,this.context=r,this.options.enabled&&(this.loadModule(),this.init())}error(e,t){let{blackErrorCategoryList:n,blackErrorIdList:r,sampleRate:i,whiteErrorCategoryList:a,whiteErrorIdList:o}=this.options,{id:s,category:c}=e;n.length&&n.includes(c)||r.length&&r.includes(s)||a.length&&!a.includes(c)||o.length&&!o.includes(s)||Math.random()>=i||$.tracerErrorMap.get(this.componentName)?.error(wt(e),{severity:t?.severity??(e.traceAsLog?`debug`:void 0),keys:{...this.context,...St(e)}})}addSubscription(e){this.subscription.add(e)}destroy(){this.subscription.unsubscribe()}async init(){try{if(await $.loadPromise,$.tracerErrorMap.has(this.componentName)||_($.appTracerModule))return;let{appTracerModule:e}=$,{initTracerError:t,initTracerErrorUploader:n,addTracerPlugin:r,getTracerModules:i}=e,a=i(this.componentName),o=!a.error,s=a.error??t(this.componentName,{enableUnhandledErrorsListeners:!1,stringifyErrorDataObject:!0});o&&n(this.componentName,{appToken:xt,environment:this.envParams.env,versionCode:1,versionName:this.envParams.version}),r(this.componentName,{name:`addedCategory`,errorBeforeAdd(e){let t=e.keys?.category??`wtf`;if(typeof t==`string`)return{issueKey:t}}}),$.tracerErrorMap.set(this.componentName,s)}catch{}}loadModule(){g($.loadPromise)||($.loadPromise=(async()=>{try{let e=new Promise((e,t)=>x().setTimeout(t,this.dynamicImportTimeout));$.appTracerModule=await Promise.race([e,import(`@apptracer/sdk/lite`)])}catch{$.loadPromise=null}})())}}export{v as withoutNullable,me as videoSizeToQuality,he as videoQualityToHeight,pe as videoHeightToQuality,we as timeout,ye as timeCodeToString,L as throttleFn,Fe as throttle,Je as tap,ct as suppressAbort,Xe as skip,Qe as shareReplay,T as safeStorage,Ke as pairwise,Ge as once,et as observeElementSize,Ee as observableFrom,te as now,c as noop,Ce as merge,We as mapTo,V as map,pt as loadVKLangPack,nt as isValidURL,_ as isNullable,g as isNonNullable,de as isLowerOrEqual,M as isLower,P as isInvariantQuality,rt as isIntersecting,ue as isHigherOrEqual,le as isHigher,S as isBrowserWindow,U as isAbortError,Te as interval,ot as interpolate,x as getWindow,ve as getVideoQualityLabel,lt as getTraceSubscriptionMethod,st as getRangeAroundIndex,at as getPlayerId,fe as getHighestQuality,w as getExponentialDelay,De as fromEvent,H as flattenObject,Ve as filterChanged,Le as filter,F as fillWithDefault,Z as devNull,ce as detectEmbed,I as debounceFn,Me as debounce,Se as combine,R as cloneDeepWith,be as cloneDeep,tt as clearVideoElement,s as checkNever,ke as buffer,_e as assertQualityIsExact,h as assertNullable,y as assertNotEmptyArray,m as assertNonNullable,o as assertNever,b as assertEmptyArray,ge as areQualitiesExact,ee as addScript,C as abortable,A as VideoQuality,xe as ValueSubject,J as VKNumericLanguage,i as VERSION,dt as TracerFactory,Oe as SubscriptionRemovable,a as Subscription,f as Subject,z as ReplaySubject,d as Observable,p as Logger,gt as InternalsExposure,Y as InterfaceLanguage,X as INTERNAL_EXPOSE_GLOBAL_KEY,q as ErrorCategory,$ as AppTracer};
|
package/package.json
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { ISubscription } from
|
|
2
|
-
import type { ITracerError, ITracerErrorData } from
|
|
3
|
-
import type { AppTracerSdk, IAppTracerContext, IAppTracerEnvParams, IAppTracerOptions, IComponentName } from
|
|
4
|
-
import { IError } from
|
|
1
|
+
import type { ISubscription } from "../reactive";
|
|
2
|
+
import type { ITracerError, ITracerErrorData } from "@apptracer/sdk/lite";
|
|
3
|
+
import type { AppTracerSdk, IAppTracerContext, IAppTracerEnvParams, IAppTracerOptions, IComponentName } from "./types";
|
|
4
|
+
import type { IError } from "../types";
|
|
5
5
|
export declare class AppTracer {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
6
|
+
protected static readonly tracerErrorMap: Map<IComponentName, ITracerError>;
|
|
7
|
+
protected static appTracerModule: typeof AppTracerSdk | null;
|
|
8
|
+
protected static loadPromise: Promise<unknown> | null;
|
|
9
|
+
private readonly dynamicImportTimeout;
|
|
10
|
+
private readonly componentName;
|
|
11
|
+
private readonly subscription;
|
|
12
|
+
private readonly options;
|
|
13
|
+
private readonly envParams;
|
|
14
|
+
private readonly context?;
|
|
15
|
+
/**
|
|
16
|
+
* на каждый `componentName` создаётся 1 уникальный экземпляр трейсера.
|
|
17
|
+
* пересоздать его уже будет нельзя
|
|
18
|
+
*/
|
|
19
|
+
constructor(componentName: IComponentName, options: IAppTracerOptions, envParams: IAppTracerEnvParams, context?: IAppTracerContext);
|
|
20
|
+
error(error: IError, errorData?: Partial<Pick<ITracerErrorData, "severity">>): void;
|
|
21
|
+
addSubscription(item: Parameters<ISubscription["add"]>[0]): void;
|
|
22
|
+
destroy(): void;
|
|
23
|
+
private init;
|
|
24
|
+
private loadModule;
|
|
25
25
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { AppTracer } from
|
|
2
|
-
export type { IAppTracerOptions, IAppTracerEnvParams, IAppTracerContext } from
|
|
1
|
+
export { AppTracer } from "./AppTracer";
|
|
2
|
+
export type { IAppTracerOptions, IAppTracerEnvParams, IAppTracerContext } from "./types";
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { ErrorCategory } from
|
|
2
|
-
import type * as AppTracerSdk from
|
|
3
|
-
import type { ITracerError, ITracerErrorData, ITracerUploaderConfig } from
|
|
4
|
-
export { AppTracerSdk };
|
|
1
|
+
import type { ErrorCategory } from "../types";
|
|
2
|
+
import type * as AppTracerSdk from "@apptracer/sdk/lite";
|
|
3
|
+
import type { ITracerError, ITracerErrorData, ITracerUploaderConfig } from "@apptracer/sdk/lite";
|
|
4
|
+
export type { AppTracerSdk };
|
|
5
5
|
export type IComponentName = string & {};
|
|
6
6
|
export interface IAppTracerOptions {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
enabled: boolean;
|
|
8
|
+
sampleRate: number;
|
|
9
|
+
whiteErrorCategoryList: ErrorCategory[];
|
|
10
|
+
blackErrorCategoryList: ErrorCategory[];
|
|
11
|
+
whiteErrorIdList: string[];
|
|
12
|
+
blackErrorIdList: string[];
|
|
13
13
|
}
|
|
14
14
|
export interface IAppTracerEnvParams {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
version: ITracerUploaderConfig["versionName"];
|
|
16
|
+
env: ITracerUploaderConfig["environment"];
|
|
17
17
|
}
|
|
18
|
-
export type IAppTracerContext = Parameters<ITracerError[
|
|
19
|
-
export type IAppTracerErrorDataKeys = ITracerErrorData[
|
|
18
|
+
export type IAppTracerContext = Parameters<ITracerError["setErrorKeys"]>[0];
|
|
19
|
+
export type IAppTracerErrorDataKeys = ITracerErrorData["keys"];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IError } from
|
|
2
|
-
import type { IAppTracerErrorDataKeys } from
|
|
1
|
+
import type { IError } from "../types";
|
|
2
|
+
import type { IAppTracerErrorDataKeys } from "./types";
|
|
3
3
|
export declare const mapIErrorToAppTracerErrorKeys: (error: IError) => IAppTracerErrorDataKeys;
|
|
4
4
|
export declare const mapIErrorThrownToError: (error: IError) => Error;
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { ILogger } from
|
|
1
|
+
import type { ILogger } from "../Logger";
|
|
2
2
|
export declare const INTERNAL_EXPOSE_GLOBAL_KEY = "__vk_vp_internals_exposure";
|
|
3
|
-
export type ExposeType =
|
|
3
|
+
export type ExposeType = "ui" | "core";
|
|
4
4
|
type InternalsExposureItem = {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
logger?: ILogger;
|
|
6
|
+
[k: string]: unknown;
|
|
7
7
|
};
|
|
8
8
|
export type InternalsExposureData = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
[playerId: string]: {
|
|
10
|
+
ui?: InternalsExposureItem;
|
|
11
|
+
core?: InternalsExposureItem;
|
|
12
|
+
};
|
|
13
13
|
};
|
|
14
14
|
declare global {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
interface Window {
|
|
16
|
+
[INTERNAL_EXPOSE_GLOBAL_KEY]?: InternalsExposureData;
|
|
17
|
+
}
|
|
18
18
|
}
|
|
19
19
|
export declare class InternalsExposure {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
private readonly playerId;
|
|
21
|
+
private readonly type;
|
|
22
|
+
constructor(type: ExposeType, playerId: string);
|
|
23
|
+
private getWindowObject;
|
|
24
|
+
private initWindowObjects;
|
|
25
|
+
expose(data: Record<string, unknown>): void;
|
|
26
|
+
destroy(): void;
|
|
27
27
|
}
|
|
28
28
|
export {};
|
package/types/Logger/Logger.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import Subject from
|
|
2
|
-
import type { ILogger, ILogInputEntry, IComponentLogger, ILogEntry } from
|
|
1
|
+
import Subject from "../reactive/Subject";
|
|
2
|
+
import type { ILogger, ILogInputEntry, IComponentLogger, ILogEntry } from "./types";
|
|
3
3
|
export declare class Logger implements ILogger {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
log$: Subject<ILogEntry>;
|
|
5
|
+
private logs;
|
|
6
|
+
log: (inputEntry: ILogInputEntry) => void;
|
|
7
|
+
createCustomLog<TArgs extends unknown[]>(transform: (...args: TArgs) => ILogInputEntry): (...args: TArgs) => void;
|
|
8
|
+
createComponentLog(component: string): IComponentLogger;
|
|
9
|
+
getAllLogs: () => ILogEntry[];
|
|
10
10
|
}
|
package/types/Logger/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { Logger } from
|
|
2
|
-
export type { ILogger, ILogInputEntry, IComponentLogEntry, IComponentLogger, ILogEntry } from
|
|
1
|
+
export { Logger } from "./Logger";
|
|
2
|
+
export type { ILogger, ILogInputEntry, IComponentLogEntry, IComponentLogger, ILogEntry } from "./types";
|
package/types/Logger/types.d.ts
CHANGED
|
@@ -1,30 +1,29 @@
|
|
|
1
|
-
import type { IObservable } from
|
|
1
|
+
import type { IObservable } from "../reactive/types";
|
|
2
2
|
export interface ILogger {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
log: (entry: ILogInputEntry) => void;
|
|
4
|
+
createCustomLog: <TArgs extends unknown[]>(transform: (...args: TArgs) => ILogInputEntry) => (...args: TArgs) => void;
|
|
5
|
+
createComponentLog: (component: string) => IComponentLogger;
|
|
6
|
+
getAllLogs: () => ILogEntry[];
|
|
7
|
+
log$: IObservable<ILogEntry>;
|
|
8
8
|
}
|
|
9
9
|
export interface ILogEntry {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Сообщение.
|
|
12
|
+
*/
|
|
13
|
+
message: string;
|
|
14
|
+
/**
|
|
15
|
+
* Компонент, в котором залогировано событие. (модуль, класс или функция)
|
|
16
|
+
*/
|
|
17
|
+
component: string;
|
|
18
|
+
/**
|
|
19
|
+
* Время, в которое случилось логируемое событие
|
|
20
|
+
*/
|
|
21
|
+
timestamp: number;
|
|
22
22
|
}
|
|
23
23
|
export type IComponentLogger = (entry: IComponentLogEntry) => void;
|
|
24
|
-
export type ILogInputEntry = Omit<ILogEntry,
|
|
25
|
-
export interface IComponentLogEntry extends Omit<ILogInputEntry,
|
|
26
|
-
}
|
|
24
|
+
export type ILogInputEntry = Omit<ILogEntry, "timestamp">;
|
|
25
|
+
export interface IComponentLogEntry extends Omit<ILogInputEntry, "component">, IOptionalComponent {}
|
|
27
26
|
interface IOptionalComponent {
|
|
28
|
-
|
|
27
|
+
component?: ILogInputEntry["component"];
|
|
29
28
|
}
|
|
30
29
|
export {};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { IRootTracer, ITracer, ITracerParams } from
|
|
2
|
-
import type { Attributes } from
|
|
1
|
+
import type { IRootTracer, ITracer, ITracerParams } from "./types";
|
|
2
|
+
import type { Attributes } from "@opentelemetry/api";
|
|
3
3
|
export declare class FakeTracer implements IRootTracer {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
private readonly fakeTraceId;
|
|
5
|
+
constructor(params?: Partial<ITracerParams>);
|
|
6
|
+
log(name: string, attributes?: Attributes): void;
|
|
7
|
+
error(name: string, attributes?: Attributes): void;
|
|
8
|
+
critical(name: string, attributes?: Attributes): void;
|
|
9
|
+
createComponentTracer(name: string): ITracer;
|
|
10
|
+
end(): void;
|
|
11
|
+
getFinishedSpans(): any | undefined;
|
|
12
|
+
getTraceId(): string;
|
|
13
13
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { IRootTracer, ITracerParams } from
|
|
2
|
-
import { Tracer } from
|
|
3
|
-
import { Milliseconds } from
|
|
1
|
+
import type { IRootTracer, ITracerParams } from "./types";
|
|
2
|
+
import { Tracer } from "./Tracer";
|
|
3
|
+
import type { Milliseconds } from "../utils";
|
|
4
4
|
export declare class RootTracer extends Tracer implements IRootTracer {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
private spanExporter;
|
|
6
|
+
constructor();
|
|
7
|
+
protected init({ name, getParentContext }: ITracerParams, startTime: Milliseconds): void;
|
|
8
|
+
getFinishedSpans(): any | undefined;
|
|
9
|
+
getTraceId(): string;
|
|
10
10
|
}
|
package/types/Tracer/Tracer.d.ts
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
import type { Tracer as OtlpTracer } from
|
|
2
|
-
import type { Attributes, Context, Span } from
|
|
3
|
-
import { ITracer, ITracerDynamicImports, ITracerParams
|
|
4
|
-
import {
|
|
1
|
+
import type { Tracer as OtlpTracer } from "@opentelemetry/sdk-trace-web";
|
|
2
|
+
import type { Attributes, Context, Span } from "@opentelemetry/api";
|
|
3
|
+
import type { ITracer, ITracerDynamicImports, ITracerParams } from "./types";
|
|
4
|
+
import { TracerDynamicImportStatus } from "./types";
|
|
5
|
+
import type { Milliseconds } from "../utils";
|
|
5
6
|
export declare class Tracer implements ITracer {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
7
|
+
private readonly dynamicImportTimeout;
|
|
8
|
+
protected span: Span;
|
|
9
|
+
protected context: Context;
|
|
10
|
+
protected childTracers: ITracer[];
|
|
11
|
+
protected initPromise: Promise<void>;
|
|
12
|
+
protected static rootTracer: OtlpTracer;
|
|
13
|
+
protected static dynamicImportStatus: TracerDynamicImportStatus;
|
|
14
|
+
protected static dynamicImports: ITracerDynamicImports;
|
|
15
|
+
protected static dynamicImportPromise: Promise<void>;
|
|
16
|
+
protected constructor({ name, getParentContext }: ITracerParams);
|
|
17
|
+
protected init({ name, getParentContext }: ITracerParams, startTime: Milliseconds): void;
|
|
18
|
+
private loadOpentelemetry;
|
|
19
|
+
protected isComponentTracerNotInitialized(): boolean;
|
|
20
|
+
log(name: string, attributes?: Attributes): void;
|
|
21
|
+
error(name: string, attributes?: Attributes): void;
|
|
22
|
+
critical(name: string, attributes?: Attributes): void;
|
|
23
|
+
createComponentTracer(name: string): ITracer;
|
|
24
|
+
end(): void;
|
|
24
25
|
}
|
package/types/Tracer/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { TracerFactory } from
|
|
2
|
-
export { ITracer, IRootTracer } from
|
|
3
|
-
export { getTraceSubscriptionMethod } from
|
|
1
|
+
export { TracerFactory } from "./TracerFactory";
|
|
2
|
+
export type { ITracer, IRootTracer } from "./types";
|
|
3
|
+
export { getTraceSubscriptionMethod } from "./utils";
|
package/types/Tracer/types.d.ts
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import type { Attributes, Context } from
|
|
2
|
-
import type { ReadableSpan } from
|
|
3
|
-
import type * as TracerOpentelemetry from
|
|
4
|
-
import type * as OpentelemetryApi from
|
|
5
|
-
import type * as OpentelemetrySdk from
|
|
1
|
+
import type { Attributes, Context } from "@opentelemetry/api";
|
|
2
|
+
import type { ReadableSpan } from "@opentelemetry/sdk-trace-web";
|
|
3
|
+
import type * as TracerOpentelemetry from "@apptracer/opentelemetry";
|
|
4
|
+
import type * as OpentelemetryApi from "@opentelemetry/api";
|
|
5
|
+
import type * as OpentelemetrySdk from "@opentelemetry/sdk-trace-web";
|
|
6
6
|
export type { TracerOpentelemetry };
|
|
7
7
|
export type { OpentelemetryApi };
|
|
8
8
|
export type { OpentelemetrySdk };
|
|
9
9
|
export declare enum TracerDynamicImportStatus {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
NotStarted = "not_started",
|
|
11
|
+
InProgress = "in_progress",
|
|
12
|
+
Failed = "failed",
|
|
13
|
+
Completed = "completed"
|
|
14
14
|
}
|
|
15
15
|
export declare enum TraceEventType {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
Log = "log",
|
|
17
|
+
Error = "error",
|
|
18
|
+
Critical = "critical"
|
|
19
19
|
}
|
|
20
20
|
export interface ITracerParams {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
name: string;
|
|
22
|
+
getParentContext?: () => Context;
|
|
23
23
|
}
|
|
24
24
|
export interface ITracerDynamicImports {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
opentelemetryApi: typeof OpentelemetryApi;
|
|
26
|
+
opentelemetrySdk: typeof OpentelemetrySdk;
|
|
27
|
+
tracer: typeof TracerOpentelemetry;
|
|
28
28
|
}
|
|
29
29
|
export interface ITracer {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
log: (name: string, attributes?: Attributes) => void;
|
|
31
|
+
error: (name: string, attributes?: Attributes) => void;
|
|
32
|
+
critical: (name: string, attributes?: Attributes) => void;
|
|
33
|
+
createComponentTracer: (name: string) => ITracer;
|
|
34
|
+
end: () => void;
|
|
35
35
|
}
|
|
36
36
|
export interface IRootTracer extends ITracer {
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
getFinishedSpans: () => ReadableSpan[] | undefined;
|
|
38
|
+
getTraceId: () => string;
|
|
39
39
|
}
|
package/types/Tracer/utils.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Attributes } from
|
|
2
|
-
export declare const getTraceSubscriptionMethod: (log: (name: string, attributes?: Attributes) => void) => (name: string) => (value:
|
|
1
|
+
import type { Attributes } from "@opentelemetry/api";
|
|
2
|
+
export declare const getTraceSubscriptionMethod: (log: (name: string, attributes?: Attributes) => void) => ((name: string) => (value: unknown) => void);
|
|
3
3
|
export declare const replaceUnsupportedValuesByStrings: (obj?: Attributes | undefined) => Attributes;
|
package/types/devNull.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
type DevNullValueArray<T> = [T?, T?, T?, T?, T?, T?, T?, T?, T?, T?, T?, T?, T?, T?, T?, T?];
|
|
2
2
|
export interface DevNullEntry {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
key: string;
|
|
4
|
+
json?: string;
|
|
5
|
+
strings?: DevNullValueArray<string>;
|
|
6
|
+
numbers?: DevNullValueArray<number>;
|
|
7
7
|
}
|
|
8
8
|
type Callback = (entry: DevNullEntry) => void;
|
|
9
9
|
type TempStorage = DevNullEntry[];
|
package/types/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export { VERSION } from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * as devNull from
|
|
10
|
-
export { DevNullEntry } from
|
|
11
|
-
export * from
|
|
1
|
+
export { VERSION } from "./env";
|
|
2
|
+
export * from "./Logger";
|
|
3
|
+
export * from "./Tracer";
|
|
4
|
+
export * from "./utils";
|
|
5
|
+
export * from "./reactive";
|
|
6
|
+
export * from "./types";
|
|
7
|
+
export * from "./translation";
|
|
8
|
+
export * from "./InternalsExposure";
|
|
9
|
+
export * as devNull from "./devNull";
|
|
10
|
+
export type { DevNullEntry } from "./devNull";
|
|
11
|
+
export * from "./AppTracer";
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import type { IEmitter, IListener, IObservable, IOperator, ISubscription, IUnsubscriber } from
|
|
1
|
+
import type { IEmitter, IListener, IObservable, IOperator, ISubscription, IUnsubscriber } from "./types";
|
|
2
2
|
export default class Observable<T> implements IObservable<T> {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
private suppressErrors;
|
|
4
|
+
constructor(subscribe?: (emitter: IEmitter<T>) => IUnsubscriber | ISubscription | void);
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Глушить ошибки не стоит.
|
|
7
|
+
* Раньше у нас они по-умолчанию ошибочно глушились что маскировало многие исключения, в том числе грубые ошибки
|
|
8
|
+
* Этот метод нужен чтобы временно поддержать старрое поведение пока маскиуремые ошибки не исправятся
|
|
9
|
+
*/
|
|
10
|
+
setSuppressErrors(suppress: boolean): void;
|
|
11
|
+
subscribe(listener: IListener<T>, error?: IListener<Error | unknown>): ISubscription;
|
|
12
|
+
pipe<K = unknown>(...operators: IOperator<unknown, unknown>[]): IObservable<K>;
|
|
13
|
+
protected _subscribe(_emitter: IEmitter<T>): IUnsubscriber | ISubscription | void;
|
|
14
14
|
}
|